![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
document no. u17894ej8v0ud00 (8th edition) date published august 2008 n printed in japan 2006 pd78f1162, 78f1162a, 78f1162a(a) pd78f1163, 78f1163a, 78f1163a(a) pd78f1164, 78f1164a, 78f1164a(a) pd78f1165, 78f1165a, 78f1165a(a) pd78f1166, 78f1166a, 78f1166a(a) pd78f1167, 78f1167a, 78f1167a(a) pd78f1168, 78f1168a, 78f1168a(a) 78k0r/kg3 16-bit single-chip microcontrollers user?s manual
user?s manual u17894ej8v0ud 2 [memo] user?s manual u17894ej8v0ud 3 1 2 3 4 voltage application waveform at input pin waveform distortion due to input noise or a reflected wave may cause malfunction. if the input of the cmos device stays in the area between v il (max) and v ih (min) due to noise, etc., the device may malfunction. take care to prevent chattering noise from entering the device when the input level is fixed, and also in the transition period when the input level passes through the area between v il (max) and v ih (min). handling of unused input pins unconnected cmos device inputs can be cause of malfunction. if an input pin is unconnected, it is possible that an internal input level may be generated due to noise, etc., causing malfunction. cmos devices behave differently than bipolar or nmos devices. input levels of cmos devices must be fixed high or low by using pull-up or pull-down circuitry. each unused pin should be connected to v dd or gnd via a resistor if there is a possibility that it will be an output pin. all handling related to unused pins must be judged separately for each device and according to related specifications governing the device. precaution against esd a strong electric field, when exposed to a mos device, can cause destruction of the gate oxide and ultimately degrade the device operation. steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it when it has occurred. environmental control must be adequate. when it is dry, a humidifier should be used. it is recommended to avoid using insulators that easily build up static electricity. semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. all test and measurement tools including work benches and floors should be grounded. the operator should be grounded using a wrist strap. semiconductor devices must not be touched with bare hands. similar precautions need to be taken for pw boards with mounted semiconductor devices. status before initialization power-on does not necessarily define the initial status of a mos device. immediately after the power source is turned on, devices with reset functions have not yet been initialized. hence, power-on does not guarantee output pin levels, i/o settings or contents of registers. a device is not initialized until the reset signal is received. a reset operation must be executed immediately after power-on for devices with reset functions. power on/off sequence in the case of a device that uses different power supplies for the internal operation and external interface, as a rule, switch on the external power supply after switching on the internal power supply. when switching the power supply off, as a rule, switch off the external power supply and then the internal power supply. use of the reverse power on/off sequences may result in the application of an overvoltage to the internal elements of the device, causing malfunction and degradation of internal elements due to the passage of an abnormal current. the correct power on/off sequence must be judged separately for each device and according to related specifications governing the device. input of signal during power off state do not input signals or an i/o pull-up power supply while the device is not powered. the current injection that results from input of such a signal or i/o pull-up power supply may cause malfunction and the abnormal current that passes in the device at this time may cause degradation of internal elements. input of signals during the power off state must be judged separately for each device and according to related specifications governing the device. notes for cmos devices 5 6 user?s manual u17894ej8v0ud 4 windows and windows nt are registered trademarks or trademarks of microsoft co rporation in the united states and/or other countries. pc/at is a trademark of internati onal business machines corporation. eeprom is a trademark of nec electronics corporation. superflash is a registered trademark of silicon storage t echnology, inc. in several countries including the united states and japan. caution: this product uses superflash ? technology licensed from silicon storage technology, inc. the information in this document is current as of august, 2008. the information is subject to change without notice. for actual design-in, refer to the latest publications of nec electronics data sheets or data books, etc., for the most up-to-date specifications of nec electronics products. not all products and/or types are available in every country. please check with an nec electronics sales representative for availability and additional information. no part of this document may be copied or reproduced in any form or by any means without the prior written consent of nec electronics. nec electronics assumes no responsibility for any errors that may appear in this document. nec electronics does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from the use of nec electronics products listed in this document or any other liability arising from the use of such products. no license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of nec electronics or others. descriptions of circuits, software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples. the incorporation of these circuits, software and information in the design of a customer's equipment shall be done under the full responsibility of the customer. nec electronics assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits, software and information. while nec electronics endeavors to enhance the quality, reliability and safety of nec electronics products, customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. to minimize risks of damage to property or injury (including death) to persons arising from defects in nec electronics products, customers must incorporate sufficient safety measures in their design, such as redundancy, fire-containment and anti-failure features. nec electronics products are classified into the following three quality grades: "standard", "special" and "specific". the "specific" quality grade applies only to nec electronics products developed based on a customer- designated "quality assurance program" for a specific application. the recommended applications of an nec electronics product depend on its quality grade, as indicated below. customers must check the quality grade of each nec electronics product before using it in a particular application. "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. "special": transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support). "specific": aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems and medical equipment for life support, etc. the quality grade of nec electronics products is "standard" unless otherwise expressly specified in nec electronics data sheets or data books, etc. if customers wish to use nec electronics products in applications not intended by nec electronics, they must contact an nec electronics sales representative in advance to determine nec electronics' willingness to support a given application. (note) (1) "nec electronics" as used in this statement means nec electronics corporation and also includes its majority-owned subsidiaries. (2) "nec electronics products" means any product developed or manufactured by or for nec electronics (as defined above). ? ? ? ? ? ? m8e 02. 11-1 user?s manual u17894ej8v0ud 5 introduction readers this manual is intended for user engineer s who wish to understand the functions of the 78k0r/kg3 and design and develop application systems and programs for these devices. the target products are as follows. ? conventional-specification products of the 78k0r/kg3: pd78f1162, 78f1163, 78f 1164, 78f1165, 78f1166, 78f1167, 78f1168 ? expanded-specification pro ducts of the 78k0r/kg3: pd78f1162a, 78f1163a, 78f1164a, 78f116 5a, 78f1166a, 78f1167a, 78f1168a ? (a) grade products of the expanded-specif ication products of the 78k0r/kg3 (under development): pd78f1162a(a), 78f1163a(a), 78f1164a (a), 78f1165a(a), 78f1166a(a), 78f1167a(a), 78f1168a(a) purpose this manual is intended to give users an understanding of the functions described in the organization below. organization the 78k0r/kg3 manual is separated into two parts: this manual and the instructions edition (common to the 78k0r microcontroller series). 78k0r/kg3 user?s manual (this manual) 78k0r microcontroller 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 ma nual have general knowledge of electrical engineering, logic circuits, and microcontrollers. ? when using this manual as the manual for (a) grade products of the expanded- specification products of 78k0r/kg3 microcontrollers: only the electrical specifications and quality grade differ between standard products and (a) grade products. read the part number for (a) grade products as follows. ? pd78f116ya pd78f116ya(a) (y = 2 to 8) ? to gain a general understanding of functions: read this manual in the order of the contents . the mark ? user?s manual u17894ej8v0ud 6 ? how to interpret the register format: for a bit number enclosed in angle brackets, the bit name is defined as a reserved word in the ra78k0r, and is defined as an sfr variable using the #pragma sfr directive in the cc78k0r. ? to know details of the 78k0r series instructions: refer to the separate document 78k0r microcontroller instructions user?s manual (u17792e) . conventions data significance: higher digits on the left and lower digits on the right active low representations: (overscore over pin and signal name) note : footnote for item marked with note in the text caution : information requiring particular attention remark : supplementary information numerical representations: binary ... or b decimal ... hexadecimal ... h related documents the related documents indicated in this pu blication may include preliminary versions. however, preliminary versions are not marked as such. documents related to devices document name document no. 78k0r/kg3 user?s manual this manual 78k0r microcontroller instructions user?s manual u17792e 78k0r microcontroller self progr amming library type01 user?s manual note u18706e note this document is classified under engineering management. contact an nec electronics sales representative. 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 sm+ system simulator operation u18601e 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-mini2 on-chip debug emulator with programming function u18371e qb-78k0rkx3 in-circuit emulator u17866e caution the related documents listed above are subject to change without notice. be sure to use the latest version of each document when designing. user?s manual u17894ej8v0ud 7 documents related to flash memo ry programming (u ser?s manuals) document name document no. pg-fp4 flash memory programmer u15260e pg-fp5 flash memory programmer u18865e other documents document name document no. semiconductor selection guide ? products and packages ? x13769x semiconductor device mount manual note quality grades on nec semiconductor devices c11531e nec semiconductor device reliability/quality control system c10983e guide to prevent damage for semiconductor devi ces by electrostatic discharge (esd) c11892e note see the ?semiconductor device m ount manual? website (h ttp://www.necel.com/pkg/en/mount/index.html). caution the related documents listed above are subject to change without notice. be sure to use the latest version of each document when designing. user?s manual u17894ej8v0ud 8 contents chapter 1 outline ........................................................................................................... ................18 1.1 differences between conventional-specification products ( pd78f116x) and expanded-specification products ( pd78f116xa) ..............................................................18 1.2 features ................................................................................................................... .................19 1.3 applications............................................................................................................... ...............20 1.4 ordering information ....................................................................................................... ........21 1.5 pin configuration (top view)............................................................................................... ...22 1.6 78k0r/kx3 microcontroller lineup .................................. ......................................................25 1.7 block diagram .............................................................................................................. ............26 1.8 outline of functions ....................................................................................................... .........27 chapter 2 pin functions .................................................................................................... ..........29 2.1 pin function list .......................................................................................................... ............29 2.2 description of pin functions ............................................................................................... ...35 2.2.1 p00 to p06 (por t 0) ...................................................................................................... ...............35 2.2.2 p10 to p17 (por t 1) ...................................................................................................... ...............36 2.2.3 p20 to p27 (por t 2) ...................................................................................................... ...............37 2.2.4 p30, p 31 (por t 3) ........................................................................................................ ................37 2.2.5 p40 to p47 (por t 4) ...................................................................................................... ...............38 2.2.6 p50 to p57 (por t 5) ...................................................................................................... ...............39 2.2.7 p60 to p67 (por t 6) ...................................................................................................... ...............40 2.2.8 p70 to p77 (por t 7) ...................................................................................................... ...............40 2.2.9 p80 to p87 (por t 8) ...................................................................................................... ...............41 2.2.10 p110, p1 11 (port 11) .................................................................................................... ..............41 2.2.11 p120 to p124 (por t 12) .................................................................................................. .............41 2.2.12 p130, p1 31 (port 13) .................................................................................................... ..............42 2.2.13 p140 to p145 (por t 14) .................................................................................................. .............43 2.2.14 p150 to p157 (por t 15) .................................................................................................. .............44 2.2.15 av ref0 .............................................................................................................................. .........44 2.2.16 av ref1 .............................................................................................................................. .........45 2.2.17 av ss .............................................................................................................................. ............45 2.2.18 reset ................................................................................................................... ....................45 2.2.19 regc .................................................................................................................... .....................45 2.2.20 v dd , ev dd0 , ev dd1 .....................................................................................................................46 2.2.21 v ss , ev ss0 , ev ss1 ......................................................................................................................46 2.2.22 flmd0................................................................................................................... .....................46 2.3 pin i/o circuits and recommende d connection of unused pins.......................................47 chapter 3 cpu architecture ................................................................................................. ....52 3.1 memory space ............................................................................................................... ...........52 3.1.1 internal progr am memory space............................................................................................ .....62 3.1.2 mirro r ar ea .............................................................................................................. ....................64 3.1.3 internal data memory space ............................................................................................... ........65 3.1.4 special function register (s fr) area..................................................................................... ......66 user?s manual u17894ej8v0ud 9 3.1.5 extended special function register (2nd sfr: 2nd specia l function regi ster) ar ea .................66 3.1.6 data memo ry addre ssing ................................................................................................... ........67 3.2 processor registers ........................................................................................................ ........74 3.2.1 control registers ........................................................................................................ .................74 3.2.2 general-purpo se regi sters................................................................................................ ..........76 3.2.3 es and cs regist ers...................................................................................................... .............78 3.2.4 special function register s (sfrs) ........................................................................................ .......79 3.2.5 extended special function registers ( 2nd sfrs: 2nd special f unction regi sters) .....................85 3.3 instruction address addressing .................................. ..........................................................9 1 3.3.1 relative addre ssing ...................................................................................................... ..............91 3.3.2 immediat e addre ssing ..................................................................................................... ...........91 3.3.3 table indi rect addr essing ................................................................................................ ...........92 3.3.4 register di rect addr essing............................................................................................... ...........93 3.4 addressing for processing data ad dresses.........................................................................94 3.4.1 impli ed addres sing ....................................................................................................... ..............94 3.4.2 register addre ssing ...................................................................................................... .............94 3.4.3 direct addre ssing ........................................................................................................ ...............95 3.4.4 short dire ct addressing .................................................................................................. ............96 3.4.5 sfr addressi ng........................................................................................................... ...............97 3.4.6 register i ndirect addr essing ............................................................................................. ..........98 3.4.7 based addres sing......................................................................................................... ..............99 3.4.8 based index ed addres sing ................................................................................................. ......102 3.4.9 stack addressi ng......................................................................................................... .............103 chapter 4 port functions ................................................................................................... .....104 4.1 port functions............................................................................................................. ...........104 4.2 port configuration ............................... .......................................................................... ........107 4.2.1 port 0................................................................................................................... .....................108 4.2.2 port 1................................................................................................................... .....................114 4.2.3 port 2................................................................................................................... .....................120 4.2.4 port 3................................................................................................................... .....................122 4.2.5 port 4................................................................................................................... .....................123 4.2.6 port 5................................................................................................................... .....................132 4.2.7 port 6................................................................................................................... .....................134 4.2.8 port 7................................................................................................................... .....................137 4.2.9 port 8................................................................................................................... .....................138 4.2.10 po rt 11................................................................................................................. .....................139 4.2.11 po rt 12................................................................................................................. .....................140 4.2.12 po rt 13................................................................................................................. .....................143 4.2.13 po rt 14................................................................................................................. .....................145 4.2.14 po rt 15................................................................................................................. .....................149 4.3 registers controlling po rt function ....................................................................................150 4.4 port function operations......................................... .......................................................... ...157 4.4.1 writing to i/o port ...................................................................................................... ...............157 4.4.2 reading from i/o port.................................................................................................... ...........157 4.4.3 operatio ns on i/o port................................................................................................... ...........157 4.4.4 connecting to external device wit h different potentia l (2.5v, 3 v) ............................................158 user?s manual u17894ej8v0ud 10 4.5 settings of port mode register an d output latch when using alternate function ....................................................................................................................... ...........160 4.6 cautions on 1-bit manipulation instruction for port register n (pn)................................163 chapter 5 external bus interface .....................................................................................164 5.1 functions of external bus interface ....................................................................................164 5.2 registers controlling ex ternal bus interface func tions ...................................................170 5.3 setting port mode register and output latch .... ................................................................173 5.4 number of instruction wait cl ocks for data access..........................................................174 5.5 number of instruction execution clocks and instruction wait clocks for fetch access......................................................................................................................... ............174 5.6 timing of external bus interf ace function..........................................................................175 5.6.1 multiple xed bus mode ..................................................................................................... ..........176 5.6.2 separat e bus mode ........................................................................................................ ..........180 5.7 example of connection to memory ............................... .......................................................184 5.7.1 connection of extern al logic (asi c, etc.)................................................................................ ..184 5.7.2 connection of synchronous memory ........................................................................................1 84 5.7.3 connection of a synchronous memory ......................................................................................18 5 chapter 6 clock generator .................................................................................................. .186 6.1 functions of clock generator........................................ ....................................................... 186 6.2 configuration of clock genera tor ........................................................................................187 6.3 registers controlling clock generator ........................ .......................................................189 6.4 system clock oscillator .................................................................................................... ....203 6.4.1 x1 o scillat or ............................................................................................................ ..................203 6.4.2 xt1 o scillato r........................................................................................................... .................203 6.4.3 internal high- speed osci llator........................................................................................... .........206 6.4.4 internal lo w-speed osc illat or ............................................................................................ .........206 6.4.5 pre scaler ................................................................................................................ ..................206 6.5 clock generator operation ............................................ ...................................................... .207 6.6 controlling clock .......................................................................................................... .........211 6.6.1 example of controlling high-speed system cloc k ......................................................................211 6.6.2 example of controlling internal high-speed oscill ation cl ock .....................................................214 6.6.3 example of contro lling subsyste m clock ................................................................................... 216 6.6.4 example of controlling intern al low-speed osc illation cl ock ......................................................218 6.6.5 cpu clock status transitio n diagr am...................................................................................... ...219 6.6.6 condition bef ore changing cpu clock and processing after c hanging cpu clock ...................224 6.6.7 time required for switchover of cpu clock and main system cl ock .........................................226 6.6.8 conditions before clock oscillation is stopped ..........................................................................2 27 chapter 7 timer array unit................................................................................................ .....228 7.1 functions of timer array unit .............................................................................................. 228 7.1.1 functions of each channel when it operates independe ntly .....................................................228 7.1.2 functions of each channel w hen it operates wit h another c hannel ...........................................229 7.1.3 lin-bus suppo rting function (c hannel 7 on ly) ...........................................................................22 9 7.2 configuration of timer array unit ............................... .........................................................23 0 user?s manual u17894ej8v0ud 11 7.3 registers controlling timer array unit ...............................................................................235 7.4 channel output (to0n pin) control ........................ .............................................................256 7.4.1 to0n pin output ci rcuit config uration.................................................................................... ....256 7.4.2 to0n pin output se tting .................................................................................................. ..........257 7.4.3 cautions on chann el output o peration..................................................................................... .257 7.4.4 collective mani pulation of to0n bits ..................................................................................... ...261 7.4.5 timer interrupt and to0n pin out put at count oper ation st art ...................................................262 7.5 channel input (ti0n pin) control. .........................................................................................263 7.5.1 ti0n edge detector ....................................................................................................... ............263 7.6 basic function of timer array un it .....................................................................................264 7.6.1 overview of single-op eration function a nd combination oper ation func tion ..............................264 7.6.2 basic rules of combin ation operatio n functi on ..........................................................................26 4 7.6.3 applicable range of basic rules of combinat ion operation functi on ........................................... 265 7.7 operation of timer array unit as independent ch annel ...................................................266 7.7.1 operation as interval timer/square wave out put ....................................................................... 266 7.7.2 operation as ex ternal event count er ...................................................................................... ..272 7.7.3 operation as frequency divider (channel 0 only ) ......................................................................275 7.7.4 operation as input pulse interval m easuremen t .......................................................................279 7.7.5 operation as input signal high-/l ow-level width measurem ent.................................................. 283 7.8 operation of plural channels of timer array unit..............................................................287 7.8.1 operation as pwm function................................................................................................ ......287 7.8.2 operation as one-shot pulse output func tion ............................................................................29 4 7.8.3 operation as multip le pwm output functi on ............................................................................. 301 chapter 8 real-time counter................................................................................................ ..308 8.1 functions of real-time counter . .........................................................................................308 8.2 configuration of real-time counter ....................... .............................................................308 8.3 registers controlling r eal-time counter ...........................................................................310 8.4 real-time counter operation .................................... ...........................................................3 25 8.4.1 starting operation of real-tim e count er .................................................................................. ...325 8.4.2 shifting to stop mode after starting operatio n ........................................................................326 8.4.3 reading/ writing real-t ime counter........................................................................................ .....327 8.4.4 setting alarm of real-time counter ....................................................................................... .....329 8.4.5 1 hz output of real-tim e count er ......................................................................................... ......330 8.4.6 32.768 khz output of real-tim e counter ................................................................................... .330 8.4.7 512 hz, 16.384 khz output of real-tim e count er ....................................................................... 330 8.4.8 example of watch error co rrection of real -time c ounter ............................................................331 chapter 9 watchdog timer ................................................................................................... ...336 9.1 functions of watchdog timer ...................................... ........................................................33 6 9.2 configuration of watchdog timer............................. ...........................................................337 9.3 register controlling watchdog time r .................................................................................338 9.4 operation of watchdog timer ..............................................................................................33 9 9.4.1 controlling operat ion of watc hdog ti mer .................................................................................. .339 9.4.2 setting overflow ti me of watc hdog ti mer.................................................................................. .340 9.4.3 setting window open period of watchdo g time r ........................................................................341 9.4.4 setting watchdog time r interval interru pt ................................................................................ ..342 user?s manual u17894ej8v0ud 12 chapter 10 clock output/buzzer output controller..............................................343 10.1 functions of clock outp ut/buzzer output controlle r ........................................................343 10.2 configuration of clock output /buzzer output controller .................................................344 10.3 registers controlling clock output/buzzer outp ut controller.........................................344 10.4 operations of clock output/buzzer output cont roller ......................................................346 10.4.1 operation as output pin ................................................................................................. ...........346 chapter 11 a/d converter ................................................................................................... .....347 11.1 function of a/d converter ................................................................................................. ...347 11.2 configuration of a/d converte r ............................................................................................ 348 11.3 registers used in a/d converter .........................................................................................35 0 11.4 a/d converter operations .................................................................................................. ...359 11.4.1 basic operations of a/d c onverter ....................................................................................... .....359 11.4.2 input volt age and conversi on results .................................................................................... ....361 11.4.3 a/d converte r operati on mode............................................................................................ ......362 11.5 temperature sensor function (expanded-specification products ( pd78f116xa) only).............................................................................................................3 64 11.5.1 configuration of temperatur e sens or ..................................................................................... ...364 11.5.2 registers used by temperatur e sens ors ................................................................................... 365 11.5.3 temperature s ensor oper ation ............................................................................................ .....367 11.5.4 procedures for usi ng temperature sensors...............................................................................3 69 11.6 how to read a/d converter char acteristics table.............................................................372 11.7 cautions for a/d converter................................................................................................ ...374 chapter 12 d/a converter ................................................................................................... .....379 12.1 function of d/a converter ................................................................................................. ...379 12.2 configuration of d/a converte r ............................................................................................ 379 12.3 registers used in d/a converter .........................................................................................38 1 12.4 operation of d/a converter................................................................................................ ...384 12.4.1 operation in norma l mode ................................................................................................ ........384 12.4.2 operation in re al-time out put m ode ...................................................................................... ....385 12.4.3 c autio ns ................................................................................................................ ...................386 chapter 13 serial array unit.............................................................................................. ...387 13.1 functions of serial array unit ............................................................................................ ..387 13.1.1 3-wire serial i/o (csi00, csi01, csi 10, csi 20) ....................................................................... 387 13.1.2 uart (uart0, uart 1, uart2, uart3) ...............................................................................388 13.1.3 simplified i 2 c (iic10, iic20) ......................................................................................................389 13.2 configuration of serial array unit ........................... ............................................................. 390 13.3 registers controlling serial array unit ...................... .........................................................395 13.4 operation stop mode....................................................................................................... ......417 13.4.1 stopping the oper ation by units ......................................................................................... .......417 13.4.2 stopping the oper ation by channels ...................................................................................... ...418 13.5 operation of 3-wire serial i/o (csi00, csi 01, csi10, csi20) communication .................420 13.5.1 master transmi ssion ..................................................................................................... ............421 13.5.2 master recept ion........................................................................................................ ...............430 user?s manual u17894ej8v0ud 13 13.5.3 master trans mission/rec eption........................................................................................... .......436 13.5.4 slave tr ansmiss ion ...................................................................................................... .............444 13.5.5 slave reception......................................................................................................... ................453 13.5.6 slave transmi ssion/reception............................................................................................ ........459 13.5.7 calculating tran sfer clock frequency.................................................................................... .....468 13.6 operation of uart (uart0, uart1, uart2, uart3) communication...........................470 13.6.1 uart tr ansmiss ion ....................................................................................................... ...........471 13.6.2 uart recept ion.......................................................................................................... ..............481 13.6.3 lin tr ansmissi on........................................................................................................ ...............488 13.6.4 lin re ception ........................................................................................................... .................491 13.6.5 calculat ing baud rate ................................................................................................... ............496 13.7 operation of simplified i 2 c (iic10, iic20) communication.................................................500 13.7.1 address fi eld trans mission.............................................................................................. ..........501 13.7.2 data tr ansmiss ion....................................................................................................... ..............506 13.7.3 data recept ion .......................................................................................................... ................509 13.7.4 stop condit ion gener ation............................................................................................... ..........513 13.7.5 calculating transfer rate ............................................................................................... ............514 13.8 processing procedure in case of error.................. .............................................................517 13.9 relationship between register settings and pins.. ...........................................................519 chapter 14 serial interface iic0 .......................................................................................... 526 14.1 functions of serial interface iic0 ............................ ............................................................ .526 14.2 configuration of serial interfac e iic0 ..................................................................................52 9 14.3 registers to controlling serial interface iic0 ....... ..............................................................532 14.4 i 2 c bus mode functions ........................................................................................................544 14.4.1 pin conf iguration....................................................................................................... ................544 14.5 i 2 c bus definitions and control methods................. ...........................................................545 14.5.1 start conditi ons........................................................................................................ .................545 14.5.2 addr esses ............................................................................................................... .................546 14.5.3 transfer direct ion specif ication........................................................................................ .........546 14.5.4 transfer clo ck setting method ........................................................................................... .......547 14.5.5 acknowle dge (ack) ....................................................................................................... ..........548 14.5.6 stop c onditio n.......................................................................................................... .................550 14.5.7 wait .................................................................................................................... ......................551 14.5.8 cance ling wa it .......................................................................................................... ................553 14.5.9 interrupt request (intiic0) generation timing and wa it cont rol .................................................554 14.5.10 address matc h detection method ......................................................................................... ....555 14.5.11 erro r detec tion........................................................................................................ ..................555 14.5.12 ext ension code......................................................................................................... ................555 14.5.13 arbi tration ............................................................................................................ .....................556 14.5.14 wak eup func tion........................................................................................................ ...............557 14.5.15 communicati on reservation.............................................................................................. ........558 14.5.16 c autio ns ............................................................................................................... ....................562 14.5.17 communica tion oper ations............................................................................................... ........563 14.5.18 timing of i 2 c interrupt request (i ntiic0) occu rrence ................................................................571 14.6 timing charts ............................................................................................................. ............592 chapter 15 multiplier ....................................................................................................... ..........599 user?s manual u17894ej8v0ud 14 15.1 functions of multiplier................................................................................................... ........599 15.2 configuration of multip lier ............................................................................................... .....600 15.3 operation of multiplier.................................................... ............................................... ........601 chapter 16 dma controller .................................................................................................. ..602 16.1 functions of dma controller ......................................... ...................................................... .602 16.2 configuration of dma controlle r..........................................................................................6 03 16.3 registers controlling dma controller .......................... .......................................................606 16.4 operation of dma controller ............................................................................................... .610 16.4.1 operatio n proc edure ..................................................................................................... ............610 16.4.2 trans fer m ode ........................................................................................................... ...............612 16.4.3 termination of dma tr ansfer ............................................................................................. .......612 16.5 example of setting of dma controller........................ .........................................................613 16.5.1 csi consecut ive trans mission ............................................................................................ ......613 16.5.2 consecutive c apturing of a/d conv ersion resu lts .....................................................................615 16.5.3 uart consecutive rec eption + ack tr ansmissi on.................................................................... 617 16.5.4 holding dma transfe r pending by dwaitn ..............................................................................619 16.5.5 forcible termi nation by software........................................................................................ .......620 16.6 cautions on using dma controller ......................................................................................621 chapter 17 interrupt functions ...........................................................................................62 3 17.1 interrupt function types.................................................................................................. .....623 17.2 interrupt sources and configuration ............................ .......................................................623 17.3 registers controlling interrupt functions ..........................................................................627 17.4 interrupt servicing operati ons ............................................................................................ .637 17.4.1 maskable interr upt ackno wledgm ent ....................................................................................... .637 17.4.2 software interrupt r equest acknow ledgm ent ............................................................................ 639 17.4.3 multiple inte rrupt servicing............................................................................................ ............640 17.4.4 interrupt request hold .................................................................................................. .............643 chapter 18 key interrupt function ....................................................................................644 18.1 functions of key interrupt ................................................ ................................................ ....644 18.2 configuration of key interrupt............................................................................................ ..644 18.3 register controlling key interrupt .............................. .........................................................6 45 chapter 19 standby function ................................................................................................ .646 19.1 standby function and configurat ion...................................................................................646 19.1.1 standby functi on........................................................................................................ ...............646 19.1.2 registers contro lling standby function .................................................................................. ....646 19.2 standby function operation................................................................................................ .649 19.2.1 halt mode ............................................................................................................... ...............649 19.2.2 stop mode............................................................................................................... ...............654 chapter 20 reset function.................................................................................................. .....661 20.1 register for confirming reset source.................................................................................669 user?s manual u17894ej8v0ud 15 chapter 21 power-on-clear circuit ....................................................................................670 21.1 functions of power-on-cl ear circuit ...................................................................................670 21.2 configuration of power-on-clear circuit.............................................................................671 21.3 operation of power-on-clear circuit ...................... .............................................................671 21.4 cautions for power-on-clear circ uit....................................................................................674 chapter 22 low-voltage detector ......................................................................................676 22.1 functions of low-voltage detector .....................................................................................676 22.2 configuration of low-voltage de tector...............................................................................677 22.3 registers controlling low-voltage detector ......................................................................677 22.4 operation of low-voltage detector........................... ...........................................................682 22.4.1 when used as re set ...................................................................................................... ...........683 22.4.2 when used as inte rrupt .................................................................................................. ..........689 22.5 cautions for low-voltage detector........................... ...........................................................695 chapter 23 regulator ........................................................................................................ ........699 23.1 regulator overview ............................................................................................................. ..699 23.2 registers controlling regulator.................................... .......................................................699 chapter 24 option byte..................................................................................................... .........701 24.1 functions of option by tes ................................................................................................. ...701 24.1.1 user option byte (000c0h to 000c2h/010c0 h to 010c 2h) ....................................................701 24.1.2 on-chip debug option byte (000c3h / 010c3 h)........................................................................ 702 24.2 format of user option byte ..................................... ........................................................... ..702 24.3 format of on-chip debug option byte ..................... ...........................................................704 24.4 setting of option byte .................................................................................................... .......705 chapter 25 flash memory.................................................................................................... .....706 25.1 writing with flash memory programmer................ .............................................................706 25.2 programming environment................................................................................................... 710 25.3 communication mode ........................................................................................................ ...710 25.4 connection of pins on board ............................................................................................... 711 25.4.1 flmd 0 pi n............................................................................................................... .................711 25.4.2 too l0 pi n............................................................................................................... .................712 25.4.3 reset pin............................................................................................................... .................712 25.4.4 port pi ns ............................................................................................................... ....................713 25.4.5 regc pin ................................................................................................................ .................713 25.4.6 x1 and x2 pi ns .......................................................................................................... ...............713 25.4.7 powe r supply............................................................................................................ ................713 25.5 registers that control flash memory ....................... ...........................................................713 25.6 programming method........................................................................................................ ....714 25.6.1 controllin g flash memory................................................................................................ ..........714 25.6.2 flash memory programmi ng m ode........................................................................................... 714 25.6.3 selecting co mmunicati on mode............................................................................................ ....715 25.6.4 communicati on commands .................................................................................................. ....715 25.7 security settings......................................................................................................... ...........717 user?s manual u17894ej8v0ud 16 25.8 processing time of each command when using pg-fp4 or pg-fp5 (reference values)........................................................................................................................ .............719 25.9 flash memory programming by self-programming .. .........................................................720 25.9.1 boot sw ap func tion ...................................................................................................... .............722 25.9.2 flash shield window fu nction ............................................................................................ ........724 chapter 26 on-chip debug function ....................................................................................725 26.1 connecting qb-mini2 to 78k0r/kg3 ............................... ....................................................725 26.2 on-chip debug security id ...................................................................................................726 26.3 securing of user resources .................................................................................................726 chapter 27 bcd correction circuit ........................... .........................................................728 27.1 bcd correction circuit f unction..........................................................................................728 27.2 registers used by bcd correction circuit .................. .......................................................728 27.3 bcd correction circuit operation........................................................................................729 chapter 28 instruction set.................................................................................................. .....731 28.1 conventions used in operation list........................... .........................................................732 28.1.1 operand identifiers and specification methods.........................................................................73 2 28.1.2 description of operation column ......................................................................................... ......733 28.1.3 description of fl ag operati on colu mn .................................................................................... ....734 28.1.4 prefix instruct ion ...................................................................................................... .............734 28.2 operation list ............................................................................................................ .............735 chapter 29 electrical specifications (standard products) .................................752 chapter 30 electrical specifications (( a) grade products) (t arget)................814 chapter 31 package drawings ...............................................................................................8 74 chapter 32 recommended soldering conditions..........................................................876 appendix a development tools..............................................................................................8 78 a.1 software package ........................................................................................................... .......881 a.2 language processing so ftware............................................................................................881 a.3 control software ........................................................................................................... .........882 a.4 flash memory programming tools ......................................................................................882 a.4.1 when using flash memory programmers pg-fp5, fl-pr5, pg -fp4 and fl -pr4...................882 a.4.2 when using on-chip d ebug emulator with progra mming function qb-mini2 ............................883 a.5 debugging tools (hardware) ................................................................................................8 83 a.5.1 when using in-circuit emulator qb- 78k0rkx 3 ........................................................................883 a.5.2 when using on-chip d ebug emulator with progra mming function qb-mini2 ............................884 a.6 debugging tools (software) ................................................................................................. 884 user?s manual u17894ej8v0ud 17 appendix b list of cautions............................................................................................... .....885 appendix c revision history ................................................................................................ ....918 c.1 major revisions in this edition............................................................................................ 918 c.2 revision history of preceding editions ................. .............................................................925 user?s manual u17894ej8v0ud 18 chapter 1 outline 1.1 differences betw een conventional-sp ecification products ( pd78f116x) and expanded- specification products ( pd78f116xa) this manual describes the functions of the 78k0r/kg3 mi crocontroller products with conventional specifications ( pd78f116x) and expanded specifications ( pd78f116xa). the differences between the conven tional-specification products ( pd78f116x) and expanded-specification products ( pd78f116xa) of the 78k0r/kg3 microcontrollers are described below. item conditions conventional- specification products expanded- specification products reference in this manual temperature sensor function channel 0 and channel 1 of the a/d converter are used. internal high-speed oscillator operating none available 11.5 temperature sensor function 4.0 v av ref0 5.5 v f ad = 0.6 to 3.6 mhz 4.0 v av ref0 5.5 v f ad = 0.33 to 3.6 mhz expansion of frequency range of conversion clock (f ad ) in a/d converter (support of low-speed conversion time) when the lv1 and lv0 bits of the a/d converter mode register (adm) are set to 0 2.7 v av ref0 < 4.0 v f ad = 0.6 to 1.8 mhz 2.7 v av ref0 < 4.0 v f ad = 0.33 to 1.8 mhz 11.3 (2) a/d converter mode register (adm) improvement of a/d converter conversion accuracy overall error when 2.7 v av ref0 < 4.0 v zero-scale error, full-scale error, integral linearity error, and differential linearity error when 2.3 v av ref0 < 4.0 v ? improved chapter 29 electrical specifications (standard products), a/d converter characteristics expansion of eeprom emulation data retention period used for updating data. when eeprom emulation library provided by nec electronics is used (usable rom size: 6 kb, which consists of 3 consecutive blocks) 3 years 5 years chapter 29 electrical specifications (standard products), flash memory programming characteristics expansion of operating voltage in simplified i 2 c mode (serial array unit) 1.8 v v dd < 2.7 v, during communication at same potential not supported supported chapter 29 electrical specifications (standard products), serial interface, (d) during communication at same potential (simplified i 2 c mode) expansion of operating voltage of external bus interface 1.8 v v dd < 2.7 v, synchronous separate/synchronous multiplexed/asynchronous separate mode not supported supported chapter 29 electrical specifications (standard products), external bus interface support for (a) grade product specifications ? not supported supported chapter 30 electrical specifications ((a) grade products) (target) chapter 1 outline user?s manual u17894ej8v0ud 19 1.2 features { minimum instruction execution time can be changed from high speed (0.05 p s: @ 20 mhz operation with high- speed system clock) to ultra low-speed (61 p s: @ 32.768 khz operation with subsystem clock) { general-purpose register: 8 bits u 32 registers (8 bits u 8 registers u 4 banks) { rom, ram capacities item part number program memory (rom) data memory (ram) p pd78f1162 p pd78f1162a 64 kb 4 kb p pd78f1163 p pd78f1163a 96 kb 6 kb p pd78f1164 p pd78f1164a 128 kb 8 kb p pd78f1165 p pd78f1165a 192 kb 10 kb p pd78f1166 p pd78f1166a 256 kb 12 kb p pd78f1167 p pd78f1167a 384 kb 24 kb p pd78f1168 p pd78f1168a flash memory 512 kb 30 kb { on-chip single-power-supply flash memory (with prohib ition of chip erase/block erase/writing function) { self-programming (with boot swap functi on/flash shield window function) { on-chip debug function { on-chip power-on-clear (poc) circuit and low-voltage detector (lvi) { on-chip watchdog timer (operable with the internal low-speed oscillation clock) { on-chip multiplier (16 bits u 16 bits) { on-chip key interrupt function { on-chip clock output/buzzer output controller { on-chip bcd adjustment { i/o ports: 88 (n-ch open drain: 4) { timer: 10 channels x 16-bit timer: 8 channels x watchdog timer: 1 channel x real-time counter: 1 channel { serial interface x csi: 2 channels/uart: 1 channel x csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel x csi: 1 channel/uart: 1 channel/simplified i 2 c: 1 channel x uart (lin-bus supported): 1 channel x i 2 c: 1 channel { 10-bit resolution a/d converter (av ref0 = 2.3 to 5.5 v): 16 channels { 8-bit resolution d/a converter (av ref1 = 1.8 to 5.5 v): 2 channels { power supply voltage: v dd = 1.8 to 5.5 v { operating ambient temperature: t a = 40 to +85 q c chapter 1 outline user?s manual u17894ej8v0ud 20 1.3 applications { home appliances x laser printer motors x clothes washers x air conditioners x refrigerators { home audio systems { digital cameras, digital video cameras chapter 1 outline user?s manual u17894ej8v0ud 21 1.4 ordering information ? flash memory version part number package quality grade pd78f1162gc-ueu-ax 100-pin plas tic lqfp (fine pitch) (14 14) standard pd78f1162agc-ueu-ax 100-pin plastic lqfp (fine pitch) (14 14) standard pd78f1163gc-ueu-ax 100-pin plas tic lqfp (fine pitch) (14 14) standard pd78f1163agc-ueu-ax 100-pin plastic lqfp (fine pitch) (14 14) standard pd78f1164gc-ueu-ax 100-pin plas tic lqfp (fine pitch) (14 14) standard pd78f1164agc-ueu-ax 100-pin plastic lqfp (fine pitch) (14 14) standard pd78f1165gc-ueu-ax 100-pin plas tic lqfp (fine pitch) (14 14) standard pd78f1165agc-ueu-ax 100-pin plastic lqfp (fine pitch) (14 14) standard pd78f1166gc-ueu-ax 100-pin plas tic lqfp (fine pitch) (14 14) standard pd78f1166agc-ueu-ax 100-pin plastic lqfp (fine pitch) (14 14) standard pd78f1167gc-ueu-ax 100-pin plas tic lqfp (fine pitch) (14 14) standard pd78f1167agc-ueu-ax 100-pin plastic lqfp (fine pitch) (14 14) standard pd78f1168gc-ueu-ax 100-pin plas tic lqfp (fine pitch) (14 14) standard pd78f1168agc-ueu-ax 100-pin plastic lqfp (fine pitch) (14 14) standard pd78f1162agc(a)-ueu-ax note 100-pin plastic lqfp (fine pitch) (14 14) special pd78f1163agc(a)-ueu-ax note 100-pin plastic lqfp (fine pitch) (14 14) special pd78f1164agc(a)-ueu-ax note 100-pin plastic lqfp (fine pitch) (14 14) special pd78f1165agc(a)-ueu-ax note 100-pin plastic lqfp (fine pitch) (14 14) special pd78f1166agc(a)-ueu-ax note 100-pin plastic lqfp (fine pitch) (14 14) special pd78f1167agc(a)-ueu-ax note 100-pin plastic lqfp (fine pitch) (14 14) special pd78f1168agc(a)-ueu-ax note 100-pin plastic lqfp (fine pitch) (14 14) special pd78f1162gf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1162agf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1163gf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1163agf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1164gf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1164agf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1165gf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1165agf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1166gf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1166agf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1167gf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1167agf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1168gf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1168agf-gas-ax 100-pin plastic lqfp (14 20) standard pd78f1162agf(a)-gas-ax note 100-pin plastic lqfp (14 20) special pd78f1163agf(a)-gas-ax note 100-pin plastic lqfp (14 20) special pd78f1164agf(a)-gas-ax note 100-pin plastic lqfp (14 20) special pd78f1165agf(a)-gas-ax note 100-pin plastic lqfp (14 20) special pd78f1166agf(a)-gas-ax note 100-pin plastic lqfp (14 20) special pd78f1167agf(a)-gas-ax note 100-pin plastic lqfp (14 20) special pd78f1168agf(a)-gas-ax note 100-pin plastic lqfp (14 20) special note under development please refer to "quality grades on nec semiconductor devices" (document no. c11531e) published by nec electronics corporation to know the specification of the quality grade on the device and its recommended applications. chapter 1 outline user?s manual u17894ej8v0ud 22 1.5 pin configuration (top view) ? 100-pin plastic lqfp (14 20) p140/pclbuz0/intp6 p141/pclbuz1/intp7 p142/sck20/scl20 p143/si20/rxd2/sda20 p144/so20/txd2 p145/ti07/to07 p00/ti00 p01/to00 p02/so10/txd1 p03/si10/rxd1/sda10 p04/sck10/scl10 p131/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 p153/ani11 p154/ani12 p155/ani13 p156/ani14 p157/ani15 av ss p50/ex8 p51/ex9 p52/ex10 p53/ex11 p54/ex12 p55/ex13 p56/ex14 p57/ex15 p17/ex31/ti02/to02 p16/ex30/ti01/to01/intp5 p15/ex29/rtcdiv/rtccl p14/ex28/rxd3 p13/ex27/txd3 p12/ex26/so00/txd0 p11/ex25/si00/rxd0 p10/ex24/sck00 av ref1 p110/ano0 p111/ano1 av ref0 ev dd0 v dd ev ss0 v ss regc p121/x1 p122/x2/exclk flmd0 p123/xt1 p124/xt2 reset p40/tool0 p41/tool1 p42/ti04/to04 p43/sck01 p44/si01 p45/so01 p46/intp1/ti05/to05 p47/intp2 p120/intp0/exlvi p60/scl0 p61/sda0 p62 p63 p31/ti03/to03/intp4 p64/rd p65/wr0 p66/wr1 p67/astb p77/ex23/kr7/intp11 p76/ex22/kr6/intp10 p75/ex21/kr5/intp9 p74/ex20/kr4/intp8 p73/ex19/kr3 p72/ex18/kr2 p71/ex17/kr1 p70/ex16/kr0 p06/wait p05/clkout ev ss1 p80/ex0 p81/ex1 p82/ex2 p83/ex3 p84/ex4 p85/ex5 p86/ex6 p87/ex7 p30/intp3/rtc1hz ev dd1 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 cautions 1. make av ss , ev ss0 , and ev ss1 the same potential as v ss . 2. make ev dd0 and ev dd1 the same potential as v dd . 3. connect the regc pin to vss via a capacitor (0.47 to 1 f). 4. p20/ani0 to p27/ani7 and p 150/ani8 to p157/ani15 are set as analog inputs in the order of p157/ani15, ?, p150/ani8, p27/ani7, ?, p20/ani 0 by the a/d port configuration register (adpc). when using p20/ani0 to p27/ani7 a nd p150/ani8 to p157/ani15 as analog inputs, start designing from p157/ani15 (see 11.3 (6) a/ d port configuration register (adpc) for details). remark when using the microcontroller for an application w here the noise generated inside the microcontroller must be reduced, it is recommended to supply separate powers to the v dd and two ev dd pins and connect the v ss and two ev ss pins to separate ground lines. chapter 1 outline user?s manual u17894ej8v0ud 23 ? 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 p157/ani15 av ss av ref0 p111/ano1 p110/ano0 av ref1 p10/ex24/sck00 p11/ex25/si00/rxd0 p12/ex26/so00/txd0 p13/ex27/txd3 p14/ex28/rxd3 p15/ex29/rtcdiv/rtccl p16/ex30/ti01/to01/intp5 p17/ex31/ti02/to02 p57/ex15 p56/ex14 p55/ex13 p54/ex12 p53/ex11 p52/ex10 p51/ex9 p50/ex8 ev dd1 p30/intp3/rtc1hz p87/ex7 p143/si20/rxd2/sda20 p144/so20/txd2 p145/ti07/to07 p00/ti00 p01/to00 p02/so10/txd1 p03/si10/rxd1/sda10 p04/sck10/scl10 p131/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 p153/ani11 p154/ani12 p155/ani13 p156/ani14 p62 p63 p31/ti03/to03/intp4 p64/rd p65/wr0 p66/wr1 p67/astb p77/ex23/kr7/intp11 p76/ex22/kr6/intp10 p75/ex21/kr5/intp9 p74/ex20/kr4/intp8 p73/ex19/kr3 p72/ex18/kr2 p71/ex17/kr1 p70/ex16/kr0 p06/wait p05/clkout ev ss1 p80/ex0 p81/ex1 p82/ex2 p83/ex3 p84/ex4 p85/ex5 p86/ex6 p142/sck20/scl20 p141/pclbuz1/intp7 p140/pclbuz0/intp6 p120/intp0/exlvi p47/intp2 p46/intp1/ti05/to05 p45/so01 p44/si01 p43/sck01 p42/ti04/to04 p41/tool1 p40/tool0 reset p124/xt2 p123/xt1 flmd0 p122/x2/exclk p121/x1 regc v ss ev ss0 v dd ev dd0 p60/scl0 p61/sda0 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 cautions 1. make av ss , ev ss0 , and ev ss1 the same potential as v ss . 2. make ev dd0 and ev dd1 the same potential as v dd . 3. connect the regc pin to vss via a capacitor (0.47 to 1 f). 4. p20/ani0 to p27/ani7 and p 150/ani8 to p157/ani15 are set as analog inputs in the order of p157/ani15, ?, p150/ani8, p27/ani7, ?, p20/ani 0 by the a/d port configuration register (adpc). when using p20/ani0 to p27/ani7 a nd p150/ani8 to p157/ani15 as analog inputs, start designing from p157/ani15 (see 11.3 (6) a/ d port configuration register (adpc) for details). remark when using the microcontroller for an application w here the noise generated inside the microcontroller must be reduced, it is recommended to supply separate powers to the v dd and two ev dd pins and connect the v ss and two ev ss pins to separate ground lines. chapter 1 outline user?s manual u17894ej8v0ud 24 pin identification ani0 to ani15: analog input ano0, ano1: analog output astb: address strobe av ref0, av ref1 : analog reference voltage av ss : analog ground clkout: clock output ev dd0, ev dd1 : power supply for port ev ss0, ev ss1 : ground for port ex0 to ex31: external extension bus 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 p06: port 0 p10 to p17: port 1 p20 to p27: port 2 p30, p31: port 3 p40 to p47: port 4 p50 to p57: port 5 p60 to p67: port 6 p70 to p77: port 7 p80 to p87: port 8 p110, p111: port 11 p120 to p124: port 12 p130, p131: port 13 p140 to p145: port 14 p150 to p157: port 15 pclbuz0, pclbuz1: pr ogrammable clock output/ buzzer output rd: read strobe regc: regulator capacitance reset: reset rtc1hz: real-time counter correction clock (1 hz) 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: serial clock input/output sda0, sda10, sda20: serial data input/output si00, si01, si10, si20: serial data input so00, so01, 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 ss : ground wait: wait wr0: lower byte write strobe wr1: upper byte write strobe x1, x2: crystal oscillator (main system clock) xt1, xt2: crystal oscillator (subsystem clock) chapter 1 outline user?s manual u17894ej8v0ud 25 1.6 78k0r/kx3 microcontroller lineup 78k0r/ke3 78k0r/kf3 78k0r/kg3 78k0r/kh3 78k0r/kj3 rom ram 64 pins 80 pins 100 pi ns 128 pins 144 pins pd78f1168 pd78f1178 512 kb 30 kb ? ? pd78f1168a pd78f1178a pd78f1188a pd78f1167 pd78f1177 384 kb 24 kb ? ? pd78f1167a pd78f1177a pd78f1187a pd78f1146 pd78f1156 pd78f1166 pd78f1176 256 kb 12 kb pd78f1146a pd78f1156a pd78f1166a pd78f1176a pd78f1186a pd78f1145 pd78f1155 pd78f1165 pd78f1175 192 kb 10 kb pd78f1145a pd78f1155a pd78f1165a pd78f1175a pd78f1185a pd78f1144 pd78f1154 pd78f1164 pd78f1174 128 kb 8 kb pd78f1144a pd78f1154a pd78f1164a pd78f1174a pd78f1184a pd78f1143 pd78f1153 pd78f1163 96 kb 6 kb pd78f1143a pd78f1153a pd78f1163a ? ? pd78f1142 pd78f1152 pd78f1162 64 kb 4 kb pd78f1142a pd78f1152a pd78f1162a ? ? chapter 1 outline user?s manual u17894ej8v0ud 26 1.7 block diagram port 0 p00 to p06 7 port 1 p10 to p17 port 2 p20 to p27 8 port 3 p30, p31 2 port 4 port 5 v ss , ev ss0, ev ss1 flmd0 v dd , ev dd0, ev dd1 8 port 6 p60 to p67 8 port 7 p70 to p77 port 12 p121 to p124 port 13 p130 8 p40 to p47 8 p50 to p57 8 port 14 p140 to p145 6 buzzer output pclbuz0/p140, pclbuz1/p141 clock output control voltage regulator regc interrupt control ram 78k/0r cpu core flash memory window watchdog timer internal low-speed oscillator power on clear/ low voltage indicator poc/lvi control reset control key return 8 kr0/p70 to kr7/p77 exlvi/p120 system control reset x1/p121 x2/exclk/p122 internal high-speed oscillator xt1/p123 xt2/p124 multiplier on-chip debug tool0/p40 tool1/p41 real-time counter direct memory access control serial array unit 0 (4 ch) uart0 serial array unit 1 (4 ch) uart3 linsel uart1 csi00 iic1 rxd0/p11 txd0/p12 rxd1/p03 txd1/p02 sck00/p10 so00/p12 si00/p11 scl10/p04 sda10/p03 rxd3/p14 txd3/p13 timer array unit (8 ch) ch 0 ch 1 ti00/p00 to00/p01 ti01/to01/p16 ch 2 ti02/to02/p17 ch 3 ti03/to03/p31 ch 4 ti04/to04/p42 ch 5 ti05/to05/p46 ch 6 ti06/to06/p131 ch 7 intp1/p46, intp2/p47 2 intp0/p120 intp5/p16 intp8/p74 to intp11/p77 4 intp3/p30, intp4/p31 2 intp6/p140, intp7/p141 2 rxd3/p14 (linsel) csi10 sck10/p04 so10/p02 si10/p03 rxd3/p14 (linsel) serial interface iic0 sda0/p61 scl0/p60 a/d converter 8 ani0/p20 to ani7/p27 av ref0 av ss 4 p120 2 port 8 p80 to p87 8 port 11 p110, p111 2 p131 port 15 p150 to p157 8 d/a converter ano0/p110, ano1/p111 av ref1 av ss 2 8 ani8/p150 to ani15/p157 external extention ex0/p80 to ex7/p87 ex8/p50 to ex15/p57 ex16/p70 to ex23/p77 csi01 sck01/p43 so01/p45 si01/p44 iic2 scl20/p142 sda20/p143 csi20 sck20/p142 so20/p144 si20/p143 8 8 ex24/p10 to ex31/p17 rxd2/p143 txd2/p144 uart2 rtc1hz/p30 rtcdiv/rtccl/p15 ti07/to07/p145 bcd adjustment 8 8 chapter 1 outline user?s manual u17894ej8v0ud 27 1.8 outline of functions (1/2) item pd78f1162, pd78f1162a pd78f1163, pd78f1163a pd78f1164, pd78f1164 a pd78f1165, pd78f1165a pd78f1166, pd78f1166a pd78f1167, pd78f1167a pd78f1168, pd78f1168a flash memory (self-programming supported) 64 kb 96 kb 128 kb 192 kb 256 kb 384 kb 512 kb internal memory ram 4 kb 6 kb 8 kb 10 kb 12 kb 24 kb 30 kb memory space 1 mb external memory expansion space 888 kb max. 824 kb max. 760 kb max. 696 kb max. 568 kb max. 440 kb max. 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 main system clock (oscillation frequency) internal high- speed oscillation clock internal oscillation 8 mhz (typ.): v dd = 1.8 to 5.5 v subsystem clock (oscillation frequency) xt1 (crystal) oscillation 32.768 khz (typ.): v dd = 1.8 to 5.5 v internal low-speed oscillation clock (for wdt) internal oscillation 240 khz (typ.): v dd = 1.8 to 5.5 v 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 61 s (subsystem clock: f sub = 32.768 khz operation) instruction set ? 8-bit operation, 16-bit operation ? multiply (8 bits 8 bits) ? bit manipulation (set, reset, test, and boolean operation), etc. i/o port total: 88 cmos i/o: 79 cmos input: 4 cmos output: 1 n-ch open-drain i/o (6 v tolerance): 4 timer ? 16-bit timer: 8 channels ? watchdog timer: 1 channel ? real-time counter: 1 channel timer outputs 8 (pwm output: 7) 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 10-bit resolution 16 channels (av ref0 = 2.3 to 5.5 v) d/a converter 8-bit resolution 2 channels (av ref1 = 1.8 to 5.5 v) chapter 1 outline user?s manual u17894ej8v0ud 28 (2/2) item pd78f1162, pd78f1162a pd78f1163, pd78f1163a pd78f1164, pd78f1164 a pd78f1165, pd78f1165a pd78f1166, pd78f1166a pd78f1167, pd78f1167a pd78f1168, pd78f1168a serial interface ? uart supporting lin-bus: 1 channel ? 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 ? i 2 c bus: 1 channel multiplier 16 bits 16 bits = 32 bits dma controller 2 channels internal 28 vectored interrupt sources external 13 key interrupt key interrupt (int kr) 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 on-chip debug function provided power supply voltage v dd = 1.8 to 5.5 v operating ambient temperature t a = ? 40 to +85 c package 100-pin plastic lqfp (14 20) (0.65 mm pitch) 100-pin plastic lqfp (14 14) (fine pitch) (0.5 mm pitch) note when instruction code ffh is executed. reset by the illegal instruction execution not issued by emulation with the in-cir cuit emulator or on-chip debug emulator. user?s manual u17894ej8v0ud 29 chapter 2 pin functions 2.1 pin function list there are five types of pin i/o buffer power supplies: av ref0 , av ref1 , ev dd0 , ev dd1 , 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 ref0 p20 to p27, p150 to p157 av ref1 p110, p111 ev dd0 , ev dd1 ? port pins other than p20 to p27, p110, p111, p121 to p124, and p150 to p157 ? reset and flmd0 pins v dd ? p121 to p124 ? pins other than port pins (excluding reset and flmd0 pins) chapter 2 pin functions user?s manual u17894ej8v0ud 30 (1) port functions (1/2) function name i/o function after reset alternate function p00 ti00 p01 to00 p02 so10/txd1 p03 si10/rxd1/sda10 p04 sck10/scl10 p05 clkout p06 i/o port 0. 7-bit i/o port. input of p03 and p04 can be set to ttl input buffer. output of p02 to p04 can be set to n-ch open-drain output (v dd tolerance). 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 wait p10 sck00/ex24 p11 si00/rxd0/ex25 p12 so00/txd0/ex26 p13 txd3/ex27 p14 rxd3/ex28 p15 rtcdiv/rtccl/ex29 p16 ti01/to01/intp5/ ex30 p17 i/o port 1. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port ti02/to02/ex31 p20 to p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani0 to ani7 p30 rtc1hz/intp3 p31 i/o port 3. 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 ti03/to03/intp4 p40 note tool0 p41 tool1 p42 ti04/to04 p43 sck01 p44 si01 p45 so01 p46 intp1/ti05/to05 p47 i/o port 4. 8-bit i/o port. input of p43 and p44 can be set to ttl input buffer. output of p43 and p45 can be set to n-ch open-drain output (v dd tolerance). 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 intp2 p50 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 ex8 to ex15 note if on-chip debugging is enabled by using an option by te, be sure to pull up the p40/tool0 pin externally (see caution in 2.2.5 p40 to p47 (port 4) ). chapter 2 pin functions user?s manual u17894ej8v0ud 31 (1) port functions (2/2) function name i/o function after reset alternate function p60 scl0 p61 sda0 p62 ? p63 ? p64 rd p65 wr0 p66 wr1 p67 i/o port 6. 8-bit i/o port. output of p60 to p63 can be set to n-ch open-drain output (6 v tolerance). input/output can be specified in 1-bit units. for only p64 to p67, use of an on-chip pull-up resistor can be specified by a software setting. input port astb p70 to p73 kr0/ex16 to kr3/ ex19 p74 to p77 i/o port 7. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port kr4/ex20/intp8 to kr7/ex23/intp11 p80 to p87 i/o port 8. 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 ex0 to ex7 p110 ano0 p111 i/o port 11. 2-bit i/o port. input/output can be specified in 1-bit units. input port ano1 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, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 p130 output output port ? p131 i/o port 13. 1-bit output port and 1-bit i/o port. for only p131, use of an on-chip pull-up resistor can be specified by a software setting. input port ti06/to06 p140 pclbuz0/intp6 p141 pclbuz1/intp7 p142 sck20/scl20 p143 si20/rxd2/sda20 p144 so20/txd2 p145 i/o port 14. 6-bit i/o port. input of p142 and p143 can be set to ttl input buffer. output of p142 to p144 can be set to the n-ch open-drain output (v dd tolerance). 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 p150 to p157 i/o port 15. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani8 to ani15 chapter 2 pin functions user?s manual u17894ej8v0ud 32 (2) non-port functions (1/3) function name i/o function after reset alternate function ani0 to ani7 input a/d converter analog input digital input port p20 to p27 ani8 to ani15 input a/d converter analog input digital input port p150 to p157 ano0 output d/a converter analog output input port p110 ano1 output d/a converter analog output input port p111 clkout output external expansion clock output input port p05 wait input external wait input input port p06 rd output read strobe signal output to external memory input port p64 wr0 output write strobe to external memory (lower 8 bits) input port p65 wr1 output write strobe to external memory (higher 8 bits) input port p66 astb output address strobe signal output to external memory input port p67 ex0 to ex7 p80 to p87 ex8 to ex15 i/o external expansion i/o p50 to p57 ex16 to ex19 p70/kr0 to p73/kr3 ex20 to ex23 p74/kr4/intp8 to p77/kr7/intp11 ex24 p10/sck00 ex25 p11/rxd0/si00 ex26 p12/txd0/so00 ex27 p13/txd3 ex28 p14/rxd3 ex29 p15/rtcdiv/rtccl ex30 p16/ti01/to01/intp5 ex31 output external expansion output input port p17/ti02/to02 exlvi input potential input for external low-voltage detection input port p120/intp0 intp0 p120/exlvi intp1 p46/ti05/to05 intp2 p47 intp3 p30/rtc1hz intp4 p31/ti03/to03 intp5 p16/ti01/to01/ex30 intp6 p140/pclbuz0 intp7 p141/pclbuz1 intp8 intp9 intp10 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 p74/kr4/ex20 to p77/kr7/ex23 kr0 to kr3 p70/ex16 to p73/ex19 kr4 to kr7 input key interrupt input input port p74/ex20/intp8 to p77/ex23/intp11 chapter 2 pin functions user?s manual u17894ej8v0ud 33 (2) non-port functions (2/3) function name i/o function after reset alternate function pclbuz0 output clock output/buzzer output input port p140/intp6 pclbuz1 p141/intp7 regc ? connecting regulator output (2.5 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 p15/rtccl/ex29 rtccl output real-time counter clock (32 khz original oscillation) output input port p15/rtcdiv/ex29 rtc1hz output real-time counter correcti on clock (1 hz) output input port p30/intp3 reset input system reset input ? ? rxd0 input serial data input to uart0 input port p11/si00/ex25 rxd1 input serial data input to uart1 input port p03/si10/sda10 rxd2 input serial data input to uart2 input port p143/si20/sda20 rxd3 input serial data input to uart3 input port p14/ex28 sck00 p10/ex24 sck01 p43 sck10 p04/scl10 sck20 i/o clock input/output for csi00, csi01, csi10, and csi20 input port p142/scl20 scl0 i/o clock input/output for i 2 c input port p60 scl10 i/o clock input/output for simplified i 2 c input port p04/sck10 scl20 i/o clock input/output for simplified i 2 c input port p142/sck20 sda0 serial data i/o for i 2 c input port p61 sda10 serial data i/o for simplified i 2 c input port p03/si10/rxd1 sda20 i/o serial data i/o for simplified i 2 c input port p143/si20/rxd2 si00 p11/rxd0/ex25 si01 p44 si10 p03/rxd1/sda10 si20 input serial data input to csi00, csi01, csi10, and csi20 input port p143/rxd2/sda20 so00 p12/txd0/ex26 so01 p45 so10 p02/txd1 so20 output serial data output from csi00, csi01, csi10, and csi20 input port p144/txd2 ti00 external count clock input to 16-bit timer 00 p00 ti01 external count clock input to 16-bit timer 01 p16/to01/intp5/ex30 ti02 external count clock input to 16-bit timer 02 p17/to02/ex31 ti03 external count clock input to 16-bit timer 03 p31/to03/intp4 ti04 external count clock input to 16-bit timer 04 p42/to04 ti05 external count clock input to 16-bit timer 05 p46/intp1/to05 ti06 external count clock input to 16-bit timer 06 p131/to06 ti07 input external count clock input to 16-bit timer 07 input port p145/to07 chapter 2 pin functions user?s manual u17894ej8v0ud 34 (2) non-port functions (3/3) function name i/o function after reset alternate function to00 16-bit timer 00 output p01 to01 16-bit timer 01 output p16/ti01/intp5/ex30 to02 16-bit timer 02 output p17/ti02/ex31 to03 16-bit timer 03 output p31/ti03/intp4 to04 16-bit timer 04 output p42/ti04 to05 16-bit timer 05 output p46/intp1/ti05 to06 16-bit timer 06 output p131/ti06 to07 output 16-bit timer 07 output input port p145/ti07 txd0 output serial data output from uart0 input port p12/so00/ex26 txd1 output serial data output from uart1 input port p02/so10 txd2 output serial data output from uart2 input port p144/so20 txd3 output serial data output from uart3 input port p13/ex27 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 (p121 to p124 and other than ports (excluding reset and flmd0 pins)) ? ? ev dd0 , ev dd1 ? positive power supply for ports (other than p20 to p27, p110, p111, p121 to p124, p150 to p157) and reset and flmd0 pins ? ? av ref0 ? ? a/d converter reference voltage input ? positive power supply for p20 to p27, p150 to p157, and a/d converter ? ? av ref1 ? ? d/a converter reference voltage input ? positive power supply for p110, p111, and d/a converter ? ? v ss ? ground potential (p121 to p124 and other than ports (excluding reset and flmd0 pins)) ? ? ev ss0 , ev ss1 ? ground potential for ports (other than p20 to p27, p110, p111, p121 to p124, and p150 to p157) and reset and flmd0 pins ? ? av ss ? ground potential for a/d converter, d/a converter, p20 to p27, p110, p111, and p150 to 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 chapter 2 pin functions user?s manual u17894ej8v0ud 35 2.2 description of pin functions 2.2.1 p00 to p06 (port 0) p00 to p06 function as a 7-bit i/o port. these pins also function as timer i/o, serial interface data i/o, clock i/o, internal system clock output, and external wait signal input. input to the p03 and p04 pins can be s pecified through a normal input buffer or a ttl input buffer in 1-bit units, using port input mode register 0 (pim0). output from the p02 to p04 pins can be specified as normal cmos output or n-ch open-drain output (v dd tolerance) in 1-bit units, using port output mode register 0 (pom0). the following operation modes can be specified in 1-bit units. (1) port mode p00 to p06 function as a 7-bit i/o port. p00 to p06 can be set to input or output port in 1-bit units using port mode register 0 (pm0). use of an on -chip pull-up resistor can be specified by pull-up resistor option register 0 (pu0). (2) control mode p00 to p06 function as timer i/o, serial interface data i/o, clock i/o, internal system clock output, and external wait signal input. (a) ti00 this is a pin for inputting an external count clock/capture trigger to 16-bit timer 00. (b) to00 this is a timer output pin of 16-bit timer 00. (c) si10 this is a serial data input pi n of serial interface csi10. (d) so10 this is a serial data output pin of serial interface csi10. (e) sck10 this is a serial clock i/o pin of serial interface csi10. (f) txd1 this is a serial data output pin of serial interface uart1. (g) rxd1 this is a serial data input pi n of serial interface uart1. (h) sda10 this is a serial data i/o pin of serial interface for simplified i 2 c. (i) scl10 this is a serial clock i/o pin of serial interface for simplified i 2 c. chapter 2 pin functions user?s manual u17894ej8v0ud 36 (j) clkout this is an internal system clock output pin. (e) wait this is an external wait signal input pin. caution to use p02/so10/txd1 and p04/sck10/ scl10 as general-pur pose ports, set serial communication operation setting register 02 (scr0 2) to the default status (0087h). in addition, clear port output mode register 0 (pom0) to 00h. 2.2.2 p10 to p17 (port 1) p10 to p17 function as an 8-bit i/o port. these pins al so function as external interrupt request input, serial interface data i/o, clock i/ o, timer i/o, real-time counter clock output, and external expansion output. the following operation modes can be specified in 1-bit units. (1) port mode p10 to p17 function as an 8-bit i/o port. p10 to p17 can be set to input or output por t in 1-bit units using port mode register 1 (pm1). use of an on -chip pull-up resistor can be specified by pull-up resistor option register 1 (pu1). (2) control mode p10 to p17 function as external inte rrupt request input, serial interface da ta i/o, clock i/o, ti mer i/o, real-time counter clock output, and external expansion output. (a) si00 this is a serial data input pi n of serial interface csi00. (b) so00 this is a serial data output pin of serial interface csi00. (c) sck00 this is a serial clock i/o pin of serial interface csi00. (d) rxd0 this is a serial data input pi n of serial interface uart0. (e) rxd3 this is a serial data input pi n of serial interface uart3. (f) txd0 this is a serial data output pin of serial interface uart0. (g) txd3 this is a serial data output pin of serial interface uart3. (h) ti01, ti02 these are the pins for inputting an external count clock/capture trigger to 16-bit timers 01 and 02. chapter 2 pin functions user?s manual u17894ej8v0ud 37 (i) to01, to02 these are the timer output pins of 16-bit timers 01 and 02. (j) intp5 this is an external interrupt request input pin for whic h the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (k) rtcdiv this is a real-time counter clo ck (32 khz, divided) output pin. (l) rtccl this is a real-time counter clock (32 kh z, original oscillation) output pin. (m) ex24 to ex31 these are the external expansion output (address bus) pins. cautions 1. to use p10/sck00/ex24 and p12/so 00/txd0/ex26 as general-purpose ports, set serial communication operation setting register 00 (s cr00) to the default status (0087h). 2. do not enable outputting rtccl and rtcdiv at the same time. 2.2.3 p20 to p27 (port 2) p20 to p27 function as an 8-bit i/o port. these pins also function as a/d converter analog input. the following operation modes can be specified in 1-bit units. (1) port mode p20 to p27 function as an 8-bit i/o port. p20 to p27 can be set to input or output por t in 1-bit units using port mode register 2 (pm2). (2) control mode p20 to p27 function as a/d converter analog input pins (ani0 to ani7). when using these pins as analog input pins, see 11.7 (6) ani0/p20 to ani7/ p27 and ani8/p150 to ani15/p157 . caution ani0/p20 to ani7/p27 are set in the digital input (general-purpose port) mode after release of reset. 2.2.4 p30, p31 (port 3) p30 and p31 function as a 2-bit i/o port. these pins also function as external interrupt request input, timer i/o, and real-time counter correction clock output. the following operation modes can be specified in 1-bit units. (1) port mode p30 and p31 function as a 2- bit i/o port. p30 and p31 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). chapter 2 pin functions user?s manual u17894ej8v0ud 38 (2) control mode p30 and p31 function as external interrupt request input, timer i/o, and real -time counter correction clock output. (a) intp3, intp4 these are the external interrupt request input pins fo r which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (b) ti03 this is a pin for inputting an external count clock/capture trigger to 16-bit timer 03. (c) to03 this is a timer output pin from 16-bit timer 03. (d) rtc1hz this is a real-time counter correction clock (1 hz) output pin. 2.2.5 p40 to p47 (port 4) p40 to p47 function as an 8-bit i/o port. these pins al so function as external interrupt request input, serial interface data i/o, clock i/ o, data i/o for a flash memory progra mmer/debugger, clock output, and timer i/o. input to the p43 and p44 pins can be specified through a normal input buffer or a ttl input buffer in 1-bit units using port input mode register 4 (pim4). output from the p43 and p45 pins can be specified as normal cmos out put or n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 4 (pom4). the following operation modes can be specified in 1-bit units. (1) port mode p40 to p47 function as an 8-bit i/o port. p40 to p47 can be set to input or output por t 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 to p47 function as serial interface data i/o, clock i/o, external interrupt reques t input, data i/o for a flash memory programmer/debugger , clock output, and timer i/o. (a) intp1, intp2 these are the external interrupt request input pins fo r which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (b) 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). chapter 2 pin functions user?s manual u17894ej8v0ud 39 (c) tool1 this is a clock output pin for a debugger. when the on-chip debug function is used, p41/tool1 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 a nd cannot be used as a port (p41). (d) ti04, ti05 these are the pins for inputting an external count clock/capture trigger to 16-bit timers 04 and 05. (e) to04, to05 these are the timer output pins from 16-bit timers 04 and 05. (f) sck01 this is a serial clock i/o pin of serial interface csi01. (g) si01 this is a serial data input pi n of serial interface csi01. (h) so01 this is a serial data output pin of serial interface csi01. 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-chi p 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 ev dd0 or ev dd1 via an external resistor , and always 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-c hip debug emulator or a flash memory programmer, or pull it up by connecting it to ev dd0 or ev dd1 via an external resistor. 2.2.6 p50 to p57 (port 5) p50 to p57 function as an 8-bit i/o port. these pins also function as external expansion i/o. the following operation modes can be specified in 1-bit units. (1) port mode p50 to p57 function as an 8-bit i/o port. p50 to p57 can be set to input or output por t 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). chapter 2 pin functions user?s manual u17894ej8v0ud 40 (2) control mode p50 to p57 function as external expansion i/o. (a) ex8 to ex15 these are the external expansion i/o (multiplex ed address/data bus, address bus, data bus) pins. 2.2.7 p60 to p67 (port 6) p60 to p67 function as an 8-bit i/o port. these pins also function as serial interface data i/o, clock i/o, read strobe signal output, write strobe signal out put, and address strobe signal output. the following operation modes can be specified in 1-bit units. (1) port mode p60 to p67 function as an 8-bit i/o port. p60 to p67 can be set to input port or output port in 1-bit units using port mode register 6 (pm6). only for p64 to p67, use of an on-chip pull-up resistor can be specified by pull-up resistor option register 6 (pu6). output of p60 to p63 is n-ch open-drain output (6 v tolerance). (2) control mode p60 to p67 function as serial interface data i/o, clock i/o, read strobe signal output, wr ite strobe signal output, and address strobe signal output. (a) sda0 this is a serial data i/o pin of serial interface iic0. (b) scl0 this is a serial clock i/o pi n of serial interface iic0. (c) rd this is a read strobe signal output pin. (d) wr0 this is a write strobe signal output (8-bit bus mode, 16-bit bus mode (lower byte)) pin. (e) wr1 this is a write strobe signal output (16-bit bus mode (higher byte)) pin. (f) astb this is an address strobe signal output pin. 2.2.8 p70 to p77 (port 7) p70 to p77 function as an 8-bit i/o port. these pins also f unction as key interrupt input, external interrupt request input, and external expansion output. the following operation modes can be specified in 1-bit units. (1) port mode p70 to p77 function as an 8-bit i/o port. p70 to p77 can be set to input or output por t in 1-bit units using port mode register 7 (pm7). use of an on -chip pull-up resistor can be specified by pull-up resistor option register 7 (pu7). chapter 2 pin functions user?s manual u17894ej8v0ud 41 (2) control mode p70 to p77 function as key interrupt input, external interrupt request input, and external expansion output. (a) kr0 to kr7 these are the key interrupt input pins (b) intp8 to intp11 these are the external interrupt request input pins fo r which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (c) ex16 to ex23 these are the external expansion output (address bus) pins. 2.2.9 p80 to p87 (port 8) p80 to p87 function as an 8-bit i/o port. these pins also function as external expansion i/o. the following operation modes can be specified in 1-bit units. (1) port mode p80 to p87 function as an 8-bit i/o port. p80 to p87 can be set to input or output por t 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 external expansion i/o. (a) ex0 to ex7 these are the external expansion i/o (mult iplexed address/data bus, data bus) pins. 2.2.10 p110, p111 (port 11) p110 and p111 function as a 2-bit i/o port. these pi ns also function as d/a converter analog output. the following operation modes can be specified in 1-bit units. (1) port mode p110 and p111 function as a 2-bit i/o port. p110 and p111 c an 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 converter analog output pins (ano0, ano1). when using these pins as analog input pins, see 12.4.3 cautions . 2.2.11 p120 to p124 (port 12) p120 function as a 1-bit i/o port. p121 to p124 functions as a 4-bit input port. these pins also function as external interrupt request input, potential input fo r external low-voltage det ection, connecting resonator for main system clock, connecting resonator for subsystem clock, and exte rnal clock input for main system clock. the following operation modes can be specified in 1-bit units. chapter 2 pin functions user?s manual u17894ej8v0ud 42 (1) port mode p120 functions as a 1-bit i/o port. p120 can be set to input 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 functions as a 4-bit input port. (2) control mode p120 to p124 function as external interrupt request in put, potential input for exter nal low-voltage detection, connecting resonator for main system clock, connecting re sonator for subsystem clock, and external clock input for main system clock. (a) intp0 this is an external interrupt request input pin for whic h the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (b) exlvi this is a potential input pin for external low-voltage detection. (c) x1, x2 these are the pins for connecting a resonator for main system clock. (d) exclk this is an external clock inpu t pin for main system clock. (e) xt1, xt2 these are the pins for connecting a resonator for subsystem clock. 2.2.12 p130, p131 (port 13) p130 functions as a 1-bit output port. p131 functions as a 1-bit i/o port. these pins also function as timer i/o. remark when the device is reset, p130 outputs a low level. therefore, to output a high level from p130 before the device is reset, the output signa l of p130 can be used as a pseudo reset signal of the cpu (see the figure for remark in 4.2.12 port 13 ). (1) port mode p130 functions as a 1-bit output port. p131 functions as a 1-bit i/o port. p131 can be set to input or output port using port mode register 13 (pm13). use of an on-chip pull-up resistor can be specified by pull-up resistor option register 13 (pu13). (2) control mode p131 functions as timer i/o. (a) ti06 this is a pin for inputting an external count clock/capture trigger to 16-bit timer 06. (b) to06 this is a timer output pin from 16-bit timer 06. chapter 2 pin functions user?s manual u17894ej8v0ud 43 2.2.13 p140 to p145 (port 14) p140 to p145 function as a 6-bit i/o port. these pins also function as timer i/o, external interrupt request input, clock/buzzer output, serial interface data i/o, and clock i/o. input to the p142 and p143 pins can be s pecified through a normal input buffer or a ttl input buffer in 1-bit units using port input mode register 14 (pim14). output from the p142 to p144 pins can be specifie d as normal cmos output or n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 14 (pom14). the following operation modes can be specified in 1-bit units. (1) port mode p140 to p145 function as a 6-bit i/o port. p140 to p145 can be set to input or output por t in 1-bit units using port mode register 14 (pm14). use of an on-chip pull-up resistor can be specified by pull-up resistor option register 14 (pu14). (2) control mode p140 to p145 function as timer i/o, external interrupt request input, clock/buzzer out put, serial interface data i/o, and clock i/o. (a) intp6, intp7 these are the external interrupt request input pins fo r which the valid edge (rising edge, falling edge, or both rising and falling edges) can be specified. (b) pclbuz0, pclbuz1 these are the clock/buzzer output pins. (c) ti07 this is a pin for inputting an external count clock/capture trigger to 16-bit timer 07. (d) to07 this is a timer output pin of 16-bit timer 07. (e) si20 this is a serial data input pi n of serial interface csi20. (f) so20 this is a serial data output pin of serial interface csi20. (g) sck20 this is a serial clock i/o pin of serial interface csi20. (h) txd2 this is a serial data output pin of serial interface uart2. (i) rxd2 this is a serial data input pi n of serial interface uart2. (j) sda20 this is a serial data i/o pin of serial interface for simplified i 2 c. chapter 2 pin functions user?s manual u17894ej8v0ud 44 (k) scl20 this is a serial clock i/o pin of serial interface for simplified i 2 c. 2.2.14 p150 to p157 (port 15) p150 to p157 function as an 8-bit i/o port. these pi ns also function as a/d converter analog input. the following operation modes can be specified in 1-bit units. (1) port mode p150 to p157 function as an 8-bit i/o port. p150 to p157 can be set to input or output port in 1-bit units using port mode register 15 (pm15). (2) control mode p150 to p157 function as a/d converter analog input pi ns (ani8 to ani15). when using these pins as analog input pins, see 11.7 (6) ani0/p20 to ani7/p 27 and ani8/p150 to ani15/p157 . caution ani8/p150 to ani15/p157 are set in the digital input (general- purpose port) mode after release of reset. 2.2.15 av ref0 this is the a/d converter reference voltage input pin an d the positive power supply pi n of p20 to p27, p150 to p157, and a/d converter. the voltage that can be supplied to av ref0 varies as follows, depending on whether p20/ani0 to p27/ani7 and p150/ani8 to p157/ani15 are used as digital i/os or analog inputs. table 2-2. av ref0 voltage applied to p20/ani0 to p 27/ani7 and p150/ani8 to p157/ani15 pins analog/digital v dd condition av ref0 voltage using at least one pin as an analog input and using all pins not as digital i/os 2.3 v v dd 5.5 v 2.3 v av ref0 v dd = ev dd0 = ev dd1 2.7 v v dd 5.5 v 2.7 v av ref0 v dd = ev dd0 = ev dd1 pins used as analog inputs and digital i/os are mixed note 2.3 v v dd < 2.7 v av ref0 has same potential as ev dd0 , ev dd1 , and v dd 2.7 v v dd 5.5 v 2.7 v av ref0 v dd = ev dd0 = ev dd1 using at least one pin as a digital i/o and using all pins not as analog inputs note 1.8 v v dd < 2.7 v av ref0 has same potential as ev dd0 , ev dd1 , and v dd note av ref0 is the reference for the i/o voltage of a port to be used as a digital port. ? high-/low-level input voltage (v ih4 /v il4 ) ? high-/low-level output voltage (v oh2 /v ol2 ) chapter 2 pin functions user?s manual u17894ej8v0ud 45 2.2.16 av ref1 this is the d/a converter reference voltage input pin and the positive power supply pin of p110, p111, and the d/a converter. the voltage that can be supplied to av ref1 varies as follows, depending on whether p110/ano0 and p111/ano1 are used as digital i/os or analog outputs. table 2-3. av ref1 voltage applied to p 110/ano0 and p111/ano1 pins analog/digital v dd condition av ref1 voltage using at least one pin as an analog output and using all pins not as digital i/os 1.8 v v dd 5.5 v 1.8 v av ref1 v dd = ev dd0 = ev dd1 2.7 v v dd 5.5 v 2.7 v av ref1 v dd = ev dd0 = ev dd1 pins used as analog outputs and digital i/os are mixed note 1.8 v v dd < 2.7 v av ref1 has same potential as ev dd0 , ev dd1 , and v dd 2.7 v v dd 5.5 v 2.7 v av ref1 v dd = ev dd0 = ev dd1 using at least one pin as a digital i/o and using all pins not as analog outputs note 1.8 v v dd < 2.7 v av ref1 has same potential as ev dd0 , ev dd1 , and v dd note av ref1 is the reference for the i/o voltage of a port to be used as a digital port. ? high-/low-level input voltage (v ih5 /v il5 ) ? high-/low-level output voltage (v oh2 /v ol2 ) 2.2.17 av ss this is the ground potential pin of a/ d converter, d/a converter, p20 to p2 7, p110, p111, and p150 to p157. even when the a/d converter and d/a converter are not used, always use this pin with the same potential as ev ss0 , ev ss1 , and v ss . 2.2.18 reset this is the active-low system reset input pin. when the external reset pin is not used, connec t this pin directly or via a resistor to ev dd0 or ev dd1 . when the external reset pin is used, design the circuit based on v dd . 2.2.19 regc this is the pin for connecting regulator output (2.5 v) stabilization capacitance for internal operation. connect this pin to v ss via a capacitor (0.47 to 1 f). however, when using the stop m ode that has been entered since operation of the internal high-speed oscillation clo ck and external main system clock, 0.47 f is recommended. 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. chapter 2 pin functions user?s manual u17894ej8v0ud 46 2.2.20 v dd , ev dd0 , ev dd1 v dd is the positive power supply pin for p121 to p124 and pins other than ports (excluding the reset and flmd0 pins). ev dd0 and ev dd1 are the positive power supply pins for ports other than p20 to p27, p110, p111, p121 to p124, and p150 to p157 as well as for the reset and flmd0 pins. 2.2.21 v ss , ev ss0 , ev ss1 v ss is the ground potential pin for p121 to p124 and pins other than ports (excluding the reset and flmd0 pins). ev ss0 and ev ss1 are the ground potential pins for ports other t han p20 to p27, p110, p111, p121 to p124, and p150 to p157 as well as for the reset and flmd0 pins. 2.2.22 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 reset. however, pulling it down must be kept selected (i.e., flmdpup = ?0?, default value) by using bit 7 (flmdpup) of the backgroun d event control register (bectl) (see 25.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 with 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 progr ammer 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 because it is internally pulled down by reset. to pull it down externally, use a resistor of 1 k to 200 k . chapter 2 pin functions user?s manual u17894ej8v0ud 47 2.3 pin i/o circuits and recommended connection of unused pins table 2-4 shows the types of pin i/o circuits and the recommended connections of unused pins. table 2-4. connection of unused pins (1/3) pin name i/o circuit type i/o recommended connection of unused pins p00/ti00 8-r p01/to00 p02/so10/txd1 5-ag p03/si10/rxd1/sda10 p04/sck10/scl10 5-an p05/clkout p06/wait p10/sck00/ex24 p11/si00/rxd0/ex25 8-r p12/so00/txd0/ex26 p13/txd3/ex27 5-ag p14/rxd3/ex28 8-r p15/rtcdiv/rtccl/ex29 5-ag p16/ti01/to01/intp5/ex30 p17/ti02/to02/ex31 8-r input: independently connect to ev dd0 , ev dd1 , ev ss0 , or ev ss1 via a resistor. output: leave open. p20/ani0 to p27/ani7 note 11-g input: independently connect to av ref0 or av ss via a resistor. output: leave open. p30/rtc1hz/intp3 p31/ti03/to03/intp4 input: independently connect to ev dd0 , ev dd1 , ev ss0 , or ev ss1 via a resistor. output: leave open. p40/tool0 8-r chapter 2 pin functions user?s manual u17894ej8v0ud 48 table 2-4. connection of unused pins (2/3) pin name i/o circuit type i/o recommended connection of unused pins p50/ex8, p51/ex9 8-r p52/ex10 to p57/ex15 5-ag input: independently connect to ev dd0 , ev dd1 , ev ss0 , or ev ss1 via a resistor. output: leave open. p60/scl0 p61/sda0 13-r p62, p63 13-p input: connect to ev ss0 or ev ss1 . output: set the port output latch to 0 and leave these pins open via low-level output. p64/rd p65/wr0 p66/wr1 p67/astb 5-ag p70/kr0/ex14 to p73/kr3/ex19 p74/kr4/ex20/intp8 to p77/kr7/ex23/intp11 8-r p80/ex0 to p87/ex7 5-ag input: independently connect to ev dd0 , ev dd1 , ev ss0 , or ev ss1 via a resistor. output: leave open. p110/ano0, p111/ano1 12-g input: independently connect to av ref1 or av ss via a resistor. output: leave open. p120/intp0/exlvi 8-r i/o input: independently connect to ev dd0 , ev dd1 , ev ss0 , or ev ss1 via a resistor. output: leave open. p121/x1 note 1 p122/x2/exclk note 1 p123/xt1 note 1 p124/xt2 note 1 37-b input independently connect to v dd or v ss via a resistor. p130 3-c output leave open. p131/ti06/to06 p140/pclbuz0/intp6 p141/pclbuz1/intp7 8-r p142/sck20/scl20 p143/si20/rxd2/sda20 5-an p144/so20/txd2 5-ag p145/ti07/to07 8-r input: independently connect to ev dd0 , ev dd1 , ev ss0 , or ev ss1 via a resistor. output: leave open. p150/ani8 to p157/ani15 note 2 11-g i/o input: independently connect to av ref0 or av ss via a resistor. output: leave open. av ref0 ? ? make this pin the same potential as ev dd0 , ev dd1 , or v dd . see 2.2.15 av ref0 when using p20 to p27 and p150 to p157. notes 1. use recommended connection above in input port mode (see figure 6-2 format of clock operation mode control register (cmc) ) when these pins are not used. 2. p150/ani8 to p157/ani15 are set in the digi tal input port mode after release of reset. chapter 2 pin functions user?s manual u17894ej8v0ud 49 table 2-4. connection of unused pins (3/3) pin name i/o circuit type i/o recommended connection of unused pins av ref1 ? ? make this pin the same potential as ev dd0 , ev dd1 , or v dd . see 2.2.16 av ref1 when using p110 and p111. av ss ? ? make this pin the same potential as ev ss0 , ev ss1 , or v ss . flmd0 2-w ? leave open or connect to v ss via a resistor of 100 k or more. reset 2 input connect directly or via a resistor to ev dd0 or ev dd1 . regc ? ? connect to v ss via capacitor (0.47 to 1 f). chapter 2 pin functions user?s manual u17894ej8v0ud 50 figure 2-1. pin i/o circuit list (1/2) type 2 type 5-ag schmitt-triggered input with hysteresis characteristics in pull-up enable data output disable input enable ev dd0, ev dd1 p-ch ev dd0, ev dd1 ev ss0, ev ss1 p-ch in/out n -ch type 2-w type 5-an in pull-down enable n-ch pull-up enable p-ch ev dd0 , ev dd1 ev ss0 , ev ss1 schmitt-triggered input with hysteresis characteristics pull-up enable data output disable p-ch ev dd0, ev dd1 ev dd0, ev dd1 ev ss0, ev ss1 p-ch in/out n -ch cmos ttl input characteristic type 3-c type 8-r ev dd0, ev dd1 p-ch n-ch data out ev ss0, ev ss1 data output disable ev dd0, ev dd1 p-ch in/out n-ch ev ss0, ev ss1 pull-up enable ev dd0, ev dd1 p-ch chapter 2 pin functions user?s manual u17894ej8v0ud 51 figure 2-1. pin i/o circuit list (2/2) type 11-g type 13-r data output disable av ref0 p-ch in/out n-ch p-ch n-ch input enable + _ av ss av ss comparator series resistor string voltage in/out n -ch data output disable ev ss0 , ev ss1 type 12-g type 37-b data output disable input enable av ref1 p-ch in/out n-ch p-ch n-ch av ss output analog voltage x1, xt1 input enable input enable amp enable p-ch n-ch x2, xt2 type 13-p data output disable input enable in/out n -ch ev ss0 , ev ss1 user?s manual u17894ej8v0ud 52 chapter 3 cpu architecture 3.1 memory space products in the 78k0r/kg3 can access a 1 mb memory s pace. figures 3-1 to 3-7 show the memory maps. figure 3-1. memory map ( pd78f1162, 78f1162a) 00000h edfffh ee000h 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 special function register (2nd sfr) 2 kb mirror 55.75 kb external expansion area note 1 888 kb max. 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 area excluding the general -purpose register area, and from the external expansion area. 2. when boot swap is not used: set the option by tes 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 25.7 security setting ). chapter 3 cpu architecture user?s manual u17894ej8v0ud 53 figure 3-2. memory map ( pd78f1163, 78f1163a) 00000h edfffh ee000h 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 special function register (2nd sfr) 2 kb mirror 53.75 kb external expansion area note 1 824 kb max. 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 1ffffh 20000h reserved notes 1. instructions can be executed from the ram area excluding the general -purpose register area, and from the external expansion area. 2. when boot swap is not used: set the option by tes 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 25.7 security setting ). chapter 3 cpu architecture user?s manual u17894ej8v0ud 54 figure 3-3. memory map ( pd78f1164, 78f1164a) 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h fdeffh fdf00h 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 8 kb general-purpose register 32 bytes flash memory 128 kb special function register (2nd sfr) 2 kb mirror 51.75 kb external expansion area note 1 824 kb max. 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 area excluding the general -purpose register area, and from the external expansion area. 2. when boot swap is not used: set the option by tes 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 25.7 security setting ). chapter 3 cpu architecture user?s manual u17894ej8v0ud 55 figure 3-4. memory map ( pd78f1165, 78f1165a) 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h fd6ffh fd700h ffedfh ffee0h ffeffh fff00h fffffh 00000h 0007fh 00080h 000bfh 000c0h 000c3h 000c4h 00fffh 01000h 0107fh 01080h 010bfh 010c0h 010c3h 010c4h 2ffffh 2ffffh 30000h special function register (sfr) 256 bytes ram note 1 10 kb general-purpose register 32 bytes flash memory 192 kb special function register (2nd sfr) 2 kb mirror 49.75 kb external expansion area note 1 760 kb max. 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 data memory space program 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 area excluding the general -purpose register area, and from the external expansion area. 2. when boot swap is not used: set the option by tes 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 25.7 security setting ). chapter 3 cpu architecture user?s manual u17894ej8v0ud 56 figure 3-5. memory map ( pd78f1166, 78f1166a) 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h fceffh fcf00h ffedfh ffee0h ffeffh fff00h fffffh 00000h 0007fh 00080h 000bfh 000c0h 000c3h 000c4h 00fffh 01000h 0107fh 01080h 010bfh 010c0h 010c3h 010c4h 3ffffh 3ffffh 40000h special function register (sfr) 256 bytes ram notes 1, 2 12 kb general-purpose register 32 bytes flash memory 256 kb special function register (2nd sfr) 2 kb mirror 47.75 kb external expansion area note 1 696 kb max. vector table area 128 bytes callt table area 64 bytes program area option byte area note 3 4 bytes vector table area 128 bytes callt table area 64 bytes option byte area note 3 4 bytes program area reserved reserved data memory space program memory space on-chip debug security id setting area note 3 10 bytes 01fffh boot cluster 0 note 4 boot cluster 1 010cdh 010ceh on-chip debug security id setting area note 3 10 bytes 000cdh 000ceh notes 1. instructions can be executed from the ram area excluding the general -purpose register area, and from the external expansion area. 2. use of the area fcf00h to fd6ffh is prohibited when using the self-programming function, since this area is used for self-programming library. 3. when boot swap is not used: set the option by tes 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. 4. writing boot cluster 0 can be prohibited depending on the setting of security (see 25.7 security setting ). chapter 3 cpu architecture user?s manual u17894ej8v0ud 57 figure 3-6. memory map ( pd78f1167, 78f1167a) 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h f9effh f9f00h ffedfh ffee0h ffeffh fff00h fffffh 00000h 0007fh 00080h 000bfh 000c0h 000c3h 000c4h 00fffh 01000h 0107fh 01080h 010bfh 010c0h 010c3h 010c4h 5ffffh 5ffffh 60000h special function register (sfr) 256 bytes ram note 1 24 kb general-purpose register 32 bytes flash memory 384 kb special function register (2nd sfr) 2 kb mirror 35.75 kb external expansion area note 1 568 kb max. 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 data memory space program 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 area excluding the general -purpose register area, and from the external expansion area. 2. when boot swap is not used: set the option by tes 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 25.7 security setting ). chapter 3 cpu architecture user?s manual u17894ej8v0ud 58 figure 3-7. memory map ( pd78f1168, 78f1168a) 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h f86ffh f8700h ffedfh ffee0h ffeffh fff00h fffffh 00000h 0007fh 00080h 000bfh 000c0h 000c3h 000c4h 00fffh 01000h 0107fh 01080h 010bfh 010c0h 010c3h 010c4h 7ffffh 7ffffh 80000h special function register (sfr) 256 bytes ram notes 1, 2 30 kb general-purpose register 32 bytes flash memory 512 kb special function register (2nd sfr) 2 kb mirror 29.75 kb external expansion area note 1 440 kb max. vector table area 128 bytes callt table area 64 bytes program area option byte area note 3 4 bytes vector table area 128 bytes callt table area 64 bytes option byte area note 3 4 bytes program area reserved reserved data memory space program memory space on-chip debug security id setting area note 3 10 bytes 01fffh boot cluster 0 note 4 boot cluster 1 010cdh 010ceh on-chip debug security id setting area note 3 10 bytes 000cdh 000ceh notes 1. instructions can be executed from the ram area excluding the general -purpose register area, and from the external expansion area. 2. use of the area f8700h to f8effh is prohibited when using the self-p rogramming function, since this area is used for self-programming library. 3. when boot swap is not used: set the option by tes 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. 4. writing boot cluster 0 can be prohibited depending on the setting of security (see 25.7 security setting ). chapter 3 cpu architecture user?s manual u17894ej8v0ud 59 remark the flash memory is divided into blocks (one block = 2 kb). for the address values and block numbers, see table 3-1 correspondence between address va lues and block numbers in flash memory . block 00h block 01h block ffh 2 kb 007ffh 00800h 00000h 00fffh 7f7ffh 7f800h 7ffffh chapter 3 cpu architecture user?s manual u17894ej8v0ud 60 correspondence between the address values and block numbers in the flash memory are shown below. table 3-1. correspondence betw een address values and block nu mbers in flash memory (1/2) address value block number address value block number address value block number address value block number 00000h to 007ffh 00h 10000h to 107ffh 20h 20000h to 207ffh 40h 30000h to 307ffh 60h 00800h to 00fffh 01h 10800h to 10fffh 21h 20800h to 20fffh 41h 30800h to 30fffh 61h 01000h to 017ffh 02h 11000h to 117ffh 22h 21000h to 217ffh 42h 31000h to 317ffh 62h 01800h to 01fffh 03h 11800h to 11fffh 23h 21800h to 21fffh 43h 31800h to 31fffh 63h 02000h to 027ffh 04h 12000h to 127ffh 24h 22000h to 227ffh 44h 32000h to 327ffh 64h 02800h to 02fffh 05h 12800h to 12fffh 25h 22800h to 22fffh 45h 32800h to 32fffh 65h 03000h to 037ffh 06h 13000h to 137ffh 26h 23000h to 237ffh 46h 33000h to 337ffh 66h 03800h to 03fffh 07h 13800h to 13fffh 27h 23800h to 23fffh 47h 33800h to 33fffh 67h 04000h to 047ffh 08h 14000h to 147ffh 28h 24000h to 247ffh 48h 34000h to 347ffh 68h 04800h to 04fffh 09h 14800h to 14fffh 29h 24800h to 24fffh 49h 34800h to 34fffh 69h 05000h to 057ffh 0ah 15000h to 157ffh 2ah 25000h to 257ffh 4ah 35000h to 357ffh 6ah 05800h to 05fffh 0bh 15800h to 15fffh 2bh 25800h to 25fffh 4bh 35800h to 35fffh 6bh 06000h to 067ffh 0ch 16000h to 167ffh 2ch 26000h to 267ffh 4ch 36000h to 367ffh 6ch 06800h to 06fffh 0dh 16800h to 16fffh 2dh 26800h to 26fffh 4dh 36800h to 36fffh 6dh 07000h to 077ffh 0eh 17000h to 177ffh 2eh 27000h to 277ffh 4eh 37000h to 377ffh 6eh 07800h to 07fffh 0fh 17800h to 17fffh 2fh 27800h to 27fffh 4fh 37800h to 37fffh 6fh 08000h to 087ffh 10h 18000h to 187ffh 30h 28000h to 287ffh 50h 38000h to 387ffh 70h 08800h to 08fffh 11h 18800h to 18fffh 31h 28800h to 28fffh 51h 38800h to 38fffh 71h 09000h to 097ffh 12h 19000h to 197ffh 32h 29000h to 297ffh 52h 39000h to 397ffh 72h 09800h to 09fffh 13h 19800h to 19fffh 33h 29800h to 29fffh 53h 39800h to 39fffh 73h 0a000h to 0a7ffh 14h 1a000h to 1a7ffh 34h 2a000h to 2a7ffh 54h 3a000h to 3a7ffh 74h 0a800h to 0afffh 15h 1a800h to 1afffh 35h 2a800h to 2afffh 55h 3a800h to 3afffh 75h 0b000h to 0b7ffh 16h 1b000h to 1b7ffh 36h 2b000h to 2b7ffh 56h 3b000h to 3b7ffh 76h 0b800h to 0bfffh 17h 1b800h to 1bfffh 37h 2b800h to 2bfffh 57h 3b800h to 3bfffh 77h 0c000h to 0c7ffh 18h 1c000h to 1c7ffh 38h 2c000h to 2c7ffh 58h 3c000h to 3c7ffh 78h 0c800h to 0cfffh 19h 1c800h to 1cfffh 39h 2c800h to 2cfffh 59h 3c800h to 3cfffh 79h 0d000h to 0d7ffh 1ah 1d000h to 1d7ffh 3ah 2d000h to 2d7ffh 5ah 3d000h to 3d7ffh 7ah 0d800h to 0dfffh 1bh 1d800h to 1dfffh 3bh 2d800h to 2dfffh 5bh 3d800h to 3dfffh 7bh 0e000h to 0e7ffh 1ch 1e000h to 1e7ffh 3ch 2e000h to 2e7ffh 5ch 3e000h to 3e7ffh 7ch 0e800h to 0efffh 1dh 1e800h to 1efffh 3dh 2e800h to 2efffh 5dh 3e800h to 3efffh 7dh 0f000h to 0f7ffh 1eh 1f000h to 1f7ffh 3eh 2f000h to 2f7ffh 5eh 3f000h to 3f7ffh 7eh 0f800h to 0ffffh 1fh 1f800h to 1ffffh 3fh 2f800h to 2ffffh 5fh 3f800h to 3ffffh 7fh remark pd78f1162, 78f1162a: block numbers 00h to 1fh pd78f1163, 78f1163a: block numbers 00h to 2fh pd78f1164, 78f1164a: block numbers 00h to 3fh pd78f1165, 78f1165a: block numbers 00h to 5fh pd78f1166, 78f1166a: block numbers 00h to 7fh pd78f1167, 78f1167a: block numbers 00h to bfh pd78f1168, 78f1168a: block numbers 00h to ffh chapter 3 cpu architecture user?s manual u17894ej8v0ud 61 table 3-1. correspondence betw een address values and block nu mbers in flash memory (2/2) address value block number address value block number address value block number address value block number 40000h to 407ffh 80h 50000h to 507ffh a0h 60000h to 607ffh c0h 70000h to 707ffh e0h 40800h to 40fffh 81h 50800h to 50fffh a1h 60800h to 60fffh c1h 70800h to 70fffh e1h 41000h to 417ffh 82h 51000h to 517ffh a2h 61000h to 617ffh c2h 71000h to 717ffh e2h 41800h to 41fffh 83h 51800h to 51fffh a3h 61800h to 61fffh c3h 71800h to 71fffh e3h 42000h to 427ffh 84h 52000h to 527ffh a4h 62000h to 627ffh c4h 72000h to 727ffh e4h 42800h to 42fffh 85h 52800h to 52fffh a5h 62800h to 62fffh c5h 72800h to 72fffh e5h 43000h to 437ffh 86h 53000h to 537ffh a6h 63000h to 637ffh c6h 73000h to 737ffh e6h 43800h to 43fffh 87h 53800h to 53fffh a7h 63800h to 63fffh c7h 73800h to 73fffh e7h 44000h to 447ffh 88h 54000h to 547ffh a8h 64000h to 647ffh c8h 74000h to 747ffh e8h 44800h to 44fffh 89h 54800h to 54fffh a9h 64800h to 64fffh c9h 74800h to 74fffh e9h 45000h to 457ffh 8ah 55000h to 557ffh aah 65000h to 657ffh cah 75000h to 757ffh eah 45800h to 45fffh 8bh 55800h to 55fffh abh 65800h to 65fffh cbh 75800h to 75fffh ebh 46000h to 467ffh 8ch 56000h to 567ffh ach 66000h to 667ffh cch 76000h to 767ffh ech 46800h to 46fffh 8dh 56800h to 56fffh adh 66800h to 66fffh cdh 76800h to 76fffh edh 47000h to 477ffh 8eh 57000h to 577ffh aeh 67000h to 677ffh ceh 77000h to 777ffh eeh 47800h to 47fffh 8fh 57800h to 57fffh afh 67800h to 67fffh cfh 77800h to 77fffh efh 48000h to 487ffh 90h 58000h to 587ffh b0h 68000h to 687ffh d0h 78000h to 787ffh f0h 48800h to 48fffh 91h 58800h to 58fffh b1h 68800h to 68fffh d1h 78800h to 78fffh f1h 49000h to 497ffh 92h 59000h to 597ffh b2h 69000h to 697ffh d2h 79000h to 797ffh f2h 49800h to 49fffh 93h 59800h to 59fffh b3h 69800h to 69fffh d3h 79800h to 79fffh f3h 4a000h to 4a7ffh 94h 5a000h to 5a7ffh b4h 6a000h to 6a7ffh d4h 7a000h to 7a7ffh f4h 4a800h to 4afffh 95h 5a800h to 5afffh b5h 6a800h to 6afffh d5h 7a800h to 7afffh f5h 4b000h to 4b7ffh 96h 5b000h to 5b7ffh b6h 6b000h to 6b7ffh d6h 7b000h to 7b7ffh f6h 4b800h to 4bfffh 97h 5b800h to 5bfffh b7h 6b800h to 6bfffh d7h 7b800h to 7bfffh f7h 4c000h to 4c7ffh 98h 5c000h to 5c7ffh b8h 6c000h to 6c7ffh d8h 7c000h to 7c7ffh f8h 4c800h to 4cfffh 99h 5c800h to 5cfffh b9h 6c800h to 6cfffh d9h 7c800h to 7cfffh f9h 4d000h to 4d7ffh 9ah 5d000h to 5d7ffh bah 6d000h to 6d7ffh dah 7d000h to 7d7ffh fah 4d800h to 4dfffh 9bh 5d800h to 5dfffh bbh 6d800h to 6dfffh dbh 7d800h to 7dfffh fbh 4e000h to 4e7ffh 9ch 5e000h to 5e7ffh bch 6e000h to 6e7ffh dch 7e000h to 7e7ffh fch 4e800h to 4efffh 9dh 5e800h to 5efffh bdh 6e800h to 6efffh ddh 7e800h to 7efffh fdh 4f000h to 4f7ffh 9eh 5f000h to 5f7ffh beh 6f000h to 6f7ffh deh 7f000h to 7f7ffh feh 4f800h to 4ffffh 9fh 5f800h to 5ffffh bfh 6f800h to 6ffffh dfh 7f800h to 7ffffh ffh remark pd78f1162, 78f1162a: block numbers 00h to 1fh pd78f1163, 78f1163a: block numbers 00h to 2fh pd78f1164, 78f1164a: block numbers 00h to 3fh pd78f1165, 78f1165a: block numbers 00h to 5fh pd78f1166, 78f1166a: block numbers 00h to 7fh pd78f1167, 78f1167a: block numbers 00h to bfh pd78f1168, 78f1168a: block numbers 00h to ffh chapter 3 cpu architecture user?s manual u17894ej8v0ud 62 3.1.1 internal program memory space the internal program memory space st ores the program and table data. 78k0r/kg3 products incorporate internal rom (flash memory), as shown below. table 3-2. intern al rom capacity internal rom part number structure capacity pd78f1162, 78f1162a 65536 8 bits (00000h to 0ffffh) pd78f1163, 78f1163a 98303 8 bits (00000h to 17fffh) pd78f1164, 78f1164a 131071 8 bits (00000h to 1ffffh) pd78f1165, 78f1165a 196607 8 bits (00000h to 2ffffh) pd78f1166, 78f1166a 262143 8 bits (00000h to 3ffffh) pd78f1167, 78f1167a 393215 8 bits (00000h to 5ffffh) pd78f1168, 78f1168a flash memory 524287 8 bits (00000h to 7ffffh) 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 pr ogram start addresses for branch upon reset or generation of each interrupt request ar e stored in the vector tabl e area. furthermore, the interrupt jump address is a 64 k ad dress of 00000h to 0ffffh, because the vector code is assumed to be 2 bytes. of the 16-bit address, the lower 8 bits are stored at ev en addresses and the higher 8 bits are stored at odd addresses. chapter 3 cpu architecture user?s manual u17894ej8v0ud 63 table 3-3. vector table vector table address interrupt source vector table address interrupt source 0002ch inttm00 00000h reset input, poc, lvi, wdt, trap 0002eh inttm01 00004h intwdti 00030h inttm02 00006h intlvi 00032h inttm03 00008h intp0 00034h intad 0000ah intp1 00036h intrtc 0000ch intp2 00038h intrtci 0000eh intp3 0003ah intkr 00010h intp4 0003ch intst2/intcsi20/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 0001eh intst0/intcsi00 0004ah intp6 00020h intsr0/intcsi01 0004ch intp7 00022h intsre0 0004eh intp8 00024h intst1/intcsi10/intiic10 00050h intp9 00026h intsr1 00052h intp10 00028h intsre1 00054h intp11 0002ah intiic0 0007eh brk (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 addr ess to a value in a range of 00000h to 0ffffh (becaus e 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 opt ion byte area. set the option byte at 010c0h to 010c3h when the boot swap is used. for details, see chapter 24 option byte . (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 010c dh when the boot swap is used. for details, see chapter 26 on-chip debug function . chapter 3 cpu architecture user?s manual u17894ej8v0ud 64 3.1.2 mirror area the pd78f1162 and 78f1162a mirror the data flash area of 00000h to 0ffffh, to f0000h to fffffh. the pd78f1163, 78f1163a, 78f1164, 78f1164a, 78f 1165, 78f1165a, 78f1166, 78f1166a, 78f1167, 78f1167a, 78f1168, and 78f1168a mirror the data fl ash 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 th at does not have the es registers as an operand can be used, and thus the content s of the data flash can be read wi th the shorter code. howeve r, the data flash area is not mirrored to the sfr, extended sfr, ram, and use prohibited areas. see 3.1 memory space for the mirror area of each product. the mirror area can only be read and no instruction can be fetched from this area. the following show examples. example 1 pd78f1162, 78f1162a example 2 pd78f1166, 78f1166a (flash memory: 64 kb, ram: 4 kb) (flash memory: 256 kb, ram: 12 kb) setting maa = 0 setting maa = 1 flash memory flash memory flash memory 01000h 00fffh 00000h 0ef00h 0eeffh 10000h 0ffffh mirror ee000h edfffh 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) special-function register (2nd sfr) 2 kb external expansion area 888 kb max. reserved reserved special-function register ( sfr) 256 bytes fffffh general-purpose register 32 bytes ffee0h ffedfh fff00h ffeffh ram 12 kb fcf00h fceffh flash memory (same data as 11000h to 1ceffh) f0800h f07ffh f1000h f0fffh reserved special-function register (2nd sfr) 2 kb ee000h edfffh f0000h effffh reserved mirror external expansion area 696 kb max. 40000h 3ffffh 00000h 1cf00h 1ceffh 11000h 10fffh flash memory flash memory flash memory remark maa: bit 0 of the processor mode control register (pmc) pmc register is described below. chapter 3 cpu architecture user?s manual u17894ej8v0ud 65 ? 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-8. format 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 settings 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 pd78f1162 or 78f1162a is used, be sure to set bit 0 (maa) of this register to 0. 3.1.3 internal data memory space 78k0r/kg3 products incorporate the following rams. table 3-4. internal ram capacity part number internal ram pd78f1162, 78f1162a 4096 8 bits (fef00h to ffeffh) pd78f1163, 78f1163a 6144 8 bits (fe700h to ffeffh) pd78f1164, 78f1164a 8192 8 bits (fdf00h to ffeffh) pd78f1165, 78f1165a 10240 8 bits (fd700h to ffeffh) pd78f1166, 78f1166a 12288 8 bits (fcf00h to ffeffh) pd78f1167, 78f1167a 24576 8 bits (f9f00h to ffeffh) pd78f1168, 78f1168a 30720 8 bits (f8700h to ffeffh) the internal ram can be used as a data area and a program area where instructions ar e written and executed. four general-purpose register banks consisting of eight 8-bi t registers per bank are assigned to the 32-byte area of ffee0h to ffeffh of the internal ra m area. however, instructions cannot be executed by using general-purpose registers. the internal ram is used as a stack memory. cautions 1. it is prohibited 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. furthermore, the areas of fcf 00h to fd6ffh and f8700h to f8effh also cannot be used as stack memories with the pd78f1166 and 78f1166a, and pd78f1168 and 78f1168a, respectively. chapter 3 cpu architecture user?s manual u17894ej8v0ud 66 3.1.4 special function register (sfr) area on-chip peripheral hardware s pecial function registers (sfrs) are allo cated in the area fff00h to fffffh (see table 3-5 in 3.2.4 special function registers (sfrs) ). 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 (2 nd sfrs) are allocated in the area f0000h to f07ffh (see table 3-6 in 3.2.5 extended special function register s (2nd sfrs: 2nd special function registers) ). sfrs other than those in th e sfr area (fff00h to fffffh) are allocated to this area. an instruction that accesses the extended sfr area, however, is 1 byte l onger than an instruction t hat accesses the sfr area. caution do not access addresses to wh ich the 2nd sfr is not assigned. chapter 3 cpu architecture user?s manual u17894ej8v0ud 67 3.1.6 data memory addressing addressing refers to the method of specifying the address of the instruction to be ex ecuted next or the address of the register or memory relevant to the execution of instructions. several addressing modes are provided for addressing the memo ry relevant to the executi on of instructions for the 78k0r/kg3, based on operability and other considerations. for areas containing data memory in particular, special addressing methods designed for the functions of special function registers (sfr) and general-purpose registers are available for use. figures 3-9 to 3-15 show corre spondence between data memory and addressing. figure 3-9. correspondence between data memory and addressing ( pd78f1162, 78f1162a) special function register (sfr) 256 bytes ram 4 kb general-purpose register 32 bytes flash memory 64 kb special function register (2nd sfr) 2 kb mirror 55.75 kb external expansion area 888 kb max. reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h 0ffffh 10000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h feeffh fef00h ffe1fh ffe20h ffedfh ffee0h ffeffh fff00h fff1fh fff20h fffffh chapter 3 cpu architecture user?s manual u17894ej8v0ud 68 figure 3-10. correspondence between data memory and addressing ( pd78f1163, 78f1163a) special function register (sfr) 256 bytes ram 6 kb general-purpose register 32 bytes flash memory 96 kb special function register (2nd sfr) 2 kb mirror 53.75 kb external expansion area 824 kb max. reserved reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h 17fffh 18000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h fe6ffh fe700h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh 1ffffh 20000h chapter 3 cpu architecture user?s manual u17894ej8v0ud 69 figure 3-11. correspondence between data memory and addressing ( pd78f1164, 78f1164a) special function register (sfr) 256 bytes ram 8 kb general-purpose register 32 bytes flash memory 128 kb special function register (2nd sfr) 2 kb mirror 51.75 kb external expansion area 824 kb max. reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h fdeffh fdf00h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh 1ffffh 20000h chapter 3 cpu architecture user?s manual u17894ej8v0ud 70 figure 3-12. correspondence between data memory and addressing ( pd78f1165, 78f1165a) special function register (sfr) 256 bytes ram 10 kb general-purpose register 32 bytes flash memory 192 kb special function register (2nd sfr) 2 kb mirror 49.75 kb external expansion area 760 kb max. reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h fd6ffh fd700h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh 2ffffh 30000h chapter 3 cpu architecture user?s manual u17894ej8v0ud 71 figure 3-13. correspondence between data memory and addressing ( pd78f1166, 78f1166a) special function register (sfr) 256 bytes ram note 12 kb general-purpose register 32 bytes flash memory 256 kb special function register (2nd sfr) 2 kb mirror 47.75 kb external expansion area 696 kb max. reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h fceffh fcf00h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh 3ffffh 40000h note use of the area fcf00h to fd6ffh is prohibited when using the self-programming function, since this area is used for self-programming library. chapter 3 cpu architecture user?s manual u17894ej8v0ud 72 figure 3-14. correspondence between data memory and addressing ( pd78f1167, 78f1167a) special function register (sfr) 256 bytes ram 24 kb general-purpose register 32 bytes flash memory 384 kb special function register (2nd sfr) 2 kb mirror 35.75 kb external expansion area 568 kb max. reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h f9effh f9f00h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh 5ffffh 60000h chapter 3 cpu architecture user?s manual u17894ej8v0ud 73 figure 3-15. correspondence between data memory and addressing ( pd78f1168, 78f1168a) special function register (sfr) 256 bytes ram note 30 kb general-purpose register 32 bytes flash memory 512 kb special function register (2nd sfr) 2 kb mirror 29.75 kb external expansion area 440 kb max. reserved reserved direct addressing register indirect addressing based addressing based indexed addressing short direct addressing sfr addressing register addressing 00000h edfffh ee000h effffh f0000h f07ffh f0800h f0fffh f1000h f86ffh f8700h ffedfh ffee0h ffeffh fff00h fff1fh fff20h ffe1fh ffe20h fffffh 7ffffh 80000h note use of the area f8700h to f8effh is prohibited when using the self-programming function, since this area is used for self-programming library. chapter 3 cpu architecture user?s manual u17894ej8v0ud 74 3.2 processor registers the 78k0r/kg3 products incorporate 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 acco rding to the number of byte s of the instruction to be fetched. when a branch instruction is execut ed, immediate data and regi ster contents are set. reset signal generation sets the reset vector table va lues at addresses 0000h and 0001h to the program counter. figure 3-16. 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 vector interrupt request acknowledgment or push psw instruction execution and are restored upon ex ecution of the retb, reti and pop psw instructions. reset signal generation sets psw to 06h. figure 3-17. 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 acknowledgment 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 executi on 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 t he register bank selected by sel rbn instruction execution is stored. chapter 3 cpu architecture user?s manual u17894ej8v0ud 75 (d) auxiliary carry flag (ac) if the operation result has a carry from bit 3 or a borrow at bi t 3, this flag is set (1). it is reset (0) in all other cases. (e) in-service priority flags (isp1, isp0) this flag manages the priority of acknowledgeable maskabl e vectored interrupts. vectored interrupt requests specified lower than the value of i sp0 and isp1 by a priority specif ication flag register (prn0l, prn0h, prn1l, prn1h, prn2l, prn2h) (see 17.3 (3) ) cannot be acknowledged. act ual request 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 accumulator during bit operation instruction execution. (3) stack pointer (sp) this is a 16-bit register to hold the start address of the memory stack area. only the internal ram area can be set as the stack area. figure 3-18. 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 (save) to the stack memory and is incremented after read (restored) from the stack memory. each stack operation saves data as shown in figure 3-19. cautions 1. since reset signal generation makes the sp contents undefined, be su re to initialize the sp before using the stack. 2. it is prohibited to use the general-pur pose register (ffee0h 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. furthermore, the areas of fcf00h to fd6ffh and f8700h to f8effh also cannot be used as stack memories with the pd78f1166 and 78f1166a, and pd78f1168 and 78f1168a, respectively. chapter 3 cpu architecture user?s manual u17894ej8v0ud 76 figure 3-19. 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 rp 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 ffeffh) of the data memory. the general-purpose registers consists of 4 bank s, each bank consisting of eight 8-bit r egisters (x, a, c, b, e, d, l, and h). each register can be used as an 8-bit register, and two 8-bit r egisters can also be used in a pair as a 16-bit register (ax, bc, de, and hl). these registers can be described in terms of function names (x, a, c, b, e, d, l, h, ax, bc, de, and hl) and absolute names (r0 to r7 and rp0 to rp3). register banks to be used for instructi on execution are set by the cpu control instruction (sel rbn). because of the 4-register bank configuration, an efficient program ca n be created by switching between a register for normal processing and a register for interrupts for each bank. caution it is prohibited to u se the general-purpose register (ff ee0h to ffeffh) space for fetching instructions or as a stack area. chapter 3 cpu architecture user?s manual u17894ej8v0ud 77 figure 3-20. 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 78 3.2.3 es and cs registers the es register is used for data acce ss and the cs register is used to specify 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-21. 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 79 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-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 t he 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 instruction operand (sfr). this manipulation can also be specified with an address. ? 16-bit manipulation describe the symbol reserved by the assembler for t he 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 di rective in the cc78k0r. when using the ra78k0r, id78k0r-qb, and sm+ for 78k0r, symbols c an 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 functi on registers (2nd sfrs: 2nd special function registers) . chapter 3 cpu architecture user?s manual u17894ej8v0ud 80 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 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 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 fff1ch 8-bit d/a conversion value setting register 0 dacs0 r/w ? 00h fff1dh 8-bit d/a conversion value setting register 1 dacs1 r/w ? 00h fff1eh 10-bit a/d conversion result register 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 fff28h port mode register 8 pm8 r/w ? ffh fff2bh port mode register 11 pm11 r/w ? ffh fff2ch port mode register 12 pm12 r/w ? ffh fff2dh port mode register 13 pm13 r/w ? feh fff2eh port mode register 14 pm14 r/w ? ffh fff2fh port mode register 15 pm15 r/w ? ffh chapter 3 cpu architecture user?s manual u17894ej8v0ud 81 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 fff30h a/d converter mode register adm r/w ? 00h fff31h analog input channel specification register ads r/w ? 00h fff32h d/a converter mode register dam 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 falli ng edge enable register 0 egn0 r/w ? 00h fff3ah external interrupt rising edge enable register 1 egp1 r/w ? 00h fff3bh external interrupt falli ng 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 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 r/w ? fff4bh serial data register 11 ? sdr11 ? ? 0000h fff50h iic shift register 0 iic0 r/w ? ? 00h fff51h iic flag register 0 iicf0 r/w ? 00h fff52h iic control register 0 iicc0 r/w ? 00h fff53h iic slave address register 0 sva0 r/w ? ? 00h fff54h iic clock select register 0 iiccl0 r/w ? 00h fff55h iic function expansion register 0 iicx0 r/w ? 00h fff56h iic status register 0 iics0 r ? 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 82 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 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 1 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 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 system 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 ? ? 00h note 2 fffa9h low-voltage detection register lvim r/w ? 00h note 3 fffaah low-voltage detection level select register lvis r/w ? 0eh note 4 fffabh watchdog timer enable register wdte r/w ? ? 1a/9a note 5 fffach fffadh ? ttblh note 6 ? ? ? ? undefined fffaeh fffafh ? ttbll note 6 ? ? ? ? undefined notes 1. the value of this register is 00h if the ampm bit (bit 3 of the rtcc0 register) is set to 1 after reset. 2. the reset value of resf varies depending on the reset source. 3. the reset value of lvim varies depending on the reset source and the setting of the option byte. 4. the reset value of lvis varies depending on the reset source. 5. the reset value of wdte is determined by the setting of the option byte. 6. do not directly operate this sfr, bec ause it cannot be used by the user. chapter 3 cpu architecture user?s manual u17894ej8v0ud 83 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 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 ? ? ? ? undefined fffc2h ? pfs note ? ? ? ? undefined fffc4h ? flpmc note ? ? ? ? undefined fffd0h interrupt request flag register 2l if2l r/w 00h fffd1h interrupt request flag register 2h if2h if2 r/w 00h fffd4h interrupt mask flag register 2l mk2l r/w ffh fffd5h interrupt mask flag register 2h mk2h mk2 r/w ffh fffd8h priority specificati on flag register 02l pr02l r/w ffh fffd9h priority specification flag register 02h pr02h pr02 r/w ffh fffdch priority specification flag register 12l pr12l r/w ffh fffddh priority specification flag register 12h pr12h pr12 r/w ffh 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 r/w ffh fffe5h interrupt mask flag register 0h mk0h mk0 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 specification flag register 00h pr00h pr00 r/w ffh fffeah priority specificati on flag register 01l pr01l r/w ffh fffebh priority specification flag register 01h pr01h pr01 r/w ffh fffech priority specification flag register 10l pr10l r/w ffh fffedh priority specification flag register 10h pr10h pr10 r/w ffh note do not directly operate this sf r, because it is to be used in the self programming library. chapter 3 cpu architecture user?s manual u17894ej8v0ud 84 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 fffeeh priority specificati on flag register 11l pr11l r/w ffh fffefh priority specification flag register 11h pr11h pr11 r/w ffh ffff0h ffff1h multiplication input data register a mula r/w ? ? 0000h ffff2h ffff3h multiplication input data register b mulb r/w ? ? 0000h ffff4h ffff5h higher multiplication result storage register muloh r ? ? 0000h ffff6h ffff7h lower multiplication result storage register mulol r ? ? 0000h ffffeh processor mode control register pmc r/w ? 00h fffffh memory extension mode control register mem r/w ? 00h remark for extended sfrs (2nd sfrs), see table 3-6 extended sfr (2nd sfr) list . chapter 3 cpu architecture user?s manual u17894ej8v0ud 85 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 f0 000h to f07ffh area. sfrs other than those in the sfr area (fff00h to fffffh) are allocated to this area. an instruction that accesse s the extended sfr area, however, is 1 byte longer than an instruction that accesses the sfr area. extended sfrs can be manipulated like general-purpose regist ers, using operation, trans fer, 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 t he 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 extended sfr. it is a reserved word in the ra78k0r, and is defined as an sfr variable using the #pragma sfr di rective in the 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 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 wh ich the 2nd sfr is not assigned. remark for sfrs in the sfr area, see 3.2.4 special functi on registers (sfrs) . chapter 3 cpu architecture user?s manual u17894ej8v0ud 86 table 3-6. extended sfr (2nd sfr) list (1/5) manipulable bit range address special function regist er (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 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 f0036h pull-up resistor option register 6 pu6 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 f003ch pull-up resistor option register 12 pu12 r/w ? 00h f003dh pull-up resistor option register 13 pu13 r/w ? 00h f003eh pull-up resistor option register 14 pu14 r/w ? 00h f0040h port input mode register 0 pim0 r/w ? 00h f0044h port input mode register 4 pim4 r/w ? 00h f004eh port input mode register 14 pim14 r/w ? 00h f0050h port output mode register 0 pom0 r/w ? 00h f0054h port output mode register 4 pom4 r/w ? 00h f005eh port output mode register 14 pom14 r/w ? 00h f0060h noise filter enable register 0 nfen0 r/w ? 00h f0061h noise filter enable register 1 nfen1 r/w ? 00h f00f0h peripheral enable register 0 per0 r/w ? 00h f00f1h peripheral enable register 1 per1 r/w ? 00h f00f2h internal high-speed oscilla tor trimming register hiotrm r/w ? ? 10h f00f3h operation speed mode control register osmc r/w ? ? 00h f00f4h regulator mode control register rmc 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 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 87 table 3-6. extended sfr (2nd sfr) list (2/5) manipulable bit range address special function regist er (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 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 se tting register 00 scr00 r/w ? ? 0087h f011ah f011bh serial communication operation se tting register 01 scr01 r/w ? ? 0087h f011ch f011dh serial communication operation se tting register 02 scr02 r/w ? ? 0087h f011eh f011fh serial communication operation se tting register 03 scr03 r/w ? ? 0087h f0120h se0l f0121h serial channel enable status register 0 ? se0 r ? ? 0000h f0122h ss0l f0123h serial channel start trigger register 0 ? ss0 r/w ? ? 0000h f0124h st0l f0125h serial channel stop trigger 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 f0144h ssr12l ? f0145h serial status register 12 ? ssr12 r ? ? 0000h f0146h ssr13l ? f0147h serial status register 13 ? ssr13 r ? ? 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 88 table 3-6. extended sfr (2nd sfr) list (3/5) manipulable bit range address special function regist er (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset f014ch sir12l ? f014dh serial flag clear trigger register 12 ? sir12 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 se tting register 10 scr10 r/w ? ? 0087h f015ah f015bh serial communication operation se tting register 11 scr11 r/w ? ? 0087h f015ch f015dh serial communication operation se tting register 12 scr12 r/w ? ? 0087h f015eh f015fh serial communication operation se tting register 13 scr13 r/w ? ? 0087h f0160h se1l f0161h serial channel enable status register 1 ? se1 r ? ? 0000h f0162h ss1l f0163h serial channel start trigger register 1 ? ss1 r/w ? ? 0000h f0164h st1l f0165h serial channel stop trigger 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 ? soe1l r/w ? ? 0000h f0174h sol1l ? f0175h serial output level register 1 ? sol1l 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 89 table 3-6. extended sfr (2nd sfr) list (4/5) manipulable bit range address special function regist er (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset 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 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 90 table 3-6. extended sfr (2nd sfr) list (5/5) manipulable bit range address special function regist er (sfr) name symbol r/w 1-bit 8-bit 16-bit after reset f01b0h te0l f01b1h timer channel enable status register 0 ? te0 r ? ? 0000h f01b2h ts0l f01b3h timer channel start tr igger register 0 ? ts0 r/w ? ? 0000h f01b4h tt0l f01b5h timer channel stop trigger 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 remark for sfrs in the sfr area, see table 3-5 sfr list . chapter 3 cpu architecture user?s manual u17894ej8v0ud 91 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 s pecifies the program address to be used as the branch destination. relative addressing is applied only to branch instructions. figure 3-22. outline of relative addressing op code pc displace 8/16 bits 3.3.2 immediate addressing [function] immediate addressing stores immediate da ta of the instruction word in t he 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-23. example of call !!addr20/br !!addr20 op code pc low addr. high addr. seg addr. figure 3-24. example of call !addr16/br !addr16 op code pc s low addr. high addr. pc pc h pc l 0000 chapter 3 cpu architecture user?s manual u17894ej8v0ud 92 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 cont ents at that table address a nd the next address in the program counter (pc) as 16-bit data, and specifies the program address. 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-25. 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 chapter 3 cpu architecture user?s manual u17894ej8v0ud 93 3.3.4 register direct addressing [function] register direct addressing stores in the program counter (pc) the cont ents of a general-purpose register pair (ax/bc/de/hl) and cs register of the current register bank specified with t he instruction word 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-26. outline of register direct addressing op code pc s pc pc h pc l cs rp chapter 3 cpu architecture user?s manual u17894ej8v0ud 94 3.4 addressing for processing data addresses 3.4.1 implied addressing [function] instructions for accessing registers (such as accumulators ) that have special functions are directly specified with the instruction word, without using any register specification 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-27. 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-28. outline of register addressing register op code memory chapter 3 cpu architecture user?s manual u17894ej8v0ud 95 3.4.3 direct addressing [function] direct addressing uses immediate data in the instructio n word as an operand address 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-29. example of addr16 target memory op code memory low addr. high addr. fffffh f0000h figure 3-30. example of es:addr16 op code memory low addr. high addr. fffffh 00000h target memory es chapter 3 cpu architecture user?s manual u17894ej8v0ud 96 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-31. 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 address ar e 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. chapter 3 cpu architecture user?s manual u17894ej8v0ud 97 3.4.5 sfr addressing [function] sfr addressing directly specifies the target sfr addresses us ing 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-manipulable sf r name (even address only) figure 3-32. outline of sfr addressing op code memory sfr fffffh fff00h sfr chapter 3 cpu architecture user?s manual u17894ej8v0ud 98 3.4.6 register indirect addressing [function] register indirect addressing directly specifies the target addresses using the contents of t he register 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-33. example of [de], [hl] target memory op code memory rp fffffh f0000h figure 3-34. example of es:[de], es:[hl] op code memory fffffh 00000h target memory es rp chapter 3 cpu architecture user?s manual u17894ej8v0ud 99 3.4.7 based addressing [function] based addressing uses the contents of a register pair specifi ed with the instruction word as a base address, and 8-bit immediate data or 16-bit immediate data as offset dat a. the sum of these val ues 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-35. example of [sp+byte] target memory op code memory byte fffffh f0000h sp chapter 3 cpu architecture user?s manual u17894ej8v0ud 100 figure 3-36. example of [hl + byte], [de + byte] target memory op code memory byte fffffh f0000h rp (hl/de) figure 3-37. example of word[b], word[c] target memory memory fffffh f0000h r (b/c) op code low addr. high addr. figure 3-38. example of word[bc] target memory memory fffffh f0000h rp (bc) op code low addr. high addr. chapter 3 cpu architecture user?s manual u17894ej8v0ud 101 figure 3-39. example of es :[hl + byte], es:[de + byte] op code byte rp (hl/de) memory fffffh 00000h target memory es figure 3-40. 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-41. example of es:word[bc] rp (bc) memory fffffh 00000h target memory es op code low addr. high addr. chapter 3 cpu architecture user?s manual u17894ej8v0ud 102 3.4.8 based indexed addressing [function] based indexed addressing uses the content s of a register pair specified with the instruction word as the base address, and the content of the b regist er or c register similarly specified with 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-42. example of [hl+b], [hl+c] target memory memory fffffh f0000h r (b/c) rp (hl) op code figure 3-43. example of es:[hl+b], es:[hl+c] r (b/c) op code rp (hl) es memory fffffh 00000h target memory chapter 3 cpu architecture user?s manual u17894ej8v0ud 103 3.4.9 stack addressing [function] the stack area is indirectly addressed with the stack pointer (sp) contents. this addressing is automatically employed when the push, pop, subrout ine 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 user?s manual u17894ej8v0ud 104 chapter 4 port functions 4.1 port functions there are five types of pin i/o buffer power supplies: av ref0 , av ref1 , ev dd0 , ev dd1 , 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 ref0 p20 to p27, p150 to p157 av ref1 p110, p111 ev dd0 , ev dd1 ? port pins other than p20 to p27, p110, p111, p121 to p124, and p150 to p157 ? reset and flmd0 pins v dd ? p121 to p124 ? non-port pins (excluding reset and flmd0 pins) 78k0r/kg3 products are provided with the ports shown in figure 4-1, which enable vari ety of control operations. the functions of each port are shown in table 4-2. in addition to the func tion as digital i/o ports, these ports have several alternate f unctions. for details of the alternate functions, see chapter 2 pin functions . figure 4-1. port types port 0 p00 p06 port 1 p10 p17 port 3 p30 p31 p20 port 2 p27 port 7 p70 p77 p120 port 12 p124 p40 port 4 p47 port 8 p80 p87 port 11 p110 p111 port 13 p130 p131 port 14 p140 p145 port 15 p150 p157 p50 port 5 p57 p60 port 6 p67 chapter 4 port functions user?s manual u17894ej8v0ud 105 table 4-2. port functions (1/2) function name i/o function after reset alternate function p00 ti00 p01 to00 p02 so10/txd1 p03 si10/rxd1/sda10 p04 sck10/scl10 p05 clkout p06 i/o port 0. 7-bit i/o port. input of p03 and p04 can be set to ttl input buffer. output of p02 to p04 can be set to n-ch open-drain output (v dd tolerance). 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 wait p10 sck00/ex24 p11 si00/rxd0/ex25 p12 so00/txd0/ex26 p13 txd3/ex27 p14 rxd3/ex28 p15 rtcdiv/rtccl/ex29 p16 ti01/to01/intp5/ ex30 p17 i/o port 1. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port ti02/to02/ex31 p20 to p27 i/o port 2. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani0 to ani7 p30 rtc1hz/intp3 p31 i/o port 3. 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 ti03/to03/intp4 p40 note tool0 p41 tool1 p42 ti04/to04 p43 sck01 p44 si01 p45 so01 p46 intp1/ti05/to05 p47 i/o port 4. 8-bit i/o port. input of p43 and p44 can be set to ttl input buffer. output of p43 and p45 can be set to n-ch open-drain output (v dd tolerance). 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 intp2 p50 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 ex8 to ex15 note if on-chip debugging is enabled by using an option by te, be sure to pull up the p40/tool0 pin externally (see caution in 2.2.5 p40 to p47 (port 4) ). chapter 4 port functions user?s manual u17894ej8v0ud 106 table 4-2. port functions (2/2) function name i/o function after reset alternate function p60 scl0 p61 sda0 p62 ? p63 ? p64 rd p65 wr0 p66 wr1 p67 i/o port 6. 8-bit i/o port. output of p60 to p63 can be set to n-ch open-drain output (6 v tolerance). input/output can be specified in 1-bit units. for only p64 to p67, use of an on-chip pull-up resistor can be specified by a software setting. input port astb p70 to p73 kr0/ex16 to kr3/ ex19 p74 to p77 i/o port 7. 8-bit i/o port. input/output can be specified in 1-bit units. use of an on-chip pull-up resistor can be specified by a software setting. input port kr4/ex20/intp8 to kr7/ex23/intp11 p80 to p87 i/o port 8. 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 ex0 to ex7 p110 ano0 p111 i/o port 11. 2-bit i/o port. input/output can be specified in 1-bit units. input port ano1 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, use of an on-chip pull-up resistor can be specified by a software setting. input port xt2 p130 output output port ? p131 i/o port 13. 1-bit output port and 1-bit i/o port. for only p131, use of an on-chip pull-up resistor can be specified by a software setting. input port ti06/to06 p140 pclbuz0/intp6 p141 pclbuz1/intp7 p142 sck20/scl20 p143 si20/rxd2/sda20 p144 so20/txd2 p145 i/o port 14. 6-bit i/o port. input of p142 and p143 can be set to ttl input buffer. output of p142 to p144 can be set to the n-ch open-drain output (v dd tolerance). 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 p150 to p157 i/o port 15. 8-bit i/o port. input/output can be specified in 1-bit units. digital input port ani8 to ani15 chapter 4 port functions user?s manual u17894ej8v0ud 107 4.2 port configuration ports include the following hardware. table 4-3. port configuration item configuration control registers port mode registers (pm0 to pm8, pm11 to pm15) port registers (p0 to p8, p11 to p15) pull-up resistor option registers (pu0, pu1, pu3 to pu8, pu12 to pu14) port input mode register s (pim0, pim4, pim14) port output mode registers (pom0, pom4, pom14) a/d port configuration register (adpc) port total: 88 (cmos i/o: 79, cmos input: 4, cmos output: 1, n-ch open drain i/o: 4) pull-up resistor total: 61 chapter 4 port functions user?s manual u17894ej8v0ud 108 4.2.1 port 0 port 0 is a 7-bit i/o port with an output latch. port 0 can be set to the input mode or output mode in 1-bit units using port mode register 0 (pm0). when the p00 to p06 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pu ll-up resistor option register 0 (pu0). input to the p03 and p04 pins can be specified through a normal input buffer or a ttl input buffer in 1-bit units using port input mode register 0 (pim0). output from the p02 to p04 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 0 (pom0). this port can also be used for time r i/o, serial interface data i/o, clock i/o, internal system clock output, and external wait signal input. reset signal generation sets port 0 to input mode. figures 4-2 to 4-7 show block diagrams of port 0. cautions 1. to use p01/to00 as a general-purpose port, set 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 p02/so10/txd1, p0 3/si10/rxd1/sda10, or p04/sck10/scl10 as a general-purpose port, note the serial array unit 0 setting. for details, refer to the following tables. ? table 13-7 relationship between register settings and pins (channel 2 of unit 0: csi10, uart1 transmission, iic10) ? table 13-8 relationship between register setti ngs and pins (channel 3 of unit 0: uart1 reception) figure 4-2. block diagram of p00 p00/ti00 wr pu rd wr port wr pm pu00 alternate function output latch (p00) pm00 ev dd0 , ev dd1 p-ch selector internal bus pu0 pm0 p0 p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 109 figure 4-3. block diagram of p01 p01/to00 wr pu rd wr port wr pm pu01 pm01 ev dd0 , ev dd1 p-ch pu0 pm0 p0 selector alternate function output latch (p01) internal bus p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 110 figure 4-4. block diagram of p02 p02/so10/txd1 wr pu rd wr port wr pm pu02 pm02 ev dd0 , ev dd1 p-ch pu0 pm0 p0 pom02 pom0 wr pom selector internal bus output latch (p02) alternate function p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 pom0: port output mode register 0 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 111 figure 4-5. block diagram of p03 and p04 p03/si10/rxd1/sda10, p04/sck10/scl10 wr pu rd wr port pu03, pu04 ev dd0 , ev dd1 p-ch pu0 p0 wr pm pm0 pom03, pom04 pom0 wr pom pm03, pm04 cmos ttl pim0 pim03, pim04 wr pim alternate function output latch (p03, p04) alternate function selector internal bus p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 pim0: port input mode register 0 pom0: port output mode register 0 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 112 figure 4-6. block diagram of p05 p05/clkout wr pu rd wr port wr pm ev dd0 , ev dd1 p-ch pu0 pm0 p0 pm05 pu05 alternate function output latch (p05) selector internal bus p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 113 figure 4-7. block diagram of p06 p06/wait wr pu rd wr port wr pm ev dd0 , ev dd1 p-ch pu0 pm0 p0 pm06 pu06 alternate function output latch (p06) selector internal bus alternate function p0: port register 0 pu0: pull-up resistor option register 0 pm0: port mode register 0 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 114 4.2.2 port 1 port 1 is an 8-bit i/o port with an output latch. port 1 can be set to the input mode or output mode in 1-bit units using port mode register 1 (pm1). when the p10 to p17 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 1 (pu1). this port can also be used for external interrupt request input, serial interface data i/o, clock i/o, ti mer i/o, real- time counter clock output, and external expansion output (address bus). reset signal generation sets port 1 to input mode. figures 4-8 to 4-12 show block diagrams of port 1. cautions 1. to use p10/sck00/ex 24, p11/si00/rxd0/ex25, p12/so00/txd0/ex26, p13/txd3/ex27, or p14/rxd3/ex28 as a general-purpose port, note the serial array unit setting. for details, refer to the following tables. ? table 13-5 relationship between register setti ngs and pins (channel 0 of unit 0: csi00, uart0 transmission) ? table 13-6 relationship between register setti ngs and pins (channel 1 of unit 0: csi01, uart0 reception) ? table 13-11 relationship between register setti ngs and pins (channel 2 of unit 1: uart3 transmission) ? table 13-12 relationship between register setti ngs and pins (channel 3 of unit 1: uart3 reception) 2. to use p16/ti01/to01/intp5/ex30 or p17/ti 02/to02/ex31 as a general-purpose port, set bits 1 and 2 (to01, to02) of timer output register 0 (to0) and bits 1 and 2 (toe01, toe02) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 3. to use p15/rtcdiv/rt ccl/ex29 as a general-purpose port, set bit 4 (rcloe0) of real-time counter control register 0 (rtcc0) and bit 6 (rcl oe2) of real-time counter control register 2 (rtcc2) to ?0?, which is the same as their default status settings. 4. do not enable outputting other alternat e functions when the external expansion output (address bus) function is used. chapter 4 port functions user?s manual u17894ej8v0ud 115 figure 4-8. block diagram of p10 p10/sck00/ex24 wr pu rd wr port wr pm pu10 pm10 ev dd0 , ev dd1 p-ch pu1 pm1 p1 alternate function alternate function output latch (p10) selector internal bus alternate function p1: port register 1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 116 figure 4-9. block diagram of p11 and p14 p11/si00/rxd0/ex25, p14/rxd3/ex28 wr pu rd wr port wr pm pu11, pu14 pm11, pm14 ev dd0 , ev dd1 p-ch pu1 pm1 p1 alternate function output latch (p11, p14) selector internal bus alternate function p1: port register 1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 117 figure 4-10. block diagram of p12 and p13 p12/so00/txd0/ex26, p13/txd3/ex27 wr pu rd wr port wr pm pu12, pu13 pm12, pm13 ev dd0 , ev dd1 p-ch pu1 pm1 p1 alternate function output latch (p12, p13) selector internal bus alternate function p1: port register 1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 118 figure 4-11. blo ck diagram of p15 p15/rtcdiv/rtccl/ex29 wr pu rd wr port wr pm pu15 pm15 ev dd0 , ev dd1 p-ch pu1 pm1 p1 output latch (p15) selector internal bus alternate function p1: port register 1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 119 figure 4-12. block diagram of p16 and p17 p16/ti01/to01/intp5/ex30, p17/ti02/to02/ex31 wr pu rd wr port wr pm pu16, pu17 pm16, pm17 ev dd0 , ev dd1 p-ch pm1 pu1 p1 alternate function output latch (p16, p17) selector internal bus alternate function p1: port register 1 pu1: pull-up resistor option register 1 pm1: port mode register 1 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 120 4.2.3 port 2 port 2 is an 8-bit i/o port with an output latch. port 2 can be set to the input mode or output mode in 1-bit units using port mode register 2 (pm2). this port can also be used for a/d converter analog input. to use p20/ani0 to p27/ani7 as di gital input pins, set them in the di gital 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 to p27/ani7 as digi tal output pins, set them in the di gital i/o mode by using adpc and in the output mode by using pm2. to use p20/ani0 to p27/ani7 as analog input pins, se t 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. table 4-4. setting functions of p20/ani0 to p27/ani7 pins adpc pm2 ads p20/ani0 to p27/ani7 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) selects ani. analog input selection output mode does not select ani. setting prohibited all p20/ani0 to p27/ani7 are set in the digi tal input mode when the reset signal is generated. figure 4-13 shows a block diagram of port 2. caution see 2.2.15 av ref0 for the voltage to be applied to the av ref0 pin when using port 2 as a digital i/o. chapter 4 port functions user?s manual u17894ej8v0ud 121 figure 4-13. block di agram of p20 to p27 internal bus p20/ani0 to p27/ani7 rd wr port wr pm output latch (p20 to p27) pm20 to pm27 selector pm2 a/d converter p2 p2: port register 2 pm2: port mode register 2 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 122 4.2.4 port 3 port 3 is a 2-bit i/o port with an output latch. port 3 can be set to the input mode or output mode in 1-bit units using port mode register 3 (pm3). when the p30 and p 31 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 external interrupt re quest input, timer i/o, and real-time counter correction clock output. reset signal generation sets port 3 to input mode. figure 4-14 shows block a diagram of port 3. cautions 1. to use p31/ti03/to03/intp4 as a genera l-purpose port, set bit 3 (to03) of timer output register 0 (to0) and bit 3 (toe03) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. 2. to use p30/rtc1hz/intp3 as a general-purpose por t, set bit 5 (rcloe1) of real-time counter control register 0 (rtcc0) to ?0?, which is the same as its default status setting. figure 4-14. block diagram of p30 and p31 p30/rtc1hz/intp3, p31/ti03/to03/intp4 wr pu rd wr port wr pm pu30, pu31 pm30, pm31 ev dd0 , ev dd1 p-ch pu3 pm3 p3 alternate function output latch (p30, p31) selector internal bus alternate function p3: port register 3 pu3: pull-up resistor option register 3 pm3: port mode register 3 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 123 4.2.5 port 4 port 4 is an 8-bit 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 to p47 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 4 (pu4) note . input to the p43 and p44 pins can be specified through a normal input buffer or a ttl input buffer in 1-bit units using port input mode register 4 (pim4). output from the p43 and p45 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 4 (pom4). this port can also be used for external interrupt request input, serial inte rface data i/o, clock i/o, flash memory programmer/debugger data i/o, clock output, and timer i/o. reset signal generation sets port 4 to input mode. figures 4-15 to 4-22 show block diagrams of port 4. note when a tool is connected, the p40 and p41 pi ns cannot be connected to a pull-up resistor. cautions 1. when a tool is connected, the p40 pin cannot be used as a port pin. when the on-chip debug function is used, p 41 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 a nd cannot be used as a port (p41). 2. to use p43/sck01, p44/si01, or p45/so01 as a general-purpose port, note the serial array unit 0 setting. for details, re fer to table 13-6 relationship between register settings and pins (channel 1 of unit 0: csi01, uart0 reception). 3. to use p42/ti04/to04 or p46/intp1/ti05/to 05 as a general-purpose port, set bits 4 and 5 (to04, to05) of timer output regi ster 0 (to0) and bits 4 and 5 (toe04, toe05) of timer output enable register 0 (toe0) to ?0?, which is the same as their default status setting. chapter 4 port functions user?s manual u17894ej8v0ud 124 figure 4-15. blo ck diagram of p40 p40/tool0 rd wr port wr pm pm4 p4 wr pu ev dd0 , ev dd1 p-ch pu4 pm40 pu40 alternate function output latch (p40) selector selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 125 figure 4-16. blo ck diagram of p41 p41/tool1 wr pu rd wr port wr pm pu41 pm41 ev dd0 , ev dd1 p-ch pu4 pm4 p4 output latch (p41) selector selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 126 figure 4-17. blo ck diagram of p42 p42/ti04/to04 rd wr port wr pm pm4 p4 wr pu ev dd0 , ev dd1 p-ch pu4 pm42 pu42 alternate function output latch (p42) selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 127 figure 4-18. blo ck diagram of p43 p43/sck01 wr pu rd wr port pu43 ev dd0 , ev dd1 p-ch pu4 p4 cmos ttl pim4 pim43 wr pim wr pm pm4 pom43 pom4 wr pom pm43 alternate function output latch (p43) selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 pim4: port input mode register 4 pom4: port output mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 128 figure 4-19. blo ck diagram of p44 cmos ttl pim4 pim44 wr pim p44/si01 wr pu rd pu4 pm4 wr port wr pm pu44 pm44 ev dd0 , ev dd1 p-ch p4 output latch (p44) selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 pim4: port input mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 129 figure 4-20. blo ck diagram of p45 wr pm pm4 pom45 pom4 wr pom pm45 p45/so01 wr pu rd wr port pu45 ev dd0 , ev dd1 p-ch pu4 p4 output latch (p45) selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 pom4: port output mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 130 figure 4-21. blo ck diagram of p46 p46/ti05/to05/intp1 wr pu rd wr port wr pm pu46 pm46 ev dd0 , ev dd1 p-ch pm4 pu4 p4 alternate function output latch (p46) selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 131 figure 4-22. blo ck diagram of p47 p47/intp2 wr pu rd pu4 pm4 wr port wr pm pu47 pm47 ev dd0 , ev dd1 p-ch p4 output latch (p47) selector internal bus alternate function p4: port register 4 pu4: pull-up resistor option register 4 pm4: port mode register 4 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 132 4.2.6 port 5 port 5 is an 8-bit 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 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 5 (pu5). this port can also be used for external expansion i/o (multiplexed address/data bus, address bus, data bus). when the external expansion i/o functi on is used, it controls the i/o ignori ng the settings on port mode register 5 (pm5), port register 5 (p5), and pull- up resistor option register 5 (pu5). reset signal generation sets port 5 to input mode. figures 4-23 and 4-24 show block diagrams of port 5. figure 4-23. block diagram of p50 and p51 p50/ex8, p51/ex9 wr pu rd wr port wr pm pu50, pu51 pm50, pm51 ev dd0 , ev dd1 p-ch pm5 pu5 p5 exen, mm0 to mm3 alternate function output latch (p50, p51) selector selector internal bus alternate function p5: port register 5 pu5: pull-up resistor option register 5 pm5: port mode register 5 rd: read signal wr : write signal exen: bit 7 of memory extensio n mode control register (mem) chapter 4 port functions user?s manual u17894ej8v0ud 133 figure 4-24. block diag ram of p52 to p57 p52/ex10 to p57/ex15 wr pu rd wr port wr pm pu52 to pu57 pm52 to pm57 ev dd0 , ev dd1 p-ch pm5 pu5 p5 exen, mm0 to mm3 alternate function output latch (p52 to p57) selector selector internal bus alternate function p5: port register 5 pu5: pull-up resistor option register 5 pm5: port mode register 5 rd: read signal wr : write signal exen: bit 7 of memory extensio n mode control register (mem) chapter 4 port functions user?s manual u17894ej8v0ud 134 4.2.7 port 6 port 6 is an 8-bit 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). when the p64 to p67 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 6 (pu6). the output of the p60 to p63 pins is n- ch open-drain output (6 v tolerance). this port can also be used for serial interface data i/o, clock i/o, read strobe signal output, write strobe signal output (8-bit bus mode, 16-bit bus mode (lower)), write st robe signal output (16-bit bus mode (higher)), and address strobe signal output. reset signal generation sets port 6 to input mode. figures 4-25 to 4-27 show block diagrams of port 6. caution stop the operation of serial interface iic0 when using p60/scl0 a nd p61/sda0 as general- purpose ports. figure 4-25. block diagram of p60 and p61 p60/scl0, p61/sda0 rd wr port wr pm alternate function output latch (p60, p61) pm60, pm61 alternate function internal bus selector pm6 p6 p6: port register 6 pm6: port mode register 6 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 135 figure 4-26. block diagram of p62 and p63 p62, p63 rd wr port wr pm output latch (p62, p63) pm62, pm63 internal bus selector pm6 p6 p6: port register 6 pm6: port mode register 6 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 136 figure 4-27. block di agram of p64 to p67 p64/rd, p65/wr0, p66/wr1, p67/astb wr pu rd wr port wr pm pu64 to pu67 pm64 to pm67 ev dd0 , ev dd1 p-ch pu6 pm6 p6 alternate function output latch (p64 to p67) internal bus selector p6: port register 6 pu6: pull-up resistor option register 6 pm6: port mode register 6 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 137 4.2.8 port 7 port 7 is an 8-bit i/o port with an output latch. port 7 can be set to the input mode or output mode in 1-bit units using port mode register 7 (pm7). when used as an input por t, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resist or option register 7 (pu7). this port can also be used for key return input, external expansion output (address bus), and interrupt request input. reset signal generation sets port 7 to input mode. figure 4-28 shows a block diagram of port 7. figure 4-28. block di agram of p70 to p77 p70/kr0/ex16 to p73/kr3/ex19, p74/kr4/ex20/intp8 to p77/kr7/ex23/intp11 wr pu rd wr port wr pm pu70 to pu77 pm70 to pm77 ev dd0 , ev dd1 p-ch pu7 pm7 p7 alternate function output latch (p70 to p77) alternate function internal bus selector p7: port register 7 pu7: pull-up resistor option register 7 pm7: port mode register 7 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 138 4.2.9 port 8 port 8 is an 8-bit 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 pi ns are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pull-up resistor option register 8 (pu8). this port can also be used for extern al expansion i/o (multiplexe d address/data bus, data bus). when the external expansion i/o function is used, it contro ls the i/o ignoring the settings on port m ode register 8 (pm8), port register 8 (p8), and pull-up resistor option register 8 (pu8). reset signal generation sets port 8 to input mode. figures 4-29 shows a block diagram of port 8. figure 4-29. block di agram of p80 to p87 p80/ex0 to p87/ex7 wr pu rd wr port wr pm pu80 to pu87 pm80 to pm87 ev dd0 , ev dd1 p-ch pm8 pu8 p8 exen alternate function output latch (p80 to p87) alternate function internal bus selector selector p8: port register 8 pu8: pull-up resistor option register 8 pm8: port mode register 8 rd: read signal wr : write signal exen: bit 7 of memory extensio n mode control register (mem) chapter 4 port functions user?s manual u17894ej8v0ud 139 4.2.10 port 11 port 11 is a 2-bit 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-30 shows a block diagram of port 11. caution see 2.2.16 av ref1 for the voltage to be applied to the av ref1 pin when using p110 and p111 as digital i/o. figure 4-30. block diag ram of p110 and p111 p110/ano0, p111/ano1 rd pm11 wr port wr pm pm110, pm111 p11 d/a converter output d/a converter operation enable signal output latch (p110, p111) internal bus selector p11: port register 11 pm11: port mode register 11 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 140 4.2.11 port 12 p120 is a 1-bit i/o port with an output latch. port 12 ca n be set to the input mode or output mode in 1-bit units using port mode register 12 (pm12). when used as an inpu t 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 res onator for subsystem clock, and external clock input for main system clock. reset signal generation sets port 12 to input mode. figures 4-31 to 4-33 show block diagrams of port 12. caution the function setting on p121 to p124 is avai lable 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. figure 4-31. blo ck diagram of p120 p120/intp0/exlvi wr pu rd wr port wr pm pu120 pm120 ev dd0 , ev dd1 p-ch pu12 pm12 p12 alternate function output latch (p120) internal bus selector p12: port register 12 pu12: pull-up resistor option register 12 pm12: port mode register 12 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 141 figure 4-32. block di agram of p121 and p122 p122/x2/exclk rd exclk, oscsel cmc oscsel cmc p121/x1 rd internal bus cmc: clock operation m ode control register rd: read signal chapter 4 port functions user?s manual u17894ej8v0ud 142 figure 4-33. block di agram of p123 and p124 p124/xt2 rd oscsels cmc oscsels cmc p123/xt1 rd internal bus cmc: clock operation m ode control register rd: read signal chapter 4 port functions user?s manual u17894ej8v0ud 143 4.2.12 port 13 p130 is a 1-bit output-only port with an output latch. p131 is a 1-bit i/o port with an output la tch. when used as an input port, use of an on-chip pull-up resistor can be specified by pull-up resistor option register 13 (pu13). reset signal generation sets port 13 to input mode. this port can also be used for timer i/o. figures 4-34 and 4-35 show block diagrams of port 13. caution to use p131/ti06/to06 as a gene ral-purpose port, set bit 6 (to06) of timer output register 0 (to0) and bit 6 (toe06) of timer output enable register 0 (toe0) to ?0 ?, which is the same as their default status setting. figure 4-34. blo ck diagram of p130 rd wr port p130 p13 output latch (p130) internal bus p13: port register 13 rd: read signal wr : write signal remark when reset is effected, p130 outputs a low level. if p130 is set to output a high level before reset is effected, the output signal of p130 ca n be dummy-output as the cpu reset signal. p130 set by software reset signal chapter 4 port functions user?s manual u17894ej8v0ud 144 figure 4-35. blo ck diagram of p131 p131/ti06/to06 wr pu rd wr port wr pm pu131 pm131 ev dd0 , ev dd1 p-ch pm13 pu13 p13 alternate function selector internal bus alternate function output latch (p131) p13: port register 13 pu13: pull-up resistor option register 13 pm13: port mode register 13 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 145 4.2.13 port 14 port 14 is a 6-bit 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 p1 45 pins are used as an input port, use of an on-chip pull-up resistor can be specified in 1-bit units by pu ll-up resistor option register 14 (pu14). input to the p142 and p143 pins can be s pecified through a normal input buffer or a ttl input buffer in 1-bit units using port input mode register 14 (pim14). output from the p142 to p144 pins can be specified as n-ch open-drain output (v dd tolerance) in 1-bit units using port output mode register 14 (pom14). this port can also be used for timer i/o, external interrupt request input, clock/buzze r output, serial interface data i/o, and clock i/o. reset signal generation sets port 14 to input mode. figures 4-36 to 4-38 show block diagrams of port 14. cautions 1. to use p142/sck20/sc l20, p143/si20/rxd2/sda20, or p 144/so20/txd2 as a general-purpose port, note the serial array unit 1 setting. for details, refer to the following tables. ? table 13-9 relationship between register settings and pins (channel 0 of unit 1: csi20, uart2 transmission, iic20) ? table 13-10 relationship between register setti ngs and pins (channel 1 of unit 1: uart2 reception) 2. to use p145/ti07/to07 as a general-purpose port, set bit 7 (to07) of ti mer output register 0 (to0) and bit 7 (toe07) of timer output enable re gister 0 (toe0) to ?0?, which is the same as their default status setting. 3. to use p140/pclbuz0/intp6 or p141/pclbuz1 /intp7 as a general-purpose port, set bit 7 of clock output select registers 0 and 1 (cks0, cks1) to ?0?, which is the same as their default status settings. chapter 4 port functions user?s manual u17894ej8v0ud 146 figure 4-36. block diagra m of p140, p141, and p145 p140/pclbuz0/intp6, p141/pclbuz1/intp7, p145/ti07/to07 wr pu rd wr port wr pm pu140, pu141, pu145 pm140, pm141, pm145 ev dd0 , ev dd1 p-ch pu14 pm14 p14 alternate function output latch (p140, p141, p145) selector internal bus alternate function p14: port register 14 pu14: pull-up resistor option register 14 pm14: port mode register 14 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 147 figure 4-37. block di agram of p142 and p143 cmos ttl pim14 pim142, pim143 wr pim wr pm pm14 pom142, pom143 pom14 wr pom pm142, pm143 p142/sck20/scl20, p143/si20/rxd2/sda20 wr pu rd wr port pu142, pu143 ev dd0 , ev dd1 p-ch pu14 p14 alternate function output latch (p142, p143) selector internal bus alternate function p14: port register 14 pu14: pull-up resistor option register 14 pm14: port mode register 14 pim14: port input mode register 14 pom14: port output mode register 14 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 148 figure 4-38. blo ck diagram of p144 wr pm pm14 pom144 pom14 wr pom pm144 p144/so20/txd2 wr pu rd wr port pu144 ev dd0 , ev dd1 p-ch pu14 p14 alternate function output latch (p144) selector internal bus p14: port register 14 pu14: pull-up resistor option register 14 pm14: port mode register 14 pom14: port output mode register 14 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 149 4.2.14 port 15 port 15 is an 8-bit i/o port with an output latch. port 15 can be set to the i nput 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. to use p150/ani8 to p157/ani15 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 pm15. use t hese pins starting from the lower bit. to use p150/ani8 to p157/ani15 as digital output pins, se t them in the digital i/o mode by using adpc and in the output mode by using pm15. table 4-5. setting functions of p150/ani8 to p157/ani15 pins adpc pm15 ads p150/ani8 to p157/ani15 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) selects ani. analog input selection output mode does not select ani. setting prohibited all p150/ani8 to p157/ani15 are set in the digita l input mode when the reset signal is generated. figure 4-39 shows a block diagram of port 15. caution see 2.2.15 av ref0 for the voltage to be applied to the av ref0 pin when using port 15 as a digital i/o. figure 4-39. block di agram of p150 to p157 p150/ani8 to p157/ani15 rd wr port wr pm pm150 to pm157 pm15 a/d converter p15 output latch (p150 to p157) selector internal bus p15: port register 15 pm15: port mode register 15 rd: read signal wr : write signal chapter 4 port functions user?s manual u17894ej8v0ud 150 4.3 registers controlling port function port functions are controlled by t he following six types of registers. ? port mode registers (pm0 to pm8, pm11 to pm15) ? port registers (p0 to p8, p11 to p15) ? pull-up resistor option registers (pu0, pu1, pu3 to pu8, pu12 to pu14) ? port input mode registers (pim0, pim4, pim14) ? port output mode registers (pom0, pom4, pom14) ? a/d port configuration register (adpc) (1) port mode registers (pm0 to pm8, pm11 to pm15) 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 (feh for pm13). when port pins are used as alternate-function pi ns, set the port mode register by referencing 4.5 settings of port mode register and output latch when using alternate function . chapter 4 port functions user?s manual u17894ej8v0ud 151 figure 4-40. format of port mode register symbol 7 6 5 4 3 2 1 0 address after reset r/w pm0 1 pm06 pm05 pm04 pm03 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 1 1 1 pm31 pm30 fff23h ffh r/w pm4 pm47 pm46 pm45 pm44 pm43 pm42 pm41 pm40 fff24h ffh r/w pm5 pm57 pm56 pm55 pm54 pm53 pm52 pm51 pm50 fff25h ffh r/w pm6 pm67 pm66 pm65 pm64 pm63 pm62 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 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 pm13 1 1 1 1 1 1 pm131 0 fff2dh feh r/w pm14 1 1 pm145 pm144 pm143 pm142 pm141 pm140 fff2eh ffh r/w pm15 pm157 pm156 pm155 pm154 pm153 pm152 pm151 pm150 fff2fh ffh r/w pmmn pmn pin i/o mode selection (m = 0 to 8, 11 to 15; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) caution be sure to set bit 7 of pm0, bits 2 to 7 of pm 3, bits 2 to 7 of pm11, bits 1 to 7 of pm12, bits 2 to 7 of pm13, and bits 6 and 7 of pm14 to ?1?. and be sure to set bit 0 of pm13 to ?0?. chapter 4 port functions user?s manual u17894ej8v0ud 152 (2) port registers (p0 to p8, p11 to p15) 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 or p11 is set to function as an analog output for a d/a converter. chapter 4 port functions user?s manual u17894ej8v0ud 153 figure 4-41. format of port register symbol 7 6 5 4 3 2 1 0 address after reset r/w p0 0 p06 p05 p04 p03 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 0 0 0 p31 p30 fff03h 00h (output latch) r/w p4 p47 p46 p45 p44 p43 p42 p41 p40 fff04h 00h (output latch) r/w p5 p57 p56 p55 p54 p53 p52 p51 p50 fff05h 00h (output latch) r/w p6 p67 p66 p65 p64 p63 p62 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 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 p131 p130 fff0dh 00h (output latch) r/w p14 0 0 p145 p144 p143 p142 p141 p140 fff0eh 00h (output latch) r/w p15 p157 p156 p155 p154 p153 p152 p151 p150 fff0fh 00h (output latch) r/w m = 0 to 8, 11 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. chapter 4 port functions user?s manual u17894ej8v0ud 154 (3) pull-up resistor option registers (p u0, pu1, pu3 to pu8, pu12 to pu14) these registers specify whether the on-c hip pull-up resistors of p00 to p06, p 10 to p17, p30, p31, p40 to p47, p50 to p57, p64 to p67, p70 to p77, p80 to p87, p1 20, p131, or p140 to p145 are to be used or not. on-chip pull-up resistors can be used in 1-bit units only for the bits se t to input mode of the pins to which the use of an on- chip pull-up resistor has been specified in pu0, pu1, pu3 to pu8, and pu12 to pu14. on-chip pull-up resistors cannot be connected to bits set to output mode and bits used as alternate-function output pins, regardless of the settings of pu0, pu1, pu3 to pu8, and pu12 to pu14. 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-42. format of pull-up resistor option register symbol 7 6 5 4 3 2 1 0 address after reset r/w pu0 0 pu06 pu05 pu04 pu03 pu02 pu01 pu00 f0030h 00h r/w pu1 pu17 pu16 pu15 pu14 pu13 pu12 pu11 pu10 f0031h 00h r/w pu3 0 0 0 0 0 0 pu31 pu30 f0033h 00h r/w pu4 pu47 pu46 pu45 pu44 pu43 pu42 pu41 pu40 f0034h 00h r/w pu5 note pu57 pu56 pu55 pu54 pu53 pu52 pu51 pu50 f0035h 00h r/w pu6 pu67 pu66 pu65 pu64 0 0 0 0 f0036h 00h r/w pu7 pu77 pu76 pu75 pu74 pu73 pu72 pu71 pu70 f0037h 00h r/w pu8 note pu87 pu86 pu85 pu84 pu83 pu82 pu81 pu80 f0038h 00h r/w pu12 0 0 0 0 0 0 0 pu120 f003ch 00h r/w pu13 0 0 0 0 0 0 pu131 0 f003dh 00h r/w pu14 0 0 pu145 pu144 pu143 pu142 pu141 pu140 f003eh 00h r/w pumn pmn pin on-chip pull-up resistor selection (m = 0, 1, 3 to 8, 12 to 14; n = 0 to 7) 0 on-chip pull-up resistor not connected 1 on-chip pull-up resistor connected note when the external expansion function is used, on-ch ip pull-up resistors cannot be connected, regardless of the settings of the pu5 and pu8 registers. chapter 4 port functions user?s manual u17894ej8v0ud 155 (4) port input mode registers (pim0, pim4, pim14) these registers set the input buffer of p03, p04, p43, p44, p142, or p143 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-43. format of port input mode register symbol 7 6 5 4 3 2 1 0 address after reset r/w pim0 0 0 0 pim04 pim03 0 0 0 f0040h 00h r/w pim4 0 0 0 pim44 pim43 0 0 0 f0044h 00h r/w pim14 0 0 0 0 pim143 pim142 0 0 f004eh 00h r/w pimmn pmn pin input buffer selection (m = 0, 4, 14; n = 2 to 4) 0 normal input buffer 1 ttl input buffer (5) port output mode registers (pom0, pom4, pom14) these registers set the output mode of p02 to p04, p43, p45, or p142 to p144 in 1-bit units. n-ch open drain output (v dd tolerance) mode can be selected during serial communication with an external device of the different potential, and for th e sda10 and sda20 pins 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-44. format of port input mode register symbol 7 6 5 4 3 2 1 0 address after reset r/w pom0 0 0 0 pom04 pom03 pom02 0 0 f0050h 00h r/w pom4 0 0 pom45 0 pom43 0 0 0 f0054h 00h r/w pom14 0 0 0 pom144 pom143 pom142 0 0 f005eh 00h r/w pommn pmn pin output mode selection (m = 0, 4, 14; n = 2 to 5) 0 normal output mode 1 n-ch open-drain output (v dd tolerance) mode chapter 4 port functions user?s manual u17894ej8v0ud 156 (6) a/d port configuration register (adpc) this register switches the p20/ani0 to p27/ani7 and p150/ani8 to p157/ani15 pins to digital i/o of port or analog input of a/d converter. adpc can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets this register to 10h. figure 4-45. 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 / p157 ani14 / p156 ani13 / p155 ani12 / p154 ani11 / p153 ani10 / p152 ani9/ p151 ani8/ p150 ani7/ p27 ani6/ p26 ani5/ p25 ani4/ p24 ani3/ p23 ani2/ p22 ani1/ p21 ani0/ p20 0 0 0 0 0 a a a a 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 a a a a d 0 0 0 1 0 a a a a 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 a a a a d d d 0 0 1 0 0 a a a a a a a a a a a a d d d d 0 0 1 0 1 a a a a a a a a a a a d d d d d 0 0 1 1 0 a a a a a a a a a a d d d d d d 0 0 1 1 1 a a a a a a a a a d d d d d d d 0 1 0 0 0 a a a a a a a a d d d d d d d d 0 1 0 0 1 a a a a a a a d d d d d d d d d 0 1 0 1 0 a a a a a a d d d d d d d d d d 0 1 0 1 1 a a a a a d d d d d d d d d d d 0 1 1 0 0 a a a a d d d d d d d d d d d d 0 1 1 0 1 a a a d d d d d d d d d d d d d 0 1 1 1 0 a a d d d d 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 d d d d 1 0 0 0 0 d d d d d d d d d d d d d d d d other than above setting prohibited cautions 1. set the channel used for a/d conversion to the input mode by using port mode registers 2 and 15 (pm2, pm15). 2. do not set the pin set by adpc as digital i/o by analog input channe l specification register (ads). 3. p20/ani0 to p27/ani7 and p 150/ani8 to p157/ani15 are set as an alog inputs in the order of p157/ani15, ?, p150/ani 8, p27/ani7, ?, p20/ ani0 by the a/d port configuration register (adpc). when using p20/ani0 to p27/ani7 and p150/ani8 to p157/ani15 as analog inputs, start designing from p157/ani15. chapter 4 port functions user?s manual u17894ej8v0ud 157 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 content s are output from the pin. once data is written to the output latch, it is reta ined until data is written to the output latch again. the data of the output latch is 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 latch contents, and the result is wr itten to the output latch. the output latch contents are output from the pins. once data is written to the output latch, it is reta ined until data is written to the output latch again. the data of the output latch is clear ed when a reset signal is generated. (2) input mode the pin level is read and an operation is performed on its cont ents. the result of the op eration is written to the output latch, but since the output buffer is off, the pin status does not change. the data of the output latch is clear ed when a reset signal is generated. chapter 4 port functions user?s manual u17894ej8v0ud 158 4.4.4 connecting to external device wit h different potential (2.5v, 3 v) when parts of ports 0, 4, and 14 operate with v dd = 4.0 v to 5.5 v, i/o connections with an external device that operates on 2.5 v, 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 (pim0, pim4, pim14). moreover, regarding outputs, different potentials can be su pported by switching the output buffer to the n-ch open drain (v dd withstand voltage) by the port output m ode registers (pom0, pom4, pom14). (1) setting procedure when usin g i/o pins of uart1, uart2, cs i01, and csi20 functions (a) use as 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: p03 in case of uart2: p143 in case of csi01: p43, p44 in case of csi10: p03, p04 in case of csi20: p142, p143 <3> set the corresponding bit of the pimn register to 1 to switch to t he ttl input buffer. <4> v ih /v il operates on 2.5v, 3 v operating voltage. (b) use as 2.5 v, 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: p02 in case of uart2: p144 in case of csi01: p43, p45 in case of csi10: p02, p04 in case of csi20: p142, p144 <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 manipulating 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 accordin g to the operating status of the serial array unit. remark n = 0, 4, 14 chapter 4 port functions user?s manual u17894ej8v0ud 159 (2) setting procedure when using i/o pins of simplified iic10 and iic20 functions <1> after reset release, the port mode is the input mode (hi-z). <2> externally pull up the pin to be used (on-chip pull-up resistor cannot be used). in case of simplified iic10: p03, p04 in case of simplified iic20: p142, p143 <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 corresponding bit of the pmn register to the output mode (data i/o is possibl e 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 array uni t and set the mode to the simplified iic mode. remark n = 0, 14 chapter 4 port functions user?s manual u17894ej8v0ud 160 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-6. table 4-6. settings of port mode register a nd output latch when using alternate function (1/3) alternate function pin name function name i/o pm p p00 ti00 input 1 p01 to00 output 0 0 so10 output 0 1 p02 txd1 output 0 1 si10 input 1 rxd1 input 1 p03 sda10 i/o 0 1 input 1 sck10 output 0 1 p04 scl10 i/o 0 1 p05 clkout output 0 0 p06 wait input 1 input 1 sck00 output 0 1 p10 ex24 output 0 0 si00 input 1 rxd0 input 1 p11 ex25 output 0 0 so00 output 0 1 txd0 output 0 1 p12 ex26 output 0 0 txd3 output 0 1 p13 ex27 output 0 0 rxd3 input 1 p14 ex28 output 0 0 rtcdiv output 0 0 rtccl output 0 0 p15 ex29 output 0 0 ti01 input 1 to01 output 0 0 intp5 input 1 p16 ex30 output 0 0 remark : don?t care pm : port mode register p : port output latch chapter 4 port functions user?s manual u17894ej8v0ud 161 table 4-6. settings of port mode register a nd output latch when using alternate function (2/3) alternate function pin name function name i/o pm p ti02 input 1 to02 output 0 0 p17 ex31 output 0 0 p20 to p27 note 1 ani0 to ani7 note 1 input 1 rtc1hz output 0 0 p30 intp3 input 1 ti03 input 1 to03 output 0 0 p31 intp4 input 1 p40 tool0 i/o p41 tool1 output ti04 input 1 p42 to04 output 0 0 input 1 p43 sck01 output 0 1 p44 si01 input 1 p45 so01 output 0 1 ti05 input 1 to05 output 0 0 p46 intp1 input 1 p47 intp2 input 1 p50 to p57 ex8 to ex15 note 2 i/o note 4 p60 scl0 i/o 0 0 p61 sda0 i/o 0 0 p64 rd output 0 0 p65 wr0 output 0 0 p66 wr1 output 0 0 p67 astb output 0 0 p70 to p73 kr0 to kr3 input 1 ex16 to ex19 output 0 0 intp8 to intp11 input 1 p74 to p77 kr4 to kr7 input 1 ex20 to ex23 output 0 0 p80 to p87 ex0 to ex7 note 3 i/o note 4 p110, p111 ano0, ano1 note 5 output 1 remark : don?t care pm : port mode register p : port output latch ( notes 1 , 2 , 3 , and 4 are listed on the next page.) chapter 4 port functions user?s manual u17894ej8v0ud 162 table 4-6. settings of port mode register a nd output latch when using alternate function (3/3) alternate function pin name function name i/o pm p intp0 input 1 p120 exlvi input 1 ti06 input 1 p131 to06 output 0 0 pclbuz0 output 0 0 p140 intp6 input 1 pclbuz1 output 0 0 p141 intp7 input 1 input 1 sck20 output 0 1 p142 scl20 i/o 0 1 si20 input 1 rxd2 input 1 p143 sda20 i/o 0 1 so20 output 0 1 p144 txd2 output 0 1 ti07 input 1 p145 to07 output 0 0 p150 to p157 note 1 ani8 to ani15 note 1 input 1 remark : don?t care pm : port mode register p : port output latch notes 1. the functions of the ani0/p20 to ani7/p27 and an i8/p150 to ani15/p157 pins can be selected by using the a/d port configuration regi ster (adpc), the analog input chann el specification register (ads), pm2, and pm15. table 4-7. setting functions of ani0/p20 to ani7/p27 and ani8/p150 to ani15/p157 pins adpc pm2, pm15 ads ani0/p20 to ani7/p27, ani8/p150 to ani15/p157 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) selects ani. analog input selection output mode does not select ani. setting prohibited 2. the functions of ex8 to ex15 are selected depe nding on the setting of the memory extension mode control register (mem). for details, see chapter 5 external bus interface . 3. when the external bus interface is enabled to op erate (exen = 1), the functions of ex0 to ex7 are automatically selected. 4. when using an alternate function of these pins, se lect the function by using the memory extension mode control register (mem). 5. when the d/a converter operation is enabled (dacen = 1), the function of anon is automatically selected. however, set port mode register 11 in the input mode (pm11n = 1). chapter 4 port functions user?s manual u17894ej8v0ud 163 4.6 cautions on 1-bit manipulation in struction for port register n (pn) when a 1-bit manipulation instruction is executed on a por t that provides both input and output functions, the output latch value of an input port that is not subject to manipulation 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. user?s manual u17894ej8v0ud 164 chapter 5 external bus interface 5.1 functions of external bus interface the external bus interface function is used to connect an external device to an area other than the internal rom, ram, and sfr areas. an external device is connected by using ports 0, 1, and 5 to 8. ports 0, 1, and 5 to 8 control signals such as address/data, read/wr ite strobe, wait, and address strobe. the external bus interface has the following features. ? the number of address bits can be selected from 8, 12, 16, and 20. ? data bus supporting 8 bits and 16 bits ? multiplexed bus and separate bus are supported. ? separate bus mode and 16-bit bus mode are selected wh en an instruction is fetched from external memory. the following table shows the pin functions in an external memory extension mode. pin function when external device is connected name function alternate-function pin ex0 to ex7 external extension i/o (multiplexed address/data bus, data bus) p80 to p87 ex8 to ex15 external extension i/o (multiplexed address/data bus, address bus, data bus) p50 to p57 ex16 to ex23 external extension output (address bus) p70/kr0 to p77/kr7/intp11 ex24 to ex31 external extension output (address bus) p10/sck00 to p17/ti02/to02 rd read strobe signal p64 wr0 write strobe signal (8-bit bus mode, 16-bit bus mode (lower byte)) p65 wr1 write strobe signal (16-bi t bus mode (higher byte)) p66 clkout internal system clock output p05 wait wait signal p06 astb address strobe signal p67 chapter 5 external bus interface user?s manual u17894ej8v0ud 165 the function of the external bus interfac e pins differs depending on the set mode. pin external extension mode ex31 to ex28 ex27 to ex24 ex23 to ex20 ex19 to ex16 ex15 to ex12 ex11 to ex8 ex7 to ex0 256-byte extension mode ? ? ? ? ? ? ad7 to ad0 4 kb extension mode ? ? ? ? ? a11 to a8 ad7 to ad0 64 kb extension mode ? ? ? ? a15 to a12 a11 to a8 ad7 to ad0 8-bit bus mode full address mode ? ? ? a19 to a16 a15 to a12 a11 to a8 ad7 to ad0 256-byte extension mode ? ? ? ? d15 to d12 d11 to d8 ad7 to ad0 4 kb extension mode ? ? ? ? d15 to d12 ad11 to ad8 ad7 to ad0 64 kb extension mode ? ? ? ? ad15 to ad12 ad11 to ad8 ad7 to ad0 multiplexed bus mode 16-bit bus mode full address mode ? ? ? a19 to a16 ad15 to ad12 ad11 to ad8 ad7 to ad0 256-byte extension mode ? ? ? ? a7 to a4 a3 to a0 d7 to d0 4 kb extension mode ? ? ? a11 to a8 a7 to a4 a3 to a0 d7 to d0 64 kb extension mode ? ? a15 to a12 a11 to a8 a7 to a4 a3 to a0 d7 to d0 8-bit bus mode full address mode ? a19 to a16 a15 to a12 a11 to a8 a7 to a4 a3 to a0 d7 to d0 256-byte extension mode ? ? a7 to a4 a3 to a0 d15 to d12 d11 to d8 d7 to d0 4 kb extension mode ? a11 to a8 a7 to a4 a3 to a0 d15 to d12 d11 to d8 d7 to d0 64 kb extension mode a15 to a12 a11 to a8 a7 to a4 a3 to a0 d15 to d12 d11 to d8 d7 to d0 separate bus mode 16-bit bus mode full address mode setting prohibited remark exxx: pin name axx: address bus dxx: data bus adxx: multiplexed address/data bus ? : external bus interface is not used. these pins can be used as port pins. chapter 5 external bus interface user?s manual u17894ej8v0ud 166 the memory maps when using the external bus interface function are as follows. figure 5-1. memory map when usi ng external bus interface function (1/4) (a) memory map of pd78f1162, 78f1162a (b) memory map of pd78f1163, 78f1163a fffffh fff00h ffeffh ffee0h ffedfh fffffh fff00h ffeffh fe700h fe6ffh f1000h f0fffh f0800h f07ffh f0000h effffh 30000h 2ffffh 21000h 20fffh 20100h 200ffh 20000h 1ffffh 18000h 17fffh 00000h ffee0h ffedfh ee000h edfffh ee000h edfffh fef00h feeffh f1000h f0fffh f0800h f07ffh f0000h effffh 20000h 1ffffh 11000h 10fffh 10100h 100ffh 10000h 0ffffh 00000h special-function register (sfr) 256 bytes special-function register (sfr) 256 bytes general-purpose register 32 bytes general-purpose register 32 bytes ram 4 kb ram 6 kb mirror 53.75 kb use prohibited use prohibited special-function register (2nd sfr) 2 kb full-address mode (when mm1, mm0 = 11) 64 kb extension mode (when mm1, mm0 = 10) 4 kb extension mode (when mm1, mm0 = 01) flash memory 96 kb 256 kb extension mode (when mm1, mm0 = 00) use-prohibited area mirror 55.75 kb special-function register (2nd sfr) 2 kb full-address mode (when mm1, mm0 = 11) 64 kb extension mode (when mm1, mm0 = 10) 4 kb extension mode (when mm1, mm0 = 01) 256-byte extension mode (when mm1, mm0 = 00) flash memory 64 kb use prohibited use prohibited chapter 5 external bus interface user?s manual u17894ej8v0ud 167 figure 5-1. memory map when usi ng external bus interface function (2/4) (c) memory map of pd78f1164, 78f1164a (d) memory map of pd78f1165, 78f1165a fffffh fffffh fff00h ffeffh f1000h f0fffh f0800h f07ffh f0000h effffh 30000h 2ffffh 21000h 20fffh 20100h 00000h 200ffh 20000h 1ffffh ee000h ffee0h ffedfh fff00h ffeffh f1000h f0fffh f0800h f07ffh 40000h 3ffffh 31000h 30fffh 30100h 300ffh 30000h 2ffffh 00000h f0000h effffh ee000h fd700h fd6ffh ffee0h ffedfh edfffh edfffh fdeffh fdf00h special-function register (sfr) 256 bytes special-function register (sfr) 256 bytes general-purpose register 32 bytes general-purpose register 32 bytes ram 8 kb ram 10 kb mirror 49.75 kb use prohibited use prohibited special-function register (2nd sfr) 2 kb full-address mode (when mm1, mm0 = 11) 64 kb extension mode (when mm1, mm0 = 10) 4 kb extension mode (when mm1, mm0 = 01) flash memory 192 kb 256 kb extension mode (when mm1, mm0 = 00) mirror 51.75 kb special-function register (2nd sfr) 2 kb full-address mode (when mm1, mm0 = 11) 64 kb extension mode (when mm1, mm0 = 10) 4 kb extension mode (when mm1, mm0 = 01) 256-byte extension mode (when mm1, mm0 = 00) flash memory 128 kb use prohibited use prohibited chapter 5 external bus interface user?s manual u17894ej8v0ud 168 figure 5-1. memory map when usi ng external bus interface function (3/4) (e) memory map of pd78f1166, 78f1166a (f) memory map of pd78f1167, 78f1167a fffffh fff00h ffeffh ffee0h ffedfh fcf00h fceffh f0800h f07ffh f0000h effffh ee000h edfffh 50000h 4ffffh 41000h 40fffh 40100h 400ffh 40000h 3ffffh 00000h f1000h f0fffh special-function register (sfr) 256 bytes general-purpose register 32 bytes ram note 12 kb mirror 47.75 kb use prohibited use prohibited special-function register (2nd sfr) 2 kb full-address mode (when mm1, mm0 = 11) 64 kb extension mode (when mm1, mm0 = 10) 4 kb extension mode (when mm1, mm0 = 01) 256-byte extension mode (when mm1, mm0 = 00) flash memory 256 kb fffffh fff00h ffeffh ffee0h ffedfh f9f00h f9effh f0800h f07ffh f0000h effffh ee000h edfffh 70000h 6ffffh 61000h 60fffh 60100h 600ffh 60000h 5ffffh 00000h f1000h f0fffh special-function register (sfr) 256 bytes general-purpose register 32 bytes ram 24 kb mirror 35.75 kb use prohibited use prohibited special-function register (2nd sfr) 2 kb full-address mode (when mm1, mm0 = 11) 64 kb extension mode (when mm1, mm0 = 10) 4 kb extension mode (when mm1, mm0 = 01) 256-byte extension mode (when mm1, mm0 = 00) flash memory 384 kb note use of the area fcf00h to fd6ffh is prohibited when using the self-programming function, since this area is used for self-programming library. chapter 5 external bus interface user?s manual u17894ej8v0ud 169 figure 5-1. memory map when usi ng external bus interface function (4/4) (g) memory map of pd78f1168, 78f1168a fffffh fff00h ffeffh ffee0h ffedfh f8700h f86ffh f0800h f07ffh f0000h effffh ee000h edfffh 90000h 8ffffh 81000h 80fffh 80100h 800ffh 80000h 7ffffh 00000h f1000h f0fffh special-function register (sfr) 256 bytes general-purpose register 32 bytes ram note 30 kb mirror 29.75 kb use prohibited use prohibited special-function register (2nd sfr) 2 kb full-address mode (when mm1, mm0 = 11) 64 kb extension mode (when mm1, mm0 = 10) 4 kb extension mode (when mm1, mm0 = 01) 256-byte extension mode (when mm1, mm0 = 00) flash memory 512 kb note use of the area f8700h to f8effh is prohibited when using the self-programming function, since this area is used for self-programming library. chapter 5 external bus interface user?s manual u17894ej8v0ud 170 5.2 registers controlling exte rnal bus interface functions the external bus interface function is controlled by the following registers. ? peripheral enable register 1 (per1) ? memory extension mode control register (mem) ? port mode registers 0, 1, 5, 6, 7, 8 (pm0, pm1, pm5, pm6, pm7, pm8) ? port registers 0, 1, 5, 6, 7, 8 (p0, p1, p5, p6, p7, p8) (1) peripheral enable register 1 (per1) per1 is used to enable or disable use of each peripher al hardware macro. clock supply to a hardware macro that is not used is stopped in order to reduce the power consumption and noise. when the external bus interface is used, be sure to set bit 0 (exben) of this register to 1. per1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 5-2. format of peripheral enable register 1 (per1) address: f00f1h after reset: 00h r/w symbol 7 6 5 4 3 2 1 <0> per1 0 0 0 0 0 0 0 exben exben control of external bus interface input clock 0 stops supply of input clock. ? sfr used by external bus interface cannot be written. ? external bus interface is in the reset status. 1 supplies input clock. ? sfr used by external bus interface can be read/written. caution when setting the external bus in terface, be sure to set exben to 1 first. if exben = 0, writing to a control register of the external bus interface is ignored, and, even if the register is read, only the default value is read (except for port mode regi sters 0, 1, 5, 6, 7, 8 (pm0, pm1, pm5, pm6, pm7, pm8) and port registers 0, 1, 5, 6, 7, 8 (p0, p1, p5, p6, p7, p8)). chapter 5 external bus interface user?s manual u17894ej8v0ud 171 (2) memory extension mode control register (mem) mem is a register that sets an external extension area. mem can be set by a 1-bit or 8-bit manipulation instruction. reset signal generation clears this register to 00h. figure 5-3. format of memory exte nsion mode control register (mem) address: fffffh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 mem exen exwen ew1 ew0 mm3 mm2 mm1 mm0 exen external bus interface enable flag 0 single-chip mode (port function is valid.) 1 external bus interface is used. exwen external wait pin enable signal 0 external wait pin is not used and can be used as a port. 1 external wait pin is used. ew1 ew0 clkout pin output clock selection 0 0 f clk 0 1 f clk /2 1 0 f clk /3 1 1 f clk /4 mm3 bus mode switching of external bus interface 0 multiplexed bus mode (can be selected only for accessing memory and cannot be selected for fetching.) 1 separate bus mode mm2 bus width selection of external bus interface 0 8-bit bus mode note (can be selected only for accessing memory and cannot be selected for fetching.) 1 16-bit bus mode mm1 mm0 mode selection 0 0 256-byte extension mode. 8 address bus pins are used. 0 1 4 kb extension mode. 12 address bus pins are used. 1 0 64 kb extension mode. 16 address bus pins are used. 1 1 full address mode. 20 address bus pins are used. note in the 8-bit bus mode, 16-bit a ccess instructions cannot be used. chapter 5 external bus interface user?s manual u17894ej8v0ud 172 the function of the external bus inte rface pins differs depending on the se tting of the memory extension mode control register (mem). mm3 mm2 mm1 mm0 ex31 to ex28 ex27 to ex24 ex23 to ex20 ex19 to ex16 ex15 to ex12 ex11 to ex8 ex7 to ex0 0 0 0 0 ? ? ? ? ? ? ad7 to ad0 0 0 0 1 ? ? ? ? ? a11 to a8 ad7 to ad0 0 0 1 0 ? ? ? ? a15 to a12 a11 to a8 ad7 to ad0 0 0 1 1 ? ? ? a19 to a16 a15 to a12 a11 to a8 ad7 to ad0 0 1 0 0 ? ? ? ? d15 to d12 d11 to d8 ad7 to ad0 0 1 0 1 ? ? ? ? d15 to d12 ad11 to ad8 ad7 to ad0 0 1 1 0 ? ? ? ? ad15 to ad12 ad11 to ad8 ad7 to ad0 0 1 1 1 ? ? ? a19 to a16 ad15 to ad12 ad11 to ad8 ad7 to ad0 1 0 0 0 ? ? ? ? a7 to a4 a3 to a0 d7 to d0 1 0 0 1 ? ? ? a11 to a8 a7 to a4 a3 to a0 d7 to d0 1 0 1 0 ? ? a15 to a12 a11 to a8 a7 to a4 a3 to a0 d7 to d0 1 0 1 1 ? a19 to a16 a15 to a12 a11 to a8 a7 to a4 a3 to a0 d7 to d0 1 1 0 0 ? ? a7 to a4 a3 to a0 d15 to d12 d11 to d8 d7 to d0 1 1 0 1 ? a11 to a8 a7 to a4 a3 to a0 d15 to d12 d11 to d8 d7 to d0 1 1 1 0 a15 to a12 a11 to a8 a7 to a4 a3 to a0 d15 to d12 d11 to d8 d7 to d0 1 1 1 1 setting prohibited exen exwen mm3 mm2 clkout astb rd wr0 wr1 wait 0 x x x ? ? ? ? ? ? 1 0 0 0 clkout astb rd write strobe ? ? 1 0 0 1 clkout astb rd low bytes write strobe high bytes write strobe ? 1 0 1 0 clkout ? rd write strobe ? ? 1 0 1 1 clkout ? rd low bytes write strobe high bytes write strobe ? 1 1 0 0 clkout astb rd write strobe ? wait 1 1 0 1 clkout astb rd low bytes write strobe high bytes write strobe wait 1 1 1 0 clkout ? rd write strobe ? wait 1 1 1 1 clkout ? rd low bytes write strobe high bytes write strobe wait remark exxx: pin name axx: address bus dxx: data bus adxx: multiplexed address/data bus ? : external bus interface is not used. these pins can be used as port pins. chapter 5 external bus interface user?s manual u17894ej8v0ud 173 5.3 setting port mode register and output latch set the port mode register and output latch as fo llows when using the external bus interface. p17/ex31 to p14/ex28 p13/ex27 to p10/ex24 p77/ex23 to p74/ex20 p73/ex19 to p70/ex16 p57/ex15 to p54/ex12 p53/ex11 to p50/ex8 p87/ex7 to p80/ex0 exen mm3 mm2 mm1 mm0 pm1x p1x pm1x p1x pm7x p7x pm7x p7x pm5x p5x pm5x p5x pm8x p8x 0 x x x x ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? x x 1 0 0 0 1 ? ? ? ? ? ? ? ? ? ? x x x x 1 0 0 1 0 ? ? ? ? ? ? ? ? x x x x x x 1 0 0 1 1 ? ? ? ? ? ? 0 0 x x x x x x 1 0 1 0 0 ? ? ? ? ? ? ? ? x x x x x x 1 0 1 0 1 ? ? ? ? ? ? ? ? x x x x x x 1 0 1 1 0 ? ? ? ? ? ? ? ? x x x x x x 1 0 1 1 1 ? ? ? ? ? ? 0 0 x x x x x x 1 1 0 0 0 ? ? ? ? ? ? ? ? x x x x x x 1 1 0 0 1 ? ? ? ? ? ? 0 0 x x x x x x 1 1 0 1 0 ? ? ? ? 0 0 0 0 x x x x x x 1 1 0 1 1 ? ? 0 0 0 0 0 0 x x x x x x 1 1 1 0 0 ? ? ? ? 0 0 0 0 x x x x x x 1 1 1 0 1 ? ? 0 0 0 0 0 0 x x x x x x 1 1 1 1 0 0 0 0 0 0 0 0 0 x x x x x x 1 1 1 1 1 setting prohibited p05/clkout p67/astb p64/rd p65/wr0 p66/wr1 p06/wait exen exwen mm3 pm05 p05 pm67 p67 pm64 p64 pm65 p65 pm66 p66 pm06 p06 0 x x ? ? ? ? ? ? ? ? ? ? ? ? 1 0 0 0 0 0 0 0 0 0 0 0 0 ? ? 1 0 1 0 0 ? ? 0 0 0 0 0 0 ? ? 1 1 0 0 0 0 0 0 0 0 0 0 0 1 x 1 1 1 0 0 ? ? 0 0 0 0 0 0 1 x remark x: does not have to be set. these pins are used as external bus interface pins. ? : external bus interface is not used. these pins can be used as port pins. chapter 5 external bus interface user?s manual u17894ej8v0ud 174 5.4 number of instruction wait clocks for data access wait clocks are added to the number of clocks of an inst ruction when the external bus interface is accessed. the actual number of operating clocks is therefore the sum of the number of operating cl ocks of each instruction and the number of wait states. clkout pin selection clock number of wait states (read/write) f clk 3 clocks f clk/ 2 5 or 6 clocks f clk /3 7 to 9 clocks f clk /4 9 to 12 clocks 5.5 number of instruction execution clocks and instruction wait clocks for fetch access the internal flash captures an opcode every 32 bits. however, an opcode is captured from the external bus interface every 16 bits. consequently, it takes time about two times longer than the internal flash to capture an instruction. furthermore, a wait is inserted when acce ssing an external memory. consequently, the minimum and maximum numbers of execution clocks of each instruction when fetching instructions from the external memory are as follows, for the number of clocks when instructions are fetched from the internal rom (flash memory) area. when fetching instructions from external memory no. of instruction execution clocks when fetching instructions from internal rom area note minimum no. of execution clocks maximum no. of execution clocks 1 2 + 2 wait 5 + 3 wait 2 6 + 2 wait 7 + 6 wait 3 4 + 2 wait 8 + 8 wait 4 8 + 2 wait 10 + 10 wait 5 6 + 2 wait 12 + 9 wait 6 10 + 5 wait 14 + 11 wait note number of clocks when the internal ram ar ea, sfr area, or expan ded sfr area has been accessed, or when an instruction that does not access data is executed furthermore, the number of waits is as follows, depending on the clock select ed for the clkout pin. clkout pin selection clock number of wait states (fetch) f clk 3 clocks f clk /2 5 or 6 clocks f clk /3 7 to 9 clocks f clk /4 9 to 12 clocks caution the flash memory and external memory are located in consecu tive spaces, but start fetching in the external memory space by using a branch in struction (call, br) in the flash memory or ram memory. chapter 5 external bus interface user?s manual u17894ej8v0ud 175 5.6 timing of external bus interface function the functions of the timing control sig nal output pins in the external memo ry extension mode are described below. (1) rd pin (alternate function: p64) this pin outputs a read strobe signal when an instructio n is fetched or data is read from the external memory. it does not output the read strobe si gnal (holds the high level) when the internal memory is read. (2) wr0 pin (alternate function: p65) this pin outputs a write strobe signal (i n 8-bit bus mode or 16-bit bus mode (lower byte)) when data is written to the external memory. it does not output the write strobe signal (holds the high level) when data is written to the internal memory. (3) wr1 pin (alternate function: p66) this pin outputs a write strobe signal (in 16-bit bus mode (higher byte)) when data is written to the external memory. it does not output the write strobe signal (holds the high level) when data is written to the internal memory. (4) wait pin (alter nate function: p06) this pin inputs an external wait signal. a wait can be inserted to the bus cycle by inputting an external wait signal in synchr onization with the clkout signal. it can be used as an i/o port pin when the ex ternal wait signal is not used. the external wait signal is ignored when the internal memory is accessed. (5) astb pin (alter nate function: p67) this pin outputs an address strobe signal. this pin outputs the address strobe signal in the multiplexed bus mode. during internal memory access, the address strobe sig nal is not output (the low level is maintained). (6) clkout pin (alternate function: p05) this pin outputs the internal system clock. the internal system clock is output when the external bus interface is used (exen bit of the mem register = 1). (7) ex0 to ex7, ex8 to ex15, ex16 to ex23, and ex24 to ex31 pins (alternate func tion: p80 to p87, p50 to p57, p70 to p77, and p10 to p17) these pins output an address signal and in put/output a data signal. a valid signal is output or input when an instruction is fetched from or data is accessed to/from the external memory. during internal memory access, the address output pin holds the address that was accessed last. the data output pin goes into the hi-z state. figures 5-4 to 5-7 show the timing charts. chapter 5 external bus interface user?s manual u17894ej8v0ud 176 5.6.1 multiplexed bus mode figure 5-4. timing to read external memory (1/2) (a) no wait, 8-bit bus clkout = f clk (exwen = 0, mm3 = 0, mm2 = 0) rd astb ad7 to ad0 a19 to a8 a7 to a0 hi-z hi-z d7 to d0 a19 to a8 clkout f clk cpu exe (wait) exe (wait) exe (wait) exe (read) (b) with wait, 8-bit bus clkout = f clk (exwen = 1, mm3 = 0, mm2 = 0) rd astb ad7 to ad0 a19 to a8 a7 to a0 hi-z hi-z hi-z a19 to a8 clkout f clk cpu d7 to d0 wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (read) chapter 5 external bus interface user?s manual u17894ej8v0ud 177 figure 5-4. timing to read external memory (2/2) (c) no wait, 16-bit bus clkout = f clk /2 (exwen = 0, mm3 = 0, mm2 = 1) rd astb ad15 to ad0 a19 to a16 a15 to a0 hi-z hi-z d15 to d0 a19 to a16 clkout f clk cpu (ex.2) cpu (ex.1) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (read) exe (wait) exe (wait) exe (wait) exe (wait) exe (read) (d) with wait, 16-bit bus clkout = f clk /2 (exwen = 1, mm3 = 0, mm2 = 1) rd astb ad15 to ad0 a19 to a16 a15 to a0 hi-z hi-z hi-z a19 to a16 clkout f clk cpu (ex.2) cpu (ex.1) exe (read) exe (wait) d15 to d0 wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (read) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) chapter 5 external bus interface user?s manual u17894ej8v0ud 178 figure 5-5. timing to write to external memory (1/2) (a) no wait, 8-bit bus clkout = f clk (exwen = 0, mm3 = 0, mm2 = 0) wr0 astb ad7 to ad0 a19 to a8 a7 to a0 hi-z hi-z d7 to d0 a19 to a8 clkout f clk cpu exe (wait) exe (wait) exe (wait) exe (write) (b) with wait, 8-bit bus clkout = f clk (exwen = 1, mm3 = 0, mm2 = 0) wr0 astb ad7 to ad0 a19 to a8 a7 to a0 hi-z hi-z a19 to a8 clkout f clk cpu exe (write) d7 to d0 wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) chapter 5 external bus interface user?s manual u17894ej8v0ud 179 figure 5-5. timing to write to external memory (2/2) (c) no wait, 16-bit bus clkout = f clk /2 (exwen = 0, mm3 = 0, mm2 = 1) wr0 astb ad15 to ad0 a19 to a16 a15 to a0 hi-z hi-z d15 to d0 a19 to a16 clkout f clk cpu (ex.2) exe (write) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) cpu (ex.1) exe (write) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) wr1 (d) with wait, 16-bit bus clkout = f clk /2 (exwen = 1, mm3 = 0, mm2 = 1), lower 8-bit writing wr0 astb ad15 to ad0 a19 to a16 a15 to a0 hi-z hi-z a19 to a16 clkout f clk cpu (ex.2) cpu (ex.1) exe (write) exe (wait) d15 to d0 wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (write) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) wr1 chapter 5 external bus interface user?s manual u17894ej8v0ud 180 5.6.2 separate bus mode figure 5-6. timing to read external memory (1/2) (a) no waits, 8-bit bus clkout = f clk (exwen = 0, mm3 = 1, mm2 = 0) rd d7 to d0 a19 to a0 d7 to d0 hi-z hi-z a19 to a0 clkout f clk cpu exe (wait) exe (wait) exe (wait) exe (read) (b) with wait, 8-bit bus clkout = f clk (exwen = 1, mm3 = 1, mm2 = 0) rd d7 to d0 a19 to a0 a19 to a0 clkout f clk cpu exe (read) d7 to d0 hi-z hi-z wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) chapter 5 external bus interface user?s manual u17894ej8v0ud 181 figure 5-6. timing to read external memory (2/2) (c) no wait, 16-bit bus clkout = f clk /2 (exwen = 0, mm3 = 1, mm2 = 1) rd d15 to d0 a15 to a0 d15 to d0 hi-z hi-z a15 to a0 clkout f clk cpu (ex.2) exe (read) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) cpu (ex.1) exe (read) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) (d) with wait, 16-bit bus clkout = f clk /2 (exwen = 1, mm3 = 1, mm2 = 1) rd d15 to d0 a15 to a0 a15 to a0 clkout f clk cpu (ex.2) cpu (ex.1) exe (read) exe (wait) d15 to d0 hi-z hi-z wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (read) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) chapter 5 external bus interface user?s manual u17894ej8v0ud 182 figure 5-7. timing to write to external memory (1/2) (a) no wait, 8-bit bus clkout = f clk (exwen = 0, mm3 = 1, mm2 = 0) wr0 d7 to d0 a19 to a0 d7 to d0 a19 to a0 clkout f clk cpu exe (wait) exe (wait) exe (wait) exe (write) hi-z hi-z (b) with wait, 8-bit bus clkout = f clk (exwen = 1, mm3 = 1, mm2 = 0) wr0 d7 to d0 a19 to a0 a19 to a0 clkout f clk cpu exe (write) d7 to d0 wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) hi-z hi-z chapter 5 external bus interface user?s manual u17894ej8v0ud 183 figure 5-7. timing to write to external memory (2/2) (c) no wait, 16-bit bus clkout = f clk /2 (exwen = 0, mm3 = 1, mm2 = 1) , higher 8-bit writing wr0 d15 to d0 a15 to a0 d15 to d0 a15 to a0 clkout f clk cpu (ex.2) exe (write) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) cpu (ex.1) exe (write) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) wr1 hi-z hi-z (d) with wait, 16-bit bus clkout = f clk /2 (exwen = 1, mm3 = 1, mm2 = 1) wr0 d15 to d0 a15 to a0 a15 to a0 clkout f clk cpu (ex.2) cpu (ex.1) exe (write) exe (wait) d15 to d0 wait exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (write) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) exe (wait) wr1 hi-z hi-z chapter 5 external bus interface user?s manual u17894ej8v0ud 184 5.7 example of connection to memory 5.7.1 connection of external logic (asic, etc.) when connecting the external logic, select the multiple xed bus mode or separate bus mode. when connecting buses, use clkout as the reference clock. other signal s have delay on clkout, however, note with caution that the clkout does not delay on-board or when designing external logic. figure 5-8. example of external logic connection a11 to a8 ad7 to ad0 78k0r/kg3 rd wr0 clkout wait address bus write data bus read write clock wait astb 4 8 en read data bus 5.7.2 connection of synchronous memory use a separate bus mode for connecting a synchronous memory. figure 5-9. example of sy nchronous memory connection a15 to a1 d15 to d0 synchronous memory 78k0r/kg3 rd wr0 clkout wr1 p a14 to a0 (address) d15 to d0 (data) oe (output enable) wr0 (lower byte write enable) clkout (input clock) wr1 (higher byte write enable) ce (chip enable) 15 16 chapter 5 external bus interface user?s manual u17894ej8v0ud 185 5.7.3 connection of asynchronous memory use the separate bus mode for connecting an asynchronous memory. figure 5-10. example of asynchronous memory connection a15 to a1 d15 to d0 asynchronous memory 78k0r/kg3 rd wr0 wr1 p a14 to a0 (address) d15 to d0 (data) oe (output enable) wr0 (lower byte write enable) wr1 (higher byte write enable) ce (chip enable) 15 16 user?s manual u17894ej8v0ud 186 chapter 6 clock generator 6.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 instru ction or setting of mstop (bit 7 of the clock operation status control register (csc)). <2> internal high-speed oscillator this circuit oscillates a clock of f ih = 8 mhz (typ.). after a reset release, the cpu always starts operating with this internal high-speed oscillation cl ock. oscillation can be stopped by executing the stop instruction or setting of hiostop (bit 0 of csc). 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 disabled by executing the stop instruct ion or setting of mstop. as the main system clock, a high-spee d system clock (x1 clock or external ma in system clock) or internal high- speed oscillation clock can be selected by setting of mcm0 (bit 4 of the system clock control register (ckc)). (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). remark f x : x1 clock oscillation frequency f ih : internal high-speed oscillation clock frequency f ex : external main system clock frequency f sub : subsystem clock frequency (3) internal low-speed oscillation clock (clock for watchdog timer) ? internal low-speed oscillator this circuit oscillates a clock of f il = 240 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 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 instruction is executed when bit 4 (wdton) of an option byte (000c0h) = 1 and bit 0 (wdstbyon) = 0 chapter 6 clock generator user?s manual u17894ej8v0ud 187 6.2 configuration of clock generator the clock generator includes the following hardware. table 6-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) peripheral enable register 0, 1 (per0, per1) operation speed mode control register (osmc) internal high-speed oscillator trimming register (hiotrm) oscillators x1 oscillator xt1 oscillator internal high-speed oscillator internal low-speed oscillator chapter 6 clock generator user?s manual u17894ej8v0ud 188 figure 6-1. block diag ram of clock generator f il xt1/p123 xt2//p124 f sub f clk css cls f main osts1 osts0 osts2 3 most 18 most 17 most 15 most 13 most 11 mstop stop exclk oscsel amph 4 f ih x1/p121 x2/exclk /p122 f mx oscsels f x f ex f xt xtstop cls hiostop 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 1 most 10 most 9 most 8 tau0 en sau0 en sau1 en iic0 en adc en dac en rtc en f sub /2 exb en external bus interface internal bus internal bus clock operation mode control register (cmc) clock operation status control register (csc) oscillation stabilization time select register (osts) system clock control register (ckc) x1 oscillation stabilization time counter oscillation stabilization time counter status register (ostc) high-speed system clock oscillator crystal/ceramic oscillation external input clock subsystem clock oscillator crystal oscillation clock operation mode control register (cmc) internal high-speed oscillator (8 mhz (typ.)) internal low-speed oscillator (240 khz (typ.)) clock operation status control register (csc) main system clock source selection watchdog timer real-time counter, clock output/buzzer output peripheral enable register 1 (per1) clock output/ buzzer output prescaler selector selection of cpu clock and peripheral hardware clock source controller peripheral enable register 0 (per0) timer array unit serial array unit 0 serial array unit 1 serial interface iic0 a/d converter d/a converter real-time counter standby control controller chapter 6 clock generator user?s manual u17894ej8v0ud 189 remark f x : x1 clock oscillation frequency f ih : 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 xt : xt1 clock oscillation frequency f sub : subsystem clock frequency f clk : cpu/peripheral hardware clock frequency f il : internal low-speed oscillation clock frequency 6.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) ? peripheral enable registers 0, 1 (per0, per1) ? operation speed mode control register (osmc) ? internal high-speed oscillator trimming register (hiotrm) chapter 6 clock generator user?s manual u17894ej8v0ud 190 (1) clock operation mode control register (cmc) this register is used to set the operation mode of t he x1/p121, x2/exclk/p122, xt 1/p123, and xt2/p124 pins, and to select a gain of the oscillator. cmc can be written only once by an 8-bit memory manipulati on 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. figure 6-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 0 0 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 0 xt1 oscillation mode crystal resonator connection amph control of high-speed system clock oscillation frequency 0 2 mhz f mx 10 mhz 1 10 mhz < f mx 20 mhz 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. it is recommended to set the default value (00h) to cmc after reset release, even when the register is used at the defaul t value, in order to prevent malfunctioning during a program loop. remark f mx : high-speed system clock frequency chapter 6 clock generator user?s manual u17894ej8v0ud 191 (2) clock operation status control register (csc) this register is used to control the op erations of the high-speed system clock, internal high-speed oscillation clock, and subsystem clock (except the 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 6-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 control of high-speed system clock operation 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 0 internal high-speed oscillator operating 1 internal high-speed oscillator stopped cautions 1. after reset release, set the clo ck operation mode control register (cmc) before starting x1 oscillation as set by mstop or xt1 oscillation as set by xtstop. 2. to start x1 oscillation as set by msto p, check the oscillation stabilization time of the x1 clock by using the oscillation st abilization time counter status register (ostc). 3. do not stop the clock selected fo r the cpu peripheral hardware clock (f clk ) with the osc register. chapter 6 clock generator user?s manual u17894ej8v0ud 192 caution 4. the setting of the flags of the regi ster to stop clock osc illation (invalidate the external clock input) and the condition befo re clock oscillation is to be stopped are as follows. table 6-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 ? cls = 0 and mcs = 0 ? cls = 1 (cpu and peripheral hardware cl ocks operate with a clock other than the high-speed system clock.) mstop = 1 subsystem clock ? cls = 0 (cpu and peripheral hardware cl ocks operate with a clock other than the subsystem clock.) xtstop = 1 internal high-speed oscillation clock ? cls = 0 and mcs = 1 ? cls = 1 (cpu and peripheral hardware cl ocks operate with a clock other than the internal high-speed oscillator clock.) 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 wh ile the internal high-spe ed 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 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 chapter 6 clock generator user?s manual u17894ej8v0ud 193 figure 6-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 counter 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 wh ile the 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 the 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 chapter 6 clock generator user?s manual u17894ej8v0ud 194 (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 t he cpu clock, the operation 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, confirm with ostc that the desired oscillation stabilization time has elaps ed after the stop mode is released. the oscillation stabilization time can be checked up to the time set using ostc. osts can be set by an 8-bit memory manipulation instruction. reset signal generation sets osts to 07h. chapter 6 clock generator user?s manual u17894ej8v0ud 195 figure 6-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 th e cpu clock, set the osts register before executi ng 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 counter 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 wh ile the 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 cpu 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 the 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 chapter 6 clock generator user?s manual u17894ej8v0ud 196 (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 6-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 1 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 ) 1 high-speed system clock (f mx ) css mcm0 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 0 0 1 0 1 f ih /2 5 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 2 1 note 3 note 3 f sub /2 other than above setting prohibited notes 1. bits 7 and 5 are read-only. 2. setting is prohibited when f mx < 4 mhz. 3. changing the value of the mcm0 bit is prohibited while css is set to 1. remarks 1. f ih : internal high-speed oscillation clock frequency f mx : high-speed system clock frequency f sub : subsystem clock frequency 2. : don?t care (cautions 1 to 3 are listed on the next page.) chapter 6 clock generator user?s manual u17894ej8v0ud 197 cautions 1. be sure to set bit 3 to 1. 2. the clock set by css, mcm0, and md iv2 to mdiv0 is supplied to the cpu and peripheral hardware. if the cpu clock is changed, therefore, the clock supplied to peripheral hardware (e xcept the real-time counter, clock output/buzzer output, and watchdog timer) is also changed at the same time. consequently, stop each peripheral function when changing the cp u/peripheral operating hardware clock. 3. if the peripheral hardware clock is used as the subsystem cl ock, the operations of the a/d converter and iic0 are not guaranteed. for the operating characteristics of the peri pheral hardware, refer to the chapters describing the various peripheral hardware as well as chapter 29 electrical specifications (standard products) and chapter 30 electrical specifications ((a) grade products) (target). the fastest instruction can be execut ed in 1 clock of the cpu clock in the 78k0r/kg3. therefore, the relationship between the cpu clock (f clk ) and the minimum instruction execution time is as shown in table 6-3. table 6-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 mdiv2 to mdiv0 bits) at 10 mhz operation at 20 mhz operation at 8 mhz (typ.) operation at 32.768 khz operation f main 0.1 s 0.05 s 0.125 s (typ.) ? f main /2 0.2 s 0.1 s 0.25 s (typ.) (default) ? f main /2 2 0.4 s 0.2 s 0.5 s (typ.) ? f main /2 3 0.8 s 0.4 s 1.0 s (typ.) ? f main /2 4 1.6 s 0.8 s 2.0 s (typ.) ? f main /2 5 3.2 s 1.6 s 4.0 s (typ.) ? f sub /2 ? ? 61 s remark f main : main system clock frequency (f ih or f mx ) f sub : subsystem clock frequency chapter 6 clock generator user?s manual u17894ej8v0ud 198 (6) peripheral enable registers 0, 1 (per0, per1) these registers are used to enable or disable use of each peripheral hardware macro. clock supply to the hardware that is not used is also stopped so as to decrease the power consumption and noise. per0 and per1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears theses registers to 00h. figure 6-7. format of periphe ral enable register (1/2) address: f00f0h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> 1 <0> per0 rtcen dacen adcen iic0en sau1en sau0en 0 tau0en address: f00f1h after reset: 00h r/w symbol 7 6 5 4 3 2 1 <0> per1 0 0 0 0 0 0 0 exben rtcen control of real-time counter (rtc) input clock note 0 stops input clock supply. ? sfr used by the real-time counter (rtc) cannot be written (can be read). ? operation of the real-time counter (rtc) continues. 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 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 input clock 0 stops input clock supply. ? sfr used by the a/d converter cannot be written. ? the a/d converter is in the reset status. 1 supplies input clock. ? sfr used by the a/d converter can be read and written. iic0en control of serial interface iic0 input clock 0 stops input clock supply. ? sfr used by the serial interface iic0 cannot be written. ? the serial interface iic0 is in the reset status. 1 supplies input clock. ? sfr used by the serial interface iic0 can be read and written. note the input clock that can be controlled by rtce n is used when the register that is used by the real-time counter (rtc) is accessed from the cpu. rtcen cannot control supply of the operating clock (f sub ) to rtc. caution be sure to clear bit 1 of the per0 register and bits 1 to 7 of the per1 register to 0. chapter 6 clock generator user?s manual u17894ej8v0ud 199 figure 6-7. format of periphe ral enable register (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 1 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. tau0en control of timer array unit input clock 0 stops input clock supply. ? sfr used by the timer array unit cannot be written. ? the timer array unit is in the reset status. 1 supplies input clock. ? sfr used by the timer array unit can be read and written. exben control of external bus interface input clock 0 stops input clock supply. ? sfr used by the external bus interface cannot be written. ? the external bus interface is in the reset status. 1 supplies input clock. ? sfr used by the external bus interface can be read and written. caution be sure to clear bit 1 of the per0 register and bits 1 to 7 of the per1 register to 0. chapter 6 clock generator user?s manual u17894ej8v0ud 200 (7) operation speed mode control register (osmc) this register is used to control the step-up circui t of the flash memory for high-speed operation. if the microcontroller operat es at a low speed with a syst em clock of 10 mhz or less, the power consumption 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 6-8. 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 0 0 0 0 0 0 0 fsel fsel f clk frequency selection 0 operates at a frequency of 10 mhz or less (default). 1 operates at a frequency higher than 10 mhz. cautions 1. osmc can be written only once after reset release, by an 8-bit memory manipulation instruction. 2. 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. 3. the cpu waits when ?1? is written to the fsel flag. interrupt requests issued during a wait will be suspended. the wait time is 16.6 s to 18.5 s when f clk = f ih , and 33.3 s to 36.9 s when f clk = f ih /2. however, counting the oscillati on stabilization time of f x can continue even while the cpu is waiting. 4. 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. 5. even when set to fsel = 1, the system clock can be operated at a frequency of 10 mhz or less. chapter 6 clock generator user?s manual u17894ej8v0ud 201 (8) internal high-speed oscilla tor trimming register (hiotrm) this register is used to adjust the accu racy of the internal high-speed oscillator. with self-measurement of the internal high-speed osc illator frequency via a subsystem clock using a crystal resonator, a timer using high-accuracy external clock inpu t (real-time counter or timer array unit), and so on, the register can adjust the accuracy. hiotrm can be set by an 8-bit memory manipulation instruction. reset signal generation sets this register to 10h. caution the frequency will var y if the temperature and v dd pin voltage change after accuracy adjustment. moreover, if the hiotrm register is set to an y value other than the in itial value (10h), the oscillation accuracy of the internal high-speed oscillation clock may exceed 8 mhz 5%, depending on the subsequent temperature and v dd voltage change, or hiotrm register setting. when the temperature and v dd voltage change, accuracy adjustment must be executed regularly or before th e frequency accuracy is required chapter 6 clock generator user?s manual u17894ej8v0ud 202 figure 6-9. format of internal high-sp eed oscillator trimming register (hiotrm) address: f00f2h after reset: 10h r/w symbol 7 6 5 4 3 2 1 0 hiotrm 0 0 0 ttrm4 ttrm3 ttrm2 ttrm1 ttrm0 clock correction value (target) (2.7 v v dd 5.5 v) ttrm4 ttrm3 ttrm2 ttrm1 ttrm0 min. typ. max. 0 0 0 0 0 ? 5.54% ? 4.88% ? 4.02% 0 0 0 0 1 ? 5.28% ? 4.62% ? 3.76% 0 0 0 1 0 ? 4.99% ? 4.33% ? 3.47% 0 0 0 1 1 ? 4.69% ? 4.03% ? 3.17% 0 0 1 0 0 ? 4.39% ? 3.73% ? 2.87% 0 0 1 0 1 ? 4.09% ? 3.43% ? 2.57% 0 0 1 1 0 ? 3.79% ? 3.13% ? 2.27% 0 0 1 1 1 ? 3.49% ? 2.83% ? 1.97% 0 1 0 0 0 ? 3.19% ? 2.53% ? 1.67% 0 1 0 0 1 ? 2.88% ? 2.22% ? 1.36% 0 1 0 1 0 ? 2.23% ? 1.91% ? 1.31% 0 1 0 1 1 ? 1.92% ? 1.60% ? 1.28% 0 1 1 0 0 ? 1.60% ? 1.28% ? 0.96% 0 1 1 0 1 ? 1.28% ? 0.96% ? 0.64% 0 1 1 1 0 ? 0.96% ? 0.64% ? 0.32% 0 1 1 1 1 ? 0.64% ? 0.32% 0% 1 0 0 0 0 0% (default) 1 0 0 0 1 0% +0.32% +0.64% 1 0 0 1 0 +0.33% +0.65% +0.97% 1 0 0 1 1 +0.66% +0.98% +1.30% 1 0 1 0 0 +0.99% +1.31% +1.63% 1 0 1 0 1 +1.32% +1.64% +1.96% 1 0 1 1 0 +1.38% +1.98% +2.30% 1 0 1 1 1 +1.46% +2.32% +2.98% 1 1 0 0 0 +1.80% +2.66% +3.32% 1 1 0 0 1 +2.14% +3.00% +3.66% 1 1 0 1 0 +2.48% +3.34% +4.00% 1 1 0 1 1 +2.83% +3.69% +4.35% 1 1 1 0 0 +3.18% +4.04% +4.70% 1 1 1 0 1 +3.53% +4.39% +5.05% 1 1 1 1 0 +3.88% +4.74% +5.40% 1 1 1 1 1 +4.24% +5.10% +5.76% caution the internal high-speed o scillation frequency b ecomes faster/slower by increasing/decreasing the hiotrm value to a value larger/smaller th an a certain value. a reversal, such as the frequency becoming slower/faster by increasing/ decreasing the hiotrm value does not occur. chapter 6 clock generator user?s manual u17894ej8v0ud 203 6.4 system clock oscillator 6.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 connection of unused pins . figure 6-10 shows an example of the exte rnal circuit of the x1 oscillator. figure 6-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. 6.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 connection of unused pins . figure 6-11 shows an example of the exte rnal circuit of the xt1 oscillator. figure 6-11. example of external circuit of xt1 oscillator (crystal oscillation) xt2 v ss xt1 32.768 khz cautions are listed on the next page. chapter 6 clock generator user?s manual u17894ej8v0ud 204 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 6-10 and 6-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 lines. do not route the wiring near a signal line through which a high fluctuating current flows. ? always make the ground point of the oscillator capacitor th e same potential as v ss . do not ground the capacitor to a ground pattern through which a high current flows. ? do not fetch signals from the oscillator. note that the xt1 oscillator is designed as a low-amplitude circuit for reducing power consumption. figure 6-12 shows examples of incorrect resonator connection. figure 6-12. examples of incorr ect resonator connection (1/2) (a) too long wiring (b) crossed signal line x2 v ss x1 x1 v ss x2 port remark when using the subsystem clock, replace x1 and x2 with xt1 and xt2, respectively. also, insert resistors in series on the xt2 side. chapter 6 clock generator user?s manual u17894ej8v0ud 205 figure 6-12. examples of incorr ect resonator connection (2/2) (c) wiring near high alternating current (d) current flowing through ground line of oscillator (potential at points a, b, and c fluctuates) v ss x1 x2 v ss x1 x2 ab c pmn v dd high current high current (e) signals are fetched v ss x1 x2 remark when using the subsystem clock, replace x1 and x2 with xt1 and xt2, respectively. also, insert resistors in series on the xt2 side. caution 2. when x2 and xt1 are wired in parallel, the crosstalk noi se of x2 may increase with xt1, resulting in malfunctioning. chapter 6 clock generator user?s manual u17894ej8v0ud 206 6.4.3 internal hi gh-speed oscillator the internal high-speed oscillator is incorporated in the 78k0r/kg3 (8 mhz (typ.)). oscillation can be controlled by bit 0 (hiostop) of the clock operat ion status control register (csc). after a reset release, the internal high-spe ed oscillator automatically starts oscillation. 6.4.4 internal low-speed oscillator the internal low-speed oscillator is incorporated in the 78k0r/kg3. 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 au tomatically starts oscillation, and the watchdog timer is driven (240 khz (typ.)) if the watchdog time r operation 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. 6.4.5 prescaler the prescaler generates cpu/peripheral hardware clock by dividing the main system clock and subsystem clock. chapter 6 clock generator user?s manual u17894ej8v0ud 207 6.5 clock generator operation the clock generator generates the following clocks and cont rols the operation modes of the cpu, such as standby mode (see figure 6-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 ? subsystem clock f sub ? internal low-speed oscillation clock f il ? cpu/peripheral hardware clock f clk the cpu starts operation when the internal high-speed osc illator starts outputting after a reset release in the 78k0r/kg3, thus enabling the following. (1) enhancement of security function when the x1 clock is set as the cpu clock by the default setting, the device cannot operate if the x1 clock is damaged or badly connected and therefore does not operate afte r reset is released. however, the start clock of the cpu is the internal high-speed oscillation clock, so the device can be started by the internal high-speed oscillation clock after a reset release. as a result, reset sources can be detected by software and the minimum amount of safety processing can be done during a nomalies to ensure that t he system terminates safely. (2) improvement of performance because the cpu can be star ted without waiting for the x1 clock o scillation stabilization time, the total performance can be improved. when the power supply voltage is turned on, the clock generator operation is shown in figure 6-13 and figure 6- 14. chapter 6 clock generator user?s manual u17894ej8v0ud 208 figure 6-13. clock generator operation wh en power supply voltage is turned on (when lvi default start function sto pped is set (option byte: lvioff = 1)) internal high-speed oscillation clock (f rh ) cpu clock high-speed system clock (f xh ) (when x1 oscillation selected) internal high-speed oscillation clock high-speed system clock switched by software subsystem clock (f sub ) (when xt1 oscillation selected) subsystem clock x1 clock oscillation stabilization time: 2 8 /f x to 2 18 /f x note 2 starting x1 oscillation is set by software. starting xt1 oscillation is set by software. reset processing waiting for voltage stabilization internal reset signal 0 v 1.59 v (typ.) 1.8 v 0.5 v/ms (min.) power supply voltage (v dd ) <1> <2> <4> <5> <5> <4> note 1 1.92 to 6.17 ms <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 exceeds 1.59 v (typ.), the reset is released and the internal high-speed oscillator automatically starts oscillation. <3> when the power supply voltage rises with a slope of 0.5 v/ms (min.), the cp u starts operation on the internal high-speed oscillation clock after the reset is released and after the stabilization times for the voltage of the power supply and regulator have elapsed, and then reset processing is performed. <4> set the start of oscillation of the x1 or xt1 clock via software (see (1) in 6.6.1 example of controlling high- speed system clock and (1) in 6.6.3 example of cont rolling subsystem clock) . <5> when switching the cpu clock to the x1 or xt1 clock, wait for the clock oscillation to stabilize, and then set switching via software (see (3) in 6.6.1 example of controlli ng high-speed system clock and (2) in 6.6.3 example of controlling subsystem clock ). notes 1. the internal voltage stabilization time includes the o scillation accuracy stabilization time of the internal high-speed oscillation clock. 2. when releasing a reset (above figure) or releas ing stop mode while the cpu is operating on the internal high-speed oscillation clock, confirm the osc illation stabilization time for the x1 clock using the oscillation stabilization time count er status register (ostc). if the cpu operates on the high-speed system clock (x1 oscillation), set the oscillation st abilization time when releasing stop mode using the oscillation stabilization time select register (osts). chapter 6 clock generator user?s manual u17894ej8v0ud 209 cautions 1. if the voltage rises wit h a slope of less 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 power application until the voltage reaches 1.8 v, or set the lvi default st art function stopped by using the option byte (lvioff = 0) (see figure 6-14). by doing so , the cpu operates with the same timing as <2> and thereafter in figure 6-13 afte r reset release by the reset pin. 2. it is not necessary to wait for the oscillati on stabilization time when an external clock input from the exclk pin is used. remark while the microcontroller is operating, a clock t hat is not used as the cpu clock can be stopped via software settings. the internal high-speed oscill ation clock and high-speed system clock can be stopped by executing the stop instruction (see (4) in 6.6.1 example of controlli ng high-speed system clock , (3) in 6.6.2 example of controlling inte rnal high-speed oscillation clock , and (3) in 6.6.3 example of controlling subsystem clock ). figure 6-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)) internal high-speed oscillation clock (f rh ) cpu clock high-speed system clock (f xh ) (when x1 oscillation selected) internal high-speed oscillation clock high-speed system clock switched by software subsystem clock (f sub ) (when xt1 oscillation selected) subsystem clock x1 clock oscillation stabilization time: 2 8 /f x to 2 18 /f x note 2 starting x1 oscillation is set by software. starting xt1 oscillation is set by software. internal reset signal 0 v 2.07 v (typ.) power supply voltage (v dd ) <1> <3> <2> <4> <5> reset processing (43 to 160 s) <4> <5> note 1 <1> when the power is turned on, an internal reset signa l is generated by the low- voltage detector (lvi). <2> when the power supply voltage exceeds 2.07 v (typ.), the reset is released and the internal high-speed oscillator automatically starts oscillation. <3> after the reset is released and reset processing is performed, the cpu starts operation on the internal high- speed oscillation clock. <4> set the start of oscillation of the x1 or xt1 clock via software (see (1) in 6.6.1 example of controlling high- speed system clock and (1) in 6.6.3 example of cont rolling subsystem clock) . <5> when switching the cpu clock to the x1 or xt1 clock, wait for the clock oscillation to stabilize, and then set switching via software (see (3) in 6.6.1 example of controlli ng high-speed system clock and (2) in 6.6.3 example of controlling subsystem clock ). chapter 6 clock generator user?s manual u17894ej8v0ud 210 notes 1. the internal reset processing time includes the o scillation accuracy stabilization time of the internal high-speed oscillation clock. 2. when releasing a reset (above figure) or releas ing stop mode while the cpu is operating on the internal high-speed oscillation clock, confirm the osc illation stabilization time for the x1 clock using the oscillation stabilization time count er status register (ostc). if the cpu operates on the high-speed system clock (x1 oscillation), set the oscillation st abilization time when releasing stop mode using the oscillation stabilization time select register (osts). cautions 1. a voltage oscillation stabilization ti me is required after the supply voltage reaches 1.59 v (typ.). if the supply voltage rises from 1.59 v (typ.) to 2.07 v (typ.) within the power supply oscillation stabilization time, the power supply o scillation stabilization time is automatically generated before reset processing. 2. it is not necessary to wait for the oscillation stabilization ti me when an external clock input from the exclk pin is used. remark while the microcontroller is operating, a clock t hat is not used as the cpu clock can be stopped via software settings. the internal high-speed oscill ation clock and high-speed system clock can be stopped by executing the stop instruction (see (4) in 6.6.1 example of controlli ng high-speed system clock , (3) in 6.6.2 example of controlling inte rnal high-speed oscillation clock , and (3) in 6.6.3 example of controlling subsystem clock ). chapter 6 clock generator user?s manual u17894ej8v0ud 211 6.6 controlling clock 6.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 pins 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 0 0 amph 0 1 0 0/1 0 0 0 0 ? 10 mhz < f x 20 mhz exclk oscsel 0 oscsels 0 0 0 amph 0 1 0 0/1 0 0 0 1 remarks 1. f x : x1 clock oscillation frequency 2. for setting of the p123/xt1 and p124/xt2 pins, see 6.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 only once after reset release, by an 8-bit memory manipulation instruction. therefore, it is necessary to also set the value of the oscsels bit at the same time. for oscsels bit, see 6.6.3 example of controlling subsystem clock. 2. set the x1 clock after th e supply voltage has reached the ope rable voltage of the clock to be used (see chapter 29 electrical specifications (st andard products) and chapter 30 electrical specifications ((a) grade products) (target)). chapter 6 clock generator user?s manual u17894ej8v0ud 212 (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 0 0 amph 1 1 0 0/1 0 0 0 remarks 1. : don?t care 2. for setting of the p123/xt1 and p124/xt2 pins, see 6.6.3 (1) example of setting procedure when oscillati ng 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 only once after reset release, by an 8-bit memory manipulation instruction. therefore, it is necessary to also set the val ue of the oscsels bits at the same time. for oscsels bits, see 6.6.3 example of controlling subsystem clock. 2. set the external main system clock after the supply voltage has reached the operable voltage of the clock to be used (see chapter 29 electrical specifications (standard products) and chapter 30 elec trical specifications ((a) grade products) (target)). (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 6.6.1 (1) example of setting proc edure when oscillating the x1 clock and (2) example of setting procedure when using th e external main system clock. ) note the setting of <1> is not necessary when hi gh-speed system clock is already operating. <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. chapter 6 clock generator user?s manual u17894ej8v0ud 213 <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 iic0en sau1en sau0en 0 tau0en (per1 register) 0 0 0 0 0 0 0 exben xxxen input clock control 0 stops input clock supply. 1 supplies input clock. caution be sure to clear bit 1 of the per0 register and bits 1 to 7 of the per1 register to 0. 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 converter input clock iic0en: control of the serial interface iic0 input clock sau1en: control of the serial array unit 1 input clock sau0en: control of the serial array unit 0 input clock tau0en: control of the timer array unit input clock exben: control of the extern al bus interface input clock (4) example of setting procedure when stopping the high-speed system clock the high-speed system clock can be stopped (disabling clock input 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 per ipheral hardware that cannot be used in stop mode, see chapter 19 standby function ). <2> setting the x1 clock oscillation stabilization time after stop mode is released if the x1 clock oscillates before t he stop mode is entered, set the va lue 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). chapter 6 clock generator user?s manual u17894ej8v0ud 214 (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 oper ating on a clock other than the high-speed system clock. when cls = 0 and mcs = 1, the high-speed system cl ock is supplied to the cpu, so change the cpu clock to the subsystem clock or internal high-speed oscillation clock. cls mcs cpu clock status 0 0 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 regi ster 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 clo ck oscillation 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. 6.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 oscilla tor 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 6.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. chapter 6 clock generator user?s manual u17894ej8v0ud 215 <2> setting the internal high-speed oscillation 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 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 0 1 0 1 f ih /2 5 caution if switching the cpu/pe ripheral hardware clock from th e high-speed system clock to the internal high-speed oscillation clock after restarting the inte rnal 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 oscillati on cannot be guaranteed for 10 s. (3) example of setting procedure when stoppi ng 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 per ipheral hardware that cannot be used in stop mode, see chapter 19 standby function ). <2> setting the x1 clock oscillation stabilization time after stop mode is released if the x1 clock oscillates before t he stop mode is entered, set the va lue of the osts register before executing the stop instruction. <3> executing the stop instruction when the stop instruction is ex ecuted, the system is placed in the stop mode and internal high- speed oscillation clock is stopped. (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 operat ing on a clock other than the internal high-speed oscillation clock. when cls = 0 and mcs = 0, the internal high-speed oscillation clock is supplied to the cpu, so change the cpu clock to the high-spe ed system clock or subsystem clock. cls mcs cpu clock status 0 0 internal high-speed oscillation clock 0 1 high-speed system clock 1 subsystem clock chapter 6 clock generator user?s manual u17894ej8v0ud 216 <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. 6.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 th e real-time counter, clock out put/buzzer output, and watchdog timer). at this time, the oper ations of the a/d converter and iic0 are not guaranteed. for the operating characteristics of the peripheral hardware , refer to the chapters describing the various peripheral hardware as well as chapter 29 electrical specifications (standard products) and chapter 30 electrical specifications ((a) grade products) (target). (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 0 0 amph 0/1 0/1 0 1 0 0 0 0/1 remark for setting of the p121/x1 and p122/x2 pins, see 6.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. <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 written only once after reset release, by an 8-bit memory manipulation instruction. therefore, it is necessary to also set the val ue of the exclk and oscsel bits at the same time. for exclk and oscsel bits, see 6.6.1 (1) example of setting procedure when oscillating the x1 clock or 6.6. 1 (2) example of setting pro cedure when using the external main system clock. chapter 6 clock generator user?s manual u17894ej8v0ud 217 (2) example of setting procedure when us ing the subsystem cl ock as the cpu clock <1> setting subsystem clock oscillation note (see 6.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 sour ce clock of the cpu clock (ckc register) css selection of cpu/peripheral hardware clock (f clk ) 1 f sub /2 caution when the subsystem clock is used as the cp u clock, the subsystem cl ock is also supplied to the peripheral hardware (exc ept the real-time counter, clock output/buzzer output, and watchdog timer). at this time, the operati ons of the a/d converter and iic0 are not guaranteed. for the operating characteristics of the peripheral hardware, refer to the chapters describing the vari ous peripheral hardware as we ll as chapter 29 electrical specifications (standard products) and chapter 30 electrical specifications ((a) grade products) (target). (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. (see figure 6-15 cpu clock status transition diagram or table 6-5 changing cpu clock for the conditions to change the subsystem clock to another clock.) cls mcs cpu clock status 0 0 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, the subsystem clock is stopped. cautions 1. be sure to confi rm that cls = 0 when setting xtstop to 1. in addition, stop the peripheral hardware if it is op erating on the subsystem clock. 2. the subsystem clock oscillation cannot be stopped using the stop instruction. chapter 6 clock generator user?s manual u17894ej8v0ud 218 6.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 oscillator automat ically starts oscillation after a reset release, and the watchdog timer is driven (240 khz (typ.)) if the watchdog time r operation 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 th e 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 osc illation 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/s top mode by the option byte (bit 0 (wdstbyon) of 000c0h) = 0) and when the watchdog timer is stopped as a result of executio n of the halt or stop instruction). chapter 6 clock generator user?s manual u17894ej8v0ud 219 6.6.5 cpu clock stat us transition diagram figure 6-15 shows the cpu clock status transition diagram of this product. figure 6-15. cpu clock stat us transition diagram cpu: operating with x1 oscillation or exclk input (c) (g) cpu: operating with xt1 oscillation cpu: xt1 oscillation halt internal high-speed oscillation: oscillatable x1 oscillation/exclk input: oscillatable xt1 oscillation: operating (d) power on reset release v dd 1.59 v 0.09 v v dd < 1.59 v 0.09 v internal high-speed oscillation: woken up x1 oscillation/exclk input: stops (input port mode) xt1 oscillation: stops (input port mode) internal high-speed oscillation: operating x1 oscillation/exclk input: stops (input port mode) xt1 oscillation: stops (input port mode) (a) v dd 1.8 v cpu: operating with internal high- speed oscillation cpu: internal high- speed oscillation stop internal high-speed oscillation: stops x1 oscillation/exclk input: stops xt1 oscillation: oscillatable cpu: internal high- speed oscillation halt internal high-speed oscillation: operating x1 oscillation/exclk input: oscillatable xt1 oscillation: oscillatable cpu: x1 oscillation/exclk input stop cpu: x1 oscillation/exclk input halt internal high-speed oscillation: stops x1 oscillation/exclk input: stops xt1 oscillation: oscillatable internal high-speed oscillation: oscillatable x1 oscillation/exclk input: operating xt1 oscillation: oscillatable (e) (f) (h) (i) internal high-speed oscillation: operating x1 oscillation/exclk input: selectable by cpu xt1 oscillation: selectable by cpu cpu: operating with xt1 oscillation cpu: xt1 oscillation halt internal high-speed oscillation: selectable by cpu x1 oscillation/exclk input: oscillatable xt1 oscillation: operating internal high-speed oscillation: oscillatable x1 oscillation/exclk input: oscillatable xt1 oscillation: operating (b) (d) (g) internal high-speed oscillation: oscillatable x1 oscillation/exclk input: selectable by cpu xt1 oscillation: operating internal high-speed oscillation: selectable by cpu x1 oscillation/exclk input: operating xt1 oscillation: selectable by cpu remark if the low-voltage 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. chapter 6 clock generator user?s manual u17894ej8v0ud 220 table 6-4 shows transition of the cpu clock and examples of setting the sfr registers. table 6-4. cpu clock transition a nd sfr register setting examples (1/4) (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/1 0 0/1 must not be checked 1 notes 1. the cmc and osmc registers can be written only onc e 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 s upply voltage has reached the operable voltage of the clock to be set (see chapter 29 electrical specificat ions (standard products) and chapter 30 electrical specifications ((a ) grade products) (target)). (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 xtstop waiting for oscillation stabilization css (a) (b) (d) 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 (i) in table 6-4 correspond to (a) to (i) in figure 6-15. chapter 6 clock generator user?s manual u17894ej8v0ud 221 table 6-4. cpu clock transition a nd sfr register setting examples (2/4) (4) 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 0/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 and osmc registers 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 s upply voltage has reached the operable voltage of the clock to be set (see chapter 29 electrical specificat ions (standard products) and chapter 30 electrical specifications ((a ) grade products) (target)). (5) 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. remark (a) to (i) in table 6-4 correspond to (a) to (i) in figure 6-15. chapter 6 clock generator user?s manual u17894ej8v0ud 222 table 6-4. cpu clock transition a nd sfr register setting examples (3/4) (6) 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 these registers are already set (7) cpu clock changing from high-speed system clock (c) 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 (c) (d) 1 0 necessary 1 unnecessary if the cpu is operating with the internal high-speed oscillation clock note the cmc register can be written only once by an 8-bit memory manipulation instru ction after reset release. (8) 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 (i) in table 6-4 correspond to (a) to (i) in figure 6-15. chapter 6 clock generator user?s manual u17894ej8v0ud 223 table 6-4. cpu clock transition a nd sfr register setting examples (4/4) (9) cpu clock changing from subsystem clock (d) to high-sp eed system clock (c) (setting sequence of sfr registers) cmc register note 1 csc register osmc register ckc register setting flag of sfr register status transition exclk oscsel amph osts register mstop fsel ostc register mcm0 css (d) (c) (x1 clock: 2 mhz f x 10 mhz) 0 1 0 note 2 0 0 must be checked 1 0 (d) (c) (x1 clock: 10 mhz < f x 20 mhz) 0 1 1 note 2 0 1 note 3 must be checked 1 0 (d) (c) (external main clock) 1 1 0/1 note 2 0 0/1 must not be checked 1 0 unnecessary if these registers are already set unnecessary if the cpu is operating with the high-spe ed system clock unnecessary if this register is already set notes 1. the cmc and osmc registers 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 s upply voltage has reached the operable voltage of the clock to be set (see chapter 29 electrical specificat ions (standard products) and chapter 30 electrical specifications ((a ) grade products) (target)). (10) ? 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) status transition setting (b) (e) (c) (f) (d) (g) executing halt instruction (11) ? 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 in x1 stop ? (b) (h) in x1 oscillation (c) (i) stopping peripheral functions that cannot operate in stop mode sets the osts register executing stop instruction remark (a) to (i) in table 6-4 correspond to (a) to (i) in figure 6-15. chapter 6 clock generator user?s manual u17894ej8v0ud 224 6.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 6-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 exter nal clock from exclk pin ? oscsel = 1, exclk = 1, mstop = 0 internal high- speed oscillation clock subsystem clock stabilization of x1 oscillation ? oscsels = 1, xtstop = 0 ? after elapse of oscillation stabilization time operating current can be reduced by stopping internal high-speed oscillator (hiostop = 1). internal high- speed oscillation clock oscillation of internal high-speed oscillator ? rstop = 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.) ? x1 clock subsystem clock stabilization of xt1 oscillation ? oscsels = 1, xtstop = 0 ? after elapse of oscillation stabilization time x1 oscillation can be stopped (mstop = 1). internal high- speed oscillation clock oscillation of internal high-speed oscillator ? rstop = 0 external main system clock input can be disabled (mstop = 1). x1 clock transition not possible (to change the clock, set it again after executing reset once.) ? external main system clock subsystem clock stabilization of xt1 oscillation ? oscsels = 1, xtstop = 0 ? after elapse of oscillation stabilization time external main system clock input can be disabled (mstop = 1). chapter 6 clock generator user?s manual u17894ej8v0ud 225 table 6-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 cl ock as main system clock ? oscsel = 1, exclk = 0, mstop = 0 ? after elapse of oscillation stabilization time ? mcs = 1 subsystem clock note external main system clock enabling input of exter nal clock from exclk pin and selection of hi gh-speed system clock as main system clock ? oscsel = 1, exclk = 1, mstop = 0 ? mcs = 1 xt1 oscillation can be stopped (xtstop = 1) note when changing the subsystem clock to another clock, the clock must be set back to the clock before setting the subsystem clock. for example, when changing the clock to the x1 clo ck after having changed the internal high-speed oscillation clock to the subsystem clock, the cl ock is changed in the order of the subsystem clock, the internal high-speed oscillation clock, and the x1 clock. chapter 6 clock generator user?s manual u17894ej8v0ud 226 6.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, mcm0, c ss) of the system clock contro l 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 hi gh-speed system clock), and the division ratio of the main system clock can be changed. the actual switchover operation is not performed immediat ely after rewriting to ckc; operation continues on the pre-switchover clock for several clocks (see table 6-6 to table 6-9 ). whether the cpu is oper ating on the main system clock or the sub system clock can be ascertained using bit 7 (cls) of ckc. whether the main syst em clock is operating on the high-spee d 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. table 6-6. maximum time required for main system clock switchover clock a switching directions clock b type f main (changing the division ratio) f main type 1 (see table 6-7 ) f ih f mx type 2 (see table 6-8 ) f main f sub type 3 (see table 6-9 ) table 6-7. maximum number of clocks required in type 1 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 6-8. maximum number of clocks required in type 2 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 chapter 6 clock generator user?s manual u17894ej8v0ud 227 table 6-9. maximum number of clocks required in type 3 set value before switchover set value after switchover css css 0 (f clk = f main ) 1 (f clk = f sub ) f main user?s manual u17894ej8v0ud 228 chapter 7 timer array unit the timer array unit has eight 16-bit timers per unit. 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. single-operation function comb ination operation function ? interval timer ? square wave output ? external event counter ? divider function (channel 0 only) ? 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 can be used to realize lin-bus reception proces sing in combination with uart3 of serial array unit 1. 7.1 functions of timer array unit the timer array unit has the following functions. 7.1.1 functions of each channel when it operates independently single-operation functions are those f unctions that can be used for any channel regardless of the operation mode of the other channel (for details, refer to 7.6.1 overview of sing le-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 ttm0n) at fixed intervals. (2) square wave output a toggle operation is performed each time inttm0n is ge nerated and a square wave with a duty factor of 50% is output from a timer output pin (to0n). (3) external event counter each timer of a unit can be used as an event counter t hat generates an interrupt when the number of the valid edges of a signal input to the timer input pin (ti0n) has reached a specific value. (4) divider function (channel 0 only) a clock input from a timer input pin (ti00) is divided and output from an output pin (to00). (5) input pulse inte rval measurement counting is started by the valid edge of a pulse signal input to a timer input pin (ti0n). 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 the signal input to the timer input pin (ti0n), and the count value is captured at the other edge. in this way, the high-leve l or low-level width of the input signal can be measured. remark n: channel number (n = 0 to 7) chapter 7 timer array unit user?s manual u17894ej8v0ud 229 7.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 follo wing the master channel) in combination (for details, refer to 7.6.1 overview of singl e-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 pulse 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 ch annel and two or more slave channels, up to seven types of pwm signals that have a specific pe riod and a specified duty fa ctor can be generated. 7.1.3 lin-bus supporting function (channel 7 only) (1) detection of wakeup signal the timer starts counting at the falli ng edge of a signal input to the serial data input pin (rxd3) of uart3 and the count value of the timer is captur ed at the rising edge. in this way, a low-level width can be measured. if the low-level width is greater than a specific value, it is recognized as a wakeup signal. (2) detection of sync break field the timer starts counting at the falling edge of a signal in put to the serial data input pin (rxd3) of uart3 after a wakeup signal is detected, and the count value of the timer is captured at t he 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 and high-level width of the signal input to the serial data input pin (rxd3) of uart3 are measured. from the bit interval of the sync field measured in this way, a baud rate is calculated. chapter 7 timer array unit user?s manual u17894ej8v0ud 230 7.2 configuration of timer array unit the timer array unit includes the following hardware. table 7-1. configuration of timer array unit item configuration timer/counter timer count er register 0n (tcr0n) register timer data register 0n (tdr0n) timer input ti00 to ti07 pins, rxd3 pin (for lin-bus) timer output to00 to to07 pins, output controller chapter 7 timer array unit user?s manual u17894ej8v0ud 231 figure 7-1. block diagram of timer array unit 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 timer output register 0 (to0) to07 to03 to06 to05 to04 to02 to01 to00 timer output enable register 0 (toe0) tau0en peripheral enable register 0 (per0) timer channel enable status register 0 (te0) timer channel stop register 0 (tt0) timer channel start register 0 (ts0) prescaler 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 timer output level register 0 (tol0) timer output mode register 0 (tom0) channel 2 channel 3 channel 4 channel 5 channel 6 channel 7 (lin-bus supported) inttm02 inttm03 inttm04 inttm05 inttm06 inttm07 isc1 noise filter enable register 1 (nfen1) timer input select register 0 (tis0) tnfen 07 tnfen 06 tnfen 05 tnfen 04 tnfen 03 tnfen 02 tnfen 01 tnfen 00 tis07 tis03 tis06 tis05 tis04 tis02 tis01 tis00 selector prs013 prs003 prs012 prs011 prs010 prs002 prs001 prs000 inttm00 pm16 cks01 ccs01 mas ter01 sts012 sts011 sts010 md012 cis011 cis010 md013 md011 md010 ovf 01 ck00 ck01 mck tclk f sub /4 tis01 tnfen01 interrupt controller output controller output latch (p16) inttm01 (timer interrupt) timer status register 01 (tsr01) overflow timer data register 01 (tdr01) timer counter register 01 (tcr01) timer mode register 01 (tmr01) channel 0 channel 1 timer controller trigger selection count clock selection mode selection slave/master controller slave/master controller edge detection selector operating clock selection noise elimination enabled/disabled trigger signal to slave channel clock signal to slave channel interrupt signal to slave channel ti00/p00 rxd3/p14/ ex28 ti02/p17/ to02/ex31 ti03/p31/ to03/intp4 ti04/p42/ to04 ti05/p46/ intp1/to05 ti06/ p131/to06 ti07/p145/ to07 (serial input pin) ti01/ p16/to01/ intp5/ex30 (timer input pin) to00/p01 to02/p17/ti02/ ex31 to03/p31/ti03/ intp4 to04/p42/ti04 to05/p46/intp1/ ti05 to06/p131/ti06 to07/p145/ti07 to01/p16/ti01/ intp5/ex30 (timer output pin) chapter 7 timer array unit user?s manual u17894ej8v0ud 232 (1) timer/counter register 0n (tcr0n) tcr0n is a 16-bit read-only register and is used to count clocks. the value of this counter is incr emented or decremented in synchronization with the rising edge of a count clock. whether the counter is incr emented or decremented depends on the oper ation mode that is selected by the md0n3 to md0n0 bits of tmr0n. figure 7-2. format of timer/counter register 0n (tcr0n) address: f0180h, f0181h (tcr00) to f018eh, f018fh (tcr07) after reset: ffffh r 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tcr0n (n = 0 to 7) the count value can be read by reading tcr0n. the count value is set to ffffh in the following cases. ? when the reset signal is generated ? when the tau0en bit of peripheral enable register 0 (per0) is cleared ? 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 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 caution the count value is not captured to tdr0n even when tcr0n is read. f0181h (tcr00) f0180h (tcr00) chapter 7 timer array unit user?s manual u17894ej8v0ud 233 the tcr0n register read value differs as follows according to operation mode changes and the operating status. table 7-2. tcr0n register read value in various operation modes tcr0n register read value note operation mode count mode operation mode change after reset operation mode change after count operation paused (tt0n = 1) operation restart after count operation paused (tt0n = 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 tdr0n register + 1 note the read values of the tcr0n regi ster when ts0n has been set to "1" while te0n = 0 are shown. the read value is held in the tcr0n register unt il the count operation starts. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 234 (2) timer data register 0n (tdr0n) 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 selecting an operation mode by using the md0n3 to md0n0 bits of tmr0n. the value of tdr0n 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 7-3. format of timer data register 0n (tdr0n) address: fff18h, fff19h (tdr00), fff1ah, fff1bh (tdr01), after reset: 0000h r/w fff64h, fff65h (tdr02) to fff6eh, fff6fh (tdr07) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tdr0n (n = 0 to 7) (i) when tdr0n is used as compare register counting down is started from the value set to tdr0n. when the count value reaches 0000h, an interrupt signal (inttm0n) is generated. tdr0n ho lds its value until it is rewritten. caution tdr0n does not perform a capture operation even if a capture trigger is input, when it is set to the compare function. (ii) when tdr0n is u sed as capture register the count value of tcr0n is captured to tdr0n when the capture trigger is input. a valid edge of the ti0n pin can be selected as the c apture trigger. this selection is made by tmr0n. remark n = 0 to 7 fff19h (tdr00) fff18h (tdr00) chapter 7 timer array unit user?s manual u17894ej8v0ud 235 7.3 registers controlling timer array unit the timer array unit is controlled by the following registers. ? peripheral enable register 0 (per0) ? timer clock select register 0 (tps0) ? timer mode register 0n (tmr0n) ? timer status register 0n (tsr0n) ? timer channel enable status register 0 (te0) ? timer channel start register 0 (ts0) ? timer channel stop register 0 (tt0) ? timer input select register 0 (tis0) ? timer output enable register 0 (toe0) ? timer output register 0 (to0) ? timer output level register 0 (tol0) ? timer output mode register 0 (tom0) ? input switch control register (isc) ? noise filter enable register 1 (nfen1) ? port mode registers 0, 1, 3, 4, 13, 14 (pm0, pm1, pm3, pm4, pm13, pm14) ? port registers 0, 1, 3, 4, 13, 14 (p0, p1, p3, p4, p13, p14) remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 236 (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 reduce the power consumption and noise. when the timer array unit is used, be sure to set bit 0 (tau0en) 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-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 iic0en sau1en sau0en 0 tau0en tau0en control of timer array unit input clock 0 stops supply of input clock. ? sfr used by the timer array unit cannot be written. ? the timer array unit is in the reset status. 1 supplies input clock. ? sfr used by the timer array unit can be read/written. cautions 1. when setting the timer array unit, be sure to set tau0en to 1 first. if tau0en = 0, writing to a control register of the timer array uni t is ignored, and all read values are default values (except for timer input sel ect register 0 (tis0), input switch control register (isc), noise filter enable register 1 (nfen1), port mode registers 0, 1, 3, 4, 13, 14 (pm0, pm1, pm3, pm4, pm13, pm14), and port registers 0, 1, 3, 4, 13, 14 (p0, p1, p3, p4, p13, p14)). 2. be sure to clear bit 1 of the per0 register to 0. chapter 7 timer array unit user?s manual u17894ej8v0ud 237 (2) timer clock select register 0 (tps0) tps0 is a 16-bit register that is used to select two ty pes of operation clocks (ck00, ck01) that are commonly supplied to each channel. ck01 is selected by bits 7 to 4 of tps0, and ck00 is selected by bits 3 to 0. rewriting of tps0 during timer operation is possible only in the following cases. rewriting of prs000 to prs003 bits: possible only when all the channels set to cks0n = 0 are in the operation stopped state (te0n = 0) rewriting of prs010 to prs013 bits: possible only when all the channels set to cks0n = 1 are in the operation stopped state (te0n = 0) tps0 can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tps0 can be set with an 8-bi t memory manipulation instruction with tps0l. reset signal generation clears this register to 0000h. figure 7-5. format of timer cl ock select register 0 (tps0) address: f01b6h, f01b7h after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tps0 0 0 0 0 0 0 0 0 prs 013 prs 012 prs 011 prs 010 prs 003 prs 002 prs 001 prs 000 selection of operation clock (ck0m) note prs 0m3 prs 0m2 prs 0m1 prs 0m0 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 note when changing the clock selected for f clk (by changing the system clock control register (ckc) value), stop the timer array unit (tt0 = 00ffh). caution be sure to clear bits 15 to 8 to ?0?. remarks 1. f clk : cpu/peripheral hardware clock frequency 2. m = 0, 1 n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 238 (3) timer mode register 0n (tmr0n) tmr0n sets an operation mode of channel n. it is us ed to select an operation clock (mck), a count clock, whether the timer operates as the master or a slave, a st art trigger and a capture trigger, the valid edge of the timer input, and an operation mode (interval, captur e, event counter, one-count, or capture & one-count). rewriting tmr0n is prohibited when the register is in operation (when te0 = 1). however, bits 7 and 6 (cis0n1, cis0n0) can be rewritten even while the register is operating with some functions (when te0 = 1) (for details, see 7.7 operation of timer array unit as independent channel and 7.8 operation of plural channels of timer array unit ). tmr0n can be set by a 16-bit memory manipulation instruction. reset signal generation clears this register to 0000h. figure 7-6. format of timer mode register 0n (tmr0n) (1/3) address: f0190h, f0191h (tmr00) to f019eh, f019fh (tmr07) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks 0n 0 0 ccs 0n mast er0n sts 0n2 sts 0n1 sts 0n0 cis 0n1 cis 0n0 0 0 md 0n3 md 0n2 md 0n1 md 0n0 cks 0n selection of operation cl ock (mck) of channel n 0 operation clock ck00 set by prs register 1 operation clock ck01 set by prs register operation clock mck is used by the edge detector. a count clock (tclk) is generated depending on the setting of the ccs0n bit. ccs 0n selection of count clock (tclk) of channel n 0 operation clock mck specified by cks0n bit 1 valid edge of input signal input from ti 0n pin/subsystem clock divided by 4 (f sub /4) count clock tclk is used for the timer/counter, output controller, and interrupt controller. mas ter 0n selection of operation in single-oper ation function or as slave channel in combination operation function/ operation as master channel in combination operation function of channel n 0 operates in single-operation f unction or as slave channel in combination operation function. 1 operates as master channel in combination operation function. only the even channel can be set as a master channel (master0n = 1). be sure to use the odd channel as a slave channel (master0n = 0). clear master0n to 0 for a channel that is used as the single-operation function. caution be sure to clear bits 14, 13, 5, and 4 to ?0?. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 239 figure 7-6. format of timer mode register 0n (tmr0n) (2/3) address: f0190h, f0191h (tmr00) to f019eh, f019fh (tmr07) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks 0n 0 0 ccs 0n mast er0n sts 0n2 sts 0n1 sts 0n0 cis 0n1 cis 0n0 0 0 md 0n3 md 0n2 md 0n1 md 0n0 sts 0n2 sts 0n1 sts 0n0 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 ti0n pin input is used as both the start trigger and capture trigger. 0 1 0 both the edges of ti0n pin input are us ed 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 0n1 cis 0n0 selection of ti0n pin input valid edge 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 sts 0n2 to sts0n0 bits is other than 010b, set the cis0n1 to cis0n0 bits to 10b. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 240 figure 7-6. format of timer mode register 0n (tmr0n) (3/3) address: f0190h, f0191h (tmr00) - f019eh, f019fh (tmr07) after reset: 0000h r/w symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks 0n 0 0 ccs 0n mast er0n sts 0n2 sts 0n1 sts 0n0 cis 0n1 cis 0n0 0 0 md 0n3 md 0n2 md 0n1 md 0n0 md 0n3 md 0n2 md 0n1 md 0n0 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 md0n0 bits varies depending on each operation mode (see table below). operation mode (value set by the md0n3 to md0n1 bits (see table above)) md 0n0 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 (ts0n = 1) is issued during operation, t he counter is cleared, an interrupt is generated, and recounting is started. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 241 (4) timer status register 0n (tsr0n) tsr0n indicates the overflow status of the counter of channel n. tsr0n is valid only in the capture mode (md0n3 to md0n1 = 010b) and capture & one-count mode (md0n3 to md0n1 = 110b). it will not be set in any other mode. se e table 7-3 for the operation of the ovf bit in each operation mode and set/clear conditions. tsr0n can be read by a 16-bit memory manipulation instruction. the lower 8 bits of tsr0n can be set with an 8-bi t memory manipulation instruction with tsr0nl. reset signal generation clears this register to 0000h. figure 7-7. format of timer status register 0n (tsr0n) address: f01a0h, f01a1h (tsr00) to f01aeh, f01afh (tsr07) after reset: 0000h r symbol 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tsr0n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ovf ovf counter overflow status of channel n 0 overflow does not occur. 1 overflow occurs. when ovf = 1, this flag is cleared (ovf = 0) when the next value is captured without overflow. table 7-3. ovf bit operation and set/cl ear conditions in each operation mode timer operation mode ovf 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 ovf bit does not change immediately after the counter has overflowed, but changes upon the subsequent capture. chapter 7 timer array unit user?s manual u17894ej8v0ud 242 (5) timer channel enable status register 0 (te0) te0 is used to enable or stop the timer operation of each channel. when a bit of timer channel start register 0 (ts0) is set to 1, the corresponding bit of this register is set to 1. when a bit of timer channel stop register 0 (tt0) is set to 1, the corresponding bit of this register is cleared to 0. te0 can be read by a 16-bit memory manipulation instruction. the lower 8 bits of te0 can be set with a 1-bit or 8-bit memory manipulation instruction with te0l. reset signal generation clears this register to 0000h. figure 7-8. format of timer channe l enable status register 0 (te0) 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 te0n indication of operation enable/stop status of channel n 0 operation is stopped. 1 operation is enabled. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 243 (6) timer channel start register 0 (ts0) ts0 is a trigger register that is used to clear a time r counter (tcr0n) and start t he counting operation of each channel. when a bit (ts0n) of this register is set to 1, the co rresponding bit (te0n) of timer channel enable status register 0 (te0) is set to 1. ts0n is a trigger bit and cleared immediately when te0n = 1. ts0 can be set by a 16-bit memory manipulation instruction. the lower 8 bits of ts0 can be set with a 1-bit or 8-bit memory manipulation instruction with ts0l. reset signal generation clears this register to 0000h. figure 7-9. format of timer channel start register 0 (ts0) 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 ts0n operation enable (start ) trigger of channel n 0 no trigger operation 1 te0n is set to 1 and the count operation becomes enabled. the tcr0n count operation start in the count ope ration enabled state varies depending on each operation mode (see table 7-4). caution be sure to clear bits 15 to 8 to ?0?. remarks 1. when the ts0 register is read, 0 is always read. 2. n = 0 to 7 table 7-4. operations from count operati on enabled state to tcr0n count start (1/2) timer operation mode operat ion when ts0n = 1 is set ? interval timer mode no operation is carried out from start tri gger detection (ts0n=1) until count clock generation. the first count clock loads the value of tdr0n to tcr0n and the subsequent count clock performs count down operation (see 7.3 (6) (a) start timing in interval timer mode ). ? event counter mode writing 1 to ts0n bit loads the value of tdr0n to tcr0n. the subsequent count clock performs count down operation. the external trigger detection selected by sts0n2 to sts0n0 bits in the tmr0n register does not start count operation (see 7.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 tcr0n and the subsequent count clock performs count up operation (see 7.3 (6) (c) start timing in capture mode ). chapter 7 timer array unit user?s manual u17894ej8v0ud 244 table 7-4. operations from count operati on enabled state to tcr0n count start (2/2) timer operation mode operat ion when ts0n = 1 is set ? one-count mode when ts0n = 0, writing 1 to ts0n 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 tdr0n to tcr0n and the subsequent count clock performs count down operation (see 7.3 (6) (d) start timing in one- count mode ). ? capture & one-count mode when ts0n = 0, writing 1 to ts0n 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 tcr0n and the subsequent count clock performs count up operation (see 7.3 (6) (e) start timing in capture & one- count mode ). (a) start timing in interval timer mode <1> writing 1 to ts0n sets te0n = 1 <2> the write data to ts0n is held until count clock generation. <3> tcr0n holds the initial val ue until count clock generation. <4> on generation of count clock, the ?tdr0n va lue? is loaded to tcr0n and count starts. figure 7-10. start timing (in interval timer mode) ts0n (write) te0n count clock f clk tcr0n inttm0n initial value tdr0n value when md0n0 = 1 is set <1> <2> <3> <4> start trigger detection signal ts0n (write) hold signal caution in the first cycle operation of count clock after writing ts0n, an error at a maximum of one clock is generated since count start delays until count clock has been generated. when the information on count start timing is necessary, an interrupt can be generated at count start by setting md0n0 = 1. chapter 7 timer array unit user?s manual u17894ej8v0ud 245 (b) start timing in event counter mode <1> while te0n is set to 0, tcr0n holds the initial value. <2> writing 1 to ts0n sets 1 to te0n. <3> as soon as 1 has been written to ts0n and 1 has been set to te0n, the "tdr0n value" is loaded to tcr0n to start counting. <4> after that, the tcr0n value is count ed down according to the count clock. figure 7-11. start timing (in event counter mode) te0n f clk tcr0n tdr0n value <1> <1> <2> <3> tdr0n value ? 1 initial value ts0n (write) count clock start trigger detection signal ts0n (write) hold signal (c) start timing in capture mode <1> writing 1 to ts0n sets te0n = 1 <2> the write data to ts0n is held until count clock generation. <3> tcr0n holds the initial val ue until count clock generation. <4> on generation of count clock, 0000h is loaded to tcr0n and count starts. figure 7-12. start timing (in capture mode) te0n f clk tcr0n inttm0n 0000h <1> <2> <3> <4> initial value when md0n0 = 1 is set ts0n (write) count clock start trigger detection signal ts0n (write) hold signal caution in the first cycle operation of count clock after writing ts0n, an error at a maximum of one clock is generated since count start delays until count clock has been generated. when the information on count start timing is necessary, an interrupt can be generated at count start by setting md0n0 = 1. chapter 7 timer array unit user?s manual u17894ej8v0ud 246 (d) start timing in one-count mode <1> writing 1 to ts0n sets te0n = 1 <2> enters the start trigger input wait status, and tcr0n holds the initial value. <3> on start trigger detection, the ?tdr0n value? is loaded to tcr0n and count starts. figure 7-13. start timing (in one-count mode) te0n f clk tcr0n start trigger input wait status tdr0n value initial value <1> <2> <3> ts0n (write) count clock note start trigger detection signal ts0n (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 (ccs0n = 0). caution an input signal sampling error is gene rated since operation starts upon start trigger detection (the error is one count clock when ti0n is used). chapter 7 timer array unit user?s manual u17894ej8v0ud 247 (e) start timing in capture & one-count mode <1> writing 1 to ts0n sets te0n = 1 <2> enters the start trigger input wait status, and tcr0n holds the initial value. <3> on start trigger detection, 0000h is loaded to tcr0n and count starts. figure 7-14. start timing (in capture & one-count mode) te0n f clk tcr0n 0000h ts0n (write) count clock note start trigger detection signal ts0n (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 operat ion clock (mck) is selected as count clock (ccs0n = 0). caution an input signal sampling error is gene rated since operation starts upon start trigger detection (the error is one count clock when ti0n is used). chapter 7 timer array unit user?s manual u17894ej8v0ud 248 (7) timer channel stop register 0 (tt0) tt0 is a trigger register that is used to clear a ti mer counter (tcr0n) and start the counting operation of each channel. when a bit (tt0n) of this register is set to 1, the corresponding bit (te 0n) of timer channel enable status register 0 (te0) is cleared to 0. tt0n is a tri gger bit and cleared to 0 immediately when te0n = 0. tt0 can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tt0 can be set with a 1-bit or 8-bit memory manipulation instruction with tt0l. reset signal generation clears this register to 0000h. figure 7-15. format of timer channel stop register 0 (tt0) 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 tt0n 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 to ?0?. remarks 1. when the tt0 register is read, 0 is always read. 2. n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 249 (8) timer input select register 0 (tis0) tis0 is used to select whether a signal input to the time r input pin (ti0n) or the subsystem clock divided by four (f sub /4) is valid for each channel. tis0 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 7-16. format of timer input select register 0 (tis0) 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 tis0n selection of timer input/sub system clock used with channel n 0 input signal of timer input pin (ti0n) 1 subsystem clock divided by 4 (f sub /4) (9) timer output enable register 0 (toe0) toe0 is used to enable or disable timer output of each channel. channel n for which timer output has been enabled become s unable to rewrite the value of the to0n bit of the timer output register (to0) described later by software, and the value reflecting the setting of the timer output function through the count operation is out put from the timer output pin (to0n). toe0 can be set by a 16-bit memory manipulation instruction. the lower 8 bits of toe0 can be set with a 1-bit or 8-bit memory manipulation instruction with toe0l. reset signal generation clears this register to 0000h. figure 7-17. format of timer output enable register 0 (toe0) 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 toe 0n timer output enable/disable of channel n 0 the to0n operation stopped by count operation (timer channel output bit). writing to the to0n bit is enabled. the to0n pin functions as data output, and it outputs the level set to the to0n bit. the output level of the to0n pin can be manipulated by software. 1 the to0n operation enabled by count oper ation (timer channel output bit). writing to the to0n bit is di sabled (writing is ignored). the to0n pin functions as timer output, and the toe0n is set or reset depending on the timer operation. the to0n pin outputs the square-wave or pwm depending on the timer operation. caution be sure to clear bits 15 to 8 to ?0?. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 250 (10) timer output register 0 (to0) to0 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 (to0n) of each channel. this register can be rewritten by software only when ti mer output is disabled (toe0n = 0). when timer output is enabled (toe0n = 1), rewriting this register by softw are is ignored, and the value is changed only by the timer operation. to use the p01/to00, p16/to01, p17/to02, p31/to03, p 42/to04, p46/to05, p 131/to06, or p145/to07 pin as a port function pin, set the corresponding to0n bit to ?0?. to0 can be set by a 16-bit memory manipulation instruction. the lower 8 bits of to0 can be set with an 8-bi t memory manipulation instruction with to0l. reset signal generation clears this register to 0000h. figure 7-18. format of timer output register 0 (to0) 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 to0 n timer output of channel n 0 timer output value is ?0?. 1 timer output value is ?1?. caution be sure to clear bits 15 to 8 to ?0?. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 251 (11) timer output level register 0 (tol0) tol0 is a register that controls t he timer output level of each channel. the setting of the inverted output of channel n by this register is reflec ted at the timing of set or reset of the timer output signal while the timer output is enabled (t oe0n = 1) in the combination operation mode (tom0n = 1). in the toggle mode (tom0n = 0), this register setting is invalid. tol0 can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tol0 can be set with an 8-bi t memory manipulation instruction with tol0l. reset signal generation clears this register to 0000h. figure 7-19. format of timer output level register 0 (tol0) 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 tol 0n control of timer output level of channel n 0 positive logic out put (active-high) 1 inverted output (active-low) caution be sure to clear bits 15 to 8 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 imm ediately after the register value is rewritten. 2. n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 252 (12) timer output mode register 0 (tom0) tom0 is used to control the timer output mode of each channel. when a channel is used for the single- operation function, set the corres ponding bit of the channel to be used to 0. when a channel is used for the combination operati on function (pwm output, one-shot pulse output, or multiple pwm output), set the corresponding bit of the master channel to 0 and the corresponding bit of the slave channel to 1. the setting of each channel n by this register is reflec ted at the timing when the timer output signal is set or reset while the timer output is enabled (toe0n = 1). tom0 can be set by a 16-bit memory manipulation instruction. the lower 8 bits of tom0 can be set with an 8-bi t memory manipulation instruction with tom0l. reset signal generation clears this register to 0000h. figure 7-20. format of timer output mode register 0 (tom0) 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 tom 0n control of timer output mode of channel n 0 toggle mode (to produce toggle output by timer interrupt request signal (inttm0n)) 1 combination operation mode (output is set by the timer interrupt request signal (inittm0n) of the master channel, and reset by the timer interrupt request signal (inittm0m) of the slave channel) caution be sure to clear bits 15 to 8 to ?0?. remark n: channel number, m: slave channel number n = 0 to 7 (n = 0, 2, 4, 6 for master channel) n < m 7 (where m is a consecutiv e integer greater than n) chapter 7 timer array unit user?s manual u17894ej8v0ud 253 (13) input switch control register (isc) isc is used to implement lin-bus communication operat ion with channel 7 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 7-21. 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 0 0 0 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 2 to ?0?. remark when the lin-bus communication function is used, select the input signal of the rxd3 pin by setting isc1 to 1. (14) noise filter enable register 1 (nfen1) nfen1 is used to set whether the noise filter c an 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, matc h detection and synchronization of the 2 clocks is performed with the cpu/peripheral hardware clock (f clk ). when the noise filter is off, only synchronization is performed with the cpu/peripheral hardware clock (f clk ). nfen1 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. chapter 7 timer array unit user?s manual u17894ej8v0ud 254 figure 7-22. format of noise filt er enable register 1 (nfen1) 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/to 07/p145 pin or rxd3/p14/ex26 pin input signal note 0 noise filter off 1 noise filter on tnfen06 enable/disable using noise filt er of ti06/to06/p131 pin input signal 0 noise filter off 1 noise filter on tnfen05 enable/disable using noise filt er of ti05/to05/p46 pin input signal 0 noise filter off 1 noise filter on tnfen04 enable/disable using noise filt er of ti04/to04/p42 pin input signal 0 noise filter off 1 noise filter on tnfen03 enable/disable using noise filter of ti03/to03/intp4/p31 pin input signal 0 noise filter off 1 noise filter on tnfen02 enable/disable using noise filt er of ti02/to02/p17 pin input signal 0 noise filter off 1 noise filter on tnfen01 enable/disable using noise filter of ti01/to01/intp5/p16 pin input signal 0 noise filter off 1 noise filter on tnfen00 enable/disable using noise f ilter of ti00/p00 pin input signal 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. chapter 7 timer array unit user?s manual u17894ej8v0ud 255 (15) port mode registers 0, 1, 3, 4, 13, 14 (pm0, pm1, pm3, pm4, pm13, pm14) these registers set input/output of ports 0, 1, 3, 4, 13, and 14 in 1-bit units. when using the p01/to00, p16/to01/ti01/intp5/ex3 0, p17/to02/ti02/ex31, p31/to03/ti03/intp4, p42/to04/ti04, p46/to05/ti05/intp1, p131/to06/ti06, and p145/to07/ti07 pins for timer output, set pm01, pm16, pm17, pm31, pm 42, pm46, pm131, and pm145 an d the output latches of p01, p16, p17, p31, p42, p46, p131, and p145 to 0. when using the p00/ti00, p16/to 01/ti01/intp5/ex30, p17/to02/ti 02/ex31, p31/to03/ti03/intp4, p42/to04/ti04, p46/to05/ti05/intp1, p131/to06/ti06, and p145/to07/ti07 pins for timer input, set pm00, pm16, pm17, pm31, pm42, pm 46, pm131, and pm145 to 1. at this ti me, the output latches of p00, p16, p17, p31, p42, p46, p131, and p145 may be 0 or 1. pm0, pm1, pm3, pm4, pm13, and pm14 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation se ts these registers to ffh. figure 7-23. format of port mode registers 0, 1, 3, 4, 13, and 14 (pm0, pm1, pm3, pm4, pm13, pm14) address: fff20h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm0 1 pm06 pm05 pm04 pm03 pm02 pm01 pm00 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 1 1 1 pm31 pm30 address: fff24h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm4 pm47 pm46 pm45 pm44 pm43 pm42 pm41 pm40 address: fff2dh after reset: feh r/w symbol 7 6 5 4 3 2 1 0 pm13 1 1 1 1 1 1 pm131 0 address: fff2eh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm14 1 1 pm145 pm144 pm143 pm142 pm141 pm140 pmmn pmn pin i/o mode selection (m = 0, 1, 3, 4, 13, 14; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) chapter 7 timer array unit user?s manual u17894ej8v0ud 256 7.4 channel output (to0n pin) control 7.4.1 to0n pin output circuit configuration figure 7-24. output circuit configuration interrupt signal of the master channel (inttm0n) tol0n tom0n toe0n <1> <2> <3> <4> <5> to0n write signal to0n pin to0n register set reset/toggle internal bus interrupt signal of the slave channel (inttm0p) controller the following describes the to0n pin output circuit. <1> when tom0n = 0 (toggle mode), the set value of t he tol0n register is ignored and only inttm0p (slave channel timer interrupt) is transmitted to the to0n register. <2> when tom0n = 1 (combination operation mode), both inttm0n (master channel timer interrupt) and inttm0p (slave channel timer interrupt) are transmitted to the to0n register. at this time, the tol0n register becomes valid and the signals are controlled as follows: when tol0n = 0: forward operation (inttm0 set, inttm0p reset) when tol0n = 1: reverse operation (inttm0 reset, inttm0p set) when inttm0n and inttm0p are simultaneously generated, (0% output of pwm), inttm0p (reset signal) takes priority, and inttm0n (set signal) is masked. <3> when toe0n = 1, inttm0n (master channel timer interrupt) and inttm0p (slave channel timer interrupt) are transmitted to the to0n register. writing to t he to0n register (to0n write signal) becomes invalid. when toe0n = 1, the to0n pin output never chang es with signals other than interrupt signals. to initialize the to0n pin output level, it is nece ssary to set toe0n = 0 and to write a value to to0n. <4> when toe0n = 0, writing to to0n bit to the tar get channel (to0n signal) becomes valid. when toe0n = 0, neither inttm0n (master channel timer interrupt) nor inttm0p (slave channel timer interrupt) is transmitted to to0n register. <5> the to0n register can always be read, and the to0n pin output level can be checked. remarks 1. n = 0 to 7 (n = 0, 2, 4, or 6 for master channel) 2. p = n + 1, n + 2, n + 3 ... (where p 7) chapter 7 timer array unit user?s manual u17894ej8v0ud 257 7.4.2 to0n pin output setting the following figure shows the procedure and status transition of to0n out put pin from initial setting to timer operation start. figure 7-25. status transition from ti mer output setting to operation start tcr0n timer alternate-function pin timer output signal toe0n to0n (counter) undefined value (ffffh after reset) write operation enabled period to to0n <1> set tom0n set tol0n <4> set the port to output mode <2> set to0n <3> set toe0n <5> timer operation start write operation disabled period to to0n hi-z <1> the operation mode of timer output is set. ? tom0n bit (0: toggle mode, 1: combination operation mode) ? tol0n bit (0: forward output, 1: reverse output) <2> the timer output signal is set to the initial status by setting to0n. <3> the timer output operation is enabled by wr iting 1 to toe0n (writing to to0n is disabled). <4> the port i/o setting is set to output (see 7.3 (15) port mode registers 0, 1, 3, 4, 13, 14 ). <5> the timer operation is enabled (ts0n = 1). remark n = 0 to 7 7.4.3 cautions on channel output operation (1) changing values set in registers to0, toe0, tol0, and tom0 during timer operation since the timer operations (operati ons of tcr0n and tdr0n) are indepen dent of the to0n output circuit and changing the values set in to0, toe0, tol0, and tom0 does not affect the timer operation, the values can be changed during timer operation. to output an expected waveform from the to0n pin by timer operation, however, set to0, toe0, tol0, and tom0 to the val ues stated in the register setting example of each operation. when the values set in toe0, tol0, and tom0 (except for to0) are changed close to the timer interrupt (inttm0n), the waveform output to the to0n pin ma y be different depending on whether the values are changed immediately before or immediately after the ti mer interrupt (inttm0n) signal generation timing. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 258 (2) default level of to0n pin and output level after timer operation start the following figure shows the to0n pin output level transition when writing has been done in the state of toe0n = 0 before port output is enabled and toe0n = 1 is set after changing the default level. (a) when operation starts with tom0n = 0 setting (toggle output) the setting of tol0n is invalid when tom0n = 0. when the timer operation starts after setting the default level, the toggle signal is generated an d the output level of to0n pin is reversed. figure 7-26. to0n pin output status at toggle output (tom0n = 0) toe0n to0n = 0, tol0n = 0 to0n = 1, tol0n = 0 to0n = 0, tol0n = 1 (same output waveform as tol0n = 0) to0n = 1, tol0n = 1 (same output waveform as tol0n = 0) default level, tol0n setting independent of tol0n setting port output is enabled to0n pin transition toggle toggle toggle toggle toggle hi-z hi-z hi-z hi-z dependent on to0n setting remarks 1. toggle: reverse to0n pin output status 2. n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 259 (b) when operation starts with tom0n = 1 setti ng (combination operati on mode (pwm output)) when tom0n = 1, the active level is determined by tol0n setting. figure 7-27. to0n pin output stat us at pwm output (tom0n = 1) toe0n to0n = 0, tol0n = 0 (active high) to0n = 1, tol0n = 0 (active high) to0n = 0, tol0n = 1 (active low) to0n = 1, tol0n = 1 (active low) default level, tol0n setting dependent on tol0n setting dependent on to0n setting no change set reset set reset set hi-z hi-z hi-z hi-z to0n pin transition port output is enabled remarks 1. set: the output signal of to0n pin changes from inactive level to active level. reset: the output signal of to0n pin changes from active level to inactive level. 2. n = 0 to 7 (3) operation of to0n pin in combination operation mode (tom0n = 1) (a) when tol0n setting has been changed during timer operation when the tol0n setting has been changed during timer operation, the setting becomes valid at the generation timing of to0n change condition. rewriti ng tol0n does not change the output level of to0n. the following figure shows the operation when the value of tol0n has been changed during timer operation (tom0n = 1). figure 7-28. operation when tol0n ha s been changed during timer operation internal set signal internal reset signal tol0n to0n pin set/reset signals are inverted to0n does not change remarks 1. set: the output signal of to0n pin changes from inactive level to active level. reset: the output signal of to0n pin changes from active level to inactive level. 2. n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 260 (b) set/reset timing to realize 0%/100% output at pwm output, the to0n pi n/to0n set timing at master channel timer interrupt (inttm0n) generation is delayed by 1 count clock by the slave channel. if the set condition and reset condition are generated at the same time, a higher priority is given to the latter. figure 7-29 shows the set/reset operat ing statuses where the master/sla ve channels are set as follows. master channel: toe0n = 1, tom0n = 0, tol0n = 0 slave channel: toe0p = 1, tom0p = 1, tol0p = 0 figure 7-29. set/reset ti ming operat ing statuses to_reset (internal signal) to_reset (internal signal) (internal signal) inttm0n to0n pin/ to0n to0p pin/ to0p count clock f clk inttm0p to_set delays to_reset by 1 count clock with slave channel toggle set reset master channel slave channel remarks 1. to_reset: to0n pin reset/toggle signal to_set: to0n pin set signal 2. n = 0 to 7 (where n = 0, 2, 4, or 6 for master channel) 3. p = n + 1, n + 2, n + 3 ... (where p 7) chapter 7 timer array unit user?s manual u17894ej8v0ud 261 7.4.4 collective manipul ation of to0n bits in the to0 register, the setting bits for all the channels ar e located in one register in the same way as the ts0 register (channel start trigger). theref ore, to0n of all the channels can be manipu lated collectively. only specific bits can also be manipulated by setting the correspondi ng toe0n = 0 to a target to0n (channel output). figure 7-30. example of to0n 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 to0n bits with toe0n = 0, and writing to to0n bits with toe0n = 1 is ignored. to0n (channel output) to which toe0n = 1 is set is not affe cted by the write op eration. even if the write operation is done to to0n, it is ignored and the output change by timer operation is normally done. figure 7-31. to0n pin statuses by collective manipulation of to0n bit to07 to06 to05 to04 to03 to02 to01 to00 two or more to0n output can be changed simultaneously output does not change when value does not change before writing writing to to0n register is ignored when toe0n = 1 writing to to0n register (caution and remark are given on the next page.) o o o chapter 7 timer array unit user?s manual u17894ej8v0ud 262 caution when toe0n = 1, even if the output by ti mer interrupt of each timer (inttm0n) contends with writing to to0n, output is normally done to to0n pin. remark n = 0 to 7 7.4.5 timer interrupt and to0n pin output at count operation start in the interval timer mode or capture mode, the md0n0 bit in the tmr0n register sets whether or not to generate a timer interrupt at count start. when md0n0 is set to 1, the count operation start timing can be known by the timer interrupt (inttm0n) generation. in the other modes, neither timer interrupt at c ount operation start nor to 0n output is controlled. figures 7-32 and 7-33 show operation examples when the interval timer mode (toe0n = 1, tom0n = 0) is set. figure 7-32. when md0n0 is set to 1 tcr0n te0n to0n inttm0n count operation start when md0n0 is set to 1, a timer interrupt (inttm0n) is output at count operation start, and to0n performs a toggle operation. figure 7-33. when md0n0 is set to 0 tcr0n te0n to0n inttm0n count operation start when md0n0 is set to 0, a timer interrupt (inttm0n) is not output at count operation start, and to0n does not change either. after counting one cycle, inttm0n is output and to0n performs a toggle operation. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 263 7.5 channel input (ti0n pin) control 7.5.1 ti0n edge detector (1) edge detection basic operation timing edge detector sampling is done in acco rdance with the operation clock (mck). figure 7-34. edge detect ion basic operation timing synchronized (noise filter) internal ti0n signal f clk rising edge detection internal trigger falling edge detection internal trigger operation clock (mck) remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 264 7.6 basic function of timer array unit 7.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 that 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 combinin g a master channel (reference 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. 7.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 is set as a master channel, channel 3 or those that follow (ch annels 3, 4, 5, etc.) 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, slave channels with a master channel between them may not be set. example: if channels 0 and 4 are set as master channel s, channels 1 to 3 can be set as the slave channels of master channel 0. channels 5 to 7 cannot be set as the slave channels of master channel 0. (6) the operating clock for a slave channel in combination with a master channel must be the same as that of the master channel. the cks bit (bit 15 of the tmr0n register) of the slave c hannel that operates in combination with the master channel must be the same value as that of the master channel. (7) a master channel can transmit inttm0n (interrupt), start software trigger, and count clock to the lower channels. (8) a slave channel can use the inttm0n (interrupt), star t software trigger, and count clock of the master channel, but it cannot transmit its own inttm0n (i nterrupt), start software trigger, and count clock to the lower channel. (9) a master channel cannot use the inttm0n (interrupt ), start software trigger, and count clock from the other master channel. (10) to simultaneously start channels that operate in combination, the ts0n bit of the channels in combination must be set at the same time. (11) during a counting operation, the ts0n bit of all channels that operate in combination or only the master channel can be set. ts0n of only a slave channel cannot be set. (12) to stop the channels in combination simultaneously, the tt0n bit of the channels in combination must be set at the same time. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 265 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 tau * a channel that singly operates may be between channel group 1 and channel group 2. channel group 2 (combination operation function) 7.6.3 applicable range of basic ru les of combination operation function the rules of the combination operation function are app lied 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 comb ination are specified, the bas ic rules of the combination operation function in 7.6.2 basic rules of comb ination operation function do not apply to the channel groups. example chapter 7 timer array unit user?s manual u17894ej8v0ud 266 7.7 operation of timer array unit as independent channel 7.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 inttm0n (timer interrupt) at fixed intervals. the interrupt generation period can be calculated by the following expression. generation period of inttm0n (timer in terrupt) = period of count clock (set value of tdr0n + 1) a subsystem clock divided by four (f sub /4) can be selected as the count cloc k, in addition to ck00 and ck01. consequently, the interval timer can be operated with the count clock fixed to f sub /4, 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 clock control regi ster (ckc)), however, stop the timer array unit (tau) (tt0 = 00ffh) first. (2) operation as square wave output to0n performs a toggle operation as soon as inttm0n has been generated, and outputs a square wave with a duty factor of 50%. the period and frequency for outputting a square wave from to0n can be calculated by the following expressions. ? period of square wave output from to0n = period of count clock (set value of tdr0n + 1) 2 ? frequency of square wave output from to0n = fr equency of count clock/{(set value of tdr0n + 1) 2} tcr0n operates as a down counter in the interval timer mode. tcr0n loads the value of tdr0n at the fi rst count clock after the channel start trigger bit (ts0n) is set to 1. if md0n0 of tmr0n = 0 at this time, inttm0n is not out put and to0n is not toggled. if md0n0 of tmr0n = 1, inttm0n is output and to0n is toggled. after that, tcr0n count down in synchronization with the count clock. when tcr0n = 0000h, inttm0n is output and to0n is toggled at the next count clock. at the same time, tcr0n loads the value of tdr0n again. af ter that, the same operation is repeated. tdr0n can be rewritten at any time. the new val ue of tdr0n becomes valid from the next period. remarks 1. n = 0 to 7 2. f clk : cpu/peripheral hardware clock frequency f sub : subsystem clock oscillation frequency chapter 7 timer array unit user?s manual u17894ej8v0ud 267 figure 7-35. block diagram of operation as interval timer/square wave output ck00 f sub /4 ck01 ts0n timer counter (tcr0n) to0n pin interrupt signal (inttm0n) data register (tdr0n) interrupt controller output controller clock selection trigger selection operation clock edge detection figure 7-36. example of basic timing of operati on as interval timer/square wave output (md0n0 = 1) ts0n te0n tdr0n tcr0n to0n inttm0n a a + 1 b 0000h a + 1 a + 1 b + 1 b + 1 b + 1 remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 268 figure 7-37. example of set contents of registers during operation as interval timer/square wave output (1/3) (1) when ck00 or ck01 is selected as count clock (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 0 mas ter0n 0 sts0n2 0 sts0n1 0 sts0n0 0 cis0n1 0 cis0n0 0 0 0 md0n3 0 md0n2 0 md0n1 0 md0n0 1/0 operation mode of channel n 000b: interval timer setting of operation when counting is started 0: neither generates inttm0n nor inverts timer output when counting is started. 1: generates inttm0n and inverts timer output when counting is started. selection of ti0n pin input edge 00b: sets 00b because these are not used. start trigger selection 000b: selects only software start. slave/master selection 0: cleared to 0 when single-operation function is selected. count clock selection 0: selects operation clock. operation clock selection 0: selects ck00 as operation clock of channel n. 1: selects ck01 as operation clock of channel n. (b) timer output register 0 (to0) bit n to0 to0n 1/0 0: outputs 0 from to0n. 1: outputs 1 from to0n. (c) timer output enable register 0 (toe0) bit n toe0 toe0n 1/0 0: stops the to0n output operation by counting operation. 1: enables the to0n output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode) (e) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 269 figure 7-37. example of set contents of registers during operation as interval timer/square wave output (2/3) (2) when f sub /4 is selected as count clock (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 1 mas ter0n 0 sts0n2 0 sts0n1 0 sts0n0 0 cis0n1 1/0 cis0n0 1/0 0 0 md0n3 0 md0n2 0 md0n1 0 md0n0 1/0 operation mode of channel n 000b: interval timer setting of operation when counting is started 0: neither generates inttm0n nor inverts timer output when counting is started. 1: generates inttm0n and inverts timer output when counting is started. f sub /4 edge selection 00b: detects falling edge (counts on f sub /4 cycles). 01b: detects rising edge (counts on f sub /4 cycles). 10b: detects both edges (counts on f sub/ 2 cycles). 11b: setting prohibited start trigger selection 000b: selects only software start. slave/master selection 0: cleared to 0 when single-operation function is selected. count clock selection 1: selects subsystem clock divided by four (f sub /4). operation clock selection 0: selects ck00 as operation clock of channel n. 1: selects ck01 as operation clock of channel n. f clk (no division) is selected as selected operation clock by tps0 register. (b) timer clock select register 0 (tps0) bits 7 to 4, 3 to 0 tps0 prs0m3 to prs0m0 0000 0000b: selects f clk (no division) as operation clock se lected by cks0n of tmr0n register. m = 0 (bits 0 to 3) when ck00 is selected and m = 1 (bits 4 to 7) when ck01 is selected (c) timer input select register 0 (tis0) bit n tis0 tis0n 1 1: selects subsystem clock divided by four (f sub /4). (d) timer output register 0 (to0) bit n to0 to0n 1/0 0: outputs 0 from to0n. 1: outputs 1 from to0n. remarks 1. n = 0 to 7, m = 0, 1 2. f sub : subsystem clock oscillation frequency chapter 7 timer array unit user?s manual u17894ej8v0ud 270 figure 7-37. example of set contents of registers during operation as interval timer/square wave output (3/3) (2) when f sub /4 is selected as count clock (continued) (e) timer output enable register 0 (toe0) bit n toe0 toe0n 1/0 0: stops the to0n output operation by counting operation. 1: enables the to0n output operation by counting operation. (f) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode) (g) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0 to 7, m = 0, 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 271 figure 7-38. operation procedure of inte rval timer/square wave output function software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en bit 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 tps0 register. determines clock frequencies of ck00 and ck01. sets the tmr0n register (determines operation mode of channel). sets the tis0n bit to 1 (f sub /4) when f sub /4 is selected as the count clock. sets interval (period) value to the tdr0n register. channel stops operating. (clock is supplied and some power is consumed.) channel default setting to use the to0n output clears the tom0n bit of the tom0 register to 0 (toggle mode). clears the tol0n bit to 0. sets the to0n bit and determines default level of the to0n output. sets toe0n to 1 and enables operation of to0n. clears the port register and port mode register to 0. the to0n pin goes into hi-z output state. the to0n default setting level is output when the port mode register is in the output mode and the port register is 0. to0n does not change because channel stops operating. the to0n pin outputs the to0n set level. operation start sets toe0n to 1 (only when operation is resumed). sets the ts0n bit to 1. the ts0n bit automatically returns to 0 because it is a trigger bit. te0n = 1, and count operation starts. value of tdr0n is loaded to tcr0n at the count clock input. inttm0n is generated and to0n performs toggle operation if the md0n0 bit of the tmr0n register is 1. during operation set values of the tmr0n register, tom0n, and tol0n bits cannot be changed. set value of the tdr0n register can be changed. the tcr0n register can always be read. the tsr0n register is not used. set values of the to0 and toe0 registers can be changed. counter (tcr0n) counts down. when count value reaches 0000h, the value of tdr0n is loaded to tcr0n again and the count operation is continued. by detecting tcr0n = 0000h, inttm0n is generated and to0n performs toggle operation. after that, the above operation is repeated. the tt0n bit is set to 1. the tt0n bit automatically returns to 0 because it is a trigger bit. te0n = 0, and count operation stops. tcr0n holds count value and stops. the to0n output is not initialized but holds current status. operation stop toe0n is cleared to 0 and value is set to the to0n bit. the to0n pin outputs the to0n set level. tau stop to hold the to0n pin output level clears to0n bit to 0 after the value to be held is set to the port register. when holding the to0n pin output level is not necessary switches the port mode register to input mode. the to0n pin output level is held by port function. the to0n pin output level goes into hi-z output state. the tau0en bit of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the to0n bit is cleared to 0 and the to0n pin is set to port mode.) remark n = 0 to 7 operation is resumed. chapter 7 timer array unit user?s manual u17894ej8v0ud 272 7.7.2 operation as external event counter the timer array unit can be used as an external event counter that counts the number of times the valid input edge (external event) is detected in the ti0n pin. when a specified count valu e is reached, 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 tdr0n + 1 tcr0n operates as a down counter in the event counter mode. when the channel start trigger bit (ts0n) is set to 1, tcr0n loads the value of tdr0n. tcr0n counts down each time the valid input edge of the ti0n pin has been detected. when tcr0n = 0000h, tcr0n loads the value of tdr 0n again, and outputs inttm0n. after that, the above operation is repeated. to0n must not be used because its waveform depends on the external event and irregular. tdr0n can be rewritten at any time. the new value of tdr0n becomes valid during the next count period. figure 7-39. block diagram of oper ation as external event counter timer counter (tcr0n) edge detection interrupt signal (inttm0n) ti0n pin data register (tdr0n) interrupt controller clock selection trigger selection ts0n remark n = 0 to 7 figure 7-40. example of basic timing of operation as external event counter ts0n te0n ti0n tdr0n tcr0n 0003h 0002h 0 0000h 1 3 0 1 2 0 1 2 1 2 3 2 inttm0n 4 events 4 events 3 events remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 273 figure 7-41. example of set contents of registers in external event counter mode (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 1 mas ter0n 0 sts0n2 0 sts0n1 0 sts0n0 0 cis0n1 1/0 cis0n0 1/0 0 0 md0n3 0 md0n2 1 md0n1 1 md0n0 0 operation mode of channel n 011b: event count mode setting of operation when counting is started 0: neither generates inttm0n nor inverts timer output when counting is started. selection of ti0n 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 single-operation function is selected. count clock selection 1: selects the ti0n pin input valid edge. operation clock selection 0: selects ck00 as operation clock of channel n. 1: selects ck01 as operation clock of channel n. (b) timer output register 0 (to0) bit n to0 to0n 0 0: outputs 0 from to0n. (c) timer output enable register 0 (toe0) bit n toe0 toe0n 0 0: stops the to0n output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode). (e) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 274 figure 7-42. 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 bit 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 tps0 register. determines clock frequencies of ck00 and ck01. channel default setting sets the tmr0n register (determines operation mode of channel). sets number of counts to the tdr0n register. clears the toe0n bit of the toe0 register to 0. channel stops operating. (clock is supplied and some power is consumed.) operation start sets the ts0n bit to 1. the ts0n bit automatically returns to 0 because it is a trigger bit. te0n = 1, and count operation starts. value of tdr0n is loaded to tcr0n and detection of the ti0n pin input edge is awaited. during operation set value of the tdr0n register can be changed. the tcr0n register can always be read. the tsr0n register is not used. set values of the tmr0n register, tom0n, tol0n, to0n, and toe0n bits cannot be changed. counter (tcr0n) counts down each time input edge of the ti0n pin has been detected. when count value reaches 0000h, the value of tdr0n is loaded to tcr0n again, and the count operation is continued. by detecting tcr0n = 0000h, the inttm0n output is generated. after that, the above operation is repeated. operation stop the tt0n bit is set to 1. the tt0n bit automatically returns to 0 because it is a trigger bit. te0n = 0, and count operation stops. tcr0n holds count value and stops. tau stop the tau0en bit of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. remark n = 0 to 7 operation is resumed. chapter 7 timer array unit user?s manual u17894ej8v0ud 275 7.7.3 operation as frequency divider (channel 0 only) the timer array unit can be used as a frequency divider that divides a clock input to the ti00 pin and outputs the result from to00. the divided clock frequency output from to00 c an be calculated by the following expression. ? when rising edge/falling edge is selected: divided clock frequency = input clock frequency/{(set value of tdr00 + 1) 2} ? when both edges are selected: divided clock frequency ? input clock frequency/(set value of tdr00 + 1) tcr00 operates as a down counter in the interval timer mode. after the channel start trigger bit (ts00) is set to 1, tcr00 loads the value of tdr 00 when the ti00 valid edge is detected. if md000 of tmr00 = 0 at this time, inttm00 is not output and to00 is not toggled. if md000 of tmr00 = 1, inttm00 is output an d to00 is toggled. after that, tcr00 counts down at the valid edge of ti00. when tcr00 = 0000h, it toggl es to00. at the same time, tcr00 loads the value of t dr00 again, and continues counting. if detection of both the edges of ti00 is selected, the duty factor error of the input clock affects the divided clock period of the to00 output. the period of the to00 output clock includes a samp ling error of one period of the operation clock. clock period of to00 output = ideal to00 output clock period operation clock period (error) tdr00 can be rewritten at any time. the new value of tdr00 becomes valid during the next count period. figure 7-43. block diagram of operation as frequency divider timer counter (tcr00) edge detection ti00 pin data register (tdr00) clock selection trigger selection ts00 to00 pin output controller chapter 7 timer array unit user?s manual u17894ej8v0ud 276 figure 7-44. example of basic timing of operation as frequency divider (md000 = 1) ts00 te00 ti00 tdr00 tcr00 to00 inttm00 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 chapter 7 timer array unit user?s manual u17894ej8v0ud 277 figure 7-45. example of set contents of registers when frequency divider is used (a) timer mode register 00 (tmr00) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr00 cks00 1/0 0 0 ccs00 1 mas ter00 0 sts002 0 sts001 0 sts000 0 cis001 1/0 cis000 1/0 0 0 md003 0 md002 0 md001 0 md000 1/0 operation mode of channel 0 000b: interval timer setting of operation when counting is started 0: neither generates inttm00 nor inverts timer output when counting is started. 1: generates inttm00 and inverts timer output when counting is started. selection of ti00 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 single-operation function is selected. count clock selection 1: selects the ti00 pin input valid edge. operation clock selection 0: selects ck00 as operation clock of channel 0. 1: selects ck01 as operation clock of channel 0. (b) timer output register 0 (to0) bit n to0 to00 1/0 0: outputs 0 from to00. 1: outputs 1 from to00. (c) timer output enable register 0 (toe0) bit n toe0 toe00 1/0 0: stops the to00 output operation by counting operation. 1: enables the to00 output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol00 0 0: cleared to 0 when tom00 = 0 (toggle mode) (e) timer output mode register 0 (tom0) bit n tom0 tom00 0 0: sets toggle mode. chapter 7 timer array unit user?s manual u17894ej8v0ud 278 figure 7-46. operation procedure when frequency divider function is used software operation hardware status power-off status (clock supply is stopped and writing to each register is disabled.) sets the tau0en bit 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 tps0 register. determines clock frequencies of ck00 and ck01. sets the tmr00 register (determines operation mode of channel). sets interval (period) value to the tdr00 register. channel stops operating. (clock is supplied and some power is consumed.) channel default setting clears the tom00 bit of the tom0 register to 0 (toggle mode). clears the tol00 bit to 0. sets the to00 bit and determines default level of the to00 output. sets toe00 to 1 and enables operation of to00. clears the port register and port mode register to 0. the to00 pin goes into hi-z output state. the to00 default setting level is output when the port mode register is in output mode and the port register is 0. to00 does not change because channel stops operating. the to00 pin outputs the to00 set level. operation start sets toe00 to 1 (only when operation is resumed). sets the ts00 bit to 1. the ts00 bit automatically returns to 0 because it is a trigger bit. te00 = 1, and count operation starts. value of tdr00 is loaded to tcr00 at the count clock input. inttm00 is generated and to00 performs toggle operation if the md000 bit of the tmr00 register is 1. during operation set value of the tdr00 register can be changed. the tcr00 register can always be read. the tsr00 register is not used. set values of the to0 and toe0 registers can be changed. set values of the tmr00 register, tom00, and tol00 bits cannot be changed. counter (tcr00) counts down. when count value reaches 0000h, the value of tdr00 is loaded to tcr00 again, and the count operation is continued. by detecting tcr00 = 0000h, inttm00 is generated and to00 performs toggle operation. after that, the above operation is repeated. the tt00 bit is set to 1. the tt00 bit automatically returns to 0 because it is a trigger bit. te00 = 0, and count operation stops. tcr00 holds count value and stops. the to00 output is not initialized but holds current status. operation stop toe00 is cleared to 0 and value is set to the to00 bit. the to00 pin outputs the to00 set level. to hold the to00 pin output level clears the to00 bit to 0 after the value to be held is set to the port register. when holding the to00 pin output level is not necessary switches the port mode register to input mode. the to00 pin output level is held by port function. the to00 pin output level goes into hi-z output state. tau stop the tau0en bit of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the to00 bit is cleared to 0 and the to00 pin is set to port mode). operation is resumed. chapter 7 timer array unit user?s manual u17894ej8v0ud 279 7.7.4 operation as input pu lse interval measurement the count value can be captured at the ti0n valid edge and t he interval of the pulse input to ti0n can be measured. the pulse interval can be calculated by the following expression. ti0n input pulse interval = period of count clock ((10000h tsr0n: ovf) + (capture value of tdr0n + 1)) caution the ti0n pin input is sampled using the operating clock selected with the cks0n bit of the tmr0n register, so an error equal to the number of operating clocks occurs. tcr0n operates as an up counter in the capture mode. when the channel start trigger (ts0n) is set to 1, tcr 0n counts up from 0000h in synchronization with the count clock. when the ti0n pin input valid edge is det ected, the count value is transferr ed (captured) to tdr0n and, at the same time, the counter (tcr0n) is cleared to 0000h, and the in ttm0n is output. if the counter overflows at this time, the ovf bit of the tsr0n register is set to 1. if the count er does not overflow, the ovf bit is cleared. after that, the above operation is repeated. as soon as the count value has been capt ured to the tdr0n register, the ovf bit of the tsr0n register is updated depending on whether the counter overflow s during the measurement pe riod. therefore, the ov erflow 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 ovf bit of the tsr0n register is set to 1. however, the ovf bit is configured as a cumulative flag, the correct interval value cannot be measured if an overflow occurs more than once. set sts0n2 to sts0n0 of the tmr0n register to 001b to use the valid edges of ti0n as a start trigger and a capture trigger. when te0n = 1, instead of the ti0n pin input, a software operation (ts0n = 1) can be used as a capture trigger. figure 7-47. block diagram of operatio n as input pulse interval measurement timer counter (tcr0n) interrupt signal (inttm0n) data register (tdr0n) interrupt controller clock selection trigger selection operation clock ck00 ck01 edge detection ti0n pin ts0n remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 280 figure 7-48. example of basic timing of operati on as input pulse interval measurement (md0n0 = 0) ts0n te0n ti0n tdr0n tcr0n 0000h c b 0000h a c d inttm0n ffffh b a d ovf0n remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 281 figure 7-49. example of set contents of registers to measure input pulse interval (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 0 mas ter0n 0 sts0n2 0 sts0n1 0 sts0n0 1 cis0n1 1/0 cis0n0 1/0 0 0 md0n3 0 md0n2 1 md0n1 0 md0n0 1/0 operation mode of channel n 010b: ca p ture mode setting of operation when counting is started 0: does not generate inttm0n when counting is started. 1: generates inttm0n when counting is started. selection of ti0n pin input edge 00b: detects falling edge. 01b: detects rising edge. 10b: detects both edges. 11b: setting prohibited capture trigger selection 001b: selects the ti0n pin input valid edge. slave/master selection 0: cleared to 0 when single-operation function is selected. count clock selection 0: selects operation clock. operation clock selection 0: selects ck00 as operation clock of channel n. 1: selects ck01 as operation clock of channel n. (b) timer output register 0 (to0) bit n to0 to0n 0 0: outputs 0 from to0n. (c) timer output enable register 0 (toe0) bit n toe0 toe0n 0 0: stops to0n output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode). (e) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 282 figure 7-50. 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 bit 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 tps0 register. determines clock frequencies of ck00 and ck01. channel default setting sets the tmr0n register (determines operation mode of channel). channel stops operating. (clock is supplied and some power is consumed.) operation start sets ts0n bit to 1. the ts0n bit automatically returns to 0 because it is a trigger bit. te0n = 1, and count operation starts. tcr0n is cleared to 0000h at the count clock input. when the md0n0 bit of the tmr0n register is 1, inttm0n is generated. during operation set values of only the cis0n1 and cis0n0 bits of the tmr0n register can be changed. the tdr0n register can always be read. the tcr0n register can always be read. the tsr0n register can always be read. set values of the tom0n, tol0n, to0n, and toe0n bits cannot be changed. counter (tcrn) counts up from 0000h. when the ti0n pin input valid edge is detected, the count value is transferred (captured) to tdr0n. at the same time, tcr0n is cleared to 0000h, and the inttm0n signal is generated. if an overflow occurs at this time, the ovf bit of the tsr0n register is set; if an overflow does not occur, the ovf bit is cleared. after that, the above operation is repeated. operation stop the tt0n bit is set to 1. the tt0n bit automatically returns to 0 because it is a trigger bit. te0n = 0, and count operation stops. tcr0n holds count value and stops. the ovf bit of the tsr0n register is also held. tau stop the tau0en bit of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. remark n = 0 to 7 operation is resumed. chapter 7 timer array unit user?s manual u17894ej8v0ud 283 7.7.5 operation as input signal hi gh-/low-level width measurement by starting counting at one edge of ti0n and capturing the number of counts at another edge, the signal width (high-level width/low-level width) of ti0n can be measured. the signal width of ti0n can be calculated by the following expression. signal width of ti0n input = period of count clock ((10000h tsrn: ovf) + (capture value of tdr0n + 1)) caution the ti0n pin input is sampled using the operating clock selected with the cks0n bit of the tmr0n register, so an error equal to the number of operating clocks occurs. tcr0n operates as an up counter in the capture & one-count mode. when the channel start trigger (ts0n) is set to 1, te0n is set to 1 and the ti 0n pin start edge detection wait status is set. when the ti0n start valid edge (rising edge of ti0n when the high-level width is to be measured) is detected, the counter counts up in synchronization with the count clock. when the valid capture edge (falling edge of ti0n when the high-level width is to be measured) is det ected later, the count value is transfe rred to tdr0n and, at the same time, inttm0n is output. if the counter overflows at this time, the ovf bit of the tsr0n register is set to 1. if the counter does not overflow, the ovf bit is clear ed. tcr0n stops at the value ?value transferred to tdr0n + 1?, and the ti0n pin start edge detection wait status is set. after that, the above operation is repeated. as soon as the count value has been capt ured to the tdr0n register, the ovf bit of the tsr0n register is updated depending on whether the counter overflow s during the measurement pe riod. therefore, the ov erflow 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 ovf bit of the tsr0n register is set to 1. however, the ovf bi t is configured as an integral flag, and the correct interval value cannot be measured if an overflow occurs more than once. whether the high-level width or low-le vel width of the ti0n pin is to be measured can be selected by using the cis0n1 and cis0n0 bits of the tmr0n register. because this function is used to measure the signal wi dth of the ti0n pin input, ts0n cannot be set to 1 while te0n is 1. cis0n1, cis0n0 of tmr0n = 10b: low-level width is measured. cis0n1, cis0n0 of tmr0n = 11b: high-level width is measured. figure 7-51. block diagram of operation as in put signal high-/low-le vel width measurement timer counter (tcr0n) interrupt signal (inttm0n) data register (tdr0n) interrupt controller clock selection trigger selection operation clock ck00 ck01 edge detection ti0n pin remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 284 figure 7-52. example of basic timing of operati on as input signal high-/low-level width measurement ts0n te0n ti0n tdr0n tcr0n b 0000h a c inttm0n ffffh b a c ovf0n 0000h remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 285 figure 7-53. example of set contents of regist ers to measure input signa l high-/low-level width (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 0 mas ter0n 0 sts0n2 0 sts0n1 1 sts0n0 0 cis0n1 1 cis0n0 1/0 0 0 md0n3 1 md0n2 1 md0n1 0 md0n0 0 operation mode of channel n 110b: capture & one-count setting of operation when counting is started 0: does not generate inttm0n when counting is started. selection of ti0n 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 ti0n pin input valid edge. slave/master selection 0: cleared to 0 when single-operation function is selected. count clock selection 0: selects operation clock. operation clock selection 0: selects ck00 as operation clock of channel n. 1: selects ck01 as operation clock of channel n. (b) timer output register 0 (to0) bit n to0 to0n 0 0: outputs 0 from to0n. (c) timer output enable register 0 (toe0) bit n toe0 toe0n 0 0: stops the to0n output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode). (e) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0 to 7 chapter 7 timer array unit user?s manual u17894ej8v0ud 286 figure 7-54. 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 bit 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 tps0 register. determines clock frequencies of ck00 and ck01. channel default setting sets the tmr0n register (determines operation mode of channel). clears toe0n to 0 and stops operation of to0n. channel stops operating. (clock is supplied and some power is consumed.) sets the ts0n bit to 1. the ts0n bit automatically returns to 0 because it is a trigger bit. te0n = 1, and the ti0n pin start edge detection wait status is set. operation start detects ti0n pin input count start valid edge. clears tcr0n to 0000h and starts counting up. during operation set value of the tdr0n register can be changed. the tcr0n register can always be read. the tsr0n register is not used. set values of the tmr0n register, tom0n, tol0n, to0n, and toe0n bits cannot be changed. when the ti0n pin start edge is detected, the counter (tcrn) counts up from 0000h. if a capture edge of the ti0n pin is detected, the count value is transferred to tdr0n and inttm0n is generated. if an overflow occurs at this time, the ovf bit of the tsr0n register is set; if an overflow does not occur, the ovf bit is cleared. tcr0n stops the count operation until the next ti0n pin start edge is detected. operation stop the tt0n bit is set to 1. tt0n bit automatically returns to 0 because it is a trigger bit. te0n = 0, and count operation stops. tcr0n holds count value and stops. the ovf bit of the tsr0n register is also held. tau stop the tau0en bit of per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. remark n = 0 to 7 operation is resumed. chapter 7 timer array unit user?s manual u17894ej8v0ud 287 7.8 operation of plural channels of timer array unit 7.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 tdr0n (master) + 1} count clock period duty factor [%] = {set value of tdr0m (s lave)}/{set value of tdr0n (master) + 1} 100 0% output: set value of tdr0m (slave) = 0000h 100% output: set value of tdr0m (slave) {set value of tdr0n (master) + 1} remark the duty factor exceeds 100% if the set value of tdr0m (slave) > (set value of tdr0n (master) + 1), it summarizes to 100% output. the master channel operates in the interval timer m ode and counts the periods. when the channel start trigger (ts0m) is set to 1, inttm0n is output. tcr0n counts down starting from the load ed value of tdr0n, in synchronization with the count clock. when tcr0n = 0000h , inttm0n is output. tcr0n loads the value of tdr0n again. after that, it conti nues the similar operation. tcr0m of a slave channel operates in one-count mode, counts the duty fact or, and outputs a pwm waveform from the to0m pin. tcr0m of the slave c hannel loads the value of tdr0m, usi ng inttm0n of the master channel as a start trigger, and stops counting until the next start trigger (inttm0n of the master channel) is input. the output level of to0m bec omes active one count clock after generat ion of inttm0n from the master channel, and inactive when tcr0m = 0000h. caution to rewrite both tdr0n of the master channe l and tdr0m of the slave channel, a write access is necessary two times. the timing at which the values of t dr0n and tdr0m are loaded to tcr0n and trc0m is upon occurrence of inttm0n of the master channel. thus, when rewriting is performed split before and after occurrence of inttm0n of the master channel, the to0m pin cannot output the expected waveform. to rewrit e both tdr0n of the master and tdr0m of the slave, therefore, be sure to rewrite both the registers immediately after inttm0n is generated from the master channel. remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 288 figure 7-55. block diagram of operation as pwm function timer counter (tcr0n) interrupt signal (inttm0n) data register (tdr0n) interrupt controller clock selection trigger selection operation clock ck00 ck01 ts0n timer counter (tcr0m) interrupt signal (inttm0m) data register (tdr0m) interrupt controller clock selection trigger selection operation clock ck00 ck01 to0m pin output controller master channel (interval timer mode) slave channel (one-count mode) remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 289 figure 7-56. example of basic ti ming of operation as pwm function ts0n te0n tdr0n tcr0n to0n inttm0n a b 0000h ts0m te0m tdr0m tcr0m to0m inttm0m c c d 0000h c d master channel slave channel a+1 a+1 b+1 ffffh ffffh remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 290 figure 7-57. example of set contents of register s when pwm function (master channel) is used (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 0 mas ter0n 1 sts0n2 0 sts0n1 0 sts0n0 0 cis0n1 0 cis0n0 0 0 0 md0n3 0 md0n2 0 md0n1 0 md0n0 1 operation mode of channel n 000b: interval timer setting of operation when counting is started 1: generates inttm0n when counting is started. selection of ti0n 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 ck00 as operation clock of channel n. 1: selects ck01 as operation clock of channel n. (b) timer output register 0 (to0) bit n to0 to0n 0 0: outputs 0 from to0n. (c) timer output enable register 0 (toe0) bit n toe0 toe0n 0 0: stops the to0n output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode). (e) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0, 2, 4, 6 chapter 7 timer array unit user?s manual u17894ej8v0ud 291 figure 7-58. example of set contents of regist ers when pwm function (slave channel) is used (a) timer mode register 0m (tmr0m) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0m cks0m 1/0 0 0 ccs0m 0 mas ter0 m 0 sts0m2 1 sts0m1 0 sts0m0 0 cis0m1 0 cis0m0 0 0 0 md0m3 1 md0m2 0 md0m1 0 md0m0 1 operation mode of channel m 100b: one-count mode start trigger during operation 1: trigger input is valid. selection of ti0m pin input edge 00b: sets 00b because these are not used. start trigger selection 100b: selects inttm0n 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 ck00 as operation clock of channel m. 1: selects ck01 as operation clock of channel m. * make the same setting as master channel. (b) timer output register 0 (to0) bit m to0 to0m 1/0 0: outputs 0 from to0m. 1: outputs 1 from to0m. (c) timer output enable register 0 (toe0) bit m toe0 toe0m 1/0 0: stops the to0m output operation by counting operation. 1: enables the to0m output operation by counting operation. (d) timer output level register 0 (tol0) bit m tol0 tol0m 1/0 0: positive logic output (active-high) 1: inverted output (active-low) (e) timer output mode register 0 (tom0) bit m tom0 tom0m 1 1: sets the combination operation mode. remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 292 figure 7-59. 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 bit 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 tps0 register. determines clock frequencies of ck00 and ck01. sets the tmr0n and tmr0m registers of two channels to be used (determines oper ation mode of channels). an interval (period) value is set to the tdr0n register of the master channel, and a duty factor is set to the tdr0m register of the slave channel. channel stops operating. (clock is supplied and some power is consumed.) channel default setting sets slave channel. the tom0m bit of the tom0 register is set to 1 (combination operation mode). sets the tol0mbit. sets the to0m bit and determines default level of the to0m output. sets toe0m to 1 and enables operation of to0m. clears the port register and port mode register to 0. the to0m pin goes into hi-z output state. the to0m default setting level is output when the port mode register is in output mode and the port register is 0. to0m does not change because channel stops operating. the to0m pin outputs the to0m set level. remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 293 figure 7-59. operation procedure wh en pwm function is used (2/2) software operation hardware status operation start sets toe0m (slave) to 1 (only when operation is resumed). the ts0n (master) and ts0m (slave) bits of the ts0 register are set to 1 at the same time. the ts0n and ts0m bits automatically return to 0 because they are trigger bits. te0n = 1, te0m = 1 when the master channel starts counting, inttm0n is generated. triggered by this interrupt, the slave channel also starts counting. during operation set values of the tmr0n and tmr0m registers, tom0n, tom0m, tol0n, and tol0m bits cannot be changed. set values of the tdr0n and tdr0m registers can be changed after inttm0n of the master channel is generated. the tcr0n and tcr0m registers can always be read. the tsr0n and tsr0m registers are not used. set values of the to0 and toe0 registers can be changed. the counter of the master channel loads the tdr0n value to tcr0n, and counts down. when the count value reaches tcr0n = 0000h, inttm0n output is generated. at the same time, the value of the tdr0n register is loaded to tcr0n, and the counter starts counting down again. at the slave channel, the value of tdr0m is loaded to tcr0m, triggered by inttm0n of the master channel, and the counter starts counting down. the output level of to0m becomes active one c ount clock after generation of the inttm0n output from the master channel. it becomes inactive when tcr0m = 0000h, and the counting operation is stopped. after that, the above operation is repeated. the tt0n (master) and tt0m (slave) bits are set to 1 at the same time. the tt0n and tt0m bits automatically return to 0 because they are trigger bits. te0n, te0m = 0, and count operation stops. tcr0n and tcr0m hold count value and stops. the to0m output is not initialized but holds current status. operation stop toe0m of slave channel is cleared to 0 and value is set to the to0m bit. the to0m pin outputs the to0m set level. to hold the to0m pin output levels clears the to0m bit to 0 after the value to be held is set to the port register. when holding the to0m pin output level is not necessary switches the port mode register to input mode. the to0m pin output level is held by port function. the to0m pin output level goes into hi-z output state. tau stop the tau0en bit of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the to0m bit is cleared to 0 and the to0m pin is set to port mode.) remark n = 0, 2, 4, 6 m = n + 1 operation is resumed. chapter 7 timer array unit user?s manual u17894ej8v0ud 294 7.8.2 operation as one-shot pulse output function by using two channels as a set, a one-shot pulse having any delay pulse width can be generated from the signal input to the ti0n pin. the delay time and pulse width can be ca lculated by the following expressions. delay time = {set value of tdr0n (master) + 2} count clock period pulse width = {set value of tdr0m (slave)} count clock period the master channel operates in the one-count mode and counts the delays. tcr0n of the master channel starts operating upon start trigger detection and tcr0n loads the value of tdr0n. tcr0n counts down from the value of tdr0n it has loaded, in synchronization with the count clock. when tcr0n = 0000h, it outputs inttm0n and stops counting until the next start trigger is detected. the slave channel operates in the one-co unt mode and counts the pulse width. tcr0m of the slave channel starts operation using inttm0n of the master channel as a start trigger, and loads t he tdr0m value. tcr0m counts down from the value of tdr0m it has load ed, in synchronization with the count value. when tcr0m = 0000h, it outputs inttm0m and stops counting until the next start trigger (inttm0n of the master channel) is detected. the output level of to0m becomes active one count clock after genera tion of inttm0n from the master channel, and inactive when tcr0m = 0000h. instead of using the ti0n pin input, a one- shot pulse can also be output using the software operation (ts0n = 1) as a start trigger. caution the timing of loading of tdr0n of the master channel is different from th at of tdr0m of the slave channel. if tdr0n and tdr0m are rewritten during operation, ther efore, an illegal waveform is output. be sure to rewrite tdr0n and tdr0m af ter inttm0n of the channel to be rewritten is generated. remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 295 figure 7-60. block diagram of operat ion as one-shot pulse output function timer counter (tcr0n) interrupt signal (inttm0n) data register (tdr0n) interrupt controller clock selection trigger selection operation clock ck00 ck01 ts0n timer counter (tcr0m) interrupt signal (inttm0m) data register (tdr0m) interrupt controller clock selection trigger selection operation clock ck00 ck01 to0m pin output controller master channel (one-count mode) slave channel (one-count mode) edge detection ti0n pin remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 296 figure 7-61. example of basic timing of operation as one-shot pulse output function te0n tdr0n tcr0n to0n inttm0n a b 0000h ts0m te0m tdr0m tcr0m to0m inttm0m 0000h b master channel slave channel a + 2 b a + 2 ffffh ffffh ti0n ts0n remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 297 figure 7-62. example of set contents of registers when one-shot pulse output func tion is used (master channel) (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 0 mas ter0n 1 sts0n2 0 sts0n1 0 sts0n0 1 cis0n1 1/0 cis0n0 1/0 0 0 md0n3 1 md0n2 0 md0n1 0 md0n0 0 operation mode of channel n 100b: one-count mode start trigger during operation 0: trigger input is invalid. selection of ti0n pin input edge 00b: detects falling edge. 01b: detects rising edge. 10b: detects both edges. 11b: setting prohibited start trigger selection 001b: selects the ti0n 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 ck00 as operation clock of channels n. 1: selects ck01 as operation clock of channels n. (b) timer output register 0 (to0) bit n to0 to0n 0 0: outputs 0 from to0n. (c) timer output enable register 0 (toe0) bit n toe0 toe0n 0 0: stops the to0n output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode). (e) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0, 2, 4, 6 chapter 7 timer array unit user?s manual u17894ej8v0ud 298 figure 7-63. example of set contents of registers when one-shot pulse output func tion is used (slave channel) (a) timer mode register 0m (tmr0m) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0m cks0m 1/0 0 0 ccs0m 0 mas ter0 m 0 sts0m2 1 sts0m1 0 sts0m0 0 cis0m1 0 cis0m0 0 0 0 md0m3 1 md0m2 0 md0m1 0 md0m0 0 operation mode of channel m 100b: one-count mode start trigger during operation 0: trigger input is invalid. selection of ti0m pin input edge 00b: sets 00b because these are not used. start trigger selection 100b: selects inttm0n 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 ck00 as operation clock of channel m. 1: selects ck01 as operation clock of channel m. * make the same setting as master channel. (b) timer output register 0 (to0) bit m to0 to0m 1/0 0: outputs 0 from to0m. 1: outputs 1 from to0m. (c) timer output enable register 0 (toe0) bit m toe0 toe0m 1/0 0: stops the to0m output operation by counting operation. 1: enables the to0m output operation by counting operation. (d) timer output level register 0 (tol0) bit m tol0 tol0m 1/0 0: positive logic output (active-high) 1: inverted output (active-low) (e) timer output mode register 0 (tom0) bit m tom0 tom0m 1 1: sets the combination operation mode. remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 299 figure 7-64. 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 bit 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 tps0 register. determines clock frequencies of ck00 and ck01. sets the tmr0n and tmr0m registers of two channels to be used (determines oper ation mode of channels). an output delay is set to the tdr0n register of the master channel, and a pulse width is set to the tdr0m register of the slave channel. channel stops operating. (clock is supplied and some power is consumed.) channel default setting sets slave channel. the tom0m bit of the tom0 register is set to 1 (combination operation mode). sets the tol0m bit. sets the to0m bit and determines default level of the to0m output. sets toe0m to 1 and enables operation of to0m. clears the port register and port mode register to 0. the to0m pin goes into hi-z output state. the to0m default setting level is output when the port mode register is in output mode and the port register is 0. to0m does not change because channel stops operating. the to0m pin outputs the to0m set level. remark n = 0, 2, 4, 6 m = n + 1 chapter 7 timer array unit user?s manual u17894ej8v0ud 300 figure 7-64. operation procedure of one-shot pulse output function (2/2) software operation hardware status sets toe0m (slave) to 1 (only when operation is resumed). the ts0n (master) and ts0m (slave) bits of the ts0 register are set to 1 at the same time. the ts0n and ts0m bits automatically return to 0 because they are trigger bits. te0n and te0m are set to 1 and the master channel enters the ti0n input edge detection wait status. counter stops operating. operation start detects the ti0n pin input valid edge of master channel. master channel starts counting. during operation set values of only the cis0n1 and cis0n0 bits of the tmr0n register can be changed. set values of the tmr0m, tdr0n, tdr0m registers, tom0n, tom0m, tol0n, and tol0m bits cannot be changed. the tcr0n and tcr0m registers can always be read. the tsr0n and tsr0m registers are not used. set values of the to0 and toe0 registers can be changed. master channel loads the value of tdr0n to tcr0n when the ti0n pin valid input edge is detected, and the counter starts counting down. when the count value reaches tcr0n = 0000h, the inttm0n output is generated, and the counter stops until the next valid edge is input to the ti0n pin. the slave channel, triggered by inttm0n of the master channel, loads the value of tdr0m to tcr0m, and the counter starts counting down. the output level of to0m becomes active one count clock after generation of inttm0n from the master channel. it becomes inactive when tcr0m = 0000h, and the counting operation is stopped. after that, the above operation is repeated. the tt0n (master) and tt0m (slave) bits are set to 1 at the same time. the tt0n and tt0m bits automatically return to 0 because they are trigger bits. te0n, te0m = 0, and count operation stops. tcr0n and tcr0m hold count value and stops. the to0m output is not initialized but holds current status. operation stop toe0m of slave channel is cleared to 0 and value is set to the to0m bit. the to0m pin outputs the to0m set level. to hold the to0m pin output levels clears the to0m bit to 0 after the value to be held is set to the port register. when holding the to0m pin output level is not necessary switches the port mode register to input mode. the to0m pin output level is held by port function. the to0m pin output level goes into hi-z output state. tau stop the tau0en bit of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the to0m bit is cleared to 0 and the to0m pin is set to port mode.) remark n = 0, 2, 4, 6 m = n + 1 operation is resumed. chapter 7 timer array unit user?s manual u17894ej8v0ud 301 7.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 duty factor of an output pu lse can be calculated by the following expressions. pulse period = {set value of tdr0n (master) + 1} count clock period duty factor 1 [%] = {set value of tdr0m (s lave 1)}/{set value of tdr0n (master) + 1} 100 duty factor 2 [%] = {set value of tdr0m (s lave 2)}/{set value of tdr0n (master) + 1} 100 remark although the duty factor exceeds 100% if the set value of tdr0p (slave 1) > {set value of tdr0n (master) + 1} or if the {set value of tdr0q (slave 2)} > {set value of tdr0n (master) + 1}, it is summarized into 100% output. tcr0n of the master channel operates in the interval timer mode and counts the periods. tcr0p of the slave channel 1 operates in one-count mode, counts the du ty factor, and outputs a pwm waveform from the to0p pin. tcr0p l oads the value of tdr0p to tcr0p, using inttm0n of the master channel as a start trigger, and start counting down. when tcr0p = 0000h, tcr0p outputs inttm0p and st ops counting until the next start trigger (inttm0n of the master channel) has been i nput. the output level of to0p becomes active one count clock after generation of inttm0n from the ma ster channel, and inactive when tcr0p = 0000h. in the same way as tcr0p of the slave channel 1, t cr0q of the slave channel 2 operates in one-count mode, counts the duty factor, and outputs a pwm waveform from the to0q pin. tcr0q loads the value of tdr0q to tcr0q, using inttm0n of the master channel as a start tri gger, and starts counting down. when tcr0q = 0000h, tcr0q outputs inttm0q and stops counting until th e next start trigger (inttm0n of the master channel) has been input. the output level of to0q becomes active one count clock after generation of in ttm0n from the master channel, and inactive when tcr0q = 0000h. when channel 0 is used as the master channel as above, up to seven types of pwm signals can be output at the same time. caution to rewrite both tdr0n of the master channe l and tdr0p of the slave channel 1, write access is necessary at least twice. sin ce the values of tdr0n and tdr0p are loaded to tcr0n and tcr0p after inttm0n is generated from th e master channel, if rewriting is performed separately before and after generation of inttm0n from the mast er channel, the to0p pin cannot output the expected waveform. to rewrite both tdr0n of th e master and tdr0p of the slave, be sure to rewrite both the registers immediately after inttm0n is generated from th e master channel (this applies also to tdr0q of the slave channel 2) . remarks 1. n = 0, 2, 4 n < p < q 7 where p and q are consecutive integers following n (p = n + 1, q = n + 2) chapter 7 timer array unit user?s manual u17894ej8v0ud 302 figure 7-65. block diagram of operation as multiple pwm output function (output two types of pwms) timer counter (tcr0n) interrupt signal (inttm0n) data register (tdr0n) interrupt controller clock selection trigger selection operation clock ck00 ck01 ts0n timer counter (tcr0p) interrupt signal (inttm0p) data register (tdr0p) interrupt controller clock selection trigger selection operation clock ck00 ck01 to0p pin output controller master channel (interval timer mode) slave channel 1 (one-count mode) timer counter (tcr0q) interrupt signal (inttm0q) data register (tdr0q) interrupt controller clock selection trigger selection operation clock ck00 ck01 to0q pin output controller slave channel 2 (one-count mode) remarks 1. n = 0, 2, 4 2. p = n + 1 q = n + 2 chapter 7 timer array unit user?s manual u17894ej8v0ud 303 figure 7-66. example of basic timing of operation as multiple pwm output function (output two types of pwms) ts0n te0n tdr0n tcr0n to0n inttm0n a b 0000h ts0p te0p tdr0p tcr0p to0p inttm0p c c d 0000h c d master channel slave channel 1 a + 1 a + 1 b + 1 ffffh ffffh ts0q te0q tdr0q tcr0q to0q inttm0q e f 0000h e f slave channel 2 a + 1 a + 1 b + 1 ffffh e f d remarks 1. n = 0, 2, 4 2. p = n + 1 q = n + 2 chapter 7 timer array unit user?s manual u17894ej8v0ud 304 figure 7-67. example of set contents of registers when multiple pwm output function (master channel) is used (a) timer mode register 0n (tmr0n) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0n cks0n 1/0 0 0 ccs0n 0 mas ter0n 1 sts0n2 0 sts0n1 0 sts0n0 0 cis0n1 0 cis0n0 0 0 0 md0n3 0 md0n2 0 md0n1 0 md0n0 1 operation mode of channel n 000b: interval timer setting of operation when counting is started 1: generates inttm0n when counting is started. selection of ti0n 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 ck00 as operation clock of channel n. 1: selects ck01 as operation clock of channel n. (b) timer output register 0 (to0) bit n to0 to0n 0 0: outputs 0 from to0n. (c) timer output enable register 0 (toe0) bit n toe0 toe0n 0 0: stops the to0n output operation by counting operation. (d) timer output level register 0 (tol0) bit n tol0 tol0n 0 0: cleared to 0 when tom0n = 0 (toggle mode). (e) timer output mode register 0 (tom0) bit n tom0 tom0n 0 0: sets toggle mode. remark n = 0, 2, 4 chapter 7 timer array unit user?s manual u17894ej8v0ud 305 figure 7-68. example of set contents of registers when multiple pwm output function (slave channel) is used (output two types of pwms) (a) timer mode registers 0p, 0q (tmr0p, tmr0q) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0p cks0p 1/0 0 0 ccs0p 0 mas ter0p 0 sts0p2 1 sts0p1 0 sts0p0 0 cis0p1 0 cis0p0 0 0 0 md0p3 1 md0p2 0 md0p1 0 md0p0 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tmr0q cks0q 1/0 0 0 ccs0q 0 mas ter0q 0 sts0q2 1 sts0q1 0 sts0q0 0 cis0q1 0 cis0q0 0 0 0 md0q3 1 md0q2 0 md0q1 0 md0q0 1 operation mode of channel p, q 100b: one-count mode start trigger during operation 1: trigger input is valid. selection of ti0p and ti0q pin input edge 00b: sets 00b because these are not used. start trigger selection 100b: selects inttm0n 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 ck00 as operation clock of channel p, q. 1: selects ck01 as operation clock of channel p, q. * make the same setting as master channel. (b) timer output register 0 (to0) bit q bit p to0 to0q 1/0 to0p 1/0 0: outputs 0 from to0p or to0q. 1: outputs 1 from to0p or to0q. (c) timer output enable register 0 (toe0) bit q bit p toe0 toe0q 1/0 toe0p 1/0 0: stops the to0p or to0q output operation by counting operation. 1: enables the to0p or to0q output operation by counting operation. (d) timer output level register 0 (tol0) bit q bit p tol0 tol0q 1/0 tol0p 1/0 0: positive logic output (active-high) 1: inverted output (active-low) (e) timer output mode register 0 (tom0) bit q bit p tom0 tom0q 1 tom0p 1 1: sets the combination operation mode. remark n = 0, 2, 4; p = n + 1; q = n + 2 chapter 7 timer array unit user?s manual u17894ej8v0ud 306 figure 7-69. 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 bit 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 tps0 register. determines clock frequencies of ck00 and ck01. sets the tmr0n, tmr0p, and tmr0q registers of each channel to be used (determines operation mode of channels). an interval (period) value is set to the tdr0n register of the master channel, and a duty factor is set to the tdr0p and tdr0q registers of the slave channel. channel stops operating. (clock is supplied and some power is consumed.) channel default setting sets slave channel. the tom0p and tom0q bits of the tom0 register are set to 1 (combination operation mode). clears the tol0p and tol0q bits to 0. sets the to0p and to0q bits and determines default level of the to0p and to0q outputs. sets toe0p or toe0q to 1 and enables operation of to0p or to0q. clears the port register and port mode register to 0. the to0p and to0q pins go into hi-z output state. the to0p and to0q default setting levels are output when the port mode register is in output mode and the port register is 0. to0p or to0q does not change because channel stops operating. the to0p and to0q pins output the to0p and to0q set levels. remarks 1. n = 0, 2, 4 2. p = n + 1; q = n + 2 chapter 7 timer array unit user?s manual u17894ej8v0ud 307 figure 7-69. operation procedure when mult iple pwm output function is used (2/2) software operation hardware status operation start sets toe0p and toe0q (slave) to 1 (only when operation is resumed). the ts0n bit (master), and ts0p and ts0q (slave) bits of the ts0 register are set to 1 at the same time. the ts0n, ts0p, and ts0q bits automatically return to 0 because they are trigger bits. te0n = 1, te0p, te0q = 1 when the master channel starts counting, inttm0n is generated. triggered by this interrupt, the slave channel also starts counting. during operation set values of the tmr0n, tmr0p, tmr0q registers, tom0n, tom0p, tom0q, tol0n, tol0p, and tol0q bits cannot be changed. set values of the tdr0n, tdr0p, and tdr0q registers can be changed after inttm0n of the master channel is generated. the tcr0n, tcr0p, and tcr0q registers can always be read. the tsr0n, tsr0p, and tsr 0q registers are not used. set values of the to0 and toe0 registers can be changed. the counter of the master channel loads the tdr0n value to tcr0n and counts down. when the count value reaches tcrn = 0000h, inttm0n output is generated. at the same time, the value of the tdr0n register is loaded to tcr0n, and the counter starts counting down again. at the slave channel 1, the values of tdr0p are transferred to tcr0p, triggered by inttm0n of the master channel, and the counter starts counting down. the output levels of to0p become active one count clock after generation of the inttm0n output from the master channel. it becomes inactive when tcr0p = 0000h, and the counting operation is stopped. at the slave channel 2, the values of tdr0q are transferred to tdr0q, triggered by inttm0n of the master channel, and the counter starts counting down. the output levels of to0q become active one count clock after generation of the inttm0n output from the master channel. it becomes inactive when tcr0q = 0000h, and the counting operation is stopped. after that, the above operation is repeated. the tt0n bit (master), tt0p, and tt0q (slave) bits are set to 1 at the same time. the tt0n, tt0p, and tt0q bits automatically return to 0 because they are trigger bits. te0n, te0p = 0, te0q = 0, and count operation stops. tcr0n, tcr0p, and tcr0q hold count value and stops. the to0p and to0q outputs are not initialized but holds current status. operation stop toe0p or toe0q of slave channel is cleared to 0 and value is set to the to0p and to0q bits. the to0p and to0q pins output the to0p and to0q set levels. to hold the to0p and to0q pin output levels clears to0p and to0q bits to 0 after the value to be held is set to the port register. when holding the to0p and to0q pin output level is not necessary switches the port mode register to input mode. the to0p and to0q pin output levels are held by port function. the to0p and to0q pin output levels go into hi-z output state. tau stop the tau0en bit of the per0 register is cleared to 0. power-off status all circuits are initialized and sfr of each channel is also initialized. (the to0p and to0q bits are cleared to 0 and the to0p and to0q pins are set to port mode.) remarks 1. n = 0, 2, 4 2. p = n + 1; q = n + 2 operation is resumed. user?s manual u17894ej8v0ud 308 chapter 8 real-time counter 8.1 functions of real-time counter 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 8.2 configuration of real-time counter the real-time counter includes the following hardware. table 8-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) control registers alarm week register (alarmww) chapter 8 real-time counter user?s manual u17894ej8v0ud 309 figure 8-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 rtc1hz/ intp3/p30 rckdiv rinte rtcdiv/rtccl/p15 intrtci rcloe2 f sub rwait wale walie wafg rwait rwst rifg rwst rifg 12-bit counter real-time counter control register 1 real-time counter control register 0 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 1 month 1 day 1 hour 1 minute chapter 8 real-time counter user?s manual u17894ej8v0ud 310 8.3 registers controlling real-time counter the real-time counter is controlle d by the following 16 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) chapter 8 real-time counter user?s manual u17894ej8v0ud 311 (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 reduce 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 8-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 iic0en sau1en sau0en 0 tau0en rtcen control of real-time counter (rtc) input clock supply note 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. note rtcen is used to supply or stop the clock used when accessing the real-time counter (rtc) register 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. be sure to clear bit 1 of the per0 register 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. chapter 8 real-time counter user?s manual u17894ej8v0ud 312 figure 8-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.768 khz). 1 enables output of rtccl pin (32.768 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 8-2 shows the displayed time digits. 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 rt ce = 1, glitches may o ccur in the 32.768 khz and 1 hz output signals. remark : don?t care chapter 8 real-time counter user?s manual u17894ej8v0ud 313 (3) real-time counter cont rol register 1 (rtcc1) the rtcc1 register is an 8-bit regist er that is used to control the alarm interrupt 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 8-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. chapter 8 real-time counter user?s manual u17894ej8v0ud 314 figure 8-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 the rifg and wafg flags may be cleared when the rtcc1 register is written by using a 1-bit manipulation instruction. use, th erefore, an 8-bit manipulation in struction in order to write to the rtcc1 register. to prevent the rifg and wa fg flags from being cl eared during writing, disable writing by setting ?1? to the correspondi ng bit. when the value may be rewritten because the rifg and wafg flags are not being used, the rtcc1 register may be written by using a 1-bit manipulation instruction. remark fixed-cycle interrupts and alarm match interrupts use the same interrupt source (intrtc). when using these two types of interrupt s at the same time, which interrupt occurred can be judged by checking the fixed-cycle interrupt status flag (r ifg) and the alarm detecti on status flag (wafg) upon intrtc occurrence. chapter 8 real-time counter user?s manual u17894ej8v0ud 315 (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 8-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 xt (1.953125 ms) 1 0 0 1 2 7 /f xt (3.90625 ms) 1 0 1 0 2 8 /f xt (7.8125 ms) 1 0 1 1 2 9 /f xt (15.625 ms) 1 1 0 0 2 10 /f xt (31.25 ms) 1 1 0 1 2 11 /f xt (62.5 ms) 1 1 1 2 12 /f xt (125 ms) rcloe2 note rtcdiv pin output control 0 output of rtcdiv pin is disabled. 1 output of rtcdiv pin is enabled. 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) notes 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 continu es 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 the high leve l, a pulse of at least one clock width of f xt 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. chapter 8 real-time counter user?s manual u17894ej8v0ud 316 (5) sub-count re gister (rsubc) the rsubc register is a 16-bit register that 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 regi ster, 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 guar anteed if it is read du ring operation, because a value that is changing is read. figure 8-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 buffer 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. if a value outside the range is set, the register value returns to the normal value after 1 period. sec can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 8-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 chapter 8 real-time counter user?s manual u17894ej8v0ud 317 (7) minute count register (min) the min register is an 8-bit register that takes a valu e 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 buffer and then to the counter up to 2 clocks (32.768 khz) later. even if the second 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 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 8-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-bit register that takes a va lue of 00 to 23 or 01 to 12, 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 buffer 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 writt en, this register ignores the overflow and is set to the value written. set a decimal valu e of 00 to 23, 01 to 12, or 21 to 32 to this register in bcd code. if a value outside the range is set, the regi ster value returns to the normal value after 1 period. 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 is set to 1 after reset. figure 8-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 ho ur indicates am(0)/pm(1) if ampm = 0 (if the 12-hour system is selected). chapter 8 real-time counter user?s manual u17894ej8v0ud 318 table 8-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 chapter 8 real-time counter user?s manual u17894ej8v0ud 319 (9) day count register (day) the day register is an 8-bit register that takes a value of 1 to 31 (dec imal) 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 buffer and then to the counter up to 2 clocks (32.768 khz) later. even if the hour 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 value of 01 to 31 to this register in bcd code. if a value outside the range is set, the register value returns to the normal value after 1 period. day can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 01h. figure 8-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 chapter 8 real-time counter user?s manual u17894ej8v0ud 320 (10) week count register (week) the week register is an 8-bit register that takes a value of 0 to 6 (decimal) and indicates the 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. if a value outside the range is set, the register value returns to the normal value after 1 period. week can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 8-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 auto matically. after reset release, se t the week count register as follow. day week sunday 00h monday 01h tuesday 02h wednesday 03h thursday 04h friday 05h saturday 06h chapter 8 real-time counter user?s manual u17894ej8v0ud 321 (11) month count register (month) the month register is an 8-bit regist er 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 register is being written, this register ignores the overflow and is set to the value written. set a decimal va lue of 01 to 12 to this register in bcd code. if a value outside the range is set, the register value returns to the normal value after 1 period. month can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 01h. figure 8-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 that takes a value of 0 to 99 (dec imal) and 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 va lue of 00 to 99 to this register in bcd code. if a value outside the range is set, the register value returns to the normal value after 1 period. year can be set by an 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 8-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 chapter 8 real-time counter user?s manual u17894ej8v0ud 322 (13) watch error correction register (subcud) this register is used to correct the watch with high a ccuracy 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 8-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). 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 corre cted by using the watch error corre ction 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 set dev to 0 when the correction range is ? 63.1 ppm or less, or 63.1 ppm or more. chapter 8 real-time counter user?s manual u17894ej8v0ud 323 (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 8-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 is set to 1 after reset. caution set a decimal value of 00 to 23, 01 to 12, or 21 to 32 to this register in bcd code. if a value outside the range is set, the alarm is not detected. figure 8-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 indicates am(0)/pm(1) if ampm = 0 (if the 12-hour system is selected). (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 8-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 chapter 8 real-time counter user?s manual u17894ej8v0ud 324 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 chapter 8 real-time counter user?s manual u17894ej8v0ud 325 8.4 real-time counter operation 8.4.1 starting operation of real-time counter figure 8-18. 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 note 2 starts counter operation. reading counter rtcen = 1 note 1 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 8.4.2 shifting to stop m ode after starting operation when shifting to stop mode without waiting for intrtc = 1 after rtce = 1. chapter 8 real-time counter user?s manual u17894ej8v0ud 326 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 8.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 8-19 , 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 checki ng again by polling that rwst has become 0 (see figure 8- 19 , example 2 ). figure 8-19. procedure for shifting to stop mode after setting rtce to 1 chapter 8 real-time counter user?s manual u17894ej8v0ud 327 8.4.3 reading/writing real-time counter read or write the counter after setting 1 to rwait first. figure 8-20. 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. chapter 8 real-time counter user?s manual u17894ej8v0ud 328 figure 8-21. 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. chapter 8 real-time counter user?s manual u17894ej8v0ud 329 8.4.4 setting alarm of real-time counter set time of alarm after setting 0 to wale first. figure 8-22. 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 use the same interrupt source (intrtc). when using these two types of interrupt s at the same time, which interrupt occurred can be judged by checking the fixed-cycle interrupt status flag (rif g) and the alarm detection status flag (wafg) upon intrtc occurrence. chapter 8 real-time counter user?s manual u17894ej8v0ud 330 8.4.5 1 hz output of real-time counter figure 8-23. 1 hz output setting procedure rtce = 0 rtce = 1 start stops counter operation. rcloe1 = 1 enables output of rtc1hz pin (1 hz). starts counter operation. output start from rtc1hz pin 8.4.6 32.768 khz output of real-time counter figure 8-24. 32.768 khz output setting procedure rtce = 0 rtce = 1 start stops counter operation. rcloe0 = 1 enables output of rtccl pin (32.768 khz). starts counter operation. 32.768 khz output start from rtccl pin 8.4.7 512 hz, 16.384 khz output of real-time counter figure 8-25. 512 hz, 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 chapter 8 real-time counter user?s manual u17894ej8v0ud 331 8.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 correcting 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 correction 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 khz output frequency 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 a fter correction performed by using the watch error correction register. chapter 8 real-time counter user?s manual u17894ej8v0ud 332 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 outpu tting 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 8.4.5 1 hz output of real-time counter for the setting procedure of outputting about 1 hz from the rtc1hz pin, and 8.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 assu med 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 32 772.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 8-26 shows the operation when (dev, f6, f5, f4, f3, f2, f1, f0) is (0, 0, 1, 0, 1, 1, 0, 0). chapter 8 real-time counter user?s manual u17894ej8v0ud 333 figure 8-26. 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 chapter 8 real-time counter user?s manual u17894ej8v0ud 334 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 outpu tting 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 8.4.5 1 hz output of real-time counter for the setting procedure of outputting about 1 hz from the rtc1hz pin, and 8.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 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 327 68 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 8-27 shows the operation when (dev, f6, f5, f4, f3, f2, f1, f0) is (1, 1, 1, 0, 1, 1, 1, 0). chapter 8 real-time counter user?s manual u17894ej8v0ud 335 figure 8-27. 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 user?s manual u17894ej8v0ud 336 chapter 9 watchdog timer 9.1 functions of watchdog timer the watchdog timer operates on the internal low-speed oscillation clock. the watchdog timer is used to detect an inadvertent program loop. if a program loop is detected, an internal reset signal is generated. program loop is detected in the following cases. ? if the watchdog timer counter overflows ? if a 1-bit manipulation instruction is execut ed on the watchdog timer enable register (wdte) ? if data other than ?ach? is written to wdte ? if data is written to wdte during a window close period 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 20 reset function . when 75% of the overflow time is reached, an interval interrupt can be generated. chapter 9 watchdog timer user?s manual u17894ej8v0ud 337 9.2 configuration of watchdog timer the watchdog timer includes the following hardware. table 9-1. configuration of watchdog timer item configuration control register watchdog timer enable register (wdte) how the counter operation is controlled, overflow time, wi ndow open period, and interval interrupt are set by the option byte. table 9-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 24 option byte . figure 9-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 10 to f il /2 20 remark f il : internal low-speed oscillation clock frequency chapter 9 watchdog timer user?s manual u17894ej8v0ud 338 9.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 9-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 wdton 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 instructio n 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)). chapter 9 watchdog timer user?s manual u17894ej8v0ud 339 9.4 operation of watchdog timer 9.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 setting bit 4 (wdton) of the option byte (000c0h) to 1 (the counter starts operating after a reset release) (for details, see chapter 24 ). 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 9.4.2 and chapter 24 ). ? set a window open period by using bits 6 and 5 (window1 and window0) of the option byte (000c0h) (for details, see 9.4.3 and chapter 24 ). 2. after a reset release, the watchdog timer starts counting. 3. by writing ?ach? to wdte after the watchdog timer starts counting and before the overflow time set by the option byte, the watchdog timer is cl eared and starts counting again. 4. after that, write wdte the second time or later afte r 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. a 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 th e first time after reset re lease, the watchdog timer is cleared in any timing regardl ess of the window open time, as long as the register is written before the overflow time, and the wa tchdog 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. chapter 9 watchdog timer user?s manual u17894ej8v0ud 340 cautions 4. the operation of the watchdog time r in the halt and stop modes differs as follows depending on the set value of bit 0 (wds tbyon) 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 the x1 oscillation clock after releasi ng the stop mode, the cpu starts operating after the oscillation stabilization time has elapsed. therefore, if the period between the stop mode release a nd the watchdog timer overflow is short, an overflow occurs during the o scillation stabilization time, causing a reset. consequently, set the ov erflow time in consideration of the oscillation stabilization time when operating with the x1 oscillation clock a nd 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 in terrupt acknowledge time is delayed. set the overflow time and window size taking this delay into consideration. 9.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 generat ed. the present count is cleared and the watchdog timer starts counting again by writing ?ach? to wdte dur ing the window open period before the overflow time. the following overflow time is set. table 9-3. setting of overflow time of watchdog timer wdcs2 wdcs1 wdcs0 overflow time of watchdog timer 0 0 0 2 10 /f il (3.88 ms) 0 0 1 2 11 /f il (7.76 ms) 0 1 0 2 12 /f il (15.52 ms) 0 1 1 2 13 /f il (31.03 ms) 1 0 0 2 15 /f il (124.12 ms) 1 0 1 2 17 /f il (496.48 ms) 1 1 0 2 18 /f il (992.97 ms) 1 1 1 2 20 /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 processing, the inte rrupt acknowledge time is delayed. set the overflow time and window size taki ng this delay into consideration. remarks 1. f il : internal low-speed oscillation clock frequency 2. ( ): f il = 264 khz (max.) chapter 9 watchdog timer user?s manual u17894ej8v0ud 341 9.4.3 setting window open period of watchdog timer set the window open period of the watchdog timer by usi ng bits 6 and 5 (window1, window0) of the option byte (000c0h). the outline of the window is as follows. ? if ?ach? is written to wdte during the window open per iod, the watchdog timer is cleared and starts counting again. ? even if ?ach? is written to wdte during the window cl ose period, an abnormality is detected and an internal reset signal is generated. example : if the window open period is 25% window close period (75%) window open period (25%) counting starts overflow time counting starts again when ?ach? is written to wdte. internal reset signal is generated if ?ach? is written to wdte. caution when data is writte n 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 9-4. setting window op en period of watchdog timer window1 window0 window open period of watchdog timer 0 0 25% 0 1 50% 1 0 75% 1 1 100% cautions 1. the watchdog timer continues its operation during self-programmi ng of the flash memory and eeprom emulation. during processing, the interrupt acknowledge ti me is delayed. set the overflow time and window size t aking 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. 3. do not set the window open period to 25% if the watchdog timer corresponds to either of the conditions below. ? when used at a supply voltage (v dd ) below 2.7 v. ? when stopping all main system clocks (inter nal high-speed oscillation clock, x1 clock, and external main system clock) by u se of the stop mode or software. ? low-power consumption mode chapter 9 watchdog timer user?s manual u17894ej8v0ud 342 remarks 1. if the overflow time is set to 2 10 /f il , the window close time and open time are as follows. setting of window open period 25% 50% 75% 100% window close time 0 to 3.56 ms 0 to 2.37 ms 0 to 0.119 ms none window open time 3.56 to 3.88 ms 2.37 to 3.88 ms 0.119 to 3.88 ms 0 to 3.88 ms user?s manual u17894ej8v0ud 343 chapter 10 clock output/buzzer output controller 10.1 functions of clock output/buzzer output controller the clock output controller is intended for carrier output 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 10-1 shows the block diagram of clock output/buzzer output controller. figure 10-1. block diagram of clo ck output/buzzer output controller f main f sub pcloe0 0 0 0 pcloe0 5 3 pclbuz0 note /intp6/p140 pclbuz1 note /intp7/p141 csel0 ccs02 ccs01 ccs00 pm141 pm140 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 (p141) internal bus clock output select register 0 (cks0) output latch (p140) 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 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. remark f main : main system clock frequency f sub : subsystem clock frequency chapter 10 clock output/buzzer output controller user?s manual u17894ej8v0ud 344 10.2 configuration of clock output/buzzer output controller the clock output/buzzer output controller includes the following hardware. table 10-1. configuration of clock output/buzzer output controller item configuration control registers clock output select registers 0, 1 (cks0, cks1) port mode register 14 (pm14) port register 14 (p14) 10.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 14 (pm14) (1) clock output select regi sters 0, 1 (cks0, cks1) these registers set output enable/disable for clock 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. chapter 10 clock output/buzzer output controller user?s manual u17894ej8v0ud 345 figure 10-2. format of clock out put select register n (cksn) address: fffa5h 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. remarks 1. n = 0, 1 2. f main : main system clock frequency 3. f sub : subsystem clock frequency chapter 10 clock output/buzzer output controller user?s manual u17894ej8v0ud 346 (2) port mode register 14 (pm14) this register sets port 14 input/output in 1-bit units. when using the p140/intp6/pclbuz0 and p141/intp7/pc lbuz1 pins for clock output/buzzer output, clear pm140 and pm141 and the output latc hes of p140 and p141 to 0. pm14 is set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets this register to ffh. figure 10-3. format of port mode register 14 (pm14) address: fff2eh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm14 1 1 pm145 pm144 pm143 pm142 pm141 pm140 pm14n p14n pin i/o mode selection (n = 0 to 5) 0 output mode (output buffer on) 1 input mode (output buffer off) 10.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). 10.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 ccsn2, cseln) of the clo ck output select register (cksn) of the pclbuzn pin (out put in disabled status). <2> set bit 7 (pcloen) of cksn to 1 to enable clock/buzzer output. remark the controller is designed not to output a pulse with a narrow width when it is used to output a clock and when clock output is enabled or disabled. as shown in figure 10-4, be sure to start output from the low period of the clock (marked with * in the figure). when stopping output, do so after the high-level period of the clock. figure 10-4. remote control output application example pcloen clock output ** remark n = 0, 1 user?s manual u17894ej8v0ud 347 chapter 11 a/d converter 11.1 function of a/d converter the a/d converter converts an analog input signal into a di gital value, and consists of up to 16 channels (ani0 to ani15) with a resolution of 10 bits. the a/d converter has the following function. ? 10-bit resolution a/d conversion 10-bit resolution a/d conversion is carried out repeatedly for one analog input channel selected from ani0 to ani15. each time an a/d conversion operation en ds, an interrupt request (intad) is generated. figure 11-1. block diag ram of a/d converter intad adcs fr2 fr1 adce fr0 av ss 5 ani0/p20 ani1/p21 ani2/p22 ani3/p23 ani4/p24 ani5/p25 ani6/p26 ani7/p27 ani8/p150 ani9/p151 ani10/p152 ani11/p153 ani12/p154 ani13/p155 ani14/p156 ani15/p157 lv1 lv0 5 adpc3 adpc2 adpc1 adpc0 5 adpc4 ads3 ads2 ads1 ads0 adiss av ref0 av ss a/d converter mode register (adm) sample & hold circuit voltage comparator adcs bit tap selector successive approximation register (sar) controller a/d conversion result register (adcr) selector internal bus analog input channel specification register (ads) a/d port configuration register (adpc) chapter 11 a/d converter user?s manual u17894ej8v0ud 348 11.2 configuration of a/d converter the a/d converter includes the following hardware. (1) ani0 to ani15 pins these are the analog input pins of the 16-channel a/d converter. they input analog signals to be converted into digital signals. pins other than the one selected as the analog input pin can be used as i/o port pins. (2) sample & hold circuit the sample & hold circuit samples the input voltage of the analog input pin selected by the selector when a/d conversion is started, and holds the samp led voltage value during a/d conversion. (3) series resistor string the series resistor string is connected between av ref0 and av ss , and generates a voltage to be compared with the sampled voltage value. figure 11-2. circuit configuration of series resistor string adcs series resistor string av ref0 p-ch av ss (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, starting from the most significant bit (msb). when the voltage value is converted into a digital valu e down to the least significant bit (lsb) (end of a/d conversion), the contents of the sar register are transfe rred to the a/d conversion result register (adcr). (6) 10-bit a/d conversion r esult register (adcr) the a/d conversion result is loaded from the successive approximation register to th is register each time a/d conversion is completed, and the adcr re gister holds the a/d conversion result in its higher 10 bits (the lower 6 bits are fixed to 0). (7) 8-bit a/d conversion result register (adcrh) the a/d conversion result is loaded from the successive approximation register to th is register each time a/d conversion is completed, and the adcrh register stores the higher 8 bi ts of the a/d conversion result. chapter 11 a/d converter user?s manual u17894ej8v0ud 349 (8) controller this circuit controls the conversion time of an input analog signal that is to be converted into a digital signal, as well as starting and stopping of t he conversion operation. when a/d c onversion has been completed, this controller generates intad. (9) av ref0 pin this pin inputs an analog power/reference voltage to the a/d converter. the signal input to ani0 to ani15 is converted into a digital signal, based on the voltage applied across av ref0 and av ss . the voltage that can be supplied to av ref0 varies as follows, depending on whether p20/ani0 to p27/ani7 and p150/ani8 to p157/ani15 are used as digital i/os or analog inputs. table 11-1. av ref0 voltage applied to p20/ani0 to p27/ ani7 and p150/ani8 to p157/ani15 pins analog/digital v dd condition av ref0 voltage using at least one pin as an analog input and using all pins not as digital i/os 2.3 v v dd 5.5 v 2.3 v av ref0 v dd = ev dd0 = ev dd1 2.7 v v dd 5.5 v 2.7 v av ref0 v dd = ev dd0 = ev dd1 pins used as analog inputs and digital i/os are mixed note 2.3 v v dd < 2.7 v av ref0 has same potential as ev dd0 , ev dd1 , and v dd 2.7 v v dd 5.5 v 2.7 v av ref0 v dd = ev dd0 = ev dd1 using at least one pin as a digital i/o and using all pins not as analog inputs note 1.8 v v dd < 2.7 v av ref0 has same potential as ev dd0 , ev dd1 , and v dd note av ref0 is the reference for the i/o voltage of a port to be used as a digital port. ? high-/low-level input voltage (v ih4 /v il4 ) ? high-/low-level output voltage (v oh2 /v ol2 ) (10) av ss pin this is the ground potential pin of t he a/d converter. always use this pin at the same potential as that of the ev ss0 , ev ss1 , and v ss pins even when the a/d converter is not used. (11) a/d converter mode register (adm) this register is used to set the conver sion time of the analog input signal to be converted, and to start or stop the conversion operation. (12) a/d port configuration register (adpc) this register switches the ani0/p20 to ani7/p27 and ani8/p150 to ani15/p157 pins to analog input of a/d converter or digital i/o of port. (13) analog input channel sp ecification register (ads) this register is used to specify the port that inputs the analog voltage to be converted into a digital signal. (14) port mode registers 2 and 15 (pm2, pm15) this register switches the ani0/p20 to ani7/p27 an d ani8/p150 to ani15/p157 pins to input or output. chapter 11 a/d converter user?s manual u17894ej8v0ud 350 11.3 registers used in a/d converter the a/d converter uses the following seven registers. ? peripheral enable register 0 (per0) ? a/d converter mode register (adm) ? a/d port configuration register (adpc) ? analog input channel specification register (ads) ? port mode registers 2 and 15 (pm2, pm15) ? 10-bit a/d conversion result register (adcr) ? 8-bit a/d conversion result register (adcrh) (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripher al hardware macro. clock supply to a hardware macro that is not used is stopped in order to reduce 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 11-3. 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 iic0en sau1en sau0en 0 tau0en adcen control of a/d converter input clock 0 stops supply of input clock. ? sfr used by the a/d converter cannot be written. ? the a/d converter is in the reset status. 1 supplies input clock. ? sfr used by the a/d converter can be read/written. cautions 1. when setting the a/d conver ter, be sure to set adcen to 1 fi rst. if adcen = 0, writing to a control register of the a/d converter is ignored , and, even if the register is read, only the default value is read (except for port mode registers 2 and 15 (pm2, pm15)). 2. be sure to clear bit 1 of the per0 register to 0. chapter 11 a/d converter user?s manual u17894ej8v0ud 351 (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 11-4. format of a/d converter mode register (adm) adce lv0 note 1 lv1 note 1 fr0 note 1 fr1 note 1 fr2 note 1 0 adcs a/d conversion operation control stops conversion operation enables conversion operation adcs 0 1 <0> 1 2 3 4 5 6 <7> adm address: fff30h after reset: 00h r/w symbol comparator operation control note 2 stops comparator operation enables comparator operation (comparator: 1/2av ref0 operation) adce 0 1 notes 1. for details of fr2 to fr0, lv 1, lv0, and a/d conversion, see table 11-3 a/d conversion time selection . 2. the operation of the compar ator is controlled by adcs and adce, and it takes 1 s from operation start to operation stabilization. theref ore, when adcs is set to 1 after 1 s or more has elapsed from the time adce is set to 1, the conversion result at that time has priority over the first conversion result. otherwise, ignore data of the first conversion. table 11-2. settings of adcs and adce adcs adce a/d co nversion operation 0 0 stop status (dc power consumption path does not exist) 0 1 conversion waiting mode (comparator: 1/2av ref0 operation, only comparator consumes power) 1 0 setting prohibited 1 1 conversion mode (comparator: 1/2av ref0 operation) figure 11-5. timing chart wh en comparator is used adce comparator adcs conversion operation conversion operation conversion stopped conversion waiting comparator: 1/2av ref0 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. caution a/d conversion must be sto pped before rewriting bits fr0 to fr2, lv1, and lv0 to values other than the identical data. chapter 11 a/d converter user?s manual u17894ej8v0ud 352 table 11-3. a/d conversion time selection (1) 2.7 v av ref0 5.5 v a/d converter mode register (adm) conversion time selection fr2 fr1 fr0 lv1 lv0 f clk = 2 mhz f clk = 10 mhz f clk = 20 mhz conversion clock (f ad ) 0 0 0 0 0 264/f clk 26.4 s 13.2 s f clk /12 0 0 1 0 0 176/f clk setting prohibited 17.6 s 8.8 s note 1 f clk /8 0 1 0 0 0 132/f clk 66.0 s note 2 13.2 s 6.6 s note 1 f clk /6 0 1 1 0 0 88/f clk 44.0 s note 2 8.8 s note 1 f clk /4 1 0 0 0 0 66/f clk 33.0 s 6.6 s note 1 f clk /3 1 0 1 0 0 44/f clk 22.0 s f clk /2 1 1 1 0 0 22/f clk 11.0 s note 1 setting prohibited setting prohibited f clk other than above setting prohibited notes 1. this can be set only when 4.0 v av ref0 5.5 v. 2. functionally expanded products ( pd78f116xa) only. caution set the conversion times with the following conditions. conventional-specification products ( pd78f116x) ? 4.0 v av ref0 5.5 v: f ad = 0.6 to 3.6 mhz ? 2.7 v av ref0 < 4.0 v: f ad = 0.6 to 1.8 mhz functionally expa nded products ( pd78f116xa) ? 4.0 v av ref0 5.5 v: f ad = 0.33 to 3.6 mhz ? 2.7 v av ref0 < 4.0 v: f ad = 0.33 to 1.8 mhz chapter 11 a/d converter user?s manual u17894ej8v0ud 353 (2) 2.3 v av ref0 5.5 v a/d converter mode register (adm) conversion time selection fr2 fr1 fr0 lv1 lv0 f clk = 2 mhz f clk = 5 mhz conversion clock (f ad ) 0 0 0 0 1 480/f clk setting prohibited f clk /12 0 0 1 0 1 320/f clk 64.0 s f clk /8 0 1 0 0 1 240/f clk 48.0 s f clk /6 0 1 1 0 1 160/f clk setting prohibited 32.0 s f clk /4 1 0 0 0 1 120/f clk 60.0 s 24.0 s note 1 f clk /3 1 0 1 0 1 80/f clk 40.0 s 16.0 s note 2 f clk /2 1 1 1 0 1 40/f clk 20.0 s note 2 setting prohibited f clk other than above setting prohibited notes 1. this can be set only when 2.7 v av ref0 5.5 v. 2. this can be set only when 4.0 v av ref0 5.5 v. cautions 1. set the conversion ti mes with the following conditions. ? 4.0 v av ref0 5.5 v: f ad = 0.6 to 3.6 mhz ? 2.7 v av ref0 < 4.0 v: f ad = 0.6 to 1.8 mhz ? 2.3 v av ref0 < 2.7 v: f ad = 0.6 to 1.44 mhz 2. when rewriting fr2 to fr0, lv1, and lv0 to other than the same data, stop a/d conversion once (adcs = 0) beforehand. 3. change lv1 and lv0 from the default value, when 2.3 v av ref0 < 2.7 v. 4. the above conversion time do es not include clock frequency e rrors. select conversion time, taking clock frequency erro rs into consideration. remark f clk : cpu/peripheral hardware clock frequency chapter 11 a/d converter user?s manual u17894ej8v0ud 354 figure 11-6. a/d converter sa mpling and a/d conversion timing adcs 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 chapter 11 a/d converter user?s manual u17894ej8v0ud 355 (3) 10-bit a/d conversion r esult register (adcr) this register is a 16-bit register that stores the a/d conversion result. the lower 6 bits are fixed to 0. each time a/d conversion ends, the conversion result is loaded from the successive approximation register. the higher 8 bits of the conversion result are stored in fff1fh and the lower 2 bits are stored in the higher 2 bits of fff1eh. adcr can be read by a 16-bit memory manipulation instruction. reset signal generation clears this register to 0000h. figure 11-7. format of 10-bit a/d conversion result register (adcr) symbol address: fff1fh, fff1eh after reset: 0000h r fff1fh fff1eh 0 0 0 0 0 0 adcr caution when writing to the a/d converter mode register (adm), analog input chan nel specification register (ads), and a/d port configuration regi ster (adpc), the conten ts of adcr may become undefined. read the conversion result followin g conversion completion before writing to adm, ads, and adpc. using timing other than the abo ve may cause an incorrect conversion result to be read. (4) 8-bit a/d conversion result register (adcrh) this register is an 8-bit register that stores the a/d conversion result. the higher 8 bits of 10-bit resolution are stored. adcrh can be read by an 8-bit memory manipulation instruction. reset signal generation clears this register to 00h. figure 11-8. format of 8-bit a/d c onversion result register (adcrh) symbol adcrh address: fff1fh after reset: 00h r 76543210 caution when writing to the a/d converter mode register (adm), analog input chan nel specification register (ads), and a/d port configuration regi ster (adpc), the contents of adcrh may become undefined. read the conversion result followin g conversion completion before writing to adm, ads, and adpc. using timing other than the abo ve may cause an incorrect conversion result to be read. chapter 11 a/d converter user?s manual u17894ej8v0ud 356 (5) 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 11-9. 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 adiss 0 0 0 ads3 ads2 ads1 ads0 adiss ads3 ads2 ads1 ads0 analog input channel input source 0 0 0 0 0 ani0 p20/ani0 pin 0 0 0 0 1 ani1 p21/ani1 pin 0 0 1 0 ani2 p22/ani2 pin 0 0 1 1 ani3 p23/ani3 pin 0 1 0 0 ani4 p24/ani4 pin 0 1 0 1 ani5 p25/ani5 pin 0 1 1 0 ani6 p26/ani6 pin 0 1 1 1 ani7 p27/ani7 pin 1 0 0 0 ani8 p150/ani8 pin 1 0 0 1 ani9 p151/ani9 pin 1 0 1 0 ani10 p152/ani10 pin 1 0 1 1 ani11 p153/ani11 pin 1 1 0 0 ani12 p154/ani12 pin 1 1 0 1 ani13 p155/ani13 pin 1 1 1 0 ani14 p156/ani14 pin 1 1 1 1 ani15 p157/ani15 pin cautions 1. be sure to cl ear bits 4 to 6 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. remark : don?t care chapter 11 a/d converter user?s manual u17894ej8v0ud 357 (6) a/d port configuration register (adpc) this register switches the ani0/p20 to ani7/p27 and ani8/p150 to ani15/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. figure 11-10. 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)/digital i/o (d) switching port 15 port 2 adp c4 adp c3 adp c2 adp c1 adp c0 ani15 /p157 ani14 /p156 ani13 /p155 ani12 /p154 ani11 /p153 ani10 /p152 ani9 /p151 ani8 /p150 ani7 /p27 ani6 /p26 ani5 /p25 ani4 /p24 ani3 /p23 ani2 /p22 ani1 /p21 ani0 /p20 0 0 0 0 0 a a a a 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 a a a a d 0 0 0 1 0 a a a a 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 a a a a d d d 0 0 1 0 0 a a a a a a a a a a a a d d d d 0 0 1 0 1 a a a a a a a a a a a d d d d d 0 0 1 1 0 a a a a a a a a a a d d d d d d 0 0 1 1 1 a a a a a a a a a d d d d d d d 0 1 0 0 0 a a a a a a a a d d d d d d d d 0 1 0 0 1 a a a a a a a d d d d d d d d d 0 1 0 1 0 a a a a a a d d d d d d d d d d 0 1 0 1 1 a a a a a d d d d d d d d d d d 0 1 1 0 0 a a a a d d d d d d d d d d d d 0 1 1 0 1 a a a d d d d d d d d d d d d d 0 1 1 1 0 a a d d d d 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 d d d d 1 0 0 0 0 d d d d d d d d d d d d d d d d other than above setting prohibited cautions 1. set a channel to be u sed for a/d conversion in the input mode by usi ng 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. 3. p20/ani0 to p27/ani7 and p 150/ani8 to p157/ani15 are set as analog inputs in the order of p157/ani15, ?, p150/ani8, p27/ani7, ?, p20/ani 0 by the a/d port configuration register (adpc). when using p20/ani0 to p27/ani7 and p150/ani8 to p157/ ani15 as analog inputs, start designing from p157/ani15. chapter 11 a/d converter user?s manual u17894ej8v0ud 358 (7) port mode registers 2 and 15 (pm2, pm15) when using the ani0/p20 to ani7/p27 and ani8/p150 to ani15/p157 pins for analog input port, set pm20 to pm27 and pm150 to pm157 to 1. the output latches of p20 to p27 and p150 to p157 at this time may be 0 or 1. if pm20 to pm27 and pm150 to 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. caution if a pin is set as an analog input por t, not the pin level bu t ?0? is always read. figure 11-11. format of port mode registers 2 and 15 (pm2, pm15) 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 pm156 pm155 pm154 pm153 pm152 pm151 pm150 pmmn pmn pin i/o mode selection (m = 2, 15; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) ani0/p20 to ani7/p27 and ani8/p150 to ani15/p157 pins are as shown below depending on the settings of adpc, ads, pm2, and pm15. table 11-4. setting functions of ani0/p20 to ani7/p27 and ani8/p150 to ani15/p157 pins adpc pm2 and pm15 ads ani0/p20 to ani7/p27 and ani8/p150 to ani15/p157 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) selects ani. analog input selection output mode does not select ani. setting prohibited chapter 11 a/d converter user?s manual u17894ej8v0ud 359 11.4 a/d converter operations 11.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 bit 0 (adce) of the a/d converter mode register (adm) to 1 to start the operation of the comparator. <3> set channels for a/d conversion to analog input by usi ng the a/d port configuration register (adpc) and set to input mode by using port mode registers 2 and 15 (pm2, pm15). <4> set a/d conversion time by using bits 5 to 1 (fr2 to fr0, lv1, and lv0) of adm. <5> select one channel for a/d conversion using the analog input channel specification register (ads). <6> start the conversion operation by setting bit 7 (adcs) of adm to 1. (<7> to <13> are operations performed by hardware.) <7> the voltage input to the selected analog input c hannel is sampled by the sample & hold circuit. <8> 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. <9> bit 9 of the successive approximation register (sar) is set. the series resistor string voltage tap is set to (1/2) av ref0 by the tap selector. <10> the voltage difference between the series resistor string voltage tap a nd sampled voltage is compared by the voltage comparator. if the analog input is greater than (1/2) av ref0 , the msb of sar remains set to 1. if the analog input is smaller than (1/2) av ref0 , the msb is reset to 0. <11> next, bit 8 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 9 = 1: (3/4) av ref0 ? bit 9 = 0: (1/4) av ref0 the voltage tap and sampled voltage are compared and bit 8 of sar is manipulated as follows. ? analog input voltage voltage tap: bit 8 = 1 ? analog input voltage < voltage tap: bit 8 = 0 <12> comparison is continued in this way up to bit 0 of sar. <13> upon completion of the comparison of 10 bits, an effective digital result value remains in sar, and the result value is transferred to the a/d conversion resu lt register (adcr, adcrh) and then latched. at the same time, the a/d conversion end in terrupt request (intad) can also be generated. <14> repeat steps <7> to <13>, until adcs is cleared to 0. to stop the a/d converter, clear adcs to 0. to restart a/d conversion from the st atus of adce = 1, start from <6>. to start a/d conversion again when adce = 0, set adce to 1, wait for 1 s or longer, and start <6>. to change a channel of a/d conversion, start from <5>. caution make sure the period of <2> to <6> is 1 s or more. remark two types of a/d conversion re sult registers are available. ? adcr (16 bits): store 10-bit a/d conversion value ? adcrh (8 bits): store 8-bit a/d conversion value chapter 11 a/d converter user?s manual u17894ej8v0ud 360 figure 11-12. basic operation of a/d converter conversion time sampling time sampling a/d conversion undefined conversion result a/d converter operation sar adcr intad conversion result a/d conversion operations are performed continuously until bit 7 (adcs) of t he a/d converter mode register (adm) is reset (0) by software. if a write operation is performed to the analog input chan nel specification register (ads) during an a/d conversion operation, the conversion operation is in itialized, and if the adcs bit is set (1), conversion starts again from the beginning. reset signal generation clears the a/d conversion re sult register (adcr, adcrh) to 0000h or 00h. chapter 11 a/d converter user?s manual u17894ej8v0ud 361 11.4.2 input voltage and conversion results the relationship between the analog input voltage input to the analog input pins (ani0 to ani15) and the theoretical a/d conversion result (stored in the 10-bit a/d conversion result regi ster (adcr)) is shown by the following expression. sar = int ( 1024 + 0.5) adcr = sar 64 or ( ? 0.5) v ain < ( + 0.5) where, int( ): function which returns integer part of value in parentheses v ain : analog input voltage av ref0 : av ref0 pin voltage adcr: a/d conversion result register (adcr) value sar: successive approximation register figure 11-13 shows the relationship between the analo g input voltage and the a/d conversion result. figure 11-13. relationship between analog i nput voltage and a/d conversion result 1023 1022 1021 3 2 1 0 ffc0h ff80h ff40h 00c0h 0080h 0040h 0000h a/d conversion result sar adcr 1 2048 1 1024 3 2048 2 1024 5 2048 input voltage/av ref0 3 1024 2043 2048 1022 1024 2045 2048 1023 1024 2047 2048 1 v ain av ref0 av ref0 1024 av ref0 1024 adcr 64 adcr 64 chapter 11 a/d converter user?s manual u17894ej8v0ud 362 11.4.3 a/d converter operation mode the operation mode of the a/d converter is the select mode. one channe l of analog input is selected from ani0 to ani15 by the analog input channel specificati on register (ads) and a/d conversion is executed. (1) a/d conversion operation by setting bit 7 (adcs) of the a/d converter mode regist er (adm) to 1, the a/d conversion operation of the voltage, which is applied to the analog input pin specif ied by the analog input channel specification register (ads), is started. when a/d conversion has been completed, the result of the a/d c onversion is stored in t he a/d conversion result register (adcr), and an interrupt request signal (int ad) is generated. when one a/d conversion has been completed, the next a/d conversion oper ation is immediately started. if ads is rewritten during a/d conversion, the a/d conv ersion operation under execut ion is stopped and restarted from the beginning. if 0 is written to adcs during a/d conversion, a/d conv ersion is immediately stopped. at this time, the conversion result immediat ely before is retained. figure 11-14. a/d conversion operation anin rewriting adm adcs = 1 rewriting ads adcs = 0 anin anin anin anim anin anim anim stopped conversion result immediately before is retained a/d conversion adcr, adcrh intad conversion is stopped conversion result immediately before is retained remarks 1. n = 0 to 15 2. m = 0 to 15 chapter 11 a/d converter user?s manual u17894ej8v0ud 363 the setting methods are described below. <1> set bit 5 (adcen) of peripheral enable register 0 (per0) to 1. <2> set bit 0 (adce) of the a/d converter mode register (adm) to 1. <3> set the channel to be used in the analog input m ode by using bits 4 to 0 (adpc4 to adpc0) of the a/d port configuration register (adpc) and bits 7 to 0 (pm27 to pm20) of port mode register 2 (pm2) and bits 7 to 0 (pm157 to pm150) of port mode register 15 (pm15). <4> select conversion time by using bits 5 to 1 (fr2 to fr0, lv1, and lv0) of adm. <5> select a channel to be used by using bits 7 and 3 to 0 (adiss, ads3 to ads0) of the analog input channel specification register (ads). <6> set bit 7 (adcs) of adm to 1 to start a/d conversion. <7> when one a/d conversion has been completed, an interrupt request signal (intad) is generated. <8> transfer the a/d conversion data to the a/d conversion result register (adcr, adcrh). chapter 11 a/d converter user?s manual u17894ej8v0ud 364 11.5 temperature sensor function (expanded-specification products ( pd78f116xa) only) a temperature sensor performs a/d conversion for two vo ltages, an internal reference voltage (sensor 0 on the ani0 side) that depends on the temperature and an internal reference voltage (sensor 1 on the ani1 side) that does not depend on the temperature, and calc ulations, so that the temperature is obtained without depending on the av ref0 voltage (av ref0 2.7 v). caution the temperature sensor cannot be used when low current consum ption mode is set (rmc = 5ah) or when the internal high-speed oscillator h as been stopped (hiostop = 1 (bit 0 of csc register)). the temperature sen sor can operate as long as the internal high-speed oscillator operates (hiostop = 0), even if it is not selected as the cpu/peripheral hardware clock source. 11.5.1 configuration of temperature sensor the temperature sensor consists of an a/ d converter and the following hardware. ? temperature sensor 0: outputs the internal reference voltage that d epends on the temperature ? temperature sensor 1: outputs the internal refe rence voltage that does not depend on the temperature figure 11-15. temperatur e sensor block diagram intad adcs fr2 fr1 adce fr0 sample & hold circuit av ss voltage comparator a/d converter mode register ( adm) internal bus 4 analog input channel specification register (ads) selector (analog input for normal use of a/d converter) ani0/p20 temperature sensor 0 controller a/d conversion result register (adcr) successive approximation register (sar) lv1 lv0 5 ads3 ads2 ads1 ads0 adiss av ref0 av ss adcs bit tap selector ani1/p21 selector selector temperature sensor 1 (analog input for normal use of a/d converter) chapter 11 a/d converter user?s manual u17894ej8v0ud 365 11.5.2 registers used by temperature sensors the following four types of registers are used when using a temperature sensor. ? peripheral enable register 0 (per0) ? a/d converter mode register (adm) ? analog input channel specification register (ads) ? 10-bit a/d conversion result register (adcr) caution setting of the a/d port configuration regist er (adpc), port mode register 2 (pm2) and port register 2 (p2) is not required when using the temperature sensor. there is no problem if the pin function is set as digital i/o. (1) peripheral enable register 0 (per0) use the per0 register in the same manner as during a/d converter basic operation (see 11.3 (1) peripheral enable register 0 (per0) ). (2) a/d converter mode register (adm) use the adm register in the same manner as during a/d converter basic operation (see 11.3 (2) a/d converter mode register (adm) ). however, selection of the a/d conversion time when a temperature sensor is used varies as shown in table 11- 5. table 11-5. selection of a/d conversi on time when using temperature sensor (1) 2.7 v av ref0 5.5 v a/d converter mode register (adm) conversion time selection fr2 fr1 fr0 lv1 lv0 f clk = 2 mhz f clk = 8 mhz f clk = 20 mhz conversion clock (f ad ) 0 0 0 0 1 480/f clk 60.0 s 24.0 s f clk /12 0 0 1 0 1 320/f clk 40.0 s f clk /8 0 1 0 0 1 240/f clk 30.0 s f clk /6 0 1 1 0 1 160/f clk setting prohibited f clk /4 1 0 0 0 1 120/f clk 60.0 s f clk /3 1 0 1 0 1 80/f clk 40.0 s f clk /2 1 1 1 0 1 40/f clk setting prohibited setting prohibited setting prohibited f clk other than above setting prohibited cautions 1. set the conversion times so as to satisfy the following condition. f ad = 0.6 to 1.8 mhz 2. when rewriting fr2 to fr0, lv1, and lv0 to other than the same da ta, stop a/d conversion (adcs = 0) beforehand. 3. the above conversion time does not include cl ock frequency errors. select conversion time, taking clock frequency erro rs into consideration. remark f clk : cpu/peripheral hardware clock frequency chapter 11 a/d converter user?s manual u17894ej8v0ud 366 (3) 10-bit a/d conversion r esult register (adcr) use the adcr register in the same manner as during a/d converter basic operation (see 11.3 (3) 10-bit a/d conversion result register (adcr) ). caution when using a temperature sensor, use the result of the second or later a/d conversion for temperature sensor 0 (ani0 side), and the resu lt of the third or later a/d conversion for temperature sensor 1 (ani1 side). (4) analog input channel specification register (ads) this register specifies the channel from which an analog voltage to be a/d-converted is input, in the same manner as during a/d converter basic operation. when a temperature sensor is used, however, some settings differ from those of a/d converter basic operation. ads can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clea rs this register to 00h. figure 11-16. format of analog input channel specification register (ads ) when using temperature sensor address: fff31h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 ads adiss 0 0 0 ads3 ads2 ads1 ads0 adiss ads3 ads2 ads1 ads0 analog input channel input source 1 0 0 0 0 ani0 temperature sensor 0 output 1 0 0 0 1 ani1 temperature sensor 1 output other than above setting prohibited caution be sure to clea r bits 4 to 6 to ?0?. chapter 11 a/d converter user?s manual u17894ej8v0ud 367 11.5.3 temperature sensor operation (1) temperature sensor detection value when using a temperature sensor, dete rmine as reference temperatures tw o points of temperature (high and low) in the temperature range to be used, and measure the resu lt of a/d conversion with temperature sensors 0 and 1 at each reference temperature in advance. pe rform the measurement in the same environment as the one in which the temperature sensor is used in a set. by using an expression of temperatur e sensor detection value characteri stics, which are obtained from the values of high and low reference temperatures and the re sult of a/d conversion with temperature sensors 0 and 1 at an arbitrary temperature, the te mperature at that time can be obtained. remark the value obtained from the ratio of the results of a/d conversion with a sensor that depends/does not depend on temperature is called a ?t emperature sensor detection value?. ? sensor that depends on temperature conversion channel: temperature sensor 0 (ani0 side) a/d conversion result: adt0 ? sensor that does not depend on temperature conversion channel: temperature sensor 1 (ani1 side) a/d conversion result: adt1 ? temperature sensor detection value = ktv = adt0 adt1 256 the characteristics (reference value) of the temp erature sensor detection value are as follows. figure 11-17. characteristics of temperatur e sensor detection value (reference value) characteristics of temperat ure sensor detection value 50 60 70 80 90 100 110 120 130 ? 40 ?c 25 ?c 85 ?c temperature (t a ) temperature sensor detection value chapter 11 a/d converter user?s manual u17894ej8v0ud 368 (2) how to calculate temperature as shown in figure 11-17, the temperature sensor detect ion value makes a characteristics curve that is linear with respect to the temperature. t herefore, the temperature sensor detection value can be expressed with the following expressions. temperature sensor detection value ? tilt (t now ? t base1 ) + offset ktv now ? (ktv base2 ? ktv base1 ) (t base2 ? t base1 ) (t now ? t base1 ) + ktv base1 t base1 : low reference temperature, t base2 : high reference temperature t now : temperature during sensor operation ktv base1 : temperature sensor detection valu e at a low reference temperature ktv base2 : temperature sensor detection valu e at a high reference temperature ktv now : temperature sensor detection va lue during temperature measurement when adt0 base1 : result of a/d conversion (sensor 0) at a low reference temperature adt1 base1 : result of a/d conversion (sensor 1) at a low reference temperature adt0 base2 : result of a/d conversion (sensor 0) at a high reference temperature adt1 base2 : result of a/d conversion (sensor 1) at a high reference temperature adt0 now : result of a/d conversion (sensor 0) during temperature measurement adt1 now : result of a/d conversion (sensor 1) during temperature measurement ktv base1 , ktv base2 , and ktv now are obtained as follows. ktv base1 = adt0 base1 adt1 base1 256 ktv base2 = adt0 base2 adt1 base2 256 ktv now = adt0 now adt1 now 256 thus, temperature t now is obtained by using the following expressions. t now ? (ktv now ? ktv base1 ) (t base2 ? t base1 ) (ktv base2 ? ktv base1 ) + t base1 adt1 base2 (adt1 base1 adt0 now ? adt0 base1 adt1 now ) (t base2 ? t base1 ) t now ? adt1 now (adt1 base1 adt0 base2 ? adt0 base1 adt1 base2 ) + t base1 remarks 1. when obtaining a temperature through calculat ion, it is recommended to determine the upper and lower end of the temperature r ange as the reference temperatures for measurement. 2. in addition to calculation, temperature t now can also be obtained by measuring the temperature sensor detection values at each temperature in advance, preparing them as table data, and comparing them with the te mperature sensor detection value during temperature measurement. with this method, table data must be created for each interval of temperatures to be detected. chapter 11 a/d converter user?s manual u17894ej8v0ud 369 11.5.4 procedures for usin g temperature sensors (1) procedure for usin g temperature sensors <1> perform the following steps in the same environmen t as the one in which the te mperature sensor is used in a set ? when obtaining a temperature through calculation determine as reference temperatures two points of temperature (high and low) in the temperature range to be used, and measure the result of a/d conversion with temperature sensors 0 and 1 at the reference temperature in advance, before shipment of the set. ? when obtaining a temperature through table reference measure the temperature sensor detection values at each temper ature in advance, and prepare them as table data. store the above values into the internal flash me mory area by means such as writing them via self programming, or store them into an external memory. remark when obtaining the temperature through calcul ation and the result of a/d conversion by temperature sensors 0 and 1 at a high and low temperature, it is recommended to determine the upper and lower end of t he temperature range as the reference temperatures for measurement. <2> to obtain a temperature, perform a/d conversion for the voltage output from temperature sensors 0 and 1 and calculation by using the expression based on adt0 and adt1, or calculate the temperature sensor detection value and compare it with table data prepared in advance. (2) procedure for obtaining adt0 and adt1 of temperature sensors 0 and 1 (adt0 base1 , adt1 base1 , adt0 base2 and adt1 base2 at reference temperatures, adt0 now and adt1 now during temperature measurement) chapter 11 a/d converter user?s manual u17894ej8v0ud 370 chapter 11 a/d converter user?s manual u17894ej8v0ud 371 figure 11-18. flowchart of proce dure for using temperature sensor adcen of per0 register = 1 start end no intad occurred? starts the supply of the input clock to a/d converter <1> <2> <3> <4> <5> <6> <7> <8> <9> <10> <11> <12> <13> <14> <15> <16> <17> starts the operation of the comparator sets conversion time select temperature sensor 0 as input source yes no intad occurred? yes adce of adm register = 1 starts a/d conversion operation first a/d conversion first a/d conversion second a/d conversion third a/d conversion second a/d conversion read a/d conversion result (adt0) adcs of adm register = 1 stops a/d conversion operation adcs = 0 stops the operation of the comparator adce = 0 stops the supply of the input clock to a/d converter adcen = 0 read adcr register adm 00xxx011b ads 80h no intad occurred? select temperature sensor 1 as input source yes no intad occurred? yes no intad occurred? yes read a/d conversion result (adt1) read adcr register obtain the current temperature (t now ) by calculation (see 11.5.3 (2) ) or table reference ads 81h caution use the result of the second or later a/d conversion for temperature sensor 0 (ani0 side), and the result of the third or later a/d con version for temperature sensor 1 (ani1 side). remark steps <1> to <17> in figure 11-18 correspond to steps <1> to <17> in 11.5.4 (2) procedure for obtaining adt0 and adt1 of temperature sensors 0 and 1 . chapter 11 a/d converter user?s manual u17894ej8v0ud 372 11.6 how to read a/d converter characteristics table here, special terms unique to the a/d converter are explained. (1) resolution this is the minimum analog input vo ltage that can be identif ied. that is, the perce ntage of the analog input voltage per bit of digital output is called 1lsb (least si gnificant bit). the percentage of 1lsb with respect to the full scale is expressed by %fsr (full scale range). 1lsb is as follows when the resolution is 10 bits. 1lsb = 1/2 10 = 1/1024 = 0.098%fsr accuracy has no relation to resolution, but is determined by overall error. (2) overall error this shows the maximum error value between the actual measured value and the theoretical value. zero-scale error, full-scale error, integral linearity error, and differential linearity errors that are combinations of these express the overall error. note that the quantization error is not included in the overall erro r in the characteristics table. (3) quantization error when analog values are converted to digital values, a 1/2lsb error naturally occurs. in an a/d converter, an analog input voltage in a range of 1/2lsb is converted to the same digita l code, so a quantization error cannot be avoided. note that the quantization erro r is not included in the overall error, zero -scale error, full-scale error, integral linearity error, and differential linearity error in the characteristics table. figure 11-19. overall error fi gure 11-20. quantization error ideal line 0 ...... 0 1 ...... 1 digital output overall error analog input av ref0 0 0......0 1 ...... 1 digital output quantization error 1/2lsb 1/2lsb analog input 0 av ref0 (4) zero-scale error this shows the difference between the actual measuremen t value of the analog input vo ltage and the theoretical value (1/2lsb) when the digital output changes from 0......000 to 0......001. if the actual measurement value is greater than the theore tical value, it shows the difference between the actual measurement value of the analog in put voltage and the theoretical val ue (3/2lsb) when the digital output changes from 0??001 to 0??010. chapter 11 a/d converter user?s manual u17894ej8v0ud 373 (5) full-scale error this shows the difference between the actual measuremen t value of the analog input vo ltage and the theoretical value (full-scale ? 3/2lsb) when the digital output chan ges from 1......110 to 1......111. (6) integral linearity error this shows the degree to which the conversion charac teristics deviate from the ideal linear relationship. it expresses the maximum value of the di fference between the actual measurement value and the ideal straight line when the zero-scale error and full-scale error are 0. (7) differential linearity error while the ideal width of code output is 1lsb, this indi cates the difference between the actual measurement value and the ideal value. figure 11-21. zero-scale error figure 11-22. full-scale error 111 011 010 001 zero-scale error ideal line 000 01 2 3 av ref0 digital output (lower 3 bits) analog input (lsb) 111 110 101 000 0 av ref0 ? 3 full-scale error ideal line analog input (lsb) digital output (lower 3 bits) av ref0 ? 2av ref0 ? 1 av ref0 figure 11-23. integral linearity error figure 11-24. differential linearity error 0 av ref0 digital output analog input integral linearity error ideal line 1 ...... 1 0 ...... 0 0 av ref0 digital output analog input differential linearity error 1 ...... 1 0 ...... 0 ideal 1lsb width (8) conversion time this expresses the time from the start of samp ling to when the digital output is obtained. the sampling time is included in the conv ersion time in the characteristics table. (9) sampling time this is the time the analog switch is turned on for the anal og voltage to be sampled by the sample & hold circuit. sampling time conversion time chapter 11 a/d converter user?s manual u17894ej8v0ud 374 11.7 cautions for a/d converter (1) operating current in stop mode the a/d converter stops operating in the stop mode. at this time, th e operating current can be reduced by clearing bit 7 (adcs) and bit 0 (adce) of the a/d converter mode register (adm) to 0. to restart from the standby status, clear bit 0 (adif) of interrupt request flag register 1l (if1l) to 0 and start operation. (2) reducing current when a/d converter is stopped be sure that the voltage to be applied to av ref0 normally satisfies the conditions stated in table 11-1. if bit 7 (adcs) and bit 0 (adce) of the a/d converter mo de register (adm) are set to 0, the current will not be increased by the a/d converter ev en if a voltage is applied to av ref0 , while the a/d converter is stopped. if a current flows from the power supply that supplies a voltage to av ref0 to an external circuit of the microcontroller as shown in figure 11-25, av ref0 = 0 v = av ss can be achieved and the external current can be reduced by satisfying the following conditions. set the following states before setting av ref0 = 0 v. ? set adcs and adce of the a/d converter mode register (adm) to 0. ? set the port mode registers (pm20 to pm27 and pm150 to pm157) of the digi tal i/o pins to 1 to set to input mode, or set the digital i/o pins to low-level output (high-level output disabled) by setting the port mode registers (pm20 to pm27 and pm150 to pm157) and port registers (p20 to p27 and p150 to p157) to 0 to set to output mode. ? make sure that no voltage is appli ed to all any of the ana log or digital pins (p20/ani0 to p27/ani7 and p150/ani8 to p157/ani15) (set to 0 v). do not perform the following operation when av ref0 = 0 v. ? do not access the port registers (p20 to p27 and p150 to p157) or port mode registers (pm20 to pm27 and pm150 to pm157) by using instructions or via dma transfer. figure 11-25. example of circuit wher e current flows to external circuit av ref0 ani0 to ani15 current flowing from power supply supplying voltage to av ref0 to external circuit when restarting the a/d conver ter, operate it after the av ref0 voltage rises and stabilizes and setting adce = 1 (see 11.4.1 basic operations of a/d converter for the procedure for setting the a/d converter operation). access digital ports after the av ref0 voltage has risen and stabilized. chapter 11 a/d converter user?s manual u17894ej8v0ud 375 (3) input range of ani0 to ani15 observe the rated range of the ani0 to ani15 input voltage. if a voltage of av ref0 or higher and av ss or lower (even in the range of absolute maximum ratings) is input to an analog input channel, the converted value of that channel becomes undefined. in addition, the converted values of the other channels may also be affected. (4) conflicting operations <1> conflict between a/d conversion result regist er (adcr, adcrh) write and adcr or adcrh read by instruction upon the end of conversion adcr or adcrh read has priority. after the read op eration, the new co nversion result is written to adcr or adcrh. <2> conflict between adcr or adcrh write and a/d converter mode regi ster (adm) write, analog input channel specification register (ads), or a/d port configuration register (a dpc) write upon the end of conversion adm, ads, or adpc write has priority. adcr or adcrh write is not performed, nor is the conversion end interrupt signal (intad) generated. (5) noise countermeasures to maintain the 10-bit resolution, attent ion must be paid to noise input to the av ref0 pin and pins ani0 to 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 11-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. chapter 11 a/d converter user?s manual u17894ej8v0ud 376 figure 11-26. 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 ref0 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 ref0 av ss v ss ani0 to ani15 (6) ani0/p20 to ani7/p27 a nd ani8/p150 to ani15/p157 <1> the analog input pins (ani0 to ani7) are also used as input port pins (p20 to p27). the analog input pins (ani8 to ani15) are al so used as input port pins (p150 to p157). when a/d conversion is performed with any of ani0 to ani15 selected, do not access p20 to p27 and p150 to p157 while conversion is in progress; otherwis e the conversion resolution may be degraded. it is recommended to select pins used as p20 to p27 and p150 to p157 starting with t he ani0/p20 that is the furthest from av ref0 . <2> if a digital pulse is applied to the pins adjacent to t he pins currently used for a/ d conversion, the expected value of the a/d conversion may not be obtained due to coupling noise. t herefore, do not apply a pulse to the pins adjacent to the pi n undergoing a/d conversion. (7) input impedance of ani0 to ani15 pins this a/d converter charges a sampling capacitor for sampling during sampling time. therefore, only a leakage current fl ows when sampling is not in progre ss, and a current that charges the capacitor flows during sampling. consequently, the input impedance 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 10 k , and to connect a capacitor of about 100 pf to the ani0 to ani15 pins (see figure 11-26 ). (8) av ref0 pin input impedance a series resistor string of several tens of k is connected between the av ref0 and av ss pins. therefore, if the output impedance of t he reference voltage source is high, this will result in a series connection to the series resistor string between the av ref0 and av ss pins, resulting in a large reference voltage error. chapter 11 a/d converter user?s manual u17894ej8v0ud 377 (9) interrupt request flag (adif) the interrupt request flag (adif) is not cleared even if th e analog input channel specification register (ads) is changed. therefore, if an analog input pin is changed during a/d conversion, the a/d conversion result and adif for the pre-change analog input may be set just before the ads rewrit e. caution is therefore re quired since, at this time, when adif is read immediately after the ads rewrite, ad if is set despite the fact a/d conversion for the post- change analog input has not ended. when a/d conversion is stopped and then resumed, clear ad if before the a/d conversion operation is resumed. figure 11-27. timing of a/d conver sion end interrupt request generation ads rewrite (start of anin conversion) a/d conversion adcr adif anin anin anim anim anin anin anim anim ads rewrite (start of anim conversion) adif is set but anim conversion has not ended. remarks 1. n = 0 to 15 2. m = 0 to 15 (10) conversion results just after a/d conversion start the first a/d conversion value immediately after a/d conv ersion starts may not fall wit hin the rating range if the adcs bit is set to 1 within 1 s after the adce bit was set to 1. take measures such as polling the a/d conversion end interrupt request (intad) and removing the first conversion result. (11) a/d conversion result regist er (adcr, adcrh) read operation when a write operation is performed to the a/d conver ter mode register (adm), analog input channel specification register (ads), and a/ d port configuration register (adp c), the contents of adcr and adcrh may become undefined. read the conversion re sult following conversion completion before writing to adm, ads, and adpc. using a timing other than the above may cause an incorrect conversion result to be read. chapter 11 a/d converter user?s manual u17894ej8v0ud 378 (12) internal equivalent circuit the equivalent circuit of the analog input block is shown below. figure 11-28. internal equi valent circuit of anin pin anin c1 c2 r1 table 11-6. resistance and capacitance valu es of equivalent circui t (reference values) av ref0 r1 c1 c2 4.0 v v dd 5.5 v 8.1 k 8 pf 5 pf 2.7 v v dd < 4.0 v 31 k 8 pf 5 pf 2.3 v v dd < 2.7 v 381 k 8 pf 5 pf remarks 1. the resistance and capacitance values shown in table 11-6 are not guaranteed values. 2. n = 0 to 15 user?s manual u17894ej8v0ud 379 chapter 12 d/a converter 12.1 function of d/a converter the d/a converter has a resolution of 8 bits and conver ts an input digital signal into an analog signal. it is configured so that output analog signals of two channels (ano0 and ano1) can be controlled. the d/a converter has the following features. { 8-bit resolution 2 channels { r-2r ladder method { output analog voltage: av ref1 m/256 (av ref1 : reference voltage for d/a converter, m: value set to dacsn register) { operation mode: normal mode/real-time output mode remark n = 0, 1 12.2 configuration of d/a converter the configuration of the d/ a converter is shown below. figure 12-1. block diag ram of d/a converter 8-bit d/a conversion value setting register 1 (dacs1) write signal of dacs0 register damd0 of dam register inttm04 signal 8-bit d/a conversion value setting register 0 (dacs0) dace0 of dam register av ref1 pin av ss pin selector selector ano0/p110 pin ano1/p111 pin dace1 of dam register write signal of dacs1 register damd1 of dam register inttm05 signal remarks 1 . inttm04 and inttm05 are timer trigger signals (interr upt signals from timer channels 4 and 5) that are used in the real-time output mode. 2. channel 0 and channel 1 of the d/a converter share the av ref1 pin. 3. channel 0 and channel 1 of t he d/a converter share the av ss pin. the av ss pin is also shared with the a/d converter. chapter 12 d/a converter user?s manual u17894ej8v0ud 380 the d/a converter includes the following hardware. table 12-1. configuration of d/a converter item configuration control registers peripheral enable register 0 (per0) d/a converter mode register (dam) 8-bit d/a conversion value setting registers 0, 1 (dacs0, dacs1) (1) av ref1 pin this is the d/a converter reference voltage input pin and the positive power supply pin of p110, p111, and the d/a converter. the voltage that can be supplied to av ref1 varies as follows, depending on whether the p110/ano0 and p111/ano1 pins are used as digital i/os or analog outputs. table 12-2. av ref1 voltage applied to p110/ano0 and p111/ano1 pins analog/digital v dd condition av ref1 voltage using at least one pin as an analog output and using all pins not as digital i/os 1.8 v v dd 5.5 v 1.8 v av ref1 v dd = ev dd0 = ev dd1 2.7 v v dd 5.5 v 2.7 v av ref1 v dd = ev dd0 = ev dd1 pins used as analog outputs and digital i/os are mixed note 1.8 v v dd < 2.7 v av ref1 has same potential as ev dd0 , ev dd1 , and v dd 2.7 v v dd 5.5 v 2.7 v av ref1 v dd = ev dd0 = ev dd1 using at least one pin as a digital i/o and using all pins not as analog outputs note 1.8 v v dd < 2.7 v av ref1 has same potential as ev dd0 , ev dd1 , and v dd note av ref1 is the reference for the i/o voltage of a port to be used as a digital port. ? high-/low-level input voltage (v ih5 /v il5 ) ? high-/low-level output voltage (v oh2 /v ol2 ) chapter 12 d/a converter user?s manual u17894ej8v0ud 381 12.3 registers used in d/a converter the d/a converter uses the following registers. ? peripheral enable register 0 (per0) ? d/a converter mode register (dam) ? 8-bit d/a conversion value setting registers 0, 1 (dacs0, dacs1) ? port mode register 11 (pm11) ? port register 11 (p11) (1) peripheral enable register 0 (per0) per0 is used to enable or disable use of each peripher al hardware macro. clock supply to a hardware macro that is not used is stopped in order to reduce 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. 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 iic0en sau1en sau0en 0 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. cautions 1. when setting the d/a c onverter, be sure to set dacen to 1 first. if dacen = 0, writing to a control register of the d/a converter is ignored , and, even if the register is read, only the default value is read (except for port mode re gister 11 (pm11) and port register 11 (p11)). 2. be sure to clear bit 1 of the per0 register to 0. chapter 12 d/a converter user?s manual u17894ej8v0ud 382 (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 12-3. format of d/a converter mode register (dam) address: fff32h after reset: 00h r/w symbol 7 6 <5> <4> 3 2 1 0 dam 0 0 dace1 dace0 0 0 damd1 damd0 dacen control of d/a conversion operation (n = 0, 1) 0 stops conversion operation 1 enables conversion operation damdn selection of d/a converter operation mode (n = 0, 1) 0 normal mode 1 real-time output mode (3) 8-bit d/a conversion value setting registers 0 and 1 (dacs0, dacs1) these registers are used to set an analog voltage value to be output to the ano0 and ano1 pins. dacs0 and dacs1 can be read by an 8- bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 12-4. format of 8-bit d/a conversion value setting registers 0 and 1 (dacs0, dacs1) address: fff1ch, fff1dh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 dacsn dacsn7 dacsn6 dacsn5 dacs n4 dacsn3 dacsn2 dacsn1 dacsn0 remark n = 0, 1 chapter 12 d/a converter user?s manual u17894ej8v0ud 383 (4) port mode register 11 (pm11) this register sets the input or output of port 11 in 1-bit units. when using the p110/ano0 and p111/ano1 pins as the anal og output function of the d/a converter, set both pm110 and pm111 to 1. the output latches of p110 and p111 at this time may be 0 or 1. pm11 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation sets this register to ffh. figure 12-5. format of port mode register 11 (pm11) address: fff2bh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm11 1 1 1 1 1 1 pm111 pm110 pm11n p11n pin i/o mode selection (n = 0, 1) 0 output mode (output buffer on) 1 input mode (output buffer off) chapter 12 d/a converter user?s manual u17894ej8v0ud 384 12.4 operation of d/a converter 12.4.1 operation in normal mode d/a conversion is performed using writ e operation to the dacsn register as the trigger. the setting method is described below. <1> set the damdn bit of the dam register to 0 (normal mode). <2> set the analog voltage value to be output to the anon pin to the dacsn register. steps <1> and <2> above constitute the initial settings. <3> set the dacen bit of the dam regi ster to 1 (d/a conversion enable). d/a conversion starts and the analog voltage set in <2> is output to the anon pin when this setting is performed. the output level, however, is determined when the settling time el apses after d/a conversion starts. <4> to perform subsequent d/a conversi ons, write to the dacsn register. d/a conversion starts and an analog volta ge is output to the anon pin when one f clk clock elapses after the write operation. the output level, however, is determined when the se ttling time elapses after d/a conversion starts. 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 ), analog voltage output is stopped, and the p110/ano0 and p111/ano1 pins can be used in port mode. at this time, the p110/ano0 and p111/ano1 pins are at high impe dance because the pm11n bit of the pm11 register is 1 (input mode). the set value of the p11 regi ster is output by setting the pm11n bit to 0 (output mode). caution make the interval for writing dacsn of the same channe l by one clock longer than f clk . if writing is successively performed, only the value written last will be converted. remarks 1. n = 0, 1 2. f clk : cpu/peripheral hardware clock chapter 12 d/a converter user?s manual u17894ej8v0ud 385 12.4.2 operation in real-time output mode d/a conversion is performed using the interrupt r equest signals (inttm04 and inttm05) of timer channel 4 and timer channel 5 as triggers. the setting method is described below. <1> set the damdn bit of the dam r egister to 1 (real-time output mode). <2> set the analog voltage value to be outpu t to the anon pin to the dacsn register. <3> set the dacen bit of the dam regi ster to 1 (d/a conversion enable). steps <1> to <3> above constitute the initial settings. <4> operate timer channel 4 and timer channel 5. <5> d/a conversion starts and the analog voltage set in <2> is output to the anon pin when the inttm04 and inttm05 signals are generated. the output level, however, is determined when the settling time el apses after d/a conversion starts. <6> after that, the value set in the dacsn register is output every time the inttm04 and inttm05 signals are generated. set the analog voltage value to be output to the anon pin to the dacsn regi ster before t he next d/a conversion is started (inttm04 and inttm05 signals are generated). when the dacen bit of the dam register is set to 0 (d/a conversion operation stop ), analog voltage output is stopped, and the p110/ano0 and p111/ano1 pins can be used in port mode. at this time, the p110/ano0 and p111/ano1 pins are at high impe dance because the pm11n bit of the pm11 register is 1 (input mode). the set value of the p11 regi ster is output by setting the pm11n bit to 0 (output mode). d/a conversion starts by setting the dacen bit, as describ ed in <3>, and an analog voltage is output to the anon pin, but the output value of t he anon pin up to <5> is undefined. an arbitrary value, however, can be output in <3> by performing the following settings before performing the setting in <1>. i. set the damdn bit of the dam register to 0 (normal mode). ii. set the voltage value output from the anon pin in <3> to the dacsn register. iii. afterward, perform <1> to <3>. consequently, the value set in ii can be output in <3 >. the output level, how ever, is determined when the settling time elapses after d/a conversion starts. cautions 1. make the interval for generating a start trigger to the sam e channel by one clock longer than f clk . if a start trigger is successively generated for every f clk , d/a conversion will be performed only at the first trigger. 2. note the following points in the procedure (i to iii) for outputting an arbitrary value in <3>. ? do not generate the start trigger of th e real-time output mode before enabling d/a conversion operation in <3> after the value is set to the dacsn register in ii. ? an arbitrary value cannot be output in <3> if the dacen bit of the per0 register is cleared once after the value is set to the dacsn register in ii. remarks 1. for the output values of the ano0 and ano1 pins in the halt and stop modes, see chapter 19 standby function . 2. n = 0, 1 3. f clk : cpu/peripheral hardware clock chapter 12 d/a converter user?s manual u17894ej8v0ud 386 12.4.3 cautions observe the following cautions when usi ng the d/a converter of the 78k0r/kg3. (1) the digital port i/o function, which is the alternate function of the ano0 and ano1 pi ns, does not operate during d/a conversion. when the p11 register is read during d/a conversion, 0 is read in input mode and the set value of the p11 register is read in output mode. if the digital out put mode is set, no output data is output to pins. (2) do not read/write the p11 register and do not change the setting of the pm11 register during d/a conversion (otherwise the conversion accuracy may decrease). (3) it is recommended that both the ano0 and ano1 pins be us ed as analog output pins or digital i/o pins, that is, use these two channels for the same application (if t hese pins are used for the different applications, the conversion accuracy may decrease). (4) in the real-time output mode, set the dacsn register value before the timer tr igger is generated. in addition, do not change the set value of the dacsn register while the trigger signal is output. (5) before changing the operation mode, be sure to clear the dacen bit of the dam register to 0 (d/a conversion stop). (6) when using the port that functions al ternately as the ano0 or ano1 pin, use it as the port input with few level changes. (7) apply power to av ref1 at the same timing as av ref0 (a/d converter reference voltage). (8) because the d/a converter stops operation in the stop mode, the ano0 and ano1 pins go into a high- impedance state, and the power consumption can be reduced. in the standby modes other than t he stop mode, however, the operation continues. to lower the power consumption, therefore, clear t he dacen bit of the dam register to 0 (d/a conversion stop). (9) since the output impedance of the d/ a converter is high, the current cannot be obtained from the anon pin (n = 0, 1). when the input impedance of t he load is low, insert a follower am plifier between the load and anon pin keeping the wiring length as short as possible (for hi gh impedance). if the wiring becomes too long, take necessary actions such as surrounding with a ground pattern. user?s manual u17894ej8v0ud 387 chapter 13 serial array unit the serial array unit has four serial channels per unit and can use 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/kg3 is as s hown below (channels 2 and 3 of unit 1 are dedicated to uart3 (supporting lin-bus)). 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 chann els 0 and 1 of unit 0, csi00 and csi01 cannot be used, but csi10, uart1, or iic10 can be used. 13.1 functions of serial array unit each serial interface supported by the 78k0r/kg3 has the following features. 13.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 chapter 13 serial array unit user?s manual u17894ej8v0ud 388 13.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 asynchr onization with the party of communication (by using an internal baud rate). full-duplex uart communication ca n 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 389 13.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 communicati on with a device such as eeprom, flash memory, or a/d converter, and ther efore, it functions only as a master and does not have a function to detect wait states. make sure by using software, as well as operating the control regist ers, 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, the 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 writi ng 0 to the soemn (soem register) bit and stopping the output of serial communication data. see 13.7.3 (2) processing flow for details. remarks 1. to use the full-function i 2 c bus, see chapter 14 serial interface iic0 . 2. m: unit number (m = 0, 1), n: channel number (n = 0, 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 390 13.2 configuration of serial array unit serial array unit includes the following hardware. table 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 391 figure 13-1 shows the block diagram of serial array unit 0. figure 13-1. block diagram of serial array unit 0 serial data input pin (when csi01: si01/p44) 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) serial output enable register 0 (soe0) serial clock i/o pin (when csi00: sck00 /p10/ex24) pm10 sau0en peripheral enable register 0 (per0) serial data input pin (when csi00: si00/ p11/rxd0/ex25) (when uart0: rxd0/ p11/si00/ex25) serial mode register 00 (smr00) serial channel enable status register 0 (se0) serial channel stop register 0 (st0) 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/ p03/rxd1/sda10) (when iic10: sda10/ p03/rxd1/si10) (when uart1: rxd1/ p03/si10/sda10) serial data output pin (when csi10: so10/ p02/txd1) (when iic10: sda10/ p03/si10/rxd1) when (uart1: txd1/ p02/so10) 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 (p10) serial clock i/o pin (when csi10: sck10/ p04/scl10) (when iic10: scl10/ p04/sck10) serial transfer error interrupt (intsre0) serial transfer end interrupt (when uart1: intsr1) serial transfer error interrupt (intsre1) serial data output pin (when csi01: so01/p45) serial clock i/o pin (when csi01: sck01/p43) ck01 ck00 ck01 ck00 ck01 ck00 noise filter enable register 0 (nfen0) noise elimination enabled/ disabled snfen00 edge/level detection selector when uart0 edge/level detection edge/level detection noise elimination enabled/ disabled snfen10 when uart1 pm12 output latch (p12) serial output level register 0 (sol0) error controller error controller selector clock controller selector communication status prescaler 0 soe02 soe01 soe00 se03 se02 se01 se00 st03 st02 st01 st00 ss03 ss02 ss01 ss00 snfen 10 snfen 00 0 sol02 0 sol00 1 1 cko02 cko01 cko00 so02 so01 so00 0 0 00 0 0 00 serial data output pin (when csi00: so00/ p12/txd0/ex26) (whe uart0: txd0/ p12/so00/ex26) chapter 13 serial array unit user?s manual u17894ej8v0ud 392 figure 13-2 shows the block diagram of serial array unit 1. figure 13-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/ p144/txd2) (when iic20: sda20/ p143/si20/rxd2) (when uart2: txd2/ p144/so20) 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: txd3/p13/ex27) serial transfer end interrupt (when uart3: intst3) ck11 ck10 ck11 ck10 ck11 ck10 edge detection serial clock i/o pin (when csi20: sck20/ p142/scl20) (when iic20: scl20/ p142/sck20) pm142 sck output latch (p142) edge/level detection serial data input pin (when csi20: si20/ p143/rxd2/sda20) (when iic20: sda20/ p143/rxd2/si20) (when uart2: rxd2/ p143/si20/sda20) noise elimination enabled/ disabled snfen20 noise filter enable register 0 (nfen0) edge/level detection serial data input pin (when uart3: rxd3/p14/ex28) snfen30 when uart3 edge/level detection when uart2 noise elimination enabled/ disabled pm144 or pm143 output latch ( p144 or p143) serial output enable register 1 (soe1) serial channel enable status register 1 (se1) serial channel stop register 1 (st1) serial channel start register 1 (ss1) serial output level register 1 (sol1) error controller error controller selector clock controller selector communication status inttm03 prescaler snfen 30 snfen 20 0 soe12 0 soe10 se13 se12 se11 se10 st13 st12 st11 st10 ss13 ss12 ss11 ss10 0 sol12 0 sol10 1 1 1 1 cko10 so12 1 so10 0 0 00 0 0 00 chapter 13 serial array unit user?s manual u17894ej8v0ud 393 (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 converted 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 this register is as follows, depending on the setting of bits 0 to 2 (dlsmn0 to dlsmn2) of the scrmn register, r egardless of the output sequence 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). chapter 13 serial array unit user?s manual u17894ej8v0ud 394 figure 13-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 13.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) chapter 13 serial array unit user?s manual u17894ej8v0ud 395 13.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 0, 4, 14 (pim0, pim4, pim14) ? port output mode registers 0, 4, 14 (pom0, pom4, pom14) ? port mode registers 0, 1, 4, 14 (pm0, pm1, pm4, pm14) ? port registers 0, 1, 4, 14 (p0, p1, p4, p14) remark m: unit number (m = 0, 1) n: channel number (n = 0 to 3) chapter 13 serial array unit user?s manual u17894ej8v0ud 396 (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 reduce 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 13-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 iic0en sau1en sau0en 0 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. cautions 1. when setting serial array unit m, be sure to set saumen to 1 first. if saumen = 0, writing to a control register of serial array unit m is igno red, and, even if the register is read, only the default value is read (excep t for input switch control regist er (isc), noise filter enable register (nfen0), port input mode regist ers (pim0, pim4, pim14), port output mode registers (pom0, pom4, pom14), port mode registers (pm0, pm1, pm4, pm14), and port registers (p0, p1, p4, p14)). 2. after setting the per0 register to 1, be su re to set the spsm register after 4 or more clocks have elapsed. 3. be sure to clear bit 1 of the per0 register to 0. 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 opera tion clocks (ckm0, 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 397 figure 13-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) t he operation of the serial array unit (sau). when selecting inttm02 and inttm03 for the operation clock, also stop the timer array unit (tau) (tt0 = 00ffh). 2. sau can be operated at a fixed division rati o of the subsystem cloc k, 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 tau. when changing f clk , however, sau and tau 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 per0 register to 1, be su re 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 398 (3) serial mode register mn (smrmn) smrmn is a register that sets an oper ation mode of channel n. it is al so used to select an operation clock (mck), specify whether the serial clock (sck) may be inpu t or not, set a start trigger, an operation mode (csi, uart, or i 2 c), and an interrupt source. this register is also us ed 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 13-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 ck m0 set by prs register 1 prescaler output clock ck m1 set by prs 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 399 figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 400 (4) serial communication operati on setting register mn (scrmn) scrmn is a communication operation setting regi ster 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 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 401 figure 13-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 not using csi01 with eoc01 = 0, e rror 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 402 figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 403 (5) higher 7 bits of the seria l 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 cleared 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 13.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 on ly when the operation is st opped (semn = 0). during operation (semn = 1), a value is written only to the lower 8 bits of sdrmn. when sdrmn is read during operation, 0 is always read. reset signal generation clears this register to 0000h. figure 13-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. remarks 1. for the function of the lower 8 bits of sdrmn, see 13.2 configuration of serial array unit . 2. m: unit number (m = 0, 1) n: channel number (n = 0 to 3) fff11h (sdr00) fff10h (sdr00) chapter 13 serial array unit user?s manual u17894ej8v0ud 404 (6) serial status register mn (ssrmn) ssrmn is a register that indicates the communication status and error occurrence status of channel n. the errors indicated by this register are a fr aming 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 13-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 pef mn ovf mn 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. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 3) chapter 13 serial array unit user?s manual u17894ej8v0ud 405 figure 13-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 pef mn ovf mn fef mn framing error detecti on flag of channel n 0 no error occurs. 1 a framing error occurs during uart reception. chapter 13 serial array unit user?s manual u17894ej8v0ud 406 (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 regi ster is set to 1, the corresponding bit (fefmn, pefmn, ovfmn) of serial status register mn is cleared to 0. because 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 13-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), f014ch, f014dh (sir12), 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 407 (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 m (ss m), the corresponding bit of this register is set to 1. when 1 is written a bit of serial channel stop regi ster m (stm), the corresponding bit is cleared to 0. channel n that is enabled to operate cannot rewrite by software the value of ckomn of the serial output register m (som) to be described below, and a value reflec ted by a communication oper ation is output from the serial clock pin. channel n that stops operation can se t the value of ckomn of the som r egister by software and output its value from the serial clock pin. in this way, any wavefo rm, such as that of a start condition/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 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 408 (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 register (ssmn), the co rresponding 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 13-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. chapter 13 serial array unit user?s manual u17894ej8v0ud 409 (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 corresponding 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 13-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. chapter 13 serial array unit user?s manual u17894ej8v0ud 410 (11) serial output enable register m (soem) soem is a register that is used to enable or stop output of the serial communication operation of each channel. channel n that enables serial output ca nnot rewrite by software the value of somn of the serial output register m (som) to be described below, and a value reflected by a communication operation is output from the serial data output pin. for channel n, whose serial output is stopped, the somn valu e of the som register can be set by software, and that value can be output from the se rial 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 13-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 15 to 3 and 1 of soe1 to ?0?. remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), mn = 00 to 02, 10, 12 chapter 13 serial array unit user?s manual u17894ej8v0ud 411 (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 when serial output is disabled (soemn = 0). when serial output is enabled (soemn = 1), rewriting by softw are is ignored, 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), rewrit ing by software is ignored, and the value of ckomn can be changed only by a serial communication operation. to use the p02/so10/txd1, p03/si10/sda 10/rxd1, p04/sck10/scl10, p10/sck00/ex24, p12/so00/txd0/ex26, p13/txd3/ex27, p 43/sck01, p45/so01, p142/sck20/scl20, p143/si20/sda20/rxd2, or p144/so20/tx d2 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 13-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-02, 10, 12 chapter 13 serial array unit user?s manual u17894ej8v0ud 412 (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 13-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 and 1 to ?0?. remark m: unit number (m = 0, 1), n: channel number (n = 0, 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 413 (14) input switch control register (isc) isc is used to realize a lin-bus communication operatio n 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 13-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 0 0 0 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 2 to ?0?. chapter 13 serial array unit user?s manual u17894ej8v0ud 414 (15) noise filter enable register 0 (nfen0) nfen0 is used to set whether the noise filter can be used for the input sig nal 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 13-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/p14 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 p14 pin. snfen20 use of noise filter of r x d2/sda20/si20/p143 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 sda20, si20, and p143 pins. snfen10 use of noise filter of r x d1/sda10/si10/p03 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 sda10, si10, and p03 pins. snfen00 use of noise filter of r x d0/si00/p11 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 si00 and p11 pins. caution be sure to clear bits 7, 5, 3, and 1 to ?0?. chapter 13 serial array unit user?s manual u17894ej8v0ud 415 (16) port input mode registers 0, 4, 14 (pim0, pim4, pim14) these registers set the input buffer of ports 0, 4, and 14 in 1-bit units. pim0, pim4, and pim14 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 13-19. format of port input mode re gisters 0, 4, and 14 (pim0, pim4, pim14) address f0040h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 pim0 0 0 0 pim04 pim03 0 0 0 address f0044h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 pim4 0 0 0 pim44 pim43 0 0 0 address f004eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 pim14 0 0 0 0 pim143 pim142 0 0 pimmn pmn pin input buffer selection (m = 0, 4, 14; n = 2 to 4) 0 normal input buffer 1 ttl input buffer (17) port output mode registers 0, 4, 14 (pom0, pom4, pom14) these registers set the output mode of ports 0, 4, and 14 in 1-bit units. pom0, pom4, and pom14 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation clears these registers to 00h. figure 13-20. format of port output mode re gisters 0, 4, and 14 (pom0, pom4, pom14) address f0050h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 pom0 0 0 0 pom04 pom03 pom02 0 0 address f0054h after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 pom4 0 0 pom45 0 pom43 0 0 0 address f005eh after reset: 00h r/w symbol 7 6 5 4 3 2 1 0 pom14 0 0 0 pom144 pom143 pom142 0 0 pommn pmn pin output buffer selection (m = 0, 4, 14; n = 2 to 5) 0 normal output mode 1 n-ch open-drain output (v dd tolerance) mode chapter 13 serial array unit user?s manual u17894ej8v0ud 416 (18) port mode registers 0, 1, 4, 14 (pm0, pm1, pm4, pm14) these registers set input/output of ports 0, 1, 4 and 14 in 1-bit units. when using the p02/so10/t x d1, p03/si10/r x d1/sda10, p04/sck10/scl10, p10/sck00/ex24, p12/so00/t x d0/ex26, p13/t x d3/ex27, p43/sck01, p 45/so01, p142/sck20/scl20, p143/si20/r x d2/sda20, and p144/so20/t x d2 pins for serial data output or serial clock output, clear the pm02, pm03, pm04, pm10, pm12, pm 13, pm43, pm45, pm142, pm143, and pm144 bits to 0, and set the output latches of p02, p03, p 04, p10, p12, p13, p43, p45, p142, p143, and p144 to 1. when using the p03/si10/r x d1/sda10, p04/sck10/scl10, p10/sck00/ex24, p11/si00/r x d0/ex25, p14/r x d3/ex28, p43/sck01, p44/si01, p142/sck20/scl20, and p143/si20/r x d2/sda20 pins for serial data input or serial clock input, set the pm03, pm 04, pm10, pm11, pm14, pm 43, pm44, pm142, and pm143 bits to 1. at this time, the output latches of p03, p 04, p10, p11, p14, p43, p44, p142, and p143 may be 0 or 1. pm0, pm1, pm4, and pm14 can be set by a 1-bit or 8-bit memory manipulation instruction. reset signal generation se ts these registers to ffh. figure 13-21. format of port mode registers 0, 1, 4, and 14 (pm0, pm1, pm4, pm14) address: fff20h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm0 1 pm06 pm05 pm04 pm03 pm02 pm01 pm00 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: fff24h after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm4 pm47 pm46 pm45 pm44 pm43 pm42 pm41 pm40 address: fff2eh after reset: ffh r/w symbol 7 6 5 4 3 2 1 0 pm14 1 1 pm145 pm144 pm143 pm142 pm141 pm140 pmmn pmn pin i/o mode selection (m = 0, 1, 4, 14; n = 0 to 7) 0 output mode (output buffer on) 1 input mode (output buffer off) chapter 13 serial array unit user?s manual u17894ej8v0ud 417 13.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 p02/so10/txd1, p03/si10/sda 10/rxd1, p04/sck10/scl1 0, p10/sck00/ex24, p11/si00/rxd0/ex25, p12/so00/tx d0/ex26, p13/txd3/ex27, p43/ sck01, p44/si01, p45/so01, p142/sck20/scl20, p143/si20/sda20/rx d2, or p144/so20/txd2 pin can be us ed as ordinary port pins in this mode. 13.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 ha rdware macro. clock supply to a hardware macro that is not used is stopped in order to r educe 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 13-22. peripheral enable register 0 (per 0) setting when stopping the operation by units cautions 1. if saumen = 0, writing to a control register of serial ar ray unit m is ignored, and, even if the register is read, only the default value is read (except for input switch control register (isc), noise filter enable register (nfen0), port input mode registers (pim0, pim4, pim14), port output mode registers (pom0, pom4, pom 14), port mode registers (pm0, pm1, pm4, pm14), and port registers (p0, p1, p4, p14)). 2. be sure to clear bit 1 of the per0 register to 0. remark m: unit number (m = 0, 1), : setting disabled (fixed by hardware) : 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 0 tau 0 e n 0/1 control of saum input clock 0: stops supply of input clock 1: su pp lies in p ut cloc k chapter 13 serial array unit user?s manual u17894ej8v0ud 418 13.4.2 stopping the operation by channels the stopping of the operation by channels is se t using each of the following registers. figure 13-23. each register setting when stopping the operation by channels (1/2) (a) 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 status register, w hose 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. (b) serial channel stop register m (stm) ? this register is a trigger register th at 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 regi ster 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 419 figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 420 13.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, csi20) 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 ? ? 3-wire serial i/o (csi00, csi01, cis 10, csi20) performs the following six types of communic ation operations. ? master transmission (see 13.5.1 .) ? master reception (see 13.5.2 .) ? master transmission/reception (see 13.5.3 .) ? slave transmission (see 13.5.4 .) ? slave reception (see 13.5.5 .) ? slave transmission/reception (see 13.5.6 .) chapter 13 serial array unit user?s manual u17894ej8v0ud 421 13.5.1 master transmission master transmission is an operation in which the 78k0r/kg3 outputs a transfer clock and transmits 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 29 electrical specificat ions (standard products) and chapter 30 electrical specification s ((a) grade products) (target) ). remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 422 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 423 (2) operation procedure figure 13-25. initial setting pr ocedure for master transmission caution after setting the per0 register 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 424 figure 13-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 13-27 procedure for resuming 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 425 figure 13-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. set 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 426 (3) processing flow (in si ngle-transmission mode) figure 13-28. timing chart of master transmission (in single-transmission mode) (type 1: dapmn = 0, ckpmn = 0) 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 427 figure 13-29. flowchart of master tr ansmission (in single-transmission mode) caution after setting the per0 register 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 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 428 (4) processing flow (in continuous transmission mode) figure 13-30. timing chart of master transmission (i n continuous transmission mode) (type 1: dapmn = 0, ckpmn = 0) 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 bi t 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 429 figure 13-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 per0 register 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 13-30 timing chart of master transmission (in continuous transmission mode) . chapter 13 serial array unit user?s manual u17894ej8v0ud 430 13.5.2 master reception master reception is an operation in which the 78k0r/kg3 outputs a transfer clock and receives data 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 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 29 electrical specificat ions (standard products) and chapter 30 electrical specification s ((a) grade products) (target) ). remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 431 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 432 (2) operation procedure figure 13-33. initial setting procedure for master reception caution after setting the per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 13-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 13-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. chapter 13 serial array unit user?s manual u17894ej8v0ud 433 figure 13-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. set 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 434 (3) processing flow (in single-reception mode) figure 13-36. timing chart of master reception (in single-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 435 figure 13-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 per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. chapter 13 serial array unit user?s manual u17894ej8v0ud 436 13.5.3 master transmission/reception master transmission/reception is an operation in which the 78k0r/kg3 outputs a transfer clock and transmits/receives data to/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 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 29 electrical specificat ions (standard products) and chapter 30 electrical specification s ((a) grade products) (target) ). remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 437 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 438 (2) operation procedure figure 13-39. initial setting procedur e for master transmission/reception caution after setting the per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 13-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 13-41 procedure for resuming master transmission/reception ). 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. 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 439 figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 440 (3) processing flow (in single -transmission/reception mode) figure 13-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 3 remark m: unit number (m = 0, 1), n: channel number (n = 0 to 2), p: csi number (p = 00, 01, 10, 20) chapter 13 serial array unit user?s manual u17894ej8v0ud 441 figure 13-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 per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. chapter 13 serial array unit user?s manual u17894ej8v0ud 442 (4) processing flow (in continu ous transmission/reception mode) figure 13-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 r egister while bffmn = 1, the transmit data is overwritten. 2. the transmit data can be read by reading 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 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 443 figure 13-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 per0 register 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 13-44 timing chart of master transmission/reception (in continuo us transmission/reception mode) . chapter 13 serial array unit user?s manual u17894ej8v0ud 444 13.5.4 slave transmission slave transmission is an operation in which the 78k0r/kg3 transmits 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 sck00, 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 the conditions above and the ac characteristics in the electrical specifications (see chapter 29 electrical specifications (standard products) and chapter 30 electrical specifications ((a) grade products) (target) ) . remarks 1. f mck : operation clock (mck) frequency of target channel 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 445 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 446 (2) operation procedure figure 13-47. initial setting pr ocedure for slave transmission caution after setting the per0 register 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 447 figure 13-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 13-49 procedure for r esuming 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 448 figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 449 (3) processing flow (in si ngle-transmission mode) figure 13-50. timing chart of sla ve transmission (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) chapter 13 serial array unit user?s manual u17894ej8v0ud 450 figure 13-51. flowchart of slave tran smission (in single-transmission mode) caution after setting the per0 register 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: se tting 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 451 (4) processing flow (in continuous transmission mode) figure 13-52. timing chart of sla ve transmission (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 ope ration. however, rewrite it before transfer of the last bit is started. chapter 13 serial array unit user?s manual u17894ej8v0ud 452 figure 13-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 per0 register 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 13-52 timing chart of slave transmission (in continuous transmission mode) . chapter 13 serial array unit user?s manual u17894ej8v0ud 453 13.5.5 slave reception slave reception is an operation in which the 78k0r/kg3 rece ives 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 sck00, 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 the conditions above and the ac characteristics in the electrical specifications (see chapter 29 electrical specifications (standard products) and chapter 30 electrical specifications ((a) grade products) (target) ) . remarks 1. f mck : operation clock (mck) frequency of target channel 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 454 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 455 (2) operation procedure figure 13-55. initial setting procedure for slave reception caution after setting the per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 13-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. chapter 13 serial array unit user?s manual u17894ej8v0ud 456 figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 457 (3) processing flow (in single-reception mode) figure 13-58. timing chart of sla ve reception (in single-reception 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 458 figure 13-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 per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. chapter 13 serial array unit user?s manual u17894ej8v0ud 459 13.5.6 slave transmission/reception slave transmission/reception is an operation in whic h the 78k0r/kg3 transmits/receives 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 sck00, 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 the conditions above and the ac characteristics in the electrical specifications (see chapter 29 electrical specifications (standard products) and chapter 30 electrical specifications ((a) grade products) (target) ) . remarks 1. f mck : operation clock (mck) frequency of target channel 2. m: unit number (m = 0, 1), n: channel number (n = 0 to 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 460 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 461 (2) operation procedure figure 13-61. initial setting proce dure for slave transmission/reception caution after setting the per0 register 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 462 figure 13-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 13-63 procedure for resumi ng 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 463 figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 464 (3) processing flow (in single -transmission/reception mode) figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 465 figure 13-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 per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. chapter 13 serial array unit user?s manual u17894ej8v0ud 466 (4) processing flow (in continu ous transmission/reception mode) figure 13-66. timing chart of sl ave transmission/recept ion (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 r egister while bffmn = 1, the transmit data is overwritten. 2. the transmit data can be read by reading 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 bi t 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 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 467 figure 13-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 per0 register 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 13-66 timing chart of slave transmission/reception (in continuo us transmission/reception mode) . chapter 13 serial array unit user?s manual u17894ej8v0ud 468 13.5.7 calculating transfer clock frequency the transfer clock frequency for 3-wire serial i/o (csi00, csi01, csi10, csi20) comm unication 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 se rial clock (sck) supplied by master} note [hz] note the permissible maximum transfer clock frequency is f mck /6. remarks 1. the value of sdrmn[15:9] is t he value of bits 15 to 9 of the 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). chapter 13 serial array unit user?s manual u17894ej8v0ud 469 table 13-2. selection of operation clock smrmn register spsm register operation clock (mck) note 1 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 note 2 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 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) t he operation of the serial array unit (sau). when selecting inttm02 and inttm03 for the operati on clock, also stop the timer array unit (tau) (tt0 = 00ffh). 2. sau can be operated at a fixed division ratio 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 tau. when changing f clk , however, sau and tau 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 470 13.6 operation of uart (uart0, uart1, uart2, uart3) communication this is a start-stop synchronization function using two lines: serial data transmission (txd) and serial data reception (rxd) lines. it transmits or receives data in asyn chronization 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 the transmitting side (even- number channel) and the receiving side (odd-n umber channel) can be used only as uarts. uart performs the following four types of communication operations. ? uart transmission (see 13.6.1 .) ? uart reception (see 13.6.2 .) ? lin transmission (uart3 only) (see 13.6.3 .) ? lin reception (uart 3 only) (see 13.6.4 .) external interrupt (intp0) or timer array unit (tau) is used. chapter 13 serial array unit user?s manual u17894ej8v0ud 471 13.6.1 uart transmission uart transmission is an operation to transmit data from the 78k0r/kg3 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 29 electrical specificat ions (standard products) and chapter 30 electrical specification s ((a) grade products) (target) ). remarks 1. f mck : operation clock (mck) frequency of target channel f clk : system clock frequency 2. m: unit number (m = 0, 1), n: channel number (n = 0, 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 472 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 473 figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 474 (2) operation procedure figure 13-69. initial setting procedure for uart transmission caution after setting the per0 register 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 475 figure 13-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 13-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. chapter 13 serial array unit user?s manual u17894ej8v0ud 476 figure 13-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. set 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 477 (3) processing flow (in si ngle-transmission mode) figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 478 figure 13-73. flowchart of uart tran smission (in single-transmission mode) caution after setting the per0 register 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 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 end of communication clearing sau1en and sau0en bits of per0 register to 0 chapter 13 serial array unit user?s manual u17894ej8v0ud 479 (4) processing flow (in continuous transmission mode) figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 480 figure 13-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> <6> caution after setting the per0 register 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 13-74 timing chart of uart transmission (in continuous transmission mode) . chapter 13 serial array unit user?s manual u17894ej8v0ud 481 13.6.2 uart reception uart reception is an operation wherein the 78k0r/kg3 a synchronously receives data from another device (start- stop synchronization). for uart reception, the odd-number channel of the two channels 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 29 electrical specificat ions (standard products) and chapter 30 electrical specification s ((a) grade products) (target) ). remarks 1. f mck : operation clock (mck) frequency of target channel f clk : system clock frequency 2. m: unit number (m = 0, 1), n: channel number (n = 1, 3) chapter 13 serial array unit user?s manual u17894ej8v0ud 482 (1) register setting figure 13-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 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 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 smr mr 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 483 figure 13-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 smr mr 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 484 (2) operation procedure figure 13-77. initial setting procedure for uart reception caution after setting the per0 register to 1, be sure to set the spsm register after 4 or more clocks have elapsed. figure 13-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. chapter 13 serial array unit user?s manual u17894ej8v0ud 485 figure 13-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 sirmn 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 486 (3) processing flow figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 487 figure 13-81. flowchart of uart reception caution after setting the per0 register 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 488 13.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] (sdr12 [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 29 electrical specificat ions (standard products) and chapter 30 electrical specification s ((a) grade products) (target) ). remark f mck : operation clock (mck) frequency of target channel f clk : system clock frequency lin stands for local interconnect network and is a low-s peed (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 lin, the master transmits a frame by attach ing baud rate information to it. a slave receives this frame and corrects a baud rate error from t he master. if the baud rate error of a slave is within 15%, communication can be established. figure 13-82 outlines a trans mission operation of lin. chapter 13 serial array unit user?s manual u17894ej8v0ud 489 figure 13-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 bits 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 490 figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 491 13.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] (sdr13 [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 29 electrical specificat ions (standard products) and chapter 30 electrical specification s ((a) grade products) (target) ). remark f mck : operation clock (mck) frequency of target channel f clk : system clock frequency figure 13-84 outlines a rec eption operation of lin. chapter 13 serial array unit user?s manual u17894ej8v0ud 492 figure 13-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 detect ed, reception is started and serial da ta is sequentially stored in the rxd3 register (= bits 7 to 0 of the serial data register 13 (sdr13)) 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 receptio n has been correctly completed. if data of low levels of less than 11 bits is detected as sbf, it is judged t hat an sbf reception error has occurred, and the system returns to the sbf reception wait status. <3> when sbf reception has been correctly completed, st art channel 7 of the timer array unit and measure the bit interval (pulse width) of the sync field (see 7.7.5 operation as input si gnal 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 493 figure 13-85 shows the configuration of a port that manipulates reception of lin. the wakeup signal transmitted from the master of lin is received by detecting an edge of an external interrupt (intp0). the length of the sync fi eld transmitted from the master can be measured by using the external event capture operation of the timer array unit (tau) to calculate a baud-rate error. by controlling switch of port input (i sc0/isc1), the input source of port input (rxd3) for reception can be input to the external interrupt pin (intp0) and timer array unit (tau). figure 13-85. port configuration for manipulating reception of lin rxd3 input intp0 input channel 7 input of tau p14/rxd3 p120/intp0/ exlvi p145/ti07 port input switch control (isc0) chapter 13 serial array unit user?s manual u17894ej8v0ud 494 the peripheral functions used for the lin communication operation are as follows. chapter 13 serial array unit user?s manual u17894ej8v0ud 495 figure 13-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 13-81 chapter 13 serial array unit user?s manual u17894ej8v0ud 496 13.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). chapter 13 serial array unit user?s manual u17894ej8v0ud 497 table 13-3. selection of operation clock smrmn register spsm register operation clock (mck) note 1 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 note 2 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 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) t he operation of the serial array unit (sau). when selecting inttm02 and inttm03 for the operati on clock, also stop the timer array unit (tau) (tt0 = 00ffh). 2. sau can be operated at a fixed division ratio 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 tau. when changing f clk , however, sau and tau 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 498 (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 that 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 % remark m: unit number (m = 0, 1), n: channel number (n = 0, 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 499 (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 13.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) remark m: unit number (m = 0, 1), n: channel number (n = 1, 3) figure 13-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 13-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 (s drmn) after the start bit is detected. if the last data (stop bit) is received before this latch timing, the data can be correctly received. chapter 13 serial array unit user?s manual u17894ej8v0ud 500 13.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 functi on is designed to execute single communication with devices such as eeprom, flash memory, and a/d converter, and theref ore, can be used only by the master and does not have a wait detection function. make sure by using software, as well as operating the c ontrol registers, that 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 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 function note an ack is not output when the last data is being re ceived by writing 0 to the soemn (soem register) bit and stopping the output of serial communication data. see 13.7.3 (2) processing flow for details. remarks 1. to use the full-function i 2 c bus, see chapter 14 serial interface iic0 . 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) ? simplified i 2 c (iic10, iic20) performs the following four types of communication operations. ? address field transmission (see 13.7.1 .) ? data transmission (see 13.7.2 .) ? data reception (see 13.7.3 .) ? stop condition generation (see 13.7.4 .) chapter 13 serial array unit user?s manual u17894ej8v0ud 501 13.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 address (7 bits) and a transfer direction (1 bit) are transmitted in 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 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 n-ch open-drain output (v dd tolerance) mode (pom03, pom143 = 1) for the port output mo de registers (pom0, pom14) (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 (pom04, pom142 = 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 502 (1) register setting figure 13-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 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 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 503 (2) operation procedure figure 13-89. initial setting proce dure for address field transmission caution after setting the per0 register 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 chapter 13 serial array unit user?s manual u17894ej8v0ud 504 (3) processing flow figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 505 figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 506 13.7.2 data transmission data transmission is an operation to transmit data to the ta rget 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 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 n-ch open-drain output (v dd tolerance) mode (pom03, pom143 = 1) for the port output mo de registers (pom0, pom14) (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 (pom04, pom142 = 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 507 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 508 (2) processing flow figure 13-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 13-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 ? chapter 13 serial array unit user?s manual u17894ej8v0ud 509 13.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 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 n-ch open-drain output (v dd tolerance) mode (pom03, pom143 = 1) for the port output mo de registers (pom0, pom14) (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 (pom04, pom142 = 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) chapter 13 serial array unit user?s manual u17894ej8v0ud 510 (1) register setting figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 511 (2) processing flow figure 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 512 figure 13-97. flowchart of data reception caution ack is not output when the last data is received (nack). 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? chapter 13 serial array unit user?s manual u17894ej8v0ud 513 13.7.4 stop condition generation after all data are transmitted to or received from the ta rget slave, a stop condition is generated and the bus is released. (1) processing flow figure 13-98. timing chart of stop condition generation stop condition stmn semn soemn sclr output sdar output operation stop somn bit manipulation ckomn bit manipulation somn bit manipulation note 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) figure 13-99. flowchart of stop condition generation 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. chapter 13 serial array unit user?s manual u17894ej8v0ud 514 13.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 remarks 1. the value of sdrmn[15:9] is t he value of bits 15 to 9 of the 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). chapter 13 serial array unit user?s manual u17894ej8v0ud 515 table 13-4. selection of operation clock smrmn register spsm register operation clock (mck) note 1 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 note 2 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 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) t he operation of the serial array unit (sau). when selecting inttm02 and inttm03 for the operati on clock, also stop the timer array unit (tau) (tt0 = 00ffh). 2. sau can be operated at a fixed division ratio 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 tau. when changing f clk , however, sau and tau 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, 2) chapter 13 serial array unit user?s manual u17894ej8v0ud 516 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% chapter 13 serial array unit user?s manual u17894ej8v0ud 517 13.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 13-100 to 13-102. figure 13-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 13-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) chapter 13 serial array unit user?s manual u17894ej8v0ud 518 figure 13-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 chapter 13 serial array unit user?s manual u17894ej8v0ud 519 13.9 relationship between re gister settings and pins tables 13-5 to 13-12 show the relationship between register settings and pins for each channel of serial array units 0 and 1. table 13-5. relationship between register settings and pins (channel 0 of unit 0: csi00, uart0 transmission) pin function se 00 note 1 md 002 md 001 soe 00 so 00 cko 00 txe 00 rxe 00 pm1 0 p10 pm 11 note 2 p11 note 2 pm1 2 p12 operation mode sck00/ ex24/p10 si00/ex25/ rxd0/p11 note 2 so00/ex26/ txd0/p12 0 0 ex25/p11 0 0 1 0 1 1 0 0 note 3 note 3 note 3 note 3 note 3 note 3 operation stop mode ex24/p10 ex25/p11/ rxd0 ex26/p12 0 1 1 0 1 1 1 note 3 note 3 slave csi00 reception sck00 (input) si00 p12 1 0/1 note 4 1 1 0 1 note 3 note 3 0 1 slave csi00 transmission sck00 (input) p11 so00 1 0/1 note 4 1 1 1 1 1 0 1 slave csi00 transmission/ reception sck00 (input) si00 so00 0 1 0/1 note 4 0 1 0 1 1 note 3 note 3 master csi00 reception sck00 (output) si00 p12 1 0/1 note 4 0/1 note 4 1 0 0 1 note 3 note 3 0 1 master csi00 transmission sck00 (output) p11 so00 0 0 1 0/1 note 4 0/1 note 4 1 1 0 1 1 0 1 master csi00 transmission/ reception sck00 (output) si00 so00 1 0 1 1 0/1 note 4 1 1 0 note 3 note 3 note 3 note 3 0 1 uart0 transmission note 5 p10 p11/rxd0 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 13-6 ). in this case, operation stop mode or uart0 transmission 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 13.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 13-6 ). remark x: don?t care chapter 13 serial array unit user?s manual u17894ej8v0ud 520 table 13-6. relationship between regi ster settings and pins (channel 1 of unit 0: csi01, uart0 reception) pin function se 01 note 1 md 012 md 011 soe 01 so01 cko 01 txe 01 rxe 01 pm 43 p43 pm44 p44 pm 45 p45 pm 11 note 2 p11 note 2 operation mode sck01/ p43 si01/p44 so01/ p45 si00/ex25/ rxd0/ p11 note 2 0 0 0 0 1 0 1 1 0 0 note 3 note 3 note 3 note 3 note 3 note 3 note 3 note 3 operation stop mode p43 p44 p45 si00/ex25/ p11 0 1 1 0 1 1 1 note 3 note 3 note 3 note 3 slave csi01 reception sck01 (input) si01 p45 si00/ex25/ p11 1 0/1 note 4 1 1 0 1 note 3 note 3 0 1 note 3 note 3 slave csi01 transmission sck01 (input) p44 so01 si00/ex25/ p11 1 0/1 note 4 1 1 1 1 1 0 1 note 3 note 3 slave csi01 transmission /reception sck01 (input) si01 so01 si00/ex25/ p11 0 1 0/1 note 4 0 1 0 1 1 note 3 note 3 note 3 note 3 master csi01 reception sck01 (output) si01 p45 si00/ex25/ p11 1 0/1 note 4 0/1 note 4 1 0 0 1 note 3 note 3 0 1 note 3 note 3 master csi01 transmission sck01 (output) p44 so01 si00/ex25/ p11 0 0 1 0/1 note 4 0/1 note 4 1 1 0 1 1 0 1 note 3 note 3 master csi01 transmission /reception sck01 (output) si01 so01 si00/ex25/ p11 1 0 1 0 1 1 0 1 note 3 note 3 note 3 note 3 note 3 note 3 1 uart0 reception notes 5, 6 p43 p44 p45 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, th is 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 13-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 13.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 13-5 ). 6. the smr00 register of chan nel 0 of unit 0 must also be set during uart0 reception. for details, refer to 13.5.2 (1) register setting . remark x: don?t care chapter 13 serial array unit user?s manual u17894ej8v0ud 521 table 13-7. relationship between register settings and pins (channel 2 of unit 0: csi10, uart1 transmission, iic10) pin function se 02 note 1 md 022 md 021 soe 02 so 02 cko 02 txe 02 rxe 02 pm 04 p04 pm03 note 2 p03 note 2 pm02 p02 operation mode sck10/ scl10/p04 si10/sda10/ rxd1/p03 note 2 so10/ txd1/p02 0 0 p03 0 1 p03/rxd1 0 1 0 0 1 1 0 0 note 3 note 3 note 3 note 3 note 3 note 3 operation stop mode p04 p03 p02 0 1 1 0 1 1 1 note 3 note 3 slave csi10 reception sck10 (input) si10 p02 1 0/1 note 4 1 1 0 1 note 3 note 3 0 1 slave csi10 transmission sck10 (input) p03 so10 1 0/1 note 4 1 1 1 1 1 0 1 slave csi10 transmission /reception sck10 (input) si10 so10 0 1 0/1 note 4 0 1 0 1 1 note 3 note 3 master csi10 reception sck10 (output) si10 p02 1 0/1 note 4 0/1 note 4 1 0 0 1 note 3 note 3 0 1 master csi10 transmission sck10 (output) p03 so10 0 0 1 0/1 note 4 0/1 note 4 1 1 0 1 1 0 1 master csi10 transmission /reception sck10 (output) si10 so10 1 0 1 1 0/1 note 4 1 1 0 note 3 note 3 note 3 note 3 0 1 uart1 transmission note 5 p04 p03/rxd1 txd1 0 0 1 0 0 0 0/1 note 6 0/1 note 6 0 1 0 1 0 1 note 3 note 3 iic10 start condition scl10 sda10 p02 1 0/1 note 4 0/1 note 4 1 0 0 1 0 1 note 3 note 3 iic10 address field transmission scl10 sda10 p02 1 0/1 note 4 0/1 note 4 1 0 0 1 0 1 note 3 note 3 iic10 data transmission scl10 sda10 p02 1 1 0/1 note 4 0/1 note 4 0 1 0 1 0 1 note 3 note 3 iic10 data reception scl10 sda10 p02 0 0 1 0 0 1 0 0 0/1 note 7 0/1 note 7 0 1 0 1 0 1 note 3 note 3 iic10 stop condition scl10 sda10 p02 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 13-8 ). in this case, operation stop mode or uart1 transmission 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 13.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 13-8 ). 6. set the cko02 bit to 1 before a start condition is genera ted. clear the so02 bit fr om 1 to 0 when the start condition is generated. 7. set the cko02 bit to 1 before a stop condition is gene rated. clear the so02 bit from 0 to 1 when the stop condition is generated. remark x: don?t care chapter 13 serial array unit user?s manual u17894ej8v0ud 522 table 13-8. relationship between register settings and pins (channel 3 of unit 0: uart1 reception) pin function se03 note 1 md032 md031 txe03 rxe03 pm03 note 2 p03 note 2 operation mode si10/sda10/rxd1/p03 note 2 0 0 1 0 0 note 3 note 3 operation stop mode si10/sda10/p03 note 2 1 0 1 0 1 1 uart1 reception notes 4, 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, th is 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 13-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 13-7 ). 5. the smr02 register of chan nel 2 of unit 0 must also be set during uart1 reception. for details, refer to 13.5.2 (1) register setting . remark x: don?t care chapter 13 serial array unit user?s manual u17894ej8v0ud 523 table 13-9. relationship between register settings and pins (channel 0 of unit 1: csi20, uart2 transmission, iic20) pin function se 10 note 1 md 102 md 101 soe 10 so 10 cko 10 txe 10 rxe 10 pm 142 p142 pm1 43 note 2 p14 3 note 2 pm 144 p144 operation mode sck20/ scl20/p142 si20/sda20/ rxd2/p143 note 2 so20/ txd2/p144 0 0 p143 0 1 p143/rxd2 0 1 0 0 1 1 0 0 note 3 note 3 note 3 note 3 note 3 note 3 operation stop mode p142 p143 p144 0 1 1 0 1 1 1 note 3 note 3 slave csi20 reception sck20 (input) si20 p144 1 0/1 note 4 1 1 0 1 note 3 note 3 0 1 slave csi20 transmission sck20 (input) p143 so20 1 0/1 note 4 1 1 1 1 1 0 1 slave csi20 transmission/reception sck20 (input) si20 so20 0 1 0/1 note 4 0 1 0 1 1 note 3 note 3 master csi20 reception sck20 (output) si20 p144 1 0/1 note 4 0/1 note 4 1 0 0 1 note 3 note 3 0 1 master csi20 transmission sck20 (output) p143 so20 0 0 1 0/1 note 4 0/1 note 4 1 1 0 1 1 0 1 master csi20 transmission/reception sck20 (output) si20 so20 1 0 1 1 0/1 note 4 1 1 0 note 3 note 3 note 3 note 3 0 1 uart2 transmission note 5 p142 p143/rxd2 txd2 0 0 1 0 0 0 0/1 note 6 0/1 note 6 0 1 0 1 0 1 note 3 note 3 iic20 start condition scl20 sda20 p144 1 0/1 note 4 0/1 note 4 1 0 0 1 0 1 note 3 note 3 iic20 address field transmission scl20 sda20 p144 1 0/1 note 4 0/1 note 4 1 0 0 1 0 1 note 3 note 3 iic20 data transmission scl20 sda20 p144 1 1 0/1 note 4 0/1 note 4 0 1 0 1 0 1 note 3 note 3 iic20 data reception scl20 sda20 p144 0 0 1 0 0 1 0 0 0/1 note 7 0/1 note 7 0 1 0 1 0 1 note 3 note 3 iic20 stop condition scl20 sda20 p144 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 13-10 ). in this case, operation stop mode or uart2 transm ission 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 13.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 13-10 ). 6. set the cko10 bit to 1 before a start condition is genera ted. clear the so10 bit fr om 1 to 0 when the start condition is generated. 7. set the cko10 bit to 1 before a stop condition is gene rated. clear the so10 bit from 0 to 1 when the stop condition is generated. remark x: don?t care chapter 13 serial array unit user?s manual u17894ej8v0ud 524 table 13-10. relationship between register settings and pins (channel 1 of unit 1: uart2 reception) pin function se11 note 1 md112 md111 txe11 rxe11 pm143 note 2 p143 note 2 operation mode si20/sda20/rxd2/p143 note 2 0 0 1 0 0 note 3 note 3 operation stop mode si20/sda20/p143 1 0 1 0 1 1 uart2 reception notes 4, 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, th is 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 13-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 13-9 ). 5. the smr10 register of chan nel 0 of unit 1 must also be set during uart2 reception. for details, refer to 13.5.2 (1) register setting . remark x: don?t care chapter 13 serial array unit user?s manual u17894ej8v0ud 525 table 13-11. relationship between register settings a nd pins (channel 2 of unit 1: uart3 transmission) pin function se12 note 1 md122 md121 soe12 so12 txe12 rxe12 pm13 p13 operation mode ex27/txd3/p13 0 0 1 0 1 0 0 note 2 note 2 operation stop mode ex27/p13 1 0 1 1 0/1 note 3 1 0 0 1 uart3 transmission note 4 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 13.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 13-12 ). remark x: don?t care table 13-12. relationship between register settings and pins (channel 3 of unit 1: uart3 reception) pin function se13 note 1 md132 md131 txe13 rxe13 pm14 p14 operation mode ex28/rxd3/p14 0 0 1 0 0 note 2 note 2 operation stop mode ex28/p14 1 0 1 0 1 1 uart3 reception notes 3, 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 13-11 ). 4. the smr12 register of chan nel 2 of unit 1 must also be set during uart3 reception. for details, refer to 13.5.2 (1) register setting . remark x: don?t care user?s manual u17894ej8v0ud 526 chapter 14 serial interface iic0 14.1 functions of serial interface iic0 serial interface iic0 has the following two modes. (1) operation stop mode this mode is used when serial transfers are not performed. it can therefore be used to reduce power consumption. (2) i 2 c bus mode (multimaster supported) this mode is used for 8-bit data transfers with several devices via two lines: a serial clock (scl0) line and a serial data bus (sda0) line. this mode complies with the i 2 c bus format and the master device can generated ?start condition?, ?address?, ?transfer direction specification?, ?dat a?, and ?stop condition? data to the slave device, via the serial data bus. the slave device automatically detects these received status and data by har dware. this function can simplify the part of application prog ram that controls the i 2 c bus. since the scl0 and sda0 pins are used for open drain ou tputs, iic0 requires pull-up resistors for the serial clock line and the serial data bus line. figure 14-1 shows a block diagram of serial interface iic0. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 527 figure 14-1. block diagram of serial interface iic0 internal bus iic status register 0 (iics0) iic control register 0 (iicc0) slave address register 0 (sva0) noise eliminator noise eliminator bus status detector match signal iic shift register 0 (iic0) so latch iice0 dq set clear cl01, cl00 trc0 dfc0 dfc0 sda0/ p61 scl0/ p60 data hold time correction circuit start condition generator stop condition generator ack generator wakeup controller ack detector output control stop condition detector serial clock counter interrupt request signal generator serial clock controller serial clock wait controller prescaler intiic0 iic shift register 0 (iic0) iicc0.stt0, spt0 iics0.msts0, exc0, coi0 iics0.msts0, exc0, coi0 f clk lrel0 wrel0 spie0 wtim0 acke0 stt0 spt0 msts0 ald0 exc0 coi0 trc0 ackd0 std0 spd0 start condition detector internal bus cld0 dad0 smc0 dfc0 cl01 cl00 clx0 iic clock select register 0 (iiccl0) stcf iicbsy stcen iicrsv iic flag register 0 (iicf0) iic function expansion register 0 (iicx0) n-ch open- drain output pm61 output latch (p61) n-ch open- drain output pm60 output latch (p60) chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 528 figure 14-2 shows a serial bus configuration example. figure 14-2. serial bus c onfiguration example using i 2 c bus master cpu1 slave cpu1 address 0 sda0 scl0 serial data bus serial clock + v dd + v dd sda0 scl0 sda0 scl0 sda0 scl0 sda0 scl0 master cpu2 slave cpu2 address 1 slave cpu3 address 2 slave ic address 3 slave ic address n chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 529 14.2 configuration of serial interface iic0 serial interface iic0 includes the following hardware. table 14-1. configuration of serial interface iic0 item configuration registers iic shift register 0 (iic0) slave address register 0 (sva0) control registers peripheral enable register 0 (per0) iic control register 0 (iicc0) iic status register 0 (iics0) iic flag register 0 (iicf0) iic clock select register 0 (iiccl0) iic function expansion register 0 (iicx0) port mode register 6 (pm6) port register 6 (p6) (1) iic shift register 0 (iic0) iic0 is used to convert 8-bit serial data to 8-bit paralle l data and vice versa in synchronization with the serial clock. iic0 can be used for both transmission and reception. the actual transmit and receive operations can be contro lled by writing and reading operations to iic0. cancel the wait state and start data transfer by writing data to iic0 during the wait period. iic0 can be set by an 8-bit memory manipulation instruction. reset signal generation clears iic0 to 00h. figure 14-3. format of iic shift register 0 (iic0) symbol iic0 address: fff50h after reset: 00h r/w 76543210 cautions 1. do not write data to iic0 during data transfer. 2. write or read iic0 only during the wait pe riod. accessing iic0 in a communication state other than during the wait period is prohibit ed. when the device serves as the master, however, iic0 can be written only once after the communication trigger bit (stt0) is set to 1. (2) slave address register 0 (sva0) this register stores local addresses when in slave mode. sva0 can be set by an 8-bit memory manipulation instruction. however, rewriting to this register is prohibited wh ile std0 = 1 (while the start condition is detected). reset signal generation clears sva0 to 00h. figure 14-4. format of slave address register 0 (sva0) symbol sva0 address: fff53h after reset: 00h r/w 76543210 0 note note bit 0 is fixed to 0. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 530 (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 (intiic0) w hen the address received by this register matches the address value set to slave address register 0 (sva0) or when an extension code is received. (5) prescaler this selects the sampling clock to be used. (6) serial clock counter this counter counts the serial clocks that are output or input during transmi t/receive operations and is used to verify that 8-bit data was transmitted or received. (7) interrupt request signal generator this circuit controls the generation of interrupt request signals (intiic0). an i 2 c interrupt request is generated by the following two triggers. ? falling edge of eighth or ninth clock of the serial clock (set by wtim0 bit) ? interrupt request generated when a stop cond ition is detected (set by spie0 bit) remark wtim0 bit: bit 3 of iic control register 0 (iicc0) spie0 bit: bit 4 of iic control register 0 (iicc0) (8) serial clock controller in master mode, this circuit generates the clock output via the scl0 pin from a sampling clock. (9) serial clock wait controller this circuit controls the wait timing. (10) ack generator, stop condition detector, start condition detector, and ack detector these circuits generate and detect each status. (11) data hold time correction circuit this circuit generates the hold time for data corre sponding to the falling edge of the serial clock. (12) start condition generator this circuit generates a start conditi on when the stt0 bit is set to 1. however, in the communication reservation disabled stat us (iicrsv bit = 1), when the bus is not released (iicbsy bit = 1), start condition requests are ignored and the stcf bit is set to 1. (13) stop condition generator this circuit generates a stop condition when the spt0 bit is set to 1. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 531 (14) bus status detector this circuit detects whether or not the bus is releas ed by detecting start conditions and stop conditions. however, as the bus status cannot be detected immediately following operation, the initial status is set by the stcen bit. remark stt0 bit: bit 1 of iic control register 0 (iicc0) spt0 bit: bit 0 of iic control register 0 (iicc0) iicrsv bit: bit 0 of iic flag register 0 (iicf0) iicbsy bit: bit 6 of iic flag register 0 (iicf0) stcf bit: bit 7 of iic flag register 0 (iicf0) stcen bit: bit 1 of iic flag register 0 (iicf0) chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 532 14.3 registers to controlling serial interface iic0 serial interface iic0 is controlled by the following eight registers. ? peripheral enable register 0 (per0) ? iic control register 0 (iicc0) ? iic flag register 0 (iicf0) ? iic status register 0 (iics0) ? iic clock select register 0 (iiccl0) ? iic function expansion register 0 (iicx0) ? port mode register 6 (pm6) ? port register 6 (p6) (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 reduce the power consumption and noise. when serial interface iic0 is used, be sure to set bit 4 (iic0en) 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-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 iic0en sau1en sau0en 0 tau0en iic0en control of serial interface iic0 input clock 0 stops supply of input clock. ? sfr used by serial interface iic0 cannot be written. ? serial interface iic0 is in the reset status. 1 supplies input clock. ? sfr used by serial interface iic0 can be read/written. cautions 1. when setting serial interfac e iic0, be sure to set iic0en to 1 first. if iic0en = 0, writing to a control register of serial interface iic0 is ignored , and, even if the register is read, only the default value is read (except for port mode register 6 (pm6) and port register 6 (p6)). 2. be sure to clear bit 1 of the per0 register to 0. (2) iic control register 0 (iicc0) this register is used to enable/stop i 2 c operations, set wait timing, and set other i 2 c operations. iicc0 can be set by a 1-bit or 8-bit memory manipulation instruction. however, set the spie0, wtim0, and acke0 bits while iice0 bit = 0 or during the wait period. these bits can be set at the same time when the iice0 bit is set from ?0? to ?1?. reset signal generation clea rs this register to 00h. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 533 figure 14-6. format of iic control register 0 (iicc0) (1/4) address: fff52h after reset: 00h r/w symbol <7> <6> <5> <4> <3> <2> <1> <0> iicc0 iice0 lrel0 wrel0 spie0 wtim0 acke0 stt0 spt0 iice0 i 2 c operation enable 0 stop operation. reset iic status register 0 (iics0) note 1 . stop internal operation. 1 enable operation. be sure to set this bit (1) while the scl0 and sda0 lines are at high level. condition for clearing (iice0 = 0) condition for setting (iice0 = 1) ? cleared by instruction ? reset ? set by instruction lrel0 note 2 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 iic control register 0 (iicc0) and iic status register 0 (iics0) are cleared to 0. ? stt0 ? spt0 ? msts0 ? exc0 ? coi0 ? trc0 ? ackd0 ? std0 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 (lrel0 = 0) condition for setting (lrel0 = 1) ? automatically cleared after execution ? reset ? set by instruction wrel0 note 2 wait cancellation 0 do not cancel wait 1 cancel wait. this setting is automatic ally cleared after wait is canceled. when wrel0 is set (wait canceled) during the wait period at the ninth clock pulse in the transmission status (trc0 = 1), the sda0 line goes into the high impedance state (trc0 = 0). condition for clearing (wrel0 = 0) condition for setting (wrel0 = 1) ? automatically cleared after execution ? reset ? set by instruction notes 1. the iics0 register, the stcf and iicbsy bits of the iicf0 register, and the cld0 and dad0 bits of the iiccl0 register are reset. 2. the signal of this bit is invalid while iice0 is 0. caution the start condition is detected immediately after i 2 c is enabled to operate (iice0 = 1) while the scl0 line is at high level and the sda0 line is at low level. immediately after enabling i 2 c to operate (iice0 = 1), set lrel0 (1 ) by using a 1-bit memory manipulation instruction. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 534 figure 14-6. format of iic control register 0 (iicc0) (2/4) spie0 note 1 enable/disable generation of interrupt request when stop condition is detected 0 disable 1 enable condition for clearing (spie0 = 0) condition for setting (spie0 = 1) ? cleared by instruction ? reset ? set by instruction wtim0 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 (wtim0 = 0) condition for setting (wtim0 = 1) ? cleared by instruction ? reset ? set by instruction a cke 0 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 (acke0 = 0) condition for setting (acke0 = 1) ? cleared by instruction ? reset ? set by instruction notes 1. the signal of this bit is invalid while iice0 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. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 535 figure 14-6. format of iic control register 0 (iicc0) (3/4) stt0 note start condition trigger 0 do not generate a start condition. 1 when bus is released (in stop mode): generate a start condition (for starting as master). when the scl0 line is high level, the sda0 line is changed from high level to low level and then the st art condition is generated. next, after the rated amount of time has elapsed, scl0 is changed to low level (wait state). 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) stcf is set to 1 and information that is set (1) to stt0 is cleared. no start condition is generated. in the wait state (when master device): generates a restart condition after releasing the wait. cautions concerning set timing ? for master reception: cannot be set to 1 during transfer. can be set to 1 only in the waiting period when acke0 has been cleared to 0 and slave has been notified of final reception. ? for master transmission: a start condition cannot be 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 spt0. ? setting stt0 to 1 and then setting it again bef ore it is cleared to 0 is prohibited. condition for clearing (stt0 = 0) condition for setting (stt0 = 1) ? cleared by setting sst0 to 1 while communication reservation is prohibited. ? cleared by loss in arbitration ? cleared after start condition is generated by master device ? cleared by lrel0 = 1 (exit from communications) ? when iice0 = 0 (operation stop) ? reset ? set by instruction note the signal of this bit is invalid while iice0 is 0. remarks 1. bit 1 (stt0) becomes 0 when it is read after data setting. 2. iicrsv: bit 0 of iic flag register (iicf0) stcf: bit 7 of iic flag register (iicf0) chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 536 figure 14-6. format of iic control register 0 (iicc0) (4/4) spt0 stop condition trigger 0 stop condition is not generated. 1 stop condition is generated (terminati on of master device?s transfer). after the sda0 line goes to low level, either set the scl0 line to high level or wait until it goes to high level. next, after the rated amount of time has elap sed, the sda0 line changes from low level to high level and a stop condition is generated. cautions concerning set timing ? for master reception: cannot be set to 1 during transfer. can be set to 1 only in the waiting period when acke0 has been cleared to 0 and slave has been notified of final reception. ? for master transmission: a 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 stt0. ? spt0 can be set to 1 only when in master mode note . ? when wtim0 has been cleared to 0, if spt0 is set to 1 dur ing the wait period that follows output of eight clocks, note that a stop condition will be generated during the high-le vel period of the ninth clock. wtim0 should be changed from 0 to 1 during the wait period following the out put of eight clocks, and spt0 should be set to 1 during the wait period that follows the output of the ninth clock. ? setting spt0 to 1 and then setting it again bef ore it is cleared to 0 is prohibited. condition for clearing (spt0 = 0) condition for setting (spt0 = 1) ? cleared by loss in arbitration ? automatically cleared after stop condition is detected ? cleared by lrel0 = 1 (exit from communications) ? when iice0 = 0 (operation stop) ? reset ? set by instruction note set spt0 to 1 only in master mode. however, spt0 must be set to 1 and a stop condition generated before the first stop condition is detect ed following the switch to the operation enabled status. caution when bit 3 (trc0) of iic status register 0 (iics0) is set to 1, wrel0 is set to 1 during the ninth clock and wait is canceled, after which t rc0 is cleared and the sda0 line is set to high impedance. remark bit 0 (spt0) becomes 0 when it is read after data setting. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 537 (3) iic status register 0 (iics0) this register indicates the status of i 2 c. iics0 is read by a 1-bit or 8-bit memory manipulation instruction only when stt0 = 1 and during the wait period. reset signal generation clea rs this register to 00h. figure 14-7. format of iic status register 0 (iics0) (1/3) address: fff56h after reset: 00h r symbol <7> <6> <5> <4> <3> <2> <1> <0> iics0 msts0 ald0 exc0 coi0 trc0 ackd0 std0 spd0 msts0 master device status 0 slave device status or communication standby status 1 master device communication status condition for clearing (msts0 = 0) condition for setting (msts0 = 1) ? when a stop condition is detected ? when ald0 = 1 (arbitration loss) ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when a start condition is generated ald0 detection of arbitration loss 0 this status means either that there was no arbitr ation or that the arbitration result was a ?win?. 1 this status indicates the arbitration result was a ?loss?. msts0 is cleared. condition for clearing (ald0 = 0) condition for setting (ald0 = 1) ? automatically cleared after iics0 is read note ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when the arbitration result is a ?loss?. exc0 detection of extension code reception 0 extension code was not received. 1 extension code was received. condition for clearing (exc0 = 0) condition for setting (exc0 = 1) ? when a start condition is detected ? when a stop condition is detected ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when the higher four bits of the received address data is either ?0000? or ?1111? (set at the rising edge of the eighth clock). note this register is also cleared when a 1-bit memo ry manipulation instruction is executed for bits other than iics0. therefore, when using the ald0 bit, read the data of this bit before the data of the other bits. remark lrel0: bit 6 of iic control register 0 (iicc0) iice0: bit 7 of iic control register 0 (iicc0) chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 538 figure 14-7. format of iic status register 0 (iics0) (2/3) coi0 detection of matching addresses 0 addresses do not match. 1 addresses match. condition for clearing (coi0 = 0) condition for setting (coi0 = 1) ? when a start condition is detected ? when a stop condition is detected ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when the received address matches the local address (slave address register 0 (sva0)) (set at the rising edge of the eighth clock). trc0 detection of transmit/receive status 0 receive status (other than transmit status). the sda0 line is set for high impedance. 1 transmit status. the value in the so0 latch is enabled for output to the sda0 line (valid starting at the falling edge of the first byte?s ninth clock). condition for clearing (trc0 = 0) condition for setting (trc0 = 1) chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 539 figure 14-7. format of iic status register 0 (iics0) (3/3) ackd0 detection of acknowledge (ack) 0 acknowledge was not detected. 1 acknowledge was detected. condition for clearing (ackd0 = 0) condition for setting (ackd0 = 1) ? when a stop condition is detected ? at the rising edge of the next byte?s first clock ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? after the sda0 line is set to low level at the rising edge of scl0?s ninth clock std0 detection of start condition 0 start condition was not detected. 1 start condition was detected. this indicates that the address transfer period is in effect. condition for clearing (std0 = 0) condition for setting (std0 = 1) ? when a stop condition is detected ? at the rising edge of the next byte?s first clock following address transfer ? cleared by lrel0 = 1 (exit from communications) ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when a start condition is detected spd0 detection of stop condition 0 stop condition was not detected. 1 stop condition was detected. the master device ?s communication is terminated and the bus is released. condition for clearing (spd0 = 0) condition for setting (spd0 = 1) ? at the rising edge of the address transfer byte?s first clock following setting of th is bit and detection of a start condition ? when iice0 changes from 1 to 0 (operation stop) ? reset ? when a stop condition is detected remark lrel0: bit 6 of iic control register 0 (iicc0) iice0: bit 7 of iic control register 0 (iicc0) (4) iic flag register 0 (iicf0) this register sets the operation mode of i 2 c and indicates the status of the i 2 c bus. iicf0 can be set by a 1-bit or 8-bit memory manipulati on instruction. however, the stcf and iicbsy bits are read-only. the iicrsv bit can be used to enable/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 (iice0) of iic control register 0 (iicc0) = 0). when operation is enabled, the iicf0 register can be read. reset signal generation clea rs this register to 00h. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 540 figure 14-8. format of iic flag register 0 (iicf0) <7> stcf condition for clearing (stcf = 0) ? cleared by stt0 = 1 ? when iice0 = 0 (operation stop) ? reset condition for setting (stcf = 1) ? generating start condition unsuccessful and stt0 cleared to 0 when communication reservation is disabled (iicrsv = 1). stcf 0 1 generate start condition start condition generation unsuccessful: clear stt0 flag stt0 clear flag iicf0 symbol <6> iicbsy 5 0 4 0 3 0 2 0 <1> stcen <0> iicrsv address: fff51h after reset: 00h r/w note condition for clearing (iicbsy = 0) ? detection of stop condition ? when iice0 = 0 (operation stop) ? reset condition for setting (iicbsy = 1) ? detection of start condition ? setting of iice0 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 (iice0 = 1), enable generation of a start condition upon detection of a stop condition. after operation is enabled (iice0 = 1), enable generation of a start condition without detecting a stop condition. initial start enable trigger condition for clearing (iicrsv = 0) ? cleared by instruction ? reset condition for setting (iicrsv = 1) ? set by instruction iicrsv 0 1 enable communication reservation disable communication reservation communication reservation function disable bit note bits 6 and 7 are read-only. cautions 1. write to stcen only when the operation is stopped (iice0 = 0). 2. as the bus release status (iicbsy = 0) is recognized regardless of the actual bus status when stcen = 1, when generating th e first start condition (stt0 = 1), it is necessary to verify that no third party comm unications are in progress in order to prevent such communications from being destroyed. 3. write to iicrsv only when th e operation is stopped (iice0 = 0). remark stt0: bit 1 of iic control register 0 (iicc0) iice0: bit 7 of iic control register 0 (iicc0) chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 541 (5) iic clock select register 0 (iiccl0) this register is used to set the transfer clock for the i 2 c bus. iiccl0 can be set by a 1-bit or 8-bit memory manipulation instruction. however, the cld0 and dad0 bits are read-only. the smc0, cl01, and cl00 bits are set in comb ination with bit 0 (clx0) of iic function expansion register 0 (iicx0) (see 14.5.4 transfer clock setting method ). set iiccl0 while bit 7 (iice0) of iic control register 0 (iicc0) is 0. reset signal generation clea rs this register to 00h. figure 14-9. format of iic clock select register 0 (iiccl0) address: fff54h after reset: 00h r/w note symbol 7 6 <5> <4> <3> <2> 1 0 iiccl0 0 0 cld0 dad0 smc0 dfc0 cl01 cl00 cld0 detection of scl0 pin level (valid only when iice0 = 1) 0 the scl0 pin was detected at low level. 1 the scl0 pin was detected at high level. condition for clearing (cld0 = 0) condition for setting (cld0 = 1) ? when the scl0 pin is at low level ? when iice0 = 0 (operation stop) ? reset ? when the scl0 pin is at high level dad0 detection of sda0 pin level (valid only when iice0 = 1) 0 the sda0 pin was detected at low level. 1 the sda0 pin was detected at high level. condition for clearing (dad0 = 0) condition for setting (dad0 = 1) ? when the sda0 pin is at low level ? when iice0 = 0 (operation stop) ? reset ? when the sda0 pin is at high level smc0 operation mode switching 0 operates in standard mode. 1 operates in fast mode. dfc0 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 regardless of dfc0 bit set (1)/clear (0). the digital filter is used for noise elimination in fast mode. note bits 4 and 5 are read-only. remark iice0: bit 7 of iic control register 0 (iicc0) chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 542 (6) iic function expansi on register 0 (iicx0) this register sets the function expansion of i 2 c. iicx0 can be set by a 1-bit or 8-bit memory manipulation instruction. the clx0 bit is set in combination with bits 3, 1, and 0 (smc0, cl01, and cl00) of iic clock select register 0 (iiccl0) (see 14.5.4 transfer clock setting method ). set iicx0 while bit 7 (iice0) of iic control register 0 (iicc0) is 0. reset signal generation clears this register to 00h. figure 14-10. format of iic function expansion register 0 (iicx0) address: fff55h after reset: 00h r/w symbol 7 6 5 4 3 2 1 <0> iicx0 0 0 0 0 0 0 0 clx0 table 14-2. selection clock setting iicx0 iiccl0 bit 0 bit 3 bit 1 bit 0 clx0 smc0 cl01 cl00 transfer clock (f clk /m) settable selection clock (f clk ) range operation mode 0 0 0 0 f clk /88 4.00 mhz to 8.4 mhz 0 0 0 1 f clk /172 8.38 mhz to 16.76 mhz 0 0 1 0 f clk /344 16.76 mhz to 20 mhz 0 0 1 1 f clk /44 2.00 mhz to 4.2 mhz normal mode (smc0 bit = 0) 0 1 0 f clk /48 7.60 mhz to 16.76 mhz 0 1 1 0 f clk /96 16.00 mhz to 20 mhz 0 1 1 1 f clk /24 4.00 mhz to 8.4 mhz fast mode (smc0 bit = 1) 1 0 setting prohibited 1 1 0 f clk /48 8.00 mhz to 8.38 mhz 1 1 1 0 setting prohibited 16.00 mhz to 16.76 mhz 1 1 1 1 f clk /24 4.00 mhz to 4.19 mhz fast mode (smc0 bit = 1) caution determine the transf er clock frequency of i 2 c by using clx0, smc0, cl01, and cl00 before enabling the operation (by setting bit 7 (iice0) of iic control register 0 (iicc0) to 1). to change the transfer clock frequency, clear iice0 once to 0. remarks 1. : don?t care 2 . f clk : cpu/peripheral hardware clock frequency chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 543 (7) 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 clock 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 iice0 (bit 7 of iic control register 0 (iicc0)) to 1 before setting the output mode because the p60/scl0 and p61/sda0 pins output a low level (fixed) when iice0 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 14-11. format of port mode register 6 (pm6) pm60 pm61 pm62 pm63 pm64 pm65 pm66 pm67 p6n pin i/o mode selection (n = 0 to 7) 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 chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 544 14.4 i 2 c bus mode functions 14.4.1 pin configuration the serial clock pin (scl0) and serial data bus pin (sda0) are configured as follows. (1) scl0....... this pin is used for serial clock input and output. this pin is an n-ch open-drain output for both master and slave devices. input is schmitt input. (2) sda0 ...... this pin is used fo r serial data input and output. this pin is an n-ch open-drain output for both master and slave devices. input is schmitt input. since outputs from the serial clock line and the serial data bus line are n-ch open-drai n outputs, an external pull-up resistor is required. figure 14-12. pin configuration diagram master device clock output (clock input) data output data input v ss v ss scl0 sda0 v dd v dd (clock output) clock input data output data input v ss v ss slave device scl0 sda0 chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 545 14.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 14-13 shows the transfer timing for the ?start conditi on?, ?address?, ?data?, and ?st op condition? output via the i 2 c bus?s serial data bus. figure 14-13. 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. 14.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 signal s that the master device gener ates to the slave device when starting a serial transfer. when the device is us ed as a slave, start conditions can be detected. figure 14-14. start conditions scl0 sda0 h a start condition is output when bit 1 (stt0) of iic control r egister 0 (iicc0) is set (to 1) after a stop condition has been detected (spd0: bit 0 = 1 in iic status register 0 (iic s0)). when a start condition is detected, bit 1 (std0) of iics0 is set (to 1). chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 546 14.5.2 addresses the address is defined by the 7 bits of data that follow the start condition. an address is a 7-bit data segment that is output in order to select one of t he slave devices that are connected to the master device via the bus lines. therefore, each slave device connected via the bus lines must have a unique address. the slave devices include hardware t hat detects the start condition and c hecks whether or not the 7-bit address data matches the data values stored in slave address register 0 (sva0). if the address data matches the sva0 values, the slave device is selected and communicates with the master device until th e master device generates a start condition or stop condition. figure 14-15. address scl0 sda0 intiic0 123456789 a6 a5 a4 a3 a2 a1 a0 r/w address note note intiic0 is not issued if data other than a local address or extension code is received during slave device operation. the slave address and the eighth bit, which spec ifies the transfer direction as described in 14.5.3 transfer direction specification below, are together written to iic shift r egister 0 (iic0) and are then output. received addresses are written to iic0. the slave address is assigned to the higher 7 bits of iic0. 14.5.3 transfer di rection specification in addition to the 7-bit address data, the master device s ends 1 bit that specifies t he transfer direction. when this transfer direction specificati on bit has a value of ?0?, it indicates that the master device is transmitting data to a slave device. when the transfer direction specification bit has a value of ?1?, it indicates that the master device is receiving data from a slave device. figure 14-16. transfer direction specification scl0 sda0 intiic0 123456789 a6 a5 a4 a3 a2 a1 a0 r/w transfer direction specification note note intiic0 is not issued if data other than a local address or extension code is received during slave device operation. chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 547 14.5.4 transfer clock setting method (1) selection clock setting method on the master side the i 2 c transfer clock frequency (f scl ) is calculated using the following expression. f scl = 1/(m t + t r + t f ) m = 24, 44, 48, 88, 96, 172, 344 (see table 14-3 selection clock setting ) t: 1/f clk t r : scl0 rise time t f : scl0 fall time for example, the i 2 c transfer clock frequency (f scl ) when f clk = 4.19 mhz, m = 88, t r = 200 ns, and t f = 50 ns is calculated using following expression. f scl = 1/(88 238.7 ns + 200 ns + 50 ns) ? 47.0 khz m t + t r + t f m/2 t m/2 t t f t r scl0 scl0 inversion scl0 inversion scl0 inversion the selection clock is set using a combination of bits 3, 1, and 0 (smc0, cl01, and cl00) of iic clock select register 0 (iiccl0) and bit 0 (clx0) of iic function expansion register 0 (iicx0). (2) selection clock setting method on the slave side to use as slave, set the bits 3, 1, and 0 (smc0, cl01, cl00) of the iic clock selection register (iicl0) and the bit 0 (clx0) of the iic function expansion register 0 (iicx0) according to the f clk (selectable selection clock range) and iic operation mode (normal or fast ) as defined in table 14-3. selection clock setting . chapter 14 serial interface iic0 user?s manual u17894ej8v0ud 548 table 14-3. selection clock setting iicx0 iiccl0 bit 0 bit 3 bit 1 bit 0 clx0 smc0 cl01 cl00 transfer clock (f clk /m) settable selection clock (f clk ) range operation mode 0 0 0 0 f clk /88 4.00 mhz to 8.4 mhz 0 0 0 1 f clk /172 8.38 mhz to 16.76 mhz 0 0 1 0 f clk /344 16.76 mhz to 20 mhz 0 0 1 1 f clk /44 2.00 mhz to 4.2 mhz normal mode (smc0 bit = 0) 0 1 0 f clk /48 7.60 mhz to 16.76 mhz 0 1 1 0 f clk /96 16.00 mhz to 20 mhz 0 1 1 1 f clk /24 4.00 mhz to 8.4 mhz fast mode (smc0 bit = 1) 1 0 setting prohibited 1 1 0 f clk /48 8.00 mhz to 8.38 mhz 1 1 1 0 setting prohibited 16.00 mhz to 16.76 mhz 1 1 1 1 f clk /24 4.00 mhz to 4.19 mhz fast mode (smc0 bit = 1) caution determine the transf er clock frequency of i 2 c by using clx0, smc0, cl01, and cl00 before enabling the operation (by setting bit 7 (iice0) of iic control register 0 (iicc0) to 1). to change the transfer clock frequency, clear iice0 once to 0. remarks 1. : don?t care 2 . f clk : cpu/peripheral hardware clock frequency 14.5.5 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 and processi ng is continued. whether ack has been detected can be checked by using bit 2 (ack d0) of iic status register 0 (iics0). when the master receives the last dat a item, it does not return ack and instead generates a stop condition. if a slave does not return ack after receiving data, the ma ster outputs a stop condition or restart condition 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 (ac ke0) of iic control register 0 (iicc0) to 1. bit 3 (trc0) of the iics0 register is set by the data of the eighth bit that follows 7-bit addre ss information. usually, set acke0 to 1 for reception (trc0 = 0). if a slave can receive no more data during reception (trc 0 = 0) or does not require the next data item, then the slave must inform the master, by clearing acke0 to 0, that it will not receive any more data. when the master does not require the next data item during reception (trc0 = 0), it must clear acke0 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). |