![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
document no. u17473ej1v0ud00 (1st edition) date published june 2005 ns cp(k) printed in japan 2005 pd78f0393 pd78f0395 pd78f0397 pd78f0397d 78k0/lg2 8-bit single-chip microcontrollers preliminary user?s manual
preliminary user?s manual u17473ej1v0ud 2 [memo] preliminary user?s manual u17473ej1v0ud 3 1 2 3 4 voltage application waveform at input pin waveform distortion due to input noise or a reflected wave may cause malfunction. if the input of the cmos device stays in the area between v il (max) and v ih (min) due to noise, etc., the device may malfunction. take care to prevent chattering noise from entering the device when the input level is fixed, and also in the transition period when the input level passes through the area between v il (max) and v ih (min). handling of unused input pins unconnected cmos device inputs can be cause of malfunction. if an input pin is unconnected, it is possible that an internal input level may be generated due to noise, etc., causing malfunction. cmos devices behave differently than bipolar or nmos devices. input levels of cmos devices must be fixed high or low by using pull-up or pull-down circuitry. each unused pin should be connected to v dd or gnd via a resistor if there is a possibility that it will be an output pin. all handling related to unused pins must be judged separately for each device and according to related specifications governing the device. precaution against esd a strong electric field, when exposed to a mos device, can cause destruction of the gate oxide and ultimately degrade the device operation. steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it when it has occurred. environmental control must be adequate. when it is dry, a humidifier should be used. it is recommended to avoid using insulators that easily build up static electricity. semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. all test and measurement tools including work benches and floors should be grounded. the operator should be grounded using a wrist strap. semiconductor devices must not be touched with bare hands. similar precautions need to be taken for pw boards with mounted semiconductor devices. status before initialization power-on does not necessarily define the initial status of a mos device. immediately after the power source is turned on, devices with reset functions have not yet been initialized. hence, power-on does not guarantee output pin levels, i/o settings or contents of registers. a device is not initialized until the reset signal is received. a reset operation must be executed immediately after power-on for devices with reset functions. power on/off sequence in the case of a device that uses different power supplies for the internal operation and external interface, as a rule, switch on the external power supply after switching on the internal power supply. when switching the power supply off, as a rule, switch off the external power supply and then the internal power supply. use of the reverse power on/off sequences may result in the application of an overvoltage to the internal elements of the device, causing malfunction and degradation of internal elements due to the passage of an abnormal current. the correct power on/off sequence must be judged separately for each device and according to related specifications governing the device. input of signal during power off state do not input signals or an i/o pull-up power supply while the device is not powered. the current injection that results from input of such a signal or i/o pull-up power supply may cause malfunction and the abnormal current that passes in the device at this time may cause degradation of internal elements. input of signals during the power off state must be judged separately for each device and according to related specifications governing the device. notes for cmos devices 5 6 preliminary user?s manual u17473ej1v0ud 4 eeprom is a trademark of nec electronics corporation. windows and windows nt are either registered trademarks or trademar ks of microsoft corporation in the united states and/or other countries. pc/at is a trademark of internati onal business machines corporation. hp9000 series 700 and hp-ux are trademarks of hewlett-packard company. sparcstation is a trademark of sparc international, inc. solaris and sunos are trademar ks of sun microsystems, inc. superflash ? is a registered tradem ark of silicon storage technology, inc. in several countries including the united states and japan. caution: this product uses superflash ? technology licensed from silicon storage technology, inc. the information contained in this document is being issued in advance of the production cycle for the product. the parameters for the product may change before final production or nec electronics corporation, at its own discretion, may withdraw the product prior to its production. not all products and/or types are available in every country. please check with an nec electronics sales representative for availability and additional information. no part of this document may be copied or reproduced in any form or by any means without the prior written consent of nec electronics. nec electronics assumes no responsibility for any errors that may appear in this document. nec electronics does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from the use of nec electronics products listed in this document or any other liability arising from the use of such products. no license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of nec electronics or others. descriptions of circuits, software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples. the incorporation of these circuits, software and information in the design of a customer's equipment shall be done under the full responsibility of the customer. nec electronics assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits, software and information. while nec electronics endeavors to enhance the quality, reliability and safety of nec electronics products, customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. to minimize risks of damage to property or injury (including death) to persons arising from defects in nec electronics products, customers must incorporate sufficient safety measures in their design, such as redundancy, fire-containment and anti-failure features. nec electronics products are classified into the following three quality grades: "standard", "special" and "specific". the "specific" quality grade applies only to nec electronics products developed based on a customer-designated "quality assurance program" for a specific application. the recommended applications of an nec electronics products depend on its quality grade, as indicated below. customers must check the quality grade of each nec electronics product before using it in a particular application. ? ? ? ? ? ? ? m5d 02. 11-1 the quality grade of nec electronics products is "standard" unless otherwise expressly specified in nec electronics data sheets or data books, etc. if customers wish to use nec electronics products in applications not intended by nec electronics, they must contact an nec electronics sales representative in advance to determine nec electronics' willingness to support a given application. (note) (1) (2) "nec electronics" as used in this statement means nec electronics corporation and also includes its majority-owned subsidiaries. "nec electronics products" means any product developed or manufactured by or for nec electronics (as defined above). computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots. transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support). aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems and medical equipment for life support, etc. "standard": "special": "specific": preliminary user?s manual u17473ej1v0ud 5 regional information ? device availability ? ordering information ? product release schedule ? availability of related technical literature ? development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, ac supply voltages, and so forth) ? network requirements in addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country. [global support] http://www.necel.com/en/support/support.html nec electronics america, inc. (u.s.) santa clara, california tel: 408-588-6000 800-366-9782 nec electronics hong kong ltd. hong kong tel: 2886-9318 nec electronics hong kong ltd. seoul branch seoul, korea tel: 02-558-3737 nec electronics shanghai ltd. shanghai, p.r. china tel: 021-5888-5400 nec electronics taiwan ltd. taipei, taiwan tel: 02-2719-2377 nec electronics singapore pte. ltd. novena square, singapore tel: 6253-8311 j05.6 n ec electronics (europe) gmbh duesseldorf, germany tel: 0211-65030 ? sucursal en espa?a madrid, spain tel: 091-504 27 87 vlizy-villacoublay, france tel: 01-30-67 58 00 ? succursale fran?aise ? filiale italiana milano, italy tel: 02-66 75 41 ? branch the netherlands eindhoven, the netherlands tel: 040-265 40 10 ? tyskland filial taeby, sweden tel: 08-63 87 200 ? united kingdom branch milton keynes, uk tel: 01908-691-133 some information contained in this document may vary from country to country. before using any nec electronics product in your application, piease contact the nec electronics office in your country to obtain a list of authorized representatives and distributors. they will verify: preliminary user?s manual u17473ej1v0ud 6 introduction readers this manual is intended for user engineer s who wish to understand the functions of the 78k0/lg2 and design and develop application systems and programs for these devices. the target products are as follows. 78k0/lg2: pd78f0393, 78f0395, 78f0397, 78f0397d purpose this manual is intended to give users an understanding of the functions described in the organization below. organization the 78k0/lg2 manual is separated into two parts: this manual and the instructions edition (common to the 78k/0 series). 78k0/lg2 user?s manual (this manual) 78k/0 series user?s manual instructions ? pin functions ? internal block functions ? interrupts ? other on-chip peripheral functions ? electrical specifications (target) ? cpu functions ? instruction set ? explanation of each instruction how to read this manual it is assumed that the readers of this ma nual have general knowledge of electrical engineering, logic circuits, and microcontrollers. ? to gain a general understanding of functions: read this manual in the order of the contents . ? how to interpret the register format: for a bit number enclosed in angle brackets, the bit name is defined as a reserved word in the ra78k0, and is defined as an sfr variable using the #pragma sfr directive in the cc78k0. ? to check the details of a register when you know the register name: refer to appendix b register index . ? to know details of the 78k/0 series instructions: refer to the separate document 78k/0 series instructions user?s manual (u12326e) . preliminary user?s manual u17473ej1v0ud 7 conventions data significance: higher digits on the left and lower digits on the right active low representations: (overscore over pin and signal name) note : footnote for item marked with note in the text caution : information requiring particular attention remark : supplementary information numerical representations: binary ... or b decimal ... hexadecimal ... h related documents the related documents indicated in this pu blication may include preliminary versions. however, preliminary versions are not marked as such. documents related to devices document name document no. 78k0/lg2 user?s manual this manual 78k/0 series instructions user?s manual u12326e documents related to development tools (software) (user?s manuals) document name document no. operation u17199e language u17198e ra78k0 ver. 3.80 assembler package structured assembly language u17197e operation u17201e cc78k0 ver. 3.70 c compiler language u17200e id78k0-qb ver. 2.90 integrat ed debugger operation u17437e pm plus ver. 5.20 u16934e documents related to development tools (hardware) (user?s manuals) document name document no. qb-78k0lx2 in-circuit emulator u17468e qb-78k0mini on-chip debug emulator u17029e documents related to fl ash memory programming document name document no. pg-fp4 flash memory programmer user?s manual u15260e caution the related documents listed above are subject to change without notice. be sure to use the latest version of each document when designing. preliminary user?s manual u17473ej1v0ud 8 other documents document name document no. semiconductor selection guide ? products and packages ? x13769x semiconductor device mount manual note quality grades on nec semiconductor devices c11531e nec semiconductor device reliability/quality control system c10983e guide to prevent damage for semiconductor devi ces by electrostatic discharge (esd) c11892e note see the ?semiconductor device m ount manual? website (h ttp://www.necel.com/pkg/en/mount/index.html). caution the related documents listed above are subject to change without notice. be sure to use the latest version of each document when designing. preliminary user?s manual u17473ej1v0ud 9 contents chapter 1 outline ........................................................................................................... ................. 17 1.1 features ................................................................................................................... ................. 17 1.2 applications ............................................................................................................... .............. 18 1.3 ordering information ....................................................................................................... ........ 19 1.4 pin configuration (top view).................................. ............................................................. ... 20 1.5 78k0/lx2 series lineup..................................................................................................... ...... 23 1.6 block diagram.............................................................................................................. ............ 25 1.7 outline of functions ....................................................................................................... ......... 26 chapter 2 pin functions .................................................................................................... ........... 29 2.1 pin function list.......................................................................................................... ............ 29 2.2 description of pin functions .................................... ........................................................... ... 33 2.2.1 p00 to p06 (por t 0)...................................................................................................... ...............33 2.2.2 p10 to p17 (por t 1)...................................................................................................... ...............34 2.2.3 p20 to p27 (por t 2)...................................................................................................... ...............35 2.2.4 p30 to p33 (por t 3)...................................................................................................... ...............35 2.2.5 p70 to p77 (por t 7)...................................................................................................... ...............36 2.2.6 p120 to p124 (por t 12)................................................................................................... ............36 2.2.7 sda0..................................................................................................................... .....................37 2.2.8 scl0 ..................................................................................................................... .....................37 2.2.9 av ref ............................................................................................................................... ..........37 2.2.10 av ss ............................................................................................................................... ............37 2.2.11 s0 to s39 ............................................................................................................... ....................37 2.2.12 com0 to com3 ............................................................................................................ .............37 2.2.13 lv dd ............................................................................................................................... ............37 2.2.14 lv ss ............................................................................................................................... ............37 2.2.15 v lc0 to v lc2 ............................................................................................................................... .37 2.2.16 c aph, c apl.............................................................................................................. ................37 2.2.17 reset ................................................................................................................... ....................37 2.2.18 regc.................................................................................................................... .....................38 2.2.19 v dd ............................................................................................................................... ..............38 2.2.20 v ss ............................................................................................................................... ..............38 2.2.21 flmd0 ................................................................................................................... ....................38 2.3 pin i/o circuits and recommended connection of unused pins....................................... 39 chapter 3 cpu architecture ................................................................................................. ..... 43 3.1 memory space............................................................................................................... ........... 43 3.1.1 internal progr am memory space ............................................................................................ ....48 3.1.2 bank area ( pd78f0397 and 78f039 7d only ) ..........................................................................50 3.1.3 internal data memory space............................................................................................... ........51 3.1.4 special function register (s fr) area ..................................................................................... .....52 3.1.5 data memo ry addre ssing ................................................................................................... ........52 3.2 processor registers ........................................................................................................ ........ 56 3.2.1 control registers........................................................................................................ .................56 preliminary user?s manual u17473ej1v0ud 10 3.2.2 general-purpo se regi sters................................................................................................ ......... 60 3.2.3 special function register s (sfrs) ........................................................................................ ...... 61 3.3 instruction address addressing ..................................... ....................................................... 6 6 3.3.1 relative addre ssing ...................................................................................................... ............. 66 3.3.2 immediat e addre ssing ..................................................................................................... .......... 67 3.3.3 table indi rect addr essing ................................................................................................ .......... 68 3.3.4 register addre ssing ...................................................................................................... ............ 68 3.4 operand address addre ssing ................................................................................................ 6 9 3.4.1 impli ed addres sing ....................................................................................................... ............. 69 3.4.2 register addre ssing ...................................................................................................... ............ 70 3.4.3 direct addre ssing ........................................................................................................ .............. 71 3.4.4 short dire ct addressing .................................................................................................. ........... 72 3.4.5 special function r egister (sfr ) addre ssing ............................................................................... 73 3.4.6 register i ndirect addr essing............................................................................................. ......... 74 3.4.7 based addres sing......................................................................................................... ............. 75 3.4.8 based index ed addres sing ................................................................................................. ....... 76 3.4.9 stack addressi ng......................................................................................................... .............. 77 chapter 4 port functions ................................................................................................... ........ 78 4.1 port functions ............................................................................................................. ............. 78 4.2 port configurat ion ......................................................................................................... .......... 80 4.2.1 port 0................................................................................................................... ...................... 81 4.2.2 port 1................................................................................................................... ...................... 87 4.2.3 port 2................................................................................................................... ...................... 92 4.2.4 port 3................................................................................................................... ...................... 94 4.2.5 port 7................................................................................................................... ...................... 96 4.2.6 po rt 12.................................................................................................................. ..................... 97 4.3 registers controlling port functi on ...................................................................................... 99 4.4 port function operations................................................. .................................................. ... 103 4.4.1 writing to i/o port ...................................................................................................... ...............103 4.4.2 reading from i/o port.................................................................................................... ...........103 4.4.3 operatio ns on i/o port................................................................................................... ...........103 4.5 settings of port mode register and output latch when using alternate function....... 104 chapter 5 clock generator .................................................................................................. .. 106 5.1 functions of clock generator....................................... ........................................................ 106 5.2 configuration of clock genera tor ........................................................................................ 107 5.3 registers controlling clock generator ....................... ........................................................ 109 5.4 system clock oscillator .................................................................................................... .... 118 5.4.1 x1 o scillat or............................................................................................................ ..................118 5.4.2 xt1 o scillato r ........................................................................................................... ................118 5.4.3 when subsystem clock is not us ed ......................................................................................... .121 5.4.4 high-speed ri ng-osc osci llator........................................................................................... ....121 5.4.5 low-speed rin g-osc osc illator ............................................................................................ ...121 5.4.6 pre scaler ................................................................................................................ ..................121 5.5 clock generator operation .............................................. .................................................... . 122 5.6 controlling clock .......................................................................................................... ......... 124 5.6.1 example of controlling high-speed system cloc k ......................................................................124 preliminary user?s manual u17473ej1v0ud 11 5.6.2 example of controlling high-speed ring-osc cl ock.................................................................127 5.6.3 example of contro lling subsyste m clock................................................................................... 129 5.6.4 example of controlling low-speed ring-os c cloc k ..................................................................131 5.6.5 clocks supplied to cp u and peripheral hardwar e....................................................................132 5.6.6 cpu clock status transitio n diagr am ...................................................................................... ..133 5.6.7 condition bef ore changing cpu clock and processing after c hanging cpu clock ...................138 5.6.8 time required for switchover of cpu clock and main system cl ock .........................................139 5.6.9 conditions before clock oscillation is stopped..........................................................................1 40 5.6.10 peripheral hard ware and sour ce clo cks .................................................................................14 1 chapter 6 16-bit timer/event counters 00 and 01 ........................................................ 142 6.1 functions of 16-bit time r/event counters 00 and 01 ............... ......................................... 142 6.2 configuration of 16-bit timer/ event counters 00 and 01................. ................................. 143 6.3 registers controlling 16-bit ti mer/event counters 00 and 01 ........ ................................. 148 6.4 operation of 16-bit timer/event counters 00 and 01 ........................................................ 159 6.4.1 interval ti mer operation ................................................................................................. ...........159 6.4.2 ppg output operations.................................................................................................... .........162 6.4.3 pulse width meas urement ope rations ......................................................................................1 65 6.4.4 external event counter o peration ......................................................................................... ....173 6.4.5 square-wave output oper ation ............................................................................................. ....176 6.4.6 one-shot puls e output op eration.......................................................................................... ....178 6.5 cautions for 16-bit timer/event counters 00 and 01......................................................... 183 chapter 7 8-bit timer/event counters 50 and 51 .......................................................... 186 7.1 functions of 8-bit time r/event counters 50 and 51 ................. ......................................... 186 7.2 configuration of 8-bit timer/ event counters 50 and 51................. ................................... 188 7.3 registers controlling 8- bit timer/event c ounters 50 and 51 ................... ........................ 190 7.4 operations of 8-bit timer/event counters 50 an d 51 ........................................................ 195 7.4.1 operation as interval timer .............................................................................................. .........195 7.4.2 operation as ex ternal event count er ...................................................................................... ..197 7.4.3 square-wave output oper ation ............................................................................................. ....198 7.4.4 pwm output operat ion ..................................................................................................... ........199 7.5 cautions for 8-bit timer/event counters 50 and 51........................................................... 203 chapter 8 8-bit timers h0 and h1 ........................................................................................ .. 204 8.1 functions of 8-bit timers h0 and h1................................................................................... 204 8.2 configuration of 8-bit timers h0 and h1 ............. ............................................................... 204 8.3 registers controlling 8-bit timers h0 and h1.................................................................... 208 8.4 operation of 8-bit timers h0 and h1 ..................... .............................................................. 213 8.4.1 operation as interval timer/square-wa ve out put....................................................................... 213 8.4.2 operation as pwm output mode ............................................................................................. .216 8.4.3 carrier generator mode oper ation (8-bit ti mer h1 only) ............................................................222 chapter 9 watch timer ...................................................................................................... ......... 229 9.1 functions of watch timer......................................... .......................................................... .. 229 9.2 configuration of watch timer .................................. ............................................................ 2 30 9.3 register controlling watch timer............................ ............................................................ 231 preliminary user?s manual u17473ej1v0ud 12 9.4 watch timer operations..................................................................................................... ... 233 9.4.1 watch time r operation .................................................................................................... ..........233 9.4.2 interval ti mer operation................................................................................................. ............234 9.5 cautions for watch timer ................................................................................................... .. 235 chapter 10 watchdog timer .................................................................................................. ... 236 10.1 functions of watchdog timer .............................................................................................. 2 36 10.2 configuration of watchdog timer ................................ ........................................................ 237 10.3 register controlling watchdog timer ......................... ........................................................ 238 10.4 operation of watchdog timer............................................................................................... 239 10.4.1 controlling operat ion of watc hdog ti mer ................................................................................. ..239 10.4.2 setting overflow ti me of watc hdog ti mer................................................................................. ..240 10.4.3 setting window open period of watchdo g time r ........................................................................241 chapter 11 clock output controller ............................................................................... 243 11.1 functions of clock outp ut controller.................................................................................. 243 11.2 configuration of clock output controller ........................................................................... 244 11.3 registers controlling clock output controller................................................................... 244 11.4 operations of clock output controller................................................................................ 246 chapter 12 a/d converter ................................................................................................... ...... 247 12.1 function of a/d converter ................................................................................................. ... 247 12.2 configuration of a/d converter .............................. .............................................................. 248 12.3 registers used in a/d converter.......................................................................................... 2 50 12.4 a/d converter operations .................................................................................................. ... 258 12.4.1 basic operations of a/d c onverter ....................................................................................... .....258 12.4.2 input volt age and conversi on results .................................................................................... ....260 12.4.3 a/d converte r operati on mode ............................................................................................ .....261 12.5 how to read a/d converter char acteristics table............................................................. 263 12.6 cautions for a/d converter................................................................................................ ... 265 chapter 13 serial interface uart0 ...................................................................................... 269 13.1 functions of serial interface uart0............................ ........................................................ 269 13.2 configuration of serial interf ace uart0 ............................................................................. 270 13.3 registers controlling serial in terface uart0..................................................................... 273 13.4 operation of serial interface uart0.......................... .......................................................... 278 13.4.1 operatio n stop mode ..................................................................................................... ...........278 13.4.2 asynchronous serial interface (uar t) m ode ........................................................................... 279 13.4.3 dedicated baud rate generator........................................................................................... ......285 chapter 14 serial interface uart6 ...................................................................................... 290 14.1 functions of serial interface uart6............................ ........................................................ 290 14.2 configuration of serial interf ace uart6 ............................................................................. 294 14.3 registers controlling serial in terface uart6..................................................................... 297 14.4 operation of serial interface uart6.......................... .......................................................... 306 14.4.1 operatio n stop mode ..................................................................................................... ...........306 preliminary user?s manual u17473ej1v0ud 13 14.4.2 asynchronous serial interface (uar t) m ode ........................................................................... 307 14.4.3 dedicated baud rate generator ........................................................................................... .....321 chapter 15 serial interfaces csi10 and csi11................................................................ 328 15.1 functions of serial interfaces csi 10 and csi11 ................................................................. 328 15.2 configuration of serial interfaces csi10 and csi1 1 .......................................................... 329 15.3 registers controlling serial interfaces csi10 a nd csi11.................................................. 331 15.4 operation of serial interfaces cs i10 and csi11 ................................................................. 336 15.4.1 operatio n stop mode..................................................................................................... ...........336 15.4.2 3-wire se rial i/o mode .................................................................................................. ............337 chapter 16 serial interface iic0 .......................................................................................... . 347 16.1 functions of serial interface iic0............................. ........................................................... . 347 16.2 configuration of serial interfac e iic0 .................................................................................. 35 0 16.3 registers to control serial interface iic0............. ............................................................... 353 16.4 i 2 c bus mode functions ........................................................................................................ 366 16.4.1 pin conf iguration ....................................................................................................... ...............366 16.5 i 2 c bus definitions and control methods................... ......................................................... 367 16.5.1 start conditi ons ........................................................................................................ ................367 16.5.2 addr esses ............................................................................................................... .................368 16.5.3 transfer direct ion specif ication ........................................................................................ ........368 16.5.4 acknowled ge (ack) signal................................................................................................ .......369 16.5.5 stop c onditio n .......................................................................................................... ................370 16.5.6 wait si gnal (w ait) ...................................................................................................... .............371 16.5.7 interrupt request (intiic0) generation timing and wa it cont rol.................................................373 16.5.8 address matc h detection method.......................................................................................... ...374 16.5.9 error detection ......................................................................................................... ................374 16.5.10 ext ension code ......................................................................................................... ...............374 16.5.11 arbi tration............................................................................................................ .....................375 16.5.12 wake- up func tion ....................................................................................................... ..............376 16.5.13 communicati on reservation .............................................................................................. .......377 16.5.14 other caut ions ......................................................................................................... .................380 16.5.15 communica tion oper ations ............................................................................................... .......381 16.5.16 timing of i 2 c interrupt request (i ntiic0) occu rrence ...............................................................386 16.6 timing charts............................................................................................................. ............ 405 16.7 communication with lcd controller/driver ........... ............................................................ 412 16.7.1 system c onfiguration.................................................................................................... ............412 16.7.2 write operatio n......................................................................................................... ................413 16.7.3 read operatio n .......................................................................................................... ..............416 chapter 17 lcd controller/driver....................................................................................... 420 17.1 functions of lcd contro ller/driver ..................................................................................... 420 17.2 configuration of lcd controller/ driver............................................................................... 421 17.3 registers controlling lcd controller/driver .......... ............................................................ 424 17.4 setting lcd controller/driver............................................................................................. .. 430 17.5 lcd display data memory ................................................................................................... . 432 17.6 common and segment signals .................................... ........................................................ 433 preliminary user?s manual u17473ej1v0ud 14 17.7 display modes ............................................................................................................. ........... 437 17.7.1 static di splay ex ample.................................................................................................. ............437 17.7.2 two-time-slice display ex ample.......................................................................................... ......440 17.7.3 three-time-slice display example ........................................................................................ .....443 17.7.4 four-time-slic e display example ......................................................................................... ......447 17.8 supplying lcd drive voltages v lc0 , v lc1 , and v lc2 ............................................................. 450 17.8.1 internal resistan ce division method ..................................................................................... .....450 17.8.2 external resist ance divisi on met hod ..................................................................................... ....452 17.8.3 internal volt age boosting method ........................................................................................ .....453 chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only).............. 454 18.1 functions of multiplier/divider ............................... ............................................................ .. 454 18.2 configuration of multiplier/d ivider ....................................................................................... 454 18.3 register controlling multiplie r/divider ................................................................................ 458 18.4 operations of multiplier/divi der.......................................................................................... .. 459 18.4.1 multiplicati on operation................................................................................................ .............459 18.4.2 division operat ion...................................................................................................... ...............461 chapter 19 interrupt functions ............................................................................................ 4 63 19.1 interrupt function types.................................................................................................. ..... 463 19.2 interrupt sources and configuration ........................... ........................................................ 463 19.3 registers controlling interrupt functions .......................................................................... 467 19.4 interrupt servicing operations ............................................................................................ . 475 19.4.1 maskable interrupt acknowl edgement ...................................................................................... 475 19.4.2 software interrupt r equest acknow ledgement ..........................................................................477 19.4.3 multiple inte rrupt servicing............................................................................................ ............478 19.4.4 interrupt request hold .................................................................................................. .............481 chapter 20 key interrupt function ..................................................................................... 482 20.1 functions of key interrupt ............................................ .................................................... .... 482 20.2 configuration of key interrupt............................................................................................ .. 482 20.3 register controlling key interrupt ............................. .......................................................... 4 83 chapter 21 standby function ................................................................................................ .. 484 21.1 standby function and configurat ion................................................................................... 484 21.1.1 standby function........................................................................................................ ...............484 21.1.2 registers contro lling standby function.................................................................................. ....485 21.2 standby function operation................................................................................................ . 487 21.2.1 halt mode ............................................................................................................... ...............487 21.2.2 stop mode ............................................................................................................... ..............492 chapter 22 reset function.................................................................................................. ...... 497 22.1 register for confirming reset source................................................................................. 505 chapter 23 power-on-clear circuit...................................................................................... 506 23.1 functions of power-on-c lear circuit ................................................................................... 506 preliminary user?s manual u17473ej1v0ud 15 23.2 configuration of power-on-clear circuit............................................................................. 507 23.3 operation of power-on-clear circuit ..................... .............................................................. 507 23.4 cautions for power-on-clear ci rcuit.................................................................................... 508 chapter 24 low-voltage detector ....................................................................................... 510 24.1 functions of low-voltage detector ..................................................................................... 510 24.2 configuration of low-voltage de tector............................................................................... 510 24.3 registers controlling low-voltage detector ...................................................................... 511 24.4 operation of low-voltage detector ......................... ............................................................ 514 24.4.1 when used as re set ...................................................................................................... ...........515 24.4.2 when used as inte rrupt .................................................................................................. ..........519 24.5 cautions for low-voltage detector.......................... ............................................................ 523 chapter 25 option byte..................................................................................................... .......... 526 chapter 26 flash memory.................................................................................................... ...... 528 26.1 internal memory size switching register ............. .............................................................. 528 26.2 bank select register ( pd78f0397 and 78f03 97d only) .................................................. 529 26.3 internal expansion ram size switching register.. ............................................................ 530 26.4 writing with flash programmer ........................................................................................... 53 0 26.5 programming environment................................................................................................... 536 26.6 communication mode ........................................................................................................ ... 536 26.7 handling of pins on board................................................................................................. ... 538 26.7.1 flmd 0 pi n ............................................................................................................... ................538 26.7.2 serial in terface pins................................................................................................... ...............538 26.7.3 reset pin ............................................................................................................... ................540 26.7.4 port pi ns............................................................................................................... ....................540 26.7.5 regc pin................................................................................................................ .................540 26.7.6 other signal pins ....................................................................................................... ...............540 26.7.7 powe r supply ............................................................................................................ ...............540 26.8 programming method........................................................................................................ .... 541 26.8.1 controllin g flash memory ................................................................................................ .........541 26.8.2 flash memory programming mode ..........................................................................................5 41 26.8.3 selecting co mmunicati on mode ............................................................................................ ...542 26.8.4 communicati on commands.................................................................................................. ....543 26.9 flash memory programming by self-writing.......... ............................................................ 544 26.10 boot swap function ....................................................................................................... ....... 547 26.10.1 outline of bo ot swap f unction.......................................................................................... .........547 chapter 27 on-chip debug function ( pd78f0397d only) ............................................ 548 27.1 security id control flag and security id.............. ............................................................... 548 chapter 28 instruction set ................................................................................................. ..... 550 28.1 conventions used in operation list...................... .............................................................. 550 28.1.1 operand identifiers and specification method s ........................................................................550 28.1.2 description of operation column......................................................................................... ......551 preliminary user?s manual u17473ej1v0ud 16 28.1.3 description of fl ag operati on colu mn .................................................................................... ....551 28.2 operation list ............................................................................................................ ............. 552 28.3 instructions listed by addressing type ................... .......................................................... 560 chapter 29 electrical specifications (target).............................................................. 563 chapter 30 package drawings ................................................................................................ 582 chapter 31 cautions for wait.............................................................................................. ... 584 31.1 cautions for wait......................................................................................................... ........... 584 31.2 peripheral hardware that generates wait ................ .......................................................... 585 appendix a development tools............................................................................................... 586 a.1 software package ........................................................................................................... ....... 589 a.2 language processing so ftware............................................................................................ 589 a.3 control software ........................................................................................................... ......... 590 a.4 flash memory writing tools ................................................................................................. 590 a.5 debugging tools (hardware) ................................................................................................ 5 91 a.5.1 when using in-circuit emulator qb -78k0lx 2 ...........................................................................591 a.5.2 when using on-c hip debug emulator qb-78k0m ini.................................................................592 a.6 debugging tools (software) ................................................................................................. 592 appendix b register index .................................................................................................. ....... 593 b.1 register index (in alphabetical order with re spect to register names) ........................ 593 b.2 register index (in alphabetical order with re spect to register symbol) ....................... 597 preliminary user?s manual u17473ej1v0ud 17 chapter 1 outline 1.1 features { minimum instruction execution time can be changed from high speed (0.1 s: @ 20 mhz operation with high- speed system clock) to ultra low-speed (122 s: @ 32.768 khz operation with subsystem clock) { general-purpose register: 8 bits 32 registers (8 bits 8 registers 4 banks) { rom, ram capacities data memory item part number program memory (rom) internal high- speed ram note internal expansion ram note lcd display ram pd78f0393 32 kb ? pd78f0395 60 kb 2 kb pd78f0397, 78f0397d flash memory note 128 kb 1 kb 6 kb 40 4 bits note the internal flash memory, internal high-speed ram capacities, and internal expansion ram capacities can be changed using the internal memory size swit ching register (ims) and the internal expansion ram size switching register (ixs). { on-chip single-power-supply flash memory { self-programming (with boot swap function) { on-chip debug function ( pd78f0397d only) { on-chip power-on-clear (poc) circuit and low-voltage detector (lvi) { short startup is possible via the cpu default start using the on-chip high-speed ring-osc { on-chip watchdog timer (operable with the on-chip low-speed ring-osc clock) { lcd controller/driver (internal voltage boosting, external resistance division, and internal resistance division are switchable) segment signals: 40, common signals: 4 { on-chip multiplier/divider ( pd78f0395, 78f0397, 78f0397d only) { on-chip key interrupt function: 8 channels { on-chip clock output controller { i/o ports: 40 { timer pd78f0393: 7 channels pd78f0395, 78f0397, 78f0397d: 8 channels { serial interface pd78f0393: 3 channels (uart (lin (local interconnect network)-bus supported): 1 channel, csi/uart note : 1 channel, i 2 c: 1 channel) pd78f0395, 78f0397, 78f0397d: 4 channels (uart (lin (local interconnect network)-bus supported: 1 channel, csi/uart note : 1 channel, csi: 1 channel, i 2 c: 1 channel) note select either of the functions of these alternate-function pins. chapter 1 outline preliminary user?s manual u17473ej1v0ud 18 { 10-bit resolution a/d converter: 8 channels { power supply voltage: v dd = 1.8 to 5.5 v { operating ambient temperature: t a = ? 40 to +85 c: (t), (s), (r) products t a = ? 40 to +125 c: (t2) products 1.2 applications aps cameras, digital cameras, av equipments, and household electrical appliances, etc. chapter 1 outline preliminary user?s manual u17473ej1v0ud 19 1.3 ordering information ? flash memory version (lead-free products) part number package pd78f0393gc(t)-8eu-a 100-pin plastic lqfp (14 14) pd78f0393gc(t2)-8eu-a 100-pin plastic lqfp (14 14) pd78f0393gc(s)-8eu-a 100-pin plastic lqfp (14 14) pd78f0393gc(r)-8eu-a 100-pin plastic lqfp (14 14) pd78f0393gf(t)-jbt-a 100-pin plastic qfp (14 20) pd78f0393gf(t2)-jbt-a 100-pin plastic qfp (14 20) pd78f0393gf(s)-jbt-a 100-pin plastic qfp (14 20) pd78f0393gf(r)-jbt-a 100-pin plastic qfp (14 20) pd78f0395gc(t)-8eu-a 100-pin plastic lqfp (14 14) pd78f0395gc(t2)-8eu-a 100-pin plastic lqfp (14 14) pd78f0395gc(s)-8eu-a 100-pin plastic lqfp (14 14) pd78f0395gc(r)-8eu-a 100-pin plastic lqfp (14 14) pd78f0395gf(t)-jbt-a 100-pin plastic qfp (14 20) pd78f0395gf(t2)-jbt-a 100-pin plastic qfp (14 20) pd78f0395gf(s)-jbt-a 100-pin plastic qfp (14 20) pd78f0395gf(r)-jbt-a 100-pin plastic qfp (14 20) pd78f0397gc(t)-8eu-a 100-pin plastic lqfp (14 14) pd78f0397gc(t2)-8eu-a 100-pin plastic lqfp (14 14) pd78f0397gc(s)-8eu-a 100-pin plastic lqfp (14 14) pd78f0397gc(r)-8eu-a 100-pin plastic lqfp (14 14) pd78f0397gf(t)-jbt-a 100-pin plastic qfp (14 20) pd78f0397gf(t2)-jbt-a 100-pin plastic qfp (14 20) pd78f0397gf(s)-jbt-a 100-pin plastic qfp (14 20) pd78f0397gf(r)-jbt-a 100-pin plastic qfp (14 20) pd78f0397dgc(t)-8eu-a note 100-pin plastic lqfp (14 14) pd78f0397dgf(t)-jbt-a note 100-pin plastic qfp (14 20) note es (engineering sample) version only. remark (t), (t2) : general management (s) : management based on individual contract (r) : management for automotive accessories chapter 1 outline preliminary user?s manual u17473ej1v0ud 20 1.4 pin configuration (top view) ? 100-pin plastic lqfp (14 14) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 p11/si10/rxd0 p12/so10 p13/txd6 p14/rxd6 p15/toh0 p16/toh1/intp5 p17/ti50/to50 p30/intp1 p31/intp2 p32/intp3 lv dd lv ss s39 s38 s37 s36 s35 s34 s33 s32 s31 s30 s29 s28 s27 p76/kr6 p75/kr5 p74/kr4 p73/kr3 p72/kr2 p71/kr1 p70/kr0 p06/ti011 /to01 p05/ti001 /ssi11 p00/ti000 p01/ti010/to00 p02/so11 p03/si11 p04/sck11 p20/ani0 p21/ani1 p22/ani2 p23/ani3 p24/ani4 p25/ani5 p26/ani6 p27/ani7 av ss av ref p10/sck10/txd0 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 s21 s22 s23 s24 s25 s26 p77/kr7 p120/intp0/exlvi p33/intp4/ti51/to51 sda0 scl0 reset p124/xt2/exclks p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss v dd caph capl v lc0 v lc1 v lc2 com0 com1 com2 com3 s0 s1 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 note note note note note note note note so11, si11, sck11, ssi11 , ti001, ti011, and to01 are available only in the pd78f0395, 78f0397, and 78f0397d. cautions 1. connect the av ss pin to v ss . 2. connect the regc pin to v ss via a capacitor (0.47 f: target). 3. p20/ani0 to p27/ani7 are set in the analog input mode after release of reset. chapter 1 outline preliminary user?s manual u17473ej1v0ud 21 ? 100-pin plastic qfp (14 20) av ref p10/sck10/txd0 p11/si10/rxd0 p12/so10 p13/txd6 p14/rxd6 p15/toh0 p16/toh1/intp5 p17/ti50/to50 p30/intp1 p31/intp2 p32/intp3 lv dd lv ss s39 s38 s37 s36 s35 s34 s33 s32 s31 s30 s29 s28 s27 s26 s25 s24 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 s21 s22 s23 p73/kr3 p72/kr2 p71/kr1 p70/kr0 p06/ti011 /to01 p05/ti001 /ssi11 p00/ti000 p01/ti010/to00 p02/so11 p03/si11 p04/sck11 p20/ani0 p21/ani1 p22/ani2 p23/ani3 p24/ani4 p25/ani5 p26/ani6 p27/ani7 av ss p74/kr4 p75/kr5 p76/kr6 p77/kr7 p120/intp0/exlvi p33/intp4/ti51/to51 sda0 scl0 reset p124/xt2/exclks p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss v dd caph capl v lc0 v lc1 v lc2 com0 com1 com2 com3 s0 s1 s2 s3 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 note note note note note note note note so11, si11, sck11, ssi11 , ti001, ti011, and to01 are available only in the pd78f0395, 78f0397, and 78f0397d. cautions 1. connect the av ss pin to v ss . 2. connect the regc pin to v ss via a capacitor (0.47 f: target). 3. p20/ani0 to p27/ani7 are set in the analog input mode after release of reset. chapter 1 outline preliminary user?s manual u17473ej1v0ud 22 pin identification ani0 to ani7: analog input av ref : analog reference voltage av ss : analog ground caph, capl: lcd power supply capacitance control com0 to com3: common output exclk: external clock input (main system clock) exclks: external clock input (subsystem clock) exlvi: external potential input for low-voltage detector flmd0: flash programming mode intp0 to intp5: external interrupt input kr0 to kr7: key return lv dd : power supply for lcd controller/driver lv ss : ground for lcd controller/driver p00 to p06: port 0 p10 to p17: port 1 p20 to p27: port 2 p30 to p33: port 3 p70 to p77: port 7 p120 to p124: port 12 regc regulator capacitance reset: reset rxd0, rxd6: receive data s0 to s39: segment output sck10, sck11 note , scl0: serial clock input/output sda0: serial data input/output si10, si11 note : serial data input so10, so11 note : serial data output ssi11 note : serial interface chip select input ti000, ti010, ti001 note , ti011 note , ti50, ti51: timer input to00, to01 note , to50, to51, toh0, toh1: timer output txd0, txd6: transmit data v dd : power supply v ss : ground v lc0 to v lc2 : lcd power supply x1, x2: crystal oscillat or (main system clock) xt1, xt2: crystal oscillator (subsystem clock) note so11, si11, sck11, ssi11 , ti001, ti011, and to01 are available only in the pd78f0395, 78f0397, and 78f0397d. chapter 1 outline preliminary user?s manual u17473ej1v0ud 23 1.5 78k0/lx2 series lineup 78k0/le2 78k0/lf2 78k0/lg2 rom ram 64 pins 80 pins 100 pins 128 kb 7 kb ? ? pd78f0397d note pd78f0397 60 kb 3 kb ? pd78f0385d note pd78f0375d note pd78f0385 pd78f0375 pd78f0395 32 kb 1 kb pd78f0363d note pd78f0363 pd78f0383 pd78f0373 pd78f0393 24 kb 1 kb ? pd78f0382 pd78f0372 ? 16 kb 768 b pd78f0361 ? ? note product with on-chip debug function chapter 1 outline preliminary user?s manual u17473ej1v0ud 24 the list of functions in the 78k 0/lx2 series is shown below. (2/2) 78k0/le2 78k0/lf2 78k0/lg2 pd78f036x pd78f037x pd78f038x pd78f039x part number item 64 pins 80 pins 100 pins flash memory (kb) 16 32 24 32 60 32 60 32 60 128 ram (kb) 0.75 1 1 1 3 1 3 1 3 7 bank (flash memory) ? 6 power supply voltage v dd = 1.8 to 5.5 v regulator provided minimum instruction execution time 0.1 s (20 mhz: v dd = 4.0 to 5.5 v)/0.2 s (10 mhz: v dd = 2.7 to 5.5 v)/ 0.4 s (5 mhz: v dd = 1.8 to 5.5 v) high-speed system clock 20 mhz: v dd = 4.0 to 5.5 v/10 mhz: v dd = 2.7 to 5.5 v/5 mhz: v dd = 1.8 to 5.5 v main high-speed ring-osc 8 mhz (typ.): v dd = 1.8 to 5.5 v subclock 32.768 khz (typ.): v dd = 1.8 to 5.5 v clock low-speed ring- osc 240 khz (typ.): v dd = 1.8 to 5.5 v port total 24 34 26 40 16 bits (tm0) 1 ch 2 ch 1 ch 2 ch 1 ch 2 ch 8 bits (tm5) 2 ch 8 bits (tmh) 2 ch watch 1 ch timer wdt 1 ch 3-wire csi note 1 ch 2 ch uart note 1 ch uart supporting lin-bus 1 ch serial interface i 2 c bus 1 ch type internal voltage boosting, extern al resistance division, and internal resistance division are switchable. segment signal 20 26 36 40 lcd common signal 4 10-bit a/d 5 ch 8 ch ? 8 ch external 7 interrupt internal 16 19 16 19 16 19 key interrupt ? 7 ch 8 ch reset pin provided poc 1.59 v 0.15 v (time for rising up to 1.8 v : 3.6 ms (max.)) lvi the detection level of the supply voltage is selectable in 16 steps. reset wdt provided clock output provided multiplier/divider ? provided ? provided ? provided on-chip debug function pd78f0363d only pd78f0375d only pd78f0385d only pd78f0397d only operating ambient temperature ? 40 to +85 c ((t), (s), (r) products), ? 40 to +125 c ((t2) products) note select either of the functions of these alternate-function pins. chapter 1 outline preliminary user?s manual u17473ej1v0ud 25 1.6 block diagram port 0 p00-p06 7 port 1 p10-p17 port 2 p20-p27 8 port 3 p30-p33 4 v ss flmd0 v dd 8 port 7 p70-p77 port 12 p120-p124 8 ani0/p20- ani7/p27 interrupt control a/d converter av ref av ss intp1/p30- intp4/p33 intp0/p120(linsel) serial interface iic0 sda0 scl0 intp5/p16 internal high-speed ram internal expansion ram note2 78k/0 cpu core flash memory bank note 1 16-bit timer/ event counter 01 note 2 to01 note2 /ti011 note2 /p06 ti001 note2 /p05 8-bit timer h0 toh0/p15 8-bit timer h1 toh1/p16 ti50/to50/p17 8-bit timer/ event counter 50 rxd0/p11 txd0/p10 serial interface uart0 watchdog timer rxd6/p14 txd6/p13 serial interface uart6 ti51/to51/p33 8-bit timer/ event counter 51 watch timer serial interface csi10 si10/p11 so10/p12 sck10/p10 low-speed ring-osc 16-bit timer/ event counter 00 to00/ti010/p01 ti000/p00 (linsel) serial interface csi11 note 2 si11 note2 /p03 so11 note2 /p02 sck11 note2 /p04 ssi11 note2 /p05 power on clear/ low voltage indicator poc/lvi control reset control key return 8 kr0/p70- kr7/p77 exlvi/p120 system control reset x1/p121 x2/exclk/p122 high-speed ring-osc xt1/p123 xt2/exclks/p124 multiplier& divider note2 on-chip debug note3 rxd6/p14 (linsel) rxd6/p14 (linsel) linsel 5 lcd controller driver s0-s39 com0-com3 v lc0 -v lc2 caph capl 40 4 lv dd lv ss 4 8 ram space for lcd data clock output control notes 1. available only in the pd78f0397 and 78f0397d. 2. available only in the pd78f0395, 78f0397, and 78f0397d. 3. available only in the pd78f0397d. chapter 1 outline preliminary user?s manual u17473ej1v0ud 26 1.7 outline of functions (1/2) item pd78f0393 pd78f0395 pd78f0397 pd78f0397d flash memory (self-programming supported) note 1 32 k 60 k 128 k bank note 2 ? ? 6 high-speed ram note 1 1 k expansion ram note 1 ? 2 k 6 k internal memory (bytes) lcd display ram 40 4 bits memory space 64 kb high-speed system clock x1 (crystal/ceramic) oscillation, extern al main system clock input (exclk) 1 to 20 mhz: v dd = 4.0 to 5.5 v, 1 to 10 mhz: v dd = 2.7 to 5.5 v, 1 to 5 mhz: v dd = 1.8 to 5.5 v main system clock (oscillation frequency) high-speed ring- osc clock on-chip ring oscillation 8 mhz (typ.): v dd = 1.8 to 5.5 v subsystem clock (oscillation frequency) xt1 (crystal) oscillation, external subsystem clock input (exclks) 32.768 khz (typ.): v dd = 1.8 to 5.5 v low-speed ring-osc clock (for tmh1, wdt) on-chip ring oscillation 240 khz (typ.): v dd = 1.8 to 5.5 v general-purpose registers 8 bits 32 registers (8 bits 8 registers 4 banks) 0.1 s/0.2 s/0.4 s/0.8 s/1.6 s (high-speed syst em clock: @ f xh = 20 mhz operation) 0.25 s/0.5 s/1.0 s/2.0 s/4.0 s (typ.) (high-speed ring-osc clock: @ f rh = 8 mhz (typ.) operation) minimum instruction execution time 122 s (subsystem clock: @ f sub = 32.768 khz operation) instruction set 16-bit operation multiply/divide (8 bits 8 bits, 16 bits 8 bits) bit manipulate (set, reset, test, and boolean operation) bcd adjust, etc. i/o ports cmos i/o: 40 16-bit timer/event counter: 1 channel 16-bit timer/event counter: 2 channels timers 8-bit timer/event counter: 2 channels 8-bit timer: 2 channels watch timer: 1 channel watchdog timer: 1 channel timer outputs 5 (pwm output: 4) 6 (pwm output: 4) clock output 156.25 khz, 312.5 khz, 625 khz, 1.25 mhz, 2.5 mhz, 5 mhz, 10 mhz (peripheral hardware clock: @ f prs = 20 mhz operation) 32.768 khz (subsystem clock: @ f sub = 32.768 khz operation) a/d converter 10-bit resolution 8 channels notes 1. the internal flash memory capacity, internal hi gh-speed ram capacity, and internal expansion ram capacity can be changed using the internal memory size switching register (ims) and the internal expansion ram size switching register (ixs). 2. banks to be used can be changed using the bank select register (bank). chapter 1 outline preliminary user?s manual u17473ej1v0ud 27 (2/2) item pd78f0393 pd78f0395 pd78f0397 pd78f0397d serial interface uart mode supporting lin- bus: 1 channel 3-wire serial i/o mode/uart mode note : 1 channel i 2 c bus mode: 1 channel uart mode supporting lin-bus: 1 channel 3-wire serial i/o mode/uart mode note : 1 channel 3-wire serial i/o mode: 1 channel i 2 c bus mode: 1 channel lcd controller/driver internal voltage boosting, external resistance division, and intern al resistance division are switchable. segment signal outputs: 40 common signal outputs: 4 multiplier/divider ? 16 bits 16 bits = 32 bits (multiplication) 32 bits 16 bits = 32 bits remainder of 16 bits (division) internal 16 19 vectored interrupt sources external 7 key interrupt key interrupt (intkr) occurs by det ecting falling edge of key input pins (kr0 to kr7). reset reset using reset pin internal reset by watchdog timer internal reset by power-on-clear internal reset by low-voltage detector on-chip debug function ? provided power supply voltage v dd = 1.8 to 5.5 v operating ambient temperature t a = ? 40 to +85 c ((t), (s), (r) products) t a = ? 40 to +125 c ((t2) products) package 100-pin plastic lqfp (14 14) 100-pin plastic qfp (14 20) note select either of the functions of these alternate-function pins. chapter 1 outline preliminary user?s manual u17473ej1v0ud 28 an outline of the timer is shown below. 16-bit timer/ event counters 00 and 01 note 1 8-bit timer/ event counters 50 and 51 8-bit timers h0 and h1 tm00 tm01 note 1 tm50 tm51 tmh0 tmh1 watch timer watchdog timer interval timer 1 channel 1 channel 1 c hannel 1 channel 1 channel 1 channel 1 c hannel note 2 ? external event counter 1 channel 1 channel 1 channel 1 channel ? ? ? ? ppg output 1 output 1 output ? ? ? ? ? ? pwm output ? ? 1 output 1 output 1 output 1 output ? ? pulse width measurement 2 inputs 2 inputs ? ? ? ? ? ? square-wave output 1 output 1 output 1 output 1 output 1 output 1 output ? ? carrier generator ? ? ? ? ? 1 output note 3 ? ? watch timer ? ? ? ? ? ? 1 channel note 2 ? function watchdog timer ? ? ? ? ? ? ? 1 channel interrupt source 2 2 1 1 1 1 1 ? notes 1. available only in the pd78f0395, 78f0397, and 78f0397d. 2. in the watch timer, the watch timer function and interval timer function can be used simultaneously. 3. tm51 and tmh1 can be used in combination as a carrier generator mode. preliminary user?s manual u17473ej1v0ud 29 chapter 2 pin functions 2.1 pin function list there are three types of pin i/o buffer power supplies: av ref , lv dd , and v dd . the relationship between these power supplies and the pins is shown below. table 2-1. pin i/o buffer power supplies power supply corresponding pins av ref p20 to p27 lv dd caph, capl, com0 to com3, s0 to s39, v lc0 to v lc2 v dd pins other than above (1) port pins (1/2) pin name i/o function after reset alternate function p00 ti000 p01 ti010/to00 p02 so11 note p03 si11 note p04 sck11 note p05 ssi11 note /ti001 note p06 i/o port 0. 7-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input ti011 note /to01 note p10 sck10/txd0 p11 si10/rxd0 p12 so10 p13 txd6 p14 rxd6 p15 toh0 p16 toh1/intp5 p17 i/o port 1. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input ti50/to50 p20 to p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. input ani0 to ani7 p30 to p32 intp1 to intp3 p33 i/o port 3. 4-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input intp4/ti51/to51 note so11, si11, sck11, ssi11, ti001, ti011, and to01 are available only in the pd78f0395, 78f0397, and 78f0397d. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 30 (1) port pins (2/2) pin name i/o function after reset alternate function p70 to p77 i/o port 7. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input kr0 to kr7 p120 intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 i/o port 12. 5-bit i/o port. input/output can be specified in 1-bit units. only for p120, use of an on-chip pull-up resistor can be specified by a software setting. input xt2/exclks chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 31 (2) non-port pins (1/2) pin name i/o function after reset alternate function intp0 p120/exlvi intp1 to intp3 p30 to p32 intp4 p33/ti51/to51 intp5 input external interrupt request input for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified input p16/toh1 si10 p11/rxd0 si11 note input serial data input to serial interface input p03 so10 p12 so11 note output serial data output from serial interface input p02 sda0 i/o serial data i/o for serial interface input ? sck10 p10/txd0 sck11 note p04 scl0 i/o clock input/output for serial interface input ? ssi11 note input chip select input for serial interface input p05/ti001 rxd0 p11/si10 rxd6 input serial data input to asynch ronous serial interface input p14 txd0 p10/sck10 txd6 output serial data output from asyn chronous serial interface input p13 ti000 external count clock input to 16-bit timer/event counter 00 capture trigger input to captur e registers (cr000, cr010) of 16-bit timer/event counter 00 p00 ti001 note external count clock input to 16-bit timer/event counter 01 capture trigger input to captur e registers (cr001, cr011) of 16-bit timer/event counter 01 p05/ssi11 note ti010 capture trigger input to capture register (cr000) of 16-bit timer/event counter 00 p01/to00 ti011 note input capture trigger input to capture register (cr001) of 16-bit timer/event counter 01 input p06/to01 note to00 16-bit timer/event counter 00 output p01/ti010 to01 note output 16-bit timer/event counter 01 output input p06/ti011 note ti50 external count clock input to 8-bit timer/event counter 50 p17/to50 ti51 input external count clock input to 8-bit timer/event counter 51 input p33/to51/intp4 to50 8-bit timer/event counter 50 output p17/ti50 to51 8-bit timer/event counter 51 output p33/ti51/intp4 toh0 8-bit timer h0 output p15 toh1 output 8-bit timer h1 output input p16/intp5 note so11, si11, sck11, ssi11, ti001, ti011, and to01 are available only in the pd78f0395, 78f0397, and 78f0397d. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 32 (2) non-port pins (2/2) pin name i/o function after reset alternate function ani0 to ani7 input a/d converter analog input input p20 to p27 av ref input a/d converter reference voltage input and positive power supply for port 2 ? ? av ss ? a/d converter ground potential. make the same potential as v ss . ? ? s0 to s39 output lcd controller/driver segment signal outputs output ? com0 to com3 output lcd controller/driver common signal outputs output ? lv dd ? positive power supply for lcd controller/driver ? ? lv ss ? ground potential for lcd controller/driver ? ? v lc0 to v lc2 ? lcd drive voltage ? ? caph ? capl ? lcd drive voltage booster capacitor connection ? ? kr0 to kr7 input key interrupt input input p70 to p77 regc ? connecting regulator output (2.5 v) stabilization capacitance for internal operation. connect to v ss via a capacitor (0.47 f: target). ? ? reset input system reset input ? ? exlvi input potential input for external low-voltage detection input p120/intp0 x1 input p121 x2 ? connecting resonator for main system clock input p122/exclk exclk input external clock input fo r main system clock input p122/x2 xt1 input p123 xt2 ? connecting resonator for su bsystem clock input p124/exclks exclks input external clock input for subsystem clock input p124/xt2 v dd ? positive power supply ? ? v ss ? ground potential ? ? flmd0 ? flash memory programming mode setting ? ? chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 33 2.2 description of pin functions 2.2.1 p00 to p06 (port 0) p00 to p06 function as a 7-bit i/o port. these pins also function as timer i/o, serial interface data i/o, clock i/o, and chip select input. the following operation modes can be specified in 1-bit units. (1) port mode p00 to p06 function as a 7-bit i/o port. p00 to p06 can be set to input or output port in 1-bit units using port mode register 0 (pm0). use of an on -chip pull-up resistor can be specified by pull-up resistor option register 0 (pu0). (2) control mode p00 to p06 function as timer i/o, serial inte rface data i/o, clock i/o, and chip select input. (a) ti000, ti001 note these are the pins for inputting an external count clo ck to 16-bit timer/event counters 00 and 01 and are also for inputting a capture trigger signal to the captur e registers (cr000, cr010 or cr001, cr011) of 16-bit timer/event counters 00 and 01. (b) ti010, ti011 note these are the pins for inputting a capt ure trigger signal to the capture re gister (cr000 or cr001) of 16-bit timer/event counters 00 and 01. (c) to00, to01 note these are timer output pins. (d) si11 note this is a serial interface serial data input pin. (e) so11 note this is a serial interface serial data output pin. (f) sck11 note this is the serial interf ace serial clock i/o pin. (g) ssi11 note this is the serial interface chip select input pin. note ti001, ti011, to01, si11, so11, sck11, and ssi11 are available only in the pd78f0395, 78f0397, and 78f0397d. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 34 2.2.2 p10 to p17 (port 1) p10 to p17 function as an 8-bit i/o port. t hese pins also function as pins for ex ternal interrupt re quest input, serial interface data i/o, cl ock i/o, and timer i/o. the following operation modes can be specified in 1-bit units. (1) port mode p10 to p17 function as an 8-bit i/o port. p10 to p17 can be set to input or output por t in 1-bit units using port mode register 1 (pm1). use of an on -chip pull-up resistor can be specified by pull-up resistor option register 1 (pu1). (2) control mode p10 to p17 function as external interrupt request in put, serial interface data i/o, clock i/o, and timer i/o. (a) si10 this is a serial interface serial data input pin. (b) so10 this is a serial interface serial data output pin. (c) sck10 this is a serial interface serial clock i/o pin. (d) rxd0, rxd6 these are the serial data input pins of the asynchronous serial interface. (e) txd0, txd6 these are the serial data output pins of the asynchronous serial interface. (f) ti50 this is the pin for inputting an external c ount clock to 8-bit timer/event counter 50. (g) to50, toh0, and toh1 these are timer output pins. (h) intp5 this is an external interrupt request input pin for whic h the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 35 2.2.3 p20 to p27 (port 2) p20 to p27 function as an 8-bit i/o port. these pins also function as pins for a/d converter analog input. the following operation modes can be specified in 1-bit units. (1) port mode p20 to p27 function as an 8-bit i/o port. p20 to p27 can be set to input or output por t in 1-bit units using port mode register 2 (pm2). (2) control mode p20 to p27 function as a/d converter analog input pins (ani0 to ani7). when using these pins as analog input pins, see (5) ani0/p20 to ani7/p27 in 12.6 cautions for a/d converter . caution p20/ani0 to p27/ani7 ar e set in the analog input mode after release of reset. 2.2.4 p30 to p33 (port 3) p30 to p33 function as a 4-bit i/o port. these pins also function as pins for external interrupt request input and timer i/o. the following operation modes can be specified in 1-bit units. (1) port mode p30 to p33 function as a 4-bit i/o port. p30 to p33 can be set to input or output port in 1-bit units using port mode register 3 (pm3). use of an on -chip pull-up resistor can be specified by pull-up resistor option register 3 (pu3). (2) control mode p30 to p33 function as external interrupt request input and timer i/o. (a) intp1 to intp4 these are the external interrupt request input pins fo r which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (b) ti51 this is an external count clock input pin to 8-bit timer/event counter 51. (c) to51 this is a timer output pin. caution in the pd78f0397d, be sure to pull the p31 pin down after reset to prevent malfunction. remark p31/intp2 and p32/intp3 of the pd78f0397d can be used as on-chip debug mode setting pins when the on-chip debug function is used. for details, see chapter 27 on-chip debug function ( pd78f0397d only). chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 36 2.2.5 p70 to p77 (port 7) p70 to p77 function as an 8-bit i/o port. these pins also function as key interrupt input pins. the following operation modes can be specified in 1-bit units. (1) port mode p70 to p77 function as an 8-bit i/o port. p70 to p77 can be set to input or output por t in 1-bit units using port mode register 7 (pm7). use of an on -chip pull-up resistor can be specified by pull-up resistor option register 7 (pu7). (2) control mode p70 to p77 function as key interrupt input pins. 2.2.6 p120 to p124 (port 12) p120 to p124 function as a 5-bit i/o port. these pins also function as pins for extern al interrupt request input, potential input for external low-voltage detection, resonator for main system clo ck connection, resonator for subsystem clock connection, and external clock input. the followin g operation modes can be s pecified in 1-bit units. (1) port mode p120 to p124 function as a 5-bit i/o por t. p120 to p124 can be set to input or output port using port mode register 12 (pm12). only for p120, use of an on-chip pull-up resistor can be specifie d by pull-up resistor option register 12 (pu12). (2) control mode p120 to p124 function as an external interrupt request in put, potential input for external low-voltage detection, resonator for main system clock connec tion, resonator for subsystem clock connection, and external clock input. (a) intp0 this functions as an external interrupt request inpu t (intp0) for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (b) exlvi this is a potential input pin for external low-voltage detection. (c) x1, x2 these are the pins for connecting a resonator for main system clock. (d) exclk this is an external clock inpu t pin for main system clock. (e) xt1, xt2 these are the pins for connecting a resonator for subsystem clock. (f) exclks this is an external clock in put pin for subsystem clock. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 37 2.2.7 sda0 this is a serial data i/o pin for se rial interface (n-ch open-drain). 2.2.8 scl0 this is a serial clock i/o pin for serial interface (n-ch open-drain). 2.2.9 av ref this is the a/d converter reference voltage input pin. when the a/d converter is not used, connect this pin directly to v dd . 2.2.10 av ss this is the a/d converter ground potenti al pin. even when the a/d converter is not used, always use this pin with the same potential as the v ss pin. 2.2.11 s0 to s39 these pins are the segment signal output pins for the lcd controller/driver. 2.2.12 com0 to com3 these pins are the common signal output pins for the lcd controller/driver. 2.2.13 lv dd this is the positive power supply pin for the lcd controller/driver. 2.2.14 lv ss this is the ground potential pin for the lcd controller/driver. 2.2.15 v lc0 to v lc2 these pins are the power supply vo ltage pins for driving the lcd. 2.2.16 caph, capl these pins are the capacitor conn ection pins for driving the lcd. 2.2.17 reset this is the active-low system reset input pin. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 38 2.2.18 regc this is the pin for connecting regulator output (2.5 v) stabilization capacitance for internal operation. connect this pin to v ss via a capacitor (0.47 f: target). regc v ss caution keep the wiring length as short as possible in the ar ea enclosed by the broken lines in the above figures. 2.2.19 v dd this is the positive power supply pin. 2.2.20 v ss this is the ground potential pin. 2.2.21 flmd0 this is a pin for setting flash memory programming mode. connect flmd0 to v ss in the normal operation mode. in flash memory programming mode, be sure to connect this pin to the flash programmer. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 39 2.3 pin i/o circuits and recommended connection of unused pins table 2-2 shows the types of pin i/o circuits and the recommended connections of unused pins. see figure 2-1 for the configuration of the i/o circuit of each type. table 2-2. pin i/o circuit types (1/2) pin name i/o circuit type i/o recommended connection of unused pins p00/ti000 p01/ti010/to00 5-ah p02/so11 note 1 5-ag p03/si11 note 1 p04/sck11 note 1 p05/ssi11 note 1 /ti001 note 1 p06/ti011 note 1 /to01 note 1 5-ag ( pd78f0393), 5-ah ( pd78f0395, 78f0397, 78f0397d) p10/sck10/txd0 p11/si10/rxd0 5-ah p12/so10 p13/txd6 5-ag p14/rxd6 5-ah p15/toh0 5-ag p16/toh1/intp5 p17/ti50/to50 5-ah input: independently connect to v dd or v ss via a resistor. output: leave open. p20/ani0 to p27/ani7 note 2 11-g chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 40 table 2-2. pin i/o circuit types (2/2) pin name i/o circuit type i/o recommended connection of unused pins p121/x1 note p122/x2/exclk note p123/xt1 note p124/xt2/exclks note 37 input: independently connect to v dd or v ss via a resistor. output: leave open. scl0 sda0 13-ad i/o input: connect to v ss . output: leave open. s0 to s39 17 com0 to com3 18 output v lc0 to v lc2 caph, capl ? ? leave open. reset 2 input ? flmd0 38 input connect to v ss . av ref connect directly to v dd . av ss ? ? connect directly to v ss . note use recommended connection above in i/o port mode (see figure 5-2 format of clock operation mode select register (oscctl) ) when these pins are not used. chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 41 figure 2-1. pin i/o circuit list (1/2) type 2 type 11-g schmitt-triggered input with hysteresis characteristics in data output disable av ref p-ch in/out n-ch p-ch n-ch av ref (threshold voltage) comparator input enable + _ av ss av ss type 5-ag type 13-ad pull-up enable data output disable input enable v dd p-ch v dd p-ch in/out n -ch v ss data output disable input enable in/out n-ch v ss type 5-ah type 17 pull-up enable data output disable input enable v dd p-ch v dd p-ch in/out n -ch v ss p-ch n-ch p-ch n-ch n-ch n-ch data out v lc0 v lc1 seg v lc2 p-ch p-ch chapter 2 pin functions preliminary user?s manual u17473ej1v0ud 42 figure 2-1. pin i/o circuit list (2/2) type 18 type 38 p-ch n-ch p-ch n-ch p-ch n-ch p-ch n-ch data p-ch n-ch v lc1 v lc0 v lc2 out com input enable in type 37 data output disable input enable v dd p-ch x1, xt1 n -ch v ss reset data output disable input enable v dd p-ch n -ch v ss reset p-ch n-ch x2, xt2 preliminary user?s manual u17473ej1v0ud 43 chapter 3 cpu architecture 3.1 memory space products in the 78k0/lg2 can each access a 64 kb memory s pace. figures 3-1 to 3-4 show the memory maps. caution regardless of the internal memory capacity, the initial valu es of the internal memory size switching register (ims) and inte rnal expansion ram size switching register (ixs) of all products in the 78k0/lg2 are fixed (ims = cfh, ixs = 0ch). therefore, set the value corresponding to each product as indicated below. table 3-1. set values of internal memo ry size switching register (ims) and internal expansion ram si ze switching register (ixs) flash memory version (78k0/lg2) ims ixs pd78f0393 c8h 0ch pd78f0395 cfh 08h pd78f0397, 78f0397d cch note 00h note although the pd78f0397 and 78f0397d have an intern al rom capacity of 128 kb, set the internal rom capacity to 48 kb, since banks are used. for how to set the banks, see 26.2 bank select register ( pd78f0397 and 78f0397d only) . chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 44 figure 3-1. memory map ( pd78f0393) special function registers (sfr) 256 8 bits internal high-speed ram 1024 8 bits general-purpose registers 32 8 bits reserved flash memory 32768 8 bits ffffh ff00h feffh fee0h fedfh fb00h faffh 8000h 7fffh 0000h program memory space data memory space 1000h 0fffh vector table area 0040h 003fh 0000h callt table area 0081h 0080h 007fh program area option byte area note 0800h 07ffh callf entry area program area 7fffh option byte area note 1081h 1080h 107fh program area note 1080h: set the option byte when the boot swap is used. 0080h: set the option byte when the boot swap is not used. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 45 figure 3-2. memory map ( pd78f0395) special function registers (sfr) 256 8 bits internal high-speed ram 1024 8 bits internal expansion ram 2048 8 bits general-purpose registers 32 8 bits reserved flash memory 61440 8 bits ffffh ff00h feffh fee0h fedfh fb00h faffh f800h f7ffh f000h efffh 0000h program memory space ram space in which instruction can be fetched data memory space 0081h 0080h 007fh 0800h 07ffh 1000h 0fffh vector table area 0040h 003fh 0000h callt table area program area option byte area note callf entry area program area efffh option byte area note 1081h 1080h 107fh program area note 1080h: set the option byte when the boot swap is used. 0080h: set the option byte when the boot swap is not used. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 46 figure 3-3. memory map ( pd78f0397) special function registers (sfr) 256 8 bits internal high-speed ram 1024 8 bits internal expansion ram 6144 8 bits general-purpose registers 32 8 bits reserved ffffh ff00h feffh fee0h fedfh fb00h faffh f800h f7ffh e000h dfffh 8000h 7fffh 0000h program memory space ram space in which instruction can be fetched data memory space flash memory 32768 8 bits (common) 0800h 07ffh 1000h 0fffh vector table area 0040h 003fh 0000h callt table area 0081h 0080h 007fh program area option byte area note callf entry area program area 7fffh option byte area note 1081h 1080h 107fh program area c000h bfffh reserved flash memory 16384 8 bits (bank 0) 16384 8 bits (bank 1) 16384 8 bits (bank 4) 16384 8 bits (bank 3) 16384 8 bits (bank 5) 16384 8 bits (bank 2) note 1080h: set the option byte when the boot swap is used. 0080h: set the option byte when the boot swap is not used. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 47 figure 3-4. memory map ( pd78f0397d) special function registers (sfr) 256 8 bits internal high-speed ram 1024 8 bits internal expansion ram 6144 8 bits general-purpose registers 32 8 bits reserved ffffh ff00h feffh fee0h fedfh fb00h faffh f800h f7ffh e000h dfffh 8000h 7fffh 0000h program memory space ram space in which instruction can be fetched data memory space flash memory 32768 8 bits (common) 0800h 07ffh 1000h 0fffh vector table area 0040h 003fh 0000h callt table area 0085h 0084h 0083h 0082h 0081h 0080h 007fh 007eh 007dh program area option byte area note 1 callf entry area 7fffh 1085h 1084h 1083h 1082h 1081h 1080h 107fh program area c000h bfffh reserved flash memory 16384 8 bits (bank 0) 16384 8 bits (bank 1) 16384 8 bits (bank 4) 16384 8 bits (bank 3) 16384 8 bits (bank 5) 16384 8 bits (bank 2) security id control area note 1 program area security id setting area note 1 008fh 008eh note 2 note 3 108fh 108eh program area option byte area note 1 security id control area note 1 security id setting area note 1 program area 0190h 018fh note 3 note 2 notes 1. 1080h, 1084h, 1085h to 108eh: set the option byte, se curity id control flag, and security id code when the boot swap is used. 0080h, 0084h, 0085h to 008eh: set the option byte, security id control flag, and security id code when the boot swap is not used. 2. this area cannot be used during on-chip debugging because it is used for communication commands (008fh to 018fh: standard setting of debugger). 3. this area cannot be used when a software break is used during on-chip debugging. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 48 3.1.1 internal program memory space the internal program memory space stores the program and table data. normally, it is addressed with the program counter (pc). 78k0/lg2 products incorporate internal rom (flash memory), as shown below. table 3-2. intern al rom capacity internal rom part number structure capacity pd78f0393 32768 8 bits (0000h to 7fffh) pd78f0395 61440 8 bits (0000h to efffh) pd78f0397, 78f0397d flash memory 131072 8 bits (0000h to 7fffh (common area) + 8000h to bfffh (bank area) 6) the internal program memory space is divided into the following areas. (1) vector table area the 64-byte area 0000h to 003fh is reserved as a vect or table area. the progra m start addresses for branch upon reset signal input or generation of each interrupt request are stored in t he vector table area. of the 16-bit address, the lower 8 bits are stored at even addresses and t he higher 8 bits are stored at odd addresses. table 3-3. vector table vector table address interrupt source vector table address interrupt source 0000h reset input, poc, lvi, wdt 001eh inttm50 0004h intlvi 0020h inttm000 0006h intp0 0022h inttm010 0008h intp1 0024h intad 000ah intp2 0026h intsr0 000ch intp3 0028h intwti 000eh intp4 002ah inttm51 0010h intp5 002ch intkr 0012h intsre6 002eh intwt 0014h intsr6 0034h intiic0/intdmu note 0016h intst6 0036h note intcsi11 note 0018h intcsi10/intst0 0038h note inttm001 note 001ah inttmh1 003ah note inttm011 note 001ch inttmh0 003eh brk note available only in the pd78f0395, 78f0397, and 78f0397d. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 49 (2) callt instruction table area the 64-byte area 0040h to 007fh can st ore the subroutine entry address of a 1-byte call instruction (callt). (3) option byte area the option byte area is assigned to the 1-byte area of 0080h and 1080h. when the boot swap is not used, set the option byte to 0080h. when the boot swap is used, set the option byte to 1080h. see chapter 25 option byte for details. (4) callf instruction entry area the area 0800h to 0fffh can perform a direct subrout ine call with a 2-byte ca ll instruction (callf). (5) security id control area ( pd78f0397d only) a security id control area is provided in a 1-byte area of 0084h and 1084h. set the security id control flag at 0084h when the boot swap is not used, and at 1084h when the boot sw ap is used. for details, see chapter 27 on-chip debug function ( pd78f0397d only). (6) security id setting area ( pd78f0397d only) a 10-byte area of 0085h to 008eh and 1085h to 108eh c an be used as a security id setting area. set the security id for 10 bytes at 0085h to 008eh when th e boot swap is not used and at 1085h to 108eh when the boot swap is used. for details, see chapter 27 on-chip debug function ( pd78f0397d only) . chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 50 3.1.2 bank area ( pd78f0397 and 78f0397d only) the pd78f0397 and 78f0397d have bank areas 0 to 5 as illustrated below. the banks are selected by using a bank select register (bank) (see 26.2 bank select register ( pd78f0397 and 78f0397d only) ). cautions 1. instructions cannot be fetched between different banks. 2. branch and access cannot be directly executed between different banks. execute branch or access between different banks via the common area. 3. locate interrupt servicing in the common area. figure 3-5. internal rom (f lash memory) configuration 8000h 7fffh bfffh common area 32768 8 bits bank area 0 16384 8 bits 0000h bank area 1 16384 8 bits bank area 2 16384 8 bits bank area 3 16384 8 bits bank area 4 16384 8 bits bank area 5 16384 8 bits chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 51 3.1.3 internal data memory space 78k0/lg2 products incorporate the following rams. (1) internal high-speed ram table 3-4. internal high-speed ram capacity part number internal high-speed ram pd78f0393 pd78f0395 pd78f0397, 78f0397d 1024 8 bits (fb00h to feffh) the 32-byte area fee0h to feffh is assigned to four g eneral-purpose register banks consisting of eight 8-bit registers per bank. this area cannot be used as a program area in which instructions are written and executed. the internal high-speed ram can also be used as a stack memory. (2) internal expansion ram table 3-5. internal expansion ram capacity part number internal expansion ram pd78f0393 ? pd78f0395 2048 8 bits (f000h to f7ffh) pd78f0397, 78f0397d 6144 8 bits (e000h to f7ffh) the internal expansion ram can also be used as a normal data area similar to the inte rnal high-speed ram, as well as a program area in which inst ructions can be written and executed. the internal expansion ram cannot be used as a stack memory. (3) lcd display ram lcd display ram is incorporated in the lcd controller/driver (see figure 17-4 lcd display ram ). table 3-6. lcd display ram capacity part number lcd display ram pd78f0393 pd78f0395 pd78f0397, 78f0397d 40 4 bits (00h to 27h of lcdseg) chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 52 3.1.4 special function register (sfr) area on-chip peripheral hardware special function registers (sfrs) are allo cated in the area ff00h to ffffh (see table 3-7 special function register list in 3.2.3 special func tion registers (sfrs) ). caution do not access addresses to which sfrs are not assigned. 3.1.5 data memory addressing addressing refers to the method of specifying the address of the instruction to be executed next or the address of the register or memory relevant to the execution of instructions. several addressing modes are provided for addressing the memo ry relevant to the executi on of instructions for the 78k0/lg2, based on operability and other c onsiderations. for areas containing data memory in particular, special addressing methods designed for the functions of special function registers (sfr) and general-purpose registers are available for use. figures 3-6 to 3-9 show correspond ence between data memory and addressing. for details of each addressing mode, see 3.4 operand address addressing . figure 3-6. correspondence between data memory and addressing ( pd78f0393) special function registers (sfr) 256 8 bits short direct addressing sfr addressing ffffh ff20h ff1fh 0000h ff00h feffh fee0h fedfh fe20h fe1fh fb00h faffh 8000h 7fffh internal high-speed ram 1024 8 bits general-purpose registers 32 8 bits reserved flash memory 32768 8 bits register addressing direct addressing register indirect addressing based addressing based indexed addressing chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 53 figure 3-7. correspondence betw een data memory and addressing ( pd78f0395) special function registers (sfr) 256 8 bits short direct addressing sfr addressing ffffh ff20h ff1fh 0000h ff00h feffh fee0h fedfh fe20h fe1fh f000h efffh internal high-speed ram 1024 8 bits general-purpose registers 32 8 bits reserved flash memory 61440 8 bits register addressing direct addressing register indirect addressing based addressing based indexed addressing f800h f7ffh fb00h faffh internal expansion ram 2048 8 bits chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 54 figure 3-8. correspondence betw een data memory and addressing ( pd78f0397) 16384 8 bits (bank 1) 16384 8 bits (bank 4) 16384 8 bits (bank 3) 16384 8 bits (bank 5) 16384 8 bits (bank 2) special function registers (sfr) 256 8 bits short direct addressing sfr addressing ffffh ff20h ff1fh 0000h ff00h feffh fee0h fedfh fe20h fe1fh 8000h 7fffh internal high-speed ram 1024 8 bits general-purpose registers 32 8 bits reserved flash memory 32768 8 bits (common) register addressing direct addressing register indirect addressing based addressing based indexed addressing f800h f7ffh e000h dfffh fb00h faffh internal expansion ram 6144 8 bits reserved c000h bfffh flash memory 16384 8 bits (bank 0) chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 55 figure 3-9. correspondence between data memory and addressing ( pd78f0397d) 16384 8 bits (bank 1) 16384 8 bits (bank 4) 16384 8 bits (bank 3) 16384 8 bits (bank 5) 16384 8 bits (bank 2) special function registers (sfr) 256 8 bits short direct addressing sfr addressing ffffh ff20h ff1fh 0000h ff00h feffh fee0h fedfh fe20h fe1fh 8000h 7fffh internal high-speed ram 1024 8 bits general-purpose registers 32 8 bits reserved flash memory 32768 8 bits (common) register addressing direct addressing register indirect addressing based addressing based indexed addressing f800h f7ffh e000h dfffh fb00h faffh internal expansion ram 6144 8 bits reserved c000h bfffh flash memory 16384 8 bits (bank 0) note 2 note 1 notes 1. 0080h to 018fh cannot be used during on-chip debug ging because they are used as a communication command area (008fh to 018fh: standard setting of debugger). 2. 007e and 007fh cannot be used when a software break is used during on-chip debugging. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 56 3.2 processor registers the 78k0/lg2 products incorporate t he following processor registers. 3.2.1 control registers the control registers control the program sequence, statuses and stack memory. the control registers consist of a program counter (pc), a program status word (psw) and a stack pointer (sp). (1) program counter (pc) the program counter is a 16-bit regist er that holds the address information of the next program to be executed. in normal operation, the pc is automat ically incremented according to the numbe r of bytes of the instruction to be fetched. when a branch instruction is execut ed, immediate data and regi ster contents are set. reset input sets the reset vector table values at addresses 0000h and 0001h to the program counter. figure 3-10. format of program counter 15 0 pc pc15 pc14 pc13 pc12 pc11 pc10 pc9 pc8 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 (2) program status word (psw) the program status word is an 8-bit r egister consisting of various flags set/reset by instruction execution. program status word contents ar e automatically stacked upon interrupt request generation or push psw instruction execution and are re stored upon execution of the retb , reti and pop psw instructions. reset input sets the psw to 02h. figure 3-11. format of program status word 7 0 psw ie z rbs1 ac rbs0 0 isp cy (a) interrupt enable flag (ie) this flag controls the interrupt reques t acknowledge operations of the cpu. when 0, the ie flag is set to the interrupt disabled (di) state, and all maskable interrupt requests are disabled. when 1, the ie flag is set to the interrupt enabled (ei) state and interrupt request acknowledgement is controlled with an in-service priority flag (isp), an in terrupt mask flag for various interrupt sources, and a priority specification flag. the ie flag is reset (0) upon di instruction execution or interrupt acknowledgement and is set (1) upon ei instruction execution. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 57 (b) zero flag (z) when the operation result is zero, this flag is se t (1). it is reset (0 ) in all other cases. (c) register bank select flags (rbs0 and rbs1) these are 2-bit flags to select one of the four register banks. in these flags, the 2-bit information that indicates t he register bank selected by sel rbn instruction execution is stored. (d) auxiliary carry flag (ac) if the operation result has a carry from bit 3 or a borrow at bi t 3, this flag is set (1). it is reset (0) in all other cases. (e) in-service priority flag (isp) this flag manages the priority of acknowledgeable mask able vectored interrupts. when this flag is 0, low- level vectored interrupt requests specified by a priority specification flag register (pr0l, pr0h, pr1l, pr1h) (see 19.3 (3) priority specifi cation flag registers (pr0l, pr0h, pr1l, pr1h) ) can not be acknowledged. actual request acknowledgement is controll ed by the interrupt enable flag (ie). (f) carry flag (cy) this flag stores overflow and underflow upon add/subtract instruct ion execution. it stores the shift-out value upon rotate instruction execution and functions as a bit accumulator during bit operation instruction execution. (3) stack pointer (sp) this is a 16-bit register to hold the start address of the memory stack area. only the internal high-speed ram area can be set as the stack area. figure 3-12. format of stack pointer 15 0 sp sp15 sp14 sp13 sp12 sp11 sp10 sp9 sp8 sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 the sp is decremented ahead of write (save) to the stack memory and is incremented after read (restored) from the stack memory. each stack operation saves/restores dat a as shown in figures 3-13 and 3-14. caution since reset input makes the sp contents undefi ned, be sure to initialize the sp before using the stack. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 58 figure 3-13. data to be saved to stack memory (a) push rp instruction (when sp = fee0h) register pair lower fee0h sp sp fee0h fedfh fedeh register pair higher fedeh (b) call, callf, callt instructions (when sp = fee0h) pc15 to pc8 fee0h sp sp fee0h fedfh fedeh pc7 to pc0 fedeh (c) interrupt, brk instruct ions (when sp = fee0h) pc15 to pc8 psw fedfh fee0h sp sp fee0h fedeh feddh pc7 to pc0 feddh chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 59 figure 3-14. data to be restored from stack memory (a) pop rp instruction (when sp = fedeh) register pair lower fee0h sp sp fee0h fedfh fedeh register pair higher fedeh (b) ret instruction (when sp = fedeh) pc15 to pc8 fee0h sp sp fee0h fedfh fedeh pc7 to pc0 fedeh (c) reti, retb instructions (when sp = feddh) pc15 to pc8 psw fedfh fee0h sp sp fee0h fedeh feddh pc7 to pc0 feddh chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 60 3.2.2 general-purpose registers general-purpose registers are mapp ed at particular addresses (fee0h to feffh) of the data memory. the general-purpose registers consists of 4 bank s, each bank consisting of eight 8-bit r egisters (x, a, c, b, e, d, l, and h). each register can be used as an 8-bit register, and two 8-bit r egisters can also be used in a pair as a 16-bit register (ax, bc, de, and hl). these registers can be described in terms of function names (x, a, c, b, e, d, l, h, ax, bc, de, and hl) and absolute names (r0 to r7 and rp0 to rp3). register banks to be used for instructi on execution are set by the cpu control instruction (sel rbn). because of the 4-register bank configur ation, an efficient program can be created by switching between a register for normal processing and a register for interrupts for each bank. figure 3-15. configuration of general-purpose registers (a) absolute name bank0 bank1 bank2 bank3 feffh fef8h fee0h rp3 rp2 rp1 rp0 r7 15 0 7 0 r6 r5 r4 r3 r2 r1 r0 16-bit processing 8-bit processing fef0h fee8h (b) function name bank0 bank1 bank2 bank3 feffh fef8h fee0h hl de bc ax h 15 0 7 0 l d e b c a x 16-bit processing 8-bit processing fef0h fee8h chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 61 3.2.3 special function registers (sfrs) unlike a general-purpose register, each special f unction register has a special function. sfrs are allocated to the ff00h to ffffh areas in the cpu, and are allo cated to the 00h to 03h areas of lcdctl in the lcd controller/driver. special function registers of the cpu can be manipulated like general-purpose registers, using operation, transfer, and bit manipulation instructions. the manipulatable bit units, 1, 8, and 16, depend on t he special function register type. each manipulation bit unit can be specified as follows. ? 1-bit manipulation describe the symbol reserved by the assembler for the 1-bit manipulation instruction operand (sfr.bit). this manipulation can also be specified with an address. ? 8-bit manipulation describe the symbol reserved by the assembler fo r the 8-bit manipulation instruction operand (sfr). this manipulation can also be specified with an address. ? 16-bit manipulation describe the symbol reserved by the assembler fo r the 16-bit manipulation instruction operand (sfrp). when specifying an address, describe an even address. remark for the operation method of special function registers in the lcd controller/driver, see 16.7 communication with lcd controller/driver . table 3-7 gives a list of the special f unction registers. the meanings of items in the table are as follows. ? symbol symbol indicating the address of a special function register. it is a re served word in the ra78k0, and is defined as an sfr variable using the #pragm a sfr directive in the cc78k0. w hen using the ra78k0, id78k0-qb, and sm+, symbols can be written as an instruction operand. ? r/w indicates whether the corresponding special f unction register can be read or written. r/w: read/write enable r: read only w: write only ? manipulatable bit units indicates the manipulatable bit unit (1, 8, or 16). ? ? ? indicates a bit unit for which manipulation is not possible. ? after reset indicates each register status upon reset input. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 62 table 3-7. special function register list (1/4) manipulatable bit unit address special function regist er (sfr) name symbol r/w 1 bit 8 bits 16 bits after reset ff00h port register 0 p0 r/w ? 00h ff01h port register 1 p1 r/w ? 00h ff02h port register 2 p2 r/w ? 00h ff03h port register 3 p3 r/w ? 00h ff07h port register 7 p7 r/w ? 00h ff08h 10-bit a/d conversion result register adcr r ? ? 0000h ff09h 8-bit a/d conversion result register adcrh r ? ? 00h ff0ah receive buffer register 6 rxb6 r ? ? ffh ff0bh transmit buffer register 6 txb6 r/w ? ? ffh ff0ch port register 12 p12 r/w ? 00h ff0dh port register 13 p13 r/w ? 00h ff0fh serial i/o shift register 10 sio10 r ? ? 00h ff10h ff11h 16-bit timer counter 00 tm00 r ? ? 0000h ff12h ff13h 16-bit timer capture/compare register 000 cr000 r/w ? ? 0000h ff14h ff15h 16-bit timer capture/compare register 010 cr010 r/w ? ? 0000h ff16h 8-bit timer counter 50 tm50 r ? ? 00h ff17h 8-bit timer compare register 50 cr50 r/w ? ? 00h ff18h 8-bit timer h compare register 00 cmp00 r/w ? ? 00h ff19h 8-bit timer h compare register 10 cmp10 r/w ? ? 00h ff1ah 8-bit timer h compare register 01 cmp01 r/w ? ? 00h ff1bh 8-bit timer h compare register 11 cmp11 r/w ? ? 00h ff1fh 8-bit timer counter 51 tm51 r ? ? 00h ff20h port mode register 0 pm0 r/w ? ffh ff21h port mode register 1 pm1 r/w ? ffh ff22h port mode register 2 pm2 r/w ? ffh ff23h port mode register 3 pm3 r/w ? ffh ff26h port mode register 6 pm6 r/w ? ffh ff27h port mode register 7 pm7 r/w ? ffh ff28h a/d converter mode register adm r/w ? 00h ff29h analog input channel specification register ads r/w ? 00h ff2ch port mode register 12 pm12 r/w ? ffh ff2eh port mode register 14 pm14 r/w ? ffh ff2fh a/d port configuration register adpc r/w ? 00h ff30h pull-up resistor option register 0 pu0 r/w ? 00h ff31h pull-up resistor option register 1 pu1 r/w ? 00h ff33h pull-up resistor option register 3 pu3 r/w ? 00h ff37h pull-up resistor option register 7 pu7 r/w ? 00h ff3ch pull-up resistor option register 12 pu12 r/w ? 00h chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 63 table 3-7. special function register list (2/4) manipulatable bit unit address special function regist er (sfr) name symbol r/w 1 bit 8 bits 16 bits after reset ff40h clock output selection register cks r/w ? 00h ff41h 8-bit timer compare register 51 cr51 r/w ? ? 00h ff43h 8-bit timer mode control register 51 tmc51 r/w ? 00h ff48h external interrupt risi ng edge enable register egp r/w ? 00h ff49h external interrupt fa lling edge enable register egn r/w ? 00h ff4ah serial i/o shift register 11 note sio11 r ? ? 00h ff4ch transmit buffer register 11 note sotb11 r/w ? ? 00h ff4fh input switch control register isc r/w ? 00h ff50h asynchronous serial interface operation mode register 6 asim6 r/w ? 01h ff53h asynchronous serial interface reception error status register 6 asis6 r ? ? 00h ff55h asynchronous serial interface transmission status register 6 asif6 r ? ? 00h ff56h clock selection register 6 cksr6 r/w ? ? 00h ff57h baud rate generator control register 6 brgc6 r/w ? ? ffh ff58h asynchronous serial interface control register 6 asicl6 r/w ? 16h ff60h sdr0l ? 00h ff61h remainder data register 0 note sdr0 sdr0h r ? 00h ff62h mda0ll ? 00h ff63h mda0l mda0lh r/w ? 00h ff64h mda0hl ? 00h ff65h multiplication/division data register a0 note mda0h mda0hh r/w ? 00h ff66h mdb0l ? 00h ff67h multiplication/division data register b0 note mdb0 mdb0h r/w ? 00h ff68h multiplier/divider control register 0 note dmuc0 r/w ? 00h ff69h 8-bit timer h mode register 0 tmhmd0 r/w ? 00h ff6ah timer clock selection register 50 tcl50 r/w ? 00h ff6bh 8-bit timer mode control register 50 tmc50 r/w ? 00h ff6ch 8-bit timer h mode register 1 tmhmd1 r/w ? 00h ff6dh 8-bit timer h carrier control register 1 tmcyc1 r/w ? 00h ff6eh key return mode register krm r/w ? 00h ff6fh watch timer operation mode register wtm r/w ? 00h ff70h asynchronous serial interface operation mode register 0 asim0 r/w ? 01h ff71h baud rate generator control register 0 brgc0 r/w ? ? 1fh ff72h receive buffer register 0 rxb0 r ? ? ffh ff73h asynchronous serial interface reception error status register 0 asis0 r ? ? 00h ff74h transmit shift register 0 txs0 w ? ? ffh note available only in the pd78f0395, 78f0397, and 78f0397d. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 64 table 3-7. special function register list (3/4) manipulatable bit unit address special function regist er (sfr) name symbol r/w 1 bit 8 bits 16 bits after reset ff80h serial operation mode register 10 csim10 r/w ? 00h ff81h serial clock select ion register 10 csic10 r/w ? 00h ff84h transmit buffer register 10 sotb10 r/w ? ? 00h ff88h serial operation mode register 11 note 1 csim11 r/w ? 00h ff89h serial clock selection register 11 note 1 csic11 r/w ? 00h ff8ch timer clock selection register 51 tcl51 r/w ? 00h ff99h watchdog timer enable register wdte r/w ? ? note 2 1ah/9ah ff9fh clock operation mode select register oscctl r/w ? 00h ffa0h ring-osc mode register rcm r/w ? 80h note 3 ffa1h main clock mode register mcm r/w ? 00h ffa2h main osc control register moc r/w ? 80h ffa3h oscillation stabilization time counter status register ostc r ? 00h ffa4h oscillation stabilization time select register osts r/w ? ? 05h ffa5h iic shift register 0 iic0 r/w ? ? 00h ffa6h iic control register 0 iicc0 r/w ? 00h ffa7h slave address register 0 sva0 r/w ? ? 00h ffa8h iic clock selection register 0 iiccl0 r/w ? 00h ffa9h iic function expansion register 0 iicx0 r/w ? 00h ffaah iic status register 0 iics0 r ? 00h ffabh iic flag register 0 iicf0 r/w ? 00h ffach reset control flag register resf r ? ? 00h note 4 ffb0h ffb1h 16-bit timer counter 01 note 1 tm01 r ? ? 0000h ffb2h ffb3h 16-bit timer capture/compare register 001 note 1 cr001 r/w ? ? 0000h ffb4h ffb5h 16-bit timer capture/compare register 011 note 1 cr011 r/w ? ? 0000h ffb6h 16-bit timer mode control register 01 note 1 tmc01 r/w ? 00h ffb7h prescaler mode register 01 note 1 prm01 r/w ? 00h ffb8h capture/compare control register 01 note 1 crc01 r/w ? 00h ffb9h 16-bit timer output control register 01 note 1 toc01 r/w ? 00h ffbah 16-bit timer mode control register 00 tmc00 r/w ? 00h ffbbh prescaler mode register 00 prm00 r/w ? 00h ffbch capture/compare control register 00 crc00 r/w ? 00h ffbdh 16-bit timer output control register 00 toc00 r/w ? 00h notes 1. available only in the pd78f0395, 78f0397, and 78f0397d. 2. the reset value of wdte is determined by setting of option byte. 3. the value of this register is 00h immediately after a reset release but automatically changes to 80h after high-speed ring-osc oscillation has been stabilized. 4. the reset value of resf varies depending on the reset source. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 65 table 3-7. special function register list (4/4) manipulatable bit unit address special function regist er (sfr) name symbol r/w 1 bit 8 bits 16 bits after reset ffbeh low-voltage detection register lvim r/w ? 00h note 1 ffbfh low-voltage detection level selection register lvis r/w ? 00h note 1 ffe0h interrupt request flag register 0l if0 if0l r/w 00h ffe1h interrupt request flag register 0h if0h r/w 00h ffe2h interrupt request flag register 1l if1 if1l r/w 00h ffe3h interrupt request flag register 1h if1h r/w 00h ffe4h interrupt mask flag register 0l mk0 mk0l r/w ffh ffe5h interrupt mask flag register 0h mk0h r/w ffh ffe6h interrupt mask flag register 1l mk1 mk1l r/w ffh ffe7h interrupt mask flag register 1h mk1h r/w ffh ffe8h priority specification flag register 0l pr0 pr0l r/w ffh ffe9h priority specification flag register 0h pr0h r/w ffh ffeah priority specification flag register 1l pr1 pr1l r/w ffh ffebh priority specification flag register 1h pr1h r/w ffh fff0h internal memory size switching register note 2 ims r/w ? ? cfh fff3h bank select register bank r/w ? ? 00h fff4h internal expansion ram size switching register note 2 ixs r/w ? ? 0ch fffbh processor clock control register pcc r/w ? 01h lcdctl's 00h lcd mode setting register lcdmd r/w ? ? 00h lcdctl's 01h lcd display mode register lcdm r/w ? ? 00h lcdctl's 02h lcd clock control register lcdc r/w ? ? 00h lcdctl's 03h lcd voltage boost control register 0 vlcg0 r/w ? ? 00h notes 1. the reset values of lvim and lvis vary depending on the reset source. 2. regardless of the internal memory capacity, the init ial values of the internal memory size switching register (ims) and internal expansion ram size switchi ng register (ixs) of all products in the 78k0/lg2 are fixed (ims = cfh, ixs = 0ch). therefore, set the value correspond ing to each product as indicated below. flash memory version (78k0/lg2) ims ixs pd78f0393 c8h 0ch pd78f0395 cfh 08h pd78f0397, 78f0397d cch 00h chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 66 3.3 instruction address addressing an instruction address is determined by program counter (pc) contents and is normally incremented (+1 for each byte) automatically according to the num ber of bytes of an instruction to be fetched each time another instruction is executed. when a branch instruction is executed, the branch destination information is set to the pc and branched by the following addressing (for deta ils of instructions, refer to 78k/0 series instructions user?s manual (u12326e) ). 3.3.1 relative addressing [function] the value obtained by adding 8-bit immediate data (displ acement value: jdisp8) of an instruction code to the start address of the following instruction is transfe rred to the program counter (pc) and branched. the displacement value is treated as signed two?s complement data ( ? 128 to +127) and bit 7 becomes a sign bit. in other words, relative addressing consists of relati ve branching from the start address of the following instruction to the ? 128 to +127 range. this function is carried out when the br $addr16 instruct ion or a conditional branch instruction is executed. [illustration] 15 0 pc + 15 0 876 s 15 0 pc jdisp8 when s = 0, all bits of are 0. when s = 1, all bits of are 1. pc indicates the start address of the instruction after the br instruction. ... chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 67 3.3.2 immediate addressing [function] immediate data in the instruction word is tran sferred to the program counter (pc) and branched. this function is carried out when the call !addr16 or br !addr16 or callf !addr11 instruction is executed. call !addr16 and br !addr16 instructions can be branc hed to the entire memory s pace. the callf !addr11 instruction is branc hed to the 0800h to 0fffh area. [illustration] in the case of call !addr16 and br !addr16 instructions 15 0 pc 87 70 call or br low addr. high addr. in the case of callf !addr11 instruction 15 0 pc 87 70 fa 10?8 11 10 00001 643 callf fa 7?0 chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 68 3.3.3 table indirect addressing [function] table contents (branch desti nation address) of the particular location to be addressed by bits 1 to 5 of the immediate data of an operation co de are transferred to the progr am counter (pc) and branched. this function is carried out when the ca llt [addr5] instruction is executed. this instruction references the address stored in the me mory table from 40h to 7fh, and allows branching to the entire memory space. [illustration] 15 1 15 0 pc 70 low addr. high addr. memory (table) effective address+1 effective address 01 00000000 87 87 65 0 0 1 11 765 10 ta 4?0 operation code 3.3.4 register addressing [function] register pair (ax) contents to be s pecified with an instruction word are tr ansferred to the program counter (pc) and branched. this function is carried out when t he br ax instruction is executed. [illustration] 70 rp 07 ax 15 0 pc 87 chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 69 3.4 operand address addressing the following methods are available to specify the r egister and memory (addressing) to undergo manipulation during instruction execution. 3.4.1 implied addressing [function] the register that functions as an accumulator (a and ax) among the general-purpose registers is automatically (implicitly) addressed. of the 78k0/lg2 instruction words, the followi ng instructions employ implied addressing. instruction register to be s pecified by implied addressing mulu a register for multiplicand and ax register for product storage divuw ax register for dividend and quotient storage adjba/adjbs a register for storage of numeric va lues that become decimal correction targets ror4/rol4 a register for storage of di git data that undergoes digit rotation [operand format] because implied addressing can be automatically employed with an instruction, no particular operand format is necessary. [description example] in the case of mulu x with an 8-bit 8-bit multiply instruction, the pr oduct of a register and x register is stored in ax. in this example, the a and ax registers are specified by implied addressing. chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 70 3.4.2 register addressing [function] the general-purpose register to be specified is accesse d as an operand with the regi ster bank select flags (rbs0 to rbs1) and the register specify co des (rn and rpn) of an operation code. register addressing is carried out when an instruction with the following operand format is executed. when an 8-bit register is specified, one of the eight registers is specified with 3 bits in the operation code. [operand format] identifier description r x, a, c, b, e, d, l, h rp ax, bc, de, hl ?r? and ?rp? can be described by absolute names (r0 to r7 and rp0 to rp3) as well as function names (x, a, c, b, e, d, l, h, ax, bc, de, and hl). [description example] mov a, c; when selecting c register as r operation code 0 1100010 register specify code incw de; when selecting de register pair as rp operation code 1 0000100 register specify code chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 71 3.4.3 direct addressing [function] the memory to be manipulated is directly addressed with immediate data in an instruction word becoming an operand address. [operand format] identifier description addr16 label or 16-bit immediate data [description example] mov a, !0fe00h; when setting !addr16 to fe00h operation code 10001110 op c ode 00000000 00h 11111110 feh [illustration] memory 0 7 addr16 (lower) addr16 (upper) op code chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 72 3.4.4 short direct addressing [function] the memory to be manipulated in the fixed space is di rectly addressed with 8-bit data in an instruction word. this addressing is applied to the 256-byte space fe20h to ff1fh. internal ram and special function registers (sfrs) are mapped at fe20h to feffh and ff00h to ff1fh, respectively. the sfr area (ff00h to ff1fh) where short direct addressing is applied is a part of the overall sfr area. ports that are frequently accessed in a program and compare and capture r egisters of the timer/event counter are mapped in this area, allowing sfrs to be mani pulated with a small number of bytes and clocks. when 8-bit immediate data is at 20h to ffh, bit 8 of an effe ctive address is set to 0. when it is at 00h to 1fh, bit 8 is set to 1. refer to the [illustration] shown below. [operand format] identifier description saddr immediate data that indicate label or fe20h to ff1fh saddrp immediate data that indicate label or fe20h to ff1fh (even address only) [description example] mov 0fe30h, a; when transferring valu e of a register to saddr (fe30h) operation code 1 1110010 op c ode 0 0110000 30h (s addr-offset) [illustration] 15 0 short direct memory effective address 1 111111 87 0 7 op code saddr-offset when 8-bit immediate data is 20h to ffh, = 0 when 8-bit immediate data is 00h to 1fh, = 1 chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 73 3.4.5 special function register (sfr) addressing [function] a memory-mapped special function register (sfr) is addre ssed with 8-bit immediate data in an instruction word. this addressing is applied to the 240-byte spaces ff00h to ffcfh and ffe0h to ffffh. however, the sfrs mapped at ff00h to ff1fh can be ac cessed with short direct addressing. [operand format] identifier description sfr special function register name sfrp 16-bit manipulatable special function register name (even address only) [description example] mov pm0, a; when selecting pm0 (ff20h) as sfr operation code 11110110 op c ode 00100000 20h (sfr-offset) [illustration] 15 0 sfr effective address 1 111111 87 0 7 op code sfr-offset 1 chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 74 3.4.6 register indirect addressing [function] register pair contents specified by a register pair spec ify code in an instruction word and by a register bank select flag (rbs0 and rbs1) serve as an operand address for addressing the memory. this addressing can be carried out for all the memory spaces. [operand format] identifier description ? [de], [hl] [description example] mov a, [de]; when selecting [de] as register pair operation code 10000101 [illustration] 16 0 8 d 7 e 0 7 7 0 a de the contents of the memory addressed are transferred. memory the memory address specified with the register pair de chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 75 3.4.7 based addressing [function] 8-bit immediate data is added as offset data to the conten ts of the base register, that is, the hl register pair in the register bank specifie d by the register bank select flag (rbs0 and rbs1), and the sum is used to address the memory. addition is performed by expanding the offs et data as a positive number to 16 bits. a carry from the 16th bit is ignored. this addressing can be carried out for all the memory spaces. [operand format] identifier description ? [hl + byte] [description example] mov a, [hl + 10h]; when setting byte to 10h operation code 10101110 00010000 [illustration] 16 0 8 h 7 l 0 7 7 0 a hl the contents of the memory addressed are transferred. memory + 10 chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 76 3.4.8 based indexed addressing [function] the b or c register contents specified in an instruction word are added to the contents of the base register, that is, the hl register pair in the regist er bank specified by the register ba nk select flag (rbs0 and rbs1), and the sum is used to address the memory. addition is perform ed by expanding the b or c register contents as a positive number to 16 bits. a carry from the 16th bit is ignored. this addressing can be carried out for all the memory spaces. [operand format] identifier description ? [hl + b], [hl + c] [description example] in the case of mov a, [hl + b] (selecting b register) operation code 10101011 [illustration] 16 0 h 7 8 l 0 7 b + 0 7 7 0 a hl the contents of the memory addressed are transferred. memory chapter 3 cpu architecture preliminary user?s manual u17473ej1v0ud 77 3.4.9 stack addressing [function] the stack area is indirectly addressed with the stack pointer (sp) contents. this addressing method is automatically employed when the push, pop, subroutine call and return instructions are executed or the register is sa ved/reset upon generation of an interrupt request. with stack addressing, only the internal high-speed ram area can be accessed. [description example] in the case of push de (saving de register) operation code 10110101 [illustration] e fee0h sp sp fee0h fedfh fedeh d memory 0 7 fedeh preliminary user?s manual u17473ej1v0ud 78 chapter 4 port functions 4.1 port functions there are two types of pin i/o buffer power supplies: av ref and v dd . the relationship between these power supplies and the pins is shown below. table 4-1. pin i/o buffer power supplies power supply corresponding pins av ref p20 to p27 v dd port pins other than p20 to p27 78k0/lg2 products are provided with t he ports shown in figure 4-1, which en able variety of control operations. the functions of each port are shown in table 4-2. in addition to the func tion as digital i/o ports, these ports have several alternate f unctions. for details of the alternate functions, see chapter 2 pin functions . figure 4-1. port types p20 p27 port 3 p30 p33 p00 p06 p10 p17 p70 p77 p120 p124 port 7 port 12 port 0 port 1 port 2 chapter 4 port functions preliminary user?s manual u17473ej1v0ud 79 table 4-2. port functions pin name i/o function after reset alternate function p00 ti000 p01 ti010/to00 p02 so11 note p03 si11 note p04 sck11 note p05 ssi11 note /ti001 note p06 i/o port 0. 7-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input ti011 note /to01 note p10 sck10/txd0 p11 si10/rxd0 p12 so10 p13 txd6 p14 rxd6 p15 toh0 p16 toh1/intp5 p17 i/o port 1. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input ti50/to50 p20 to p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. input ani0 to ani7 p30 to p32 intp1 to intp3 p33 i/o port 3. 4-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input intp4/ti51/to51 p70 to p77 i/o port 7. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input kr0 to kr7 p120 intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 i/o port 12. 5-bit i/o port. input/output can be specified in 1-bit units. only for p120, use of an on-chip pull-up resistor can be specified by a software setting. input xt2/exclks note so11, si11, sck11, ssi11, ti001, ti011, and to01 are available only in the pd78f0395, 78f0397, and 78f0397d. chapter 4 port functions preliminary user?s manual u17473ej1v0ud 80 4.2 port configuration ports include the following hardware. table 4-3. port configuration item configuration control registers port mode register (pm0 to pm3, pm7, pm12) port register (p0 to p3, p7, p12) pull-up resistor option register (pu0, pu1, pu3, pu7, pu12) a/d port configuration register (adpc) port total: 40 pull-up resistor total: 28 chapter 4 port functions preliminary user?s manual u17473ej1v0ud 81 4.2.1 port 0 port 0 is a 7-bit i/o port with an output latch. port 0 can be set to the input mode or output mode in 1-bit units using port mode register 0 (pm0). when the p00 to p06 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 0 (pu0). this port can also be used for timer i/o, serial interface data i/o note , and clock i/o. reset input sets port 0 to input mode. figures 4-2 to 4-7 show block diagrams of port 0. caution when p02/so11 note and p04/sck11 note are used as general-purpo se ports, set serial operation mode register 11 (csim11) and serial clock selecti on register 11 (csic11) to the initial setting (00h). note available only in the pd78f0395, 78f0397, and 78f0397d. figure 4-2. block diagram of p00 p00/ti000 wr pu rd wr port wr pm pu00 alternate function output latch (p00) pm00 v dd p-ch selector internal bus pu0 pm0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 82 figure 4-3. bl ock diagram of p01 p01/ti010/to00 wr pu rd wr port wr pm pu01 alternate function output latch (p01) pm01 alternate function v dd p-ch selector internal bus pu0 pm0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 83 figure 4-4. bl ock diagram of p02 internal bus p02/so11 note wr pu rd wr port wr pm pu02 output latch (p02) pm02 alternate function note v dd p-ch pu0 pm0 selector note available only in the pd78f0395, 78f0397, and 78f0397d. pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 84 figure 4-5. block diagram of p03 and p05 (a) pd78f0393 p03, p05 wr pu rd wr port wr pm pu03, pu05 output latch (p03, p05) pm03, pm05 v dd p-ch selector internal bus pu0 pm0 (b) pd78f0395, 78f0397, and 78f0397d p03/si11, p05/ssi11/ti001 wr pu rd wr port wr pm pu03, pu05 alternate function output latch (p03, p05) pm03, pm05 v dd p-ch selector internal bus pu0 pm0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 85 figure 4-6. block diagram of p04 (a) pd78f0393 p04 wr pu rd wr port wr pm pu04 output latch (p04) pm04 v dd p-ch selector internal bus pu0 pm0 (b) pd78f0395, 78f0397, and 78f0397d p04/sck11 wr pu rd wr port wr pm pu04 alternate function output latch (p04) pm04 alternate function v dd p-ch selector internal bus pu0 pm0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 86 figure 4-7. block diagram of p06 (a) pd78f0393 p06 wr pu rd wr port wr pm pu06 output latch (p06) pm06 v dd p-ch selector internal bus pu0 pm0 (b) pd78f0395, 78f0397, and 78f0397d p06/ti011/to01 wr pu rd wr port wr pm pu06 alternate function output latch (p06) pm06 alternate function v dd p-ch selector internal bus pu0 pm0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 87 4.2.2 port 1 port 1 is an 8-bit i/o port with an output latch. port 1 can be set to the input mode or output mode in 1-bit units using port mode register 1 (pm1). when the p10 to p17 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 1 (pu1). this port can also be used for external interrupt requ est input, serial interfac e data i/o, clock i/o, and timer i/o. reset input sets port 1 to input mode. figures 4-8 to 4-12 show block diagrams of port 1. caution when p10/sck10/txd0 a nd p12/so10 are used as general- purpose ports, set serial operation mode register 10 (csim10) and serial clock selecti on register 10 (csic10) to the initial setting (00h). figure 4-8. block diagram of p10 p10/sck10/txd0 wr pu rd wr port wr pm pu10 alternate function output latch (p10) pm10 alternate function v dd p-ch selector internal bus pu1 pm1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 88 figure 4-9. block diagram of p11 and p14 p11/si10/rxd0, p14/rxd6 wr pu rd wr port wr pm pu11, pu14 alternate function output latch (p11, p14) pm11, pm14 v dd p-ch selector internal bus pu1 pm1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 89 figure 4-10. block diagram of p12 and p15 p12/so10 p15/toh0 wr pu rd wr port wr pm pu12, pu15 output latch (p12, p15) pm12, pm15 alternate function v dd p-ch selector internal bus pu1 pm1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 90 figure 4-11. blo ck diagram of p13 p13/txd6 wr pu rd wr port wr pm pu13 output latch (p13) pm13 alternate function v dd p-ch internal bus selector pu1 pm1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 91 figure 4-12. block diagram of p16 and p17 p16/toh1/intp5, p17/ti50/to50 wr pu rd wr port wr pm pu16, pu17 alternate function output latch (p16, p17) pm16, pm17 alternate function v dd p-ch selector internal bus pu1 pm1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 92 4.2.3 port 2 port 2 is an 8-bit i/o port with an output latch. port 2 can be set to the input mode or output mode in 1-bit units using port mode register 2 (pm2). this port can also be used for a/d converter analog input. when p20/ani0 to p27/ani7 are used as digital input port s, select digital i/o usi ng the a/d port configuration register (adpc), set the input mode using pm2, and then use these ports from the lower bits. when p20/ani0 to p27/ani7 are used as digital output ports, select di gital i/o using adpc, and then set output mode using pm2. table 4-4. settings of p20/ ani0 to p27/ani7 pin function adpc setting pm2 setting ads setting p20/ani0 to p27/ani7 pins ani selection setting prohibited input mode ani non-selection digital input ani selection setting prohibited digital i/o selection output mode ani non-selection digital output ani selection analog input (target for conversion) input mode ani non-selection analog input (target for non- conversion) ani selection analog input selection output mode ani non-selection setting prohibited when a reset signal is generated, p20/ani0 to p27/ani7 are all set to analog input mode. figure 4-13 shows a block diagram of port 2. chapter 4 port functions preliminary user?s manual u17473ej1v0ud 93 figure 4-13. block di agram of p20 to p27 internal bus p20/ani0 to p27/ani7 rd wr port wr pm output latch (p20 to p27) pm20 to pm27 selector pm2 a/d converter pm2: port mode register 2 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 94 4.2.4 port 3 port 3 is a 4-bit i/o port with an output latch. port 3 can be set to the input mode or output mode in 1-bit units using port mode register 3 (pm3). when used as an input por t, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resist or option register 3 (pu3). this port can also be used for external interrupt request input and timer i/o. reset input sets port 3 to input mode. figures 4-14 and 4-15 show block diagrams of port 3. caution in the pd78f0397d, be sure to pull the p31 pin down after reset to prevent malfunction. remark p31/intp2 and p32/intp3 of the pd78f0397d can be used as on-chip debug mode setting pins when the on-chip debug function is used. for details, see chapter 27 on-chip debug function ( pd78f0397d only). figure 4-14. block di agram of p30 to p32 p30/intp1 to p32/intp3 wr pu rd wr port wr pm pu30 to pu32 alternate function output latch (p30 to p32) pm30 to pm32 v dd p-ch selector internal bus pu3 pm3 pu3: pull-up resistor option register 3 pm3: port mode register 3 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 95 figure 4-15. blo ck diagram of p33 p33/intp4/ti51/to51 wr pu rd wr port wr pm pu33 alternate function output latch (p33) pm33 alternate function v dd p-ch selector internal bus pu3 pm3 pu3: pull-up resistor option register 3 pm3: port mode register 3 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 96 4.2.5 port 7 port 7 is an 8-bit i/o port with an output latch. port 7 can be set to the input mode or output mode in 1-bit units using port mode register 7 (pm7). when the p70 to p77 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 7 (pu7). this port can also be used for key return input. reset input sets port 7 to input mode. figure 4-16 shows a block diagram of port 7. figure 4-16. block di agram of p70 to p77 p70/kr0 to p77/kr7 wr pu rd wr port wr pm pu70 to pu77 alternate function output latch (p70 to p77) pm70 to pm77 v dd p-ch selector internal bus pu7 pm7 pu7: pull-up resistor option register 7 pm7: port mode register 7 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 97 4.2.6 port 12 port 12 is a 5-bit i/o port with an output latch. port 12 can be set to the input mode or output mode in 1-bit units using port mode register 12 (pm12). when used as an input por t only for p120, use of an on-chip pull-up resistor can be specified by pull-up resistor option register 12 (pu12). this port can also be used for external interrupt request input, potential input for external low-voltage detection, resonator for main system clock connection, external cl ock input, and resonator for subsystem clock connection. reset input sets port 12 to input mode. figures 4-17 and 4-18 show block diagrams of port 12. caution when using p121/x1, p122/x 2/exclk, p123/xt1, or p124/xt2/exc lks to connect a resonator for the main system clock or subsystem clock, or to input an external clock, the x1 oscillation mode, xt1 oscillation mode, or external clock input m ode must be set by using the clock operation mode select register (oscctl) (for details, see 5.3 (1) clock operation mode select register (oscctl) and (3) setting of op eration mode for subsystem clo ck pin). the reset value of oscctl is 00h (all p121 to p124 are i/o port pins). at this time, settings of pm121 to pm124 and p121 to p124 are not necessary. remark x1 and x2 of the pd78f0397d can be used as on-chip debug mode setting pins when the on-chip debug function is used. for details, see chapter 27 on-chip debug function ( pd78f0397d only) . figure 4-17. blo ck diagram of p120 p120/intp0/exlvi wr pu rd wr port wr pm pu120 alternate function output latch (p120) pm120 v dd p-ch selector internal bus pu12 pm12 pu12: pull-up resistor option register 12 pm12: port mode register 12 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 98 figure 4-18. block di agram of p121 to p124 p122/x2/exclk, p124/xt2/exclks rd wr port wr pm output latch (p122/p124) pm122/pm124 pm12 pm12 rd wr port wr pm output latch (p121/p123) pm121/pm123 pm12 pm12 exclk, oscsel/ exclks, oscsels oscctl oscsel/ oscsels oscctl p121/x1,p123/xt1 oscsel/ oscsels oscctl oscsel/ oscsels oscctl selector selector internal bus pu12: pull-up resistor option register 12 pm12: port mode register 12 rd: read signal wr : write signal chapter 4 port functions preliminary user?s manual u17473ej1v0ud 99 4.3 registers controlling port function port functions are controlled by the following four types of registers. ? port mode registers (pm0 to pm3, pm7, pm12) ? port registers (p0 to p3, p7, p12) ? pull-up resistor option registers (pu0, pu1, pu3, pu7, pu12) ? a/d port configuration register (adpc) (1) port mode registers (pm0 to pm3, pm7, and pm12) these registers specify input or output mode for the port in 1-bit units. these registers can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets these registers to ffh. when port pins are used as alternate-function pins, set the port mode register and output latch as shown in table 4-4. figure 4-19. format of port mode register 7 1 symbol pm0 6 pm06 5 pm05 4 pm04 3 pm03 2 pm02 1 pm01 0 pm00 address ff20h after reset ffh r/w r/w pm17 pm1 pm16 pm15 pm14 pm13 pm12 pm11 pm10 ff21h ffh r/w pm27 pm2 pm26 pm25 pm24 pm23 pm22 pm21 pm20 ff22h ffh r/w 1 pm3 1 1 1 pm33 pm32 pm31 pm30 ff23h ffh r/w pm77 pm7 pm76 pm75 pm74 pm73 pm72 pm71 pm70 ff27h ffh r/w 1 pm12 1 1 pm124 pm123 pm122 pm121 pm120 ff2ch ffh r/w pmmn pmn pin i/o mode selection (m = 0 to 3, 7, 12; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) remark for pm6, see 16.3 registers to control serial interface iic0 . for pm14, see 11.3 registers controlling clock output controller or 17.3 registers controlling lcd controller/driver . chapter 4 port functions preliminary user?s manual u17473ej1v0ud 100 (2) port registers (p0 to p3, p7, p12) these registers write the data t hat is output from the chip when data is output from a port. if the data is read in the input mode, the pin level is read. if it is read in the output mode, the value of the output latch is read. these registers can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears these registers to 00h. figure 4-20. format of port register 7 0 symbol p0 6 p06 5 p05 4 p04 3 p03 2 p02 1 p01 0 p00 address ff00h after reset 00h (output latch) r/w r/w p17 p1 p16 p15 p14 p13 p12 p11 p10 ff01h 00h (output latch) r/w r/w p27 p2 p26 p25 p24 p23 p22 p21 p20 ff02h 00h (output latch) 0 p3 0 0 0 p33 p32 p31 p30 ff03h 00h (output latch) r/w p77 p7 p76 p75 p74 p73 p72 p71 p70 ff07h 00h (output latch) r/w 0 p12 0 0 p124 p123 p122 p121 p120 ff0ch 00h (output latch) r/w m = 0 to 3, 7, 12; n = 0 to 7 pmn output data control (in output mode) input data read (in input mode) 0 output 0 input low level 1 output 1 input high level remark for p13, see 17.3 registers controlling lcd controller/driver . chapter 4 port functions preliminary user?s manual u17473ej1v0ud 101 (3) pull-up resistor option regist ers (pu0, pu1, pu3, pu7, pu12) these registers specify whether the on-ch ip pull-up resistors of p00 to p06, p 10 to p17, p30 to p33, p70 to p77, and p120 are to be used or not. on-chip pull-up resistors can be used in 1-bit units only for the bits set to input mode of the pins to which the use of an on-chip pull-up resistor has been s pecified in pu0, pu1, pu3, pu7, and pu12. on-chip pull-up resistors cannot be connected to bits set to output mode and bits used as alternate- function output pins, regardless of the setti ngs of pu0, pu1, pu3, pu7, and pu12. these registers can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears these registers to 00h. figure 4-21. format of pull-up resistor option register 7 0 symbol pu0 6 pu06 5 pu05 4 pu04 3 pu03 2 pu02 1 pu01 0 pu00 address ff30h after reset 00h r/w r/w pu17 pu1 pu16 pu15 pu14 pu13 pu12 pu11 pu10 ff31h 00h r/w 0 pu3 0 0 0 pu33 pu32 pu31 pu30 ff33h 00h r/w pu77 pu7 pu76 pu75 pu74 pu73 pu72 pu71 pu70 ff37h 00h r/w 0 pu12 0 0 0 0 0 0 pu120 ff3ch 00h r/w pumn pmn pin on-chip pull-up resistor selection (m = 0, 1, 3, 7, 12; n = 0 to 7) 0 on-chip pull-up resistor not connected 1 on-chip pull-up resistor connected chapter 4 port functions preliminary user?s manual u17473ej1v0ud 102 (4) a/d port configuration register (adpc) this register switches the p20/ani0 to p27/ani7 pins to analog in put of a/d converter or digital i/o of port. adpc can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 4-22. format of a/d port configuration register (adpc) adpc0 adpc1 adpc2 adpc3 0 0 0 0 analog input (a)/digital input (d) switching setting prohibited adpc3 0 1 2 3 4 5 6 7 adpc address: ff2fh after reset: 00h r/w symbol p27/ ani7 a a a a a a a a d p26/ ani6 a a a a a a a d d p25/ ani5 a a a a a a d d d p24/ ani4 a a a a a d d d d p23/ ani3 a a a a d d d d d p22/ ani2 a a a d d d d d d p21/ ani1 a a d d d d d d d p20/ ani0 a d d d d d d d d 0 0 0 0 0 0 0 0 1 adpc2 0 0 0 0 1 1 1 1 0 adpc1 0 0 1 1 0 0 1 1 0 adpc0 0 1 0 1 0 1 0 1 0 other than above cautions 1. set the channel used for a/d conversion in the input mode by using port mode register 2 (pm2). 2. do not set a pin to be used as a digital i/o pin with adpc with ads. 3. if data is written to adpc, a wait cycle is ge nerated. do not write data to adpc when the cpu is operating on the subsystem clock and the pe ripheral hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 4 port functions preliminary user?s manual u17473ej1v0ud 103 4.4 port function operations port operations differ depending on whether the inpu t or output mode is set, as shown below. caution in the case of 1-bit memory manipulation instru ction, although a single bit is manipulated, the port is accessed as an 8-bit unit. therefore, on a port with a mixture of input and output pins, the output latch contents for pins specified as input are undefined, even for bits other than the manipulated bit. 4.4.1 writing to i/o port (1) output mode a value is written to the output latch by a transfer instruct ion, and the output latch content s are output from the pin. once data is written to the output latch, it is reta ined until data is written to the output latch again. the data of the output latch is cleared by reset. (2) input mode a value is written to the output latch by a transfer instruction, but since the output buffer is off, the pin status does not change. once data is written to the output latch, it is reta ined until data is written to the output latch again. 4.4.2 reading from i/o port (1) output mode the output latch contents ar e read by a transfer instruction. t he output latch content s do not change. (2) input mode the pin status is read by a transfer instruct ion. the output latch c ontents do not change. 4.4.3 operations on i/o port (1) output mode an operation is performed on the output latch contents, and the result is wr itten to the output latch. the output latch contents are output from the pins. once data is written to the output latch, it is reta ined until data is written to the output latch again. the data of the output latch is cleared by reset. (2) input mode the pin level is read and an operation is performed on its cont ents. the result of the op eration is written to the output latch, but since the output buffer is off, the pin status does not change. chapter 4 port functions preliminary user?s manual u17473ej1v0ud 104 4.5 settings of port mode register and output latch when using alternate function when port pins are used as alternate-function pins, set t he port mode register and output latch as shown in table 4-5. table 4-5. settings of port mode register and output latch when using alternate function alternate function pin name function name i/o pm p p00 ti000 input 1 ti010 input 1 p01 to00 output 0 0 p02 so11 note1 output 0 0 p03 si11 note1 input 1 input 1 p04 sck11 note1 output 0 1 ssi11 note1 input 1 p05 ti001 note1 input 1 ti011 note1 input 1 p06 to01 note1 output 0 0 input 1 sck10 output 0 1 p10 txd0 output 0 1 si10 input 1 p11 rxd0 input 1 p12 so10 output 0 0 p13 txd6 output 0 1 p14 rxd6 input 1 p15 toh0 output 0 0 toh1 output 0 0 p16 intp5 input 1 ti50 input 1 p17 to50 output 0 0 p20 to p27 note2 ani0 to ani7 note2 input 1 p30 to p32 intp1 to intp3 input 1 intp4 input 1 ti51 input 1 p33 to51 output 0 0 p70 to p77 kr0 to kr7 input 1 intp0 input 1 p120 exlvi input 1 p121 x1 note3 ? x2 note3 ? p122 exclk note3 input p123 xt1 note3 ? xt2 note3 ? p124 exclks note3 input (refer to notes and remarks on the next page.) chapter 4 port functions preliminary user?s manual u17473ej1v0ud 105 notes1. so11, si11, sck11, ssi11, ti001, ti011, and to01 are available only in the pd78f0395, 78f0397, and 78f0397d. 2. the functions of the ani0/p20 to ani7/p27 pins ar e determined according to the settings of a/d port configuration register (adpc), analog input channel specificat ion register (ads), and pm2. table 4-6. settings of ani0/ p20 to ani7/p27 pin function adpc setting pm2 setting ads setting p20/ani0 to p27/ani7 pins ani selection analog input (target for conversion) input mode ani non-selection analog input (target for non- conversion) ani selection analog input selection output mode ani non-selection setting prohibited ani selection setting prohibited input mode ani non-selection digital input ani selection setting prohibited digital i/o selection output mode ani non-selection digital output 3. when using p121/x1, p122/x2/exclk, p123/xt1, or p124/xt2/exclks to connect a resonator for the main system clock or subsystem clock, or to input an external clock, the x1 oscillation mode, xt1 oscillation mode, or external clock input mode must be set by using the clock operation mode select register (oscctl) (for details, see 5.3 (1) clock operation mode select register (oscctl) and (3) setting of operati on mode for subsystem clock pin ). the reset value of oscctl is 00h (all p121 to p124 are i/o port pins). at this time, settings of pm121 to pm124 and p121 to p124 are not necessary. remarks1. : don?t care pm : port mode register p : port output latch 2. x1, x2, p31, and p32 pins of the pd78f0397d can be used as on-chip debug mode setting pins when the on-chip debug function is used. for details, see chapter 27 on-chip debug function ( pd78f0397d only) . preliminary user?s manual u17473ej1v0ud 106 chapter 5 clock generator 5.1 functions of clock generator the clock generator generates the clock to be supplied to the cpu and peripheral hardware. the following three kinds of system clo cks and clock oscillators are selectable. (1) main system clock <1> x1 oscillator this circuit oscillates a clock of f x = 1 to 20 mhz by connecting a resonator across x1 and x2. oscillation can be stopped by executing the stop inst ruction or using the main osc control register (moc). <2> high-speed ring-osc oscillator this circuit oscillates a clock of f rh = 8 mhz (typ.). after a reset release, the cpu always starts operating with this high-speed ring-osc clock. oscillation can be stopped by executing the stop instruction or using the ri ng-osc mode register (rcm). an external main system clock (f exclk = 1 to 20 mhz) can also be supplied from the exclk/x2/p122 pin. an external main system clock input can be disabled by executing the stop in struction or using rcm. as the main system clock, a high-speed system clock (x 1 clock or external main system clock) or high-speed ring-osc clock can be selected by using the main clock mode register (mcm). (2) subsystem clock ? subsystem clock oscillator this circuit oscillates at a frequency of f xt = 32.768 khz by connecting a 32.768 khz resonator across xt1 and xt2. oscillation can be stopped by using the pr ocessor clock control register (pcc) and clock operation mode select register (oscctl). an external subsystem clock (f exclks = 32.768 khz) can also be supplied from the exclks/xt2/p124 pin. an external subsystem clock input can be disabled by setting pcc and oscctl. remarks 1. f x : x1 clock oscillation frequency 2. f rh : high-speed ring-osc clock oscillation frequency 3. f exclk : external main system clock frequency 4. f xt : xt1 clock oscillation frequency 5. f exclks : external subsystem clock frequency chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 107 (3) low-speed ring-osc clock (clock for watchdog timer) ? low-speed ring-osc oscillator this circuit oscillates a clock of f rl = 240 khz (typ.). after a reset re lease, the low-speed ring-osc clock always starts operating. oscillation can be stopped by using the ring-os c mode register (rcm) when ?low-speed ring-osc oscillation can be stopped by software? is set by option byte. the low-speed ring-osc clock cannot be used as the cp u clock. the following hardware operates with the low-speed ring-osc clock. ? watchdog timer ? tmh1 (when f rl , f rl /2 7 , or f rl /2 9 is selected) remark f rl : low-speed ring-osc clock oscillation frequency 5.2 configuration of clock generator the clock generator includes the following hardware. table 5-1. configuration of clock generator item configuration control registers clock operation mode select register (oscctl) processor clock control register (pcc) ring-osc mode register (rcm) main osc control register (moc) main clock mode register (mcm) oscillation stabilization time counter status register (ostc) oscillation stabilization time select register (osts) oscillators x1 oscillator xt1 oscillator high-speed ring-osc oscillator low-speed ring-osc oscillator chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 108 figure 5-1. block diag ram of clock generator option byte 1: cannot be stopped 0: can be stopped ring-osc mode register (rcm) lsrstop rsts rstop high-speed ring-osc oscillator (8 mhz (typ.)) low-speed ring-osc oscillator (240 khz (typ.)) f rl clock operation mode select register (oscctl) oscsels exclks xt1/p123 xt2/exclks/ p124 f sub peripheral hardware clock (f prs ) watchdog timer, 8-bit timer h1 watch timer, lcd controller/driver 1/2 cpu clock (f cpu ) processor clock control register (pcc) css pcc2 cls pcc1 pcc0 prescaler main system clock switch f xp peripheral hardware clock switch x1 oscillation stabilization time counter osts1 osts0 osts2 oscillation stabilization time select register (osts) 3 most 16 most 15 most 14 most 13 most 11 oscillation stabilization time counter status register (ostc) controller mcm0 xsel mcs mstop stop exclk oscsel amph clock operation mode select register (oscctl) 4 f xp 2 f xp 2 2 f xp 2 3 f xp 2 4 main clock mode register (mcm) main clock mode register (mcm) main osc control register (moc) f rh internal bus internal bus high-speed system clock oscillator crystal/ceramic oscillation external input clock x1/p121 x2/exclk/ p122 f xh f sub 2 crystal oscillation external input clock subsystem clock oscillator f x f exclk f xt f exclks selector xtstart processor clock control register (pcc) xtstart subsystem clock oscillator chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 109 remarks 1. f x : x1 clock oscillation frequency 2. f rh : high-speed ring-osc clock oscillation frequency 3. f exclk : external main system clock frequency 4. f xh : high-speed system clock oscillation frequency 5. f xp : main system clock oscillation frequency 6. f prs : peripheral hardware clock oscillation frequency 7. f cpu : cpu clock oscillation frequency 8. f xt : xt1 clock oscillation frequency 9. f exclks : external subsystem clock frequency 10. f sub : subsystem clock oscillation frequency 11. f rl : low-speed ring-osc clock oscillation frequency 5.3 registers controlling clock generator the following seven registers are used to control the clock generator. ? clock operation mode sele ct register (oscctl) ? processor clock control register (pcc) ? ring-osc mode register (rcm) ? main osc control register (moc) ? main clock mode register (mcm) ? oscillation stabilization time c ounter status register (ostc) ? oscillation stabilization time select register (osts) (1) clock operation mode select register (oscctl) this register selects the operation mo des of the high-speed system and s ubsystem clocks, and the gain of the on-chip oscillator. oscctl can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 110 figure 5-2. format of clock operati on mode select register (oscctl) address: ff9fh after reset: 00h r/w symbol <7> <6> <5> <4> 3 2 1 <0> oscctl exclk oscsel exclks note oscsels note 0 0 0 amph exclk oscsel high-speed system clock pin operation mode p121/x1 pin p122/x2/exclk pin 0 0 i/o port mode i/o port 0 1 x1 oscillation mode crystal/ceramic resonator connection 1 0 i/o port mode i/o port 1 1 external clock input mode i/o port external clock input amph operating frequency control 0 1 mhz f xh 10 mhz 1 10 mhz < f xh 20 mhz note exclks and oscsels are used in combinatio n with xtstart (bit 6 of the processor clock control register (pcc)). refer to (3) setting of operati on mode for subsystem clock pin . cautions 1. be sure to set amph to 1 if the high-speed system cl ock oscillation frequency exceeds 10 mhz. 2. set amph before setting the peripheral functions after a reset release. the value of amph can be changed only once after a reset release. the clock supply to the cpu is stopped for 5 s (min.) after amph has been set to 1. 3. if the stop instruction is execute d with amph set to 1 when the high-speed ring-osc clock or external main system clock is used as th e cpu clock, then the clock supply to the cpu is stopped for 5 s (min.) after the stop mode has been released. if the x1 clock is used as the cpu clock, oscillation stabilization time is counted after the st op mode has been released. 4. to change the value of exclk and oscsel, be sure to confirm that bit 7 (mstop) of the main osc control register (moc) is 1 (the x1 oscillator stops or the external clock from the exclk pin is disabled). remark f xh : high-speed system clock oscillation frequency chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 111 (2) processor clock control register (pcc) this register is used to select t he cpu clock, the division ratio, and operation mode for subsystem clock. pcc is set by a 1-bit or 8-bit memory manipulation instruction. reset input sets pcc to 01h. figure 5-3. format of processor clock control register (pcc) address: fffbh after reset: 01h r/w note 1 symbol 7 6 <5> <4> 3 2 1 0 pcc 0 xtstart note2 cls css 0 pcc2 pcc1 pcc0 cls cpu clock status 0 main system clock 1 subsystem clock notes 1. bit 5 is read-only. 2. xtstart is used in combination with exc lks and oscsels (bits 5 and 4 of the clock operation mode select register (oscctl)). refer to (3) setting of operation mode for subsystem clock pin . caution be sure to clear bits 3 and 7 to 0. remarks 1. f xp : main system clock oscillation frequency 2. f sub : subsystem clock oscillation frequency the fastest instruction can be executed in 2 clocks of t he cpu clock in the 78k0/lg2. therefore, the relationship between the cpu clock (f cpu ) and the minimum instruction execution time is as shown in table 5-2. css pcc2 pcc1 pcc0 cpu clock (f cpu ) selection 0 0 0 f xp 0 0 1 f xp /2 (default) 0 1 0 f xp /2 2 0 1 1 f xp /2 3 0 1 0 0 f xp /2 4 0 0 0 0 0 1 0 1 0 0 1 1 1 1 0 0 f sub /2 other than above setting prohibited chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 112 table 5-2. relationship between cpu clo ck and minimum instruction execution time minimum instruction execution time: 2/f cpu high-speed system clock note high-speed ring-osc clock note subsystem clock cpu clock (f cpu ) at 10 mhz operation at 20 mhz operation at 8 mhz (typ.) operation at 32.768 khz operation f xp 0.2 s 0.1 s 0.25 s (typ.) ? f xp /2 0.4 s 0.2 s 0.5 s (typ.) ? f xp /2 2 0.8 s 0.4 s 1.0 s (typ.) ? f xp /2 3 1.6 s 0.8 s 2.0 s (typ.) ? f xp /2 4 3.2 s 1.6 s 4.0 s (typ.) ? f sub /2 ? ? 122.1 s note the main clock mode register (mcm) is used to set the main system clock supplied to cpu clock (high- speed system clock/high-s peed ring-osc clock) (see figure 5-6 ). (3) setting of operation mode for subsystem clock pin the operation mode for the subsystem clock pin can be se t by using bit 6 (xtstart) of the processor clock control register (pcc) and bits 5 and 4 (exclks, osc sels) of the clock operation mode select register (oscctl) in combination. table 5-3. setting of operati on mode for subsystem clock pin pcc oscctl bit 6 bit 5 bit 4 xtstart exclks oscsels subsystem clock pin operation mode p123/xt1 pin p124/xt2/exclks pin 0 0 0 i/o port mode i/o port 0 0 1 xt1 oscillation mode crystal resonator connection 0 1 0 i/o port mode i/o port 0 1 1 external clock input mode i/o port external clock input 1 xt1 oscillation mode crystal resonator connection caution confirm that bit 5 (cls) of the processor clock cont rol register (pcc) is 0 (cpu is operating with main system clock) when changing the current valu es of xtstart, exclks, and oscsels. remark : don?t care chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 113 (4) ring-osc mode register (rcm) this register sets the operation mode of ring-osc. rcm can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to 80h note 1 . figure 5-4. format of ring-osc mode register (rcm) address: ffa0h after reset: 80h note 1 r/w note 2 symbol <7> 6 5 4 3 2 <1> <0> rcm rsts 0 0 0 0 0 lsrstop rstop rsts status of high-speed ring-osc oscillation 0 waiting for accuracy stabilization of high-speed ring-osc oscillation 1 stability operating of high-speed ring-osc oscillation lsrstop low-speed ring-osc oscillating/stopped 0 low-speed ring-osc oscillating 1 low-speed ring-osc stopped rstop high-speed ring-osc oscillating/stopped 0 high-speed ring-osc oscillating 1 high-speed ring-osc stopped notes 1. the value of this register is 00h immedi ately after a reset release but automatically changes to 80h after high-speed ring-osc oscillation has been stabilized. 2. bit 7 is read-only. caution when setting rstop to 1, be sure to confirm that the cpu operates with a clock other than the high-speed ri ng-osc clock. specifically, set under either of the following conditions. ? when mcs = 1 (when cpu operates with the high-speed system clock) ? when cls = 1 (when cpu opera tes with the subsystem clock) in addition, stop peripheral hardware that is operating on the high-speed ring-osc clock before setting rstop to 1. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 114 (5) main osc control register (moc) this register selects the operati on mode of the high-speed system clock. this register is used to stop the x1 oscillator or to disable an external clock input from the exclk pin when the cpu operates with a clock other than the high-speed system clock. moc can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to 80h. figure 5-5. format of main osc control register (moc) address: ffa2h after reset: 80h r/w symbol <7> 6 5 4 3 2 1 0 moc mstop 0 0 0 0 0 0 0 control of high-speed system clock operation mstop x1 oscillation mode external clock input mode 0 x1 oscillator operating external clock from exclk pin is enabled 1 x1 oscillator stopped external clock from exclk pin is disabled cautions 1. when setting ms top to 1, be sure to confirm that the cpu operates with a clock other than the high-speed system clock. specifically , set under either of the following conditions. ? when mcs = 0 (when cpu operates wit h the high-speed ring-osc clock) ? when cls = 1 (when cpu opera tes with the subsystem clock) in addition, stop peripheral hardware th at is operating on the high-speed system clock before setting mstop to 1. 2. do not clear mstop to 0 while bit 6 (oscsel) of the clock operation mode select register (oscctl) is 0 (i/o port mode). 3. the peripheral hardware cannot operate when the pe ripheral hardware clock is stopped. to resume the operation of the peripheral hardware after the peripheral hardware clock has been stopped, in itialize the peri pheral hardware. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 115 (6) main clock mode register (mcm) this register selects the main system clock supplied to cpu clock and clock supplied to peripheral hardware clock. mcm can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 5-6. format of main clock mode register (mcm) address: ffa1h after reset: 00h r/w note symbol 7 6 5 4 3 <2> <1> <0> mcm 0 0 0 0 0 xsel mcs mcm0 selection of clock supplied to main system clock and peripheral hardware xsel mcm0 main system clock (f xp ) peripheral hardware clock (f prs ) 0 0 0 1 high-speed ring-osc clock (f rh ) 1 0 high-speed ring-osc clock (f rh ) 1 1 high-speed system clock (f xh ) high-speed system clock (f xh ) mcs main system clock status 0 operates with hi gh-speed ring-osc clock 1 operates with hi gh-speed system clock note bit 1 is read-only. cautions 1. xsel can be change d only once after a reset release. 2. a clock other than f prs is supplied to the following peripheral functions regardless of the se tting of xsel and mcm0. ? watchdog timer (operates with low-speed ring-osc clock) ? when ?f rl ?, ?f rl /2 7 ?, or ?f rl /2 9 ? is selected as the count clock for 8-bit timer h1 (operates with low-speed ring-osc clock) ? peripheral hardware selects the ext ernal clock as the clock source (except when the external count clock of tm 0n (n = 0, 1) is selected (ti00n pin valid edge)) chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 116 (7) oscillation stabilization time counter status register (ostc) this is the register that indicates t he count status of the x1 clock oscillati on stabilization time counter. when x1 clock oscillation starts with the high-speed ring-osc cloc k or subsystem clock used as the cpu clock, the x1 clock oscillation stabilization time can be checked. ostc can be read by a 1-bit or 8-bit memory manipulation instruction. when reset is released (reset by reset input, poc, lv i, and wdt), the stop instruction and mstop (bit 7 of moc register) = 1 clear ostc to 00h. figure 5-7. format of oscillation stabilizati on time counter status register (ostc) address: ffa3h after reset: 00h r symbol 7 6 5 4 3 2 1 0 ostc 0 0 0 most11 most 13 most14 most15 most16 most11 most13 most14 most15 most16 oscillation stabilization time status f x = 10 mhz f x = 20 mhz 1 0 0 0 0 2 11 /f x min. 204.8 s min. 102.4 s min. 1 1 0 0 0 2 13 /f x min. 819.2 s min. 409.6 s min. 1 1 1 0 0 2 14 /f x min. 1.64 ms min. 819.2 s min. 1 1 1 1 0 2 15 /f x min. 3.27 ms min. 1.64 ms min. 1 1 1 1 1 2 16 /f x min. 6.55 ms min. 3.27 ms min. cautions 1. after the above time has elapsed, th e bits are set to 1 in order from most11 and remain 1. 2. the oscillation stabilization time counter counts up to the oscillation stabilization time set by osts. if the st op mode is entered and then released while the high-speed ring- osc clock or subsystem cl ock is being used as the cpu clock, set the oscillation stabilization time as follows. ? desired ostc oscillation stabilization time oscillation stabilization time set by osts note, therefore, that only the status up to the oscillation stabilization time set by osts is set to ostc afte r stop mode is released. 3. the x1 clock oscillation stabilization wa it time does not include the time until clock oscillation starts (?a? below). stop mode release x1 pin voltage waveform a remark f x : x1 clock oscillation frequency chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 117 (8) oscillation stabilization time select register (osts) this register is used to select the x1 clock oscillation stabilization wait time when the stop mode is released. when the x1 clock is selected as the cpu clock, the operation waits for the time set using osts after the stop mode is released. when the high-speed ring-osc clock is selected as the cpu clock, confirm with ostc that the desired oscillation stabilization time has elapsed after the stop mode is released. the oscillation stabilization time can be checked up to the time set using ostc. osts can be set by an 8-bit memory manipulation instruction. reset input sets osts to 05h. figure 5-8. format of oscillation stabiliz ation time select register (osts) address: ffa4h after reset: 05h r/w symbol 7 6 5 4 3 2 1 0 osts 0 0 0 0 0 osts2 osts1 osts0 osts2 osts1 osts0 oscillation stabilization time selection f x = 10 mhz f x = 20 mhz 0 0 1 2 11 /f x 204.8 s 102.4 s 0 1 0 2 13 /f x 819.2 s 409.6 s 0 1 1 2 14 /f x 1.64 ms 819.2 s 1 0 0 2 15 /f x 3.27 ms 1.64 ms 1 0 1 2 16 /f x 6.55 ms 3.27 ms other than above setting prohibited cautions 1. to set the stop mode when the x1 clock is used as the cpu clock, set osts before executing the stop instruction. 2. do not change the value of the osts register during the x1 clock oscillation stabilization time. 3. the oscillation stabilization time counter counts up to the oscillation stabilization time set by osts. if the st op mode is entered and then released while the high-speed ring- osc clock or subsystem cl ock is being used as the cpu clock, set the oscillation stabilization time as follows. ? desired ostc oscillation stabilization time oscillation stabilization time set by osts note, therefore, that only the status up to the oscillation stabilization time set by osts is set to ostc afte r stop mode is released. 4. the x1 clock oscillation stabilization wa it time does not include the time until clock oscillation starts (?a? below). stop mode release x1 pin voltage waveform a remark f x : x1 clock oscillation frequency chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 118 5.4 system clock oscillator 5.4.1 x1 oscillator the x1 oscillator oscillates with a cryst al resonator or ceramic resonator (1 to 20 mhz) connected to the x1 and x2 pins. figure 5-9 shows an example of the exte rnal circuit of the x1 oscillator. figure 5-9. example of external circuit of x1 oscillator (crystal or ceramic oscillation) v ss x1 x2 crystal resonator or ceramic resonator cautions are listed on the next page. 5.4.2 xt1 oscillator the xt1 oscillator oscillates with a crystal resonator (standard: 32.768 khz) connected to the xt1 and xt2 pins. figure 5-10 shows an example of the exte rnal circuit of the xt1 oscillator. figure 5-10. example of external circuit of xt1 oscillator (crystal oscillation) xt2 v ss xt1 32.768 khz cautions are listed on the next page. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 119 cautions 1. when using the x1 oscillator and xt1 o scillator, wire as follows in the area enclosed by the broken lines in the figures 5-9 and 5-10 to avoid an adverse e ffect from wiring capacitance. keep the wiring length as short as possible. do not cross the wiring with the other signal li nes. do not route the wiring near a signal line through which a high fluctuating current flows. always make the ground point of the os cillator capacitor the same potential as v ss . do not ground the capacitor to a ground patter n through which a high current flows. do not fetch signals from the oscillator. note that the xt1 oscillator is designed as a low-amplitude circuit for reducing power consumption. figure 5-11 shows examples of incorrect resonator connection. figure 5-11. examples of incorr ect resonator connection (1/2) (a) too long wiring (b) crossed signal line x2 v ss x1 x1 v ss x2 port remark when using the subsystem clock, replace x1 and x2 with xt1 and xt2, respectively. also, insert resistors in series on the xt2 side. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 120 figure 5-11. examples of incorr ect resonator connection (2/2) (c) wiring near high alternating current (d) current flowing through ground line of oscillator (potential at points a, b, and c fluctuates) v ss x1 x2 v ss x1 x2 ab c pmn v dd high current high current (e) signals are fetched v ss x1 x2 remark when using the subsystem clock, replace x1 and x2 with xt1 and xt2, respectively. also, insert resistors in series on the xt2 side. cautions 2. when x2 and xt1 are wired in paralle l, the crosstalk noise of x2 may increase with xt1, resulting in malfunctioning. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 121 5.4.3 when subsystem clock is not used if it is not necessary to use the subsystem clock for low power consumption operat ions, or if not using the subsystem clock as an i/o port, set the xt1 and xt2 pins to i/o mode (oscsel = 0) and connect them as follows. input (pm123/pm124 = 1): i ndependently connect to v dd or v ss via a resistor. output (pm123/pm124 = 0): leave open. remark oscsel: bit 6 of clock operation mode select register (oscctl) pm123, pm124: bits 3 and 4 of port mode register 12 (pm12) 5.4.4 high-speed ring-osc oscillator the high-speed ring-osc oscillator is incorporated in t he 78k0/lg2. oscillation can be controlled by the ring- osc mode register (rcm). after a reset release, the high-speed ring-osc clo ck automatically starts oscillation (8 mhz (typ.)). 5.4.5 low-speed ring-osc oscillator the low-speed ring-osc oscillator is incorporated in the 78k0/lg2. the low-speed ring-osc oscillation clock is only used as th e watchdog timer and the clock of 8-bit timer h1. the low-speed ring-osc clock cannot be used as the cpu clock. ?can be stopped by software? or ?cannot be stopped? ca n be selected by the option byte. when ?can be stopped by software? is set, oscillation can be contro lled by the ring-osc mode register (rcm). after a reset release, the low-speed ring-osc clock autom atically starts oscillation, and the watchdog timer is driven (240 khz (typ.)) if the watchdog timer operation is enabled using the option byte. 5.4.6 prescaler the prescaler generates various clocks by dividing the main system clock when the ma in system clock is selected as the clock to be supplied to the cpu. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 122 5.5 clock generator operation the clock generator generates the following clocks and contro ls the operation modes of the cpu, such as standby mode (see figure 5-1 ). ? main system clock f xp ? high-speed system clock f xh x1 clock f x external main system clock f exclk ? high-speed ring-osc clock f rh ? subsystem clock f sub ? xt1 clock f xt ? external subsystem clock f exclks ? low-speed ring-osc clock f rl ? cpu clock f cpu ? peripheral hardware clock f prs the cpu starts operation when the on-chip high-speed ring-osc oscillator starts outputting after a reset release in the 78k0/lg2, thus enabling the following. (1) enhancement of security function when the x1 clock is set as the cpu clock by the defaul t setting, the device cannot operate if the x1 clock is damaged or badly connected and therefore does not operate after reset is released. however, the start clock of the cpu is the on-chip high-speed ring-osc clock, so the device can be started by the high-speed ring-osc clock after a reset release. cons equently, the system can be safely shut down by performing a minimum operation, such as acknowledging a reset source by softw are or performing safety processing when there is a malfunction. (2) improvement of performance because the cpu can be started with out waiting for the x1 clock oscillation stabilization time, the total performance can be improved. when the power supply voltage is turned on, the clock generator operation is shown in figure 5-12. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 123 figure 5-12. clock generator operation wh en power supply voltage is turned on high-speed ring-osc clock (f rh ) cpu clock high-speed system clock (f xh ) (when x1 oscillation selected) high-speed ring-osc clock high-speed system clock switched by software subsystem clock (f sub ) (when xt1 oscillation selected) subsystem clock x1 clock oscillation stabilization time: 2 11 /f x to 2 16 /f x note starting x1 oscillation is specified by software. starting xt1 oscillation is specified by software. reset processing (20 s (typ.)) waiting for voltage stabilization (3.24 ms (typ.)) internal reset signal 0 v 1.59 v (typ.) 1.8 v 0.5 v/ms (max.) power supply voltage(v dd) <1> <2> <3> <4> <5> <5> <4> waiting for oscillation accuracy stabilization <1> when the power is turned on, an internal reset signal is generated by the power-on-clear (poc) circuit. <2> when the power supply voltage exceeds 1.59 v (typ.), the reset is released and the high-speed ring-osc clock automatically starts oscillation. <3> when the power supply voltage rises with a slope of 0.5 v/ms (max.), the cpu st arts operation on the high- speed ring-ocs clock after the reset is released and afte r the stabilization times for the voltage of the power supply and regulator have elapsed, and then reset processing is performed. <4> set the start of oscillation of the x1 or xt1 clock via software (refer to (1) in 5.6.1 example of controlling high-speed system clock and (1) in 5.6.3 example of c ontrolling subsystem clock) . <5> when switching the cpu clock to the x1 or xt1 clock, wait for the clock oscillation to stabilize, and then set switching via software (refer to (2) in 5.6.1 example of controll ing high-speed system clock and (2) in 5.6.3 example of controlling subsystem clock ). note when releasing a reset (above figure) or releasin g stop mode while the cpu is operating on the high- speed ring-osc clock, confirm the oscillation stabiliz ation time for the x1 clock using the oscillation stabilization time counter status r egister (ostc). if the cpu operates on the high-speed system clock (x1 oscillation), set the oscillation stabilization time when releasing stop mode using the oscillation stabilization time select register (osts). cautions 1. if the voltage rises with a slope of less than 0.5 v/ms (ma x.) from power application until the voltage reaches 1.8 v, input a lo w level to the reset pin from power application until the voltage reaches 1.8 v (see figure 5-13). by doing so, the cpu operates with the same timing as <2> and thereafter in figure 5-12 af ter reset release by the reset pin. 2. it is not necessary to wait for the oscillation stabilization ti me when an external clock input from the exclk and exc lks pins is used. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 124 remark while the microcontroller is operating, a clock that is not used as the cpu clock can be stopped via software settings. the high-speed ring-osc clo ck and high-speed system clock can be stopped by executing the stop instruction (refer to (4) in 5.6.1 example of controll ing high-speed system clock , (3) in 5.6.2 example of controllin g high-speed ring-osc clock , and (3) in 5.6.3 example of controlling subsystem clock ). 5.6 controlling clock 5.6.1 example of control ling high-speed system clock the following two types of high-s peed system clocks are available. ? x1 clock: crystal/ceramic resonator is connected across the x1 and x2 pins. ? external main system clock: exter nal clock is input to the exclk pin. when the high-speed system clock is not used, the x1/p 121 and x2/exclk/p122 pins can be used as i/o port pins. caution the x1/p121 and x2/exclk/p122 pins are in the i/o port mode after a reset release. the following describes examples of setti ng procedures for the following cases. (1) when oscillating x1 clock (2) when using external main system clock (3) when using high-speed system clock as cpu clock or peripheral hardware clock (4) when stopping high-speed system clock (1) example of setting procedure when oscillating the x1 clock <1> setting frequency (oscctl register) using amph, set the gain of the on-chip osci llator according to the frequency to be used. amph note operating frequency control 0 1 mhz f xh 10 mhz 1 10 mhz < f xh 20 mhz remark f xh : high-speed system clock oscillation frequency <2> setting x1 and x2 pins and selecting x1 clock or external clock (oscctl register) when exclk is cleared to 0 and oscsel is set to 1, the mode is switched from port mode to x1 oscillation mode. exclk oscsel operation mode of high- speed system clock pin p121/x1 pin p122/x2/exclk pin 0 1 x1 oscillation mode crystal/ceramic resonator connection <3> controlling oscillation of x1 clock (moc register) if mstop is cleared to 0, the x1 oscillator starts oscillating. <4> waiting for the stabilization of the oscillation of x1 clock check the ostc register and wait for the necessary time. during the wait time, other software processing can be executed with the high-speed ring osc clock. note set amph before setting the peripheral functions afte r a reset release. the value of amph can be changed only once after a reset release. when amph is set to 1, the clock supply to the cpu is stopped for 5 s (min.). chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 125 cautions1. do not change the value of exclk and oscsel while the x1 clock is operating. 2. set the x1 clock after the supply voltage has reach ed the operable voltag e of the clock to be used (refer to chapter 29 el ectrical specifications (target)). (2) example of setting procedure when using the external main system clock <1> setting frequency (oscctl register) using amph, set the frequency to be used. amph note operating frequency control 0 1 mhz f xh 10 mhz 1 10 mhz < f xh 20 mhz remark f xh : high-speed system clock oscillation frequency <2> setting p121/x1 and p122/x2/exclk pins and selecting operation mode (oscctl register) when exclk and oscsel are set to 1, the mode is switched from port mode to external clock input mode. exclk oscsel operation mode of high- speed system clock pin p121/x1 pin p122/x2/exclk pin 1 1 external clock input mode i/o port external clock input <3> controlling external main system clock input (moc register) when mstop is cleared to 0, the input of the external main system clock is enabled. note set amph before setting the peripheral functions afte r a reset release. the value of amph can be changed only once after a reset release. when amph is set to 1, the clock supply to the cpu is stopped for 5 s (min.). cautions1. do not change the val ue of exclk and oscsel while th e external main system clock is operating. 2. set the external main syst em clock after the supply volt age has reached the operable voltage of the clock to be used (refer to chapter 29 electrical specifications (target)). (3) example of setting procedure when using hi gh-speed system clock as cpu clock or peripheral hardware clock <1> setting high-speed system clock oscillation note (refer to 5.6.1 (1) example of setting proce dure when oscillating the x1 clock and (2) example of setting procedure when using th e external main system clock. ) note the setting of <1> is not necessary when hi gh-speed system clock is already operating. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 126 <2> setting the high-speed system clock as the main system clock (mcm register) when xsel and mcm0 are set to 1, the high-speed syst em clock is supplied as the main system clock and peripheral hardware clock. selection of main system clock and clock supplied to peripheral hardware xsel mcm0 main system clock (f xp ) peripheral hardware clock (f prs ) 1 1 high-speed system clock (f xh ) high-speed system clock (f xh ) caution if the high-speed system clock is selected as the main syst em clock, a clock other than the high-speed system clock cannot be set as the peripheral hardware clock. <3> setting the main system clock as the cpu clo ck and selecting the division ratio (pcc register) when css is cleared to 0, the main system clock is supplied to the cpu. to select the cpu clock division ratio, use pcc0, pcc1, and pcc2. css pcc2 pcc1 pcc0 cpu clock (f cpu ) selection 0 0 0 f xp 0 0 1 f xp /2 (default) 0 1 0 f xp /2 2 0 1 1 f xp /2 3 1 0 0 f xp /2 4 0 other than above setting prohibited (4) example of setting procedure when stopping the high-speed system clock the high-speed system clock can be st opped in the foll owing two ways. ? executing the stop instruction to set the stop mode ? setting mstop to 1 and stopping the x1 oscillation (dis abling clock input if the external clock is used) (a) to execute a stop instruction <1> setting to stop peripheral hardware stop peripheral hardware that c annot be used in the stop mode (f or peripheral hardware that cannot be used in stop mode, refer to chapter 21 standby function ). <2> setting the x1 clock oscillation st abilization time after standby release when the cpu is operating on the x1 clock, set t he value of the osts r egister before the stop instruction is executed. <3> executing the stop instruction when the stop instruction is ex ecuted, the system is placed in the stop mode and x1 oscillation is stopped (the input of the ex ternal clock is disabled). chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 127 (b) to stop x1 oscillation (disabling exter nal clock input) by setting mstop to 1 <1> confirming the cpu clock st atus (pcc and mcm registers) confirm with cls and mcs that the cp u is operating on a clock other t han the high-speed system clock. when cls = 0 and mcs = 1, the high-speed system cl ock is supplied to the cpu, so change the cpu clock to the subsystem clo ck or high-speed ring-osc clock. cls mcs cpu clock status 0 0 high-speed ring-osc clock 0 1 high-speed system clock 1 subsystem clock <2> stopping the high-speed system clock (moc register) when mstop is set to 1, x1 oscillation is stopp ed (the input of the external clock is disabled). caution be sure to confirm that mcs = 0 or cls = 1 when setting mstop to 1. in addition, stop peripheral hardware that is operating on the high-speed system clock. 5.6.2 example of control ling high-speed ring-osc clock the following describes examples of setti ng procedures for the following cases. (1) example of setting procedure when restar ting high-speed ring-osc clock oscillation (2) example of setting procedure when using high-spe ed ring-osc clock as cpu clock or high-speed system clock as peripheral hardware clock (3) example of setting procedure when stopping the high-speed ring-osc clock (1) example of setting procedure when rest arting high-speed ring-osc clock oscillation note 1 <1> setting restart of high-speed ring-osc clock oscillation (rcm register) when rstop is cleared to 0, the high-s peed ring-osc clock starts operating. <2> waiting for the oscillation accuracy stabilizat ion time of high-speed ring-osc (rcm register) wait until rsts is set to 1 note 2 . notes 1. after a reset release, the high-speed ring-osc clo ck automatically starts oscillating and is selected as the cpu clock. 2. this wait time is not necessary if high accura cy is not necessary for the cpu clock and peripheral hardware clock. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 128 (2) example of setting procedure when using hi gh-speed ring-osc clock as cpu clock or high-speed system clock as peripheral hardware clock <1> ? restarting the high-speed ring-osc clock oscillation note (refer to 5.6.2 (1) example of setting procedure wh en restarting high-s peed ring-osc clock oscillation ). ? oscillating the high-speed system clock note (this setting is required when using the high-speed system clock as the peripheral hardware clock. refer to 5.6.1 (1) example of setting proce dure when oscillating the x1 clock and (2) example of setting procedure when using th e external main system clock. ) note the setting of <1> is not necessary when t he high-speed ring-osc clock or high-speed system clock is already operating. <2> selecting the clock s upplied as the main system clock and peri pheral hardware clock (mcm register) set the main system clock and peripheral hardware clock using xsel and mcm0. selection of main system clock and clock supplied to peripheral hardware xsel mcm0 main system clock (f xp ) peripheral hardware clock (f prs ) 0 0 0 1 high-speed ring-osc clock (f rh ) 1 0 high-speed ring-osc clock (f rh ) high-speed system clock (f xh ) <3> selecting the cpu clock division ratio (pcc register) when css is cleared to 0, the main system clock is supplied to the cpu. to select the cpu clock division ratio, use pcc0, pcc1, and pcc2. css pcc2 pcc1 pcc0 cpu clock (f cpu ) selection 0 0 0 f xp 0 0 1 f xp /2 (default) 0 1 0 f xp /2 2 0 1 1 f xp /2 3 1 0 0 f xp /2 4 0 other than above setting prohibited (3) example of setting procedure when stopping the high-speed ring-osc clock the high-speed ring-osc clock can be stopped in the following two ways. ? executing the stop instruction to set the stop mode ? setting rstop to 1 and stopping the high-speed ring-osc oscillation (a) to execute a stop instruction <1> setting of peripheral hardware stop peripheral hardware that c annot be used in the stop mode (f or peripheral hardware that cannot be used in stop mode, refer to chapter 21 standby function ). <2> setting the x1 clock oscillation st abilization time after standby release when the cpu is operating on the x1 clock, set t he value of the osts r egister before the stop instruction is executed. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 129 <3> executing the stop instruction when the stop instruction is executed, the system is placed in the stop mode and high-speed ring-osc oscillation is stopped. (b) to stop high-speed ring-osc oscillation by setting rstop to 1 <1> confirming the cpu clock st atus (pcc and mcm registers) confirm with cls and mcs that the cpu is operati ng on a clock other than the high-speed ring-osc clock. when cls = 0 and mcs = 0, the high-speed ring-osc clock is supplied to the cpu, so change the cpu clock to the high-speed system clock or subsystem clock. cls mcs cpu clock status 0 0 high-speed ring-osc clock 0 1 high-speed system clock 1 subsystem clock <2> stopping the high-speed ring-osc clock (rcm register) when rstop is set to 1, high-spee d ring-osc oscillation is stopped. caution be sure to confirm that mcs = 1 or cls = 1 when setting rstop to 1. in addition, stop peripheral hardware that is operating on the high-speed ring-osc clock. 5.6.3 example of cont rolling subsystem clock the following two types of sub system clocks are available. ? xt1 clock: crystal/ceramic resonator is connected across the xt1 and xt2 pins. ? external subsystem clock: external clock is input to the exclks pin. when the subsystem clock is not us ed, the xt1/p123 and xt2/ exclks/p124 pins can be used as i/o port pins. caution the xt1/p123 and xt2/exclks/p124 pins are in the i/o port mode after a reset release. the following describes examples of setti ng procedures for the following cases. (1) when oscillating xt1 clock (2) when using external subsystem clock (3) when using subsystem clock as cpu clock (4) when stopping subsystem clock (1) example of setting procedur e when oscillating the xt1 clock <1> setting xt1 and xt2 pins and selectin g operation mode (pcc and oscctl registers) when xtstart, exclks, and oscsels are set as any of the following, the mode is switched from port mode to xt1 oscillation mode. xtstart exclks oscsels operation mode of subsystem clock pin p123/xt1 pin p124/xt2/exclk s pin 0 0 1 1 xt1 oscillation mode crystal/ceramic resonator connection remark : don?t care chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 130 <2> waiting for the stabilization of the subsystem clock oscillation wait for the oscillation stabilization time of the subsystem clock by software, using a timer function. caution do not change the value of xtstart, exclks, and oscsel s while the subsystem clock is operating. (2) example of setting procedure when using the external subsystem clock <1> setting xt1 and xt2 pins, selecting xt1 clock/ external clock and controlling oscillation (pcc and oscctl registers) when xtstart is cleared to 0 and exclks and oscsel s are set to 1, the mode is switched from port mode to external clock input mode. in this ca se, input the external clock to the exclks/xt2/p124 pins. xtstart exclks oscsels operation mode of subsystem clock pin p123/xt1 pin p124/xt2/exclks pin 0 1 1 external clock input mode i/o port external clock input caution do not change the value of xtstart, exclks, and oscsel s while the subsystem clock is operating. (3) example of setting procedure when using the subsystem cl ock as the cpu clock <1> setting subsystem clock oscillation note (refer to 5.6.3 (1) example of setting proce dure when oscillating the xt1 clock and (2) example of setting procedure when using the external subsystem clock .) note the setting of <1> is not necessary when while the subsystem clock is operating. <2> switching the cpu clock (pcc register) when css is set to 1, the subsystem clock is supplied to the cpu. css pcc2 pcc1 pcc0 cpu clock (f cpu ) selection 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 f sub /2 1 other than above setting prohibited chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 131 (4) example of setting procedure wh en stopping the subsystem clock <1> confirming the cpu clock st atus (pcc and mcm registers) confirm with cls and mcs that the cpu is operat ing on a clock other than the subsystem clock. when cls = 1, the subsystem clock is supplied to the cpu, so change the cpu clock to the high-speed ring-osc clock or high-speed system clock. cls mcs cpu clock status 0 0 high-speed ring-osc clock 0 1 high-speed system clock 1 subsystem clock <2> stopping the subsystem clock (oscctl register) when oscsels is cleared to 0, xt1 oscillation is stop ped (the input of the external clock is disabled). cautions1. be sure to confirm that cls = 0 when clearing oscsels to 0. in addition, stop the watch timer if it is operating on the subsystem clock. 2. the subsystem clock oscillation cannot be stopped using the stop instruction. 5.6.4 example of control ling low-speed ring-osc clock the low-speed ring-osc clock c annot be used as the cpu clock. only the following peripheral hardware can operate with this clock. ? watchdog timer ? 8-bit timer h1 (if f rl is selected as the count clock) in addition, the following operation modes can be selected by the option byte. ? low-speed ring-osc clock oscillation cannot be stopped ? low-speed ring-osc clock oscillation can be stopped by software the low-speed ring-osc clock automatical ly starts oscillation after a reset release, and the watchdog timer is driven (240 khz (typ.)) if the watchdog timer operation has been enabled by the option byte. (1) example of setting procedure when stopping the low-speed ring-osc clock <1> setting lsrstop to 1 (rcm register) when lsrstop is set to 1, the low-s peed ring-osc oscillation is stopped. (2) example of setting procedure when restarti ng oscillation of the low-speed ring-osc clock <1> clearing lsrstop to 0 (rcm register) when lsrstop is cleared to 0, the low-speed ring-osc clock is oscillated. caution if ?low-speed ring-osc cl ock oscillation cannot be stopped? is selected by the option byte, oscillation of the low-speed ring-osc clock cannot be controlled. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 132 5.6.5 clocks supplied to cp u and peripheral hardware the following table shows the relation among the clocks supplied to the cpu and peripheral hardware, and setting of registers. table 5-4. clocks supplied to cpu and peripheral hardware, and register setting supplied clock clock supplied to cpu clock supplied to peripheral hardware xsel css mcm0 exclk high-speed ring-osc clock 0 0 x1 clock 1 0 0 0 high-speed ring-osc clock external main system clock 1 0 0 1 x1 clock 1 0 1 0 external main system clock 1 0 1 1 high-speed ring-osc clock 0 1 1 1 0 0 x1 clock 1 1 1 0 1 1 0 1 subsystem clock external main system clock 1 1 1 1 remarks 1. xsel: bit 2 of the main clock mode register (mcm) 2. css: bit 4 of the processor clock control register (pcc) 3. mcm0: bit 0 of mcm 4. exclk: bit 7 of the clock operat ion mode select register (oscctl) 5. : don?t care chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 133 5.6.6 cpu clock stat us transition diagram figure 5-13 shows the cpu clock status transition diagram of this product. figure 5-13. cpu clock st atus transition diagram power on reset release v dd 1.59 v (min.) v dd 1.8 v (min.) v dd < 1.59 v (min.) low-speed ring-osc: woken up high-speed ring-osc: woken up x1 oscillation/exclk input: stops (i/o port mode) xt1 oscillation/exclks input: stops (i/o port mode) low-speed ring-osc: operating high-speed ring-osc: operating x1 oscillation/exclk input: stops (i/o port mode) xt1 oscillation/exclks input: stops (i/o port mode) cpu: operating with high-speed ring-osc low-speed ring-osc: operable high-speed ring-osc: operating x1 oscillation/exclk input: selectable by cpu xt1 oscillation/exclks input: selectable by cpu cpu: high- speed ring-osc stop low-speed ring-osc: operable high-speed ring-osc: stops x1 oscillation/exclk input: stops xt1 oscillation/exclks input: stops cpu: high- speed ring-osc halt low-speed ring-osc: operable high-speed ring-osc: operating x1 oscillation/exclk input: operable xt1 oscillation/exclks input: operable cpu: operating with x1 oscillation or exclk input cpu: x1 oscillation/exclk input stop cpu: x1 oscillation/exclk input halt low-speed ring-osc: operable high-speed ring-osc: selectable by cpu x1 oscillation/exclk input: operating xt1 oscillation/exclks input: selectable by cpu low-speed ring-osc: operable high-speed ring-osc: stops x1 oscillation/exclk input: stops xt1 oscillation: stops low-speed ring-osc: operable high-speed ring-osc: operable x1 oscillation/exclk input: operating xt1 oscillation/exclks input: operable cpu: operating with xt1 oscillation or exclks input cpu: xt1 oscillation/exclks input halt low-speed ring-osc: operable high-speed ring-osc: selectable by cpu x1 oscillation/exclk input: selectable by cpu xt1 oscillation/exclks input: operating low-speed ring-osc: operable high-speed ring-osc: operable x1 oscillation/exclk input: operable xt1 oscillation/exclks input: operating (b) (a) (c) (d) (e) (f) (g) (h) (i) chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 134 table 5-5 shows transition of the cpu clock and examples of setting the sfr registers. table 5-5. cpu clock transition a nd sfr register setting examples (1/4) (1) cpu operating with high-speed ring- osc clock (b) after reset release (a) status transition sfr register setting (a) (b) sfr registers do not have to be se t (default status after reset release). (2) cpu operating with high-speed system clock (c) after reset release (a) (the cpu operates with the high- speed ring-osc clock immediately after a reset release (b).) (setting sequence of sfr registers) setting flag of sfr register status transition amph exclk oscsel mstop ostc register xsel mcm0 (a) (b) (c) (x1 clock: less than 10 mhz) 0 0 1 0 must be checked 1 1 (a) (b) (c) (external main clock: less than 10 mhz) 0 1 1 0 must not be checked 1 1 (a) (b) (c) (x1 clock: 10 mhz or more) 1 0 1 0 must be checked 1 1 (a) (b) (c) (external main clock: 10 mhz or more) 1 1 1 0 must not be checked 1 1 caution set the clock after the supply volt age has reached the opera ble voltage of the clo ck to be set (refer to chapter 29 electrical specifications (target)). (3) cpu operating with subsystem clock (d) after reset release (a) (the cpu operates with the high- speed ring-osc clock immediately after a reset release (b).) (setting sequence of sfr registers) setting flag of sfr register status transition xtstart exclks oscsels waiting for oscillation stabilization css 0 0 1 (a) (b) (d) (xt1 clock) 1 necessary 1 (a) (b) (d) (external subsystem clock) 0 1 1 unnecessary 1 remarks 1. (a) to (i) in table 5-5 correspond to (a) to (i) in figure 5-13. 2. exclk, oscsel, exclks, oscsels, amph: bits 7 to 4 and 0 of the clock oper ation mode select register (oscctl) mstop: bit 7 of the main osc control register (moc) xsel, mcm0: bits 2 and 0 of the main clock mode register (mcm) xtstart, css: bits 6 and 4 of the processor clock control register (pcc) : don?t care chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 135 table 5-5. cpu clock transition a nd sfr register setting examples (2/4) (4) cpu clock changing from high-speed ring -osc clock (b) to high-speed system clock (c) (setting sequence of sfr registers) setting flag of sfr register status transition amph note exclk oscsel mstop ostc register xsel note mcm0 (b) (c) (x1 clock: less than 10 mhz) 0 0 1 0 must be checked 1 1 (b) (c) (external main clock: less than 10 mhz) 0 1 1 0 must not be checked 1 1 (b) (c) (x1 clock: 10 mhz or more) 1 0 1 0 must be checked 1 1 (b) (c) (external main clock: 10 mhz or more) 1 1 1 0 must not be checked 1 1 unnecessary if these registers are already set unnecessary if the cpu is operating with the high-speed system clock note the value of this flag can be changed only once after a re set release. this setting is not necessary if it has already been set. caution set the clock after the supply volt age has reached the opera ble voltage of the clo ck to be set (refer to chapter 29 electrical specifications (target)). (5) cpu clock changing from high-speed ri ng-osc clock (b) to subsystem clock (d) (setting sequence of sfr registers) setting flag of sfr register status transition xtstart exclks oscsels waiting for oscillation stabilization css 0 0 1 (b) (d) (xt1 clock) 1 necessary 1 (b) (d) (external subsystem cl ock) 0 1 1 unnecessary 1 unnecessary if the cpu is operating with the subsystem clock remarks 1. (a) to (i) in table 5-4 correspond to (a) to (i) in figure 5-13. 2. exclk, oscsel, exclks, oscsels, amph: bits 7 to 4 and 0 of the clock oper ation mode select register (oscctl) mstop: bit 7 of the main osc control register (moc) xsel, mcm0: bits 2 and 0 of the main clock mode register (mcm) xtstart, css: bits 6 and 4 of the processor clock control register (pcc) : don?t care chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 136 table 5-5. cpu clock transition a nd sfr register setting examples (3/4) (6) cpu clock changing from high-speed system clock (c) to high-speed ring-osc clock (b) (setting sequence of sfr registers) setting flag of sfr register status transition rstop rsts mcm0 (c) (b) 0 confirm this flag is 1. 0 unnecessary if the cpu is operating with the high-spe ed ring-osc clock (7) cpu clock changing from high-speed system clock (c) to subsystem clock (d) (setting sequence of sfr registers) setting flag of sfr register status transition xtstart exclks oscsels waiting for oscillation stabilization css 0 0 1 (c) (d) (xt1 clock) 1 necessary 1 (c) (d) (external subsystem clock) 0 1 1 unnecessary 1 unnecessary if the cpu is operating with the subsystem clock (8) cpu clock changing from subsystem cl ock (d) to high-speed ring-osc clock (b) (setting sequence of sfr registers) setting flag of sfr register status transition rstop rsts mcm0 css (d) (b) 0 confirm this flag is 1. 0 0 unnecessary if the cpu is operating with the high-spe ed ring-osc clock unnecessary if xsel is 0 remarks 1. (a) to (i) in table 5-5 correspond to (a) to (i) in figure 5-13. 2. mcm0: bit 0 of the main clock mode register (mcm) exclks, oscsels: bits 5 and 4 of the cl ock operation mode select register (oscctl) rsts, rstop: bits 7 and 0 of the ring-osc mode register (rcm) xtstart, css: bits 6 and 4 of the processor clock control register (pcc) : don?t care chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 137 table 5-5. cpu clock transition a nd sfr register setting examples (4/4) (9) cpu clock changing from subsystem clock (d) to high-sp eed system clock (c) (setting sequence of sfr registers) setting flag of sfr register status transition amph note exclk oscsel mstop ostc register xsel note mcm0 css (d) (c) (x1 clock: less than 10 mhz) 0 0 1 0 must be checked 1 1 0 (d) (c) (external main clock: less than 10 mhz) 0 1 1 0 must not be checked 1 1 0 (d) (c) (x1 clock: 10 mhz or more) 1 0 1 0 must be checked 1 1 0 (d) (c) (external main clock: 10 mhz or more) 1 1 1 0 must not be checked 1 1 0 unnecessary if these registers are already set unnecessary if the cpu is operating with the high-speed system clock unnecessary if this register is already set note the value of this flag can be changed only once after a re set release. this setting is not necessary if it has already been set. caution set the clock after the supply volt age has reached the opera ble voltage of the clo ck to be set (refer to chapter 29 electrical specifications (target)). (10) ? halt mode (e) set while cpu is opera ting with high-speed ring-osc clock (b) ? halt mode (f) set while cpu is ope rating with high-speed system clock (c) ? halt mode (g) set while cpu is operating with subsystem clock (d) status transition setting (b) (e) (c) (f) (d) (g) executing halt instruction (11) ? stop mode (h) set while cpu is ope rating with high-speed ring-osc clock (b) ? stop mode (i) set while cpu is ope rating with high-speed system clock (c) (setting sequence) status transition setting (b) (h) (c) (i) stopping peripheral functions that cannot operate in stop mode executing stop instruction remarks 1. (a) to (i) in table 5-5 correspond to (a) to (i) in figure 5-13. 2. exclk, oscsel, amph: bits 7, 6 and 0 of the clock operation mode sele ct register (oscctl) mstop: bit 7 of the main osc control register (moc) xsel, mcm0: bits 2 and 0 of the main clock mode register (mcm) css: bit 4 of the processor clock control register (pcc) chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 138 5.6.7 condition before changing cpu clo ck and processing after changing cpu clock condition before changing the cpu clock and processing after changing the cpu clock are shown below. table 5-6. changing cpu clock cpu clock before change after change condition before change processing after change x1 clock stabilization of x1 oscillation ? mstop = 0, oscsel = 1, exclk = 0 ? after elapse of oscillation stabilization time high-speed ring-osc clock external main system clock enabling input of exter nal clock from exclk pin ? mstop = 0, oscsel = 1, exclk = 1 high-speed ring-osc oscillation can be stopped (rstop = 1). clock supply to cpu is stopped for 5 s (min.) after amph has been set to 1. x1 clock x1 oscillation can be stopped (mstop = 1). external main system clock high-speed ring- osc clock oscillation of high-speed ring-osc ? rstop = 0 external main system clock input can be disabled (mstop = 1). high-speed ring-osc clock operating current can be reduced by stopping high-speed ring-osc oscillation (rstop = 1). x1 clock x1 oscillation can be stopped (mstop = 1). external main system clock xt1 clock stabilization of xt1 oscillation ? xtstart = 0, exclks = 0, oscsels = 1, or xtstart = 1 ? after elapse of oscillation stabilization time external main system clock input can be disabled (mstop = 1). high-speed ring-osc clock operating current can be reduced by stopping high-speed ring-osc oscillation (rstop = 1). x1 clock x1 oscillation can be stopped (mstop = 1). external main system clock external subsystem clock enabling input of ex ternal clock from exclks pin ? xtstart = 0, exclks = 1, oscsels = 1 external main system clock input can be disabled (mstop = 1). high-speed ring- osc clock oscillation of high-speed ring-osc and selection of high-s peed ring-osc clock as main system clock ? rstop = 0, mcs = 0 xt1 oscillation can be stopped or external subsystem clock input can be disabled (oscsels = 0). x1 clock stabilization of x1 oscillation and selection of high-speed system cl ock as main system clock ? mstop = 0, oscsel = 1, exclk = 0 ? after elapse of oscillation stabilization time ? mcs = 1 ? supply voltage has reached the operable voltage of the clock to be set xt1 clock, external subsystem clock external main system clock enabling input of exter nal clock from exclk pin and selection of high-speed system clock as main system clock ? mstop = 0, oscsel = 1, exclk = 1 ? mcs = 1 ? xt1 oscillation can be stopped or external subsystem clock input can be disabled (oscsels = 0). ? clock supply to cpu is stopped for 5 s (min.) after amph has been set to 1. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 139 5.6.8 time required for switchover of cpu clock and main system clock by setting bits 0 to 2 (pcc0 to pcc2) and bit 4 (css) of the processor clock control register (pcc), the cpu clock can be switched (between the main system clock and the s ubsystem clock) and the division ratio of the main system clock can be changed. the actual switchover operat ion is not performed immediately after rewr iting to pcc; operat ion continues on the pre-switchover clock for several clocks (see table 5-7 ). whether the cpu is oper ating on the main system clock or the sub system clock can be ascertained using bit 5 (cls) of the pcc register. table 5-7. time required for s witchover of cpu clock and main system clock cycle division factor set value before switchover set value after switchover css pcc2 pcc1 pcc0 css pcc2 pcc1 pcc0 css pcc2 pcc1 pcc0 css pcc2 pcc1 pcc0 css pcc2 pcc1 pcc0 css pcc2 pcc1 pcc0 css pcc2 pcc1 pcc0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 0 0 16 clocks 16 clocks 16 clocks 16 clocks 2f xp /f sub clocks 0 0 1 8 clocks 8 clocks 8 clocks 8 clocks f xp /f sub clocks 0 1 0 4 clocks 4 clocks 4 clocks 4 clocks f xp /2f sub clocks 0 1 1 2 clocks 2 clocks 2 clocks 2 clocks f xp /4f sub clocks 0 1 0 0 1 clock 1 clock 1 clock 1 clock f xp /8f sub clocks 1 2 clocks 2 clocks 2 clo cks 2 clocks 2 clocks caution selection of the main system clock cycle division factor (pcc0 to pcc2) and switchover from the main system clock to th e subsystem clock (chang ing css from 0 to 1) should not be set simultaneously. simultaneous setting is possible, however, for sel ection of the main system clock cycle division factor (pcc0 to pcc2) and switchover from the subsystem clock to the main system clock (changing css from 1 to 0). remarks1. the number of clocks listed in table 5-7 is the number of cpu clocks before switchover. 2. when switching the cpu clock from the subsystem clock to the main s ystem clock, calculate the number of clocks by rounding up to the next clock and di scarding the decimal portion, as shown below. example when switching cpu clock from f sub /2 to f xp /2 (@ oscillation with f sub = 32.768 khz, f xp = 10 mhz) f xp /f sub = 10000/32.768 ? 305.1 306 clocks by setting bit 0 (mcm0) of the main clock mode register (mcm), the main system clo ck can be switch ed (between the high-speed ring-osc clock and the high-speed system clock). the actual switchover oper ation is not performed immediately after re writing to mcm0; operation continues on the pre-switchover clock for several clocks (see table 5-8 ). whether the cpu is operating on the high-speed ring-osc clock or the high-speed system clock can be ascertained using bit 1 (mcs) of mcm. chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 140 table 5-8. maximum time required for main system clock switchover set value before switchover set value after switchover mcm0 mcm0 0 1 0 1 + 2f rh /f xh clock 1 1 + 2f xh /f rh clock caution when switching the high-speed ring-osc clo ck to the high-speed system clock, bit 2 (xsel) of mcm must be set to 1 in advance. the value of xsel can be changed only on ce after a reset release. remarks1. the number of clocks listed in table 5-8 is t he number of main system clocks before switchover. 2. calculate the number of clocks in tabl e 5-8 by removing the decimal portion. example when switching the main system clock from the high-speed ring-osc clock to the high-speed system clock (@ oscillation with f rh = 8 mhz, f xh = 10 mhz) 1 + 2f rh /f xh = 1 + 2 8/10 = 1 + 2 0.8 = 1 + 1.6 = 2.6 2 clocks 5.6.9 conditions before cl ock oscillation is stopped the following lists the register flag settings for stopping th e clock oscillation (disabling external clock input) and conditions before the clock oscillation is stopped. table 5-9. conditions before the clo ck oscillation is stopped and flag settings clock conditions before clock oscillation is stopped (external clock input disabled) flag settings of sfr register high-speed ring-osc clock mcs = 1 or cls = 1 (the cpu is operating on a clock other than the high-speed ring-osc clock) rstop = 1 x1 clock external main system clock mcs = 1 or cls = 1 (the cpu is operating on a clock other than the high-speed system clock) mstop = 1 xt1 clock external subsystem clock cls = 0 (the cpu is operating on a clock other than the subsystem clock) oscsels = 0 chapter 5 clock generator preliminary user?s manual u17473ej1v0ud 141 5.6.10 peripheral hardware and source clocks the following lists peripheral hardware and source clocks incorpor ated in the 78k0/lg2. table 5-10. peripheral ha rdware and source clocks source clock peripheral hardware peripheral hardware clock (f prs ) subsystem clock (f sub ) low-speed ring- osc clock (f rl ) tm50 output external clock from peripheral hardware pins 00 y n n n y (ti000 pin) note 16-bit timer/ event counter 01 y n n n y (ti001 pin) note 00 y n n n y (ti50 pin) note 8-bit timer/ event counter 01 y n n n y (ti51 pin) note 00 y n n y n 8-bit timer 01 y n y n n watch timer y y n n n watchdog timer n n y n n clock output y y n n n a/d converter y n n n n uart0 y n n y n uart6 y n n y n csi10 y n n n y (sck10 pin) note csi11 y n n n y (sck11 pin) note serial interface iic0 y n n n y (scl0 pin) note lcd controller/driver y y n n n note when the cpu is operating on the subsystem clock and the high-speed ring-osc clock has been stopped, do not operate these functions on the external clock input from peripheral hardware pins. remark y : can be selected, n : cannot be selected preliminary user?s manual u17473ej1v0ud 142 chapter 6 16-bit timer/even t counters 00 and 01 the pd78f0393 incorporates 16-bit ti mer/event counter 00, and the pd78f0395, 78f0397, and 78f0397d incorporate 16-bit timer/ event counters 00 and 01. 6.1 functions of 16-bit timer/event counters 00 and 01 16-bit timer/event counters 00 and 01 note have the following functions. ? interval timer ? ppg output ? pulse width measurement ? external event counter ? square-wave output ? one-shot pulse output (1) interval timer 16-bit timer/event counters 00 and 01 generate an in terrupt request at the preset time interval. (2) ppg output 16-bit timer/event counters 00 and 01 can output a recta ngular wave whose frequency and output pulse width can be set freely. (3) pulse width measurement 16-bit timer/event counters 00 and 01 can measure th e pulse width of an externally input signal. (4) external event counter 16-bit timer/event counters 00 and 01 can measure the number of pulses of an externally input signal. (5) square-wave output 16-bit timer/event counters 00 and 01 can output a square wave with any selected frequency. (6) one-shot pulse output 16-bit timer event counters 00 and 01 can output a one-sh ot pulse whose output pulse width can be set freely. note available only in the pd78f0395, 78f0397, and 78f0397d. chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 143 6.2 configuration of 16-bit timer/event counters 00 and 01 16-bit timer/event counters 00 and 01 include the following hardware. table 6-1. configuration of 16- bit timer/event counters 00 and 01 item configuration timer counter 16-bit timer counter 0n (tm0n) register 16-bit timer capture/compare registers 00n, 01n (cr00n, cr01n) timer input ti00n, ti01n timer output to0n, output controller control registers 16-bit timer mode control register 0n (tmc0n) 16-bit timer capture/compare control register 0n (crc0n) 16-bit timer output control register 0n (toc0n) prescaler mode register 0n (prm0n) port mode register 0 (pm0) port register 0 (p0) remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d figures 6-1 and 6-2 show the block diagrams. figure 6-1. block diagram of 16-bit timer/event counter 00 internal bus capture/compare control register 00 (crc00) ti010/to00/p01 f prs f prs /2 2 f prs /2 8 f prs ti000/p00 prescaler mode register 00 (prm00) 2 prm001 prm000 crc002 16-bit timer capture/compare register 010 (cr010) match match 16-bit timer counter 00 (tm00) clear noise elimi- nator crc002 crc001 crc000 inttm000 to00/ti010/ p01 inttm010 16-bit timer output control register 00 (toc00) 16-bit timer mode control register 00 (tmc00) internal bus tmc003 tmc002 tmc001 ovf00 toc004 lvs00 lvr00 toc001 toe00 selector 16-bit timer capture/compare register 000 (cr000) selector selector selector noise elimi- nator noise elimi- nator output controller ospe00 ospt00 output latch (p01) pm01 to cr010 chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 144 figure 6-2. block diagram of 16-bit timer/event counter 01 ( pd78f0395, 78f0397, 78f0397d only) internal bus capture/compare control register 01 (crc01) ti011/to01/p06 f prs f prs /2 4 f prs /2 6 f prs ti001/p05/ ssi11 prescaler mode register 01 (prm01) 2 prm011 prm010 crc012 16-bit timer capture/compare register 011 (cr011) match match 16-bit timer counter 01 (tm01) clear noise elimi- nator crc012 crc011 crc010 inttm001 to01/ti011/ p06 inttm011 16-bit timer output control register 01 (toc01) 16-bit timer mode control register 01 (tmc01) internal bus tmc013 tmc012 tmc011 ovf01 toc014 lvs01 lvr01 toc011 toe01 selector 16-bit timer capture/compare register 001 (cr001) selector selector selector noise elimi- nator noise elimi- nator output controller ospe01 ospt01 output latch (p06) pm06 to cr011 chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 145 (1) 16-bit timer counter 0n (tm0n) tm0n is a 16-bit read-only regist er that counts count pulses. the counter is incremented in synchronization with the rising edge of the input clock. figure 6-3. format of 16-bit timer counter 0n (tm0n) tm0n (n = 0, 1) symbol ff11h (tm00) ffb1h (tm01) ff10h (tm00) ffb0h (tm01) address: ff10h, ff11h (tm00), ffb0h, ffb1h (tm01) after reset: 0000h r the count value is reset to 0000h in the following cases. <1> at reset input <2> if tmc0n3 and tmc0n2 are cleared <3> if the valid edge of the ti00n pin is input in the mode in which clear & start occurs when inputting the valid edge of the ti00n pin <4> if tm0n and cr00n match in the mode in which cl ear & start occurs on a match of tm0n and cr00n <5> ospt0n is set in one-shot pulse output mode (2) 16-bit timer capture/comp are register 00n (cr00n) cr00n is a 16-bit register that has t he functions of both a captur e register and a compare r egister. whether it is used as a capture register or as a comp are register is set by bit 0 (crc0n0) of capture/compar e control register 0n (crc0n). cr00n can be set by a 16-bit memory manipulation instruction. reset input clears this register to 0000h. figure 6-4. format of 16-bit timer ca pture/compare register 00n (cr00n) cr00n (n = 0, 1) symbol ff13h (cr000) ffb3h (cr001) ff12h (cr000) ffb2h (cr001) address: ff12h, ff13h (cr000), ffb2h, ffb3h (cr001) after reset: 0000h r/w ? when cr00n is used as a compare register the value set in cr00n is constant ly compared with 16-bit timer count er 0n (tm0n) count value, and an interrupt request (inttm00n) is gener ated if they match. the set valu e is held until cr00n is rewritten. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 146 ? when cr00n is used as a capture register it is possible to select the valid edge of the ti00n pi n or the ti01n pin as the c apture trigger. the ti00n or ti01n pin valid edge is set using prescaler mode register 0n (prm0n) (see table 6-2 ). table 6-2. cr00n capture trigger and valid edges of ti00n and ti01n pins (1) ti00n pin valid edge selected as captu re trigger (crc0n1 = 1, crc0n0 = 1) ti00n pin valid edge cr00n capture trigger es0n1 es0n0 falling edge rising edge 0 1 rising edge falling edge 0 0 no capture operation both rising and falling edges 1 1 (2) ti01n pin valid edge selected as captu re trigger (crc0n1 = 0, crc0n0 = 1) ti01n pin valid edge cr00n capture trigger es1n1 es1n0 falling edge falling edge 0 0 rising edge rising edge 0 1 both rising and falling edges both rising and falling edges 1 1 remarks 1. setting es0n1, es0n0 = 1, 0 and es1n1, es1n0 = 1, 0 is prohibited. 2. es0n1, es0n0: bits 5 and 4 of prescaler mode register 0n (prm0n) es1n1, es1n0: bits 7 and 6 of prescaler mode register 0n (prm0n) crc0n1, crc0n0: bits 1 and 0 of capture/ compare control register 0n (crc0n) 3. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d cautions 1. set a value other than 0000h in cr00n in the mode in which clear & start occurs on a match of tm0n and cr00n. 2. if cr00n is cleared to 0000h in the free-running mode and in the clear mode using the valid edge of the ti00n pin, an interrupt request (inttm00n) is generated when the value of cr00n changes from 0000h to 0001h following tm0n overflow (ffffh). in addition, inttm00n is generated after a match between tm0n and cr00n , after detecting the valid edge of the ti01n pin, and the time r is cleared by a one-shot trigger. 3. when p01 or p06 is used as the valid edge input of the ti01n pin, it cannot be used as the timer output (to0n). moreover, when p01 or p 06 is used as to0n, it cannot be used as the valid edge input of the ti01n pin. 4. when cr00n is used as a capture register, read data is undefined if the register read time and capture trigger input conflict (the captu re data itself is the correct value). if count stop input and capture trigger in put conflict, the capture d data is undefined. 5. do not rewrite cr00n during tm0n operation. chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 147 (3) 16-bit timer capture/comp are register 01n (cr01n) cr01n is a 16-bit register that has t he functions of both a captur e register and a compare r egister. whether it is used as a capture register or a compar e register is set by bit 2 (crc0n2) of capture/compare c ontrol register 0n (crc0n). cr01n can be set by a 16-bit memory manipulation instruction. reset input clears this register to 0000h. figure 6-5. format of 16-bit timer ca pture/compare register 01n (cr01n) cr01n (n = 0, 1) symbol ff15h (cr010) ffb5h (cr011) ff14h (cr010) ffb4h (cr011) address: ff14h, ff15h (cr010), ffb4h, ffb5h (cr011) after reset: 0000h r/w ? when cr01n is used as a compare register the value set in the cr01n is cons tantly compared with 16-bit timer c ounter 0n (tm0n) count value, and an interrupt request (inttm01n) is gener ated if they match. the set valu e is held until cr01n is rewritten. ? when cr01n is used as a capture register it is possible to select the valid edge of the ti00n pin as the capture trigger. the ti00n pin valid edge is set by prescaler mode register 0n (prm0n) (see table 6-3 ). table 6-3. cr01n capture trigger and valid edge of ti00n pin (crc0n2 = 1) ti00n pin valid edge cr01n capture trigger es0n1 es0n0 falling edge falling edge 0 0 rising edge rising edge 0 1 both rising and falling edges both rising and falling edges 1 1 remarks 1. setting es0n1, es0n0 = 1, 0 is prohibited. 2. es0n1, es0n0: bits 5 and 4 of prescaler mode register 0n (prm0n) crc0n2: bit 2 of capture/compar e control register 0n (crc0n) 3. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d cautions 1. if the cr01n register is cleared to 0000h, an interrupt re quest (inttm01n) is generated when the value of cr01n changes from 0000h to 0001h following tm0n over flow (ffffh). in addition, inttm01n is generate d after a match between tm0n and cr01n, after detecting the valid edge of the ti00n pin, and the ti mer is cleared by a one-shot trigger. 2. when cr01n is used as a capture register, read data is undefined if the register read time and capture trigger input conflict (the captu re data itself is the correct value). if count stop input and capture trigger in put conflict, the capture d data is undefined. 3. cr01n can be rewritten dur ing tm0n operation. for details, see caution 2 in figure 6-20. chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 148 6.3 registers controlling 16-bi t timer/event counters 00 and 01 the following six registers are used to cont rol 16-bit timer/event counters 00 and 01. ? 16-bit timer mode control register 0n (tmc0n) ? capture/compare contro l register 0n (crc0n) ? 16-bit timer output control register 0n (toc0n) ? prescaler mode register 0n (prm0n) ? port mode register 0 (pm0) ? port register 0 (p0) (1) 16-bit timer mode cont rol register 0n (tmc0n) this register sets the 16-bit timer operating mode, t he 16-bit timer counter 0n (tm0n) clear mode, and output timing, and detects an overflow. tmc0n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears tmc0n to 00h. caution 16-bit timer counter 0n (tm0n) starts opera tion at the moment tmc0n2 and tmc0n3 are set to values other than 0, 0 (operation stop mode), respectively. set tmc0n2 and tmc0n3 to 0, 0 to stop the operation. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 149 figure 6-6. format of 16-bit timer mode control register 00 (tmc00) 7 0 6 0 5 0 4 0 3 tmc003 2 tmc002 1 tmc001 <0> ovf00 symbol tmc00 address ffbah after reset: 00h r/w tmc003 tmc002 tmc001 operating mode and clear mode selection to00 inversion timing selection interrupt request generation 0 0 0 0 0 1 operation stop (tm00 cleared to 0) no change not generated 0 1 0 free-running mode match between tm00 and cr000 or match between tm00 and cr010 0 1 1 match between tm00 and cr000, match between tm00 and cr010 or ti000 pin valid edge 1 0 0 1 0 1 clear & start occurs on ti000 pin valid edge ? 1 1 0 clear & start occurs on match between tm00 and cr000 match between tm00 and cr000 or match between tm00 and cr010 1 1 1 match between tm00 and cr000, match between tm00 and cr010 or ti000 pin valid edge chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 150 figure 6-7. format of 16-bit timer mode control register 01 (tmc01) 7 0 6 0 5 0 4 0 3 tmc013 2 tmc012 1 tmc011 <0> ovf01 symbol tmc01 address ffb6h after reset: 00h r/w tmc013 tmc012 tmc011 operating mode and clear mode selection to01 inversion timing selection interrupt request generation 0 0 0 0 0 1 operation stop (tm01 cleared to 0) no change not generated 0 1 0 free-running mode match between tm01 and cr001 or match between tm01 and cr011 0 1 1 match between tm01 and cr001, match between tm01 and cr011 or ti001 pin valid edge 1 0 0 1 0 1 clear & start occurs on ti001 pin valid edge ? 1 1 0 clear & start occurs on match between tm01 and cr001 match between tm01 and cr001 or match between tm01 and cr011 1 1 1 match between tm01 and cr001, match between tm01 and cr011 or ti001 pin valid edge chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 151 (2) capture/compare control register 0n (crc0n) this register controls the oper ation of the 16-bit timer capture/ compare registers (cr00n, cr01n). crc0n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears crc0n to 00h. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d figure 6-8. format of capture/comp are control register 00 (crc00) address: ffbch after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 crc00 0 0 0 0 0 crc002 crc001 crc000 crc002 cr010 operating mode selection 0 operates as compare register 1 operates as capture register crc001 cr000 capture trigger selection 0 captures on valid edge of ti010 pin 1 captures on valid edge of ti000 pin by reverse phase note crc000 cr000 operating mode selection 0 operates as compare register 1 operates as capture register note the capture operation is not perform ed if both the rising and falling edges are specified as the valid edge of the ti000 pin. cautions 1. timer operation must be stopped before setting crc00. 2. when the mode in which clear & start occurs on a match betw een tm00 and cr000 is selected with 16-bit timer mode control register 00 (tmc00), cr0 00 should not be specified as a capture register. 3. to ensure that the capture operation is pe rformed properly, the cap ture trigger requires a pulse two cycles longer than the count clock selected by prescaler mode register 00 (prm00). chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 152 figure 6-9. format of capture/comp are control register 01 (crc01) address: ffb8h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 crc01 0 0 0 0 0 crc012 crc011 crc010 crc012 cr011 operating mode selection 0 operates as compare register 1 operates as capture register crc011 cr001 capture trigger selection 0 captures on valid edge of ti011 pin 1 captures on valid edge of ti001 pin by reverse phase note crc010 cr001 operating mode selection 0 operates as compare register 1 operates as capture register note the capture operation is not perform ed if both the rising and falling edges are specified as the valid edge of the ti001 pin. cautions 1. timer operation must be stopped before setting crc01. 2. when the mode in which clear & start occurs on a match betw een tm01 and cr001 is selected with 16-bit timer mode control register 01 (tmc01), cr0 01 should not be specified as a capture register. 3. to ensure that the capture operation is pe rformed properly, the cap ture trigger requires a pulse two cycles longer than the count clock selected by prescaler mode register 01 (prm01). (3) 16-bit timer output control register 0n (toc0n) this register controls the operation of the 16-bit timer/ event counter 0n output controller. it sets/resets the timer output f/f (lv0n), enables/disables output invers ion and 16-bit timer/event counter 0n timer output, enables/disables the one-shot pulse output operation, and sets the one-shot pulse output trigger via software. toc0n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears toc0n to 00h. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 153 figure 6-10. format of 16-bit timer ou tput control register 00 (toc00) address: ffbdh after reset: 00h r/w symbol 7 <6> <5> 4 <3> <2> 1 <0> toc00 0 ospt00 ospe00 toc004 lvs00 lvr00 toc001 toe00 ospt00 one-shot pulse output trigger control via software 0 no one-shot pulse output trigger 1 one-shot pulse output trigger ospe00 one-shot pulse output operation control 0 successive pulse output mode 1 one-shot pulse output mode note toc004 timer output f/f control using match of cr010 and tm00 0 disables inversion operation 1 enables inversion operation lvs00 lvr00 timer output f/f status setting 0 0 no change 0 1 timer output f/f reset (0) 1 0 timer output f/f set (1) 1 1 setting prohibited toc001 timer output f/f control using match of cr000 and tm00 0 disables inversion operation 1 enables inversion operation toe00 timer output control 0 disables output (output fixed to level 0) 1 enables output note the one-shot pulse output mode op erates correctly only in the free -running mode and the mode in which clear & start occurs at the ti000 pin valid edge. in the mode in which clear & start occurs on a match between the tm00 register and cr000 re gister, one-shot pulse output is not possible because an overflow does not occur. cautions 1. timer operation must be st opped before setting other than toc004. 2. if lvs00 and lvr00 are read, 0 is read. 3. ospt00 is automatically cleared after data is set, so 0 is read. 4. do not set ospt00 to 1 other than in one-shot pulse output mode. 5. a write interval of two cycles or more of th e count clock selected by prescaler mode register 00 (prm00) is required to write to ospt00 successively. 6. do not set lvs00 to 1 before toe00, and do not set lvs00 and toe00 to 1 simultaneously. 7. perform <1> and <2> below in the following order, not at the same time. <1> set toc001, toc004, toe00, ospe00: timer output operation setting <2> set lvs00, lvr00: timer output f/f setting chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 154 figure 6-11. format of 16-bit timer ou tput control register 01 (toc01) address: ffb9h after reset: 00h r/w symbol 7 <6> <5> 4 <3> <2> 1 <0> toc01 0 ospt01 ospe01 toc014 lvs01 lvr01 toc011 toe01 ospt01 one-shot pulse output trigger control via software 0 no one-shot pulse output trigger 1 one-shot pulse output trigger ospe01 one-shot pulse output operation control 0 successive pulse output mode 1 one-shot pulse output mode note toc014 timer output f/f control using match of cr011 and tm01 0 disables inversion operation 1 enables inversion operation lvs01 lvr01 timer output f/f status setting 0 0 no change 0 1 timer output f/f reset (0) 1 0 timer output f/f set (1) 1 1 setting prohibited toc011 timer output f/f control using match of cr001 and tm01 0 disables inversion operation 1 enables inversion operation toe01 timer output control 0 disables output (output fixed to level 0) 1 enables output note the one-shot pulse output mode op erates correctly only in the free -running mode and the mode in which clear & start occurs at the ti001 pin valid edge. in the mode in which clear & start occurs on a match between the tm01 register and cr001 re gister, one-shot pulse output is not possible because an overflow does not occur. cautions 1. timer operation must be st opped before setting other than toc014. 2. if lvs01 and lvr01 are read, 0 is read. 3. ospt01 is automatically cleared after data is set, so 0 is read. 4. do not set ospt01 to 1 other than in one-shot pulse output mode. 5. a write interval of two cycles or more of th e count clock selected by prescaler mode register 01 (prm01) is required to write to ospt01 successively. 6. do not set lvs01 to 1 before toe01, and do not set lvs01 and toe01 to 1 simultaneously. 7. perform <1> and <2> below in the following order, not at the same time. <1> set toc011, toc014, toe01, ospe01: timer output operation setting <2> set lvs01, lvr01: timer output f/f setting chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 155 (4) prescaler mode register 0n (prm0n) this register is used to set the 16-bit timer counter 0n (tm0n) count clock and ti00n and ti01n pin input valid edges. prm0n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears prm0n to 00h. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d figure 6-12. format of prescaler mode register 00 (prm00) address: ffbbh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 prm00 es101 es100 es001 es000 0 0 prm001 prm000 es101 es100 ti010 pin valid edge selection 0 0 falling edge 0 1 rising edge 1 0 setting prohibited 1 1 both falling and rising edges es001 es000 ti000 pin valid edge selection 0 0 falling edge 0 1 rising edge 1 0 setting prohibited 1 1 both falling and rising edges count clock selection prm001 prm000 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz 0 0 f prs 2 mhz 5 mhz 10 mhz 20 mhz 0 1 f prs /2 2 500 khz 1.25 mhz 2.5 mhz 5 mhz 1 0 f prs /2 8 7.81 khz 19.53 khz 39.06 khz 78.12 khz 1 1 ti000 valid edge note note the external clock requires a pulse two cycles longer than internal clock (f prs ). chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 156 cautions 1. always set data to prm 00 after stopping the timer operation. 2. if the valid edge of the ti000 pin is to be set for the count clock, do not set the clear & start mode using the valid edge of the ti000 pin and the capture trigger. 3. if the ti000 or ti010 pin is high level immediatel y after system reset, the rising edge is immediately detected after the rising edge or both the rising and falling edges are set as the valid edge(s) of the ti000 pin or ti010 pin to en able the operation of 16-bit timer counter 00 (tm00). care is therefore requi red when pulling up the ti000 or ti010 pin. however, when re- enabling operation after the operation has been st opped once, the rising edge is not detected. 4. when ti010 pin valid edge is used, p01 cannot be used as the timer output (to00), and when the to00 pin is used, the ti010 pi n valid edge cannot be used. remark f prs : peripheral hardware clock oscillation frequency chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 157 figure 6-13. format of prescaler mode register 01 (prm01) address: ffb7h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 prm01 es111 es110 es011 es010 0 0 prm011 prm010 es111 es110 ti011 pin valid edge selection 0 0 falling edge 0 1 rising edge 1 0 setting prohibited 1 1 both falling and rising edges es011 es010 ti001 pin valid edge selection 0 0 falling edge 0 1 rising edge 1 0 setting prohibited 1 1 both falling and rising edges count clock selection prm011 prm010 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz 0 0 f prs 2 mhz 5 mhz 10 mhz 20 mhz 0 1 f prs /2 4 125 khz 312.5 khz 625 khz 1.25 mhz 1 0 f prs /2 6 31.25 khz 78.125 khz 156.25 khz 312.5 khz 1 1 ti001 valid edge note note the external clock requires a pulse two cycles longer than internal clock (f prs ). cautions 1. always set data to prm 01 after stopping the timer operation. 2. if the valid edge of the ti001 pin is to be set for the count clock, do not set the clear & start mode using the valid edge of the ti001 pin and the capture trigger. 3. if the ti001 or ti011 pin is high level immediatel y after system reset, the rising edge is immediately detected after the rising edge or both the rising and falling edges are set as the valid edge(s) of the ti001 pin or ti011 pin to en able the operation of 16-bit timer counter 01 (tm01). care is therefore requi red when pulling up the ti001 or ti011 pin. however, when re- enabling operation after the operation has been st opped once, the rising edge is not detected. 4. when ti011 pin valid edge is used, p06 cannot be used as the timer output (to01), and when the to01 pin is used, the ti011 pi n valid edge cannot be used. remark f prs : peripheral hardware clock oscillation frequency chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 158 (5) port mode register 0 (pm0) this register sets port 0 input/output in 1-bit units. when using the p01/to 00/ti010 and p06/to01 note /ti011 note pins for timer output, set pm01 and pm06 and the output latches of p01 and p06 to 0. when using the p00/ti000, p01/to00/ti010, p05/ti001 note /ssi11 note , and p06/to01 note /ti011 note pins for timer input, set pm00, pm01, pm05, and pm06 to 1. at this ti me, the output latches of p00, p01, p05, and p06 may be 0 or 1. pm0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets pm0 to ffh. figure 6-14. format of port mode register 0 (pm0) 7 1 6 pm06 5 pm05 4 pm04 3 pm03 2 pm02 1 pm01 0 pm00 symbol pm0 address: ff20h after reset: ffh r/w pm0n 0 1 p0n pin i/o mode selection (n = 0 to 6) output mode (output buffer on) input mode (output buffer off) note available only in the pd78f0395, 78f0397, and 78f0397d. chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 159 6.4 operation of 16-bit ti mer/event counters 00 and 01 6.4.1 interval timer operation setting 16-bit timer mode control register 0n (tmc0n) and capture/compare control register 0n (crc0n) as shown in figure 6-15 allows operation as an interval timer. setting the basic operation setting procedure is as follows. <1> set the crc0n register (see figure 6-15 for the set value). <2> set any value to the cr00n register. <3> set the count clock by using the prm0n register. <4> set the tmc0n register to start the operation (see figure 6-15 for the set value). caution cr00n cannot be rewr itten during tm0n operation. remark for how to enable the inttm00n interrupt, see chapter 19 interrupt functions . interrupt requests are generated repeatedly using the count value preset in 16-bit timer capture/compare register 00n (cr00n) as the interval. when the count value of 16-bit timer counter 0n (tm0n) matches the value set in cr00n, counting continues with the tm0n value cleared to 0 and the interrupt request signal (inttm00n) is generated. the count clock of 16-bit timer/event counter 0n can be selected with bits 0 and 1 (prm0n0, prm0n1) of prescaler mode register 0n (prm0n). remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 160 figure 6-15. control register setti ngs for interval timer operation (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 1 tmc0n2 1 tmc0n1 0/1 ovf0n 0 tmc0n clears and starts on match between tm0n and cr00n. (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 0/1 crc0n1 0/1 crc0n0 0 crc0n cr00n used as compare register (c) prescaler mode register 0n (prm0n) es1n1 0/1 es1n0 0/1 es0n1 0/1 es0n0 0/1 3 0 2 0 prm0n1 0/1 prm0n0 0/1 prm0n selects count clock. setting invalid (setting ?10? is prohibited.) setting invalid (setting ?10? is prohibited.) remarks 1. 0/1: setting 0 or 1 allows another function to be used simultaneously with the interval timer. see the description of the respective control registers for details. 2. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 161 figure 6-16. interval ti mer configuration diagram 16-bit timer capture/compare register 00n (cr00n) 16-bit timer counter 0n (tm0n) ovf0n clear circuit inttm00n f prs (f prs ) note 1 f prs /2 2 (f prs /2 4 ) note 1 f prs /2 8 (f prs /2 6 ) note 1 ti000/p00 (ti001/ssi11/p05) note 1 selector noise eliminator f prs note 2 notes 1. frequencies and pin names without parentheses are for 16-bit timer/event counter 00, and those in parentheses are for 16-bit timer/event counter 01. 2. ovf0n is set to 1 only when 16-bit timer capt ure/compare register 00n is set to ffffh. figure 6-17. timing of interval timer operation count clock t tm0n count value cr00n inttm00n 0000h 0001h n 0000h 0001h n 0000h 0001h n n n n n timer operation enabled clear clear interrupt acknowledged interrupt acknowledged remark interval time = (n + 1) t n = 0001h to ffffh (settable range) n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 162 6.4.2 ppg output operations setting 16-bit timer mode control register 0n (tmc0n) and capture/compare control register 0n (crc0n) as shown in figure 6-18 allows operation as ppg (programmable pulse generator) output. setting the basic operation setting procedure is as follows. <1> set the crc0n register (see figure 6-18 for the set value). <2> set any value to the cr00n register as the cycle. <3> set any value to the cr01n register as the duty factor. <4> set the toc0n register (see figure 6-18 for the set value). <5> set the count clock by using the prm0n register. <6> set the tmc0n register to start the operation (see figure 6-18 for the set value). caution to change the value of the duty factor (the value of the cr01n register) during operation, see caution 2 in figure 6-20 ppg output operation timing. remarks 1. for the setting of the to0n pin, see 6.3 (5) port mode register 0 (pm0) . 2. for how to enable the inttm00n interrupt, see chapter 19 interrupt functions . in the ppg output oper ation, rectangular wa ves are output from the to0n pin with the pulse wi dth and the cycle that correspond to the count values preset in 16-bit time r capture/compare register 01n (cr01n) and in 16-bit timer capture/compare register 00n (cr00n), respectively. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 163 figure 6-18. control register settings for ppg output operation (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 1 tmc0n2 1 tmc0n1 0 ovf0n 0 tmc0n clears and starts on match between tm0n and cr00n. (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 0 crc0n1 crc0n0 0 crc0n cr00n used as compare register cr01n used as compare register (c) 16-bit timer output control register 0n (toc0n) 7 0 ospt0n 0 ospe0n 0 toc0n4 1 lvs0n 0/1 lvr0n 0/1 toc0n1 1 toe0n 1 toc0n enables to0n output. inverts output on match between tm0n and cr00n. specifies initial value of to0n output f/f (setting ?11? is prohibited). inverts output on match between tm0n and cr01n. disables one-shot pulse output. (d) prescaler mode register 0n (prm0n) es1n1 0/1 es1n0 0/1 es0n1 0/1 es0n0 0/1 3 0 2 0 prm0n1 0/1 prm0n0 0/1 prm0n selects count clock. setting invalid (setting ?10? is prohibited.) setting invalid (setting ?10? is prohibited.) cautions 1. values in the following ra nge should be set in cr00n and cr01n: 0000h < cr01n < cr00n ffffh 2. the cycle of the pulse generated through ppg output (cr00n setting value + 1) has a duty of (cr01n setting value + 1)/(cr00n setting value + 1). remark : don?t care n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 164 figure 6-19. configuration diagram of ppg output 16-bit timer capture/compare register 00n (cr00n) 16-bit timer counter 0n (tm0n) clear circuit noise eliminator f prs f prs (f prs ) note f prs /2 2 (f prs /2 4 ) note f prs /2 8 (f prs /2 6 ) note ti000/p00 (ti001/ssi11/p05) note 16-bit timer capture/compare register 01n (cr01n) to00/ti010/p01 ( to01/ti011/p06 ) selector output controller note frequencies and pin names without parentheses are for 16-bit timer/event counter 00, and those in parentheses are for 16-bit timer/event counter 01. figure 6-20. ppg output operation timing t 0000h 0000h 0001h 0001h m ? 1 count clock tm0n count value to0n pulse width: (m + 1) t 1 cycle: (n + 1) t n cr00n capture value cr01n capture value m m n ? 1 n n clear clear cautions 1. cr00n cannot be re written during tm0n operation. 2. in the ppg output operatio n, change the pulse width (rew rite cr01n) during tm0n operation using the following procedure. <1> disable the timer output inversion operati on by match of tm0n and cr01n (toc0n4 = 0) <2> disable the inttm01n interrupt (tmmk01n = 1) <3> rewrite cr01n <4> wait for 1 cycle of the tm0n count clock <5> enable the timer output inversion operati on by match of tm0n and cr01n (toc0n4 = 1) <6> clear the interrupt request flag of inttm01n (tmif01n = 0) <7> enable the inttm01n interrupt (tmmk01n = 0) remarks 1. 0000h m < n ffffh 2. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 165 6.4.3 pulse width measurement operations it is possible to measure the pulse width of the signal s input to the ti00n pin and ti01n pin using 16-bit timer counter 0n (tm0n). there are two measurement methods : measuring with tm0n used in free -running mode, and measuring by restarting the timer in synchronization with th e edge of the signal in put to the ti00n pin. when an interrupt occurs, read the valid value of the capt ure register, check the overflow flag, and then calculate the necessary pulse width. clear the overflow flag after checking it. the capture operation is not performed unt il the signal pulse width is sampl ed in the count clock cycle selected by prescaler mode register 0n (prm0n) and the valid level of the ti00n or ti01n pin is dete cted twice, thus eliminating noise with a short pulse width. figure 6-21. cr01n capture operat ion with rising edge specified count clock tm0n ti00n rising edge detection cr01n inttm01n n ? 3n ? 2n ? 1 n n + 1 n setting the basic operation setting procedure is as follows. <1> set the crc0n register (see figures 6-22 , 6-25 , 6-27 , and 6-29 for the set value). <2> set the count clock by using the prm0n register. <3> set the tmc0n register to start the operation (see figures 6-22 , 6-25 , 6-27 , and 6-29 for the set value). caution to use two capture register s, set the ti00n and ti01n pins. remarks 1. for the setting of the ti00n (or ti01n) pin, see 6.3 (5) port mode register 0 (pm0) . 2. for how to enable the inttm00n (or inttm01n) interrupt, see chapter 19 interrupt functions . 3. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 166 (1) pulse width measurement with free-runni ng counter and one capture register when 16-bit timer counter 0n (tm0n) is operated in free-ru nning mode, and the edge specified by prescaler mode register 0n (prm0n) is input to the ti00n pin, the value of tm0n is taken into 16-bit timer capture/compare register 01n (cr01n) and an external interrupt request signal (inttm01n) is set. specify both the rising and falling edges of the ti00n pin by using bits 4 and 5 (es0n0 and es0n1) of prm0n. sampling is performed using the count clock selected by prm0n, and a capture operation is only performed when a valid level of the ti00n pin is detected twic e, thus eliminating noise with a short pulse width. figure 6-22. control register settings for pul se width measurement with free-running counter and one capture register (whe n ti00n and cr01n are used) (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 0 tmc0n2 1 tmc0n1 0/1 ovf0n 0 tmc0n free-running mode (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 1 crc0n1 0/1 crc0n0 0 crc0n cr00n used as compare register cr01n used as capture register (c) prescaler mode register 0n (prm0n) es1n1 0/1 es1n0 0/1 es0n1 1 es0n0 1 3 0 2 0 prm0n1 0/1 prm0n0 0/1 prm0n selects count clock (setting ?11? is prohibited). specifies both edges for pulse width detection. setting invalid (setting ?10? is prohibited.) remark 0/1: setting 0 or 1 allows another function to be used simultaneously with pulse width measurement. see the description of the respecti ve control registers for details. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 167 figure 6-23. configuration di agram for pulse width measureme nt with free-running counter f prs (f prs ) note f prs /2 2 (f prs /2 4 ) note f prs /2 8 (f prs /2 6 ) note ti00n 16-bit timer counter 0n (tm0n) ovf0n 16-bit timer capture/compare register 01n (cr01n) internal bus inttm01n selector note frequencies without parentheses are for 16-bit timer/ev ent counter 00, and those in parentheses are for 16- bit timer/event counter 01. figure 6-24. timing of pulse width measureme nt operation with free-running counter and one capture register ( with both edges specified) t 0000h 0000h ffffh 0001h d0 d0 count clock tm0n count value ti00n pin input cr01n capture value inttm01n ovf0n (d1 ? d0) t (d3 ? d2) t (10000h ? d1 + d2) t d1 d2 d3 d2 d3 d0 + 1 d1 d1 + 1 note note clear ovf0n by software. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 168 (2) measurement of two pulse widths with free-running counter when 16-bit timer counter 0n (tm0n) is operated in free- running mode, it is possible to simultaneously measure the pulse widths of the two signals input to the ti00n pin and the ti01n pin. when the edge specified by bits 4 and 5 (es0n0 and es0n1) of prescaler mode register 0n (prm0n) is input to the ti00n pin, the value of tm0n is taken into 16-bit time r capture/compare register 01n (cr01n) and an interrupt request signal (inttm01n) is set. also, when the edge specified by bits 6 and 7 (es1n0 and es1n1) of prm0n is input to the ti01n pin, the value of tm0n is taken into 16-bit timer capture/compare register 00n (cr00n) and an interrupt request signal (inttm00n) is set. specify both the rising and falling edges as the edges of the ti00n and ti01n pins, by using bits 4 and 5 (es0n0 and es0n1) and bits 6 and 7 (es1n0 and es1n1) of prm0n. sampling is performed using the co unt clock cycle selected by prescale r mode register 0n (prm0n), and a capture operation is only performed when a valid level of the ti00n or ti01n pin is detected twice, thus eliminating noise with a short pulse width. figure 6-25. control register settings for measure ment of two pulse widths with free-running counter (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 0 tmc0n2 1 tmc0n1 0/1 ovf0n 0 tmc0n free-running mode (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 1 crc0n1 0 crc0n0 1 crc0n cr00n used as capture register captures valid edge of ti01n pin to cr00n. cr01n used as capture register (c) prescaler mode register 0n (prm0n) es1n1 1 es1n0 1 es0n1 1 es0n0 1 3 0 2 0 prm0n1 0/1 prm0n0 0/1 prm0n selects count clock (setting ?11? is prohibited). specifies both edges for pulse width detection. specifies both edges for pulse width detection. remark 0/1: setting 0 or 1 allows another function to be used simultaneously with pulse width measurement. see the description of the respecti ve control registers for details. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 169 figure 6-26. timing of pulse width measure ment operation with free-running counter (with both edges specified) t 0000h 0000h ffffh 0001h d0 d0 ti01n pin input cr00n capture value inttm01n inttm00n ovf0n (d1 ? d0) t (d3 ? d2) t (10000h ? d1 + d2) t (10000h ? d1 + (d2 + 1)) t d1 d2 + 1 d1 d2 d2 d3 d0 + 1 d1 d1 + 1 d2 + 1 d2 + 2 count clock tm0n count value ti00n pin input cr01n capture value note note clear ovf0n by software. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 170 (3) pulse width measurement with free-runni ng counter and two capture registers when 16-bit timer counter 0n (tm0n) is operated in free-running mode, it is possible to measure the pulse width of the signal input to the ti00n pin. when the rising or falling edge specified by bits 4 and 5 (es0n0 and es0n1) of prescaler mode register 0n (prm0n) is input to the ti00n pin, the value of tm0n is taken into 16-bi t timer capture/compare register 01n (cr01n) and an interrupt request signal (inttm01n) is set. also, when the inverse edge to that of the capture operation is input into cr 01n, the value of tm0n is taken into 16-bit timer capture/compare register 00n (cr00n). sampling is performed using the co unt clock cycle selected by prescale r mode register 0n (prm0n), and a capture operation is only performed when a valid level of the ti00n pin is detec ted twice, thus eliminating noise with a short pulse width. figure 6-27. control register settings for pulse width measurement with fr ee-running counter and two capture registers (with rising edge specified) (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 0 tmc0n2 1 tmc0n1 0/1 ovf0n 0 tmc0n free-running mode (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 1 crc0n1 1 crc0n0 1 crc0n cr00n used as capture register captures to cr00n at inverse edge to valid edge of ti00n. cr01n used as capture register (c) prescaler mode register 0n (prm0n) es1n1 0/1 es1n0 0/1 es0n1 0 es0n0 1 3 0 2 0 prm0n1 0/1 prm0n0 0/1 prm0n selects count clock (setting ?11? is prohibited). specifies rising edge for pulse width detection. setting invalid (setting ?10? is prohibited.) remark 0/1: setting 0 or 1 allows another function to be used simultaneously with pulse width measurement. see the description of the respecti ve control registers for details. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 171 figure 6-28. timing of pulse width measureme nt operation with free-running counter and two capture registers (with rising edge specified) t 0000h 0000h ffffh 0001h d0 d0 inttm01n ovf0n d2 d1 d3 d2 d3 d0 + 1 d2 + 1 d1 d1 + 1 cr00n capture value count clock tm0n count value ti00n pin input cr01n capture value (d1 ? d0) t (d3 ? d2) t (10000h ? d1 + d2) t note note clear ovf0n by software. (4) pulse width measurement by means of restart when input of a valid edge to the ti00n pi n is detected, the count value of 16- bit timer counter 0n (tm0n) is taken into 16-bit timer capture/compare register 01n (cr01n), and then the pulse width of t he signal input to the ti00n pin is measured by clearing tm0n and restarting the count operation. either of two edges ? rising or falling ? can be selected using bits 4 and 5 ( es0n0 and es0n1) of prescaler mode register 0n (prm0n). sampling is performed using the count clock cycle sele cted by prescaler mode register 0n (prm0n) and a capture operation is only performed when a valid level of the ti00n pin is detec ted twice, thus eliminating noise with a short pulse width. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 172 figure 6-29. control register settings for pu lse width measurement by means of restart (with rising edge specified) (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 1 tmc0n2 0 tmc0n1 0/1 ovf0n 0 tmc0n clears and starts at valid edge of ti00n pin. (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 1 crc0n1 1 crc00n 1 crc0n cr00n used as capture register captures to cr00n at inverse edge to valid edge of ti00n. cr01n used as capture register (c) prescaler mode register 0n (prm0n) es1n1 0/1 es1n0 0/1 es0n1 0 es0n0 1 3 0 2 0 prm0n1 0/1 prm0n0 0/1 prm0n selects count clock (setting ?11? is prohibited). specifies rising edge for pulse width detection. setting invalid (setting ?10? is prohibited.) figure 6-30. timing of pulse width measurement operation by means of restart (with risi ng edge specified) t 0000h 0001h 0000h 0001h 0000h 0001h d0 d0 inttm01n d1 t d2 t d2 d1 d2 d1 cr00n capture value count clock tm0n count value ti00n pin input cr01n capture value remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 173 6.4.4 external event counter operation setting the basic operation setting procedure is as follows. <1> set the crc0n register (see figure 6-31 for the set value). <2> set the count clock by using the prm0n register. <3> set any value to the cr00n register (0000h cannot be set). <4> set the tmc0n register to start the operation (see figure 6-31 for the set value). remarks 1. for the setting of the ti00n pin, see 6.3 (5) port mode register 0 (pm0) . 2. for how to enable the inttm00n interrupt, see chapter 19 interrupt functions . the external event counter counts the num ber of external clock pulses input to the ti00n pin using 16-bit timer counter 0n (tm0n). tm0n is incremented each time the valid edge specified by prescaler mode register 0n (prm0n) is input. when the tm0n count value matches the 16-bit timer capt ure/compare register 00n (cr00n) value, tm0n is cleared to 0 and the interrupt requ est signal (inttm00n) is generated. input a value other than 0000h to cr00n (a count operation with 1-bit pulse cannot be carried out). any of three edges ? rising, falling, or both edges ? can be selected using bits 4 and 5 (es0n0 and es0n1) of prescaler mode register 0n (prm0n). sampling is performed using the internal clock (f prs ) and an operation is only performed when a valid level of the ti00n pin is detected twice, thus eliminating noise with a short pulse width. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 174 figure 6-31. control register setti ngs in external event counter mode (with rising edge specified) (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 1 tmc0n2 1 tmc0n1 0/1 ovf0n 0 tmc0n clears and starts on match between tm0n and cr00n. (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 0/1 crc0n1 0/1 crc0n0 0 crc0n cr00n used as compare register (c) prescaler mode register 0n (prm0n) es1n1 0/1 es1n0 0/1 es0n1 0 es0n0 1 3 0 2 0 prm0n1 1 prm0n0 1 prm0n selects external clock. specifies rising edge for pulse width detection. setting invalid (setting ?10? is prohibited.) remark 0/1: setting 0 or 1 allows another function to be used simultaneously with the external event counter. see the description of the respecti ve control registers for details. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 175 figure 6-32. configuration diagra m of external event counter f prs internal bus 16-bit timer capture/compare register 00n (cr00n) match clear ovf0n note noise eliminator 16-bit timer counter 0n (tm0n) valid edge of ti00n pin inttm00n note ovf0n is set to 1 only when cr00n is set to ffffh. figure 6-33. external event counter oper ation timing (with rising edge specified) ti00n pin input tm0n count value cr00n inttm00n 0000h 0001h 0002h 0003h 0004h 0005h n ? 1 n 0000h 0001h 0002h 0003h n caution when reading the ext ernal event counter count val ue, tm0n should be read. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 176 6.4.5 square-wave output operation setting the basic operation setting procedure is as follows. <1> set the count clock by using the prm0n register. <2> set the crc0n register (see figure 6-34 for the set value). <3> set the toc0n register (see figure 6-34 for the set value). <4> set any value to the cr00n register (0000h cannot be set). <5> set the tmc0n register to start the operation (see figure 6-34 for the set value). caution cr00n cannot be rewr itten during tm0n operation. remarks 1. for the setting of the to0n pin, see 6.3 (5) port mode register 0 (pm0) . 2. for how to enable the inttm00n interrupt, see chapter 19 interrupt functions . a square wave with any selected frequency can be output at intervals determined by the count value preset to 16- bit timer capture/compare register 00n (cr00n). the to0n pin output status is reversed at intervals determined by the count value preset to cr00n + 1 by setting bit 0 (toe0n) and bit 1 (toc0n1) of 16-bit timer output control register 0n (toc0n) to 1. this enables a square wave with any selected frequency to be output. figure 6-34. control register settings in square-wave output mode (1/2) (a) 16-bit timer mode cont rol register 0n (tmc0n) 7 0 6 0 5 0 4 0 tmc0n3 1 tmc0n2 1 tmc0n1 0 ovf0n 0 tmc0n clears and starts on match between tm0n and cr00n. (b) capture/compare cont rol register 0n (crc0n) 7 0 6 0 5 0 4 0 3 0 crc0n2 0/1 crc0n1 0/1 crc0n0 0 crc0n cr00n used as compare register remark 0/1: setting 0 or 1 allows another function to be used simultaneously with square-wave output. see the description of the respective control registers for details. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 177 figure 6-34. control register settings in square-wave output mode (2/2) (c) 16-bit timer output control register 0n (toc0n) 7 0 ospt0n 0 ospe0n 0 toc0n4 0 lvs0n 0/1 lvr0n 0/1 toc0n1 1 toe0n 1 toc0n enables to0n output. inverts output on match between tm0n and cr00n. specifies initial value of to0n output f/f (setting ?11? is prohibited). does not invert output on match between tm0n and cr01n. disables one-shot pulse output. (d) prescaler mode register 0n (prm0n) es1n1 0/1 es1n0 0/1 es0n1 0/1 es0n0 0/1 3 0 2 0 prm0n1 0/1 prm0n0 0/1 prm0n selects count clock. setting invalid (setting ?10? is prohibited.) setting invalid (setting ?10? is prohibited.) remark 0/1: setting 0 or 1 allows another function to be used simultaneously with square-wave output. see the description of the respective control registers for details. n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d figure 6-35. square-wave output operation timing count clock tm0n count value cr00n inttm00n to0n pin output 0000h 0001h 0002h n ? 1n 0000h 0001h 0002h n ? 1n 0000h n remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 178 6.4.6 one-shot pulse output operation 16-bit timer/event counter 0n can output a one-shot pulse in synchronization with a software trigger or an external trigger (ti00n pin input). setting the basic operation setting procedure is as follows. <1> set the count clock by using the prm0n register. <2> set the crc0n register (see figures 6-36 and 6-38 for the set value). <3> set the toc0n register (see figures 6-36 and 6-38 for the set value). <4> set any value to the cr00n and cr01n registers (0000h cannot be set). <5> set the tmc0n register to start the operation (see figures 6-36 and 6-38 for the set value). remarks 1. for the setting of the to0n pin, see 6.3 (5) port mode register 0 (pm0) . 2. for how to enable the inttm00n (if necessary, inttm01n) interrupt, see chapter 19 interrupt functions . (1) one-shot pulse output with software trigger a one-shot pulse can be output from t he to0n pin by setting 16-bit timer mode control register 0n (tmc0n), capture/compare control register 0n (crc0n), and 16-bit timer output control register 0n (toc0n) as shown in figure 6-36, and by setting bit 6 (ospt0n) of the toc0n register to 1 by software. by setting the ospt0n bit to 1, 16-bit timer/event co unter 0n is cleared and starte d, and its output becomes active at the count value (n) set in advance to 16-bit time r capture/compare register 01n (cr01n). after that, the output becomes inactive at the count value (m) set in advance to 16-bit timer capture/compare register 00n (cr00n) note . even after the one-shot pulse has been output, the tm0n regi ster continues its operat ion. to stop the tm0n register, the tmc0n3 and tmc0n2 bits of t he tmc0n register must be set to 00. note the case where n < m is described here. when n > m, the output becomes active with the cr00n register and inactive with the cr01n register. do not set n to m. cautions 1. do not set the ospt0n bit to 1 again while the one-shot pulse is being output. to output the one-shot pulse again, wait until the current one-shot pulse output is completed. 2. when using the one-shot pulse output of 16-bit timer/event counter 0n with a software trigger, do not change the level of the ti 00n pin or its alternate-function port pin. because the external trigger is valid even in this case, the ti mer is cleared and started even at the level of the ti00n pin or its alternate-function port pin, resulting in the output of a pulse at an undesired timing. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 179 figure 6-36. control register settings for on e-shot pulse output with software trigger (a) 16-bit timer mode cont rol register 0n (tmc0n) 0000 7654 0 tmc0n3 tmc0n tmc0n2 tmc0n1 ovf0n free-running mode 100 (b) capture/compare cont rol register 0n (crc0n) 00000 76543 crc0n crc0n2 crc0n1 crc0n0 cr00n as compare register cr01n as compare register 0 0/1 0 (c) 16-bit timer output control register 0n (toc0n) 0 7 0 1 1 0/1 toc0n lvr0n lvs0n toc0n4 ospe0n ospt0n toc0n1 toe0n enables to0n output. inverts output upon match between tm0n and cr00n. specifies initial value of to0n output f/f (setting ?11? is prohibited.) inverts output upon match between tm0n and cr01n. sets one-shot pulse output mode. set to 1 for output. 0/1 1 1 (d) prescaler mode register 0n (prm0n) 0/1 0/1 0/1 0/1 0 prm0n prm0n1 prm0n0 selects count clock. setting invalid (setting ?10? is prohibited.) 0 0/1 0/1 es1n1 es1n0 es0n1 es0n0 setting invalid (setting ?10? is prohibited.) 32 caution do not set 0000h to the cr00n and cr01n registers. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 180 figure 6-37. timing of one-shot pulse output operation with software trigger 0000h n nn n n mm m m nm n + 1 n ? 1 m ? 1 0001h m + 1 m + 2 0000h count clock tm0n count cr01n set value cr00n set value ospt0n inttm01n inttm00n to0n pin output set tmc0n to 04h (tm0n count starts) caution 16-bit timer counter 0n st arts operating as soon as a value othe r than 00 (operation stop mode) is set to the tmc0n3 and tmc0n2 bits. remark n < m (2) one-shot pulse output with external trigger a one-shot pulse can be output from t he to0n pin by setting 16-bit timer mode control register 0n (tmc0n), capture/compare control register 0n (crc0n), and 16-bit timer output control register 0n (toc0n) as shown in figure 6-38, and by using the valid edge of the ti00n pin as an external trigger. the valid edge of the ti00n pin is specified by bits 4 and 5 (es0n0, es 0n1) of prescaler mode register 0n (prm0n). the rising, falling, or both the rising and falling edges can be specified. when the valid edge of the ti00n pin is detected, the 16-bit time r/event counter is clear ed and started, and the output becomes active at the count value set in advance to 16-bit timer capture/compare register 01n (cr01n). after that, the output becomes inactive at the count value set in advance to 16-bit timer capture/compare register 00n (cr00n) note . note the case where n < m is described here. when n > m, the output becomes active with the cr00n register and inactive with the cr01n register. do not set n to m. caution do not input the external trigger again while the one-shot pulse is being output. to output the one-shot pulse again, wait until th e current one-shot pulse output is completed. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 181 figure 6-38. control register settings for on e-shot pulse output with external trigger (with rising edge specified) (a) 16-bit timer mode cont rol register 0n (tmc0n) 0000 7654 1 tmc0n3 tmc0n tmc0n2 tmc0n1 ovf0n clears and starts at valid edge of ti00n pin. 000 (b) capture/compare cont rol register 0n (crc0n) 00000 76543 crc0n crc0n2 crc0n1 crc0n0 cr00n used as compare register cr01n used as compare register 0 0/1 0 (c) 16-bit timer output control register 0n (toc0n) 0 7 01 1 0/1 toc0n lvr0n toc0n1 toe0n ospe0n ospt0n toc0n4 lvs0n enables to0n output. inverts output upon match between tm0n and cr00n. specifies initial value of to0n output f/f (setting ?11? is prohibited.) inverts output upon match between tm0n and cr01n. sets one-shot pulse output mode. 0/1 1 1 (d) prescaler mode register 0n (prm0n) 0/1 0/1 0 1 prm0n prm0n1 prm0n0 selects count clock (setting ?11? is prohibited). specifies the rising edge for pulse width detection. 0/1 0/1 es1n1 es1n0 es0n1 es0n0 setting invalid (setting ?10? is prohibited.) 00 32 caution do not set the cr00n a nd cr01n registers to 0000h. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 182 figure 6-39. timing of one-shot pulse output operation with external trigger (wit h rising edge specified) 0000h n nn n n mm m m m n + 1 n + 2 m + 1 m + 2 m ? 2 m ? 1 0001h 0000h count clock tm0n count value cr01n set value cr00n set value ti00n pin input inttm01n inttm00n to0n pin output when tmc0n is set to 08h (tm0n count starts) t caution 16-bit timer counter 0n st arts operating as soon as a value othe r than 00 (operation stop mode) is set to the tmc0n2 and tmc0n3 bits. remark n < m n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 183 6.5 cautions for 16-bit timer/event counters 00 and 01 (1) timer start errors an error of up to one clock may occur in the time requir ed for a match signal to be generated after timer start. this is because 16-bit timer counter 0n (tm0n) is started asynchronously to the count clock. figure 6-40. start timing of 16-bit timer counter 0n (tm0n) tm0n count value 0000h 0001h 0002h 0004h count clock timer start 0003h (2) 16-bit timer capture/compare register 00n setting in the mode in which clear & start occurs on a match between tm0n and cr00n, set 16-bit timer capture/compare register 00n (cr00n) to other than 0000h. this means a 1-pulse count operation cannot be performed when 16-bit timer/event counter 0n is used as an external event counter. (3) capture register data retention timing the values of 16-bit timer capture/ compare registers 00n and 01n (cr00n and cr01n) are not guaranteed after 16-bit timer/event counter 0n has been stopped. (4) valid edge setting set the valid edge of the ti00n pin after setting bits 2 and 3 (tmc0n2 and tmc0n3) of 16-bit timer mode control register 0n (tmc0n) to 0, 0, respectively, and then sto pping timer operation. the valid edge is set using bits 4 and 5 (es0n0 and es0n1) of prescaler mode register 0n (prm0n). (5) re-triggering one-shot pulse (a) one-shot pulse output by software do not set the ospt0n bit to 1 again while the one-shot pulse is being output. to output the one-shot pulse again, wait until the current one-shot pu lse output is completed. (b) one-shot pulse output with external trigger do not input the external trigger again while the one-shot pulse is being output. to output the one-shot pulse again, wait until the current one-shot pu lse output is completed. (c) one-shot pulse output function when using the one-shot pulse output of 16-bit timer/ev ent counter 0n with a software trigger, do not change the level of the ti00n pin or its alternate function port pin. because the external trigger is valid even in this case , the timer is cleared and start ed even at the level of the ti00n pin or its alternate function port pin, resulting in the output of a pulse at an undesired timing. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 184 (6) operation of ovf0n flag <1> the ovf0n flag is also set to 1 in the following case. when of the following modes: the mode in which cl ear & start occurs on a match between tm0n and cr00n, the mode in which clear & start occurs on a ti00n pin valid edge, or the free-running mode, is selected cr00n is set to ffffh tm0n is counted up from ffffh to 0000h. figure 6-41. operation timing of ovf0n flag count clock cr00n tm0n ovf0n inttm00n ffffh fffeh ffffh 0000h 0001h <2> even if the ovf0n flag is cleared before the next count clock is counted (before tm0n becomes 0001h) after the occurrence of tm0n overflow, the ovf0n flag is re-set newly and clear is disabled. (7) conflicting operations conflict between the read period of the 16-bit timer captur e/compare register (cr00n/cr01n) and capture trigger input (cr00n/cr01n used as capture register) capture trigger input has priority. the data read from cr00n/cr01n is undefined. figure 6-42. capture regist er data retention timing count clock tm0n count value edge input inttm01n capture read signal cr01n capture value n n + 1 n + 2 m m + 1 m + 2 x n + 2 capture, but read value is not guaranteed capture m + 1 remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 6 16-bit timer/event counters 00 and 01 preliminary user?s manual u17473ej1v0ud 185 (8) timer operation <1> even if 16-bit timer counter 0n (tm0n) is read, t he value is not captured by 16-bit timer capture/compare register 01n (cr01n). <2> regardless of the cpu?s operation mode, when the timer stops, the input signals to the ti00n/ti01n pins are not acknowledged. <3> the one-shot pulse output mode oper ates correctly only in the free-ru nning mode and the mode in which clear & start occurs at the ti00n vali d edge. in the mode in which clear & start occurs on a match between the tm0n register and cr00n register, one-shot pulse output is not possi ble because an overflow does not occur. (9) capture operation <1> if the ti00n pin valid edge is spec ified as the count clock, a captur e operation by the capture register specified as the trigger for the ti00n pin is not possible. <2> to ensure the reliability of the c apture operation, the capt ure trigger requires a pulse two cycles longer than the count clock selected by prescaler mode register 0n (prm0n). <3> the capture operation is performed at the falling ed ge of the count clock. an interrupt request input (inttm00n/inttm01n), however, is generated at the rise of the next count clock. (10) compare operation a capture operation may not be performed for cr00n/cr01n se t in compare mode even if a capture trigger has been input. (11) edge detection <1> if the ti00n or ti01n pin is high level immediately a fter system reset and the rising edge or both the rising and falling edges are specified as the valid edge of t he ti00n or ti01n pin to enable the 16-bit timer counter 0n (tm0n) operation, a rising edge is detected immediately after the operation is enabled. be careful therefore when pulling up the ti00n or ti01n pin. however, the rising edge is not detected at restart after the operation has been stopped once. <2> the sampling clock used to remove noise differs when the ti00n pin valid edge is used as the count clock and when it is used as a capture trigger. in the former case, the count clock is f prs , and in the latter case the count clock is selected by prescaler mode register 0n (prm0n). the capture operation is started only after a valid edge is detected twice by sampling, thus eliminating noise with a short pulse width. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d preliminary user?s manual u17473ej1v0ud 186 chapter 7 8-bit timer/even t counters 50 and 51 7.1 functions of 8-bit ti mer/event counters 50 and 51 8-bit timer/event counters 50 and 51 have the following functions. ? interval timer ? external event counter ? square-wave output ? pwm output figures 7-1 and 7-2 show the block diagrams of 8-bit timer/event counters 50 and 51. figure 7-1. block diagram of 8-bit timer/event counter 50 internal bus 8-bit timer compare register 50 (cr50) ti50/to50/p17 f prs /2 13 f prs f prs /2 match mask circuit ovf clear 3 selector tcl502 tcl501 tcl500 timer clock selection register 50 (tcl50) internal bus tce50 tmc506 lvs50 lvr50 tmc501 toe50 invert level 8-bit timer mode control register 50 (tmc50) s r s q r inv selector to tmh0 to uart0 to uart6 inttm50 to50/ti50/p17 note 1 note 2 selector 8-bit timer counter 50 (tm50) selector output latch (p17) pm17 f prs /2 2 f prs /2 8 f prs /2 6 notes 1. timer output f/f 2. pwm output f/f chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 187 figure 7-2. block diagram of 8-bit timer/event counter 51 internal bus 8-bit timer compare register 51 (cr51) ti51/to51/ p33/intp4 f prs /2 12 f prs f prs /2 match mask circuit ovf clear 3 selector tcl512 tcl511 tcl510 timer clock selection register 51 (tcl51) internal bus tce51 tmc516 lvs51 lvr51 tmc511 toe51 invert level 8-bit timer mode control register 51 (tmc51) s r s q r inv selector inttm51 to51/ti51/ p33/intp4 note 1 note 2 selector 8-bit timer counter 51 (tm51) selector output latch (p33) pm33 f prs /2 6 f prs /2 4 f prs /2 8 notes 1. timer output f/f 2. pwm output f/f chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 188 7.2 configuration of 8-bit timer/event counters 50 and 51 8-bit timer/event counters 50 and 51 include the following hardware. table 7-1. configuration of 8-bit timer/event counters 50 and 51 item configuration timer register 8-bit timer counter 5n (tm5n) register 8-bit timer compare register 5n (cr5n) timer input ti5n timer output to5n control registers timer clock selection register 5n (tcl5n) 8-bit timer mode control register 5n (tmc5n) port mode register 1 (pm1) or port mode register 3 (pm3) port register 1 (p1) or port register 3 (p3) (1) 8-bit timer counter 5n (tm5n) tm5n is an 8-bit register that count s the count pulses and is read-only. the counter is incremented in synchronization with the rising edge of the count clock. figure 7-3. format of 8-bit timer counter 5n (tm5n) symbol tm5n (n = 0, 1) address: ff16h (tm50), ff1fh (tm51) after reset: 00h r in the following situations, the count value is cleared to 00h. <1> reset input <2> when tce5n is cleared <3> when tm5n and cr5n match in the mode in which clear & start occurs upon a match of the tm5n and cr5n. remark n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 189 (2) 8-bit timer compare register 5n (cr5n) cr5n can be read and written by an 8-bi t memory manipulation instruction. except in pwm mode, the value set in cr5n is constantly compared with the 8-bit timer counter 5n (tm5n) count value, and an interrupt request (in ttm5n) is generated if they match. in pwm mode, when the to5n pin becomes active due to a tm5n overflow and the values of tm5n and cr5n match, the to5n pin becomes inactive. the value of cr5n can be set within 00h to ffh. reset input clears cr5n to 00h. figure 7-4. format of 8-bit time r compare register 5n (cr5n) symbol cr5n (n = 0, 1) address: ff17h (cr50), ff41h (cr51) after reset: 00h r/w cautions 1. in the mode in which clear & start oc curs on a match of tm5n and cr5n (tmc5n6 = 0), do not write other values to cr5n during operation. 2. in pwm mode, make the cr5n rewrite peri od 3 count clocks of the count clock (clock selected by tcl5n) or more. remark n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 190 7.3 registers controlling 8-bit ti mer/event counters 50 and 51 the following four registers are used to co ntrol 8-bit timer/event counters 50 and 51. ? timer clock selection register 5n (tcl5n) ? 8-bit timer mode control register 5n (tmc5n) ? port mode register 1 (pm1) or port mode register 3 (pm3) ? port register 1 (p1) or port register 3 (p3) (1) timer clock selecti on register 5n (tcl5n) this register sets the count clock of 8-bit timer/ev ent counter 5n and the valid edge of the ti5n pin input. tcl5n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears tcl5n to 00h. remark n = 0, 1 figure 7-5. format of timer clo ck selection register 50 (tcl50) address: ff6ah after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tcl50 0 0 0 0 0 tcl502 tcl501 tcl500 count clock selection tcl502 tcl501 tcl500 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz 0 0 0 ti50 pin falling edge note 1 0 0 1 ti50 pin rising edge note 2 0 1 0 f prs 2 mhz 5 mhz 10 mhz 20 mhz 0 1 1 f prs /2 1 mhz 2.5 mhz 5 mhz 10 mhz 1 0 0 f prs /2 2 500 khz 1.25 mhz 2.5 mhz 5 mhz 1 0 1 f prs /2 6 31.25 khz 78.13 khz 156.25 khz 312.5 khz 1 1 0 f prs /2 8 7.81 khz 19.53 khz 39.06 khz 78.13 khz 1 1 1 f prs /2 13 0.24 khz 0.61 khz 1.22 khz 2.44 khz notes 1. in the on-board mode, the flmd0 pin falling edge is selected. 2. in the on-board mode, the flmd0 pin rising edge is selected. cautions 1. when rewriting tcl50 to othe r data, stop the timer operation beforehand. 2. be sure to clea r bits 3 to 7 to 0. remark f prs : peripheral hardware clock oscillation frequency chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 191 figure 7-6. format of timer clo ck selection register 51 (tcl51) address: ff8ch after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tcl51 0 0 0 0 0 tcl512 tcl511 tcl510 count clock selection tcl512 tcl511 tcl510 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz 0 0 0 ti51 pin falling edge 0 0 1 ti51 pin rising edge 0 1 0 f prs 2 mhz 5 mhz 10 mhz 20 mhz 0 1 1 f prs /2 1 mhz 2.5 mhz 5 mhz 10 mhz 1 0 0 f prs /2 4 125 khz 312.5 khz 625 khz 1.25 mhz 1 0 1 f prs /2 6 31.25 khz 78.13 khz 156.25 khz 312.5 khz 1 1 0 f prs /2 8 7.81 khz 19.53 khz 39.06 khz 78.13 khz 1 1 1 f prs /2 12 0.49 khz 1.22 khz 2.44 khz 4.88 khz cautions 1. when rewriting tcl51 to othe r data, stop the timer operation beforehand. 2. be sure to clea r bits 3 to 7 to 0. remark f prs : peripheral hardware clock oscillation frequency chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 192 (2) 8-bit timer mode control register 5n (tmc5n) tmc5n is a register that performs the following five types of settings. <1> 8-bit timer counter 5n (tm5n) count operation control <2> 8-bit timer counter 5n (tm5n) operating mode selection <3> timer output f/f (flip flop) status setting <4> active level selection in timer f/f control or pwm (free-running) mode. <5> timer output control tmc5n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. remark n = 0, 1 figure 7-7. format of 8-bit timer mode control register 50 (tmc50) address: ff6bh after reset: 00h r/w note symbol <7> 6 5 4 <3> <2> 1 <0> tmc50 tce50 tmc506 0 0 lvs50 lvr50 tmc501 toe50 tce50 tm50 count operation control 0 after clearing to 0, count operation disabled (counter stopped) 1 count operation start tmc506 tm50 operating mode selection 0 mode in which clear & start occurs on a match between tm50 and cr50 1 pwm (free-running) mode lvs50 lvr50 timer output f/f status setting 0 0 no change 0 1 timer output f/f reset (0) 1 0 timer output f/f set (1) 1 1 setting prohibited in other modes (tmc506 = 0) in pwm mode (tmc506 = 1) tmc501 timer f/f control active level selection 0 inversion operation disabled active-high 1 inversion operation enabled active-low toe50 timer output control 0 output disabled (tm50 output is low level) 1 output enabled note bits 2 and 3 are write-only. (refer to cautions and remarks on the next page.) chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 193 figure 7-8. format of 8-bit timer mode control register 51 (tmc51) address: ff43h after reset: 00h r/w note symbol <7> 6 5 4 <3> <2> 1 <0> tmc51 tce51 tmc516 0 0 lvs51 lvr51 tmc511 toe51 tce51 tm51 count operation control 0 after clearing to 0, count operation disabled (counter stopped) 1 count operation start tmc516 tm51 operating mode selection 0 mode in which clear & start occurs on a match between tm51 and cr51 1 pwm (free-running) mode lvs51 lvr51 timer output f/f status setting 0 0 no change 0 1 timer output f/f reset (0) 1 0 timer output f/f set (1) 1 1 setting prohibited in other modes (tmc516 = 0) in pwm mode (tmc516 = 1) tmc511 timer f/f control active level selection 0 inversion operation disabled active-high 1 inversion operation enabled active-low toe51 timer output control 0 output disabled (tm51 output is low level) 1 output enabled note bits 2 and 3 are write-only. cautions 1. the settings of lvs5n and lv r5n are valid in other than pwm mode. 2. perform <1> to <4> below in the following order, not at the same time. <1> set tmc5n1, tmc5n6 : operation mode setting <2> set toe5n to enable output: timer output enable <3> set lvs5n, lvr5n (see caution 1): timer f/f setting <4> set tce5n 3. stop operation befo re rewriting tmc5n6. remarks 1. in pwm mode, pwm output is made inactive by clearing tce5n to 0. 2. if lvs5n and lvr5n are read, the value is 0. 3. the values of the tmc5n6, lvs5n, lvr5n, tmc 5n1, and toe5n bits are re flected at the to5n pin regardless of the value of tce5n. 4. n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 194 (3) port mode registers 1 and 3 (pm1, pm3) these registers set port 1 and 3 input/output in 1-bit units. when using the p17/to50/ti50 and p 33/to51/ti51/intp4 pins for timer output, clear pm17 and pm33 and the output latches of p17 and p33 to 0. when using the p17/to50/ti50 and p33/ to51/ti51/intp4 pins for timer input, set pm17 and pm33 to 1. the output latches of p17 and p33 at this time may be 0 or 1. pm1 and pm3 can be set by a 1-bit or 8- bit memory manipulation instruction. reset input sets these registers to ffh. figure 7-9. format of port mode register 1 (pm1) address: ff21h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm1 pm17 pm16 pm15 pm14 pm13 pm12 pm11 pm10 pm1n p1n pin i/o mode selection (n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) figure 7-10. format of port mode register 3 (pm3) address: ff23h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm3 1 1 1 1 pm33 pm32 pm31 pm30 pm3n p3n pin i/o mode selection (n = 0 to 3) 0 output mode (output buffer on) 1 input mode (output buffer off) chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 195 7.4 operations of 8-bit timer/event counters 50 and 51 7.4.1 operation as interval timer 8-bit timer/event counter 5n operates as an interval time r that generates interrupt req uests repeatedly at intervals of the count value preset to 8-bi t timer compare register 5n (cr5n). when the count value of 8-bit timer counter 5n (tm5n) ma tches the value set to cr5n, counting continues with the tm5n value cleared to 0 and an interrupt request signal (inttm5n) is generated. the count clock of tm5n can be selected with bits 0 to 2 (tcl5n0 to tcl5n2) of timer clock selection register 5n (tcl5n). setting <1> set the registers. ? tcl5n: select the count clock. ? cr5n: compare value ? tmc5n: stop the count operation, se lect the mode in which clear & start occurs on a match of tm5n and cr5n. (tmc5n = 0000 0b = don?t care) <2> after tce5n = 1 is set, the count operation starts. <3> if the values of tm5n and cr5n match, intt m5n is generated (tm5n is cleared to 00h). <4> inttm5n is generated repeatedly at the same interval. set tce5n to 0 to stop the count operation. caution do not write other values to cr5n during operation. figure 7-11. interval ti mer operation timing (1/2) (a) basic operation t count clock tm5n count value cr5n tce5n inttm5n count start clear clear 00h 01h n 00h 01h n 00h 01h n n n n n interrupt acknowledged interrupt acknowledged interval time interval time remark interval time = (n + 1) t n = 01h to ffh n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 196 figure 7-11. interval ti mer operation timing (2/2) (b) when cr5n = 00h t interval time count clock tm5n cr5n tce5n inttm5n 00h 00h 00h 00h 00h (c) when cr5n = ffh t count clock tm5n cr5n tce5n inttm5n 01h feh ffh 00h feh ffh 00h ffh ffh ffh interval time interrupt acknowledged interrupt acknowledged remark n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 197 7.4.2 operation as external event counter the external event counter c ounts the number of external clock pulses to be input to the ti5n pin by 8-bit timer counter 5n (tm5n). tm5n is incremented each time the valid edge specified by timer clock selection regist er 5n (tcl5n) is input. either the rising or falling edge can be selected. when the tm5n count value matches the value of 8-bit ti mer compare register 5n (cr5n), tm5n is cleared to 0 and an interrupt request signal (inttm5n) is generated. whenever the tm5n value matches the va lue of cr5n, inttm5n is generated. setting <1> set each register. ? set the port mode register (pm17 or pm33) note to 1. ? tcl5n: select ti5n pin input edge. ti5n pin falling edge tcl5n = 00h ti5n pin rising edge tcl5n = 01h ? cr5n: compare value ? tmc5n: stop the count operation, select the mode in which clear & start occurs on match of tm5n and cr5n, disable the timer f/f inversion operation, disable timer output. (tmc5n = 0000 00b = don?t care) <2> when tce5n = 1 is set, the number of pu lses input from the ti5n pin is counted. <3> when the values of tm5n and cr5n match, inttm5n is generated (tm5n is cleared to 00h). <4> after these settings, inttm5n is generated each time the values of tm5n and cr5n match. note 8-bit timer/event counter 50: pm17 8-bit timer/event counter 51: pm33 figure 7-12. external event counter oper ation timing (with rising edge specified) ti5n tm5n count value cr5n inttm5n 00h 01h 02h 03h 04h 05h n ? 1 n 00h 01h 02h 03h n count start remark n = 00h to ffh n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 198 7.4.3 square-wave output operation a square wave with any selected frequency is output at in tervals determined by the value preset to 8-bit timer compare register 5n (cr5n). the to5n pin output status is inverted at intervals determined by the count value preset to cr5n by setting bit 0 (toe5n) of 8-bit timer mode control r egister 5n (tmc5n) to 1. this enables a square wave with any selected frequency to be output (duty = 50%). setting <1> set each register. ? clear the port output latch (p17 or p33) note and port mode register (pm17 or pm33) note to 0. ? tcl5n: select the count clock. ? cr5n: compare value ? tmc5n: stop the count operat ion, select the mode in which clear & start occurs on a match of tm5n and cr5n. lvs5n lvr5n timer output f/f status setting 1 0 high-level output 0 1 low-level output timer output f/f inversion enabled timer output enabled (tmc5n = 00001011b or 00000111b) <2> after tce5n = 1 is set, the count operation starts. <3> the timer output f/f is inverted by a match of tm5n and cr5n. after inttm5n is generated, tm5n is cleared to 00h. <4> after these settings, the timer output f/f is inverted at the same interval and a square wave is output from to5n. the frequency is as follows. frequency = 1/2t (n + 1) (n: 00h to ffh) note 8-bit timer/event counter 50: p17, pm17 8-bit timer/event counter 51: p33, pm33 caution do not write other values to cr5n during operation. remark n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 199 figure 7-13. square-wave output operation timing count clock tm5n count value 00h 01h 02h n ? 1n n 00h n ? 1 n 00h 01h 02h cr5n to5n note t count start note the initial value of to5n output c an be set by bits 2 and 3 (lvr5n, lvs5n) of 8-bit timer mode control register 5n (tmc5n). 7.4.4 pwm output operation 8-bit timer/event counter 5n operates as a pwm output when bit 6 (tmc5n6) of 8-bit timer mode control register 5n (tmc5n) is set to 1. the duty pulse determined by the value set to 8-bit time r compare register 5n (cr5n) is output from to5n. set the active level width of the pwm pulse to cr5n; the active level can be selected with bit 1 (tmc5n1) of tmc5n. the count clock can be selected with bits 0 to 2 (tcl5n0 to tcl5n2) of timer clock selection register 5n (tcl5n). pwm output can be enabled/disabled with bit 0 (toe5n) of tmc5n. caution in pwm mode, make the cr5n rewrite period 3 count clocks of the count clock (clock selected by tcl5n) or more. remark n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 200 (1) pwm output basic operation setting <1> set each register. ? clear the port output latch (p17 or p33) note and port mode register (pm17 or pm33) note to 0. ? tcl5n: select the count clock. ? cr5n: compare value ? tmc5n: stop the count operation, select pwm mode. the timer output f/f is not changed. tmc5n1 active level selection 0 active-high 1 active-low timer output enabled (tmc5n = 01000001b or 01000011b) <2> the count operation starts when tce5n = 1. clear tce5n to 0 to stop the count operation. note 8-bit timer/event counter 50: p17, pm17 8-bit timer/event counter 51: p33, pm33 pwm output operation <1> pwm output (output from to5n) outputs an inactive level until an overflow occurs. <2> when an overflow occurs, the active level is outpu t. the active level is output until cr5n matches the count value of 8-bit timer counter 5n (tm5n). <3> after the cr5n matches the count value, the inacti ve level is output until an overflow occurs again. <4> operations <2> and <3> are repe ated until the count operation stops. <5> when the count operation is stopped with tce5n = 0, pwm output becomes inactive. for details of timing, see figures 7-14 and 7-15 . the cycle, active-level width, and duty are as follows. ? cycle = 2 8 t ? active-level width = nt ? duty = n/2 8 (n = 00h to ffh) remark n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 201 figure 7-14. pwm output operation timing (a) basic operation (active level = h) count clock tm5n cr5n tce5n inttm5n to5n 00h 01h ffh 00h 01h 02h n n + 1 ffh 00h 01h 02h m 00h n <2> active level <1> <3> inactive level active level <5> t (b) cr5n = 00h count clock tm5n cr5n tce5n inttm5n to5n inactive level inactive level 01h 00h ffh 00h 01h 02h n n + 1 ffh 00h 01h 02h m 00h 00h n + 2 l t (c) cr5n = ffh tm5n cr5n tce5n inttm5n to5n 01h 00h ffh 00h 01h 02h n n + 1 ffh 00h 01h 02h m 00h ffh n + 2 inactive level active level inactive level active level inactive level t remarks 1. <1> to <3> and <5> in figure 7-14 (a) correspond to <1> to <3> and <5> in pwm output operation in 7.4.4 (1) pwm output basic operation . 2. n = 0, 1 chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 202 (2) operation with cr5n changed figure 7-15. timing of operation with cr5n changed (a) cr5n value is changed from n to m before clock rising edge of ffh value is transferred to cr5n at overflow immediately after change. count clock tm5n cr5n tce5n inttm5n to5n <1> cr5n change (n m) n n + 1 n + 2 ffh 00h 01h m m + 1 m + 2 ffh 00h 01h 02h m m + 1 m + 2 n 02h m h <2> t (b) cr5n value is changed from n to m after clock rising edge of ffh value is transferred to cr5n at second overflow. count clock tm5n cr5n tce5n inttm5n to5n n n + 1 n + 2 ffh 00h 01h n n + 1 n + 2 ffh 00h 01h 02h n 02h n h m m m + 1 m + 2 <1> cr5n change (n m) <2> t caution when reading from cr5n betw een <1> and <2> in figure 7-15, the value read differs from the actual value (read value: m, actual value of cr5n: n). chapter 7 8-bit timer/event counters 50 and 51 preliminary user?s manual u17473ej1v0ud 203 7.5 cautions for 8-bit ti mer/event counters 50 and 51 (1) timer start error an error of up to one clock may occur in the time requir ed for a match signal to be generated after timer start. this is because 8-bit timer counters 50 and 51 (tm50, tm 51) are started asynchronous ly to the count clock. figure 7-16. 8-bit timer counter 5n start timing count clock tm5n count value 00h 01h 02h 03h 04h timer start remark n = 0, 1 preliminary user?s manual u17473ej1v0ud 204 chapter 8 8-bit timers h0 and h1 8.1 functions of 8-bit timers h0 and h1 8-bit timers h0 and h1 have the following functions. ? interval timer ? pwm output mode ? square-wave output ? carrier generator mode (8-bit timer h1 only) 8.2 configuration of 8-bit timers h0 and h1 8-bit timers h0 and h1 include the following hardware. table 8-1. configuration of 8-bit timers h0 and h1 item configuration timer register 8-bit timer counter hn registers 8-bit timer h compare register 0n (cmp0n) 8-bit timer h compare register 1n (cmp1n) timer output tohn control registers 8-bit timer h mode register n (tmhmdn) 8-bit timer h carrier control register 1 (tmcyc1) note port mode register 1 (pm1) port register 1 (p1) note 8-bit timer h1 only remark n = 0, 1 figures 8-1 and 8-2 show the block diagrams. chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 205 figure 8-1. block diag ram of 8-bit timer h0 tmhe0 cks02 cks01 cks00 tmmd01 tmmd00 tolev0 toen0 toh0/p15 inttmh0 f prs f prs /2 f prs /2 2 f prs /2 6 f prs /2 10 1 0 f/f r 3 2 pm15 match internal bus 8-bit timer h mode register 0 (tmhmd0) 8-bit timer h compare register 10 (cmp10) decoder selector interrupt generator output controller level inversion pwm mode signal timer h enable signal clear 8-bit timer h compare register 00 (cmp00) output latch (p15) 8-bit timer/ event counter 50 output selector 8-bit timer counter h0 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 206 figure 8-2. block diag ram of 8-bit timer h1 match internal bus tmhe1 cks12 cks11 cks10 tmmd11 tmmd10 tolev1 toen1 8-bit timer h compare register 1 1 (cmp11) decoder toh1/ intp5/ p16 8-bit timer h carrier control register 1 (tmcyc1) inttmh1 inttm51 selector f prs f prs /2 2 f prs /2 4 f prs /2 6 f prs /2 12 f rl f rl /2 7 f rl /2 9 interrupt generator output controller level inversion pm16 output latch (p16) 1 0 f/f r pwm mode signal carrier generator mode signal timer h enable signal 3 2 8-bit timer h compare register 0 1 (cmp01) 8-bit timer counter h1 clear rmc1 nrzb1 nrz1 reload/ interrupt control 8-bit timer h mode register 1 (tmhmd1) selector chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 207 (1) 8-bit timer h compar e register 0n (cmp0n) this register can be read or written by an 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 8-3. format of 8-bit time r h compare register 0n (cmp0n) symbol cmp0n (n = 0, 1) address: ff18h (cmp00), ff1ah (cmp01) after reset: 00h r/w 7 6 5 4 32 1 0 caution cmp0n cannot be rewritte n during timer count operation. (2) 8-bit timer h compar e register 1n (cmp1n) this register can be read or written by an 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 8-4. format of 8-bit time r h compare register 1n (cmp1n) symbol cmp1n (n = 0, 1) address: ff19h (cmp10), ff1bh (cmp11) after reset: 00h r/w 7 6 5 4 32 1 0 cmp1n can be rewritten during timer count operation. an interrupt request signal (inttmhn) is generated if th e timer count values and cmp1n match after setting cmp1n in carrier generator mode. the ti mer count value is cleared at the same time. if the cmp1n value is rewritten during timer operation, transferring is perfo rmed at the timing at whic h the count value and cmp1n value match. if the transfer timing and writing from cpu to cmp 1n conflict, transfer is not performed. caution in the pwm output mode and carrier genera tor mode, be sure to set cmp1n when starting the timer count operation (tmhen = 1) after the ti mer count operation was stopped (tmhen = 0) (be sure to set again even if se tting the same value to cmp1n). remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 208 8.3 registers controlling 8-bit timers h0 and h1 the following four registers are used to control 8-bit timers h0 and h1. ? 8-bit timer h mode register n (tmhmdn) ? 8-bit timer h carrier control register 1 (tmcyc1) note ? port mode register 1 (pm1) ? port register 1 (p1) note 8-bit timer h1 only (1) 8-bit timer h mode register n (tmhmdn) this register controls the mode of timer h. this register can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 209 figure 8-5. format of 8-bit time r h mode register 0 (tmhmd0) tmhe0 stops timer count operation (counter is cleared to 0) enables timer count operation (count operation started by inputting clock) tmhe0 0 1 timer operation enable tmhmd0 cks02 cks01 cks00 tmmd01 tmmd00 tolev0 toen0 address: ff69h after reset: 00h r/w f prs f prs /2 f prs /2 2 f prs /2 6 f prs /2 10 tm50 output note setting prohibited cks02 0 0 0 0 1 1 cks01 0 0 1 1 0 0 cks00 0 1 0 1 0 1 f prs = 2 mhz 2 mhz 1 mhz 500 khz 31.25 khz 1.95 khz count clock selection other than above interval timer mode pwm output mode setting prohibited tmmd01 0 1 tmmd00 0 0 timer operation mode low level high level tolev0 0 1 timer output level control (in default mode) disables output enables output toen0 0 1 timer output control other than above <7> 6 5 4 3 2 <1> <0> f prs = 5 mhz 5 mhz 2.5 mhz 1.25 mhz 78.13 khz 4.88 khz f prs = 10 mhz 10 mhz 5 mhz 2.5 mhz 156.25 khz 9.77 khz f prs = 20 mhz 20 mhz 10 mhz 5 mhz 312.5 khz 19.54 khz note note the following points when select ing the tm50 output as the count clock. ? pwm mode (tmc506 = 1) start the operation of 8-bit timer/ event counter 50 first and then set t he count clock to make the duty = 50%. ? mode in which the count clock is cleared and started upon a match of tm50 and cr50 (tmc506 = 0) start the operation of 8-bit timer/ event counter 50 first and then enable the timer f/f inversion operation (tmc501 = 1). it is not necessary to enable the to50 pin as a timer output pin in any mode. chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 210 cautions 1. when tmhe0 = 1, setting th e other bits of tmhmd0 is prohibited. 2. in the pwm output mode, be sure to set 8-bit timer h compare re gister 10 (cmp10) when starting the timer count operation (tmhe0 = 1) after the timer count operation was stopped (tmhe0 = 0) (be sure to set again even if setting the same value to cmp10). remarks 1. f prs : peripheral hardware clock oscillation frequency 2. tmc506: bit 6 of 8-bit timer mode control register 50 (tmc50) tmc501: bit 1 of tmc50 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 211 figure 8-6. format of 8-bit time r h mode register 1 (tmhmd1) tmhe1 stops timer count operation (counter is cleared to 0) enables timer count operation (count operation started by inputting clock) tmhe1 0 1 timer operation enable tmhmd1 cks12 cks11 cks10 tmmd11 tmmd10 tolev1 toen1 address: ff6ch after reset: 00h r/w interval timer mode carrier generator mode pwm output mode setting prohibited tmmd11 0 0 1 1 tmmd10 0 1 0 1 timer operation mode low level high level tolev1 0 1 timer output level control (in default mode) disables output enables output toen1 0 1 timer output control <7> 6 5 4 3 2 <1> <0> f prs f prs /2 2 f prs /2 4 f prs /2 6 f prs /2 12 f rl /2 7 f rl /2 9 f rl cks12 0 0 0 0 1 1 1 1 cks11 0 0 1 1 0 0 1 1 cks10 0 1 0 1 0 1 0 1 f prs = 2 mhz 2 mhz 500 khz 125 khz 31.25 khz 0.49 khz 1.88 khz (typ.) 0.47 khz (typ.) 240 khz (typ.) count clock selection f prs = 5 mhz 5 mhz 1.25 mhz 312.5 khz 78.13 khz 1.22 khz f prs = 10 mhz 10 mhz 2.5 mhz 625 khz 156.25 khz 2.44 khz f prs = 20 mhz 20 mhz 5 mhz 1.25 mhz 312.5 khz 4.88 khz cautions 1. when tmhe1 = 1, setting th e other bits of tmhmd1 is prohibited. 2. in the pwm output mode and carrier genera tor mode, be sure to set 8-bit timer h compare register 11 (cmp11) when star ting the timer count operation (tmh e1 = 1) after the timer count operation was stopped (tmhe1 = 0) (be sure to set again even if setting the same value to cmp11). 3. when the carrier generator mode is used, set so that the count clock frequency of tmh1 becomes more than 6 times the count clock frequency of tm51. chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 212 remarks 1. f prs : peripheral hardware clock oscillation frequency 2. f rl : low-speed ring-osc clock oscillation frequency (2) 8-bit timer h carrier control register 1 (tmcyc1) this register controls the remote control output and carrier pulse output status of 8-bit timer h1. this register can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 8-7. format of 8-bit timer h carrier control register 1 (tmcyc1) 0 tmcyc1 0 0 0 0 rmc1 nrzb1 nrz1 address: ff6dh after reset: 00h r/w note low-level output high-level output low-level output carrier pulse output rmc1 0 0 1 1 nrzb1 0 1 0 1 remote control output carrier output disabled status (low-level status) carrier output enabled status (rmc1 = 1: carrier pulse output, rmc1 = 0: high-level status) nrz1 0 1 carrier pulse output status flag <0> note bit 0 is read-only. (3) port mode register 1 (pm1) this register sets port 1 input/output in 1-bit units. when using the p15/toh0 and p16/toh1/intp5 pins for timer output, clear pm15 and pm16 and the output latches of p15 and p16 to 0. pm1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to ffh. figure 8-8. format of port mode register 1 (pm1) address: ff21h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm1 pm17 pm16 pm15 pm14 pm13 pm12 pm11 pm10 pm1n p1n pin i/o mode selection (n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 213 8.4 operation of 8-bit timers h0 and h1 8.4.1 operation as inter val timer/square-wave output when 8-bit timer counter hn and compare register 0n (cmp0n) match, an interrupt request signal (inttmhn) is generated and 8-bit timer counter hn is cleared to 00h. compare register 1n (cmp1n) is not used in interval time r mode. since a match of 8-bit timer counter hn and the cmp1n register is not detected even if the cmp1n register is set, timer output is not affected. by setting bit 0 (toenn) of timer h mode register n (tmh mdn) to 1, a square wave of any frequency (duty = 50%) is output from tohn. (1) usage generates the inttmhn signal repeatedly at the same interval. <1> set each register. figure 8-9. register setting during inte rval timer/square-wave output operation (i) setting timer h mode register n (tmhmdn) 0 0/1 0/1 0/1 0 0 0/1 0/1 tmmdn0 tolevn toenn cksn1 cksn2 tmhen tmhmdn cksn0 tmmdn1 timer output setting timer output level inversion setting interval timer mode setting count clock (f cnt ) selection count operation stopped (ii) cmp0n register setting ? compare value (n) <2> count operation starts when tmhen = 1. <3> when the values of 8-bit timer counter hn and the cmp0n register match, the inttmhn signal is generated and 8-bit timer counter hn is cleared to 00h. interval time = (n +1)/f cnt <4> subsequently, the inttmhn signal is generated at t he same interval. to stop the count operation, clear tmhen to 0. remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 214 (2) timing chart the timing of the interval timer/square- wave output operation is shown below. figure 8-10. timing of interval time r/square-wave output operation (1/2) (a) basic operation 00h count clock count start 8-bit timer counter hn cmp0n tmhen inttmhn tohn 01h n clear interval time clear n 00h 01h n 00h 01h 00h <2> level inversion, match interrupt occurrence, 8-bit timer counter hn clear <2> level inversion, match interrupt occurrence, 8-bit timer counter hn clear <3> <1> <1> the count operation is enabled by setting the tmhen bi t to 1. the count clock starts counting no more than 1 clock after the operation is enabled. <2> when the values of 8-bit timer count er hn and the cmp0n register match, the value of 8-bit timer counter hn is cleared, the tohn output level is in verted, and the inttmhn signal is output. <3> the inttmhn signal and tohn output become inactive by clearing the tmhen bit to 0 during timer hn operation. if these are inactive from the first, the level is retained. remark n = 0, 1 n = 01h to feh chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 215 figure 8-10. timing of interval time r/square-wave output operation (2/2) (b) operation when cmp0n = ffh 00h count clock count start 8-bit timer counter hn cmp0n tmhen inttmhn tohn 01h feh clear clear ffh 00h feh ffh 00h ffh interval time (c) operation when cmp0n = 00h count clock count start 8-bit timer counter hn cmp0n tmhen inttmhn tohn 00h 00h interval time remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 216 8.4.2 operation as pwm output mode in pwm output mode, a pulse with an arbi trary duty and arbitrary cycle can be output. 8-bit timer compare register 0n (cmp0n) controls the cycle of timer output (tohn). re writing the cmp0n register during timer operation is prohibited. 8-bit timer compare register 1n (cmp1n) controls the dut y of timer output (tohn). re writing the cmp1n register during timer operation is possible. the operation in pwm output mode is as follows. tohn output becomes active and 8-bit timer counter hn is cleared to 0 when 8-bit timer counter hn and the cmp0n register match after the timer count is started. tohn output becomes inactive when 8-bit timer counter hn and the cmp1n register match. (1) usage in pwm output mode, a pulse for which an arbitr ary duty and arbitrary cycle can be set is output. <1> set each register. figure 8-11. register setting in pwm output mode (i) setting timer h mode register n (tmhmdn) 0 0/1 0/1 0/1 1 0 0/1 1 tmmdn0 tolevn toenn cksn1 cksn2 tmhen tmhmdn cksn0 tmmdn1 timer output enabled timer output level inversion setting pwm output mode selection count clock (f cnt ) selection count operation stopped (ii) setting cmp0n register ? compare value (n): cycle setting (iii) setting cmp1n register ? compare value (m): duty setting remarks 1. n = 0, 1 2. 00h cmp1n (m) < cmp0n (n) ffh chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 217 <2> the count operation starts when tmhen = 1. <3> the cmp0n register is the compare register that is to be compared first after counter operation is enabled. when the values of 8-bit timer counter hn and the cmp0 n register match, 8-bit timer counter hn is cleared, an interrupt request signal (inttmhn) is generated, and tohn output becomes active. at the same time, the compare register to be compared with 8-bit timer c ounter hn is changed from t he cmp0n register to the cmp1n register. <4> when 8-bit timer counter hn and the cmp1n regist er match, tohn output becomes inactive and the compare register to be compared with 8-bit timer coun ter hn is changed from the cmp1n register to the cmp0n register. at this time, 8-bit timer counter hn is not cleared and the inttmhn signal is not generated. <5> by performing procedures <3> and <4> repeatedl y, a pulse with an arbitrary duty can be obtained. <6> to stop the count operation, set tmhen = 0. if the setting value of the cmp0n register is n, the setting value of the cmp1n register is m, and the count clock frequency is f cnt , the pwm pulse output cycle and duty are as follows. pwm pulse output cycle = (n + 1)/f cnt duty = active width : total widt h of pwm = (m + 1) : (n + 1) cautions 1. in pwm output mode , three operation clocks (signal sel ected using the cksn2 to cksn0 bits of the tmhmdn register) are required to transfer the cmp1n register value after rewriting the register. 2. be sure to set the cmp1n register when starting the timer count operation (tmhen = 1) after the timer count operation was stopped (tmhen = 0) (be sure to set again even if setting the same value to the cmp1n register). remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 218 (2) timing chart the operation timing in pwm output mode is shown below. caution make sure that the cmp1n register setting value (m) and cmp0 n register setting value (n) are within the following range. 00h cmp1n (m) < cmp0n (n) ffh figure 8-12. operation timing in pwm output mode (1/4) (a) basic operation count clock 8-bit timer counter hn cmp0n tmhen inttmhn tohn (tolevn = 0) tohn (tolevn = 1) 00h 01h a5h 00h 01h 02h a5h 00h a5h 00h 01h 02h cmp1n a5h 01h <1> <2> <3> <4> <1> the count operation is enabled by setting the tmhen bit to 1. start 8-bit timer counter hn by masking one count clock to count up. at this time, tohn output remains inactive (when tolevn = 0). <2> when the values of 8-bit timer counter hn and the cm p0n register match, the tohn output level is inverted, the value of 8-bit timer counter hn is cleared, and the inttmhn signal is output. <3> when the values of 8-bit timer counter hn and the cm p1n register match, the le vel of the tohn output is returned. at this time, the 8-bit timer counter val ue is not cleared and the inttmhn signal is not output. <4> clearing the tmhen bit to 0 during timer hn operati on makes the inttmhn signal and tohn output inactive. remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 219 figure 8-12. operation timing in pwm output mode (2/4) (b) operation when cmp0n = ffh, cmp1n = 00h count clock 8-bit timer counter hn cmp0n tmhen inttmhn tohn (tolevn = 0) 00h 01h ffh 00h 01h 02h ffh 00h ffh 00h 01h 02h cmp1n ffh 00h (c) operation when cmp0n = ffh, cmp1n = feh count clock 8-bit timer counter hn cmp0n tmhen inttmhn tohn (tolevn = 0) 00h 01h feh ffh 00h 01h feh ffh 00h 01h feh ffh 00h cmp1n ffh feh remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 220 figure 8-12. operation timing in pwm output mode (3/4) (d) operation when cmp0n = 01h, cmp1n = 00h count clock 8-bit timer counter hn cmp0n tmhen inttmhn tohn (tolevn = 0) 01h 00h 01h 00h 01h 00h 00h 01h 00h 01h cmp1n 00h remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 221 figure 8-12. operation timing in pwm output mode (4/4) (e) operation by changi ng cmp1n (cmp1n = 01h 03h, cmp0n = a5h) count clock 8-bit timer counter hn cmp0n tmhen inttmhn tohn (tolevn = 0) 00h 01h 02h a5h 00h 01h 02h 03h a5h 00h 01h 02h 03h a5h 00h cmp1n 01h a5h 03h 01h (03h) <1> <3> <4> <2> <2>' <5> <6> <1> the count operation is enabled by setting tmhen = 1. start 8-bit timer counter hn by masking one count clock to count up. at this time, the tohn output remains inactive (when tolevn = 0). <2> the cmp1n register value can be changed during timer counter operation. this operation is asynchronous to the count clock. <3> when the values of 8-bit timer count er hn and the cmp0n register match, the value of 8-bit timer counter hn is cleared, the tohn output becomes active, and the inttmhn signal is output. <4> if the cmp1n register value is changed, the value is latched and not transferred to the register. when the values of 8-bit timer counter hn and the cmp1n register before the change match, the value is transferred to the cmp1n register and the cmp1n re gister value is changed (<2>?). however, three count clocks or more are required fr om when the cmp1n register value is changed to when the value is transferred to the register. if a match signal is generated within thr ee count clocks, the changed value cannot be transferred to the register. <5> when the values of 8-bit timer counter hn and the cm p1n register after the change match, the tohn output becomes inactive. 8-bit timer counter hn is no t cleared and the inttmhn signal is not generated. <6> clearing the tmhen bit to 0 during timer hn operati on makes the inttmhn signal and tohn output inactive. remark n = 0, 1 chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 222 8.4.3 carrier generator mode operation (8-bit timer h1 only) the carrier clock generated by 8-bit timer h1 is output in the cycle set by 8-bit timer/event counter 51. in carrier generator mode, the output of the 8-bit timer h1 carrier pulse is controlled by 8-bit timer/event counter 51, and the carrier pulse is out put from the toh1 output. (1) carrier generation in carrier generator mode, 8-bit timer h compare regist er 01 (cmp01) generates a low-level width carrier pulse waveform and 8-bit timer h compare register 11 (cmp11) generates a high-level width carrier pulse waveform. rewriting the cmp11 register during 8-bit timer h1 operat ion is possible but rewriti ng the cmp01 register is prohibited. (2) carrier output control carrier output is controlled by the interrupt request sig nal (inttm51) of 8-bit timer/event counter 51 and the nrzb1 and rmc1 bits of the 8-bit timer h carrier co ntrol register (tmcyc1). the relationship between the outputs is shown below. rmc1 bit nrzb1 bit output 0 0 low-level output 0 1 high-level output 1 0 low-level output 1 1 carrier pulse output chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 223 to control the carrier pulse output during a count operation, the nrz1 and nrzb1 bits of the tmcyc1 register have a master and slave bit configuratio n. the nrz1 bit is read-only but t he nrzb1 bit can be read and written. the inttm51 signal is synchronized with the 8-bit timer h1 count clock and output as the inttm5h1 signal. the inttm5h1 signal becomes the data transfer signal of the nrz1 bit, and the nrzb1 bit value is transferred to the nrz1 bit. the timing for transfer from the nrzb1 bit to the nrz1 bit is as shown below. figure 8-13. transfer timing 8-bit timer h1 count clock tmhe1 inttm51 inttm5h1 nrz1 nrzb1 rmc1 1 1 1 0 00 <1> <2> <1> the inttm51 signal is synchronized with the count cl ock of 8-bit timer h1 and is output as the inttm5h1 signal. <2> the value of the nrzb1 bit is tr ansferred to the nrz1 bit at the second clock from the rising edge of the inttm5h1 signal. cautions 1. do not rewrite the nrzb1 bit again until at least the second clock afte r it has been rewritten, or else the transfer from the nrzb1 bi t to the nrz1 bit is not guaranteed. 2. when 8-bit timer/event counter 51 is used in the carrier generator mode, an interrupt is generated at the timing of <1>. when 8-bit timer/event counter 51 is used in a mode other than the carrier generator mode, the timi ng of the interrupt generation differs. chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 224 (3) usage outputs an arbitrary carrier clock from the toh1 pin. <1> set each register. figure 8-14. register setting in carrier generator mode (i) setting 8-bit timer h m ode register 1 (tmhmd1) 0 0/1 0/1 0/1 0 timer output enabled timer output level inversion setting carrier generator mode selection count clock (f cnt ) selection count operation stopped 1 0/1 1 tmmd10 tolev1 toen1 cks11 cks12 tmhe1 tmhmd1 cks10 tmmd11 (ii) cmp01 register setting ? compare value (iii) cmp11 register setting ? compare value (iv) tmcyc1 register setting ? rmc1 = 1 ... remote control output enable bit ? nrzb1 = 0/1 ... carrier output enable bit (v) tcl51 and tmc51 register setting ? see 7.3 registers controlling 8-bit timer/event counters 50 and 51 . <2> when tmhe1 = 1, 8-bit timer h1 starts counting. <3> when tce51 of 8-bit timer mode control register 51 (tmc 51) is set to 1, 8-bit timer/event counter 51 starts counting. <4> after the count operation is enabled, the first com pare register to be compared is the cmp01 register. when the count value of 8-bit time r counter h1 and the cmp 01 register value match, the inttmh1 signal is generated, 8-bit timer counter h1 is cleared, and at the same time, the compare register to be compared with 8-bit timer counter h1 is switched from the cmp01 register to the cmp11 register. <5> when the count value of 8-bit ti mer counter h1 and the cm p11 register value match, the inttmh1 signal is generated, 8-bit timer counter h1 is cleared, and at the same time, the compare register to be compared with 8-bit timer counter h1 is switched from the cmp11 register to the cmp01 register. <6> by performing procedures <4> and <5> r epeatedly, a carrier clock is generated. <7> the inttm51 signal is synchronized with count clock of 8-bit timer h1 and output as the inttm5h1 signal. the inttm5h1 signal becomes the data transfer signal for the nrzb1 bit, and the nrzb1 bit value is transferred to the nrz1 bit. <8> when the nrz1 bit is high level, a carri er clock is output from the toh1 pin. <9> by performing the procedures above, an arbitrary carrier clock is obtained. to stop the count operation, clear tmhe1 to 0. chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 225 if the setting value of the cmp01 register is n, the setting value of the cmp 11 register is m, and the count clock frequency is f cnt , the carrier clock output cycle and duty are as follows. carrier clock output cycle = (n + m + 2)/f cnt duty = high-level width : carrier clock ou tput width = ( m + 1) : (n + m + 2) cautions 1. be sure to set the cm p11 register when starting the time r count operation (tmhe1 = 1) after the timer count operati on was stopped (tmhe1 = 0) (be sure to set again even if setting the same value to the cmp11 register). 2. set so that the count clock frequency of tmh1 becomes more than 6 times the count clock frequency of tm51. (4) timing chart the carrier output control timing is shown below. cautions 1. set the values of the cmp01 and cmp11 registers in a range of 01h to ffh. 2. in the carrier generator mode, three ope rating clocks (signal selected by cks12 to cks10 bits of tmhmd1 register) or more are requi red from when the cmp11 register value is changed to when the value is transferred to the register. 3. be sure to set the rmc1 bit be fore the count operation is started. chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 226 figure 8-15. carrier generator mode operation timing (1/3) (a) operation when cmp01 = n, cmp11 = n 00h n 00h n 00h n 00h n 00h n 00h n n n 0 0 1 1 0 0 1 1 0 0 00h 01h l 00h 01h l 00h 01h l 00h 01h 00h 01h l l cmpn0 cmpn1 tmhen inttmhn carrier clock 8-bit timer 5n count clock tm5n count value cr5n tce5n tohn inttm5n nrzbn nrzn carrier clock inttm5hn 8-bit timer hn count clock 8-bit timer counter hn count value <1> <2> <3> <4> <5> <6> <7> <1> when tmhe1 = 0 and tce51 = 0, 8-bit timer counter h1 operation is stopped. <2> when tmhe1 = 1 is set, 8-bit timer counter h1 starts a count operation. at that ti me, the carrier clock is held at the inactive level. <3> when the count value of 8-bit timer counter h1 matc hes the cmp01 register val ue, the first inttmh1 signal is generated, the carrier clock signal is inverted, and the compare register to be compared with 8-bit timer counter h1 is switched from the cmp01 register to the cmp11 register. 8-bit timer counter h1 is cleared to 00h. <4> when the count value of 8-bit timer counter h1 matc hes the cmp11 register value, the inttmh1 signal is generated, the carrier clock signal is inverted, and t he compare register to be compared with 8-bit timer counter h1 is switched from the cmp11 register to the cmp01 register. 8-bit timer counter h1 is cleared to 00h. by performing procedures <3> and <4> repeatedly, a carrier clock with duty fixed to 50% is generated. <5> when the inttm51 signal is generated, it is synchro nized with 8-bit timer h1 count clock and output as the inttm5h1 signal. <6> the inttm5h1 signal becomes the data transfer si gnal for the nrzb1 bit, and the nrzb1 bit value is transferred to the nrz1 bit. <7> when nrz1 = 0 is set, the toh1 output becomes low level. chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 227 figure 8-15. carrier generator mode operation timing (2/3) (b) operation when cmp01 = n, cmp11 = m n l 00h n 00h 01h m 00h n 00h 01h m 00h 00h n m 0 0 1 1 0 0 1 1 0 0 00h 01h l 00h 01h l 00h 01h l 00h 01h 00h 01h l cmpn0 cmpn1 tmhen inttmhn carrier clock 8-bit timer 5n count clock tm5n count value cr5n tce5n tohn inttm5n nrzbn nrzn carrier clock inttm5hn 8-bit timer hn count clock 8-bit timer counter hn count value <1> <2> <3> <4> <5> <6> <7> <1> when tmhe1 = 0 and tce51 = 0, 8-bit timer counter h1 operation is stopped. <2> when tmhe1 = 1 is set, 8-bit timer counter h1 starts a count operation. at that ti me, the carrier clock is held at the inactive level. <3> when the count value of 8-bit timer counter h1 matc hes the cmp01 register val ue, the first inttmh1 signal is generated, the carrier clock signal is inverted, and the compare register to be compared with 8-bit timer counter h1 is switched from the cmp01 register to the cmp11 register. 8-bit timer counter h1 is cleared to 00h. <4> when the count value of 8-bit timer counter h1 matc hes the cmp11 register value, the inttmh1 signal is generated, the carrier clock signal is inverted, and t he compare register to be compared with 8-bit timer counter h1 is switched from the cmp11 register to the cmp01 register. 8-bit timer counter h1 is cleared to 00h. by performing procedures <3> and <4> repeatedly, a carrier clock with duty fixed to other than 50% is generated. <5> when the inttm51 signal is generated, it is synchro nized with 8-bit timer h1 count clock and output as the inttm5h1 signal. <6> a carrier signal is output at the first rising edge of the carrier clock if nrz1 is set to 1. <7> when nrz1 = 0, the toh1 output is held at the high level and is not changed to low level while the carrier clock is high level (from <6> and <7>, the high-level width of the carrier clock waveform is guaranteed). chapter 8 8-bit timers h0 and h1 preliminary user?s manual u17473ej1v0ud 228 figure 8-15. carrier generator mode operation timing (3/3) (c) operation when cmp11 is changed 8-bit timer h1 count clock cmp01 tmhe1 inttmh1 carrier clock 00h 01h n 00h 01h 01h m 00h n 00h l 00h <1> <3>? <4> <3> <2> cmp11 <5> m n l m (l) 8-bit timer counter h1 count value <1> when tmhe1 = 1 is set, 8-bit timer h1 starts a count oper ation. at that time, the carrier clock is held at the inactive level. <2> when the count value of 8-bit timer counter h1 matches the cmp01 register value, 8-bit timer counter h1 is cleared and the inttmh1 signal is output. <3> the cmp11 register can be rewritten during 8-bit timer h1 operation, however, the changed value (l) is latched. the cmp11 register is changed when the co unt value of 8-bit timer counter h1 and the cmp11 register value before t he change (m) match (<3>?). <4> when the count value of 8-bit timer counter h1 and the cmp11 register value before the change (m) match, the inttmh1 signal is output, the carrier signal is inve rted, and 8-bit timer counter h1 is cleared to 00h. <5> the timing at which the count value of 8-bit timer counter h1 and the cmp11 regi ster value match again is indicated by the value after the change (l). preliminary user?s manual u17473ej1v0ud 229 chapter 9 watch timer 9.1 functions of watch timer the watch timer has the following functions. ? watch timer ? interval timer the watch timer and the interval timer can be used simultaneously. figure 9-1 shows the watch timer block diagram. figure 9-1. block diagram of watch timer f prs /2 7 f w /2 4 f w /2 5 f w /2 6 f w /2 7 f w /2 8 f w /2 10 f w /2 11 f w /2 9 f sub intwt intwti wtm0 wtm1 wtm2 wtm3 wtm4 wtm5 wtm6 wtm7 f w clear 11-bit prescaler clear 5-bit counter watch timer operation mode register (wtm) internal bus selector selector selector selector f wx /2 4 f wx /2 5 f wx remark f prs : peripheral hardware clock oscillation frequency f sub : subsystem clock oscillation frequency f w : watch timer clock frequency (f prs /2 7 or f sub ) f wx : f w or f w /2 9 chapter 9 watch timer preliminary user?s manual u17473ej1v0ud 230 (1) watch timer when the peripheral hardware clock or subsystem clock is used, interrupt reques ts (intwt) are generated at preset intervals. table 9-1. watch timer interrupt time interrupt time when operated at f sub = 32.768 khz when operated at f prs = 2 mhz when operated at f prs = 5 mhz when operated at f prs = 10 mhz when operated at f prs = 20 mhz 2 4 /f w 488 s 1.02 ms 410 s 205 s 102 s 2 5 /f w 977 s 2.05 ms 819 s 410 s 205 s 2 13 /f w 0.25 s 0.52 s 0.210 s 0.105 s 520 s 2 14 /f w 0.5 s 1.05 s 0.419 s 0. 210 s 0.105 s remark f prs : peripheral hardware clock oscillation frequency f sub : subsystem clock oscillation frequency f w : watch timer clock frequency (f prs /2 7 or f sub ) (2) interval timer interrupt requests (intwti) are gen erated at preset time intervals. table 9-2. interval timer interval time interval time when operated at f sub = 32.768 khz when operated at f prs = 2 mhz when operated at f prs = 5 mhz when operated at f prs = 10 mhz when operated at f prs = 20 mhz 2 4 /f w 488 s 1.02 ms 410 s 205 s 102 s 2 5 /f w 977 s 2.05 ms 820 s 410 s 205 s 2 6 /f w 1.95 ms 4.10 ms 1.64 ms 820 s 410 s 2 7 /f w 3.91 ms 8.20 ms 3.28 ms 1.64 ms 820 s 2 8 /f w 7.81 ms 16.4 ms 6.55 ms 3.28 ms 1.64 ms 2 9 /f w 15.6 ms 32.8 ms 13.1 ms 6.55 ms 3.28 ms 2 10 /f w 31.3 ms 65.5 ms 26.2 ms 13.1 ms 6.55 ms 2 11 /f w 62.5 ms 131.1 ms 52.4 ms 26.2 ms 13.1 ms remark f prs : peripheral hardware clock oscillation frequency f sub : subsystem clock oscillation frequency f w : watch timer clock frequency (f prs /2 7 or f sub ) 9.2 configuration of watch timer the watch timer includes the following hardware. table 9-3. watch timer configuration item configuration counter 5 bits 1 prescaler 11 bits 1 control register watch timer operation mode register (wtm) chapter 9 watch timer preliminary user?s manual u17473ej1v0ud 231 9.3 register controlling watch timer the watch timer is controlled by the wa tch timer operation mode register (wtm). ? watch timer operation mode register (wtm) this register sets the watch timer count clock, enabl es/disables operation, prescaler interval time, and 5-bit counter operation control. wtm is set by a 1-bit or 8-bit memory manipulation instruction. reset input clears wtm to 00h. figure 9-2. format of watch timer operation mode register (wtm) address: ff6fh after reset: 00h r/w symbol 7 6 5 4 3 2 <1> <0> wtm wtm7 wtm6 wtm5 wtm4 wtm3 wtm2 wtm1 wtm0 watch timer count clock selection (f w ) wtm7 f sub = 32.768 khz f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz 0 f prs /2 7 ? 15.625 khz 39.062 khz 78.125 khz 156.25 khz 1 f sub 32.768 khz ? wtm6 wtm5 wtm4 prescaler interval time selection 0 0 0 2 4 /f w 0 0 1 2 5 /f w 0 1 0 2 6 /f w 0 1 1 2 7 /f w 1 0 0 2 8 /f w 1 0 1 2 9 /f w 1 1 0 2 10 /f w 1 1 1 2 11 /f w wtm3 wtm2 interrupt time selection 0 0 2 14 /f w 0 1 2 13 /f w 1 0 2 5 /f w 1 1 2 4 /f w wtm1 5-bit counter operation control 0 clear after operation stop 1 start wtm0 watch timer operation enable 0 operation stop (clear both prescaler and timer) 1 operation enable chapter 9 watch timer preliminary user?s manual u17473ej1v0ud 232 caution do not change the count clock and interval ti me (by setting bits 4 to 7 (wtm4 to wtm7) of wtm) during watch timer operation. remarks 1. f w : watch timer clock frequency (f prs /2 7 or f sub ) 2. f prs : peripheral hardware clock oscillation frequency 3. f sub : subsystem clock oscillation frequency chapter 9 watch timer preliminary user?s manual u17473ej1v0ud 233 9.4 watch timer operations 9.4.1 watch timer operation the watch timer generates an interrupt request (intwt) at a specific time interval by using the peripheral hardware clock or subsystem clock. when bit 0 (wtm0) and bit 1 (wtm1) of the watch timer oper ation mode register (wtm) are set to 1, the count operation starts. when these bits are cleared to 0, t he 5-bit counter is cleared an d the count operation stops. when the interval timer is simultaneously operated, zero -second start can be achieved only for the watch timer by clearing wtm1 to 0. in this case, however, the 11-bit prescaler is not cleared. therefore, an error up to 2 9 1/f w seconds occurs in the first overfl ow (intwt) after zero-second start. the interrupt request is generated at the following time intervals. table 9-4. watch timer interrupt time wtm3 wtm2 interrupt time selection when operated at f sub = 32.768 khz (wtm7 = 1) when operated at f prs = 2 mhz (wtm7 = 0) when operated at f prs = 5 mhz (wtm7 = 0) when operated at f prs = 10 mhz (wtm7 = 0) when operated at f prs = 20 mhz (wtm7 = 0) 0 0 2 14 /f w 0.5 s 1.05 s 0.419 s 0. 210 s 0.105 s 0 1 2 13 /f w 0.25 s 0.52 s 0.210 s 0.105 s 520 s 1 0 2 5 /f w 977 s 2.05 ms 819 s 410 s 205 s 1 1 2 4 /f w 488 s 1.02 ms 410 s 205 s 102 s remarks 1. f w : watch timer clock frequency (f prs /2 7 or f sub ) 2. f prs : peripheral hardware clock oscillation frequency 3. f sub : subsystem clock oscillation frequency chapter 9 watch timer preliminary user?s manual u17473ej1v0ud 234 9.4.2 interval timer operation the watch timer operates as interval timer which generates in terrupt requests (intwti) r epeatedly at an interval of the preset count value. the interval time can be selected with bits 4 to 6 (wtm 4 to wtm6) of the watch timer operation mode register (wtm). when bit 0 (wtm0) of the wtm is set to 1, the count operation starts. when this bit is set to 0, the count operation stops. table 9-5. interval timer interval time wtm6 wtm5 wtm4 interval time when operated at f sub = 32.768 khz (wtm7 = 1) when operated at f prs = 2 mhz (wtm7 = 0) when operated at f prs = 5 mhz (wtm7 = 0) when operated at f prs = 10 mhz (wtm7 = 0) when operated at f prs = 20 mhz (wtm7 = 0) 0 0 0 2 4 /f w 488 s 1.02 ms 410 s 205 s 102 s 0 0 1 2 5 /f w 977 s 2.05 ms 820 s 410 s 205 s 0 1 0 2 6 /f w 1.95 ms 4.10 ms 1.64 ms 820 s 410 s 0 1 1 2 7 /f w 3.91 ms 8.20 ms 3.28 ms 1.64 ms 820 s 1 0 0 2 8 /f w 7.81 ms 16.4 ms 6.55 ms 3.28 ms 1.64 ms 1 0 1 2 9 /f w 15.6 ms 32.8 ms 13.1 ms 6.55 ms 3.28 ms 1 1 0 2 10 /f w 31.3 ms 65.5 ms 26.2 ms 13.1 ms 6.55 ms 1 1 1 2 11 /f w 62.5 ms 131.1 ms 52.4 ms 26.2 ms 13.1 ms remarks 1. f w : watch timer clock frequency (f prs /2 7 or f sub ) 2. f prs : peripheral hardware clock oscillation frequency 3. f sub : subsystem clock oscillation frequency figure 9-3. operation timing of watch timer/interval timer 0h start overflow overflow 5-bit counter count clock watch timer interrupt intwt interval timer interrupt intwti interrupt time of watch timer (0.5 s) interval time (t) t interrupt time of watch timer (0.5 s) n t n t remark f w : watch timer clock frequency n: the number of times of interval timer operations figures in parentheses are for operation with f w = 32.768 khz (wtm7 = 1, wtm3, wtm2 = 0, 0) chapter 9 watch timer preliminary user?s manual u17473ej1v0ud 235 9.5 cautions for watch timer when operation of the watch timer and 5- bit counter is enabled by the watch timer mode control register (wtm) (by setting bits 0 (wtm0) and 1 (wtm1) of wtm to 1), the inte rval until the first interr upt request (intwt) is generated after the register is set does not exactly match the specif ication made with bits 2 and 3 (wtm2, wtm3) of wtm. subsequently, however, the intwt signal is generated at the specified intervals. figure 9-4. example of generation of watch timer inte rrupt request (intwt) (when interrupt period = 0.5 s) it takes 0.515625 seconds for the first intwt to be generated (2 9 1/32768 = 0.015625 s longer). intwt is then generated every 0.5 seconds. 0.5 s 0.5 s 0.515625 s wtm0, wtm1 intwt preliminary user?s manual u17473ej1v0ud 236 chapter 10 watchdog timer 10.1 functions of watchdog timer the watchdog timer operates on the low-speed ring-osc clock. the watchdog timer is used to detect an inadvertent program loop. if a program loop is detected, an internal reset signal is generated. program loop is detected in the following cases. ? if the watchdog timer counter overflows ? if a 1-bit manipulation instruction is execut ed on the watchdog timer enable register (wdte) ? if data other than ?ach? is written to wdte ? if data is written to wdte during a window close period ? if the cpu fetches an area not set by the ims and ixs regi sters (detection of invalid check while cpu hangs up) ? if the cpu accesses an area not set by the ims and ixs regi sters by executing a read/wr ite instruction (detection of abnormal access while cpu hangs up) when a reset occurs due to the watchdog timer, bit 4 (wdtrf) of the reset control flag register (resf) is set to 1. for details of resf, see chapter 22 reset function . chapter 10 watchdog timer preliminary user?s manual u17473ej1v0ud 237 10.2 configuration of watchdog timer the watchdog timer includes the following hardware. table 10-1. configuration of watchdog timer item configuration control register watchdog timer enable register (wdte) how the counter operation is controlled, overflow ti me, and window open period are set by the option byte. table 10-2. setting of op tion bytes and watchdog timer setting of watchdog timer option byte window open period bits 6 and 5 (window1, window0) controlling counter operation of watchdog timer bit 4 (wdton) overflow time of watchdog timer bits 3 to 1 (wdcs2 to wdcs0) remark for the option byte, see chapter 25 option byte . figure 10-1. block diag ram of watchdog timer f rl /2 clock input controller reset output controller internal reset signal internal bus selector 17-bit counter 2 10 /f rl to 2 17 /f rl watchdog timer enable register (wdte) clear, reset control wdton of option byte window1 and window0 of option byte count clear signal wdcs2 to wdcs0 of option byte overflow signal cpu access signal of option byte cpu access error detector window size determination signal chapter 10 watchdog timer preliminary user?s manual u17473ej1v0ud 238 10.3 register controlling watchdog timer the watchdog timer is controlled by the watchdog timer enable register (wdte). (1) watchdog timer enable register (wdte) writing ach to wdte clears the watchdog timer counter and starts counting again. this register can be set by an 8-bit memory manipulation instruction. reset input sets this register to 9ah or 1ah note . figure 10-2. format of watchdog timer enable register (wdte) 0 1 2 3 4 5 6 7 symbol wdte address: ff99h after reset: 9ah/1ah note r/w note the wdte reset value differs depending on the wd ton setting value of the option byte. to operate watchdog timer, set wdton to 1. wdton setting value wdte reset value 0 (watchdog timer count operation disabled) 1ah 1 (watchdog timer count operation enabled) 9ah cautions 1. if a value other than ach is written to wdte, an internal reset signal is generated. if the source clock to the watchdog timer is stopped, however, an internal reset signal is generated when the source clock to the watchdog timer resumes operation. 2. if a 1-bit memory manipulation instructio n is executed for wdte, an internal reset signal is generated. if the source clock to the wa tchdog timer is stopped, however, an internal reset signal is genera ted when the source clock to th e watchdog timer resumes operation. 3. the value read from wdte is 9ah/1ah (this differs fr om the written value (ach)). chapter 10 watchdog timer preliminary user?s manual u17473ej1v0ud 239 10.4 operation of watchdog timer 10.4.1 controlling operation of watchdog timer 1. when the watchdog timer is used, its oper ation is specified by the option byte. ? enable counting operation of the watchdog timer by setting bit 4 (wdton) of the option byte to 1 (the counter starts operating after a re set release) (for details, see chapter 25 ). wdton watchdog timer counter control 0 count operation disabled (counting stops after reset). 1 count operation enabled (counting starts after reset). ? set an overflow time by using bits 3 to 1 (wdcs 2 to wdcs0) of the opti on byte (for details, see 10.4.2 and chapter 25 ). ? set a window open period by using bits 6 and 5 (wi ndow1 and window0) of the option byte (for details, see 10.4.3 and chapter 25 ). 2. after a reset release, the watchdog timer starts counting. 3. by writing ?ach? to wdte after the watchdog timer starts counting and before the overflow time set by the option byte, the watchdog timer is cl eared and starts counting again. 4. after that, write wdte the second ti me or later after a reset release during the window open period. if wdte is written during a period other than the window open period, an internal reset signal is generated. 5. if the overflow time expires without ?ach? wri tten to wdte, an internal reset signal is generated. cautions 1. the first writing to wdte after a reset releas e clears the watchdog timer, if it is made before the overflow time regardless of the timing of the writing, and the watchdog timer starts counting again. 2. if the watchdog timer is cleared by writi ng ?ach? to wdte, the actual overflow time may be different from the overflow time set by the option byte by up to 2/f rl seconds. 3. the watchdog timer can be cleared immediately before the count value overflows (ffffh). 4. the operation of the watchdog timer in the halt and stop modes differs as follows depending on the set value of bit 0 (ringosc) of the option byte. ringosc = 0 (low-speed ring- osc can be stopped by software) ringosc = 1 (low-speed ring- osc cannot be stopped) in halt mode retains status before halt mode is set. in stop mode watchdog timer operation stops. retains status before stop mode is set. if ringosc = 0, the watchdog timer resum es counting after the halt or stop mode is released. at this time, the counter is not cleared (0) but re tains its present value. 5. the watchdog timer does not stop duri ng self-programming of th e flash memory and eeprom tm emulation. during processing, the interrupt acknowle dge time is delayed. set the overflow time and window size taki ng this delay into consideration. chapter 10 watchdog timer preliminary user?s manual u17473ej1v0ud 240 10.4.2 setting overflow time of watchdog timer set the overflow time of the watchdog timer by usin g bits 3 to 1 (wdcs2 to wdcs0) of the option byte. if an overflow occurs, an internal reset signal is generated. if ?ach? is written to wdte during the window open period before the overflow time, the present count is cleared and the watc hdog timer starts counting again. the following overflow time is set. table 10-3. setting of over flow time of watchdog timer wdcs2 wdcs1 wdcs0 overflow time of watchdog timer 0 0 0 2 10 /f rl (3.88 ms) 0 0 1 2 11 /f rl (7.76 ms) 0 1 0 2 12 /f rl (15.52 ms) 0 1 1 2 13 /f rl (31.03 ms) 1 0 0 2 14 /f rl (62.06 ms) 1 0 1 2 15 /f rl (124.12 ms) 1 1 0 2 16 /f rl (248.24 ms) 1 1 1 2 17 /f rl (496.48 ms) cautions 1. the combination of wdcs2, wdcs 1, wdcs0 = 0, 0, 0 and window1, window0 = 0, 0 is prohibited. 2. the watchdog timer does not stop duri ng self-programming of the flash memory and eeprom emulation. during processing, the interrupt ackno wledge time is delayed. set the overflow time and window size taking this delay into consideration. remarks 1. f rl : low-speed ring-osc clock oscillation frequency 2. ( ): f rl = 264 khz (max.) chapter 10 watchdog timer preliminary user?s manual u17473ej1v0ud 241 10.4.3 setting window open period of watchdog timer set the window open period of the watchdog timer by usi ng bits 6 and 5 (window1, window0) of the option byte. the outline of the window is as follows. ? if ?ach? is written to wdte during the window open per iod, the watchdog timer is cleared and starts counting again. ? even if ?ach? is written to wdte during the window cl ose period, an abnormality is detected and an internal reset signal is generated. example : if the window open period is 25% window close period (75%) window open period (25%) counting starts overflow time counting starts again when ach is written to wdte. internal reset signal is generated if ach is written to wdte. caution the first writing to wdte after a reset release clears the watchdog timer, if it is made before the overflow time regardless of the timing of th e writing, and the watc hdog timer starts counting again. the window open period to be set is as follows. table 10-4. setting window open period of watchdog timer window1 window0 window open period of watchdog timer 0 0 25% 0 1 50% 1 0 75% 1 1 100% (default) cautions 1. the combination of wdcs2, wdcs 1, wdcs0 = 0, 0, 0 and window1, window0 = 0, 0 is prohibited. 2. the watchdog timer does not stop durin g self-programming of the flash memory and eeprom emulation. during processing, the interrupt ackno wledge time is delayed. set the overflow time and window size taking this delay into consideration. chapter 10 watchdog timer preliminary user?s manual u17473ej1v0ud 242 remark if the overflow time is set to 2 10 /f rl , the window close time and open time are as follows. setting of window open period 25% 50% 75% 100% window close time 0 to 3.56 ms 0 to 2.37 ms 0 to 0.119 ms none window open time 3.56 to 3.88 ms 2.37 to 3.88 ms 0.119 to 3.88 ms 0 to 3.88 ms preliminary user?s manual u17473ej1v0ud 243 chapter 11 clock output controller 11.1 functions of clock output controller the clock output controller of 78k0/lg2 is intended for clock output for supply to lcd controller/driver. the clock selected with the clock output selection register (cks) is supplied to the lcd controller/driver. figure 11-1 shows the block diagram of clock output controller. figure 11-1. block diagram of clock output controller f prs f prs to f prs /2 7 f sub cloe 8 lcd controller/driver clock controller prescaler internal bus ccs3 clock output selection register (cks) ccs2 ccs1 ccs0 pm140 selector port mode register 14 (pm14) chapter 11 clock output controller preliminary user?s manual u17473ej1v0ud 244 11.2 configuration of clock output controller the clock output controller includes the following hardware. table 11-1. configuration of clock output controller item configuration control registers clock output selection register (cks) port mode register 14 (pm14) 11.3 registers controlling clock output controller the following two registers are used to co ntrol the clock output controller. ? clock output selection register (cks) ? port mode register 14 (pm14) (1) clock output selection register (cks) this register sets output enable/disable for clock output (pcl), and sets the output clock. cks is set by a 1-bit or 8-bit memory manipulation instruction. reset input clears cks to 00h. chapter 11 clock output controller preliminary user?s manual u17473ej1v0ud 245 figure 11-2. format of clock out put selection register (cks) address: ff40h after reset: 00h r/w symbol 7 6 5 <4> 3 2 1 0 cks 0 0 0 cloe ccs3 ccs2 ccs1 ccs0 cloe pcl output enable/disable specification 0 clock division circui t operation stopped. pcl fixed to low level. 1 clock division ci rcuit operation enabled. pcl output enabled. pcl output clock selection note ccs3 ccs2 ccs1 ccs0 f sub = 32.768 khz f prs = 10 mhz f prs = 20 mhz 0 0 0 0 f prs 10 mhz setting prohibited note 0 0 0 1 f prs /2 5 mhz 10 mhz 0 0 1 0 f prs /2 2 2.5 mhz 5 mhz 0 0 1 1 f prs /2 3 1.25 mhz 2.5 mhz 0 1 0 0 f prs /2 4 625 khz 1.25 mhz 0 1 0 1 f prs /2 5 312.5 khz 625 khz 0 1 1 0 f prs /2 6 156.25 khz 312.5 khz 0 1 1 1 f prs /2 7 ? 78.125 khz 156.25 khz 1 0 0 0 f sub 32.768 khz ? other than above setting prohibited note the pcl output clock prohibits settings if they exceed 10 mhz. remarks 1. f prs : peripheral hardware clock oscillation frequency 2. f sub : subsystem clock oscillation frequency chapter 11 clock output controller preliminary user?s manual u17473ej1v0ud 246 (2) port mode register 14 (pm14) pm14 controls the clock output to the lcd controller/driver. set the pm140 bit to 0 to use this r egister as the clock output function. pm14 is set with a 1-bit or 8-bit memory manipulation instruction. reset input sets pm14 to ffh. figure 11-3. format of port mode register 14 (pm14) address: ff2eh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm14 1 1 1 1 1 1 1 pm140 pm140 clock output control to lcd controller/driver 0 clock output to lcd controller/driver enabled 1 clock output to lcd controller/driver disabled 11.4 operations of clock output controller the clock pulse is output as the following procedure. <1> select the clock pulse output frequency with bits 0 to 3 (ccs0 to ccs3) of the clock output selection register (cks) (clock pulse output in disabled status). <2> set bit 4 (cloe) of cks to 1 to enable clock output. remark the clock output controller is designed not to output pulses with a small width during output enable/disable switching of the clock output. as show n in figure 11-4, be sure to start output from the low period of the clock (marked with * in the figure) . when stopping output, do so after securing a high level of the clock. figure 11-4. remote control output application example cloe clock output ** preliminary user?s manual u17473ej1v0ud 247 chapter 12 a/d converter 12.1 function of a/d converter the a/d converter converts an analog input signal into a digi tal value, and consists of up to eight channels (ani0 to ani7) with a resolution of 10 bits. the a/d converter has the following function. ? 10-bit resolution a/d conversion 10-bit resolution a/d conversion is carried out repeatedly for one channel selected from analog inputs ani0 to ani7. each time an a/d conversion operation en ds, an interrupt request (intad) is generated. figure 12-1. block diag ram of a/d converter av ref av ss intad adcs bit adcs fr2 fr1 adce fr0 sample & hold circuit av ss voltage comparator a/d converter mode register (adm) internal bus 3 ads2 ads1 ads0 analog input channel specification register (ads) ani0/p20 ani1/p21 ani2/p22 ani3/p23 ani4/p24 ani5/p25 ani6/p26 ani7/p27 controller a/d conversion result register (adcr) successive approximation register (sar) lv1 lv0 5 a/d port configuration register (adpc) adpc3 adpc2 adpc1 adpc0 4 selector tap selector chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 248 12.2 configuration of a/d converter the a/d converter includes the following hardware. table 12-1. registers of a/ d converter used on software item configuration registers a/d converter mode register (adm) a/d port configuration register (adpc) analog input channel specification register (ads) port mode register 2 (pm2) 10-bit a/d conversion resu lt register (adcr) 8-bit a/d conversion result register (adcrh) (1) ani0 to ani7 pins these are the analog input pins of the 8- channel a/d converter. they input analog signals to be converted into digital signals. pins other than the one selected as the analog input pin can be used as i/o port pins. (2) sample & hold circuit the sample & hold circuit samples the input signal of the analog input pin selected by the selector when a/d conversion is started, and holds the sampled anal og input voltage value during a/d conversion. (3) series resistor string the series resistor stri ng is connected between av ref and av ss , and generates a voltage to be compared with the analog input signal. figure 12-2. circuit configuration of series resistor string adcs series resistor string av ref p-ch av ss (4) voltage comparator the voltage comparator compar es the sampled analog input voltage and t he output voltage of the series resistor string. (5) successive approximation register (sar) this register compares the sampled analog voltage and the voltage of the series resistor string, and converts the result, starting from the most significant bit (msb). when the voltage value is converted into a digital valu e down to the least significant bit (lsb) (end of a/d conversion), the contents of the sar register are transfe rred to the a/d conversion result register (adcr). chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 249 (6) 10-bit a/d conversion r esult register (adcr) the a/d conversion result is loaded from the successive approximation register to th is register each time a/d conversion is completed, and the adcr re gister holds the a/d conversion result in its higher 10 bits (the lower 6 bits are fixed to 0). (7) 8-bit a/d conversion result register (adcrh) the a/d conversion result is loaded from the successive approximation register to th is register each time a/d conversion is completed, and the adcrh register stores the higher 8 bi ts of the a/d conversion result. caution when data is read from adcr and adcrh, a wa it cycle is generated. do not read data from adcr and adcrh when the cpu is operating on the subsystem clock and the peripheral hardware clock is stopped. for de tails, see chapter 31 cautions for wait. (8) controller when a/d conversion has been completed, this controller generates intad. (9) av ref pin this pin inputs an analog power/reference voltage to the a/d converter. always use this pin at the same potential as that of the v dd pin even when the a/d converter is not used. the signal input to ani0 to ani7 is converted into a digital signal, based on the voltage applied across av ref and av ss . (10) av ss pin this is the ground potential pin of the a/d converter. al ways use this pin at the same potential as that of the v ss pin even when the a/d converter is not used. (11) a/d converter mode register (adm) this register is used to set the conver sion time of the analog input signal to be converted, and to start or stop the conversion operation. (12) a/d port configuration register (adpc) this register switches the p20/ani0 to p27/ani7 pins to analog input of a/d converter or digital input of port. (13) analog input channel sp ecification register (ads) this register is used to specify the port that inputs the analog voltage to be converted into a digital signal. (14) port mode register 2 (pm2) this register switches the p20/ani0 to p27/ani7 pins to input or output. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 250 12.3 registers used in a/d converter the a/d converter uses the following six registers. ? a/d converter mode register (adm) ? a/d port configuration register (adpc) ? analog input channel specification register (ads) ? port mode register 2 (pm2) ? 10-bit a/d conversion result register (adcr) ? 8-bit a/d conversion result register (adcrh) (1) a/d converter mode register (adm) this register sets the conversion time for analog inpu t to be a/d converted, and starts/stops conversion. adm can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 12-3. format of a/d converter mode register (adm) adce lv0 note 1 lv1 note 1 fr0 note 1 fr1 note 1 fr2 note 1 0 adcs a/d conversion operation control stops conversion operation enables conversion operation adcs 0 1 <0> 1 2 3 4 5 6 <7> adm address: ff28h after reset: 00h r/w symbol comparator operation control note 2 stops comparator operation enables comparator operation (comparator: 1/2av dd operation) adce 0 1 notes 1. for details of fr2 to fr0, lv 1, lv0, and a/d conversion, see table 12-3 a/d conversion time selection . 2. a comparator is incorporated to realize low-volt age operation. the operati on of the comparator is controlled by adcs and adce, and it takes 1 s from operation start to operation stabilization. therefore, when adcs is set to 1 after 1 s or more has elapsed from the time adce is set to 1, the conversion result at that time has priority over the first conversion result. otherwise, ignore data of the first conversion. table 12-2. settings of adcs and adce adcs adce a/d co nversion operation 0 0 stop status (dc power consumption path does not exist) 0 1 conversion waiting mode (comparator: 1/2av dd operation, only comparator consumes power) 1 0 conversion mode (comparator operation stopped note ) 1 1 conversion mode (comparator: 1/2av dd operation) note ignore data of the first conversion because it is not guaranteed range. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 251 figure 12-4. timing chart wh en comparator is used adce comparator adcs conversion operation conversion operation conversion stopped conversion waiting comparator: 1/2av dd operation note note the time from the rising of the adce bi t to the falling of the adcs bit must be 1 s or longer. cautions 1. a/d conversion must be stopped before re writing bits fr0 to fr2, lv1, and lv0 to values other than the identical data. 2. if data is written to adm, a wait cycle is generated. do not write data to adm when the cpu is operating on the subsystem clock and the periphera l hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 252 table 12-3. a/d conversion time selection (1) 2.7 v av ref 5.5 v a/d converter mode register (adm) conversion ti me selection conversion time configuration fr2 fr1 fr0 lv1 lv0 f prs = 2 mhz f prs = 10 mhz f prs = 20 mhz conversion clock (f ad ) sar clear sampling successive conversion time adcr transfer, intad generation 0 0 0 0 0 264/f prs 26.4 s 13.2 s f prs /12 0 0 1 0 0 176/f prs 17.6 s 8.8 s note f prs /8 0 1 0 0 0 132/f prs 13.2 s 6.6 s note f prs /6 0 1 1 0 0 88/f prs setting prohibited 8.8 s note f prs /4 1 0 0 0 0 66/f prs 33.0 s 6.6 s note f prs /3 1 0 1 0 0 44/f prs 22.0 s setting prohibited setting prohibited f prs /2 2/f ad 6/f ad 12/f ad 2/f ad other than above setting prohibited note this can be set only when 4.0 v av ref 5.5 v. (2) 2.3 v av ref < 2.7 v a/d converter mode register (adm) conversion ti me selection conversion time configuration fr2 fr1 fr0 lv1 lv0 f prs = 2 mhz f prs = 5 mhz conversion clock (f ad ) sar clear sampling successive conversion time adcr transfer, intad generation 0 0 0 0 1 480/f prs setting prohibited f prs /12 0 0 1 0 1 320/f prs 64.0 s f prs /8 0 1 0 0 1 240/f prs 48.0 s f prs /6 0 1 1 0 1 160/f prs setting prohibited 32.0 s f prs /4 1 0 0 0 1 120/f prs 60.0 s setting prohibited f prs /3 1 0 1 0 1 80/f prs 40.0 s setting prohibited f prs /2 2/f ad 24/f ad 12/f ad 2/f ad other than above setting prohibited cautions 1. set the conversion ti mes with the following conditions. ? 4.0 v av ref 5.5 v: sampling + successive conversion time = 5 to 30 s ? 2.7 v av ref < 4.0 v: sampling + successive conversion time = 10 to 30 s ? 2.3 v av ref < 2.7 v: sampling + successive conversion time = 25 to 62 s 2. when rewriting fr2 to fr0, lv1, and lv0 to other than the same data, stop a/d conversion once beforehand. 3. change lv1 and lv0 from the default value, when 2.3 v av ref < 2.7 v. remark f prs : peripheral hardware clock oscillation frequency chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 253 figure 12-5. a/d converter sa mpling and a/d conversion timing adcs wait period note conversion time conversion time sampling time sampling timing intad adcs 1 or ads rewrite sampling time sar clear sar clear transfer to adcr, intad generation successive conversion time note for details of wait period, see chapter 31 cautions for wait . (2) 10-bit a/d conversion r esult register (adcr) this register is a 16-bit register that stores the a/d conversion result. the lower 6 bits are fixed to 0. each time a/d conversion ends, the conversion resu lt is loaded from the successive appr oximation register, and is stored in adcr in order starting from bit 7 of ff09h. ff09h indi cates the higher 8 bits of the conversion result, and ff08h indicates the lower 2 bits of the conversion result. adcr can be read by a 16-bit memory manipulation instruction. reset input clears this register to 0000h. figure 12-6. format of 10-bit a/d conversion result register (adcr) symbol address: ff08h, ff09h after reset: 0000h r ff09h ff08h 0 0 0 0 0 0 adcr cautions 1. when writing to the a/d converter mode register (adm), analog input ch annel specification register (ads), and a/d port configuration register (adpc), the contents of adcr may become undefined. read the conversion resu lt following conversion completion before writing to adm, ads, and adpc. using timing other than the above m ay cause an incorrect conversion result to be read. 2. if data is read from adcr, a wait cycle is ge nerated. do not read data from adcr when the cpu is operating on the subsystem clock and th e peripheral hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 254 (3) 8-bit a/d conversion result register (adcrh) this register is an 8-bit register that stores the a/d conversion result. the higher 8 bits of 10-bit resolution are stored. adcrh can be read by an 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 12-7. format of 8-bit a/d c onversion result register (adcrh) symbol adcrh address: ff09h after reset: 00h r 76543210 cautions 1. when writing to the a/d converter mode register (adm), analog input ch annel specification register (ads), and a/d port configuration register (adpc), the contents of adcrh may become undefined. read the conversion resu lt following conversion completion before writing to adm, ads, and adpc. using timing other than the above m ay cause an incorrect conversion result to be read. 2. if data is read from adcrh, a wait cycle is generated. do not r ead data from adcrh when the cpu is operating on the subsystem clock a nd the peripheral hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 255 (4) analog input channel specification register (ads) this register specifies the input port of the analog voltage to be a/d converted. ads can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 12-8. format of analog input channel specification register (ads) ads0 ads1 ads2 0 0 0 0 0 analog input channel specification ani0 ani1 ani2 ani3 ani4 ani5 ani6 ani7 ads0 0 1 0 1 0 1 0 1 ads1 0 0 1 1 0 0 1 1 ads2 0 0 0 0 1 1 1 1 0 1 2 3 4 5 6 7 ads address: ff29h after reset: 00h r/w symbol cautions 1. be sure to clear bits 3 to 7 to 0. 2 set the channel used for a/d conversion in the input mode by using port mode register 2 (pm2). 3. do not set a pin to be used as a digital i/o pin with adpc with ads. 4. if data is written to ads, a wait cycle is generated. do not wr ite data to ads when the cpu is operating on the subsystem clock and the periphera l hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 256 (5) a/d port configuration register (adpc) this register switches the p20/ani0 to p27/ani7 pins to analog in put of a/d converter or digital i/o of port. adpc can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 12-9. format of a/d port configuration register (adpc) adpc0 adpc1 adpc2 adpc3 0 0 0 0 analog input (a)/digital input (d) switching setting prohibited adpc3 0 1 2 3 4 5 6 7 adpc address: ff2fh after reset: 00h r/w symbol p27/ ani7 a a a a a a a a d p26/ ani6 a a a a a a a d d p25/ ani5 a a a a a a d d d p24/ ani4 a a a a a d d d d p23/ ani3 a a a a d d d d d p22/ ani2 a a a d d d d d d p21/ ani1 a a d d d d d d d p20/ ani0 a d d d d d d d d 0 0 0 0 0 0 0 0 1 adpc2 0 0 0 0 1 1 1 1 0 adpc1 0 0 1 1 0 0 1 1 0 adpc0 0 1 0 1 0 1 0 1 0 other than above cautions 1. set the channel used for a/d conversion in the input mode by using port mode register 2 (pm2). 2. do not set a pin to be used as a digital i/o pin with adpc with ads. 3. if data is written to adpc, a wait cycle is ge nerated. do not write data to adpc when the cpu is operating on the subsystem clock and the peri pheral hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 257 (6) port mode register 2 (pm2) when using the p20/ani0 to p27/ani7 pins for analog input port, set pm20 to pm27 to 1. the output latches of p20 to p27 at this time may be 0 or 1. pm2 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to ffh. figure 12-10. format of port mode register 2 (pm2) pm20 pm21 pm22 pm23 pm24 pm25 pm26 pm27 p2n pin i/o mode selection (n = 0 to 7) output mode (output buffer on) input mode (output buffer off) pm2n 0 1 0 1 2 3 4 5 6 7 pm2 address: ff22h after reset: ffh r/w symbol the functions of the ani0/p20 to an i7/p27 pins are determined according to the settings of adpc, ads, and pm2. table 12-4. settings of ani0/p20 to ani7/p27 pin function adpc setting pm2 setting ads setting p20/ani0 to p27/ani7 pins ani selection analog input (target for conversion) input mode ani non-selection analog input (target for non- conversion) ani selection analog input selection output mode ani non-selection setting prohibited ani selection setting prohibited input mode ani non-selection digital input ani selection setting prohibited digital i/o selection output mode ani non-selection digital output chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 258 12.4 a/d converter operations 12.4.1 basic operations of a/d converter <1> select one channel for a/d conversion using the analog input channel specification register (ads). <2> set channels for a/d conversion to analog input by usi ng the a/d port configuration register (adpc) and set to input mode by using port mode register 2 (pm2). <3> set adce to 1 and wait for 1 s or longer. <4> set adcs to 1 and start the conversion operation. (<5> to <11> are operations performed by hardware.) <5> the voltage input to the selected analog input c hannel is sampled by the sample & hold circuit. <6> when sampling has been done for a certain time, the sa mple & hold circuit is placed in the hold state and the input analog voltage is held until the a/d conversion operation has ended. <7> bit 9 of the successive approximation register (sar) is set. the series resistor string voltage tap is set to (1/2) av ref by the tap selector. <8> the voltage difference between the se ries resistor string voltage tap and analog input is compared by the voltage comparator. if the analog input is greater than (1/2) av ref , the msb of sar remains set to 1. if the analog input is smaller than (1/2) av ref , the msb is reset to 0. <9> next, bit 8 of sar is automatically set to 1, and the operation proceeds to the nex t comparison. the series resistor string voltage tap is selected according to the preset value of bit 9, as described below. ? bit 9 = 1: (3/4) av ref ? bit 9 = 0: (1/4) av ref the voltage tap and analog input vo ltage are compared and bit 8 of sar is manipulated as follows. ? analog input voltage voltage tap: bit 8 = 1 ? analog input voltage < voltage tap: bit 8 = 0 <10> comparison is continued in this way up to bit 0 of sar. <11> upon completion of the comparison of 10 bits, an effective digital result value remains in sar, and the result value is transferred to the a/d conversion resu lt register (adcr, adcrh) and then latched. at the same time, the a/d conversion end in terrupt request (intad) can also be generated. <12> repeat steps <5> to <11>, until adcs is cleared to 0. to stop the a/d converter, clear adcs to 0. to restart a/d conversion from the st atus of adce = 1, start from <4>. to restart a/d conversion from the status of adce = 0, however, start from <3>. remark two types of a/d conversion re sult registers are available. ? adcr (16 bits): store 10-bit a/d conversion value ? adcrh (8 bits): store 8-bit a/d conversion value chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 259 figure 12-11. basic operation of a/d converter conversion time sampling time sampling a/d conversion undefined conversion result a/d converter operation sar adcr intad conversion result a/d conversion operations are performed continuously until bit 7 (adcs) of t he a/d converter mode register (adm) is reset (0) by software. if a write operation is performed to one of the adm, analog input channel specif ication register (ads) or a/d port configuration register (adpc) during an a/d conversion operat ion, the conversion operation is initialized, and if the adcs bit is set (1), conversion starts again from the beginning. reset input clears the a/d conversion result r egister (adcr, adcrh) to 0000h or 00h. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 260 12.4.2 input voltage and conversion results the relationship between the analog input voltage input to the analog input pins (ani0 to ani7) and the theoretical a/d conversion result (stored in the 10-bit a/d conver sion result register (adcr)) is shown by the following expression. sar = int ( 1024 + 0.5) adcr = sar 64 or (adcr ? 0.5) v ain < (adcr + 0.5) where, int( ): function which returns integer part of value in parentheses v ain : analog input voltage av ref : av ref pin voltage adcr: a/d conversion result register (adcr) value sar: successive approximation register figure 12-12 shows the relationship between the analo g input voltage and the a/d conversion result. figure 12-12. relationship between analog i nput voltage and a/d conversion result 1023 1022 1021 3 2 1 0 ffc0h ff80h ff40h 00c0h 0080h 0040h 0000h a/d conversion result (adcr) sar adcr 1 2048 1 1024 3 2048 2 1024 5 2048 input voltage/av ref 3 1024 2043 2048 1022 1024 2045 2048 1023 1024 2047 2048 1 v ain av ref av ref 1024 av ref 1024 chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 261 12.4.3 a/d converter operation mode the operation mode of the a/d converter is the select mode. one channe l of analog input is selected from ani0 to ani7 by the analog input channel specification register (ads) and a/d co nversion is executed. (1) a/d conversion operation by setting bit 7 (adcs) of the a/d converter mode regist er (adm) to 1, the a/d conversion operation of the voltage, which is applied to the analog input pin specif ied by the analog input channel specification register (ads), is started. when a/d conversion has been completed, the result of the a/d c onversion is stored in t he a/d conversion result register (adcr), and an interrupt request signal (intad) is generated. once the a/ d conversion has started and when one a/d conversion has been comple ted, the next a/d conver sion operation is immediately started. the a/d conversion operations are repeated until new data is written to ads. if adm, ads, and the a/d port configur ation register (adpc) are rewri tten during a/d conversion, the a/d conversion operation under execution is st opped and restarted from the beginning. if 0 is written to adcs during a/d conversion, a/d conv ersion is immediately stopped. at this time, the conversion result immediat ely before is retained. figure 12-13. a/d conversion operation anin rewriting adm adcs = 1 rewriting ads adcs = 0 anin anin anin anim anin anim anim stopped conversion result immediately before is retained a/d conversion adcr, adcrh intad conversion is stopped conversion result immediately before is retained remarks 1. n = 0 to 7 2. m = 0 to 7 chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 262 the setting methods are described below. ? when used as a/d conversion operation <1> set bit 0 (adce) of the a/d converter mode register (adm) to 1. <2> select the channel using bits 2 to 0 (ads2 to ad s0) of the analog input channel specification register (ads), bits 3 to 0 (adpc3 to adpc0) of the a/d port configuration register (adpc), and bits 7 to 0 (pm27 to pm20) of port mode register 2 (pm2), and sele ct the conversion time using bits 5 to 1 (fr2 to fr0, lv1, lv0) of adm. <3> set bit 7 (adcs) of adm to 1 to start a/d conversion. <4> an interrupt request signal (intad) is generated. <5> transfer the a/d conversion data to the a/d conversion result register (adcr, adcrh). chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 263 12.5 how to read a/d converter characteristics table here, special terms unique to the a/d converter are explained. (1) resolution this is the minimum analog input vo ltage that can be identif ied. that is, the perce ntage of the analog input voltage per bit of digital output is called 1lsb (least si gnificant bit). the percentage of 1lsb with respect to the full scale is expressed by %fsr (full scale range). 1lsb is as follows when the resolution is 10 bits. 1lsb = 1/2 10 = 1/1024 = 0.098%fsr accuracy has no relation to resolution, but is determined by overall error. (2) overall error this shows the maximum error value between the actual measured value and the theoretical value. zero-scale error, full-scale error, integral linearity error, and differential linearity errors that are combinations of these express the overall error. note that the quantization error is not included in the overall erro r in the characteristics table. (3) quantization error when analog values are converted to digital values, a 1/2lsb error naturally occurs. in an a/d converter, an analog input voltage in a range of 1/2lsb is converted to the same digita l code, so a quantization error cannot be avoided. note that the quantization erro r is not included in the overall error, zero -scale error, full-scale error, integral linearity error, and differential linearity error in the characteristics table. figure 12-14. overall error figur e 12-15. quanti zation error ideal line 0 ?? 0 1 ?? 1 digital output overall error analog input av ref 0 0 ?? 0 1 ?? 1 digital output quantization error 1/2lsb 1/2lsb analog input 0 av ref (4) zero-scale error this shows the difference between the actual measuremen t value of the analog input vo ltage and the theoretical value (1/2lsb) when the digital output changes from 0......000 to 0......001. if the actual measurement value is greater than the theore tical value, it shows the difference between the actual measurement value of the analog in put voltage and the theoretical val ue (3/2lsb) when the digital output changes from 0??001 to 0??010. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 264 (5) full-scale error this shows the difference between the actual measuremen t value of the analog input vo ltage and the theoretical value (full-scale ? 3/2lsb) when the digital output chan ges from 1......110 to 1......111. (6) integral linearity error this shows the degree to which the conversion charac teristics deviate from the ideal linear relationship. it expresses the maximum value of the di fference between the actual measurement value and the ideal straight line when the zero-scale error and full-scale error are 0. (7) differential linearity error while the ideal width of code output is 1lsb, this indi cates the difference between the actual measurement value and the ideal value. figure 12-16. zero-scale error figure 12-17. full-scale error 111 011 010 001 zero-scale error ideal line 000 01 2 3 av ref digital output (lower 3 bits) analog input (lsb) 111 110 101 000 0 av ref ? 3 full-scale error ideal line analog input (lsb) digital output (lower 3 bits) av ref ? 2av ref ? 1 av ref figure 12-18. integral linearity error figure 12-19. differential linearity error 0 av ref digital output analog input integral linearity error ideal line 1 ?? 1 0 ?? 0 0 av ref digital output analog input differential linearity error 1 ?? 1 0 ?? 0 ideal 1lsb width (8) conversion time this expresses the time from the start of samp ling to when the digital output is obtained. the sampling time is included in the conv ersion time in the characteristics table. (9) sampling time this is the time the analog switch is turned on for the anal og voltage to be sampled by the sample & hold circuit. sampling time conversion time chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 265 12.6 cautions for a/d converter (1) operating current in stop mode the a/d converter stops operating in the stop mode. at this time, th e operating current can be reduced by clearing bit 7 (adcs) of the a/d conver ter mode register (adm) to 0 (see figure 12-2 ). to restart from the standby status, clear bit 0 (adif) of interrupt request flag register 1l (if1l) to 0 and start operation. (2) input range of ani0 to ani7 observe the rated range of the ani0 to an i7 input voltage. if a voltage of av ref or higher and av ss or lower (even in the range of absolute maximum ratings) is input to an analog input channel, the converted value of that channel becomes undefined. in addition, the converted values of the other channels may also be affected. (3) conflicting operations <1> conflict between a/d conversion result regist er (adcr, adcrh) write and adcr or adcrh read by instruction upon the end of conversion adcr or adcrh read has priority. after the read op eration, the new co nversion result is written to adcr or adcrh. <2> conflict between adcr or adcrh write and a/d converter mode regi ster (adm) write, analog input channel specification register (ads), or a/d port configuration register (a dpc) write upon the end of conversion adm, ads, or adpc write has priority. adcr or adcrh write is not performed, nor is the conversion end interrupt signal (intad) generated. (4) noise countermeasures to maintain the 10-bit resolution, attent ion must be paid to noise input to the av ref pin and pins ani0 to ani7. because the effect increases in propor tion to the output impedance of the analog input source, it is recommended that a capacitor be connected externally, as shown in figure 12-20, to reduce noise. figure 12-20. analog input pin connection reference voltage input c = 100 to 1,000 pf if there is a possibility that noise equal to or higher than av ref or equal to or lower than av ss may enter, clamp with a diode with a small v f value (0.3 v or lower). av ref av ss v ss ani0 to ani7 chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 266 (5) ani0/p20 to ani7/p27 <1> the analog input pins (ani0 to ani7) are also used as input port pins (p20 to p27). when a/d conversion is performed with any of an i0 to ani7 selected, do not access port 2 while conversion is in progress; otherwis e the conversion resolution may be degraded. it is recommended to select pins used as port 2 starting with the ani0/p20 that is the furthest from av ref . <2> if a digital pulse is applied to the pins adjacent to t he pins currently used for a/ d conversion, the expected value of the a/d conversion may not be obtained due to coupling noise. t herefore, do not apply a pulse to the pins adjacent to the pi n undergoing a/d conversion. (6) input impedance of ani0 to ani7 pins in this a/d converter, the internal sampling capacitor is charged and sampling is performed for approx. one sixth of the conversion time. since only the leakage current flows other than during sa mpling and the current for charging the capacitor also flows during sampling, the input impedance fluctuates and has no meaning. to perform sufficient sampling, however, it is recommen ded to make the output impe dance of the analog input source 10 k ? or lower, or attach a capacitor of around 100 pf to the ani0 to ani7 pins (see figure 12-20 ). (7) av ref pin input impedance a series resistor string of several tens of k ? is connected between the av ref and av ss pins. therefore, if the output impedance of t he reference voltage source is high, this will result in a series connection to the series resistor string between the av ref and av ss pins, resulting in a large reference voltage error. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 267 (8) interrupt request flag (adif) the interrupt request flag (adif) is not cleared even if th e analog input channel specification register (ads) is changed. therefore, if an analog input pin is changed during a/d conversion, the a/d conversion result and adif for the pre-change analog input may be set just before the ads rewrit e. caution is therefore re quired since, at this time, when adif is read immediately after the ads rewrite, ad if is set despite the fact a/d conversion for the post- change analog input has not ended. when a/d conversion is stopped and then resumed, clear ad if before the a/d conversion operation is resumed. figure 12-21. timing of a/d conver sion end interrupt request generation ads rewrite (start of anin conversion) a/d conversion adcr adif anin anin anim anim anin anin anim anim ads rewrite (start of anim conversion) adif is set but anim conversion has not ended. remarks 1. n = 0 to 7 2. m = 0 to 7 (9) conversion results just after a/d conversion start the first a/d conversion value immediately after a/d conv ersion starts may not fall wit hin the rating range if the adcs bit is set to 1 within 1 s after the adce bit was set to 1, or if t he adcs bit is set to 1 with the adce bit = 0. take measures such as pollin g the a/d conversion end interrupt r equest (intad) and removing the first conversion result. (10) a/d conversion result regist er (adcr, adcrh) read operation when a write operation is performed to the a/d conver ter mode register (adm), analog input channel specification register (ads), and a/ d port configuration register (adp c), the contents of adcr and adcrh may become undefined. read the conversion re sult following conversion completion before writing to adm, ads, and adpc. using a timing other than the above may cause an incorrect conversion result to be read. chapter 12 a/d converter preliminary user?s manual u17473ej1v0ud 268 (11) internal equivalent circuit the equivalent circuit of the analog input block is shown below. figure 12-22. internal equi valent circuit of anin pin anin c1 c2 c3 r1 r2 table 12-5. resistance and capacitance valu es of equivalent circui t (reference values) av ref r1 r2 c1 c2 c3 2.7 v t.b.d. t.b.d. t.b.d. t.b.d. t.b.d. 4.5 v t.b.d. t.b.d. t.b.d. t.b.d. t.b.d. remarks 1. the resistance and capacitance values shown in table 12-5 are not guaranteed values. 2. n = 0 to 7 preliminary user?s manual u17473ej1v0ud 269 chapter 13 serial interface uart0 13.1 functions of serial interface uart0 serial interface uart0 has the following two modes. (1) operation stop mode this mode is used when serial communication is not executed and can enable a reduction in the power consumption. for details, see 13.4.1 operation stop mode . (2) asynchronous serial interface (uart) mode the functions of this mode are outlined below. for details, see 13.4.2 asynchronous seri al interface (uart) mode and 13.4.3 dedicated baud rate generator . ? two-pin configuration t x d0: transmit data output pin r x d0: receive data input pin ? length of communication data can be selected from 7 or 8 bits. ? dedicated on-chip 5-bit baud rate generator allowing any baud rate to be set ? transmission and reception can be performed independently. ? four operating clock inputs selectable ? fixed to lsb-first communication cautions 1. if clock supply to serial interface uart0 is not stopped (e.g., in the halt mode), normal operation continues. if clock supply to serial interface uart0 is stopped (e.g., in the stop mode), each register stops operating, and hold s the value immediatel y before clock supply was stopped. the t x d0 pin also holds the value imme diately before clock supply was stopped and outputs it. however, the operati on is not guaranteed after clock supply is resumed. therefore, reset the circuit so th at power0 = 0, rxe0 = 0, and txe0 = 0. 2. set power0 = 1 and then set txe0 = 1 (tr ansmission) or rxe0 = 1 (reception) to start communication. 3. txe0 and rxe0 are synch ronized by the base clock (f xclk0 ) set by brgc0. to enable transmission or reception again, set txe0 or rxe0 to 1 at least tw o clocks of base clock after txe0 or rxe0 has been clear ed to 0. if txe0 or rxe0 is set within two clocks of base clock, the transmission ci rcuit or reception circui t may not be initialized. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 270 13.2 configuration of serial interface uart0 serial interface uart0 includes the following hardware. table 13-1. configurati on of serial interface uart0 item configuration registers receive buffer register 0 (rxb0) receive shift register 0 (rxs0) transmit shift register 0 (txs0) control registers asynchronous serial interface o peration mode register 0 (asim0) asynchronous serial interface recepti on error status register 0 (asis0) baud rate generator control register 0 (brgc0) port mode register 1 (pm1) port register 1 (p1) chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 271 figure 13-1. block diagram of serial interface uart0 t x d0/ sck10/p10 intst0 r x d0/ si10/p11 intsr0 f prs /2 5 f prs /2 3 f prs /2 transmit shift register 0 (txs0) receive shift register 0 (rxs0) receive buffer register 0 (rxb0) asynchronous serial interface reception error status register 0 (asis0) asynchronous serial interface operation mode register 0 (asim0) baud rate generator control register 0 (brgc0) 8-bit timer/ event counter 50 output registers selector baud rate generator baud rate generator reception unit reception control filter internal bus transmission control transmission unit output latch (p10) pm10 7 7 chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 272 (1) receive buffer register 0 (rxb0) this 8-bit register stores parallel data conv erted by receive shift register 0 (rxs0). each time 1 byte of data has been received, new receive dat a is transferred to this r egister from receive shift register 0 (rxs0). if the data length is set to 7 bits the receive data is tran sferred to bits 0 to 6 of rxb0 and the msb of rxb0 is always 0. if an overrun error (ove0) occurs, the rece ive data is not transferred to rxb0. rxb0 can be read by an 8-bit memory manipulation inst ruction. no data can be written to this register. reset input or power0 = 0 se ts this register to ffh. (2) receive shift register 0 (rxs0) this register converts the serial data input to the r x d0 pin into parallel data. rxs0 cannot be directly manipulated by a program. (3) transmit shift register 0 (txs0) this register is used to set transmit data. transmission is started when data is written to txs0, and serial data is transmitted from the t x d0 pins. txs0 can be written by an 8-bit memory manipulatio n instruction. this register cannot be read. reset input, power0 = 0, or txe0 = 0 sets this register to ffh. caution do not write the next tran smit data to txs0 before the tr ansmission completion interrupt signal (intst0) is generated. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 273 13.3 registers controlling serial interface uart0 serial interface uart0 is controlled by the following five registers. ? asynchronous serial interface operation mode register 0 (asim0) ? asynchronous serial interface recept ion error status register 0 (asis0) ? baud rate generator control register 0 (brgc0) ? port mode register 1 (pm1) ? port register 1 (p1) (1) asynchronous serial interface ope ration mode register 0 (asim0) this 8-bit register controls the serial comm unication operations of serial interface uart0. this register can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to 01h. figure 13-2. format of asynchronous serial inte rface operation mode register 0 (asim0) (1/2) address: ff70h after reset: 01h r/w symbol <7> <6> <5> 4 3 2 1 0 asim0 power0 txe0 rxe0 ps01 ps00 cl0 sl0 1 power0 enables/disables operati on of internal operation clock 0 note 1 disables operation of the internal operation clock (fixes the clock to low level) and asynchronously resets the internal circuit note 2 . 1 enables operation of the internal operation clock. txe0 enables/disables transmission 0 disables transmission (synchronously resets th e transmission circuit). 1 enables transmission. rxe0 enables/disables reception 0 disables reception (synchronous ly resets the reception circuit). 1 enables reception. notes 1. the input from the r x d0 pin is fixed to high level when power0 = 0. 2. asynchronous serial interface reception error status register 0 (asis0), transmit shift register 0 (txs0), and receive buffer register 0 (rxb0) are reset. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 274 figure 13-2. format of asynchronous serial inte rface operation mode register 0 (asim0) (2/2) ps01 ps00 transmission oper ation reception operation 0 0 does not output parity bit. reception without parity 0 1 outputs 0 parity. reception as 0 parity note 1 0 outputs odd parity. judges as odd parity. 1 1 outputs even parity. judges as even parity. cl0 specifies character length of transmit/receive data 0 character length of data = 7 bits 1 character length of data = 8 bits sl0 specifies number of stop bits of transmit data 0 number of stop bits = 1 1 number of stop bits = 2 note if ?reception as 0 parity? is selected, the parity is not judged. therefore, bit 2 (pe0) of asynchronous serial interface reception error status register 0 (asis0) is not set and the error interrupt does not occur. cautions 1. at startup, set power0 to 1 and then set txe0 to 1. to stop the op eration, clear txe0 to 0, and then clear power0 to 0. 2. at startup, set power0 to 1 and then set rxe0 to 1. to stop the operation, clear rxe0 to 0, and then clear power0 to 0. 3. set power0 to 1 and then set rxe0 to 1 wh ile a high level is input to the rxd0 pin. if power0 is set to 1 and rxe0 is set to 1 wh ile a low level is input, reception is started. 4. txe0 and rxe0 are synch ronized by the base clock (f xclk0 ) set by brgc0. to enable transmission or reception again, set txe0 or rxe0 to 1 at least two cl ocks of base clock after txe0 or rxe0 has been cleared to 0. if txe0 or rxe0 is set within two clocks of base clock, the transmission circuit or recepti on circuit may not be initialized. 5. clear the txe0 and rxe0 bits to 0 be fore rewriting the ps01, ps00, and cl0 bits. 6. make sure that txe0 = 0 when rewriting th e sl0 bit. reception is always performed with ?number of stop bits = 1?, and therefore, is not affected by the set value of the sl0 bit. 7. be sure to set bit 0 to 1. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 275 (2) asynchronous serial interface recepti on error status register 0 (asis0) this register indicates an error status on completion of re ception by serial interface uart0. it includes three error flag bits (pe0, fe0, ove0). this register is read-only by an 8-bit memory manipulation instruction. reset input clears this register to 00h if bit 7 (power 0) and bit 5 (rxe0) of asim0 = 0. 00h is read when this register is read. figure 13-3. format of asynchronous serial inte rface reception error status register 0 (asis0) address: ff73h after reset: 00h r symbol 7 6 5 4 3 2 1 0 asis0 0 0 0 0 0 pe0 fe0 ove0 pe0 status flag indicating parity error 0 if power0 = 0 and rxe0 = 0, or if asis0 register is read. 1 if the parity of transmit data does not match the parity bit on completion of reception. fe0 status flag indicating framing error 0 if power0 = 0 and rxe0 = 0, or if asis0 register is read. 1 if the stop bit is not detected on completion of reception. ove0 status flag indicating overrun error 0 if power0 = 0 and rxe0 = 0, or if asis0 register is read. 1 if receive data is set to the rxb0 register and the next reception operation is completed before the data is read. cautions 1. the operation of the pe0 bit differs depending on the set values of the ps01 and ps00 bits of asynchronous serial interface operati on mode register 0 (asim0). 2. only the first bit of the receive data is checked as the stop bit, re gardless of the number of stop bits. 3. if an overrun error occurs , the next receive data is not wr itten to receive buffer register 0 (rxb0) but discarded. 4. if data is read from asis0, a wait cycle is generated. do not read data from asis0 when the cpu is operating on the subsystem clock and th e peripheral hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 276 (3) baud rate generator c ontrol register 0 (brgc0) this register selects the base clock of serial interf ace uart0 and the division value of the 5-bit counter. brgc0 can be set by an 8-bit memory manipulation instruction. reset input sets this register to 1fh. figure 13-4. format of baud rate ge nerator control register 0 (brgc0) address: ff71h after reset: 1fh r/w symbol 7 6 5 4 3 2 1 0 brgc0 tps01 tps00 0 mdl04 mdl03 mdl02 mdl01 mdl00 base clock (f xclk0 ) selection tps01 tps00 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz 0 0 tm50 output note 0 1 f prs /2 1 mhz 2.5 mhz 5 mhz 10 mhz 1 0 f prs /2 3 250 khz 625 khz 1.25 mhz 2.5 mhz 1 1 f prs /2 5 62.5 khz 156.25 khz 312.5 khz 625 khz mdl04 mdl03 mdl02 mdl01 mdl00 k selection of 5-bit counter output clock 0 0 setting prohibited 0 1 0 0 0 8 f xclk0 /8 0 1 0 0 1 9 f xclk0 /9 0 1 0 1 0 10 f xclk0 /10 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 0 1 0 26 f xclk0 /26 1 1 0 1 1 27 f xclk0 /27 1 1 1 0 0 28 f xclk0 /28 1 1 1 0 1 29 f xclk0 /29 1 1 1 1 0 30 f xclk0 /30 1 1 1 1 1 31 f xclk0 /31 note note the following points when selecting the tm50 output as the base clock. ? pwm mode (tmc506 = 1) start the operation of 8-bit timer/ event counter 50 first and then set t he count clock to make the duty = 50%. ? mode in which the count clock is cleared and started upon a match of tm50 and cr50 (tmc506 = 0) start the operation of 8-bit timer/ event counter 50 first and then enable the timer f/f inversion operation (tmc501 = 1). it is not necessary to enable the to50 pin as a timer output pin in any mode. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 277 cautions 1. make sure that bit 6 (txe0) and bit 5 (rxe0) of the asim0 register = 0 when rewriting the mdl04 to mdl00 bits. 2. the baud rate value is the output clock of the 5-bit c ounter divided by 2. remarks 1. f xclk0 : frequency of base clock selected by the tps01 and tps00 bits 2. f prs : peripheral hardware clock oscillation frequency 3. k: value set by the mdl04 to md l00 bits (k = 8, 9, 10, ..., 31) 4. : don?t care 5. tmc506: bit 6 of 8-bit timer mode control register 50 (tmc50) tmc501: bit 1 of tmc50 (4) port mode register 1 (pm1) this register sets port 1 input/output in 1-bit units. when using the p10/txd0/sck10 pin for serial interface dat a output, clear pm10 to 0 and set the output latch of p10 to 1. when using the p11/rxd0/si10 pin for seri al interface data input, set pm11 to 1. the output latch of p11 at this time may be 0 or 1. pm1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to ffh. figure 13-5. format of port mode register 1 (pm1) address: ff21h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm1 pm17 pm16 pm15 pm14 pm13 pm12 pm11 pm10 pm1n p1n pin i/o mode selection (n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 278 13.4 operation of serial interface uart0 serial interface uart0 has the following two modes. ? operation stop mode ? asynchronous serial interface (uart) mode 13.4.1 operation stop mode in this mode, serial communication cannot be executed, thus reducing the power consumption. in addition, the pins can be used as ordinary port pins in this mode. to se t the operation stop mode, clear bits 7, 6, and 5 (power0, txe0, and rxe0) of asim0 to 0. (1) register used the operation stop mode is set by asynchronous serial interface operation mode register 0 (asim0). asim0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to 01h. address: ff70h after reset: 01h r/w symbol <7> <6> <5> 4 3 2 1 0 asim0 power0 txe0 rxe0 ps01 ps00 cl0 sl0 1 power0 enables/disables operati on of internal operation clock 0 note 1 disables operation of the internal operation clock (fixes the clock to low level) and asynchronously resets the internal circuit note 2 . txe0 enables/disables transmission 0 disables transmission (synchronously resets th e transmission circuit). rxe0 enables/disables reception 0 disables reception (synchronous ly resets the reception circuit). notes 1. the input from the r x d0 pin is fixed to high level when power0 = 0. 2. asynchronous serial interface reception error status register 0 (asis0), transmit shift register 0 (txs0), and receive buffer register 0 (rxb0) are reset. caution clear power0 to 0 after clearing txe0 and rxe0 to 0 to set the operation stop mode. to start the operation, set power0 to 1, and then set txe0 and rxe0 to 1. remark to use the rxd0/si10/p11 and txd0/sck10/p 10 pins as general-purpose port pins, see chapter 4 port functions . chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 279 13.4.2 asynchronous serial interface (uart) mode in this mode, 1-byte data is transmitted/received following a start bit, and a full-duplex operation can be performed. a dedicated uart baud rate generator is incorporated, so that communication can be executed at a wide range of baud rates. (1) registers used ? asynchronous serial interface operation mode register 0 (asim0) ? asynchronous serial interface recept ion error status register 0 (asis0) ? baud rate generator control register 0 (brgc0) ? port mode register 1 (pm1) ? port register 1 (p1) the basic procedure of setting an operatio n in the uart mode is as follows. <1> set the brgc0 register (see figure 13-4 ). <2> set bits 1 to 4 (sl0, cl0, ps00, and ps01) of the asim0 register (see figure 13-2 ). <3> set bit 7 (power0) of the asim0 register to 1. <4> set bit 6 (txe0) of the asim0 register to 1. transmission is enabled. set bit 5 (rxe0) of the asim0 register to 1. reception is enabled. <5> write data to the txs0 register. data transmission is started. caution take relationship with the other party of communication when setting the port mode register and port register. the relationship between the register settings and pins is shown below. table 13-2. relationship between register settings and pins pin function power0 txe0 rxe0 pm10 p10 pm11 p11 uart0 operation txd0/sck10/p10 rxd0/si10/p11 0 0 0 note note note note stop sck10/p10 si10/p11 0 1 note note 1 reception sck10/p10 rxd0 1 0 0 1 note note transmission txd0 si10/p11 1 1 1 0 1 1 transmission/ reception txd0 rxd0 note can be set as port function. remark : don?t care power0: bit 7 of asynchronous serial interface operation mode register 0 (asim0) txe0: bit 6 of asim0 rxe0: bit 5 of asim0 pm1 : port mode register p1 : port output latch chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 280 (2) communication operation (a) format and waveform example of normal transmit/receive data figures 13-6 and 13-7 show the format and waveform example of the normal transmit/receive data. figure 13-6. format of normal uart transmit/receive data start bit parity bit d0 d1 d2 d3 d4 1 data frame character bits d5 d6 d7 stop bit one data frame consists of the following bits. ? start bit ... 1 bit ? character bits ... 7 or 8 bits (lsb first) ? parity bit ... even parity, odd parity, 0 parity, or no parity ? stop bit ... 1 or 2 bits the character bit length, parity, and stop bit length in one data frame are specified by asynchronous serial interface operation mode register 0 (asim0). figure 13-7. example of normal uart transmit/receive data waveform 1. data length: 8 bits, parity: even pari ty, stop bit: 1 bit, communication data: 55h 1 data frame start d0 d1 d2 d3 d4 d5 d6 d7 parity stop 2. data length: 7 bits, parity: odd parity , stop bit: 2 bits, communication data: 36h 1 data frame start d0 d1 d2 d3 d4 d5 d6 parity stop stop 3. data length: 8 bits, pa rity: none, stop bit: 1 bit, communication data: 87h 1 data frame start d0 d1 d2 d3 d4 d5 d6 d7 stop chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 281 (b) parity types and operation the parity bit is used to detect a bit error in communicati on data. usually, the same type of parity bit is used on both the transmission and reception sides. with even parity and odd parity, a 1-bit (odd number) error can be detected. with zero parity and no parity, an error cannot be detected. (i) even parity ? transmission transmit data, including the parity bit, is controlled so that the number of bits that are ?1? is even. the value of the parity bit is as follows. if transmit data has an odd number of bits that are ?1?: 1 if transmit data has an even number of bits that are ?1?: 0 ? reception the number of bits that are ?1? in the receive dat a, including the parity bit, is counted. if it is odd, a parity error occurs. (ii) odd parity ? transmission unlike even parity, transmit data, including the parity bit, is controlled so that the number of bits that are ?1? is odd. if transmit data has an odd number of bits that are ?1?: 0 if transmit data has an even number of bits that are ?1?: 1 ? reception the number of bits that are ?1? in the receive data, including the parit y bit, is counted. if it is even, a parity error occurs. (iii) 0 parity the parity bit is cleared to 0 when data is transmitted, regardless of the transmit data. the parity bit is not detected when the data is received. therefore, a parity error does not occur regardless of whether the parity bit is ?0? or ?1?. (iv) no parity no parity bit is appended to the transmit data. reception is performed assuming t hat there is no parity bit when data is received. because there is no parity bit, a parity error does not occur. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 282 (c) transmission the t x d0 pin outputs a high level when bit 7 (power0) of asynchronous serial interface operation mode register 0 (asim0) is set to 1. if bit 6 (txe0) of asim0 is then set to 1, transmission is enabled. transmission can be started by writing transmit data to tr ansmit shift register 0 (txs0). the start bit, parity bit, and stop bit are automatica lly appended to the data. when transmission is started, the start bit is output from the t x d0 pin, followed by t he rest of the data in order starting from the lsb. when transmission is co mpleted, the parity and stop bits set by asim0 are appended and a transmission completion inte rrupt request (intst0) is generated. transmission is stopped until the data to be transmitted next is written to txs0. figure 13-8 shows the timing of the transmission comp letion interrupt request (intst0). this interrupt occurs as soon as the last stop bit has been output. caution after transmit data is written to txs0, do not write the next transmit data before the transmission completion interrupt signal (intst0) is generated. figure 13-8. transmission comple tion interrupt request timing 1. stop bit length: 1 intst0 d0 start d1 d2 d6 d7 stop t x d0 (output) parity 2. stop bit length: 2 t x d0 (output) intst0 d0 start d1 d2 d6 d7 parity stop chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 283 (d) reception reception is enabled and the r x d0 pin input is sampled when bit 7 (power0) of asynchronous serial interface operation mode register 0 (asim0) is set to 1 and then bit 5 (rxe0) of asim0 is set to 1. the 5-bit counter of the baud rate generator st arts counting when the falling edge of the r x d0 pin input is detected. when the set value of baud rate generator control register 0 (brgc0) has been counted, the r x d0 pin input is sampled again ( in figure 13-9). if the r x d0 pin is low level at this time, it is recognized as a start bit. when the start bit is detected, recept ion is started, and serial data is sequentially stored in receive shift register 0 (rxs0) at the set baud rate. when the st op bit has been received, the reception completion interrupt (intsr0) is generated and t he data of rxs0 is written to receive buffer register 0 (rxb0). if an overrun error (ove0) occurs, however, the receive data is not written to rxb0. even if a parity error (pe0) occurs while reception is in progress, reception continues to the reception position of the stop bit, and an error interrupt (int sr0) is generated after completion of reception. figure 13-9. reception completi on interrupt request timing r x d0 (input) intsr0 start d0 d1 d2 d3 d4 d5 d6 d7 parity stop rxb0 cautions 1. be sure to read receive buffer register 0 (rxb0) e ven if a reception error occurs. otherwise, an overrun error wil l occur when the next data is received, and the reception error status will persist. 2. reception is always performed with the ?num ber of stop bits = 1? . the second stop bit is ignored. 3. be sure to read asynchro nous serial interface reception e rror status register 0 (asis0) before reading rxb0. chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 284 (e) reception error three types of errors may occur during reception: a parity error, framing error, or ov errun error. if the error flag of asynchronous serial interface reception error st atus register 0 (asis0) is set as a result of data reception, a reception error interrupt request (intsr0) is generated. which error has occurred during reception can be identifi ed by reading the contents of asis0 in the reception error interrupt servicing (intsr0) (see figure 13-3 ). the contents of asis0 are reset to 0 when asis0 is read. table 13-3. cause of reception error reception error cause parity error the parity specifi ed for transmission does not match the parity of the receive data. framing error stop bit is not detected. overrun error reception of the next data is completed before data is read from receive buffer register 0 (rxb0). (f) noise filter of receive data the r x d0 signal is sampled using the base clock output by the prescaler block. if two sampled values are the same, the output of t he match detector changes, and the data is sampled as input data. because the circuit is configured as shown in figure 13- 10, the internal processing of the reception operation is delayed by two clocks from the external signal status. figure 13-10. noise filter circuit internal signal b internal signal a match detector in base clock r x d0/si10/p11 q in ld_en q chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 285 13.4.3 dedicated baud rate generator the dedicated baud rate generator consis ts of a source clock selector and a 5-bit programmable counter, and generates a serial clock for transmission/reception of uart0. separate 5-bit counters are provided for transmission and reception. (1) configuration of ba ud rate generator ? base clock the clock selected by bits 7 and 6 (tps01 and tps00) of baud rate generator control register 0 (brgc0) is supplied to each module when bit 7 (power0) of asyn chronous serial interface operation mode register 0 (asim0) is 1. this clock is called the base clock and its frequency is called f xclk0 . the base clock is fixed to low level when power0 = 0. ? transmission counter this counter stops operation, clear ed to 0, when bit 7 (power0) or bit 6 (txe0) of asynchronous serial interface operation mode register 0 (asim0) is 0. it starts counting when power0 = 1 and txe0 = 1. the counter is cleared to 0 when the first data transmi tted is written to transmit shift register 0 (txs0). ? reception counter this counter stops operation, clear ed to 0, when bit 7 (power0) or bit 5 (rxe0) of asynchronous serial interface operation mode register 0 (asim0) is 0. it starts counting when the start bit has been detected. the counter stops operation after one frame has been received, until the next start bit is detected. figure 13-11. configuration of baud rate generator f xclk0 selector power0 5-bit counter match detector baud rate brgc0: mdl04 to mdl00 1/2 power0, txe0 (or rxe0) brgc0: tps01, tps00 8-bit timer/ event counter 50 output f prs /2 5 f prs /2 f prs /2 3 baud rate generator remark power0: bit 7 of asynchronous serial interface operation mode register 0 (asim0) txe0: bit 6 of asim0 rxe0: bit 5 of asim0 brgc0: baud rate generator control register 0 chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 286 (2) generation of serial clock a serial clock can be generated by using baud rate generator control register 0 (brgc0). select the clock to be input to the 5-bit counter by using bits 7 and 6 (tps01 and tps00) of brgc0. bits 4 to 0 (mdl04 to mdl00) of brgc0 can be used to select the division value of the 5-bit counter. (a) baud rate the baud rate can be calculated by the following expression. ? baud rate = [bps] f xclk0 : frequency of base clock selected by the tps 01 and tps00 bits of the brgc0 register k: value set by the mdl04 to mdl00 bits of t he brgc0 register (k = 8, 9, 10, ..., 31) (b) error of baud rate the baud rate error can be calculated by the following expression. ? error (%) = ? 1 100 [%] cautions 1. keep the baud rate error during transmission to within the permissible error range at the reception destination. 2. make sure that the baud rate error dur ing reception satisfies the range shown in (4) permissible baud rate ra nge during reception. example: frequency of base clock = 2.5 mhz = 2,500,000 hz set value of mdl04 to mdl00 bits of brgc0 register = 10000b (k = 16) target baud rate = 76,800 bps baud rate = 2.5 m/(2 16) = 2,500,000/(2 16) = 78,125 [bps] error = (78,125/76,800 ? 1) 100 = 1.725 [%] f xclk0 2 k actual baud rate (baud rate with error) desired baud rate (correct baud rate) chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 287 (3) example of setting baud rate table 13-4. set data of baud rate generator f prs = 2.0 mhz f prs = 5.0 mhz f prs = 10.0 mhz f prs = 20.0 mhz baud rate [bps] tps01, tps00 k calculated value err [%] tps01, tps00 k calculated value err [%] tps01, tps00 k calculated value err [%] tps01, tps00 k calculated value err [%] 4800 3 26 4808 0.16 3 16 4883 1.73 ? ? ? ? ? ? ? ? 9600 3 13 9615 0.16 3 8 9766 1.73 3 16 9766 1.73 ? ? ? ? 10400 3 12 10417 0.16 2 30 10417 0.16 3 15 10417 0.16 3 30 10417 0.16 19200 1 26 19231 0.16 2 16 19531 1.73 3 8 19531 1.73 3 16 19531 1.73 24000 1 21 23810 ? 0.79 2 13 24038 0.16 2 26 24038 0.16 3 13 24038 0.16 31250 1 16 31250 0 2 10 31250 0 2 20 31250 0 3 10 31250 0 33660 1 15 33333 ? 0.79 2 9 34722 3.34 2 18 34722 3.34 3 9 34722 3.34 38400 1 13 38462 0.16 2 8 39063 1.73 2 16 39063 1.73 3 8 39063 1.73 56000 1 9 55556 ? 0.79 1 22 56818 1.46 2 11 56818 1.46 2 22 56818 1.46 62500 1 8 62500 0 1 20 62500 0 2 10 62500 0 2 20 62500 0 76800 ? ? ? ? 1 16 78125 1.73 2 8 78125 1.73 2 16 78125 1.73 115200 ? ? ? ? 1 11 113636 ? 1.36 1 22 113636 ? 1.36 2 11 113636 ? 1.36 153600 ? ? ? ? 1 8 156250 1.73 1 16 156250 1.73 2 8 156250 1.73 remark tps01, tps00: bits 7 and 6 of baud rate generator control register 0 (brgc0) (setting of base clock (f xclk0 )) k: value set by the mdl04 to mdl00 bits of brgc0 (k = 8, 9, 10, ..., 31) f prs : peripheral hardware clock oscillation frequency err: baud rate error chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 288 (4) permissible baud rate range during reception the permissible error from the baud rate at the trans mission destination during reception is shown below. caution make sure that the baud rate error during reception is within the permissible error range, by using the calculation expression shown below. figure 13-12. permissible baud rate range during reception fl 1 data frame (11 fl) flmin flmax data frame length of uart0 start bit bit 0 bit 1 bit 7 parity bit minimum permissible data frame length maximum permissible data frame length stop bit start bit bit 0 bit 1 bit 7 parity bit latch timing stop bit start bit bit 0 bit 1 bit 7 parity bit stop bit as shown in figure 13-12, the latch timing of the re ceive data is determined by t he counter set by baud rate generator control register 0 (brgc0) a fter the start bit has been detected. if the last data (stop bit) meets this latch timing, the data can be correctly received. assuming that 11-bit data is received, the theoretical values can be calculated as follows. fl = (brate) ? 1 brate: baud rate of uart0 k: set value of brgc0 fl: 1-bit data length margin of latch timing: 2 clocks chapter 13 serial interface uart0 preliminary user?s manual u17473ej1v0ud 289 minimum permissible data frame length: flmin = 11 fl ? fl = fl therefore, the maximum receivable baud rate at the transmission destination is as follows. brmax = (flmin/11) ? 1 = brate similarly, the maximum permissible data fr ame length can be calculated as follows. 10 k + 2 21k ? 2 11 2 k 2 k flmax = fl 11 therefore, the minimum receivable baud rate at the transmission destination is as follows. brmin = (flmax/11) ? 1 = brate the permissible baud rate error between uart0 and the transmission destination can be calculated from the above minimum and maximum baud rate expressions, as follows. table 13-5. maximum/minimum permissible baud rate error division ratio (k) maximum perm issible baud rate error minimu m permissible baud rate error 8 +3.53% ? 3.61% 16 +4.14% ? 4.19% 24 +4.34% ? 4.38% 31 +4.44% ? 4.47% remarks 1. the permissible error of reception depends on t he number of bits in one frame, input clock frequency, and division ratio (k). the higher t he input clock frequency and the higher the division ratio (k), the higher the permissible error. 2. k: set value of brgc0 k ? 2 2k 21k + 2 2k 22k 21k + 2 flmax = 11 fl ? fl = fl 21k ? 2 20k 20k 21k ? 2 preliminary user?s manual u17473ej1v0ud 290 chapter 14 serial interface uart6 14.1 functions of serial interface uart6 serial interface uart6 has the following two modes. (1) operation stop mode this mode is used when serial communication is not executed and can enable a reduction in the power consumption. for details, see 14.4.1 operation stop mode . (2) asynchronous serial interface (uart) mode this mode supports the lin (local interconnect network) -bus. the functions of this mode are outlined below. for details, see 14.4.2 asynchronous seri al interface (uart) mode and 14.4.3 dedicated baud rate generator . ? two-pin configuration t x d6: transmit data output pin r x d6: receive data input pin ? data length of communication data can be selected from 7 or 8 bits. ? dedicated internal 8-bit baud rate generator allowing any baud rate to be set ? transmission and reception can be performed independently. ? twelve operating clock inputs selectable ? msb- or lsb-first communication selectable ? inverted transmission operation ? sync break field transmission from 13 to 20 bits ? more than 11 bits can be identified for sync break field reception (sbf reception flag provided). cautions 1. the t x d6 output inversion function inverts only th e transmission side a nd not the reception side. to use this f unction, the reception side must be ready for reception of inverted data. 2. if clock supply to serial interface uart6 is not stopped (e .g., in the halt mode), normal operation continues. if clock supply to serial interface uart6 is stopped (e.g., in the stop mode), each register stops operating, and hold s the value immediatel y before clock supply was stopped. the t x d6 pin also holds the value imme diately before clock supply was stopped and outputs it. however, the operati on is not guaranteed after clock supply is resumed. therefore, reset the circuit so th at power6 = 0, rxe6 = 0, and txe6 = 0. 3. if data is continuously tr ansmitted, the communicat ion timing from the stop bit to the next start bit is extended two operating clocks of the macro. however, th is does not affect the result of communication because the reception side initializ es the timing when it has detected a start bit. do no t use the continuous transmissi on function if the interface is incorporated in lin. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 291 remark lin stands for local interconnect network and is a low-speed (1 to 20 kbps) serial communication protocol intended to aid the cost reduction of an automotive network. lin communication is single-master communication, and up to 15 slaves can be connected to one master. the lin slaves are used to contro l the switches, actuator s, and sensors, and thes e are connected to the lin master via the lin network. normally, the lin master is connected to a network such as can (controller area network). in addition, the lin bus uses a single-wire method and is connected to the nodes via a transceiver that complies with iso9141. in the lin protocol, the master tr ansmits a frame with baud rate information and the slave receives it and corrects the baud rate error. theref ore, communication is possible when the baud rate error in the slave is 15% or less. figures 14-1 and 14-2 outline the transmissi on and reception operations of lin. figure 14-1. lin transmission operation sleep bus wakeup signal frame 8 bits note 1 55h transmission data transmission data transmission data transmission data transmission 13-bit note 2 sbf transmission note 3 sync break field sync field identifier field data field data field checksum field tx6 intst6 notes 1. the wakeup signal frame is substituted by 80h transmission in the 8-bit mode. 2. the sync break field is output by har dware. the output width is the bit length set by bits 4 to 2 (sbl62 to sbl60) of asynchronous serial inte rface control register 6 (asicl6) (see 14.4.2 (2) (h) sbf transmission ). 3. intst6 is output on completion of each transmissi on. it is also output when sbf is transmitted. remark the interval between each field is controlled by software. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 292 figure 14-2. lin reception operation sleep bus 13 bits note 2 sf reception id reception data reception data reception data reception note 5 note 3 note 1 note 4 wakeup signal frame sync break field sync field identifier field data field data field checksum field rx6 sbf reception reception interrupt (intsr6) edge detection (intp0) capture timer disable enable disable enable notes 1. the wakeup signal is detected at the edge of t he pin, and enables uart6 and sets the sbf reception mode. 2. reception continues until the stop bit is detected. when an sbf wit h low-level data of 11 bits or more has been detected, it is assumed that sbf reception has been completed correctly, and an interrupt signal is output. if an sbf with low-leve l data of less than 11 bits has been detected, it is assumed that an sbf reception error has occurred. the interrupt signal is not output and the sbf reception mode is restored. 3. if sbf reception has been completed correctly, an interrupt signal is output. this sbf reception completion interrupt enables the capture timer. detection of errors ove6, pe6, and fe6 is suppressed, and error detection processing of ua rt communication and data transfer of the shift register and rxb6 is not performed. the shift register holds the reset value ffh. 4. calculate the baud rate error from the bit length of the sync field, disable uart6 after sf reception, and then re-set baud rate generator control register 6 (brgc6). 5. distinguish the checksum field by software. also perform processi ng by software to initialize uart6 after reception of the checksum field an d to set the sbf reception mode again. to perform a lin receive operation, use a conf iguration like the one shown in figure 14-3. the wakeup signal transmitted from the lin master is received by detecting the edge of the external interrupt (intp0). the length of the sync field transmitted from the lin master can be measured using the external event capture operation of 16-bit timer/event counte r 00, and the baud rate error can be calculated. the input source of the reception port input (rxd6) c an be input to the external interrupt (intp0) and 16-bit timer/event counter 00 by port input switch control (isc0/isc1), without co nnecting rxd6 and intp0/ti000 externally. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 293 figure 14-3. port configurati on for lin reception operation rxd6 input intp0 input ti000 input p14/rxd6 p120/intp0 p00/ti000 port input switch control (isc0) chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 294 14.2 configuration of serial interface uart6 serial interface uart6 includes the following hardware. table 14-1. configurati on of serial interface uart6 item configuration registers receive buffer register 6 (rxb6) receive shift register 6 (rxs6) transmit buffer register 6 (txb6) transmit shift register 6 (txs6) control registers asynchronous serial interface o peration mode register 6 (asim6) asynchronous serial interface recepti on error status register 6 (asis6) asynchronous serial interface transm ission status register 6 (asif6) clock selection register 6 (cksr6) baud rate generator control register 6 (brgc6) asynchronous serial interface control register 6 (asicl6) input switch control register (isc) port mode register 1 (pm1) port register 1 (p1) chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 295 figure 14-4. block diagram of serial interface uart6 internal bus asynchronous serial interface control register 6 (asicl6) transmit buffer register 6 (txb6) transmit shift register 6 (txs6) t x d6/ p13 intst6 baud rate generator asynchronous serial interface control register 6 (asicl6) reception control receive shift register 6 (rxs6) receive buffer register 6 (rxb6) r x d6/ p14 ti000, intp0 note intsr6 baud rate generator filter intsre6 asynchronous serial interface reception error status register 6 (asis6) asynchronous serial interface operation mode register 6 (asim6) asynchronous serial interface transmission status register 6 (asif6) transmission control registers f prs f prs /2 f prs /2 2 f prs /2 3 f prs /2 4 f prs /2 5 f prs /2 6 f prs /2 7 f prs /2 8 f prs /2 9 f prs /2 10 8-bit timer/ event counter 50 output 8 reception unit transmission unit clock selection register 6 (cksr6) baud rate generator control register 6 (brgc6) output latch (p13) pm13 8 selector note selectable with input switch control register (isc). chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 296 (1) receive buffer register 6 (rxb6) this 8-bit register stores parallel data conv erted by receive shift register 6 (rxs6). each time 1 byte of data has been received, new receive data is transferred to this register from rxs6. if the data length is set to 7 bits, data is transferred as follows. ? in lsb-first reception, the receive data is transferred to bits 0 to 6 of rxb6 and the msb of rxb6 is always 0. ? in msb-first reception, the receive data is transferred to bits 1 to 7 of rxb6 and the lsb of rxb6 is always 0. if an overrun error (ove6) occurs, the rece ive data is not transferred to rxb6. rxb6 can be read by an 8-bit memory manipulation inst ruction. no data can be written to this register. reset input sets this register to ffh. (2) receive shift register 6 (rxs6) this register converts the serial data input to the r x d6 pin into parallel data. rxs6 cannot be directly manipulated by a program. (3) transmit buffer register 6 (txb6) this buffer register is used to set transmit data. tr ansmission is started when data is written to txb6. this register can be read or written by an 8-bit memory manipulation instruction. reset input sets this register to ffh. cautions 1. do not write data to txb6 when bi t 1 (txbf6) of asynchronous serial interface transmission status register 6 (asif6) is 1. 2. do not refresh (write the same value to) txb6 by software during a communication operation (when bit 7 (power6) and bit 6 (txe6) of asynchr onous serial interface operation mode register 6 (asim6) are 1 or when bit 7 (power6) and bit 5 (rxe6) of asim6 are 1). (4) transmit shift register 6 (txs6) this register transmits the data transferred from txb6 from the t x d6 pin as serial data. data is transferred from txb6 immediately after txb6 is written for the first tr ansmission, or immediately before intst6 occurs after one frame was transmitted for continuous transmission. da ta is transferred from txb6 and transmitted from the t x d6 pin at the falling edge of the base clock. txs6 cannot be directly manipulated by a program. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 297 14.3 registers controlling serial interface uart6 serial interface uart6 is controlle d by the following nine registers. ? asynchronous serial interface operation mode register 6 (asim6) ? asynchronous serial interface recept ion error status register 6 (asis6) ? asynchronous serial interface transmission status register 6 (asif6) ? clock selection register 6 (cksr6) ? baud rate generator control register 6 (brgc6) ? asynchronous serial interface control register 6 (asicl6) ? input switch control register (isc) ? port mode register 1 (pm1) ? port register 1 (p1) (1) asynchronous serial interface ope ration mode register 6 (asim6) this 8-bit register controls the serial comm unication operations of serial interface uart6. this register can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to 01h. remark asim6 can be refreshed (the same value is wr itten) by software during a communication operation (when bit 7 (power6) and bit 6 (txe6) of asim6 = 1 or bit 7 (power6) and bit 5 (rxe6) of asim6 = 1). figure 14-5. format of asynchronous serial inte rface operation mode register 6 (asim6) (1/2) address: ff50h after reset: 01h r/w symbol <7> <6> <5> 4 3 2 1 0 asim6 power6 txe6 rxe6 ps61 ps60 cl6 sl6 isrm6 power6 enables/disables operati on of internal operation clock 0 note 1 disables operation of the internal operation clock (fixes the clock to low level) and asynchronously resets the internal circuit note 2 . 1 note 3 enables operation of the internal operation clock txe6 enables/disables transmission 0 disables transmission (synchronously resets th e transmission circuit). 1 enables transmission notes 1. the output of the t x d6 pin goes high and the input from the r x d6 pin is fixed to the high level when power6 = 0. 2. asynchronous serial interface reception error status register 6 (asis6), asynchronous serial interface transmission status register 6 (asif6), bit 7 ( sbrf6) and bit 6 (sbrt6) of asynchronous serial interface control register 6 (asicl6), and receive buffer register 6 (rxb6) are reset. 3. operation of the 8-bit counter out put is enabled at the second base clock after 1 is written to the power6 bit. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 298 figure 14-5. format of asynchronous serial inte rface operation mode register 6 (asim6) (2/2) rxe6 enables/disables reception 0 disables reception (synchronous ly resets the reception circuit). 1 enables reception ps61 ps60 transmission oper ation reception operation 0 0 does not output parity bit. reception without parity 0 1 outputs 0 parity. reception as 0 parity note 1 0 outputs odd parity. judges as odd parity. 1 1 outputs even parity. judges as even parity. cl6 specifies character length of transmit/receive data 0 character length of data = 7 bits 1 character length of data = 8 bits sl6 specifies number of stop bits of transmit data 0 number of stop bits = 1 1 number of stop bits = 2 isrm6 enables/disables occurr ence of reception completion interrupt in case of error 0 ?intsre6? occurs in case of error (at this time, intsr6 does not occur). 1 ?intsr6? occurs in case of error (at this time, intsre6 does not occur). note if ?reception as 0 parity? is selected, the parity is not judged. therefore, bit 2 (pe6) of asynchronous serial interface reception error status register 6 (asis6) is not set and the error interrupt does not occur. cautions 1. at startup, set power6 to 1 and then set txe6 to 1. to stop the op eration, clear txe6 to 0, and then clear power6 to 0. 2. at startup, set power6 to 1 and then set rxe6 to 1. to stop the operation, clear rxe6 to 0, and then clear power6 to 0. 3. set power6 to 1 and then set rxe6 to 1 wh ile a high level is input to the rxd6 pin. if power6 is set to 1 and rxe6 is set to 1 wh ile a low level is input, reception is started. 4. clear the txe6 and rxe6 bits to 0 be fore rewriting the ps61, ps60, and cl6 bits. 5. fix the ps61 and ps60 bits to 0 when mounting the device on lin. 6. make sure that txe6 = 0 wh en rewriting the sl6 bit. recep tion is always performed with ?the number of stop bits = 1?, and therefore, is not affected by the set value of the sl6 bit. 7. make sure that rxe6 = 0 when rewriting the isrm6 bit. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 299 (2) asynchronous serial interface recepti on error status register 6 (asis6) this register indicates an error status on completion of re ception by serial interface uart6. it includes three error flag bits (pe6, fe6, ove6). this register is read-only by an 8-bit memory manipulation instruction. reset input clears this register to 00h if bit 7 (power 6) and bit 5 (rxe6) of asim6 = 0. 00h is read when this register is read. figure 14-6. format of asynchronous serial inte rface reception error status register 6 (asis6) address: ff53h after reset: 00h r symbol 7 6 5 4 3 2 1 0 asis6 0 0 0 0 0 pe6 fe6 ove6 pe6 status flag indicating parity error 0 if power6 = 0 and rxe6 = 0, or if asis6 register is read 1 if the parity of transmit data does not match the parity bit on completion of reception fe6 status flag indicating framing error 0 if power6 = 0 and rxe6 = 0, or if asis6 register is read 1 if the stop bit is not detected on completion of reception ove6 status flag indicating overrun error 0 if power6 = 0 and rxe6 = 0, or if asis6 register is read 1 if receive data is set to the rxb6 register and the next reception operation is completed before the data is read. cautions 1. the operation of the pe6 bit differs depending on the set values of the ps61 and ps60 bits of asynchronous serial interface operati on mode register 6 (asim6). 2. the first bit of the receive da ta is checked as the stop bit, regardless of the number of stop bits. 3. if an overrun error occurs , the next receive data is not wr itten to receive buffer register 6 (rxb6) but discarded. 4. if data is read from asis6, a wait cycle is generated. do not read data from asis6 when the cpu is operating on the subsystem clock and th e peripheral hardware clock is stopped. for details, see chapter 31 cautions for wait. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 300 (3) asynchronous serial interface tran smission status register 6 (asif6) this register indicates the status of transmission by se rial interface uart6. it includes two status flag bits (txbf6 and txsf6). transmission can be continued without disruption even during an interrupt period, by writing the next data to the txb6 register after data has been transferred from the txb6 register to the txs6 register. this register is read-only by an 8-bit memory manipulation instruction. reset input clears this register to 00h if bi t 7 (power6) and bit 6 (txe6) of asim6 = 0. figure 14-7. format of asynchronous serial in terface transmission status register 6 (asif6) address: ff55h after reset: 00h r symbol 7 6 5 4 3 2 1 0 asif6 0 0 0 0 0 0 txbf6 txsf6 txbf6 transmit buffer data flag 0 if power6 = 0 or txe6 = 0, or if data is tr ansferred to transmit shift register 6 (txs6) 1 if data is written to transmit buffer register 6 (txb6) (if data exists in txb6) txsf6 transmit shift register data flag 0 if power6 = 0 or txe6 = 0, or if the next data is not transferred from transmit buffer register 6 (txb6) after completion of transfer 1 if data is transferred from transmit buffer regist er 6 (txb6) (if data transmi ssion is in progress) cautions 1. to transmit data conti nuously, write the first transmit data (first byte) to the txb6 register. be sure to check that the txbf6 fl ag is ?0?. if so, write the next transmit data (second byte) to the txb6 register. if data is written to th e txb6 register while the txbf6 flag is ?1?, the transmit data cannot be guaranteed. 2. to initialize the transmission unit upon comple tion of continuous transmission, be sure to check that the txsf6 flag is ?0 ? after generation of the tran smission completion interrupt, and then execute initializat ion. if initiali zation is executed while the txsf6 flag is ?1?, the transmit data cannot be guaranteed. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 301 (4) clock selection register 6 (cksr6) this register selects the base cl ock of serial interface uart6. cksr6 can be set by an 8-bit memory manipulation instruction. reset input clears this register to 00h. remark cksr6 can be refreshed (the same value is written) by software during a communication operation (when bit 7 (power6) and bit 6 (txe6) of asim6 = 1 or bit 7 (power6) and bit 5 (rxe6) of asim6 = 1). figure 14-8. format of clock selection register 6 (cksr6) address: ff56h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 cksr6 0 0 0 0 tps63 tps62 tps61 tps60 base clock (f xclk6 ) selection tps63 tps62 tps61 tps60 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz 0 0 0 0 f prs 2 mhz 5 mhz 10 mhz 20 mhz 0 0 0 1 f prs /2 1 mhz 2.5 mhz 5 mhz 10 mhz 0 0 1 0 f prs /2 2 500 khz 1.25 mhz 2.5 mhz 5 mhz 0 0 1 1 f prs /2 3 250 khz 625 khz 1.25 mhz 2.5 mhz 0 1 0 0 f prs /2 4 125 khz 312.5 khz 625 khz 1.25 mhz 0 1 0 1 f prs /2 5 62.5 khz 156.25 khz 312.5 khz 625 khz 0 1 1 0 f prs /2 6 31.25 khz 78.13 khz 156.25 khz 312.5 khz 0 1 1 1 f prs /2 7 15.625 khz 39.06 khz 78.13 khz 156.25 khz 1 0 0 0 f prs /2 8 7.813 khz 19.53 khz 39.06 khz 78.13 khz 1 0 0 1 f prs /2 9 3.906 khz 9.77 khz 19.53 khz 39.06 khz 1 0 1 0 f prs /2 10 1.953 khz 4.88 khz 9.77 khz 19.53 khz 1 0 1 1 tm50 output note other than above setting prohibited note note the following points when selecting the tm50 output as the base clock. ? pwm mode (tmc506 = 1) start the operation of 8-bit timer/ event counter 50 first and then set t he count clock to make the duty = 50%. ? mode in which the count clock is cleared and started upon a match of tm50 and cr50 (tmc506 = 0) start the operation of 8-bit timer/ event counter 50 first and then enable the timer f/f inversion operation (tmc501 = 1). it is not necessary to enable the to50 pin as a timer output pin in any mode. caution make sure power6 = 0 wh en rewriting tps63 to tps60. remarks 1. f prs : peripheral hardware clock oscillation frequency 2. tmc506: bit 6 of 8-bit timer mode control register 50 (tmc50) tmc501: bit 1 of tmc50 chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 302 (5) baud rate generator c ontrol register 6 (brgc6) this register sets the division value of t he 8-bit counter of serial interface uart6. brgc6 can be set by an 8-bit memory manipulation instruction. reset input sets this register to ffh. remark brgc6 can be refreshed (the same value is written) by software during a communication operation (when bit 7 (power6) and bit 6 (txe6) of asim6 = 1 or bit 7 (power6) and bit 5 (rxe6) of asim6 = 1). figure 14-9. format of baud rate ge nerator control register 6 (brgc6) address: ff57h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 brgc6 mdl67 mdl66 mdl65 mdl64 mdl63 mdl62 mdl61 mdl60 mdl67 mdl66 mdl65 mdl64 mdl63 mdl62 mdl61 mdl60 k output clock selection of 8-bit counter 0 0 0 0 0 setting prohibited 0 0 0 0 1 0 0 0 8 f xclk6 /8 0 0 0 0 1 0 0 1 9 f xclk6 /9 0 0 0 0 1 0 1 0 10 f xclk6 /10 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 1 1 1 1 0 0 252 f xclk6 /252 1 1 1 1 1 1 0 1 253 f xclk6 /253 1 1 1 1 1 1 1 0 254 f xclk6 /254 1 1 1 1 1 1 1 1 255 f xclk6 /255 cautions 1. make sure that bit 6 (txe6) and bit 5 (rxe6) of the asim6 register = 0 when rewriting the mdl67 to mdl60 bits. 2. the baud rate is the output clo ck of the 8-bit counter divided by 2. remarks 1. f xclk6 : frequency of base clock selected by the t ps63 to tps60 bits of cksr6 register 2. k: value set by mdl67 to mdl60 bits (k = 8, 9, 10, ..., 255) 3. : don?t care chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 303 (6) asynchronous serial interface control register 6 (asicl6) this register controls the serial communicati on operations of serial interface uart6. asicl6 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to 16h. caution asicl6 can be refreshed (the same value is written) by software during a communication operation (when bit 7 (power6) and bit 6 (txe6) of asim6 = 1 or bit 7 (power6) and bit 5 (rxe6) of asim6 = 1). however, do not set bot h sbrt6 and sbtt6 to 1 by a refresh operation during sbf reception (sbrf6 = 1) or sbf transm ission (until intst6 o ccurs since sbtt6 has been set (1)), because it may re-trigge r sbf reception or sbf transmission. figure 14-10. format of asynchronous serial interface control register 6 (asicl6) (1/2) address: ff58h after reset: 16h r/w note symbol <7> <6> 5 4 3 2 1 0 asicl6 sbrf6 sbrt6 sbtt6 sbl62 sbl61 sbl60 dir6 txdlv6 sbrf6 sbf reception status flag 0 if power6 = 0 and rxe6 = 0 or if sbf reception has been completed correctly 1 sbf reception in progress sbrt6 sbf reception trigger 0 ? 1 sbf reception trigger sbtt6 sbf transmission trigger 0 ? 1 sbf transmission trigger note bit 7 is read-only. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 304 figure 14-10. format of asynchronous serial interface control register 6 (asicl6) (2/2) sbl62 sbl61 sbl60 sbf transmission output width control 1 0 1 sbf is output with 13-bit length. 1 1 0 sbf is output with 14-bit length. 1 1 1 sbf is output with 15-bit length. 0 0 0 sbf is output with 16-bit length. 0 0 1 sbf is output with 17-bit length. 0 1 0 sbf is output with 18-bit length. 0 1 1 sbf is output with 19-bit length. 1 0 0 sbf is output with 20-bit length. dir6 first-bit specification 0 msb 1 lsb txdlv6 enables/disables inverting t x d6 output 0 normal output of t x d6 1 inverted output of t x d6 cautions 1. in the case of an sbf reception error, the mode return s to the sbf reception mode. the status of the sbrf6 flag is held (1). 2. before setting the sbrt6 bit, make sure that bit 7 (power6) and bit 5 (rxe6) of asim6 = 1. after setting the sbrt6 bit to 1, do not clear it to 0 before sbf reception is completed (before an interrupt request signal is generated). 3. the read value of the sbrt6 bit is always 0. sbrt6 is auto matically cleared to 0 after sbf reception has been co rrectly completed. 4. before setting the sbtt6 bit to 1, make sure that bit 7 (pow er6) and bit 6 (txe6) of asim6 = 1. after setting the sbtt6 bit to 1, do not clear it to 0 before sbf transmission is completed (before an interrupt requ est signal is generated). 5. the read value of the sbtt6 bit is always 0. sbtt6 is automatically clear ed to 0 at the end of sbf transmission. 6. before rewriting the dir6 and txdlv6 bits, clear the txe6 a nd rxe6 bits to 0. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 305 (7) input switch control register (isc) the input switch control regi ster (isc) is used to receive a status si gnal transmitted from the master during lin (local interconnect network) reception. t he input source is switched by setting isc. this register can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. figure 14-11. format of input s witch control register (isc) address: ff4fh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 isc 0 0 0 0 0 0 isc1 isc0 isc1 ti000 input source selection 0 ti000 (p00) 1 rxd6 (p14) isc0 intp0 input source selection 0 intp0 (p120) 1 rxd6 (p14) (8) port mode register 1 (pm1) this register sets port 1 input/output in 1-bit units. when using the p13/txd6 pin for serial interface data output, clear pm13 to 0 and set the output latch of p13 to 1. when using the p14/rxd6 pin for serial interface data input, set pm14 to 1. the output la tch of p14 at this time may be 0 or 1. pm1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to ffh. figure 14-12. format of port mode register 1 (pm1) address: ff21h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm1 pm17 pm16 pm15 pm14 pm13 pm12 pm11 pm10 pm1n p1n pin i/o mode selection (n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 306 14.4 operation of serial interface uart6 serial interface uart6 has the following two modes. ? operation stop mode ? asynchronous serial interface (uart) mode 14.4.1 operation stop mode in this mode, serial communication cannot be executed; theref ore, the power consumption can be reduced. in addition, the pins can be used as ordinary po rt pins in this mode. to set the operation stop mode, clear bits 7, 6, and 5 (power6, txe6, and rxe6) of asim6 to 0. (1) register used the operation stop mode is set by asynchronous serial interface operation mode register 6 (asim6). asim6 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets this register to 01h. address: ff50h after reset: 01h r/w symbol <7> <6> <5> 4 3 2 1 0 asim6 power6 txe6 rxe6 ps61 ps60 cl6 sl6 isrm6 power6 enables/disables operati on of internal operation clock 0 note 1 disables operation of the internal operation clock (fixes the clock to low level) and asynchronously resets the internal circuit note 2 . txe6 enables/disables transmission 0 disables transmission o peration (synchronously resets the transmission circuit). rxe6 enables/disables reception 0 disables reception (synchronous ly resets the reception circuit). notes 1. the output of the t x d6 pin goes high and the input from the r x d6 pin is fixed to high level when power6 = 0. 2. asynchronous serial interface reception error status register 6 (asis6), asynchronous serial interface transmission status register 6 (asif6), bit 7 ( sbrf6) and bit 6 (sbrt6) of asynchronous serial interface control register 6 (asicl6), and receive buffer register 6 (rxb6) are reset. caution clear power6 to 0 after clearing txe6 and rxe6 to 0 to set the operation stop mode. to start the operation, set power6 to 1, and then set txe6 and rxe6 to 1. remark to use the rxd6/p14 and txd6/p13 pins as general-purpose port pins, see chapter 4 port functions . chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 307 14.4.2 asynchronous serial interface (uart) mode in this mode, data of 1 byte is transmitted/received following a start bit, and a full-duplex operation can be performed. a dedicated uart baud rate generator is incorporated, so that communication can be executed at a wide range of baud rates. (1) registers used ? asynchronous serial interface operation mode register 6 (asim6) ? asynchronous serial interface recept ion error status register 6 (asis6) ? asynchronous serial interface transmission status register 6 (asif6) ? clock selection register 6 (cksr6) ? baud rate generator control register 6 (brgc6) ? asynchronous serial interface control register 6 (asicl6) ? input switch control register (isc) ? port mode register 1 (pm1) ? port register 1 (p1) the basic procedure of setting an operatio n in the uart mode is as follows. <1> set the cksr6 register (see figure 14-8 ). <2> set the brgc6 register (see figure 14-9 ). <3> set bits 0 to 4 (isrm6, sl6, cl6, ps60, ps61) of the asim6 register (see figure 14-5 ). <4> set bits 0 and 1 (txdlv6, di r6) of the asicl6 register (see figure 14-10 ). <5> set bit 7 (power6) of the asim6 register to 1. <6> set bit 6 (txe6) of the asim6 register to 1. transmission is enabled. set bit 5 (rxe6) of the asim6 register to 1. reception is enabled. <7> write data to transmit buffer register 6 (txb6). data transmission is started. caution take relationship with the other party of communication when setting the port mode register and port register. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 308 the relationship between the register settings and pins is shown below. table 14-2. relationship between register settings and pins pin function power6 txe6 rxe6 pm13 p13 pm14 p14 uart6 operation txd6/p13 rxd6/p14 0 0 0 note note note note stop p13 p14 0 1 note note 1 reception p13 rxd6 1 0 0 1 note note transmission txd6 p14 1 1 1 0 1 1 transmission/ reception txd6 rxd6 note can be set as port function. remark : don?t care power6: bit 7 of asynchronous serial interface operation mode register 6 (asim6) txe6: bit 6 of asim6 rxe6: bit 5 of asim6 pm1 : port mode register p1 : port output latch chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 309 (2) communication operation (a) format and waveform example of normal transmit/receive data figures 14-13 and 14-14 show the format and waveform example of the normal transmit/receive data. figure 14-13. format of normal uart transmit/receive data 1. lsb-first transmission/reception start bit parity bit d0 d1 d2 d3 d4 1 data frame character bits d5 d6 d7 stop bit 2. msb-first transmission/reception start bit parity bit d7 d6 d5 d4 d3 1 data frame character bits d2 d1 d0 stop bit one data frame consists of the following bits. ? start bit ... 1 bit ? character bits ... 7 or 8 bits ? parity bit ... even parity, odd parity, 0 parity, or no parity ? stop bit ... 1 or 2 bits the character bit length, parity, and stop bit length in one data frame are specified by asynchronous serial interface operation mode register 6 (asim6). whether data is communicated with the lsb or msb first is specified by bit 1 (dir6) of asynchronous serial interface control register 6 (asicl6). whether the t x d6 pin outputs normal or inverted data is s pecified by bit 0 (txdlv6) of asicl6. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 310 figure 14-14. example of normal uart transmit/receive data waveform 1. data length: 8 bits, lsb first, parity: even parity, stop bit: 1 bit, communication data: 55h 1 data frame start d0 d1 d2 d3 d4 d5 d6 d7 parity stop 2. data length: 8 bits, msb first, parity: even parity, stop bit: 1 bit, communication data: 55h 1 data frame start d7 d6 d5 d4 d3 d2 d1 d0 parity stop 3. data length: 8 bits, msb first, parity: even parity, stop bit: 1 bit, communication data: 55h, t x d6 pin inverted output 1 data frame start d7 d6 d5 d4 d3 d2 d1 d0 parity stop 4. data length: 7 bits, lsb first, parity: o dd parity, stop bit: 2 bits, communication data: 36h 1 data frame start d0 d1 d2 d3 d4 d5 d6 parity stop stop 5. data length: 8 bits, lsb first, parity: none, stop bit: 1 bit, communication data: 87h 1 data frame start d0 d1 d2 d3 d4 d5 d6 d7 stop chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 311 (b) parity types and operation the parity bit is used to detect a bit error in communicati on data. usually, the same type of parity bit is used on both the transmission and reception sides. with even parity and odd parity, a 1-bit (odd number) error can be detected. with zero parity and no parity, an error cannot be detected. caution fix the ps61 and ps60 bits to 0 wh en the device is inco rporated in lin. (i) even parity ? transmission transmit data, including the parity bit, is controlled so that the number of bits that are ?1? is even. the value of the parity bit is as follows. if transmit data has an odd number of bits that are ?1?: 1 if transmit data has an even number of bits that are ?1?: 0 ? reception the number of bits that are ?1? in the receive dat a, including the parity bit, is counted. if it is odd, a parity error occurs. (ii) odd parity ? transmission unlike even parity, transmit data, including the parity bit, is controlled so that the number of bits that are ?1? is odd. if transmit data has an odd number of bits that are ?1?: 0 if transmit data has an even number of bits that are ?1?: 1 ? reception the number of bits that are ?1? in the receive data, including the parit y bit, is counted. if it is even, a parity error occurs. (iii) 0 parity the parity bit is cleared to 0 when data is transmitted, regardless of the transmit data. the parity bit is not detected when the data is received. therefore, a parity error does not occur regardless of whether the parity bit is ?0? or ?1?. (iv) no parity no parity bit is appended to the transmit data. reception is performed assuming t hat there is no parity bit when data is received. because there is no parity bit, a parity error does not occur. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 312 (c) normal transmission the t x d6 pin outputs a high level when bit 7 (power6) of asynchronous serial interface operation mode register 6 (asim6) is set to 1. if bit 6 (txe6) of asim6 is then set to 1, transmission is enabled. transmission can be started by writing transmit data to tr ansmit buffer register 6 (txb6). the start bit, parity bit, and stop bit are automatica lly appended to the data. when transmission is started, the data in txb6 is transferred to transmit sh ift register 6 (txs6). after that, the data is sequentially out put from txs6 to the t x d6 pin. when transmission is completed, the parity and stop bits set by asim6 are appended and a transmission co mpletion interrupt reques t (intst6) is generated. transmission is stopped until the data to be transmitted next is written to txb6. figure 14-15 shows the timing of the transmission comp letion interrupt request (intst6). this interrupt occurs as soon as the last stop bit has been output. figure 14-15. normal transmission comp letion interrupt request timing 1. stop bit length: 1 intst6 d0 start d1 d2 d6 d7 stop t x d6 (output) parity 2. stop bit length: 2 t x d6 (output) intst6 d0 start d1 d2 d6 d7 parity stop chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 313 (d) continuous transmission the next transmit data can be written to transmit buffer re gister 6 (txb6) as soon as transmit shift register 6 (txs6) has started its shift operation. consequently, even while the intst6 interrupt is being serviced after transmission of one data frame, data can be continuously transmitted and an efficient communication rate can be realized. in addition, the txb6 register can be e fficiently written twice (2 bytes) without having to wait for the transmission time of one data frame, by readi ng bit 0 (txsf6) of asynchronous serial interface transmission status register 6 (asif6) when the transmission completion interrupt has occurred. to transmit data continuously, be sure to reference t he asif6 register to check the transmission status and whether the txb6 register can be written, and then write the data. cautions 1. the txbf6 and txsf6 flags of the asif6 register change from ?10? to ?11?, and to ?01? during continuous transmission. to check the status, therefore, do not use a combination of the txbf6 a nd txsf6 flags for judgment. read only the txbf6 flag when executing continuous transmission. 2. when the device is incorp orated in a lin, the continuous transmission function cannot be used. make sure that a synchronous serial interface tran smission status register 6 (asif6) is 00h before writin g transmit data to transmit buffer register 6 (txb6). txbf6 writing to txb6 register 0 writing enabled 1 writing disabled caution to transmit data continuously, write the first transmit data (fi rst byte) to the txb6 register. be sure to check that the txbf6 fl ag is ?0?. if so, write the next transmit da ta (second byte) to the txb6 register. if data is written to the txb6 register while the txbf6 flag is ?1?, the transmit data cannot be guaranteed. the communication status can be checked using the txsf6 flag. txsf6 transmission status 0 transmission is completed. 1 transmission is in progress. cautions 1. to initialize the transm ission unit upon completion of continuous transmission, be sure to check that the txsf 6 flag is ?0? after generation of the transmission completion interrupt, and then execute initialization. if initialization is executed while the txsf6 flag is ?1?, the transmit data cannot be guaranteed. 2. during continuous transmission, an ove rrun error may occur, which means that the next transmission was completed before exe cution of intst6 interrupt servicing after transmission of one data frame. an ove rrun error can be detected by developing a program that can count the number of transmit data and by refere ncing the txsf6 flag. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 314 figure 14-16 shows an example of the continuous transmission processing flow. figure 14-16. example of contin uous transmission processing flow write txb6. set registers. write txb6. transfer executed necessary number of times? yes read asif6 txbf6 = 0? no no yes transmission completion interrupt occurs? read asif6 txsf6 = 0? no no no yes yes yes yes completion of transmission processing transfer executed necessary number of times? remark txb6: transmit buffer register 6 asif6: asynchronous serial interface transmission status register 6 txbf6: bit 1 of asif6 (transmit buffer data flag) txsf6: bit 0 of asif6 (trans mit shift register data flag) chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 315 figure 14-17 shows the timing of starting continuous transmission, and figure 14-18 shows the timing of ending continuous transmission. figure 14-17. timing of starting continuous transmission t x d6 start intst6 data (1) data (1) data (2) data (3) data (2) data (1) data (3) ff ff parity stop data (2) parity stop txb6 txs6 txbf6 txsf6 start start note note when asif6 is read, there is a period in which t xbf6 and txsf6 = 1, 1. therefore, judge whether writing is enabled using only the txbf6 bit. remark t x d6: t x d6 pin (output) intst6: interrupt request signal txb6: transmit buffer register 6 txs6: transmit shift register 6 asif6: asynchronous serial interface transmission status register 6 txbf6: bit 1 of asif6 txsf6: bit 0 of asif6 chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 316 figure 14-18. timing of ending continuous transmission t x d6 start intst6 data (n ? 1) data (n ? 1) data (n) data (n) data (n ? 1) ff parity stop stop data (n) parity stop txb6 txs6 txbf6 txsf6 power6 or txe6 start remark t x d6: t x d6 pin (output) intst6: interrupt request signal txb6: transmit buffer register 6 txs6: transmit shift register 6 asif6: asynchronous serial interface transmission status register 6 txbf6: bit 1 of asif6 txsf6: bit 0 of asif6 power6: bit 7 of asynchronous serial interface operation mode register (asim6) txe6: bit 6 of asynchronous serial interface operation mode register (asim6) chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 317 (e) normal reception reception is enabled and the r x d6 pin input is sampled when bit 7 (power6) of asynchronous serial interface operation mode register 6 (asim6) is set to 1 and then bit 5 (rxe6) of asim6 is set to 1. the 8-bit counter of the baud rate generator st arts counting when the falling edge of the r x d6 pin input is detected. when the set value of baud rate generator control register 6 (brgc6) has been counted, the r x d6 pin input is sampled again ( in figure 14-19). if the r x d6 pin is low level at this time, it is recognized as a start bit. when the start bit is detected, receptio n is started, and serial data is sequ entially stored in the receive shift register (rxs6) at the set baud rate. when the stop bi t has been received, the reception completion interrupt (intsr6) is generated and the data of rxs6 is written to receive buffer register 6 (rxb6). if an overrun error (ove6) occurs, however, the receiv e data is not written to rxb6. even if a parity error (pe6) occurs while reception is in progress, reception continues to the reception position of the stop bit, and an error interrupt (intsr6 /intsre6) is generated on completion of reception. figure 14-19. reception completi on interrupt request timing r x d6 (input) intsr6 start d0 d1 d2 d3 d4 d5 d6 d7 parity rxb6 stop cautions 1. be sure to read receive buffer register 6 (rxb6) e ven if a reception error occurs. otherwise, an overrun error wil l occur when the next data is received, and the reception error status will persist. 2. reception is always performed with the ?num ber of stop bits = 1? . the second stop bit is ignored. 3. be sure to read asynchro nous serial interface reception e rror status register 6 (asis6) before reading rxb6. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 318 (f) reception error three types of errors may occur during reception: a parity error, framing error, or ov errun error. if the error flag of asynchronous serial interface reception error st atus register 6 (asis6) is set as a result of data reception, a reception error interrupt r equest (intsr6/intsre6) is generated. which error has occurred during reception can be identifi ed by reading the contents of asis6 in the reception error interrupt servicing (intsr6/intsre6) (see figure 14-6 ). the contents of asis6 are reset to 0 when asis6 is read. table 14-3. cause of reception error reception error cause parity error the parity specifi ed for transmission does not match the parity of the receive data. framing error stop bit is not detected. overrun error reception of the next data is completed before data is read from receive buffer register 6 (rxb6). the error interrupt can be separated into reception completion interrupt (intsr6) and error interrupt (intsre6) by clearing bit 0 (isrm6) of asynchronous se rial interface operation mode register 6 (asim6) to 0. figure 14-20. reception error interrupt 1. if isrm6 is cleared to 0 (recep tion completion interr upt (intsr6) and error interrupt (intsre6) are separated) (a) no error during recepti on (b) error during reception intsr6 intsre6 intsr6 intsre6 2. if isrm6 is set to 1 (error interrupt is included in intsr6) (a) no error during recepti on (b) error during reception intsre6 intsr6 intsre6 intsr6 chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 319 (g) noise filter of receive data the rxd6 signal is sampled with the base clock output by the prescaler block. if two sampled values are the same, the output of t he match detector changes, and the data is sampled as input data. because the circuit is configured as shown in figure 14- 21, the internal processing of the reception operation is delayed by two clocks from the external signal status. figure 14-21. noise filter circuit internal signal b internal signal a match detector in base clock r x d6/p14 q in ld_en q (h) sbf transmission when the device is incorporated in li n, the sbf (synchronous break fiel d) transmission control function is used for transmission. for the tr ansmission operation of lin, see figure 14-1 lin transmission operation . when bit 7 (power6) of asynchronous serial interface mode register 6 (asim6) is set to 1, the txd6 pin outputs high level. next, when bit 6 (txe6) of asim6 is set to 1, the transmission e nabled status is entered, and sbf transmission is started by setting bit 5 (sbtt6) of asynchronous serial interface control register 6 (asicl6) to 1. thereafter, a low level of bits 13 to 20 (set by bits 4 to 2 (sbl62 to sbl60) of asicl6) is output. following the end of sbf transmission, the transmission completi on interrupt request (i ntst6) is generated and sbtt6 is automatically cleared. thereafter, the normal transmission mode is restored. transmission is suspended until the dat a to be transmitted next is written to transmit buffer register 6 (txb6), or until sbtt6 is set to 1. figure 14-22. sbf transmission t x d6 intst6 sbtt6 1 2 3 4 5 6 7 8 9 10 11 12 13 stop remark t x d6: t x d6 pin (output) intst6: transmission completion interrupt request sbtt6: bit 5 of asynchronous serial interface control register 6 (asicl6) chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 320 (i) sbf reception when the device is incorporated in lin, the sbf (synch ronous break field) recept ion control function is used for reception. for the re ception operation of lin, see figure 14-2 lin reception operation . reception is enabled when bit 7 (power6) of asynch ronous serial interface operation mode register 6 (asim6) is set to 1 and then bit 5 (rxe6) of asim6 is se t to 1. sbf reception is enabled when bit 6 (sbrt6) of asynchronous serial interface contro l register 6 (asicl6) is set to 1. in the sbf reception enabled status, the r x d6 pin is sampled and the start bit is detected in the same manner as the normal reception enable status. when the start bit has been detected, reception is started, and serial data is sequentially stored in the receive shift register 6 (rxs6) at the set baud rate. w hen the stop bit is received and if the width of sbf is 11 bits or more, a reception completion interrupt reques t (intsr6) is generated as normal processing. at this time, the sbrf6 and sbrt6 bits are automatical ly cleared, and sbf reception ends. detection of errors, such as ove6, pe6, and fe6 (bits 0 to 2 of as ynchronous serial interface reception error status register 6 (asis6)) is suppressed, and error detection processing of uart communication is not performed. in addition, data transfer between receive shift register 6 (rxs6) and receive buffer register 6 (rxb6) is not performed, and the reset value of ffh is retained. if the width of sbf is 10 bits or less, an interrupt does not occur as error processing after the stop bit has been re ceived, and the sbf reception mode is restored. in this case, the sbrf6 and sbrt6 bits are not cleared. figure 14-23. sbf reception 1. normal sbf reception (stop bit is detect ed with a width of more than 10.5 bits) r x d6 sbrt6 /sbrf6 intsr6 1234567891011 2. sbf reception error (stop bit is detect ed with a width of 10.5 bits or less) r x d6 sbrt6 /sbrf6 intsr6 12345678910 ?0? remark r x d6: r x d6 pin (input) sbrt6: bit 6 of asynchronous serial interface control register 6 (asicl6) sbrf6: bit 7 of asicl6 intsr6: reception completion interrupt request chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 321 14.4.3 dedicated baud rate generator the dedicated baud rate generator consists of a source clock selector and an 8-bit programmable counter, and generates a serial clock for transmission/reception of uart6. separate 8-bit counters are provided for transmission and reception. (1) configuration of ba ud rate generator ? base clock the clock selected by bits 3 to 0 (tps63 to tps60) of clock selectio n register 6 (cksr6) is supplied to each module when bit 7 (power6) of asynchronous serial interface operation mode register 6 (asim6) is 1. this clock is called the base clock and its frequency is called f xclk6 . the base clock is fixed to low level when power6 = 0. ? transmission counter this counter stops operation, clear ed to 0, when bit 7 (power6) or bit 6 (txe6) of asynchronous serial interface operation mode register 6 (asim6) is 0. it starts counting when power6 = 1 and txe6 = 1. the counter is cleared to 0 when the first data transmi tted is written to transmit buffer register 6 (txb6). if data are continuously transmitted, the counter is cleared to 0 agai n when one frame of data has been completely transmitted. if there is no data to be transmitted next, the count er is not cleared to 0 and continues counting until power6 or txe6 is cleared to 0. ? reception counter this counter stops operation, clear ed to 0, when bit 7 (power6) or bit 5 (rxe6) of asynchronous serial interface operation mode register 6 (asim6) is 0. it starts counting when the start bit has been detected. the counter stops operation after one frame has been received, until the next start bit is detected. chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 322 figure 14-24. configuration of baud rate generator selector power6 8-bit counter match detector baud rate baud rate generator brgc6: mdl67 to mdl60 1/2 power6, txe6 (or rxe6) cksr6: tps63 to tps60 f prs f prs /2 f prs /2 2 f prs /2 3 f prs /2 4 f prs /2 5 f prs /2 6 f prs /2 7 f prs /2 8 f prs /2 9 f prs /2 10 8-bit timer/ event counter 50 output f xclk6 remark power6: bit 7 of asynchronous serial interface operation mode register 6 (asim6) txe6: bit 6 of asim6 rxe6: bit 5 of asim6 cksr6: clock selection register 6 brgc6: baud rate generator control register 6 chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 323 (2) generation of serial clock a serial clock can be generated by using clock selection register 6 (cksr6) and baud rate generator control register 6 (brgc6). select the clock to be input to the 8-bit counter by using bits 3 to 0 (tps63 to tps60) of cksr6. bits 7 to 0 (mdl67 to mdl60) of brgc6 can be used to select the division value of the 8-bit counter. (a) baud rate the baud rate can be calculated by the following expression. ? baud rate = [bps] f xclk6 : frequency of base clock selected by tps63 to tps60 bits of cksr6 register k: value set by mdl67 to mdl60 bits of br gc6 register (k = 8, 9, 10, ..., 255) (b) error of baud rate the baud rate error can be calculated by the following expression. ? error (%) = ? 1 100 [%] cautions 1. keep the baud rate error during transmission to within the permissible error range at the reception destination. 2. make sure that the baud rate error dur ing reception satisfies the range shown in (4) permissible baud rate ra nge during reception. example: frequency of base clock = 10 mhz = 10,000,000 hz set value of mdl67 to mdl60 bits of brgc6 register = 00100001b (k = 33) target baud rate = 153600 bps baud rate = 10 m/(2 33) = 10000000/(2 33) = 151,515 [bps] error = (151515/153600 ? 1) 100 = ? 1.357 [%] actual baud rate (baud rate with error) desired baud rate (correct baud rate) f xclk6 2 k chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 324 (3) example of setting baud rate table 14-4. set data of baud rate generator f prs = 2.0 mhz f prs = 5.0 mhz f prs = 10.0 mhz f prs = 20.0 mhz baud rate [bps] tps01, tps00 k calculated value err [%] tps01, tps00 k calculated value err [%] tps01, tps00 k calculated value err [%] tps01, tps00 k calculated value err [%] 300 8h 13 301 0.16 7h 65 301 0.16 8h 65 301 0.16 9h 65 301 0.16 600 7h 13 601 0.16 6h 65 601 0.16 7h 65 601 0.16 8h 65 601 0.16 1200 6h 13 1202 0.16 5h 65 1202 0.16 6h 65 1202 0.16 7h 65 1202 0.16 2400 5h 13 2404 0.16 4h 65 2404 0.16 5h 65 2404 0.16 6h 65 2404 0.16 4800 4h 13 4808 0.16 3h 65 4808 0.16 4h 65 4808 0.16 5h 65 4808 0.16 9600 3h 13 9615 0.16 2h 65 9615 0.16 3h 65 9615 0.16 4h 65 9615 0.16 19200 2h 13 19231 0.16 1h 65 19231 0.16 2h 65 19231 0.16 3h 65 19231 0.16 24000 1h 21 23810 ? 0.79 3h 13 24038 0.16 4h 13 24038 0.16 5h 13 24038 0.16 31250 1h 4 31250 0 4h 5 31250 0 5h 5 31250 0 6h 5 31250 0 38400 1h 13 38462 0.16 0h 65 38462 0.16 1h 65 38462 0.16 2h 65 38462 0.16 48000 0h 21 47619 ? 0.79 2h 13 48077 0.16 3h 13 48077 0.16 4h 13 48077 0.16 76800 0h 13 76923 0.16 0h 33 75758 ? 1.36 0h 65 76923 0.16 1h 65 76923 0.16 115200 0h 9 111111 ? 3.55 1h 11 113636 ? 1.36 0h 43 116279 0.94 0h 87 114943 ? 0.22 153600 ? ? ? ? 1h 8 156250 1.73 0h 33 151515 ? 1.36 1h 33 151515 ? 1.36 312500 ? ? ? ? 0h 8 312500 0 1h 8 312500 0 2h 8 312500 0 remark tps63 to tps60: bits 3 to 0 of clock select ion register 6 (cksr6) (setting of base clock (f xclk6 )) k: value set by mdl67 to mdl60 bits of baud rate generator control register 6 (brgc6) (k = 8, 9, 10, ..., 255) f prs : peripheral hardware clock oscillation frequency err: baud rate error chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 325 (4) permissible baud rate range during reception the permissible error from the baud rate at the trans mission destination during reception is shown below. caution make sure that the baud rate error during reception is within the permissible error range, by using the calculation expression shown below. figure 14-25. permissible baud rate range during reception fl 1 data frame (11 fl) flmin flmax data frame length of uart6 start bit bit 0 bit 1 bit 7 parity bit minimum permissible data frame length maximum permissible data frame length stop bit start bit bit 0 bit 1 bit 7 parity bit latch timing stop bit start bit bit 0 bit 1 bit 7 parity bit stop bit as shown in figure 14-25, the latch timing of the re ceive data is determined by t he counter set by baud rate generator control register 6 (brgc6) a fter the start bit has been detected. if the last data (stop bit) meets this latch timing, the data can be correctly received. assuming that 11-bit data is received, the theoretical values can be calculated as follows. fl = (brate) ? 1 brate: baud rate of uart6 k: set value of brgc6 fl: 1-bit data length margin of latch timing: 2 clocks chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 326 minimum permissible data frame length: flmin = 11 fl ? fl = fl therefore, the maximum receivable baud rate at the transmission destination is as follows. brmax = (flmin/11) ? 1 = brate similarly, the maximum permissible data fr ame length can be calculated as follows. 10 k + 2 21k ? 2 11 2 k 2 k flmax = fl 11 therefore, the minimum receivable baud rate at the transmission destination is as follows. brmin = (flmax/11) ? 1 = brate the permissible baud rate error between uart6 and the transmission destination can be calculated from the above minimum and maximum baud rate expressions, as follows. table 14-5. maximum/minimum permissible baud rate error division ratio (k) maximum perm issible baud rate error minimu m permissible baud rate error 8 +3.53% ? 3.61% 20 +4.26% ? 4.31% 50 +4.56% ? 4.58% 100 +4.66% ? 4.67% 255 +4.72% ? 4.73% remarks 1. the permissible error of reception depends on t he number of bits in one frame, input clock frequency, and division ratio (k). the higher t he input clock frequency and the higher the division ratio (k), the higher the permissible error. 2. k: set value of brgc6 22k 21k + 2 flmax = 11 fl ? fl = fl 21k ? 2 20k 20k 21k ? 2 k ? 2 2k 21k + 2 2k chapter 14 serial interface uart6 preliminary user?s manual u17473ej1v0ud 327 (5) data frame length during continuous transmission when data is continuously transmitted, th e data frame length from a stop bit to the next start bit is extended by two clocks of base clock from the normal value. howeve r, the result of communica tion is not affected because the timing is initialized on the recepti on side when the start bit is detected. figure 14-26. data frame length during continuous transmission start bit bit 0 bit 1 bit 7 parity bit stop bit fl 1 data frame fl fl fl fl fl fl flstp start bit of second byte start bit bit 0 where the 1-bit data length is fl, the stop bit length is flstp, and base clock frequency is f xclk6 , the following expression is satisfied. flstp = fl + 2/f xclk6 therefore, the data frame length during continuous transmission is: data frame length = 11 fl + 2/f xclk6 preliminary user?s manual u17473ej1v0ud 328 chapter 15 serial interfaces csi10 and csi11 the pd78f0393 incorporates serial interface csi10, and the pd78f0395, 78f0397, and 78f 0397d incorporate serial interfaces csi10 and csi11. 15.1 functions of serial interfaces csi10 and csi11 serial interfaces csi10 and csi11 have the following two modes. ? operation stop mode ? 3-wire serial i/o mode (1) operation stop mode this mode is used when serial communication is not performed and can enable a reduction in the power consumption. for details, see 15.4.1 operation stop mode . (2) 3-wire serial i/o mode (ms b/lsb-first selectable) this mode is used to communicate 8-bit data using three lines: a serial clock line (sck1n) and two serial data lines (si1n and so1n). the processing time of data communication can be s hortened in the 3-wire serial i/o mode because transmission and reception can be simultaneously executed. in addition, whether 8-bit data is communicated with the msb or lsb first can be specified, so this interface can be connected to any device. the 3-wire serial i/o mode is used for connecting periphe ral ics and display controllers with a clocked serial interface. for details, see 15.4.2 3-wire serial i/o mode . remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 329 15.2 configuration of serial interfaces csi10 and csi11 serial interfaces csi10 and csi11 include the following hardware. table 15-1. configuration of serial interfaces csi10 and csi11 item configuration registers transmit buffer register 1n (sotb1n) serial i/o shift re gister 1n (sio1n) control registers serial operation mode register 1n (csim1n) serial clock selection register 1n (csic1n) port mode register 0 (pm0) or port mode register 1 (pm1) port register 0 (p0) or port register 1 (p1) remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d figure 15-1. block diagram of serial interface csi10 internal bus si10/p11/r x d0 intcsi10 f prs /2 f prs /2 2 f prs /2 3 f prs /2 4 f prs /2 5 f prs /2 6 f prs /2 7 sck10/p10/t x d0 transmit buffer register 10 (sotb10) transmit controller clock start/stop controller & clock phase controller serial i/o shift register 10 (sio10) output selector so10/p12 output latch 8 transmit data controller 8 output latch (p12) pm12 selector chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 330 figure 15-2. block diagram of serial interface csi11 ( pd78f0395, 78f0397, and 78f0397d only) 8 8 internal bus output selector output latch transmit controller clock start/stop controller & clock phase controller so11/p02 intcsi11 transmit buffer register 11 (sotb11) transmit data controller si11/p03 serial i/o shift register 11 (sio11) f prs /2 f prs /2 2 f prs /2 3 f prs /2 4 f prs /2 5 f prs /2 6 f prs /2 7 sck11/p04 ssi11 output latch (p02) pm02 selector (1) transmit buffer register 1n (sotb1n) this register sets the transmit data. transmission/reception is started by wr iting data to sotb1n when bit 7 (csie 1n) and bit 6 (trmd1n) of serial operation mode register 1n (csim1n) is 1. the data written to sotb1n is converted from parallel data into serial data by serial i/o shift register 1n, and output to the serial output pin (so1n). sotb1n can be written or read by an 8- bit memory manipulation instruction. reset input clears this register to 00h. cautions 1. do not access sotb1n when csot1n = 1 (during serial communication). 2. the ssi11 pin can be used in the slave mode . for details of the transmission/reception operation, see 15.4.2 (2) communication operation. (2) serial i/o shift register 1n (sio1n) this is an 8-bit register that converts data from parallel data into serial data and vice versa. this register can be read by an 8-bit memory manipulation instruction. reception is started by reading data fr om sio1n if bit 6 (trmd1n) of serial operation mode register 1n (csim1n) is 0. during reception, the data is read from the serial input pin (si1n) to sio1n. reset input clears this register to 00h. cautions 1. do not access sio1n when cs ot1n = 1 (during serial communication). 2. the ssi11 pin can be used in the slave mode. for details of the reception operation, see 15.4.2 (2) communication operation. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 331 15.3 registers controlling seri al interfaces csi10 and csi11 serial interfaces csi10 and csi11 are cont rolled by the following four registers. ? serial operation mode register 1n (csim1n) ? serial clock selection register 1n (csic1n) ? port mode register 0 (pm0) or port mode register 1 (pm1) ? port register 0 (p0) or port register 1 (p1) (1) serial operation mode register 1n (csim1n) csim1n is used to select the operation m ode and enable or disable operation. csim1n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d figure 15-3. format of serial oper ation mode register 10 (csim10) address: ff80h after reset: 00h r/w note 1 symbol <7> 6 5 4 3 2 1 0 csim10 csie10 trmd10 0 dir10 0 0 0 csot10 csie10 operation control in 3-wire serial i/o mode 0 disables operation note 2 and asynchronously resets the internal circuit note 3 . 1 enables operation trmd10 note 4 transmit/receive mode control 0 note 5 receive mode (transmission disabled). 1 transmit/receive mode dir10 note 6 first bit specification 0 msb 1 lsb csot10 communication status flag 0 communication is stopped. 1 communication is in progress. notes 1. bit 0 is a read-only bit. 2. when using p10/sck10/txd0, p11/si10/rxd0, and p 12/so10 as general-purpose port pins, see chapter 4 port functions , caution 2 of figure 15-5 , and table 15-2 . 3. bit 0 (csot10) of csim10 and serial i/o shift register 10 (sio10) are reset. 4. do not rewrite trmd10 when csot10 = 1 (during serial communication). 5. the so10 output is fixed to the low level when trmd 10 is 0. reception is started when data is read from sio10. 6. do not rewrite dir10 when csot10 = 1 (during serial communication). caution be sure to clear bit 5 to 0. chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 332 figure 15-4. format of serial oper ation mode register 11 (csim11) address: ff88h after reset: 00h r/w note 1 symbol <7> 6 5 4 3 2 1 0 csim11 csie11 trmd11 sse11 dir11 0 0 0 csot11 csie11 operation control in 3-wire serial i/o mode 0 disables operation note 2 and asynchronously resets the internal circuit note 3 . 1 enables operation trmd11 note 4 transmit/receive mode control 0 note 5 receive mode (transmission disabled). 1 transmit/receive mode sse11 notes 6, 7 ssi11 pin use selection 0 ssi11 pin is not used 1 ssi11 pin is used dir11 note 8 first bit specification 0 msb 1 lsb csot11 communication status flag 0 communication is stopped. 1 communication is in progress. notes 1. bit 0 is a read-only bit. 2. when using p02/so11, p03/si11, p04/sck11, and p05/ssi11/ti001 as general-purpose port pins, see chapter 4 port functions , caution 2 of figure 15-6 , and table 15-2 . 3. bit 0 (csot11) of csim11 and serial i/o shift register 11 (sio11) are reset. 4. do not rewrite trmd11 when csot11 = 1 (during serial communication). 5. the so11 output is fixed to the low level when trmd 11 is 0. reception is started when data is read from sio11. 6. do not rewrite sse11 when csot11 = 1 (during serial communication). 7. before setting this bit to 1, fix the ssi11 pin input level to 0 or 1. 8. do not rewrite dir11 when csot11 = 1 (during serial communication). chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 333 (2) serial clock selecti on register 1n (csic1n) this register specifies the timing of the data transmission/reception and sets the serial clock. csic1n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears this register to 00h. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d figure 15-5. format of serial clo ck selection register 10 (csic10) address: ff81h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 csic10 0 0 0 ckp10 dap10 cks102 cks101 cks100 ckp10 dap10 specification of data transmission/reception timing type 0 0 d7 d6 d5 d4 d3 d2 d1 d0 sck10 so10 si10 input timing 1 0 1 d7 d6 d5 d4 d3 d2 d1 d0 sck10 so10 si10 input timing 2 1 0 d7 d6 d5 d4 d3 d2 d1 d0 sck10 so10 si10 input timing 3 1 1 d7 d6 d5 d4 d3 d2 d1 d0 sck10 so10 si10 input timing 4 csi10 serial clock selection cks102 cks101 cks100 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz mode 0 0 0 f prs /2 1 mhz 2.5 mhz 5 mhz 10 mhz 0 0 1 f prs /2 2 500 khz 1.25 mhz 2.5 mhz 5 mhz 0 1 0 f prs /2 3 250 khz 625 khz 1.25 mhz 2.5 mhz 0 1 1 f prs /2 4 125 khz 312.5 khz 625 khz 1.25 mhz 1 0 0 f prs /2 5 62.5 khz 156.25 khz 312.5 khz 625 khz 1 0 1 f prs /2 6 31.25 khz 78.13 khz 156.25 khz 312.5 khz 1 1 0 f prs /2 7 15.63 khz 39.06 khz 78.13 khz 156.25 khz master mode 1 1 1 external clock input to sck10 slave mode cautions 1. do not write to csic10 while csie10 = 1 (operation enabled). 2. clear ckp10 to 0 to use p10/sck10/txd0, p11/si10/rxd0, and p12/so10 as general-purpose port pins. 3. the phase type of the data clock is type 1 after reset. remark f prs : peripheral hardware clock oscillation frequency chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 334 figure 15-6. format of serial clo ck selection register 11 (csic11) address: ff89h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 csic11 0 0 0 ckp11 dap11 cks112 cks111 cks110 ckp11 dap11 specification of data transmission/reception timing type 0 0 d7 d6 d5 d4 d3 d2 d1 d0 sck11 so11 si11 input timing 1 0 1 d7 d6 d5 d4 d3 d2 d1 d0 sck11 so11 si11 input timing 2 1 0 d7 d6 d5 d4 d3 d2 d1 d0 sck11 so11 si11 input timing 3 1 1 d7 d6 d5 d4 d3 d2 d1 d0 sck11 so11 si11 input timing 4 csi11 serial clock selection cks112 cks111 cks110 f prs = 2 mhz f prs = 5 mhz f prs = 10 mhz f prs = 20 mhz mode 0 0 0 f prs /2 1 mhz 2.5 mhz 5 mhz 10 mhz 0 0 1 f prs /2 2 500 khz 1.25 mhz 2.5 mhz 5 mhz 0 1 0 f prs /2 3 250 khz 625 khz 1.25 mhz 2.5 mhz 0 1 1 f prs /2 4 125 khz 312.5 khz 625 khz 1.25 mhz 1 0 0 f prs /2 5 62.5 khz 156.25 khz 312.5 khz 625 khz 1 0 1 f prs /2 6 31.25 khz 78.13 khz 156.25 khz 312.5 khz 1 1 0 f prs /2 7 15.63 khz 39.06 khz 78.13 khz 156.25 khz master mode 1 1 1 external clock input to sck11 slave mode cautions 1. do not write to csic11 while csie11 = 1 (operation enabled). 2. clear ckp11 to 0 to use p0 2/so11, p03/si11, and p04/sck11 as general-purpose port pins. 3. the phase type of the data clock is type 1 after reset. remark f prs : peripheral hardware clock oscillation frequency chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 335 (3) port mode registers 0 and 1 (pm0, pm1) these registers set port 0 and 1 input/output in 1-bit units. when using p10/sck10 and p04/sck11 note as the clock output pins of the se rial interface, clear pm10 and pm04 to 0, and set the output latches of p10 and p04 to 1. when using p12/so10 and p02/so11 note as the data output pins of the seri al interface, clear pm12, pm02, and the output latches of p12 and p02 to 0. when using p10/sck10 and p04/sck11 note as the clock input pins of the serial interface, p11/si10/rxd0 and p03/si11 note as the data input pins, and p05/ssi11 note /ti001 as the chip select input pin, set pm10, pm04, pm11, pm03, and pm05 to 1. at this time, the output latches of p10, p04, p11, p03, and p05 may be 0 or 1. pm0 and pm1 can be set by a 1-bit or 8- bit memory manipulation instruction. reset input sets these registers to ffh. note pd78f0395, 78f0397, and 78f0397d only figure 15-7. format of port mode register 0 (pm0) 7 1 6 pm06 5 pm05 4 pm04 3 pm03 2 pm02 1 pm01 0 pm00 symbol pm0 address: ff20h after reset: ffh r/w pm0n 0 1 p0n pin i/o mode selection (n = 0 to 6) output mode (output buffer on) input mode (output buffer off) figure 15-8. format of port mode register 1 (pm1) 7 pm17 6 pm16 5 pm15 4 pm14 3 pm13 2 pm12 1 pm11 0 pm10 symbol pm1 address: ff21h after reset: ffh r/w pm1n 0 1 p1n pin i/o mode selection (n = 0 to 7) output mode (output buffer on) input mode (output buffer off) chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 336 15.4 operation of serial interfaces csi10 and csi11 serial interfaces csi10 and csi11 can be used in the following two modes. ? operation stop mode ? 3-wire serial i/o mode 15.4.1 operation stop mode serial communication is not executed in this mode. therefore, the power consumption can be reduced. in addition, the p10/sck10/t x d0, p11/si10/r x d0, p12/so10, p02/so11 note , p03/si11 note , and p04/sck11 note pins can be used as ordinary i/o port pins in this mode. note pd78f0395, 78f0397, and 78f0397d only (1) register used the operation stop mode is set by serial operation mode register 1n (csim1n). to set the operation stop mode, clear bit 7 (csie1n) of csim1n to 0. (a) serial operation mode register 1n (csim1n) csim1n can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears csim1n to 00h. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d ? serial operation mode register 10 (csim10) address: ff80h after reset: 00h r/w symbol <7> 6 5 4 3 2 1 0 csim10 csie10 trmd10 0 dir10 0 0 0 csot10 csie10 operation control in 3-wire serial i/o mode 0 disables operation note 1 and asynchronously resets the internal circuit note 2 . notes 1. when using p10/sck10/txd0, p11/si10/rxd0, and p12/so10 as general-purpose port pins, see chapter 4 port functions , caution 2 of figure 15-5 , and table 15-2 . 2. bit 0 (csot10) of csim10 and serial i/o shift register 10 (sio10) are reset. ? serial operation mode register 11 (csim11) address: ff88h after reset: 00h r/w symbol <7> 6 5 4 3 2 1 0 csim11 csie11 trmd11 sse11 dir11 0 0 0 csot11 csie11 operation control in 3-wire serial i/o mode 0 disables operation note 1 and asynchronously resets the internal circuit note 2 . notes 1. when using p02/so11, p03/ si11, p04/sck11, and p05/ssi11/ ti001 as general-purpose port pins, see chapter 4 port functions , caution 2 of figure 15-6 , and table 15-2 . 2. bit 0 (csot11) of csim11 and serial i/o shift register 11 (sio11) are reset. chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 337 15.4.2 3-wire serial i/o mode the 3-wire serial i/o mode is used for connecting peripheral ics and display controll ers with a clocked serial interface. in this mode, communication is executed by using three lin es: the serial clock (sck1n), serial output (so1n), and serial input (si1n) lines. (1) registers used ? serial operation mode register 1n (csim1n) ? serial clock selection register 1n (csic1n) ? port mode register 0 (pm0) or port mode register 1 (pm1) ? port register 0 (p0) or port register 1 (p1) the basic procedure of setting an operation in the 3-wire se rial i/o mode is as follows. <1> set the csic1n register (see figures 15-5 and 15-6 ). <2> set bits 0 and 4 to 6 (csot1n, dir1n, sse11 (ser ial interface csi11 only), and trmd1n) of the csim1n register (see figures 15-3 and 15-4 ). <3> set bit 7 (csie1n) of the csim1n register to 1. transmission/reception is enabled. <4> write data to transmit buffer register 1n (sotb1n). data transmission/reception is started. read data from serial i/o shift register 1n (sio1n). data reception is started. caution take relationship with the other party of communication when setting the port mode register and port register. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 338 the relationship between the register settings and pins is shown below. table 15-2. relationship between register settings and pins (1/2) (a) serial interface csi10 pin function csie10 trmd10 pm11 p11 pm12 p12 pm10 p10 csi10 operation si10/rxd0/ p11 so10/p12 sck10/ txd0/p10 0 note 1 note 1 note 1 note 1 note 1 note 1 stop rxd0/p11 p12 txd0/ p10 note 2 1 0 1 note 1 note 1 1 slave reception note 3 si10 p12 sck10 (input) note 3 1 1 note 1 note 1 0 0 1 slave transmission note 3 rxd0/p11 so10 sck10 (input) note 3 1 1 1 0 0 1 slave transmission/ reception note 3 si10 so10 sck10 (input) note 3 1 0 1 note 1 note 1 0 1 master reception si10 p12 sck10 (output) 1 1 note 1 note 1 0 0 0 1 master transmission rxd0/p11 so10 sck10 (output) 1 1 1 0 0 0 1 master transmission/ reception si10 so10 sck10 (output) notes 1. can be set as port function. 2. to use p10/sck10/txd0 as port pins, clear ckp10 to 0. 3. to use the slave mode, set cks102, cks101, and cks100 to 1, 1, 1. remark : don?t care csie10: bit 7 of serial operation mode register 10 (csim10) trmd10: bit 6 of csim10 ckp10: bit 4 of serial clock selection register 10 (csic10) cks102, cks101, cks100: bits 2 to 0 of csic10 pm1 : port mode register p1 : port output latch chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 339 table 15-2. relationship between register settings and pins (2/2) (b) serial interface csi11 ( pd78f0395, 78f0397, and 78f0397d only) pin function csie11 trmd11 sse11 pm03 p03 pm02 p02 pm04 p04 pm05 p05 csi11 operation si11/ p03 so11/ p02 sck11/ p04 ssi11/ ti001/p05 0 note 1 note 1 note 1 note 1 note 1 note 1 note 1 note 1 stop p03 p02 p04 note 2 ti001/ p05 0 note 1 note 1 ti001/ p05 1 0 1 1 note 1 note 1 1 1 slave reception note 3 si11 p02 sck11 (input) note 3 ssi11 0 note 1 note 1 ti001/ p05 1 1 1 note 1 note 1 0 0 1 1 slave transmission note 3 p03 so11 sck11 (input) note 3 ssi11 0 note 1 note 1 ti001/ p05 1 1 1 1 0 0 1 1 slave transmission/ reception note 3 si11 so11 sck11 (input) note 3 ssi11 1 0 0 1 note 1 note 1 0 1 note 1 note 1 master reception si11 p02 sck11 (output) ti001/ p05 1 1 0 note 1 note 1 0 0 0 1 note 1 note 1 master transmission p03 so11 sck11 (output) ti001/ p05 1 1 0 1 0 0 0 1 note 1 note 1 master transmission/ reception si11 so11 sck11 (output) ti001/ p05 notes 1. can be set as port function. 2. to use p04/sck11 as port pins, clear ckp11 to 0. 3. to use the slave mode, set cks112, cks111, and cks110 to 1, 1, 1. remark : don?t care csie11: bit 7 of serial operation mode register 11 (csim11) trmd11: bit 6 of csim11 ckp11: bit 4 of serial clock selection register 11 (csic11) cks112, cks111, cks110: bits 2 to 0 of csic11 pm0 : port mode register p0 : port output latch chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 340 (2) communication operation in the 3-wire serial i/o mode, data is tr ansmitted or received in 8-bit units. each bit of the dat a is transmitted or received in synchronization with the serial clock. data can be transmitted or received if bit 6 (trmd1n) of serial operation mode register 1n (csim1n) is 1. transmission/reception is started when a value is writt en to transmit buffer register 1n (sotb1n). in addition, data can be received when bit 6 (trmd1n) of seri al operation mode register 1n (csim1n) is 0. reception is started when dat a is read from serial i/o shift register 1n (sio1n). however, communication is performed as follows if bit 5 (s se11) of csim11 is 1 when serial interface csi11 is in the slave mode. <1> low level input to the ssi11 pin transmission/reception is started when sotb11 is writt en, or reception is star ted when sio11 is read. <2> high level input to the ssi11 pin transmission/reception or reception is held, therefore, even if sotb11 is written or sio11 is read, transmission/reception or rece ption will not be started. <3> data is written to sotb11 or data is read from sio 11 while a high level is input to the ssi11 pin, then a low level is input to the ssi11 pin transmission/reception or reception is started. <4> a high level is input to the ssi11 pi n during transmission/reception or reception transmission/reception or reception is suspended. after communication has been started, bit 0 (csot1n) of csim1n is set to 1. when communication of 8-bit data has been completed, a communication completion interrupt request flag (csiif1n) is set, and csot1n is cleared to 0. then the next communication is enabled. cautions 1. do not access the cont rol register and data register when csot1n = 1 (during serial communication). 2. when using serial interface csi11, wait fo r the duration of at least one clock before the clock operation is started to ch ange the level of the ssi11 pin in the slave mode; otherwise, malfunctioning may occur. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 341 figure 15-9. timing in 3-wire serial i/o mode (1/2) (1) transmission/reception timing (t ype 1; trmd1n = 1, dir1n = 0, ckp1n = 0, dap1n = 0, sse11 = 1 note ) aah abh 56h adh 5ah b5h 6ah d5h 55h (communication data) 55h is written to sotb1n. sck1n sotb1n sio1n csot1n csiif1n so1n si1n (receive aah) read/write trigger intcsi1n ssi11 note note the sse11 flag and ssi11 pin are available only for serial interface csi11, and are used in the slave mode. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 342 figure 15-9. timing in 3-wire serial i/o mode (2/2) (2) transmission/reception timing (t ype 2; trmd1n = 1, dir1n = 0, ckp1n = 0, dap1n = 1, sse11 = 1 note ) abh 56h adh 5ah b5h 6ah d5h sck1n sotb1n sio1n csot1n csiif1n so1n si1n (input aah) aah 55h (communication data) 55h is written to sotb1n. read/write trigger intcsi1n ssi11 note note the sse11 flag and ssi11 pin are available only for serial interface csi11, and are used in the slave mode. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 343 figure 15-10. timing of clock/data phase (a) type 1; ckp1n = 0, dap1n = 0 d7 d6 d5 d4 d3 d2 d1 d0 sck1n so1n writing to sotb1n or reading from sio1n si1n capture csiif1n csot1n (b) type 2; ckp1n = 0, dap1n = 1 d7 d6 d5 d4 d3 d2 d1 d0 sck1n so1n writing to sotb1n or reading from sio1n si1n capture csiif1n csot1n (c) type 3; ckp1n = 1, dap1n = 0 d7 d6 d5 d4 d3 d2 d1 d0 sck1n so1n writing to sotb1n or reading from sio1n si1n capture csiif1n csot1n (d) type 4; ckp1n = 1, dap1n = 1 d7 d6 d5 d4 d3 d2 d1 d0 sck1n so1n writing to sotb1n or reading from sio1n si1n capture csiif1n csot1n remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 344 (3) timing of output to so1n pin (first bit) when communication is started, the value of transmit buffe r register 1n (sotb1n) is output from the so1n pin. the output operation of the first bit at this time is described below. figure 15-11. output operation of first bit (1) when ckp1n = 0, dap1n = 0 (or ckp1n = 1, dap1n = 0) sck1n sotb1n sio1n so1n writing to sotb1n or reading from sio1n first bit 2nd bit output latch the first bit is directly latched by the sotb1n register to the output latch at the falling (or rising) edge of sck1n, and output from the so1n pin via an output selector. then, the value of the sotb1n regi ster is transferred to the sio1n register at the next rising (or fa lling) edge of sck1n, and shifted one bit. at the same time, the first bit of the receive data is stored in the s io1n register via the si1n pin. the second and subsequent bits are latc hed by the sio1n register to the output latch at the next falling (or rising) edge of sck1n, and the data is output from the so1n pin. (2) when ckp1n = 0, dap1n = 1 (or ckp1n = 1, dap1n = 1) sck1n sotb1n sio1n so1n writing to sotb1n or reading from sio1n first bit 2nd bit 3rd bit output latch the first bit is directly latched by the sotb1n register at the falling edge of the write signal of the sotb1n register or the read signal of the sio1n register, and output from the so1n pin via an output selector. then, the value of the sotb1n register is transfe rred to the sio1n register at the next falling (or rising) edge of sck1n, and shifted one bit. at the same time, the first bit of the rece ive data is stored in the sio1n register via the si1n pin. the second and subsequent bits are latc hed by the sio1n register to the out put latch at the next rising (or falling) edge of sck1n, and the data is output from the so1n pin. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 345 (4) output value of so1n pin (last bit) after communication has been completed, the so1n pin holds the output value of the last bit. figure 15-12. output value of so1n pin (last bit) (1) type 1; when ckp1n = 0 and dap1n = 0 (or ckp1n = 1, dap1n = 0) sck1n sotb1n sio1n so1n writing to sotb1n or reading from sio1n ( next request is issued.) last bit output latch (2) type 2; when ckp1n = 0 and dap1n = 1 (or ckp1n = 1, dap1n = 1) sck1n sotb1n sio1n so1n last bit writing to sotb1n or reading from sio1n ( next request is issued.) output latch remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 15 serial interfaces csi10 and csi11 preliminary user?s manual u17473ej1v0ud 346 (5) so1n output the status of the so1n output is as follows if bit 7 (csie1n) of seri al operation mode register 1n (csim1n) is cleared to 0. table 15-3. so1n output status trmd1n dap1n dir1n so1n output note 1 trmd1n = 0 note 2 ? ? outputs low level note 2 dap1n = 0 ? value of so1n latch (low-level output) dir1n = 0 value of bit 7 of sotb1n trmd1n = 1 dap1n = 1 dir1n = 1 value of bit 0 of sotb1n notes 1. the actual output of the so 10/p12 or so11/p02 pin is determined according to pm12 and p12 or pm02 and p02, as well as the so1n output. 2. status after reset caution if a value is written to trmd1n, dap1n, and dir1n, the output value of so1n changes. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d preliminary user?s manual u17473ej1v0ud 347 chapter 16 serial interface iic0 16.1 functions of serial interface iic0 serial interface iic0 has the following two modes. (1) operation stop mode this mode is used when serial transfers are not performed. it can therefore be used to reduce power consumption. (2) i 2 c bus mode (multimaster supported) this mode is used for 8-bit data transfers with several devices via two lines: a serial clock (scl0) line and a serial data bus (sda0) line. this mode complies with the i 2 c bus format and the master device can output ?start condition?, ?data?, and ?stop condition? data to the slave device, via the serial data bus. the slave device automatically detects these received data by hardware. this function can simplify the part of application prog ram that controls the i 2 c bus. since the scl0 and sda0 pins are used for open drain ou tputs, iic0 requires pull-up resistors for the serial clock line and the serial data bus line. figure 16-1 shows a block diagram of serial interface iic0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 348 figure 16-1. block diagram of serial interface iic0 internal bus iic status register 0 (iics0) iic control register 0 (iicc0) slave address register 0 (sva0) noise eliminator noise eliminator bus status detector match signal iic shift register 0 (iic0) so latch iice0 dq set clear cl01, cl00 data hold time correction circuit start condition generator ack output circuit wake-up controller ack detector stop condition detector serial clock counter interrupt request signal generator serial clock controller serial clock wait controller prescaler intiic0 lrel0 wrel0 spie0 wtim0 acke0 stt0 spt0 msts0 ald0 exc0 coi0 trc0 ackd0 std0 spd0 start condition detector internal bus cld0 dad0 smc0 dfc0 cl01 cl00 clx0 iic clock selection register 0 (iiccl0) stcf iicbsy stcen iicrsv iic flag register 0 (iicf0) iic function expansion register 0 (iicx0) sda0 pm61 n-ch open- drain output n-ch open- drain output pm60 scl0 f prs chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 349 figure 16-2 shows a serial bus configuration example. figure 16-2. serial bus c onfiguration example using i 2 c bus master cpu1 slave cpu1 address 0 sda0 scl0 serial data bus serial clock + v dd + v dd sda0 scl0 sda0 scl0 sda0 scl0 sda0 scl0 master cpu2 slave cpu2 address 1 slave cpu3 address 2 slave ic address 3 slave ic address n chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 350 16.2 configuration of serial interface iic0 serial interface iic0 includes the following hardware. table 16-1. configuration of serial interface iic0 item configuration registers iic shift register 0 (iic0) slave address register 0 (sva0) control registers iic control register 0 (iicc0) iic status register 0 (iics0) iic flag register 0 (iicf0) iic clock selection register 0 (iiccl0) iic function expansion register 0 (iicx0) port mode register 6 (pm6) (1) iic shift register 0 (iic0) iic0 is used to convert 8-bit serial data to 8-bit paralle l data and vice versa in synchronization with the serial clock. iic0 can be used for both transmission and reception. write and read operations to iic0 are used to c ontrol the actual transmit and receive operations. iic0 is set by an 8-bit memory manipulation instruction. reset input clears iic0 to 00h. figure 16-3. format of iic shift register 0 (iic0) symbol iic0 address: ffa5h after reset: 00h r/w 76543210 caution do not write data to iic0 during data transfer. (2) slave address register 0 (sva0) this register sets local a ddresses when in slave mode. sva0 is set by an 8-bit memory manipulation instruction. reset input clears sva0 to 00h. figure 16-4. format of slave address register 0 (sva0) symbol sva0 address: ffa7h after reset: 00h r/w 76543210 0 note note bit 0 is fixed to 0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 351 (3) so latch the so latch is used to retain the sda0 pin?s output level. (4) wake-up controller this circuit generates an interrupt request (intiic0) w hen the address received by this register matches the address value set to slave address register 0 (sva0) or when an extension code is received. (5) prescaler this selects the sampling clock to be used. (6) serial clock counter this counter counts the serial clocks that are output or input during transmi t/receive operations and is used to verify that 8-bit data was transmitted or received. (7) interrupt request signal generator this circuit controls the generation of interrupt request signals (intiic0). an i 2 c interrupt request is generated by the following two triggers. falling edge of eighth or ninth clock of the serial clock (set by wtim0 bit) interrupt request generated when a stop cond ition is detected (set by spie0 bit) remark wtim0 bit: bit 3 of iic control register 0 (iicc0) spie0 bit: bit 4 of iic control register 0 (iicc0) (8) serial clock controller in master mode, this circuit generates the clock output via the scl0 pin from a sampling clock. (9) serial clock wait controller this circuit controls the wait timing. (10) ack output circuit, stop condition detector, start condition detector, and ack detector these circuits are used to output and detect various control signals. (11) data hold time correction circuit this circuit generates the hold time for data corre sponding to the falling edge of the serial clock. (12) start condition generator this circuit generates a start conditi on when the stt0 bit is set to 1. however, in the communication reservation disabled stat us (iicrsv bit = 1), when the bus is not released (iicbsy bit = 1), start condition requests are ignored and the stcf bit is set to 1. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 352 (13) bus status detector this circuit detects whether or not the bus is releas ed by detecting start conditions and stop conditions. however, as the bus status cannot be detected immediately following operation, the initial status is set by the stcen bit. remark stt0 bit: bit 1 of iic control register 0 (iicc0) iicrsv bit: bit 0 of iic flag register 0 iicbsy bit: bit 6 of iic flag register 0 stcf bit: bit 7 of iic flag register 0 stcen bit: bit 1 of iic flag register 0 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 353 16.3 registers to control serial interface iic0 serial interface iic0 is controlled by the following six registers. iic control register 0 (iicc0) iic flag register 0 (iicf0) iic status register 0 (iics0) iic clock selection register 0 (iiccl0) iic function expansion register 0 (iicx0) port mode register 6 (pm6) (1) iic control register 0 (iicc0) this register is used to enable/stop i 2 c operations, set wait timing, and set other i 2 c operations. iicc0 is set by a 1-bit or 8-bit memory manipulation instruction. reset input clears iicc0 to 00h. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 354 figure 16-5. format of iic control register 0 (iicc0) (1/4) address: ffa6h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> iicc0 iice0 lrel0 wrel0 spie0 wtim0 acke0 stt0 spt0 iice0 i 2 c operation enable 0 stop operation. reset iic status register 0 (iics0) note 1 . stop internal operation. 1 enable operation. condition for clearing (iice0 = 0) condition for setting (iice0 = 1) ? cleared by instruction ? reset ? set by instruction lrel0 exit from communications 0 normal operation 1 this exits from the current communications and sets st andby mode. this setting is automatically cleared after being executed. its uses include cases in which a locally irrelevant extension code has been received. the scl0 and sda0 lines are set to high impedance. the following flags of iic status register 0 (iic s0) and iic control register 0 (iicc0) are cleared. std0 ackd0 trc0 coi0 exc0 msts0 stt0 spt0 the standby mode following exit from communications remains in effect until the following co mmunications entry conditions are met. ? after a stop condition is detected, restart is in master mode. ? an address match or extension code rece ption occurs after the start condition. condition for clearing (lrel0 = 0) note 2 condition for setting (lrel0 = 1) ? automatically cleared after execution ? reset ? set by instruction wrel0 wait cancellation 0 do not cancel wait 1 cancel wait. this setting is automatic ally cleared after wait is canceled. when wrel0 is set (wait canceled) during the wait period at the ninth clock pulse in the transmission status (trc0 = 1), the sda0 line goes into the high impedance state (trc0 = 0). condition for clearing (wrel0 = 0) note 2 condition for setting (wrel0 = 1) ? automatically cleared after execution ? reset ? set by instruction notes 1. the iics0 register, the stcf0 and iic bsy bits of the iicf0 register, and the cld0 and dad0 bits of the iiccl0 register are reset. 2. this flag?s signal is invalid when iice0 = 0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 355 figure 16-5. format of iic control register 0 (iicc0) (2/4) spie0 enable/disable generation of interrupt request when stop condition is detected 0 disable 1 enable condition for clearing (spie0 = 0) note condition for setting (spie0 = 1) ? cleared by instruction ? reset ? set by instruction wtim0 control of wait and interrupt request generation 0 interrupt request is generated at the eighth clock?s falling edge. master mode: after output of eight clocks, cloc k output is set to low level and wait is set. slave mode: after input of eight clo cks, the clock is set to low level and wait is set for master device. 1 interrupt request is generated at the ninth clock?s falling edge. master mode: after output of nine clocks, clock output is set to low level and wait is set. slave mode: after input of nine clo cks, the clock is set to low level and wait is set for master device. an interrupt is generated at the falling edge of the ninth cl ock during address transfer independently of the setting of this b it. the setting of this bit is valid when the address transfer is completed. when in master mode, a wait is inserted at the fallin g edge of the ninth clock during address transfer s. for a slave device that has received a local address, a wait is inserted at the falling edge of the ninth clock after an acknowledge signal (ack) is issued. however, when the slave device has received an extension code, a wait is inserted at the falling edge of the eighth clock. condition for clearing (wtim0 = 0) note condition for setting (wtim0 = 1) ? cleared by instruction ? reset ? set by instruction acke0 acknowledgment control 0 disable acknowledgment. 1 enable acknowledgment. during the nint h clock period, the sda0 line is set to low level. however, ack is invalid during address transfers and other than in expansion mode. condition for clearing (acke0 = 0) note condition for setting (acke0 = 1) ? cleared by instruction ? reset ? set by instruction note this flag?s signal is invalid when iice0 = 0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 356 figure 16-5. format of iic control register 0 (iicc0) (3/4) stt0 start condition trigger 0 do not generate a start condition. 1 when bus is released (in stop mode): generate a start condition (for starting as master). the sda0 line is changed from high level to low level and then the start condition is generated. next, after the ra ted amount of time has elapsed, scl0 is changed to low level. when a third party is communicating: ? when communication reservation function is enabled (iicrsv = 0) functions as the start condition reservation flag. w hen set to 1, automatically generates a start condition after the bus is released. ? when communication reservation function is disabled (iicrsv = 1) stcf is set to 1. no start condition is generated. in the wait state (when master device): generates a restart condition after releasing the wait. cautions concerning set timing ? for master reception: cannot be set to 1 during transfer. can be set to 1 only in the waiting period when acke0 has been cleared to 0 and slave has been notified of final reception. ? for master transmission: a start condition cannot be generat ed normally during the ack0 period. set to 1 during the wait period. ? cannot be set to 1 at the same time as spt0. condition for clearing (stt0 = 0) note condition for setting (stt0 = 1) ? cleared by loss in arbitration ? cleared after start condition is generated by master device ? cleared by lrel0 = 1 (exit from communications) ? when iice0 = 0 (operation stop) ? reset ? set by instruction note this flag?s signal is invalid when iice0 = 0. remarks 1. bit 1 (stt0) becomes 0 when it is read after data setting. 2. iicrsv: bit 0 of iic flag register (iicf0) stcf: bit 7 of iic flag register (iicf0) chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 357 figure 16-5. format of iic control register 0 (iicc0) (4/4) spt0 stop condition trigger 0 stop condition is not generated. 1 stop condition is generated (terminati on of master device?s transfer). after the sda0 line goes to low level, either set the scl0 li ne to high level or wait until it goes to high level. next, after the rated amount of time has elapsed, the sda0 line changes from low level to high level and a stop condition is generated. cautions concerning set timing ? for master reception: cannot be set to 1 during transfer. can be set to 1 only in the waiting period when acke0 has been cleared to 0 and slave has been notified of final reception. ? for master transmission: a stop condition cannot be generat ed normally during the ack signal period. therefore, set it during the waiting period. ? cannot be set to 1 at the same time as stt0. ? spt0 can be set to 1 only when in master mode note 1 . ? when wtim0 has been cleared to 0, if spt0 is set to 1 during t he wait period that follows output of eight clocks, note that a stop condition will be generated during the high-level period of the ninth clock. when a ninth clock must be output, wtim0 should be changed from 0 to 1 during the wait period following output of eight clocks, and spt0 should be set to 1 during the wait period that follows output of the ninth clock. condition for clearing (spt0 = 0) note 2 condition for setting (spt0 = 1) ? cleared by loss in arbitration ? automatically cleared after stop condition is detected ? cleared by lrel0 = 1 (exit from communications) ? when iice0 = 0 (operation stop) ? reset ? set by instruction notes 1. set spt0 to 1 only in master mode. however, spt0 must be set and a stop condition generated before the first stop condition is detected following the switch to the operation enabled status. for details, see 16.5.14 other cautions . 2. this flag?s signal is invalid when iice0 = 0. caution when bit 3 (trc0) of iic status register 0 (iic s0) is set to 1, wrel0 is set to 1 during the ninth clock and wait is canceled, after which trc0 is cleared and the sda0 line is set to high impedance. remark bit 0 (spt0) becomes 0 when it is read after data setting. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 358 (2) iic status register 0 (iics0) this register indicates the status of i 2 c. iics0 is read by a 1-bit or 8-bit memory manipulation instruction. reset input clears iics0 to 00h. caution if data is read from iics0 , a wait cycle is generated. do not read data from iics0 when the cpu is operating on the subsystem clock and th e peripheral hardware cl ock is stopped. for details, see chapter 31 cautions for wait. figure 16-6. format of iic status register 0 (iics0) (1/3) address: ffaah after reset: 00h r symbol <7> <6> <5> <4> <3> <2> <1> <0> iics0 msts0 ald0 exc0 coi0 trc0 ackd0 std0 spd0 msts0 master device status 0 slave device status or communication standby status 1 master device communication status condition for clearing (msts0 = 0) condition for setting (msts0 = 1) ? when a stop condition is detected ? when ald0 = 1 (arbitration loss) ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when a start condition is generated ald0 detection of arbitration loss 0 this status means either that there was no arbitr ation or that the arbitration result was a ?win?. 1 this status indicates the arbitration result was a ?loss?. msts0 is cleared. condition for clearing (ald0 = 0) condition for setting (ald0 = 1) ? automatically cleared after iics0 is read note ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when the arbitration result is a ?loss?. note this register is also cleared when a bit manipula tion instruction is executed for bits other than iics0. therefore, when using the ald0 bit, read the data of this bit before the data of the other bits. remark lrel0: bit 6 of iic control register 0 (iicc0) iice0: bit 7 of iic control register 0 (iicc0) chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 359 figure 16-6. format of iic status register 0 (iics0) (2/3) exc0 detection of extension code reception 0 extension code was not received. 1 extension code was received. condition for clearing (exc0 = 0) condition for setting (exc0 = 1) ? when a start condition is detected ? when a stop condition is detected ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when the higher four bits of the received address data is either ?0000? or ?1111? (set at the rising edge of the eighth clock). coi0 detection of matching addresses 0 addresses do not match. 1 addresses match. condition for clearing (coi0 = 0) condition for setting (coi0 = 1) ? when a start condition is detected ? when a stop condition is detected ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when the received address matches the local address (slave address register 0 (sva0)) (set at the rising edge of the eighth clock). trc0 detection of transmit/receive status 0 receive status (other than transmit status). the sda0 line is set for high impedance. 1 transmit status. the value in the so0 latch is ena bled for output to the sda0 line (valid starting at the falling edge of the first byte?s ninth clock). condition for clearing (trc0 = 0) condition for setting (trc0 = 1) chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 360 figure 16-6. format of iic status register 0 (iics0) (3/3) ackd0 detection of acknowledge signal (ack) 0 ack signal was not detected. 1 ack signal was detected. condition for clearing (ackd0 = 0) condition for setting (ackd0 = 1) ? when a stop condition is detected ? at the rising edge of the next byte?s first clock ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? after the sda0 line is set to low level at the rising edge of scl0?s ninth clock std0 detection of start condition 0 start condition was not detected. 1 start condition was detected. this indicates that the address transfer period is in effect. condition for clearing (std0 = 0) condition for setting (std0 = 1) ? when a stop condition is detected ? at the rising edge of the next byte?s first clock following address transfer ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when a start condition is detected spd0 detection of stop condition 0 stop condition was not detected. 1 stop condition was detected. the master device?s co mmunication is terminated and the bus is released. condition for clearing (spd0 = 0) condition for setting (spd0 = 1) ? at the rising edge of the address transfer byte?s first clock following setting of this bit and detection of a start condition ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when a stop condition is detected remark lrel0: bit 6 of iic control register 0 (iicc0) iice0: bit 7 of iic control register 0 (iicc0) chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 361 (3) iic flag register 0 (iicf0) this register sets the operation mode of i 2 c and indicates the status of the i 2 c bus. iicf0 is read by a 1-bit or 8-bit memory manipulati on instruction. however, the stcf and iicbsy bits are read-only. the iicrsv bit can be used to enable/disable the communication reservation function (see 16.5.13 communication reservation ). stcen can be used to set the in itial value of the iicbsy bit (see 16.5.14 other cautions ). iicrsv and stcen can be written only when the operation of i 2 c is disabled (bit 7 (iice0) of iic control register 0 (iicc0) = 0). when operation is enabled, the iicf0 register can be read. reset input clears iicf0 to 00h. figure 16-7. format of iic flag register 0 (iicf0) <7> stcf condition for clearing (stcf = 0) cleared by stt0 = 1 reset condition for setting (stcf = 1) generating start condition unsuccessful and stt0 cleared to 0 when communication reservation is disabled (iicrsv = 1). stcf 0 1 generate start condition start condition generation unsuccessful: clear stt0 flag stt0 clear flag iicf0 symbol <6> iicbsy 5 0 4 0 3 0 2 0 <1> stcen <0> iicrsv address: ffabh after reset: 00h r/w note condition for clearing (iicbsy = 0) detection of stop condition reset condition for setting (iicbsy = 1) detection of start condition setting of iice0 when stcen = 0 iicbsy 0 1 bus release status bus communication status i 2 c bus status flag condition for clearing (stcen = 0) detection of stop condition reset condition for setting (stcen = 1) set by instruction stcen 0 1 after operation is enabled (iice0 = 1), enable generation of a start condition upon detection of a stop condition. after operation is enabled (iice0 = 1), enable generation of a start condition without detecting a stop condition. initial start enable trigger condition for clearing (iicrsv = 0) cleared by instruction reset condition for setting (iicrsv = 1) set by instruction iicrsv 0 1 enable communication reservation disable communication reservation communication reservation function disable bit note bits 6 and 7 are read-only. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 362 cautions 1. write to stcen only when the operation is stopped (iice0 = 0). 2. as the bus release status (iicbsy = 0) is recognized regardless of the actual bus status when stcen = 1, when generating th e first start condition (stt0 = 1), it is necessary to verify that no third party comm unications are in progress in order to prevent such communications from being destroyed. 3. write to iicrsv only when the operation is stopped (iice0 = 0). remark stt0: bit 1 of iic control register 0 (iicc0) iice0: bit 7 of iic control register 0 (iicc0) (4) iic clock selection register 0 (iiccl0) this register is used to set the transfer clock for the i 2 c bus. iiccl0 is set by a 1-bit or 8-bit memory manipulation in struction. however, the cld0 and dad0 bits are read- only. the smc0, cl01, and cl00 bits are set in comb ination with bit 0 (clx0) of iic function expansion register 0 (iicx0) (see 16.3 (6) i 2 c transfer clock setting method ). reset input clears iiccl0 to 00h. figure 16-8. format of iic clock selection register 0 (iiccl0) (1/2) address: ffa8h after reset: 00h r/w note symbol 7 6 <5> <4> <3> <2> 1 0 iiccl0 0 0 cld0 dad0 smc0 dfc0 cl01 cl00 cld0 detection of scl0 pin level (valid only when iice0 = 1) 0 the scl0 line was detected at low level. 1 the scl0 line was detected at high level. condition for clearing (cld0 = 0) condition for setting (cld0 = 1) ? when the scl0 line is at low level ? when iice0 = 0 (operation stop) ? reset ? when the scl0 line is at high level dad0 detection of sda0 pin level (valid only when iice0 = 1) 0 the sda0 line was detected at low level. 1 the sda0 line was detected at high level. condition for clearing (dad0 = 0) condition for setting (dad0 = 1) ? when the sda0 line is at low level ? when iice0 = 0 (operation stop) ? reset ? when the sda0 line is at high level note bits 4 and 5 are read-only. remark iice0: bit 7 of iic control register 0 (iicc0) chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 363 figure 16-8. format of iic clock selection register 0 (iiccl0) (2/2) smc0 operation mode switching 0 operates in standard mode. 1 operates in high-speed mode. dfc0 digital filter operation control 0 digital filter off. 1 digital filter on. digital filter can be used only in high-speed mode. in high-speed mode, the transfer clock does not va ry regardless of dfc0 bit set (1)/clear (0). the digital filter is used for noise elimination in high-speed mode. caution stop serial transfer once before rewrit ing cl01 and cl00 to other than the same value. (5) iic function expansi on register 0 (iicx0) this register sets the function expansion of i 2 c. iicx0 is set by a 1-bit or 8-bit memory manipulation inst ruction. however, the clx0 bit is set in combination with bits 3, 1, and 0 (smc0, c l01, and cl00) of iic clock sele ction register 0 (iiccl0) (see 16.3 (6) i 2 c transfer clock setting method ). reset input clears iicx0 to 00h. figure 16-9. format of iic clock selection register 0 (iiccl0) address: ffa9h after reset: 00h r/w symbol 7 6 5 4 3 2 1 <0> iicx0 0 0 0 0 0 0 0 clx0 (6) i 2 c transfer clock setting method the i 2 c transfer clock frequency (f scl ) is calculated using the following expression. f scl = 1/(m t + t r + t f ) m = 24, 48, 66, 88, 96, 172, 344 (see table 16-2 selection clock setting ) t: 1/f prs t r : scl0 rise time t f : scl0 fall time chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 364 for example, the i 2 c transfer clock frequency (f scl ) when f prs = 8.38 mhz, m = 88, t r = 200 ns, and t f = 50 ns is calculated using following expression. f scl = 1/(88 119.3 ns + 200 ns + 50 ns) ? 93.0 khz m t + t r + t f m/2 t m/2 t t f t r scl0 scl0 inversion scl0 inversion scl0 inversion the selection clock is set using a combination of bits 3, 1, and 0 (smc0, cl01, and cl00) of iic clock selection register 0 (iiccl0) and bit 0 (clx0) of iic function expansion register 0 (iicx0). table 16-2. selection clock setting iicx0 iiccl0 bit 0 bit 3 bit 1 bit 0 clx0 smc0 cl01 cl00 selection clock (f w ) transfer clock (f prs /m) settable selection clock (f w ) range operation mode 0 0 0 0 f prs /2 f prs /88 2.00 to 4.19 mhz 0 0 0 1 f prs /2 f prs /172 0 0 1 0 f prs /4 f prs /344 4.19 to 8.38 mhz normal mode (smc0 bit = 0) 0 0 1 1 setting prohibited 0 1 0 f prs /2 f prs /48 0 1 1 0 f prs /4 f prs /96 4.19 to 8.38 mhz high-speed mode (smc0 bit = 1) 0 1 1 1 1 0 setting prohibited 1 1 0 f prs /2 f prs /24 1 1 1 0 f prs /4 f prs /48 4.00 to 4.19 mhz high-speed mode (smc0 bit = 1) 1 1 1 1 setting prohibited remarks 1. : don?t care 2 . f prs : peripheral hardware clock oscillation frequency chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 365 (7) port mode register 6 (pm6) this register sets the input/output of the scl0 and sda0 pins in 1-bit units. when using the scl0 pin as clock i/o and the sda0 pin as serial data i/o, clear pm60 and pm61 to 0. set iice0 (bit 7 of iic control register 0 (iicc0)) to 1 before setting the output mode because the scl0 and sda0 pins output a low level (fixed) when iice0 is 0. pm6 is set by a 1-bit or 8-bit memory manipulation instruction. reset input sets pm6 to ffh. figure 16-10. format of port mode register 6 (pm6) pm60 pm61 1 1 1 1 1 1 sda0 pin i/o mode selection output mode (output buffer on) input mode (output buffer off) pm61 0 1 0 1 2 3 4 5 6 7 pm6 address: ff26h after reset: ffh r/w symbol scl0 pin i/o mode selection output mode (output buffer on) input mode (output buffer off) pm60 0 1 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 366 16.4 i 2 c bus mode functions 16.4.1 pin configuration the serial clock pin (scl0) and serial data bus pin (sda0) are configured as follows. (1) scl0....... this pin is used for serial clock input and output. this pin is an n-ch open-drain output for both master and slave devices. input is schmitt input. (2) sda0 ...... this pin is used fo r serial data input and output. this pin is an n-ch open-drain output for both master and slave devices. input is schmitt input. since outputs from the serial clock line and the serial data bus line are n-ch open-drai n outputs, an external pull-up resistor is required. figure 16-11. pin configuration diagram master device clock output (clock input) data output data input v ss v ss scl0 sda0 v dd v dd (clock output) clock input data output data input v ss v ss slave device scl0 sda0 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 367 16.5 i 2 c bus definitions and control methods the following section describes the i 2 c bus?s serial data communication format and the signals used by the i 2 c bus. figure 16-12 shows the transfer timing for the ?start cond ition?, ?data?, and ?stop c ondition? output via the i 2 c bus?s serial data bus. figure 16-12. i 2 c bus serial data transfer timing scl0 sda0 start condition address r/w ack data ack data ack stop condition 1-7 8 9 1-7 8 9 1-7 8 9 the master device outputs the start condi tion, slave address, and stop condition. the acknowledge signal (ack) can be output by either the master or slave device (normally, it is output by the device that receives 8-bit data). the serial clock (scl0) is continuously output by the master device. howeve r, in the slave device, the scl0?s low level period can be extended and a wait can be inserted. 16.5.1 start conditions a start condition is met when the scl0 pin is at high level and the sda0 pin changes from high level to low level. the start conditions for the scl0 pin and sda0 pin are si gnals that the master device outputs to the slave device when starting a serial transfer. when the device is us ed as a slave, start conditions can be detected. figure 16-13. start conditions scl0 sda0 h a start condition is output when bit 1 (stt0) of iic control r egister 0 (iicc0) is set (to 1) after a stop condition has been detected (spd0: bit 0 = 1 in iic status register 0 (iic s0)). when a start condition is detected, bit 1 (std0) of iics0 is set (to 1). chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 368 16.5.2 addresses the address is defined by the 7 bits of data that follow the start condition. an address is a 7-bit data segment that is output in order to select one of t he slave devices that are connected to the master device via the bus lines. therefore, each slave device connected via the bus lines must have a unique address. the slave devices include hardware t hat detects the start condition and c hecks whether or not the 7-bit address data matches the data values stored in slave address register 0 (sva0). if the address data matches the sva0 values, the slave device is selected and communicates with the master device until the mast er device transmits a start condition or stop condition. figure 16-14. address scl0 sda0 intiic0 123456789 a6 a5 a4 a3 a2 a1 a0 r/w address note note intiic0 is not issued if data other than a local address or extension code is received during slave device operation. the slave address and the eighth bit, which spec ifies the transfer direction as described in 16.5.3 transfer direction specification below, are together written to iic shift r egister 0 (iic0) and are then output. received addresses are written to iic0. the slave address is assigned to the higher 7 bits of iic0. 16.5.3 transfer di rection specification in addition to the 7-bit address data, the master device s ends 1 bit that specifies t he transfer direction. when this transfer direction specificati on bit has a value of ?0?, it indicates that the master device is transmitting data to a slave device. when the transfer direction specification bit has a value of ?1?, it indicates that the master device is receiving data from a slave device. figure 16-15. transfer direction specification scl0 sda0 intiic0 123456789 a6 a5 a4 a3 a2 a1 a0 r/w transfer direction specification note note intiic0 is not issued if data other than a local address or extension code is received during slave device operation. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 369 16.5.4 acknowledge (ack) signal the acknowledge (ack) signal is used by the transmitting a nd receiving devices to confirm serial data reception. the receiving device returns one ack signal for each 8 bits of data it receives. the transmitting device normally receives an ack signal after transmitting 8 bits of data. howe ver, when the master device is the receiving device, it does not output an ack signal after receiving the final dat a to be transmitted. the transmitting device detects whether or not an ack signal is returned after it transmits 8 bits of data. when an ack signal is returned, the reception is judged as normal and processing continues. if the slave device does not return an ack signal, the master device outputs either a stop conditi on or a restart condition and then stops the current transmission. failure to return an ack signal may be caused by the following two factors. <1> reception was not performed normally. <2> the final data was received. when the receiving device sets the sda0 line to low leve l during the ninth clock, the ack signal becomes active (normal receive response). when bit 2 (acke0) of iic control register 0 (iicc0) is set to 1, automatic ack signal generation is enabled. transmission of the eighth bit following the 7 address data bits causes bit 3 (trc0) of iic status register 0 (iics0) to be set. when this trc0 bit?s value is ?0?, it indica tes receive mode. therefore, acke0 should be set to 1. when the slave device is receiving (when trc0 = 0), if the slave devices does not need to receive any more data after receiving several bytes, setting acke0 to 0 will prev ent the master device from starting transmission of the subsequent data. similarly, when the master device is receiving (when t rc0 = 0) and the subsequent data is not needed and when either a restart condition or a stop co ndition should therefore be output, setting acke0 to 0 will prevent the ack signal from being returned. this prevents the msb data fr om being output via the sda0 line (i.e., stops transmission) during transmission from the slave device. figure 16-16. ack signal scl0 sda0 123456789 a6 a5 a4 a3 a2 a1 a0 r/w ack when the local address is received, an ack signal is auto matically output in sync with the falling edge of the scl0?s eighth clock regardless of the acke0 value. no ac k signal is output if the re ceived address is not a local address. the ack signal output method during data reception is based on the wait timing setting, as described below. when 8-clock wait is selected: (wtim0 = 0) ack signal is output at the falling edge of the scl0 pin?s eighth clock if acke0 is set to 1 before wait cancellation. when 9-clock wait is selected: (wtim0 = 1) ack signal is automatically output at the falling edge of the scl0 pin?s eighth clock if acke0 has already been set to 1. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 370 16.5.5 stop condition when the scl0 pin is at high level, changing the sda0 pin from low level to high level generates a stop condition. a stop condition is a signal that the master device outputs to the slave device when serial transfer has been completed. when the device is used as a slave, stop conditions can be detected. figure 16-17. stop condition scl0 sda0 h a stop condition is generated when bit 0 (spt0) of iic c ontrol register 0 (iicc0) is set to 1. when the stop condition is detected, bit 0 (spd0) of iic status register 0 (iics0) is se t to 1 and intiic0 is generated when bit 4 (spie0) of iicc0 is set to 1. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 371 16.5.6 wait signal (wait) the wait signal (wait) is used to not ify the communication partner that a device (master or slave) is preparing to transmit or receive data (i .e., is in a wait state). setting the scl0 pin to low level notifies the communication par tner of the wait status. when wait status has been canceled for both the master and slave devices, the next data transfer can begin. figure 16-18. wait signal (1/2) (1) when master device has a nine-clock wait and slave device has an eight-clock wait (master transmits, slave receives, and acke0 = 1) master iic0 scl0 slave iic0 scl0 acke0 transfer lines scl0 sda0 6789 123 master returns to high impedance but slave is in wait state (low level). wait after output of ninth clock iic0 data write (cancel wait) wait after output of eighth clock wait signal from slave wait signal from master ffh is written to iic0 or wrel0 is set to 1 678 9 123 d2 d1 d0 d7 d6 d5 ack h chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 372 figure 16-18. wait signal (2/2) (2) when master and slave devices both have a nine-clock wait (master transmits, slave receives, and acke0 = 1) master iic0 scl0 slave iic0 scl0 acke0 transfer lines scl0 sda0 h 6789 1 23 master and slave both wait after output of ninth clock wait signal from master and slave wait signal from slave iic0 data write (cancel wait) ffh is written to iic0 or wrel0 is set to 1 6789 123 d2 d1 d0 ack d7 d6 d5 output according to previously set acke0 value remark acke0: bit 2 of iic control register 0 (iicc0) wrel0: bit 5 of iic control register 0 (iicc0) a wait may be automatically generated depending on the setting of bit 3 (wtim0) of iic control register 0 (iicc0). normally, the receiving side cancels the wait status when bi t 5 (wrel0) of iicc0 is set to 1 or when ffh is written to iic shift register 0 (iic0), and the transmitting side cancels the wait status when data is written to iic0. the master device can also cancel the wait status via either of the following methods. by setting bit 1 (stt0) of iicc0 to 1 by setting bit 0 (spt0) of iicc0 to 1 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 373 16.5.7 interrupt request (intiic0) generation timing and wait control the setting of bit 3 (wtim0) of iic c ontrol register 0 (iicc0) determines t he timing by which intiic0 is generated and the corresponding wait control, as shown in table 16-3. table 16-3. intiic0 generation timing and wait control during slave device operation during master device operation wtim0 address data reception data transmission address data reception data transmission 0 9 notes 1, 2 8 note 2 8 note 2 9 8 8 1 9 notes 1, 2 9 note 2 9 note 2 9 9 9 notes 1. the slave device?s intiic0 signal and wait period occu rs at the falling edge of the ninth clock only when there is a match with the address set to slave address register 0 (sva0). at this point, the ack signal is output regardless of the value set to iicc0?s bit 2 (acke0). for a slave device that has received an extension code, intiic 0 occurs at the falling edge of the eighth clock. however, if the address does not match after rest art, intiic0 is generated at the falling edge of the 9th clock, but wait does not occur. 2. if the received address does not match the contents of slave address register 0 (sva0) and extension code is not received, neither intiic0 nor a wait occurs. remark the numbers in the table indicate the number of t he serial clock?s clock signals. interrupt requests and wait control are both synchronized with t he falling edge of these clock signals. (1) during address transmission/reception slave device operation: interrupt and wait timi ng are determined depending on the conditions described in notes 1 and 2 above, regardless of the wtim0 bit. master device operation: interrupt and wait timing oc cur at the falling edge of the ninth clock regardless of the wtim0 bit. (2) during data reception master/slave device operation: interrupt and wait timing are determined according to the wtim0 bit. (3) during data transmission master/slave device operation: interrupt and wait timing are determined according to the wtim0 bit. (4) wait cancellation method the four wait cancellation methods are as follows. by setting bit 5 (wrel0) of iic control register 0 (iicc0) to 1 by writing to iic shift register 0 (iic0) by setting a start condition (setting bit 1 (stt0) of iicc0 to 1) note by setting a stop condition (setting bit 0 (spt0) of iicc0 to 1) note note master only. when an 8-clock wait has been selected (wtim0 = 0), the output level of the ac k signal must be determined prior to wait cancellation. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 374 (5) stop condition detection intiic0 is generated when a stop condit ion is detected (only when spie0 = 1). 16.5.8 address match detection method in i 2 c bus mode, the master device can se lect a particular slave device by transmitting the corresponding slave address. address match can be detected automatical ly by hardware. an interrupt r equest (intiic0) occurs when a local address has been set to slave address register 0 (sva0) and when the address set to sva0 matches the slave address sent by the master device, or when an extension code has been received. 16.5.9 error detection in i 2 c bus mode, the status of t he serial data bus (sda0) during data transmi ssion is captured by iic shift register 0 (iic0) of the transmitting device, so the iic0 data prior to transmission can be compared with the transmitted iic0 data to enable detection of transmission errors. a transmission error is judged as having occurred when the compared data values do not match. 16.5.10 extension code (1) when the higher 4 bits of the receive address are ei ther ?0000? or ?1111?, the extension code reception flag (exc0) is set to 1 for extension code reception and an interrupt request (intiic0) is issued at the falling edge of the eighth clock. the local address stored in slave address register 0 (sva0) is not affected. (2) if ?111110 ? is set to sva0 by a 10-bit address transfer and ?111110 ? is transferred from the master device, the results are as follows. note that intiic0 occurs at the falling edge of the eighth clock. higher four bits of data match: exc0 = 1 seven bits of data match: coi0 = 1 remark exc0: bit 5 of iic status register 0 (iics0) coi0: bit 4 of iic status register 0 (iics0) (3) since the processing after the interrupt request occurs differs according to the data that follows the extension code, such processing is performed by software. for example, after the extension code is received, if you do not wish to operate the target device as a slave device, you can set bit 6 (lrel0) of iic control register 0 (iicc0) to 1 to set the standby mode for the next communication operation. table 16-4. extension code bit definitions slave address r/w bit description 0 0 0 0 0 0 0 0 general call address 0 0 0 0 0 0 0 1 start byte 0 0 0 0 0 0 1 cbus address 0 0 0 0 0 1 0 address that is reserved for different bus format 1 1 1 1 0 x x 10-bit slave address specification chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 375 16.5.11 arbitration when several master devices simultaneous ly output a start condition (when stt0 is set to 1 before std0 is set to 1), communication among the master devic es is performed as the number of clo cks are adjusted until the data differs. this kind of operation is called arbitration. when one of the master devices loses in arbitration, an arbitration loss flag (ald 0) in iic status register 0 (iics0) is set (1) via the timing by which the arbitration loss oc curred, and the scl0 and sda0 lines are both set to high impedance, which releases the bus. the arbitration loss is detected based on the timing of the next interrupt reques t (the eighth or ninth clock, when a stop condition is detected, et c.) and the ald0 = 1 setting that has been made by software. for details of interrupt request timing, see 16.5.16 timing of i 2 c interrupt request (intiic0) occurrence . remark std0: bit 1 of iic status register 0 (iics0) stt0: bit 1 of iic control register 0 (iicc0) figure 16-19. arbitration timing example scl0 sda0 scl0 sda0 scl0 sda0 hi-z hi-z master 1 loses arbitration master 1 master 2 transfer lines chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 376 table 16-5. status during arbitrati on and interrupt request generation timing status during arbitration interrupt request generation timing during address transmission read/write data after address transmission during extension code transmission read/write data after extension code transmission during data transmission during ack signal transfer period after data transmission when restart condition is detected during data transfer at falling edge of eighth or ninth clock following byte transfer note 1 when stop condition is detected during data transfer when stop condition is output (when spie0 = 1) note 2 when data is at low level while attempting to output a restart condition at falling edge of eighth or ninth clock following byte transfer note 1 when stop condition is detected while attempting to output a restart condition when stop condition is output (when spie0 = 1) note 2 when data is at low level while attempting to output a stop condition when scl0 is at low level while attempting to output a restart condition at falling edge of eighth or ninth clock following byte transfer note 1 notes 1. when wtim0 (bit 3 of iic control register 0 (iicc0 )) = 1, an interrupt request occurs at the falling edge of the ninth clock. when wtim0 = 0 and the extension code?s slave address is received, an interrupt request occurs at the falling edge of the eighth clock. 2. when there is a chance that ar bitration will occur, set spie0 = 1 for master device operation. remark spie0: bit 4 of iic control register 0 (iicc0) 16.5.12 wake-up function the i 2 c bus slave function is a function that generates an interrupt request si gnal (intiic0) when a local address and extension code have been received. this function makes processing more efficient by pr eventing unnecessary intiic0 signal from occurring when addresses do not match. when a start condition is detected, wake-up standby mode is set. this wake-up standby mode is in effect while addresses are transmitted due to the possibility that an ar bitration loss may change the master device (which has output a start condition) to a slave device. however, when a stop condition is detecte d, bit 4 (spie0) of iic control register 0 (iicc0) is set regardless of the wake-up function, and this determines whether in terrupt requests are enabled or disabled. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 377 16.5.13 communication reservation (1) when communication reservation func tion is enabled (bit 0 (iicrsv) of iic flag register 0 (iicf0) = 0) to start master device communications when not curr ently using a bus, a communication reservation can be made to enable transmission of a start condition when the bus is released. there are two modes under which the bus is not used. when arbitration results in neither master nor slave operation when an extension code is received and slave operation is disabled (ack is not returned and the bus was released when bit 6 (lrel0) of iic control register 0 (iicc0) was set to 1). if bit 1 (stt0) of iicc0 is set to 1 while the bus is not used (after a stop condition is detected), a start condition is automatically generated and wait status is set. when the bus release is detected (when a stop condition is detected), writing to iic shift register 0 (iic0) causes the master address transfer to start. at this point, bit 4 (spie0) of iicc0 should be set to 1. when stt0 has been set to 1, the operation mode (as st art condition or as communication reservation) is determined according to the bus status. if the bus has been released .........................................a start c ondition is generated if the bus has not been released (stand by mode) .........communica tion reservation check whether the communication reservation operates or not by using msts0 (bit 7 of iic status register 0 (iics0)) after stt0 is set to 1 and the wait time elapses. the wait periods, which should be set via software, are listed in table 16-6. table 16-6. wait periods clx0 smc0 cl01 cl00 wait period 0 0 0 0 46 clocks 0 0 0 1 86 clocks 0 0 1 0 172 clocks 0 0 1 1 34 clocks 0 1 0 0 0 1 0 1 30 clocks 0 1 1 0 60 clocks 0 1 1 1 12 clocks 1 1 0 0 1 1 0 1 18 clocks 1 1 1 0 36 clocks figure 16-20 shows the communication reservation timing. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 378 figure 16-20. communication reservation timing 2 13456 2 13456 789 scl0 sda0 program processing hardware processing write to iic0 set spd0 and intiic0 stt0 = 1 communi- cation reservation set std0 output by master with bus mastership remark iic0: iic shift register 0 stt0: bit 1 of iic control register 0 (iicc0) std0: bit 1 of iic status register 0 (iics0) spd0: bit 0 of iic status register 0 (iics0) communication reservations are accepted via the following timing. after bit 1 (std0) of iic status register 0 (iics0) is set to 1, a communication reservation can be made by setting bit 1 (stt0) of iic control register 0 (iicc0) to 1 before a stop condition is detected. figure 16-21. timing for accepting communication reservations scl0 sda0 std0 spd0 standby mode figure 16-22 shows the communication reservation protocol. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 379 figure 16-22. communication reservation protocol di set1 stt0 define communication reservation wait msts0 = 0? (communication reservation) note yes no (generate start condition) cancel communication reservation mov iic0, # h ei sets stt0 flag (communication reservation) defines that communication reservation is in effect (defines and sets user flag to any part of ram) secures wait period set by software (see table 16-6 ). confirmation of communication reservation clear user flag iic0 write operation note the communication reservation operation executes a write to iic shift register 0 (iic0) when a stop condition interrupt request occurs. remark stt0: bit 1 of iic control register 0 (iicc0) msts0: bit 7 of iic status register 0 (iics0) iic0: iic shift register 0 (2) when communication reservation function is disabled (b it 0 (iicrsv) of iic flag register 0 (iicf0) = 1) when bit 1 (stt0) of iic control register 0 (iicc0) is se t to 1 when the bus is not used in a communication during bus communication, this request is rejected and a start condition is not generated. the following two statuses are included in the st atus where bus is not used. ? when arbitration results in neither master nor slave operation ? when an extension code is received and slave operation is disabled (ack signal is not returned and the bus was released when bit 6 (lrel0) of iicc0 was set to 1) to confirm whether the start conditi on was generated or request was rejected, check stcf (bit 7 of iicf0). the time shown in table 16-7 is required until stcf is se t to 1 after setting stt0 = 1. therefore, secure the time by software. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 380 table 16-7. wait periods cl01 cl00 wait period 0 0 6 clocks 0 1 6 clocks 1 0 12 clocks 1 1 3 clocks 16.5.14 other cautions (1) when stcen (bit 1 of iic flag register 0 (iicf0)) = 0 immediately after i 2 c operation is enabled, the bus communication status (iicbsy (bit 6 of iicf0) = 1) is recognized regardless of the actual bus status. w hen changing from a mode in which no stop condition has been detected to a master device communication mode, fi rst generate a stop condition to release the bus, then perform master device communication. when using multiple masters, it is not possible to per form master device communication when the bus has not been released (when a stop condition has not been detected). use the following sequence for generating a stop condition. <1> set iic clock selection register 0 (iiccl0). <2> set bit 7 (iice0) of iic c ontrol register 0 (iicc0) to 1. <3> set bit 0 (spt0) of iicc0 to 1. (2) when stcen = 1 immediately after i 2 c operation is enabled, the bus released stat us (iicbsy = 0) is recognized regardless of the actual bus status. to issue the fi rst start condition (stt0 (bit 1 of iic c ontrol register 0 (iicc0)) = 1), it is necessary to confirm that the bus has been rel eased, so as to not disturb other communications. (3) if other i 2 c communications are already in progress if i 2 c operation is enabled and the device participates in communication already in progress when the sda0 pin is low and the scl0 pin is high, the macro of i 2 c recognizes that the sda0 pin has gone low (detects a start condition). if the value on the bus at this time can be recognized as an ex tension code, an acknowledge signal is returned, but this interferes with other i 2 c communications. to avoid this, start i 2 c in the following sequence. <1> clear bit 4 (spie0) of iicc0 to 0 to disable gener ation of an interrupt request signal (intiic0) when the stop condition is detected. <2> set bit 7 (iice0) of iicc0 to 1 to enable the operation of i 2 c. <3> wait for detection of the start condition. <4> set bit 6 (lrel0) of iicc0 to 1 before the acknow ledge signal is returned (4 to 80 clocks after setting iice0 to 1), to forcibly disable detection. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 381 16.5.15 communication operations (1) master operation 1 the following shows the flowchart for master communic ation when the communication reservation function is enabled (bit 0 (iicrsv) of iic flag register 0 (iicf0 ) = 0) and the master operation is started after a stop condition is detected (bit 1 (stcen) of iicf0 = 0). figure 16-23. master operation flowchart (1) iiccl0 h select transfer clock iicc0 h iice0 = spie0 = wtim0 = 1 spt0 = 1 start iic0 write transfer wait stt0 = 1 start iic0 write transfer wrel0 = 1 start reception generate stop condition spt0 = 1 start data processing data processing acke0 = 0 wrel0 = wtim0 = 1 no no yes (stop condition detection) no no no no no (restart) no no yes yes yes yes yes yes intiic0 = 1? wtim0 = 0 acke0 = 1 intiic0 = 1? transfer completed? transfer completed? intiic0 = 1? trc0 = 1? ackd0 = 1? msts0 = 1? yes no intiic0 = 1? intiic0 = 1? ackd0 = 1? communication reservation stop condition detection, start condition generation by communication reservation wait time is secured by software (see table 16-6 ) address transfer completion no (receive) yes (transmit) generate stop condition (no slave with matching address) end end yes (start condition generation) chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 382 (2) master operation 2 the following shows the flowchart for master communic ation when the communication reservation function is disabled (iicrsv0 bit = 1) and the master operation is started without detecting a stop condition (stcen0 bit = 1). figure 16-24. master operation flowchart (2) no generate stop condition (no slave with matching address) iiccl0 h iicf0 h transfer clock selection iicf0 register setting iicc0 register initial setting iicc0 h iice0 = spie0 = wtim0 = 1 stt0 = 1 insert wait start no yes iicbsy0 = 0? no yes start iic0 write transfer start iic0 write transfer wtim0 = 0 acke0 = 1 wrel0 = 1 start reception data processing data processing acke0 = 0 wrel0 = wtim0 = 1 spt0 = 1 generate stop condition no yes (address transfer completion) yes intiic0 = 1? no yes yes intiic0 = 1? no yes intiic0 = 1? no yes ackd0 = 1? no reception completed? yes no (restart) transfer completed? ackd0 = 1? yes (transmit) trc0 = 1? no (receive) stcf0 = 0? stop master communication wait time is secured by software (see table 16-7 ) master communication is stopped because bus is occupied end end chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 383 (3) slave operation the processing procedure of the slave operation is as follows. basically, the slave operation is event-driven. therefor e, processing by the intiic0 interrupt (processing that must substantially change the operation status such as de tection of a stop condition during communication) is necessary. in the following explanation, it is assumed that the extension code is not supported for data communication. it is also assumed that the intiic0 interrupt servicing only performs status transition pr ocessing, and that actual data communication is performed by the main processing. iic0 interrupt servicing main processing intiic0 flag setting data setting therefore, data communication processing is perfo rmed by preparing the following three flags and passing them to the main processing instead of intiic0. <1> communication mode flag this flag indicates the following two communication statuses. ? clear mode: status in which data communication is not performed ? communication mode: status in which data comm unication is performed (from valid address detection to stop condition detection, no detection of the ack signal from master, address mismatch) <2> ready flag this flag indicates that data communication is enabled. its function is the same as the intiic0 interrupt for ordinary data communication. this flag is set by interrupt servicing and cleared by the main processing. clear this flag by interrupt servicing when communication is started. however, the ready flag is not set by interrupt servicing when the first data is transmitted. therefore, the first data is transmitted without the flag being cleared (an address match is interpreted as a request for the next data). <3> communication direction flag this flag indicates the direction of communic ation. its value is the same as trc0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 384 the main processing of the slave operation is explained next. start serial interface iic0 and wait until communication is enabled. when communication is enabled, execute communication by using the communication mode flag an d ready flag (processing of the stop condition and start condition is performed by an interrupt. here, check the status by using the flags). the transmission operation is repeated until the master no longer returns the ack signal. if the ack signal is not returned from the master, communication is completed. for reception, the necessary amount of data is received . when communication is completed, the ack signal is not returned as the next data. after that, the master issu es a stop condition or restart condition. exit from the communication status occurs in this way. figure 16-25. slave operation flowchart (1) yes yes yes yes yes yes yes yes no no no no no no no no start communication mode? communication mode? communication mode? ready? ready? read data clear ready flag clear ready flag communication direction flag = 1? wtim0 = 1 wrel0 = 1 acke0 = 0 wrel0 = 1 acke0 = wtim0 = 1 ackd0 = 1? wrel0 = 1 clear communication mode flag data processing data processing transfer completed? iic0 data iicc0 xxh iice0 = 1 iiccl0 xxh iicf0 xxh transfer clock selection iicf0 register setting chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 385 an example of the processing procedur e of the slave with the intiic0 inte rrupt is explained below (processing is performed assuming that no extension code is used). the intiic0 interrupt c hecks the status, and the following operations are performed. <1> communication is stopped if the stop condition is issued. <2> if the start condition is issued, the address is c hecked and communication is completed if the address does not match. if the address matches, the communi cation mode is set, wait is cancelled, and processing returns from the interrupt (the ready flag is cleared). <3> for data transmit/receive, only the ready flag is set. processing returns from the interrupt with the iic0 bus remaining in the wait status. remark <1> to <3> above correspond to <1> to <3> in figure 16-26 slave operation flowchart (2) . figure 16-26. slave operation flowchart (2) yes yes yes no no no intiic0 generated set ready flag interrupt servicing completed interrupt servicing completed interrupt servicing completed termination processing spd0 = 1? std0 = 1? coi0 = 1? lrel0 = 1 clear communication mode communication direction flag trc0 set communication mode flag clear ready flag <1> <2> <3> chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 386 16.5.16 timing of i 2 c interrupt request (intiic0) occurrence the intiic0 interrupt request timing and the iic status register 0 (iics0) settings corresponding to that timing are described below. (1) master device operation (a) start ~ address ~ data ~ data ~ stop (normal transmission/reception) (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 5 2 1 spt0 = 1 1: iics0 = 1000110b 2: iics0 = 1000000b 3: iics0 = 1000000b (sets wtim0) 4: iics0 = 100000b (sets spt0) 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp spt0 = 1 3 4 2 1 1: iics0 = 1000110b 2: iics0 = 1000100b 3: iics0 = 100000b (sets spt0) 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 387 (b) start ~ address ~ data ~ start ~ address ~ data ~ stop (restart) (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 4 7 2 3 1 st rw d7 to d0 ak 5 6 stt0 = 1 spt0 = 1 1: iics0 = 1000110b 2: iics0 = 1000000b (sets wtim0) 3: iics0 = 100000b (cl ears wtim0, sets stt0) 4: iics0 = 1000110b 5: iics0 = 1000000b (sets wtim0) 6: iics0 = 100000b (sets spt0) 7: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 5 2 1 st rw d7 to d0 ak 4 stt0 = 1 spt0 = 1 1: iics0 = 1000110b 2: iics0 = 100000b (sets stt0) 3: iics0 = 1000110b 4: iics0 = 100000b (sets spt0) 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 388 (c) start ~ code ~ data ~ data ~ stop (extension code transmission) (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 5 2 1 spt0 = 1 1: iics0 = 1010110b 2: iics0 = 1010000b 3: iics0 = 1010000b (sets wtim0) 4: iics0 = 101000b (sets spt0) 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 2 1 spt0 = 1 1: iics0 = 1010110b 2: iics0 = 1010100b 3: iics0 = 101000b (sets spt0) 4: iics0 = 00001001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 389 (2) slave device operation (slave address data reception time (matches with sva0)) (a) start ~ address ~ data ~ data ~ stop (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 2 1 1: iics0 = 0001110b 2: iics0 = 0001000b 3: iics0 = 0001000b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 2 1 1: iics0 = 0001110b 2: iics0 = 0001100b 3: iics0 = 000100b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 390 (b) start ~ address ~ data ~ start ~ address ~ data ~ stop (i) when wtim0 = 0 (after restart, matches with sva0) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 5 2 1 st rw d7 to d0 ak 4 1: iics0 = 0001110b 2: iics0 = 0001000b 3: iics0 = 0001110b 4: iics0 = 0001000b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 (after restart, matches with sva0) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 5 2 1 st rw d7 to d0 ak 4 1: iics0 = 0001110b 2: iics0 = 000100b 3: iics0 = 0001110b 4: iics0 = 000100b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 391 (c) start ~ address ~ data ~ start ~ code ~ data ~ stop (i) when wtim0 = 0 (after restart, extension code reception) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 5 2 1 st rw d7 to d0 ak 4 1: iics0 = 0001110b 2: iics0 = 0001000b 3: iics0 = 0010010b 4: iics0 = 0010000b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 (after restart, extension code reception) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 6 2 1 st rw d7 to d0 ak 5 4 1: iics0 = 0001110b 2: iics0 = 000100b 3: iics0 = 0010010b 4: iics0 = 0010110b 5: iics0 = 001000b 6: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 392 (d) start ~ address ~ data ~ start ~ address ~ data ~ stop (i) when wtim0 = 0 (after restart, does not match with address (= not extension code)) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 4 2 1 st rw d7 to d0 ak 1: iics0 = 0001110b 2: iics0 = 0001000b 3: iics0 = 0000010b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 (after restart, does not match with address (= not extension code)) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 4 2 1 st rw d7 to d0 ak 1: iics0 = 0001110b 2: iics0 = 000100b 3: iics0 = 0000010b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 393 (3) slave device operation (w hen receiving extension code) (a) start ~ code ~ data ~ data ~ stop (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 2 1 1: iics0 = 0010010b 2: iics0 = 0010000b 3: iics0 = 0010000b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 4 5 3 1 2 1: iics0 = 0010010b 2: iics0 = 0010110b 3: iics0 = 0010100b 4: iics0 = 001000b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 394 (b) start ~ code ~ data ~ start ~ address ~ data ~ stop (i) when wtim0 = 0 (after restart, matches with sva0) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 5 2 1 st rw d7 to d0 ak 4 1: iics0 = 0010010b 2: iics0 = 0010000b 3: iics0 = 0001110b 4: iics0 = 0001000b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 (after restart, matches with sva0) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 4 6 3 1 st rw d7 to d0 ak 5 2 1: iics0 = 0010010b 2: iics0 = 0010110b 3: iics0 = 001000b 4: iics0 = 0001110b 5: iics0 = 000100b 6: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 395 (c) start ~ code ~ data ~ start ~ code ~ data ~ stop (i) when wtim0 = 0 (after restart, extension code reception) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 5 2 1 st rw d7 to d0 ak 4 1: iics0 = 0010010b 2: iics0 = 0010000b 3: iics0 = 0010010b 4: iics0 = 0010000b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 (after restart, extension code reception) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 4 7 3 1 st rw d7 to d0 ak 6 2 5 1: iics0 = 0010010b 2: iics0 = 0010110b 3: iics0 = 001000b 4: iics0 = 0010010b 5: iics0 = 0010110b 6: iics0 = 001000b 7: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 396 (d) start ~ code ~ data ~ start ~ address ~ data ~ stop (i) when wtim0 = 0 (after restart, does not match with address (= not extension code)) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 3 4 2 1 st rw d7 to d0 ak 1: iics0 = 0010010b 2: iics0 = 0010000b 3: iics0 = 0000010b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (ii) when wtim0 = 1 (after restart, does not match with address (= not extension code)) st ad6 to ad0 rw ak d7 to d0 ad6 to ad0 ak ak sp 5 4 3 1 st rw d7 to d0 ak 2 1: iics0 = 0010010b 2: iics0 = 0010110b 3: iics0 = 001000b 4: iics0 = 0000010b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 397 (4) operation without communication (a) start ~ code ~ data ~ data ~ stop st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 1 1: iics0 = 00000001b remark : generated only when spie0 = 1 (5) arbitration loss operation (opera tion as slave after arbitration loss) (a) when arbitration loss occurs durin g transmission of slave address data (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 4 3 1 2 1: iics0 = 0101110b ( example when ald0 is read during interrupt servicing) 2: iics0 = 0001000b 3: iics0 = 0001000b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 398 (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 2 1 1: iics0 = 0101110b ( example when ald0 is read during interrupt servicing) 2: iics0 = 0001100b 3: iics0 = 000100b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (b) when arbitration loss occurs dur ing transmission of extension code (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 4 2 1 1: iics0 = 0110010b ( example when ald0 is read during interrupt servicing) 2: iics0 = 0010000b 3: iics0 = 0010000b 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 399 (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 4 5 3 1 2 1: iics0 = 0110010b ( example when ald0 is read during interrupt servicing) 2: iics0 = 0010110b 3: iics0 = 0010100b 4: iics0 = 001000b 5: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (6) operation when arbitration loss occurs (no communication after arbitration loss) (a) when arbitration loss occu rs during transmission of slave address data (when wtim0 = 1) st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 2 1 1: iics0 = 01000110b ( example when ald0 is read during interrupt servicing) 2: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 400 (b) when arbitration loss occurs dur ing transmission of extension code st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 2 1 1: iics0 = 0110010b ( example when ald0 is read during interrupt servicing) sets lrel0 = 1 by software 2: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (c) when arbitration loss occu rs during transmission of data (i) when wtim0 = 0 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 1 2 1: iics0 = 10001110b 2: iics0 = 01000000b ( example when ald0 is read during interrupt servicing) 3: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 401 (ii) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak ak sp 3 1 2 1: iics0 = 10001110b 2: iics0 = 01000100b ( example when ald0 is read during interrupt servicing) 3: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 (d) when loss occurs due to rest art condition during data transfer (i) not extension code (example: unmatches with sva0, wtim0 = 1) st ad6 to ad0 rw ak d7 to dn ad6 to ad0 ak sp 2 3 1 st rw d7 to d0 ak 1: iics0 = 1000110b 2: iics0 = 01000110b ( example when ald0 is read during interrupt servicing) 3: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care n = 6 to 0 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 402 (ii) extension code st ad6 to ad0 rw ak d7 to dn ad6 to ad0 ak sp 2 3 1 st rw d7 to d0 ak 1: iics0 = 1000110b 2: iics0 = 0110010b ( example when ald0 is read during interrupt servicing) sets lrel0 = 1 by software 3: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care n = 6 to 0 (e) when loss occurs due to st op condition during data transfer st ad6 to ad0 rw ak d7 to dn sp 2 1 1: iics0 = 1000110b 2: iics0 = 01000001b remark : always generated : generated only when spie0 = 1 : don?t care n = 6 to 0 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 403 (f) when arbitration loss occurs due to low-level da ta when attempting to generate a restart condition (i) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak sp 3 4 2 1 ak d7 to d0 ak stt0 = 1 1: iics0 = 1000110b 2: iics0 = 1000100b (sets stt0) 3: iics0 = 01000100b ( example when ald0 is read during interrupt servicing) 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care (g) when arbitration loss occurs due to a stop condition when attempting to generate a restart condition (i) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 ak sp 2 3 1 stt0 = 1 1: iics0 = 1000110b 2: iics0 = 100000b (sets stt0) 3: iics0 = 01000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 404 (h) when arbitration loss occurs due to low-level data when attemp ting to generate a stop condition (i) when wtim0 = 1 st ad6 to ad0 rw ak d7 to d0 d7 to d0 ak sp 3 4 2 1 ak d7 to d0 ak spt0 = 1 1: iics0 = 1000110b 2: iics0 = 100000b (sets spt0) 3: iics0 = 01000000b ( example when ald0 is read during interrupt servicing) 4: iics0 = 00000001b remark : always generated : generated only when spie0 = 1 : don?t care chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 405 16.6 timing charts when using the i 2 c bus mode, the master device outputs an address via the serial bus to select one of several slave devices as its communication partner. after outputting the slave address, the mast er device transmits the trc0 bit (bit 3 of iic status register 0 (iics0)), which specifies the data transfer di rection, and then starts serial communication with the slave device. figures 16-27 and 16-28 show timing charts of the data communication. iic shift register 0 (iic0)?s shift operation is synchronized with the falling edge of the serial clock (scl0). the transmit data is transferred to the so0 latch a nd is output (msb first) via the sda0 pin. data input via the sda0 pin is captured into iic0 at the rising edge of scl0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 406 figure 16-27. example of master to slave communication (when 9-clock wait is selected fo r both master and slave) (1/3) (1) start condition ~ address iic0 ackd0 std0 spd0 wtim0 h h l l l l h h h l l acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 iic0 ackd0 std0 spd0 wtim0 acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 scl0 sda0 processing by master device transfer lines processing by slave device 123456789 4 3 2 1 ad6 ad5 ad4 ad3 ad2 ad1 ad0 w ack d4 d5 d6 d7 iic0 address iic0 data iic0 ffh transmit start condition receive (when exc0 = 1) note note note to cancel slave wait, write ?ffh? to iic0 or set wrel0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 407 figure 16-27. example of master to slave communication (when 9-clock wait is selected fo r both master and slave) (2/3) (2) data iic0 ackd0 std0 spd0 wtim0 h h l l l l l l h h h h l l l l l acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 iic0 ackd0 std0 spd0 wtim0 acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 scl0 sda0 processing by master device transfer lines processing by slave device 1 9 8 23456789 3 2 1 d7 d0 d6 d5 d4 d3 d2 d1 d0 d5 d6 d7 iic0 data iic0 ffh iic0 ffh iic0 data transmit receive note note note note note to cancel slave wait, write ?ffh? to iic0 or set wrel0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 408 figure 16-27. example of master to slave communication (when 9-clock wait is selected fo r both master and slave) (3/3) (3) stop condition iic0 ackd0 std0 spd0 wtim0 h h l l l l h h h l acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 iic0 ackd0 std0 spd0 wtim0 acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 scl0 sda0 processing by master device transfer lines processing by slave device 123456789 2 1 d7 d6 d5 d4 d3 d2 d1 d0 ad5 ad6 iic0 data iic0 address iic0 ffh note iic0 ffh note stop condition start condition transmit note note (when spie0 = 1) receive (when spie0 = 1) note to cancel slave wait, write ?ffh? to iic0 or set wrel0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 409 figure 16-28. example of slave to master communication (when 9-clock wait is selected fo r both master and slave) (1/3) (1) start condition ~ address iic0 ackd0 std0 spd0 wtim0 h h l l h h l acke0 msts0 stt0 l l spt0 wrel0 intiic0 trc0 iic0 ackd0 std0 spd0 wtim0 acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 scl0 sda0 processing by master device transfer lines processing by slave device 123456789 4 56 3 2 1 ad6 ad5 ad4 ad3 ad2 ad1 ad0 r d4 d3 d2 d5 d6 d7 iic0 address iic0 ffh note note iic0 data start condition note to cancel master wait, write ?ffh? to iic0 or set wrel0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 410 figure 16-28. example of slave to master communication (when 9-clock wait is selected fo r both master and slave) (2/3) (2) data iic0 ackd0 std0 spd0 wtim0 h h h l l l l l l h h h l l l l l acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 iic0 ackd0 std0 spd0 wtim0 acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 scl0 sda0 processing by master device transfer lines processing by slave device 1 89 23456789 3 2 1 d7 d0 ack d6 d5 d4 d3 d2 d1 d0 ack d5 d6 d7 note note receive transmit iic0 data iic0 data iic0 ffh note iic0 ffh note note to cancel master wait, write ?ffh? to iic0 or set wrel0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 411 figure 16-28. example of slave to master communication (when 9-clock wait is selected fo r both master and slave) (3/3) (3) stop condition iic0 ackd0 std0 spd0 wtim0 h h l l l h acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 iic0 ackd0 std0 spd0 wtim0 acke0 msts0 stt0 spt0 wrel0 intiic0 trc0 scl0 sda0 processing by master device transfer lines processing by slave device 123456789 2 1 d7 d6 d5 d4 d3 d2 d1 d0 ad5 ad6 iic0 address iic0 ffh note iic0 data stop condition start condition (when spie0 = 1) n-ack (when spie0 = 1) note note to cancel master wait, write ?ffh? to iic0 or set wrel0. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 412 16.7 communication with lcd controller/driver with the 78k0/lg2, setting to lcd cont roller/driver is performed via the i 2 c bus interface. therefore reading and writing to the lcd controller/dr iver registers can be performed. 16.7.1 system configuration the system configuration of the lcd controller/driver in the 78k 0/lg2 is illustrat ed in figure 16-29. figure 16-29. system configuration cpu lcd controller /driver 78k0/lg2 scl0 sda0 sda0 scl0 serial clock serial data bus v dd v dd lscl lsda chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 413 16.7.2 write operation the processing procedure, format, and operation of writing to the l cd controller/driver via the i 2 c bus interface are explained below. the lcd controller/driver r egister to be accessed can be specified wit h the slave id and address (see figure 17-3). (1) processing procedure figure 16-30. processing procedure of write operation remark st: start condition rst: restart condition sp: stop condition slave id reception yes st detected? id matched? ack ?? m ack transmission address reception wd reception sp detection end lcd controller/driver side (slave) yes no no yes no slave id transmission address transmission wd transmission end cpu side (master) st generation ack reception yes ack transmission sp generation no ack transmission ack reception yes no ack reception yes no completed? yes no transfer direction chapter 16 serial interface iic0 414 preliminary user?s manual u17473ej1v0ud (2) communication format write data to each register on the l cd controller/driver starting from t he start condition, slave id, address, write data, then stop c ondition in that order. figure 16-31. communication format for wr ite operation (when writing twice) access target <1> st <2> slave id <3> r/w <4> ack <5> address <6> ack lcdctl st 0 1 1 1 0 0 0 0 ack a7 a6 a5 a4 a3 a2 a1 a0 ack lcdseg st 0 1 1 1 0 0 1 0 ack a7 a6 a5 a4 a3 a2 a1 a0 ack <7> write data 1 <8> ack <9> write data 2 <10> ack <11> sp d7 d6 d5 d4 d3 d2 d1 d0 ack d7 d6 d5 d4 d3 d2 d1 d0 ack sp d7 d6 d5 d4 d3 d2 d1 d0 ack d7 d6 d5 d4 d3 d2 d1 d0 ack sp note with the 78k0/lg2, the addre ss is incremented by one based on the r egister read/write start address by continuously performing read/write acce ss from transmissions of the start condition to stop condition. with this function, the address does not need to be set each time. cautions 1. generate a st op condition if an access like the one shown belo w is made. ? an access made in a forma t other than specified an access made with a slave id other than specified 2. when sda0 is fixed at the low level output stat us due to noise, input 0 to p130 (bit 0 of port register 13) to reset th e lcd controller/driver. remark st: start condition sp: stop condition a7 to a0: addresses for lcdctl or lcdseg address lcdctl: a1, a0 lcdseg: a5, a4, a3, a2, a1, a0 address note lcdctl: (a1, a0) + 1 lcdseg: (a5, a4, a3, a2, a1, a0) + 1 chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 415 (3) operation the operation flow when transmitting write data twice is shown below. steps <1> to <11> correspond to <1> to <11> in figure 16-31. <1> the start condition is transmitted. <2> the slave id is transmitted (from the 1st to 7th clocks). <3> r/w information (0) is transmitted (at the 8th clock). <4> an acknowledge signal is received (at the rising edge of the 9th clock). <5> the write start address is transmitted (f rom the 1st to 8th clocks following <4>). <6> an acknowledge signal is received (at the rising edge of the 9th clock). <7> write data is transmitted (first time) (from the 1st to 8th clocks following <6>). <8> an acknowledge signal is received (at the rising edge of the 9th clock). <9> write data is transmitted (second time) (f rom the 1st to 8th clocks following <8>). (the address is automatic ally incremented by 1.) <10> an acknowledge signal is received (at the rising edge of the 9th clock). <11> the stop condition is transmitted. figures 16-32 shows the timing c hart of the write operation. figure 16-32. timing chart of write operation 189 1 id6 rack 0 189 1 id6 ack xxh xxh xxh xxh xxh xxh xxh write to iic shift register 0 setup 89 a0 89 a0 ack ack xxh xxh xxh xxh 1 8 9 1 89 wd0 wd0 xxh xxh xxh xxh xxh xxh start condition stop condition start condition 189 1 89 8 19 0 xxh w wd7 ack ack wd7 scl sda scl0 sda0 lscl lsda master iic shift register 0 iic bus slave iic shift register write to iic shift register 0 write to iic shift register 0 stop condition setup setup chapter 16 serial interface iic0 416 preliminary user?s manual u17473ej1v0ud 16.7.3 read operation the processing procedure, format, and operation of reading the lcd controller/driver via the i 2 c bus interface are explained below. the lcd controller/driver r egister to be accessed can be specified wit h the slave id and address (see figure 17-3). (1) processing procedure figure 16-33. processing procedure of read operation remark st: start condition rst: restart condition sp: stop condition slave id reception yes st detected? no id matched? ack ?? m ack transmission address reception rst detected? slave id reception id matched? rd transmission ack reception sp detection end yes lcd controller/driver side (slave) no no yes yes no no yes no slave id transmission address transmission slave id transmission rd reception ack transmission end yes cpu side (master) yes no st generation ack reception yes rst generation ack transmission ack reception yes sp generation no no transfer direction ack reception yes no ack transmission chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 417 (2) communication format read data from each register on the l cd controller/driver starting from t he start condition, slave id, address, restart condition, slave id, read data, then stop condition in that order. figure 16-34. communication format for r ead operation (when reading twice) access target <1> st <2> slave id <3> r/w <4> ack <5> address <6> ack lcdctl st 0 1 1 1 0 0 0 0 ack a7 a6 a5 a4 a3 a2 a1 a0 ack lcdseg st 0 1 1 1 0 0 1 0 ack a7 a6 a5 a4 a3 a2 a1 a0 ack <7> rst <8> slave id <9> r/w <10> ack <11> read dara 1 <12> ack rst 0 1 1 1 0 0 0 1 ack d7 d6 d5 d4 d3 d2 d1 d0 ack rst 0 1 1 1 0 0 1 1 ack d7 d6 d5 d4 d3 d2 d1 d0 ack <13> read data2 <14> ack <15> sp d7 d6 d5 d4 d3 d2 d1 d0 nak sp d7 d6 d5 d4 d3 d2 d1 d0 nak sp note with the 78k0/lg2, the addre ss is incremented by one based on the r egister read/write start address by continuously performing read/write acce ss from transmissions of the start condition to stop condition. with this function, the address does not need to be set each time. cautions 1. generate a st op condition if an access like the one shown belo w is made. an access made in a forma t other than specified an access made with a slave id other than specified 2. when sda0 is fixed at the low level output stat us due to noise, input 0 to p130 (bit 0 of port register 13) to reset th e lcd controller/driver. remark st: start condition rst: restart condition sp: stop condition a7 to a0: addresses for lcdctl or lcdseg address lcdctl: a1, a0 lcdseg: a5, a4, a3, a2, a1, a0 address note lcdctl: (a1, a0) + 1 lcdseg: (a5, a4, a3, a2, a1, a0) + 1 chapter 16 serial interface iic0 418 preliminary user?s manual u17473ej1v0ud (3) operation the operation flow when receiving read data twice is shown below. steps <1> to <15> correspond to <1> to <15> in figure 16-34. <1> the start condition is transmitted. <2> the slave id is transmitted (first time) (from the 1st to 7th clocks). <3> r/w information (0) is transmitted (at the 8th clock). <4> an acknowledge signal is received (at the rising edge of the 9th clock). <5> the read start address is transmitted (f rom the 1st to 8th clocks following <4>). <6> an acknowledge signal is received (at the rising edge of the 9th clock). <7> the restart condition is transmitted. <8> the slave id is transmitted (second time) (from the 1st to 7th clocks following <7>). <9> r/w information (1) is transmitted (at the 8th clock). <10> an acknowledge signal is received (at the rising edge of the 9th clock). <11> read data is received (first time) (f rom the 1st to 8th clocks following <10>). <12> an acknowledge signal is transmitted (from the fa lling edge of the 8th clock to the falling edge of the 9th clock). <13> read data is received (second time) (fro m the 1st to 8th clocks following <12>). (the address is automatica lly incremented by 1.) <14> stop the acknowledge signal transmission. note <15> the stop condition is transmitted. note do not transmit the acknowledge signal when completing data reception. chapter 16 serial interface iic0 preliminary user?s manual u17473ej1v0ud 419 figures 16-35 shows the timing chart of the read operation. figure 16-35. timing chart of read operation (continued from above) scl 12 789 12 id6 id5 id0 wack sda 0 0 scl0 12 789 12 id6 id5 id0 w sda0 0 0 lscl ack lsda master iic shift register 0 xxh xxh xxh xxh xxh xxh xxh xxh xxh xxh xxh xxh write to iic shift register 0 setup iic bus 89 xxh xxh a0 89 a0 ack xxh xxh xxh xxh xxh ack 12 789 1 8 29 slave start condition setup start condition iic shift register 189 1 id6 rack rd7 189 1 id6 r rd7 ack xxh xxh xxh xxh xxh xxh xxh setup 89 rd0 89 rd0 ack ack xxh xxh xxh ffh write ffh or wrel0 = 1 xxh 1 89 1 89 rd7 rd0 rd7 rd0 xxh xxh xxh xxh xxh xxh xxh xxh ffh write ffh or wrel0 = 1 restart condition stop condition 189 1 89 8 1 stop condition 9 scl sda scl0 sda0 lscl lsda master iic shift register 0 iic shift register iic bus slave setup write to iic shift register 0 setup write to iic shift register write to iic shift register write to iic shift register restart condition preliminary user?s manual u17473ej1v0ud 420 chapter 17 lcd controller/driver 17.1 functions of lcd controller/driver the functions of the lcd controller/driver in the 78k0/lg2 are as follows. (1) the lcd driver reference voltage gener ator can switch internal voltage boos ting, external resistance division, and internal resistance division. (2) automatic output of segment and common signal s based on automatic display data memory read (3) five different display modes: static 1/2 duty (1/2 bias) 1/3 duty (1/2 bias) 1/3 duty (1/3 bias) 1/4 duty (1/3 bias) (4) four different frame frequencies, selectable in each display mode (5) up to 40 segment signal outputs (s0 to s39) and four common signal outputs (com0 to com3) table 17-1 lists the maximum number of pixels that can be displayed in each display mode. table 17-1. maximu m number of pixels lcd driver reference voltage generator bias mode number of time slices common signals used number of segments maximum number of pixels ? static com0 (com1 to com3) 40 (40 segment signals, 1 common signal) note 1 2 com0, com1 80 (40 segment signals, 2 common signals) note 2 external resistance division internal resistance division 1/2 3 com0 to com2 3 com0 to com2 120 (40 segment signals, 3 common signals) note 3 internal voltage boosting external resistance division internal resistance division 1/3 4 com0 to com3 40 160 (40 segment signals, 4 common signals) note 4 notes 1. 5-digit lcd panel, each digit having an 8-segment configuration. 2. 10-digit lcd panel, each digit having a 4-segment configuration. 3. 15-digit lcd panel, each digit having a 3-segment configuration. 4. 20-digit lcd panel, each digit having a 2-segment configuration. chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 421 17.2 configuration of lcd controller/driver the lcd controller/driver consis ts of the following hardware. the lcd controller/driver includes of two blocks: lcdseg block for cont rolling segments, and lcdctl block for controlling lcd register setting and mode setting. table 17-2. configuration of lcd controller/driver item configuration display outputs (lcdseg) 40 segment signals 4 common signals (com0 to com3) lcd controller/ driver control registers (lcdctl) lcd mode setting register (lcdmd) lcd display mode register (lcdm) lcd clock control register (lcdc) lcd voltage boost control register 0 (vlcg0) cpu control registers clock out put selection register (cks) port register 13 (p13) port mode register 14 (pm14) figure 17-1. hardware configur ation of lcd controller/driver lcd controller lcd driver lcdctl i 2 c bus interface lcdseg cpu scl0 sda0 p13 cks pm14 reset input clock input f pcl chapter 17 lcd controller/driver 422 preliminary user?s manual u17473ej1v0ud internal bus lcdc3 lcdc2 lcdc1 lcdc0 2 2 prescaler lcd clock selector selector f lcd 2 6 f lcd 2 7 f lcd 2 8 f lcd 2 9 lcd clock control register (lcdc) vlcon lcdm2 lcd display mode register (lcdm) v lc0 segment driver common driver com0 com1 com2 com3 3210 3210 65 74 lcdseg's 00h lcdon segment driver 3210 65 74 lcdseg's 27h s39 f pcl f pcl /2 f pcl /2 2 s0 - - - - - - - - - - f lcd selector 3210 lcdon lcdcl lcdm1 gain lcd voltage boost control register 0 (vlcg0) v lc2 caph capl v lc1 ------- ------- ------- ------- ------- ------- ------- timing controller vlcon lcdm0 ctsel1 ctsel0 lcdon scoc segset0 mdset1 lcd mode setting register (lcdmd) mdset0 segset2 segset1 lcd drive voltage controller 2 3 selector clock generator for boosting booster circuit segment voltage controller common voltage controller segment voltage controller display data memory figure 17-2. block diagram of lcd controller/driver remark f pcl : the clock generated by the clock output controller ------- chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 423 figure 17-3 shows the controll register of lcd controller/driver, and figur e 17-4 shows the lcd display ram. figure 17-3. controll register of lcd controller/driver address bit register 7 6 5 4 3 2 1 0 lcdctl's 03h ctsel1 ctsel0 0 0 0 0 0 gain vlcg0 02h 0 0 0 0 lcdc3 lcdc2 lcdc1 lcdc0 lcdc 01h lcdon scoc vlcon 0 0 lcdm2 lcdm1 lcdm0 lcdm lcdctl's 00h segset2 segset1 segset0 0 0 0 mdset1 mdset0 lcdmd figure 17-4. lcd display ram address bit segment 7 6 5 4 3 2 1 0 lcdseg's 27h 0 0 0 0 s39 26h 0 0 0 0 s38 25h 0 0 0 0 s37 24h 0 0 0 0 s36 23h 0 0 0 0 s35 22h 0 0 0 0 s34 21h 0 0 0 0 s33 20h 0 0 0 0 s32 1fh 0 0 0 0 s31 1eh 0 0 0 0 s30 1dh 0 0 0 0 s29 1ch 0 0 0 0 s28 1bh 0 0 0 0 s27 1ah 0 0 0 0 s26 19h 0 0 0 0 s25 18h 0 0 0 0 s24 17h 0 0 0 0 s23 16h 0 0 0 0 s22 15h 0 0 0 0 s21 14h 0 0 0 0 s20 13h 0 0 0 0 s19 12h 0 0 0 0 s18 11h 0 0 0 0 s17 10h 0 0 0 0 s16 0fh 0 0 0 0 s15 0eh 0 0 0 0 s14 0dh 0 0 0 0 s13 0ch 0 0 0 0 s12 0bh 0 0 0 0 s11 0ah 0 0 0 0 s10 09h 0 0 0 0 s9 08h 0 0 0 0 s8 07h 0 0 0 0 s7 06h 0 0 0 0 s6 05h 0 0 0 0 s5 04h 0 0 0 0 s4 03h 0 0 0 0 s3 02h 0 0 0 0 s2 01h 0 0 0 0 s1 lcdseg's 00h 0 0 0 0 s0 common com3 com2 com1 com0 remark bits 4 to 7 are fixed to 0. chapter 17 lcd controller/driver 424 preliminary user?s manual u17473ej1v0ud 17.3 registers controlling lcd controller/driver the following seven registers are used to control the lcd controller/driver. lcd mode setting register (lcdmd) lcd display mode register (lcdm) lcd clock control register (lcdc) lcd voltage boost control register 0 (vlcg0) clock output selection register (cks) port register 13 (p13) port mode register 14 (pm14) (1) lcd mode setting register (lcdmd) lcdmd sets the number of segments and the lcd reference voltage generator. lcdmd is set using an 8-bit memo ry manipulation instruction. reset input sets lcdmd to 00h. figure 17-5. format of lcd mode setting register address: lcdctl's 00h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 lcdmd segset2 segset1 segset0 0 0 0 mdset1 mdset0 segset2 segset1 segset0 segment number setting 0 0 40 other than above setting prohibited mdset1 mdset0 lcd reference voltage generator selection 0 0 external resistance division method 0 1 internal resistance division method 1 internal voltage boosting method cautions 1. bits 2 to 4 must be set to 0. 2. lcdmd can be set only once after a reset release. chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 425 (2) lcd display mode register (lcdm) lcdm specifies whether to enable display operation. it also specifies whether to enable segment pin/common pin output, booster circui t operation, and the display mode. lcdm is set using an 8-bit memory manipulation instruction. reset input sets lcdm to 00h. figure 17-6. format of l cd display mode register address: lcdctl's 01h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 lcdm lcdon scoc vlcon 0 0 lcdm2 lcdm1 lcdm0 lcdon lcd display enable/disable 0 display off (all segment outputs are deselected.) 1 display on scoc segment pin/common pin output control note 0 output ground level to segment/common pin 1 output deselect level to segment pin and lcd waveform to common pin vlcon booster circui t operation enable/disable note 0 no internal voltage boosting 1 internal voltage boosting enabled lcd controller/driver display mode selection resistance division method voltage boosting method lcdm2 lcdm1 lcdm0 number of time slices bias mode number of time slices bias mode 0 0 0 4 1/3 4 1/3 0 0 1 3 1/3 3 1/3 0 1 0 2 1/2 4 1/3 0 1 1 3 1/2 3 1/3 1 0 0 static setting prohibited other than above setting prohibited note when the lcd display panel is not used, scoc and vlcon must be set to 0 to conserve power. chapter 17 lcd controller/driver 426 preliminary user?s manual u17473ej1v0ud cautions 1. bits 3 and 4 must be set to 0. 2. when operating vlcon, follo w the procedure described below. a. to stop voltage boosting after switch ing display status from on to off : 1) set to display off status by setting lcdon = 0. 2) disable outputs of all the segment buffers and common bu ffers by setting scoc = 0. 3) stop voltage boosting by setting vlcon = 0. b. to stop voltage boosting during display on status : setting prohibited. be sure to stop vo ltage boosting after setting display off. c. to set display on from voltage boosting stop status : 1) start voltage boosting by setting vlcon = 1, then wait for voltage boost wait time (t vawait ) (see chapter 29 electrical specifications (target)). 2) set all the segment buffers and comm on buffers to non-display output status by setting scoc = 1. 3) set display on by setting lcdon = 1. (3) lcd clock control register (lcdc) lcdc specifies the lcd source clock and lcd clock. the frame frequency is determined according to t he lcd clock and the number of time slices. lcdc is set using an 8-bit memory manipulation instruction. reset input sets lcdc to 00h. figure 17-7. format of l cd clock control register address: lcdctl's 02h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 lcdc 0 0 0 0 l cdc3 lcdc2 lcdc1 lcdc0 lcdc3 lcdc2 lcd source clock (f lcd ) selection note 0 f pcl (clock generated by clock output controller) 1 0 f pcl /2 1 1 f pcl /2 2 lcdc1 lcdc0 lcd clock (lcdcl) selection 0 0 f lcd /2 6 0 1 f lcd /2 7 1 0 f lcd /2 8 1 1 f lcd /2 9 note specify an lcd source clock (f lcd ) frequency of at least 32 khz. cautions 1. bits 4 to 7 must be set to 0. 2. before changing the lcdc setting, be su re to stop voltage boosting (vlcon = 0). 3. set the frame frequency to 128 hz or lower. chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 427 (4) lcd voltage boost control register 0 (vlcg0) vlcg0 controls the voltage boost leve l during the voltage boost operation. vlcg0 is set with an 8-bit memo ry manipulation instruction. reset input sets vlcg0 to 00h. figure 17-8. format of lcd volt age boost control register 0 address: lcdctl's 03h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 vlcg0 ctsel1 ctsel0 0 0 0 0 0 gain gain reference voltage (v lc2 ) level selection note1 0 1.5 v (specification of the lcd panel used is 4.5 v.) 1 1.0 v (specification of the lcd panel used is 3 v.) contrast adjustment (typ.) note2 v lc0 v lc1 v lc2 ctsel1 ctsel0 gain = 0 gain = 1 gain = 0 gain = 1 gain = 0 gain = 1 1 0 4.89 v 3.29 v 3.27 v 2.27 v 1.633 v 1.133 v 1 1 4.71 v 3.21 v 3.13 v 2.13 v 1.567 v 1.067 v 0 0 4.50 v 3.00 v 3.00 v 2.00 v 1.500 v 1.000 v 0 1 4.29 v 2.79 v 2.87 v 1.87 v 1.433 v 0.933 v notes 1. select the settings according to the specif ications of the lcd panel that is used. 2. set these bits so that lv dd after voltage boosting becomes 2.0 to 5.5 v. cautions 1. bits 1 to 5 must be set to 0. 2. before changing the vlcg0 setting, be sure to stop voltage boosting (vlcon = 0). chapter 17 lcd controller/driver 428 preliminary user?s manual u17473ej1v0ud (5) clock output selection register (cks) cks enables/disables the clock output (pcl) to the lcd controller/driver, and sets the output clock. cks is set with a 1-bit or 8-bit memory manipulation instruction. reset input sets cks to 00h. figure 17-9. format of clock output selection register address: ff40h after reset: 00h r/w symbol 7 6 5 3 2 1 0 cks 0 0 0 cloe ccs3 ccs2 ccs1 ccs0 cloe pm140 specification of enable/disable for clock output to lcd controller/driver note 1 0 clock output to lcd controller/driver enabled other than above clock output to lcd controller/driver disabled pcl output clock selection ccs3 ccs2 ccs1 ccs0 f sub = 32.768 khz f prs = 10 mhz f prs = 20 mhz 0 1 1 0 f prs /2 6 156.25 khz 312.5 khz 0 1 1 1 f prs /2 7 - 78.125 khz 156.25 khz 1 0 0 0 f sub 32.768 khz - other than above setting prohibited note enabling/disabling the pcl clock output is specified by combini ng the pm140 settings (see (7) port mode register 14 (pm14)). caution bits 5 to 7 must be set to 0. remarks 1. f prs : peripheral hardware clock oscillation frequency 2. f sub : subsystem clock oscillation frequency 4 chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 429 (6) port register 13 (p13) p13 controls the reset for the lcd controller/driver. when using the lcd controlle r/driver, set p130 to 1. p13 is set with a 1-bit or 8-bit memory manipulation instruction. reset input sets p13 to 00h. figure 17-10. format of port register 13 address: ff0d h after reset: 00h ( output latch ) r/w symbol 7 6 5 4 3 2 1 0 p13 0 0 0 0 0 0 0 p130 p130 lcd controller/driver reset control 0 reset status set 1 reset status released (7) port mode register 14 (pm14) pm14 controls the clock output to the lcd controller/driver. when using the lcd controlle r/driver, set pm140 to 0. pm14 is set with a 1-bit or 8-bit memory manipulation instruction. reset input sets pm14 to ffh. figure 17-11. format of port mode register 14 address: ff2e h after reset: ff h ( output latch ) r/w symbol 7 6 5 4 3 2 1 0 pm14 1 1 1 1 1 1 1 pm140 pm140 clock output control to lcd controller/driver 0 clock output to lcd controller/driver enabled 1 clock output to lcd controller/driver disabled chapter 17 lcd controller/driver 430 preliminary user?s manual u17473ej1v0ud 17.4 setting lcd controller/driver set the lcd controller/driver using the following procedure. (1) voltage boosting method operation flow for transition of reset status to display st atus in lcd controller/driver <1> set p130 = 1 to release the reset status. <2> set the output clock using the cl ock output selection register (cks). <3> set pm140 = 0 to set output mode. <4> set cloe (bit 4 of cks) to 1 to enable the clock output. <5> set mdset1 (bit 1 of lcdmd) to 1 to set the internal voltage boosting method (initial setting: external resistance division method) <6> set the initial values to the lcd display dat a area (bits 0 to 3) in the lcd display ram. <7> set the display mode using lcdm0, lcdm1, and lcdm 2 (bits 0, 1, and 2 of l cd display mode register (lcdm)) (1/2 bias mode and static mode cannot be set). <8> set the lcd clock using lcd clock control register (lcdc). <9> set the voltage boost level and contrasts using lcd voltage boost control register 0 (vlcg0). gain = 0: v lc0 = 4.5 v, v lc1 = 3 v, v lc2 = 1.5 v gain = 1: v lc0 = 3 v, v lc1 = 2 v, v lc2 = 1 v <10> set vlcon (bit 5 of lcdm) to 1 to enable voltage boosting. <11> wait for voltage boost wait time (t vawait ) from setting of vlcon (see chapter 29 electrical specifications (target)). <12> set scoc (bit 6 of lcdm) to 1 to output the deselect voltage. <13> set lcdon (bit 7 of lcdm) to 1 and set data to the data memory in accordance with the display contents, after the output corresponding to each data memory is started. subsequent to this procedure, set the dat a to be displayed in the data memory. remark the register can be set in 1-bit units because the i 2 c bus is used for setting. chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 431 (2) resistance division method operation flow for transition of reset status to display st atus in lcd controller/driver <1> set p130 = 1 to release the reset status. <2> set the output clock using the cl ock output selection register (cks). <3> set pm140 = 0 to set output mode. <4> set cloe (bit 4 of cks) to 1 to enable the clock output. <5> set to the internal voltage boosting method using mdset0 and mdset1 (bit 0 and 1 of lcdmd). (mdset0, mdset1 = 0, 0: exter nal resistance division method, mdset0, mdset1 = 0, 1: inter nal resistance division method) <6> set the initial values to the lcd display dat a area (bits 0 to 3) in the lcd display ram. <7> set the display mode using lcdm0, lcdm1, and lcdm 2 (bits 0, 1, and 2 of l cd display mode register (lcdm)). <8> set the lcd clock using lcd clock control register (lcdc). <9> set scoc (bit 6 of lcdm) to 1 to output the deselect voltage. <10> set lcdon (bit 7 of lcdm) to 1 and set data to the data memory in accordance with the display contents, after the output corresponding to each data memory is started. subsequent to this procedure, set the dat a to be displayed in the data memory. remark the register can be set in 1-bit units because the i 2 c bus is used for setting. chapter 17 lcd controller/driver 432 preliminary user?s manual u17473ej1v0ud 17.5 lcd display data memory the lcd display data memory is mapped at addresses 00h to 27h of lcdseg. data in the lcd display data memory can be displayed on the lcd panel using the lcd controller/driver. figure 17-12 shows the relationship between the c ontents of the lcd disp lay data memory and the segment/common outputs. figure 17-12. relationship between lcd display data memory cont ents and segment/common outputs s0 lcdseg's 00h s1 lcdseg's 01h s2 lcdseg's 02h s3 lcdseg's 03h s37 lcdseg's 25h s38 lcdseg's 26h s39 lcdseg's 27h com3 com2 com1 com0 b7 b6 b5 b4 b3 b2 b1 b0 address caution no memory is allocated to the higher 4 bits of the lcd displ ay data memory. be sure to set there bits to 0. chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 433 17.6 common and segment signals each pixel of the lcd panel turns on when the pot ential difference between the corresponding common and segment signals becomes higher than a s pecific voltage (lcd drive voltage, v lcd ). the pixels turn off when the potential difference becomes lower than v lcd . applying dc voltage to the common and s egment signals of an lcd panel causes deterioration. to avoid this problem, this lcd panel is driven by ac voltage. (1) common signals each common signal is selected sequentially according to a specified number of ti me slices at the timing listed in table 17-3. in the st atic display mode, the same signal is output to com0 to com3. in the two-time-slice mode, leave t he com2 and com3 pins open. in t he three-time-slice mode, leave the com3 pin open. table 17-3. com signals com0 com1 com2 com3 com signal number of time slices static display mode two-time-slice mode three-time-slice mode four-time-slice mode open open open (2) segment signals the segment signals correspond to 40 bytes of lcd display data memory (00h to 27h of lcdseg). bits 0, 1, 2, and 3 of each byte are read in synchronization with com0, com1, com2, and com3, respectively. if a bit is 1, it is converted to the se lect voltage, and if it is 0, it is converted to the deselect voltage. the conversion results are output to the segment pins (s0 to s39). check, with the information given above, what combination of front-surfa ce electrodes (corresponding to the segment signals) and rear-surface electrodes (corres ponding to the common signals) forms display patterns in the lcd display data memory, and write the bit data that corresponds to the desired display pattern on a one-to-one basis. lcd display data memory bits 1 to 3, bits 2 and 3, and bi t 3 are not used for lcd displa y in the static display, two-time slot, and three-time slot modes, respectively . so these bits can be used for purposes other than display. lcd display data memory bits 4 to 7 are fixed to 0. chapter 17 lcd controller/driver 434 preliminary user?s manual u17473ej1v0ud (3) output waveforms of common and segment signals the voltages listed in t able 17-4 are output as co mmon and segment signals. when both common and segment signals are at t he select voltage, a display on-voltage of v lcd is obtained. the other combinations of the signals correspond to the display off-voltage. table 17-4. lcd drive voltage (a) static display mode segment signal select signal level deselect signal level common signal lv ss /v lc0 v lc0 /lv ss v lc0 /lv ss ?v lcd /+v lcd 0 v/0 v (b) 1/2 bias method segment signal select signal level deselect signal level common signal lv ss /v lc0 v lc0 /lv ss select signal level v lc0 /lv ss ?v lcd /+v lcd 0 v/0 v deselect signal level v lc1 = v lc2 ? v lcd /+ v lcd + v lcd /? v lcd (c) 1/3 bias method segment signal select signal level deselect signal level common signal lv ss /v lc0 v lc1 /v lc2 select signal level v lc0 /lv ss ?v lcd /+v lcd ? v lcd /+ v lcd deselect signal level v lc2 /v lc1 ? v lcd /+ v lcd ? v lcd /+ v lcd 1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 435 figure 17-13 shows the common signal waveforms, and figure 17-14 shows the vo ltages and phases of the common and segment signals. figure 17-13. common signal waveforms (a) static display mode comn (static display) t f = t v lc0 lv ss v lcd t: one lcd clock period t f : frame frequency (b) 1/2 bias method comn (two-time slot mode) t f = 2 t v lc0 lv ss v lcd v lc2 comn (three-time slot mode) t f = 3 t v lc0 lv ss v lcd v lc2 t: one lcd clock period t f : frame frequency (c) 1/3 bias method comn (three-time slot mode) t f = 3 t v lc0 lv ss v lcd v lc1 v lc2 t f = 4 t comn (four-time slot mode) v lc0 v lcd v lc1 v lc2 lv ss t: one lcd clock period t f : frame frequency chapter 17 lcd controller/driver 436 preliminary user?s manual u17473ej1v0ud figure 17-14. voltages and phases of common and segment signals (a) static display mode select deselect common signal segment signal v lc0 lv ss v lcd v lc0 lv ss v lcd tt t: one lcd clock period (b) 1/2 bias method select deselect common signal segment signal v lc0 lv ss v lcd v lc0 lv ss v lcd tt v lc2 v lc2 t: one lcd clock period (c) 1/3 bias method select deselect common signal segment signal v lc0 lv ss v lcd v lc0 lv ss v lcd tt v lc2 v lc2 v lc1 v lc1 t: one lcd clock period chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 437 17.7 display modes 17.7.1 static display example figure 17-16 shows how the five-digit lcd panel having the display pattern shown in figure 17-15 is connected to the segment signals (s0 to s39) and the common signal (com 0) of the 78k0/lg2 chip. this example displays data "12.345" in the lcd panel. the content s of the display data memory (addre sses 00h to 27h of lcdseg) correspond to this display. the following description focuses on numeral "2." ( ) disp layed in the fourth digit. to display "2." in the lcd panel, it is necessary to apply the select or deselect voltage to the s24 to s31 pins according to table 17-5 at the timing of the common signal com0; see figure 17-15 fo r the relationship between the segment signals and lcd segments. table 17-5. select and deselect voltages (com0) segment s24 s25 s26 s27 s28 s29 s30 s31 common com0 select deselect select select deselect select select select according to table 17-5, it is determined that the bit-0 pattern of the display data memory locations (18h to 1fh of lcdseg) must be 10110111. figure 17-17 shows the lcd drive waveforms of s27 and s 28, and com0. when the select voltage is applied to s27 at the timing of com0, an alternate rectangle waveform, +v lcd / ? v lcd , is generated to turn on the corresponding lcd segment. com1 to com3 are supplied with the same waveform as for com0. so, com0 to com3 may be connected together to increase t he driving capacity. figure 17-15. static lcd display pattern and electrode connections s 8n+3 s 8n+2 s 8n+5 s 8n+1 s 8n s 8n+4 s 8n+6 s 8n+7 com0 remark n = 0 to 4 chapter 17 lcd controller/driver 438 preliminary user?s manual u17473ej1v0ud figure 17-16. example of connecting static lcd panel 0000011011101101101011100011011010111010 bit 3 bit 2 bit 1 bit 0 timing strobe data memory address lcd panel lcdseg's 00h 1 2 3 4 5 6 7 8 9 a b c d e f lcdseg's 10h 1 2 3 4 5 6 7 8 9 a b c d e f lcdseg's 20h 1 2 3 4 5 6 7 s 0 s 1 s 2 s 3 s 4 s 5 s 6 s 7 s 8 s 9 s 10 s 11 s 12 s 13 s 14 s 15 s 16 s 17 s 18 s 19 s 20 s 21 s 22 s 23 com 3 com 2 com 1 com 0 s 24 s 25 s 26 s 27 s 28 s 29 s 30 s 31 s 32 s 33 s 34 s 35 s 36 s 37 s 38 s 39 can be connected together chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 439 figure 17-17. static l cd drive waveform examples t f v lc0 lv ss com0 v lc0 lv ss s27 v lc0 lv ss s28 +v lcd 0 com0-s28 - v lcd +v lcd 0 com0-s27 - v lcd chapter 17 lcd controller/driver 440 preliminary user?s manual u17473ej1v0ud 17.7.2 two-time-s lice display example figure 17-19 shows how the 10-digit lcd panel having the di splay pattern shown in figure 17-18 is connected to the segment signals (s0 to s39) and the common signals (c om0 and com1) of the 78k0/lg 2 chip. this example displays data "123456.7890" in the lcd panel. the contents of the di splay data memory (addresses 00h to 27h of lcdseg) correspond to this display. the following description focuses on numeral "3" ( ) displa yed in the eighth digit. to display "3" in the lcd panel, it is necessary to apply the select or deselect voltage to t he s28 to s31 pins according to table 17-6 at the timing of the common signals com0 and com1; see figure 17-18 for the relationship between t he segment signals and lcd segments. table 17-6. select and desel ect voltages (com0 and com1) segment s28 s29 s30 s31 common com0 select select deselect deselect com1 deselect select select select according to table 17-6, it is det ermined that the display data memory location (1fh of lcdseg) that corresponds to s31 must contain xx10. figure 17-20 shows examples of lcd drive waveforms between the s31 signal and each common signal. when the select voltage is applied to s31 at the ti ming of com1, an alternate rectangle waveform, +v lcd / ? v lcd , is generated to turn on the corresponding lcd segment. figure 17-18. two-time-slice lcd displ ay pattern and electrode connections s 4n+2 s 4n+3 s 4n+1 s 4n com0 com1 remark n = 0 to 9 chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 441 figure 17-19. example of connecting two-time-slice lcd panel 0011101000110111010111010111111101111111 0000111011100010111011110100111001101100 bit 3 bit 2 bit 1 bit 0 timing strobe data memory address lcd panel lcdseg's 00h 1 2 3 4 5 6 7 8 9 a b c d e f lcdseg's 10h 1 2 3 4 5 6 7 8 9 a b s 0 s 1 s 2 s 3 s 4 s 5 s 6 s 7 s 8 s 9 s 10 s 11 s 12 s 13 s 14 s 15 s 16 s 17 s 18 s 19 s 20 s 21 s 22 s 23 s 24 s 25 s 26 s 27 com 3 com 2 com 1 com 0 open open c d e f lcdseg's 20h 1 2 3 4 5 6 7 s 28 s 29 s 30 s 31 s 32 s 33 s 34 s 35 s 36 s 37 s 38 s 39 : can always be used to store any data bec ause the two-time-slice mode is being used. chapter 17 lcd controller/driver 442 preliminary user?s manual u17473ej1v0ud figure 17-20. two-time-slice lcd dri ve waveform examples (1/2 bias method) t f v lc0 lv ss com0 v lc0 lv ss v lc0 lv ss s31 +v lcd 0 com1-s31 - v lcd +v lcd 0 com0-s31 - v lcd v lc1,2 v lc1,2 v lc1,2 com1 +1/2v lcd +1/2v lcd - 1/2v lcd - 1/2v lcd chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 443 17.7.3 three-time-s lice display example figure 17-22 shows how the 13-digit lcd panel having the di splay pattern shown in figure 17-21 is connected to the segment signals (s0 to s38) and the common signals (c om0 to com2) of the 78k0/ lg2 chip. this example displays data "123456.7890123" in the lcd panel . the contents of the display dat a memory (addresses 00h to 26h of lcdseg) correspond to this display. the following description focuses on numeral "6." ( ) disp layed in the eighth digit. to display "6." in the lcd panel, it is necessary to apply the select or deselect voltage to the s21 to s23 pins according to table 17-7 at the timing of the common signals com0 to com2; see figure 17-21 for the relationship bet ween the segment signals and lcd segments. table 17-7. select and desel ect voltages (com0 to com2) segment s21 s22 s23 common com0 deselect select select com1 select select select com2 select select ? according to table 17-7, it is det ermined that the display data memory location (15h of lcdseg) that corresponds to s21 must contain x110. figures 17-23 and 17-24 show exampl es of lcd drive waveforms bet ween the s21 signal and each common signal in the 1/2 and 1/3 bias methods, respectively. when t he select voltage is applied to s21 at the timing of com1 or com2, an alternate rectangle waveform, +v lcd / ? v lcd , is generated to turn on the corresponding lcd segment. figure 17-21. three-time-slice lcd displ ay pattern and electrode connections s 3n+2 s 3n com0 com2 s 3n+1 com1 remark n = 0 to 12 chapter 17 lcd controller/driver 444 preliminary user?s manual u17473ej1v0ud figure 17-22. example of conn ecting three-time-slice lcd panel timing strobe com3 com2 com1 com0 bit0 bit1 bit2 bit3 s0 s1 s2 s3 1 0 lcdseg 's 00h 1 1 1 0 2 1 0 3 s4 s5 s6 s7 1 1 4 0 5 1 0 6 0 0 7 s8 s9 s10 s11 0 8 1 0 9 1 1 a 1 b s12 s13 s14 s15 1 0 c 1 0 d 1 e 1 0 f s16 s17 s18 s19 1 1 lcdseg 's 10h 1 1 1 0 2 1 0 3 s20 s21 s22 s23 1 4 0 1 5 1 1 6 1 7 s24 s25 s26 s27 0 0 8 1 1 9 1 a 1 0 b s28 s29 s30 s31 0 0 c 1 d 1 0 e 1 1 f s32 s33 s34 s35 0 lcdseg 's 20h 1 0 1 1 1 2 0 3 s36 s37 s38 1 0 4 0 0 5 0 6 data memory address lcd panel open 1 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 1 1 0 1 1 0 0 1 1 1 0 0 ' ' ' ' ' ' ' ' ' ' ' ' ' ?: can be used to store any data because there is no corres ponding segment in the lcd panel. : can always be used to store any data becaus e the three-time-slice mode is being used. chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 445 figure 17-23. three-time-slice lcd dri ve waveform examples (1/2 bias method) t f v lc0 lv ss com0 v lc0 lv ss v lc0 lv ss com2 +v lcd 0 com1-s21 - v lcd +v lcd 0 com0-s21 - v lcd v lc1,2 v lc1,2 v lc1,2 com1 +1/2v lcd +1/2v lcd - 1/2v lcd - 1/2v lcd v lc0 lv ss s21 v lc1,2 +v lcd 0 com2-s21 - v lcd +1/2v lcd - 1/2v lcd chapter 17 lcd controller/driver 446 preliminary user?s manual u17473ej1v0ud figure 17-24. three-time-slice lcd dri ve waveform examples (1/3 bias method) v lc0 v lc2 com0 +v lcd 0 com0-s21 - v lcd v lc1 +1/3v lcd - 1/3v lcd lv ss v lc0 v lc2 com1 v lc1 lv ss v lc0 v lc2 com2 v lc1 lv ss v lc0 v lc2 s21 v lc1 lv ss +v lcd 0 com1-s21 - v lcd +1/3v lcd - 1/3v lcd +v lcd 0 com2-s21 - v lcd +1/3v lcd - 1/3v lcd t f chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 447 17.7.4 four-time-sli ce display example figure 17-26 shows how the 20-digit lcd panel having the di splay pattern shown in figure 17-25 is connected to the segment signals (s0 to s39) and the common signals (c om0 to com3) of the 78k0/ lg2 chip. this example displays data "123456.78901234567890" in the lcd panel. the cont ents of the display data memory (addresses 00h to 27h of lcdseg) correspond to this display. the following description focuses on numeral "6." ( ) disp layed in the 15th digit. to display "6." in the lcd panel, it is necessary to apply the select or deselect voltage to t he s28 and s29 pins according to table 17-8 at the timing of the common signals com0 to com3; see figure 17-25 fo r the relationship between the segment signals and lcd segments. table 17-8. select and desel ect voltages (com0 to com3) segment s28 s29 common com0 select select com1 deselect select com2 select select com3 select select according to table 17-8, it is determined that the display data memo ry location (1ch of lcdseg) that corresponds to s28 must contain 1101. figure 17-27 shows examples of lcd drive waveforms between the s28 signal and each common signal. when the select voltage is applied to s28 at the ti ming of com0, an alternate rectangle waveform, +v lcd / ? v lcd , is generated to turn on the corresponding lcd segment. figure 17-25. four-time-slice lcd displ ay pattern and electrode connections remark n = 0 to 19 com0 s 2n com1 s 2n+1 com2 com3 chapter 17 lcd controller/driver 448 preliminary user?s manual u17473ej1v0ud figure 17-26. example of connecting four-time-slice lcd panel timing strobe com3 com2 com1 com0 bit0 bit1 bit2 bit3 s0 s1 s2 s3 1 1 0 lcdseg's 00h 1 1 1 1 1 1 0 2 1 0 0 3 s4 s5 s6 s7 1 1 0 4 1 1 1 5 1 1 0 6 1 0 0 7 s8 s9 s10 s11 1 1 0 8 1 1 1 9 1 1 0 a 1 0 1 b s12 s13 s14 s15 0 1 0 c 1 0 0 d 1 1 0 e 0 0 1 f s16 s17 s18 s19 1 0 0 lcdseg's 10h 0 1 1 1 0 1 0 2 0 0 0 3 s20 s21 s22 s23 1 1 0 4 1 1 1 5 1 1 0 6 1 0 0 7 s24 s25 s26 s27 1 1 0 8 1 1 1 9 1 1 0 a 1 0 0 b s28 s29 s30 s31 1 1 1 c 1 1 1 d 1 1 0 e 1 0 1 f s32 s33 s34 s35 0 1 0 lcdseg's 20h 1 0 0 1 1 1 0 2 0 0 1 3 s36 s37 s38 s39 1 0 0 4 0 1 1 5 0 1 0 6 0 0 0 7 data memory address lcd panel 1 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1 0 chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 449 figure 17-27. four-time-slice lcd dri ve waveform examples (1/3 bias method) v lc0 v lc2 com0 +v lcd 0 com0-s28 - v lcd v lc1 +1/3v lcd - 1/3v lcd lv ss v lc0 v lc2 com1 v lc1 lv ss v lc0 v lc2 com2 v lc1 lv ss v lc0 v lc2 com3 v lc1 lv ss +v lcd 0 com1-s28 - v lcd +1/3v lcd - 1/3v lcd v lc0 v lc2 s28 v lc1 lv ss t f remark the waveforms for com2 to s28 and com3 to s28 are omitted. chapter 17 lcd controller/driver 450 preliminary user?s manual u17473ej1v0ud 17.8 supplying lcd drive voltages v lc0 , v lc1 , and v lc2 with the 78k0/lg2, a lcd drive power supply can be generated using either of three types of methods: internal resistance division method, external resistance di vision method, or inter nal voltage boosting method. 17.8.1 internal resi stance division method the 78k0/lg2 incorporates vo ltage divider resistors for generating lcd dr ive power supplies. using internal voltage divider resistors, a lcd drive power supply that meet each bias met hod listed in table 17-9 can be generated, without using external vo ltage divider resistors. table 17-9. lcd drive voltages (with on-chip voltage divider resistors) bias method no bias (static) 1/2 bias method 1/3 bias method lcd drive voltage pin v lc0 v lcd v lcd v lcd v lc1 v lcd v lcd note v lcd v lc2 v lcd v lcd note for the 1/2 bias method, it is necessary to connect the v lc1 and v lc2 pins externally. figure 17-28 shows examples of gener ating lcd drive voltages interna lly according to table 17-9. 2 3 2 3 1 2 1 3 1 3 chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 451 figure 17-28. examples of lcd drive power conn ections (internal resistance division method) (a) 1/3 bias method and static display mode v lc0 v lcd r r r v lc1 v lc2 lv ss (b) 1/2 bias method v lc0 v lcd r r r v lc1 v lc2 lv ss chapter 17 lcd controller/driver 452 preliminary user?s manual u17473ej1v0ud 17.8.2 external resi stance division method the 78k0/lg2 can also use external voltage divider resistors for generati ng lcd drive power supplies, without using internal resistors. figure 17- 29 shows examples of lcd drive volt age connection, corresponding to each bias method. figure 17-29. examples of lcd drive power conn ections (external resistance division method) (a) static display mode (b) 1/2 bias method v lc0 v lcd r v lc1 v lc2 lv ss v lc0 v lcd r v lc1 v lc2 lv ss r (c) 1/3 bias method v lc0 v lcd r v lc1 v lc2 lv ss r r chapter 17 lcd controller/driver preliminary user?s manual u17473ej1v0ud 453 17.8.3 internal voltage boosting method the 78k0/lg2 contains a booster circuit ( 3 only) to generate a supply voltage to drive the lcd. the internal lcd reference voltage is output from the v lc2 pin. a voltage two times higher than that on v lc2 is output from the v lc1 pin and a voltage three times higher than that on v lc2 is output from the v lc0 pin. the lcd reference voltage (v lc2 ) can be specified by setting lcd boos t control register 0 (vlcg0). the 78k0/lg2 requires an external capacitor (recommended value: 0.47 f) when the internal voltage boosting method is selected. table 17-10. output voltages of v lc0 to v lc2 pins vlcg0 gain = 0 gain = 1 lcd drive power supply pin v lc0 4.5 v 3.0 v v lc1 3.0 v 2.0 v v lc2 (lcd reference voltage) 1.5 v 1.0 v cautions 1. when using the lcd function, do not leave the v lc0 , v lc1 , and v lc2 pins open. refer to figure 17-30 for connection. 2. since the lcd dri ve voltage is separate from the main power supply, a constant voltage can be supplied regardless of v dd and lv dd fluctuation. figure 17-30. example of conn ecting pins for lcd driver v lc0 v lc1 v lc2 c2 c3 c4 caph c1 external pin c1 = c2 = c3 = c4 = 0.47 f capl remark use a capacitor with as little leakage as possible. in addition, make c1 a nonpolar capacitor. preliminary user?s manual u17473ej1v0ud 454 chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) only for the pd78f0395, 78f0397, and 78 f0397d, the multiplier/d ivider is provided. 18.1 functions of multiplier/divider the multiplier/divider has the following functions. ? 16 bits 16 bits = 32 bits (multiplication) ? 32 bits 16 bits = 32 bits, 16-bit remainder (division) 18.2 configuration of multiplier/divider the multiplier/divider incl udes the following hardware. table 18-1. configuration of multiplier/divider item configuration registers remainder data register 0 (sdr0) multiplication/division data r egisters a0 (mda0h, mda0l) multiplication/division dat a registers b0 (mdb0) control register multiplier/divider control register 0 (dmuc0) figure 18-1 shows the block diagram of the multiplier/divider. chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 455 figure 18-1. block diagra m of multiplier/divider internal bus cpu clock start clear 17-bit adder controller multiplication/division data register b0 (mdb0 (mdb0h + mdb0l) remainder data register 0 (sdr0 (sdr0h + sdr0l) 6-bit counter dmusel0 multiplier/divider control register 0 (dmuc0) controller multiplication/division data register a0 ( mda0h (mda0hh + mda0hl) + mda0l (mda0lh + mda0ll) ) controller dmue mda000 intdmu chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 456 (1) remainder data register 0 (sdr0) sdr0 is a 16-bit register that stores a remainder. th is register stores 0 in the multiplication mode and the remainder of an operation result in the division mode. sdr0 can be read by an 8-bit or 16-bit memory manipulation instruction. reset input clears sdr0 to 0000h. figure 18-2. format of remainder data register 0 (sdr0) address: ff60h, ff61h after reset: 0000h r symbol ff61h (sdr0h) ff60h (sdr0l) sdr0 sdr 015 sdr 014 sdr 013 sdr 012 sdr 011 sdr 010 sdr 009 sdr 008 sdr 007 sdr 006 sdr 005 sdr 004 sdr 003 sdr 002 sdr 001 sdr 000 cautions 1. the value read from sdr0 duri ng operation processing (while bit 7 (dmue) of multiplier/divider control register 0 (dmuc0) is 1) is not guaranteed. 2. sdr0 is reset when the operation is started (when dmue is set to 1). (2) multiplication/division data register a0 (mda0h, mda0l) mda0 is a 32-bit register that sets a 16-bit multiplier a in the multiplication mode and a 32-bit dividend in the division mode, and stores the 32-bit result of the oper ation (higher 16 bits: mda0h, lower 16 bits: mda0l). figure 18-3. format of mult iplication/division data regi ster a0 (mda0h, mda0l) address: ff62h, ff63h, ff64h, ff65h after reset: 0000h, 0000h r/w symbol ff65h (mda0hh) ff64h (mda0hl) mda0h mda 031 mda 030 mda 029 mda 028 mda 027 mda 026 mda 025 mda 024 mda 023 mda 022 mda 021 mda 020 mda 019 mda 018 mda 017 mda 016 symbol ff63h (mda0lh) ff62h (mda0ll) mda0l mda 015 mda 014 mda 013 mda 012 mda 011 mda 010 mda 009 mda 008 mda 007 mda 006 mda 005 mda 004 mda 003 mda 002 mda 001 mda 000 cautions 1. mda0h is cleared to 0 when an operation is starte d in the multiplication mode (when multiplier/divider control regist er 0 (dmuc0) is set to 81h). 2. do not change the value of mda0 duri ng operation processing (whi le bit 7 (dmue) of multiplier/divider control regi ster 0 (dmuc0) is 1). even in this case, the operation is executed, but the result is undefined. 3. the value read from mda0 during operation processi ng (while dmue is 1) is not guaranteed. chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 457 the functions of mda0 when an operation is executed are shown in the table below. table 18-2. functions of mda0 during operation execution dmusel0 operation mode setting operation result 0 division mode di vidend division result (quotient) 1 multiplication mode higher 16 bits: 0, lower 16 bits: multiplier a multiplication result (product) the register configuration differs between when multiplication is executed and when division is executed, as follows. ? register configuration during multiplication chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 458 18.3 register controlling multiplier/divider the multiplier/divider is controlled by mult iplier/divider control register 0 (dmuc0). (1) multiplier/divider c ontrol register 0 (dmuc0) dmuc0 is an 8-bit register that controls the operation of the multiplier/divider. dmuc0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears dmuc0 to 00h. figure 18-5. format of multiplier/divider control register 0 (dmuc0) dmue dmuc0 0 0 0 0 0 0 dmusel0 stops operation starts operation dmue note 0 1 operation start/stop division mode multiplication mode dmusel0 0 1 operation mode (multiplication/division) selection address: ff68h after reset: 00h r/w symbol 4 3 2 1 0 6 <7> 5 note when dmue is set to 1, the operati on is started. dmue is automatically cleared to 0 after the operation is complete. cautions 1. if dmue is cleared to 0 during ope ration processing (when dmue is 1), the operation result is not guaranteed. if the operation is comp leted while the clearing instruction is being executed, the operation result is guaranteed, provided that the interrupt flag is set. 2. do not change the value of dmusel0 during operation processing (w hile dmue is 1). if it is changed, undefined operation r esults are stored in multiplicat ion/division data register a0 (mda0) and remainder data register 0 (sdr0). 3. if dmue is cleared to 0 during opera tion processing (while dmue is 1), the operation processing is stopped. to execute the operati on again, set multiplication/division data register a0 (mda0), multiplication/division data register b0 (mdb0), and multiplier/divider control register 0 (dmuc0), and star t the operation (by setting dmue to 1). chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 459 18.4 operations of multiplier/divider 18.4.1 multiplication operation ? initial setting 1. set operation data to multiplicati on/division data register a0l (mda0l) a nd multiplication/division data register b0 (mdb0). 2. set bits 0 (dmusel0) and 7 (dmue) of multiplier/divi der control register 0 (dmuc0) to 1. operation will start. ? during operation 3. the operation will be completed when 16 internal clocks have been issued after the start of the operation (intermediate data is stored in t he mda0l and mda0h registers during operation, and t herefore the read values of these registers are not guaranteed). ? end of operation 4. the operation result data is stor ed in the mda0l and mda0h registers. 5. dmue is cleared to 0 (end of operation). 6. after the operation, an interrup t request signal (intdmu) is generated. ? next operation 7. to execute multiplication next, start from the initial setting in 18.4.1 multiplication operation . 8. to execute division next, start from the initial setting in 18.4.2 division operation . chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 460 figure 18-6. timing chart of multiplication operation (00dah 0093h) operation clock mda0 sdr0 mdb0 1 2 345 6 78 9a b cd e f 10 0 0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 006d 0000 00da xxxx 00da xxxx xxxx xxxx 0049 8036 0024 c01b 005b e00d 0077 7006 003b b803 0067 5c01 007d 2e00 003e 9700 001f 4b80 000f a5c0 0007 d2e0 0003 e970 0001 f4b8 0000 fa5c 0000 7d2e 0093 xxxx internal clock dmue dmusel0 counter intdmu chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 461 18.4.2 division operation ? initial setting 1. set operation data to multiplicati on/division data register a0 (mda0l and mda0h) and multiplication/division data register b0 (mdb0). 2. set bits 0 (dmusel0) and 7 (dmue) of multiplier/divider control register 0 (dmuc0) to 0 and 1, respectively. operation will start. ? during operation 3. the operation will be completed when 32 internal clocks have been issued after the start of the operation (intermediate data is stored in the mda0l and mda0 h registers and remainder data register 0 (sdr0) during operation, and theref ore the read values of these registers are not guaranteed). ? end of operation 4. the result data is stored in th e mda0l, mda0h, and sdr0 registers. 5. dmue is cleared to 0 (end of operation). 6. after the operation, an interrup t request signal (intdmu) is generated. ? next operation 7. to execute multiplication next, start from the initial setting in 18.4.1 multiplication operation . 8. to execute division next, start from the initial setting in 18.4.2 division operation . chapter 18 multiplier/divider ( pd78f0395, 78f0397, and 78f0397d only) preliminary user?s manual u17473ej1v0ud 462 figure 18-7. timing chart of division operation (dcba2586h 0018h) operation clock mda0 sdr0 mdb0 12345678 19 1a 1b 1c 1d 1e 1f 20 0 0 0000 0001 0003 0006 000d 0003 0007 000e 0004 000b 0016 0014 0010 0008 0011 000b 0016 b974 4b0c dcba 2586 xxxx xxxx xxxx 72e8 9618 e5d1 2c30 cba2 5860 9744 b0c1 2e89 6182 5d12 c304 ba25 8609 0c12 64d8 1824 c9b0 3049 9361 6093 26c3 c126 4d87 824c 9b0e 0499 361d 0932 6c3a 0018 xxxx internal clock dmue dmusel0 counter intdmu ?0? preliminary user?s manual u17473ej1v0ud 463 chapter 19 interrupt functions 19.1 interrupt function types the following two types of inte rrupt functions are used. (1) maskable interrupts these interrupts undergo mask control. maskable interrup ts can be divided into a high interrupt priority group and a low interrupt priority group by setting the priority specification flag registers (pr0l, pr0h, pr1l, pr1h). multiple interrupt servicing can be applied to low-priority interrupts when high-priority interrupts are generated. if two or more interrupts with the same priority are generated simultaneously, each interrupt is serviced according to its predetermined priority (see table 19-1 ). a standby release signal is generated a nd stop and halt modes are released. external interrupt requests and internal interrupt requests are provided as maskable interrupts. ? pd78f0393 external: 7, internal: 16 ? pd78f0395, 78f0397, 78f0397d external: 7, internal: 19 (2) software interrupt this is a vectored interrupt generated by executing the brk instruction. it is acknowledged even when interrupts are disabled. the software interrupt does not undergo interrupt priority control. 19.2 interrupt sources and configuration the pd78f0393 has a total of 24 interrupt sources, and the pd78f0395, 78f0397, and 78f0397d have a total of 27 interrupt sources, including maskable interrupts and softw are interrupts. in addition, they also have up to four reset sources (see table 19-1 ). chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 464 table 19-1. interrupt source list (1/2) interrupt source interrupt type default priority note 1 name trigger internal/ external vector table address basic configuration type note 2 0 intlvi low-voltage detection note 3 internal 0004h (a) 1 intp0 0006h 2 intp1 0008h 3 intp2 000ah 4 intp3 000ch 5 intp4 000eh 6 intp5 pin input edge detection external 0010h (b) 7 intsre6 uart6 reception error generation 0012h 8 intsr6 end of uart6 reception 0014h 9 intst6 end of uart6 transmission 0016h 10 intcsi10/ intst0 end of csi10 communication/end of uart0 transmission 0018h 11 inttmh1 match between tmh1 and cmp01 (when compare register is specified) 001ah 12 inttmh0 match between tmh0 and cmp00 (when compare register is specified) 001ch 13 inttm50 match between tm50 and cr50 (when compare register is specified) 001eh 14 inttm000 match between tm00 and cr000 (when compare register is specified), ti010 pin valid edge detection (when capture register is specified) 0020h 15 inttm010 match between tm00 and cr010 (when compare register is specified), ti000 pin valid edge detection (when capture register is specified) 0022h 16 intad end of a/d conversion 0024h 17 intsr0 end of uart0 reception or reception error generation 0026h 18 intwti watch timer referenc e time interval signal 0028h 19 inttm51 match between tm51 and cr51 (when compare register is specified) internal 002ah (a) 20 intkr key interrupt detection external 002ch (c) maskable 21 intwt watch timer overflow internal 002eh (a) notes 1. the default priority is the priority applicable w hen two or more maskable interrupts are generated simultaneously. 0 is the highest priority, and 25 is the lowest. 2. basic configuration types (a) to (d) co rrespond to (a) to (d) in figure 19-1. 3. when bit 1 (lvimd) of the low-voltage det ection register (lvim) is cleared to 0. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 465 table 19-1. interrupt source list (2/2) interrupt source interrupt type default priority note 1 name trigger internal/ external vector table address basic configuration type note 2 22 intiic0/ intdmu note 3 end of iic0 communication/end of multiply/divide operation 0034h 23 intcsi11 note 3 end of csi11 communication 0036h 24 inttm001 note 3 match between tm01 and cr001 (when compare register is specified), ti011 pin valid edge detection (when capture register is specified) 0038h maskable 25 inttm011 note 3 match between tm01 and cr011 (when compare register is specified), ti001 pin valid edge detection (when capture register is specified) internal 003ah (a) software ? brk brk instruction execution ? 003eh (d) reset reset input poc power-on clear lvi low-voltage detection note 4 reset ? wdt wdt overflow ? 0000h ? notes 1. the default priority is the priority applicable w hen two or more maskable interrupts are generated simultaneously. 0 is the highest priority, and 25 is the lowest. 2. basic configuration types (a) to (d) co rrespond to (a) to (d) in figure 19-1. 3. the interrupt sources intdmu, intcsi11, in ttm001, and inttm011 are available only in the pd78f0395, 78f0397, and 78f0397d. 4. when bit 1 (lvimd) of the low-voltage detection register (lvim) is set to 1. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 466 figure 19-1. basic configurati on of interrupt function (1/2) (a) internal maskable interrupt internal bus interrupt request if mk ie pr isp priority controller vector table address generator standby release signal (b) external maskable inte rrupt (intp0 to intp5) internal bus interrupt request if mk ie pr isp priority controller vector table address generator standby release signal external interrupt edge enable register (egp, egn) edge detector if: interrupt request flag ie: interrupt enable flag isp: in-service priority flag mk: interrupt mask flag pr: priority specification flag chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 467 figure 19-1. basic configurati on of interrupt function (2/2) (c) external maskable interrupt (intkr) if mk ie pr isp internal bus interrupt request priority controller vector table address generator standby release signal key interrupt detector 1 when krmn = 1 (n = 0 to 7) (d) software interrupt internal bus interrupt request priority controller vector table address generator if: interrupt request flag ie: interrupt enable flag isp: in-service priority flag mk: interrupt mask flag pr: priority specification flag krm: key return mode register 19.3 registers controlling interrupt functions the following 6 types of registers are used to control the interrupt functions. ? interrupt request flag regist er (if0l, if0h, if1l, if1h) ? interrupt mask flag register (mk0l, mk0h, mk1l, mk1h) ? priority specification flag register (pr0l, pr0h, pr1l, pr1h) ? external interrupt rising edge enable register (egp) ? external interrupt falling edge enable register (egn) ? program status word (psw) table 19-2 shows a list of interrupt request flags, interrupt mask flags, and priority specification flags corresponding to interrupt request sources. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 468 table 19-2. flags corresponding to interrupt request sources interrupt request flag interrupt mask flag priority specification flag interrupt source register register register intlvi lviif if0l lvimk mk0l lvipr pr0l intp0 pif0 pmk0 ppr0 intp1 pif1 pmk1 ppr1 intp2 pif2 pmk2 ppr2 intp3 pif3 pmk3 ppr3 intp4 pif4 pmk4 ppr4 intp5 pif5 pmk5 ppr5 intsre6 sreif6 sremk6 srepr6 intsr6 srif6 if0h srmk6 mk0h srpr6 pr0h intst6 stif6 stmk6 stpr6 intcsi10 csiif10 csimk10 csipr10 intst0 stif0 dualif0 note 1 stmk0 dualmk0 note 2 stpr0 dualpr0 note 2 inttmh1 tmifh1 tmmkh1 tmprh1 inttmh0 tmifh0 tmmkh0 tmprh0 inttm50 tmif50 tmmk50 tmpr50 inttm000 tmif000 tmmk000 tmpr000 inttm010 tmif010 tmmk010 tmpr010 intad adif if1l admk mk1l adpr pr1l intsr0 srif0 srmk0 srpr0 intwti wtiif wtimk wtipr inttm51 tmif51 tmmk51 tmpr51 intkr krif krmk krpr intwt wtif wtmk wtpr intiic0 iicif0 iicmk0 iicpr0 intdmu note 3 dmuif note 3 if1h dmumk note 3 mk1h dmupr note 3 pr1h intcsi11 note 3 csiif11 note 3 csimk11 note 3 csipr11 note 3 inttm001 note 3 tmif001 note 3 tmmk001 note 3 tmpr001 note 3 inttm011 note 3 tmif011 note 3 tmmk011 note 3 tmpr011 note 3 notes 1. if either interrupt source intcsi10 or ints t0 is generated, these flags are set (1). 2. both interrupt sources intcsi10 and intst0 are supported. 3. pd78f0395, 78f0397, and 78f0397d only. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 469 (1) interrupt request flag regist ers (if0l, if0h, if1l, if1h) the interrupt request flags are set to 1 when the correspo nding interrupt request is g enerated or an instruction is executed. they are cleared to 0 when an instruction is executed upon acknow ledgment of an interrupt request or upon reset input. when an interrupt is acknowledged, the interrupt req uest flag is automatically cleared and then the interrupt routine is entered. if0l, if0h, if1l, and if1h are set by a 1-bit or 8-bit memory manipulation instruct ion. when if0l and if0h, and if1l and if1h are combined to form 16-bit registers if0 and if1, they are set by a 16-bit memory manipulation instruction. reset input clears these registers to 00h. figure 19-2. format of interrupt request fl ag registers (if0l, if0h, if1l, if1h) address: ffe0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> if0l sreif6 pif5 pif4 pif3 pif2 pif1 pif0 lviif address: ffe1h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> if0h tmif010 tmif000 tmif50 tmifh0 tmifh1 dualif0 csiif10 stif0 stif6 srif6 address: ffe2h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> if1l 0 0 wtif krif tmif51 wtiif srif0 adif address: ffe3h after reset: 00h r/w symbol 7 6 5 4 <3> <2> <1> <0> if1h 0 0 0 0 tmif011 note tmif001 note csiif11 note iicif0 dmuif note xxifx interrupt request flag 0 no interrupt request signal is generated 1 interrupt request is generated, interrupt request status note pd78f0395, 78f0397, and 78f0397d only. cautions 1. be sure to clear bits 6 and 7 of if1l to 0. 2. be sure to clear bits 1 to 7 of if1h to 0 for the pd78f0393. be sure to clear bits 4 to 7 of if1h to 0 for the pd78f0395, 78f0397, and 78f0397d. 3. when operating a timer, se rial interface, or a/d converter after standby release, operate it once after clearing the interrupt request flag. an interrupt request flag may be set by noise. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 470 cautions 4. when manipulating a flag of the in terrupt request flag regi ster, use a 1-bit memory manipulation instruction (clr1). when descr ibing in c language, use a bit manipulation instruction such as ?if0l.0 = 0;? or ?_asm(?clr1 if0l, 0?);? because the co mpiled assembler must be a 1-bit memory manipulation instruction (clr1). if a program is described in c language usi ng an 8-bit memory manipulation instruction such as ?if0l &= 0xfe;? and compiled, it becom es the assembler of three instructions. mov a, if0l and a, #0feh mov if0l, a in this case, even if the request flag of another bit of the same interrupt request flag register (if0l) is set to 1 at the timing between ?mov a, if0l? and ?mov if 0l, a?, the flag is cleared to 0 at ?mov if0l, a?. therefore, care must be exercised when us ing an 8-bit memory manipulation instruction in c language. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 471 (2) interrupt mask flag regist ers (mk0l, mk0h, mk1l, mk1h) the interrupt mask flags are used to enable/disable the corresponding maskable interrupt servicing. mk0l, mk0h, mk1l, and mk1h are set by a 1-bit or 8- bit memory manipulation instruction. when mk0l and mk0h, and mk1l and mk1h are combined to form 16-bit registers mk0 and mk1, they are set by a 16-bit memory manipulation instruction. reset input sets these registers to ffh. figure 19-3. format of interrupt mask fl ag registers (mk0l, mk0h, mk1l, mk1h) address: ffe4h after reset: ffh r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> mk0l sremk6 pmk5 pmk4 pmk3 pmk2 pmk1 pmk0 lvimk address: ffe5h after reset: ffh r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> mk0h tmmk010 tmmk000 tmmk50 tmmkh0 tmmkh1 dualmk0 csimk0 stmk0 stmk6 srmk6 address: ffe6h after reset: ffh r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> mk1l 1 1 wtmk krmk tmmk51 wtimk srmk0 admk address: ffe7h after reset: ffh r/w symbol 7 6 5 4 <3> <2> <1> <0> mk1h 1 1 1 1 tmmk011 note tmmk001 note csimk11 note iicmk0 dmumk note xxmkx interrupt servicing control 0 interrupt servicing enabled 1 interrupt servicing disabled note pd78f0395, 78f0397, and 78f0397d only. cautions 1. be sure to set bits 6 and 7 of mk1l to 1. 2. be sure to set bits 1 to 7 of mk1h to 1 for the pd78f0393. be sure to set bits 4 to 7 of mk1h to 1 for the pd78f0395, 78f0397, and 78f0397d. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 472 (3) priority specification flag re gisters (pr0l, pr0h, pr1l, pr1h) the priority specification flag regist ers are used to set the corresponding maskable interrupt priority order. pr0l, pr0h, pr1l, and pr1h are set by a 1-bit or 8-bi t memory manipulation instruction. if pr0l and pr0h, and pr1l and pr1h are combined to form 16-bit registers pr0 and pr1, they are set by a 16-bit memory manipulation instruction. reset input sets these registers to ffh. figure 19-4. format of priority specification flag registers (pr0l, pr0h, pr1l, pr1h) address: ffe8h after reset: ffh r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> pr0l srepr6 ppr5 ppr4 ppr3 ppr2 ppr1 ppr0 lvipr address: ffe9h after reset: ffh r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> pr0h tmpr010 tmpr000 tmpr50 tmprh0 tmprh1 dualpr0 csipr10 stpr0 stpr6 srpr6 address: ffeah after reset: ffh r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> pr1l 1 1 wtpr krpr tmpr51 wtipr srpr0 adpr address: ffebh after reset: ffh r/w symbol 7 6 5 4 <3> <2> <1> <0> pr1h 1 1 1 1 tmpr011 note tmpr001 note csipr11 note iicpr0 dmupr note xxprx priority level selection 0 high priority level 1 low priority level note pd78f0395, 78f0397, and 78f0397d only. cautions 1. be sure to set bits 6 and 7 of pr1l to 1. 2. be sure to set bits 1 to 7 of pr1h to 1 for the pd78f0393. be sure to set bits 4 to 7 of pr1h to 1 for the pd78f0395, 78f0397, and 78f0397d. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 473 (4) external interrupt rising edge en able register (egp), external interrupt falling edge enable register (egn) these registers specify the valid edge for intp0 to intp5. egp and egn are set by a 1-bit or 8-bit memory manipulation instruction. reset input clears these registers to 00h. figure 19-5. format of external interrupt rising edge enable register (egp) and external interrupt falling edge enable register (egn) address: ff48h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 egp 0 0 egp5 egp4 egp3 egp2 egp1 egp0 address: ff49h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 egn 0 0 egn5 egn4 egn3 egn2 egn1 egn0 egpn egnn intpn pin valid edge selection (n = 0 to 7) 0 0 edge detection disabled 0 1 falling edge 1 0 rising edge 1 1 both rising and falling edges table 19-3 shows the ports corresponding to egpn and egnn. table 19-3. ports correspo nding to egpn and egnn detection enable register edge detection port interrupt request signal egp0 egn0 p120 intp0 egp1 egn1 p30 intp1 egp2 egn2 p31 intp2 egp3 egn3 p32 intp3 egp4 egn4 p33 intp4 egp5 egn5 p16 intp5 caution select the port mode by clearing eg pn and egnn to 0 because an edge may be detected when the external interrupt func tion is switched to the port function. remark n = 0 to 5 chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 474 (5) program status word (psw) the program status word is a register used to hold the instruction exec ution result and the current status for an interrupt request. the ie flag that sets maskable interr upt enable/disable and the isp fl ag that controls multiple interrupt servicing are mapped to the psw. besides 8-bit read/write, this register can carry out op erations using bit manipulation instructions and dedicated instructions (ei and di). when a vect ored interrupt request is acknowledged, if the brk instruction is executed, the contents of the psw are aut omatically saved into a stack and the ie flag is reset to 0. if a maskable interrupt request is acknowledged, the contents of the priority specification flag of t he acknowledged interrupt are transferred to the isp flag. the psw contents are also saved into the stack with t he push psw instruction. they are restored from the stack with the reti, retb, and pop psw instructions. reset input sets psw to 02h. figure 19-6. format of program status word <7> ie <6> z <5> rbs1 <4> ac <3> rbs0 2 0 <1> isp 0 cy psw after reset 02h isp high-priority interrupt servicing (low-priority interrupt disabled) ie 0 1 disabled priority of interrupt currently being serviced interrupt request acknowledgment enable/disable used when normal instruction is executed enabled interrupt request not acknowledged, or low- priority interrupt servicing (all maskable interrupts enabled) 0 1 chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 475 19.4 interrupt servicing operations 19.4.1 maskable interrupt acknowledgement a maskable interrupt becomes acknowledgeable when the in terrupt request flag is set to 1 and the mask (mk) flag corresponding to that interrupt request is cleared to 0. a vectored interrupt request is acknowledged if interrupts are in the interrupt enabled state (when the ie flag is set to 1). however, a low-priority interrupt request is not acknowledged during servicing of a higher priority interrupt request (when the isp flag is reset to 0). the times from generation of a maskable interrupt reques t until interrupt servicing is perfor med are listed in table 19-4 below. for the interrupt request acknowledgement timing, see figures 19-8 and 19-9 . table 19-4. time from generation of maskable inte rrupt until servicing minimum time maximum time note when pr = 0 7 clocks 32 clocks when pr = 1 8 clocks 33 clocks note if an interrupt request is generated just before a di vide instruction, the wait time becomes longer. remark 1 clock: 1/f cpu (f cpu : cpu clock) if two or more maskable interrupt requests are generated simultaneously, the request with a higher priority level specified in the priority specification flag is acknowledge d first. if two or more interrupts requests have the same priority level, the request with the highest default priority is acknowledged first. an interrupt request that is held pending is a cknowledged when it becomes acknowledgeable. figure 19-7 shows the interrupt request acknowledgement algorithm. if a maskable interrupt request is acknowledged, the content s are saved into the stacks in the order of psw, then pc, the ie flag is reset (0), and the contents of the pr iority specification flag corresponding to the acknowledged interrupt are transferred to the isp flag. the vector table data deter mined for each interrupt request is the loaded into the pc and branched. restoring from an interrupt is possible by using the reti instruction. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 476 figure 19-7. interrupt request ac knowledgement pr ocessing algorithm start if = 1? mk = 0? pr = 0? ie = 1? isp = 1? interrupt request held pending yes yes no no yes (interrupt request generation) yes no (low priority) no no yes yes no ie = 1? no any high-priority interrupt request among those simultaneously generated with pr = 0? yes (high priority) no yes yes no vectored interrupt servicing interrupt request held pending interrupt request held pending interrupt request held pending interrupt request held pending interrupt request held pending interrupt request held pending vectored interrupt servicing any high-priority interrupt request among those simultaneously generated? any high-priority interrupt request among those simultaneously generated with pr = 0? if: interrupt request flag mk: interrupt mask flag pr: priority specification flag ie: flag that controls acknowledgement of mask able interrupt request (1 = enable, 0 = disable) isp: flag that indicates the priority level of the interrupt currently being serviced (0 = high-priority interrupt servicing, 1 = no interrupt request acknowledg ed, or low-priority interrupt servicing) chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 477 figure 19-8. interrupt request ac knowledgement timing (minimum time) 8 clocks 7 clocks instruction instruction psw and pc saved, jump to interrupt servicing interrupt servicing program cpu processing if ( pr = 1) if ( pr = 0) 6 clocks remark 1 clock: 1/f cpu (f cpu : cpu clock) figure 19-9. interrupt request ac knowledgement timing (maximum time) 33 clocks 32 clocks instruction divide instruction psw and pc saved, jump to interrupt servicing interrupt servicing program cpu processing if ( pr = 1) if ( pr = 0) 6 clocks 25 clocks remark 1 clock: 1/f cpu (f cpu : cpu clock) 19.4.2 software interrupt request acknowledgement a software interrupt acknowledge is acknowledged by brk instruction execution. so ftware interrupts cannot be disabled. if a software interrupt request is ackno wledged, the cont ents are saved into the stacks in the order of the program status word (psw), then program counter (pc), the ie flag is reset (0), and t he contents of the ve ctor table (003eh, 003fh) are loaded into the pc and branched. restoring from a software interrupt is possi ble by using the retb instruction. caution do not use the reti instruction fo r restoring from the software interrupt. chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 478 19.4.3 multiple interrupt servicing multiple interrupt servicing occurs when another interrupt re quest is acknowledged during execution of an interrupt. multiple interrupt servicing does not occur unless the in terrupt request acknowledgem ent enabled state is selected (ie = 1). when an interrupt request is acknowledged, interrupt request acknow ledgement becomes disabled (ie = 0). therefore, to enable multiple interrupt servicing, it is necessary to set (1) the ie flag with the ei instruction during interrupt servicing to enable interrupt acknowledgement. moreover, even if interrupts are enabled, multiple interr upt servicing may not be enabled, this being subject to interrupt priority control. two types of priority control are available: default priority control and programmable priority control. programmable priority control is used for multiple interrupt servicing. in the interrupt enabled state, if an in terrupt request with a priority equal to or higher than that of the interrupt currently being serviced is generated, it is acknowledged for mu ltiple interrupt servicing. if an interrupt with a priority lower than that of the interrupt currently being serviced is generated during interrupt servicing, it is not acknowledged for multiple interrupt servicing. inte rrupt requests that are not enabled because interrupts are in the interrupt disabled state or because they have a lower prio rity are held pending. when servicing of the current interrupt ends, the pending interrupt request is acknowledged following execution of at least one main processing instruction execution. table 19-5 shows relationship between interrupt requests enabled for multiple interrupt servicing and figure 19-10 shows multiple interrupt servicing examples. table 19-5. relationship between interrupt requests enabled for multiple interrupt servicing during interrupt servicing maskable interrupt request pr = 0 pr = 1 multiple interrupt request interrupt being serviced ie = 1 ie = 0 ie = 1 ie = 0 software interrupt request isp = 0 { { maskable interrupt isp = 1 { { { software interrupt { { { remarks 1. : multiple interrupt servicing enabled 2. : multiple interrupt servicing disabled 3. isp and ie are flags contained in the psw. isp = 0: an interrupt with higher priority is being serviced. isp = 1: no interrupt request has been acknowledged, or an interrupt with a lower priority is being serviced. ie = 0: interrupt request acknowledgement is disabled. ie = 1: interrupt request acknowledgement is enabled. 4. pr is a flag contained in pr0l, pr0h, pr1l, and pr1h. pr = 0: higher priority level pr = 1: lower priority level chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 479 figure 19-10. examples of multip le interrupt se rvicing (1/2) example 1. multiple inte rrupt servicing occurs twice main processing intxx servicing intyy servicing intzz servicing ei ei ei reti reti reti intxx (pr = 1) intyy (pr = 0) intzz (pr = 0) ie = 0 ie = 0 ie = 0 ie = 1 ie = 1 ie = 1 during servicing of interrupt intxx, two interrupt re quests, intyy and intzz, are acknowledged, and multiple interrupt servicing takes place. before each interrupt re quest is acknowledged, the ei instruction must always be issued to enable interrupt request acknowledgment. example 2. multiple interrupt servicing does not occur due to priority control main processing intxx servicing intyy servicing intxx (pr = 0) intyy (pr = 1) ei reti ie = 0 ie = 0 ei 1 instruction execution reti ie = 1 ie = 1 interrupt request intyy issued during servicing of interrupt intxx is not acknowledged because its priority is lower than that of intxx, and mu ltiple interrupt servicing does not take place. the intyy interrupt request is held pending, and is acknowledged following execution of one main processing instruction. pr = 0: higher priority level pr = 1: lower priority level ie = 0: interrupt request acknowledgment disabled chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 480 figure 19-10. examples of multip le interrupt se rvicing (2/2) example 3. multiple interrupt servicing do es not occur because inte rrupts are not enabled main processing intxx servicing intyy servicing ei 1 instruction execution reti reti intxx (pr = 0) intyy (pr = 0) ie = 0 ie = 0 ie = 1 ie = 1 interrupts are not enabled during servicing of interrupt int xx (ei instruction is not issued), therefore, interrupt request intyy is not acknowledged and multiple interrupt serv icing does not take place. the intyy interrupt request is held pending, and is acknowledged following ex ecution of one main processing instruction. pr = 0: higher priority level ie = 0: interrupt request acknowledgement disabled chapter 19 interrupt functions preliminary user?s manual u17473ej1v0ud 481 19.4.4 interrupt request hold there are instructions where, even if an interrupt request is issued for them while another instruction is being executed, request acknowledgement is held pending until t he end of execution of the next instruction. these instructions (interrupt request hol d instructions) are listed below. ? mov psw, #byte ? mov a, psw ? mov psw, a ? mov1 psw. bit, cy ? mov1 cy, psw. bit ? and1 cy, psw. bit ? or1 cy, psw. bit ? xor1 cy, psw. bit ? set1 psw. bit ? clr1 psw. bit ? retb ? reti ? push psw ? pop psw ? bt psw. bit, $addr16 ? bf psw. bit, $addr16 ? btclr psw. bit, $addr16 ? ei ? di ? manipulation instructions for the if0l, if0h, if1l, if1h, mk0l, mk0h, mk1l, mk1h, pr0l, pr0h, pr1l, and pr1h registers. caution the brk instruction is not one of the above-listed interrupt re quest hold instructions. however, the software interrupt activated by executing the brk instruction causes the ie flag to be cleared. therefore, even if a maskable interrupt re quest is generated during execution of the brk instruction, the interrupt re quest is not acknowledged. figure 19-11 shows the timing at which interrupt requests are held pending. figure 19-11. interrupt request hold instruction n instruction m psw and pc saved, jump to interrupt servicing interrupt servicing program cpu processing if remarks 1. instruction n: interrupt request hold instruction 2. instruction m: instruction other t han interrupt request hold instruction 3. the pr (priority level) values do not affect the operation of if (interrupt request). preliminary user?s manual u17473ej1v0ud 482 chapter 20 key interrupt function 20.1 functions of key interrupt a key interrupt (intkr) can be generated by setting t he key return mode register (krm) and inputting a falling edge to the key interrupt input pins (kr0 to kr7). table 20-1. assignment of k ey interrupt detection pins flag description krm0 controls kr0 signal in 1-bit units. krm1 controls kr1 signal in 1-bit units. krm2 controls kr2 signal in 1-bit units. krm3 controls kr3 signal in 1-bit units. krm4 controls kr4 signal in 1-bit units. krm5 controls kr5 signal in 1-bit units. krm6 controls kr6 signal in 1-bit units. krm7 controls kr7 signal in 1-bit units. 20.2 configuration of key interrupt the key interrupt includes the following hardware. table 20-2. configuration of key interrupt item configuration control register key return mode register (krm) figure 20-1. block diag ram of key interrupt intkr key return mode register (krm) krm7 krm6 krm5 krm4 krm3 krm2 krm1 krm0 kr7 kr6 kr5 kr4 kr3 kr2 kr1 kr0 chapter 20 key interrupt function preliminary user?s manual u17473ej1v0ud 483 20.3 register controlling key interrupt (1) key return mode register (krm) this register controls the krm0 to krm7 bits using the kr0 to kr7 signals, respectively. krm is set by a 1-bit or 8-bit memory manipulation instruction. reset input clears krm to 00h. figure 20-2. format of key return mode register (krm) krm7 does not detect key interrupt signal detects key interrupt signal krmn 0 1 key interrupt mode control krm krm6 krm5 krm4 krm3 krm2 krm1 krm0 address: ff6eh after reset: 00h r/w symbol 765432 0 cautions 1. if any of the krm0 to krm7 bits used is set to 1, set bits 0 to 7 (pu70 to pu77) of the corresponding pull-up resistor register 7 (pu7) to 1. 2. if krm is changed, the interrupt request flag may be set. therefore, disable interrupts and then change the krm register. clear the in terrupt request flag and enable interrupts. 3. the bits not used in the key inte rrupt mode can be used as normal ports. preliminary user?s manual u17473ej1v0ud 484 chapter 21 standby function 21.1 standby function and configuration 21.1.1 standby function the standby function is designed to reduce the operating current of the system. the following two modes are available. (1) halt mode halt instruction execution se ts the halt mode. in the halt mode, the cpu operation clock is stopped. if the high-speed system clock oscillator, high-speed ring-osc oscillator, lo w-speed ring-osc oscillator, or subsystem clock oscillator is operating before the halt mode is set, oscillation of each clock continues. in this mode, the operating current is not decreased as much as in the stop mode, but the halt mode is effective for restarting operation immediately upon interrupt reques t generation and carrying out intermittent operations. (2) stop mode stop instruction execution sets the stop mode. in the stop mode, the high-speed system clock oscillator and high-speed ring-osc oscillator stop, stopping the whole system, thereby considerably reducing the cpu operating current. because this mode can be cleared by an interrupt reques t, it enables intermittent operations to be carried out. however, because a wait time is required to secure th e oscillation stabilization time after the stop mode is released, select the halt mode if it is necessary to start processing immediately upon interrupt request generation. in either of these two modes, all the contents of registers, flags and data me mory just before the standby mode is set are held. the i/o port output latches an d output buffer statuses are also held. cautions 1. the stop mode can be used only when the cpu is operating on the main system clock. the subsystem clock oscillation cannot be stopped. the halt mode can be used when the cpu is operating on either the main syst em clock or the subsystem clock. 2. when shifting to the stop mode, be su re to stop the peripher al hardware operation operating with main system clock be fore executing stop instruction. 3. the following sequence is r ecommended for operating current reduction of the a/d converter when the standby function is used: first cl ear bit 7 (adcs) of the a/d converter mode register (adm) to 0 to stop the a/d conversi on operation, and then execute the halt or stop instruction. chapter 21 standby function preliminary user?s manual u17473ej1v0ud 485 21.1.2 registers controlling standby function the standby function is controlled by the following two registers. ? oscillation stabilization time c ounter status register (ostc) ? oscillation stabilization time select register (osts) remark for the registers that start, st op, or select the clock, see chapter 5 clock generator . (1) oscillation stabilization time c ounter status register (ostc) this is the status register of the x1 clock oscillation stabilization time counter. if the high-speed ring-osc clock or subsystem clock is used as the cpu clock, the x1 clock oscillation stabiliz ation time can be checked. ostc can be read by a 1-bit or 8-bit memory manipulation instruction. reset release (reset by reset input, poc, lvi, and wdt) , the stop instruction, and mstop (bit 7 of moc register) = 1 clear ostc to 00h. figure 21-1. format of oscillation stabilizati on time counter status register (ostc) address: ffa3h after reset: 00h r symbol 7 6 5 4 3 2 1 0 ostc 0 0 0 most11 most 13 most14 most15 most16 most11 most13 most14 most15 most16 oscillation stabilization time status f x = 10 mhz f x = 20 mhz 1 0 0 0 0 2 11 /f x min. 204.8 s min. 102.4 s min. 1 1 0 0 0 2 13 /f x min. 819.2 s min. 409.6 s min. 1 1 1 0 0 2 14 /f x min. 1.64 ms min. 819.2 s min. 1 1 1 1 0 2 15 /f x min. 3.27 ms min. 1.64 ms min. 1 1 1 1 1 2 16 /f x min. 6.55 ms min. 3.27 ms min. cautions 1. after the above time has elapsed, th e bits are set to 1 in order from most11 and remain 1. 2. if the stop mode is entered and th en released while th e high-speed ring-osc clock or subsystem clock is being used as the cp u clock, set the oscillation stabilization time as follows. ? desired ostc oscillation stabilization time oscillation stabilization time set by osts the oscillation stabilization time c ounter counts only dur ing the oscillation stabilization time set by osts. therefore, note that only the statuses during the oscillation stabilization time set by osts are set to ostc after stop mode has been released. 3. the x1 clock oscillation stabilization wait time does not include the time until clock oscillation starts (?a? below). a stop mode release x1 pin voltage waveform remark f x : x1 clock oscillation frequency chapter 21 standby function preliminary user?s manual u17473ej1v0ud 486 (2) oscillation stabilization time select register (osts) this register is used to select the x1 clock oscillation stabilization wait ti me when stop mode is released. the wait time set by osts is valid only after stop mode is rel eased when the x1 clock is selected as the cpu clock. after stop mode is released when the high-speed ring-osc clock is selected, check the x1 clock oscillation stabilization time using ostc. osts can be set by an 8-bit memory manipulation instruction. reset input sets osts to 05h. figure 21-2. format of oscillation stabiliz ation time select register (osts) address: ffa4h after reset: 05h r/w symbol 7 6 5 4 3 2 1 0 osts 0 0 0 0 0 osts2 osts1 osts0 osts2 osts1 osts0 oscillation stabilization time selection f x = 10 mhz f x = 20 mhz 0 0 1 2 11 /f x 204.8 s 102.4 s 0 1 0 2 13 /f x 819.2 s 409.6 s 0 1 1 2 14 /f x 1.64 ms 819.2 s 1 0 0 2 15 /f x 3.27 ms 1.64 ms 1 0 1 2 16 /f x 6.55 ms 3.27 ms other than above setting prohibited cautions 1. to set the stop mode when the x1 clock is used as the cpu clock, set osts before executing the stop instruction. 2. do not change the value of the osts register during the x1 clock oscillation stabilization time. 3. if the stop mode is entered and th en released while th e high-speed ring-osc clock or subsystem clock is being used as the cp u clock, set the oscillation stabilization time as follows. ? desired ostc oscillation stabilization time oscillation stabilization time set by osts the oscillation stabilization time c ounter counts only dur ing the oscillation stabilization time set by osts. therefore, note that only the statuses during the oscillation stabilization time set by osts are set to ostc after stop mode has been released. 4. the x1 clock oscillation stabilization wait time does not include the time until clock oscillation starts (?a? below). a stop mode release x1 pin voltage waveform remark f x : x1 clock oscillation frequency chapter 21 standby function preliminary user?s manual u17473ej1v0ud 487 21.2 standby function operation 21.2.1 halt mode (1) halt mode the halt mode is set by executing t he halt instruction. halt mode can be set regardless of whether the cpu clock before the setting was the high-speed system clock, high-speed ring-osc clock, or subsystem clock. the operating statuses in t he halt mode are shown below. chapter 21 standby function preliminary user?s manual u17473ej1v0ud 488 table 21-1. operating statuses in halt mode (1/2) when halt instruction is executed while cpu is operating on main system clock halt mode setting item when cpu is operating on high-speed ring-osc clock (f rh ) when cpu is operating on x1 clock (f x ) when cpu is operating on external main system clock (f exclk ) system clock clock supply to the cpu is stopped f rh operation continues (cannot be stopped) status before halt mode was set is retained f x status before halt mode was set is retained operation continues (cannot be stopped) status before halt mode was set is retained main system clock f exclk operates or stops by external cl ock input operation continues (cannot be stopped) f xt status before halt mode was set is retained subsystem clock f exclks operates or stops by external clock input f rl status before halt mode was set is retained cpu operation stopped flash memory operation stopped ram status before halt mode was set is retained regulator operates in normal mode port (latch) status before halt mode was set is retained 00 16-bit timer/event counter 01 note 50 8-bit timer/event counter 51 h0 8-bit timer h1 watch timer operable watchdog timer operable. clock supply to watchdog ti mer stops when ?low-speed ring-osc oscillation can be stopped by software? is set by option byte. a/d converter uart0 uart6 csi10 csi11 note serial interface iic0 lcd controller/driver multiplier/divider note power-on-clear function low-voltage detection function external interrupt operable note pd78f0395, 78f0397, and 78f0397d only. remark f rh : high-speed ring-osc oscillation clock f x : x1 clock f exclk : external main system clock f xt : xt1 clock f exclks : external subsystem clock f rl : low-speed ring-osc oscillation clock chapter 21 standby function preliminary user?s manual u17473ej1v0ud 489 table 21-1. operating statuses in halt mode (2/2) when halt instruction is executed while cpu is operating on subsystem clock halt mode setting item when cpu is operating on xt1 clock (f xt ) when cpu is operating on external subsystem clock (f exclks ) system clock clock supply to the cpu is stopped f rh f x status before halt mode was set is retained main system clock f exclk operates or stops by external clock input f xt operation continues (cannot be stopped) stat us before halt mode was set is retained subsystem clock f exclks operates or stops by external clock input operation continues (cannot be stopped) f rl status before halt mode was set is retained cpu operation stopped flash memory operation stopped ram status before halt mode was set is retained regulator operates in low-operating current mode when high-speed ring-osc clock (f rh ) oscillation is stopped. operates in normal mode when high-speed ring-osc clock (f rh ) oscillates. port (latch) status before halt mode was set is retained 00 16-bit timer/event counter 01 note 50 8-bit timer/event counter 51 h0 8-bit timer h1 watch timer operable watchdog timer operable. clock supply to watchdog timer st ops when ?low-speed ring-osc oscillation can be stopped by software? is set by option byte. a/d converter operable. however, operat ion disabled when peripheral hardware clock (f prs ) is stopped. uart0 uart6 csi10 csi11 note serial interface iic0 lcd controller/driver multiplier/divider note power-on-clear function low-voltage detection function external interrupt operable note pd78f0395, 78f0397, and 78f0397d only. remark f rh : high-speed ring-osc oscillation clock f x : x1 clock f exclk : external main system clock f xt : xt1 clock f exclks : external subsystem clock f rl : low-speed ring-osc oscillation clock chapter 21 standby function preliminary user?s manual u17473ej1v0ud 490 (2) halt mode release the halt mode can be released by the following two sources. (a) release by unmasked interrupt request when an unmasked interrupt request is generated, the halt mode is released. if interrupt acknowledgement is enabled, vectored interrupt servicing is carried out. if interrupt acknowledgement is disabled, the next address instruction is executed. figure 21-3. halt mode release by interrupt request generation halt instruction wait wait operating mode halt mode operating mode oscillation high-speed system clock, high-speed ring-osc clock, or subsystem clock status of cpu standby release signal interrupt request remarks 1. the broken lines indicate the case when the in terrupt request which has released the standby mode is acknowledged. 2. the wait time is as follows: when vectored interrupt servicing is carried out: 8 or 9 clocks when vectored interrupt servicing is not carried out: 2 or 3 clocks chapter 21 standby function preliminary user?s manual u17473ej1v0ud 491 (b) release by reset signal input (reset by reset pin, reset by wdt, poc, lvi) when the reset signal is input, halt mode is released, and then, as in the case with a normal reset operation, the program is executed after br anching to the reset vector address. figure 21-4. halt mode release by reset signal input (1) when high-speed system clock is used as cpu clock halt instruction reset signal high-speed system clock (x1 oscillation) operating mode (high-speed system clock) halt mode reset period operating mode (high-speed ring-osc clock) oscillates oscillation stopped oscillates status of cpu oscillation stabilization time (2 11 /f x to 2 16 /f x ) oscillation stopped starting x1 oscillation is specified by software. (2) when high-speed ring-os c clock is used as cpu clock halt instruction reset signal high-speed ring-osc clock operating mode (high-speed ring-osc clock) halt mode reset period operating mode (high-speed ring-osc clock) oscillates oscillation stopped oscillates status of cpu oscillates (low- accuracy) (high-accuracy) automatic selection (3) when subsystem clo ck is used as cpu clock halt instruction reset signal subsystem clock (xt1 oscillation) operating mode (subsystem clock) halt mode reset period operating mode (high-speed ring-osc clock) oscillates oscillation stopped oscillates status of cpu oscillation stopped starting xt1 oscillation is specified by software. remark f x : x1 clock oscillation frequency chapter 21 standby function preliminary user?s manual u17473ej1v0ud 492 table 21-2. operation in response to interrupt request in halt mode release source mk pr ie isp operation 0 0 0 next address instruction execution 0 0 1 interrupt servicing execution 0 1 0 1 0 1 0 next address instruction execution 0 1 1 1 interrupt servicing execution maskable interrupt request 1 halt mode held reset signal input ? ? reset processing : don?t care 21.2.2 stop mode (1) stop mode setting and operating statuses the stop mode is set by executing t he stop instruction, and it can be se t only when the cpu clock before the setting was the main system clock. caution because the interrupt request signal is used to clear the standby mode, if there is an interrupt source with the interrupt request flag set and the interrupt mask flag reset, the standby mode is immediately cleared if set. thus, the stop mode is reset to the halt mode immediately after execution of the stop instruction and the system returns to the operating mode as soon as the wait time set using the oscillation stabilizat ion time select register (osts) has elapsed. the operating statuses in t he stop mode are shown below. chapter 21 standby function preliminary user?s manual u17473ej1v0ud 493 table 21-3. operating statuses in stop mode when stop instruction is executed while cpu is operating on main system clock stop mode setting item when cpu is operating on high-speed ring-osc clock (f rh ) when cpu is operating on x1 clock (f x ) when cpu is operating on external main system clock (f exclk ) system clock clock supply to the cpu is stopped f rh f x stopped main system clock f exclk input invalid f xt status before stop mode was set is retained subsystem clock f exclks operates or stops by external clock input f rl status before stop mode was set is retained cpu operation stopped flash memory operation stopped ram status before stop mode was set is retained regulator operates in low-operating current mode port (latch) status before stop mode was set is retained 00 16-bit timer/event counter 01 note operation stopped 50 operable only when ti50 is selected as the count clock 8-bit timer/event counter 51 operable only when ti51 is selected as the count clock h0 operable only when tm50 output is selected as the count clock during 8- bit timer/event counter 50 operation 8-bit timer h1 operable only when f rl , f rl /2 7 , or f rl /2 9 is selected as the count clock watch timer operable only when subsystem clock is selected as the count clock watchdog timer operable. clock supply to watchdog ti mer stops when ?low-speed ring-osc oscillation can be stopped by software? is set by option byte. a/d converter operation stopped uart0 uart6 operable only when tm50 output is selected as the serial clock during 8-bi t timer/event counter 50 operation csi10 csi11 note serial interface iic0 operable only when external clock is selected as the serial clock lcd controller/driver operable only when subsyst em clock is selected as the count clock multiplier/divider note operation stopped power-on-clear function low-voltage detection function external interrupt operable note pd78f0395, 78f0397, and 78f0397d only. (cautions are listed on the next page.) remark f rh : high-speed ring-osc oscillation clock f x : x1 clock f exclk : external main system clock f xt : xt1 clock f exclks : external subsystem clock f rl : low-speed ring-osc oscillation clock chapter 21 standby function preliminary user?s manual u17473ej1v0ud 494 cautions 1. to use the peripheral ha rdware that stops operation in the stop mode, and the peripheral hardware for which the clock that stops oscillati ng in the stop mode after the stop mode is released, restart the peripheral hardware. 2. even if ?low-speed ring-osc oscillation can be stopped by software? is selected by the option byte, the low-speed ring-osc oscillation continues in the stop mode in the status before the stop mode is set. to stop the low-speed ring- osc oscillation in the stop mode, stop it by software and then execute the stop instruction. 3. to shorten oscillation stabiliz ation time after the stop mode is released when the cpu operates with the high-speed system clock (x 1 oscillation), temporarily swit ch the cpu clock to the high- speed ring-osc clock befo re the next execution of the stop in struction. before changing the cpu clock from the high-speed ring-osc to the high-speed system clock (x1 oscillation) after the stop mode is released, check the oscilla tion stabilization time with the oscillation stabilization time counter status register (ostc). 4. if the stop instruction is executed with amph set to 1 when the high- speed ring-osc clock or external main system clock is used as the cpu clock, the cl ock is supplied to the cpu 5 s (min.) after the stop mode has been released. if the x1 clock is used as the cpu clock, oscillation stabilization time is counted after the stop mode h as been released , regardless of the set value of amph. (2) stop mode release figure 21-5. operation timing wh en stop mode is released high-speed ring-osc clock is selected as cpu clock when stop instruction is executed high-speed ring-osc clock high-speed system clock (x1 oscillation) high-speed system clock (x1 oscillation) is selected as cpu clock when stop instruction is executed stop mode release stop mode clock switched by software high-speed ring-osc clock high-speed system clock halt status (oscillation stabilization time set by osts) high-speed system clock automatic selection low-accuracy high-speed ring-osc clock high-accuracy high-speed ring-osc clock automatic selection the stop mode can be released by the following two sources. chapter 21 standby function preliminary user?s manual u17473ej1v0ud 495 (a) release by unmasked interrupt request when an unmasked interrupt request is generated, the stop mode is released. after the oscillation stabilization time has elapsed, if interrupt acknowledg ment is enabled, vectored interrupt servicing is carried out. if interrupt acknowledgment is disabled, the next address instruction is executed. figure 21-6. stop mode release by interrupt request generation (1) when high-speed system clock is used as cpu clock operating mode (high-speed system clock) operating mode (high-speed system clock) oscillates oscillates stop instruction stop mode wait (set by osts) standby release signal oscillation stabilization wait (halt mode status) oscillation stopped high-speed system clock (x1 oscillation) status of cpu oscillation stabilization time (set by osts) (2) when high-speed ring-os c clock is used as cpu clock operating mode (high-speed ring-osc clock) operating mode (high-speed ring-osc clock) oscillates stop instruction stop mode standby release signal high-speed ring-osc clock status of cpu oscillation stopped oscillates oscillates (low- accuracy) (high-accuracy) automatic selection remark the broken lines indicate the case when the inte rrupt request that has re leased the standby mode is acknowledged. chapter 21 standby function preliminary user?s manual u17473ej1v0ud 496 (b) release by reset signal input (reset by reset pin, reset by wdt, poc, lvi) when the reset signal is input, stop mode is rel eased and a reset operation is performed after the oscillation stabilization time has elapsed. figure 21-7. stop mode release by reset signal input (1) when high-speed system clock is used as cpu clock stop instruction reset signal high-speed system clock (x1 oscillation) operating mode (high-speed system clock) stop mode reset period operating mode (high-speed ring-osc clock) oscillates oscillation stopped oscillates status of cpu oscillation stabilization time (2 11 /f x to 2 16 /f x ) oscillation stopped starting x1 oscillation is specified by software. oscillation stopped (2) when high-speed ring-os c clock is used as cpu clock stop instruction reset signal high-speed ring-osc clock operating mode (high-speed ring-osc clock) stop mode reset period operating mode (high-speed ring-osc clock) oscillates oscillation stopped oscillates status of cpu oscillates (low- accuracy) (high-accuracy) automatic selection oscillation stopped remark f x : x1 clock oscillation frequency table 21-4. operation in response to interrupt request in stop mode release source mk pr ie isp operation 0 0 0 next address instruction execution 0 0 1 interrupt servicing execution 0 1 0 1 0 1 0 next address instruction execution 0 1 1 1 interrupt servicing execution maskable interrupt request 1 stop mode held reset signal input ? ? reset processing : don?t care preliminary user?s manual u17473ej1v0ud 497 chapter 22 reset function the following four operations are av ailable to generate a reset signal. (1) external reset input via reset pin (2) internal reset by watchdog timer program loop detection (3) internal reset by comparison of supply voltage and detection voltage of power-on-clear (poc) circuit (4) internal reset by comparison of supply voltage and detection voltage of low-power-supply detector (lvi) external and internal resets have no functional differences . in both cases, program ex ecution starts at the address at 0000h and 0001h when the reset signal is input. a reset is applied when a low level is input to the reset pin, the watchdog timer overflows, or by poc and lvi circuit voltage detection, and each item of hardware is set to the status shown in tables 22-1 and 22-2. each pin is high impedance during reset input or during the oscillat ion stabilization time just after a reset release. when a high level is input to the reset pin, the rese t is released and program exec ution starts using the high- speed ring-osc clock. a reset generated by the watchdo g timer is automatically released after the reset, and program execution starts using the high-speed ring-osc clock (see figures 22-2 to 22-4 ). reset by poc and lvi circuit power supply detection is automatically released when v dd v poc or v dd v lvi after the reset, and program execution starts using the high-speed ring-osc clock (see chapter 23 power-on-clear circuit and chapter 24 low-voltage detector ). cautions 1. for an external reset, input a low level for 10 s or more to the reset pin. 2. during reset input, the x1 cl ock, xt1 clock, high -speed ring-osc clock, and low-speed ring- osc clock stop oscillating. external main syst em clock input and ext ernal subsystem clock input become invalid. 3. when the stop mode is released by a reset , the stop mode contents are held during reset input. however, the port pins become high-impedance. chapter 22 reset function preliminary user?s manual u17473ej1v0ud 498 figure 22-1. block di agram of reset function lvirf wdtrf reset control flag register (resf) internal bus watchdog timer reset signal reset power-on-clear circuit reset signal low-voltage detector reset signal reset signal reset signal to lvim/lvis register clear set clear set caution an lvi circuit internal r eset does not reset the lvi circuit. remarks 1. lvim: low-voltage detection register 2. lvis: low-voltage detection level selection register chapter 22 reset function preliminary user?s manual u17473ej1v0ud 499 figure 22-2. timing of reset by reset input delay delay hi-z normal operation cpu clock reset period (oscillation stop) normal operation (reset processing, high-speed ring-osc clock) reset internal reset signal port pin reset signal to lcd controller/driver note high-speed system clock (when x1 oscillation is selected) high-speed ring-osc clock low-accuracy high-speed ring- osc clock automatic selection starting x1 oscillation is specified by software. high-accuracy high-speed ring-osc clock note set p130 (bit 0 of port mode register 13) to 1 by software. figure 22-3. timing of reset du e to watchdog timer overflow normal operation reset period (oscillation stop) cpu clock watchdog timer overflow internal reset signal normal operation (reset processing, high-speed ring-osc clock) hi-z port pin note high-speed system clock (when x1 oscillation is selected) high-speed ring-osc clock low-accuracy high-speed ring- osc clock automatic selection high-accuracy high-speed ring-osc clock starting x1 oscillation is specified by software. reset signal to lcd controller/driver note set p130 (bit 0 of port mode register 13) to 1 by software. caution a watchdog timer internal reset resets the watchdog timer. chapter 22 reset function preliminary user?s manual u17473ej1v0ud 500 figure 22-4. timing of reset in stop mode by reset input delay delay normal operation cpu clock reset period (oscillation stop) reset internal reset signal stop instruction execution stop status (oscillation stop) normal operation (reset processing, high-speed ring-osc clock) high-speed system clock (when x1 oscillation is selected) high-speed ring-osc clock hi-z port pin note low-accuracy high-speed ring- osc clock automatic selection high-accuracy high-speed ring-osc clock starting x1 oscillation is specified by software. reset signal to lcd controller/driver note set p130 (bit 0 of port mode register 13) to 1 by software. remark for the reset timing of the power-on-clear circuit and low-voltage detector, see chapter 23 power- on-clear circuit and chapter 24 low-voltage detector . chapter 22 reset function preliminary user?s manual u17473ej1v0ud 501 table 22-1. operation st atuses during reset period item during reset period system clock clock supply to the cpu is stopped. f rh operation stopped f x operation stopped (pin is i/o port mode) main system clock f exclk clock input invalid (pin is i/o port mode) f xt operation stopped (pin is i/o port mode) subsystem clock f exclks clock input invalid (pin is i/o port mode) f rl cpu flash memory ram operation stopped regulator operable port (latch) 00 16-bit timer/event counter 01 note 50 8-bit timer/event counter 51 h0 8-bit timer h1 watch timer watchdog timer a/d converter uart0 uart6 csi10 csi11 note serial interface iic0 lcd controller/driver multiplier/divider note operation stopped power-on-clear f unction operable low-voltage detection function external interrupt operation stopped note pd78f0395, 78f0397, and 78f0397d only. remark f rh : high-speed ring-osc oscillation clock f x : x1 oscillation clock f exclk : external main system clock f xt : xt1 oscillation clock f exclks : external subsystem clock f rl : low-speed ring-osc oscillation clock chapter 22 reset function preliminary user?s manual u17473ej1v0ud 502 table 22-2. hardware statuses after reset acknowledgment (1/3) hardware after reset acknowledgment note 1 program counter (pc) the contents of the reset vector table (0000h, 0001h) are set. stack pointer (sp) undefined program status word (psw) 02h data memory undefined note 2 ram general-purpose registers undefined note 2 port registers (p0 to p3, p7, p12, p13) (output latches) 00h port mode registers (pm0 to pm3, pm6, pm7, pm12, pm14) ffh pull-up resistor option registers (pu0, pu1, pu3, pu7, pu12) 00h internal memory size switching register (ims) cfh internal expansion ram size sw itching register (ixs) 0ch bank select register (bank) 00h processor clock control register (pcc) 01h clock operation mode select register (oscctl) 00h ring-osc mode register (rcm) 80h main clock mode register (mcm) 00h main osc control register (moc) 80h oscillation stabilization time select register (osts) 05h oscillation stabilization time counter status register (ostc) 00h timer counters 00, 01 (tm00, tm01) 0000h capture/compare registers 000, 010, 001, 011 (cr000, cr010, cr001, cr011) 0000h mode control registers 00, 01 (tmc00, tmc01) 00h prescaler mode registers 00, 01 (prm00, prm01) 00h capture/compare control registers 00, 01 (crc00, crc01) 00h 16-bit timer/event counters 00, 01 note 3 timer output control registers 00, 01 (toc00, toc01) 00h timer counters 50, 51 (tm50, tm51) 00h compare registers 50, 51 (cr50, cr51) 00h timer clock selection regist ers 50, 51 (tcl50, tcl51) 00h 8-bit timer/event counters 50, 51 mode control registers 50, 51 (tmc50, tmc51) 00h compare registers 00, 10, 01, 11 (cmp00, cmp10, cmp01, cmp11) 00h mode registers (tmhmd0, tmhmd1) 00h 8-bit timers h0, h1 carrier control register 1 (tmcyc1) note 4 00h watch timer operation m ode register (wtm) 00h clock output controller clock output selection register (cks) 00h notes 1. during reset input or oscillation stabilization time wa it, only the pc contents among the hardware statuses become undefined. all other hardware statuses remain unchanged after reset. 2. when a reset is executed in the standby mode, the pre-reset status is held even after reset. 3. 16-bit timer/event counter 01 is available only in the pd78f0395, 78f0397, and 78f0397d. 4. 8-bit timer h1 only. chapter 22 reset function preliminary user?s manual u17473ej1v0ud 503 table 22-2. hardware statuses after reset acknowledgment (2/3) hardware status after reset acknowledgment watchdog timer enable register (wdte) 1ah/9ah note 1 10-bit a/d conversion result register (adcr) 0000h 8-bit a/d conversion result register (adcrh) 00h mode register (adm) 00h analog input channel specification register (ads) 00h a/d converter a/d port configuration register (adpc) 00h receive buffer register 0 (rxb0) ffh transmit shift register 0 (txs0) ffh asynchronous serial interface oper ation mode register 0 (asim0) 01h asynchronous serial interface reception error status register 0 (asis0) 00h serial interface uart0 baud rate generator control register 0 (brgc0) 1fh receive buffer register 6 (rxb6) ffh transmit buffer register 6 (txb6) ffh asynchronous serial interface oper ation mode register 6 (asim6) 01h asynchronous serial interface reception error status register 6 (asis6) 00h asynchronous serial interface transmis sion status register 6 (asif6) 00h clock selection register 6 (cksr6) 00h baud rate generator control register 6 (brgc6) ffh asynchronous serial interface control register 6 (asicl6) 16h serial interface uart6 input switch control register (isc) 00h transmit buffer registers 10, 11 (sotb10, sotb11) 00h serial i/o shift registers 10, 11 (sio10, sio11) 00h serial operation mode registers 10, 11 (csim10, csim11) 00h serial interfaces csi10, csi11 note 2 serial clock selection register s 10, 11 (csic10, csic11) 00h shift register 0 (iic0) 00h control register 0 (iicc0) 00h slave address register 0 (sva0) 00h clock selection register 0 (iiccl0) 00h function expansion register 0 (iicx0) 00h status register 0 (iics0) 00h serial interface iic0 flag register 0 (iicf0) 00h lcd mode setting register (lcdmd) 00h lcd display mode register (lcdm) 00h lcd clock control register (lcdc) 00h lcd controller/driver lcd voltage boost control register 0 (vlcg0) 00h notes 1. the reset value of wdte is dete rmined by the option byte setting. 2. serial interface csi11 is available only in the pd78f0395, 78f0397, and 78f0397d. chapter 22 reset function preliminary user?s manual u17473ej1v0ud 504 table 22-2. hardware statuses after reset acknowledgment (3/3) hardware status after reset acknowledgment remainder data register 0 (sdr0) 0000h multiplication/division data regi ster a0 (mda0h, mda0l) 0000h multiplication/division data register b0 (mdb0) 0000h multiplier/divider note 1 multiplier/divider control register 0 (dmuc0) 00h key interrupt key return mode register (krm) 00h reset function reset control flag register (resf) 00h note 2 low-voltage detection register (lvim) 00h note 2 low-voltage detector low-voltage detection level selection register (lvis) 00h note 2 request flag registers 0l, 0h, 1l, 1h (if0l, if0h, if1l, if1h) 00h mask flag registers 0l, 0h, 1l, 1h (mk0l, mk0h, mk1l, mk1h) ffh priority specification fl ag registers 0l, 0h, 1l, 1h (pr0l, pr0h, pr1l, pr1h) ffh external interrupt rising edge enable register (egp) 00h interrupt external interrupt falling edge enable register (egn) 00h notes 1. multiplier/divider is available only in the pd78f0395, 78f0397, and 78f0397d. 2. these values vary depending on the reset source. reset source register reset input reset by poc reset by wdt reset by lvi resf see table 22-3 . lvim lvis cleared (00h) cleared (00h) cleared (00h) held chapter 22 reset function preliminary user?s manual u17473ej1v0ud 505 22.1 register for confirming reset source many internal reset generation sources exist in the 78k0/ lg2. the reset control flag register (resf) is used to store which source has generated the reset request. resf can be read by an 8-bit memory manipulation instruction. reset input, reset input by power-on-clear (poc ) circuit, and reading resf clear resf to 00h. figure 22-5. format of reset control flag register (resf) address: ffach after reset: 00h note r symbol 7 6 5 4 3 2 1 0 resf 0 0 0 wdtrf 0 0 0 lvirf wdtrf internal reset request by watchdog timer (wdt) 0 internal reset request is not generated, or resf is cleared. 1 internal reset request is generated. lvirf internal reset request by low-voltage detector (lvi) 0 internal reset request is not generated, or resf is cleared. 1 internal reset request is generated. note the value after reset varies depending on the reset source. caution do not read data by a 1-bi t memory manipulation instruction. the status of resf when a reset request is generated is shown in table 22-3. table 22-3. resf status when reset request is generated reset source flag reset input reset by poc reset by wdt reset by lvi wdtrf set (1) held lvirf cleared (0) cleared (0) held set (1) preliminary user?s manual u17473ej1v0ud 506 chapter 23 power-on-clear circuit 23.1 functions of power-on-clear circuit the power-on-clear circuit (poc) has the following functions. ? generates internal reset signal at power on. ? compares supply voltage (v dd ) and detection voltage (v poc = 1.59 v 0.15 v), generates internal reset signal when v dd < v poc , and releases reset when v dd v poc . caution if an internal reset signal is generated in the poc circuit, th e reset control flag register (resf) is cleared to 00h. remark this product incorporates multiple hardware functi ons that generate an internal reset signal. a flag that indicates the reset cause is located in the re set control flag register (resf) for when an internal reset signal is generated by the watchdog timer (w dt) or low-voltage-detector (lvi). resf is not cleared to 00h and the flag is set to 1 when an in ternal reset signal is generated by wdt or lvi. for details of resf, see chapter 22 reset function . chapter 23 power-on-clear circuit preliminary user?s manual u17473ej1v0ud 507 23.2 configuration of power-on-clear circuit the block diagram of the power-on-clear circuit is shown in figure 23-1. figure 23-1. block diagram of power-on-clear circuit ? + reference voltage source internal reset signal v dd v dd 23.3 operation of power-on-clear circuit in the power-on-clear circuit, the supply voltage (v dd ) and detection voltage (v poc ) are compared, an internal reset signal is generated when v dd < v poc , and reset is released when v dd v poc . figure 23-2. timing of internal reset si gnal generation in powe r-on-clear circuit time supply voltage (v dd ) poc detection voltage (v poc ) internal reset signal note note the rise time of the suppl y voltage is 0.5 v/ms (typ.). remark internal reset signal is active-low. chapter 23 power-on-clear circuit preliminary user?s manual u17473ej1v0ud 508 23.4 cautions for power-on-clear circuit in a system where the supply voltage (v dd ) fluctuates for a certain period in the vicinity of the poc detection voltage (v poc ), the system may be repeatedly reset and released from the reset status. in this case, the time from release of reset to the start of the oper ation of the microcontroller can be arbitrarily set by taking the following action. chapter 23 power-on-clear circuit preliminary user?s manual u17473ej1v0ud 509 figure 23-3. example of software processing after reset release (2/2) ? checking reset cause yes no check reset cause power-on-clear/external reset generated reset processing by watchdog timer reset processing by low-voltage detector no wdtrf of resf register = 1? lvirf of resf register = 1? yes preliminary user?s manual u17473ej1v0ud 510 chapter 24 low-voltage detector 24.1 functions of low-voltage detector the low-voltage detector (lvi ) has the following functions. ? compares supply voltage (v dd ) and detection voltage (v lvi ), and generates an internal interrupt signal or internal reset signal when v dd < v lvi . detection levels (16 levels) of s upply voltage can be changed by software. ? compares a voltage input from an external input pin (exlvi) with the detection voltage (v exlvi = 1.21 v (typ.)), and generates an internal interrupt signal or internal reset signal when exlvi < v exlvi . ? the supply voltage (v dd ) or voltage input from an external input pin (exlvi) can be selected by software. ? interrupt or reset function can be selected by software. ? operable in stop mode. when the low-voltage detector is used to reset, bit 0 (lvirf) of the reset control flag regi ster (resf) is set to 1 if reset occurs. for details of resf, see chapter 22 reset function . 24.2 configuration of low-voltage detector the block diagram of the low-voltage detector is shown in figure 24-1. figure 24-1. block diagram of low-voltage detector lvis1 lvis0 lvion | { v dd n-ch lvis2 lvis3 lvif intlvi 4 lvisel exlvi/p120/ intp0 lvimd v dd selector internal reset signal selector reference voltage source low-voltage detection register (lvim) low-voltage detection level selection register (lvis) internal bus low-voltage detection level selector chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 511 24.3 registers controlling low-voltage detector the low-voltage detector is contro lled by the following registers. ? low-voltage detection register (lvim) ? low-voltage detection level selection register (lvis) ? port mode register 12 (pm12) chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 512 (1) low-voltage detection register (lvim) this register sets low-voltag e detection and the operation mode. this register can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears lvim to 00h. figure 24-2. format of low-volta ge detection register (lvim) <0> lvif <1> lvimd <2> lvisel 3 0 4 0 5 0 6 0 <7> lvion symbol lvim address: ffbeh after reset: 00h r/w note 1 lvion notes 2, 3 enables low-voltage detection operation 0 disables operation 1 enables operation lvisel note 2 voltage detection selection 0 detects level of supply voltage (v dd ) 1 detects level of input voltage from external input pin (exlvi) lvimd note 2 low-voltage detection operation mode selection 0 ? lvisel = 0: generates interrupt signal when supply voltage (v dd ) < detection voltage (v lvi ) ? lvisel = 1: generates interrupt signal when input voltage from external input pin (exlvi) < detection voltage (v exlvi ) 1 ? lvisel = 0: generates internal reset signal when supply voltage (v dd ) < detection voltage (v lvi ) ? lvisel = 1: generates internal reset signal when input voltage from external input pin (exlvi) < detection voltage (v exlvi ) lvif note 4 low-voltage detection flag 0 ? lvisel = 0: supply voltage (v dd ) detection voltage (v lvi ), or when operation is disabled ? lvisel = 1: input voltage from external input pin (exlvi) detection voltage (v exlvi ), or when operation is disabled 1 ? lvisel = 0: supply voltage (v dd ) < detection voltage (v lvi ) ? lvisel = 1: input voltage from external input pin (exlvi) < detection voltage (v exlvi ) notes 1. bit 0 is read-only. 2. lvion, lvimd, and lvisel are cleared to 0 in the case of a reset other than an lvi reset. these are not cleared to 0 in the case of an lvi reset. 3. when lvion is set to 1, operation of the com parator in the lvi circuit is started. use software to wait for an operation stabilization time (10 s (typ.)) when lvion is set to 1 until the voltage is confirmed at lvif. 4. the value of lvif is output as the interru pt request signal intlvi when lvion = 1 and lvimd = 0. cautions 1. to stop lvi, follow either of the procedures below. ? when using 8-bit memory manipulation instruction: write 00h to lvim. ? when using 1-bit memory manipulation instruction: clear lvion to 0. 2. input voltage from external input pin (exlvi) must be exlvi < v dd . chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 513 (2) low-voltage detection level selection register (lvis) this register selects the low-voltage detection level. this register can be set by a 1-bit or 8-bit memory manipulation instruction. reset input clears lvis to 00h. figure 24-3. format of low-voltage dete ction level selection register (lvis) 0 lvis0 1 lvis1 2 lvis2 3 lvis3 4 0 5 0 6 0 7 0 symbol lvis address: ffbfh after reset: 00h r/w lvis3 lvis2 lvis1 lvis0 detection level 0 0 0 0 v lvi0 (4.24 v 0.1 v) 0 0 0 1 v lvi1 (4.09 v 0.1 v) 0 0 1 0 v lvi2 (3.93 v 0.1 v) 0 0 1 1 v lvi3 (3.78 v 0.1 v) 0 1 0 0 v lvi4 (3.62 v 0.1 v) 0 1 0 1 v lvi5 (3.47 v 0.1 v) 0 1 1 0 v lvi6 (3.32 v 0.1 v) 0 1 1 1 v lvi7 (3.16 v 0.1 v) 1 0 0 0 v lvi8 (3.01 v 0.1 v) 1 0 0 1 v lvi9 (2.85 v 0.1 v) 1 0 1 0 v lvi10 (2.70 v 0.1 v) 1 0 1 1 v lvi11 (2.55 v 0.1 v) 1 1 0 0 v lvi12 (2.39 v 0.1 v) 1 1 0 1 v lvi13 (2.24 v 0.1 v) 1 1 1 0 v lvi14 (2.08 v 0.1 v) 1 1 1 1 v lvi15 (1.93 v 0.1 v) cautions 1. be sure to clear bits 4 to 7 to 0. 2. do not change the value of lvis during lvi operation. 3. when an input voltage from the externa l input pin (exlvi) is detected, the detection voltage (v exlvi = 1.21 v (typ.)) is fixed. therefor e, setting of lvis is not necessary. chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 514 (3) port mode register 12 (pm12) when using the p120/exlvi/intp0 pin for external low-volt age detection potential input, set pm120 to 1. at this time, the output latch of p120 may be 0 or 1. pm12 can be set by a 1-bit or 8-bit memory manipulation instruction. reset input sets pm12 to ffh. figure 24-4. format of port mode register 12 (pm12) 0 pm120 1 pm121 2 pm122 3 pm123 4 pm124 5 1 6 1 7 1 symbol pm12 address: ff2ch after reset: ffh r/w pm12n p12n pin i/o mode selection (n = 0 to 4) 0 output mode (output buffer on) 1 input mode (output buffer off) 24.4 operation of low-voltage detector the low-voltage detector can be us ed in the following two modes. (1) used as reset ? if lvisel = 0, compares the supply voltage (v dd ) and detection voltage (v lvi ), generates an internal reset signal when v dd < v lvi , and releases internal reset when v dd v lvi . ? if lvisel = 1, compares the input voltage from external input pin (exlvi) and detection voltage (v exlvi = 1.21 v (typ.)), generates an internal reset signal when exlvi < v exlvi , and releases internal reset when exlvi v exlvi . (2) used as interrupt ? if lvisel = 0, compares the supply voltage (v dd ) and detection voltage (v lvi ), and generates an interrupt signal (intlvi) when v dd < v lvi . ? if lvisel = 1, compares the input voltage from external input pin (exlvi) and detection voltage (v exlvi = 1.21 v (typ.)), and generates an interrupt signal (intlvi) when exlvi < v exlvi . remark lvisel: bit 2 of low-voltage detection register (lvim) chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 515 24.4.1 when used as reset (1) when detecting level of supply voltage (v dd ) ? when starting operation <1> mask the lvi interrupt (lvimk = 1). <2> clear bit 2 (lvisel) of the low-voltage detection r egister (lvim) to 0 (detects level of supply voltage (v dd )) (default value). <3> set the detection voltage using bits 3 to 0 (lvis3 to lvis0) of the low-voltage detection level selection register (lvis). <4> set bit 7 (lvion) of lvim to 1 (enables lvi operation). <5> use software to wait for an operation stabilization time (10 s (typ.)). <6> wait until it is checked that (supply voltage (v dd ) detection voltage (v lvi )) by bit 0 (lvif) of lvim. <7> set bit 1 (lvimd) of lvim to 1 (generates internal reset signal when supply voltage (v dd ) < detection voltage (v lvi )). figure 24-5 shows the timing of the internal reset signal generated by the low-volt age detector. the numbers in this timing chart correspond to <1> to <7> above. cautions 1. <1> must always be executed. when lvimk = 0, an interrupt may occur immediately after the processing in <4>. 2. if supply voltage (v dd ) detection voltage (v lvi ) when lvimd is set to 1, an internal reset signal is not generated. ? when stopping operation either of the following pr ocedures must be executed. ? when using 8-bit memory manipulation instruction: write 00h to lvim. ? when using 1-bit memory manipulation instruction: clear lvimd to 0 and then lvion to 0. chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 516 figure 24-5. timing of low-voltage dete ctor internal reset signal generation (detects level of supply voltage (v dd )) supply voltage (v dd ) lvi detection voltage (v lvi ) poc detection voltage (v poc ) <3> <1> time lvimk flag (set by software) lvif flag lvirf flag note 3 note 2 lvi reset signal poc reset signal internal reset signal cleared by software not cleared not cleared not cleared not cleared cleared by software <4> <7> clear clear clear <5> wait time lvion flag (set by software) lvimd flag (set by software) h note 1 l lvisel flag (set by software) <6> <2> notes 1. the lvimk flag is set to ?1? by reset input. 2. the lvif flag may be set (1). 3. lvirf is bit 0 of the reset control flag re gister (resf). for details of resf, see chapter 22 reset function . remark <1> to <7> in figure 24-5 above correspond to <1> to <7> in the description of 24.4.1 (1) when detecting level of supply voltage (v dd ) ? when starting operation . chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 517 (2) when detecting level of input vo ltage from external input pin (exlvi) ? when starting operation <1> mask the lvi interrupt (lvimk = 1). <2> set bit 2 (lvisel) of the low-voltage detection regist er (lvim) to 1 (detects level of input voltage from external input pin (exlvi)). <3> set bit 7 (lvion) of lvim to 1 (enables lvi operation). <4> use software to wait for an operation stabilization time (10 s (typ.)). <5> wait until it is checked that (input voltage from external input pin (exlvi) detection voltage (v exlvi = 1.21 v (typ.))) by bit 0 (lvif) of lvim. <6> set bit 1 (lvimd) of lvim to 1 (generates internal reset signal when input voltage from external input pin (exlvi) < detection voltage (v exlvi = 1.21 v (typ.))). figure 24-6 shows the timing of the internal reset signal generated by the low-volt age detector. the numbers in this timing chart correspond to <1> to <6> above. cautions 1. <1> must always be executed. when lvimk = 0, an interrupt may occur immediately after the processing in <3>. 2. if input voltage from external input pin (exlvi) detection voltage (v exlvi = 1.21 v (typ.)) when lvimd is set to 1, an intern al reset signal is not generated. 3. input voltage from external input pin (exlvi) must be exlvi < v dd . ? when stopping operation either of the following pr ocedures must be executed. ? when using 8-bit memory manipulation instruction: write 00h to lvim. ? when using 1-bit memory manipulation instruction: clear lvimd to 0 and then lvion to 0. chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 518 figure 24-6. timing of low-voltage dete ctor internal reset signal generation (detects level of input voltage fr om external input pin (exlvi)) input voltage from external input pin (exlvi) lvi detection voltage (v exlvi ) <1> time lvimk flag (set by software) lvif flag lvirf flag note 3 note 2 lvi reset signal internal reset signal cleared by software not cleared not cleared not cleared not cleared cleared by software <3> <6> lvion flag (set by software) lvimd flag (set by software) h note 1 lvisel flag (set by software) <5> <2> not cleared not cleared <4> wait time not cleared not cleared not cleared notes 1. the lvimk flag is set to ?1? by reset input. 2. the lvif flag may be set (1). 3. lvirf is bit 0 of the reset control flag register (resf). for details of resf, see chapter 22 reset function . remark <1> to <6> in figure 24-6 above correspond to <1> to <6> in the description of 24.4.1 (2) when detecting level of input voltage from external input pin (exlvi) ? when starting operation . chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 519 24.4.2 when used as interrupt (1) when detecting level of supply voltage (v dd ) ? when starting operation <1> mask the lvi interrupt (lvimk = 1). <2> clear bit 2 (lvisel) of the low-voltage detection r egister (lvim) to 0 (detects level of supply voltage (v dd )) (default value). <3> set the detection voltage using bits 3 to 0 (lvis3 to lvis0) of the low-voltage detection level selection register (lvis). <4> set bit 7 (lvion) of lvim to 1 (enables lvi operation). <5> use software to wait for an operation stabilization time (10 s (typ.)). <6> confirm that ?supply voltage (v dd ) detection voltage (v lvi )? at bit 0 (lvif) of lvim. <7> clear the interrupt request flag of lvi (lviif) to 0. <8> release the interrupt mask flag of lvi (lvimk). <9> clear bit 1 (lvimd) of lvim to 0 (gener ates interrupt signal when supply voltage (v dd ) < detection voltage (v lvi )) (default value). <10> execute the ei instruction (w hen vector interrupts are used). figure 24-7 shows the timing of the interrupt signal ge nerated by the low-voltage detector. the numbers in this timing chart correspond to <1> to <9> above. ? when stopping operation either of the following pr ocedures must be executed. ? when using 8-bit memory manipulation instruction: write 00h to lvim. ? when using 1-bit memory manipulation instruction: clear lvion to 0. chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 520 figure 24-7. timing of low-voltage de tector interrupt signal generation (detects level of supply voltage (v dd )) supply voltage (v dd ) lvi detection voltage (v lvi ) poc detection voltage (v poc ) time <1> note 1 <8> cleared by software lvimk flag (set by software) lvif flag intlvi lviif flag internal reset signal <4> <6> <7> cleared by software <5> wait time lvion flag (set by software) note 2 note 2 <3> l lvisel flag (set by software) <2> lvimd flag (set by software) l <9> notes 1. the lvimk flag is set to ?1? by reset input. 2. the lvif and lviif flags may be set (1). remark <1> to <9> in figure 24-7 above correspond to <1> to <9> in the description of 24.4.2 (1) when detecting level of supply voltage (v dd ) ? when starting operation . chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 521 (2) when detecting level of input vo ltage from external input pin (exlvi) ? when starting operation <1> mask the lvi interrupt (lvimk = 1). <2> set bit 2 (lvisel) of the low-voltage detection regist er (lvim) to 1 (detects level of input voltage from external input pin (exlvi)). <3> set bit 7 (lvion) of lvim to 1 (enables lvi operation). <4> use software to wait for an operation stabilization time (10 s (typ.)). <5> confirm that ?input voltage fr om external input pin (exlvi) detection voltage (v exlvi = 1.21 v (typ.))? at bit 0 (lvif) of lvim. <6> clear the interrupt request flag of lvi (lviif) to 0. <7> release the interrupt mask flag of lvi (lvimk). <8> clear bit 1 (lvimd) of lvim to 0 (gener ates interrupt signal when supply voltage (v dd ) < detection voltage (v lvi )) (default value). <9> execute the ei instruction (w hen vector interrupts are used). figure 24-8 shows the timing of the interrupt signal ge nerated by the low-voltage detector. the numbers in this timing chart correspond to <1> to <8> above. caution input voltage from external i nput pin (exlvi) must be exlvi < v dd . ? when stopping operation either of the following pr ocedures must be executed. ? when using 8-bit memory manipulation instruction: write 00h to lvim. ? when using 1-bit memory manipulation instruction: clear lvion to 0. chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 522 figure 24-8. timing of low-voltage detector interrupt signal generation (detects level of input voltage fr om external input pin (exlvi)) input voltage from external input pin (exlvi) lvi detection voltage (v exlvi ) time <1> note 1 <7> cleared by software lvimk flag (set by software) lvif flag intlvi lviif flag <3> <5> <6> cleared by software <4> wait time lvion flag (set by software) note 2 note 2 lvisel flag (set by software) <2> lvimd flag (set by software) l <8> notes 1. the lvimk flag is set to ?1? by reset input. 2. the lvif and lviif flags may be set (1). remark <1> to <8> in figure 24-8 above correspond to <1> to <8> in the description of 24.4.2 (1) when detecting level of supply voltage (v dd ) ? when starting operation . chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 523 24.5 cautions for low-voltage detector in a system where the supply voltage (v dd ) fluctuates for a certain period in t he vicinity of the lvi detection voltage (v lvi ), the operation is as follows depending on how the low-voltage detector is used. (1) when used as reset the system may be repeatedly reset and released from the reset status. in this case, the time from release of reset to the start of the operation of the microcontroller can be arbitrarily set by taking action (1) below. (2) when used as interrupt interrupt requests may be frequently generated. take action (2) below. in this system, take the following actions. chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 524 figure 24-9. example of software processing after reset release (1/2) ? if supply voltage fluctuation is 50 ms or less in vicinity of lvi detection voltage yes lvi ; the high-speed ring-osc clock is set as the cpu clock when the reset signal is generated ; the cause of reset (power-on-clear, wdt, or lvi) can be identified by the resf register. ; tmifh1 = 1: interrupt request is generated. ; initialization of ports ; 8-bit timer h1 can operate with the low-speed ring-osc clock. source: f rl (264 khz (max.))/2 7 compare value 104 = 50 ms (f rl : low-speed ring-osc clock oscillation frequency) no note 1 reset checking cause of reset note 2 50 ms has passed? (tmifh1 = 1?) initialization processing start timer (set to 50 ms) notes 1. if reset is generated again during this period , initialization processing is not started. 2. a flowchart is shown on the next page. chapter 24 low-voltage detector preliminary user?s manual u17473ej1v0ud 525 figure 24-9. example of software processing after reset release (2/2) ? checking reset cause yes no check reset cause power-on-clear/external reset generated reset processing by watchdog timer reset processing by low-voltage detector yes wdtrf of resf register = 1? lvirf of resf register = 1? no preliminary user?s manual u17473ej1v0ud 526 chapter 25 option byte the 78k0/lg2 has an area called an opt ion byte at address 0080h/1080h note of the flash memory. when using the product, be sure to set the following functions by using the option byte. { low-speed ring-osc oscillation ? can be stopped by software ? cannot be stopped { watchdog timer interval time setting { watchdog timer counter operation control ? enabled counter operation ? disabled counter operation { watchdog timer window open period setting figure 25-1. allocation of option byte option byte flash memory 0000h 0080h note 1080h note window1 0 ringosc window0 wdton wdcs1 wdcs0 wdcs2 figure 25-2. format of option byte (1/2) address: 0080h/1080h note 7 6 5 4 3 2 1 0 0 window1 window0 wdton wdcs2 wdcs1 wdcs0 ringosc window1 window0 watchdog timer window open period 0 0 25% 0 1 50% 1 0 75% 1 1 100% note set 1080h to the same value as that for 0080h in advance, since 0080h and 10 80h are switched during the boot swap operation. chapter 25 option byte preliminary user?s manual u17473ej1v0ud 527 figure 25-2. format of option byte (2/2) wdton watchdog timer counter control 0 counter operation disabled (counting stopped after reset) 1 counter operation enabled (counting started after reset) wdcs2 wdcs1 wdcs0 watc hdog timer overflow time 0 0 0 2 10 /f rl (3.88 ms) 0 0 1 2 11 /f rl (7.76 ms) 0 1 0 2 12 /f rl (15.52 ms) 0 1 1 2 13 /f rl (31.03 ms) 1 0 0 2 14 /f rl (62.06 ms) 1 0 1 2 15 /f rl (124.12 ms) 1 1 0 2 16 /f rl (248.24 ms) 1 1 1 2 17 /f rl (496.48 ms) ringosc low-speed ring-osc oscillation 0 can be stopped by software (stopped when 1 is written to lsrstop bit) 1 cannot be stopped (not stopped even if 1 is written to lsrstop bit) cautions 1. the combination of wdcs2, wdcs1, wdcs0 = 0, 0, 0 and window1, window0 = 0, 0 is prohibited. 2. the watchdog timer does not stop duri ng self-programming of th e flash memory and eeprom emulation. during pr ocessing, the interrupt acknowledge time is delayed. set the overflow time and window size taki ng this delay into consideration. 3. if ringosc = 0 (oscillation can be stopped by software), supply of the count clock to the watchdog timer is stopped in the halt and stop m odes, regardless of the setting of bit 0 (lsrstop) of the ring-osc mode register ( rcm). if the low-sp eed ring-osc clock is selected for the count clock to 8-bit timer h1, however, the c ount clock is supplied in the halt and stop modes while the low-speed ring-osc clock operates (lsrstop = 0). 4. be sure to clear bit 7 to 0. remarks 1. f rl : low-speed ring-osc clock oscillation frequency 2. ( ): f rl = 264 khz (max.) 3. an example of software coding for setting the option bytes is shown below. opt oseg at 0080h option: db 00h ; set to option byte preliminary user?s manual u17473ej1v0ud 528 chapter 26 flash memory the pd78f0393, 78f0395, 78f0397, and 78f0397d incorporate the flash me mory to which a program can be written, erased, and overwritt en while mounted on the board. 26.1 internal memory size switching register the internal memory capacity can be selected using t he internal memory size s witching register (ims). ims is set by an 8-bit memory manipulation instruction. reset input sets ims to cfh. caution be sure to set each produc t to the values shown in table 26-1 after a reset release. figure 26-1. format of internal memo ry size switching register (ims) address: fff0h after reset: cfh r/w symbol 7 6 5 4 3 2 1 0 ims ram2 ram1 ram0 0 rom3 rom2 rom1 rom0 ram2 ram1 ram0 internal hi gh-speed ram capacity selection 1 1 0 1024 bytes other than above setting prohibited rom3 rom2 rom1 rom0 internal rom capacity selection 1 0 0 0 32 kb 1 1 0 0 48 kb 1 1 1 1 60 kb other than above setting prohibited table 26-1. internal memory si ze switching register settings flash memory versions (78k0/lg2) ims setting pd78f0393 c8h pd78f0395 cfh pd78f0397, 78f0397d cch note note although the pd78f0397 and 78f0397d have an internal rom capacity of 128 kb, se t the internal rom capacity to 48 kb, since banks are us ed. for how to set the banks, see 26.2 bank select register ( pd78f0397 and 78f0397d only) . chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 529 26.2 bank select register ( pd78f0397 and 78f0397d only) the bank area to be used can be set using the bank select register (bank). bank is set by an 8-bit memory manipulation instruction. reset input clears bank to 00h. remark for the bank area, see figure 3-3 memory map ( pd78f0397) , figure 3-4 memory map ( pd78f0397d) , and 3.1.2 bank area ( pd78f0397 and 78f0397d only) . figure 26-2. format of bank select register (bank) address: fff3h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 bank 0 0 0 0 0 bank2 bank1 bank0 bank setting bank2 bank1 bank0 pd78f0397, 78f0397d 0 0 0 common area (32 k) + bank area 0 (16 k) 0 0 1 common area (32 k) + bank area 1 (16 k) 0 1 0 common area (32 k) + bank area 2 (16 k) 0 1 1 common area (32 k) + bank area 3 (16 k) 1 0 0 common area (32 k) + bank area 4 (16 k) 1 0 1 common area (32 k) + bank area 5 (16 k) other than above setting prohibited chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 530 26.3 internal expansion ram size switching register the internal expansion ram capacity can be selected using the internal expansion ram size switching register (ixs). ixs is set by an 8-bit memory manipulation instruction. reset input sets ixs to 0ch. caution be sure to set each produc t to the values shown in table 26-2 after a reset release. figure 26-3. format of internal expans ion ram size switching register (ixs) address: fff4h after reset: 0ch r/w symbol 7 6 5 4 3 2 1 0 ixs 0 0 0 ixram4 ixram3 ixram2 ixram1 ixram0 ixram4 ixram3 ixram2 ixram1 ixram0 internal expansion ram capacity selection 0 1 1 0 0 0 bytes 0 1 0 0 0 2048 bytes 0 0 0 0 0 6144 bytes other than above setting prohibited table 26-2. internal expansion ram size switching register settings flash memory versions (78k0/lg2) ixs setting pd78f0393 0ch pd78f0395 08h pd78f0397, 78f0397d 00h 26.4 writing with flash programmer data can be written to the flash memory on-board or off-board, by using a dedicated flash programmer. (1) on-board programming the contents of the flash memory can be rewritten after the 78k0/lg2 has been moun ted on the target system. the connectors that connect the dedicated flash programmer must be mounted on the target system. (2) off-board programming data can be written to the flash memory with a dedicat ed program adapter (fa seri es) before the 78k0/lg2 is mounted on the target system. remark the fa series is a product of na ito densei machida mfg. co., ltd. chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 531 table 26-3. wiring between 78k0/lg2 and dedicated flash programmer (gc package) pin configuration of dedicated flas h programmer with csi10 with uart6 signal name i/o pin function pin name pin no. pin name pin no. si/rxd input receive signal so10/p12 74 txd6/p13 73 so/txd output transmit signal si10/rxd0/p11 75 rxd6/p14 72 sck output transfer clock sck10/txd0/p10 76 ? ? clk output clock to 78k0/lg2 ? note 1 ? exclk/x2/p122 note 2 10 /reset output reset signal reset 6 reset 6 flmd0 output mode signal flmd0 9 flmd0 9 v dd 14 v dd 14 lv dd 65 lv dd 65 v dd i/o v dd voltage generation/ power monitoring av ref 77 av ref 77 v ss 13 v ss 13 lv ss 64 lv ss 64 gnd ? ground av ss 78 av ss 78 notes 1. only the high-speed ring-osc clock (f rh ) can be used when csi10 is used. 2. only the x1 clock (f x ) or external main system clock (f exclk ) can be used when uart6 is used. when using the clock out of the flash programme r, connect clk and exclk of the programmer. table 26-4. wiring between 78k0/lg2 and dedicated flash programmer (gf package) pin configuration of dedicated flas h programmer with csi10 with uart6 signal name i/o pin function pin name pin no. pin name pin no. si/rxd input receive signal so10/p12 77 txd6/p13 76 so/txd output transmit signal si10/rxd0/p11 78 rxd6/p14 75 sck output transfer clock sck10/txd0/p10 79 ? ? clk output clock to 78k0/lg2 ? note 1 ? exclk/x2/p122 note 2 13 /reset output reset signal reset 9 reset 9 flmd0 output mode signal flmd0 12 flmd0 12 v dd 17 v dd 17 lv dd 68 lv dd 68 v dd i/o v dd voltage generation/ power monitoring av ref 80 av ref 80 v ss 16 v ss 16 lv ss 67 lv ss 67 gnd ? ground av ss 81 av ss 81 notes 1. only the high-speed ring-osc clock (f rh ) can be used when csi10 is used. 2. only the x1 clock (f x ) or external main system clock (f exclk ) can be used when uart6 is used. when using the clock out of the flash programme r, connect clk and exclk of the programmer. chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 532 examples of the recommended connection when using the adapter for flash memory writing are shown below. figure 26-4. example of wiring ad apter for flash memory writing in 3-wire serial i/o (csi10) mode (gc package) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 writer interface si so sck clk /reset flmd0 v dd (2.7 to 5.5 v) gnd gnd vdd vdd2 chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 533 figure 26-5. example of wiring ad apter for flash memory writing in uart (uart6) mode (gc package) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 writer interface si so sck clk /reset flmd0 v dd (2.7 to 5.5 v) gnd gnd vdd vdd2 chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 534 figure 26-6. example of wiring ad apter for flash memory writing in 3-wire serial i/o (csi10) mode (gf package) gnd vdd vdd2 si so sck clk /reset flmd0 writer interface v dd (2.7 to 5.5 v) gnd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 535 figure 26-7. example of wiring ad apter for flash memory writing in uart (uart6) mode (gf package) gnd vdd vdd2 si so sck clk /reset flmd0 writer interface v dd (2.7 to 5.5 v) gnd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 536 26.5 programming environment the environment required for writing a program to the fl ash memory of the 78k0/lg 2 is illustrated below. figure 26-8. environment for wr iting program to flash memory rs-232c usb 78k0/lg2 flmd0 v dd v ss reset csi10/uart6 host machine dedicated flash programmer pg-fp4 (flash pro4) cxxxxxx bxxxxx axxxx x x x y yy xxxxx xxxxxx xxxx x x x x y y y y s tat v e a host machine that controls the dedic ated flash programmer is necessary. to interface between the dedicated flash programme r and the 78k0/lg2, csi10 or uart6 is used for manipulation such as writing and erasi ng. to write the flash memory off- board, a dedicated program adapter (fa series) is necessary. 26.6 communication mode communication between the dedicated flash progra mmer and the 78k0/lg2 is established by serial communication via csi10 or uart6 of the 78k0/lg2. (1) csi10 transfer rate: 200 khz to 2 mhz figure 26-9. communication with de dicated flash programmer (csi10) v dd /lv dd /av ref v ss /lv ss /av ss reset so10 si10 sck10 flmd0 flmd0 v dd gnd /reset si/rxd so/txd sck dedicated flash programmer pg-fp4 (flash pro4) cxxxxxx bxxxxx axxxx xxx yyy xxxxx xxxxxx xxxx xxxx yyyy statve 78k0/lg2 chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 537 (2) uart6 transfer rate: 115200 bps figure 26-10. communication with de dicated flash programmer (uart6) v dd /lv dd /av ref v ss /lv ss /av ss reset txd6 rxd6 v dd gnd /reset si/rxd so/txd exclk clk dedicated flash programmer pg-fp4 (flash pro4) cxxxxxx bxxxxx axxxx xxx yyy xxxxx xx xxxx xxxx xxxx yyyy statve flmd0 flmd0 78k0/lg2 if flashpro4 is used as the dedicated flash programme r, flashpro4 generates the following signal for the 78k0/lg2. for details, refer to the flashpro4 manual. table 26-4. pin connection flashpro4 78k0/lg2 connection signal name i/o pin function pin name csi10 uart6 flmd0 output mode signal flmd0 v dd i/o v dd voltage generation/power monitoring v dd , lv dd , av ref gnd ? ground v ss , lv ss , av ss clk output clock output to 78k0/lg2 exclk note 1 { note 2 /reset output reset signal reset si/rxd input receive signal so10/txd6 so/txd output transmit signal si10/rxd6 sck output transfer clock sck10 notes 1. only the high-speed ring-osc clock (f rh ) can be used when csi10 is used. 2. only the x1 clock (f x ) or external main system clock (f exclk ) can be used when uart6 is used. when using the clock out of the flash programme r, connect clk and exclk of the programmer. remark : be sure to connect the pin. { : the pin does not have to be connected if the signal is generated on the target board. : the pin does not have to be connected. chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 538 26.7 handling of pins on board to write the flash memory on-board, connectors that connect the dedicated flash programmer must be provided on the target system. first provide a f unction that selects the normal operati on mode or flash memory programming mode on the board. when the flash memory programming mode is set, all the pins not used for programming the flash memory are in the same status as immediately after re set. therefore, if the external device does not recognize t he state immediately after reset, the pins must be handled as described below. 26.7.1 flmd0 pin in the normal operation mode, 0 v is input to the flmd 0 pin. in the flash memory programming mode, the v dd write voltage is supplied to the flmd0 pin. an flmd0 pin connection example is shown below. figure 26-11. flmd0 pin connection example 78k0/lg2 flmd0 dedicated flash programmer connection pin 26.7.2 serial interface pins the pins used by each serial interface are listed below. table 26-6. pins used by each serial interface serial interface pins used csi10 so10, si10, sck10 uart6 txd6, rxd6 to connect the dedicated flash programmer to the pins of a serial interface that is co nnected to another device on the board, care must be exercised so that signals do not collide or that the other device does not malfunction. chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 539 (1) signal collision if the dedicated flash programmer (output) is connected to a pin (input) of a serial interface connected to another device (output), signal collision takes place. to avoid this collision, either isolat e the connection with the other device, or make the other device go into an output high-impedance state. figure 26-12. signal collision (i nput pin of serial interface) input pin signal collision dedicated flash programmer connection pin other device output pin in the flash memory programming mode, the signal output by the device collides with the signal sent from the dedicated flash programmer. therefore, isolate the signal of the other device. 78k0/lg2 (2) malfunction of other device if the dedicated flash programmer (output or input) is connec ted to a pin (input or output) of a serial interface connected to another device (input), a signal may be output to the other device , causing the device to malfunction. to avoid this malfunction, isolate the connection with the other device. figure 26-13. malfunction of other device pin dedicated flash programmer connection pin other device input pin if the signal output by the 78k0/lg2 in the flash memory programming mode affects the other device, isolate the signal of the other device. pin dedicated flash programmer connection pin other device input pin if the signal output by the dedicated flash programmer in the flash memory programming mode affects the other device, isolate the signal of the other device. 78k0/lg2 78k0/lg2 chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 540 26.7.3 reset pin if the reset signal of the dedicated flash programmer is co nnected to the reset pin that is connected to the reset signal generator on the board, signal collision takes place. to prevent this collision, is olate the connection with the reset signal generator. if the reset signal is input from the user system whil e the flash memory programming mode is set, the flash memory will not be correctly programmed. do not input any signal other than the reset signal of the dedicated flash programmer. figure 26-14. signal collision (reset pin) reset dedicated flash programmer connection signal reset signal generator signal collision output pin in the flash memory programming mode, the signal output by the reset signal generator collides with the signal output by the dedicated flash programmer. therefore, isolate the signal of the reset signal generator. 78k0/lg2 26.7.4 port pins when the flash memory programming mode is set, all the pins not used for flash memory programming enter the same status as that immediately afte r reset. if external devices connected to the ports do not recognize the port status immediately after reset, the port pin must be connected to v dd or v ss via a resistor. 26.7.5 regc pin connect the regc pin to gnd via a capacitor (0.47 f: target) in the same manner as during normal operation. 26.7.6 other signal pins connect x1 and x2 in the same status as in t he normal operation mode when using the on-board clock. to input the operating clock from the programmer, how ever, connect the clock out of the programmer to exclk. cautions 1. only the high-speed ring-osc clock (f rh ) can be used when csi10 is used. 2. only the x1 clock (f x ) or external main system clock (f exclk ) can be used when uart6 is used. 26.7.7 power supply to use the supply voltage output of t he flash programmer, connect the v dd pin to v dd of the flash programmer, and the v ss pin to gnd of the flash programmer. however, be sure to connect the v dd and v ss pins to v dd and gnd of the flash programmer to use the power monitor function with the flash programmer. to use the on-board supply voltage, connect in compliance with the normal operation mode. supply the same other power supplies (lv dd , lv ss , av ref , and av ss ) as those in the normal operation mode. chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 541 26.8 programming method 26.8.1 controlling flash memory the following figure illustrates the proc edure to manipulate the flash memory. figure 26-15. flash memory manipulation procedure start selecting communication mode manipulate flash memory end? yes flmd0 pulse supply no end flash memory programming mode is set 26.8.2 flash memory programming mode to rewrite the contents of the flash memory by using the dedicated fl ash programmer, set the 78k0/lg2 in the flash memory programming mode. to se t the mode, set the flmd0 pin to v dd and clear the reset signal. change the mode by using a jumper when writing the flash memory on-board. figure 26-16. flash memory programming mode v dd reset 5.5 v 0 v v dd 0 v flash memory programming mode flmd0 flmd0 pulse v dd 0 v table 26-7. relationship between flmd0 pi n and operation mode after reset release flmd0 operation mode 0 normal operation mode v dd flash memory programming mode chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 542 26.8.3 selecting communication mode in the 78k0/lg2, a communication mode is selected by inpu tting pulses (up to 11 pulses) to the flmd0 pin after the dedicated flash memory programmi ng mode is entered. these flmd0 pu lses are generated by the flash programmer. the following table shows the relationship between the number of pulses and communication modes. table 26-8. communication modes standard setting note 1 communication mode port speed on target frequency multiply rate pins used peripheral clock number of flmd0 pulses f x 0 uart (uart6) uart-ch0 115200 bps note 3 txd6, rxd6 f exclk 3 3-wire serial i/o (csi10) sio-ch0 200 khz to 2 mhz note 2 optional 2 to 16 mhz 1.0 so10, si10, sck10 f rh 8 notes 1. selection items for standard settings on flashpro4. 2. the possible setting range differs depending on the voltage. for details, refer to the chapter of electrical specifications. 3. because factors other than the baud rate error, such as the signal waveform slew, also affect uart communication, thoroughly evaluate the slew as well as the baud rate error. caution when uart6 is select ed, the receive clock is calculated b ased on the reset command sent from the dedicated flash programmer after th e flmd0 pulse has been received. remark f x : x1 clock f exclk : external main system clock f rh : high-speed ring-osc clock chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 543 26.8.4 communication commands the 78k0/lg2 communicates with the dedi cated flash programmer by using comma nds. the signals sent from the flash programmer to the 78k0/lg2 are called commands, and the commands sent fr om the 78k0/lg2 to the dedicated flash programmer are called response commands. figure 26-17. communication commands command response command 78k0/lg2 dedicated flash programmer pg-fp4 (flash pro4) cxxxxxx bxxxxx axxxx x x x y y y x x x x x x x x x x x x x x x x x x x y y y y statve the flash memory control commands of the 78k0/lg2 are listed in the t able below. all these commands are issued from the programmer and the 78k0/lg2 perform pr ocessing corresponding to the respective commands. table 26-9. flash memory control commands classification command name function verify batch verify command compares the contents of the entire memory with the input data. erase batch erase command erases t he contents of the entire memory. blank check batch blank check command checks the erasure status of the entire memory. high-speed write command writes data by specifying the write address and number of bytes to be written, and executes a verify check. data write successive write command writes data from the address following that of the high-speed write command executed immediately before, and executes a verify check. status read command obtains the operation status oscillation frequency setting command sets the oscillation frequency erase time setting command sets the erase time for batch erase write time setting command sets the write time for writing data baud rate setting command sets the baud rate when uart is used silicon signature command reads the silicon signature information system setting, control reset command escapes from each status the 78k0/lg2 return a response command for the comm and issued by the dedicated flash programmer. the response commands sent from the 78k0/lg2 are listed below. table 26-10. response commands command name function ack acknowledges command/data. nak acknowledges illegal command/data. chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 544 26.9 flash memory programming by self-writing the 78k0/lg2 supports a self-p rogramming function that can be used to rewrite the flash memory via a user program. because this function allows a user application to rewrite the flash memory by using the 78k0/lg2 self- programming library, it can be used to upgrade the program in the field. if an interrupt occurs during self-programming, self -programming can be temporarily stopped and interrupt servicing can be executed. to execute interrupt servicing, restore the normal operation mode after self-programming has been stopped, and execute t he ei instruction. after the self-pr ogramming mode is later restored, self- programming can be resumed. remark for details of the self-programming function and the 78k0/lg2 self-programming library, refer to a separate document to be published (document name: 78k0/kx2 applic ation note, release schedule: pending). cautions 1. the self-programmi ng function cannot be used when th e cpu operates with the subsystem clock. 2. input a high level to the fl md0 pin during self-programming. 3. be sure to execute the di instru ction before starting self-programming. the self-programming function checks the interrupt request flags (if0l, if0h, if1l, and if1h). if an interrupt request is gene rated, self-programming is stopped. 4. self-programming is also st opped by an interrupt request that is not masked even in the di status. to prevent this, mask the interrupt by using the interrupt mask flag registers (mk0l, mk0h, mk1l, and mk1h). 5. self-programming is executed with the high-speed ring-osc clo ck. if the cpu operates with the x1 clock or external main syst em clock, the oscillation stab ilization wait time of the high- speed ring-osc clock elap ses during self-programming. (cautions 6 is listed on the next page.) chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 545 cautions 6. locate the entry program for self-p rogramming in the common area of 0000h to 7fffh. figure 26-18. operation mode and memory map for se lf-programming ( pd78f0397) bank 1 bank 4 bank 3 bank 5 bank 2 normal mode flash memory (common area) 0000h 8000h 7fffh ffffh fb00h faffh c000h bfffh f800h f7ffh e000h dfffh ff00h feffh internal high- speed ram internal expansion ram sfr reserved reserved flash memory control firmware rom disable accessing flash memory (bank 0) bank 1 bank 4 bank 3 bank 5 bank 2 self-programming mode flash memory (common area) 0000h 8000h 7fffh ffffh fb00h faffh c000h bfffh f800h f7ffh e000h dfffh ff00h feffh internal high- speed ram internal expansion ram sfr reserved reserved flash memory control firmware rom disable accessing enable accessing instructions can be fetched from common area and selected bank area. instructions can be fetched from common area and firmware rom. chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 546 the procedure of self-program ming is illustrated below. figure 26-19. self-programming procedure ei execution instruction secure entry ram area execute di instruction flmd0 pin = high level start self-programming flmd0 pin = low level check library return value end of self-programming entry program (user program) library entry program (user program) set parameters to entry ram execute library and access flash memory according to parameter contents no interrupt request interrupt request interrupt servicing self-programming stopped chapter 26 flash memory preliminary user?s manual u17473ej1v0ud 547 26.10 boot swap function the 78k0/lg2 has a boot swap function. even if a momentary power failure occurs for some re ason while the boot area is being rewritten by self- programming and the program in the boot area is lost, the boot swap functi on can execute the program correctly after re-application of power, reset, and start. the boot program area of the 78k0/lg 2 is as follows: 0000h to 0fffh ar e boot cluster 0, and 1000h to 1fffh are boot cluster 1 (fixed in 4 kb units). boot clusters 0 and 1 are swapped during boot swapping. 26.10.1 outline of boot swap function before erasing the boot program area by self-programming, write a new boot program to the block to be swapped, and also set the boot flag note . even if a momentary power failure occurs , the address is swapp ed when the system is reset and started next time. consequently, the above area to be swapped is used as a boot area, and the program is executed correctly. figure 26-20 shows an image of the boot swap function. note the boot flag is controlled by the flash me mory control firmware of the 78k0/lg2. figure 26-20. image of boot swap function (1) if boot swap is not supported user program user program user program boot program xxxxh 0000h user program user program user program erasure in progress xxxxh 0000h user program user program user program undefined data xxxxh 0000h self- programming momentary power failure not restarted 1000h 0fffh 2000h 1fffh 1000h 0fffh 2000h 1fffh 1000h 0fffh 2000h 1fffh (2) if boot swap is supported user program user program xxxxh 0000h user program user program xxxxh 0000h user program user program xxxxh 0000h self- programming momentary power failure started correctly 1000h 0fffh 2000h 1fffh 1000h 0fffh 2000h 1fffh 2000h 1fffh 1000h 0fffh new boot program (boot cluster 1) erasure in progress (boot cluster 0) new boot program (boot cluster 0) undefined data (boot cluster 1) user program (boot cluster 1) boot program (boot cluster 0) preliminary user?s manual u17473ej1v0ud 548 chapter 27 on-chip debug function ( pd78f0397d only) the pd78f0397d uses the v dd , flmd0, reset, x1 (or p31), x2 (or p32), and v ss pins to communicate with the host machine via an in-circuit emulator (qb-78k0mini) for on-chip debugging. whether x1 and p31, or x2 and p32 are used can be selected. caution in the on-chip debug mode, clock is input from the x1 pin. remarks1. the pd78f0397d is the es (engineering sample) version only. 2. for details of the on-chip debug f unction, refer to the separate document qb-78k0mini user?s manual (u17029e) . 27.1 security id control flag and security id the pd78f0397d has a security id control area in 0084h/10 84h of the flash memory and a security id setting area in 0085h to 008eh/1085h to 108eh. set 1084h and 1085h to 108eh to the same values as those for 0084h and 0085h to 008eh, in advance, since 0084h and 0085h to 008eh and 1084h and 1085h to 108e h are switched when the boot swap operation is used during self-programming. figure 27-1. position of security id control area and security id setting area security id control area flash memory 0000h 008eh 0085h 0084h 0 0 ocden0 00 0 ocden1 0 108eh 1085h 1084h security id setting area security id setting area chapter 27 on-chip debug function ( pd78f0397d only) preliminary user?s manual u17473ej1v0ud 549 figure 27-2. format of security id control flag address: 0084h/1084h note 7 6 5 4 3 2 1 0 0 0 0 0 0 0 ocden1 ocden0 ocden1 ocden0 on-chip debug operation control 0 0 operation prohibited 0 1 setting prohibited 1 0 operation enabled. flash memory data is not erased when authentication of the security id has failed. 1 1 operation enabled. flash memory data is erased when authentication of the security id has failed. notes1. be sure to set 0084h to 00h (disabling on-chip debug operation) when using a product that does not have the on-chip debug function ( pd78f0393, 78f0395, or 78f0397). in addition, set 1084h to 00h in advance, since 0084h and 1084h are switched during the boot swap operation. 2. when using the on-chip debug function in a product that has the on-chip debug function ( pd78f0397d), set 0084h to 02h or 03h. in addition, set 1084h to the same value as that for 0084h in advance, since 0084h and 1084h are switched during the boot swap operation. table 27-1. security id code address security id code 0085h to 008eh 1085h to 108eh any id code of 10 bytes preliminary user?s manual u17473ej1v0ud 550 chapter 28 instruction set this chapter lists each instruction set of the 78k0/lg2 in table form. for details of each operation and operation code, refer to the separate document 78k/0 series instructions user?s manual (u12326e) . 28.1 conventions used in operation list 28.1.1 operand identifier s and specification methods operands are written in the ?operand? column of each instruction in ac cordance with the specification method of the instruction operand identifier (refer to the assembler s pecifications for details). when there are two or more methods, select one of them. uppercase letters and the sym bols #, !, $ and [ ] are keywords and must be written as they are. each symbol has the following meaning. ? #: immediate data specification ? !: absolute address specification ? $: relative address specification ? [ ]: indirect address specification in the case of immediate data, describe an appropriate num eric value or a label. when using a label, be sure to write the #, !, $, and [ ] symbols. for operand register identifiers r and rp, either function names (x, a, c, etc.) or absolute names (names in parentheses in the table below, r0, r1, r2, etc.) can be used for specification. table 28-1. operand identifi ers and specification methods identifier specification method r rp sfr sfrp x (r0), a (r1), c (r2), b (r3), e (r4), d (r5), l (r6), h (r7) ax (rp0), bc (rp1), de (rp2), hl (rp3) special function register symbol note special function register symbol (16-bit manipulatable register even addresses only) note saddr saddrp fe20h to ff1fh immediate data or labels fe20h to ff1fh immediate data or labels (even address only) addr16 addr11 addr5 0000h to ffffh immediate data or labels (only even addresses for 16-bit da ta transfer instructions) 0800h to 0fffh immediate data or labels 0040h to 007fh immediate data or labels (even address only) word byte bit 16-bit immediate data or label 8-bit immediate data or label 3-bit immediate data or label rbn rb0 to rb3 note addresses from ffd0h to ffdfh c annot be accessed with these operands. remark for special function register symbols, see table 3-7 special function register list . chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 551 28.1.2 description of operation column a: a register; 8-bit accumulator x: x register b: b register c: c register d: d register e: e register h: h register l: l register ax: ax register pair; 16-bit accumulator bc: bc register pair de: de register pair hl: hl register pair pc: program counter sp: stack pointer psw: program status word cy: carry flag ac: auxiliary carry flag z: zero flag rbs: register bank select flag ie: interrupt request enable flag ( ): memory contents indicated by addre ss or register contents in parentheses x h , x l : higher 8 bits and lower 8 bits of 16-bit register : logical product (and) : logical sum (or) : exclusive logical sum (exclusive or) ?? : inverted data addr16: 16-bit immediate data or label jdisp8: signed 8-bit data (displacement value) 28.1.3 description of flag operation column (blank): not affected 0: cleared to 0 1: set to 1 : set/cleared according to the result r: previously saved value is restored chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 552 28.2 operation list clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy r, #byte 2 4 ? r byte saddr, #byte 3 6 7 (saddr) byte sfr, #byte 3 ? 7 sfr byte a, r note 3 1 2 ? a r r, a note 3 1 2 ? r a a, saddr 2 4 5 a (saddr) saddr, a 2 4 5 (saddr) a a, sfr 2 ? 5 a sfr sfr, a 2 ? 5 sfr a a, !addr16 3 8 9 a (addr16) !addr16, a 3 8 9 (addr16) a psw, #byte 3 ? 7 psw byte a, psw 2 ? 5 a psw psw, a 2 ? 5 psw a a, [de] 1 4 5 a (de) [de], a 1 4 5 (de) a a, [hl] 1 4 5 a (hl) [hl], a 1 4 5 (hl) a a, [hl + byte] 2 8 9 a (hl + byte) [hl + byte], a 2 8 9 (hl + byte) a a, [hl + b] 1 6 7 a (hl + b) [hl + b], a 1 6 7 (hl + b) a a, [hl + c] 1 6 7 a (hl + c) mov [hl + c], a 1 6 7 (hl + c) a a, r note 3 1 2 ? a ? r a, saddr 2 4 6 a ? (saddr) a, sfr 2 ? 6 a ? (sfr) a, !addr16 3 8 10 a ? (addr16) a, [de] 1 4 6 a ? (de) a, [hl] 1 4 6 a ? (hl) a, [hl + byte] 2 8 10 a ? (hl + byte) a, [hl + b] 2 8 10 a ? (hl + b) 8-bit data transfer xch a, [hl + c] 2 8 10 a ? (hl + c) notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed 3. except ?r = a? remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 553 clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy rp, #word 3 6 ? rp word saddrp, #word 4 8 10 (saddrp) word sfrp, #word 4 ? 10 sfrp word ax, saddrp 2 6 8 ax (saddrp) saddrp, ax 2 6 8 (saddrp) ax ax, sfrp 2 ? 8 ax sfrp sfrp, ax 2 ? 8 sfrp ax ax, rp note 3 1 4 ? ax rp rp, ax note 3 1 4 ? rp ax ax, !addr16 3 10 12 ax (addr16) movw !addr16, ax 3 10 12 (addr16) ax 16-bit data transfer xchw ax, rp note 3 1 4 ? ax ? rp a, #byte 2 4 ? a, cy a + byte saddr, #byte 3 6 8 (saddr), cy (saddr) + byte a, r note 4 2 4 ? a, cy a + r r, a 2 4 ? r, cy r + a a, saddr 2 4 5 a, cy a + (saddr) a, !addr16 3 8 9 a, cy a + (addr16) a, [hl] 1 4 5 a, cy a + (hl) a, [hl + byte] 2 8 9 a, cy a + (hl + byte) a, [hl + b] 2 8 9 a, cy a + (hl + b) add a, [hl + c] 2 8 9 a, cy a + (hl + c) a, #byte 2 4 ? a, cy a + byte + cy saddr, #byte 3 6 8 (saddr), cy (saddr) + byte + cy a, r note 4 2 4 ? a, cy a + r + cy r, a 2 4 ? r, cy r + a + cy a, saddr 2 4 5 a, cy a + (saddr) + cy a, !addr16 3 8 9 a, cy a + (addr16) + c a, [hl] 1 4 5 a, cy a + (hl) + cy a, [hl + byte] 2 8 9 a, cy a + (hl + byte) + cy a, [hl + b] 2 8 9 a, cy a + (hl + b) + cy 8-bit operation addc a, [hl + c] 2 8 9 a, cy a + (hl + c) + cy notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed 3. only when rp = bc, de or hl 4. except ?r = a? remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 554 clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy a, #byte 2 4 ? a, cy a ? byte saddr, #byte 3 6 8 (saddr), cy (saddr) ? byte a, r note 3 2 4 ? a, cy a ? r r, a 2 4 ? r, cy r ? a a, saddr 2 4 5 a, cy a ? (saddr) a, !addr16 3 8 9 a, cy a ? (addr16) a, [hl] 1 4 5 a, cy a ? (hl) a, [hl + byte] 2 8 9 a, cy a ? (hl + byte) a, [hl + b] 2 8 9 a, cy a ? (hl + b) sub a, [hl + c] 2 8 9 a, cy a ? (hl + c) a, #byte 2 4 ? a, cy a ? byte ? cy saddr, #byte 3 6 8 (saddr), cy (saddr) ? byte ? cy a, r note 3 2 4 ? a, cy a ? r ? cy r, a 2 4 ? r, cy r ? a ? cy a, saddr 2 4 5 a, cy a ? (saddr) ? cy a, !addr16 3 8 9 a, cy a ? (addr16) ? cy a, [hl] 1 4 5 a, cy a ? (hl) ? cy a, [hl + byte] 2 8 9 a, cy a ? (hl + byte) ? cy a, [hl + b] 2 8 9 a, cy a ? (hl + b) ? cy subc a, [hl + c] 2 8 9 a, cy a ? (hl + c) ? cy a, #byte 2 4 ? a a byte saddr, #byte 3 6 8 (saddr) (saddr) byte a, r note 3 2 4 ? a a r r, a 2 4 ? r r a a, saddr 2 4 5 a a (saddr) a, !addr16 3 8 9 a a (addr16) a, [hl] 1 4 5 a a (hl) a, [hl + byte] 2 8 9 a a (hl + byte) a, [hl + b] 2 8 9 a a (hl + b) 8-bit operation and a, [hl + c] 2 8 9 a a (hl + c) notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed 3. except ?r = a? remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 555 clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy a, #byte 2 4 ? a a byte saddr, #byte 3 6 8 (saddr) (saddr) byte a, r note 3 2 4 ? a a r r, a 2 4 ? r r a a, saddr 2 4 5 a a (saddr) a, !addr16 3 8 9 a a (addr16) a, [hl] 1 4 5 a a (hl) a, [hl + byte] 2 8 9 a a (hl + byte) a, [hl + b] 2 8 9 a a (hl + b) or a, [hl + c] 2 8 9 a a (hl + c) a, #byte 2 4 ? a a byte saddr, #byte 3 6 8 (saddr) (saddr) byte a, r note 3 2 4 ? a a r r, a 2 4 ? r r a a, saddr 2 4 5 a a (saddr) a, !addr16 3 8 9 a a (addr16) a, [hl] 1 4 5 a a (hl) a, [hl + byte] 2 8 9 a a (hl + byte) a, [hl + b] 2 8 9 a a (hl + b) xor a, [hl + c] 2 8 9 a a (hl + c) a, #byte 2 4 ? a ? byte saddr, #byte 3 6 8 (saddr) ? byte a, r note 3 2 4 ? a ? r r, a 2 4 ? r ? a a, saddr 2 4 5 a ? (saddr) a, !addr16 3 8 9 a ? (addr16) a, [hl] 1 4 5 a ? (hl) a, [hl + byte] 2 8 9 a ? (hl + byte) a, [hl + b] 2 8 9 a ? (hl + b) 8-bit operation cmp a, [hl + c] 2 8 9 a ? (hl + c) notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed 3. except ?r = a? remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 556 clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy addw ax, #word 3 6 ? ax, cy ax + word subw ax, #word 3 6 ? ax, cy ax ? word 16-bit operation cmpw ax, #word 3 6 ? ax ? word mulu x 2 16 ? ax a x multiply/ divide divuw c 2 25 ? ax (quotient), c (remainder) ax c r 1 2 ? r r + 1 inc saddr 2 4 6 (saddr) (saddr) + 1 r 1 2 ? r r ? 1 dec saddr 2 4 6 (saddr) (saddr) ? 1 incw rp 1 4 ? rp rp + 1 increment/ decrement decw rp 1 4 ? rp rp ? 1 ror a, 1 1 2 ? (cy, a 7 a 0 , a m ? 1 a m ) 1 time rol a, 1 1 2 ? (cy, a 0 a 7 , a m + 1 a m ) 1 time rorc a, 1 1 2 ? (cy a 0 , a 7 cy, a m ? 1 a m ) 1 time rolc a, 1 1 2 ? (cy a 7 , a 0 cy, a m + 1 a m ) 1 time ror4 [hl] 2 10 12 a 3 ? 0 (hl) 3 ? 0 , (hl) 7 ? 4 a 3 ? 0 , (hl) 3 ? 0 (hl) 7 ? 4 rotate rol4 [hl] 2 10 12 a 3 ? 0 (hl) 7 ? 4 , (hl) 3 ? 0 a 3 ? 0 , (hl) 7 ? 4 (hl) 3 ? 0 adjba 2 4 ? decimal adjust accumulator after addition bcd adjustment adjbs 2 4 ? decimal adjust accumulator after subtract cy, saddr.bit 3 6 7 cy (saddr.bit) cy, sfr.bit 3 ? 7 cy sfr.bit cy, a.bit 2 4 ? cy a.bit cy, psw.bit 3 ? 7 cy psw.bit cy, [hl].bit 2 6 7 cy (hl).bit saddr.bit, cy 3 6 8 (saddr.bit) cy sfr.bit, cy 3 ? 8 sfr.bit cy a.bit, cy 2 4 ? a.bit cy psw.bit, cy 3 ? 8 psw.bit cy bit manipulate mov1 [hl].bit, cy 2 6 8 (hl).bit cy notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 557 clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy cy, saddr.bit 3 6 7 cy cy (saddr.bit) cy, sfr.bit 3 ? 7 cy cy sfr.bit cy, a.bit 2 4 ? cy cy a.bit cy, psw.bit 3 ? 7 cy cy psw.bit and1 cy, [hl].bit 2 6 7 cy cy (hl).bit cy, saddr.bit 3 6 7 cy cy (saddr.bit) cy, sfr.bit 3 ? 7 cy cy sfr.bit cy, a.bit 2 4 ? cy cy a.bit cy, psw.bit 3 ? 7 cy cy psw.bit or1 cy, [hl].bit 2 6 7 cy cy (hl).bit cy, saddr.bit 3 6 7 cy cy (saddr.bit) cy, sfr.bit 3 ? 7 cy cy sfr.bit cy, a.bit 2 4 ? cy cy a.bit cy, psw. bit 3 ? 7 cy cy psw.bit xor1 cy, [hl].bit 2 6 7 cy cy (hl).bit saddr.bit 2 4 6 (saddr.bit) 1 sfr.bit 3 ? 8 sfr.bit 1 a.bit 2 4 ? a.bit 1 psw.bit 2 ? 6 psw.bit 1 set1 [hl].bit 2 6 8 (hl).bit 1 saddr.bit 2 4 6 (saddr.bit) 0 sfr.bit 3 ? 8 sfr.bit 0 a.bit 2 4 ? a.bit 0 psw.bit 2 ? 6 psw.bit 0 clr1 [hl].bit 2 6 8 (hl).bit 0 set1 cy 1 2 ? cy 1 1 clr1 cy 1 2 ? cy 0 0 bit manipulate not1 cy 1 2 ? cy cy notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 558 clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy call !addr16 3 7 ? (sp ? 1) (pc + 3) h , (sp ? 2) (pc + 3) l , pc addr16, sp sp ? 2 callf !addr11 2 5 ? (sp ? 1) (pc + 2) h , (sp ? 2) (pc + 2) l , pc 15 ? 11 00001, pc 10 ? 0 addr11, sp sp ? 2 callt [addr5] 1 6 ? (sp ? 1) (pc + 1) h , (sp ? 2) (pc + 1) l , pc h (00000000, addr5 + 1), pc l (00000000, addr5), sp sp ? 2 brk 1 6 ? (sp ? 1) psw, (sp ? 2) (pc + 1) h , (sp ? 3) (pc + 1) l , pc h (003fh), pc l (003eh), sp sp ? 3, ie 0 ret 1 6 ? pc h (sp + 1), pc l (sp), sp sp + 2 reti 1 6 ? pc h (sp + 1), pc l (sp), psw (sp + 2), sp sp + 3 rrr call/return retb 1 6 ? pc h (sp + 1), pc l (sp), psw (sp + 2), sp sp + 3 rrr psw 1 2 ? (sp ? 1) psw, sp sp ? 1 push rp 1 4 ? (sp ? 1) rp h , (sp ? 2) rp l , sp sp ? 2 psw 1 2 ? psw (sp), sp sp + 1 r r r pop rp 1 4 ? rp h (sp + 1), rp l (sp), sp sp + 2 sp, #word 4 ? 10 sp word sp, ax 2 ? 8 sp ax stack manipulate movw ax, sp 2 ? 8 ax sp !addr16 3 6 ? pc addr16 $addr16 2 6 ? pc pc + 2 + jdisp8 unconditional branch br ax 2 8 ? pch a, pc l x bc $addr16 2 6 ? pc pc + 2 + jdisp8 if cy = 1 bnc $addr16 2 6 ? pc pc + 2 + jdisp8 if cy = 0 bz $addr16 2 6 ? pc pc + 2 + jdisp8 if z = 1 conditional branch bnz $addr16 2 6 ? pc pc + 2 + jdisp8 if z = 0 notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 559 clocks flag instruction group mnemonic operands bytes note 1 note 2 operation zaccy saddr.bit, $addr16 3 8 9 pc pc + 3 + jdisp8 if (saddr.bit) = 1 sfr.bit, $addr16 4 ? 11 pc pc + 4 + jdisp8 if sfr.bit = 1 a.bit, $addr16 3 8 ? pc pc + 3 + jdisp8 if a.bit = 1 psw.bit, $addr16 3 ? 9 pc pc + 3 + jdisp8 if psw.bit = 1 bt [hl].bit, $addr16 3 10 11 pc pc + 3 + jdisp8 if (hl).bit = 1 saddr.bit, $addr16 4 10 11 pc pc + 4 + jdisp8 if (saddr.bit) = 0 sfr.bit, $addr16 4 ? 11 pc pc + 4 + jdisp8 if sfr.bit = 0 a.bit, $addr16 3 8 ? pc pc + 3 + jdisp8 if a.bit = 0 psw.bit, $addr16 4 ? 11 pc pc + 4 + jdisp8 if psw. bit = 0 bf [hl].bit, $addr16 3 10 11 pc pc + 3 + jdisp8 if (hl).bit = 0 saddr.bit, $addr16 4 10 12 pc pc + 4 + jdisp8 if (saddr.bit) = 1 then reset (saddr.bit) sfr.bit, $addr16 4 ? 12 pc pc + 4 + jdisp8 if sfr.bit = 1 then reset sfr.bit a.bit, $addr16 3 8 ? pc pc + 3 + jdisp8 if a.bit = 1 then reset a.bit psw.bit, $addr16 4 ? 12 pc pc + 4 + jdisp8 if psw.bit = 1 then reset psw.bit btclr [hl].bit, $addr16 3 10 12 pc pc + 3 + jdisp8 if (hl).bit = 1 then reset (hl).bit b, $addr16 2 6 ? b b ? 1, then pc pc + 2 + jdisp8 if b 0 c, $addr16 2 6 ? c c ? 1, then pc pc + 2 + jdisp8 if c 0 conditional branch dbnz saddr, $addr16 3 8 10 (saddr) (saddr) ? 1, then pc pc + 3 + jdisp8 if (saddr) 0 sel rbn 2 4 ? rbs1, 0 n nop 1 2 ? no operation ei 2 ? 6 ie 1 (enable interrupt) di 2 ? 6 ie 0 (disable interrupt) halt 2 6 ? set halt mode cpu control stop 2 6 ? set stop mode notes 1. when the internal high-speed ram area is acce ssed or for an instruction with no data access 2. when an area except the internal high-speed ram area is accessed remarks 1. one instruction clock cycle is one cycle of the cpu clock (f cpu ) selected by the processor clock control register (pcc). 2. this clock cycle applies to the internal rom program. chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 560 28.3 instructions listed by addressing type (1) 8-bit instructions mov, xch, add, addc, sub, subc, and, or, xor, cmp, mulu, divuw, inc, dec, ror, rol, rorc, rolc, ror4, rol4, push, pop, dbnz second operand first operand #byte a r note sfr saddr !addr16 psw [de] [hl] [hl + byte] [hl + b] [hl + c] $addr16 1 none a add addc sub subc and or xor cmp mov xch add addc sub subc and or xor cmp mov xch mov xch add addc sub subc and or xor cmp mov xch add addc sub subc and or xor cmp mov mov xch mov xch add addc sub subc and or xor cmp mov xch add addc sub subc and or xor cmp ror rol rorc rolc r mov mov add addc sub subc and or xor cmp inc dec b, c dbnz sfr mov mov saddr mov add addc sub subc and or xor cmp mov dbnz inc dec !addr16 mov psw mov mov push pop [de] mov [hl] mov ror4 rol4 [hl + byte] [hl + b] [hl + c] mov x mulu c divuw note except ?r = a? chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 561 (2) 16-bit instructions movw, xchw, addw, subw, cmpw, push, pop, incw, decw second operand first operand #word ax rp note sfrp saddrp !addr16 sp none ax addw subw cmpw movw xchw movw movw movw movw rp movw movw note incw decw push pop sfrp movw movw saddrp movw movw !addr16 movw sp movw movw note only when rp = bc, de, hl (3) bit manipulation instructions mov1, and1, or1, xor1, set1, clr1, not1, bt, bf, btclr second operand first operand a.bit sfr.bit saddr.bit psw.bit [hl].bit cy $addr16 none a.bit mov1 bt bf btclr set1 clr1 sfr.bit mov1 bt bf btclr set1 clr1 saddr.bit mov1 bt bf btclr set1 clr1 psw.bit mov1 bt bf btclr set1 clr1 [hl].bit mov1 bt bf btclr set1 clr1 cy mov1 and1 or1 xor1 mov1 and1 or1 xor1 mov1 and1 or1 xor1 mov1 and1 or1 xor1 mov1 and1 or1 xor1 set1 clr1 not1 chapter 28 instruction set preliminary user?s manual u17473ej1v0ud 562 (4) call instructions/branch instructions call, callf, callt, br, bc, bnc, bz, bnz, bt, bf, btclr, dbnz second operand first operand ax !addr16 !addr11 [addr5] $addr16 basic instruction br call br callf callt br bc bnc bz bnz compound instruction bt bf btclr dbnz (5) other instructions adjba, adjbs, brk, ret, reti, retb, sel, nop, ei, di, halt, stop preliminary user?s manual u17473ej1v0ud 563 chapter 29 electrical specifications (target) caution these specifications show targ et values of (t), (s), and (r) products, which may change after device evaluation. absolute maximum ratings (t a = 25 c) parameter symbol conditions ratings unit v dd v dd = lv dd ? 0.5 to +6.5 v lv dd v dd = lv dd ? 0.5 to +6.5 v v ss v ss = lv ss ? 0.5 to +0.3 v lv ss v ss = lv ss ? 0.5 to +0.3 v av ref ? 0.5 to v dd + 0.3 note v supply voltage av ss ? 0.5 to +0.3 v v i1 p00 to p06, p10 to p17, p20 to p27, p30 to p33, p70 to p77, p120 to p124, x1, x2, xt1, xt2, reset ? 0.3 to v dd + 0.3 note v input voltage v i2 scl0, sda0 (n-ch open drain) ? 0.3 to +6.5 v v o1 p00 to p06, p10 to p17, p20 to p27, p30 to p33, p70 to p77, p120 to p124, x1, x2, xt1, xt2, reset ? 0.3 to v dd + 0.3 note output voltage v o2 s0 to s39, com0 to com3 ? 0.3 to v lc0 + 0.3 note v analog input voltage v an ani0 to ani7 ? 0.3 to av ref + 0.3 note and ? 0.3 to v dd + 0.3 note v per pin ? 10 ma p00 to p04, p120 ? 25 ma output current, high i oh total of all pins ? 80 ma p05, p06, p10 to p17, p30 to p33, p70 to p77 ? 55 ma per pin 30 ma p00 to p04, p120 60 ma output current, low i ol total of all pins 200 ma p05, p06, p10 to p17, p30 to p33, p70 to p77, scl0, sda0 140 ma in normal operation mode operating ambient temperature t a in flash memory programming mode ? 40 to +85 c storage temperature t stg ? 40 to +150 c note must be 6.5 v or lower. caution product quality may suffer if the absolute maximum rating is exceeded even momentarily for any parameter. that is, the absolute maximum ratings are rated values at which the product is on the verge of suffering physical damage, and therefore the product must be used under conditions that ensure that the absolute m aximum ratings are not exceeded. remark unless specified otherwise, the characteristics of alter nate-function pins are the same as those of port pins. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 564 x1 oscillator characteristics (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, v ss = lv ss = av ss = 0 v) resonator recommended circuit parameter conditions min. typ. max. unit 4.0 v v dd 5.5 v 1.0 20.0 2.7 v v dd < 4.0 v 1.0 10.0 ceramic resonator c1 x2 x1 v ss c2 x1 clock oscillation frequency (f x ) note 1.8 v v dd < 2.7 v 1.0 5.0 mhz 4.0 v v dd 5.5 v 1.0 20.0 2.7 v v dd < 4.0 v 1.0 10.0 crystal resonator c1 x2 x1 c2 v ss x1 clock oscillation frequency (f x ) note 1.8 v v dd < 2.7 v 1.0 5.0 mhz note indicates only oscillator characteristics. refer to ac characteristics for instruction execution time. cautions 1. when using the x1 oscillator, wire as follo ws in the area enclosed by the broken lines in the above figures to avoid an adverse effect from wiring capacitance. ? keep the wiring leng th as short as possible. do not cross the wiring wi th the other signal lines. do not route the wiring near a signal line th rough which a high fluctuating current flows. always make the ground point of the o scillator capacitor th e same potential as v ss . do not ground the capacitor to a ground pattern through which a high current flows. do not fetch signals from the oscillator. 2. since the cpu is started by the high-speed ring-osc after a r eset release, check the x1 clock oscillation stabilization time usi ng the oscillation stabilization ti me counter status register (ostc) by the user. determine the oscillation stabilization ti me of the ostc register and oscillation stabilization time select register (ost s) after sufficiently eval uating the oscillation stabilization time with the resonator to be used. remark for the resonator selection and oscillator const ant, customers are requested to either evaluate the oscillation themselves or apply to the resonator manufacturer for evaluation. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 565 ring-osc oscillator characteristics (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, v ss = lv ss = av ss = 0 v) resonator parameter conditions min. typ. max. unit 2.7 v v dd 5.5 v 7.6 note 2 8.0 note 2 8.4 note 2 mhz 8 mhz ring-osc oscillator high-speed ring-osc clock oscillation frequency (f rh ) note 1 1.8 v v dd < 2.7 v 7.6 note 2 8.0 note 2 10 note 2 mhz 2.7 v v dd 5.5 v 216 240 264 khz 240 khz ring-osc oscillator low-speed ring-osc clock oscillation frequency (f rl ) 1.8 v v dd < 2.7 v 120 240 264 khz notes 1. indicates only oscillator characteristics. refer to ac characteristics for instruction execution time. 2. this is the frequency when rsts (bit 7 of the ri ng-osc mode register (rcm)) = 1. it is 5 mhz (typ.) when rsts = 0. xt1 oscillator characteristics (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, v ss = lv ss = av ss = 0 v) resonator recommended circuit parameter conditions min. typ. max. unit crystal resonator xt1 xt2 c4 c3 rd v ss xt1 clock oscillation frequency (f xt ) note 32 32.768 35 khz note indicates only oscillator characteristics. refer to ac characteristics for instruction execution time. cautions 1. when using the xt1 oscillator, wire as follows in the area enclosed by the br oken lines in the above figure to avoid an adverse effect from wiring capacitance. ? keep the wiring length as short as possible. ? do not cross the wiring with the other signal lines. ? do not route the wiring near a signal line th rough which a high fluctuating current flows. ? always make the ground point of the osci llator capacitor the same potential as v ss . ? do not ground the capacitor to a ground pa ttern through which a high current flows. ? do not fetch signals from the oscillator. 2. the xt1 oscillator is desi gned as a low-amplitude circuit for reducing power consumption, and is more prone to malfunction due to noise than th e x1 oscillator. partic ular care is therefore required with the wiring method when the xt1 clock is used. remark for the resonator selection and oscillator const ant, customers are requested to either evaluate the oscillation themselves or apply to the resonator manufacturer for evaluation. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 566 dc characteristics (1/4) (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, av ref v dd , v ss = lv ss = av ss = 0 v) parameter symbol conditions min. typ. max. unit 4.0 v v dd 5.5 v ? 3.0 ma 2.7 v v dd < 4.0 v ? 2.5 ma per pin for p00 to p06, p10 to p17, p30 to p33, p70 to p77, p120 1.8 v v dd < 2.7 v ? 1.0 ma 4.0 v v dd 5.5 v ? 20.0 ma 2.7 v v dd < 4.0 v ? 10.0 ma total note of p00 to p04, p120 1.8 v v dd < 2.7 v ? 5.0 ma 4.0 v v dd 5.5 v ? 30.0 ma 2.7 v v dd < 4.0 v ? 19.0 ma total note of p05, p06, p10 to p17, p30 to p33, p70 to p77 1.8 v v dd < 2.7 v ? 10.0 ma 4.0 v v dd 5.5 v ? 50.0 ma 2.7 v v dd < 4.0 v ? 29.0 ma i oh1 total note of all pins 1.8 v v dd < 2.7 v ? 15.0 ma i oh2 per pin for p20 to p27 av ref = v dd ? 0.1 ma output current, high i oh3 per pin for p121 to p124 ? 0.1 ma 4.0 v v dd 5.5 v 8.5 ma 2.7 v v dd < 4.0 v 5.0 ma per pin for p00 to p06, p10 to p17, p30 to p33, p70 to p77, p120 1.8 v v dd < 2.7 v 2.0 ma 4.0 v v dd 5.5 v 15.0 ma 2.7 v v dd < 4.0 v 5.0 ma per pin for scl0, sda0 1.8 v v dd < 2.7 v 2.0 ma 4.0 v v dd 5.5 v 20.0 ma 2.7 v v dd < 4.0 v 15.0 ma total note of p00 to p04, p120 1.8 v v dd < 2.7 v 9.0 ma 4.0 v v dd 5.5 v 45.0 ma 2.7 v v dd < 4.0 v 35.0 ma total note of p05, p06, p10 to p17, p30 to p33, p70 to p77 1.8 v v dd < 2.7 v 20.0 ma 4.0 v v dd 5.5 v 65.0 ma 2.7 v v dd < 4.0 v 50.0 ma i ol1 total note of all pins 1.8 v v dd < 2.7 v 29.0 ma i ol2 per pin for p20 to p27 av ref = v dd 0.4 ma output current, low i ol3 per pin for p121 to p124 0.4 ma note specifications under c ondition that duty = 70% remark unless specified otherwise, the characteristics of alter nate-function pins are the same as those of port pins. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 567 dc characteristics (2/4) (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, av ref v dd , v ss = lv ss = av ss = 0 v) parameter symbol conditions min. typ. max. unit v ih1 p02, p12, p13, p15, p121 to p124, scl0, sda0 0.7v dd v dd v v ih2 p00, p01, p03 to p06, p10, p11, p14, p16, p17, p30 to p33, p70 to p77, p120, reset 0.8v dd v dd v input voltage, high ( pd78f0395, 78f0397, 78f0397d) v ih3 p20 to p27 av ref = v dd 0.7av ref av ref v v ih1 p02 to p06, p12, p13, p15, p121 to p124, scl0, sda0 0.7v dd v dd v v ih2 p00, p01, p10, p11, p14, p16, p17, p30 to p33, p70 to p77, p120, reset 0.8v dd v dd v input voltage, high ( pd78f0393) v ih3 p20 to p27 av ref = v dd 0.7av ref av ref v v il1 p02, p12, p13, p15, p121 to p124, scl0, sda0 0 0.3v dd v v il2 p00, p01, p03 to p06, p10, p11, p14, p16, p17, p30 to p33, p70 to p77, p120, reset 0 0.2v dd v input voltage, low ( pd78f0395, 78f0397, 78f0397d) v il3 p20 to p27 av ref = v dd 0 0.3av ref v v il1 p02 to p06, p12, p13, p15, p121 to p124, scl0, sda0 0 0.3v dd v v il2 p00, p01, p10, p11, p14, p16, p17, p30 to p33, p70 to p77, p120, reset 0 0.2v dd v input voltage, low ( pd78f0393) v il3 p20 to p27 av ref = v dd 0 0.3av ref v 4.0 v v dd 5.5 v, i oh1 = ? 3.0 ma v dd ? 0.7 v 2.7 v v dd < 4.0 v, i oh1 = ? 2.5 ma v dd ? 0.5 v v oh1 p00 to p06, p10 to p17, p30 to p33, p70 to p77, p120 1.8 v v dd < 2.7 v, i oh1 = ? 1.0 ma v dd ? 0.5 v p20 to p27 av ref = v dd , i oh2 = ? 0.1 ma v dd ? 0.5 v output voltage, high v oh2 p121 to p124 i oh2 = ? 0.1 ma v dd ? 0.5 v remark unless specified otherwise, the characteristics of alter nate-function pins are the same as those of port pins. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 568 dc characteristics (3/4) (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, av ref v dd , v ss = lv ss = av ss = 0 v) parameter symbol conditions min. typ. max. unit 4.0 v v dd 5.5 v, i ol1 = 8.5 ma 0.7 v 2.7 v v dd < 4.0 v, i ol1 = 5.0 ma 0.7 v 1.8 v v dd < 2.7 v, i ol1 = 2.0 ma 0.5 v v ol1 p00 to p06, p10 to p17, p30 to p33, p70 to p77, p120 1.8 v v dd < 2.7 v, i ol1 = 0.5 ma 0.4 v p20 to p27 av ref = v dd , i ol2 = 0.4 ma 0.4 v v ol2 p121 to p124 i ol2 = 0.4 ma 0.4 v 4.0 v v dd 5.5 v, i ol3 = 15 ma 2.0 v 4.0 v v dd 5.5 v, i ol3 = 5.0 ma 0.4 v 2.7 v v dd < 4.0 v, i ol1 = 3.0 ma 0.4 v output voltage, low v ol3 scl0, sda0 1.8 v v dd < 2.7 v, i ol1 = 2.0 ma 0.4 v i lih1 p00 to p06, p10 to p17, p30 to p33, p70 to p77, p120 v i = v dd 1 a i lih2 p20 to p27 v i = av ref = v dd 1 a i/o port mode 1 a input leakage current, high i lih3 p121 to 124 (x1, x2, xt1, xt2) v i = v dd osc mode 20 a i lil1 p00 to p06, p10 to p17, p30 to p33, p70 to p77, p120 v i = v ss ? 1 a i lil2 p20 to p27 v i = v ss , av ref = v dd ? 1 a i/o port mode ? 1 a input leakage current, low i lil3 p121 to 124 (x1, x2, xt1, xt2) v i = v ss osc mode ? 20 a pull-up resistor r u v i = v dd 10 20 100 k ? v il in normal operation mode 0 0.2v dd v flmd0 supply voltage v ih in self-programming mode 0.8v dd v dd v remark unless specified otherwise, the characteristics of alter nate-function pins are the same as those of port pins. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 569 dc characteristics (4/4) (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, av ref v dd , v ss = lv ss = av ss = 0 v) parameter symbol conditions min. typ. max. unit f xh = 20 mhz note 2 , v dd = 5.0 v 4.7 5.8 ma f xh = 10 mhz note 2, 3 , v dd = 5.0 v 2.5 3.5 ma f xh = 10 mhz note 2, 3 , v dd = 3.0 v 2.1 3.1 ma f xh = 5 mhz note 2, 3 , v dd = 3.0 v 1.5 2.2 ma f xh = 5 mhz note 2, 3 , v dd = 2.0 v 1.2 1.8 ma f rh = 8 mhz, v dd = 5.0 v 1.9 2.7 ma i dd1 note 1 operation mode f sub = 32.768 khz note 2, 4 , v dd = 5.0 v 17 30 a f xh = 20 mhz note 2 , v dd = 5.0 v 2.2 2.6 ma f xh = 10 mhz note 2, 3 , v dd = 5.0 v 1.0 1.2 ma f xh = 5 mhz note 2, 3 , v dd = 3.0 v 0.55 0.65 ma f rh = 8 mhz, v dd = 5.0 v 0.6 0.65 ma i dd2 note 5 halt mode f sub = 32.768 khz note 2, 4 , v dd = 5.0 v 3.5 20 a supply current i dd3 note 5 stop mode v dd = 5.0 v 1 20 a a/d converter operating current i adc note 6 when a/d converter is operating 2.3 v av ref v dd , during conversion at maximum speed 0.86 1.9 ma watchdog timer operating current i wdt note 7 when watchdog timer is operating during 240 khz low-speed ring-osc operation 5 10 a lvi operating current i lvi note 8 when lvi is operating 9 35 a lv dd = 5.0 v 150 330 a i lcd1 note 9 when lcd (including booster circuit) is stopped and iic is operating lv dd = 3.0 v 75 160 a lv dd = 5.0 v 2 36 a i lcd2 note 9 when only lcd booster circuit is operating and iic is in standby status lv dd = 3.0 v 1.5 16 a lv dd = 5.0 v 5 45 a i lcd3 note 9 when lcd display is operating and iic is in standby status lv dd = 3.0 v 4 22 a lv dd = 5.0 v 0.1 30 a lcd operating current i lcd4 note 9 when lcd (including booster circuit) is stopped and iic is in standby status lv dd = 3.0 v 0.05 10 a notes 1. total current flowing through the internal power supply (v dd ). peripheral operation current is included (however, the current that flows through the pu ll-up resistors of ports, a/d converter, and lcd controller/driver is not included). 2. square-wave input 3. when amph (bit 0 of clock operation mode select register (oscctl)) = 0. 4. when the main system clock is stopped. 5. total current flowing through the internal power supply (v dd ). peripheral operation current is included (however, the current that flows th rough the pull-up resistors of ports, a/d converter, watchdog timer, lvi circuit, and lcd controller/driver is not included). 6. this includes only the current that flows through t he a/d converter. when the a/d converter is operating in operation mode or halt mode, the current value of the 78k 0/lg2 is obtained by adding i adc to i dd1 or i dd2 . 7. this includes only the current that flows throu gh the watchdog timer. when the watchdog timer is operating in halt mode or stop mode, the current value of the 78k0/lg2 is obtained by adding i wdt to i dd2 or i dd3 . 8. this includes only the current that flows through the lvi circuit. when the lvi circuit is operating in halt mode or stop mode, the current value of the 78k0/lg2 is obtained by adding i lvi to i dd2 or i dd3 . 9. this includes only the current that flows through the lcd controller/driver. the current value of the 78k0/lg2 is obtained by addi ng the lcd operating current (i lcd1 , i lcd2 , i lcd3 , or i lcd4 ) to the supply current (i dd1 , i dd2 , or i dd3 ). chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 570 remarks 1. f xh : high-speed system clock frequency (x1 clock oscillation frequency or external main system clock frequency) 2. f rh : high-speed ring-osc clock oscillation frequency 3. f sub : subsystem clock frequency (xt1 clock oscillation frequency or external subsystem clock frequency) ac characteristics (1) basic operation (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, v ss = lv ss = av ss = 0 v) parameter symbol conditions min. typ. max. unit 4.0 v v dd 5.5 v 0.1 32 s 2.7 v v dd < 4.0 v 0.2 32 s high-speed system clock (f xh ) 1.8 v v dd < 2.7 v 0.4 32 s 2.7 v v dd 5.5 v 0.25 4 s main system clock (f xp ) operation high-speed ring- osc clock (f rh ) 1.8 v v dd < 2.7 v 0.5 4 s instruction cycle (minimum instruction execution time) t cy subsystem clock (f sub ) operation 114 122 125 s 4.0 v v dd 5.5 v 1.0 20.0 mhz 2.7 v v dd < 4.0 v 1.0 10.0 mhz external main system clock frequency f exclk 1.8 v v dd < 2.7 v 1.0 5.0 mhz external main system clock input high-level width, low-level width t exclkh , t exclkl (1/f exclk 1/2) ? 1 ns external subsystem clock frequency f exclks 32 32.768 35 khz external subsystem clock input high-level width, low-level width t exclksh , t exclksl (1/f exclks 1/2) ? 5 ns 4.0 v v dd 5.5 v 2/f sam + 0.1 note 2 s ti000, ti010, ti001 note 1 , ti011 note 1 input high-level width, low-level width t tih0 , t til0 2.7 v v dd < 4.0 v 2/f sam + 0.2 note 2 s 4.0 v v dd 5.5 v 10 mhz 2.7 v v dd < 4.0 v 10 mhz ti50, ti51 input frequency f ti5 1.8 v v dd < 2.7 v 5 mhz 4.0 v v dd 5.5 v 50 ns 2.7 v v dd < 4.0 v 50 ns ti50, ti51 input high-level width, low-level width t tih5 , t til5 1.8 v v dd < 2.7 v 100 ns interrupt input high-level width, low-level width t inth , t intl 1 s key return input low-level width t kr 250 ns reset low-level width t rsl 10 s notes 1. pd78f0395, 78f0397, and 78f0397d only. 2. selection of f sam = f prs , f prs /4, f prs /256, or f prs , f prs /16, f prs /64 is possible using bits 0 and 1 (prm000, prm001 or prm010, prm011) of prescaler mode regi sters 00 and 01 (prm00, prm01). note that when selecting the ti000 or ti001 valid edge as the count clock, f sam = f prs. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 571 t cy vs. v dd (main system clock operation) 5.0 1.0 2.0 0.4 0.2 0.1 0 10 1.0 2.0 3.0 4.0 5.0 6.0 5.5 2.7 100 0.01 1.8 32 guaranteed operation range cycle time t cy [ s] supply voltage v dd [v] ac timing test points (excluding ex ternal main system clock a nd external subsystem clock) 0.8v dd 0.2v dd test points 0.8v dd 0.2v dd external main system clock timing , external subsystem clock timing exclk 0.7v dd (min.) 0.3v dd (max.) 1/f exclk t exclkl t exclkh 1/f exclks t exclksl t exclksh exclks 0.7v dd (min.) 0.3v dd (max.) chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 572 ti timing ti000, ti010, ti001 note , ti011 note t til0 t tih0 ti50, ti51 1/f ti5 t til5 t tih5 interrupt request input timing intp0 to intp5 t intl t inth key interrupt input timing kr0 to kr7 t kr reset input timing reset t rsl note pd78f0395, 78f0397, and 78f0397d only. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 573 (2) serial interface (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, v ss = lv ss = av ss = 0 v) (a) uart6 (dedicated baud rate generator output) parameter symbol conditions min. typ. max. unit transfer rate 312.5 kbps (b) uart0 (dedicated baud rate generator output) parameter symbol conditions min. typ. max. unit transfer rate 312.5 kbps (c) iic0 standard mode high-speed mode parameter symbol min. max. min. max. unit scl0 clock frequency f scl 0 100 0 400 khz setup time of start/restart condition note 1 t su:sta 4.8 ? 0.7 ? s hold time t hd:sta 4.1 ? 0.7 ? s hold time when scl0 = ?l? t low 5.0 ? 1.25 ? s hold time when scl0 = ?h? t high 5.0 ? 1.25 ? s data setup time (reception) t su:dat 0 ? 0 ? s data hold time (transmission) note 2 t hd:dat 0.47 4.0 0.23 1.00 s notes 1. the first clock pulse is generated after this per iod when the start/restart condition is detected. 2. the maximum value (max.) of t hd:dat is during normal transfer and a wa it state is inserted in the ack (acknowledge) timing. (d) csi1n (master mode, sck1n... internal clock output) parameter symbol conditions min. typ. max. unit 4.0 v v dd 5.5 v 100 ns 2.7 v v dd < 4.0 v 200 ns sck1n cycle time t kcy1 1.8 v v dd < 2.7 v 400 ns sck1n high-/low-level width t kh1 , t kl1 t kcy1 /2 ? 10 note 1 ns si1n setup time (to sck1n ) t sik1 30 ns si1n hold time (from sck1n ) t ksi1 30 ns delay time from sck1n to so1n output t kso1 c = 50 pf note 2 40 ns notes 1. this value is when high-speed system clock (f xh ) is used. 2. c is the load capacitance of the sck1n and so1n output lines. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 574 (e) csi1n (slave mode, sck1n... external clock input) parameter symbol conditions min. typ. max. unit sck1n cycle time t kcy2 400 ns sck1n high-/low-level width t kh2 , t kl2 t kcy2 /2 ns si1n setup time (to sck1n ) t sik2 80 ns si1n hold time (from sck1n ) t ksi2 50 ns delay time from sck1n to so1n output t kso2 c = 50 pf note 120 ns note c is the load capacitance of the so1n output line. remark n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d serial transfer timing 3-wire serial i/o mode: si1n so1n t kcym t klm t khm t sikm t ksim input data t ksom output data sck1n remark m = 1, 2 n = 0: pd78f0393 n = 0, 1: pd78f0395, 78f0397, 78f0397d chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 575 a/d converter characteristics (t a = ? 40 to +85 c, 1.8 v v dd = lv dd 5.5 v, 2.3 v av ref v dd , v ss = lv ss = av ss = 0 v) parameter symbol conditions min. typ. max. unit resolution r es 10 bit 4.0 v av ref 5.5 v 0.4 %fsr 2.7 v av ref < 4.0 v 0.6 %fsr overall error notes 1, 2 a inl 2.3 v av ref < 2.7 v 1.2 %fsr 4.0 v av ref 5.5 v 6.1 36.7 s 2.7 v av ref < 4.0 v 12.2 36.7 s conversion time t conv 2.3 v av ref < 2.7 v 27 66.6 s 4.0 v av ref 5.5 v 0.4 %fsr 2.7 v av ref < 4.0 v 0.6 %fsr zero-scale error notes 1, 2 e zs 2.3 v av ref < 2.7 v 0.6 %fsr 4.0 v av ref 5.5 v 0.4 %fsr 2.7 v av ref < 4.0 v 0.6 %fsr full-scale error notes 1, 2 e fs 2.3 v av ref < 2.7 v 0.6 %fsr 4.0 v av ref 5.5 v 2.5 lsb 2.7 v av ref < 4.0 v 4.5 lsb integral non-linearity error note 1 i le 2.3 v av ref < 2.7 v 6.5 lsb 4.0 v av ref 5.5 v 1.5 lsb 2.7 v av ref < 4.0 v 2.0 lsb differential non-linearity error note 1 d le 2.3 v av ref < 2.7 v 2.0 lsb analog input voltage v ain av ss av ref v notes 1. excludes quantization error ( 1/2 lsb). 2. this value is indicated as a ratio (%fsr) to the full-scale value. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 576 lcd characteristics (t a = ? 40 to +85 c, 2.0 v lv dd 5.5 v) (1) resistance division method (a) static display mode (2.0 v lv dd 5.5 v) parameter symbol conditions min. typ. max. unit lcd drive voltage v lcd 2.0 lv dd v lcd divider resistor note 1 r lcd 60 100 150 k ? lcd output resistor note 2 (common) r odc 40 k ? lcd output resistor note 2 (segment) r ods 200 k ? pull-up resistor note 3 between lv dd and v lc0 r lu lv dd = 5.0 v, v lc0 = 3.0 v 7.3 k ? (b) 1/3 bias method (2.5 v lv dd 5.5 v) parameter symbol conditions min. typ. max. unit lcd drive voltage v lcd 2.5 lv dd v lcd divider resistor note 1 r lcd 60 100 150 k ? lcd output resistor note 2 (common) r odc 40 k ? lcd output resistor note 2 (segment) r ods 200 k ? pull-up resistor note 3 between lv dd and v lc0 r lu lv dd = 5.0 v, v lc0 = 3.0 v 7.3 k ? (c) 1/2 bias method (2.7 v lv dd 5.5 v) parameter symbol conditions min. typ. max. unit lcd drive voltage v lcd 2.7 lv dd v lcd divider resistor note 1 r lcd 60 100 150 k ? lcd output resistor note 2 (common) r odc 40 k ? lcd output resistor note 2 (segment) r ods 200 k ? pull-up resistor note 3 between lv dd and v lc0 r lu lv dd = 5.0 v, v lc0 = 3.0 v 7.3 k ? notes 1. when internal resistors are connected only. 2. the output resistor is a resist or connected between one of the v lc0 , v lc1 , v lc2 and v ss pins, and either of the seg and com pins. 3. disconnected when lcd mode is entered by setting the lcd mode setting register (lcdmd). remark the figures in the above table indicate the values when a 0.47 f capacitor is connected between v lc0 to v lc2 and gnd. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 577 (2) internal voltage boosting method (1.8 v lv dd 5.5 v) parameter symbol conditions min. typ. max. unit ctsel1 = 0, ctsel0 = 1 1.35 1.43 1.51 v ctsel1 = 0, ctsel0 = 0 1.42 1.50 1.58 v ctsel1 = 1, ctsel0 = 1 1.48 1.57 1.66 v gain = 0 ctsel1 = 1, ctsel0 = 0 1.54 note 3 1.63 note 3 1.72 note 3 v ctsel1 = 0, ctsel0 = 1 0.87 0.93 1.00 v ctsel1 = 0, ctsel0 = 0 0.94 1.00 1.06 v ctsel1 = 1, ctsel0 = 1 1.00 1.07 1.14 v lcd output voltage variation range v lcd2 c1 to c4 note 1 = 0.47 f note 2 gain = 1 ctsel1 = 1, ctsel0 = 0 1.06 1.13 1.20 v doubler output voltage v lcd1 c1 to c4 note 1 = 0.47 f note 2 2 v lcd2 v tripler output voltage v lcd0 c1 to c4 note 1 = 0.47 f note 2 3 v lcd2 v 4.5 v lv dd 5.5 v 4 s gain = 0 1.8 v lv dd < 4.5 v 0.5 s voltage boost wait time note 4 t vawait gain = 1 0.5 s lcd output resistor note 5 (common) r odc 40 k ? lcd output resistor note 5 (segment) r ods 200 k ? notes 1. this is a capacitor that is connected between voltage pins used to drive the lcd. c1: a capacitor connected between caph and capl c2: a capacitor connected between v lc0 and gnd c3: a capacitor connected between v lc1 and gnd c4: a capacitor connected between v lc2 and gnd 2. when the frame frequency is 128 hz or lower, t he seg and com pins are left open, and (lcdon, scoc, vlcon) = 111b. 3. when operating voltage range is 2.0 v lv dd < 5.5 v. 4. this is the wait time from when voltage boosti ng is started (vlcon = 1) until display is enabled (lcdon = 1). 5. the output resistor is a resist or connected between one of the v lc0 , v lc1 , v lc2 and v ss pins, and either of the seg and com pins. chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 578 poc circuit characteristics (t a = ? 40 to +85 c, v ss = lv ss = 0 v) parameter symbol conditions min. typ. max. unit detection voltage v poc 1.44 1.59 1.74 v slope when power supply voltage rises t pth slope of variation when v dd is rising from 0 v to v poc 0.5 v/ms minimum pulse width t pw 50 s poc circuit timing supply voltage (v dd ) time detection voltage (min.) detection voltage (typ.) detection voltage (max.) t pth t pw power supply voltage rise time (t a = ? 40 to +85 c, v ss = lv ss = 0 v) parameter symbol conditions min. typ. max. unit maximum time for rising up to 1.8 v (v dd (min.)) (v dd : 0 v 1.8 v) t pup1 when reset input is not used 3.6 ms maximum time for rising up to 1.8 v (v dd (min.)) (reset input release v dd : 1.8 v) t pup2 when reset input is used 1.9 ms timing of power supply voltage rise time when reset input is not used 1.8 v t pup1 supply voltage (v dd ) time when reset input is used 1.8 v t pup2 v poc reset pin supply voltage (v dd ) time chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 579 lvi circuit characteristics (t a = ? 40 to +85 c, v poc v dd = lv dd 5.5 v, v ss = lv ss = 0 v) parameter symbol conditions min. typ. max. unit v lvi0 4.14 4.24 4.34 v v lvi1 3.99 4.09 4.19 v v lvi2 3.83 3.93 4.03 v v lvi3 3.68 3.78 3.88 v v lvi4 3.52 3.62 3.72 v v lvi5 3.37 3.47 3.57 v v lvi6 3.22 3.32 3.42 v v lvi7 3.06 3.16 3.26 v v lvi8 2.91 3.01 3.11 v v lvi9 2.75 2.85 2.95 v v lvi10 2.60 2.70 2.80 v v lvi11 2.45 2.55 2.65 v v lvi12 2.29 2.39 2.49 v v lvi13 2.14 2.24 2.34 v v lvi14 1.98 2.08 2.18 v supply voltage level v lvi15 1.83 1.93 2.03 v detection voltage external input pin note 1 exlvi exlvi < v dd , 1.8 v v dd 5.5 v 1.21 v minimum pulse width t lw 50 s operation stabilization wait time note 2 t lwait 10 s notes 1. the exlvi/p120/intp0 pin is used. 2. time required from setting bit 7 (lvion) of the low- voltage detection register (lvim) to 1 to operation stabilization. remark v lvi(n ? 1) > v lvin : n = 1 to 15 lvi circuit timing supply voltage (v dd ) time detection voltage (min.) detection voltage (typ.) detection voltage (max.) t lw t lwait lvion 1 chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 580 data memory stop mode low supply vo ltage data retention characteristics (t a = ? 40 to +85 c) parameter symbol conditions min. typ. max. unit data retention supply voltage v dddr 1.44 note 5.5 v note the value depends on the poc detec tion voltage. when the voltage drop s, the data is retained until a poc reset is effected, but data is not re tained when a poc reset is effected. v dd stop instruction execution standby release signal (interrupt request) stop mode data retention mode v dddr operation mode chapter 29 electrical specifications (target) preliminary user?s manual u17473ej1v0ud 581 flash memory programming characteristics (t a = ? 40 to +85 c, 2.7 v v dd = lv dd 5.5 v, v ss = lv ss = av ss = 0 v) (1) basic characteristics parameter symbol conditions min. typ. max. unit v dd supply current i dd f xp = 10 mhz (typ.), 20 mhz (max.) 4.5 11.0 ma in all-block units t eraca 20 200 ms erase time note 1 in block units t erasa 20 200 ms write time t wrwa t.b.d. t.b.d. s number of rewrites per chip c erwr data is retained for up to 10 years. 1 erase + 1 write after erase = 1 rewrite note 2 100 times notes 1. the prewrite time before erasure and the erase verify time (writeback time) are not included. 2. when a product is first written after shipment, ?erase write? and ?write only? are both taken as one rewrite. remark f xp : main system clock oscillation frequency (2) serial write operation characteristics parameter symbol conditions min. typ. max. unit time from reset to flmd0 count start t rfcf 4.1 17.1 ms count execution time t count 10.8 13.2 ms flmd0 counter high-/low-level width t ch /t cl t c 0.45 s flmd0 counter rise/fall time t r /t f 12.5 s remark these values may change after evaluation. serial write operation reset flmd0 v dd 0 v v dd 0 v t rfcf t cl t f t r t count t ch t c preliminary user?s manual u17473ej1v0ud 582 chapter 30 package drawings 100-pin plastic lqfp (fine pitch) (14x14) note each lead centerline is located within 0.08 mm of its true position (t.p.) at maximum material condition. item millimeters a b d g 16.00 0.20 14.00 0.20 0.50 (t.p.) 1.00 j 16.00 0.20 k c 14.00 0.20 i 0.08 1.00 0.20 l 0.50 0.20 f 1.00 n p q 0.08 1.40 0.05 0.10 0.05 s100gc-50-8eu, 8ea-2 s 1.60 max. h 0.22 + 0.05 ? 0.04 m 0.17 + 0.03 ? 0.07 r3 + 7 ? 3 1 25 26 50 100 76 75 51 s s n j detail of lead end c d a b r k m l p i s q g f m h chapter 30 package drawings preliminary user?s manual u17473ej1v0ud 583 100-pin plastic qfp (14x20) hi j detail of lead end m c d a b q r k m l p s s n g f note each lead centerline is located within 0.13 mm of its true position (t.p.) at maximum material condition. item millimeters a b d g 23.2 0.2 20.0 0.2 0.13 0.575 i 17.2 0.2 j c 14.0 0.2 0.65 (t.p.) k 1.6 0.2 l 0.8 0.2 f 0.825 s100gf-65-jbt-2 n p q 0.10 2.7 0.1 0.125 0.075 s 3.0 max. m 0.17 + 0.06 ? 0.05 r3 + 7 ? 3 h 0.32 + 0.08 ? 0.07 80 81 51 50 30 31 100 1 s preliminary user?s manual u17473ej1v0ud 584 chapter 31 cautions for wait 31.1 cautions for wait this product has two internal system buses. one is a cpu bus and the other is a peripheral bus t hat interfaces with the low-speed peripheral hardware. because the clock of the cpu bus and the clock of the peripheral bus are asynchronous, unexpected illegal data may be passed if an access to the cpu conflict s with an access to the peripheral hardware. when accessing the peripheral hardware that may cause a conflict, therefore, the cpu repeatedly executes processing, until the correct data is passed. as a result, the cpu does not start the next instruction processing but waits. if this happens, the number of execution clocks of an instruction incr eases by the number of wait clocks (f or the number of wait clocks, see table 31- 1 ). this must be noted when r eal-time processing is performed. chapter 31 cautions for wait preliminary user?s manual u17473ej1v0ud 585 31.2 peripheral hardware that generates wait table 31-1 lists the register s that issue a wait request when accessed by the cpu, and the number of cpu wait clocks. table 31-1. registers that generate wait and number of cpu wait clocks peripheral hardware register access number of wait clocks serial interface uart0 asis0 read 1 clock (fixed) serial interface uart6 asis6 read 1 clock (fixed) serial interface iic0 iics0 read 1 clock (fixed) adm write ads write adpc write adcr read 1 to 5 clocks (when f ad = f prs /2 is selected) 1 to 7 clocks (when f ad = f prs /3 is selected) 1 to 9 clocks (when f ad = f prs /4 is selected) 2 to 13 clocks (when f ad = f prs /6 is selected) 2 to 17 clocks (when f ad = f prs /8 is selected) 2 to 25 clocks (when f ad = f prs /12 is selected) a/d converter the above number of clocks is when the same source clock is selected for f cpu and f prs . the number of wait clocks can be calculated by the following expression and under the following conditions. preliminary user?s manual u17473ej1v0ud 586 appendix a development tools the following development t ools are available for the development of systems that employ the 78k0/lg2. figure a-1 shows the developm ent tool configuration. ? support for pc98-nx series unless otherwise specified, pr oducts supported by ibm pc/at tm compatibles are compatible with pc98-nx series computers. when using pc98-nx series computer s, refer to the explanation for ibm pc/at compatibles. ? windows tm unless otherwise specified, ?windows? means the following oss. ? windows 98 ? windows nt tm ? windows 2000 ? windows xp appendix a development tools preliminary user?s manual u17473ej1v0ud 587 figure a-1. development tool configuration (1/2) (1) when using the in-circuit emulator qb-78k0lx2 language processing software ? assembler package ? c compiler package ? device file ? c library source file note 1 debugging software ? integrated debugger host machine (pc or ews) in-circuit emulator note 3 emulation probe target system flash programmer flash memory write adapter flash memory ? software package ? project manager software package flash memory write environment control software (windows only) note 2 power supply unit usb interface cable notes 1. the c library source file is not included in the software package. 2. the project manager pm+ is in cluded in the assembler package. the pm+ is only used for windows. 3. in-circuit emulator qb-78k0lx2 is supplied with in tegrated debugger id78k0-qb, simple flash memory programmer pg-fpl3, power supply unit, and usb inte rface cable. any other products are sold separately. appendix a development tools preliminary user?s manual u17473ej1v0ud 588 figure a-1. development tool configuration (2/2) (2) when using the on-chip debug emulator qb-78k0mini on-chip debug emulator note 3 connection cable language processing software ? assembler package ? c compiler package ? device file ? c library source file note 1 debugging software ? integrated debugger host machine (pc or ews) usb interface cable target connector target system flash programmer flash memory writing adapter flash memory ? software package ? project manager (windows only) note 2 software package flash memory writing environment control software notes 1. the c library source file is not included in the software package. 2. the project manager pm+ is in cluded in the assembler package. pm+ is only used for windows. 3. on-chip debug emulator qb-78k0mini is supp lied with integrated debugger id78k0-qb, usb interface cable, and connection cable. any other products are sold separately. appendix a development tools preliminary user?s manual u17473ej1v0ud 589 a.1 software package development tools (software) common to the 78k/0 series are combined in this package. sp78k0 78k/0 series software package part number: s sp78k0 remark in the part number differs depending on the host machine and os used. s sp78k0 host machine os supply medium ab17 windows (japanese version) bb17 pc-9800 series, ibm pc/at compatibles windows (english version) cd-rom a.2 language processing software this assembler converts programs written in mnemonics into object codes executable with a microcontroller. this assembler is also provided with functi ons capable of automatically creating symbol tables and branch instruction optimization. this assembler should be used in combi nation with a device file (df780397) (sold separately). appendix a development tools preliminary user?s manual u17473ej1v0ud 590 remark in the part number differs depending on the host machine and os used. s ra78k0 s cc78k0 s cc78k0-l host machine os supply medium ab17 windows (japanese version) bb17 pc-9800 series, ibm pc/at compatibles windows (english version) 3p17 hp9000 series 700 tm hp-ux tm (rel. 10.10) 3k17 sparcstation tm sunos tm (rel. 4.1.4) solaris tm (rel. 2.5.1) cd-rom s df780397 host machine os supply medium ab13 windows (japanese version) bb13 pc-9800 series, ibm pc/at compatibles windows (english version) 3.5-inch 2hd fd a.3 control software pm+ project manager this is control software designed to enable e fficient user program development in the windows environment. all operations used in development of a user program, such as starting the editor, building, and starting the debugger, can be performed from the project manager. appendix a development tools preliminary user?s manual u17473ej1v0ud 591 a.5 debugging tools (hardware) a.5.1 when using in-circu it emulator qb-78k0lx2 qb-78k0lx2 notes 1, 2 in-circuit emulator this in-circuit emulator serves to debug har dware and software when developing application systems using the 78k0/lx2. it corresponds to the integrated debugger (id78k0-qb). this emulator should be used in combination with a power supply unit and emulation probe, and the usb is used to connect this em ulator to the host machine. qb-144-ca-01 check pin adapter this check pin adapter is used in waveform monitoring using the oscilloscope, etc. qb-144-ep-01s emulation probe this emulation probe is flexible type and used to connect the in-circuit emulator and target system. qb-100gc-ea-03t, qb-100gf-ea-03t exchange adapter this exchange adapter is used to perform pin conver sion from the in-circuit emulator to target connector. ? qb-100gc-ea-03t: 100-pin pl astic lqfp (gc-8eu type) ? qb-100gf-ea-03t: 100-pin plastic qfp (gf-jbt type) qb-100gc-ys-01t, qb-100gf-ys-01t space adapter this space adapter is used to adjust the height bet ween the target system and in-circuit emulator. ? qb-100gc-ys-01t: 100-pin pl astic lqfp (gc-8eu type) ? qb-100gf-ys-01t: 100-pin plastic qfp (gf-jbt type) qb-100gc-yq-01t, qb-100gf-yq-01t yq connector this yq connector is used to connect the target connector and exchange adapter. ? qb-100gc-yq-01t: 100-pin pl astic lqfp (gc-8eu type) ? qb-100gf-yq-01t: 100-pin plastic qfp (gf-jbt type) qb-100gc-hq-01t, qb-100gf-hq-01t mount adapter this mount adapter is used to mount the target device with socket. ? qb-100gc-hq-01t: 100-pin pl astic lqfp (gc-8eu type) ? qb-100gf-hq-01t: 100-pin plastic qfp (gf-jbt type) qb-100gc-nq-01t, qb-100gf-nq-01t target connector this target connector is used to mount on the target system. ? qb-100gc-nq-01t: 100-pin pl astic lqfp (gc-8eu type) ? qb-100gf-nq-01t: 100-pin plastic qfp (gf-jbt type) notes 1. the qb-78k0lx2 is supplied wit h integrated debugger id78k0-qb, simple flash memory programmer pg-fpl3, power supply unit, and usb interface cable. 2. under development remark the packed contents differ depending on the part number, as follows. packed contents part number in-circuit emulator emulation probe exchange adapter yq connector target connector qb-78k0lx2-zzz none qb-78k0lx2-t100gc qb-100gc-ea-03t qb-100gc-yq-01t qb-100gc-nq-01t qb-78k0lx2-t100gf qb-78k0lx2 qb-144-ep-01s qb-100gf-ea-03t qb-100gf-yq-01t qb-100gf-nq-01t appendix a development tools preliminary user?s manual u17473ej1v0ud 592 a.5.2 when using on-chip debug emulator qb-78k0mini qb-78k0mini note on-chip debug emulator the on-chip debug emulator serves to debug hardware and software when developing application systems using the 78k0/lx2. it supports the integrated debugger (id78k0- qb) supplied with the qb-78k0mini. this emulator uses a connection cable and a usb interface cable that is used to connect the host machine. target connector specific ations 10-pin general-purpose connector (2.54 mm pitch) note the qb-78k0mini is supplied with integrated debugger id78k0-qb, usb interface cable, and connection cable. a.6 debugging tools (software) this debugger supports the in-circuit emulator s for the 78k/0 series. the id78k0-qb is windows-based software. it has improved c-compatible debugging functions and can display the results of tracing with the source program using an integrating window function that associates the source program, disassemble display, and memory di splay with the trace result. it should be used in combination with the device file (sold separately). id78k0-qb integrated debugger part number: s id78k0-qb remark in the part number differs depending on the host machine and os used. s id78k0-qb host machine os supply medium ab17 windows (japanese version) bb17 pc-9800 series, ibm pc/at compatibles windows (english version) cd-rom preliminary user?s manual u17473ej1v0ud 593 appendix b register index b.1 register index (in al phabetical order with respect to register names) [a] a/d converter mode register (adm).............................................................................................. ..............................250 a/d port configuratio n register (adpc) ......................................................................................... ......................102, 256 analog input channel specification re gister (ads) .............................................................................. ........................255 asynchronous serial interface control register 6 (asi cl6)...................................................................... ....................303 asynchronous serial interface operat ion mode regist er 0 (a sim0) ................................................................ .............273 asynchronous serial interface operat ion mode regist er 6 (a sim6) ................................................................ .............297 asynchronous serial interface recepti on error status regi ster 0 ( asis0)........................................................ .............275 asynchronous serial interface recepti on error status regi ster 6 ( asis6)........................................................ .............299 asynchronous serial interface transmi ssion status regi ster 6 ( asif6) ........................................................... .............300 [b] bank select r egister (bank) .................................................................................................... ...................................529 baud rate generator contro l register 0 (brg c0)................................................................................. ........................276 baud rate generator contro l register 6 (brg c6)................................................................................. ........................302 [c] capture/compare contro l register 00 (crc0 0).................................................................................... ........................151 capture/compare contro l register 01 (crc0 1).................................................................................... ........................151 clock operation mode select register (oscctl) .................................................................................. ......................109 clock output selectio n register (cks) .......................................................................................... .......................244, 428 clock selection regi ster 6 (c ksr6)............................................................................................. ................................301 [e] 8-bit a/d conversion resu lt register (adcrh) ................................................................................... ..........................254 8-bit timer compare re gister 50 (cr50)......................................................................................... ..............................189 8-bit timer compare re gister 51 (cr51)......................................................................................... ..............................189 8-bit timer coun ter 50 (t m50).................................................................................................. ....................................188 8-bit timer coun ter 51 (t m51).................................................................................................. ....................................188 8-bit timer h carrier cont rol register 1 (tmc yc1).............................................................................. ..........................212 8-bit timer h compare register 00 (cmp00) ...................................................................................... ..........................207 8-bit timer h compare register 01 (cmp01) ...................................................................................... ..........................207 8-bit timer h compare register 10 (cmp10) ...................................................................................... ..........................207 8-bit timer h compare register 11 (cmp11) ...................................................................................... ..........................207 8-bit timer h mode re gister 0 (tmhmd0)......................................................................................... ...........................208 8-bit timer h mode re gister 1 (tmhmd1)......................................................................................... ...........................208 8-bit timer mode contro l register 50 (tmc 50) ................................................................................... ..........................192 8-bit timer mode contro l register 51 (tmc 51) ................................................................................... ..........................192 external interrupt falling edg e enable regist er (egn).......................................................................... ........................473 external interrupt rising e dge enable regist er (egp)........................................................................... ........................473 [i] iic clock selection re gister 0 (iiccl0)........................................................................................ .................................362 appendix b register index preliminary user?s manual u17473ej1v0ud 594 iic control regist er 0 ( iicc0) ................................................................................................. ......................................353 iic flag register 0 (iicf0).................................................................................................... .........................................361 iic function expansion re gister 0 (iicx0) ...................................................................................... ..............................363 iic shift regist er 0 ( iic0) .................................................................................................... ..........................................350 iic status regist er 0 ( iics0).................................................................................................. .......................................358 input switch contro l register (isc) ............................................................................................ ...................................305 internal expansion ram size switching regi ster (ixs)........................................................................... ......................530 internal memory size s witching regist er (ims).................................................................................. ...........................528 interrupt mask flag re gister 0h (mk0h)......................................................................................... ..............................471 interrupt mask flag re gister 0l (mk0l) ......................................................................................... ...............................471 interrupt mask flag re gister 1h (mk1h)......................................................................................... ..............................471 interrupt mask flag re gister 1l (mk1l) ......................................................................................... ...............................471 interrupt request flag register 0h (if0h) ...................................................................................... ...............................469 interrupt request flag register 0l (if 0l)...................................................................................... .................................469 interrupt request flag register 1h (if1h) ...................................................................................... ...............................469 interrupt request flag register 1l (if 1l)...................................................................................... .................................469 [k] key return mode re gister (krm) ................................................................................................. ................................483 [l] lcd clock control register (lcdc) .............................................................................................. ................................426 lcd display mode re gister (lcdm) ............................................................................................... .............................425 lcd mode setting re gister (lcdmd) .............................................................................................. ............................424 lcd voltage boost contro l register 0 (vlcg0) ................................................................................... .........................427 low-voltage detection level selection regi ster (l vis).......................................................................... ........................513 low-voltage detecti on register (lvim).......................................................................................... ...............................512 [m] main clock mode register (mcm) ................................................................................................. ...............................115 main osc control register (moc) ................................................................................................ ...............................114 multiplication/division data r egister a0 (md a0h, md a0l) ........................................................................ ..................456 multiplication/division dat a register b0 (mdb0) ................................................................................ ...........................457 multiplier/divider contro l register 0 (dm uc0).................................................................................. .............................458 [o] oscillation stabilization time c ounter status r egister (ostc).................................................................. .............116, 485 oscillation stabilization time select regi ster (osts).......................................................................... ..................117, 486 [p] port mode regist er 0 (p m0) ..................................................................................................... ......................99, 158, 335 port mode regist er 1 (p m1) ...................................................................................................99 , 194, 212, 277, 305, 335 port mode regist er 2 (p m2) ..................................................................................................... ..............................99, 257 port mode regist er 3 (p m3) ..................................................................................................... ..............................99, 194 port mode regist er 6 (p m6) ..................................................................................................... ....................................365 port mode regist er 7 (p m7) ..................................................................................................... ......................................99 port mode regist er 12 (p m12) ................................................................................................... ............................99, 514 port mode regist er 14 (p m14) ................................................................................................... ..........................246, 429 appendix b register index preliminary user?s manual u17473ej1v0ud 595 port regist er 0 (p0)........................................................................................................... ...........................................100 port regist er 1 (p1)........................................................................................................... ...........................................100 port regist er 2 (p2)........................................................................................................... ...........................................100 port regist er 3 (p3)........................................................................................................... ...........................................100 port regist er 7 (p7)........................................................................................................... ...........................................100 port register 12 (p12) ......................................................................................................... .........................................100 port register 13 (p13) ......................................................................................................... .........................................429 prescaler mode regi ster 00 (prm00)............................................................................................. .............................155 prescaler mode regi ster 01 (prm01)............................................................................................. .............................155 priority specification fl ag register 0h (p r0h) ................................................................................. .............................472 priority specification fl ag register 0l (p r0l) ................................................................................. ..............................472 priority specification fl ag register 1h (p r1h) ................................................................................. .............................472 priority specification fl ag register 1l (p r1l) ................................................................................. ..............................472 processor clock cont rol regist er (pcc) ......................................................................................... ..............................111 pull-up resistor opti on register 0 (pu0) ....................................................................................... ................................101 pull-up resistor opti on register 1 (pu1) ....................................................................................... ................................101 pull-up resistor opti on register 3 (pu3) ....................................................................................... ................................101 pull-up resistor opti on register 7 (pu7) ....................................................................................... ................................101 pull-up resistor opti on register 12 (pu 12) ..................................................................................... ..............................101 [r] receive buffer regi ster 0 (rxb0) ............................................................................................... .................................272 receive buffer regi ster 6 (rxb6) ............................................................................................... .................................296 remainder data regi ster 0 (sdr0)............................................................................................... ...............................456 reset control flag register (resf) ............................................................................................. .................................505 ring-osc mode r egister (rcm) ................................................................................................... ..............................113 [s] serial clock selection register 10 (csic10).................................................................................... .............................333 serial clock selection register 11 (csic11).................................................................................... .............................333 serial i/o shift regi ster 10 (sio10) ........................................................................................... ...................................330 serial i/o shift regi ster 11 (sio11) ........................................................................................... ...................................330 serial operation mode register 10 (csim 10)..................................................................................... ..........................331 serial operation mode register 11 (csim 11)..................................................................................... ..........................331 16-bit timer capture/compar e register 000 (c r000) .............................................................................. ......................145 16-bit timer capture/compar e register 001 (c r001) .............................................................................. ......................145 16-bit timer capture/compar e register 010 (c r010) .............................................................................. ......................147 16-bit timer capture/compar e register 011 (c r011) .............................................................................. ......................147 16-bit timer count er 00 (tm00)................................................................................................. ...................................145 16-bit timer count er 01 (tm01)................................................................................................. ...................................145 16-bit timer mode contro l register 00 (tmc 00) .................................................................................. .........................148 16-bit timer mode contro l register 01 (tmc 01) .................................................................................. .........................148 16-bit timer output cont rol register 00 (t oc00)................................................................................ ...........................152 16-bit timer output cont rol register 01 (t oc01)................................................................................ ...........................152 slave address regi ster 0 (sva0)................................................................................................ .................................350 appendix b register index preliminary user?s manual u17473ej1v0ud 596 [t] 10-bit a/d conversion resu lt register (adcr)................................................................................... ...........................253 timer clock selection register 50 (tcl50)...................................................................................... .............................190 timer clock selection register 51 (tcl51)...................................................................................... .............................190 transmit buffer regi ster 10 (s otb10) ........................................................................................... ..............................330 transmit buffer regi ster 11 (s otb11) ........................................................................................... ..............................330 transmit buffer regi ster 6 (txb6).............................................................................................. ..................................296 transmit shift regi ster 0 (txs0) ............................................................................................... ...................................272 [w] watch timer operation mode register (wtm) ...................................................................................... ........................231 watchdog timer enable register (wdte).......................................................................................... ...........................238 appendix b register index preliminary user?s manual u17473ej1v0ud 597 b.2 register index (in al phabetical order with respect to register symbol) [a] adcr: 10-bit a/d conver sion result regist er .................................................................................... ...................253 adcrh: 8-bit a/d conver sion result register .................................................................................... .....................254 adm: a/d converte r mode re gister ............................................................................................... ....................250 adpc: a/d port config uration r egist er.......................................................................................... ...............102, 256 ads: analog input channel specific ation re gister ............................................................................... ..............255 asicl6: asynchronous serial in terface control register 6....................................................................... ...............303 asif6: asynchronous serial interface transmission status register 6............................................................ ......300 asim0: asynchronous serial interf ace operation mode register 0................................................................. .......273 asim6: asynchronous serial interf ace operation mode register 6................................................................. .......297 asis0: asynchronous serial interface re ception error stat us regist er 0......................................................... ......275 asis6: asynchronous serial interface re ception error stat us regist er 6......................................................... ......299 [b] bank: bank sele ct regi ster..................................................................................................... ............................529 brgc0: baud rate generato r control r egister 0.................................................................................. ...................276 brgc6: baud rate generato r control r egister 6.................................................................................. ...................302 [c] cks: clock output se lection re gister ........................................................................................... .............244, 428 cksr6: clock select ion register 6 .............................................................................................. ..........................301 cmp00: 8-bit timer h compare regi ster 00....................................................................................... .....................207 cmp01: 8-bit timer h compare regi ster 01....................................................................................... .....................207 cmp10: 8-bit timer h compare regi ster 10....................................................................................... .....................207 cmp11: 8-bit timer h compare regi ster 11....................................................................................... .....................207 cr000: 16-bit timer capture/ compare regi ster 000............................................................................... ................145 cr001: 16-bit timer capture/ compare regi ster 001............................................................................... ................145 cr010: 16-bit timer capture/ compare regi ster 010............................................................................... ................147 cr011: 16-bit timer capture/ compare regi ster 011............................................................................... ................147 cr50: 8-bit timer co mpare regi ster 50 .......................................................................................... .....................189 cr51: 8-bit timer co mpare regi ster 51 .......................................................................................... .....................189 crc00: capture/compare control regi ster 00 ..................................................................................... ..................151 crc01: capture/compare control regi ster 01 ..................................................................................... ..................151 csic10: serial clock se lection regi ster 10..................................................................................... ........................333 csic11: serial clock se lection regi ster 11..................................................................................... ........................333 csim10: serial operat ion mode regi ster 10 ...................................................................................... .....................331 csim11: serial operat ion mode regi ster 11 ...................................................................................... .....................331 [d] dmuc0: multiplier/divider control re gister 0................................................................................... ........................458 [e] egn: external interrupt falling edge enabl e regi ster ........................................................................... ..............473 egp: external interrupt rising edge enabl e regi ster............................................................................ ..............473 appendix b register index preliminary user?s manual u17473ej1v0ud 598 [i] if0h: interrupt reques t flag regi ster 0h ....................................................................................... ......................469 if0l: interrupt reques t flag regi ster 0l ....................................................................................... ......................469 if1h: interrupt reques t flag regi ster 1h ....................................................................................... ......................469 if1l: interrupt reques t flag regi ster 1l ....................................................................................... ......................469 iic0: iic shift register 0 ..................................................................................................... ...............................350 iicc0: iic contro l register 0 .................................................................................................. ..............................353 iiccl0: iic clock sele ction regi ster 0......................................................................................... ...........................362 iicf0: iic flag register 0 ..................................................................................................... ................................361 iics0: iic status register 0 ................................................................................................... ..............................358 iicx0: iic function ex pansion regi ster 0 ....................................................................................... ......................363 ims: internal memory si ze switchin g regi ster................................................................................... ................528 isc: input switch control r egist er............................................................................................. ........................305 ixs: internal expansion ram size switchin g regi ster ............................................................................ ..........530 [k] krm: key return mode re gister .................................................................................................. .......................483 [l] lcdc: lcd clock co ntrol r egister ............................................................................................... ........................426 lcdm: lcd displa y mode re gister ................................................................................................ ......................425 lcdmd: lcd mode setting re gister............................................................................................... ........................424 lvim: low-voltage de tection re gister........................................................................................... ......................512 lvis: low-voltage detection level selecti on regi ster ........................................................................... ..............513 [m] mcm: main clo ck mode re gister.................................................................................................. .......................115 mda0h: multiplication/div ision data r egister a0................................................................................ .....................456 mda0l: multiplication/div ision data r egister a0................................................................................ .....................456 mdb0: multiplication/div ision data r egister b0................................................................................. ....................457 mk0h: interrupt mask flag regist er 0h .......................................................................................... ......................471 mk0l: interrupt mask flag regist er 0l .......................................................................................... .......................471 mk1h: interrupt mask flag regist er 1h .......................................................................................... ......................471 mk1l: interrupt mask flag regist er 1l .......................................................................................... .......................471 moc: main osc c ontrol r egister ................................................................................................. ......................114 [o] oscctl: clock operation mode select regist er ................................................................................... ...................109 ostc: oscillation stabilization ti me counter stat us regi ster ................................................................... .....116, 485 osts: oscillation stabilizati on time select register ........................................................................... ..........117, 486 [p] p0: port r egister 0 ............................................................................................................ ..............................100 p1: port r egister 1 ............................................................................................................ ..............................100 p2: port r egister 2 ............................................................................................................ ..............................100 p3: port r egister 3 ............................................................................................................ ..............................100 p7: port r egister 7 ............................................................................................................ ..............................100 p12: port r egister 12 .......................................................................................................... ..............................100 appendix b register index preliminary user?s manual u17473ej1v0ud 599 p13: port r egister 13.......................................................................................................... ..............................429 pcc: processor cloc k control register .......................................................................................... ....................111 pm0: port mode register 0...................................................................................................... ............ 99, 158, 335 pm1: port mode regist er 1.......................................................................................... 99, 194, 212 , 277, 305, 335 pm2: port mode register 2...................................................................................................... ....................99, 257 pm3: port mode register 3...................................................................................................... ....................99, 194 pm6: port mode register 6...................................................................................................... ..........................365 pm7: port mode register 7...................................................................................................... ............................99 pm12: port mode register 12.................................................................................................... ....................99, 514 pm14: port mode register 14.................................................................................................... ..................246, 429 pr0h: priority specificat ion flag r egister 0h .................................................................................. .....................472 pr0l: priority specificat ion flag r egister 0l.................................................................................. ......................472 pr1h: priority specificat ion flag r egister 1h .................................................................................. .....................472 pr1l: priority specificat ion flag r egister 1l.................................................................................. ......................472 prm00: prescaler m ode register 00 .............................................................................................. .......................155 prm01: prescaler m ode register 01 .............................................................................................. .......................155 pu0: pull-up resistor option regi ster 0........................................................................................ ......................101 pu1: pull-up resistor option regi ster 1........................................................................................ ......................101 pu3: pull-up resistor option regi ster 3........................................................................................ ......................101 pu7: pull-up resistor option regi ster 7........................................................................................ ......................101 pu12: pull-up resistor option regi ster 12...................................................................................... ......................101 [r] rcm: ring-osc m ode register .................................................................................................... .....................113 resf: reset contro l flag re gister .............................................................................................. .........................505 rxb0: receive buffe r regist er 0 ................................................................................................ .........................272 rxb6: receive buffe r regist er 6 ................................................................................................ .........................296 [s] sdr0: remainder dat a regist er 0................................................................................................ .......................456 sio10: serial i/o sh ift register 10............................................................................................ ............................330 sio11: serial i/o sh ift register 11............................................................................................ ............................330 sotb10: transmit bu ffer regist er 10 ............................................................................................ ..........................330 sotb11: transmit bu ffer regist er 11 ............................................................................................ ..........................330 sva0: slave addre ss regist er 0................................................................................................. .........................350 [t] tcl50: timer clock sele ction regi ster 50....................................................................................... ......................190 tcl51: timer clock sele ction regi ster 51....................................................................................... ......................190 tm00: 16-bit time r counter 00 .................................................................................................. ..........................145 tm01: 16-bit time r counter 01 .................................................................................................. ..........................145 tm50: 8-bit time r counte r 50 ................................................................................................... ...........................188 tm51: 8-bit time r counte r 51 ................................................................................................... ...........................188 tmc00: 16-bit timer mode control regi ster 00................................................................................... ....................148 tmc01: 16-bit timer mode control regi ster 01................................................................................... ....................148 tmc50: 8-bit timer mode control re gister 50.................................................................................... .....................192 tmc51: 8-bit timer mode control re gister 51.................................................................................... .....................192 appendix b register index preliminary user?s manual u17473ej1v0ud 600 tmcyc1: 8-bit timer h carri er control r egister 1 ............................................................................... .......................212 tmhmd0: 8-bit timer h mode regi ster 0 .......................................................................................... .........................208 tmhmd1: 8-bit timer h mode regi ster 1 .......................................................................................... .........................208 toc00: 16-bit timer output control re gister 00 ................................................................................. .....................152 toc01: 16-bit timer output control re gister 01 ................................................................................. .....................152 txb6: transmit buffe r register 6 ............................................................................................... .........................296 txs0: transmit shi ft register 0 ................................................................................................ ...........................272 [v] vlcg0: lcd voltage boos t control re gister 0 .................................................................................... ...................427 [w] wdte: watchdog timer enable re gister........................................................................................... ....................238 wtm: watch timer oper ation mode regist er....................................................................................... ................231 |
Price & Availability of UPD78F0393GFT2-JBT-A
![]() |
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |