![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
user?s manual all information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change by renesas electronics corp. without notice. please review the latest information published by renesas electronics corp. through various m eans, including the renesas electronics corp. website (http://www.renesas.com). 78k0r/lx3 user?s manual: hardware rev.5.01 jun 2011 16 16-bit single-chip microcontrollers www.renesas.com
notice 1. all information included in this document is current as of th e date this document is issued. such information, however, is subject to change without any prior notice. before purchasing or using any renesas electronics products listed herein, please confirm the latest product information with a renesas electronics sales office. also, please pay regular and careful attention to additional and different information to be disclosed by renesas electronics such as that disclosed through our website. 2. renesas electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property ri ghts of third parties by or arising from the use of renesas electronics products or technical information described in this document . no license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property right s of renesas electronics or others. 3. you should not alter, modify, copy, or otherwise misappropriate any renesas electronics product, whether in whole or in part . 4. descriptions of circuits, software and other related information in this document are provided only to illustrate the operat ion of semiconductor products and application examples. you are fully responsible for the incorporation of these circuits, software, and information in the design of your equipment. renesas electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits, software, or information. 5. when exporting the products or technology described in this document, you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations. you should not use renesas electronics products or the technology de scribed in this document for any purpose re lating to military applications or use by the military, including but not limited to the development of weapons of mass destruction. renesas electronics products and technology may not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. 6. renesas electronics has used reasonable care in preparing the information included in this document, but renesas electronics does not warrant that such information is error free. renesas electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or om issions from the information included herein. 7. renesas electronics products are classified according to the following three quality grades: ?standard?, ?high quality?, an d ?specific?. the recommended applications for each renesas electronics product depends on the product?s quality grade, as indicated below. you must check the quality grade of each renesas electronics product before using it in a particular application. you may not use any renesas electronics product for any application categorized as ?specific? without the prior written consent of renesas electronics. further, you may not use any renesas electronics product for any application for which it is not intended without the prior written consent of renesas electronics. renesas electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any renesas electronics product for a n application categorized as ?specific? or for which the product is not intended where you have failed to obtain the prior writte n consent of renesas electronics. the quality grade of each renesas electronics product is ?standard? unless otherwise expressly specified in a renesas electronics data sheets or data books, etc. ?standard?: computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic equipment; and industrial robots. ?high quality?: transportation equipment (automobiles, trains, ship s, etc.); traffic control systems; anti-disaster systems; an ti- crime systems; safety equipment; and medical equipment not specifically designed for life support. ?specific?: aircraft; aerospace equipment; submersible repeaters; nuclear reactor control systems; medical equipment or systems for life support (e.g. artificial life support devices or systems), surgical implantations, or healthcare intervention (e.g. excision, etc.), and any other applications or purposes that pose a direct threat to human life. 8. you should use the renesas electronics products described in this document within the range specified by renesas electronics , especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. renesas electronics shall have no liability for malfunctions o r damages arising out of the use of renesas electronics products beyond such specified ranges. 9. although renesas electronics endeavors to improve the quality and reliability of its products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. fur ther, renesas electronics products are not subject to radiation resistance design. please be sure to implement safety measures to guard them against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a renesas electronics product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. because the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or system manufactured by you. 10. please contact a renesas electronics sales office for details as to environmental matters such as the environmental compatibility of each renesas electronics product. please use re nesas electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of c ontrolled substances, including without limitation, the eu rohs directive. renesas electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations. 11. this document may not be reproduced or duplicated, in any fo rm, in whole or in part, without prior written consent of renes as electronics. 12. please contact a renesas electronics sales office if you have any questions regarding the information contained in this document or renesas electronics products, or if you have any other inquiries. (note 1) ?renesas electronics? as used in this document means renesas electronics corporation and also includes its majority- owned subsidiaries. (note 2) ?renesas electronics product(s)? means any product developed or manufactured by or for renesas electronics. notes for cmos devices (1) 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 vil (max) and vih (min) due to noise, et c., 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 vil (max) and vih (min). (2) handling of unused input pins: unconnected cm os device inputs can be cause of malfunction. if an input pin is unconnected, it is possible that an in ternal input level may be generated due to noise, etc., causing malfunction. cmos devices behave different ly 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 vdd or gnd via a resist or 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. (3) precaution against esd: a strong electric fi eld, when exposed to a mos device, can cause destruction of the gate oxide and ultimately degrade t he device operation. steps must be taken to stop generation of static elec tricity as much as possible, and quickly dissipate it when it has occurred. environmental control must be adequat e. when it is dry, a humidifier should be used. it is recommended to avoid using insulators that easily build up static electricity. semi conductor devices must be stored and transported in an anti-static container, static shielding bag or conducti ve material. all test and measurement tools including work benches and floors should be gr ounded. the operator should be grounded using a wrist strap. semiconductor devices must not be touc hed with bare hands. similar precautions need to be taken for pw boards with mounted semiconductor devices. (4) status before initialization: power-on does not necessarily define the in itial status of a mos device. immediately after the power source is turn ed on, devices with reset functions have not yet been initialized. hence, power-on does not guarantee output pin levels, i/o setti ngs or contents of registers. a device is not initialized un til the reset signal is received. a re set operation must be executed immediately after power-on for devices with reset functions. (5) 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 po wer supply off, as a rule, switch o ff the external power supply and then the internal power supply. use of the reverse powe r 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 sp ecifications governing the device. (6) 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 re sults from input of such a signal or i/o pull-up power supply may cause malfunction and the abnormal cu rrent that passes in the device at this time may cause degradation of internal elem ents. input of signals during th e power off state must be judged separately for each device and according to re lated specifications governing the device. how to use this manual readers this manual is intended for user engineer s who wish to understand the functions of the 78k0r/lx3 microcontrollers and design and develop application systems and programs for these devices. the target products are as follows. ? 78k0r/lf3: pd78f1500a, 78f1501a, 78f150 2a, 78f1510a, 78f1512a ? 78k0r/lg3: pd78f1503a, 78f1504a, 78f150 5a, 78f1513a, 78f1515a ? 78k0r/lh3: pd78f1506a, 78f1507a, 78f150 8a, 78f1516a, 78f1518a purpose this manual is intended to give users an u nderstanding of the functions described in the organization below. organization the manual for the 78k0r/lx3 microcontrollers is separated into two parts: this manual and the instructions edition (common to the 78k0r microcontroller series). 78k0r/lx3 preliminary user?s manual (this manual) 78k0r microcontrollers user?s manual instructions ? pin functions ? internal block functions ? interrupts ? other on-chip peripheral functions ? electrical specifications ? cpu functions ? instruction set ? explanation of each instruction how to read this manual it is assumed that the readers of this m anual 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 . the mark ? 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 publ ication may include preliminary versions. however, preliminary versions are not marked as such. documents related to devices document name document no. 78k0r/lx3 user?s manual hardware this manual 78k0r microcontrollers instructions user?s manual r01us0029e documents related to development tools (software) (user?s manuals) document name document no. operation u18549e cc78k0r ver. 2.00 c compiler language u18548e operation u18547e ra78k0r ver. 1.20 assembler package language u18546e operation u18601e sm+ system simulator user open interface u18212e pm+ ver. 6.30 u18416e id78k0r-qb ver. 3.20 integrated debugger operation u17839e documents related to development tools (hardware) (user?s manuals) document name document no. qb-78k0rlx3 in-circuit emulator u19336e qb-mini2 on-chip debug emulator with programming function u18371e documents related to flash memo ry programming (u ser?s manuals) document name document no. pg-fp5 flash memory programmer r20ut0008e qb-programmer programmi ng gui operation u18527e caution the related documents listed above are subject to change without notice. be sure to use the latest version of each document when designing. other documents document name document no. renesas microcomputer general catalog r01cs0001e 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 mount manual? website (http://www.renesas.com/prod/package/manual/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. all trademarks and registered trademarks ar e the property of their respective owners. eeprom is a trademark of rene sas electronics corporation. windows is a registered trademark or trademark of microsof t corporation in the united states and/or other countries. superflash is a registered trademark 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. contents chapter 1 outline........................................................................................................... .................... 1 1.1 features.................................................................................................................. ......................... 1 1.2 ordering information...................................................................................................... ................ 3 1.3 pin configuration (top view) .............................................................................................. .......... 4 1.3.1 78k 0r/lf3 ............................................................................................................... ......................... 4 1.3.2 78k 0r/lg3 ............................................................................................................... ........................ 7 1.3.3 78k 0r/lh3............................................................................................................... ....................... 10 1.4 block diagram ............................................................................................................. ................. 13 1.4.1 78k 0r/lf3 ............................................................................................................... ....................... 13 1.4.2 78k 0r/lg3 ............................................................................................................... ...................... 15 1.4.3 78k 0r/lh3............................................................................................................... ....................... 17 1.5 outline of functions...................................................................................................... ............... 19 chapter 2 pin functions .................................................................................................... ........... 23 2.1 pin function list ......................................................................................................... ................. 23 2.1.1 78k 0r/lf3 ............................................................................................................... ....................... 24 2.1.2 78k 0r/lg3 ............................................................................................................... ...................... 30 2.1.3 78k 0r/lh3............................................................................................................... ....................... 36 2.2 description of pin func tions .............................................................................................. ........ 43 2.2.1 p00 to p02 .............................................................................................................. ........................ 43 2.2.2 p10 to p17 .............................................................................................................. ........................ 44 2.2.3 p20 to p27 .............................................................................................................. ........................ 46 2.2.4 p30 to p34 .............................................................................................................. ........................ 47 2.2.5 p 40, p41 ................................................................................................................ ......................... 48 2.2.6 p50 to p57 .............................................................................................................. ........................ 49 2.2.7 p 60, p61 ................................................................................................................ ......................... 50 2.2.8 p70 to p77 .............................................................................................................. ........................ 51 2.2.9 p80 to p87 .............................................................................................................. ........................ 52 2.2.10 p90 to p97 ............................................................................................................. ....................... 53 2.2.11 p100 to p102 ........................................................................................................... ..................... 54 2.2.12 p1 10, p 111 ............................................................................................................. ...................... 54 2.2.13 p120 to p124 ........................................................................................................... ..................... 55 2.2.14 p130................................................................................................................... ........................... 56 2.2.15 p140 to p147 ........................................................................................................... ..................... 56 2.2.16 p150 to p152, p157 ..................................................................................................... ................. 57 2.2.17 com0 to com7........................................................................................................... .................. 57 2.2.18 segxx .................................................................................................................. ......................... 57 2.2.19 vlc0 to vlc3 ........................................................................................................... .................... 57 2.2.20 vrefout/avrefp ( pd78f150xa only) .................................................................................. 58 2.2.21 avref ( pd78f151xa only) ....................................................................................................... 58 2.2.22 reset .................................................................................................................. ........................ 58 2.2.23 regc................................................................................................................... ......................... 58 2.2.24 flmd0 .................................................................................................................. ........................ 58 2.2.25 avdd0, avdd1, avdd, evdd1 , avss, evdd, evss, vdd, vss ............................................. 59 2.3 pin i/o circuits and recomme nded connection of unu sed pins ........................................... 60 2.3.1 78k 0r/lf3 ............................................................................................................... ....................... 60 2.3.2 78k 0r/lg3 ............................................................................................................... ...................... 63 2.3.3 78k 0r/lh3............................................................................................................... ....................... 66 chapter 3 cpu architecture ................................................................................................. ..... 74 3.1 memory space .............................................................................................................. ................ 74 3.1.1 internal progr am memory space ........................................................................................... .......... 79 3.1.2 mi rror ar ea............................................................................................................. .......................... 81 3.1.3 internal dat a memory space.............................................................................................. .............. 83 3.1.4 special function register (sfr) area .................................................................................... ........... 84 3.1.5 extended special function register (2nd sfr: 2nd special func tion register) area ...................... 84 3.1.6 data me mory addr essing .................................................................................................. .............. 85 3.2 processor registers....................................................................................................... .............. 88 3.2.1 contro l regist ers ....................................................................................................... ....................... 88 3.2.2 general-pur pose registers............................................................................................... ................ 90 3.2.3 es and cs regist ers..................................................................................................... ................... 92 3.2.4 special functi on register s (sfrs) ....................................................................................... ............. 93 3.2.5 extended specia l function registers (2nd sfrs: 2nd special function register s) .......................... 99 3.3 instruction address addressi ng............................................................................................ ... 108 3.3.1 relati ve addre ssing..................................................................................................... .................. 108 3.3.2 immedi ate addres sing .................................................................................................... ............... 108 3.3.3 table indi rect addr essing ............................................................................................... ............... 109 3.3.4 register di rect addr essing.............................................................................................. ............... 110 3.4 addressing for processing data addresses ........................................................................... 111 3.4.1 impli ed addre ssing ...................................................................................................... .................. 111 3.4.2 regist er addre ssing ..................................................................................................... ................. 111 3.4.3 direct addre ssing ....................................................................................................... ................... 112 3.4.4 short di rect addr essing ................................................................................................. ................ 113 3.4.5 sfr addressi ng .......................................................................................................... .................. 114 3.4.6 register i ndirect addr essi ng............................................................................................ .............. 115 3.4.7 based addre ssing........................................................................................................ .................. 116 3.4.8 based in dexed addr essing ................................................................................................ ............ 119 3.4.9 stack addre ssing........................................................................................................ ................... 120 chapter 4 port functions ................................................................................................... ...... 121 4.1 port functions ............................................................................................................ ................ 121 4.2 port configuration..................................................... ................................................... .............. 129 4.2.1 po rt 0.................................................................................................................. ........................... 130 4.2.2 po rt 1.................................................................................................................. ........................... 133 4.2.3 po rt 2.................................................................................................................. ........................... 138 4.2.4 po rt 3.................................................................................................................. ........................... 142 4.2.5 po rt 4.................................................................................................................. ........................... 144 4.2.6 po rt 5.................................................................................................................. ........................... 146 4.2.7 po rt 6.................................................................................................................. ........................... 150 4.2.8 po rt 7.................................................................................................................. ........................... 151 4.2.9 po rt 8.................................................................................................................. ........................... 156 4.2.10 po rt 9................................................................................................................. .......................... 162 4.2.11 po rt 10................................................................................................................ ......................... 165 4.2.12 po rt 11................................................................................................................ ......................... 167 4.2.13 po rt 12................................................................................................................ ......................... 168 4.2.14 po rt 13................................................................................................................ ......................... 172 4.2.15 po rt 14................................................................................................................ ......................... 173 4.2.16 po rt 15................................................................................................................ ......................... 176 4.3 registers controlling port function ....................... ................................................................ . 180 4.4 port function operations .................................................................................................. ........ 197 4.4.1 writi ng to i/o port ..................................................................................................... ..................... 197 4.4.2 reading from i/o port................................................................................................... ................. 197 4.4.3 operatio ns on i/o port.................................................................................................. ................. 197 4.4.4 connecting to external device with different power potent ial (2.5 v, 3 v)...................................... 198 4.5 settings of port mode register and output latch when using alternate function........... 200 4.6 cautions on 1-bit manipulation instruction for port register n (p n) .................................... 205 chapter 5 clock generator .................................................................................................. .. 206 5.1 functions of clock generator.............................................................................................. ..... 206 5.2 configuration of clock gene rator .......................................................................................... .. 207 5.3 registers controlling clock generator................... ................................................................. 2 09 5.4 system clock oscillator ................................................................................................... ......... 222 5.4.1 x1 oscill ator........................................................................................................... ........................ 222 5.4.2 xt1 oscilla tor .......................................................................................................... ...................... 222 5.4.3 internal hi gh-speed os cillator .......................................................................................... .............. 226 5.4.4 internal lo w-speed os cillator........................................................................................... ............... 226 5.4.5 pr escaler ............................................................................................................... ........................ 226 5.5 clock generator operation ................................................................................................. ...... 227 5.6 controlling clock......................................................................................................... ............... 232 5.6.1 example of controlli ng high-speed syst em clock .......................................................................... . 232 5.6.2 example of controlling intern al high-speed osc illation cl ock.......................................................... 23 5 5.6.3 example of cont rolling subsyst em clock.................................................................................. ...... 237 5.6.4 example of controlling intern al low-speed osci llation cl ock ........................................................... 23 9 5.6.5 cpu clock stat us transiti on diagr am..................................................................................... ......... 240 5.6.6 condition before changing cpu clock and processi ng after changing cpu cl ock ........................ 247 5.6.7 time required for switchover of cpu clock and main system cl ock .............................................. 249 5.6.8 conditions before clock osc illation is stopp ed .......................................................................... ..... 250 chapter 6 timer array unit................................................................................................ ...... 251 6.1 functions of timer array unit............................................................................................. ...... 253 6.1.1 functions of eac h channel when it oper ates indepe ndently .......................................................... 253 6.1.2 functions of each channel when it operates with another channe l ............................................... 254 6.1.3 lin-bus supporting function (cha nnel 7 of timer a rray unit 0 only) ................................................ 254 6.2 configuration of timer array unit .................... ..................................................................... ... 255 6.3 registers controlling timer array unit................... ................................................................. 261 6.4 channel output (topq pin) control ................. ........................................................................ 289 6.4.1 topq pin output ci rcuit config uration................................................................................... .......... 289 6.4.2 topq pin output setting ................................................................................................. .............. 290 6.4.3 cautions on cha nnel output operation .................................................................................... .... 291 6.4.4 collective mani pulation of topq bits .................................................................................... ......... 294 6.4.5 timer interrupt and topq pi n output at oper ation st art............................................................... 295 6.5 channel input control.................................................. ................................................... ........... 296 6.5.1 edge dete ction ci rcuit .................................................................................................. .................. 296 6.6 basic function of timer array unit .................. ...................................................................... .. 297 6.6.1 overview of single-operation f unction and combination operation f unction ................................... 297 6.6.2 basic rules of comb ination operat ion func tion ........................................................................... .... 297 6.6.3 applicable range of basic rules of comb ination operati on functi on ................................................ 298 6.7 operation of timer array unit as independent channel ........................................................ 299 6.7.1 operation as interv al timer/squar e wave output .......................................................................... .. 299 6.7.2 operation as ex ternal event count er ..................................................................................... ........ 306 6.7.3 operation as frequency divi der .......................................................................................... ........... 310 6.7.4 operation as input pulse interval measur ement ........................................................................... . 315 6.7.5 operation as in put signal high-/low-le vel width me asurem ent....................................................... 319 6.8 operation of plural channels of timer array un it .................................................................. 323 6.8.1 operation as pwm f unction ............................................................................................... ........... 323 6.8.2 operation as one-s hot pulse output function............................................................................. .... 330 6.8.3 operation as mult iple pwm output func tion ............................................................................... ... 337 chapter 7 real-time counter................................................................................................ ... 345 7.1 functions of real-time c ounter............................................................................................ ... 345 7.2 configuration of real-time c ounter ........................................................................................ 345 7.3 registers controlling real-time counter.................. .............................................................. 347 7.4 real-time counter operation ............................................................................................... .... 362 7.4.1 starting operation of real-tim e coun ter ................................................................................. ......... 362 7.4.2 shifting to stop m ode after starti ng operat ion.......................................................................... ... 363 7.4.3 reading/writi ng real-tim e count er....................................................................................... ........... 364 7.4.4 setting alarm of real-tim e count er ...................................................................................... ........... 366 7.4.5 1 hz output of real-tim e counter ........................................................................................ ............ 367 7.4.6 32.768 khz output of real-tim e coun ter .................................................................................. ....... 367 7.4.7 512 hz or 16.384 khz ou tput of real -time c ounter ........................................................................ . 368 7.4.8 example of watch error co rrection of real-t ime coun ter ................................................................. 3 69 chapter 8 watchdog timer ................................................................................................... .... 374 8.1 functions of watchdog timer............................................................................................... .... 374 8.2 configuration of watchdog time r ........................................................................................... . 375 8.3 register controlling watchdog timer...................................................................................... 3 76 8.4 operation of watchdog timer............................................................................................... .... 377 8.4.1 controlling operat ion of watc hdog timer ................................................................................. ....... 377 8.4.2 setting overflow ti me of watc hdog ti mer................................................................................. ....... 378 8.4.3 setting window open pe riod of watc hdog ti mer ............................................................................ . 379 8.4.4 setting watchdog ti mer interval interrupt ............................................................................... ........ 380 chapter 9 clock output/buzzer output controller ................................................. 381 9.1 functions of clock output/buzze r output controller .................... ........................................ 381 9.2 configuration of clock output /buzzer output controller...................................................... 382 9.3 registers controlling clock ou tput/buzzer output controller ............................................. 382 9.4 operations of clock output/b uzzer output controller .................. ........................................ 384 9.4.1 operation as output pin ................................................................................................. ................ 384 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) .................................................................. 385 10.1 function of a/d converter................................................................................................ ....... 385 10.2 configuration of a/d converter ........................................................................................... ... 388 10.3 registers used in a/d converter.......................................................................................... .. 390 10.4 a/d converter operations ............................................. .................................................... ...... 403 10.4.1 basic operations of a/d c onverter ...................................................................................... ......... 403 10.4.2 input voltage and conversion results ................................................................................... ........ 405 10.4.3 a/d converte r operati on modes.......................................................................................... ......... 406 10.5 how to read a/d converter characteristics tabl e............................................................... 412 10.6 cautions for a/d converter ............................................................................................... ...... 414 chapter 11 d/a converter ( pd78f150xa only) .................................................................... 418 11.1 function of d/a converter................................................................................................ ....... 418 11.2 configuration of d/a converter ........................................................................................... ... 418 11.3 registers used in d/a converter.......................................................................................... .. 420 11.4 operation of d/a converter............................................................................................... ...... 423 11.4.1 operation in norma l mode............................................................................................... ............ 423 11.4.2 operation in real-time out put mode ..................................................................................... ........ 423 11.5 cautions for d/a converter ............................................................................................... ...... 424 chapter 12 operational amplifier ( pd78f150xa only).................................................... 425 12.1 function of operational amplifier .................. ...................................................................... .. 425 12.2 configuration of operational amplifier.................................................................................. 4 25 12.3 amplifier registers used in operational amplif ier............................................................... 427 12.4 operational amplifier operat ions......................................................................................... .. 433 12.4.1 single amp mode........................................................................................................ ................ 433 chapter 13 voltage reference ( pd78f150xa only)........................................................... 434 13.1 function of voltage refe rence ............................................................................................ ... 434 13.2 configuration of voltage re ference ....................................................................................... 434 13.3 amplifier registers used in voltage reference .................................................................... 435 13.4 voltage reference operations ..................................... ........................................................ ... 437 13.4.1 reference vo ltage out put m ode .......................................................................................... ........ 437 13.5 cautions for voltage reference................................ ........................................................... ... 437 chapter 14 serial array unit.............................................................................................. .... 438 14.1 functions of serial array unit........................................................................................... ...... 439 14.1.1 3-wire serial i/o (csi 00, csi01, cs i10, cs i20) ......................................................................... . 439 14.1.2 uart (uart0, ua rt1, uart2, uart 3) .................................................................................. 439 14.1.3 simplified i 2 c (iic10, iic20) ......................................................................................................... 440 14.2 configuration of serial array unit ............... ........................................................................ ... 441 14.3 registers controlling serial array unit................. ................................................................. 446 14.4 operation stop mode ...................................................................................................... ......... 469 14.4.1 stoppin g the operati on by units........................................................................................ ........... 469 14.4.2 stoppin g the operation by chann els ..................................................................................... ....... 470 14.5 operation of 3-wire serial i/o (csi00, csi 01, csi10, csi20) communication ................... 472 14.5.1 master transmission .................................................................................................... ................ 473 14.5.2 master recept ion....................................................................................................... ................... 482 14.5.3 master trans mission/rec eption .......................................................................................... .......... 488 14.5.4 slave transmi ssion ..................................................................................................... ................. 496 14.5.5 slave reception ........................................................................................................ ................... 505 14.5.6 slave trans mission/rec eption ........................................................................................... ........... 511 14.5.7 calculating tr ansfer clock frequency................................................................................... ......... 520 14.6 operation of uart (uart0, uart1, uart2, uart3) communication ............................. 522 14.6.1 uart transmi ssion ...................................................................................................... ............... 523 14.6.2 uart recept ion......................................................................................................... .................. 533 14.6.3 lin transmi ssion....................................................................................................... ................... 540 14.6.4 lin reception.......................................................................................................... ..................... 543 14.6.5 calculat ing baud rate .................................................................................................. ................ 548 14.7 operation of simplified i 2 c (iic10, iic20) communication ................................................... 552 14.7.1 address fi eld transmi ssion ............................................................................................. ............. 553 14.7.2 data transmi ssion...................................................................................................... .................. 558 14.7.3 data reception ......................................................................................................... .................... 561 14.7.4 stop conditi on gener ation.............................................................................................. .............. 565 14.7.5 calculati ng transfe r rate .............................................................................................. ................ 566 14.8 processing procedure in case of error ................ ................................................................. 569 14.9 relationship between register settings and pins ............................................................... 571 chapter 15 serial interface iica .......................................................................................... . 578 15.1 functions of serial interface iica................ ....................................................................... .... 578 15.2 configuration of serial inte rface iica ................................................................................... . 581 15.3 registers controlling serial interface iica........... ................................................................. 58 4 15.4 i 2 c bus mode functions........................................................................................................... 596 15.4.1 pin c onfigurat ion ...................................................................................................... ................... 596 15.4.2 setting transfer clock by us ing iicwl and iicwh regist ers ........................................................ 597 15.5 i 2 c bus definitions and control methods .............................................................................. 598 15.5.1 start conditi ons ....................................................................................................... .................... 598 15.5.2 a ddresses .............................................................................................................. ..................... 599 15.5.3 transfer direct ion specif ication....................................................................................... ............. 599 15.5.4 ackno wledge (a ck) ...................................................................................................... .............. 600 15.5.5 stop condition ......................................................................................................... .................... 601 15.5.6 wait ................................................................................................................... .......................... 602 15.5.7 canc eling wait ......................................................................................................... .................... 604 15.5.8 interrupt request (intiica) gen eration timing and wait cont rol ................................................... 605 15.5.9 address matc h detection method ......................................................................................... ....... 606 15.5.10 erro r detec tion....................................................................................................... .................... 606 15.5.11 exte nsion code........................................................................................................ .................. 606 15.5.12 arbi tration........................................................................................................... ....................... 607 15.5.13 wake up func tion....................................................................................................... ................. 609 15.5.14 communicati on reserv ation............................................................................................. .......... 612 15.5.15 ca utions .............................................................................................................. ...................... 616 15.5.16 communica tion oper ations.............................................................................................. .......... 617 15.5.17 timing of i 2 c interrupt request (int iica) occu rrence ................................................................ 625 15.6 timing charts ............................................................................................................ ............... 646 chapter 16 lcd controller/driver ....................................................................................... 661 16.1 functions of lcd controller/driver....................... ................................................................ . 661 16.2 configuration of lcd controller/driver ................ ................................................................. 66 5 16.3 registers controlling lcd controller/driver........... .............................................................. 667 16.4 lcd display data memory.................................................................................................. ..... 675 16.5 setting lcd controller/driver ............................................................................................ ..... 678 16.6 common and segment signals .............................................................................................. 6 80 16.7 display modes ............................................................................................................ .............. 687 16.7.1 static di splay ex ample................................................................................................. ................ 687 16.7.2 two-time-slic e display example ......................................................................................... ......... 690 16.7.3 three-time-slic e display example ....................................................................................... ......... 693 16.7.4 four-time-slic e display example ........................................................................................ .......... 697 16.7.5 eight-time-slic e display example ....................................................................................... .......... 700 16.8 supplying lcd drive voltages vlc0, vlc1, vlc2 , and vlc3 ............................................ 703 16.8.1 external resi stance divisi on met hod .................................................................................... ........ 703 16.8.2 internal vo ltage boosti ng method ....................................................................................... ......... 704 16.8.3 capacito r split method................................................................................................. ................ 705 16.9 selection of lcd display data ............................................................................................ .... 706 16.9.1 a-pattern ar ea and b-pattern area data di splay ......................................................................... . 706 16.9.2 blinking display (alternately disp laying a-pattern and b- pattern ar ea data) ................................ 707 chapter 17 multiplier/divider ............................................................................................... .... 708 17.1 functions of multiplier/divider .................................. ........................................................... 708 17.2 configuration of multiplier/divide r ....................................................................................... 708 17.3 register controlling multiplier/div ider ................................................................................ 713 17.4 operations of multiplier/divider ............................................................................................ 714 17.4.1 multiplication operation....................................................................................................... ..... 714 17.4.2 division op eratio n ............................................................................................................. ....... 715 chapter 18 dma controller .................................................................................................. ... 717 18.1 functions of dma controller .............................................................................................. .... 717 18.2 configuration of dma controller .................... ...................................................................... .. 718 18.3 registers controlling dma controller ................................................................................... 72 1 18.4 operation of dma contro ller.............................................................................................. ..... 724 18.4.1 operat ion proc edure .................................................................................................... ............... 724 18.4.2 trans fer m ode .......................................................................................................... ................... 725 18.4.3 termination of dma tr ansfer ............................................................................................ ........... 725 18.5 example of setting of dma controller .................. ................................................................. 72 5 18.5.1 csi consec utive trans mission ........................................................................................... .......... 725 18.5.2 csi mast er reception................................................................................................... ................ 727 18.5.3 csi transmi ssion/rec eption ............................................................................................. ............ 729 18.5.4 consecut ive capturing of a/d conversion results ........................................................................ 731 18.5.5 uart consec utive reception + ack transmi ssion ...................................................................... 733 18.5.6 holding dma trans fer pending by dwaitn ................................................................................. 735 18.5.7 forced terminat ion by so ftware ......................................................................................... .......... 736 18.6 cautions on using dma controller ........................................................................................ 7 38 chapter 19 interrupt functions.............................................................................................. 740 19.1 interrupt function types ................................................................................................. ........ 740 19.2 interrupt sources and configur ation ..................................................................................... 7 41 19.3 registers controlling interrupt functions............ ................................................................. 746 19.4 interrupt servicing oper ations ........................................................................................... .... 764 19.4.1 maskable interr upt acknow ledgment ...................................................................................... ..... 764 19.4.2 software interrupt request ack nowledg ment .............................................................................. . 766 19.4.3 multiple in terrupt se rvicing........................................................................................... ................ 767 19.4.4 interrupt request hold ................................................................................................. ................. 770 chapter 20 key interrupt function ..................................................................................... 771 20.1 functions of key interrupt ............................................................................................... ....... 771 20.2 configuration of key in terrupt ........................................................................................... ..... 771 20.3 register controlling key interrupt ........................ ............................................................... .. 772 chapter 21 standby function ................................................................................................ .. 773 21.1 standby function and co nfiguration ..................................................................................... 77 3 21.1.1 standby func tion ....................................................................................................... .................. 773 21.1.2 registers contro lling standby function................................................................................. ........ 773 21.2 standby function operatio n ............................................................................................... .... 776 21.2.1 ha lt m ode .............................................................................................................. ................... 776 21.2.2 st op m ode .............................................................................................................. .................. 782 chapter 22 reset function.................................................................................................. ...... 788 22.1 register for confirming reset source .................. ................................................................. 79 7 chapter 23 power-on-clear circuit...................................................................................... 798 23.1 functions of power-on-clear circuit..................... ................................................................. 798 23.2 configuration of power-on-clea r circuit ............................................................................... 799 23.3 operation of power-on-clear circuit ..................... ................................................................. 799 23.4 cautions for power-on-clear circuit ..................... ................................................................. 802 chapter 24 low-voltage detector ....................................................................................... 804 24.1 functions of low-voltage detector....................... ................................................................. 804 24.2 configuration of low-voltage detector ................................................................................. 805 24.3 registers controlling low-voltage detector........... .............................................................. 805 24.4 operation of low-voltage detector ....................... ................................................................. 810 24.4.1 when us ed as re set ..................................................................................................... ............... 811 24.4.2 when used as interrupt ................................................................................................. .............. 817 24.5 cautions for low-voltage detector ....................... ................................................................. 823 chapter 25 regulator ........................................................................................................ ......... 827 25.1 regulator overview....................................................................................................... ........... 827 25.2 registers controlling regulator .......................................................................................... ... 827 chapter 26 option byte..................................................................................................... .......... 829 26.1 functions of option by tes ................................................................................................ ...... 829 26.1.1 user option byte (000c0h to 000c2h/010c0h to 010c 2h) ....................................................... 829 26.1.2 on-chip debug option byte (000c3h / 010c3h )........................................................................... 83 0 26.2 format of user option byte ............................................................................................... ..... 830 26.3 format of on-chip debug option byte.................. ................................................................. 832 26.4 setting of option byte................................................................................................... ........... 833 chapter 27 flash memory .................................................................................................... ...... 834 27.1 writing with flash memory programmer ............................................................................... 834 27.2 programming environment .................................................................................................. ... 834 27.3 communication mode ....................................................................................................... ....... 835 27.4 connection of pins on board.............................................................................................. .... 837 27.4.1 fl md0 pin.............................................................................................................. ..................... 837 27.4.2 t ool0 pi n.............................................................................................................. ..................... 838 27.4.3 r eset pin .............................................................................................................. .................... 838 27.4.4 po rt pins .............................................................................................................. ........................ 838 27.4.5 re gc pin ............................................................................................................... ..................... 838 27.4.6 x1 an d x2 pins ......................................................................................................... ................... 838 27.4.7 powe r suppl y........................................................................................................... .................... 839 27.5 registers controlling flash memory...................................................................................... 8 39 27.6 programming method ....................................................................................................... ....... 840 27.6.1 controlli ng flash memory............................................................................................... .............. 840 27.6.2 flash memory programmi ng mode.......................................................................................... .... 840 27.6.3 selecting communicati on mode ........................................................................................... ....... 841 27.6.4 communi cation co mmands................................................................................................. ........ 841 27.7 security settings ........................................................................................................ .............. 843 27.8 flash memory programming by self-programming ............................................................. 845 27.8.1 boot swap func tion ..................................................................................................... ................. 847 27.8.2 flash shield window f unction........................................................................................... ............ 849 27.9 creating rom code to place order for previ ously written product .................................. 850 27.9.1 procedure for using rom code to plac e an or der ................................................................... 850 chapter 28 on-chip debug function ..................................................................................... 851 28.1 connecting qb-mini2 to 78k0r/lx3 microcontro llers ......................................................... 851 28.2 on-chip debug security id ................................................................................................ ..... 852 28.3 securing of user resources ............................................................................................... .... 852 chapter 29 bcd correction circuit ....................... .............................................................. 854 29.1 bcd correction circuit function........................... ............................................................... .. 854 29.2 registers used by bcd correction circuit .......... ................................................................. 854 29.3 bcd correction circuit operation ......................... ................................................................ . 855 chapter 30 instruction set.................................................................................................. ...... 857 30.1 conventions used in operation list ..................... ................................................................. 8 57 30.1.1 operand identifiers and specificat ion me thods.......................................................................... .. 857 30.1.2 description of operation column ........................................................................................ .......... 858 30.1.3 description of flag operati on colu mn ................................................................................... ........ 859 30.1.4 prefix instruct ion ..................................................................................................... ................. 859 30.2 operation list ........................................................................................................... ................ 860 chapter 31 electrical specifications ................................................................................. 877 chapter 32 package drawings ................................................................................................. 934 32.1 78k0r/lf3...................................................................................................................... ......... 934 32.2 78k0r/lg3 ...................................................................................................................... ........ 936 32.3 78k0r/lh3 ...................................................................................................................... ........ 937 chapter 33 recommended soldering conditions ........................................................... 938 appendix a development tools............................................................................................... 940 a.1 software package .......................................................................................................... ............ 943 a.2 language processing software ..................................... ......................................................... . 943 a.3 flash memory programming tools.......................................................................................... 94 4 a.3.1 when using flash memory programmer pg-fp5 and fl-p r5...................................................... 944 a.3.2 when using on-chip debug emulator with programm ing function qb-mini2................................. 944 a.4 debugging tools (hardware)............................................. ................................................... .... 945 a.4.1 when using in-circuit emulator qb -78k0rlx 3 ............................................................................. 9 45 a.4.2 when using on-chip debug emulator with programm ing function qb-mini2................................. 946 a.5 debugging tools (software) .............................................. .................................................. ..... 946 appendix b register index .................................................................................................. ....... 947 b.1 register index (in alphabeti cal order with respect to regist er names) ............................ 947 b.2 register index (in alphabetical order with respect to register symbol)........................... 952 appendix c list of cautions ............................................................................................... ...... 957 appendix d revision history ................................................................................................ ..... 996 d.1 major revisions in this edition ........................................................................................... .... 996 d.2 revision history of preceding editions ................. ............................................................... 1000 r01uh0004ej0501 rev.5.01 1 jun 20, 2011 r01uh0004ej0501 rev.5.01 jun 20, 2011 78k0r/lx3 renesas mcu chapter 1 outline the 78k0r/lx3 microcontrollers are 16-bit single-chip microcontrollers that include the 78k0r cpu core and peripheral functions such as rom/ram, lcd controller/drive r, a/d converter, d/a conver ter, operational amplifier, multifunctional serial interfaces, multifunctional timers, real-time counter, and watchdog timer. 1.1 features { minimum instruction execution time can be changed from high speed (0.05 s: @ 20 mhz operation with high-speed system clock) to ultra low-speed (61 s: @ 32.768 khz operation with subsystem clock) { general-purpose register: 8 bits 32 registers (8 bits 8 registers 4 banks) { rom, ram capacities 78k0r/lf3 78k0r/lg3 78k0r/lh3 program memory (rom) data memory (ram) 80 pins 100 pins 128 pins 64 kb 4 kb pd78f1500a, pd78f1510a pd78f1503a, pd78f1513a pd78f1506a, pd78f1516a 96 kb 6 kb pd78f1501a pd78f1504a pd78f1507a 128 kb 7 kb pd78f1502a, pd78f1512a pd78f1505a, pd78f1515a pd78f1508a, pd78f1518a { on-chip internal high-speed oscillation clock ? 20 mhz internal high-speed s oscillation clock: 20 mhz 2.4 % ? 8 mhz internal high-speed s oscillation clock: 8 mhz 2 % (when 1.8 v v dd < 2.7 v) ? 1 mhz internal high-speed s oscillation clock: 1 mhz 13 % { on-chip single-power-supply flash memory (with prohib ition of chip erase/block erase/writing function) { self-programming (with boot swap func tion/flash shield window function) { on-chip debug function { on-chip power-on-clear (poc) circuit and low-voltage detector (lvi) { on-chip watchdog timer (can operate on dedicated internal low-speed oscillation clock) { on-chip multiplier/divider (16 bits 16 bits, 32 bits 32 bits) { on-chip key interrupt function { on-chip clock output/buzzer out put controller (output: 2) { on-chip bcd adjustment { i/o ports: ? 78k0r/lf3: 51 ? 78k0r/lg3: 67 (n-ch open drain: 2) ? 78k0r/lh3: 83 (n-ch open drain: 2) { timer timer 78k0r/lf3 78k0r/lg3 78k0r/lh3 16-bit timer 12 ch (input: 6, output: 6) 12 ch (input: 8, output: 8) 12 ch (input: 12, output: 12) watchdog timer 1 ch real-time counter 1 ch (output:2) 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 2 jun 20, 2011 { serial interface: 1 channel ? 78k0r/lf3: csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel uart (lin-bus supported): 1 channel ? 78k0r/lg3: csi: 1 channel/uart: 1 channel csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel uart (lin-bus supported): 1 channel multimaster i 2 c: 1 channel ? 78k0r/lh3: csi: 2 channels/uart: 1 channel csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel uart (lin-bus supported): 1 channel multimaster i 2 c: 1 channel { 12-bit resolution a/d conversion ( pd78f150xa only) ? 78k0r/lf3: 8 channels ? 78k0r/lg3, 78k0r/lh3: 12 channels { 10-bit resolution a/d conversion ( pd78f151xa only) ? 78k0r/lf3: 8 channels ? 78k0r/lg3, 78k0r/lh3: 12 channels { 12-bit resolution d/a converter ( pd78f150xa only): 2 channels { operational amplifier ( pd78f150xa only) ? 78k0r/lf3: 2 channels ? 78k0r/lg3, 78k0r/lh3: 3 channels { on-chip voltage reference (2.0 v/2.5 v) ( pd78f150xa only) { lcd controller/driver (internal volt age boosting method, capacitor split met hod, and external resistance division method are switchable) lcd controller/driver 78k0r/lf3 78k0r/lg3 78k0r/lh3 segment signal output 31 (27) note 40 (36) note 54 (50) note common signal output 4 (8) note note the values in parentheses are the number of signal outputs when 8com is used. { dma controller: 2 channels { power supply voltage: v dd = 1.8 to 5.5 v { operating ambient temperature: t a = ? 40 to +85 c 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 3 jun 20, 2011 1.2 ordering information ? flash memory version (lead-free products) 78k0r/lx3 microcontrollers package part number 80-pin plastic lqfp (14x14) pd78f1500agc-gad-ax, 78f1501agc-gad-ax, 78f1502agc-gad-ax, 78f1510agc-gad-ax, 78f1512agc-gad-ax, 78k0r/lf3 80-pin plastic lqfp (f ine pitch) (12x12) pd78f1500agk-gak-ax, 78f1501agk-gak-ax, 78f1502agk-gak-ax, 78f1510agk-gak-ax, 78f1512agk-gak-ax 78k0r/lg3 100-pin plastic lqfp (fine pitch) (14x14) pd78f1503agc-ueu-ax, 78f1504agc-ueu-ax, 78f1505agc-ueu-ax , 78f1513agc-ueu-ax, 78f1515agc-ueu-ax 78k0r/lh3 128-pin plastic lqfp (fine pitch) (14x20) pd78f1506agf-gat-ax, 78f1507agf-gat-ax, 78f1508agf-gat-ax, 78f1516agf-gat-ax, 78f1518agf-gat-ax caution the 78k0r/lx3 microcontrollers have an on-chip debug function, wh ich is provided for development and evaluation. do not use the on-chip debug functi on in products designated for mass production, because the guaranteed number of re writable times of the flash memory may be exceeded when this function is used, and produc t reliability therefore cannot be guaranteed. renesas electronics is not liable for problems occurring when the on-chip debug function is used. 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 4 jun 20, 2011 1.3 pin configuration (top view) 1.3.1 78k0r/lf3 (1) pd78f150xa ? 80-pin plastic lqfp (14 14) ? 80-pin plastic lqfp (fine pitch) (12 12) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 80 79 78 77 76 75 74 73 72 71 70 69 68 64 63 62 61 67 66 65 21 22 23 24 25 26 27 28 29 30 31 32 33 37 38 39 40 34 35 36 av ss av dd0 p111/ano1 p110/ano0 av dd1 com0 com1 com2 com3 com4/seg0 com5/seg1 com6/seg2 com7/seg3 seg4 seg5 seg6 seg7 seg8 seg9 seg10 p10/sck20/scl20 p11/intp6/si20/rxd2/sda20 p12/to02/so20/txd2 p13/to04/so10/txd1 p14/intp4/si10/rxd1/sda10 p15/intp7/sck10/scl10 p30/intp1/ti03/to00/rtc1hz p31/intp2/ti00/to03/rtcdiv/rtccl/pclbuz1 p32/intp5/ti01/to01/pclbuz0 p33/intp3/ti07/to07 p130 p20/ani0/amp0- p21/ani1/amp0o p22/ani2/amp0+ p23/ani3/amp1- p24/ani4/amp1o p25/ani5/amp1+ p26/ani6 p157/ani15/av refm v refout /av refp p50/seg30/rxd3 p51/seg29/txd3 p52/seg28/ti02 p53/seg27/ti04 p54/seg26 p55/seg25 p56/seg24 p57/seg23 p90/seg22 p91/seg21 p92/seg20 p140/seg19 p141/seg18 p142/seg17 p143/seg16 p144/seg15 p145/seg14 p146/seg13 p147/seg12 p100/seg11 p120/intp0/exlvi p41/tool1 p40/tool0 p00/caph p01/capl p02/v lc3 v lc2 v lc1 v lc0 reset p124/xt2 p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss ev ss v dd ev dd cautions 1. make av ss the same potential as v ss . 2. connect the regc pin to vss via a capacitor (0.47 to 1 f). 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 5 jun 20, 2011 (2) pd78f150xa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 80 79 78 77 76 75 74 73 72 71 70 69 68 64 63 62 61 67 66 65 21 22 23 24 25 26 27 28 29 30 31 32 33 37 38 39 40 34 35 36 av ss av dd p111 p110 ev dd1 com0 com1 com2 com3 com4/seg0 com5/seg1 com6/seg2 com7/seg3 seg4 seg5 seg6 seg7 seg8 seg9 seg10 p10/sck20/scl20 p11/intp6/si20/rxd2/sda20 p12/to02/so20/txd2 p13/to04/so10/txd1 p14/intp4/si10/rxd1/sda10 p15/intp7/sck10/scl10 p30/intp1/ti03/to00/rtc1hz p31/intp2/ti00/to03/rtcdiv/rtccl/pclbuz1 p32/intp5/ti01/to01/pclbuz0 p33/intp3/ti07/to07 p130 p20/ani0 p21/ani1 p22/ani2 p23/ani3 p24/ani4 p25/ani5 p26/ani6 p157/ani15 av ref p50/seg30/rxd3 p51/seg29/txd3 p52/seg28/ti02 p53/seg27/ti04 p54/seg26 p55/seg25 p56/seg24 p57/seg23 p90/seg22 p91/seg21 p92/seg20 p140/seg19 p141/seg18 p142/seg17 p143/seg16 p144/seg15 p145/seg14 p146/seg13 p147/seg12 p100/seg11 p120/intp0/exlvi p41/tool1 p40/tool0 p00/caph p01/capl p02/v lc3 v lc2 v lc1 v lc0 reset p124/xt2 p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss ev ss v dd ev dd cautions 1. make av ss the same potential as v ss . 2. connect the regc pin to vss via a capacitor (0.47 to 1 f). 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 6 jun 20, 2011 pin identification amp0- , amp1- : amplifier input minus amp0+ , amp1+ : amplifier input plus amp0o , amp0o : amplifier output ani0 to ani6, ani15 : analog input (adc) ano0, ado1 : analog output (dac) av ref : analog reference voltage av refm : analog reference voltage minus av refp : analog reference voltage plus av ss : analog ground av dd : analog power supply av dd0 : analog power supply (adc/vref/opamp) av dd1 : analog power supply (dac) caph, capl : capacitor for lcd com0 to com7 : lcd common output ev dd , ev dd1 : power supply for port ev ss : gnd for port exclk : external clock input (main system clock) exlvi : external potential input for low voltage detector flmd0 : flash programming mode intp0 to intp7 : exte rnal interrupt input p00 to p02 : port 0 p10 to p15 : port 1 p20 to p26 : port 2 p30 to p33 : port 3 p40, p41 : port 4 p50 to p57 : port 5 p90 to p92 : port 9 p100 : port 10 p110, p111 : port 11 p120 to p124 : port 12 p130 : port 13 p140 to p147 : port 14 p157 : port 15 pclbuz0, pclbuz1 : programmable clock output /buzzer output regc : regulator capacitance reset: reset rtc1hz : real-time counter correction clock (1hz) output rtccl : real-time counter clock (32 khz original oscillation) output rtcdiv : real-time counter clock (32 khz divided frequency) output rxd1 to rxd3 : receive data sck10, sck20 : serial clock input/output scl10, scl20 : serial clock input/output sda10, sda20 : serial data input/output seg0 to seg30 : lcd segment output si10, si20 : serial data input so10, so20 : serial data output ti00 to ti04, ti07 : timer input to00 to to04, to07 : timer output tool0 : data input/output for tool tool1 : clock output for tool txd1 to txd3 : transmit data v dd : power supply v lc0 to v lc3 : lcd power supply v refout : voltage reference output v ss : ground x1, x2 : crystal oscillator (main system clock) xt1, xt2 : crystal oscillator (subsystem clock) 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 7 jun 20, 2011 1.3.2 78k0r/lg3 (1) pd78f150xa ? 100-pin plastic lqfp (fine pitch) (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 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 p120/exlvi/intp0 p41/tool1 p40/tool0 p80/intp11/sck00 p81/intp9/rxd0/si00 p82/txd0/so00 p00/caph p01/capl p02/v lc3 v lc2 v lc1 v lc0 reset p124/xt2 p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss ev ss v dd ev dd p60/scl0 p61/sda0 p50/seg39/rxd3 p51/seg38/txd3 p52/seg37/ti02 p53/seg36/ti04 p54/seg35 p55/seg34 p56/seg33 p57/seg32 p90/seg31 p91/seg30 p92/seg29 p93/seg28 p94/seg27 p95/seg26 p96/seg25 p97/seg24 p140/seg23 p141/seg22 p142/seg21 p143/seg20 p144/seg19 p145/seg18 p146/seg17 p147/seg16 p100/seg15 v refout /av refp av ss av dd0 p111/ano1 p110/ano0 av dd1 com0 com1 com2 com3 com4/seg0 com5/seg1 com6/seg2 com7/seg3 seg4 seg5 seg6 seg7 seg8 seg9 seg10 seg11 seg12 seg13 seg14 p10/sck20/scl20 p11/intp6/si20/rxd2/sda20 p12/to02/so20/txd2 p13/to04/so10/txd1 p14/intp4/si10/rxd1/sda10 p15/intp7/sck10/scl10 p16/intp10/ti05/to05 p30/intp1/ti03/to00/rtc1hz p31/intp2/ti00/to03/rtcdiv/rtccl/pclbuz1 p32/intp5/ti01/to01/pclbuz0 p33/intp3/ti07/to07 p34/intp8/ti06/to06 p130 p20/ani0/amp0- p21/ani1/amp0o p22/ani2/amp0+ p23/ani3/amp1- p24/ani4/amp1o p25/ani5/amp1+ p26/ani6/amp2- p27/ani7/amp2o p150/ani8/amp2+ p151/ani9 p152/ani10 p157/ani15/av refm cautions 1. make av ss the same potential as v ss . 2. connect the regc pin to vss via a capacitor (0.47 to 1 f). 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 8 jun 20, 2011 (2) pd78f151xa ? 100-pin plastic lqfp (fine pitch) (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 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 p120/exlvi/intp0 p41/tool1 p40/tool0 p80/intp11/sck00 p81/intp9/rxd0/si00 p82/txd0/so00 p00/caph p01/capl p02/v lc3 v lc2 v lc1 v lc0 reset p124/xt2 p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss ev ss v dd ev dd p60/scl0 p61/sda0 p50/seg39/rxd3 p51/seg38/txd3 p52/seg37/ti02 p53/seg36/ti04 p54/seg35 p55/seg34 p56/seg33 p57/seg32 p90/seg31 p91/seg30 p92/seg29 p93/seg28 p94/seg27 p95/seg26 p96/seg25 p97/seg24 p140/seg23 p141/seg22 p142/seg21 p143/seg20 p144/seg19 p145/seg18 p146/seg17 p147/seg16 p100/seg15 av ref av ss av dd p111 p110 ev dd1 com0 com1 com2 com3 com4/seg0 com5/seg1 com6/seg2 com7/seg3 seg4 seg5 seg6 seg7 seg8 seg9 seg10 seg11 seg12 seg13 seg14 p10/sck20/scl20 p11/intp6/si20/rxd2/sda20 p12/to02/so20/txd2 p13/to04/so10/txd1 p14/intp4/si10/rxd1/sda10 p15/intp7/sck10/scl10 p16/intp10/ti05/to05 p30/intp1/ti03/to00/rtc1hz p31/intp2/ti00/to03/rtcdiv/rtccl/pclbuz1 p32/intp5/ti01/to01/pclbuz0 p33/intp3/ti07/to07 p34/intp8/ti06/to06 p130 p20/ani0- p21/ani1 p22/ani2 p23/ani3 p24/ani4 p25/ani5 p26/ani6 p27/ani7 p150/ani8 p151/ani9 p152/ani10 p157/ani15 cautions 1. make av ss the same potential as v ss . 2. connect the regc pin to vss via a capacitor (0.47 to 1 f). 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 9 jun 20, 2011 pin identification amp0- to amp2- : amplifier input minus amp0+ to amp2+ : amplifier input plus amp0o to amp2o : amplifier output ani0 to ani10, ani15 : analog input (adc) ano0, ado1 : analog output (dac) av ref : analog reference voltage av refm : analog reference voltage minus av refp : analog reference voltage plus av ss : analog ground av dd : analog power supply av dd0 : analog power supply (adc/vref/opamp) av dd1 : analog power supply (dac) caph, capl : capacitor for lcd com0 to com7 : lcd common output ev dd , ev dd1 : power supply for port ev ss : gnd for port exclk : external clock input (main system clock) exlvi : external potential input for low voltage detector flmd0 : flash programming mode intp0 to intp11 : external interrupt input p00 to p02 : port 0 p10 to p16 : port 1 p20 to p27 : port 2 p30 to p34 : port 3 p40, p41 : port 4 p50 to p57 : port 5 p60, p61 : port 6 p80 to p82 : port 8 p90 to p97 : port 9 p100 : port 10 p110, p111 : port 11 p120 to p124 : port 12 p130 : port 13 p140 to p147 : port 14 p150 to p152, p157 : port 15 pclbuz0, pclbuz1 : programmable clock output /buzzer output regc : regulator capacitance reset: reset rtc1hz : real-time counter correction clock (1hz) output rtccl : real-time counter clock (32 khz original oscillation) output rtcdiv : real-time counter clock (32 khz divided frequency) output rxd0 to rxd3 : receive data sck00, sck10, sck20 : serial clock input/output scl0, scl10, scl20 : se rial clock input/output sda0, sda10, sda20 : se rial data input/output seg0 to seg39 : lcd segment output si00, si10, si20 : serial data input so00, so10, so20 : serial data output ti00 to ti07 : timer input to00 to to07 : timer output tool0 : data input/output for tool tool1 : clock output for tool txd0 to txd3 : transmit data v dd : power supply v lc0 to v lc3 : lcd power supply v refout : voltage reference output v ss : ground x1, x2 : crystal oscillator (main system clock) xt1, xt2 : crystal oscillator (subsystem clock) 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 10 jun 20, 2011 1.3.3 78k0r/lh3 (1) pd78f150xa ? 128-pin plastic lqfp (fine pitch) (14 20) p120/exlvi/intp0 p77/kr7/so01 p76/kr6/si01 p75/kr5/sck01 p74/kr4 p73/kr3 p72/kr2 p71/kr1 p70/kr0 p41/tool1 p40/tool0 p80/intp11/sck00 p81/intp9/rxd0/si00 p82/txd0/so00 p83 p84/to10/ti10 p85/to11/ti11 p86/to12/ti12 p87/to13/ti13 p00/caph p01/capl p02/v lc3 v lc2 v lc1 v lc0 reset p124/xt2 p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss ev ss v dd ev dd p60/scl0 p61/sda0 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 102 101 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 75 74 73 72 71 70 69 68 67 66 65 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 v refout /av refp av ss av dd0 p111/ano1 p110/ano0 av dd1 com0 com1 com2 com3 com4/seg0 com5/seg1 com6/seg2 com7/seg3 seg4 seg5 seg6 seg7 seg8 seg9 seg10 seg11 seg12 seg13 seg14 seg15 seg16 seg17 seg18 seg19 seg20 seg21 seg22 seg23 seg24 seg25 seg26 p102/seg27 p50/seg53/rxd3 p51/seg52/txd3 p52/seg51/ti02 p53/seg50/ti04 p54/seg49 p55/seg48 p56/seg47 p57/seg46 p90/seg45 p91/seg44 p92/seg43 p93/seg42 p94/seg41 p95/seg40 p96/seg39 p97/seg38 p140/seg37 p141/seg36 p142/seg35 p143/seg34 p144/seg33 p145/seg32 p146/seg31 p147/seg30 p100/seg29 p101/seg28 p10/sck20/scl20 p11/intp6/si20/rxd2/sda20 p12/to02/so20/txd2 p13/to04/so10/txd1 p14/intp4/si10/rxd1/sda10 p15/intp7/sck10/scl10 p16/intp10/ti05/to05 p17 p30/intp1/ti03/to00/rtc1hz p31/intp2/ti00/to03/rtcdiv/rtccl/pclbuz1 p32/intp5/ti01/to01/pclbuz0 p33/intp3/ti07/to07 p34/intp8/ti06/to06 p130 p20/ani0/amp0- p21/ani1/amp0o p22/ani2/amp0+ p23/ani3/amp1- p24/ani4/amp1o p25/ani5/amp1+ p26/ani6/amp2- p27/ani7/amp2o p150/ani8/amp2+ p151/ani9 p152/ani10 p157/ani15/av refm cautions 1. make av ss the same potential as v ss . 2. connect the regc pin to vss via a capacitor (0.47 to 1 f). 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 11 jun 20, 2011 (2) pd78f151xa p120/exlvi/intp0 p77/kr7/so01 p76/kr6/si01 p75/kr5/sck01 p74/kr4 p73/kr3 p72/kr2 p71/kr1 p70/kr0 p41/tool1 p40/tool0 p80/intp11/sck00 p81/intp9/rxd0/si00 p82/txd0/so00 p83 p84/to10/ti10 p85/to11/ti11 p86/to12/ti12 p87/to13/ti13 p00/caph p01/capl p02/v lc3 v lc2 v lc1 v lc0 reset p124/xt2 p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss ev ss v dd ev dd p60/scl0 p61/sda0 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 102 101 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 75 74 73 72 71 70 69 68 67 66 65 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 av ref av ss av dd p111 p110 ev dd1 com0 com1 com2 com3 com4/seg0 com5/seg1 com6/seg2 com7/seg3 seg4 seg5 seg6 seg7 seg8 seg9 seg10 seg11 seg12 seg13 seg14 seg15 seg16 seg17 seg18 seg19 seg20 seg21 seg22 seg23 seg24 seg25 seg26 p102/seg27 p50/seg53/rxd3 p51/seg52/txd3 p52/seg51/ti02 p53/seg50/ti04 p54/seg49 p55/seg48 p56/seg47 p57/seg46 p90/seg45 p91/seg44 p92/seg43 p93/seg42 p94/seg41 p95/seg40 p96/seg39 p97/seg38 p140/seg37 p141/seg36 p142/seg35 p143/seg34 p144/seg33 p145/seg32 p146/seg31 p147/seg30 p100/seg29 p101/seg28 p10/sck20/scl20 p11/intp6/si20/rxd2/sda20 p12/to02/so20/txd2 p13/to04/so10/txd1 p14/intp4/si10/rxd1/sda10 p15/intp7/sck10/scl10 p16/intp10/ti05/to05 p17 p30/intp1/ti03/to00/rtc1hz p31/intp2/ti00/to03/rtcdiv/rtccl/pclbuz1 p32/intp5/ti01/to01/pclbuz0 p33/intp3/ti07/to07 p34/intp8/ti06/to06 p130 p20/ani0 p21/ani1 p22/ani2 p23/ani3 p24/ani4 p25/ani5 p26/ani6 p27/ani7 p150/ani8 p151/ani9 p152/ani10 p157/ani15 cautions 1. make av ss the same potential as v ss . 2. connect the regc pin to vss via a capacitor (0.47 to 1 f). 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 12 jun 20, 2011 pin identification amp0- to amp2- : amplifier input minus amp0+ to amp2+ : amplifier input plus amp0o to amp2o : amplifier output ani0 to ani10, ani15 : analog input (adc) ano0, ado1 : analog output (dac) av ref : analog reference voltage av refm : analog reference voltage minus av refp : analog reference voltage plus av ss : analog ground av dd : analog power supply av dd0 : analog power supply (adc/vref/opamp) av dd1 : analog power supply (dac) caph, capl : capacitor for lcd com0 to com7 : lcd common output ev dd , ev dd1 : power supply for port ev ss : gnd for port exclk : external clock input (main system clock) exlvi : external potential input for low voltage detector flmd0 : flash programming mode intp0 to intp11 : external interrupt input kr0 to kr7 : key return p00 to p02 : port 0 p10 to p17 : port 1 p20 to p27 : port 2 p30 to p34 : port 3 p40, p41 : port 4 p50 to p57 : port 5 p60, p61 : port 6 p70 to p77 : port 7 p80 to p87 : port 8 p90 to p97 : port 9 p100 to p102 : port 10 p110, p111 : port 11 p120 to p124 : port 12 p130 : port 13 p140 to p147 : port 14 p150 to p152, p157 : port 15 pclbuz0, pclbuz1 : programmable clock output /buzzer output regc : regulator capacitance reset: reset rtc1hz : real-time counter correction clock (1hz) output rtccl : real-time counter clock (32 khz original oscillation) output rtcdiv : real-time counter clock (32 khz divided frequency) output rxd0 to rxd3 : receive data sck00, sck01, sck10, sck20 : serial clock input/output scl0, scl10, scl20 : se rial clock input/output sda0, sda10, sda20 : se rial data input/output seg0 to seg53 : lcd segment output si00, si01, si10, si20 : serial data input so00, so01, so10, so20 : serial data output ti00 to ti07, ti10 to ti13 : timer input to00 to to07, to10 to to13 : timer output tool0 : data input/output for tool tool1 : clock output for tool txd0 to txd3 : transmit data v dd : power supply v lc0 to v lc3 : lcd power supply v refout : voltage reference output v ss : ground x1, x2 : crystal oscillator (main system clock) xt1, xt2 : crystal oscillator (subsystem clock) 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 13 jun 20, 2011 1.4 block diagram 1.4.1 78k0r/lf3 (1) pd78f1500a, 78f1501a, 78f1502a port 0 p00 to p02 3 p20 to p26 7 p30 to p33 4 v ss , ev ss flmd0 v dd , ev dd p10 to p15 6 p40, p41 2 p50 to p57 8 p140 to p147 8 ram 78k0r cpu core flash memory timer array unit0 (8ch) ch0 ch1 ti00/p31 to00/p30 ti01/to01/p32 ch2 ti02/p52 ch3 ch4 p121 to p124 4 p90 to p92 3 p110, p111 2 p130 p120 interrupt control intp1/p30, intp2/p31, intp3/p33, intp4/p14, intp5/p32, intp6/p11, intp7/p15 7 intp0/p120 rxd3/p50 (linsel) buzzer output clock output control voltage regulator regc power on clear/ low voltage indicator poc/lvi control reset control exlvi/p120 reset x1/p121 x2/exclk/p122 system control high-speed internal oscillator xt1/p123 xt2/p124 multiplier direct memory access control a/d converter ani0/p20 to ani6/p26 av dd0 av ss pclbuz0/p32, pclbuz1/p31 2 d/a converter ano0/p110, ano1/p111 av dd1 av ss 2 ch7 rxd3/p50 (linsel) ti07/to07/p33 on-chip debug tool0/p40 tool1/p41 bcd adjustment port 1 port 2 port 3 port 4 port 5 port 9 port 10 port 11 port 12 port 13 port 14 port 15 op-amp 0 amp0-/p20 ampo0/p21 amp0+/p22 op-amp 1 amp1-/p23 ampo1/p24 amp1+/p25 voltage reference v refout /av refp av refm /p157 window watchdog timer low-speed internal oscillator realtime counter serial array unit0 (2ch) uart1 rxd1/p14 txd1/p13 csi10 sck10/p15 so10/p13 si10/p14 iic10 scl10/p15 sda10/p14 rtc1hz/p30 rtcdiv/rtccl/p31 serial array unit1 (4ch) uart3 linsel rxd3/p50 txd3/p51 iic20 scl20/p10 sda20/p11 csi20 sck20/p10 so20/p12 si20/p11 rxd2/p11 txd2/p12 uart2 lcd controller/ driver ram space for lcd data seg0 to seg30 31 8 com0 to com7 v lc0 to v lc3 caph capl to02/p12 ti03/p30 to03/p31 ti04/p53 to04/p13 p100 7 p157 ch5 ch6 timer array unit1 (4ch) ch0 ch1 ch2 ch3 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 14 jun 20, 2011 (2) pd78f1510a, 78f1512a port 0 p00 to p02 3 p20 to p27 8 p30 to p34 5 v ss , ev ss flmd0 v dd , ev dd p10 to p16 7 p60, p61 2 p40, p41 2 p50 to p57 8 p140 to p147 8 ram 78k0r cpu core flash memory timer array unit0 (8ch) ch0 ch1 ti00/p31 to00/p30 ti01/to01/p32 ch2 ti02/p52 ch3 ch4 ch5 ti05/to05/p16 ch6 ti06/to06/p34 ch7 rxd3/p50 (linsel) p121 to p124 4 p90 to p97 8 p110, p111 2 p130 p120 p150 to p152, p157 4 interrupt control intp1/p30, intp2/p31, intp3/p33, intp4/p14, intp5/p32, intp6/p11, intp7/p15, intp8/p34, intp9/p81, intp10/p16, intp11/p80 11 intp0/p120 rxd3/p50 (linsel) buzzer output clock output control voltage regulator regc power on clear/ low voltage indicator poc/lvi control reset control exlvi/p120 reset x1/p121 x2/exclk/p122 system control high-speed internal oscillator xt1/p123 xt2/p124 multiplier direct memory access control a/d converter ani0/p20 to ani7/p27, ani8/p150 to ani10/p152, ani15/p157 pclbuz0/p32, pclbuz1/p31 2 ti07/to07/p33 p80 to p82 3 on-chip debug tool0/p40 tool1/p41 window watchdog timer low-speed internal oscillator realtime counter serial array unit0 (4ch) uart0 uart1 csi00 rxd0/p81 txd0/p82 rxd1/p14 txd1/p13 sck00/p80 so00/p82 si00/p81 csi10 sck10/p15 so10/p13 si10/p14 iic10 scl10/p15 sda10/p14 rtc1hz/p30 rtcdiv/rtccl/p31 serial array unit1 (4ch) uart3 linsel rxd3/p50 txd3/p51 serial interface iica sda0/p61 scl0/p60 iic20 scl20/p10 sda20/p11 csi20 sck20/p10 so20/p12 si20/p11 rxd2/p11 txd2/p12 uart2 bcd adjustment port 1 port 2 port 3 port 4 port 5 port 6 port 8 port 9 port 10 port 11 port 12 port 13 port 14 port 15 av ref lcd controller/ driver ram space for lcd data seg0 to seg39 40 8 com0 to com7 v lc0 to v lc3 caph capl to02/p12 ti03/p30 to03/p31 ti04/p53 to04/p13 p100 12 timer array unit1 (4ch) ch0 ch1 ch2 ch3 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 15 jun 20, 2011 1.4.2 78k0r/lg3 (1) pd78f1503a, 78f1504a, 78f1505a port 0 p00 to p02 3 p20 to p27 8 p30 to p34 5 v ss , ev ss flmd0 v dd , ev dd p10 to p16 7 p60, p61 2 p40, p41 2 p50 to p57 8 p140 to p147 8 ram 78k0r cpu core flash memory timer array unit0 (8ch) ch0 ch1 ti00/p31 to00/p30 ti01/to01/p32 ch2 ti02/p52 ch3 ch4 ch5 ti05/to05/p16 ch6 ti06/to06/p34 ch7 rxd3/p50 (linsel) p121 to p124 4 p90 to p97 8 p110, p111 2 p130 p120 p150 to p152, p157 4 interrupt control intp1/p30, intp2/p31, intp3/p33, intp4/p14, intp5/p32, intp6/p11, intp7/p15, intp8/p34, intp9/p81, intp10/p16, intp11/p80 11 intp0/p120 rxd3/p50 (linsel) buzzer output clock output control voltage regulator regc power on clear/ low voltage indicator poc/lvi control reset control exlvi/p120 reset x1/p121 x2/exclk/p122 system control high-speed internal oscillator xt1/p123 xt2/p124 multiplier direct memory access control a/d converter ani0/p20 to ani7/p27, ani8/p150 to ani10/p152, ani15/p157 av dd0 av ss pclbuz0/p32, pclbuz1/p31 2 d/a converter ano0/p110, ano1/p111 av dd1 av ss 2 ti07/to07/p33 p80 to p82 3 on-chip debug tool0/p40 tool1/p41 window watchdog timer low-speed internal oscillator realtime counter serial array unit0 (4ch) uart0 uart1 csi00 rxd0/p81 txd0/p82 rxd1/p14 txd1/p13 sck00/p80 so00/p82 si00/p81 csi10 sck10/p15 so10/p13 si10/p14 iic10 scl10/p15 sda10/p14 rtc1hz/p30 rtcdiv/rtccl/p31 serial array unit1 (4ch) uart3 linsel rxd3/p50 txd3/p51 serial interface iica sda0/p61 scl0/p60 iic20 scl20/p10 sda20/p11 csi20 sck20/p10 so20/p12 si20/p11 rxd2/p11 txd2/p12 uart2 bcd adjustment port 1 port 2 port 3 port 4 port 5 port 6 port 8 port 9 port 10 port 11 port 12 port 13 port 14 port 15 op-amp 0 amp0-/p20 ampo0/p21 amp0+/p22 op-amp 1 amp1-/p23 ampo1/p24 amp1+/p25 op-amp 2 amp2-/p26 ampo2/p27 amp2+/p150 voltage reference v refout /av refp av refm /p157 lcd controller/ driver ram space for lcd data seg0 to seg39 40 8 com0 to com7 v lc0 to v lc3 caph capl to02/p12 ti03/p30 to03/p31 ti04/p53 to04/p13 p100 12 timer array unit1 (4ch) ch0 ch1 ch2 ch3 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 16 jun 20, 2011 (2) pd78f1513a, 78f1515a port 0 p00 to p02 3 p20 to p27 8 p30 to p34 5 v ss , ev ss flmd0 v dd , ev dd p10 to p16 7 p60, p61 2 p40, p41 2 p50 to p57 8 p140 to p147 8 ram 78k0r cpu core flash memory timer array unit0 (8ch) ch0 ch1 ti00/p31 to00/p30 ti01/to01/p32 ch2 ti02/p52 ch3 ch4 ch5 ti05/to05/p16 ch6 ti06/to06/p34 ch7 rxd3/p50 (linsel) p121 to p124 4 p90 to p97 8 p110, p111 2 p130 p120 p150 to p152, p157 4 interrupt control intp1/p30, intp2/p31, intp3/p33, intp4/p14, intp5/p32, intp6/p11, intp7/p15, intp8/p34, intp9/p81, intp10/p16, intp11/p80 11 intp0/p120 rxd3/p50 (linsel) buzzer output clock output control voltage regulator regc power on clear/ low voltage indicator poc/lvi control reset control exlvi/p120 reset x1/p121 x2/exclk/p122 system control high-speed internal oscillator xt1/p123 xt2/p124 multiplier direct memory access control a/d converter ani0/p20 to ani7/p27, ani8/p150 to ani10/p152, ani15/p157 pclbuz0/p32, pclbuz1/p31 2 ti07/to07/p33 p80 to p82 3 on-chip debug tool0/p40 tool1/p41 window watchdog timer low-speed internal oscillator realtime counter serial array unit0 (4ch) uart0 uart1 csi00 rxd0/p81 txd0/p82 rxd1/p14 txd1/p13 sck00/p80 so00/p82 si00/p81 csi10 sck10/p15 so10/p13 si10/p14 iic10 scl10/p15 sda10/p14 rtc1hz/p30 rtcdiv/rtccl/p31 serial array unit1 (4ch) uart3 linsel rxd3/p50 txd3/p51 serial interface iica sda0/p61 scl0/p60 iic20 scl20/p10 sda20/p11 csi20 sck20/p10 so20/p12 si20/p11 rxd2/p11 txd2/p12 uart2 bcd adjustment port 1 port 2 port 3 port 4 port 5 port 6 port 8 port 9 port 10 port 11 port 12 port 13 port 14 port 15 av ref lcd controller/ driver ram space for lcd data seg0 to seg39 40 8 com0 to com7 v lc0 to v lc3 caph capl to02/p12 ti03/p30 to03/p31 ti04/p53 to04/p13 p100 12 timer array unit1 (4ch) ch0 ch1 ch2 ch3 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 17 jun 20, 2011 1.4.3 78k0r/lh3 (1) pd78f1506a, 78f1507a, 78f1508a port 0 p00 to p02 3 p20 to p27 8 p30 to p34 5 v ss , ev ss flmd0 v dd , ev dd p10 to p17 8 p60, p61 2 p70 to p77 8 p40, p41 2 p50 to p57 8 p140 to p147 8 ram 78k0r cpu core flash memory timer array unit0 (8ch) ch0 ch1 ti00/p31 to00/p30 ti01/to01/p32 ch2 ti02/p52 ch3 ch4 ch5 ti05/to05/p16 ch6 ti06/to06/p34 ch7 rxd3/p50 (linsel) p121 to p124 4 p90 to p97 8 p110, p111 2 p130 p120 p150 to p152, p157 4 interrupt control intp1/p30, intp2/p31, intp3/p33, intp4/p14, intp5/p32, intp6/p11, intp7/p15, intp8/p34, intp9/p81, intp10/p16, intp11/p80 11 intp0/p120 rxd3/p50 (linsel) buzzer output clock output control voltage regulator regc power on clear/ low voltage indicator poc/lvi control reset control key return 8 kr0/p70 to kr7/p77 exlvi/p120 reset x1/p121 x2/exclk/p122 system control high-speed internal oscillator xt1/p123 xt2/p124 multiplier direct memory access control a/d converter ani0/p20 to ani7/p27, ani8/p150 to ani10/p152, ani15/p157 av dd0 av ss pclbuz0/p32, pclbuz1/p31 2 d/a converter ano0/p110, ano1/p111 av dd1 av ss 2 ti07/to07/p33 p80 to p87 8 on-chip debug tool0/p40 tool1/p41 window watchdog timer low-speed internal oscillator realtime counter serial array unit0 (4ch) uart0 uart1 csi00 rxd0/p81 txd0/p82 rxd1/p14 txd1/p13 sck00/p80 so00/p82 si00/p81 csi10 sck10/p15 so10/p13 si10/p14 iic10 scl10/p15 sda10/p14 csi01 sck01/p75 so01/p77 si01/p76 rtc1hz/p30 rtcdiv/rtccl/p31 serial array unit1 (4ch) uart3 linsel rxd3/p50 txd3/p51 serial interface iica sda0/p61 scl0/p60 iic20 scl20/p10 sda20/p11 csi20 sck20/p10 so20/p12 si20/p11 rxd2/p11 txd2/p12 uart2 bcd adjustment port 1 port 2 port 3 port 4 port 5 port 6 port 7 port 8 port 9 port 10 p100 to p102 3 port 11 port 12 port 13 port 14 port 15 op-amp 0 amp0-/p20 ampo0/p21 amp0+/p22 op-amp 1 amp1-/p23 ampo1/p24 amp1+/p25 op-amp 2 amp2-/p26 ampo2/p27 amp2+/p150 voltage reference v refout /av refp av refm /p157 lcd controller/ driver ram space for lcd data seg0 to seg53 54 8 com0 to com7 v lc0 to v lc3 caph capl to02/p12 ti03/p30 to03/p31 ti04/p53 to04/p13 12 timer array unit1 (4ch) ch0 ch1 ti11/to11/p85 ti10/to10/p84 ch2 ti12/to12/p86 ch3 ti13/to13/p87 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 18 jun 20, 2011 (2) pd78f1516a, 78f1518a port 0 p00 to p02 3 p20 to p27 8 p30 to p34 5 v ss , ev ss flmd0 v dd , ev dd p10 to p17 8 p60, p61 2 p70 to p77 8 p40, p41 2 p50 to p57 8 p140 to p147 8 ram 78k0r cpu core flash memory timer array unit0 (8ch) ch0 ch1 ti00/p31 to00/p30 ti01/to01/p32 ch2 ti02/p52 ch3 ch4 ch5 ti05/to05/p16 ch6 ti06/to06/p34 ch7 rxd3/p50 (linsel) p121 to p124 4 p90 to p97 8 p110, p111 2 p130 p120 p150 to p152, p157 4 interrupt control intp1/p30, intp2/p31, intp3/p33, intp4/p14, intp5/p32, intp6/p11, intp7/p15, intp8/p34, intp9/p81, intp10/p16, intp11/p80 11 intp0/p120 rxd3/p50 (linsel) buzzer output clock output control voltage regulator regc power on clear/ low voltage indicator poc/lvi control reset control key return 8 kr0/p70 to kr7/p77 exlvi/p120 reset x1/p121 x2/exclk/p122 system control high-speed internal oscillator xt1/p123 xt2/p124 multiplier direct memory access control a/d converter ani0/p20 to ani7/p27, ani8/p150 to ani10/p152, ani15/p157 pclbuz0/p32, pclbuz1/p31 2 ti07/to07/p33 p80 to p87 8 on-chip debug tool0/p40 tool1/p41 window watchdog timer low-speed internal oscillator realtime counter serial array unit0 (4ch) uart0 uart1 csi00 rxd0/p81 txd0/p82 rxd1/p14 txd1/p13 sck00/p80 so00/p82 si00/p81 csi10 sck10/p15 so10/p13 si10/p14 iic10 scl10/p15 sda10/p14 csi01 sck01/p75 so01/p77 si01/p76 rtc1hz/p30 rtcdiv/rtccl/p31 serial array unit1 (4ch) uart3 linsel rxd3/p50 txd3/p51 serial interface iica sda0/p61 scl0/p60 iic20 scl20/p10 sda20/p11 csi20 sck20/p10 so20/p12 si20/p11 rxd2/p11 txd2/p12 uart2 bcd adjustment port 1 port 2 port 3 port 4 port 5 port 6 port 7 port 8 port 9 port 10 p100 to p102 3 port 11 port 12 port 13 port 14 port 15 av ref lcd controller/ driver ram space for lcd data seg0 to seg53 54 8 com0 to com7 v lc0 to v lc3 caph capl to02/p12 ti03/p30 to03/p31 ti04/p53 to04/p13 12 timer array unit1 (4ch) ch0 ch1 ti11/to11/p85 ti10/to10/p84 ch2 ti12/to12/p86 ch3 ti13/to13/p87 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 19 jun 20, 2011 1.5 outline of functions pd78f150xa (1/2) 78k0r/lf3 78k0r/lg3 78k0r/lh3 item pd78 f1500a pd78 f1501a pd78 f1502a pd78 f1503a pd78 f1504a pd78 f1505a pd78 f1506a pd78 f1507a pd78 f1508a flash memory (self-programming supported) 64 kb 96 kb 128 kb 64 kb 96 kb 128 kb 64 kb 96 kb 128 kb internal memory ram 4 kb 6kb 7kb 4 kb 6kb 7kb 4 kb 6kb 7kb memory space 1 mb high-speed system clock x1 (crystal/ceramic) oscillation, extern al main system clock input (exclk) 2 to 20 mhz: v dd = 2.7 to 5.5 v, 2 to 5 mhz: v dd = 1.8 to 5.5 v internal high-speed oscillation clock internal oscillation 1 mhz (typ.) or 8 mhz (typ.) selected by an option byte main system clock (oscillation frequency) 20 mhz internal high- speed oscillation clock internal oscillation 20 mhz (typ.) : v dd = 2.7 to 5.5 v subsystem clock (oscillation frequency) xt1 (crystal) oscillation 32.768 khz (typ.) internal low-speed oscillation clock (for wdt) internal oscillation 30 khz (typ.) general-purpose register 8 bits 32 registers (8 bits 8 registers 4 banks) 0.05 s (high-speed system clock: f mx = 20 mhz operation) 0.125 s (internal high-speed oscillation clock: f ih = 8 mhz (typ.) operation) minimum instruction execution time 30.5 s (subsystem clock: f sub = 32.768 khz operation) instruction set ? 8-bit operation, 16-bit operation ? multiply (16 bits 16 bits) ? bit manipulation (set, reset, test, and boolean operation), etc. total 51 67 83 cmos 46 60 76 i/o n-ch ? 2 2 output cmos 1 1 1 i/o port input cmos 4 4 4 timer ? 16-bit timer: 12 channels ? watchdog timer: 1 channel ? real-time counter: 1 channel timer outputs 6 (pwm output: 5 (timer array unit 0)) 8 (pwm output: 7 (timer array unit 0)) 12 (pwm output: 7 (timer array unit 0), 3 (timer array unit 1)) rtc outputs 2 ? 1 hz (subsystem clock: f sub = 32.768 khz) ? 512 hz or 16.384 khz or 32.768 khz (subsystem clock: f sub = 32.768 khz) clock output/buzzer output 2 ? 2.44 khz, 4.88 khz, 9.76 khz, 1.25 mhz, 2.5 mhz, 5 mhz, 10 mhz (peripheral hardware clock: f main = 20 mhz operation) ? 256 hz, 512 hz, 1.024 khz, 2.048 khz, 4.096 khz, 8.192 khz, 16.384 khz, 32.768 khz (subsystem clock: f sub = 32.768 khz operation) a/d converter 12-bit resolution 8 channels 12-bit resolution 12 channels d/a converter 12-bit resolution 2 channels 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 20 jun 20, 2011 pd78f150xa (2/2) 78k0r/lf3 78k0r/lg3 78k0r/lh3 item pd78 f1500a pd78 f1501a pd78 f1502a pd78 f1503a pd78 f1504a pd78 f1505a pd78 f1506a pd78 f1507a pd78 f1508a operational amplifier 2 channels 3 channels voltage reference 2.0 v/2.5 v uart supporting lin-bus 1 csi/uart/ simplified i 2 c 2 csi/uart ? 1 ? csi (2 ch) /uart ? ? 1 serial interface multimaster i 2 c ? 1 lcd controller/driver internal voltage boosting method, capacitor split method, and exter nal resistance division method are switchable. segment signal output 31 (27) note 1 40 (36) note 1 54 (50) note 1 common signal output 4 (8) note 1 multiplier/divider 16 bits 16 bits = 32 bits (multiplication), 32 bits 32 bits = 32 bits, 32-bit remainder (division) dma controller 2 channels internal 30 33 33 vectored interrupt sources external 8 12 13 key interrupt ? key interrupt (intkr) occurs by detecting falling edge of the key input pins (kr0 to kr7). reset ? reset by reset pin ? internal reset by watchdog timer ? internal reset by power-on-clear ? internal reset by low-voltage detector ? internal reset by illegal instruction execution note 2 power-on-clear circuit ? power-on-reset: 1.61 0.09 v ? power-down-reset: 1.59 0.09 v v dd voltage detector 1.91 v to 4.22 v (16 stages) low-voltage detector exlvi voltage detector 1.21 v on-chip debug function bcd adjustment provided power supply voltage v dd = 1.8 to 5.5 v operating ambient temperature t a = ? 40 to +85 c package ? 80-pin plastic lqfp (14x14) ? 80-pin plastic lqfp (fine pitch) (12x12) 100-pin plastic lqfp (fine pitch) (14x14) 128-pin plastic lqfp (fine pitch) (14x20) notes 1. the values in parentheses are the number of signal outputs when 8com is used. 2. when instruction code ffh is executed. reset by the illegal instruction execution not issued by emulation with the in-circu it emulator or on-chip debug emulator. 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 21 jun 20, 2011 pd78f151xa (1/2) 78k0r/lf3 78k0r/lg3 78k0r/lh3 item pd78 f1500a pd78 f1502a pd78 f1503a pd78 f1505a pd78 f1506a pd78 f1508a flash memory (self-programming supported) 64 kb 128 kb 64 kb 128 kb 64 kb 128 kb internal memory ram 4 kb 7kb 4 kb 7kb 4 kb 7kb memory space 1 mb high-speed system clock x1 (crystal/ceramic) oscillation, extern al main system clock input (exclk) 2 to 20 mhz: v dd = 2.7 to 5.5 v, 2 to 5 mhz: v dd = 1.8 to 5.5 v internal high-speed oscillation clock internal oscillation 1 mhz (typ.) or 8 mhz (typ.) selected by an option byte main system clock (oscillation frequency) 20 mhz internal high- speed oscillation clock internal oscillation 20 mhz (typ.) : v dd = 2.7 to 5.5 v subsystem clock (oscillation frequency) xt1 (crystal) oscillation 32.768 khz (typ.) internal low-speed oscillation clock (for wdt) internal oscillation 30 khz (typ.) general-purpose register 8 bits 32 registers (8 bits 8 registers 4 banks) 0.05 s (high-speed system clock: f mx = 20 mhz operation) 0.125 s (internal high-speed oscillation clock: f ih = 8 mhz (typ.) operation) minimum instruction execution time 30.5 s (subsystem clock: f sub = 32.768 khz operation) instruction set ? 8-bit operation, 16-bit operation ? multiply (16 bits 16 bits) ? bit manipulation (set, reset, test, and boolean operation), etc. total 51 67 83 cmos 46 60 76 i/o n-ch ? 2 2 output cmos 1 1 1 i/o port input cmos 4 4 4 timer ? 16-bit timer: 12 channels ? watchdog timer: 1 channel ? real-time counter: 1 channel timer outputs 6 (pwm output: 5 (timer array unit 0)) 8 (pwm output: 7 (timer array unit 0)) 12 (pwm output: 7 (timer array unit 0), 3 (timer array unit 1)) rtc outputs 2 ? 1 hz (subsystem clock: f sub = 32.768 khz) ? 512 hz or 16.384 khz or 32.768 khz (subsystem clock: f sub = 32.768 khz) clock output/buzzer output 2 ? 2.44 khz, 4.88 khz, 9.76 khz, 1.25 mhz, 2.5 mhz, 5 mhz, 10 mhz (peripheral hardware clock: f main = 20 mhz operation) ? 256 hz, 512 hz, 1.024 khz, 2.048 khz, 4.096 khz, 8.192 khz, 16.384 khz, 32.768 khz (subsystem clock: f sub = 32.768 khz operation) a/d converter 12-bit resolution 8 channels 12-bit resolution 12 channels 78k0r/lx3 chapter 1 outline r01uh0004ej0501 rev.5.01 22 jun 20, 2011 pd78f150xa (2/2) 78k0r/lf3 78k0r/lg3 78k0r/lh3 item pd78 f1500a pd78 f1502a pd78 f1503a pd78 f1505a pd78 f1506a pd78 f1508a uart supporting lin-bus 1 csi/uart/ simplified i 2 c 2 csi/uart ? 1 ? csi (2 ch) /uart ? ? 1 serial interface multimaster i 2 c ? 1 lcd controller/driver internal voltage boosting method, capacitor split method, and exter nal resistance division method are switchable. segment signal output 31 (27) note 1 40 (36) note 1 54 (50) note 1 common signal output 4 (8) note 1 multiplier/divider 16 bits 16 bits = 32 bits (multiplication), 32 bits 32 bits = 32 bits, 32-bit remainder (division) dma controller 2 channels internal 30 33 33 vectored interrupt sources external 8 12 13 key interrupt ? key interrupt (intkr) occurs by detecting falling edge of the key input pins (kr0 to kr7). reset ? reset by reset pin ? internal reset by watchdog timer ? internal reset by power-on-clear ? internal reset by low-voltage detector ? internal reset by illegal instruction execution note 2 power-on-clear circuit ? power-on-reset: 1.61 0.09 v ? power-down-reset: 1.59 0.09 v v dd voltage detector 1.91 v to 4.22 v (16 stages) low-voltage detector exlvi voltage detector 1.21 v on-chip debug function bcd adjustment provided power supply voltage v dd = 1.8 to 5.5 v operating ambient temperature t a = ? 40 to +85 c package ? 80-pin plastic lqfp (14x14) ? 80-pin plastic lqfp (fine pitch) (12x12) 100-pin plastic lqfp (fine pitch) (14x14) 128-pin plastic lqfp (fine pitch) (14x20) notes 1. the values in parentheses are the number of signal outputs when 8com is used. 2. when instruction code ffh is executed. reset by the illegal instruction execution not issued by emulation with the in-circu it emulator or on-chip debug emulator. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 23 jun 20, 2011 chapter 2 pin functions 2.1 pin function list there are four types of pin i/o buffer power supplies: av dd0 , av dd, av dd1 , ev dd1 , ev 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 dd0 , av dd p20 to p27, p150 to p152, p157 av dd1 , ev dd1 p110, p111 ev dd ? port pins other than p20 to p27, p110, p111, p150 to p152, p157 ? reset, flmd0 pins v dd pins other than port , reset, flmd0 pins 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 24 jun 20, 2011 2.1.1 78k0r/lf3 (1) port functions (1/2) : 78k0r/lf3 function name i/o function after reset alternate function p00 caph p01 capl p02 i/o port 0. 3-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 port v lc3 p10 sck20/scl20 p11 si20/rxd2/sda20/ intp6 p12 so20/txd2/to02 p13 so10/txd1/to04 p14 si10/rxd1/sda10/ intp4 p15 i/o port 1. 6-bit i/o port. input/output can be specified in 1-bit units. input of p10, p11, p14 and p15 can be set to ttl buffer. output of p10 to p15 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port sck10/scl10/intp7 p20 ani0/amp0- note 1 p21 ani1/amp0o note 1 p22 ani2/amp0+ note 1 p23 ani3/amp1- note 1 p24 ani4/amp1o note 1 p25 ani5/amp1+ note 1 p26 i/o port 2. 7-bit i/o port. input/output can be specified in 1-bit units. digital input port ani6 p30 ti03/to00/rtc1hz/ intp1 p31 ti00/to03/rtcdiv/ rtccl/pclbuz1/ intp2 p32 ti01/to01/intp5/ pclbuz0 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 port ti07/to07/intp3 p40 note 2 tool0 p41 i/o port 4. 2-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 port tool1 notes 1. ampxx applies to pd78f150xa only. 2. if on-chip debugging is enabled by using an option byte, be sure to pull up the p40/tool0 pin externally. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 25 jun 20, 2011 (1) port functions (2/2) : 78k0r/lf3 function name i/o function after reset alternate function p50 seg30/rxd3 p51 seg29/txd3 p52 seg28/ti02 p53 seg27/ti04 p54 to p57 i/o port 5. 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 port seg26 to seg23 p90 to p92 i/o port 9. 3-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg22 to seg20 p100 i/o port 10. 1-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg11 p110 ano0 note p111 i/o port 11. 2-bit i/o port. inputs/output can be specified in 1-bit units. input port ano1 note p120 i/o intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 input port 12. 1-bit i/o port and 4-bit input port. for only p120, input/output can be specified in 1-bit units. for only p120, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 p130 output port 13. 1-bit output port. output port ? p140 to p147 i/o port 14. 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 port seg19 to seg12 p157 i/o port 15. 1-bit i/o port. input/output can be specified in 1-bit units. digital input port ani15/av refm note note anox and av refm apply to pd78f150xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 26 jun 20, 2011 (2) non-port functions (1/4) : 78k0r/lf3 function name i/o function after reset alternate function ani0 p20/amp0- note 1 ani1 p21/amp0o note 1 ani2 p22/amp0+ note 1 ani3 p23/amp1- note 1 ani4 p24/amp1o note 1 ani5 p25/amp1+ note 1 ani6 p26 ani15 input a/d converter analog input digital input port p157/av refm note 1 amp0- note 1 p20/ani0 amp1- note 1 input operational amplifier input (negative side) digital input port p23/ani3 amp0+ note 1 p22/ani2 amp1+ note 1 input operational amplifie r input (positive side) digital input port p25/ani5 amp0o note 1 p21/ani1 amp1o note 1 output operational amplifier output digital input port p24/ani4 av refm note 1 analog negative reference voltage input digital input port p157/ani15 av refp note 1 v refout note 1 av ref note 2 input analog positive reference voltage input input ? v refout note 1 output analog reference voltage output input av refp note 1 ano0 note 1 p110 ano1 note 1 output d/a converter analog output input port p111 seg0 to seg3 com4 to com7 seg4 to seg10 ? seg11 p100 seg12 to seg19 p147 to p140 seg20 to seg22 p92 to p90 seg23 to seg26 p57 to p54 seg27 p53/ti04 seg28 p52/ti02 seg29 p51/txd3 seg30 output lcd controller/driver segment signal outputs output p50/rxd3 com0 to com3 ? com4 to com7 output lcd controller/driver common signal outputs output seg0 to seg3 v lc0 to v lc2 ? ? v lc3 ? lcd drive voltage input port p02 notes 1. ampxx, anox, av refp , av refm , and v refout apply to pd78f150xa only. 2. av ref applies to pd78f151xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 27 jun 20, 2011 (2) non-port functions (2/4) : 78k0r/lf3 function name i/o function after reset alternate function caph p00 capl ? connecting a capacitor for lcd controller/driver input port p01 exlvi input potential input for external low-voltage detection input port p120/intp0 intp0 p120/exlvi intp1 p30/ti03/to00/ rtc1hz intp2 p31/ti00/to03/ rtcdiv/rtccl/ pclbuz1 intp3 p33/ti07/to07 intp4 p14/si10/rxd1/ sda10 intp5 p32/ti01/to01/ pclbuz0 intp6 p11/si20/rxd2/ sda20 intp7 input external interrupt request input for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified input port p15/sck10/scl10 pclbuz0 p32/ti01/to01/ intp5 pclbuz1 output clock output/buzzer output input port p31/ti00/to03/ rtcdiv/rtccl/intp2 regc ? connecting regulator output (2.4 v) stabilization capacitance for internal operation. connect to v ss via a capacitor (0.47 to 1 f). ? ? rtcdiv output real-time counter clock ( 32 khz divided frequency) output input port p31/ti00/to03/ pclbuz1/rtccl/ intp2 rtccl output real-time counter clock (32 khz original oscillation) output input port p31/ti00/to03/ pclbuz1/rtcdiv/ intp2 rtc1hz output real-time counter correction clock (1 hz) output input port p30/ti03/to00/ intp1 reset input system reset input ? ? rxd1 serial data input to uart1 p14/si10/sda10/ intp4 rxd2 serial data input to uart2 p11/si20/sda20/ intp6 rxd3 input serial data input to uart3 input port p50/seg30 sck10 clock input/output for csi10 p15/scl10/intp7 sck20 i/o clock input/output for csi20 input port p10/scl20 scl10 p15/sck10/intp7 scl20 i/o clock input/output for simplified i 2 c input port p10/sck20 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 28 jun 20, 2011 (2) non-port functions (3/4) : 78k0r/lf3 function name i/o function after reset alternate function sda10 p14/si10/rxd1/ intp4 sda20 serial data i/o for simplified i 2 c p11/si20/rxd2/ intp6 si10 serial data input to csi10 p14/rxd1/sda10/ intp4 si20 i/o serial data input to csi20 input port p11/rxd2/sda20/ intp6 so10 serial data output from csi10 p13/txd1/to04 so20 output serial data output from csi20 input port p12/txd2/to02 ti00 external count clock input to 16-bit timer 00 p31/to03/rtcdiv/ rtccl/pclbuz1/ intp2 ti01 external count clock input to 16-bit timer 01 p32/to01/intp5/ pclbuz0 ti02 external count clock input to 16-bit timer 02 p52/seg28 ti03 external count clock input to 16-bit timer 03 p30/to00/rtc1hz/ intp1 ti04 external count clock input to 16-bit timer 04 p53/seg27 ti07 input external count clock input to 16-bit timer 07 input port p33/to07/intp3 to00 16-bit timer 00 output p30/ti03/rtc1hz/ intp1 to01 16-bit timer 01 output p32/ti01/intp5/ pclbuz0 to02 16-bit timer 02 output p12/so20/txd2 to03 16-bit timer 03 output p31/ti00/rtcdiv/ rtccl/pclbuz1/ intp2 to04 16-bit timer 04 output p13/so10/txd1 to07 output 16-bit timer 07 output input port p33/ti07/intp3 txd1 serial data output from uart1 p13/so10/to04 txd2 serial data output from uart2 p12/so20/to02 txd3 output serial data output from uart3 input port p51/seg29 x1 ? input port p121 x2 ? resonator connection for main system clock input port p122/exclk exclk input external clock input for ma in system clock input port p122/x2 xt1 ? input port p123 xt2 ? resonator connection for subsystem clock input port p124 v dd ? positive power supply (pins other than port and reset, flmd0 pins) ? ? ev dd ? positive power supply for reset , flmd0 pins, and port pins other than p20 to p26, p110, p111, p157 ? ? 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 29 jun 20, 2011 (2) non-port functions (4/4) : 78k0r/lf3 function name i/o function after reset alternate function av dd note 1 av dd note 2 ? positive power supply for p20 to p26, p157 ? ? av dd1 note 1 ev dd1 note 2 ? positive power supply for p110, p111 ? ? v ss ? ground potential (pins other than port and reset, flmd0 pins) ? ? ev ss ? ground potential for reset, flmd0 pins, and port pins other than p20 to p26, p110, p111, p157 ? ? av ss ? ground potential for p20 to p26, p110, p111, p157 ? ? flmd0 ? flash memory programming mode setting ? ? tool0 i/o data i/o for flash memory programmer/debugger input port p40 tool1 output clock output for debugger input port p41 notes 1. av dd0 and av dd1 apply to pd78f150xa only. 2. av dd and ev dd1 apply to pd78f151xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 30 jun 20, 2011 2.1.2 78k0r/lg3 (1) port functions (1/2) : 78k0r/lg3 function name i/o function after reset alternate function p00 caph p01 capl p02 i/o port 0. 3-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 port v lc3 p10 sck20/scl20 p11 si20/rxd2/sda20/ intp6 p12 so20/txd2/to02 p13 so10/txd1/to04 p14 si10/rxd1/sda10/ intp4 p15 sck10/scl10/intp7 p16 i/o port 1. 7-bit i/o port. input/output can be specified in 1-bit units. input of p10, p11, p14 and p15 can be set to ttl buffer. output of p10 to p15 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port ti05/to05/intp10 p20 ani0/amp0- note 1 p21 ani1/amp0o note 1 p22 ani2/amp0+ note 1 p23 ani3/amp1- note 1 p24 ani4/amp1o note 1 p25 ani5/amp1+ note 1 p26 ani6/amp2- note 1 p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani7/amp2o note 1 p30 ti03/to00/rtc1hz/ intp1 p31 ti00/to03/rtcdiv/ rtccl/pclbuz1/ intp2 p32 ti01/to01/intp5/ pclbuz0 p33 ti07/to07/intp3 p34 i/o port 3. 5-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 port ti06/to06/intp8 p40 note 2 tool0 p41 i/o port 4. 2-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 port tool1 notes 1. ampxx applies to pd78f150xa only. 2. if on-chip debugging is enabled by using an option byte, be sure to pull up the p40/tool0 pin externally. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 31 jun 20, 2011 (1) port functions (2/2) : 78k0r/lg3 function name i/o function after reset alternate function p50 seg39/rxd3 p51 seg38/txd3 p52 seg37/ti02 p53 seg36/ti04 p54 to p57 i/o port 5. 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 port seg35 to seg32 p60 scl0 p61 i/o port 6. 2-bit i/o port. output is n-ch open-drain output (6 v tolerance). input/output can be specified in 1-bit units. input port sda0 p80 sck00/intp11 p81 rxd0/si00/intp9 p82 i/o port 8. 3-bit i/o port. inputs/output can be specified in 1-bit units. output of p80 and p82 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port txd0/so00 p90 to p97 i/o port 9. 8-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg31 to seg24 p100 i/o port 10. 1-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg15 p110 ano0 note p111 i/o port 11. 2-bit i/o port. inputs/output can be specified in 1-bit units. input port ano1 note p120 i/o intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 input port 12. 1-bit i/o port and 4-bit input port. for only p120, input/output can be specified in 1-bit units. for only p120, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 p130 output port 13. 1-bit output port. output port ? p140 to p147 i/o port 14. 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 port seg23 to seg16 p150 ani8/amp2+ p151 ani9 p152 ani10 p157 i/o port 15. 4-bit i/o port. input/output can be specified in 1-bit units. digital input port ani15/av refm note note anox and av refm apply to pd78f150xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 32 jun 20, 2011 (2) non-port functions (1/4) : 78k0r/lg3 function name i/o function after reset alternate function ani0 p20/amp0- note 1 ani1 p21/amp0o note 1 ani2 p22/amp0+ note 1 ani3 p23/amp1- note 1 ani4 p24/amp1o note 1 ani5 p25/amp1+ note 1 ani6 p26/amp2- note 1 ani7 p27/amp2o note 1 ani8 p150/amp2+ note 1 ani9 p151 ani10 p152 ani15 input a/d converter analog input digital input port p157/av refm note 1 amp0- note 1 p20/ani0 amp1- note 1 p23/ani3 amp2- note 1 input operational amplifier input (negative side) digital input port p26/ani6 amp0+ note 1 p22/ani2 amp1+ note 1 p25/ani5 amp2+ note 1 input operational amplifie r input (positive side) digital input port p150/ani8 amp0o note 1 p21/ani1 amp1o note 1 p24/ani4 amp2o note 1 output operational amplifier output digital input port p27/ani7 av refm note 1 analog negative reference voltage input digital input port p157/ani15 av refp note 1 v refout note 1 av ref note 2 input analog positive reference voltage input input ? v refout note 1 output analog reference voltage output input av refp note 1 ano0 note 1 p110 ano1 note 1 output d/a converter analog output input port p111 seg0 to seg3 com4 to com7 seg4 to seg14 output ? seg15 p100 seg16 to seg23 p147 to p140 seg24 to seg31 p97 to p90 seg32 to seg35 p57 to p54 seg36 p53/ti04 seg37 p52/ti02 seg38 p51/txd3 seg39 output lcd controller/driver segment signal outputs input port p50/rxd3 notes 1. ampxx, anox, av refp , av refm , and v refout apply to pd78f150xa only. 2. am ref applies to pd78f151xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 33 jun 20, 2011 (2) non-port functions (2/4) : 78k0r/lg3 function name i/o function after reset alternate function com0 to com3 ? com4 to com7 output lcd controller/driver common signal outputs output seg0 to seg3 v lc0 to v lc2 ? ? v lc3 ? lcd drive voltage input port p02 caph p00 capl ? connecting a capacitor for lcd controller/driver input port p01 exlvi input potential input for external low-voltage detection input port p120/intp0 intp0 p120/exlvi intp1 p30/ti03/to00/ rtc1hz intp2 p31/ti00/to03/ rtcdiv/rtccl/ pclbuz1 intp3 p33/ti07/to07 intp4 p14/si10/rxd1/ sda10 intp5 p32/ti01/to01/ pclbuz0 intp6 p11/si20/rxd2/ sda20 intp7 p15/sck10/scl10 intp8 p34/ti06/to06 intp9 p81/rxd0/si00 intp10 p16/ti05/to05 intp11 input external interrupt request input for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified input port p80/sck00 pclbuz0 p32/ti01/to01/ intp5 pclbuz1 output clock output/buzzer output input port p31/ti00/to03/ rtcdiv/rtccl/intp2 regc ? connecting regulator output (2.4 v) stabilization capacitance for internal operation. connect to v ss via a capacitor (0.47 to 1 f). ? ? rtcdiv output real-time counter clock ( 32 khz divided frequency) output input port p31/ti00/to03/ pclbuz1/rtccl/ intp2 rtccl output real-time counter clock (32 khz original oscillation) output input port p31/ti00/to03/ pclbuz1/rtcdiv/ intp2 rtc1hz output real-time counter correction clock (1 hz) output input port p30/ti03/to00/ intp1 reset input system reset input ? ? 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 34 jun 20, 2011 (2) non-port functions (3/4) : 78k0r/lg3 function name i/o function after reset alternate function rxd0 serial data input to uart0 p81/si00/intp9 rxd1 serial data input to uart1 p14/si10/sda10/ intp4 rxd2 serial data input to uart2 p11/si20/sda20/ intp6 rxd3 input serial data input to uart3 input port p50/seg39 sck00 clock input/output for csi00 p80/intp11 sck10 clock input/output for csi10 p15/scl10/intp7 sck20 i/o clock input/output for csi20 input port p10/scl20 scl0 i/o clock input/output for i 2 c input port p60 scl10 p15/sck10/intp7 scl20 i/o clock input/output for simplified i 2 c input port p10/sck20 sda0 i/o serial data i/o for i 2 c input port p61 sda10 p14/si10/rxd1/ intp4 sda20 i/o serial data i/o for simplified i 2 c input port p11/si20/rxd2/ intp6 si00 serial data input to csi00 p81/rxd0/intp9 si10 serial data input to csi10 p14/rxd1/sda10/ intp4 si20 input serial data input to csi20 input port p11/rxd2/sda20/ intp6 so00 serial data output from csi00 p82/txd0 so10 serial data output from csi10 p13/txd1/to04 so20 output serial data output from csi20 input port p12/txd2/to02 ti00 external count clock input to 16-bit timer 00 p31/to03/rtcdiv/ rtccl/pclbuz1/ intp2 ti01 external count clock input to 16-bit timer 01 p32/to01/intp5/ pclbuz0 ti02 external count clock input to 16-bit timer 02 p52/seg37 ti03 external count clock input to 16-bit timer 03 p30/to00/rtc1hz/ intp1 ti04 external count clock input to 16-bit timer 04 p53/seg36 ti05 external count clock input to 16-bit timer 05 p16/to05/intp10 ti06 external count clock input to 16-bit timer 06 p34/to06/intp8 ti07 input external count clock input to 16-bit timer 07 input port p33/to07/intp3 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 35 jun 20, 2011 (2) non-port functions (4/4) : 78k0r/lg3 function name i/o function after reset alternate function to00 16-bit timer 00 output p30/ti03/rtc1hz/ intp1 to01 16-bit timer 01 output p32/ti01/intp5/ pclbuz0 to02 16-bit timer 02 output p12/so20/txd2 to03 16-bit timer 03 output p31/ti00/rtcdiv/ rtccl/pclbuz1/ intp2 to04 16-bit timer 04 output p13/so10/txd1 to05 16-bit timer 05 output p16/ti05/intp10 to06 16-bit timer 06 output p34/ti06/intp8 to07 output 16-bit timer 07 output input port p33/ti07/intp3 txd0 serial data output from uart0 p82/so00 txd1 serial data output from uart1 p13/so10/to04 txd2 serial data output from uart2 p12/so20/to02 txd3 output serial data output from uart3 input port p51/seg38 x1 ? input port p121 x2 ? resonator connection for main system clock input port p122/exclk exclk input external clock input for ma in system clock input port p122/x2 xt1 ? input port p123 xt2 ? resonator connection for subsystem clock input port p124 v dd ? positive power supply (pins other than port and reset, flmd0 pins) ? ? ev dd ? positive power supply for reset , flmd0 pins, and port pins other than p20 to p27, p110, p111, p150 to p152, p157 ? ? av dd note 1 av dd note 2 ? positive power supply for p20 to p27, p150 to p152, p157 ? ? av dd1 note 1 ev dd1 note 2 ? positive power supply for p110, p111 ? ? v ss ? ground potential (pins other than port and reset, flmd0 pins) ? ? ev ss ? ground potential for reset, flmd0 pins, and port pins other than p20 to p27, p110, p111, p150 to p152, p157 ? ? av ss ? ground potential for p20 to p27, p110, p111, p150 to p152, p157 ? ? flmd0 ? flash memory programming mode setting ? ? tool0 i/o data i/o for flash memory programmer/debugger input port p40 tool1 output clock output for debugger input port p41 notes 1. av dd0 and av dd1 apply to pd78f150xa only. 2. av dd and ev dd1 apply to pd78f151xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 36 jun 20, 2011 2.1.3 78k0r/lh3 (1) port functions (1/3) : 78k0r/lh3 function name i/o function after reset alternate function p00 caph p01 capl p02 i/o port 0. 3-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 port v lc3 p10 sck20/scl20 p11 si20/rxd2/sda20/ intp6 p12 so20/txd2/to02 p13 so10/txd1/to04 p14 si10/rxd1/sda10/ intp4 p15 sck10/scl10/intp7 p16 ti05/to05/intp10 p17 i/o port 1. 8-bit i/o port. input/output can be specified in 1-bit units. input of p10, p11, p14 and p15 can be set to ttl buffer. output of p10 to p15 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port ? p20 ani0/amp0- note 1 p21 ani1/amp0o note 1 p22 ani2/amp0+ note 1 p23 ani3/amp1- note 1 p24 ani4/amp1o note p25 ani5/amp1+ note 1 p26 ani6/amp2- note 1 p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani7/amp2o note 1 p30 ti03/to00/rtc1hz/ intp1 p31 ti00/to03/rtcdiv/ rtccl/pclbuz1/ intp2 p32 ti01/to01/intp5/ pclbuz0 p33 ti07/to07/intp3 p34 i/o port 3. 5-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 port ti06/to06/intp8 p40 note 2 tool0 p41 i/o port 4. 2-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 port tool1 notes 1. ampxx applies to pd78f150xa only. 2. if on-chip debugging is enabled by using an option byte, be sure to pull up the p40/tool0 pin externally. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 37 jun 20, 2011 (1) port functions (2/3) : 78k0r/lh3 function name i/o function after reset alternate function p50 seg53/rxd3 p51 seg52/txd3 p52 seg51/ti02 p53 seg50/ti04 p54 to p57 i/o port 5. 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 port seg49 to seg46 p60 scl0 p61 i/o port 6. 2-bit i/o port. output is n-ch open-drain output (6 v tolerance). input/output can be specified in 1-bit units. input port sda0 p70 to p74 kr0 to kr4 p75 kr5/sck01 p76 kr6/si01 p77 i/o port 7. 8-bit i/o port. input/output can be specified in 1-bit units. input of p75 and p76 can be set to ttl buffer. output of p75 and p77 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port kr7/so01 p80 sck00/intp11 p81 rxd0/si00/intp9 p82 txd0/so00 p83 ? p84 ti10/to10 p85 ti11/to11 p86 ti12/to12 p87 i/o port 8. 8-bit i/o port. inputs/output can be specified in 1-bit units. output of p80 and p82 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port ti13/to13 p90 to p97 i/o port 9. 8-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg45 to seg38 p100 to p102 i/o port 10. 3-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg29 to seg27 p110 ano0 note p111 i/o port 11. 2-bit i/o port. inputs/output can be specified in 1-bit units. input port ano1 note p120 i/o intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 input port 12. 1-bit i/o port and 4-bit input port. for only p120, input/output can be specified in 1-bit units. for only p120, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 p130 output port 13. 1-bit output port. output port ? note anox applies to pd78f150xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 38 jun 20, 2011 (1) port functions (3/3) : 78k0r/lh3 function name i/o function after reset alternate function p140 to p147 i/o port 14. 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 port seg37 to seg30 p150 ani8/amp2+ note p151 ani9 p152 ani10 p157 i/o port 15. 4-bit i/o port. input/output can be specified in 1-bit units. digital input port ani15/av refm note note amp2+ and av refm apply to pd78f150xa only. (2) non-port functions (1/5) : 78k0r/lh3 function name i/o function after reset alternate function ani0 p20/amp0- note 1 ani1 p21/amp0o note 1 ani2 p22/amp0+ note 1 ani3 p23/amp1- note 1 ani4 p24/amp1o note 1 ani5 p25/amp1+ note 1 ani6 p26/amp2- note 1 ani7 p27/amp2o note 1 ani8 p150/amp2+ note 1 ani9 p151 ani10 p152 ani15 input a/d converter analog input digital input port p157/av refm note 1 amp0- note 1 p20/ani0 amp1- note 1 p23/ani3 amp2- note 1 input operational amplifier input (negative side) digital input port p26/ani6 amp0+ note 1 p22/ani2 amp1+ note 1 p25/ani5 amp2+ note 1 input operational amplifie r input (positive side) digital input port p150/ani8 amp0o note 1 p21/ani1 amp1o note 1 p24/ani4 amp2o note 1 output operational amplifier output digital input port p27/ani7 av refm note 1 analog negative reference voltage input digital input port p157/ani15 av refp note 1 v refout note 1 av ref note 2 input analog positive reference voltage input input ? v refout note 1 output analog reference voltage output input av refp note 1 ano0 note 1 p110 ano1 note 1 output d/a converter analog output input port p111 notes 1. ampxx, anox, av refp , av refm , and av refout apply to pd78f150xa only. 2. av ref applies to pd78f151xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 39 jun 20, 2011 (2) non-port functions (2/5) : 78k0r/lh3 function name i/o function after reset alternate function seg0 to seg3 com4 to com7 seg4 to seg26 ? seg27 to seg29 p102 to p100 seg30 to seg37 p147 to p140 seg38 to seg45 p97 to p90 seg46 to seg49 p57 to p54 seg50 p53/ti04 seg51 p52/ti02 seg52 p51/txd3 seg53 output lcd controller/driver segment signal outputs output p50/rxd3 com0 to com3 ? com4 to com7 output lcd controller/driver common signal outputs output seg0 to seg3 v lc0 to v lc2 ? ? v lc3 ? lcd drive voltage input port p02 caph p00 capl ? connecting a capacitor for lcd controller/driver input port p01 exlvi input potential input for external low-voltage detection input port p120/intp0 intp0 p120/exlvi intp1 p30/ti03/to00/ rtc1hz intp2 p31/ti00/to03/ rtcdiv/rtccl/ pclbuz1 intp3 p33/ti07/to07 intp4 p14/si10/rxd1/ sda10 intp5 p32/ti01/to01/ pclbuz0 intp6 p11/si20/rxd2/ sda20 intp7 p15/sck10/scl10 intp8 p34/ti06/to06 intp9 p81/rxd0/si00 intp10 p16/ti05/to05 intp11 input external interrupt request input for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified input port p80/sck00 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 40 jun 20, 2011 (2) non-port functions (3/5) : 78k0r/lh3 function name i/o function after reset alternate function kr0 to kr4 p70-p74 kr5 p75/sck01 kr6 p76/si01 kr7 input key interrupt input input port p77/so01 pclbuz0 p32/ti01/to01/ intp5 pclbuz1 output clock output/buzzer output input port p31/ti00/to03/ rtcdiv/rtccl/intp2 regc ? connecting regulator output (2.4 v) stabilization capacitance for internal operation. connect to v ss via a capacitor (0.47 to 1 f). ? ? rtcdiv output real-time counter clock ( 32 khz divided frequency) output input port p31/ti00/to03/ pclbuz1/rtccl/ intp2 rtccl output real-time counter clock (32 khz original oscillation) output input port p31/ti00/to03/ pclbuz1/rtcdiv/ intp2 rtc1hz output real-time counter correction clock (1 hz) output input port p30/ti03/to00/ intp1 reset input system reset input ? ? rxd0 serial data input to uart0 p81/si00/intp9 rxd1 serial data input to uart1 p14/si10/sda10/ intp4 rxd2 serial data input to uart2 p11/si20/sda20/ intp6 rxd3 input serial data input to uart3 input port p50/seg53 sck00 clock input/output for csi00 p80/intp11 sck01 clock input/output for csi01 p75/kr5 sck10 clock input/output for csi10 p15/scl10/intp7 sck20 i/o clock input/output for csi20 input port p10/scl20 scl0 i/o clock input/output for i 2 c input port p60 scl10 p15/sck10/intp7 scl20 i/o clock input/output for simplified i 2 c input port p10/sck20 sda0 i/o serial data i/o for i 2 c input port p61 sda10 p14/si10/rxd1/ intp4 sda20 i/o serial data i/o for simplified i 2 c input port p11/si20/rxd2/ intp6 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 41 jun 20, 2011 (2) non-port functions (4/5) : 78k0r/lh3 function name i/o function after reset alternate function si00 serial data input to csi00 p81/rxd0/intp9 si01 serial data input to csi01 p76/kr6 si10 serial data input to csi10 p14/rxd1/sda10/ intp4 si20 input serial data input to csi20 input port p11/rxd2/sda20/ intp6 so00 serial data output from csi00 p82/txd0 so01 serial data output from csi01 p77/kr7 so10 serial data output from csi10 p13/txd1/to04 so20 output serial data output from csi20 input port p12/txd2/to02 ti00 external count clock input to 16-bit timer 00 p31/to03/rtcdiv/ rtccl/pclbuz1/ intp2 ti01 external count clock input to 16-bit timer 01 p32/to01/intp5/ pclbuz0 ti02 external count clock input to 16-bit timer 02 p52/seg51 ti03 external count clock input to 16-bit timer 03 p30/to00/rtc1hz/ intp1 ti04 external count clock input to 16-bit timer 04 p53/seg50 ti05 external count clock input to 16-bit timer 05 p16/to05/intp10 ti06 external count clock input to 16-bit timer 06 p34/to06/intp8 ti07 external count clock input to 16-bit timer 07 p33/to07/intp3 ti10 external count clock input to 16-bit timer 10 p84/to10 ti11 external count clock input to 16-bit timer 11 p85/to11 ti12 external count clock input to 16-bit timer 12 p86/to12 ti13 input external count clock input to 16-bit timer 13 input port p87/to13 to00 16-bit timer 00 output p30/ti03/rtc1hz/ intp1 to01 16-bit timer 01 output p32/ti01/intp5/ pclbuz0 to02 16-bit timer 02 output p12/so20/txd2 to03 16-bit timer 03 output p31/ti00/rtcdiv/ rtccl/pclbuz1/ intp2 to04 16-bit timer 04 output p13/so10/txd1 to05 16-bit timer 05 output p16/ti05/intp10 to06 16-bit timer 06 output p34/ti06/intp8 to07 output 16-bit timer 07 output input port p33/ti07/intp3 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 42 jun 20, 2011 (2) non-port functions (5/5) : 78k0r/lh3 function name i/o function after reset alternate function to10 16-bit timer 10 output p84/ti10 to11 16-bit timer 11 output p85/ti11 to12 16-bit timer 12 output p86/ti12 to13 output 16-bit timer 13 output input port p87/ti13 txd0 serial data output from uart0 p82/so00 txd1 serial data output from uart1 p13/so10/to04 txd2 serial data output from uart2 p12/so20/to02 txd3 output serial data output from uart3 input port p51/seg52 x1 ? input port p121 x2 ? resonator connection for main system clock input port p122/exclk exclk input external clock input for ma in system clock input port p122/x2 xt1 ? input port p123 xt2 ? resonator connection for subsystem clock input port p124 v dd ? positive power supply (pins other than port and reset, flmd0 pins) ? ? ev dd ? positive power supply for reset , flmd0 pins, and port pins other than p20 to p27, p110, p111, p150 to p152, p157 ? ? av dd , note 1 av dd note 2 ? positive power supply for p20 to p27, p150 to p152, p157 ? ? av dd1 note 1 ev dd1 note 2 ? positive power supply for p110, p111 ? ? v ss ? ground potential (pins other than port and reset, flmd0 pins) ? ? ev ss ? ground potential for reset, flmd0 pins, and port pins other than p20 to p27, p110, p111, p150 to p152, p157 ? ? av ss ? ground potential for p20 to p27, p110, p111, p150 to p152, p157 ? ? flmd0 ? flash memory programming mode setting ? ? tool0 i/o data i/o for flash memory programmer/debugger input port p40 tool1 output clock output for debugger input port p41 notes 1. av dd0 and av dd1 apply to pd78f150xa only. 2. av dd and ev dd1 apply to pd78f151xa only. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 43 jun 20, 2011 2.2 description of pin functions remark the pins mounted depend on the product. refer to 1.3 pin configuration (top view) and 2.1 pin function list . 2.2.1 p00 to p02 p00 to p02 function as an i/o port. this port can also be us ed for connecting a capacitor for lcd controller/driver, and power supply voltage pin for driving the lcd. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p00/caph p01/capl p02/v lc3 the following operation modes can be specified in 1-bit units. (1) port mode p00 to p02 function as an i/o port. p00 to p02 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 p02 function as connecting a capacitor for lcd contro ller/driver, and power supply voltage pin for driving the lcd. (a) caph, capl these are the pins for connecting a capacitor for lcd controller/driver. (b) v lc3 this is the pin for inputting a power supply voltage pin for driving the lcd. caution to use p00/caph, p01/capl, and p02/v lc3 as a general-purpose port, set bit 5 (mdset1) and bit 4 (mdset0) of lcd mode register (lcdmd) to ?0?, which is the same as their default status setting. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 44 jun 20, 2011 2.2.2 p10 to p17 p10 to p17 function as an i/o port. this port can also be us ed for external interrupt request input, serial interface data i/o, clock i/o, and timer i/o. input to the p10, p11, p14, and p15 pins can be specified through a normal input buffer or a ttl input buffer in 1-bit units using port input mode register 1 (pim1). output from the p10-p15 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 1 (pom1). 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p10/sck20/scl20 p11/si20/rxd2/sda20/intp6 p12/so20/txd2/to02 p13/so10/txd1/to04 p14/si10/rxd1/sda10/intp4 p15/sck10/scl10/intp7 p16/ti05/to05/intp10 ? p17 ? ? the following operation modes can be specified in 1-bit units. (1) port mode p10 to p17 function as an i/o port. p10 to p17 can be set to input or output port 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 serial interface clock i/o, data i/o, timer i/o, and exter nal interrupt request input. (a) sck10, sck20 these are serial clock i/o pin of se rial interface csi10 and csi20. (b) si10, si20 these are serial data input pin of serial interface csi10 and csi20. (c) so10, so20 these are serial data output pin of serial interface csi10 and csi20. (d) scl10, scl20 these are serial clock i/o pin of serial interface iic10 and iic20 (simplified i 2 c). (e) sda10, sda20 these are serial data i/o pin of serial interface iic10 and iic20 (simplified i 2 c). (f) rxd1, rxd2 these are serial data input pin of serial interface uart1 and uart2. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 45 jun 20, 2011 (g) txd1, txd2 these are serial data output pin of serial interface uart1 and uart2. (h) ti05 this is a timer input pin of 16-bit timer 05. (i) to02, to04, to05 these are the timer output pins of 16-bit timers 02, 04, and 05. (j) intp4, intp6, intp7, intp10 these are the external interrupt request input pins for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. cautions 1. to use p10/sck20/scl2 0 and p11/si20/rxd2/sda20/intp6 as a general-purpose port, note the serial array unit 1 setting. for de tails, refer to table 14-9 relati onship between register settings and pins (channel 0 of unit 1: csi20, uart2 reception, iic20). 2. to use p12/to02/so20/txd2 as a general-purpose port, set bit 2 (to02) of timer output register 0 (to0) and bit 2 (toe02) of timer output enable re gister 0 (toe0) to ?0?, which is the same as their default status setting. and as a general-pur pose port, note the serial array unit 1 setting. for details of serial array unit 1 setting, refer to table 14-9 relationship between register settings and pins (channel 0 of unit 1: csi20, uart2 reception, iic20). 3. to use p13/to04/so10/txd1 as a general-purpose port, set bit 4 (to04) of timer output register 0 (to0) and bit 4 (toe04) of timer output enable re gister 0 (toe0) to ?0?, which is the same as their default status setting. and as a general-pur pose port, note the serial array unit 0 setting. for details of serial array unit 0 setting, refer to table 14-7 relationship between register settings and pins (channel 2 of unit 0: csi10, uart1 transmission, iic10) 4. to use p14/si10/rxd1/sda10/intp4 and p15/ sck10/scl10/intp7 as a general-purpose port, note the serial array unit 0 setting. for details, refer to table 14- 7 relationship between register settings and pins (channel 2 of unit 0: csi10, uart1 transmission, iic10) 5. to use p16/to05/ti05/intp10 as a general-purpose po rt, set bit 5 (to05) of timer output register 0 (to0) and bit 5 (toe05) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 46 jun 20, 2011 2.2.3 p20 to p27 p20 to p27 function as an i/o port. this port can also be us ed for a/d converter analog i nput, and operatio nal amplifier i/o. pd78f150xa pd78f151xa 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) p20/ani0/amp0- p20/ani0 p21/ani1/amp0o p20/ani1 p22/ani2/amp0+ p20/ani2 p23/ani3/amp1- p20/ani3 p24/ani4/amp1o p20/ani4 p25/ani5/amp1+ p20/ani5 p26/ani6/amp2- p26/ani6 p26/ani6 p27/ani7/amp2o ? ? p27/ani7 the following operation modes can be specified in 1-bit units. (1) port mode p20 to p27 function as an i/o port. p20 to p27 can be set to input or output port in 1-bit units using port mode register 2 (pm2). (2) control mode p20 to p27 function as a/d converter analog input and operational amplifier i/o. (a) ani0 to ani7 these are a/d converter analog input pins. (b) amp0-, amp1-, amp2- these are pins that the input voltage on the negative side of operational amplifiers 0 to 2. (c) amp0+, amp1+ these are pins that the input voltage on the positive side of oper ational amplifiers 0 and 1. (d) amp0o, amp1o, amp2o these are operational amplif iers 0 to 2 output pins. cautions 1. p20/ani0/amp0- to p27/ ani7/anp2o are set in the digital in put (general-purpose port) mode after release of reset. 2. when using at least one port of ports p20/ani0/amp0- to p 27/ani7/anp2o as a digital port, set av dd0 to the same potential as ev dd or v dd . 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 47 jun 20, 2011 2.2.4 p30 to p34 p30 to p34 function as an i/o port. this port can also be used for timer i/o, real -time counter clock output, correction clock output, clock output/buzzer output, a nd external interrupt request input. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p30/ti03/to00/rtc1hz/intp1 p31/ti00/to03/rtcdiv/rtccl/ pclbuz1/intp2 p32/ti01/to01/pclbuz0/intp5 p33/ti07/to07/ intp3 p34/ti06/to06/ intp8 ? the following operation modes can be specified in 1-bit units. (1) port mode p30 to p34 function as an i/o port. p30 to p34 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 p34 function as timer i/o, real-time counter clo ck output, correction clock outpu t, clock output/buzzer output, and external interrupt request input. (a) ti00, ti01, ti03 ti06, ti07 these are the timer input pins of 16-bit timers 00, 01, 03, 06, and 07. (b) to00, to01, to03, to06, to07 these are the timer output pins of 16-bit timers 00, 01, 03, 06, and 07. (c) rtccl this is a real-time counter clock (32 kh z, original oscillation) output pin. (d) rtcdiv this is a real-time counter clo ck (32 khz, divided) output pin. (e) rtc1hz this is a real-time counter correction clock (1 hz) output pin. (f) pclbuz0, pclbuz1 these are clock output/buzzer output pins. (g) intp1, intp2, intp3, intp5, intp8 these are the external interrupt request input pins for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 48 jun 20, 2011 cautions 1. to use p30/to00/ti03/rt c1hz/intp1 as a general-purpose port, set bit 5 (rcloe1) of real-time counter control register 0 (rtcc0), bit 0 (to00) of timer output register 0 (to0) and bit 0 (toe00) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 2. to use p31/to03/ti00/rtcdi v/rtccl/pclbuz1/intp2 as a general-purpose port, set bit 4 (rcloe0) of real-time counter control register 0 (rtcc0), bit 6 (rcloe2) of real-time counter control register 2 (rtcc2), bit 3 (to03) of timer output register 0 (to0), bit 3 (toe03) of timer output enable register 0 (toe0) and bit 7 of clock output select register 1 (cks1) to ?0?, which is the same as their default status setting. 3. to use p32/to01/ti01/intp5/pcl buz0 as a general-purpose port, set bit 1 (to01) of timer output register 0 (to0), bit 1 (toe01) of timer output en able register 0 (toe0) and bit 7 of clock output select register 0 (cks0) to ?0?, which is the same as their default status setting. 4. to use p33/to07/ti07/intp3 and p34/to06/ti06/intp8 as a gene ral-purpose port, set bit 7, 6 (to07, to06) of timer output regist er 0 (to0), and bit 7, 6 (toe07, toe06) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 2.2.5 p40, p41 p40 and p41 function as an i/o port. these pins also function as data i/o for a flash memory programmer/debugger and clock output for a debugger. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p40/tool0 p41/tool1 the following operation modes can be specified in 1-bit units. (1) port mode p40 and p41 function as an i/o port. p 40 and p41 can be set to in put or output port in 1- bit units using port mode register 4 (pm4). use of an on-chip pull-up resistor can be specified by pull-up resistor option register 4 (pu4). be sure to connect an external pull-up resistor to p40 when on-chip debugging is enabled (by using an option byte). (2) control mode p40 and p41 function as data i/o for a flash memory programmer/debugger and clock output for a debugger. (a) tool0 this is a data i/o pin for a flash memory programmer/debugger. be sure to pull up this pin externally when on-chip debugging is enabled (pulling it down is prohibited). 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 49 jun 20, 2011 (b) tool1 this is a clock output pin for a debugger. when the on-chip debug function is us ed, p41/tool1 pin can be used as fo llows by the mode setting on the debugger. 1-line mode: can be used as a port (p41). 2-line mode: used as a tool1 pin a nd cannot be used as a port (p41). caution the function of the p40/tool0 pin var ies as described in (a) to (c) below. in the case of (b) or (c), make the specified connection. (a) in normal operation mode and when on-chip debugging is disabled (ocdenset = 0) by an option byte (000c3h) => use this pin as a port pin (p40). (b) in normal operation mode and when on-chip debugging is enabled (ocdenset = 1) by an option byte (000c3h) => connect this pin to v dd via an external resistor, and a lways input a high level to the pin before reset release. (c) when on-chip debug functi on is used, or in write mode of flash memory programmer => use this pin as tool0. directly connect this pin to the on-chip debug emulator or a flas h memory programmer, or pull it up by connecting it to v dd via an external resistor. 2.2.6 p50 to p57 p50 to p57 function as an i/o port. this port can also be used for serial interface data i/o, timer input, and segment output of lcd controller/driver. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p50/rxd3/segxx (xx = 30) ( xx = 39) ( xx = 53) p51/txd3/segxx ( xx = 29) ( xx = 38) ( xx = 52) p52/ti02/segxx ( xx = 28) ( xx = 37) ( xx = 51) p53/ti04/segxx ( xx = 27) ( xx = 36) ( xx = 50) p54/segxx ( xx = 26) ( xx = 35) ( xx = 49) p55/segxx ( xx = 25) ( xx = 34) ( xx = 48) p56/segxx ( xx = 24) ( xx = 33) ( xx = 47) p57/segxx ( xx = 23) ( xx = 32) ( xx = 46) the following operation modes can be specified in 1-bit units. (1) port mode p50 to p57 function as an i/o port. p50 to p57 can be set to input or output port in 1-bit units using port mode register 5 (pm5). use of an on-chip pull-up resistor can be specified by pull-up resistor option register 5 (pu5). 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 50 jun 20, 2011 (2) control mode p50 to p57 function as serial interface data i/o, time r input, and segment output of lcd controller/driver. (a) rxd3 this is a serial data input pi n of serial interface uart3. (b) txd3 this is a serial data output pin of serial interface uart3. (c) ti02, ti04 these are the timer input pins of 16-bit timers 02 and 04. (d) segxx this is a segment output pin of lcd controller/driver. 2.2.7 p60, p61 p60 and p61 function as an i/o port. this port can al so be used for s serial interface iica data i/o and clock i/o. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p60/scl0 ? p61/sda0 ? the following operation modes can be specified in 1-bit units. (1) port mode p60 and p61 function as an i/o port. p60 and p61 can be set to input port or output port in 1-bit units using port mode register 6 (pm6). output of p60 and p61 is n-ch open- drain output (6 v tolerance). (2) control mode p60 and p61 function as serial interface iica clock i/o and data i/o. (a) scl0 this is a serial clock i/o pi n of serial interface iica. (b) sda0 this is a serial data i/o pin of serial interface iica. caution when using p60/scl0 and p61/sda0 as a ge neral-purpose port, stop the operation of serial interface iica. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 51 jun 20, 2011 2.2.8 p70 to p77 p70 to p77 function as an i/o port. this port can also be us ed for key return in put, serial interface clock i/o, and data i/o. input to the p75, and p76 pins can be specified through a no rmal input buffer or a ttl input buffer in 1-bit units using port input mode register 7 (pim7). output from the p75, and p77 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 7 (pom7). 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p70/kr0 ? p71/kr1 ? p72/kr2 ? p73/kr3 ? p74/kr4 ? p75/sck01 ? p76/kr6/si01 ? p77/kr7/so01 ? the following operation modes can be specified in 1-bit units. (1) port mode p70 to p77 function as an i/o port. p70 to p77 can be set to input or output port 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 in put, serial interface clock i/o, and data i/o. (a) kr0 to kr7 these are the key return input pins (b) sck01 this is a clock i/o pin of serial interface csi01. (c) si01 this is a serial data input pi n of serial interface csi01. (d) so01 this is a serial data output pin of serial interface csi01. caution to use p75/sck01/kr5, p76/ si01/kr6, and p77/so01/kr7, as a gene ral-purpose port, note the serial array unit 0 setting. for details, refer to table 14- 6 relationship between regi ster settings and pins (channel 1 of unit 0: csi01, uart0 reception). 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 52 jun 20, 2011 2.2.9 p80 to p87 p80 to p87 function as an i/o port. this port can also be used for serial interface clock i/o, data i/o, timer i/o, and external interrupt request input. output from the p80 and p82 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 8 (pom8). 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p80/sck00/intp11 ? p81/rxd0/si00/intp9 ? p82/txd0/so00 ? p83 ? ? p84/to10/ti10 ? ? p85/to11/ti11 ? ? p86/to12/ti12 ? ? p87/to13/ti13 ? ? the following operation modes can be specified in 1-bit units. (1) port mode p80 to p87 function as an i/o port. p80 to p87 can be set to input or output port in 1-bit units using port mode register 8 (pm8). use of an on-chip pull-up resistor can be specified by pull-up resistor option register 8 (pu8). (2) control mode p80 to p87 function as serial interface clock i/o, data i/o, timer i/o, and exter nal interrupt request input. (a) sck00 this is a clock i/o pin of serial interface csi00. (b) si00 this is a serial data input pi n of serial interface csi00. (c) so00 this is a serial data output pin of serial interface csi00. (d) rxd0 this is a serial data input pin for serial interface uart0. (e) txd0 this is a serial data output pin for serial interface uart0. (f) ti10 to ti13 these are the timer input pins of 16-bit timers 10 to 13. (g) to10 to to13 these are the timer output pins of 16-bit timers 10 to 13. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 53 jun 20, 2011 (h) intp9, intp11 these are the external interrupt request input pins for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. caution to use p80/sck00/intp11, p81/rxd0/si00/in tp9, and p82/so00/txd0, as a general-purpose port, note the serial array unit 0 setting. for details, re fer to table 14-5 relationship between register settings and pins (channel 0 of unit 0: csi00, uart0 reception). 2.2.10 p90 to p97 p90 to p97 function as an i/o port. this port can also be used for segment output of lcd controller/driver. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p90/segxx (xx = 22) (xx = 31) (xx = 45) p91/segxx (xx = 21) (xx = 30) (xx = 44) p92/segxx (xx = 20) (xx = 29) (xx = 43) p93/segxx ? (xx = 28) (xx = 42) p94/segxx ? (xx = 27) (xx = 41) p95/segxx ? (xx = 26) (xx = 40) p96/segxx ? (xx = 25) (xx = 39) p97/segxx ? (xx = 24) (xx = 38) the following operation modes can be specified in 1-bit units. (1) port mode p90 to p97 function as an i/o port. p90 to p97 can be set to input or output port in 1-bit units using port mode register 9 (pm9). use of an on-chip pull-up resistor can be specified by pull-up resistor option register 9 (pu9). (2) control mode p90 to p97 function as segment output of lcd controller/driver (segxx). 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 54 jun 20, 2011 2.2.11 p100 to p102 p100 to p102 function as an i/o port. this port can also be used for segment output of lcd controller/driver. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p100/segxx (xx = 11) (xx = 15) (xx = 29) p101/segxx ? ? (xx = 28) p102/segxx ? ? (xx = 27) the following operation modes can be specified in 1-bit units. (1) port mode p100 to p102 function as an i/o port. p100 to p102 can be set to input or output port in 1-bit units using port mode register 10 (pm10). use of an on-chip pull-up resistor ca n be specified by pull-up resistor option register 10 (pu10). (2) control mode p100 to p102 function as segment output of lcd controller/driver (segxx). 2.2.12 p110, p111 p110 and p111 function as an i/o port. this port can also be used for d/a converter analog output. pd78f150xa pd78f151xa 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) p110/ano0 p110 p111/ano1 p111 the following operation modes can be specified in 1-bit units. (1) port mode p110 and p111 function as an i/o port. p110 and p111 can be set to input or output port in 1-bit units using port mode register 11 (pm11). (2) control mode p110 and p111 function as d/a conv erter analog output (ano0, ano1). caution when using at least one port of p 110/ano0 and p111/ano1 as a digital port, set av dd1 to the same potential as ev dd or v dd . 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 55 jun 20, 2011 2.2.13 p120 to p124 p120 function as an i/o port. p121 to p124 function as an input port. these pins also func tion as potential input for external low-voltage detection, connecting resonator for main system clock, connecting resonat or for subsystem clock, external clock input for main system clo ck, and external interrupt request input. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p120/intp0/exlvi p121/x1 p122/x2/exclk p123/xt1 p124/xt2 the following operation modes can be specified in 1-bit units. (1) port mode p120 functions as an i/o port. p120 can be set to input por t or output port using port mode register 12 (pm12). use of an on-chip pull-up resistor can be specified by pull-up resistor option register 12 (pu12). p121 to p124 function as an input port. (2) control mode p120 to p124 function as potential input for external low- voltage detection, connecting resonator for main system clock, connecting resonator for subsystem clock, external clock input for main system clock, and external interrupt request input. (a) exlvi this is a potential input pin for external low-voltage detection. (b) x1, x2 these are the pins for connecting a resonator for main system clock. (c) exclk this is an external clock inpu t pin for main system clock. (d) xt1, xt2 these are the pins for connecting a resonator for subsystem clock. (e) intp0 this is an external interrupt request input pin for which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. caution the function setting on p121 to p124 is available only once after the reset release. the port once set for connection to an oscillato r cannot be used as an input port unless the reset is performed. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 56 jun 20, 2011 2.2.14 p130 p130 functions as an output port. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p130 remark the p130 pin outputs a low level when it is used as a port function pin and a reset is effected. if p130 is set to output a high level before reset is effected, the output signal of p130 can be dummy-output as the cpu reset signal (see the figure for remark in 4.2.14 port 13 ). 2.2.15 p140 to p147 p140 to p147 function as an i/o port. this port can also be used for segment output of lcd controller/driver. 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p140/segxx (xx = 19) (xx = 23) (xx = 37) p141/segxx (xx = 18) (xx = 22) (xx = 36) p142/segxx (xx = 17) (xx = 21) (xx = 35) p143/segxx (xx = 16) (xx = 20) (xx = 34) p144/segxx (xx = 15) (xx = 19) (xx = 33) p145/segxx (xx = 14) (xx = 18) (xx = 32) p146/segxx (xx = 13) (xx = 17) (xx = 31) p147/segxx (xx = 12) (xx = 16) (xx = 30) the following operation modes can be specified in 1-bit units. (1) port mode p140 to p147 function as an i/o port. p140 to p147 can be set to input or output port in 1-bit units using port mode register 14 (pm14). use of an on-chip pull-up resistor ca n be specified by pull-up resistor option register 14 (pu14). (2) control mode p140 to p147 function as segment output of lcd controller/driver (segxx). 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 57 jun 20, 2011 2.2.16 p150 to p152, p157 p150 to p152 and p157 function as an i/o port. this port c an also be used for a/d converter analog input, reference voltage input, and operational amplifier input. pd78f150xa pd78f151xa 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) p150/ani8/amp2+ ? ? p150/ani8 p151/ani9 ? ? p152/ani10 ? ? p157/ani15/av refm p157/ani15 the following operation modes can be specified in 1-bit units. (1) port mode p150 to p152 and p157 function as an i/o port. p150 to p152 and p157 can be set to input or output port in 1-bit units using port mode register 15 (pm15). (2) control mode p150 to p152 and p157 function as a/d converter analog input, reference voltage input, and operational amplifier input. (a) ani8 to ani10, ani15 these are a/d converter analog input pins. (b) av refm this is the pin that inputs the negativ e reference voltage of a/d converter. (c) amp2+ this is the pin that the input voltage on the positive side of operational amplifier 2. cautions 1. p150/ani8/amp2+ to p152/ani10 and p157/ani15/av refm are set in the digital input (general- purpose port) mode after release of reset. 2. when using at least one port of p 150/ani8/amp2+ to p152/ ani10 and p157/ani15/av refm as a digital port, set av dd0 to the same potential as ev dd or v dd . 2.2.17 com0 to com7 these are common outputs of lcd controller/driver. 2.2.18 segxx these are segment outputs of lcd controller/driver. remark 78k0r/lf3: seg0 to seg30 78k0r/lg3: seg0 to seg39 78k0r/lh3: seg0 to seg53 2.2.19 v lc0 to v lc3 these are the pins for inputting a power supply voltage pin for driving the lcd. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 58 jun 20, 2011 2.2.20 v refout /av refp ( pd78f150xa only) v refout is an analog reference voltage output pin for voltage reference. av refp is the pin that inputs the pos itive reference voltage of the a/ d converter and d/a converter. 2.2.21 av ref ( pd78f151xa only) av ref is the pin that inputs the positive re ference voltage of the a/d converter. 2.2.22 reset this is the active-low system reset input pin. when the external reset pin is not used, connect this pin directly to ev dd or via a resistor. when the external reset pin is used, design the circuit based on v dd . 2.2.23 regc this is the pin for connecting regulator output (2.4 v) stab ilization capacitance for internal operation. connect this pin to v ss via a capacitor (0.47 to 1 f). also, use a capacitor with good characteristics, si nce it is used to stabilize internal voltage. regc v ss caution keep the wiring length as short as possible for the broken- line part in the above figure. 2.2.24 flmd0 this is a pin for setting flash memory programming mode. perform either of the following processing. (a) in normal operation mode it is recommended to leave this pin open during normal operation. the flmd0 pin must always be kept at the v ss level before reset release but does not have to be pulled down externally because it is internally pulled down by rese t. however, pulling it down must be kept selected (i.e., flmdpup = ?0?, default value) by using bit 7 (flmdpup ) of the background event control register (bectl) (see 27.5 (1) back ground event control register ). to pull it down externally, use a resistor of 200 k or smaller. self programming and the rewriting of flash memory wit h the programmer can be prohibited using hardware, by directly connecting this pin to the v ss pin. (b) in self programming mode it is recommended to leave this pin open when using the self programming function. to pull it down externally, use a resistor of 100 k to 200 k . in the self programming mode, the setting is swit ched to pull up in the self programming library. (c) in flash memory programming mode directly connect this pin to a flash memory programmer when data is written by the flash memory programmer. this supplies a writing voltage of the v dd level to the flmd0 pin. the flmd0 pin does not have to be pulled down externally bec ause it is internally pulled down by reset. to pull it down externally, use a resistor of 1 k to 200 k . 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 59 jun 20, 2011 2.2.25 av dd0 , av dd1 , av dd , ev dd1 , av ss , ev dd , ev ss , v dd , v ss (1) av dd0 ( pd78f150xa only) this is the ground potential pi n of a/d converter, operational amplifier, voltage referenc e, p20 to p27, p150 to p152 and p157. when using at least one port of ports 2 and 15 as a digita l port, or when not using th e a/d converter, operational amplifier, or voltage reference, set av dd0 to the same potential as ev dd or v dd . (2) av dd1 ( pd78f150xa only) this is the ground potential pin of d/a converter, p110 and p111. when using at least one port of ports 11 as a digi tal port, or when not using the d/a converter set av dd1 to the same potential as ev dd or v dd . (3) av dd ( pd78f151xa only) this is the ground potential pi n of a/d converter, p20 to p27, p150 to p152 and p157. when using at least one port of ports 2 and 15 as a di gital port, or when not using the a/d converter, set av dd to the same potential as ev dd or v dd . (4) ev ddi ( pd78f151xa only) this is the ground potentia l pin of p110 and p111. when using at least one port of ports 11 as a digital port, set ev dd1 to the same potential as ev dd or v dd . (5) av ss this is the ground potential pin of a/d converter, d/a converte r, operational amplifier, volt age reference, p20 to p27, p110, p111, p150 to p152, and p157. even when the a/d converter, d/a c onverter, operational amplifier, and voltage reference is not used, always us e this pin with the same potential as ev ss and v ss . (6) ev dd this is the positive power supply pin fo r ports other than p20 to p27, p110, p 111, p150 to p152, and p157 as well as for the reset and flmd0 pins. (7) ev ss this is the ground potential pin for ports other than p20 to p27, p110, p111, p150 to p152, and p157 as well as for the reset and flmd0 pins. (8) v dd this is the positive power supply pin other than ports, reset, and flmd0 pins. (9) v ss this is the ground potential pin other than ports, reset, and flmd0 pins. 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 60 jun 20, 2011 2.3 pin i/o circuits and recomme nded connection of unused pins 2.3.1 78k0r/lf3 table 2-2 shows the types of pin i/o circuits and the recommended connections of unused pins. table 2-2. connection of unused pins (78k0r/lf3) (1/3) pin name i/o circuit type i/o recommended connection of unused pins p00/caph p01/capl 12-h p02/v lc3 5-at p10/sck20/scl20 p11/si20/rxd2/sda20/ intp6 5-an p12/so20/txd2/to02 p13/so10/txd1/to04 5-ag p14/si10/rxd1/sda10/ intp4 p15/sck10/scl10/intp7 5-an input: independently connect to ev dd or ev ss via a resistor. output: leave open. p20/ani0/amp0- note 1, 2 11-p note 3 p21/ani1/amp0o note 1, 2 11-s note 3 p22/ani2/amp0+ note 1, 2 11-n note 3 p23/ani3/amp1- note 1, 2 11-p note 3 p24/ani4/amp1o note 1, 2 11-s note 3 p25/ani5/amp1+ note 1, 2 11-n note 3 p26/ani6 note 1, 2 11-g note 3 input: independently connect to av dd0 or av ss via a resistor. output: leave open. p30/ti03/to00/rtc1hz/ intp1 p31/ti00/to03/rtcdiv/ rtccl/pclbuz1/intp2 p32/ti01/to01/intp5/ pclbuz0 p33/ti07/to07/intp3 input: independently connect to ev dd or ev ss via a resistor. output: leave open. p40/tool0 8-r 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 61 jun 20, 2011 table 2-2. connection of unused pins (78k0r/lf3) (2/3) pin name i/o circuit type i/o recommended connection of unused pins p90/seg22 to p92/seg20 p100/seg11 17-p 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 62 jun 20, 2011 table 2-2. connection of unused pins (78k0r/lf3) (3/3) pin name i/o circuit type i/o recommended connection of unused pins av dd0 note 1 , av dd note 2 ? ? 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 63 jun 20, 2011 2.3.2 78k0r/lg3 table 2-3 shows the types of pin i/o circuits and the recommended connections of unused pins. table 2-3. connection of u nused pins (78k0r/lg3) (1/3) pin name i/o circuit type i/o recommended connection of unused pins p00/caph p01/capl 12-h p02/v lc3 5-at p10/sck20/scl20 p11/si20/rxd2/sda20/ intp6 5-an p12/so20/txd2/to02 p13/so10/txd1/to04 5-ag p14/si10/rxd1/sda10/ intp4 p15/sck10/scl10/intp7 5-an p16/ti05/to05/intp10 8-r input: independently connect to ev dd or ev ss via a resistor. output: leave open. p20/ani0/amp0- note 1, 2 11-p note 3 p21/ani1/amp0o note 1, 2 11-s note 3 p22/ani2/amp0+ note 1, 2 11-n note 3 p23/ani3/amp1- note 1, 2 11-p note 3 p24/ani4/amp1o note 1, 2 11-s note 3 p25/ani5/amp1+ note 1, 2 11-n note 3 p26/ani6/amp2- note 1, 2 11-p note 3 p27/ani7/amp2o note 1, 2 11-s note 3 input: independently connect to av dd0 or av ss via a resistor. output: leave open. p30/ti03/to00/rtc1hz/ intp1 p31/ti00/to03/rtcdiv/ rtccl/pclbuz1/intp2 p32/ti01/to01/intp5/ pclbuz0 p33/ti07/to07/intp3 p34/ti06/to06/intp8 8-r input: independently connect to ev dd or ev ss via a resistor. output: leave open. p40/tool0 8-r 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 64 jun 20, 2011 table 2-3. connection of u nused pins (78k0r/lg3) (2/3) pin name i/o circuit type i/o recommended connection of unused pins p50/seg39/rxd3 17-q p51/seg38/txd3 17-p p52/seg37/ti02 p53/seg36/ti04 17-q p54/seg35 to p57/seg32 17-p 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 65 jun 20, 2011 table 2-3. connection of u nused pins (78k0r/lg3) (3/3) pin name i/o circuit type i/o recommended connection of unused pins p150/ani8/amp2+ note 1 11-n p151/ani9 note 1 p152/ani10 note 1 11-g p157/ani15/av refm note 1, 2 11-t note 3 i/o input: independently connect to av dd0 or av ss via a resistor. output: leave open. seg0/com4 to seg3/com7 18-f seg4 to seg14 17-t com0 to com3 18-e output v lc0 to v lc2 ? ? leave open. av dd0 ? ? 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 66 jun 20, 2011 2.3.3 78k0r/lh3 table 2-4 to shows the types of pin i/o circui ts and the recommended connec tions of unused pins. table 2-4. connection of unused pins (78k0r/lh3) (1/3) pin name i/o circuit type i/o recommended connection of unused pins p00/caph p01/capl 12-h p02/v lc3 5-at p10/sck20/scl20 p11/si20/rxd2/sda20/ intp6 5-an p12/so20/txd2/to02 p13/so10/txd1/to04 5-ag p14/si10/rxd1/sda10/ intp4 p15/sck10/scl10/intp7 5-an p16/ti05/to05/intp10 8-r p17 5-ag input: independently connect to ev dd or ev ss via a resistor. output: leave open. p20/ani0/amp0- note 1, 2 11-p note 3 p21/ani1/amp0o note 1, 2 11-s note 3 p22/ani2/amp0+ note 1, 2 11-n note 3 p23/ani3/amp1- note 1, 2 11-p note 3 p24/ani4/amp1o note 1, 2 11-s note 3 p25/ani5/amp1+ note 1, 2 11-n note 3 p26/ani6/amp2- note 1, 2 11-p note 3 p27/ani7/amp2o note 1, 2 11-s note 3 input: independently connect to av dd0 or av ss via a resistor. output: leave open. p30/ti03/to00/rtc1hz/ intp1 p31/ti00/to03/rtcdiv/ rtccl/pclbuz1/intp2 p32/ti01/to01/intp5/ pclbuz0 p33/ti07/to07/intp3 p34/ti06/to06/intp8 8-r input: independently connect to ev dd or ev ss via a resistor. output: leave open. p40/tool0 8-r 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 67 jun 20, 2011 table 2-4. connection of unused pins (78k0r/lh3) (2/3) pin name i/o circuit type i/o recommended connection of unused pins p50/seg53/rxd3 17-q p51/seg52/txd3 17-p p52/seg51/ti02 p53/seg50/ti04 17-q p54/seg49 to p57/seg46 17-p 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 68 jun 20, 2011 table 2-4. connection of unused pins (78k0r/lh3) (3/3) pin name i/o circuit type i/o recommended connection of unused pins p150/ani8/amp2+ note 1 11-n p151/ani9 note 1 p152/ani10 note 1 11-g note 3 p157/ani15/av refm note 1, 2 11-t i/o input: independently connect to av dd0 or av ss via a resistor. output: leave open. seg0/com4 to seg3/com7 18-f seg4 to seg26 17-t com0 to com3 18-e output v lc0 to v lc2 ? ? leave open. av dd0 ? ? 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 69 jun 20, 2011 figure 2-1. pin i/o circuit list (1/5) type 2 type 2-w schmitt-triggered input with hysteresis characteristics in in pull-down enable n-ch pull-up enable p-ch v dd v ss schmitt-triggered input with hysteresis characteristics type 3-c type 5 ev dd p-ch n-ch data out ev ss pullup enable data output disable input enable ev dd p-ch ev dd ev ss p-ch in/out n -ch type 5-an type 5-ag pull-up enable data output disable p-ch ev dd ev dd ev ss p-ch in/out n -ch cmos ttl input characteristic pullup enable data output disable input enable ev dd p-ch ev dd ev ss p-ch in/out n -ch 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 70 jun 20, 2011 figure 2-1. pin i/o circuit list (2/5) type 5-at type 11-s pullup enable data output disable input enable p-ch p-ch in/out ev dd ev dd ev ss n -ch v lc3 data output disable av dd0 p-ch in/out n-ch p-ch n-ch comparator input enable + _ av ss av ss + _ op amp v ref (threshold voltage) type 8-r type 11-g data output disable ev dd p-ch in/out n-ch ev ss pullup enable ev dd p-ch data output disable av dd0 p-ch in/out n-ch p-ch n-ch input enable + _ av ss av ss comparator series resistor string voltage type 11-n type 11-p data output disable av ref p-ch in/out n-ch p-ch n-ch comparator input enable + _ av ss av ss + _ op amp v ref (threshold voltage) data output disable av ref p-ch in/out n-ch p-ch n-ch input enable + _ av ss av ss + _ op amp (threshold voltage) comparator v ref 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 71 jun 20, 2011 figure 2-1. pin i/o circuit list (3/5) type 11-t type 12-h data output disable av dd0 p-ch in/out n-ch p-ch n-ch comparator input enable + _ av ss av ss v ref (threshold voltage) p-ch n-ch av refm pullup enable data output disable input enable ev dd p-ch ev dd p-ch in/out n-ch p-ch n-ch caph, capl ev ss type 12-a type 17-p data output disable input enable av dd1 p-ch in/out n-ch p-ch n-ch av ss analog output voltage type 13-r in/out n -ch data output disable ev ss p-ch n-ch seg data p-ch n-ch p-ch p-ch n-ch pullup enable data output disable input enable p-ch p-ch in/out p-ch n-ch n-ch v lc0 v lc1 v lc2 ev dd ev dd n -ch v lc3 ev ss v ss 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 72 jun 20, 2011 figure 2-1. pin i/o circuit list (4/5) type 17-q type 17-t p-ch n-ch seg data p-ch n-ch p-ch n-ch out p-ch n-ch n-ch v lc0 v lc1 v lc2 v lc3 v ss type 18-e p-ch n-ch seg data p-ch n-ch p-ch n-ch pullup enable data output disable input enable p-ch p-ch in/out p-ch n-ch n-ch v lc0 v lc1 v lc2 ev dd ev dd n -ch v lc3 ev ss v ss p-ch com data p-ch n-ch out p-ch n-ch n-ch n-ch p-ch p-ch n-ch p-ch n-ch v lc0 v lc1 v lc2 v lc3 v ss 78k0r/lx3 chapter 2 pin functions r01uh0004ej0501 rev.5.01 73 jun 20, 2011 figure 2-1. pin i/o circuit list (5/5) type 18-f type 37-a xt1 input enable input enable p-ch n-ch xt2 type 37-c p-ch com data p-ch n-ch p-ch n-ch n-ch n-ch p-ch p-ch n-ch p-ch n-ch out p-ch n-ch seg data p-ch n-ch p-ch n-ch p-ch n-ch n-ch v lc0 v lc1 v lc2 v lc3 v ss v lc0 v lc1 v lc2 v lc3 v ss x1 input enable input enable p-ch n-ch x2 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 74 jun 20, 2011 chapter 3 cpu architecture 3.1 memory space products in the 78k0r/lx3 microcontrollers can access a 1 mb memory space. figures 3-1 to 3-3 show the memory maps. figure 3-1. memory map ( pd78f1500a, 78f1503a, 78f1506a, 78f1510a, 78f1513a, 78f1516a) 00000h effffh f0000h f07ffh f0800h f0fffh f1000h feeffh fef00h ffedfh ffee0h ffeffh fff00h fffffh 00000h 0007fh 00080h 000bfh 000c0h 000c3h 000c4h 00fffh 01000h 0107fh 01080h 010bfh 010c0h 010c3h 010c4h 0ffffh 0ffffh 10000h special function register (sfr) 256 bytes ram note 1 4 kb general-purpose register 32 bytes flash memory 64 kb extended special function register (2nd sfr) 2 kb mirror 55.75 kb vector table area 128 bytes callt table area 64 bytes program area option byte area note 2 4 bytes vector table area 128 bytes callt table area 64 bytes option byte area note 2 4 bytes program area reserved reserved program memory space data memory space on-chip debug security id setting area note 2 10 bytes 01fffh boot cluster 0 note 3 boot cluster 1 010cdh 010ceh on-chip debug security id setting area note 2 10 bytes 000cdh 000ceh notes 1. instructions can be executed from the ram ar ea excluding the general-purpose register area. 2. when boot swap is not used: set the option bytes to 000c0h to 000c3h, and the on-chip debug security ids to 000c4h to 000cdh. when boot swap is used: set the option bytes to 000c0h to 000c3h and 010c0h to 010c3h, and the on-chip debug security ids to 000c4h to 000cdh and 010c4h to 010cdh. 3. writing boot cluster 0 can be prohibited depending on the setting of security (see 27.7 security setting ). 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 75 jun 20, 2011 figure 3-2. memory map ( pd78f1501a, 78f1504a, 78f1507a) 00000h effffh f0000h f07ffh f0800h f0fffh f1000h fe6ffh fe700h ffedfh ffee0h ffeffh fff00h fffffh 00000h 0007fh 00080h 000bfh 000c0h 000c3h 000c4h 00fffh 01000h 0107fh 01080h 010bfh 010c0h 010c3h 010c4h 17fffh 17fffh 18000h special function register (sfr) 256 bytes ram note 1 6 kb general-purpose register 32 bytes flash memory 96 kb extended special function register (2nd sfr) 2 kb mirror 53.75 kb vector table area 128 bytes callt table area 64 bytes program area option byte area note 2 4 bytes vector table area 128 bytes callt table area 64 bytes option byte area note 2 4 bytes program area reserved reserved program memory space data memory space on-chip debug security id setting area note 2 10 bytes 01fffh boot cluster 0 note 3 boot cluster 1 010cdh 010ceh on-chip debug security id setting area note 2 10 bytes 000cdh 000ceh notes 1. instructions can be executed from the ram ar ea excluding the general-purpose register area. 2. when boot swap is not used: set the option bytes to 000c0h to 000c3h, and the on-chip debug security ids to 000c4h to 000cdh. when boot swap is used: set the option bytes to 000c0h to 000c3h and 010c0h to 010c3h, and the on-chip debug security ids to 000c4h to 000cdh and 010c4h to 010cdh. 3. writing boot cluster 0 can be prohibited depending on the setting of security (see 27.7 security setting ). 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 76 jun 20, 2011 figure 3-3. memory map ( pd78f1502a, 78f1505a, 78f1508a, 78f1512a, 78f1515a, 78f1518a) 00000h effffh f0000h f07ffh f0800h f0fffh f1000h fe2ffh fe300h ffedfh ffee0h ffeffh fff00h fffffh 00000h 0007fh 00080h 000bfh 000c0h 000c3h 000c4h 00fffh 01000h 0107fh 01080h 010bfh 010c0h 010c3h 010c4h 1ffffh 1ffffh 20000h special function register (sfr) 256 bytes ram note 1 7 kb general-purpose register 32 bytes flash memory 128 kb extended special function register (2nd sfr) 2 kb mirror 51.75 kb vector table area 128 bytes callt table area 64 bytes program area option byte area note 2 4 bytes vector table area 128 bytes callt table area 64 bytes option byte area note 2 4 bytes program area reserved reserved program memory space data memory space on-chip debug security id setting area note 2 10 bytes 01fffh boot cluster 0 note 3 boot cluster 1 010cdh 010ceh on-chip debug security id setting area note 2 10 bytes 000cdh 000ceh reserved fdeffh fdf00h notes 1. instructions can be executed from the ram ar ea excluding the general-purpose register area. 2. when boot swap is not used: set the option bytes to 000c0h to 000c3h, and the on-chip debug security ids to 000c4h to 000cdh. when boot swap is used: set the option bytes to 000c0h to 000c3h and 010c0h to 010c3h, and the on-chip debug security ids to 000c4h to 000cdh and 010c4h to 010cdh. 3. writing boot cluster 0 can be prohibited depending on the setting of security (see 27.7 security setting ). 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 77 jun 20, 2011 remark the flash memory is divided into blocks (one block = 1 kb). for the address val ues and block numbers, see table 3-1 correspondence between address va lues and block number s in flash memory . block 00h block 01h block 3fh 1 kb 003ffh 00400h 00000h 007ffh 0fbffh 0fc00h 0ffffh 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 78 jun 20, 2011 correspondence between the address values and block numbers in the flash memory are shown below. table 3-1. correspondence between address values and block number s in flash memory address value block number address value block number address value block number address value block number 00000h to 003ffh 00h 08000h to 083ffh 20h 10000h to 103ffh 40h 18000h to 183ffh 60h 00400h to 007ffh 01h 08400h to 087ffh 21h 10400h to 107ffh 41h 18400h to 187ffh 61h 00800h to 00bffh 02h 08800h to 08bffh 22h 10800h to 10bffh 42h 18800h to 18bffh 62h 00c00h to 00fffh 03h 08c00h to 08fffh 23h 10c00h to 10fffh 43h 18c00h to 18fffh 63h 01000h to 013ffh 04h 09000h to 093ffh 24h 11000h to 113ffh 44h 19000h to 193ffh 64h 01400h to 017ffh 05h 09400h to 097ffh 25h 11400h to 117ffh 45h 19400h to 197ffh 65h 01800h to 01bffh 06h 09800h to 09bffh 26h 11800h to 11bffh 46h 19800h to 19bffh 66h 01c00h to 01fffh 07h 09c00h to 09fffh 27h 11c00h to 11fffh 47h 19c00h to 19fffh 67h 02000h to 023ffh 08h 0a000h to 0a3ffh 28h 12000h to 123ffh 48h 1a000h to 1a3ffh 68h 02400h to 027ffh 09h 0a400h to 0a7ffh 29h 12400h to 127ffh 49h 1a400h to 1a7ffh 69h 02800h to 02bffh 0ah 0a800h to 0abffh 2ah 12800h to 12bffh 4ah 1a800h to 1abffh 6ah 02c00h to 02fffh 0bh 0ac00h to 0afffh 2bh 12c00h to 12fffh 4bh 1ac00h to 1afffh 6bh 03000h to 033ffh 0ch 0b000h to 0b3ffh 2ch 13000h to 133ffh 4ch 1b000h to 1b3ffh 6ch 03400h to 037ffh 0dh 0b400h to 0b7ffh 2dh 13400h to 137ffh 4dh 1b400h to 1b7ffh 6dh 03800h to 03bffh 0eh 0b800h to 0bbffh 2eh 13800h to 13bffh 4eh 1b800h to 1bbffh 6eh 03c00h to 03fffh 0fh 0bc00h to 0bfffh 2fh 13c00h to 13fffh 4fh 1bc00h to 1bfffh 6fh 04000h to 043ffh 10h 0c000h to 0c3ffh 30h 14000h to 143ffh 50h 1c000h to 1c3ffh 70h 04400h to 047ffh 11h 0c400h to 0c7ffh 31h 14400h to 147ffh 51h 1c400h to 1c7ffh 71h 04800h to 04bffh 12h 0c800h to 0cbffh 32h 14800h to 14bffh 52h 1c800h to 1cbffh 72h 04c00h to 04fffh 13h 0cc00h to 0cfffh 33h 14c00h to 14fffh 53h 1cc00h to 1cfffh 73h 05000h to 053ffh 14h 0d000h to 0d3ffh 34h 15000h to 153ffh 54h 1d000h to 1d3ffh 74h 05400h to 057ffh 15h 0d400h to 0d7ffh 35h 15400h to 157ffh 55h 1d400h to 1d7ffh 75h 05800h to 05bffh 16h 0d800h to 0dbffh 36h 15800h to 15bffh 56h 1d800h to 1dbffh 76h 05c00h to 05fffh 17h 0dc00h to 0dfffh 37h 15c00h to 15fffh 57h 1dc00h to 1dfffh 77h 06000h to 063ffh 18h 0e000h to 0e3ffh 38h 16000h to 163ffh 58h 1e000h to 1e3ffh 78h 06400h to 067ffh 19h 0e400h to 0e7ffh 39h 16400h to 167ffh 59h 1e400h to 1e7ffh 79h 06800h to 06bffh 1ah 0e800h to 0ebffh 3ah 16800h to 16bffh 5ah 1e800h to 1ebffh 7ah 06c00h to 06fffh 1bh 0ec00h to 0efffh 3bh 16c00h to 16fffh 5bh 1ec00h to 1efffh 7bh 07000h to 073ffh 1ch 0f000h to 0f3ffh 3ch 17000h to 173ffh 5ch 1f000h to 1f3ffh 7ch 07400h to 077ffh 1dh 0f400h to 0f7ffh 3dh 17400h to 177ffh 5dh 1f400h to 1f7ffh 7dh 07800h to 07bffh 1eh 0f800h to 0fbffh 3eh 17800h to 17bffh 5eh 1f800h to 1fbffh 7eh 07c00h to 07fffh 1fh 0fc00h to 0ffffh 3fh 17c00h to 17fffh 5fh 1fc00h to 1ffffh 7fh remark pd78f1500a, 78f1503a, 78f1506a, 78f1510a, 78f1513a, 78f1516a: block numbers 00h to 3fh pd78f1501a, 78f1504a, 78f1507a: block numbers 00h to 5fh pd78f1502a, 78f1505a, 78f1508a, 78f1512a, 78f1515a, 78f1518a: block numbers 00h to 7fh 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 79 jun 20, 2011 3.1.1 internal program memory space the internal program memory space st ores the program and table data. norma lly, it is addressed with the program counter (pc). 78k0r/lx3 microcontrollers products incorporate in ternal rom (flash memory), as shown below. table 3-2. intern al rom capacity internal rom part number structure capacity pd78f1500a, 78f1503a, 78f1506a, 78f1510a, 78f1513a, 78f1516a 65536 8 bits (00000h to 0ffffh) pd78f1501a, 78f1504a, 78f1507a 98303 8 bits (00000h to 17fffh) pd78f1502a, 78f1505a, 78f1508a, 78f1512a, 78f1515a, 78f1518a flash memory 131071 8 bits (00000h to 1ffffh) the internal program memory space is divided into the following areas. (1) vector table area the 128-byte area 00000h to 0007fh is reserved as a ve ctor table area. the progr am start addresses for branch upon reset or generation of each interrupt request are stored in the vector table area. fu rthermore, the interrupt jump address is a 64 k address of 00000h to 0ffffh, becaus e the vector code is assumed to be 2 bytes. of the 16-bit address, the lower 8 bits ar e stored at even addresses and the higher 8 bits are stored at odd addresses. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 80 jun 20, 2011 table 3-3. vector table vector table address interrupt source lf3 lg3 lh3 vector table address interrupt source lf3 lg3 lh3 00030h inttm02 00000h reset input, poc, lvi, wdt, trap 00032h inttm03 00004h intwdti 00034h intad 00006h intlvi 00036h intrtc 00008h intp0 00038h intrtci 0000ah intp1 0003ah intkr ? ? 0000ch intp2 intst2 0000eh intp3 intcsi20 00010h intp4 0003ch intiic20 00012h intp5 0003eh intsr2 00014h intst3 00040h intsre2 00016h intsr3 00042h inttm04 00018h intsre3 00044h inttm05 0001ah intdma0 00046h inttm06 0001ch intdma1 00048h inttm07 intst0 ? 0004ah intp6 0001eh intcsi00 ? 0004ch intp7 intsr0 ? 0004eh intp8 ? 00020h intcsi01 ? ? 00050h intp9 ? 00022h intsre0 00052h intp10 ? intst1 00054h intp11 ? intcsi10 00056h inttm10 00024h intiic10 00058h inttm11 00026h intsr1 0005ah inttm12 00028h intsre1 0005ch inttm13 0002ah intiica ? 0005eh intmd 0002ch inttm00 0007eh brk 0002eh inttm01 (2) callt instruction table area the 64-byte area 00080h to 000bfh can st ore the subroutine entry address of a 2- byte call instruction (callt). set the subroutine entry address to a value in a range of 00000h to 0ffffh (becau se an address code is of 2 bytes). to use the boot swap function, set a callt instruction table also at 01080h to 010bfh. (3) option byte area a 4-byte area of 000c0h to 000c3h can be used as an opti on byte area. set the option byte at 010c0h to 010c3h when the boot swap is used. for details, see chapter 26 option byte . 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 81 jun 20, 2011 (4) on-chip debug security id setting area a 10-byte area of 000c4h to 000cdh and 010c4h to 010cdh can be used as an on-chip debug security id setting area. set the on-chip debug security id of 10 bytes at 000c4h to 000cdh when the boot swap is not used and at 000c4h to 000cdh and 010c4h to 010cdh when the boot swap is used. for details, see chapter 28 on-chip debug function . 3.1.2 mirror area the pd78f1500a, 78f1503a, 78f01506a, 78f1510a, 78f1513a, and 78f1516a mi rror the data flash area of 00000h to 0ffffh, to f0000h to fffffh (the data flash ar ea to be mirrored is set by the processor mode control register (pmc)). the pd78f1501a, 78f1502a, 78f1504a, 78f1505a, 78f1507a , 78f1508a, 78f1512a, 78f1515a, and 78f1518a mirror the data flash area of 00000h to 0ffffh or 10000h to 1ffffh, to f0000h to fffffh (the data flash area to be mirrored is set by the processor mode control register (pmc)). by reading data from f0000h to fffffh, an instruction that does not have the es r egisters as an operand can be used, and thus the contents of the data flash can be read with the shorter c ode. however, the data flash area is not mirrored to the sfr, extended sfr, ram, and use prohibited areas. the mirror area can only be read and no instruction can be fetched from this area. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 82 jun 20, 2011 the following show examples. remark maa: bit 0 of the processor mode control register (pmc). example 1 pd78f1500a, 78f1503a, 78f1506a, 78f1510a, 78f1513a, 78f1516a (flash memory: 64 kb, ram: 4 kb) setting maa = 0 example 2 pd78f1502a, 78f1505a, 78f1508a, 78f1512a, 78f1515a, 78f1518a (flash memory: 128 kb, ram: 7 kb) setting maa = 1 flash memory flash memory flash memory 01000h 00fffh 00000h 0ef00h 0eeffh 10000h 0ffffh mirror f0000h effffh f0800h f07ffh f1000h f0fffh fef00h feeffh ffee0h ffedfh fff00h ffeffh fffffh special-function register ( sfr) 256 bytes general-purpose register 32 bytes ram 4 kb flash memory (same data as 01000h to 0eeffh) reserved reserved extended special function register (2nd sfr) 2 kb for example, 02345h is mirrored to f2345h. data can therefore be read by mov a, !2345h, instead of mov es, #00h and mov a, es:!2345h. special-function register ( sfr) 256 bytes fffffh general-purpose register 32 bytes ffee0h ffedfh fff00h ffeffh ram 7 kb fe300h fe2ffh flash memory (same data as 11000h to 1de ff h) f0800h f07ffh f1000h f0fffh reserved f0000h effffh reserved mirror 20000h 1ffffh 00000h 1df00h 1deffh 11000h 10fffh flash memory flash memory flash memory extended special function register (2nd sfr) 2 kb reserved fdf00h fdeffh for example, 15432h is mirrored to f5432h. data can therefore be read by mov a, !5432h, instead of mov es, #01h and mov a, es:!5432h. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 83 jun 20, 2011 pmc register is described below. ? processor mode control register (pmc) this register selects the flash memory s pace for mirroring to area from f0000h to fffffh. pmc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets this register to 00h. figure 3-4. format of configuration of processor mode control register (pmc) address: ffffeh after reset: 00h r/w symbol 7 6 5 4 3 2 1 <0> pmc 0 0 0 0 0 0 0 maa maa selection of flash memory space fo r mirroring to area from f0000h to fffffh 0 00000h to 0ffffh is mirrored to f0000h to fffffh 1 10000h to 1ffffh is mirrored to f0000h to fffffh cautions 1. set pmc only once during the initial setti ngs prior to operating the dma controller. rewriting pmc other than during the init ial settings is prohibited. 2. after setting pmc, wait for at least one instruction and access the mirror area. 3. when the pd78f1500a, 78f1503a, 78f1506a, 78f1510 a, 78f1513a, and 78f1516a (flash memory size: 64 kb) are used, be sure to set bit 0 (maa) of this register to 0. 3.1.3 internal data memory space 78k0r/lx3 microcontrollers products incorporate the following rams. table 3-4. internal ram capacity part number internal ram pd78f1500a, 78f1503a, 78f1506a, 78f1510a, 78f1513a, 78f1516a 4096 8 bits (fef00h to ffeffh) pd78f1501a, 78f1504a, 78f1507a 6144 8 bits (fe700h to ffeffh) pd78f1502a, 78f1505a, 78f1508a, 78f1512a, 78f1515a, 78f1518a 7168 8 bits (fe300h to ffeffh) the internal ram can be used as a data area and a program area where instructions are wr itten and executed. four general-purpose register banks consisting of eight 8-bit registers per bank are a ssigned to the 32-byte area of ffee0h to ffeffh of the internal ram area. ho wever, instructions cannot be execut ed by using general-purpose registers. the internal ram is used as a stack memory. cautions 1. it is prohibi ted to use the general-purpose register (ffee0h to ffeffh) space for fetching instructions or as a stack area. 2. while using the self-programming function, th e area of ffe20h to ffeffh cannot be used as a stack memory. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 84 jun 20, 2011 3.1.4 special function register (sfr) area on-chip peripheral hardware special function registers (sfrs) are allo cated in the area fff00h to fffffh. caution do not access addresses to which sfrs are not assigned. 3.1.5 extended special function register (2 nd sfr: 2nd special function register) area on-chip peripheral hardware special function registers ( 2nd sfrs) are allocated in the area f0000h to f07ffh. sfrs other than those in the sfr area (f ff00h to fffffh) are allocated to this area. an instruction that accesses the 2nd sfr area, however, is 1 byte longer than an instruction that accesses the sfr area. caution do not access addresses to which 2nd sfrs are not assigned. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 85 jun 20, 2011 3.1.6 data memory addressing addressing refers to the method of spec ifying 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 executio n of instructions for the 78k0r/lx3 microcontrollers, based on operability and other considerations. for areas containing data memory in particular, special addressing methods designed for the functi ons of special function regi sters (sfr) and general-purpose registers are available for use. figures 3-5 to 3-7 sh ow correspondence between data memory and addressing. figure 3-5. correspondence between data memory and addressing ( pd78f1500a, 78f1503a, 78f1506a, 78f1510a, 78f1513a, 78f1516a) special function register (sfr) 256 bytes ram 4 kb general-purpose register 32 bytes flash memory 64 kb mirror 55.75 kb reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h 0ffffh 10000h effffh f0000h f07ffh f0800h f0fffh f1000h feeffh fef00h ffe1fh ffe20h ffedfh ffee0h ffeffh fff00h fff1fh fff20h fffffh extended special function register (2nd sfr) 2 kb 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 86 jun 20, 2011 figure 3-6. correspondence between data memory and addressing ( pd78f1501a, 78f1504a, 78f1507a) special function register (sfr) 256 bytes ram 6 kb general-purpose register 32 bytes flash memory 96 kb mirror 53.75 kb reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h 17fffh 18000h effffh f0000h f07ffh f0800h f0fffh f1000h fe6ffh fe700h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh extended special function register (2nd sfr) 2 kb 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 87 jun 20, 2011 figure 3-7. correspondence between data memory and addressing ( pd78f1502a, 78f1505a, 78f1508a, 78 f1512a, 78f1515a, 78f1518a) special function register (sfr) 256 bytes ram 7 kb general-purpose register 32 bytes flash memory 128 kb mirror 51.75 kb reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h effffh f0000h f07ffh f0800h f0fffh f1000h fe2ffh fe300h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh 1ffffh 20000h extended special function register (2nd sfr) 2 kb reserved fdeffh fdf00h 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 88 jun 20, 2011 3.2 processor registers the 78k0r/lx3 microcontrollers products inco rporate the 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 20-bit regist er that holds the address information of the next program to be executed. in normal operation, pc is automatically incremented according to the number of bytes of the instruction to be fetched. when a branch instruction is executed, imme diate data and register contents are set. reset signal generation sets the reset vector table val ues at addresses 0000h and 0001h to the program counter. figure 3-8. format of program counter 19 pc 0 (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 are stored in the stack area upon interr upt request generation or push psw instruction execution and are re stored upon execution of the retb , reti and pop psw instructions. reset signal generation sets psw to 06h. figure 3-9. format of program status word ie z rbs1 ac rbs0 isp0 cy 70 isp1 psw (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 a cknowledgment is controlled with an in-service priority flag (isp1, isp0), an interrupt mask flag for various interrupt sources, and a priority specification flag. the ie flag is reset (0) upon di instruction executio n or interrupt acknowledgment and is set (1) upon ei instruction execution. (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, rbs1) these are 2-bit flags to select one of the four register banks. in these flags, the 2-bit information that indicates the re gister bank selected by sel rbn instruction execution is stored. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 89 jun 20, 2011 (d) auxiliary carry flag (ac) if the operation result has a carry from bit 3 or a borrow at bit 3, this flag is set (1). it is reset (0) in all other cases. (e) in-service priority flags (isp1, isp0) this flag manages the priority of acknowledgeable maskabl e vectored interrupts. vectored interrupt requests specified lower than the value of isp0 and isp1 by a priority specificatio n flag register (prn0l, prn0h, prn1l, prn1h, prn2l, prn2h) (see 19.3 (3) ) can not be acknowledged. actual re quest acknowledgment is controlled by the interrupt enable flag (ie). remark n = 0, 1 (f) carry flag (cy) this flag stores overflow and underflow upon add/subtract instruction execution. it stores the shift-out value upon rotate instruction execution and functions as a bit a ccumulator during bit operation instruction execution. (3) stack pointer (sp) this is a 16-bit register to hold the st art address of the memory stack area. only the internal ram area can be set as the stack area. figure 3-10. format of stack pointer 15 sp sp15 sp14 sp13 sp12 sp11 sp10 sp9 sp8 sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 0 the sp is decremented ahead of write (s ave) to the stack memory and is incr emented after read (restored) from the stack memory. each stack operation saves data as shown in figure 3-11. cautions 1. since reset signal gene ration makes the sp contents undefined, be sure to initialize the sp before using the stack. 2. it is prohibited to use the general-purpose register (ffee0 h to ffeffh) space as a stack area. 3. while using the self-programming function, th e area of ffe20h to ffeffh cannot be used as a stack memory. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 90 jun 20, 2011 figure 3-11. data to be saved to stack memory pc7 to pc0 pc15 to pc8 pc19 to pc16 psw interrupt, brk instruction sp sp ? 4 sp ? 4 sp ? 3 sp ? 2 sp ? 1 sp call, callt instructions register pair lower register pair higher push rp instruction sp sp ? 2 sp ? 2 sp ? 1 sp (4-byte stack) (4-byte stack) pc7 to pc0 pc15 to pc8 pc19 to pc16 00h sp sp ? 4 sp ? 4 sp ? 3 sp ? 2 sp ? 1 sp 00h psw push psw instruction sp sp ? 2 sp ? 2 sp ? 1 sp 3.2.2 general-purpose registers general-purpose registers are mapped at particular addresses (ffee0h to ffe ffh) of the data memory. the general- purpose registers consists of 4 banks, each bank consisting of eight 8-bit registers (x, a, c, b, e, d, l, and h). each register can be used as an 8-bit register, and two 8-bit regi sters 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 instruction execution are set by the cpu control instruction ( sel rbn). because of the 4- register bank configuration, an efficient program can be created by switching betwe en a register for normal processing and a register for interrupts for each bank. caution it is prohibited to u se the general-purpose register ( ffee0h to ffeffh) space for fetching instructions or as a stack area. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 91 jun 20, 2011 figure 3-12. configuration of general-purpose registers (a) function name register bank 0 register bank 1 register bank 2 register bank 3 ffeffh ffef8h ffee0h hl de bc ax h 15 0 7 0 l d e b c a x 16-bit processing 8-bit processing ffef0h ffee8h (b) absolute name register bank 0 register bank 1 register bank 2 register bank 3 ffeffh ffef8h ffee0h rp3 rp2 rp1 rp0 r7 15 0 7 0 r6 r5 r4 r3 r2 r1 r0 16-bit processing 8-bit processing ffef0h ffee8h 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 92 jun 20, 2011 3.2.3 es and cs registers the es register is used for data access and the cs register is used to s pecify the higher address when a branch instruction is executed. the default value of the es register after reset is 0fh, and that of the cs register is 00h. figure 3-13. configuration of es and cs registers 0 0 0 0 es3 es2 es1 es0 70 es 6 5 4 3 21 0 0 0 0 cs3 cp2 cp1 cp0 70 cs 6 5 4 3 21 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 93 jun 20, 2011 3.2.4 special function registers (sfrs) unlike a general-purpose register, each sfr has a special function. sfrs are allocated to the fff00h to fffffh area. sfrs can be manipulated like general-purpo se registers, using operation, trans fer, and bit manipulation instructions. the manipulable bit units, 1, 8, and 16, depend on the sfr 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 for the 8-bit manipulation instruct ion operand (sfr). this manipulation can also be specified with an address. ? 16-bit manipulation describe the symbol reserved by the assembler for the 16-bit manipulation instruction operand (sfrp). when specifying an address, describe an even address. table 3-5 gives a list of the sfrs. the meani ngs of items in the table are as follows. ? symbol symbol indicating the address of a special function register . it is a reserved word in the ra78k0r, and is defined as an sfr variable using the #pragma sfr directive in t he cc78k0r. when using the ra78k0r, id78k0r-qb, and sm+ for 78k0r, symbols can be written as an instruction operand. ? r/w indicates whether the corresponding sfr can be read or written. r/w: read/write enable r: read only w: write only ? manipulable bit units ? ? indicates the manipulable bit unit (1, 8, or 16). ? ? ? indicates a bit unit for which manipulation is not possible. ? after reset indicates each register status upon reset signal generation. caution do not access addresses to which sfrs are not assigned. remark for extended sfrs (2nd sfrs), see 3.2.5 extended special function registers (2nd sfrs: 2nd special function registers) . 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 94 jun 20, 2011 table 3-5. sfr list (1/5) manipulable bit range address special function register (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 fff00h port register 0 p0 r/w ? 00h fff01h port register 1 p1 r/w ? 00h fff02h port register 2 p2 r/w ? 00h fff03h port register 3 p3 r/w ? 00h fff04h port register 4 p4 r/w ? 00h fff05h port register 5 p5 r/w ? 00h fff06h port register 6 p6 r/w ? 00h ? fff07h port register 7 p7 r/w ? 00h ? ? fff08h port register 8 p8 r/w ? 00h ? fff09h port register 9 p9 r/w ? 00h fff0ah port register 10 p10 r/w ? 00h fff0bh port register 11 p11 r/w ? 00h fff0ch port register 12 p12 r/w ? undefined fff0dh port register 13 p13 r/w ? 00h fff0eh port register 14 p14 r/w ? 00h fff0fh port register 15 p15 r/w ? 00h fff10h txd0/ sio00 ? ? fff11h serial data register 00 ? sdr00 r/w ? ? 0000h ? fff12h rxd0/ sio01 ? ? fff13h serial data register 01 ? sdr01 r/w ? ? 0000h ? fff14h txd3 ? fff15h serial data register 12 ? sdr12 r/w ? ? 0000h fff16h rxd3 ? fff17h serial data register 13 ? sdr13 r/w ? ? 0000h fff18h fff19h timer data register 00 tdr00 r/w ? ? 0000h fff1ah fff1bh timer data register 01 tdr01 r/w ? ? 0000h fff1eh 12-bit a/d conversion result register note adcr r ? ? 0000h fff1fh 8-bit a/d conversion result register adcrh r ? ? 00h fff20h port mode register 0 pm0 r/w ? ffh fff21h port mode register 1 pm1 r/w ? ffh fff22h port mode register 2 pm2 r/w ? ffh fff23h port mode register 3 pm3 r/w ? ffh fff24h port mode register 4 pm4 r/w ? ffh fff25h port mode register 5 pm5 r/w ? ffh fff26h port mode register 6 pm6 r/w ? ffh ? fff27h port mode register 7 pm7 r/w ? ffh ? ? note for pd78f151xa, 10-bit a/d conversion result register is applied. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 95 jun 20, 2011 table 3-5. sfr list (2/5) manipulable bit range address special function register (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 fff28h port mode register 8 pm8 r/w ? ffh ? fff29h port mode register 9 pm9 r/w ? ffh fff2ah port mode register 10 pm10 r/w ? ffh fff2bh port mode register 11 pm11 r/w ? ffh fff2ch port mode register 12 pm12 r/w ? ffh fff2eh port mode register 14 pm14 r/w ? feh fff2fh port mode register 15 pm15 r/w ? ffh fff30h a/d converter mode register adm r/w ? 00h fff31h analog input channel specification register ads r/w ? 00h fff32h a/d converter mode register 1 adm1 r/w ? 00h fff33h operational amplifier control register note oac r/w ? 00h fff36h analog reference voltage control register advrc r/w ? 00h fff37h key return mode register krm r/w ? 00h ? ? fff38h external interrupt rising edge enable register 0 egp0 r/w ? 00h fff39h external interrupt falling edge enable register 0 egn0 r/w ? 00h fff3ah external interrupt rising edge enable register 1 egp1 r/w ? 00h ? fff3bh external interrupt falling edge enable register 1 egn1 r/w ? 00h ? fff3ch input switch control register isc r/w ? 00h fff3eh timer input select register 0 tis0 r/w ? 00h fff3fh timer input select register 1 tis1 r/w ? 00h fff40h lcd mode register lcdmd r/w ? 00h fff41h lcd display mode register lcdm r/w ? 00h fff42h lcd clock control register 0 lcdc0 r/w ? 00h fff43h lcd boost level control register vlcd r/w ? 0fh fff44h txd1/ sio10 ? fff45h serial data register 02 ? sdr02 r/w ? ? 0000h fff46h rxd1 ? fff47h serial data register 03 ? sdr03 r/w ? ? 0000h fff48h txd2/ sio20 ? fff49h serial data register 10 ? sdr10 r/w ? ? 0000h fff4ah rxd2 ? fff4bh serial data register 11 ? sdr11 r/w ? ? 0000h fff50h iica shift register iica r/w ? ? 00h ? fff51h iica status register iics r ? 00h ? fff52h iica flag register iicf r/w ? 00h ? fff58h d/a d/a conversion value setting register 0 note dacs0 r/w ? ? 00h fff59h conversion value setting register w0 note ? dacs w0 r/w ? ? 0000h fff5ah d/a d/a conversion value setting register 1 note dacs1 r/w ? ? 00h fff5bh conversion value setting register w1 note ? dacs w1 r/w ? ? 0000h note dedicated to pd78f150xa. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 96 jun 20, 2011 table 3-5. sfr list (3/5) manipulable bit range address special function register (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 fff5ch d/a converter mode register dam r/w ? 00h fff64h fff65h timer data register 02 tdr02 r/w ? ? 0000h fff66h fff67h timer data register 03 tdr03 r/w ? ? 0000h fff68h fff69h timer data register 04 tdr04 r/w ? ? 0000h fff6ah fff6bh timer data register 05 tdr05 r/w ? ? 0000h fff6ch fff6dh timer data register 06 tdr06 r/w ? ? 0000h fff6eh fff6fh timer data register 07 tdr07 r/w ? ? 0000h fff70h fff71h timer data register 10 tdr10 r/w ? ? 0000h fff72h fff73h timer data register 11 tdr11 r/w ? ? 0000h fff74h fff75h timer data register 12 tdr12 r/w ? ? 0000h fff76h fff77h timer data register 13 tdr13 r/w ? ? 0000h fff90h fff91h sub-count register rsubc r ? ? 0000h fff92h second count register sec r/w ? ? 00h fff93h minute count register min r/w ? ? 00h fff94h hour count register hour r/w ? ? 12h note fff95h week count register week r/w ? ? 00h fff96h day count register day r/w ? ? 01h fff97h month count register month r/w ? ? 01h fff98h year count register year r/w ? ? 00h fff99h watch error correction register subcud r/w ? ? 00h fff9ah alarm minute register alarmwm r/w ? ? 00h fff9bh alarm hour register alarmwh r/w ? ? 12h fff9ch alarm week register alarmww r/w ? ? 00h note the value of this register is 00h if the ampm bit (bit 3 of the rtcc0 register) is set to 1 after reset. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 97 jun 20, 2011 table 3-5. sfr list (4/5) manipulable bit range address special function register (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 fff9dh real-time counter control register 0 rtcc0 r/w ? 00h fff9eh real-time counter control register 1 rtcc1 r/w ? 00h fff9fh real-time counter control register 2 rtcc2 r/w ? 00h fffa0h clock operation mode control register cmc r/w ? ? 00h fffa1h clock operation status control register csc r/w ? c0h fffa2h oscillation stabilization time counter status register ostc r ? 00h fffa3h oscillation stabilization time select register osts r/w ? ? 07h fffa4h clock control register ckc r/w ? 09h fffa5h clock output select register 0 cks0 r/w ? 00h fffa6h clock output select register 1 cks1 r/w ? 00h fffa8h reset control flag register resf r ? ? undefined note 1 fffa9h low-voltage detection register lvim r/w ? 00h note 2 fffaah low-voltage detection level select register lvis r/w ? 0eh note 3 fffabh watchdog timer enable register wdte r/w ? ? 1a/9a note 4 fffb0h dma sfr address register 0 dsa0 r/w ? ? 00h fffb1h dma sfr address register 1 dsa1 r/w ? ? 00h fffb2h dma ram address register 0l dra0l r/w ? 00h fffb3h dma ram address register 0h dra0h dra0 r/w ? 00h fffb4h dma ram address register 1l dra1l r/w ? 00h fffb5h dma ram address register 1h dra1h dra1 r/w ? 00h fffb6h dma byte count register 0l dbc0l r/w ? 00h fffb7h dma byte count register 0h dbc0h dbc0 r/w ? 00h fffb8h dma byte count register 1l dbc1l r/w ? 00h fffb9h dma byte count register 1h dbc1h dbc1 r/w ? 00h fffbah dma mode control register 0 dmc0 r/w ? 00h fffbbh dma mode control register 1 dmc1 r/w ? 00h fffbch dma operation control register 0 drc0 r/w ? 00h fffbdh dma operation control register 1 drc1 r/w ? 00h fffbeh back ground event control register bectl r/w ? 00h fffc0h ? pfcmd note 5 ? ? ? ? undefined fffc2h ? pfs note 5 ? ? ? ? undefined fffc4h ? flpmc note 5 ? ? ? ? undefined notes 1. the reset value of resf varies depending on the reset source. 2. the reset value of lvim varies depending on the reset source and the setting of the option byte. 3. the reset value of lvis varies depending on the reset source. 4. the reset value of wdte is determined by the setting of the option byte. 5. do not directly operate this sfr, because it is to be used in the self programming library. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 98 jun 20, 2011 table 3-5. sfr list (5/5) manipulable bit range address special function register (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 fffd0h if2l fffd1h interrupt request flag register 2 if2h if2 r/w 0000h fffd4h mk2l fffd5h interrupt mask flag register 2 mk2h mk2 r/w ffffh fffd8h pr02l fffd9h priority specificati on flag register 02 pr02h pr02 r/w ffffh fffdch pr12l fffddh priority specificati on flag register 12 pr12h pr12 r/w ffffh fffe0h interrupt request flag register 0l if0l r/w 00h fffe1h interrupt request flag register 0h if0h if0 r/w 00h fffe2h interrupt request flag register 1l if1l r/w 00h fffe3h interrupt request flag register 1h if1h if1 r/w 00h fffe4h interrupt mask flag register 0l mk0l mk0 r/w ffh fffe5h interrupt mask flag register 0h mk0h r/w ffh fffe6h interrupt mask flag register 1l mk1l r/w ffh fffe7h interrupt mask flag register 1h mk1h mk1 r/w ffh fffe8h priority specificati on flag register 00l pr00l r/w ffh fffe9h priority specificati on flag register 00h pr00h pr00 r/w ffh fffeah priority specificati on flag register 01l pr01l r/w ffh fffebh priority specificati on flag register 01h pr01h pr01 r/w ffh fffech priority specificati on flag register 10l pr10l r/w ffh fffedh priority specificati on flag register 10h pr10h pr10 r/w ffh fffeeh priority specificati on flag register 11l pr11l r/w ffh fffefh priority specificati on flag register 11h pr11h pr11 r/w ffh ffff0h ffff1h multiplication/division data register a (l) mdal/mula r/w ? ? 0000h ffff2h ffff3h multiplication/division data register a (h) mdah/mulb r/w ? ? 0000h ffff4h ffff5h multiplication/division data regi ster b (h) mdbh/muloh r/w ? ? 0000h ffff6h ffff7h multiplication/division data regi ster b (l) mdbl/mulol r/w ? ? 0000h remark for extended sfrs (2nd sfrs), see table 3-6 extended sfr (2nd sfr) list . 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 99 jun 20, 2011 3.2.5 extended special function registers (2nd sfrs: 2nd special function registers) unlike a general-purpose register, each extended sfr (2nd sfr) has a special function. extended sfrs are allocated to the f 0000h to f07ffh area. sfrs other t han those in the sfr area (fff00h to fffffh) are allocated to this area. an instruction that accesses t he extended sfr area, however, is 1 by te longer than an instruction that a ccesses the sfr area. extended sfrs can be manipulated like general-purpose regist ers, using operation, transfer, and bit manipulation instructions. the manipulable bit units, 1, 8, and 16, depe nd on the sfr 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 (!addr16.bit). this manipulation can also be specified with an address. ? 8-bit manipulation describe the symbol reserved by the assembler for the 8- bit manipulation instruction operand (!addr16). this manipulation can also be specified with an address. ? 16-bit manipulation describe the symbol reserved by the assembler for the 16-bit manipulation instruction operand (!addr16). when specifying an address, describe an even address. table 3-6 gives a list of the ext ended sfrs. the meanings of item s in the table are as follows. ? symbol symbol indicating the address of an ex tended sfr. it is a reserved word in the ra78k0r, and is defined as an sfr variable using the #pragma sfr directive in the cc78k 0r. when using the ra78k0r, id78k0r-qb, and sm+ for 78k0r, symbols can be written as an instruction operand. ? r/w indicates whether the corresponding extended sfr can be read or written. r/w: read/write enable r: read only w: write only ? manipulable bit units ? ? indicates the manipulable bit unit (1, 8, or 16). ? ? ? indicates a bit unit for which manipulation is not possible. ? after reset indicates each register status upon reset signal generation. caution do not access addresses to which 2nd sfrs are not assigned. remark for sfrs in the sfr area, see 3.2.4 special functi on registers (sfrs) . 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 100 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (1/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f0017h a/d port configuration register adpc r/w ? ? 10h f0030h pull-up resistor option register 0 pu0 r/w ? 00h f0031h pull-up resistor option register 1 pu1 r/w ? 00h f0033h pull-up resistor option register 3 pu3 r/w ? 00h f0034h pull-up resistor option register 4 pu4 r/w ? 00h f0035h pull-up resistor option register 5 pu5 r/w ? 00h f0037h pull-up resistor option register 7 pu7 r/w ? 00h ? ? f0038h pull-up resistor option register 8 pu8 r/w ? 00h ? f0039h pull-up resistor option register 9 pu9 r/w ? 00h f003ah pull-up resistor option register 10 pu10 r/w ? 00h f003ch pull-up resistor option register 12 pu12 r/w ? 00h f003eh pull-up resistor option register 14 pu14 r/w ? 00h f0041h port input mode register 1 pim1 r/w ? 00h f0047h port input mode register 7 pim7 r/w ? 00h ? ? f0051h port output mode register 1 pom1 r/w ? 00h f0057h port output mode register 7 pom7 r/w ? 00h ? ? f0058h port output mode register 8 pom8 r/w ? 00h ? f0060h noise filter enable register 0 nfen0 r/w ? 00h f0061h noise filter enable register 1 nfen1 r/w ? 00h f0062h noise filter enable register 2 nfen2 r/w ? 00h ? ? f0080h port function register pfall r/w ? 00h f0081h segment enable register segen r/w ? 00h f00e0h f00e1h multiplication/division data register c (l) mdcl r ? ? 0000h f00e2h f00e3h multiplication/division data register c (h) mdch r ? ? 0000h f00e8h multiplication/division control register mduc r/w ? 00h f00f0h peripheral enable register 0 per0 r/w ? 00h f00f3h operation speed mode control register osmc r/w ? ? 00h f00f4h regulator mode control register rmc r/w ? ? 00h f00f6h 20 mhz internal high-speed oscillation control register dscctl r/w ? 00h f00feh bcd adjust result register bcdadj r ? ? undefined f0100h ssr00l ? ? f0101h serial status register 00 ? ssr00 r ? ? 0000h ? f0102h ssr01l ? ? f0103h serial status register 01 ? ssr01 r ? ? 0000h ? f0104h ssr02l ? f0105h serial status register 02 ? ssr02 r ? ? 0000h f0106h ssr03l ? f0107h serial status register 03 ? ssr03 r ? ? 0000h f0108h sir00l ? ? f0109h serial flag clear trigger register 00 ? sir00 r/w ? ? 0000h ? 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 101 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (2/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f010ah sir01l ? ? f010bh serial flag clear trigger register 01 ? sir01 r/w ? ? 0000h ? f010ch sir02l ? f010dh serial flag clear trigger register 02 ? sir02 r/w ? ? 0000h f010eh sir03l ? f010fh serial flag clear trigger register 03 ? sir03 r/w ? ? 0000h f0110h f0111h serial mode register 00 smr00 r/w ? ? 0020h ? f0112h f0113h serial mode register 01 smr01 r/w ? ? 0020h ? f0114h f0115h serial mode register 02 smr02 r/w ? ? 0020h f0116h f0117h serial mode register 03 smr03 r/w ? ? 0020h f0118h f0119h serial communication operation setting register 00 scr00 r/w ? ? 0087h ? f011ah f011bh serial communication operation setting register 01 scr01 r/w ? ? 0087h ? f011ch f011dh serial communication operation setting register 02 scr02 r/w ? ? 0087h f011eh f011fh serial communication operation setting register 03 scr03 r/w ? ? 0087h f0120h se0l f0121h serial channel enable status register 0 ? se0 r ? ? 0000h f0122h ss0l f0123h serial channel start register 0 ? ss0 r/w ? ? 0000h f0124h st0l f0125h serial channel stop register 0 ? st0 r/w ? ? 0000h f0126h sps0l ? f0127h serial clock select register 0 ? sps0 r/w ? ? 0000h f0128h f0129h serial output register 0 so0 r/w ? ? 0f0fh f012ah soe0l f012bh serial output enable register 0 ? soe0 r/w ? ? 0000h f0134h sol0l ? f0135h serial output level register 0 ? sol0 r/w ? ? 0000h f0140h ssr10l ? f0141h serial status register 10 ? ssr10 r ? ? 0000h f0142h ssr11l ? f0143h serial status register 11 ? ssr11 r ? ? 0000h 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 102 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (3/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f0144h ssr12l r ? f0145h serial status register 12 ? ssr12 ? ? 0000h f0146h ssr13l r ? f0147h serial status register 13 ? ssr13 ? ? 0000h f0148h sir10l ? f0149h serial flag clear trigger register 10 ? sir10 r/w ? ? 0000h f014ah sir11l ? f014bh serial flag clear trigger register 11 ? sir11 r/w ? ? 0000h f014eh sir13l ? f014fh serial flag clear trigger register 13 ? sir13 r/w ? ? 0000h f0150h f0151h serial mode register 10 smr10 r/w ? ? 0020h f0152h f0153h serial mode register 11 smr11 r/w ? ? 0020h f0154h f0155h serial mode register 12 smr12 r/w ? ? 0020h f0156h f0157h serial mode register 13 smr13 r/w ? ? 0020h f0158h f0159h serial communication operation setting register 10 scr10 r/w ? ? 0087h f015ah f015bh serial communication operation setting register 11 scr11 r/w ? ? 0087h f015ch f015dh serial communication operation setting register 12 scr12 r/w ? ? 0087h f015eh f015fh serial communication operation setting register 13 scr13 r/w ? ? 0087h f0160h se1l f0161h serial channel enable status register 1 ? se1 r ? ? 0000h f0162h ss1l f0163h serial channel start register 1 ? ss1 r/w ? ? 0000h f0164h st1l f0165h serial channel stop register 1 ? st1 r/w ? ? 0000h f0166h sps1l ? f0167h serial clock select register 1 ? sps1 r/w ? ? 0000h f0168h f0169h serial output register 1 so1 r/w ? ? 0f0fh f016ah soe1l f016bh serial output enable register 1 ? soe1 r/w ? ? 0000h 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 103 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (4/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f0174h sol1l ? f0175h serial output level register 1 ? sol1 r/w ? ? 0000h f0180h f0181h timer counter register 00 tcr00 r ? ? ffffh f0182h f0183h timer counter register 01 tcr01 r ? ? ffffh f0184h f0185h timer counter register 02 tcr02 r ? ? ffffh f0186h f0187h timer counter register 03 tcr03 r ? ? ffffh f0188h f0189h timer counter register 04 tcr04 r ? ? ffffh f018ah f018bh timer counter register 05 tcr05 r ? ? ffffh f018ch f018dh timer counter register 06 tcr06 r ? ? ffffh f018eh f018fh timer counter register 07 tcr07 r ? ? ffffh f0190h f0191h timer mode register 00 tmr00 r/w ? ? 0000h f0192h f0193h timer mode register 01 tmr01 r/w ? ? 0000h f0194h f0195h timer mode register 02 tmr02 r/w ? ? 0000h f0196h f0197h timer mode register 03 tmr03 r/w ? ? 0000h f0198h f0199h timer mode register 04 tmr04 r/w ? ? 0000h f019ah f019bh timer mode register 05 tmr05 r/w ? ? 0000h f019ch f019dh timer mode register 06 tmr06 r/w ? ? 0000h f019eh f019fh timer mode register 07 tmr07 r/w ? ? 0000h f01a0h tsr00l ? f01a1h timer status register 00 ? tsr00 r ? ? 0000h f01a2h tsr01l ? f01a3h timer status register 01 ? tsr01 r ? ? 0000h f01a4h tsr02l ? f01a5h timer status register 02 ? tsr02 r ? ? 0000h 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 104 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (5/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f01a6h tsr03l ? f01a7h timer status register 03 ? tsr03 r ? ? 0000h f01a8h tsr04l ? f01a9h timer status register 04 ? tsr04 r ? ? 0000h f01aah tsr05l ? ? f01abh timer status register 05 ? tsr05 r ? ? 0000h ? f01ach tsr06l ? ? f01adh timer status register 06 ? tsr06 r ? ? 0000h ? f01aeh tsr07l ? f01afh timer status register 07 ? tsr07 r ? ? 0000h f01b0h te0l f01b1h timer channel enable status register 0 ? te0 r ? ? 0000h f01b2h ts0l f01b3h timer channel start register 0 ? ts0 r/w ? ? 0000h f01b4h tt0l f01b5h timer channel stop register 0 ? tt0 r/w ? ? 0000h f01b6h tps0l ? f01b7h timer clock select register 0 ? tps0 r/w ? ? 0000h f01b8h to0l ? f01b9h timer output register 0 ? to0 r/w ? ? 0000h f01bah toe0l f01bbh timer output enable register 0 ? toe0 r/w ? ? 0000h f01bch tol0l ? f01bdh timer output level register 0 ? tol0 r/w ? ? 0000h f01beh tom0l ? f01bfh timer output mode register 0 ? tom0 r/w ? ? 0000h f01c0h f01c1h timer counter register 10 tcr10 r ? ? ffffh f01c2h f01c3h timer counter register 11 tcr11 r ? ? ffffh f01c4h f01c5h timer counter register 12 tcr12 r ? ? ffffh f01c6h f01c7h timer counter register 13 tcr13 r ? ? ffffh f01c8h f01c9h timer mode register 10 tmr10 r/w ? ? 0000h f01cah f01cbh timer mode register 11 tmr11 r/w ? ? 0000h f01cch f01cdh timer mode register 12 tmr12 r/w ? ? 0000h 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 105 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (6/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f01ceh f01cfh timer mode register 13 tmr13 r/w ? ? 0000h f01d0h tsr10l ? ? ? f01d1h timer status register 10 ? tsr10 r ? ? 0000h ? ? f01d2h tsr11l ? ? ? f01d3h timer status register 11 ? tsr11 r ? ? 0000h ? ? f01d4h tsr12l ? 0000h ? ? f01d5h timer status register 12 ? tsr12 r ? ? ? ? f01d6h tsr13l ? 0000h ? ? f01d7h timer status register 13 ? tsr13 r ? ? ? ? f01d8h te1l 0000h f01d9h timer channel enable status register 1 ? te1 r ? ? f01dah ts1l f01dbh timer channel start register 1 ? ts1 r/w ? ? 0000h f01dch tt1l f01ddh timer channel stop register 1 ? tt1 r/w ? ? 0000h f01deh tps1l ? f01dfh timer clock select register 1 ? tps1 r/w ? ? 0000h f01e0h to1l ? ? ? f01e1h timer output register 1 ? to1 r/w ? ? 0000h ? ? f01e2h toe1l ? ? f01e3h timer output enable register 1 ? toe1 r/w ? ? 0000h ? ? f01e4h tol1l ? ? ? f01e5h timer output level register 1 ? tol1 r/w ? ? 0000h ? ? f01e6h tom1l ? ? ? f01e7h timer output mode register 1 ? tom1 r/w ? ? 0000h ? ? f0230h iica control register 0 iicctl0 r/w ? 00h ? f0231h iica control register 1 iicctl1 r/w ? 00h ? f0232h iica low-level width setting register iicwl r/w ? ? ffh ? f0233h iica high-level width setting register iicwh r/w ? ? ffh ? f0234h slave address register sva r/w ? ? 00h ? f0400h lcd display data memory 0 seg0 r/w ? ? 00h f0401h lcd display data memory 1 seg1 r/w ? ? 00h f0402h lcd display data memory 2 seg2 r/w ? ? 00h f0403h lcd display data memory 3 seg3 r/w ? ? 00h f0404h lcd display data memory 4 seg4 r/w ? ? 00h f0405h lcd display data memory 5 seg5 r/w ? ? 00h f0406h lcd display data memory 6 seg6 r/w ? ? 00h f0407h lcd display data memory 7 seg7 r/w ? ? 00h f0408h lcd display data memory 8 seg8 r/w ? ? 00h 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 106 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (7/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f0409h lcd display data memory 9 seg9 r/w ? ? 00h f040ah lcd display data memory 10 seg10 r/w ? ? 00h f040bh lcd display data memory 11 seg11 r/w ? ? 00h f040ch lcd display data memory 12 seg12 r/w ? ? 00h f040dh lcd display data memory 13 seg13 r/w ? ? 00h f040eh lcd display data memory 14 seg14 r/w ? ? 00h f040fh lcd display data memory 15 seg15 r/w ? ? 00h f0410h lcd display data memory 16 seg16 r/w ? ? 00h f0411h lcd display data memory 17 seg17 r/w ? ? 00h f0412h lcd display data memory 18 seg18 r/w ? ? 00h f0413h lcd display data memory 19 seg19 r/w ? ? 00h f0414h lcd display data memory 20 seg20 r/w ? ? 00h f0415h lcd display data memory 21 seg21 r/w ? ? 00h f0416h lcd display data memory 22 seg22 r/w ? ? 00h f0417h lcd display data memory 23 seg23 r/w ? ? 00h f0418h lcd display data memory 24 seg24 r/w ? ? 00h f0419h lcd display data memory 25 seg25 r/w ? ? 00h f041ah lcd display data memory 26 seg26 r/w ? ? 00h f041bh lcd display data memory 27 seg27 r/w ? ? 00h f041ch lcd display data memory 28 seg28 r/w ? ? 00h f041dh lcd display data memory 29 seg29 r/w ? ? 00h f041eh lcd display data memory 30 seg30 r/w ? ? 00h f041fh lcd display data memory 31 seg31 r/w ? ? 00h ? f0420h lcd display data memory 32 seg32 r/w ? ? 00h ? f0421h lcd display data memory 33 seg33 r/w ? ? 00h ? f0422h lcd display data memory 34 seg34 r/w ? ? 00h ? f0423h lcd display data memory 35 seg35 r/w ? ? 00h ? f0424h lcd display data memory 36 seg36 r/w ? ? 00h ? f0425h lcd display data memory 37 seg37 r/w ? ? 00h ? f0426h lcd display data memory 38 seg38 r/w ? ? 00h ? f0427h lcd display data memory 39 seg39 r/w ? ? 00h ? f0428h lcd display data memory 40 seg40 r/w ? ? 00h ? ? f0429h lcd display data memory 41 seg41 r/w ? ? 00h ? ? f042ah lcd display data memory 42 seg42 r/w ? ? 00h ? ? f042bh lcd display data memory 43 seg43 r/w ? ? 00h ? ? f042ch lcd display data memory 44 seg44 r/w ? ? 00h ? ? f042dh lcd display data memory 45 seg45 r/w ? ? 00h ? ? f042eh lcd display data memory 46 seg46 r/w ? ? 00h ? ? 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 107 jun 20, 2011 table 3-6. extended sfr (2nd sfr) list (8/8) manipulable bit range address special function regi ster (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 78k0r/lf3 78k0r/lg3 78k0r/lh3 f042fh lcd display data memory 47 seg47 r/w ? ? 00h ? ? f0430h lcd display data memory 48 seg48 r/w ? ? 00h ? ? f0431h lcd display data memory 49 seg49 r/w ? ? 00h ? ? f0432h lcd display data memory 50 seg50 r/w ? ? 00h ? ? f0433h lcd display data memory 51 seg51 r/w ? ? 00h ? ? f0434h lcd display data memory 52 seg52 r/w ? ? 00h ? ? f0435h lcd display data memory 53 seg53 r/w ? ? 00h ? ? remark for sfrs in the sfr area, see table 3-5 sfr list . 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 108 jun 20, 2011 3.3 instruction address addressing 3.3.1 relative addressing [function] relative addressing stores in the progr am counter (pc) the result of adding a displacement value included in the instruction word (signed complement data: ? 128 to +127 or ? 32768 to +32767) to the program counter (pc)?s value (the start address of the next instruction) , and specifies the program address to be used as the branch destination. relative addressing is applied only to branch instructions. figure 3-14. outline of relative addressing op code pc displace 8/16 bits 3.3.2 immediate addressing [function] immediate addressing stores immediat e data of the instruction word in the program counter, and specifies the program address to be used as the branch destination. for immediate addressing, call !!addr20 or br !!addr20 is used to specify 20-bit addresses and call !addr16 or br !addr16 is used to specify 16-bit addresses. 0000 is set to the higher 4 bits when specifying 16-bit addresses. figure 3-15. example of call !!addr20/br !!addr20 op code pc low addr. high addr. seg addr. figure 3-16. example of call !addr16/br !addr16 op code pc s low addr. high addr. pc pc h pc l 0000 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 109 jun 20, 2011 3.3.3 table indirect addressing [function] table indirect addressing specifies a table address in the callt table area (0080h to 00bfh) with the 5-bit immediate data in the instruction word, stores the contents at t hat table address and the next address in the program counter (pc) as 16-bit data, and specifies the program addre ss. table indirect addressing is applied only for callt instructions. in the 78k0r microcontrollers, branc hing is enabled only to the 64 kb space from 00000h to 0ffffh. figure 3-17. outline of table indirect addressing low addr. high addr. 0 0000 op code 00000000 10 table address pc s pc pc h pc l memory 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 110 jun 20, 2011 3.3.4 register direct addressing [function] register direct addressing stores in the program counter (pc) the contents of a gener al-purpose register pair (ax/bc/de/hl) and cs register of the cu rrent register bank specif ied with the instruction wo rd as 20-bit data, and specifies the program address. regi ster direct addressing can be applied only to the call ax, bc, de, hl, and br ax instructions. figure 3-18. outline of register direct addressing op code pc s pc pc h pc l cs rp 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 111 jun 20, 2011 3.4 addressing for processing data addresses 3.4.1 implied addressing [function] instructions for accessing registers (such as accumulators) that have special functions ar e directly specified with the instruction word, without using any register spec ification field in the instruction word. [operand format] because implied addressing can be automatically empl oyed with an instruction, no particular operand format is necessary. implied addressing can be applied only to mulu x. figure 3-19. outline of implied addressing a register op code memory 3.4.2 register addressing [function] register addressing accesses a general-purpose register as an operand. the instruction word of 3-bit long is used to select an 8-bit register and the instruction word of 2-bit long is used to select a 16-bit register. [operand format] identifier description r x, a, c, b, e, d, l, h rp ax, bc, de, hl figure 3-20. outline of register addressing register op code memory 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 112 jun 20, 2011 3.4.3 direct addressing [function] direct addressing uses immediate data in the instruction word as an operand addre ss to directly specify the target address. [operand format] identifier description addr16 label or 16-bit immediate dat a (only the space from f0000h to fffffh is specifiable) es: addr16 label or 16-bit immediate data (higher 4- bit addresses are specified by the es register) figure 3-21. example of addr16 target memory op code memory low addr. high addr. fffffh f0000h figure 3-22. example of es:addr16 op code memory low addr. high addr. fffffh 00000h target memory es 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 113 jun 20, 2011 3.4.4 short direct addressing [function] short direct addressing directly specif ies the target addresses using 8-bit data in the instruction word. this type of addressing is applied only to the space from ffe20h to fff1fh. [operand format] identifier description saddr label, ffe20h to fff1fh immediate data, or 0fe20h to 0ff1fh immediate data (only the space from ffe20h to fff1fh is specifiable) saddrp label, ffe20h to fff1fh immediate data, or 0f e20h to 0ff1fh immediate data (even address only) (only the space from ffe20h to fff1fh is specifiable) figure 3-23. outline of short direct addressing op code memory saddr fff1fh ffe20h saddr remark saddr and saddrp are used to describe the values of addresses fe20h to ff1fh with 16-bit immediate data (higher 4 bits of actual a ddress are omitted), and the values of addresses ffe20h to fff1fh with 20- bit immediate data. regardless of whether saddr or saddrp is used, addresses within the space from ffe20h to fff1fh are specified for the memory. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 114 jun 20, 2011 3.4.5 sfr addressing [function] sfr addressing directly specifies the ta rget sfr addresses using 8-bit data in the instruction word. this type of addressing is applied only to t he space from fff00h to fffffh. [operand format] identifier description sfr sfr name sfrp 16-bit-manipulatable sf r name (even address only) figure 3-24. outline of sfr addressing op code memory sfr fffffh fff00h sfr 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 115 jun 20, 2011 3.4.6 register indirect addressing [function] register indirect addressing directly spec ifies the target addresses using the c ontents of the regist er pair specified with the instruction word as an operand address. [operand format] identifier description ? [de], [hl] (only the space from f0000h to fffffh is specifiable) ? es:[de], es:[hl] (higher 4-bit addresses are specified by the es register) figure 3-25. example of [de], [hl] target memory op code memory rp fffffh f0000h figure 3-26. example of es:[de], es:[hl] op code memory fffffh 00000h target memory es rp 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 116 jun 20, 2011 3.4.7 based addressing [function] based addressing uses the cont ents of a register pair spec ified with the instruction wo rd as a base address, and 8- bit immediate data or 16-bit immediate dat a as offset data. the sum of these values is used to specify the target address. [operand format] identifier description ? [hl + byte], [de + byte], [sp + byte] (only the space from f0000h to fffffh is specifiable) ? word[b], word[c] (only the space from f0000h to fffffh is specifiable) ? word[bc] (only the space from f0 000h to fffffh is specifiable) ? es:[hl + byte], es:[de + byte] (higher 4-bit addresses are specified by the es register) ? es:word[b], es:word[c] (higher 4-bit addresses are specified by the es register) ? es:word[bc] (higher 4-bit addresses are specified by the es register) figure 3-27. example of [sp+byte] target memory op code memory byte fffffh f0000h sp 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 117 jun 20, 2011 figure 3-28. example of [hl + byte], [de + byte] target memory op code memory byte fffffh f0000h rp (hl/de) figure 3-29. example of word[b], word[c] target memory memory fffffh f0000h r (b/c) op code low addr. high addr. figure 3-30. example of word[bc] target memory memory fffffh f0000h rp (bc) op code low addr. high addr. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 118 jun 20, 2011 figure 3-31. example of es :[hl + byte], es:[de + byte] op code byte rp (hl/de) memory fffffh 00000h target memory es figure 3-32. example of es:word[b], es:word[c] r (b/c) memory fffffh 00000h target memory es op code low addr. high addr. figure 3-33. example of es:word[bc] rp (bc) memory fffffh 00000h target memory es op code low addr. high addr. 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 119 jun 20, 2011 3.4.8 based indexed addressing [function] based indexed addressing uses the cont ents of a register pair specified wit h the instruction word as the base address, and the content of the b register or c register similarly specified wit h the instruction word as offset address. the sum of these values is used to specify the target address. [operand format] identifier description ? [hl+b], [hl+c] (only the space from f0000h to fffffh is specifiable) ? es:[hl+b], es:[hl+c] (higher 4-bit addres ses are specified by the es register) figure 3-34. example of [hl+b], [hl+c] target memory memory fffffh f0000h r (b/c) rp (hl) op code figure 3-35. example of es:[hl+b], es:[hl+c] r (b/c) op code rp (hl) es memory fffffh 00000h target memory 78k0r/lx3 chapter 3 cpu architecture r01uh0004ej0501 rev.5.01 120 jun 20, 2011 3.4.9 stack addressing [function] the stack area is indirectly address ed with the stack pointer (sp) contents. this addressing is automatically employed when the push, pop, subrouti ne call, and return instructions are executed or the register is saved/restored upon generation of an interrupt request. stack addressing is applied only to the internal ram area. [operand format] identifier description ? push ax/bc/de/hl pop ax/bc/de/hl call/callt ret brk retb (interrupt request generated) reti 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 121 jun 20, 2011 chapter 4 port functions 4.1 port functions there are four types of pin i/o buffer power supplies: av dd0 , av dd , av dd1 , ev dd1 , ev dd , 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 dd0, av dd p20 to p27, p150 to p152, p157 av dd1, ev dd1 p110, p111 ev dd ? port pins other than p20 to p27, p110, p111, p150 to p152, p157 ? reset, flmd0 pins v dd pins other than port , reset, flmd0 pins 78k0r/lx3 products are provided with digital i/o ports, whic h enable variety of control oper ations. the functions of each port are shown in tables 4-2 to 4-4. in addition to the function as digital i/o ports, these ports have several alternate fu nctions. for details of the alternate functions, see chapter 2 pin functions . 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 122 jun 20, 2011 table 4-2. port functions (78k0r/lf3) (1/2) function name i/o function after reset alternate function p00 caph p01 capl p02 i/o port 0. 3-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 port v lc3 p10 sck20/scl20 p11 si20/rxd2/sda20/ intp6 p12 so20/txd2/to02 p13 so10/txd1/to04 p14 si10/rxd1/sda10/ intp4 p15 i/o port 1. 6-bit i/o port. input/output can be specified in 1-bit units. input of p10, p11, p14 and p15 can be set to ttl buffer. output of p10 to p15 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port sck10/scl10/intp7 p20 ani0/amp0- note 1 p21 ani1/amp0o note 1 p22 ani2/amp0+ note 1 p23 ani3/amp1- note 1 p24 ani4/amp1o note 1 p25 ani5/amp1+ note 1 p26 i/o port 2. 7-bit i/o port. input/output can be specified in 1-bit units. digital input port ani6 p30 ti03/to00/rtc1hz/ intp1 p31 ti00/to03/rtcdiv/ rtccl/pclbuz1/ intp2 p32 ti01/to01/intp5/ pclbuz0 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 port ti07/to07/intp3 p40 note tool0 p41 i/o port 4. 2-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 port tool1 notes 1. ampxx applies to pd78f150xa only. 2. if on-chip debugging is enabled by using an option byte, be sure to pull up the p40/tool0 pin externally. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 123 jun 20, 2011 table 4-2. port func tions (78k0r/lf3) (2/2) function name i/o function after reset alternate function p50 seg30/rxd3 p51 seg29/txd3 p52 seg28/ti02 p53 seg27/ti04 p54 to p57 i/o port 5. 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 port seg26 to seg23 p90 to p92 i/o port 9. 3-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg22 to seg20 p100 i/o port 10. 1-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg11 p110 ano0 note p111 i/o port 11. 2-bit i/o port. inputs/output can be specified in 1-bit units. input port ano1 note p120 i/o intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 input port 12. 1-bit i/o port and 4-bit input port. for only p120, input/output can be specified in 1-bit units. for only p120, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 p130 output port 13. 1-bit output port. output port ? p140 to p147 i/o port 14. 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 port seg19 to seg12 p157 i/o port 15. 1-bit i/o port. input/output can be specified in 1-bit units. digital input port ani15/av refm note note anox and av refm apply to pd78f150xa only. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 124 jun 20, 2011 table 4-3. port functions (78k0r/lg3) (1/2) function name i/o function after reset alternate function p00 caph p01 capl p02 i/o port 0. 3-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 port v lc3 p10 sck20/scl20 p11 si20/rxd2/sda20/ intp6 p12 so20/txd2/to02 p13 so10/txd1/to04 p14 si10/rxd1/sda10/ intp4 p15 sck10/scl10/intp7 p16 i/o port 1. 7-bit i/o port. input/output can be specified in 1-bit units. input of p10, p11, p14 and p15 can be set to ttl buffer. output of p10 to p15 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port ti05/to05/intp10 p20 ani0/amp0- note 1 p21 ani1/amp0o note 1 p22 ani2/amp0+ note 1 p23 ani3/amp1- note 1 p24 ani4/amp1o note 1 p25 ani5/amp1+ note 1 p26 ani6/amp2- note 1 p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani7/amp2o note 1 p30 ti03/to00/rtc1hz/ intp1 p31 ti00/to03/rtcdiv/ rtccl/pclbuz1/ intp2 p32 ti01/to01/intp5/ pclbuz0 p33 ti07/to07/intp3 p34 i/o port 3. 5-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 port ti06/to06/intp8 p40 note 2 tool0 p41 i/o port 4. 2-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 port tool1 notes 1. ampxx applies to pd78f150xa only. 2. if on-chip debugging is enabled by using an option byte, be sure to pull up the p40/tool0 pin externally. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 125 jun 20, 2011 table 4-3. port functions (78k0r/lg3) (2/2) function name i/o function after reset alternate function p50 seg39/rxd3 p51 seg38/txd3 p52 seg37/ti02 p53 seg36/ti04 p54 to p57 i/o port 5. 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 port seg35 to seg32 p60 scl0 p61 i/o port 6. 2-bit i/o port. output is n-ch open-drain output (6 v tolerance). input/output can be specified in 1-bit units. input port sda0 p80 sck00/intp11 p81 rxd0/si00/intp9 p82 i/o port 8. 3-bit i/o port. inputs/output can be specified in 1-bit units. output of p80 and p82 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port txd0/so00 p90 to p97 i/o port 9. 8-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg31 to seg24 p100 i/o port 10. 1-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg15 p110 ano0 note p111 i/o port 11. 2-bit i/o port. inputs/output can be specified in 1-bit units. input port ano1 note p120 i/o intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 input port 12. 1-bit i/o port and 4-bit input port. for only p120, input/output can be specified in 1-bit units. for only p120, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 p130 output port 13. 1-bit output port. output port ? p140 to p147 i/o port 14. 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 port seg23 to seg16 p150 ani8/amp2+ note p151 ani9 p152 ani10 p157 i/o port 15. 4-bit i/o port. input/output can be specified in 1-bit units. digital input port ani15/av refm note note anox, amp2+, and av refm apply to pd78f150xa only. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 126 jun 20, 2011 table 4-4. port functions (78k0r/lh3) (1/3) function name i/o function after reset alternate function p00 caph p01 capl p02 i/o port 0. 3-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 port v lc3 p10 sck20/scl20 p11 si20/rxd2/sda20/ intp6 p12 so20/txd2/to02 p13 so10/txd1/to04 p14 si10/rxd1/sda10/ intp4 p15 sck10/scl10/intp7 p16 ti05/to05/intp10 p17 i/o port 1. 8-bit i/o port. input/output can be specified in 1-bit units. input of p10, p11, p14 and p15 can be set to ttl buffer. output of p10 to p15 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port ? p20 ani0/amp0- note 1 p21 ani1/amp0o note 1 p22 ani2/amp0+ note 1 p23 ani3/amp1- note 1 p24 ani4/amp1o note p25 ani5/amp1+ note 1 p26 ani6/amp2- note 1 p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani7/amp2o note 1 p30 ti03/to00/rtc1hz/ intp1 p31 ti00/to03/rtcdiv/ rtccl/pclbuz1/ intp2 p32 ti01/to01/intp5/ pclbuz0 p33 ti07/to07/intp3 p34 i/o port 3. 5-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 port ti06/to06/intp8 p40 note 2 tool0 p41 i/o port 4. 2-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 port tool1 notes 1. ampxx applies to pd78f150xa only. 2. if on-chip debugging is enabled by using an option byte, be sure to pull up the p40/tool0 pin externally. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 127 jun 20, 2011 table 4-4. port functi ons (78k0r/lh3) (2/3) function name i/o function after reset alternate function p50 seg53/rxd3 p51 seg52/txd3 p52 seg51/ti02 p53 seg50/ti04 p54 to p57 i/o port 5. 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 port seg49 to seg46 p60 scl0 p61 i/o port 6. 2-bit i/o port. output is n-ch open-drain output (6 v tolerance). input/output can be specified in 1-bit units. input port sda0 p70 to p74 kr0 to kr4 p75 kr5/sck01 p76 kr6/si01 p77 i/o port 7. 8-bit i/o port. input/output can be specified in 1-bit units. input of p75 and p76 can be set to ttl buffer. output of p75 and p77 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port kr7/so01 p80 sck00/intp11 p81 rxd0/si00/intp9 p82 txd0/so00 p83 ? p84 ti10/to10 p85 ti11/to11 p86 ti12/to12 p87 i/o port 8. 8-bit i/o port. inputs/output can be specified in 1-bit units. output of p80 and p82 can be set to n-ch open-drain output (v dd tolerance). use of an on-chip pull-up resistor can be specified by a software setting. input port ti13/to13 p90 to p97 i/o port 9. 8-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg45 to seg38 p100 to p102 i/o port 10. 3-bit i/o port. inputs/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port seg29 to seg27 p110 ano0 note p111 i/o port 11. 2-bit i/o port. inputs/output can be specified in 1-bit units. input port ano1 note p120 i/o intp0/exlvi p121 x1 p122 x2/exclk p123 xt1 p124 input port 12. 1-bit i/o port and 4-bit input port. for only p120, input/output can be specified in 1-bit units. for only p120, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 note anox applies to pd78f150xa only. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 128 jun 20, 2011 table 4-4. port functi ons (78k0r/lh3) (3/3) function name i/o function after reset alternate function p130 output port 13. 1-bit output port. output port ? p140 to p147 i/o port 14. 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 port seg37 to seg30 p150 ani8/amp2+ note p151 ani9 p152 ani10 p157 i/o port 15. 4-bit i/o port. input/output can be specified in 1-bit units. digital input port ani15/av refm note note amp2+ and av refm apply to pd78f150xa only. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 129 jun 20, 2011 4.2 port configuration ports include the following hardware. table 4-5. port configuration item configuration control registers ? 78k0r/lf3 port mode registers (pmx x) : pm0 to pm5, pm9 to pm12, pm14, pm15 port registers (pxx) : p0 to p5, p9 to p15 pull-up resistor option registers (puxx) : pu0, pu1, pu3 to pu5, pu9, pu10, pu12, pu14 port input mode registers (pim1) port output mode registers (pom1) a/d port configuration register (adpc) port function register (pfall) input switch control register (isc) ? 78k0r/lg3 port mode registers (pmx x) : pm0 to pm6, pm8 to pm12, pm14, pm15 port registers (pxx) : p0 to p6, p8 to p15 pull-up resistor option registers (puxx) : pu0, pu1, pu3 to pu5, pu8 to pu10, pu12, pu14 port input mode registers (pim1) port output mode registers (pom1, pom8) a/d port configuration register (adpc) port function register (pfall) input switch control register (isc) ? 78k0r/lh3 port mode register s (pmxx) : pm0 to pm12, pm14, pm15 port registers (pxx) : p0 to p15 pull-up resistor option registers (puxx) : pu0, pu1, pu3 to pu5, pu7 to pu10, pu12, pu14 port input mode regi sters (pim1, pim7) port output mode registers (pom1, pom7, pom8) a/d port configuration register (adpc) port function register (pfall) input switch control register (isc) port ? 78k0r/lf3: total: 51 (cmos i/o: 46, cmos output: 1, cmos input: 4) ? 78k0r/lg3: total: 67 (cmos i/o: 60, cmos output: 1, cmos input: 4, n-ch open drain i/o: 2) ? 78k0r/lh3: total: 83 (cmos i/o: 76, cmos output: 1, cmos input: 4, n-ch open drain i/o: 2) pull-up resistor ? 78k0r/lf3: total: 36 ? 78k0r/lg3: total: 46 ? 78k0r/lh3: total: 62 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 130 jun 20, 2011 4.2.1 port 0 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p00/caph p01/capl p02/v lc3 port 0 is an 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 p02 pins 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 connecting a capacitor for l cd controller/driver, and power supply voltage pin for driving the lcd. reset signal generation sets port 0 to input mode. figures 4-1 and 4-2 show block diagrams of port 0. caution to use p00/caph , p01/capl, and p02/v lc3 as a general-purpose port, set bit 5 (mdset1) and bit 4 (mdset0) of lcd mode register (lcdmd) to ?0?, which is the same as their default status setting. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 131 jun 20, 2011 figure 4-1. block diagram of p00 and p01 p00/caph, p01/capl wr pu rd pu0 pm0 wr port wr pm pu00, pu01 output latch (p00, p01) pm00, pm01 ev dd p-ch p0 caph, capl lcdmd mdset1, mdset0 wr lcdmd internal bus selector selector p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 lcdmd: lcd mode register rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 132 jun 20, 2011 figure 4-2. block diagram of p02 p02/v lc3 wr pu rd pu0 pm0 wr port wr pm pu02 output latch (p02) pm02 ev dd p-ch p0 lcdm lcdm0 to lcdm2 v lc3 lcdmd mdset1, mdset0 wr lcdmd wr lcdm selector selector internal bus p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 lcdm: lcd display mode register lcdmd: lcd mode register rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 133 jun 20, 2011 4.2.2 port 1 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p10/sck20/scl20 p11/si20/rxd2/sda20/intp6 p12/so20/txd2/to02 p13/so10/txd1/to04 p14/si10/rxd1/sda10/intp4 p15/sck10/scl10/intp7 p16/ti05/to05/intp10 ? p17 ? ? port 1 is an 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 pins 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). input to the p10, p11, p14, and p15 pins can be specified through a normal input buffer or a ttl input buffer in 1-bit units using port input mode register 1 (pim1). output from the p10 to p15 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 1 (pom1). this port can also be used for serial interface clock i/o, data i/o, timer i/o, and external interrupt request input,. reset signal generation sets port 1 to input mode. figures 4-3 to 4-6 show block diagrams of port 1. cautions 1. to use p10/sck20/scl2 0 and p11/si20/rxd2/sda20/intp6 as a general-purpose port, note the serial array unit 1 setting. for de tails, refer to table 14-9 relati onship between register settings and pins (channel 0 of unit 1: csi20, uart2 reception, iic20). 2. to use p12/to02/so20/txd2 as a general-purpose port, set bit 2 (to02) of timer output register 0 (to0) and bit 2 (toe02) of timer output enable re gister 0 (toe0) to ?0?, which is the same as their default status setting. and as a general-pur pose port, note the serial array unit 1 setting. for details of serial array unit 1 setting, refer to table 14-9 relationship between register settings and pins (channel 0 of unit 1: csi20, uart2 reception, iic20). 3. to use p13/to04/so10/txd1 as a general-purpose port, set bit 4 (to04) of timer output register 0 (to0) and bit 4 (toe04) of timer output enable re gister 0 (toe0) to ?0?, which is the same as their default status setting. and as a general-pur pose port, note the serial array unit 0 setting. for details of serial array unit 0 setting, refer to table 14-7 relationship between register settings and pins (channel 2 of unit 0: csi10, uart1 transmission, iic10) 4. to use p14/si10/rxd1/sda10/intp4 and p15/ sck10/scl10/intp7 as a general-purpose port, note the serial array unit 0 setting. for details, refer to table 14- 7 relationship between register settings and pins (channel 2 of unit 0: csi10, uart1 transmission, iic10) 5. to use p16/to05/ti05/intp10 as a general-purpose po rt, set bit 5 (to05) of timer output register 0 (to0) and bit 5 (toe05) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 134 jun 20, 2011 figure 4-3. block diagram of p10, p11, p14, and p15 p10/sck20/scl20, p11/si20/rxd2/sda20/intp6, p14/si10/rxd1/sda10/intp4, p15/sck10/scl10/intp7 wr pu rd wr port pu10, pu11, pu14, pu15 alternate function alternate function output latch (p10, p11, p14, p15) ev dd p-ch pu1 p1 wr pm pm1 pom10, pom11, pom14, pom15 pom1 wr pom pm10, pm11, pm14, pm15 cmos ttl pim1 pim10, pim11, pim14, pim15 wr pim selector internal bus p1: port register 1 pu1: pull-up resistor option register 1 pim1: port input mode register 1 pom1: port output mode register 1 pm1: port mode register 1 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 135 jun 20, 2011 figure 4-4. block diagram of p12 and p13 wr pu rd wr port wr pm pu12, pu13 output latch (p12, p13) pm12, pm13 p12/so20/txd2/to02, p13/so10/txd1/to04 ev dd p-ch pu1 pm1 p1 pom12, pom13 pom1 wr pom alternate function (timer) alternate function (serial interface) selector internal bus p1: port register 1 pu1: pull-up resistor option register 1 pom1: port output mode register 1 pm1: port mode register 1 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 136 jun 20, 2011 figure 4-5. block diagram of p16 p16/ti05/to05/intp10 wr pu rd wr port wr pm ev dd p-ch pu1 pm1 p1 pm16 output latch (p16) pu16 alternate function alternate function selector internal bus p1: port register 1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 137 jun 20, 2011 figure 4-6. block diagram of p17 rd p17 p-ch wr pu wr port wr pm pu17 output latch (p17) pm17 selector ev dd pu1 pm1 p1 internal bus p1: port register 1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 138 jun 20, 2011 4.2.3 port 2 pd78f150xa pd78f151xa 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) p20/ani0/amp0- p20/ani0 p21/ani1/amp0o p20/ani1 p22/ani2/amp0+ p20/ani2 p23/ani3/amp1- p20/ani3 p24/ani4/amp1o p20/ani4 p25/ani5/amp1+ p20/ani5 p26/ani6/amp2- p26/ani6 p26/ani6 p27/ani7/amp2o ? ? p27/ani7 port 2 is an 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 converte r analog input, and oper ational amplifier i/o. to use p20/ani0/amp0- to p27/ani7/amp2o as digital input pins, set them in the digital i/o mode by using the a/d port configuration register (adpc) and in the input mode by using pm2. use t hese pins starting from the lower bit. to use p20/ani0/amp0- to p27/ani7/amp 2o as digital output pins , set them in the digita l i/o mode by using adpc and in the output mode by using pm2. to use p20/ani0/amp0- to p27/ani7/amp2o as analog input pins, set them in the analog input mode by using the a/d port configuration register (adpc) and in the input mode by using pm2. use t hese pins starting from the upper bit. all p20/ani0/amp0- to p27/ani7/amp2o are set in t he digital input mode when the reset signal is generated. figures 4-7 to 4-9 show block diagrams of port 2. caution make the av dd0 pin the same potential as the ev dd or v dd pin when port 2 is used as a digital port. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 139 jun 20, 2011 table 4-6. setting functions of ani0/amp0-/p20, ani 2/amp0+/p22, ani3/amp1-/p2 3, ani5/amp1+/p25, and ani6/amp2-/p26 pins adpc register pm2 registers oaenn bit ads register ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1- /p23, ani5/amp1+/p25, and ani6/amp2-/p26 pins 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) selects ani. setting prohibited input mode 1 does not select ani. operational amplifier input analog input selection output mode ? ? setting prohibited table 4-7. setting functions of ani1/amp0o/p 21, ani4/amp1o/p24, and ani7/amp2o/p27 pins adpc register pm2 register oaenn bit ads register ani1/amp0o/p21, ani4/amp1o/p24, and ani7/amp2o/p27 pins 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) selects ani. operational amplifier output (to be converted) input mode 1 does not select ani. operational amplifier output (not to be converted) analog input selection output mode ? ? setting prohibited remark 78k0r/lf3: n = 0, 1 78k0r/lg3, 78k0r/lh3: n = 0 to 2 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 140 jun 20, 2011 figure 4-7. block diagra m of p20, p23, and p26 p20/ani0/amp0-, p23/ani3/amp1-, p26/ani6/amp2- rd wr port wr pm output latch (p20, p23, p26) pm20, pm23, pm26 pm2 a/d converter p2 operational amplifier (-) input selector internal bus p2: port register 2 pm2: port mode register 2 rd: read signal wr : write signal figure 4-8. block diagra m of p21, p24, and p27 p21/ani1/amp0o, p24/ani4/amp1o, p27/ani7/amp2o rd wr port wr pm output latch (p21, p24, p27) pm21, pm24, pm27 pm2 a/d converter p2 operational amplifier output internal bus selector p2: port register 2 pm2: port mode register 2 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 141 jun 20, 2011 figure 4-9. block diagram of p22 to p25 p22/ani2/amp0+, p25/ani5/amp1+ rd wr port wr pm output latch (p22, p25) pm22, pm25 pm2 a/d converter p2 operational amplifier (+) input internal bus selector p2: port register 2 pm2: port mode register 2 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 142 jun 20, 2011 4.2.4 port 3 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p30/ti03/to00/rtc1hz/ intp1 p31/ti00/to03/rtcdiv/ rtccl/pclbuz1/intp2 p32/ti01/to01/pclbuz0/ intp5 p33/ti07/to07/intp3 p34/ti06/to06/intp8 ? port 3 is an 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 the p30 to p34 pins 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 3 (pu3). this port can also be used for timer i/o, real-time counter clock output, correction clock output, clock output/buzzer output, and external interrupt request input. reset signal generation sets port 3 to input mode. figure 4-10 shows a block diagram of port 3. cautions 1. to use p30/to00/ti03/rt c1hz/intp1 as a general-purpose port, set bit 5 (rcloe1) of real-time counter control register 0 (rtcc0), bit 0 (to00) of timer output register 0 (to0) and bit 0 (toe00) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 2. to use p31/to03/ti00/rtcdi v/rtccl/pclbuz1/intp2 as a general-purpose port, set bit 4 (rcloe0) of real-time counter control register 0 (rtcc0), bit 6 (rcloe2) of real-time counter control register 2 (rtcc2), bit 3 (to03) of timer output register 0 (to0), bit 3 (toe03) of timer output enable register 0 (toe0) and bit 7 of clock output select register 1 (cks1) to ?0?, which is the same as their default status setting. 3. to use p32/to01/ti01/intp5/pcl buz0 as a general-purpose port, set bit 1 (to01) of timer output register 0 (to0), bit 1 (toe01) of timer output en able register 0 (toe0) and bit 7 of clock output select register 0 (cks0) to ?0?, which is the same as their default status setting. 4. to use p33/to07/ti07/intp3 and p34/to06/ti06/intp8 as a gene ral-purpose port, set bit 7, 6 (to07, to06) of timer output regist er 0 (to0), and bit 7, 6 (toe07, toe06) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 143 jun 20, 2011 figure 4-10. block di agram of p30 to p34 p30/ti03/to00/rtc1hz/intp1, p31/ti00/to03/rtcdiv/rtccl/pclbuz1/intp2, p32/ti01/to01/pclbuz0/intp5, p33/ti07/to07/intp3, p34/ti06/to06/intp8 wr pu rd wr port wr pm ev dd p-ch pu3 pm3 p3 pm30 to pm34 output latch (p30 to p34) pu30 to pu34 alternate function alternate function selector internal bus p3: port register 3 pu3: pull-up resistor option register 3 pm3: port mode register 3 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 144 jun 20, 2011 4.2.5 port 4 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p40/tool0 p41/tool1 port 4 is an i/o port with an output latch. port 4 can be set to the input mode or output mode in 1-bit units using port mode register 4 (pm4). when the p40 an d p41 pins are used as an input port, us e of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 2 (pu2) note . this port can also be used for flash memory pr ogrammer/debugger data i/o and debugger clock output. reset signal generation sets port 4 to input mode. figure 4-11 shows a block diagram of port 4. note when a tool is connected, the p40 and p41 pi ns cannot be connected to a pull-up resistor. caution when a tool is connected, th e p40 pin cannot be used as a port pin. when the on-chip debug function is used, p41 pin can be used as follows by the mode setting on the debugger. ? 1-line mode: can be used as a port (p41). ? 2-line mode: used as a tool1 pin and cannot be used as a port (p41). 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 145 jun 20, 2011 figure 4-11. block di agram of p40, p41 p40/tool0, p41/tool1 rd wr port wr pm output latch (p40, p41) pm4 p4 wr pu ev dd p-ch pu4 pm40, pm41 pu40, pu41 alternate function alternate function internal bus selector selector p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 146 jun 20, 2011 4.2.6 port 5 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p50/rxd3/segxx (xx = 30) ( xx = 39) ( xx = 53) p51/txd3/segxx ( xx = 29) ( xx = 38) ( xx = 52) p52/ti02/segxx ( xx = 28) ( xx = 37) ( xx = 51) p53/ti04/segxx ( xx = 27) ( xx = 36) ( xx = 50) p54/segxx ( xx = 26) ( xx = 35) ( xx = 49) p55/segxx ( xx = 25) ( xx = 34) ( xx = 48) p56/segxx ( xx = 24) ( xx = 33) ( xx = 47) p57/segxx ( xx = 23) ( xx = 32) ( xx = 46) port 5 is an i/o port with an output latch. port 5 can be set to the input mode or output mode in 1-bit units using port mode register 5 (pm5). when the p50 to p57 pins 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 5 (pu5). this port can also be used for serial interface data i/o, ti mer input and segment output of lcd controller/driver. reset signal generation sets port 5 to input mode. figures 4-12 to 4-14 show block diagrams of port 5. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 147 jun 20, 2011 figure 4-12. block diagra m of p50, p52, and p53 p50/segxx/rxd3, p52/segxx/ti02, p53/segxx/ti04 rd wr port wr pm pm50, pm52, pm53 pm5 wr pu pu50, pu52, pu53 p-ch pu5 p5 ev dd output latch (p50, p52, p53) pf5l pfall wr pf lcd controller/driver wr isc isc2, isc3, isc4 isc selector selector internal bus alternate function p5: port register 5 pu5: pull-up resistor option register 5 pm5: port mode register 5 pfall: port function register isc: input switch control register rd: read signal wr : write signal remark 78k0r/lf3: p50/seg30/rxd3, p 52/seg28/ti02, p53/seg27/ti04 78k0r/lg3: p50/seg39/rxd3, p 52/seg37/ti02, p53/seg36/ti04 78k0r/lh3: p50/seg53/rxd3, p 52/seg51/ti02, p53/seg50/ti04 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 148 jun 20, 2011 figure 4-13. blo ck diagram of p51 p51/segxx/txd3 rd wr port wr pm pm51 pm5 wr pu pu51 p-ch pu5 p5 ev dd output latch (p51) pf5l pfall wr pf lcd controller/driver selector selector internal bus alternate function p5: port register 5 pu5: pull-up resistor option register 5 pm5: port mode register 5 pfall: port function register rd: read signal wr : write signal remark 78k0r/lf3: p51/seg29/txd3 78k0r/lg3: p51/seg38/txd3 78k0r/lh3: p51/seg52/txd3 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 149 jun 20, 2011 figure 4-14. block di agram of p54 to p57 p54/segxx to p57/segxx rd wr port wr pm pm54 to pm57 pm5 wr pu pu54 to pu57 p-ch pu5 p5 ev dd output latch (p54 to p57) pf5h pfall wr pf lcd controller/driver selector selector internal bus p5: port register 5 pu5: pull-up resistor option register 5 pm5: port mode register 5 pfall: port function register rd: read signal wr : write signal remark 78k0r/lf3: p54/seg26 to p57/seg23 78k0r/lg3: p54/seg35 to p57/seg32 78k0r/lh3: p54/seg53 to p57/seg50 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 150 jun 20, 2011 4.2.7 port 6 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p60/scl0 ? p61/sda0 ? port 6 is an i/o port with an output latch. port 6 can be set to the input mode or output mode in 1-bit units using port mode register 6 (pm6). the output is n-ch open-drai n output (6 v tolerance). this port can also be used for serial interface data i/o and clock i/o. reset signal generation sets port 6 to input mode. figure 4-15 shows a block diagram of port 6. caution when using p60/scl0 and p61/sda0 as a general-purpose port, stop the operation of serial interface iica. figure 4-15. block diagram of p60 and p61 p60/scl0, p61/sda0 rd wr port wr pm output latch (p60, p61) pm60, pm61 pm6 p6 alternate function alternate function internal bus selector p6: port register 6 pm6: port mode register 6 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 151 jun 20, 2011 4.2.8 port 7 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p70/kr0 ? p71/kr1 ? p72/kr2 ? p73/kr3 ? p74/kr4 ? p75/sck01 ? p76/kr6/si01 ? p77/kr7/so01 ? port 7 is an 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 pins 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). input to the p75 and p76 pins can be specified through a norma l input buffer or a ttl input buffer in 1-bit units using port input mode register 7 (pim7). output from the p75 and p77 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 7 (pom7). this port can also be used for key return input, serial interfac e clock i/o, and data i/o. reset signal generation sets port 7 to input mode. figures 4-16 to 4-19 show block diagrams of port 7. caution to use p75/sck01/kr5, p76/ si01/kr6, and p77/so01/kr7, as a gene ral-purpose port, note the serial array unit 0 setting. for details, refer to table 14- 6 relationship between regi ster settings and pins (channel 1 of unit 0: csi01, uart0 reception). 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 152 jun 20, 2011 figure 4-16. block di agram of p70 to p74 p70/kr0 to p74/kr4 wr pu rd pu7 pm7 wr port wr pm pu70 to pu74 output latch (p70 to p74) pm70 to pm74 ev dd p-ch p7 internal bus selector alternate function p7: port register 7 pu7: pull-up resistor option register 7 pm7: port mode register 7 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 153 jun 20, 2011 figure 4-17. blo ck diagram of p75 p75/kr5/sck01 wr pu rd wr port pu75 output latch (p75) ev dd p-ch pu7 p7 wr pm pm7 pom75 pom7 wr pom pm75 cmos ttl pim7 pim75 wr pim selector alternate function alternate function internal bus p7: port register 7 pu7: pull-up resistor option register 7 pim7: port input mode register 7 pom7: port output mode register 7 pm7: port mode register 7 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 154 jun 20, 2011 figure 4-18. blo ck diagram of p76 cmos ttl pim7 pim76 wr pim p76/kr6/si01 wr pu rd pu7 pm7 wr port wr pm pu76 output latch (p76) pm76 ev dd p-ch p7 selector internal bus alternate function p7: port register 7 pu7: pull-up resistor option register 7 pim7: port input mode register 7 pm7: port mode register 7 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 155 jun 20, 2011 figure 4-19. blo ck diagram of p77 p77/kr7/so01 rd wr port wr pm pu77 output latch (p77) pm77 ev dd p-ch pu77 pm7 p7 pom77 pom7 wr pom wr pu alternate function alternate function selector internal bus p7: port register 7 pu7: pull-up resistor option register 7 pom7: port output mode register 7 pm7: port mode register 7 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 156 jun 20, 2011 4.2.9 port 8 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p80/sck00/intp11 ? p81/rxd0/si00/intp9 ? p82/txd0/so00 ? p83 ? ? p84/to10/ti10 ? ? p85/to11/ti11 ? ? p86/to12/ti12 ? ? p87/to13/ti13 ? ? port 8 is an i/o port with an output latch. port 8 can be set to the input mode or output mode in 1-bit units using port mode register 8 (pm8). when the p80 to p87 pins 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 8 (pu8). output from the p80 and p82 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 8 (pom8). this port can also be used for serial interface clock i/o, data i/o, timer i/o, and external interrupt request input. reset signal generation sets port 8 to input mode. figures 4-20 to 4-24 show block diagrams of port 8. caution to use p80/sck00/intp11, p81/rxd0/si00/in tp9, and p82/so00/txd0, as a general-purpose port, note the serial array unit 0 setting. for details, re fer to table 14-5 relationship between register settings and pins (channel 0 of unit 0: csi00, uart0 reception). 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 157 jun 20, 2011 figure 4-20. blo ck diagram of p80 p80/sck00/intp11 rd wr port wr pm pu80 output latch (p80) pm80 ev dd p-ch pu8 pm8 p8 pom80 pom8 wr pom wr pu alternate function alternate function selector internal bus p8: port register 8 pu8: pull-up resistor option register 8 pom8: port output mode register 8 pm8: port mode register 8 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 158 jun 20, 2011 figure 4-21. blo ck diagram of p81 p81/rxd0/si00/intp9 wr pu rd pu8 pm8 wr port wr pm pu81 output latch (p81) pm81 ev dd p-ch p8 internal bus alternate function selector p8: port register 8 pu8: pull-up resistor option register 8 pm8: port mode register 8 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 159 jun 20, 2011 figure 4-22. blo ck diagram of p82 p82/txd0/so00 wr pu rd wr port wr pm pu82 output latch (p82) pm82 ev dd p-ch pu8 pm8 p8 pom82 pom8 wr pom selector alternate function internal bus p8: port register 8 pu8: pull-up resistor option register 8 pom8: port output mode register 8 pm8: port mode register 8 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 160 jun 20, 2011 figure 4-23. blo ck diagram of p83 rd p83 p-ch wr pu wr port wr pm pu83 output latch (p83) pm83 selector ev dd pu8 pm8 p8 internal bus p8: port register 8 pu8: pull-up resistor option register 8 pm8: port mode register 8 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 161 jun 20, 2011 figure 4-24. block di agram of p84 to p87 p84/ti10/to10, p85/ti11/to11, p86/ti12/to12, p87/ti13/to13 wr pu rd wr port wr pm ev dd p-ch pu8 pm8 p8 pm84 to pm87 output latch (p84 to p87) pu84 to pu87 selector alternate function alternate function internal bus p8: port register 8 pu8: pull-up resistor option register 8 pm8: port mode register 8 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 162 jun 20, 2011 4.2.10 port 9 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p90/segxx (xx = 22) (xx = 31) (xx = 45) p91/segxx (xx = 21) (xx = 30) (xx = 44) p92/segxx (xx = 20) (xx = 29) (xx = 43) p93/segxx ? (xx = 28) (xx = 42) p94/segxx ? (xx = 27) (xx = 41) p95/segxx ? (xx = 26) (xx = 40) p96/segxx ? (xx = 25) (xx = 39) p97/segxx ? (xx = 24) (xx = 38) port 9 is an i/o port with an output latch. port 9 can be set to the input mode or output mode in 1-bit units using port mode register 9 (pm9). when the p90 to p97 pins 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 9 (pu9). this port can also be used for segment output. reset signal generation sets port 9 to input mode. figures 4-25 and 4-26 show block diagrams of port 9. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 163 jun 20, 2011 figure 4-25. block di agram of p90 to p93 p90/segxx to p93/segxx rd wr port wr pm pm90 to pm93 pm9 wr pu pu90 to pu93 p-ch pu9 p9 ev dd output latch (p90 to p93) pf9l pfall wr pf lcd controller/driver internal bus selector selector p9: port register 9 pu9: pull-up resistor option register 9 pm9: port mode register 9 pfall: port function register rd: read signal wr : write signal remark 78k0r/lf3: p90/seg22 to p92/seg20 78k0r/lg3: p90/seg31 to p93/seg28 78k0r/lh3: p90/seg45 to p93/seg42 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 164 jun 20, 2011 figure 4-26. block di agram of p94 to p97 p94/segxx to p97/segxx rd wr port wr pm pm94 to pm97 pm9 wr pu pu94 to pu97 p-ch pu9 p9 ev dd output latch (p94 to p97) pf9h pfall wr pf lcd controller/driver internal bus selector selector p9: port register 9 pu9: pull-up resistor option register 9 pm9: port mode register 9 pfall: port function register rd: read signal wr : write signal remark 78k0r/lg3: p94/seg27 to p97/seg24 78k0r/lh3: p94/seg41 to p97/seg38 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 165 jun 20, 2011 4.2.11 port 10 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p100/segxx (xx = 11) (xx = 15) (xx = 29) p101/segxx ? ? (xx = 28) p102/segxx ? ? (xx = 27) port 10 is an i/o port with an output latch. port 10 can be set to the input mode or output mode in 1-bit units using port mode register 10 (pm10). when the p100 to p102 pins 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 10 (pu10). this port can also be used for segment output. reset signal generation sets port 10 to input mode. figure 4-27 shows a block diagram of port 10. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 166 jun 20, 2011 figure 4-27. block di agram of p100 to p102 p100/segxx to p102/segxx rd wr port wr pm pm100 to pm102 pm10 wr pu pu100 to pu102 p-ch pu10 p10 ev dd output latch (p100 to p102) pf10 pfall wr pf lcd controller/driver selector selector internal bus p10: port register 10 pu10: pull-up resistor option register 10 pm10: port mode register 10 pfall: port function register rd: read signal wr : write signal remark 78k0r/lf3: p100/seg11 78k0r/lg3: p100/seg15 78k0r/lh3: p100/seg29 to p102/seg27 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 167 jun 20, 2011 4.2.12 port 11 pd78f150xa pd78f151xa 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) p110/ano0 p110 p111/ano1 p111 port 11 is an i/o port with an output latch. port 11 can be set to the input mode or output mode in 1-bit units using port mode register 11 (pm11). this port can also be used for d/a converter analog output. reset signal generation sets port 11 to input mode. figure 4-28 shows a block diagram of port 11. caution make the av dd1 pin the same potential as the ev dd or v dd pin when port 11 is used as a digital port. figure 4-28. block di agram of p110, p111 p110/ano0, p111/ano1 rd wr port wr pm output latch (p110, p111) pm110, pm111 pm11 p11 d/a converter output dace0, dace1 dam wr dam internal bus selector selector p11: port register 11 pm11: port mode register 11 dam: d/a converter mode register rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 168 jun 20, 2011 4.2.13 port 12 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p120/intp0/exlvi p121/x1 p122/x2/exclk p123/xt1 p124/xt2 p120 is a 1-bit i/o port with an output latc h. 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 port, use of an on-chip pull-up resistor can be specified by pull-up resistor option register 12 (pu12). p121 to p124 are 4-bit input ports. this port can also be used for external interrupt request input, potential input for external low-voltage detection, connecting resonator for main system clock, connecting resonat or for subsystem clock, and external clock input for main system clock. reset signal generation sets port 12 to input mode. figures 4-29 to 4-31 show block diagrams of port 12. caution the function setting on p121 to p124 is available only once after the reset release. the port once set for connection to an oscillator cannot be used as an input port unless th e reset is performed. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 169 jun 20, 2011 figure 4-29. blo ck diagram of p120 p120/intp0/exlvi wr pu rd wr port wr pm pu120 output latch (p120) pm120 ev dd p-ch pu12 pm12 p12 selector internal bus alternate function p12: port register 12 pu12: pull-up resistor option register 12 pm12: port mode register 12 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 170 jun 20, 2011 figure 4-30. block di agram of p121 and p122 p122/x2/exclk rd exclk, oscsel cmc oscsel cmc clock generator p121/x1 rd internal bus cmc: clock operation m ode control register rd: read signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 171 jun 20, 2011 figure 4-31. block di agram of p123 and p124 p124/xt2 rd oscsels cmc oscsels cmc p123/xt1 rd clock generator internal bus cmc: clock operation m ode control register rd: read signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 172 jun 20, 2011 4.2.14 port 13 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p130 p130 is a port dedicated to 1-bit output and is provided with an output latch. figure 4-32 shows a block diagram of port 13. figure 4-32. blo ck diagram of p130 rd output latch (p130) wr port p130 p13 internal bus p13: port register 13 rd: read signal wr : write signal remark the p130 pin outputs a low level when it is used as a port function pin and a reset is effected. if p130 is set to output a high level before reset is effected, the output signal of p130 can be dummy-output as the cpu reset signal. p130 set by software reset signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 173 jun 20, 2011 4.2.15 port 14 78k0r/lf3 (80 pins: pd78f15x0a, 78f1501a, 78f15x2a) 78k0r/lg3 (100 pins: pd78f15x3a, 78f1504a, 78f15x5a) 78k0r/lh3 (128 pins: pd78f15x6a, 78f1507a, 78f15x8a) p140/segxx (xx = 19) (xx = 23) (xx = 37) p141/segxx (xx = 18) (xx = 22) (xx = 36) p142/segxx (xx = 17) (xx = 21) (xx = 35) p143/segxx (xx = 16) (xx = 20) (xx = 34) p144/segxx (xx = 15) (xx = 19) (xx = 33) p145/segxx (xx = 14) (xx = 18) (xx = 32) p146/segxx (xx = 13) (xx = 17) (xx = 31) p147/segxx (xx = 12) (xx = 16) (xx = 30) port 14 is an i/o port with an output latch. port 14 can be set to the input mode or output mode in 1-bit units using port mode register 14 (pm14). when the p140 to p147 pin is 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 14 (pu14). this port can also be used for segment output. reset signal generation sets port 14 to input mode. figures 4-33 and 4-34 show block diagrams of port 14. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 174 jun 20, 2011 figure 4-33. block di agram of p140 to p143 p140/segxx to p143/segxx rd wr port wr pm pm140 to pm143 pm14 wr pu pu140 to pu143 p-ch pu14 p14 ev dd output latch (p140 to p143) pf14l pfall wr pf lcd controller/driver internal bus selector selector p14: port register 14 pu14: pull-up resistor option register 14 pm14: port mode register 14 pfall: port function register rd: read signal wr : write signal remark 78k0r/lf3: p140/seg19 to p143/seg16 78k0r/lg3: p140/seg23 to p143/seg20 78k0r/lh3: p140/seg37 to p143/seg34 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 175 jun 20, 2011 figure 4-34. block di agram of p144 to p147 p144/segxx to p147/segxx rd wr port wr pm pm144 to pm147 pm14 wr pu pu144 to pu147 p-ch pu14 p14 ev dd output latch (p144 to p147) pf14h pfall wr pf lcd controller/driver internal bus selector selector p14: port register 14 pu14: pull-up resistor option register 14 pm14: port mode register 14 pfall: port function register rd: read signal wr : write signal remark 78k0r/lf3: p144/seg15 to p147/seg12 78k0r/lg3: p144/seg19 to p147/seg16 78k0r/lh3: p144/seg33 to p147/seg30 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 176 jun 20, 2011 4.2.16 port 15 pd78f150xa pd78f151xa 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) p150/ani8/amp2+ ? ? p150/ani8 p151/ani9 ? ? p152/ani10 ? ? p157/ani15/av refm p157/ani15 port 15 is an i/o port with an output latch. port 15 can be set to the input mode or output mode in 1-bit units using port mode register 15 (pm15). this port can also be used for a/d converter analog input, reference voltage input, and operational amplifier input. to use p150/ani8/amp2+ to p152/ani10, p157/ani15/av refm as digital input pins, set them in the digital i/o mode by using the a/d port configuration register (adpc) and in the input mode by using pm 15. use these pins starting from the lower bit. to use p150/ani8/amp2+ to p152/ani10, p157/ani15/av refm as digital output pins, set them in the digital i/o mode by using adpc and in the output mode by using pm15. all p150/ani8/amp2+ to p152/ani10, p157/ani15/av refm are set in the digital input mode when the reset signal is generated. figures 4-35 to 4-37 show block diagrams of port 15. caution make the av dd0 pin the same potential as the ev dd or v dd pin when port 15 is used as a digital port. table 4-8. setting function s of ani8/amp2+/p150 pins adpc register pm2 and pm15 registers oaenn bit ads register ani8/amp2+/p150 pins 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be a/d converted) 0 does not select ani. analog input (not to be a/d converted) selects ani. setting prohibited input mode 1 does not select ani. operational amplifier input analog input selection output mode ? ? setting prohibited 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 177 jun 20, 2011 table 4-9. setting functions of ani9/p151 and ani10/am152 pins adpc register pm15 register ads register ani9/p151 and ani10/am152 pins input mode ? digital input digital i/o selection output mode ? digital output selects ani. analog input (to be a/d converted) input mode does not select ani. analog input (not to be a/d converted) analog input selection output mode ? setting prohibited table 4-10. setting functions of ani15/av refm /p157 pin adpc register pm15 register adref bit ads register ani15/av refm /p157 pin 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) input mode 1 ? negative reference voltage input of a/d converter analog input selection output mode ? ? setting prohibited 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 178 jun 20, 2011 figure 4-35. blo ck diagram of p150 p150/ani8/amp2+ rd wr port wr pm output latch (p150) pm150 pm15 a/d converter p15 operational amplifier (+) input internal bus selector p15: port register 15 pm15: port mode register 15 rd: read signal wr : write signal figure 4-36. block di agram of p151, p152 p151/ani9, p152/ani10 rd wr port wr pm output latch (p151, p152) pm151, pm152 pm15 a/d converter p15 internal bus selector p15: port register 15 pm15: port mode register 15 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 179 jun 20, 2011 figure 4-37. blo ck diagram of p157 p157/ani15/av refm rd wr port wr pm output latch (p157) pm157 pm15 a/d converter p15 operational amplifier (-) input internal bus selector p15: port register 15 pm15: port mode register 15 rd: read signal wr : write signal 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 180 jun 20, 2011 4.3 registers controlling port function port functions are controlled by the following eight types of registers. ? port mode registers (pmxx) ? port registers (pxx) ? pull-up resistor option registers (puxx) ? port input mode registers (pimx) ? port output mode registers (pomx) ? a/d port configuration register (adpc) ? port function register (pfall) ? input switch control register (isc) (1) port mode registers (pmxx) 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 signal generation sets these registers to ffh. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 181 jun 20, 2011 figure 4-38 format of port mode register (78k0r/lf3) symbol 7 6 5 4 3 2 1 0 address after reset r/w pm0 1 1 1 1 1 pm02 pm01 pm00 fff20h ffh r/w pm1 1 1 pm15 pm14 pm13 pm12 pm11 pm10 fff21h ffh r/w pm2 1 pm26 pm25 pm24 pm23 pm22 pm21 pm20 fff22h ffh r/w pm3 1 1 1 1 pm33 pm32 pm31 pm30 fff23h ffh r/w pm4 1 1 1 1 1 1 pm41 pm40 fff24h ffh r/w pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 fff25h ffh r/w pm9 1 1 1 1 1 pm92 pm91 pm90 fff29h ffh r/w pm10 1 1 1 1 1 1 1 pm100 fff2ah ffh r/w pm11 1 1 1 1 1 1 pm111 pm110 fff2bh ffh r/w pm12 1 1 1 1 1 1 1 pm120 fff2ch ffh r/w pm14 pm147 pm146 pm145 pm144 pm143 pm142 pm141 pm140 fff2eh feh r/w pm15 pm157 1 1 1 1 1 1 1 fff2fh ffh r/w pmmn pmn pin i/o mode selection (m = 0 to 5, 9 to 12, 14, 15; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) caution be sure to set bits 3 to 7 of pm0, bits 6, 7 of pm1, bit 7 of pm2, bits 4 to 7 of pm3, bits 2 to 7 of pm4, bits 3 to 7 of pm9, bits 1 to 7 of pm10, bits 2 to 7 of pm11, bits 1 to 7 of pm12, and bits 0 to 6 of pm15 to 1. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 182 jun 20, 2011 figure 4-39 format of port mode register (78k0r/lg3) symbol 7 6 5 4 3 2 1 0 address after reset r/w pm0 1 1 1 1 1 pm02 pm01 pm00 fff20h ffh r/w pm1 1 pm16 pm15 pm14 pm13 pm12 pm11 pm10 fff21h ffh r/w pm2 pm27 pm26 pm25 pm24 pm23 pm22 pm21 pm20 fff22h ffh r/w pm3 1 1 1 pm34 pm33 pm32 pm31 pm30 fff23h ffh r/w pm4 1 1 1 1 1 1 pm41 pm40 fff24h ffh r/w pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 fff25h ffh r/w pm6 1 1 1 1 1 1 pm61 pm60 fff26h ffh r/w pm8 1 1 1 1 1 pm82 pm81 pm80 fff28h ffh r/w pm9 pm97 pm96 pm95 pm94 pm93 pm92 pm91 pm90 fff29h ffh r/w pm10 1 1 1 1 1 1 1 pm100 fff2ah ffh r/w pm11 1 1 1 1 1 1 pm111 pm110 fff2bh ffh r/w pm12 1 1 1 1 1 1 1 pm120 fff2ch ffh r/w pm14 pm147 pm146 pm145 pm144 pm143 pm142 pm141 pm140 fff2eh feh r/w pm15 pm157 1 1 1 1 pm152 pm151 pm150 fff2fh ffh r/w pmmn pmn pin i/o mode selection (m = 0 to 6, 8 to 12, 14, 15; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) caution be sure to set bits 3 to 7 of pm0, bit 7 of pm1, bits 5 to 7 of pm3, bits 2 to 7 of pm4, bits 2 to 7 of pm6, bits 3 to 7 of pm8, bits 1 to 7 of pm10, bits 2 to 7 of pm11, bits 1 to 7 of pm12, and bits 3 to 6 of pm15 to 1. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 183 jun 20, 2011 figure 4-40 format of port mode register (78k0r/lh3) symbol 7 6 5 4 3 2 1 0 address after reset r/w pm0 1 1 1 1 1 pm02 pm01 pm00 fff20h ffh r/w pm1 pm17 pm16 pm15 pm14 pm13 pm12 pm11 pm10 fff21h ffh r/w pm2 pm27 pm26 pm25 pm24 pm23 pm22 pm21 pm20 fff22h ffh r/w pm3 1 1 1 pm34 pm33 pm32 pm31 pm30 fff23h ffh r/w pm4 1 1 1 1 1 1 pm41 pm40 fff24h ffh r/w pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 fff25h ffh r/w pm6 1 1 1 1 1 1 pm61 pm60 fff26h ffh r/w pm7 pm77 pm76 pm75 pm74 pm73 pm72 pm71 pm70 fff27h ffh r/w pm8 pm87 pm86 pm85 pm84 pm83 pm82 pm81 pm80 fff28h ffh r/w pm9 pm97 pm96 pm95 pm94 pm93 pm92 pm91 pm90 fff29h ffh r/w pm10 1 1 1 1 1 pm102 pm101 pm100 fff2ah ffh r/w pm11 1 1 1 1 1 1 pm111 pm110 fff2bh ffh r/w pm12 1 1 1 1 1 1 1 pm120 fff2ch ffh r/w pm14 pm147 pm146 pm145 pm144 pm143 pm142 pm141 pm140 fff2eh feh r/w pm15 pm157 1 1 1 1 pm152 pm151 pm150 fff2fh ffh r/w pmmn pmn pin i/o mode selection (m = 0 to 12, 14, 15; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) caution be sure to set bits 3 to 7 of pm0, bits 5 to 7 of pm3, bits 2 to 7 of pm4, bits 2 to 7 of pm6, bits 3 to 7 of pm10, bits 2 to 7 of pm11, bits 1 to 7 of pm12, and bits 3 to 6 of pm15 to 1. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 184 jun 20, 2011 (2) port registers (pxx) 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 output latch value is read note . these registers can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. note it is always 0 and never a pin level that is read out if a port is read during the input mode when p2 and p15 are set to function as an analog input for a a/d converter , and p11 are set to function as an analog input for a d/a converter. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 185 jun 20, 2011 figure 4-41. format of port register (78k0r/lf3) symbol 7 6 5 4 3 2 1 0 address after reset r/w p0 0 0 0 0 0 p02 p01 p00 fff00h 00h (output latch) r/w p1 0 0 p15 p14 p13 p12 p11 p10 fff01h 00h (output latch) r/w p2 0 p26 p25 p24 p23 p22 p21 p20 fff02h 00h (output latch) r/w p3 0 0 0 0 p33 p32 p31 p30 fff03h 00h (output latch) r/w p4 0 0 0 0 0 0 p41 p40 fff04h 00h (output latch) r/w p5 p57 p56 p55 p54 p53 p52 p51 p50 fff05h 00h (output latch) r/w p9 0 0 0 0 0 p92 p91 p90 fff09h 00h (output latch) r/w p10 0 0 0 0 0 0 0 p100 fff0ah 00h (output latch) r/w p11 0 0 0 0 0 0 p111 p110 fff0bh 00h (output latch) r/w p12 0 0 0 p124 p123 p122 p121 p120 fff0ch undefined r/w note p13 0 0 0 0 0 0 0 p130 fff0dh 00h (output latch) r/w p14 p147 p146 p145 p144 p143 p142 p141 p140 fff0eh 00h (output latch) r/w p15 p157 0 0 0 0 0 0 0 fff0fh 00h (output latch) r/w m = 0 to 5, 9 to 15 ; 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 note p121 to p124 are read-only. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 186 jun 20, 2011 figure 4-42. format of port register (78k0r/lg3) symbol 7 6 5 4 3 2 1 0 address after reset r/w p0 0 0 0 0 0 p02 p01 p00 fff00h 00h (output latch) r/w p1 0 p16 p15 p14 p13 p12 p11 p10 fff01h 00h (output latch) r/w p2 p27 p26 p25 p24 p23 p22 p21 p20 fff02h 00h (output latch) r/w p3 0 0 0 p34 p33 p32 p31 p30 fff03h 00h (output latch) r/w p4 0 0 0 0 0 0 p41 p40 fff04h 00h (output latch) r/w p5 p57 p56 p55 p54 p53 p52 p51 p50 fff05h 00h (output latch) r/w p6 0 0 0 0 0 0 p61 p60 fff06h 00h (output latch) r/w p8 0 0 0 0 0 p82 p81 p80 fff08h 00h (output latch) r/w p9 p97 p96 p95 p94 p93 p92 p91 p90 fff09h 00h (output latch) r/w p10 0 0 0 0 0 0 0 p100 fff0ah 00h (output latch) r/w p11 0 0 0 0 0 0 p111 p110 fff0bh 00h (output latch) r/w p12 0 0 0 p124 p123 p122 p121 p120 fff0ch undefined r/w note p13 0 0 0 0 0 0 0 p130 fff0dh 00h (output latch) r/w p14 p147 p146 p145 p144 p143 p142 p141 p140 fff0eh 00h (output latch) r/w p15 p157 0 0 0 0 p152 p151 p150 fff0fh 00h (output latch) r/w m = 0 to 6, 8 to 15 ; 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 note p121 to p124 are read-only. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 187 jun 20, 2011 figure 4-43. format of port register (78k0r/lh3) symbol 7 6 5 4 3 2 1 0 address after reset r/w p0 0 0 0 0 0 p02 p01 p00 fff00h 00h (output latch) r/w p1 p17 p16 p15 p14 p13 p12 p11 p10 fff01h 00h (output latch) r/w p2 p27 p26 p25 p24 p23 p22 p21 p20 fff02h 00h (output latch) r/w p3 0 0 0 p34 p33 p32 p31 p30 fff03h 00h (output latch) r/w p4 0 0 0 0 0 0 p41 p40 fff04h 00h (output latch) r/w p5 p57 p56 p55 p54 p53 p52 p51 p50 fff05h 00h (output latch) r/w p6 0 0 0 0 0 0 p61 p60 fff06h 00h (output latch) r/w p7 p77 p76 p75 p74 p73 p72 p71 p70 fff07h 00h (output latch) r/w p8 p87 p86 p85 p84 p83 p82 p81 p80 fff08h 00h (output latch) r/w p9 p97 p96 p95 p94 p93 p92 p91 p90 fff09h 00h (output latch) r/w p10 0 0 0 0 0 p102 p101 p100 fff0ah 00h (output latch) r/w p11 0 0 0 0 0 0 p111 p110 fff0bh 00h (output latch) r/w p12 0 0 0 p124 p123 p122 p121 p120 fff0ch undefined r/w note p13 0 0 0 0 0 0 0 p130 fff0dh 00h (output latch) r/w p14 p147 p146 p145 p144 p143 p142 p141 p140 fff0eh 00h (output latch) r/w p15 p157 0 0 0 0 p152 p151 p150 fff0fh 00h (output latch) r/w m = 0 to 15 ; 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 note p121 to p124 are read-only. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 188 jun 20, 2011 (3) pull-up resistor option registers (puxx) these registers specify whether the on-ch ip pull-up resistors 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 specified in these registers. on-chip pull-up resistor s cannot be connected to bits set to output mode and bits used as alternate-function output pins, regardl ess of the settings of these registers. these registers can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 4-44. format of pull-up resist or option register (78k0r/lf3) symbol 7 6 5 4 3 2 1 0 address after reset r/w pu0 0 0 0 0 0 pu02 pu01 pu00 f0030h 00h r/w pu1 0 0 pu15 pu14 pu13 pu12 pu11 pu10 f0031h 00h r/w pu3 0 0 0 0 pu33 pu32 pu31 pu30 f0033h 00h r/w pu4 0 0 0 0 0 0 pu41 pu40 f0034h 00h r/w pu5 pu57 pu56 pu55 pu54 pu53 pu52 pu51 pu50 f0035h 00h r/w pu9 0 0 0 0 0 pu92 pu91 pu90 f0039h 00h r/w pu10 0 0 0 0 0 0 0 pu100 f003ah 00h r/w pu12 0 0 0 0 0 0 0 pu120 f003ch 00h r/w pu14 pu147 pu146 pu145 pu144 pu143 pu142 pu141 pu140 f003eh 00h r/w pumn pmn pin on-chip pull-up resistor selection (m = 0, 1, 3 to 5, 9, 10, 12, 14 ; n = 0 to 7) 0 on-chip pull-up resistor not connected 1 on-chip pull-up resistor connected 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 189 jun 20, 2011 figure 4-45. format of pull-up resist or option register (78k0r/lg3) symbol 7 6 5 4 3 2 1 0 address after reset r/w pu0 0 0 0 0 0 pu02 pu01 pu00 f0030h 00h r/w pu1 0 pu16 pu15 pu14 pu13 pu12 pu11 pu10 f0031h 00h r/w pu3 0 0 0 pu34 pu33 pu32 pu31 pu30 f0033h 00h r/w pu4 0 0 0 0 0 0 pu41 pu40 f0034h 00h r/w pu5 pu57 pu56 pu55 pu54 pu53 pu52 pu51 pu50 f0035h 00h r/w pu8 0 0 0 0 0 pu82 pu81 pu80 f0038h 00h r/w pu9 pu97 pu96 pu95 pu94 pu93 pu92 pu91 pu90 f0039h 00h r/w pu10 0 0 0 0 0 0 0 pu100 f003ah 00h r/w pu12 0 0 0 0 0 0 0 pu120 f003ch 00h r/w pu14 pu147 pu146 pu145 pu144 pu143 pu142 pu141 pu140 f003eh 00h r/w pumn pmn pin on-chip pull-up resistor selection (m = 0, 1, 3 to 5, 8 to 10, 12, 14 ; n = 0 to 7) 0 on-chip pull-up resistor not connected 1 on-chip pull-up resistor connected 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 190 jun 20, 2011 figure 4-46. format of pull-up resist or option register (78k0r/lh3) symbol 7 6 5 4 3 2 1 0 address after reset r/w pu0 0 0 0 0 0 pu02 pu01 pu00 f0030h 00h r/w pu1 pu17 pu16 pu15 pu14 pu13 pu12 pu11 pu10 f0031h 00h r/w pu3 0 0 0 pu34 pu33 pu32 pu31 pu30 f0033h 00h r/w pu4 0 0 0 0 0 0 pu41 pu40 f0034h 00h r/w pu5 pu57 pu56 pu55 pu54 pu53 pu52 pu51 pu50 f0035h 00h r/w pu7 pu77 pu76 pu75 pu74 pu73 pu72 pu71 pu70 f0037h 00h r/w pu8 pu87 pu86 pu85 pu84 pu83 pu82 pu81 pu80 f0038h 00h r/w pu9 pu97 pu96 pu95 pu94 pu93 pu92 pu91 pu90 f0039h 00h r/w pu10 0 0 0 0 0 pu102 pu101 pu100 f003ah 00h r/w pu12 0 0 0 0 0 0 0 pu120 f003ch 00h r/w pu14 pu147 pu146 pu145 pu144 pu143 pu142 pu141 pu140 f003eh 00h r/w pumn pmn pin on-chip pull-up resistor selection (m = 0, 1, 3 to 5, 7 to 10, 12, 14 ; n = 0 to 7) 0 on-chip pull-up resistor not connected 1 on-chip pull-up resistor connected 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 191 jun 20, 2011 (4) port input mode registers (pimx) pim1 and pim7 registers set the input buffer of p10, p11, p14, p15, p75, or p76 in 1-bit units. ttl input buffer can be selected during serial communication with an external device of the different potential. these registers can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 4-47. format of port input mode register ? 78k0r/lf3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pim1 0 0 pim15 pim14 0 0 pim11 pim10 f0041h 00h r/w ? 78k0r/lg3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pim1 0 0 pim15 pim14 0 0 pim11 pim10 f0041h 00h r/w ? 78k0r/lh3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pim1 0 0 pim15 pim14 0 0 pim11 pim10 f0041h 00h r/w pim7 0 pim76 pim75 0 0 0 0 0 f0047h 00h r/w pimmn pmn pin input buffer selection (m = 1 and 7; n = 0, 1, 4 to 6) 0 normal input buffer 1 ttl input buffer 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 192 jun 20, 2011 (5) port output mode registers (pomx) these registers set the output mode of p10 to p15, p75, p77, p80, or p82 in 1-bit units. n-ch open drain output (v dd tolerance) mode can be selected during se rial communication with an external device of the different potential, and for the sd a10, sda20 pin during simplified i 2 c communication with an external device of the same potential. these registers can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 4-48. format of port output mode register ? 78k0r/lf3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pom1 0 0 pom15 pom14 pom13 po m12 pom11 pom10 f0051h 00h r/w ? 78k0r/lg3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pom1 0 0 pom15 pom14 pom13 po m12 pom11 pom10 f0051h 00h r/w pom8 0 0 0 0 0 pom82 0 pom80 f0058h 00h r/w ? 78k0r/lh3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pom1 0 0 pom15 pom14 pom13 po m12 pom11 pom10 f0051h 00h r/w pom7 pom77 0 pom75 0 0 0 0 0 f0057h 00h r/w pom8 0 0 0 0 0 pom82 0 pom80 f0058h 00h r/w pommn pmn pin output mode selection (m = 1, 7, and 8; n = 0 to 5 and 7) 0 normal output mode 1 n-ch open-drain output (v dd tolerance) mode 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 193 jun 20, 2011 (6) a/d port configuration register (adpc) this register switches the ani0/amp0-/p20 to ani7/amp2o/p27, ani8/amp2+/p150 to ani10/p152, ani15/av refm /p157 pins to analog input or digital i/o of port. adpc can be set by an 8-bit memory manipulation instruction. reset signal generation sets this register to 10h. figure 4-49. format of a/d port configuration register (adpc) address: f0017h after reset: 10h r/w symbol 7 6 5 4 3 2 1 0 adpc 0 0 0 adpc4 adpc3 adpc2 adpc1 adpc0 analog input (a)/digita l i/o (d) switching port 15 port 2 adp c4 adp c3 adp c2 adp c1 adp c0 ani15 /av refm /p157 ani10 /p152 ani9 /p151 ani8 /amp2+ /p150 ani7 /amp2o /p27 ani6 /amp2- /p26 ani5 /amp1+ /p25 ani4 /amp1o /p24 ani3 /amp1- /p23 ani2 /amp0+ /p22 ani1 /amp0o /p21 ani0 /amp0- /p20 0 0 0 0 0 a a a a a a a a a a a a 0 0 0 0 1 a a a a a a a a a a a d 0 0 0 1 0 a a a a a a a a a a d d 0 0 0 1 1 a a a a a a a a a d d d 0 0 1 0 0 a a a a a a a a d d d d 0 0 1 0 1 a a a a a a a d d d d d 0 0 1 1 0 a a a a a a d d d d d d 0 0 1 1 1 a a a a a d d d d d d d 0 1 0 0 0 a a a a d d d d d d d d 0 1 0 0 1 a a a d d d d d d d d d 0 1 0 1 0 a a d d d d d d d d d d 0 1 1 1 1 a d d d d d d d d d d d 1 0 0 0 0 d d d d d d d d d d d d other than the above setting prohibited note this setting is prohibited for 78k0r/lf3. cautions 1. set a channel to be u sed for a/d conversion in the input mode by us ing port mode registers 2 and 15 (pm2, pm15). 2. do not set the pin that is set by adpc as digital i/o by analog input channel specification register (ads). note note note note 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 194 jun 20, 2011 (7) port function register (pfall) this register sets whether to use pins p50 to p57, p90 to p97, p100 to p102, and p140 to p147 as port pins (other than segment output pins) or segment output pins. pfall is set using a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets pfall to 00h. remark the port pins to be used alternatively with the segment output pins vary, depending on the product. ? 78k0r/lf3: p50 to p57, p90 to p92, p100, p140 to p147 ? 78k0r/lg3: p50 to p57, p90 to p97, p100, p140 to p147 ? 78k0r/lh3: p50 to p57, p90 to p97, p100 to p102, p140 to p147 figure 4-50. format of port func tion register (pfall) (1/2) address: f0080h after reset : 00h r/w symbol 7 6 5 4 3 2 1 0 pfall 0 pf14h pf14l pf10 pf9h note pf9l pf5h pf5l pf14h port/segment outputs specification of the p144 to p147 pins 0 used the p144 to p147 pins as port (other than segment output) 1 used the p144 to p147 pins as segment output pf14l port/segment outputs specification of the p140 to p143 pins 0 used the p140 to p143 pins as port (other than segment output) 1 used the p140 to p143 pins as segment output pf10 port/segment outputs specification of the p100 to p102 pins 0 used the p100 to p102 pins as port (other than segment output) 1 used the p100 to p102 pins as segment output pf9h port/segment outputs specification of the p94 to p97 pins 0 used the p94 to p97 pins as port (other than segment output) 1 used the p94 to p97 pins as segment output pf9l port/segment outputs specification of p90 to p93 pins 0 used the p90 to p93 pins as port (other than segment output) 1 used the p90 to p93 pins as segment output note 78k0r/lg3, 78k0r/lh3 only 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 195 jun 20, 2011 figure 4-50. format of port func tion register (pfall) (2/2) pf5h port/segment outputs specification of the p54 to p57 pins 0 used the p54 to p57 pins as port (other than segment output) 1 used the p54 to p57 pins as segment output pf5l port/segment outputs specification of p50 to p53 pins 0 used the p50 to p53 pins as port (other than segment output) 1 used the p50 to p53 pins as segment output caution for 78k0r/lf3, bits 3 and 7 must be set to 0. for 78k0r/lg3 and 78k0r/lh3, bit 7 must be set to 0. (8) input switch control register (isc) bits 0 and 1 of isc are used for linking with an external in terrupt or a timer array unit when performing a lin-bus communication operation with uart3. when bit 0 is set to 1, the input signal of the serial data input (r x d3) pin is selected as an external interrupt (intp0) that can be used to detect a wakeup signal. when bit 1 is set to 1, the input signal of the serial data input (r x d3) pin is selected as a timer input, so that the pulse widths of a sync break field and a sync field can be measured by the timer. bits 2 to 4 of isc are used to prevent through cu rrent from entering when using the ti04/segxx/p53, ti02/segxx/p52, and rxd3/segxx/ p50 pins as segment outputs or port outputs. the segment output pins to be used al ternatively with the ti04, ti02, and rxd3 pins are internally connected with a schmitt trigger buffer. when using these pins as segment outputs or port outputs, bits 2 to 4 of isc must be set to 0 (prohibiting input to schmitt trigger buffers) in order to prevent through current from entering. isc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. remark the segment output pins to be used alternatively with the ti02, ti04, and rxd3 pins vary, depending on the product. ? 78k0r/lf3: ti04/seg27/p53, ti02/seg28/p52, rxd3/seg30/p50 ? 78k0r/lg3: ti04/seg36/p53, ti02/seg37/p52, rxd3/seg39/p50 ? 78k0r/lh3: ti04/seg50/p53, ti02/seg51/p52, rxd3/seg53/p50 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 196 jun 20, 2011 figure 4-51. format of input s witch control register (isc) address: fff3ch after reset : 00h r/w symbol 7 6 5 4 3 2 1 0 isc 0 0 0 isc4 isc3 isc2 isc1 isc0 isc4 ti04/segxx/p53 schmitt trigger buffer control 0 disables input 1 enables input isc3 ti02/segxx/p52 schmitt trigger buffer control 0 disables input 1 enables input isc2 rxd3/segxx/p50 schmitt trigger buffer control 0 disables input 1 enables input isc1 switching channel 7 input of timer array unit 0 uses the input signal of the ti07 pin as a timer input (normal operation). 1 input signal of r x d3 pin is used as timer i nput (wakeup signal detection). isc0 switching external interrupt (intp0) input 0 uses the input signal of the intp0 pin as an external interrupt (normal operation). 1 uses the input signal of the r x d3 pin as an external interrupt (to measure the pulse widths of t he sync break field and sync field). caution be sure to clea r bits 5 to 7 to ?0?. to use the ti04/segxx/p53, ti02/segxx/ p52, and rxd3/segxx/p50 pins, set the pf5l and iscn (n = 2 to 4) bits as follows, according to the function to be used. pf5l iscn pin function 0 0 port output (default) 0 1 port input, timer input, or serial data input 1 0 segment output 1 1 setting prohibited 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 197 jun 20, 2011 4.4 port function operations port operations differ depending on whether the inpu t or output mode is set, as shown below. 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 conten ts 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 clear ed when a reset signal is generated. (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. the data of the output latch is clear ed when a reset signal is generated. 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 latc h contents, and the result is written 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 clear ed when a reset signal is generated. (2) input mode the pin level is read and an operation is performed on its contents. the result of the operation is written to the output latch, but since the output buffer is off, the pin status does not change. the data of the output latch is clear ed when a reset signal is generated. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 198 jun 20, 2011 4.4.4 connecting to external device with di fferent power potential (2.5 v, 3 v) when parts of ports 1, 7, and 8 operate with v dd = 4.0 v to 5.5 v, i/o connections wit h an external devic e that operates on a 2.5v or 3 v power supply voltage are possible. regarding inputs, cmos/ttl switching is possible on a bit-by -bit basis by port input mode registers (pim1 and pim7). moreover, regarding outputs, different power potentials can be supported by switching t he output buffer to the n-ch open drain (v dd withstand voltage) by the port output m ode registers (pom1, pom7 and pom8). (1) setting procedure when using i/o pins of uart1, uart2 csi00, csi01, csi10, and csi20 functions (a) use as 2.5v or 3 v input port <1> after reset release, the port mode is the input mode (hi-z). <2> if pull-up is needed, externally pull up the pin to be used (on-chip pull-up resistor cannot be used). in case of uart1: p14 in case of uart2: p11 in case of csi01: p75, p76 in case of csi10: p15, p14 in case of csi20: p10, p11 <3> set the corresponding bit of the pimn register to 1 to switch to the ttl input buffer. <4> v ih /v il operates on a 2.5v or 3 v operating voltage. remark n = 1, 7 (b) use as 2.5v or 3 v output port <1> after reset release, the port mode changes to the input mode (hi-z). <2> pull up externally the pin to be used ( on-chip pull-up resistor cannot be used). in case of uart1: p13 in case of uart2: p12 in case of csi00: p80, p82 in case of csi01: p75, p77 in case of csi10: p15, p13 in case of csi20: p10, p12 <3> set the output latch of the corresponding port to 1. <4> set the corresponding bit of the pomn regi ster to 1 to set the n-ch open drain output (v dd withstand voltage) mode. <5> set the output mode by mani pulating the pmn register. at this time, the output data is high level, so the pin is in the hi-z state. <6> operation is done only in the low level accordi ng to the operating status of the serial array unit. remark n = 1, 7, 8 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 199 jun 20, 2011 (2) setting procedure when using i/o pi ns of simplified iic10, iic20 functions <1> after reset release, the port mode is the input mode (hi-z). <2> externally pull up the pin to be used (o n-chip pull-up resistor cannot be used). in case of simplified iic10: p14, p15 in case of simplified iic20: p11, p10 <3> set the output latch of the corresponding port to 1. <4> set the corresponding bit of the pom1 regist er to 1 to set the n-ch open drain output (v dd withstand voltage) mode. <5> set the corresponding bit of the pm 1 register to the output mode (data i/o is possible in the output mode). at this time, the output data is high level, so the pin is in the hi-z state. <6> enable the operation of the serial arra y unit and set the mode to the simplified i 2 c mode. 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 200 jun 20, 2011 4.5 settings of port mode register and output latch when using alternate function to use the alternate function of a por t pin, set the port mode register and output latch as shown in table 4-11. table 4-11. settings of port mode register a nd output latch when using alternate function (1/5) alternate function lf3 lg3 lh3 pin name function name i/o pfall (pfxxx) isc (iscx) pm p p00 caph output ? ? p01 capl output ? ? p02 v lc3 i/o ? ? input ? ? 1 sck20 output ? ? 0 1 p10 scl20 i/o ? ? 0 1 si20 input ? ? 1 rxd2 input ? ? 1 sda20 i/o ? ? 0 1 p11 intp6 input ? ? 1 so20 output ? ? 0 1 txd2 output ? ? 0 1 p12 to02 output ? ? 0 0 so10 output ? ? 0 1 txd1 output ? ? 0 1 p13 to04 output ? ? 0 0 si10 input ? ? 1 rxd1 input ? ? 1 sda10 i/o ? ? 0 1 p14 intp4 input ? ? 1 input ? ? 1 sck10 output ? ? 0 1 scl10 i/o ? ? 0 1 p15 intp7 input ? ? 1 ti05 input ? ? 1 to05 output ? ? 0 0 ? p16 intp10 input ? ? 1 remark : don?t care ? : not applicable pfall: port function register isc: input switch control register pm : port mode register p : port output latch 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 201 jun 20, 2011 table 4-11. settings of port mode register a nd output latch when using alternate function (2/5) alternate function lf3 lg3 lh3 pin name function name i/o pfall (pfxxx) isc (iscx) pm p ani0-ani5 input ? ? 1 amp0-, amp0+, amp1-, amp1+ input ? ? 1 p20 to 25 note amp0o, amp1o output ? ? 1 ani6 input ? ? 1 ? p26 note amp2- input ? ? 1 ani7 input ? ? 1 ? p27 note amp2o output ? ? 1 ti03 input ? ? 1 to00 output ? ? 0 0 rtc1hz output ? ? 0 0 p30 intp1 input ? ? 1 ti00 input ? ? 1 to03 output ? ? 0 0 rtcdiv output ? ? 0 0 rtccl output ? ? 0 0 pclbuz1 output ? ? 0 0 p31 intp2 input ? ? 1 ti01 input ? ? 1 to01 output ? ? 0 0 intp5 input ? ? 1 p32 pclbuz0 output ? ? 0 0 ti07 input ? isc1=0 1 to07 output ? ? 0 0 p33 intp3 input ? ? 1 ti06 input ? ? 1 to06 output ? ? 0 0 ? p34 intp8 input ? ? 1 note the function of the p20/ani0/amp0-, p21/an i1/amp0o, p22/ani2/amp0+, p23/ani3/amp1-, p24/ani4/amp1o, p25/ani5/amp1+, p26/ani6 pins c an be selected by using t he a/d port configuration register (adpc), port mode register 2 (pm2), analo g input channel specification register (ads), and operational amplifier control register (oac). refer to 4.2.3 port 2 . remark : don?t care ? : not applicable pfall: port function register isc: input switch control register pm : port mode register p : port output latch 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 202 jun 20, 2011 table 4-11. settings of port mode register a nd output latch when using alternate function (3/5) alternate function lf3 lg3 lh3 pin name function name i/o pfall (pfxxx) isc (iscx) pm p p40 tool0 i/o ? ? p41 tool1 output ? ? p50 note 1 rxd3 input isc2=1 note 2 1 p51 note 1 txd3 output ? 0 1 p52 note 1 ti02 input isc3=1 1 p53 note 1 ti04 input pf5l=0 isc4=1 1 ? p60 scl0 i/o ? ? 0 0 ? p61 sda0 i/o ? ? 0 0 ? ? p70 to p74 kr0 to kr4 input ? ? 1 kr5 input ? ? 1 input ? ? 1 ? ? p75 sck01 output ? ? 0 1 kr6 input ? ? 1 ? ? p76 si01 input ? ? 1 kr7 input ? ? 1 ? ? p77 so01 output ? ? 0 1 input ? ? 1 sck00 output ? ? 0 1 ? p80 intp11 input ? ? 1 rxd0 input ? ? 1 si00 input ? ? 1 ? p81 intp9 input ? ? 1 txd0 output ? ? 0 1 ? p82 so00 output ? ? 0 1 ti10 input ? ? 1 ? ? p84 to10 output ? ? 0 0 ti11 input ? ? 1 ? ? p85 to11 output ? ? 0 0 notes 1. refer to table 4-11 settings of port mode register and output latch when using alternate function (5/5) about the segment output (segxx). 2. the rxd3 input can be set as the input source of an ex ternal interrupt input (intp0) by setting isc0 = 1. the rxd3 input can be set as the inpu t source of a timer input (ti07) by setting isc1 = 1. remark : don?t care ? : not applicable pfall: port function register isc: input switch control register pm : port mode register p : port output latch 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 203 jun 20, 2011 table 4-11. settings of port mode register a nd output latch when using alternate function (4/5) alternate function lf3 lg3 lh3 pin name function name i/o pfall (pfxxx) isc (iscx) pm p ti12 input ? ? 1 ? ? p86 to12 output ? ? 0 0 ti13 input ? ? 1 ? ? p87 to13 output ? ? 0 0 p110, p111 ano0, ano1 output ? ? 0 intp0 note 1 input ? isc0 = 0 1 p120 exlvi note 1 input ? ? 1 p121 x1 note 1 ? ? ? x2 note 1 ? ? ? p122 exclk note 1 input ? ? p123 xt1 note 1 ? ? ? p124 xt2 note 1 ? ? ? ani8 input ? ? 1 ? p150 note 2 amp2+ input ? ? 1 ? p151, p152 note 2 ani9, ani10 input ? ? 1 ani15 input ? ? 1 p157 note 2 av refm input ? ? 1 notes 1. to use the p121 to p124 pins for main system clo ck resonator connection (x1, x2), subsystem clock resonator connection (xt1, xt2), or main system cloc k external clock input (exclk), the x1 oscillation mode, xt1 oscillation mode, or external clock input m ode must be set, respectively, by using the clock operation mode control register (cmc). cmc can be wri tten only once after reset release (for details, refer to 5.3 (1) clock operation mode control register (cmc) ). the reset value of cmc is 00h (both p121 to p124 are input port pins). 2. the p150/ani8/amp2+, p151/ani9 , p152/ani10, p157/ani15/av refm pins are as shown below depending on the settings of the a/d port conf iguration register (adpc), port m ode register 2 (pm2), analog input channel specification register (ads ), operational amplifier control r egister (oac), and analog reference voltage control register (advrc). refer to 4.2.16 port 15 . remark : don?t care ? : not applicable pfall: port function register isc: input switch control register pm : port mode register p : port output latch 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 204 jun 20, 2011 table 4-11. settings of port mode register a nd output latch when using alternate function (5/5) alternate function lf3 lg3 lh3 pin name function name i/o pfall (pfxxx) isc (iscx) pm p p50 note seg30 output pf5l=1 isc2 = 0 p51 note seg29 output pf5l=1 ? p52 note seg28 output pf5l=1 isc3 = 0 p53 note seg27 output pf5l=1 isc4 = 0 p54 to 57 seg26 to seg23 output pf5h=1 ? p90 to 92 seg22 to seg20 output pf9l=1 ? p140 to 143 seg19 to seg16 output pf14l=1 ? p144 to 147 seg15 to seg12 output pf14h=1 ? ? ? p100 seg11 output pf10=1 ? p50 note seg39 output pf5l=1 isc2 = 0 p51 note seg38 output pf5l=1 ? p52 note seg37 output pf5l=1 isc3 = 0 p53 note seg36 output pf5l=1 isc4 = 0 p54 to 57 seg35 to seg32 output pf5h=1 ? p90 to 93 seg31 to seg28 output pf9l=1 ? p94 to 97 seg27 to seg24 output pf9h=1 ? p140 to 143 seg23 to seg20 output pf14l=1 ? p144 to 147 seg19 to seg16 output pf14h=1 ? ? ? p100 seg15 output pf10=1 ? p50 note seg53 output pf5l=1 isc2 = 0 p51 note seg52 output pf5l=1 ? p52 note seg51 output pf5l=1 isc3 = 0 p53 note seg50 output pf5l=1 isc4 = 0 p54 to 57 seg49 to seg46 output pf5h=1 ? p90 to 93 seg45 to seg42 output pf9l=1 ? p94 to 97 seg41 to seg38 output pf9h=1 ? p140 to 143 seg37 to seg34 output pf14l=1 ? p144 to 147 seg33 to seg30 output pf14h=1 ? ? ? p100 to 102 seg29 to seg27 output pf10=1 ? note for alternate function other than the segment output (segxx), refer to table 4-11 settings of port mode register and output latch when using alternate function (3/5). remark : don?t care ? : not applicable pfall: port function register isc: input switch control register pm : port mode register p : port output latch 78k0r/lx3 chapter 4 port functions r01uh0004ej0501 rev.5.01 205 jun 20, 2011 4.6 cautions on 1-bit manipulation in struction for port register n (pn) when a 1-bit manipulation instruction is executed on a port that provides both input and output functions, the output latch value of an input port that is not subject to mani pulation may be written in addition to the targeted bit. therefore, it is recommended to rewr ite the output latch when switching a port from input mode to output mode. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 206 jun 20, 2011 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 = 2 to 20 mhz by connecting a resonator to x1 and x2. oscillation can be stopped by executing the stop inst ruction or setting of msto p (bit 7 of the clock operation status control register (csc)). <2> internal high-speed oscillator note this circuit oscillates clocks of f ih = 1 mhz (typ.) or f ih = 8 mhz (typ.). after a reset release, the cpu always starts operating with this internal high-spe ed oscillation clock. oscillation can be stopped by executing the stop instruction or setting hiostop (bit 0 of csc). <3> 20 mhz internal high-sp eed oscillation clock oscillator note this circuit oscillates a clock of f ih20 = 20 mhz (typ.). oscillation can be started by setting bit 0 (dscon) of the 20 mhz internal high-speed oscillation control register (dscctl) to 1 with v dd 2.7 v. oscillation can be stopped by setting dscon to 0. note to use the internal high-speed oscillation clock, use the option byte to set the frequency (1 mhz, 8 mhz, or 20 mhz) in advance (for details, see chapter 26 option byte ). also, the internal high- speed oscillator automatically star ts oscillating after reset release. to use the 20 mhz internal high- speed oscillator to operate the microcontroller, osc illation is started by setting bit 0 (dscon) of the 20 mhz internal high-speed oscillation control register (dscctl) to 1. an external main system clock (f ex = 2 to 20 mhz) can also be supplied from the exclk/x2/p122 pin. an external main system clock input can be di sabled by executing the stop in struction or setting of mstop. as the main system clock, a high-speed system clock (x1 clock or external main system clock) or internal high- speed oscillation clock can be selected by setting of mcm0 (bit 4 of the syst em clock control register (ckc)). remark f x : x1 clock oscillation frequency f ih : internal high-speed oscillation clock frequency f ih20 : 20 mhz internal high-speed oscillation clock frequency f ex : external main system clock frequency 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 207 jun 20, 2011 (2) subsystem clock ? xt1 clock oscillator this circuit oscillates a clock of f sub = 32.768 khz by connecting a 32.768 khz resonator to xt1 and xt2. oscillation can be stopped by se tting xtstop (bit 6 of csc). (3) internal low-speed oscillation clock (clock for watchdog timer) ? internal low-speed oscillator this circuit oscillates a clock of f il = 30 khz (typ.). the internal low-speed oscillation clock cannot be used as the cpu clock. the only hardware that operates with the internal low-speed oscillation clock is the watchdog timer. oscillation is stopped when the watchdog timer stops. remarks 1. f sub : subsystem clock frequency f il : internal low-speed oscillation clock frequency 2. the watchdog timer stops in the following cases. ? when bit 4 (wdton) of an option byte (000c0h) = 0 ? if the halt or stop instructi on is executed when bit 4 (wdton) of an option byte (000c0h) = 1 and bit 0 (wdstbyon) = 0 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 control register (cmc) clock operation status control register (csc) oscillation stabilization time counter status register (ostc) oscillation stabilization time select register (osts) system clock control register (ckc) 20 mhz internal high-speed oscilla tion control register (dscctl) peripheral enable registers 0 (per0) operation speed mode control register (osmc) oscillators x1 oscillator xt1 oscillator internal high-speed oscillator internal low-speed oscillator 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 208 jun 20, 2011 figure 5-1. block diag ram of clock generator xt1/p123 xt2//p124 f sub f clk css cls osts1 osts0 osts2 3 most 18 most 17 most 15 most 13 most 11 mstop stop mode signal exclk oscsel amph 3 f mx f xt x1/p121 x2/exclk /p122 f x f ex mcm0 mcs md iv2 md iv1 md iv0 cpu f main /2 5 f main /2 4 f main /2 3 f main /2 2 f main /2 f main sdiv most 10 most 9 most 8 sau1 en iica en dac en rtc en f sub /2 xtstop hiostop cls f ih f main option byte(000c1h) frqsel2, frqsel1 f ih1 f ih8 option byte(000c0h) wdton wdstbyon f il halt/stop mode signal standby control circuit (see chapter 24) halt mode stop mode normal operation mode f sub f subc f mainc adc en sau0 en tau0 en tau1 en f subc /2 internal bus clock operation mode control register (cmc) high-speed system clock oscillator crystal/ceramic oscillation external input clock internal high-speed oscillator internal high-speed oscillation (1 mhz (typ.)) internal high-speed oscillation (8 mhz (typ.)) internal low-speed oscillator internal low-speed oscillation (30 khz (typ.)) subsystem clock oscillator crystal oscillation clock operation mode control register (cmc) clock operation status control register (csc) internal bus watchdog timer real-time counter, clock output/buzzer output main system clock source selection clock output/ buzzer output prescaler prescaler selector selector selection of cpu clock and peripheral hardware clock source timer array unit 0 controller timer array unit 1 serial array unit 0 timer array unit 0 serial array unit 1 serial interface iica a/d converter, operational amplifiers, voltage reference d/a converter real-time counter peripheral enable register 0 (per0) system clock control register (ckc) oscillation stabilization time select register (osts) x1 oscillation stabilization time counter oscillation stabilization time counterstatus register (ostc) clock operation status control register (csc) sdiv oscsels amphs0 amphs1 20 mhz internal high-speed oscillation control register (dscctl) dscs dscon seldsc f ih20 20 mhz internal high-speed oscillator i nternal high-speed oscillation (20 mhz (typ.)) f ih20 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 209 jun 20, 2011 remark f x : x1 clock oscillation frequency f ih : internal high-speed oscillation clock frequency f ih1 : 1 mhz internal high-speed oscillation clock frequency f ih8 : 8 mhz internal high-speed oscillation clock frequency f ih20 : 20 mhz internal high-speed oscillation clock frequency f ex : external main system clock frequency f mx : high-speed system clock frequency f main : main system clock frequency f mainc : main system selection clock frequency f xt : xt1 clock oscillation frequency f sub : subsystem clock frequency f subc : subsystem selection clock frequency f clk : cpu/peripheral hardware clock frequency f il : internal low-speed oscillation clock frequency 5.3 registers controlling clock generator the following eight registers are us ed to control the clock generator. ? clock operation mode control register (cmc) ? clock operation status control register (csc) ? oscillation stabilization time c ounter status register (ostc) ? oscillation stabilization time select register (osts) ? system clock control register (ckc) ? 20 mhz internal high-speed oscillation control register (dscctl) ? peripheral enable register 0 (per0) ? operation speed mode control register (osmc) (1) clock operation mode control register (cmc) this register is used to set the operation mode of t he x1/p121, x2/exclk/p122, xt1/ p123, and xt2/p124 pins, and to select a gain of the oscillator. cmc can be written only once by an 8-bit memory manipulation instruction after reset release. this register can be read by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 210 jun 20, 2011 figure 5-2. format of clock operat ion mode control register (cmc) address: fffa0h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 cmc exclk oscsel 0 oscsels 0 amphs1 amphs0 amph exclk oscsel high-speed system clock pin operation mode x1/p121 pin x2/exclk/p122 pin 0 0 input port mode input port 0 1 x1 oscillation mode crystal/ceramic resonator connection 1 0 input port mode input port 1 1 external clock input mode input port external clock input oscsels subsystem clock pin operat ion mode xt1/p123 pin xt2/p124 pin 0 input port mode input port 1 xt1 oscillation mode crystal resonator connection amphs1 amphs0 xt1 oscillator oscillation mode selection 0 0 low-consumption oscillation 0 1 normal oscillation 1 0 1 1 super-low-consumption oscillation amph control of high-speed system clock oscillation frequency 0 2 mhz f mx 10 mhz 1 10 mhz < f mx 20 mhz remark f mx : high-speed system clock frequency cautions 1. cmc can be written only once after reset release, by an 8- bit memory manipulation instruction. 2. after reset release, set cmc before x1 or xt1 oscilla tion is started as set by the clock operation status control register (csc). 3. be sure to set amph to 1 if the x1 clock oscillation fr equency exceeds 10 mhz. 4. to use cmc with its initial value (00h), be su re to set it to 00h a fter releasing reset in order to prevent malfunction when a program loop occurs. 5. the xt1 oscillator is designed as a low-gain circuit for achieving low-power consumption. note the following poin ts when designing the xt1 oscillator. ? the pins and circuit board include parasi tic capacitance. therefore, confirm that there are no problems by performing osc illation evaluation on the circuit board to be actually used. ? when low-consumption oscillation or super-low-consumpt ion oscillation is selected, lower power consumption than when selecting normal oscillation can be achieved. however, in this case, the xt1 oscillati on margin is reduced, so perform sufficient oscillation evaluation of the resonator to be used for xt1 oscillation before usi ng the resonator. (cautions are continued on the next page.) 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 211 jun 20, 2011 ? keep the wiring length between the xt1 and xt2 pins and resonator as short as possible and parasitic capacitance and wire resistance as small as possible. this is particularly impor tant when super-low- consumption oscillation (amphs1 = 1) is selected. ? configure the circuit board by using ma terial with little par asitic capacitance and wire resistance. ? place a ground pattern that h as the same potential as v ss (if possible) around the xt1 oscillator. ? do not cross the signal lines between the xt1 and xt2 pins and the resonator with other signal lines. do not route the signal lines near a signal line through which a high fluctuating current flows. ? moisture absorption by the circuit boa rd and condensation on the board in a highly humid environment may cause th e impedance between the xt1 and xt2 pins to drop and disable oscillation. wh en using the circuit board in such an environment, prevent the circuit board from absorbing moisture by taking measures such as coating the circuit board. ? coat the surface of the ci rcuit board by using materi al that does not generate capacitance or leakage between the xt1 and xt2 pins. (2) clock operation status control register (csc) this register is used to control the operations of the high-speed system clock, internal high-speed oscillation clock, and subsystem clock (except the 20 mhz internal high-speed oscillation clock and internal low-speed oscillation clock). csc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets this register to c0h. figure 5-3. format of clock operati on status control register (csc) address: fffa1h after reset: c0h r/w symbol <7> <6> 5 4 3 2 1 <0> csc mstop xtstop 0 0 0 0 0 hiostop high-speed system clock operation control mstop x1 oscillation mode external clock input mode input port mode 0 x1 oscillator operating external clock from exclk pin is valid 1 x1 oscillator stopped external clock from exclk pin is invalid ? subsystem clock operation control xtstop xt1 oscillation mode input port mode 0 xt1 oscillator operating 1 xt1 oscillator stopped ? hiostop internal high-speed oscillation clock operation control 0 internal high-speed oscillator operating 1 internal high-speed oscillator stopped caution 1. after reset release, set the clock operation mode control register (cmc) before starting x1 oscillation as set by mstop or xt1 oscillation as set by xtstop. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 212 jun 20, 2011 cautions 2. to start x1 oscillati on as set by mstop, check the osc illation stabilization time of the x1 clock by using the oscillation stabilizat ion time counter stat us register (ostc). 3. do not stop the cl ock selected for the cpu pe ripheral hardware clock (f clk ) with the osc register. 4. the setting of the flags of the register to stop clock oscillation (invalidate the external clock input) and the condition before clock o scillation is to be stopped are as follows. table 5-2. condition before stoppin g clock oscillation and flag setting clock condition befo re stopping clock (invalidating external clock input) setting of csc register flags x1 clock external main system clock cpu and peripheral hardware cl ocks operate with a clock other than the high-speed system clock. ? cls = 0 and mcs = 0 ? cls = 1 mstop = 1 subsystem clock cpu and peripheral hardware cl ocks operate with a clock other than the subsystem clock. (cls = 0) xtstop = 1 internal high-speed oscillation clock cpu and peripheral hardware cl ocks operate with a clock other than the internal high-speed oscillator clock and 20 mhz internal high-speed oscillation clock. ? cls = 0 and mcs = 1 ? cls = 1 hiostop = 1 (3) oscillation stabilization time c ounter status register (ostc) this is the register that indicates the count status of the x1 clock osci llation stabilization time counter. the x1 clock oscillation stabilization time can be checked in the following case, ? if the x1 clock starts oscillation while the internal hi gh-speed oscillation clock or subsystem clock is being used as the cpu clock. ? if the stop mode is entered and then re leased while the internal high-speed oscillation clock is being used as the cpu clock with the x1 clock oscillating. ostc can be read by a 1-bit or 8-bit memory manipulation instruction. when reset signal is generated, the stop instruction and mstop (bit 7 of csc register) = 1 clear ostc to 00h. remark the oscillation stabilization time counter starts counting in the following cases. ? when oscillation of the x1 clock starts (exclk, oscsel = 0, 1 mstop = 0) ? when the stop mode is released 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 213 jun 20, 2011 figure 5-4. format of oscillation stabilizati on time counter status register (ostc) address: fffa2h after reset: 00h r symbol 7 6 5 4 3 2 1 0 ostc most 8 most 9 most 10 most 11 most 13 most 15 most 17 most 18 oscillation stabilization time status most 8 most 9 most 10 most 11 most 13 most 15 most 17 most 18 f x = 10 mhz f x = 20 mhz 0 0 0 0 0 0 0 0 2 8 /f x max. 25.6 s max. 12.8 s max. 1 0 0 0 0 0 0 0 2 8 /f x min. 25.6 s min. 12.8 s min. 1 1 0 0 0 0 0 0 2 9 /f x min. 51.2 s min. 25.6 s min. 1 1 1 0 0 0 0 0 2 10 /f x min. 102.4 s min. 51.2 s min. 1 1 1 1 0 0 0 0 2 11 /f x min. 204.8 s min. 102.4 s min. 1 1 1 1 1 0 0 0 2 13 /f x min. 819.2 s min. 409.6 s min. 1 1 1 1 1 1 0 0 2 15 /f x min. 3.27 ms min. 1.64 ms min. 1 1 1 1 1 1 1 0 2 17 /f x min. 13.11 ms min. 6.55 ms min. 1 1 1 1 1 1 1 1 2 18 /f x min. 26.21 ms min. 13.11 ms min. cautions 1. after the above time has elapsed, the bits are set to 1 in order from most8 and remain 1. 2. the oscillation stabilization time count er counts up to the oscillation stabilization time set by osts. in the following cases, set the oscillation stabilization time of osts to the value greater than the count value which is to be checked by the ostc register after the oscillation starts. ? if the x1 clock starts oscillation while th e internal high-speed oscillation clock or subsystem clock is being used as the cpu clock. ? if the stop mode is entered and then released while the internal high-speed oscillation clock is being used as the cp u clock with the x1 clock oscillating. (note, therefore, that only the status up to the oscillation stabilization time set by osts is set to ostc after th e stop mode is released.) 3. the x1 clock oscillation stabilization wait 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 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 214 jun 20, 2011 (4) 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 operat ion automatically waits for the time set using osts after the stop mode is released. when the internal high-speed oscillation clock is selected as the cpu clock, confi rm with ostc that the desired oscillation stabilization time has elapsed after the stop m ode is released. the oscillati on stabilization time can be checked up to the time set using ostc. osts can be set by an 8-bit memory manipulation instruction. reset signal generation sets osts to 07h. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 215 jun 20, 2011 figure 5-5. format of oscillation stabiliz ation time select register (osts) address: fffa3h after reset: 07h r/w symbol 7 6 5 4 3 2 1 0 osts 0 0 0 0 0 osts2 osts1 osts0 oscillation stabilization time selection osts2 osts1 osts0 f x = 10 mhz f x = 20 mhz 0 0 0 2 8 /f x 25.6 s setting prohibited 0 0 1 2 9 /f x 51.2 s 25.6 s 0 1 0 2 10 /f x 102.4 s 51.2 s 0 1 1 2 11 /f x 204.8 s 102.4 s 1 0 0 2 13 /f x 819.2 s 409.6 s 1 0 1 2 15 /f x 3.27 ms 1.64 ms 1 1 0 2 17 /f x 13.11 ms 6.55 ms 1 1 1 2 18 /f x 26.21 ms 13.11 ms cautions 1. to set the stop mode when the x1 clock is used as the cp u clock, set the osts register before executing the stop instruction. 2. setting the oscillation stabilization time to 20 s or less is prohibited. 3. to change the setting of the osts regist er, be sure to confirm that the counting operation of the ostc register has been completed. 4. do not change the value of the osts register during the x1 clock oscillation stabilization time. 5. the oscillation stabilization time count er counts up to the oscillation stabilization time set by osts. in the following cases, set the oscillation stabilization time of osts to the value greater than the count value which is to be checked by the ostc register after the oscillation starts. ? if the x1 clock starts oscillation while th e internal high-speed oscillation clock or subsystem clock is being used as the cpu clock. ? if the stop mode is entered and then released while the internal high-speed oscillation clock is being used as the cp u clock with the x1 clock oscillating. (note, therefore, that only the status up to the oscillation stabilization time set by osts is set to ostc after th e stop mode is released.) 6. the x1 clock oscillation stabilization wait 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 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 216 jun 20, 2011 (5) system clock control register (ckc) this register is used to select a cpu/per ipheral hardware clock and a division ratio. ckc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets this register to 09h. figure 5-6. format of system clock control register (ckc) address: fffa4h after reset: 09h r/w note 1 symbol <7> <6> <5> <4> 3 2 1 0 ckc cls css mcs mcm0 sdiv mdiv2 mdiv1 mdiv0 cls status of cpu/peripheral hardware clock (f clk ) 0 main system clock (f main ) 1 subsystem clock (f sub ) mcs status of main system clock (f main ) 0 internal high-speed oscillation clock (f ih ) or 20 mhz internal high-speed oscillation clock (f ih20 ) 1 high-speed system clock (f mx ) css mcm0 sdiv mdiv2 mdiv1 mdiv0 selection of cpu/peripheral hardware clock (f clk ) 0 0 0 f ih 0 0 1 f ih /2 (default) 0 1 0 f ih /2 2 0 1 1 f ih /2 3 1 0 0 f ih /2 4 note 2 0 0 1 0 1 f ih /2 5 note 2 0 0 0 f mx 0 0 1 f mx /2 0 1 0 f mx /2 2 0 1 1 f mx /2 3 1 0 0 f mx /2 4 0 1 1 0 1 f mx /2 5 note 3 0 f sub 1 note 4 note 4 1 f sub /2 other than above setting prohibited notes 1. bits 7 and 5 are read-only. 2. setting is prohibited when f ih = 1 mhz. 3. setting is prohibited when f mx < 4 mhz. 4. changing the value of the mcm0 bit is prohibited while css is set to 1. ( remarks and cautions are listed on the next page.) 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 217 jun 20, 2011 remarks 1. f ih : internal high-speed oscillation clock frequency f ih20 : 20 mhz internal high-speed oscillation clock frequency f mx : high-speed system clock frequency f sub subsystem clock frequency 2. : don?t care cautions 1. the clock set by css, mcm0, sdiv, and mdiv2 to mdiv0 is supplied to the cpu and peripheral hardware. if the cpu clock is changed, therefore, the clock supplied to peripheral hardware (excep t the real-time counter, timer array unit (when f sub /2, f sub /4, the valid edge of ti0mn inpu t, or the valid edge of in trtci is selected as the count clock), clock output/buzzer output, and watc hdog timer) is also changed at the same time. consequently, stop each periphe ral function when changing the cpu/peripheral operati ng hardware clock. 2. if the peripheral hardware clock is used as th e subsystem clock, the operations of the a/d converter and iica are not guaranteed . for the operating characteristics of the peripheral hardware, refer to the ch apters describing the various peripheral hardware as well as chapter 31 electrical specifications. the fastest instruction can be executed in 1 clock of the cpu clock in the 78k0r /lx3 microcontrollers. therefore, the relationship between the cpu clock (f clk ) and the minimum instruction execution time is as shown in table 5-3. table 5-3. relationship between cpu clo ck and minimum instruction execution time minimum instruction execution time: 1/f clk main system clock (css = 0) high-speed system clock (mcm0 = 1) internal high-speed oscillation clock (mcm0 = 0) subsystem clock (css = 1) cpu clock (value set by the sdiv, and mdiv2 to mdiv0 bits) at 10 mhz operation at 20 mhz operation at 8 mhz (typ.) operation at 20 mhz (typ.) operation at 32.768 khz operation f main 0.1 s 0.05 s 0.125 s (typ.) 0.05 s (typ.) ? f main /2 0.2 s 0.1 s 0.25 s (typ.) (default) 0.1 s (typ.) ? f main /2 2 0.4 s 0.2 s 0.5 s (typ.) 0.2 s (typ.) ? f main /2 3 0.8 s 0.4 s 1.0 s (typ.) 0.4 s (typ.) ? f main /2 4 1.6 s 0.8 s 2.0 s (typ.) 0.8 s (typ.) ? f main /2 5 3.2 s 1.6 s 4.0 s (typ.) 1.6 s (typ.) ? f sub ? ? 30.5 s f sub /2 ? ? 61 s remark f main : main system clock frequency (f ih ,f ih20 , or f mx ) f sub : subsystem clock frequency 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 218 jun 20, 2011 (6) 20 mhz internal high-speed osc illation control register (dscctl) this register controls the 20 mhz internal high-speed oscillation clock (dsc) function. it can be used to select whether to use the 20 mhz internal high-speed oscillation clock (f ih20 ) as a peripheral hardware clock that supports 20 mhz. dscctl can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 5-7. format of 20 mhz internal high-sp eed oscillation control register (dscctl) address: f00f6h after reset: 00h r/w note symbol 7 6 5 4 <3> <2> 1 <0> dscctl 0 0 0 0 dscs seldsc 0 dscon dscs 20 mhz internal high-speed oscillation supply status flag 0 not supplied 1 supplied seldsc selection of 20 mhz internal high-speed oscillation for cpu/peripheral hardware clock (f clk ) 0 does not select 20 mhz inter nal high-speed oscillation (clock selected by ckc register is supplied to f clk ) 1 selects 20 mhz internal high-speed oscillati on (20 mhz internal hi gh-speed oscillation is supplied to f clk ) dscon 20 mhz internal hi gh-speed oscillation clock (f ih20 ) operation enable/disable 0 disables operation. 1 enables operation. note bit 3 is read-only. cautions 1. 20 mhz internal osc illation can only be used if v dd 2.7 v. 2. set seldsc when 100 s have elapsed after h aving set dscon with v dd 2.7 v. 3. the internal high-speed oscillator must be operated (hiostop = 0) when dscon = 1. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 219 jun 20, 2011 (7) peripheral enable register 0 (per0) this register is used to enable or dis able use of each peripheral hardware macr o. clock supply to the hardware that is not used is also stopped so as to decrease the power consumption and noise. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears theses registers to 00h. figure 5-8. format of peripheral en able register 0 (per0) (1/2) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note 1 sau1en sau0en tau1en tau0en rtcen control of real-time counter (rtc) input clock note 2 0 stops input clock supply. ? sfr used by the real-time counter (rtc) cannot be written. ? the real-time counter (rtc) is in the reset status. 1 supplies input clock. ? sfr used by the real-time counter (rtc) can be read and written. dacen control of d/a converter input clock 0 stops input clock supply. ? sfr used by the d/a converter cannot be written. ? the d/a converter is in the reset status. 1 supplies input clock. ? sfr used by the d/a converter can be read and written. adcen control of a/d converter, operational amplifier, and voltage reference input clock 0 stops input clock supply. ? sfr used by the a/d converter, operational amplifier, and voltage reference cannot be written. ? the a/d converter, operational amplifier, and voltage reference is in the reset status. 1 supplies input clock. ? sfr used by the a/d converter, operational amplifier, and voltage reference can be read and written. iicaen control of serial interface iica input clock 0 stops input clock supply. ? sfr used by the serial interface iica cannot be written. ? the serial interface iica is in the reset status. 1 supplies input clock. ? sfr used by the serial interface iica can be read and written. notes 1. 78k0r/lg3, 78k0r/lh3 only 2. by using rtcen, can supply and stop the clock that is used when accessing the real-time counter (rtc) from the cpu. rtcen cannot control supply of the operating clock (f sub ) to rtc. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 220 jun 20, 2011 figure 5-8. format of peripheral en able register 0 (per0) (2/2) sau1en control of serial array unit 1 input clock 0 stops input clock supply. ? sfr used by the serial array unit 1 cannot be written. ? the serial array unit is in the reset status. 1 supplies input clock. ? sfr used by the serial array unit 1 can be read and written. sau0en control of serial array unit 0 input clock 0 stops input clock supply. ? sfr used by the serial array unit 0 cannot be written. ? the serial array unit 0 is in the reset status. 1 supplies input clock. ? sfr used by the serial array unit 0 can be read and written. tau1en control of timer array unit 1 input clock 0 stops input clock supply. ? sfr used by timer array unit 1 cannot be written. ? timer array unit 1 is in the reset status. 1 supplies input clock. ? sfr used by timer array unit 1 can be read and written. tau0en control of timer array unit 0 input clock 0 stops input clock supply. ? sfr used by timer array unit 0 cannot be written. ? timer array unit 0 is in the reset status. 1 supplies input clock. ? sfr used by timer array unit 0 can be read and written. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 221 jun 20, 2011 (8) operation speed mode c ontrol register (osmc) this register is used to control the step-up circui t of the flash memory for high-speed operation. if the microcontroller operates at a lo w speed with a system clock of 10 mhz or less, the power c onsumption can be lowered by setting this register to the default value, 00h. osmc can be set by an 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 5-9. format of operation speed mode control register (osmc) address: f00f3h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 osmc rtclpc 0 0 0 0 0 flpc fsel rtclpc setting in subsystem clock halt mode 0 enables subsystem clock s upply to peripheral functions. (see table 21-1 operating statuses in halt mode (2/3) for the peripheral functions whose operations are enabled.) 1 stops subsystem clock supply to peripheral functions exce pt real-time counter, clock output/buzzer output, and lcd controller/driver. flpc fsel f clk frequency selection 0 0 operates at a frequency of 10 mhz or less (default). 0 1 operates at a frequency higher than 10 mhz. 1 0 operates at a frequency of 1 mhz. 1 1 setting prohibited cautions 1. write ?1? to fsel before the following two operations. ? changing the clock prior to dividing f clk to a clock other than f ih . ? operating the dma controller. 2. the cpu waits (140.5 clock (f clk )) when ?1? is written to the fsel bit. interrupt requests issued during a wait will be suspended. however, counting the oscillati on stabilization time of f x can continue even while the cpu is waiting. 3. to increase f clk to 10 mhz or higher, set f sel to ?1?, then change f clk after two or more clocks have elapsed. 4. confirm that the clock is operating at 10 mhz or less before setting fsel = 0. 5. to shift to stop mode while v dd 2.7 v, set fsel = 0 after setting f clk to 10 mhz or less. 6. the halt mode current when operating on the subsystem clock can be reduced by setting rtclpc to 1. howeve r, the clock cannot be suppl ied to peripheral functions except the real-time counter in the subsyst em clock halt mode. set bit 7 (rtcen) of per0 to 1 and bits 0 to 6 of per0 to 0 before setting the subsystem clock halt mode. 7. once flpc has been set from 0 to 1, setting it back to 0 fr om 1 other than by reset is prohibited. 8. when setting fsel to ?1?, do so while rmc = 00h. when setting flpc to ?1?, do so while rmc = 5ah. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 222 jun 20, 2011 5.4 system clock oscillator 5.4.1 x1 oscillator the x1 oscillator oscillates with a cryst al resonator or ceramic resonator (2 to 20 mhz) connected to the x1 and x2 pins. an external clock can also be input. in this case, input the clock signal to the exclk pin. to use the x1 oscillator, set bits 7 and 6 (exclk, oscsel ) of the clock operation mode control register (cmc) as follows. ? crystal or ceramic oscillation: exclk, oscsel = 0, 1 ? external clock input: exclk, oscsel = 1, 1 when the x1 oscillator is not used, set the input port mode (exclk, oscsel = 0, 0). when the pins are not used as input port pins, either, see table 2-2 to 2-4 connection of unused pins . figure 5-10 shows an example of the exte rnal circuit of the x1 oscillator. figure 5-10. example of extern al circuit of x1 oscillator (a) crystal or ceramic osc illation (b) external clock v ss x1 x2 crystal resonator or ceramic resonator exclk external clock 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. to use the xt1 oscillator, set bit 4 (oscsels) of t he clock operation mode control register (cmc) to 1. when the xt1 oscillator is not used, set the input port mode (oscsels = 0). when the pins are not used as input port pins, either, see table 2-2 to 2-4 connection of unused pins . figure 5-11 shows an example of the exte rnal circuit of the xt1 oscillator. figure 5-11. example of external circuit of xt1 oscillator (crystal oscillation) xt2 v ss xt1 32.768 khz cautions are listed on the next page. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 223 jun 20, 2011 caution 1. when using the x1 oscillator and xt1 osc illator, wire as follows in the area enclosed by the broken lines in the figures 5-10 and 5-11 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 lin es. do not route the wiring near a signal line through which a high fluctuating current flows. ? always make the ground point of the o scillator capacitor the 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. note that the xt1 oscillator is designed as a low-gain circuit fo r achieving low-power consumption. note the following points when designing the xt1 oscillator. ? the pins and circuit board include parasitic cap acitance. therefore, c onfirm that there are no problems by performing oscillation evaluation on the circuit board to be actually used. ? when low-consumption oscilla tion or super-low-consumption oscillation is selected, lower power consumption than when selecting normal o scillation can be achieved. however, in this case, the xt1 oscillation margin is reduced, so perform suffici ent oscillation evaluation of the resonator to be used for xt1 oscilla tion before using the resonator. ? keep the wiring length between the xt1 and xt 2 pins and resonator as short as possible and parasitic capacitance and wire resi stance as small as possible. th is is particularly important when super-low-consum ption oscillation (amphs1 = 1) is selected. ? configure the circuit board by using mate rial with little parasitic capacitance and wire resistance. ? place a ground pattern that h as the same potential as v ss (if possible) around the xt1 oscillator. ? do not cross the signal lines between the xt1 and xt2 pins an d the resonator with other signal lines. do not route the signal lines near a si gnal line through which a high fluctuating current flows. ? moisture absorption by the circuit board and condensation on the board in a highly humid environment may cause the impe dance between the xt1 and xt2 pins to drop and disable oscillation. when using the ci rcuit board in such an envir onment, prevent the circuit board from absorbing moisture by taking measu res such as coating the circuit board. ? coat the surface of the circuit board by using material that does not generate capacitance or leakage between the xt1 and xt2 pins. figure 5-12 shows examples of incorrect resonator connection. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 224 jun 20, 2011 figure 5-12. examples of incorr ect resonator connection (1/2) (a) too long wiring (b) crossed signal line x2 v ss x1 x1 ng ng ng v ss x2 port (c) signal lines of x1 and x2 cross (d) power supply/gnd pattern ex ists underneath x1 and x2 wiring x2 v ss x1 x1 power supply/gnd pattern v ss x2 note note do not place a power supply/gnd pattern underneath the wir ing section (in broken lines above) of the x1 and x2 pins and resonator in the multilayer board and double-sided board. do not configure a layout that ma y cause capacitance elements and affe ct the oscillation characteristics. remark when using the subsystem clock, replace x1 and x2 wi th xt1 and xt2, respectively. also, insert resistors in series on the xt2 side. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 225 jun 20, 2011 figure 5-12. examples of incorr ect resonator connection (2/2) (e) wiring near high alternating current (f) 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 (g) signals are fetched v ss x1 x2 remark when using the subsystem clock, replace x1 and x2 wi th xt1 and xt2, respectively. also, insert resistors in series on the xt2 side. caution 2. when x2 and xt1 are wired in parallel, the crosstalk noise of x2 may in crease with xt1, resulting in malfunctioning. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 226 jun 20, 2011 5.4.3 internal hi gh-speed oscillator the internal high-speed oscillator is incorporated in the 78k0r/lx3 (1, 8 and 20 mhz (typ.)). oscillation can be controlled by bit 0 (hiostop) of the clock operation status control register (csc) and bit 0 (dscon) of the 20 mhz internal high-speed oscillation control register (dscctl). caution to use the 1, 8, or 20 mhz inte rnal high-speed oscillati on clock, use the option byte to set the frequency in advance (for details, see chapter 26 option byte). also, the internal high-speed oscillator automatically starts oscillating a fter reset release. (if 8 mhz or 20 mh z is selected by using the option byte, the microcontroller operates using the 8 mhz in ternal high-speed oscilla tor.) to use the 20 mhz internal high-speed oscillator to operate the microcontroller, oscilla tion is started by setting bit 0 (dscon) of the dscctl register to 1 with v dd 2.7 v. 5.4.4 internal low-speed oscillator the internal low-speed oscillator is incorpor ated in the 78k0r/lx3 microcontrollers. the internal low-speed oscillation clock is used only as the watchdog timer clock. the internal low-speed oscillation clock cannot be used as the cpu clock. after a reset release, the internal low-speed oscillator autom atically starts oscillation, an d the watchdog timer is driven (30 khz (typ.)) if the watchdog timer oper ation is enabled by the option byte. the internal low-speed oscillator c ontinues oscillation except when the wa tchdog timer stops. when the watchdog timer operates, the internal low-speed oscillation clo ck does not stop, even in case of a program loop. 5.4.5 prescaler the prescaler generates a cp u/peripheral hardware cl ock by dividing the main system clock and subsystem clock. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 227 jun 20, 2011 5.5 clock generator operation the clock generator generates the follo wing clocks and controls the operation modes of the cpu, such as standby mode (see figure 5-1 ). ? main system clock f main ? high-speed system clock f mx x1 clock f x external main system clock f ex ? internal high-speed oscillation clock f ih 1 mhz internal high-speed oscillation clock f ih1 8 mhz internal high-speed oscillation clock f ih8 ? 20 mhz internal high-speed oscillation clock f ih20 ? subsystem clock f sub ? subsystem selection clock f subc ? internal low-speed oscillation clock f il ? cpu/peripheral hardware clock f clk the cpu starts operation when the internal high-speed o scillator starts outputting after a reset release in the 78k0r/lx3 microcontrollers, 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 t herefore does not operate after reset is rel eased. however, the start clock of the cpu is the internal high-speed oscillat ion clock, so the device c an be started by the inter nal high-speed oscillation clock after a reset release. as a re sult, reset sources can be detected by so ftware and the minimum amount of safety processing can be done during anomalies to ens ure that the system terminates safely. (2) improvement of performance because the cpu can be start ed without waiting for the x1 clock oscillat ion stabilization time, the total performance can be improved. when the power supply voltage is turned on, the clock gen erator operation is shown in figure 5-13 and figure 5-14. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 228 jun 20, 2011 figure 5-13. clock generator operation wh en power supply voltage is turned on (when lvi default start function stoppe d is set (option byte: lvioff = 1)) seldsc = 1 0 v 1.61 v (typ.) 1.8 v 0.5 v/ms (min.) note 1 power supply voltage (v dd ) internal reset signal cpu clock internal high-speed oscillation clock (f ih ) high-speed system clock (f mx ) (when x1 oscillation selected) 20 mhz internal high-speed oscillation clock (f ih20 ) subsystem clock (f sub ) (when xt1 oscillation selected) reset processing (2.12 to 5.84 ms) switched by software subsystem clock high-speed system clock 1 or 8 mhz internal high- speed oscillation clock 20 mhz internal high- speed oscillation clock 1 or 8 mhz internal high- speed oscillation clock x1 clock oscillation stabilization time note 2 starting x1 oscillation is specified by software. starting xt1 oscillation is specified by software. 20 mhz internal high-speed oscillation clock oscillation stabilization time : 100 s dscon = 1 is set by software. <4> <4> <4> <5> <5> <5> <1> <2> <3> <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 exc eeds 1.61 v (typ.), the reset is rel eased and the internal high-speed oscillator automatically starts oscillation. <3> the cpu starts operation on the internal high-speed oscillation clock note 3 after a reset processing such as waiting for the voltage of the power supply or regulator to stabilize has been performed after reset release. <4> set the start of oscillation of the x1 or xt1 clock via software (see (1) in 5.6.1 example of controlling high- speed system clock and (1) in 5.6.3 example of cont rolling subsystem clock) . <5> when switching the cpu clock to the x1 or xt1 clock, wait for the clock oscillatio n to stabilize, and then set switching via software (see (3) in 5.6.1 example of controlli ng high-speed system clock and (2) in 5.6.3 example of controlling subsystem clock ). switch to the 20 mhz internal high-speed oscillation clock by setting the dscon bit (bit 0 of the 20 mhz internal high-speed oscillation control regist er (dscctl)), waiting for 100 s, and then setting the seldsc bit to 1 by using software note 4 . ( notes and cautions are listed on the next page.) 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 229 jun 20, 2011 notes 1. the internal reset processing time includes the oscill ation accuracy stabilization time of the internal high- speed oscillation clock. 2. when releasing a reset, confirm the oscillation stabiliz ation time for the x1 clock using the oscillation stabilization time counter st atus register (ostc). 3. the microcontroller operates on the 8 mhz internal high-speed oscillation clock if 8 mhz or 20 mhz is selected for the internal high-speed oscillator by usi ng the option byte or on the 1 mhz internal high-speed oscillation clock if 1 mhz is selected. 4. if the internal high-speed oscillator is set to 1 mhz by using the option byte, the 20 mhz internal high-speed oscillation clock cannot be used. cautions 1. if the voltage rises with a slope of l ess than 0.5 v/ms (min.) from power application until the voltage reaches 1.8 v, input a lo w level to the reset pin from pow er application until the voltage reaches 1.8 v, or set the lvi default start functi on stopped by using the option byte (lvioff = 0) (see figure 5-14). by doing so, the cpu operat es with the same timing as <2> and thereafter in figure 5-13 after reset rel ease by the reset pin. 2. it is not necessary to wait for the oscillation stabilization time when an external clock input from the exclk pin is used. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 230 jun 20, 2011 figure 5-14. clock generator operation wh en power supply voltage is turned on (when lvi default start function enable d is set (option byte: lvioff = 0)) seldsc = 1 0 v 2.07 v note 1 power supply voltage (v dd ) internal reset signal cpu clock internal high-speed oscillation clock (f ih ) high-speed system clock (f mx ) (when x1 oscillation selected) 20 mhz internal high-speed oscillation clock (f ih20 ) subsystem clock (f sub ) (when xt1 oscillation selected) reset processing (195 to 341 s) switched by software subsystem clock high-speed system clock 1 or 8 mhz internal high- speed oscillation clock 20 mhz internal high- speed oscillation clock 1 or 8 mhz internal high- speed oscillation clock x1 clock oscillation stabilization time note 2 starting x1 oscillation is specified by software. starting xt1 oscillation is specified by software. 20 mhz internal high-speed oscillation clock oscillation stabilization time : 100 s dscon = 1 is set by software. <4> <4> <4> <5> <5> <5> <1> <2> <3> <1> when the power is turned on, an internal reset signal is generated by the low-voltage detector (lvi) circuit. <2> when the power supply voltage exc eeds 2.07 v (typ.), the reset is rel eased and the internal high-speed oscillator note 3 automatically starts oscillation. <3> after the reset is released and reset processing is perfo rmed, the cpu starts operation on the internal high-speed oscillation clock note 3 . <4> set the start of oscillation of the x1 or xt1 clock via software (see (1) in 5.6.1 example of controlling high- speed system clock and (1) in 5.6.3 example of controlling subsystem clock ). switch to oscillation using the 20 mhz internal high-spee d oscillation clock after setting the dscon bit to 1 by using software. <5> when switching the cpu clock to the x1 or xt1 clock, wait for the clock oscillatio n to stabilize, and then set switching via software (see (3) in 5.6.1 example of controllin g high-speed system clock and (2) in 5.6.3 example of controlling subsystem clock ). switch to the 20 mhz internal high-speed oscillation cloc k after confirming that the power supply voltage is at least 2.7 v, setting the dscon bit (bit 0 of the 20 mhz inte rnal high-speed oscillation control register (dscctl)), waiting for 100 s, and then setting the seldsc bit to 1 by using software note 4 . ( notes and cautions are listed on the next page.) 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 231 jun 20, 2011 notes 1. the internal reset processing time includes the oscill ation accuracy stabilization time of the internal high- speed oscillation clock. 2. when releasing a reset, confirm the oscillation stabiliz ation time for the x1 clock using the oscillation stabilization time counter st atus register (ostc). 3. the microcontroller operates on the 8 mhz internal high-speed oscillation clock if 8 mhz or 20 mhz is selected for the internal high-speed oscillator by usi ng the option byte or on the 1 mhz internal high-speed oscillation clock if 1 mhz is selected. 4. if the internal high-speed oscillator is set to 1 mhz by using the option byte, the 20 mhz internal high-speed oscillation clock cannot be used. cautions 1. a voltage stabilization time (about 2.12 to 5.84 ms) is required afte r the supply voltage reaches 1.61 v (typ.). if the time for the supply voltage to rise from 1. 61 v (typ.) to 2.07 v (typ.) is shorter than the voltage stab ilization time, reset processing is entered after the voltage stabilization time elapses. 2. it is not necessary to wait fo r the oscillation stabilization time when an external clock input from the exclk pin is used. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 232 jun 20, 2011 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 to 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/p121 and x2/exclk/p122 pi ns can be used as input port pins. caution the x1/p121 and x2/exclk/p122 pins are in the input 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 clo ck as cpu/peripheral hardware clock (4) when stopping high-speed system clock (1) example of setting procedure when oscillating the x1 clock <1> setting p121/x1 and p122/x2/exclk pins and setting oscillation frequency (cmc register) ? 2 mhz f x 10 mhz exclk oscsel 0 oscsels 0 amphs1 amphs0 amph 0 1 0 0/1 0 0/1 0/1 0 ? 10 mhz < f x 20 mhz exclk oscsel 0 oscsels 0 amphs1 amphs0 amph 0 1 0 0/1 0 0/1 0/1 1 remarks 1. f x : x1 clock oscillation frequency 2. for setting of the p123/xt1 and p124/xt2 pins, see 5.6.3 example of controlling subsystem clock . <2> controlling oscillation of x1 clock (csc register) if mstop is cleared to 0, the x1 oscillator starts oscillating. <3> 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 internal high-speed oscillation clock. cautions 1. the cmc register can be written on ly once after reset release, by an 8-bit memory manipulation instruction. therefore, it is necessary to also set the val ue of the oscsels bit at the same time. for oscsels bit, see 5.6.3 example of controlling subsystem clock. 2. set the x1 clock after the supply voltage has reached the opera ble voltage of the clock to be used (see chapter 31 el ectrical specifications). 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 233 jun 20, 2011 (2) example of setting procedure when using the external main system clock <1> setting p121/x1 and p122/x2/exclk pins (cmc register) exclk oscsel 0 oscsels 0 amphs1 amphs0 amph 1 1 0 0/1 0 0/1 0/1 0/1 remark for setting of the p123/xt 1 and p124/xt2 pins, see 5.6.3 (1) example of setting procedure when oscillating the subsystem clock . <2> controlling external main syst em clock input (csc register) when mstop is cleared to 0, the input of the external main system clock is enabled. cautions 1. the cmc register can be written on ly once after reset release, by an 8-bit memory manipulation instruction. therefore, it is necessary to also set the value of the oscsels bits at the same time. for oscsels bits, see 5.6.3 example of controlling subsystem clock. 2. set the external main system clock after th e supply voltage has reac hed the operable voltage of the clock to be used (see chapte r 31 electrical specifications). (3) example of setting procedure wh en using high-speed system clock as cpu/peripheral hardware clock <1> setting high-speed system clock oscillation note (see 5.6.1 (1) example of setting proce dure when oscillating the x1 clock and (2) example of setting procedure when using the ext ernal main system clock. ) note the setting of <1> is not necessary when hi gh-speed system clock is already operating. <2> setting the high-speed system clock as the source clock of the cpu/peripheral hardware clock and setting the division ratio of the set clock (ckc register) mcm0 mdiv2 mdiv1 mdiv0 selection of cpu/peripheral hardware clock (f clk ) 0 0 0 f mx 0 0 1 f mx /2 0 1 0 f mx /2 2 0 1 1 f mx /2 3 1 0 0 f mx /2 4 1 1 0 1 f mx /2 5 note note setting is prohibited when f mx < 4 mhz. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 234 jun 20, 2011 <3> if some peripheral hardware macros are not used, s upply of the input clock to each hardware macro can be stopped. (per0 register) rtcen dacen adcen iicaen sau1en sau0en tau1en tau0en xxxen input clock control 0 stops input clock supply. 1 supplies input clock. remark rtcen: control of the r eal-time counter input clock dacen: control of the d/a converter input clock adcen: control of the a/d converte r and operational amplifier input clock iicaen: control of the serial interface iica input clock sau1en: control of the serial array unit 1 unit input clock sau0en: control of the serial array unit 0 unit input clock tau1en: control of the ti mer array unit 1 input clock tau0en: control of the ti mer array unit 0 input clock (4) example of setting procedure when stopping the high-speed system clock the high-speed system clock can be stopped (disabling clock i nput if the external clock is used) in the following two ways. ? executing the stop instruction ? setting mstop to 1 (a) to execute a stop instruction <1> setting to stop peripheral hardware stop peripheral hardware that cannot be used in the stop mode (for peripheral hardware that cannot be used in stop mode, see chapter 21 standby function ). <2> setting the x1 clock oscillation stabilization time after stop mode is released if the x1 clock oscillates before the stop mode is en tered, set the value of the osts register before executing the stop instruction. <3> executing the stop instruction when the stop instruction is exec uted, the system is placed in t he stop mode and x1 oscillation is stopped (the input of the exte rnal clock is disabled). 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 235 jun 20, 2011 (b) to stop x1 oscillation (disabling exter nal clock input) by setting mstop to 1 <1> confirming the cpu clock status (ckc register) confirm with cls and mcs that the cpu is operating on a clock other than the high-speed system clock. when cls = 0 and mcs = 1, the high-speed system clo ck is supplied to the cpu, so change the cpu clock to the subsystem clock or inte rnal high-speed o scillation clock. cls mcs cpu clock status 0 0 internal high-speed oscillation cl ock or 20 mhz internal high-speed oscillation clock 0 1 high-speed system clock 1 subsystem clock <2> setting of x1 clock oscillation stabilizatio n time after restart of x1 clock oscillation note prior to setting "1" to mstop, set the osts regist er to a value greater than the count value to be confirmed with the osts register afte r x1 clock oscillation is restarted. <3> stopping the high-speed system clock (csc register) when mstop is set to 1, x1 oscillation is stopp ed (the input of the external clock is disabled). note this setting is required to resume the x1 clock osc illation when the high-speed system clock is in the x1 oscillation mode. this setting is not required in the external clock input mode. 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 controlling inte rnal high-speed oscillation clock the following describes examples of clock setting procedures for the following cases. (1) when restarting oscillation of the internal high-speed oscillation clock (2) when using internal high-speed oscillation clock as cpu/peripheral hardware clock (3) when stopping the internal high-speed oscillation clock (1) example of setting procedure wh en restarting oscillation of the in ternal high-speed oscillation clock note <1> setting restart of oscillation of the intern al high-speed oscillation clock (csc register) when hiostop is cleared to 0, the internal hi gh-speed oscillation clock restarts oscillation. note after a reset release, the internal high-speed oscillat or automatically starts oscillating and the internal high- speed oscillation clock is selected as the cpu/peripheral hardware clock. (2) example of setting procedure when using intern al high-speed oscillation clock as cpu/peripheral hardware clock <1> restarting oscillation of the internal high-speed oscillation clock note (see 5.6.2 (1) example of setting pr ocedure when restarting internal high-speed oscillation clock ). note the setting of <1> is not necessary when the intern al high-speed oscillation clock is operating. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 236 jun 20, 2011 <2> setting the internal high-speed oscillation clock as the source clock of the cp u/peripheral hardware clock and setting the division ratio of the set clock (ckc register) mcm0 mdiv2 mdiv1 mdiv0 selection of cpu/peripheral hardware clock (f clk ) 0 0 0 f ih 0 0 1 f ih /2 0 1 0 f ih /2 2 0 1 1 f ih /2 3 1 0 0 f ih /2 4 note 0 1 0 1 f ih /2 5 note note setting is prohibited when f ih = 1 mhz. caution if switching the cpu/peri pheral hardware clock from th e high-speed system clock to the internal high-speed oscillation clock after restarting the in ternal high-speed oscillation clock, do so after 10 s or more have elapsed. if the switching is made immediately after the internal high-speed oscillation clock is restarted, the accuracy of the internal high-speed oscillat ion cannot be guaranteed for 10 s. (3) example of setting procedure when stop ping the internal high-speed oscillation clock the internal high-speed oscillation clock can be stopped in the following two ways. ? executing the stop instruction ? setting hiostop to 1 (a) to execute a stop instruction <1> setting of peripheral hardware stop peripheral hardware that cannot be used in the stop mode (for peripheral hardware that cannot be used in stop mode, see chapter 21 standby function ). <2> setting the x1 clock oscillation stabilization time after stop mode is released if the x1 clock oscillates before the stop mode is en tered, set the value of the osts register before executing the stop instruction. <3> executing the stop instruction when the stop instruction is exec uted, the system is placed in the stop mode and internal high-speed oscillation clock is stopped. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 237 jun 20, 2011 (b) to stop internal high-speed osc illation clock by setting hiostop to 1 <1> confirming the cpu clock status (ckc register) confirm with cls and mcs that the cpu is operatin g on a clock other than the internal high-speed oscillation clock. when cls = 0 and mcs = 0, the internal high-speed osci llation clock is supplied to the cpu, so change the cpu clock to the high-speed syst em clock or subsystem clock. cls mcs cpu clock status 0 0 internal high-speed oscillation clo ck or 20 mhz internal high-speed oscillation clock 0 1 high-speed system clock 1 subsystem clock <2> stopping the internal high-speed oscillation clock (csc register) when hiostop is set to 1, internal high-speed oscillation clock is stopped. caution be sure to confirm that mcs = 1 or cls = 1 when setting hiostop to 1. in addition, stop peripheral hardware that is operating on the internal high-speed oscillation clock. 5.6.3 example of cont rolling subsystem clock the subsystem clock can be oscillated by connecti ng a crystal resonator to the xt1 and xt2 pins. when the subsystem clock is not us ed, the xt1/p123 and xt2/p124 pins can be used as input port pins. caution the xt1/p123 and xt2/p124 pins are in the input port mode after a reset release. the following describes examples of setti ng procedures for the following cases. (1) when oscillating subsystem clock (2) when using subsystem clock as cpu clock (3) when stopping subsystem clock caution when the subsystem clock is used as the cpu cl ock, the subsystem clock is also supplied to the peripheral hardware (except the real-ti me counter, timer array unit (when f sub /2, f sub /4, the valid edge of ti0mn input, or the valid e dge of intrtci is selected as the count clock), clock output/buzzer output, and watchdog timer). at this time, the operations of the a/d converter and iica are not guaranteed. for the operating ch aracteristics of the peripheral ha rdware, refer to the chapters describing the various periphera l hardware as well as chapter 31 electrical specifications. (1) example of setting procedure wh en oscillating the subsystem clock <1> setting p123/xt1 and p124/xt2 pins (cmc register) exclk oscsel 0 oscsels 0 amphs1 amphs0 amph 0/1 0/1 0 1 0 0/1 0/1 0/1 remark for setting of the p121/x1 and p122/x2 pins, see 5.6.1 example of controlling high-speed system clock . <2> controlling oscillation of subsystem clock (csc register) if xtstop is cleared to 0, the xt1 oscillator starts oscillating. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 238 jun 20, 2011 <3> 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 the cmc register can be wr itten only once after reset release, by an 8-bit memory manipulation instruction. therefore, it is necessary to al so set the value of the exclk and oscsel bits at the same time. for exclk and oscsel bits, see 5.6.1 (1) exampl e of setting procedure when oscillating the x1 clock or 5.6.1 (2) example of setting procedur e when using the externa l main system clock. (2) example of setting procedure when us ing the subsystem cl ock as the cpu clock <1> setting subsystem clock oscillation note (see 5.6.3 (1) example of setting procedur e when oscillating the subsystem clock .) note the setting of <1> is not necessary when while the subsystem clock is operating. <2> setting the subsystem clock as the source clo ck of the cpu/peripheral hardware clock and setting the division ratio of the set clock (ckc register) css sdiv selection of cpu/peripheral hardware clock (f clk ) 0 f sub 1 1 f sub /2 caution when the subsystem clock is used as the cpu cl ock, the subsystem clock is also supplied to the peripheral hardware (except the real-ti me counter, timer array unit (when f sub /2, f sub /4, the valid edge of ti0mn input, or the valid edge of intrtci is selected as th e count clock), clock output/buzzer output, and watchdog timer). at this time, the operations of the a/d converter and iica are not guaranteed. for the operating character istics of the peripheral hardware, refer to the chapters describing the various peripheral hardware as well as chapter 31 electrical specifications. (3) example of setting procedure wh en stopping the subsystem clock <1> confirming the cpu clock status (ckc register) 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 t he cpu, so change the cpu clock to the internal high- speed oscillation clock or high-speed system clock. cls mcs cpu clock status 0 0 internal high-speed oscillation cl ock or 20 mhz internal high-speed oscillation clock 0 1 high-speed system clock 1 subsystem clock <2> stopping the subsystem clock (csc register) when xtstop is set to 1, subsystem clock is stopped. cautions 1. be sure to confirm th at cls = 0 when setting xtstop to 1. in addition, stop the peripheral hardware if it is operati ng on the subsystem clock. 2. the subsystem clock oscillation cannot be stopped using the stop instruction. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 239 jun 20, 2011 5.6.4 example of controlling in ternal low-speed oscillation clock the internal low-speed oscillation clock cannot be used as the cpu clock. used only as the watchdog timer clock. the internal low-speed oscillat or automatically starts oscillation after a re set release, and the watchdog timer is driven (30 khz (typ.)) if the watchdog timer oper ation is enabled by the option byte. the internal low-speed oscillator c ontinues oscillation except when the wa tchdog timer stops. when the watchdog timer operates, the internal low-speed oscillation clo ck does not stop even in case of a program loop. (1) example of setting procedure when stoppi ng the internal low-speed oscillation clock the internal low-speed oscillation clock can be stopped in the following two ways. ? stop the watchdog timer in the halt/stop mode by the option byte (bit 0 (wdstbyon) of 000c0h = 0), and execute the halt or stop instruction. ? stop the watchdog timer by the option byte (bit 4 (wdton) of 000c0h = 0). (2) example of setting procedure when restarting o scillation of the internal low-speed oscillation clock the internal low-speed oscillation clock can be restarted as follows. ? release the halt or stop mode (only when the watchdog timer is stopped in the halt/sto p mode by the option byte (bit 0 (wdstbyon) of 000c0h) = 0) and when the watchdog timer is stopped as a result of execution of the halt or stop instruction). 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 240 jun 20, 2011 5.6.5 cpu clock stat us transition diagram figure 5-15 shows the cpu clock status transition diagram of this product. figure 5-15. cpu clock stat us transition diagram internal high-speed oscillation: woken up x1 oscillation/exclk input: stops (input port mode) xt1 oscillation: stops (input port mode) dsc oscillation: stops internal high-speed oscillation: operating x1 oscillation/exclk input: stops (input port mode) xt1 oscillation: stops (input port mode) dsc oscillation: stops v dd 1.61 v 0.09 v dd 1.8 v v dd < 1.61 v 0.09 cpu: internal high- speed oscillation stop cpu: internal high- speed oscillation halt cpu: x1 oscillation/exclk input stop internal high-speed oscillation: stops x1 oscillation/exclk input: stops xt1 oscillation: oscillatable dsc oscillation: stops internal high-speed oscillation: operating x1 oscillation/exclk input: oscillatable xt1 oscillation: oscillatable dsc oscillation: stops internal high-speed oscillation: stops x1 oscillation/exclk input: stops xt1 oscillation: oscillatable dsc oscillation: stops internal high-speed oscillation: oscillatable x1 oscillation/exclk input: operating xt1 oscillation: oscillatable dsc oscillation: stops cpu: operating with internal high- speed oscillation cpu: operating with x1 oscillation or exclk input cpu: x1 oscillation/exclk input halt power on reset release internal high-speed oscillation: selectable by cpu x1 oscillation/exclk input: operating xt1 oscillation: selectable by cpu dsc oscillation: stops internal high-speed oscillation: operating x1 oscillation/exclk input: selectable by cpu xt1 oscillation: selectable by cpu dsc oscillation: selectable by cpu cpu: operating with dsc oscillation cpu: dsc oscillation halt internal high-speed oscillation: selectable by cpu x1 oscillation/exclk input: cannot be selected by cpu xt1 oscillation: cannot be selected by cpu dsc oscillation: operating internal high-speed oscillation: oscillatable x1 oscillation/exclk input: oscillatable xt1 oscillation: oscillatable dsc oscillation: operating (g) (k) (d) (j) (c) (f) (i) (e) (h) (b) (a) cpu: operating with xt1 oscillation cpu: xt1 oscillation halt internal high-speed oscillation: selectable by cpu x1 oscillation/exclk input: selectable by cpu xt1 oscillation: operating dsc oscillation: stops internal high-speed oscillation: oscillatable x1 oscillation/exclk input: oscillatable xt1 oscillation: operating dsc oscillation: stops note 1 notes 2, 3 notes 1. after reset release, an operation at one of the fo llowing operating frequencies is started, because f clk = f ih /2 has been selected by setting the system cl ock control register (ckc) to 09h. ? when 1 mhz has been selected by using the option byte: 500 khz (1 mhz/2) ? when 8 mhz or 20 mhz has been selected by using the option byte: 4 mhz (8 mhz/2) 2. specify 20 mhz internal oscillation after checking that v dd is at least 2.7 v. 3. 20 mhz internal oscillation cannot be used if 1 mhz internal oscillation is selected by using the option byte. remarks 1. if the low-power-supply detector (lvi) is set to on by default by the option bytes, the reset will not be released until the power supply voltage (v dd ) exceeds 2.07 v 0.2 v. after the reset operation, the status will shift to (b) in the above figure. 2. dsc: 20 mhz internal high-speed oscillation clock 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 241 jun 20, 2011 table 5-4 shows transition of the cpu clock and examples of setting the sfr registers. table 5-4. cpu clock transition a nd sfr register setting examples (1/6) (1) cpu operating with internal high-speed oscillation clock (b) a fter 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 internal high-speed oscill ation clock immediately after a reset release (b).) (setting sequence of sfr registers) cmc register note 1 csc register osmc register ckc register setting flag of sfr register status transition exclk oscsel amph mstop fsel ostc register mcm0 (a) (b) (c) (x1 clock: 2 mhz f x 10 mhz) 0 1 0 0 0 must be checked 1 (a) (b) (c) (x1 clock: 10 mhz < f x 20 mhz) 0 1 1 0 1 note 2 must be checked 1 (a) (b) (c) (external main clock) 1 1 0 0/1 note 2 must not be checked 1 notes 1. the clock operation mode control register (c mc) can be written only once by an 8-bit memory manipulation instruction after reset release. 2. fsel = 1 when f clk > 10 mhz if a divided clock is selected and f clk 10 mhz, use with fsel = 0 is possible even if f x > 10 mhz. caution set the clock after the suppl y voltage has reached the operable volt age of the clock to be set (see chapter 31 electrical specifications). (3) cpu operating with subsystem cl ock (d) after reset release (a) (the cpu operates with the internal high-speed oscill ation clock immediately after a reset release (b).) (setting sequence of sfr registers) cmc register note csc register ckc register setting flag of sfr register status transition oscsels amphs1 amphs0 xtstop waiting for oscillation stabilization css (a) (b) (d) 1 0/1 0/1 0 necessary 1 note the cmc register can be written only once by an 8-bit memory manipulation instru ction after reset release. remark (a) to (k) in table 5-4 correspond to (a) to (k) in figure 5-15. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 242 jun 20, 2011 table 5-4. cpu clock transition a nd sfr register setting examples (2/6) (4) cpu operating with 20 mhz internal high-speed oscillation clock (j) after reset release (a) (the cpu operates with the internal high-speed oscill ation clock immediately after a reset release (b).) (setting sequence of sfr registers) dscctl register note dscctl register setting flag of sfr register status transition dscon waiting for oscillation stabilization seldsc (a) (b) (j) 1 necessary (100 s) 1 note check that v dd 2.7 v and set dscon = 1. (5) cpu clock changing from inte rnal high-speed oscillation clock (b) to high-speed system clock (c) (setting sequence of sfr registers) cmc register note 1 csc register osmc register ckc regi ster setting flag of sfr register status transition exclk oscsel amph osts register mstop fsel ostc register mcm0 (b) (c) (x1 clock: 2 mhz fx 10 mhz) 0 1 0 note 2 0 0 must be checked 1 (b) (c) (x1 clock: 10 mhz < fx 20 mhz) 0 1 1 note 2 0 1 note 3 must be checked 1 (b) (c) (external main clock) 1 1 note 2 0 0/1 must not be checked 1 unnecessary if these registers are already set unnecessary if the cpu is operating with the high-speed system clock notes 1. the cmc register can be changed only once after reset release. this setting is not necessary if it has already been set. 2. set the oscillation stabilization time as follows. ? desired ostc oscillation stabilization time oscillation stabilization time set by osts 3. fsel = 1 when f clk > 10 mhz if a divided clock is selected and f clk 10 mhz, use with fsel = 0 is possible even if f x > 10 mhz. caution set the clock after the suppl y voltage has reached the operable volt age of the clock to be set (see chapter 31 electrical specifications). remarks 1. : don?t care 2. (a) to (k) in table 5-4 correspond to (a) to (k) in figure 5-15. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 243 jun 20, 2011 table 5-4. cpu clock transition a nd sfr register setting examples (3/6) (6) cpu clock changing from in ternal high-speed oscillation cl ock (b) to subsystem clock (d) (setting sequence of sfr registers) cmc register note csc register ckc register setting flag of sfr register status transition oscsels xtstop waiting for oscillation stabilization css (b) (d) 1 0 necessary 1 unnecessary if the cpu is operating with the subsystem clock note the cmc register can be written only once by an 8-bit memory manipulation instru ction after reset release. (7) cpu clock changing from internal high-speed oscillation clock (b) to 20 mhz internal high-speed oscillation clock (j) (setting sequence of sfr registers) dscctl register note dscctl register setting flag of sfr register status transition dscon waiting for oscillation stabilization seldsc (b) (j) 1 necessary (100 s) 1 unnecessary if the cpu is operating with the 20 mhz internal high-speed oscillation clock note check that v dd 2.7 v and set dscon = 1. (8) cpu clock changing from high- speed system clock (c) to internal high-speed oscillation clock (b) (setting sequence of sfr registers) csc register ckc register setting flag of sfr register status transition hiostop oscillation accuracy stabilization time mcm0 (c) (b) 0 10 s 0 unnecessary if the cpu is operating with the internal high- speed oscillation clock remark (a) to (k) in table 5-4 correspond to (a) to (k) in figure 5-15. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 244 jun 20, 2011 table 5-4. cpu clock transition a nd sfr register setting examples (4/6) (9) cpu clock changing from high-speed system clock (c) to subsystem clock (d) (setting sequence of sfr registers) csc register ckc register setting flag of sfr register status transition xtstop waiting for oscillation stabilization css (c) (d) 0 necessary 1 unnecessary if the cpu is operating with the subsystem clock (10) cpu clock changing from subsystem clock (d) to internal high-speed oscillation clock (b) (setting sequence of sfr registers) csc register ckc register setting flag of sfr register status transition hiostop mcm0 css (d) (b) 0 0 0 unnecessary if the cpu is operating with the internal high-speed oscillation clock unnecessary if this register is already set remark (a) to (k) in table 5-4 correspond to (a) to (k) in figure 5-15. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 245 jun 20, 2011 table 5-4. cpu clock transition a nd sfr register setting examples (5/6) (11) cpu clock changing from subsystem clock (d) to high-sp eed system clock (c) (setting sequence of sfr registers) csc register osmc register ckc register setting flag of sfr register status transition osts register mstop fsel ostc register mcm0 css (d) (c) (x1 clock: 2 mhz f x 10 mhz) note 1 0 0 must be checked 1 0 (d) (c) (x1 clock: 10 mhz < f x 20 mhz) note 1 0 1 note 2 must be checked 1 0 (d) (c) (external main clock) note 1 0 0/1 must not be checked 1 0 unnecessary if the cpu is operating with the high-speed system clock unnecessary if these registers are already set notes 1. set the oscillation stabili zation time as follows. ? desired ostc oscillation stabilization time oscillation stabilization time set by osts 2. fsel = 1 when f clk > 10 mhz if a divided clock is selected and f clk 10 mhz, use with fsel = 0 is possible even if f x > 10 mhz. caution set the clock after the suppl y voltage has reached the operable volt age of the clock to be set (see chapter 31 electrical specifications). (12) cpu clock changing from 20 mhz internal high-speed oscillation clock (j) to in ternal high-speed oscillation clock (b) (setting sequence of sfr registers) dscctl register setting flag of sfr register status transition seldsc dscon (j) (b) 0 0 remark (a) to (k) in table 5-4 correspond to (a) to (k) in figure 5-15. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 246 jun 20, 2011 table 5-4. cpu clock transition a nd sfr register setting examples (6/6) (13) ? halt mode (e) set while cpu is operating wit h internal high-speed oscillation 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) ? halt mode (k) set while cpu is operating with 20 mhz internal high-speed oscillation clock (j) status transition setting (b) (e) (c) (f) (d) (g) (j) (k) executing halt instruction (14) ? stop mode (h) set while cp u is operating with internal hi gh-speed oscillation clock (b) ? stop mode (i) set while cpu is ope rating with high-speed system clock (c) (setting sequence) status transition setting (b) (h) ? in x1 oscillation sets the osts register (c) (i) external main system clock stopping peripheral functions that cannot operate in stop mode ? executing stop instruction remark (a) to (k) in table 5-4 correspond to (a) to (k) in figure 5-15. 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 247 jun 20, 2011 5.6.6 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-5. changing cpu clock (1/2) cpu clock before change after change condition before change processing after change x1 clock stabilization of x1 oscillation ? oscsel = 1, exclk = 0, mstop = 0 ? after elapse of oscillation stabilization time external main system clock enabling input of ex ternal clock from exclk pin ? oscsel = 1, exclk = 1, mstop = 0 operating current can be reduced by stopping internal high-speed oscillator (hiostop = 1). subsystem clock stabilization of x1 oscillation ? oscsels = 1, xtstop = 0 ? after elapse of oscillation stabilization time ? internal high- speed oscillation clock 20 mhz internal high-speed oscillation clock stabilization of dsc oscillation with 20 mhz set by using the option byte ? v dd 2.7 v ? after elapse of oscillation stabilization time (100 s) after setting to dscon = 1 ? seldsc = 1 ? internal high- speed oscillation clock oscillation of internal high-speed oscillator ? hiostop = 0 x1 oscillation can be stopped (mstop = 1). external main system clock transition not possible (to change the clock, set it again after executing reset once.) ? subsystem clock stabilization of xt1 oscillation ? oscsels = 1, xtstop = 0 ? after elapse of oscillation stabilization time x1 oscillation can be stopped (mstop = 1). x1 clock 20 mhz internal high-speed oscillation clock transition cannot be performed unless the clock is changed to the internal high-speed oscillation clock once. ? internal high- speed oscillation clock oscillation of internal high-speed oscillator ? hiostop = 0 external main syst em clock input can be disabled (mstop = 1). x1 clock transition not possible (to change the clock, set it again after executing reset once.) ? subsystem clock stabilization of xt1 oscillation ? oscsels = 1, xtstop = 0 ? after elapse of oscillation stabilization time external main syst em clock input can be disabled (mstop = 1). external main system clock 20 mhz internal high-speed oscillation clock transition cannot be performed unless the clock is changed to the internal high-speed oscillation clock once. ? 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 248 jun 20, 2011 table 5-5. changing cpu clock (2/2) cpu clock before change after change condition before change processing after change internal high- speed oscillation clock oscillation of internal high-speed oscillator and selection of internal high-speed oscillation clock as main system clock ? hiostop = 0, mcs = 0 x1 clock stabilization of x1 oscillation and selection of high-speed system clock as main system clock ? oscsel = 1, exclk = 0, mstop = 0 ? after elapse of oscillation stabilization time ? mcs = 1 external main system clock enabling input of ex ternal clock from exclk pin and selection of high-speed system clock as main system clock ? oscsel = 1, exclk = 1, mstop = 0 ? mcs = 1 xt1 oscillation can be stopped (xtstop = 1) subsystem clock 20 mhz internal high-speed oscillation clock transition cannot be performed unless the clock is changed to the internal high-speed oscillation clock once. ? internal high- speed oscillation clock ? seldsc = 0 (set when changing the clock.) 20 mhz internal high-speed oscillation clock can be stopped (dscon = 0) x1 clock transition cannot be performed unless the clock is changed to the internal high-speed oscillation clock once. ? external main system clock transition cannot be performed unless the clock is changed to the internal high-speed oscillation clock once. ? 20 mhz internal high-speed oscillation clock subsystem clock transition cannot be performed unless the clock is changed to the internal high-speed oscillation clock once. ? 78k0r/lx3 chapter 5 clock generator r01uh0004ej0501 rev.5.01 249 jun 20, 2011 5.6.7 time required for switchover of cpu clock and main system clock by setting bits 0 to 2, 4, and 6 (mdiv0 to mdiv2, sdiv, mc m0, css) of the system clock control register (ckc), the cpu clock can be switched (between the main system clock and the subsystem clock), main system clock can be switched (between the internal high-speed oscillation clock and the high-speed system clock), and the division ratio of the main system clock can be changed. the actual switchover operat ion is not performed immediately after rewrit ing to ckc; operatio n continues on the pre- switchover clock for several clo cks (see table 5-6 to table 5-9). whether the cpu is operating on the main system clock or t he subsystem clock can be ascertained using bit 7 (cls) of ckc. whether the main system clock is operating on the high-speed system clock or internal high-speed oscillation clock can be ascertained using bit 5 (mcs) of ckc. when the cpu clock is switched, the perip heral hardware clock is also switched. internal high-speed oscillation clock table 5-6. maximum time required for main system clock switchover clock a switching directions clock b remark f mainc f mainc f subc (changing the division ratio) f subc see table 5-7 f ih f mx see table 5-8 f mainc f subc see table 5-9 table 5-7. maximum number of clocks required in f mainc ? f mainc (changing the division ratio), f subc ? f subc (changing the division ratio) set value after switchover set value before switchover clock a clock b clock a 1 + f a /f b clock clock b 1 + f b /f a clock table 5-8. maximum number of clocks required in f ih ? f mx set value before switchover set value after switchover mcm0 mcm0 0 (f main = f ih ) 1 (f main = f mx ) f mx f ih 1 + f ih /f mx clock 0 (f main = f ih ) f mx 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 251 jun 20, 2011 chapter 6 timer array unit 78k0r/lf3 78k0r/lg3 78k0r/lh3 item 80 pins 100 pins 128 pins 0 8 ch (pwm output: 5) 8 ch (pwm output: 7) 8 ch (pwm output: 7) timer array unit 1 4 ch (pwm output: 0) 4 ch (pwm output: 0) 4 ch (pwm output: 3) the 78k0r/lx3 is provided with two timer array units. time array unit 0 is provided with eight 16-bit timers and timer array unit 1 is provided with four 16-bit timers. each 16- bit timer is called a channel and can be used as an independent timer. in addition, two or more ?channels? can be used to create a high-accuracy timer. independent operation function combination operation function ? interval timer ? square wave output ? external event counter ? divider function ? input pulse interval measurement ? measurement of high-/low-l evel width of input signal ? pwm output ? one-shot pulse output ? multiple pwm output channel 7 of timer array unit 0 can be used to realize lin-bu s reception processing in combination with uart3 of serial array unit 1. cautions 1. channel 5 of timer array unit 0 of the 78k0r/lf3 can be used only as an interval timer. 2. channel 6 of timer array unit 0 of the 78k0r/lf3 can be used on ly as an interval timer, for pwm output (master channel), and for one-shot pulse ou tput (master channel when software trigger start is selected). 3. channels 0 to 3 of timer array unit 1 of the 78k0r/lf3 and 78k0r/lg3 can be used only as interval timers. 4. channels 1, 5 to 7 of timer array unit 0 and ch annels 0 to 3 of timer array unit 1 cannot be used as frequency dividers. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 252 jun 20, 2011 whether each chan nel of the timer array unit is provided with timer i/o pins differs depending on t he product. timer i/o pins of each product timer array unit n channel m input (tipq) / output (topq) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) input ti00/to03/p31/rtcdiv/rtccl/pclbuz1/intp2 0 output to00/ti03/p30rtc1hz/intp1 1 i/o ti01/to01/p32/pclbuz0/intp5 input ti02/p52/segxx (78k0r/lf3: xx = 28, 78k0r/lg3: xx = 37, 78k0r/lh3: xx = 51) 2 output to02/p12/so02/txd2 input ti03/to00/p30rtc1hz/intp1 3 output to03/ti00/p31/rtcdiv/rtccl/pclbuz1/intp2 input ti04/p53/segxx (78k0r/lf3: xx = 27, 78k0r/lg3: xx = 36, 78k0r/lh3: xx = 50) 4 output to04/p13/so10/txd1 5 i/o ti05/to05/p16/intp10 6 i/o ? ti06/to06/p34/intp8 0 7 i/o ti07/to07/p33/intp3 0 i/o ti10/to10/p84 1 i/o ti11/to11/p85 2 i/o ti12/to12/p86 1 3 i/o ? ti13/to13/p87 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 253 jun 20, 2011 6.1 functions of timer array unit the timer array unit has the following functions. 6.1.1 functions of each channel when it operates independently independent operation functions are those functions that can be used for any channel regardless of the operation mode of the other channel (for details, refer to 6.6.1 overview of single-operation function and combination operation function ). (1) interval timer each timer of a unit can be used as a reference timer t hat generates an interrupt (in ttmmn) at fixed intervals. (2) square wave output a toggle operation is performed each time inttmpq is gener ated and a square wave with a duty factor of 50% is output from a timer output pin (topq). (3) external event counter each timer of a unit can be used as an event counter t hat generates an interrupt wh en the number of the valid edges of a signal input to the timer input pin (tipq) has reached a specific value. (4) divider function a clock input from a timer input pin (tipq) is divided and output from an output pin (topq). (5) input pulse inte rval measurement counting is started by the valid edge of a pulse signal input to a timer input pin (tipq). the count value of the timer is captured at the valid edge of the next pulse. in this way, the interval of the input pulse can be measured. (6) measurement of high-/low-l evel width of input signal counting is started by a single edge of t he signal input to the timer input pin (tipq), and the count value is captured at the other edge. in this way, the high-level or low-level width of the input signal can be measured. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 254 jun 20, 2011 6.1.2 functions of each channel when it operates with another channel combination operation functions are t hose functions that are attained by us ing the master channel (mostly the reference timer that controls cycles) and the slave channel s (timers that operate followi ng the master channel) in combination (for details, refer to 6.6.1 overview of single -operation function and combination operation function ). (1) pwm (pulse width modulator) output two channels are used as a set to generate a pulse with a specified period and a specified duty factor. (2) one-shot pulse output two channels are used as a set to generate a one-shot pul se with a specified delay time and a specified pulse width. (3) multiple pwm (pulse width modulator) output by extending the pwm function and using one master cha nnel and two or more slave channels, up to seven types of pwm signals that have a specific period and a specified duty factor can be generated. 6.1.3 lin-bus supporting function (channel 7 of timer array unit 0 only) (1) detection of wakeup signal the timer starts counting at the falling edge of a signal input to the serial data input pin (rxd3) of uart3 and the count value of the timer is captured at the rising edge. in this way, a low-level width can be measured. if the low- level width is greater than a specific valu e, it is recognized as a wakeup signal. (2) detection of sync break field the timer starts counting at the fallin g edge of a signal input to the serial data input pin (rxd3) of uart3 after a wakeup signal is detected, an d the count value of the timer is captured at the rising edge. in this way, a low-level width is measured. if the low-level width is greater than a specific value, it is recognized as a sync break field. (3) measurement of pulse width of sync field after a sync break field is detected, the low-level width a nd high-level width of the signa l input to the serial data input pin (rxd3) of uart3 are measured. from the bit inte rval of the sync field measured in this way, a baud rate is calculated. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 255 jun 20, 2011 6.2 configuration of timer array unit the timer array unit includes the following hardware. table 6-1. configuration of timer array unit item configuration timer/counter timer counter register mn (tcrmn) register timer data register mn (tdrmn) timer input tipq pin, rxd3 pin (for lin-bus) timer output topq pins, output controller 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 256 jun 20, 2011 figure 6-1. block diagram of timer array unit 0 to07 to03 to06 to05 to04 to02 to01 to00 te07 te03 te06 te05 te04 te02 te01 te00 toe07 toe03 toe06 toe05 toe04 toe02 toe01 toe00 ts07 ts03 ts06 ts05 ts04 ts02 ts01 ts00 tt07 tt03 tt06 tt05 tt04 tt02 tt01 tt00 tol07 tol03 tol06 tol05 tol04 tol02 tol01 tol00 tom07 tom03 tom06 tom05 tom04 tom02 tom01 tom00 tnfen 07 tnfen 06 tnfen 05 tnfen 04 tnfen 03 tnfen 02 tnfen 01 tnfen 00 tis07 tis03 tis06 tis05 tis04 tis02 tis01 tis00 channel 0 rxd3 ti02 ti03 ti05 ti06 to00 to02 to03 to04 to05 to06 inttm00 inttm02 inttm03 inttm04 inttm05 inttm06 inttm07 isc1 ti07 to07 pm32 cks01 ccs01 mas ter01 sts012 sts011 sts010 md012 cis011 cis010 md013 md011 md010 ovf 01 ck00 ck01 mck tclk tis01 tnfen01 f subc /2 ti00 rtc interval interrupt (intrtci) : f xt /2 6 to f xt /2 12 f subc /2 noise elimination enabled/disabled ti04 rtc interval interrupt (intrtci) : f xt /2 6 to f xt /2 12 f subc /2 0 0 rtcis 04 rtcis 00 tis00, rtcis00, sdiv tis04, rtcis04, sdiv 3 bits 0 to 3 are used by timer array unit 1 channel 1 of the d/a converter (damd1 = 1 setting) channel 0 of the d/a converter (damd0 = 1 setting) a/d converter (adtmd = 1, adtrs = 0 setting) a/d converter (adtmd = 1, adtrs = 1 setting) timer channel enable status register 0 (te0) timer channel stop register 0 (tt0) timer channel start register 0 (ts0) timer input select register 0 (tis0) timer input select register 1 (tis1) timer output register 0 (to0) timer output enable register 0 (toe0) timer output level register 0 (tol0) timer output mode register 0 (tom0) noise filter enable register 1 (nfen1) slave/master controller trigger signal to slave channel clock signal to slave channel interrupt signal to slave channel count clock selection selector selector selector edge detection noise elimination enabled/disabled operating clock selection trigger selection slave/master controller channel 1 ti01 (timer input pin) channel 2 channel 3 (serial input pin) channel 7 (lin-bus supported) selector channel 6 channel 5 channel 4 selector noise elimination enabled/disabled timer controller mode selection timer data register 01 (tdr01) timer counter register 01 (tcr01) timer status register 01 (tsr01) overflow interrupt controller output controller output latch (p32) to01 (timer output pin) inttm01 (timer interrupt) timer mode register 01 (tmr01) timer clock select register 0 (tps0) 4 4 f clk f clk /2 0 to f clk /2 15 selector f clk /2 0 to f clk /2 15 selector tau0en peripheral enable register 0 (per0) prescaler prs013 prs003 prs012 prs011 prs010 prs002 prs001 prs000 3 remark channels 5 and 6 of the 78k0r/lf3 are not pr ovided with timer i/o pins (ti05/to05, ti06/to06). 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 257 jun 20, 2011 figure 6-2. block diagram of timer array unit 1 timer clock select register 1 (tps1) prs113 4 prs103 prs112 prs111 prs110 prs102 prs101 prs100 4 f clk tau1en channel 0 ti10 ti12 ti13 to10 to12 to13 inttm10 inttm12 inttm13 pm85 cks11 ccs11 mas ter11 sts112 sts111 sts110 md112 cis111 cis110 md113 md111 md110 ovf 11 ck10 ck11 mck tclk output latch ( p85) tis11 tnfen11 to13 to12 to11 to10 te13 te12 te11 te10 toe13 toe12 toe11 toe10 ts13 ts12 ts11 ts10 tt13 tt12 tt11 tt10 tol13 tol12 tol11 tol10 tom13 tom12 tom11 tom10 tnfen 13 tnfen 12 tnfen 11 tnfen 10 tis13 tis12 tis11 tis10 f subc /2 timer output register 1 (to1) timer output enable register 1 (toe1) timer channel enable status register 1 (te1) timer channel stop register 1 (tt1) timer channel start register 1 (ts1) timer output level register 1 (tol1) timer output mode register 1 (tom1) noise filter enable register 2 (nfen2) timer input select register 1 (tis1) peripheral enable register 0 (per0) f clk /2 0 to f clk /2 15 selector f clk /2 0 to f clk /2 15 selector prescaler slave/master controller trigger signal to slave channel clock signal to slave channel interrupt signal to slave channel edge detection selector count clock selection trigger selection slave/master controller channel 1 ti11 (timer input pin) noise elimination enabled/disabled operating clock selection channel 2 channel 3 timer counter register 11 (tcr11) overflow timer data register 11 (tdr11) timer status register 11 (tsr11) interrupt controller output controller timer controller mode selection to11 (timer output pin) inttm11 (timer interrupt) timer mode register 11 (tmr11) remark for the channels 0 to 3 of 78k0r/lf3 and 78k0r/lg3, the timer i/o pins (ti10/ to10 to ti13/to13) are not mounted. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 258 jun 20, 2011 (1) timer/counter register mn (tcrmn) tcrmn is a 16-bit read-only register and is used to count clocks. the value of this counter is increment ed or decremented in synchronization with the rising edge of a count clock. whether the counter is incr emented or decremented depends on the opera tion mode that is selected by the mdmn3 to mdmn0 bits of tmrmn. figure 6-3. format of timer/ counter register mn (tcrmn) address: f0180h, f0181h (tcr00) to f018eh, f018fh (tcr07) after reset: ffffh r f01c0h, f01c1h (tcr10) to f01c6h, f01c7h (tcr13) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tcrmn the count value can be re ad by reading tcrmn. the count value is set to ffffh in the following cases. ? when the reset signal is generated ? when the tau0en bit (tau0) and tau1en bit (tau1) of peripheral enable register 0 (per0) is cleared the count value is cleared to 0000h in the following cases. ? when the start trigger is input in the capture mode ? when capturing has been completed in the capture mode ? when counting of the slave channel has been completed in the pwm output mode ? when counting of the master/slave channel has been completed in the one-shot pulse output mode ? when counting of the slave channel has been completed in the multiple pwm output mode caution the count value is not captured to tdrmn even when tcrmn is read. remark mn: unit number + channel number mn = 00 to 07, 10 to 13 f0181h (tcr00) f0180h (tcr00) 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 259 jun 20, 2011 the tcrmn register read value differs as follows according to operation mode changes and the operating status. table 6-2. tcrmn register read value in various operation modes tcrmn register read value note operation mode count mode operation mode change after reset operation mode change after count operation paused (ttmn = 1) operation restart after count operation paused (ttmn = 1) during start trigger wait status after one count interval timer mode count down ffffh undefined stop value ? capture mode count up 0000h undefined stop value ? event counter mode count down ffffh undefined stop value ? one-count mode count down ffffh undefined stop value ffffh capture & one- count mode count up 0000h undefined stop value capture value of tdrmn register + 1 note the read values of the tcrmn regi ster when tsmn has been set to "1" while temn = 0 are shown. the read value is held in the tcrmn register unt il the count operation starts. remark mn: unit number + channel number mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 260 jun 20, 2011 (2) timer data register mn (tdrmn) this is a 16-bit register from which a capture function and a compare function can be selected. the capture or compare function can be switched by sele cting an operation mode by using the mdmn3 to mdmn0 bits of tmrmn. the value of tdrmn can be changed at any time. this register can be read or written in 16-bit units. reset signal generation clears this register to 0000h. figure 6-4. format of timer data register mn (tdrmn) address: fff18h, fff19h (tdr00), fff1ah, fff1bh (tdr01), after reset: 0000h r/w fff64h, fff65h (tdr02) to fff6eh, fff6fh (tdr07) fff70h, fff71h (tdr10) to fff76h, fff77h (tdr13) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tdrmn (i) when tdrmn is used as compare register counting down is started from the value set to tdrmn. when the count value reaches 0000h, an interrupt signal (inttmmn) is generated. tdrmn ho lds its value until it is rewritten. caution tdrmn does not perform a captu re operation even if a capture trigger is input, when it is set to the compare function. (ii) when tdrpq is u sed as capture register the count value of tcrpq is captured to tdrpq when the capture trigger is input. a valid edge of the tipq pin can be selected as the c apture trigger. this selection is made by tmrpq. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 fff19h (tdr00) fff18h (tdr00) 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 261 jun 20, 2011 6.3 registers controlling timer array unit timer array unit is controlled by the following registers. ? peripheral enable register 0 (per0) ? timer clock select register m (tpsm) ? timer mode register mn (tmrmn) ? timer status register pq (tsrpq) ? timer channel enable status register m (tem) ? timer channel start register m (tsm) ? timer channel stop register m (ttm) ? timer input select regi sters 0, 1 (tis0, tis1) ? timer output enable register p (toep) ? timer output register p (top) ? timer output level register p (tolp) ? timer output mode register p (tomp) ? input switch control register (isc) ? noise filter enable registers 1, 2 (nfen1, nfen2) ? port mode registers 1, 3, 5, 8 (pm1, pm3, pm5, pm8) ? port registers1, 3, 5, 8 (p1, p3, p5, p8) remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, p = 0, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, p = 0, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 262 jun 20, 2011 (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripheral hardware macro. clock supply to a hardware macro that is not used is stopped in order to r educe the power consumption and noise. when the timer array unit 0 is used, be sure to set bit 0 (tau0en) of this register to 1. when the timer array unit 1 is used, be sure to set bit 1 (tau1en) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. caution when setting the timer array uni t, be sure to set taumen to 1 first. if taumen = 0, writing to a control register of the timer array unit is i gnored, and all read values are default values. figure 6-5. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note sau1en sau0en tau1en tau0en taumen control of timer array unit m input clock 0 stops supply of input clock. ? sfr used by the timer array unit m cannot be written. ? the timer array unit m is in the reset status. 1 supplies input clock. ? sfr used by the timer array unit m can be read/written. note 78k0r/lg3, 78k0r/lh3 only (2) timer clock select register m (tpsm) tpsm is a 16-bit register that is used to select tw o types of operation clocks (ckm0, ckm1) that are commonly supplied to each channel. ckm1 is selected by bits 7 to 4 of tpsm, and ckm0 is selected by bits 3 to 0. rewriting of tpsm during timer operation is possible only in the following cases. rewriting of prsm00 to prsm03 bits: possible only when all the channels set to cksmn = 0 are in the operation stopped state (temn = 0) rewriting of prsm10 to prsm13 bits: possible only when all the channels set to cksmn = 1 are in the operation stopped state (temn = 0) tpsm can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tpsm can be set with an 8-bi t memory manipulation instruction with tpsml. reset signal generation clears this register to 0000h. remark mn: unit number + channel number m = 0, 1, mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 263 jun 20, 2011 figure 6-6. format of timer clock select register m (tpsm) address: f01b6h, f01b7h (tps0) after reset: 0000h r/w f01deh, f01dfh (tps1) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tpsm 0 0 0 0 0 0 0 0 prs m13 prs m12 prs m11 prs m10 prs m03 prs m02 prs m01 prs m00 selection of operation clock (ckmk) notes 1,2 prs mk3 prs mk2 prs mk1 prs mk0 f clk = 2 mhz f clk = 5 mhz f clk = 10 mhz f clk = 20 mhz 0 0 0 0 f clk 2 mhz 5 mhz 10 mhz 20 mhz 0 0 0 1 f clk /2 1 mhz 2.5 mhz 5 mhz 10 mhz 0 0 1 0 f clk /2 2 500 khz 1.25 mhz 2.5 mhz 5 mhz 0 0 1 1 f clk /2 3 250 khz 625 khz 1.25 mhz 2.5 mhz 0 1 0 0 f clk /2 4 125 khz 312.5 khz 625 khz 1.25 mhz 0 1 0 1 f clk /2 5 62.5 khz 156.2 khz 312.5 khz 625 khz 0 1 1 0 f clk /2 6 31.25 khz 78.1 khz 156.2 khz 312.5 khz 0 1 1 1 f clk /2 7 15.62 khz 39.1 khz 78.1 khz 156.2 khz 1 0 0 0 f clk /2 8 7.81 khz 19.5 khz 39.1 khz 78.1 khz 1 0 0 1 f clk /2 9 3.91 khz 9.76 khz 19.5 khz 39.1 khz 1 0 1 0 f clk /2 10 1.95 khz 4.88 khz 9.76 khz 19.5 khz 1 0 1 1 f clk /2 11 976 hz 2.44 khz 4.88 khz 9.76 khz 1 1 0 0 f clk /2 12 488 hz 1.22 khz 2.44 khz 4.88 khz 1 1 0 1 f clk /2 13 244 hz 610 hz 1.22 khz 2.44 khz 1 1 1 0 f clk /2 14 122 hz 305 hz 610 hz 1.22 khz 1 1 1 1 f clk /2 15 61 hz 153 hz 305 hz 610 hz notes 1. when changing the clock selected for f clk (by changing the system clock c ontrol register (ckc) value), stop the timer array unit (tt0 = 00ffh, tt1 = 000fh). 2. only in the case of sdiv=0, ccsmn=1 and tismn=1, continuously use of taum is allowed, even when changing cpu clock. however, the following limitation is existing. ? when changing cpu clock, source clock decrease/increase occurs as follows. main clock subsystem clock (css = 0 1): ? 1 clock subsystem clock main clock (css = 1 0): +1 clock caution be sure to clear bits 15 to 8 to ?0?. remarks 1. f clk : cpu/peripheral hardware clock frequency 2. k = 0, 1 3. mn: unit number + channel number m = 0, 1, mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 264 jun 20, 2011 (3) timer mode register mn (tmrmn) tmrmn sets an operation mode of channel n of timer array uni t m. it is used to select an operation clock (mck), a count clock, whether the timer operates as the master or a slave, a start trigger and a capture trigger, the valid edge of the timer input, and an operation mode (interval, capture, event counter, one-count, or capture & one- count). rewriting tmrmn is prohibited when the register is in oper ation (when tem = 1). however, bits 7 and 6 (cismn1, cismn0) can be rewritten even while the register is oper ating with some functions (when tem = 1) (for details, see 6.7 operation of timer array unit as independent channel and 6.8 operation of plural channels of timer array unit ). tmrmn can be set by a 16-bit memory manipulation instruction. reset signal generation clears this register to 0000h. figure 6-7. format of timer m ode register mn (tmrmn) (1/4) address: f0190h, f0191h (tmr00) to f019eh, f019fh (tmr07) after reset: 0000h r/w f01c8h, f01c9h (tmr10) to f01ceh, f01cfh (tmr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cks mn 0 0 ccs mn mast ermn sts mn2 sts mn1 sts mn0 cis mn1 cis mn0 0 0 md mn3 md mn2 md mn1 md mn0 cks mn selection of operation cl ock (mck) of channel n 0 operation clock ckm0 set by tpsm register 1 operation clock ckm1 set by tpsm register operation clock mck is used by the edge detector. a count clock (tclk) and a sampling clock are generated depending on the setting of the ccsmn bit. ccs mn selection of count clock (tclk) of channel n 0 operation clock mck specified by cksmn bit 1 valid edge of input signal input from tipq pin, f sub /2, f sub/ 4, or intrtc1 (the timer input used with channel x is selected by using tism register). count clock tclk is used for the timer/counter, output controller, and interrupt controller. if ccsmn = 1, use the count clock under the following condition. ? the frequency of the operating clock selected by using cksmn the frequency of the clock selected by using tismn 2 caution be sure to clear bits 14, 13, 5, and 4 to ?0?. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 265 jun 20, 2011 figure 6-7. format of timer m ode register mn (tmrmn) (2/4) address: f0190h, f0191h (tmr00) to f019eh, f019fh (tmr07) after reset: 0000h r/w f01c8h, f01c9h (tmr10) to f01ceh, f01cfh (tmr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cks mn 0 0 ccs mn mast ermn sts mn2 sts mn1 sts mn0 cis mn1 cis mn0 0 0 md mn3 md mn2 md mn1 md mn0 mas ter mn selection of slave/master of channel n 0 operates as slave channel with combination operation function. 1 operates as master channel with combination operation function. only the even channel can be set as a master channel (mastermn = 1). be sure to use the odd channel as a slave channel (mastermn = 0). clear mastermn to 0 for a channel that is used with the independent operation function. sts mn2 sts mn1 sts mn0 setting of start trigger or capture trigger of channel n 0 0 0 only software trigger start is valid (other trigger sources are unselected). 0 0 1 valid edge of tipq pin input signal, f sub /2, f sub/ 4, or intrtc1 is used as both the start trigger and capture trigger. 0 1 0 both the edges of tipq pin input signal, f sub /2, f sub/ 4, or intrtc1 are used as a start trigger and a capture trigger. 1 0 0 interrupt signal of the master channel is us ed (when the channel is used as a slave channel with the combination operation function). other than above setting prohibited cis mn1 cis mn0 selection of valid edge of tipq pin input signal , f sub /2, f sub/ 4, or intrtc1 (the timer input used with channel x is selected by using tism register). 0 0 falling edge 0 1 rising edge 1 0 both edges (when low-level width is measured) start trigger: falling edge, capture trigger: rising edge 1 1 both edges (when high-level width is measured) start trigger: rising edge, capture trigger: falling edge if both the edges are specified when the value of the st smn2 to stsmn0 bits is other than 010b, set the cismn1 to cismn0 bits to 10b. caution be sure to clear bits 14, 13, 5, and 4 to ?0?. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 266 jun 20, 2011 figure 6-7. format of timer m ode register mn (tmrmn) (3/4) address: f0190h, f0191h (tmr00) to f019eh, f019fh (tmr07) after reset: 0000h r/w f01c8h, f01c9h (tmr10) to f01ceh, f01cfh (tmr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cks mn 0 0 ccs mn mast ermn sts mn2 sts mn1 sts mn0 cis mn1 cis mn0 0 0 md mn3 md mn2 md mn1 md mn0 md mn3 md mn2 md mn1 md mn0 operation mode of channel n count operation of tcr independent operation 0 0 0 1/0 interval timer mode counting down possible 0 1 0 1/0 capture mode counting up possible 0 1 1 0 event counter mode counting down possible 1 0 0 1/0 one-count mode counting down impossible 1 1 0 0 capture & one-count mode counting up possible other than above setting prohibited the operation of mdmn0 bits varies depending on each operation mode (see following table). cautions 1. be sure to clear bits 14, 13, 5, and 4 to ?0?. 2. channel 5 of timer array unit 0 and channels 0 to 3 of timer array unit 1 of the 78k0r/lf3 can be set only to the interval mode. 3. channel 6 of timer array unit 0 of the 78k0r /lf3 can be set only to the interval mode and one-count mode (when using as master). 4. channels 0 to 3 of timer array unit 1 of th e 78k0r/lg3 can be set only to the interval mode. remark mn: unit number + channel number mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 267 jun 20, 2011 figure 6-7. format of timer m ode register mn (tmrmn) (4/4) operation mode (value set by the mdmn3 to mdmn1 bits (see table above)) md mn0 setting of starting counting and interrupt 0 timer interrupt is not generated when counting is started (timer output does not change, either). ? interval timer mode (0, 0, 0) ? capture mode (0, 1, 0) 1 timer interrupt is generated when counting is started (timer output also changes). ? event counter mode (0, 1, 1) 0 timer interrupt is not generated when counting is started (timer output does not change, either). 0 start trigger is invalid during counting operation. at that time, interrupt is not generated, either. ? one-count mode (1, 0, 0) 1 start trigger is valid during counting operation note . at that time, interrupt is also generated. ? capture & one-count mode (1, 1, 0) 0 timer interrupt is not generated when counting is started (timer output does not change, either). start trigger is invalid during counting operation. at that time interrupt is not generated, either. other than above setting prohibited note if the start trigger (tsmn = 1) is issued during op eration, the counter is cleared, an interrupt is generated, and recounting is started. remark mn: unit number + channel number mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 268 jun 20, 2011 (4) timer status register pq (tsrpq) tsrpq indicates the overflow status of the counter of channel n. tsrpq is valid only in the capture mode (mdpq3 to mdpq1 = 010b) and capture & one-count mode (mdpq3 to mdpq1 = 110b). it will not be set in any other mode. see table 6-3 for the operation of the ovfpq bit in each operation mode and set/clear conditions. tsrpq can be read by a 16-bit memory manipulation instruction. the lower 8 bits of tsrpq can be set with an 8-bi t memory manipulation instruction with tsrpql. reset signal generation clears this register to 0000h. figure 6-8. format of timer status register pq (tsrpq) address: f01a0h, f01a1h (tsr00) to f01aeh, f01afh (tsr07) after reset: 0000h r f01d0h, f01d1h (tsr10) to f01d6h, f01d7h (tsr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tsrpq 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ovf pq ovf pq counter overflow status of channel q 0 overflow does not occur. 1 overflow occurs. when ovfpq = 1, this flag is clea red (ovfpq = 0) when the next va lue is captured without overflow. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 table 6-3. ovfpq bit operation and set/cl ear conditions in each operation mode timer operation mode ovf pq set/clear conditions clear when no overflow has occurred upon capturing ? capture mode ? capture & one-count mode set when an overflow has occurred upon capturing clear ? interval timer mode ? event counter mode ? one-count mode set ? (use prohibited, not set/cleared) remark the ovfpq bit does not change immediately after the counter has overflowed, but changes upon the subsequent capture. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 269 jun 20, 2011 (5) timer channel enable status register m (tem) tem is used to enable or stop the timer operation of each channel. when a bit of timer channel start register m (tsm) is set to 1, the corresponding bit of this register is set to 1. when a bit of timer channel stop register m (ttm) is set to 1, the corresponding bit of this register is cleared to 0. tem can be read by a 16-bit memory manipulation instruction. the lower 8 bits of tem can be set with a 1-bit or 8-bit memory manipulation instruction with teml. reset signal generation clears this register to 0000h. figure 6-9. format of timer channe l enable status register m (tem) address: f01b0h, f01b1h after reset: 0000h r symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 te0 0 0 0 0 0 0 0 0 te07 te06 te05 te04 te03 te02 te01 te00 address: f01d8h, f01d9h after reset: 0000h r symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 te1 0 0 0 0 0 0 0 0 0 0 0 0 te13 te12 te11 te10 te mn indication of operation enable/stop status of channel n 0 operation is stopped. 1 operation is enabled. remark mn: unit number + channel number m = 0, 1, mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 270 jun 20, 2011 (6) timer channel start register m (tsm) tsm is a trigger register that is used to clear a ti mer counter (tcrmn) and start the counting operation of each channel. when a bit (tsmn) of this register is set to 1, the corresponding bit (temn) of timer channel enable status register m (tem) is set to 1. tsmn is a trigger bit and cleared immediately when temn = 1. tsm can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tsm can be set with a 1-bit or 8-bit memory manipulation instruction with tsml. reset signal generation clears this register to 0000h. figure 6-10. format of timer channel start register m (tsm) address: f01b2h, f01b3h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ts0 0 0 0 0 0 0 0 0 ts07 ts06 ts05 ts04 ts03 ts02 ts01 ts00 address: f01dah, f01dbh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ts1 0 0 0 0 0 0 0 0 0 0 0 0 ts13 ts12 ts11 ts10 tsmn operation enable (sta rt) trigger of channel n 0 no trigger operation 1 temn is set to 1 and the count operation becomes enabled. the tcrmn count operation start in the count ope ration enabled state varies depending on each operation mode (see table 6-4). caution be sure to clear bits 15 to 8 of ts0 and bits 15 to 4 of ts1 to ?0?. remarks 1. when the tsm register is read, 0 is always read. 2. mn: unit number + channel number m = 0, 1, mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 271 jun 20, 2011 table 6-4. operations from count oper ation enabled state to tcrmn count start timer operation mode operati on when tsmn = 1 is set ? interval timer mode no operation is carried out from start tr igger detection (tsmn=1) until count clock generation. the first count clock loads the value of tdrmn to tcrmn and the subsequent count clock performs count down operation (see 6.3 (6) (a) start timing in interval timer mode ). ? event counter mode writing 1 to tsmn bit loads the value of tdrmn to tcrmn. the subsequent count clock performs count down operation. the external trigger detection selected by stsmn2 to stsmn0 bits in the tmrmn register does not start count operation (see 6.3 (6) (b) start timing in event counter mode ). ? capture mode no operation is carried out from star t trigger detection until count clock generation. the first count clock loads 0000h to tcrmn and the subsequent count clock performs count up operation (see 6.3 (6) (c) start timing in capture mode ). ? one-count mode when temn = 0, writing 1 to tsmn bit sets the start trigger wait state. no operation is carried out from star t trigger detection until count clock generation. the first count clock loads the value of tdrmn to tcrmn and the subsequent count clock performs count down operation (see 6.3 (6) (d) start timing in one- count mode ). ? capture & one-count mode when temn = 0, writing 1 to tsmn bit sets the start trigger wait state. no operation is carried out from star t trigger detection until count clock generation. the first count clock loads 0000h to tcrmn and the subsequent count clock performs count up operation (see 6.3 (6) (e) start timing in capture & one- count mode ). cautions 1. channel 5 of timer array unit 0 and channe ls 0 to 3 of timer array unit 1 of the 78k0r/lf3 can be set only to the interval mode. 2. channel 6 of timer array unit 0 of the 78k0r /lf3 can be set only to the interval mode and one-count mode (when using as master). 3. channels 0 to 3 of timer array unit 1 of th e 78k0r/lg3 can be set only to the interval mode. (a) start timing in interval timer mode <1> writing 1 to tsmn sets temn = 1 <2> the write data to tsmn is held until count clock generation. <3> tcrmn holds the initial val ue until count clock generation. <4> on generation of count clock, the ?tdrmn value? is loaded to tcrmn and count starts. remark mn: unit number + channel number mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 272 jun 20, 2011 figure 6-11. start timing (in interval timer mode) tsmn (write) temn count clock f clk tcrmn inttmmn initial value tdrmn value when mdmn0 = 1 is set <1> <2> <3> <4> start trigger detection signal tsmn (write) hold signal caution in the first cycle operation of count clock a fter writing tsmn, an error at a maximum of one clock is generated since count start delays until count cl ock has been generated. when the information on count start timing is necessary, an interrupt can be generated at count start by setting mdmn0 = 1. remark mn: unit number + channel number mn = 00 to 07, 10 to 13 (b) start timing in event counter mode <1> while tepq is set to 0, tcrpq holds the initial value. <2> writing 1 to tspq sets 1 to tepq. <3> as soon as 1 has been written to tspq and 1 has been set to tepq, the "tdrpq value" is loaded to tcrpq to start counting. <4> after that, the tcrpq value is count ed down according to the count clock. figure 6-12. start timing (in event counter mode) tepq f clk tcrpq tdrpq value <1> <1> <2> <3> tdrpq value-1 initial value tspq (write) count clock start trigger detection signal tspq (write) hold signal remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 273 jun 20, 2011 (c) start timing in capture mode <1> writing 1 to tspq sets tepq = 1 <2> the write data to tspq is held until count clock generation. <3> tcrpq holds the initial val ue until count clock generation. <4> on generation of count clock, 0000h is loaded to tcrpq and count starts. figure 6-13. start timing (in capture mode) tepq f clk tcrpq inttmpq 0000h <1> <2> <3> <4> initial value when mdpq0 = 1 is set tspq (write) count clock start trigger detection signal tspq (write) hold signal caution in the first cycle operation of count clock afte r writing tspq, an error at a maximum of one clock is generated since count start delays until count cloc k has been generated. when the information on count start timing is necessary, an interrupt can be generated at count start by setting mdpq0 = 1. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 274 jun 20, 2011 (d) start timing in one-count mode <1> writing 1 to tspq sets tepq = 1 <2> enters the start trigger input wait status, and tcrpq holds the initial value. <3> on start trigger detection , the ?tdrpq value? is loaded to tcrpq and count starts. figure 6-14. start timing (in one-count mode) tepq f clk tcrpq start trigger input wait status tdrpq value initial value <1> <2> <3> tspq (write) count clock note start trigger detection signal tspq (write) hold signal tin edge detection signal note when the one-count mode is set, the operation cloc k (mck) is selected as count clock (ccspq = 0). caution an input signal sampling error is generated since operation starts upon start trigger detection (the error is one count clock when tipq is used). remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07, 06 (only when used as the master) 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 275 jun 20, 2011 (e) start timing in capture & one-count mode <1> writing 1 to tspq sets tepq = 1 <2> enters the start trigger input wait status, and tcrpq holds the initial value. <3> on start trigger detection , 0000h is loaded to tcrpq and count starts. figure 6-15. start timing (in capture & one-count mode) tepq f clk tcrpq 0000h tspq (write) count clock note start trigger detection signal tspq (write) hold signal tin edge detection signal start trigger input wait status initial value <2> <3> <1> note when the capture & one-count mode is set, the operati on clock (mck) is selected as count clock (ccspq = 0). caution an input signal sampling error is generate d since operation starts upon start trigger detection (the error is one count clock when tipq is used). (7) timer channel stop register m (ttm) ttm is a trigger register that is used to clear a time r counter (tcrmn) and start t he counting operation of each channel. when a bit (ttmn) of this register is set to 1, the corresp onding bit (temn) of timer chan nel enable status register 0 (tem) is cleared to 0. ttmn is a trigger bit and cleared to 0 immediately when temn = 0. ttm can be set by a 16-bit memory manipulation instruction. the lower 8 bits of ttm can be set with a 1-bit or 8-bit memory manipulation instruction with ttml. reset signal generation clears this register to 0000h. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 276 jun 20, 2011 figure 6-16. format of timer channel stop register m (ttm) address: f01b4h, f01b5h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tt0 0 0 0 0 0 0 0 0 tt07 tt06 tt05 tt04 tt03 tt02 tt01 tt00 address: f01dch, f01ddh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tt1 0 0 0 0 0 0 0 0 0 0 0 0 tt13 tt12 tt11 tt10 ttmn operation stop trigger of channel n 0 no trigger operation 1 operation is stopped (s top trigger is generated). caution be sure to clear bits 15 to 8 of tt0 and bits 15 to 4 of tt1 to ?0?. remarks 1. when the ttm register is read, 0 is always read. 2. mn: unit number + channel number m = 0, 1, mn = 00 to 07, 10 to 13 (8) timer input select registers 0, 1 (tis0, tis1) tis0 and tis1 use can be set to the input signal of a ti mer input pin (tipq), half t he frequency of the subsystem clock (f sub /2), one fourth the frequency of the subsystem clock (f sub /4), or an rtc interval interrupt (intrtci) as the timer input. the timer input can be selected for each channel. tis0 and tis1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 figure 6-17. format of timer input select registers 0, 1 (tis0, tis1) (1/2) ? 78k0r/lf3 address: fff3eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tis0 tis07 0 0 tis04 tis03 tis02 tis01 tis00 address: fff4eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tis1 0 0 rtcis04 rtcis00 0 0 0 0 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 277 jun 20, 2011 figure 6-17. format of timer input select registers 0, 1 (tis0, tis1) (2/2) ? 78k0r/lg3 address: fff3eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tis0 tis07 tis06 tis05 tis04 tis03 tis02 tis01 tis00 address: fff4eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tis1 0 0 rtcis04 rtcis00 0 0 0 0 ? 78k0r/lh3 address: fff3eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tis0 tis07 tis06 tis05 tis04 tis03 tis02 tis01 tis00 address: fff4eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 tis1 0 0 rtcis04 rtcis00 tis13 tis12 tis11 tis10 ? channels 1 to 3 and 5 to 7 of timer array unit 0 and channels 0 to 3 of timer array unit 1 tispq sdiv selection of timer input used with chann el (pq = 01, 02, 03, 05, 06, 07, 10, 11, 12, 13) 0 input signal of timer input pin (tipq) 0 f sub /2 1 1 f sub /4 ? channels 0 and 4 of timer array unit 0 tispq rtcispq sdiv selection of timer input used with channel (pq = 00, 04) 0 input signal of timer input pin (tipq) 0 f sub /2 0 1 f sub /4 0 rtc interval interrupt (intrtci) 1 1 1 setting prohibited caution when the lin-bus communication function is used, select the input signal of the rxd3 pin by setting isc1 to 1 and tis07 = 0. remarks 1. pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 2. : don?t care 3. f sub : subsystem select clock 4. sdiv: bit 3 of the system clock control register (ckc) 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 278 jun 20, 2011 (9) timer output enable register p (toep) toep is used to enable or disable timer output of each channel. channel q for which timer output has been enabled becomes unable to rewrite the value of the topq bit of the timer output register (top) described later by software, and the va lue reflecting the setting of the timer output function through the count operation is output from the timer output pin (topq). toep can be set by a 16-bit memory manipulation instruction. the lower 8 bits of toep can be set with a 1-bit or 8-bit memory manipulation instruction with toepl. reset signal generation clears this register to 0000h. figure 6-18. format of timer output enable register p (toep) ? 78k0r/lf3 address: f01bah, f01bbh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 toe0 0 0 0 0 0 0 0 0 toe 07 0 0 toe 04 toe 03 toe 02 toe 01 toe 00 ? 78k0r/lg3 address: f01bah, f01bbh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 toe0 0 0 0 0 0 0 0 0 toe 07 toe 06 toe 05 toe 04 toe 03 toe 02 toe 01 toe 00 ? 78k0r/lh3 address: f01bah, f01bbh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 toe0 0 0 0 0 0 0 0 0 toe 07 toe 06 toe 05 toe 04 toe 03 toe 02 toe 01 toe 00 address: f01e2h, f01e3h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 toe1 0 0 0 0 0 0 0 0 0 0 0 0 toe 13 toe 12 toe 11 toe 10 toe pq timer output enable/disable of channel q 0 the topq operation stopped by count operation (timer channel output bit). writing to the topq bit is enabled. the topq pin functions as data output, and it outputs the level set to the topq bit. the output level of the topq pin can be manipulated by software. 1 the topq operation enabled by count oper ation (timer channel output bit). writing to the topq bit is di sabled (writing is ignored). the topq pin functions as timer output, and the toepq is set or reset depending on the timer operation. the topq pin outputs the square-wave or pwm depending on the timer operation. (caution and remark are given on the next page.) 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 279 jun 20, 2011 cautions 1. for 78k0r/lf3, be sure to clear bits 15 to 8, 6 and 5 of toe0 to ?0?. 2. for 78k0r/lg3, be sure to clear bits 15 to 8 of toe0 to ?0?. 3. for 78k0r/lh3, be sure to clear bit 15 to 8 of toe0, bits 15 to 4 of toe1 to ?0?. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 (10) timer output register p (top) top is a buffer register of timer output of each channel. the value of each bit in this register is output from the timer output pin (topq) of each channel. this register can be rewritten by software only when ti mer output is disabled (toepq = 0). when timer output is enabled (toepq = 1), rewriting this register by softwar e is ignored, and the value is changed only by the timer operation. to use the p30/to00, p32/to01, p 12/to02, p31/to03, p13/to 04, p16/to05, p34/to06, p33/to07, p84/to10, p85/to11, p86/to12, or p87/to13 pi n as a port function pin, set the corresponding topq bit to ?0?. top can be set by a 16-bit memory manipulation instruction. the lower 8 bits of top can be set with an 8-bi t memory manipulation instruction with topl. reset signal generation clears this register to 0000h. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 280 jun 20, 2011 figure 6-19. format of timer output register p (top) ? 78k0r/lf3 address: f01b8h, f01b9h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 to0 0 0 0 0 0 0 0 0 to0 7 0 0 to0 4 to0 3 to0 2 to0 1 to0 0 ? 78k0r/lg3 address: f01b8h, f01b9h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 to0 0 0 0 0 0 0 0 0 to0 7 to0 6 to0 5 to0 4 to0 3 to0 2 to0 1 to0 0 ? 78k0r/lh3 address: f01b8h, f01b9h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 to0 0 0 0 0 0 0 0 0 to0 7 to0 6 to0 5 to0 4 to0 3 to0 2 to0 1 to0 0 address: f01e0h, f01e1h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 to1 0 0 0 0 0 0 0 0 0 0 0 0 to1 3 to1 2 to1 1 to1 0 to pq timer output of channel q 0 timer output value is ?0?. 1 timer output value is ?1?. cautions 1. for 78k0r/lf3, be sure to clear bits 15 to 8, 6 and 5 of to0 to ?0?. 2. for 78k0r/lg3, be sure to cl ear bits 15 to 8 of to0 to ?0?. 3. for 78k0r/lh3, be sure to clear bit 15 to 8 of to0, bits 15 to 4 of to1 to ?0?. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 281 jun 20, 2011 (11) timer output level register p (tolp) tolp is a register that controls t he timer output level of each channel. the setting of the inverted output of channel q by this register is reflected at the timing of set or reset of the timer output signal while the timer output is enabled (toepq = 1) in the combination operation mode (tompq = 1). in the toggle mode (tompq = 0), this register setting is invalid. tolp can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tolp can be set with an 8-bi t memory manipulation instruction with tolpl. reset signal generation clears this register to 0000h. figure 6-20. format of timer output level register p (tolp) ? 78k0r/lf3 address: f01bch, f01bdh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tol0 0 0 0 0 0 0 0 0 tol 07 0 0 tol 04 tol 03 tol 02 tol 01 tol 00 ? 78k0r/lg3 address: f01bch, f01bdh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tol0 0 0 0 0 0 0 0 0 tol 07 tol 06 tol 05 tol 04 tol 03 tol 02 tol 01 tol 00 ? 78k0r/lh3 address: f01bch, f01bdh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tol0 0 0 0 0 0 0 0 0 tol 07 tol 06 tol 05 tol 04 tol 03 tol 02 tol 01 tol 00 address: f01e4h, f01e5h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tol1 0 0 0 0 0 0 0 0 0 0 0 0 tol 13 tol 12 tol 11 tol 10 tolpq control of timer output level of channel q 0 positive logic out put (active-high) 1 inverted output (active-low) cautions 1. for 78k0r/lf3, be sure to clear bits 15 to 8, 6 and 5 of tol0 to ?0?. 2. for 78k0r/lg3, be sure to clear bits 15 to 8 of tol0 to ?0?. 3. for 78k0r/lh3, be sure to clear bit 15 to 8 of tol0, bits 15 to 4 of tol1 to ?0?. remarks 1. if the value of this register is rewritten during timer operation, the timer output is inverted when the timer output signal changes next, instead of immedi ately after the register value is rewritten. 2. pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 282 jun 20, 2011 (12) timer output mode register p (tomp) tomp is used to control the timer output mode of each channel. when a channel is used for the combination operation f unction (pwm output, one-shot pulse output, or multiple pwm output), set the corresponding bi t of the slave channel to 1. the setting of each channel q by this register is reflected at the timing when the timer output signal is set or reset while the timer output is enabled (toepq = 1). tomp can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tomp can be set with an 8-bi t memory manipulation instruction with tompl. reset signal generation clears this register to 0000h. figure 6-21. format of timer output mode register p (tomp) ? 78k0r/lf3 address: f01beh, f01bfh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tom0 0 0 0 0 0 0 0 0 tom 07 0 0 tom 04 tom 03 tom 02 tom 01 tom 00 ? 78k0r/lg3 address: f01beh, f01bfh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tom0 0 0 0 0 0 0 0 0 tom 07 tom 06 tom 05 tom 04 tom 03 tom 02 tom 01 tom 00 ? 78k0r/lh3 address: f01beh, f01bfh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tom0 0 0 0 0 0 0 0 0 tom 07 tom 06 tom 05 tom 04 tom 03 tom 02 tom 01 tom 00 address: f01e6h, f01e7h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tom1 0 0 0 0 0 0 0 0 0 0 0 0 tom 13 tom 12 tom 11 tom 10 tom pq control of timer output mode of channel q 0 toggle mode (to produce toggle output by timer interrupt request signal (inttmpq)) 1 combination operation mode (set by the timer interrupt request signal (inittmpq) of the master channel, and reset by the timer interrupt request signal (inittmpr) of the slave channel) cautions 1. for 78k0r/lf3, be sure to clear bits 15 to 8, 6 and 5 of tom0 to ?0?. 2. for 78k0r/lg3, be sure to clear bits 15 to 8 of tom0 to ?0?. 3. for 78k0r/lh3, be sure to clear bit 15 to 8 of tom0, bits 15 to 4 of tom1 to ?0?. (remark is listed on the next page.) 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 283 jun 20, 2011 remark pq: unit number + channel number (only for channels provided with timer i/o pins) <1> 78k0r/lf3: ? p = 0, q = 0 to 4, 7 (q = 0, 2, 4 for master channel) q < r 7 (where r is a consecutive integer greater than q) <2> 78k0r/lg3: ? p = 0, q = 0 to 7 (q = 0, 2, 4, 6 for master channel) q < r 7 (where r is a consecutive integer greater than q) <3> 78k0r/lh3: ? p = 0, q = 0 to 7 (q = 0, 2, 4, 6 for master channel) q < r 7 (where r is a consecutive integer greater than q) ? p = 1, q = 0 to 3 (q = 0, 2 for master channel) q < r 3 (where r is a consecutive integer greater than q) (13) input switch control register (isc) isc is used to implement lin-bus communication operation with channel 7 of timer array unit 0 in association with serial array unit 1. when bit 1 of this register is set to 1, the input signal of the serial data input pin (rxd3) is selected as a timer input signal. isc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 6-22. format of input switch control register (isc) address: fff3ch after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 isc 0 0 0 isc4 isc3 isc2 isc1 isc0 isc1 switching channel 7 input of timer array unit 0 uses the input signal of the ti07 pin as a timer input (normal operation). 1 input signal of r x d3 pin is used as timer input (wakeup signal detection). caution be sure to clear bits 5 to 7 to ?0?. remarks 1. when the lin-bus communication function is used, se lect the input signal of the rxd3 pin by setting isc1 to 1. 2. bits 0 and 2 to 4 of isc are not used with tau0. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 284 jun 20, 2011 (14) noise filter enable regi sters 1, 2 (nfen1, nfen2) nfen1 and nfen2 are used to set whether the noise fi lter can be used for the timer input signal to each channel. enable the noise filter by setting the corresponding bi ts to 1 on the pins in need of noise removal. when the noise filter is on, match detection and syn chronization of the 2 clocks is performed with the cpu/peripheral hardware clock (f clk ). when the noise filter is off, onl y synchronization is performed with the cpu/peripheral hardware clock (f clk ). nfen1, nfen2 can be set by a 1-bit or 8- bit memory manipulation instruction. reset signal generation clears these registers to 00h. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 285 jun 20, 2011 figure 6-23. format of noise filter enable register 1 (nfen1) (1/2) ? 78k0r/lf3 address: f0061h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 nfen1 tnfen07 0 0 tnfen04 tnfen03 tnfen02 tnfen01 tnfen00 ? 78k0r/lg3, 78k0r/lh3 address: f0061h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 nfen1 tnfen07 tnfen06 tnfen05 tnfen04 tnfen03 tnfen02 tnfen01 tnfen00 tnfen07 enable/disable using noise filter of ti07/ to07/p33/intp3 pin or rxd3/p50/segz pin input signal note (78k0r/lf3: z = 30, 78k0r/lg3: z = 39, 78k0r/lh3: z = 53) 0 noise filter off 1 noise filter on tnfen06 enable/disable using noise filter of ti06/to06/p34/intp8 pin input signal 0 noise filter off 1 noise filter on tnfen05 enable/disable using noise filter of ti05/to05/p16/intp10 pin input signal 0 noise filter off 1 noise filter on tnfen04 enable/disable using noise filter of ti04/p53/segz pin input signal (78k0r/lf3: z = 27, 78k0r/lg3: z = 36, 78k0r/lh3: z = 50) 0 noise filter off 1 noise filter on tnfen03 enable/disable using noise filter of ti03/to03/p30/rtc1hz/intp1 pin input signal 0 noise filter off 1 noise filter on tnfen02 enable/disable using noise filter of ti02/p52/segz pin input signal (78k0r/lf3: z = 28, 78k0r/lg3: z = 37, 78k0r/lh3: z = 51) 0 noise filter off 1 noise filter on note the applicable pin can be switched by setting isc1 of the isc register. isc1 = 0: whether or not to use the noise filter of ti07 pin can be selected. isc1 = 1: whether or not to use the noi se filter of rxd3 pin can be selected. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 286 jun 20, 2011 figure 6-23. format of noise filter enable register 1 (nfen1) (2/2) tnfen01 enable/disable using noise filter of ti01/to01/p32/intp5/pclbuz0 pin input signal 0 noise filter off 1 noise filter on tnfen00 enable/disable using noise filter of ti00/ to03/p31/rtcdiv/rtccl/pclbuz1/intp2 pin input signal 0 noise filter off 1 noise filter on figure 6-24. format of noise filt er enable register 2 (nfen2) address: f0061h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 nfen1 0 0 0 0 tnfen13 tnfen12 tnfen11 tnfen10 tnfen13 enable/disable using noise filt er of ti13/to13/p87 pin input signal 0 noise filter off 1 noise filter on tnfen12 enable/disable using noise filt er of ti12/to12/p86 pin input signal 0 noise filter off 1 noise filter on tnfen11 enable/disable using noise filt er of ti11/to11/p85 pin input signal 0 noise filter off 1 noise filter on tnfen10 enable/disable using noise filt er of ti10/to10/p84 pin input signal 0 noise filter off 1 noise filter on 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 287 jun 20, 2011 (15) port mode registers 1, 3, 5, 8 (pm1, pm3, pm5, pm8) these registers set input/output of por ts 1, 3, 5, and 8 in 1-bit units. when using the p30/to00/ti03/rtc1hz/intp1, p 32/to01/ti01/intp5/pclbuz 0, p12/to02/so02/txd2, p31/to03/ti00/rtcdiv/rtccl/pc lbuz1/intp2, p13/to04/so10/ txd1, p16/to05/ti05/intp10, p34/to06/ti06/intp8, p33/to07/ti07/intp3, p 84/to10/ti10, p85/to11/ti 11, p86/to12/ti12, and p87/to13/ti13 pins for timer output, set pm30, pm32, pm12, pm31, pm13, pm16, pm34, pm33, and pm84 to pm87 and the output latches of p30, p32, p12, p 31, p13, p16, p34, p33, and p84 to p87 to 0. when using the p31/ti00/to03/rtcdiv/rtccl/pcl buz1/intp2, p32/ti01/to01/intp5/pclbuz0, p52/ti02/segz (78k0r/lf3: z = 28, 78k0r/lg3: z = 37, 78k0r/lh3: z = 51), p30/ti03/to00/rtc1hz/intp1, p53/ti04/segz (78k0r/lf3: z = 27, 78k0r/lg3: z = 36, 78k0r/lh3: z = 50), p16/ti05/to05/intp10, p34/ti06/to06/intp8, p33/ti07/to07/intp3, p 84/ti10/to10, p85/ti11/to 11, p86/ti12/to12, and p87/ti13/to13 pins for timer input, set pm31, pm32, pm52, pm30, pm53, pm16, pm34 pm33, and pm84 to pm87 to 1. at this time, the output latches of p31, p32, p52, p30, p53, p16, p34, p33, and p84 to p87 may be 0 or 1. pm1, pm3, pm5, and pm8 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation se ts these registers to ffh. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 288 jun 20, 2011 figure 6-25. format of port mode registers 1, 3, 5, 8 (pm1, pm3, pm5, pm8) ? 78k0r/lf3 address: fff21h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm1 1 1 pm15 pm14 pm13 pm12 pm11 pm10 address: fff23h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm3 1 1 1 1 pm33 pm32 pm31 pm30 address: fff25h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 ? 78k0r/lg3 address: fff21h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm1 1 pm16 pm15 pm14 pm13 pm12 pm11 pm10 address: fff23h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm3 1 1 1 pm34 pm33 pm32 pm31 pm30 address: fff25h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 ? 78k0r/lh3 address: fff21h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm1 pm17 pm16 pm15 pm14 pm13 pm12 pm11 pm10 address: fff23h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm3 1 1 1 pm34 pm33 pm32 pm31 pm30 address: fff25h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 address: fff28h after reset: feh r/w symbol 7 6 5 4 3 2 1 0 pm8 pm87 pm86 pm85 pm84 pm83 pm82 pm81 pm80 pmmn pmn pin i/o mode selection (m = 1, 3, 5, 8; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 289 jun 20, 2011 6.4 channel output (topq pin) control 6.4.1 topq pin output circuit configuration figure 6-26. output circuit configuration interrupt signal of the master channel (inttmpq) tolpq tompq toepq <1> <2> <3> <4> <5> topq write signal topq pin top register set reset/toggle internal bus interrupt signal of the slave channel (inttmpr) controller the following describes the topq pin output circuit. <1> when tompq = 0 (toggle mode), the set value of t he tolp register is ignored and only inttmpr (slave channel timer interrupt) is transmitted to the top register. <2> when tompq = 1 (combination operation mode) , both inttmpq (master channel timer interrupt) and inttmpr (slave channel timer interrupt) are transmitted to the top register. at this time, the tolp register becomes valid and the signals are controlled as follows: when tolpq = 0: forward operation (inttmpq set, inttmpr reset) when tolpq = 1: reverse operation (inttmpq reset, inttmpr set) when inttmpq and inttmpr are simultaneously generat ed, (0% output of pwm), inttmpr (reset signal) takes priority, and inttmpq (set signal) is masked. <3> when toepq = 1, inttmpq (master channel timer in terrupt) and inttmpr (slave channel timer interrupt) are transmitted to the topq register. writing to the top register (topq write signal) becomes invalid. when toepq = 1, the topq pin output never chang es with signals other than interrupt signals. to initialize the topq pin output level, it is nece ssary to set toepq = 0 and to write a value to topq. <4> when toepq = 0, writing to topq bit to the target channel (topq signal) becomes valid. when toepq = 0, neither inttmpq (master channel timer interrupt) nor in ttmpr (slave channel timer interrupt) is transmitted to topq register. <5> the top register can always be read, a nd the topq pin output level can be checked. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 290 jun 20, 2011 remark pq: unit number + channel number (only for channels provided with timer i/o pins) <1> 78k0r/lf3: ? p = 0, q = 0 to 4, 7 (q = 0, 2, 4 for master channel) q < r 7 (where r is a consecutive integer greater than q) <2> 78k0r/lg3: ? p = 0, q = 0 to 7 (q = 0, 2, 4, 6 for master channel) q < r 7 (where r is a consecutive integer greater than q) <3> 78k0r/lh3: ? p = 0, q = 0 to 7 (q = 0, 2, 4, 6 for master channel) q < r 7 (where r is a consecutive integer greater than q) ? p = 1, q = 0 to 3 (q = 0, 2 for master channel) q < r 3 (where r is a consecutive integer greater than q) 6.4.2 topq pin output setting the following figure shows the procedure and status transition of topq out put pin from initial setting to timer operation start. figure 6-27. status transition from ti mer output setting to operation start tcrpq timer alternate-function pin timer output signal toepq topq (counter) undefined value (ffffh after reset) write operation enabled period to topq <1> set the tompq set the tolpq <4> set the port to output mode <2> set the topq <3> set the toepq <5> timer operation start write operation disabled period to topq hi-z <1> the operation mode of timer output is set. ? tompq bit (0: toggle mode, 1: combination operation mode) ? tolpq bit (0: forward output, 1: reverse output) <2> the timer output signal is set to the initial status by setting topq. <3> the timer output operation is enabled by wr iting 1 to toepq (writing to topq is disabled). <4> the port i/o setting is set to output (see 6.3 (15) port mode registers 1, 3, 5, 8 ). <5> the timer operation is enabled (tspq = 1). remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 291 jun 20, 2011 6.4.3 cautions on channel output operation (1) changing values set in registers top, toep,tolp, and tomp during timer operation since the timer operations (operations of tcrpq and td rpq) are independent of the topq output circuit and changing the values set in top, toep, tolp, and tomp does not affect the timer oper ation, the values can be changed during timer operation. to output an expected wave form from the topq pin by timer operation, however, set top, toep, tolp, and tomp to the values stated in the register setting example of each operation. when the values set in toep, tolp, and tomp (except for top) are changed close to the timer interrupt (inttmpq), the waveform output to the topq pin may be different depending on whether the values are changed immediately before or immediately after the time r interrupt (inttmpq) signal generation timing. (2) default level of topq pin and ou tput level after timer operation start the following figure shows the topq pin output level transi tion when writing has been done in the state of toepq = 0 before port output is enabled and toepq = 1 is set after changing the default level. (a) when operation starts with tompq = 0 setting (toggle output) the setting of tolpq is invalid when tompq = 0. when t he timer operation starts after setting the default level, the toggle signal is generated and the ou tput level of topq pin is reversed. figure 6-28. topq pin output status at toggle output (tompq = 0) toepq topq = 0, tolpq = 0 topq = 1, tolpq = 0 topq = 0, tolpq = 1 (same output waveform as tolpq = 0) topq = 1, tolpq = 1 (same output waveform as tolpq = 0) default level, tolpq setting independent of tolpq setting port output is enabled topq pin transition toggle toggle toggle toggle toggle hi-z hi-z hi-z hi-z dependent on topq setting remarks 1. toggle: reverse topq pin output status 2. pq: unit number + channel number (onl y for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 292 jun 20, 2011 (b) when operation starts with tompq = 1 setti ng (combination operati on mode (pwm output)) when tompq = 1, the active level is determined by tolpq setting. figure 6-29. topq pin output status at pwm output (tompq = 1) toepq topq = 0, tolpq = 0 (active high) topq = 1, tolpq = 0 (active high) topq = 0, tolpq = 1 (active low) topq = 1, tolpq = 1 (active low) default level, tolpq setting dependent on tolpq setting dependent on topq setting no change set reset set reset set hi-z hi-z hi-z hi-z topq pin transition port output is enabled (3) operation of topq pin in combination operation mode (tompq = 1) (a) when tolpq setting has been changed during timer operation when the tolpq setting has been changed during timer oper ation, the setting becomes valid at the generation timing of topq change condition. rewriting tolpq does not change the output level of topq. the following figure shows the operation when the valu e of tolpq has been changed during timer operation (tompq = 1). figure 6-30. operation when tolpq h as been changed during timer operation internal set signal internal reset signal tolpq topq pin set/reset signals are inverted topq does not change remarks 1. set: the output signal of topq pin changes from inactive level to active level. reset: the output signal of topq pin changes from active level to inactive level. 2. pq: unit number + channel number (onl y for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 293 jun 20, 2011 (b) set/reset timing to realize 0%/100% output at pwm output, the topq pin/ topq set timing at master channel timer interrupt (inttmpq) generation is delayed by 1 count clock by the slave channel timer interrupt (inttmqr). if the set condition and reset condition are generated at the same time, a higher priority is given to the latter. figure 6-31 shows the set/reset operat ing statuses where the master/sla ve channels are set as follows. ? master channel: toepq = 1, tompq = 0, tolpq = 0 ? slave channel: toepr = 1, tompr = 1, tolpr = 0 figure 6-31. set/reset ti ming operat ing statuses to_reset (internal signal) to_reset (internal signal) (internal signal) inttmpq topq pin/ topq topr pin/ topr count clock f clk inttmpr to_set delays to_reset by 1 count clock with slave channel toggle set reset master channel slave channel remarks 1. to_reset: topq pin reset/toggle signal to_set: topq pin set signal 2. pq: unit number + channel number (onl y for channels provided with timer i/o pins) <1> 78k0r/lf3: ? p = 0, q = 0 to 4, 7 (q = 0, 2, 4 for master channel) q < r 7 (where r is a consecutive integer greater than q) <2> 78k0r/lg3: ? p = 0, q = 0 to 7 (q = 0, 2, 4, 6 for master channel) q < r 7 (where r is a consecutive integer greater than q) <3> 78k0r/lh3: ? p = 0, q = 0 to 7 (q = 0, 2, 4, 6 for master channel) q < r 7 (where r is a consecutive integer greater than q) ? p = 1, q = 0 to 3 (q = 0, 2 for master channel) q < r 3 (where r is a consecutive integer greater than q) 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 294 jun 20, 2011 6.4.4 collective manipulation of topq bits in the top register, the setting bits for all the channels are lo cated in one register in the same way as the tsp register (channel start trigger). therefor e, topq of all the channels can be manipulated collectively. only specific bits can also be manipulated by setting the corresponding toe pq = 0 to a target topq (channel output). figure 6-32. example of to0q bits collective manipulation before writing to0 0 0 0 0 0 0 0 0 to07 0 to06 0 to05 1 to04 0 to03 0 to02 0 to01 1 to00 0 toe0 0 0 0 0 0 0 0 0 toe07 0 toe06 0 toe05 1 toe04 0 toe03 1 toe02 1 toe01 1 toe00 1 data to be written 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 after writing to0 0 0 0 0 0 0 0 0 to07 1 to06 1 to05 1 to04 0 to03 0 to02 0 to01 1 to00 0 writing is done only to topq bits with toepq = 0, and writing to topq bits with toepq = 1 is ignored. topq (channel output) to which toepq = 1 is set is not affected by the write operat ion. even if the write operation is done to topq, it is ignored and the output change by timer operation is normally done. figure 6-33. topq pin statuses by co llective manipulation of topq bits to07 to06 to05 to04 to03 to02 to01 to00 two or more topq output can be changed simultaneously output does not change when value does not change before writing writing to top bit is ignored when toepq = 1 writing to top register (caution and remark are given on the next page.) o o o 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 295 jun 20, 2011 caution when toepq = 1, even if the output by ti mer interrupt of each timer (inttmpq) contends with writing to topq, output is normally done to topq pin. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 6.4.5 timer interrupt and topq pin output at operation start in the interval timer mode or capture mode, the mdmn0 bit in the tmrmn register sets whether or not to generate a timer interrupt at count start. when mdmn0 is set to 1, the count operation start timing ca n be known by the timer interrupt (inttmmn) generation. in the other modes, neither timer interrupt at c ount operation start nor to pq output is controlled. figures 6-34 and 6-35 show operation examples when the interval timer mode (toemn = 1, tommn = 0) is set. figure 6-34. when mdmn0 is set to 1 tcrmn temn topq inttmmn count operation start when mdmn0 is set to 1, a timer interrupt (inttmmn) is output at count operation st art, and topq performs a toggle operation. figure 6-35. when mdmn0 is set to 0 tcrmn temn topq inttmmn count operation start when mdmn0 is set to 0, a timer interrupt (inttmmn) is not output at count operatio n start, and topq does not change either. after counting one cycle, inttmmn is output and topq performs a toggle operation. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 296 jun 20, 2011 6.5 channel input control 6.5.1 edge detection circuit (1) edge detection basic operation timing edge detection circuit sampling is done in accordance with the operation clock (mck). figure 6-36. edge detect ion basic operation timing synchronized (noise filter) internal tipq signal f clk rising edge detection internal trigger falling edge detection internal trigger operation clock (mck) remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 297 jun 20, 2011 6.6 basic function of timer array unit 6.6.1 overview of single-operation f unction and combination operation function the timer array unit consists of several channels and has a single-operation function t hat allows each channel to operate independently, and a combination operation function that uses two or more channels in combination. the single-operation function can be used for any channel, regardless of the operation mode of the other channels. the combination operation function is realized by combin ing a master channel (referenc e timer that mainly counts periods) and a slave channel (timer that operates in acco rdance with the master channel), and several rules must be observed when using this function. 6.6.2 basic rules of comb ination operation function the basic rules of using the combinat ion operation function are as follows. (1) only an even channel (channel 0, 2, 4, etc.) can be set as a master channel. (2) any channel, except channel 0, can be set as a slave channel. (3) the slave channel must be lower than the master channel. example: if channel 2 of tau0 is set as a master channel, channel 3 or those that follo w (channels 3, 4, etc. 5) can be set as a slave channel. if channel 2 of tau1 is set as a master channel , channel 3 (because tau1 is provided only with channels up to channel 3) can be set as a slave channel. (4) two or more slave channels can be set for one master channel. (5) when two or more master channels are to be used, sl ave channels with a master c hannel between them may not be set. example: if channels 0 and 4 of tau0 are set as master channels, channels 1 to 3 can be set as the slave channels of master channel 0. channels 5 to 7 cann ot be set as the slave channels of master channel 0. (6) the operating clock for a slave channel in combinatio n with a master channel must be the same as that of the master channel. the cks bit (bit 15 of the tmrmn register) of the slave channel that operates in combination with the master channel must be the same va lue as that of t he master channel. (7) a master channel can transmit inttmmn (interrupt), st art software trigger, and count clock to the lower channels. (8) a slave channel can use the inttmmn (interrupt), start software trigger, and count clock of the master channel, but it cannot transmit its own inttmmn (interrupt), start so ftware trigger, and count clock to the lower channel. (9) a master channel cannot use the inttmmn (interrupt), start software tri gger, and count clock from the higher master channel. (10) to simultaneously start channels that operate in combi nation, the tsmn bit of the ch annels in combination must be set at the same time. (11) during a counting operation, the ts mn bit of all channels that operate in combination or only the master channel can be set. tsmn of only a slave channel cannot be set. (12) to stop the channels in combination simultaneously, the ttmn bit of the channels in combination must be set at the same time. remark mn: unit number + channel number mn = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 298 jun 20, 2011 channel 1: slave channel 0: master channel group 1 (combination operation function) * the operating clock of channel group 1 may be different from that of channel group 2. channel 2: slave channel 3: single-operation function channel 4: master channel 5: slave channel 6: single-operation function channel 7: single-operation function ck00 ck01 tau0 * a channel that singly operates may be between channel group 1 and channel group 2. channel group 2 (combination operation function) 6.6.3 applicable range of basic ru les of combination operation function the rules of the combination operation function are applied in a channel group (a master channel and slave channels forming one combination operation function). if two or more channel groups that do not operate in combi nation are specified, the basic rules of the combination operation function in 6.6.2 basic rules of comb ination operation function do not apply to the channel groups. example 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 299 jun 20, 2011 6.7 operation of timer array unit as independent channel 6.7.1 operation as interval timer/square wave output (1) interval timer the timer array unit can be used as a reference timer that generates inttmmn (timer interrupt) at fixed intervals. the interrupt generation period can be calculated by the following expression. generation period of inttmmn (timer interrupt) = period of count clock (set value of tdrmn + 1) (2) operation as square wave output topq performs a toggle operation as soon as inttmpq has been generated, and outp uts a square wave with a duty factor of 50%. the period and frequency for outputting a square wave from topq can be calculated by the following expressions. ? period of square wave output from topq = period of count clock (set value of tdrpq + 1) 2 ? frequency of square wave output from topq = fr equency of count clock/{(set value of tdrpq + 1) 2} the valid edge of tipq pin input signal, the valid edge of f sub /2, the valid edge of f sub/ 4, or the valid edge of intrtc1 can be selected as the count clock, in addition to ckm0 and ckm1. consequently, the interval timer can be operated, regardless of the f clk frequency (main system clock, subsystem clock). when changing the clock selected as f clk (changing the value of the system cl ock control register (ckc)), stop the timer array units 0 and 1 (taus0, taus1) (tt0 = 00ffh, tt1 = 000fh) first. only in the case of sdiv=0, ccsmn=1 and tismn=1, contin uously use of taum is allowed, even when changing cpu clock. however, the following limitation is existing. ? when changing cpu clock, source clock decrease/increase occurs as follows. main clock subsystem clock (css = 0 1): ? 1 clock subsystem clock main clock (css = 1 0): +1 clock tcrmn operates as a down counter in the interval timer mode. tcrmn loads the value of tdrmn at the fi rst count clock after the channel start trigger bit (tsmn) is set to 1. if mdmn0 of tmrmn = 0 at this time, inttmmn is not output and topq is not toggled. if mdmn0 of tmrmn = 1, inttmmn is output and topq is toggled. after that, tcrmn count down in syn chronization with the count clock. when tcrmn = 0000h, inttmmn is output and topq is toggled at the next count clock. at the same time, tcrmn loads the value of tdrmn again. a fter that, the same operation is repeated. tdrmn can be rewritten at any time. the new valu e of tdrmn becomes valid from the next period. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 300 jun 20, 2011 figure 6-37. block diagram of operation as interval timer/square wave output timer counter (tcrmn) topq pin interrupt signal (inttmmn) data register (tdrmn) interrupt controller output controller clock selection trigger selection operation clock ckm0 ckm1 tsmn clock selection edge selection timer input selection tipq pin input f sub /2 f sub /4 intrtci note note channels 0 and 4 of timer array unit 0 only remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 figure 6-38. example of basic timing of operati on as interval timer/square wave output (mdmn0 = 1) tsmn temn tdrmn tcrmn topq inttmmn a a+1 b 0000h a+1 a+1 b+1 b+1 b+1 remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 301 jun 20, 2011 figure 6-39. example of set contents of registers during operation as interval time r/square wave output (1/3) (1) when ckm0 or ckm1 is selected as count clock (a) timer mode register mn (tmrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cksmn 1/0 0 0 ccsmn 0 mas termn 0 stsmn2 0 stsmn1 0 stsmn0 0 cismn1 0 cismn0 0 0 0 mdmn3 0 mdmn2 0 mdmn1 0 mdmn0 1/0 operation mode of channel n 000b: interval timer setting of operation when counting is started 0: neither generates inttmmn nor inverts timer output when counting is started. 1: generates inttmmn and inverts timer output when counting is started. selection of edge of timer input 00b: sets 00b because these are not used. start trigger selection 000b: selects only software start. slave/master selection 0: cleared to 0 when independent function is selected. count clock selection 0: selects operation clock. operation clock selection 0: selects ckm0 as operation clock of channel n. 1: selects ckm1 as operation clock of channel n. (b) timer output register p (top) bit q top topq 1/0 0: outputs 0 from topq. 1: outputs 1 from topq. (c) timer output enable register p (toep) bit q toep toepq 1/0 0: stops the topq output operation by counting operation. 1: enables the topq output operation by counting operation. (d) timer output level register p (tolp) bit q tolp tolpq 0 0: cleared to 0 when tompq = 0 (toggle mode) (e) timer output mode register p (tomp) bit q tomp tompq 0 0: sets toggle mode. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 302 jun 20, 2011 figure 6-39. example of set contents of registers during operation as interval time r/square wave output (2/3) (2) when the timer input (tipq pin input, f sub /4, f sub /2 or intrtci) is selected as count clock note (1/2) note the timer input is selected by using tispq bit, sdiv bit, and rtcispq bit. for details, refer to figure 6-17 format of timer input select re gisters 0, 1 (tis0, tis1). (a) timer mode register mn (tmrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cksmn 1/0 0 0 ccsmn 1 mas termn 0 stsmn2 0 stsmn1 0 stsmn0 0 cismn1 1/0 cismn0 1/0 0 0 mdmn3 0 mdmn2 0 mdmn1 0 mdmn0 1/0 operation mode of channel n 000b: interval timer setting of operation when counting is started 0: neither generates inttmmn nor inverts timer output when counting is started. 1: generates inttmmn and inverts timer output when counting is started. selection of edge of timer input 00b: detects falling edge. 01b: detects rising edge. 10b: detects both edges. 11b: setting prohibited start trigger selection 000b: selects only software start. slave/master selection 0: cleared to 0 when independent function is selected. count clock selection 1: selects timer input valid edge. operation clock selection 0: selects ckm0 as operation clock of channel n. 1: selects ckm1 as operation clock of channel n. f clk (no division) is selected as select ed operation clock by tpsm register. (b) timer clock select register m (tpsm) bits 7 to 4, 3 to 0 tpsm prsmk3 to prsmk0 0000 0000b: selects f clk (no division) as operation clock se lected by cksmn of tmrmn register. k = 0 (bits 0 to 3) when ckm0 is selected and k = 1 (bits 4 to 7) when ckm1 is selected (c) timer output register p (top) bit q top topq 1/0 0: outputs 0 from topq. 1: outputs 1 from topq. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 303 jun 20, 2011 figure 6-39. example of set contents of registers during operation as interval time r/square wave output (3/3) (2) when the timer input (tipq pin input, f sub /4, f sub /2 or intrtci) is selec ted as count clock (2/2) (e) timer output enable register p (toep) bit q toep toepq 1/0 0: stops the topq output operation by counting operation. 1: enables the topq output operation by counting operation. (f) timer output level register p (tolp) bit q tolp tolpq 0 0: cleared to 0 when tompq = 0 (toggle mode) (g) timer output mode register p (tomp) bit q tomp tompq 0 0: sets toggle mode. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 304 jun 20, 2011 figure 6-40. operation procedure of interv al timer/square wave output function (1/2) software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsm register. determines clock frequencies of ckm0 and ckm1. sets the tmrmn register (determines operation mode of channel). if timer input is selected for the count clock, set the timer input (tipq pin input, f sub /4, f sub /2, or intrtci) by using the tispq, sdiv, and rtcispq bits. sets interval (period) value to the tdrmn register. channel stops operating. (clock is supplied and some power is consumed.) channel default setting to use the topq output clears the tompq bit of the tomm register to 0 (toggle mode). clears the tolpq bit to 0. sets the topq bit and determines default level of the topq output. sets toepq to 1 and enables operation of topq. clears the port register and port mode register to 0. the tomn pin goes into hi-z output state. the topq default setting level is output when the port mode register is in the output mode and the port register is 0. topq does not change because channel stops operating. the topq pin outputs the topq set level. operation start sets toepq to 1 (only when operation is resumed). sets the tsmn bit to 1. the tsmn bit automatically returns to 0 because it is a trigger bit. temn = 1, and count operation starts. value of tdrmn is loaded to tcrmn at the count clock input. inttmmn is generated and topq performs toggle operation if the mdmn0 bit of the tmrmn register is 1. during operation set values of tmrmn, tomp, and tolp registers cannot be changed. set value of the tdrmn register can be changed. the tcrmn register can always be read. the tsrmn register is not used. set values of the top and toep registers can be changed. counter (tcrmn) counts down. when count value reaches 0000h, the value of tdrmn is loaded to tcrmn again and the count operation is continued. by detecting tcrmn = 0000h, inttmmn is generated and tomn performs toggle operation. after that, the above operation is repeated. the ttmn bit is set to 1. the ttmn bit automatically returns to 0 because it is a trigger bit. temn = 0, and count operation stops. tcrmn holds count value and stops. the topq output is not initialized but holds current status. operation stop toepq is cleared to 0 and value is set to top register. the topq pin outputs the topq set level. remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: m = 0, 1, mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 operation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 305 jun 20, 2011 figure 6-40. operation procedure of interv al timer/square wave output function (2/2) software operation hardware status tau stop to hold the topq pin output level clears topq bit to 0 after the value to be held is set to the port register. when holding the topq pin output level is not necessary switches the port mode register to input mode. the topq pin output level is held by port function. the topq pin output level goes into hi-z output state. the tau0en or tau1en bits of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the topq bit is cleared to 0 and the topq pin is set to port mode.) remark mn: unit number + channel number, pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: mn = 00 to 07, 10 to 13, pq = 00 to 04, 07 78k0r/lg3: mn = 00 to 07, 10 to 13, pq = 00 to 07 78k0r/lh3: mn = 00 to 07, 10 to 13, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 306 jun 20, 2011 6.7.2 operation as external event counter the timer array unit can be used as an external event count er that counts the number of times the valid input edge (external event) is detected in the tipq pin. when a specified count value is r eached, the event counter generates an interrupt. the specified number of counts ca n be calculated by the following expression. specified number of counts = set value of tdrpq + 1 tcrpq operates as a down counter in the event counter mode. when the channel start trigger bit (tspq) is set to 1, tcrpq loads the value of tdrpq. tcrpq counts down each time the valid input edge of the tipq pin has been detected. when tcrpq = 0000h, tcrpq loads the value of tdrpq again, and outputs inttmpq. after that, the above operation is repeated. topq must not be used because its waveform depends on the external event and irregular. tdrpq can be rewritten at any time. the new value of tdrpq becomes valid during the next count period. figure 6-41. block diagram of oper ation as external event counter timer counter (tcrpq) edge detection interrupt signal (inttmpq) tipq pin data register (tdrpq) interrupt controller clock selection trigger selection tspq remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 307 jun 20, 2011 figure 6-42. example of basic timing of operation as external event counter tspq tepq tipq tdrpq tcrpq 0003h 0002h 0 0000h 1 3 0 1 2 0 1 2 1 2 3 2 inttmpq 4 events 4 events 3 events remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 308 jun 20, 2011 figure 6-43. example of set contents of registers in external event counter mode (a) timer mode register pq (tmrpq) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrpq ckspq 1/0 0 0 ccspq 1 mas terpq 0 stspq2 0 stspq1 0 stspq0 0 cispq1 1/0 cispq0 1/0 0 0 mdpq3 0 mdpq2 1 mdpq1 1 mdpq0 0 operation mode of channel q 011b: event count mode setting of operation when counting is started 0: neither generates inttmpq nor inverts timer output when counting is started. selection of tipq pin input edge 00b: detects falling edge. 01b: detects rising edge. 10b: detects both edges. 11b: setting prohibited start trigger selection 000b: selects only software start. slave/master selection 0: cleared to 0 when independent function is selected. count clock selection 1: selects the tipq pin input valid edge. operation clock selection 0: selects ckp0 as operation clock of channel q. 1: selects ckp1 as operation clock of channel q. (b) timer output register p (top) bit q top topq 0 0: outputs 0 from topq. (c) timer output enable register p (toep) bit q toep toepq 0 0: stops the topq output operation by counting operation. (d) timer output level register p (tolp) bit q tolp tolpq 0 0: cleared to 0 when tompq = 0 (toggle mode). (e) timer output mode register p (tomp) bit q tomp tompq 0 0: sets toggle mode. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 309 jun 20, 2011 figure 6-44. operation procedure when ex ternal event counter function is used software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsp register. determines clock frequencies of ckp0 and ckp1. channel default setting sets the tmrpq register (determines operation mode of channel). sets number of counts to the tdrpq register. clears the toepq bit of the toep register to 0. channel stops operating. (clock is supplied and some power is consumed.) operation start sets the tspq bit to 1. the tspq bit automatically returns to 0 because it is a trigger bit. tepq = 1, and count operation starts. value of tdrpq is loaded to tcrpq and detection of the tipq pin input edge is awaited. during operation set value of the tdrpq register can be changed. the tcrpq register can always be read. the tsrpq register is not used. set values of tmrpq, tomp, tolp, top, and toep registers cannot be changed. counter (tcrpq) counts down each time input edge of the tipq pin has been detected. when count value reaches 0000h, the value of tdrpq is loaded to tcrpq again, and the count operation is continued. by detecting tcrpq = 0000h, the inttmpq output is generated. after that, the above operation is repeated. operation stop the ttpq bit is set to 1. the ttpq bit automatically returns to 0 because it is a trigger bit. tepq = 0, and count operation stops. tcrpq holds count value and stops. tau stop the tau0en or tau1en bits of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 operation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 310 jun 20, 2011 6.7.3 operation as frequency divider the timer array unit can be used as a frequency divider that di vides a clock input to the tipq pin and outputs the result from topq. the divided clock frequency output from topq c an be calculated by the following expression. ? when rising edge/falling edge is selected: divided clock frequency = input clock frequency/{(set value of tdrpq + 1) 2} ? when both edges are selected: divided clock frequency ? input clock frequency/(set value of tdrpq + 1) tcrpq operates as a down counter in the interval timer mode. after the channel start trigger bit (tspq) is set to 1, tc rpq loads the value of tdrpq when the tipq valid edge is detected. if mdpq0 of tmrpq = 0 at this time, inttmpq is not output and topq is not toggled. if mdpq0 of tmrpq = 1, inttmpq is output and topq is toggled. after that, tcrpq counts down at the valid edge of tipq. when tcrpq = 0000h, it toggles topq. at the same time, tcrpq loads the value of tdrpq again, and continues counting. if detection of both the edges of tipq is selected, the duty fact or error of the input clock affects the divided clock period of the topq output. the period of the topq output clock includes a samp ling error of one period of the operation clock. clock period of topq output = ideal topq output clock period operation clock period (error) tdrpq can be rewritten at any time. the new value of tdrpq becomes valid during the next count period. figure 6-45. block diagram of operation as frequency divider timer counter (tcrpq) edge detection tipq pin data register (tdrpq) clock selection trigger selection tspq topq pin output controller remark pq: unit number + channel number (only for channels provided with timer i/o pins) pq = 00, 02 to 04 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 311 jun 20, 2011 figure 6-46. example of basic timing of operation as frequency divider (mdpq0 = 1) tspq tepq tipq tdrpq tcrpq topq inttmpq 0002h divided by 6 0001h 0 0000h 1 2 0 1 2 0 1 0 1 0 1 0 1 0 1 2 divided by 4 remark pq: unit number + channel number (only for channels provided with timer i/o pins) pq = 00, 02 to 04 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 312 jun 20, 2011 figure 6-47. example of set contents of registers when frequency divider is used (a) timer mode register pq (tmrpq) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrpq ckspq 1/0 0 0 ccspq 1 mas terpq 0 stspq2 0 stspq1 0 stspq0 0 cispq1 1/0 cispq0 1/0 0 0 mdpq3 0 mdpq2 0 mdpq1 0 mdpq0 1/0 operation mode of channel q 000b: interval timer setting of operation when counting is started 0: neither generates inttmpq nor inverts timer output when counting is started. 1: generates inttmpq and inverts timer output when counting is started. selection of tipq pin input edge 00b: detects falling edge. 01b: detects rising edge. 10b: detects both edges. 11b: setting prohibited start trigger selection 000b: selects only software start. slave/master selection 0: cleared to 0 when independent function is selected. count clock selection 1: selects the tipq pin input valid edge. operation clock selection 0: selects ckp0 as operation clock of channel q. 1: selects ckp1 as operation clock of channel q. (b) timer output register p (top) bit q top topq 1/0 0: outputs 0 from topq. 1: outputs 1 from topq. (c) timer output enable register p (toep) bit q toep toepq 1/0 0: stops the topq output operation by counting operation. 1: enables the topq output operation by counting operation. (d) timer output level register p (tolp) bit q tolp tolpq 0 0: cleared to 0 when tompq = 0 (toggle mode) (e) timer output mode register p (tomp) bit q tomp tompq 0 0: sets toggle mode. remark pq: unit number + channel number (only for channels provided with timer i/o pins) pq = 00, 02 to 04 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 313 jun 20, 2011 figure 6-48. operation procedure when fr equency divider function is used (1/2) software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsp register. determines clock frequencies of ckp0 and ckp1. sets the tmrpq register (determines operation mode of channel). sets interval (period) value to the tdrpq register. channel stops operating. (clock is supplied and some power is consumed.) channel default setting clears the tompq bit of the tomp register to 0 (toggle mode). clears the tolpq bit to 0. sets the topq bit and determines default level of the topq output. sets toepq to 1 and enables operation of topq. clears the port register and port mode register to 0. the topq pin goes into hi-z output state. the topq default setting level is output when the port mode register is in output mode and the port register is 0. topq does not change because channel stops operating. the topq pin outputs the topq set level. operation start sets the toepq to 1 (only when operation is resumed). sets the tspq bit to 1. the tspq bit automatically returns to 0 because it is a trigger bit. tepq = 1, and count operation starts. value of tdrpq is loaded to tcrpq at the count clock input. inttmpq is generated and topq performs toggle operation if the mdpq0 bit of the tmrpq register is 1. during operation set value of the tdrpq register can be changed. the tcrpq register can always be read. the tsrpq register is not used. set values of top and toep registers can be changed. set values of tmrpq, tomp, and tolp registers cannot be changed. counter (tcrpq) counts down. when count value reaches 0000h, the value of tdrpq is loaded to tcrpq again, and the count operation is continued. by detecting tcrpq = 0000h, inttmpq is generated and topq performs toggle operation. after that, the above operation is repeated. the ttpq bit is set to 1. the ttpq bit automatically returns to 0 because it is a trigger bit. tepq = 0, and count operation stops. tcrpq holds count value and stops. the topq output is not initialized but holds current status. operation stop toepq is cleared to 0 and value is set to the top register. the topq pin outputs the topq set level. remark pq: unit number + channel number (only for channels provided with timer i/o pins) pq = 00, 02 to 04 operation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 314 jun 20, 2011 figure 6-48. operation procedure when fr equency divider function is used (2/2) software operation hardware status to hold the topq pin output level clears topq bit to 0 after the value to be held is set to the port register. when holding the topq pin output level is not necessary switches the port mode register to input mode. the topq pin output level is held by port function. the topq pin output level goes into hi-z output state. tau stop the tau0en or tau1en bits of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the topq bit is cleared to 0 and the topq pin is set to port mode). remark pq: unit number + channel number (only for channels provided with timer i/o pins) pq = 00, 02 to 04 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 315 jun 20, 2011 6.7.4 operation as input pu lse interval measurement the count value can be captured at the ti pq valid edge and the interval of t he pulse input to tipq can be measured. the pulse interval can be calculated by the following expression. tipq input pulse interval = period of count clock ((10000h tsrpq: ovf) + (capture value of tdrpq + 1)) caution the tipq pin input is sampled using th e operating clock selected with the ckspq bit of the tmrpq register, so an erro r equal to the number of operating clocks occurs. tcrpq operates as an up counter in the capture mode. when the channel start trigger (tspq) is set to 1, tcrpq co unts up from 0000h in synchronization with the count clock. when the tipq pin input valid edge is detec ted, the count value is transferred (c aptured) to tdrpq and, at the same time, the counter (tcrpq) is cleared to 0000h, and the inttm pq is output. if the counter overflows at this time, the ovfpq bit of the tsrpq register is set to 1. if the counter does not overflow, t he ovfpq bit is cleared. after that, the above operation is repeated. as soon as the count value has been captured to the tdrpq register, the ovfpq bit of the tsrpq register is updated depending on whether the counter overflow s during the measurement period. ther efore, the overflow status of the captured value can be checked. if the counter reaches a full count for two or more periods, it is judged to be an overflow occurrence, and the ovfpq bit of the tsrpq register is set to 1. howe ver, the ovfpq bit is configured as a cumulative flag, the correct interval value cannot be measured if an overflow occurs more than once. set stspq2 to stspq0 of the tmrpq register to 001b to us e the valid edges of tipq as a start trigger and a capture trigger. when tepq = 1, instead of the tipq pin input, a software operation (tspq = 1) can be used as a capture trigger. figure 6-49. block diagram of operatio n as input pulse interval measurement timer counter (tcrpq) interrupt signal (inttmpq) data register (tdrpq) interrupt controller clock selection trigger selection operation clock ckp0 ckp1 edge detection tipq pin tspq remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 316 jun 20, 2011 figure 6-50. example of basic timing of operati on as input pulse interval measurement (mdpq0 = 0) tspq tepq tipq tdrpq tcrpq 0000h c b 0000h a c d inttmpq ffffh b a d ovfpq remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 317 jun 20, 2011 figure 6-51. example of set contents of registers to measure input pulse interval (a) timer mode register pq (tmrpq) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrpq ckspq 1/0 0 0 ccspq 0 mas terpq 0 stspq2 0 stspq1 0 stspq0 1 cispq1 1/0 cispq0 1/0 0 0 mdpq3 0 mdpq2 1 mdpq1 0 mdpq0 1/0 operation mode of channel q 010b: ca p ture mode setting of operation when counting is started 0: does not generate inttmpq when counting is started. 1: generates inttmpq when counting is started. selection of tipq pin input edge 00b: detects falling edge. 01b: detects rising edge. 10b: detects both edges. 11b: setting prohibited capture trigger selection 001b: selects the tipq pin input valid edge. slave/master selection 0: cleared to 0 when independent function is selected. count clock selection 0: selects operation clock. operation clock selection 0: selects ckp0 as operation clock of channel q. 1: selects ckp1 as operation clock of channel q. (b) timer output register p (top) bit q top topq 0 0: outputs 0 from topq. (c) timer output enable register p (toep) bit q toep toepq 0 0: stops topq output operation by counting operation. (d) timer output level register p (tolp) bit q tolp tolpq 0 0: cleared to 0 when tompq = 0 (toggle mode). (e) timer output mode register p (tomp) bit q tomp tompq 0 0: sets toggle mode. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 318 jun 20, 2011 figure 6-52. operation procedure when input pulse interval measurement function is used software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsp register. determines clock frequencies of ckp0 and ckp1. channel default setting sets the tmrpq register (determines operation mode of channel). channel stops operating. (clock is supplied and some power is consumed.) operation start sets tspq bit to 1. the tspq bit automatically returns to 0 because it is a trigger bit. tepq = 1, and count operation starts. tcrpq is cleared to 0000h at the count clock input. when the mdpq0 bit of the tmrpq register is 1, inttmpq is generated. during operation set values of only the cispq1 and cispq0 bits of the tmrpq register can be changed. the tdrpq register can always be read. the tcrpq register can always be read. the tsrpq register can always be read. set values of tomp, tolp, top, and toep registers cannot be changed. counter (tcrpq) counts up from 0000h. when the tipq pin input valid edge is detected, the count value is transferred (captured) to tdrpq. at the same time, tcrpq is cleared to 0000h, and the inttmpq signal is generated. if an overflow occurs at this time, the ovfpq bit of the tsrpq register is set; if an overflow does not occur, the ovfpq bit is cleared. after that, the above operation is repeated. operation stop the ttpq bit is set to 1. the ttpq bit automatically returns to 0 because it is a trigger bit. tepq = 0, and count operation stops. tcrpq holds count value and stops. the ovfpq bit of the tsrpq register is also held. tau stop the tau0en or tau1en bits of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 operation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 319 jun 20, 2011 6.7.5 operation as input signal hi gh-/low-level width measurement by starting counting at one edge of ti pq and capturing the number of counts at another edge, the signal width (high- level width/low-level width) of tipq can be measured. t he signal width of tipq can be calculated by the following expression. signal width of tipq input = period of count clock ((10000h tsrpq: ovf) + (capture value of tdrpq + 1)) caution the tipq pin input is sampled using th e operating clock selected with the ckspq bit of the tmrpq register, so an erro r equal to the number of operating clocks occurs. tcrpq operates as an up counter in the capture & one-count mode. when the channel start trigger (tspq) is set to 1, tepq is set to 1 and the tipq pin start edge detection wait status is set. when the tipq start valid edge (rising ed ge of tipq when the high-level width is to be measured) is detected, the counter counts up in synchronization wit h the count clock. when the valid capt ure edge (falling edge of tipq when the high-level width is to be measured) is detected later, the c ount value is transferred to tdrpq and, at the same time, inttmpq is output. if the counter overflows at this time, the ov fpq bit of the tsrpq register is set to 1. if the counter does not overflow, the ovfpq bit is cleared. tcrpq stops at the value ?value transferred to tdrpq + 1?, and the tipq pin start edge detection wait status is set. after that, the above operation is repeated. as soon as the count value has been captured to the tdrpq register, the ovfpq bit of the tsrpq register is updated depending on whether the counter overflow s during the measurement period. ther efore, the overflow status of the captured value can be checked. if the counter reaches a full count for two or more periods, it is judged to be an overflow occurrence, and the ovfpq bit of the tsrpq register is set to 1. howe ver, the ovfpq bit is configured as an int egral flag, and the correct interval value cannot be measured if an overflow occurs more than once. whether the high-level width or low-level width of the tipq pin is to be measured can be selected by using the cispq1 and cispq0 bits of the tmrpq register. because this function is used to meas ure the signal width of the tipq pin input, tspq cannot be set to 1 while tepq is 1. cispq1, cispq0 of tmrpq = 10b: low-level width is measured. cispq1, cispq0 of tmrpq = 11b: high-level width is measured. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 320 jun 20, 2011 figure 6-53. block diagram of operation as in put signal high-/low-le vel width measurement timer counter (tcrpq) interrupt signal (inttmpq) data register (tdrpq) interrupt controller clock selection trigger selection operation clock ckp0 ckp1 edge detection tipq pin remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 figure 6-54. example of basic timing of operati on as input signal high-/low-level width measurement tspq tepq tipq tdrpq tcrpq b 0000h a c inttmpq ffffh b a c ovfpq 0000h remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: pq = 00 to 04, 07 78k0r/lg3: pq = 00 to 07 78k0r/lh3: pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 321 jun 20, 2011 figure 6-55. example of set contents of regist ers to measure input signa l high-/low-level width (a) timer mode register pq (tmrpq) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrpq ckspq 1/0 0 0 ccspq 0 mas terpq 0 stspq2 0 stspq1 1 stspq0 0 cispq1 1 cispq0 1/0 0 0 mdpq3 1 mdpq2 1 mdpq1 0 mdpq0 0 operation mode of channel q 110b: capture & one-count setting of operation when counting is started 0: does not generate inttmpq when counting is started. selection of tipq pin input edge 10b: both edges (to measure low-level width) 11b: both edges (to measure high-level width) start trigger selection 010b: selects the tipq pin input valid edge. slave/master selection 0: cleared to 0 when independent function is selected. count clock selection 0: selects operation clock. operation clock selection 0: selects ckp0 as operation clock of channel q. 1: selects ckp1 as operation clock of channel q. (b) timer output register p (top) bit q top topq 0 0: outputs 0 from topq. (c) timer output enable register p (toep) bit q toep toepq 0 0: stops the topq output operation by counting operation. (d) timer output level register p (tolp) bit q tolp tolpq 0 0: cleared to 0 when tompq = 0 (toggle mode). (e) timer output mode register p (tomp) bit q tomp tompq 0 0: sets toggle mode. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 322 jun 20, 2011 figure 6-56. operation procedure when input signal high-/low-level width measu rement function is used software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsp register. determines clock frequencies of ckp0 and ckp1. channel default setting sets the tmrpq register (determines operation mode of channel). clears toepq to 0 and stops operation of topq. channel stops operating. (clock is supplied and some power is consumed.) sets the tspq bit to 1. the tspq bit automatically returns to 0 because it is a trigger bit. tepq = 1, and the tipq pin start edge detection wait status is set. operation start detects tipq pin input count start valid edge. clears tcrpq to 0000h and starts counting up. during operation set value of the tdrpq register can be changed. the tcrpq register can always be read. the tsrpq register is not used. set values of tmrpq, tomp, tolp, top, and toep registers cannot be changed. when the tipq pin start edge is detected, the counter (tcrpq) counts up from 0000h. if a capture edge of the tipq pin is detected, the count value is transferred to tdrpq and inttmpq is generated. if an overflow occurs at this time, the ovfpq bit of the tsrpq register is set; if an overflow does not occur, the ovfpq bit is cleared. tcrpq stops the count operation until the next tipq pin start edge is detected. operation stop the ttpq bit is set to 1. ttpq bit automatically returns to 0 because it is a trigger bit. tepq = 0, and count operation stops. tcrpq holds count value and stops. the ovfpq bit of the tsrpq register is also held. tau stop the tau0en or tau1en bits of per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. remark pq: unit number + channel number (only for channels provided with timer i/o pins) 78k0r/lf3: p = 0, pq = 00 to 04, 07 78k0r/lg3: p = 0, pq = 00 to 07 78k0r/lh3: p = 0, 1, pq = 00 to 07, 10 to 13 ope r ation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 323 jun 20, 2011 6.8 operation of plural channels of timer array unit 6.8.1 operation as pwm function two channels can be used as a set to generate a pulse of any period and duty factor. the period and duty factor of the output pulse can be calculated by the following expressions. pulse period = {set value of tdrmn (master) + 1} count clock period duty factor [%] = {set value of tdrmp (s lave)}/{set value of tdrmn (master) + 1} 100 0% output: set value of tdrmp (slave) = 0000h 100% output: set value of tdrmp (slave) {set value of tdrmn (master) + 1} remark the duty factor exceeds 100% if the set value of t drmp (slave) > (set value of tdrmn (master) + 1), it summarizes to 100% output. the master channel operates in the interval timer mode and counts the peri ods. when the channel start trigger (tsmn) is set to 1, inttmmn is output. tcrmn counts down starting fr om the loaded value of tdrmn, in synchronization with the count clock. when tcrmn = 0000h, inttmmn is output. tcrm n loads the value of tdrmn again. after that, it continues the similar operation. tcrmp of a slave channel operates in one-count mode, counts t he duty factor, and outputs a pwm waveform from the tomp pin. tcrmp of the slave channel loads the value of tdrmp, using intt mmn of the master channel as a start trigger, and stops counting until t he next start trigger (inttmmn of the master channel) is input. the output level of tomp becomes acti ve one count clock after generation of inttmmn from the master channel, and inactive when tcrmp = 0000h. caution to rewrite both tdrmn of the master channe l and tdrmp of the slave channel, a write access is necessary two times. the timing at which the values of tdrmn and tdrmp are loaded to tcrmn and tcrmp is upon occurrence of inttmmn of the master channel. thus, when rewriting is performed split before and after occurrence of inttmmn of th e master channel, the tomp pin cannot output the expected waveform. to rewrite both tdrmn of the m aster and tdrmp of the slave, therefore, be sure to rewrite both the registers immediately after inttmmn is generated fr om the master channel. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 324 jun 20, 2011 figure 6-57. block diagram of operation as pwm function timer counter (tcrmn) interrupt signal (inttmmn) data register (tdrmn) interrupt controller clock selection trigger selection operation clock ckm0 ckm1 tsmn timer counter (tcrmp) interrupt signal (inttmmp) data register (tdrmp) interrupt controller clock selection trigger selection operation clock ckm0 ckm1 tomp pin output controller master channel (interval timer mode) slave channel (one-count mode) remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 325 jun 20, 2011 figure 6-58. example of basic ti ming of operation as pwm function tsmn temn tdrmn tcrmn tomn inttmmn a b 0000h tsmp temp tdrmp tcrmp tomp inttmmp c c d 0000h c d master channel slave channel a+1 a+1 b+1 ffffh ffffh remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 326 jun 20, 2011 figure 6-59. example of set contents of register s when pwm function (master channel) is used (a) timer mode register mn (tmrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cksmn 1/0 0 0 ccsmn 0 mas termn 1 stsmn2 0 stsmn1 0 stsmn0 0 cismn1 0 cismn0 0 0 0 mdmn3 0 mdmn2 0 mdmn1 0 mdmn0 1 operation mode of channel n 000b: interval timer setting of operation when counting is started 1: generates inttmmn when counting is started. selection of timn pin input edge 00b: sets 00b because these are not used. start trigger selection 000b: selects only software start. slave/master selection 1: channel 1 is set as master channel. count clock selection 0: selects operation clock. operation clock selection 0: selects ckm0 as operation clock of channel n. 1: selects ckm1 as operation clock of channel n. (b) timer output register m (tom) bit n tom tomn 0 0: outputs 0 from tomn. (c) timer output enable register m (toem) bit n toem toemn 0 0: stops the tomn output operation by counting operation. (d) timer output level register m (tolm) bit n tolm tolmn 0 0: cleared to 0 when tommn = 0 (toggle mode). (e) timer output mode register m (tomm) bit n tomm tommn 0 0: sets toggle mode. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, to07, ti00 to ti04, and ti07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13, ti10 to ti13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 327 jun 20, 2011 figure 6-60. example of set contents of regist ers when pwm function (slave channel) is used (a) timer mode register mp (tmrmp) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmp cksmp 1/0 0 0 ccsmp 0 mas termp 0 stsmp2 1 stsmp1 0 stsmp0 0 cismp1 0 cismp0 0 0 0 mdmp3 1 mdmp2 0 mdmp1 0 mdmp0 1 operation mode of channel p 100b: one-count mode start trigger during operation 1: trigger input is valid. selection of timp pin input edge 00b: sets 00b because these are not used. start trigger selection 100b: selects inttmmn of master channel. slave/master selection 0: channel 0 is set as slave channel. count clock selection 0: selects operation clock. operation clock selection 0: selects ckm0 as operation clock of channel p. 1: selects ckm1 as operation clock of channel p. * make the same setting as master channel. (b) timer output register m (tom) bit p tom tomp 1/0 0: outputs 0 from tomp. 1: outputs 1 from tomp. (c) timer output enable register m (toem) bit p toem toemp 1/0 0: stops the tomp output operation by counting operation. 1: enables the tomp output operation by counting operation. (d) timer output level register m (tolm) bit p tolm tolmp 1/0 0: positive logic output (active-high) 1: inverted output (active-low) (e) timer output mode register m (tomm) bit p tomm tommp 1 1: sets the combination operation mode. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, to07, ti00 to ti04, and ti07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13, ti10 to ti13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 328 jun 20, 2011 figure 6-61. operation procedure wh en pwm function is used (1/2) software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsm register. determines clock frequencies of ckm0 and ckm1. sets the tmrmn and tmrmp registers of two channels to be used (determines oper ation mode of channels). an interval (period) value is set to the tdrmn register of the master channel, and a duty factor is set to the tdrmp register of the slave channel. channel stops operating. (clock is supplied and some power is consumed.) channel default setting sets slave channel. the tommp bit of the tomn register is set to 1 (combination operation mode). sets the tolmp bit. sets the tomp bit and determines default level of the tomp output. sets toemp to 1 and enables operation of tomp. clears the port register and port mode register to 0. the tomn pin goes into hi-z output state. the tomn default setting level is output when the port mode register is in output mode and the port register is 0. tomp does not change because channel stops operating. the tomp pin outputs the tomp set level. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 329 jun 20, 2011 figure 6-61. operation procedure wh en pwm function is used (2/2) software operation hardware status operation start sets toemp (slave) to 1 (only when operation is resumed). the tsmn (master) and tsmp (slave) bits of the tsm register are set to 1 at the same time. the tsmn and tsmp bits automatically return to 0 because they are trigger bits. temn = 1, temp = 1 when the master channel starts counting, inttmmn is generated. triggered by this interrupt, the slave channel also starts counting. during operation set values of the tmrmn and tmrmp registers and tommn, tommp, tolmn, and tolmp bits cannot be changed. set values of the tdrmn and tdrmp registers can be changed after inttmmn of the master channel is generated. the tcrmn and tcrmp registers can always be read. the tsrmn and tsrmp registers are not used. set values of the tom and toem registers cannot be changed. the counter of the master channel loads the tdrmn value to tcrmn, and counts down. when the count value reaches tcrmn = 0000h, inttmmn output is generated. at the same time, the value of the tdrmn register is loaded to tcrmn, and the counter starts counting down again. at the slave channel, the va lue of tdrmp is loaded to tcrmp, triggered by inttmmn of the master channel, and the counter starts counting down. the output level of tomp becomes active one c ount clock after generation of the inttmmn output from the master channel. it becomes inactive when tcrmp = 0000h, and the counting operation is stopped. after that, the above operation is repeated. the ttmn (master) and ttmp (slave) bits are set to 1 at the same time. the ttmn and ttmp bits automatically return to 0 because they are trigger bits. temn, temp = 0, and count operation stops. tcrmn and tcrmp hold count value and stops. the tomp output is not initialized but holds current status. operation stop toemp of slave channel is cleared to 0 and value is set to the tomp register. the tomp pin outputs the tomp set level. to hold the tomp pin output levels clears tomp bit to 0 after the value to be held is set to the port register. when holding the tomp pin output levels is not necessary switches the port mode register to input mode. the tomp pin output levels is held by port function. the tomp pin output levels go are into hi-z output state. tau stop the tau0en or tau1en bits of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the tomp bit is cleared to 0 and the tomp pin is set to port mode.) remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins operation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 330 jun 20, 2011 6.8.2 operation as one-shot pulse output function a one-shot pulse with any delay pulse width can be generat ed by using two channels in combination and timn pin input or software manipulation (tsmn = 1). the delay time and pulse width can be ca lculated by the following expressions. delay time = {set value of tdrmn (master) + 2} count clock period pulse width = {set value of tdrmp (slave)} count clock period the master channel operates in the one- count mode and counts the delays. t crmn of the master channel starts operating upon start trigger detection and tcrmn loads the value of tdrmn. tcrmn counts down from the value of tdrmn it has loaded, in synchronizati on with the count clock. when tcrm n = 0000h, it outputs inttmmn and stops counting until the next start trigger is detected. the slave channel operates in the on e-count mode and counts the pulse width. tcrmp of the slave channel starts operation using inttmmn of the master channel as a start trigger, and loads t he tdrmp value. tcrmp counts down from the value of tdrmp it has load ed, in synchronization with the count va lue. when tcrmp = 0000h, it outputs inttmmp and stops counting until the next star t trigger (inttmmn of the master channe l) is detected. the output level of tomp becomes active one count clock after generation of inttmmn from the master channel, and inactive when tcrmp = 0000h. instead of using the timn pin input, a one-shot pulse can al so be output using the software operation (tsmn = 1) as a start trigger. caution the timing of loading of tdrmn of the master channel is different from that of tdrmp of the slave channel. if tdrmn and tdrmp are re written during operation, therefore, an illegal waveform is output. be sure to rewrite tdrmn and t drmp after inttmmn of the channel to be rewritten is generated. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, to07, ti00 to ti04, and ti07 pins ? channel 6 of timer array unit 0 can output a one-shot pulse only when software trigger start is selected and it is used as the master channel (because the ti06 pin is not provided). 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13, ti10 to ti13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 331 jun 20, 2011 figure 6-62. block diagram of operat ion as one-shot pulse output function timer counter (tcrmn) interrupt signal (inttmmn) data register (tdrmn) interrupt controller clock selection trigger selection operation clock ckm0 ckm1 tsmn timer counter (tcrmp) interrupt signal (inttmmp) data register (tdrmp) interrupt controller clock selection trigger selection operation clock ckm0 ckm1 tomp pin output controller master channel (one-count mode) slave channel (one-count mode) edge detection timn pin remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, to07, ti00 to ti04, and ti07 pins ? channel 6 of timer array unit 0 can output a one-shot pulse only when software trigger start is selected and it is used as the master channel (because the ti06 pin is not provided). 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13, ti10 to ti13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 332 jun 20, 2011 figure 6-63. example of basic timing of operation as one-shot pulse output function (start trigger tlmn input valid edge) temn tdrmn tcrmn tomn inttmmn a b 0000h tsmp temp tdrmp tcrmp tomp inttmmp 0000h b master channel slave channel a+2 b a+2 ffffh ffffh timn tsmn remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 333 jun 20, 2011 figure 6-64. example of set c ontents of registers when on e-shot pulse output function is used (master channel) (a) timer mode register mn (tmrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cksmn 1/0 0 0 ccsmn 0 mas termn 1 stsmn2 0 stsmn1 0 stsmn0 1 cismn1 1/0 cismn0 1/0 0 0 mdmn3 1 mdmn2 0 mdmn1 0 mdmn0 0 operation mode of channel n 100b: one-count mode start trigger during operation 0: trigger input is invalid. selection of timn pin input edge 00b: detects falling edge. 01b: detects rising edge. 10b: detects both edges. 11b: setting prohibited start trigger selection 000b: selects the software trigger start. 001b: selects the timn pin input valid edge. slave/master selection 1: channel 1 is set as master channel. count clock selection 0: selects operation clock. operation clock selection 0: selects ckm0 as operation clock of channels n. 1: selects ckm1 as operation clock of channels n. (b) timer output register m (tom) bit n tom tomn 0 0: outputs 0 from tomn. (c) timer output enable register m (toem) bit n toem toemn 0 0: stops the tomn output operation by counting operation. (d) timer output level register m (tolm) bit n tolm tolmn 0 0: cleared to 0 when tommn = 0 (toggle mode). (e) timer output mode register m (tomm) bit n tomm tommn 0 0: sets toggle mode. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, to07, ti00 to ti04, and ti07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13, ti10 to ti13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 334 jun 20, 2011 figure 6-65. example of set contents of registers when one-shot pulse ou tput function is used (slave channel) (a) timer mode register mp (tmrmp) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmp cksmp 1/0 0 0 ccsmp 0 mas termp 0 stsmp2 1 stsmp1 0 stsmp0 0 cismp1 0 cismp0 0 0 0 mdmp3 1 mdmp2 0 mdmp1 0 mdmp0 0 operation mode of channel p 100b: one-count mode start trigger during operation 0: trigger input is invalid. selection of timp pin input edge 00b: sets 00b because these are not used. start trigger selection 100b: selects inttmmn of master channel. slave/master selection 0: channel 0 is set as slave channel. count clock selection 0: selects operation clock. operation clock selection 0: selects ckm0 as operation clock of channel p. 1: selects ckm1 as operation clock of channel p. * make the same setting as master channel. (b) timer output register m (tom) bit p tom tomp 1/0 0: outputs 0 from tomp. 1: outputs 1 from tomp. (c) timer output enable register m (toem) bit p toem toemp 1/0 0: stops the tomp output operation by counting operation. 1: enables the tomp output operation by counting operation. (d) timer output level register m (tolm) bit p tolm tolmp 1/0 0: positive logic output (active-high) 1: inverted output (active-low) (e) timer output mode register m (tomm) bit p tomm tommp 1 1: sets the combination operation mode. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, to07, ti00 to ti04, and ti07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+ 1, to00 to to07, ti00 to ti07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13, ti10 to ti13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 335 jun 20, 2011 figure 6-66. operation procedure of one-shot pulse output function (1/2) software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsm register. determines clock frequencies of ckm0 and ckm1. sets the tmrmn and tmrmp registers of two channels to be used (determines oper ation mode of channels). an output delay is set to the tdrmn register of the master channel, and a pulse width is set to the tdrmp register of the slave channel. channel stops operating. (clock is supplied and some power is consumed.) channel default setting sets slave channel. the tommp bit of the tomm register is set to 1 (combination operation mode). sets the tolmp bit. sets the tomp bit and determines default level of the tomp output. sets toemp to 1 and enables operation of tomp. clears the port register and port mode register to 0. the tomn pin goes into hi-z output state. the tomn default setting level is output when the port mode register is in output mode and the port register is 0. tomp does not change because channel stops operating. the tomp pin outputs the tomp set level. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins ? channel 6 of timer array unit 0 can output a one-shot pulse only when software trigger start is selected and it is used as the master channel (because the ti06 pin is not provided). 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 336 jun 20, 2011 figure 6-66. operation procedure of one-shot pulse output function (2/2) software operation hardware status sets toemp (slave) to 1 (only when operation is resumed). the tsmn (master) and tsmp (slave) bits of the tsm register are set to 1 at the same time. the tsmn and tsmp bits automatically return to 0 because they are trigger bits. temn and temp are set to 1 and the master channel enters the timn input edge detection wait status. counter stops operating. operation start detects the start trigger of master channel. (the valid edge of the timn pin input is detected or the tsmn bit is set to 1.) master channel starts counting. during operation set values of only the cismn1 and cismn0 bits of the tmrmn register can be changed. set values of the tmrmp, tdrmn, and tdrmp registers and tommn, tommp, tolmn, and tolmp bits cannot be changed. the tcrmn and tcrmp registers can always be read. the tsrmn and tsrmp registers are not used. set values of the tom and toem registers can be changed. master channel loads the value of tdrmn to tcrmn when the start trigger is detected, and the counter starts counting down. when the count value reaches tcrmn = 0000h, the inttmmn output is generated, and the counter stops until the next valid edge is input to the timn pin. the slave channel, triggered by inttmmn of the master channel, loads the value of tdrmp to tcrmp, and the counter starts counting down. the output level of tomp becomes active one count clock after generation of inttmmn from the master channel. it becomes inactive when tcrmp = 0000h, and the counting operation is stopped. after that, the above operation is repeated. the ttmn (master) and ttmp (slave) bits are set to 1 at the same time. the ttmn and ttmp bits automatically return to 0 because they are trigger bits. temn, temp = 0, and count operation stops. tcrmn and tcrmp hold count value and stops. the tomp output is not initialized but holds current status. operation stop toemp of slave channel is cleared to 0 and value is set to the tom register. the tomp pin outputs the tomn set level. to hold the tomp pin output levels clears tomp bit to 0 after the value to be held is set to the port register. when holding the tomp pin output levels is not necessary switches the port mode register to input mode. the tomp pin output levels is held by port function. the tomp pin output levels go are into hi-z output state. tau stop the tau0en or tau1en bits of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the tomp bit is cleared to 0 and the tomp pin is set to port mode.) remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, 6, p = n+1, to00 to to04, and to07 pins ? channel 6 of timer array unit 0 can output a one-shot pulse only when software trigger start is selected and it is used as the master channel (because the ti06 pin is not provided). 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, 6, p = n+1, to00 to to07 pins ? m = 1, n = 0, 2, p = n+1, to10 to to13 pins operation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 337 jun 20, 2011 6.8.3 operation as multiple pwm output function by extending the pwm function and using two or more sl ave channels, many pwm output signals can be produced. for example, when using two slave channels, the period and du ty factor of an output pul se can be calculated by the following expressions. pulse period = {set value of tdrmn (master) + 1} count clock period duty factor 1 [%] = {set value of tdrmp (s lave 1)}/{set value of tdrmn (master) + 1} 100 duty factor 2 [%] = {set value of tdrmp (s lave 2)}/{set value of tdrmn (master) + 1} 100 remark although the duty factor exceeds 100% if the set value of tdrmp (slave 1) > {set value of tdrmn (master) + 1} or if the {set value of tdrmq (slave 2)} > {set value of tdrmn (master) + 1}, it is summarized into 100% output. tcrmn of the master channel operates in the interval timer mode and counts the periods. tcrmp of the slave channel 1 operates in one-count mode, counts the duty factor, and outputs a pwm waveform from the tomp pin. tcrmp loads the value of tdrmp to tcrmp, using inttmmn of the master channel as a start trigger, and start counting down. when tcrmp = 0000h, tcrmp outputs inttmmp and stops counting until the next start trigger (inttmmn of the master channel) has been input. the out put level of tomp becomes active one count clock after generation of inttmmn from the master channel, and inactive when tcrmp = 0000h. in the same way as tcrmp of the slav e channel 1, tcrmq of the slave channel 2 operates in one-count mode, counts the duty factor, and outputs a pwm waveform from the tomq pi n. tcrmq loads the value of tdrmq to tcrmq, using inttmmn of the master channel as a start trigger, and starts counting down. when tcrmq = 0000h, tcrmq outputs inttmmq and stops counting until the next start trigger (intt mmn of the master channel) has been input. the output level of tomq becomes active one count clock after generati on of inttmmn from the master channel, and inactive when tcrmq = 0000h. when channel 0 is used as the master channel as described above, up to seven types of pwm signals can be output at the same time with timer array unit 0 and up to three types with timer array unit 1. caution to rewrite both tdrmn of the master channe l and tdrmp of the slave channel 1, write access is necessary at least twice. since the values of tdrmn and tdrmp are loaded to tcrmn and tcrmp after inttmmn is generated from the master channel, if rewriti ng is performed sepa rately before and after generation of inttmmn from the master chan nel, the tomp pin cannot output the expected waveform. to rewrite both tdrmn of the master and tdrmp of the slave, be sure to rewrite both the registers immediately after inttmmn is generated from the master channel (this applies also to tdrmq of the slave channel 2) . remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, p = n+1, q = n+2, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins ? m = 1, n = 0, p = 1, q = 2, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 338 jun 20, 2011 figure 6-67. block diagram of operation as multiple pwm output function (output two types of pwms) timer counter (tcrmn) interrupt signal (inttmmn) data register (tdrmn) interrupt controller clock selection trigger selection operation clock ckm0 ckm1 tsmn timer counter (tcrmp) interrupt signal (inttmmp) data register (tdrmp) interrupt controller clock selection trigger selection operation clock ckm0 ckm1 tomp pin output controller master channel (interval timer mode) slave channel 1 (one-count mode) timer counter (tcrmq) interrupt signal (inttmmq) data register (tdrmq) interrupt controller clock selection trigger selection operation clock ckm0 ckm1 tomq pin output controller slave channel 2 (one-count mode) remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, p = n+1, q = n+2, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins ? m = 1, n = 0, p = 1, q = 2, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 339 jun 20, 2011 figure 6-68. example of basic timing of operation as multiple pwm output function (output two types of pwms) tsmn temn tdrmn tcrmn tomn inttmmn a b 0000h tsmp temp tdrmp tcrmp tomp inttmmp c c d 0000h c d master channel slave channel 1 a+1 a+1 b+1 ffffh ffffh tsmq temq tdrmq tcrmq tomq inttmmq e f 0000h e f slave channel 2 a+1 a+1 b+1 ffffh e f d remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, p = n+1, q = n+2, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins ? m = 1, n = 0, p = 1, q = 2, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 340 jun 20, 2011 figure 6-69. example of set contents of registers when multiple pwm output function (master channel) is used (a) timer mode register mn (tmrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmn cksmn 1/0 0 0 ccsmn 0 mas termn 1 stsmn2 0 stsmn1 0 stsmn0 0 cismn1 0 cismn0 0 0 0 mdmn3 0 mdmn2 0 mdmn1 0 mdmn0 1 operation mode of channel n 000b: interval timer setting of operation when counting is started 1: generates inttmmn when counting is started. selection of timn pin input edge 00b: sets 00b because these are not used. start trigger selection 000b: selects only software start. slave/master selection 1: channel 1 is set as master channel. count clock selection 0: selects operation clock. operation clock selection 0: selects ckm0 as operation clock of channel n. 1: selects ckm1 as operation clock of channel n. (b) timer output register m (tom) bit n tom tomn 0 0: outputs 0 from tomn. (c) timer output enable register m (toem) bit n toem toemn 0 0: stops the tomn output operation by counting operation. (d) timer output level register m (tolm) bit n tolm tolmn 0 0: cleared to 0 when tommn = 0 (toggle mode). (e) timer output mode register m (tomm) bit n tomm tommn 0 0: sets toggle mode. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, to00 to to04, to07, ti00 to ti04, and ti07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, to00 to to07, and ti00 to ti07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, to00 to to07, and ti00 to ti07 pins ? m = 1, n = 0, to10 to to13 , and ti10 to ti13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 341 jun 20, 2011 figure 6-70. example of set contents of registers when multiple pwm output function (slave channel) is used (output two types of pwms) (a) timer mode register mp, mq (tmrmp, tmrmq) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmp cksmp 1/0 0 0 ccsmp 0 mas termp 0 stsmp2 1 stsmp1 0 stsmp0 0 cismp1 0 cismp0 0 0 0 mdmp3 1 mdmp2 0 mdmp1 0 mdmp0 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmrmq cksmq 1/0 0 0 ccsmq 0 mas termq 0 stsmq2 1 stsmq1 0 stsmq0 0 cismq1 0 cismq0 0 0 0 mdmq3 1 mdmq2 0 mdmq1 0 mdmq0 1 operation mode of channel p, q 100b: one-count mode start trigger during operation 1: trigger input is valid. selection of timp and timq pin input edge 00b: sets 00b because these are not used. start trigger selection 100b: selects inttmmn of master channel. slave/master selection 0: channel 0 is set as slave channel. count clock selection 0: selects operation clock. operation clock selection 0: selects ckm0 as operation clock of channel p, q. 1: selects ckm1 as operation clock of channel p, q. * make the same setting as master channel. (b) timer output register m (tom) bit q bit p tom tomq 1/0 tomp 1/0 0: outputs 0 from tomp or tomq. 1: outputs 1 from tomp or tomq. (c) timer output enable register m (toem) bit q bit p toem toemq 1/0 toemp 1/0 0: stops the tomp or tomq output operation by counting operation. 1: enables the tomp or tomq output operation by counting operation. (d) timer output level register m (tolm) bit q bit p tolm tolmq 1/0 tolmp 1/0 0: positive logic output (active-high) 1: inverted output (active-low) (e) timer output mode register m (tomm) bit q bit p tomm tommq 1 tommp 1 1: sets the combination operation mode. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 342 jun 20, 2011 remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, p = n+1, q = n+2, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins ? m = 1, n = 0, p = 1, q = 2, to10 to to13 pins figure 6-71. operation procedure when mult iple pwm output function is used (1/2) software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en or tau1en bits of the per0 register to 1. power-on status. each channel stops operating. (clock supply is started and writing to each register is enabled.) tau default setting sets the tpsm register. determines clock frequencies of ckm0 and ckm1. sets the tmrmn, tmrmp, and tmrmq registers of each channel to be used (determines operation mode of channels). an interval (period) value is set to the tdrmn register of the master channel, and a duty factor is set to the tdrmp and tdrmq register of the slave channel. channel stops operating. (clock is supplied and some power is consumed.) channel default setting sets slave channel. the tommp and tommq bits of the tomm register are set to 1 (combination operation mode). clears the tolmp and tolmq bits to 0. sets the tomp and tomq bits and determines default level of the tomp and tomq outputs. sets toemp or toemq to 1 and enables operation of tomp and tomq. clears the port register and port mode register to 0. the tomn pin goes into hi-z output state. the tomp and tomq default setting levels are output when the port mode register is in output mode and the port register is 0. tomp or tomq does not change because channel stops operating. the tomp and tomq pins output the tomp and tomq set levels. remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, p = n+1, q = n+2, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins ? m = 1, n = 0, p = 1, q = 2, to10 to to13 pins 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 343 jun 20, 2011 figure 6-71. operation procedure when mult iple pwm output function is used (2/2) software operation hardware status operation start sets toemp and toemq (slave) to 1 (only when operation is resumed). the tsmn bit (master), and tsmp and tsmq (slave) bits of the tsm register are set to 1 at the same time. the tsmn, tsmp, and tsmq bits automatically return to 0 because they are trigger bits. temn = 1, temp, temq = 1 when the master channel starts counting, inttmmn is generated. triggered by this interrupt, the slave channel also starts counting. during operation set values of the tmrmn, tmrmp, and tmrmq registers and tommn, tommp, tommq, tolmn, tolmp, and tolmq bits cannot be changed. set values of the tdrmn, tdrmp, and tdrmq registers can be changed after inttmmn of the master channel is generated. the tcrmn, tcrmp, and tcrmq registers can always be read. the tsrmn, tsrmp, and tsrmq registers are not used. set values of the tom and toem registers can be changed. the counter of the master channel loads the tdrmn value to tcrmn and counts down. when the count value reaches tcrmn = 0000h, inttmmn output is generated. at the same time, the value of the tdrmn register is loaded to tcrmn, and the counter starts counting down again. at the slave channel 1, the values of tdrmp are transferred to tcrmp, triggered by inttmmn of the master channel, and the counter starts counting down. the output levels of tomp become active one count clock after generation of the inttmmn output from the master channel. it becomes inactive when tcrmp = 0000h, and the counting operation is stopped. at the slave channel 2, the values of tdrmq are transferred to tdrmq, triggered by inttmmn of the master channel, and the counter starts counting down. the output levels of tomq become active one count clock after generation of the inttmmn output from the master channel. it becomes inactive when tcrmq = 0000h, and the counting operation is stopped. after that, the above operation is repeated. the ttmn bit (master), ttmp, and ttmq (slave) bits are set to 1 at the same time. the ttmn, ttmp, and ttmq bits automatically return to 0 because they are trigger bits. temn, temp, and temq = 0, and count operation stops. tcrmn, tcrmp and tcrmq hold count value and stops. the tomp and tomq outputs are not initialized but holds current status. operation stop toemp or toemq of slave channel is cleared to 0 and value is set to the tomp and tomq registers. the tomp and tomq pins output the tomp and tomq set levels. to hold the tomp and tomq pins output levels clears tomp and tomq bits to 0 after the value to be held is set to the port register. when holding the tomp and tomq pins output levels is not necessary switches the port mode register to input mode. the tomp and tomq pins output levels are held by port function. the tomp and tomq pins output levels go into hi-z output state. tau stop the tau0en or tau1en bits of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the tomp and tomq bits are cleared to 0 and the tomp and tomq pins are set to port mode.) operation is resumed. 78k0r/lx3 chapter 6 timer array unit r01uh0004ej0501 rev.5.01 344 jun 20, 2011 remarks 1. 78k0r/lf3: ? m = 0, n = 0, 2, p = n+1, q = n+2, to00 to to04, and to07 pins 2 . 78k0r/lg3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins 3. 78k0r/lh3: ? m = 0, n = 0, 2, 4, p = n+1, q = n+2, to00 to to07 pins ? m = 1, n = 0, p = 1, q = 2, to10 to to13 pins 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 345 jun 20, 2011 chapter 7 real-time counter 7.1 functions of real-time counter the real-time counter is mounted onto all 78k0r/lx 3 microcontroller products. the real-time counter ha s the following features. ? having counters of year, month, week, day, hour, minute, and second, and can count up to 99 years. ? constant-period interrupt function (period: 1 month to 0.5 seconds) ? alarm interrupt function (alarm: week, hour, minute) ? interval interrupt function ? pin output function of 1 hz ? pin output function of 512 hz or 16.384 khz or 32.768 khz 7.2 configuration of real-time counter the real-time counter includes the following hardware. table 7-1. configuration of real-time counter item configuration peripheral enable register 0 (per0) real-time counter control register 0 (rtcc0) real-time counter control register 1 (rtcc1) real-time counter control register 2 (rtcc2) sub-count register (rsubc) second count register (sec) minute count register (min) hour count register (hour) day count register (day) week count register (week) month count register (month) year count register (year) watch error correction register (subcud) alarm minute register (alarmwm) alarm hour register (alarmwh) alarm week register (alarmww) port mode register 3 control registers port register 3 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 346 jun 20, 2011 figure 7-1. block diagra m of real-time counter intrtc f sub rtce rcloe1 rcloe0 ampm ct2 ct1 ct0 rinte rcloe2 ict2 ict1 ict0 rtce ampm ct0 to ct2 rckdiv f sub rckdiv rinte intrtci rcloe2 f sub rwait wale walie wafg rwait rwst rifg rwst rifg 12-bit counter real-time counter control register 1 (rtcc1) real-time counter control register 0 (rtcc0) alarm week register (alarmww) (7-bit) alarm hour register (alarmwh) (6-bit) alarm minute register (alarmwm) (7-bit) year count register (year) (8-bit) month count register (month) (5-bit) week count register (week) (3-bit) day count register (day) (6-bit) hour count register (hour) (6-bit) minute count register (min) (7-bit) second count register (sec) (7-bit) wait control 0.5 seconds sub-count register (rsubc) (16-bit) count clock = 32.768 khz selector buffer buffer buffer buffer buffer buffer buffer count enable/ disable circuit watch error correction register (subcud) (8-bit) selector selector internal bus real-time counter control register 2 (rtcc2) 1 month 1 day 1 hour 1 minute rtcdiv/ rtccl/ti00/ to03/intp2/ p31 to lcd driver/controller rtc1hz/ ti03/to00/ p30/intp1 pm30 output latch ( p30) pm31 output latch ( p31) to cannels 0 or 4 of the tau0 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 347 jun 20, 2011 7.3 registers controlling real-time counter timer real-time counter is controlle d by the following 18 registers. ? peripheral enable register 0 (per0) ? real-time counter control register 0 (rtcc0) ? real-time counter control register 1 (rtcc1) ? real-time counter control register 2 (rtcc2) ? sub-count register (rsubc) ? second count register (sec) ? minute count register (min) ? hour count register (hour) ? day count register (day) ? week count register (week) ? month count register (month) ? year count register (year) ? watch error correction register (subcud) ? alarm minute register (alarmwm) ? alarm hour register (alarmwh) ? alarm week register (alarmww) ? port mode register 3 (pm3) ? port register 3 (p3) 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 348 jun 20, 2011 (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripheral hardware macro. clock supply to a hardware macro that is not used is stopped in order to r educe the power consumption and noise. when the real-time counter is used, be sure to set bit 7 (rtcen) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-2. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note1 sau1en sau0en tau1en tau0en rtcen control of real-time counter (rtc) input clock note2 0 stops supply of input clock. ? sfr used by the real-time counter (rtc) cannot be written. ? the real-time counter (rtc) is in the reset status. 1 supplies input clock. ? sfr used by the real-time counter (rtc) can be read/written. notes 1. 78k0r/lg3, 78k0r/lh3 only 2. by using rtcen, can supply and stop the clock that is used when accessing the real-time counter (rtc) from the cpu. rtcen cannot control supply of the operating clock (f sub ) to rtc. cautions 1. when using the real-time counter, first set rtcen to 1, while oscillation of the subsystem clock (f sub ) is stable. if rtcen = 0, writing to a control register of the real-time counter is ignored, and, even if the register is read, only the default value is read. 2. clock supply to peripheral functions excep t the real-time counter can be stopped in the halt mode when operating on the sub system clock by setti ng rtclpc of the operation speed mode control register (osmc) to 1. in this case, set rtcen to 1 and bits 0 to 6 of per0 to 0. (2) real-time counter cont rol register 0 (rtcc0) the rtcc0 register is an 8-bit register that is used to start or stop the real-time co unter operation, control the rtccl and rtc1hz pins, and set a 12- or 24-hour system and the constant-per iod interrupt function. rtcc0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 349 jun 20, 2011 figure 7-3. format of real-time c ounter control register 0 (rtcc0) address: fff9dh after reset: 00h r/w symbol <7> 6 <5> <4> 3 2 1 0 rtcc0 rtce 0 rcloe1 rcloe0 ampm ct2 ct1 ct0 rtce real-time counter operation control 0 stops counter operation. 1 starts counter operation. rcloe1 rtc1hz pin output control 0 disables output of rtc1hz pin (1 hz). 1 enables output of rtc1hz pin (1 hz). rcloe0 note rtccl pin output control 0 disables output of rtccl pin (32 khz). 1 enables output of rtccl pin (32 khz). ampm selection of 12-/24-hour system 0 12-hour system (a.m. and p.m. are displayed.) 1 24-hour system ? to change the value of ampm, set rwait (bit 0 of rtcc 1) to 1, and re-set the hour count register (hour). ? table 7-2 shows the displayed ti me digits that are displayed. ct2 ct1 ct0 constant-period interrupt (intrtc) selection 0 0 0 does not use constant-period interrupt function. 0 0 1 once per 0.5 s (synchronized with second count up) 0 1 0 once per 1 s (same time as second count up) 0 1 1 once per 1 m (second 00 of every minute) 1 0 0 once per 1 hour (minute 00 and second 00 of every hour) 1 0 1 once per 1 day (hour 00, minute 00, and second 00 of every day) 1 1 once per 1 month (day 1, hour 00 a.m., minute 00, and second 00 of every month) when changing the values of ct2 to ct0 while the counter operates (rtce = 1), rewrite the values of ct2 to ct0 after disabling interrupt servicing intrtc by using the inte rrupt mask flag register. furthermore, after rewriting the values of ct2 to ct0, enable interrupt serv icing after clearing the rifg and rtcif flags. note rcloe0 and rcloe2 must not be enabled at the same time. caution if rcloe0 and rcloe1 are changed when rtce = 1, the last wavefo rm of the 32.768 khz and 1 hz output signals may become short. remark : don?t care 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 350 jun 20, 2011 (3) real-time counter cont rol register 1 (rtcc1) the rtcc1 register is an 8-bit register that is used to control the alarm interr upt function and the wait time of the counter. rtcc1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-4. format of real-time count er control register 1 (rtcc1) (1/2) address: fff9eh after reset: 00h r/w symbol <7> <6> 5 <4> <3> 2 <1> <0> rtcc1 wale walie 0 wafg rifg 0 rwst rwait wale alarm operation control 0 match operation is invalid. 1 match operation is valid. when setting a value to the wale bit while the counter ope rates (rtce = 1) and walie = 1, rewrite the wale bit after disabling interrupt servicing intr tc by using the interrupt mask flag r egister. furthermore, clear the wafg and rtcif flags after rewriting the wale bit. when setti ng each alarm register (walie flag of rtcc1, the alarmwm register, the alarmwh register, and the alarmww register), set match operation to be invalid (?0?) for the wale bit. walie control of alarm interrupt (intrtc) function operation 0 does not generate interrupt on matching of alarm. 1 generates interrupt on matching of alarm. wafg alarm detection status flag 0 alarm mismatch 1 detection of matching of alarm this is a status flag that indicates detection of matching wi th the alarm. it is valid only when wale = 1 and is set to ?1? one clock (32.768 khz) after matching of the alarm is detec ted. this flag is cleared w hen ?0? is written to it. writing ?1? to it is invalid. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 351 jun 20, 2011 figure 7-4. format of real-time count er control register 1 (rtcc1) (2/2) rifg constant-period interrupt status flag 0 constant-period interrupt is not generated. 1 constant-period interrupt is generated. this flag indicates the status of generation of the const ant-period interrupt. when the constant-period interrupt is generated, it is set to ?1?. this flag is cleared when ?0? is written to it. writing ?1? to it is invalid. rwst wait status flag of real-time counter 0 counter is operating. 1 mode to read or write counter value this status flag indicates whether the setting of rwait is valid. before reading or writing the counter value, confirm that the value of this flag is 1. rwait wait control of real-time counter 0 sets counter operation. 1 stops sec to year counters. mode to read or write counter value this bit controls the operation of the counter. be sure to write ?1? to it to read or write the counter value. because rsubc continues operation, complete reading or writ ing of it in 1 second, and clear this bit back to 0. when rwait = 1, it takes up to 1 clock (32.768 khz) until the counter value can be read or written. if rsubc overflows when rwait = 1, it counts up after rwai t = 0. if the second count register is written, however, it does not count up because rsubc is cleared. caution if writing is performed to the rtcc1 regist er with a 1-bit manipulation instruction, the rifg and wafg flags may be cleared. therefore, to perform writing to the rifg and wafg flags, be sure to use an 8-bit manipulation instruction. at th is time, set 1 to the rifg and wafg flags to invalidate writing and not to clear the rifg and wafg flags during writing. when the value may be rewritten because the rifg and wafg flags are not being u sed, the rtcc1 register may be written by using a 1-bit manipulation instruction. remark fixed-cycle interrupts and alarm match interrupts us e the same interrupt sour ce (intrtc). when using these two types of interrupts at the same time, wh ich interrupt occurred can be judged by checking the fixed-cycle interrupt status fl ag (rifg) and the alarm detection status flag (wafg) upon intrtc occurrence. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 352 jun 20, 2011 (4) real-time counter cont rol register 2 (rtcc2) the rtcc2 register is an 8-bit register that is used to control the interval interrupt function and the rtcdiv pin. rtcc2 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-5. format of real-time c ounter control register 2 (rtcc2) address: fff9fh after reset: 00h r/w symbol <7> <6> <5> 4 3 2 1 0 rtcc2 rinte rcloe2 rckdiv 0 0 ict2 ict1 ict0 rinte ict2 ict1 ict0 interval interrupt (intrtci) selection 0 interval interrupt is not generated. 1 0 0 0 2 6 /f sub (1.953125 ms) 1 0 0 1 2 7 /f sub (3.90625 ms) 1 0 1 0 2 8 /f sub (7.8125 ms) 1 0 1 1 2 9 /f sub (15.625 ms) 1 1 0 0 2 10 /f sub (31.25 ms) 1 1 0 1 2 11 /f sub (62.5 ms) 1 1 1 2 12 /f sub (125 ms) rcloe2 note rtcdiv pin output control 0 disables output of rtcdiv pin 1 enables output of rtcdiv pin rckdiv selection of rtcdiv pin output frequency 0 rtcdiv pin outputs 512 hz (1.95 ms). 1 rtcdiv pin outputs 16.384 khz (0.061 ms). note rcloe0 and rcloe2 must not be enabled at the same time. cautions 1. change ict2, ict1, and ict0 when rinte = 0. 2. when the output from rtcdiv pin is stoppe d, the output continues after a maximum of two clocks of f xt and enters the low level. while 512 hz is output, and when the output is stopped immediately after entering th e high level, a pulse of at least one clock width of f sub may be generated. 3. after the real-time counter starts operati ng, the output width of the rtcdiv pin may be shorter than as set during th e first interval period. remark f sub : subsystem clock frequency 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 353 jun 20, 2011 (5) sub-count regi ster (rsubc) the rsubc register is a 16-bit register t hat counts the reference time of 1 second of the real-time counter. it takes a value of 0000h to 7fffh and counts 1 second with a clock of 32.768 khz. rsubc can be set by a 16-bit memory manipulation instruction. reset signal generation clears this register to 0000h. cautions 1. when a correction is made by using the subcud register , the value may become 8000h or more. 2. this register is also cl eared by reset effected by wr iting the second count register. 3. the value read from this register is not guaranteed if it is read during operation, because a value that is changing is read. figure 7-6. format of sub-count register (rsubc) address: fff90h after reset: 0000h r symbol 7 6 5 4 3 2 1 0 rsubc subc7 subc6 subc5 subc4 subc3 subc2 subc1 subc0 address: fff91h after reset: 0000h r symbol 7 6 5 4 3 2 1 0 rsubc subc15 subc14 subc13 subc12 subc11 subc10 subc9 subc8 (6) second count register (sec) the sec register is an 8-bit register that takes a value of 0 to 59 (dec imal) and indicates the count value of seconds. it counts up when the sub-counter overflows. when data is written to this register, it is written to a buff er and then to the counter up to 2 clocks (32.768 khz) later. set a decimal value of 00 to 59 to this register in bcd code. sec can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-7. format of second count register (sec) address: fff92h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 sec 0 sec40 sec20 sec10 sec8 sec4 sec2 sec1 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 354 jun 20, 2011 (7) minute count register (min) the min register is an 8-bit register t hat takes a value of 0 to 59 (decimal) and indicates the count value of minutes. it counts up when the second counter overflows. when data is written to this register, it is written to a buff er and then to the counter up to 2 clocks (32.768 khz) later. even if the second count register overflows while this regist er is being written, this regi ster ignores the overflow and is set to the value written. set a decimal value of 00 to 59 to this register in bcd code. min can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-8. format of minute count register (min) address: fff93h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 min 0 min40 min20 min10 min8 min4 min2 min1 (8) hour count register (hour) the hour register is an 8-bi t register that takes a value of 00 to 23, or 01 to 12 and 21 to 32 (decimal) and indicates the count value of hours. it counts up when the minute counter overflows. when data is written to this register, it is written to a buff er and then to the counter up to 2 clocks (32.768 khz) later. even if the minute count register overflows while this register is being written, this register ignores the overflow and is set to the value written. set a decimal value of 00 to 23, or 01 to 12 and 21 to 32 to this register in bcd code. hour can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 12h. however, the value of this register is 00h if the ampm bit (bit 3 of the rtcc0 regist er) is set to 1 after reset. figure 7-9. format of hour count register (hour) address: fff94h after reset: 12h r/w symbol 7 6 5 4 3 2 1 0 hour 0 0 hour20 hour10 ho ur8 hour4 hour2 hour1 caution bit 5 (hour20) of hour in dicates am(0)/pm(1) if ampm = 0 (if the 12-hour system is selected). 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 355 jun 20, 2011 table 7-2. displayed time digits 24-hour display (ampm bit = 1) 12-hour display (ampm bit = 0) time hour register time hour register 0 00h 0 a.m. 12h 1 01h 1 a.m. 01h 2 02h 2 a.m. 02h 3 03h 3 a.m. 03h 4 04h 4 a.m. 04h 5 05h 5 a.m. 05h 6 06h 6 a.m. 06h 7 07h 7 a.m. 07h 8 08h 8 a.m. 08h 9 09h 9 a.m. 09h 10 10h 10 a.m. 10h 11 11h 11 a.m. 11h 12 12h 0 p.m. 32h 13 13h 1 p.m. 21h 14 14h 2 p.m. 22h 15 15h 3 p.m. 23h 16 16h 4 p.m. 24h 17 17h 5 p.m. 25h 18 18h 6 p.m. 26h 19 19h 7 p.m. 27h 20 20h 8 p.m. 28h 21 21h 9 p.m. 29h 22 22h 10 p.m. 30h 23 23h 11 p.m. 31h the hour register value is set to 12-hour display when the ampm bit is ?0? and to 24-hour display when the ampm bit is ?1?. in 12-hour display, the fifth bit of the ho ur register displays 0 for am and 1 for pm. (9) day count register (day) the day register is an 8-bit register that takes a value of 1 to 31 (decimal) and indicates the count value of days. it counts up when the hour counter overflows. this counter counts as follows. ? 01 to 31 (january, march, may, july, august, october, december) ? 01 to 30 (april, june, september, november) ? 01 to 29 (february, leap year) ? 01 to 28 (february, normal year) when data is written to this register, it is written to a buff er and then to the counter up to 2 clocks (32.768 khz) later. even if the hour count register overflows wh ile this register is being written, this register ignores the overflow and is set to the value written. set a decimal value of 01 to 31 to this register in bcd code. day can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 01h. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 356 jun 20, 2011 figure 7-10. format of day count register (day) address: fff96h after reset: 01h r/w symbol 7 6 5 4 3 2 1 0 day 0 0 day20 day10 day8 day4 day2 day1 (10) week count register (week) the week register is an 8-bit register that takes a value of 0 to 6 (decim al) and indicates t he count value of weekdays. it counts up in synchronization with the day counter. when data is written to this register, it is written to a buffer and then to the counter up to 2 clocks (32.768 khz) later. set a decimal value of 00 to 06 to this register in bcd code. week can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-11. format of week count register (week) address: fff95h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 week 0 0 0 0 0 week4 week2 week1 caution the value corresponding to th e month count register or the day count register is not stored in the week count register automatica lly. after reset release, set the week count register as follow. day week sunday 00h monday 01h tuesday 02h wednesday 03h thursday 04h friday 05h saturday 06h 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 357 jun 20, 2011 (11) month count register (month) the month register is an 8-bi t register that takes a value of 1 to 12 (decimal) and indicates the count value of months. it counts up when the day counter overflows. when data is written to this register, it is written to a buffer and then to the counter up to 2 clocks (32.768 khz) later. even if the day count register overflows while this r egister is being written, this register ignores the overflow and is set to the value written. set a decimal value of 01 to 12 to this register in bcd code. set a decimal value of 01 to 12 to this register in bcd code. month can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 01h. figure 7-12. format of month count register (month) address: fff97h after reset: 01h r/w symbol 7 6 5 4 3 2 1 0 month 0 0 0 month10 month8 month4 month2 month1 (12) year count register (year) the year register is an 8-bit register t hat takes a value of 0 to 99 (decimal) an d indicates the count value of years. it counts up when the month counter overflows. values 00, 04, 08, ?, 92, and 96 indicate a leap year. when data is written to this register, it is written to a buffer and then to the counter up to 2 clocks (32.768 khz) later. even if the month count register overflows while th is register is being written, this register ignores the overflow and is set to the value written. set a decimal valu e of 00 to 99 to this register in bcd code. set a decimal value of 00 to 99 to this register in bcd code. year can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-13. format of year count register (year) address: fff98h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 year year80 year40 year20 year10 year8 year4 year2 year1 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 358 jun 20, 2011 (13) watch error correction register (subcud) this register is used to correct the watch with high ac curacy when it is slow or fast by changing the value (reference value: 7fffh) that overflow s from the sub-count register (rsu bc) to the second count register. rewrite the subcud register after disabling interrupt servicing intrtc by using the interrupt mask flag register. furthermore, after rewriting the subcud register, enable interrupt servicing after clearing the interrupt request flag (rtcif) and constant-period interrupt status flag (rifg). subcud can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-14. format of watch e rror correction register (subcud) address: fff99h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 subcud dev f6 f5 f4 f3 f2 f1 f0 dev setting of watch error correction timing 0 corrects watch error when the second digits are at 00, 20, or 40 (every 20 seconds). 1 corrects watch error only when the second digits are at 00 (every 60 seconds). writing to the subcud register at the following timing is prohibited. ? when dev = 0 is set: for a period of sec = 00h, 20h, 40h ? when dev = 1 is set: for a period of sec = 00h f6 setting of watch error correction value 0 increases by {(f5, f4, f3, f2, f1, f0) ? 1} 2. 1 decreases by {(/f5, /f4, /f3, /f2, /f1, /f0) + 1} 2. when (f6, f5, f4, f3, f2, f1, f0) = (*, 0, 0, 0, 0, 0, *), the watch error is not corrected. * is 0 or 1. /f5 to /f0 are the inverted values of the corresponding bits (000011 when 111100). range of correction value: (when f6 = 0) 2, 4, 6, 8, ? , 120, 122, 124 (when f6 = 1) ? 2, ? 4, ? 6, ? 8, ? , ? 120, ? 122, ? 124 the range of value that can be corrected by using the watch error correction register (subcud) is shown below. dev = 0 (correction every 20 seconds) dev = 1 (correction every 60 seconds) correctable range ? 189.2 ppm to 189.2 ppm ? 63.1 ppm to 63.1 ppm maximum excludes quantization error 1.53 ppm 0.51 ppm minimum resolution 3.05 ppm 1.02 ppm remark if a correctable range is ? 63.1 ppm or lower and 63.1 ppm or higher, set 0 to dev. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 359 jun 20, 2011 (14) alarm minute register (alarmwm) this register is used to set minutes of alarm. alarmwm can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. caution set a decimal value of 00 to 59 to this register in bcd code. if a value outside the range is set, the alarm is not detected. figure 7-15. format of ala rm minute register (alarmwm) address: fff9ah after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 alarmwm 0 wm40 wm20 wm10 wm8 wm4 wm2 wm1 (15) alarm hour register (alarmwh) this register is used to set hours of alarm. alarmwh can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 12h. however, the value of this register is 00h if the ampm bit (bit 3 of the rtcc0 regist er) is set to 1 after reset. caution set a decimal value of 00 to 23, or 01 to 12 and 21 to 32 to this register in bcd code. if a value outside the range is set, the alarm is not detected. figure 7-16. format of alarm hour register (alarmwh) address: fff9bh after reset: 12h r/w symbol 7 6 5 4 3 2 1 0 alarmwh 0 0 wh20 wh10 wh8 wh4 wh2 wh1 caution bit 5 (wh20) of alarmwh i ndicates am(0)/pm(1) if ampm = 0 (if the 12-hour system is selected). 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 360 jun 20, 2011 (16) alarm week register (alarmww) this register is used to set date of alarm. alarmww can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-17. format of alarm week register (alarmww) address: fff9ch after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 alarmww 0 ww6 ww5 ww4 ww3 ww2 ww1 ww0 here is an example of setting the alarm. day 12-hour display 24-hour display time of alarm sunday w w 0 monday w w 1 tuesday w w 2 wednesday w w 3 thursday w w 4 friday w w 5 saturday w w 6 hour 10 hour 1 minute 10 minute 1 hour 10 hour 1 minute 10 minute 1 every day, 0:00 a.m. 1 1 1 1 1 1 1 1 2 0 0 0 0 0 0 every day, 1:30 a.m. 1 1 1 1 1 1 1 0 1 3 0 0 1 3 0 every day, 11:59 a.m. 1 1 1 1 1 1 1 1 1 5 9 1 1 5 9 monday through friday, 0:00 p.m. 0 1 1 1 1 1 0 3 2 0 0 1 2 0 0 sunday, 1:30 p.m. 1 0 0 0 0 0 0 2 1 3 0 1 3 3 0 monday, wednesday, friday, 11:59 p.m. 0 1 0 1 0 1 0 3 1 5 9 2 3 5 9 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 361 jun 20, 2011 (17) port mode register 3 (pm3) this register sets port 3 input/output in 1-bit units. when using the p30/rtc1hz/to00/ti03/intp1 pin for real-time counter correction clock output, the p31/rtcdiv/rtccl/ti00/to03/pclbuz1/intp2 pin for real -time counter clock output, set pm30, pm31 and the output latches of p30, p31 to 0. pm3 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generati on sets pm3 to ffh. figure 7-18. format of port mode register 3 (pm3) ? 78k0r/lf3 address: fff23h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm3 1 1 1 1 pm33 pm32 pm31 pm30 ? 78k0r/lg3, 78k0r/lh3 address: fff23h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm3 1 1 1 pm34 pm33 pm32 pm31 pm30 pm3n p3n pin i/o mode selection (n = 0 to 4) 0 output mode (output buffer on) 1 input mode (output buffer off) 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 362 jun 20, 2011 7.4 real-time counter operation 7.4.1 starting operation of real-time counter figure 7-19. procedure for starting operation of real-time counter setting ampm, ct2 to ct0 setting min rtce = 0 setting sec (clearing rsubc) start intrtc = 1? stops counter operation. selects 12-/24-hour system and interrupt (intrtc). sets second count register. sets minute count register. no yes setting hour sets hour count register. setting week sets week count register. setting day sets day count register. setting month sets month count register. setting year sets year count register. clearing if flags of interrupt clears interrupt request flags (rtcif, rtciif). clearing mk flags of interrupt clears interrupt mask flags (rtcmk, rtcimk). rtce = 1 note2 starts counter operation. reading counter rtcen = 1 note1 supplies input clock. notes 1. first set rtcen to 1, while o scillation of the subsystem clock (f sub ) is stable. 2. confirm the procedure described in 7.4.2 shifting to stop mode after starting operation when shifting to stop mode without waiting for intrtc = 1 after rtce = 1. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 363 jun 20, 2011 yes rtce = 1 rwait = 1 no yes rwait = 0 no rwst = 1 ? rwst = 0 ? stop mode rtce = 1 stop mode waiting at least for 2 f sub clocks sets to counter operation start shifts to stop mode sets to counter operation start sets to stop the sec to year counters, reads the counter value, write mode checks the counter wait status sets the counter operation shifts to stop mode example 2 example 1 7.4.2 shifting to stop mode after starting operation perform one of the following processing when shifting to stop mode immediately after setting rtce to 1. however, after setting rtce to 1, this processing is not required when shifting to stop mode after the first intrtc interrupt has occurred. ? shifting to stop mode when at least two subsystem clocks (f sub ) (about 62 s) have elapsed after setting rtce to 1 (see figure 7-20 , example 1 ). ? checking by polling rwst to become 1, after setting rtce to 1 and then setting rwait to 1. afterward, setting rwait to 0 and shifting to stop mode after che cking again by polling that rwst has become 0 (see figure 7-20 , example 2 ). figure 7-20. procedure for shifting to stop mode after setting rtce to 1 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 364 jun 20, 2011 7.4.3 reading/writing real-time counter read or write the counter after setting 1 to rwait first. figure 7-21. procedure for reading real-time counter reading min rwait = 1 reading sec start rwst = 1? stops sec to year counters. mode to read and write count values reads second count register. reads minute count register. no yes reading hour reads hour count register. reading week reads week count register. reading day reads day count register. reading month reads month count register. reading year reads year count register. rwait = 0 rwst = 0? note no yes sets counter operation. checks wait status of counter. end note be sure to confirm that rwst = 0 before setting stop mode. caution complete the series of opera tions of setting rwait to 1 to cl earing rwait to 0 within 1 second. remark sec, min, hour, week, day, month, and year may be read in any sequence. all the registers do not have to be set and only some registers may be read. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 365 jun 20, 2011 figure 7-22. procedure for writing real-time counter writing min rwait = 1 writing sec start rwst = 1? stops sec to year counters. mode to read and write count values no yes writing hour writing week writing day writing month writing year rwait = 0 rwst = 0? note no yes sets counter operation. checks wait status of counter. end writes second count register. writes minute count register. writes hour count register. writes week count register. writes day count register. writes month count register. writes year count register. note be sure to confirm that rwst = 0 before setting stop mode. caution complete the series of opera tions of setting rwait to 1 to cl earing rwait to 0 within 1 second. remark sec, min, hour, week, day, month, a nd year may be written in any sequence. all the registers do not have to be set an d only some registers may be written. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 366 jun 20, 2011 7.4.4 setting alarm of real-time counter set time of alarm after setting 0 to wale first. figure 7-23. alarm setting procedure wale = 0 setting alarmwm start intrtc = 1? match operation of alarm is invalid. sets alarm minute register. alarm processing yes walie = 1 interrupt is generated when alarm matches. setting alarmwh sets alarm hour register. setting alarmww sets alarm week register. wale = 1 match operation of alarm is valid. wafg = 1? no yes constant-period interrupt servicing match detection of alarm no remarks 1. alarmwm, alarmwh, and alarmww may be written in any sequence. 2. fixed-cycle interrupts and alarm match interrupts us e the same interrupt source (intrtc). when using these two types of interrupts at the same time, wh ich interrupt occurred can be judged by checking the fixed-cycle interrupt status flag (rifg) and the alarm detection status flag (wafg) upon intrtc occurrence. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 367 jun 20, 2011 7.4.5 1 hz output of real-time counter figure 7-24. 1 hz output setting procedure rcloe1 = 1 rtce = 0 rtce = 1 enables output of rtc1hz pin (1 hz). start output start from rtc1hz pin stops counter operation. starts counter operation. 7.4.6 32.768 khz output of real-time counter figure 7-25. 32.768 khz output setting procedure rcloe0 = 1 rtce = 0 rtce = 1 start 32.768 khz output start from rtccl pin stops counter operation. enables output of rtccl pin (32.768 khz). starts counter operation. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 368 jun 20, 2011 7.4.7 512 hz or 16.384 khz output of real-time counter figure 7-26. 512 hz or 16.384 khz output setting procedure rtce = 0 rtce = 1 start stops counter operation. rcloe2 = 1 output of rtcdiv pin is enabled. 512 hz output: rckdiv = 0 16.384 khz output: rckdiv = 1 selects output frequency of rtcdiv pin. starts counter operation. 512 hz or 16.384 khz output start from rtcdiv pin 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 369 jun 20, 2011 7.4.8 example of watch error correction of real-time counter the watch can be corrected with high accuracy when it is slow or fast, by setting a value to the watch error correction register. example of calculating the correction value the correction value used when correctin g the count value of the sub-count register (rsubc) is calculated by using the following expression. set dev to 0 when the correction range is ? 63.1 ppm or less, or 63.1 ppm or more. (when dev = 0) correction value note = number of correction counts in 1 minute 3 = (oscillation frequency target frequency ? 1) 32768 60 3 (when dev = 1) correction value note = number of correction counts in 1 minute = (oscillation frequency target frequency ? 1) 32768 60 note the correction value is the watch error correction value calculated by using bits 6 to 0 of the watch error correction regist er (subcud). (when f6 = 0) correction value = {(f5, f4, f3, f2, f1, f0) ? 1} 2 (when f6 = 1) correction value = ? {(/f5, /f4, /f3, /f 2, /f1, /f0) + 1} 2 when (f6, f5, f4, f3, f2, f1, f0) is (*, 0, 0, 0, 0, 0, *), watch error correct ion is not performed. ?*? is 0 or 1. /f5 to /f0 are bit-inverted values (000011 when 111100). remarks 1. the correction value is 2, 4, 6, 8, ? 120, 122, 124 or ? 2, ? 4, ? 6, ? 8, ? ? 120, ? 122, ? 124. 2. the oscillation frequency is the subsystem clock (f sub ). it can be calculated from the 32.768 khz output frequen cy of the rtccl pin or the output frequency of the rtc1hz pin 32768 when the watch error correction register is set to its initial value (00h). 3. the target frequency is the frequency resulting after correction performed by using the watch error correction register. 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 370 jun 20, 2011 correction example <1> example of correcting from 32772.3 hz to 32768 hz (32772.3 hz ? 131.2 ppm) [measuring the oscillation frequency] the oscillation frequency note of each product is measured by outputti ng about 32 khz from the rtccl pin or outputting about 1 hz from the rtc1hz pin when the watch erro r correction register is set to its initial value (00h). note see 7.4.5 1 hz output of real-time counter for the setting procedure of outputti ng about 1 hz from the rtc1hz pin, and 7.4.6 32.768 khz output of real-time counter for the setting procedure of outputting about 32 khz from the rtccl pin. [calculating the correction value] (when the output frequency from t he rtccl pin is 32772.3 hz) if the target frequency is assumed to be 32768 hz (32772.3 hz ? 131.2 ppm), the correction range for ? 131.2 ppm is ? 63.1 ppm or less, so assume dev to be 0. the expression for calculating the correct ion value when dev is 0 is applied. correction value = number of correction counts in 1 minute 3 = (oscillation frequency target frequency ? 1) 32768 60 3 = (32772.3 32768 ? 1) 32768 60 3 = 86 [calculating the values to be set to (f6 to f0)] (when the correction value is 86) if the correction value is 0 or more (w hen delaying), assume f6 to be 0. calculate (f5, f4, f3, f2, f1, f0) from the correction value. {(f5, f4, f3, f2, f1, f0) ? 1} 2 = 86 (f5, f4, f3, f2, f1, f0) = 44 (f5, f4, f3, f2, f1, f0) = (1, 0, 1, 1, 0, 0) consequently, when correcting from 32772.3 hz to 32768 hz (32772.3 hz ? 131.2 ppm), setting the correction register such that dev is 0 and the correction value is 86 (bits 6 to 0 of subcud: 0101100) results in 32768 hz (0 ppm). figure 7-27 shows the operation when (dev, f6, f5, f4, f3, f2, f1, f0) is (0, 0, 1, 0, 1, 1, 0, 0). 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 371 jun 20, 2011 figure 7-27. operation when (dev, f6, f5, f4, f3 , f2, f1, f0) = (0, 0, 1, 0, 1, 1, 0, 0) rsubc count value sec 00 01 8055h 0000h 0001h 7fffh 0000h 8054h 40 8055h 0000h 8054h 8055h 0000h 8054h 19 0000h 0001h 7fffh 20 39 0000h 0001h 7fffh 0000h 0001h 7fffh 59 00 8055h 0000h 8054h 7fffh + 56h (86) 7fffh + 56h (86) 7fffh + 56h (86) 7fffh+56h (86) count start 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 372 jun 20, 2011 correction example <2> example of correcting from 32767.4 hz to 32768 hz (32767.4 hz + 18.3 ppm) [measuring the oscillation frequency] the oscillation frequency note of each product is measured by outputti ng about 32 khz from the rtccl pin or outputting about 1 hz from the rtc1hz pin when the watch erro r correction register is set to its initial value (00h). note see 7.4.5 1 hz output of real-time counter for the setting procedure of outputti ng about 1 hz from the rtc1hz pin, and 7.4.6 32.768 khz output of real-time counter for the setting procedure of outputting about 32 khz from the rtccl pin. [calculating the correction value] (when the output frequency from the rtc1hz pin is 0.9999817 hz) oscillation frequency = 32768 0.9999817 32767.4 hz assume the target frequency to be 32768 hz (32767.4 hz + 18.3 ppm) and dev to be 1. the expression for calculating the correct ion value when dev is 1 is applied. correction value = number of correction counts in 1 minute = (oscillation frequency target frequency ? 1) 32768 60 = (32767.4 32768 ? 1) 32768 60 = ? 36 [calculating the values to be set to (f6 to f0)] (when the correction value is ? 36) if the correction value is 0 or less (when speeding up), assume f6 to be 1. calculate (f5, f4, f3, f2, f1, f0) from the correction value. ? {(/f5, /f4, /f3, /f2, /f1, /f0) + 1} 2 = ? 36 (/f5, /f4, /f3, /f2, /f1, /f0) = 17 (/f5, /f4, /f3, /f2, /f1, /f0) = (0, 1, 0, 0, 0, 1) (f5, f4, f3, f2, f1, f0) = (1, 0, 1, 1, 1, 0) consequently, when correcting from 32767.4 hz to 32768 hz (32767.4 hz + 18.3 ppm), setting the correction register such that dev is 1 and the correction value is ? 36 (bits 6 to 0 of subcud: 1101110) results in 32768 hz (0 ppm). figure 7-28 shows the operation when (dev, f6, f5, f4, f3, f2, f1, f0) is (1, 1, 1, 0, 1, 1, 1, 0). 78k0r/lx3 chapter 7 real-time counter r01uh0004ej0501 rev.5.01 373 jun 20, 2011 figure 7-28. operation when (dev, f6, f5, f4, f3 , f2, f1, f0) = (1, 1, 1, 0, 1, 1, 1, 0) rsubc count value sec 00 01 7fdbh 0000h 0001h 7fffh 0000h 7fdah 40 19 0000h 0001h 7fffh 0000h 0001h 7fffh 20 39 0000h 0001h 7fffh 0000h 0001h 7fffh 0000h 0001h 7fffh 59 00 7fdbh 0000h 7fdah 7fffh ? 24h (36) 7fffh ? 24h (36) count start 78k0r/lx3 chapter 8 watchdog timer r01uh0004ej0501 rev.5.01 374 jun 20, 2011 chapter 8 watchdog timer 8.1 functions of watchdog timer the watchdog timer is mounted onto all 78k0r/lx3 microcontroller products. the watchdog timer operates on the internal low-speed oscillation clock. the watchdog timer is used to detect an inadvertent program l oop. 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 when a reset occurs due to the watchdog timer, bit 4 (wdrf) of the reset control flag register (resf) is set to 1. for details of resf, see chapter 22 reset function . when 75% of the overflow time is reached, an interval interrupt can be generated. 78k0r/lx3 chapter 8 watchdog timer r01uh0004ej0501 rev.5.01 375 jun 20, 2011 8.2 configuration of watchdog timer the watchdog timer includes the following hardware. table 8-1. configuration of watchdog timer item configuration control register watchdog timer enable register (wdte) how the counter operation is controlled, overflow time, window open period, and interval interrupt are set by the option byte. table 8-2. setting of option bytes and watchdog timer setting of watchdog timer option byte (000c0h) watchdog timer interval interrupt bit 7 (wdtint) 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) controlling counter operation of watchdog timer (in halt/stop mode) bit 0 (wdstbyon) remark for the option byte, see chapter 26 option byte . figure 8-1. block diagram of watchdog timer f il wdton of option byte (000c0h) wdtint of option byte (000c0h) interval time controller (count value overflow time 3/4) interval time interrupt wdcs2 to wdcs0 of option byte (000c0h) clock input controller 20-bit counter selector overflow signal reset output controller internal reset signal count clear signal window size decision signal window size check watchdog timer enable register (wdte) write detector to wdte except ach internal bus window1 and window0 of option byte (000c0h) f il /2 7 to f il /2 17 78k0r/lx3 chapter 8 watchdog timer r01uh0004ej0501 rev.5.01 376 jun 20, 2011 8.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 signal generation sets this register to 9ah or 1ah note . figure 8-2. format of watchdog timer enable register (wdte) 0 1 2 3 4 5 6 7 symbol wdte address: fffabh after reset: 9ah/1ah note r/w note the wdte reset value differs depending on the wdto n setting value of the option byte (000c0h). 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 writte n to wdte, an internal r eset signal is generated. 2. if a 1-bit memory manipulation instruction is executed for wdte, an internal reset signal is generated. 3. the value read from wdte is 9ah/1ah (this differs fr om the written value (ach)). 78k0r/lx3 chapter 8 watchdog timer r01uh0004ej0501 rev.5.01 377 jun 20, 2011 8.4 operation of watchdog timer 8.4.1 controlling operation of watchdog timer 1. when the watchdog timer is used, its operati on is specified by the option byte (000c0h). ? enable counting operation of the watchdog timer by setti ng bit 4 (wdton) of the option byte (000c0h) to 1 (the counter starts operating after a re set release) (for details, see chapter 26 ). wdton watchdog timer counter 0 counter operation disabled (counting stopped after reset) 1 counter operation enabled (counting started after reset) ? set an overflow time by using bits 3 to 1 (wdcs2 to wdcs0) of the option byte (000c0h) (for details, see 8.4.2 and chapter 26 ). ? set a window open period by using bits 6 and 5 (wi ndow1 and window0) of the option byte (000c0h) (for details, see 8.4.3 and chapter 26 ). 2. after a reset release, the watchdog timer starts counting. 3. by writing ?ach? to wdte after the watchdog timer star ts counting and before the overflow time set by the option byte, the watchdog timer is cleared and starts counting again. 4. after that, write wdte the second time or later a fter a reset release during the window open period. if wdte is written during a window close 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. an internal reset signal is generated in the following cases. ? 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 cautions 1. when data is written to wdte for the first time after reset release, the wa tchdog timer is cleared in any timing regardless of the window open ti me, as long as the register is written before the overflow time, 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 il seconds. 3. the watchdog timer can be cleared imme diately before the c ount value overflows. 78k0r/lx3 chapter 8 watchdog timer r01uh0004ej0501 rev.5.01 378 jun 20, 2011 cautions 4. the operation of th e watchdog timer in the halt and stop modes differs as follows depending on the set value of bit 0 (wdstbyon) of the option byte (000c0h). wdstbyon = 0 wdstbyon = 1 in halt mode in stop mode watchdog timer operation stops. watchdog timer operation continues. if wdstbyon = 0, the watchdog timer resum es counting after the halt or stop mode is released. at this time, the counter is cleared to 0 and counting starts. when operating with th e x1 oscillation clock after releasi ng the stop mode, the cpu starts operating after the oscillation stabilization time has elapsed. therefore, if the period be tween the stop mode release and the watchdog timer overflow is short, an overflow occurs during the oscilla tion stabilization time, causing a reset. consequently, set the overfl ow time in consideration of the oscillation stabilization time when operating with the x1 oscillation clock and when the watchdog timer is to be cleared after the stop mode release by an interval interrupt. 5. the watchdog timer continues its operati on during self-programming of the flash memory and eeprom tm emulation. during processing, the interr upt acknowledge time is delayed. set the overflow time and window size taki ng this delay into consideration. 8.4.2 setting overflow time of watchdog timer set the overflow time of the watchdog timer by using bits 3 to 1 (wdcs2 to wdcs0) of the option byte (000c0h). if an overflow occurs, an internal reset signal is generated. the present count is cleared and the watchdog timer starts counting again by writing ?ach? to wdte during the window open period before the overflow time. the following overflow time is set. table 8-3. setting of overflow time of watchdog timer wdcs2 wdcs1 wdcs0 overflow time of watchdog timer (f il = 33 khz (max.)) 0 0 0 2 7 /f il (3.88 ms) 0 0 1 2 8 /f il (7.76 ms) 0 1 0 2 9 /f il (15.52 ms) 0 1 1 2 10 /f il (31.03 ms) 1 0 0 2 12 /f il (124.12 ms) 1 0 1 2 14 /f il (496.48 ms) 1 1 0 2 15 /f il (992.97 ms) 1 1 1 2 17 /f il (3971.88 ms) caution the watchdog timer conti nues its operation during self-program ming of the flash memory and eeprom emulation. during processi ng, the interrupt acknowledge time is delayed. set the overflow time and window size taking th is delay into consideration. remark f il : internal low-speed oscillation clock frequency 78k0r/lx3 chapter 8 watchdog timer r01uh0004ej0501 rev.5.01 379 jun 20, 2011 8.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, wi ndow0) of the option byte (000c0h). the outline of the window is as follows. ? if ?ach? is written to wdte during the window open period, the watchdog timer is cleared and starts counting again. ? even if ?ach? is written to wdte during the window clos e period, an abnormality is detected and an internal reset signal is generated. example : if the window open period is 50% window close period (50%) window close period (50%) 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 when data is written to wdte for the first time after reset release, the watchdog timer is cleared in any timing regardless of the window open time, as long as the register is written before the overflow time, and the watchdog timer starts counting again. the window open period to be set is as follows. table 8-4. setting window op en period of watchdog timer window1 window0 window open period of watchdog timer 0 0 setting prohibited 0 1 50% 1 0 75% 1 1 100% cautions 1. the watchdog timer continues its ope ration during self-programming of the flash memory and eeprom emulation. during pro cessing, the interrupt acknowledge time is delayed. set the overflow time and window size taki ng this delay into consideration. 2. when bit 0 (wdstbyon) of the option byte (000c0h) = 0, the window open period is 100% regardless of the values of window1 and window0. 78k0r/lx3 chapter 8 watchdog timer r01uh0004ej0501 rev.5.01 380 jun 20, 2011 remark if the overflow time is set to 2 10 /f il , the window close time and open time are as follows. (2.7 v v dd 5.5 v) setting of window open period 50% 75% 100% window close time 0 to 18.96 ms 0 to 9.48 ms none window open time 18.96 to 31.03 ms 9.48 to 31.03 ms 0 to 31.03 ms 78k0r/lx3 chapter 9 clock output/buzzer output controller r01uh0004ej0501 rev.5.01 381 jun 20, 2011 chapter 9 clock output/buzzer output controller 9.1 functions of clock output/buzzer output controller the clock output/buzzer output controller is mounted onto all 78k0r/ lx3 microcontroller products. the clock output controller is intended for carrier outpu t during remote controlled transmission and clock output for supply to peripheral ics. buzzer output is a function to output a square wave of buzzer frequency. one pin can be used to output a clock or buzzer sound. two output pins, pclbuz0 and pclbuz1, are available. pclbuz0 outputs a clock selected by cl ock output select register 0 (cks0). pclbuz1 outputs a clock selected by cl ock output select register 1 (cks1). figure 9-1 shows the block diagram of clock output/buzzer output controller. figure 9-1. block diagram of clo ck output/buzzer output controller f main f sub pcloe0 0 0 0 pcloe0 5 3 pclbuz0 note /p32/ ti01/to01/intp5 pclbuz1 note /p31/ ti00/to03/rtcdiv/ rtccl/intp2 csel0 ccs02 ccs01 ccs00 pm31 pcloe1 0 0 0 csel1 ccs12 ccs11 ccs10 8 pcloe1 8 f main /2 11 to f main /2 13 clock/buzzer controller internal bus clock output select register 1 (cks1) prescaler prescaler selector selector clock/buzzer controller output latch (p31) internal bus clock output select register 0 (cks0) output latch (p32) f main /2 11 to f main /2 13 f main to f main /2 4 f main to f main /2 4 f sub to f sub /2 7 f sub to f sub /2 7 pm32 note the pclbuz0 and pclbuz1 pins can out put a clock of up to 10 mhz at 2.7 v v dd . setting a clock exceeding 5 mhz at v dd < 2.7 v is prohibited. 78k0r/lx3 chapter 9 clock output/buzzer output controller r01uh0004ej0501 rev.5.01 382 jun 20, 2011 9.2 configuration of clock output/buzzer output controller the clock output/buzzer output controller includes the following hardware. table 9-1. configuration of clock output/buzzer output controller item configuration control registers clock output select registers 0, 1 (cks0, cks1) port mode register 3 (pm3) port register 3 (p3) 9.3 registers controlling clock ou tput/buzzer output controller the following two registers are used to control the clock output/buzzer output controller. ? clock output select registers 0, 1 (cks0, csk1) ? port mode register 3 (pm3) (1) clock output select regi sters 0, 1 (cks0, cks1) these registers set output enable/disable for clo ck output or for the buzzer frequency output pin (pclbuz0/pclbuz1), and set the output clock. select the clock to be output from pclbuz0 by using cks0. select the clock to be output from pclbuz1 by using cks1. cks0 and cks1 are set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. 78k0r/lx3 chapter 9 clock output/buzzer output controller r01uh0004ej0501 rev.5.01 383 jun 20, 2011 figure 9-2. format of clock output select register n (cksn) address: fffa5h (cks0), fffa6h (cks1) after reset: 00h r/w symbol <7> 6 5 4 3 2 1 0 cksn pcloen 0 0 0 cseln ccsn2 ccsn1 ccsn0 pcloen pclbuzn output enabl e/disable specification 0 output disable (default) 1 output enable pclbuzn output clock selection cseln ccsn2 ccsn1 ccsn0 f main = 5 mhz f main = 10 mhz f main = 20 mhz 0 0 0 0 f main 5 mhz 10 mhz note setting prohibited note 0 0 0 1 f main /2 2.5 mhz 5 mhz 10 mhz note 0 0 1 0 f main /2 2 1.25 mhz 2.5 mhz 5 mhz 0 0 1 1 f main /2 3 625 khz 1.25 mhz 2.5 mhz 0 1 0 0 f main /2 4 312.5 khz 625 khz 1.25 mhz 0 1 0 1 f main /2 11 2.44 khz 4.88 khz 9.76 khz 0 1 1 0 f main /2 12 1.22 khz 2.44 khz 4.88 khz 0 1 1 1 f main /2 13 610 hz 1.22 khz 2.44 khz 1 0 0 0 f sub 32.768 khz 1 0 0 1 f sub /2 16.384 khz 1 0 1 0 f sub /2 2 8.192 khz 1 0 1 1 f sub /2 3 4.096 khz 1 1 0 0 f sub /2 4 2.048 khz 1 1 0 1 f sub /2 5 1.024 khz 1 1 1 0 f sub /2 6 512 hz 1 1 1 1 f sub /2 7 256 hz note setting an output clock exceeding 10 mhz is prohibited when 2.7 v v dd . setting a clock exceeding 5 mhz at v dd < 2.7 v is also prohibited. cautions 1. change the output clock after disabling clock output (pcloen = 0). 2. if the selected clock (f main or f sub ) stops during clock output (pcloen = 1), the output becomes undefined. 3. to shift to stop mode when the main system clock is selected (cseln = 0), set pcloen = 0 before executing the stop instru ction. when the subsystem clock is selected (cseln = 1), pcloen = 1 can be set because the cl ock can be output in stop mode. remarks 1. n = 0, 1 2. f main : main system clock frequency 3. f sub : subsystem clock frequency 78k0r/lx3 chapter 9 clock output/buzzer output controller r01uh0004ej0501 rev.5.01 384 jun 20, 2011 (2) port mode register 3 (pm3) this register sets port 3 input/output in 1-bit units. when using the p31/pclbuz1/ti00/ to03/rtcdiv/rtccl/intp2 and p32/pclb uz0/ti01/to01/intp5 pins for clock output/buzzer output, clear pm31 and pm32 and the output latches of p32 and p31 to 0. pm3 is set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets this register to ffh. figure 9-3. format of port mode register 3 (pm3) address: fff23h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm3 1 1 1 pm34 pm33 pm32 pm31 pm30 pm3n p3n pin i/o mode selection (n = 0 to 4) 0 output mode (output buffer on) 1 input mode (output buffer off) 9.4 operations of clock output/buzzer output controller one pin can be used to output a clock or buzzer sound. two output pins, pclbuz0 and pclbuz1, are available. pclbuz0 outputs a clock/buzzer selected by clock output select register 0 (cks0). pclbuz1 outputs a clock/buzzer selected by clock output select register 1 (cks1). 9.4.1 operation as output pin pclbuzn is output as the following procedure. <1> select the output frequency with bits 0 to 3 (ccsn0 to cc sn2, cseln) of the clock out put select register (cksn) of the pclbuzn pin (output in disabled status). <2> set bit 7 (pcloen) of cksn to 1 to enable clock/buzzer output. remark the controller used for outputting t he clock starts or stops outputting the clock one clock after enabling or disabling clock output (pcloen) is switched. at this time, pulses with a narrow width are not output. figure 9-4 shows enabling or stopping output using pclo en and the timing of outputting the clock. figure 9-4. remote control output application example pcloen 1 clock elapsed narrow pulses are not recognized clock output remark n = 0, 1 78k0r/lx3 r01uh0004ej0501 rev.5.01 385 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) pd78f150xa pd78f151xa item 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) 78k0r/lf3 (80 pins) 78k0r/lg3 (100 pins) 78k0r/lh3 (128 pins) a/d converter 8 ch 12 ch 8 ch 12 ch resolution 12 bits 10 bits 10.1 function of a/d converter the a/d converter is a 12-bit resolution or 10-bit resolution c onverter that converts analog input signals into digital values, and consists of up to twelve channels of a/d converter analog inputs (ani0 to ani10, ani15). ani1, ani4, and ani7 are alternatively used with operati onal amplifier 0, 1, and 2 outputs (amp0o, amp1o, and amp2o) as pin functions. accordingly, operational amplifier outputs can be used as analog input sources. the following four a/d converter operation modes are available. ? software trigger mode (continuous conversion mode) ? software trigger mode (single conversion mode) ? timer trigger mode (continuous conversion mode) ? timer trigger mode (single conversion mode) 78k0r/lx3 r01uh0004ej0501 rev.5.01 386 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) figure 10-1. block diagra m of 12-bit a/d converter ( pd78f150xa) remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 intad adcs adscm fr2 fr1 adce fr0 av ss 4 lv1 lv0 5 adpc3 adpc2 adpc1 adpc0 5 adpc4 ads3 ads2 ads1 ads0 2 adtmd adtrs ani0/amp0-/p20 ani1/amp0o/p21 ani2/amp0+/p22 ani3/amp1-/p23 ani4/amp1o/p24 ani5/amp1+/p25 ani6/amp2-/p26 ani7/amp2o/p27 ani8/amp2+/p150 ani9/p151 ani10/p152 ani15/av refm /p157 av refp /v refout av ss adcs bit adref bit ad refm ad refp av refm / ani15/p157 vrsel bit vron, vrgv bit av dd0 adref vrgv vron tap selector series resistor string a/d voltage comparator successive approximation register (sar) controller timer trigger 0, 1 selector sample & hold circuit a/d conversion result register (adcr) a/d converter mode register (adm) analog reference voltage control register (advrc) internal bus analog input channel specification register (ads) a/d port configuration register (adpc) a/d converter mode register1 (adm1) selector voltage reference circuit 78k0r/lx3 r01uh0004ej0501 rev.5.01 387 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) figure 10-2. block diagram of 10-bit a/d converter ( pd78f151xa) intad adcs adscm fr2 fr1 adce fr0 av ss 4 lv1 lv0 5 adpc3 adpc2 adpc1 adpc0 5 adpc4 ads3 ads2 ads1 ads0 2 adtmd adtrs ani0/amp0-/p20 ani1/amp0o/p21 ani2/amp0+/p22 ani3/amp1-/p23 ani4/amp1o/p24 ani5/amp1+/p25 ani6/amp2-/p26 ani7/amp2o/p27 ani8/amp2+/p150 ani9/p151 ani10/p152 ani15/av refm /p157 av refp /v refout av ss adcs bit adref bit ad refm ad refp av refm / ani15/p157 vrsel bit vron, vrgv bit av dd0 vrgv tap selector series resistor string a/d voltage comparator successive approximation register (sar) controller timer trigger 0, 1 selector sample & hold circuit a/d conversion result register (adcr) a/d converter mode register (adm) analog reference voltage control register (advrc) internal bus analog input channel specification register (ads) a/d port configuration register (adpc) a/d converter mode register1 (adm1) selector voltage reference circuit r emarks 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 78k0r/lx3 r01uh0004ej0501 rev.5.01 388 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) 10.2 configuration of a/d converter the a/d converter includes the following hardware. (1) ani0 to ani10, ani15 pins these are the analog input pins of the a/d converter. they input analog signals to be converted into digital signals. pins other than the one selected as the anal og input pin can be used as i/o port pins. remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 (2) sample & hold circuit the sample & hold circuit samples each of the analog input voltages sequentially sent from the input circuit, and sends them to the a/d voltage comparat or. this circuit also holds the sampled analog input voltage during a/d conversion. (3) series resistor string the series resistor string is connected between ad refp and ad refm , and generates a voltage to be compared with the sampled voltage value. figure 10-3. circuit configuration of series resistor string adcs series resistor string ad refp p-ch ad refm (4) voltage comparator the voltage comparator compares the sampled voltage value and the output volt age of the series resistor string. (5) successive approximation register (sar) this register converts the result of comparison by the voltage comparator, star ting from the most significant bit (msb). when the voltage value is converted into a digital value down to the least significant bit (lsb) (end of a/d conversion), the contents of the sar register are transferred to the a/d conversion result register (adcr). 78k0r/lx3 r01uh0004ej0501 rev.5.01 389 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (6) 12-bit a/d conversion result register, 10-bi t a/d conversion result register (adcr) the a/d conversion result is loaded from the successive approximation register to this register each time a/d conversion is completed, and the adcr regi ster holds the a/d conversion result in its lower 12 bits (the higher 4 bits are fixed to 0). 10-bit a/d conversion result register does not fix its lower 2 bits. (7) 8-bit a/d conversion result register (adcrh) the a/d conversion result is loaded from the successive approximation register to this register each time a/d conversion is completed, and the adcrh register stores the higher 8 bi ts of the a/d conversion result. (8) controller this circuit controls the conversion time of an input analog si gnal that is to be converted into a digital signal, as well as starting and stopping of the conver sion operation. when a/d conversion has been completed, this controller generates intad. (9) av dd0, av dd pin this pin inputs an analog power to the a/d converter. w hen one or more of the pins of ports 2 and 15 are used as the digital port pins, make av dd0 the same potential as ev dd or v dd . (10) av ss pin this is the ground potential pi n of the a/d converter. always use this pi n at the same potential as that of the v ss pin even when the a/d converter is not used. the ground potential (av ss ) can also be used as the negative reference voltage (ad refm ) of the a/d converter. to use av ss as ad refm , clear the adref bit of the advrc register to 0. (11) av refp /v refout pin this pin is used to externally input the reference voltage (av refp ) of the a/d converter or output the voltage (v refout ) generated by the voltage reference. to use av refp as the positive reference voltage (ad refp ) of the a/d converter, clear the vron bit of the advrc register to 0. to use v refout as ad refp , set the vron bit to 1. the analog signal input to ani0 to ani10, ani15 is conv erted into a digital signal, based on the voltage applied across ad refp and ad refm . (12) av refm pin this pin is used to externally input the reference voltage (av refm ) of the a/d converter. to use av refm as the negative reference voltage (ad refm ) of the a/d converter, set the adre f bit of the advrc register to 1. remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 (13) av ref pin this pin is used to externally input the reference voltage. 78k0r/lx3 r01uh0004ej0501 rev.5.01 390 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) 10.3 registers used in a/d converter the a/d converter uses t he following ten registers. ? peripheral enable register 0 (per0) ? a/d converter mode register (adm) ? a/d converter mode register 1 (adm1) ? analog reference voltage control register (advrc) ? 12-bit a/d conversion result register (adcr) ( pd78f150xa only) ? 10-bit a/d conversion result register (adcr) ( pd78f151xa only) ? 8-bit a/d conversion result register (adcrh) ? analog input channel specification register (ads) ? a/d port configuration register (adpc) ? port mode registers 2, 15 (pm2, pm15) (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripheral hardware macro. clock supply to a hardware macro that is not used is stopped in order to reduc e the power consumption and noise. when the a/d converter is used, be sure to se t bit 5 (adcen) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 10-4. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note sau1en sau0en tau1en tau0en adcen control of a/d converter, operational amplifier, and voltage reference input clock 0 stops supply of input clock. ? sfr used by the a/d converter, operational amplifier, and voltage reference cannot be written. ? the a/d converter, operational amplifier, and voltage reference is in the reset status. 1 supplies input clock. ? sfr used by the a/d converter can, operational amplifier, and voltage reference can be read/written. note 78k0r/lg3, 78k0r/lh3 only caution when setting the a/d converter, be sure to set adcen to 1 first. if adcen = 0, writing to a control register of the a/d conver ter is ignored, and, even if the re gister is read, only the default value is read. 78k0r/lx3 r01uh0004ej0501 rev.5.01 391 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (2) 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 signal generation clears this register to 00h. figure 10-5. format of a/d converter mode register (adm) address: fff30h after reset: 00h r/w symbol <7> 6 5 4 3 2 1 <0> adm adcs adscm fr2 note 1 fr1 note 1 fr0 note 1 lv1 note 1 lv0 note 1 adce adcs a/d conversion operation control notes 2, 3, 4 0 stops conversion operation 1 enables conversion operation adscm a/d conversion operation mode specification 0 continuous conversion mode 1 single conversion mode adce a/d voltage comparator operation control note 4 0 stops a/d voltage comparator operation 1 enables a/d voltage comparator operation notes 1. for details of fr2 to fr0, lv 1, lv0, and a/d conversion, see table 10-2 a/d conversion time selection . 2. when using the a/d converter in timer trigger mode, do not set adcs to 1. (adcs automatically switches to 1 when a timer trigger signal is generated.) ho wever, adcs may be set to 0 to stop a/d conversion. 3. read adcs to determine whether a/ d conversion is under execution. 4. the operation of the a/ d voltage comparator is controlled by adcs and adce, and it takes 1 s from operation start to operation stabilization. th erefore, when adcs is set to 1 after 1 s or more has elapsed from the time adce is set to 1, t he conversion result at that time has priority over the first conversion result. otherwise, ignore data of the first conversion. table 10-1. 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 (a/d voltage co mparator operation, only comparator consumes power) 1 0 setting prohibited 1 1 conversion mode (a/d voltage comparator operation) 78k0r/lx3 r01uh0004ej0501 rev.5.01 392 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) figure 10-6. timing chart when a/ d voltage comparator is used adce a/d voltage comparator adcs conversion operation conversion operation conversion stopped conversion waiting a/d voltage comparator operation note note to stabilize the internal circuit, the time from the rising of the adce bit 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 adscm, fr0 to fr2, lv1, and lv0 to values other than th e identical data. 2 when using the a/d con verter in normal mode 2 (lv1 = 0, lv0 = 1) or low voltage mode (lv1 = 1, lv0 = 0), enable the input gate voltage boost circ uit for the a/d converte r by using the analog reference voltage control register (advrc), and then set adce and adcs to 1. after the voltage boost circuit stabilization time (10 s) passes after the input gate voltage boost circuit for the a/d converter has been enab led, set adcs to 1. 78k0r/lx3 r01uh0004ej0501 rev.5.01 393 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) table 10-2. a/d conversion time selection a/d converter mode register (adm) conversion time selection fr2 fr1 fr0 lv1 lv0 mode f clk = 1 mhz f clk = 8 mhz f clk = 10 mhz f clk = 20 mhz conversion clock (f ad ) 0 0 0 240/f clk 30 s 24 s 12 s f clk /12 0 0 1 160/f clk 20 s 16 s 8 s f clk /8 0 1 0 120/f clk 15 s 12 s 6 s f clk /6 0 1 1 100/f clk 12.5 s 10 s 5 s f clk /5 1 0 0 80/f clk 10 s 8 s f clk /4 1 0 1 60/f clk setting prohibited 7.5 s 6 s f clk /3 1 1 0 40/f clk 40 s 5 s f clk /2 1 1 1 0 0 normal mode 1 note 1 20/f clk 20 s setting prohibited setting prohibited setting prohibited f clk 0 0 0 240/f clk 30 s 24 s 12 s f clk /12 0 0 1 160/f clk 20 s 16 s 8 s f clk /8 0 1 0 120/f clk 15 s 12 s 6 s f clk /6 0 1 1 100/f clk 12.5 s 10 s 5 s f clk /5 1 0 0 80/f clk 10 s 8 s f clk /4 1 0 1 60/f clk setting prohibited 7.5 s 6 s f clk /3 1 1 0 40/f clk 40 s 5 s f clk /2 1 1 1 0 1 normal mode 2 note 2 20/f clk 20 s setting prohibited setting prohibited setting prohibited f clk 0 0 0 300/f clk 37.5 s 30 s 15 s note 4 f clk /12 0 0 1 200/f clk 25 s 20 s note 4 10 s note 4 f clk /8 0 1 0 150/f clk 18.8 s note 4 15 s note 4 7.5 s note 4 f clk /6 0 1 1 125/f clk 15.6 s note 4 12.5 s note 4 6.25 s note 4 f clk /5 1 0 0 100/f clk 12.5 s note 4 10 s note 4 f clk /4 1 0 1 75/f clk setting prohibited 9.38 s note 4 7.5 s note 4 f clk /3 1 1 0 50/f clk 50 s 6.25 s note 4 f clk /2 1 1 1 1 0 low voltage mode note 3 25/f clk 25 s setting prohibited setting prohibited setting prohibited f clk other than above setting prohibited notes 1. normal mode 1: 2.7 v av dd0 5.5 v, when operation of the input gate voltage boost circuit for the a/d converter is stopped. 2. normal mode 2: 2.3 v av dd0 5.5 v, when operation of the input gate voltage boost circuit for the a/d converter is operating. 3. low voltage mode: 1.8 v av dd0 5.5 v, when operation of the input gate voltage boost circuit for the a/d converter is operating. 4. when t a = 0 to 50 c and 2.3 v av dd0 3.6 v. caution when using the a/d converter in no rmal mode 2 (lv1 = 0, lv0 = 1) or low voltage mode (lv1 = 1, lv0 = 0), enable the input gate voltage boost circuit fo r the a/d converter by us ing the analog reference voltage control register (advrc), and then set adce and adcs to 1. after the voltage boost circuit stabilization time (10 s) passes after the input gate voltage boost circuit for the a/d converter has been enabled, set adcs to 1. remark f clk : cpu/peripheral hardware clock frequency 78k0r/lx3 r01uh0004ej0501 rev.5.01 394 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) figure 10-7. a/d converter sa mpling and a/d conversion timing adcs wait period conversion time conversion time sampling sampling timing intad adcs 1 or ads rewrite sampling sar clear sar clear transfer to adcr, intad generation successive conversion (3) a/d converter mode register 1 (adm1) this register sets the a/d conversion start trigger. adm1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 10-8. format of a/d con verter mode register 1 (adm1) address: fff32h after reset: 00h r/w symbol <7> 6 5 4 3 2 1 0 adm1 adtmd 0 0 0 0 0 0 adtrs adtmd a/d trigger mode selection 0 software trigger mode 1 timer trigger mode (hardware trigger mode) adtrs timer trigger signal selection 0 inttm02 1 inttm03 caution rewriting adm1 during a/d conversion is prohi bited. rewrite it when conversion operation is stopped (adcs = 0). 78k0r/lx3 r01uh0004ej0501 rev.5.01 395 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (4) analog reference voltage control register (advrc) this register is used to select the reference voltage supplies of the a/d and d/a converters , control the operation of the input gate voltage boost circuit for the a/d converter, and control the voltage reference (vr) operation. the electrical specifications of the a/d converter can be maintained even during low-voltage operation thanks to the operation of the input gate voltage boos t circuit for the a/d converter. advrc can be set by a 1-bit or 8-bi t memory manipulation instruction. reset signal generation clears this register to 00h. figure 10-9. format of analog referen ce voltage control register (advrc) address: fff36h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 advrc adref note 0 0 0 vrsel note 0 vrgv note vron note adref note negative reference voltage supply selection of a/d converter selection 0 av ss 1 av refm (external voltage reference input) vrsel note vrgv vron note positive reference voltage supplies selection of a/d and d/a converters operation control of voltage reference output voltage selection of voltage reference operation control of input gate voltage boost circuit for a/d converter relationship with the conversion mode used 0 0 0 2.5 v stops operation can be set in normal mode 1. 0 1 0 av refp (external voltage reference input) stops operation (hi-z) 2.0 v enables operation can be set in normal mode 2 or low voltage mode. 1 0 0 stops operation (pull-down output) 2.5 v stops operation ? 1 0 1 enables operation 2.5 v can be set in normal mode 2 or low voltage mode. 1 1 0 stops operation (pull-down output) 2.0 v ? 1 1 1 v refout (voltage reference output) enables operation 2.0 v enables operation can be set in normal mode 2 or low voltage mode. other than the above setting prohibited note these bits can be set only for pd78f150xa. they are fixed ?0? for pd78f151xa. caution 1. when using the a/ d converter in normal mode 2 (lv1 = 0, lv 0 = 1) or low voltage mode (lv1 = 1, lv0 = 0), enable the input gate voltage boost ci rcuit for the a/d conver ter by using the analog reference voltage control register (advrc), and then set adce and adcs to 1. after the voltage boost circuit stabilization time (10 s) passes after the input gate voltage boost circuit for the a/d converter has been enab led, set adcs to 1. 78k0r/lx3 r01uh0004ej0501 rev.5.01 396 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) cautions 2. to use voltage reference out put to the positive refere nce voltage of the a/d c onverter, be sure to set vron to 1 after setting vrsel to 1. 3. do not change the output vo ltage of the reference voltage by using vrgv during the voltage reference operation (vron = 1). remark the combinations of the selectabl e reference voltage supplies (positiv e side, negative side) of the a/d converter are as follows, according to the adref, vrsel and vron settings. table 10-3. settings of adref, vrsel and vron adref vrsel vron positive reference voltage of a/d converter (ad refp ) negative reference voltage of a/d converter (ad refm ) 0 0 0 av refp av ss 0 1 1 v refout (vr output) av ss 1 0 0 av refp av refm 1 1 1 v refout (vr output) av refm (5) 12-bit a/d conversion result register (adcr) ( pd78f150xa only) this register is a 16-bit register that st ores the a/d conversion result in the select mode. the higher 4 bits are fixed to 0. each time a/d conversion ends, the conversion result is loaded from the successive approximation register. the higher 4 bits of the conversion re sult are stored in fff1fh and the lower 8 bits are stored in the fff1eh. adcr can be read by a 16-bit memory manipulation instruction. reset signal generation clears this register to 0000h. figure 10-10. format of 10-bit a/d conversion result register (adcr) symbol address: fff1eh, fff1fh after reset: 0000h r fff1fh fff1eh 0 0 0 0 adcr caution when writing to a/d conver ter mode register (adm), analog input channel speci fication register (ads), and a/d port configurati on register (adpc), the contents of adcr may become undefined. read the conversion result follow ing conversion completion before wr iting to adm, ads, and adpc. using timing other than the a bove may cause an incorrect c onversion result to be read. 78k0r/lx3 r01uh0004ej0501 rev.5.01 397 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (6) 10-bit a/d conversion result register (adcr) ( pd78f151xa only) this register is a 16-bit register that st ores the a/d conversion result in the select mode. the higher 4 bits are fixed to 0. the lower 2 bits are undefined. ea ch time a/d conversion ends, the c onversion result is loaded from the successive approximation register. the higher 4 bits of the conversion result are stored in fff1fh and the lower 8 bits are stored in the fff1eh. adcr can be read by a 16-bit memory manipulation instruction. reset signal generation clears this register to 0000h. figure 10-11. format of 12-bit a/d conversion result register (adcr) symbol address: fff1eh, fff1fh after reset: 0000h r fff1fh fff1eh 0 0 0 0 adcr * * *: undefined caution when writing to a/d conver ter mode register (adm), analog input channel speci fication register (ads), and a/d port configurati on register (adpc), the contents of adcr may become undefined. read the conversion result follow ing conversion completion before wr iting to adm, ads, and adpc. using timing other than the a bove may cause an incorrect c onversion result to be read. (7) 8-bit a/d conversion result register (adcrh) this register is an 8-bit register that st ores the a/d conversion result. the higher 8 bits of 12-bit resolution are stored. adcrh can be read by an 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 10-12. format of 8-bit a/d c onversion result register (adcrh) symbol address: fff1fh note after reset: 00h r fff1fh fff1eh adcrh 0 0 0 0 adcrh note if address fff1fh is read, the data of adcrh (lower four bits of fff1fh and higher four bits of fff1eh) will be read. caution when writing to a/d conver ter mode register (adm), analog input channel speci fication register (ads), and a/d port configurati on register (adpc), the contents of adcrh may become undefined. read the conversion result follow ing conversion completion before wr iting to adm, ads, and adpc. using timing other than the a bove may cause an incorrect c onversion result to be read. 78k0r/lx3 r01uh0004ej0501 rev.5.01 398 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (8) analog input channel specification register (ads) this register specifies the input channel of the analog voltage to be a/d converted. ads can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 10-13. format of analog input channel specification register (ads) address: fff31h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 ads 0 0 0 0 ads3 ads2 ads1 ads0 ads3 ads2 ads1 ads0 analog input channel 0 0 0 0 ani0 0 0 0 1 ani1 0 0 1 0 ani2 0 0 1 1 ani3 0 1 0 0 ani4 0 1 0 1 ani5 0 1 1 0 ani6 0 1 1 1 ani7 1 0 0 0 ani8 1 0 0 1 ani9 1 0 1 0 ani10 1 1 1 1 ani15 other than the above setting prohibited note this setting is prohibited for 78k0r/lf3. cautions 1. be sure to cl ear bits 4 to 7 to ?0?. 2 set a channel to be used fo r a/d conversion in the input mode by using port mode registers 2 and 15 (pm2, pm15). 3. do not set the pin that is set by adpc as digital i/o by ads. 4. when using an operational amplifier n, the out put signal of an operational amplifier n can be used as an analog input. remark 78k0r/lf3: n = 0, 1 78k0r/lg3, 78k0r/lh3: n = 0 to 2 note note note note 78k0r/lx3 r01uh0004ej0501 rev.5.01 399 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (9) a/d port configuration register (adpc) this register switches the ani0/amp0-/p20 to ani7/amp2o/p27, ani8/amp2+/p150 to ani10/p152 and ani15/av refm /p157 pins to analog input of a/ d converter or digital i/o of port. adpc can be set by an 8-bit memory manipulation instruction. reset signal generation sets this register to 10h. remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 figure 10-14. format of a/d port configuration register (adpc) address: f0017h after reset: 10h r/w symbol 7 6 5 4 3 2 1 0 adpc 0 0 0 adpc4 adpc3 adpc2 adpc1 adpc0 analog input (a)/digita l i/o (d) switching port 15 port 2 adp c4 adp c3 adp c2 adp c1 adp c0 ani15 /av refm /p157 ani10 /p152 ani9 /p151 ani8 /amp2+ /p150 ani7 /amp2o /p27 ani6 /amp2- /p26 ani5 /amp1+ /p25 ani4 /amp1o /p24 ani3 /amp1- /p23 ani2 /amp0+ /p22 ani1 /amp0o /p21 ani0 /amp0- /p20 0 0 0 0 0 a a a a a a a a a a a a 0 0 0 0 1 a a a a a a a a a a a d 0 0 0 1 0 a a a a a a a a a a d d 0 0 0 1 1 a a a a a a a a a d d d 0 0 1 0 0 a a a a a a a a d d d d 0 0 1 0 1 a a a a a a a d d d d d 0 0 1 1 0 a a a a a a d d d d d d 0 0 1 1 1 a a a a a d d d d d d d 0 1 0 0 0 a a a a d d d d d d d d 0 1 0 0 1 a a a d d d d d d d d d 0 1 0 1 0 a a d d d d d d d d d d 0 1 1 1 1 a d d d d d d d d d d d 1 0 0 0 0 d d d d d d d d d d d d other than the above setting prohibited note this setting is prohibited for 78k0r/lf3. cautions 1. set a channel to be u sed for a/d conversion in the input mo de by using port mode registers 2 and 15 (pm2, pm15). 2. do not set the pin that is set by adpc as digital i/o by ads. note note note note 78k0r/lx3 r01uh0004ej0501 rev.5.01 400 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (10) port mode registers 2, 15 (pm2, pm15) when using ani0/amp0-/p20 to ani7/amp2o/p 27, ani8/amp2+/p150 to ani10/p152 and ani15/av refm /p157 pins for analog input port, set pm20 to pm27, pm150 to pm152, and p157 to 1. the output latches of p20 to p27, p150 to p152 and p157 at this time may be 0 or 1. if pm20 to pm27, pm150 to pm152 and pm157 are set to 0, they cannot be used as analog input port pins. pm2 and pm15 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets these registers to ffh. remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 caution if a pin is set as an analog input por t, not the pin level bu t ?0? is always read. figure 10-15. formats of port mode registers 2, 15 (pm2, pm15) ? 78k0r/lf3 address: fff22h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm2 1 pm26 pm25 pm24 pm23 pm22 pm21 pm20 address: fff2fh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm15 pm157 1 1 1 1 1 1 1 ? 78k0r/lg3, 78k0r/lh3 address: fff22h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm2 pm27 pm26 pm25 pm24 pm23 pm22 pm21 pm20 address: fff2fh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm15 pm157 1 1 1 1 pm152 pm151 pm150 pmmn pmn pin i/o mode selection (mn = 20 to 27, 150 to 152, 157) 0 output mode (output buffer on) 1 input mode (output buffer off) 78k0r/lx3 r01uh0004ej0501 rev.5.01 401 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) the ani0/amp0-/p20 to ani7/amp2o/p27, an i8/amp2+/p150 to ani10/p152 and ani15/av refm /p157 pins are as shown below depending on the settings of adpc , ads, pm2, pm15, oaenn bit and adref bit. caution when an operational ampl ifier is used, pins ampn+, ampn ? , and ampno are used, so the alternative analog input functions cannot be u sed. the operational amplifier output signals, however, can be used as analog inputs. table 10-4. setting functions of ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1-/p23, ani5/amp1+/p25, ani6/amp2-/p26, and ani8/amp2+/p150 pins adpc register pm2 and pm15 registers oaenn bit ads register ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1-/p23, ani5/amp1+/p25, ani6/amp2-/p26, and ani8/amp2+/p150 pins 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) selects ani. setting prohibited input mode 1 does not select ani. operational amplifier input analog input selection output mode ? ? setting prohibited remark 78k0r/lf3: ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1-/p23, ani5/amp1+/p25, n = 0, 1 78k0r/lg3, 78k0r/lh3: ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1-/p23, ani5/amp1+/p25, ani6/amp2-/p26, ani8/amp2+/p150, n = 0 to 2 table 10-5. setting functions of ani1/amp0 o/p21, ani4/amp1o/p24, and ani7/amp2o/p27 pins adpc register pm2 register oaenn bit ads register ani1/amp0o/p21, ani4/amp1o/p24, and ani7/amp2o/p27 pins 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) selects ani. operational amplifier output (not to be converted) input mode 1 does not select ani. operational amplifier output (to be converted) analog input selection output mode ? ? setting prohibited remark 78k0r/lf3: ani1/amp0o/p21, ani4/amp1o/p24, n = 0, 1 78k0r/lg3, 78k0r/lh3: ani1/amp0o/p21, ani4 /amp1o/p24, and ani7/amp2o/p27, n = 0 to 2 78k0r/lx3 r01uh0004ej0501 rev.5.01 402 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) table 10-6. setting functions of ani9/p151 and ani10/am152 pins adpc register pm15 register ads register ani9/p151 and ani10/am152 pins input mode ? digital input digital i/o selection output mode ? digital output selects ani. analog input (to be a/d converted) input mode does not select ani. analog input (not to be a/d converted) analog input selection output mode ? setting prohibited remark 78k0r/lf3: ani9/p151 and ani10/am152 are not mounted. 78k0r/lg3, 78k0r/lh3: ani9/p151, ani10/am152 table 10-7. setting functions of ani15/av refm /p157 pin adpc register pm15 register adref bit ads register ani15/av refm /p157 pin 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) input mode 1 ? negative reference voltage input of a/d converter analog input selection output mode ? ? setting prohibited 78k0r/lx3 r01uh0004ej0501 rev.5.01 403 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) 10.4 a/d converter operations 10.4.1 basic operations of a/d converter <1> set bit 5 (adcen) of peripheral enable register 0 (per0) to 1 to start the supply of the input clock to the a/d converter. <2> set the a/d conversion time by using bits 5 to 1 (fr2 to fr0, lv1, and lv0) of a/d converter mode register (adm), and set the operation mode by using bit 6 (admd) of adm. <3> use bits 7, 3, 1, and 0 (adref, vrsel, vrgv, and vr on) of the analog reference voltage control register (advrc) to specify the reference volta ge source of the a/d converter and the operation of the input gate voltage boost circuit for the a/d converter. <4> set bit 0 (adce) of adm to 1 to star t the operation of the a/d voltage comparator. <5> set the channels for a/d conversion to analog input by using the a/d port configurat ion register (adpc) and set to input mode by using port mode registers (pm2 and pm15). <6> select one channel for a/d conversion using the analog input channel specification register (ads). <7> use the a/d converter mode register 1 (adm1) to set the trigger mode. <8> start the conversion operation by setting bit 7 (adcs) of adm to 1, if the software trigger mode has been set in step <7>. if timer trigger mode was specified in step <7>, adcs is automatically set to 1 and a/d conversion starts when the timer trigger signal is detected.(<9> to <15> are operations performed by hardware.) <9> the voltage input to the selected analog input c hannel is sampled by the sample & hold circuit. <10> when sampling has been done for a certain time, the sa mple & hold circuit is placed in the hold state and the sampled voltage is held until the a/ d conversion operation has ended. <11> bit 11 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. <12> the voltage difference between the series resistor string voltage tap and sampled voltage 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. <13> next, bit 10 of sar is automatically set to 1, and t he operation proceeds to the next comparison. the series resistor string voltage tap is selected according to the preset value of bit 9, as described below. ? bit 11 = 1: (3/4) av ref ? bit 11 = 0: (1/4) av ref the voltage tap and sampled voltage are compared and bit 8 of sar is manipulated as follows. ? sampled voltage voltage tap: bit 10 = 1 ? sampled voltage < voltage tap: bit 10 = 0 <14> comparison is continued in this way up to bit 0 of sar. <15> upon completion of the comparison of 12 bits, an effe ctive 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. <16> if single conversion mode has been set in step <2>, adcs is automatically cleared to 0 and enters a wait state after the first a/d conversion ends. if the continuous conversion mode has been set in step <2>, repeat steps <9> to <15>. to stop the a/d converter, clear adcs to 0. to restart a/d conversion from the status of adce = 1, start from <8>. to start a/d conversion again when adce = 0, set adce to 1, wait for 1 s or longer, and start step <8>. to change the channel to be a/d converted, perform step <6>. 78k0r/lx3 r01uh0004ej0501 rev.5.01 404 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) cautions 1. make sure the period of <4> to <8> is 1 s or more. 2. to use an operational amplifier output fo r an analog input, start operating the operational amplifier before setting the a/d conver sion operation (see chapter 12 operational amplifier). furthermore, do not change th e operational amplifier setting during the a/d conversion operation. 3. to use an output voltage of the voltage reference for a pos itive reference voltage of a/d converter, start operating the vo ltage reference before setting the a/d conversion operation (see chapter 13 voltage reference). furthermore, do not change the voltage reference setting during the a/d conversion operation. 4. when using the a/d converter in normal mode 2 (l v1 = 0, lv0 = 1) or low voltage mode (lv1 = 1, lv0 = 0), enable the input gate voltage boost circ uit for the a/d converte r by using the analog reference voltage control register (advrc), and then set adce and adcs to 1. after the voltage boost circuit stabilization time (10 s) passes after the input gate voltage boost circuit for the a/d converter has been enab led, set adcs to 1. remark two types of a/d conversion result registers are available. reset signal generation clears the a/d conversion result register (adcr, adcrh) to 0000h or 00h. ? adcr (16 bits): store 12-bit a/d conversion value ? adcrh (8 bits): store 8-bit a/d conversion value figure 10-16. basic operation of a/d converter sar adcr intad a/d converter operation conversion time sampling time sampling undefined a/d conversion conversion result conversion result 78k0r/lx3 r01uh0004ej0501 rev.5.01 405 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) 10.4.2 input voltage and conversion results the relationship between the analog i nput voltage input to the analog input pins (ani0 to ani10, ani15) and the theoretical a/d conversion result (stored in the 12-bit a/d conversion result regi ster (adcr)) is shown by the following expression. adcr = int ( 4096 + 0.5) 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 : reference voltage of a/d converter adcr: 12-bit a/d conversion result register (adcr) value remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 figure 10-16 shows the relationship between the analo g input voltage and the a/d conversion result. figure 10-17. relationship between analog i nput voltage and a/d conversion result 4095 4094 4093 3 2 1 0 0fffh 0ffeh 0ffdh 0003h 0002h 0001h 0000h a/d conversion result sar adcr 1 8192 1 4096 3 8192 2 4096 5 8192 input voltage/av ref 3 4096 8187 8192 4094 4096 8189 8192 4095 4096 8191 8192 1 v ain av ref av ref 4096 av ref 4096 78k0r/lx3 r01uh0004ej0501 rev.5.01 406 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) 10.4.3 a/d converter operation modes the following four a/d converter operation modes are available. ? software trigger mode (continuous conversion mode) ? software trigger mode (single conversion mode) ? timer trigger mode (continuous conversion mode) ? timer trigger mode (single conversion mode) (1) software trigger mode (c ontinuous conversion mode) <1> by setting bit 7 (adcs) of the a/d converter mode regi ster (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 chan nel specification register (ads), is started. <2> when a/d conversion has been completed, the result of the a/d conversion is stored in the a/d conversion result register (adcr, adcrh), and an interrupt request signal (intad) is generated. when one a/d conversion has been completed, the next a/d conversion operation is immediately started. <3> if 1 is written to adcs during a/d conversion, the a/ d conversion operation under execution is stopped and restarted from the beginning. at this time, th e conversion result immediately before is retained. <4> if ads is rewritten during a/d conversion, the a/d c onversion operation under exec ution is stopped and restarted from the beginning. at this time, the conv ersion result immediately before is retained. <5> if 0 is written to adcs during a/d conversion, a/d conversion is immediately stopped. at this time, the conversion result immediat ely before is retained. figure 10-18. software trigger m ode (continuous conversion mode) anin <1> adcs = 1 anin anin anim anin anim anim adcr, adcrh intad adcs <3> adcs = 1 <5> adcs = 0 a/d conversion conversion operation under execution is stopped, and restarted from the beginning conversion operation under execution is stopped <4> rewriting ads <2> a/d conversion is completed <2> a/d conversion is completed remark 78k0r/lf3: n = 0 to 6, 15, m = 0 to 6, 15 78k0r/lg3, 78k0r/lh3: n = 0 to 10, 15, m = 0 to 10, 15 78k0r/lx3 r01uh0004ej0501 rev.5.01 407 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (2) software trigger mode (single conversion mode) <1> by setting bit 7 (adcs) of the a/d converter mode regi ster (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 chan nel specification register (ads), is started. <2> when a/d conversion has been completed, the result of the a/d conversion is stored in the a/d conversion result register (adcr, adcrh), and an interrupt request signal (intad) is generated. when one a/d conversion has been completed, adcs is automatically clear ed and an a/d conversion wa it state is entered. <3> if 1 is written to adcs during a/d conversion, the a/ d conversion operation under execution is stopped and restarted from the beginning. at this time, th e conversion result immediately before is retained. <4> if ads is rewritten during a/d conversion, the a/d c onversion operation under exec ution is stopped and restarted from the beginning. at this time, the conv ersion result immediately before is retained. <5> if 0 is written to adcs during a/d conversion, a/d conversion is immediately stopped. at this time, the conversion result immediat ely before is retained. figure 10-19. software trigger mode (single conversion mode) anin anin anin anim anin anim an im adcr, adcrh intad adcs <1> adcs = 1 <5> adcs = 0 <1> adcs = 1 <3> adcs = 1 <1> adcs = 1 a/d conversion <4> rewriting ads <2> a/d conversion is completed <2> a/d conversion is completed wait state wait state conversion operation under execution is stopped, and restarted from the beginning conversion operation under execution is stopped remark 78k0r/lf3: n = 0 to 6, 15, m = 0 to 6, 15 78k0r/lg3, 78k0r/lh3: n = 0 to 10, 15, m = 0 to 10, 15 78k0r/lx3 r01uh0004ej0501 rev.5.01 408 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (3) timer trigger mode (c ontinuous conversion mode) <1> timer trigger mode is set and a timer trigger wait state is entered by setting bit 7 (adtmd) of a/d converter mode register 1 (adm1) to 1. <2> when the timer trigger signal is detected, bit 7 (adcs) of the a/d converter mode regi ster (adm) is automatically set to 1 and a/d conversion of the voltage applied to the analog input pin specified using the analog input channel specification register (ads) starts. <3> when a/d conversion has been completed, the result of the a/d conversion is stored in the a/d conversion result register (adcr, adcrh), and an interrupt request signal (intad) is generated. when one a/d conversion has been completed, the next a/d conversion operation is immediately started. <4> if 1 is written to ads during a/d conversion, the a/d conversion operation u nder execution is stopped and restarted from the beginning. at this time, th e conversion result immediately before is retained. <5> if a timer trigger signal is generated during a/d conv ersion, the a/d conversion o peration under execution is stopped and restarted from the beginning. at this time , the conversion result imm ediately before is retained. <6> if 0 is written to adcs during a/ d conversion, a/d conversion is immedi ately stopped, and a timer trigger wait state is entered. at this time, the conver sion result immediately before is retained. <7> when 0 is written to adtmd while a/d conversion oper ation is stopped (adcs = 0), the software trigger mode is set and a/d conversion operation is not started, even if a timer trigger signal is generated. figure 10-20. timer trigger m ode (continuous c onversion mode) anin <1> adtmd = 1 anin anin anim anin anim anim adcr, adcrh intad adcs <6> adcs = 0 anim <7> adtmd = 0 anin timer trigger adtmd a/d conversion <3> a/d conversion is completed <3> a/d conversion is completed <3> a/d conversion is completed <2> timer trigger generation <5> timer trigger generation wait state wait state <4> rewriting ads conversion operation under execution is stopped, and restarted from the beginning conversion operation under execution is stopped, and restarted from the beginning conversion operation under execution is stopped note note leave at least enough time for a/d conversion to finish between each generation of the timer trigger signal. remark 78k0r/lf3: n = 0 to 6, 15, m = 0 to 6, 15 78k0r/lg3, 78k0r/lh3: n = 0 to 10, 15, m = 0 to 10, 15 78k0r/lx3 r01uh0004ej0501 rev.5.01 409 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (4) timer trigger mode (single conversion mode) <1> timer trigger mode is set and a timer trigger wait state is entered by setting bit 7 (adtmd) of a/d converter mode register 1 (adm1) to 1. <2> when the timer trigger signal is detected, bit 7 (adcs) of the a/d converter mode regi ster (adm) is automatically set to 1 and a/d conversion of the voltage applied to the analog input pin specified using the analog input channel specification register (ads) starts. <3> when a/d conversion has been completed, the result of the a/d conversion is stored in the a/d conversion result register (adcr, adcrh), and an interrupt request signal (intad) is generated. when one a/d conversion has been completed, adcs is automatically clear ed and a timer trigger wait state is entered. <4> even if ads is rewritten during an a/d conversion operat ion, the a/d conversion operat ion performed at that time is continued. the channel will be switched w hen the next a/d conver sion operation starts. <5> if a timer trigger signal is generated during a/d conv ersion, the a/d conversion o peration under execution is stopped and restarted from the beginning. at this time , the conversion result imm ediately before is retained. <6> when 0 is written to adtmd while a/d conversion oper ation is stopped (adcs = 0), the software trigger mode is set and a/d conversion operation is not started, even if a timer trigger signal is generated. figure 10-21. timer trigger m ode (single conversion mode) anin anin anim anin anim adcr, adcrh intad adcs anin adtmd anim timer trigger a/d conversion wait state wait state wait state wait state <1> adtmd = 1 <6> adtmd = 0 <2> timer trigger generation <2> timer trigger generation <2> timer trigger generation <5> timer trigger generation <3> a/d conversion is completed <3> a/d conversion is completed <3> a/d conversion is completed conversion operation under execution is stopped, and restarted from the beginning conversion is not stopped <4> rewriting ads note note leave at least enough time for a/d conversion to finish between each generation of the timer trigger signal. remark 78k0r/lf3: n = 0 to 6, 15, m = 0 to 6, 15 78k0r/lg3, 78k0r/lh3: n = 0 to 10, 15, m = 0 to 10, 15 78k0r/lx3 r01uh0004ej0501 rev.5.01 410 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) the setting methods are described below. <1> set bit 5 (adcen) of peripheral enable register 0 (per0) to 1. <2> select the conversion time by using bits 5 to 1 (fr2 to fr0, lv1, and lv0) of a/d converter mode register (adm), and select the operation mode by using bit 6 (adscm) of adm. <3> use bits 7, 3, 1, and 0 (adref, vrsel, vrgv, and vron) of the analog reference voltage control register (advrc) to specify the reference vo ltage source of the a/d converte r and the operation of the input gate voltage boost circuit for the a/d converter. <4> set bit 0 (adce) of adm to 1. <5> set the channel to be used in the analog input mode by using bits 4 to 0 (adpc4 to adpc0) of the a/d port configuration register (adpc), bits 7 to 0 (pm27 to pm 20) of port mode register 2 (pm2), and bits 7, 2 to 0 (pm157, pm152 to pm150) of port mode register 15 (pm15). <6> select a channel to be used by using bits 3 to 0 (ads3 to ads0) of the analog input channel specification register (ads). <7> use bits 0 and 7 (adtrs, adtmd) of a/d conver ter mode register 1 (adm1) to set the trigger mode. <8> in the software trigger mode start a/d conversion by setting bit 7 (adcs) of adm to 1. in the timer trigger mode adcs is automatically set to 1 and a/d conversion starts when the timer trigger signal is generated. <9> when one a/d conversion has been completed, an interrupt request signal (intad) is generated. <10> transfer the a/d conversion data to the a/d conversion result register (adcr, adcrh). <11> in the continuous conversion mode start the next a/d conversion automatically. in the single conversion mode adcs is automatically cleared to 0 and the a/d converter goes on standby. to start a/d conversion operation, go to step <8>. 78k0r/lx3 r01uh0004ej0501 rev.5.01 411 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) cautions 1. make sure the period of <4> to <8> is 1 s or more. 2. <4> may be done between <5> and <7>. 3. <4> can be omitted. howe ver, ignore data of the first con version after <8> in this case. 4. the period from <9> to <13> differs from the conversion time set using bits 5 to 1 (fr2 to fr0, lv1, lv0) of adm. the period from <12> to <13> is the conversion time set using fr2 to fr0, lv1, and lv0. 5. to use an operational amplifier output for an analog input, start operating the operational amplifier before setting the a/d conver sion operation (see chapter 12 operational amplifier). furthermore, do not change th e operational amplifier setting during the a/d conversion operation. 6. to use an output voltage of the voltage reference for a pos itive reference voltage of a/d converter, start operating the voltage referenc e before setting the a/d conversion operation (see chapter 13 voltage reference). fur thermore, do not change the voltage reference setting during the a/d conversion operation. 7. when using the a/d converter in normal mode 2 (lv1 = 0, lv0 = 1) or low voltage mode (lv1 = 1, lv0 = 0), enable the input gate voltage boost circuit for the a/d converter by using the analog reference voltage control register (advrc), and then set adce and adcs to 1. after the voltage boost circuit stabilization time (10 s) passes after the input gate voltage boost circuit for the a/d c onverter has been enab led, set adcs to 1. 78k0r/lx3 r01uh0004ej0501 rev.5.01 412 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) 10.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 voltage that can be identifi ed. that is, the percentage of the analog input voltage per bit of digital output is called 1lsb (least significant bi t). 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 12 bits. 1lsb = 1/2 12 = 1/4096 = 0.024 %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, integr al linearity error, and differential linearit y 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 digital co de, so a quantization error cannot be avoided. note that the quantization error is not included in the overall error, zero-scale error, full-scale erro r, integral linearity error, and differential linearity erro r in the characteristics table. figure 10-22. overall error figur e 10-23. 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 measurement value of the analog input voltage and the theoretical value (1/2lsb) when the digital output changes from 0......000 to 0......001. if the actual measurement value is gr eater than the theoretical value, it shows the difference between the actual measurement value of the analog inpu t voltage and the theoretical value (3/ 2lsb) when the digital output changes from 0??001 to 0??010. 78k0r/lx3 r01uh0004ej0501 rev.5.01 413 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (5) full-scale error this shows the difference between the actual measurement value of the analog input voltage 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 characteristics deviate from the ideal linear relationship. it expresses the maximum value of the difference between the actual m easurement 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 indicate s the difference between the ac tual measurement value and the ideal value. figure 10-24. zero-scale error figure 10-25. 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 10-26. integral linearity error figure 10-27. 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 78k0r/lx3 r01uh0004ej0501 rev.5.01 414 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) 10.6 cautions for a/d converter (1) operating current in stop mode shift to stop mode after stopping the a/d converter (b y setting bit 7 (adcs) of the a/d converter mode register (adm) to 0). the operating current can be reduced by setti ng bit 0 (adce) of the a/d conv erter mode register (adm) to 0 at the same time. when using normal mode 2 (lv1 = 0, lv0 = 1) or low voltage mode (lv1 = 1, lv0 = 0), clear bit 1 (vrgv) and bit 0 (vron) of the analog reference voltage control regi ster (advrc) to 0, and then shift to stop mode. to restart from the standby status, clear bit 0 (adif) of interrupt request flag regist er 1l (if1l) to 0 and start operation. (2) input range of ani0 to ani10, ani15 observe the rated range of the ani0 to ani1 0, ani15 input voltage. if a voltage of av dd0 or higher and av ss or lower (even in the range of absolute maximum ratings) is input to an analog input channel, t he 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 register (adcr, adcrh) write and adcr or adcrh read by instruction upon the end of conversion adcr or adcrh read has priority. after the read operati on, the new conversion result is written to adcr or adcrh. <2> conflict between adcr or adcrh writ e and a/d converter mode register (adm) write, analog input channel specification register (ads), or a/ d port configuration register (adpc) write upon the end of conversion adm, ads, or adpc write has priority. adcr or a dcrh write is not performed, nor is the conversion end interrupt signal (intad) generated. (4) noise countermeasures to maintain the 12-bit resolution, attent ion must be paid to noise input to the av refp pin and pins ani0 to ani10, ani15. <1> connect a capacitor with a low equivalent resistance and a good frequency response to the power supply. <2> the higher the output impedance of the analog input source, the greater the influence. to reduce the noise, connecting external c as shown in figure 10-26 is recommended. <3> do not switch these pins wit h other pins during conversion. <4> the accuracy is improved if the halt mode is set immediately after the start of conversion. remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 78k0r/lx3 r01uh0004ej0501 rev.5.01 415 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) figure 10-28. 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 dd0 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 refp av ss v ss ani0 to ani10, ani15 (5) ani0 to ani10, ani15 <1> the analog input pins (ani0 to ani7) are also used as input port pins (p20 to p27). the analog input pins (ani8 to ani10, ani15) are al so used as input port pins (p150 to p152, p157). when a/d conversion is performed with any of ani0 to ani10, and ani15 selected, do not access p20 to p27, p150 to p152, and p157 while conversion is in progre ss; otherwise the conversion resolution may be degraded. it is recommended to select pins used as p20 to p27, p150 to p152, and p157 star ting with the ani0/p20 that is the furthest from av dd0 . <2> if the pins adjacent to the pins currently used for a/ d conversion are used as digi tal i/o port, the expected value of the a/d conversion may not be obtained due to coupling noi se. therefore, make sure that digital pulses are not input to or output from the pins adjace nt to the pin undergoing a/d conversion. <3> if any pin among pins of ports 2 and 15 is used as di gital output port during a/d c onversion, the expected value of the a/d conversion may not be obtained due to coupling noi se. therefore, make sure that digital pulses are not output to pins of ports 2 and 15 during a/d conversion. (6) input impedance of ani0 to ani10, ani15 pins this a/d converter charges a sampling capacitor for sampling during sampling time. therefore, only a leakage current flows when sampling is not in progress, and a current that charges the capacitor flows during sampling. consequently, the input impedanc e fluctuates depending on whether sampling is in progress, and on the other states. to make sure that sampling is effective, however, it is recommended to keep the ou tput impedance of the analog input source to within 1 k , and to connect a capacitor of about 100 pf to the ani0 to ani10 and ani15 pins (see figure 10-26 ). remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 78k0r/lx3 r01uh0004ej0501 rev.5.01 416 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (7) av refp pin input impedance a series resistor string of several tens of k is connected between the av refp and av refm (or av ss ) pins. therefore, if the output impedance of the reference voltage supply is high, this will result in a series connection to the series resistor string between the av refp and av refm (or av ss ) pins, resulting in a large reference voltage (av ref ) error of a/d converter. (8) interrupt request flag (adif) the interrupt request flag (adif) is not cleared even if the analog input channel spec ification register (ads) is changed. therefore, if an analog in put 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 rewrite. caution is therefor e required since, at this time, when adif is read immediately after the ad s rewrite, adif 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 10-29. 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. remark 78k0r/lf3: n = 0 to 6, 15, m = 0 to 6, 15 78k0r/lg3, 78k0r/lh3: n = 0 to 10, 15, m = 0 to 10, 15 (9) conversion results just after a/d conversion start the first a/d conversion value immediately after a/d conversi on starts may not fall within the rating range if the adcs bit is set to 1 within 1 s after the adce bit was set to 1, or if the adcs bit is set to 1 with the adce bit = 0. take measures such as polling the a/d conversion end interrupt request (intad) and removing the first conversion result. 78k0r/lx3 r01uh0004ej0501 rev.5.01 417 jun 20, 2011 chapter 10 12-bit a/d converter ( pd78f150xa), 10-bit a/d converter ( pd78f151xa) (10) a/d conversion result regist er (adcr, adcrh) read operation when a write operation is performed to a/d converter mode register (adm), a/d converter mode register 1 (adm1), analog input channel specification regist er (ads), and a/d port configuration re gister (adpc), the contents of adcr and adcrh may become undefined. read the conversion result following conversion completion before writing to adm, adm1, ads, or adpc. using a timing other than t he above may cause an incorrect conversion result to be read. (11) internal equivalent circuit the equivalent circuit of the analog input block is shown below. figure 10-30. internal equi valent circuit of anin pin anin c1 c2 r1 table 10-8. resistance and capacitance valu es of equivalent circui t (reference values) r1 c1 c2 11.5 k 8.0 pf 8.0 pf remarks 1. the resistance and capacitance values shown in table 10-8 are not guaranteed values. 2. 78k0r/lf3: n = 0 to 6, 15, 78k0r/lg3, 78k0r/lh3: n = 0 to 10, 15 (12) rewriting dacswn during a/d conversion rewriting dacswn (n = 0, 1) during a/d conversion is pr ohibited when both the positiv e reference voltage of a/d converter (ad refp ) and the positive reference voltage of the d/a converter (da refp ) are the voltage reference output (v refout ) (vrsel = 1 and daref = 1). rewrite it when conversion operation is stopped (adcs = 0). 78k0r/lx3 r01uh0004ej0501 rev.5.01 418 jun 20, 2011 chapter 11 d/a converter ( pd78f150xa only) chapter 11 d/a converter ( pd78f150xa only) 11.1 function of d/a converter the d/a converter with two channels is mounted onto all 78k0r/lx3 microcontroller products. the d/a converter has t he following features. { 12-bit resolution 2 channels { r-2r ladder method { output analog voltage ? 12-bit resolution: reference voltage for d/a converter m12/4096 (m12: value set to dacswn register) ? 8-bit resolution: reference voltage for d/a converter m8/256 (m8: value set to dacsn register) { supply voltage for d/a converter: av dd1 { ground for d/a converter: av ss { positive reference voltage for d/a converter: av dd1 , or av refp /v refout { negative reference voltage for d/a converter: av ss { operation mode ? normal mode ? real-time output mode remark n = 0, 1 11.2 configuration of d/a converter the d/a converter includes the following hardware. table 11-1. configuration of d/a converter item configuration control registers peripheral enable register 0 (per0) d/a converter mode register (dam) d/a conversion value setting regist ers w0, w1 (dacsw0, dacsw1) d/a conversion value setting regi sters 0, 1 (dacs0, dacs1) 78k0r/lx3 r01uh0004ej0501 rev.5.01 419 jun 20, 2011 chapter 11 d/a converter ( pd78f150xa only) figure 11-1. block diag ram of d/a converter ano0/p110 ano1/p111 dace0 dace1 damd0 damd1 av refp /v refout av ss daref dace1 dace0 dares1 dares0 damd1 damd0 av dd1 dares0 da refp write signal of dacsw0 register or write signal of dacs0 internal bus internal bus d/a conversion value setting register ( dacsw0 or dacs0) selector selector d/a conversion value setting register ( dacsw1 or dacs1) write signal of dacsw1 register or write signal of dacs1 inttm04 signal inttm05 signal d/a converter mode register (dam) selector voltege reference circuit vrsel bit vron, vrgv bit da refm remarks 1 . inttm04 and inttm05 are timer trigger signals (interr upt signals from timer channels 5 and 6) that are used in the real-time output mode. 2. channels 0 and 1 of the d/a converter share the av ref1 pin and the av refp /v refout pin. 3. channels 0 and 1 of the d/a converter share the av ss pin. the av ss pin is also shared with an a/d converter, an operational amplifier , and a voltage reference. 78k0r/lx3 r01uh0004ej0501 rev.5.01 420 jun 20, 2011 chapter 11 d/a converter ( pd78f150xa only) 11.3 registers used in d/a converter the d/a converter uses the following four registers. ? peripheral enable register 0 (per0) ? d/a converter mode register (dam) ? d/a conversion value setting registers w0, w1 (dacsw0, dacsw1) ? d/a conversion value setting registers 0, 1 (dacs0, dacs1) (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripheral hardware macro. clock supply to a hardware macro that is not used is stopped in order to reduc e the power consumption and noise. when the d/a converter is used, be sure to se t bit 6 (dacen) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. cautions when setting the d/ a converter, be sure to set dacen to 1 first. if dacen = 0, writing to a control register of the d/a conver ter is ignored, and, even if the register is read, only the default value is read. figure 11-2. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note sau1en sau0en tau1en tau0en dacen control of d/a converter input clock 0 stops supply of input clock. ? sfr used by the d/a converter cannot be written. ? the d/a converter is in the reset status. 1 supplies input clock. ? sfr used by the d/a converter can be read/written. note 78k0r/lg3, 78k0r/lh3 only 78k0r/lx3 r01uh0004ej0501 rev.5.01 421 jun 20, 2011 chapter 11 d/a converter ( pd78f150xa only) (2) d/a converter mode register (dam) this register controls the oper ation of the d/a converter. dam can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 11-3. format of d/a converter mode register (dam) address: fff5ch after reset: 00h r/w symbol 7 6 <5> <4> 3 2 1 0 dam 0 daref dace1 dace0 dares1 dares0 damd1 damd0 daref positive reference voltage supply selection of d/a converter note1 0 av dd1 (power supply for d/a co nverter analog circuit) 1 v refout (voltage reference output) note2 / av refp (external voltage reference input) dacen d/a conversion operation control (n = 0, 1) 0 stops conversion operation 1 enables conversion operation daresn d/a converter resolution selection (n = 0, 1) 0 8-bit 1 12-bit damdn d/a converter operation mode selection (n = 0, 1) 0 normal mode 1 real-time output mode notes 1. the reference voltage of the d/a converter cannot be specified separately for each channel because it is common to both channels. 2. to use an output voltage of the volt age reference for the positive refere nce voltage of the d/a converter (da refp ), start operating the voltage reference before setting the d/a conversion operation (see chapter 13 voltage reference ). furthermore, do not change the vo ltage reference setting during the d/a conversion operation. remark the positive reference voltage of the d/a converter is as follows, a ccording to the daref, vrsel and vron settings. table 11-2. settings of daref, vrsel and vron daref vrsel vron positive reference voltage of d/a converter (da refp ) 0 av dd1 1 0 0 av refp 1 1 1 v refout : don?t care 78k0r/lx3 r01uh0004ej0501 rev.5.01 422 jun 20, 2011 chapter 11 d/a converter ( pd78f150xa only) (3) d/a conversion value setting registers w0, w1 (dacsw0, dacsw1) these registers are used to set an analog voltage value to be output to the ano0 and ano1 pins, when the d/a converter is used. dacsw0 and dacsw1 can be read by a 16 -bit memory manipulation instruction. reset signal generation clears these registers to 0000h. figure 11-4. format of d/a conversion valu e setting registers w0, w1 (dacsw0, dacsw1) address: fff58h, fff59h (dacsw0), fff5ah, fff5bh (dacsw1) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 dacswn 0 0 0 0 dacs wn11 dacs wn10 dacs wn9 dacs wn8 dacs wn7 dacs wn6 dacs wn5 dacs wn4 dacs wn3 dacs wn2 dacs wn1 dacs wn0 caution rewriting dacswn during a/d c onversion is prohibited when both the positive reference voltage of the a/d converter (ad refp ) and the positive reference volt age of the d/a converter (da refp ) are the voltage reference output (v refout ) (vrsel = 1 and daref = 1). rewrite it when conversion operation is stopped (adcs = 0). remarks 1. the relations between the resolutions and analog output voltages (v anon ) of the d/a converter are as follows. ? 8-bit resolution (daresn = 0) : v anon = reference voltage for d/a converter (dacswn7 to dacswn0) /256 ? 12-bit resolution (daresn = 1) : v anon = reference voltage for d/a converter (dacswn11 to dacswn0) /4096 2. n = 0, 1 (4) d/a conversion value setting registers 0, 1 (dacs0, dacs1) these registers are used to set the analog voltage values to be output to the ano0 and ano1 pins when the d/a converter is used at 8-bit resolution. dacs0 and dacs1 can be read by an 8- bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 11-5. format of d/a conversion valu e setting registers 0, 1 (dacs0, dacs1) address: fff58h (dacs0), fff5ah (dacs1) after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 dacsn dacsn7 dacsn6 dacsn5 dacs n4 dacsn3 dacsn2 dacsn1 dacsn0 remarks 1. the relations between the resolutions and analog output voltages (v anon ) of the d/a converter are as follows. ? 8-bit resolution (daresn = 0) : v anon = reference voltage for d/a converter (dacsn7 to dacsn0) /256 2. n = 0, 1 78k0r/lx3 r01uh0004ej0501 rev.5.01 423 jun 20, 2011 chapter 11 d/a converter ( pd78f150xa only) 11.4 operation of d/a converter 11.4.1 operation in normal mode d/a conversion is performed using write operation to t he dacsn register as the trigger. the setting method is described below. <1> set bit 6 (dacen) of peripheral enable register 0 (per0) to 1 to start the supply of the input clock to the d/a converter. <2> set the damdn bit of the d/a converter mode register (dam) to 0 (normal mode). <3> use the bit 6 (daref) of the dam register to select the d/a converter reference voltage supply on the positive side. <4> use the daresn bit of the dam register to select the resolution of the d/a converter. <5> set the analog voltage value to be output to the anon pin to the d/a conversion value setting register wn (dacswn) or d/a conversion value setting register n (dacsn). steps <1> and <5> above constitute the initial settings. <6> set the dacen bit of the dam regi ster to 1 (d/a conversion enable). after the wait time (20 s or more) elapses, d/a conversion starts , and then, after the settling time (18 s (max.)) elapses, the d/a converted analog voltage value is output from the anon pin. <7> to perform subsequent d/a conversions, wr ite to the dacswn or dacsn register. the previous d/a conversion result is he ld until the next d/a c onversion is performed. when the dacen bit of the dam register is set to 0 (d/a conversion operation stop) , d/a conversion stops, the anon pin goes into a high-impedance state when the pm11n bit of the pm11 register = 1 (input mode), and the anon pin outputs the set value of the p11 re gister when the pm11n bit = 0 (output mode). cautions 1. even if 1, 0, and then 1 is set to the dacen bit, there is a wait after 1 is set for the last time. 2. if the dacswn or dacsn register is rewritten du ring the settling time, d/a conversion is aborted and reconversion by using the rewritten values starts. remark n = 0, 1 11.4.2 operation in real-time output mode d/a conversion is performed using the inte rrupt request signals (inttm04 and inttm05) note of timer channels 4 and 5 as triggers. the setting method is described below. note channel 0 of the d/a converter: inttm04 channel 1 of the d/a converter: inttm05 <1> set bit 6 (dacen) of peripheral enable register 0 (per0) to 1 to start the supply of the input clock to the d/a converter. <2> set the damdn bit of the d/a converter mode register (dam) to 0 (normal mode). <3> use the bit 6 (daref) of the dam register to select the d/a converter reference voltage supply on the positive side. <4> use the daresn bit of the dam register to select the resolution of the d/a converter. <5> set the analog voltage value to be output to the anon pin to the d/a conversion value setting register wn (dacswn) or d/a conversion value setting register n (dacsn). 78k0r/lx3 r01uh0004ej0501 rev.5.01 424 jun 20, 2011 chapter 11 d/a converter ( pd78f150xa only) <6> set the dacen bit of the dam regi ster to 1 (d/a conversion enable). after the wait time ( 20 s or more ) elapses, d/a conversion starts, and then, after the settling time (18 s (max.)) elapses, the d/a converted analog voltage value is output from the anon pin. <7> set the damdn bit of the dam r egister to 1 (real-time output mode). steps <1> to <7> above constitute the initial settings. <8> operate timer channel m. <9> generation of the inttm0m signa ls starts d/a conversion and the d/ a converted analog voltage value will be output from the anon pin after a settling time (18 s ( max .)) has elapsed. <10> afterward, the value set to the dacswn or dacsn register will be output at t he generation timing of the inttm0m signals. set the analog voltage value to be output to the anon pin, to the dacswn or dacs n register before performing the next d/a conversion (inttm0m signal are generated). when the dacen bit of the dam register is set to 0 (d /a conversion operation stop) , d/a conversion stops, the anon pin goes into a high-impedance state when the pm11n bit of the pm11 register = 1 (input mode), and the anon pin outputs the set value of the p11 re gister when the pm11n bit = 0 (output mode). cautions 1. even if 1, 0, and then 1 is set to the dace n bit, there is a wait after 1 is set for the last time. 2. make the interval be tween each generation of the inttm0m si gnal longer than the settling time. if an inttm0m signal is generated during the se ttling time, d/a conver sion is aborted and reconversion starts. 3. even if the generation of the inttm0m signal and rewriting the dacswn or dacsn register conflict, the d/a conver sion result is output. remark n = 0, 1 11.5 cautions for d/a converter observe the following cautions when using the d/a converter. (1) the digital port i/o function, which is the alternate f unction of the ano0 and ano1 pins, does not operate during d/a conversion. when the p11 register is read during d/a conversion, 0 is r ead in input mode and the set value of the p11 register is read in output mode. if the digital output mo de is set, no output data is output to pins. (2) the operation of the d/a converter continues in the halt and stop mode. to lower the power consumption, therefore, clear the dacen bit of the dam register to 0 (d/a conversion st op), and execute halt or stop instruction. (3) rewriting dacswn (n = 0, 1) during a/d conversion is pr ohibited when both the positive reference voltage of the a/d converter (ad refp ) and the positive reference voltage of the d/a converter (da refp ) are the voltage reference output (v refout ) (vrsel = 1 and daref = 1). rewrite it when conversion operation is stopped (adcs = 0). remark n = 0, 1, m = 4, 5 78k0r/lx3 r01uh0004ej0501 rev.5.01 425 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) chapter 12 operational amplifier ( pd78f150xa only) 78k0r/lf3 ( pd78f150na: n = 0 to 2) 78k0r/fg3 ( pd78f150na: n = 3 to 5) 78k0r/lh3 ( pd78f150na: n = 6 to 8) item 80 pins 100 pins 128 pins operational amplifier 2 ch (operational amplifiers 0, 1) 3 ch (operational amplifiers 0 to 2) 12.1 function of operational amplifier operational amplifiers are mounted onto products of 78k0r/lx3 microcontrollers . the operational amplifiers have the following modes. ? single amp mode the difference in potential of analog vo ltages input from two pins (ampn ? and ampn+ pins) is amplified and the amplified voltage is output from the ampno pin. the amplified voltage can be used as an analog input of the a/d converter, because the ampno pin is alternatively used with analog input pin of the a/d converter. remark 78k0r/lf3: n = 0, 1 78k0r/lg3, 78k0r/lh3: n = 0 to 2 12.2 configuration of operational amplifier the operational amplifiers consist of the following hardware. table 12-1. configuration of operational amplifiers item configuration operational amplifier input ampn - pin, ampn+ pin operational amplifier output ampno pin control registers peripheral enable register 0 (per0) operational amplifier control register (oac) a/d configuration register (adpc) port mode registers 2, 15 (pm2, pm15) remark 78k0r/lf3: n = 0, 1 78k0r/lg3, 78k0r/lh3: n = 0 to 2 78k0r/lx3 r01uh0004ej0501 rev.5.01 426 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) figure 12-1. block diagram of operational amplifier internal bus oaen0 operational amplifier control register (oac) amp2+/ani8/p150 amp2-/ani6/p26 amp2o/ani7/p27 amp2 amp1+/ani5/p25 amp1-/ani3/p23 amp1o/ani4/p24 amp1 ? + to a/d converter amp0+/ani2/p22 amp0-/ani0/p20 amp0o/ani1/p21 amp0 operational amplifier 0 oaen1 oaen2 oaen1 bit oaen0 bit operational amplifier 1 operational amplifier 2 to a/d converter to a/d converter ? + ? + remark 78k0r/lf3: operational amplifiers 0, 1 78k0r/lg3, 78k0r/lh3: operational amplifiers 0 to 2 78k0r/lx3 r01uh0004ej0501 rev.5.01 427 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) 12.3 amplifier registers used in operational amplifier the operational amplifiers use the following four registers. ? peripheral enable register 0 (per0) ? operational amplifier control register (oac) ? a/d port configuration register (adpc) ? port mode registers 2, 15 (pm2, pm15) (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripheral hardware macro. clock supply to a hardware macro that is not used is stopped in order to reduc e the power consumption and noise. when the operational amplifier is used, be sure to set bit 5 (adcen) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 12-2. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note sau1en sau0en tau1en tau0en adcen control of a/d converter, operational amplifier, and voltage reference input clock 0 stops input clock supply. ? sfr used by the a/d converter, operational amplifier, and voltage reference cannot be written. ? the a/d converter, operational amplifier, and voltage reference is in the reset status. 1 supplies input clock. ? sfr used by the a/d converter, operational amplifier, and voltage reference can be read and written. note 78k0r/lg3, 78k0r/lh3 only caution when setting operational am plifier, be sure to set adcen to 1 first. if adcen = 0, writing to a control register of operational am plifier is ignored, and, even if the register is read, only the default value is read 78k0r/lx3 r01uh0004ej0501 rev.5.01 428 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) (2) operational amplifier control register (oac) this register controls the operations of operational amplifiers 0 to 2. oac can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. remark 78k0r/lf3: operational amplifiers 0, 1 78k0r/lg3, 78k0r/lh3: operational amplifiers 0 to 2 figure 12-3. format of operational amplifier control register (oac) address: fff33h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 oac 0 0 0 0 0 oaen2 oaen1 oaen0 oaen2 operational amplifier 2 operation control 0 stops operational amplifier 2 operation 1 enables operational amplifier 2 operation oaen1 operational amplifier 1 operation control 0 stops operational amplifier 1 operation 1 enables operational amplifier 1 operation oaen0 operational amplifier 1 operation control 0 stops operational amplifier 0 operation 1 enables operational amplifier 0 operation cautions 1. use the adpc register to specify as analog inpu ts the pins to be used with operational amplifiers. 2. when using as digital inputs the pins of ports 2 and 15, which are not used with operational amplifiers, when the ope rational amplifiers are used, make su re that the inpu t levels are fixed. 78k0r/lx3 r01uh0004ej0501 rev.5.01 429 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) (3) a/d port configuration register (adpc) this register switches the ani0/amp0-/p20 to an i7/amp2o/p27, ani8/amp2+/p150 to ani10/p152, and ani15/av refm /p157 pins to analog input of a/d converter or digi tal i/o of port. set pins to be used with operational amplifiers to the analog input. adpc can be set by an 8-bit memory manipulation instruction. reset signal generation sets this register to 10h. remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 figure 12-4. format of a/d port configuration register (adpc) address: f0017h after reset: 10h r/w symbol 7 6 5 4 3 2 1 0 adpc 0 0 0 adpc4 adpc3 adpc2 adpc1 adpc0 analog input (a)/digita l i/o (d) switching port 15 port 2 adp c4 adp c3 adp c2 adp c1 adp c0 ani15 /av refm /p157 ani10 /p152 ani9 /p151 ani8 /amp2+ /p150 ani7 /amp2o /p27 ani6 /amp2- /p26 ani5 /amp1+ /p25 ani4 /amp1o /p24 ani3 /amp1- /p23 ani2 /amp0+ /p22 ani1 /amp0o /p21 ani0 /amp0- /p20 0 0 0 0 0 a a a a a a a a a a a a 0 0 0 0 1 a a a a a a a a a a a d 0 0 0 1 0 a a a a a a a a a a d d 0 0 0 1 1 a a a a a a a a a d d d 0 0 1 0 0 a a a a a a a a d d d d 0 0 1 0 1 a a a a a a a d d d d d 0 0 1 1 0 a a a a a a d d d d d d 0 0 1 1 1 a a a a a d d d d d d d 0 1 0 0 0 a a a a d d d d d d d d 0 1 0 0 1 a a a d d d d d d d d d 0 1 0 1 0 a a d d d d d d d d d d 0 1 1 1 1 a d d d d d d d d d d d 1 0 0 0 0 d d d d d d d d d d d d other than the above setting prohibited note this setting is prohibited for 78k0r/lf3. caution set pins to be used with oper ational amplifiers in the input mode by using port mode registers 2 and 15 (pm2, pm15). note note note note 78k0r/lx3 r01uh0004ej0501 rev.5.01 430 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) (4) port mode registers 2, 15 (pm2, pm15) when using ani0/amp0-/p20 to ani7/amp2o/p 27, ani8/amp2+/p150 to ani10/p152 and ani15/av refm /p157 pins for analog input port, set pm20 to pm27, pm150 to pm152, and p157 to 1. the output latches of p20 to p27, p150 to p152 and p157 at this time may be 0 or 1. if pm20 to pm27, pm150 to pm152 and pm157 are set to 0, they cannot be used as analog input port pins. pm2 and pm15 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets these registers to ffh. remark 78k0r/lf3: ani0-ani6, ani15 78k0r/lg3, 78k0r/lh3: ani0-ani10, ani15 caution if a pin is set as an analog input por t, not the pin level bu t ?0? is always read. figure 12-5. formats of port mode registers 2, 15 (pm2, pm15) ? 78k0r/lf3 address: fff22h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm2 1 pm26 pm25 pm24 pm23 pm22 pm21 pm20 address: fff2fh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm15 pm157 1 1 1 1 1 1 1 ? 78k0r/lg3, 78k0r/lh3 address: fff22h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm2 pm27 pm26 pm25 pm24 pm23 pm22 pm21 pm20 address: fff2fh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm15 pm157 1 1 1 1 pm152 pm151 pm150 pmmn pmn pin i/o mode selection (mn = 20 to 27, 150 to 152, 157) 0 output mode (output buffer on) 1 input mode (output buffer off) 78k0r/lx3 r01uh0004ej0501 rev.5.01 431 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) the ani0/amp0-/p20 to ani7/amp2o/p27, an i8/amp2+/p150 to ani10/p152 and ani15/av refm /p157 pins are as shown below depending on the settings of adpc , ads, pm2, pm15, oaenn bit and adref bit. table 12-2. setting functions of ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1-/p23, ani5/amp1+/p25, ani6/amp2-/p26, and ani8/amp2+/p150 pins adpc register pm2 and pm15 registers oaenn bit ads register ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1- /p23, ani5/amp1+/p25, ani6/amp2-/p26, and ani8/amp2+/p150 pins 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) selects ani. setting prohibited input mode 1 does not select ani. operational amplifier input analog input selection output mode ? ? setting prohibited remark 78k0r/lf3: ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1-/p23, ani5/amp1+/p25, n = 0, 1 78k0r/lg3, 78k0r/lh3: ani0/amp0-/p20, ani2/amp0+/p22, ani3/amp1-/p23, ani5/amp1+/p25, ani6/amp2-/p26, ani8/amp2+/p150, n = 0 to 2 caution when an operational amplifier is used, ampn+, ampn ? , and ampno pins are used, so the alternative analog input functions cannot be used. table 12-3. setting functions of ani1/amp0 o/p21, ani4/amp1o/p24, and ani7/amp2o/p27 pins adpc register pm2 register oaenn bit ads register ani1/amp0o/p21, ani4/amp1o/p24, and ani7/amp2o/p27 pins 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) selects ani. operational amplifier output (not to be converted) input mode 1 does not select ani. operational amplifier output (to be converted) analog input selection output mode ? ? setting prohibited remark 78k0r/lf3: ani1/amp0o/p21, ani4/amp1o/p24, n = 0, 1 78k0r/lg3, 78k0r/lh3: ani1/amp0o/p21, ani4 /amp1o/p24, and ani7/amp2o/p27, n = 0 to 2 78k0r/lx3 r01uh0004ej0501 rev.5.01 432 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) caution when an operational amplifier is used, ampn+, ampn ? , and ampno pins are used, so the alternative analog input functions cannot be used. the operational amplifie r output signals, however, can be used as analog inputs. table 12-4. setting functions of ani9/p151 and ani10/am152 pins adpc register pm15 register ads register ani9/p151 and ani10/am152 pins input mode ? digital input digital i/o selection output mode ? digital output selects ani. analog input (to be converted) input mode does not select ani. analog input (not to be converted) analog input selection output mode ? setting prohibited remark 78k0r/lf3: ani9/p151 and ani10/am152 are not mounted. 78k0r/lg3, 78k0r/lh3: ani9/p151, ani10/am152 table 12-5. setting functions of ani15/av refm /p157 pin adpc register pm15 register adref bit ads register ani15/av refm /p157 pin 0 ? digital input input mode 1 ? setting prohibited 0 ? digital output digital i/o selection output mode 1 ? setting prohibited selects ani. analog input (to be converted) 0 does not select ani. analog input (not to be converted) input mode 1 ? negative reference voltage input of a/d converter analog input selection output mode ? ? setting prohibited 78k0r/lx3 r01uh0004ej0501 rev.5.01 433 jun 20, 2011 chapter 12 operational amplifier ( pd78f150xa only) 12.4 operational amplifier operations the operational amplifiers 0 to 2 have the following mode. ? single amp mode (operational amplifiers 0 to 2) 12.4.1 single amp mode in single amplifier mode, the difference in potentia l of analog voltages input from two pins (ampn ? and ampn+ pins) is amplified and the amplified voltage is output from the ampno pin. the gain is determined by externally connecting a resistor or the like. the amplified voltage can be used as an analog input of the a/d converter, because the ampno pin is alternatively used with analog input pin of the a/d converter. the procedure for starting operation in sing le amplifier mode is described below. <1> set bit 5 (adcen) of peripheral enable register 0 (per0) to 1 to start the supply of the input clock to the operational amplifier. <2> use the a/d port confi guration register (adpc) to set the pins (ampn ? , ampn+, ampno) to be used in single amplifier mode as analog inputs. <3> use the port mode register x (pmx) to set the pins (ampn ? , ampn+, ampno) to be used in single amplifier mode to input mode. <4> set (1) the oaenn bit of operational amplifier control regi ster (oac) and enable operation in single amplifier mode. <5> use software to wait until the operatio nal amplifier stabilizes (turn-on time: 20 s (max.)). caution to use as an input of the a/d converter a voltage that has been amplified in single amplifier mode, enable operation in single amplifie r mode before selecting an analog input channel by using the ads register. remark 78k0r/lf3: n = 0, 1, x = 2 78k0r/lg3, 78k0r/lh3: n = 0 to 2, x = 2, 15 78k0r/lx3 r01uh0004ej0501 rev.5.01 434 jun 20, 2011 chapter 13 voltage reference ( pd78f150xa only) chapter 13 voltage reference ( pd78f150xa only) 13.1 function of voltage reference the voltage reference is mounted onto all 78k0r/lx3 mi crocontroller products. the voltage reference has the following modes. ? reference voltage output mode a reference voltage is output from the v refout pin. furthermore, the generated re ference voltage is supplied to the internal a/d and d/a converters. 2.0 v (typ.) or 2.5 v (typ.) can be sele cted as the output voltage. 13.2 configuration of voltage reference the voltage reference consists of the following hardware. table 13-1. configuration of voltage reference item configuration reference voltage output v refout pin control registers peripheral enable registers 0 (per0) analog reference voltage control register (advrc) figure 13-1. block diagra m of voltage reference internal bus vrgv analog reference voltage control register (advrc) v refout /av refp vron voltage reference circuit positive reference voltage of a/d converter and d/a converter vrsel 78k0r/lx3 r01uh0004ej0501 rev.5.01 435 jun 20, 2011 chapter 13 voltage reference ( pd78f150xa only) 13.3 amplifier registers used in voltage reference the voltage reference uses the following two registers. ? peripheral enable register 0 (per0) ? analog reference voltage control register (advrc) (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripheral hardware macro. clock supply to a hardware macro that is not used is stopped in order to reduc e the power consumption and noise. when the voltage reference is used, be sure to set bit 5 (adcen) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 13-2. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note sau1en sau0en tau1en tau0en adcen control of a/d converter, operational amplifier, and voltage reference input clock 0 stops input clock supply. ? sfr used by the a/d converter, operational amplifier, and voltage reference cannot be written. ? the a/d converter, operational amplifier, and voltage reference is in the reset status. 1 supplies input clock. ? sfr used by the a/d converter, operational amplifier, and voltage reference can be read and written. note 78k0r/lg3, 78k0r/lh3 only caution when setting voltage referen ce, be sure to set adcen to 1 first. if adcen = 0, writing to a control register of voltage reference is igno red, and, even if the register is read, only the default value is read. (2) analog reference voltage control register (advrc) this register is used to select the reference voltage suppl ies of the a/d and d/a conver ters, control the operation of the input gate voltage boost circuit for the a/d converte r, and control the voltage reference (vr) operation. advrc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. 78k0r/lx3 r01uh0004ej0501 rev.5.01 436 jun 20, 2011 chapter 13 voltage reference ( pd78f150xa only) figure 13-3. format of analog referen ce voltage control register (advrc) address: fff36h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 advrc adref 0 0 0 vrsel 0 vrgv vron adref negative reference voltage supply of a/d converter selection 0 av ss 1 av refm (external voltage reference input) vrsel vrgv vron positive reference voltage supplies selection of a/d and d/a converters operation control of voltage reference output voltage selection of voltage reference operation control of input gate voltage boost circuit for a/d converter relationship with the conversion mode used 0 0 0 2.5 v stops operation can be set in normal mode 1. 0 1 0 av refp (external voltage reference input) stops operation (hi-z) 2.0 v enables operation can be set in normal mode 2 or low voltage mode. 1 0 0 stops operation (pull-down output) 2.5 v stops operation ? 1 0 1 enables operation 2.5 v can be set in normal mode 2 or low voltage mode. 1 1 0 stops operation (pull-down output) 2.0 v ? 1 1 1 v refout (voltage reference output) enables operation 2.0 v enables operation can be set in normal mode 2 or low voltage mode. other than the above setting prohibited cautions 1. during voltage reference operation, be sure to connect a tantalum capacitor (capacitance: 10 f 30 %, esr: 2 (max.), esl: 10 nh (max.)) and a ceramic capacitor ( capacitance: 0.1 f 30 %, esr: 2 (max.), esl: 10 nh (max.)) to the v refout /av refp pin for stabilizing the reference voltage. furthermore, do not apply a voltage from the v refout /av refp pin during voltage reference operation. 2. to use voltage reference output (v refout ) to the positive reference vo ltage of the a/d converter (ad refp ) and the positive reference volt age of the d/a converter (da refp ), be sure to set vron to 1 after setting vrsel to 1. 78k0r/lx3 r01uh0004ej0501 rev.5.01 437 jun 20, 2011 chapter 13 voltage reference ( pd78f150xa only) cautions 3. rewriting dacswn (n = 0, 1) during a/ d conversion is prohibited when both the positive reference voltage of the a/d converter (ad refp ) and the positive refere nce voltage of the d/a converter (da refp ) are the voltage reference output (v refout ) (vrsel = 1 and daref = 1). rewrite it when conversion ope ration is stopped (adcs = 0). 4. do not change the output vo ltage of the reference voltage by using vrgv during the voltage reference operation (vron = 1). 13.4 voltage reference operations the voltage reference has the following mode. ? reference voltage output mode a reference voltage is output from the v refout pin. furthermore, the generated re ference voltage is supplied to the internal a/d and d/a converters. 2.0 v (typ.) or 2.5 v (typ.) can be sele cted as the output voltage. 13.4.1 reference voltage output mode the procedure for starting operation is described below. <1> set bit 5 (adcen) of peripheral enable register 0 (per0) to 1 to start the supply of the input clock to the voltage reference. <2> set bit 3 (vrsel) of the analog reference voltage control re gister (advrc) to 1. the positive reference voltage of both the a/d and d/a converters or only the a/d converter is set to voltage reference output. <3> specify the reference voltage val ue by using bit 1 (vrgv) of advrc. <4> enable voltage reference operation by setting bit 0 (vron) of advrc to 1. <5> use software to wait until the voltage referenc e operation stabilizes (settling time: 17 ms (max.)). 13.5 cautions for voltage reference observe the following cautions when using the voltage reference. ? the v refout output voltage can be used only as the positive reference voltage of t he internal a/d and d/a converters of the microcontroller. do not connect an external ci rcuit other than a tantalum capacitor (capacitance: 10 f 30 %, esr: 2 (max.), esl: 10 nh (max.)) and a ceramic capacitor (capacitance: 0.1 f 30 %, esr: 2 (max.), esl: 10 nh (max.)) to the v refout pin for stabilizing the reference voltage. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 438 jun 20, 2011 chapter 14 serial array unit the serial array unit has four serial channels per unit and can us e two or more of various serial interfaces (3-wire serial (csi), uart, and simplified i 2 c) in combination. function assignment of each channel su pported by the 78k0r/lx3 microcontroll ers is as shown below (channels 2 and 3 of unit 1 are dedicated to uart3 (supporting lin-bus)). ? 78k0r/lf3 unit channel used as csi used as uart used as simplified i 2 c 2 csi10 iic10 0 3 ? uart1 ? 0 csi20 iic20 1 ? uart2 ? 2 ? ? 1 3 ? uart3 (supporting lin-bus) ? ? 78k0r/lg3 unit channel used as csi used as uart used as simplified i 2 c 0 csi00 ? 1 ? uart0 ? 2 csi10 iic10 0 3 ? uart1 ? 0 csi20 iic20 1 ? uart2 ? 2 ? ? 1 3 ? uart3 (supporting lin-bus) ? ? 78k0r/lh3 unit channel used as csi used as uart used as simplified i 2 c 0 csi00 ? 1 csi01 uart0 ? 2 csi10 iic10 0 3 ? uart1 ? 0 csi20 iic20 1 ? uart2 ? 2 ? ? 1 3 ? uart3 (supporting lin-bus) ? (example of combination) when ?uart0? is used for c hannels 0 and 1 of unit 0, csi00 and csi01 cannot be used, but csi10, uart1, or iic10 can be used. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 439 jun 20, 2011 14.1 functions of serial array unit each serial interface supported by the 78k0r/lx3 microcontrollers has the following features. 14.1.1 3-wire serial i/o (csi00, csi01, csi10, csi20) this is a clocked communication function that uses thr ee lines: serial clock (sck) and serial data (si and so) lines. [data transmission/reception] ? data length of 7 or 8 bits ? phase control of transmit/receive data ? msb/lsb first selectable ? level setting of transmit/receive data [clock control] ? master/slave selection ? phase control of i/o clock ? setting of transfer period by prescaler and internal counter of each channel [interrupt function] ? transfer end interrupt/buffer empty interrupt [error detection flag] ? overrun error 14.1.2 uart (uart0, uart1, uart2, uart3) this is a start-stop synchronization function using two lines: serial data transmission (t x d) and serial data reception (r x d) lines. it transmits or receives data in asynchroniza tion with the party of communication (by using an internal baud rate). full-duplex uart communication can be realized by using two channels, one dedicated to transmission (even channel) and the other to reception (odd channel). [data transmission/reception] ? data length of 5, 7, or 8 bits ? select the msb/lsb first ? level setting of transmit/recei ve data and select of reverse ? parity bit appending and parity check functions ? stop bit appending [interrupt function] ? transfer end interrupt/buffer empty interrupt ? error interrupt in case of framing error, parity error, or overrun error [error detection flag] ? framing error, parity error, or overrun error the lin-bus is accepted in uart 3 (2 and 3 channels of unit 1) [lin-bus functions] ? wakeup signal detection ? sync break field (sbf) detection ? sync field measurement, baud rate calculation external interrupt (intp0) or timer array unit (tau) is used. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 440 jun 20, 2011 14.1.3 simplified i 2 c (iic10, iic20) this is a clocked communication function to communicate wit h two or more devices by using two lines: serial clock (scl) and serial data (sda). this simplified i 2 c is designed for single communica tion with a device such as eeprom, flash memory, or a/d converter, and ther efore, it functions only as a master an d does not have a function to detect wait states. make sure by using software, as well as operating the control registers, that the ac specif ications of the start and stop conditions are observed. [data transmission/reception] ? master transmission, master reception (onl y master function with a single master) ? ack output function note and ack detection function ? data length of 8 bits (when an address is transmitted, t he address is specified by the higher 7 bits, and the least significant bit is used for r/w control.) ? manual generation of start condition and stop condition [interrupt function] ? transfer end interrupt [error detection flag] ? parity error (ack error) [functions not supported by simplified i 2 c] ? slave transmission, slave reception ? arbitration loss detection function ? wait detection functions note an ack is not output when the la st data is being received by writing 0 to the soemn (soem register) bit and stopping the output of serial communication data. see 14.7.3 (2) processing flow for details. remarks 1. to use an i 2 c bus of full function, see chapter 15 serial interface iica . 2. m: unit number (m = 0, 1), n: channel number (n = 0, 2), mn = 02, 10 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 441 jun 20, 2011 14.2 configuration of serial array unit serial array unit includes the following hardware. table 14-1. configuration of serial array unit item configuration shift register 8 bits buffer register lower 8 bits of serial data register mn (sdrmn) note serial clock i/o sck00, sck01, sck10, sck20 pins (for 3-wire serial i/o), scl10, scl20 pins (for simplified i 2 c) serial data input si00, si01, si10, si20 pins (for 3-wire serial i/o), r x d0, r x d1, r x d2 pins (for uart), r x d3 pin (for uart supporting lin-bus) serial data output so00, so01, so10, so20 pins (for 3-wire serial i/o), t x d0, t x d1, t x d2 pins (for uart), t x d3 pin (for uart supporting lin-bus), output controller serial data i/o sda10, sda20 pins (for simplified i 2 c) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 442 jun 20, 2011 figure 14-1 shows the block diagram of serial array unit 0. figure 14-1. block diagram of serial array unit 0 serial data input pin (when csi01: si01) serial transfer end interrupt (when csi01: intcsi01) (when uart0: intsr0) serial clock select register 0 (sps0) prs 013 4 prs 003 prs 012 prs 011 prs 010 prs 002 prs 001 prs 000 4 f clk f clk /2 0 to f clk /2 11 selector f clk /2 0 to f clk /2 11 selector cks00 md001 ccs00 sts00 md002 mode selection csi00 or uart0 (for transmission) edge detection communication controller shift register serial data register 00 (sdr00) interrupt controller edge/level detection serial output register 0 (so0) 0 soe02 soe01 soe00 serial output enable register 0 (soe0) serial clock i/o pin (when csi00: sck00) pm80 sau0en peripheral enable register 0 (per0) serial data input pin (when csi00: si00) (when uart0: rxd0) serial data output pin (when csi00: so00) (when uart0: t x d0) serial mode register 00 (smr00) se03 se02 se01 se00 serial channel enable status register 0 (se0) st03 st02 st01 st00 serial channel stop register 0 (st0) ss03 ss02 ss01 ss00 serial channel start register 0 (ss0) (buffer register block) (clock division setting block) error controller txe 00 rxe 00 dap 00 ckp 00 serial communication operation setting register 00 (scr00) eoc 00 fect 00 pect 00 serial flag clear trigger register 00 (sir00) ovct 00 ptc 001 slc 000 ptc 000 dir 00 slc 001 dls 002 dls 001 dls 000 tsf 00 ovf 00 bff 00 fef 00 pef 00 serial status register 00 (ssr00) output controller serial transfer end interrupt (when csi00: intcsi00) (when uart0: intst0) error information clear channel 0 mode selection csi01 or uart0 (for reception) communication controller channel 1 serial data input pin (when csi10: si10) (when iic10: sda10) (when uart1: r x d1) serial data output pin (when csi10: so10) (when iic10: sda10) (when uart1: t x d1) serial transfer end interrupt (when csi10: intcsi10) (when iic10: intiic10) (when uart1: intst1) mode selection csi10 or iic10 or uart1 (for transmission) communication controller channel 2 mode selection uart1 (for reception) communication controller channel 3 ck01 inttm02 ck00 mck tclk sck output latch (p80) serial clock i/o pin (when csi10: sck10) (when iic10: scl10) serial transfer error interrupt (intsre0) serial transfer end interrupt (when uart1: intsr1) serial transfer error interrupt (intsre1) serial data output pin (when csi01: so01) serial clock i/o pin (when csi01: sck01) ck01 ck00 ck01 ck00 ck01 ck00 snfen 10 noise filter enable register 0 (nfen0) snfen 00 noise elimination enabled/ disabled snfen00 edge/level detection selector when uart0 edge/level detection edge/level detection noise elimination enabled/ disabled snfen10 when uart1 pm82 output latch (p82) 0 sol02 0 sol00 serial output level register 0 (sol0) error controller error controller selector clock controller selector communication status prescaler 1 1 cko02 cko01 cko00 so02 so01 so00 0 0 00 0 0 00 remarks 1. for 78k0r/lf3, the channels 0 and 1 are not mounted. 2. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 443 jun 20, 2011 figure 14-2 shows the block diagram of serial array unit 1. figure 14-2. block diagram of serial array unit 1 serial clock select register 1 (sps1) prs 113 4 prs 103 prs 112 prs 111 prs 110 prs 102 prs 101 prs 100 4 f clk f clk /2 0 to f clk /2 11 selector f clk /2 0 to f clk /2 11 selector cks10 md101 ccs10 sts10 md102 mode selection csi20 or iic20 or uart2 (for transmission) communication controller shift register serial data register 10 (sdr10) interrupt controller serial output register 1 (so1) sau1en peripheral enable register 0 (per0) serial data output pin (when csi20: so20) (when iic20: sda20) (when uart2: txd2) serial mode register 10 (smr10) (buffer register block) (clock division setting block) error controller txe 10 rxe 10 dap 10 ckp 10 serial communication operation setting register 10 (scr10) eoc 10 fect 10 pect 10 serial flag clear trigger register 10 (sir10) ovct 10 ptc 101 slc 100 ptc 100 dir 10 slc 101 dls 102 dls 101 dls 100 tsf 10 ovf 10 bff 10 fef 10 pef 10 serial status register 10 (ssr10) output controller serial transfer end interrupt (when csi20: intcsi20) (when iic20: intiic20) (when uart2: intst2) error information clear channel 0 ck11 ck10 mck tclk serial transfer end interrupt (when uart3: intsr3) serial transfer error interrupt (intsre3) mode selection uart2 (for reception) communication controller channel 1 mode selection uart3 (for transmission) communication controller channel 2 (lin-bus supported) mode selection uart3 (for reception) communication controller channel 3 (lin-bus supported) serial transfer end interrupt (when uart2: intsr2) serial transfer error interrupt (intsre2) serial data output pin (when uart3: t x d3) serial transfer end interrupt (when uart3: intst3) ck11 ck10 ck11 ck10 ck11 ck10 edge detection serial clock i/o pin (when csi20: sck20) (when iic20: scl20) pm10 sck output latch (p10) edge/level detection serial data input pin (when csi20: si20) (when iic20: sda20) (when uart2: rxd2) noise elimination enabled/ disabled snfen20 snfen 30 noise filter enable register 0 (nfen0) snfen 20 edge/level detection serial data input pin (when uart3: rxd3) snfen30 when uart3 edge/level detection when uart2 noise elimination enabled/ disabled pm11 or pm12 output latch ( p11 or p12) 0 soe12 0 soe10 serial output enable register 1 (soe1) se13 se12 se11 se10 serial channel enable status register 1 (se1) st13 st12 st11 st10 serial channel stop register 1 (st1) ss13 ss12 ss11 ss10 serial channel start register 1 (ss1) 0 sol12 0 sol10 serial output level register 1 (sol1) error controller error controller selector clock controller selector communication status inttm03 prescaler 11 1 1 cko10 so12 1 so10 000 0 000 0 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 444 jun 20, 2011 (1) shift register this is an 8-bit register that converts para llel data into serial data or vice versa. during reception, it converts data inpu t to the serial pin into parallel data. when data is transmitted, the value set to this register is output as serial data from the serial output pin. the shift register cannot be dire ctly manipulated by program. to read or write the shift register, use the lowe r 8 bits of serial data register mn (sdrmn). 7 6 5 4 3 2 1 0 shift register (2) lower 8 bits of the serial data register mn (sdrmn) sdrmn is the transmit/receive data regist er (16 bits) of channel n. bits 7 to 0 function as a transmit/receive buffer register, and bits 15 to 9 are used as a register that sets the division ratio of the operation clock (mck). when data is received, parallel data conver ted by the shift register is stored in the lower 8 bits. when data is to be transmitted, set transmit to be transferred to the shift register to the lower 8 bits. the data stored in the lower 8 bits of th is register is as follows, depending on the setting of bits 0 to 2 (dlsmn0 to dlsmn2) of the scrmn register, regardle ss of the output sequ ence of the data. ? 5-bit data length (stored in bits 0 to 4 of sdrmn register) (settable in uart mode only) ? 7-bit data length (stored in bits 0 to 6 of sdrmn register) ? 8-bit data length (stored in bits 0 to 7 of sdrmn register) sdrmn can be read or written in 16-bit units. the lower 8 bits of sdrmn of sdrmn can be read or written note as the following sfr, depending on the communication mode. ? csip communication ? siop (csip data register) ? uartq reception ? rxdq (uartq receive data register) ? uartq transmission ? txdq (uartq transmit data register) ? iicr communication ? sior (iicr data register) reset signal generation clears this register to 0000h. remarks 1. after data is received, ?0? is stored in bits 0 to 7 in bit portions that exceed the data length. 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 3), p: csi number (p = 00, 01, 10, 20), q: uart number (q = 0 to 3), r: iic number (r = 10, 20) note writing in 8-bit units is prohibited when the operation is stopped (semn = 0). 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 445 jun 20, 2011 figure 14-3. format of serial data register mn (sdrmn) address: fff10h, fff11h (sdr00), fff12h, fff13h (sdr01), after reset: 0000h r/w fff44h, fff45h (sdr02), fff46h, fff47h (sdr03), fff48h, fff49h (sdr10), fff4ah, fff4bh (sdr11), fff14h, fff15h (sdr12), fff16h, fff17h (sdr13) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn 0 (m = 0, 1; n = 0 to 3) 7 6 5 4 3 2 1 0 shift register caution be sure to clear bit 8 to ?0?. remarks 1. for the function of the hi gher 7 bits of sdrmn, see 14.3 registers controlling serial array unit . 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 3), p: csi number (p = 00, 01, 10, 20), q: uart number (q = 0 to 3), r: iic number (r = 10, 20) fff11h (sdr00) fff10h (sdr00) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 446 jun 20, 2011 14.3 registers controlling serial array unit serial array unit is controlled by the following registers. ? peripheral enable register 0 (per0) ? serial clock select register m (spsm) ? serial mode register mn (smrmn) ? serial communication operation setting register mn (scrmn) ? serial data register mn (sdrmn) ? serial status register mn (ssrmn) ? serial flag clear trigger register mn (sirmn) ? serial channel enable status register m (sem) ? serial channel start register m (ssm) ? serial channel stop register m (stm) ? serial output enable register m (soem) ? serial output level register m (solm) ? serial output register m (som) ? input switch control register (isc) ? noise filter enable register 0 (nfen0) ? port input mode registers 1, 7 (pim1, pim7) ? port output mode registers 1, 7, 8 (pom1, pom7, pom8) ? port mode registers 1, 5, 7, 8 (pm1, pm5, pm7, pm8) ? port registers 1, 5, 7, 8 (p1, p5, p7, p8) remark m: unit number (m = 0, 1) n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 447 jun 20, 2011 (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripheral hardware macro. clock supply to a hardware macro that is not used is stopped in order to r educe the power consumption and noise. when serial array unit 0 is used, be sure to set bit 2 (sau0en) of this register to 1. when serial array unit 1 is used, be sure to set bit 3 (sau1en) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 14-4. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note sau1en sau0en tau1en tau0en saumen control of serial array unit m input clock 0 stops supply of input clock. ? sfr used by serial array unit m cannot be written. ? serial array unit m is in the reset status. 1 supplies input clock. ? sfr used by serial array unit m can be read/written. note 78k0r/lg3, 78k0r/lh3 only cautions 1. when setting serial array uni t m, be sure to set saumen to 1 first. if saumen = 0, writing to a control register of serial array unit m is ignored, and, even if the register is read, only the default value is read (except for input switch cont rol register (isc), noise filter enable register (nfen0), port input mode registers (pim1, pi m7), port output mode registers (pom1, pom7, pom8), port mode registers (pm1, pm5, pm7, pm8), and port registers (p1, p5, p7, p8)). 2. after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. remark m: unit number (m = 0, 1) (2) serial clock select register m (spsm) spsm is a 16-bit register that is used to select two types of operation clocks (ckm 0, ckm1) that are commonly supplied to each channel. ckm1 is selected by bits 7 to 4 of spsm, and ckm0 is selected by bits 3 to 0. rewriting spsm is prohibited when the register is in operation (when semn = 1). spsm can be set by a 16-bit memory manipulation instruction. the lower 8 bits of spsm can be set with an 8-bi t memory manipulation instruction with spsml. reset signal generation clears this register to 0000h. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 448 jun 20, 2011 figure 14-5. format of serial clock select register m (spsm) address: f0126h, f0127h (sps0), f0166h, f0167h (sps1) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 spsm 0 0 0 0 0 0 0 0 prs m13 prs m12 prs m11 prs m10 prs m03 prs m02 prs m01 prs m00 section of operation clock (ckmp) note 1 prs mp3 prs mp2 prs mp1 prs mp0 f clk = 2 mhz f clk = 5 mhz f clk = 10 mhz f clk = 20 mhz 0 0 0 0 f clk 2 mhz 5 mhz 10 mhz 20 mhz 0 0 0 1 f clk /2 1 mhz 2.5 mhz 5 mhz 10 mhz 0 0 1 0 f clk /2 2 500 khz 1.25 mhz 2.5 mhz 5 mhz 0 0 1 1 f clk /2 3 250 khz 625 khz 1.25 mhz 2.5 mhz 0 1 0 0 f clk /2 4 125 khz 313 khz 625 khz 1.25 mhz 0 1 0 1 f clk /2 5 62.5 khz 156 khz 313 khz 625 khz 0 1 1 0 f clk /2 6 31.3 khz 78.1 khz 156 khz 313 khz 0 1 1 1 f clk /2 7 15.6 khz 39.1 khz 78.1 khz 156 khz 1 0 0 0 f clk /2 8 7.81 khz 19.5 khz 39.1 khz 78.1 khz 1 0 0 1 f clk /2 9 3.91 khz 9.77 khz 19.5 khz 39.1 khz 1 0 1 0 f clk /2 10 1.95 khz 4.88 khz 9.77 khz 19.5 khz 1 0 1 1 f clk /2 11 977 hz 2.44 khz 4.88 khz 9.77 khz 1 1 1 1 inttm02 if m = 0, inttm03 if m = 1 note 2 other than above setting prohibited notes 1. when changing the clock selected for f clk (by changing the system clock control register (ckc) value), do so after having stopped (stm = 000fh) the operation of the serial array unit (saum). when selecting inttm02 and inttm03 for the operation clock, also stop the timer array unit (tau0) (tt0 = 00ffh). 2. saum can be operated at a fixed division rati o of the subsystem clock, regardless of the f clk frequency (main system clock, subsystem clock), by operating the interval timer for which f sub /4 has been selected as the count clock (setting tis02 (if m = 0) or tis03 (if m = 1) of the tis0 register to 1) and selecting inttm02 and inttm03 by using the spsm register in channels 2 and 3 of tau0. when changing f clk , however, saum and tau0 must be stopped as described in note 1 above. cautions 1. be sure to clear bits 15 to 8 to ?0?. 2. after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. remarks 1. f clk : cpu/peripheral hardware clock frequency f sub : subsystem clock frequency 2. m: unit number (m = 0, 1), p = 0, 1 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 449 jun 20, 2011 (3) serial mode register mn (smrmn) smrmn is a register that se ts an operation mode of channel n. it is also used to select an operation clock (mck), specify whether the serial clock (sck) may be input or not, set a start trigger, an operation mode (csi, uart, or i 2 c), and an interrupt source. this register is also used to invert the level of the receive data only in the uart mode. rewriting smrmn is prohibited when the register is in operation (when semn = 1). however, the mdmn0 bit can be rewritten during operation. smrmn can be set by a 16-bit memory manipulation instruction. reset signal generation sets this register to 0020h. figure 14-6. format of serial m ode register mn (smrmn) (1/2) address: f0110h, f0111h (smr00) to f0116h, f0117h (smr03), after reset: 0020h r/w f0150h, f0151h (smr10), f0152h, f0153h (smr11), f0154h, f0155h (smr12), f0156h, f0157h (smr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cks mn ccs mn 0 0 0 0 0 sts mn 0 sis mn0 1 0 0 md mn2 md mn1 md mn0 cks mn selection of operation cl ock (mck) of channel n 0 prescaler output clock ckm0 set by spsm register 1 prescaler output clock ckm1 set by spsm register operation clock mck is used by the edge detector. in addition, depending on the setting of the ccsmn bit and the higher 7 bits of the sdrmn register, a transfer clock (tclk) is generated. ccs mn selection of transfer clock (tclk) of channel n 0 divided operation clock mck specified by cksmn bit 1 clock input from sck pin (slave transfer in csi mode) transfer clock tclk is used for the sh ift register, communication controller, output controller, interrupt controller, and error controller. when ccsmn = 0, the division ratio of mck is set by the higher 7 bits of the sdrmn register. sts mn selection of start trigger source 0 only software trigger is valid (selected for csi, uart transmission, and simplified i 2 c). 1 valid edge of r x d pin (selected for uart reception) transfer is started when the above source is satisfied after 1 is set to the ssm register. caution be sure to clear bits 13 to 9, 7, 4, and 3 to ?0?. be sure to set bit 5 to ?1?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 450 jun 20, 2011 figure 14-6. format of serial m ode register mn (smrmn) (2/2) address: f0110h, f0111h (smr00) to f0116h, f0117h (smr03), after reset: 0020h r/w f0150h, f0151h (smr10), f0152h, f0153h (smr11), f0154h, f0155h (smr12), f0156h, f0157h (smr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cks mn ccs mn 0 0 0 0 0 sts mn 0 sis mn0 1 0 0 md mn2 md mn1 md mn0 sis mn0 controls inversion of level of receive data of channel n in uart mode 0 falling edge is detected as the start bit. the input communication data is captured as is. 1 rising edge is detected as the start bit. the input communication data is inverted and captured. md mn2 md mn1 setting of operation mode of channel n 0 0 csi mode 0 1 uart mode 1 0 simplified i 2 c mode 1 1 setting prohibited md mn0 selection of interrupt source of channel n 0 transfer end interrupt 1 buffer empty interrupt for successive transmission, the next transmit data is written by setting mdmn0 to 1 when sdrmn data has run out. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 451 jun 20, 2011 (4) serial communication operation setting register mn (scrmn) scrmn is a communication operation setting register of channel n. it is used to set a data transmission/reception mode, phase of data and clock, whether an error signal is to be masked or not, parity bit, start bit, stop bit, and data length. rewriting scrmn is prohibited when the register is in operation (when semn = 1). scrmn can be set by a 16-bit memory manipulation instruction. reset signal generation sets this register to 0087h. figure 14-7. format of serial communication operation setting register mn (scrmn) (1/3) address: f0118h, f0119h (scr00) to f011eh, f011fh (scr03), after reset: 0087h r/w f0158h, f0159h (scr10), f015ah, f015bh (scr11), f015ch, f015dh (scr12), f015eh, f015fh (scr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txe mn rxe mn dap mn ckp mn 0 eoc mn ptc mn1 ptc mn0 dir mn 0 slc mn1 slc mn0 0 dls mn2 dls mn1 dls mn0 txe mn rxe mn setting of operation mode of channel n 0 0 does not start communication. 0 1 reception only 1 0 transmission only 1 1 transmission/reception dap mn ckp mn selection of data and clock phase in csi mode type 0 0 d7 d6 d5 d4 d3 d2 d1 d0 sckp sop si p input timing 1 0 1 d7 d6 d5 d4 d3 d2 d1 d0 sckp sop si p input timing 2 1 0 d7 d6 d5 d4 d3 d2 d1 d0 sckp sop si p input timing 3 1 1 d7 d6 d5 d4 d3 d2 d1 d0 sckp sop si p input timing 4 be sure to set dapmn, ckpmn = 0, 0 in the uart mode and simplified i 2 c mode. caution be sure to clear bits 3, 6, and 11 to ?0?. be sure to set bit 2 to ?1?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 452 jun 20, 2011 figure 14-7. format of serial communication operation setting register mn (scrmn) (2/3) address: f0118h, f0119h (scr00) to f011eh, f011fh (scr03), after reset: 0087h r/w f0158h, f0159h (scr10), f015ah, f015bh (scr11), f015ch, f015dh (scr12), f015eh, f015fh (scr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txe mn rxe mn dap mn ckp mn 0 eoc mn ptc mn1 ptc mn0 dir mn 0 slc mn1 slc mn0 0 dls mn2 dls mn1 dls mn0 eoc mn selection of masking of error interr upt signal (intsrex (x = 0 to 3)) 0 masks error interrupt intsrex (intsrx is not masked). 1 enables generation of error interrupt intsre x (intsrx is masked if an error occurs). set eocmn = 0 in the csi mode, simplified i 2 c mode, and during uart transmission. note set eocmn = 1 during uart reception. setting of parity bit in uart mode ptc mn1 ptc mn0 transmission reception 0 0 does not output the parity bit. receives without parity 0 1 outputs 0 parity. no parity judgment 1 0 outputs even parity. judged as even parity. 1 1 outputs odd parity. judges as odd parity. be sure to set ptcmn1, ptcmn0 = 0, 0 in the csi mode and simplified i 2 c mode. dir mn selection of data transfer sequence in csi and uart modes 0 inputs/outputs data with msb first. 1 inputs/outputs data with lsb first. be sure to clear dirmn = 0 in the simplified i 2 c mode. slc mn1 slc mn0 setting of stop bit in uart mode 0 0 no stop bit 0 1 stop bit length = 1 bit 1 0 stop bit length = 2 bits 1 1 setting prohibited when the transfer end interrupt is selected, the interr upt is generated when all stop bits have been completely transferred. set 1 bit (slcmn1, slcmn0 = 0, 1) during uart reception and in the simplified i 2 c mode. set no stop bit (slcmn1, slcmn0 = 0, 0) in the csi mode. note when using csi01 not with eoc01 = 0, error interrupt intsre0 may be generated. caution be sure to clear bits 3, 6, and 11 to ?0?. be sure to set bit 2 to ?1?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 453 jun 20, 2011 figure 14-7. format of serial communication operation setting register mn (scrmn) (3/3) address: f0118h, f0119h (scr00) to f011eh, f011fh (scr03), after reset: 0087h r/w f0158h, f0159h (scr10), f015ah, f015bh (scr11), f015ch, f015dh (scr12), f015eh, f015fh (scr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txe mn rxe mn dap mn ckp mn 0 eoc mn ptc mn1 ptc mn0 dir mn 0 slc mn1 slc mn0 0 dls mn2 dls mn1 dls mn0 dls mn2 dls mn1 dls mn0 setting of data length in csi and uart modes 1 0 0 5-bit data length (stored in bits 0 to 4 of sdrmn register) (settable in uart mode only) 1 1 0 7-bit data length (stored in bits 0 to 6 of sdrmn register) 1 1 1 8-bit data length (stored in bits 0 to 7 of sdrmn register) other than above setting prohibited be sure to set dlsmn0 = 1 in the simplified i 2 c mode. caution be sure to clear bits 3, 6, and 11 to ?0?. be sure to set bit 2 to ?1?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 454 jun 20, 2011 (5) higher 7 bits of the serial data register mn (sdrmn) sdrmn is the transmit/receive data regist er (16 bits) of channel n. bits 7 to 0 function as a transmit/receive buffer register, and bits 15 to 9 are used as a register that sets the division ratio of the operation clock (mck). if the ccsmn bit of serial mode register mn (smrmn) is clear ed to 0, the clock set by dividing the operating clock by the higher 7 bits of sdrmn is used as the transfer clock. for the function of the lower 8 bits of sdrmn, see 14.2 configuration of serial array unit . sdrmn can be read or written in 16-bit units. however, the higher 7 bits can be written or read only when the operation is stopped (semn = 0). during operation (semn = 1), a value is written only to the lower 8 bits of sdrmn. when sdrmn is r ead during operation, 0 is always read. reset signal generation clears this register to 0000h. figure 14-8. format of serial data register mn (sdrmn) address: fff10h, fff11h (sdr00), fff12h, fff13h (sdr01), after reset: 0000h r/w fff44h, fff45h (sdr02), fff46h, fff47h (sdr03), fff48h, fff49h (sdr10), fff4ah, fff4bh (sdr11), fff14h, fff15h (sdr12), fff16h, fff17h (sdr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn 0 sdrmn[15:9] transfer clock setting by dividing the oper ating clock (mck) 0 0 0 0 0 0 0 mck/2 0 0 0 0 0 0 1 mck/4 0 0 0 0 0 1 0 mck/6 0 0 0 0 0 1 1 mck/8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 1 1 1 1 0 mck/254 1 1 1 1 1 1 1 mck/256 cautions 1. be sure to clear bit 8 to ?0?. 2. setting sdrmn[15:9] = (0000000b, 0000001 b) is prohibited when uart is used. 3. setting sdrmn[15:9] = 0000000b is prohibited when the simplified i 2 c is used. set sdrmn[15:9] to 0000001b or greater. remarks 1. for the function of the lower 8 bits of sdrmn, see 14.2 configuration of serial array unit . 2. m: unit number (m = 0, 1) n: channel number (n = 0 to 3) fff11h (sdr00) fff10h (sdr00) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 455 jun 20, 2011 (6) serial status register mn (ssrmn) ssrmn is a register that indicates t he communication status and error occurrenc e status of channel n. the errors indicated by this register are a framing error, parity error, and overrun error. ssrmn can be read by a 16-bit memory manipulation instruction. the lower 8 bits of ssrmn can be set with an 8-bit memory manipulation instruction with ssrmnl. reset signal generation clears this register to 0000h. figure 14-9. format of serial st atus register mn (ssrmn) (1/2) address: f0100h, f0101h (ssr00) to f0106h, f0107h (ssr03), after reset: 0000h r f0140h, f0141h (ssr10), f0142h, f0143h (ssr11), f0144h, f0145h (ssr12), f0146h, f0147h (ssr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssrmn 0 0 0 0 0 0 0 0 0 tsf mn bff mn 0 0 fef mn note pef mn note ovf mn note tsf mn communication status indica tion flag of channel n 0 communication is not under execution. 1 communication is under execution. because this flag is an updating flag, it is automatically cleared when the communication operation is completed. this flag is cleared also when the stmn/ssmn bit is set to 1. bff mn buffer register status indication flag of channel n 0 valid data is not stored in the sdrmn register. 1 valid data is stored in the sdrmn register. this is an updating flag. it is automatic ally cleared when transfer from the sdrm n register to the shift register is completed. during reception, it is automatically clear ed when data has been read from the sdrmn register. this flag is cleared also when the stmn/ssmn bit is set to 1. this flag is automatically set if transmit data is written to the sdrmn register when the txemn bit of the scrmn register = 1 (transmission or reception mode in each communi cation mode). it is automatically set if receive data is stored in the sdrmn register when the rxemn bit of t he scrmn register = 1 (trans mission or reception mode in each communication mode). it is also set in case of a reception error. if data is written to the sdrmn register when bffmn = 1, the transmit/receive data stored in the register is discarded and an overrun error (ovfmn = 1) is detected. note only ssr12 register does not have fet12, pet12, and ovf12. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 456 jun 20, 2011 figure 14-9. format of serial st atus register mn (ssrmn) (2/2) address: f0100h, f0101h (ssr00) to f0106h, f0107h (ssr03), after reset: 0000h r f0140h, f0141h (ssr10), f0142h, f0143h (ssr11), f0144h, f0145h (ssr12), f0146h, f0147h (ssr13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssrmn 0 0 0 0 0 0 0 0 0 tsf mn bff mn 0 0 fef mn note pef mn note ovf mn note fef mn framing error detecti on flag of channel n 0 no error occurs. 1 a framing error occurs during uart reception. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 457 jun 20, 2011 (7) serial flag clear trigger register mn (sirmn) sirmn is a trigger register that is used to clear each error flag of channel n. when each bit (fectmn, pectmn, ovctmn) of this regist er is set to 1, the corresponding bit (fefmn, pefmn, ovfmn) of serial status register mn is cleared to 0. be cause sirmn is a trigger register, it is cleared immediately when the corresponding bit of ssrmn is cleared. sirmn can be set by a 16-bit memory manipulation instruction. the lower 8 bits of sirmn can be set with an 8-bi t memory manipulation instruction with sirmnl. reset signal generation clears this register to 0000h. figure 14-10. format of serial flag clear trigger register mn (sirmn) address: f0108h, f0109h (sir00) to f010eh, f010fh (sir03), after reset: 0000h r/w f0148h, f0149h (sir10), f014ah, f014bh (sir11), f014eh, f014fh (sir13) symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sirmn 0 0 0 0 0 0 0 0 0 0 0 0 0 fec tmn pec tmn ovc tmn fec tmn clear trigger of fram ing error of channel n 0 no trigger operation 1 clears the fefmn bit of the ssrmn register to 0. pec tmn clear trigger of parity error flag of channel n 0 no trigger operation 1 clears the pefmn bit of the ssrmn register to 0. ovc tmn clear trigger of overrun error flag of channel n 0 no trigger operation 1 clears the ovfmn bit of the ssrmn register to 0. caution be sure to clear bits 15 to 3 to ?0?. remarks 1. m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 2. when the sirmn register is read, 0000h is always read. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 458 jun 20, 2011 (8) serial channel enable status register m (sem) sem indicates whether data transmission/reception ope ration of each channel is enabled or stopped. when 1 is written a bit of serial channel start register 0 (ss m), the corresponding bit of this register is set to 1. when 1 is written a bit of serial channel stop regi ster 0 (stm), the corresponding bit is cleared to 0. channel n that is enabled to operate cannot rewrite by softw are the value of ckomn of t he serial output register m (som) to be described below, and a value reflected by a co mmunication operation is output from the serial clock pin. channel n that stops operation can set the value of ckomn of the som regist er by software and output its value from the serial clock pin. in this way, any waveform, su ch as that of a start conditi on/stop condition, can be created by software. sem can be read by a 16-bit memory manipulation instruction. the lower 8 bits of sem can be set with an 1-bit or 8-bit memory manipulation instruction with seml. reset signal generation clears this register to 0000h. figure 14-11. format of serial channe l enable status register m (sem) address: f0120h, f0121h (se0), f0160h, f0161h (se1) after reset: 0000h r symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sem 0 0 0 0 0 0 0 0 0 0 0 0 sem 3 sem 2 sem 1 sem 0 sem n indication of operation enable/stop status of channel n 0 operation stops (stops with the values of the control r egister and shift register, and the statuses of the serial clock i/o pin, serial data output pin, and the fef, pef, and ovf error flags retained note ). 1 operation is enabled. note bits 6 and 5 (tsfmn, bffmn) of the ssrmn register are cleared. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 459 jun 20, 2011 (9) serial channel start register m (ssm) ssm is a trigger register that is used to enab le starting communication/count by each channel. when 1 is written a bit of this regist er (ssmn), the corresponding bit (semn) of serial channel enable status register m (sem) is set to 1. because ssmn is a trigger bit, it is cleared immediately when semn = 1. ssm can be set by a 16-bit memory manipulation instruction. the lower 8 bits of ssm can be set with an 1-bit or 8-bit memory manipulation instruction with ssml. reset signal generation clears this register to 0000h. figure 14-12. format of serial channel start register m (ssm) address: f0122h, f0123h (ss0), f0162h, f0163h (ss1) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm 3 ssm 2 ssm 1 ssm 0 ssmn operation start trigger of channel n 0 no trigger operation 1 sets semn to 1 and enters the communication wait st atus (if a communication operation is already under execution, the operation is stopped and the start condition is awaited). caution be sure to clear bits 15 to 4 to ?0?. remarks 1. m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 2. when the ssm register is read, 0000h is always read. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 460 jun 20, 2011 (10) serial channel stop register m (stm) stm is a trigger register that is used to en able stopping communication/count by each channel. when 1 is written a bit of this register (stmn), the corre sponding bit (semn) of serial channel enable status register m (sem) is cleared to 0. because stmn is a trigger bit, it is cleared immediately when semn = 0. stm can set written by a 16-bit me mory manipulation instruction. the lower 8 bits of stm can be set with an 1-bit or 8-bit memory manipulation instruction with stml. reset signal generation clears this register to 0000h. figure 14-13. format of serial channel stop register m (stm) address: f0124h, f0125h (st0), f0164h, f0165h (st1) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 stm 0 0 0 0 0 0 0 0 0 0 0 0 stm 3 stm 2 stm 1 stm 0 stm n operation stop trigger of channel n 0 no trigger operation 1 clears semn to 0 and stops the communication operation. (stops with the values of the contro l register and shift register, and the st atuses of the serial clock i/o pin, serial data output pin, and the fef, pef, and ovf error flags retained note .) note bits 6 and 5 (tsfmn, bffmn) of the ssrmn register are cleared. caution be sure to clear bits 15 to 4 to ?0?. remarks 1. m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 2. when the stm register is read, 0000h is always read. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 461 jun 20, 2011 (11) serial output enable register m (soem) soem is a register that is used to enable or stop output of the serial comm unication operation of each channel. channel n that enables serial output cannot rewrite by software the value of so mn of the serial output register m (som) to be described below, and a value reflected by a co mmunication operation is output from the serial data output pin. for channel n, whose serial output is stopped, the somn value of the som register can be set by software, and that value can be output from the serial data output pin. in this way, any waveform of the start condition and stop condition can be created by software. soem can be set by a 16-bit memory manipulation instruction. the lower 8 bits of soem can be set with an 1-bit or 8-bit memory manipulation instruction with soeml. reset signal generation clears this register to 0000h. figure 14-14. format of serial output enable register m (soem) address: f012ah, f012bh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soe0 0 0 0 0 0 0 0 0 0 0 0 0 0 soe 02 soe 01 soe 00 address: f016ah, f016bh after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soe1 0 0 0 0 0 0 0 0 0 0 0 0 0 soe 12 0 soe 10 soe mn serial output enable/disable of channel n 0 stops output by serial communication operation. 1 enables output by serial communication operation. caution be sure to clear bits 15 to 3 of so e0, and bits 1 and 15 to 3 of soe1 to ?0?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), mn = 00 to 02, 10, 12 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 462 jun 20, 2011 (12) serial output register m (som) som is a buffer register for serial output of each channel. the value of bit n of this regi ster is output from the serial data output pin of channel n. the value of bit (n + 8) of this register is outp ut from the serial clock output pin of channel n. somn of this register can be rewritten by software only wh en serial output is disabled (soemn = 0). when serial output is enabled (soemn = 1), rewriting by software is ig nored, and the value of the register can be changed only by a serial communication operation. ckomn of this register can be rewritten by softwar e only when the channel operation is stopped (semn = 0). while channel operation is enabled (semn = 1), rewriti ng by software is ignored, and the value of ckomn can be changed only by a serial communication operation. to use the p10/sck20/scl20, p11/si20/sda20/rxd2 /intp6, p12/so20/txd2/to 02, p13/so10/txd1/to04, p14/si10/sda10/rxd1/intp4, p15/sck1 0/scl10/intp7, p51/txd3/sdgx (78k0r/lf3: x = 29, 78k0r/lg3: x = 38, 78k0r/lh3: x = 52), p75/sck01/kr 5, p77/so01/kr7, p80/sck00/intp11, or p82/so00/txd0 pin as a port function pin, set the corresponding ckomn and somn bits to ?1?. som can be set by a 16-bit memory manipulation instruction. reset signal generation clears this register to 0f0fh. figure 14-15. format of serial output register m (som) address: f0128h, f0129h after reset: 0f0fh r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 so0 0 0 0 0 1 cko 02 cko 01 cko 00 0 0 0 0 1 so 02 so 01 so 00 address: f0168h, f0169h after reset: 0f0fh r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 so1 0 0 0 0 1 1 1 cko 10 0 0 0 0 1 so 12 1 so 10 cko mn serial clock output of channel n 0 serial clock output value is ?0?. 1 serial clock output value is ?1?. so mn serial data output of channel n 0 serial data output value is ?0?. 1 serial data output value is ?1?. caution be sure to set bits 11 and 3 of so0, and bits 11 to 9, 3, and 1 of so1 to ?1?. and be sure to clear bits 15 to 12 and 7 to 4 of som to ?0?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), mn = 00 to 02, 10, 12 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 463 jun 20, 2011 (13) serial output level register m (solm) solm is a register that is used to set inve rsion of the data output level of each channel. this register can be set only in the uart mode. be sure to set 0000h in the csi mode and simplifies i 2 c mode. inverting channel n by using this register is reflect ed on pin output only when serial output is enabled (soemn = 1). when serial output is disabled (soemn = 0) , the value of the somn bit is output as is. rewriting solm is prohibited when the regi ster is in operation (when semn = 1). solm can be set by a 16-bit memory manipulation instruction. the lower 8 bits of solm can be set with an 8-bi t memory manipulation instruction with solml. reset signal generation clears this register to 0000h. figure 14-16. format of serial output level register m (solm) address: f0134h, f0135h (sol0), f0174h, f0175h (sol1) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 solm 0 0 0 0 0 0 0 0 0 0 0 0 0 sol m2 0 sol m0 sol mn selects inversion of the level of the transmit data of channel n in uart mode 0 communication data is output as is. 1 communication data is inverted and output. caution be sure to clear bits 15 to 3, 1 to ?0?. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 464 jun 20, 2011 (14) input switch control register (isc) isc is used to realize a lin-bus communication operation by uart3 in coordination with an external interrupt and the timer array unit. when bit 0 is set to 1, the input signal of the serial data input (r x d3) pin is selected as an external interrupt (intp0) that can be used to detect a wakeup signal. when bit 1 is set to 1, the input signal of the serial data input (r x d3) pin is selected as a timer input, so that the pulse widths of a sync break field and a sync field can be measured by the timer. isc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 14-17. format of input switch control register (isc) address: fff3ch after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 isc 0 0 0 isc4 isc3 isc2 isc1 isc0 isc1 switching channel 7 input of timer array unit 0 uses the input signal of the ti07 pin as a timer input (normal operation). 1 input signal of r x d3 pin is used as timer input (wakeup signal detection). isc0 switching external interrupt (intp0) input 0 uses the input signal of the intp0 pin as an external interrupt (normal operation). 1 uses the input signal of the r x d3 pin as an external interrupt (to measure the pulse widths of t he sync break field and sync field). caution be sure to clear bits 7 to 5 to ?0?. remark bits 2 to 4 of isc are not used with sau1. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 465 jun 20, 2011 (15) noise filter enable register 0 (nfen0) nfen0 is used to set whether the noise filter can be used for the input signal from the serial data input pin to each channel. disable the noise filter of the pin used for csi or simplified i 2 c communication, by clearing the corresponding bit of this register to 0. enable the noise filter of the pin used for uart communication, by setting the corresponding bit of this register to 1. when the noise filter is enabled, cpu/peripheral operating clock (f clk ) is synchronized with 2-clock match detection. nfen0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 14-18. format of noise filter enable register 0 (nfen0) address: f0060h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 nfen0 0 snfen30 0 snfen20 0 snfen10 0 snfen00 snfen30 use of noise filter of r x d3/p50/segx (78k0r/lf3: x = 30, 78k0r/lg3: x = 39, 78k0r/lh3: x = 53) pin 0 noise filter off 1 noise filter on set snfen30 to 1 to use the r x d3 pin. clear snfen30 to 0 to use the p50 or segx pins. snfen20 use of noise filter of r x d2/p11/si20/sda20/intp6 pin 0 noise filter off 1 noise filter on set snfen20 to 1 to use the r x d2 pin. clear snfen20 to 0 to use the p11, si20, sda20 or intp6 pins. snfen10 use of noise filter of r x d1/p14/si10/sda10/intp4 pin 0 noise filter off 1 noise filter on set snfen10 to 1 to use the r x d1 pin. clear snfen10 to 0 to use the p14, si10, sda10 or intp4 pins. snfen00 use of noise filter of r x d0/p80/si00/intp9 pin 0 noise filter off 1 noise filter on set snfen00 to 1 to use the r x d0 pin. clear snfen00 to 0 to use the p80, si00 or intp9. caution be sure to clear bits 7, 5, 3, and 1 to ?0?. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 466 jun 20, 2011 (16) port input mode registers 1, 7 (pim1, pim7) these registers set the input buffer of p10, p 11, p14, p15, p75, and p76 in 1-bit units. pim1 and pim7 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 14-19. format of port input m ode registers 1, and 7 (pim1, pim7) ? 78k0r/lf3, 78k0r/lg3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pim1 0 0 pim15 pim14 0 0 pim11 pim10 f0041h 00h r/w ? 78k0r/lh3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pim1 0 0 pim15 pim14 0 0 pim11 pim10 f0041h 00h r/w pim7 0 pim76 pim75 0 0 0 0 0 f0047h 00h r/w pimmn pmn pin input buffer selection (m = 1 and 7; n = 0, 1, 4 to 6) 0 normal input buffer 1 ttl input buffer 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 467 jun 20, 2011 (17) port output mode registers 1, 7, 8 (pom1, pom7, pom8) these registers set the output mode of p10 to p 15, p75, p77, p80 and 82 in 1-bit units. pom1, pom7, and pom8 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 14-20. format of port output mode registers 1, 7, and 8 (pom1, pom7, pom8) ? 78k0r/lf3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pom1 0 0 pom15 pom14 pom13 po m12 pom11 pom10 f0051h 00h r/w ? 78k0r/lg3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pom1 0 0 pom15 pom14 pom13 po m12 pom11 pom10 f0051h 00h r/w pom8 0 0 0 0 0 pom82 0 pom80 f0058h 00h r/w ? 78k0r/lh3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pom1 0 0 pom15 pom14 pom13 po m12 pom11 pom10 f0051h 00h r/w pom7 pom77 0 pom75 0 0 0 0 0 f0057h 00h r/w pom8 0 0 0 0 0 pom82 0 pom80 f0058h 00h r/w pommn pmn pin output mode selection (m = 1, 7, and 8; n = 0 to 5 and 7) 0 normal output mode 1 n-ch open-drain output (v dd tolerance) mode 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 468 jun 20, 2011 (18) port mode registers 1, 5, 7, 8 (pm1, pm5, pm7, pm8) these registers set input/output of ports 1, 5, 7 and 8 in 1-bit units. when using the p10/sck20/scl20, p11/si20/sda20/rxd2/intp6, p12/so20/txd2/to02, p13/so10/txd1/to04, p14/si10/sda10/rxd1/intp4, p15/sck10/scl10/intp7, p51/txd3/segx (78k0r/lf3: x = 29, 78k0r/lg3: x = 38, 78k0r/lh3: x = 52), p75/sck01/kr5, p77/so01/kr7, p80/sck00/intp11, and p82/so00/txd0 pins for serial data output or serial clock output, clear the pm10, pm11, pm12, pm13, pm14, pm15, pm 51, pm75, pm77, pm80, and pm82 bits to 0, and set the output latches of p10, p11, p12, p13, p14, p15, p51, p75, p77, p80, and p82 to 1. when using the p10/sck20/scl20, p11/si20/sda20/rxd2/intp6, p14/si10/sda10/rxd1/intp4, p15/sck10/scl10/intp7, p50/rxd3/segx (78k0r/lf3: x = 30, 78k0r/lg3: x = 39, 78k0r/lh3: x = 53), p75/sck01/kr5, p76/si01/kr6, p80/sck00/intp11, and p81/ si00/rxd0/intp9 pins for serial data input or serial clock input, set the pm10, pm11, pm14, pm15, pm50, pm75, pm76, pm80, and pm81 bits to 1. at this time, the output latches of p10, p11, p14, p15, p 50, p75, p76, p80, and p81 may be 0 or 1. pm1, pm5, pm7, and pm8 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation se ts these registers to ffh. figure 14-21. format of port mode registers 1, 5, 7, and 8 (pm1, pm5, pm7, pm8) ? 78k0r/lf3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pm1 1 1 pm15 pm14 pm13 pm12 pm11 pm10 fff21h ffh r/w pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 fff25h ffh r/w ? 78k0r/lg3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pm1 1 pm16 pm15 pm14 pm13 pm12 pm11 pm10 fff21h ffh r/w pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 fff25h ffh r/w pm8 1 1 1 1 1 pm82 pm81 pm80 fff28h ffh r/w ? 78k0r/lh3 symbol 7 6 5 4 3 2 1 0 address after reset r/w pm1 pm17 pm16 pm15 pm14 pm13 pm12 pm11 pm10 fff21h ffh r/w pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 fff25h ffh r/w pm7 pm77 pm76 pm75 pm74 pm73 pm72 pm71 pm70 fff27h ffh r/w pm8 pm87 pm86 pm85 pm84 pm83 pm82 pm81 pm80 fff28h ffh r/w pmmn pmn pin i/o mode selection (m = 1, 5, 7, 8; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 469 jun 20, 2011 14.4 operation stop mode each serial interface of serial array unit has the operation stop mode. in this mode, serial communication cannot be exec uted, thus reducing the power consumption. in addition, the p10/sck20/scl20, p11/si20/sda20/rxd2/intp6, p12/so20/txd2/to02, p13/so10/txd1/to04, p14/si10/sda10/rxd1/intp4, p15/sck10/ scl10/intp7, p50/rxd3/segx (78k0r/lf3: x = 30, 78k0r/lg3: x = 39, 78k0r/lh3: x = 53), p51/txd3/segx (78k0r/lf3: x = 29, 78k0r/lg3: x = 38, 78k0r/lh3: x = 52), p75/sck01/kr5, p76/si01/kr6, p77/so01/kr7, p80/sck00/intp11, p81/si00/rxd0/intp9, and p82/so00/txd0 pins can be used as ordinary port pins in this mode. 14.4.1 stopping the operation by units the stopping of the operation by units is set by using peripheral enable register 0 (per0). per0 is used to enable or disable use of each peripheral har dware macro. clock supply to a hardware macro that is not used is stopped in order to reduc e the power consumption and noise. to stop the operation of serial array unit 0, set bit 2 (sau0en) to 0. to stop the operation of serial array unit 1, set bit 3 (sau1en) to 0. figure 14-22. peripheral enable register 0 (per 0) setting when stopping the operation by units caution if saumen = 0, writing to a control register of serial array unit m is ignored, and, even if the register is read, only the default value is read (e xcept for input switch contro l register (isc), noise filter enable register (nfen0), port input mode re gisters (pim1, pim7), port output mode registers (pom1, pom7, pom8), port mode registers (pm1, pm5, pm7, pm8), and port registers (p1, p5, p7, p8)). remark m: unit number (m = 0, 1) : bits not used with serial array units (dependi ng on the settings of other peripheral functions) 0/1: set to 0 or 1 depending on the usage of the user (a) peripheral enable register 0 (per0) ? set only the bit of saum to be stopped to 0. 7 6 5 4 3 2 1 0 per0 rtcen dacen adcen iic0en sau1en 0/1 sau0en 0/1 tau 1 e n tau 0 e n control of saum input clock 0: stops supply of input clock 1: su pp lies in p ut cloc k 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 470 jun 20, 2011 14.4.2 stopping the operation by channels the stopping of the operation by channels is se t using each of the following registers. figure 14-23. each register setting when stopping the operation by channels (1/2) ? serial channel enable status register m ( sem) ? this register indicates whether data transmission/reception operation of eac h channel is enabled or stopped. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sem 0 0 0 0 0 0 0 0 0 0 0 0 sem3 0/1 sem2 0/1 sem1 0/1 sem0 0/1 0: operation stops ? the sem register is a read-only stat us register, whose operation is stopped by using the stm register. with a channel whose operation is stopped, the value of ckomn of the som register can be set by software. ? serial channel stop register m (stm) ? this register is a trigger register that is used to enable stopping communication/count by each channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 stm 0 0 0 0 0 0 0 0 0 0 0 0 stm3 0/1 stm2 0/1 stm1 0/1 stm0 0/1 1: clears semn to 0 and stops the communication operation * because stmn is a trigger bit, it is cleared immediately when semn = 0. (c) serial output enable register m (soem) ? this regist er is a register that is used to enable or stop output of the serial communication operation of each channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soe0 0 0 0 0 0 0 0 0 0 0 0 0 0 soe02 0/1 soe01 0/1 soe00 0/1 0: stops output by serial communication operation * for channel n, whose serial output is stopped, the so0n value of the so0 register can be set by software. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soe1 0 0 0 0 0 0 0 0 0 0 0 0 0 soe12 0/1 0 soe10 0/1 0: stops output by serial communication operation * for channel n, whose serial output is stopped, the so1n value of the so1 register can be set by software. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) : setting disabled (fixed by hardware), 0/1: set to 0 or 1 depending on the usage of the user 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 471 jun 20, 2011 figure 14-23. each register setting when stopping the operation by channels (2/2) (d) serial output register m (som) ?thi s register is a buffer register for serial output of each channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 so0 0 0 0 0 1 cko02 0/1 cko01 0/1 cko00 0/1 0 0 0 0 1 so02 0/1 so01 0/1 so00 0/1 1: serial clock output value is ?1? 1: serial data output value is ?1? * when using pins corresponding to each c hannel as port function pins, set the corresponding cko0n and so0n bits to ?1?. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 so1 0 0 0 0 1 1 1 cko10 0/1 0 0 0 0 1 so12 0/1 1 so10 0/1 1: serial clock output value is ?1? 1: serial data output value is ?1? * when using pins corresponding to each channel as port function pins, set the corresponding cko10 and so1n bits to ?1?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) : setting disabled (fixed by hardware), 0/1: set to 0 or 1 depending on the usage of the user 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 472 jun 20, 2011 14.5 operation of 3-wire serial i/o (c si00, csi01, csi10, csi20) communication this is a clocked communication function that uses thr ee lines: serial clock (sck) and serial data (si and so) lines. [data transmission/reception] ? data length of 7 or 8 bits ? phase control of transmit/receive data ? msb/lsb first selectable ? level setting of transmit/receive data [clock control] ? master/slave selection ? phase control of i/o clock ? setting of transfer period by prescaler and internal counter of each channel [interrupt function] ? transfer end interrupt/buffer empty interrupt [error detection flag] ? overrun error the channels supporting 3-wire serial i/o (csi00, csi01, csi10, csi 20) are channels 0 to 2 of sau0 and channel 0 of sau1. unit channel used as csi used as uart used as simplified i 2 c 0 csi00 uart0 ? 1 csi01 ? 2 csi10 uart1 iic10 0 3 ? ? 0 csi20 uart2 iic20 1 ? ? 2 ? uart3 (supporting lin-bus) ? 1 3 ? ? remarks 1. for 78k0r/lf3, csi00 and csi01 are not mounted. 2. for 78k0r/lg3, csi01 is not mounted. 3-wire serial i/o (csi00, csi01, cis 10, csi20) performs the following six types of communic ation operations. ? master transmission (see 14.5.1 .) ? master reception (see 14.5.2 .) ? master transmission/reception (see 14.5.3 .) ? slave transmission (see 14.5.4 .) ? slave reception (see 14.5.5 .) ? slave transmission/reception (see 14.5.6 .) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 473 jun 20, 2011 14.5.1 master transmission master transmission is that the 78k0r/lx3 microcontrollers out put a transfer clock and transmit data to another device. 3-wire serial i/o csi00 csi01 csi10 csi20 target channel channel 0 of sau0 channel 1 of sau0 channel 2 of sau0 channel 0 of sau1 pins used sck00, so00 sck01, so01 sck10, so10 sck20, so20 intcsi00 intcsi01 intcsi10 intcsi20 interrupt transfer end interrupt (in single-transfer mode) or buff er empty interrupt (in continuous transfer mode) can be selected. error detection flag none transfer data length 7 or 8 bits transfer rate max. f clk /4 [mhz], min. f clk /(2 2 11 128) [mhz] note f clk : system clock frequency data phase selectable by dapmn bit ? dapmn = 0: data output starts from the start of the operation of the serial clock. ? dapmn = 1: data output starts half a clock before the start of the serial clock operation. clock phase selectable by ckpmn bit ? ckpmn = 0: forward ? ckpmn = 1: reverse data direction msb or lsb first note use this operation within a range that satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. for 78k0r/lf3, csi00 and csi01 are not mounted. 2. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 474 jun 20, 2011 (1) register setting figure 14-24. example of contents of registers for master transmission of 3-wire serial i/o (csi00, csi01, csi10, csi20) (a) serial output register m (som) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 0/1 ckom1 0/1 ckom0 0/1 0 0 0 0 1 som2 0/1 som1 0/1 som0 0/1 communication starts when these bits are 1 if the data phase is forward (ckpmn = 0). if the phase is reversed (ckpmn = 1), communication starts when these bits are 0. (b) serial output enable register m (soem) ? se ts only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 0/1 soem0 0/1 (c) serial channel start register m (ssm) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 0/1 ssm0 0/1 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 0 0 sism0 0 1 0 0 mdmn2 0 mdmn1 0 mdmn0 0/1 operation mode of channel n 0: transfer end interrupt 1: buffer empty interrupt (e) serial communication operati on setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 1 rxemn 0 dapmn 0/1 ckpmn 0/1 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0/1 0 slcmn1 0 slcmn0 0 0 dlsmn2 1 dlsmn1 1 dlsmn0 0/1 (f) serial data register mn (sdrmn) (lower 8 bits: siop) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 transmit data setting remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) : setting is fixed in the csi ma ster transmission mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user siop 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 475 jun 20, 2011 (2) operation procedure figure 14-25. initial setting pr ocedure for master transmission caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting initial setting setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting som register changing setting of soem register setting port writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set a transfer baud rate. manipulate the somn and ckomn bits and set an initial output level. set the soemn bit to 1 and enable data output of the target channel. enable data output and clock output of the target channel by setting a port register and a port mode register. set transmit data to the siop register (bits 7 to 0 of the sdrmn register) and start communication. set the ssmn bit of the target channel to 1 to set semn = 1. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 476 jun 20, 2011 figure 14-26. procedure for stopping master transmission remarks 1. even after communication is stopped, the pin level is retained. to resume the operation, re-set the som register (see figure 14-27 procedure for r esuming master transmission ). 2. p: csi number (p = 00, 01, 10, 20) starting setting to stop setting stm register stopping communication write 1 to the stmn bit of the target channel. stop communication in midway. set the soem register and stop the output of the target channel changing setting of soem register 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 477 jun 20, 2011 figure 14-27. procedure for resuming master transmission starting setting for resumption port manipulation changing setting of spsm register changing setting of sdrmn register changing setting of smrmn register changing setting of som register port manipulation writing to ssm register starting communication disable data output and clock output of the target channel by setting a port register and a port mode register. change the setting if an incorrect division ratio of the operation clock is set. change the setting if an incorrect transfer baud rate is set. change the setting if the setting of the smrmn register is incorrect. manipulate the somn and ckomn bits and set an initial output level. enable data output and clock output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. sets transmit data to the siop register (bits 7 to 0 of the sdrmn register) and start communication. (essential) (selective) (selective) (selective) (selective) ( essential ) (essential) (essential) change the setting if the setting of the scrmn register is incorrect. (selective) changing setting of scrmn register cleared by using sirmn registe r if fef, pef, or ovf flag remains set. (selective) clearing error flag set the soem register and enable data output of the target channel. (selective) changing setting of soem register set the soem register and stop the output of the target channel. (selective) changing setting of soem register 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 478 jun 20, 2011 (3) processing flow (in si ngle-transmission mode) figure 14-28. timing chart of master transmission (in single-transmission mode) ssmn stmn semn sdrmn sckp pin sop pin shift register mn intcsip tsfmn data transmission (8-bit length) data transmission (8-bit length) data transmission (8-bit length) transmit data 3 transmit data 2 transmit data 1 transmit data 1 transmit data 2 transmit data 3 shift operation shift operation shift operation remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 479 jun 20, 2011 figure 14-29. flowchart of master tr ansmission (in single-transmission mode) caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting csi communication writing 1 to ssmn bit writing transmit data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. smrmn, scrmn: sett ing communication sdrmn[15:9]: setting transfer rate som, soem: setting output transfer end interrupt g enerated? transmission completed? no no yes yes setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation clearing sau1en and sau0en bits of per0 register to 0 end of communication 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 480 jun 20, 2011 (4) processing flow (in continuous transmission mode) figure 14-30. timing chart of master tran smission (in continuous transmission mode) ssmn semn sdrmn sckp pin sop pin shift register mn intcsip tsfmn data transmission (8-bit length) data transmission (8-bit length) transmit data 2 transmit data 1 transmit data 3 bffmn mdmn0 transmit data 2 <1> <2> <2> <2> <3> <3> <3> <5> <6> <4> ( note ) shift operation shift operation shift operation transmit data 3 data transmission (8-bit length) stmn transmit data 1 note when transmit data is written to the sdrmn register while bffmn = 1, the transmit data is overwritten. caution the mdmn0 bit can be rewr itten even during operation. however, rewrite it before transfer of the last bit is started, so that it will be rewritten before the transfer end interrupt of the last transmit data. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 481 jun 20, 2011 figure 14-31. flowchart of master transm ission (in continuous transmission mode) starting csi communication writing 1 to ssmn bit writing transmit data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. <1> select the buffer empty interrupt. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem; setting output n o n o n o y es setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation end of communication clearing 0 to mdmn0 bit y es n o y es n o communication continued? y es y es clearing sau1en and sau0en bits of per0 register to 0 <2> <3> <4> <5> transmitting next data? buffer empty interrupt generated? transfer end interrupt generated? tsfmn = 1? writing 1 to mdmn0 bit <6> caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. remark <1> to <6> in the figure correspond to <1> to <6> in figure 14-30 timing chart of master transmission (in continuous transmission mode) . 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 482 jun 20, 2011 14.5.2 master reception master reception is that the 78k0r/lx 3 microcontrollers output a transfer clock and receive data from other device. 3-wire serial i/o csi00 csi01 csi10 csi20 target channel channel 0 of sau0 channel 1 of sau0 channel 2 of sau0 channel 0 of sau1 pins used sck00, si00 sck01, si01 sck10, si10 sck20, si20 intcsi00 intcsi01 intcsi10 intcsi20 interrupt transfer end interrupt only (setting the buffer empty interrupt is prohibited.) error detection flag overrun error detection flag (ovfmn) only transfer data length 7 or 8 bits transfer rate max. f clk /4 [mhz], min. f clk /(2 2 11 128) [mhz] note f clk : system clock frequency data phase selectable by dapmn bit ? dapmn = 0: data input starts from the start of the operation of the serial clock. ? dapmn = 1: data input starts half a clock bef ore the start of the serial clock operation. clock phase selectable by ckpmn bit ? ckpmn = 0: forward ? ckpmn = 1: reverse data direction msb or lsb first note use this operation within a range that satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. for 78k0r/lf3, csi00 and csi01 are not mounted. 2. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 483 jun 20, 2011 (1) register setting figure 14-32. example of contents of register s for master reception of 3-wire serial i/o (csi00, csi01, csi10, csi20) (a) serial output register m (som) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 0/1 ckom1 0/1 ckom0 0/1 0 0 0 0 1 som2 som1 som0 communication starts when these bits are 1 if the data phase is forward (ckpmn = 0). if the phase is reversed (ckpmn = 1), communication starts when these bits are 0. (b) serial output enable register m (soem) ? cl ears only the bits of the target channel to 0. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 0/1 soem0 0/1 (c) serial channel start register m (ssm) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 0/1 ssm0 0/1 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 0 mdmn1 0 mdmn0 0 operation mode of channel n 0: transfer end interrupt (e) serial communication operati on setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 0 rxemn 1 dapmn 0/1 ckpmn 0/1 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0/1 0 slcmn1 0 slcmn0 0 0 dlsmn2 1 dlsmn1 1 dlsmn0 0/1 (f) serial data register mn (sdrmn) (lower 8 bits: siop) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 receive data register (write ffh as dummy data.) remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) : setting is fixed in the csi master reception mode , : setting disabled (s et to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user siop 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 484 jun 20, 2011 (2) operation procedure figure 14-33. initial setting procedure for master reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 14-34. procedure for stopping master reception remark even after communication is stopped, the pin level is retained. to resume the operation, re-set the som register (see figure 14-35 procedure for resuming master reception ). starting initial setting setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting som register setting port writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set a transfer baud rate. manipulate the ckomn bit and set an initial output level. enable clock output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. set dummy data to the siop register (bits 7 to 0 of the sdrmn register) and start communication. starting setting to stop setting stm register stopping communication write 1 to the stmn bit of the target channel. stop communication in midway. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 485 jun 20, 2011 figure 14-35. procedure for resuming master reception starting setting for resumption port manipulation changing setting of spsm register changing setting of sdrmn register changing setting of smrmn register changing setting of som register port manipulation writing to ssm register starting communication disable clock output of the target channel by setting a port register and a port mode register. change the setting if an incorrect division ratio of the operation clock is set. change the setting if an incorrect transfer baud rate is set. change the setting if the setting of the smrmn register is incorrect. manipulate the ckomn bit and set a clock output level. enable clock output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. sets dummy data to the siop register (bits 7 to 0 of the sdrmn register) and start communication. (essential) (selective) (selective) ( selective ) (selective) ( essential ) (essential) (essential) change the setting if the setting of the scrmn register is incorrect. (selective) changing setting of scrmn register cleared by using sirmn register if fef, pef, or ovf flag remains set. (selective) clearing error flag clear the soem register to 0 and stop data output of the target channel. (essential) changing setting of soem register 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 486 jun 20, 2011 (3) processing flow (in single-reception mode) figure 14-36. timing chart of master reception (in si ngle-reception mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sip pin shift register mn intcsip tsfmn data reception (8-bit length) data reception (8-bit length) data reception (8-bit length) reception & shift operation reception & shift operation reception & shift operation stmn receive data 3 receive data 2 receive data 1 dummy data for reception dummy data dummy data receive data 1 receive data 2 receive data 3 write read write read read write remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 487 jun 20, 2011 figure 14-37. flowchart of master reception (in single-reception mode) starting csi communication writing 1 to ssmn bit writing dummy data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem: setting sckp output transfer end interrupt generated? reception completed? no no yes yes setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation clearing sau1en and sau0en bits of per0 register to 0 end of communication reading siop (= sdrmn[7:0]) register starting reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 488 jun 20, 2011 14.5.3 master transmission/reception master transmission/reception is that the 78k0r/lx3 microcontrollers output a transfer clock and transmit/receive data to/from other device. 3-wire serial i/o csi00 csi01 csi10 csi20 target channel channel 0 of sau0 channel 1 of sau0 channel 2 of sau0 channel 0 of sau1 pins used sck00, si00, so00 sck01, si01, so01 sck10, si10, so10 sck20, si20, so20 intcsi00 intcsi01 intcsi10 intcsi20 interrupt transfer end interrupt (in single-transfer mode) or buff er empty interrupt (in continuous transfer mode) can be selected. error detection flag overrun error detection flag (ovfmn) only transfer data length 7 or 8 bits transfer rate max. f clk /4 [mhz], min. f clk /(2 2 11 128) [mhz] note f clk : system clock frequency data phase selectable by dapmn bit ? dapmn = 0: data i/o starts at the start of the operation of the serial clock. ? dapmn = 1: data i/o starts half a clock befo re the start of the serial clock operation. clock phase selectable by ckpmn bit ? ckpmn = 0: forward ? ckpmn = 1: reverse data direction msb or lsb first note use this operation within a range that satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. for 78k0r/lf3, csi00 and csi01 are not mounted. 2. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 489 jun 20, 2011 (1) register setting figure 14-38. example of contents of registers for master transmission/reception of 3-wire serial i/o (csi00, csi01, csi10, csi20) (a) serial output register m (som) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 0/1 ckom1 0/1 ckom0 0/1 0 0 0 0 1 som2 0/1 som1 0/1 som0 0/1 communication starts when these bits are 1 if the data phase is forward (ckpmn = 0). if the phase is reversed (ckpmn = 1), communication starts when these bits are 0. (b) serial output enable register m (soem) ? se ts only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 0/1 soem0 0/1 (c) serial channel start register m (ssm) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 0/1 ssm0 0/1 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 0 mdmn1 0 mdmn0 0/1 operation mode of channel n 0: transfer end interrupt 1: buffer empty interrupt (e) serial communication operati on setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 1 rxemn 1 dapmn 0/1 ckpmn 0/1 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0/1 0 slcmn1 0 slcmn0 0 0 dlsmn2 1 dlsmn1 1 dlsmn0 0/1 (f) serial data register mn (sdrmn) (lower 8 bits: siop) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 transmit data setting/receive data register remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) : setting is fixed in the csi mast er transmission/reception mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user siop 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 490 jun 20, 2011 (2) operation procedure figure 14-39. initial setting procedur e for master transmission/reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 14-40. procedure for stoppi ng master transmission/reception remark even after communication is stopped, the pin level is retained. to resume the operation, re-set the som register (see figure 14-41 procedure for resumi ng master transmission/reception ). starting setting to stop setting stm register write 1 to the stmn bit of the target channel. changing setting of soem register stopping communication set the soem register and stop the output of the target channel. stop communication in midway. starting initial setting setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting som register changing setting of soem register setting port writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set a transfer baud rate. manipulate the somn and ckomn bits and set an initial output level. set the soemn bit to 1 and enable data output of the target channel. enable data output and clock output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. set transmit data to the siop register (bits 7 to 0 of the sdrmn register) and start communication. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 491 jun 20, 2011 figure 14-41. procedure for resumi ng master transmission/reception starting setting for resumption port manipulation changing setting of spsm register changing setting of sdrmn register changing setting of smrmn register changing setting of som register disable data output and clock output of the target channel by setting a port register and a port mode register. change the setting if an incorrect division ratio of the operation clock is set. change the setting if an incorrect transfer baud rate is set. change the setting if the setting of the smrmn register is incorrect. manipulate the somn and ckomn bits and set an initial output level. (essential) (selective) (selective) (selective) (selective) change the setting if the setting of the scrmn register is incorrect. (selective) changing setting of scrmn register cleared by using sirmn registe r if fef, pef, or ovf flag remains set. (selective) clearing error flag set the soem register and stop the output of the target channel. (selective) changing setting of soem register changing setting of soem register port manipulation writing to ssm register starting communication set the soem register and enable the output of the target channel. enable data output and clock output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 and set semn to 1. set transmit data to the siop register (bits 7 to 0 of the sdrmn register) and start communication. (selective) ( essential ) (essential) (essential) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 492 jun 20, 2011 (3) processing flow (in single -transmission/reception mode) figure 14-42. timing chart of master transmission/ reception (in single-trans mission/reception mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sip pin shift register mn intcsip tsfmn data transmission/reception (8-bit length) data transmission/reception (8-bit length) data transmission/reception (8-bit length) sop pin reception & shift operation reception & shift operation reception & shift operation stmn receive data 3 receive data 2 receive data 1 transmit data 1 transmit data 2 receive data 1 receive data 2 receive data 3 write read write read read write transmit data 3 transmit data 2 transmit data 1 transmit data 2 remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 493 jun 20, 2011 figure 14-43. flowchart of master transmission/ reception (in single- tr ansmission/reception mode) starting csi communication writing 1 to ssmn bit writing transmit data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem: setting output and sckp output transfer end interrupt generated? transmission/reception completed? no no yes yes setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation clearing sau1en and sau0en bits of per0 register to 0 end of communication reading siop (=sdrmn[7:0]) register starting transmission/reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 494 jun 20, 2011 (4) processing flow (in continu ous transmission/reception mode) figure 14-44. timing chart of master transmission/ reception (in continuous tr ansmission/reception mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sip pin shift register mn intcsip tsfmn sop pin reception & shift operation reception & shift operation bffmn reception & shift operation mdmn0 data transmission/reception (8-bit length) data transmission/reception (8-bit length) data transmission/reception (8-bit length) stmn <4> <5> transmit data 1 transmit data 3 receive data 3 write read read read write <1> <2> <3> <2> <3> <4> <2> <7> <8> ( note 1 ) transmit data 2 write <6> <3> ( note 2 ) ( note 2 ) receive data 2 receive data 1 receive data 1 receive data 2 receive data 3 transmit data 3 transmit data 2 transmit data 1 notes 1. when transmit data is written to the sdrmn register while bffmn = 1, the transmit data is overwritten. 2. the transmit data can be read by r eading the sdrmn register during this period. at this time, the transfer operation is not affected. caution the mdmn0 bit can be rewr itten even during operation. however, rewrite it before transfer of the last bit is started, so that it has been rewritten before the transfer end interrupt of the last transmit data. remarks 1. <1> to <8> in the figure correspond to <1> to <8> in figure 14-45 flowchart of master transmission/reception (in contin uous transmission/reception mode ). 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 495 jun 20, 2011 figure 14-45. flowchart of master transmission/r eception (in continuous tr ansmission/reception mode) starting csi communication writing 1 to ssmn bit reading receive data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. <1> select the buffer empty interrupt. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem: setting output and sckp output y es y es n o n o setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation end of communication clearing 0 to mdmn0 bit n o transfer end interrupt generated? y es n o communication continued? y es y es clearing sau1en and sau0en bits of per0 register to 0 communication data exists? writing transmit data to siop (=sdrmn[7:0]) tsfmn = 1? reading receive data to siop (=sdrmn[7:0]) writing 1 to mdmn0 bit buffer empty interrupt generated? <2> <3> <5> <6> <7> <4> <8> n o caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. remark <1> to <8> in the figure correspond to <1> to <8> in figure 14-44 timing chart of master transmission/reception (in continuo us transmission/reception mode) . 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 496 jun 20, 2011 14.5.4 slave transmission slave transmission is that the 78k0r/lx3 microcontrollers trans mit data to another device in the state of a transfer clock being input from another device. 3-wire serial i/o csi00 csi01 csi10 csi20 target channel channel 0 of sau0 channel 1 of sau0 channel 2 of sau0 channel 0 of sau1 pins used sck00, so00 sck01, so01 sck10, so10 sck20, so20 intcsi00 intcsi01 intcsi10 intcsi20 interrupt transfer end interrupt (in single-transfer mode) or buff er empty interrupt (in continuous transfer mode) can be selected. error detection flag overrun error detection flag (ovfmn) only transfer data length 7 or 8 bits transfer rate max. f mck /6 [mhz] notes 1, 2 data phase selectable by dapmn bit ? dapmn = 0: data output starts from the start of the operation of the serial clock. ? dapmn = 1: data output starts half a clock before the start of the serial clock operation. clock phase selectable by ckpmn bit ? ckpmn = 0: forward ? ckpmn = 1: reverse data direction msb or lsb first notes 1. because the external serial clock input to pins sck 00, sck01, sck10, and sck20 is sampled internally and used, the fastest transfer rate is f mck /6 [mhz]. 2. use this operation within a range t hat satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. f mck : operation clock (mck) frequency of target channel 2. for 78k0r/lf3, csi00 and csi01 are not mounted. 3. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 497 jun 20, 2011 (1) register setting figure 14-46. example of contents of register s for slave transmission of 3-wire serial i/o (csi00, csi01, csi10, csi20) (a) serial output register m (som) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 ckom1 ckom0 0 0 0 0 1 som2 0/1 som1 0/1 som0 0/1 (b) serial output enable register m (soem) ? se ts only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 0/1 soem0 0/1 (c) serial channel start register m (ssm) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 0/1 ssm0 0/1 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 1 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 0 mdmn1 0 mdmn0 0/1 operation mode of channel n 0: transfer end interrupt 1: buffer empty interrupt (e) serial communication operati on setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 1 rxemn 0 dapmn 0/1 ckpmn 0/1 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0/1 0 slcmn1 0 slcmn0 0 0 dlsmn2 1 dlsmn1 1 dlsmn0 0/1 (f) serial data register mn (sdrmn) (lower 8 bits: siop) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 transmit data setting remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) : setting is fixed in the csi slave transmission mode , : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user siop 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 498 jun 20, 2011 (2) operation procedure figure 14-47. initial setting pr ocedure for slave transmission caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting initial setting setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting som register changing setting of soem register setting port writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set bits 15 to 9 to 0000000b for baud rate setting. manipulate the somn bit and set an initial output level. set the soemn bit to 1 and enable data output of the target channel. enable data output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. set transmit data to the siop register (bits 7 to 0 of the sdrmn register) and wait for a clock from the master. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 499 jun 20, 2011 figure 14-48. procedure for stopping slave transmission remark even after communication is stopped, the pin level is retained. to resume the operation, re-set the som register (see figure 14-49 procedure for resuming slave transmission ). starting setting to stop setting stm register write 1 to the stmn bit of the target channel. changing setting of soem register stopping communication set the soem register and stop the output of the target channel. stop communication in midway. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 500 jun 20, 2011 figure 14-49. procedure for resuming slave transmission starting setting for resumption port manipulation changing setting of spsm register changing setting of smrmn register disable data output of the target channel by setting a port register and a port mode register. change the setting if an incorrect division ratio of the operation clock is set. change the setting if the setting of the smrmn register is incorrect. (selective) (selective) ( selective ) change the setting if the setting of the scrmn register is incorrect. (selective) changing setting of scrmn register cleared by using sirmn registe r if fef, pef, or ovf flag remains set. (selective) clearing error flag stop the target fo r communication or wait until the target completes its operation. (essential) manipulating target for communication changing setting of som register port manipulation writing to ssm register manipulate the somn and ckomn bits and set an initial output level. enable data output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. set transmit data to the siop register (bits 7 to 0 of the sdrmn register) and wait for a clock from the master. (selective) ( essential ) (essential) (essential) set the soem register and stop the output of the target channel. (selective) changing setting of soem register set the soem register and enable the output of the target channel. (selective) changing setting of soem register starting target for communication start the target for communication. (essential) starting communication 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 501 jun 20, 2011 (3) processing flow (in si ngle-transmission mode) figure 14-50. timing chart of slave tr ansmission (in single-transmission mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sop pin shift register mn intcsip tsfmn stmn data transmission (8-bit length) data transmission (8-bit length) data transmission (8-bit length) transmit data 3 transmit data 2 transmit data 1 transmit data 1 transmit data 2 transmit data 3 shift operation shift operation shift operation remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 502 jun 20, 2011 figure 14-51. flowchart of slave tran smission (in single-transmission mode) caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting csi communication writing 1 to ssmn bit writing transmit data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem: setting output transfer end interrupt generated? transmission completed? no no yes yes setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation clearing sau1en and sau0en bits of per0 register to 0 end of communication 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 503 jun 20, 2011 (4) processing flow (in continuous transmission mode) figure 14-52. timing chart of slave transm ission (in continuous transmission mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sop pin shift register mn intcsip tsfmn bffmn mdmn0 stmn data transmission (8-bit length) data transmission (8-bit length) transmit data 2 transmit data 1 transmit data 3 transmit data 2 <1> <2> <2> <2> <3> <3> <3> <5> <4> ( note ) shift operation shift operation shift operation transmit data 3 data transmission (8-bit length) transmit data 1 <6> note when transmit data is written to the sdrmn register while bffmn = 1, the transmit data is overwritten. caution the mdmn0 bit can be rewritten even during opera tion. however, rewrite it before transfer of the last bit is started. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 504 jun 20, 2011 figure 14-53. flowchart of slave transmission (in continuous transmission mode) starting csi communication writing 1 to ssmn bit writing transmit data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. <1> select the buffer empty interrupt. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem: setting output n o n o n o y es setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation end of communication clearing 0 to mdmn0 bit y es n o y es n o communication continued? y es y es clearing sau1en and sau0en bits of per0 register to 0 <2> <3> <4> <5> transmitting next data? buffer empty interrupt generated? transfer end interrupt generated? tsfmn = 1? writing 1 to mdmn0 bit <6> caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. remark <1> to <6> in the figure correspond to <1> to <6> in figure 14-52 timing chart of slave transmission (in continuous transmission mode) . 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 505 jun 20, 2011 14.5.5 slave reception slave reception is that the 78k0r/lx3 microcontrollers receiv e data from another device in the state of a transfer clock being input from another device. 3-wire serial i/o csi00 csi01 csi10 csi20 target channel channel 0 of sau0 channel 1 of sau0 channel 2 of sau0 channel 0 of sau1 pins used sck00, si00 sck01, si01 sck10, si10 sck20, si20 intcsi00 intcsi01 intcsi10 intcsi20 interrupt transfer end interrupt only (setting the buffer empty interrupt is prohibited.) error detection flag overrun error detection flag (ovfmn) only transfer data length 7 or 8 bits transfer rate max. f mck /6 [mhz] notes 1, 2 data phase selectable by dapmn bit ? dapmn = 0: data input starts from the start of the operation of the serial clock. ? dapmn = 1: data input starts half a clock bef ore the start of the serial clock operation. clock phase selectable by ckpmn bit ? ckpmn = 0: forward ? ckpmn = 1: reverse data direction msb or lsb first notes 1. because the external serial clock input to pins sck 00, sck01, sck10, and sck20 is sampled internally and used, the fastest transfer rate is f mck /6 [mhz]. 2. use this operation within a range that satisfies t he conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. f mck : operation clock (mck) frequency of target channel 2. for 78k0r/lf3, csi00 and csi01 are not mounted. 3. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 506 jun 20, 2011 (1) register setting figure 14-54. example of contents of regist ers for slave reception of 3-wire serial i/o (csi00, csi01, csi10, csi20) (a) serial output register m (som) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 ckom1 ckom0 0 0 0 0 1 som2 som1 som0 (b) serial output enable register m (soem) ? cl ears only the bits of the target channel to 0. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 0/1 soem0 0/1 (c) serial channel start register m (ssm) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 0/1 ssm0 0/1 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 1 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 0 mdmn1 0 mdmn0 0 operation mode of channel n 0: transfer end interrupt (e) serial communication operati on setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 0 rxemn 1 dapmn 0/1 ckpmn 0/1 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0/1 0 slcmn1 0 slcmn0 0 0 dlsmn2 1 dlsmn1 1 dlsmn0 0/1 (f) serial data register mn (sdrmn) (lower 8 bits: siop) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn 0000000 (baud rate setting) 0 receive data register remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) : setting is fixed in the csi slave reception mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user siop 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 507 jun 20, 2011 (2) operation procedure figure 14-55. initial setting procedure for slave reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 14-56. procedure for stopping slave reception starting initial settings setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting port writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set bits 15 to 9 to 0000000b for baud rate setting. enable data input and clock input of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. wait for a clock from the master. starting setting to stop setting stm register stopping communication write 1 to the stmn bit of the target channel. stop communication in midway. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 508 jun 20, 2011 figure 14-57. procedure for resuming slave reception starting setting for resumption port manipulation changing setting of spsm register changing setting of smrmn register changing setting of som register port manipulation writing to ssm register starting communication disable clock output of the target channel by setting a port register and a port mode register. change the setting if an incorrect division ratio of the operation clock is set. change the setting if the setting of the smrmn register is incorrect. manipulate the ckomn bit and enable reception. enable clock output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. wait for a clock from the master. (essential) (selective) (selective) (selective) (essential) (essential) (essential) change the setting if the setting of the scrmn register is incorrect. (selective) changing setting of scrmn register cleared by using sirmn register if fef, pef, or ovf flag remains set. (selective) clearing error flag clear the soem register to 0 and stop data output of the target channel. (essential) changing setting of soem register manipulating target for communication stop the target for communication or wait until the target completes its operation. change the setting if the setting of the sdrmn register is incorrect. (selective) changing setting of sdrmn register (essential) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 509 jun 20, 2011 (3) processing flow (in single-reception mode) figure 14-58. timing chart of slave reception (in single-rec eption mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sip pin shift register mn intcsip tsfmn stmn data reception (8-bit length) data reception (8-bit length) data reception (8-bit length) receive data 3 receive data 2 receive data 1 receive data 1 receive data 2 receive data 3 read read read reception & shift operation reception & shift operation reception & shift operation remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 510 jun 20, 2011 figure 14-59. flowchart of slave reception (in singl e-reception mode) starting csi communication writing 1 to ssmn bit writing 1 to stmn bit perform initial setting when semn = 0. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem: setting sckp output transfer end interrupt generated? reception completed? no no yes yes setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation clearing sau1en and sau0en bits of per0 register to 0 end of communication reading siop (=sdrmn[7:0]) register starting reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 511 jun 20, 2011 14.5.6 slave transmission/reception slave transmission/reception is that t he 78k0r/lx3 microcontrollers transmit/receive data to/from another device in the state of a transfer clock being input from another device. 3-wire serial i/o csi00 csi01 csi10 csi20 target channel channel 0 of sau0 channel 1 of sau0 channel 2 of sau0 channel 0 of sau1 pins used sck00, si00, so00 sck01, si01, so01 sck10, si10, so10 sck20, si20, so20 intcsi00 intcsi01 intcsi10 intcsi20 interrupt transfer end interrupt (in single-transfer mode) or buff er empty interrupt (in continuous transfer mode) can be selected. error detection flag overrun error detection flag (ovfmn) only transfer data length 7 or 8 bits transfer rate max. f mck /6 [mhz] notes 1, 2 data phase selectable by dapmn bit ? dapmn = 0: data i/o starts from the start of the operation of the serial clock. ? dapmn = 1: data i/o starts half a clock befo re the start of the serial clock operation. clock phase selectable by ckpmn bit ? ckpmn = 0: forward ? ckpmn = 1: reverse data direction msb or lsb first notes 1. because the external serial clock input to pins sck 00, sck01, sck10, and sck20 is sampled internally and used, the fastest transfer rate is f mck /6 [mhz]. 2. use this operation within a range t hat satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. f mck : operation clock (mck) frequency of target channel 2. for 78k0r/lf3, csi00 and csi01 are not mounted. 3. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 512 jun 20, 2011 (1) register setting figure 14-60. example of contents of registers fo r slave transmission/recepti on of 3-wire serial i/o (csi00, csi01, csi10, csi20) (a) serial output register m (som) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 ckom1 ckom0 0 0 0 0 1 som2 0/1 som1 0/1 som0 0/1 (b) serial output enable register m (soem) ? se ts only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 0/1 soem0 0/1 (c) serial channel start register m (ssm) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 0/1 ssm0 0/1 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 1 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 0 mdmn1 0 mdmn0 0/1 operation mode of channel n 0: transfer end interrupt 1: buffer empty interrupt (e) serial communication operati on setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 1 rxemn 1 dapmn 0/1 ckpmn 0/1 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0/1 0 slcmn1 0 slcmn0 0 0 dlsmn2 1 dlsmn1 1 dlsmn0 0/1 (f) serial data register mn (sdrmn) (lower 8 bits: siop) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn 0000000 (baud rate setting) 0 transmit data setting/receive data register remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) : setting is fixed in the csi slave transmission/reception mode, : setting di sabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user siop 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 513 jun 20, 2011 (2) operation procedure figure 14-61. initial setting proce dure for slave transmission/reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting initial setting setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting som register changing setting of soem register setting port writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set bits 15 to 9 to 0000000b for baud rate setting. manipulate the somn bit and set an initial output level. set the soemn bit to 1 and enable data output of the target channel. enable data output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. set transmit data to the siop register (bits 7 to 0 of the sdrmn register) and wait for a clock from the master. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 514 jun 20, 2011 figure 14-62. procedure for stopping slave transmission/reception remark even after communication is stopped, the pin level is retained. to resume the operation, re-set the som register (see figure 14-63 procedure for resu ming slave transmission/reception ). starting setting to stop setting stm register write 1 to the stmn bit of the target channel. changing setting of soem register stopping communication set the soem register and stop the output of the target channel. stop communication in midway. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 515 jun 20, 2011 figure 14-63. procedure for resu ming slave transmission/reception starting setting for resumption manipulating target for communication port manipulation changing setting of spsm register changing setting of smrmn register changing setting of som register stop the target fo r communication or wait until the target completes its operation. disable data output of the target channel by setting a port register and a port mode register. change the setting if an incorrect division ratio of the operation clock is set. change the setting if the setting of the smrmn register is incorrect. manipulate the somn bit and set an initial output level. (essential) (essential) ( selective ) (selective) (selective) clearing error flag (selective) cleared by using sirmn registe r if fef, pef, or ovf flag remains set. changing setting of sdrm register change the setting if an incorrect division ratio of the operation clock is set. ( selective ) changing setting of scrmn register change the setting if the setting of the scrmn register is incorrect. ( selective ) changing setting of soem register set the soem register and stop the output of the target channel. (selective) changing setting of soem register port manipulation writing to ssm register set the soem register and enable the output of the target channel. enable data output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. (selective) (essential) (essential) starting communication starting target for communication set transmit data to the siop register (bits 7 to 0 of the sdrmn register) and wait for a clock from the master. start the target for communication. (essential) (essential) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 516 jun 20, 2011 (3) processing flow (in single -transmission/reception mode) figure 14-64. timing chart of sl ave transmission/recept ion (in single-transmi ssion/reception mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sip pin shift register mn intcsip tsfmn sop pin stmn data transmission/reception (8-bit length) receive data 3 receive data 2 receive data 1 transmit data 1 transmit data 2 transmit data 3 receive data 2 receive data 3 write read write read read write transmit data 3 transmit data 2 transmit data 1 reception & shift operation reception & shift operation reception & shift operation receive data 1 data transmission/reception (8-bit length) data transmission/reception (8-bit length) remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 517 jun 20, 2011 figure 14-65. flowchart of slave transmission/ reception (in single- tran smission/reception mode) starting csi communication writing 1 to ssmn bit writing transmit data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. smrmn, scrmn: setting communication sdrmn[15:9] : setting transfer rate som, soem : setting output transfer end interrupt generated? transmission/reception completed? no no yes yes setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation clearing sau1en and sau0en bits of per0 register to 0 end of communication reading siop (=sdrmn[7:0]) register starting transmission/reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 518 jun 20, 2011 (4) processing flow (in continu ous transmission/reception mode) figure 14-66. timing chart of sla ve transmission/reception (in continuous transmission/reception mode) (type 1: dapmn = 0, ckpmn = 0) ssmn semn sdrmn sckp pin sip pin shift register mn intcsip tsfmn sop pin bffmn mdmn0 stmn <4> <5> transmit data 1 transmit data 3 receive data 3 write read read read write <1> <2> <3> <2> <3> <4> <2> <7> <8> ( note 1 ) transmit data 2 write <6> <3> ( note 2 ) ( note 2 ) reception & shift operation receive data 2 receive data 1 receive data 1 receive data 2 receive data 3 transmit data 3 transmit data 2 transmit data 1 data transmission/reception (8-bit length) reception & shift operation reception & shift operation data transmission/reception (8-bit length) data transmission/reception (8-bit length) notes 1. when transmit data is written to the sdrmn register while bffmn = 1, the transmit data is overwritten. 2. the transmit data can be read by r eading the sdrmn register during this period. at this time, the transfer operation is not affected. caution the mdmn0 bit can be rewr itten even during operation. however, rewrite it before transfer of the last bit is started, so that it will be rewritten before the transfer end interrupt of the last transmit data. remarks 1. <1> to <8> in the figure correspond to <1> to <8> in figure 14-67 flowchart of slave transmission/reception (in contin uous transmission/reception mode ). 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 519 jun 20, 2011 figure 14-67. flowchart of slave transmission/recep tion (in continuous transmission/reception mode) starting csi communication writing 1 to ssmn bit reading receive data to siop (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. <1> select the buffer empty interrupt. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate som, soem: setting output y es y es n o n o setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation end of communication clearing 0 to mdmn0 bit n o transfer end interrupt generated? y es n o communication continued? y es y es clearing sau1en and sau0en bits of per0 register to 0 communication data exists? writing transmit data to siop (=sdrmn[7:0]) tsfmn = 1? reading receive data to siop (=sdrmn[7:0]) writing 1 to mdmn0 bit buffer empty interrupt generated? <2> <3> <5> <6> <7> <4> <8> n o caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. remark <1> to <8> in the figure correspond to <1> to <8> in figure 14-66 timing chart of slave transmission/reception (in continuo us transmission/reception mode) . 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 520 jun 20, 2011 14.5.7 calculating transfer clock frequency the transfer clock frequency for 3-wire serial i/o (csi00, csi 01, csi10, csi20) communic ation can be calculated by the following expressions. (1) master (transfer clock frequency) = {operation clock (mck) frequency of target channel} (sdrmn[15:9] + 1) 2 [hz] (2) slave (transfer clock frequency) = {frequency of serial clock (sck) supplied by master} note [hz] note the permissible maximum frequency is the smaller of f clk /6 and f mck /2. remarks 1. the value of sdrmn[15:9] is t he value of bits 15 to 9 of t he sdrmn register (0000000b to 1111111b) and therefore is 0 to 127. 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2) the operation clock (mck) is determined by serial clock se lect register m (spsm) and bit 15 (cksmn) of serial mode register mn (smrmn). 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 521 jun 20, 2011 table 14-2. selection of operation clock smrmn register spsm register operation clock (mck) note1 cksmn prs m13 prs m12 prs m11 prs m10 prs m03 prs m02 prs m01 prs m00 f clk = 20 mhz x x x x 0 0 0 0 f clk 20 mhz x x x x 0 0 0 1 f clk /2 10 mhz x x x x 0 0 1 0 f clk /2 2 5 mhz x x x x 0 0 1 1 f clk /2 3 2.5 mhz x x x x 0 1 0 0 f clk /2 4 1.25 mhz x x x x 0 1 0 1 f clk /2 5 625 khz x x x x 0 1 1 0 f clk /2 6 313 khz x x x x 0 1 1 1 f clk /2 7 156 khz x x x x 1 0 0 0 f clk /2 8 78.1 khz x x x x 1 0 0 1 f clk /2 9 39.1 khz x x x x 1 0 1 0 f clk /2 10 19.5 khz x x x x 1 0 1 1 f clk /2 11 9.77 khz 0 x x x x 1 1 1 1 inttm02 if m = 0, inttm03 if m = 1 note2 0 0 0 0 x x x x f clk 20 mhz 0 0 0 1 x x x x f clk /2 10 mhz 0 0 1 0 x x x x f clk /2 2 5 mhz 0 0 1 1 x x x x f clk /2 3 2.5 mhz 0 1 0 0 x x x x f clk /2 4 1.25 mhz 0 1 0 1 x x x x f clk /2 5 625 khz 0 1 1 0 x x x x f clk /2 6 313 khz 0 1 1 1 x x x x f clk /2 7 156 khz 1 0 0 0 x x x x f clk /2 8 78.1 khz 1 0 0 1 x x x x f clk /2 9 39.1 khz 1 0 1 0 x x x x f clk /2 10 19.5 khz 1 0 1 1 x x x x f clk /2 11 9.77 khz 1 1 1 1 1 x x x x inttm02 if m = 0, inttm03 if m = 1 note2 other than above setting prohibited notes 1. when changing the clock selected for f clk (by changing the system clock control register (ckc) value), do so after having stopped (stm = 000fh) the opera tion of the serial array unit (saum). when selecting inttm02 and inttm03 for the operation clock, also stop the timer array unit (tau0) (tt0 = 00ffh). 2. saum can be operated at a fixed division rati o of the subsystem clock, regardless of the f clk frequency (main system clock, subsystem clock), by operating the interval timer for which f sub /4 has been selected as the count clock (setting tis02 (if m = 0) or tis03 (if m = 1) of the tis0 register to 1) and selecting inttm02 and inttm03 by using the spsm r egister in channels 2 and 3 of tau0. when changing f clk , however, saum and tau0 must be stopped as described in note 1 above. remarks 1. x: don?t care 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 522 jun 20, 2011 14.6 operation of uart (uart0, uart1, uart2, uart3) communication this is a start-stop synchronization function using two line s: serial data transmission (txd) and serial data reception (rxd) lines. it transmits or receives data in asynchronization with the party of communication (by using an internal baud rate). full-duplex uart communication can be realized by using two channels, one dedicated to transmission (even channel) and the other to reception (odd channel). [data transmission/reception] ? data length of 5, 7, or 8 bits ? select the msb/lsb first ? level setting of transmit/recei ve data and select of reverse ? parity bit appending and parity check functions ? stop bit appending [interrupt function] ? transfer end interrupt/buffer empty interrupt ? error interrupt in case of framing error, parity error, or overrun error [error detection flag] ? framing error, parity error, or overrun error the lin-bus is supported in uart3 (2, 3 channels of unit 1) [lin-bus functions] ? wakeup signal detection ? sync break field (sbf) detection ? sync field measurement, baud rate calculation uart0 uses channels 0 and 1 of sau0. uart1 uses channels 2 and 3 of sau0. uart2 uses channels 0 and 1 of sau1. uart3 uses channels 2 and 3 of sau1. unit channel used as csi used as uart used as simplified i 2 c 0 csi00 uart0 ? 1 csi01 ? 2 csi10 uart1 iic10 0 3 ? ? 0 csi20 iic20 1 ? uart2 ? 2 ? uart3 (supporting lin-bus) ? 1 3 ? ? caution when using serial array units 0 and 1 as uart s, the channels of both th e transmitting side (even- number channel) and the receiving side (odd-n umber channel) can be used only as uarts. remark for 78k0r/lf3, uart0 is not mounted. external interrupt (intp0) or timer array unit (tau) is used. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 523 jun 20, 2011 uart performs the following four types of communication operations. ? uart transmission (see 14.6.1 .) ? uart reception (see 14.6.2 .) ? lin transmission (uart3 only) (see 14.6.3 .) ? lin reception (uart 3 only) (see 14.6.4 .) 14.6.1 uart transmission uart transmission is an operation to transmit data fr om the 78k0r/lx3 microcontrollers to another device asynchronously (start-stop synchronization). of two channels used for uart, the even channel is used for uart transmission. uart uart0 uart1 uart2 uart3 target channel channel 0 of sau0 channel 2 of sau0 channel 0 of sau1 channel 2 of sau1 pins used txd0 txd1 txd2 txd3 intst0 intst1 intst2 intst3 interrupt transfer end interrupt (in single-transfer mode) or buff er empty interrupt (in continuous transfer mode) can be selected. error detection flag none transfer data length 5, 7, or 8 bits transfer rate max. f mck /6 [bps] (sdrmn [15:9] = 2 or more), min. f clk /(2 2 11 128) [bps] note data phase forward output (default: high level) reverse output (default: low level) parity bit the following selectable ? no parity bit ? appending 0 parity ? appending even parity ? appending odd parity stop bit the following selectable ? appending 1 bit ? appending 2 bits data direction msb or lsb first note use this operation within a range that satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. f mck : operation clock (mck) frequency of target channel f clk : system clock frequency 2. for 78k0r/lf3, uart0 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 524 jun 20, 2011 (1) register setting figure 14-68. example of contents of registers for uart transmission of uart (uart0, uart1, uart2, uart3) (1/2) (a) serial output register m (som) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 ckom1 ckom0 0 0 0 0 1 som2 0/1 note som1 som0 0/1 note (b) serial output enable register m (soem) ? se ts only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 soem0 0/1 (c) serial channel start register m (ssm) ? sets only the bits of the target channel to 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 ssm0 0/1 (d) serial output level register m (solm) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 solm 0 0 0 0 0 0 0 0 0 0 0 0 0 solm2 0/1 0 solm0 0/1 0: forward (normal) transmission 1: reverse transmission (e) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 0 mdmn1 1 mdmn0 0/1 operation mode of channel n 0: transfer end interrupt 1: buffer empty interrupt note before transmission is started, be sure to set to 1 when the solmn bit of the target channel is set to 0, and set to 0 when the solmn bit of the target channel is set to 1. the value varies depending on the communication data during communication operation. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), q: uart number (q = 0 to 3) : setting is fixed in the uart transmission mode, : setting disabled (fixed by hardware) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 525 jun 20, 2011 figure 14-68. example of contents of registers for uart transmission of uart (uart0, uart1, uart2, uart3) (2/2) (f) serial communication operation setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 1 rxemn 0 dapmn 0 ckpmn 0 0 eocmn 0 ptcmn1 0/1 ptcmn0 0/1 dirmn 0/1 0 slcmn1 0/1 slcmn0 0/1 0 dlsmn2 1 dlsmn1 0/1 dlsmn0 0/1 setting of stop bit 01b: appending 1 bit 10b: appending 2 bits setting of parity bit 00b: no parity 01b: 0 parity 10b: even parity 11b: odd parity (g) serial data register mn (sdrmn) (lower 8 bits: txdq) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 transmit data setting remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), q: uart number (q = 0 to 3) : setting is fixed in the uart transmission mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user txdq 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 526 jun 20, 2011 (2) operation procedure figure 14-69. initial setting procedure for uart transmission caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting initial setting setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting som register setting port changing setting of soem register writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set a transfer baud rate. manipulate the somn bit and set an initial output level. enable data output of the target channel by setting a port register and a port mode register. set the soemn bit to 1 and enable data output of the target channel. set the ssmn bit of the target channel to 1 to set semn = 1. set transmit data to the txdq register (bits 7 to 0 of the sdrmn register) and start communication. changing setting of solm register set an output data level. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 527 jun 20, 2011 figure 14-70. procedure for stopping uart transmission remark even after communication is stopped, the pin level is retained. to resume the operation, re-set the som register (see figure 14-71 procedure for resuming uart transmission ). starting setting to stop setting stm register write 1 to the stmn bit of the target channel. changing setting of soem register stopping communication set the soemn bit to 0 and stop the output. stop communication in midway. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 528 jun 20, 2011 figure 14-71. procedure for resuming uart transmission port manipulation changing setting of spsm register changing setting of sdrm register changing setting of smrmn register changing setting of som register port manipulation writing to ssm register starting communication disable data output of the target channel by setting a port register and a port mode register. change the setting if an incorrect division ratio of the operation clock is set. change the setting if an incorrect transfer baud rate is set. change the setting if the setting of the smrmn register is incorrect. manipulate the somn bit and set an initial output level. enable data output of the target channel by setting a port register and a port mode register. set the ssmn bit of the target channel to 1 to set semn = 1. sets transmit data to the txdq register (bits 7 to 0 of the sdrmn register) and start communication. (essential) (selective) (essential) changing setting of soem register set the soemn bit to 1 and enable output. changing setting of soem register clear the soemn bit to 0 and stop output. (essential) changing setting of scrmn register change the setting if the setting of the scrmn register is incorrect. changing setting of solmn register change the setting if the setting of the solmn register is incorrect. starting setting for resumption (essential) (essential) (essential) (essential) (selective) (selective) (selective) (selective) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 529 jun 20, 2011 (3) processing flow (in si ngle-transmission mode) figure 14-72. timing chart of uart tr ansmission (in single-transmission mode) ssmn semn sdrmn txdq pin shift register mn intstq tsfmn p sp st st p sp st p sp stmn data transmission (7-bit length) data transmission (7-bit length) data transmission (7-bit length) transmit data 1 transmit data 2 transmit data 3 transmit data 3 transmit data 2 transmit data 1 shift operation shift operation shift operation remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), q: uart number (q = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 530 jun 20, 2011 figure 14-73. flowchart of uart tran smission (in single-transmission mode) caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting uart communication writing 1 to ssmn bit writing transmit data to txdq (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate solmn: setting output data level som, soem: setting output transfer end interrupt generated? transmission completed? no no yes yes setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation end of communication clearing sau1en and sau0en bits of per0 register to 0 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 531 jun 20, 2011 (4) processing flow (in continuous transmission mode) figure 14-74. timing chart of uart transmission (in continuous transmission mode) ssmn semn sdrmn txdq pin shift register mn intstq tsfmn p st st p st p sp bffmn mdmn0 stmn sp sp data transmission (7-bit length) data transmission (7-bit length) transmit data 1 transmit data 2 transmit data 3 transmit data 3 transmit data 2 transmit data 1 shift operation shift operation shift operation <1> <2> <2> <3> ( note ) <2> <3> <5> <3> <4> data transmission (7-bit length) <6> note when transmit data is written to the sdrmn register while bffmn = 1, the transmit data is overwritten. caution the mdmn0 bit can be rewr itten even during operation. however, rewrite it before transfer of the last bit is started, so that it has been rewritten before the transfer end interrupt of the last transmit data. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), q: uart number (q = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 532 jun 20, 2011 figure 14-75. flowchart of uart transmission (in continuous transmission mode) starting uart communication writing 1 to ssmn bit writing transmit data to txdq (=sdrmn[7:0]) writing 1 to stmn bit perform initial setting when semn = 0. <1> select the buffer empty interrupt. smrmn, scrmn: setting communication sdrmn[15:9]: setting transfer rate solmn: setting output data level som, soem: setting output n o n o n o y es setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register port manipulation end of communication clearing 0 to mdmn0 bit y es tsfmn = 1? transfer end interrupt g enerated? n o y es n o communication continued? y es y es clearing sau1en and sau0en bits of per0 register to 0 transmitting next data? <2> <3> buffer empty interrupt generated? writing 1 to mdmn0 bit <4> <5> caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. remark <1> to <5> in the figure correspond to <1> to <5> in figure 14-74 timing chart of uart transmission (in continuous transmission mode) . 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 533 jun 20, 2011 14.6.2 uart reception uart reception is an operation wherein the 78k0r/lx3 mi crocontrollers asynchronously receive data from another device (start-stop synchronization). for uart reception, the odd-number channel of the two c hannels used for uart is used. the smr register of both the odd- and even-numbered channels must be set. uart uart0 uart1 uart2 uart3 target channel channel 1 of sau0 channel 3 of sau0 channel 1 of sau1 channel 3 of sau1 pins used rxd0 rxd1 rxd2 rxd3 intsr0 intsr1 intsr2 intsr3 interrupt transfer end interrupt only (setting the buffer empty interrupt is prohibited.) error interrupt intsre0 intsre1 intsre2 intsre3 error detection flag ? framing error detection flag (fefmn) ? parity error detection flag (pefmn) ? overrun error detection flag (ovfmn) transfer data length 5, 7 or 8 bits transfer rate max. f mck /6 [bps] (sdrmn [15:9] = 2 or more), min. f clk /(2 2 11 128) [bps] note data phase forward output (default: high level) reverse output (default: low level) parity bit the following selectable ? no parity bit (no parity check) ? appending 0 parity (no parity check) ? appending even parity ? appending odd parity stop bit appending 1 bit data direction msb or lsb first note use this operation within a range that satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. f mck : operation clock (mck) frequency of target channel f clk : system clock frequency 2. for 78k0r/lf3, uart0 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 534 jun 20, 2011 (1) register setting figure 14-76. example of contents of registers for uart reception of uart (uart0, uart1, uart2, uart3) (1/2) (a) serial output register m (som) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 ckom1 ckom0 0 0 0 0 1 som2 som1 som0 (b) serial output enable register m (soem) ? sets the bits of the target channel to 0. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 soem1 0/1 soem0 (c) serial channel start register m (ssm) ? sets only the bits of the target channel is 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 0/1 ssm2 ssm1 0/1 ssm0 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 1 0 sismn0 0/1 1 0 0 mdmn2 0 mdmn1 1 mdmn0 0 0: forward (normal) reception 1: reverse reception operation mode of channel n 0: transfer end interrupt (e) serial mode register mr (smrmr) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmr cksmr 0/1 ccsmr 0 0 0 0 0 0 stsmr 0 0 sismr0 0 1 0 0 mdmr2 0 mdmr1 1 mdmr0 0/1 same setting value as cksmn operation mode of channel r 0: transfer end interrupt 1: buffer empty interrupt (f) serial communication operation setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 0 rxemn 1 dapmn 0 ckpmn 0 0 eocmn 1 ptcmn1 0/1 ptcmn0 0/1 dirmn 0/1 0 slcmn1 0 slcmn0 1 0 dlsmn2 1 dlsmn1 0/1 dlsmn0 0/1 caution for the uart reception, be sure to set smrmr of channel r that is to be paired with channel n. remark m: unit number (m = 0, 1), n: channel number (n = 1, 3), r: channel number (r = n ? 1), q: uart number (q = 0 to 3) : setting is fixed in the uart reception mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 535 jun 20, 2011 figure 14-76. example of contents of registers for uart reception of uart (uart0, uart1, uart2, uart3) (2/2) (g) serial data register mn (sdrmn) (lower 8 bits: rxdq) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 receive data register caution for the uart reception, be sure to set smrmr of channel r that is to be paired with channel n. remark m: unit number (m = 0, 1), n: channel number (n = 1, 3), r: channel number (r = n ? 1), q: uart number (q = 0 to 3) : setting is fixed in the uart reception mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user rxdq 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 536 jun 20, 2011 (2) operation procedure figure 14-77. initial setting procedure for uart reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 14-78. procedure for stopping uart reception starting initial setting setting per0 register setting spsm register setting smrmn and smrmr registers setting scrmn register setting sdrmn register writing to ssm register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set a transfer baud rate. set the ssmn bit of the target channel to 1 to set semn = 1. the start bit is detected. starting setting to stop setting stm register stopping communication write 1 to the stmn bit of the target channel. stop communication in midway. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 537 jun 20, 2011 figure 14-79. procedure for resuming uart reception starting setting for resumption manipulating target for communication changing setting of spsm register changing setting of sdrmn register writing to ssm register starting communication stop the target for communication or wait until the target completes its operation. change the setting if an incorrect division ratio of the operation clock is set. change the setting if an incorrect transfer baud rate is set. change the setting if the setting of the smrmn and smrmr registers is incorrect. set the ssmn bit of the target channel to 1 to set semn = 1. the start bit is detected. (essential) (selective) change the setting if the setting of the scrmn register is incorrect. changing setting of scrmn register cleared by using sirm register if fef, pef, or ovf flag remains set. clearing error flag clear the soem register to 0 and stop data output of the target channel. changing setting of soem register changing setting of smrmn and smrmr registers (essential) (essential) (essential) (selective) (selective) (selective) (selective) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 538 jun 20, 2011 (3) processing flow figure 14-80. timing chart of uart reception ssmn semn sdrmn rxdq pin shift register mn intsrq tsfmn p st st p st p stmn sp sp sp data reception (7-bit length) data reception (7-bit length) data reception (7-bit length) receive data 1 receive data 2 receive data 3 receive data 2 receive data 1 shift operation shift operation shift operation receive data 3 remark m: unit number (m = 0, 1), n: channel number (n = 1, 3), q: uart number (q = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 539 jun 20, 2011 figure 14-81. flowchart of uart reception caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting uart communication writing 1 to ssmn bit writing 1 to stmn bit end of uart communication perform initial setting when semn = 0. smrmn, smrmr, scrmn: setting communication sdrmn[15:9]: setting transfer rate som: set ckomn and somn bits to 1 transfer end interrupt generated? reception completed? no no yes yes starting reception reading rxdq register (sdrmn[7:0]) detecting start bit error interrupt generated? error processing no yes port manipulation clearing sau1en and sau0en bits of per0 register to 0 setting sau1en and sau0en bits of per0 register to 1 setting transfer rate by spsm register 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 540 jun 20, 2011 14.6.3 lin transmission of uart transmission, uart3 supports lin communication. for lin transmission, channel 2 of unit 1 (sau1) is used. uart uart0 uart1 uart2 uart3 support of lin communication not supported not supported not supported supported target channel ? ? ? channel 2 of sau1 pins used ? ? ? txd3 ? ? ? intst3 interrupt transfer end interrupt (in single-transfer mode) or buffer empty interrupt (in continuous transfer mode) can be selected. error detection flag none transfer data length 8 bits transfer rate max. f mck /6 [bps] (sdrmn [15:9] = 2 or more), min. f clk /(2 2 11 128) [bps] note data phase forward output (default: high level) reverse output (default: low level) parity bit the following selectable ? no parity bit ? appending 0 parity ? appending even parity ? appending odd parity stop bit the following selectable ? appending 1 bit ? appending 2 bits data direction msb or lsb first note use this operation within a range that satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. f mck : operation clock (mck) frequency of target channel f clk : system clock frequency 2. for 78k0r/lf3, uart0 is not mounted. lin stands for local interconnect network and is a low-speed (1 to 20 kbps) serial communication protocol designed to reduce the cost of an automobile network. communication of lin is single-master communicatio n and up to 15 slaves can be connected to one master. the slaves are used to control switches, actuators, and sensors, which are connect ed to the master via lin. usually, the master is connected to a network such as can (controller area network). a lin bus is a single-wire bus to which nodes are connected via transceiver conforming to iso9141. according to the protocol of li n, the master transmits a frame by attaching baud rate information to it. a slave receives this frame and corrects a baud rate error from the master. if the baud rate error of a slave is within 15%, communication can be established. figure 14-82 outlines a trans mission operation of lin. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 541 jun 20, 2011 figure 14-82. transmission operation of lin lin bus wakeup signal frame 8 bits note 1 55h transmission data transmission data transmission data transmission data transmission 13-bit sbf transmission note 2 sync break field sync field identification field data field data field checksum field t x d3 (output) intst3 note 3 notes 1. the baud rate is set so as to satisfy the standard of the wakeup signal and data of 00h is transmitted. 2. a sync break field is defined to have a width of 13 bi ts and output a low level. where the baud rate for main transfer is n [bps], therefore, the baud rate of the sync break field is calculated as follows. (baud rate of sync break field) = 9/13 n by transmitting data of 00h at this baud rate, a sync break field is generated. 3. intst3 is output upon completion of transmission. intst3 is also output when sbf transmission is executed. remark the interval between fields is controlled by software. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 542 jun 20, 2011 figure 14-83. flowchart for lin transmission starting lin communication writing 1 to ss12 transmitting wakeup signal frame transmitting sync break field writing 1 to st12 end of lin communication sync break field identification field data field checksum field sync field transfer end interrupt g enerated? transfer end interrupt g enerated? writing 1 to ss12 transmitting 55h wakeup signal frame setting baud rate setting transfer data 00h setting transfer data 00h setting baud rate receiving data 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 543 jun 20, 2011 14.6.4 lin reception of uart reception, uart3 supports lin communication. for lin reception, channel 3 of unit 1 (sau1) is used. uart uart0 uart1 uart2 uart3 support of lin communication not supported not supported not supported supported target channel ? ? ? channel 3 of sau1 pins used ? ? ? rxd3 ? ? ? intsr3 interrupt transfer end interrupt only (setting the buffer empty interrupt is prohibited.) error interrupt ? ? ? intsre3 error detection flag ? framing error detection flag (fef13) ? parity error detection flag (pef13) ? overrun error detection flag (ovf13) transfer data length 8 bits transfer rate max. f mck /6 [bps] (sdrmn [15:9] = 2 or more), min. f clk /(2 2 11 128) [bps] note data phase forward output (default: high level) reverse output (default: low level) parity bit the following selectable ? no parity bit ? appending 0 parity ? appending even parity ? appending odd parity stop bit the following selectable ? appending 1 bit ? appending 2 bits data direction msb or lsb first note use this operation within a range that satisfies the conditions above and the ac characteristics in the electrical specifications (see chapter 31 electrical specifications ). remarks 1. f mck : operation clock (mck) frequency of target channel f clk : system clock frequency 2. for 78k0r/lf3, uart0 is not mounted. figure 14-84 outlines a rec eption operation of lin. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 544 jun 20, 2011 figure 14-84. reception operation of lin lin bus 13-bit sbf reception sf reception id reception data reception data reception data reception wakeup signal frame sync break field sync field identification field data filed data filed checksum field r x d3 (input) reception interrupt (intsr3) edge detection (intp0) capture timer disable enable disable enable <1> <2> <3> <4> <5> here is the flow of signal processing. <1> the wakeup signal is detected by detecting an interr upt edge (intp0) on a pin. when the wakeup signal is detected, enable reception of uart3 (r xe13 = 1) and wait for sbf reception. <2> when the start bit of sbf is detected, reception is started and serial data is sequentially stored in the rxd3 register (= bits 7 to 0 of the serial data register 13 (s dr13)) at the set baud rate. when the stop bit is detected, the reception end interrupt request (intsr3) is generated. when data of low levels of 11 bits or more is detected as sbf, it is judged that sbf reception has been correctly co mpleted. if data of low le vels of less than 11 bits is detected as sbf, it is judged that an sbf recepti on error has occurred, and the system returns to the sbf reception wait status. <3> when sbf reception has been correctly completed, star t channel 7 of the timer array unit and measure the bit interval (pulse width) of the sync field (see 6.7.5 operation as input signal high-/low-level width measurement ). <4> calculate a baud rate error from the bit interval of sync field (sf). stop uart3 once and adjust (re-set) the baud rate. <5> the checksum field should be distinguished by software. in addition, processing to initialize uart3 after the checksum field is received and to wait for reception of sbf should also be performed by software. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 545 jun 20, 2011 figure 14-85 shows the configuration of a port that manipulates reception of lin. the wakeup signal transmitted from the mast er of lin is received by detecting an ed ge of an external interrupt (intp0). the length of the sync field transmitted fr om the master can be measured by using t he external event capture operation of the timer array unit (tau) to calculate a baud-rate error. by controlling switch of port input (isc0 /isc1), the input source of port input (r xd3) for reception can be input to the external interrupt pin (intp0) and timer array unit (tau). figure 14-85. port configuration for manipulating reception of lin rxd3 input intp0 input channel 7 input of tau p50/rxd3 p120/intp0 p33/ti07 port input switch control (isc0) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 546 jun 20, 2011 the peripheral functions used for the lin communication operation are as follows. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 547 jun 20, 2011 figure 14-86. flowchart of lin reception starting lin communication detecting low-level width detecting low-level width stopping operation detecting high-level width end of lin communication sync break field identification field data field checksum field sync field sbf detected? writing 1 to st13 writing 1 to ss13 wakeup signal frame setting tau in capture mode (to measure low-level width) detecting low-level width receiving data wakeup detected? setting tau in capture mode (to measure low-/high-level width) detecting low-level width setting uart reception mode calculating baud rate detecting high-level width intp0, tau sau for details, see figure 14-81 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 548 jun 20, 2011 14.6.5 calculating baud rate (1) baud rate calculation expression the baud rate for uart (uart0, uart1, uart2, uart3) communication can be calculated by the following expressions. (baud rate) = {operation clock (mck) frequency of ta rget channel} (sdrmn[15:9] + 1) 2 [bps] caution setting sdrmn [15:9] = (0000000b, 0000001b) is prohibited. remarks 1. when uart is used, the value of sdrmn[15:9] is the value of bits 15 to 9 of the sdrmn register (0000010b to 1111111b) and therefore is 2 to 127. 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 3) the operation clock (mck) is determined by serial cloc k select register m (spsm) and bit 15 (cksmn) of serial mode register mn (smrmn). 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 549 jun 20, 2011 table 14-3. selection of operation clock smrmn register spsm register operation clock (mck) note1 cksmn prs m13 prs m12 prs m11 prs m10 prs m03 prs m02 prs m01 prs m00 f clk = 20 mhz x x x x 0 0 0 0 f clk 20 mhz x x x x 0 0 0 1 f clk /2 10 mhz x x x x 0 0 1 0 f clk /2 2 5 mhz x x x x 0 0 1 1 f clk /2 3 2.5 mhz x x x x 0 1 0 0 f clk /2 4 1.25 mhz x x x x 0 1 0 1 f clk /2 5 625 khz x x x x 0 1 1 0 f clk /2 6 313 khz x x x x 0 1 1 1 f clk /2 7 156 khz x x x x 1 0 0 0 f clk /2 8 78.1 khz x x x x 1 0 0 1 f clk /2 9 39.1 khz x x x x 1 0 1 0 f clk /2 10 19.5 khz x x x x 1 0 1 1 f clk /2 11 9.77 khz 0 x x x x 1 1 1 1 inttm02 if m = 0, inttm03 if m = 1 note2 0 0 0 0 x x x x f clk 20 mhz 0 0 0 1 x x x x f clk /2 10 mhz 0 0 1 0 x x x x f clk /2 2 5 mhz 0 0 1 1 x x x x f clk /2 3 2.5 mhz 0 1 0 0 x x x x f clk /2 4 1.25 mhz 0 1 0 1 x x x x f clk /2 5 625 khz 0 1 1 0 x x x x f clk /2 6 313 khz 0 1 1 1 x x x x f clk /2 7 156 khz 1 0 0 0 x x x x f clk /2 8 78.1 khz 1 0 0 1 x x x x f clk /2 9 39.1 khz 1 0 1 0 x x x x f clk /2 10 19.5 khz 1 0 1 1 x x x x f clk /2 11 9.77 khz 1 1 1 1 1 x x x x inttm02 if m = 0, inttm03 if m = 1 note2 other than above setting prohibited notes 1. when changing the clock selected for f clk (by changing the system clock control register (ckc) value), do so after having stopped (stm = 000fh) the opera tion of the serial array unit (saum). when selecting inttm02 and inttm03 for the operation clock, also stop the timer array unit (tau0) (tt0 = 00ffh). 2. saum can be operated at a fixed division rati o of the subsystem clock, regardless of the f clk frequency (main system clock, subsystem clock), by operating the interval timer for which f sub /4 has been selected as the count clock (setting tis02 (if m = 0) or tis03 (if m = 1) of the tis0 register to 1) and selecting inttm02 and inttm03 by using the spsm r egister in channels 2 and 3 of tau0. when changing f clk , however, saum and tau0 must be stopped as described in note 1 above. remarks 1. x: don?t care 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 550 jun 20, 2011 (2) baud rate error during transmission the baud rate error of uart (uart0, uart1, uart2, uart3) communication during transmission can be calculated by the following expression. make sure t hat the baud rate at the transmission side is within the permissible baud rate range at the reception side. (baud rate error) = (calculated baud rate value) (target baud rate) 100 ? 100 [%] here is an example of setting a uart baud rate at f clk = 20 mhz. f clk = 20 mhz uart baud rate (target baud rate) operation clock (mck) sdrmn[15:9] calculat ed baud rate error from target baud rate 300 bps f clk /2 9 64 300.48 bps +0.16 % 600 bps f clk /2 8 64 600.96 bps +0.16 % 1200 bps f clk /2 7 64 1201.92 bps +0.16 % 2400 bps f clk /2 6 64 2403.85 bps +0.16 % 4800 bps f clk /2 5 64 4807.69 bps +0.16 % 9600 bps f clk /2 4 64 9615.38 bps +0.16 % 19200 bps f clk /2 3 64 19230.8 bps +0.16 % 31250 bps f clk /2 3 39 31250.0 bps 0.0 % 38400 bps f clk /2 2 64 38461.5 bps +0.16 % 76800 bps f clk /2 64 76923.1 bps +0.16 % 153600 bps f clk 64 153846 bps +0.16 % 312500 bps f clk 31 312500 bps 0.0 % 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 551 jun 20, 2011 (3) permissible baud rate range for reception the permissible baud rate range for reception during uart (uart0, uart1, uart2, uart3) communication can be calculated by the following expression. make sure that the baud rate at the transmission side is within the permissible baud rate range at the reception side. 2 k nfr (maximum receivable baud rate) = 2 k nfr ? k + 2 brate 2 k (nfr ? 1) (minimum receivable baud rate) = 2 k nfr ? k ? 2 brate brate: calculated baud rate value at the reception side (see 14.6.5 (1) baud rate calculation expression .) k: sdrmn[15:9] + 1 nfr: 1 data frame length [bits] = (start bit) + (data length) + (parity bit) + (stop bit) figure 14-87. permissible baud rate range fo r reception (1 data frame length = 11 bits) fl 1 data frame (11 fl) (11 fl) min. (11 fl) max. data frame length of sau start bit bit 0 bit 1 bit 7 parity bit permissible minimum data frame length permissible maximum 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-87, the timing of latching receive data is determined by the division ratio set by bits 15 to 9 of the serial data register mn (sdrmn) after the start bit is detected. if the last data (stop bit) is received before this latch timing, the data can be correctly received. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 552 jun 20, 2011 14.7 operation of simplified i 2 c (iic10, iic20) communication this is a clocked communication function to communicate with two or more devices by using two lines: serial clock (scl) and serial data (sda). this communication function is designed to execute single communication with devices such as eeprom, flash memory, and a/d converter, and therefore, can be used only by the mast er and does not have a wait detection function. make sure by using software, as well as operating the control registers, t hat the ac specifications of the start and stop conditions are observed. [data transmission/reception] ? master transmission, master reception (onl y master function with a single master) ? ack output function note and ack detection function ? data length of 8 bits (when an address is transmitted, the addr ess is specified by the higher 7 bi ts, and the least significant bit is used for r/w control.) ? manual generation of start condition and stop condition [interrupt function] ? transfer end interrupt [error detection flag] ? parity error (ack error) * [functions not supported by simplified i 2 c] ? slave transmission, slave reception ? arbitration loss detection function ? wait detection function note an ack is not output when the last data is being received by writing 0 to the soemn (soem register) bit and stopping the output of serial communication data. see 14.7.3 (2) processing flow for details. remarks 1. to use the full-function i 2 c bus, see chapter 15 serial interface iica . 2. m: unit number (m = 0, 1), n: channel number (n = 0, 2) the channels supporting simplified i 2 c (iic10, iic20) are channel 2 of sau0 and channel 0 of sau1. unit channel used as csi used as uart used as simplified i 2 c 0 csi00 ? 1 csi01 uart0 ? 2 csi10 uart1 iic10 0 3 ? ? 0 csi20 uart2 iic20 1 ? ? 2 ? ? 1 3 ? uart3 (supporting lin-bus) ? 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 553 jun 20, 2011 simplified i 2 c (iic10, iic20) performs the following four types of communication operations. ? address field transmission (see 14.7.1 .) ? data transmission (see 14.7.2 .) ? data reception (see 14.7.3 .) ? stop condition generation (see 14.7.4 .) 14.7.1 address field transmission address field transmission is a transmission operation that first executes in i 2 c communication to identify the target for transfer (slave). after a start condition is generated, an addre ss (7 bits) and a transfer direction (1 bit) are transmitted i n one frame. simplified i 2 c iic10 iic20 target channel channel 2 of sau0 channel 0 of sau1 pins used scl10, sda10 note scl20, sda20 note intiic10 intiic20 interrupt transfer end interrupt only (setting the buffer empty interrupt is prohibited.) error detection flag parity error detection flag (pefmn) transfer data length 8 bits (transmitted with specifying the higher 7 bits as address and the least significant bit as r/w control) transfer rate max. f clk /4 [mhz] (sdrmn [15:9] = 1 or more) f clk : system clock frequency however, the following condition must be satisfied in each mode of i 2 c. ? max. 400 khz (first mode) ? max. 100 khz (standard mode) data level forward output (default: high level) parity bit no parity bit stop bit appending 1 bit (for ack reception timing) data direction msb first note to perform communication via simplified i 2 c, set the data i/o pins (sda10, sda 20) in the n-ch open-drain output (v dd tolerance) mode (pom14 = 1, pom11 = 1) by us ing the port output mode re gister 1 (pom1) (see 4.3 registers controlling port function for details). when communicating with an external device with a different potential, set the n-ch open-drain output (v dd tolerance) mode (pom15 = 1, pom10 = 1) also for the clock input/output pins (scl10, scl20) (see 4.4.4 connecting to external device wit h different potential (2.5 v, 3 v) for details). remark m: unit number (m = 0, 1), n: channel number (n = 0, 2) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 554 jun 20, 2011 (1) register setting figure 14-88. example of contents of register s for address field transmission of simplified i 2 c (iic10, iic20) (a) serial output register m (som) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 0/1 ckom1 ckom0 0/1 0 0 0 0 1 som2 0/1 som1 som0 0/1 start condition is generated by manipulating the somn bit. (b) serial output enable register m (soem) ? sets only the bits of the target channel. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 soem0 0/1 soemn = 0 until the start condition is generated, and soemn = 1 after generation. (c) serial channel start register m (ssm) ? sets only the bits of the target channel is 1. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 ssm0 0/1 (d) serial mode register mn (smrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 1 mdmn1 0 mdmn0 0 operation mode of channel n 0: transfer end interrupt (e) serial communication operati on setting register mn (scrmn) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 1 rxemn 0 dapmn 0 ckpmn 0 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0 0 slcmn1 0 slcmn0 1 0 dlsmn2 1 dlsmn1 1 dlsmn0 1 setting of parity bit 00b: no parity setting of stop bit 01b: appending 1 bit (ack) (f) serial data register mn (sdrmn) (lower 8 bits: sior) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 transmit data setting (address + r/w) remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), r: iic number (r = 10, 20) : setting is fixed in the iic mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user sior 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 555 jun 20, 2011 (2) operation procedure figure 14-89. initial setting proce dure for address field transmission caution after setting the saumen to 1, be sure to set the spsm register after 4 or more clocks have elapsed. starting initial setting setting per0 register setting spsm register setting smrmn register setting scrmn register setting sdrmn register setting som register setting port setting som register starting communication release the serial array unit from the reset status and start clock supply. set the prescaler. set an operation mode, etc. set a communication format. set a transfer baud rate. manipulate the somn and ckomn bits and set an initial output level. enable data output, clock output, and the n-ch open-drain output (v dd tolerance) mode of the target channel by setting a port register, a port mode register, and a port output mode register. clear the somn bit to 0 to generate the start condition. set address and r/w to the sior register (bits 7 to 0 of the sdrmn register) and start communication. writing to ssm register set the ssmn bit of the target channel to 1 to set semn = 1. setting som register clear the ckomn bit to 0 to lower the clock output level. changing setting of soem register set the soemn bit to 1 and enable data output of the target channel. secure a wait time so that the specifications of i 2 c on the slave side are satisfied. wait 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 556 jun 20, 2011 (3) processing flow figure 14-90. timing chart of address field transmission d7 d6 d5 d4 d3 d2 d1 d0 r/w d7 d6 ssmn semn soemn sdrmn sclr output sdar output sdar input shift register mn intiicr tsfmn d5 d4 d3 d2 d1 d0 ack address shift operation address field transmission somn bit manipulation ckomn bit manipulation remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), r: iic number (r = 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 557 jun 20, 2011 figure 14-91. flowchart of address field transmission starting iic communication writing 0 to somn bit address field transmission completed perform initial setting when semn = 0. smrmn, scrmn: se tting communication spsm, sdrmn[15:9]: setting transfer rate transfer end interrupt g enerated? no yes writing address and r/w data to sior (sdrmn[7:0]) writing 1 to ssmn bit parity error (ack error) flag pefmn = 1 ? no yes ack reception error to data transmission flow and data reception flow writing 1 to soemn bit writing 0 to ckomn bit 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 558 jun 20, 2011 14.7.2 data transmission data transmission is an operation to transmit data to the target for transfer (slave) after transmission of an address field. after all data are transmitted to the slave, a stop condition is generated and the bus is released. simplified i 2 c iic10 iic20 target channel channel 2 of sau0 channel 0 of sau1 pins used scl10, sda10 note scl20, sda20 note intiic10 intiic20 interrupt transfer end interrupt only (setting the buffer empty interrupt is prohibited.) error detection flag parity error detection flag (pefmn) transfer data length 8 bits transfer rate max. f clk /4 [mhz] (sdrmn [15:9] = 1 or more) f clk : system clock frequency however, the following condition must be satisfied in each mode of i 2 c. ? max. 400 khz (first mode) ? max. 100 khz (standard mode) data level forward output (default: high level) parity bit no parity bit stop bit appending 1 bit (for ack reception timing) data direction msb first note to perform communication via simplified i 2 c, set the data i/o pins (sda10, sda 20) in the n-ch open-drain output (v dd tolerance) mode (pom14 = 1, pom11 = 1) by us ing the port output mode re gister 1 (pom1) (see 4.3 registers controlling port function for details). when communicating with an external device with a different potential, set the n-ch open-drain output (v dd tolerance) mode (pom15 = 1, pom10 = 1) also for the clock input/output pins (scl10, scl20) (see 4.4.4 connecting to external device wit h different potential (2.5 v, 3 v) for details). remark m: unit number (m = 0, 1), n: channel number (n = 0, 2) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 559 jun 20, 2011 (1) register setting figure 14-92. example of contents of regist ers for data transmission of simplified i 2 c (iic10, iic20) (a) serial output register m (som) ? do not manipulate this regi ster during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 0/1 note ckom1 ckom0 0/1 note 0 0 0 0 1 som2 0/1 note som1 som0 0/1 note (b) serial output enable register m (soem) ? do not manipulate this register during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 soem0 0/1 (c) serial channel start register m (ssm) ? do not manipulate this register during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 ssm0 0/1 (d) serial mode register mn (smrmn) ? do not manipulate this re gister during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 1 mdmn1 0 mdmn0 0 (e) serial communication operation setting register mn (scrmn) ? do not manipulate the bits of this register, except the txemn and rxemn bits, during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 1 rxemn 0 dapmn 0 ckpmn 0 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0 0 slcmn1 0 slcmn0 1 0 dlsmn2 1 dlsmn1 1 dlsmn0 1 (f) serial data register mn (sdrmn) (lower 8 bits: sior) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 transmit data setting note the value varies depending on the communication data during communication operation. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), r: iic number (r = 10, 20) : setting is fixed in the iic mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user sior 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 560 jun 20, 2011 (2) processing flow figure 14-93. timing chart of data transmission d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 ssmn semn soemn sdrmn sclr output sdar output sdar input shift register mn intiicr tsfmn d5 d4 d3 d2 d1 d0 ack shift operation ?l? ?h? ?h? transmit data 1 remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), r: iic number (r = 10, 20) figure 14-94. flowchart of data transmission starting data transmission data transmission completed transfer end interrupt g enerated? no yes writing data to sior (sdrmn[7:0]) no yes ack reception error s top con di t i on generat i on data transfer completed? yes no address field transmission completed parity error (ack error) flag pefmn = 1 ? 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 561 jun 20, 2011 14.7.3 data reception data reception is an operation to receive data to the target for transfer (slave) after transmission of an address field. after all data are received to the slave, a stop condition is generated and the bus is released. simplified i 2 c iic10 iic20 target channel channel 2 of sau0 channel 0 of sau1 pins used scl10, sda10 note scl20, sda20 note intiic10 intiic20 interrupt transfer end interrupt only (setting the buffer empty interrupt is prohibited.) error detection flag none transfer data length 8 bits transfer rate max. f clk /4 [mhz] (sdrmn [15:9] = 1 or more) f clk : system clock frequency however, the following condition must be satisfied in each mode of i 2 c. ? max. 400 khz (first mode) ? max. 100 khz (standard mode) data level forward output (default: high level) parity bit no parity bit stop bit appending 1 bit (ack transmission) data direction msb first note to perform communication via simplified i 2 c, set the data i/o pins (sda10, sda 20) in the n-ch open-drain output (v dd tolerance) mode (pom14 = 1, pom11 = 1) by us ing the port output mode re gister 1 (pom1) (see 4.3 registers controlling port function for details). when communicating with an external device with a different potential, set the n-ch open-drain output (v dd tolerance) mode (pom15 = 1, pom10 = 1) also for the clock input/output pins (scl10, scl20) (see 4.4.4 connecting to external device wit h different potential (2.5 v, 3 v) for details). remark m: unit number (m = 0, 1), n: channel number (n = 0, 2) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 562 jun 20, 2011 (1) register setting figure 14-95. example of contents of regi sters for data reception of simplified i 2 c (iic10, iic20) (a) serial output register m (som) ? do not manipulate this regi ster during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 som 0 0 0 0 1 ckom2 0/1 note ckom1 ckom0 0/1 note 0 0 0 0 1 som2 0/1 note som1 som0 0/1 note (b) serial output enable register m (soem) ? do not manipulate this register during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 soem 0 0 0 0 0 0 0 0 0 0 0 0 0 soem2 0/1 soem1 soem0 0/1 (c) serial channel start register m (ssm) ? do not manipulate this register during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ssm 0 0 0 0 0 0 0 0 0 0 0 0 ssm3 ssm2 0/1 ssm1 ssm0 0/1 (d) serial mode register mn (smrmn) ? do not manipulate this re gister during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 smrmn cksmn 0/1 ccsmn 0 0 0 0 0 0 stsmn 0 0 sismn0 0 1 0 0 mdmn2 1 mdmn1 0 mdmn0 0 (e) serial communication operation setting register mn (scrmn) ? do not manipulate the bits of this register, except the txemn and rxemn bits, during data transmission/reception. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 scrmn txemn 0 rxemn 1 dapmn 0 ckpmn 0 0 eocmn 0 ptcmn1 0 ptcmn0 0 dirmn 0 0 slcmn1 0 slcmn0 1 0 dlsmn2 1 dlsmn1 1 dlsmn0 1 (f) serial data register mn (sdrmn) (lower 8 bits: sior) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 sdrmn baud rate setting 0 dummy transmit data setting (ffh) note the value varies depending on the communication data during communication operation. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), r: iic number (r = 10, 20) : setting is fixed in the iic mode, : setting disabled (set to the initial value) : bit that cannot be used in this mode (set to the initial value when not used in any mode) 0/1: set to 0 or 1 depending on the usage of the user sior 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 563 jun 20, 2011 (2) processing flow figure 14-96. timing chart of data reception (a) when starting data reception d7 d6 d5 d4 d3 d2 d1 d0 ssmn semn soemn sdrmn sclr output sdar output sdar input shift register mn intiicr tsfmn ack stmn txemn = 0 / rxemn = 1 txemn, rxemn txemn = 1 / rxemn = 0 shift operation ?h? dummy data (ffh) receive data (b) when receiving last data d7 d6 d5 d4 d3 d2 d1 d0 d2 d1 d0 stmn semn soemn sdrmn sclr output sdar output sdar input shift register mn intiicr tsfmn receive data receive data output is enabled by serial communication operation output is stopped by serial communication operation nack ack txemn = 0 / rxemn = 1 txemn, rxemn stop condition reception of last byte iic operation stop somn bit manipulation ckomn bit manipulation somn bit manipulation shift operation dummy data (ffh) shift operation dummy data (ffh) remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), r: iic number (r = 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 564 jun 20, 2011 figure 14-97. flowchart of data reception caution ack is also output when the last data is received. communication is then completed by setting ?1? to the stmn bit to stop operation and generating a stop condition. starting data reception data reception completed transfer end interrupt g enerated? no yes writing dummy data (ffh) to sior (sdrmn[7:0]) s top con di t i on generat i on yes no reading sior (sdrmn[7:0]) address field tran smission completed writing 1 to stmn bit writing 0 to txemn bit, and 1 to rxemn bit writing 1 to ssmn bit last byte received? yes writing 0 to soemn bit (stopping output by serial communication operation) no data transfer completed? 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 565 jun 20, 2011 14.7.4 stop condition generation after all data are transmitted to or received from the target sl ave, a stop condition is generated and the bus is released. (1) processing flow figure 14-98. timing chart of stop condition generation note during the receive operation, the soemn bit is set to 0 before receiving the last data. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), r: iic number (r = 10, 20) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 566 jun 20, 2011 figure 14-99. flowchart of stop condition generation 14.7.5 calculating transfer rate the transfer rate for simplified i 2 c (iic10, iic20) communication can be calculated by the following expressions. (transfer rate) = {operation clock (mck) frequency of target channel} (sdrmn[15:9] + 1) 2 caution setting sdrmn [15:9] = 0000000b is prohibi ted. set sdrmn[15:9] to 0000001b or greater. remarks 1. the value of sdrmn[15:9] is t he value of bits 15 to 9 of t he sdrmn register (0000000b to 1111111b) and therefore is 0 to 127. 2. m: unit number (m = 0, 1), n: channel number (n = 0, 2) the operation clock (mck) is determined by serial clock se lect register m (spsm) and bit 15 (cksmn) of serial mode register mn (smrmn). starting generation of stop condition. end of iic communication writing 1 to stmn bit to clear semn to 0. writing 0 to soemn bit writing 1 to somn bit writing 1 to ckomn bit writing 0 to somn bit completion of data transmission/data reception wait secure a wait time so that the specifications of i 2 c on the slave side are satisfied. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 567 jun 20, 2011 table 14-4. selection of operation clock smrmn register spsm register operation clock (mck) note1 cksmn prs m13 prs m12 prs m11 prs m10 prs m03 prs m02 prs m01 prs m00 f clk = 20 mhz x x x x 0 0 0 0 f clk 20 mhz x x x x 0 0 0 1 f clk /2 10 mhz x x x x 0 0 1 0 f clk /2 2 5 mhz x x x x 0 0 1 1 f clk /2 3 2.5 mhz x x x x 0 1 0 0 f clk /2 4 1.25 mhz x x x x 0 1 0 1 f clk /2 5 625 khz x x x x 0 1 1 0 f clk /2 6 313 khz x x x x 0 1 1 1 f clk /2 7 156 khz x x x x 1 0 0 0 f clk /2 8 78.1 khz x x x x 1 0 0 1 f clk /2 9 39.1 khz x x x x 1 0 1 0 f clk /2 10 19.5 khz x x x x 1 0 1 1 f clk /2 11 9.77 khz 0 x x x x 1 1 1 1 inttm02 if m = 0, inttm03 if m = 1 note2 0 0 0 0 x x x x f clk 20 mhz 0 0 0 1 x x x x f clk /2 10 mhz 0 0 1 0 x x x x f clk /2 2 5 mhz 0 0 1 1 x x x x f clk /2 3 2.5 mhz 0 1 0 0 x x x x f clk /2 4 1.25 mhz 0 1 0 1 x x x x f clk /2 5 625 khz 0 1 1 0 x x x x f clk /2 6 313 khz 0 1 1 1 x x x x f clk /2 7 156 khz 1 0 0 0 x x x x f clk /2 8 78.1 khz 1 0 0 1 x x x x f clk /2 9 39.1 khz 1 0 1 0 x x x x f clk /2 10 19.5 khz 1 0 1 1 x x x x f clk /2 11 9.77 khz 1 1 1 1 1 x x x x inttm02 if m = 0, inttm03 if m = 1 note2 other than above setting prohibited notes 1. when changing the clock selected for f clk (by changing the system clock control register (ckc) value), do so after having stopped (stm = 000fh) the opera tion of the serial array unit (saum). when selecting inttm02 and inttm03 for the operation clock, also stop the timer array unit (tau0) (tt0 = 00ffh). 2. saum can be operated at a fixed division rati o of the subsystem clock, regardless of the f clk frequency (main system clock, subsystem clock), by operating the interval timer for which f sub /4 has been selected as the count clock (setting tis02 (if m = 0) or tis03 (if m = 1) of the tis0 register to 1) and selecting inttm02 and inttm03 by using the spsm r egister in channels 2 and 3 of tau0. when changing f clk , however, saum and tau0 must be stopped as described in note 1 above. remarks 1. x: don?t care 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 568 jun 20, 2011 here is an example of setting an iic transfer rate where mck = f clk = 20 mhz. f clk = 20 mhz iic transfer mode (desired transfer rate) operation clock (mck) sdrmn[15:9] calculated transfer rate error from desired transfer rate 100 khz f clk 99 100 khz 0.0% 400 khz f clk 24 400 khz 0.0% 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 569 jun 20, 2011 14.8 processing procedure in case of error the processing procedure to be followed if an error of eac h type occurs is described in figures 14-100 to 14-102. figure 14-100. processing procedure in case of parity error or overrun error software manipulation hardware status remark reads sdrmn register. bff = 0, and channel n is enabled to receive data. this is to prevent an overrun error if the next reception is completed during error processing. reads ssrmn register. error type is identified and the read value is used to clear error flag. writes sirmn register. error flag is cl eared. error can be cleared only during reading, by writing the value read from the ssrmn register to the sirmn register without modification. figure 14-101. processing procedure in case of framing error software manipulation hardware status remark reads sdrmn register. bff = 0, and channel n is enabled to receive data. this is to prevent an overrun error if the next reception is completed during error processing. reads ssrmn register. error type is identified and the read value is used to clear error flag. writes sirmn register. error flag is cl eared. error can be cleared only during reading, by writing the value read from the ssrmn register to the sirmn register without modification. sets stmn bit to 1. semn = 0, and channel n stops operation. synchronization with other party of communication synchronization with the other party of communication is re-established and communication is resumed because it is considered that a framing error has occurred because the start bit has been shifted. sets ssmn bit to 1. semn = 1, and channel n is enabled to operate. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 570 jun 20, 2011 figure 14-102. processing procedure in case of parity error (ack error) in simplified i 2 c mode software manipulation hardware status remark reads sdrmn register. bff = 0, and channel n is enabled to receive data. this is to prevent an overrun error if the next reception is completed during error processing. reads ssrmn register. error type is identified and the read value is used to clear error flag. writes sirmn register. error flag is cl eared. error can be cleared only during reading, by writing the value read from the ssrmn register to the sirmn register without modification. sets stmn bit to 1. semn = 0, and channel n stops operation. creates stop condition. creates start condition. slave is not ready for reception because ack is not returned. therefore, a stop condition is created, the bus is released, and communication is started again from the start condition. or, a restart condition is generated and transmission can be redone from address transmission. sets ssmn bit to 1. semn = 1, and channel n is enabled to operate. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2), mn = 02, 10 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 571 jun 20, 2011 14.9 relationship between re gister settings and pins tables 14-5 to 14-12 show the relationship between register settings and pins for each channel of serial array units 0 and 1. table 14-5. relationship between register settings and pi ns (channel 0 of unit 0: csi00, uart0 transmission) pin function se 00 note1 md 002 md 001 soe 00 so 00 cko 00 txe 00 rxe 00 pm 80 p80 pm 81 note2 p81 note2 pm 82 p82 operation mode sck00/ intp11 /p80 si00/rxd0/ intp9/ p81 note2 so00/ txd0/p82 0 0 intp9/p81 0 0 1 0 1 1 0 0 note3 note3 note3 note3 note3 note3 operation stop mode intp11/ p80 rxd0/ intp9/p81 p82 0 1 1 0 1 1 1 note3 note3 slave csi00 reception sck00 (input) si00 p82 1 0/1 note4 1 1 0 1 note3 note3 0 1 slave csi00 transmission sck00 (input) intp9/p81 so00 1 0/1 note4 1 1 1 1 1 0 1 slave csi00 transmission/ reception sck00 (input) si00 so00 0 1 0/1 note4 0 1 0 1 1 note3 note3 master csi00 reception sck00 (output) si00 p82 1 0/1 note4 0/1 note4 1 0 0 1 note3 note3 0 1 master csi00 transmission sck00 (output) intp9/p81 so00 0 0 1 0/1 note4 0/1 note4 1 1 0 1 1 0 1 master csi00 transmission/ reception sck00 (output) si00 so00 1 0 1 1 0/1 note4 1 1 0 note3 note3 note3 note3 0 1 uart0 transmission note5 intp11/ p80 rxd0/ intp9/p81 txd0 notes 1. the se0 register is a read-only status register which is set using the ss0 and st0 registers. 2. when channel 1 of unit 0 is set to uart0 reception, this pin becomes an rxd0 function pin (refer to table 14-6 ). in this case, operation stop mode or uart0 trans mission must be selected for channel 0 of unit 0. 3. this pin can be set as a port function pin. 4. this is 0 or 1, depending on the communication operation. for details, refer to 14.3 (12) serial output register m (som) . 5. when using uart0 transmission and reception in a pair, set channel 1 of unit 0 to uart0 reception (refer to table 14-6 ). remarks 1. x: don?t care 2. for 78k0r/lf3, the channel 0 of unit 0 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 572 jun 20, 2011 table 14-6. relationship between register settings and pins (channel 1 of unit 0: csi01, uart0 reception) pin function se 01 note1 md 012 md 011 soe 01 so01 cko 01 txe 01 rxe 01 pm 75 p75 pm 76 p76 pm 77 p77 pm 81 note2 p81 note2 operation mode sck01/ kr5/ p75 si01/ kr6/ p76 so01/ kr7/ p77 rxd0/si00/ intp9/ p81 note2 0 0 0 0 1 0 1 1 0 0 note3 note3 note3 note3 note3 note3 note3 note3 operation stop mode kr5/ p75 kr6/p76 kr7/ p77 si00/ intp9/p80 0 1 1 0 1 1 1 note3 note3 note3 note3 slave csi01 reception sck01 (input) si01 kr7/ p77 si00/ intp9/p80 1 0/1 note4 1 1 0 1 note3 note3 0 1 note3 note3 slave csi01 transmission sck01 (input) kr6/p76 so01 si00/ intp9/p80 1 0/1 note4 1 1 1 1 1 0 1 note3 note3 slave csi01 transmission /reception sck01 (input) si01 so01 si00/ intp9/p80 0 1 0/1 note4 0 1 0 1 1 note3 note3 note3 note3 master csi01 reception sck01 (output) si01 kr7/ p77 si00/ intp9/p80 1 0/1 note4 0/1 note4 1 0 0 1 note3 note3 0 1 note3 note3 master csi01 transmission sck01 (output) kr6/p76 so01 si00/ intp9/p80 0 0 1 0/1 note4 0/1 note4 1 1 0 1 1 0 1 note3 note3 master csi01 transmission /reception sck01 (output) si01 so01 si00/ intp9/p80 1 0 1 0 1 1 0 1 note3 note3 note3 note3 note3 note3 1 uart0 reception note5, 6 kr5/ p75 kr6/p76 kr7/ p77 rxd0 notes 1. the se0 register is a read-only status register which is set using the ss0 and st0 registers. 2. when channel 1 of unit 0 is set to uart0 reception, this pin becomes an rxd0 function pin. in this case, set channel 0 of unit 0 to operation stop mode or uart0 transmission (refer to table 14-5 ). when channel 0 of unit 0 is set to csi00, this pin cannot be used as an rxd0 function pin. in this case, set channel 1 of unit 0 to operation stop mode or csi01. 3. this pin can be set as a port function pin. 4. this is 0 or 1, depending on the communication operation. for details, refer to 14.3 (12) serial output register m (som) . 5. when using uart0 transmission and reception in a pair, set channel 0 of unit 0 to uart0 transmission (refer to table 14-5 ). 6. the smr00 register of channel 0 of unit 0 must also be set during uart0 reception. for details, refer to 14.5.2 (1) register setting . remarks 1. x: don?t care 2. for 78k0r/lf3, the channel 1 of unit 0 is not mounted. 3. for 78k0r/lg3, csi01 is not mounted. 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 573 jun 20, 2011 table 14-7. relationship between register settings and pins (channel 2 of unit 0: csi10, uart1 transmission, iic10) pin function se 02 note1 md 022 md 021 soe 02 so 02 cko 02 txe 02 rxe 02 pm 15 p15 pm14 note2 p14 note2 pm13 p13 operation mode sck10/ scl10/ intp7/p15 si10/sda10/ rxd1/intp4 /p14 note2 so10/ txd1/ to04/p13 0 0 intp4/p14 0 1 rxd1/intp4/ p14 0 1 0 0 1 1 0 0 note3 note3 note3 note3 note3 note3 operation stop mode intp7/p15 intp4/p14 to04/p13 0 1 1 0 1 1 1 note3 note3 slave csi10 reception sck10 (input) si10 to04/p13 1 0/1 note4 1 1 0 1 note3 note3 0 1 slave csi10 transmission sck10 (input) intp4/p14 so10 1 0/1 note4 1 1 1 1 1 0 1 slave csi10 transmission /reception sck10 (input) si10 so10 0 1 0/1 note4 0 1 0 1 1 note3 note3 master csi10 reception sck10 (output) si10 to04/p13 1 0/1 note4 0/1 note4 1 0 0 1 note3 note3 0 1 master csi10 transmission sck10 (output) intp4/p14 so10 0 0 1 0/1 note4 0/1 note4 1 1 0 1 1 0 1 master csi10 transmission /reception sck10 (output) si10 so10 1 0 1 1 0/1 note4 1 1 0 note3 note3 note3 note3 0 1 uart1 transmission note5 intp7/p15 rxd1/intp4/ p14 txd1 0 0 1 0 0 0 0/1 note6 0/1 note6 0 1 0 1 0 1 note3 note3 iic10 start condition scl10 sda10 to04/p13 1 0/1 note4 0/1 note4 1 0 0 1 0 1 note3 note3 iic10 address field transmission scl10 sda10 to04/p13 1 0/1 note4 0/1 note4 1 0 0 1 0 1 note3 note3 iic10 data transmission scl10 sda10 to04/p13 1 1 0/1 note4 0/1 note4 0 1 0 1 0 1 note3 note3 iic10 data reception scl10 sda10 to04/p13 0 0 1 0 0 1 0 0 0/1 note7 0/1 note7 0 1 0 1 0 1 note3 note3 iic10 stop condition scl10 sda10 to04/p13 notes 1. the se0 register is a read-only status register which is set using the ss0 and st0 registers. 2. when channel 3 of unit 0 is set to uart1 reception, this pin becomes an rxd1 function pin (refer to table 14-8 ). in this case, operation stop mode or uart1 trans mission must be selected for channel 2 of unit 0. 3. this pin can be set as a port function pin. 4. this is 0 or 1, depending on the communication operation. for details, refer to 14.3 (12) serial output register m (som) . 5. when using uart1 transmission and reception in a pair, set channel 3 of unit 0 to uart1 reception (refer to table 14-8 ). 6. set the cko02 bit to 1 before a start condition is genera ted. clear the so02 bit from 1 to 0 when the start condition is generated. 7. set the cko02 bit to 1 before a stop condition is genera ted. clear the so02 bit from 0 to 1 when the stop condition is generated. remark x: don?t care 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 574 jun 20, 2011 table 14-8. relationship between register settings and pins (channel 3 of un it 0: uart1 reception) pin function se03 note1 md032 md031 txe03 rxe03 pm14 note2 p14 note2 operation mode rxd1/si10/sda10/intp4/ p14 note2 0 0 1 0 0 note3 note3 operation stop mode si10/sda10/intp4/p14 note2 1 0 1 0 1 1 uart1 reception note4, 5 rxd1 notes 1. the se0 register is a read-only status register which is set using the ss0 and st0 registers. 2. when channel 3 of unit 0 is set to uart1 reception, this pin becomes an rxd1 function pin. in this case, set channel 2 of unit 0 to operation stop mode or uart1 transmission (refer to table 14-7 ). when channel 2 of unit 0 is set to csi10 or iic10, this pi n cannot be used as an rxd1 function pin. in this case, set channel 3 of unit 0 to operation stop mode. 3. this pin can be set as a port function pin. 4. when using uart1 transmission and reception in a pair, set channel 2 of unit 0 to uart1 transmission (refer to table 14-7 ). 5. the smr02 register of channel 2 of unit 0 must also be set during uart1 reception. for details, refer to 14.5.2 (1) register setting . remark x: don?t care 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 575 jun 20, 2011 table 14-9. relationship between register settings and pins (channel 0 of unit 1: csi20, uart2 transmission, iic20) pin function se 10 note1 md 102 md 101 soe 10 so 10 cko 10 txe 10 rxe 10 pm 10 p10 pm 11 note2 p11 note2 pm 12 p12 operation mode sck20/ scl20/p10 si20/sda20/ rxd2/intp6/ p11 note2 so20/ txd2/ to02/p12 0 0 intp6/p11 0 1 rxd2/intp6/ p11 0 1 0 0 1 1 0 0 note3 note3 note3 note3 note3 note3 operation stop mode p10 intp6/p11 to02/p12 0 1 1 0 1 1 1 note3 note3 slave csi20 reception sck20 (input) si20 to02/p12 1 0/1 note4 1 1 0 1 note3 note3 0 1 slave csi20 transmission sck20 (input) intp6/p11 so20 1 0/1 note4 1 1 1 1 1 0 1 slave csi20 transmission/reception sck20 (input) si20 so20 0 1 0/1 note4 0 1 0 1 1 note3 note3 master csi20 reception sck20 (output) si20 to02/p12 1 0/1 note4 0/1 note4 1 0 0 1 note3 note3 0 1 master csi20 transmission sck20 (output) intp6/p11 so20 0 0 1 0/1 note4 0/1 note4 1 1 0 1 1 0 1 master csi20 transmission/reception sck20 (output) si20 so20 1 0 1 1 0/1 note4 1 1 0 note3 note3 note3 note3 0 1 uart2 transmission note5 p10 rxd2/intp6/ p11 txd2 0 0 1 0 0 0 0/1 note6 0/1 note6 0 1 0 1 0 1 note3 note3 iic20 start condition scl20 sda20 to02/p12 1 0/1 note4 0/1 note4 1 0 0 1 0 1 note3 note3 iic20 address field transmission scl20 sda20 to02/p12 1 0/1 note4 0/1 note4 1 0 0 1 0 1 note3 note3 iic20 data transmission scl20 sda20 to02/p12 1 1 0/1 note4 0/1 note4 0 1 0 1 0 1 note3 note3 iic20 data reception scl20 sda20 to02/p12 0 0 1 0 0 1 0 0 0/1 note7 0/1 note7 0 1 0 1 0 1 note3 note3 iic20 stop condition scl20 sda20 to02/p12 notes 1. the se1 register is a read-only status register which is set using the ss1 and st1 registers. 2. when channel 1 of unit 1 is set to uart2 reception, this pin becomes an rxd2 function pin (refer to table 14- 10 ). in this case, operation stop mode or uart2 transmission must be selected for channel 0 of unit 1. 3. this pin can be set as a port function pin. 4. this is 0 or 1, depending on the communication operation. for details, refer to 14.3 (12) serial output register m (som) . 5. when using uart2 transmission and reception in a pair, set channel 1 of unit 1 to uart2 reception (refer to table 14-10 ). 6. set the cko10 bit to 1 before a start condition is genera ted. clear the so10 bit from 1 to 0 when the start condition is generated. 7. set the cko10 bit to 1 before a stop condition is genera ted. clear the so10 bit from 0 to 1 when the stop condition is generated. remark x: don?t care 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 576 jun 20, 2011 table 14-10. relationship between register settings and pins (channel 1 of unit 1: uart2 reception) pin function se11 note1 md112 md111 txe11 rxe11 pm11 note2 p11 note2 operation mode si20/sda20/rxd2/ intp6/p11 note2 0 0 1 0 0 note3 note3 operation stop mode si20/sda20/intp6/p11 1 0 1 0 1 1 uart2 reception note4, 5 rxd2 notes 1. the se1 register is a read-only status register which is set using the ss1 and st1 registers. 2. when channel 1 of unit 1 is set to uart2 reception, this pin becomes an rxd2 function pin. in this case, set channel 0 of unit 1 to operation stop mode or uart2 transmission (refer to table 14-9 ). when channel 0 of unit 1 is set to csi20 or iic20, this pi n cannot be used as an rxd2 function pin. in this case, set channel 1 of unit 1 to operation stop mode. 3. this pin can be set as a port function pin. 4. when using uart2 transmission and reception in a pair, set channel 0 of unit 1 to uart2 transmission (refer to table 14-9 ). 5. the smr10 register of channel 0 of unit 1 must also be set during uart2 reception. for details, refer to 14.5.2 (1) register setting . remark x: don?t care 78k0r/lx3 chapter 14 serial array unit r01uh0004ej0501 rev.5.01 577 jun 20, 2011 table 14-11. relationship between register settings a nd pins (channel 2 of unit 1: uart3 transmission) pin function se12 note1 md122 md121 soe12 so12 txe12 rxe12 pm51 p51 operation mode txd3/seg52/p51 0 0 1 0 1 0 0 note2 note2 operation stop mode seg52/p51 1 0 1 1 0/1 note3 1 0 0 1 uart3 transmission note4 txd3 notes 1. the se1 register is a read-only status register which is set using the ss1 and st1 registers. 2. this pin can be set as a port function pin. 3. this is 0 or 1, depending on the communication operation. for details, refer to 14.3 (12) serial output register m (som) . 4. when using uart3 transmission and reception in a pair, set channel 3 of unit 1 to uart3 reception (refer to table 14-12 ). remark x: don?t care table 14-12. relationship between register settings and pins (channel 3 of unit 1: uart3 reception) pin function se13 note1 md132 md131 txe13 rxe13 pm50 p50 operation mode rxd3/seg53/p50 0 0 1 0 0 note2 note2 operation stop mode seg53/p50 1 0 1 0 1 1 uart3 reception note3, 4 rxd3 notes 1. the se1 register is a read-only status register which is set using the ss1 and st1 registers. 2. this pin can be set as a port function pin. 3. when using uart3 transmission and reception in a pair, set channel 2 of unit 1 to uart3 transmission (refer to table 14-11 ). 4. the smr12 register of channel 2 of unit 1 must also be set during uart3 reception. for details, refer to 14.5.2 (1) register setting . remark x: don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 578 jun 20, 2011 chapter 15 serial interface iica 78k0r/lf3 78k0r/lg3 78k0r/lh3 item 80 pins 100 pins 128 pins serial interface iica ? 1 ch 15.1 functions of serial interface iica serial interface iica has the following three 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 generated ?start condition?, ?address?, ?transfer direction specificatio n?, ?data?, and ?stop condition? data to the slave device, via the serial data bus. the slave device automatically detects thes e received status and data by hardware. this function can simplify the part of application program that controls the i 2 c bus. since the scl0 and sda0 pins are used for open drain outputs, iica requires pull-up resistors for the serial clock line and the serial data bus line. (3) wakeup mode the stop mode can be released by generating an interrupt request signal (intiica) when an extension code from the master device or a local address has been received while in stop mode. this can be set by using the wup bit of iica control register 1 (iicctl1). figure 15-1 shows a block diagram of serial interface iica. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 579 jun 20, 2011 figure 15-1. block diagram of serial interface iica iice dq dfc sda0/ p61 scl0/ p60 intiica iicctl0.stt, spt iics.msts, exc, coi iics.msts, exc, coi f clk lrel wrel spie wtim acke stt spt msts ald exc coi trc ackd std spd stcf iicbsy stcen iicrsv wup cld dad dfc smc pm60 internal bus iica status register (iics) iica control register 0 (iicctl0) slave address register (sva) noise eliminator match signal match signal iica shift register (iica) so latch set clear iicwl trc dfc data hold time correction circuit start condition generator stop condition generator ack generator wakeup controller n-ch open- drain output pm61 noise eliminator bus status detector ack detector stop condition detector serial clock counter interrupt request signal generator serial clock controller serial clock wait controller start condition detector internal bus iica flag register (iicf) iica control register 1 (iicctl1) n-ch open- drain output output latch (p60) output latch (p61) wup sub-circuit for standby filter filter output control iica shift register (iica) counter iica low-level width setting register (iicwl) iica high-level width setting register (iicwh) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 580 jun 20, 2011 figure 15-2 shows a serial bus configuration example. figure 15-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 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 581 jun 20, 2011 15.2 configuration of serial interface iica serial interface iica includes the following hardware. table 15-1. configuration of serial interface iica item configuration registers iica shift register (iica) slave address register (sva) control registers peripheral enable register 0 (per0) iica control register 0 (iicctl0) iica status register (iics) iica flag register (iicf) iica control register 1 (iicctl1) iica low-level width setting register (iicwl) iica high-level width setting register (iicwh) port mode register 6 (pm6) port register 6 (p6) (1) iica shift register (iica) iica is used to convert 8-bit serial data to 8-bit parallel data and vice versa in synchronization with the serial clock. iica can be used for both transmission and reception. the actual transmit and receive operations can be contro lled by writing and reading operations to iica. cancel the wait state and start data transfer by writing data to iica during the wait period. iica can be set by an 8-bit memory manipulation instruction. reset signal generation clears iica to 00h. figure 15-3. format of iica shift register (iica) symbol iica address: fff50h after reset: 00h r/w 76543210 cautions 1. do not write data to iica during data transfer. 2. write or read iica only during the wait pe riod. accessing iica in a communication state other than during the wait period is prohibited. when the device serves as the master, however, iica can be written only once after the comm unication trigger bit (stt) is set to 1. 3. when communication is reserved, write data to iica after the interrupt triggered by a stop condition is detected. (2) slave address register (sva) this register stores seven bits of local addresse s {a6, a5, a4, a3, a2, a1, a0} when in slave mode. sva can be set by an 8-bit memory manipulation instruction. however, rewriting to this register is prohibited wh ile std = 1 (while the start condition is detected). reset signal generation clears sva to 00h. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 582 jun 20, 2011 figure 15-4. format of slave address register (sva) symbol sva address: f0234h after reset: 00h r/w 76543210 0 note a0 a1 a2 a3 a4 a5 a6 note bit 0 is fixed to 0. (3) so latch the so latch is used to retain the sda0 pin?s output level. (4) wakeup controller this circuit generates an interrupt request (intiica) when the address received by this register matches the address value set to the slave address register (sva) or when an extension code is received. (5) serial clock counter this counter counts the serial clocks that are output or in put during transmit/receive operations and is used to verify that 8-bit data was transmitted or received. (6) interrupt request signal generator this circuit controls the generation of interrupt request signals (intiica). 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 wtim bit) ? interrupt request generated when a stop co ndition is detected (set by spie bit) remark wtim bit: bit 3 of iica control register 0 (iicctl0) spie bit: bit 4 of iica control register 0 (iicctl0) (7) serial clock controller in master mode, this circuit generates the clock output via the scl0 pin from a sampling clock. (8) serial clock wait controller this circuit controls the wait timing. (9) ack generator, stop condition detector, start condition detector, and ack detector these circuits generate and detect each status. (10) data hold time correction circuit this circuit generates the hold time for data corre sponding to the falling edge of the serial clock. (11) start condition generator this circuit generates a start condition when the stt bit is set to 1. however, in the communication reservat ion disabled status (iicrsv bit = 1) , when the bus is not released (iicbsy bit = 1), start condition requests are ignor ed and the stcf bit is set to 1. (12) stop condition generator this circuit generates a stop condition when the spt bit is set to 1. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 583 jun 20, 2011 (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 stt bit: bit 1 of iica control register 0 (iicctl0) spt bit: bit 0 of iica control register 0 (iicctl0) iicrsv bit: bit 0 of iica flag register (iicf) iicbsy bit: bit 6 of iica flag register (iicf) stcf bit: bit 7 of iica flag register (iicf) stcen bit: bit 1 of iica flag register (iicf) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 584 jun 20, 2011 15.3 registers controlling serial interface iica serial interface iica is controlled by the following eight registers. ? peripheral enable register 0 (per0) ? iica control register 0 (iicctl0) ? iica flag register (iicf) ? iica status register (iics) ? iica control register 1 (iicctl1) ? iica low-level width setting register (iicwl) ? iica high-level width se tting register (iicwh) ? port mode register 6 (pm6) ? port register 6 (p6) (1) peripheral enable register 0 (per0) this register is used to enable or disable supplying t he clock to the peripheral hardware. clock supply to a hardware macro that is not used is stopped in or der to reduce the power consumption and noise. when serial interface iica is used, be sure to set bit 4 (iicaen) of this register to 1. per0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 15-5. format of peripheral enable register 0 (per0) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> per0 rtcen dacen adcen iicaen note sau1en sau0en tau1en tau0en iicaen control of serial interface iica input clock 0 stops supply of input clock. ? sfr used by serial interface iica cannot be written. ? serial interface iica is in the reset status. 1 supplies input clock. ? sfr used by serial interface iica can be read/written. note 78k0r/lg3, 78k0r/lh3 only caution when setting serial interface iica, be sure to set iicaen to 1 firs t. if iicaen = 0, writing to a control register of serial interface iica is ignor ed, and, even if the register is read, only the default value is read. (2) iica control register 0 (iicctl0) this register is used to enable/stop i 2 c operations, set wait timing, and set other i 2 c operations. iicctl0 can be set by a 1-bit or 8-bit memory manipulat ion instruction. however, set the spie, wtim, and acke bits while iice bit = 0 or during the wait period. these bi ts can be set at the same ti me when the iice bit is set from ?0? to ?1?. reset signal generation clea rs this register to 00h. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 585 jun 20, 2011 figure 15-6. format of iica cont rol register 0 (iicctl0) (1/4) address: f0230h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> iicctl0 iice lrel wrel spie wtim acke stt spt iice i 2 c operation enable 0 stop operation. reset the iica status register (iics) note 1 . stop internal operation. 1 enable operation. be sure to set this bit (1) while the scl0 and sda0 lines are at high level. condition for clearing (iice = 0) condition for setting (iice = 1) ? cleared by instruction ? reset ? set by instruction lrel notes 2,3 exit from communications 0 normal operation 1 this exits from the current communications and sets standby mode. this setting is automatically cleared to 0 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 iica control register 0 (iicctl0) and iica status register (iics) are cleared to 0. ? stt ? spt ? msts ? exc ? coi ? trc ? ackd ? std the standby mode following exit from communications rema ins in effect until the following communications 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 (lrel = 0) condition for setting (lrel = 1) ? automatically cleared after execution ? reset ? set by instruction wrel notes 2,3 wait cancellation 0 do not cancel wait 1 cancel wait. this setting is automatic ally cleared after wait is canceled. when wrel is set (wait canceled) during the wait period at the ninth clock pulse in t he transmission status (trc = 1), the sda0 line goes into the high impedance state (trc = 0). condition for clearing (wrel = 0) condition for setting (wrel = 1) ? automatically cleared after execution ? reset ? set by instruction notes 1. the iics register, the stcf and iicbsy bits of the iicf register, and the cld and dad bits of the iicctl1 register are reset. 2. the signal of this bit is invalid while iice is 0. 3. when the lrel and wrel bits are read, 0 is always read. caution if the operation of i 2 c is enabled (iice = 1) when the scl0 line is at high level, the sda0 line is at low level, and dfc of the iicctl1 register is 1, a start condition will be inadvertently detected immediately. immediately after enabling i 2 c to operate (iice = 1), set lrel (1) by using a 1-bit memory manipulation instruction. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 586 jun 20, 2011 figure 15-6. format of iica cont rol register 0 (iicctl0) (2/4) spie note 1 enable/disable generation of interrupt request when stop condition is detected 0 disable 1 enable if wup of the iicctl1 register is 1, no stop condition interrupt will be generated even if spie = 1. condition for clearing (spie = 0) condition for setting (spie = 1) ? cleared by instruction ? reset ? set by instruction wtim note 1 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 clock during address transfer independently of the setting of this bit. the setting of this bit is valid when the address tr ansfer is completed. when in master mode, a wait is inserted at the falling edge of the ninth clock during address tr ansfers. 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 (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 (wtim = 0) condition for setting (wtim = 1) ? cleared by instruction ? reset ? set by instruction acke notes 1, 2 acknowledgment control 0 disable acknowledgment. 1 enable acknowledgment. during t he ninth clock period, the sda0 line is set to low level. condition for clearing (acke = 0) condition for setting (acke = 1) ? cleared by instruction ? reset ? set by instruction notes 1. the signal of this bit is invalid while iice is 0. set this bit during that period. 2. the set value is invalid during address transfer and if the code is not an extension code. when the device serves as a slave and the addresses match, an acknowledgment is generated regardless of the set value. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 587 jun 20, 2011 figure 15-6. format of iica cont rol register 0 (iicctl0) (3/4) stt note start condition trigger 0 do not generate a start condition. 1 when bus is released (in standby state, when iicbsy = 0): if this bit is set (1), a start conditi on is generated (startup as the master). when a third party is communicating: ? when communication reservation function is enabled (iicrsv = 0) functions as the start condition reservation flag. when set to 1, automatically generates a start condition after the bus is released. ? when communication reservation function is disabled (iicrsv = 1) even if this bit is set (1), the stt bit is cleared and the stt clear flag (stcf) is set (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 acke has been cleared to 0 and slave ha s been notified of final reception. ? for master transmission: a start condition cannot be generated normally during the acknowledge period. set to 1 during the wait period that follows output of the ninth clock. ? cannot be set to 1 at the same time as spt. ? setting stt to 1 and then setting it again before it is cleared to 0 is prohibited. condition for clearing (stt = 0) condition for setting (stt = 1) ? cleared by setting stt to 1 while communication reservation is prohibited. ? cleared by loss in arbitration ? cleared after start condition is generated by master device ? cleared by lrel = 1 (exit from communications) ? when iice = 0 (operation stop) ? reset ? set by instruction note the signal of this bit is invalid while iice0 is 0. remarks 1. bit 1 (stt) becomes 0 when it is read after data setting. 2. iicrsv: bit 0 of iic flag register (iicf) stcf: bit 7 of iic flag register (iicf) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 588 jun 20, 2011 figure 15-6. format of iica cont rol register 0 (iicctl0) (4/4) spt stop condition trigger 0 stop condition is not generated. 1 stop condition is generated (terminati on of master device?s transfer). 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 acke has been cleared to 0 and slave has been notified of final reception. ? for master transmission: a st op condition cannot be generated normally during the acknowledge period. therefore, set it during the wait period that follows output of the ninth clock. ? cannot be set to 1 at the same time as stt. ? spt can be set to 1 only when in master mode. ? when wtim has been cleared to 0, if spt is set to 1 duri ng the wait period that follows output of eight clocks, note that a stop condition will be generated during the high-level peri od of the ninth clock. wtim should be changed from 0 to 1 during the wait period following the output of eight clocks, and spt should be set to 1 during the wait period that follows the output of the ninth clock. ? setting spt to 1 and then setting it again before it is cleared to 0 is prohibited. condition for clearing (spt = 0) condition for setting (spt = 1) ? cleared by loss in arbitration ? automatically cleared after stop condition is detected ? cleared by lrel = 1 (exit from communications) ? when iice = 0 (operation stop) ? reset ? set by instruction caution when bit 3 (trc) of the iica status register (iics) is set to 1, wrel is set to 1 during the ninth clock and wait is canceled, after which trc is cleared and the sda0 line is set to high impedance. release the wait performed while the trc bit is 1 (transmission status) by writing to the iica shift register. remark bit 0 (spt) becomes 0 when it is read after data setting. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 589 jun 20, 2011 (3) iica status register (iics) this register indicates the status of i 2 c. iics is read by a 1-bit or 8-bit memory manipulation in struction only when stt = 1 and during the wait period. reset signal generation clea rs this register to 00h. caution reading the iics register while the address ma tch wakeup function is enabled (wup = 1) in stop mode is prohibited. when the wup bit is chan ged from 1 to 0 (wakeup operation is stopped), regardless of the intiica interrupt request, the ch ange in status is not reflected until the next start condition or stop condition is detected. to use the wakeup function, therefore, enable (spie = 1) the interrupt generated by detecting a stop condition and read the iics register after the interrupt has been detected. remark stt: bit 1 of iica control register 0 (iicctl0) wup: bit 7 of iica control register 1 (iicctl1) figure 15-7. format of iica status register (iics) (1/3) address: fff51h after reset: 00h r symbol <7> <6> <5> <4> <3> <2> <1> <0> iics msts ald exc coi trc ackd std spd msts master status check flag 0 slave device status or communication standby status 1 master device communication status condition for clearing (msts = 0) condition for setting (msts = 1) ? when a stop condition is detected ? when ald = 1 (arbitration loss) ? cleared by lrel = 1 (exit from communications) ? when iice changes from 1 to 0 (operation stop) ? reset ? when a start condition is generated ald 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?. msts is cleared. condition for clearing (ald = 0) condition for setting (ald = 1) ? automatically cleared after iics is read note ? when iice changes from 1 to 0 (operation stop) ? reset ? when the arbitration result is a ?loss?. exc detection of extension code reception 0 extension code was not received. 1 extension code was received. condition for clearing (exc = 0) condition for setting (exc = 1) ? when a start condition is detected ? when a stop condition is detected ? cleared by lrel = 1 (exit from communications) ? when iice 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). note this register is also cleared when a 1-bit memory manipulation instruction is ex ecuted for bits other than iics. therefore, when using the ald bit, read the da ta of this bit before the data of the other bits. remark lrel: bit 6 of iica control register 0 (iicctl0) iice: bit 7 of iica control register 0 (iicctl0) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 590 jun 20, 2011 figure 15-7. format of iica status register (iics) (2/3) coi detection of matching addresses 0 addresses do not match. 1 addresses match. condition for clearing (coi = 0) condition for setting (coi = 1) ? when a start condition is detected ? when a stop condition is detected ? cleared by lrel = 1 (exit from communications) ? when iice changes from 1 to 0 (operation stop) ? reset ? when the received address matches the local address (slave address register (sva)) (set at the rising edge of the eighth clock). trc 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 enabled for output to the sda0 line (valid starting at the falling edge of the first byte?s ninth clock). condition for clearing (trc = 0) condition for setting (trc = 1) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 591 jun 20, 2011 figure 15-7. format of iica status register (iics) (3/3) ackd detection of acknowledge (ack) 0 acknowledge was not detected. 1 acknowledge was detected. condition for clearing (ackd = 0) condition for setting (ackd = 1) ? when a stop condition is detected ? at the rising edge of the next byte?s first clock ? cleared by lrel = 1 (exit from communications) ? when iice 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 std 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 (std = 0) condition for setting (std = 1) ? when a stop condition is detected ? at the rising edge of the next byte?s first clock following address transfer ? cleared by lrel = 1 (exit from communications) ? when iice changes from 1 to 0 (operation stop) ? reset ? when a start condition is detected spd detection of stop condition 0 stop condition was not detected. 1 stop condition was detected. the master device ?s communication is terminated and the bus is released. condition for clearing (spd = 0) condition for setting (spd = 1) ? at the rising edge of the address transfer byte?s first clock following setting of th is bit and detection of a start condition ? when iice changes from 1 to 0 (operation stop) ? reset ? when a stop condition is detected remark lrel: bit 6 of iica control register 0 (iicctl0) iice: bit 7 of iica control register 0 (iicctl0) (4) iica flag register (iicf) this register sets the operation mode of i 2 c and indicates the status of the i 2 c bus. iicf can be set by a 1-bit or 8-bit memory manipulation instruction. however, the stcf and iicbsy bits are read- only. the iicrsv bit can be used to enable/disabl e the communication reservation function. stcen can be used to set the initial value of the iicbsy bit. iicrsv and stcen can be written only when the operation of i 2 c is disabled (bit 7 (iice) of iica control register 0 (iicctl0) = 0). when operation is en abled, the iicf register can be read. reset signal generation clea rs this register to 00h. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 592 jun 20, 2011 figure 15-8. format of iica flag register (iicf) <7> stcf condition for clearing (stcf = 0) ? cleared by stt = 1 ? when iice = 0 (operation stop) ? reset condition for setting (stcf = 1) ? generating start condition unsuccessful and stt cleared to 0 when communication reservation is disabled (iicrsv = 1). stcf 0 1 generate start condition start condition generation unsuccessful: clear stt flag stt clear flag iicf symbol <6> iicbsy 5 0 4 0 3 0 2 0 <1> stcen <0> iicrsv address: fff52h after reset: 00h r/w note condition for clearing (iicbsy = 0) ? detection of stop condition ? when iice = 0 (operation stop) ? reset condition for setting (iicbsy = 1) ? detection of start condition ? setting of iice when stcen = 0 iicbsy 0 1 bus release status (communication initial status when stcen = 1) bus communication status (communication initial status when stcen = 0) i 2 c bus status flag condition for clearing (stcen = 0) ? cleared by instruction ? detection of start condition ? reset condition for setting (stcen = 1) ? set by instruction stcen 0 1 after operation is enabled (iice = 1), enable generation of a start condition upon detection of a stop condition. after operation is enabled (iice = 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. cautions 1. write to stcen only when the operation is stopped (iice = 0). 2. as the bus release status (iicbsy = 0) is recognized regardless of the actual bus status when stcen = 1, when generating the first start condition (stt = 1), it is necessary to verify that no third party communications are in progress in order to prevent such communications from being destroyed. 3. write to iicrsv only when the operation is stopped (iice = 0). remark stt: bit 1 of iica cont rol register 0 (iicctl0) iice: bit 7 of iica control register 0 (iicctl0) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 593 jun 20, 2011 (5) iica control register 1 (iicctl1) this register is used to set the operation mode of i 2 c and detect the statuses of the scl0 and sda0 pins. iicctl1 can be set by a 1-bit or 8-bit memory manipulatio n instruction. however, the cld and dad bits are read- only. set the iicctl1 register, except t he wup bit, while operation of i 2 c is disabled (bit 7 (iice) of iica control register 0 (iicctl0) is 0). reset signal generation clea rs this register to 00h. figure 15-9. format of iica cont rol register 1 (iicctl1) (1/2) address: f0231h after reset: 00h r/w note 1 symbol 7 6 <5> <4> <3> <2> 1 0 iicctl1 wup 0 cld dad smc dfc 0 0 wup control of address match wakeup 0 stops operation of address match wakeup function in stop mode. 1 enables operation of address match wakeup function in stop mode. to shift to stop mode when wup = 1, execute the stop instruction at least three clocks after setting (1) the wup bit (see figure 15-22 flow when setting wup = 1 ). clear (0) the wup bit after the address has matched or an extension code has been received. the subsequent communication can be entered by the cl earing (0) wup bit. (the wait must be released and transmit data must be written after the wup bit has been cleared (0).) the interrupt timing when the address has matched or when an extension code has been received, while wup = 1, is identical to the interrupt timing when wup = 0. (a delay of the difference of sampling by the clock will occur.) furthermore, when wup = 1, a stop condition interr upt is not generated even if the spie bit is set to 1. when wup = 0 is set by a source other than an interrupt from serial interface iica, operation as the master device cannot be performed until the subsequent start co ndition or stop condition is detected. do not output a start condition by setting (1) the stt bit, without waiti ng for the detection of the subsequent start condition or stop condition. condition for clearing (w up = 0) condition for setting (wup = 1) ? cleared by instruction (after address match or extension code reception) ? set by instruction (when the msts, exc, and coi bits are ?0?, and the std bit also ?0? (communication not entered)) note 2 notes 1. bits 4 and 5 are read-only. 2. the status of the iica status register (iics) must be che cked and the wup bit must be set during the period shown below. scl0 <1> <2> sda0 a6 a5 a4 a3 a2 a1 a0 the maximum time from reading iics to setting wup is the period from <1> to <2>. check the iics operation status and set wup during this period. r/w 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 594 jun 20, 2011 figure 15-9. format of iica cont rol register 1 (iicctl1) (2/2) cld detection of scl0 pin level (valid only when iice = 1) 0 the scl0 pin was detected at low level. 1 the scl0 pin was detected at high level. condition for clearing (cld = 0) condition for setting (cld = 1) ? when the scl0 pin is at low level ? when iice = 0 (operation stop) ? reset ? when the scl0 pin is at high level dad detection of sda0 pin level (valid only when iice = 1) 0 the sda0 pin was detected at low level. 1 the sda0 pin was detected at high level. condition for clearing (dad = 0) condition for setting (dad = 1) ? when the sda0 pin is at low level ? when iice = 0 (operation stop) ? reset ? when the sda0 pin is at high level smc operation mode switching 0 operates in standard mode. 1 operates in fast mode. dfc digital filter operation control 0 digital filter off. 1 digital filter on. digital filter can be used only in fast mode. in fast mode, the transfer clock does not vary, rega rdless of the dfc bit being set (1) or cleared (0). the digital filter is used for noise elimination in fast mode. remark iice: bit 7 of iica control register 0 (iicctl0) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 595 jun 20, 2011 (6) iica low-level width setting register (iicwl) this register is used to set the low-level width of the scl0 pin signal that is output by serial interface iica. the iicwl register can be set by an 8- bit memory manipulation instruction. set the iicwl register while operation of i 2 c is disabled (bit 7 (iice) of iica control register 0 (iicctl0) is 0). reset signal generation sets this register to ffh. figure 15-10. format of iica low-level width setting register (iicwl) address: f0232h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 iicwl (7) iica high-level width setting register (iicwh) this register is used to set the high-level width of the scl0 pin signal that is output by serial interface iica. the iicwh register can be set by an 8- bit memory manipulation instruction. set the iicwh register while operation of i 2 c is disabled (bit 7 (iice) of iica control register 0 (iicctl0) is 0). reset signal generation sets this register to ffh. figure 15-11. format of iica high-level width setting register (iicwh) address: f0233h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 iicwh remark for how to set the transfer clock by using the iicwl and iicwh registers, see 15.4.2 setting transfer clock by using iicwl and iicwh registers . (8) port mode register 6 (pm6) this register sets the input/output of port 6 in 1-bit units. when using the p60/scl0 pin as cloc k i/o and the p61/sda0 pin as serial data i/o, clear pm60 and pm61, and the output latches of p60 and p61 to 0. set iice (bit 7 of iica control register 0 (iicctl0)) to 1 before setting the output mode because the p60/scl0 and p61/sda0 pins output a low level (fixed) when iice is 0. pm6 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation se ts this register to ffh. figure 15-12. format of port mode register 6 (pm6) pm60 pm61 1 1 1 1 1 1 p6n pin i/o mode selection (n = 0, 1) output mode (output buffer on) input mode (output buffer off) pm6n 0 1 0 1 2 3 4 5 6 7 pm6 address: fff26h after reset: ffh r/w symbol 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 596 jun 20, 2011 15.4 i 2 c bus mode functions 15.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 da ta bus line are n-ch open-drain outputs, an external pull-up resistor is required. figure 15-13. 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 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 597 jun 20, 2011 15.4.2 setting transfer clock by using iicwl and iicwh registers (1) setting transfer clock on master side transfer clock = f clk iicwl + iicwh + f clk (t r + t f ) at this time, the optimal setting values of iicwl and iicwh are as follows. (the fractional parts of all setting values are rounded up.) ? when the fast mode iicwl = 0.52 transfer clock f clk iicwh = ( 0.48 transfer clock ? t r ? t f ) f clk ? when the standard mode iicwl = 0.47 transfer clock f clk iicwh = ( 0.53 transfer clock ? t r ? t f ) f clk (2) setting iicwl and iicwh on slave side (the fractional parts of all setting values are truncated.) ? when the fast mode iicwl = 1.3 s f clk iicwh = (1.2 s ? t r ? t f ) f clk ? when the standard mode iicwl = 4.7 s f clk iicwh = (5.3 s ? t r ? t f ) f clk caution note the minimum f clk operation frequency when setting the transfer clock. the minimum f clk operation frequency for serial interface ii ca is determined according to the mode. fast mode: f clk = 3.5 mhz (min.) standard mode: f clk = 1 mhz (min.) remarks 1. calculate the rise time (t r ) and fall time (t f ) of the sda0 and scl0 signals separately, because they differ depending on the pull-up resistance and wire load. 2. iicwl: iica low-level width setting register iicwh: iica high-level width setting register t f : sda0 and scl0 signal falling times t r : sda0 and scl0 signal rising times f clk : cpu/peripheral hardware clock frequency 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 598 jun 20, 2011 15.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 15-14 shows the transfer timing for the ?start conditi on?, ?address?, ?data?, and ?stop condition? output via the i 2 c bus?s serial data bus. figure 15-14. i 2 c bus serial data transfer timing scl0 sda0 start condition address r/w ack data 1-7 8 9 1-8 ack data ack stop condition 9 1-8 9 the master device generates the start c ondition, slave address, and stop condition. the acknowledge (ack) can be generated 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. 15.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 signals that the master device generates to the slave device when starting a serial transfer. when the device is us ed as a slave, start conditions can be detected. figure 15-15. start conditions scl0 sda0 h a start condition is output when bit 1 (stt) of iica control re gister 0 (iicctl0) is set (1) after a stop condition has been detected (spd: bit 0 of the iica status register (iics) = 1). when a start condition is detected, bit 1 (std) of iics is set (1). 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 599 jun 20, 2011 15.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. theref ore, 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 che cks whether or not the 7-bit address data matches the data values stored in the slave address regist er (sva). if the address data matches the sva values, the slave device is selected and communicates with the master device unt il the master device generat es a start condition or stop condition. figure 15-16. address scl0 sda0 intiica 123456789 a6 a5 a4 a3 a2 a1 a0 r/w address note note intiica is not issued if data other than a local address or extension code is received during slave device operation. addresses are output when a total of 8 bi ts consisting of the slave address and the transfer direction described in 15.5.3 transfer di rection specification are written to the iica shift register (iica). the received addresses are written to iica. the slave address is assigned to the higher 7 bits of iica. 15.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 spec ification 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 indicate s that the master device is receiving data from a slave device. figure 15-17. transfer direction specification scl0 sda0 intiica 123456789 a6 a5 a4 a3 a2 a1 a0 r/w transfer direction specification note note intiica is not issued if data other than a local address or extension code is received during slave device operation. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 600 jun 20, 2011 15.5.4 acknowledge (ack) ack is used to check the status of serial data at the transmission and reception sides. the reception side returns ack each time it has received 8-bit data. the transmission side usually receives ack after transmitting 8- bit data. when ack is returned from the reception side, it is assumed that reception has been correctly performed a nd processing is continued. whether ack has been detected can be checked by using bit 2 (ackd) of the iica status register (iics). when the master receives the last data item, it does not return ack and instead ge nerates a stop condition. if a slave does not return ack after receiving data, the master outputs a stop condition or restart condit ion and stops transmission. if ack is not returned, the possible causes are as follows. <1> reception was not performed normally. <2> the final data item was received. <3> the reception side specified by the address does not exist. to generate ack, the reception side makes the sda0 line low at the ninth clock (indicating normal reception). automatic generation of ack is enabled by setting bit 2 (acke) of iica control register 0 (ii cctl0) to 1. bit 3 (trc) of the iics register is set by the data of the eighth bit that follows 7-bit address information. usually, set acke to 1 for reception (trc = 0). if a slave can receive no more data during reception (trc = 0) or does not require the next data item, then the slave must inform the master, by clearing acke to 0, that it will not receive any more data. when the master does not require the next data item during reception (trc = 0), it must clear acke to 0 so that ack is not generated. in this way, the master informs a slave at the transmission side that it does not require any more data (transmission will be stopped). figure 15-18. ack scl0 sda0 123456789 a6 a5 a4 a3 a2 a1 a0 r/w ack when the local address is received, ac k is automatically generated, regardle ss of the value of acke. when an address other than that of t he local address is received, ack is not generated (nack). when an extension code is received, ack is generated if acke is set to 1 in advance. how ack is generated when data is received differs as follows depending on the setting of the wait timing. ? when 8-clock wait state is selected (b it 3 (wtim) of iicctl0 register = 0): by setting acke to 1 before releasing the wait state, ack is generated at the falling edge of the eighth clock of the scl0 pin. ? when 9-clock wait state is selected (b it 3 (wtim) of iicctl0 register = 1): ack is generated by setting acke to 1 in advance. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 601 jun 20, 2011 15.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 t he master device generates to the slave device when serial transfer has been completed. when the device is used as a slave, stop conditions can be detected. figure 15-19. stop condition scl0 sda0 h a stop condition is generated when bit 0 (spt ) of iica control register 0 (iicctl0) is set to 1. when the stop condition is detected, bit 0 (spd) of t he iica status register (iics) is set to 1 and intiica is generated when bit 4 (spie) of iicctl0 is set to 1. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 602 jun 20, 2011 15.5.6 wait the wait is used to notify the communicati on partner that a device (mast er or slave) is preparing to transmit or receive data (i.e., is in a wait state). setting the scl0 pin to low level notifie s the communication partner of the wait state. when wait state has been canceled for both the master and slave devices, the next data transfer can begin. figure 15-20. wait (1/2) (1) when master device has a nine-clock wait and slave device has an eight-clock wait (master transmits, slave receives, and acke = 1) master iica scl0 slave iica scl0 acke 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 iica data write (cancel wait) wait after output of eighth clock wait from slave wait from master ffh is written to iica or wrel is set to 1 678 9 123 d2 d1 d0 d7 d6 d5 ack h 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 603 jun 20, 2011 figure 15-20. wait (2/2) (2) when master and slave devices both have a nine-clock wait (master transmits, slave receives, and acke = 1) master iica scl0 slave iica scl0 acke transfer lines scl0 sda0 h 6789 1 23 master and slave both wait after output of ninth clock wait from master and slave wait from slave iica data write (cancel wait) ffh is written to iica or wrel is set to 1 6789 123 d2 d1 d0 ack d7 d6 d5 generate according to previously set acke value remark acke: bit 2 of iica control register 0 (iicctl0) wrel: bit 5 of iica control register 0 (iicctl0) a wait may be automatically generated depending on the setti ng of bit 3 (wtim) of iica control register 0 (iicctl0). normally, the receiving side cancels the wait state when bit 5 (wrel) of the iicctl0 register is set to 1 or when ffh is written to the iica shift register (iica), and the transmitting side cancels the wait state w hen data is written to the iica register. ? by setting bit 1 (stt) of iicctl0 to 1 ? by setting bit 0 (spt) of iicctl0 to 1 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 604 jun 20, 2011 15.5.7 canceling wait the i 2 c usually cancels a wait stat e by the following processing. ? writing data to iica shift register (iica) ? setting bit 5 (wrel) of iica control register 0 (iicctl0) (canceling wait) ? setting bit 1 (stt) of iicctl0 regi ster (generating start condition) note ? setting bit 0 (spt) of iicctl0 regi ster (generating stop condition) note note master only when the above wait canceling processing is executed, the i 2 c cancels the wait state and communication is resumed. to cancel a wait state and transmit data (incl uding addresses), write the data to iica. to receive data after canceling a wait state, or to comple te data transmission, set bit 5 (wrel) of iica control register 0 (iicctl0) to 1. to generate a restart condition after canceling a wait state, set bit 1 (stt) of iicctl0 to 1. to generate a stop condition after canceling a wa it state, set bit 0 ( spt) of iicctl0 to 1. execute the canceling processing only once for one wait state. if, for example, data is written to iica after canceling a wait state by setting wrel to 1, an incorrect value may be output to sda0 because the timing for changing the sd a0 line conflicts with the timing for writing iica. in addition to the above, communication is stopped if iice is cleared to 0 when communication has been aborted, so that the wait stat e can be canceled. if the i 2 c bus has deadlocked due to noise, processing is saved from communication by setting bit 6 (lrel) of iicctl0, so that the wait st ate can be canceled. caution if a processing to cancel a wait state executed when wup (bit 7 of iica control register 1 (iicctl1)) = 1, the wait state will not be canceled. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 605 jun 20, 2011 15.5.8 interrupt request (intiica) generation timing and wait control the setting of bit 3 (wtim) of iica control register 0 (iic ctl0) determines the timing by which intiica is generated and the corresponding wait control, as shown in table 15-2. table 15-2. intiica generation timing and wait control during slave device operation during master device operation wtim 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 intiica signal and wait period o ccurs at the falling edge of the ninth clock only when there is a match with the address set to the slave address register (sva). at this point, ack is generated regardless of the value set to iicctl0?s bit 2 (acke). for a slave device that has received an extension code, intiica occu rs at the falling edge of the eighth clock. however, if the address does not match after rest art, intiica 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 the slave address register (sva) and extension code is not received, neither intiica nor a wait occurs. remark the numbers in the table indicate t he number of the serial clock?s clock signals. interrupt requests and wait control are both synchronized with the 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 wtim bit. ? master device operation: interrupt and wait timing oc cur at the falling edge of the ninth clock regardless of the wtim bit. (2) during data reception ? master/slave device operation: interrupt and wait timing are determined according to the wtim bit. (3) during data transmission ? master/slave device operation: interrupt and wait timing are determined according to the wtim bit. (4) wait cancellation method the four wait cancellation methods are as follows. ? writing data to iica shift register (iica) ? setting bit 5 (wrel) of iica control register 0 (iicctl0) (canceling wait) ? setting bit 1 (stt) of iicctl0 regi ster (generating start condition) note ? setting bit 0 (spt) of iicctl0 regi ster (generating stop condition) note note master only. when an 8-clock wait has been selected (wtim = 0) , the presence/absence of ack generation must be determined prior to wait cancellation. (5) stop condition detection intiica is generated when a stop condit ion is detected (only when spie = 1). 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 606 jun 20, 2011 15.5.9 address match detection method in i 2 c bus mode, the master device can se lect a particular slave device by trans mitting the corresponding slave address. address match can be detected automatically by hardware. an interrupt request (intiica) occurs when the address set to the slave address register (sva) matches the slave address sent by the master device, or when an extension code has been received. 15.5.10 error detection in i 2 c bus mode, the status of t he serial data bus (sda0) during data transmissi on is captured by the iica shift register (iica) of the transmitting device, so the iica data prior to transmission can be compared with the transmitted iica data to enable detection of transmission errors. a transmission erro r is judged as having occurred when the compared data values do not match. 15.5.11 extension code (1) when the higher 4 bits of the receive address are eit her ?0000? or ?1111?, the extension code reception flag (exc) is set to 1 for extension code reception and an interrupt request (intiica) is issued at the falling edge of the eighth clock. the local address stored in the slav e address register (sva) is not affected. (2) the settings below are specified if 11110xx0 is transferre d from the master by using a 10-bit address transfer when the sva register is set to 11110xx0. note that intiica occurs at the falling edge of the eighth clock. ? higher four bits of data match: exc = 1 ? seven bits of data match: coi = 1 remark exc: bit 5 of iica status register (iics) coi: bit 4 of iica status register (iics) (3) since the processing after the interrupt request occurs di ffers according to the data that follows the extension code, such processing is performed by software. if the extension code is received while a slave device is operating, then the slave device is participating in communication even if its address does not match. for example, after the extension code is received, if you do not wish to operate the target device as a slave device, set bit 6 (lrel) of the iica control re gister 0 (iicctl0) to 1 to set the standby mode for the next communication operation. table 15-3. bit definitions of main extension code slave address r/w bit description 0 0 0 0 0 0 0 0 general call address 1 1 1 1 0 x x 0 10-bit slave address sp ecification (for address authentication) 1 1 1 1 0 x x 1 10-bit slave address specification (for read command issuance after address match) remark for extension codes other than the above, refer to the i 2 c-bus specification published by nxp. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 607 jun 20, 2011 15.5.12 arbitration when several master devices simultaneous ly generate a start condition (when stt is set to 1 before std is set to 1), communication among the master devices is performed as the num ber of clocks 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) in the iica status register (iics) is set (1) via the timing by which the arbitration loss occurred, and the scl0 and sda0 lines are both set to high impedance, which releases the bus. the arbitration loss is detected based on th e timing of the next interrupt request (t he eighth or ninth clock, when a stop condition is detected, etc.) and the ald = 1 setting that has been made by software. for details of interrupt request timing, see 15.5.8 interrupt request (intiica) generation timing and wait control . remark std: bit 1 of iica status register (iics) stt: bit 1 of iica control register 0 (iicctl0) figure 15-21. arbitration timing example scl0 sda0 scl0 sda0 scl0 sda0 hi-z hi-z master 1 loses arbitration master 1 master 2 transfer lines 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 608 jun 20, 2011 table 15-4. status during arbitration 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 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 transf er when stop condition is generated (when spie = 1) note 2 when data is at low level while attempting to generate a restart condition at falling edge of eighth or ninth clock following byte transfer note 1 when stop condition is detected while attempting to generate a restart condition when stop condition is generated (when spie = 1) note 2 when data is at low level while attempting to generate a stop condition when scl0 is at low level while attempting to generate a restart condition at falling edge of eighth or ninth clock following byte transfer note 1 notes 1. when wtim (bit 3 of iica control r egister 0 (iicctl0)) = 1, an interrupt request occurs at the falling edge of the ninth clock. when wtim = 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 spie = 1 for master device operation. remark spie: bit 4 of iica control register 0 (iicctl0) 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 609 jun 20, 2011 15.5.13 wakeup function the i 2 c bus slave function is a function t hat generates an interrupt request signa l (intiica) when a local address and extension code have been received. this function makes processing more efficient by prev enting unnecessary intiica signal from occurring when addresses do not match. when a start condition is detected, wa keup standby mode is set. this wakeup standby mode is in effect while addresses are transmitted due to the possibility that an arbi tration loss may change the master device (which has generated a start condition) to a slave device. however, when a stop condition is detected, bit 4 (spie) of iica control register 0 (iicctl0) is set regardless of the wakeup function, and this determines whether interrupt requests are enabled or disabled. to use the wakeup function in the stop mode, set wup to 1. addresses can be received regardless of the operation clock. an interrupt request signal (intiica) is also generated when a local addres s and extension code have been received. operation returns to normal operation by using an in struction to clear (0) the wup bit after this interrupt has been generated. figure 15-22 shows the flow for setting wup = 1 and figure 15-23 shows the flow for setting wup = 0 upon an address match. figure 15-22. flow when setting wup = 1 waits for 3 clocks. yes no start wup = 1 wait stop instruction execution msts = std = exc = coi =0? 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 610 jun 20, 2011 figure 15-23. flow when setting wup = 0 upon addr ess match (including extension code reception) waits for 5 clocks. executes processing corresponding to the operation to be executed after checking the operation state of serial interface iica. stop mode state no yes wup = 0 wait reading iics intiica = 1? 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 611 jun 20, 2011 use the following flows to perform the processing to re lease the stop mode other t han by an interrupt request (intiica) generated from serial interface iica. ? master device operation: flow shown in figure 15-24 ? slave device operation: same as the flow in figure 15-23 figure 15-24. when operating as master device after releasing stop mode other than by intiica executes processing corresponding to the operation to be executed after checking the operation state of serial interface iica. no yes releases stop mode by an interrupt other than intiica. generates a stop condition or selects as a slave device. start wup = 1 spie = 1 releasing stop mode stop instruction wup = 0 reading iics intiica = 1? stop mode state waits for 5 clocks. wait 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 612 jun 20, 2011 15.5.14 communication reservation (1) when communication reservation func tion is enabled (bit 0 (iicrsv) of iica flag register (iicf) = 0) to start master device communications when not currently 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 by setting bit 6 (lrel) of iica control r egister 0 (iicctl0) to 1 and saving communication). if bit 1 (stt) of iicctl0 is set to 1 while the bus is not used (after a stop condition is detected), a start condition is automatically generated and wait state is set. if an address is written to the iica shift register (iica) after bit 4 (spie) of iicctl0 was set to 1, and it was detected by generation of an interrupt request signal (intiica) that the bus was released (detection of the stop condition), then the device automatically starts communicat ion as the master. data written to iica before the stop condition is detected is invalid. when stt has been set to 1, the operation mode (as start 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)......... communication reservation check whether the communication reservation operates or not by using msts (bit 7 of the iica status register (iics)) after stt is set to 1 and the wait time elapses. use software to secure the wait time calculated by the following expression. wait time from setting stt = 1 to checking the msts flag: (iicwl setting value + iicwh setting value + 4 clocks) / f clk + t f 2 remark iicwl: iica low-level width setting register iicwh: iica high-level width setting register t f : sda0 and scl0 signal falling times f clk : cpu/peripheral hardware clock frequency 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 613 jun 20, 2011 figure 15-25 shows the communication reservation timing. figure 15-25. communication reservation timing 2 1 3456 2 1 3456 789 scl0 sda0 program processing hardware processing write to iica set spd and intiica stt = 1 communi- cation reservation set std generate by master device with bus mastership remark iica: iica shift register stt: bit 1 of iica control register 0 (iicctl0) std: bit 1 of iica status register (iics) spd: bit 0 of iica status register (iics) communication reservations are accepted via the timing sh own in figure 15-26. after bit 1 (std) of the iica status register (iics) is set to 1, a communication rese rvation can be made by setting bit 1 (stt) of iica control register 0 (iicctl0) to 1 befor e a stop condition is detected. figure 15-26. timing for accep ting communication reservations scl0 sda0 std spd standby mode (communication can be reserved by setting stt to 1 during this period.) figure 15-27 shows the communication reservation protocol. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 614 jun 20, 2011 figure 15-27. communication reservation protocol di set1 stt define communication reservation wait msts = 0? (communication reservation) note 2 yes no (generate start condition) cancel communication reservation mov iica, # h ei sets stt flag (communication reservation) defines that communication reservation is in effect (defines and sets user flag to any part of ram) secures wait time note 1 by software. confirmation of communication reservation clear user flag iica write operation notes 1. the wait time is calculated as follows. (iicwl setting value + iicwh setting value + 4 clocks) / f clk + t f 2 2. the communication reservation operation executes a write to the iica shift register (iica) when a stop condition interrupt request occurs. remark stt: bit 1 of iica control register 0 (iicctl0) msts: bit 7 of iica status register (iics) iica: iica shift register iicwl: iica low-level width setting register iicwh: iica high-level width setting register t f : sda0 and scl0 signal falling times f clk : cpu/peripheral hardware clock frequency 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 615 jun 20, 2011 (2) when communication reservation function is disabled (bit 0 (iicrsv) of iica flag register (iicf) = 1) when bit 1 (stt) of iica control regi ster 0 (iicctl0) is set to 1 when t he 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 is not returned and the bus was released by setting bit 6 (lrel) of iicctl0 to 1 and saving communication) to confirm whether the start condition was generated or re quest was rejected, check stcf (bit 7 of iicf). it takes up to 5 clocks until stcf is set to 1 after setting stt = 1. therefore, secure the time by software. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 616 jun 20, 2011 15.5.15 cautions (1) when stcen = 0 immediately after i 2 c operation is enabled (iice = 1), the bus comm unication status (iicbsy = 1) is recognized regardless of the actual bus status. when changing from a mode in which no stop condition has been detected to a master device communication mode, first 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 iica control register 1 (iicctl1). <2> set bit 7 (iice) of iica cont rol register 0 (iicctl0) to 1. <3> set bit 0 (spt) of iicctl0 to 1. (2) when stcen = 1 immediately after i 2 c operation is enabled (iice = 1), the bus re leased status (iicbsy = 0) is recognized regardless of the actual bus status. to generate the first start condition (stt = 1), it is necessary to confirm that the bus has been released, 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 part icipates 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 re cognized as an extension code, ack 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 (spie) of iicctl0 to 0 to disable generati on of an interrupt request signal (intiica) when the stop condition is detected. <2> set bit 7 (iice) of iicctl0 to 1 to enable the operation of i 2 c. <3> wait for detection of the start condition. <4> set bit 6 (lrel) of iicctl0 to 1 before ack is retu rned (4 to 80 clocks after setting iice to 1), to forcibly disable detection. (4) setting stt and spt (bits 1 and 0 of iicctl0) again afte r they are set and before they are cleared to 0 is prohibited. (5) when transmission is reserved, set spie (bit 4 of iictl0) to 1 so that an interrupt request is generated when the stop condition is detected. transfer is started when communication data is wr itten to iica after the interrupt request is generated. unless the interrupt is generated when the st op condition is detected, the device stops in the wait state because the interrupt request is not generated when communication is start ed. however, it is not necessary to set spie to 1 when msts (bit 7 of iics) is detected by software. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 617 jun 20, 2011 15.5.16 communication operations the following shows three operatio n procedures with the flowchart. (1) master operation in single master system the flowchart when using the 78k0r/lx3 microcontrollers as the master in a single master system is shown below. this flowchart is broadly divided into the initial settings and communication processing. execute the initial settings at startup. if communication wit h the slave is required, prepare the communication and then execute communication processing. (2) master operation in multimaster system in the i 2 c bus multimaster system, whether the bus is released or used cannot be judged by the i 2 c bus specifications when the bus takes part in a communicati on. here, when data and clock are at a high level for a certain period (1 frame), the 78k0r/lx3 microcontrollers take part in a communication with bus released state. this flowchart is broadly divided into the initial settings , communication waiting, and communication processing. the processing when the 78k0r/lx3 microcontrollers loose in arbitration and are specifi ed as the slave is omitted here, and only the processing as the ma ster is shown. execute the initial settings at startup to take part in a communication. then, wait for the communication request as t he master or wait for the s pecification as the slave. the actual communication is performed in the communication processing, and it supports the transmission/reception with the slave and the arbitration with other masters. (3) slave operation an example of when the 78k0r/lx3 microcontrollers are used as the i 2 c bus slave is shown below. when used as the slave, operation is star ted by an interrupt. execute the initial settings at startup, then wait for the intiica interrupt occurrence (communication waiting). when an intiica interrupt occurs, the communication status is judged and its result is passed as a flag over to the main processing. by checking the flags, necessary communication processing is performed. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 618 jun 20, 2011 (1) master operation in single-master system figure 15-28. master operation in single-master system spt = 1 spt = 1 wrel = 1 start end acke = 0 wtim = wrel = 1 no no yes no no no yes yes yes yes stcen = 1? acke = 1 wtim = 0 trc = 1? ackd = 1? ackd = 1? no yes no yes yes no yes no yes no yes no yes no stt = 1 iicwl, iicwh xxh iicf 0xh setting stcen, iicrsv = 0 iicctl0 1xx111xxb iice = 1 iicctl0 0xx111xxb acke = wtim = spie = 1 setting port initializing i 2 c bus note sva xxh writing iica writing iica reading iica intiica interrupt occurs? end of transfer? end of transfer? restart? setting of the port used alternatively as the pin to be used. first, set the port to input mode and the output latch to 0 (see 15.3 (8) port mode register 6 (pm6) ). setting port set the port from input mode to output mode and enable the output of the i 2 c bus (see 15.3 (8) port mode register 6 (pm6) ). sets a transfer clock. sets a local address. sets a start condition. prepares for starting communication (generates a start condition). starts communication (specifies an address and transfer direction). waits for detection of acknowledge. waits for data transmission. starts transmission. communication processing initial setting starts reception. waits for data reception. intiica interrupt occurs? waits for detection of acknowledge. prepares for starting communication (generates a stop condition). waits for detection of the stop condition. intiica interrupt occurs? intiica interrupt occurs? intiica interrupt occurs? note release (scl0 and sda0 pins = high level) the i 2 c bus in conformance with the specifications of the product that is communicating. if eeprom is outputting a low le vel to the sda0 pin, for example, set the scl0 pin in the output port mode, and output a clock pu lse from the output port until the sda0 pin is constantly at high level. remark conform to the specifications of the product that is communicating, with respect to the transmission and reception formats. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 619 jun 20, 2011 (2) master operation in multi-master system figure 15-29. master operation in multi-master system (1/3) iicwl, iicwh xxh iicf 0xh setting stcen and iicrsv setting port spt = 1 sva xxh spie = 1 start slave operation slave operation releases the bus for a specific period. bus status is being checked. yes checking bus status note master operation starts? enables reserving communication. disables reserving communication. spd = 1? stcen = 1? iicrsv = 0? a selects a transfer clock. sets a local address. sets a start condition. (communication start request) (no communication start request) ? waiting to be specified as a slave by other master ? waiting for a communication start request (depends on user program) prepares for starting communication (generates a stop condition). waits for detection of the stop condition. no yes yes no intiica interrupt occurs? intiica interrupt occurs? yes no yes no spd = 1? yes no slave operation no intiica interrupt occurs? yes no 1 b spie = 0 yes no waits for a communication request. waits for a communication initial setting iicctl0 1xx111xxb iice = 1 iicctl0 0xx111xxb acke = wtim = spie = 1 setting of the port used alternatively as the pin to be used. first, set the port to input mode and the output latch to 0 (see 15.3 (8) port mode register 6 (pm6) ). setting port set the port from input mode to output mode and enable the output of the i 2 c bus (see 15.3 (8) port mode register 6 (pm6) ). note confirm that the bus is released (cld bit = 1, dad bit = 1) for a specific period (for example, for a period of one frame). if the sda0 pin is constantly at low level, decide whether to release the i 2 c bus (scl0 and sda0 pins = high level) in conformance with the specificat ions of the product that is communicating. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 620 jun 20, 2011 figure 15-29. master operation in multi-master system (2/3) stt = 1 wait slave operation yes msts = 1? exc = 1 or coi =1? prepares for starting communication (generates a start condition). secure wait time note by software. waits for bus release (communication being reserved). wait state after stop condition was detected and start condition was generated by the communication reservation function. no intiica interrupt occurs? yes yes no no a c stt = 1 wait note slave operation yes iicbsy = 0? exc = 1 or coi =1? prepares for starting communication (generates a start condition). disables reserving communication. enables reserving communication. waits for bus release detects a stop condition. no no intiica interrupt occurs? yes yes no yes stcf = 0? no b d c d communication processing communication processing note the wait time is calculated as follows. (iicwl setting value + iicwh setting value + 4 clocks) / f clk + t f 2 remark iicwl: iica low-level width setting register iicwh: iica high-level wid th setting register t f : sda0 and scl0 signal falling times f clk : cpu/peripheral hardware clock frequency 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 621 jun 20, 2011 figure 15-29. master operation in multi-master system (3/3) writing iica wtim = 1 wrel = 1 reading iica acke = 1 wtim = 0 wtim = wrel = 1 acke = 0 writing iica yes trc = 1? restart? msts = 1? starts communication (specifies an address and transfer direction). starts transmission. no yes waits for data reception. starts reception. yes no intiica i nterrupt occurs? yes no transfer end? waits for detection of ack. yes no intiica i nterrupt occurs? waits for data transmission. does not participate in communication. yes no intiica i nterrupt occurs? no yes ackd = 1? no yes no c 2 yes msts = 1? no yes transfer end? no yes ackd = 1? no 2 yes msts = 1? no 2 waits for detection of ack. yes no intiica i nterrupt occurs? yes msts = 1? no c 2 yes exc = 1 or coi = 1? no 1 2 spt = 1 stt = 1 slave operation end communication processing communication processing remarks 1. conform to the specifications of the product that is communicating, with respect to the transmission and reception formats. 2. to use the device as a master in a multi-master system, read the ms ts bit each time interrupt intiica has occurred to check the arbitration result. 3. to use the device as a slave in a multi-master system, check the status by using the iics and iicf registers each time inte rrupt intiica has occurred, and determine the processing to be performed next. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 622 jun 20, 2011 (3) slave operation the processing procedure of the slave operation is as follows. basically, the slave operation is event-driven. therefore, processing by the intiica interrupt (processing that must substantially change the operation st atus such as detection of a stop c ondition during communication) is necessary. in the following explanation, it is a ssumed that the extension c ode is not supported for data communication. it is also assumed that the intiica interrupt servicing only per forms status transition proces sing, and that actual data communication is performed by the main processing. iica interrupt servicing main processing intiica flag setting data setting therefore, data communication processing is performed by preparing the following three flags and passing them to the main processing instead of intiica. <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 commun ication is performed (from valid address detection to stop condition detection, no detection of ack from master, address mismatch) <2> ready flag this flag indicates that data communication is enabled. its function is the same as the intiica 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 communicati on 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 communication. its value is the same as trc. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 623 jun 20, 2011 the main processing of the slave operation is explained next. start serial interface iica and wait until communication is enabled. when communication is enabled, execute communication by using the communication mode flag and ready flag (processing of the stop condition and start condition is performed by an interrupt. he re, check the status by using the flags). the transmission operation is repeated unt il the master no longer returns ack. if ack is not returned from the master, communication is completed. for reception, the necessary amount of data is received. when communication is completed, ack is not returned as the next data. after that, the master generates a stop condition or restart condition. exit from the communication status occurs in this way. figure 15-30. slave operation flowchart (1) yes yes yes yes yes yes yes no no no no no no wrel = 1 ackd = 1? no yes no yes no start communication mode flag = 1? communication mode flag = 1? communication direction flag = 1? ready flag = 1? communication direction flag = 0? reading iica clearing ready flag clearing ready flag communication direction flag = 1? clearing communication mode flag wrel = 1 writing iica sva xxh sets a local address. iicwl, iicwh xxh selects a transfer clock. iicf 0xh setting iicrsv sets a start condition. starts transmission. starts reception. communication mode flag = 1? ready flag = 1? setting port setting port communication processing initial setting setting of the port used alternatively as the pin to be used. first, set the port to input mode and the output latch to 0 (see 15.3 (8) port mode register 6 (pm6) ). set the port from input mode to output mode and enable the output of the i 2 c bus (see 15.3 (8) port mode register 6 (pm6) ). iicctl0 0xx011xxb acke = wtim = 1, spie = 0 iicctl0 1xx011xxb iice = 1 remark conform to the specifications of the product t hat is in communication, regarding the transmission and reception formats. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 624 jun 20, 2011 an example of the processing procedure of the slave wit h the intiica interrupt is explained below (processing is performed assuming that no extension code is used). th e intiica interrupt checks 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 che cked and communication is completed if the address does not match. if the address matches, the communication mo de 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 i 2 c bus remaining in the wait state. remark <1> to <3> above correspond to <1> to <3> in figure 15-31 slave operation flowchart (2). figure 15-31. slave operation flowchart (2) yes yes yes no no no intiica generated set ready flag interrupt servicing completed spd = 1? std = 1? coi = 1? communication direction flag trc set communication mode flag clear ready flag clear c ommunication direction flag, ready flag, and communication mode flag <1> <2> <3> 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 625 jun 20, 2011 15.5.17 timing of i 2 c interrupt request (intiica) occurrence the timing of transmitting or receiving data and generation of interrupt request signal int iica, and the value of the iics register when the intiica signal is generated are shown below. remark st: start condition ad6 to ad0: address r/w: transfer direction specification ack: acknowledge d7 to d0: data sp: stop condition 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 626 jun 20, 2011 (1) master device operation (a) start ~ address ~ data ~ data ~ stop (transmission/reception) (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp spt = 1 3 4 5 2 1 1: iics = 1000110b 2: iics = 1000000b 3: iics = 1000000b (sets wtim to 1) note 4: iics = 100000b (sets spt to 1) note 5: iics = 00000001b note to generate a stop condition, set wtim to 1 and ch ange the timing for generating the intiica interrupt request signal. remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp spt = 1 3 4 2 1 1: iics = 1000110b 2: iics = 1000100b 3: iics = 100000b (sets spt to 1) 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 627 jun 20, 2011 (b) start ~ address ~ data ~ start ~ address ~ data ~ stop (restart) (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack stt = 1 spt = 1 3 4 7 2 1 5 6 1: iics = 1000110b 2: iics = 1000000b (sets wtim to 1) note 1 3: iics = 100000b (clears wtim to 0 note 2 , sets stt to 1) 4: iics = 1000110b 5: iics = 1000000b (sets wtim to 1) note 3 6: iics = 100000b (sets spt to 1) 7: iics = 00000001b notes 1. to generate a start condition, set wtim to 1 and change the timing for generating the intiica interrupt request signal. 2. clear wtim to 0 to restore the original setting. 3. to generate a stop condition, set wtim to 1 and change the timing for generating the intiica interrupt request signal. remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack stt = 1 spt = 1 3 4 5 2 1 1: iics = 1000110b 2: iics = 100000b (sets stt to 1) 3: iics = 1000110b 4: iics = 100000b (sets spt to 1) 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 628 jun 20, 2011 (c) start ~ code ~ data ~ data ~ stop (extension code transmission) (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp spt = 1 3 4 5 2 1 1: iics = 1010110b 2: iics = 1010000b 3: iics = 1010000b (sets wtim to 1) note 4: iics = 101000b (sets spt to 1) 5: iics = 00000001b note to generate a stop condition, set wtim to 1 and ch ange the timing for generating the intiica interrupt request signal. remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp spt = 1 3 4 2 1 1: iics = 1010110b 2: iics = 1010100b 3: iics = 101000b (sets spt to 1) 4: iics = 00001001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 629 jun 20, 2011 (2) slave device operation (slave address data reception) (a) start ~ address ~ data ~ data ~ stop (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 2 1 1: iics = 0001110b 2: iics = 0001000b 3: iics = 0001000b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 2 1 1: iics = 0001110b 2: iics = 0001100b 3: iics = 000100b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 630 jun 20, 2011 (b) start ~ address ~ data ~ start ~ address ~ data ~ stop (i) when wtim = 0 (after restart, matches with sva) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 5 2 1 1: iics = 0001110b 2: iics = 0001000b 3: iics = 0001110b 4: iics = 0001000b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 (after restart, matches with sva) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 5 2 1 1: iics = 0001110b 2: iics = 000100b 3: iics = 0001110b 4: iics = 000100b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 631 jun 20, 2011 (c) start ~ address ~ data ~ start ~ code ~ data ~ stop (i) when wtim = 0 (after restart, do es not match address (= extension code)) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 5 2 1 1: iics = 0001110b 2: iics = 0001000b 3: iics = 0010010b 4: iics = 0010000b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 (after restart, do es not match address (= extension code)) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 5 6 2 1 4 1: iics = 0001110b 2: iics = 000100b 3: iics = 0010010b 4: iics = 0010110b 5: iics = 001000b 6: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 632 jun 20, 2011 (d) start ~ address ~ data ~ start ~ address ~ data ~ stop (i) when wtim = 0 (after restart, does not match address (= not extension code)) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 2 1 1: iics = 0001110b 2: iics = 0001000b 3: iics = 00000110b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 (after restart, does not match address (= not extension code)) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 2 1 1: iics = 0001110b 2: iics = 000100b 3: iics = 00000110b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 633 jun 20, 2011 (3) slave device operation (w hen receiving extension code) the device is always participating in communication when it receives an extension code. (a) start ~ code ~ data ~ data ~ stop (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 2 1 1: iics = 0010010b 2: iics = 0010000b 3: iics = 0010000b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 5 2 1 1: iics = 0010010b 2: iics = 0010110b 3: iics = 0010100b 4: iics = 001000b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 634 jun 20, 2011 (b) start ~ code ~ data ~ start ~ address ~ data ~ stop (i) when wtim = 0 (after restart, matches sva) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 5 2 1 1: iics = 0010010b 2: iics = 0010000b 3: iics = 0001110b 4: iics = 0001000b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 (after restart, matches sva) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 6 2 1 5 1: iics = 0010010b 2: iics = 0010110b 3: iics = 001000b 4: iics = 0001110b 5: iics = 000100b 6: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 635 jun 20, 2011 (c) start ~ code ~ data ~ start ~ code ~ data ~ stop (i) when wtim = 0 (after restart, extension code reception) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 5 2 1 1: iics = 0010010b 2: iics = 0010000b 3: iics = 0010010b 4: iics = 0010000b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 (after restart, extension code reception) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 7 2 1 5 6 1: iics = 0010010b 2: iics = 0010110b 3: iics = 001000b 4: iics = 0010010b 5: iics = 0010110b 6: iics = 001000b 7: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 636 jun 20, 2011 (d) start ~ code ~ data ~ start ~ address ~ data ~ stop (i) when wtim = 0 (after restart, does not match address (= not extension code)) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 2 1 1: iics = 00100010b 2: iics = 00100000b 3: iics = 00000110b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 (after restart, does not match address (= not extension code)) st ad6 to ad0 r/w ack d7 to d0 ad6 to ad0 ack ack sp st r/w d7 to d0 ack 3 4 5 2 1 1: iics = 00100010b 2: iics = 00100110b 3: iics = 0010000b 4: iics = 00000110b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 637 jun 20, 2011 (4) operation without communication (a) start ~ code ~ data ~ data ~ stop st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 1 1: iics = 00000001b remark : generated only when spie = 1 (5) arbitration loss operation (opera tion as slave after arbitration loss) when the device is used as a master in a multi-master system, read the msts bit each time interrupt request signal intiica has occurred to check the arbitration result. (a) when arbitration loss occurs durin g transmission of slave address data (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 2 1 1: iics = 0101110b 2: iics = 0001000b 3: iics = 0001000b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 638 jun 20, 2011 (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 2 1 1: iics = 0101110b 2: iics = 0001100b 3: iics = 000100b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (b) when arbitration loss occurs dur ing transmission of extension code (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 2 1 1: iics = 0110010b 2: iics = 0010000b 3: iics = 0010000b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 639 jun 20, 2011 (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 4 5 2 1 1: iics = 0110010b 2: iics = 0010110b 3: iics = 0010100b 4: iics = 001000b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (6) operation when arbitration loss occurs (no communication after arbitration loss) when the device is used as a master in a multi-master system, read the msts bit each time interrupt request signal intiica has occurred to check the arbitration result. (a) when arbitration loss occu rs during transmission of slave address data (when wtim = 1) st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 2 1 1: iics = 01000110b 2: iics = 00000001b remark : always generated : generated only when spie = 1 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 640 jun 20, 2011 (b) when arbitration loss occurs dur ing transmission of extension code st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 2 1 1: iics = 0110010b sets lrel = 1 by software 2: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (c) when arbitration loss occu rs during transmission of data (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 2 1 1: iics = 10001110b 2: iics = 01000000b 3: iics = 00000001b remark : always generated : generated only when spie = 1 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 641 jun 20, 2011 (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack ack sp 3 2 1 1: iics = 10001110b 2: iics = 01000100b 3: iics = 00000001b remark : always generated : generated only when spie = 1 (d) when loss occurs due to rest art condition during data transfer (i) not extension code (example: unmatches with sva) st ad6 to ad0 r/w ack d7 to dn ad6 to ad0 ack sp st r/w d7 to d0 ack 3 2 1 1: iics = 1000110b 2: iics = 01000110b 3: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care n = 6 to 0 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 642 jun 20, 2011 (ii) extension code st ad6 to ad0 r/w ack d7 to dn ad6 to ad0 ack sp st r/w d7 to d0 ack 3 2 1 1: iics = 1000110b 2: iics = 01100010b sets lrel = 1 by software 3: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care n = 6 to 0 (e) when loss occurs due to st op condition during data transfer st ad6 to ad0 r/w ack d7 to dn sp 2 1 1: iics = 10000110b 2: iics = 01000001b remark : always generated : generated only when spie = 1 : don?t care n = 6 to 0 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 643 jun 20, 2011 (f) when arbitration loss occurs due to low-level da ta when attempting to generate a restart condition (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack sp ack d7 to d0 ack stt = 1 3 4 5 2 1 1: iics = 1000110b 2: iics = 1000000b (sets wtim to 1) 3: iics = 1000100b (clears wtim to 0) 4: iics = 01000000b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack sp ack d7 to d0 ack stt = 1 3 4 2 1 1: iics = 1000110b 2: iics = 1000100b (sets stt to 1) 3: iics = 01000100b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 644 jun 20, 2011 (g) when arbitration loss occurs due to a stop cond ition when attempting to generate a restart condition (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 ack sp stt = 1 3 4 2 1 1: iics = 1000110b 2: iics = 1000000b (sets wtim to 1) 3: iics = 100000b (sets stt to 1) 4: iics = 01000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 ack sp stt = 1 2 3 1 1: iics = 1000110b 2: iics = 100000b (sets stt to 1) 3: iics = 01000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 645 jun 20, 2011 (h) when arbitration loss occurs due to low-level data when attemp ting to generate a stop condition (i) when wtim = 0 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack sp ack d7 to d0 ack spt = 1 3 4 5 2 1 1: iics = 1000110b 2: iics = 1000000b (sets wtim to 1) 3: iics = 1000100b (clears wtim to 0) 4: iics = 01000100b 5: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care (ii) when wtim = 1 st ad6 to ad0 r/w ack d7 to d0 d7 to d0 ack sp ack d7 to d0 ack spt = 1 3 4 2 1 1: iics = 1000110b 2: iics = 1000100b (sets spt to 1) 3: iics = 01000100b 4: iics = 00000001b remark : always generated : generated only when spie = 1 : don?t care 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 646 jun 20, 2011 15.6 timing charts when using the i 2 c bus mode, the master device out puts an address via the serial bus to select one of several slave devices as its communication partner. after outputting the slave address, the ma ster device transmits the trc bit (bit 3 of the iica status register (iics)), which specifies the data transfer di rection, and then starts serial communication with the slave device. figures 15-32 and 15-33 show timing charts of the data communication. the iica shift register (iica)?s shift operation is synchronized with the falling ed ge of the serial clock (scl0). the transmit data is transferred to the so latch an d is output (msb first) via the sda0 pin. data input via the sda0 pin is captured into iica at the rising edge of scl0. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 647 jun 20, 2011 figure 15-32. example of master to slave communication (when 9-clock wait is selected for master, 9-clock wait is selected for slave) (1/4) (1) start condition ~ address ~ data iica stt (st trigger) spt (sp trigger) ackd (ack detection) wtim (8 or 9 clock wait) acke (ack control) msts (communication status) trc (transmit/receive) scl0 (bus) (clock line) wrel (wait cancellation) intiica (interrupt) sda0 (bus) (data line) w ack <2> iica std (st detection) spd (sp detection) ackd (ack detection) acke (ack control) msts (communication status) trc (transmit/receive) wrel (wait cancellation) intiica (interrupt) master side bus line slave side slave address l l h l h h h l ad5 ad4 ad3 ad2 ad1 ad0 wtim (8 or 9 clock wait) note 1 start condition d 1 7 ad6 note 2 note 3 <5> <1> <4> <3> <6> : wait state by slave device : wait state by master and slave devices notes 1. write data to iica, not setting the wrel bit, in or der to cancel a wait stat e during master transmission. 2. make sure that the time between the fall of the sda0 pin signal and the fall of the scl0 pin signal is at least 4.0 s when specifying standard mode and at least 0.6 s when specifying fast mode. 3. to cancel slave wait, write ?ffh? to iica or set the wrel bit. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 648 jun 20, 2011 the meanings of <1> to <6> in (1) start condition ~ address ~ data in figure 15-32 are explained below. <1> the start condition trigger is set by the master device (stt = 1) and a start condition (sda0 = 0 and scl0 = 1) is generated once the bus data line goes low (s da0 = 0). when the start condition is subsequently detected, the master devi ce enters the master device communicat ion status (msts = 1). the master device is ready to communicate once the bus clock line goes low (scl0 = 0) after the hold time has elapsed. <2> the master device writes the address + w (transmissio n) to the iica shift register (iica) and transmits the slave address. <3> if the address received matches the address of a slave device note , that slave device sends an ack by hardware to the master device. the ack is detected by the master device (ackd = 1) at the rising edge of the 9th clock. <4> the master device issues an interrupt (intiica: end of address transmission) at the falling edge of the 9th clock, and the slave device whose address matched t he transmitted slave address also issues an interrupt (intiica: address match). the master device and sl ave device also set a wait status (scl0 = 0) note when the addresses match. <5> the master device writes the data to transmit to the iic a register and releases the wa it status that it set by the master device. <6> if the slave device releases the wait status (wrel = 1), the master device starts transferring data to the slave device. note if the transmitted address does not match the address of the slave device, the slave device does not return an ack to the master device (nack: sda0 = 1). the sl ave device also does not issue the intiica interrupt (address match) and does not set a wait status. the ma ster device, however, issues the intiica interrupt (end of address transmission) regardless of whether it receives an ack or nack. remark <1> to <15> in figure 15-32 represent the enti re procedure for communicating data using the i 2 c bus. figure 15-32 (1) start condition ~ address ~ data shows the processing from <1> to <6>, figure 15-32 (2) address ~ data ~ data shows the processing from <3> to <10>, and figure 15-32 (3) data ~ data ~ stop condition shows the processing from <7> to <15>. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 649 jun 20, 2011 figure 15-32. example of master to slave communication (when 9-clock wait is selected for master, 9-clock wait is selected for slave) (2/4) (2) address ~ data ~ data iica stt (st trigger) spt (sp trigger) ackd (ack detection) wtim (8 or 9 clock wait) acke (ack control) msts (communication status) trc (transmit/receive) scl0 (bus) (clock line) wrel (wait cancellation) intiica (interrupt) sda0 (bus) (data line) iica std (st detection) spd (sp detection) ackd (ack detection) wtim (8 or 9 clock wait) acke (ack control) msts (communication status) trc (transmit/receive) wrel (wait cancellation) intiica (interrupt) w ack master side bus line slave side h h l h l l l h h l l d 1 6 d 1 5 d 1 4 d 1 3 d 1 2 d 1 1 d 1 0 d 1 7 d 2 7 ack h note 2 <10> <6> <7> <8> <3> <4> note 1 note 1 <9> <5> note 2 : wait state by slave device : wait state by master and slave devices notes 1. write data to iica, not setting the wrel bit, in orde r to cancel a wait state during master transmission. 2. to cancel slave wait, write ?ffh? to iica or set the wrel bit. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 650 jun 20, 2011 the meanings of <3> to <10> in (2) address ~ data ~ data in figure 15-32 are explained below. <3> if the address received matches the address of a slave device note , that slave device sends an ack by hardware to the master device. the ack is detected by the master device (ackd = 1) at the rising edge of the 9th clock. <4> the master device issues an interrupt (intiica: end of address transmission) at the falling edge of the 9th clock, and the slave device whose address matched t he transmitted slave address also issues an interrupt (intiica: address match). the master device and sl ave device also set a wait status (scl0 = 0) note when the addresses match. <5> the master device writes the data to transmit to the iica shift register (iica) and releases the wait status that it set by the master device. <6> if the slave device releases the wait status (wrel = 1), the master device starts transferring data to the slave device. <7> when data transfer is complete, the slave device sends an ack by hardware to the master device. the ack is detected by the master device (ackd = 1) at the rising edge of the 9th clock. <8> the master device and slave device set a wait stat us (scl0 = 0) at the falling edge of the 9th clock, and both the master device and slave device i ssue an interrupt (intiica: end of transfer). <9> the master device writes the data to transmit to the iic a register and releases the wa it status that it set by the master device. <10> the slave device reads the received data and releases the wait status (wrel = 1). the master device then starts transferring data to the slave device. note if the transmitted address does not match the address of the slave device, the slave device does not return an ack to the master device (nack: sda0 = 1). the sl ave device also does not issue the intiica interrupt (address match) and does not set a wait status. the ma ster device, however, issues the intiica interrupt (end of address transmission) regardless of whether it receives an ack or nack. remark <1> to <15> in figure 15-32 represent the enti re procedure for communicating data using the i 2 c bus. figure 15-32 (1) start condition ~ address ~ data shows the processing from <1> to <6>, figure 15-32 (2) address ~ data ~ data shows the processing from <3> to <10>, and figure 15-32 (3) data ~ data ~ stop condition shows the processing from <7> to <15>. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 651 jun 20, 2011 figure 15-32. example of master to slave communication (when 9-clock wait is selected for master, 9-clock wait is selected for slave) (3/4) (3) data ~ data ~ stop condition master side d 16 1 iica stt (st trigger) spt (sp trigger) ackd (ack detection) wtim (8 or 9 clock wait) acke (ack control) msts (communication status) trc (transmit/receive) scl0 (bus) (clock line) wrel (wait cancellation) intiica (interrupt) sda0 (bus) (data line) d 16 2 d 16 3 d 16 4 d 16 5 d 16 0 d 16 6 iica std (st detection) spd (sp detection) ackd (ack detection) wtim (8 or 9 clock wait) acke (ack control) msts (communication status) trc (transmit/receive) wrel (wait cancellation) intiica (interrupt) d 15 0 d 16 7 bus line slave side l l h h l l h h l ack ack note 1 stop condition <14> <9> note 2 <8> <12> <7> <11> <15> <10> <13> note 3 note 3 : wait state by master device : wait state by slave device : wait state by master and slave devices notes 1. write data to iica, not setting the wrel bit, in or der to cancel a wait stat e during master transmission. 2. make sure that the time between the rise of the scl0 pin signal and the generation of the stop condition after a stop condition has been issued is at least 4.0 s when specifying standard mode and at least 0.6 s when specifying fast mode. 3. to cancel slave wait, write ?ffh? to iica or set the wrel bit. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 652 jun 20, 2011 the meanings of <7> to <15> in (3) data ~ data ~ stop condition in figure 15-32 are explained below. <7> when data transfer is complete, the slave device sends an ack by hardware to the master device. the ack is detected by the master device (ackd = 1) at the rising edge of the 9th clock. <8> the master device and slave device set a wait stat us (scl0 = 0) at the falling edge of the 9th clock, and both the master device and slave device i ssue an interrupt (intiica: end of transfer). <9> the master device writes the data to transmit to the iica shift register (iica) and releases the wait status that it set by the master device. <10> the slave device reads the received data and releases the wait status (wrel = 1). the master device then starts transferring data to the slave device. <11> when data transfer is complete, the slave device sends an ack by hardware to the master device. the ack is detected by the master device (ackd = 1) at the rising edge of the 9th clock. <12> the master device and slave device set a wait stat us (scl0 = 0) at the falling edge of the 9th clock, and both the master device and slave device i ssue an interrupt (intiica: end of transfer). <13> the slave device reads the received dat a and releases the wait status (wrel = 1). <14> after a stop condition trigger is set, the bus data line is cleared (sda0 = 0) and the bus clock line is set (scl0 = 1). the stop condition is then generated by setting the bus data line (sda0 = 1) after the stop condition setup time has elapsed. <15> when a stop condition is generat ed, the slave device detects the st op condition and issues an interrupt (intiica: stop condition). remark <1> to <15> in figure 15-32 represent the enti re procedure for communicating data using the i 2 c bus. figure 15-32 (1) start condition ~ address ~ data shows the processing from <1> to <6>, figure 15-32 (2) address ~ data ~ data shows the processing from <3> to <10>, and figure 15-32 (3) data ~ data ~ stop condition shows the processing from <7> to <15>. 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 653 jun 20, 2011 figure 15-32. example of master to slave communication (when 9-clock wait is selected for master, 9-clock wait is selected for slave) (4/4) (4) data ~ restart condition ~ address l h l h l h iica stt (st trigger) spt (sp trigger) ackd (ack detection) wtim (8 or 9 clock wait) acke (ack control) msts (communication status) trc (transmit/receive) scl0 (bus) (clock line) wrel (wait cancellation) intiica (interrupt) sda0 (bus) (data line) ad6 iica std (st detection) spd (sp detection) ackd (ack detection) wtim (8 or 9 clock wait) acke (ack control) msts (communication status) trc (transmit/receive) wrel (wait cancellation) intiica (interrupt) master side bus line slave side slave address d 1 3 ack l h h l h restart condition d 1 2 d 1 1 d 1 0 ad5 ad4 ad3 ad2 ad1 78k0r/lx3 chapter 15 serial interface iica r01uh0004ej0501 rev.5.01 654 jun 20, 2011 the following describes the operations in figure 15-32 (4) data ~ restart condition ~ address. after the operations in steps <7> and <8>, the operations in steps <1> to <3> are performed. these steps re turn the processing to step <3>, the data transmission step. <7> when data transfer is complete, the slave device sends an ack by hardware to the master device. the ack is detected by the master device (ackd = 1) at the rising edge of the 9th clock. <8> the master device and slave device set a wait stat us (scl0 = 0) at the falling edge of the 9th clock, and both the master device and slave device i ssue an interrupt (intiica: end of transfer). the slave device reads the received data and releases the wait status (wrel = 1). |