|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
revision date: jun. 03, 2008 16 h8s/2218 group , h8s/2212 group hardware manual renesas 16-bit single-chip microcomputer h8s family/h8s/2200 series rev.6.00 rej09b0074-0600 h8s/2218 HD64F2218 HD64F2218u hd6432217 h8s/2212 hd64f2212 hd64f2212u hd64f2211 hd64f2211u hd6432211 hd6432210 hd6432210s
rev.6.00 jun. 03, 2008 page ii of xlviii rej09b0074-0600 1. this document is provided for reference purposes only so that renesas customers may select the appropriate renesas products for their use. renesas neither makes warranties or representations with respect to the accuracy or completeness of the information contained in this document nor grants any license to any intellectual property rights or any other rights of renesas or any third party with respect to the information in this document. 2. renesas shall have no liability for damages or infringement of any intellectual property or other rights arising out of the use of any information in this document, including, but not limited to, product data, diagrams, charts, programs, algorithms, and application circuit examples. 3. you should not use the products or the technology described in this document for the purpose of military applications such as the development of weapons of mass destruction or for the purpose of any other military use. when exporting the products or technology described herein, you should follow the applicable export control laws and regulations, and procedures required by such laws and regulations. 4. all information included in this document such as product data, diagrams, charts, programs, algorithms, and application circuit examples, is current as of the date this document is issued. such information, however, is subject to change without any prior notice. before purchasing or using any renesas products listed in this document, please confirm the latest product information with a renesas sales office. also, please pay regular and careful attention to additional and different information to be disclosed by renesas such as that disclosed through our website. (http://www.renesas.com ) 5. renesas has used reasonable care in compiling the information included in this document, but renesas assumes no liability whatsoever for any damages incurred as a result of errors or omissions in the information included in this document. 6. when using or otherwise relying on the information in this document, you should evaluate the information in light of the total system before deciding about the applicability of such information to the intended application. renesas makes no representations, warranties or guaranties regarding the suitability of its products for any particular application and specifically disclaims any liability arising out of the application and use of the information in this document or renesas products. 7. with the exception of products specified by renesas as suitable for automobile applications, renesas products are not designed, manufactured or tested for applications or otherwise in systems the failure or malfunction of which may cause a direct threat to human life or create a risk of human injury or which require especially high quality and reliability such as safety systems, or equipment or systems for transportation and traffic, healthcare, combustion control, aerospace and aeronautics, nuclear power, or undersea communication transmission. if you are considering the use of our products for such purposes, please contact a renesas sales office beforehand. renesas shall have no liability for damages arising out of the uses set forth above. 8. notwithstanding the preceding paragraph, you should not use renesas products for the purposes listed below: (1) artificial life support devices or systems (2) surgical implantations (3) healthcare intervention (e.g., excision, administration of medication, etc.) (4) any other purposes that pose a direct threat to human life renesas shall have no liability for damages arising out of the uses set forth in the above and purchasers who elect to use renesas products in any of the foregoing applications shall indemnify and hold harmless renesas technology corp., its affiliated companies and their officers, directors, and employees against any and all damages arising out of such applications. 9. you should use the products described herein within the range specified by renesas, especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. renesas shall have no liability for malfunctions or damages arising out of the use of renesas products beyond such specified ranges. 10. although renesas endeavors to improve the quality and reliability of its products, ic products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. please be sure to implement safety measures to guard against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a renesas product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other applicable measures. among others, since the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or system manufactured by you. 11. in case renesas products listed in this document are detached from the products to which the renesas products are attached or affixed, the risk of accident such as swallowing by infants and small children is very high. you should implement safety measures so that renesas products may not be easily detached from your products. renesas shall have no liability for damages arising out of such detachment. 12. this document may not be reproduced or duplicated, in any form, in whole or in part, without prior written approval from renesas. 13. please contact a renesas sales office if you have any questions regarding the information contained in this document, renesas semiconductor products, or if you have any other inquiries. notes regarding these materials rev.6.00 jun. 03, 2008 page iii of xlviii rej09b0074-0600 general precautions in the handling of mpu/mcu products the following usage notes are applicable to all mpu/mcu products from renesas. for detailed usage notes on the products covered by this manual, refer to the relevant sections of the manual. if the descriptions under general precautions in the handling of mpu/mcu products and in the body of the manual differ from each other, the description in the body of the manual takes precedence. 1. handling of unused pins handle unused pins in accord with the directions given under handling of unused pins in the manual. ? the input pins of cmos products are generally in the high-impedance state. in operation with an unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of lsi, an associated shoot-through current flows internally, and malfunctions may occur due to the false recognition of the pin state as an input signal. unused pins should be handled as described under handling of unused pins in the manual. 2. processing at power-on the state of the product is undefined at the moment when power is supplied. ? the states of internal circuits in the lsi are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied. in a finished product where the reset signal is applied to the external reset pin, the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed. in a similar way, the states of pins in a product that is reset by an on-chip power-on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified. 3. prohibition of access to reserved addresses access to reserved addresses is prohibited. ? the reserved addresses are provided for the possible future expansion of functions. do not access these addresses; the correct operation of lsi is not guaranteed if they are accessed. 4. clock signals after applying a reset, only release the reset line after the operating clock signal has become stable. when switching the clock signal during program execution, wait until the target clock signal has stabilized. ? when the clock signal is generated with an external resonator (or from an external oscillator) during a reset, ensure that the reset line is only released after full stabilization of the clock signal. moreover, when switching to a clock signal produced with an external resonator (or by an external oscillator) while program execution is in progress, wait until the target clock signal is stable. 5. differences between products before changing from one product to another, i.e. to one with a different type number, confirm that the change will not lead to problems. ? the characteristics of mpu/mcu in the same group but having different type numbers may differ because of the differences in internal memory capacity and layout pattern. when changing to products of different type numbers, implement a system-evaluation test for each of the products. rev.6.00 jun. 03, 2008 page iv of xlviii rej09b0074-0600 configuration of this manual this manual comprises the following items: 1. general precautions on handling of product 2. configuration of this manual 3. preface 4. main revisions for this edition (only for revised versions) the list of revisions is a summary of points that have been revised or added to earlier versions. this does not include all of the revised contents. for details, see the actual locations in this manual. 5. contents 6. overview 7. description of functional modules ? cpu and system-control modules ? on-chip peripheral modules the configuration of the functional descrip tion of each module differs according to the module. however, the generic style includes the following items: i) feature ii) input/output pin iii) register description iv) operation v) usage note when designing an application system that includes this lsi, take notes into account. each section includes notes in relation to the descriptions given, and usage notes are given, as required, as the final part of each section. 8. list of registers 9. electrical characteristics 10. appendix 11. index rev.6.00 jun. 03, 2008 page v of xlviii rej09b0074-0600 preface this lsi is a microcomputer (mcu) made up of the h8s/2000 cpu with renesas technology's original architecture as its core, and the peripher al functions required to configure a system. the h8s/2000 cpu has an internal 32-bit configuration, sixteen 16-bit general registers, and a simple and optimized instruction set for high-speed operation. the h8s/2000 cpu can handle a 16-mbyte linear address space. this lsi is equipped with rom and ram, a direct memory access controller (dmac), a bus master, a 16-bit timer pulse unit (tpu), a watchdog timer (wdt), a realtime clock (rtc), a universal serial bus (usb), two types of serial communication interfaces (scis), an a/d converter, and i/o ports as on-chip peripheral modules for system configuration. a single-power flash memory (f-ztat ? *) version and masked rom version are available for this lsi's rom. the f-ztat version provides flexibility as it can be reprogrammed in no time to cope with all situations from the early stages of mass production to full-scale mass production. this is particularly applicable to application devices with specifications that will most probably change. this manual describes this lsi's hardware. note: * f-ztat is a trademark of renesas technology, corp. target users: this manual was written for users who will be using the h8s/2218 group and h8s/2212 group in the design of application systems. target users are expected to understand the fundamentals of electri cal circuits, logical circuits, and microcomputers. objective: this manual was written to explain the hardware functions and electrical characteristics of the h8s/2218 group and h8s/2212 group to the target users. refer to the h8s/2600 series, h8s/2000 series software manual for a detailed description of the instruction set. notes on reading this manual: ? in order to understand the overall functions of the chip read the manual according to the contents. this manual can be roughly categorized into parts on the cpu, system control functions, periph eral functions and electrical characteristics. ? in order to understand the details of the cpu's functions read the h8s/2600 series, h8s/2000 series software manual. rev.6.00 jun. 03, 2008 page vi of xlviii rej09b0074-0600 ? in order to understand the details of a register when its name is known read the index that is the final part of the manual to find the page number of the entry on the register. the addresses, bits, and initial values of the registers are summarized in section 21, list of registers. examples: register name: the following notation is used for cases when the same or a similar function, e.g. 16-bit timer pulse unit or serial communication, is implemented on more than one channel: xxx_n (xxx is the register name and n is the channel number) bit order: the msb is on the left and the lsb is on the right. number notation: binary is b'xxxx, hexadecimal is h'xxxx. signal notation: an overbar is added to a low-active signal: xxxx related manuals: the latest versions of all related manuals are available from our web site. please ensure you have the latest versions of all documents you require. http://www.renesas.com/eng/ h8s/2218 group, h8s/2212 group manuals: document title document no. h8s/2218 group, h8s/2212 group hardware manual this manual h8s/2600 series, h8s/2000 series software manual rej09b0139 user's manuals for development tools: document title document no. h8s, h8/300 series c/c++ compiler, assembler, optimizing linkage editor compiler package ver. 6.01 user's manual rej10b0161 h8s, h8/300 series simulator/debugger (for windows) user?s manual ade-702-037 h8s, h8/300 series high-performance embedded workshop, high-performance debugging interface tutorial ade-702-231 high-performance embedded workshop user's manual ade-702-201 application notes: document title document no. h8s, h8/300 series c/c++ compiler package application note rej05b0464 rev.6.00 jun. 03, 2008 page vii of xlviii rej09b0074-0600 main revisions for this edition item page revision (see manual for details) all ? h8s/2210s (hd6432210s) added 1.1 overview ? on-chip memory 2 table amended rom rom ram remarks part no. masked rom version 64 kbytes 32 kbytes 32 kbytes 8 kbytes 4 kbytes 4 kbytes ? ? ? hd6432211 hd6432210 hd6432210s h8s/2212 group ? compact package note deleted package body size pin pitch remarks code * tqfp-100 p-lfbga-112 lqfp-64 vqfn-64 12.0 2.0 mm 10.0 10.0 mm 10.0 10.0 mm 8.0 8.0 mm 0.4 mm 0.8 mm 0.5 mm 0.4 mm h8s/2218 group h8s/2212 group tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev tnp-64b, tnp-64bv note: * a v appended to the end of the package code indicates a lead-free version. . 1.2 internal block diagram 3 description amended ?the internal block diagram of the hd6432211, hd6432210 and hd6432210s is shown in figure 1.4. figure 1.1 internal block diagram of HD64F2218 and HD64F2218u notes amended notes: 1.the fwe pin is provided only in the HD64F2218 and HD64F2218u. 2.when emle = 0, boundary scan is available and the pins function as tdo, tck, tms, trst , and tdi, respectively. when emle = 1, h-udi function is available and the pins function as tdo, tck, tms, trst , and tdi, respectively. figure 1.4 internal block diagram of hd6432211, hd6432210 and hd6432210s 6 title amended 1.3 pin arrangement 7 description amended ?the pin arrangements of the hd6432211, hd6432210 and hd6432210s is shown in figures 1.10 and 1.12. rev.6.00 jun. 03, 2008 page viii of xlviii rej09b0074-0600 item page revision (see manual for details) 1.3 pin arrangement figure 1.10 pin arrangements of hd6432211, hd6432210 and hd6432210s (fp-64e, fp-64ev) 12 title amended figure 1.12 pin arrangements of hd6432211, hd6432210 and hd6432210s (tnp-64b, tnp-64bv) 14 title amended 3.4 memory map in each operating mode figure 3.3 memory map in each operating mode for hd64f2212, hd64f2212u, hd64f2211, hd64f2211u, hd6432211, hd6432210 and hd6432210s 79 title and figure amended mode 7 (advanced single-chip mode) rom: 32 kbytes ram: 4 kbytes h'007fff h'000000 on-chip rom hd6432210, hd6432210s 12.3.10 serial extended mode register b_0 (semrb_0) figure 12.3 examples of base clock when average transfer rate is selected (3) 390 figure amended 123 3 mhz 1.8421 mhz 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 18 19 20 21 23 22 24 25 26 2 3 4 5 6 7 8 9 10 11 12 14 13 15 16 27 30 31 32 33 34 35 36 37 28 29 123 12 mhz 7.3684 mhz 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 18 19 20 21 23 22 24 25 26 2 3 4 5 6 7 8 9 10 11 12 14 13 15 16 27 30 31 32 33 34 35 36 37 28 29 base clock 24 mhz/2 = 12 mhz 12 mhz (35/57) = 7.3684 mhz (average) 1 bit = base clock 16 * base clock with 460.526-kbps average transfer rate (acs3 to acs0 = b'1001) average transfer rate = 7.3684 mhz/16 = 460.526 kbps average error with 460.6kbps = -0.059% 1 bit = base clock 16 * base clock 24 mhz/8 = 3 mhz 3 mhz (35/57) = 1.8421 mhz (average) when = 24 mhz base clock with 115.132-kbps average transfer rate (acs3 to acs0 = b'1000) average transfer rate =1.8421 mhz/16 = 115.132 kbps average error with 115.2 kbps = -0.0059% rev.6.00 jun. 03, 2008 page ix of xlviii rej09b0074-0600 item page revision (see manual for details) 12.7.7 serial data transmission (except for block transfer mode) 432 description amended and added figure 12.31 shows a flowchart for transmission. a sequence of transmit operations can be performed automatically by specifying the dmac to be activated with a txi interrupt source. in a transmit operation, the tdre flag is set to 1 at the same time as the tend flag in ssr is set, and a txi interrupt will be generated if the tie bit in scr has been set to 1. if the txi request is designated beforehand as a dmac activation source, the dmac will be activated by the txi request, and transfer of the transmit data will be carried out. the tdre and tend flags are automatically cleared to 0 when data is transferred by the dmac. in the event of an error, the sci retransmits the same data automatically. during this period, the tend flag remains cleared to 0 and the dmac is not activated. therefore, the sci and dmac will automatically transmit the specified number of bytes in the event of an error, including retransmission. however, the ers flag is not cleared automatically when an error occurs, and so the rie bit should be set to 1 beforehand so that an eri request will be generated in the event of an error, and the ers flag will be cleared. when using the dmac for data transmission or reception, always make dmac settings and enable the dmac before making sci settings. for details on dmac settings, see section 7, dma controller (dmac). 12.7.8 serial data reception (except for block transfer mode) 435 description amended figure 12.33 shows a flowchart for reception. a sequence of receive operations can be performed automatically by specifying the dmac to be activated using an rxi interrupt source. in a receive operation, an rxi interrupt request is generated when the rdrf flag in ssr is set to 1. if the rxi request is designated beforehand as a dmac activation source, the dmac will be activated by the rxi request, and the receive data will be transferred. the rdrf flag is cleared to 0 automatically when data is transferred by the dmac. if an error occurs in receive mode and the orer or per flag is set to 1, a transfer error interrupt (eri) request will be generated. hence, so the error flag must be cleared to 0. in the event of an error, the dmac is not activated and receive data is skipped. therefore, receive data is transferred for only the specified number of bytes in the event of an error. even when a parity error occurs in receive mode and the per flag is set to 1, the data that has been received is transferred to rdr and can be read from there. rev.6.00 jun. 03, 2008 page x of xlviii rej09b0074-0600 item page revision (see manual for details) 14.5.3 suspend and resume operations figure 14.8 example flowchart of suspend and resume interrupt processing 503 figure amended suspend interrupt processing prohibit irq6 (clear irq6e in ier to 0) clear suspend flag (clear sprsi in uifr3 to 0) confirm that remote-wakeup is prohibited confirm that remote-wakeup is enabled enable usb module stop mode (set mstpb0 in mstpcrb to 1) set standby enable flag to 1 suspend state confirmed? (sprss in uifr3 = 1?) suspend state confirmed? (sprss in uifr3 = 1?) remote- wakeup enabled? (rwups in udrr = 1) yes yes yes no no * 3 * 1 * 2 enable irq6 interrupt (set irq6e in ier to 1) clear suspend flag (clear sprsi in uifr3 to 0) 14.5.9 stall operations figure 14.20 forcible stall by firmware 518 figure amended stall handshake stall to (2-1) or (3-1) (1-3) 1. scme is set to 0 2. epnstl is set to 1 3. set internal status bit to 1 4. transmit stall handshake internal status bit 0 1 epnstl 1 (scme = 0) rev.6.00 jun. 03, 2008 page xi of xlviii rej09b0074-0600 item page revision (see manual for details) 15.1 features 535 description amended ? conversion time: 8.1 s per channel (at 16-mhz operation), 10.7 s per channel (at 24-mhz operation), 21.8 s per channel (at 6-mhz operation) 16 ram 551 description amended ?the h8s/2210 and h8s/2210s has 4 kbytes of on-chip high- speed static ram. table amended product class rom type ram size ram address h8s/2212 group masked rom version 4 kbytes h'ffe000 to h'ffefbf h'ffffc0 to h'ffffff hd6432210 hd6432210s 17.4 input/output pins table 17.2 pin configuration 560 table amended pin name i/o function pf3, pf0, p16, p14 input sets this lsi's operating mode in programmer mode all emle input emulator enable txd2 output serial transmit data output rxd2 input serial receive data input HD64F2218, hd64f2212, hd64f2211 18.1 features 593 table amended product class rom size rom address (modes 6 and 7) h8s/2218 group h8s/2212 group 64 kbytes 64 kbytes 32 kbytes h'000000 to h'00ffff h'000000 to h'00ffff h'000000 to h'007fff hd6432217 hd6432211 hd6432210, hd6432210s 19.8 pll circuit for usb 604 description amended the pll circuit has the function of doubling or tripling the 16- mhz or 24-mhz clock from the main oscillator to generate the 48-mhz usb operating clock. . when the pll circuit is used, set the ucks3 to ucks0 bits of uctlr. for details, refer to section 14, universal serial bus (usb). when the pll circuit is not used, connect the plvcc pin to vcc and the pllvss pin to the ground (vss). figure 19.9 shows examples of external circuits peripheral to the pll. figure 19.9 example of pll circuit figure added rev.6.00 jun. 03, 2008 page xii of xlviii rej09b0074-0600 item page revision (see manual for details) 22.2 power supply voltage and operating frequency range figure 22.1 power supply voltage and operating ranges 658 figure replaced 22.3 dc characteristics 659 condition d added condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) table 22.3 permissible output currents 662 condition d added condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) 22.4.1 clock timing table 22.4 clock timing 664 condition d added condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) 664 - 665 table amended item unit symbol min. max. condition a min. max. condition b min. max. condition c min. max. test conditions condition d clock cycle time clock high pulse width clock low pulse width clock rise time clock fall time oscillation stabilization time at reset (crystal) oscillation stabilization time in software standby (crystal) external clock output stabilization delay time subclock stabilization time subclock oscillator frequency subclock ( sub) cycle time 62.5 20 20 ? ? 20 8 8 500 ? 166.6 ? ? 10 10 ? ? ? ? 2 41.6 13 13 ? ? 20 8 4 500 ? 166.6 ? ? 7 7 ? ? ? ? 2 41.6 13 13 ? ? 20 8 4 500 ? 62.5 ? ? 7 7 ? ? ? ? 2 ns ns ns ns ns ms ms ms s s khz s figure 22.3 figure 22.4 figures 20.4, 19.2 c l1 = c l2 = 10 to 22 pf figures 20.4, 19.2 c l1 = c l2 = 10 to 15 pf figure 22.4 t cyc t ch t cl t cr t cf t osc1 t osc2 t dext t osc3 f sub f sub 166.6 32.768 30.5 32.768 30.5 32.768 30.5 32.768 30.5 50 50 ? ? 40 16 16 1000 ? ? ? 25 25 ? ? ? ? 4 rev.6.00 jun. 03, 2008 page xiii of xlviii rej09b0074-0600 item page revision (see manual for details) 22.4.2 control signal timing table 22.5 control signal timing 666 condition d added condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) 22.4.3 bus timing table 22.6 bus timing 668 condition d added condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) 22.4.4 timing of on- chip supporting modules table 22.7 timing of on-chip supporting modules 675 condition d added condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) 22.6 a/d conversion characteristics table 22.9 a/d conversion characteristics 682 condition d added condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) 682 table amended item condition a min. typ. condition b, c, d max. min. typ. max. unit resolution conversion time analog input capacitance permissible signal-source impedance nonlinearity error offset error full-scale error quantization absolute accuracy 10 21.8 ? ? ? ? ? ? ? 10 ? ? ? ? ? ? ? ? 10 ? 20 5 6.0 4.0 4.0 0.5 8.0 10 8.1 ? ? ? ? ? ? ? 10 ? ? ? ? ? ? ? ? 10 ? 20 5 6.0 4.0 4.0 0.5 6.0 bits s pf k lsb lsb lsb lsb lsb rev.6.00 jun. 03, 2008 page xiv of xlviii rej09b0074-0600 item page revision (see manual for details) b. product model lineup 689 - 690 table amended and note deleted product class part no. model name marking package (code) h8s/2212 group masked rom version hd6432211 hd6432210 hd6432210s hd6432211( *** )fp hd6432211( *** )np hd6432210( *** )fp hd6432210( *** )np hd6432210s( *** )fp hd6432210s( *** )np 2211( *** )fp 2211( *** )np 2210( *** )fp 2210( *** )np 2210s( *** )fp 2210s( *** )np 64-pin lqfp (fp-64e, fp-64ev) 64-pin vqfn (tnp-64b, tnp-64bv) 64-pin lqfp (fp-64e, fp-64ev) 64-pin vqfn (tnp-64b, tnp-64bv) 64-pin lqfp (fp-64e, fp-64ev) 64-pin vqfn (tnp-64b, tnp-64bv) all trademarks and registered trademarks are the property of their respective owners. rev.6.00 jun. 03, 2008 page xiii of xlvi rej09b0074-0600 contents section 1 overview .............................................................................................................1 1.1 overview....................................................................................................................... ....1 1.2 internal block diagram.....................................................................................................3 1.3 pin arrangements..............................................................................................................7 1.4 pin functions in each operating mode ............................................................................15 1.5 pin functions .................................................................................................................. ..21 section 2 cpu ......................................................................................................................31 2.1 features ....................................................................................................................... ......31 2.1.1 differences between h8s/2600 cpu and h8s/2000 cpu ..................................32 2.1.2 differences from h8/300 cpu.............................................................................33 2.1.3 differences from h8/300h cpu..........................................................................33 2.2 cpu operating modes ......................................................................................................34 2.2.1 normal mode .......................................................................................................34 2.2.2 advanced mode ...................................................................................................36 2.3 address space .................................................................................................................. .38 2.4 register configuration ......................................................................................................39 2.4.1 general registers .................................................................................................40 2.4.2 program counter (pc) .........................................................................................41 2.4.3 extended control register (exr) .......................................................................41 2.4.4 condition-code register (ccr) ..........................................................................42 2.4.5 initial register values..........................................................................................43 2.5 data formats ................................................................................................................... ..43 2.5.1 general register data formats ............................................................................43 2.5.2 memory data formats .........................................................................................45 2.6 instruction set ................................................................................................................ ...45 2.6.1 table of instructions classified by function .......................................................47 2.6.2 basic instruction formats ....................................................................................57 2.7 addressing modes and effective address calculation .....................................................58 2.7.1 register direct?rn.............................................................................................58 2.7.2 register indirect?@ern ....................................................................................58 2.7.3 register indirect with displacement?@(d:16, ern) or @(d:32, ern)..............59 2.7.4 register indirect with post-increment or pre-decrement?@ern+ or @-ern ..59 2.7.5 absolute address?@aa:8, @aa:16, @aa:24, or @aa:32....................................59 2.7.6 immediate?#xx:8, #xx:16, or #xx:32 .................................................................60 2.7.7 program-counter relative?@(d:8, pc) or @(d:16, pc)....................................60 2.7.8 memory indirect?@@aa:8 ................................................................................61 rev.6.00 jun. 03, 2008 page xiv of xlvi rej09b0074-0600 2.7.9 effective address calculation ..............................................................................62 2.8 processing states .............................................................................................................. .64 2.9 usage notes.................................................................................................................... ...66 2.9.1 note on tas instruction usage ...........................................................................66 2.9.2 stm/ltm instruction usage ...............................................................................66 2.9.3 note on bit manipulation instructions .................................................................66 2.9.4 accessing registers containing write-only bits ................................................68 section 3 mcu operating modes ...................................................................................71 3.1 operating mode selection .................................................................................................71 3.2 register descriptions.........................................................................................................7 2 3.2.1 mode control register (mdcr)..........................................................................72 3.2.2 system control register (syscr) ......................................................................72 3.3 operating mode descriptions............................................................................................74 3.3.1 mode 4 (supported only by the h8s/2218 group)..............................................74 3.3.2 mode 5 (supported only by the h8s/2218 group)..............................................74 3.3.3 mode 6 (supported only by the h8s/2218 group)..............................................75 3.3.4 mode 7 .................................................................................................................75 3.3.5 pin functions........................................................................................................76 3.4 memory map in each operating mode.............................................................................77 section 4 exception handling ..........................................................................................81 4.1 exception handling types and priority ............................................................................81 4.2 exception sources and exception vector table................................................................81 4.3 reset .......................................................................................................................... ........83 4.3.1 reset types ..........................................................................................................83 4.3.2 reset exception handling ....................................................................................84 4.3.3 interrupts after reset ............................................................................................86 4.3.4 state of on-chip peripheral m odules after reset release ...................................86 4.4 traces ......................................................................................................................... .......87 4.5 interrupts ..................................................................................................................... ......87 4.6 trap instruction ............................................................................................................... ..88 4.7 stack status after exception handling ..............................................................................89 4.8 notes on use of the stack .................................................................................................90 section 5 interrupt controller ...........................................................................................91 5.1 features ....................................................................................................................... ......91 5.2 input/output pins .............................................................................................................. 93 5.3 register descriptions.........................................................................................................9 3 5.3.1 interrupt priority registers a to g, j, k, m (ipra to iprg, iprj, iprk, iprm) ...................................................................94 rev.6.00 jun. 03, 2008 page xv of xlvi rej09b0074-0600 5.3.2 irq enable register (ier) ..................................................................................95 5.3.3 irq sense control registers h and l (iscrh, iscrl).....................................96 5.3.4 irq status register (isr)....................................................................................98 5.4 interrupt sources .............................................................................................................. .99 5.4.1 external interrupts ...............................................................................................99 5.4.2 internal interrupts.................................................................................................100 5.5 interrupt exception handling vector table......................................................................101 5.6 interrupt control modes and interrupt operation .............................................................103 5.6.1 interrupt control mode 0 .....................................................................................103 5.6.2 interrupt control mode 2 .....................................................................................105 5.6.3 interrupt exception handling sequence ..............................................................107 5.6.4 interrupt res ponse times ....................................................................................108 5.6.5 dmac activation by interrupt............................................................................109 5.7 usage notes .................................................................................................................... ..112 5.7.1 contention between interrupt generation and disabling.....................................112 5.7.2 instructions that disable interrupts ......................................................................113 5.7.3 times when interrupts are disabled ...................................................................113 5.7.4 interrupts during execution of eepmov instruction..........................................113 5.7.5 irq interrupt........................................................................................................113 5.7.6 nmi interrupt usage notes..................................................................................114 section 6 bus controller ....................................................................................................115 6.1 features ....................................................................................................................... ......115 6.2 input/output pins .............................................................................................................. 117 6.3 register descriptions ........................................................................................................11 8 6.3.1 bus width control re gister (a bwcr) ...............................................................118 6.3.2 access state control register (astcr) .............................................................119 6.3.3 wait control registers h and l (wcrh, wcrl)..............................................120 6.3.4 bus control register h (bcrh)..........................................................................124 6.3.5 bus control regist er l ( bcrl) ..........................................................................125 6.3.6 pin function control register (pfcr) ................................................................126 6.4 bus control .................................................................................................................... ...127 6.4.1 area divisions .....................................................................................................127 6.4.2 bus specifications................................................................................................128 6.4.3 bus interface for each area.................................................................................129 6.4.4 chip select signals ..............................................................................................130 6.5 basic timing ................................................................................................................... ..131 6.5.1 on-chip memory (rom, ram) access timing ................................................131 6.5.2 on-chip peripheral module access timing........................................................132 6.5.3 external address space access timing ..............................................................133 6.6 basic bus interface ...........................................................................................................1 34 rev.6.00 jun. 03, 2008 page xvi of xlvi rej09b0074-0600 6.6.1 data size and data alignment (supported only by the h8s/2218 group) .........134 6.6.2 valid strobes ........................................................................................................135 6.6.3 basic timing ........................................................................................................136 6.6.4 wait control.........................................................................................................145 6.7 burst rom interface .........................................................................................................147 6.7.1 basic timing ........................................................................................................147 6.7.2 wait control.........................................................................................................149 6.8 idle cycle ..................................................................................................................... .....149 6.9 bus release .................................................................................................................... ...153 6.9.1 bus release usage note.......................................................................................154 6.10 bus arbitration ................................................................................................................ ..155 6.10.1 operation..............................................................................................................155 6.10.2 bus transfer timing ............................................................................................155 6.10.3 external bus release usage note ........................................................................156 6.11 resets and the bus controller ...........................................................................................156 section 7 dma controller (dmac) ..............................................................................157 7.1 features ....................................................................................................................... ......157 7.2 register configuration ......................................................................................................159 7.3 register descriptions.........................................................................................................1 61 7.3.1 memory address registers (mar)......................................................................161 7.3.2 i/o address register (ioar)...............................................................................161 7.3.3 execute transfer count register (etcr)............................................................162 7.3.4 dma control register (dmacr) .......................................................................163 7.3.5 dma band control register (dmabcr) ...........................................................169 7.4 operation...................................................................................................................... .....177 7.4.1 transfer modes ....................................................................................................177 7.4.2 sequential mode...................................................................................................178 7.4.3 idle mode .............................................................................................................181 7.4.4 repeat mode ........................................................................................................183 7.4.5 normal mode .......................................................................................................186 7.4.6 block transfer mode............................................................................................189 7.4.7 dmac activation sources...................................................................................194 7.4.8 basic dmac bus cycles .....................................................................................196 7.4.9 dmac bus cycles (dual address mode) ...........................................................197 7.4.10 dmac multi-channel operation.........................................................................202 7.4.11 relation between the dmac and external bus requests....................................203 7.4.12 nmi interrupts and dmac ..................................................................................203 7.4.13 forced termination of dmac operation ............................................................204 7.4.14 clearing full address mode ................................................................................205 7.5 interrupts ..................................................................................................................... ......206 rev.6.00 jun. 03, 2008 page xvii of xlvi rej09b0074-0600 7.6 usage notes .................................................................................................................... ..207 7.6.1 dmac register access during operation...........................................................207 7.6.2 module stop.........................................................................................................208 7.6.3 medium-speed mode...........................................................................................208 7.6.4 activation source acceptance .............................................................................209 7.6.5 internal interrupt after end of transfer................................................................209 7.6.6 channel re-setting ..............................................................................................209 section 8 i/o ports ..............................................................................................................211 8.1 port 1......................................................................................................................... ........216 8.1.1 port 1 data direction register (p1ddr).............................................................216 8.1.2 port 1 data register (p1dr)................................................................................217 8.1.3 port 1 register (port1)......................................................................................217 8.1.4 pin functions .......................................................................................................218 8.2 port 3......................................................................................................................... ........223 8.2.1 port 3 data direction register (p3ddr).............................................................223 8.2.2 port 3 data register (p3dr)................................................................................224 8.2.3 port 3 register (port3)......................................................................................224 8.2.4 port 3 open-drain control register (p3odr) ....................................................225 8.2.5 pin functions .......................................................................................................225 8.3 port 4......................................................................................................................... ........227 8.3.1 port 4 register (port4)......................................................................................227 8.3.2 pin function .........................................................................................................227 8.4 port 7......................................................................................................................... ........228 8.4.1 port 7 data direction register (p7ddr).............................................................228 8.4.2 port 7 data register (p7dr)................................................................................229 8.4.3 port 7 register (port7)......................................................................................230 8.4.4 pin functions .......................................................................................................231 8.5 port 9......................................................................................................................... ........232 8.5.1 port 9 register (port9)......................................................................................232 8.5.2 pin function .........................................................................................................232 8.6 port a......................................................................................................................... .......233 8.6.1 port a data direction register (paddr) ...........................................................233 8.6.2 port a data register (padr) ..............................................................................234 8.6.3 port a register (porta) ....................................................................................234 8.6.4 port a pull-up mos control register (papcr) ................................................235 8.6.5 port a open-drain control register (paodr) ..................................................235 8.6.6 pin functions .......................................................................................................236 8.6.7 port a input pull-up mos states........................................................................238 8.7 port b (h8s/2218 group only) ........................................................................................239 8.7.1 port b data direction register (pbddr)............................................................239 rev.6.00 jun. 03, 2008 page xviii of xlvi rej09b0074-0600 8.7.2 port b data register (pbdr)...............................................................................240 8.7.3 port b register (portb).....................................................................................240 8.7.4 port b pull-up mos control register (pbpcr) .................................................241 8.7.5 pin functions........................................................................................................242 8.7.6 port b input pull-up mos states ........................................................................244 8.8 port c (h8s/2218 group only).........................................................................................245 8.8.1 port c data direction register (pcddr)............................................................245 8.8.2 port c data register (pcdr)...............................................................................246 8.8.3 port c register (portc).....................................................................................246 8.8.4 port c pull-up mos control register (pcpcr) .................................................247 8.8.5 pin functions........................................................................................................247 8.8.6 port c input pull- up mos states ........................................................................249 8.9 port d (h8s/2218 group only).........................................................................................250 8.9.1 port d data direction register (pdddr) ...........................................................250 8.9.2 port d data register (pddr) ..............................................................................251 8.9.3 port d register (portd) ....................................................................................251 8.9.4 port d pull-up mos control register (pdpcr).................................................252 8.9.5 pin functions........................................................................................................252 8.9.6 port d input pull- up mos states ........................................................................254 8.10 port e......................................................................................................................... ........255 8.10.1 port e data direction register (peddr) ............................................................255 8.10.2 port e data register (pedr) ...............................................................................256 8.10.3 port e register (porte) .....................................................................................256 8.10.4 port e pull-up mos control register (pepcr) .................................................257 8.10.5 pin functions........................................................................................................257 8.10.6 port e input pull-up mos states.........................................................................260 8.11 port f ......................................................................................................................... ........261 8.11.1 port f data direction register (pfddr).............................................................262 8.11.2 port f data register (pfdr)................................................................................263 8.11.3 port f register (portf)......................................................................................263 8.11.4 clock output control register (outcr)............................................................264 8.11.5 pin functions........................................................................................................264 8.12 port g ......................................................................................................................... .......267 8.12.1 port g data direction register (pgddr) ...........................................................268 8.12.2 port g data register (pgdr) ..............................................................................269 8.12.3 port g register (portg) ....................................................................................269 8.12.4 pin functions........................................................................................................270 8.13 handling of unused pins...................................................................................................271 section 9 16-bit timer pulse unit (tpu) .....................................................................273 9.1 features ....................................................................................................................... ......273 rev.6.00 jun. 03, 2008 page xix of xlvi rej09b0074-0600 9.2 input/output pins .............................................................................................................. 277 9.3 register descriptions ........................................................................................................27 8 9.3.1 timer control register (tcr) .............................................................................279 9.3.2 timer mode register (tmdr) ............................................................................282 9.3.3 timer i/o control register (tior) .....................................................................284 9.3.4 timer interrupt enable register (tier) ..............................................................293 9.3.5 timer status register (tsr)................................................................................294 9.3.6 timer counter (tcnt)........................................................................................297 9.3.7 timer general register (tgr) ............................................................................297 9.3.8 timer start register (tstr)................................................................................297 9.3.9 timer synchro register (tsyr) .........................................................................298 9.4 interface to bus master .....................................................................................................299 9.4.1 16-bit registers ...................................................................................................299 9.4.2 8-bit registers .....................................................................................................299 9.5 operation...................................................................................................................... .....301 9.5.1 basic functions....................................................................................................301 9.5.2 synchronous operation........................................................................................307 9.5.3 buffer operation ..................................................................................................309 9.5.4 pwm modes ........................................................................................................313 9.5.5 phase counting mode ..........................................................................................317 9.6 interrupts ..................................................................................................................... ......322 9.6.1 interrupt source and priority................................................................................322 9.6.2 dmac activation................................................................................................323 9.6.3 a/d converter activation....................................................................................323 9.7 operation timing..............................................................................................................3 24 9.7.1 input/output timing ............................................................................................324 9.7.2 interrupt signal timing........................................................................................327 9.8 usage notes .................................................................................................................... ..331 section 10 watchdog timer (wdt) ..............................................................................339 10.1 features ....................................................................................................................... ......339 10.2 register descriptions ........................................................................................................34 0 10.2.1 timer counter (tcnt)........................................................................................340 10.2.2 timer control/status register (tcsr) ................................................................340 10.2.3 reset control/status register (rstcsr) ............................................................342 10.3 operation...................................................................................................................... .....343 10.3.1 watchdog ti mer mode ........................................................................................343 10.3.2 timing of setting of watchdog timer overflow flag (wovf) .........................344 10.3.3 interval timer mode ............................................................................................344 10.3.4 timing of setting of overflow flag (ovf) .........................................................345 10.4 interrupts ..................................................................................................................... ......345 rev.6.00 jun. 03, 2008 page xx of xlvi rej09b0074-0600 10.5 usage notes.................................................................................................................... ...346 10.5.1 notes on register access .....................................................................................346 10.5.2 contention between timer counter (tcnt) write and increment......................347 10.5.3 changing value of cks2 to cks0 ......................................................................348 10.5.4 switching between watchdog timer mode and interval timer mode ................348 10.5.5 internal reset in watchdog timer mode .............................................................348 10.5.6 ovf flag clearing in interval timer mode.........................................................348 section 11 realtime clock (rtc) ..................................................................................349 11.1 features ....................................................................................................................... ......349 11.2 input/output pin ............................................................................................................... .350 11.3 register descriptions.........................................................................................................3 50 11.3.1 second data register (rsecdr) ........................................................................350 11.3.2 minute data register (rmindr) ........................................................................351 11.3.3 hour data register (rhrdr)..............................................................................352 11.3.4 day-of-week data register (rwkdr)...............................................................353 11.3.5 rtc control regist er 1 (rt ccr1) .....................................................................354 11.3.6 rtc control regist er 2 (rt ccr2) .....................................................................355 11.3.7 clock source select register (rtccsr) ............................................................356 11.3.8 extended module stop register (exmdlstp) ..................................................357 11.4 operation...................................................................................................................... .....358 11.4.1 initial settings of registers after power-on and resetting procedure .................358 11.4.2 time data reading procedure..............................................................................359 11.5 interrupt source ............................................................................................................... ..360 11.6 operating state in each mode...........................................................................................361 11.7 usage notes.................................................................................................................... ...362 section 12 serial communication interface .................................................................363 12.1 features ....................................................................................................................... ......363 12.1.1 block diagram .....................................................................................................365 12.2 input/output pins .............................................................................................................. 367 12.3 register descriptions.........................................................................................................3 67 12.3.1 receive shift register (rsr)...............................................................................368 12.3.2 receive data register (rdr) ..............................................................................368 12.3.3 transmit data register (tdr) .............................................................................368 12.3.4 transmit shift register (tsr)..............................................................................368 12.3.5 serial mode register (smr) ................................................................................369 12.3.6 serial control register (scr) ..............................................................................373 12.3.7 serial status re gister (ssr).................................................................................377 12.3.8 smart card mode register (scmr) ....................................................................383 12.3.9 serial extended mode register a_0 (semra_0)...............................................384 rev.6.00 jun. 03, 2008 page xxi of xlvi rej09b0074-0600 12.3.10 serial extended mode register b_0 (semrb_0)...............................................386 12.3.11 bit rate register (brr) ......................................................................................395 12.4 operation in asynchronous mode ....................................................................................403 12.4.1 data transfer format ...........................................................................................404 12.4.2 receive data sampling timing and reception margin in asynchronous mode 405 12.4.3 clock....................................................................................................................406 12.4.4 sci initialization (asynchronous mode) .............................................................407 12.4.5 data transmission (asynchronous mode)...........................................................408 12.4.6 serial data reception (asynchronous mode)......................................................410 12.5 multiprocessor communi cation function.........................................................................413 12.5.1 multiprocessor serial da ta transmission ............................................................415 12.5.2 multiprocessor serial data reception..................................................................416 12.6 operation in clocked synchronou s mode ........................................................................419 12.6.1 clock....................................................................................................................419 12.6.2 sci initialization (clocked synchronous mode) .................................................420 12.6.3 serial data transmission (clocked synchronous mode) ....................................421 12.6.4 serial data reception (clocked synchronous mode)..........................................424 12.6.5 simultaneous serial data transmission and reception (clocked synchr onous m ode) .............................................................................425 12.7 operation in smart card interface ....................................................................................427 12.7.1 pin connection example......................................................................................427 12.7.2 data format (except for block transfer mode) ..................................................428 12.7.3 clock....................................................................................................................429 12.7.4 block transfer mode ...........................................................................................429 12.7.5 receive data sampling timing and reception margin.......................................430 12.7.6 initializa tion .........................................................................................................431 12.7.7 serial data transmission (except for block transfer mode)..............................432 12.7.8 serial data reception (except for block transfer mode) ...................................435 12.7.9 clock output control...........................................................................................436 12.8 sci select function (clocked synchronous mode)..........................................................438 12.9 interrupts ..................................................................................................................... ......440 12.9.1 interrupts in normal serial communication interface mode...............................440 12.9.2 interrupts in smart card interface mode .............................................................441 12.10 usage notes .................................................................................................................... ..441 12.10.1 module stop mode setting ..................................................................................441 12.10.2 break detection and processing (asynchronous mode only).............................441 12.10.3 mark state and break detection (asynchronous mode only) ............................442 12.10.4 receive error flags and transmit operations (clocked synchronous mode only).....................................................................442 12.10.5 restrictions on use of dmac .............................................................................442 12.10.6 operation in case of mode transition.................................................................443 rev.6.00 jun. 03, 2008 page xxii of xlvi rej09b0074-0600 12.10.7 switching from sck pin function to port pin function:.....................................447 section 13 boundary scan function ..............................................................................449 13.1 features ....................................................................................................................... ......449 13.2 pin configuration .............................................................................................................. 451 13.3 register descriptions.........................................................................................................4 52 13.3.1 instruction register (instr) ...............................................................................452 13.3.2 idcode register (idcode)..............................................................................454 13.3.3 bypass register (bypass)..............................................................................454 13.3.4 boundary scan register (bscanr)....................................................................454 13.4 boundary scan function operation ..................................................................................462 13.4.1 tap controller.....................................................................................................462 13.5 usage notes.................................................................................................................... ...463 section 14 universal serial bus (usb) .........................................................................465 14.1 features ....................................................................................................................... ......465 14.2 input/output pins .............................................................................................................. 467 14.3 register descriptions.........................................................................................................4 67 14.3.1 usb control register (uctlr) ..........................................................................468 14.3.2 usb dmac transfer request register (udmar) ............................................471 14.3.3 usb device resume register (udrr) ...............................................................472 14.3.4 usb trigger register 0 (utrg0) .......................................................................473 14.3.5 usb fifo clear register 0 (ufclr0) ...............................................................475 14.3.6 usb endpoint stall regi ster 0 (uestl0) ...........................................................476 14.3.7 usb endpoint stall regi ster 1 (uestl1) ...........................................................477 14.3.8 usb endpoint data regi ster 0s (uedr0s) .........................................................477 14.3.9 usb endpoint data regi ster 0i (uedr0i) ..........................................................477 14.3.10 usb endpoint data regi ster 0o (u edr0o) ........................................................478 14.3.11 usb endpoint data regi ster 3 (uedr3) ............................................................478 14.3.12 usb endpoint data regi ster 1 (uedr1) ............................................................478 14.3.13 usb endpoint data regi ster 2 (uedr2) ............................................................479 14.3.14 usb endpoint receive data size register 0o (uesz0o)....................................479 14.3.15 usb endpoint receive data size register 2 (uesz2)........................................479 14.3.16 usb interrupt flag re gister 0 (uifr0) ...............................................................480 14.3.17 usb interrupt flag re gister 1 (uifr1) ...............................................................482 14.3.18 usb interrupt flag re gister 3 (uifr3) ...............................................................483 14.3.19 usb interrupt enable register 0 (uier0) ...........................................................484 14.3.20 usb interrupt enable register 1 (uier1) ...........................................................485 14.3.21 usb interrupt enable register 3 (uier3) ...........................................................485 14.3.22 usb interrupt select re gister 0 (uisr0).............................................................486 14.3.23 usb interrupt select re gister 1 (uisr1).............................................................486 rev.6.00 jun. 03, 2008 page xxiii of xlvi rej09b0074-0600 14.3.24 usb interrupt select re gister 3 (uisr3) ............................................................487 14.3.25 usb data status register (udsr) ......................................................................487 14.3.26 usb configuration value register (ucvr) .......................................................488 14.3.27 usb test register 0 (utstr0) ..........................................................................489 14.3.28 usb test register 1 (utstr1) ..........................................................................490 14.3.29 usb test registers 2 and a to f (utstr2, utstra to utstrf)..................492 14.3.30 module stop control register b (mstpcrb)....................................................492 14.3.31 extended module stop register (exmdlstp)..................................................493 14.4 interrupt sources .............................................................................................................. .494 14.5 communication operation ................................................................................................497 14.5.1 initializa tion .........................................................................................................497 14.5.2 usb cable connection/ disconnection ................................................................498 14.5.3 suspend and resume operations .........................................................................502 14.5.4 control transfer...................................................................................................506 14.5.5 interrupt-in transfer (endpoint 3) .......................................................................512 14.5.6 bulk-in transfer (dual fifos) (en dpoint 1).......................................................513 14.5.7 bulk-out transfer (dual fifos) (en dpoint 2) ....................................................515 14.5.8 processing of usb standard commands and class/vendor commands.............516 14.5.9 stall operations....................................................................................................517 14.6 dma transfer specifications ...........................................................................................520 14.6.1 dmac transfer by usb request........................................................................520 14.6.2 dma transfer by auto-request..........................................................................522 14.7 usb external circuit example .........................................................................................525 14.8 usage notes .................................................................................................................... ..527 14.8.1 emulator usage notes .........................................................................................527 14.8.2 bus interface ........................................................................................................527 14.8.3 operating frequency............................................................................................527 14.8.4 setup data reception...........................................................................................528 14.8.5 fifo clear ...........................................................................................................528 14.8.6 irq6 interru pt......................................................................................................528 14.8.7 data register overread or overwrite ..................................................................528 14.8.8 reset.....................................................................................................................529 14.8.9 ep0 interrupt sources assignment ......................................................................529 14.8.10 level shifter for vbus and irqx pins ...............................................................530 14.8.11 usb endpoint data read and write....................................................................530 14.8.12 restrictions on entering and canceling power-down mode...............................530 14.8.13 usb external circuit example ............................................................................532 14.8.14 pin processing when usb not used ...................................................................533 14.8.15 notes on tr interrupt ..........................................................................................533 rev.6.00 jun. 03, 2008 page xxiv of xlvi rej09b0074-0600 section 15 a/d converter .................................................................................................535 15.1 features ....................................................................................................................... ......535 15.2 input/output pins .............................................................................................................. 537 15.3 register descriptions.........................................................................................................5 37 15.3.1 a/d data registers a to d (addra to addrd) ..............................................538 15.3.2 a/d control/status register (adcsr)................................................................538 15.3.3 a/d control register (adcr).............................................................................540 15.4 interface to bus master .....................................................................................................541 15.5 operation...................................................................................................................... .....542 15.5.1 single mode .........................................................................................................542 15.5.2 scan mode............................................................................................................543 15.5.3 input sampling and a/d conversion time ..........................................................544 15.5.4 external trigger input timing .............................................................................545 15.6 interrupts ..................................................................................................................... ......546 15.7 a/d conversion precision definitions ..............................................................................546 15.8 usage notes.................................................................................................................... ...548 15.8.1 module stop mode setting...................................................................................548 15.8.2 permissible signal source impedance..................................................................548 15.8.3 influences on absolute precision .........................................................................548 15.8.4 range of analog power supply and other pin settings ......................................549 15.8.5 notes on board design.........................................................................................549 section 16 ram ...................................................................................................................551 section 17 flash memory (f-ztat version) .............................................................553 17.1 features ....................................................................................................................... ......553 17.2 mode transitions............................................................................................................... 554 17.3 block configuration ..........................................................................................................55 8 17.4 input/output pins .............................................................................................................. 560 17.5 register descriptions.........................................................................................................5 60 17.5.1 flash memory control register 1 (flmcr1) .....................................................561 17.5.2 flash memory control register 2 (flmcr2) .....................................................562 17.5.3 erase block regist er 1 (e br1)............................................................................563 17.5.4 erase block regist er 2 (e br2)............................................................................564 17.5.5 ram emulation register (ramer) ...................................................................565 17.5.6 serial control register x (scrx) .......................................................................566 17.6 on-board programming modes ........................................................................................567 17.6.1 sci boot mode (HD64F2218, hd64f2212, and hd64f2211)...........................567 17.6.2 usb boot mode (HD64F2218u, hd64f2212u, and hd64f2211u).................571 17.6.3 programming/erasing in user program mode .....................................................576 17.7 flash memory emulation in ram ....................................................................................577 rev.6.00 jun. 03, 2008 page xxv of xlvi rej09b0074-0600 17.8 flash memory programming/erasing ...............................................................................579 17.8.1 program/progra m-verify .....................................................................................579 17.8.2 erase/erase-verify...............................................................................................581 17.9 program/erase protection..................................................................................................583 17.9.1 hardware protection ............................................................................................583 17.9.2 software protection..............................................................................................583 17.9.3 error protection....................................................................................................583 17.10 interrupt handling when programming/erasing flash memory.......................................584 17.11 programmer mode ............................................................................................................585 17.12 power-down states for flash memory.............................................................................586 17.13 flash memory programming and erasing precautions .....................................................587 17.14 note on switching from f-ztat version to masked rom version ..............................592 section 18 masked rom ..................................................................................................593 18.1 features ....................................................................................................................... ......593 section 19 clock pulse generator ..................................................................................595 19.1 register descriptions ........................................................................................................59 6 19.1.1 system clock control register (sckcr) ...........................................................596 19.1.2 low power control register (lpwrcr)............................................................597 19.2 system clock oscillator....................................................................................................600 19.2.1 connecting a crystal resonator...........................................................................600 19.2.2 inputting external clock......................................................................................601 19.3 duty adjustment circuit ...................................................................................................602 19.4 medium-speed clock divider ..........................................................................................602 19.5 bus master clock selection circuit ..................................................................................602 19.6 subclock os cillator ...........................................................................................................6 03 19.6.1 connecting 32.768-khz cr ystal resonator..........................................................603 19.6.2 handling pins when subclock not required.......................................................603 19.7 subclock waveform generation circuit ...........................................................................604 19.8 pll circuit for usb .........................................................................................................604 19.9 usage notes .................................................................................................................... ..605 19.9.1 note on crystal resonator ...................................................................................605 19.9.2 note on board design..........................................................................................605 19.9.3 note on switchover of external clock ................................................................605 section 20 power-down modes ......................................................................................607 20.1 register descriptions ........................................................................................................61 1 20.1.1 standby control register (sbycr) ....................................................................611 20.1.2 timer control/status register (tcsr_1) ............................................................613 20.1.3 module stop control registers a to c (mstpcra to mstp crc) ...................614 rev.6.00 jun. 03, 2008 page xxvi of xlvi rej09b0074-0600 20.1.4 extended module stop register (exmdlstp) ..................................................617 20.2 medium-speed mode ........................................................................................................617 20.3 sleep mode..................................................................................................................... ...618 20.3.1 transition to sleep mode .....................................................................................618 20.3.2 exiting sleep mode ..............................................................................................618 20.4 software standby mode ....................................................................................................619 20.4.1 transition to software standby mode..................................................................619 20.4.2 clearing software standby mode ........................................................................619 20.4.3 setting oscillation stabilization time after clearing software standby mode ...620 20.4.4 software standby mode application example ....................................................620 20.5 hardware standby mode...................................................................................................621 20.5.1 transition to hardware standby mode ................................................................621 20.5.2 clearing hardware standby mode .......................................................................621 20.5.3 hardware standby mode timing .........................................................................622 20.5.4 hardware standby mode timings........................................................................622 20.6 module st op mode ............................................................................................................623 20.7 watch mode ..................................................................................................................... .624 20.7.1 transition to watch mode....................................................................................624 20.7.2 exiting watch mode ............................................................................................624 20.8 subsleep mode .................................................................................................................. 625 20.8.1 transition to sleep mode .....................................................................................625 20.8.2 exiting subsleep mode ........................................................................................625 20.9 subactive mode................................................................................................................. 626 20.9.1 transition to subactive mode ..............................................................................626 20.9.2 exiting subactive mode .......................................................................................626 20.10 direct tr ansitions ............................................................................................................. .627 20.10.1 direct transitions from high-speed mode to subactive mode ...........................627 20.10.2 direct transitions from subactiv e mode to high-speed mode ...........................627 20.11 clock output disabling function...................................................................................627 20.12 usage notes.................................................................................................................... ...628 20.12.1 i/o port status ......................................................................................................628 20.12.2 current dissipation during oscillation stabilization wait period........................628 20.12.3 flash memory module st op.................................................................................628 20.12.4 dmac module stop ............................................................................................628 20.12.5 on-chip peripheral module interrupt ..................................................................628 20.12.6 entering subactive/watch mode and dmac and dtc module stop.................629 20.12.7 writing to mstpcr.............................................................................................629 section 21 list of registers ..............................................................................................631 21.1 register addresses (address order) .................................................................................632 21.2 register bits .................................................................................................................. ....640 rev.6.00 jun. 03, 2008 page xxvii of xlvi rej09b0074-0600 21.3 register states in each operating mode...........................................................................649 section 22 electrical characteristics ..............................................................................657 22.1 absolute maximum ratings .............................................................................................657 22.2 power supply voltage and operating frequency range ..................................................658 22.3 dc character istics ............................................................................................................6 59 22.4 ac character istics ............................................................................................................6 63 22.4.1 clock timing .......................................................................................................664 22.4.2 control signal timing .........................................................................................666 22.4.3 bus timi ng ..........................................................................................................668 22.4.4 timing of on-chip su pporting modu les .............................................................675 22.5 usb characteristics ..........................................................................................................68 0 22.6 a/d conversion characteristics........................................................................................682 22.7 flash memory characteristics...........................................................................................683 22.8 usage note..................................................................................................................... ...684 appendix .............................................................................................................................68 5 a. i/o port states in each processing state ...........................................................................685 b. product model lineup ......................................................................................................689 c. package dimensions .........................................................................................................691 index .............................................................................................................................69 5 rev.6.00 jun. 03, 2008 page xxviii of xlvi rej09b0074-0600 rev.6.00 jun. 03, 2008 page xxix of xlvi rej09b0074-0600 figures section 1 overview figure 1.1 internal block diag ram of HD64F2218 and HD64F2218u ..................................3 figure 1.2 internal bloc k diagram of hd6432217 .................................................................4 figure 1.3 internal block diagram of hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u .........................................................................................................5 figure 1.4 internal block diagram of hd6432211, hd6432210 and hd6432210s..............6 figure 1.5 pin arrangements of HD64F2218 and HD64F2218u (tfp-100g, tfp-100gv).7 figure 1.6 pin arrangements of HD64F2218 and HD64F2218u (bp-112, bp-112v)...........8 figure 1.7 pin arrangements of hd6432217 (tfp-100g, tfp-100gv)................................9 figure 1.8 pin arrangements of hd6432217 (bp-112, bp-112v) .........................................10 figure 1.9 pin arrangements of hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u (fp- 64e, fp-64ev)..................................................................11 figure 1.10 pin arrangements of hd6432211, hd6432210 and hd6432210s (fp-64e, fp-64ev)................................................................................................12 figure 1.11 pin arrangements of hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u (tnp -64b, tnp-64bv)...........................................................13 figure 1.12 pin arrangements of hd6432211, hd6432210 and hd6432210s (tnp-64b, tnp-64bv) .........................................................................................14 section 2 cpu figure 2.1 exception vector table (normal mode)................................................................35 figure 2.2 stack structure in normal mode............................................................................35 figure 2.3 exception vector table (advanced mode)............................................................36 figure 2.4 stack structure in advanced mode........................................................................37 figure 2.5 memory map.......................................................................................................... 38 figure 2.6 cpu registers ....................................................................................................... .39 figure 2.7 usage of general registers ....................................................................................40 figure 2.8 stack............................................................................................................... ........41 figure 2.9 general register data formats (1).........................................................................44 figure 2.9 general register data formats (2).........................................................................44 figure 2.10 memory data formats............................................................................................45 figure 2.11 instruction formats (examples) .............................................................................57 figure 2.12 branch address specifi cation in memory indirect mode ......................................61 figure 2.13 state transitions .................................................................................................. ...65 figure 2.14 flowchart of method for accessing registers containing write-only bits ..........69 rev.6.00 jun. 03, 2008 page xxx of xlvi rej09b0074-0600 section 3 mcu operating modes figure 3.1 memory map in each oper ating mode for HD64F2218 and HD64F2218u .........77 figure 3.2 memory map in each operating mode for hd6432217........................................78 figure 3.3 memory map in each operating mode for hd64f2212, hd64f2212u, hd64f2211, hd64f2211u, hd6432211, hd6432210, hd6432210s and hd64322 10s ..........................................................................................................79 section 4 exception handling figure 4.1 reset sequence (mode 4) .......................................................................................85 figure 4.2 reset sequence (modes 6 and 7) ............................................................................86 figure 4.3 stack status after exception handling ...................................................................89 figure 4.4 operation when sp value is odd ...........................................................................90 section 5 int errupt controller figure 5.1 block diagram of interrupt controller ...................................................................92 figure 5.2 block diagram of interrupts irqn .........................................................................99 figure 5.3 timing of setting irqnf........................................................................................100 figure 5.4 flowchart of procedure up to interrupt acceptance in interrupt control mode 0....................................................................................................................104 figure 5.5 flowchart of procedure up to interrupt acceptance in interrupt control mode 2....................................................................................................................106 figure 5.6 interrupt exception handling .................................................................................107 figure 5.7 interrupt control for dmac...................................................................................110 figure 5.8 contention between inte rrupt generation and disabling........................................112 section 6 bus controller figure 6.1 block diagram of bus controller ...........................................................................116 figure 6.2 overview of area divisions ...................................................................................127 figure 6.3 csn signal output timing (n = 0 to 5)...................................................................130 figure 6.4 on-chip memory access cycle .............................................................................131 figure 6.5 pin states during on-chip memory access ...........................................................132 figure 6.6 on-chip peripher al module access cycle .............................................................132 figure 6.7 pin states during on-c hip peripheral module access ...........................................133 figure 6.8 access sizes and data alignment control (8-bit access space)...........................134 figure 6.9 access sizes and data alignment control (16-bit access space).........................135 figure 6.10 bus timing for 8-bit 2-state access space............................................................136 figure 6.11 bus timing for 8-bit 3-state access space (except area 6) .................................137 figure 6.12 bus timing for area 6 and rt c.............................................................................138 figure 6.13 bus timing for 16-bit 2-state access space (1) (even address byte access) .....139 figure 6.14 bus timing for 16-bit 2-state access space (2) (odd address byte access).......140 figure 6.15 bus timing for 16-bit 2-state access space (3) (word access) ...........................141 rev.6.00 jun. 03, 2008 page xxxi of xlvi rej09b0074-0600 figure 6.16 bus timing for 16-bit 3-state access space (1) (even address byte access) .....142 figure 6.17 bus timing for 16-bit 3-state access space (2) (odd address byte access) ......143 figure 6.18 bus timing for 16-bit 3-state access space (3) (word access)...........................144 figure 6.19 example of wait state insertion timing................................................................146 figure 6.20 example of burst rom access timing (when ast0 = brsts1 = 1).................148 figure 6.21 example of burst rom access timing (when ast0 = brsts1 = 0).................148 figure 6.22 example of idle cycle operation (1) .....................................................................150 figure 6.23 example of idle cycle operation (2) .....................................................................151 figure 6.24 relationship between chip select ( cs ) and read ( rd ).........................................152 figure 6.25 bus-released state transition timing ...................................................................154 section 7 dma controller (dmac) figure 7.1 block diagram of dmac ......................................................................................158 figure 7.2 operation in sequential mode................................................................................179 figure 7.3 example of sequential mode setting procedure ....................................................180 figure 7.4 operation in idle mode ..........................................................................................181 figure 7.5 example of idle mode setting procedure...............................................................182 figure 7.6 operation in repeat mode ......................................................................................184 figure 7.7 example of repeat mode setting procedure..........................................................185 figure 7.8 operation in normal mode ....................................................................................187 figure 7.9 example of normal mode setting procedure.........................................................188 figure 7.10 operation in block transfer mode (blkdir = 0) ................................................190 figure 7.11 operation in block transfer mode (blkdir = 1) ................................................191 figure 7.12 operation flow in block transfer mode ...............................................................192 figure 7.13 example of block tr ansfer mode setting procedure.............................................193 figure 7.14 example of dma transfer bus timing.................................................................196 figure 7.15 example of short address mode transfer .............................................................197 figure 7.16 example of full addr ess mode (cycle steal) transfer .........................................198 figure 7.17 example of full address mode (burst mode) transfer.........................................199 figure 7.18 example of full address mode (block transfer mode) transfer .........................200 figure 7.19 example of dreq level activated normal mode transfer .................................201 figure 7.20 example of multi-channel transfer ......................................................................202 figure 7.21 example of procedure for continuing transfer on channel interrupted by nmi interrupt ....................................................................................................204 figure 7.22 example of procedure for forcibly terminating dmac operation......................204 figure 7.23 example of procedure for clearing full address mode ........................................205 figure 7.24 block diagram of transf er end/transfer break interrupt .....................................206 figure 7.25 dmac register update timing ............................................................................207 figure 7.26 contention between dmac register update and cpu read................................208 rev.6.00 jun. 03, 2008 page xxxii of xlvi rej09b0074-0600 section 9 16-bit timer pulse unit (tpu) figure 9.1 block diagram of tpu...........................................................................................274 figure 9.2 16-bit register access operation [bus master ? tcnt (16 bits)] .....................299 figure 9.3 8-bit register access operation [bus master ? tcr (upper 8 bits)] .................300 figure 9.4 8-bit register access operation [bus master ? tmdr (lower 8 bits)].............300 figure 9.5 8-bit register access operation [bus master ? tcr and tmdr (16 bits)].......300 figure 9.6 example of counter operation setting procedure..................................................301 figure 9.7 free-running counter operation ...........................................................................302 figure 9.8 periodic counter operation ....................................................................................303 figure 9.9 example of setting procedure for waveform output by compare match .............303 figure 9.10 example of 0 output/1 output operation...............................................................304 figure 9.11 example of toggle output operation.....................................................................304 figure 9.12 example of input capture operation setting procedure.........................................305 figure 9.13 example of input capture operation......................................................................306 figure 9.14 example of synchronous operation setting procedure..........................................307 figure 9.15 example of synchronous operation .......................................................................308 figure 9.16 compare match buffer operation ..........................................................................309 figure 9.17 input capture buffer operation ..............................................................................309 figure 9.18 example of buffer operation setting procedure ....................................................310 figure 9.19 example of buffer operation (1)............................................................................311 figure 9.20 example of buffer operation (2)............................................................................312 figure 9.21 example of pwm mode setting procedure............................................................314 figure 9.22 example of pwm mode operation (1) ..................................................................315 figure 9.23 example of pwm mode operation (2) ..................................................................315 figure 9.24 example of pwm mode operation (3) ..................................................................316 figure 9.25 example of phase counting mode setting procedure ............................................317 figure 9.26 example of phase counting mode 1 operation......................................................318 figure 9.27 example of phase counting mode 2 operation......................................................319 figure 9.28 example of phase counting mode 3 operation......................................................320 figure 9.29 example of phase counting mode 4 operation......................................................321 figure 9.30 count timing in internal clock operation .............................................................324 figure 9.31 count timing in external clock operation............................................................324 figure 9.32 output compare output timing.............................................................................325 figure 9.33 input capture input signal timing .........................................................................325 figure 9.34 counter clear timing (compare match)................................................................326 figure 9.35 counter clear timing (input capture) ...................................................................326 figure 9.36 buffer operation timing (compare match)...........................................................327 figure 9.37 buffer operation timing (input capture)...............................................................327 figure 9.38 tgi interrupt timing (compare match).................................................................328 figure 9.39 tgi interrupt timing (input capture) ....................................................................328 figure 9.40 tciv interrupt setting timing ...............................................................................329 rev.6.00 jun. 03, 2008 page xxxiii of xlvi rej09b0074-0600 figure 9.41 tciu interrupt setting timing...............................................................................329 figure 9.42 timing for status flag clearing by cpu ...............................................................330 figure 9.43 timing for status flag clearing by dmac activation .........................................330 figure 9.44 phase difference, overlap, and pulse width in phase counting mode .................331 figure 9.45 contention between tcnt write and clear operations........................................332 figure 9.46 contention between tcnt write and increment operations ................................332 figure 9.47 contention between tgr write and compare match............................................333 figure 9.48 contention between buffer register write and compare match...........................334 figure 9.49 contention between tgr read and input capture ................................................334 figure 9.50 contention between tgr write and input capture ...............................................335 figure 9.51 contention between buffer register write and input capture...............................336 figure 9.52 contention between overflow and counter clearing.............................................336 figure 9.53 contention between tcnt write and overflow....................................................337 section 10 watchdog timer (wdt) figure 10.1 block diagram of wdt .........................................................................................340 figure 10.2 operation in watchdog timer mode......................................................................343 figure 10.3 timing of wovf setting.......................................................................................344 figure 10.4 operation in interval timer mode..........................................................................344 figure 10.5 timing of ovf setting...........................................................................................345 figure 10.6 format of data written to tcnt and tcsr .........................................................346 figure 10.7 format of data written to rstcsr (example of wdt0) ....................................347 figure 10.8 contention between tcnt write and increment...................................................347 section 11 realtime clock (rtc ) figure 11.1 block diagram of rtc ..........................................................................................349 figure 11.2 definition of time expression ...............................................................................354 figure 11.3 initial setting procedure.........................................................................................3 58 figure 11.4 example: reading of inaccurate time data...........................................................359 figure 11.5 initializing procedure in using rtc interrupt .......................................................361 figure 11.6 example of rtc interrupt handling routine ........................................................361 section 12 serial co mmunication interface figure 12.1 block diagram of sci_0........................................................................................365 figure 12.2 block diagram of sci_2........................................................................................366 figure 12.3 examples of base clock when average transfer rate is selected (1)..................388 figure 12.3 examples of base clock when average transfer rate is selected (2)..................389 figure 12.3 examples of base clock when average transfer rate is selected (3)..................390 figure 12.4 example of average transfer rate setting when tpu clock is input (1)............391 figure 12.4 example of average transfer rate setting when tpu clock is input (2)............392 figure 12.4 example of average transfer rate setting when tpu clock is input (3)............393 rev.6.00 jun. 03, 2008 page xxxiv of xlvi rej09b0074-0600 figure 12.4 example of average transfer rate setting when tpu clock is input (4) ............394 figure 12.5 data format in asynchronous communication (example with 8-bit data, parity, two stop bits) .................................................403 figure 12.6 receive data sampling timing in asynchronous mode........................................405 figure 12.7 relationship between output clock and transfer data phase (asynchronous mode) ............................................................................................406 figure 12.8 sample sci initialization flowchart.......................................................................407 figure 12.9 example of operation in transmission in asynchronous mode (example with 8-bit data, parity, one stop bit) ...................................................408 figure 12.10 sample serial da ta transmission flowchart ..........................................................409 figure 12.11 example of sci operation in reception (example with 8-bit data, parity, one stop bit) ...................................................410 figure 12.12 sample serial data reception flowchart (1)..........................................................411 figure 12.12 sample serial data reception flowchart (2)..........................................................412 figure 12.13 example of communication using multiprocessor format (transmission of data h'aa to receiving station a)............................................414 figure 12.14 sample multiprocessor serial data transmission flowchart .................................415 figure 12.15 example of sci operation in reception (example with 8-bit data, multiprocessor bit, one stop bit) ...............................416 figure 12.16 sample multiprocessor seri al data reception flowchart (1).................................417 figure 12.16 sample multiprocessor seri al data reception flowchart (2).................................418 figure 12.17 data format in synchronous communication (for lsb-first)..............................419 figure 12.18 sample sci initialization flowchart.......................................................................420 figure 12.19 sample sci transmission operation in clocked synchronous mode....................422 figure 12.20 sample serial da ta transmission flowchart ..........................................................423 figure 12.21 example of sci operation in reception ................................................................424 figure 12.22 sample serial data reception flowchart ...............................................................425 figure 12.23 sample flowchart of simultaneous serial data transmit and receive operations ..........................................................................................426 figure 12.24 schematic diagram of smart card interface pin connections ...............................427 figure 12.25 normal smart card interface data format.............................................................428 figure 12.26 direct convention (sdir = sinv = o/ e = 0)........................................................428 figure 12.27 inverse convention (sdir = sinv = o/ e = 1)......................................................429 figure 12.28 receive data sampling timing in smart card mode (using clock of 372 time s the transfer rate).......................................................430 figure 12.29 retransfer operation in sci transmit mode..........................................................433 figure 12.30 tend flag generation timing in transmission operation...................................433 figure 12.31 example of transmission processing flow ...........................................................434 figure 12.32 retransfer operation in sci receive mode ...........................................................435 figure 12.33 example of reception processing flow .................................................................436 figure 12.34 timing for fixing clock output level ...................................................................436 rev.6.00 jun. 03, 2008 page xxxv of xlvi rej09b0074-0600 figure 12.35 clock halt and restart procedure ..........................................................................437 figure 12.36 example of communicatio n using the sci select function .................................438 figure 12.37 example of communicatio n using the sci select function .................................439 figure 12.38 example of clocked synchronous transmission by dmac .................................442 figure 12.39 sample flowchart for m ode transition during transmission................................444 figure 12.40 port pin state of asynchronou s transmission using internal clock .....................444 figure 12.41 port pin state of synchronous transmission using internal clock .......................445 figure 12.42 sample flowchart for mode transition during reception .....................................446 figure 12.43 operation when switching from sck pin function to port pin function .............447 figure 12.44 operation when switching from sck pin function to port pin function (example of preventing low-level output)..........................................................448 section 13 boundary scan function figure 13.1 block diagram of boundary scan function...........................................................450 figure 13.2 boundary scan register configuration..................................................................455 figure 13.3 tap controller status transition...........................................................................462 figure 13.4 recommended reset signal design.......................................................................463 figure 13.5 serial data input/output ........................................................................................463 section 14 universal serial bus (usb) figure 14.1 block diagram of usb ..........................................................................................466 figure 14.2 usb initializa tion................................................................................................. ..497 figure 14.3 usb cable connection (when usb module stop or power-down mode is not used) .............................498 figure 14.4 usb cable connection (when usb module stop or power-down mode is used)....................................499 figure 14.5 usb cable disconnection (when usb module stop or power-down mode is not used) .............................500 figure 14.6 usb cable disconnection (when usb module stop or power-down mode is used)....................................501 figure 14.7 example flowchart of suspend and resume operations.......................................502 figure 14.8 example flowchart of suspend and resume interrupt processing ........................503 figure 14.9 example flowchart of suspend and remote-wakeup operations.........................504 figure 14.10 example flowchart of remote-wakeup interrupt processing ...............................505 figure 14.11 control transfer stage configuration ....................................................................506 figure 14.12 setup stage operation ............................................................................................5 07 figure 14.13 data stage operation (control-in) .........................................................................508 figure 14.14 data stage operation (control-out) ......................................................................509 figure 14.15 status stage operation (control-in) .......................................................................510 figure 14.16 status stage operation (control-out) ....................................................................511 figure 14.17 ep3 interrupt-in transfer operation ......................................................................512 rev.6.00 jun. 03, 2008 page xxxvi of xlvi rej09b0074-0600 figure 14.18 ep1 bulk-in transfer operation.............................................................................514 figure 14.19 ep2 bulk-out transfer operation ..........................................................................515 figure 14.20 forcible stall by firmware .....................................................................................518 figure 14.21 automatic stall by usb function module .............................................................519 figure 14.22 ep1pkte operation in utrg0.............................................................................521 figure 14.23 ep2rdfn operation in utrg0 ............................................................................522 figure 14.24 ep1pkte operation in utrg0 (auto-request) ...................................................523 figure 14.25 ep2rdfn operation in utrg0 (auto-request)...................................................524 figure 14.26 usb external circuit in bus-powered mode .........................................................525 figure 14.27 usb external circ uit in self-powered mode .........................................................526 figure 14.28 flowchart ......................................................................................................... .......531 figure 14.29 timing chart...................................................................................................... .....532 figure 14.30 tr interrupt flag set timing .................................................................................533 section 15 a/d converter figure 15.1 block diagram of a/d converter...........................................................................536 figure 15.2 access to addr (when reading h'aa40) ...........................................................541 figure 15.3 a/d conversion timing (sin gle-chip mode, channel 1 selected)........................542 figure 15.4 a/d conversion timing (scan mode, channels an0 to an2 selected) ...............543 figure 15.5 a/d conversion timing .........................................................................................544 figure 15.6 external trigger input timing................................................................................545 figure 15.7 a/d conversion precision definitions (1)..............................................................547 figure 15.8 a/d conversion precision definitions (2)..............................................................547 figure 15.9 example of analog input circuit............................................................................548 figure 15.10 analog input pin equivalent circuit.......................................................................549 section 17 flash memory (f-ztat version) figure 17.1 block diagram of flash memory ...........................................................................554 figure 17.2 flash memory state tran sitions .............................................................................555 figure 17.3 boot mode (sample)...............................................................................................55 6 figure 17.4 user program mode (sample) ................................................................................557 figure 17.5 flash memory block configuration (HD64F2218, HD64F2218u , hd64f2212, hd 64f2212u ) ..................................558 figure 17.6 flash memory block conf iguration (hd64f2211, hd64f2211u).......................559 figure 17.7 system configuration in sci boot mode...............................................................568 figure 17.8 system configuration di agram when using usb boot mode...............................572 figure 17.9 programming/erasing flowchart example in user program mode .......................576 figure 17.10 flowchart for flash memory emulation in ram ..................................................577 figure 17.11 example of ram overlap operation .....................................................................578 figure 17.12 program/prog ram-verify flowchart .......................................................................580 figure 17.13 erase/erase-verify flowchart.................................................................................582 rev.6.00 jun. 03, 2008 page xxxvii of xlvi rej09b0074-0600 figure 17.14 memory ma p in progra mmer m ode.......................................................................585 figure 17.15 power-on/off timing (boot mode).......................................................................589 figure 17.16 power-on/off timi ng (user prog ram mode) ........................................................590 figure 17.17 mode transition timing (example: boot mode user mode ? user program mode).............................591 section 18 masked rom figure 18.1 block diagram of on-c hip masked rom (64 kbytes)..........................................593 section 19 clock pulse generator figure 19.1 block diagram of clock pulse generator ..............................................................595 figure 19.2 connection of crystal resonator (example)..........................................................600 figure 19.3 crystal resonator equivalent circuit .....................................................................600 figure 19.4 external clock input (examples) ...........................................................................601 figure 19.5 external clock input timing..................................................................................602 figure 19.6 example connection of 32.768-khz quartz oscillator..........................................603 figure 19.7 equivalence circuit for 32.768-khz oscillator ......................................................603 figure 19.8 pin handling when subclock not required...........................................................603 figure 19.9 example of pll circuit .........................................................................................604 figure 19.10 note on board design of oscillator circuit ...........................................................605 figure 19.11 example of external clock switching circuit .......................................................606 figure 19.12 example of external clock switchover timing.....................................................606 section 20 power-down modes figure 20.1 mode transition diagram ......................................................................................609 figure 20.2 example of flash memory module stop mode usage ..........................................616 figure 20.3 medium-speed mode transition and clearance timing .......................................618 figure 20.4 software standby mode application example ......................................................621 figure 20.5 hardware standby mode timing (example) .........................................................622 figure 20.6 timing of transition to hardware standby mode .................................................622 figure 20.7 timing of recovery from hardware standby mode ..............................................623 section 22 electrical characteristics figure 22.1 power supply voltage and operating ranges........................................................658 figure 22.2 output load circuit................................................................................................ 663 figure 22.3 system clock timing.............................................................................................665 figure 22.4 oscillation stabilization timing.............................................................................665 figure 22.5 reset input timing................................................................................................. 667 figure 22.6 interrupt input timing............................................................................................6 67 figure 22.7 basic bus timing (two-state access)...................................................................670 figure 22.8 basic bus timing (three-state access).................................................................671 rev.6.00 jun. 03, 2008 page xxxv iii of xlvi rej09b0074-0600 figure 22.9 basic bus timing (three-state access with one wait state)................................672 figure 22.10 burst rom access timing (two-state access) ....................................................673 figure 22.11 external bus release timing .................................................................................674 figure 22.12 i/o port input/output timing .................................................................................677 figure 22.13 tpu input/output timing ......................................................................................677 figure 22.14 tpu clock input timing ........................................................................................677 figure 22.15 sck clock input timing........................................................................................678 figure 22.16 sci input/output ti ming (clock synchr onous m ode)...........................................678 figure 22.17 a/d converter external trigger input timing .......................................................678 figure 22.18 boundary scan tck input timing.........................................................................678 figure 22.19 boundary scan trst input timing (at reset hold).............................................678 figure 22.20 boundary scan data transmission timing ............................................................679 figure 22.21 data signal timing................................................................................................ .681 figure 22.22 test load circuit ................................................................................................. ...681 appendix figure c.1 tfp-100g and tfp-100gv package dimensions .................................................691 figure c.2 bp-112 and bp-1 12v package dimensions ...........................................................692 figure c.3 fp-64e and fp-64ev package dimensions ...........................................................693 figure c.4 tnp-64b and tnp-64bv package dimensions ....................................................694 rev.6.00 jun. 03, 2008 page xxxix of xlvi rej09b0074-0600 tables section 1 overview table 1.1 pin functions in each operating mode for h8s/2218 group................................15 table 1.2 pin functions in each operating mode for h8s/2212 group................................18 section 2 cpu table 2.1 instruction classification........................................................................................46 table 2.2 operation notation .................................................................................................47 table 2.3 data transfer instructions ......................................................................................48 table 2.4 arithmetic operations instructions ........................................................................49 table 2.5 logic operations instructions ................................................................................50 table 2.6 shift instructions ....................................................................................................51 table 2.7 bit manipulation instructions.................................................................................52 table 2.8 branch instructions.................................................................................................54 table 2.9 system control instruction.....................................................................................55 table 2.10 block data transfer instruction .............................................................................56 table 2.11 addressing modes..................................................................................................58 table 2.12 absolute address access ranges ..........................................................................60 table 2.13 effective address calculation................................................................................62 section 3 mcu operating modes table 3.1 mcu operating mode selection............................................................................71 table 3.2 pin functions in each operating mode..................................................................76 section 4 exception handling table 4.1 exception types and priority .................................................................................81 table 4.2 exception handling vector table ..........................................................................82 table 4.3 reset types ............................................................................................................84 table 4.4 status of ccr and exr after trace exception handling ......................................87 table 4.5 status of ccr and exr after trap instruction exception handling .....................88 section 5 int errupt controller table 5.1 pin configuration ...................................................................................................93 table 5.2 interrupt sources, vector addresses, and interrupt priorities ................................101 table 5.3 interrupt control modes .........................................................................................103 table 5.4 interrupt res ponse times.......................................................................................108 table 5.5 number of states in interrupt handling routine execution statuses.....................109 table 5.6 interrupt source selection and clearing control....................................................111 rev.6.00 jun. 03, 2008 page xl of xlvi rej09b0074-0600 section 6 bus controller table 6.1 pin configuration....................................................................................................117 table 6.2 bus specifications for each area (basic bus interface) ........................................129 table 6.3 data buses used and valid strobes........................................................................135 table 6.4 pin states in idle cycle...........................................................................................152 table 6.5 pin states in bus released state.............................................................................153 section 7 dma controller (dmac) table 7.1 short address mode and full address mode (for 1 channel: example of channel 0) .................................................................160 table 7.2 dmac transfer modes ..........................................................................................177 table 7.3 register functions in sequential mode ..................................................................178 table 7.4 register functions in idle mode.............................................................................181 table 7.5 register functions in repeat mode........................................................................183 table 7.6 register functions in normal mode.......................................................................186 table 7.7 register functions in block transfer mode ...........................................................189 table 7.8 dmac activation sources .....................................................................................194 table 7.9 dmac channel priority order...............................................................................202 table 7.10 interrupt source priority order...............................................................................206 section 8 i/o ports table 8.1 port functions of h8s/2218 gr oup ........................................................................211 table 8.2 port functions of h8s/2212 gr oup ........................................................................214 table 8.3 p17 pin f unction.....................................................................................................218 table 8.4 p16 pin f unction.....................................................................................................218 table 8.5 p15 pin f unction.....................................................................................................218 table 8.6 p14 pin f unction.....................................................................................................219 table 8.7 p13 pin f unction.....................................................................................................219 table 8.8 p12 pin f unction.....................................................................................................219 table 8.9 p11 pin f unction.....................................................................................................220 table 8.10 p10 pin f unction.....................................................................................................220 table 8.11 p17 pin f unction.....................................................................................................220 table 8.12 p16 pin f unction.....................................................................................................221 table 8.13 p15 pin f unction.....................................................................................................221 table 8.14 p14 pin f unction.....................................................................................................221 table 8.15 p13 pin f unction.....................................................................................................222 table 8.16 p12 pin f unction.....................................................................................................222 table 8.17 p11 pin f unction.....................................................................................................222 table 8.18 p10 pin f unction.....................................................................................................222 table 8.19 p36 pin f unction.....................................................................................................225 table 8.20 p32 pin f unction.....................................................................................................226 rev.6.00 jun. 03, 2008 page xli of xlvi rej09b0074-0600 table 8.21 p31 pin function ....................................................................................................226 table 8.22 p30 pin function ....................................................................................................226 table 8.23 p74 pin function ....................................................................................................231 table 8.24 p71 pin function ....................................................................................................231 table 8.25 p70 pin function ....................................................................................................231 table 8.26 p77 pin function ....................................................................................................231 table 8.27 p76 pin function ....................................................................................................232 table 8.28 p75 pin function ....................................................................................................232 table 8.29 pa3 pin function ...................................................................................................236 table 8.30 pa2 pin function ...................................................................................................236 table 8.31 pa1 pin function ...................................................................................................237 table 8.32 pa0 pin function ...................................................................................................237 table 8.33 pa3 pin function ...................................................................................................237 table 8.34 pa2 pin function ...................................................................................................238 table 8.35 pa1 pin function ...................................................................................................238 table 8.36 input pull-up mos states (port a)........................................................................238 table 8.37 pb7 pin function ...................................................................................................242 table 8.38 pb6 pin function ...................................................................................................242 table 8.39 pb5 pin function ...................................................................................................242 table 8.40 pb4 pin function ...................................................................................................243 table 8.41 pb3 pin function ...................................................................................................243 table 8.42 pb2 pin function ...................................................................................................243 table 8.43 pb1 pin function ...................................................................................................243 table 8.44 pb0 pin function ...................................................................................................244 table 8.45 input pull-up mos states (port b)........................................................................244 table 8.46 pc7 pin function ...................................................................................................247 table 8.47 pc6 pin function ...................................................................................................247 table 8.48 pc5 pin function ...................................................................................................248 table 8.49 pc4 pin function ...................................................................................................248 table 8.50 pc3 pin function ...................................................................................................248 table 8.51 pc2 pin function ...................................................................................................248 table 8.52 pc1 pin function ...................................................................................................248 table 8.53 pc0 pin function ...................................................................................................249 table 8.54 input pull-up mos states (port c)........................................................................249 table 8.55 pd7 pin function ...................................................................................................252 table 8.56 pd6 pin function ...................................................................................................252 table 8.57 pd5 pin function ...................................................................................................252 table 8.58 pd4 pin function ...................................................................................................253 table 8.59 pd3 pin function ...................................................................................................253 table 8.60 pd2 pin function ...................................................................................................253 table 8.61 pd1 pin function ...................................................................................................253 rev.6.00 jun. 03, 2008 page xlii of xlvi rej09b0074-0600 table 8.62 pd0 pin function....................................................................................................253 table 8.63 input pull-up mos states (port d) ........................................................................254 table 8.64 pe7 pin function ....................................................................................................257 table 8.65 pe6 pin function ....................................................................................................257 table 8.66 pe5 pin function ....................................................................................................258 table 8.67 pe4 pin function ....................................................................................................258 table 8.68 pe3 pin function ....................................................................................................258 table 8.69 pe2 pin function ....................................................................................................258 table 8.70 pe1 pin function ....................................................................................................259 table 8.71 pe0 pin function ....................................................................................................259 table 8.72 pe7 pin function ....................................................................................................259 table 8.73 pe6 pin function ....................................................................................................259 table 8.74 pe5 pin function ....................................................................................................259 table 8.75 pe4 pin function ....................................................................................................260 table 8.76 pe3 pin function ....................................................................................................260 table 8.77 pe2 pin function ....................................................................................................260 table 8.78 pe1 pin function ....................................................................................................260 table 8.79 pe0 pin function ....................................................................................................260 table 8.80 input pull-up mos states (port e) ........................................................................261 table 8.81 pf7 pin function ....................................................................................................264 table 8.82 pf6 pin function ....................................................................................................264 table 8.83 pf5 pin function ....................................................................................................265 table 8.84 pf4 pin function ....................................................................................................265 table 8.85 pf3 pin function ....................................................................................................265 table 8.86 pf2 pin function ....................................................................................................265 table 8.87 pf1 pin function ....................................................................................................266 table 8.88 pf0 pin function ....................................................................................................266 table 8.89 pf7 pin function ....................................................................................................266 table 8.90 pf3 pin function ....................................................................................................267 table 8.91 pf0 pin function ....................................................................................................267 table 8.92 pg4 pin function....................................................................................................270 table 8.93 pg3 pin function....................................................................................................270 table 8.94 pg2 pin function....................................................................................................270 table 8.95 pg1 pin function....................................................................................................270 table 8.96 pg1 pin function....................................................................................................271 table 8.97 pg0 pin function....................................................................................................271 table 8.98 examples of ways to handle unused input pins ...................................................272 section 9 16-bit timer pulse unit (tpu) table 9.1 tpu functions ........................................................................................................275 table 9.2 pin configuration....................................................................................................277 rev.6.00 jun. 03, 2008 page xliii of xlvi rej09b0074-0600 table 9.3 cclr2 to cclr0 (channel 0) ...............................................................................280 table 9.4 cclr2 to cclr0 (cha nnels 1 an d 2) ....................................................................280 table 9.5 tpsc2 to tpsc0 (channel 0).................................................................................281 table 9.6 tpsc2 to tpsc0 (channel 1).................................................................................281 table 9.7 tpsc2 to tpsc0 (channel 2).................................................................................282 table 9.8 md3 to md0..........................................................................................................283 table 9.9 tiorh_0 (channel 0).............................................................................................285 table 9.10 tiorh_0 (channel 0).............................................................................................286 table 9.11 tiorl_0 (channel 0) .............................................................................................287 table 9.12 tiorl_0 (channel 0) .............................................................................................288 table 9.13 tior_1 (channel 1)................................................................................................289 table 9.14 tior_1 (channel 1)................................................................................................290 table 9.15 tior_2 (channel 2)................................................................................................291 table 9.16 tior_2 (channel 2)................................................................................................292 table 9.17 register combinations in buffer operation...........................................................309 table 9.18 pwm output registers and output pins................................................................314 table 9.19 phase counting mode clock input pins.................................................................317 table 9.20 up/down-count conditions in phase counting mode 1 .......................................318 table 9.21 up/down-count conditions in phase counting mode 2 .......................................319 table 9.22 up/down-count conditions in phase counting mode 3 .......................................320 table 9.23 up/down-count conditions in phase counting mode 4 .......................................321 table 9.24 tpu interrupts........................................................................................................322 section 10 watchdog timer (wdt) table 10.1 wdt interrupt source............................................................................................345 section 11 realtime clock (rtc) table 11.1 pin configuration ...................................................................................................350 table 11.2 interrupt source......................................................................................................360 table 11.3 operating state in each mode................................................................................362 section 12 serial co mmunication interface table 12.1 pin configuration ...................................................................................................367 table 12.2 relationships between the n setting in brr and bit rate b ................................395 table 12.3 brr settings for various bit rates (asynchronous mode) ..................................396 table 12.4 maximum bit rate for each frequency (asynchronous mode) ............................399 table 12.5 maximum bit rate with external clock input (asynchronous mode)..................400 table 12.6 brr settings for various bit rates (clocked synchronous mode) ......................401 table 12.7 maximum bit rate with external clock input (clocked synchronous mode)......401 table 12.8 brr settings for various bit rates (smart card interface mode, when n = 0 and s = 372)..........................................402 rev.6.00 jun. 03, 2008 page xliv of xlvi rej09b0074-0600 table 12.9 maximum bit rate at various frequencies (smart card interface mode).............402 table 12.10 serial transfer formats (asynchronous mode)......................................................404 table 12.11 ssr status flags and receive data handling ........................................................411 table 12.12 sci interrupt sources .............................................................................................440 table 12.13 interrupt sources in smart card interface mode ....................................................441 section 13 boundary scan function table 13.1 pin configuration....................................................................................................451 table 13.2 instruction configuration........................................................................................452 table 13.3 idcode register configuration............................................................................454 table 13.4 correspondence between lsi pins and boundary scan register ...........................455 section 14 universal serial bus (usb) table 14.1 pin configuration....................................................................................................467 table 14.2 relationship between utstr0 setting and pin output .........................................490 table 14.3 relationship between pin input and utstr1 monitoring value ..........................491 table 14.4 interrupt sources.....................................................................................................495 table 14.5 command decoding by firmware..........................................................................516 section 15 a/d converter table 15.1 pin configuration....................................................................................................537 table 15.2 analog input channels and corresponding addr registers ................................538 table 15.3 a/d conversion time (single mode).....................................................................545 table 15.4 a/d conversion time (scan mode) .......................................................................545 table 15.5 a/d converter interrupt source..............................................................................546 table 15.6 analog pin specifications.......................................................................................549 section 17 flash memory (f-ztat version) table 17.1 differences between boot mode and user program mode ....................................555 table 17.2 pin configuration....................................................................................................560 table 17.3 setting on-board programming modes .................................................................567 table 17.4 boot mode operation .............................................................................................570 table 17.5 system clock frequencies for which automatic adjustment of lsi bit rate is possible...................................................................................................................57 0 table 17.6 enumeration information........................................................................................571 table 17.7 usb boot mode operation.....................................................................................574 table 17.8 flash memory operating states..............................................................................586 table 17.9 registers present in f-ztat version but absent in masked rom version.........592 section 19 clock pulse generator table 19.1 damping resistance value .....................................................................................600 rev.6.00 jun. 03, 2008 page xlv of xlvi rej09b0074-0600 table 19.2 crystal resonator characteristics...........................................................................600 table 19.3 external clock input conditions ............................................................................601 table 19.4 external clock input conditions when duty adjustment circuit is not used .......602 section 20 power-down modes table 20.1 lsi internal states in each mode...........................................................................608 table 20.2 transition conditions of power-down modes.......................................................610 table 20.3 oscillation stabilizatio n time settings ..................................................................620 table 20.4 pin state in each processing state ......................................................................627 section 22 electrical characteristics table 22.1 absolute maximum ratings...................................................................................657 table 22.2 dc characteristics..................................................................................................659 table 22.3 permissible output currents...................................................................................662 table 22.4 clock timing..........................................................................................................664 table 22.5 control signal timing............................................................................................666 table 22.6 bus timi ng.............................................................................................................668 table 22.7 timing of on-chip su pporting modu les ...............................................................675 table 22.8 usb characteristics (usd+ and usd- pi ns) when on-chip usb transceiver is used........................................................................................................................6 80 table 22.9 a/d conversion characteristics .............................................................................682 table 22.10 flash memory characteristics ................................................................................683 rev.6.00 jun. 03, 2008 page xlvi of xlvi rej09b0074-0600 section 1 overview rev.6.00 jun. 03, 2008 page 1 of 698 rej09b0074-0600 section 1 overview 1.1 overview ? high-speed h8s/2000 central processing unit with 16-bit architecture ? upward-compatible with h8/300 and h8/300h cpus on an object level ? sixteen 16-bit general registers ? 65 basic instructions ? various peripheral functions ? dma controller (dmac) ? 16-bit timer-pulse unit (tpu) ? watchdog timer (wdt) ? realtime clock (rtc) ? serial communication interface (sci) ? boundary scan ? universal serial bus (usb) ? 10-bit a/d converter ? high-performance user debugging interface (h-udi) ? clock pulse generator ? on-chip memory h8s/2218 group rom part no. rom ram remarks flash memory version HD64F2218 128 kbytes 12 kbytes sci boot mode HD64F2218u 128 kbytes 12 kbytes usb boot mode masked rom version hd6432217 64 kbytes 8 kbytes ? section 1 overview rev.6.00 jun. 03, 2008 page 2 of 698 rej09b0074-0600 h8s/2212 group rom part no. rom ram remarks flash memory version hd64f2212 128 kbytes 12 kbytes sci boot mode hd64f2212u 128 kbytes 12 kbytes usb boot mode hd64f2211 64 kbytes 8 kbytes sci boot mode hd64f2211u 64 kbytes 8 kbytes usb boot mode masked rom version hd6432211 64 kbytes 8 kbytes ? hd6432210 32 kbytes 4 kbytes ? hd6432210s 32 kbytes 4 kbytes ? ? general i/o ports i/o pins: 69 for the h8s/2218 group, 37 for the h8s/2212 group ? supports various power-down states ? compact package package code * body size pin pitch remarks tqfp-100 tfp-100g, tfp-100gv 12.0 12.0 mm 0.4 mm h8s/2218 group p-lfbga-112 bp-112, bp-112v 10.0 10.0 mm 0.8 mm lqfp-64 fp-64e, fp-64ev 10.0 10.0 mm 0.5 mm h8s/2212 group vqfn-64 tnp-64b, tnp-64bv 8.0 8.0 mm 0.4 mm note: * a v appended to the end of the package code indicates a lead-free version. section 1 overview rev.6.00 jun. 03, 2008 page 3 of 698 rej09b0074-0600 1.2 internal block diagram the internal block diagram of the HD64F2218 and HD64F2218u is shown in figure 1.1. the internal block diagram of the hd6432217 is shown in figure 1.2. the internal block diagram of the hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u is shown in figure 1.3. the internal block diagram of the hd6432211, hd6432210 and hd6432210s is shown in figure 1.4. pe7 / d7 pe6 / d6 pe5 / d5 pe4 / d4 pe3 / d3 pe2 / d2 pe1 / d1 pe0 / d0 pd7 / d15 pd6 / d14 pd5 / d13 pd4 / d12 pd3 / d11 pd2 / d10 pd1 / d9 pd0 / d8 vcc vcc vss vss drvcc drvss emle * 2 tdo * 2 tck * 2 tms * 2 trst * 2 tdi * 2 pa3 / a19/sck2 pa2 / a18/rxd2 pa1 / a17/txd2 pa0 / a16 pb7 / a15 pb6 / a14 pb5 / a13 pb4 / a12 pb3/a11 pb2 / a10 pb1 / a9 pb0 / a8 pc7 / a7 pc6 / a6 pc5 / a5 pc4 / a4 pc3 / a3 pc2 / a2 pc1 / a1 pc0 / a0 p36 (pupd+) p32 / sck0/ irq 4 p31 / rxd0 p30 / txd0 p10 / tioca0 /a20 p11 / tiocb0 /a21 p12 / tiocc0 / tclka/a22 p13 / tiocd0 / tclkb/a23 p14 / tioca1/ irq0 p15 / tiocb1 / tclkc p16 / tioca2/ irq1 p17 / tiocb2/ tclkd p70/ cs4 p71/ cs5 p74 / mres pg4 / cs0 pg3 / cs1 pg2 / cs2 pg1 / cs3 / irq7 pf7 / pf6 / as pf5 / rd pf4 / hwr pf3 / lwr / adtrg / irq3 pf2 / wait pf1 / back pf0 / breq / irq2 md2 md1 md0 extal xtal pllvcc pllvss osc1 osc2 p96/an14 p97/an15 vref h8s/2000 cpu wdt dmac usb p40/an0 p41/an1 p42/an2 p43/an3 sci2 stby res nmi fwe * 1 uspnd/tmow usd+ usd- ubpm vbus rom ram rtc peripheral data bus peripheral address bus internal address bus internal data bus port d boundary scan/h-udi * 2 tpu (3 channels) interrupts controller port e port a port b bus controller port c port 3 port f port g port 9 port 4 port 1 port 7 sci0 (high speed uart) a/d converter (6 channels) main clock pulse generator sub-clock pulse generator the fwe pin is provided only in the HD64F2218 and HD64F2218u. when emle = 0, boundary scan is available and the pins function as tdo, tck, tms, trst , and tdi, respectively. when emle = 1, h-udi function is available and the pins function as tdo, tck, tms, trst , and tdi, respectively. notes: 1. 2. figure 1.1 internal block diagram of HD64F2218 and HD64F2218u section 1 overview rev.6.00 jun. 03, 2008 page 4 of 698 rej09b0074-0600 p e 7 / d7 p e 6 / d6 p e 5 / d5 p e4 / d 4 p e 3 / d3 p e 2 / d2 p e 1 / d1 p e 0 / d0 pd7 / d15 pd6 / d1 4 pd5 / d13 pd 4/ d12 pd3 / d11 pd2 / d10 pd1 / d9 pd0 / d8 vcc vcc vss vss drvcc drvss n c * 2 n c * 2 n c * 2 n c * 2 n c * 2 n c * 2 pa3 / a19 / sc k 2 pa2 / a18 / rxd2 pa1 / a17 /t xd2 pa0 / a16 pb7 / a15 pb6 / a1 4 pb5 / a13 pb 4/ a12 pb3 / a11 pb2 / a10 pb1 / a9 pb0 / a8 pc7 / a7 pc6 / a6 pc5 / a5 pc 4/ a 4 pc3 / a3 pc2 / a2 pc1 / a1 pc0 / a0 p36 (pupd + ) p32 / sc k 0 / i rq 4 p31 / rxd0 p30 /t xd0 p10 /ti oca0 / a20 p11 /ti ocb0 / a21 p12 /ti occ0 /t c lk a / a22 p13 /ti ocd0 /t c lk b / a23 p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d p70 / cs 4 p71 / cs 5 p7 4/ m r e s pg 4/ cs0 pg3 / cs 1 pg2 / cs2 pg1 / cs3 / i rq7 p f 7 / p f 6 / a s p f 5 / rd p f4 / h wr p f 3 / l wr / a d t rg / i rq3 p f 2 / w ait p f 1 / b a ck p f 0 / br e q / i rq2 md2 md1 md0 e x t a l x t a l p ll vcc p ll vss osc1 osc2 p96 / a n 1 4 p97 / a n 15 vref h 8s / 2000 cpu wd t dmac usb p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 sc i 2 s t by r e s n m i f w e * 1 usp n d /t mow usd + usd - ubp m vbus rom ram r t c per i phera l data bus per i phera l address bus i nterna l address bus i nterna l data bus port d t pu (3 channe l s) i nterrupts contro ll er port e port a port b bus contro ll er port c port 3 port f port g port 9 port 4 port 1 port 7 sc i 0 ( hi gh speed uar t ) a / d converter (6 channe l s) ma i n c l ock pu l se generator sub - c l ock pu l se generator n otes : n c (no connect i on) : t hese p i ns shou l d not be connected ; they shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2218 and h d6 4f 2218u . i t shou l d be f i xed l o w. 2 . n e i ther boundary scan nor h- ud i funct i on i s ava il ab l e and the p i ns funct i on as n c . figure 1.2 internal block diagram of hd6432217 section 1 overview rev.6.00 jun. 03, 2008 page 5 of 698 rej09b0074-0600 p e 7 p e 6 p e 5 p e4 p e 3 p e 2 p e 1 p e 0 vcc vcc vss vss drvcc drvss pa3 / sc k 2 pa2 / rxd2 pa1 /t xd2 p36 (pupd + ) p32 / sc k 0 / i rq 4 p31 / rxd0 p30 /t xd0 p10 /ti oca0 p11 /ti ocb0 p12 /ti occ0 /t c lk a p13 /ti ocd0 /t c lk b p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d pg1 / i rq7 p f 7 / p f 3 / a d t rg / i rq3 p f 0 / i rq2 md2 md1 md0 e x t a l x t a l p ll vcc p ll vss osc1 osc2 p96 / a n 1 4 p97 / a n 15 vref h 8s / 2000 cpu wd t dmac usb p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 sc i 2 s t by r e s n m i f w e * 1 usp n d /t mow usd + usd - ubp m vbus rom ram r t c e m le * 2 t do / p77 * 2 t c k/ p76 * 2 t ms / p75 * 2 t rs t /n c * 2 t d i/ pg0 * 2 n otes : n c (no connect i on) : t h i s p i n shou l d not be connected ; i t shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2212, h d6 4f 2212u, h d6 4f 2211, and h d6 4f 2211u . 2 . when e m le = 0, port funct i on i s ava il ab l e and the p i ns funct i on as p77, p76, p75, n c, and pg0, respect i ve l y . when e m le = 1, h- ud i funct i on i s ava il ab l e and the p i ns funct i on as t do, t c k , t ms, t rs t , and t d i , respect i ve l y . per i phera l data bus per i phera l address bus h- ud i/ ports 7 and g * 2 t pu (3 channe l s) i nterrupts contro ll er port e port a port 3 port f port g port 9 port 4 port 1 ma i n c l ock pu l se generator sub - c l ock pu l se generator sc i 0 ( hi gh speed uar t ) a / d converter (6 channe l s) i nterna l address bus i nterna l data bus bus contro ll er figure 1.3 internal block diagram of hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u section 1 overview rev.6.00 jun. 03, 2008 page 6 of 698 rej09b0074-0600 p e 7 p e 6 p e 5 p e4 p e 3 p e 2 p e 1 p e 0 vcc vcc vss vss drvcc drvss pa3 / sc k 2 pa2 / rxd2 pa1 /t xd2 p36 (pupd + ) p32 / sc k 0 / i rq 4 p31 / rxd0 p30 /t xd0 p10 /ti oca0 p11 /ti ocb0 p12 /ti occ0 /t c lk a p13 /ti ocd0 /t c lk b p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d pg1 / i rq7 p f 7 / p f 3 / a d t rg / i rq3 p f 0 / i rq2 md2 md1 md0 e x t a l x t a l p ll vcc p ll vss osc1 osc2 p96 / a n 1 4 p97 / a n 15 vref h 8s / 2000 cpu wd t dmac usb p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 sc i 2 s t by r e s n m i f w e * 1 usp n d /t mow usd + usd - ubp m vbus rom ram r t c n c * 2 p77 * 2 p76 * 2 p75 * 2 n c * 2 pg0 * 2 per i phera l data bus per i phera l address bus ports 7 and g * 2 t pu (3 channe l s) i nterrupts contro ll er port e port a port 3 port f port g port 9 port 4 port 1 ma i n c l ock pu l se generator sub - c l ock pu l se generator sc i 0 ( hi gh speed uar t ) a / d converter (6 channe l s) i nterna l address bus i nterna l data bus bus contro ll er n otes : n c (no connect i on) : t hese p i ns shou l d not be connected ; they shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2212, h d6 4f 2212u, h d6 4f 2211, and h d6 4f 2211u . i t shou l d be f i xed l o w. 2 . t he port funct i on i s ava il ab l e and the p i ns funct i on as n c, p77, p76, p75, n c, and pg0, respect i ve l y . figure 1.4 internal block diagram of hd6432211, hd6432210 and hd6432210s section 1 overview rev.6.00 jun. 03, 2008 page 7 of 698 rej09b0074-0600 1.3 pin arrangements the pin arrangements of the HD64F2218 and HD64F2218u are shown in figures 1.5 and 1.6. the pin arrangements of the hd6432217 are shown in figures 1.7 and 1.8. the pin arrangements of the hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u are shown in figures 1.9 and 1.11. the pin arrangements of the hd6432211, hd6432210 and hd6432210s is shown in figures 1.10 and 1.12. tf p - 100g tf p - 100gv ( t op v i e w ) t he f w e p i n i s prov i ded on l y i n the h d6 4f 2218 and h d6 4f 2218u . when e m le = 0, boundary scan i s ava il ab l e and the p i ns funct i on as t do, t c k , t ms, t rs t , and t d i , respect i ve l y . when e m le = 1, h- ud i funct i on i s ava il ab l e and the p i ns funct i on as t do, t c k , t ms, t rs t , and t d i , respect i ve l y . n otes : 1 . 2 . pd 4/ d12 pd5 / d13 pd6 / d1 4 pd7 / d15 f w e * 1 n m i e m le * 2 t do * 2 t c k * 2 t ms * 2 t rs t * 2 t d i * 2 vcc p f 7 / vss p f 6 / a s p f 5 / rd p f4/ h wr p f 3 / l wr / a d t rg / i rq3 p f 2 / w ait p f 1 / b a ck p f 0 / br e q / i rq2 pa3 / a19 / sc k 2 pa2 / a18 / rxd2 pa1 / a17 /t xd2 pb5 / a13 pb 4/ a12 p ll vcc ubp m p ll vss p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 vref pb3 / a11 pb2 / a10 pb1 / a9 pb0 / a8 p96 / a n 1 4 p97 / a n 15 drvss usd - usd + drvcc p36(pupd + ) vbus pg 4/ cs0 pg3 / cs 1 pg2 / cs2 76 77 78 79 80 81 82 83 8 4 85 86 87 88 89 90 91 92 93 9 4 95 96 97 98 99 100 50 4 9 4 8 4 7 4 6 4 5 44 4 3 4 2 4 1 4 0 39 38 37 36 35 3 4 33 32 31 30 29 28 27 26 75 7 4 73 72 71 70 69 68 67 66 65 6 4 63 62 61 60 59 58 57 56 55 5 4 53 52 51 1 2 3 4 5 6 7 8 9 10 11 12 13 1 4 15 16 17 18 19 20 21 22 23 2 4 25 pa0 / a16 p10 /ti oca0 / a20 p11 /ti ocb0 / a21 p12 /ti occ0 /t c lk a / a22 p13 /ti ocd0 /t c lk b / a23 p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d pc0 / a0 pc1 / a1 pc2 / a2 pc3 / a3 md0 md1 md2 pc 4/ a 4 pc5 / a5 pc6 / a6 pc7 / a7 usp n d /t mow p30 /t xd0 p31 / rxd0 p32 / sc k 0 / i rq 4 pg1 / cs3 / i rq7 pd3 / d11 pd2 / d10 pd1 / d9 pd0 / d8 p e 7 / d7 p e 6 / d6 p e 5 / d5 p e4/ d 4 p e 3 / d3 p e 2 / d2 p e 1 / d1 p e 0 / d0 p70 / cs 4 vcc e x t a l x t a l vss r e s s t by p71 / cs 5 p7 4/ m r e s osc1 osc2 pb7 / a15 pb6 / a1 4 figure 1.5 pin arrangements of HD64F2218 and HD64F2218u (tfp-100g, tfp-100gv) section 1 overview rev.6.00 jun. 03, 2008 page 8 of 698 rej09b0074-0600 11 10 9 8 7 6 5 4 3 2 1 n c pd3 / d11 pd0 / d8 p e 5 / d5 p e 2 / d2 p70 / cs 4 x t a l s t by osc1 pb7 / a15 n c pd5 / d13 pd 4/ d12 pd2 / d10 p e 7 / d7 p e 3 / d3 p e 0 / d0 e x t a l p71 / cs 5 osc2 pb6 / a1 4 pb5 / a13 f w e * 1 pd7 / d15 n c pd1 / d9 p e4/ d 4 vcc vss p7 4/ m r e s n cpb 4/ a12 ubp m t do * 2 e m le * 2 n m i pd6 / d1 4 p e 6 / d6 p e 1 / d1 r e s n cp ll vcc p ll vss p 4 1 / a n 1 t rs t * 2 t d i * 2 t ms * 2 t c k * 2 p 4 0 / a n 0p 4 2 / a n 2p 4 3 / a n 3 n c p f 7 / vss vcc p f 6 / a s vref pb1 / a9 pb3 / a11 pb2 / a10 p f 5 / rd p f4/ h wr p f 3 / l wr / a d t rg / i rq3 p f 1 / b a ck drvss p97 / a n 15 pb0 / a8 p96 / a n 1 4 p f 2 / w ait p f 0 / br e q / i rq2 pa2 / a18 / rxd2 p11 / ti ocb0 / a21 p17 / ti ocb2 / t c lk d md2 usp n d / t mow pg 4/ cs0 drvcc usd + usd - pa3 / a19 / sc k 2 pa1 / a17 / t xd2 n c p1 4/ ti oca1 / i rq0 pc0 / a0 pc3 / a3 pc6 / a6 p32 / sc k 0 / i rq 4 n c vbus p36 (pudp + ) n c pa0 / a16 p12 / ti occ0 / t c lk a / a22 p15 / ti ocb1 / t c lk c pc2 / a2 md1 pc5 / a5 p30 /t xd0 pg1 / cs3 / i rq7 pg2 / cs2 pg3 / cs 1 n c p10 / ti oca0 / a20 p13 / ti ocd0 / t c lk b / a23 p16 / ti oca2 / i rq 1 pc1 / a1 md0 pc 4/ a 4 pc7 / a7 p31 / rxd0 n c n c bp - 112 bp - 112v ( t op v i e w ) abcd ef g hjkl abcd ef g hjkl in d e x n otes : n c (no connect i on) : t hese p i ns shou l d not be connected ; they shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2218 and h d6 4f 2218u . 2 . when e m le = 0, boundary scan i s ava il ab l e and the p i ns funct i on as t do, t c k , t ms, t rs t , and t d i , respect i ve l y . when e m le = 1, h- ud i funct i on i s ava il ab l e and the p i ns funct i on as t do, t c k , t ms, t rs t , and t d i , respect i ve l y . figure 1.6 pin arrangements of HD64F2218 and HD64F2218u (bp-112, bp-112v) section 1 overview rev.6.00 jun. 03, 2008 page 9 of 698 rej09b0074-0600 tf p - 100g tf p - 100gv ( t op v i e w ) n otes : n c (no connect i on) : t hese p i ns shou l d not be connected ; they shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2218 and h d6 4f 2218u . i t shou l d be f i xed l o w. 2 . n e i ther boundary scan nor h- ud i funct i on i s ava il ab l e and the p i ns funct i on as n c . pd 4/ d12 pd5 / d13 pd6 / d1 4 pd7 / d15 f w e * 1 n m i n c * 2 n c * 2 n c * 2 n c * 2 n c * 2 n c * 2 vcc p f 7 / vss p f 6 / a s p f 5 / rd p f4/ h wr p f 3 / l wr / a d t rg / i rq3 p f 2 / w ait p f 1 / b a ck p f 0 / br e q / i rq2 pa3 / a19 / sc k 2 pa2 / a18 / rxd2 pa1 / a17 /t xd2 pb5 / a13 pb 4/ a12 p ll vcc ubp m p ll vss p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 vref pb3 / a11 pb2 / a10 pb1 / a9 pb0 / a8 p96 / a n 1 4 p97 / a n 15 drvss usd - usd + drvcc p36(pupd + ) vbus pg 4/ cs0 pg3 / cs 1 pg2 / cs2 76 77 78 79 80 81 82 83 8 4 85 86 87 88 89 90 91 92 93 9 4 95 96 97 98 99 100 50 4 9 4 8 4 7 4 6 4 5 44 4 3 4 2 4 1 4 0 39 38 37 36 35 3 4 33 32 31 30 29 28 27 26 75 7 4 73 72 71 70 69 68 67 66 65 6 4 63 62 61 60 59 58 57 56 55 5 4 53 52 51 1 2 3 4 5 6 7 8 9 10 11 12 13 1 4 15 16 17 18 19 20 21 22 23 2 4 25 pa0 / a16 p10 /ti oca0 / a20 p11 /ti ocb0 / a21 p12 /ti occ0 /t c lk a / a22 p13 /ti ocd0 /t c lk b / a23 p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d pc0 / a0 pc1 / a1 pc2 / a2 pc3 / a3 md0 md1 md2 pc 4/ a 4 pc5 / a5 pc6 / a6 pc7 / a7 usp n d /t mow p30 /t xd0 p31 / rxd0 p32 / sc k 0 / i rq 4 pg1 / cs3 / i rq7 pd3 / d11 pd2 / d10 pd1 / d9 pd0 / d8 p e 7 / d7 p e 6 / d6 p e 5 / d5 p e4/ d 4 p e 3 / d3 p e 2 / d2 p e 1 / d1 p e 0 / d0 p70 / cs 4 vcc e x t a l x t a l vss r e s s t by p71 / cs 5 p7 4/ m r e s osc1 osc2 pb7 / a15 pb6 / a1 4 figure 1.7 pin arrangements of hd6432217 (tfp-100g, tfp-100gv) section 1 overview rev.6.00 jun. 03, 2008 page 10 of 698 rej09b0074-0600 11 10 9 8 7 6 5 4 3 2 1 n c pd3 / d11 pd0 / d8 p e 5 / d5 p e 2 / d2 p70 / cs 4 x t a l s t by osc1 pb7 / a15 n c pd5 / d13 pd 4/ d12 pd2 / d10 p e 7 / d7 p e 3 / d3 p e 0 / d0 e x t a l p71 / cs 5 osc2 pb6 / a1 4 pb5 / a13 f w e * 1 pd7 / d15 n c pd1 / d9 p e4/ d 4 vcc vss p7 4/ m r e s n cpb 4/ a12 ubp m n c * 2 n c * 2 n m i pd6 / d1 4 p e 6 / d6 p e 1 / d1 r e s n cp ll vcc p ll vss p 4 1 / a n 1 n c * 2 n c * 2 n c * 2 n c * 2 p 4 0 / a n 0p 4 2 / a n 2p 4 3 / a n 3 n c p f 7 / vss vcc p f 6 / a s vref pb1 / a9 pb3 / a11 pb2 / a10 p f 5 / rd p f4/ h wr p f 3 / l wr / a d t rg / i rq3 p f 1 / b a ck drvss p97 / a n 15 pb0 / a8 p96 / a n 1 4 p f 2 / w ait p f 0 / br e q / i rq2 pa2 / a18 / rxd2 p11 / ti ocb0 / a21 p17 / ti ocb2 / t c lk d md2 usp n d / t mow pg 4/ cs0 drvcc usd + usd - pa3 / a19 / sc k 2 pa1 / a17 / t xd2 n c p1 4/ ti oca1 / i rq0 pc0 / a0 pc3 / a3 pc6 / a6 p32 / sc k 0 / i rq 4 n c vbus p36 (pudp + ) n c pa0 / a16 p12 / ti occ0 / t c lk a / a22 p15 / ti ocb1 / t c lk c pc2 / a2 md1 pc5 / a5 p30 /t xd0 pg1 / cs3 / i rq7 pg2 / cs2 pg3 / cs 1 n c p10 / ti oca0 / a20 p13 / ti ocd0 / t c lk b / a23 p16 / ti oca2 / i rq 1 pc1 / a1 md0 pc 4/ a 4 pc7 / a7 p31 / rxd0 n c n c bp - 112 bp - 112v ( t op v i e w ) abcd ef g hjkl abcd ef g hjkl in d e x n otes : n c (no connect i on) : t hese p i ns shou l d not be connected ; they shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2218 and h d6 4f 2218u . i t shou l d be f i xed l o w. 2 . n e i ther boundary scan nor h- ud i funct i on i s ava il ab l e and the p i ns funct i on as n c . figure 1.8 pin arrangements of hd6432217 (bp-112, bp-112v) section 1 overview rev.6.00 jun. 03, 2008 page 11 of 698 rej09b0074-0600 n otes : n c (no connect i on) : t h i s p i n shou l d not be connected ; i t shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2212, h d6 4f 2212u, h d6 4f 2211, and h d6 4f 2211u . 2 . when e m le = 0, port funct i on i s ava il ab l e and the p i ns funct i on as p77, p76, p75, n c, and pg0, respect i ve l y . when e m le = 1, h- ud i funct i on i s ava il ab l e and the p i ns funct i on as t do, t c k , t ms, t rs t , and t d i , respect i ve l y . p10 /ti oca0 p11 /ti ocb0 p12 /ti occ0 /t c lk a p13 /ti ocd0 /t c lk b p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d md0 md1 md2 usp n d /t mow p30 /t xd0 p31 / rxd0 p32 / sc k 0 / i rq 4 pg1 / i rq7 123 4 5 6 7 8 9 101112131 4 15 16 4 8 4 7 4 6 4 5 44 4 3 4 2 4 1 4 039383736353 4 33 p e 7 p e 6 p e 5 p e4 p e 3 p e 2 p e 1 p e 0 vcc e x t a l x t a l vss r e s s t by osc1 osc2 32 31 30 29 28 27 26 25 2 4 23 22 21 20 19 18 17 4 9 50 51 52 53 5 4 55 56 57 58 59 60 61 62 63 6 4 f w e * 1 n m i e m le * 2 t do / p77 * 2 t c k/ p76 * 2 t ms / p75 * 2 t rs t /n c * 2 t d i/ pg0 * 2 vcc p f 7 / vss p f 3 / a d t rg / i rq3 p f 0 / i rq2 pa3 / sc k 2 pa2 / rxd2 pa1 /t xd2 p ll vcc ubp m p ll vss p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 vref p96 / a n 1 4 p97 / a n 15 drvss usd - usd + drvcc p36 (pupd + ) vbus f p - 6 4e f p - 6 4e v ( t op v i e w ) figure 1.9 pin arrangements of hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u (fp-64e, fp-64ev) section 1 overview rev.6.00 jun. 03, 2008 page 12 of 698 rej09b0074-0600 n otes : n c (no connect i on) : t hese p i ns shou l d not be connected ; they shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2212, h d6 4f 2212u, h d6 4f 2211, and h d6 4f 2211u . i t shou l d be f i xed l o w. 2 . t he port funct i on i s ava il ab l e and the p i ns funct i on as n c, p77, p76, p75, n c, and pg0, respect i ve l y . p10 /ti oca0 p11 /ti ocb0 p12 /ti occ0 /t c lk a p13 /ti ocd0 /t c lk b p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d md0 md1 md2 usp n d /t mow p30 /t xd0 p31 / rxd0 p32 / sc k 0 / i rq 4 pg1 / i rq7 123 4 5 6 7 8 9 101112131 4 15 16 4 8 4 7 4 6 4 5 44 4 3 4 2 4 1 4 039383736353 4 33 p e 7 p e 6 p e 5 p e4 p e 3 p e 2 p e 1 p e 0 vcc e x t a l x t a l vss r e s s t by osc1 osc2 32 31 30 29 28 27 26 25 2 4 23 22 21 20 19 18 17 4 9 50 51 52 53 5 4 55 56 57 58 59 60 61 62 63 6 4 f w e * 1 n m i n c * 2 p77 * 2 p76 * 2 p75 * 2 n c * 2 pg0 * 2 vcc p f 7 / vss p f 3 / a d t rg / i rq3 p f 0 / i rq2 pa3 / sc k 2 pa2 / rxd2 pa1 /t xd2 p ll vcc ubp m p ll vss p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 vref p96 / a n 1 4 p97 / a n 15 drvss usd - usd + drvcc p36 (pupd + ) vbus f p - 6 4e f p - 6 4e v ( t op v i e w ) figure 1.10 pin arrangements of hd6432211, hd6432210 and hd6432210s (fp-64e, fp-64ev) section 1 overview rev.6.00 jun. 03, 2008 page 13 of 698 rej09b0074-0600 n otes : n c (no connect i on) : t h i s p i n shou l d not be connected ; i t shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2212, h d6 4f 2212u, h d6 4f 2211, and h d6 4f 2211u . 2 . when e m le = 0, the port funct i on i s enab l ed (p77, p76, p75, n c, and pg0) . when e m le = 1, the h- ud i funct i on i s enab l ed ( t do, t c k , t ms, t rs t , and t d i ) . p10 /ti oca0 p11 /ti ocb0 p12 /ti occ0 /t c lk a p13 /ti ocd0 /t c lk b p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d md0 md1 md2 usp n d /t mow p30 /t xd0 p31 / rxd0 p32 / sc k 0 / i rq 4 pg1 / i rq7 123 4 5 6 7 8 9 101112131 4 15 16 4 8 4 7 4 6 4 5 44 4 3 4 2 4 1 4 039383736353 4 33 p e 7 p e 6 p e 5 p e4 p e 3 p e 2 p e 1 p e 0 vcc e x t a l x t a l vss r e s s t by osc1 osc2 32 31 30 29 28 27 26 25 2 4 23 22 21 20 19 18 17 4 9 50 51 52 53 5 4 55 56 57 58 59 60 61 62 63 6 4 f w e * 1 n m i e m le * 2 t do / p77 * 2 t c k/ p76 * 2 t ms / p75 * 2 t rs t /n c * 2 t d i/ pg0 * 2 vcc p f 7 / vss p f 3 / a d t rg / i rq3 p f 0 / i rq2 pa3 / sc k 2 pa2 / rxd2 pa1 /t xd2 p ll vcc ubp m p ll vss p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 vref p96 / a n 1 4 p97 / a n 15 drvss usd - usd + drvcc p36 (pupd + ) vbus tn p - 6 4 b tn p - 6 4 bv ( t op v i e w ) figure 1.11 pin arrangements of hd64f2212, hd64f2212u, hd64f2211, and hd64f2211u (tnp-64b, tnp-64bv) section 1 overview rev.6.00 jun. 03, 2008 page 14 of 698 rej09b0074-0600 p10 /ti oca0 p11 /ti ocb0 p12 /ti occ0 /t c lk a p13 /ti ocd0 /t c lk b p1 4/ti oca1 / i rq0 p15 /ti ocb1 /t c lk c p16 /ti oca2 / i rq 1 p17 /ti ocb2 /t c lk d md0 md1 md2 usp n d /t mow p30 /t xd0 p31 / rxd0 p32 / sc k 0 / i rq 4 pg1 / i rq7 123 4 5 6 7 8 9 101112131 4 15 16 4 8 4 7 4 6 4 5 44 4 3 4 2 4 1 4 039383736353 4 33 p e 7 p e 6 p e 5 p e4 p e 3 p e 2 p e 1 p e 0 vcc e x t a l x t a l vss r e s s t by osc1 osc2 32 31 30 29 28 27 26 25 2 4 23 22 21 20 19 18 17 4 9 50 51 52 53 5 4 55 56 57 58 59 60 61 62 63 6 4 f w e * 1 n m i n c * 2 p77 * 2 p76 * 2 p75 * 2 n c * 2 pg0 * 2 vcc p f 7 / vss p f 3 / a d t rg / i rq3 p f 0 / i rq2 pa3 / sc k 2 pa2 / rxd2 pa1 /t xd2 p ll vcc ubp m p ll vss p 4 0 / a n 0 p 4 1 / a n 1 p 4 2 / a n 2 p 4 3 / a n 3 vref p96 / a n 1 4 p97 / a n 15 drvss usd - usd + drvcc p36 (pupd + ) vbus tn p - 6 4 b tn p - 6 4 bv ( t op v i e w ) n otes : n c (no connect i on) : t hese p i ns shou l d not be connected ; they shou l d be l eft open . 1 . t he f w e p i n i s prov i ded on l y i n the h d6 4f 2212, h d6 4f 2212u, h d6 4f 2211, and h d6 4f 2211u . i t shou l d be f i xed l o w. 2 . t he port funct i on i s enab l ed (p77, p76, p75, n c, and pg0) . figure 1.12 pin arrangements of hd6432211, hd6432210 and hd6432210s (tnp-64b, tnp-64bv) section 1 overview rev.6.00 jun. 03, 2008 page 15 of 698 rej09b0074-0600 1.4 pin functions in each operating mode table 1.1 shows the pin functions in each operating mode for the h8s/2218 group, and table 1.2 shows that for the h8s/2212 group. table 1.1 pin functions in each operating mode for h8s/2218 group pin no. pin name * tfp-100g, tfp-100gv bp-112, bp-112v modes 4, 5 mode 6 mode 7 programmer mode 1 b2 pa0/a16 pa0/a16 pa0 nc 2 b1 p10/tioca0/a20 p10/tioca0/a20 p10/tioca0 a2 3 d4 p11/tiocb0/a21 p11/tiocb0/a21 p11/tiocb0 a3 4 c2 p12/tiocc0/tclka/a22 p12/tiocc0/tclka/a22 p12/tiocc0/tclka a4 5 c1 p13/tiocd0/tclkb/a23 p13/tiocd0/tclkb/a23 p13/tiocd0/tclkb a5 6 d3 p14/tioca1/ irq0 p14/tioca1/ irq0 p14/tioca1/ irq0 vss 7 d2 p15/tiocb1/tclkc p15/tiocb1/tclkc p15/tiocb1/tclkc we 8 d1 p16/tioca2/ irq1 p16/tioca2/ irq1 p16/tioca2/ irq1 vss 9 e4 p17/tiocb2/tclkd p17/tiocb2/tclkd p17/tiocb2/tclkd ce 10 e3 a0 pc0/a0 pc0 nc 11 e1 a1 pc1/a1 pc1 nc 12 e2 a2 pc2/a2 pc2 nc 13 f3 a3 pc3/a3 pc3 nc 14 f1 md0 md0 md0 vss 15 f2 md1 md1 md1 vss 16 f4 md2 md2 md2 vss 17 g1 a4 pc4/a4 pc4 nc 18 g2 a5 pc5/a5 pc5 nc 19 g3 a6 pc6/a6 pc6 nc 20 h1 a7 pc7/a7 pc7 nc 21 g4 uspnd/tmow uspnd/tmow uspnd/tmow nc 22 h2 p30/txd0 p30/txd0 p30/txd0 a10 23 j1 p31/rxd0 p31/rxd0 p31/rxd0 a11 24 h3 p32/sck0/ irq4 p32/sck0/ irq4 p32/sck0/ irq4 a12 25 j2 pg1/ cs3 / irq7 pg1/ cs3 / irq7 pg1/ irq7 a15 section 1 overview rev.6.00 jun. 03, 2008 page 16 of 698 rej09b0074-0600 pin no. pin name * tfp-100g, tfp-100gv bp-112, bp-112v modes 4, 5 mode 6 mode 7 programmer mode 26 k2 pg2/ cs2 pg2/ cs2 pg2 nc 27 l2 pg3/ cs1 pg3/ cs1 pg3 nc 28 h4 pg4/ cs0 pg4/ cs0 pg4 nc 29 k3 vbus vbus vbus vss 30 l3 p36 (pudp+) p36 (pudp+) p36 (pudp+) a16 31 j4 drvcc drvcc drvcc vcc 32 k4 usd+ usd+ usd+ nc 33 l4 usd- usd- usd- nc 34 h5 drvss drvss drvss vss 35 j5 p97/an15 p97/an15 p97/an15 a7 36 l5 p96/an14 p96/an14 p96/an14 a6 37 k5 pb0/a8 pb0/a8 pb0 nc 38 j6 pb1/a9 pb1/a9 pb1 nc 39 l6 pb2/a10 pb2/a10 pb2 nc 40 k6 pb3/a11 pb3/a11 pb3 nc 41 h6 vref vref vref vcc 42 k7 p43/an3 p43/an3 p43/an3 a14 43 j7 p42/an2 p42/an2 p42/an2 a13 44 l8 p41/an1 p41/an1 p41/an1 a9 45 h7 p40/an0 p40/an0 p40/an0 a8 46 k8 pllvss pllvss pllvss vss 47 l9 ubpm ubpm ubpm a17 48 j8 pllvcc pllvcc pllvcc vcc 49 k9 pb4/a12 pb4/a12 pb4 nc 50 l10 pb5/a13 pb5/a13 pb5 nc 51 k10 pb6/a14 pb6/a14 pb6 nc 52 k11 pb7/a15 pb7/a15 pb7 nc 53 j10 osc2 osc2 osc2 nc 54 j11 osc1 osc1 osc1 vcc 55 h9 p74/ mres p74/ mres p74/ mres nc section 1 overview rev.6.00 jun. 03, 2008 page 17 of 698 rej09b0074-0600 pin no. pin name * tfp-100g, tfp-100gv bp-112, bp-112v modes 4, 5 mode 6 mode 7 programmer mode 56 h10 p71/ cs5 p71/ cs5 p71 nc 57 h11 stby stby stby vcc 58 g8 res res res res 59 g9 vss vss vss vss 60 g11 xtal xtal xtal xtal 61 g10 extal extal extal extal 62 f9 vcc vcc vcc vcc 63 f11 p70/ cs4 p70/ cs4 p70 nc 64 f10 pe0/d0 pe0/d0 pe0 d0 65 f8 pe1/d1 pe1/d1 pe1 d1 66 e11 pe2/d2 pe2/d2 pe2 d2 67 e10 pe3/d3 pe3/d3 pe3 d3 68 e9 pe4/d4 pe4/d4 pe4 d4 69 d11 pe5/d5 pe5/d5 pe5 d5 70 e8 pe6/d6 pe6/d6 pe6 d6 71 d10 pe7/d7 pe7/d7 pe7 d7 72 c11 d8 d8 pd0 nc 73 d9 d9 d9 pd1 nc 74 c10 d10 d10 pd2 nc 75 b11 d11 d11 pd3 nc 76 b10 d12 d12 pd4 nc 77 a10 d13 d13 pd5 nc 78 d8 d14 d14 pd6 nc 79 b9 d15 d15 pd7 nc 80 a9 fwe fwe fwe fwe 81 c8 nmi nmi nmi vcc 82 b8 emle/nc emle/nc emle/nc vss 83 a8 tdo/nc tdo/nc tdo/nc nc 84 d7 tck/nc tck/nc tck/nc vcc 85 c7 tms/nc tms/nc tms/nc vcc section 1 overview rev.6.00 jun. 03, 2008 page 18 of 698 rej09b0074-0600 pin no. pin name * tfp-100g, tfp-100gv bp-112, bp-112v modes 4, 5 mode 6 mode 7 programmer mode 86 a7 trst /nc trst /nc trst /nc res 87 b7 tdi/nc tdi/nc tdi/nc vss 88 c6 vcc vcc vcc vcc 89 a6 pf7/ pf7/ pf7/ nc 90 b6 vss vss vss vss 91 d6 as as pf6 nc 92 a5 rd rd pf5 nc 93 b5 hwr hwr pf4 nc 94 c5 pf3/ lwr / adtrg / irq3 pf3/ lwr / adtrg / irq3 pf3/ adtrg / irq3 vcc 95 a4 pf2/ wait pf2/ wait pf2 nc 96 d5 pf1/ back pf1/ back pf1 nc 97 b4 pf0/ breq / irq2 pf0/ breq / irq2 pf0/ irq2 vcc 98 a3 pa3/a19/sck2 pa3/a19/sck2 pa3/sck2 a1 99 c4 pa2/a18/rxd2 pa2/a18/rxd2 pa2/rxd2 a0 100 b3 pa1/a17/txd2 pa1/a17/txd2 pa1/txd2 oe note: * the nc should be left open. table 1.2 pin functions in each operating mode for h8s/2212 group pin no. pin name * fp-64e, fp-64ev, tnp-64b, tnp-64bv mode 7 programmer mode 1 p10/tioca0 a2 2 p11/tiocb0 a3 3 p12/tiocc0/tclka a4 4 p13/tiocd0/tclkb a5 5 p14/tioca1/ irq0 vss 6 p15/tiocb1/tclkc we 7 p16/tioca2/ irq1 vss 8 p17/tiocb2/tclkd ce 9 md0 vss section 1 overview rev.6.00 jun. 03, 2008 page 19 of 698 rej09b0074-0600 pin no. pin name * fp-64e, fp-64ev, tnp-64b, tnp-64bv mode 7 programmer mode 10 md1 vss 11 md2 vss 12 uspnd/tmow nc 13 p30/txd0 a10 14 p31/rxd0 a11 15 p32/sck0/ irq4 a12 16 pg1/ irq7 a15 17 vbus vss 18 p36(pd+) a16 19 drvcc vcc 20 usd+ nc 21 usd- nc 22 drvss vss 23 p97/an15 a7 24 p96/an14 a6 25 vref vcc 26 p43/an3 a14 27 p42/an2 a13 28 p41/an1 a9 29 p40/an0 a8 30 pllvss vss 31 ubpm a17 32 pllvcc vcc 33 osc2 nc 34 osc1 vcc 35 stby vcc 36 res res 37 vss vss 38 xtal xtal section 1 overview rev.6.00 jun. 03, 2008 page 20 of 698 rej09b0074-0600 pin no. pin name * fp-64e, fp-64ev, tnp-64b, tnp-64bv mode 7 programmer mode 39 extal extal 40 vcc vcc 41 pe0 d0 42 pe1 d1 43 pe2 d2 44 pe3 d3 45 pe4 d4 46 pe5 d5 47 pe6 d6 48 pe7 d7 49 fwe fwe 50 nmi vcc 51 emle/nc vss 52 tdo/p77 nc 53 tck/p76 vcc 54 tms/p75 vcc 55 trst /nc res 56 tdi/pg0 vss 57 vcc vcc 58 pf7/ nc 59 vss vss 60 pf3/ adtrg / irq3 vcc 61 pf0/ irq2 vcc 62 pa3/sck2 a1 63 pa2/rxd2 a0 64 pa1/txd2 oe note: * the nc should be left open. section 1 overview rev.6.00 jun. 03, 2008 page 21 of 698 rej09b0074-0600 1.5 pin functions pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function vcc input 62 88 f9 c6 40 57 power supply pins. connect all these pins to the system power supply. vss input 59 90 g9 b6 37 59 ground pins. connect all these pins to the system power supply (0 v). pllvcc 48 j8 32 input power supply pin for an on-chip pll oscillator. connect this pin to the system power supply. power supply pllvss 46 k8 30 input ground pin for an on-chip pll oscillator xtal 60 g11 38 input for connection to a crystal resonator. for examples of crystal resonator connection and external clock input, see section 19, clock pulse generator. clock extal 61 g10 39 input for connection to a crystal resonator. an external clock can be supplied from the extal pin. for examples of crystal resonator connection and external clock input, see section 19, clock pulse generator. osc1 osc2 54 53 j11 j10 34 33 input for connection to a 32.768-khz crystal resonator. for examples of crystal resonator connection, see section 19, clock pulse generator. 89 a6 58 output supplies the system clock to external devices. operating mode control md2 md1 md0 16 15 14 f4 f2 f1 11 10 9 input set the operating mode. inputs at these pins cannot be modified during operation. sets the operating mode. inputs at these pins should not be changed during operation. except for mode changing, be sure to fix the levels of the mode pins (md2 to md0) by pulling them down or pulling them up until the power turns off. section 1 overview rev.6.00 jun. 03, 2008 page 22 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function res * 58 g8 36 input reset pin. when this pin is driven low, the chip is reset. stby * 57 h11 35 input when this pin is driven low, a transition is made to hardware standby mode. mres 55 h9 ? input when this pin is driven low, a transition is made to manual reset mode. (supported only by the h8s/2218 group) breq 97 b4 ? input used by an external bus master to issue a bus request to this lsi (supported only by the h8s/2218 group) back 96 d5 ? output indicates that the bus has been released to an external bus master. (supported only by the h8s/2218 group) fwe 80 a9 49 input pin for use by flash memory. this pin is only used in the flash memory version. in the masked rom version, it should be connected to the system power supply (0 v). system control emle 82 b8 51 input emulator enable when e10a is not used, connect this pin to the system power supply (0 v). when e10a is used, this pin should be fixed high. interrupts nmi * 81 c8 50 input nonmaskable interrupt pin. if this pin is not used, it should be fixed high. irq7 irq4 irq3 irq2 irq1 irq0 25 24 94 97 8 6 j2 h3 c5 b4 d1 d3 16 15 60 61 7 5 input these pins request a maskable interrupt. section 1 overview rev.6.00 jun. 03, 2008 page 23 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function address bus a23 a22 a21 a20 a19 a18 a17 a16 a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 5 4 3 2 98 99 100 1 52 51 50 49 40 39 38 37 20 19 18 17 13 12 11 10 c1 c2 d4 b1 a3 c4 b3 b2 k11 k10 l10 k9 k6 l6 j6 k5 h1 g3 g2 g1 f3 e2 e1 e3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? output these pins output an address. (supported only by the h8s/2218 group) section 1 overview rev.6.00 jun. 03, 2008 page 24 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function data bus d15 d14 d13 d12 d11 d10 d9 d8 d7 d6 d5 d4 d3 d2 d1 d0 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 b9 d8 a10 b10 b11 c10 d9 c11 d10 e8 d11 e9 e10 e11 f8 f10 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? i/o these pins constitute a bi- directional data bus. (supported only by the h8s/2218 group) bus control cs5 cs4 cs3 cs2 cs1 cs0 56 63 25 26 27 28 h10 f11 j2 k2 l2 h4 ? ? ? ? ? ? output signals for selecting areas 5 to 0 in the external address space. (supported only by the h8s/2218 group) as 91 d6 ? output when this pin is low, it indicates that address output on the address bus is enabled. (supported only by the h8s/2218 group) rd 92 a5 ? output when this pin is low, it indicates that the external address space can be read. (supported only by the h8s/2218 group) section 1 overview rev.6.00 jun. 03, 2008 page 25 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function bus control hwr 93 b5 ? output a strobe signal that writes to external address space and indicates that the upper half (d15 to d8) of the data bus is enabled. (supported only by the h8s/2218 group) lwr 94 c5 ? output a strobe signal that writes to external address space and indicates that the lower half (d7 to d0) of the data bus is enabled. (supported only by the h8s/2218 group) wait 95 a4 ? input requests insertion of a wait state in the bus cycle when accessing external 3-state address space. (supported only by the h8s/2218 group) tclka tclkb tclkc tclkd 4 5 7 9 c2 c1 d2 e4 3 4 6 8 input tpu external clock input pins tioca0 tiocb0 tiocc0 tiocd0 2 3 4 5 b1 d4 c2 c1 1 2 3 4 i/o the tgra_0 to tgrd_0 input capture input/output compare output/pwm output pins tioca1 tiocb1 6 7 d3 d2 5 6 i/o the tgra_1 and tgrb_1 input capture input/output compare output/pwm output pins 16-bit timer pulse unit (tpu) tioca2 tiocb2 8 9 d1 e4 7 8 i/o the tgra_2 and tgrb_2 input capture input/output compare output/pwm output pins realtime clock (rtc) tmow 21 g4 12 output the divided clock output pin section 1 overview rev.6.00 jun. 03, 2008 page 26 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function txd2 txd0 100 22 b3 h2 64 13 output data output pins rxd2 rxd0 99 23 c4 j1 63 14 input data input pins serial communica- tion interface (sci) sck2 sck0 98 24 a3 h3 62 15 i/o clock input/output pins an15 an14 an3 an2 an1 an0 35 36 42 43 44 45 j5 l5 k7 j7 l8 h7 23 24 26 27 28 29 input analog input pins for the a/d converter adtrg 94 c5 60 input pin for input of an external trigger to start a/d conversion a/d converter vref 41 h6 25 input the reference voltage input pin for the a/d converter. when the a/d converter is not used, this pin should be connected to the system power supply (vcc). tms 85 c7 54 input control signal input pin for the boundary scan tck 84 d7 53 input clock input pin for the boundary scan tdo 83 a8 52 output data output pin for the boundary scan tdi 87 b7 56 input data input pin for the boundary scan boundary scan (supported only by the HD64F2218 and HD64F2218u) trst 86 a7 55 input reset pin for the tap controller usb drvcc 31 j4 19 input power supply pin for the on-chip transceiver. connect this pin to the system power supply. drvss 34 h5 22 input ground pin for the on-chip transceiver. section 1 overview rev.6.00 jun. 03, 2008 page 27 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function usb usd+ * usd- * 32 33 k4 l4 20 21 i/o usb data i/o pin vbus * 29 k3 17 input connection/disconnection detecting input pin for the usb cable uspnd 21 g4 12 output usb suspend output this pin is driven high when a transition is made to suspend state. ubpm 47 l9 31 input bus power/self power mode setting input when the usb is used in bus power mode, this input pin must be fixed low. when the usb is used in self power mode, this input pin must be fixed high. p36 (pupd+) 30 l3 18 i/o use as d+ signal pull-up control pin. i/o port p17 p16 p15 p14 p13 p12 p11 p10 9 8 7 6 5 4 3 2 e4 d1 d2 d3 c1 c2 d4 b1 8 7 6 5 4 3 2 1 i/o 8-bit i/o pins p36 p32 p31 p30 30 24 23 22 l3 h3 j1 h2 18 15 14 13 i/o 4-bit i/o pins (use p36 as d+ signal pull-up control pin of usb.) p43 42 k7 26 input 4-bit input pins p42 43 j7 27 p41 44 l8 28 p40 45 h7 29 section 1 overview rev.6.00 jun. 03, 2008 page 28 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function i/o port p77 p76 p75 p74 p71 p70 ? ? ? 55 56 63 ? ? ? h9 h10 f11 52 53 54 ? ? ? i/o 3-bit i/o pins p97 p96 35 36 j5 l5 23 24 input 2-bit input pins pa3 pa2 pa1 pa0 98 99 100 1 a3 c4 b3 b2 62 63 64 ? i/o 4-bit i/o pins for the h8s/2218 group. 3-bit i/o pins for the h8s/2212 group. pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 52 51 50 49 40 39 38 37 k11 k10 l10 k9 k6 l6 j6 k5 ? ? ? ? ? ? ? ? i/o 8-bit i/o pins (supported only by the h8s/2218 group) pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 20 19 18 17 13 12 11 10 h1 g3 g2 g1 f3 e2 e1 e3 ? ? ? ? ? ? ? ? i/o 8-bit i/o pins (supported only by the h8s/2218 group) section 1 overview rev.6.00 jun. 03, 2008 page 29 of 698 rej09b0074-0600 pin no. type symbol tfp-100g, tfp-100gv bp-112, bp-112v fp-64e, fp-64ev, tnp-64b, tnp-64bv i/o function i/o port pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 79 78 77 76 75 74 73 72 b9 d8 a10 b10 b11 c10 d9 c11 ? ? ? ? ? ? ? ? i/o 8-bit i/o pins (supported only by the h8s/2218 group) pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 71 70 69 68 67 66 65 64 d10 e8 d11 e9 e10 e11 f8 f10 48 47 46 45 44 43 42 41 i/o 8-bit i/o pins pf7 pf6 pf5 pf4 pf3 pf2 pf1 pf0 89 91 92 93 94 95 96 97 a6 d6 a5 b5 c5 a4 d5 b4 58 ? ? ? 60 ? ? 61 i/o 8-bit i/o pins for the h8s/2218 group. 3-bit i/o pins for the h8s/2212 group. pg4 pg3 pg2 pg1 pg0 28 27 26 25 ? h4 l2 k2 j2 ? ? ? ? 16 56 i/o 4-bit i/o pins for the h8s/2218 group. 2-bit i/o pins for the h8s/2212 group. note: * anti-noise measures should be taken to prevent malfunction. section 1 overview rev.6.00 jun. 03, 2008 page 30 of 698 rej09b0074-0600 section 2 cpu rev.6.00 jun. 03, 2008 page 31 of 698 rej09b0074-0600 section 2 cpu the h8s/2000 cpu is a high-speed central processing unit with an internal 32-bit architecture that is upward compatible with the h8/300 and h8/300h cpus. the h8s/2000 cpu has sixteen 16-bit general registers, can address a 16-mbyte linear address space, and is ideal for realtime control. this section describes the h8s/2000 cpu. the usable modes and address spaces differ depending on the product. for details on each product, refer to section 3, mcu operating modes. 2.1 features ? upward-compatible with h8/300 and h8/300h cpus ? can execute h8/300 and h8/300h cpu object programs ? general-register architecture ? sixteen 16-bit general registers also usable as sixteen 8-bit registers or eight 32-bit registers ? sixty-five basic instructions ? 8/16/32-bit arithmetic and logic instructions ? multiply and divide instructions ? powerful bit-manipulation instructions ? eight addressing modes ? register direct [rn] ? register indirect [@ern] ? register indirect with displacement [@(d:16,ern) or @(d:32,ern)] ? register indirect with post-increment or pre-decrement [@ern+ or @?ern] ? absolute address [@aa:8, @aa:16, @aa:24, or @aa:32] ? immediate [#xx:8, #xx:16, or #xx:32] ? program-counter relative [@(d:8,pc) or @(d:16,pc)] ? memory indirect [@@aa:8] ? 16-mbyte address space ? program: 16 mbytes ? data: 16 mbytes ? high-speed operation ? all frequently-used instructions execute in one or two states ? 8/16/32-bit register-register add/subtract: 1 state ? 8 8-bit register-register multiply: 12 states ? 16 8-bit register-register divide: 12 states cpus211a_010020011200 section 2 cpu rev.6.00 jun. 03, 2008 page 32 of 698 rej09b0074-0600 ? 16 16-bit register-register multiply: 20 states ? 32 16-bit register-register divide: 20 states ? two cpu operating modes ? normal mode* ? advanced mode note: * normal mode is not available in this lsi. ? power-down state ? transition to power-down state by sleep instruction ? cpu clock speed selection 2.1.1 differences between h8 s/2600 cpu and h8s/2000 cpu the differences between the h8s/2600 cpu and the h8s/2000 cpu are as shown below. ? register configuration the mac register is supported only by the h8s/2600 cpu. ? basic instructions the four instructions mac, clrmac, ldmac, and stmac are supported only by the h8s/2600 cpu. ? the number of execution states of the mulxu and mulxs instructions execution states instruction mnemonic h8s/2600 h8s/2000 mulxu mulxu.b rs, rd 3 12 mulxu.w rs, erd 4 20 mulxs mulxs.b rs, rd 4 13 mulxs.w rs, erd 5 21 in addition, there are differences in address space, ccr and exr register functions, power-down modes, etc., depending on the model. section 2 cpu rev.6.00 jun. 03, 2008 page 33 of 698 rej09b0074-0600 2.1.2 differences from h8/300 cpu in comparison to the h8/300 cpu, the h8s/2000 cpu has the following enhancements. ? more general registers and control registers ? eight 16-bit extended registers, and one 8-bit and two 32-bit control registers, have been added. ? extended address space ? normal mode supports the same 64-kbyte address space as the h8/300 cpu. ? advanced mode supports a maximum 16-mbyte address space. ? enhanced addressing ? the addressing modes have been enhanced to make effective use of the 16-mbyte address space. ? enhanced instructions ? addressing modes of bit-manipulation instructions have been enhanced. ? signed multiply and divide instructions have been added. ? two-bit shift instructions have been added. ? instructions for saving and restoring multiple registers have been added. ? a test and set instruction has been added. ? higher speed ? basic instructions execute twice as fast. 2.1.3 differences from h8/300h cpu in comparison to the h8/300h cpu, the h8s/2000 cpu has the following enhancements. ? additional control register ? one 8-bit control registers have been added. ? enhanced instructions ? addressing modes of bit-manipulation instructions have been enhanced. ? two-bit shift instructions have been added. ? instructions for saving and restoring multiple registers have been added. ? a test and set instruction has been added. ? higher speed ? basic instructions execute twice as fast. section 2 cpu rev.6.00 jun. 03, 2008 page 34 of 698 rej09b0074-0600 2.2 cpu operating modes the h8s/2000 cpu has two operating modes: normal and advanced. normal mode supports a maximum 64-kbyte address space. advanced mode supports a maximum 16-mbyte total address space. the mode is selected by the mode pins. 2.2.1 normal mode the exception vector table and stack have the same structure as in the h8/300 cpu. ? address space a maximum address space of 64 kbytes can be accessed. ? extended registers (en) the extended registers (e0 to e7) can be used as 16-bit registers, or as the upper 16-bit segments of 32-bit registers. when en is used as a 16-bit register it can contain any value, even when the corresponding general register (rn) is used as an address register. if the general register is referenced in the register indirect addressing mode with pre-decrement (@?rn) or post-increment (@rn+) and a carry or borrow occurs, however, the value in the corresponding extended register (en) will be affected. ? instruction set all instructions and addressing modes can be used. only the lower 16 bits of effective addresses (ea) are valid. ? exception vector table and memory indirect branch addresses in normal mode the top area starting at h'0000 is allocated to the exception vector table. one branch address is stored per 16 bits. the excep tion vector table in normal mode is shown in figure 2.1. for details of the exception vector table, see section 4, exception handling. the memory indirect addressing mode (@@aa:8) employed in the jmp and jsr instructions uses an 8-bit absolute address included in the instruction code to specify a memory operand that contains a branch address. in normal mode the operand is a 16-bit (word) operand, providing a 16-bit branch address. branch addresses can be stored in the top area from h'0000 to h'00ff. note that this area is also used for the exception vector table. ? stack structure when the program counter (pc) is pushed onto the stack in a subroutine call, and the pc, condition-code register (ccr), and extended cont rol register (exr) are pushed onto the stack in exception handling, they are stored as shown in figure 2.2. exr is not pushed onto the stack in interrupt control mode 0. for details, see section 4, exception handling. note: normal mode is not available in this lsi. section 2 cpu rev.6.00 jun. 03, 2008 page 35 of 698 rej09b0074-0600 h'0000 h'0001 h'0002 h'0003 h'0004 h'0005 h'0006 h'0007 h'0008 h'0009 h'000a h'000b reset exception vector (reserved for system use) exception vector 1 exception vector 2 exception vector tabl e (reserved for system use) figure 2.1 exception vector table (normal mode) (a) subroutine branch (b) exception handling pc (16 bits) exr * 1 reserved * 1 * 3 ccr ccr * 3 pc (16 bits) sp sp notes: 1. 2. 3. when exr is not used, it is not stored on the stack. sp when exr is not used. ignored when returning. ( sp * 2 ) figure 2.2 stack stru cture in normal mode section 2 cpu rev.6.00 jun. 03, 2008 page 36 of 698 rej09b0074-0600 2.2.2 advanced mode ? address space linear access is provided to a 16-mbyte maximum address space. ? extended registers (en) the extended registers (e0 to e7) can be used as 16-bit registers, or as the upper 16-bit segments of 32-bit registers or address registers. ? instruction set all instructions and addressing modes can be used. ? exception vector table and memory indirect branch addresses in advanced mode the top area starting at h'00000000 is allocated to the exception vector table in units of 32 bits. in each 32 bits, the upper 8 bits are ignored and a branch address is stored in the lower 24 bits (figure 2.3). for details of th e exception vector table, see section 4, exception handling. h'00000000 h'00000003 h'00000004 h'0000000b h'0000000c h'00000010 h'00000008 h'00000007 reserved reserved reserved reset exception vector (reserved for system use) exception vector table exception vector 1 (reserved for system use) figure 2.3 excep tion vector tabl e (advanced mode) section 2 cpu rev.6.00 jun. 03, 2008 page 37 of 698 rej09b0074-0600 the memory indirect addressing mode (@@aa:8) employed in the jmp and jsr instructions uses an 8-bit absolute address included in the instruction code to specify a memory operand that contains a branch address. in advanced mode the operand is a 32-bit longword operand, providing a 32-bit branch address. the upper 8 bits of these 32 bits are a reserved area that is regarded as h'00. branch addresses can be stored in the area from h'00000000 to h'000000ff. note that the first part of this range is also the exception vector table. ? stack structure in advanced mode, when the program counter (pc) is pushed onto the stack in a subroutine call, and the pc, condition-code register (ccr), and extended control register (exr) are pushed onto the stack in exception handling, they are stored as shown in figure 2.4. when exr is invalid, it is not pushed onto the stack. for details, see section 4, exception handling. pc (24 bits) exr * 1 reserved * 1 * 3 ccr pc (24 bits) reserved (a) subroutine branch (b) exception handling when exr is not used, it is not stored on the stack. sp when exr is not used. ignored when returning. sp sp notes: 1. 2. 3. ( sp * 2 ) figure 2.4 stack stru cture in advanced mode section 2 cpu rev.6.00 jun. 03, 2008 page 38 of 698 rej09b0074-0600 2.3 address space figure 2.5 shows a memory map of the h8s/2000 cpu. the h8s/2000 cpu provides linear access to a maximum 64-kbyte address space in normal mode, and a maximum 16-mbyte (architecturally 4-gbyte) address space in advanced mode. the usable modes and address spaces differ depending on the product. for details on each product, refer to section 3, mcu operating modes. h'0000 h'ffff h'00000000 h'ffffffff h'00ffffff 64 kbytes 16 mbytes not available in this lsi. program area data area (b) advanced mode (a) normal mode * note: * not available in this lsi. figure 2.5 memory map section 2 cpu rev.6.00 jun. 03, 2008 page 39 of 698 rej09b0074-0600 2.4 register configuration the h8s/2000 cpu has the internal registers shown in figure 2.6. there are two types of registers: general registers and control registers. control registers are a 24-bit program counter (pc), an 8-bit extended control register (exr), and an 8-bit condition code register (ccr). ti2i1i0 exr 76543210 pc 23 0 15 0 7 0 7 0 e0 e1 e2 e3 e4 e5 e6 e7 r0h r1h r2h r3h r4h r5h r6h r7h r0l r1l r2l r3l r4l r5l r6l r7l sp: pc: exr: t: i2 to i0: ccr: i: ui: stack pointer program counter extended control register trace bit interrupt mask bits condition-code register interrupt mask bit user bit or interrupt mask bit * half-carry flag user bit negative flag zero flag overflow flag carry flag er0 er1 er2 er3 er4 er5 er6 er7 (sp) iuihunzvc ccr 76543210 h: u: n: z: v: c: general registers (rn) and extended registers (en) control registers (cr) legend: ---- note: * cannot be used as an interrupt mask bit in this lsi. figure 2.6 cpu registers section 2 cpu rev.6.00 jun. 03, 2008 page 40 of 698 rej09b0074-0600 2.4.1 general registers the h8s/2000 cpu has eight 32-bit general registers. these general registers are all functionally alike and can be used as both address registers and data registers. when a general register is used as a data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. figure 2.7 illustrates the usage of the general registers. when the general registers are used as 32-bit registers or address registers, they are designated by the letters er (er0 to er7). the er registers divide into 16-bit general registers designated by the letters e (e0 to e7) and r (r0 to r7). these registers are functionally equivalent, providing a maximum sixteen 16-bit registers. the e registers (e0 to e7) are also referred to as extended registers. the r registers divide into 8-bit general registers designated by the letters rh (r0h to r7h) and rl (r0l to r7l). these registers are functionally equivalent, providing a maximum sixteen 8-bit registers. the usage of each register can be selected independently. general register er7 has the function of stack pointer (sp) in addition to its general-register function, and is used implicitly in exception handling and subroutine calls. figure 2.8 shows the stack. ? address registers ? 32-bit registers ? 16-bit registers ? 8-bit registers er registers (er0 to er7) e registers (extended registers) (e0 to e7) r registers (r0 to r7) rh registers (r0h to r7h) rl registers (r0l to r7l) figure 2.7 usage of general registers section 2 cpu rev.6.00 jun. 03, 2008 page 41 of 698 rej09b0074-0600 sp (er7) free area stack area figure 2.8 stack 2.4.2 program counter (pc) this 24-bit counter indicates the address of the next instruction the cpu will execute. the length of all cpu instructions is two bytes (one word), so the least significant pc bit is ignored. (when an instruction is fetched, the least significant pc bit is regarded as 0.) 2.4.3 extended control register (exr) exr is an 8-bit register that manipulates the ldc, stc, andc, orc, and xorc instructions. when these instructions except for the stc instruction is executed, all interrupts including nmi will be masked for three states after execution is completed. bit bit name initial value r/w description 7 t 0 r/w trace bit when this bit is set to 1, a trace exception is generated each time an instruction is executed. when this bit is cleared to 0, instructions are executed in sequence. 6 to 3 ? all 1 ? reserved these bits are always read as 1. 2 1 0 i2 i1 i0 1 r/w these bits designate the interrupt mask level (0 to 7). for details, refer to section 5, interrupt controller. section 2 cpu rev.6.00 jun. 03, 2008 page 42 of 698 rej09b0074-0600 2.4.4 condition-code register (ccr) this 8-bit register contains internal cpu status information, including an interrupt mask bit (i) and half-carry (h), negative (n), zero (z), overflow (v), and carry (c) flags. operations can be performed on the ccr bits by the ldc, stc, andc, orc, and xorc instructions. the n, z, v, and c flags are used as branching conditions for conditional branch (bcc) instructions. bit bit name initial value r/w description 7 i 1 r/w interrupt mask bit masks interrupts other than nmi when set to 1. nmi is accepted regardless of the i bit setting. the i bit is set to 1 by hardware at the start of an exception-handling sequence. for details, refer to section 5, interrupt controller. 6 ui undefined r/w user bit or interrupt mask bit can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. this bit cannot be used as an interrupt mask bit in this lsi. 5 h undefined r/w half-carry flag when the add.b, addx.b, sub.b, subx.b, cmp.b or neg.b instruction is executed, this flag is set to 1 if there is a carry or borrow at bit 3, and cleared to 0 otherwise. when the add.w, sub.w, cmp.w, or neg.w instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 11, and cleared to 0 otherwise. when the add.l, sub.l, cmp.l, or neg.l instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 27, and cleared to 0 otherwise. 4 u undefined r/w user bit can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. 3 n undefined r/w negative flag stores the value of the most significant bit of data as a sign bit. 2 z undefined r/w zero flag set to 1 to indicate zero data, and cleared to 0 to indicate non-zero data. section 2 cpu rev.6.00 jun. 03, 2008 page 43 of 698 rej09b0074-0600 bit bit name initial value r/w description 1 v undefined r/w overflow flag set to 1 when an arithmetic overflow occurs, and cleared to 0 at other times. 0 c undefined r/w carry flag set to 1 when a carry occurs, and cleared to 0 otherwise. used by: ? add instructions, to indicate a carry ? subtract instructions, to indicate a carry ? shift and rotate instructions, to indicate a carry they carry flag is also used as a bit accumulator by bit manipulation instructions. 2.4.5 initial register values reset exception handling loads the cpu's program co unter (pc) from the vector table, clears the trace bit in exr to 0, and sets the interrupt mask bits in ccr and exr to 1. the other ccr bits and the general registers are not initialized. in par ticular, the stack pointer (er7) is not initialized. the stack pointer should therefore be initialized by an mov.l instruction executed immediately after a reset. 2.5 data formats the h8s/2000 cpu can process 1-bit, 4-bit (bcd), 8-bit (byte), 16-bit (word), and 32-bit (longword) data. bit-manipulation instructions operate on 1-bit data by accessing bit n (n = 0, 1, 2, ?, 7) of byte operand data. the daa and das decimal-adjust instructions treat byte data as two digits of 4-bit bcd data. 2.5.1 general register data formats figure 2.9 shows the data formats in general registers. section 2 cpu rev.6.00 jun. 03, 2008 page 44 of 698 rej09b0074-0600 70 70 msb lsb msb lsb 70 43 don't care don't care don't care 70 43 70 don't care 65432 710 70 don't care 65432 710 don't care data type register number data image byte data byte data 4-bit bcd data 4-bit bcd data 1-bit data 1-bit data rnh rnl rnh rnl rnh rnl upper lower upper lower figure 2.9 general register data formats (1) 15 0 msb lsb 15 0 msb lsb 31 16 msb 15 0 lsb en rn ern: en: rn: rnh: rnl: msb: lsb: general register er general register e general register r general register rh general register rl most significant bit least significant bit data type data image register number word data word data rn en longword data legend: ern figure 2.9 general register data formats (2) section 2 cpu rev.6.00 jun. 03, 2008 page 45 of 698 rej09b0074-0600 2.5.2 memory data formats figure 2.10 shows the data formats in memory. the h8s/2000 cpu can access word data and longword data in memory, but word or longword data must begin at an even address. if an attempt is made to access word or longword data at an odd address, no address error occurs but the least significant bit of the address is regarded as 0, so the access starts at the preceding address. this also applies to instruction fetches. when sp (er7) is used as an address register to access the stack, the operand size should be word size or longword size. 70 76 543210 msb lsb msb msb lsb lsb data type address 1-bit data byte data word data address l address l address 2m address 2m+1 longword data address 2n address 2n+1 address 2n+2 address 2n+3 data image figure 2.10 memory data formats 2.6 instruction set the h8s/2000 cpu has 65 types of instructions. the instructions are classified by function in table 2.1. section 2 cpu rev.6.00 jun. 03, 2008 page 46 of 698 rej09b0074-0600 table 2.1 instruction classification function instructions size types mov b/w/l 5 pop * 1 , push * 1 w/l ldm * 5 , stm * 5 l data transfer movfpe * 3 , movtpe * 3 b add, sub, cmp, neg b/w/l 19 addx, subx, daa, das b inc, dec b/w/l adds, subs l mulxu, divxu, mulxs, divxs b/w extu, exts w/l arithmetic operations tas * 4 b logic operations and, or, xor, not b/w/l 4 shift shal, shar, shll, shlr, rotl, rotr, rotxl, rotxr b/w/l 8 bit manipulation bset, bclr, bnot, btst, bld, bild, bst, bist, band, biand, bor, bior, bxor, bixor b 14 branch bcc * 2 , jmp, bsr, jsr, rts ? 5 system control trapa, rte, sleep, ldc, stc, andc, orc, xorc, nop ? 9 block data transfer eepmov ? 1 total: 65 legend: b: byte size w: word size l: longword size notes: 1. pop.w rn and push.w rn are identical to mov.w @sp+, rn and mov.w rn, @- sp. pop.l ern and push.l ern are identical to mov.l @sp+, ern and mov.l ern, @-sp. 2. bcc is the general name for conditional branch instructions. 3. cannot be used in this lsi. 4. only register er0, er1, er4, or er5 should be used when using the tas instruction. 5. er7 is used as a stack pointer in stm and ldm instructions. er7, therefore, should not be used as a saving (stm) or restoring (ldm) register. section 2 cpu rev.6.00 jun. 03, 2008 page 47 of 698 rej09b0074-0600 2.6.1 table of instructions classified by function tables 2.3 to 2.10 summarizes the instructions in each functional category. the notation used in tables 2.3 to 2.10 is defined below. table 2.2 operation notation symbol description rd general register (destination) * rs general register (source) * rn general register * ern general register (32-bit register) (ead) destination operand (eas) source operand exr extended control register ccr condition-code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition ? subtraction multiplication division logical and logical or logical exclusive or move not (logical complement) :8/:16/:24/:32 8-, 16-, 24-, or 32-bit length note: * general registers include 8-bit registers (r0h to r7h, r0l to r7l), 16-bit registers (r0 to r7, e0 to e7), and 32-bit registers (er0 to er7). section 2 cpu rev.6.00 jun. 03, 2008 page 48 of 698 rej09b0074-0600 table 2.3 data transfer instructions instruction size * 1 function mov b/w/l (eas) rd, rs (ead) moves data between two general registers or between a general register and memory, or moves immediate data to a general register. movfpe b cannot be used in this lsi. movtpe b cannot be used in this lsi. pop w/l @sp+ rn pops a general register from the stack. pop.w rn is identical to mov.w @sp+, rn. pop.l ern is iden tical to mov.l @sp+, ern push w/l rn @-sp pushes a general register onto the stack. push.w rn is identical to mov.w rn, @-sp. push.l ern is identical to mov.l ern, @-sp. ldm * 2 l @sp+ rn (register list) pops two or more general registers from the stack. stm * 2 l rn (register list) @-sp pushes two or more general registers onto the stack. notes: 1. size refers to the operand size. b: byte w: word l: longword 2. er7 is used as a stack pointer in stm and ldm instructions. er7, therefore, should not be used as a saving (stm) or restoring (ldm) register. section 2 cpu rev.6.00 jun. 03, 2008 page 49 of 698 rej09b0074-0600 table 2.4 arithmetic operations instructions instruction size * 1 function add sub b/w/l rd rs rd, rd #imm rd performs addition or subtraction on data in two general registers, or on immediate data and data in a general register. (immediate byte data cannot be subtracted from byte data in a general register. use the subx or add instruction.) addx subx b rd rs c rd, rd #imm c rd performs addition or subtraction with carry or borrow on byte data in two general registers, or on immediate data and data in a general register. inc dec b/w/l rd 1 rd, rd 2 rd increments or decrements a general register by 1 or 2. (byte operands can be incremented or decremented by 1 only.) adds subs l rd 1 rd, rd 2 rd, rd 4 rd adds or subtracts the value 1,2, or 4 to or from data in a 32-bit register. daa das b rd (decimal adjust) rd decimal-adjusts an addition or subtraction result in a general register by referring to the ocr to produce 4-bit bcd data. mulxu b/w rd rs rd performs unsigned multiplication on data in two general registers: either 8 bits 8 bits 16 bits or 16 bits 16 bits 32 bits. mulxs b/w rd rs rd performs signed multiplication on data in two general registers: either 8 bits 8 bits 16 bits or 16 bits 16 bits 32 bits. divxu b/w rd rs rd performs unsigned division on data in two general registers: either 16 bits 8 bits 8-bit quotient and 8-bit remainder or 32 bits 16 bits 16-bit quotient and 16-bit remainder. divxs b/w rd rs rd performs signed division on data in two general registers: either 16 bits 8 bits 8-bit quotient and 8-bit remainder or 32 bits 16 bits 16-bit quotient and 16-bit remainder. cmp b/w/l rd ? rs, rd ? #imm compares data in a general register with data in another general register or with immediate data, and sets ccr bits according to the result. section 2 cpu rev.6.00 jun. 03, 2008 page 50 of 698 rej09b0074-0600 instruction size * 1 function neg b/w/l 0 ? rd rd takes the two's complement (arithmetic complement) of data in a general register. extu w/l rd (zero extension) rd extends the lower 8 bits of a 16-bit register to word size, or the lower 16 bits of a 32-bit register to longword size, by padding with zeros on the left. exts w/l rd (sign extension) rd extends the lower 8 bits of a 16-bit register to word size, or the lower 16 bits of a 32-bit register to longword size, by extending the sign bit. tas * 2 b @erd ? 0, 1 ( section 2 cpu rev.6.00 jun. 03, 2008 page 51 of 698 rej09b0074-0600 table 2.6 shift instructions instruction size * function shal shar b/w/l rd (shift) rd performs an arithmetic shift on general register contents. 1-bit or 2 bit shift is possible. shll shlr b/w/l rd (shift) rd performs an logical shift on general register contents. 1-bit or 2 bit shift is possible. rotl rotr b/w/l rd (rotate) rd rotates general register contents. 1-bit or 2 bit rotation is possible. rotxl rotxr b/w/l rd (rotate) rd rotates general register contents through the carry flag. 1-bit or 2 bit rotation is possible. note: * size refers to the operand size. b: byte w: word l: longword section 2 cpu rev.6.00 jun. 03, 2008 page 52 of 698 rej09b0074-0600 table 2.7 bit manipulation instructions instruction size * function bset b 1 ( section 2 cpu rev.6.00 jun. 03, 2008 page 53 of 698 rej09b0074-0600 instruction size * function bxor b c ( section 2 cpu rev.6.00 jun. 03, 2008 page 54 of 698 rej09b0074-0600 table 2.8 branch instructions instruction size function bcc ? branches to a specified address if a specified condition is true. the branching conditions are listed below. mnemonic description condition bra (bt) always (true) always brn (bf) never (false) never bhi high c z = 0 bls low or same c z = 1 bcc (bhs) carry clear (high or same) c = 0 bcs (blo) carry set (low) c = 1 bne not equal z = 0 beq equal z = 1 bvc overflow clear v = 0 bvs overflow set v = 1 bpl plus n = 0 bmi minus n = 1 bge greater or equal n v = 0 blt less than n v = 1 bgt greater than z (n v) = 0 ble less or equal z (n v) = 1 jmp ? branches unconditionally to a specified address. bsr ? branches to a subroutine at a specified address jsr ? branches to a subroutine at a specified address rts ? returns from a subroutine section 2 cpu rev.6.00 jun. 03, 2008 page 55 of 698 rej09b0074-0600 table 2.9 system co ntrol instruction instruction size * function trapa ? starts trap-instruction exception handling. rte ? returns from an exception-handling routine. sleep ? causes a transition to a power-down state. ldc b/w (eas) ccr, (eas) exr moves the source operand contents or immediate data to ccr or exr. although ccr and exr are 8-bit registers, word-size transfers are performed between them and memory. the upper 8 bits are valid. stc b/w ccr (ead), exr (ead) transfers ccr or exr contents to a general register or memory. although ccr and exr are 8-bit registers, word-size transfers are performed between them and memory. the upper 8 bits are valid. andc b ccr #imm ccr, exr #imm exr logically ands the ccr or exr contents with immediate data. orc b ccr #imm ccr, exr #imm exr logically ors the ccr or exr contents with immediate data. xorc b ccr #imm ccr, exr #imm exr logically exclusive-ors the ccr or exr contents with immediate data. nop ? pc + 2 pc only increments the program counter. note: * size refers to the operand size. b: byte w: word section 2 cpu rev.6.00 jun. 03, 2008 page 56 of 698 rej09b0074-0600 table 2.10 block data transfer instruction instruction size function eepmov.b ? if r4l 0 then repeat @er5+ @er6+ r4l?1 r4l until r4l = 0 else next; eepmov.w ? if r4 0 then repeat @er5+ @er6+ r4?1 r4 until r4 = 0 else next; transfer a data block. starting from the address set in er5, transfers data for the number of bytes set in r4l or r4 to the address location set in er6. execution of the next instruction begins as soon as the transfer is completed. section 2 cpu rev.6.00 jun. 03, 2008 page 57 of 698 rej09b0074-0600 2.6.2 basic instruction formats the h8s/2000 cpu instructions consist of 2-byte (1-word) units. an instruction consists of an operation field (op), a register field (r), an effective address extension (ea), and a condition field (cc). figure 2.11 shows examples of instruction formats. ? operation field indicates the function of the instruction, the addressing mode, and the operation to be carried out on the operand. the operation field always includes the first four bits of the instruction. some instructions have two operation fields. ? register field specifies a general register. address registers are specified by 3 bits, data registers by 3 bits or 4 bits. some instructions have two register fields. some have no register field. ? effective address extension 8, 16, or 32 bits specifying immediate data, an absolute address, or a displacement. ? condition field specifies the branching condition of bcc instructions. op op rn rm nop, rts, etc. add.b rn, rm, etc. mov.b @(d:16, rn), rm, etc. rn rm op ea(disp) op cc ea(disp) bra d:16, etc. (1) operation field only (2) operation field and register fields (3) operation field, register fields, and effective address extension (4) operation field, effective address extension, and condition field figure 2.11 instruction formats (examples) section 2 cpu rev.6.00 jun. 03, 2008 page 58 of 698 rej09b0074-0600 2.7 addressing modes and eff ective address calculation the h8s/2000 cpu supports the eight addressing modes listed in table 2.11. each instruction uses a subset of these addressing modes. arithmetic an d logic instructions can use the register direct and immediate modes. data transfer instructions can use all addressing modes except program- counter relative and memory indirect. bit manipula tion instructions use register direct, register indirect, or absolute addressing mode to specify an operand, and register direct (bset, bclr, bnot, and btst instructions) or immediate (3-bit) addressing mode to specify a bit number in the operand. table 2.11 addressing modes no. addressing mode symbol 1 register direct rn 2 register indirect @ern 3 register indirect with displacement @(d:16,ern)/@(d:32,ern) 4 register indirect with post-increment register indirect with pre-decrement @ern+ @?ern 5 absolute address @aa:8/@aa:16/@aa:24/@aa:32 6 immediate #xx:8/#xx:16/#xx:32 7 program-counter relative @(d:8,pc)/@(d:16,pc) 8 memory indirect @@aa:8 2.7.1 register direct?rn the register field of the instruction specifies an 8-, 16-, or 32-bit general register containing the operand. r0h to r7h and r0l to r7l can be specified as 8-bit registers. r0 to r7 and e0 to e7 can be specified as 16-bit registers. er0 to er7 can be specified as 32-bit registers. 2.7.2 register indirect?@ern the register field of the instruction code specifi es an address register (ern) which contains the address of the operand on memory. if the address is a program instruction address, the lower 24 bits are valid and the upper 8 bits are all assumed to be 0 (h'00). section 2 cpu rev.6.00 jun. 03, 2008 page 59 of 698 rej09b0074-0600 2.7.3 register indirect with displaceme nt?@(d:16, ern) or @(d:32, ern) a 16-bit or 32-bit displacement contained in the instruction is added to an address register (ern) specified by the register field of the instruction, and the sum gives the address of a memory operand. a 16-bit displacement is sign-extended when added. 2.7.4 register indirect with post-increment or pre-decrement?@ern+ or @-ern register indirect with post-increment?@ern+: the register field of the instruction code specifies an address register (ern) which contains the address of a memory operand. after the operand is accessed, 1, 2, or 4 is added to the address register contents and the sum is stored in the address register. the value added is 1 for byte access, 2 for word transfer instruction, or 4 for longword transfer instruction. for word or longword transfer instruction, the register value should be even. register indirect with pre-decrement?@-ern: the value 1, 2, or 4 is subtracted from an address register (ern) specified by the register field in the instruction code, and the result becomes the address of a memory operand. the result is also stored in the address register. the value subtracted is 1 for byte access, 2 for word transfer instruction, or 4 for longword transfer instruction. for word or longword transfer instruction, the register value should be even. 2.7.5 absolute address?@aa:8, @aa:16, @aa:24, or @aa:32 the instruction code contains the absolute addr ess of a memory operand. the absolute address may be 8 bits long (@aa:8), 16 bits long (@aa:16), 24 bits long (@aa:24), or 32 bits long (@aa:32). table 2.12 indicates the acces sible absolute address ranges. to access data, the absolute address should be 8 bits (@aa:8), 16 bits (@aa:16), or 32 bits (@aa:32) long. for an 8-bit absolute address, th e upper 24 bits are all assumed to be 1 (h'ffff). for a 16-bit absolute address the upper 16 bits ar e a sign extension. a 32-bit absolute address can access the entire address space. a 24-bit absolute address (@aa:24) indicates the address of a program instruction. the upper 8 bits are all assumed to be 0 (h'00). section 2 cpu rev.6.00 jun. 03, 2008 page 60 of 698 rej09b0074-0600 table 2.12 absolute address access ranges absolute address normal mode * advanced mode data address 8 bits (@aa:8) h'ff00 to h'ffff h'ffff00 to h'ffffff 16 bits (@aa:16) h'0000 to h'ffff h'000000 to h'007fff, h'ff8000 to h'ffffff 32 bits (@aa:32) h'000000 to h'ffffff program instruction address 24 bits (@aa:24) note: * not available in this lsi. 2.7.6 immediate?#xx:8, #xx:16, or #xx:32 the instruction contains 8-bit (#xx:8), 16-bit (#xx:16), or 32-bit (#xx:32) immediate data as an operand. the adds, subs, inc, and dec instructions contain immediate data implicitly. some bit manipulation instructions contain 3-bit immediate data in the instruction code, specifying a bit number. the trapa instruction contains 2-bit immediate data in its instruction code, specifying a vector address. 2.7.7 program-counter relative?@(d:8, pc) or @(d:16, pc) this mode is used in the bcc and bsr instructio ns. an 8-bit or 16-bit displacement contained in the instruction is sign-extended and added to the 24-bit pc contents to generate a branch address. only the lower 24 bits of this branch address are valid; the upper 8 bits are all assumed to be 0 (h'00). the pc value to which the displacement is added is the address of the first byte of the next instruction, so the possible branching range is ?126 to +128 bytes (?63 to +64 words) or ?32766 to +32768 bytes (?16383 to +16384 words) from the branch instruction. the resulting value should be an even number. section 2 cpu rev.6.00 jun. 03, 2008 page 61 of 698 rej09b0074-0600 2.7.8 memory indirect?@@aa:8 this mode can be used by the jmp and jsr instructions. the instruction code contains an 8-bit absolute address specifying a memory operand. this memory operand contains a branch address. the upper bits of the absolute address are all assumed to be 0, so the address range is 0 to 255 (h'0000 to h'00ff in normal mode*, h'000000 to h'0000ff in advanced mode). in normal mode the memory operand is a word operand and the branch address is 16 bits long. in advanced mode the memory operand is a longword operand, the first byte of which is assumed to be h'00. note that the first part of the address range is also the exception vector area. for further details, refer to section 4, exception handling. if an odd address is specified in word or longword memory access, or as a branch address, the least significant bit is regarded as 0, causing data to be accessed or instruction code to be fetched at the address preceding the specified address. (for further information, see section 2.5.2, memory data formats.) note: * not available in this lsi. specified by @aa:8 specified by @aa:8 branch address branch address reserved (a) normal mode * (b) advanced mode note: * normal mode is not available in this lsi. figure 2.12 branch a ddress specification in memory indirect mode section 2 cpu rev.6.00 jun. 03, 2008 page 62 of 698 rej09b0074-0600 2.7.9 effective address calculation table 2.13 indicates how effective addresses are calculated in each addressing mode. in normal mode the upper 8 bits of the effective address are ignored in order to generate a 16-bit address. table 2.13 effective address calculation no 1 offset 1 2 4 r op 31 0 31 23 2 3 register indirect with d isplacement @(d:16,ern) or @ (d:32,ern) 4 r op disp r op rm op rn 31 0 31 0 r op don't care 31 23 31 0 don't care 31 0 disp 31 0 31 0 31 23 31 0 don't care 31 23 31 0 don't care 24 24 24 24 addressing mode and instruction format effective address calculation effective address (ea) register direct (rn) general register contents general register contents general register contents general register contents sign extension register indirect (@ern) register indirect with post-increment or pre-decrement ?register indirect with post-increment @ern+ ?register indirect with pre-decrement @-ern 1, 2, or 4 1, 2, or 4 operand size byte word longword operand is general register contents. section 2 cpu rev.6.00 jun. 03, 2008 page 63 of 698 rej09b0074-0600 no 5 op 31 23 31 0 don't care abs @aa:8 7 h'ffff op 31 23 31 0 don't care @aa:16 op @aa:24 @aa:32 abs 15 16 31 23 31 0 don't care 31 23 31 0 don't care abs op abs 6 op imm #xx:8/#xx:16/#xx:32 8 24 24 24 24 addressing mode and instruction format absolute address immediate effective address calculation effective address (ea) sign extension operand is immediate data. 31 23 7 program-counter relative @(d:8,pc)/@(d:16,pc) memory indirect @@aa:8 ? normal mode * ? advanced mode 31 0 don't care 23 0 disp 0 31 23 31 0 don't care disp op 23 op 8 abs 31 0 abs h'000000 7 8 0 15 31 23 31 0 don't care 15 h'00 16 op abs 31 0 abs h'000000 7 8 0 31 24 24 24 note: * normal mode is not available in this lsi. pc contents sign extension memory contents memory contents section 2 cpu rev.6.00 jun. 03, 2008 page 64 of 698 rej09b0074-0600 2.8 processing states the h8s/2000 cpu has five main processing stat es: the reset state, exception handling state, program execution state, bus-released state, and power-down state. figure 2.13 indicates the state transitions. ? reset state in this state the cpu and internal peripheral modules are all initialized and stop. when the res input goes low all current processing stops and the cpu enters the reset state. all interrupts are masked in the reset state. reset exception handling starts when the res signal changes from low to high. for details, refer to section 4, exception handling. the reset state can also be entered by a watchdog timer overflow. ? exception-handling state the exception-handling state is a transient state that occurs when the cpu alters the normal processing flow due to an exception source, such as , a reset, trace, interrupt, or trap instruction. the cpu fetches a start address (vector) from the exception vector table and branches to that address. for further details, refer to section 4, exception handling. ? program execution state in this state the cpu executes program instructions in sequence. ? bus-released state in a product which has a bus master other than the cpu, such as a direct memory access controller (dmac) and a data transfer controller (dtc), the bus-released state occurs when the bus has been released in response to a bus request from a bus master other than the cpu. while the bus is released, the cpu halts operations. ? power-down state this is a power-down state in which the cpu stops operating. the program stop state occurs when a sleep instruction is executed or the cpu enters hardware standby mode. for details, refer to section 20, power-down modes. section 2 cpu rev.6.00 jun. 03, 2008 page 65 of 698 rej09b0074-0600 exception handling state bus-released state hardware standby mode * 2 software standby mode reset state * 1 sleep mode power-down state * 3 program execution state end of bus request bus request interrupt request external interrupt request res = high mres = high request for exce ption handling stby = high, res = low end of bus request bus request sleep instruc tion, ssby = 0 sleep instruc tion, ssby = 1 notes: 1. 2. 3. from any state except hardware standby mode, a transition to the reset state occurs whenever res goes low. a transition can also be made to the reset state when the watchdog timer overflows. from any state except hardware standby mode and power-on reset state, a transition to the manual reset state occurs whenever mres goes low. from any state, a transition to hardware standby mode occurs when stby goes low. apart from these states, there are also the watch mode, subactive mode, and the subsleep mode. see section 20, power-down modes. end of exception handlin g figure 2.13 state transitions section 2 cpu rev.6.00 jun. 03, 2008 page 66 of 698 rej09b0074-0600 2.9 usage notes 2.9.1 note on tas instruction usage only register er0, er1, er4, or er5 should be used when using the tas instruction. the tas instruction is not generated by the renesas technology h8s and h8/300 series c/c++ compilers. if the tas instruction is used as a user-defined intrinsic function, ensure that only register er0, er1, er4, or er5 is used. 2.9.2 stm/ltm instruction usage with the stm or ldm instruction, the er7 register is used as the stack pointer, and thus cannot be used as a register that allows save (stm) or restore (ldm) operation. with a single stm or ldm instruction, two to four registers can be saved or restored. the available registers are as follows: for two registers: er0 and er1, er2 and er3, or er4 and er5 for three registers: er0 to er2, or er4 to er6 for four registers: er0 to er3 for the renesas technology h8s or h8/300 series c/c++ compiler, the stm/ldm instruction including er7 is not created. 2.9.3 note on bit manipulation instructions using bit manipulation instructions on registers containing write-only bits can result in the bits that should have been manipulated not being manipulated as intended or in the wrong bits being manipulated. reading data from a register containing write-only bits may return fixed or undefined values. consequently, bit manipulation instructions that use the read values to perform operations (bnot, btst, band, biand, bor, bior, bxor, bixor, bld, and bild) will not work properly. in addition, bit manipulation instructions that write data following operations based on the data values read (bset, bclr, bnot, bst, and bist) may change the values of bits unrelated to the intended bit manipulation. therefore, cautio n is necessary when using bit manipulation instructions on registers containing write-only bits. section 2 cpu rev.6.00 jun. 03, 2008 page 67 of 698 rej09b0074-0600 the instructions bset, bclr, bnot, bst, and bist perform the following operations in the order shown: 1. read data in byte units 2. perform bit manipulation on the r ead data according to the instruction 3. write data in byte units example: using the bclr instruction to clear pin 14 only of p1ddr for port 1 p1ddr is an 8-bit register that contains write-only bits. it is used to specify the i/o setting of the individual pins in port 1. reading produces invalid data. attempting to read from p1ddr returns undefined values. in this example, the bclr instruction is used to set pin 14 as an input port. let us assume that pins 17 to 14 are presently set as output pins and pins 13 to 10 are set as input pins. thus, the value of p1ddr is initially h'f0. p17 p16 p15 p14 p13 p12 p11 p10 i/o output output output output input input input input p1ddr 1 1 1 1 0 0 0 0 to change pin 14 from an output pin to an input pin, the value of bit 4 in p1ddr must be changed from 1 to 0 (h'f0 to h'e0). now assume that the bclr instruction is used to clear bit 4 in p1ddr to 0. bclr #4, @p1ddr however, using the above bit manipulation instruction on the write-only register p1ddr can cause problems, as described below. the bclr instruction first reads data from p1ddr in byte units, but in this case the read values are undefined. these undefined values can be 0 or 1 for each bit in the register, but there is no way of telling which. since all of the bits in p1ddr are write-only, undefined values are returned for all of the bits when the register is read. in this example the value of p1ddr is h'f0, but we will assume that the value returned when the register was read is h'f8, which would give bit 3 a value of 1. section 2 cpu rev.6.00 jun. 03, 2008 page 68 of 698 rej09b0074-0600 p17 p16 p15 p14 p13 p12 p11 p10 i/o output output output output input input input input p1ddr 1 1 1 1 0 0 0 0 read value 1 1 1 1 1 0 0 0 the bclr instruction performs bit manipulation on the read value, which is h'f8 in this example. it clears bit 4 to 0. p17 p16 p15 p14 p13 p12 p11 p10 i/o output output output output input input input input p1ddr 1 1 1 1 0 0 0 0 after bit manipulation 1 1 1 0 1 0 0 0 following bit manipulation the data is written to p1ddr and the bclr instruction terminates. p17 p16 p15 p14 p13 p12 p11 p10 i/o output output output input output input input input p1ddr 1 1 1 0 1 0 0 0 write value 1 1 1 0 1 0 0 0 the contents of p1ddr should have been overwritten with a value of h'e0, but in fact a value of h'e8 was written to the register. this changed pin 13, which should have been an input pin, to an output pin. in this example we assumed that the value of bit 1 in p1ddr was 1. however, since the values of bits 7 to 0 in p1ddr are all undefined when read, there is the possibility that individual bit values could be changed from 0 to 1 or from 1 to 0. to prevent this from happening, the recommendations in section 2.9.4, accessing registers containing write-only bits, should be followed when changing the values of registers containing write-only bits. in addition, the bclr instruction can be used to clear flags in internal i/o registers to 0. in such cases it is not necessary to read the relevant flag beforehand so long as it is clear that it has been set to 1 by an interrupt processing routine or the like. 2.9.4 accessing registers containing write-only bits using data transfer instructions or bit manipulation instructions on registers containing write-only bits can result in undefined values being read. to prevent the reading of undefined values, the procedure described below should be used to access registers containing write-only bits. section 2 cpu rev.6.00 jun. 03, 2008 page 69 of 698 rej09b0074-0600 in order to write to a register containing write-only bits, set aside a work area in memory (in on- chip ram, for example) and write the data to be manipulated to it. after accessing and manipulating the data in the work area in memory, write the resulting data to the register containing write-only bits. figure 2.14 example flowchart of method for accessing registers containing write-only bits write data to work area write data from work area to register containing write-only bits access data in work area (using either data transfer instructions or bit manipulation instructions) write data from work area to register containing write-only bits write initial value change value of register containing write-only bits figure 2.14 flowchart of method for accessing registers containing write-only bits example: clearing pin 14 only of p1ddr for port 1 p1ddr is an 8-bit register that contains write-only bits. it is used to specify the i/o setting of the individual pins in port 1. reading produces invalid data. attempting to read from p1ddr returns undefined values. in this example, the bclr instruction is used to set pin 14 as an input port. to start, the initial value h'f0 to be written to p1ddr is written ahead of time to the work area (ram0) in memory. mov.b #h'f0, r0l mov.b r0l, @ram0 mov.b r0l, @p1ddr section 2 cpu rev.6.00 jun. 03, 2008 page 70 of 698 rej09b0074-0600 p17 p16 p15 p14 p13 p12 p11 p10 i/o output output output output input input input input p1ddr 1 1 1 1 0 0 0 0 ram0 1 1 1 1 0 0 0 0 to change pin 14 from an output pin to an input pin, the value of bit 4 in p1ddr must be changed from 1 to 0 (h'f0 to h'e0). here the bclr instruction will be used to clear bit 4 in p1ddr to 0. bclr #4, @ram0 p17 p16 p15 p14 p13 p12 p11 p10 i/o output output output output input input input input p1ddr 1 1 1 1 0 0 0 0 ram0 1 1 1 0 0 0 0 0 since ram0 is a read/write area of memory, performing the above bit manipulation using the bclr instruction causes only bit 4 in ram0 to be cleared to 0. the value of ram0 is then written to p1ddr. mov.b @ram0, r0l mov.b r0l, @p1ddr p17 p16 p15 p14 p13 p12 p11 p10 i/o output output output input input input input input p1ddr 1 1 1 0 0 0 0 0 ram0 1 1 1 0 0 0 0 0 by using the above procedure to access registers co ntaining write-only bits, it is possible to create programs that are not dependent on the type of instructions used. section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 71 of 698 rej09b0074-0600 section 3 mcu operating modes 3.1 operating mode selection this lsi supports four operating modes (modes 4 to 7). these modes enable selection of the cpu operating mode, enabling/disabling of on-chip rom, and the initial bus width setting, by setting the mode pins (md2 to md0) as show in table 3.1. modes 4 to 6 are external extended modes that allow access to the external memory and peripheral devices. in external extended mode, 8-bit or 16-bit address space can be set for each area depending on the bus controller setting after program execution starts. if 16-bit access is selected for any one area, 16-bit bus mode is set; if 8-bit access is selected for all areas, 8-bit bus mode is set. in mode 7, the external address space cannot be used. do not change the mode pin settings during operation. only mode 7 is available in the h8s/2212 group. table 3.1 mcu operating mode selection external data bus mcu operating mode md2 md1 md0 cpu operating mode description on-chip rom initial value maximum value 4 1 0 0 advanced mode on-chip rom disabled, extended mode disabled 16 bits 16 bits 5 1 0 1 advanced mode on-chip rom disabled, extended mode disabled 8 bits 16 bits 6 1 1 0 advanced mode on-chip rom enabled, extended mode enabled 8 bits 16 bits 7 1 1 1 advanced mode single-chip mode enabled ? ? note: when using the e6000 emulator: ? mode 7 is not available in the h8s/2218 group. (the e6000 emulator does not support mode 7.) ? note following restrictions to use the rtc and usb in mode 6. specify pfcr so that a9 and a8 are output on the pb1 and pb0 pins. set h'ff in pcddr so that a7 to a0 are output on the pc7 to pc0 pins. section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 72 of 698 rej09b0074-0600 3.2 register descriptions the following registers are related to the operating mode. ? mode control register (mdcr) ? system control register (syscr) 3.2.1 mode control register (mdcr) mdcr is used to monitor the current operating mode of this lsi. mdcr should not be modified. bit bit name initial value r/w description 7 to 4 ? undefined ? reserved these bits are always read as undefined value and cannot be modified. 3 fwe ? * 1 r flash programming enable reflects the input level at the fwe pin. this bit functions same as the fwe bit in the flmcr1 register. 2 1 0 mds2 mds1 mds0 ? * 1 ? * 1 ? * 1 r r r mode select 2 to 0 these bits indicate the input levels at pins md2 to md0 (the current operating mode). bits mds2 to mds0 correspond to md2 to md0. mds2 to mds0 are read-only bits and they cannot be written to. the mode pin (md2 to md0) input levels are latched into these bits when mdcr is read. these latches are canceled by a power-on reset, but maintained at manual reset * 2 . notes: 1 . determined by the fwe and md2 to md0 pin settings. 2. supported only by the h8s/2218 group. 3.2.2 system control register (syscr) syscr is used to select the interrupt control m ode and the detected edge for nmi, select the mres input pin* enable or disable, and enables or disables on-chip ram. section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 73 of 698 rej09b0074-0600 bit bit name initial value r/w description 7 ? 0 r/w reserved the write value should always be 0. 6 ? 0 ? reserved this bit is always read as 0 and cannot be modified. 5 4 intm1 intm0 0 0 r/w r/w these bits select the control mode of the interrupt controller. for details of the interrupt control modes, see section 5.6, interrupt control modes and interrupt operation. 00: interrupt control mode 0 01: setting prohibited 10: interrupt control mode 2 11: setting prohibited 3 nmieg 0 r/w nmi edge select selects the valid edge of the nmi interrupt input. 0: an interrupt is requested at the falling edge of nmi input 1: an interrupt is requested at the rising edge of nmi input 2 mrese 0 r/w manual reset select enables or disables the mres pin * input. 0: manual reset is disabled 1: manual reset is enabled the mres input pin * can be used. 1 ? 0 ? reserved this bit is always read as 0 and cannot be modified. 0 rame 1 r/w ram enable enables or disables the on-chip ram. the rame bit is initialized when the reset status is released. 0: on-chip ram is disabled 1: on-chip ram is enabled note: * supported only by the h8s/2218 group. section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 74 of 698 rej09b0074-0600 3.3 operating mode descriptions 3.3.1 mode 4 (supported only by the h8s/2218 group) the cpu can access a 16-mbyte address space in advanced mode. the on-chip rom is disabled. pins p13 to p10, and ports a, b, and c function as an address bus, ports d and e function as a data bus, and part of port f carries bus control signals. pins p13 to p11 function as input ports immediately after a reset. pin 10 and ports a and b function as address (a20 to a8) outputs immediately after a reset. address (a23 to a21) output can be enabled or disabled by bits ae3 to ae0 in the pin function control register (pfcr) regardless of the corresponding data direction register (ddr) values. pins for which address output is disabled among pins p13 to p10 and in ports a and b become port outputs when the corresponding ddr bits are set to 1. port c always has an address (a7 to a0) output function. the initial bus mode after a reset is 16 bits, with 16-bit access to all areas. however, note that if 8- bit access is designated by the bus controller for all areas, the bus mode switches to 8 bits. 3.3.2 mode 5 (supported only by the h8s/2218 group) the cpu can access a 16-mbyte address space in advanced mode. the on-chip rom is disabled. pins p13 to p10, and ports a, b, and c function as an address bus, ports d and e function as a data bus, and part of port f carries bus control signals. pins p13 to p11 function as input ports immediately after a reset. pin 10 and ports a and b function as address (a20 to a8) outputs immediately after a reset. address (a23 to a21) output can be enabled or disabled by bits ae3 to ae0 in the pin function control register (pfcr) regardless of the corresponding data direction register (ddr) values. pins for which address output is disabled among pins p13 to p10 and in ports a and b become port outputs when the corresponding ddr bits are set to 1. port c always has an address (a7 to a0) output function. the initial bus mode after a reset is 8 bits, with 8-bit access to all areas. however, note that if 16- bit access is designated by the bus controller for any area, the bus mode switches to 16 bits and port e becomes a data bus. section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 75 of 698 rej09b0074-0600 3.3.3 mode 6 (supported only by the h8s/2218 group) the cpu can access a 16-mbyte address space in advanced mode. the on-chip rom is enabled. pins p13 to p10, and ports a, b and c function as input ports immediately after a reset. address (a23 to a8) output can be enabled or disabled by bits ae3 to ae0 in the pin function control register (pfcr) regardless of the corresponding data direction register (ddr) values. pins for which address output is disabled among pins p13 to p10 and in ports a and b become port outputs when the corresponding ddr bits are set to 1. port c is an input port immediately after a reset. addresses a7 to a0 are output by setting the corresponding ddr bits to 1. ports d and e function as a data bus, and part of port f carries data bus signals. the initial bus mode after a reset is 8 bits, with 8-bit access to all areas. however, note that if 16- bit access is designated by the bus controller for any area, the bus mode switches to 16 bits and port e becomes a data bus. 3.3.4 mode 7 the cpu can access a 16-mbyte address space in advanced mode. the on-chip rom is enabled, but external addresses cannot be accessed. all i/o ports are available for use as input-output ports. section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 76 of 698 rej09b0074-0600 3.3.5 pin functions the pin functions of ports 1, and a to f vary depending on the operating mode. table 3.2 shows their functions in each operating mode. table 3.2 pin functions in each operating mode port mode 4 mode 5 mode 6 mode 7 port 1 p13 to p11 p * /a p * /a p * /a p p10 p/a * p/a * p * /a p port a pa3 to pa0 p/a * p/a * p * /a p port b p/a * p/a * p * /a p port c a a p * /a p port d d d d p port e p/d * p * /d p * /d p port f pf7 p/c * p/c * p/c * p * /c pf6 to pf4 c c c p pf3 p/c * p * /c p * /c pf2 to pf0 p * /c p * /c p * /c legend: p: i/o port a: address bus output d: data bus i/o c: control signals, clock i/o * : after reset section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 77 of 698 rej09b0074-0600 3.4 memory map in each operating mode figures 3.1 to 3.3 show the memory map in each operation mode, respectively. external address space notes: 1. 2. 3. though rtc and usb registers are provided inside the chip, asn, rdn, and wrn are asserted and the addresses are output when these areas are accessed. therefore, care should be taken when connecting memory externally. the reserved area of h'fee800 to h'ffbfff should not be accessed. the external address can be used instead, by clearing the rame bit in syscr to 0. external address space on-chip ram * 3 usb registers * 1 internal i/o registers * 1 reserved * 2 on-chip ram * 3 external address space external address space on-chip ram * 3 on-chip rom on-chip rom usb registers * 1 internal i/o registers * 1 reserved * 2 reserved * 2 on-chip ram * 3 external address space external address space on-chip ram usb registers internal i/o registers on-chip ram h'000000 h'01ffff h'020000 h'e00000 h'fee800 h'c00000 h'000000 h'000000 h'ffc000 h'fee800 h'ffc000 h'e00000 h'fee800 h'c00000 h'ffc000 h'ffefbf h'ffffc0 h'ffffc0 h'ffffc0 h'ffffff h'ffffff h'ffffff h'ffefc0 h'ffefc0 h'fff800 h'fff800 h'fff800 h'dfffff h'c00000 modes 4 and 5 (advanced extended modes with on-chip rom desabled) mode 6 (advanced extended mode with on-chip rom enabled) mode 7 (advanced single-chip mode) rom: ? ram: 12 kbytes rom: 128 kbytes ram: 12 kbytes rom: 128 kbytes ram: 12 kbytes figure 3.1 memory map in each operating mode for HD64F2218 and HD64F2218u section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 78 of 698 rej09b0074-0600 external address space notes: 1. 2. 3. though rtc and usb registers are provided inside the chip, asn, rdn, and wrn are asserted and the addresses are output when these areas are accessed. therefore, care should be taken when connecting memory externally. the reserved area of h'fee800 to h'ffcfff should not be accessed. the external address can be used instead, by clearing the rame bit in syscr to 0. external address space on-chip ram * 3 usb registers * 1 internal i/o registers * 1 reserved * 2 on-chip ram * 3 on-chip ram * 3 on-chip ram external address space external address space on-chip ram * 3 on-chip rom on-chip rom usb registers * 1 usb registers internal i/o registers * 1 reserved * 2 reserved * 2 reserved external address space external address space on-chip ram internal i/o registers modes 4 and 5 (advanced extended modes with on-chip rom desabled) mode 6 (advanced extended mode with on-chip rom enabled) mode 7 (advanced single-chip mode) rom: ? ram: 8 kbytes rom: 64 kbytes ram: 8 kbytes rom: 64 kbytes ram: 8 kbytes h'00ffff h'000000 h'000000 h'020000 h'010000 h'e00000 h'fee800 h'c00000 h'000000 h'00ffff h'ffd000 h'fee800 h'ffd000 h'e00000 h'fee800 h'c00000 h'ffd000 h'ffefbf h'ffffc0 h'ffffc0 h'ffffc0 h'ffffff h'ffffff h'ffffff h'ffefc0 h'ffefc0 h'fff800 h'fff800 h'fff800 h'dfffff h'c00000 figure 3.2 memory map in each operating mode for hd6432217 section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 79 of 698 rej09b0074-0600 n ote : * t he reserved area shou l d not be accessed . mode 7 (advanced s i ng l e - ch i p mode) mode 7 (advanced s i ng l e - ch i p mode) mode 7 (advanced s i ng l e - ch i p mode) rom : 128 kbytes ram : 12 kbytes rom : 6 4 kbytes ram : 8 kbytes rom : 32 kbytes ram : 4 kbytes h' 007 fff h' 000000 h' 00 ffff h' 000000 h'fee 800 h'ff d000 h'ffef b f h'ffff c0 h'ffffff h'fff 800 h' d fffff h' c00000 h'fee 800 h'ffe 000 h'ffef b f h'ffff c0 h'ffffff h'fff 800 h' d fffff h' c00000 h' 01 ffff h' 000000 h'fee 800 h'ff c000 h'ffef b f h'ffff c0 h'ffffff h'fff 800 h' d fffff h' c00000 on - ch i p ram on - ch i p ram on - ch i p ram on - ch i p ram on - ch i p ram on - ch i p ram on - ch i p rom on - ch i p rom on - ch i p rom usb reg i sters usb reg i sters usb reg i sters i nterna l i/ o reg i sters i nterna l i/ o reg i sters i nterna l i/ o reg i sters reserved * reserved * reserved * h d6 4f 2212, h d6 4f 2212u h d6 4f 2211, h d6 4f 2211u, h d6 4 32211 h d6 4 32210, h d6 4 32210s figure 3.3 memory map in each operating mode for hd64f2212, hd64f2212u, hd64f2211, hd64f2211u, hd6432211, hd6432210 and hd6432210s section 3 mcu operating modes rev.6.00 jun. 03, 2008 page 80 of 698 rej09b0074-0600 section 4 exception handling rev.6.00 jun. 03, 2008 page 81 of 698 rej09b0074-0600 section 4 exception handling 4.1 exception handling types and priority as table 4.1 indicates, exception handling may be caused by a reset, trace, trap instruction, or interrupt. exception handling is prioritized as shown in table 4.1. if two or more exceptions occur simultaneously, they are accepted and processed in order of priority. exception sources, the stack structure, and operation of the cpu vary depending on the interrupt control mode. for details on the interrupt control mode, refer to section 5, interrupt controller. table 4.1 exception types and priority priority exception type start of exception handling high reset starts immediately after a low-to-high transition at the res or mres * pin, or when the watchdog timer overflows. the cpu enters the reset state when the res pin is low. the cpu enters the manual reset state when the mres pin * is low. trace starts when execution of the current instruction or exception handling ends, if the trace (t) bit in the exr is set to 1. this is enabled only in trace interrupt control mode 2. trace exception processing is not performed after rte instruction execution. interrupt starts when execution of the current instruction or exception handling ends, if an interrupt request has been issued. note that after executing the andc, orc, xorc, or ldc instruction or at the completion of reset exception processing, no interrupt is detected. low trap instruction (trapa) started by execution of a trap instruction (trapa). trap exception processing is always accepted in program execution state. note: * supported only by the h8s/2218 group. 4.2 exception sources and exception vector table different vector addresses are assigned to differ ent exception sources. table 4.2 lists the exception sources and their vector addresses. since the us able modes differ depending on the product, for details on each product, refer to section 3, mcu operating modes. section 4 exception handling rev.6.00 jun. 03, 2008 page 82 of 698 rej09b0074-0600 table 4.2 exception handling vector table vector address * 1 exception source vector number normal mode * 4 advanced mode power-on reset 0 h'0000 to h'0001 h'0000 to h'0003 manual reset 1 h'0002 to h'0003 h'0004 to h'0007 2 h'0004 to h'0005 h'0008 to h'000b 3 h'0006 to h'0007 h'000c to h'000f reserved for system use 4 h'0008 to h'0019 h'0010 to h'0013 trace 5 h'000a to h'000b h'0014 to h'0017 direct transitions * 2 6 h'000c to h'000d h'0018 to h'001b external interrupt (nmi) 7 h'000e to h'000f h'001c to h'001f #0 8 h'0010 to h'0011 h'0020 to h'0023 #1 9 h'0012 to h'0013 h'0024 to h'0027 #2 10 h'0014 to h'0015 h'0028 to h'002b trap instruction #3 11 h'0016 to h'0017 h'002c to h'002f 12 h'0018 to h'0019 h'0030 to h'0033 13 h'001a to h'001b h'0034 to h'0037 14 h'001c to h'001d h'0038 to h'003b reserved for system use 15 h'001e to h'001f h'003c to h'003f external interrupt irq0 16 h'0020 to h'0021 h'0040 to h'0043 external interrupt irq1 17 h'0022 to h'0023 h'0044 to h'0047 external interrupt irq2 18 h'0024 to h'0025 h'0048 to h'004b external interrupt irq3 19 h'0026 to h'0027 h'004c to h'004f external interrupt irq4 20 h'0028 to h'0029 h'0050 to h'0053 rtc interrupt irq5 21 h'002a to h'002b h'0054 to h'0057 usb interrupt irq6 22 h'002c to h'002d h'0058 to h'005b external interrupt irq7 23 h'002e to h'002f h'005c to h'005f internal interrupt * 3 24 h'0030 to h'0031 h'0060 to h'0063 ? ? ? 127 h'00fe to h'00ff h'01fc to h'01ff notes: 1. lower 16 bits of the address. 2. for direct transfer, see section 20.10, direct transitions. 3. for details of internal interrupt vectors, see section 5.5, interrupt exception handling vector table. 4. not available in this lsi. section 4 exception handling rev.6.00 jun. 03, 2008 page 83 of 698 rej09b0074-0600 4.3 reset a reset has the highest exception priority. when the res or mres * pin goes low, all processing halts and this lsi enters the reset state. to ensure that this lsi is reset, hold the res pin low for at least 20 ms at power-up or hold the res or mres * pin low for at least 20 states during operation. a reset initializes the internal state of the cpu and the registers of on-chip peripheral modules. this lsi can also be reset by overflow of the watchdog timer. for details, see section 10, watchdog timer (wdt). immediately after a reset, interrupt control mode 0 is set. notes: trst in the HD64F2218 and HD64F2218u, which incorporate a boundary scan function, should be brought low when power is on. for details, see section 13, boundary scan function. * supported only by the h8s/2218 group. 4.3.1 reset types a reset can be of either of two types for the h8s/2218 group: a power-on reset or a manual reset. a reset for the h8s/2212 group is power-on reset. reset types are shown in table 4.3. a power-on reset should be used when powering on. the internal state of the cpu is initialized by either type of reset. a power-on reset also initializes all the registers in the on-chip peripheral modules, while a manual reset initializes all the registers in the on-chip peripheral modules except for the bus controller and i/o ports, which retain their previous states. with a manual reset, since the on-chip peripheral modules are initialized, ports used as on-chip peripheral module i/o pins are switched to i/o ports controlled by ddr and dr. section 4 exception handling rev.6.00 jun. 03, 2008 page 84 of 698 rej09b0074-0600 table 4.3 reset types reset transition condition internal state type mres res cpu on-chip peripheral modules power-on reset low initialized initialized manual reset low high initialized initialized, except for bus controller and i/o ports legend: : don't care a reset caused by the watchdog timer can also be of either of two types: a power-on reset or a manual reset. when the mres pin* is used, mres pin* input must be enabled by setting the mrese bit to 1 in syscr. note:* supported only by the h8s/2218 group. 4.3.2 reset exception handling when the res or mres * pin goes low, this lsi enters the reset. to ensure that this lsi is reset, hold the res pin low for at least 20 ms at power-up. to reset the chip during operation, hold the res or mres * pin low for at least 20 states. when the res or mres * pin goes high after being held low for the necessary time, this lsi starts reset exception handling as follows. 1. the internal state of the cpu and the registers of the on-chip peripheral modules are initialized, the t bit is cleared to 0 in exr, and the i bit is set to 1 in exr and ccr. 2. the reset exception handling vector address is read and transferred to the pc, and program execution starts from the address indicated by the pc. note: * supported only by the h8s/2218 group. figures 4.1 and 4.2 show examples of the reset sequence. section 4 exception handling rev.6.00 jun. 03, 2008 page 85 of 698 rej09b0074-0600 (1) (3) (2) (4) (5) (6) note: * three program wait states are inserted. reset exception handling vector address (for power-on reset, (1) = h'000000, (3) = h'000002; for manual reset, (1) = h'000004, (3) = h'000006) start address (contents of reset exception handling vector address) start address ((5) = (2) (4)) first program instruction res , mres address bus rd hwr , lwr d15 to d0 (1) (3) high (2) (4) (5) (6) * * * vector fetch internal processing prefetch of first program instruction figure 4.1 reset sequence (mode 4) section 4 exception handling rev.6.00 jun. 03, 2008 page 86 of 698 rej09b0074-0600 (1) (3) (2) (4) (5) (6) : reset exception handling vector address (for a power-on reset, (1) = h'000000, (3) = h'000002 for a manual reset, (1) = h'000004, (3) = h'000006) : start address (contents of reset exceptiion handling vector address) : start address ((5) = (2) (4)) : first program instruction res , mres internal address bus internal read signal internal write signal internal data bus vector fetch (1) (3) (5) high internal processing prefetch of first program instruction (4) (6) (2) figure 4.2 reset sequence (modes 6 and 7) 4.3.3 interrupts after reset if an interrupt is accepted after a reset but before the stack pointer (sp) is initialized, the pc and ccr will not be saved correctly, leading to a program crash. to prevent this, all interrupt requests, including nmi, are disabled immediately after a reset. since the first instruction of a program is always executed immediately after the reset state ends, make sure that this instruction initializes the stack pointer (example: mov.l #xx: 32,sp). 4.3.4 state of on-chip peripheral modules after reset release after reset release, mstpcra, mstpcrb, and mstpcrc are initialized and all modules except the dmac enter module stop mode. consequently, on-chip peripheral module registers cannot be read from or written to. register reading and writing is enabled when module stop mode is exited. section 4 exception handling rev.6.00 jun. 03, 2008 page 87 of 698 rej09b0074-0600 4.4 traces traces are enabled in interrupt control mode 2. trace mode is not activated in interrupt control mode 0, irrespective of the state of the t bit. for details of interrupt control modes, see section 5, interrupt controller. if the t bit in exr is set to 1, trace mode is activated. in trace mode, a trace exception occurs on completion of each instruction. trace mode is not affected by interrupt masking. table 4.4 shows the state of ccr and exr after execution of trace exception handling. trace mode is canceled by clearing the t bit in exr to 0. the t bit saved on the stack retains its value of 1, and when control is returned from the trace exception handling routine by the rte instruction, trace mode resumes. trace exception handling is not carried out after execution of the rte instruction. interrupts are accepted even within the trace exception handling routine. table 4.4 status of ccr and exr after trace exception handling ccr exr interrupt control mode i ui i2 to i0 t 0 trace exception handling cannot be used. 2 1 ? ? 0 legend: 1: set to 1 0: cleared to 0 ?: retains value prior to execution. 4.5 interrupts interrupts are controlled by the interrupt controller. the interrupt controller has two interrupt control modes and can assign interrupts other than nmi to eight priority/mask levels to enable multiplexed interrupt control. the source to start interrupt exception handling and the vector address differ depending on the product. for details, refer to section 5, interrupt controller. the interrupt exception handling is as follows: 1. the values in the program counter (pc), condition code register (ccr), and extended control register (exr) are saved in the stack. 2. the interrupt mask bit is updated and the t bit is cleared. 3. a vector address corresponding to the interrupt source is generated, the start address is loaded from the vector table to the pc, and program execution starts from that address. section 4 exception handling rev.6.00 jun. 03, 2008 page 88 of 698 rej09b0074-0600 4.6 trap instruction trap instruction exception handling starts when a trapa instruction is executed. trap instruction exception handling can be executed at all times in the program execution state. the trap instruction exception handling is as follows: 1. the values in the program counter (pc), condition code register (ccr), and extended control register (exr) are saved in the stack. 2. the interrupt mask bit is updated and the t bit is cleared. 3. a vector address corresponding to the interrupt source is generated, the start address is loaded from the vector table to the pc, and program execution starts from that address. the trapa instruction fetches a start address from a vector table entry corresponding to a vector number from 0 to 3, as specified in the instruction code. table 4.5 shows the status of ccr and exr after execution of trap instruction exception handling. table 4.5 status of ccr and exr after trap instruction exception handling ccr exr interrupt control mode i ui i2 to i0 t 0 1 ? ? ? 2 1 ? ? 0 legend: 1: set to 1 0: cleared to 0 ?: retains value prior to execution. section 4 exception handling rev.6.00 jun. 03, 2008 page 89 of 698 rej09b0074-0600 4.7 stack status aft er exception handling figure 4.3 shows the stack after completion of trap instruction exception handling and interrupt exception handling. ccr ccr * 1 pc (16 bits) sp exr reserved * 1 ccr ccr * 1 pc (16 bits) sp ccr pc (24 bits) sp exr reserved * 1 ccr pc (24 bits) sp (a) normal modes * 2 (b) advanced modes interrupt control mode 0 interrupt control mode 2 interrupt control mode 0 interrupt control mode 2 notes: 1. 2. ignored on return. normal modes are not available in this lsi. figure 4.3 stack status after exception handling section 4 exception handling rev.6.00 jun. 03, 2008 page 90 of 698 rej09b0074-0600 4.8 notes on use of the stack when accessing word data or longword data, this lsi assumes that the lowest address bit is 0. the stack should always be accessed by word transfer in struction or longword transfer instruction, and the value of the stack pointer (sp: er7) should always be kept even. use the following instructions to save registers: push.w rn (or mov.w rn, @-sp) push.l ern (or mov.l ern, @-sp) use the following instructions to restore registers: pop.w rn (or mov.w @sp+, rn) pop.l ern (or mov.l @sp+, ern) setting sp to an odd value may lead to a malfunction. figure 4.4 shows an example of what happens when the sp value is odd. sp ccr: pc: r1l: sp: condition code register program counter general register r1l stack pointer ccr sp sp r1l h'fffefa h'fffefb h'fffefc h'fffefd h'fffefe h'fffeff pc pc trapa instruction executed sp set to h'fffeff data saved above sp mov.b r1l, @-er7 executed contents of ccr lost address legend: note: this diagram illustrates an example in which the interrupt control mode is 0, in advanced mode. figure 4.4 operation when sp value is odd section 5 interrupt controller rev.6.00 jun. 03, 2008 page 91 of 698 rej09b0074-0600 section 5 interrupt controller 5.1 features ? two interrupt control modes ? any of two interrupt control modes can be set by means of the intm1 and intm0 bits in the system control register (syscr). ? priorities settable with ipr ? an interrupt priority register (ipr) is provided for setting interrupt priorities. eight priority levels can be set for each module for all interrupts except nmi. nmi is assigned the highest priority level of 8, and can be accepted at all times. ? independent vector addresses ? all interrupt sources are assigned independent vector addresses, making it unnecessary for the source to be identified in the interrupt handling routine. ? seven external interrupts (nmi, irq7 , and irq4 to irq0 ) ? nmi is the highest-priority interrupt, and is accepted at all times. rising edge or falling edge can be selected for nmi. falling edge, rising edge, or both edge detection, or level sensing, can be selected for irq7 and irq4 to irq0 . irq6 is an interrupt only for the on- chip usb. irq5 is an interrupt only for the on-chip rtc. ? dmac control ? dmac activation is performed by means of interrupts. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 92 of 698 rej09b0074-0600 a block diagram of the interrupt controller is shown in figure 5.1. syscr nmi input irq input internal interrupt request wovi to exirq1 intm1, intm0 nmieg nmi input unit irq input unit isr iscr ier ipr interrupt controller priority determination interrupt request vector number i i2 to i0 ccr exr cpu iscr: ier: isr: ipr: syscr: irq sense control register irq enable register irq status register interrupt priority register system control register legend: figure 5.1 block diagram of interrupt controller section 5 interrupt controller rev.6.00 jun. 03, 2008 page 93 of 698 rej09b0074-0600 5.2 input/output pins table 5.1 summarizes the pins of the interrupt controller. table 5.1 pin configuration name i/o function nmi input nonmaskable external interrupt rising or falling edge can be selected irq7 input irq4 input irq3 input irq2 input maskable external interrupts rising, falling, or both edges, or level sensing can be selected ( irq6 is an interrupt signal only for the on-chip usb. irq5 is an interrupt signal only for the on-chip rtc.) irq1 input irq0 input 5.3 register descriptions the interrupt controller has the following registers. for details on the system control register, refer to section 3.2.2, system control register (syscr). ? system control register (syscr) ? irq sense control register h (iscrh) ? irq sense control register l (iscrl) ? irq enable register (ier) ? irq status register (isr) ? interrupt priority register a (ipra) ? interrupt priority register b (iprb) ? interrupt priority register c (iprc) ? interrupt priority register d (iprd) ? interrupt priority register e (ipre) ? interrupt priority register f (iprf) ? interrupt priority register g (iprg) ? interrupt priority register j (iprj) ? interrupt priority register k (iprk) ? interrupt priority register m (iprm) section 5 interrupt controller rev.6.00 jun. 03, 2008 page 94 of 698 rej09b0074-0600 5.3.1 interrupt priority registers a to g, j, k, m (ipra to iprg, iprj, iprk, iprm) the ipr registers set priorities (levels 7 to 0) for interrupts other than nmi. the correspondence between interrupt sources and ipr settings is shown in section 5.5, interrupt exception handling vector table. setting a value in the range from h'0 to h'7 in the 3-bit groups of bits 6 to 4 and 2 to 0 sets the priority of the corresponding interrupt. bit bit name initial value r/w description 7 ? 0 ? reserved this bit is always read as 0 and cannot be modified. 6 5 4 ipr6 ipr5 ipr4 1 1 1 r/w r/w r/w these bits set the priority of the corresponding interrupt source. 000: priority level 0 (lowest) 001: priority level 1 010: priority level 2 011: priority level 3 100: priority level 4 101: priority level 5 110: priority level 6 111: priority level 7 (highest) 3 ? 0 ? reserved this bit is always read as 0 and cannot be modified. 2 1 0 ipr2 ipr1 ipr0 1 1 1 r/w r/w r/w these bits set the priority of the corresponding interrupt source. 000: priority level 0 (lowest) 001: priority level 1 010: priority level 2 011: priority level 3 100: priority level 4 101: priority level 5 110: priority level 6 111: priority level 7 (highest) section 5 interrupt controller rev.6.00 jun. 03, 2008 page 95 of 698 rej09b0074-0600 5.3.2 irq enable register (ier) ier controls enabling and disabling of interrupt requests irq7 to irq0. bit bit name initial value r/w description 7 irq7e 0 r/w irq7 enable the irq7 interrupt request is enabled when this bit is 1. 6 irq6e 0 r/w irq6 enable * 1 the irq6 interrupt request is enabled when this bit is 1. 5 irq5e 0 r/w irq5 enable * 2 the irq5 interrupt request is enabled when this bit is 1. 4 irq4e 0 r/w irq4 enable the irq4 interrupt request is enabled when this bit is 1. 3 irq3e 0 r/w irq3 enable the irq3 interrupt request is enabled when this bit is 1. 2 irq2e 0 r/w irq2 enable the irq2 interrupt request is enabled when this bit is 1. 1 irq1e 0 r/w irq1 enable the irq1 interrupt request is enabled when this bit is 1. 0 irq0e 0 r/w irq0 enable the irq0 interrupt request is enabled when this bit is 1. notes: 1. irq6 is an interrupt only for the on-chip usb. 2. irq5 is an interrupt only for the on-chip rtc. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 96 of 698 rej09b0074-0600 5.3.3 irq sense control registers h and l (iscrh, iscrl) the iscr registers select the source that generates an interrupt request at pins irq7 to irq0 . bit bit name initial value r/w description 15 14 irq7scb irq7sca 0 0 r/w r/w irq7 sense control b irq7 sense control a 00: interrupt request generated at irq7 input low level 01: interrupt request generated at falling edge of irq7 input 10: interrupt request generated rising edge of irq7 input 11: interrupt request generated at both falling and rising edges of irq7 input 13 12 irq6scb irq6sca 0 0 r/w r/w irq6 * 1 sense control b irq6 * 1 sense control a 00: setting prohibited when using on-chip usb suspend or resume interrupt 01: interrupt request generated at falling edge of irq6 input 1x: setting prohibited 11 10 irq5scb irq5sca 0 0 r/w r/w irq5 * 2 sense control b irq5 * 2 sense control a 00: setting prohibited when using rtc interrupt 01: interrupt request generated at falling edge of irq5 input 1x: setting prohibited 9 8 irq4scb irq4sca 0 0 r/w r/w irq4 sense control b irq4 sense control a 00: interrupt request generated at irq4 input low level 01: interrupt request generated at falling edge of irq4 input 10: interrupt request generated at rising edge of irq4 input 11: interrupt request generated at both falling and rising edges of irq4 input section 5 interrupt controller rev.6.00 jun. 03, 2008 page 97 of 698 rej09b0074-0600 bit bit name initial value r/w description 7 6 irq3scb irq3sca 0 0 r/w r/w irq3 sense control b irq3 sense control a 00: interrupt request generated at irq3 input low level 01: interrupt request generated at falling edge of irq3 input 10: interrupt request generated at rising edge of irq3 input 11: interrupt request generated at both falling and rising edges of irq3 input 5 4 irq2scb irq2sca 0 0 r/w r/w irq2 sense control b irq2 sense control a 00: interrupt request generated at irq2 input low level 01: interrupt request generated at falling edge of irq2 input 10: interrupt request generated at rising edge of irq2 input 11: interrupt request generated at both falling and rising edges of irq2 input 3 2 irq1scb irq1sca 0 0 r/w r/w irq1 sense control b irq1 sense control a 00: interrupt request generated at irq1 input low level 01: interrupt request generated at falling edge of irq1 input 10: interrupt request generated at rising edge of irq1 input 11: interrupt request generated at both falling and rising edges of irq1 input section 5 interrupt controller rev.6.00 jun. 03, 2008 page 98 of 698 rej09b0074-0600 bit bit name initial value r/w description 1 0 irq0scb irq0sca 0 0 r/w r/w irq0 sense control b irq0 sense control a 00: interrupt request generated at irq0 input low level 01: interrupt request generated at falling edge of irq0 input 10: interrupt request generated at rising edge of irq0 input 11: interrupt request generated at both falling and rising edges of irq0 input legend: : don?t care notes: 1. irq6 is an interrupt only for the on-chip usb. 2. irq5 is an interrupt only for the on-chip rtc. 5.3.4 irq status register (isr) isr indicates the status of irq7 to irq0 interrupt requests. bit bit name initial value r/w description 7 irq7f 0 r/(w) * 6 irq6f 0 r/(w) * 5 irq5f 0 r/(w) * 4 irq4f 0 r/(w) * 3 irq3f 0 r/(w) * 2 irq2f 0 r/(w) * 1 irq1f 0 r/(w) * 0 irq0f 0 r/(w) * [setting condition] when the interrupt source selected by the iscr registers occurs [clearing conditions] ? cleared by reading irqnf flag when irqnf = 1, then writing 0 to irqnf flag ? when interrupt exception handling is executed when low-level detection is set and , irqn input is high ? when irqn interrupt exception handling is executed when falling, rising, or both-edge detection is set note: * only 0 can be written, to clear flags. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 99 of 698 rej09b0074-0600 5.4 interrupt sources 5.4.1 external interrupts there are seven external interrupts: nmi, irq7, and irq4 to irq0. these interrupts can be used to restore this lsi from software standby mode. though irq5 is only for the on-chip rtc and irq6 is only for the on-chip usb, the interrupts can be used to restore this lsi from software standby mode. irq5 and irq6 are functionally same as irq7 and irq4 to irq0. nmi interrupt: nmi is the highest-priority interrupt, and is always accepted by the cpu regardless of the interrupt control mode or the status of the cpu interrupt mask bits. the nmieg bit in syscr can be used to select whether an interrupt is requested at a rising edge or a falling edge on the nmi pin. irq7 to irq0 interrupts: interrupts irq7 to irq0 are requested by an input signal at pins irq7 to irq0 . interrupts irq7 to irq0 have the following features: ? using iscr, it is possible to select whether an interrupt is generated by a low level, falling edge, rising edge, or both edges, at pins irq7 to irq0 ? enabling or disabling of interrupt requests irq7 to irq0 can be selected with ier. ? the interrupt priority level can be set with ipr. ? the status of interrupt requests irq7 to irq0 is indicated in isr. isr fl ags can be cleared to 0 by software. a block diagram of irqn interrupts is shown in figure 5.2. irqne irqnf s r q irqn interrupt request clear signal edge/level detection circuit irqnsca, irqnscb irqn input note: n = 7 to 0 figure 5.2 block diagram of interrupts irqn section 5 interrupt controller rev.6.00 jun. 03, 2008 page 100 of 698 rej09b0074-0600 the set timing for irqnf is shown in figure 5.3. irqn input pin irqnf note: n = 7 to 0 figure 5.3 timing of setting irqnf the detection of irqn interrupts does not depend on whether the relevant pin has been set for input or output. however, when a pin is used as an external interrupt input pin, do not clear the corresponding ddr to 0; and use the pin as an i/o pin for another function. irqnf interrupt request flag is set when the setting condition is sa tisfied, regardless of ier settings. accordingly, refer to only necessary flags. 5.4.2 internal interrupts the sources for internal interrupts from on?chip peripheral modules have the following features: ? for each on?chip peripheral module there are flags that indicate the interrupt request status, and enable bits that select enabling or disabling of these interrupts. if both of these are set to 1 for a particular interrupt source, an interrupt request is issued to the interrupt controller. ? the interrupt priority level can be set by means of ipr. ? the dmac can be activated by a tpu, sci, or other interrupt request. ? when the dmac is activated by an interrupt request, it is not affected by the interrupt control mode or cpu interrupt mask bit. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 101 of 698 rej09b0074-0600 5.5 interrupt exception handling vector table table 5.2 shows interrupt exception handling sources, vector addresses, and interrupt priorities. for default priorities, the lower the vector number, the higher the priority. priorities among modules can be set by means of the ipr. modules set at the same priority will conform to their default priorities. priorities within a module are fixed. table 5.2 interrupt sources, vector addresses, and interrupt priorities vector address * interrupt source origin of interrupt source vector number advanced mode ipr priority external pins nmi 7 h'001c high irq0 16 h'0040 ipra6 to ipra4 irq1 17 h'0044 ipra2 to ipra0 irq2 18 h'0048 iprb6 to iprb4 irq3 19 h'004c irq4 20 h'0050 iprb2 to iprb0 rtc irq5 21 h'0054 usb irq6 22 h'0058 iprc6 to iprc4 external pins irq7 23 h'005c watchdog timer wovi 25 h'0064 iprd6 to iprd4 a/d adi 28 h'0070 ipre2 to ipre0 tgi0a 32 h'0080 tgi0b 33 h'0084 tgi0c 34 h'0088 tgi0d 35 h'008c tpu channel 0 tgi0v 36 h'0090 iprf6 to iprf4 tpu channel 1 tgi1a 40 h'00a0 iprf2 to iprf0 tgi1b 41 h'00a4 tgi1v 42 h'00a8 tgi1u 43 h'00ac low section 5 interrupt controller rev.6.00 jun. 03, 2008 page 102 of 698 rej09b0074-0600 vector address * interrupt source origin of interrupt source vector number advanced mode ipr priority tgi2a 44 h'00b0 high tgi2b 45 h'00b4 tgi2v 46 h'00b8 tpu channel 2 tgi2u 47 h'00bc iprg6 to iprg4 dend0a 72 h'0120 dend0b 73 h'0124 dend1a 74 h'0128 dmac dend1b 75 h'012c iprj6 to iprj4 eri0 80 h'0140 rxi0 81 h'0144 txi0 82 h'0148 sci channel 0 tei0 83 h'014c iprj2 to iprj0 eri2 88 h'0160 rxi2 89 h'0164 txi2 90 h'0168 sci channel 2 tei2 91 h'016c iprk2 to iprk0 usb exirq0 104 h'01a0 iprm6 to iprm4 exirq1 105 h'01a4 low note: * lower 16 bits of the start address. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 103 of 698 rej09b0074-0600 5.6 interrupt control modes and interrupt operation the interrupt controller has two modes: interrupt control mode 0 and interrupt control mode 2. interrupt operations differ depending on the interrupt control mode. the interrupt control mode is selected by syscr. table 5.3 shows the differences between interrupt control mode 0 and interrupt control mode 2. table 5.3 interrupt control modes interrupt control mode priority setting register interrupt mask bits description 0 default i the priority of interrupt sources are fixed at the default settings. interrupt sources except for nmi is marked by the i bit. 2 ipr i2 to i0 8-level interrupt mask control is performed by bits i2 to i0. 8 priority levels other than nmi can be set with ipr. 5.6.1 interrupt control mode 0 in interrupt control mode 0, interrupt requests except for nmi is masked by the i bit of ccr in the cpu. figure 5.4 shows a flowchart of the interrupt acceptance operation in this case. 1. if an interrupt source occurs when the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. 2. if the i bit is set to 1, only an nmi interrupt is accepted, and other interrupt requests are held pending. if the i bit is cleared, an interrupt request is accepted. 3. interrupt requests are sent to the interrupt co ntroller, the highest-ranked interrupt according to the priority system is accepted, and other interrupt requests are held pending. 4. when the cpu accepts an interrupt request, it starts interrupt exception handling after execution of the current instruction has been completed. 5. the pc and ccr are saved to the stack area by interrupt exception handling. the pc saved on the stack shows the address of the first instruction to be executed after returning from the interrupt handling routine. 6. next, the i bit in ccr is set to 1. this masks all interrupts except nmi. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 104 of 698 rej09b0074-0600 7. the cpu generates a vector address for the accepted interrupt and starts execution of the interrupt handling routine at the address indicated by the contents of the vector address in the vector table. program execution status interrupt generated? nmi irq0 irq1 exirq1 i = 0 save pc and ccr i 1 read vector address branch to interrupt handling routine yes no yes yes yes no no no yes yes no hold pending figure 5.4 flowchart of proce dure up to interrupt acceptance in interrupt control mode 0 section 5 interrupt controller rev.6.00 jun. 03, 2008 page 105 of 698 rej09b0074-0600 5.6.2 interrupt control mode 2 in interrupt control mode 2, mask control is done in eight levels for interrupt requests except for nmi by comparing the exr interrupt mask level (i2 to i0 bits) in the cpu and the ipr setting. figure 5.5 shows a flowchart of the interrupt acceptance operation in this case. 1. if an interrupt source occurs when the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. 2. when interrupt requests are sent to the interrupt controller, the interrupt with the highest priority according to the interrup t priority levels set in ipr is selected, and lower-priority interrupt requests are held pending. if a number of interrupt requests with the same priority are generated at the same time, the interrupt request with the highest priority according to the priority system shown in table 5.2 is selected. 3. next, the priority of the selected interrupt request is compared with the interrupt mask level set in exr. an interrupt request with a priority no higher than the mask level set at that time is held pending, and only an interrupt request with a priority higher than the interrupt mask level is accepted. 4. when the cpu accepts an interrupt request, it starts interrupt exception handling after execution of the current instruction has been completed. 5. the pc, ccr, and exr are saved to the stack area by interrupt exception handling. the pc saved on the stack shows the address of the first instruction to be executed after returning from the interrupt handling routine. 6. the t bit in exr is cleared to 0. the interrupt mask level is rewritten with the priority level of the accepted interrupt. if the accepted interrupt is nmi, the interrupt mask level is set to h'7. 7. the cpu generates a vector address for the accepted interrupt and starts execution of the interrupt handling routine at the address indicated by the contents of the vector address in the vector table. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 106 of 698 rej09b0074-0600 yes program execution status interrupt generated? nmi level 6 interrupt? mask level 5 or below? level 7 interrupt? mask level 6 or below? save pc, ccr, and exr clear t bit to 0 update mask level read vector address branch to interrupt handling routine level 1 interrupt? mask level 0? yes yes no yes yes yes no yes yes no no no no no no hold pending figure 5.5 flowchart of procedu re up to interrupt acceptance in interrupt control mode 2 section 5 interrupt controller rev.6.00 jun. 03, 2008 page 107 of 698 rej09b0074-0600 5.6.3 interrupt exception handling sequence figure 5.6 shows the interrupt exception handling sequence. the example shown is for the case where interrupt control mode 0 is set in advanced mode, and the program area and stack area are in on-chip memory. (14) (12) (10) (6) (4) (2) (1) (5) (7) (9) (11) (13) interrupt service routine instruction prefetch internal operation vector fetch stack instruction prefetch internal operation interrupt acceptance interrupt level determination wait for end of instruction interrupt request signal internal address bus internal read signal internal write signal internal data bus (3) (1) (2) (4) (3) (5) (7) instruction prefetch address (not executed. this is the contents of the saved pc, the return address) instruction code (not executed) instruction prefetch address (not executed) sp-2 sp-4 saved pc and saved ccr vector address interrupt handling routine start address (vector address contents) interrupt handling routine start address ((13) = (10) (12)) first instruction of interrupt handling routine (6) (8) (9) (11) (10) (12) (13) (14) (8) figure 5.6 interrupt exception handling section 5 interrupt controller rev.6.00 jun. 03, 2008 page 108 of 698 rej09b0074-0600 5.6.4 interrupt response times table 5.4 shows interrupt response times ? the interval between generation of an interrupt request and execution of the first instruction in the interrupt handling routine. the execution status symbols used in table 5.4 are explained in table 5.5. this lsi is capable of fast word transfer to on-chip memory, and have the program area in on-chip rom and the stack area in on-chip ram, enabling high-speed processing. table 5.4 interrupt response times normal mode * 5 advanced mode no. execution state interrupt control mode 0 interrupt control mode 2 interrupt control mode 0 interrupt control mode 2 1 interrupt priority determination * 1 3 3 3 3 2 number of wait states until executing instruction ends * 2 1 to 19+2s i 1 to 19+2s i 1 to 19+2s i 1 to 19+2s i 3 pc, ccr, exr stack save 2s k 3s k 2s k 3s k 4 vector fetch s i s i 2s i 2s i 5 instruction fetch * 3 2s i 2s i 2s i 2s i 6 internal processing * 4 2 2 2 2 total (using on-chip memory) 11 to 31 12 to 32 12 to 32 13 to 33 notes: 1. two states in case of internal interrupt. 2. refers to mulxs and divxs instructions. 3. prefetch after interrupt acceptance and interrupt handling routine prefetch. 4. internal processing after interrupt acceptance and internal processing after vector fetch. 5. not available in this lsi. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 109 of 698 rej09b0074-0600 table 5.5 number of states in interrupt handling routine execution statuses object of access external device 8-bit bus 16-bit bus symbol internal memory 2-state access 3-state access 2-state access 3-state access instruction fetch s i 1 4 6 + 2m 2 3 + m branch address read s j stack manipulation s k legend: m: number of wait states in an external device access. 5.6.5 dmac activation by interrupt the dmac can be activated by an interrupt. in this case, the following options are available: ? interrupt request to cpu ? activation request to dmac ? selection of a number of the above for details of interrupt requests that can be used with to activate the dmac, see section 7, dma controller (dmac). figure 5.7 shows a block diagram of the interrupt controller of dmac. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 110 of 698 rej09b0074-0600 cpu i, i2 to i0 dmac irq interrupt on-chip peripheral module interrupt source clear signal interrupt request disenable signal clear signal selection circuit cpu interrupt request vector number interrupt controller determination of priority control logic figure 5.7 interrupt control for dmac selection of interrupt source: an activation factor is directly input to each channel of the dmac. the activation factors for each channel of the dmac are selected by the dtf3 to dtf0 bits of dmacr. the dta bit of dmabcr can be us ed to select whether the selected activation factors are managed by the dmac. by setting the dta bit to 1, the interrupt factor which was the activation factor for that dmac cannot act as the cpu interrupt factor. interrupt factors other than the interrupts managed by the dmac is cpu interrupt request. determination of priority: the activation source is directly input to each channel of dmac. operation order: if the same interrupt is selected as the dmac activation factor or cpu interrupt factor, these operate independently. they operate in accordance with the respective operating states and bus priorities. table 5.6 shows the interrupt factor clear control and selection of interrupt factors by specification of the dta bit of dmac's dmabcr. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 111 of 698 rej09b0074-0600 table 5.6 interrupt source sel ection and clea ring control settings dmac interrupt sources se lection/clearing control dta dmac cpu 0 1 x legend: : the relevant interrupt is used. interrupt source clearing is performed. (the cpu should clear the source flag in the interrupt handling routine.) : the relevant interrupt is used. the interrupt source is not cleared. x: the relevant bit cannot be used. notes on use: the sci interrupt source is cleared when the dmac reads or writes to the prescribed register, and is not dependent upon the dta bit. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 112 of 698 rej09b0074-0600 5.7 usage notes 5.7.1 contention between interrupt generation and disabling when an interrupt enable bit is cleared to 0 to disable interrupts, the disabling becomes effective after execution of the instruction. when an interrupt enable bit is cleared to 0 by an instruction such as bclr or mov, if an interrupt is generated during execution of the instruction, the interrupt concerned will still be enabled on completion of the instruction, and so interrupt exception handling for that interrupt will be executed on completion of the instruction. however, if there is an interrupt request of higher priority than that interrupt, interrupt exception handling will be executed for the higher-priority interrupt, and the lower-priority interrupt will be ignored. the same also applies when an interrupt source flag is cleared to 0. figure 5.8 shows an example in which the tgiea bit in the tpu's tier_0 is cleared to 0. the above contention will not occur if an enable b it or interrupt source flag is cleared to 0 while the interrupt is masked. internal address bus internal write signal tgiea tgfa tgi0a interrupt signal tier0 write cycle by cpu tgi0a exception handling tier_0 address figure 5.8 contention between in terrupt generation and disabling section 5 interrupt controller rev.6.00 jun. 03, 2008 page 113 of 698 rej09b0074-0600 5.7.2 instructions that disable interrupts instructions that disable interrupts are ldc, andc, orc, and xorc. after any of these instructions is executed, all interrupts including nmi are disabled and the next instruction is always executed. when the i bit is set by one of these instructions, the new value becomes valid two states after execution of the instruction ends. 5.7.3 times when interrupts are disabled there are times when interrupt acceptance is disabled by the interrupt controller. the interrupt controller disables interrupt accep tance for a 3-state period after the cpu has updated the mask level with an ldc, andc, orc, or xorc instruction. 5.7.4 interrupts during execution of eepmov instruction interrupt operation differs between the eepmov.b instruction and the eepmov.w instruction. with the eepmov.b instruction, an interrupt request (including nmi) issued during the transfer is not accepted until the move is completed. with the eepmov.w instruction, if an interrupt request is issued during the transfer, interrupt exception handling starts at a break in the transfer cycle. the pc value saved on the stack in this case is the address of the next instruction. therefore, if an interrupt is generated during execution of an eepmov.w instruction, the following coding should be used. l1: eepmov.w mov.w r4, r4 bne l1 5.7.5 irq interrupt when operating by clock input, acceptance of input to an irq is synchronized with the clock. in software standby mode and watch mode, the input is accepted asynchronously. for details on the input conditions, see section 22.4.2, control signal timing. section 5 interrupt controller rev.6.00 jun. 03, 2008 page 114 of 698 rej09b0074-0600 5.7.6 nmi interrupt usage notes the nmi interrupt is part of the exception processing performed cooperatively by the lsi?s internal interrupt controller and the cpu when the system is operating normally under the specified electrical conditions. no operations, including nmi interrupts, are guaranteed when operation is not normal (runaway status) due to software problems or abnormal input to the lsi?s pins. in such cases, the lsi may be restored to the normal program execution state by applying an external reset. section 6 bus controller rev.6.00 jun. 03, 2008 page 115 of 698 rej09b0074-0600 section 6 bus controller this lsi has a built-in bus controller (bsc) that manages the external address space divided into eight areas. the bus controller also has a bus arbitr ation function, and controls the operation of the internal bus masters: the cpu and dma controller (dmac). 6.1 features ? manages external address space in area units ? manages the external space as 8 areas of 2-mbytes ? bus specifications can be set independently for each area ? burst rom interface can be set ? basic bus interface* 1 ? chip select ( cs0 to cs5 ) can be output for areas 0 to 5* 2 ? 8-bit access or 16-bit access can be selected for each area ? 2-state access or 3-state access can be selected for each area ? program wait states can be inserted for each area ? burst rom interface* 2 ? burst rom interface can be selected for area 0 ? one or two states can be selected for the burst cycle ? idle cycle insertion* 2 ? idle cycle can be inserted between cons ecutive read accesses to different areas ? idle cycle can be inserted before a write access to an external area immediately after a read access to an external area ? bus arbitration ? the on-chip bus arbiter arbitrates bus mastership among cpu and dmac ? other features ? external bus release function* 2 notes: 1. chip select cs6 in area 6 is for the on-chip usb. therefore it cannot be used as an external area. 8-bit bus mode, 3-state access, and no program wait state should be set for area 6. access to the rtc related registers (address: h'ffff40 to h'ffff5f) follows the specification of area 7. 8-bit access, 3-state access, and no program wait state should be set for area 7. 2. these functions are not available in the h8s/2212 group. bscs207a_010020020100 section 6 bus controller rev.6.00 jun. 03, 2008 page 116 of 698 rej09b0074-0600 figure 6.1 shows a block diagram of the bus controller. area decorder bus controller abwcr astcr bcrh bcrl internal address bus external bus control signals chip select signals breq * back * internal control signals wait controller wcrh wcrl bus mode signal internal data bus bus arbiter cpu bus acknowledge signal dmac bus acknowledge signal dmac bus request signal cpu bus request signal wait * note : * supported only by the h8s/2218 group. legend: a bwcr: a stcr: wcrh, wcrl: bcrh, bcrl: bus width control register access state control register waite control registers h, l bus control registers h, l figure 6 . 1 block diagram of bus controller section 6 bus controller rev.6.00 jun. 03, 2008 page 117 of 698 rej09b0074-0600 6.2 input/output pins table 6.1 summarizes the pins of the bus controller. these pins are supported only by the h8s/2218 group. table 6.1 pin configuration name symbol i/o function address strove as output strobe signal indicating that address output on address bus is enabled. read rd output strobe signal indicating that external space is being read. high write hwr output strobe signal indicating that external space is to be written, and upper half (d15 to d8) of data bus is enabled. low write lwr output strobe signal indicating that external space is to be written, and lower half (d7 to d0) of data bus is enabled. chip select 0 to 5 cs0 to cs5 output strobe signal indicating that areas 0 to 5 are selected. wait wait input wait request signal when accessing external 3-state access space. bus request breq input request signal that releases bus to external device. bus request acknowledge back output acknowledge signal indicating that bus has been released. section 6 bus controller rev.6.00 jun. 03, 2008 page 118 of 698 rej09b0074-0600 6.3 register descriptions the following shows the registers of the bus controller. ? bus width control register (abwcr) ? access state control register (astcr) ? wait control register h (wcrh) ? wait control register l (wcrl) ? bus control register h (bcrh) ? bus control register l (bcrl ) ? pin function control register (pfcr) 6.3.1 bus width control register (abwcr) abwcr designates each area for either 8-bit access or 16-bit access. abwcr sets the data bus width for the external memory space. the bus width for on-chip memory and internal i/o registers except for the on-chip usb and rtc is fixed regardless of the settings in abwcr. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 abw7 * 2 abw6 * 2 abw5 abw4 abw3 abw2 abw1 abw0 1/0 * 1 1/0 * 1 1/0 * 1 1/0 * 1 1/0 * 1 1/0 * 1 1/0 * 1 1/0 * 1 r/w r/w r/w r/w r/w r/w r/w r/w area 7 to 0 bus width control: these bits select whether the corresponding area is to be designated for 8-bit access or 16-bit access. 0: area n is designated for 16-bit access 1: area n is designated for 8-bit access legend: n = 7 to 0 notes: 1. in modes 5 to 7, initial value of each bit is 1. in mode 4, initial value of each bit is 0. these bits should be set to 1 in the h8s/2212 group. 2. the on-chip usb and on-chip rtc are allocated to area 6 and area 7, respectively. therefore, these bits should be set to 1. section 6 bus controller rev.6.00 jun. 03, 2008 page 119 of 698 rej09b0074-0600 6.3.2 access state control register (astcr) astcr designates each area as either a 2-state access space or a 3-state access space. astcr sets the number of access states for the external memory space. the number of access states for on-chip memory and internal i/o registers except for the on-chip usb is fixed regardless of the settings in astcr. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 ast7 * ast6 * ast5 ast4 ast3 ast2 ast1 ast0 1 1 1 1 1 1 1 1 r/w r/w r/w r/w r/w r/w r/w r/w area 7 to 0 access state control: these bits select whether the corresponding area is to be designated as a 2-state access space or a 3-state access space. wait state insertion is enabled or disabled at the same time. 0: area n is designated for 2-state access wait state insertion in area n external space is disabled 1: area n is designated for 3-state access wait state insertion in area n external space is enabled legend: n = 7 to 0 note: * the on-chip usb and on-chip rtc are allocated to area 6 and area 7, respectively. therefore, these bits should be set to 1. section 6 bus controller rev.6.00 jun. 03, 2008 page 120 of 698 rej09b0074-0600 6.3.3 wait control registers h and l (wcrh, wcrl) wcrh and wcrl select the number of program wait states for each area. program waits are not inserted in the case of on-chip memory or internal i/o registers except for the on-chip usb. ? wcrh bit bit name initial value r/w description 7 6 w71 * w70 * 1 1 r/w r/w area 7 wait control 1 and 0 these bits select the number of program wait states when area 7 in external space is accessed while the ast7 bit in astcr is set to 1. 00: program wait not inserted when external space area 7 is accessed 01: 1 program wait state inserted when external space area 7 is accessed 10: 2 program wait states inserted when external space area 7 is accessed 11: 3 program wait states inserted when external space area 7 is accessed 5 4 w61 * w60 * 1 1 r/w r/w area 6 wait control 1 and 0 these bits select the number of program wait states when area 6 in external space is accessed while the ast6 bit in astcr is set to 1. 00: program wait not inserted when external space area 6 is accessed 01: 1 program wait state inserted when external space area 6 is accessed 10: 2 program wait states inserted when external space area 6 is accessed 11: 3 program wait states inserted when external space area 6 is accessed note: * the on-chip usb and on-chip rtc are allocated to area 6 and area 7, respectively. therefore, these bits should be set to 0. section 6 bus controller rev.6.00 jun. 03, 2008 page 121 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 2 w51 w50 1 1 r/w r/w area 5 wait control 1 and 0 these bits select the number of program wait states when area 5 in external space is accessed while the ast5 bit in astcr is set to 1. 00: program wait not inserted when external space area 5 is accessed 01: 1 program wait state inserted when external space area 5 is accessed 10: 2 program wait states inserted when external space area 5 is accessed 11: 3 program wait states inserted when external space area 5 is accessed 1 0 w41 w40 1 1 r/w r/w area 4 wait control 1 and 0 these bits select the number of program wait states when area 4 in external space is accessed while the ast4 bit in astcr is set to 1. 00: program wait not inserted when external space area 4 is accessed 01: 1 program wait state inserted when external space area 4 is accessed 10: 2 program wait states inserted when external space area 4 is accessed 11: 3 program wait states inserted when external space area 4 is accessed section 6 bus controller rev.6.00 jun. 03, 2008 page 122 of 698 rej09b0074-0600 ? wcrl bit bit name initial value r/w description 7 6 w31 w30 1 1 r/w r/w area 3 wait control 1 and 0 these bits select the number of program wait states when area 3 in external space is accessed while the ast3 bit in astcr is set to 1. 00: program wait not inserted when external space area 3 is accessed 01: 1 program wait state inserted when external space area 3 is accessed 10: 2 program wait states inserted when external space area 3 is accessed 11: 3 program wait states inserted when external space area 3 is accessed 5 4 w21 w20 1 1 r/w r/w area 2 wait control 1 and 0 these bits select the number of program wait states when area 2 in external space is accessed while the ast2 bit in astcr is set to 1. 00: program wait not inserted when external space area 2 is accessed 01: 1 program wait state inserted when external space area 2 is accessed 10: 2 program wait states inserted when external space area 2 is accessed 11: 3 program wait states inserted when external space area 2 is accessed section 6 bus controller rev.6.00 jun. 03, 2008 page 123 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 2 w11 w10 1 1 r/w r/w area 1 wait control 1 and 0 these bits select the number of program wait states when area 1 in external space is accessed while the ast1 bit in astcr is set to 1. 00: program wait not inserted when external space area 1 is accessed 01: 1 program wait state inserted when external space area 1 is accessed 10: 2 program wait states inserted when external space area 1 is accessed 11: 3 program wait states inserted when external space area 1 is accessed 1 0 w01 w00 1 1 r/w r/w area 0 wait control 1 and 0 these bits select the number of program wait states when area 0 in external space is accessed while the ast0 bit in astcr is set to 1. 00: program wait not inserted when external space area 0 is accessed 01: 1 program wait state inserted when external space area 0 is accessed 10: 2 program wait states inserted when external space area 0 is accessed 11: 3 program wait states inserted when external space area 0 is accessed section 6 bus controller rev.6.00 jun. 03, 2008 page 124 of 698 rej09b0074-0600 6.3.4 bus control register h (bcrh) bcrh selects enabling or disabling of idle cycl e insertion, and the memory interface for area 0. this register should be set initial value and not be modified in the h8s/2212 group. bit bit name initial value r/w description 7 icis1 1 r/w idle cycle insert 1: selects whether or not one idle cycle state is to be inserted between bus cycles when successive external read cycles are performed in different areas. 0: idle cycle not inserted in case of successive external read cycles in different areas 1: idle cycle inserted in case of successive external read cycles in different areas 6 icis0 1 r/w idle cycle insert 0: selects whether or not one idle cycle state is to be inserted between bus cycles when successive external read and write cycles are performed. 0: idle cycle not inserted in case of successive external read and write cycles 1: idle cycle inserted in case of successive external read and write cycles 5 brstrm 0 r/w burst rom enable: selects whether area 0 is used as a burst rom interface. 0: area 0 is basic bus interface 1: area 0 is burst rom interface 4 brsts1 1 r/w burst cycle select 1: selects the number of burst cycles for the burst rom interface. 0: burst cycle comprises 1 state 1: burst cycle comprises 2 states 3 brsts0 0 r/w burst cycle select 0: selects the number of words that can be accessed in a burst rom interface burst access. 0: max. 4 words in burst access 1: max. 8 words in burst access 2 to 0 ? all 0 r/w reserved the write value should always be 0. section 6 bus controller rev.6.00 jun. 03, 2008 page 125 of 698 rej09b0074-0600 6.3.5 bus control register l (bcrl) bcrl performs selection of the external bus-released state protocol, and enabling or disabling of wait pin input. the functions selected by this register are available only in the h8s/2218 group. this register should not be modified in the h8s/2212 group. bit bit name initial value r/w description 7 brle * 0 r/w bus release enable enables or disables external bus release. 0: external bus release is disabled. breq and back can be used as i/o ports. 1: external bus release is enabled. 6 ? 0 r/w reserved the write value should always be 0. 5 ? 0 ? reserved this bit is always read as 0 and cannot be modified. 4 ? 0 r/w reserved the write value should always be 0. 3 ? 1 r/w reserved the write value should always be 1. 2, 1 ? all 0 r/w reserved the write value should always be 0. 0 waite * 0 r/w wait pin enable selects enabling or disabling of wait input by the wait pin. 0: wait input by wait pin disabled. wait pin can be used as i/o port. 1: wait input by wait pin enabled. note: * these bits should be set to 0 in the h8s/2212 group. section 6 bus controller rev.6.00 jun. 03, 2008 page 126 of 698 rej09b0074-0600 6.3.6 pin function control register (pfcr) pfcr performs address output control in external extended mode. when using the usb with the emulator (e6000), enable the a8 and a9 output by setting ae3 to ae0 to 0010. bit bit name initial value r/w description 7 to 4 ? undefined r/w reserved the write value should always be 0. 3 2 1 0 ae3 ae2 ae1 ae0 1/0 * 1/0 * 0 1/0 * r/w r/w r/w r/w address output enable 3 to 0 these bits select enabling or disabling of address outputs a8 to a23 in romless extended mode and modes with rom. when a pin is enabled for address output, the address is output regardless of the corresponding ddr setting. when a pin is disabled for address output, it becomes an output port when the corresponding ddr bit is set to 1. 0000: a8 to a23 output disabled (initial value of mode 6 and 7) 0001: a8 output enabled; a9 to a23 output disabled 0010: a8, a9 output enabled; a10 to a23 output disabled 0011: a8 to a10 output enabled; a11 to a23 output disabled 0100: a8 to a11 output enabled; a12 to a23 output disabled 0101: a8 to a12 output enabled; a13 to a23 output disabled 0110: a8 to a13 output enabled; a14 to a23 output disabled 0111: a8 to a14 output enabled; a15 to a23 output disabled 1000: a8 to a15 output enabled; a16 to a23 output disabled 1001: a8 to a16 output enabled; a17 to a23 output disabled 1010: a8 to a17 output enabled; a18 to a23 output disabled 1011: a8 to a18 output enabled; a19 to a23 output disabled 1100: a8 to a19 output enabled; a20 to a23 output disabled 1101: a8 to a20 output enabled; a21 to a23 output disabled (initial value of modes 4 and 5) 1110: a8 to a21 output enabled; a22, a23 output disabled 1111: a8 to a23 output enabled note: * in modes 4 and 5, initial value of each bit is 1. in modes 6 and 7, initial value of each bit is 0. section 6 bus controller rev.6.00 jun. 03, 2008 page 127 of 698 rej09b0074-0600 6.4 bus control 6.4.1 area divisions in advanced mode, the bus controller partitions the 16 mbytes address space into eight areas, 0 to 7, in 2-mbyte units, and performs bus control for external space in area units. in normal mode*, it controls a 64-kbyte address space comprising part of area 0. figure 6.2 shows an outline of the memory map. chip select signals ( cs0 to cs5 ) can be output for areas 0 to 5. note: * not available in this lsi. area 0 (2 mbytes) h'000000 h'ffffff (1) (2) h'0000 h'1fffff h'200000 area 1 (2 mbytes) h'3fffff h'400000 area 2 (2 mbytes) h'5fffff h'600000 area 3 (2 mbytes) h'7fffff h'800000 area 4 (2 mbytes) h'9fffff h'a00000 area 5 (2 mbytes) h'bfffff h'c00000 area 6 (2 mbytes) h'dfffff h'e00000 area 7 (2 mbytes) h'ffff advanced mode normal mode * 1 notes: 1. not available in this lsi. 2. this area is allocated to the on-chip usb in this lsi. * 2 figure 6.2 overview of area divisions section 6 bus controller rev.6.00 jun. 03, 2008 page 128 of 698 rej09b0074-0600 6.4.2 bus specifications the external space bus specifications consist of three elements: bus width, number of access states, and number of program wait states. the bus width and number of access states for memory and internal i/o registers except for the on- chip usb and rtc are fixed, and are not affected by the bus controller. bus width: a bus width of 8 or 16 bits can be selected with abwcr. an area for which an 8-bit bus is selected functions as an 8-bit access space, and an area for which a 16-bit bus is selected functions as a16-bit access space. if all areas are designated for 8-bit access, 8-bit bus mode is set; if any area is designated for 16-bit access, 16-bit bus mode is set. when the burst rom interface is designated, 16-bit bus mode is always set. 8-bit bus mode should be set for area 6 and area 7 in this lsi. number of access states: two or three access states can be selected with astcr. an area for which 2-state access is selected functions as a 2-state access space, and an area for which 3-state access is selected functions as a 3-state access space. with the burst rom interface, the number of access states may be determined without regard to astcr. when 2-state access space is designated, wait insertion is disabled. area 6 and area 7 should be set to function as a 3-state access space in this lsi. number of program wait states: when 3-state access space is designated by astcr, the number of program wait states to be inserted automatically is selected with wcrh and wcrl. from 0 to 3 program wait states can be selected. the number of program wait states in area 6 and area 7 should be set to 0 in this lsi. section 6 bus controller rev.6.00 jun. 03, 2008 page 129 of 698 rej09b0074-0600 table 6.2 bus specifications for ea ch area (basic bus interface) abwcr astcr wcrh, wcrl bus specifications (basic bus interface) abwn astn wn1 wn0 bus width number of access states number of program wait states 0 0 ? ? 16 2 0 1 0 0 3 0 1 1 1 0 2 1 3 1 0 ? ? 8 2 0 1 0 0 3 0 1 1 1 0 2 1 3 6.4.3 bus interface for each area the initial state of each area is basic bus interface, 3-state access space. the initial bus width is selected according to the operating mode. the bus specifications described here cover basic items only, and the sections on each memory interface (section 6.6, basic bus interface and section 6.7, burst rom interface) should be referred to for further details. note that the rom is always enabled and no external extended mode in the h8s/2212 group. area 0: area 0 includes on-chip rom, and in rom-disabled extended mode, all of area 0 is external space. in rom-enabled extended mode, the space excluding on-chip rom is external space. when area 0 external space is accessed, the cs0 signal can be output. either basic bus interface or burst rom interface can be selected for area 0. areas 1 to 6: in external extended mode, all of areas 1 to 6 is external space. when area 1 to 5 external space is accessed, the cs1 to cs5 pin signals respectively can be output. only the basic bus interface can be used for areas 1 to 5. area 6 is only for the on-chip usb. for details, see section 14, universal serial bus (usb). area 7: area 7 includes the on-chip ram and internal l/o registers. in external extended mode, the space excluding the reserved area (for details, see section 3.4, memory map in each operating mode) the on-chip ram and internal l/o registers except on-chip rtc, is external space. the on- chip ram is enabled when the rame bit in the system control register (syscr) is set to 1; when section 6 bus controller rev.6.00 jun. 03, 2008 page 130 of 698 rej09b0074-0600 the rame bit is cleared to 0, the on-chip ram is disabled and the corresponding space becomes external space. only the basic bus interface can be used for the area 7. 6.4.4 chip select signals in the h8s/2218 group chip select signals ( cs0 to cs5 ) can be output to areas 0 to 5, the signal being driven low when the corresponding external space area is accessed. figure 6.3 shows an example of csn (n = 0 to 5) output timing. enabling or disabling of the csn signal is performed by setting the data direction register (ddr) for the port corresponding to the particular csn pin. in rom-disabled extended mode, the cs0 pin is placed in the output state after a power-on reset. pins cs1 to cs5 are placed in the input state after a power-on reset, and so the corresponding ddr should be set to 1 when outputting signals cs1 to cs5 . in rom-enabled extended mode, pins cs0 to cs5 are all placed in the input state after a power-on reset, and so the corresponding ddr should be set to 1 when outputting signals cs0 to cs5 . for details, see section 8, i/o ports. bus cycle t 1 t 2 t 3 area n external address a ddress bus csn figure 6.3 csn signal output timing (n = 0 to 5) section 6 bus controller rev.6.00 jun. 03, 2008 page 131 of 698 rej09b0074-0600 6.5 basic timing the cpu is driven by a system clock ( ), denoted by the symbol . the period from one rising edge of to the next is referred to as a "state." the memory cycle or bus cycle consists of one, two, or three states. different methods are us ed to access on-chip memory, on-chip peripheral modules, and the external address space. 6.5.1 on-chip memory (rom, ram) access timing on-chip memory is accessed in one state. the data bus is 16 bits wide, permitting both byte and word transfer instruction. figure 6.4 shows the on-chip memory access cycle. figure 6.5 shows the pin states. t 1 internal address bus bus cycle address read data write data internal read signal internal data bus internal write signal internal data bus read access write access figure 6.4 on-chip memory access cycle section 6 bus controller rev.6.00 jun. 03, 2008 page 132 of 698 rej09b0074-0600 bus cycle t 1 unchanged a ddress bus * as * rd * hwr , lwr * data bus * note : * supported only by the h8s/2218 group. high high high high-impedance state figure 6.5 pin states during on-chip memory access 6.5.2 on-chip peripheral module access timing the on-chip peripheral modules are accessed in tw o states except on-chip usb and rtc. the data bus is either 8 bits or 16 bits wide, depending on the particular internal i/o register being accessed. figure 6.6 shows the access timing for the on-chip peripheral modules. figure 6.7 shows the pin states. t 1 t 2 internal address bus bus cycle address read data write data internal read signal internal data bus internal write signal internal data bus read access write access figure 6.6 on-chip peripheral module access cycle section 6 bus controller rev.6.00 jun. 03, 2008 page 133 of 698 rej09b0074-0600 t 1 t 2 bus cycle unchanged a ddress bus * as * rd * hwr , lwr * data bus * note : * supported only by the h8s/2218 group. high high high high-impedance state figure 6.7 pin states during on-chip peripheral module access 6.5.3 external address space access timing the external address space is accessed with an 8-bit or 16-bit data bus width in a two-state or three-state bus cycle. in three-state access, wait states can be inserted. for further details, refer to section 6.6.3, basic timing. section 6 bus controller rev.6.00 jun. 03, 2008 page 134 of 698 rej09b0074-0600 6.6 basic bus interface the basic bus interface enables direct connection of rom, sram, and so on. 6.6.1 data size and data alignment (supported only by the h8s/2218 group) data sizes for the cpu and other internal bus masters are byte, word, and longword. the bus controller has a data alignment function, and when accessing external space, controls whether the upper data bus (d15 to d8) or lower data bus (d7 to d0) is used according to the bus specifications for the area being accessed (8-bit access space or 16-bit access space) and the data size. 8-bit access space: figure 6.8 illustrates data alignment control for the 8-bit access space. with the 8-bit access space, the upper data bus (d15 to d8) is always used for accesses. the amount of data that can be accessed at one time is one byte: a word transfer instruction is performed as two- byte accesses, and a longword transfer instruction, as four-byte accesses. d15 d8 d7 d0 upper data bus lower data bus byte size word size 1st bus cycle 2nd bus cycle longword size 1st bus cycle 2nd bus cycle 3rd bus cycle 4th bus cycle figure 6.8 access sizes and data a lignment control (8 -bit access space) 16-bit access space: figure 6.9 illustrates data alignment control for the 16-bit access space. with the 16-bit access space, the upper data bus (d15 to d8) and lower data bus (d7 to d0) are used for accesses. the amount of data that can be accessed at one time is one byte or one word, and a longword transfer instruction is executed as two word transfer instructions. in byte access, whether the upper or lower data bus is used is determined by whether the address is even or odd. the upper data bus is used for an even address, and the lower data bus for an odd address. section 6 bus controller rev.6.00 jun. 03, 2008 page 135 of 698 rej09b0074-0600 d15 d8 d7 d0 upper data bus lower data bus byte size word size 1st bus cycle 2nd bus cycle longword size even address byte size odd address figure 6.9 access sizes and data alignment control (16-bit access space) 6.6.2 valid strobes table 6.3 shows the data buses used and valid strobes for the access spaces in the h8s/2218 group. in a read, the rd signal is valid without discrimination between the upper and lower halves of the data bus. in a write, the hwr signal is valid for the upper half of the data bus, and the lwr signal for the lower half. the rd , hwr , and lwr signals are not available in the h8s/2212 group. table 6.3 data buses used and valid strobes area access size read/ write address valid strobe upper data bus (d15 to d8) lower data bus (d7 to d0) byte read ? rd valid invalid 8-bit access space write ? hwr hi-z byte read even rd valid invalid odd invalid valid 16-bit access space write even hwr valid hi-z odd lwr hi-z valid word read ? rd valid valid write ? hwr , lwr notes: hi-z: high impedance. invalid: input state: input value is ignored. section 6 bus controller rev.6.00 jun. 03, 2008 page 136 of 698 rej09b0074-0600 6.6.3 basic timing 8-bit 2-state access space: figure 6.10 shows the bus timing for an 8-bit 2-state access space in the h8s/2218 group. when an 8-bit access space is accessed, the upper half (d15 to d8) of the data bus is used. wait states cannot be inserted. bus cycle t 1 t 2 address bus csn as rd d15 to d8 valid d7 to d0 invalid read hwr lwr (16-bit bus mode) d15 to d8 valid d7 to d0 high impedance high impedance write high note: n = 0 to 5 lwr (8-bit bus mode) figure 6.10 bus timing for 8-bit 2-state access space section 6 bus controller rev.6.00 jun. 03, 2008 page 137 of 698 rej09b0074-0600 8-bit 3-state access space (except area 6): figure 6.11 shows the bus timing for an 8-bit 3- state access space in the h8s/2218 group. when an 8-bit access space is accessed, the upper half (d15 to d8) of the data bus is used. wait states can be inserted. bus cycle t 1 t 2 address bus csn as rd d15 to d8 valid d7 to d0 invalid read hwr lwr (16-bit bus mode) d15 to d8 valid d7 to d0 write high note: n = 0 to 5 t 3 high impedance high impedance lwr (8-bit bus mode) figure 6.11 bus timing for 8-bit 3-state access space (except area 6) section 6 bus controller rev.6.00 jun. 03, 2008 page 138 of 698 rej09b0074-0600 8-bit 3-state access space (area 6 and rtc): figure 6.12 shows the bus timing for area 6 and rtc area (address = h'ffff40 to h'ffff5f). when the areas are accessed, the data bus cannot be used. wait states cannot be inserted. t 1 t 2 as * rd * d15 to d8 * d7 to d0 * hwr * lwr * (16-bit bus mode) lwr * (8-bit bus mode) d15 to d8 * d7 to d0 * write invalid invalid high high impedance high impedance high impedance read t 3 bus cycle address bus * note : * supported only by the h8s/2218 group. figure 6.12 bus timing for area 6 and rtc section 6 bus controller rev.6.00 jun. 03, 2008 page 139 of 698 rej09b0074-0600 16-bit 2-state access space: figures 6.13 to 6.15 show bus timings for a 16-bit 2-state access space in the h8s/2218 group. when a 16-bit access space is accessed, the upper half (d15 to d8) of the data bus is used for the even address, and the lower half (d7 to d0) for the odd address. wait states cannot be inserted. bus cycle t 1 t 2 address bus csn as rd d15 to d8 valid d7 to d0 invalid read hwr lwr d15 to d8 valid d7 to d0 write high note: n = 0 to 5 high impedance figure 6.13 bus timing for 16-bit 2-stat e access space (1) (even address byte access) section 6 bus controller rev.6.00 jun. 03, 2008 page 140 of 698 rej09b0074-0600 bus cycle t 1 t 2 address bus csn as rd d15 to d8 invalid d7 to d0 valid read hwr lwr d15 to d8 d7 to d0 valid write note: n = 0 to 5 high high impedance figure 6.14 bus timing for 16-bit 2-stat e access space (2) (odd address byte access) section 6 bus controller rev.6.00 jun. 03, 2008 page 141 of 698 rej09b0074-0600 bus cycle t 1 t 2 address bus csn as rd d15 to d8 valid d7 to d0 valid read hwr lwr d15 to d8 valid d7 to d0 valid write note: n = 0 to 5 figure 6.15 bus timing for 16-bit 2-state access space (3) (word access) section 6 bus controller rev.6.00 jun. 03, 2008 page 142 of 698 rej09b0074-0600 16-bit 3-state access space: figures 6.16 to 6.18 show bus timings for a 16-bit 3-state access space in the h8s/2218 group. when a 16-bit access space is accessed , the upper half (d15 to d8) of the data bus is used for the even address, and the lower half (d7 to d0) for the odd address. wait states can be inserted. bus cycle t 1 t 2 address bus csn as rd d15 to d8 valid d7 to d0 invalid read hwr lwr d15 to d8 valid d7 to d0 write high note: n = 0 to 5 t 3 high impedance figure 6.16 bus timing for 16-bit 3-state access space (1) (even address byte access) section 6 bus controller rev.6.00 jun. 03, 2008 page 143 of 698 rej09b0074-0600 bus cycle t 1 t 2 address bus csn as rd d15 to d8 invalid d7 to d0 valid read hwr lwr d15 to d8 d7 to d0 valid write high note: n = 0 to 5 t 3 high impedance figure 6.17 bus timing for 16-bit 3-stat e access space (2) (odd address byte access) section 6 bus controller rev.6.00 jun. 03, 2008 page 144 of 698 rej09b0074-0600 bus cycle t 1 t 2 address bus csn as rd d15 to d8 d7 to d0 valid valid read hwr lwr d15 to d8 d7 to d0 valid valid write note: n = 0 to 5 t 3 figure 6.18 bus timing for 16-bit 3-state access space (3) (word access) section 6 bus controller rev.6.00 jun. 03, 2008 page 145 of 698 rej09b0074-0600 6.6.4 wait control when accessing external space, this lsi can extend the bus cycle by inserting one or more wait states (tw). there are two ways of inserting wait states: program wait insertion and pin wait insertion using the wait pin. program wait insertion: from 0 to 3 wait states can be inserted automatically between the t 2 state and t 3 state on an individual area basis in 3-state access space, according to the settings of wcrh and wcrl. pin wait insertion: setting the waite bit in bcrh to 1 enables wait insertion by means of the wait pin in the h8s/2218 group. when external space is accessed in this state, program wait insertion is first carried out according to th e settings in wcrh and wcrl. then, if the wait pin is low at the falling edge of in the last t 2 or t w state, a t w state is inserted. if the wait pin is held low, t w states are inserted until it goes high. section 6 bus controller rev.6.00 jun. 03, 2008 page 146 of 698 rej09b0074-0600 figure 6.19 shows an example of wait state insertion timing. in the h8s/2212 group, the waite bit in bcrh should not be set to 1. by program wait t 1 address bus as rd data bus read data read hwr , lwr write data write note: indicates the timing of wait pin sampling. wait data bus t 2 t w t w t w t 3 by wait pin figure 6.19 example of wait state insertion timing section 6 bus controller rev.6.00 jun. 03, 2008 page 147 of 698 rej09b0074-0600 6.7 burst rom interface with the h8s/2218 group, external space area 0 can be designated as burst rom space, and burst rom interfacing can be performed. the burst rom space interface enables 16-bit configuration rom with burst access capability to be accessed at high speed. area 0 can be designated as burst rom space by means of the brstrm bit in bcrh. consecutive burst accesses of a maximum of 4 words or 8 words can be performed for cpu instruction fetches only. one or two states can be selected for burst access. 6.7.1 basic timing the number of states in the initial cycle (full access) of the burst rom interface is in accordance with the setting of the ast0 bit in astcr. also, when the ast0 bit is set to 1, wait state insertion is possible. one or two states can be selected for the burst cycle, according to the setting of the brsts1 bit in bcrh. wait states cannot be inserted. when area 0 is designated as burst rom space, it becomes 16-bit access space regardless of the setting of the abw0 bit in abwcr. when the brsts0 bit in bcrh is cleared to 0, burst access of up to 4 words is performed; when the brsts0 bit is set to 1, burst access of up to 8 words is performed. the basic access timing for burst rom space is shown in figures 6.20 and 6.21. the timing shown in figure 6.20 is for the case where the ast0 and brsts1 bits are both set to 1, and that in figure 6.21 is for the case where both these bits are cleared to 0. section 6 bus controller rev.6.00 jun. 03, 2008 page 148 of 698 rej09b0074-0600 t 1 a ddress bus cs0 as data bus t 2 t 3 t 1 t 2 t 1 full access t 2 rd burst access only lower address changed read data read data read data figure 6.20 example of burst rom access timing (when ast0 = brsts1 = 1) t 1 cs0 as t 2 t 1 t 1 rd a ddress bus data bus full access burst access only lower address changed read data read data read data figure 6.21 example of burst rom access timing (when ast0 = brsts1 = 0) section 6 bus controller rev.6.00 jun. 03, 2008 page 149 of 698 rej09b0074-0600 6.7.2 wait control as with the basic bus interface, either program wait insertion or pin wait insertion using the wait pin can be used in the initial cycle (full access) of the burst rom interface. see section 6.6.4, wait control. wait states cannot be inserted in a burst cycle. 6.8 idle cycle when the h8s/2218 group accesses external space, it can insert a 1-state idle cycle (t i ) between bus cycles in the following two cases: (1) wh en read accesses between different areas occur consecutively, and (2) when a write cycle occurs im mediately after a read cycle. by inserting an idle cycle it is possible, for example, to avoid data collisions between rom, with a long output floating time, and high-speed memory, i/o interfaces, and so on. consecutive reads betw een different areas: if consecutive reads between different areas occur while the icis1 bit in bcrh is set to 1, an idle cy cle is inserted at the start of the second read cycle. figure 6.22 shows an example of the operation in this case. in this example, bus cycle a is a read cycle from rom with a long output floating time, and bus cycle b is a read cycle from sram, each being located in a different area. in (a), an idle cycle is not inserted, and a collision occurs in cycle b between the read data from rom and that from sram. in (b), an idle cycle is inserted, and a data collision is prevented. section 6 bus controller rev.6.00 jun. 03, 2008 page 150 of 698 rej09b0074-0600 t 1 address bus rd bus cycle a data bus t 2 t 3 t 1 t 2 bus cycle b long output floating time data collision (a) idle cycle not inserted (icis1 = 0) t 1 address bus rd bus cycle a data bus t 2 t 3 t i t 1 bus cycle b (b) idle cycle inserted (initial value icis1 = 1) t 2 cs (area a) cs (area b) cs (area a) cs (area b) figure 6.22 example of idle cycle operation (1) section 6 bus controller rev.6.00 jun. 03, 2008 page 151 of 698 rej09b0074-0600 write after read: if an external write occurs after an external read while the icis0 bit in bcrh is set to 1, an idle cycle is inserted at the start of the write cycle. figure 6.23 shows an example of the operation in this case. in this example, bus cycle a is a read cycle from rom with a long output floating time, and bus cycle b is a cpu write cycle. in (a), an idle cycle is not inserted, and a collision occurs in cycle b between the read data from rom and the cpu write data. in (b), an idle cycle is inserted, and a data collision is prevented. t 1 t 2 t 3 t 1 t 2 t 1 t 2 t 3 t i t 1 t 2 a ddress bus ? bus cycle a data bus bus cycle b long output floating time data collision (a) idle cycle not inserted (icis0 = 0) address bus rd bus cycle a data bus bus cycle b (b) idle cycle inserted (initial value icis0 = 1) cs (area a) cs (area b) rd hwr hwr cs (area a) cs (area b) figure 6.23 example of idle cycle operation (2) relationship between chip select ( cs ) signal and read ( rd ) signal: depending on the system's load conditions, the rd signal may lag behind the cs signal. an example is shown in figure 6.24. in this case, with the setting for no idle cycle insertion (a), there may be a period of overlap between the bus cycle a rd signal and the bus cycle b cs signal. setting idle cycle insertion, as in (b), however, will prevent any overlap between the rd and cs signals. in the initial state after reset release, idle cycle insertion (b) is set. section 6 bus controller rev.6.00 jun. 03, 2008 page 152 of 698 rej09b0074-0600 t 1 t 2 t 3 t 1 t 2 t 1 t 2 t 3 t i t 1 t 2 a ddress bus ? bus cycle a bus cycle b (a) idle cycle not inserted (icis1 = 0) possibility of overlap between cs (area b) and rd address bus bus cycle a bus cycle b (b) idle cycle inserted (initial value icis1 = 1) cs (area a) cs (area b) rd rd cs (area a) cs (area b) figure 6.24 relationship between chip select ( cs ) and read ( rd ) table 6.4 shows pin states in an idle cycle. table 6.4 pin states in idle cycle pins pin state a23 to a0 contents of next bus cycle d15 to d0 high impedance csn high as high rd high hwr high lwr high section 6 bus controller rev.6.00 jun. 03, 2008 page 153 of 698 rej09b0074-0600 6.9 bus release the h8s/2218 group can release the external bus in response to a bus request from an external device. in the external bus released state, the internal bus master continues to operate as long as there is no external access. in external extended mode, the bus can be released to an external device by setting the brle bit in bcrl to 1. driving the breq pin low issues an external bus request to this lsi. when the breq pin is sampled, at the prescribed timing the back pin is driven low, and the address bus, data bus, and bus control signals are placed in the high-impedance state, establishing the external bus- released state. in the external bus released state, an internal bus master can perform accesses using the internal bus. when an internal bus master wants to make an external access, it temporarily defers activation of the bus cycle, and waits for the bus request from the external bus master to be dropped. when the breq pin is driven high, the back pin is driven high at the prescribed timing and the external bus released state is terminated. in the event of simultaneous external bus release request and external access request generation, the order of priority is as follows: (high) external bus release > intern al bus master external access (low) table 6.5 shows pin states in the external bus released state. in the h8s/2212 group, the brle bit in bcrl should not be set to 1. table 6.5 pin states in bus released state pins pin state a23 to a0 high impedance d15 to d0 high impedance csn high impedance as high impedance rd high impedance hwr high impedance lwr high impedance section 6 bus controller rev.6.00 jun. 03, 2008 page 154 of 698 rej09b0074-0600 figure 6.25 shows the timing for transition to the bus-released state. cpu cycle address minimum 1 state t 0 t 1 t 2 hwr , lwr breq back high impedance high impedance as csn high impedance high impedance high impedance rd high impedance data bus a ddress bus [1] [2] [3] [4] [5] [1] low level of breq pin is sampled at rise of t 2 state. [2] back pin is driven low at end of cpu read cycle, releasing bus to external bus master. [3] breq pin state is still sampled in external bus released state. [4] high level of breq pin is sampled. [5] back pin is driven high, ending bus release cycle. cpu cycle external bus released state note : n = 0 to 5 figure 6.25 bus-released state transition timing 6.9.1 bus release usage note when mstpcr is set to h'ffffff and transmitted to sleep mode, the external bus release does not function. to activate the external bus release in sleep mode, do not set mstpcr to h'ffffff. section 6 bus controller rev.6.00 jun. 03, 2008 page 155 of 698 rej09b0074-0600 6.10 bus arbitration this lsi has a bus arbiter that arbitrates bus master operations. there are two bus masters, the cpu and dmac, which perform read/write operations when they have possession of the bus. each bus master requests the bus by means of a bus request signal. the bus arbiter determines priorities at the prescribed timing, and permits use of the bus by means of a bus request acknowledge signal. the selected bus master then takes possession of the bus and begins its operation. 6.10.1 operation the bus arbiter detects the bus masters' bus request signals, and if the bus is requested, sends a bus request acknowledge signal to the bus master making the request. if there are bus requests from more than one bus master, the bus request acknowledge signal is sent to the one with the highest priority. when a bus master receives the bus request acknowledge signal, it takes possession of the bus until that signal is canceled. the order of priority of the bus masters is as follows: (high) dmac > cpu (low) an internal bus access by an internal bus master, and external bus release, can be executed in parallel in the h8s/2218 group. in the event of simultaneous external bus release request, and internal bus master external access request generation, the order of priority is as follows: (high) external bus release > intern al bus master external access (low) the h8s/2212 group does not have the external bus release function. 6.10.2 bus transfer timing even if a bus request is received from a bus master with a higher priority than that of the bus master that has acquired the bus and is currently operating, the bus is not necessarily transferred immediately. there are specific times at which each bus master can relinquish the bus. cpu: the cpu is the lowest-priority bus master, and if a bus request is received from the dmac, the bus arbiter transfers the bus to the bus master th at issued the request. the timing for transfer of the bus is as follows: section 6 bus controller rev.6.00 jun. 03, 2008 page 156 of 698 rej09b0074-0600 ? the bus is transferred at a break between bus cycles. however, if a bus cycle is executed in discrete operations, as in the case of a longword-size access, the bus is not transferred between the operations. ? if the cpu is in sleep mode, it transfers the bus immediately. dmac: the dmac sends the bus arbiter a request for the bus when an activation request is generated. in the case of a usb request in short address mode or normal mode, and in cycle steal mode, the dmac releases the bus after a single transfer. in block transfer mode, it releases the bus after transfer of one block, and in burst mode, after completion of the transfer. 6.10.3 external bus release usage note external bus release can be performed on completion of an external bus cycle in the h8s/2218 group. the cs signal remains low until the end of the external bus cycle. therefore, when external bus release is performed, the cs signal may change from the low level to the high- impedance state. 6.11 resets and the bus controller in a power-on reset, this lsi, including the bus cont roller, enters the reset state at that point, and an executing bus cycle is discontinued. in a manual reset*, the bus controller's registers and internal state are maintained, and an executing external bus cycle is completed. in this case, wait input is ignored and write data is not guaranteed. note: * supported only by the h8s/2218 group. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 157 of 698 rej09b0074-0600 section 7 dma controller (dmac) this lsi has a built-in dma controller (dmac) which can carry out data transfer on up to 4 channels. 7.1 features the features of the dmac are listed below. ? choice of short address mode or full address mode (1) short address mode ? maximum of 4 channels can be used ? choice of dual address mode ? in dual address mode, one of the two addresses, transfer source and transfer destination, is specified as 24 bits and the other as16 bits ? choice of sequential mode, idle mode, or repeat mode for dual address mode (2) full address mode ? maximum of 2 channels can be used ? transfer source and transfer destin ation address specified as 24 bits ? choice of normal mode or block transfer mode ? 16-mbyte address space can be specified directly ? byte or word can be set as the transfer unit ? activation sources: internal interrupt, usb reques t, auto-request (depending on transfer mode) ? 16-bit timer-pulse unit (tpu) compare match/input capture interrupts ? serial communication interface (sci_0) transmission complete interrupt, reception complete interrupt ? a/d conversion end interrupt ? usb request ? auto-request ? module stop mode can be set section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 158 of 698 rej09b0074-0600 a block diagram of the dmac is shown in figure 7.1. internal address bus addres buffer processor internal interrupts tgi0a tgi1a tgi2a txi0 rxi0 adi usb request signals dreq0 dreq1 interrupt signals dend0a dend0b dend1a dend1b control logic dmacr1b dmacr1a dmacr0b dmacr0a dmatcr dmabcr data buffer internal address bus mar0a ioar0a etcr0a mar0b ioar0b etcr0b mar1a ioar1a etcr1a mar1b ioar1b etcr1b legend: dmatcr: dmabcr: dmacr: mar: ioar: etcr: dma terminal control register * dma band control register (for all channels) dma control register memory address register i/o address register executive transfer counter register note: * reserved register channel 0 module data bus channel 0a channel 0b channel 1a channel 1b channel 1 figure 7.1 block diagram of dmac section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 159 of 698 rej09b0074-0600 7.2 register configuration the dmac registers are listed below. ? memory address register 0a (mar0a) ? i/o address register 0a (ioar0a) ? transfer count register 0a (etcr0a) ? memory address register 0b (mar0b) ? i/o address register 0b (ioar0b) ? transfer count register 0b (etcr0b) ? memory address register 1a (mar1a) ? i/o address register 1a (ioar1a) ? transfer count register 1a (etcr1a) ? memory address register 1b (mar1b) ? i/o address register 1b (ioar1b) ? transfer count register 1b (etcr1b) ? dma control register 0a (dmacr0a) ? dma control register 0b (dmacr0b) ? dma control register 1a (dmacr1a) ? dma control register 1b (dmacr1b) ? dma band control register (dmabcr) the dmac register functions differs depending on the address modes: short address mode and full address mode. the dmac register functions are described in each address mode. short address mode or full address mode can be selected for channels 1 and 0 independently by means of bits fae1 and fae0. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 160 of 698 rej09b0074-0600 table 7.1 short address mode and full address mode (for 1 channel: example of channel 0) fae0 description 0 mar0a specifies transfer source/transfer destination address specifies transfer destination/transfer source address specifies number of transfers specifies transfer size, mode, activation source, etc. short address mode specified (channels a and b operate independently) specifies transfer source/transfer destination address specifies transfer destination/transfer source address specifies number of transfers specifies transfer size, mode, activation source, etc. channel 0a channel 0b ioar0a etcr0a dmacr0a mar0b ioar0b etcr0b dmacr0b 1 mar0a ioar0a etcr0a dmacr0a mar0b ioar0b etcr0b dmacr0b specifies transfer source address specifies transfer destination address not used not used specifies number of transfers specifies number of transfers (used in block transfer mode only) specifies transfer size, mode, activation source, etc. full address mode specified (channels a and b operate combination) channel 0 section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 161 of 698 rej09b0074-0600 7.3 register descriptions 7.3.1 memory address registers (mar) ? short address mode mar is a 32-bit readable/writable register th at specifies the transfer source address or destination address. the upper 8 bits of mar are reserved: they are always read as 0, and cannot be modified. whether mar functions as the source address register or as the destination address register can be selected by means of the dtdir bit in dmacr. mar is incremented or decremented each time a byte or word transfer is executed, so that the address specified by mar is constantly updated. for details, see section 7.3.4, dma control register (dmacr). mar is not initialized by a reset or in standby mode. ? full address mode mar is a 32-bit readable/writable register; ma ra functions as the transfer source address register, and marb as the destination address register. mar is composed of two 16-bit registers, marh and marl. the upper 8 bits of marh are reserved: they are always read as 0, and cannot be modified. mar is incremented or decremented each time a byte or word transfer is executed, so that the source or destination memory address can be updated automatically. for details, see section 7.3.4, dma control register (dmacr). mar is not initialized by a reset or in standby mode. 7.3.2 i/o address register (ioar) ? short address mode ioar is a 16-bit readable/writable register that specifies the lower 16 bits of the transfer source address or destination address. the upper 8 bits of the transfer address are automatically set to h'ff. whether ioar functions as the source address register or as the destination address register can be selected by means of the dtdir bit in dmacr. ioar is not incremented or decremented each time a transfer is executed, so that the address specified by ioar is fixed. ioar is not initialized by a reset or in standby mode. ? full address mode: ioar is not used in full address mode transfer. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 162 of 698 rej09b0074-0600 7.3.3 execute transfer count register (etcr) ? short address mode etcr is a 16-bit readable/writable register that specifies the number of transfers. the setting of this register is different for sequential mode and idle mode on the one hand, and for repeat mode on the other. etcr is not initialized by a reset or in standby mode. ? sequential mode and idle mode in sequential mode and idle mode, etcr functions as a 16-bit transfer counter (with a count range of 1 to 65,536). etcr is decremented by 1 each time a transfer is performed, and when the count reaches h'0000, the dte bit in dmabcr is cleared, and transfer ends. ? repeat mode in repeat mode, etcr functions as an 8-bit tr ansfer counter etcrl (with a count range of 1 to 256) and transfer number storage register etcrh. etcrl is decremented by 1 each time a transfer is performed, and when the count reaches h'00, etcrl is loaded with the value in etcrh. at this point, mar is automatically restored to the value it had when the count was started. the dte bit in dmabcr is not cleared, and so transfers can be performed repeatedly until the dte bit is cleared by the user. ? full address mode etcr is a 16-bit readable/writable register that specifies the number of transfers. the function of this register is different in normal mode and in block transfer mode. etcr is not initialized by a reset or in standby mode. ? normal mode (a) etcra in normal mode, etcra functions as a 16-bit transfer counter. etcra is decremented by 1 each time a transfer is performed, and transfer ends when the count reaches h'0000. (b) etcrb etcrb is not used in normal mode. ? block transfer mode (a) etcra in block transfer mode, etcral functions as an 8-bit block size counter and etcrah holds the block size. etcral is decremented each time a 1-byte or 1-word transfer is performed, and when the count reaches h'00, etcral is loaded with the value in etcrah. so by setting the block size in etcrah and etcral, it is possible to repeatedly transfer blocks consisting of any desired number of bytes or words. (b) etcrb etcrb functions in block transfer mode, as a 16-bit block transfer counter. etcrb is decremented by 1 each time a block is transferred, and transfer ends when the count reaches h'0000. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 163 of 698 rej09b0074-0600 7.3.4 dma control register (dmacr) dmacr controls the operation of each dmac channel. ? short address mode (common to dmacra and dmacrb) bit bit name initial value r/w description 7 dtsz 0 r/w data transfer size selects the size of data to be transferred at one time. 0: byte-size transfer 1: word-size transfer 6 dtid 0 r/w data transfer increment/decrement selects incrementing or decrementing of mar every data transfer in sequential mode or repeat mode. in idle mode, mar is neither incremented nor decremented. 0: mar is incremented after a data transfer ? when dtsz = 0, mar is incremented by 1 after a transfer ? when dtsz = 1, mar is incremented by 2 after a transfer 1: mar is decremented after a data transfer ? when dtsz = 0, mar is decremented by 1 after a transfer ? when dtsz = 1, mar is decremented by 2 after a transfer section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 164 of 698 rej09b0074-0600 bit bit name initial value r/w description 5 rpe 0 r/w repeat enable used in combination with the dtie bit in dmabcr to select the mode (sequential, idle, or repeat) in which transfer is to be performed. rpe dtie 0 0: transfer in sequential mode (no transfer end interrupt) 0 1: transfer in sequential mode (with transfer end interrupt) 1 0: transfer in repeat mode (no transfer end interrupt) 1 1: transfer in idle mode (with transfer end interrupt) note: for details of operation in sequential, idle, and repeat mode, see section 7.4.2, sequential mode, section 7.4.3, idle mode, and section 7.4.4, repeat mode. 4 dtdir 0 r/w data transfer direction specifies the data transfer direction (source or destination). 0: transfer with mar as source address and ioar as destination address 1: transfer with ioar as source address and mar as destination address section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 165 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 2 1 0 dtf3 dtf2 dtf1 dtf0 0 0 0 0 r/w r/w r/w r/w data transfer factor these bits select the data transfer factor (activation source). 0000: ? 0001: activated by a/d conversion end interrupt 0010: ? 0011: ? 0100: activated by sci channel 0 transmission complete interrupt 0101: activated by sci channel 0 reception complete interrupt 0110: ? 0111: ? 1000: activated by tpu channel 0 compare match/input capture a interrupt 1001: activated by tpu channel 1 compare match/input capture a interrupt 1010: activated by tpu channel 2 compare match/input capture a interrupt 1011: ? 1100: ? 1101: ? 1110: ? 1111: ? the same factor can be selected for more than one channel. in this case, activation starts with the highest-priority channel according to the relative channel priorities. for relative channel priorities, see section 7.4.10, dmac multi-channel operation. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 166 of 698 rej09b0074-0600 ? full address mode (dmacra) bit bit name initial value r/w description 15 dtsz 0 r/w data transfer size selects the size of data to be transferred at one time. 0: byte-size transfer 1: word-size transfer 14 13 said saide 0 0 r/w r/w source address increment/decrement source address increment/decrement enable these bits specify whether source address register mara is to be incremented, decremented, or left unchanged, when data transfer is performed. 00: mara is fixed 01: mara is incremented after a data transfer ? when dtsz = 0, mara is incremented by 1 after a transfer ? when dtsz = 1, mara is incremented by 2 after a transfer 10: mara is fixed 11: mara is decremented after a data transfer ? when dtsz = 0, mara is decremented by 1 after a transfer ? when dtsz = 1, mara is decremented by 2 after a transfer 12 11 blkdir blke 0 0 r/w r/w block direction block enable these bits specify whether normal mode or block transfer mode is to be used. if block transfer mode is specified, the blkdir bit specifies whether the source side or the destination side is to be the block area. 00: transfer in normal mode 01: transfer in block transfer mode, destination side is block area 10: transfer in normal mode 11: transfer in block transfer mode, source side is block area for operation in normal mode and block transfer mode, see section 7.4, operation. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 167 of 698 rej09b0074-0600 bit bit name initial value r/w description 10 to 8 ? all 0 r/w reserved although these bits are readable/writable, only 0 should be written to. ? full address mode (dmacrb) bit bit name initial value r/w description 7 ? 0 r/w reserved although this bit is readable/writable, only 0 should be written to. 6 5 daid daide 0 0 r/w r/w destination address increment/decrement destination address increment/decrement enable these bits specify whether destination address register marb is to be incremented, decremented, or left unchanged, when data transfer is performed. 00: marb is fixed 01: marb is incremented after a data transfer ? when dtsz = 0, marb is incremented by 1 after a transfer ? when dtsz = 1, marb is incremented by 2 after a transfer 10: marb is fixed 11: marb is decremented after a data transfer ? when dtsz = 0, marb is decremented by 1 after a transfer ? when dtsz = 1, marb is decremented by 2 after a transfer 4 ? 0 r/w reserved although this bit is readable/writable, only 0 should be written to. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 168 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 2 1 0 dtf3 dtf2 dtf1 dtf0 0 0 0 0 r/w r/w r/w r/w data transfer factor these bits select the data transfer factor (activation source). in normal mode: 0000: ? 0001: ? 0010: ? 0011: activated by dreq signal's low level input from usb (usb request) 010 : ? 0110: auto-request (cycle steal) 0111: auto-request (burst) 1 : ? in block transfer mode: 0000: ? 0001: activated by a/d conversion end interrupt 0010: ? 0011: ? 0100: activated by sci channel 0 transmission complete interrupt 0101: activated by sci channel 0 reception complete interrupt 0110: ? 0111: ? 1000: activated by tpu channel 0 compare match/input capture a interrupt 1001: activated by tpu channel 1 compare match/input capture a interrupt 1010: activated by tpu channel 2 compare match/input capture a interrupt 1011: ? 11 : ? the same factor can be selected for more than one channel. in this case, activation starts with the highest-priority channel according to the relative channel priorities. for relative channel priorities, see section 7.4.10, dmac multi-channel operation. legend: : don't care section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 169 of 698 rej09b0074-0600 7.3.5 dma band control register (dmabcr) dmabcr controls the operation of each dmac channel. ? short address mode bit bit name initial value r/w description 15 fae1 0 r/w full address enable 1 specifies whether channel 1 is to be used in short address mode or full address mode. in short address mode, channels 1a and 1b are used as independent channels. 0: short address mode 1: full address mode 14 fae0 0 r/w full address enable 0 specifies whether channel 0 is to be used in short address mode or full address mode. in short address mode, channels 0a and 0b are used as independent channels. 0: short address mode 1: full address mode 13, 12 ? ? r/w reserved the write value should always be 0. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 170 of 698 rej09b0074-0600 bit bit name initial value r/w description 11 10 9 8 dta1b dta1a dta0b dta0a 0 0 0 0 r/w r/w r/w r/w data transfer acknowledge these bits enable or disable clearing, when dma transfer is performed, of the internal interrupt source selected by the data transfer factor setting. when dte = 1 and dta = 1, the internal interrupt source selected by the data transfer factor setting is cleared automatically by dma transfer. when dte = 1 and dta = 1, the internal interrupt source selected by the data transfer factor setting does not issue an interrupt request to the cpu. when dte = 1 and dta = 0, the internal interrupt source selected by the data transfer factor setting is not cleared when a transfer is performed, and can issue an interrupt request to the cpu in parallel. in this case, the interrupt source should be cleared by the cpu. when dte = 0, the internal interrupt source selected by the data transfer factor setting issues an interrupt request to the cpu regardless of the dta bit setting. 0: clearing of selected internal interrupt source at time of dma transfer is disabled 1: clearing of selected internal interrupt source at time of dma transfer is enabled section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 171 of 698 rej09b0074-0600 bit bit name initial value r/w description 7 6 5 4 dte1b dte1a dte0b dte0a 0 0 0 0 r/w r/w r/w r/w data transfer enable when dte = 0, data transfer is disabled and the activation source selected by the data transfer factor setting is ignored. if the activation source is an internal interrupt, an interrupt request is issued to the cpu. if the dtie bit is set to 1when dte = 0, the dmac regards this as indicating the end of a transfer, and issues a transfer end interrupt request to the cpu. the conditions for the dte bit being cleared to 0 are as follows: ? when initialization is performed ? when the specified number of transfers have been completed in a transfer mode other than repeat mode ? when 0 is written to the dte bit to forcibly abort the transfer, or for a similar reason when dte = 1, data transfer is enabled and the dmac waits for a request by the activation source selected by the data transfer factor setting. when a request is issued by the activation source, dma transfer is executed. the condition for the dte bit being set to 1 is as follows: ? when 1 is written to the dte bit after the dte bit is read as 0 0: data transfer disabled 1: data transfer enabled 3 2 1 0 dtie1b dtie1a dtie0b dtie0a 0 0 0 0 r/w r/w r/w r/w data transfer end interrupt enable these bits enable or disable an interrupt to the cpu when transfer ends. if the dtie bit is set to 1 when dte = 0, the dmac regards this as indicating the end of a transfer, and issues a transfer end interrupt request to the cpu. a transfer end interrupt can be canceled either by clearing the dtie bit to 0 in the interrupt handling routine, or by performing processing to continue transfer by setting the transfer counter and address register again, and then setting the dte bit to 1. 0: transfer end interrupt disabled 1: transfer end interrupt enabled section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 172 of 698 rej09b0074-0600 ? full address mode bit bit name initial value r/w description 15 fae1 0 r/w full address enable 1 specifies whether channel 1 is to be used in short address mode or full address mode. in full address mode, channels 1a and 1b are used together as a single channel. 0: short address mode 1: full address mode 14 fae0 0 r/w full address enable 0 specifies whether channel 0 is to be used in short address mode or full address mode. in full address mode, channels 0a and 0b are used together as a single channel. 0: short address mode 1: full address mode 13,12 ? all 0 r/w reserved although these bits are readable/writable, only 0 should be written to. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 173 of 698 rej09b0074-0600 bit bit name initial value r/w description data transfer acknowledge enables or disables clearing, when dma transfer is performed, of the internal interrupt source selected by the data transfer factor setting. when dte = 1 and dta = 1, the internal interrupt source selected by the data transfer factor setting is cleared automatically by dma transfer. when dte = 1 and dta = 1, the internal interrupt source selected by the data transfer factor setting does not issue an interrupt request to the cpu. when dte = 1 and dta = 0, the internal interrupt source selected by the data transfer factor setting is not cleared when a transfer is performed, and can issue an interrupt request to the cpu in parallel. in this case, the interrupt source should be cleared by the cpu transfer. when dte = 0, the internal interrupt source selected by the data transfer factor setting issues an interrupt request to the cpu regardless of the dta bit setting. the state of the dtme bit does not affect the above operations. 11 dta1 0 r/w data transfer acknowledge 1 enables or disables clearing, when dma transfer is performed, of the internal interrupt source selected by the channel 1 data transfer factor setting. 0: clearing of selected internal interrupt source at time of dma transfer is disabled 1: clearing of selected internal interrupt source at time of dma transfer is enabled 10 ? 0 r/w reserved although this bit is readable/writable, only 0 should be written to. 9 dta0 0 r/w data transfer acknowledge 0 enables or disables clearing, when dma transfer is performed, of the internal interrupt source selected by the channel 0 data transfer factor setting. 0: clearing of selected internal interrupt source at time of dma transfer is disabled 1: clearing of selected internal interrupt source at time of dma transfer is enabled section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 174 of 698 rej09b0074-0600 bit bit name initial value r/w description 8 ? 0 r/w reserved although this bit is readable/writable, only 0 should be written to. data transfer master enable together with the dte bit, this bit controls enabling or disabling of data transfer on the relevant channel. when both the dtme bit and the dte bit are set to 1, transfer is enabled for the channel. if the relevant channel is in the middle of a burst mode transfer when an nmi interrupt is generated, the dtme bit is cleared, the transfer is interrupted, and bus mastership passes to the cpu. when the dtme bit is subsequently set to 1 again, the interrupted transfer is resumed. in block transfer mode, however, the dtme bit is not cleared by an nmi interrupt, and transfer is not interrupted. the conditions for the dtme bit being cleared to 0 are as follows: ? when initialization is performed ? when nmi is input in burst mode ? when 0 is written to the dtme bit the condition for dtme being set to 1 is as follows: ? when 1 is written to dtme after dtme is read as 0 7 dtme1 0 r/w data transfer master enable 1 enables or disables data transfer on channel 1 0: data transfer disabled. in burst mode, cleared to 0 by an nmi interrupt 1: data transfer enabled section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 175 of 698 rej09b0074-0600 bit bit name initial value r/w description data transfer enable when dte = 0, data transfer is disabled and the activation source selected by the data transfer factor setting is ignored. if the activation source is an internal interrupt, an interrupt request is issued to the cpu. if the dtie bit is set to 1 when dte = 0, the dmac regards this as indicating the end of a transfer, and issues a transfer end interrupt request to the cpu. the conditions for the dte bit being cleared to 0 are as follows: ? when initialization is performed ? when the specified number of transfers have been completed ? when 0 is written to the dte bit to forcibly abort the transfer, or for a similar reason when dte = 1 and dtme = 1, data transfer is enabled and the dmac waits for a request by the activation source selected by the data transfer factor setting. when a request is issued by the activation source, dma transfer is executed. the condition for the dte bit being set to 1 is as follows: ? when 1 is written to the dte bit after the dte bit is read as 0 6 dte1 0 r/w data transfer enable 1 enables or disables data transfer on channel 1. 0: data transfer disabled 1: data transfer enabled 5 dtme0 0 r/w data transfer master enable 0 enables or disables data transfer on channel 0. 0: data transfer disabled. in burst mode, cleared to 0 by an nmi interrupt 1: data transfer enabled 4 dte0 0 r/w data transfer enable 0 enables or disables data transfer on channel 0. 0: data transfer disabled 1: data transfer enabled section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 176 of 698 rej09b0074-0600 bit bit name initial value r/w description data transfer interrupt enable b enables or disables an interrupt to the cpu when transfer is interrupted. if the dtieb bit is set to 1 when dtme = 0, the dmac regards this as indicating a break in the transfer, and issues a transfer break interrupt request to the cpu. a transfer break interrupt can be canceled either by clearing the dtieb bit to 0 in the interrupt handling routine, or by performing processing to continue transfer by setting the dtme bit to 1. 3 dtie1b 0 r/w data transfer interrupt enable 1b enables or disables the channel 1 transfer break interrupt. 0 : transfer break interrupt disabled 1: transfer break interrupt enabled data transfer end interrupt enable a enables or disables an interrupt to the cpu when transfer ends. if the dtiea bit is set to 1 when dte = 0, the dmac regards this as indicating the end of a transfer, and issues a transfer end interrupt request to the cpu. a transfer end interrupt can be canceled either by clearing the dtiea bit to 0 in the interrupt handling routine, or by performing processing to continue transfer by setting the dte bit to 1. 2 dtie1a 0 r/w data transfer end interrupt enable 1a enables or disables the channel 1 transfer end interrupt. 0: transfer end interrupt disabled 1: transfer end interrupt enabled 1 dtie0b 0 r/w data transfer interrupt enable 0b enables or disables the channel 0 transfer break interrupt. 0 : transfer break interrupt disabled 1: transfer break interrupt enabled 0 dtie0a 0 r/w data transfer end interrupt enable 0a enables or disables the channel 0 transfer end interrupt. 0: transfer end interrupt disabled 1: transfer end interrupt enabled section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 177 of 698 rej09b0074-0600 7.4 operation 7.4.1 transfer modes table 7.2 lists the dmac modes. table 7.2 dmac transfer modes transfer mode transfer source remarks short address mode dual address mode (1) sequential mode (2) idle mode (3) repeat mode ? tpu channel 0 to 2 compare match/input capture a interrupt ? sci transmission complete interrupt ? sci reception complete interrupt ? a/d conversion end interrupt ? up to 4 channels can operate independently full address mode (4) normal mode ? usb request ? auto-request ? max. 2-channel operation, combining channels a and b (5) block transfer mode ? tpu channel 0 to 2 compare match/input capture a interrupt ? sci transmission complete interrupt ? sci reception complete interrupt ? a/d conversion end interrupt ? with auto-request, burst mode transfer or cycle steal transfer can be selected section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 178 of 698 rej09b0074-0600 7.4.2 sequential mode sequential mode can be specified by clearing the rpe bit in dmacr to 0. in sequential mode, mar is updated after each byte or word transfer in response to a single transfer request, and this is executed the number of times specified in etcr. one address is specified by mar, and the other by ioar. the transfer direction can be specified by the dtdir bit in dmacr. table 7.3 summarizes register functions in sequential mode. table 7.3 register functions in sequential mode function register dtdir = 0 dtdir = 1 initial setting operation 23 0 mar source address register destination address register start address of transfer destination or transfer source incremented/ decremented every transfer 23 15 0 ioar h'ff destination address register source address register start address of transfer source or transfer destination fixed 0 15 etcr transfer counter number of transfers decremented every transfer, transfer ends when count reaches h ' 0000 mar specifies the start address of the transfer so urce or transfer destination as 24 bits. mar is incremented or decremented by 1 or 2 each time a byte or word is transferred. ioar specifies the lower 16 bits of the other address. the 8 bits above ioar have a value of h'ff. figure 7.2 illustrates operation in sequential mode. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 179 of 698 rej09b0074-0600 a ddress t a ddress b transfer ioar 1 byte or word transfer performed in response to 1 transfer request notes: address address where: t = l b = l + (?1) dtid (2 dtsz (n?1)) l = value set in mar n = value set in etcr figure 7.2 operation in sequential mode the number of transfers is specified as 16 bits in etcr. etcr is decremented by 1 each time a transfer is executed, and when its value reaches h' 0000, the dte bit is cleared and transfer ends. if the dtie bit is set to 1 at this time, an interrupt request is sent to the cpu. the maximum number of transfers, when h'0000 is set in etcr, is 65,536. transfer requests (activation sources) consist of a/d conversion end interrupt, sci transmission complete and reception complete interrupts, and tpu channel 0 to 2 compare match/input capture a interrupts. figure 7.3 shows an example of the setting procedure for sequential mode. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 180 of 698 rej09b0074-0600 sequential mode setting set dmabcrh set transfer source and transfer destination addresses set number of transfers set dmacr read dmabcrl set dmabcrl sequential mode [1] [2] [3] [4] [5] [6] [1] set each bit in dmabcrh. clear the fae bit to 0 to select short address mode. specify enabling or disabling of internal interrupt clearing with the dta bit. [2] set the transfer source address and transfer destination address in mar and ioar. [3] set the number of transfers in etcr. [4] set each bit in dmacr. set the transfer data size with the dtsz bit. specify whether mar is to be incremented or decremented with the dtid bit. clear the rpe bit to 0 to select sequential mode. specify the transfer direction with the dtdir bit. select the activation source with bits dtf3 to dtf0. [5] read the dte bit in dmabcrl as 0. [6] set each bit in dmabcrl. specify enabling or disabling of transfer andinterrupts with the dtie bit. set the dte bit to 1 to enable transfer. figure 7.3 example of sequential mode setting procedure section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 181 of 698 rej09b0074-0600 7.4.3 idle mode idle mode can be specified by setting the rpe bit and dtie bit in dmacr to 1. in idle mode, one byte or word is transferred in response to a single transfer request, and this is executed the number of times specified in etcr. one address is specified by mar, and the other by ioar. the transfer direction can be specified by the dtdi r bit in dmacr. table 7.4 summarizes register functions in idle mode. table 7.4 register functions in idle mode function register dtdir = 0 dtdir = 1 initial setting operation 23 0 mar source address register destination address register start address of transfer destination or transfer source fixed 23 15 0 ioar h'ff destination address register source address register start address of transfer source or transfer destination fixed 0 15 etcr transfer counter number of transfers decremented every transfer, transfer ends when count reaches h ' 0000 mar specifies the start address of the transfer so urce or transfer destination as 24 bits. mar is neither incremented nor decremented each time a byte or word is transferred. ioar specifies the lower 16 bits of the other address. the 8 bits above ioar have a value of h'ff. figure 7.4 illustrates operation in idle mode. transfer ioar 1 byte or word transfer performed in response to 1 transfer request mar figure 7.4 operation in idle mode the number of transfers is specified as 16 bits in etcr. etcr is decremented by 1 each time a transfer is executed, and when its value reaches h' 0000, the dte bit is cleared and transfer ends. if the dtie bit is set to 1 at this time, an interrupt request is sent to the cpu. the maximum number of transfers, when h'0000 is set in etcr, is 65,536. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 182 of 698 rej09b0074-0600 transfer requests (activation sources) consist of a/d conversion end interrupt, sci transmission complete and reception complete interrupts, and tpu channel 0 to 2 compare match/input capture a interrupts. figure 7.5 shows an example of the setting procedure for idle mode. idle mode setting set dmabcrh set transfer source and transfer destination addresses set number of transfers set dmacr read dmabcrl set dmabcrl idle mode [1] [2] [3] [4] [5] [6] [1] set ech bit in dmabcrh. clear the fae bit to 0 to select short address mode. specify enabling or disabling of internal interrupt clearing with the dta bit. [2] set the transfer source address and transfer destinatiln address in mar and ioar. [3] set the number of transfers in etcr. [4] set each bit in dmacr. set the transfer data size with the dtsz bit. specify whether mar is to be incremented or decremented with the dtid bit. set the rpe bit to 1. specify the transfer direction with the dtdir bit. select the activation source with bits dtf3 to dtf0. [5] read the dte bit in dmabcrl as 0. [6] set each bit in dmabcrl. set the dtie bit to 1. set the dte bit to 1 to enable transfer. figure 7.5 example of idle mode setting procedure section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 183 of 698 rej09b0074-0600 7.4.4 repeat mode repeat mode can be specified by setting the rpe b it in dmacr to 1, and clearing the dtie bit to 0. in repeat mode, mar is updated after each byte or word transfer in response to a single transfer request, and this is executed the number of times specified in etcr. on completion of the specified number of transfers, mar and etcrl are automatically restored to their original settings and operation continues. one address is specified by mar, and the other by ioar. the transfer direction can be specified by the dtdi r bit in dmacr. table 7.5 summarizes register functions in repeat mode. table 7.5 register functions in repeat mode function register dtdir = 0 dtdir = 1 initial setting operation 23 0 mar source address register destination address register start address of transfer destination or transfer source incremented/decrem ented every transfer. initial setting is restored when value reaches h ' 0000 23 15 0 ioar h'ff destination address register source address register start address of transfer source or transfer destination fixed 0 etcrh 7 holds number of transfers number of transfers fixed 0 etcrl 7 transfer counter number of transfers decremented every transfer. loaded with etcrh value when count reaches h ' 00 mar specifies the start address of the transfer so urce or transfer destination as 24 bits. mar is incremented or decremented by 1 or 2 each time a byte or word is transferred. ioar specifies the lower 16 bits of the other address. the 8 bits above ioar have a value of h'ff. the number of transfers is specified as 8 bits by etcrh and etcrl. the maximum number of transfers, when h'00 is set in both etcrh and etcrl, is 256. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 184 of 698 rej09b0074-0600 in repeat mode, etcrl functions as the transfer counter, and etcrh is used to hold the number of transfers. etcrl is decremented by 1 each time a transfer is executed, and when its value reaches h'00, it is loaded with the value in etcrh. at the same time, the value set in mar is restored in accordance with the values of th e dtsz and dtid bits in dmacr. the mar restoration operation is as shown below. mar = mar ? (?1) dtid 2 dtsz etcrh the same value should be set in etcrh and etcrl. in repeat mode, operation continues until the dte bit is cleared. to end the transfer operation, therefore, you should clear the dte bit to 0. a transfer end interrupt request is not sent to the cpu. by setting the dte bit to 1 again after it has been cleared, the operation can be restarted from the transfer after that terminated when the dte bit was cleared. figure 7.6 illustrates operation in repeat mode. a ddress t a ddress b transfer ioar 1 byte or word transfer performed in rewponse to 1 transfer request notes: address address where: t = l b = l + (?1) dtid (2 dtsz (n?1)) l = value set in mar n = value set in etcr figure 7.6 operation in repeat mode section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 185 of 698 rej09b0074-0600 transfer requests (activation sources) consist of a/d conversion end interrupt, sci transmission complete and reception complete interrupts, and tpu channel 0 to 2 compare match/input capture a interrupts. figure 7.7 shows an example of the setting procedure for repeat mode. repeat mode setting read dmabcrh set transfer source and transfer destination addresses set number of transfers set dmacr read dmabcrl set dmabcrl repeat mode [1] [2] [3] [4] [5] [6] [1] set each bit in dmabcrh. clear the fae bit to 0 to select short address mode. specify enabling or disabling of internal interrupt clearing with the dta bit. [2] set the transfer source address and transfer destination address in mar and ioar. [3] set the number of transfers in etcr. [4] set each bit in dmacr. set the transfer data size with the dtsz bit. specify whether mar is to be incremented or decremented with the dtid bit. set the rpe bit to 1. specify the transfer direction with the dtdir bit. select the activation source with bits dtf3 to dtf0. [5] read the dte bit in dmabcrl as 0. [6] set each bit in dmabcrl. clear the dtie bit to 1. set the dte bit to 1 to enable transfer. figure 7.7 example of repeat mode setting procedure section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 186 of 698 rej09b0074-0600 7.4.5 normal mode in normal mode, transfer is performed with channels a and b used in combination. normal mode can be specified by setting the fae bit in dma bcr to 1 and clearing the blke bit in dmacra to 0. in normal mode, mar is updated after each byte or word transfer in response to a single transfer request, and this is executed the number of times specified in etcra. the transfer source is specified by mara, and the transfer destination by marb. table 7.6 summarizes register functions in normal mode. table 7.6 register functions in normal mode register function initial setting operation 23 0 mara source address register start address of transfer source incremented/decremented every transfer, or fixed 23 0 marb destination address register start address of transfer destination incremented/decremented every transfer, or fixed 15 0 etcra transfer counter number of transfers decremented every transfer; transfer ends when count reaches h ' 0000 mara and marb specify the start addresses of the transfer source and transfer destination, respectively, as 24 bits. mar can be incremented or decremented by 1 or 2 each time a byte or word is transferred, or can be fixed. incrementi ng, decrementing, or holding a fixed value can be set separately for mara and marb. the number of transfers is specified by etcra as 16 bits. etcra is decremented each time a transfer is performed, and when its value reaches h'0000 the dte bit is cleared and transfer ends. if the dtie bit is set to 1 at this time, an interrupt request is sent to the cpu. the maximum number of transfers, when h'0000 is set in etcra, is 65,536. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 187 of 698 rej09b0074-0600 figure 7.8 illustrates operation in normal mode. a ddress t a a ddress b a transfer address t b notes: address t a = l a address t b = l b address b a = l a + saide (?1) said (2 dtsz (n?1)) address b b = l b + daide (?1) daid (2 dtsz (n?1)) l a = value set in mara l b = value set in marb n = value set in etcra address b b figure 7.8 operation in normal mode transfer requests (activation sources) are external requests and auto-requests. with auto-request, the dmac is only activated by register setting, and the specified number of transfers are performed automatically. with auto-request, cycle steal mode or burst mode can be selected. in cycle steal mode, the bus is released to another bus master each time a transfer is performed. in burst mode, the bus is held continuously until tr ansfer ends. for setting details, see section 7.3.4, dma controller register (dmacr). section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 188 of 698 rej09b0074-0600 figure 7.9 shows an example of the setting procedure for normal mode. normal mode setting set dmabcrh set transfer source and transfer destination addresses set number of transfers set dmacr read dmabcrl set dmabcrl normal mode [1] [2] [3] [4] [5] [6] [1] set each bit in dmabcrh. set the fae bit to 1 to select full address mode. specify enabling or disabling of internal interrupt clearing with the dta bit. [2] set the transfer source address in mara, and the transfer destination address in marb. [3] set the number of transfers in etcra. [4] set each bit in dmacra and dmacrb. set the transfer data size with the dtsz bit. specify whether mara is to be incremented, decremented, or fixed, with the said and saide bits. clear the blke bit to 0 to select normal mode. specify whether marb is to be incremented, decremented, or fixed, with the daid and daide bits. select the activation source with bits dtf3 to dtf0. [5] read the dte = 0 and dtme = 0 in dmabcrl. [6] set each bit in dmabcrl. specify enabling or desabling of transfer end interrupts with the dtie bit. set both the dtme bit and the dte bit to 1 to enable transfer. figure 7.9 example of normal mode setting procedure section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 189 of 698 rej09b0074-0600 7.4.6 block transfer mode in block transfer mode, transfer is performed with channels a and b used in combination. block transfer mode can be specified by setting the fae bit in dmabcr and the blke bit in dmacra to 1. in block transfer mode, a transfer of the specified block size is carried out in response to a single transfer request, and this is executed the specified number of times. the transfer source is specified by mara, and the tran sfer destination by marb. either the transfer source or the transfer destination can be selected as a block area (an area composed of a number of bytes or words). table 7.7 summarizes register functions in block transfer mode. table 7.7 register functions in block transfer mode register function initial setting operation 23 0 mara source address register start address of transfer source incremented/decremented every transfer, or fixed 23 0 marb description address register start address of transfer destination incremented/decremented every transfer, or fixed 0 etcrah 7 holds block size block size fixed 0 etcral 7 block size counter block size decremented every transfer; etcrh value copied when count reaches h ' 00 0 15 etcrb block transfer counter number of block transfers decremented every block transfer; transfer ends when count reaches h'0000 mara and marb specify the start addresses of the transfer source and transfer destination, respectively, as 24 bits. mar can be incremented or decremented by 1 or 2 each time a byte or word is transferred, or can be fixed. incrementi ng, decrementing, or holding a fixed value can be set separately for mara and marb. whether a block is to be designated for mara or for marb is specified by the blkdir bit in dmacra. to specify the number of transfers, if m is the size of one block (where m = 1 to 256) and n transfers are to be performed (where n = 1 to 65,536), m is set in both etcrah and etcral, and n in etcrb. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 190 of 698 rej09b0074-0600 figure 7.10 illustrates operation in block transfer mode when marb is designated as a block area. a ddress t a a ddress b a transfer address t b notes: address t a = l a address t b = l b address b a = l a + saide (?1) said (2 dtsz (m n?1)) address b b = l b + daide (?1) daid (2 dtsz (n?1)) l a = value set in mara l b = value set in marb n = value set in etcra m = value set in etcrah and etcral address b b 1st block 2nd block nth block block area consecutive transfer of m bytes or words is performed in response to one request figure 7.10 operation in block transfer mode (blkdir = 0) section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 191 of 698 rej09b0074-0600 figure 7.11 illustrates operation in block transfer mode when mara is designated as a block area. address t b address b b transfer a ddress t a notes: address t a = l a address t b = l b address b a = l a + saide (?1) said (2 dtsz (n?1)) address b b = l b + daide (?1) daid (2 dtsz (m n?1)) l a = value set in mara l b = value set in marb n = value set in etcrb m = value set in etcrah and etcral a ddress b a 1st block 2nd block nth block block area consecutive transfer of m bytes or words is performed in response to one request figure 7.11 operation in block transfer mode (blkdir = 1) etcral is decremented by 1 each time a byte or word transfer is performed. in response to a single transfer request, burst transfer is performed until the value in etcral reaches h'00. etcral is then loaded with the value in etcrah. at this time, the value in the mar register for which a block designation has been given by the blkdir bit in dmacra is restored in accordance with the dtsz, said/daid, and saide/daide bits in dmacr. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 192 of 698 rej09b0074-0600 etcrb is decremented by 1 every block transfer, and when the count reaches h'0000 the dte bit is cleared and transfer ends. if the dtie bit is set to 1 at this point, an interrupt request is sent to the cpu. figure 7.12 shows the operation flow in block transfer mode. start (dte = dtme = 1) mara = mara ? saide (?1) said 2 dtsz etcrah no yes no yes no yes no yes clear dte bit to 0 to end transfer acquire bus etcral = etcral?1 transfer request? etcral = h'00 release bus blkdir = 0 etcral = etcrah etcrb = etcrb ? 1 etcrb = h'0000 read address specified by mara mara = mara + saide (?1) said 2 dtsz write to address specified by marb marb = marb + daide (?1) daid 2 dtsz marb = marb ? daide (?1) daid 2 dtsz etcrah figure 7.12 operation flow in block transfer mode section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 193 of 698 rej09b0074-0600 transfer requests (activation sources) consist of a/d conversion end interrupt, sci transmission complete and reception complete interrupts, and tpu channel 0 to 2 compare match/input capture a interrupts. for details, see section 7.3.4, dma control register (dmacr). figure 7.13 shows an example of the setting procedure for block transfer mode. block transfer mode setting set dmabcrh set transfer source and transfer destination addresses set number of transfers set dmacr read dmabcrl set dmabcrl block transfer mode [1] [2] [3] [4] [5] [6] [1] set each bit in dmabcrh. set the fae bit to 1 to select full address mode. specify enabling or disabling of internal interrupt clearing with the dta bit. [2] set the transfer source address in mara, and the transfer destination address in marb. [3] set the transfer source address in etcrah and etcral. set the number of transfers in etcrb. [4] set each bit in dmacra and dmacrb. set the transfer data size with the dtsz bit. specify whether mara is to be incremented, decremented, or fixed, with the said and saide bits. set the blke bit to 1 to select block transfer mode. specify whether the transfer source or the transfer destination is a block area with the blkdir bit. specify whether marb is to be incremented, decremented, or fixed, with the daid and daide bits. select the activation source with bits dtf3 to dtf0. [5] read the dte = 0 and dtme = 0 in dmabcrl. [6] set each bit in dmabcrl. specify enabling or desabling of transfer end interrupts to the cpu with the dtie bit. set both the dtme bit and the dte bit to 1 to enable transfer. figure 7.13 example of block transfer mode setting procedure section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 194 of 698 rej09b0074-0600 7.4.7 dmac activation sources dmac activation sources consist of internal interrupts, external requests, and auto-requests. the activation sources that can be specified depend on the transfer mode, as shown in table 7.8. table 7.8 dmac activation sources full address mode activation source short address mode normal mode block transfer mode internal adi interrupt txi0 rxi0 tgi0a tgi1a tgi2a usb request low level input of the dreq signal auto-request legend: : can be specified : cannot be specified activation by internal interrupt: an interrupt request selected as a dmac activation source can be sent simultaneously to the cpu. for details, see section 5, interrupt controller. with activation by an internal interrupt, the dmac accepts the request independently of the interrupt controller. consequently, interrupt controller priority sett ings are not accepted. if the dmac is activated by an interrupt request that is not used as a cpu interrupt source (dta = 1), the interrupt source flag is cleared automatically by the dma transfer. with adi, txi, and rxi interrupts, however, the interrupt source flag is not cleared unless the prescribed register is accessed in a dma transfer. if the same interrupt is used as an activation source for more than one channel, the interrupt request flag is cleared when the highest-priority channel is activated first. transfer requests for other channels are held pending in the dmac, and activation is carried out in order of priority. when dte = 0, such as after completion of a transfer, a request from the selected activation source is not sent to the dmac, regardless of the dta bit. in this case, the relevant interrupt section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 195 of 698 rej09b0074-0600 request is sent to the cpu. in case of overlap with a cpu interrupt source (dta = 0), the interrupt request flag is not cleared by the dmac. activation by usb request: the usb request ( dreq signal) is specified as a dmac activation source. the usb request is generated by the level sense. in full-address normal mode, the usb request is carried out as follows. while the dreq signal is kept high, the dmac waits for the transfer request. while the dreq signal is kept low, the dmac releases the bus each time a byte is transferred and the transfer is performed continuously. when the dreq signal is driven high during the transfer, the transfer is halted and the dmac waits for the transfer request. activation by auto-request: auto-request activation is performed by register setting only, and transfer continues to the end. with auto-request activation, cycle steal mode or burst mode can be selected. in cycle steal mode, the dmac releases the bus to another bus master each time a byte or word is transferred. dma and cpu cycles usually alternate. in burst mode, the dmac keeps possession of the bus until the end of the transfer, and transfer is performed continuously. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 196 of 698 rej09b0074-0600 7.4.8 basic dmac bus cycles an example of the basic dmac bus cycle timing is shown in figure 7.14. in this example, word- size transfer is performed from 16-bit, 2-state access space to 8-bit, 3-state access space. when the bus is transferred from the cpu to the dmac, a source address read and destination address write are performed. the bus is not released in response to another bus request, etc., between these read and write operations. as with cpu cycles, dma cycles conform to the bus controller settings. dmac cycle (1-word transfer) cpu cycle cpu cycle t 1 t 2 t 1 t 2 t 3 t 1 t 2 t 3 source address destination address address bus rd hwr lwr figure 7.14 example of dma transfer bus timing the address is not output to the external address bus in an access to on-chip memory or an internal i/o register. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 197 of 698 rej09b0074-0600 7.4.9 dmac bus cycles (dual address mode) short address mode: figure 7.15 shows a transfer example in which tend * output is enabled and byte-size short address mode transfer (sequential/idle/repeat mode) is performed from external 8-bit, 2-state access space to internal i/o space. dma read rd hwr tend * lwr dma write dma read dma write dma read dma write dma dead a ddress bus note: * this lsi does not support tend output. bus release bus release bus release bus releas e last transfer cycle figure 7.15 example of short address mode transfer a one-byte or one-word transfer is performed for one transfer request, and after the transfer the bus is released. while the bus is released one or more bus cycles are inserted by the cpu. in the transfer end cycle (the cycle in which the transfer counter reaches 0), a one-state dma dead cycle is inserted after the dma write cycle. in repeat mode, when tend * output is enabled, tend * output goes low in the transfer cycle in which the transfer counter reaches 0. note: * this lsi does not support tend output. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 198 of 698 rej09b0074-0600 full address mode (cycle steal mode): figure 7.16 shows a transfer example in which tend * output is enabled and word-size full address mode transfer (cycle steal mode) is performed from external 16-bit, 2-state access space to external 16-bit, 2-state access space. dma read rd hwr tend * lwr dma write dma read dma write dma read dma write dma dead a ddress bus bus release bus release bus release bus releas e last transfer cycle note: * this lsi does not support tend output. figure 7.16 example of full address mode (cycle steal) transfer a one-byte or one-word transfer is performed, and after the transfer the bus is released. while the bus is released one bus cycle is inserted by the cpu. in the transfer end cycle (the cycle in which the transfer counter reaches 0), a one-state dma dead cycle is inserted after the dma write cycle. note: * this lsi does not support tend output. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 199 of 698 rej09b0074-0600 full address mode (burst mode): figure 7.17 shows a transfer example in which tend * output is enabled and word-size full address mode transfer (burst mode) is performed from external 16- bit, 2-state access space to external 16-bit, 2-state access space. dma read rd hwr tend * lwr dma write dma read dma write dma read dma write dma dead a ddress bus bus release bus release last transfer cycle burst transfer note: * this lsi does not support tend output. figure 7.17 example of full address mode (burst mode) transfer in burst mode, one-byte or one-word transfers are executed consecutively until transfer ends. in the transfer end cycle (the cycle in which the transfer counter reaches 0), a one-state dma dead cycle is inserted after the dma write cycle. if a request from another higher-priority channel is generated after burst transfer starts, that channel has to wait until the burst transfer ends. if an nmi is generated while a channel designated for burst transfer is in the transfer enabled state, the dtme bit is cleared and the channel is placed in the transfer disabled state. if burst transfer has already been activated inside the dmac, the bus is released on completion of a one-byte or one-word transfer within the burst transfer, and bu rst transfer is suspended. if the last transfer cycle of the burst transfer has already been activ ated inside the dmac, execution continues to the end of the transfer even if the dtme bit is cleared. note: * this lsi does not support tend output. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 200 of 698 rej09b0074-0600 full address mode (block transfer mode): figure 7.18 shows a transfer example in which tend * output is enabled and word-size full address mode transfer (block transfer mode) is performed from internal 16-bit, 1-state access space to external 16-bit, 2-state access space. dma read rd hwr tend * lwr dma write dma dead a ddress bus bus release bus release bus release last block transfer dma read block transfer dma write dma read dma write dma dead dma read dma write note: * this lsi does not support tend output. figure 7.18 example of full addres s mode (block transfer mode) transfer a one-block transfer is performed for one transfer request, and after the transfer the bus is released. while the bus is released, one or more bus cycles are inserted by the cpu. in the transfer end cycle of each block (the cycle in which the transfer counter reaches 0), a one- state dma dead cycle is inserted after the dma write cycle. one block is transmitted without interruption. nm i generation does not affect block transfer operation. note: * this lsi does not support tend output. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 201 of 698 rej09b0074-0600 dreq signal level activation timing (normal mode): set the dta bit for the channel for which the dreq signal is selected to 1. figure 7.19 shows an example of dreq level activated normal mode transfer. dreq bus release idle idle idle read request clear period acceptance resumes acceptance resumes minimum of 2 cycles minimum of 2 cycles request clear period request request transfer source transfer source transfer destination transfer destination read write write a ddress bus dma control channel dma read dma write bus release dma read dma write bus release [1] [2] [3] [4] [5] [6] [7] acceptance after transfer enabling; the dreq signal low level is sampled on the rising edge of f, and the request is held. the request is cleared at the next bus break, and activation is started in the dmac. start of dma cycle. acceptance is resumed after the write cycle is completed. (as in [1], the dreq signal low level is sampled on the rising edge of , and the request is held.) [1] [2] [5] [3] [6] [4] [7] figure 7.19 example of dreq level activated normal mode transfer dreq signal sampling is performed every cycle, with the rising edge of the next cycle after the end of the dmabcr write cycle for setting the transfer enabled state as the starting point. when the dreq signal low level is sampled while acceptance by means of the dreq signal is possible, the request is held in the dmac. then, when activation is initiated in the dmac, the request is cleared. acceptance resumes after the end of the write cycle, dreq signal low level sampling is performed again, and this operation is repeated until the transfer ends. note: the dreq signal of this chip is an internal signal of chip, so it is not output from the pin. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 202 of 698 rej09b0074-0600 7.4.10 dmac multi-channel operation the dmac channel priority order is: channel 0 > channel 1, and channel a > channel b. table 7.9 summarizes the priority order for dmac channels. table 7.9 dmac channel priority order short address mode full address mode priority channel 0a channel 0 high channel 0b channel 1a channel 1 channel 1b low if transfer requests are issued simultaneously for more than one channel, or if a transfer request for another channel is issued during a transfer, when the bus is released the dmac selects the highest- priority channel from among those issuing a reques t according to the priority order shown in table 7.9. during burst transfer, or when one block is being transferred in block transfer, the channel will not be changed until the end of the transfer. figure 7.20 shows a transfer example in which transfer requests are issued simultaneously for channels 0a, 0b, and 1. dma read dma write dma read dma write dma read dma write dma read a ddress bus rd hwr lwr dma control channel 0a channel 0b channel 1 idle write idle read write idle read write read request clear request hold request hold request clear request clear bus release channel 0a transfer bus release channel 0b transfer channel 1 transfer bus release request hold read selection non- selection selection figure 7.20 example of multi-channel transfer section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 203 of 698 rej09b0074-0600 7.4.11 relation between the dmac and external bus requests there can be no break between a dma cycle read and a dma cycle write. this means that an external bus release cycle is not generated between the external read and external write in a dma cycle. in the case of successive read and write cycles, such as in burst transfer or block transfer, an external bus released state may be inserted after a write cycle. when dma cycle reads or writes are accesses to on-ch ip memory or internal i/o registers, these dma cycles can be executed at the same time as refresh cycles or external bus release. however, simultaneous operation may not be possible when a write buffer is used. 7.4.12 nmi interrupts and dmac when an nmi interrupt is requested, burst mode transfer in full address mode is interrupted. an nmi interrupt does not affect the operation of the dmac in other modes. in full address mode, transfer is enabled for a channel when both the dte bit and the dtme bit are set to 1. with burst mode setting, the dtme bit is cleared when an nmi interrupt is requested. if the dtme bit is cleared during burst mode transfer, the dmac discontinues transfer on completion of the 1-byte or 1-word transfer in progress, then releases the bus, which passes to the cpu. the channel on which transfer was interrupted can be restarted by setting the dtme bit to 1 again. figure 7.21 shows the procedure for continuing tr ansfer when it has been interrupted by an nmi interrupt on a channel designated for burst mode transfer. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 204 of 698 rej09b0074-0600 resumption of transfer on interrupted channel set dtme bit to 1 transfer continues [1] [2] dte = 1 dtme = 0 transfer ends no yes [1] [2] check that dte = 1 and dtme = 0 in dmabcrl write 1 to the dtme bit. figure 7.21 example of procedure for cont inuing transfer on channel interrupted by nmi interrupt 7.4.13 forced termination of dmac operation if the dte bit for the channel currently operating is cleared to 0, the dmac stops on completion of the 1-byte or 1-word transfer in progress. dmac operation resumes when the dte bit is set to 1 again. in full address mode, the same applies to the dtme bit. figure 7.22 shows the procedure for forcibly terminating dmac operation by software. forced termination of dmac clear dte bit to 0 forced termination [1] [1] clear the dte bit in dmabcrl to 0. if you want to prevent interrupt generation after forced termination of dmac operation, clear the dtie bit to 0 at the same time. figure 7.22 example of procedure fo r forcibly terminat ing dmac operation section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 205 of 698 rej09b0074-0600 7.4.14 clearing full address mode figure 7.23 shows the procedure for releasing and initializing a channel designated for full address mode. after full address mode has been cleared, th e channel can be set to another transfer mode using the appropriate setting procedure. clearing full address mode stop the channel initialize dmacr clear fae bit to 0 initialization; operation halted [1] [2] [3] [1] clear both the dte bit and the dtme bit in dmabcrl to 0; or wait until the transfer ends and the dte bit is cleared to 0, then clear the dtme bit to 0. also clear the corresponding dtie bit to 0 at the same time. [2] clear all bits in dmacra and dmacrb to 0. [3] clear the fae bit in dmabcrh to 0. figure 7.23 example of procedu re for clearing full address mode section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 206 of 698 rej09b0074-0600 7.5 interrupts the sources of interrupts generated by the dmac are transfer end and transfer break. table 7.10 shows the interrupt sources and their priority order. table 7.10 interrupt source priority order interrupt source interrupt name short address mode full address mode interrupt priority order dend0a interrupt due to end of transfer on channel 0a interrupt due to end of transfer on channel 0 high dend0b interrupt due to end of transfer on channel 0b interrupt due to break in transfer on channel 0 dend1a interrupt due to end of transfer on channel 1a interrupt due to end of transfer on channel 1 dend1b interrupt due to end of transfer on channel 1b interrupt due to break in transfer on channel 1 low enabling or disabling of each interrupt source is set by means of the dtie bit for the corresponding channel in dmabcr, and interrupts from each source are sent to the interrupt controller independently. the relative priority of transfer end interrupts on each channel is decided by the interrupt controller, as shown in table 7.10. figure 7.24 shows a block diagram of a transfer end/transfer break interrupt. an interrupt is always generated when the dtie bit is set to 1 while dte bit is cleared to 0. dte/ dtme dtie transfer end/transfe r break interrupt figure 7.24 block diagram of transfer end/transfer break interrupt in full address mode, a transfer break interrupt is generated when the dtme bit is cleared to 0 while dtieb bit is set to 1. in both short addr ess mode and full address mode, dmabcr should be set so as to prevent the occurrence of a combination that constitutes a condition for interrupt generation during setting. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 207 of 698 rej09b0074-0600 7.6 usage notes 7.6.1 dmac register access during operation except for forced termination, the operating (including transfer waiting state) channel setting should not be changed. the operating channel setting should only be changed when transfer is disabled. also, the dmac register should not be written to in a dma transfer. dmac register reads during operation (including the transfer waiting state) are described below. 1. dmac control starts one cycle before the bus cycle, with output of the internal address. consequently, mar is updated in the bus cycle before dmac transfer. figure 7.25 shows an example of the update timing for dmac registers in dual address transfer mode. [1] transfer source address register mar operation (incremented/decremented/fixed) transfer counter etcr operation (decremented) block size counter etcr operation (decremented in block transfer mode) [2] transfer destination address register mar operation (incremented/decremented/fixed) [2'] transfer destination address register mar operation (incremented/decremented/fixed) block transfer counter etcr operation (decremented, in last transfer cycle of a block in block transfer mode) [3] transfer address register mar restore operation (in block or repeat transfer mode) transfer counter etcr restore (in repeat transfer mode) block size counter etcr restore (in block transfer mode) note: the mar operation is post-incrementing/decrementing of the dma internal address value. [3] [2'] [2] [1] [1] dma transfer cycle dma read dma read dma write dma write dma dead dma internal address dma control dma register operation dma last transfer cycle transfer destination transfer destination transfer source transfer source idle idle idle read read dead write write figure 7.25 dmac register update timing section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 208 of 698 rej09b0074-0600 2. if a dmac transfer cycle occurs immediately after a dmac register read cycle, the dmac register is read as shown in figure 7.26. [1] [2] note: the lower word of mar is the updated value after the operation in [1]. cpu longword read dma transfer cycle mar upper word read mar lower word read dma read dma write dma internal address dma control dma register operation idle read write idle transfer source transfer destination figure 7.26 contention between dmac register update and cpu read 7.6.2 module stop when the mstpa7 bit in mstpcr is set to 1, the dmac clock stops, and the module stop state is entered. however, 1 cannot be written to the mstpa7 bit if any of the dmac channels is enabled. this setting should therefore be made when dmac operation is stopped. when the dmac clock stops, dmac register accesses can no longer be made. since the following dmac register settings are valid even in the module stop state, they should be invalidated, if necessary, before a module stop. ? transfer end/suspend interrupt (dte = 0 and dtie = 1) for details, refer to section 20, power-down modes. 7.6.3 medium-speed mode when the dta bit is 0, internal interrupt signals specified as dmac transfer sources are edge- detected. in medium-speed mode, the dmac operates on a medium-speed clock, while on-chip peripheral modules operate on a high-speed clock. consequently, if the period in which the relevant interrupt source is cleared by the cpu or another dmac channel, and the next interrupt is generated, is less than one state with respect to the dmac clock (bus master clock), edge detection may not be possible and the interrupt may be ignored. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 209 of 698 rej09b0074-0600 7.6.4 activation source acceptance at the start of activation source acceptance, a low level is detected in both dreq signal falling edge sensing and low level sensing. similarly, in the case of an internal interrupt, the interrupt request is detected. therefore, a request is accepted from an internal interrupt or dreq pin low level that occurs before execution of the dmabcrl write to enable transfer. when the dmac is activated, take any necessary steps to prevent an internal interrupt or dreq signal low level remaining from the end of the previous transfer, etc. 7.6.5 internal interrupt after end of transfer when the dte bit is cleared to 0 by the end of tran sfer or an abort, the selected internal interrupt request will be sent to the cpu even if dta is set to 1. also, if internal dmac activation has already been initiated when operation is aborted, the transfer is executed but flag clearing is not performed for the selected internal interrupt even if dta is set to 1. an internal interrupt request following the end of transfer or an abort should be handled by the cpu as necessary. 7.6.6 channel re-setting to reactivate a number of channels when multiple channels are enabled, use exclusive handling of transfer end interrupts, and perform dmabcr control bit operations exclusively. note, in particular, that in cases where multiple interrupts are generated between reading and writing of dmabcr, and a dmabcr operation is performed during new interrupt handling, the dmabcr write data in the original interrupt handling routine will be incorrect, and the write may invalidate the results of the operations by the multiple interrupts. ensure that overlapping dmabcr operations are not performed by multiple interrupts, and that there is no separation between read and write operations by the use of a bit-manipulation instruction. also, when the dte and dtme bits are cleared by the dmac or are written with 0, they must first be read while cleared to 0 before the cpu can write a 1 to them. section 7 dma controller (dmac) rev.6.00 jun. 03, 2008 page 210 of 698 rej09b0074-0600 section 8 i/o ports rev.6.00 jun. 03, 2008 page 211 of 698 rej09b0074-0600 section 8 i/o ports table 8.1 and table 8.2 summarize the port functions of the h8s/2218 group and h8s/2212 group respectively. the pins of each port also have other functions such as input/output or external interrupt input pins of on-chip peripheral modules. each i/o port includes a data direction register (ddr) that controls input/output, a data register (dr) that stores output data, and a port register (port) used to read the pin states. the input-only ports do not have dr and ddr. ports a to e have an on-chip input pull-up mos and a input pull-up mos control register (pcr) to control the on/off state of the input pull-up mos. ports 3 and a include an open-drain control register (odr) that controls the on/off state of the output buffer pmos. all the i/o ports can drive a single ttl load and 30-pf capacitive load. table 8.1 port functions of h8s/2218 group port description modes 4 and 5 mode 6 mode 7 input/output type p17/tiocb2/tclkd p16/tioca2/ irq1 p15/tiocb1/tclkc p14/tioca1/ irq0 p13/tiocd0/tclkb/a23 p13/tiocd0/tclkb p12/tiocc0/tclka/a22 p12/tiocc0/tclka p11/tiocb0/a21 p11/tiocb0 port 1 general i/o port also functioning as tpu i/o pins, interrupt input pins, and address bus output pins p10/tioca0/a20 p10/tioca0 schmitt trigger input ( irq1 , irq0 ) port 3 general i/o port also functioning as sci_0 i/o pins and interrupt input pins p36 p32/sck0/ irq4 p31/rxd0 p30/txd0 open-drain output schmitt trigger input ( irq4 ) port 4 general input port also functioning as a/d converter analog input pins p43/an3 p42/an2 p41/an1 p40/an0 port 7 general i/o port also functioning as bus control output pins and manual reset input pins p74/ mres p71/ cs5 p70/ cs4 p74/ mres p71 p70 section 8 i/o ports rev.6.00 jun. 03, 2008 page 212 of 698 rej09b0074-0600 port description modes 4 and 5 mode 6 mode 7 input/output type port 9 general input port also functioning as a/d converter analog input pins p97/an15 p96/an14 port a general i/o port also functioning as sci_2 i/o pins and address bus output pins pa3/a19/sck2 pa2/a18/rxd2 pa1/a17/txd2 pa0/a16 pa3/sck2 pa2/rxd2 pa1/txd2 pa0 on-chip input pull-up mos open-drain output port b general i/o port also functioning as address bus output pins pb7/a15 pb6/a14 pb5/a13 pb4/a12 pb3/a11 pb2/a10 pb1/a9 pb0/a8 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 on-chip input pull-up mos a7 when ddr = 0: pc7 when ddr = 1: a7 pc7 a6 when ddr = 0: pc6 when ddr = 1: a6 pc6 port c general i/o port also functioning as address bus output pins a5 when ddr = 0: pc5 when ddr = 1: a5 pc5 on-chip input pull-up mos a4 when ddr = 0: pc4 when ddr = 1: a4 pc4 a3 when ddr = 0: pc73 when ddr = 1: a3 pc3 a2 when ddr = 0: pc2 when ddr = 1: a2 pc2 a1 when ddr = 0: pc1 when ddr = 1: a1 pc1 a0 when ddr = 0: pc0 when ddr = 1: a0 pc0 port d general i/o port also functioning as data bus i/o pins d15 d14 d13 d12 d11 d10 d9 d8 pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 on-chip input pull-up mos section 8 i/o ports rev.6.00 jun. 03, 2008 page 213 of 698 rej09b0074-0600 port description modes 4 and 5 mode 6 mode 7 input/output type 8-bit bus mode: pe7 16-bit bus mode: d7 pe7 8-bit bus mode: pe6 16-bit bus mode: d6 pe6 8-bit bus mode: pe5 16-bit bus mode: d5 pe5 8-bit bus mode: pe4 16-bit bus mode: d4 pe4 8-bit bus mode: pe3 16-bit bus mode: d3 pe3 port e general i/o port also functioning as data bus i/o pins 8-bit bus mode: pe2 16-bit bus mode: d2 pe2 on-chip input pull-up mos 8-bit bus mode: pe1 16-bit bus mode: d1 pe1 8-bit bus mode: pe0 16-bit bus mode: d0 pe0 port f when ddr = 0: pf7 when ddr = 1 (after reset): when ddr = 0 (after reset): pf7 when ddr = 1: schmitt trigger input ( irq3 , irq2 ) as pf6 rd pf5 general i/o port also functioning as bus control signal i/o pins and interrupt input pins hwr pf4 8-bit bus mode: pf3/ adtrg / irq3 16-bit bus mode: lwr pf3/ adtrg / irq3 when waite = 0 (after reset): pf2 when waite = 1: wait pf2 when brle = 0 (after reset): pf1 when brle = 1: back pf1 when brle = 0 (after reset): pf0/ irq2 when brle = 1: breq / irq2 pf0/ irq2 section 8 i/o ports rev.6.00 jun. 03, 2008 page 214 of 698 rej09b0074-0600 port description modes 4 and 5 mode 6 mode 7 input/output type port g when ddr = 0 (after reset in mode 6): pg4 when ddr = 1 (after reset in modes 4, 5): cs0 pg4 schmitt trigger input ( irq7 ) general i/o port also functioning as bus control output pins and interrupt input pins when ddr = 0: pg3 when ddr = 1: cs1 pg3 when ddr = 0: pg2 when ddr = 1: cs2 pg2 when ddr = 0: pg1/ irq7 when ddr = 1: cs3 / irq7 pg1/ irq7 table 8.2 port functions of h8s/2212 group port description mode 7 input/output type port 1 general i/o port also functioning as tpu i/o pins and interrupt input pins p17/tiocb2/tclkd p16/tioca2/ irq1 p15/tiocb1/tclkc p14/tioca1/ irq0 p13/tiocd0/tclkb p12/tiocc0/tclka p11/tiocb0 p10/tioca0 schmitt trigger input ( irq1 , irq0 ) port3 general i/o port also functioning as sci_0 i/o pins and interrupt input pins p36 p32/sck0/ irq4 p31/rxd0 p30/txd0 open-drain output schmitt trigger input ( irq4 ) port 4 general input port also functioning as a/d converter analog input pins p43/an3 p42/an2 p41/an1 p40/an0 port 7 general i/o port p77 * p76 * p75 * port 9 general input port also functioning as a/d converter analog input pins p97/an15 p96/an14 section 8 i/o ports rev.6.00 jun. 03, 2008 page 215 of 698 rej09b0074-0600 port description mode 7 input/output type port a general i/o port also functioning as sci_2 i/o pins pa3/sck2 pa2/rxd2 pa1/txd2 on-chip input pull-up mos open-drain output port e general i/o port pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 on-chip input pull-up mos when ddr = 0 (after reset): pf7 when ddr = 1: port f general i/o port also functioning as interrupt input pins pf3/ adtrg / irq3 pf0/ irq2 schmitt trigger input ( irq3 , irq2 ) port g general i/o port also functioning as interrupt input pins pg1/ irq7 pg0 * schmitt trigger input ( irq7 ) note: * these pins are available only when emle = 0. these pins are not available when the h-udi is used. section 8 i/o ports rev.6.00 jun. 03, 2008 page 216 of 698 rej09b0074-0600 8.1 port 1 in the h8s/2218 group, the port 1 is an 8-bit i/o port also functioning as address bus pins, tpu i/o pins, and external interrupt input pins. in the h8s/2212 group, the port 1 is an 8-bit i/o port also functioning as tpu i/o pins and external interrupt input pins. the port 1 has the following registers. ? port 1 data direction register (p1ddr) ? port 1 data register (p1dr) ? port 1 register (port1) 8.1.1 port 1 data di rection register (p1ddr) p1ddr specifies input or output for the pins of the port 1. since p1ddr is a write-only register, the bit manipulation instructions must not be used to write p1ddr. for details, see section 2.9.4, acce ssing registers containing write-only bits. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 p17ddr p16ddr p15ddr p14ddr p13ddr p12ddr p11ddr p10ddr 0 0 0 0 0 0 0 0 w w w w w w w w (h8s/2218 group) modes 4 to 6: if address output is enabled by the setting of bits ae3 to ae0 in pfcr, pins p13 to p10 are address outputs. pins p17 to p14, and pins p13 to p10 when address output is disabled, are output ports when the corresponding p1ddr bits are set to 1, and input ports when the corresponding p1ddr bits are cleared to 0. mode 7: setting a p1ddr bit to 1 makes the corresponding port 1 pin an output port, while clearing the bit to 0 makes the pin an input port. (h8s/2212 group) setting a p1ddr bit to 1 makes the corresponding port 1 pin an output port, while clearing the bit to 0 makes the pin an input port. section 8 i/o ports rev.6.00 jun. 03, 2008 page 217 of 698 rej09b0074-0600 8.1.2 port 1 data register (p1dr) p1dr stores output data for the port 1 pins. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 p17dr p16dr p15dr p14dr p13dr p12dr p11dr p10dr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w store output data for a pin that functions as a general output port. 8.1.3 port 1 register (port1) port1 indicates the pin states of the port 1. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 p17 p16 p15 p14 p13 p12 p11 p10 ? * ? * ? * ? * ? * ? * ? * ? * r r r r r r r r if the port 1 is read while p1ddr bits are set to 1, the p1dr value is read. if the port 1 is read while p1ddr bits are cleared to 0, the pin states are read. note: * determined by the states of pins p17 to p10. section 8 i/o ports rev.6.00 jun. 03, 2008 page 218 of 698 rej09b0074-0600 8.1.4 pin functions pin functions of h8s/2218 group port 1 pins also function as address bus (a23 to a20) output pins, tpu i/o pins, and external interrupt input ( irq0 and irq1 ) pins. the correspondence between the register specification and the pin functions is shown below. table 8.3 p17 pin function tpu channel 2 setting * output setting input setting or initial value p17ddr ? 0 1 p17 input pin p17 output pin tiocb2 output pin tiocb2 input pin pin function tclkd input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). table 8.4 p16 pin function tpu channel 2 setting * 1 output setting input setting or initial value p16ddr ? 0 1 p16 input pin p16 output pin tioca2 output pin tioca2 input pin pin function irq1 input pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. when this pin is used as an external interrupt pin, this pin must not be used for another function. table 8.5 p15 pin function tpu channel 1 setting * output setting input setting or initial value p15ddr ? 0 1 p15 input pin p15 output pin tiocb1 output pin tiocb1 input pin pin function tclkc input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). section 8 i/o ports rev.6.00 jun. 03, 2008 page 219 of 698 rej09b0074-0600 table 8.6 p14 pin function tpu channel 1 setting * 1 output setting input setting or initial value p14ddr ? 0 1 p14 input pin p14 output pin tioca1 output pin tioca1 input pin pin function irq0 input pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. when this pin is used as an external interrupt pin, this pin must not be used for another function. table 8.7 p13 pin function ae3 to ae0 * 2 other than b'1111 b'1111 tpu channel 0 setting * 1 output setting input setting or initial value ? p13ddr ? 0 1 ? p13 input pin p13 output pin tiocd0 output pin tiocd0 input pin pin function tclkb input pin a23 output pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. valid in modes 4, 5, and 6. table 8.8 p12 pin function ae3 to ae0 * 2 other than b'1111 b'1111 tpu channel 0 setting * 1 output setting input setting or initial value ? p12ddr ? 0 1 ? p12 input pin p12 output pin tiocc0 output pin tiocc0 input pin pin function tclka input pin a22 output pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. valid in modes 4, 5, and 6. section 8 i/o ports rev.6.00 jun. 03, 2008 page 220 of 698 rej09b0074-0600 table 8.9 p11 pin function ae3 to ae0 * 2 other than b'1110 to b'1111 b'1110 to b'1111 tpu channel 0 setting * 1 output setting input setting or initial value ? p11ddr ? 0 1 ? p11 input pin p11 output pin pin function tiocb0 output pin tiocb0 input pin a21 output pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. valid in modes 4, 5, and 6. table 8.10 p10 pin function ae3 to ae0 * 2 other than b'1101 to b'1111 b'1101 to b'1111 tpu channel 0 setting * 1 output setting input setting or initial value ? p10ddr ? 0 1 ? p10 input pin p10 output pin pin function tioca0 output pin tioca0 input pin a20 output pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. valid in modes 4, 5, and 6. pin functions of h8s/2212 group port 1 pins also function as tpu i/o pins and external interrupt input ( irq0 and irq1 ) pins. the correspondence between the register specification and the pin functions is shown below. table 8.11 p17 pin function tpu channel 2 setting * output setting input setting or initial value p17ddr ? 0 1 p17 input pin p17 output pin tiocb2 output pin tiocb2 input pin pin function tclkd input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). section 8 i/o ports rev.6.00 jun. 03, 2008 page 221 of 698 rej09b0074-0600 table 8.12 p16 pin function tpu channel 2 setting * 1 output setting input setting or initial value p16ddr ? 0 1 p16 input pin p16 output pin tioca2 output pin tioca2 input pin pin function irq1 input pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. when this pin is used as an external interrupt pin, this pin must not be used for another function. table 8.13 p15 pin function tpu channel 1 setting * output setting input setting or initial value p15ddr ? 0 1 p15 input pin p15 output pin tiocb1 output pin tiocb1 input pin pin function tclkc input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). table 8.14 p14 pin function tpu channel 1 setting * 1 output setting input setting or initial value p14ddr ? 0 1 p14 input pin p14 output pin tioca1 output pin tioca1 input pin pin function irq0 input pin * 2 notes: 1. for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). 2. when this pin is used as an external interrupt pin, this pin must not be used for another function. section 8 i/o ports rev.6.00 jun. 03, 2008 page 222 of 698 rej09b0074-0600 table 8.15 p13 pin function tpu channel 0 setting * output setting input setting or initial value p13ddr ? 0 1 p13 input pin p13 output pin tiocd0 output pin tiocd0 input pin pin function tclkb input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). table 8.16 p12 pin function tpu channel 0 setting * output setting input setting or initial value p12ddr ? 0 1 p12 input pin p12 output pin tiocc0 output pin tiocc0 input pin pin function tclka input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). table 8.17 p11 pin function tpu channel 0 setting * output setting input setting or initial value p11ddr ? 0 1 p11 input pin p11 output pin pin function tiocb0 output pin tiocb0 input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). table 8.18 p10 pin function tpu channel 0 setting * output setting input setting or initial value p10ddr ? 0 1 p10 input pin p10 output pin pin function tioca0 output pin tioca0 input pin note: * for details on the tpu channel setting, refer to section 9, 16-bit timer pulse unit (tpu). section 8 i/o ports rev.6.00 jun. 03, 2008 page 223 of 698 rej09b0074-0600 8.2 port 3 the port 3 is a 4-bit i/o port also functioning as the sci i/o pins and external interrupt input ( irq4 ) pins. the port 3 of the h8s/2218 group has the same function as that of the h8s/2212 group. the port 3 has the following registers. ? port 3 data direction register (p3ddr) ? port 3 data register (p3dr) ? port 3 register (port3) ? port 3 open-drain control register (p3odr) 8.2.1 port 3 data di rection register (p3ddr) p3ddr specifies input or output for the pins of the port 3. since p3ddr is a write-only register, the bit manipulation instructions must not be used to write p3ddr. for details, see section 2.9.4, acce ssing registers containing write-only bits. bit bit name initial value r/w description 7 ? undefined ? reserved this bit is undefined and cannot be modified. 6 p36ddr 0 w setting a p3ddr bit to 1 makes the corresponding port 3 pin an output pin, while clearing the bit to 0 makes the pin an input pin. 5 to 3 ? undefined ? reserved these bits are undefined and cannot be modified. 2 1 0 p32ddr p31ddr p30ddr 0 0 0 w w w setting a p3ddr bit to 1 makes the corresponding port 3 pin an output pin, while clearing the bit to 0 makes the pin an input pin. section 8 i/o ports rev.6.00 jun. 03, 2008 page 224 of 698 rej09b0074-0600 8.2.2 port 3 data register (p3dr) p3dr stores output data for the port 3 pins. bit bit name initial value r/w description 7 ? undefined ? reserved this bit is undefined and cannot be modified. 6 p36dr 0 r/w stores output data for a pin that functions as a general output port. 5 to 3 ? undefined ? reserved these bits are undefined and cannot be modified. 2 1 0 p32dr p31dr p30dr 0 0 0 r/w r/w r/w store output data for a pin that functions as a general output port. 8.2.3 port 3 register (port3) port3 indicates the pin states of the port 3. bit bit name initial value r/w description 7 ? undefined ? reserved this bit is undefined. 6 p36 ? * r if the port 3 is read while p3ddr bits are set to 1, the p3dr value is read. if the port 3 is read while p3ddr bits are cleared to 0, the pin states are read. 5 to 3 ? undefined ? reserved these bits are undefined. 2 1 0 p32 p31 p30 ? * ? * ? * r r r if the port 3 is read while p3ddr bits are set to 1, the p3dr value is read. if the port 3 is read while p3ddr bits are cleared to 0, the pin states are read. note: * determined by the states of pins p36 and p32 to p30. section 8 i/o ports rev.6.00 jun. 03, 2008 page 225 of 698 rej09b0074-0600 8.2.4 port 3 open-drain control register (p3odr) p3odr controls the pmos on/off state for each port 3 pin. bit bit name initial value r/w description 7 ? undefined ? reserved this bit is undefined and cannot be modified. 6 p36odr 0 r/w setting a p3odr bit to 1 makes the corresponding port 3 pin an nmos open-drain output pin, while clearing the bit to 0 makes the pin a cmos output pin. 5 to 3 ? undefined ? reserved these bits are undefined and cannot be modified. 2 1 0 p32odr p31odr p30odr 0 0 0 r/w r/w r/w setting a p3odr bit to 1 makes the corresponding port 3 pin an nmos open-drain output pin, while clearing the bit to 0 makes the pin a cmos output pin. 8.2.5 pin functions port 3 pins also function as sci i/o pins and external interrupt input ( irq4 ) pins. the correspondence between the register specification and the pin functions is shown below. the p36 pin must be used as the d+ pull-up control output pin of the usb. for details, refer to section 14, universal serial bus (usb). table 8.19 p36 pin function p36ddr 0 1 pin function p36 input pin p36 output pin (d+ pull-up control output pin of usb) section 8 i/o ports rev.6.00 jun. 03, 2008 page 226 of 698 rej09b0074-0600 table 8.20 p32 pin function cke1 in scr_0 0 1 c/ a in smr_0 0 1 ? cke0 in scr_0 0 1 ? ? p32ddr 0 1 ? ? ? p32 input pin p32 output pin sck0 output pin sck0 output pin sck0 input pin pin function irq4 input pin * note: * when this pin is used as an external interrupt pin, this pin must not be used for another function. table 8.21 p31 pin function re in scr_0 0 1 p31ddr 0 1 ? pin function p31 input pin p31 output pin rxd0 input pin table 8.22 p30 pin function te in scr_0 0 1 p30ddr 0 1 ? pin function p30 input pin p30 output pin txd0 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 227 of 698 rej09b0074-0600 8.3 port 4 the port 4 is a 4-bit input port also functioning as a/d converter analog input pins. the port 4 of the h8s/2218 group has the same function as that of the h8s/2212 group. the port 4 has the following register. ? port 4 register (port4) 8.3.1 port 4 register (port4) port4 indicates the pin states of the port 4. bit bit name initial value r/w description 7 to 4 ? undefined ? reserved these bits are undefined. 3 2 1 0 p43 p42 p41 p40 ? * ? * ? * ? * r r r r the pin states are always read when these bits are read. note: * determined by the states of pins p43 to p40. 8.3.2 pin function the port 4 also functions as a/d converter analog input (an3 to an0) pins. section 8 i/o ports rev.6.00 jun. 03, 2008 page 228 of 698 rej09b0074-0600 8.4 port 7 in the h8s/2218 group, the port 7 is a 3-bit i/o port also functioning as bus control output pins and manual reset input pins. in the h8s/2212 group, the port 7 is a 3-bit i/o port also functioning as h-udi pins. the port 7 has the following registers. ? port 7 data direction register (p7ddr) ? port 7 data register (p7dr) ? port 7 register (port7) 8.4.1 port 7 data di rection register (p7ddr) p7ddr specifies input or output for the pins of the port 7. since p7ddr is a write-only register, the bit manipulation instructions must not be used to write p7ddr. for details, see section 2.9.4, acce ssing registers containing write-only bits. bit bit name initial value r/w description 7 6 5 p77ddr p76ddr p75ddr 0 0 0 w w w (h8s/2218 group) reserved these bits are undefined and cannot be modified. (h8s/2212 group) when emle = 1: pins p77 to p75 function as the h-udi pins (tdo, tms, tck). when emle = 0: if a p7ddr bit is set to 1, pins p77 to p75 function as output ports. if a p7ddr bit is cleared to 0, pins p77 to p75 function as input ports. 4 p74ddr 0 w (h8s/2218 group) setting a p7ddr bit to 1 makes the corresponding port 7 pin an output pin, while clearing the bit to 0 makes the pin an input pin. (h8s/2212 group) reserved this bit is undefined and cannot be modified. 3, 2 ? undefined ? reserved these bits are undefined and cannot be modified. section 8 i/o ports rev.6.00 jun. 03, 2008 page 229 of 698 rej09b0074-0600 bit bit name initial value r/w description 1 0 p71ddr p70ddr 0 0 w w (h8s/2218 group) setting a p7ddr bit to 1 makes the corresponding port 7 pin an output pin, while clearing the bit to 0 makes the pin an input pin. (h8s/2212 group) reserved these bits are undefined and cannot be modified. 8.4.2 port 7 data register (p7dr) p7dr stores output data for the port 7 pins. bit bit name initial value r/w description 7 6 5 p77dr p76dr p75dr 0 0 0 r/w r/w r/w (h8s/2218 group) reserved these bits are undefined and cannot be modified. (h8s/2212 group) store output data for the port 7 pins. 4 p74dr 0 r/w (h8s/2218 group) stores output data for the port 7 pins. (h8s/2212 group) reserved this bit is undefined and cannot be modified. 3, 2 ? undefined ? reserved these bits are undefined and cannot be modified. 1 0 p71dr p70dr 0 0 r/w r/w (h8s/2218 group) store output data for the port 7 pins. (h8s/2212 group) reserved these bits are undefined and cannot be modified. section 8 i/o ports rev.6.00 jun. 03, 2008 page 230 of 698 rej09b0074-0600 8.4.3 port 7 register (port7) port7 indicates the pin states of the port 7. bit bit name initial value r/w description 7 6 5 p77 p76 p75 ? * ? * ? * ? ? ? (h8s/2218 group) reserved these bits are undefined and cannot be modified. (h8s/2212 group) if p7ddr bits are set to 1, the p7dr value is read. if p7ddr bits are cleared to 0, the pin states are read. 4 p74 ? * r (h8s/2218 group) if the port 7 is read while p7ddr bits are set to 1, the p7dr value is read. if the port 7 is read while p7ddr bits are cleared to 0, the pin states are read. (h8s/2212 group) reserved this bit is undefined and cannot be modified. 3, 2 ? undefined ? reserved these bits are undefined and cannot be modified. 1 0 p71 p70 ? * ? * r r (h8s/2218 group) if the port 7 is read while p7ddr bits are set to 1, the p7dr value is read. if the port 7 is read while p7ddr bits are cleared to 0, the pin states are read. (h8s/2212 group) reserved these bits are undefined and cannot be modified. note: * determined by the states of pins p77 to p74, p71, and p70. section 8 i/o ports rev.6.00 jun. 03, 2008 page 231 of 698 rej09b0074-0600 8.4.4 pin functions pin functions of h8s/2218 group port 7 pins also function as bus control output pins and manual reset input pins. the correspondence between the register specification and the pin functions is shown below. table 8.23 p74 pin function mrese 0 1 p74ddr 0 1 ? pin function p74 input pin p74 output pin mres input pin table 8.24 p71 pin function operating mode modes 4 to 6 mode 7 p71ddr 0 1 0 1 pin function p71 input pin cs5 output pin p71 input pin p71 output pin table 8.25 p70 pin function operating mode modes 4 to 6 mode 7 p70ddr 0 1 0 1 pin function p70 input pin cs4 output pin p70 input pin p70 output pin pin functions of h8s/2212 group port 7 pins also function as h-udi pins. the correspondence between the register specification and the pin functions is shown below. table 8.26 p77 pin function emle 0 1 p77ddr 0 1 ? pin function p77 input pin p77 output pin tdo output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 232 of 698 rej09b0074-0600 table 8.27 p76 pin function emle 0 1 p76ddr 0 1 ? pin function p76 input pin p76 output pin tck input pin table 8.28 p75 pin function emle 0 1 p75ddr 0 1 ? pin function p75 input pin p75 output pin tms input pin 8.5 port 9 the port 9 is a 2-bit input port also functioning as a/d converter analog input pins. the port 9 of the h8s/2218 group has the same function as that of the h8s/2212 group. ? port 9 register (port9) 8.5.1 port 9 register (port9) port9 indicates the pin states of the port 9. bit bit name initial value r/w description 7 6 p97 p96 ? * ? * r r the pin states are always read when these bits are read. 5 to 0 ? undefined ? reserved these bits are undefined. note: * determined by the states of pins p97 and p96. 8.5.2 pin function the port 9 also functions as a/d converter analog input (an15 and an14) pins. section 8 i/o ports rev.6.00 jun. 03, 2008 page 233 of 698 rej09b0074-0600 8.6 port a in the h8s/2218 group, the port a is a 4-bit i/o port also functioning as address bus (a19 to a16) output pins and sci i/o pins. in the h8s/2212 group, the port a is a 3-bit i/o port also functioning as sci i/o pins. the port a has the following registers. ? port a data direction register (paddr) ? port a data register (padr) ? port a register (porta) ? port a pull-up mos control register (papcr) ? port a open-drain control register (paodr) 8.6.1 port a data di rection register (paddr) paddr specifies input or output for the pins of the port a. since paddr is a write-only register, the bit manipulation instructions must not be used to write paddr. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 to 4 ? undefined ? reserved these bits are undefined and cannot be modified. 3 2 1 0 pa3ddr pa2ddr pa1ddr pa0ddr * 0 0 0 0 w w w w (h8s/2218 group) modes 4 to 6: if address output is enabled by the setting of bits ae3 to ae0 in pfcr, the corresponding port a pins are address outputs. when address output is disabled, setting a paddr bit to 1 makes the corresponding port a pin an output port, while clearing the bit to 0 makes the pin an input port. mode 7: setting a paddr bit to 1 makes the corresponding port a pin an output port, while clearing the bit to 0 makes the pin an input port. (h8s/2212 group) setting a paddr bit to 1 makes the corresponding port a pin an output port, while clearing the bit to 0 makes the pin an input port. note: * reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. section 8 i/o ports rev.6.00 jun. 03, 2008 page 234 of 698 rej09b0074-0600 8.6.2 port a data register (padr) padr stores output data for the port a pins. bit bit name initial value r/w description 7 to 4 ? undefined ? reserved these bits are undefined and cannot be modified. 3 2 1 0 pa3dr pa2dr pa1dr pa0dr * 0 0 0 0 r/w r/w r/w r/w store output data for a pin that functions as a general output port. note: * reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. 8.6.3 port a register (porta) porta indicates the pin states of the port a. bit bit name initial value r/w description 7 to 4 ? undefined ? reserved these bits are undefined. 3 2 1 0 pa3 pa2 pa1 pa0 * 2 ? * 1 ? * 1 ? * 1 ? * 1 r r r r if the port a is read while paddr bits are set to 1, the padr value is read. if the port a is read while paddr bits are cleared to 0, the pin states are read. notes: 1. determined by the states of pins pa3 to pa0. 2. reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. section 8 i/o ports rev.6.00 jun. 03, 2008 page 235 of 698 rej09b0074-0600 8.6.4 port a pull-up mos control register (papcr) papcr controls the on/off state of the port a input pull-up mos. papcr is valid for port input and sci input pins. bit bit name initial value r/w description 7 to 4 ? undefined ? reserved these bits are undefined and cannot be modified. 3 2 1 0 pa3pcr pa2pcr pa1pcr pa0pcr * 0 0 0 0 r/w r/w r/w r/w when a pin functions as an input port, setting the corresponding bit to 1 turns on the input pull-up mos for that pin. note: * reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. 8.6.5 port a open-drain control register (paodr) paodr specifies an output type of the port a. paodr is valid for port output and sci output pins. bit bit name initial value r/w description 7 to 4 ? undefined ? reserved these bits are undefined and cannot be modified. 3 2 1 0 pa3odr pa2odr pa1odr pa0odr * 0 0 0 0 r/w r/w r/w r/w setting a paodr bit to 1 makes the corresponding port a pin an nmos open-drain output pin, while clearing the bit to 0 makes the pin a cmos output pin. note: * reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. section 8 i/o ports rev.6.00 jun. 03, 2008 page 236 of 698 rej09b0074-0600 8.6.6 pin functions pin functions of h8s/2218 group port a pins also function as address bus (a19 to a16) output pins and sci_2 i/o pins. the correspondence between the register specification and the pin functions is shown below. table 8.29 pa3 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 b'11 other than b'11 ? cke1 in scr_2 ? 0 1 0 1 c/ a in smr_2 ? 0 1 ? 0 1 ? cke0 in scr_2 ? 0 1 ? ? 0 1 ? ? pa3ddr ? 0 1 ? ? ? 0 1 ? ? ? pin function a19 output pin pa3 input pin pa3 output pin sck2 output pin sck2 output pin sck2 input pin pa3 input pin pa3 output pin sck2 output pin sck2 output pin sck2 input pin table 8.30 pa2 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 b'1011 or b'11 other than b'1011 or b'11 ? re in scr_2 ? 0 1 0 1 pa2ddr ? 0 1 ? 0 1 ? pin function a18 output pin pa2 input pin pa2 output pin rxd2 input pin pa2 input pin pa2 output pin rxd2 input pin legend: : don't care. section 8 i/o ports rev.6.00 jun. 03, 2008 page 237 of 698 rej09b0074-0600 table 8.31 pa1 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 b'101 or b'11 other than b'101 or b'11 ? te in scr_2 ? 0 1 0 1 pa1ddr ? 0 1 ? 0 1 ? pin function a17 output pin pa1 input pin pa1 output pin txd2 output pin pa1 input pin pa1 output pin txd2 output pin table 8.32 pa0 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 other than b'0 or b'1000 b'0 or b'1000 ? pa0ddr ? 0 1 0 1 pin function a16 output pin pa0 input pin pa0 output pin pa0 input pin pa0 output pin legend: : don't care. pin functions of h8s/2212 group port a pins also function as sci_2 i/o pins. th e correspondence between the register specification and the pin functions is shown below. table 8.33 pa3 pin function cke1 in scr_2 0 1 c/ a in smr_2 0 1 ? cke0 in scr_2 0 1 ? ? pa3ddr 0 1 ? ? ? pin function pa3 input pin pa3 output pin sck2 output pin sck2 output pin sck2 input pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 238 of 698 rej09b0074-0600 table 8.34 pa2 pin function re in scr_2 0 1 pa2ddr 0 1 ? pin function pa2 input pin pa2 output pin rxd2 input pin table 8.35 pa1 pin function te in scr_2 0 1 pa1ddr 0 1 ? pin function pa1 input pin pa1 output pin txd2 output pin 8.6.7 port a input pull-up mos states the port a has an on-chip input pull-up mos function that can be controlled by software. the input pull-up mos can be specified as the on or off state for individual bits. table 8.36 summarizes the input pull-up mos states. table 8.36 input pull-up mos states (port a) pins power-on reset hardware standby mode manual reset software standby mode in other operations address output, port output, sci output off off port input, sci input on/off legend: off: input pull-up mos is always off. on/off: on when paddr = 0 and papcr = 1; otherwise off. section 8 i/o ports rev.6.00 jun. 03, 2008 page 239 of 698 rej09b0074-0600 8.7 port b (h8s/2218 group only) the port b is an 8-bit i/o port also functioning as address bus (a15 to a8) output pins. the port b has the following registers. note: when the usb is used while the e6000 emulator is used, the ae3 to ae0 bits in pfcr must be set so that the pb1 and pb0 pins output addresses a9 and a8. this note applies to both the h8s/2218 group and h8s/2212 group. ? port b data direction register (pbddr) ? port b data register (pbdr) ? port b register (portb) ? port b pull-up mos control register (pbpcr) 8.7.1 port b data di rection register (pbddr) pbddr specifies input or output for the pins of the port b. since pbddr is a write-only register, the bit manipulation instructions must not be used to write pbddr. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pb7ddr pb6ddr pb5ddr pb4ddr pb3ddr pb2ddr pb1ddr pb0ddr 0 0 0 0 0 0 0 0 w w w w w w w w modes 4 to 6: if address output is enabled by the setting of bits ae3 to ae0 in pfcr, the corresponding port b pins are address outputs. when address output is disabled, setting a pbddr bit to 1 makes the corresponding port b pin an output port, while clearing the bit to 0 makes the pin an input port. mode 7: setting a pbddr bit to 1 makes the corresponding port b pin an output port, while clearing the bit to 0 makes the pin an input port. section 8 i/o ports rev.6.00 jun. 03, 2008 page 240 of 698 rej09b0074-0600 8.7.2 port b data register (pbdr) pbdr stores output data for the port b pins. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pb7dr pb6dr pb5dr pb4dr pb3dr pb2dr pb1dr pb0dr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w store output data for a pin that functions as a general output port. 8.7.3 port b register (portb) portb indicates the pin states of the port b. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 ? * ? * ? * ? * ? * ? * ? * ? * r r r r r r r r if the port b is read while pbddr bits are set to 1, the pbdr value is read. if the port b is read while pbddr bits are cleared to 0, the pin states are read. note: * determined by the states of pins pb7 to pb0. section 8 i/o ports rev.6.00 jun. 03, 2008 page 241 of 698 rej09b0074-0600 8.7.4 port b pull-up mos control register (pbpcr) pbpcr controls the on/off state of the port b input pull-up mos. pbpcr is valid for port input pins. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pb7pcr pb6pcr pb5pcr pb4pcr pb3pcr pb2pcr pb1pcr pb0pcr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w when a pin functions as an input port, setting the corresponding bit to 1 turns on the input pull-up mos for that pin. section 8 i/o ports rev.6.00 jun. 03, 2008 page 242 of 698 rej09b0074-0600 8.7.5 pin functions port b pins also function as address bus (a15 to a9) output pins. the correspondence between the register specification and the pin functions is shown below. note: when using the usb with the emulator (e6000), set a9 and a8 as address bus output pins. table 8.37 pb7 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 b'1 other than b'1 ? pb7ddr ? 0 1 0 1 pin function a15 output pin pb7 input pin pb7 output pin pb7 input pin pb7 output pin table 8.38 pb6 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 b'0111 or b'1 other than b'0111 or b'1 ? pb6ddr ? 0 1 0 1 pin function a14 output pin pb6 input pin pb6 output pin pb6 input pin pb6 output pin table 8.39 pb5 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 b'011 or b'1 other than b'011 or b'1 ? pb5ddr ? 0 1 0 1 pin function a13 output pin pb5 input pin pb5 output pin pb5 input pin pb5 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 243 of 698 rej09b0074-0600 table 8.40 pb4 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 other than b'0100 or b'00 b'0100 or b'00 ? pb4ddr ? 0 1 0 1 pin function a12 output pin pb4 input pin pb4 output pin pb4 input pin pb4 output pin table 8.41 pb3 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 other than b'00 b'00 ? pb3ddr ? 0 1 0 1 pin function a11 output pin pb3 input pin pb3 output pin pb3 input pin pb3 output pin table 8.42 pb2 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 other than b'0010 or b'000 b'0010 or b'000 ? pb2ddr ? 0 1 0 1 pin function a10 output pin pb2 input pin pb2 output pin pb2 input pin pb2 output pin table 8.43 pb1 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 other than b'000 b'000 ? pb1ddr ? 0 1 0 1 pin function a9 output pin pb1 input pin pb1 output pin pb1 input pin pb1 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 244 of 698 rej09b0074-0600 table 8.44 pb0 pin function operating mode modes 4 to 6 mode 7 ae3 to ae0 other than b'0000 b'0000 ? pb0ddr ? 0 1 0 1 pin function a8 output pin pb0 input pin pb0 output pin pb0 input pin pb0 output pin legend: : don't care. 8.7.6 port b input pull-up mos states the port b has an on-chip input pull-up mos function that can be controlled by software. the input pull-up mos can be specified as the on or off state for individual bits. table 8.45 summarizes the input pull-up mos states. table 8.45 input pull-up mos states (port b) pins power-on reset hardware standby mode manual reset software standby mode in other operations address output, port output off off port input on/off legend: off: input pull-up mos is always off. on/off: on when pbddr = 0 and pbpcr = 1; otherwise off. section 8 i/o ports rev.6.00 jun. 03, 2008 page 245 of 698 rej09b0074-0600 8.8 port c (h8s/2218 group only) the port c is an 8-bit i/o port also functioning as address bus (a7 to a0) output pins. the port c has the following registers. note: when the rtc and usb are used while the e6000 emulator is used, the pc7ddr to pc0ddr bits in pcddr must be set so that the pc7 to pc0 pins output addresses a7 to a0. this note applies to both the h8s/2218 group and h8s/2212 group. ? port c data direction register (pcddr) ? port c data register (pcdr) ? port c register (portc) ? port c pull-up mos control register (pcpcr) 8.8.1 port c data di rection register (pcddr) pcddr specifies input or output for the pins of the port c. since pcddr is a write-only register, the bit manipulation instructions must not be used to write pcddr. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pc7ddr pc6ddr pc5ddr pc4ddr pc3ddr pc2ddr pc1ddr pc0ddr 0 0 0 0 0 0 0 0 w w w w w w w w modes 4 and 5: port c pins are address output pins. mode 6: setting a pcddr bit to 1 makes the corresponding port c pin an address output pin, while clearing the bit to 0 makes the pin an input port. mode 7: setting a pcddr bit to 1 makes the corresponding port c pin an output port, while clearing the bit to 0 makes the pin an input port. section 8 i/o ports rev.6.00 jun. 03, 2008 page 246 of 698 rej09b0074-0600 8.8.2 port c data register (pcdr) pcdr stores output data for the port c pins. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pc7dr pc6dr pc5dr pc4dr pc3dr pc2dr pc1dr pc0dr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w store output data for a pin that functions as a general output port. 8.8.3 port c register (portc) portc indicates the pin states of the port c. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 ? * ? * ? * ? * ? * ? * ? * ? * r r r r r r r r if the port c is read while p cddr bits are set to 1, the pcdr value is read. if the port c is read while pcddr bits are cleared to 0, the pin states are read. note: * determined by the states of pins pc7 to pc0. section 8 i/o ports rev.6.00 jun. 03, 2008 page 247 of 698 rej09b0074-0600 8.8.4 port c pull-up mos control register (pcpcr) pcpcr controls the on/off state of the port c input pull-up mos. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pc7pcr pc6pcr pc5pcr pc4pcr pc3pcr pc2pcr pc1pcr pc0pcr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w when a pin functions as an input port, setting the corresponding bit to 1 turns on the input pull-up mos for that pin. 8.8.5 pin functions port c pins also function as address bus (a7 to a0) output pins. the correspondence between the register specification and the pin functions is shown below. note: when using the rtc and usb with the emulator (e6000), set a7 to a0 as address bus output pins. table 8.46 pc7 pin function operating mode modes 4 and 5 mode 6 mode 7 pc7ddr ? 0 1 0 1 pin function a7 output pin pc7 input pin a7 output pin pc7 input pin pc7 output pin table 8.47 pc6 pin function operating mode modes 4 and 5 mode 6 mode 7 pc6ddr ? 0 1 0 1 pin function a6 output pin pc6 input pin a6 output pin pc6 input pin pc6 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 248 of 698 rej09b0074-0600 table 8.48 pc5 pin function operating mode modes 4 and 5 mode 6 mode 7 pc5ddr ? 0 1 0 1 pin function a5 output pin pc5 input pin a5 output pin pc5 input pin pc5 output pin table 8.49 pc4 pin function operating mode modes 4 and 5 mode 6 mode 7 pc4ddr ? 0 1 0 1 pin function a4 output pin pc4 input pin a4 output pin pc4 input pin pc4 output pin table 8.50 pc3 pin function operating mode modes 4 and 5 mode 6 mode 7 pc3ddr ? 0 1 0 1 pin function a3 output pin pc3 input pin a3 output pin pc3 input pin pc3 output pin table 8.51 pc2 pin function operating mode modes 4 and 5 mode 6 mode 7 pc2ddr ? 0 1 0 1 pin function a2 output pin pc2 input pin a2 output pin pc2 input pin pc2 output pin table 8.52 pc1 pin function operating mode modes 4 and 5 mode 6 mode 7 pc1ddr ? 0 1 0 1 pin function a1 output pin pc1 input pin a1 output pin pc1 input pin pc1 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 249 of 698 rej09b0074-0600 table 8.53 pc0 pin function operating mode modes 4 and 5 mode 6 mode 7 pc0ddr ? 0 1 0 1 pin function a0 output pin pc0 input pin a0 output pin pc0 input pin pc0 output pin 8.8.6 port c input pull-up mos states the port c has an on-chip input pull-up mos function that can be controlled by software. the input pull-up mos can be used in modes 6 and 7, and can be specified as the on or off state for individual bits. table 8.54 summarizes the input pull-up mos states. table 8.54 input pull-up mos states (port c) pins power-on reset hardware standby mode manual reset software standby mode in other operations a ddress output (modes 4 and 5), port output (modes 6 and 7) off off port input (modes 6 and 7) on/off legend: off: input pull-up mos is always off. on/off: on when pcddr = 0 and pcpcr = 1; otherwise off. section 8 i/o ports rev.6.00 jun. 03, 2008 page 250 of 698 rej09b0074-0600 8.9 port d (h8s/2218 group only) the port d is an 8-bit i/o port also functioning as data bus (d15 to d8) i/o pins. the port d has the following registers. ? port d data direction register (pdddr) ? port d data register (pddr) ? port d register (portd) ? port d pull-up mos control register (pdpcr) 8.9.1 port d data di rection register (pdddr) pdddr specifies input or output for the pins of the port d. since pdddr is a write-only register, the bit manipulation instructions must not be used to write pdddr. for details, see section 2.9.4, acce ssing registers containing write-only bits. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pd7ddr pd6ddr pd5ddr pd4ddr pd3ddr pd2ddr pd1ddr pd0ddr 0 0 0 0 0 0 0 0 w w w w w w w w modes 4 to 6: port d pins automatically function as data input/output pins. mode 7: setting a pdddr bit to 1 makes the corresponding port d pin an output port, while clearing the bit to 0 makes the pin an input port. section 8 i/o ports rev.6.00 jun. 03, 2008 page 251 of 698 rej09b0074-0600 8.9.2 port d data register (pddr) pddr stores output data for the port d pins. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pd7dr pd6dr pd5dr pd4dr pd3dr pd2dr pd1dr pd0dr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w store output data for a pin that functions as a general output port. 8.9.3 port d register (portd) portd indicates the pin states of the port d. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 ? * ? * ? * ? * ? * ? * ? * ? * r r r r r r r r if the port d is read while pdddr bits are set to 1, the pddr value is read. if the port d is read while pdddr bits are cleared to 0, the pin states are read. note: after accessing exmdlstp or the rtc register (address range: h'ffff40 to h'ffff5f), you must perform a dummy read to the external address space (such as h'ffef00 to h'ff7ff) outside the range h'ffff40 to h'ffff5f before reading portd. note: * determined by the states of pins pd7 to pd0. section 8 i/o ports rev.6.00 jun. 03, 2008 page 252 of 698 rej09b0074-0600 8.9.4 port d pull-up mos control register (pdpcr) pdpcr controls the on/off state of the port d input pull-up mos. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pd7pcr pd6pcr pd5pcr pd4pcr pd3pcr pd2pcr pd1pcr pd0pcr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w when a pin functions as an input port, setting the corresponding bit to 1 turns on the input pull-up mos for that pin. 8.9.5 pin functions port d pins also function as data bus (d15 to d8) i/o pins. the correspondence between the register specification and the pin functions is shown below. table 8.55 pd7 pin function operating mode modes 4 to 6 mode 7 pd7ddr ? 0 1 pin function d15 input/output pin pd7 input pin pd7 output pin table 8.56 pd6 pin function operating mode modes 4 to 6 mode 7 pd6ddr ? 0 1 pin function d14 input/output pin pd6 input pin pd6 output pin table 8.57 pd5 pin function operating mode modes 4 to 6 mode 7 pd5ddr ? 0 1 pin function d13 input/output pin pd5 input pin pd5 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 253 of 698 rej09b0074-0600 table 8.58 pd4 pin function operating mode modes 4 to 6 mode 7 pd4ddr ? 0 1 pin function d12 input/output pin pd4 input pin pd4 output pin table 8.59 pd3 pin function operating mode modes 4 to 6 mode 7 pd3ddr ? 0 1 pin function d11 input/output pin pd3 input pin pd3 output pin table 8.60 pd2 pin function operating mode modes 4 to 6 mode 7 pd2ddr ? 0 1 pin function d10 input/output pin pd2 input pin pd2 output pin table 8.61 pd1 pin function operating mode modes 4 to 6 mode 7 pd1ddr ? 0 1 pin function d9 input/output pin pd1 input pin pd1 output pin table 8.62 pd0 pin function operating mode modes 4 to 6 mode 7 pd0ddr ? 0 1 pin function d8 input/output pin pd0 input pin pd0 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 254 of 698 rej09b0074-0600 8.9.6 port d input pull-up mos states the port d has an on-chip input pull-up mos function that can be controlled by software. the input pull-up mos can be used in mode 7, and can be specified as the on or off state for individual bits. table 8.63 summarizes the input pull-up mos states. table 8.63 input pull-up mos states (port d) pins power- on reset hardware standby mode manual reset software standby mode in other operations data input/output (modes 4 to 6), port output (mode 7) off off port input (mode 7) on/off legend: off: input pull-up mos is always off. on/off: on when pdddr = 0 and pdpcr = 1; otherwise off. section 8 i/o ports rev.6.00 jun. 03, 2008 page 255 of 698 rej09b0074-0600 8.10 port e the port e is an 8-bit i/o port also functioning as data bus (d7 to d0) i/o pins. the port e has the following registers. ? port e data direction register (peddr) ? port e data register (pedr) ? port e register (porte) ? port e pull-up mos control register (pepcr) 8.10.1 port e data di rection register (peddr) peddr specifies input or output for the pins of the port e. since peddr is a write-only register, the bit manipulation instructions must not be used to write peddr. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pe7ddr pe6ddr pe5ddr pe4ddr pe3ddr pe2ddr pe1ddr pe0ddr 0 0 0 0 0 0 0 0 w w w w w w w w (h8s/2218 group) modes 4 to 6: when 8-bit bus mode is selected, port e functions as an i/o port. setting a peddr bit to 1 makes the corresponding port e pin an output port, while clearing the bit to 0 makes the pin an input port. when 16-bit bus mode is selected, the input/output direction settings in peddr are ignored, and port e pins automatically function as data input/output pins. for details on 8-bit/16-bit bus mode, refer to section 6, bus controller. mode 7: setting a peddr bit to 1 makes the corresponding port e pin an output port, while clearing the bit to 0 makes the pin an input port. (h8s/2212 group) setting a peddr bit to 1 makes the corresponding port e pin an output port, while clearing the bit to 0 makes the pin an input port. section 8 i/o ports rev.6.00 jun. 03, 2008 page 256 of 698 rej09b0074-0600 8.10.2 port e data register (pedr) pedr stores output data for the port e pins. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pe7dr pe6dr pe5dr pe4dr pe3dr pe2dr pe1dr pe0dr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w store output data for a pin that functions as a general output port. 8.10.3 port e register (porte) porte indicates the pin states of the port e. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 ? * ? * ? * ? * ? * ? * ? * ? * r r r r r r r r if the port e is read while peddr bits are set to 1, the pedr value is read. if the port e is read while peddr bits are cleared to 0, the pin states are read. note: * determined by the states of pins pe7 to pe0. section 8 i/o ports rev.6.00 jun. 03, 2008 page 257 of 698 rej09b0074-0600 8.10.4 port e pull-up mos control register (pepcr) pepcr controls the on/off state of the port e input pull-up mos. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pe7pcr pe6pcr pe5pcr pe4pcr pe3pcr pe2pcr pe1pcr pe0pcr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w when a pin functions as an input port, setting the corresponding bit to 1 turns on the input pull-up mos for that pin. 8.10.5 pin functions pin functions of h8s/2218 group port e pins also function as data bus (d7 to d0 ) i/o pins. the correspondence between the register specification and the pin function is shown below. table 8.64 pe7 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe7ddr 0 1 ? 0 1 pin function pe7 input pin pe7 output pin d7 input/output pin pe7 input pin pe7 output pin table 8.65 pe6 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe6ddr 0 1 ? 0 1 pin function pe6 input pin pe6 output pin d6 input/output pin pe6 input pin pe6 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 258 of 698 rej09b0074-0600 table 8.66 pe5 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe5ddr 0 1 ? 0 1 pin function pe5 input pin pe5 output pin d5 input/output pin pe5 input pin pe5 output pin table 8.67 pe4 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe4ddr 0 1 ? 0 1 pin function pe4 input pin pe4 output pin d4 input/output pin pe4 input pin pe4 output pin table 8.68 pe3 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe3ddr 0 1 ? 0 1 pin function pe3 input pin pe3 output pin d3 input/output pin pe3 input pin pe3 output pin table 8.69 pe2 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe2ddr 0 1 ? 0 1 pin function pe2 input pin pe2 output pin d2 input/output pin pe2 input pin pe2 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 259 of 698 rej09b0074-0600 table 8.70 pe1 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe1ddr 0 1 ? 0 1 pin function pe1 input pin pe1 output pin d1 input/output pin pe1 input pin pe1 output pin table 8.71 pe0 pin function operating mode modes 4 to 6 mode 7 bus mode 8-bit bus mode 16-bit bus mode ? pe0ddr 0 1 ? 0 1 pin function pe0 input pin pe0 output pin d0 input/output pin pe0 input pin pe0 output pin pin functions of h8s/2212 group the port e function as a general i/o port. the correspondence between the register specification and the pin function is shown below. table 8.72 pe7 pin function pe7ddr 0 1 pin function pe7 input pin pe7 output pin table 8.73 pe6 pin function pe6ddr 0 1 pin function pe6 input pin pe6 output pin table 8.74 pe5 pin function pe5ddr 0 1 pin function pe5 input pin pe5 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 260 of 698 rej09b0074-0600 table 8.75 pe4 pin function pe4ddr 0 1 pin function pe4 input pin pe4 output pin table 8.76 pe3 pin function pe3ddr 0 1 pin function pe3 input pin pe3 output pin table 8.77 pe2 pin function pe2ddr 0 1 pin function pe2 input pin pe2 output pin table 8.78 pe1 pin function pe1ddr 0 1 pin function pe1 input pin pe1 output pin table 8.79 pe0 pin function pe0ddr 0 1 pin function pe0 input pin pe0 output pin 8.10.6 port e input pull-up mos states the port e has an on-chip input pull-up mos function that can be controlled by software. the input pull-up mos can be used in modes 4 to 6 and in 8-bit bus mode, or in mode 7, and can be specified as the on or off state for individual bits. table 8.80 summarizes the input pull-up mos states. section 8 i/o ports rev.6.00 jun. 03, 2008 page 261 of 698 rej09b0074-0600 table 8.80 input pull-up mos states (port e) pins power-on reset hardware standby mode manual reset software standby mode in other operations data input/output (16-bit bus mode in modes 4 to 6), port output (8-bit bus mode in modes 4 to 6, mode 7) off off port input (8-bit bus mode in modes 4 to 6, mode 7) on/off legend: off: input pull-up mos is always off. on/off: on when peddr = 0 and pepcr = 1; otherwise off. 8.11 port f in the h8s/2218 group, the port f is an 8-bit i/o port also functioning as external interrupt input ( irq2 , irq3 ) pins, bus control signal i/o pins, and system clock output pins. in the h8s/2212 group, the port f is a 3-bit i/o port also functioning as external interrupt input ( irq2 , irq3 ) pins and system clock output pins. the port f has the following registers. ? port f data direction register (pfddr) ? port f data register (pfdr) ? port f register (portf) section 8 i/o ports rev.6.00 jun. 03, 2008 page 262 of 698 rej09b0074-0600 8.11.1 port f data di rection register (pfddr) pfddr specifies input or output for the pins of the port f. since pfddr is a write-only register, the bit manipulation instructions must not be used to write pfddr. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pf7ddr pf6ddr * 2 pf5ddr * 2 pf4ddr * 2 pf3ddr pf2ddr * 2 pf1ddr * 2 pf0ddr 1/0 * 1 0 0 0 0 0 0 0 w w w w w w w w (h8s/2218 group) modes 4 to 6: pin pf7 functions as the output pin when the pf7ddr bit is set to 1, and as an input port when the bit is cleared to 0. pins pf6 to pf3 are automatically designated as bus control output pins. pins pf2 to pf0 are made bus control input/output pins by bus controller settings. otherwise, setting a pfddr bit to 1 makes the corresponding pin an output port, while clearing the bit to 0 makes the pin an input port. mode 7 setting a pfddr bit to 1 makes the corresponding port f pin pf6 to pf0 an output port, or in the case of pin pf7, the output pin. clearing the bit to 0 makes the pin an input port. (h8s/2212 group) setting a pfddr bit to 1 makes the corresponding port f pin pf6 to pf0 an output port, or in the case of pin pf7, the output pin. clearing the bit to 0 makes the pin an input port. notes: 1. the initial value becomes 1 in modes 4 to 6 and 0 in mode 7. 2. reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. section 8 i/o ports rev.6.00 jun. 03, 2008 page 263 of 698 rej09b0074-0600 8.11.2 port f data register (pfdr) pfdr stores output data for the port f pins. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pf7dr pf6dr * pf5dr * pf4dr * pf3dr pf2dr * pf1dr * pf0dr 0 0 0 0 0 0 0 0 r/w r/w r/w r/w r/w r/w r/w r/w store output data for a pin that functions as a general output port. note: * reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. 8.11.3 port f register (portf) portf indicates the pin states of the port f. bit bit name initial value r/w description 7 6 5 4 3 2 1 0 pf7 pf6 * 2 pf5 * 2 pf4 * 2 pf3 pf2 * 2 pf1 * 2 pf0 ? * 1 ? * 1 ? * 1 ? * 1 ? * 1 ? * 1 ? * 1 ? * 1 r r r r r r r r if the port f is read while pfddr bits are set to 1, the pfdr value is read. if the port f is read while pfddr bits are cleared to 0, the pin states are read. notes: 1. determined by the states of pins pf7 to pf0. 2. reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. section 8 i/o ports rev.6.00 jun. 03, 2008 page 264 of 698 rej09b0074-0600 8.11.4 clock output control register (outcr) outcr specifies the clock frequency output from the pf7 pin. bit bit name initial value r/w description 7 to 3 ? undefined ? reserved the write value should always be 0. 2 1 0 pf7out2 pf7out1 pf7out0 0 0 0 r/w r/w r/w pf7 pin output select 2 to 0 000: main oscillation clock 001: outputs 1/2 of main oscillation clock 010: outputs 1/3 of main oscillation clock 011: outputs 1/4 of main oscillation clock 1xx: reserved this function is not supported by the e6000 emulator. in section 22, electrical characteristics is in the case when pf7out2 to pf7out0 = 000. 8.11.5 pin functions pin functions of h8s/2218 group the port f is an 8-bit i/o port. port f pins also function as external interrupt input ( irq2 , irq3 ) pins, bus control signal i/o pins, and system clock output ( ) pins. the correspondence between the register specification and the pin functions is shown below. table 8.81 pf7 pin function pf7ddr 0 1 pf7out2 to pf7out0 ? b'000 b'001 b'010 b'011 pin function pf7 input pin output pin /2 output pin /3 output pin /4 output pin table 8.82 pf6 pin function operating mode modes 4 to 6 mode 7 pf6ddr ? 0 1 pin function as output pin pf6 input pin pf6 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 265 of 698 rej09b0074-0600 table 8.83 pf5 pin function operating mode modes 4 to 6 mode 7 pf5ddr ? 0 1 pin function rd output pin pf5 input pin pf5 output pin table 8.84 pf4 pin function operating mode modes 4 to 6 mode 7 pf4ddr ? 0 1 pin function hwr output pin pf4 input pin pf4 output pin table 8.85 pf3 pin function operating mode modes 4 to 6 mode 7 bus mode 16-bit bus mode 8-bit bus mode ? pf3ddr ? 0 1 0 1 pf3 input pin pf3 output pin pf3 input pin pf3 output pin adtrg input pin * 1 pin function lwr output pin irq3 input pin * 2 notes: 1. adtrg input pin when trgs0 = trgs1 = 1. 2. when this pin is used as an external interrupt input pin, this pin must not be used as an i/o pin for another function. table 8.86 pf2 pin function operating mode modes 4 to 6 mode 7 waite 0 1 ? pf2ddr 0 1 ? 0 1 pin function pf2 input pin pf2 output pin wait input pin pf2 input pin pf2 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 266 of 698 rej09b0074-0600 table 8.87 pf1 pin function operating mode modes 4 to 6 mode 7 brle 0 1 ? pf1ddr 0 1 ? 0 1 pin function pf1 input pin pf1 output pin back output pin pf1 input pin pf1 output pin table 8.88 pf0 pin function operating mode modes 4 to 6 mode 7 brle 0 1 ? pf0ddr 0 1 ? 0 1 pf0 input pin pf0 output pin breq input pin pf0 input pin pf0 output pin pin function irq2 input pin * note: * when this pin is used as an external interrupt input pin, this pin must not be used as an i/o pin for another function. pin functions of h8s/2212 group the port f is a 3-bit i/o port. port f pins also function as external interrupt input ( irq2 , irq3 ) pins and system clock output ( ) pins. the correspondence between the register specification and the pin functions is shown below. table 8.89 pf7 pin function pf7ddr 0 1 pf7out2 to pf7out0 ? b'000 b'001 b'010 b'011 pin function pf7 input pin output pin /2 output pin /3 output pin /4 output pin section 8 i/o ports rev.6.00 jun. 03, 2008 page 267 of 698 rej09b0074-0600 table 8.90 pf3 pin function pf3ddr 0 1 pf3 input pin pf3 output pin adtrg input pin * 1 pin function irq3 input pin * 2 notes: 1. adtrg input pin when trgs0 = trgs1 = 1. 2. when this pin is used as an external interrupt input pin, this pin must not be used as an i/o pin for another function. table 8.91 pf0 pin function pf0ddr 0 1 pf0 input pin pf0 output pin pin function irq2 input pin * note: * when this pin is used as an external interrupt input pin, this pin must not be used as an i/o pin for another function. 8.12 port g in the h8s/2218 group, the port g is a 4-bit i/o port also functioning as external interrupt input ( irq7 ) pins and bus control output ( cs0 to cs3 ) pins. in the h8s/2212 group, the port g is a 2- bit i/o port also functioning as external interrupt input ( irq7 ) pins and h-udi (tdi) pins. the port g has the following registers. ? port g data direction register (pgddr) ? port g data register (pgdr) ? port g register (portg) section 8 i/o ports rev.6.00 jun. 03, 2008 page 268 of 698 rej09b0074-0600 8.12.1 port g data direction register (pgddr) pgddr specifies input or output for the pins of the port g. since pgddr is a write-only register, the bit manipulation instructions must not be used to write pgddr. for details, see section 2.9.4, acce ssing registers containing write-only bits. bit bit name initial value r/w description 7 to 5 ? undefined ? reserved these bits are undefined and cannot be modified. 4 3 2 1 pg4ddr * 2 pg3ddr * 2 pg2ddr * 2 pg1ddr 0/1 * 1 0 0 0 w w w w (h8s/2218 group) modes 4 to 6: setting a pgddr bit to 1 makes the pg4 to pg1 pins bus control signal output pins, while clearing the bit to 0 makes the pins input ports. mode 7: setting a pgddr bit to 1 makes the corresponding port g pin an output port, while clearing the bit to 0 makes the pin an input port. (h8s/2212 group) setting a pg1ddr bit to 1 makes the corresponding port g pin an output port, while clearing the bit to 0 makes the pin an input port. 0 pg0ddr * 3 0 w (h8s/2212 group) when emle = 1: pin pg0 function as the h-udi (tdi) pin. when emle = 0: if a pg0ddr bit is set to 1, pin pg0 function as output ports. if a pg0ddr bit is cleared to 0, pin pg0 function as input ports. notes: 1. the initial value becomes 1 in modes 4 and 5 and 0 in modes 6 and 7. 2. reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. 3. reserved in the h8s/2218 group. if this bit is read, an undefined value will be read. this bit cannot be modified. section 8 i/o ports rev.6.00 jun. 03, 2008 page 269 of 698 rej09b0074-0600 8.12.2 port g data register (pgdr) pgdr stores output data for the port g pins. bit bit name initial value r/w description 7 to 5 ? undefined ? reserved these bits are undefined and cannot be modified. 4 3 2 1 0 pg4dr * 1 pg3dr * 1 pg2dr * 1 pg1dr pg0dr * 2 0 0 0 0 0 r/w r/w r/w r/w r/w store output data for a pin that functions as a general output port. notes: 1. reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. this bit cannot be modified. 2. reserved in the h8s/2218 group. if this bit is read, an undefined value will be read. this bit cannot be modified. 8.12.3 port g register (portg) portg indicates the pin states of the port g. bit bit name initial value r/w description 7 to 5 ? undefined ? reserved these bits are undefined. 4 3 2 1 0 pg4 * 2 pg3 * 2 pg2 * 2 pg1 pg0 * 3 ? * 1 ? * 1 ? * 1 ? * 1 ? * 1 r r r r r if the port g is read while pgddr bits are set to 1, the pgdr value is read. if the port g is read while pgddr bits are cleared to 0, the pin states are read. notes: 1. determined by the states of pins pg4 to pg0. 2. reserved in the h8s/2212 group. if this bit is read, an undefined value will be read. 3. reserved in the h8s/2218 group. if this bit is read, an undefined value will be read. section 8 i/o ports rev.6.00 jun. 03, 2008 page 270 of 698 rej09b0074-0600 8.12.4 pin functions pin functions of h8s/2218 group port g pins also function as external interrupt input ( irq7 ) pins and bus control signal output ( cs0 to cs3 ) pins. the correspondence between the register specification and the pin functions is shown below. table 8.92 pg4 pin function operating mode modes 4 to 6 mode 7 pg4ddr 0 1 0 1 pin function pg4 input pin cs0 output pin pg4 input pin pg4 output pin table 8.93 pg3 pin function operating mode modes 4 to 6 mode 7 pg3ddr 0 1 0 1 pin function pg3 input pin cs1 output pin pg3 input pin pg3 output pin table 8.94 pg2 pin function operating mode modes 4 to 6 mode 7 pg2ddr 0 1 0 1 pin function pg2 input pin cs2 output pin pg2 input pin pg2 output pin table 8.95 pg1 pin function operating mode modes 4 to 6 mode 7 pg1ddr 0 1 0 1 pg1 input pin cs3 output pin pg1 input pin pg1 output pin pin function irq7 input pin * note: * when this pin is used as an external interrupt input pin, this pin must not be used as an i/o pin for another function. section 8 i/o ports rev.6.00 jun. 03, 2008 page 271 of 698 rej09b0074-0600 pin functions of h8s/2212 group port g pins also function as external interrupt input ( irq7 ) pins and h-udi (tdi) pins. the correspondence between the register specification and the pin functions is shown below. table 8.96 pg1 pin function pg1ddr 0 1 pg1 input pin pg1 output pin pin function irq7 input pin * note: * when this pin is used as an external interrupt input pin, this pin must not be used as an i/o pin for another function. table 8.97 pg0 pin function emle 0 1 pg0ddr 0 1 ? pin function pg0 input pin pg0 output pin tdi input pin 8.13 handling of unused pins unused input pins should be fixed high or low. generally, the input pins of cmos products are high-impedance. leaving unused pins open can cause the generation of intermediate levels due to peripheral noise induction. this can result in shoot-through current inside the device and cause it to malfunction. table 8.98 lists examples of ways to handle unused pins. for the handling of dedicated boundary scan pins that are unused, see section 13.2, pin configuration, and section 13.5, usage notes. pins marked nc should be left open. for the handling of dedicated usb pins that are unused, see section 14.8.14, pin processing when usb not used. section 8 i/o ports rev.6.00 jun. 03, 2008 page 272 of 698 rej09b0074-0600 table 8.98 examples of ways to handle unused input pins port name pin handling example port 1 port 3 connect each pin to vcc (pull-up) or to vss (pull-down) via a resistor. port 4 connect each pin to avcc (pull-up) or to avss (pull-down) via a resistor. port 7 connect each pin to vcc (pull-up) or to vss (pull-down) via a resistor. port 9 connect each pin to avcc (pull-up) or to avss (pull-down) via a resistor. port a port b * port c * port d * port e port f connect each pin to vcc (pull-up) or to vss (pull-down) via a resistor. * ports b, c, and d apply to the h8s/2218 group only. port g section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 273 of 698 rej09b0074-0600 section 9 16-bit timer pulse unit (tpu) this lsi has an on-chip 16-bit timer pulse unit (tpu) that comprises three 16-bit timer channels. the function list of the 16-bit timer unit and its block diagram are shown in table 9.1 and figure 9.1, respectively. 9.1 features ? maximum 8-pulse input/output ? selection of 8 counter input clocks for each channel ? the following operations can be set for each channel waveform output at compare match, input capture function, counter clear operation, simultaneous writing to multiple timer counters (tcnt), simultaneous clearing using compare match or input capture, simultaneous input/output for individual registers using counter synchronous operation, pwm output using user-defined duty, up to 7-phase pwm output by combination with synchronous operation ? buffer operation settable for channel 0 ? phase counting mode settable independently for each of channels 1 and 2 ? fast access via internal 16-bit bus ? 13 interrupt sources ? automatic transfer of register data ? a/d converter conversion start trigger can be generated ? module stop mode can be set ? baud rate clock for the sci0 can be generated timtpu2c_000020020900 section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 274 of 698 rej09b0074-0600 channel 2 tmdr tsr tcr tior tier tgra tcnt tgrb tgrc channel 1 tmdr tsr tcr tior tier tgra tcnt tgrb channel 0 control logic for channel 0 to 2 tgra tcnt tgrb tgrd bus interface common tsyr control logic tstr /1 /4 /16 /64 /256 /1024 tclka tclkb tclkc tclkd legend: tstr: tsyr: tcr: tmdr: timer start register timer synchro register timer control register timer mode register timer i/o control registers (h, l) timer interrupt enable register timer status register timer general registers (a, b, c, d) tioca0 tiocb0 tiocc0 tiocd0 tioca1 tiocb1 tioca2 tiocb2 interrupt request signals channel 0: channel 1: channel 2: internal data bus a/d converter convertion start signal module data bus tgi0a tgi0b tgi0c tgi0d tci0v tgi1a tgi1b tci1v tci1u tgi2a tgi2b tci2v tci2u tmdr tsr tcr tiorh tier tiorl input/output pins channel 0: channel 1: channel 2: clock input internal clock: external clock: tior(h, l): tier: tsr: tgr(a, b, c, d): figure 9.1 block diagram of tpu section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 275 of 698 rej09b0074-0600 table 9.1 tpu functions item channel 0 channel 1 channel 2 count clock /1 /4 /16 /64 tclka tclkb tclkc tclkd /1 /4 /16 /64 /256 tclka tclkb /1 /4 /16 /64 /1024 tclka tclkb tclkc general registers tgra_0 tgrb_0 tgra_1 tgrb_1 tgra_2 tgrb_2 general registers/buffer registers tgrc_0 tgrd_0 ? ? i/o pins tioca0 tiocb0 tiocc0 tiocd0 tioca1 tiocb1 tioca2 tiocb2 counter clear function tgr compare match or input capture tgr compare match or input capture tgr compare match or input capture 0 output o o o 1 output o o o compare match output toggle output o o o input capture function o o o synchronous operation o o o pwm mode o o o phase counting mode ? o o buffer operation o ? ? section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 276 of 698 rej09b0074-0600 item channel 0 channel 1 channel 2 dmac activation tgra_0 compare match or input capture tgra_1 compare match or input capture tgra_2 compare match or input capture a/d converter trigger tgra_0 compare match or input capture tgra_1 compare match or input capture tgra_2 compare match or input capture interrupt sources 5 sources ? compare match or input capture 0a ? compare match or input capture 0b ? compare match or input capture 0c ? compare match or input capture 0d ? overflow 4 sources ? compare match or input capture 1a ? compare match or input capture 1b ? overflow ? underflow 4 sources ? compare match or input capture 2a ? compare match or input capture 2b ? overflow ? underflow legend: o: possible ?: not possible section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 277 of 698 rej09b0074-0600 9.2 input/output pins table 9.2 pin configuration channel symbol i/o function tclka input external clock a input pin (channel 1 phase counting mode a phase input) tclkb input external clock b input pin (channel 1 phase counting mode b phase input) tclkc input external clock c input pin (channel 2 phase counting mode a phase input) all tclkd input external clock d input pin (channel 2 phase counting mode b phase input) tioca0 i/o tgra_0 input capture input/output compare output/pwm output pin tiocb0 i/o tgrb_0 input capture input/output compare output/pwm output pin tiocc0 i/o tgrc_0 input capture input/output compare output/pwm output pin 0 tiocd0 i/o tgrd_0 input capture input/output compare output/pwm output pin tioca1 i/o tgra_1 input capture input/output compare output/pwm output pin 1 tiocb1 i/o tgrb_1 input capture input/output compare output/pwm output pin 2 tioca2 i/o tgra_2 input capture input/output compare output/pwm output pin tiocb2 i/o tgra_2 input capture input/output compare output/pwm output pin section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 278 of 698 rej09b0074-0600 9.3 register descriptions the tpu has the following registers. ? timer control register_0 (tcr_0) ? timer mode register_0 (tmdr_0) ? timer i/o control register h_0 (tiorh_0) ? timer i/o control register l_0 (tiorl_0) ? timer interrupt enable register_0 (tier_0) ? timer status register_0 (tsr_0) ? timer counter_0 (tcnt_0) ? timer general register a_0 (tgra_0) ? timer general register b_0 (tgrb_0) ? timer general register c_0 (tgrc_0) ? timer general register d_0 (tgrd_0) ? timer control register_1 (tcr_1) ? timer mode register_1 (tmdr_1) ? timer i/o control register _1 (tior_1) ? timer interrupt enable register_1 (tier_1) ? timer status register_1 (tsr_1) ? timer counter_1 (tcnt_1) ? timer general register a_1 (tgra_1) ? timer general register b_1 (tgrb_1) ? timer control register_2 (tcr_2) ? timer mode register_2 (tmdr_2) ? timer i/o control register_2 (tior_2) ? timer interrupt enable register_2 (tier_2) ? timer status register_2 (tsr_2) ? timer counter_2 (tcnt_2) ? timer general register a_2 (tgra_2) ? timer general register b_2 (tgrb_2) common registers ? timer start register (tstr) ? timer synchro register (tsyr) section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 279 of 698 rej09b0074-0600 9.3.1 timer control register (tcr) the tcr registers control the tcnt operation for each channel. the tpu has a total of three tcr registers, one for each channel (channel 0 to 2). tcr register settings should be made only when tcnt operation is stopped. bit bit name initial value r/w description 7 6 5 cclr2 cclr1 cclr0 0 0 0 r/w r/w r/w counter clear 2 to 0 these bits select the tcntcounter clearing source. see tables 9.3 and 9.4 for details. 4 3 ckeg1 ckeg0 0 0 r/w r/w clock edge 1 and 0 these bits select the input clock edge. when the internal clock is counted using both edges, the input clock frequency is halved (e.g., /4 both edges = /2 rising edge). if phase counting mode is used on channels 1, 2, 4, and 5, this setting is ignored and the phase counting mode setting has priority. internal clock edge selection is valid when the input clock is /4 or slower. if /1 is selected as the input clock, this setting is ignored and count at falling edge of is selected. 00: count at rising edge 01: count at falling edge 1 : count at both edges legend: : don?t care 2 1 0 tpsc2 tpsc1 tpsc0 0 0 0 r/w r/w r/w time prescaler 2 to 0 these bits select the tcnt counter clock. the clock source can be selected independently for each channel. see tables 9.5 to 9.7 for details. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 280 of 698 rej09b0074-0600 table 9.3 cclr2 to cclr0 (channel 0) bit 7 bit 6 bit 5 channel cclr2 cclr1 cclr0 description 0 0 0 0 tcnt clearing disabled 1 tcnt cleared by tgra compare match/input capture 1 0 tcnt cleared by tgrb compare match/input capture 1 tcnt cleared by counter clearing for another channel performing synchronous clearing/synchronous operation * 1 1 0 0 tcnt clearing disabled 1 tcnt cleared by tgrc compare match/input capture * 2 1 0 tcnt cleared by tgrd compare match/input capture * 2 1 tcnt cleared by counter clearing for another channel performing synchronous clearing/synchronous operation * 1 notes: 1. synchronous operation setting is performed by setting the sync bit in tsyr to 1. 2. when tgrc or tgrd is used as a buffer register. tcnt is not cleared because the buffer register setting has priority, and compare match/input capture dose not occur. table 9.4 cclr2 to cclr0 (channels 1 and 2) bit 7 bit 6 bit 5 channel reserved * 2 cclr1 cclr0 description 1, 2 0 0 0 tcnt clearing disabled 1 tcnt cleared by tgra compare match/input capture 1 0 tcnt cleared by tgrb compare match/input capture 1 tcnt cleared by counter clearing for another channel performing synchronous clearing/synchronous operation * 1 notes: 1. synchronous operation setting is performed by setting the sync bit in tsyr to 1. 2. bit 7 is reserved in channels 1 and 2. it is always read as 0 and cannot be modified. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 281 of 698 rej09b0074-0600 table 9.5 tpsc2 to tpsc0 (channel 0) bit 2 bit 1 bit 0 channel tpsc2 tpsc1 tpsc0 description 0 0 0 0 internal clock: counts on /1 1 internal clock: counts on /4 1 0 internal clock: counts on /16 1 internal clock: counts on /64 1 0 0 external clock: counts on tclka pin input 1 external clock: counts on tclkb pin input 1 0 external clock: counts on tclkc pin input 1 external clock: counts on tclkd pin input table 9.6 tpsc2 to tpsc0 (channel 1) bit 2 bit 1 bit 0 channel tpsc2 tpsc1 tpsc0 description 1 0 0 0 internal clock: counts on /1 1 internal clock: counts on /4 1 0 internal clock: counts on /16 1 internal clock: counts on /64 1 0 0 external clock: counts on tclka pin input 1 external clock: counts on tclkb pin input 1 0 internal clock: counts on /256 1 setting prohibited note: this setting is ignored when channel 1 is in phase counting mode. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 282 of 698 rej09b0074-0600 table 9.7 tpsc2 to tpsc0 (channel 2) bit 2 bit 1 bit 0 channel tpsc2 tpsc1 tpsc0 description 2 0 0 0 internal clock: counts on /1 1 internal clock: counts on /4 1 0 internal clock: counts on /16 1 internal clock: counts on /64 1 0 0 external clock: counts on tclka pin input 1 external clock: counts on tclkb pin input 1 0 external clock: counts on tclkc pin input 1 internal clock: counts on /1024 note: this setting is ignored when channel 1 is in phase counting mode. 9.3.2 timer mode register (tmdr) the tmdr registers are used to set the operating mode for each channel. the tpu has three tmdr registers, one for each channel. tmdr register settings should be made only when tcnt operation is stopped. bit bit name initial value r/w description 7, 6 ? all 1 ? reserved these bits are always read as 1 and cannot be modified. 5 bfb 0 r/w buffer operation b specifies whether tgrb is to operate in the normal way, or tgrb and tgrd are to be used together for buffer operation. when tgrd is used as a buffer register. tgrd input capture/output compare is not generation. in channels 1 and 2, which have no tgrd, bit 5 is reserved. it is always read as 0 and cannot be modified. 0: tgrb operates normally 1: tgrb and tgrd used together for buffer operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 283 of 698 rej09b0074-0600 bit bit name initial value r/w description 4 bfa 0 r/w buffer operation a specifies whether tgra is to operate in the normal way, or tgra and tgrc are to be used together for buffer operation. when tgrc is used as a buffer register, tgrc input capture/output compare is not generated. in channels 1 and 2, which have no tgrc, bit 4 is reserved. it is always read as 0 and cannot be modified. 0: tgra operates normally 1: tgra and tgrc used together for buffer operation 3 2 1 0 md3 md2 md1 md0 0 0 0 0 r/w r/w r/w r/w modes 3 to 0 these bits are used to set the timer operating mode. md3 is a reserved bit. in a write, the write value should always be 0. see table 9.8, for details. table 9.8 md3 to md0 bit 3 bit2 bit 1 bit 0 md3 * 1 md2 * 2 md1 md0 description 0 normal operation 0 1 reserved 0 pwm mode 1 0 1 1 pwm mode 2 0 phase counting mode 1 0 1 phase counting mode 2 0 phase counting mode 3 0 1 1 1 phase counting mode 4 1 ? legend: : don?t care notes: 1. md3 is reserved bit. in a write, it should be written with 0. 2. phase counting mode cannot be set for channels 0 and 3. in this case, 0 should always be written to md2. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 284 of 698 rej09b0074-0600 9.3.3 timer i/o control register (tior) the tior registers control the tgr registers. the tpu has eight tior registers, two each for channels 0, and one each for channels 1 and 2. care is required since tior is affected by the tmdr setting. the initial output specified by tior is valid when the counter is stopped (the cst bit in tstr is cleared to 0). note also that, in pwm mode 2, the output at the point at which the counter is cleared to 0 is specified. when tgrc or tgrd is designated for buffer operation, this setting is invalid and the register operates as a buffer register. ? tiorh_0, tior_1, tior_2 bit bit name initial value r/w description 7 6 5 4 iob3 iob2 iob1 iob0 0 0 0 0 r/w r/w r/w r/w i/o control b3 to b0 specify the function of tgrb. 3 2 1 0 ioa3 ioa2 ioa1 ioa0 0 0 0 0 r/w r/w r/w r/w i/o control a3 to a0 specify the function of tgra. ? tiorl_0 bit bit name initial value r/w description 7 6 5 4 iod3 iod2 iod1 iod0 0 0 0 0 r/w r/w r/w r/w i/o control d3 to d0 specify the function of tgrd. 3 2 1 0 ioc3 ioc2 ioc1 ioc0 0 0 0 0 r/w r/w r/w r/w i/o control c3 to c0 specify the function of tgrc. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 285 of 698 rej09b0074-0600 table 9.9 tiorh_0 (channel 0) description bit 7 bit 6 bit 5 bit 4 iob3 iob2 iob1 iob0 tgrb_0 function tiocb0 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 1 output at compare match 0 1 1 1 output compare register initial output is 1 output toggle output at compare match 1 0 input capture register capture input source is tiocb0 pin input capture at rising edge 0 1 capture input source is tiocb0 pin input capture at falling edge 0 1 capture input source is tiocb0 pin input capture at both edges 1 setting prohibited legend: : don?t care section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 286 of 698 rej09b0074-0600 table 9.10 tiorh_0 (channel 0) description bit 3 bit 2 bit 1 bit 0 ioa3 ioa2 ioa1 ioa0 tgra_0 function tioca0 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 1 output at compare match 0 1 1 1 output compare register initial output is 1 output toggle output at compare match 1 0 input capture register capture input source is tioca0 pin input capture at rising edge 0 1 capture input source is tioca0 pin input capture at falling edge 0 1 capture input source is tioca0 pin input capture at both edges 1 setting prohibited legend: : don?t care section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 287 of 698 rej09b0074-0600 table 9.11 tiorl_0 (channel 0) description bit 7 bit 6 bit 5 bit 4 iod3 iod2 iod1 iod0 tgrd_0 function tiocd0 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 0 1 1 1 output compare register * initial output is 1 output toggle output at compare match 1 0 input capture register * capture input source is tiocd0 pin input capture at rising edge 0 1 capture input source is tiocd0 pin input capture at falling edge 0 1 capture input source is tiocd0 pin input capture at both edges 1 setting prohibited legend: : don?t care note: * when the bfb bit in tmdr_0 is set to 1 and tgrd_0 is used as a buffer register, this setting is invalid and input capture/output compare is not generated. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 288 of 698 rej09b0074-0600 table 9.12 tiorl_0 (channel 0) description bit 3 bit 2 bit 1 bit 1 ioc3 ioc2 ioc1 ioc0 tgrc_0 function tiocc0 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 1 output at compare match 0 1 1 1 output compare register * initial output is 1 output toggle output at compare match 1 0 input capture register * capture input source is tiocc0 pin input capture at rising edge 0 1 capture input source is tiocc0 pin input capture at falling edge 0 1 capture input source is tiocc0 pin input capture at both edges 1 setting prohibited legend: : don?t care note: * when the bfa bit in tmdr_0 is set to 1and tgrc_0 is used as a buffer register, this setting is invalid and input capture/output compare is not generated. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 289 of 698 rej09b0074-0600 table 9.13 tior_1 (channel 1) description bit 7 bit 6 bit 5 bit 4 iob3 iob2 iob1 iob0 tgrb_1 function tiocb1 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 1 output at compare match 0 1 1 1 output compare register initial output is 1 output toggle output at compare match 1 0 input capture register capture input source is tiocb1 pin input capture at rising edge 0 1 capture input source is tiocb1 pin input capture at falling edge 0 1 capture input source is tiocb1 pin input capture at both edges 1 setting prohibited legend: : don?t care section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 290 of 698 rej09b0074-0600 table 9.14 tior_1 (channel 1) description bit 3 bit 2 bit 1 bit 0 ioa3 ioa2 ioa1 ioa0 tgra_1 function tioca1 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 1 output at compare match 0 1 1 1 output compare register initial output is 1 output toggle output at compare match 1 0 input capture register capture input source is tioca1 pin input capture at rising edge 0 1 capture input source is tioca1 pin input capture at falling edge 0 1 capture input source is tioca1 pin input capture at both edges 1 setting prohibited legend: : don?t care section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 291 of 698 rej09b0074-0600 table 9.15 tior_2 (channel 2) description bit 7 bit 6 bit 5 bit 4 iob3 iob2 iob1 iob0 tgrb_2 function tiocb2 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 1 output at compare match 0 1 1 1 output compare register initial output is 1 output toggle output at compare match 1 0 input capture register capture input source is tiocb2 pin input capture at rising edge 0 1 capture input source is tiocb2 pin input capture at falling edge 1 capture input source is tiocb2 pin input capture at both edges legend: : don?t care section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 292 of 698 rej09b0074-0600 table 9.16 tior_2 (channel 2) description bit 3 bit 2 bit 1 bit 0 ioa3 ioa2 ioa1 ioa0 tgra_2 function tioca2 pin function 0 output disabled 0 1 initial output is 0 output 0 output at compare match 0 initial output is 0 output 1 output at compare match 0 1 1 initial output is 0 output toggle output at compare match 0 output disabled 0 1 initial output is 1 output 0 output at compare match 0 initial output is 1 output 1 output at compare match 0 1 1 1 output compare register initial output is 1 output toggle output at compare match 1 0 input capture register capture input source is tioca2 pin input capture at rising edge 0 1 capture input source is tioca2 pin input capture at falling edge 1 capture input source is tioca2 pin input capture at both edges legend: : don?t care section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 293 of 698 rej09b0074-0600 9.3.4 timer interrupt enable register (tier) the tier registers control enabli ng or disabling of interrupt requests for each channel. the tpu has three tier registers, one for each channel. bit bit name initial value r/w description 7 ttge 0 r/w a/d conversion start request enable enables or disables generation of a/d conversion start requests by tgra input capture/compare match. 0: a/d conversion start request generation disabled 1: a/d conversion start request generation enabled 6 ? 1 ? reserved this bit is always read as 1 and cannot be modified. 5 tcieu 0 r/w underflow interrupt enable enables or disables interrupt requests (tcu) by the tcfu flag when the tcfu flag in tsr is set to 1 in channels 1 and 2. in channel 0, bit 5 is reserved. 0: interrupt requests (tciu) by tcfu disabled 1: interrupt requests (tciu) by tcfu enabled 4 tciev 0 r/w overflow interrupt enable enables or disables interrupt requests (tciv) by the tcfv flag when the tcfv flag in tsr is set to 1. 0: interrupt requests (tciv) by tcfv disabled 1: interrupt requests (tciv) by tcfv enabled 3 tgied 0 r/w tgr interrupt enable d enables or disables interrupt requests (tgid) by the tgfd bit when the tgfd bit in tsr is set to 1 in channel 0. in channels 1 and 2, bit 3 is reserved. it is always read as 0 and cannot be modified. 0: interrupt requests (tgid) by tgfd disabled 1: interrupt requests (tgid) by tgfd enabled. 2 tgiec 0 r/w tgr interrupt enable c enables or disables interrupt requests (tgic) by the tgfc bit when the tgfc bit in tsr is set to 1 in channel 0. in channels 1 and 2, bit 2 is reserved. it is always read as 0 and cannot be modified. 0: interrupt requests (tgic) by tgfc disabled 1: interrupt requests (tgic) by tgfc enabled section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 294 of 698 rej09b0074-0600 bit bit name initial value r/w description 1 tgieb 0 r/w tgr interrupt enable b enables or disables interrupt requests (tgib) by the tgfb bit when the tgfb bit in tsr is set to 1. 0: interrupt requests (tgib) by tgfb disabled 1: interrupt requests (tgib) by tgfb enabled 0 tgiea 0 r/w tgr interrupt enable a enables or disables interrupt requests (tgia) by the tgfa bit when the tgfa bit in tsr is set to 1. 0: interrupt requests (tgia) by tgfa disabled 1: interrupt requests (tgia) by tgfa enabled 9.3.5 timer status register (tsr) the tsr registers indicate the status of each channel. the tpu has three tsr registers, one for each channel. bit bit name initial value r/w description 7 tcfd 1 r count direction flag status flag that shows the direction in which tcnt counts in channel 1 and 2. in channel 0, bit 7 is reserved. it is always read as 0 and cannot be modified. 0: tcnt counts down 1: tcnt counts up 6 ? 1 ? reserved this bit is always read as 1 and cannot be modified. 5 tcfu 0 r/(w) * underflow flag status flag that indicates that tcnt underflow has occurred when channels 1 and 2 are set to phase counting mode. the write value should always be 0 to clear this flag. in channel 0, bit 5 is reserved. [setting condition] when the tcnt value underflows (change from h'0000 to h'ffff) [clearing condition] when 0 is written to tcfu after reading tcfu = 1 section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 295 of 698 rej09b0074-0600 bit bit name initial value r/w description 4 tcfv 0 r/(w) * overflow flag status flag that indicates that tcnt overflow has occurred. the write value should always be 0 to clear this flag. [setting condition] when the tcnt value overflows (change from h'ffff to h'0000) [clearing condition] when 0 is written to tcfv after reading tcfv = 1 3 tgfd 0 r/(w) * input capture/output compare flag d status flag that indicates the occurrence of tgrd input capture or compare match in channel 0. the write value should always be 0 to clear this flag. in channels 1 and 2, bit 3 is reserved. it is always read as 0 and cannot be modified. [setting conditions] ? when tcnt = tgrd while tgrd is functioning as output compare register ? when tcnt value is transferred to tgrd by input capture signal while tgrd is functioning as input capture register [clearing condition] when 0 is written to tgfd after reading tgfd = 1 2 tgfc 0 r/(w) * input capture/output compare flag c status flag that indicates the occurrence of tgrc input capture or compare match in channel 0. the write value should always be 0 to clear this flag. in channels 1 and 2, bit 2 is reserved. it is always read as 0 and cannot be modified. [setting conditions] ? when tcnt = tgrc while tgrc is functioning as output compare register ? when tcnt value is transferred to tgrc by input capture signal while tgrc is functioning as input capture register [clearing condition] when 0 is written to tgfc after reading tgfc = 1 section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 296 of 698 rej09b0074-0600 bit bit name initial value r/w description 1 tgfb 0 r/(w) * input capture/output compare flag b status flag that indicates the occurrence of tgrb input capture or compare match. the write value should always be 0 to clear this flag. [setting conditions] ? when tcnt = tgrb while tgrb is functioning as output compare register ? when tcnt value is transferred to tgrb by input capture signal while tgrb is functioning as input capture register [clearing condition] when 0 is written to tgfb after reading tgfb = 1 0 tgfa 0 r/(w) * input capture/output compare flag a status flag that indicates the occurrence of tgra input capture or compare match. the write value should always be 0 to clear this flag. [setting conditions] ? when tcnt = tgra while tgra is functioning as output compare register ? when tcnt value is transferred to tgra by input capture signal while tgra is functioning as input capture register [clearing conditions] ? when dmac is activated by tgia interrupt while dta bit of dmabcr in dmac is 1 ? when 0 is written to tgfa after reading tgfa = 1 note: * only 0 can be written to clear the flags. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 297 of 698 rej09b0074-0600 9.3.6 timer counter (tcnt) the tcnt registers are 16-bit counters. the tpu has three tcnt counters, one for each channel. the tcnt counters are initialized to h'0000 by a reset, and in hardware standby mode. the tcnt counters cannot be accessed in 8-bit units; they must always be accessed as a 16-bit unit. 9.3.7 timer general register (tgr) the tgr registers are 16-bit registers with a dual function as output compare and input capture registers. the tpu has 16 tgr registers, four each for channel 0 and two each for channels 1 and 2. tgrc and tgrd for channel 0 can also be designated for operation as buffer registers. the tgr registers cannot be accessed in 8-bit units; they must always be accessed as a 16-bit unit. tgr buffer register combinations are tgra?tgrc and tgrb?tgrd. 9.3.8 timer start register (tstr) tstr is an 8-bit readable/writable register that selects operation/stoppage for channels 0 to 2. when setting the operating mode in tmdr or setting the count clock in tcr, first stop the tcnt counter. bit bit name initial value r/w description 7 to 3 ? all 0 ? reserved the write value should always be 0. 2 1 0 cst2 cst1 cst0 0 0 0 r/w r/w r/w counter start 2 to 0 (cst2 to cst0) these bits select operation or stoppage for tcnt. if 0 is written to the cst bit during operation with the tioc pin designated for output, the counter stops but the tioc pin output compare output level is retained. if tior is written to when the cst bit is cleared to 0, the pin output level will be changed to the set initial output value. 0: tcnt_2 to tcnt_0 count operation is stopped 1: tcnt_2 to tcnt_0 performs count operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 298 of 698 rej09b0074-0600 9.3.9 timer synchro register (tsyr) tsyr selects independent operation or synchronous operation for the channel 0 to 2 tcnt counters. a channel performs synchronous operation when the corresponding bit in tsyr is set to 1. bit bit name initial value r/w description 7 to 3 ? all 0 ? reserved the write value should always be 0. 2 1 0 sync2 sync1 sync0 0 0 0 r/w r/w r/w timer synchro 2 to 0 these bits select whether operation is independent of or synchronized with other channels. when synchronous operation is selected, synchronous presetting of multiple channels, and synchronous clearing through counter clearing on another channel are possible. to set synchronous operation, the sync bits for at least two channels must be set to 1. to set synchronous clearing, in addition to the sync bit, the tcnt clearing source must also be set by means of bits cclr2 to cclr0 in tcr. 0: tcnt_2 to tcnt_0 operates independently (tcnt presetting /clearing is unrelated to other channels) 1: tcnt_2 to tcnt_0 performs synchronous operation tcnt synchronous presetting/synchronous clearing is possible section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 299 of 698 rej09b0074-0600 9.4 interface to bus master 9.4.1 16-bit registers tcnt and tgr are 16-bit registers. as the data bus to the bus master is 16 bits wide, these registers can be read and written to in 16-bit units. these registers cannot be read from or written to in 8-bit units; 16-bit access must always be used. an example of 16-bit register access operation is shown in figure 9.2. h l tcnth tcntl internal data bus bus interface module data bus bus master figure 9.2 16-bit register access operation [bus master ? tcnt (16 bits)] 9.4.2 8-bit registers registers other than tcnt and tgr are 8-bit. as the data bus to the cpu is 16 bits wide, these registers can be read and written to in 16-bit units. they can also be read and written to in 8-bit units. examples of 8-bit register access operation are shown in figures 9.3 to 9.5. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 300 of 698 rej09b0074-0600 h l tcr internal data bus bus interface module data bus bus master figure 9.3 8-bit register a ccess operation [bus master ? tcr (upper 8 bits)] h l tmdr internal data bus bus interface module data bus bus master figure 9.4 8-bit register a ccess operation [bus master ? tmdr (lower 8 bits)] h l tcr tmdr internal data bus bus interface module data bus bus master figure 9.5 8-bit register a ccess operation [bus master ? tcr and tmdr (16 bits)] section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 301 of 698 rej09b0074-0600 9.5 operation 9.5.1 basic functions each channel has a tcnt and tgr. tcnt performs up-counting, and is also capable of free- running operation, synchronous counting, and external event counting. each tgr can be used as an input capture register or output compare register. counter operation: when one of bits cst0 to cst2 is set to 1 in tstr, the tcnt counter for the corresponding channel starts counting. tcnt can operate as a free-running counter, periodic counter, and so on. 1. example of count operation setting procedure figure 9.6 shows an example of the count operation setting procedure. operation selection select counter clock periodic counter select counter clearing source select output compare register set period free-running counter start count operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 302 of 698 rej09b0074-0600 2. free-running count operation and periodic count operation immediately after a reset, the tpu's tcnt counters are all designated as free-running counters. when the relevant bit in tstr is set to 1 the corresponding tcnt counter starts up- count operation as a free-running counter. when tcnt overflows (from h'ffff to h'0000), the tcfv bit in tsr is set to 1. if the value of the corresponding tciev bit in tier is 1 at this point, the tpu requests an interrupt. after overflow, tcnt starts counting up again from h'0000. figure 9.7 illustrates free-running counter operation. tcnt value h'ffff h'0000 cst bit tcfv time figure 9.7 free-running counter operation when compare match is selected as the tcnt clearing source, the tcnt counter for the relevant channel performs periodic count operation. the tgr register for setting the period is designated as an output compare register, and counter clearing by compare match is selected by means of bits cclr2 to cclr0 in tcr. after the settings have been made, tcnt starts up- count operation as periodic counter when the corresponding bit in tstr is set to 1. when the count value matches the value in tgr, the tgf bit in tsr is set to 1 and tcnt is cleared to h'0000. if the value of the corresponding tgie bit in tier is 1 at this point, the tpu requests an interrupt. after a compare match, tcnt starts counting up again from h'0000. figure 9.8 illustrates periodic counter operation. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 303 of 698 rej09b0074-0600 tcnt value tgr h'0000 cst bit tgf time counter cleared by tgr compare match flag cleared by software or dmac activation figure 9.8 period ic counter operation waveform output by compare match: the tpu can perform 0, 1, or toggle output from the corresponding output pin using compare match. 1. example of setting procedure for waveform output by compare match figure 9.9 shows an example of the setting procedure for waveform output by compare match. output selection select waveform output mode set output timing start count operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 304 of 698 rej09b0074-0600 2. examples of waveform output operation figure 9.10 shows an example of 0 output/1 output. in this example tcnt has been designated as a free-running counter, and settings have been made so that 1 is output by compare match a, and 0 is output by compare match b. when the set level and the pin level coincide, the pin level does not change. tcnt value h'ffff h'0000 tioca tiocb tim e tgra tgrb no change no change no change no change 1 output 0 output figure 9.10 example of 0 output/1 output operation figure 9.11 shows an example of toggle output. in this example tcnt has been designated as a periodic counter (with counter clearing performed by compare match b), and settings have been made so that output is toggled by both compare match a and compare match b. tcnt value h'ffff h'0000 tiocb tioca time tgrb tgra toggle output toggle output counter cleared by tgrb compare match figure 9.11 example of toggle output operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 305 of 698 rej09b0074-0600 input capture function: the tcnt value can be transferred to tgr on detection of the tioc pin input edge. rising edge, falling edge, or both edges can be selected as the detected edge. 1. example of input capture operation setting procedure figure 9.12 shows an example of the input capture operation setting procedure. input selection select input capture input start count designate tgr as an input capture register by means of tior, and select rising edge, falling edge, or both edges as the input capture source and input signal edge. set the cst bit in tstr to 1 to start the count operation. [1] [2] [1] [2] figure 9.12 example of input ca pture operation setting procedure section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 306 of 698 rej09b0074-0600 2. example of input capture operation figure 9.13 shows an example of input capture operation. in this example both rising and falling edges have been selected as the tioca pin input capture input edge, falling edge has been selected as the tiocb pin input capture input edge, and counter clearing by tgrb input capture has been designated for tcnt. tcnt value h'0180 h'0000 tioca tgra h'0010 h'0005 counter cleared by tiocb input (falling edge) h'0160 h'0005 h'0160 h'0010 tgrb h'0180 tiocb time figure 9.13 example of input capture operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 307 of 698 rej09b0074-0600 9.5.2 synchronous operation in synchronous operation, the values in a number of tcnt counters can be rewritten simultaneously (synchronous presetting). also, a number of tcnt counters can be cleared simultaneously by making the appropriate setting in tcr (synchronous clearing). synchronous operation enables tgr to be incremented with respect to a single time base. channels 0 to 2 can all be designated for synchronous operation. example of synchronous operation setting procedure: figure 9.14 shows an example of the synchronous operation setting procedure. no yes synchronous operation selection set synchronous operation synchronous presetting set tcnt section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 308 of 698 rej09b0074-0600 example of synchronous operation: figure 9.15 shows an example of synchronous operation. in this example, synchronous operation and pwm mode 1 have been designated for channels 0 to 2, tgrb_0 compare match has been set as the channel 0 counter clearing source, and synchronous clearing has been set for the channel 1 and 2 counter clearing source. three-phase pwm waveforms are output from pins tioc0a, tioc1a, and tioc2a. at this time, synchronous presetting, and synchronous clearing by tgrb_0 compare match, is performed for channel 0 to 2 tcnt counters, and the data set in tgrb_0 is used as the pwm cycle. for details of pwm modes, see section 9.5.4, pwm modes. tcnt0 to tcnt2 values h'0000 tioca_0 tioca_1 tgrb_0 synchronous clearing by tgrb_0 compare match tgra_2 tgra_1 tgrb_2 tgra_0 tgrb_1 tioca_2 time figure 9.15 example of synchronous operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 309 of 698 rej09b0074-0600 9.5.3 buffer operation buffer operation, provided for channel 0, enables tgrc and tgrd to be used as buffer registers. buffer operation differs depending on whether tgr has been designated as an input capture register or as a compare match register. table 9.17 shows the register combinations used in buffer operation. table 9.17 register combinat ions in buffer operation channel timer general re gister buffer register 0 tgra_0 tgrc_0 tgrb_0 tgrd_0 ? when tgr is an output compare register when a compare match occurs, the value in the buffer register for the corresponding channel is transferred to the timer general register. this operation is illustrated in figure 9.16. buffer register timer general register tcnt comparator compare match signal figure 9.16 compare match buffer operation ? when tgr is an input capture register when input capture occurs, the value in tcnt is transferred to tgr and the value previously held in the timer general register is transferred to the buffer register. this operation is illustrated in figure 9.17. buffer register timer general register tcnt input capture signal figure 9.17 input capture buffer operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 310 of 698 rej09b0074-0600 example of buffer operation setting procedure: figure 9.18 shows an example of the buffer operation setting procedure. buffer operation select tgr function set buffer operation start count section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 311 of 698 rej09b0074-0600 examples of buffer operation 1. when tgr is an output compare register figure 9.19 shows an operation example in which pwm mode 1 has been designated for channel 0, and buffer operation has been designated for tgra and tgrc. the settings used in this example are tcnt clearing by compare match b, 1 output at compare match a, and 0 output at compare match b. as buffer operation has been set, when compare match a occurs the output changes and the value in buffer register tgrc is simultaneously transferred to timer general register tgra. this operation is repeated each time compare match a occurs. for details of pwm modes, see section 9.5.4, pwm modes. tcnt value tgrb_0 h'0000 tgrc_0 tgra_0 h'0200 h'0520 tioca h'0200 h'0450 h'0520 h'0450 tgra_0 h'0450 h'0200 transfer time figure 9.19 example of buffer operation (1) section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 312 of 698 rej09b0074-0600 2. when tgr is an input capture register figure 9.20 shows an operation example in which tgra has been designated as an input capture register, and buffer operation has been designated for tgra and tgrc. counter clearing by tgra input capture has been set for tcnt, and both rising and falling edges have been selected as the tioca pin input capture input edge. as buffer operation has been set, when the tcnt value is stored in tgra upon occurrence of input capture a, the value previously stored in tgra is simultaneously transferred to tgrc. tcnt value h'09fb h'0000 tgrc tim e h'0532 tioca tgra h'0f07 h'0532 h'0f07 h'0532 h'0f07 h'09fb figure 9.20 example of buffer operation (2) section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 313 of 698 rej09b0074-0600 9.5.4 pwm modes in pwm mode, pwm waveforms are output from the output pins. 0, 1, or toggle output can be selected as the output level in response to compare match of each tgr. settings of tgr registers can output a pwm waveform in the range of 0 % to 100 % duty. designating tgr compare match as the counter clearing source enables the period to be set in that register. all channels can be designated for pwm mode independently. synchronous operation is also possible. there are two pwm modes, as described below. ? pwm mode 1 pwm output is generated from the tioca and tiocc pins by pairing tgra with tgrb and tgrc with tgrd. the output specified by bits ioa3 to ioa0 and ioc3 to ioc0 in tior is output from the tioca and tiocc pins at comp are matches a and c, and the output specified by bits iob3 to iob0 and iod3 to iod0 in ti or is output at compare matches b and d. the initial output value is the value set in tgra or tgrc. if the set values of paired tgrs are identical, the output value does not change when a compare match occurs. in pwm mode 1, a maximum 4-phase pwm output is possible. ? pwm mode 2 pwm output is generated using one tgr as the cycle register and the others as duty registers. the output specified in tior is performed by means of compare matches. upon counter clearing by a synchronization register compare match, the output value of each pin is the initial value set in tior. if the set values of the cycle and duty registers are identical, the output value does not change when a compare match occurs. in pwm mode 2, a maximum 7-phase pwm output is possible by combined use with synchronous operation. the correspondence between pwm output pins and registers is shown in table 9.18. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 314 of 698 rej09b0074-0600 table 9.18 pwm output registers and output pins output pins channel registers pwm mode 1 pwm mode 2 tgra_0 tioca0 tgrb_0 tioca0 tiocb0 tgrc_0 tiocc0 0 tgrd_0 tiocc0 tiocd0 tgra_1 tioca1 1 tgrb_1 tioca1 tiocb1 2 tgra_2 tioca2 tioca2 tgrb_2 tiocb2 note: in pwm mode 2, pwm output is not possible for the tgr register in which the period is set. example of pwm mode setting procedure: figure 9.21 shows an example of the pwm mode setting procedure. pwm mode select counter clock select counter clearing source select waveform output level set tgr set pwm mode start count section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 315 of 698 rej09b0074-0600 examples of pwm mode operation: figure 9.22 shows an example of pwm mode 1 operation. in this example, tgra compare match is set as the tcnt clearing source, 0 is set for the tgra initial output value and output value, and 1 is set as the tgrb output value. in this case, the value set in tgra is used as the period, and the values set in tgrb registers as the duty. tcnt value tgra h'0000 tioca time tgrb counter cleared by tgra compare match figure 9.22 example of pwm mode operation (1) figure 9.23 shows an example of pwm mode 2 operation. in this example, synchronous operation is designated for channels 0 and 1, tgrb_1 compare match is set as the tcnt clearing source, and 0 is set for the initial output value and 1 for the output value of the other tgr registers (tgra_0 to tgrd_0, tgra_1), to output a 5-phase pwm waveform. in this case, the value set in tgrb_1 is used as the cycle, and the values set in the other tgrs as the duty. tcnt value tgrb_1 h'0000 tioca0 counter cleared by tgrb_1 compare match time tgra_1 tgrd_0 tgrc_0 tgrb_0 tgra_0 tiocb0 tiocc0 tiocd0 tioca1 figure 9.23 example of pwm mode operation (2) section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 316 of 698 rej09b0074-0600 figure 9.24 shows examples of pwm waveform output with 0 % duty and 100 % duty in pwm mode. tcnt value tgra h'0000 tioca time tgrb 0% duty tgrb rewritten tgrb rewritten tgrb rewritten tcnt value tgra h'0000 tioca time tgrb 100% duty tgrb rewritten tgrb rewritten tgrb rewritten output does not change when cycle register and duty register compare matches occur simultaneously tcnt value tgra h'0000 tioca time tgrb 100% duty tgrb rewritten tgrb rewritten tgrb rewritten output does not change when cycle register and duty register compare matches occur simultaneously 0% duty figure 9.24 example of pwm mode operation (3) section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 317 of 698 rej09b0074-0600 9.5.5 phase counting mode in phase counting mode, the phase difference between two external clock inputs is detected and tcnt is incremented/decremented accordingly. this mode can be set for channels 1 and 2. when phase counting mode is set, an external clock is selected as the counter input clock and tcnt operates as an up/down-counter regardless of the setting of bits tpsc2 to tpsc0 and bits ckeg1 and ckeg0 in tcr. however, the functions of bits cclr1 and cclr0 in tcr, and of tior, tier, and tgr are valid, and input capture/compare match and interrupt functions can be used. this can be used for two-phase encoder pulse input. when overflow occurs while tcnt is counting up, the tcfv flag in tsr is set; when underflow occurs while tcnt is counting down, the tcfu flag is set. the tcfd bit in tsr is the count direction flag. reading the tcfd flag provides an indication of whether tcnt is counting up or down. table 9.19 shows the correspondence between external clock pins and channels. table 9.19 phase counting mode clock input pins external clock pins channels a-phase b-phase when channel 1 is set to phase counting mode tclka tclkb when channel 2 is set to phase counting mode tclkc tclkd example of phase counting mode setting procedure: figure 9.25 shows an example of the phase counting mode setting procedure. phase counting mode select phase counting mode start count section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 318 of 698 rej09b0074-0600 examples of phase co unting mode operation: in phase counting mode, tcnt counts up or down according to the phase difference between two external clocks. there are four modes, according to the count conditions. 1. phase counting mode 1 figure 9.26 shows an example of phase counting mode 1 operation, and table 9.20 summarizes the tcnt up/down-count conditions. tcnt value time down-count up-count tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) figure 9.26 example of phase counting mode 1 operation table 9.20 up/down-count conditions in phase counting mode 1 tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) operation high level low level low level high level up-count high level low level high level down-count low level legend: : rising edge : falling edge section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 319 of 698 rej09b0074-0600 2. phase counting mode 2 figure 9.27 shows an example of phase counting mode 2 operation, and table 9.21 summarizes the tcnt up/down-count conditions. time down-count up-count tcnt value tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) figure 9.27 example of phase counting mode 2 operation table 9.21 up/down-count conditions in phase counting mode 2 tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) operation high level don't care low level don't care low level don't care high level up-count high level don't care low level don't care high level don't care low level down-count legend: : rising edge : falling edge section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 320 of 698 rej09b0074-0600 3. phase counting mode 3 figure 9.28 shows an example of phase counting mode 3 operation, and table 9.22 summarizes the tcnt up/down-count conditions. time up-count down-count tcnt value tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) figure 9.28 example of phase counting mode 3 operation table 9.22 up/down-count conditions in phase counting mode 3 tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) operation high level don't care low level don't care low level don't care high level up-count high level down-count low level don't care high level don't care low level don't care legend: : rising edge : falling edge section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 321 of 698 rej09b0074-0600 4. phase counting mode 4 figure 9.29 shows an example of phase counting mode 4 operation, and table 9.23 summarizes the tcnt up/down-count conditions. tim e up-count down-count tcnt value tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) figure 9.29 example of phase counting mode 4 operation table 9.23 up/down-count conditions in phase counting mode 4 tclka (channel 1) tclkc (channel 2) tclkb (channel 1) tclkd (channel 2) operation high level low level up-count low level high level don't care high level low level down-count high level don't care low level legend: : rising edge : falling edge section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 322 of 698 rej09b0074-0600 9.6 interrupts 9.6.1 interrupt so urce and priority there are three kinds of tpu interrupt source: tgr input capture/compare match, tcnt overflow, and tcnt underflow. each interrupt source has its own status flag and enable/disabled bit, allowing generation of interrupt request signals to be enabled or disabled individually. when an interrupt request is generated, the corresponding status flag in tsr is set to 1. if the corresponding enable/disable bit in tier is set to 1 at this time, an interrupt is requested. the interrupt request is cleared by clearing the status flag to 0. relative channel priorities can be changed by the interrupt controller, but the priority order within a channel is fixed. for details, see section 5, interrupt controller. table 9.24 lists the tpu interrupt sources. table 9.24 tpu interrupts channel name interrupt source inte rrupt flag dmac activation priority * tgi0a tgra_0 input capture/compare match tgfa possible high tgi0b tgrb_0 input capture/compare match tgfb not possible tgi0c tgrc_0 input capture/compare match tgfc not possible tgi0d tgrd_0 input capture/compare match tgfd not possible 0 tci0v tcnt_0 overflow tcfv not possible tgi1a tgra_1 input capture/compare match tgfa possible tgi1b tgrb_1 input capture/compare match tgfb not possible tci1v tcnt_1 overflow tcfv not possible 1 tci1u tcnt_1 underflow tcfu not possible 2 tgi2a tgra_2 input capture/compare match tgfa possible tgi2b tgrb_2 input capture/compare match tgfb not possible tci2v tcnt_2 overflow tcfv not possible tci2u tcnt_2 underflow tcfu not possible low note: * this table shows the initial state immediately after a reset. the relative channel priorities can be changed by the interrupt controller. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 323 of 698 rej09b0074-0600 input capture/compare match interrupt: an interrupt is requested if the tgie bit in tier is set to 1 when the tgf flag in tsr is set to 1 by the occurrence of a tgr input capture/compare match on a particular channel. the interrupt request is cleared by clearing the tgf flag to 0. the tpu has 8 input capture/compare match interrupts, four each for channel 0, and two each for channels 1 and 2. overflow interrupt: an interrupt is requested if the tciev bit in tier is set to 1 when the tcfv flag in tsr is set to 1 by the occurrence of tcnt overflow on a channel. the interrupt request is cleared by clearing the tcfv flag to 0. the tpu has three overflow interrupts, one for each channel. underflow interrupt: an interrupt is requested if the tcieu bit in tier is set to 1 when the tcfu flag in tsr is set to 1 by the occurrence of tcnt underflow on a channel. the interrupt request is cleared by clearing the tcfu flag to 0. the tpu has two underflow interrupts, one each for channels 1 and 2. 9.6.2 dmac activation the dmac can be activated by the tgra input capture/compare match interrupt for a channel. for details, see section 7, dma controller (dmac). with the tpu, a total of three tgra input capture/compare match interrupts can be used as dmac activation sources, one for each channel. 9.6.3 a/d converter activation the a/d converter can be activated by the tgra input capture/compare match for a channel. if the ttge bit in tier is set to 1 when the tgfa flag in tsr is set to 1 by the occurrence of a tgra input capture/compare match on a particular channel, a request to start a/d conversion is sent to the a/d converter. if the tpu conversio n start trigger has been selected on the a/d converter side at this time, a/d conversion is st arted. in the tpu, a total of three tgra input capture/compare match interrupts can be used as a/d converter conversion start sources, one for each channel. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 324 of 698 rej09b0074-0600 9.7 operation timing 9.7.1 input/output timing tcnt count timing: figure 9.30 shows tcnt count timing in internal clock operation, and figure 9.31 shows tcnt count timing in external clock operation. tcnt tcnt input clock internal clock n - 1 n n + 1 n + 2 falling edge rising edge figure 9.30 count timing in internal clock operation tcnt tcnt input clock external clock n - 1 n n + 1 n + 2 falling edge rising edge falling edge figure 9.31 count timing in external clock operation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 325 of 698 rej09b0074-0600 output compare output timing: a compare match signal is generated in the final state in which tcnt and tgr match (the point at which the count value matched by tcnt is updated). when a compare match signal is generated, the output value set in tior is output at the output compare output pin. after a match between tcnt and tgr, the compare match signal is not generated until the tcnt input clock is generated. figure 9.32 shows output compare output timing. tgr tcnt tcnt input clock n n n + 1 compare match signal tioc pin figure 9.32 output compare output timing input capture signal timing: figure 9.33 shows input capture signal timing. tcnt input capture input n n + 1 n + 2 n n + 2 tgr input capture signal figure 9.33 input capture input signal timing section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 326 of 698 rej09b0074-0600 timing for counter clearing by compare match/input capture: figure 9.34 shows the timing when counter clearing by compare match occurrence is specified, and figure 9.35 shows the timing when counter clearing by input capture occurrence is specified. tcnt counter clear signal compare match signal tgr n n h'0000 figure 9.34 counter clear timing (compare match) tcnt counter clear signal input capture signal tgr n h'0000 n figure 9.35 counter clear timing (input capture) section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 327 of 698 rej09b0074-0600 buffer operation timing: figures 9.36 and 9.37 show the timing in buffer operation. tgra, tgrb compare match signal tcnt tgrc, tgrd nn n n n + 1 figure 9.36 buffer operation timing (compare match) tgra, tgrb tcnt input capture signal tgrc, tgrd n n n n + 1 n n n + 1 figure 9.37 buffer operation timing (input capture) 9.7.2 interrupt signal timing tgf flag setting timing in case of compare match: figure 9.38 shows the timing for setting of the tgf flag in tsr by compare match occurrence, and tgi interrupt request signal timing. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 328 of 698 rej09b0074-0600 tgr tcnt tcnt input clock n n n + 1 compare match signal tgf flag tgi interrupt figure 9.38 tgi interrupt timing (compare match) tgf flag setting timing in case of input capture: figure 9.39 shows the timing for setting of the tgf flag in tsr by input capture occurrence, and tgi interrupt request signal timing. tgr tcnt input capture signal n n tgf flag tgi interrupt figure 9.39 tgi interrupt timing (input capture) section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 329 of 698 rej09b0074-0600 tcfv flag/tcfu flag setting timing: figure 9.40 shows the timing for setting of the tcfv flag in tsr by overflow occurrence, and tciv interrupt request signal timing. figure 9.41 shows the timing for setting of the tcfu flag in tsr by underflow occurrence, and tciu interrupt request signal timing. overflow signal tcnt (overflow) tcnt input clock h'ffff h'0000 tcfv flag tciv interrupt figure 9.40 tciv interrupt setting timing underflow signal tcnt (underflow) tcnt input clock h'0000 h'ffff tcfu flag tciu interrupt figure 9.41 tciu interrupt setting timing section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 330 of 698 rej09b0074-0600 status flag clearing timing: after a status flag is read as 1 by the cpu, it is cleared by writing 0 to it. when the dmac is activated, the flag is cleared automatically. figure 9.42 shows the timing for status flag clearing by the cpu, and fi gure 9.43 shows the timing for status flag clearing by the dmac. t 1 t 2 tsr write cycle tsr address a ddress write signal status flag interrupt request signal figure 9.42 timing for status flag clearing by cpu interrupt request signal status flag a ddress source address dmac read cycle t 1 t 2 destination address t 1 t 2 dmac write cycle figure 9.43 timing for status flag clearing by dmac activation section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 331 of 698 rej09b0074-0600 9.8 usage notes input clock restrictions: the input clock pulse width must be at least 1.5 states in the case of single-edge detection, and at least 2.5 states in the case of both-edge detection. the tpu will not operate properly with a narrower pulse width. in phase counting mode, the phase difference and overlap between the two input clocks must be at least 1.5 states, and the pulse width must be at least 2.5 states. figure 9.44 shows the input clock conditions in phase counting mode. overlap phase differ- ence phase differ- ence overlap tclka (tclkc) tclkb (tclkd) pulse width pulse width pulse width pulse width notes: phase difference and overlap pulse width : 1.5 states or more : 2.5 states or more figure 9.44 phase differen ce, overlap, and pulse widt h in phase counting mode caution on period setting: when counter clearing by compare match is set, tcnt is cleared in the final state in which it matches the tgr value (the point at which the count value matched by tcnt is updated). consequently, the actual counter frequency is given by the following formula: f = ???? (n + 1) where f : counter frequency : operating frequency n : tgr set value section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 332 of 698 rej09b0074-0600 contention between tcnt wr ite and clear operations: if the counter clear signal is generated in the t 2 state of a tcnt write cycle, tcnt clearing takes precedence and the tcnt write is not performed. figure 9.45 shows the timing in this case. counter clear signal write signal a ddress tcnt address tcnt tcnt write cycle t 1 t 2 n h'0000 figure 9.45 contention between tcnt write and clear operations contention between tcnt writ e and increment operations: if incrementing occurs in the t 2 state of a tcnt write cycle, the tcnt write takes precedence and tcnt is not incremented. figure 9.46 shows the timing in this case. tcnt input clock write signal a ddress tcnt address tcnt tcnt write cycle t 1 t 2 n m tcnt write data figure 9.46 contention between t cnt write and increment operations section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 333 of 698 rej09b0074-0600 contention between tgr wr ite and compare match: if a compare match occurs in the t 2 state of a tgr write cycle, the tgr write takes precedence and the compare match signal is inhibited. a compare match does not occur even if the same value as before is written. figure 9.47 shows the timing in this case. compare match signal write signal a ddress tgr address tcnt tgr write cycle t 1 t 2 n m tgr write data tgr n n+1 prohibited figure 9.47 contention between tgr write and compare match section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 334 of 698 rej09b0074-0600 contention between buffer register write and compare match: if a compare match occurs in the t 2 state of a tgr write cycle, the data transferred to tgr by the buffer operation will be the data prior to the write. figure 9.48 shows the timing in this case. compare match signal write signal a ddress buffer register address buffer register tgr write cycle t 1 t 2 n tgr n m buffer register write data figure 9.48 contention between bu ffer register write and compare match contention between tgr read and input capture: if the input capture signal is generated in the t 1 state of a tgr read cycle, the data that is read will be the data after input capture transfer. figure 9.49 shows the timing in this case. input capture signal read signal a ddress tgr address tgr tgr read cycle t 1 t 2 m internal data bus x m figure 9.49 contention between tgr read and input capture section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 335 of 698 rej09b0074-0600 contention between tgr write and input capture: if the input capture signal is generated in the t 2 state of a tgr write cycle, the input capture operation takes precedence and the write to tgr is not performed. figure 9.50 shows the timing in this case. input capture signal write signal a ddress tcnt tgr write cycle t 1 t 2 m tgr m tgr address figure 9.50 contention between tgr write and input capture section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 336 of 698 rej09b0074-0600 contention between buffer regi ster write and input capture: if the input capture signal is generated in the t 2 state of a buffer register write cycle, the buffer operation takes precedence and the write to the buffer register is not performed. figure 9.51 shows the timing in this case. input capture signal write signal a ddress tcnt buffer register write cycle t 1 t 2 n tgr n m m buffer register buffer register address figure 9.51 contention between bu ffer register write and input capture contention between overflow/u nderflow and co unter clearing: if overflow/underflow and counter clearing occur simultaneously, the tcfv/tcfu flag in tsr is not set and tcnt clearing takes precedence. figure 9.52 shows the operation timing when a tgr compare match is specified as the clearing source, and h'ffff is set in tgr. counter clearing signal tcnt input clock tcnt tgf flag prohibited tcfv flag h'ffff h'0000 figure 9.52 contention between overflow and co unter clearing section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 337 of 698 rej09b0074-0600 contention between tcnt wr ite and overflo w/underflow: if there is an up-count or down- count in the t 2 state of a tcnt write cycle, and overflow/underflow occurs, the tcnt write takes precedence and the tcfv/tcfu flag in tsr is not set. figure 9.53 shows the operation timing when there is contention between tcnt write and overflow. write signal a ddress tcnt address tcnt tcnt write cycle t 1 t 2 h'ffff m tcnt write data tcfv flag prohibited figure 9.53 contention betw een tcnt write and overflow multiplexing of i/o pins: in this lsi, the tclka input pin is multiplexed with the tiocc0 i/o pin, the tclkb input pin with the tiocd0 i/o pin, the tclkc input pin with the tiocb1 i/o pin, and the tclkd input pin with the tiocb2 i/o pin. when an external clock is input, compare match output should not be performed from a multiplexed pin. interrupts in module stop mode: if module stop mode is entered when an interrupt has been requested, it will not be possible to clear the cpu interrupt source or the dmac activation source. interrupts should therefore be disabled before entering module stop mode. module stop mode setting: tpu operation can be disabled or enabled using the module stop control register. the initial setting is for tpu operation to be halted. register access is enabled by clearing module stop mode. for details, refer to section 20, power-down modes. section 9 16-bit timer pulse unit (tpu) rev.6.00 jun. 03, 2008 page 338 of 698 rej09b0074-0600 section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 339 of 698 rej09b0074-0600 section 10 watchdog timer (wdt) the watchdog timer (wdt) is an 8-bit timer that can generate an internal reset signal for this lsi if a system crash prevents the cpu from writing to the timer counter, thus allowing it to overflow. when this watchdog function is not needed, the wdt can be used as an interval timer. in interval timer operation, an interval timer interrupt is generated each time the counter overflows. the block diagram of the wdt is shown in figure 10.1. 10.1 features ? selectable from eight counter input clocks ? switchable between watchdog timer mode and interval timer mode in watchdog timer mode: ? if the counter overflows, it is possible to select whether this lsi is internally reset or not. in interval timer mode: ? if the counter overflows, the wdt generates an interval timer interrupt (wovi). wdt0104a_000020011200 section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 340 of 698 rej09b0074-0600 overflow interrupt control wovi (interrupt request signal) internal reset signal * reset control rstcsr tcnt tscr /2 /64 /128 /512 /2048 /8192 /32768 /131072 clock clock select internal clock sources bus interface module bus tcsr: tcnt: rstcsr: notes: when a sub-block is operating, will be sub . * the type of internal reset signal depends on a register setting. timer control/status register timer counter reset control/status register wdt legend: internal bus figure 10.1 block diagram of wdt 10.2 register descriptions the wdt has the following three registers. for details, refer to section 21, list of registers. to prevent accidental overwriting, tcsr, tcnt, and rstcsr have to be written to by a different method to normal registers. for details, refer to section 10.5.1, notes on register access. ? timer counter (tcnt) ? timer control/status register (tcsr) ? reset control/status register (rstcsr) 10.2.1 timer counter (tcnt) tcnt is an 8-bit readable/writable up-counter. tcnt is initialized to h'00 by a reset, when the tme bit in tcsr is cleared to 0. 10.2.2 timer control/status register (tcsr) tcsr is an 8-bit readable/writable register. its functions include selecting the clock source to be input to tcnt, and selecting the timer mode. section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 341 of 698 rej09b0074-0600 bit bit name initial value r/w description 7 ovf 0 r/(w) * overflow flag indicates that tcnt has overflowed. only a write of 0 is permitted, to clear the flag. [setting condition] when tcnt overflows (changes from h'ff to h'00) when internal reset request generation is selected in watchdog timer mode, ovf is cleared automatically by the internal reset. [clearing condition] cleared by reading tcsr when ovf = 1, then writing 0 to ovf when polling cvf when the interval timer interrupt has been prohibited, ovf = 1 status should be read two or more times. 6 wt/ it 0 r/w timer mode select selects whether the wdt is used as a watchdog timer or interval timer. 0: interval timer mode 1: watchdog timer mode 5 tme 0 r/w timer enable when this bit is set to 1, tcnt starts counting. when this bit is cleared, tcnt stops counting and is initialized to h'00. 4, 3 ? all 1 ? reserved these bits are always read as 1 and cannot be modified. 2 1 0 cks2 cks1 cks0 0 0 0 r/w r/w r/w clock select 0 to 2 selects the clock source to be input to tcnt. the overflow frequency for = 16 mhz is enclosed in parentheses. the overflow period is the time from when tcnt starts counting up from h'00 until overflow occurs. 000: clock /2 (frequency: 32.0 s) 001: clock /64 (frequency: 1.0 ms) 010: clock /128 (frequency: 2.0 ms) 011: clock /512 (frequency: 8.2 ms) 100: clock /2048 (frequency: 32.8 ms) 101: clock /8192 (frequency: 131.1 ms) 110: clock /32768 (frequency: 524.3 ms) 111: clock /131072 (frequency: 2.1 s) note: * the write value should always be 0 to clear this flag. section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 342 of 698 rej09b0074-0600 10.2.3 reset control/status register (rstcsr) rstcsr is an 8-bit readable/writable register that controls the generation of the internal reset signal when tcnt overflows, and selects the type of internal reset signal. rstcsr is initialized to h'1f by a reset signal from the res pin, and not by the wdt internal reset signal caused by overflows. bit bit name initial value r/w description 7 wovf 0 r/(w) * 1 watchdog overflow flag this bit is set when tcnt overflows in watchdog timer mode. this bit cannot be set in interval timer mode, and the write value should always be 0. [setting condition] set when tcnt overflows (changed from h'ff to h'00) in watchdog timer mode [clearing condition] cleared by reading rstcsr when wovf = 1, and then writing 0 to wovf 6 rste 0 r/w reset enable specifies whether or not a reset signal is generated in the chip if tcnt overflows during watchdog timer operation. 0: reset signal is not generated even if tcnt overflows (though this lsi is not reset, tcnt and tcsr in wdt are reset) 1: reset signal is generated if tcnt overflows 5 rsts 0 r/w reset select selects the type of internal reset generated if tcnt overflows during watchdog timer operation. 0: power-on reset * 2 1: manual reset * 3 4 to 0 ? all 1 ? reserved these bits are always read as 1 and cannot be modified. notes: 1. the write value should always be 0 to clear this flag. 2. bear in mind that the usb register is not initialized by a power-on reset trigged by the wdt. for details, see section 14.8.8, reset. 3. supported only by the h8s/2218 group. section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 343 of 698 rej09b0074-0600 10.3 operation 10.3.1 watchdog timer mode to use the wdt as a watchdog timer, set the wt/ it bit in tcsr and the tme bit to 1. tcnt does not overflow while the system is operating normally. software must prevent tcnt overflows by rewriting the tcnt value (normally be writing h'00) before overflows occurs. when the rste bit of the rstcsr is set to 1, and if the tcnt overflows, an internal reset signal for this lsi is issued. in this case, select power- on reset or manual reset* by setting the rsts bit of the rstcsr to 0. if a reset caused by a signal input to the res pin occurs at the same time as a reset caused by a wdt overflow, the res pin reset has priority and the wovf bit in rstcsr is cleared to 0. the internal reset signal is output for 518 states. when the tcnt overflows in watchdog timer mode, the wovf bit of the rstcsr is set to 1. if the rste bit of the rstcsr has been set to 1, an internal reset signal for the entire lsi is generated at tcnt overflow. note: * supported only by the h8s/2218 group. tcnt value h'00 time h'ff wt/ it = 1 tme = 1 h'00 written to tcnt wt/ it = 1 tme = 1 h'00 written to tcnt 518 states (wdt0) internal reset signal * wt/ it : tme: legend: overflow wovf = 1 timer mode select bit timer enabl bit note: * with wdt0, the internal reset signal is generated only when the rste bit is set to 1. internal reset generated figure 10.2 operation in watchdog timer mode section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 344 of 698 rej09b0074-0600 10.3.2 timing of setting of watchdog timer overflow flag (wovf) with wdt, the wovf bit in rstcsr is set to 1 if tcnt overflows in watchdog timer mode. if tcnt overflows while the rste bit in rstcsr is set to 1, an internal reset signal is generated for the entire chip. this timing is illustrated in figure 10.3. tcnt h'ff h'00 overflow signal (internal signal) internal reset signal wovf 518 states (wdt0) figure 10.3 timing of wovf setting 10.3.3 interval timer mode to use the wdt as an interval timer, clear bit wt/ it in tcsr to 0 and set bit tme to 1. when the interval timer is operating, an interval timer interrupt (wovi) is generated each time the tcnt overflows. therefore, an interrupt can be generated at intervals. tcnt count h'00 tim e h'ff wt/ it = 0 tme = 1 wovi overflow overflow overflow overflow wovi: interval interrupt request generation legend: wovi wovi wovi figure 10.4 operation in interval timer mode section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 345 of 698 rej09b0074-0600 10.3.4 timing of setting of overflow flag (ovf) the ovf flag is set to 1 if tcnt overflows during interval timer operation. at the same time, an interval timer interrupt (wovi) is requested. this timing is shown in figure 10.5. tcnt h'ff h'00 overflow signal (internal signal) ovf figure 10.5 timing of ovf setting 10.4 interrupts during interval timer mode operation, an overflow generates an interval timer interrupt (wovi). the interval timer interrupt is requested whenever the ovf flag is set to 1 in tcsr. ovf must be cleared to 0 in the interrupt handling routine. table 10.1 wdt interrupt source name interrupt source interrupt flag wovi tcnt overflow wovf section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 346 of 698 rej09b0074-0600 10.5 usage notes 10.5.1 notes on register access the watchdog timer?s tcnt, tcsr, and rstcsr registers differ from other registers in being more difficult to write to. the procedures for writing to and reading these registers are given below. writing to tcnt and tcsr: these registers must be written to by a word transfer instruction. they cannot be written to with byte transfer instructions. figure 10.6 shows the format of data written to tcnt and tcsr. tcnt and tcsr both have the same write address. for a write to tcnt, the upper byte of the written word must contain h'5a and the lower byte must contain the write data. for a write to tcsr, the upper byte of the written word must contain h'a5 and the lower byte must contain the write data. this transfers the write data from the lower byte to tcnt or tcsr. tcnt write tcsr write address: h'ff74 address: h'ff74 h'5a write data 15 8 7 0 h'a5 write data 15 8 7 0 figure 10.6 format of data written to tcnt and tcsr writing to rstcsr: rstcsr must be written to by a word transfer to address h'ff76. it cannot be written to with byte instructions. figure 10.7 shows the format of data written to rstcsr. the method of writing 0 to the wovf bit differs from that for writing to the rste and rsts bits. to write 0 to the wovf bit, the upper byte of the written word must contain h'a5 and the lower byte must contain h'00. this clears the wovf bit to 0, but has no effect on the rste and rsts bits. to write to the rste and rsts bits, the upper byte must contain h'5a and the lower byte must contain the write data. this writes the values in bits 6 and 5 of the lower byte into the rste and rsts bits, but has no effect on the wovf bit. section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 347 of 698 rej09b0074-0600 writing 0 to wovf bit write to rste, rsts bits address: h'ff76 address: h'ff76 h'a5 h'00 15 8 7 0 h'5a write data 15 8 7 0 figure 10.7 format of data written to rstcsr (example of wdt0) reading from tcnt, tcsr, and rstcsr: tcnt, tcsr, and rstcsr are read by using the same method as for the general registers. tcsr, tcnt, and rstcsr are allocated in addresses h'ff74, h'ff75, and h'ff77 respectively. 10.5.2 contention between timer counter (tcnt) write and increment if a timer counter clock pulse is generated during the t 2 state of a tcnt write cycle, the write takes priority and the timer counter is not incremented. figure 10.8 shows this operation. a ddress internal write signal tcnt input clock tcnt nm t 1 t 2 tcnt write cycle counter write data figure 10.8 contention betw een tcnt write and increment section 10 watchdog timer (wdt) rev.6.00 jun. 03, 2008 page 348 of 698 rej09b0074-0600 10.5.3 changing value of cks2 to cks0 if bits cks0 to cks2 in tcsr are written to while the wdt is operating, errors could occur in the incrementation. software must be used to stop the watchdog timer (by clearing the tme bit to 0) before changing the value of bits cks0 to cks2. 10.5.4 switching between watchdog timer mode and interval timer mode if the mode is switched from watchdog timer to interval timer while the wdt is operating, errors could occur in the incrementation. software must be used to stop the watchdog timer (by clearing the tme bit to 0) before switching the mode. 10.5.5 internal reset in watchdog timer mode this lsi is not reset internally if tcnt over flows while the rste bit is cleared to 0 during watchdog timer operation, however tcnt and tcsr of the wdt are reset. tcnt, tcsr, or rstcr cannot be written to for 132 states following an overflow. during this period, any attempt to read the wovf flag is not acknowledged. accordingly, wait 132 states after overflow to write 0 to the wovf flag for clearing. 10.5.6 ovf flag clearing in interval timer mode when the ovf flag setting conflicts with the ovf flag reading in interval timer mode, writing 0 to the ovf bit may not clear the flag even though the ovf bit has been read while it is 1. if there is a possibility that the ovf flag setting and reading will conflict, such as when the ovf flag is polled with the interval timer interrupt disabled, read the ovf bit while it is 1 at least twice before writing 0 to the ovf bit to clear the flag. section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 349 of 698 rej09b0074-0600 section 11 realtime clock (rtc) the realtime clock (rtc) is a timer used to count time ranging from a second to a week. figure 11.1 shows the block diagram of the rtc. 11.1 features ? counts seconds, minutes, hours, and day-of-week ? start/stop function ? reset function ? readable/writable counter of seconds, minutes, hours, and day-of-week with bcd codes ? periodic (seconds, minutes, hours, days, and weeks) interrupts ? 8-bit free running counter ? selection of clock source ? 8-bit bus (3 cycle access timing) connected to the external bus rtc register is allocated to a part of area 7 of external address (h'ffff48 to h'ffff4f) pss 32-khz oscillator circuit rtccsr rsecdr rmindr rwkdr clock count control circuit interrupt control circuit interrupt irq 5 rtccr1 rhrdr rtccr2 internal data bus 1/4 tmow legend: rtccsr: rsecdr: rmindr: rhrdr: rwkdr: rtccr1: rtccr2: pss: clock source select register second date register minute date register hour date register day-of-week date register rtc control register 1 rtc control register 2 prescaler s figure 11.1 block diagram of rtc section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 350 of 698 rej09b0074-0600 11.2 input/output pin table 11.1 shows the rtc input/output pin. table 11.1 pin configuration name abbreviation i/o function clock output tmow output rtc divided clock output 11.3 register descriptions the rtc has the following registers. ? second data register (rsecdr) ? minute data register (rmindr) ? hour data register (rhrdr) ? day-of-week data register (rwkdr) ? rtc control register 1 (rtccr1) ? rtc control register 2 (rtccr2) ? clock source select register (rtccsr) ? extended module stop register (exmdlstp) 11.3.1 second data register (rsecdr) rsecdr counts the bcd-coded second value. this register is initialized to h'00 by a stby input or the rst bit in rtccr1, but not initialized by a res input. the setting range is decimal 00 to 59. for more information on reading seconds, minutes, hours, and day-of-week, see section 11.4.2, time data reading procedure. section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 351 of 698 rej09b0074-0600 bit bit name initial value * r/w description 7 bsy ? r rtc busy this bit is set to 1 when the rtc is updating (operating) the values of second, minute, hour, and day-of-week data registers. when this bit is 0, the values of second, minute, hour, and day-of-week data registers must be adopted. 6 5 4 sc12 sc11 sc10 ? ? ? r/w r/w r/w counting ten?s position of seconds counts on 0 to 5 for 60-second counting. 3 2 1 0 sc03 sc02 sc01 sc00 ? ? ? ? r/w r/w r/w r/w counting one?s position of seconds counts on 0 to 9 once per second. when a carry is generated, 1 is added to the ten?s position. note: * initial value after res . 11.3.2 minute data register (rmindr) rmindr counts the bcd-coded minute value on the carry generated once per minute by the rsecdr counting. this register is initialized to h'00 a stby input or the rst bit in rtccr1, but not initialized by a res input. the setting range is decimal 00 to 59. bit bit name initial value * r/w description 7 bsy ? r rtc busy this bit is set to 1 when the rtc is updating (operating) the values of second, minute, hour, and day-of-week data registers. when this bit is 0, the values of second, minute, hour, and day-of-week data registers must be adopted. 6 5 4 mn12 mn11 mn10 ? ? ? r/w r/w r/w counting ten?s position of minutes counts on 0 to 5 for 60-minute counting. 3 2 1 0 mn03 mn02 mn01 mn00 ? ? ? ? r/w r/w r/w r/w counting one?s position of minutes counts on 0 to 9 once per minute. when a carry is generated, 1 is added to the ten?s position. note: * initial value after res . section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 352 of 698 rej09b0074-0600 11.3.3 hour data register (rhrdr) rhrdr counts the bcd-coded hour value on the carry generated once per hour by rmindr. this register is initialized to h'00 by a stby input or the rst bit in rtccr1, but not initialized by a res input. the setting range is either decimal 0 to 11 or 0 to 23 by the selection of the 12/24 bit in rtccr1. bit bit name initial value * r/w description 7 bsy ? r rtc busy this bit is set to 1 when the rtc is updating (operating) the values of second, minute, hour, and day-of-week data registers. when this bit is 0, the values of second, minute, hour, and day-of-week data registers must be adopted. 6 ? 0 ? reserved this bit is always read as 0. 5 4 hr11 hr10 ? ? r/w r/w counting ten?s position of hours counts on 0 to 2 for ten?s position of hours. 3 2 1 0 hr03 hr02 hr01 hr00 ? ? ? ? r/w r/w r/w r/w counting one?s position of hours counts on 0 to 9 once per hour. when a carry is generated, 1 is added to the ten?s position. note: * initial value after res . section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 353 of 698 rej09b0074-0600 11.3.4 day-of-week data register (rwkdr) rwkdr counts the bcd-coded day-of-week value on the carry generated once per day by rhrdr. this register is initialized to h'00 by a stby input or the rst bit in rtccr1, but not initialized by a res input. the setting range is decimal 0 to 6 using bits wk2 to wk0. bit bit name initial value * r/w description 7 bsy ? r rtc busy this bit is set to 1 when the rtc is updating (operating) the values of second, minute, hour, and day-of-week data registers. when this bit is 0, the values of second, minute, hour, and day-of-week data registers must be adopted. 6 to 3 ? all 0 ? reserved these bits are always read as 0. 2 1 0 wk2 wk1 wk0 ? ? ? r/w r/w r/w day-of-week counting day-of-week is indicated with a binary code. 000: sunday 001: monday 010: tuesday 011: wednesday 100: thursday 101: friday 110: saturday 111: reserved (setting prohibited) note: * initial value after res . section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 354 of 698 rej09b0074-0600 11.3.5 rtc control register 1 (rtccr1) rtccr1 controls start/stop and reset of the clock timer. bits 7 to 5 of this register are initialized to h'00 by a stby input or the rst bit in rtccr1, but not initialized by a res input. for the definition of time expression, see figure 11.2. bit bit name initial value * r/w description 7 run ? r/w rtc operation start 0: stops rtc and free running counter operation 1: starts rtc and free running counter operation 6 12/24 ? r/w operating mode 0: rtc operates in 12- hour mode. rhrdr counts on 0 to 11. 1: rtc operates in 24- hour mode. rhrdr counts on 0 to 23. 5 pm ? r/w a.m./p.m. 0: indicates a.m. when rtc is in the 12-hour mode. 1: indicates p.m. when rtc is in the 12-hour mode. 4 rst 0 r/w reset 0: normal operation 1: resets registers and control circuits except rtccsr and this bit. clear this bit to 0 after having been set to 1. 3 to 0 ? all 0 ? reserved these bits are always read as 0. note: * initial value after res . 24-hour count 01234567891011121314151617 12-hour count 0 pm 24-hour count 12-hour count pm 0 (morning) 1 (afternoon) noon 1234567891011012345 18 19 20 21 22 23 0 6 1 (afternoon) 0 78910110 figure 11.2 definition of time expression section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 355 of 698 rej09b0074-0600 11.3.6 rtc control register 2 (rtccr2) rtccr2 controls rtc periodic interrupts of weeks, days, hours, minutes, and seconds. this register is initialized to h'00 by a stby input or the rst bit in rtccr1, but not initialized by a res input. enabling interrupts of weeks, days, hours, minutes, and seconds sets the irrta flag to 1 in the interrupt flag register 1 (irr1) when an interrupt occurs. it also controls an overflow interrupt of a free running counter when rtc operates as a free running counter. bit bit name initial value * r/w description 7, 6 ? all 0 ? reserved these bits are always read as 0. 5 foie ? r/w free running counter overflow interrupt enable 0: disables an overflow interrupt 1: enables an overflow interrupt 4 wkie ? r/w week periodic interrupt enable 0: disables a week periodic interrupt 1: enables a week periodic interrupt 3 dyie ? r/w day periodic interrupt enable 0: disables a day periodic interrupt 1: enables a day periodic interrupt 2 hrie ? r/w hour periodic interrupt enable 0: disables an hour periodic interrupt 1: enables an hour periodic interrupt 1 mnie ? r/w minute periodic interrupt enable 0: disables a minute periodic interrupt 1: enables a minute periodic interrupt 0 seie ? r/w second periodic interrupt enable 0: disables a second periodic interrupt 1: enables a second periodic interrupt note: * initial value after res . section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 356 of 698 rej09b0074-0600 11.3.7 clock source select register (rtccsr) rtccsr selects clock source. this register is initialized to h'08 by a stby input or res input. a free running counter controls start/stop of counter operation by the run bit in rtccr1. when a clock other than 32.768 mhz is selected, the rtc is disabled and operates as an 8-bit free running counter. an interrupt can be generated by setting 1 to the foie bit in rtccr2 and enabling an overflow interrupt of the free running counter. a clock in which the system clock is divided by 32, 16, 8, or 4 is output in high-speed mode, medium-speed mode, sleep mode, subactive mode, or subsleep mode. bit bit name initial value r/w description 7 ? 0 ? reserved this bit is always read as 0. 6 5 rcs6 rcs5 0 0 r/w r/w clock output selection selects a clock output from the tmow pin when the tmowe bit in uctlr is set to 1. 00: /4 01: /8 10: /16 11: /32 4 ? 0 ? reserved this bit is always read as 0. 3 2 1 0 rcs3 rcs2 rcs1 rcs0 1 0 0 0 r/w r/w r/w r/w clock source selection 0000: /8 ?????????????????? free running counter operation 0001: /32 ???????????????? free running counter operation 0010: /128 ?????????????? free running counter operation 0011: /256 ?????????????? free running counter operation 0100: /512 ?????????????? free running counter operation 0101: /2048 ???????????? free running counter operation 0110: /4096 ???????????? free running counter operation 0111: /8192 ???????????? free running counter operation 1000: 32.768 khz ????? rtc operation section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 357 of 698 rej09b0074-0600 11.3.8 extended module stop register (exmdlstp) exmdlstp controls the clock supply of the rtc and usb. note: when reading pin states using the port d register (portd), after accessing exmdlstp (address range: h'ffff40 to h'ffff5f), you must perform a dummy read to the external address space (such as h'ffef00 to h'ff7ff) outside the range h'ffff40 to h'ffff5f before reading portd. bit bit name initial value r/w module 7 to 2 ? undefined ? reserved these bits are always read as undefined values. these bits should not to be modified. 1 rtcstop 0 r/w rtc module stop 0: rtc module stop cancelled 1: rtc module stop 0 usbstop1 0 r/w usb module stop 0: usb module stop partly cancelled 1: usb module completely stop section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 358 of 698 rej09b0074-0600 11.4 operation 11.4.1 initial settings of registers a fter power-on and resetting procedure the rtc registers that store second, minute, hour, day-of week, operating mode, and a.m./p.m. data are not reset by an stby input. therefore, all registers must be set to their initial values after power-on and stby input. figure 11.3 shows the initial setting and resetting procedures of the rtc. once the register setting are made, the rtc provides an accurate time as long as power is supplied regardless of a res input. rst in rtccr1=1 rst in rtccr1=0 set rsecdr, rmindr, rhrdr, rwkdr, 12/24 in rtccr1, and pm run in rtccr1=1 clock count controller is reset. second, minute, hour, day-of-week, operating mode, and a.m/p.m are set. rtc operation is started. figure 11.3 initial setting procedure section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 359 of 698 rej09b0074-0600 11.4.2 time data reading procedure when the seconds, minutes, hours, or day-of-week datum is updated while time data is being read, the data obtained may not be correct, and so the time data must be read again. figure 11.4 shows an example in which correct data is not obtained. in this example, since only rsecdr is read after data update, about 1-minute inconsistency occurs. to avoid reading in this timing, the following processing must be performed. 1. check the setting of the bsy bit, and when the bsy bit changes from 1 to 0, read from the second, minute, hour, and day-of-week registers. when about 62.5 ms is passed after the bsy bit is set to 1, the registers are updated, and the bsy bit is cleared to 0. 2. making use of interrupts, read from the second, minute, hour, and day-of week registers after the irq5f flag in isr is set to 1 and the bsy bit is confirmed to be 0. 3. read from the second, minute, hour, and day-of week registers twice in a row, and if there is no change in the read data, the read data is used. before update rwkdr = h'03, rhddr = h'13, rmindr = h'46, rsecdr = h'59 bsy bit = 0 (1) day-of-week data register read h'03 (2) hour data register read h'13 (3) minute data register read h'46 bsy bit -> 1 (under data update) after update rwkdr = h'03, rhddr = h'13, rmindr = h'47, rsecdr = h'00 bsy bit -> 0 (4) second data register read h'00 processing flow figure 11.4 example: reading of inaccurate time data section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 360 of 698 rej09b0074-0600 11.5 interrupt source the rtc interrupt sources are listed in table 11.2. there are five kinds of rtc interrupts: week interrupts, day interrupts, hour interrupts, minute interrupts, and second interrupts. when using an interrupt, initiate the rtc last after other registers (include iscrh and ier of interrupt controller) are set. do not set multiple interrupt enable bits in rtccr2 simultaneously to 1. when an interrupt request of the rtc occurs, the irq5f flag in isr is set to 1. when clearing the flag, write 0 after reading the flag = 1. figure 11.5 shows the initializing setting procedure in using the rtc interrupt and figure 11.6 shows an example of the rtc interrupt handling routine. table 11.2 interrupt source interrupt name interrupt source interrupt enable bit overflow interrupt occurs when the free running counter is overflown. foie week periodic interrupt occurs every week when the day-of-week date register value becomes 0. wkie day periodic interrupt occurs every day when the day-of-week date register is counted. dyie hour periodic interrupt occurs every hour when the hour date register is counted. hrie minute periodic interrupt occurs every minute when the minute date register is counted. mnie second periodic interrupt occurs every second when the second date register is counted. seie section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 361 of 698 rej09b0074-0600 write 0 to bit 5 in isr register set rtc register write 1 to bit 5 in ier run in rtccr1 = 1 set irq5scb = 0 and irq5sca = 1 in iscrh register read isr register set the falling edge of irq 5 irq5 is enabled clear the irq5f flag figure 11.5 initializing pro cedure in using rtc interrupt write 0 to bit 5 in isr register interrupt handling rte read isr register clear the irq5f flag figure 11.6 example of rtc interrupt handling routine 11.6 operating state in each mode table 11.3 shows the operating state in each mode when the rtc is set for clock operation and free running timer operation. the clock operation is performed continuously even in low power mode. therefore, when the clock operation is unnecessary, cancel it by exmdlstp. section 11 realtime clock (rtc) rev.6.00 jun. 03, 2008 page 362 of 698 rej09b0074-0600 table 11.3 operating state in each mode function high- speed medium- speed sleep module stop watch subactive subsleep software standby hard-ware standby clock operation subclock operation subclock operation subclock operation halted (retained) subclock operation subclock operation subclock operation subclock operation halted (reset) free running timer operation operating operating operating halted (retained) halted (retained) halted (retained) halted (retained) halted (retained) halted (reset) 11.7 usage notes (1) notes on using the emulator in the e6000 emulator the rtc module is mounted on an external extended board. since it must be accessed as an external module, the limitations listed below apply. these limitations do not apply to the e10a or to product chips. ? rtc operation is not supported in the h8s/2218 group's mode 7 (single-chip mode). ? when using the rtc module in the h8s/2218 group's mode 6 (on-chip rom-enabled mode) or the h8s/2212 group's mode 7 (single-chip mode), a7 to a0 are input pins in the initial status. therefore, a7 to a0 must be set as ou tput pins by setting pc7ddr to pc0ddr to h'ff before accessing the rtc module. ? the above setting is not necessary when using the rtc module in the h8s/2218 group's modes 4 and 5 (on-chip rom-disabled mode) because a7 to a0 are output pins. (2) bus interface the bus interface of the module conforms to the bus specifications for external area 7. consequently, before accessing the rtc module, area 7 must be specified as having an 8-bit bus width and 3-state access using the bus controller register. (3) method for reading pin states using the port d register (portd) first access exmdlstp or the rtc register (address range: h'ffff40 to h'ffff5f). then, you must perform a dummy read to the external address space (such as h'ffef00 to h'ff7ff) outside the range h'ffff40 to h'ffff5f before reading portd. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 363 of 698 rej09b0074-0600 section 12 serial communication interface this lsi has two independent serial communication interface (sci) channels. the sci can handle both asynchronous and clocked synchronous serial communication. asynchronous serial data communication can be carried out using standard asynchronous communication chips such as a universal asynchronous receiver/transmitter (uart) or an asynchronous communication interface adapter (acia). a function is also provided for serial communication between processors (multiprocessor communication functio n). the sci also supports the smart card (ic card) interface based on iso/iec 7816-3 (identification card) as an enhanced asynchronous communication function. 12.1 features ? choice of asynchronous or clocked synchronous serial communication mode ? full-duplex communication capability the transmitter and receiver are mutually indepe ndent, enabling transmis sion and reception to be executed simultaneously. double-buffering is used in both the transm itter and the receiver, enabling continuous transmission and continuous reception of serial data. on-chip baud rate generator allows any bit rate to be selected external clock can be selected as a transfer clock source (except for in smart card interface mode). ? choice of lsb-first or msb-first transfer (except in the case of asynchronous mode 7-bit data) ? four interrupt sources transmit-end, transmit-data-empty, receive-data-full, and receive error ? that can issue requests. the transmit-data-empty interrupt and receive data full interrupts can be used to activate the direct memory access controller (dmac). ? module stop mode can be set asynchronous mode ? data length: 7 or 8 bits ? stop bit length: 1 or 2 bits ? parity: even, odd, or none ? receive error detection: parity, overrun, and framing errors ? break detection: break can be detected by read ing the rxd pin level directly in the case of a framing error section 12 serial communication interface rev.6.00 jun. 03, 2008 page 364 of 698 rej09b0074-0600 ? average transfer rate generator (sci_0): 921.569 kbps, 720 kbps, 460.784 kbps, or 115.196 kbps can be selected at 16 mhz 921.053 kbps, 720 kbps, 460.526 kbps, or 115.132 kbps can be selected at 24 mhz ? a transfer rate clock can be input from the tpu (sci_0) ? communication between multiple processors is supported clocked synchronous mode ? data length: 8 bits ? receive error detection: overrun errors detected ? sci select function (sci_0): txd0 = high-impedance and sck0 = fixed high-level input can selected when irq7 = 1) ? serial data communication can be carried out with other chips that have a synchronous communication function smart card interface ? an error signal can be automatically transmitted on detection of a parity error during reception ? data can be automatically re-transmitted on detection of a error signal during transmission ? both direct convention and inverse convention are supported section 12 serial communication interface rev.6.00 jun. 03, 2008 page 365 of 698 rej09b0074-0600 12.1.1 block diagram figure 12.1 shows the block diagram of the sci_0. figure 12.2 shows the block diagram of the sci_2. rxd0 txd0 pg1/ irq7 c/a cke1 sse sck0 clock external clock tei txi rxi eri rsr: rdr: tsr: tdr: smr: receive shift register receive data register transmit shift register transmit data register serial mode register scr: ssr: scmr: brr: semra_0: semrb_0: serial control register serial status register smart card mode register bit rate register serial extended mode register a_0 serial extended mode register b_0 scmr ssr scr smr semra_0 semrb_0 control transmission and reception baud rate generator average transfer rate generator 10.667 mhz 115.152 kbps 460.606 kbps 16 mhz 115.196 kbps 460.784 kbps 720 kbps 921.569 kbps 24 mhz 115.132 kbps 460.526 kbps 720 kbps 921.053 kbps brr tpu tiocc0 tioca1 tioca0 tioca2 module data bus rdr tsr rsr parity generation legend: tdr sci transfer clock generator in tpu parity check internal data bus bus interface /4 /16 /64 figure 12.1 block diagram of sci_0 section 12 serial communication interface rev.6.00 jun. 03, 2008 page 366 of 698 rej09b0074-0600 rxd txd sck clock external clock /4 /16 /64 tei txi rxi eri rsr: rdr: tsr: tdr: smr: scr: ssr: scmr: brr: receive shift register receive data register transmit shift register transmit data register serial mode register serial control register serial status register smart card register bit rate register scmr ssr scr smr control transmission and reception baud rate generator brr module data bus rdr tsr rsr detecting parity parity check legend: tdr internal data bus bus interface figure 12.2 block diagram of sci_2 section 12 serial communication interface rev.6.00 jun. 03, 2008 page 367 of 698 rej09b0074-0600 12.2 input/output pins table 12.1 shows the serial pins for each sci channel. table 12.1 pin configuration channel pin name * i/o function sck0 i/o sci_0 clock input/output rxd0 input sci_0 receive data input 0 txd0 output sci_0 transmit data output 2 sck2 i/o sci_2 clock input/output rxd2 input sci_2 receive data input txd2 output sci_2 transmit data output note: * pin names sck, rxd, and txd are used in the text for all channels, omitting the channel designation. 12.3 register descriptions the sci has the following registers for each channel. some bits in the serial mode register (smr), serial status register (ssr), and serial control re gister (scr) have different functions in different modes ? normal serial communication interface mode and smart card interface mode; therefore, the bits are described separately for each mode in the corresponding register sections. ? receive shift register (rsr) ? receive data register (rdr) ? transmit data register (tdr) ? transmit shift register (tsr) ? serial mode register (smr) ? serial control register (scr) ? serial status register (ssr) ? smart card mode register (scmr) ? serial extended mode register a_0 (semra_0) (only for channel 0) ? serial extended mode register b_0 (semrb_0) (only for channel 0) ? bit rate register (brr) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 368 of 698 rej09b0074-0600 12.3.1 receive shift register (rsr) rsr is a shift register that is used to receive se rial data input to the rxd pin and convert it into parallel data. when one byte of data has been received, it is transferred to rdr automatically. rsr cannot be directly accessed by the cpu. 12.3.2 receive data register (rdr) rdr is an 8-bit register that stores received data. when the sci has received one byte of serial data, it transfers the received serial data from rsr to rdr, where it is stored. after this, rsr is receive-enabled. as rsr and rdr function as a double buffer in this way, continuous receive operations are possible. after confirming that the rdrf bit in ssr is set to 1, read rdr only once. rdr cannot be written to by the cpu. rdr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, or module stop mode. 12.3.3 transmit data register (tdr) tdr is an 8-bit register that stores data for transmission. when the sci detects that tsr is empty, it transfers the transmit data written in tdr to ts r and starts transmission. the double-buffered structure of tdr and tsr enables continuous serial transmission. if the next transmit data has already been written to tdr during serial transm ission, the sci transfers the written data to tsr to continue transmission. although tdr can be read from or written to by the cpu at all times, to achieve reliable serial transmission, write transmit data to tdr only once after confirming that the tdre bit in ssr is set to 1. tdr is initialized to h'ff by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, or module stop mode. 12.3.4 transmit shift register (tsr) tsr is a shift register that transmits serial data. to perform serial data transmission, the sci first transfers transmit data from tdr to tsr, then sends the data to the txd pin. tsr cannot be directly accessed by the cpu. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 369 of 698 rej09b0074-0600 12.3.5 serial mode register (smr) smr is used to set the sci's serial transfer format and select the baud rate generator clock source. some bits in smr have different functions in normal mode and smart card interface mode. ? normal serial communication interface mode (when smif in scmr is 0) bit bit name initial value r/w description 7 c/ a 0 r/w communication mode 0: asynchronous mode 1: clocked synchronous mode 6 chr 0 r/w character length (enabled only in asynchronous mode) 0: selects 8 bits as the data length 1: selects 7 bits as the data length. lsb-first is fixed and the msb of tdr is not transmitted in transmission in clocked synchronous mode, a fixed data length of 8 bits is used. 5 pe 0 r/w parity enable (enabled only in asynchronous mode) when this bit is set to 1, the parity bit is added to transmit data before transmission, and the parity bit is checked in reception. for a multiprocessor format, parity bit addition and checking are not performed regardless of the pe bit setting. 4 o/ e 0 r/w parity mode (enabled only when the pe bit is 1 in asynchronous mode) 0: selects even parity 1: selects odd parity 3 stop 0 r/w stop bit length (enabled only in asynchronous mode) selects the stop bit length in transmission. 0: 1 stop bit 1: 2 stop bits in reception, only the first stop bit is checked. if the second stop bit is 0, it is treated as the start bit of the next transmit character. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 370 of 698 rej09b0074-0600 bit bit name initial value r/w description 2 mp 0 r/w multiprocessor mode (enabled only in asynchronous mode) when this bit is set to 1, the multiprocessor communication function is enabled. the pe bit and o/ e bit settings are invalid in multiprocessor mode. for details, see section 12.5, multi processor communication function. 1 0 cks1 cks0 0 0 r/w r/w clock select 0 and 1: these bits select the clock source for the baud rate generator. 00: clock (n = 0) 01: /4 clock (n = 1) 10: /16 clock (n = 2) 11: /64 clock (n = 3) for the relationship between the bit rate register setting and the baud rate, see section 12.3.11, bit rate register (brr). n is the decimal representation of the value of n in brr (see section 12.3.11, bit rate register (brr)). section 12 serial communication interface rev.6.00 jun. 03, 2008 page 371 of 698 rej09b0074-0600 ? smart card interface mode (when smif in scmr is 1) bit bit name initial value r/w description 0 gsm mode setting this bit to 1 allows gsm mode operation. in gsm mode, the tend set timing is put forward to 11.0 etu from the start and the clock output control function is appended. for details, see section 12.7.9, clock output control. 0: normal smart card interface mode operation (initial value) (1) the tend flag is generated 12.5 etu (11.5 etu in the block transfer mode) after the beginning of the start bit. (2) clock output on/off control only. 7 gm r/w 1: gsm mode operation in smart card interface mode (1) the tend flag is generated 11.0 etu after the beginning of the start bit. (2) in addition to clock output on/off control, high/how fixed control is supported (set using scr). 6 blk 0 r/w setting this bit to 1 allows block transfer mode operation. for details, see section 12.7.4, block transfer mode. 0: normal smart card interface mode operation (initial value) (1) error signal transmission, detection, and automatic data retransmission are performed. (2) the txi interrupt is generated by the tend flag. (3) the tend flag is set 12.5 etu (11.0 etu in the gsm mode) after transmission starts. 1: operation in block transfer mode (1) error signal transmission, detection, and automatic data retransmission are not performed. (2) the txi interrupt is generated by the tdre flag. (3) the tend flag is set 11.5 etu (11.0 etu in the gsm mode) after transmission starts. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 372 of 698 rej09b0074-0600 bit bit name initial value r/w description 5 pe 0 r/w parity enable when this bit is set to 1, the parity bit is added to transmit data before transmission, and the parity bit is checked in reception. set this bit to 1 in smart card interface mode. 4 o/ e 0 r/w parity mode (valid only when the pe bit is 1) 0: selects even parity 1: selects odd parity for details on the usage of this bit in smart card interface mode, see section 12.7.2, data format (except in block transfer mode). 3 2 bcp1 bcp0 0 0 r/w r/w basic clock pulse 1 and 0 these bits select the number of basic clock cycles in a 1- bit data transfer time in smart card interface mode. 00: 32 clock cycles (s = 32) 01: 64 clock cycles (s = 64) 10: 372 clock cycles (s = 372) 11: 256 clock cycles (s = 256) for details, see section 12.7.5, receive data sampling timing and reception margin. s is described in section 12.3.11, bit rate register (brr). 1 0 cks1 cks0 0 0 r/w r/w clock select 1 and 0 these bits select the clock source for the baud rate generator. 00: clock (n = 0) 01: /4 clock (n = 1) 10: /16 clock (n = 2) 11: /64 clock (n = 3) for the relation between the bit rate register setting and the baud rate, see section 12.3.11, bit rate register (brr). n is the decimal display of the value of n in brr (see section 12.3.11, bit rate register (brr)). section 12 serial communication interface rev.6.00 jun. 03, 2008 page 373 of 698 rej09b0074-0600 12.3.6 serial control register (scr) scr is a register that enables or disables sci tran sfer operations and interrupt requests, and is also used to selection of the transfer clock source. for details on interrupt requests, refer to section 12.9, interrupts. some bits in scr have different functions in normal mode and smart card interface mode. ? normal serial communication interface mode (when smif in scmr is 0) bit bit name initial value r/w description 7 tie 0 r/w transmit interrupt enable when this bit is set to 1, the txi interrupt request is enabled. txi interrupt request cancellation can be performed by reading 1 from the tdre flag, then clearing it to 0, or clearing the tie bit to 0. 6 rie 0 r/w receive interrupt enable when this bit is set to 1, rxi and eri interrupt requests are enabled. rxi and eri interrupt request cancellation can be performed by reading 1 from the rdrf flag, or the fer, per, or orer flag, then clearing the flag to 0, or clearing the rie bit to 0. 5 te 0 r/w transmit enable when this bit s set to 1, transmission is enabled. in this state, serial transmission is started when transmit data is written to tdr and the tdre flag in ssr is cleared to 0. smr setting must be performed to decide the transfer format before setting the te bit to 1. the tdre flag in ssr is fixed at 1 if transmission is disabled by clearing this bit to 0. 4 re 0 r/w receive enable when this bit is set to 1, reception is enabled. serial reception is started in this state when a start bit is detected in asynchronous mode or serial clock input is detected in clocked synchronous mode. smr setting must be performed to decide the transfer format before setting the re bit to 1. clearing the re bit to 0 does not affect the rdrf, fer, per, and orer flags, which retain their states. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 374 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 mpie 0 r/w multiprocessor interrupt enable (enabled only when the mp bit in smr is 1 in asynchronous mode) when this bit is set to 1, receive data in which the multiprocessor bit is 0 is skipped, and setting of the rdrf, fer, and orer status flags in ssr is prohibited. on receiving data in which the multiprocessor bit is 1, this bit is automatically cleared and normal reception is resumed. for details, refer to section 12.5, multiprocessor communication function. when receive data including mpb = 0 is received, receive data transfer from rsr to rdr, receive error detection, and setting of the rdrf, fer, and orer flags in ssr, is not performed. when receive data including mpb = 1 is received, the mpb bit in ssr is set to 1, the mpie bit is cleared to 0 automatically, and generation of rxi and eri interrupts (when the tie and rie bits in scr are set to 1) and fer and orer flag setting is enabled. 2 teie 0 r/w transmit end interrupt enable this bit is set to 1, tei interrupt request is enabled. tei cancellation can be performed by reading 1 from the tdre flag in ssr, then clearing it to 0 and clearing the tend flag to 0, or clearing the teie bit to 0. 1 0 cke1 cke0 0 0 r/w r/w clock enable 0 and 1 selects the clock source and sck pin function. asynchronous mode 00: internal baud rate generator sck pin functions as i/o port 01: internal baud rate generator outputs a clock of the same frequency as the bit rate from the sck pin. 1 : external clock inputs a clock with a frequency 16 times the bit rate from the sck pin. clocked synchronous mode 0 : internal clock (sck pin functions as clock output) 1 : external clock (sck pin functions as clock input) legend: : don?t care section 12 serial communication interface rev.6.00 jun. 03, 2008 page 375 of 698 rej09b0074-0600 ? smart card interface mode (when smif in scmr is 1) bit bit name initial value r/w description 7 tie 0 r/w transmit interrupt enable when this bit is set to 1, txi interrupt request is enabled. txi interrupt request cancellation can be performed by reading 1 from the tdre flag in ssr, then clearing it to 0, or clearing the tie bit to 0. 6 rie 0 r/w receive interrupt enable when this bit is set to 1, rxi and eri interrupt requests are enabled. rxi and eri interrupt request cancellation can be performed by reading 1 from the rdrf, fer, per, or orer flag in ssr, then clearing the flag to 0, or clearing the rie bit to 0. 5 te 0 r/w transmit enable when this bit s set to 1, transmission is enabled. in this state, serial transmission is started when transmit data is written to tdr and the tdre flag in ssr is cleared to 0. smr setting must be performed to decide the transfer format before setting the te bit to 1. when this bit is cleared to 0, the transmission operation is disabled, and the tdre flag is fixed at 1. 4 re 0 r/w receive enable when this bit is set to 1, reception is enabled. serial reception is started in this state when a start bit is detected in asynchronous mode or serial clock input is detected in clocked synchronous mode. smr setting must be performed to decide the reception format before setting the re bit to 1. clearing the re bit to 0 does not affect the rdrf, fer,per, and orer flags, which retain their states. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 376 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 mpie 0 r/w multiprocessor interrupt enable (enabled only when the mp bit in smr is 1 in asynchronous mode) write 0 to this bit in smart card interface mode. when receive data including mpb = 0 is received, receive data transfer from rsr to rdr, receive error detection, and setting of the rerf, fer, and orer flags in ssr, are not performed. when receive data including mpb = 1 is received, the mpb bit in ssr is set to 1, the mpie bit is cleared to 0 automatically, and generation of rxi and eri interrupts (when the tie and rie bits in scr are set to 1) and fer and orer flag setting are enabled. 2 teie 0 r/w transmit end interrupt enable write 0 to this bit in smart card interface mode. tei cancellation can be performed by reading 1 from the tdre flag in ssr, then clearing it to 0 and clearing the tend flag to 0, or clearing the teie bit to 0. 1 0 cke1 cke0 0 0 r/w clock enable 0 and 1 enables or disables clock output from the sck pin. the clock output can be dynamically switched in gsm mode. for details, refer to section 12.7.9, clock output control. when the gm bit in smr is 0: 00: output disabled (sck pin can be used as an i/o port pin) 01: clock output 1 : reserved when the gm bit in smr is 1: 00: output fixed low 01: clock output 10: output fixed high 11: clock output legend: : don?t care section 12 serial communication interface rev.6.00 jun. 03, 2008 page 377 of 698 rej09b0074-0600 12.3.7 serial status register (ssr) ssr is a register containing status flags of the sci and multiprocessor bits for transfer. 1 cannot be written to flags tdre, rdrf, orer, per, and fer; they can only be cleared. some bits in ssr have different functions in normal mode and smart card interface mode. ? normal serial communication interface mode (when smif in scmr is 0) bit bit name initial value r/w description 7 tdre 1 r/(w) * transmit data register empty displays whether tdr contains transmit data. [setting conditions] ? when the te bit in scr is 0 ? when data is transferred from tdr to tsr and data can be written to tdr [clearing conditions] ? when 0 is written to tdre after reading tdre = 1 ? when the dmac is activated by a txi interrupt request and writes data to tdr 6 rdrf 0 r/(w) * receive data register full indicates that the received data is stored in rdr. [setting condition] when serial reception ends normally and receive data is transferred from rsr to rdr [clearing conditions] ? when 0 is written to rdrf after reading rdrf = 1 ? when the dmac is activated by an rxi interrupt and transferred data from rdr rdr and the rdrf flag are not affected and retain their previous values when the re bit in scr is cleared to 0. the rdrf flag is not affected and retains their previous values when the re bit in scr is cleared to 0. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 378 of 698 rej09b0074-0600 bit bit name initial value r/w description 5 orer 0 r/(w) * overrun error [setting condition] ? when the next serial reception is completed while rdrf = 1 the receive data prior to the overrun error is retained in rdr, and the data receiv ed subsequently is lost. also, subsequent serial reception cannot be continued while the orer flag is set to 1. in clocked synchronous mode, serial transmission cannot be continued, either. [clearing condition] ? when 0 is written to orer after reading orer = 1 the orer flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 4 fer 0 r/(w) * framing error [setting condition] ? when the stop bit is 0 in 2-stop-bit mode, only the first stop bit is checked for a value of 0; the second stop bits not checked. if a framing error occurs, the receive data is transferred to rdr but the rdrf flag is not set. also, subsequent serial reception cannot be continued while the fer flag is set to 1. in clocked synchronous mode, serial transmission cannot be continued, either. [clearing condition] ? when 0 is written to fer after reading fer = 1 the fer flag is not affected and retains its previous state when the re bit in scr is cleared to 0. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 379 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 per 0 r/(w) * parity error [setting condition] ? when a parity error is detected during reception if a parity error occurs, the receive data is transferred to rdr but the rdrf flag is not set. also, subsequent serial reception cannot be continued while the per flag is set to 1. in clocked synchronous mode, serial transmission cannot be continued, either. [clearing condition] ? when 0 is written to per after reading per = 1 the per flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2 tend 1 r transmit end [setting conditions] ? when the te bit in scr is 0 ? when tdre = 1 at transmission of the last bit of a 1- byte serial transmit character [clearing conditions] ? when 0 is written to tdre after reading tdre = 1 ? when the dmac is activated by a txi interrupt and writes data to tdr 1 mpb 0 r multiprocessor bit mpb stores the multiprocessor bit in the receive data. when the re bit in scr is cleared to 0 its previous state is retained. this bit retains its previous state when the re bit in scr is cleared to 0. 0 mpbt 0 r/w multiprocessor bit transfer mpbt stores the multiprocessor bit to be added to the transmit data. note: * the write value should always be 0 to clear the flag. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 380 of 698 rej09b0074-0600 ? smart card interface mode (when smif in scmr is 1) bit bit name initial value r/w description 7 tdre 1 r/(w) * transmit data register empty indicates whether tdr contains transmit data. [setting conditions] ? when the te bit in scr is 0 ? when data is transferred from tdr to tsr and data can be written to tdr [clearing conditions] ? when 0 is written to tdre after reading tdre = 1 ? when the dmac is activated by a txi interrupt request and writes data to tdr 6 rdrf 0 r/(w) * receive data register full indicates that the received data is stored in rdr. [setting condition] when serial reception ends normally and receive data is transferred from rsr to rdr [clearing conditions] ? when 0 is written to rdrf after reading rdrf = 1 ? when the dmac is activated by an rxi interrupt and transferred data from rdr the rdrf flag is not affected and retains their previous values when the re bit in scr is cleared to 0. if reception of the next data is completed while the rdrf flag is still set to 1, an overrun error will occur and the receive data will be lost. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 381 of 698 rej09b0074-0600 bit bit name initial value r/w description 5 orer 0 r/(w) * overrun error indicates that an overrun error occurred during reception, causing abnormal termination. [setting condition] ? when the next serial reception is completed while rdrf = 1 the receive data prior to the overrun error is retained in rdr, and the data receiv ed subsequently is lost. also, subsequent serial cannot be continued while the orer flag is set to 1. in clocked synchronous mode, serial transmission cannot be continued, either. [clearing condition] ? when 0 is written to orer after reading orer = 1 the orer flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 4 ers 0 r/(w) * error signal status indicates that the status of an error, signal 1 returned from the reception side at reception [setting condition] ? when the low level of the error signal is sampled [clearing condition] ? when 0 is written to ers after reading ers = 1 the ers flag is not affected and retains its previous state when the re bit in scr is cleared to 0. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 382 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 per 0 r/(w) * parity error indicates that a parity error occurred during reception using parity addition in asynchronous mode, causing abnormal termination. [setting condition] ? when a parity error is detected during reception if a parity error occurs, the receive data is transferred to rdr but the rdrf flag is not set. also, subsequent serial reception cannot be continued while the per flag is set to 1. in clocked synchronous mode, serial transmission cannot be continued, either. [clearing condition] ? when 0 is written to per after reading per = 1 the per flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2 tend 1 r transmit end this bit is set to 1 when no error signal has been sent back from the receiving end and the next transmit data is ready to be transferred to tdr. [setting conditions] ? when the te bit in scr is 0 and the ers bit is also 0 ? when the ers bit is 0 and the tdre bit is 1 after the specified interval following transmission of 1-byte data. the timing of bit setting differs according to the register setting as follows: when gm = 0 and blk = 0, 12.5 etu after transmission starts when gm = 0 and blk = 1, 11.5 etu after transmission starts when gm = 1 and blk = 0, 11.0 etu after transmission starts when gm = 1 and blk = 1, 11.0 etu after transmission starts [clearing conditions] ? when 0 is written to tdre after reading tdre = 1 ? when the dmac is activated by a txi interrupt and transfers transmission data to tdr section 12 serial communication interface rev.6.00 jun. 03, 2008 page 383 of 698 rej09b0074-0600 bit bit name initial value r/w description 1 mpb 0 r multiprocessor bit this bit is not used in smart card interface mode. 0 mpbt 0 r/w multiprocessor bit transfer write 0 to this bit in smart card interface mode. note: * the write value should always be 0 to clear the flag. 12.3.8 smart card mode register (scmr) scmr is a register that selects the transfer format. in this lsi, smart card interface mode cannot be specified. bit bit name initial value r/w description 7 to 4 ? all 1 ? reserved these bits are always read as 1. 3 dir 0 r/w data transfer direction selects the serial/parallel conversion format. 0: lsb-first in transfer 1: msb-first in transfer the bit setting is valid only when the transfer data format is 8 bits. 2 inv 0 r/w data invert specifies inversion of the data logic level. the sinv bit does not affect the logic level of the parity bit. to invert the parity bit, invert the o/ e bit in smr. 0: tdr contents are transmitted as they are. receive data is stored as it is in rdr 1: tdr contents are inverted before being transmitted. receive data is stored in inverted form in rdr 1 ? 1 ? reserved this bit is always read as 1. 0 smif 0 r/w smart card interface mode select when this bit is set to 1, smart card interface mode is selected. 0: normal asynchronous or clocked synchronous mode 1: smart card interface mode section 12 serial communication interface rev.6.00 jun. 03, 2008 page 384 of 698 rej09b0074-0600 12.3.9 serial extended mode register a_0 (semra_0) semra_0 extends the functions of sci_0. semr0 enables selection of the sci_0 select function in synchronous mode, base clock setting in asynchronous mode, and also clock source selection and automatic transfer rate setting. figure 12.3 shows an example of the internal base clock when an average transfer rate is selected and figure 12.4 shows as example of the setting when the tpu clock input is selected. bit bit name initial value r/w description 7 sse 0 r/w sci_0 select enable allows selection of the sci0 select function when an external clock is input in synchronous mode. the sse setting is valid when external clock input is used (cke1 = 1 in scr) in synchronous mode (c/ a = 1 in smr). 0: sci_0 select function disabled 1: sci_0 select function enabled when the sci_0 select function is enabled, if 1 is input to the pg1/ irq7 pin, txd0 output goes to the high-impedance state, sck0 input is fixed high. 6 5 4 tcs2 tcs1 tcs0 0 0 0 r/w r/w r/w tpu clock select when the tpu clock is input (acs3 to acs0 = b'0100) as the clock source in asynchronous mode, serial transfer clock is generated depending on the combination of the tpu clock. base clock clock enable tclka tclkb tclkc 000 tioca1 tioca2 base clock written in the left column pin input pin input 001 tioca0 | tiocc0 tioca1 pin input base clock written in the left column pin input 010 tioca0 tioca1 & tioca2 pin input base clock written in the left column pin input 011 tioca0 | tiocc0 tioca1 & tioca2 pin input base clock written in the left column pin input 1 reserved (setting prohibited) legend: &: and (logical multiplication) i : or (logical addition) note: the functions of bits 6 to 4 are not supported by the e6000 emulator. figure 12.4 shows the setting examples. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 385 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 abcs 0 r/w asynchronous base clock select selects the 1-bit-interval base clock in asynchronous mode. the abcs setting is valid in asynchronous mode (c/ a = 0 in smr). 0: sci_0 operates on base clock with frequency of 16 times transfer rate 1: sci_0 operates on base clock with frequency of 8 times transfer rate 2 1 0 acs2 acs1 acs0 0 0 0 r/w r/w r/w asynchronous clock source select 2 to 0 these bits select the clock source in asynchronous mode depending on the combination with the bit 7 (acs3) in semrb_0 (serial extended mode register b_0). when an average transfer rate is selected, the base clock is set automatically regardless of the abcs value. note that average transfer rates support only 10.667 mhz, 16 mhz, and 24 mhz, and not support other operating frequencies. set acs3 to acs0 when inputting the external clock (the cke1 bit in the scr register is 1) in asynchronous mode (the c/ a bit in the smr register is 0). figures 12.3 and 12.4 show the setting examples. acs 3210 0000: external clock input 0001: 115.152 kbps average transfer rate (for = 10.667 mhz only) is selected (sci_0 operates on base clock with frequency of 16 times transfer rate) 0010: 460.606 kbps average transfer rate (for = 10.667 mhz only) is selected (sci_0 operates on base clock with frequency of eight times transfer rate) 0011: 921.569 kbps average transfer rate (for = 16 mhz only) is selected (sci_0 operates on base clock with frequency of eight times transfer rate) 0100: tpu clock input the signal generated by tioca0, tiocc0, tioca1, and tioca2, which are the compare match outputs for tpu_0 to tpu_2 or pwm outputs, is used as a base clock. note that irq0 and irq1 cannot be used since tioca1 and tioca2 are used as outputs. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 386 of 698 rej09b0074-0600 bit bit name initial value r/w description 2 1 0 acs2 acs1 acs0 0 0 0 r/w r/w r/w 0101: 115.196 kbps average transfer rate (for = 16 mhz only) is selected (sci_0 operates on base clock with frequency of 16 times transfer rate) 0110: 460.784 kbps average transfer rate (for = 16 mhz only) is selected (sci_0 operates on base clock with frequency of eight times transfer rate) 0111: 720 kbps average transfer rate (for = 16 mhz only) is selected (sci_0 operates on base clock with frequency of eight times transfer rate) 1000: 115.132 kbps average transfer rate (for = 24 mhz only) is selected * (sci_0 operates on base clock with frequency of 16 times transfer rate) 1001: 460.526 kbps average transfer rate (for = 24 mhz only) is selected * (sci_0 operates on base clock with frequency of 16 times transfer rate) 1010: 720 kbps average transfer rate (for = 24 mhz only) is selected * (sci_0 operates on base clock with frequency of eight times transfer rate) 1011: 921.053 kbps average transfer rate (for = 24 mhz only) is selected * (sci_0 operates on base clock with frequency of eight times transfer rate) 11 : reserved (setting prohibited) note: * the average transfer rate select functions for 24 mhz only (acs3 to acs0 = b'10xx) are not supported by the e6000 emulator. 12.3.10 serial extended mode register b_0 (semrb_0) semrb_0 enables clock source selection with the combination of semra_0, automatic transfer rate setting, and control of port 1 pins (p16, p14, p12, and p10) at the transfer clock generation by tpu. note: semrb_0 is not supported by the e6000 emulator. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 387 of 698 rej09b0074-0600 bit bit name initial value r/w description 7 acs3 0 r/w asynchronous clock source select selects the clock source in asynchronous mode depending on the combination with the acs2 to acs0 (bits 2 to 0 in semra_0). for details, see section 12.3.9, serial extended mode register a_0 (semra_0). 6 to 4 ? undefined ? reserved the write value should always be 0. 3 tioca2e 1 r/w tioca2 output enable controls the tioca2 output on the p16 pin. when the tioca2 in tpu is output to generate the transfer clock, p16 is used as other function pin by setting this bit to 0. 0: disables output of tioca2 in tpu 1: enables output of tioca2 in tpu 2 tioca1e 1 r/w tioca1 output enable controls the tioca1 output on the p14 pin. when the tioca1 in tpu is output to generate the transfer clock, p14 is used as other function pin by setting this bit to 0. 0: disables output of tioca1 in tpu 1: enables output tioca1 in tpu 1 tiocc0e 1 r/w tiocc0 output enable controls the tiocc0 output on the p12 pin. when the tiocc0 in tpu is output to generate the transfer clock, p12 is used as other function pin by setting this bit to 0. 0: disables output of tiocc0 in tpu 1: enables output of tiocc0 in tpu 0 tioca0e 1 r/w tioca0 output enable controls the tioca0 output on the p10 pin. when the tioca0 in tpu is output to generate the transfer clock, p10 is used as other function pin by setting this bit to 0. 0: disables output of tioca0 in tpu 1: enables output of tioca0 in tpu section 12 serial communication interface rev.6.00 jun. 03, 2008 page 388 of 698 rej09b0074-0600 1234567891011 123 45 67 8 12 13 14 15 16 17 18 19 20 21 23 22 24 25 26 27 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 1 2 3 4 28 29 5.333 mhz 3.6848 mhz 123 123 4 5 6 7 8 9 10111213141516171819 2021 23 22 4 5 6 7 8 9 10 11 12 13 14 15 16 24 25 26 27 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 1 2 3 4 28 29 2.667 mhz 1.8424 mhz base clock 10.667 mhz/2 = 5.333 mhz 5.333 mhz (38/55) = 3.6848 mhz (average) 1 bit = base clock 8 * base clock with 460.606-kbps average transfer rate (acs3 to acs0 = b'0010) average transfer rate = 3.6848 mhz/8 = 460.606 kbps average error with 460.6 kbps = -0.043% 1 bit = base clock 16 * base clock 10.667 mhz/4= 2.667 mhz 2.667 mhz (38/55) = 1.8424 mhz (average) when = 10.667 mhz base clock with 115.152-kbps average transfer rate (acs3 to acs0 = b'0001) average transfer rate = 1.8424 mhz/16 = 115.152 kbps average error with 115.2 kbps = -0.043% note: * the lengh of one bit varies according to the base clock synchronization. figure 12.3 examples of base clock wh en average transfer rate is selected (1) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 389 of 698 rej09b0074-0600 123456789 10 123 45 67 8 11 12 13 14 15 16 17 18 19 20 21 23 22 2425 1 2 5 6 7 8 9 101112131415 161718 19202122232425 34 8 mhz 7.3725 mhz 123456789 10 11 12 13 14 15 16 17 123456789 10 11 12 13 14 15 16 18 19 20 21 23 22 24 25 26 27 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 1 2 3 4 5 6 7 8 28 29 8 mhz 8 mhz 7.3725 mhz 123456789 10 11 12 13 14 15 16 17 12345678 18 19 20 21 23 22 24 25 26 27 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 1 2 3 4 5 6 7 8 28 29 5.76 mhz 123 2 mhz 1.8431 mhz 456789 10 11 12 13 14 15 16 17 123456789 10 11 12 13 14 15 16 18 19 20 21 23 22 24 25 26 27 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 1 2 3 4 5 6 7 8 28 29 base clock 16 mhz/2 = 8 mhz 8 mhz (18/25) = 5.76 mhz (average) base clock with 720-kbps average transfer rate (acs3 to acs0 = b'0111) average transfer rate = 5.76 mhz/8 = 720 kbps average error with 720 kbps = 0% base clock 16 mhz/2 = 8 mhz 8 mhz (47/51) = 7.3725 mhz (average) base clock with 921.569-kbps average transfer rate (acs3 to acs0 = b'0011) average transfer rate = 7.3725 mhz/8 = 921.569 kbps average error with 921.6 kbps = -0.003% note: * the lengh of one bit varies according to the base clock synchronization. base clock 16 mhz/2 = 8 mhz 8 mhz (47/51) = 7.3725 mhz (average) 1 bit = base clock 16 * 1 bit = base clock 8 * 1 bit = base clock 8 * base clock with 460.784-kbps average transfer rate (acs3 to acs0 = b'0110) average transfer rate = 7.3725 mhz/16 = 460.784 kbps average error with 460.8 kbps = -0.004% 1 bit = base clock 16 * base clock 16 mhz/8 = 2 mhz 2 mhz (47/51) = 1.8431 mhz (average) when = 16 mhz base clock with 115.196-kbps average transfer rate (acs3 to acs0 = b'0101) average transfer rate = 1.8431 mhz/16 = 115.196 kbps average error with 115.2 kbps = -0.004% figure 12.3 examples of base clock wh en average transfer rate is selected (2) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 390 of 698 rej09b0074-0600 123 4 56789101112131 4 15 16 17 18 19 20 21 23 22 2 4 25 1 2 5 6 7 8 9 101112131 4 15 16 17 18 19 20 21 22 23 2 4 25 3 4 12 m h z 5 . 76 m h z 123 3 m h z 1 . 8 4 21 m h z 4 56789101112131 4 15 16 17 1 18 19 20 21 23 22 2 4 25 26 23 4 56789101112 1 4 13 15 16 27 30 31 32 33 3 4 35 36 37 38 39 4 0 4 1 4 2 4 3 44 4 5 4 6 4 7 4 8 4 9505152535 4 55 56 57 1 2 28 29 123 12 m h z 7 . 368 4 m h z 4 56789101112131 4 15 16 17 1 18 19 20 21 23 22 2 4 25 26 23 4 56789101112 1 4 13 15 16 27 30 31 32 33 3 4 35 36 37 38 39 4 0 4 1 4 2 4 3 44 4 5 4 6 4 7 4 8 4 9505152535 4 55 56 57 1 2 28 29 123 12 m h z 7 . 368 4 m h z 4 56789101112131 4 15 16 17 1 18 19 20 21 23 22 2 4 25 26 23 4 5678 1 23 4 5678 27 30 31 32 33 3 4 35 36 37 38 39 4 0 4 1 4 2 4 3 44 4 5 4 6 4 7 4 8 4 9505152535 4 55 56 57 1 2 28 29 base c l ock 2 4 m h z / 2 = 12 m h z 12 m h z (12 / 25) = 5 . 76 m h z (average) base c l ock w i th 720 - kbps average transfer rate (acs3 to acs0 = b ' 1010) average transfer rate = 5 . 76 m h z / 8 = 720 kbps average error w i th 720 kbps = 0% base c l ock 2 4 m h z / 2 = 12 m h z 12 m h z (35 / 57) = 7 . 368 4 m h z (average) base c l ock w i th 921 . 053 - kbps average transfer rate (acs3 to acs0 = b ' 1011) average transfer rate = 7 . 368 4 m h z / 8 = 921 . 053 kbps average error w i th 921 . 1 kbps = - 0 . 059% n ote : * t he l engh of one b i t var i es accord i ng to the base c l ock synchron i zat i on . base c l ock 2 4 m h z / 2 = 12 m h z 12 m h z (35 / 57) = 7 . 368 4 m h z (average) 1 b i t = base c l ock 16 * 1 b i t = base c l ock 8 * 1 b i t = base c l ock 8 * base c l ock w i th 4 60 . 526 - kbps average transfer rate (acs3 to acs0 = b ' 1001) average transfer rate = 7 . 368 4 m h z / 16 = 4 60 . 526 kbps average error w i th 4 60 . 6kbps = - 0 . 059% 1 b i t = base c l ock 16 * base c l ock 2 4 m h z / 8 = 3 m h z 3 m h z (35 / 57) = 1 . 8 4 21 m h z (average) when = 2 4 m h z base c l ock w i th 115 . 132 - kbps average transfer rate (acs3 to acs0 = b ' 1000) average transfer rate = 1 . 8 4 21 m h z / 16 = 115 . 132 kbps average error w i th 115 . 2 kbps = - 0 . 0059% figure 12.3 examples of base clock wh en average transfer rate is selected (3) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 391 of 698 rej09b0074-0600 123 4 mhz 3 mhz example for tpu clock generation for 187.5 kbps average transfer rate when = 16 mhz (tcs2 to tcs0 = b'000) (1) 4-mhz base clock provided by tpu_1 is multiplied by 3/4 by tpu_2 to generate 3-mhz base clock (2) by making 1 bit = 16 base clocks, the average transfer will be 3 mhz/16 = 187.5 kbps tpu and sci settings b ase clock t ioca1output = 4 mhz c lock enable t ioca2 output s ck0 b ase clock = 4 mhz 3/4 = 3 mhz (average) 1 bit = base clock 16 * average transfer rate = 3 mhz/16 = 187.5 kbps note: * the lengh of one bit varies according to the base clock synchronization. 41234123412 3 34123412 3412 123 123 123 12 3 3 123 123 12 123 456 789 1011 5 12 13 14 15 16 1 2 3 4 ? tcr_1 = h'20 [tcnt_1 cleared by tgra_1 compare match, tcnt_1 incremented at rising edge of /1] ? tcr_2 = h'2c [tcnt_2 cleared by tgra_2 compare match, tcnt_2 incremented at falling edge of tclka ? tmdr_1 = tmdr_2 = h'c2 [pwm mode 1] ? tior_1 = h'21 [0 as tioca1 initial output, 0 output on tgra_1 compare match, 1 output on tgrb_1 compare match] ? tior_2 = h'21 [0 as tioca2 initial output, 0 output on tgra_2 compare match, 1 output on tgrb_2 compare match] ? tcnt_1 = tcnt_2 = h'0000 ? tgra_1 = h'0003, tgrb_1 = h'0001 ? tgra_2 = h'0003, tgrb_2 = h'0001 ? scr_0 = h'03 (external clock) ? semra_0 = h'04 (tcs2 to tcs0 = b'000, abcs = 0, acs2 to acs0 = b'100) ? semrb_0 = h'00 (acs3 = 0) clock enable base clock tpu tioca2 tioca1 tiocc0 tioca0 tclka tclkb sci_0 sck0 figure 12.4 example of average transfer rate setting when tpu clock is input (1) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 392 of 698 rej09b0074-0600 9.6 mhz 9 mhz example for tpu clock generation for 562.5 kbps average transfer rate when = 24 mhz (tcs2 to tcs0 = b'001) (1) 9.6-mhz base clock provided by tpu_0 is multiplied by 15/16 by tpu_1 to generate 9-mhz base clock (2) by making 1 bit = 16 base clocks, the average transfer will be 9 mhz/16 = 562.5 kbps tpu and sci settings tioca0 output = 4.8 mhz tiocc0 output = 4.8 mhz sck0 base clock = 9.6 mhz 15/16 = 9 mhz (average) 1 bit = base clock 16 * average transfer rate = 9 mhz/16 = 562.5 kbps note: * the length of one bit varies according to the base clock synchronization. 12 56 3 base clock (tioca0 + tiocc0) output = 9.6 mhz clock enable tioca1 output 4781112 910 1314 1 2 15 16 3 4 7 8 56 910 1314 11 12 15 16 3 4 12 56 910 78 11 12 56 3 4 7 8 11 12 910 1314 1 2 15 3 4 7 8 56 910 1314 11 12 15 3 4 12 56 910 78 11 12 56 3 4 7 8 11 12 910 1314 161 15 2 3 6 7 4 5 8 9 12 13 10 11 14 1 2 15 16 3 4 7 8 56 9 ? tcr_0 = h'20 [tcnt_0 cleared by tgra_0 compare match, tcnt_0 incremented at rising edge of /1] ? tcr_1 = h'2d [tcnt_1 cleared by tgra_1 compare match, tcnt_1 incremented at falling edge of tclkb ? tmdr_0 = tmdr_1 = h'c2 [pwm mode 1] ? tiorh_0 = h'21 [0 as tioca0 initial output, 0 output on tgra_0 compare match, 1 output on tgrb_0 compare match] ? tiorl_0 = h'21 [0 as tiocc0 initial output, 0 output on tgrc_0 compare match, 1 output on tgrd_0 compare match] ? tior_1 = h'21 [0 as tioca1 initial output, 0 output on tgra_1 compare match, 1 output on tgrb_1 compare match] ? tcnt_0 = tcnt_1 = h'0000 ? tgra_0 = h'0004, tgrb_0 = h'0002, tgrc_0 = h'0001, tgrd_0 = h'0000 ? tgra_1 = h'000f, tgrb_1 = h'0000 ? scr_0 = h'03 (external clock) ? semra_0 = h'14 (tcs2 to tcs0 = b'001, abcs = 0, acs2 to acs0 = b'100) ? semrb_0 = h'00 (acs3 = 0) tpu tioca2 clock enable base clock tioca1 tiocc0 tioca0 tclka tclkb sci_0 sck0 d >ck q figure 12.4 example of average transfer rate setting when tpu clock is input (2) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 393 of 698 rej09b0074-0600 25 1 2 6 mhz 5.52 mhz example for tpu clock generation for 345 kbps average transfer rate when = 24 mhz (tcs2 to tcs0 = b'010) (1) 6-mhz base clock provided by tpu_0 is multiplied by 23/25 by tpu_1 and tpu_2 to generate 5.52-mhz base clock (2) by making 1 bit = 16 base clocks, the average transfer will be 5.52 mhz/16 = 345 kbps tpu and sci settings base clock tioca0 (tpu_0) output = 6 mhz tioca1(tpu_1) output sck0 base clock = 6 mhz 23/25 = 5.52 mhz (average) 1 bit = base clock 16 * average transfer rate = 5.52 mhz/16 = 345 kbps note: * the length of one bit varies according to the base clock synchronization. 345678910 2122232425 11 12 13 14 15 16 17 18 19 20 1 2 3 123 4 5 6 7 8 9 10 21 22 23 24 25 11 12 13 14 15 16 17 18 19 20 123 45678910 212223 11 12 13 14 15 16 17 18 19 20 1 2 3 12 4 5 6 7 8 9 10 21 22 23 11 12 13 14 15 16 17 18 19 20 123 45678910 567 11 12 13 14 15 16 1 2 3 4 8 9 10 15 16 11 12 13 14 15 16 1 12 13 14 2 3 4 5 6 7 8 9 10 11 tioca2(tpu_2) output clock enable (tioca1tioca2) output ? tcr_0 = h'20 [tcnt_0 cleared by tgra_0 compare match, tcnt_0 incremented at rising edge of /1] ? tcr_1 = h'2d [tcnt_1 cleared by tgra_1 compare match, tcnt_1 incremented at falling edge of tclkb] ? tcr_2 = h'2d [tcnt_2 cleared by tgra_2 compare match, tcnt_2 incremented at falling edge of tclkb ? tmdr_0 = tmdr_1 = tmdr_2 = h'c2 [pwm mode 1] ? tiorh_0 = h'21 [0 as tioca0 initial output, 0 output on tgra_0 compare match, 1 output on tgrb_0 compare match] ? tior_1 = h'21 [0 as tioca1 initial output, 0 output on tgra_1 compare match, 1 output on tgrb_1 compare match] ? tior_2 = h'21 [0 as tioca2 initial output, 0 output on tgra_2 compare match, 1 output on tgrb_2 compare match] ? tcnt_0 = tcnt_1 = h'0000, tcnt_2 = h'000c ? tgra_0 = h'0003, tgrb_0 = h'0001 ? tgra_1 = h'0018, tgrb_1 = h'0000 ? tgra_2 = h'0018, tgrb_2 = h'0000 ? scr_0 = h'03 (external clock) ? semra_0 = h'24 (tcs2 to tcs0 = b'010, abcs = 0, acs2 to acs0 = b'100) ? semrb_0 = h'00 (acs3 = 0) tpu tioca2 clock enable base clock tioca1 tiocc0 tioca0 tclka tclkb sci_0 sck0 d >ck q figure 12.4 example of average transfer rate setting when tpu clock is input (3) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 394 of 698 rej09b0074-0600 9.6 mhz 8.832 mhz example for tpu clock generation for 552 kbps average transfer rate when = 24 mhz (tcs2 to tcs0 = b'011) (1) 9.6-mhz base clock provided by tpu_0 is multiplied by 23/25 by tpu_1 and tpu_2 to generate 8.832-mhz base clock (2) by making 1 bit = 16 base clocks, the average transfer will be 8.832 mhz/16 = 552 kbps tpu and sci settings tioca0 output = 4.8 mhz tiocc0 output = 4.8 mhz sck0 base clock = 9.6 mhz 23/25 = 8.832 mhz (average) 1 bit = base clock 16 * average transfer rate = 8.832 mhz/16 = 552 kbps note: * the length of one bit varies according to the base clock synchronization. 12 56 3 base clock (tioca0 + tiocc0) output = 9.6 mhz tioca1 output 4781112 910 1314 1718 15 16 19 20 23 24 21 22 25 1 4 5 2 3 6 7 10 11 8 9 12 13 16 17 14 15 18 12 56 3 4 7 8 11 12 910 1314 1617 15 18 19 22 23 20 21 4 5 2 13 6 1011 8 7 9 12 13 16 17 14 15 12 56 3 4 7 8 11 12 910 1314 161 15 2 3 6 7 4 5 11 12 9 810 13 12 15 14 16 3 4 7 8 56 tioca2 output clock enable (tioca1tioca2) output ? tcr_0 = h'20 [tcnt_0 cleared by tgra_0 compare match, tcnt_0 incremented at rising edge of /1] ? tcr_1 = h'2d [tcnt_1 cleared by tgra_1 compare match, tcnt_1 incremented at falling edge of tclkb] ? tcr_2 = h'2d [tcnt_2 cleared by tgra_2 compare match, tcnt_2 incremented at falling edge of tclkb ? tmdr_0 = tmdr_1 = tmdr_2 = h'c2 [pwm mode 1] ? tiorh_0 = h'21 [0 as tioca0 initial output, 0 output on tgra_0 compare match, 1 output on tgrb_0 compare match] ? tiorl_0 = h'21 [0 as tiocc0 initial output, 0 output on tgrc_0 compare match, 1 output on tgrd_0 compare match] ? tior_1 = h'21 [0 as tioca1 initial output, 0 output on tgra_1 compare match, 1 output on tgrb_1 compare match] ? tior_2 = h'21 [0 as tioca2 initial output, 0 output on tgra_2 compare match, 1 output on tgrb_2 compare match] ? tcnt_0 = tcnt_1 = h'0000, tcnt_2 = h'000c ? tgra_0 = h'0004, tgrb_0 = h'0002, tgrc_0 = h'0001, tgrd_0 = h'0000 ? tgra_1 = h'0018, tgrb_1 = h'0000 ? tgra_2 = h'0018, tgrb_2 = h'0000 ? scr_0 = h'03 (external clock) ? semra_0 = h'34 (tcs2 to tcs0 = b'011, abcs = 0, acs2 to acs0 = b'100) ? semrb_0 = h'00 (acs3 = 0) tpu tioca2 clock enable base clock tioca1 tiocc0 tioca0 tclka tclkb sci_0 sck0 d >ck q figure 12.4 example of average transfer rate setting when tpu clock is input (4) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 395 of 698 rej09b0074-0600 12.3.11 bit rate register (brr) brr is an 8-bit register that adjusts the bit rate. as the sci performs baud rate generator control independently for each channel, different bit rates can be set for each channel. table 12.2 shows the relationships between the n setting in brr and bit rate b for normal asynchronous mode, clocked synchronous mode, and smart card interface mode. the initial value of brr is h'ff, and it can be read from or written to by the cpu at all times. table 12.2 relationships between the n setting in brr and bit rate b mode abcs bit rate error 0 b = 64 2 2n-1 (n + 1) 10 6 error (%) = ? 1 100 b 64 2 2n-1 (n + 1) 10 6 asynchronous mode 1 b = 32 2 2n-1 (n + 1) 10 6 error (%) = ? 1 100 b 32 2 2n-1 (n + 1) 10 6 clocked synchronous mode b = 8 2 2n-1 (n + 1) 10 6 ? smart card interface mode b = s 2 2n+1 (n + 1) 10 6 error (%) = ? 1 100 b s 2 2n+1 (n + 1) 10 6 legend: b: bit rate (bps) n: brr setting for baud rate generator (0 n 255) : operating frequency (mhz) n, s: determined by the smr settings shown in the following tables. : don?t care smr setting smr setting cks1 cks0 clock source n bcp1 bcp0 s 0 0 0 0 0 32 0 1 /4 1 0 1 64 1 0 /16 2 1 0 372 1 1 /64 3 1 1 256 table 12.3 shows sample n settings in brr in normal asynchronous mode. table 12.4 shows the maximum bit rate for each frequency in normal asynchronous mode. table 12.6 shows sample n settings in brr in clocked synchronous mode. table 12.8 shows sample n settings in brr in smart card interface mode. in smart card interface mode, s (the number of basic clock periods in a 1-bit transfer interval) can be selected. for details, see section 12.7.5, receive data sampling section 12 serial communication interface rev.6.00 jun. 03, 2008 page 396 of 698 rej09b0074-0600 timing and reception margin. tables 12.5 and 12.7 show the maximum bit rates with external clock input. when the abcs bit in sci_0?s serial extended mode register a_0 (semra_0) is set to 1 in asynchronous mode, the maximum bit rates are twice those shown in table 12.3. table 12.3 brr settings for various bit rates (asynchronous mode) operating frequency (mhz) 2 2.097152 2.4576 3 bit rate (bps) n n error (%) n n error (%) n n error (%) n n error (%) 110 1 141 0.03 1 148 ?0.04 1 174 ?0.26 1 212 0.03 150 1 103 0.16 1 108 0.21 1 127 0.00 1 155 0.16 300 0 207 0.16 0 217 0.21 0 255 0.00 1 77 0.16 600 0 103 0.16 0 108 0.21 0 127 0.00 0 155 0.16 1200 0 51 0.16 0 54 ?0.70 0 63 0.00 0 77 0.16 2400 0 25 0.16 0 26 1.14 0 31 0.00 0 38 0.16 4800 0 12 0.16 0 13 ?2.48 0 15 0.00 0 19 ?2.34 9600 ? ? ? 0 6 ?2.48 0 7 0.00 0 9 ?2.34 19200 ? ? ? ? ? ? 0 3 0.00 0 4 ?2.34 31250 0 1 0.00 ? ? ? ? ? ? 0 2 0.00 38400 ? ? ? ? ? ? 0 1 0.00 ? ? ? section 12 serial communication interface rev.6.00 jun. 03, 2008 page 397 of 698 rej09b0074-0600 operating frequency (mhz) 3.6864 4 4.9152 5 bit rate (bps) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 64 0.70 2 70 0.03 2 86 0.31 2 88 ?0.25 150 1 191 0.00 1 207 0.16 1 255 0.00 2 64 0.16 300 1 95 0.00 1 103 0.16 1 127 0.00 1 129 0.16 600 0 191 0.00 0 207 0.16 0 255 0.00 1 64 0.16 1200 0 95 0.00 0 103 0.16 0 127 0.00 0 129 0.16 2400 0 47 0.00 0 51 0.16 0 63 0.00 0 64 0.16 4800 0 23 0.00 0 25 0.16 0 31 0.00 0 32 ?1.36 9600 0 11 0.00 0 12 0.16 0 15 0.00 0 15 1.73 19200 0 5 0.00 ? ? ? 0 7 0.00 0 7 1.73 31250 ? ? ? 0 3 0.00 0 4 ?1.70 0 4 0.00 38400 0 2 0.00 ? ? ? 0 3 0.00 0 3 1.73 operating frequency (mhz) 6 6.144 7.3728 8 bit rate (bps) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 106 ?0.44 2 108 0.08 2 130 ?0.07 2 141 0.03 150 2 77 0.16 2 79 0.00 2 95 0.00 2 103 0.16 300 1 155 0.16 1 159 0.00 1 191 0.00 1 207 0.16 600 1 77 0.16 1 79 0.00 1 95 0.00 1 103 0.16 1200 0 155 0.16 0 159 0.00 0 191 0.00 0 207 0.16 2400 0 77 0.16 0 79 0.00 0 95 0.00 0 103 0.16 4800 0 38 0.16 0 39 0.00 0 47 0.00 0 51 0.16 9600 0 19 ?2.34 0 19 0.00 0 23 0.00 0 25 0.16 19200 0 9 ?2.34 0 9 0.00 0 11 0.00 0 12 0.16 31250 0 5 0.00 0 5 2.40 ? ? ? 0 7 0.00 38400 0 4 ?2.34 0 4 0.00 0 5 0.00 ? ? ? section 12 serial communication interface rev.6.00 jun. 03, 2008 page 398 of 698 rej09b0074-0600 operating frequency (mhz) 9.8304 10 12 12.288 bit rate (bps) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 174 ?0.26 2 177 ?0.25 2 212 0.03 2 217 0.08 150 2 127 0.00 2 129 0.16 2 155 0.16 2 159 0.00 300 1 255 0.00 2 64 0.16 2 77 0.16 2 79 0.00 600 1 127 0.00 1 129 0.16 1 155 0.16 1 159 0.00 1200 0 255 0.00 1 64 0.16 1 77 0.16 1 79 0.00 2400 0 127 0.00 0 129 0.16 0 155 0.16 0 159 0.00 4800 0 63 0.00 0 64 0.16 0 77 0.16 0 79 0.00 9600 0 31 0.00 0 32 ?1.36 0 38 0.16 0 39 0.00 19200 0 15 0.00 0 15 1.73 0 19 ?2.34 0 19 0.00 31250 0 9 ?1.70 0 9 0.00 0 11 0.00 0 11 2.40 38400 0 7 0.00 0 7 1.73 0 9 ?2.34 0 9 0.00 operating frequency (mhz) 14 14.7456 16 17.2032 bit rate (bps) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 248 ?0.17 3 64 0.70 3 70 0.03 3 75 0.48 150 2 181 0.16 2 191 0.00 2 207 0.16 2 223 0.00 300 2 90 0.16 2 95 0.00 2 103 0.16 2 111 0.00 600 1 181 0.16 1 191 0.00 1 207 0.16 1 223 0.00 1200 1 90 0.16 1 95 0.00 1 103 0.16 1 111 0.00 2400 0 181 0.16 0 191 0.00 0 207 0.16 0 223 0.00 4800 0 90 0.16 0 95 0.00 0 103 0.16 0 111 0.00 9600 0 45 ?0.93 0 47 0.00 0 51 0.16 0 55 0.00 19200 0 22 ?0.93 0 23 0.00 0 25 0.16 0 27 0.00 31250 0 13 0.00 0 14 ?1.70 0 15 0.00 0 16 1.20 38400 ? ? ? 0 11 0.00 0 12 0.16 0 13 0.00 section 12 serial communication interface rev.6.00 jun. 03, 2008 page 399 of 698 rej09b0074-0600 operating frequency (mhz) 18 19.6608 20 24 bit rate (bps) n n error (%) n n error (%) n n error (%) n n error (%) 110 3 79 ?0.12 3 86 0.31 3 88 ?0.25 3 106 ?0.44 150 2 233 0.16 2 255 0.00 3 64 0.16 3 77 0.16 300 2 116 0.16 2 127 0.00 2 129 0.16 2 155 0.16 600 1 233 0.16 1 255 0.00 2 64 0.16 2 77 0.16 1200 1 116 0.16 1 127 0.00 1 129 0.16 1 155 0.16 2400 0 233 0.16 0 255 0.00 1 64 0.16 1 77 0.16 4800 0 116 0.16 0 127 0.00 0 129 0.16 0 155 0.16 9600 0 58 ?0.69 0 63 0.00 0 64 0.16 0 77 0.16 19200 0 28 1.02 0 31 0.00 0 32 ?1.36 0 38 0.16 31250 0 17 0.00 0 19 ?1.70 0 19 0.00 0 23 0.00 38400 0 14 ?2.34 0 15 0.00 0 15 1.73 0 19 ?2.34 note: this table shows bit rates when the abcs bit in semra_0 is cleared to 0. when the abcs bit in semr0 is set to 1, the bit rates are twice those shown in this table. in this lsi, operating frequency must be 6 mhz or greater. table 12.4 maximum bit rate for each frequency (asynchronous mode) maximum bit rate (kbps) maximum bit rate (kbps) (mhz) abcs = 0 abcs = 1 n n (mhz) abcs = 0 abcs = 1 n n 2 62.5 125.0 0 0 9.8304 307.2 614.4 0 0 2.097152 65.536 131.027 0 0 10 312.5 625.0 0 0 2.4576 76.8 153.6 0 0 12 375.0 750.0 0 0 3 93.75 187.5 0 0 12.288 384.0 768.0 0 0 3.6864 115.2 230.4 0 0 14 437.5 875.0 0 0 4 125.0 250.0 0 0 14.7456 460.8 921.6 0 0 4.9152 153.6 307.2 0 0 16 500.0 1000.0 0 0 5 156.25 312.5 0 0 17.2032 537.6 1075.2 0 0 6 187.5 375.0 0 0 18 562.5 1125.0 0 0 6.144 192.0 384.0 0 0 19.6608 614.4 1228.8 0 0 7.3728 230.4 460.8 0 0 20 625.0 1250.0 0 0 8 250.0 500.0 0 0 24 750.0 1500.0 0 0 section 12 serial communication interface rev.6.00 jun. 03, 2008 page 400 of 698 rej09b0074-0600 table 12.5 maximum bit rate with ext ernal clock input (asynchronous mode) maximum bit rate (kbps) maximum bit rate (kbps) (mhz) external input clock (mhz) abcs = 0 abcs = 1 (mhz) external input clock (mhz) abcs = 0 abcs = 1 2 0.5000 31.25 62.5 9.8304 2.4576 153.6 307.2 2.097152 0.5243 327.68 65.536 10 2.5000 156.25 312.5 2.4576 0.6144 38.4 76.8 12 3.0000 187.5 375.0 3 0.7500 46.875 93.75 12.288 3.0720 192.0 384.0 3.6864 0.9216 57.6 115.2 14 3.5000 218.75 437.0 4 1.0000 62.5 125.0 14.7456 3.6864 230.4 460.8 4.9152 1.2288 76.8 153.6 16 4.0000 250.0 500.0 5 1.2500 78.125 156.25 17.2032 4.3008 268.8 537.6 6 1.5000 93.75 187.5 18 4.5000 281.25 562.5 6.144 1.5360 96.0 192.0 19.6608 4.9152 307.2 614.4 7.3728 1.8432 115.2 230.4 20 5.0000 312.5 625.0 8 2.0000 125.0 250.0 24 6.0000 375.0 750.0 note: in this lsi, operating frequency must be 6 mhz or greater. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 401 of 698 rej09b0074-0600 table 12.6 brr settings for various bit rates (clocked synchronous mode) operating frequency (mhz) 2 4 6 8 10 16 20 24 bit rate (bps) n n n n n n n n n n n n n n n n 110 3 70 ? ? 250 2 124 2 249 3 124 ? ? 3 249 500 1 249 2 124 2 249 ? ? 3 124 ? ? ? ? 1 k 1 124 1 249 2 124 ? ? 2 249 ? ? ? ? 2.5 k 0 199 1 99 1 149 1 199 1 249 2 99 2 124 2 149 5 k 0 99 0 199 1 74 1 99 1 124 1 199 1 249 2 74 10 k 0 49 0 99 0 149 0 199 0 249 1 99 1 124 1 149 25 k 0 19 0 39 0 59 0 79 0 99 0 159 0 199 0 239 50 k 0 9 0 19 0 29 0 39 0 49 0 79 0 99 0 119 100 k 0 4 0 9 0 14 0 19 0 24 0 39 0 49 0 59 250 k 0 1 0 3 0 5 0 7 0 9 0 15 0 19 0 23 500 k 0 0 * 0 1 0 2 0 3 0 4 0 7 0 9 0 11 1 m 0 0 * 0 1 0 3 0 4 0 5 2 m 0 0 * 0 1 0 2 2.5 m 0 0 * 0 1 ? ? 4 m 0 0 * 5 m 0 0 * ? ? 6 m 0 0 * legend: blank: cannot be set. ?: can be set, but there will be a degree of error. * : continuous transfer is not possible. table 12.7 maximum bit rate with external clock input (clocked synchronous mode) (mhz) external input clock (mhz) maximum bit rate (mbps) (mhz) external input clock (mhz) maximum bit rate (mbps) 2 0.333 0.333 14 2.333 2.333 4 0.667 0.667 16 2.667 2.667 6 1.000 1.000 18 3.000 3.000 8 1.333 1.333 20 3.333 3.333 10 1.667 1.667 24 4.000 4.000 12 2.000 2.000 note: in this lsi, operating frequency must be 6 mhz or greater. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 402 of 698 rej09b0074-0600 table 12.8 brr settings for various bit rates (smart card interface mode, when n = 0 and s = 372) operating frequency (mhz) 5.00 7.00 7.1424 10.00 10.7136 13.00 bit rate (bps) n error (%) n error (%) n error (%) n error (%) n error (%) n error (%) 6720 0 0.01 1 30.00 1 28.57 1 0.01 1 7.14 2 13.33 9600 0 30.00 0 1.99 0 0.00 1 30.00 1 25.00 1 8.99 operating frequency (mhz) 14.2848 16.00 18.00 20.00 24.00 bit rate (bps) n error (%) n error (%) n error (%) n error (%) n error (%) 6720 2 4.76 2 6.67 3 0.01 3 0.01 4 3.99 9600 1 0.00 1 12.01 2 15.99 2 6.66 2 12.01 table 12.9 maximum bit rate at various f requencies (smart card interface mode) maximum bit rate (bps) (mhz) s = 32 s = 64 s = 256 s = 372 n n 5.00 78125 39063 9766 6720 0 0 6.00 93750 46875 11719 8065 0 0 7.00 109375 54688 13672 9409 0 0 7.1424 111600 55800 13950 9600 0 0 10.00 156250 78125 19531 13441 0 0 10.7136 167400 83700 20925 14400 0 0 13.00 203125 101563 25391 17473 0 0 14.2848 223200 111600 27900 19200 0 0 16.00 250000 125000 31250 21505 0 0 18.00 281250 140625 35156 24194 0 0 20.00 312500 156250 39063 26882 0 0 24.00 375000 187500 46875 32258 0 0 note: in this lsi, operating frequency must be 6 mhz or greater. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 403 of 698 rej09b0074-0600 12.4 operation in as ynchronous mode figure 12.5 shows the general format for asynchronous serial communication. one frame consists of a start bit (low level), followed by data (in lsb-first order), a parity bit (high or low level), and finally stop bits (high level). in asynchronous serial communication, the transmission line is usually held in the mark state (high level). the sci monitors the transmission line. when the transmission line goes to the space state (low leve l), the sci recognizes a start bit and starts serial communication. inside the sci, the transmitter and receiver are independent units, enabling full- duplex. both the transmitter and the receiver also have a double-buffered structure, so data can be read from or written during transmission or reception, enabling continuous data transfer. lsb start bit msb idle state (mark state) stop bit 0 transmit/receive data d0 d1 d2 d3 d4 d5 d6 d7 0/1 1 1 1 1 serial data parity bit 1 bit 1 or 2 bits 7 or 8 bits 1 bit, or none one unit of transfer data (character or frame) figure 12.5 data format in asynchronous communication (example with 8-bit data, parity, two stop bits) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 404 of 698 rej09b0074-0600 12.4.1 data transfer format table 12.10 shows the data transfer formats that can be used in asynchronous mode. any of 12 transfer formats can be selected according to the smr setting. for details on the multiprocessor bit, refer to section 12.5, multiprocessor communication function. table 12.10 serial transfer formats (asynchronous mode) s 8-bit data stop s 7-bit data stop s 8-bit data stop stop s 8-bit data p stop s 7-bit data stop p s 8-bit data mpb stop s 8-bit data mpb stop stop s 7-bit data stop mpb s 7-bit data stop mpb stop s 7-bit data stop stop smr settings 123456789101112 serial transfer format and frame length stop s 8-bit data p stop s 7-bit data stop p stop chr pe mp stop 00 00 00 01 01 00 01 01 10 00 10 01 11 00 11 01 0? 10 0? 11 1? 10 1? 11 legend: s: start bit stop: stop bit p: parity bit mpb: multiprocessor bit section 12 serial communication interface rev.6.00 jun. 03, 2008 page 405 of 698 rej09b0074-0600 12.4.2 receive data sampling timing and r eception margin in asynchronous mode in asynchronous mode, the sci operates on a basic clock with a frequency of 16 times * the transfer rate. in reception, the sci samples the fal ling edge of the start bit using the basic clock, and performs internal synchronization. receive data is latched internally at the rising edge of the 8th * pulse of the basic clock as shown in figure 12.6. thus, the reception margin in asynchronous mode is given by formula (1) below. m = | (0.5 ? ) ? (l ? 0.5) f ? (1+ f) | 100 [%] ... formula (1) 2n 1 n | d ? 0.5 | where m: reception margin n: ratio of bit rate to clock (n = 16 if abcs = 0, n = 8 if abcs = 1) d: clock duty (d = 0 to 1.0) l: frame length (l = 9 to 12) f: absolute value of clock rate deviation assuming values of f (absolute value of clock rate deviation) = 0, d (clock duty) = 0.5, and n (ratio of bit rate to clock) = 16 in formula (1), the reception margin can be given by the formula. m = {0.5 ? 1/(2 16)} 100 [%] = 46.875% however, this is only the computed value, and a margin of 20% to 30% should be allowed for in system design. internal basic clock 16 clocks * 8 clocks * receive data (rxd) synchronization sampling timing start bit d0 d1 data sampling timing 15 0 7 15 0 07 figure 12.6 receive data samplin g timing in asynchronous mode section 12 serial communication interface rev.6.00 jun. 03, 2008 page 406 of 698 rej09b0074-0600 note: * figure 12.6 shows an example when the abcs bit of semra_0 is cleared to 0. when abcs is set to 1, the clock frequency of basic clock is 8 times the bit rate and the receive data is sampled at the rising ed ge of the 4th pulse of the basic clock. 12.4.3 clock either an internal clock generated by the on-chip ba ud rate generator or an external clock input at the sck pin can be selected as the sci's serial clock, according to the setting of the c/ a bit in smr and the cke0 and cke1 bits in scr. when an external clock is input at the sck pin, the clock frequency should be 16 times the bit rate used. when an external clock is selected, the basic clock of average transfer rate can be selected according to the acs2 to acs0 bit setting of semr_0. when the sci is operated on an internal clock, the clock can be output from the sck pin by setting cke1 = 0 and cke0 = 1. the frequency of th e clock output in this case is equal to the bit rate, and the phase is such that the rising edge of the clock is in the middle of the transmit data, as shown in figure 12.7. 0 1 frame d0 d1 d2 d3 d4 d5 d6 d7 0/1 11 sck txd figure 12.7 relationship between output clock and transfer data phase (asynchronous mode) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 407 of 698 rej09b0074-0600 12.4.4 sci initialization (asynchronous mode) before transmitting and receiving data, you should first clear the te and re bits in scr to 0, then initialize the sci as described in a sample flowchart in figure 12.8. when the operating mode, or transfer format, is changed for example, the te and re bits must be cleared to 0 before making the change using the following procedure. when the te b it is cleared to 0, the tdre flag is set to 1. note that clearing the re bit to 0 does not initialize the contents of the rdrf, per, fer, and orer flags, or the contents of rdr. when the external clock is used in asynchronous mode, the clock must be supplied even during initialization. wait section 12 serial communication interface rev.6.00 jun. 03, 2008 page 408 of 698 rej09b0074-0600 12.4.5 data transmission (asynchronous mode) figure 12.9 shows an example of operation for transmission in asynchronous mode. in transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr. if the flag is cleared to 0, the sci recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit is set to 1 at this time, a transmit data empty interrupt request (txi) is generated. continuous transmission is possible because the txi interrupt routine writes next transmit data to tdr before transmission of the current transmit data has been completed. 3. data is sent from the txd pin in the following order: start bit, transmit data, parity bit or multiprocessor bit (may be omitted depending on the format), and stop bit. 4. the sci checks the tdre flag at the timing for sending the stop bit. 5. if the tdre flag is 0, the data is transferred from tdr to tsr, the stop bit is sent, and then serial transmission of the next frame is started. 6. if the tdre flag is 1, the tend flag in ssr is set to 1, the stop bit is sent, and then the "mark state" is entered, in which 1 is output. if the teie bit in scr is set to 1 at this time, a tei interrupt request is generated. tdre tend 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 1 1 1 data start bit parity bit stop bit start bit data parity bit stop bit txi interrupt request generated data written to tdr and tdre flag cleared to 0 in txi interrupt service routine tei interrupt request generated idle state (mark state) txi interrupt request generated figure 12.9 example of operation in transmission in asynchronous mode (example with 8-bit data, parity, one stop bit) figure 12.10 shows a sample flowchart for transmission in asynchronous mode. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 409 of 698 rej09b0074-0600 no section 12 serial communication interface rev.6.00 jun. 03, 2008 page 410 of 698 rej09b0074-0600 12.4.6 serial data recepti on (asynchronous mode) figure 12.11 shows an example of operation for reception in asynchronous mode. in serial reception, the sci operates as described below. 1. the sci monitors the communication line. if a st art bit is detected, the sci performs internal synchronization, receives receive data in rsr, and checks the parity bit and stop bit. 2. if an overrun error occurs (when reception of the next data is completed while the rdrf flag is still set to 1), the orer bit in ssr is set to 1. if the rie bit in scr is set to 1 at this time, an eri interrupt request is generated. receive data is not transferred to rdr. the rdrf flag remains to be set to 1. 3. if a parity error is detected, the per bit in ssr is set to 1 and receive data is transferred to rdr. if the rie bit in scr is set to 1 at this time, an eri interrupt request is generated. 4. if a framing error is detected (when the stop bit is 0), the fer bit in ssr is set to 1 and receive data is transferred to rdr. if the rie bit in scr is set to 1 at this time, an eri interrupt request is generated. 5. if reception is completed successfully, the rdrf bit in ssr is set to 1, and receive data is transferred to rdr. if the rie bit in scr is set to 1 at this time, an rxi interrupt request is generated. continuous reception is possible becau se the rxi interrupt routine reads the receive data transferred to rdr before reception of the next receive data has been completed. rdrf fer 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 0 1 1 data start bit parity bit stop bit start bit data parity bit stop bit eri interrupt request generated by framing error idle state (mark state) rdr data read and rdrf flag cleared to 0 in rxi interrupt service routine rxi interrupt request generated figure 12.11 example of sci operation in reception (example with 8-bit data, parity, one stop bit) table 12.11 shows the states of the ssr status flags and receive data handling when a receive error is detected. if a receive error is detected, the rd rf flag retains its state before receiving data. reception cannot be resumed while a receive error fl ag is set to 1. accordingly, clear the orer, fer, per, and rdrf bits to 0 before resuming reception. figure 12.12 shows a sample flow chart for serial data reception. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 411 of 698 rej09b0074-0600 table 12.11 ssr status flags and receive data handling ssr status flag rdrf * orer fer per receive data receive error type 1 1 0 0 lost overrun error 0 0 1 0 transferred to rdr framing error 0 0 0 1 transferred to rdr parity error 1 1 1 0 lost overrun error + framing error 1 1 0 1 lost overrun error + parity error 0 0 1 1 transferred to rdr framing error + parity error 1 1 1 1 lost overrun error + framing error + parity error note: * the rdrf flag retains the state it had before data reception. yes section 12 serial communication interface rev.6.00 jun. 03, 2008 page 412 of 698 rej09b0074-0600 section 12 serial communication interface rev.6.00 jun. 03, 2008 page 413 of 698 rej09b0074-0600 12.5 multiprocessor communication function use of the multiprocessor communication function enables data transfer between a number of processors sharing communication lines by asynchronous serial communication using the multiprocessor format, in which a multiprocessor bit is added to the transfer data. when multiprocessor communication is performed, each receiving station is addressed by a unique id code. the serial communication cycl e consists of two component cycles; an id transmission cycle that specifies the receiving station, and a data transmission cycle. the multiprocessor bit is used to differentiate between the id transmission cycle and the data transmission cycle. if the multiprocessor bit is 1, the cycle is an id transmission cycle; if the multiprocessor bit is 0, the cycle is a data transmission cycle. figure 12.13 shows an example of inter-processor communication using the multiprocessor format. the transmitting station first sends the id code of the receiving station with which it wants to perform serial communication as data with a 1 multiprocessor bit added. it then sends transmit data as data with a 0 multiprocessor bit added. when data with a 1 multiprocessor bit is received, the receiving station compares that data with its own id. the station whose id matches then receives the data sent next. stations whose id do not match continue to skip data until data with a 1 multiprocessor bit is again received. the sci uses the mpie bit in scr to implement this function. when the mpie bit is set to 1, transfer of receive data from rsr to rdr, error flag detection, and setting the ssr status flags, rdrf, fer, and orer to 1, are inhibited until da ta with a 1 multiprocessor bit is received. on reception of a receive character with a 1 multiprocessor bit, the mpb bit in ssr is set to 1 and the mpie bit is automatically cleared, thus normal recep tion is resumed. if the rie bit in scr is set to 1 at this time, an rxi interrupt is generated. when the multiprocessor format is selected, the parity bit setting is rendered invalid. all other bit settings are the same as those in normal asynchronous mode. the clock used for multiprocessor communication is the same as that in normal asynchronous mode. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 414 of 698 rej09b0074-0600 transmitting station receiving station a receiving station b receiving station c receiving station d (id = 01) (id = 02) (id = 03) (id = 04) serial transmission line serial data id transmission cycle = receiving station specification data transmission cycle = data transmission to receiving station specified by id (mpb = 1) (mpb = 0) h'01 h'aa legend: mpb: multiprocessor bit figure 12.13 example of communica tion using multiprocessor format (transmission of data h'aa to receiving station a) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 415 of 698 rej09b0074-0600 12.5.1 multiprocessor serial data transmission figure 12.14 shows a sample flowchart for multiprocessor serial data transmission. for an id transmission cycle, set the mpbt bit in ssr to 1 before transmission. for a data transmission cycle, clear the mpbt bit in ssr to 0 before transmission. all other sci operations are the same as those in asynchronous mode. no section 12 serial communication interface rev.6.00 jun. 03, 2008 page 416 of 698 rej09b0074-0600 12.5.2 multiprocessor s erial data reception figure 12.16 shows a sample flowchart for multiprocessor serial data reception. if the mpie bit in scr is set to 1, data is skipped until data with a 1 multiprocessor bit is sent. on receiving data with a 1 multiprocessor bit, the receive data is transferred to rdr. an rxi interrupt request is generated at this time. all other sci operations are the same as in asynchronous mode. figure 12.15 shows an example of sci operation for multiprocessor format reception. mpie rdr value 0 d0 d1 d7 1 1 0 d0 d1 d7 0 1 1 1 data (id1) start bit mpb stop bit start bit data (data1) mpb stop bit data (id2) start bit stop bit start bit data (data2) stop bit rxi interrupt request (multiprocessor interrupt) generated idle state (mark state) rdrf rdr data read and rdrf flag cleared to 0 in rxi interrupt service routine if not this station?s id, mpie bit is set to 1 again rxi interrupt request is not generated, and rdr retains its state id1 (a) data does not match station?s id mpie rdr value 0 d0 d1 d7 1 1 0 d0 d1 d7 0 1 1 1 mpb mpb rxi interrupt request (multiprocessor interrupt) generated idle state (mark state) rdrf rdr data read and rdrf flag cleared to 0 in rxi interrupt service routine matches this station?s id, so reception continues, and data is received in rxi interrupt service routine mpie bit set to 1 again id2 (b) data matches station?s id data2 id1 mpie = 0 mpie = 0 figure 12.15 example of sci operation in reception (example with 8-bit data, multiprocessor bit, one stop bit) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 417 of 698 rej09b0074-0600 yes section 12 serial communication interface rev.6.00 jun. 03, 2008 page 418 of 698 rej09b0074-0600 section 12 serial communication interface rev.6.00 jun. 03, 2008 page 419 of 698 rej09b0074-0600 12.6 operation in clocke d synchronous mode figure 12.17 shows the general format for clocked synchronous communication. in clocked synchronous mode, data is transmitted or received synchronous with clock pulses. in clocked synchronous serial communication, data on the transmission line is output from one falling edge of the serial clock to the next. in clocked synchr onous mode, the sci receives data in synchronous with the rising edge of the serial clock. after 8-bit data is output, the transmission line holds the msb state. in clocked synchronous mode, no parity or multiprocessor bit is added. inside the sci, the transmitter and receiver are independent units, enabling full-duplex communication through the use of a common clock. both the transmitter and the receiver also have a double-buffered structure, so data can be read from or wri tten during transmission or reception, enabling continuous data transfer. don't care don't car e one unit of transfer data (character or frame) bit 0 serial data synchronization clock bit 1 bit 3 bit 4 bit 5 lsb msb bit 2 bit 6 bit 7 * * note: * high except in continuous transfer figure 12.17 data format in synchronous communication (for lsb-first) 12.6.1 clock either an internal clock generated by the on-chip baud rate generator or an external synchronization clock input at the sck pin can be selected, according to the setting of cke0 and cke1 bits in scr. when the sci is operated on an internal clock, the serial clock is output from the sck pin. eight serial clock pulses are output in the transfer of one character, and when no transfer is performed the clock is fixed high. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 420 of 698 rej09b0074-0600 12.6.2 sci initialization (clocked synchronous mode) before transmitting and receiving data, the te and re bits in scr should be cleared to 0, then the sci should be initialized as described in a sample flowchart in figure 12.18. when the operating mode, or transfer format, is changed for example, the te and re bits must be cleared to 0 before making the change using the following procedure. wh en the te bit is cleared to 0, the tdre flag is set to 1. note that clearing the re bit to 0 does not change the contents of the rdrf, per, fer, and orer flags, or the contents of rdr. wait section 12 serial communication interface rev.6.00 jun. 03, 2008 page 421 of 698 rej09b0074-0600 12.6.3 serial data transmission (clocked synchronous mode) figure 12.19 shows an example of sci operation for transmission in clocked synchronous mode. in serial transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr, and if the flag is 0, the sci recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit in scr is set to 1 at this time, a transmit data empty interrupt (txi) is generated. continuous transmission is possible because the txi interrupt routine writes the next transmit data to tdr before transmission of the current transmit data has been completed. 3. 8-bit data is sent from the txd pin synchronized with the output clock when output clock mode has been specified, and synchronized with the input clock when use of an external clock has been specified. 4. the sci checks the tdre flag at the timing for sending the msb (bit 7). 5. if the tdre flag is cleared to 0, data is transferred from tdr to tsr, and serial transmission of the next frame is started. 6. if the tdre flag is set to 1, the tend flag in ssr is set to 1, and the tdre flag maintains the output state of the last bit. if the teie bit in s cr is set to 1 at this time, a tei interrupt request is generated. the sck pin is fixed high. figure 12.20 shows a sample flow chart for serial data transmission. even if the tdre flag is cleared to 0, transmission will not start while a recei ve error flag (orer, fer, or per) is set to 1. make sure that the receive error flags are cleared to 0 before starting transmission. note that clearing the re bit to 0 does not clear the receive error flags. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 422 of 698 rej09b0074-0600 transfer direction bit 0 serial data synchronization clock 1 frame tdre tend data written to tdr and tdre flag cleared to 0 in txi interrupt service routine txi interrupt request generated bit 1 bit 7 bit 0 bit 1 bit 6 bit 7 txi interrupt request generated tei interrupt request generated figure 12.19 sample sci transmission operation in clocked synchronous mode section 12 serial communication interface rev.6.00 jun. 03, 2008 page 423 of 698 rej09b0074-0600 no section 12 serial communication interface rev.6.00 jun. 03, 2008 page 424 of 698 rej09b0074-0600 12.6.4 serial data reception (clocked synchronous mode) figure 12.21 shows an example of sci operation for reception in clocked synchronous mode. in serial reception, the sci operates as described below. 1. the sci performs internal initialization synchronous with a synchronous clock input or output, starts receiving data, and stores the received data in rsr. 2. if an overrun error occurs (when reception of the next data is completed while the rdrf flag in ssr is still set to 1), the orer bit in ssr is set to 1. if the rie bit in scr is set to 1 at this time, an eri interrupt request is generated, receive data is not transferred to rdr, and the rdrf flag remains to be set to 1. 3. if reception is completed successfully, the rdrf bit in ssr is set to 1, and receive data is transferred to rdr. if the rie bit in scr is set to 1 at this time, an rxi interrupt request is generated. continuous reception is possible becau se the rxi interrupt routine reads the receive data transferred to rdr before reception of the next receive data has finished. bit 7 serial data synchronization clock 1 frame rdrf orer eri interrupt request generated by overrun error rxi interrupt request generated rdr data read and rdrf flag cleared to 0 in rxi interrupt service routine rxi interrupt request generated bit 0 bit 7 bit 0 bit 1 bit 6 bit 7 figure 12.21 example of sci operation in reception reception cannot be resumed while a receive error fl ag is set to 1. accordingly, clear the orer, fer, per, and rdrf bits to 0 before resuming reception. figure 12.22 shows a sample flow chart for serial data reception. when the internal clock is selected during reception, the synchronization clock will be output until an overrun error occurs or the re bit is cleared. to receive data in frame units, a dummy data of one frame must be transmitted simultaneously. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 425 of 698 rej09b0074-0600 yes section 12 serial communication interface rev.6.00 jun. 03, 2008 page 426 of 698 rej09b0074-0600 yes section 12 serial communication interface rev.6.00 jun. 03, 2008 page 427 of 698 rej09b0074-0600 12.7 operation in smar t card interface the sci supports an ic card (smart card) interface that conforms to iso/iec 7816-3 (identification card) as a serial communication interface extension function. switching between the normal serial communication interface and the smart card interface mode is carried out by means of a register setting. 12.7.1 pin connection example figure 12.24 shows an example of connection with the smart card. in communication with an ic card, as both transmission and reception are carried out on a single data transmission line, the txd pin and rxd pin should be connected to the lsi pin. the data transmission line should be pulled up to the v cc power supply with a resistor. if an ic card is not connected, and the te and re bits are both set to 1, closed transmission/reception is possible, enabling self-diagnosis to be carried out. when the clock generated on the smart card interface is used by an ic card, the sck pin output is input to the clk pin of the ic card. th is lsi port output is used as the reset signal. txd rxd this lsi v cc i/o connected equipment ic card data line clock line reset line clk rst sck px (port) figure 12.24 schematic diagram of smart card interfa ce pin connections section 12 serial communication interface rev.6.00 jun. 03, 2008 page 428 of 698 rej09b0074-0600 12.7.2 data format (except for block transfer mode) figure 12.25 shows the transfer data format in smart card interface mode. ? one frame consists of 8-bit data plus a parity bit in asynchronous mode. ? in transmission, a guard time of at least 2 etu (elementary time unit: the time for transfer of one bit) is left between the end of the parity bit and the start of the next frame. ? if a parity error is detected during reception, a low error signal level is output for one etu period, 10.5 etu after the start bit. ? if an error signal is sampled during transmission, the same data is retransmitted automatically after a delay of 2 etu or longer. ds d0 d1 d2 d3 d4 d5 d6 d7 dp when there is no parity error transmitting station output ds d0 d1 d2 d3 d4 d5 d6 d7 dp when a parity error occurs transmitting station output de receiving station output start bit data bits parity bit error signal legend: d s : d0 to d7: dp: de: figure 12.25 normal smart card interface data format data transfer with other types of ic cards (direct convention and inverse convention) are performed as described in the following. ds azzazz z za a (z) (z) state d0 d1 d2 d3 d4 d5 d6 d7 dp figure 12.26 direct conv ention (sdir = sinv = o/ e = 0) with the direction convention type ic and the above sample start character, the logic 1 level corresponds to state z and the logic 0 level to state a, and transfer is performed in lsb-first order. the start character data above is h'3b. for the direct convention type, clear the sdir and sinv section 12 serial communication interface rev.6.00 jun. 03, 2008 page 429 of 698 rej09b0074-0600 bits in scmr to 0. according to smart card regulations, clear the o/ e bit in smr to 0 to select even parity mode. ds azzaaa z aa a (z) (z) state d7 d6 d5 d4 d3 d2 d1 d0 dp figure 12.27 inverse convention (sdir = sinv = o/ e = 1) with the inverse convention type, the logic 1 level corresponds to state a and the logic 0 level to state z, and transfer is performed in msb-first order. the start character data for the above is h'3f. for the inverse convention type, set the sdir and sinv bits in scmr to 1. according to smart card regulations, even parity mode is the logic 0 level of the parity bit, and corresponds to state z. in this lsi, the sinv bit inverts only data bits d0 to d7. therefore, set the o/ e bit in smr to 1 to invert the parity bit for both transmission and reception. 12.7.3 clock as a transmit/receive clock, only an internal clock which is generated by an on-chip baud rate generator can be used. when clock output is selected by setting cke0 to 1, a clock with a frequency s times the bit rate is output from the sck pin. note: symbol s is the value of s described in section 12.3.11, bit rate register (brr). 12.7.4 block transfer mode operation in block transfer mode is the same as that in the normal smart card interface mode, except for the following points. ? in reception, though the parity check is performed, no error signal is output even if an error is detected. however, the per bit in ssr is set to 1 and must be cleared before receiving the parity bit of the next frame. ? in transmission, a guard time of at least 1 etu is left between the end of the parity bit and the start of the next frame. ? in transmission, because retransmission is not performed, the tend flag is set to 1, 11.5 etu after transmission start. ? as with the normal smart card interface, the ers flag indicates the error signal status, but since error signal transfer is not performed, this flag is always cleared to 0. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 430 of 698 rej09b0074-0600 12.7.5 receive data sampling ti ming and reception margin in smart card interface mode an internal clock generated by the on-chip baud rate generator can only be used as a transmission/reception clock. in this mode, the sci operates on a basic clock with a frequency of 32, 64, 372, or 256 times the transfer rate (fixed to 16 times in normal asynchronous mode) as determined by bits bcp1 and bcp0. in reception, the sci samples the falling edge of the start bit using the basic clock, and performs internal synchronization. as shown in figure 12.28, by sampling receive data at the ri sing-edge of the 16th, 32nd, 186th, or 128th pulse of the basic clock, data can be latched at the middle of the bit. the reception margin is given by the following formula. m = | (0.5 ? ) ? (l ? 0.5) f ? (1+ f) | 100 [%] 2n 1 n | d ? 0.5 | where m: reception margin (%) n: ratio of bit rate to clock (n = 32, 64, 372, and 256) d: clock duty (d = 0 to 1.0) l: frame length (l = 10) f: absolute value of clock frequency deviation assuming values of f = 0, d = 0.5 and n = 372 in the above formula, the reception margin formula is as follows. m = (0.5 ? 1/2 372) 100% = 49.866% internal basic clock 372 clocks 186 clocks receive data (rxd) synchronization sampling timing d0 d1 data sampling timing 185 371 0 371 185 0 0 start bit figure 12.28 receive data samp ling timing in smart card mode (using clock of 372 times the transfer rate) section 12 serial communication interface rev.6.00 jun. 03, 2008 page 431 of 698 rej09b0074-0600 12.7.6 initialization before transmitting and receiving data, initialize the sci as described below. initialization is also necessary when switching from transmit mode to receive mode, or vice versa. 1. clear the te and re bits in scr to 0. 2. clear the error flags ers, per, and orer in ssr to 0. 3. set the gm, blk, o/ e , bcp0, bcp1, cks0, cks1 bits in smr. set the pe bit to 1. 4. set the smif, sdir, and sinv bits in scmr. when the smif bit is set to 1, the txd and rxd pins are both switched from ports to sci pins, and are placed in the high-impedance state. 5. set the value corresponding to the bit rate in brr. 6. set the cke0 and cke1 bits in scr. clear th e tie, rie, te, re, mpie, and teie bits to 0. if the cke0 bit is set to 1, the clock is output from the sck pin. 7. wait at least one bit interval, then set the tie, rie, te, and re bits in scr. do not set the te bit and re bit at the same time, except for self-diagnosis. to switch from receive mode to transmit mode, af ter checking that the sci has finished reception, initialize the sci, and set re to 0 and te to 1. whether sci has finished reception or not can be checked with the rdrf, per, or orer flags. to switch from transmit mode to receive mode, after checking that the sci has finished transmission, initialize the sci, and set te to 0 and re to 1. whether sci has finished transmission or not can be checked with the tend flag. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 432 of 698 rej09b0074-0600 12.7.7 serial data transmission (except for block transfer mode) as data transmission in smart card interface mode involves error signal sampling and retransmission processing, the operations are different from those in normal serial communication interface mode (except for block transfer mode). figure 12.29 illustrates the retransfer operation when the sci is in transmit mode. 1. if an error signal is sent back from the receiving end after transmission of one frame is complete, the ers bit in ssr is set to 1. if the rie bit in scr is enabled at this time, an eri interrupt request is generated. the ers bit in ssr should be cleared to 0 by the time the next parity bit is sampled. 2. the tend bit in ssr is not set for a frame in which an error signal indicating an abnormality is received. data is retransferred from tdr to tsr, and retransmitted automatically. 3. if an error signal is not sent back from the receiving end, the ers bit in ssr is not set. transmission of one frame, including a retransfer , is judged to have been completed, and the tend bit in ssr is set to 1. if the tie bit in scr is enabled at this time, a txi interrupt request is generated. writing transmit data to tdr transfers the next transmit data. figure 12.31 shows a flowchart for transmission. a sequence of transmit operations can be performed automatically by specifying the dmac to be activated with a txi interrupt source. in a transmit operation, the tdre flag is set to 1 at the same time as the tend flag in ssr is set, and a txi interrupt will be generated if the tie bit in scr has been set to 1. if the txi request is designated beforehand as a dmac activation so urce, the dmac will be activated by the txi request, and transfer of the transmit data will be carried out. the tdre and tend flags are automatically cleared to 0 when data is transferred by the dmac. in the event of an error, the sci retransmits the same data automatically. during this period, the tend flag remains cleared to 0 and the dmac is not activated. therefore, the sci and dmac will automatically transmit the specified number of bytes in the event of an error, including retransmission. however, the ers flag is not cleared automatically when an error occurs, and so the rie bit should be set to 1 beforehand so that an eri request will be generated in the event of an error, and the ers flag will be cleared. when using the dmac for data transmission or reception, always make dmac settings and enable the dmac before making sci settings. for details on dmac settings, see section 7, dma controller (dmac). section 12 serial communication interface rev.6.00 jun. 03, 2008 page 433 of 698 rej09b0074-0600 d0 d1 d2 d3 d4 d5 d6 d7 dp de ds d0 d1 d2 d3 d4 d5 d6 d7 dp (de) ds d0 d1 d2 d3 d4 ds transfer frame n + 1 retransferred frame nth transfer frame tdre tend fer/ers transfer to tsr from tdr transfer to tsr from tdr transfer to tsr from tdr figure 12.29 retransfer operation in sci transmit mode the timing for setting the tend flag depends on the value of the gm bit in smr. the tend flag set timing is shown in figure 12.30. ds d0 d1 d2 d3 d4 d5 d6 d7 dp i/o data 12.5 etu txi (tend interrupt) 11.0 etu de guard time when gm = 0 when gm = 1 start bit data bits parity bit error signal legend: ds: d0 to d7: dp: de: figure 12.30 tend flag generation timing in transmission operation section 12 serial communication interface rev.6.00 jun. 03, 2008 page 434 of 698 rej09b0074-0600 initialization no yes clear te bit to 0 start transmission start no no no yes yes yes yes no end write data to tdr, and clear tdre flag in ssr to 0 error processing error processing tend = 1? all data transmitted ? tend = 1? ers = 0? ers = 0? figure 12.31 example of transmission processing flow section 12 serial communication interface rev.6.00 jun. 03, 2008 page 435 of 698 rej09b0074-0600 12.7.8 serial data r eception (except for block transfer mode) data reception in smart card interface mode uses the same operation procedure as for normal serial communication interface mode. figure 12.32 illustrates the retransfer operation when the sci is in receive mode. 1. if an error is found when the received parity bit is checked, the per bit in ssr is automatically set to 1. if the rie bit in scr is set at this ti me, an eri interrupt request is generated. the per bit in ssr should be kept cleared to 0 until the next parity bit is sampled. 2. the rdrf bit in ssr is not set for a frame in which an error has occurred. 3. if no error is found when the received parity bit is checked, the per bit in ssr is not set to 1, the receive operation is judged to have been completed normally, and the rdrf flag in ssr is automatically set to 1. if the rie bit in scr is enabled at this time, an rxi interrupt request is generated. figure 12.33 shows a flowchart for reception. a sequence of receive operations can be performed automatically by specifying the dmac to be activat ed using an rxi interrupt source. in a receive operation, an rxi interrupt request is generated when the rdrf flag in ssr is set to 1. if the rxi request is designated beforehand as a dmac activation source, the dmac will be activated by the rxi request, and the receive data will be transferred. the rdrf flag is cleared to 0 automatically when data is transferred by the dmac. if an error occurs in receive mode and the orer or per flag is set to 1, a transfer error interrupt (eri) request will be generated. hence, so the error flag must be cleared to 0. in the event of an error, the dmac is not activated and receive data is skipped. therefore, receive data is transferred for only the specified number of bytes in the event of an error. even when a parity error occurs in receive mode and the per flag is set to 1, the data that has been received is transferred to rdr and can be read from there. note: for details on receive operations in block tr ansfer mode, refer to section 12.4, operation in asynchronous mode. d0 d1 d2 d3 d4 d5 d6 d7 dp de ds d0 d1 d2 d3 d4 d5 d6 d7 dp (de) ds d0 d1 d2 d3 d4 ds transfer frame n + 1 retransferred frame nth transfer frame rdrf per figure 12.32 retransfer opera tion in sci receive mode section 12 serial communication interface rev.6.00 jun. 03, 2008 page 436 of 698 rej09b0074-0600 initialization read rdr and clear rdrf flag in ssr to 0 clear re bit to 0 start reception start error processing no no no yes yes orer = 0 and per = 0 rdrf = 1? all data received? yes figure 12.33 example of reception processing flow 12.7.9 clock output control when the gm bit in smr is set to 1, the clock output level can be fixed with bits cke0 and cke1 in scr. at this time, the minimum clock pulse width can be made the specified width. figure 12.34 shows the timing for fixing the clock output level. in this example, gm is set to 1, cke1 is cleared to 0, and the ck e0 bit is controlled. specified pulse width sck cke0 specified pulse width figure 12.34 timing for fixing clock output level section 12 serial communication interface rev.6.00 jun. 03, 2008 page 437 of 698 rej09b0074-0600 when turning on the power or switching between smart card interface mode and software standby mode, the following procedures should be followed in order to maintain the clock duty. powering on: to secure clock duty from power-on, the following switching procedure should be followed. 1. the initial state is port input and high impedance. use a pull-up resistor or pull-down resistor to fix the potential. 2. fix the sck pin to the specified output level with the cke1 bit in scr. 3. set smr and scmr, and switch to smart card mode operation. 4. set the cke0 bit in scr to 1 to start clock output. when changing from smart card interface mode to software standby mode: 1. set the data register (dr) and data direction register (ddr) corresponding to the sck pin to the value for the fixed output state in software standby mode. 2. write 0 to the te bit and re bit in the serial control register (scr) to halt transmit/receive operation. at the same time, set the cke1 bit to the value for the fixed output state in software standby mode. 3. write 0 to the cke0 bit in scr to halt the clock. 4. wait for one serial clock period. during this interval, clock output is fixed at the specified level, with the duty preserved. 5. make the transition to the software standby state. when returning to smart card interface mode from software standby mode: 1. exit the software standby state. 2. write 1 to the cke0 bit in scr and output the clock. signal generation is started with the normal duty. software standby normal operation normal operation figure 12.35 clock halt and restart procedure section 12 serial communication interface rev.6.00 jun. 03, 2008 page 438 of 698 rej09b0074-0600 12.8 sci select function (c locked synchronous mode) the sci_0 supports the sci select function which allows clock synchronous communication between master lsi and one of multiple slave lsi. figure 12.36 shows an example of communication using the sci select function. figure 12.37 shows the operation. the master lsi can communicate with slave lsi_a by bringing sel_a and sel_b signals low and high, respectively. in this case, the txd0_b pin of the slave lsi_b is brought high- impedance state and the internal sck0_a signal is fixed high. this halts the communication operation of slave lsi_b. the master lsi can communicate with slave lsi_b by bringing the sel_a and sel_b signals high and low, respectively. the slave lsi detects the selection by receiving the low level input from the irq7 pin and immediately executes data transmission/reception processing. note: the selection signals ( sel_a and sel_b ) of the lsi must be switched while the serial clock (m_sck) is high after the end bit of the transmit data has been send. note that one selection signal can be brought low at the same time. interrupt controller tsr0_a rsr0_a transmission/ reception control slave lsi_a (this lsi) master lsi sck0_a sck0_b c/a = cke1 = sse = 1 slave lsi_b (this lsi) sel_a irq7_a irq7_b sel_b m_txd rxd0_a txd0_a rxd0_b txd0_b sck0 sck0 m_rxd m_sck figure 12.36 example of communication using the sci select function section 12 serial communication interface rev.6.00 jun. 03, 2008 page 439 of 698 rej09b0074-0600 m_sck [master lsi] [slave lsi_a] communication between master lsi and slave lsi_a communication between master lsi and slave lsi_b m_txd m_rxd sel_a sel_b irq7_a ( sel_a ) [slave lsi_b] irq7_b ( sel_b ) d0 d0 d1 d1 d7 d7 d0 d1 d7 d0 d0 d1 d1 d7 d7 d0 d1 d7 sck0_a rsr0_a txd0_a sck0_b rsr0_b txd0_b hi-z hi-z hi-z d0 d6 d7 d0 d6 d7 period of m_sck = high fixed high level fixed high level hi-z figure 12.37 example of communication using the sci select function section 12 serial communication interface rev.6.00 jun. 03, 2008 page 440 of 698 rej09b0074-0600 12.9 interrupts 12.9.1 interrupts in normal serial communication interface mode table 12.12 shows the interrupt sources in no rmal serial communication interface mode. a different interrupt vector is assigned to each inte rrupt source, and individual interrupt sources can be enabled or disabled using the enable bits in scr. when the tdre flag in ssr is set to 1, a txi interrupt request is generated. when the tend flag in ssr is set to 1, a tei interrupt request is ge nerated. a txi interrupt can activate the dmac to perform data transfer. the tdre flag is cleared to 0 automatically when data is transferred by the dmac. when the rdrf flag in ssr is set to 1, an rxi interrupt request is generated. when the orer, per, or fer flag in ssr is set to 1, an eri interrupt request is generated. an rxi interrupt request can activate the dmac to transfer data. the rdrf flag is cleared to 0 automatically when data is transferred by the dmac. a tei interrupt is requested when the tend flag is set to 1 and the teie bit is set to 1. if a tei interrupt and a txi interrupt are requested simultaneously, the txi interrupt has priority for acceptance. however, if the tdre and tend flags are cleared simultaneously by the txi interrupt routine, the sci cannot branch to the tei interrupt routine later. table 12.12 sci interrupt sources channel name interrupt source inte rrupt flag dmac activation priority * eri0 receive error orer, fer, per not possible high rxi0 receive data full rdrf possible txi0 transmit data empty tdre possible 0 tei0 transmission end tend not possible 2 eri2 receive error orer, fer, per not possible rxi2 receive data full rdrf not possible txi2 transmit data empty tdre not possible tei2 transmission end tend not possible low note: * this table shows the initial state immediately after a reset. the relative channel priorities can be changed by the interrupt controller. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 441 of 698 rej09b0074-0600 12.9.2 interrupts in smart card interface mode table 12.13 shows the interrupt sources in smart card interface mode. the transmit end interrupt (tei) request cannot be used in this mode. note: in case of block transfer mode, see section 12.9.1, interrupts in normal serial communication interface mode. table 12.13 interrupt sources in smart card interface mode channel name interrupt source interrupt flag dmac activation priority * eri0 receive error, detection orer, per, ers not possible high rxi0 receive data full rdrf possible 0 txi0 transmit data empty tend possible 2 eri2 receive error, detection orer, per, ers not possible rxi2 receive data full rdrf not possible txi2 transmit data empty tend not possible low note: * indicates the initial state immediately after a reset. priorities in channels can be changed by the interrupt controller. 12.10 usage notes 12.10.1 module stop mode setting sci operation can be disabled or enabled using the module stop control register. the initial setting is for sci operation to be halted. register access is enabled by clearing module stop mode. for details, refer to section 20, power-down modes. 12.10.2 break detection and processing (asynchronous mode only) when framing error detection is performed, a break can be detected by reading the rxd pin value directly. in a break, the input from the rxd pin becomes all 0s, setting the fer flag, and possibly the per flag. note that as the sci continues the receive operation after receiving a break, even if the fer flag is cleared to 0, it will be set to 1 again. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 442 of 698 rej09b0074-0600 12.10.3 mark state and break detection (asynchronous mode only) when te is 0, the txd pin is used as an i/o port whose direction (input or output) and level are determined by dr and ddr. this can be used to set the txd pin to mark state (high level) or send a break during serial data transmission. to maintain the communication line at mark state until te is set to 1, set both ddr and dr to 1. as te is cleared to 0 at this point, the txd pin becomes an i/o port, and 1 is output from the txd pin. to send a break during serial transmission, first set pcr to 1 and pdr to 0, and then clear te to 0. when te is cleared to 0, the transmitter is initialized regardless of the current transmission state, the txd pin becomes an i/o port, and 0 is output from the txd pin. 12.10.4 receive error flags and transmit op erations (clocked sync hronous mode only) transmission cannot be started when a receive error flag (orer, per, or fer) is set to 1, even if the tdre flag is cleared to 0. be sure to cl ear the receive error flags to 0 before starting transmission. note also that receive error flags cann ot be cleared to 0 even if the re bit is cleared to 0. 12.10.5 restrictions on use of dmac ? when an external clock source is used as the serial clock, the transmit clock should not be input until at least 5 clock cycles after tdr is updated by the dmac. misoperation may occur if the transmit clock is input within 4 clocks after tdr is updated. (figure 12.38) ? when rdr is read by the dmac, be sure to set the activation source to the relevant sci reception end interrupt (rxi). t d0 lsb serial data sck d1 d3 d4 d5 d2 d6 d7 note: when operating on an external clock, set t>4 clocks. tdre figure 12.38 example of clocked synchronous transmission by dmac section 12 serial communication interface rev.6.00 jun. 03, 2008 page 443 of 698 rej09b0074-0600 12.10.6 operation in case of mode transition ? transmission operation should be stopped (by clearing te, tie, and teie to 0) before making a module stop mode, software standby mode, watch mode, subactive mode, or subsleep mode transition. tsr, tdr, and ssr are reset. the output pin states in module stop mode, software standby mode, watch mode, subactive mode, or subsleep mode depend on the port settings, and becomes high-level output after the relevant m ode is cleared. if a transition is made during transmission, the data being transmitted will be undefined. when transmitting without changing the transmit mode after the relevant mode is cleared, transmission can be started by setting te to 1 again, and performing the following sequence: ssr read -> tdr write -> tdre clearance. to transmit with a different transmit mode after clearing the relevant mode, the procedure must be started again from initialization. figure 12.39 shows a sample flowchart for mode transition during transmission. port pin states are shown in figures 12.40 and 12.41. section 12 serial communication interface rev.6.00 jun. 03, 2008 page 444 of 698 rej09b0074-0600 read tend flag in ssr te= 0 transition to software standby mode, etc. exit from software standby mode, etc. change operating mode? no all data transmitted? tend = 1 yes yes yes section 12 serial communication interface rev.6.00 jun. 03, 2008 page 445 of 698 rej09b0074-0600 te bit sck output pin txd output pin port input/output high output final txd bit retention port input/output port port sci txd output sci txd output high output * port input/output start of transmission end of transmission transition to software standby exit from software standby note: * initialized by the software standby. figure 12.41 port pin state of synchronous transmission using internal clock section 12 serial communication interface rev.6.00 jun. 03, 2008 page 446 of 698 rej09b0074-0600 ? reception receive operation should be stopped (by clearing re to 0) before making a module stop mode, software standby mode, watch mode, subactive mode, or subsleep mode transition. rsr, rdr, and ssr are reset. if a transition is made without stopping operation, the data being received will be invalid. to continue receiving without changing the reception mode after the relevant mode is cleared, set re to 1 before starting reception. to receive with a different receive mode, the procedure must be started again from initialization. figure 12.42 shows a sample flowchart for mode transition during reception. re = 0 transition to software standby mode, etc. read receive data in rdr read rdrf flag in ssr exit from software standby mode, etc. change operating mode? no rdrf = 1 yes yes section 12 serial communication interface rev.6.00 jun. 03, 2008 page 447 of 698 rej09b0074-0600 12.10.7 switching from sck pin function to port pin function: when switching the sck pin function to the output port function (high-level output) by making the following settings while ddr = 1, dr = 1, c/ a = 1, cke1 = 0, cke0 = 0, and te = 1 (synchronous mode), low-level output occurs for one half-cycle. 1. end of serial data transmission 2. te bit = 0 3. c/ a bit = 0 ... switchover to port output 4. occurrence of low-level output (see figure 12.43) bit 7 bit 6 1. end of transmission 4. low-level output 3.c/a= 0 2.te= 0 half-cycle low-level output sck/port data te c/ a cke1 cke0 figure 12.43 operation when switching from sck pin function to port pin function section 12 serial communication interface rev.6.00 jun. 03, 2008 page 448 of 698 rej09b0074-0600 sample procedure for avoiding low-level output: as this sample procedure temporarily places the sck pin in the input state, the sck/port pin should be pulled up beforehand with an external circuit. with ddr = 1, dr = 1, c/ a = 1, cke1 = 0, cke0 = 0, and te = 1, make the following settings in the order shown. 1. end of serial data transmission 2. te bit = 0 3. cke1 bit = 1 4. c/ a bit = 0 ... switchover to port output 5. cke1 bit = 0 bit 7 bit 6 1. end of transmission 3.cke1= 1 5.cke1= 0 4.c/a= 0 2.te= 0 high-level output sck/port data te c/ a cke1 cke0 figure 12.44 operation when switching from sck pin function to port pin function (example of preventing low-level output) section 13 boundary scan function rev.6.00 jun. 03, 2008 page 449 of 698 rej09b0074-0600 section 13 boundary scan function the HD64F2218 and HD64F2218u incorporate a boundary scan function, which is a serial i/o interface based on the jtag (joint test action group, ieeestd.1149.1 and ieee standard test access port and boundary scan architecture). figure 13.1 shows the block diagram of the boundary scan function. 13.1 features ? five test signals ? tck, tdi, tdo, tms, trst ? six test modes supported ? byapass, sample/preload, extest, clamp, highz, idcode ? boundary scan function cannot be performed on the following pins. ? power supply pins: vcc, vss, vref, pllvcc, pllvss, drvcc, drvss ? clock signals: extal, xtal, osc2, osc1 ? analog signals: p40 to p43, p96, p97, usd+, usd- ? boundary scan signals: tck, tdi, tdo, tms, trst ? h-udi control signal: emle section 13 boundary scan function rev.6.00 jun. 03, 2008 page 450 of 698 rej09b0074-0600 idcode bscanr (boundary scan cell chain) tdo mux tck tms trst legend: bscanr: idcode: bypass: instr: tap: boundary scan register idcode register bypass register instruction register test access port tdi bypass instr tap controller mux figure 13.1 block diagram of boundary scan function section 13 boundary scan function rev.6.00 jun. 03, 2008 page 451 of 698 rej09b0074-0600 13.2 pin configuration table 13.1 shows the i/o pins used in the boundary scan function. table 13.1 pin configuration pin name i/o function tms input test mode select controls the tap controller which is a 16-state finite state machine. the tms input value at the rising edge of tck determines the status transition direction on the tap controller. the tms is fixed high when the boundary scan function is not used. the protocol is based on jtag standard (ieee std.1149.1). this pin has a pull-up resistor. tck input test clock a clock signal for the boundary scan function. when the boundary scan function is used, input a clock of 50% duty to this pin. this pin has a pull-up resistor. tdi input test data input a data input signal for the boundary scan function. data input from the tdi is latched at the rising edge of tck. tdi is fixed high when the boundary scan function is not used. this pin has a pull-up register. tdo output test data output a data output signal for the boundary scan function. data output from the tdo changes at the falling edge of tck. the output driver of the tdo is driven only when it is necessary only in shift-ir or shift-dr states, and is brought to the high- impedance state when not necessary. trst input test reset asynchronously resets the tap controller when trst is brought low. the user must apply power-on reset signal specific to the boundary scan function when the power is supplied. (for details on signal design, refer to section 13.5, usage notes.) this pin has a pull-up resister. section 13 boundary scan function rev.6.00 jun. 03, 2008 page 452 of 698 rej09b0074-0600 13.3 register descriptions the boundary scan function has the following registers. these registers cannot be accessed by the cpu. ? instruction register (instr) ? idcode register (idcode) ? bypass register (bypass) ? boundary scan register (bscanr) 13.3.1 instruction register (instr) instr is a 3-bit register. at initialization, this register is specified to idcode mode. when trst is pulled low, or when the tap controller is in the test-logic-reset state, instr is initialized. instr can be written by the serial data input from the tdi. if more than three bits of instruction is input from the tdi, instr stores the last three bits of serial data. if a command reserved in instr is used, the correct operation cannot be guaranteed. bit bit name initial value r/w description 2 ti2 1 ? 1 ti1 0 ? test instruction bits instruction configuration is shown in table 13.2. 0 ti0 1 ? table 13.2 instruction configuration bit 2 bit1 bit 0 ti2 ti1 ti0 instruction 0 0 0 extest 0 0 1 sample/preload 0 1 0 clamp 0 1 1 highz 1 0 0 reserved 1 0 1 idcode (initial value) 1 1 0 reserved 1 1 1 bypass section 13 boundary scan function rev.6.00 jun. 03, 2008 page 453 of 698 rej09b0074-0600 extest: the extest instruction is used to test external circuits when this lsi is installed on the print circuit board. if this instruction is executed, output pins are used to output test data (specified by the sample/preload instruction) from the boundary scan register to the print circuit board, and input pins are used to input test results. sample/preload: the sample/preload instruction is used to input data from the lsi internal circuits to the boundary scan register, output data from scan path, and reload the data to the scan path. while this instruction is executed, input signals are directly input to the lsi and output signals are also directly output to the external circuits. the lsi system circuit is not affected by this instruction. in sample operation, the boundary scan register latches the snap shot of data transferred from input pins to internal circuit or data transferred from internal circuit to output pins. the latched data is read from the scan path. the scan register latches the snap data at the rising edge of the tck in capture-dr state. the scan register latches snap shot without affecting the lsi normal operation. in preload operation, initial value is written from the scan path to the parallel output latch of the boundary scan register prior to the extest instruction execution. if the extest is executed without executing this reload operation, undefined values are output from the beginning to the end (transfer to the output latch) of the extest sequence. (in extest instruction, output parallel latches are always output to the output pins.) clamp: when the clamp instruction is selected output pins output the boundary scan register value which was specified by the sample/preload instruction in advance. while the clamp instruction is selected, the status of boundary scan register is maintained regardless of the tap controller state. bypass is connected between tdi and tdo, the same operation as bypass instruction can be achieved. highz: when the highz instruction is selected, all outputs enter high-impedance state. while this instruction is selected, the status of boundary scan register is maintained regardless of the tap controller state. bypass resistor is connected between tdi and tdo, the same operation as bypass instruction can be achieved. idcode: when the idcode instruction is selected, idcode register value is output to the tdo in shift-dr state of tap controller. in this case, idcode register value is output from the lsb. during this instruction execution, test circuit does not affect the system circuit. instr is initialized by the idcode instruction in test-logic-reset state of tap controller. bypass: the bypass instruction is a standard instruction necessary to operate bypass register. the bypass instruction improves the serial data transfer speed by bypassing the scan path. during this instruction execution, test circuit does not affect the system circuit. section 13 boundary scan function rev.6.00 jun. 03, 2008 page 454 of 698 rej09b0074-0600 13.3.2 idcode register (idcode) idcode register is a 32-bit register. if instr is set to idcode mode, idcode is connected between tdi and tdo. the HD64F2218, HD64F2218u output fixed codes h'002a200f from the tdo. serial data cannot be written to idcode register through tdi. table 13.3 shows the idcode register configuration. table 13.3 idcode register configuration bits 31 to 28 27 to 12 11 to 1 0 HD64F2218, HD64F2218u codes 0000 0000 0010 1010 0010 0000 0000 111 1 contents version (4 bits) part no. (16 bits) product no. (11 bits) fixed code (1 bit) 13.3.3 bypass register (bypass) bypass is a 1-bit register. if instr is specified to bypass mode, clamp mode, or highz mode, bypass is connected between tdi and tdo. 13.3.4 boundary scan register (bscanr) bscan is a 199-bit shift register assigned on the pins to control input/output pins. the i/o pins consists of three bits (in, control, out), input pins 1 bit (in), and output pins 1 bit (out) of shift registers. the boundary scan test based on the jtag standard can be performed by using instructions listed in table 13.2. table 13.4 shows the correspondence between the lsi pins and boundary scan registers. (in table 13.4, control indicates the high active pin. by specifying control to high, the pin is driven by out. ) figure 13.2 shows the boundary scan register configuration example. section 13 boundary scan function rev.6.00 jun. 03, 2008 page 455 of 698 rej09b0074-0600 i/o pin control out in tdi pin tdo pin figure 13.2 boundary scan register configuration table 13.4 correspondence between lsi pins and boundary scan register tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name from tdi 89 a6 pf7/ in 198 control 197 out 196 91 d6 pf6/ as in 195 control 194 out 193 92 a5 pf5/ rd in 192 control 191 out 190 93 b5 pf4/ hwr in 189 control 188 out 187 94 c5 pf3/ lwr / adtrg / irq3 in 186 control 185 out 184 95 a4 pf2/ wait in 183 control 182 out 181 section 13 boundary scan function rev.6.00 jun. 03, 2008 page 456 of 698 rej09b0074-0600 tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name 96 d5 pf1/ back in 180 control 179 out 178 97 b4 pf0/ breq / irq2 in 177 control 176 out 175 98 a3 pa3/a19/sck2 in 174 control 173 out 172 99 c4 pa2/a18/rxd2 in 171 control 170 out 169 100 b3 pa1/a17/txd2 in 168 control 167 out 166 1 b2 pa0/a16 in 165 control 164 out 163 2 b1 p10/tioca0/a20 in 162 control 161 out 160 3 d4 p11/tiocb0/a21 in 159 control 158 out 157 4 c2 p12/tiocc0/tclka/a22 in 156 control 155 out 154 5 c1 p13/tiocd0/tclkb/a23 in 153 control 152 out 151 section 13 boundary scan function rev.6.00 jun. 03, 2008 page 457 of 698 rej09b0074-0600 tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name 6 d3 p14/tioca1/ irq0 in 150 control 149 out 148 7 d2 p15/tiocb1/tclkc in 147 control 146 out 145 8 d1 p16/tioca2/ irq1 in 144 control 143 out 142 9 e4 p17/tiocb2/tclkd in 141 control 140 out 139 10 e3 pc0/a0 in 138 control 137 out 136 11 e1 pc1/a1 in 135 control 134 out 133 12 e2 pc2/a2 in 132 control 131 out 130 13 f3 pc3/a3 in 129 control 128 out 127 14 f1 md0 in 126 15 f2 md1 in 125 16 f4 md2 in 124 17 g1 pc4/a4 in 123 control 122 out 121 section 13 boundary scan function rev.6.00 jun. 03, 2008 page 458 of 698 rej09b0074-0600 tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name 18 g2 pc5/a5 in 120 control 119 out 118 19 g3 pc6/a6 in 117 control 116 out 115 20 h1 pc7/a7 in 114 control 113 out 112 21 g4 uspnd/tmow out 111 22 h2 p30/txd0 in 110 control 109 out 108 23 j1 p31/rxd0 in 107 control 106 out 105 24 h3 p32/sck0/ irq4 in 104 control 103 out 102 25 j2 pg1/ cs3 / irq7 in 101 control 100 out 99 26 k2 pg2/ cs2 in 98 control 97 out 96 27 l2 pg3/ cs1 in 95 control 94 out 93 28 h4 pg4/ cs0 in 92 control 91 out 90 section 13 boundary scan function rev.6.00 jun. 03, 2008 page 459 of 698 rej09b0074-0600 tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name 29 k3 vbus in 89 30 l3 p36 in 88 control 87 out 86 37 k5 pb0/a8 in 85 control 84 out 83 38 j6 pb1/a9 in 82 control 81 out 80 39 l6 pb2/a10 in 79 control 78 out 77 40 k6 pb3/a11 in 76 control 75 out 74 47 l9 ubpm in 73 49 k9 pb4/a12 in 72 control 71 out 70 50 l10 pb5/a13 in 69 control 68 out 67 51 k10 pb6/a14 in 66 control 65 out 64 52 k11 pb7/a15 in 63 control 62 out 61 section 13 boundary scan function rev.6.00 jun. 03, 2008 page 460 of 698 rej09b0074-0600 tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name 55 h9 p74/ mres in 60 control 59 out 58 56 h10 p71/ cs5 in 57 control 56 out 55 57 h11 stby in 54 58 g8 res in 53 63 f11 p70/ cs4 in 52 control 51 out 50 64 f10 pe0/d0 in 49 control 48 out 47 65 f8 pe1/d1 in 46 control 45 out 44 66 e11 pe2/d2 in 43 control 42 out 41 67 e10 pe3/d3 in 40 control 39 out 38 68 e9 pe4/d4 in 37 control 36 out 35 69 d11 pe5/d5 in 34 control 33 out 32 section 13 boundary scan function rev.6.00 jun. 03, 2008 page 461 of 698 rej09b0074-0600 tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name 70 e8 pe6/d6 in 31 control 30 out 29 71 d10 pe7/d7 in 28 control 27 out 26 72 c11 pd0/d8 in 25 control 24 out 23 73 d9 pd1/d9 in 22 control 21 out 20 74 c10 pd2/d10 in 19 control 18 out 17 75 b11 pd3/d11 in 16 control 15 out 14 76 b10 pd4/d12 in 13 control 12 out 11 77 a10 pd5/d13 in 10 control 9 out 8 78 d8 pd6/d14 in 7 control 6 out 5 79 b9 pd7/d15 in 4 control 3 out 2 section 13 boundary scan function rev.6.00 jun. 03, 2008 page 462 of 698 rej09b0074-0600 tfp-100g tfp-100gv pin no. bp-112 bp-112v pin no. pin name i/o bit name 80 a9 fwe in 1 81 c8 nmi in 0 to tdo 13.4 boundary scan function operation 13.4.1 tap controller figure 13.3 shows the tap controller status transition diagram, based on the jtag standard. 1 1 test-logic-reset 1 1 1 1 1 1 11 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 run-test/idle select-dr capture-dr shift-dr exit1-dr update-dr pause-dr exit2-dr select-ir capture-ir shift-ir exit1-ir update-ir pause-ir exit2-ir figure 13.3 tap controller status transition note: the transition condition is the tms value at the rising edge of tck. the tdi value is sampled at the rising edge of the tck and shifted at the falling edge of the tck. the tdo value changes at the falling edge of the tck. in addition, tdo is high-impedance state in a state other than shift-dr or shift-ir state. if trst is 0, test-logic-reset state is entered asynchronously with the tck. section 13 boundary scan function rev.6.00 jun. 03, 2008 page 463 of 698 rej09b0074-0600 13.5 usage notes 1. when using the boundary scan function, clear trst to 0 at power-on and after the t resw time has elapsed set trst to 1 and set tck, tms, and tdi appropriately. during normal operation when the boundary scan function is not used, set tck, tms, and tdi to hi-z, clear trst to 0 at power-on, and after the t resw time has elapsed set trst to 1 or to hi-z. these pins are pulled up internally, so care must be taken in standby mode because breakthrough current flow can occur if there is a potential difference between the pin input voltage value when set to 1 and the power supply voltage vcc. 2. the following must be noted on the power-on reset signal applied to the trst pin. ? reset signal must be applied at power-on. ? trst must be separated in order not to affect the system operation. ? trst must be separated from the system circuitry in order not to affect the system operation. ? system circuitry must also be separated from the trst in order not to affect trst operation as shown in figure 13.4. board edge pin system reset trst trst res lsi power-on reset circuit figure 13.4 recommended reset signal design 3. tck clock speed should be slower than system clock frequency. 4. in serial communication, data is input or output from the lsb as shown in figure 13.5. boundary scan register bit n bit n - 1 bit 1 bit 0 tdi tdo figure 13.5 serial data input/output section 13 boundary scan function rev.6.00 jun. 03, 2008 page 464 of 698 rej09b0074-0600 5. if a pin with pull-up function is sampleed with pull-up function enabled, the corresponding in register is set to 1. in this case, the co rresponding control register must be cleared to 0. 6. if a pin with open-drain function is sampleed while its open-drain function is enabled and while the corresponding out register is set to 1, the corresponding control register is cleared to 0 (the pin status is hi-z). if the pin is sampleed while the corresponding out register is cleared to 0, the corresponding control register is set to 1 (the pin status is 0). 7. if extest, clamp, or highz state is ente red, this lsi enters guarded mode such as hardware standby mode ( res = stby = 0). before entering normal operating mode from extest, clamp, or highz state, specify res , stby , fwe, and md2 to md0 pin to the designated mode. 8. the emle pin must be cleared to 0. when the pin is set to 1, this chip functions as high- performance user debugging interface (h-udi). emle pin chip state 0 normal operation, boundary scan function 1 high-performance user debugging interface (h-udi) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 465 of 698 rej09b0074-0600 section 14 universal serial bus (usb) this lsi incorporates a usb function module complying with usb standard version 1.1. figure 14.1 shows the block diagram of the usb. 14.1 features ? usb standard version 2.0 full speed mode (12 mbps) support ? bus-powered mode or self-powered mode is selectable via the usb specific pin ( ubpm ) ? on-chip pll circuit to generate the usb operation clock (24 mhz 2 = 48 mhz, 16 mhz 3 = 48 mhz) ? on-chip bus transceiver ? standard commands are processed automatically by hardware ? only set_descriptor, get_descriptor, class/vendorcommand, and synchframe commands should be processed by software ? current configuration value can be checked by set_configuration interrupt ? three transfer modes supported (control, bulk, interrupt) ? configuration of four endpoints; ep0, ep1, ep2, and ep3 configuration 1 interface0 alternate 0 total 456-byte fifo incorporated ep0s (control_setup transfer, fifo 8 bytes) ep0i (control_in transfer, fifo 64 bytes) ep0o (control_out tranfer, fifo 64 bytes) ep1 (bulk_in transfer, fifo 64 bytes 2 [dual-buffer confifugraion]) ep2 (bulk_out transfer, fifo 64 bytes 2 [dual-buffer confifugraion]) ep3 (interrup_in transfer, fifo 64 bytes) ? 16 kinds of interrupts ? suspend/resume interrupt source can be assigned for irq6 ? each interrupt source except the suspend/resume interrupt source can be assigned for exirq0 or exirq1 via registers ? dma transfer interface ? dma transfer is enabled for the bulk transfer data of ep1 and ep2 ? 8-bit bus (3 cycle access timing) connected to the external bus interface ? internal registers are addressed to a part of area 6 of external address (h'c00000 to h'dfffff) ? address h'c00100 to h'dfffff is for usb reserved area and thus access prohibited. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 466 of 698 rej09b0074-0600 note: in this section, power-down mode represents watch, subactive, subsleep, and software standby modes. registers 456-byte fifo ep3 udc synchronization circuit interface [connection/disconnection] [internal bus] [main clock] [interrupt request signal] [dma transfer request signal] [power mode selection] peripheral data bus peripheral address bus peripheral bus control signal exirq0 , exirq1 dreq0 , dreq1 irq6 (12mhz) (48mhz) vbus ubpm udc core pll curcuit udc: ep0s: ep0i: ep0o: usb device controller endpoint 0 setup fifo endpoint 0 in fifo endpoint 0 out fifo ep1: ep2: ep3: end point 1 fifo end point 2 fifo end point 3 fifo legend: ep0o ep1 ep0s ep2 ep0i usb on-chip transceiver [data] [power supply] drvss rs rs drvcc uspnd usd+ usd- d+ d- figure 14.1 block diagram of usb section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 467 of 698 rej09b0074-0600 14.2 input/output pins table 14.1 shows the usb pin configuration. table 14.1 pin configuration pin name i/o function usd+ usd- i/o i/o pin for usb data drvcc input usb internal transceiver power supply pin drvss input usb internal transceiver ground pin vbus input usb cable connection/disconnection detection signal pin ubpm input usb bus-powered/self-powered mode set pin when usb is used in bus-powered mode, ubpm must be fixed low. when usb is used in self-powered mode, ubpm must be fixed high. uspnd output usb suspend output pin when usb enters the suspend state, uspnd is set to high. 14.3 register descriptions the usb has the following registers. ? usb control register (uctlr) ? usb dmac transfer requ est register (udmar) ? usb device resume register (udrr) ? usb trigger register 0 (utrg0) ? usb fifo clear register 0 (ufclr0) ? usb endpoint stall register 0 (uestl0) ? usb endpoint stall register 1 (uestl1) ? usb endpoint data register 0s (uedr0s) [for setup data reception] ? usb endpoint data register 0i (uedr0i) [for control_in data transmission] ? usb endpoint data register 0o (uedr0o) [for control_out data reception] ? usb endpoint data register 3 (uedr3) [for interrupt_in data transmission] ? usb endpoint data register 1 (uedr1) [for bulk_in data transmission] ? usb endpoint data register 2 (uedr2) [for bulk_out data reception] ? usb endpoint receive data size register 0o (uesz0o) [for control _out data reception] section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 468 of 698 rej09b0074-0600 ? usb endpoint receive data size register 2 (uesz2) [for bulk_out data reception] ? usb interrupt flag register 0 (uifr0) ? usb interrupt flag register 1 (uifr1) ? usb interrupt flag register 3 (uifr3) ? usb interrupt enable register 0 (uier0) ? usb interrupt enable register 1 (uier1) ? usb interrupt enable register 3 (uier3) ? usb interrupt select register 0 (uisr0) ? usb interrupt select register 1 (uisr1) ? usb interrupt select register 3 (uisr3) ? usb data status register (udsr) ? usb configuration value register (ucvr) ? usb test register 0 (utstr0) ? usb test register 1 (utstr1) ? usb test registers 2 and a to f (utstr2, utstra to utstrf) ? module stop control register b (mstpcrb) ? extended module stop register (exmdlstp) 14.3.1 usb control register (uctlr) uctlr is used to select the usb operation clock and control the usb module internal reset. uctlr can be read from or written to even when the usb module stop 2 bit (mstpb0) in mstpcrb is 1. for details on uctlr setting procedure, refer to section 14.5, communication operation. bit bit name initial value r/w description 7 ? 0 r/w reserved the write value should always be 0. 6 tmowe 0 r/w tmow pin enable 0: the uspnd/tmow pin outputs uspnd of usb. 1: the uspnd/tmow pin outputs tmow of rtc. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 469 of 698 rej09b0074-0600 bit bit name initial value r/w description 5 4 3 2 ucks3 ucks2 ucks1 ucks0 0 r/w usb operation clock select 3 to 0 these bits control the on-chip pll, which generates the usb operation clock (48 mhz). when ucks3 to ucks0 are 0000, the pll circuit stops and thus the usb operation clock must be selected according to the clock source. the on-chip pll circuit starts operating after the usb module stop 2 bit has been cancelled. in addition, the usb operation clock is supplied to the udc core after the usb operating clock stabilization time has been passed. the completion timing of the usb operating clock stabilization time can be detected by the ck48ready flag in uifr3. ucks0 to ucks3 muse be written while the usb module stop 2 bit (mstpb0) is 1. 0000: usb operation clock stops (pll stops) 0001: reserved 001 : reserved 010 : reserved 0110: uses a clock (48 mhz) generated by doubling the 24-mhz main oscillation by the pll. 0111: uses a clock (48 mhz) generated by tripling the 16-mhz main oscillation by the pll. 1 : reserved the usb operating clock stabilization time is 2 ms. legend: : don't care section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 470 of 698 rej09b0074-0600 bit bit name initial value r/w description 1 uifrst 1 r/w usb interface software reset controls usb module internal reset. when the uifrst bit is set to 1, the usb internal modules other than uctlr, uier3, and the ck48ready bit in uifr3 are all reset. at initialization, the uifrst bit must be cleared to 0 after the usb operating clock (48 mhz) stabilization time has passed following the clearing of the usb module stop 2 bit. 0: sets the usb internal modules to the operating state. (at initialization, this bit must be cleared after the usb operating clock stabilization time has passed.) 1: sets the usb internal modules other than uctlr, uier3, and the ck48ready bit in uifr3 to the reset state. if the uifrst bit is set to 1 after it is cleared to 0, the udcrst bit should also be set to 1 simultaneously. 0 udcrst 1 r/w udc core software reset controls reset of the udc core in the usb module. when the udcrst bit is set to 1, the udc core is reset and the usb bus synchronization operation stops. at initialization, udcrst must be cleared to 0 after d+ pull-up by the port (p36) control following the clearing of the uifrst bit. in the suspend state, to maintain the internal state of the udc core, enter power-down mode after setting the usb module stop 2 bit with the udcrst bit to be maintained to 0. after vbus disconnection detection, udcrst must be set to 1. 0: sets the udc core in the usb module to operating state. (at initialization, udcrst must be cleared to 0 after d+ pull-up by the port control following the clearing of the uifrst bit.) 1: sets the udc core in the usb module to reset state. (in the suspend state, udcrst must not be set to 1; after vbus disconnection detection, udcrst must be set to 1.) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 471 of 698 rej09b0074-0600 14.3.2 usb dmac transfer re quest register (udmar) udmar is set when data transfer by means of a usb request of the on-chip dmac is performed for data registers uedr1 and uedr2 corresponding to ep1 and ep2 respectively used for bulk transfer. for the dmac transfer, set dreq0 and dreq1 separately. if dreq0 and dreq1 usage overlaps, the usb cannot operate correctly. for details on dmac transfer, refer to section 14.6, dma transfer specifications. note: as the dreq signal is not used in the data transfer by auto request of the on-chip dmac, set udmar to h'00. bit bit name initial value r/w description 7 to 4 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 3 2 ep2t1 ep2t0 0 r/w ep2 dmac transfer request select 1, 0 00: does not request ep2 dmac transfer 01: reserved 10: requests ep2 dmac transfer by dreq0 11: requests ep2 dmac transfer by dreq1 1 0 ep1t1 ep1t0 0 r/w ep1 dmac transfer request select 1, 0 00: does not request ep1 dmac transfer 01: reserved 10: requests ep1 dmac transfer by dreq0 11: requests ep1 dmac transfer by dreq1 section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 472 of 698 rej09b0074-0600 14.3.3 usb device resume register (udrr) udrr indicates the enabled or disabled state of remote wakeup by the host, and executes the remote wakeup of the usb modules in the suspend state. bit bit name initial value r/w description 7 to 2 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 1 rwups 0 r remote wakeup status indicates the enabled or disabled state of remote wakeup by the host. this bit is a status bit and cannot be written to. if the remote wakeup from the host is disabled by device_remote_wakeup through the set_feature/clear _feature request, this bit is cleared to 0. if the remote wakeup is enabled, this bit is set to 1. 0: remote wakeup disabled state 1: remote wakeup enabled state 0 dvr 0 w device resume cancels the suspend state (executes the remote wakeup). this bit can be written to 1 and is always read as 0. before executing the remote wakeup, power-down mode or usb module stop mode must be cancelled to provide a clock for the usb module. 0: performs no operation 1: cancels the suspend state (executes the remote wakeup) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 473 of 698 rej09b0074-0600 14.3.4 usb trigger register 0 (utrg0) utrg0 is a one-shot register to generate triggers to the fifo for each endpoint ep0 to ep3. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7, 6 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 5 ep2rdfn 0 w ep2 read complete 0: performs no operation. 1: writes 1 to this bit after reading data for ep2 out fifo. ep2 has a dual-fifo configuration. this trigger is generated to the currently effective fifo. 4 ep1pkte 0 w ep1 packet enable 0: performs no operation. 1: generates a trigger to enable the transmission to ep1 in fifo. ep1 has a dual-fifo configuration. this trigger is generated to the currently effective fifo. 3 ep3pkte 0 w ep3 packet enable 0: performs no operation. 1: generates a trigger to enable the transmission to ep3 in fifo. 2 ep0ordfn 0 w ep0o read complete 0: performs no operation. 1: writes 1 to this bit after reading data for ep0o out fifo. this trigger enables ep0o to receive the next packet. 1 ep0ipkte 0 w ep0i packet enable 0: performs no operation. 1: generates a trigger to enable the transmission to ep0i in fifo. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 474 of 698 rej09b0074-0600 bit bit name initial value r/w description 0 ep0srdfn 0 w ep0s read complete 0: performs no operation. a nak handshake is returned in response to transmit/receive requests in the data stage until 1 is written to this bit. 1: writes 1 to this bit after reading data for ep0s command fifo. after receiving the setup command, this trigger enables the next packet in the data stage to be received by ep0i and ep0o. ep0s can always be overwritten and receive data regardless of this trigger. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 475 of 698 rej09b0074-0600 14.3.5 usb fifo clear register 0 (ufclr0) ufclr0 is a one-shot register used to clear th e fifo for each endpoint ep0 to ep3. writing 1 to a bit clears the data in the corresponding fifo. for in fifo, writing 1 to a bit in ufclr0 clears the data for which the corresponding pkte bit in utrg0 is not set to 1 after data write, or data that is validated by setting the corresponding pkte bit in utrg0. for out fifo, writing 1 to a bit in ufclr0 clears data that has not been fixed during reception or received data for which the corresponding rdfn b it is not set to 1. accordingly, care must be taken not to clear data that is currently being received or transmitted. ep1 and ep2, having a dual- fifo configuration, are cleared by entire fifo s. note that this trigger does not clear the corresponding interrupt flag. for details, see section 2.9.4, accessing registers containing write- only bits. bit bit name initial value r/w description 7, 6 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 5 ep2clr 0 w ep2 clear 0: performs no operation. 1: clears ep2 out fifo. 4 ep1clr 0 w ep1 clear 0: performs no operation. 1: clears ep1 in fifo. 3 ep3clr 0 w ep3 clear 0: performs no operation. 1: clears ep3 in fifo. 2 ep0oclr 0 w ep0o clear 0: performs no operation. 1: clears ep0o out fifo. 1 ep0iclr 0 w ep0i clear 0: performs no operation. 1: clears ep0i in fifo. 0 ? 0 r reserved this bit is always read as 0 and cannot be modified. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 476 of 698 rej09b0074-0600 14.3.6 usb endpoint stall register 0 (uestl0) uestl0 is used to forcibly stall each endpoint ep0 to ep3. when the bit is set to 1, the corresponding endpoint returns a stall handshake to the host, following from the next transfer. the stall bit for endpoint 0 is cleared automati cally on reception of 8-byte command data for which decoding is performed by the function, and thus the ep0stl bit is cleared to 0. when the setupts flag in uifr0 is set to 1, a write of 1 to the ep0stl bit is ignored. for details, refer to section 14.5.9, stall operations. bit bit name initial value r/w description 7, 6 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 5 ep2stl 0 r/w ep2 stall 0: cancels the ep2 stall state. 1: sets the ep2 stall state. 4 ep1stl 0 r/w ep1 stall 0: cancels the ep1 stall state. 1: sets the ep1 stall state. 3 ep3stl 0 r/w ep3 stall 0: cancels the ep3 stall state. 1: sets the ep3 stall state. 2, 1 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 0 ep0stl 0 r/w ep0 stall 0: cancels the ep0 stall state. 1: sets the ep0 stall state. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 477 of 698 rej09b0074-0600 14.3.7 usb endpoint stall register 1 (uestl1) uestl1 is used to control stall cancellation mode for all endpoints. bit bit name initial value r/w description 7 scme 0 r/w reserved the write value should always be 0. 6 to 0 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 14.3.8 usb endpoint data register 0s (uedr0s) uedr0s stores the setup command for endpoint 0 (for control_out transfer). uedr0s stores 8- byte command data sent from the host in setup stage. for details on the usb operation when data for the next setup stage is received while data in uedr0s is being read, refer to section 14.8, usage notes. uedr0s is a byte register to which 4-byte address area is assigned. accordingly, uedr0s allows the user to read 2-byte or 4-byte data continuously by word transfer or longword transfer. bit bit name initial value r/w description 7 to 0 d7 to d0 ? r these bits store the setup command for control_out transfer 14.3.9 usb endpoint data register 0i (uedr0i) uedr0i is a data register for endpoint 0 (for control_in transfer). uedr0i stores data to be sent to the host. the number of data items to be written continuously must be the maximum packet size or less. uedr0i is a byte register to which 4-byte address area is assigned. accordingly, uedr0i allows the user to write 2-byte or 4-byte data continuously by word transfer or longword transfer. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 to 0 d7 to d0 all 0 w these bits store data for control_in transfer section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 478 of 698 rej09b0074-0600 14.3.10 usb endpoint data register 0o (uedr0o) uedr0o is a data register for endpoint 0 (for co ntrol_out transfer). uedr0o stores data received from the host. the number of data items to be read must be the number of bytes specified by uesz0o. when 1 byte is read from uedr0o, uesz0o is decremented by1. uedr0o is a byte register to which 4-byte addr ess area is assigned. accordingly, uedr0o allows the user to read 2-byte or 4-byte data continuously by word transfer or longword transfer. bit bit name initial value r/w description 7 to 0 d7 to d0 ? r these bits store data for control_out transfer 14.3.11 usb endpoint data register 3 (uedr3) uedr3 is a data register for endpoint 3 (for interrupt_in transfer). uedr3 stores data to be sent to the host. the number of data items to be written continuously must be the maximum packet size or less. uedr3 is a byte register to which 4-byte addr ess area is assigned. accordingly, uedr3 allows the user to write 2-byte or 4-byte data continuously by word transfer or longword transfer. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 to 0 d7 to d0 all 0 w these bits store data for interrupt_in transfer 14.3.12 usb endpoint data register 1 (uedr1) uedr1 is a data register for endpoint 1 (for bulk_in transfer). uedr1 stores data to be sent to the host. the number of data items to be written continuously must be the maximum packet size or less. uedr1 is a byte register to which 4-byte addr ess area is assigned. accordingly, uedr1 allows the user to write 2-byte or 4-byte data continuously by word transfer or longword transfer. for details, see section 2.9.4, accessing registers containing write-only bits. bit bit name initial value r/w description 7 to 0 d7 to d0 all 0 w these bits store data for bulk_in transfer section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 479 of 698 rej09b0074-0600 14.3.13 usb endpoint data register 2 (uedr2) uedr2 is a data register for endpoint 2 (for bulk_out transfer). uedr2 stores data received from the host. the number of data items to be read must be the number of bytes specified by uesz2. when 1 byte is read from uedr2, uesz2 is decremented by1. uedr2 is a byte register to which 4-byte addr ess area is assigned. accordingly, uedr2 allows the user to read 2-byte or 4-byte data continuously by word transfer or longword transfer. bit bit name initial value r/w description 7 to 0 d7 to d0 ? r these bits store data for bulk_out transfer 14.3.14 usb endpoint receive data size register 0o (uesz0o) uesz0o is a receive data size register for endpoint 0 (for control_out transfer). uesz0o indicates the number of bytes of data to be received from the host. note that uesz0o is decremented by 1 every time when 1 byte is read from uedr0o. bit bit name initial value r/w description 7 ? ? r reserved 6 to 0 d6 to d0 ? r these bits indicate the size of data to be received in control_out transfer 14.3.15 usb endpoint receive data size register 2 (uesz2) uesz2 is a receive data size register for endpoint 2 (for bulk_out transfer). uesz2 indicates the number of bytes of data to be received from the host. note that uesz2 is decremented by 1 every time when 1 byte is read from uedr2. the fifo for endpoint 2 (for bulk_out transfer) has a dual-fifo configuration. the data size indicated by this register refers to the currently selected fifo. bit bit name initial value r/w description 7 ? ? r reserved 6 to 0 d6 to d0 ? r these bits indicate the size of data to be received in bulk_out transfer section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 480 of 698 rej09b0074-0600 14.3.16 usb interrupt flag register 0 (uifr0) uifr0 is an interrupt flag register indicating the setup command reception, ep0 and ep3 transmission/reception, and bus reset state. if the corresponding bit is set to 1, the corresponding exirq0 or exirq1 interrupt is requested to the cpu. a bit in this register can be cleared by writing 0 to it. writing 1 to a bit is invalid and causes no operation. consequently, to clear a flag, write 0 to the corresponding bit and 1 to all the other bits. (for example, write h'df to clear bit 5.) the bit-clear instruction is a read/modify/write instru ction, so if a new flag is set between the read and write operations, there is a danger that it may be cleared erroneously. therefore, do not use the bit-clear instruction to clear bits in this interrupt flag resister. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 481 of 698 rej09b0074-0600 bit bit name initial value r/w description 7 brst 0 r/(w) * bus reset set to 1 when the bus reset signal is detected on the usb bus. the corresponding interrupt output is exirq0 or exirq1 . note that brst is also set to 1 if d+ is not pulled-up during usb cable connection. 6 ? 0 r reserved this bit is always read as 0 and cannot be modified. 5 ep3tr 0 r/(w) * ep3 transfer request set to 1 if there is no valid data in the fifo when an in token is sent from the host to ep3. the corresponding interrupt output is exirq0 or exirq1 . 4 ep3ts 0 r/(w) * ep3 transmit complete set to 1 if the data written in ep3 is transmitted to the host normally and the ack handshake is returned. the corresponding interrupt output is exirq0 or exirq1 . 3 ep0ots 0 r/(w) * ep0o receive complete set to 1 if ep0o receives data from the host normally and returns the ack handshake to the host. the corresponding interrupt output is exirq0 or exirq1 . 2 ep0itr 0 r/(w) * ep0i transfer request set to 1 if there is no valid data in the fifo when an in token is sent from the host to ep0i. the corresponding interrupt output is exirq0 or exirq1 . 1 ep0its 0 r/(w) * ep0i transmit complete set to 1 if the data written in ep0i is transmitted to the host normally and the ack handshake is returned. the corresponding interrupt output is exirq0 or exirq1 . 0 setupts 0 r/(w) * setup command receive complete set to 1 if ep0s normally receives 8-byte command data to be decoded by the function from the host and returns the ack handshake to the host. the corresponding interrupt output is exirq0 or exirq1 . note: * the write value should always be 0 to clear this flag. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 482 of 698 rej09b0074-0600 14.3.17 usb interrupt flag register 1 (uifr1) uifr1 is an interrupt flag register indicating the ep1 and ep2 status. if the corresponding bit is set to 1, the corresponding exirq0 or exirq1 interrupt is requested to the cpu. ep1tr flags can be cleared by writing 0 to them. writing 1 to them is invalid and causes no operation. consequently, to clear a flag, write 0 to the corresponding bit and 1 to all the other bits. (for example, write h'fd to clear bit 1.) the bit-clear instruction is a read/modify/write instruction, so if a new flag is set between the read and write operations, there is a danger that it may be cleared erroneously. therefore, do not use the bit-clear in struction to clear bits in this interrupt flag resister. however, ep1empty, ep2ready, and ep1allemptys are status bits to indicate the ep1, ep2, and fifo state respectively, and cannot be cleared. bit bit name initial value r/w description 7 to 4 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 3 ep1all emptys 1 r ep1 fifo all empty status ep1 fifo has a dual-fifo configuration. this bit is set to 1 if there is no valid data in both fifos. this corresponds to the negative-electrode signal for the ep1de bit in udsr. an interrupt cannot be required by ep1allempty. 2 ep2ready 0 r ep2 data ready ep2 fifo has a dual-fifo configuration. this bit is set to 1 if there is valid data at least in either of fifos. this bit is cleared to 0 if there is no valid data in both fifos. this bit is a status bit and cannot be cleared. the corresponding interrupt output is exirq0 or exirq1 . 1 ep1tr 0 r/(w) * ep1 transfer request set to 1 if there is no valid data in both fifos when an in token is sent from the host to ep1. the corresponding interrupt output is exirq0 or exirq1 . 0 ep1empty 1 r ep1 fifo empty ep1 fifo has a dual-fifo configuration. this bit is set to 1 if there is no valid data at least in either of fifos. this bit is cleared to 0 if there is valid data in both fifos. this bit is a status bit and cannot be cleared. the corresponding interrupt output is exirq0 or exirq1 . note: * the write value should always be 0 to clear this flag. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 483 of 698 rej09b0074-0600 14.3.18 usb interrupt flag register 3 (uifr3) uifr3 is an interrupt flag register indicating the usb status. if the corresponding bit is set to 1, the corresponding exirq0 , exirq1 , or irq6 interrupt is requested to the cpu. vbusi, sprsi, setc, sof, and ck48ready flags can be cleared by writing 0 to them. writing 1 to them is invalid and causes no operation. consequently, to cl ear a flag, write 0 to the corresponding bit and 1 to all the other bits. (for example, write h'df to clear bit 5.) the bit-clear instruction is a read/modify/write instruction, so if a new flag is set between the read and write operations, there is a danger that it may be cleared erroneously. theref ore, do not use the bit-clear instruction to clear bits in this interrupt flag resister. vbuss an d sprss are status bits and cannot be cleared. bit bit name initial value r/w description 7 ck48ready 0 r/(w) * usb operating clock (48 mhz) stabilization detection set to 1 when the usb operating clock (48 mhz) stabilization time has been automatically counted after usb module stop mode cancellation. the corresponding interrupt output is exirq0 or exirq1 . ck48ready can also operate in the usb interface software reset state (the uifrst bit in uctlr is set to 1). refer to the ucks3 to ucks0 bits in section 14.3.1, usb control register (uctlr). 6 sof 0 r/(w) * start of frame packet detection set to 1 if the start of frame (sof) packet is detected. the corresponding interrupt output is exirq0 or exirq1 . 5 setc 0 r/(w) * set_configuration command detection set to 1 if the set_configuration command is detected. the corresponding interrupt output is exirq0 or exirq1 . 4 ? 0 r reserved this bit is always read as 0 and cannot be modified. 3 sprss 0 r suspend/resume status sprss indicates the suspend/resume status. however, an interrupt cannot be requested by sprss. 0: indicates that the bus is in the normal state. 1: indicates that the bus is in the suspend state. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 484 of 698 rej09b0074-0600 bit bit name initial value r/w description 2 sprsi 0 r/(w) * suspend/resume interrupt set to 1 if a transition from normal state to suspend state or suspend state to normal state has occurred. the corresponding interrupt output is irq6 . this bit can be used to cancel power-down mode at resuming. 1 vbuss 0 r vbus status vbuss is a status bit to indicate the vbus state by the usb cable connection or disconnection. however, an interrupt cannot be requested by vbuss. 0: indicates that the vbus (usb cable) bus is disconnected. 1: indicates that the vbus (usb cable) bus is connected. 0 vbusi 0 r/(w) * vbus interrupt set to 1 if a vbus state changes by the usb cable connection or disconnection. the corresponding interrupt output is exirq0 or exirq1 . note: * the write value should always be 0 to clear this flag. 14.3.19 usb interrupt enable register 0 (uier0) uier0 enables the interrupt request indicated in the interrupt flag register 0 (uifr0). when an interrupt flag is set while the corresponding bit in uier0 is set to 1, an interrupt is requested by asserting the corresponding exirq0 or exirq1 . either exirq0 or exirq1 must be selected by the interrupt select register 0 (uisr0). bit bit name initial value r/w description 7 brste 0 r/w enables the brst interrupt. 6 ? 0 r reserved this bit is always read as 0. 5 ep3tre 0 r/w enables the ep3tr interrupt. 4 ep3tse 0 r/w enables the ep3ts interrupt. 3 ep0otse 0 r/w enables the ep0ots interrupt. 2 ep0itre 0 r/w enables the ep0itr interrupt. 1 ep0itse 0 r/w enables the ep0its interrupt. 0 setuptse 0 r/w enables the setupts interrupt. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 485 of 698 rej09b0074-0600 14.3.20 usb interrupt enable register 1 (uier1) uier1 enables the interrupt request indicated in the interrupt flag register 1 (uifr1). when an interrupt flag is set while the corresponding bit in uier1 is set to 1, an interrupt is requested by asserting the corresponding exirq0 or exirq1 . either exirq0 or exirq1 must be selected by the interrupt select register 1 (uisr1). bit bit name initial value r/w description 7 to 4 ? all 0 r reserved these bits are always read as 0. 3 ? 0 r/w reserved the write value should always be 0. 2 ep2readye 0 r/w enables the ep2ready interrupt. 1 ep1tre 0 r/w enables the ep1tr interrupt. 0 ep1emptye 0 r/w enables the ep1emptye interrupt. 14.3.21 usb interrupt enable register 3 (uier3) uier3 enables the interrupt request indicated in the interrupt flag register 3 (uifr3). this register is readable/writable while the usb module stop 2 bit (mstpb0) in mstpcrb is 1. when an interrupt flag is set while the correspon ding bit in uier3 is set to 1, an interrupt is requested by asserting the corresponding exirq0 or exirq1 . either exirq0 or exirq1 must be selected by the interrupt select register 3 (uisr3). note, however, that the sprsie bit is an interrupt enable bit specific to the irq6 pin and cannot be selected by uisr3. bit bit name initial value r/w description 7 ck48readye 1 r/w enables the ck48ready interrupt. 6 sofe 0 r/w enables the sof interrupt. 5 setce 0 r/w enables the setc interrupt. 4, 3 ? all 0 r reserved these bits are always read as 0. 2 sprsie 0 r/w enables the sprsi interrupt. (only for irq6 ) 1 ? 0 r reserved this bit is always read as 0. 0 vbusie 0 r/w enables the vbusi interrupt. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 486 of 698 rej09b0074-0600 14.3.22 usb interrupt select register 0 (uisr0) uisr0 sets exirq to output interrupt request indicated in the interrupt flag register 0 (uifr0). when a bit in uier0 corresponding to the uisr0 bit is cleared to 0, an interrupt request is output from exirq0 . when a bit in uier0 corresponding to the uisr0 bit is set to 1, an interrupt request is output from exirq1 . bit bit name initial value r/w description 7 brsts 0 r/w selects the brst interrupt. 6 ? 0 r reserved this bit is always read as 0. 5 ep3trs 0 r/w selects the ep3tr interrupt. 4 ep3tss 0 r/w selects the ep3ts interrupt 3 ep0otss 0 r/w selects the ep0ots interrupt. 2 ep0itrs 0 r/w selects the ep0itr interrupt. 1 ep0itss 0 r/w selects the ep0its interrupt. 0 setuptss 0 r/w selects the setupts interrupt. 14.3.23 usb interrupt select register 1 (uisr1) uisr1 sets exirq to output interrupt request indicated in the interrupt flag register 1 (uifr1). when a bit in uier1 corresponding to the uisr1 bit is cleared to 0, an interrupt request is output from exirq0 . when a bit in uier1 corresponding to the uisr1 bit is set to 1, an interrupt request is output from exirq1 . bit bit name initial value r/w description 7 to 4 ? all 0 r reserved these bits are always read as 0. 3 ? 0 r/w reserved the write value should always be 0. 2 ep2readys 0 r/w selects the ep2ready interrupt. 1 ep1trs 0 r/w selects the ep1tr interrupt. 0 ep1emptys 0 r/w selects the ep1empty interrupt. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 487 of 698 rej09b0074-0600 14.3.24 usb interrupt select register 3 (uisr3) uisr3 sets exirq to output interrupt request indicated in the interrupt flag register 3 (uifr3). when a bit in uier3 corresponding to the uisr3 bit is cleared to 0, an interrupt request is output from exirq0 . when a bit in uier3 corresponding to the uisr3 bit is set to 1, an interrupt request is output from exirq1 . bit bit name initial value r/w description 7 ck48readys 0 r/w selects the ck48ready interrupt. 6 sofs 0 r/w selects the sof interrupt. 5 setcs 0 r/w selects the setc interrupt. 4 to 1 ? all 0 r reserved these bits are always read as 0. 0 vbusis 0 r/w selects the vbusi interrupt. 14.3.25 usb data status register (udsr) udsr indicates whether the in fifo data registers (ep1, and ep3) contain valid data or not. a bit in usdr is set when data written to the corresponding in fifo becomes valid after the corresponding pkte bit in utrg is set to 1. a bit in usdr is cleared when all valid data is sent to the host. for ep1, having a dual-fifo configuration, the corresponding bit in usdr is cleared to 0 and fifo becomes empty. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 488 of 698 rej09b0074-0600 bit bit name initial value r/w description 7 to 3 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 2 ep1de 0 r ep1 data enable 0: indicates that the ep1 contains no valid data. 1: indicates that the ep1 contains valid data. ep1de corresponds to the negative-electrode signal for ep1allemptys in uifr1. 1 ep3de 0 r ep3 data enable 0: indicates that the ep3 contains no valid data. 1: indicates that the ep3 contains valid data. 0 ep0ide 0 r ep0i data enable 0: indicates that the ep0i contains no valid data. 1: indicates that the ep0i contains valid data. 14.3.26 usb configuration value register (ucvr) ucvr stores the configuration value when the set_configuration command is received from the host. bit bit name initial value r/w description 7, 6 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 5 cnfv0 0 r configuration value 0 stores the configuration value when the set_configuration command is received. cnfv0 is modified when the setc bit in uifr3 is set to 1. 4 to 0 ? all 0 r reserved these bits are always read as 0 and cannot be modified. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 489 of 698 rej09b0074-0600 14.3.27 usb test register 0 (utstr0) utstr0 controls the on-chip transceiver output signals. setting the ptste bit to 1 after setting uifrst and udcrst in uctlr to 0 specifies the transceiver output signals (usd+ and usd-) arbitrarily. table 14.2 shows the relationship between utstr0 setting and pin output. bit bit name initial value r/w description 7 ptste 0 r/w pin test enable enables the test control for the on-chip transceiver output pins (usd+ and usd-) and uspnd pin. 6 to 4 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 3 2 1 0 suspend oe fse0 vpo 0 1 0 0 r/w r/w r/w r/w on-chip transceiver output signal setting suspend: sets the uspnd pin signal of the on-chip transceiver. oe : sets the output enable ( oe ) signal of the on-chip transceiver. fse0: sets the single-ended 0 (fse0) signal of the on-chip transceiver. vpo: sets the usd+ (vpo) signal of the on- chip transceiver. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 490 of 698 rej09b0074-0600 table 14.2 relationship between utstr0 setting and pin output register setting pin output pin input register setting pin output uctlr/ tmowe ptste suspend uspnd/ tmow vbus ptste oe fse0 vpo usd+ usd- 1 ? 0 hi-z hi-z 0 0 ? 1 0 ? ? 0 1 0 0 1 1 0 0 0 0 1 0 1 1 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 hi-z hi-z legend: : don?t care ?: cannot be controlled. indicates state in normal operation according to the usb operation and port settings. 14.3.28 usb test register 1 (utstr1) utstr1 allows the usb control pin and on-chip transceiver input signals to be monitored. table 14.3 shows the relationship between pin input and utstr1 monitoring value. bit bit name initial value r/w description 7 6 vbus ubpm ? * ? * r r on-chip transceiver input signal monitor vbus: monitors the vbus pin. ubpm : monitors the ubpm pin. 5 to 3 ? all 0 r reserved these bits are always read as 0 and cannot be modified. 2 1 0 rcv vp vm ? * ? * ? * r r r on-chip transceiver input signal monitor rcv: monitors the differential input level (rcv) signal of the on-chip transceiver. vp: monitors the usd+ (vp) signal of the on-chip transceiver. vm: monitors the usd- (vm) signal of the on-chip transceiver. note: * determined by the state of pins. vbus, ubpm , usd+, usd- section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 491 of 698 rej09b0074-0600 table 14.3 relationship between pin input and utstr1 monitoring value pin input utstr1 monitoring value register setting pin input utstr1 monitoring value vbus ubpm vbus ubpm utstr0/ ptste utstr0/ suspend vbus usd+ usd- rcv vp vm 0/1 0/1 0 0 0 0 0/1 0/1 0 1 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 0 1 0 0 0 0 1 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 0 1 1 legend: : don?t care 0/1: combination for pin input = utstr1 monitoring value. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 492 of 698 rej09b0074-0600 14.3.29 usb test registers 2 and a to f (utstr2, utstra to utstrf) utstr2 and utsrta to utsrtf are test registers and cannot be written to. 14.3.30 module stop control register b (mstpcrb) bit bit name initial value r/w description 7 6 5 4 3 2 1 mstpb7 mstpb6 mstpb5 mstpb4 mstpb3 mstpb2 mstpb1 1 1 1 1 1 1 1 r/w module stop for details, refer to section 20.1.3, module stop control registers a to c (mstpcra to mstpcrc). 0 mstpb0 1 r/w usb module stop 2 0: cancels the stop state of the usb module completely. a clock is provided for the usb module completely. before clearing this bit, make sure to clear the usbstop1 bit in exmdlstp. after this bit has been cleared, the internal pll circuit starts operation. registers in the usb module must be accessed after the usb operating clock stabilization time (the ck48ready bit in uifr3 is set to 1) has passed. 1: places the usb module partly in the stop state. the internal pll circuit and the most of the clocks in the usb module stop operation. however, register values in the usb module are maintained. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 493 of 698 rej09b0074-0600 14.3.31 extended module stop register (exmdlstp) bit bit name initial value r/w description 7 to 2 ? undefined ? reserved these bits are always read as an undefined value and cannot be modified. 1 rtcstop 0 r/w rtc module stop 0: cancels the rtc module stop. 1: sets the rtc module stop. 0 usbstop1 0 r/w usb module stop 1 0: cancels the stop state of the usb module partly. a clock is provided for the usb module partly. after this bit has been cleared, only the uctlr and uier3 registers in the usb module can be accessed. to access the other registers, clear the mstpb0 bit in mstpcrb to 0. 1: places the usb module completely in the stop state. the clocks in the usb module stop operation completely. however, register values in the usb module are maintained. notes: 1. for details on usb module stop mode cancellation procedure, refer to section 14.5, communication operation. 2. when reading pin states using the port d register (portd), after accessing exmdlstp (address range: h'ffff40 to h'ffff5f), you must perform a dummy read to the external address space (such as h'ffef00 to h'ff7ff) outside the range h'ffff40 to h'ffff5f before reading portd. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 494 of 698 rej09b0074-0600 14.4 interrupt sources this module has three interrupt signals. table 14.4 shows the interrupt sources and their corresponding interrupt request signals. the exirq interrupt signals are activated at low level. the exirq interrupt requests can only be detected at low level (specified as level sensitive). the suspend/resume interrupt request irq6 must be specified to be detected at the falling edge (falling- edge sensitive) by the interrupt controller register. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 495 of 698 rej09b0074-0600 table 14.4 interrupt sources register bit transfer mode interrupt source description interrupt request signal dmac activation by usb request * 5 uifr0 0 control transfer (ep0) setupts * 1 setup command receive complete exirq0 or exirq1 1 ep0its * 1 ep0i transfer complete exirq0 or exirq1 2 ep0itr * 1 ep0i transfer request exirq0 or exirq1 3 ep0ots * 1 ep0o receive complete exirq0 or exirq1 4 interrupt_in transfer (ep3) ep3ts ep3 transfer complete exirq0 or exirq1 5 ep3tr ep3 transfer request exirq0 or exirq1 6 ? reserved ? ? ? 7 (status) brst bus reset exirq0 or exirq1 uifr1 0 bulk_in transfer (ep1) ep1empty ep1 fifo empty exirq0 or exirq1 dreq0 or dreq1 * 2 1 ep1tr ep1 transfer request exirq0 or exirq1 2 bulk_out transfer (ep2) ep2ready ep2 data ready exirq0 or exirq1 dreq0 or dreq1 * 3 3 bulk_in transfer (ep1) (ep1allemptys) ep1 fifo all empty status 4 ? reserved ? ? ? 5 6 7 section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 496 of 698 rej09b0074-0600 register bit transfer mode interrupt source description interrupt request signal dmac activation by usb request * 5 uifr3 0 ? (status) vbusi vbus interrupt exirq0 or exirq1 1 (vbuss) vbus status 2 sprsi suspend/resume interrupt irq6 * 4 3 (sprss) suspend/resume status 4 reserved ? ? ? 5 setc set_configuration detection exirq0 or exirq1 6 sof start of frame packet detection exirq0 or exirq1 7 ck48ready usb operating clock stabilization detection exirq0 or exirq1 notes: 1. ep0 interrupts must be assigned to the same interrupt request signal. 2. an ep1 dma transfer by a usb request is specified by the ep1t1 and ep1t0 bits in udmar. 3. an ep2 dma transfer by a usb request is specified by the ep2t1 and ep2t0 bits in udmar. 4. the suspend/resume interrupt request irq6 must be specified to be detected at the falling edge (irq6scb and irq6sca in iscrh = 01) by the interrupt controller register. 5. the dreq signal is not used for auto-request. the cpu can activate the dmac using any flags and interrupts. ? exirq0 signal the exirq0 signal requests interrupt sources for which the corresponding bits in interrupt select registers 0 to 3 (uisr0 to uisr3) are cleared to 0. the exirq0 is driven low if a corresponding bit in the interrupt flag register is set to 1. ? exirq1 signal the exirq1 signal requests interrupt sources for which the corresponding bits in interrupt select registers 0 to 3 (uisr0 to uisr3) are cleared to 0. the exirq1 is driven low if a corresponding bit in the interrupt flag register is set to 1. ? irq6 signal the irq6 signal is specific to the suspend/resume interrupt request. the falling edge of the irq6 signal is output at the transition from the suspend state or from the resume state. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 497 of 698 rej09b0074-0600 14.5 communication operation 14.5.1 initialization the usb must be initialized as described in the flowchart in figure 14.2. cancel power-on reset usb function firmware no yes set each interrupt start usb operationg clock oscillation. usb operating clock stabilization time has passed? cancel usb module stop 2 (clear mstpb0 in mstpcrb to 0) clear ck48ready in uifr3 to 0 usb module stop 2 (write to 1 mstpb0 in mstpcrb) wait for usb cable connection yes yes no no (bus powered) (self powered) to usb cable connecting procedure enter power-down mode (if necessary) set each interrupt wait for usb operating clock stabilization usb interface operation ok usb operating clock stabilization detection interrupt occurs. cancel usb interface reset (clear uifrst in uctlr to 0) self powered? system needs to enter power-down mode? cancel usb module stop 1 (clear usbstp1 in exmdlstp to 0) select usb operating clock (write 1 to ucks3 to ucks0 in uctlr) to 14.5.2 (1) * * * exirq0 note: before entering power-down mode, set usb module stop 2 by setting the mstpb0 bit in mstpcrb to 1. figure 14.2 usb initialization section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 498 of 698 rej09b0074-0600 14.5.2 usb cable connection/disconnection (1) usb cable connection (when usb module stop or power-down mode is not used) if the usb cable enters the connection state from the disconnection state in an application (self powered) where usb module stop or power-down mode is not used, perform the operation as shown in figure 14.3. in bus-powered mode, perform the operation according to note 2 in figure 14.3. connect the usb cable usb function firmware receive bus reset from the host bus reset interrupt occurs. a vbus interrupt occurs check if vbuss in uifr3 is set to 1 enable d+ pull-up by port 36 (p36) check the usb cable connection state initialize the firmware yes no wait for a setup interrupt cancel udc core reset (clear udcrst in uctlr to 0) clear all fifos clear vbusi in uifr3 system ready? set usb module operation * 1 * 2 exirqx exirqx notes: 1. vbus interrupts in the usb module cannot be detected in power-down mode or in the usb module stop state. 2. in bus-powered mode, power is applied after the usb cable has been connected. accordingly, immediately after completing the power-on reset, initialization (14.5.1), clearing all fifos, and system preparation, enable the d+ pull-up by the port 36 (p36) and cancel the udc core reset state. from 14.5.1 after completing the bus- powered mode initialization figure 14.3 usb cable connection (when usb module stop or power-down mode is not used) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 499 of 698 rej09b0074-0600 (2) usb cable connection (when usb module stop or power-down mode is used) if the usb cable enters the connection state from the disconnection state in an application (self powered) where usb module stop or power-down mode is used, perform the operation as shown in figure 14.4. connect the usb cable usb function firmware no yes receive bus reset from the host a bus reset interrupt occurs start usb operating clock oscillation usb operating clock stabilization time has passed? cancel usb module stop 2 clear mstpb0 in mstpcrb to 0 check by using the port function in irqx clear ck48ready in uifr3 to 0 enable d+ pull-up by port 36 (p36) initialize the firmware wait for setup interrupt yes yes yes no no no cancel udc core reset (clear udcrst in uctlr to 0) clear all fifos wait for usb operating clock stabilization a usb operating clock stabilization detection interrupt occurs. system ready? power-down mode? usb module stopped? start usb module operation * * exirqx exirqx external interrupt irqx * note: a vbus interrupts in the usb module cannot be detected in power-down mode or in the usb module stop state. accordingly, in an application (self powered) where power-down mode or usb module stop is used,vbus interrupts of the usb must be detected via the external interrupt pin irqx . in this case, the irqx pin must be specified as both-edge sensitive. when irqx is used, vbus interrupts in the usb module need not to be used. check the usb cable connection state figure 14.4 usb cable connection (when usb module stop or power-down mode is used) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 500 of 698 rej09b0074-0600 (3) usb cable disconnection (when usb module stop or power-down mode is not used) if the usb cable enters the disconnection state from the connection state in an application (self powered) where usb module stop or power-down mode is not used, perform the operation as shown in figure 14.5. in bus-powered mode, the power is automatically turned off when the usb cable is disconnected and the following processing is not required. disconnect the usb cable vbus interrupt occurs usb function firmware reset the udc core clear vbusi in uifr3 to 0 check if vbuss in uifr3 is cleared to 0 cancel d + pull-up by port 36 (p36) wait for usb cable connection reset the udc core write udcrst in uctlr to 1 * * exirqx note: vbus interrupts in the usb module cannot be detected in power-down mode or in the usb module stop state. figure 14.5 usb cable disconnection (when usb module stop or power-down mode is not used) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 501 of 698 rej09b0074-0600 (4) usb cable disconnection (when usb module stop or power-down mode is used) if the usb cable enters the disconnection state from the connection state in an application (self powered) where usb module stop or power-down mode is used, perform the operation as shown in figure 14.6. disconnect the usb cable usb function firmware no yes enable d+ pull-up by port 36 (p36) enter power-down mode (only if necessary) wait for usb cable connection yes yes yes no no no stop usb module write mstpb0 in mstpcrb to 1 reset udc core write udcrst in uctrl to 1 reset udc core system needs to enter power-down mode? * 1 * 2 * 2 1. 2. exirqx external interrupt irqx * 1 notes: vbus interrupts in the usb module cannot be detected in power-down mode or in the usb module stop state. accordingly, in an application (self powered) where power-down mode or usb module stop is used , vbus interrupts of the usb must bedetected via the external interrupt pin irqx . in this case, the irqx pin must be specified as both edge sensitive. when irqx is used, vbus interrupts in the usb module need not to be used. before entering power-down mode, make sure to set usb module stop2 (the mstpb0 bit of mstpcrb = 1). check the usb cable disconnection state start usb operating clock oscillation usb operating clock stabilization time has passed? usb operating clock stabilization detection interrupt occurs. powe-down mode ? usb module stopped? cancel usb module stop 2 clear mstpb0 in mstpcrb to 0 wait for usb operating clock stabilization check connections by using the port function of irqx clear ck48ready in uifr3 to 0 figure 14.6 usb cable disconnection (when usb module stop or power-down mode is used) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 502 of 698 rej09b0074-0600 14.5.3 suspend and resume operations (1) suspend and resume operations figures 14.7 and 14.8 are flowcharts of the suspend and resume operations. if the usb bus enters the suspend state from a non-suspend state, or if it enters a non-suspend state from the suspend state due to a resume signal from up-stream, perform the operations shown below. usb function firmware usb cable connected a bus idle of 3 ms or more occurs a suspend/resume interrupt occurs suspend state a resume interrupt is generated from up-stream a suspend/resume interrupt occurs enable sprsi and irq6 interrupts (set sprsie in uier3 to 1) (set irq6e in ier to 1) initialize standby enable flag (clear standby enable flag to 0) run user program in one of the power-down modes mask all interrupts (manipulate bit i using ldc instruction, etc.) enable irq6 interrupt (set irq6e in ier to 1) unmask all interrupts (clear bit i using ldc instruction, etc.) transition to one of the power-down modes (execute sleep instruction) suspend interrupt processing (see figure 14.8) irq6 irq6 suspend/resume interrupt processing main process no no yes yes standby enable flag = 0? resume interrupt processing (see figure 14.8) * 1 * 1 * 1 * 2 * 2 * 2 standby enable flag = 1? notes: 1. the standby enable flag is a software flag for controlling transition to the standby state (one of the power-down modes). there is no such hardware flag. 2. interrupts should be masked from when the irq6 interrupt is received until the sleep instruction is executed. finally, unmask the interrupts using the ldc instruction or the like and execute the sleep instruction immediately afterward. figure 14.7 example flowchart of suspend and resume operations section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 503 of 698 rej09b0074-0600 (2) suspend and resume interrupt processing figure 14.8 is a flowchart of suspend and resume interrupt processing. usb fun c tion firmware resume interrupt pro c essing usb operating c lo c k stabilization dete c tion interrupt pro c essing suspend interrupt pro c essing start usb operatin g clock oscillation a usb operatin g clock stabilization detection interrupt occurs clear usb module stop 2 mode (clear mstpb0 in mstpcrb to 0) clear resume fla g (clear sprsi in uifr3 to 0) clear usb operatin g clock stabilization detection fla g (clear ck48ready in uifr3 to 0) resume main process prohibit irq6 (clear irq6e in ier to 0) clear suspend fla g (clear sprsi in uifr3 to 0) confirm that remote-wakeup is prohibited confirm that remote-wakeup is enabled enable usb module stop mode (set mstpb0 in mstpcrb to 1) set standby enable fla g to 1 clear standby enable fla g to 0 wait for usb operatin g clock stabilization suspend state confirmed ? (sprss in uifr3 = 1 ? ) suspend state confirmed ? (sprss in uifr3 = 1 ? ) remote- wakeup enabled ? (rwups in udrr = 1) usb operatin g clock stabilization time has passed ? yes yes yes yes yes no no no no e x i rqx no * 4 * 4 * 5 * 3 * 1 * 5 * 1 * 2 standby enable fla g = 0 ? suspend state confirmed ? (sprss in uifr3 = 1 ? ) i rq6 notes: 1. the standby enable fla g is a software fla g for controllin g transition to the standby state (one of the power-down modes). there is no such hardware fla g . 2. interrupts should be masked from when the i rq6 interrupt is received until the sleep instruction is executed. finally, unmask the interrupts usin g the ldc instruction or the like and execute the sleep instruction immediately afterward. 3. the remote-wakeup function cannot be used unless it is enabled by the host. accordin g ly, the remote-wakeup function cannot be used unless it is enabled by the host. accordin g ly, make sure to check rwups in udrr before usin g the remote-wakeup function. however, it is not necessary to confirm that the remote-wakeup function is enabled by the host if the application does not make use of this fu nction. 4. when resumin g usin g the remote wakeup function, the usb module stop state must already be cleared. 5. return to the main process and wait for the usb operatin g clock stabilization detection interrupt. when resumin g by means of remote- wakeup the usb operatin g clock has already stabilized, so this step is not necessary. enable irq6 interrupt (set irq6e in ier to 1) clear suspend fla g (clear sprsi in uifr3 to 0) figure 14.8 example flowchart of suspend and resume interrupt processing section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 504 of 698 rej09b0074-0600 (3) suspend and remote-wakeup operations figures 14.9 and 14.10 are flowcharts of the suspend and remote-wakeup operations. if the usb bus enters a non-suspend state from the suspend state due to a remote-wakeup signal from this function, perform the operations shown below. usb function firmware usb cable connected a bus idle of 3 ms or more occurs a suspend/resume interrupt occurs suspend state output resume signal to usb bus a suspend/resume interrupt occurs enable sprsi and irq6 interrupts (set sprsie in uier3 to 1) (set irq6e in ier to 1) initialize standby enable flag (clear standby enable flag to 0) run user program in one of the power-down modes mask all interrupts (manipulate bit i using ldc instruction, etc.) enable irq6 interrupt (set irq6e in ier to 1) unmask all interrupts (clear bit i using ldc instruction, etc.) transition to one of the power-down modes (execute sleep instruction) suspend interrupt processing (see figure 14.8) irq6 nmi or irqx irq6 suspend/remote-wakeup interrupt processing main process no no yes yes standby enable flag = 0? remote-wakeup interrupt processing (see figure 14.10) * 1 * 1 * 1 * 2 * 2 * 2 standby enable flag = 1? notes: 1. the standby enable flag is a software flag for controlling transition to the standby state (one of the power-down modes). there is no such hardware flag. 2. interrupts should be masked from when the irq6 interrupt is received until the sleep instruction is executed. finally, unmask the interrupts using the ldc instruction or the like and execute the sleep instruction immediately afterward. remote- wakeup figure 14.9 example flowchart of suspend and remote-wakeup operations section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 505 of 698 rej09b0074-0600 (4) remote-wakeup interrupt processing figure 14.10 is a flowchart of remote-wakeup interrupt processing. usb function firmware remote-wakeup interrupt processing usb operating clock stabilization detection interrupt processing start usb operating clock oscillation output resume signal to usb bus a suspend/resume interrupt occurs a usb operating clock stabilization detection interrupt occurs wait for resume signal from up-stream clear usb operating clock stabilization detection flag (clear ck48ready in uifr3 to 0) execute remote-wakeup (set dvr in udrr to 1) resume interrupt processing (see figure 14.8) clear usb module stop mode (clear sprsi in uifr3 to 0) wait for usb operating clock stabilization resume main process usb operating clock stabilization time has passed? yes yes no exirqx irq6 no is remote- wakeup enabled by host? nmi or irqx remote- wakeup figure 14.10 example flowchart of remote-wakeup interrupt processing section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 506 of 698 rej09b0074-0600 14.5.4 control transfer the control transfer consists of three stages; setu p, data (sometimes omitted), and status, as shown in figure 14.11. the data stage consists of multiple bus transactions. figures 14.12 to 14.16 show operation flows in each stage. control-in setup stage data stage status stage control-out no data setup (0) data0 setup (0) data0 setup (0) data0 in (1) data1 out (1) data1 in (0) data0 out (0) . . . . . . data0 in (0/1) data0/1 out (0/1) data0/1 out (1) data1 in (1) data1 in (1) data1 figure 14.11 control transfer stage configuration section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 507 of 698 rej09b0074-0600 (1) setup stage usb function firmware receive setup token receive 8-byte command data in uedr0s to data stage set setup command recive complete flag (setupts in uifr0 = 1) automatic processing by this module clear setupts flag (setupts in uifr0 = 0) clear ep0i fifo (ep0iclr in ufclr = 1) clear ep0o fifo (ep0oclr in ufclr = 1) read 8-byte data from uedr0s decode command data determine data stage direction * 1 write 1 to ep0s read complete bit (ep0srdfn in utrg0 = 1) to control-in data stage to control-out data stage command to be processed by firmware? exirqx yes no notes: 1. in the setup stage, the firmware first analyzes the command data that is sent from the host and required to be processed by the firmware, and determines subsequent processing. (for example, the data stage direction.) 2. when the transfer direction is control-out, the ep0i transfer request interrupt that is required in the status stage should be enabled. when the transfer direction is control-in, this interrupt is not required and must be disabled. * 2 figure 14.12 setup stage operation section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 508 of 698 rej09b0074-0600 (2) data stage (control-in) the firmware first analyzes the command data that is sent from the host in the setup stage, and determines the subsequent data stage direction. if the result of command data analysis is that the data stage is in-transfer, one packet of data to be sent to the host is written to the fifo. if there is more data to be sent, this data is written to the fifo after the data written first has been sent to the host (ep0its in uifr0 is set to 1). the end of the data stage is identified when the host transmits an out token and the status stage is entered. usb function firmware receive in token transmit data to host set ep0i transmit complete flag (ep0its in uifr0 = 1) from setup stage write data to usb endpoint data register 0i (uedr0i) write 1 to ep0i packet enable bit (ep0ipkte in utrg0 = 1) clear ep0i transmit complete flag (ep0its in uifr0 = 0) write 1 to ep0i packet enable bit (ep0ipkte in utrg0 = 1) write data to usb endpoint data register 0i (uedr0i) 1 written to ep0srdfn in utrg0? valid data in ep0i fifo? nak nak no no yes yes ack exirqx note: if the size of the data transmitted by the function is smaller than the data size requested by the host, the function indicates the end of the data stage by returnning to the host a packet shorter than the maximum packet size. if the size of the data transmitted by the function is an integral multiple of the maximum packet size, the function indicates the end of the data stage by transmitting a zero-length packet. figure 14.13 data stage operation (control-in) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 509 of 698 rej09b0074-0600 (3) data stage (control-out) the firmware first analyzes the command data that is sent from the host in the setup stage, and determines the subsequent data stage direction. if the result of command data analysis is that the data stage is out-transfer, data from the host is waited for, and after data is received (ep0ots in uifr0 is set to 1), data is read from the fifo. next, the firmware writes 1 to the ep0o read complete bit, empties the receive fifo, and waits for reception of the next data. the end of the data stage is identified when the host transmits an in token and the status stage is entered. usb function firmware receive out token receive data from host receive out token set ep0o receive complete flag (ep0ots in uifr0 = 1) clear ep0o receive complete flag (ep0ots in uifr0 = 0) read data from usb endpoint receive data size register 0o (uesz0o) write 1 to ep0o read complete bit (ep0ordfn in utrg0 = 1) read data from usb endpoint data register 0o (uedr0o) 1 written to ep0srdfn in utrg0? 1 written to ep0ordfn in utrg0? nak nak ack no yes no yes exirqx figure 14.14 data stage operation (control-out) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 510 of 698 rej09b0074-0600 (4) status stage (control-in) the control-in status stage starts with an out token from the host. the firmware receives 0- byte data from the host, and ends control transfer. usb function firmware out token reception 0-byte reception from host end of control transfer set ep0o reception complete flag (uifr0/ep0ots = 1) clear ep0o reception complete flag (uifr0/ep0ots = 0) write 1 to ep0o read complete bit (utrg0/ep0ordfn = 1) end of control transfer ack exirqx figure 14.15 status stage operation (control-in) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 511 of 698 rej09b0074-0600 (5) status stage (control-out) the control-out status stage starts with an in token from the host. when an in-token is received at the start of the status stage, there is not yet any data in the ep0i fifo, and so an ep0i transfer request interrupt is generated. the firmware recognizes from this interrupt that the status stage has started. next, in order to transmit 0-byte data to the host, 1 is written to the ep0i packet enable bit but no data is written to the ep0i fifo. as a result, the next in token causes 0-byte data to be transmitted to the host, and control transfer ends. after the firmware has finished all processing relating to the data stage, 1 should be written to the ep0i packet enable bit. usb function firmware receive in token transfer 0-byte data to host end of control transfer set ep0i transmit complete flag (ep0its in uifr0 = 1) clear ep0i transfer request flag (ep0itr in uifr0 = 0) write 1 to ep0i packet enable bit (ep0ipkte in utrg0 = 1) write 0 to ep0i transfer request interrupt enable bit (ep0itre in uier0 = 0) clear ep0i transmit complete flag (ep0its in uifr0 = 0) end of control transfer valid data in ep0i fifo? ack yes no nak exirqx exirqx figure 14.16 status stage operation (control-out) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 512 of 698 rej09b0074-0600 14.5.5 interrupt-in transfer (endpoint 3) usb function firmware receive in token transmit data to host set ep3 transmit complete flag (ep3ts in uifr0 = 1) write data to usb endpoint data register 3 (uedr3) write 1 to ep3 packet enable bit (ep3pkte in utrg0 = 1) clear ep3 transmit complete flag (ep3ts in uifr0 = 0) write data to usb endpoint data register3 (uedr3) write 1 to ep3 packet enable bit (ep3pkte in utrg0 = 1) valid data in ep3 fifo? is there transmit data to host? is there transmit data to host? no yes no yes no yes nak ack note: this flowchart shows just one example of interrupt-in transfer processing. other possibilities include an operation flow in which, if there is data to be transmited, the ep3de bit udsr is referred to confirm that the fifo is empty, and then data is written to the fifo. exirqx figure 14.17 ep3 interr upt-in transfer operation section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 513 of 698 rej09b0074-0600 14.5.6 bulk-in transfer (dual fifos) (endpoint 1) ep1 has two 64-byte fifos, but the user can transmit data and write transmit data without being aware of this dual-fifo configuration. however, one data write should be performed for one fifo. for example, even if both fifos are empty, it is not possible to perform ep1pkte at one time after consecutively writing 128 bytes of data. ep1pkte must be performed for each 64- byte write. when transmitting data to the host by bulk-in transfer, first enable the ep1 fifo empty interrupt by writing 1 to ep1emptye in uier1. at first, both ep1 fifos are empty, and so an ep1 fifo empty interrupt is generated immediately. the data to be transmitted is written to the data register using this interrupt. after the first transmit data write for one fifo, the other fifo is empty, and so the next transmit data can be written to the other fifo immediately. when both fifos are full, ep1empty is cleared to 0. if at least one fifo is empty, uifr1/ep1empty is set to 1. when ack is returned from the host after data transmission is completed, the fifo used in the data transmission becomes empty. if the other fifo contains valid transmit data at this time, transmission can be continued. when transmission of all data has been completed, write 0 to uier1/ep1emptye and disable exirq0 or exirq1 interrupt requests. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 514 of 698 rej09b0074-0600 usb function firmware receive in token transmit data to host write 1 to ep1 fifo empty enable (ep1emptye in uier1 = 1) uifr1/ep1empty interrupt usb endpoint data register 1 (write one packet of data to uedr1) write 1 to ep1 packet enable bit (ep1pkte in utrg0 = 1) write 0 to ep1 fifo empty interrupt enable bit (ep1emptye in uier1 = 0) set ep1 fifo empty status (ep1empty in uifr1 = 1) valid data in ep1 fifo? nak ack yes yes yes no no no clear ep1 fifo empty status (ep1empty in uifr1 = 0) space in ep1 fifo? no yes exirqx is there data to be transmitted to host? is there data to be transmitted in host? figure 14.18 ep1 bulk-in transfer operation section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 515 of 698 rej09b0074-0600 14.5.7 bulk-out transfer (dual fifos) (endpoint 2) ep2 has two 64-byte fifos, but the user can receive data and read receive data without being aware of this dual-fifo configuration. when one fifo is full after reception is completed, the uifr1/ep2ready bit is set. after the first receive operation into one of the fifos when both fifos are empty, the other fifo is empty, and so the next packet can be received immediately. when both fifos are full, nak is returned to the host automatically. when reading of the receive data is completed following data reception, 1 is written to the utrg0/ep2rdfn bit. this operation empties the fifo that has just been read, and makes it ready to receive the next packet. usb function firmware receive out token receive data from host set ep2 data ready status (ep2ready in uifr1 = 1) clear ep2 data ready status (ep2ready in uifr1 = 0) read usb endpoint receive data size register 2 (uesz2) read data from usb endpoint data register 2 (uedr2) write 1 to ep2o read complete bit (ep2rdfn in utrg0 = 1) space in ep2 fifo? no yes both ep2 fifos empty? no yes nak ack exirqx exirqi figure 14.19 ep2 bulk-out transfer operation section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 516 of 698 rej09b0074-0600 14.5.8 processing of usb standard commands and class/vendor commands (1) processing of commands transmitted by control transfer a command transmitted from the host by contro l transfer may require decoding and execution of command processing by the firmware. whether or not command decoding is required by the firmware is indicated in table 14.5 below. table 14.5 command decoding by firmware decoding not necessary by firmware decoding necessary by firmware clear feature get configuration get interface get status set address set configuration set feature set interface get descriptor synch frame set descriptor class/vendor command if decoding is not necessary by the firmware, command decoding and data stage and status stage processing are performed automatically. no processing is necessary by the user. an interrupt is not generated in this case. if decoding is necessary by the firmware, the usb function module stores the command in the ep0s fifo. after normal reception is completed, the setupts flag in uier0 is set and an interrupt request is generated from the exirqx pin. in the interrupt routine, eight bytes of data must be read from the ep0s data register (uedr0s) and decoded by the firmware. the necessary data stage and status stage processing should then be carried out according to the result of the decoding operation. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 517 of 698 rej09b0074-0600 14.5.9 stall operations (1) overview this section describes stall operations in th e usb function module. there are two cases in which the usb function module stall function is used: . when the firmware forcibly stalls an endpoint for some reason . when a stall is performed automatically within the usb function module due to a usb specification violation. the usb function module has internal status bits that hold the status (stall or non-stall) of each endpoint. when a transaction is sent from the host, the module refers these internal status bits and determines whether to return a stall to the host. these bits cannot be cleared by the firmware; they must be cleared with a clear feature command from the host. however, the internal status bit for ep0 is cleared automatically at the reception of the setup command. (2) forcible stall by firmware the firmware uses the uestl register to issue a stall request for the usb function module. when the firmware wishes to stall a specific endpoint, it sets the corresponding epnstl bit (1- 1 in figure 14.20). the internal status bits are not changed at this time. when a transaction is sent from the host for the endpoint for which the epnstl bit was set, the usb function module refers the internal status bit, and if this is not set, refers the corresponding epnstl bit (1-2 in figure 14.20). if the corresponding epnstl bit is not set, the internal status bit is not changed and the transaction is accepted. if the corresponding epnstl bit is set, the usb function module sets the internal status bit and returns a stall handshake to the host (1-3 in figure 14.20). once an internal status bit is set, it remains set until cleared by a clear feature command from the host, without regarding to epnstl. even after a bit is cleared by the clear feature command (3-1 in figure 14.20), the usb function module continues to return a stall handshake while the epnstl bit is set, since the internal status bit is set each time a transaction is executed for the corresponding endpoint (1-2 in figure 14.20). to clear a stall, therefore, it is necessary for the corresponding epnstl bit to be cleared by the firmware, and also for the internal status bit to be cleared with a clear feature command (2-1 to 2-3 in figure 14.20). section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 518 of 698 rej09b0074-0600 (1) t rans i t i on from norma l operat i on to sta ll (1 - 1) t ransact i on request usb reference usb funct i on modu l e (1 - 2) sta ll handshake sta ll t o (2 - 1) or (3 - 1) t o (1 - 3) n orma l status restored (1 - 3) (2) when c l ear f eature i s sent after e pns tl has been c l eared (2 - 1) sta ll handshake t ransact i on request (2 - 2) c l ear f eature command c l ear f eature command (2 - 3) (3) when c l ear f eature i s sent before e pns tl i s c l eared to 0 (3 - 1) 1 . set e pns tl to 1 by f i rmware 1 . rece i ve in/ ou t token from the host 2 . refer to e pns tl 1 . t ransm i t sta ll handshake 1 . c l ear i nterna l status b i t to 0 1 . c l ear i nterna l status b i t to 0 2 . n o change i n e pns tl b i t 1 . scm e i s set to 0 2 . e pns tl i s set to 1 3 . set i nterna l status b i t to 1 4. t ransm i t sta ll handshake 1 . c l ear e pns tl to 0 by f i rmware 2 . rece i ve in/ ou t token from the host 3 . i nterna l status b i t has been set to 1 4. e pns tl i s not referred to 5 . n o change i n i nterna l status b i t t o (1 - 2) i nterna l status b i t 0 e pns tl 0 1 i nterna l status b i t 0 e pns tl 1 i nterna l status b i t 0 1 e pns tl 1 (scm e = 0) i nterna l status b i t 1 e pns tl 1 0 i nterna l status b i t 1 e pns tl 0 i nterna l status b i t 1 0 e pns tl 0 i nterna l status b i t 1 0 e pns tl 1 figure 14.20 forcible stall by firmware section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 519 of 698 rej09b0074-0600 (3) automatic stall by usb function module when a stall setting is made with the set feature command, when the information of this module differs from that returned to the host by the get descriptor, or in the event of a usb specification violation, the usb function module automatically sets the internal status bit for the corresponding endpoint without regarding to epnstl, and returns a stall handshake (1-1 in figure 14.21). once an internal status bit is set, it remains set until cleared by a clear feature command from the host, without regarding to epnstl. after a bit is cleared by the clear feature command, epnstl is referred (3-1 in figure 14.21). the usb function module continues to return a stall handshake while the internal status bit is set, since the internal status bit is set even if a transaction is executed for the corresponding endpoint (2-1 and 2-2 in figure 14.21). to clear a stall, therefore, the internal status bit must be cleared with a clear feature command (3-1 in figure 14.21). if set by the firmware, epnstl should also be cleared (2-1 in figure 14.21). (1) transition from normal operation to stall (2) when transaction is performed whill internal status bit is set stall handshake transaction request stall handshake (2-2) clear feature command (3) when clear feature is sent before transaction is performed (3-1) 1. in case of usb specification violation, usb function module stalls endpoint automatically. 1. transmit stall handshake 1. clear the internal status bit to 0 2. no change in epnstl bit 1. receive in/out token from the host 2. internal status bit has been set to 1 3. epnstl is not referred to 4. no change internal status bit normal status restored internal status bit 0 1 epnstl 0 internal status bit 1 epnstl 0 internal status bit 1 epnstl 0 internal status bit 1 0 epnstl 0 stall status maintained usb function module to (2-1) or (3-1) (1-1) (2-1) figure 14.21 automatic stall by usb function module section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 520 of 698 rej09b0074-0600 14.6 dma transfer specifications two methods of usb request and auto request are available for the dma transfer of usb data. 14.6.1 dmac transfer by usb request (1) overview only normal mode in full address mode (cycle steal mode) supports the transfer by a usb request of the on-chip dmac. endpoints that can be transferred by the on-chip dmac are ep1 and ep2 in bulk transfer (corresponding registers are uedr1 and uedr2). in dma transfer, the usb module must be accessed as an external device in area 6. the usb module cannot be accessed as a device with external ack (single-address transfer cannot be performed). 0-byte data transfer to ep2 is ignored even if the dma transfer is enabled by setting the ep2t1 bit in udmar to 1. (2) on-chip dmac settings the on-chip dmac must be specified as follows: a usb request ( dreq signal is used), activated by low-level input, byte size, full-address mode transfer, and the dta bit in dmabcr = 1. after completing the dma transfer of specified times, the dmac automatically stops. note, however, that the usb module keeps the dreq signal low while data to be transferred by the on-chip dmac remains regardless of the dmac status. (3) ep1 dma transfer the ep1t1 bit in udmar enables the dma transfer. the ep1t0 bit in udmar specifies the dreq signal to be used by the dma transfer. when 1 is written to the ep1t1 bit, the dreq signal is driven low if at least one of ep1 data fifos is empty; the dreq signal is driven high if both ep1 data fifos are full. (a) ep1pkte in utrg0 when dma transfer is performed on ep1 transmit data, the usb module automatically performs the same processing as writing 1 to ep1pkte if one data fifo (64 bytes) becomes full. accordingly, to transfer data of integral multiples of 64 bytes, the user needs not to write 1 to ep1pkte. to transfer data of less than 64 bytes, the user must write 1 to ep1pkte using the dma transfer end interrupt of the on-chip dmac. if the user writes 1 to ep1pkte in cases other than the case when data of less than 64 bytes is transferred, excess transfer occurs and correct operation cannot be guaranteed. figure 14.22 shows an example for transmitting 150 bytes of data from ep1 to the host. in this case, internal processing as the same as writing 1 to ep1pkte is automatically performed twice. this kind of internal processing is performed when the currently selected data fifo becomes full. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 521 of 698 rej09b0074-0600 accordingly, this processing is automatically performed only when 64-byte data is sent. this processing is not performed automatically when data less than 64 bytes is sent. (b) ep1 dma transfer procedure 1. set the bits ep1t1 and ep1t0 in udmar. 2. set dmac (specifies the number of transfers in dmac to transmit 150 bytes of data). 3. activate dmac. 4. perform dma transfer. 5. write 1 to the ep1pkte bit in utrg0 by a dma transfer end interrupt. 64 bytes 64 bytes 22 bytes ep1pkte (automatically performed) ep1pkte (automatically performed) ep1pkte is not performed executed by dma transfe r end interrupt (user) figure 14.22 ep1pkte operation in utrg0 (4) ep2 dma transfer the ep2t1 bit in udmar enables the dma transfer. the ep2t0 bit in the udmar specifies the dreq signal to be used by the dma transfer. when 1 is written to the ep2t1 bit, the dreq signal is driven low if at least one of ep2 data fifos is full (ready state); the dreq signal is driven high if both ep2 data fifos are empty when all receive data items are read. (a) ep2rdfn in utrg0 when dma transfer is performed on ep2 receive data, do not write 1 to ep2rdfn after one data fifo (64 bytes) has been read. in data transfer other than dma transfer, the next data cannot be read after one data fifo (64 bytes) has been read unless 1 is written to ep2rdfn. while in dma transfer, the usb module automatically performs the same processing as writing 1 to ep2rdfn if the currently selected data fifo becomes empty. accordingly, in dma tr ansfer, the user needs not to write 1 to ep2rdfn. if the user writes 1 to ep2rdfn in dma transfer, excess transfer occurs and correct operation cannot be guaranteed. figure 14.23 shows an example of ep2 receiving 150 bytes of data from the host. in this case, internal processing as the same as writing 1 to ep2rdfn is automatically performed three times. this kind of internal processing is performed when the currently selected data fifo becomes empty. accordingly, this processing is automatically performed both when 64-byte data is sent and when data less than 64 bytes is sent. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 522 of 698 rej09b0074-0600 (b) ep2 dma transfer procedure perform dmac transfer in 1 packet units. after setting the ep2ready flag, check the size of data received from the host and then set the data size as the number of dmac transfers. 1. set the bits ep2t1 and ep2t0 in udmar. 2. wait for the ep2ready flag in uifr1 to be set. 3. set dmac. read the value in uesz2 and specifies the size of received data (not more than 64 bytes) as the number of transfers. 4. activate dmac. 5. perform dma transfer (not more than 64 bytes). 6. wait for dma transfer end. 7. repeat steps 2 to 6. ep2rdfn (automatically performed) ep2rdfn (automatically performed) ep2rdfn (automaticall y performed) 64 bytes 64 bytes 22 bytes figure 14.23 ep2rdfn operation in utrg0 14.6.2 dma transfer by auto-request (1) overview burst mode transfer or ycle steal transfer can be selected for the on-chip dmac auto-request transfer. endpoints that can be transferred by the on-chip dmac are all registers (uedr0s, uedr0i, uedr0o, uedr1, uedr2, uedr3). confirm flags and interrupts corresponding to each data register before activating the dma. as udmar is not used in auto-request mode, set udmar to h'00. (2) on-chip dmac settings the on-chip dmac must be specified as follows: auto-request, byte size, full-address mode transfer, and number of transfers equal to or less than the maximum packet size of the data register. after completing the dmac transfers of specified time, the dmac automatically stops. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 523 of 698 rej09b0074-0600 (3) ep0, ep1, or ep3 dma transfer (a) epnpkte bits of utrg0 (n = 0i, 1, or 3) note that 1 is not automatically written to epnpkte in case of auto-request transfer. always write 1 to epnpkte by the cpu. the following example shows when 150-byte data is transmitted from ep1 to the host. in this case, 1 should be written to ep2pkte three times as shown in figure 14.24. (b) ep1 dma transfer procedure the dmac transfer unit should be one packet. therefore, set the number of transfers so that it is equal to or less than the maximum packet size of each endpoint. 1. confirm that uifr1/ep1empty flag is 1. 2. dmac settings for ep1 data transfer (such as auto-request and address setting). 3. set the number of transfers for 64 bytes (the maximum packet size or less) in the dmac. 4. activate the dmac (write 1 to dte after reading dte as 0). 5. dma transfer. 6. write 1 to the utrg0/ep1pkte bit after the dma transfer is completed. 7. repeat steps 1 to 6 above. 8. confirm that uifr1/ep1empty flag is 1. 9. set the number of transfer for 22 bytes in the dmac. 10. activate the dmac (write 1 to dte after reading dte as 0). 11. dma transfer. 12. write 1 to the utrg0/ep1pkte bit after the dma transfer is completed. write 1 to ep1pkte write 1 to ep1pkte write 1 to ep1pkte 64 bytes 64 bytes 22 bytes figure 14.24 ep1pkte operation in utrg0 (auto-request) (4) ep0o or ep2 dma transfer (a) epnrdfn bits of utrg0 (n = 0o or 2) note that 1 is not automatically written to epnrdfn in case of auto-request transfer. always write 1 to epnrdfn by the cpu. the following example shows when ep2 receives 150-byte data from the host. in this case, 1 should be written to ep2rdfn three times as shown in figure 14.25. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 524 of 698 rej09b0074-0600 (b) ep2 dma transfer procedure the dmac transfer unit should be one packet. therefore, set the number of transfers so that it is equal to or less than the maximum packet size of each endpoint. 1. wait for the uifr1/ep2ready flag to be set. 2. dmac settings for ep2 data transfer (such as auto-request and address setting). read value of uesz2 and specify number of transfers to match size of received data (64 bytes or less). 3. activate the dmac (write 1 to dte after reading dte as 0). 4. dma transfer (transfer of 64 bytes or less). 5. write 1 to the utrg0/ep2rdfn bit after the dma transfer is completed. 6. repeat steps 1 to 5 above. write 1 to ep2rdfn write 1 to ep2rdfn write 1 to ep2rdfn 64 bytes 64 bytes 22 bytes figure 14.25 ep2rdfn operation in utrg0 (auto-request) section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 525 of 698 rej09b0074-0600 14.7 usb external circuit example figures 14.26 and 14.27 show the usb external circuit examples of this lis. regulator 0: bus-powered mode internal transceiver vcc 1.5 k drvcc (3.3 v) vcc (3.3 v) vbus (5 v) usd+ usd- d+ d- drvss gnd ubpm vbus vcc (3.3 v) 24 24 vss usb connector * 1 usb step-down to the operating voltage vcc (3.3 v) of this lsi. to protect the lsi, voltage applicable ic such as hd74lv-a series must be used even when the system power is turned off. prevent the vbus pin from being affected by noise while usb is in communication. pull-up control external circuit for full speed 1. 2. 3. notes: * 2 * 3 p36 figure 14.26 usb external circuit in bus-powered mode section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 526 of 698 rej09b0074-0600 1: self-powered mode internal transceiver p36 1.5 k drvcc (3.3 v) 3.3v vbus (5 v) usd+ usd- d+ d- 24 24 drvss gnd ubpm vbus vcc (3.3 v) irqx vcc vcc vss usb connector * 1 * 2 * 3 usb to protect the lsi, voltage applicable ic such as hd74lv-a series must be used even when the system power is turned off. to cancel power-down mode by detecting the usb cable connection, thevbus signal must be connected to the irqx pin. note that power-down mode state cannot be canceled by the usb interrupt exirqx . prevent the vbus pin from being affected by noise while usb is in communication. pull-up control external circuit for full speed 1. 2. 3. notes: vcc * 1 figure 14.27 usb external circuit in self-powered mode section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 527 of 698 rej09b0074-0600 14.8 usage notes 14.8.1 emulator usage notes 1. if uedr0o and uedr2 are displayed using the i/o register window function, or the like, the ep0o fifo or ep2 fifo read pointer will not operate properly, preventing uedr0o, uesz0o, uedr2, and uesz2 from being read correctly. therefore, uedr0o and uedr2 should not be displayed. 2. in the e6000, since the usb module is mounted on the external extended board and accessed as an external module, there are some limitations as shown below. these limitations do not apply to the e10a or to product chips. ? usb operation is not supported in the h8s/2218 group?s mode 7 (single-chip mode). ? when using the usb module in the h8s/2218 group?s mode 6 (on-chip rom-enabled mode) or the h8s/2212 group?s mode 7 (single-chip mode), cs6 and a9 to a0 are input pins in the initial status. therefore, cs6 and a9 to a0 must be set as output pins (= b'0010) by setting p72ddr to 1, ae3 to ae0 to b'0010, and pc7 ddr to pc0ddr to h'ff before accessing the usb module. ? when using the usb module in the h8s/2218 group?s modes 4 and 5 (on-chip rom-disabled mode), cs6 and a9 to a8 must be set as output pins by setting p72ddr to 1 and ae3 to ae0 to b'0010. 14.8.2 bus interface the usb module's interface is based on the bus specifications of external area 6. accordingly, before accessing the usb module, area 6 must be specified as having an 8-bit bus width and 3- state access using the bus controller register. address h'c00100 to h'dfffff is for usb reserved area and thus access prohibited. 14.8.3 operating frequency the main clock of this lsi must be 24 mhz or 16 mhz. this 24-mhz main clock, used as base clock, is doubled in the on-chip pll circuit or this 16-mhz main clock, also used as base clock, is tripled in the on-chip pll circuit, to generate the 48-mhz usb operating clock. since the usb module does not support medium-speed mode, sleep mode, watch mode, subactive mode, and subsleep mode, make sure to use full-speed mode. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 528 of 698 rej09b0074-0600 14.8.4 setup data reception the following must be noted for the ep0s fifo used to receive 8-byte setup data. the usb is designed to always receive setup commands. acco rdingly, write from the udc has higher priority than read from the lsi. if the reception of the ne xt setup command starts while the lsi is reading data after completing reception, this data read from the lsi is forcibly cancelled and the next setup command write starts. after the next setup command write, data read from the lsi is thus undefined. read operation is forcib ly disabled because data cannot be guaranteed if dp-ram used as fifo accesses the same address for write and read. 14.8.5 fifo clear if the usb cable is disconnected during communication, old data may be contained in the fifo. accordingly, fifos must be cleared immediately after usb cable connection. in addition, after bus reset, all fifos must also be cleared. note, however, that fifos that are currently used for data transfer to or from the host must not be cleared. 14.8.6 irq6 interrupt a suspend/resume interrupt requested by irq6 must be specified as falling-edge sensitive. 14.8.7 data register overread or overwrite when the cpu reads or writes to data registers, the following must be noted: ? transmit data registers (uedr0i, uedr3, uedr1) data to be written to the transmit data registers must be within the maximum packet size. for the transmit data register of ep1 having a dual-fifo configuration, data to be written at any time must be within the maximum packet size. in this case, after a data write, the fifo is switched to the other fifo, enabling an further data write, when the pkte bit in utrg0 is set to 1. accordingly, data of size corresponding to two fifos must not be written to the transmit data registers at a time. ? receive data registers (uedr0o, uedr2) receive data registers must not read a data size that is greater than the effective size of the read data item. in other words, receive data registers must not read data with data size larger than that specified by the receive data size register. for the receive data register of ep2 having a dual-fifo configuration, data to be read at an y time must be within the maximum packet size. in this case, after reading the currently selected fifo, set the rdfn bit in utrg to 1. this switches the fifo to the other fifo and updates the receive data size, enabling the next data read. in addition, if there is no receive data in a fifo, data must not be read. otherwise, the section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 529 of 698 rej09b0074-0600 pointer that controls the internal module fifo is updated and correct operation cannot be guaranteed. 14.8.8 reset ? the manual reset during usb communication operations must not be executed, since the lsi may stop with the state of usd+ and usd- pins maintained. this usb module uses synchronous reset for some registers. the reset state of these registers must be cancelled after the clock oscillation stabilization time has passed. at initialization, reset must be cancelled using the following procedure: 1. cancel the usb module stop 1: clear the usbstop1 bit in exmdlstp to 0. 2. select the usb operating clock: write 1 to the ucks3 to ucks0 bits in uctlr. 3. cancel the usb module stop 2: clear the mstpb0 bit in mstpcrb to 0. 4. wait for the usb operating clock stabilization: wait until the ck48ready bit in uifr3 is set to 1. 5. cancel the usb interface reset state: clear the uifrst bit in uctlr to 0. 6. cancel the udc core reset state: clear the udcrst bit in uctlr to 0. for details, see the flowcharts in section 14.5. 1, initialization and section 14.5.2, usb cable connection/disconnection. ? the usb registers are not initialized when the watchdog timer (wdt) triggers a power-on reset. therefore, the usb may not operate properly after a power-on reset is triggered by the wdt due to cpu runaway or a similar cause. (if a power-on reset is triggered by input of a power-on reset signal from the res pin, the usb registers are initialized and there is no problem.) consequently, an initialization routine should be used to write the initial values listed below to the following three registers, thereby ensuring that all the usb registers are properly initialized, immediately following a reset. uctlr = h'03, uier3 = h'80, uifr3 = h'00 14.8.9 ep0 interrupt sources assignment ep0 interrupt sources assigned to bits 3 to 0 in uifr0 must be assigned to the same interrupt signal ( exirqx ) by setting uisr0. there are no other restrictions on interrupt sources. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 530 of 698 rej09b0074-0600 14.8.10 level shifter for vbus and irqx pins the vbus and irqx pins of this usb module must be connected to the usb connector?s vbus pin via a level shifter. this is because the usb module has a circuit that operates by detecting usb cable connection or disconnection. even if the power of the device incorporating this usb module is turned off, 5-v power is applied to the usb connector?s vbus pin while the usb cab le is connected to the device set. to protect the lsi from destruction, use a level shifter such as the hd74lv-a series, which allows voltage application to the pin even when the power is off. 14.8.11 usb endpoint data read and write to write data to an usb endpoint data register (uedr0i, uedr1, or uedr3) on the transmit side using a cpu word or longword transfer instruction, the size of data to be written must be smaller than the size of data that is to be transmitted. for example, when 7-byte data is transferred to the host, 8-byte data is sent to the host if data is written twice by the longword transfer instructions or if data is written four times by the word transfer instructions. to write 7-byte data correctly, data must be written once by a longword transfer instruction, once by a word transfer instru ction, and once by a byte transfer instruction, or data must be written three times by a word transfer instruction and once by a byte transfer instruction. to read data from the usb endpoint data register (uedr0o or uedr2) on the receive side, the correct size of data must be read. in this case, the data size is specified by the usb endpoint receive size register (uesz0o or uesz2). to execute dma transfer on data in the usb endpoint data register using the on-chip dmac, byte transfer musts be used. in word transfer, odd-byte data cannot be transferred. word transfer is thus disabled. 14.8.12 restrictions on entering and canceling power-down mode before entering the power-down mode, set the usb module stop 2 state. the udc core must not be reset. to access the usb module after canceling power-down mode, cancel the usb module stop 2 state and wait for the usb operating clock (48 mhz) stabilization time. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 531 of 698 rej09b0074-0600 (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (21) (22) (19) (20) (23) (24) specify irq6 to falling edge sensitive (set irq6e in ier to 1) (write irq6scb and irq6sca in iscrh to 01 cancel usb module stop2 mode (clear mstpb0 in mstpcrb to 0) enter usb module stop 2 state (stop mstpb0 in mstpcrb to 1) usb communication operations can be restarted by using various usb registers clear sprsi in uifr3 to 0 mask all interrupts with ldc instruction, etc. * set irq6e in ier to 1 * unmask all interrupts with ldc instruction, etc. * enter power-down mode * (execute sleep instruction) irq6 = low (falling edge output) set irq6f in isr to 1 set sprsi and sprss in uifr3 to 1 confirm sprss in uifr3 as 1 clear irq6e in ier to 0 * clear sprsi in uifr3 to 0 detect usb bus suspend state uspnd pin = high procedure to enter power-down mode procedure to cancel power-down mode detect usb bus resume uspnd pin = low all usb module internal clocks stop usb module intenal clock operation starts wait 2 ms for usb operation clock to stabilize (wait for ck48ready in uifr3 is set to 1) all lsi internal clocks stop irq6 = high irq6 = high cancel power-down mode wait for system clock stabilization time (for external clok: 16 states min.) (for crystal oscillator clock: 4 ms min.) enter active mode (lsi internal clock starts oscillation) irq6 = low (falling edge output) set irq6f in isr to 1 set sprsi of uifr3 to 1 clear sprss of uifr3 to 0 set ck48ready in uifr3 to 1 (usb operating clock stabilized) detect sof packet set sof of uifr3 to 1 : indicates operations to be done by firmware. guide to flowchart figures : indicates operations to be automatically done by hardware in this lsi. note: * interrupts should be masked from when the irq6 interrupt is received until the sleep instruction is executed. finally, unmask the interrupts using the ldc instruction or the like and execute the sleep instruction immediately afterward. figure 14.28 flowchart section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 532 of 698 rej09b0074-0600 (1) (2) (3) (3) (3) (3) (4) (4) (4) (5) (6) (7) (7) (7) power-down mode 4 ms wait for oscillator to stabilize 2 ms wait for usb operation clock to stabilize usb module stop state usb operation resumes (8) (9) (9) (10) (10) (11) (11) (12) (13) (14) (15) (16) (17) (18) (18) (21) (22) (23) usb bus state irq6 isr/irq6f uifr3/sprsi uspnd uifr3/sprss uifr3/sof usb module stop power-down mode system clock normal suspend sof usb internal clock uifr3/ ck48ready clk48 (48mhz) usb operating clock (48mhz) (14) (19) (19) (20) (24) resume normal figure 14.29 timing chart 14.8.13 usb external circuit example the usb external circuit examples are used for reference only. in actual board design, carefully check the system operation. in addition, the usb external circuit examples cannot guarantee the correct system operation. the user must individually take measures against external surges or esd noise by incorporating protective diodes or other components if necessary. section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 533 of 698 rej09b0074-0600 14.8.14 pin processing when usb not used pin processing should be performed as follows. drvcc = vcc, drvss = 0 v, usd + = usd ? = uspnd = open state, vbus = ubpm = 0 v 14.8.15 notes on tr interrupt note the following when using the transfer request interrupt (tr interrupt) for in transfer to ep0i, ep1, or ep3. the tr interrupt flag is set if the fifo for the target ep has no data when the in token is sent from the usb host. however, at the timing shown in figure 14.30, multiple tr interrupts occur successively. take appropriate measures against malfunction in such a case. note: this module determines whether to return nak if the fifo of the target ep has no data when receiving the in token, but the tr interrupt flag is set only after a nak handshake is sent. if the next in token is sent before pkte of utrg0 is written to, the tr interrupt flag is set again. cpu host in token in token in token sets tr flag (sets the flag again) sets tr flag determines whether to return nak transmits data tr interrupt routine clear tr flag writes transmit data utrg0/ pkte tr interrupt routine usb nak determines whether to return nak nak ack figure 14.30 tr interrupt flag set timing section 14 universal serial bus (usb) rev.6.00 jun. 03, 2008 page 534 of 698 rej09b0074-0600 section 15 a/d converter rev.6.00 jun. 03, 2008 page 535 of 698 rej09b0074-0600 section 15 a/d converter this lsi includes a successive approximation type 10-bit a/d converter that allows up to six analog input channels to be selected. the block diagram of the a/d converter is shown in figure 15.1. 15.1 features ? 10-bit resolution ? six input channels ? conversion time: 8.1 s per channel (at 16-mhz operation), 10.7 s per channel (at 24-mhz operation), 21.8 s per channel (at 6-mhz operation) ? two operating modes ? single mode: single-channel a/d conversion ? scan mode: continuous a/d conversion on 1 to 4 channels ? four data registers ? conversion results are held in a 16-bit data register for each channel ? sample and hold function ? three methods conversion start ? software ? timer (tpu) conversion start trigger ? external trigger signal ( adtrg ) ? interrupt request ? an a/d conversion end interrupt request (adi) can be generated ? module stop mode can be set ? settable analog conversion voltage range analog conversion voltage range settable using the reference voltage pin (vref) as the reference voltage adcms34a_000120011200 section 15 a/d converter rev.6.00 jun. 03, 2008 page 536 of 698 rej09b0074-0600 module data bus bus interface multiplexer control circuit internal data bus + a d c s r a d c r a d d r d a d d r c a d d r b a d d r a an0 an1 an2 an3 an14 an15 legend: adcr: a/d control register adcsr: a/d control/status register addra: a/d data register a addrb: a/d data register b addrc: a/d data register c addrd: a/d data register d adtrg time conversion start trigger from tpu adi interrupt signal successive approximation register sample and hold circuit comparator /2 /4 /8 /16 10 bit d/a off during a/d conversion standby on during a/d conversion vref vcc vss figure 15.1 block diagram of a/d converter section 15 a/d converter rev.6.00 jun. 03, 2008 page 537 of 698 rej09b0074-0600 15.2 input/output pins table 15.1 summarizes the input pins used by the a/d converter. the an0 to an3 and an14 to an15 pins are analog input pins. the vcc and vss pins are the power supply pins for the analog block in the a/d converter. the vref pin is the reference voltage pin for the a/d conversion. table 15.1 pin configuration pin name symbol i/o function power supply pin vcc input analog block power supply and reference voltage (also used for digital block) ground pin vss input analog block ground and reference voltage (also used for digital block) reference voltage pin vref input reference voltage pin for a/d conversion analog input pin 0 an0 input analog input pin 1 an1 input analog input pin 2 an2 input analog input pin 3 an3 input analog input pin 14 an14 input analog input pin 15 an15 input analog input pins a/d external trigger input pin adtrg input external trigger input pin for starting a/d conversion 15.3 register descriptions the a/d converter has the following registers. ? a/d data register a (addra) ? a/d data register b (addrb) ? a/d data register c (addrc) ? a/d data register d (addrd) ? a/d control/status register (adcsr) ? a/d control register (adcr) section 15 a/d converter rev.6.00 jun. 03, 2008 page 538 of 698 rej09b0074-0600 15.3.1 a/d data registers a to d (addra to addrd) there are four 16-bit read-only addr registers; addra to addrd, used to store the results of a/d conversion. the addr registers, which store a conversion result for each channel, are shown in table 15.2. the converted 10-bit data is stored in bits 6 to 15. the lower 6 bits are always read as 0. the data bus between the cpu and the a/d converter is 8 bits wide. the upper byte can be read directly from the cpu, however the lower byte should be read via a temporary register. the temporary register contents are transferred from the addr when the upper byte data is read. when reading the addr, read the upper byte before the lower byte, or read in word unit. the initial value of the addr is h'0000. table 15.2 analog input channels and corresponding addr registers analog input channel a/d data register to be stored the results of a/d conversion an0 addra an1 addrb an2, an14 addrc an3, an15 addrd 15.3.2 a/d control/status register (adcsr) adcsr controls a/d conversion operations. bit bit name initial value r/w description 7 adf 0 r/(w) * a/d end flag a status flag that indicates the end of a/d conversion. [setting conditions] ? when a/d conversion ends in single mode ? when a/d conversion ends on all channels specified in scan mode [clearing conditions] ? when 0 is written after reading adf = 1 ? when dmac is activated by an adi interrupt and addr is read section 15 a/d converter rev.6.00 jun. 03, 2008 page 539 of 698 rej09b0074-0600 bit bit name initial value r/w description 6 adie 0 r/w a/d interrupt enable a/d conversion end interrupt (adi) request enabled when 1 is set. 5 adst 0 r/w a/d start clearing this bit to 0 stops a/d conversion, and the a/d converter enters the wait state. setting this bit to 1 starts a/d conversion. it can be set to 1 by software, the timer conversion start trigger, and the a/d external trigger ( adtrg ). in single mode, this bit is cleared to 0 automatically when conversion on the specified channel is complete. in scan mode, conversion continues sequentially on the specified channels until this bit is cleared to 0 by software, a reset, a transition to standby mode, or module stop mode. 4 scan 0 r/w scan mode selects single mode or scan mode as the a/d conversion operating mode. 0: single mode 1: scan mode 3 2 1 0 ch3 ch2 ch1 ch0 0 0 0 0 r/w r/w r/w r/w channel select 3 to 0 select analog input channels. when scan = 0 when scan = 1 0000: an0 0000: an0 0001: an1 0001: an0 to an1 0010: an2 0010: an0 to an2 0011: an3 0011: an0 to an3 01 : setting prohibited 01xx: setting prohibited 10 : setting prohibited 1xxx: setting prohibited 11 : setting prohibited 1110: an14 1111: an15 legend: : don?t care note: * the write value should always be 0 to clear this flag. section 15 a/d converter rev.6.00 jun. 03, 2008 page 540 of 698 rej09b0074-0600 15.3.3 a/d control register (adcr) the adcr enables a/d conversion started by an external trigger signal. bit bit name initial value r/w description 7 6 trgs1 trgs0 0 0 r/w r/w timer trigger select 1 and 0 enables the start of a/d conversion by a trigger signal. only set bits trgs1 and trgs0 while conversion is stopped (adst = 0). 00: a/d conversion start by software 01: a/d conversion start by tpu 10: setting prohibited 11: a/d conversion start by external trigger pin ( adtrg ) 5, 4 ? all 1 ? reserved these bits are always read as 1 cannot be modified. 3 2 cks1 cks0 0 0 r/w r/w clock select 1 and 0 these bits specify the a/d conversion time. the conversion time should be changed only when adst = 0. 00: conversion time = 530 states (max.) 01: conversion time = 266 states (max.) 10: conversion time = 134 states (max.) 11: conversion time = 68 states (max.) the conversion time setting should exceed the conversion time shown in section 22.6, a/d converter characteristics. 1, 0 ? all 1 ? reserved these bits are always read as 1, and only 1 should be written to them. section 15 a/d converter rev.6.00 jun. 03, 2008 page 541 of 698 rej09b0074-0600 15.4 interface to bus master addra to addrd are 16-bit registers. as the data bus to the bus master is 8 bits wide, the bus master accesses to the upper byte of the registers directly while to the lower byte of the registers via the temporary register (temp). data in addr is read in the following way: when the upper-byte data is read, the upper-byte data will be transferred to the cpu and the lower-byte data will be transferred to temp. then, when the lower-byte data is read, the lower-byte data will be transferred to the cpu. when data in addr is read, the data should be read from the upper byte and lower byte in the order. when only the upper-byte data is read, the data is guaranteed. however, when only the lower-byte data is read, the data is not guaranteed. figure 15.2 shows data flow when accessing to addr. temp (h'40) addrnl (h'40) addrnh (h'aa) temp (h'40) addrnl (h'40) addrnh (h'aa) read the upper byte read the lower byte (n = a to d ) (n = a to d ) module data bus module data bus bus interface bus interface bus master (h'40) bus master (h'aa) figure 15.2 access to addr (when reading h'aa40) section 15 a/d converter rev.6.00 jun. 03, 2008 page 542 of 698 rej09b0074-0600 15.5 operation the a/d converter operates by successive approximation with 10-bit resolution. it has two operating modes; single mode and scan mode. when changing the operating mode or analog input channel, in order to prevent in correct operation, first clear th e bit adst to 0 in adcsr. the adst bit can be set at the same time as the operating mode or analog input channel is changed. 15.5.1 single mode in single mode, a/d conversion is to be performed only once on the specified single channel. the operations are as follows. 1. a/d conversion is started when the adst bit is set to 1, according to software or external trigger input. 2. when a/d conversion is completed, the result is transferred to the corresponding a/d data register to the channel. 3. on completion of conversion, the adf bit in adcsr is set to 1. if the adie bit is set to 1 at this time, an adi interrupt request is generated. 4. the adst bit remains set to 1 during a/d conversion. when a/d conversion ends, the adst bit is automatically cleared to 0 and the a/d converter enters the wait state. adie adst adf state of channel 0 (an0) a/d conversion starts 2 1 addra addrb addrc addrd state of channel 1 (an1) state of channel 2 (an2) state of channel 3 (an3) note: * vertical arrows ( ) indicate instructions executed by software. set * set * clear * clear * a/d conversion result 1 a/d conversion a/d conversion result 2 read conversion result * read conversion result * idle idle idle idle idle idle a/d conversion set * figure 15.3 a/d conversion timing (single-chip mode, channel 1 selected) section 15 a/d converter rev.6.00 jun. 03, 2008 page 543 of 698 rej09b0074-0600 15.5.2 scan mode in scan mode, a/d conversion is to be performed sequentially on the specified channels (four channels maximum). the operations are as follows. 1. when the adst bit is set to 1 by software, tpu or external trigger input, a/d conversion starts on the first channel in the group (an0 when ch3 and ch2 = 00, an4 when ch3 and ch2 = 01, or an8 when ch3 and ch2 = 10). 2. when a/d conversion for each channel is completed, the result is sequentially transferred to the a/d data register corresponding to each channel. 3. when conversion of all the selected channels is completed, the adf flag is set to 1. if the adie bit is set to 1 at this time, an adi interrupt is requested after a/d conversion ends. conversion of the first channel in the group starts again. 4. steps 2 to 3 are repeated as long as the adst bit remains set to 1. when the adst bit is cleared to 0, a/d conversion stops. adst adf addra addrb addrc addrd state of channel 0 (an0) state of channel 1 (an1) state of channel 2 (an2) state of channel 3 (an3) set * 1 clear * 1 idle notes: 1. vertical arrows ( ) indicate instructions executed by software. 2. data currently being converted is ignored. clear * 1 idle idle a/d conversion time continuous a/d conversion execution a/d conversion 1 idle idle idle idle idle transfer a/d conversion 4 a/d conversion result 1 a/d conversion result 2 a/d conversion result 3 a/d conversion result 4 idle a/d conversion 5 * 2 a/d conversion 3 a/d conversion 2 figure 15.4 a/d conversion timing (sca n mode, channels an0 to an2 selected) section 15 a/d converter rev.6.00 jun. 03, 2008 page 544 of 698 rej09b0074-0600 15.5.3 input sampling and a/d conversion time the a/d converter has a built-in sample-and-hold circuit. the a/d converter samples the analog input when the a/d conversion start delay time (t d ) has passed after the adst bit is set to 1, then starts conversion. figure 15.5 shows the a/d conversion timing. tables 15.3 and 15.4 show the a/d conversion time. as indicated in figure 15.5, the a/d conversion time (t conv ) includes t d and the input sampling time (t spl ). the length of t d varies depending on the timing of the write access to adcsr. the total conversion time therefore varies within the ranges indicated in table 15.4. in scan mode, the values given in table 15.4 apply to the first conversion time. the values given in table 15.3 apply to the second and subsequent conversions. (1) (2) t d t spl t conv a ddress write signal input sampling timing a df legend: (1): adcsr write cycle (2): adcsr address t d : a/d conversion start delay t spl : input sampling time t conv : a/d conversion time figure 15.5 a/d conversion timing section 15 a/d converter rev.6.00 jun. 03, 2008 page 545 of 698 rej09b0074-0600 table 15.3 a/d conversion time (single mode) cks1 = 0 cks1 = 1 cks0 = 0 cks0 = 1 cks0 = 0 cks0 = 1 item symbol min. typ. max. min. typ. max. min. typ. max. min. typ. max. a/d conversion start delay t d 18 ? 33 10 ? 17 6 ? 9 4 ? 5 input sampling time t spl ? 127 ? ? 63 ? ? 31 ? ? 15 ? a/d conversion time t conv 515 ? 530 259 ? 266 131 ? 134 67 ? 68 note: all values represent the number of states. table 15.4 a/d conversion time (scan mode) cks1 cks0 conversion time (state) 0 512 (fixed) 0 1 256 (fixed) 1 0 128 (fixed) 1 64 (fixed) 15.5.4 external trigger input timing a/d conversion can be externally triggered. wh en the trgs0 and trgs1 bits are set to 11 in adcr, external trigger input is enabled at the adtrg pin. a falling edge at the adtrg pin sets the adst bit to 1 in adcsr, starting a/d conversion. other operations, in both single and scan modes, are the same as when the bit adst has been set to 1 by software. figure 15.6 shows the timing. adtrg internal trigger signal a dst a/d conversion figure 15.6 external trigger input timing section 15 a/d converter rev.6.00 jun. 03, 2008 page 546 of 698 rej09b0074-0600 15.6 interrupts the a/d converter generates an a/d conversion end interrupt (adi) at the end of a/d conversion. setting the adie bit to 1 enables adi interrupt requests while the bit adf in adcsr is set to 1 after a/d conversion is completed. the dmac can be activated by an adi interrupt. table 15.5 a/d converter interrupt source name interrupt source interrupt source flag dmac activation adi a/d conversion completed adf possible 15.7 a/d conversion precision definitions this lsi?s a/d conversion precision definitions are given below. ? resolution the number of a/d converter digital output codes ? quantization error the deviation inherent in the a/d converter, given by 1/2 lsb (see figure 15.7). ? offset error the deviation of the analog input voltage valu e from the ideal a/d conversion characteristic when the digital output changes from the minimum voltage value b'0000000000 (h'000) to b'0000000001 (h'001) (see figure 15.8). ? full-scale error the deviation of the analog input voltage valu e from the ideal a/d conversion characteristic when the digital output changes from b'1111111110 (h'3fe) to b'1111111111 (h'3ff) (see figure 15.8). ? nonlinearity error the error with respect to the ideal a/d conversion characteristic between zero voltage and full- scale voltage. does not include offset error, fu ll-scale error, or quantization error (see figure 15.8). ? absolute precision the deviation between the digital value and the analog input value. includes offset error, full- scale error, quantization error, and nonlinearity error. section 15 a/d converter rev.6.00 jun. 03, 2008 page 547 of 698 rej09b0074-0600 111 110 101 100 011 010 001 000 1 1024 2 1024 1022 1024 1023 1024 fs quantization error digital output ideal a/d conversion characteristic analog input voltage figure 15.7 a/d conversion precision definitions (1) fs digital output ideal a/d conversion characteristic nonlinearity error analog input voltage offset error actual a/d conversion characteristic full-scale error figure 15.8 a/d conversion precision definitions (2) section 15 a/d converter rev.6.00 jun. 03, 2008 page 548 of 698 rej09b0074-0600 15.8 usage notes 15.8.1 module stop mode setting operation of the a/d converter can be disabled or enabled using the module stop control register. the initial setting is for operation of the a/d converter to be halted. register access is enabled by clearing module stop mode. for details, refer to section 20, power-down modes. 15.8.2 permissible signal source impedance this lsi's analog input is designed such that conve rsion precision is guaranteed for an input signal for which the signal source impedance is 5 k or less. this specification is provided to enable the a/d converter?s sample-and-hold circuit input capacitance to be charged within the sampling time; if the sensor output impedance exceeds 5 k , charging may be insufficient and it may not be possible to guarantee a/d conversion precision. however, for a/d conversion in single mode with a large capacitance provided externally, the input lo ad will essentially comprise only the internal input resistance of 10 k , and the signal source impedance is ignored. however, as a low-pass filter effect is obtained in this case, it may not be possible to follow an analog signal with a large differential coefficient (e.g., 5 mv/ s or greater) (see figure 15.9). when converting a high-speed analog signal, a low-impedance buffer should be inserted. 15.8.3 influences on absolute precision adding capacitance results in coupling with gnd, and therefore noise in gnd may adversely affect absolute precision. be sure to make the connection to an electrically stable gnd such as avss. care is also required to insure that filter circuits do not communicate with digital signals on the mounting board (i.e., acting as antennas). 20 pf 10 k c in = 15 pf sensor output impedance to 5 k this lsi low-pass filter c to 0.1 f sensor input a/d converter equivalent circuit figure 15.9 example of analog input circuit section 15 a/d converter rev.6.00 jun. 03, 2008 page 549 of 698 rej09b0074-0600 15.8.4 range of analog power supply and other pin settings if the conditions below are not met, the reliability of the device may be adversely affected. ? analog input voltage range the voltage applied to analog input pin ann during a/d conversion should be in the range vss ann vref. ? vref input range the analog reference voltage input at the vref pin set is the range vref vcc. 15.8.5 notes on board design careful consideration is required in board design for noise countermeasures and in order to prevent damage due to abnormal voltage, such as an excessive surge at the analog input pins (an0 to an3 or an14 to an15) and analog reference voltage pin (vref). table 15.6 analog pin specifications item min. max. unit analog input capacitance ? 20 pf permissible signal source impedance ? 5 * k note: * vcc = 2.7 to 3.6 v 20 pf ann note: values are reference values. 10 k to a/d converte r figure 15.10 analog input pin equivalent circuit section 15 a/d converter rev.6.00 jun. 03, 2008 page 550 of 698 rej09b0074-0600 section 16 ram rev.6.00 jun. 03, 2008 page 551 of 698 rej09b0074-0600 section 16 ram the h8s/2218 and h8s/2212 have 12 kbytes of on-chip high-speed static ram. the h8s/2217 and h8s/2211 have 8 kbytes of on-chip high-speed static ram. the h8s/2210 and h8s/2210s has 4 kbytes of on-chip high-speed static ram. the ram is connected to the cpu by a 16-bit data bus, enabling one-state access by the cpu to both byte data and word data. this makes it possible to perform fast word data transfer. the on-chip ram can be enabled or disabled by means of the ram enable bit (rame) in the system control register (syscr). for details on syscr, refer to section 3.2.2, system control register (syscr). product class rom type ram size ram address HD64F2218 HD64F2218u flash memory version 12 kbytes h'ffc000 to h'ffefbf h'ffffc0 to h'ffffff h8s/2218 group hd6432217 masked rom version 8 kbytes h'ffd000 to h'ffefbf h'ffffc0 to h'ffffff h8s/2212 group hdf64f2212 hdf64f2212u flash memory version 12 kbytes h'ffc000 to h'ffefbf h'ffffc0 to h'ffffff hd64f2211 hd64f2211u 8 kbytes h'ffd000 to h'ffefbf h'ffffc0 to h'ffffff hd6432211 masked rom version 8 kbytes h'ffd000 to h'ffefbf h'ffffc0 to h'ffffff hd6432210 hd6432210s 4 kbytes h'ffe000 to h'ffefbf h'ffffc0 to h'ffffff section 16 ram rev.6.00 jun. 03, 2008 page 552 of 698 rej09b0074-0600 section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 553 of 698 rej09b0074-0600 section 17 flash memory (f-ztat version) the features of the on-chip flash memory are summarized below. the block diagram of the flash memory is shown in figure 17.1. 17.1 features ? size: product class rom size rom address h8s/2218 group HD64F2218, HD64F2218u 128 kbytes h'000000 to h'01ffff (modes 6 and 7) h8s/2212 group hd64f2212, hd64f2212u h'000000 to h'01ffff (mode 7) hd64f2211, hd64f2211u 64 kbytes h'000000 to h'00ffff (mode 7) ? programming/erase methods ? the flash memory is programmed 128 bytes at a time. erase is performed in single-block units. the flash memory is configured as follows: 32 kbytes 2 blocks, 28 kbytes 1 block, 16 kbytes 8 blocks, 8 kbytes 1 block, and 1 kbyte 4 blocks. to erase the entire flash memory, each block must be erased in turn. ? reprogramming capability ? flash memory can be reprogrammed a minimum of 100 times. ? two flash memory operating modes ? boot mode sci boot mode: HD64F2218, hd64f2212, and hd64f2211 usb boot mode: HD64F2218u, hd64f2212u, and hd64f2211u ? user program mode on-board programming/erasing can be done in boot mode in which the boot program built into the chip is started for erase or programming of the entire flash memory. in normal user program mode, individual blocks can be erased or programmed. ? automatic bit rate adjustment ? with data transfer in sci boot mode, this lsi's bit rate can be automatically adjusted to match the transfer bit rate of the host. ? programming/erasing protection ? sets hardware protection, software protection, and error protection against flash memory programming/erasing. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 554 of 698 rej09b0074-0600 ? programmer mode ? flash memory can be programmed/erased in programmer mode, using a prom programmer, as well as in on-board programming mode. ? flash memory emulation in ram ? flash memory programming can be emulated in real time by overlapping a part of ram onto flash memory. module bus bus interface/controller flash memory * (128 kbytes) operating mode flmcr2 internal data bus (upper 8 bits) internal data bus (lower 8 bits) fwe pin mode pins (md2 to md0) pf3, pf0, p16, p1 4 ebr1 ebr2 ramer flmcr1 flash memory control register 1 flash memory control register 2 erase block register 1 erase block register 2 ram emulation register legend: flmcr1: flmcr2: ebr1: ebr2: ramer: note: * 128 kbytes in the HD64F2218, HD64F2218u, hd64f2212, and hd64f2212u; 64 kbytes in the hd64f2211 and hd64f2211u. h'000000 h'000002 h'000001 h'000003 h'01fffe h'01ffff figure 17.1 block diagram of flash memory 17.2 mode transitions when the mode pins and the fwe pin are set in the reset state and a reset-start is executed, this lsi enters an operating mode as shown in figure 17.2. in user mode, flash memory can be read but not programmed or erased. the boot and user program modes are provided as modes to write and erase the flash memory. the differences between boot mode and user program mode are shown in table 17.1. boot mode and user program mode operations are shown in figures 17.3 and 17.4, respectively. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 555 of 698 rej09b0074-0600 sci, usb boot mode on-board programming mode user program mode user mode (on-chip rom enabled) reset state programmer mode res = 0 fwe = 1 fwe = 0 * 1 * 1 * 2 notes: only make a transition between user mode and user program mode when the cpu is not accessing the flash memory. 1. ram emulation possible 2. md2 to md0 = 000, pf3, pf0, p16, p14 = 1100 res = 0 md2 to 0 = 01x, fwe = 1 res = 0 res = 0 md2 to 0 = 11x, fwe = 0 md2 to 0 = 11x, fwe = 1 figure 17.2 flash memory state transitions table 17.1 differences between boot mode and user program mode sci, usb boot mode user program mode user mode total erase yes yes no block erase no yes no programming control program * program/program-verify erase/erase-verify program/program-verify emulation ? note: * to be provided by the user, in accordance with the recommended algorithm. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 556 of 698 rej09b0074-0600 flash memory this lsi ram host programming control program application program (old version) new application program flash memory this lsi ram host application program (old version) boot program area new application program flash memory this lsi ram host flash memory preprogramming erase boot program new application program flash memory this lsi program execution stat e ram host new application program boot program programming control program 1. initial state the old program version or data remains written in the flash memory. the user should prepare the programming control program and new application program beforehand in the host. 2. programming control program transfer when boot mode is entered, the boot program in this lsi (originally incorporated in the chip) is started and the programming control program in the host is transferred to ram via sci or usb communication. the boot program required for flash memory erasing is automatically transferred to the ram boot program area. 3. flash memory initialization the erase program in the boot program area (in ram) is executed, and the flash memory is initialized (to h'ff). in boot mode, total flash memory erasure is performed, without regard to blocks. 4. writing new application program the programming control program transferred from the host to ram is executed, and the new application program in the host is written into the flash memory. programming control program boot program boot program boot program area boot program area programming control program sci or usb sci or usb sci or usb sci or usb figure 17.3 boot mode (sample) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 557 of 698 rej09b0074-0600 flash memory this lsi ram host programming/ erase control program boot program new application program flash memory this lsi ram host new application program flash memory this lsi ram host flash memory erase boot program new application program flash memory this lsi program execution stat e ram host boot program boot program fwe assessment program application program (old version) new application program 1. initial state the fwe assessment program that confirms that user program mode has been entered, and the program that will transfer the programming/erase control program from flash memory to on-chip ram should be written into the flash memory by the user beforehand. the programming/erase control program should be prepared in the host or in the flash memory. 2. programming/erase control program transfer when user program mode is entered, user software confirms this fact, executes transfer program in the flash memory, and transfers the programming/erase control program to ram. 3. flash memory initialization the programming/erase program in ram is executed, and the flash memory is initialized (to h'ff). erasing can be performed in block units, but not in byte units. 4. writing new application program next, the new application program in the host is written into the erased flash memory blocks. do not write to unerased blocks. programming/ erase control program programming/ erase control program programming/ erase control program transfer program application program (old version) transfer program fwe assessment program fwe assessment program transfer program fwe assessment program transfer program sci or usb sci or usb sci or usb sci or usb figure 17.4 user program mode (sample) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 558 of 698 rej09b0074-0600 17.3 block configuration figure 17.5 shows the block configuration of 128-kbyte flash memory in the HD64F2218, HD64F2218u, hd64f2212, and hd64f2212u. the thick lines indicate erasing units, the narrow lines indicate programming units, and the values are addresses. the flash memory is divided into one kbyte (four blocks), 28 kbytes (one block), 16 kbytes (one block), eight kbytes (two blocks), and 32 kbytes (two blocks). erasing is performed in these divided units. programming is performed in 128-byte units starting from an address whose lower eight bits are h'00 or h'80. eb0 eb1 eb2 eb3 eb4 eb7 eb8 eb9 eb6 eb5 erase unit 1 kbyte programming unit: 128 bytes erase unit 1 kbyte erase unit 1 kbyte erase unit 1 kbyte erase unit 28 kbytes erase unit 16 kbytes erase unit 8 kbytes erase unit 8 kbytes erase unit 32 kbytes erase unit 32 kbytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes h'000000 h'000001 h'000002 h'00007f h'0003ff h'00047f h'00087f h'000c7f h'00107f h'007fff h'00807f h'00bfff h'0007ff h'000bff h'000fff h'01ffff h'00c07f h'00dfff h'00e07f h'00ffff h'01007f h'017fff h'01807f h'000400 h'000401 h'000402 h'000800 h'000801 h'000802 h'000c00 h'000c01 h'000c02 h'001000 h'001001 h'001002 h'008000 h'008001 h'008002 h'00c000 h'00c001 h'00c002 h'00e000 h'00e001 h'00e002 h'010000 h'010001 h'010002 h'018000 h'018001 h'018002 h'000380 h'000381 h'000382 h'000780 h'000781 h'000782 h'000b80 h'000b81 h'000b82 h'000f80 h'000f81 h'000f82 h'007f80 h'007f81 h'007f82 h'017f80 h'017f81 h'017f82 h'01ff80 h'01ff81 h'01ff82 h'00bf80 h'00bf81 h'00bf82 h'00df80 h'00df81 h'00df82 h'00ff80 h'00ff81 h'00ff82 figure 17.5 flash memory block configuration (HD64F2218, HD64F2218u, hd64f2212, hd64f2212u) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 559 of 698 rej09b0074-0600 figure 17.6 shows the block configuration of 64-kbyte flash memory in the hd64f2211 and hd64f2211u. the thick lines indicate erasing units, the narrow lines indicate programming units, and the values are addresses. the flash memory is divided into one kbyte (four blocks), 28 kbytes (one block), and 16 kbytes (one block), eight kbytes (two blocks). erasing is performed in these divided units. programming is performed in 128-byte units starting from an address whose lower eight bits are h'00 or h'80. eb0 eb1 eb2 eb3 eb4 eb7 eb6 eb5 erase unit 1 kbyte programming unit: 128 bytes erase unit 1 kbyte erase unit 1 kbyte erase unit 1 kbyte erase unit 28 kbytes erase unit 16 kbytes erase unit 8 kbytes erase unit 8 kbytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes programming unit: 128 bytes h'000000 h'000001 h'000002 h'00007f h'0003ff h'00047f h'00087f h'000c7f h'00107f h'007fff h'00807f h'00bfff h'0007ff h'000bff h'000fff h'00c07f h'00dfff h'00e07f h'00ffff h'000400 h'000401 h'000402 h'000800 h'000801 h'000802 h'000c00 h'000c01 h'000c02 h'001000 h'001001 h'001002 h'008000 h'008001 h'008002 h'00c000 h'00c001 h'00c002 h'00e000 h'00e001 h'00e002 h'000380 h'000381 h'000382 h'000780 h'000781 h'000782 h'000b80 h'000b81 h'000b82 h'000f80 h'000f81 h'000f82 h'007f80 h'007f81 h'007f82 h'00bf80 h'00bf81 h'00bf82 h'00df80 h'00df81 h'00df82 h'00ff80 h'00ff81 h'00ff82 figure 17.6 flash memory block configuration (hd64f2211, hd64f2211u) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 560 of 698 rej09b0074-0600 17.4 input/output pins the flash memory is controlled by means of the pins shown in table 17.2. table 17.2 pin configuration pin name i/o function res input reset all fwe input flash program/erase protection by hardware md2, md1, md0 input sets this lsi's operating mode pf3, pf0, p16, p14 input sets this lsi's operating mode in programmer mode emle input emulator enable txd2 output serial transmit data output rxd2 input serial receive data input HD64F2218, hd64f2212, hd64f2211 usd + , usd ? input/output usb data input/output vbus input usb cable connect/cut detect ubpm input usb bus power mode/self power mode select HD64F2218u, hd64f2212u, hd64f2211u uspnd output usb suspend output p36 (pupd+) output d + pull-up control 17.5 register descriptions the flash memory has the following registers. for details on register addresses and register states during each processing, refer to section 21, list of registers. ? flash memory control register 1 (flmcr1) ? flash memory control register 2 (flmcr2) ? erase block register 1 (ebr1) ? erase block register 2 (ebr2) ? ram emulation register (ramer) ? serial control register x ( scrx) the masked rom version is not equipped with the above registers. attempting to read them with produce an undetermined value, and writing to them is invalid. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 561 of 698 rej09b0074-0600 17.5.1 flash memory control register 1 (flmcr1) flmcr1 is a register that makes the flash memory transit to program mode, program-verify mode, erase mode, or erase-verify mode. for details on register setting, refer to section 17.8, flash memory programming/erasing. bit bit name initial value r/w description 7 fwe ? * r flash write enable reflects the input level at the fwe pin. it is set to 1 when a low level is input to the fwe pin, and cleared to 0 when a high level is input. 6 swe1 0 r/w software write enable when this bit is set to 1, flash memory programming/erasing is enabled. when this bit is cleared to 0, other flmcr1 register bits and all ebr1, ebr2 bits cannot be set. [setting condition] when fwe = 1 5 esu1 0 r/w erase setup when this bit is set to 1, the flash memory transits to the erase setup state. when it is cleared to 0, the erase setup state is cancelled. set this bit to 1 before setting the e1 bit in flmcr1. [setting condition] when fwe = 1 and swe1 = 1 4 psu1 0 r/w program setup when this bit is set to 1, the flash memory transits to the program setup state. when it is cleared to 0, the program setup state is cancelled. set this bit to 1 before setting the p1 bit in flmcr1. [setting condition] when fwe = 1 and swe1 = 1 3 ev1 0 r/w erase-verify when this bit is set to 1, the flash memory transits to erase-verify mode. when it is cleared to 0, erase-verify mode is cancelled. [setting condition] when fwe = 1 and swe1 = 1 section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 562 of 698 rej09b0074-0600 bit bit name initial value r/w description 2 pv1 0 r/w program-verify when this bit is set to 1, the flash memory transits to program-verify mode. when it is cleared to 0, program- verify mode is cancelled. [setting condition] when fwe = 1 and swe1 = 1 1 e1 0 r/w erase when this bit is set to 1 while the swe1 and esu1 bits are 1, the flash memory transits to erase mode. when it is cleared to 0, erase mode is cancelled. [setting condition] when fwe = 1, swe1 = 1, and esu1 = 1 0 p1 0 r/w program when this bit is set to 1 while the swe1 and psu1 bits are 1, the flash memory transits to program mode. when it is cleared to 0, program mode is cancelled. [setting condition] when fwe = 1, swe1 = 1, and psu1 = 1 note: * set according to the fwe pin state. 17.5.2 flash memory control register 2 (flmcr2) flmcr2 is a register that displays the state of flash memory programming/erasing. flmcr2 is a read-only register, and should not be written to. bit bit name initial value r/w description 7 fler 0 r indicates that an error has occurred during an operation on flash memory (programming or erasing). when fler is set to 1, flash memory goes to the error- protection state. see section 17.9.3, error protection, for details. 6 to 0 ? all 0 ? reserved these bits are always read as 0. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 563 of 698 rej09b0074-0600 17.5.3 erase block register 1 (ebr1) ebr1 specifies the flash memory erase area block. ebr1 is initialized to h'00 when the swe1 bit in flmcr is 0. do not set more than one bit at a time, as this will cause all the bits in ebr1 and ebr2 to be automatically cleared to 0. bit bit name initial value r/w description 7 eb7 0 r/w when this bit is set to 1, 8 kbytes of eb7 (h'00e000 to h'00ffff) are to be erased. 6 eb6 0 r/w when this bit is set to 1, 8 kbytes of eb6 (h'00c000 to h'00dfff) are to be erased. 5 eb5 0 r/w when this bit is set to 1, 16 kbytes of eb5 (h'008000 to h'00bfff) are to be erased. 4 eb4 0 r/w when this bit is set to 1, 28 kbytes of eb4 (h'001000 to h'007fff) are to be erased. 3 eb3 0 r/w when this bit is set to 1, 1 kbyte of eb3 (h'000c00 to h'000fff) is to be erased. 2 eb2 0 r/w when this bit is set to 1, 1 kbyte of eb2 (h'000800 to h'000bff) is to be erased. 1 eb1 0 r/w when this bit is set to 1, 1 kbyte of eb1 (h'000400 to h'0007ff) is to be erased. 0 eb0 0 r/w when this bit is set to 4, 1 kbyte of eb0 (h'000000 to h'0003ff) is to be erased. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 564 of 698 rej09b0074-0600 17.5.4 erase block register 2 (ebr2) ebr2 specifies the flash memory erase area block. ebr2 is initialized to h'00 when the swe1 bit in flmcr1 is 0. do not set more than one bit at a time, as this will cause all the bits in ebr1 and ebr2 to be automatically cleared to 0. note: these registers are reserved on the hd64f2211 and hd64f2211u. only h'00 should be written to them. bit bit name initial value r/w description 7 to 2 ? all 0 r/w reserved the write value should always be 0. 1 eb9 0 r/w when this bit is set to 1, 32 kbytes of eb9 (h'018000 to h'01ffff) are to be erased. 0 eb8 0 r/w when this bit is set to 1, 32 kbytes of eb8 (h'010000 to h'017fff) are to be erased. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 565 of 698 rej09b0074-0600 17.5.5 ram emulation register (ramer) ramer specifies the area of flash memory to be overlapped with part of ram when emulating real-time flash memory programming. ramer settings should be made in user mode or user program mode. to ensure correct operation of the emulation function, the rom for which ram emulation is performed should not be accessed immediately after this register has been modified. normal execution of an access immediately after register modification is not guaranteed. for details, refer to section 17.7, flash memory emulation in ram. bit bit name initial value r/w description 7 to 4 ? all 0 r/w reserved these bits always read as 0. the write value should always be 0. 3 rams 0 r/w ram select specifies selection or non-selection of flash memory emulation in ram. when rams = 1, the flash memory is overlapped with part of ram, and all flash memory block are program/erase-protected. 2 1 0 ram2 ram1 ram0 0 0 0 r/w r/w r/w flash memory area selection when the rams bit is set to 1, selects one of the following flash memory areas to overlap the ram area. the areas correspond with 1-kbyte erase blocks. 000: h'000000 to h'0003ff (eb0) 001: h'000400 to h'0007ff (eb1) 010: h'000800 to h'000bff (eb2) 011: h'000c00 to h'000fff (eb3) 100: setting prohibited 101: setting prohibited 110: setting prohibited 111: setting prohibited section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 566 of 698 rej09b0074-0600 17.5.6 serial control register x (scrx) scrx performs register access control. bit bit name initial value r/w description 7 to 4 ? all 0 r/w reserved the write value should always be 0. 3 flshe 0 r/w flash memory control register enable: controls cpu access to the flash memory control registers (flmcr1, flmcr2, ebr1, and ebr2). setting the flshe bit to 1 enables read/write access to the flash memory control registers. if flshe is cleared to 0, the flash memory control registers are deselected. in this case, the flash memory control register contents are retained. 0: flash control registers deselected in area h'ffffa8 to h'ffffac 1: flash control registers selected in area h'ffffa8 to h'ffffac 2 to 0 ? all 0 r/w reserved the write value should always be 0. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 567 of 698 rej09b0074-0600 17.6 on-board programming modes when pins are set to on-board programming mode and a reset-start is executed, a transition is made to the on-board programming state in which program/erase/verify operations can be performed on the on-chip flash memory. there are two on-board programming modes: boot mode and user program mode. the pin settings for transition to each of these modes are shown in table 17.3. for a diagram of the transitions to the various flash memory modes, see figure 17.2. table 17.3 setting on-board programming modes mode emle fwe md2 md1 md0 sci boot mode (HD64F2218, hd64f2212, hd64f2211) advanced: single-chip mode 0 1 0 1 advanced: single-chip mode 24 mhz system clock 0 1 0 1 0 usb boot mode (HD64F2218u, hd64f2212u, hd64f2211u) advanced: single-chip mode 16 mhz system clock 0 1 0 1 1 user program mode advanced: on-chip rom extended mode (mcu operating mode 6) 0 1 1 1 0 advanced: single-chip mode (mcu operating mode 7) 0 1 1 1 1 17.6.1 sci boot mode (HD64F2218, hd64f2212, and hd64f2211) when a reset-start is executed after the lsi's pins have been set to boot mode, the boot program built into the lsi is started and the programming control program prepared in the host is serially transmitted to the lsi via the sci. in the lsi, the programming control program received via the sci is written into the programming control program area in on-chip ram. after the transfer is completed, control branches to the start address of the programming control program area and the programming control program execution state is entered (flash memory programming is performed). the system configuration in boot mode is shown in figure 17.7. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 568 of 698 rej09b0074-0600 rxd2 txd2 sci_2 this lsi flash memory write data reception 1 01 note: * mode pin and fwe pin input must satisfy the mode programming setup time (t mds = 200ns) with respect to the reset release timing. legend: : don ? t care fwe md2 to md0 * verify data transmission host on-chip ram 0emle figure 17.7 system configuration in sci boot mode table 17.4 shows the boot mode operations between reset end and branching to the programming control program. 1. when boot mode is used, the flash memory programming control program must be prepared in the host beforehand. prepare a programming control program in accordance with the description in section 17.8, flash memory programming/erasing. in boot mode, if any data has been programmed into the flash memory (if all data is not 1), all flash memory blocks are erased. boot mode is for use in enforced exit when user program mode is unavailable, such as the first time on-board programming is performed, or if the program activated in user program mode is accidentally erased. 2. the sci_2 should be set to asynchronous mode, and the transfer format as follows: 8-bit data, 1 stop bit, and no parity. 3. when the boot program is initiated, the chip measures the low-level period of asynchronous sci communication data (h'00) transmitted continuously from the host. the chip then calculates the bit rate of transmission from the host, and adjusts the sci_2 bit rate to match that of the host. the reset should end with the rxd pin high. the rxd and txd pins should be pulled up on the board if necessary. after the reset ends, it takes approximately 100 states before the chip is ready to measure the low-level period. 4. after matching the bit rates, the chip transmits one h'00 byte to the host to indicate the end of bit rate adjustment. the host should confirm that this adjustment end indication (h'00) has been received normally, and transmit one h'55 by te to the chip. if reception could not be performed normally, initiate boot mode again by a reset. depending on the host?s transfer bit rate and system clock frequency of this lsi, there will be a discrepancy between the bit rates of the host and the chip. to operate the sci properly, set the host?s transfer bit rate and system clock frequency of this lsi within the ranges listed in table 17.5. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 569 of 698 rej09b0074-0600 5. in boot mode, a part of the on-chip ram area (four kbytes) is used by the boot program. the area to which the programming control program is transferred from the host is 8 kbytes (h'ffc000 to h'ffdfff) in the HD64F2218, HD64F2218u, hd64f2212, and hd64f2212u and 4 kbytes (h'ffd000 to h'ffdfff) in the hd64f2211 and hd64f2211u. the boot program area cannot be used until the execution state in boot mode switches to the programming control program. 6. before branching to the programming control program, the chip terminates transfer operations by the sci_2 (by clearing the re and te bits in scr to 0), but the adjusted bit rate value remains set in brr. therefore, the programming control program can still use it for transfer of write data or verify data with the host. the txd pin is high. the contents of the cpu general registers are undefined immediately after branching to the programming control program. these registers must be initialized at the beginning of the programming control program, since the stack pointer (sp), in particular, is used implicitly in subroutine calls, etc. 7. boot mode can be cleared by a reset. end the reset* after driving the reset pin low, waiting at least 20 states, and then setting the fwe pin and the mode (md) pins. boot mode is also cleared when a wdt overflow occurs. 8. do not change the md pin input levels in boot mode. if the mode pin input levels are changed (for example, from low to high) during a reset, the state of ports with multiplexed address functions and bus control output pins ( as , rd , wr ) will change according to the change in the microcomputer?s operating mode . therefore, care must be taken to make pin settings to prevent these pins from becoming output signal pins during a reset, or to prevent collision with signals outside the microcomputer. 9. all interrupts are disabled during programming or erasing of the flash memory. note:* mode pin and fwe pin input must satisfy the mode programming setup time (t mds = 200 ns) with respect to the reset release timing. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 570 of 698 rej09b0074-0600 table 17.4 boot mode operation item host operation lsi operation branches to boot program at reset- start continuously transmits data h'00 at specified bit rate measures low-level period of receive data h'00 calculates bit rate and sets it in brr of sci_2 bit rate adjustment transmits data h'55 when data h'00 is received error-free transmits data h'00 to host as adjustment end indication transmits data h'aa to host when data h'55 is received transmits number of bytes (n) of programming control program transmits number of bytes (n) of programming control program to be transferred as 2-byte data (low- order byte following high-order byte) echobacks the 2-byte data received as verification data transmits 1-byte of programming control program (repeated for n times) transmits 1-byte of programming control program echobacks received data to host and also transfers it to ram flash memory erase checks flash memory data, erases all flash memory blocks in case of written data existing, and transmits data h'aa to host. (if erase could not be done, transmits data h'ff to host and aborts operation) programming control program execution branches to programming control program transferred to on-chip ram and starts execution table 17.5 system clock frequencies for which automatic adjustment of lsi bit rate is possible host bit rate system clock frequency range of lsi 19,200 bps 8 to 24 mhz 9,600 bps 6 to 24 mhz 4,800 bps 6 to 24 mhz section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 571 of 698 rej09b0074-0600 17.6.2 usb boot mode (HD64F2218u, hd64f2212u, and hd64f2211u) ? features ? selection of bus-powered mode or self-powered mode ? supports the usb operating clock generation by 16 mhz system clock with pll3 multiplication (fwe = 1, md2 to md0 = 011) or 24 mhz system clock with pll2 multiplication (fwe = 1, md2 to md0 = 010) ? d+ pull up control connection supported for p36 pin only ? see table 17.6 for enumeration information table 17.6 enumeration information usb standard ver.1.1 transfer modes control (in, out), bulk (in, out) maximum power self power mode ( ubpm pin = 1) 100 ma bus power mode ( ubpm pin = 0) 500 ma endpoint configuration ep0 control (in, out) 64 byte s configuration 1 interface number 0 alte rn ate setting 0 ep1 bulk (in) 64 bytes ep2 bulk (out) 64 bytes ? notes on usb boot mode execution ? specify 16 mhz or 24 mhz system clock and the fwe and md2 to md0 pins correctly. ? use the p36 pin for d+ pull-up control connection. ? to ensure stable power supply during flash memory programming/erasing, do not use cable connection via a bus powered hub. ? note in particular that, in the worst case, the lsi may be permanently damaged if the usb cable is detached during flash memory programming/erasing. ? a transition is not made to power-down modes even if the usb bus enters suspend mode when in bus power mode. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 572 of 698 rej09b0074-0600 ? overview when a reset start preformed after the pins of this lsi have been set to boot mode, a boot program incorporated in the microcomputer beforehand is activated, and the prepared programming control program is transmitted sequentially to the host using the usb. with this lsi, the programming control program received by the usb is written to a programming control program area in on-chip ram. after transfer is completed, control branches to the start address of the programming control program area, and the programming control program execution state is established (flash memory programming is performed). figure 17.8 shows a system configuration diagram when using usb boot mode. note: * fwe pin and mode pin input must satisfy the mode programming setup time (t mds = 200ns) when a reset is released. legend: : don?t care ubpm vbus 1: self power setting 0: bus power setting data transmission/reception this lsi flash memory p36 1.5k rs rs host or self-powerd hub on-chip ram system clock: 16 mhz or 24mhz fwe * md2 to md0 * emle 1 01 extal xtal d+ d- usd+ usd- usb 0 figure 17.8 system configuration diagram when using usb boot mode table 17.7 shows operations from reset release in usb boot mode until processing branches to the programming control program. 1. when boot mode is used, the flash memory programming control program must be prepared in the host beforehand. prepare a programming control program in accordance with the description in section 17.8, flash memory programming/erasing. in boot mode, if any data has been programmed into the flash memory (if all data is not 1), all flash memory blocks are erased. boot mode is for use in enforced exit when user program mode is unavailable, such a the first time on-board programming control program, or performed, or if the program activated in user program mode is accidentally erased. 2. when the boot program is activated, enumeration with respect to the host is carried out. enumeration information is shown in table 17.6. when enumeration is completed, transmit a single h'55 byte from the host. if reception has not been preformed normally, restart boot mode by means of a reset. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 573 of 698 rej09b0074-0600 3. set the frequency for transmission from the host as a numeric value in units of mhz 100 (ex: 16.00 mhz h'0640, 24.00 mhz h'0960). 4. in boot mode, the 4-kbyte on-chip ram area h'ffe000 to h'ffefbf is used by the boot program. the programming control program is transferred from the host stored in the 8-kbyte area h'ffc000 to h'ffdfff in the HD64F2218, HD64F2218u, hd64f2212, and hd64f2212u and the 4-kbyte area h'ffd000 to h'ffdfff in the hd64f2211 and hd64f2211u. the boot program area cannot be used until program execution switches to the programming control program. also note that the boot program remains in ram even after control passes to the programming control program. 5. when a branch is made to the programming control program, the usb remains connected and can be used immediately for transmission/receptio n of write data or verify data between the programming control program and the host. the contents of cpu general registers are undefined after a branch to the programming contro l program. note, in particular, that since the stack pointer is used implicitly in subroutine calls ad the like, it should be initialized at the start of the programming control program. 6. boot mode is by means of a reset. drive the reset pin low, wait for the elapse of at least 20 states, then set the fwe pin and mode pins to release the reset.* boot mode is also exited in the event of a wdt overflow reset. 7. do not change the input level of the mode pins while in boot mode. in the input level of a mode pin is changed (from low to high) during a reset, the states of ports with a dual function as address output s, and bus control output signals ( as , rd , wr ), will change due to switching of the operating mode. either make pin settings so that these pins do not become output signal pins during a reset, or take precautions to prevent collisions with external signals. 8. interrupt cannot be used during flash memory programming or erasing. note: * fwe pin and mode pin input must satisfy the mode programming set up time (t mds = 200 ns) when a reset is released. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 574 of 698 rej09b0074-0600 table 17.7 usb boot mode operation item host operation operation of this lsi branches to boot program after reset start start of usb boot mode transmits one h'55 byte on completion of usb enumeration transmits one h'aa byte to host on reception of h'55 transfer clock information transmits frequency (2 bytes), number of multiplication classification (1 byte), multiplication ratio (1 byte) with 16 mhz system clock, h'0640, h'01, h'01 are transmitted with 24 mhz system clock, h'0960, h'01, h'01 are transmitted if received data are within respective ranges, transmits h'aa to host if any received data is out-of- ranges, transmits h'ff to host and halts operation transfer number of bytes (n) of programming control program performs 2-byte transfer number of bytes (n) of programming control program if received number of bytes is within ranges, transmits h'aa to host if received number of bytes is out-of- ranges, transmits h'ff to host and halts operation section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 575 of 698 rej09b0074-0600 item host operation operation of this lsi transfer of programming control program and sum value transmits programming control program in n-byte divisions. transfers received data to on- chip ram transmits sum value (two's complement of sum total of programming control program (1 byte)) calculates sum total of received sum value and 1 byte units of programming control program transferred to on-chip ram if sum is 0, transmits h'aa to host if sum is not 0, transmits h'ff to host halts operation memory erase starts total erase of flash memory transmits total erase status command (h'3a) transmits h'11 to host if total erase processing is being executed when total erase status command is received transmits h'06 to host if total erase of all blocks has been completed when total erase status command is received retransmits total erase status command (h'3a) when h'11 is received if erase cannot be performed when total erase status command is received, transmits h'ee to host and halts operation execution of programming control program branches to programming control program transferred to on-chip ram and starts execution. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 576 of 698 rej09b0074-0600 17.6.3 programming/erasing in user program mode on-board programming/erasing of an individual flash memory block can also be performed in user program mode by branching to a user program/erase control program. the user must set branching conditions and provide on-board fwe control and supply of programming data, and storing a program/erase control program in part of the program area as necessary. the flash memory must contain the user program/erase control program or a program which provides the user program/erase control program from external memory. because the flash memory itself cannot be read during programming/erasing, transfer the user program/erase control program to on-chip ram, as like in boot mode. figure 17.9 shows a sample procedure for programming/erasing in user program mode. prepare a user program/erase control program in accordance with the description in section 17.8, flash memory programming/erasing. yes no program/erase? transfer user program /erase control program to ram branch to user program/erase control in ram execute user program/erase control pogram (flash memory rewrite) branch to flash memory application program branch to flash memory application program md2 to md0 = 110,111 reset start figure 17.9 programming/erasing flowchart example in user program mode section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 577 of 698 rej09b0074-0600 17.7 flash memory emulation in ram making a setting in the ram emulation register (ramer) enables part of ram to be overlapped onto the flash memory area so that data to be written to flash memory can be emulated in ram in real time. emulation can be performed in user mode or user program mode. figure 17.10 shows an example of emulation of real-time flash memory programming. 1. set ramer to overlap part of ram onto the area for which real-time programming is required. 2. emulation is performed using the overlapping ram. 3. after the program data has been confirmed, the rams bit is cleared, thus releasing ram overlap. 4. the data written in the overlapping ram is written into the flash memory space (eb0). start of emulation program set ramer write tuning data to overlap ram execute application program tuning ok? clear ramer write to flash memory emulation block end of emulation program no yes figure 17.10 flowchart for flash memory emulation in ram section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 578 of 698 rej09b0074-0600 an example in which flash memory block area eb0 is overlapped is shown in figure 17.11. 1. the ram area to be overlapped is fixed at a 1-kbyte area in the range of h'ffd000 to h'ffd3ff. 2. the flash memory area to overlap is selected by ramer from a 1-kbyte area among one of the eb0 to eb3 blocks. 3. the overlapped ram area can be accessed from both the flash memory addresses and ram addresses. 4. when the rams bit in ramer is set to 1, program/erase protection is enabled for all flash memory blocks (emulation protection). in this state, setting the p1 or e1 bit in flmcr1 to 1 does not cause a transition to program mode or erase mode. 5. a ram area cannot be erased by execution of so ftware in accordance with the erase algorithm. 6. block area eb0 contains the vector table. when performing ram emulation, the vector table is needed in the overlap ram. (eb0) (eb2) (eb1) (eb0) (eb2) flash memory flash memory on-chip ram (1-kbyte shadow) on-chip ram (4 kbytes) on-chip ram (1 kbyte) on-chip ram (7 kbytes - 64 bytes) on-chip ram (64 bytes) on-chip ram (4 kbytes) on-chip ram (1 kbyte) on-chip ram (7 kbytes - 64 bytes) on-chip ram (64 bytes) flash memory normal memory map ram overlap memory map h'000000 h'000400 h'000800 h'000c00 h'ffd000 h'ffffff h'ffffc0 h'ffd400 h'ffefbf h'ffd3ff h'ffc000 figure 17.11 example of ram overlap operation section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 579 of 698 rej09b0074-0600 17.8 flash memory programming/erasing a software method, using the cpu, is employed to program and erase flash memory in the on- board programming modes. depending on the flmcr1 setting, the flash memory operates in one of the following four modes: program mode, erase mode, program-verify mode, and erase-verify mode. the programming control program in boot mode and the user program/erase control program in user program mode use these operating modes in combination to perform programming/erasing. flash memory programming and erasing should be performed in accordance with the descriptions in section 17.8.1, program/program-verify and section 17.8.2, erase/erase-verify, respectively. 17.8.1 program/program-verify when writing data or programs to the flash memory, the program/program-verify flowchart shown in figure 17.12 should be followed. performing programming operations according to this flowchart will enable data or programs to be written to the flash memory without subjecting the chip to voltage stress or sacrificing program data reliability. 1. programming must be done to an empty address. do not reprogram an address to which programming has already been performed. 2. programming should be carried out 128 bytes at a time. a 128-byte data transfer must be performed even if writing fewer than 128 bytes. in this case, h'ff data must be written to the extra addresses. 3. prepare the following data storage areas in ram: a 128-byte programming data area, a 128- byte reprogramming data area, and a 128-byte additional-programming data area. perform reprogramming data computation and additional programming data computation according to figure 17.12. 4. consecutively transfer 128 bytes of data in byte units from the reprogramming data area or additional-programming data area to the flash memory. the program address and 128-byte data are latched in the flash memory. the lower 8 bits of the start address in the flash memory destination area must be h'00 or h'80. 5. the time during which the p1 bit is set to 1 is the programming time. figure 17.12 shows the allowable programming times. 6. the watchdog timer (wdt) is set to prevent overprogramming due to program runaway, etc. an overflow cycle of approximately (y + z1 + + ) s is allowed. 7. for a dummy write to a verify address, write 1-byte data h'ff to an address whose lower 1 bit is b'0. verify data can be read in words from the address to which a dummy write was performed. 8. the maximum number of repetitions of the program/program-verify sequence to the same bit is (n1 + n2). section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 580 of 698 rej09b0074-0600 write pulse application subroutine subroutine write pulse end sub set psu1 bit in flmcr1 wdt enable disable wdt note: 7. write pulse width wait (y) s set p1 bit in flmcr1 wait (z0), (z1), or (z2) s clear p1 bit in flmcr1 wait ( ) s clear psu1 bit in flmcr1 wait ( ) s * 5 * 6 * 6 * 6 * 6 * 6 * 6 * 6 * 6 * 6 * 6 * 6 * 6 original data (d) verify data (v) reprogram data (x) comments programming completed still in erased state; no action programming incomplete; reprogram ram program data storage area (128 bytes) reprogram data storage area (128 bytes) additional-programming data storage area (128 bytes) reprogram data computation table reprogram data (x') verify data (v) additional- programming data (y) 1 1 1 1 0 1 0 0 0 0 1 1 comments additional programming to be executed additional programming not to be executed additional programming not to be executed additional programming not to be executed 0 1 1 1 0 1 0 1 0 0 1 1 additional-programming data computation table notes: 1. data transfer is performed by byte transfer. the lower 8 bits of the first address written to must be h'00 or h'80. a 128-byte data transfer must be performed even if writing fewer than 128 bytes; in this case, h'ff data must be written to t he extra addresses. 2. verify data is read in 16-bit (word) units. 3. reprogram data is determined by the operation shown in the table below (comparison between the data stored in the program d ata area and the verify data). bits for which the reprogram data is 0 are programmed in the next reprogramming loop. therefore, even bits for which programming has bee n completed will be subjected to programming once again if the result of the subsequent verify operation is ng. 4. a 128-byte area for storing program data, a 128-byte area for storing reprogram data, and a 128-byte area for storing addit ional data must be provided in ram. the contents of the reprogram data area and additional data area are modified as programming proceeds. 5. a write pulse of z0 or z1 is applied according to the progress of the programming operation. see note 7 for details of the pulse widths. when writing of additional- programming data is executed, a z2 write pulse should be applied. reprogram data x' means reprogram data when the write pulse i s applied. 6. x, y, z0, z1, z2, , , , , , , n1, and n2 are shown in section 22.7, flash memory characteristics. start end of programming set swe1 bit in flmcr1 start of programming wait (x) s n = 1 m = 0 no no no yes yes yes wait ( ) s wait ( ) s * 2 * 4 * 1 wait ( ) s apply write pulse z0 s or z1 s sub-routine-call set pv1 bit in flmcr1 h'ff dummy write to verify address read verify data write data = verify data? * 4 * 3 * 1 transfer reprogram data to reprogram data area reprogram data computation * 4 transfer additional-programming data to additional-programming data area additional-programming data computation clear pv1 bit in flmcr1 clear swe1 bit in flmcr1 m = 1 reprogram see note 7 for pulse width m = 0 ? increment address programming failure yes clear swe1 bit in flmcr1 wait ( ) s no no yes n1 n? no yes n1 n ? wait ( ) s n (n1 + n2)? n n + 1 write 128-byte data in ram reprogram data area consecutively to flash memory store 128-byte program data in program data area and reprogram data area apply write pulse (additional programming) z2 s sub-routine-call 128-byte data verification completed? successively write 128-byte data from additional- programming data area in ram to flash memory perform programming in the erased state. do not perform additional programming on previously programmed addresses. p1 bit set time (s) * 6 1z2 2 n1-1 n1 n1+1 n1+2 n1+3 n1+n2-1 n1+n2-2 n1+n2 z2 z2 z2 _ _ _ _ _ _ z0 z0 z0 z0 z1 z1 z1 z1 z1 z1 number of writes n program re -program figure 17.12 program/pr ogram-verify flowchart section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 581 of 698 rej09b0074-0600 17.8.2 erase/erase-verify when erasing flash memory, the erase/erase-verify flowchart shown in figure 17.13 should be followed. 1. prewriting (setting erase block data to all 0s) is not necessary. 2. erasing is performed in block units. make only a single-bit specification in the erase block register 1, 2 (ebr1, ebr2). to erase multiple blocks, each block must be erased in turn. 3. the time during which the e1 bit is set to 1 is the flash memory erase time. 4. the watchdog timer (wdt) is set to prevent overprogramming due to program runaway, etc. an overflow cycle of approximately (y+z+ + ) ms is allowed. 5. for a dummy write to a verify address, write 1-byte data h'ff to an address whose lower 1 bit is b'0. verify data can be read in longwords from the address to which a dummy write was performed. 6. if the read data is unerased, set erase mode again, and repeat the erase/erase-verify sequence as before. the maximum number of repetitions of the erase/erase-verify sequence is n. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 582 of 698 rej09b0074-0600 start set ebr1 (2) enable wdt disable wdt read verify data increment address verify data = all 1s? last address of block? all erase block erased? set block start address as verify address h'ff dummy write to verify address set swe1 bit in flmcr1 n = 1 set esu1 bit in flmcr1 set e1 bit in flmcr1 start erasing halt erasing wait (x) s wait (y) s clear e1 bit in flmcr1 set ev1 bit in flmcr1 wait (z) s clear esu1 bit in flmcr1 wait ( ) s wait ( ) s wait ( ) s clear ev1 bit in flmcr1 n n + 1 wait ( ) s clear swe1 bit in flmcr1 wait ( ) s clear ev1 bit in flmcr1 n (n)? wait ( ) s clear swe1 bit in flmcr1 wait ( ) s erase failure end of erasing wait ( ) s no yes yes no no no yes yes * 1 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 5 * 2 * 3 * 4 notes: 1. 2. 3. 4. 5. pre-write (clearing data in the block to be erased to 0) isn not required. x, y, z, , , , , , , and n are shown in section 22.7, flash memory characteristics. veryfy data is read in 16 bits. only 1 bit in the ebr register must be set. two or more bits in ebr cannot be set. erasure is performed in block units. to erase multiple blocks, each block must be erased sequentially. figure 17.13 erase/erase-verify flowchart section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 583 of 698 rej09b0074-0600 17.9 program/erase protection there are three kinds of flash memory program/erase protection: hardware protection, software protection, and error protection. 17.9.1 hardware protection hardware protection refers to a state in which programming/erasing of flash memory is forcibly disabled or aborted because of a transition to reset or standby mode. flash memory control register 1 (flmcr1), flash memory control regist er 2 (flmcr2), erase block register 1 (ebr1), and erase block register 2 (ebr2) are initialized. in a reset via the res pin, the reset state is not entered unless the res pin is held low until oscillation stabilizes after powering on. in the case of a reset during operation, hold the res pin low for the res pulse width specified in the ac characteristics section. 17.9.2 software protection software protection can be implemented against programming/erasing of all flash memory blocks by clearing the swe1 bit in flmcr1. when softwa re protection is in effect, setting the p1 or e1 bit in flmcr1 does not cause a transition to program mode or erase mode. by setting the erase block register 1 (ebr1), and erase block register 2 (ebr2), erase protection can be set for individual blocks. when ebr1 and ebr2 are set to h'00, erase protection is set for all blocks. 17.9.3 error protection in error protection, an error is detected when the cpu's runaway occurs during flash memory programming/erasing, or operation is not performed in accordance with the program/erase algorithm, and the program/erase operation is aborted. aborting the program/erase operation prevents damage to the flash memory due to overprogramming or overerasing. when the following errors are detected during programming/erasing of flash memory, the fler bit in flmcr2 is set to 1, and the error protection state is entered. setting conditions of fler bit (erase protection) ? when the flash memory of the relevant address area is read during programming/erasing (including vector read and instruction fetch) ? immediately after exception handling (excluding a reset) during programming/erasing ? when a sleep instruction is executed during programming/erasing ? when the cpu releases the bus mastership to the dmac during programming/erasing section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 584 of 698 rej09b0074-0600 the flmcr1, flmcr2, ebr1 and ebr2 settings are retained, but program mode or erase mode is aborted at the point at which the error occurred. program mode or erase mode cannot be re- entered by re-setting the p1 or e1 bit. however, pv1 and ev1 bit setting is enabled, and a transition can be made to verify mode. 17.10 interrupt handling when programming/erasing flash memory all interrupts, including nmi interrupt is disabled when flash memory is being programmed or erased (when the p1 or e1 bit is set in flmcr1), and while the boot program is executing in boot mode* 1 , to give priority to the program or eras e operation. there are three reasons for this: 1. interrupt during programming or erasing might cause a violation of the programming or erasing algorithm, with the result that normal operation could not be assured. 2. in the interrupt exception handling sequence during programming or erasing, the vector would not be read correctly* 2 , possibly resulting in cpu runaway. 3. if interrupt occurred during boot program execution, it would not be possible to execute the normal boot mode sequence. notes: 1. interrupt requests must be disabled inside and outside the cpu until the programming control program has completed programming. 2. the vector may not be read correctly in this case for the following two reasons: ? if flash memory is read while being programmed or erased (while the p1 or e1 bit is set in flmcr1), correct read data will not be obtained (undetermined values will be returned). ? if the interrupt entry in the vector table has not been programmed yet, interrupt exception handling will not be executed correctly. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 585 of 698 rej09b0074-0600 17.11 programmer mode in programmer mode, a prom programmer can perform programming/erasing via a socket adapter, just like for a discrete flash memory. use a prom programmer that supports the renesas technology 128-kbyte or 64-kbyte flash memory on-chip mcu device type. memory map in programmer mode is shown in figure 17.14. mcu mode on-chip rom space 128 kbytes programmer mode h'000000 h'00000 h'01ffff h'1ffff mcu mode on-chip rom space 64 kbytes programmer mode h'000000 h'0000 h'00ffff h'ffff figure 17.14 memory map in programmer mode section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 586 of 698 rej09b0074-0600 17.12 power-down states for flash memory in user mode, the flash memory will operate in either of the following states: ? normal operating mode the flash memory can be read and written to. ? standby mode all flash memory circuits are halted. ? power-down state the flash memory can be read when part of the power supply circuit is halted and the lsi operates by subclocks. table 17.8 shows the correspondence between the operating modes of this lsi and the flash memory. when the flash memory returns to normal operation from a power-down state, a power supply circuit stabilization period is needed. when the flash memory returns to its normal operating state from watch mode or standby mode, bits sts2 to sts0 in sbycr must be set to provide a wait time of at least 100 s; when returns from flash memory module stop mode, the software wait state should be set. table 17.8 flash memory operating states lsi operating state flash memory operating state active mode normal operating mode sleep mode watch mode standby mode flash memory module stop mode standby mode (before entering to the normal operation mode, wait time of at least 100 s is required.) subactive mode subsleep mode power-down mode (read only) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 587 of 698 rej09b0074-0600 17.13 flash memory programming and erasing precautions precautions concerning the use of on-board programming mode, the ram emulation function, and prom mode are summarized below. ? use the specified voltages and timing for programming and erasing. applied voltages in excess of the rating can permanently damage the device. use a prom programmer that supports the renesas technology microcomputer device type with on-chip flash memory (fztat128v3a, fztat64v3a). do not select the hn27c4096 setting for the prom programmer, and only use the specified socket adapter. failure to observe these points may result in damage to the device. ? powering on and off do not apply a high level to the fwe pin until vcc has stabilized. also, drive the fwe pin low before turning off vcc. when applying or disconnecting vcc power, fix the fwe pin low and place the flash memory in the hardware protection state. the power-on and power-off timing requirements should also be satisfied in the event of a power failure and subsequent recovery. ? fwe application/disconnection fwe application should be carried out when mcu operation is in a stable condition. if mcu operation is not stable, fix the fwe pin low and set the protection state. the following points must be observed concerning fwe application and disconnection to prevent unintentional programming or erasing of flash memory: ? apply fwe when the vcc voltage has stabilized within its rated voltage range. ? in boot mode, apply and disconnect fwe during a reset. ? in user program mode, fwe can be switched between high and low level regardless of the reset state. fwe input can also be switched during execution of a program in flash memory. ? do not apply fwe if program runaway has occurred. ? disconnect fwe only when the swe1, esu1, psu1, ev1, pv1, p1, and e1 bits in flmcr1 are cleared. make sure that the sw e1, esu1, psu1, ev1, pv1, p1, and e1 bits are not set by mistake when applying or disconnecting fwe. ? do not apply a constant high level to the fwe pin. apply a high level to the fwe pin only when programming or erasing flash memory. a system configuration in which a high level is constantly applied to the fwe pin should be avoided. also, while a high level is applied to the fwe pin, the watchdog timer should be activated to prevent overprogramming or overerasing due to program runaway, etc. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 588 of 698 rej09b0074-0600 ? use the recommended algorithm when programming and erasing flash memory. the recommended algorithm enables programmi ng and erasing to be carried out without subjecting the device to voltage stress or sacrificing program data reliability. when setting the p1 or e1 bit in flmcr1, the watchdog timer should be set beforehand as a precaution against program runaway, etc. ? do not set or clear the swe1 bit during execution of a program in flash memory. wait at least s* after clearing the swe1 bit before executing a program or reading data in flash memory. when the swe1 bit is set, data in flash memory can be rewritten, but access flash memory only for verify operations (verification during programming/erasing). also, do not clear the swe1 bit during programming, erasing, or verifying. similarly, when using emulation by ram with a high level applied to the fwe pin, the swe1 bit should be cleared before executing a program or reading data in flash memory. however, read/write accesses can be performed in the ram area overlapping the flash memory space regardless of whether the swe1 bit is set or cleared. note: * refer to section 22.7, flash memory characteristics. ? do not use interrupts while flash memory is being programmed or erased. all interrupt requests, including nmi, should be disabled during fwe application to give priority to program/erase operations. ? do not perform additional programming. erase the memory before reprogramming. in on-board programming, perform only one programming operation on a 128-byte programming unit block. in programmer mode, too, perform only one programming operation on a 128-byte programming unit block. programming should be carried out with the entire programming unit block erased. ? before programming, check that the chip is correctly mounted in the prom programmer. overcurrent damage to the device can result if the index marks on the prom programmer socket, socket adapter, and ch ip are not correctly aligned. ? do not touch the socket adapter or chip during programming. touching either of these can cause contact faults and write errors. ? the reset state must be entered after powering on apply the reset signal for at least 100 s during the oscillation setting period. ? when a reset is applied during operation, this should be done while the swe1 pin is low. wait at least s* after clearing the swe1 bit before applying the reset. note: * refer to section 22.7, flash memory characteristics. section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 589 of 698 rej09b0074-0600 1. 2. 3. except when switching modes, the level of the mode pins (md2 to md0) must be fixed until power-off by pulling the pins up or down. see section 22.7, flash memory characteristics. mode programming setup time t mds (min) = 200 ns. period during which flash memory access is prohibited (x: wait time after setting swe1 bit) * 2 period during which flash memory can be programmed (execution of program in flash memory prohibited, and data reads other than verify operations prohibited) notes: v cc fwe t osc1 min 0 s min 0 s t mds * 3 t mds * 3 md2 to md0 * 1 res swe1 bit swe1 set swe1 cleared x programming/ erasing possible wait time: wait time: figure 17.15 power-on/off timing (boot mode) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 590 of 698 rej09b0074-0600 swe1 set swe1 cleared v cc fwe t osc1 min 0 s md2 to md0 * 1 res swe1 bit x t mds * 3 1. 2. 3. except when switching modes, the level of the mode pins (md2 to md0) must be fixed until power-off by pulling the pins up or down. see section 22.7, flash memory characteristics. mode programming setup time t mds (min) = 200 ns. period during which flash memory access is prohibited (x: wait time after setting swe1 bit) * 2 period during which flash memory can be programmed (execution of program in flash memory prohibited, and data reads other than verify operations prohibited) notes: programming/ erasing possible wait time: wait time: figure 17.16 power-on/off timing (user program mode) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 591 of 698 rej09b0074-0600 v cc fwe t osc1 min 0 s t mds t mds t mds t resw md2 to md0 res swe1 bit mode change * 1 boot mode mode change * 1 user mode user program mode user mode user program mode swe1 set swe1 cleared x * 4 * 4 * 2 * 4 * 4 1. 2. 3. 4. when entering boot mode or making a transition from boot mode to another mode, mode switching must be carried out by means of res input when making a transition from boot mode to another mode, a mode programming setup time t mds (min) of 200 ns is necessary with respect to res clearance timing. see section 22.7, flash memory characteristics. wait time: . period during which flash memory access is prohibited (x: wait time after setting swe1 bit) * 3 period during which flash memory can be programmed (execution of program in flash memory prohibited, and data reads other than verify operations prohibited) notes: wait time: programming/ erasing possible x wait time: programming/ erasing possible x wait time: programming/ erasing possible x wait time: programming/ erasing possible figure 17.17 mode transition timing (example: boot mode user mode ? user program mode) section 17 flash memory (f-ztat version) rev.6.00 jun. 03, 2008 page 592 of 698 rej09b0074-0600 17.14 note on switching from f-ztat version to masked rom version the masked rom version does not have the internal registers for flash memory control that are provided in the f-ztat version. table 17.9 lists the registers that are present in the f-ztat version but not in the masked rom version. if a register listed in table 17.9 is read in the masked rom version, an undefined value will be returned. therefore, if application software developed on the f-ztat version is switched to a masked rom version product, it must be modified to ensure that the registers in table 17.9 have no effect. table 17.9 registers present in f-ztat v ersion but absent in masked rom version register abbreviation address flash memory control register 1 flmcr1 h'ffa8 flash memory control register 2 flmcr2 h'ffa9 erase block register 1 ebr1 h'ffaa erase block register 2 ebr2 h'ffab ram emulation register ramer h'fedb serial control register x scrx h'fdb4 section 18 masked rom rev.6.00 jun. 03, 2008 page 593 of 698 rej09b0074-0600 section 18 masked rom this lsi incorporates a masked rom which has the following features. 18.1 features ? size product class rom size rom address (modes 6 and 7) h8s/2218 group hd6432217 64 kbytes h'000000 to h'00ffff h8s/2212 group hd6432211 64 kbytes h'000000 to h'00ffff hd6432210, hd6432210s 32 kbytes h'000000 to h'007fff ? connected to the bus master through 16-bit da ta bus, enabling one-state access to both byte data and word data. figure 18.1 shows a block diagram of the on-chip masked rom. internal data bus (upper 8 bits) internal data bus (lower 8 bits) h'000000 h'000002 h'000001 h'000003 h'00fffe h'00ffff figure 18.1 block diagram of on-chip masked rom (64 kbytes) section 18 masked rom rev.6.00 jun. 03, 2008 page 594 of 698 rej09b0074-0600 section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 595 of 698 rej09b0074-0600 section 19 clock pulse generator this lsi has an on-chip clock pulse generator that generates the system clock ( ), the bus master clock, and internal clocks. the clock pulse gene rator consists of a main clock oscillator, duty adjustment circuit, clock select circuit, medium -speed clock divider, bus master clock selection circuit, subclock oscillator, waveform shaping ci rcuit, pll (phase locked loop) circuit, and usb operating clock selection circuit. a block diagram of clock pulse generator is shown in figure 19.1. duty adjustment circuit extal xtal main clock oscillator usb operation clock selection circuit osc1 osc2 subclock oscillator waveform generation circuit medium- speed clock divider system clock to pin usb operation clock to usb rtc clock to rtc internal clock to peripheral modules bus master cloc k to cpu, dmac usb clock to usb /2 to /32 sck2 to sck0 ucks3 to ucks0 sckcr rfcut 48mhz lpwrcr uctlr bus master clock selection circuit clock selection circuit sub legend: lpwrcr: low power control register sckcr: system clock control register uctlr: usb control register pll circuit figure 19.1 block diagram of clock pulse generator the frequency of the main clock oscillator can be changed by software by means of settings in the low-power control register (lpwrcr) and system clock control register (sckcr). pll 48-mhz clock can be selected by software by means of setting the usb control register (uctlr). for details, refer to section 14, universal serial bus (usb). cpg0600b_000020020900 section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 596 of 698 rej09b0074-0600 19.1 register descriptions the on-chip clock pulse generator has the following registers. ? system clock control register (sckcr) ? low-power control register (lpwrcr) 19.1.1 system clock control register (sckcr) sckcr controls clock output and medium-speed mode. bit bit name initial value r/w description 7 pstop 0 r/w clock output disable controls output. the operation of this bit changes depending on the operating mode. for details, see section 20.11, clock output disabling function. 0: output, fixed high, or high impedance 1: fixed high or high impedance 6 ? 0 r/w reserved although this bit is readable/writable, only 0 should be written to. 5, 4 ? all 0 ? reserved these bits are always read as 0. 3 ? 0 r/w reserved although this bit is readable/writable, only 0 should be written to. section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 597 of 698 rej09b0074-0600 bit bit name initial value r/w description 2 1 0 sck2 sck1 sck0 0 0 0 r/w r/w r/w system clock select 2 to 0 these bits select the bus master clock. to operate in subactive mode or watch mode, clear the sck2 to sck0 bits to 0. 000: high-speed mode 001: medium-speed clock is /2 010: medium-speed clock is /4 011: medium-speed clock is /8 100: medium-speed clock is /16 101: medium-speed clock is /32 11 : setting prohibited legend: : don?t care 19.1.2 low power control register (lpwrcr) lpwrcr performs power-down mode control, selects sampling frequency for eliminating noise, performs subclock oscillator control, and selects whether or not built-in feedback resistance and duty adjustment circuit of the system clock generator used. bit bit name initial value r/w description 7 dton 0 r/w direct transition on flag 0: when the sleep instruction is executed in high-speed mode or medium-speed mode, operation shifts to sleep mode, software standby mode, or watch mode * . when the sleep instruction is executed in subactive mode, operation shifts to subsleep mode or watch mode. 1: when the sleep instruction is executed in high-speed mode or medium-speed mode, operation shifts directly to subactive mode, or shifts to sleep mode or software standby mode. when the sleep instruction is executed in subactive mode, operation shifts directly to high-speed mode, or shifts to subsleep mode. section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 598 of 698 rej09b0074-0600 bit bit name initial value r/w description 6 lson 0 r/w low speed on flag 0: when the sleep instruction is executed in high-speed mode or medium-speed mode, operation shifts to sleep mode, software standby mode, or watch mode *. when the sleep instruction is executed in subactive mode, operation shifts to watch mode * or shifts directly to high-speed mode. operation shifts to high-speed mode when watch mode is cancelled. 1: when the sleep instruction is executed in high-speed mode * , operation shifts to watch mode or subactive mode * . when the sleep instruction is executed in subactive mode, operation shifts to subsleep mode or watch mode. operation shifts to subactive mode when watch mode is cancelled. 5 nesel 0 r/w noise elimination sampling frequency select this bit selects the sampling frequency of the subclock ( sub ) generated by the subclock oscillator is sampled by the clock ( ) generated by the system clock oscillator 0: sampling using 1/32 x 1: sampling using 1/4 x 4 substp 0 r/w subclock enable this bit enables/disables subclock generation. this bit should be set to 1 when subclock is not used. 0: enables subclock generation. 1: disables subclock generation. section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 599 of 698 rej09b0074-0600 bit bit name initial value r/w description 3 rfcut 0 r/w built-in feedback resistor control selects whether the oscillator?s built-in feedback resistor and duty adjustment circuit are used with external clock input. this bit should not be accessed when a crystal oscillator is used. after this bit is set when using external clock input, a transition should initially be made to software standby mode. switching between use and non-use of the oscillator?s built-in feedback resistor and duty adjustment circuit is performed when the transition is made to software standby mode. 0: main clock oscillator?s built-in feedback resistor and duty adjustment circuit are used 1: main clock oscillator?s built-in feedback resistor and duty adjustment circuit are not used 2 ? 0 r/w reserved this bit can be read from or written to, but the write value should always 0. 1 0 stc1 stc0 0 0 r/w r/w frequency multiplication factor specify the frequency multiplication factor of the pll circuit incorporated into the evaluation chip. the specified frequency multiplication factor is valid after a transition to software standby mode. with this lsi, the stc1 and stc0 bits must both be set to 1. after a reset, the stc1 and stc0 bits are both cleared to 0, and so they must be set to 1. 00: 1 01: 2 (setting prohibited) 10: 4 (setting prohibited) 11: pll is bypassed note: * when watch mode or subactive mode is entered, set high-speed mode. section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 600 of 698 rej09b0074-0600 19.2 system clock oscillator clock pulses can be supplied by connecting a crystal resonator, or by input of an external clock. 19.2.1 connecting a crystal resonator a crystal resonator can be connected as shown in the example in figure 19.2. select the damping resistance r d according to table 19.1. an at-cut parallel-resonance crystal should be used. extal xtal r d c l2 c l1 c l1 = c l2 = 10 to 22 pf (recommended value, including stray capacitance of circuit board) figure 19.2 connection of crystal resonator (example) table 19.1 damping resistance value frequency (mhz) 6 8 10 13 16 20 24 r d ( ) 300 200 100 0 0 0 0 figure 19.3 shows the equivalent circuit of the crystal resonator. use a crystal resonator that has the characteristics shown in table 19.2. xtal c l at-cut parallel-resonance type extal c 0 lr s figure 19.3 crystal resonator equivalent circuit table 19.2 crystal resonator characteristics frequency (mhz) 6 8 10 13 16 20 24 r s max ( ) 100 80 60 60 50 40 40 c 0 max (pf) 7 7 7 7 7 7 7 section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 601 of 698 rej09b0074-0600 19.2.2 inputting external clock an external clock signal can be input as shown in an example in figure 19.4. if the xtal pin is left open, make sure that stray capacitance is no more than 10 pf. when complementary clock input to xtal pin, the external clock input should be fixed high in standby mode, subactive mode, subsleep mode, or watch mode. extal xtal extal xtal external clock input open external clock input (a) xtal pin left open (b) complementary clock input at xtal pin figure 19.4 external clock input (examples) table 19.3 shows the input conditions for the external clock. table 19.3 external clock input conditions vcc= 2.4 to 3.6v vcc = 2.7 to 3.6v vcc = 3.0 to 3.6v item symbol min max min max min max unit test conditions external clock input low pulse width t exl 65 ? 25 ? 15.5 ? ns external clock input high pulse width t exh 65 ? 25 ? 15.5 ? ns external clock rise time t exr ? 15 ? 6.25 ? 5.25 ns external clock fall time t exf ? 15 ? 6.25 ? 5.25 ns figure 19.5 clock low pulse width level t cl 0.35 0.65 0.4 0.6 0.4 0.6 tcyc figure 22.3 clock high pulse width level t ch 0.35 0.65 0.4 0.6 0.4 0.6 tcyc the external clock input conditions when the duty adjustment circuit is not used are shown in table 19.4. when the duty adjustment circuit is not used, note that the maximum operating frequency depends on the external clock input waveform. for example, if t exl = t exh = 20.8 ns and t exr = t exf = 5.25 ns, the maximum operating frequency becomes 19.2 mhz depending on the clcok cycle time of 52.1 ns. section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 602 of 698 rej09b0074-0600 table 19.4 external clock input conditions when duty adjustment circuit is not used item symbol min max min max min max unit test conditions external clock input low pulse width t exl 80 ? 31.25 ? 20.8 ? ns figure 19.5 external clock input high pulse width t exh 80 ? 31.25 ? 20.8 ? ns external clock rise time t exr ? 15 ? 6.25 ? 5.25 ns external clock fall time t exf ? 15 ? 6.25 ? 5.25 ns t exh t exl t exr t exf v cc 0.5 extal figure 19.5 external clock input timing 19.3 duty adjustment circuit when the oscillator frequency is 5 mhz or higher, the duty adjustment circuit adjusts the duty cycle of the clock signal from the oscillator to generate the system clock ( ). 19.4 medium-speed clock divider the medium-speed clock divider divides the system clock to generate /2, /4, /8, /16, and /32. 19.5 bus master clock selection circuit the bus master clock selection circuit selects the clock supplied to the bus master by setting the bits sck2 to sck0 in sckcr. the bus master clock can be selected from high-speed mode, or medium-speed clocks ( /2, /4, /8, /16, /32). section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 603 of 698 rej09b0074-0600 19.6 subclock oscillator 19.6.1 connecting 32.768-khz crystal resonator supply a clock to the subclock divider, connect a 32.768-khz crystal resonator, as shown in figure 19.6. figure 19.7 shows the equivalence circuit for a 32.768-khz oscillator. osc1 osc2 note: c 1 and c 2 are reference values including the floating capacitance of the board. c 1 c 2 c 1 = c 2 = 15 pf (typ.) figure 19.6 example connection of 32.768-khz quartz oscillator osc1 osc2 cs ls rs co co = 1.5 pf (typ.) rs = 14 k (typ.) fw = 32.768 khz type name = c001r (seiko epson) figure 19.7 equivalence circuit for 32.768-khz oscillator 19.6.2 handling pins when subclock not required if no subclock is required, connect the osc1 pin to vss and leave osc2 open, as shown in figure 19.8. set the substp bit of lpwrcr to 1. if this setting is not made, transition to power-down mode may not complete properly in some cases. osc1 osc2 open stat e figure 19.8 pin handling when subclock not required section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 604 of 698 rej09b0074-0600 19.7 subclock waveform generation circuit to eliminate noise from the subclock input to osci, the subclock is sampled using the dividing clock . the sampling frequency is set using the nesel bit of lpwrcr. for details, see section 19.1.2, low power control register (lpwrcr). no sampling is performed in subactive mode, subsleep mode, or watch mode. 19.8 pll circuit for usb the pll circuit has the function of doubling or tripling the 16-mhz or 24-mhz clock from the main oscillator to generate the 48-mhz usb operating clock. when the pll circuit is used, set the ucks3 to ucks0 bits of uctlr. for details, refer to section 14, universal serial bus (usb). when the pll circuit is not used, connect the plvcc pin to vcc and the pllvss pin to the ground (vss). figure 19.9 shows examples of external circuits peripheral to the pll. 16 - m h z or 2 4- m h z crysta l resonator or externa l c l ock (2) p ll i s not used (1) p ll i s used n ote : * cb, cpb i s l am i nated ceram i c . r p : 200 p ll vcc e x t a l x t a l p ll vss vcc vss vcc cpb : 0 . 1 f * cb : 0 . 1 f * 6 - to 2 4- m h z crysta l resonator or externa l c l ock p ll vcc e x t a l x t a l p ll vss vcc vss vcc figure 19.9 example of pll circuit section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 605 of 698 rej09b0074-0600 19.9 usage notes 19.9.1 note on crystal resonator since various characteristics related to the crystal resonator are closely linked to the user's board design, thorough evaluation is necessary on the user's part, using the resonator connection examples shown in this section as a guide. as the resonator circuit ratings will depend on the floating capacitance of the resonator and the mounting circuit, the ratings should be determined in consultation with the resonator manufacturer. the design must ensure that a voltage exceeding the maximum rating is not applied to the oscillator pin. 19.9.2 note on board design when designing the board, place the crystal resonator and its load capacitors as close as possible to the xtal or osc1 and extal or osc2 pins. other signal lines should be routed away from the oscillator circuit to prevent induction from interfering with correct oscillation. see figure 19.10. prohibit signal a signal b this lsi extal or osc1 xtal or osc2 c 1 c 2 figure 19.10 note on board design of oscillator circuit 19.9.3 note on switchover of external clock when two or more external clocks (e.g. 16 mhz and 13 mhz) are used as the system clock, switchover of the input clock should be carried out in software standby mode. an example of an external clock switching circuit is shown in figure 19.11, and an example of the external clock switchover timing in figure 19.12. section 19 clock pulse generator rev.6.00 jun. 03, 2008 page 606 of 698 rej09b0074-0600 this lsi ouptut port external interrupt extal request switchover of external clock interrupted external signal external clock switchover signal external clock 1 external clock 2 control cycle selector figure 19.11 example of external clock switching circuit 200 ns or more (2) (1) (2) (3) (4) (5) port setting (clock switchover) software standby mode transition external clock switchover external interrupt generation (input interrupt at least 200 ns after transition to software standby mode.) interrupt exception handling (5) sleep instruction execution interrupt exception handling operation external clock 1 external clock 2 (1) port setting (3) external clock switchover signal extal internal clock (4) wait time external interrupt active (external clock 2) software standby mode active (external clock 1) clock switchover request figure 19.12 example of external clock switchover timing section 20 power-down modes rev.6.00 jun. 03, 2008 page 607 of 698 rej09b0074-0600 section 20 power-down modes in addition to the normal program execution state, this lsi has five power-down modes in which operation of the cpu and oscillator is halted and power dissipation is reduced. low-power operation can be achieved by individually controlling the cpu, on-chip supporting modules, and so on. this lsi's operating modes are high-speed mode and five power down modes: 1. medium-speed mode 2. subactive mode 3. sleep mode 4. subsleep mode 5. watch mode 6. module stop mode 7. software standby mode 8. hardware standby mode 1. to 5. are power-down modes. sleep mode is cpu states, medium-speed mode is a cpu and bus master state, subactive mode is a cpu, bus ma ster, and on-chip peripheral function state, and module stop mode is an internal peripheral function (including bus masters other than the cpu) state. some of these states can be combined. after a reset, the lsi is in high-speed mode, flash memory, and module stop mode (other than dmac). table 20.1 and table 20.2 show the lsi internal states in each mode and the transition conditions of power-down modes respectively. figure 20.1 shows the diagram of mode transition. section 20 power-down modes rev.6.00 jun. 03, 2008 page 608 of 698 rej09b0074-0600 table 20.1 lsi internal states in each mode function high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby system clock pulse generator function- ing function- ing function- ing function- ing halted halted halted halted halted subclock pulse generator function- ing/halted function- ing/halted function- ing/halted function- ing/halted function- ing function- ing function- ing function- ing/halted halted cpu instructions function- ing medium- speed operation halted function- ing halted subclock operation halted halted halted registers retained retained retained retained undefined ram function- ing function- ing function- ing function- ing retained function- ing retained retained retained i/o function- ing function- ing function- ing function- ing retained function- ing function- ing halted high impedance external interrupts nmi irq0 to irq4, irq7 function- ing function- ing function- ing function- ing function- ing function- ing function- ing function- ing halted peripheral functions dmac function- ing medium- speed operation function- ing halted (retained) halted (retained) halted (retained) halted (retained) halted (retained) halted (reset) wdt function- ing function- ing function- ing function- ing halted (retained) subclock operation subclock operation halted (retained) halted (reset) rtc clock operation subclock operation subclock operation subclock operation halted (retained) subclock operation subclock operation subclock operation subclock functioning/ halted halted (reset) free- running timer operation function- ing function- ing function- ing halted (retained) halted (retained) halted (retained) halted (retained) halted (retained) halted (reset) tpu sci function- ing function- ing function- ing halted (retained) halted (retained) halted (retained) halted (retained) halted (retained) halted (reset) a/d function- ing function- ing function- ing halted (reset) halted (reset) halted (reset) halted (reset) halted (reset) halted (reset) usb function- ing function- ing halted (retained) halted (retained) halted (reset) pll circuit function not guaranteed halted function not guaranteed. always select module stop mode. halted notes: "halted (retained)" means that internal register values are retained. the internal state is "operation suspended." "halted (reset)" means that internal register values and internal states are initialized. in module stop mode, only modules for which a stop setting has been made are halted (reset or retained). section 20 power-down modes rev.6.00 jun. 03, 2008 page 609 of 698 rej09b0074-0600 program-halted state program execution state reset execution state sck2 to sck0 = 0 sck2 to sck0 0 sleep instruction any interrupt sleep instruction interrupt * 1 sleep instruction sleep instruction interrupt * 2 interrupt * 1 , lson bit = 1 stby pin = high res pin = low stby pin = low ssby = 0, lson = 0 ssby = 1, pss = 0, lson = 0 res pin = high mres pin = high : transition after exception processing notes: 1. nmi and irq0 to irq4, irq7, rtc interrupt, and usb suspend/resume interrupt 2. nmi and irq0 to irq4, irq7, rtc interrupt, and wdt interrupt : power-down power-on reset state manual reset state high-speed mode (main clock) hardware standby mode software standby mode sleep mode (main clock) ssby = 1, pss = 1, dton = 0 ssby = 0, pss = 1, lson = 1 sub-speed mode (subclock) watch mode (subclock) medium-speed mode (main clock) sleep instruction ssby = 1, pss = 1, dton = 1, lson = 0 after the oscillation settling time (sts2 to 0), clock switching exception processing sleep instruction ssby = 1, pss = 1, dton = 1, lson = 1 clock switching exception processing sub-active mode (sub clock) sleep instruction interrupt * 1 , lson bit = 0 when a transition is made between modes by means of an interrupt, the transition cannot be made on interrupt source generation alone. ensure that interrupt handling is performed after accepting the interrupt request. from any state except hardware standby mode, a transition to the power-on reset state occurs when res is driven low. from any state except hardware standby mode and power-on reset, a transition to the manual reset state occurs when mres is driven low. from any state, a transition to hardware standby mode occurs when stby is driven low. always select high-speed mode before making a transition to watch mode or subactive mode. figure 20.1 mode transition diagram section 20 power-down modes rev.6.00 jun. 03, 2008 page 610 of 698 rej09b0074-0600 table 20.2 transition conditions of power-down modes status of control bit at transition pre-transition state ssby pss lson dton state after transition invoked by sleep command state after transition back from power-down mode invoked by interrupt 0 0 sleep high-speed/medium-speed 0 1 ? ? 1 0 0 software standby high-speed/medium-speed 1 0 1 ? ? 1 1 0 0 watch high-speed 1 1 1 0 watch subactive 1 1 0 1 ? ? high-speed/ medium-speed 1 1 1 1 subactive ? subactive 0 0 ? ? 0 1 0 ? ? 0 1 1 sub sleep subactive 1 0 ? ? 1 1 0 0 watch high-speed 1 1 1 0 watch subactive 1 1 0 1 high-speed ? 1 1 1 1 ? ? legend: : don?t care ?: do not set section 20 power-down modes rev.6.00 jun. 03, 2008 page 611 of 698 rej09b0074-0600 20.1 register descriptions the registers relating to the power down mode are shown below. for details on the low power control register (lpwrcr), refer to section 19.1.2, low power control register (lpwrcr). for details on the system clock control register (sckcr), refer to section 19.1.1, system clock control register (sckcr). ? standby control register (sbycr) ? system clock control register (sckcr) ? low power control register (lpwrcr) ? timer control/status register (tcsr_1) ? module stop control register a (mstpcra) ? module stop control register b (mstpcrb) ? module stop control register c (mstpcrc) ? extended module stop register (exmdlstp) 20.1.1 standby control register (sbycr) sbycr performs software standby mode control. bit bit name initial value r/w description 7 ssby 0 r/w software standby this bit specifies the transition mode after executing the sleep instruction 0: shifts to sleep mode when the sleep instruction is executed in high-speed mode or medium-speed mode. shifts to subsleep mode when the sleep instruction is executed in subactive mode. 1: shifts to software standby mode, subactive mode, or watch mode when the sleep instruction is executed in high-speed mode or medium-speed mode. shifts to watch mode or high-speed mode when the sleep instruction is executed in subactive mode. this bit does not change when clearing software standby mode by using external interrupts and shifting to normal operation. 0 should be written to this bit for clearing. section 20 power-down modes rev.6.00 jun. 03, 2008 page 612 of 698 rej09b0074-0600 bit bit name initial value r/w description 6 5 4 sts2 sts1 sts0 0 0 0 r/w r/w r/w standby timer select 2 to 0 these bits select the mcu wait time for clock stabilization when cancel software standby mode, watch mode, or subactive mode by an external interrupt. with a crystal oscillator (tables 20.3 and 20.4) , select a wait time of t osc2 ms (oscillation stabilization time) or more, depending on the operating frequency. with an external clock, there are no specific wait requirements. however, in the f-ztat version a standby time of 16 wait states cannot be used with an external clock. in this case, select a wait time of 100 s or more. 000: standby time = 8192 states 001: standby time = 16384 states 010: standby time = 32768 states 011: standby time = 65536 states 100: standby time = 131072 states 101: standby time = 262144 states 110: standby time = 2048 states 111: standby time = 16 states 3 ope 1 r/w output port enable this bit selects whether address bus and bus control signals ( cs0 to cs7 , as , rd , hwr , and lwr ) are brought to high impedance state or retained in software standby mode, watch mode, or direct transition. 0: high impedance state 1: retained 2 to 0 ? all 0 ? reserved these bits are always read as 0, and cannot be modified. section 20 power-down modes rev.6.00 jun. 03, 2008 page 613 of 698 rej09b0074-0600 20.1.2 timer control/status register (tcsr_1) tcsr_1 controls the operation in power-down mode transition. bit bit name initial value r/w description 7 to 5 ? all 0 ? reserved the write value should always be 0. 4 pss 0 r/w prescaler select 0: when the sleep instruction is executed in high- speed mode or medium-speed mode, operation shifts to sleep mode or software standby mode. 1: when the sleep instruction is executed in high- speed mode or medium-speed mode, operation shifts to sleep mode, watch mode, or subactive mode. when the sleep instruction is executed in subactive mode, operation shifts to subsleep mode, watch mode, or high-speed mode tcsr_1 differs from other registers in being more difficult to write to. the procedures for writing to and reading this register are given below. write: tcsr_1 must be written to by a word transfer instruction. the upper byte of the written word must contain h a5 and the lower byte must contain the write data. (when the pss bit is set to 1, the upper byte of the written word must contain h'a510.) read: tcsr_1 is read by the same procedure as for the general registers. 3 to 0 ? all 0 ? reserved the write value should always be 0. section 20 power-down modes rev.6.00 jun. 03, 2008 page 614 of 698 rej09b0074-0600 20.1.3 module stop control registers a to c (mstpcra to mstpcrc) mstpcr, comprising three 8-bit readable/writable registers, performs module stop mode control. setting a bit to 1, causes the corresponding module to enter module stop mode, while clearing the bit to 0 clears the module stop mode. mstpcra bit bit name initial value r/w module 7 mstpa7 0 r/w dma controller (dmac) 6 mstpa6 * 0 r/w ? 5 mstpa5 1 r/w 16-bit timer pulse unit (tpu) 4 mstpa4 * 1 r/w ? 3 mstpa3 * 1 r/w ? 2 mstpa2 * 1 r/w ? 1 mstpa1 1 r/w a/d converter 0 mstpa0 * 1 r/w ? mstpcrb bit bit name initial value r/w module 7 mstpb7 1 r/w serial communication interface 0 (sci_0) 6 mstpb6 * 1 r/w ? 5 mstpb5 1 r/w serial communication interface 2 (sci_2) 4 mstpb4 * 1 r/w ? 3 mstpb3 * 1 r/w ? 2 mstpb2 * 1 r/w ? 1 mstpb1 * 1 r/w ? 0 mstpb0 1 r/w usb section 20 power-down modes rev.6.00 jun. 03, 2008 page 615 of 698 rej09b0074-0600 mstpcrc bit bit name initial value r/w module 7 mstpc7 * 1 r/w ? 6 mstpc6 * 1 r/w ? 5 mstpc5 * 1 r/w ? 4 mstpc4 * 1 r/w ? 3 mstpc3 * 1 r/w ? 2 mstpc2 * 1 r/w ? 1 mstpc1 0 r/w flash memory (this bit is reserved in the masked rom version; setting is disabled.) note: setting of the flash memory module stop mode should be carried out while the programs in the on-chip ram and external memory are executed. if the flash memory is stopped with the programming in the flash memory, the program after setting module stop mode stops and enters to the deadlock state. figure 20.2 shows the example of using module stop mode. 0 mstpc0 * 1 r/w ? note: * mstpa6 are readable/writable bits with an initial value of 0 and should always be written with 1. mstpa4 to mstpa2, mstpa0, mstpb6, ms tpb4 to mstpb1, mstpc7 to mstpc2, mstpc0 are readable/writable bits with an initial value of 1 and should always be written with 1. section 20 power-down modes rev.6.00 jun. 03, 2008 page 616 of 698 rej09b0074-0600 no yes yes yes execute flash memory program branch to on-chip ram program return to flash memory program execute flash memory program write 1 to flash memory module stop bit using on-chip ram program operation in power-down mode by entering flash memory module stop mode write 0 to flash memory module stop bit by on-chip ram program program executed module flash memory on-chip ram flash memory power-down mode setting required? flash memory program execution is required? wait for longer than flash memory power supply stabilization time: 100 s or longer for interrupt processing, enable ram emulation function of eb0 area in flash memory and copy part of vector address and program to on-chip ram no no figure 20.2 example of flash memory module stop mode usage section 20 power-down modes rev.6.00 jun. 03, 2008 page 617 of 698 rej09b0074-0600 20.1.4 extended module stop register (exmdlstp) exmdlstp controls the clock supply of the rtc and usb, performs module stop mode control. setting a bit to 1, causes the corresponding module to enter module stop mode, while clearing the bit to 0 clears the module stop mode. bit bit name initial value r/w module 7 to 2 ? undefined ? reserved read is undefined. these bits should not to be modified. 1 rtcstop 0 r/w rtc 0 usbstop1 0 r/w usb 20.2 medium-speed mode when the sck2 to sck0 bits in sckcr are set to 1, the operating mode changes to medium- speed mode as soon as the current bus cycle ends. in medium-speed mode, the cpu operates on the operating clock ( /2, /4, /8, /16, or /32) specified by the sck2 to sck0 bits. the bus masters other than the cpu (dmac) also operate in medium-speed mode. on-chip supporting modules other than the bus masters always operate on the high-speed clock ( ). in medium-speed mode, a bus access is executed in the specified number of states with respect to the bus master operating clock. for example, if /4 is selected as the operating clock, on-chip memory is accessed in 4 states, and internal i/o registers in 8 states. medium-speed mode is cleared by clearing all of bi ts sck2 to sck0 to 0. a transition is made to high-speed mode and medium-speed mode is cleared at the end of the current bus cycle. if a sleep instruction is executed when the ssby bit in sbycr, the lson bit in lpwrcr are cleared to 0, a transition is made to sleep mode. when sleep mode is cleared by an interrupt, medium-speed mode is restored. when the sleep instruction is executed with the ssby bit = 1 and the lson bit, and the pss bit in tcsr_1 are cleared to 0, operation shifts to the software standby mode. when software standby mode is cleared by an external interrupt, medium-speed mode is restored. when the res or mres * pin is set low and medium-speed mode is cancelled, operation shifts to the reset state. the same applies in the case of a reset caused by overflow of the watchdog timer. when the stby pin is driven low, a transition is made to hardware standby mode. section 20 power-down modes rev.6.00 jun. 03, 2008 page 618 of 698 rej09b0074-0600 figure 20.3 shows the timing for transition to and clearance of medium-speed mode. note: * supported only by the h8s/2218 group. sckcr sckcr , supporting module clock bus master clock internal address bus internal write signal medium-speed mode figure 20.3 medium-speed mode transition and clearance timing 20.3 sleep mode 20.3.1 transition to sleep mode when the sleep instruction is executed when the ssby bit in sbycr and the lson bit in lpwrcr are cleared to 0, the cpu enters the sleep mode. in sleep mode, cpu operation stops but the contents of the cpu's internal registers are retained. other supporting modules do not stop. 20.3.2 exiting sleep mode sleep mode is exited by any interrupt, or signals at the res , mres *, or stby pin. ? exiting sleep mode by interrupts when an interrupt occurs, sleep mode is exite d and interrupt exception processing starts. sleep mode is not exited if the interrupt is disabled, or interrupts other than nmi are masked by the cpu. ? exiting sleep mode by res or mres * pin setting the res or mres * pin level low selects the reset state. after the stipulated reset input duration, driving the res or mres * pin high starts the cpu performing reset exception processing. ? exiting sleep mode by stby pin when the stby pin level is driven low, a transition is made to hardware standby mode. note: * supported only by the h8s/2218 group. section 20 power-down modes rev.6.00 jun. 03, 2008 page 619 of 698 rej09b0074-0600 20.4 software standby mode 20.4.1 transition to software standby mode a transition is made to software standby mode when the sleep instruction is executed when the ssby bit in sbycr is set to 1 and the lson bit in lpwrcr and the pss bit in tcsr_1 are cleared to 0. in this mode, the cpu, on-chip supporting modules, and oscillator all stop. however, the contents of the cpu's internal registers, ram data, and the states of on-chip supporting modules other than the a/d converter, and the states of i/o ports, are retained. in this mode the oscillator stops, and therefore power dissipation is significantly reduced. 20.4.2 clearing software standby mode software standby mode is cleared by an external interrupt (nmi pin, irq7 pin, or irq0 to irq4 pins), rtc interrupt ( irq5 signal), or usb suspend/resume interrupt ( irq6 signal), or by means of the res pin, mres pin*, or stby pin. ? clearing with an interrupt when an nmi or irq0 to irq7 interrupt reques t signal is input, clock oscillation starts, and after the elapse of the time set in bits sts2 to sts0 in sbycr, stable clocks are supplied to the entire chip, software standby mode is cleared, and interrupt exception handling is started. when clearing software standby mode with an irq0 to irq7 interrupt, set the corresponding enable bit to 1 and ensure that no interrupt with a higher priority than interrupts irq0 to irq5 is generated. software standby mode cannot be cleared if the interrupt has been masked on the cpu side. ? clearing with the res or mres * pin when the res or mres * pin is driven low, clock oscillation is started. at the same time as clock oscillation starts, clocks are supplied to the entire chip. note that the res or mres * pin must be held low until clock oscillation stabilizes. when the res or mres * pin goes high, the cpu begins reset exception handling. ? clearing with the stby pin when the stby pin is driven low, a transition is made to hardware standby mode. note: * supported only by the h8s/2218 group. section 20 power-down modes rev.6.00 jun. 03, 2008 page 620 of 698 rej09b0074-0600 20.4.3 setting oscillation stabilization time after clearing software standby mode bits sts2 to sts0 in sbycr should be set as described below. ? using a crystal oscillator: set bits sts2 to sts0 so that the standby time is at least t osc2 ms (the oscillation stabilization time). table 20.3 shows the standby times for different operating frequencies and settings of bits sts2 to sts0. ? using an external clock set bits sts2 to sts0 as any value. usually, minimum value is recommended. a standby time of 100 s or longer (flash memory power supply stabilization time) should be used in the f- ztat version. table 20.3 oscillation stabilization time settings sts2 sts1 sts0 standby time 24mhz 20mhz 16mhz 13mhz 10mhz 8mhz 6mhz 4mhz 2mhz unit 0 0 0 8192 states 0.34 0.41 0.51 0.63 0.82 1.0 1.4 2.0 4.1 ms 1 16384 states 0.68 0.82 1.0 1.3 1.6 2.0 2.7 4.1 8.2 1 0 32768 states 1.4 1.6 2.0 2.5 3.3 4.1 5.5 8.2 16.4 1 65536 states 2.7 3.3 4.1 5.0 6.6 8.2 10.9 16.4 32.8 1 0 0 131072 states 5.5 6.6 8.2 10.1 13.1 16.4 21.8 32.8 65.5 1 262144 states 10.9 13.1 16.4 20.2 26.2 32.8 43.7 65.5 131.1 1 0 2048 states 0.09 0.10 0.13 0.16 0.20 0.26 0.34 0.51 1.0 1 16 states 0.67 0.80 1. 0 1.2 1.6 2.0 2.7 4.0 8.0 s : recommended time setting (for conditions, see t osc2 in table 22.4.) 20.4.4 software standby mode application example figure 20.4 shows an example in which a transition is made to software standby mode at the falling edge on the nmi pin, and software standby mode is cleared at the rising edge on the nmi pin. in this example, an nmi interrupt is accepted with the nmieg bit in syscr cleared to 0 (falling edge specification), then the nmieg bit is set to 1 (rising edge specification), the ssby bit is set to 1, and a sleep instruction is executed, causing a transition to software standby mode. software standby mode is then cleared at the rising edge on the nmi pin. section 20 power-down modes rev.6.00 jun. 03, 2008 page 621 of 698 rej09b0074-0600 oscillator nmi nmieg ssby nmi exception handling nmieg = 1 ssby = 1 oscillation stabilization time t osc2 software standby mode (power-down mode) nmi exception handling sleep instruction figure 20.4 software standby mode application example 20.5 hardware standby mode 20.5.1 transition to hardware standby mode when the stby pin is driven low, a transition is made to hardware standby mode from any mode. in hardware standby mode, all functions enter the reset state and stop operation, resulting in a significant reduction in power dissipation. as long as the prescribed voltage is supplied, on-chip ram data is retained. i/o ports are set to the high-impedance state. in order to retain on-chip ram data, the rame bit in syscr should be cleared to 0 before driving the stby pin low. do not change the state of the mode pins (md2 to md0) while this lsi is in hardware standby mode. 20.5.2 clearing hardware standby mode hardware standby mode is cleared by means of the stby pin and the res pin. when the stby pin is driven high while the res pin is low, the reset state is set and clock oscillation is started. ensure that the res pin is held low until the clock oscillator stabilizes (at least t osc1 ?the oscillation stabilization time?when using a crystal oscillator). when the res pin is subsequently driven high, a transition is made to the program execution state via the reset exception handling state. section 20 power-down modes rev.6.00 jun. 03, 2008 page 622 of 698 rej09b0074-0600 20.5.3 hardware standby mode timing figure 20.5 shows an example of hardware standby mode timing. when the stby pin is driven low after the res pin has been driven low, a transition is made to hardware standby mode. hardware standby mode is cleared by driving the stby pin high, waiting for the oscillation stabilization time, then changing the res pin from low to high. oscillator res stby oscillation stabilization time t osc1 reset exception handling figure 20.5 hardware standby mode timing (example) 20.5.4 hardware standby mode timings timing of transition to hardware standby mode: 1. to retain ram contents with the rame bit set to 1 in syscr drive the res signal low at least 10 states before the stby signal goes low, as shown in figure 20.6. after stby has gone low, res has to wait for at least 0 ns before becoming high. t 2 0 ns t 1 10 t cyc stby res figure 20.6 timing of transition to hardware standby mode 2. to retain ram contents with the rame bit cleared to 0 in syscr, or when ram contents do not need to be retained res does not have to be driven low as in the above case. section 20 power-down modes rev.6.00 jun. 03, 2008 page 623 of 698 rej09b0074-0600 timing of recovery from hardware standby mode: drive the res signal low approximately 100 ns or more before stby goes high to execute a power-on reset. t osc t nmirh t 100 ns stby res nmi figure 20.7 timing of recovery from hardware standby mode 20.6 module stop mode module stop mode can be set for individual on-chip supporting modules. when the corresponding mstp bit in mstpcr is set to 1, module operation stops at the end of the bus cycle and a transition is made to module stop mode. the cpu continues operating independently. when the corresponding mstp bit is cleared to 0, module stop mode is cleared and the module starts operating at the end of the bus cycle. in module stop mode, the internal states of modules other than the a/d converter are retained. after reset clearance, all modules other than dmac and flash memory are in module stop mode. when an on-chip supporting module is in module stop mode, read/write access to its registers is disabled. when a transition is made to sleep mode with a ll modules stopped, the bus controller and i/o ports also stop operating, enabling current dissipation to be further reduced. section 20 power-down modes rev.6.00 jun. 03, 2008 page 624 of 698 rej09b0074-0600 20.7 watch mode 20.7.1 transition to watch mode cpu operation makes a transition to watch mode when the sleep instruction is executed in high- speed mode or subactive mode with sbycr ssby=1, lpwrcr dton = 0, and tcsr_1 pss = 1. in watch mode, the cpu is stopped and peripheral modules other than rtc are also stopped. the contents of the cpu?s internal registers, the data in internal ram, and the statuses of the internal peripheral modules (excluding the a/d converter) and i/o ports are retained. to make a transition to watch mode, bits sck2 to sck0 in sckcr must be set to 0. 20.7.2 exiting watch mode watch mode is exited by any interrupt (wovi interrupt, nmi pin, or irq0 , to irq7 ), or signals at the res , mres *, or stby pin. ? exiting watch mode by interrupts when an interrupt occurs, watch mode is exited and a transition is made to high-speed mode or medium-speed mode when the lpwrcr lson bit = 0 or to subactive mode when the lson bit = 1. when a transition is made to high-speed mode, a stable clock is supplied to all lsi circuits and interrupt exception processing starts after the time set in sbycr sts2 to sts0 has elapsed. in case of irq0, to irq7 interrupts, no transition is made from watch mode if the corresponding enable bit/pin function switching bit has been cleared to 0, and, in the case of interrupts from the internal peripheral modules, the interrupt enable register has been set to disable the reception of that interrupt, or is masked by the cpu. see section 20.4.3, setting oscillation stablization time after clearing software standby mode, for how to set the oscillation settling time when making a transition from watch mode to high-speed mode. ? exiting watch mode by res or mres * pin for exiting watch mode by the res or mres * pin, see section 20.4.2, clearing software standby mode. ? exiting watch mode by stby pin when the stby pin level is driven low, a transition is made to hardware standby mode. note: * supported only by the h8s/2218 group. section 20 power-down modes rev.6.00 jun. 03, 2008 page 625 of 698 rej09b0074-0600 20.8 subsleep mode 20.8.1 transition to sleep mode when the sleep instruction is executed with the sbycr ssby bit = 0, lpwrcr lson bit = 1, and tcsr_1 pss bit = 1, cpu operation shifts to subsleep mode. in subsleep mode, the cpu is stopped. peripheral modules other wdt and rtc are also stopped. the contents of the cpu's internal registers, the data in internal ram, and the statuses of the internal peripheral modules (excluding the a/d converter) and i/o ports are retained. 20.8.2 exiting subsleep mode subsleep mode is exited by an interrupt (interrupts from internal peripheral modules, nmi pin, or irq0 , to irq7 ), or signals at the res , mres *, or stby pin. ? exiting subsleep mode by interrupts when an interrupt occurs, subsleep mode is exited and interrupt exception processing starts. in case of irq0 , to irq7 interrupts, subsleep mode is not cancelled if the corresponding enable bit/pin function switching bit has been cleared to 0, and, in the case of interrupts from the internal peripheral modules, the interrupt enable register has been set to disable the reception of that interrupt, or is masked by the cpu. ? exiting subsleep mode by res or mres * pin for exiting subsleep mode by the res or mres * pin, see section 20.4.2, clearing software standby mode. ? exiting subsleep mode by stby pin when the stby pin level is driven low, a transition is made to hardware standby mode. note: * supported only by the h8s/2218 group. section 20 power-down modes rev.6.00 jun. 03, 2008 page 626 of 698 rej09b0074-0600 20.9 subactive mode 20.9.1 transition to subactive mode when the sleep instruction is executed in high-speed mode with the sbycr ssby bit = 1, lpwrcr dton bit = 1, lson bit = 1, and tcsr_1 pss bit = 1, cpu operation shifts to subactive mode. when an interrupt occurs in watch mode, and if the lson bit of lpwrcr is 1, a transition is made to subactive mode. and if an in terrupt occurs in subsleep mode, a transition is made to subactive mode. in subactive mode, the cpu operates at low speed on the subclock, and the program is executed step by step. peripheral modules other than wdt and rtc are also stopped. when operating the cpu in subactive mode, the sckcr sck2 to sck0 bits must be set to 0. 20.9.2 exiting subactive mode subactive mode is exited by the sleep instruction or the res , mres *, or stby pin. ? exiting subactive mode by sleep instruction when the sleep instruction is executed with the sbycr ssby bit = 1, lpwrcr dton bit = 0, and tcsr_1 pss bit = 1, the cpu exits subactive mode and a transition is made to watch mode. when the sleep instruction is executed with the sbycr ssby bit = 0, lpwrcr lson bit = 1, and tcsr_1 pss bit = 1, a transitio n is made to subsleep mode. finally, when the sleep instruction is executed with the sbycr ssby bit = 1, lpwrcr dton bit = 1, lson bit = 0, and tcsr_1 pss bit = 1, a direct transition is made to high-speed mode (sck0 to sck2 all 0). ? exiting subactive mode by res or mres * pin for exiting subactive mode by the res or mres * pin, see section 20.4.2, clearing software standby mode. ? exiting subactive mode by stby pin when the stby pin level is driven low, a transition is made to hardware standby mode. note: * supported only by the h8s/2218 group. section 20 power-down modes rev.6.00 jun. 03, 2008 page 627 of 698 rej09b0074-0600 20.10 direct transitions there are three modes, high-speed, medium-speed , and subactive, in which the cpu executes programs. when a direct transition is made, there is no interruption of program execution when shifting between high-speed and subactive modes. direct transitions are enabled by setting the lpwrcr dton bit to 1, then executing the sleep instruction. after a transition, direct transition interrupt exception processing starts. 20.10.1 direct transitions from high-speed mode to subactive mode execute the sleep instruction in high-speed mode when the sbycr ssby bit = 1, lpwrcr lson bit = 1, and dton bit = 1, and tscr_1 pss bit = 1 to make a transition to subactive mode. 20.10.2 direct transitions from suba ctive mode to high-speed mode execute the sleep instruction in subactive mode when the sbycr ssby bit = 1, lpwrcr lson bit = 0, and dton bit = 1, and tscr_1 pss bit = 1 to make a direct transition to high- speed mode after the time set in sbycr sts2 to sts0 has elapsed. 20.11 clock output disabling function output of the clock can be controlled by means of the pstop bit in sckcr, and ddr for the corresponding port. when the pstop bit is set to 1, the clock stops at the end of the bus cycle, and output goes high. clock output is enabled when the pstop bit is cleared to 0. when ddr for the corresponding port is cleared to 0, clock output is disabled and input port mode is set. table 20.4 shows the state of the pin in each processing state. table 20.4 pin state in each processing state register settings ddr pstop high-speed mode, medium-speed mode, subactive mode sleep mode, subsleep mode software standby mode, watch mode, direct transition hardware standby mode 0 high impedance high impedance high impedance high impedance 1 0 output output fixed high high impedance 1 1 fixed high fixed high fixed high high impedance legend: : don?t care section 20 power-down modes rev.6.00 jun. 03, 2008 page 628 of 698 rej09b0074-0600 20.12 usage notes 20.12.1 i/o port status in software standby mode or watch mode, i/o port states are retained. in addition, if the ope bit is set to 1, the address bus and bus control signal outp ut are retained. therefore, there is no reduction in current dissipation for the output current when a high-level signal is output. 20.12.2 current dissipation during oscillation stabilization wait period current dissipation increases during the oscillation stabilization wait period. 20.12.3 flash memory module stop setting of the flash memory module stop mode should be carried out while the programs in the on- chip ram and external memory are executed. for details, see section 20.1.3, module stop control registers a to c (mstpcra to mstpcrc). 20.12.4 dmac module stop depending on the operating status of the dmac, the mstpa7 bit may not be set to 1. setting of the dmac module stop mode should be carried out only when the dmac is not activated. for details, section 7, dma controller (dmac). 20.12.5 on-chip peripheral module interrupt ? module stop mode relevant interrupt operations cannot be performed in module stop mode. consequently, if module stop mode is entered when an interrupt has been requested, it will not be possible to clear the cpu interrupt source or dmac activation source. interrupts should therefore be disabled before setting module stop mode. ? subactive mode/watch mode on-chip peripheral modules (dmac and tpu) that stop operation in subactive mode cannot clear interrupts in subactive mode. therefore, if subactive mode is entered when an interrupt is requested, cpu interrupt factors cannot be cleared. interrupts should therefore before executing the sleep instruction and entering subactive or watch mode. section 20 power-down modes rev.6.00 jun. 03, 2008 page 629 of 698 rej09b0074-0600 20.12.6 entering subactive/watch mode and dmac and dtc module stop to enter subactive or watch mode, set dmac to module stop (write 1 to the mstpa7 bit) and reading the mstpa7 bit as 1 before transiting mode. after transiting from subactive mode to active mode, clear module stop. when a dmac activation source is generated in subactive mode, the dmac is activated when module stop is cleared following the transition to active mode. 20.12.7 writing to mstpcr mstpcr should only be written to by the cpu. section 20 power-down modes rev.6.00 jun. 03, 2008 page 630 of 698 rej09b0074-0600 section 21 list of registers rev.6.00 jun. 03, 2008 page 631 of 698 rej09b0074-0600 section 21 list of registers the register list gives information on the on-chip i/o register addresses, how the register bits are configured, and the register states in each operating mode. the information is given as shown below. 1. register addresses (address order) ? registers are listed from the lower allocation addresses. ? registers are classified by functional modules. ? the access size is indicated. 2. register bits ? bit configurations of the registers are described in the same order as the register addresses (address order) above. ? reserved bits are indicated by ? ? ? in the bit name column. ? the bit number in the bit-name column indicates that the whole register is allocated as a counter or for holding data. ? 16-bit or 24-bit registers are indicated from the bit on the msb side. 3. register states in each operating mode ? register states are described in the same order as the register addresses (address order) above. ? the register states described here are for the basic operating modes. if there is a specific reset for an on-chip peripheral module, refer to the section on that on-chip peripheral module. section 21 list of registers rev.6.00 jun. 03, 2008 page 632 of 698 rej09b0074-0600 21.1 register addresses (address order) the data bus width indicates the numbers of bits by which the register is accessed. the number of access states indicates the number of states based on the specified reference clock. register name abbreviation number of bits address data bus width number of access states module usb reserved area ? ? h'c00000 to h'c0007f ? ? usb usb control register uctlr 8 h'c00080 8 3 usb test register a utstra 8 h'c00081 8 3 usb dmac transfer request register udmar 8 h'c00082 8 3 usb device resume register udrr 8 h'c00083 8 3 usb trigger register 0 utrg0 8 h'c00084 8 3 usb fifo clear register 0 ufclr0 8 h'c00086 8 3 usb endpoint stall register 0 uestl0 8 h'c00088 8 3 usb endpoint stall register 1 uestl1 8 h'c00089 8 3 usb endpoint data register 0s uedr0s 8 h'c00090 to h'c00093 8 3 usb endpoint data register 0i uedr0i 8 h'c00094 to h'c00097 8 3 usb endpoint data register 0o uedr0o 8 h'c00098 to h'c0009b 8 3 usb endpoint data register 3 uedr3 8 h'c0009c to h'c0009f 8 3 usb endpoint data register 1 uedr1 8 h'c000a0 to h'c000a3 8 3 usb endpoint data register 2 uedr2 8 h'c000a4 to h'c000a7 8 3 section 21 list of registers rev.6.00 jun. 03, 2008 page 633 of 698 rej09b0074-0600 register name abbreviation number of bits address data bus width number of access states module usb endpoint receive data size register 0o uesz0o 8 h'c000bc 8 3 usb endpoint receive data size register 2 uesz2 8 h'c000bd 8 3 usb interrupt flag register 0 uifr0 8 h'c000c0 8 3 usb interrupt flag register 1 uifr1 8 h'c000c1 8 3 usb interrupt flag register 3 uifr3 8 h'c000c3 8 3 usb interrupt enable register 0 uier0 8 h'c000c4 8 3 usb interrupt enable register 1 uier1 8 h'c000c5 8 3 usb interrupt enable register 3 uier3 8 h'c000c7 8 3 usb interrupt selection register 0 uisr0 8 h'c000c8 8 3 usb interrupt selection register 1 uisr1 8 h'c000c9 8 3 usb interrupt selection register 3 uisr3 8 h'c000cb 8 3 usb data status register udsr 8 h'c000cc 8 3 usb configuration value register ucvr 8 h'c000cf 8 3 usb test register 0 utstr0 8 h'c000f0 8 3 usb test register 1 utstr1 8 h'c000f1 8 3 usb test register 2 utstr2 8 h'c000f2 8 3 usb test register b utstrb 8 h'c000fb 8 3 usb test register c utstrc 8 h'c000fc 8 3 usb test register d utstrd 8 h'c000fd 8 3 usb test register e utstre 8 h'c000fe 8 3 usb test register f utstrf 8 h'c000ff 8 3 usb reserved area ? ? h'c00100 to h'dfffff ? ? usb serial control register x scrx 8 h?fdb4 8 2 flash section 21 list of registers rev.6.00 jun. 03, 2008 page 634 of 698 rej09b0074-0600 register name abbreviation number of bits address data bus width number of access states module standby control register sbycr 8 h?fde4 8 2 system control register syscr 8 h?fde5 8 2 system clock control register sckcr 8 h?fde6 8 2 mode control register mdcr 8 h?fde7 8 2 module stop control register a mstpcra 8 h?fde8 8 2 module stop control register b mstpcrb 8 h?fde9 8 2 module stop control register c mstpcrc 8 h?fdea 8 2 system pin function control register pfcr 8 h?fdeb 8 2 bsc low power control register lpwrcr 8 h?fdec 8 2 system clock output control register outcr 8 h?fdef 8 2 port serial extended mode register a_0 semra_0 8 h?fdf8 8 2 serial extended mode register b_0 semrb_0 8 h?fdf9 8 2 sci_0 irq sense control register h iscrh 8 h?fe12 8 2 irq sense control register l iscrl 8 h?fe13 8 2 irq enable register ier 8 h?fe14 8 2 irq status register isr 8 h?fe15 8 2 int port 1 data direction register p1ddr 8 h?fe30 8 2 port port 3 data direction register p3ddr 8 h?fe32 8 2 port 7 data direction register p7ddr 8 h?fe36 8 2 port a data direction register paddr 8 h'fe39 8 2 port b data direction register pbddr 8 h'fe3a 8 2 port c data direction register pcddr 8 h'fe3b 8 2 port d data direction register pdddr 8 h'fe3c 8 2 port e data direction register peddr 8 h'fe3d 8 2 port f data direction register pfddr 8 h'fe3e 8 2 port g data direction register pgddr 8 h'fe3f 8 2 port a pull-up mos control register papcr 8 h'fe40 8 2 port b pull-up mos control register pbpcr 8 h'fe41 8 2 port c pull-up mos control register pcpcr 8 h'fe42 8 2 port d pull-up mos control register pdpcr 8 h'fe43 8 2 port e pull-up mos control register pepcr 8 h'fe44 8 2 port 3 open drain control register p3odr 8 h'fe46 8 2 port a open drain control register paodr 8 h'fe47 8 2 section 21 list of registers rev.6.00 jun. 03, 2008 page 635 of 698 rej09b0074-0600 register name abbreviation number of bits address data bus width number of access states module timer start register tstr 8 h'feb0 16 2 timer synchro register tsyr 8 h'feb1 16 2 tpu interrupt priority register a ipra 8 h'fec0 8 2 interrupt priority register b iprb 8 h'fec1 8 2 interrupt priority register c iprc 8 h'fec2 8 2 interrupt priority register d iprd 8 h'fec3 8 2 interrupt priority register e ipre 8 h'fec4 8 2 interrupt priority register f iprf 8 h'fec5 8 2 interrupt priority register g iprg 8 h'fec6 8 2 interrupt priority register j iprj 8 h'fec9 8 2 interrupt priority register k iprk 8 h'feca 8 2 interrupt priority register m iprm 8 h'fecc 8 2 int bus width control register abwcr 8 h'fed0 8 2 access state control register astcr 8 h'fed1 8 2 wait control register h wcrh 8 h'fed2 8 2 wait control register l wcrl 8 h'fed3 8 2 bus control register h bcrh 8 h'fed4 8 2 bus control register l bcrl 8 h'fed5 8 2 bsc ram emulation register ramer 8 h'fedb 8 2 flash memory address register 0a h mar0ah 16 h'fee0 16 2 dmac memory address register 0a l mar0al 16 h'fee2 16 2 i/o address register 0a ioar0a 16 h'fee4 16 2 transfer count register 0a etcr0a 16 h'fee6 16 2 memory address register 0b h mar0bh 16 h'fee8 16 2 memory address register 0b l mar0bl 16 h'feea 16 2 i/o address register 0b ioar0b 16 h'feec 16 2 transfer count register 0b etcr0b 16 h'feee 16 2 memory address register 1a h mar1ah 16 h'fef0 16 2 memory address register 1a l mar1al 16 h'fef2 16 2 i/o address register 1a ioar1a 16 h'fef4 16 2 transfer count register 1a etcr1a 16 h'fef6 16 2 memory address register 1b h mar1bh 16 h'fef8 16 2 memory address register 1b l mar1bl 16 h'fefa 16 2 section 21 list of registers rev.6.00 jun. 03, 2008 page 636 of 698 rej09b0074-0600 register name abbreviation number of bits address data bus width number of access states module i/o address register 1b ioar1b 16 h'fefc 16 2 dmac transfer count register 1b etcr1b 16 h'fefe 16 2 port 1 data register p1dr 8 h'ff00 8 2 port 3 data register p3dr 8 h'ff02 8 2 port 7 data register p7dr 8 h'ff06 8 2 port a data register padr 8 h'ff09 8 2 port b data register pbdr 8 h'ff0a 8 2 port c data register pcdr 8 h'ff0b 8 2 port d data register pddr 8 h'ff0c 8 2 port e data register pedr 8 h'ff0d 8 2 port f data register pfdr 8 h'ff0e 8 2 port g data register pgdr 8 h'ff0f 8 2 port timer control register_0 tcr_0 8 h'ff10 16 2 timer mode register_0 tmdr_0 8 h'ff11 16 2 timer i/o control register h_0 tiorh_0 8 h'ff12 16 2 timer i/o control register l_0 tiorl_0 8 h'ff13 16 2 timer interrupt enable register_0 tier_0 8 h'ff14 16 2 timer status register_0 tsr_0 8 h'ff15 16 2 timer counter_0 tcnt_0 16 h'ff16 16 2 timer general register a_0 tgra_0 16 h'ff18 16 2 timer general register b_0 tgrb_0 16 h'ff1a 16 2 timer general register c_0 tgrc_0 16 h'ff1c 16 2 timer general register d_0 tgrd_0 16 h'ff1e 16 2 tpu_0 timer control register_1 tcr_1 8 h'ff20 16 2 tpu_1 timer mode register_1 tmdr_1 8 h'ff21 16 2 timer i/o control register _1 tior_1 8 h'ff22 16 2 timer interrupt enable register _1 tier_1 8 h'ff24 16 2 timer status register_1 tsr_1 8 h'ff25 16 2 timer counter_1 tcnt_1 16 h'ff26 16 2 timer general register a_1 tgra_1 16 h'ff28 16 2 timer general register b_1 tgrb_1 16 h'ff2a 16 2 section 21 list of registers rev.6.00 jun. 03, 2008 page 637 of 698 rej09b0074-0600 register name abbreviation number of bits address data bus width number of access states module timer control register_2 tcr_2 8 h'ff30 16 2 timer mode register_2 tmdr_2 8 h'ff31 16 2 timer i/o control register 2 tior_2 8 h'ff32 16 2 timer interrupt enable register 2 tier_2 8 h'ff34 16 2 timer status register_2 tsr_2 8 h'ff35 16 2 timer counter_2 tcnt_2 16 h'ff36 16 2 timer general register a_2 tgra_2 16 h'ff38 16 2 timer general register b_2 tgrb_2 16 h'ff3a 16 2 tpu_2 extended module stop register exmdlstp 8 h'ff40 8 2 system second data register/ free running counter data register rsecdr 8 h'ff48 8 2 minute data register rmindr 8 h'ff49 8 2 hour data register rhrdr 8 h'ff4a 8 2 day-of-week data register rwkdr 8 h'ff4b 8 2 rtc control register 1 rtccr1 8 h'ff4c 8 2 rtc control register 2 rtccr2 8 h'ff4d 8 2 clock source select register rtccsr 8 h'ff4f 8 2 rtc dma control register 0a dmacr0a 8 h'ff62 16 2 dma control register 0b dmacr0b 8 h'ff63 16 2 dma control register 1a dmacr1a 8 h?ff64 16 2 dma control register 1b dmacr1b 8 h?ff65 16 2 dma band control register dmabcr 16 h?ff66 16 2 dmac timer control/status register tcsr 8 h'ff74 16 2 wdt timer counter tcnt 8 h'ff74 (write) 16 2 timer counter tcnt 8 h'ff75 (read) 16 2 reset control/status register rstcsr 8 h'ff76 (write) 16 2 reset control/status register rstcsr 8 h'ff77 (read) 16 2 section 21 list of registers rev.6.00 jun. 03, 2008 page 638 of 698 rej09b0074-0600 register name abbreviation number of bits address data bus width number of access states module serial mode register_0 smr_0 8 h'ff78 8 2 sci_0 bit rate register_0 brr_0 8 h'ff79 8 2 serial control register_0 scr_0 8 h'ff7a 8 2 transmit data register_0 tdr_0 8 h'ff7b 8 2 serial status register_0 ssr_0 8 h'ff7c 8 2 receive data register_0 rdr_0 8 h'ff7d 8 2 smart card mode register_0 scmr_0 8 h'ff7e 8 2 serial mode register_2 smr_2 8 h'ff88 8 2 bit rate register_2 brr_2 8 h'ff89 8 2 serial control register_2 scr_2 8 h'ff8a 8 2 transmit data register_2 tdr_2 8 h'ff8b 8 2 serial status register_2 ssr_2 8 h'ff8c 8 2 receive data register_2 rdr_2 8 h'ff8d 8 2 smart card mode register_2 scmr_2 8 h'ff8e 8 2 sci_2 a/d data register ah addrah 8 h'ff90 8 2 a/d data register al addral 8 h'ff91 8 2 a/d data register bh addrbh 8 h'ff92 8 2 a/d data register bl addrbl 8 h'ff93 8 2 a/d data register ch addrch 8 h'ff94 8 2 a/d data register cl addrcl 8 h'ff95 8 2 a/d data register dh addrdh 8 h'ff96 8 2 a/d data register dl addrdl 8 h'ff97 8 2 a/d control/status register adcsr 8 h'ff98 8 2 a/d control register adcr 8 h'ff99 8 2 a/d timer control/status register tcsr_1 8 h'ffa2 16 2 system flash memory control register 1 flmcr1 8 h'ffa8 8 2 flash flash memory control register 2 flmcr2 8 h'ffa9 8 2 erase block register 1 ebr1 8 h'ffaa 8 2 erase block register 2 ebr2 8 h'ffab 8 2 section 21 list of registers rev.6.00 jun. 03, 2008 page 639 of 698 rej09b0074-0600 register name abbreviation number of bits address data bus width number of access states module port 1 register port1 8 h'ffb0 8 2 port port 3 register port3 8 h'ffb2 8 2 port 4 register port4 8 h'ffb3 8 2 port 7 register port7 8 h'ffb6 8 2 port 9 register port9 8 h'ffb8 8 2 port a register porta 8 h'ffb9 8 2 port b register portb 8 h'ffba 8 2 port c register portc 8 h'ffbb 8 2 port d register portd 8 h'ffbc 8 2 port e register porte 8 h'ffbd 8 2 port f register portf 8 h'ffbe 8 2 port g register portg 8 h'ffbf 8 2 section 21 list of registers rev.6.00 jun. 03, 2008 page 640 of 698 rej09b0074-0600 21.2 register bits register bit names of the on-chip peripheral modules are described below. each line covers eight bits, so 16-bit registers are shown as two lines and 32-bit registers as four lines. register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module uctlr ? uspnde ucks3 ucks2 ucks1 ucks0 uifrst udcrst usb utstra ? ? ? ? ? ? ? ? udmar ? ? ? ? ep2t1 ep2t0 ep1t1 ep1t0 udrr ? ? ? ? ? ? rwups dvr utrg0 ? ? ep2rdfn ep1pkte ep3pkte ep0ordfn ep0ipkte ep0srdfn ufclr0 ? ? ep2clr ep1clr ep3clr ep0oclr ep0iclr ? uestl0 ? ? ep2stl ep1stl ep3stl ? ? ep0stl uestl1 scme ? ? ? ? ? ? ? uedr0s d7 d6 d5 d4 d3 d2 d1 d0 uedr0i d7 d6 d5 d4 d3 d2 d1 d0 uedr0o d7 d6 d5 d4 d3 d2 d1 d0 uedr3 d7 d6 d5 d4 d3 d2 d1 d0 uedr1 d7 d6 d5 d4 d3 d2 d1 d0 uedr2 d7 d6 d5 d4 d3 d2 d1 d0 uesz0o ? d6 d5 d4 d3 d2 d1 d0 uesz2 ? d6 d5 d4 d3 d2 d1 d0 uifr0 brst ? ep3tr ep3ts ep0ots ep0itr ep0its setupts uifr1 ? ? ? ? ep1all emptys ep2 ready ep1tr ep1 empty uifr3 ck48 ready sof setc ? sprss sprsi vbuss vbusi uier0 brste ? ep3tre ep3tse ep0otse ep0itre ep0itse setuptse uier1 ? ? ? ? ? ep2 readye ep1tre ep1 emptye uier3 ck48 readye sofe setce ? ? sprsie ? vbusie uisr0 brsts ? ep3trs ep3tss ep0otss ep0itrs ep0itss setuptss section 21 list of registers rev.6.00 jun. 03, 2008 page 641 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module uisr1 ? ? ? ? ? ep2 readys ep1trs ep1 emptys usb uisr3 ck48 readys sofs setcs ? ? ? ? vbusis udsr ? ? ? ? ? ep1de ep3de ep0ide ucvr ? ? cnfv0 ? ? ? ? ? utstr0 ptste ? ? ? suspend oe fse0 vpo utstr1 vbus ubpm ? ? ? rcv vp vm utstr2 ? ? ? ? ? ? ? ? utstrb ? ? ? ? ? ? ? ? utstrc ? ? ? ? ? ? ? ? utstrd ? ? ? ? ? ? ? ? utstre ? ? ? ? ? ? ? ? utstrf ? ? ? ? ? ? ? ? scrx ? ? ? ? flshe ? ? ? flash sbycr ssby sts2 sts1 sts0 ope ? ? ? system syscr ? ? intm1 intm0 nmieg mrese ? rame sckcr pstop ? ? ? ? sck2 sck1 sck0 mdcr ? ? ? ? fwe mds2 mds1 mds0 mstpcra mstpa7 mstpa6 mstpa5 mstpa4 mstpa3 mstpa2 mstpa1 mstpa0 mstpcrb mstpb7 mstpb6 mstpb5 mstpb4 mstpb3 mstpb2 mstpb1 mstpb0 mstpcrc mstpc7 mstpc6 mstpc5 mstpc4 mstpc3 mstpc2 mstpc1 mstpc0 pfcr ? ? ? ? ae3 ae2 ae1 ae0 bsc lpwrcr dton lson nesel substp rfcut ? stc1 stc0 system outcr ? ? ? ? ? pf7out2 pf7out1 pf7out0 port semra_0 sse tcs2 tcs1 tcs0 abc s acs2 acs1 acs0 sci_0 semrb_0 acs3 ? ? ? tioca2e tioca1e tiocc0e tioca0e iscrh irq7scb irq7sca irq6scb irq6sca irq5scb irq5sca irq4scb irq4sca int iscrl irq3scb irq3sca irq2scb irq2sca irq1scb irq1sca irq0scb irq0sca ier irq7e irq6e irq5e irq4e irq3e irq2e irq1e irq0e isr irq7f irq6f irq5f irq4f irq3f irq2f irq1f irq0f section 21 list of registers rev.6.00 jun. 03, 2008 page 642 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module p1ddr p17ddr p16ddr p15ddr p14ddr p 13ddr p12ddr p11ddr p10ddr port p3ddr ? p36ddr ? ? ? p32ddr p31ddr p30ddr p7ddr p77ddr p76ddr p75ddr p74ddr ? ? p71ddr p70ddr paddr ? ? ? ? pa3ddr pa2ddr pa1ddr pa0ddr pbddr pb7ddr pb6ddr pb5ddr pb4ddr pb3ddr pb2ddr pb1ddr pb0ddr pcddr pc7ddr pc6ddr pc5ddr pc4ddr pc3ddr pc2ddr pc1ddr pc0ddr pdddr pd7ddr pd6ddr pd5ddr pd4ddr pd3ddr pd2ddr pd1ddr pd0ddr peddr pe7ddr pe6ddr pe5ddr pe4ddr pe3ddr pe2ddr pe1ddr pe0ddr pfddr pf7ddr pf6ddr pf5ddr pf4ddr pf3ddr pf2ddr pf1ddr pf0ddr pgddr ? ? ? pg4ddr pg3ddr pg2ddr pg1ddr pg0ddr papcr ? ? ? ? pa3pcr pa2pcr pa1pcr pa0pcr pbpcr pb7pcr pb6pcr pb5pcr pb4pcr pb3pcr pb2pcr pb1pcr pb0pcr pcpcr pc7pcr pc6pcr pc5pcr pc4pcr pc3pcr pc2pcr pc1pcr pc0pcr pdpcr pd7pcr pd6pcr pd5pcr pd4pcr pd3pcr pd2pcr pd1pcr pd0pcr pepcr pe7pcr pe6pcr pe5pcr pe4pcr pe3pcr pe2pcr pe1pcr pe0pcr p3odr ? p36odr ? ? ? p32odr p31odr p30odr paodr ? ? ? ? pa3odr pa2odr pa1odr pa0odr tstr ? ? ? ? ? cst2 cst1 cst0 tpu tsyr ? ? ? ? ? sync2 sync1 sync0 ipra ? ipra6 ipra5 ipra4 ? ipra2 ipra1 ipra0 int iprb ? iprb6 iprb5 iprb4 ? iprb2 iprb1 iprb0 iprc ? iprc6 iprc5 iprc4 ? ? ? ? iprd ? iprd6 iprd5 iprd4 ? ? ? ? ipre ? ? ? ? ? ipre2 ipre1 ipre0 iprf ? iprf6 iprf5 iprf4 ? iprf2 iprf1 iprf0 iprg ? iprg6 iprg5 iprg4 ? ? ? ? iprj ? iprj6 iprj5 iprj4 ? iprj2 iprj1 iprj0 iprk ? ? ? ? ? iprk2 iprk1 iprk0 iprm ? iprm6 iprm5 iprm4 ? ? ? ? section 21 list of registers rev.6.00 jun. 03, 2008 page 643 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module abwcr abw7 abw6 abw5 abw4 abw3 abw2 abw1 abw0 bsc astcr ast7 ast6 ast5 ast4 ast3 ast2 ast1 ast0 wcrh w71 w70 w61 w60 w51 w50 w41 w40 wcrl w31 w30 w21 w20 w11 w10 w01 w00 bcrh icis1 icis0 brstrm brsts1 brsts0 rmts2 rmts1 rmts0 bcrl brle ? ? ? ? ? ? waite ramer ? ? ? ? rams ? ram1 ram0 flash mar0a ? ? ? ? ? ? ? ? dmac bit 23 bit 22 bit 21 bit 20 bit 19 bit 18 bit 17 bit 16 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ioar0a bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 etcr0a bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mar0b ? ? ? ? ? ? ? ? bit 23 bit 22 bit 21 bit 20 bit 19 bit 18 bit 17 bit 16 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ioar0b bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 etcr0b bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mar1a ? ? ? ? ? ? ? ? bit 23 bit 22 bit 21 bit 20 bit 19 bit 18 bit 17 bit 16 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ioar1a bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 etcr1a bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 section 21 list of registers rev.6.00 jun. 03, 2008 page 644 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module mar1b ? ? ? ? ? ? ? ? dmac bit 23 bit 22 bit 21 bit 20 bit 19 bit 18 bit 17 bit 16 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ioar1b bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 etcr1b bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1dr p17dr p16dr p15dr p14dr p 13dr p12dr p11dr p10dr port p3dr ? p36dr ? ? ? p32dr p31dr p30dr p7dr p77dr p76dr p75dr p74dr ? ? p71dr p70dr padr ? ? ? ? pa3dr pa2dr pa1dr pa0dr pbdr pb7dr pb6dr pb5dr pb4dr pb3dr pb2dr pb1dr pb0dr pcdr pc7dr pc6dr pc5dr pc4dr pc3dr pc2dr pc1dr pc0dr pddr pd7dr pd6dr pd5dr pd4dr pd3dr pd2dr pd1dr pd0dr pedr pe7dr pe6dr pe5dr pe4dr pe3dr pe2dr pe1dr pe0dr pfdr pf7dr pf6dr pf5dr pf4dr pf3dr pf2dr pf1dr pf0dr pgdr ? ? ? pg4dr pg3dr pg2dr pg1dr pg0dr tcr_0 cclr2 cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 tpu_0 tmdr_0 ? ? bfb bfa md3 md2 md1 md0 tiorh_0 iob3 iob2 iob1 iob0 ioa3 ioa2 ioa1 ioa0 tiorl_0 iod3 iod2 iod1 iod 0 ioc3 ioc2 ioc1 ioc0 tier_0 ttge ? ? tciev tgied tgiec tgieb tgiea tsr_0 ? ? ? tcfv tgfd tgfc tgfb tgfa bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tcnt_0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tgra_0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tgrb_0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 section 21 list of registers rev.6.00 jun. 03, 2008 page 645 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tpu_0 tgrc_0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tgrd_0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tcr_1 ? cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 tpu_1 tmdr_1 ? ? ? ? md3 md2 md1 md0 tior_1 iob3 iob2 iob1 iob0 ioa3 ioa2 ioa1 ioa0 tier_1 ttge ? tcieu tciev ? ? tgieb tgiea tsr_1 tcfd ? tcfu tcfv ? ? tgfb tgfa bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tcnt_1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tgra_1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tgrb_1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tcr_2 ? cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 tpu_2 tmdr_2 ? ? ? ? md3 md2 md1 md0 tior_2 iob3 iob2 iob1 iob0 ioa3 ioa2 ioa1 ioa0 tier_2 ttge ? tcieu tciev ? ? tgieb tgiea tsr_2 tcfd ? tcfu tcfv ? ? tgfb tgfa bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tcnt_2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tgra_2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tgrb_2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 exmdlstp ? ? ? ? ? ? rtcstop usbstop1 system section 21 list of registers rev.6.00 jun. 03, 2008 page 646 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module rsecdr bsy sc12 sc11 sc10 sc03 sc02 sc01 sc00 rtc rmindr bsy mn12 mn11 mn10 mn03 mn02 mn01 mn00 rhrdr bsy ? hr11 hr10 hr03 hr02 hr01 hr00 rwkdr bsy ? ? ? ? wk2 wk1 kwk0 rtccr1 run 12/24 pm rst ? ? ? ? rtccr2 ? ? foie wkie dyie hrie mnie seie rtccsr ? rcs6 rcs5 ? rcs3 rcs2 rcs1 rcs0 dmacr0a * 1 dtsz dtid rpe dtdir dtf3 dtf2 dtf1 dtf0 dmac dmacr0a * 2 dtsz said saide blkdir blke ? ? ? dmacr0b * 1 dtsz dtid rpe dtdir dtf3 dtf2 dtf1 dtf0 dmacr0b * 2 ? daid daide ? dtf3 dtf2 dtf1 dtf0 dmacr1a * 1 dtsz dtid rpe dtdir dtf3 dtf2 dtf1 dtf0 dmacr1a * 2 dtsz said saide blkdir blke ? ? ? dmacr1b * 1 dtsz dtid rpe dtdir dtf3 dtf2 dtf1 dtf0 dmacr1b * 2 ? daid daide ? dtf3 dtf2 dtf1 dtf0 dmabcr * 1 fae1 fae0 ? ? dta1b dta1a dta0b dta0a dte1b dte1a dte0b dte0a dtie1b dtie1a dtie0b dtie0a dmabcr * 2 fae1 fae0 ? ? dta1 ? dta0 ? dtme1 dte1 dtme0 dte0 dtie1b dtie1a dtie0b dtie0a tcsr ovf wt/ it tme ? ? cks2 cks1 cks0 wdt tcnt bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rstcsr wovf rste rsts ? ? ? ? ? smr_0 c/ a chr pe o/ e stop mp cks1 cks0 sci_0 smr_0 * 3 gm blk pe o/ e bcp1 bcp0 cks1 cks0 brr_0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 scr_0 tie rie te re mpie teie cke1 cke0 tdr_0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ssr_0 tdre rdrf orer fer per tend mpb mpbt ssr_0 * 3 tdre rdrf orer ers per tend mpb mpbt rdr_0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 scmr_0 ? ? ? ? sdir sinv ? smif section 21 list of registers rev.6.00 jun. 03, 2008 page 647 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module smr_2 c/ a chr pe o/ e stop mp cks1 cks0 sci_2 smr_2 * 3 gm blk pe o/ e bcp1 bcp0 cks1 cks0 brr_2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 scr_2 tie rie te re mpie teie cke1 cke0 tdr_2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ssr_2 tdre rdrf orer fer per tend mpb mpbt ssr_2 * 3 tdre rdrf orer ers per tend mpb mpbt rdr_2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 scmr_2 ? ? ? ? sdir sinv ? smif addrah ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 a/d addral ad1 ad0 ? ? ? ? ? ? addrbh ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 addrbl ad1 ad0 ? ? ? ? ? ? addrch ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 addrcl ad1 ad0 ? ? ? ? ? ? addrdh ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 addrdl ad1 ad0 ? ? ? ? ? ? adcsr adf adie adst scan ? ch2 ch1 ch0 adcr trgs1 trgs0 ? ? cks1 cks0 ? ? tcsr_1 ? ? ? pss ? ? ? ? system flmcr1 fwe swe1 esu1 psu1 ev1 pv1 e1 p1 flash flmcr2 fler ? ? ? ? ? ? ? ebr1 eb7 eb6 eb5 eb4 eb3 eb2 eb1 eb0 ebr2 ? ? ? ? ? ? eb9 eb8 section 21 list of registers rev.6.00 jun. 03, 2008 page 648 of 698 rej09b0074-0600 register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module port1 p17 p16 p15 p14 p13 p12 p11 p10 port port3 ? p36 ? ? ? p32 p31 p30 port4 ? ? ? ? p43 p42 p41 p40 port7 p77 p76 p75 p74 ? ? p71 p70 port9 p97 p96 ? ? ? ? ? ? porta ? ? ? ? pa3 pa2 pa1 pa0 portb pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 portc pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 portd pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 porte pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 portf pf7 pf6 pf5 pf4 pf3 pf2 pf1 pf0 portg ? ? ? pg4 pg3 pg2 pg1 pg0 notes: 1. short address mode 2. full address mode 3. smart card interface section 21 list of registers rev.6.00 jun. 03, 2008 page 649 of 698 rej09b0074-0600 21.3 register states in each operating mode register name power-on reset manual reset high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby module uctlr initialized * ? ? ? ? ? ? ? ? ? initialized usb utstra initialized * ? ? ? ? ? ? ? ? ? initialized udmar initialized * ? ? ? ? ? ? ? ? ? initialized udrr initialized * ? ? ? ? ? ? ? ? ? initialized utrg0 initialized * ? ? ? ? ? ? ? ? ? initialized ufclr0 initialized * ? ? ? ? ? ? ? ? ? initialized uestl0 initialized * ? ? ? ? ? ? ? ? ? initialized uestl1 initialized * ? ? ? ? ? ? ? ? ? initialized uedr0s ? * ? ? ? ? ? ? ? ? ? ? uedr0i initialized * ? ? ? ? ? ? ? ? ? initialized uedr0o ? * ? ? ? ? ? ? ? ? ? ? uedr3 initialized * ? ? ? ? ? ? ? ? ? initialized uedr1 initialized * ? ? ? ? ? ? ? ? ? initialized uedr2 ? * ? ? ? ? ? ? ? ? ? ? uesz0o ? * ? ? ? ? ? ? ? ? ? ? uesz2 ? * ? ? ? ? ? ? ? ? ? ? uifr0 initialized * ? ? ? ? ? ? ? ? ? initialized uifr1 initialized * ? ? ? ? ? ? ? ? ? initialized uifr3 initialized * ? ? ? ? ? ? ? ? ? initialized uier0 initialized * ? ? ? ? ? ? ? ? ? initialized uier1 initialized * ? ? ? ? ? ? ? ? ? initialized uier3 initialized * ? ? ? ? ? ? ? ? ? initialized uisr0 initialized * ? ? ? ? ? ? ? ? ? initialized uisr1 initialized * ? ? ? ? ? ? ? ? ? initialized uisr3 initialized * ? ? ? ? ? ? ? ? ? initialized udsr initialized * ? ? ? ? ? ? ? ? ? initialized ucvr initialized * ? ? ? ? ? ? ? ? ? initialized section 21 list of registers rev.6.00 jun. 03, 2008 page 650 of 698 rej09b0074-0600 register name power-on reset manual reset high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby module utstr0 initialized * ? ? ? ? ? ? ? ? ? initialized usb utstr1 initialized * ? ? ? ? ? ? ? ? ? initialized utstr2 initialized * ? ? ? ? ? ? ? ? ? initialized utstrb initialized * ? ? ? ? ? ? ? ? ? initialized utstrc initialized * ? ? ? ? ? ? ? ? ? initialized utstrd initialized * ? ? ? ? ? ? ? ? ? initialized utstre initialized * ? ? ? ? ? ? ? ? ? initialized utstrf initialized * ? ? ? ? ? ? ? ? ? initialized scrx initialized initialized ? ? ? ? ? ? ? ? initialized flash sbycr initialized initialized ? ? ? ? ? ? ? ? initialized system syscr initialized initialized ? ? ? ? ? ? ? ? initialized sckcr initialized initialized ? ? ? ? ? ? ? ? initialized mdcr initialized ? ? ? ? ? ? ? ? ? initialized mstpcra initialized initialized ? ? ? ? ? ? ? ? initialized mstpcrb initialized initialized ? ? ? ? ? ? ? ? initialized mstpcrc initialized initialized ? ? ? ? ? ? ? ? initialized pfcr initialized ? ? ? ? ? ? ? ? ? initialized bsc lpwrcr initialized ? ? ? ? ? ? ? ? ? initialized system outcr initialized initialized ? ? ? ? ? ? ? ? initialized port semra_0 initialized initialized ? ? ? ? ? ? ? ? initialized sci_0 semrb_0 initialized initialized ? ? ? ? ? ? ? ? initialized iscrh initialized initialized ? ? ? ? ? ? ? ? initialized int iscrl initialized initialized ? ? ? ? ? ? ? ? initialized ier initialized initialized ? ? ? ? ? ? ? ? initialized isr initialized initialized ? ? ? ? ? ? ? ? initialized p1ddr initialized ? ? ? ? ? ? ? ? ? initialized port p3ddr initialized ? ? ? ? ? ? ? ? ? initialized p7ddr initialized ? ? ? ? ? ? ? ? ? initialized paddr initialized ? ? ? ? ? ? ? ? ? initialized pbddr initialized ? ? ? ? ? ? ? ? ? initialized pcddr initialized ? ? ? ? ? ? ? ? ? initialized section 21 list of registers rev.6.00 jun. 03, 2008 page 651 of 698 rej09b0074-0600 register name power-on reset manual reset high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby module pdddr initialized ? ? ? ? ? ? ? ? ? initialized port peddr initialized ? ? ? ? ? ? ? ? ? initialized pfddr initialized ? ? ? ? ? ? ? ? ? initialized pgddr initialized ? ? ? ? ? ? ? ? ? initialized papcr initialized ? ? ? ? ? ? ? ? ? initialized pbpcr initialized ? ? ? ? ? ? ? ? ? initialized pcpcr initialized ? ? ? ? ? ? ? ? ? initialized pdpcr initialized ? ? ? ? ? ? ? ? ? initialized pepcr initialized ? ? ? ? ? ? ? ? ? initialized p3odr initialized ? ? ? ? ? ? ? ? ? initialized paodr initialized ? ? ? ? ? ? ? ? ? initialized tstr initialized initialized ? ? ? ? ? ? ? ? initialized tpu tsyr initialized initialized ? ? ? ? ? ? ? ? initialized ipra initialized initialized ? ? ? ? ? ? ? ? initialized int iprb initialized initialized ? ? ? ? ? ? ? ? initialized iprc initialized initialized ? ? ? ? ? ? ? ? initialized iprd initialized initialized ? ? ? ? ? ? ? ? initialized ipre initialized initialized ? ? ? ? ? ? ? ? initialized iprf initialized initialized ? ? ? ? ? ? ? ? initialized iprg initialized initialized ? ? ? ? ? ? ? ? initialized iprj initialized initialized ? ? ? ? ? ? ? ? initialized iprk initialized initialized ? ? ? ? ? ? ? ? initialized iprm initialized initialized ? ? ? ? ? ? ? ? initialized abwcr initialized ? ? ? ? ? ? ? ? ? initialized bsc astcr initialized ? ? ? ? ? ? ? ? ? initialized wcrh initialized ? ? ? ? ? ? ? ? ? initialized wcrl initialized ? ? ? ? ? ? ? ? ? initialized bcrh initialized ? ? ? ? ? ? ? ? ? initialized bcrl initialized ? ? ? ? ? ? ? ? ? initialized ramer initialized ? ? ? ? ? ? ? ? ? initialized flash section 21 list of registers rev.6.00 jun. 03, 2008 page 652 of 698 rej09b0074-0600 register name power-on reset manual reset high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby module mar0a ? ? ? ? ? ? ? ? ? ? ? dmac ioar0a ? ? ? ? ? ? ? ? ? ? ? etcr0a ? ? ? ? ? ? ? ? ? ? ? mar0b ? ? ? ? ? ? ? ? ? ? ? ioar0b ? ? ? ? ? ? ? ? ? ? ? etcr0b ? ? ? ? ? ? ? ? ? ? ? mar1a ? ? ? ? ? ? ? ? ? ? ? ioar1a ? ? ? ? ? ? ? ? ? ? ? etcr1a ? ? ? ? ? ? ? ? ? ? ? mar1b ? ? ? ? ? ? ? ? ? ? ? ioar1b ? ? ? ? ? ? ? ? ? ? ? etcr1b ? ? ? ? ? ? ? ? ? ? ? p1dr initialized ? ? ? ? ? ? ? ? ? initialized port p3dr initialized ? ? ? ? ? ? ? ? ? initialized p7dr initialized ? ? ? ? ? ? ? ? ? initialized padr initialized ? ? ? ? ? ? ? ? ? initialized pbdr initialized ? ? ? ? ? ? ? ? ? initialized pcdr initialized ? ? ? ? ? ? ? ? ? initialized pddr initialized ? ? ? ? ? ? ? ? ? initialized pedr initialized ? ? ? ? ? ? ? ? ? initialized pfdr initialized ? ? ? ? ? ? ? ? ? initialized pgdr initialized ? ? ? ? ? ? ? ? ? initialized tcr_0 initialized initialized ? ? ? ? ? ? ? ? initialized tpu_0 tmdr_0 initialized initialized ? ? ? ? ? ? ? ? initialized tiorh_0 initialized initialized ? ? ? ? ? ? ? ? initialized tiorl_0 initialized initialized ? ? ? ? ? ? ? ? initialized tier_0 initialized initialized ? ? ? ? ? ? ? ? initialized tsr_0 initialized initialized ? ? ? ? ? ? ? ? initialized tcnt_0 initialized initialized ? ? ? ? ? ? ? ? initialized tgra_0 initialized initialized ? ? ? ? ? ? ? ? initialized tgrb_0 initialized initialized ? ? ? ? ? ? ? ? initialized tgrc_0 initialized initialized ? ? ? ? ? ? ? ? initialized tgrd_0 initialized initialized ? ? ? ? ? ? ? ? initialized section 21 list of registers rev.6.00 jun. 03, 2008 page 653 of 698 rej09b0074-0600 register name power-on reset manual reset high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby module tcr_1 initialized initialized ? ? ? ? ? ? ? ? initialized tpu_1 tmdr_1 initialized initialized ? ? ? ? ? ? ? ? initialized tior_1 initialized initialized ? ? ? ? ? ? ? ? initialized tier_1 initialized initialized ? ? ? ? ? ? ? ? initialized tsr_1 initialized initialized ? ? ? ? ? ? ? ? initialized tcnt_1 initialized initialized ? ? ? ? ? ? ? ? initialized tgra_1 initialized initialized ? ? ? ? ? ? ? ? initialized tgrb_1 initialized initialized ? ? ? ? ? ? ? ? initialized tcr_2 initialized initialized ? ? ? ? ? ? ? ? initialized tpu_2 tmdr_2 initialized initialized ? ? ? ? ? ? ? ? initialized tior_2 initialized initialized ? ? ? ? ? ? ? ? initialized tier_2 initialized initialized ? ? ? ? ? ? ? ? initialized tsr_2 initialized initialized ? ? ? ? ? ? ? ? initialized tcnt_2 initialized initialized ? ? ? ? ? ? ? ? initialized tgra_2 initialized initialized ? ? ? ? ? ? ? ? initialized tgrb_2 initialized initialized ? ? ? ? ? ? ? ? initialized exmdlstp initialized ? ? ? ? ? ? ? ? ? initialized system rsecdr ? ? ? ? ? ? ? ? ? ? initialized rtc rmindr ? ? ? ? ? ? ? ? ? ? initialized rhrdr ? ? ? ? ? ? ? ? ? ? initialized rwkdr ? ? ? ? ? ? ? ? ? ? initialized rtccr1 ? ? ? ? ? ? ? ? ? ? initialized rtccr2 ? ? ? ? ? ? ? ? ? ? initialized rtccsr initialized ? ? ? ? ? ? ? ? ? initialized dmacr0a initialized initialized ? ? ? ? ? ? ? ? initialized dmac dmacr0b initialized initialized ? ? ? ? ? ? ? ? initialized dmacr1a initialized initialized ? ? ? ? ? ? ? ? initialized dmacr1b initialized initialized ? ? ? ? ? ? ? ? initialized dmabcr initialized initialized ? ? ? ? ? ? ? ? initialized tcsr initialized initialized ? ? ? ? ? ? ? ? initialized wdt tcnt initialized initialized ? ? ? ? ? ? ? ? initialized rstcsr initialized initialized ? ? ? ? ? ? ? ? initialized section 21 list of registers rev.6.00 jun. 03, 2008 page 654 of 698 rej09b0074-0600 register name power-on reset manual reset high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby module smr_0 initialized initialized ? ? ? ? ? ? ? ? initialized sci_0 brr_0 initialized initialized ? ? ? ? ? ? ? ? initialized scr_0 initialized initialized ? ? ? ? ? ? ? ? initialized tdr_0 initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized ssr_0 initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized rdr_0 initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized scmr_0 initialized initialized ? ? ? ? ? ? ? ? initialized smr_2 initialized initialized ? ? ? ? ? ? ? ? initialized sci_2 brr_2 initialized initialized ? ? ? ? ? ? ? ? initialized scr_2 initialized initialized ? ? ? ? ? ? ? ? initialized tdr_2 initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized ssr_2 initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized rdr_2 initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized scmr_2 initialized initialized ? ? ? ? ? ? ? ? initialized addrah initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized a/d addral initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized addrbh initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized addrbl initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized addrch initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized addrcl initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized addrdh initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized addrdl initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized adcsr initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized adcr initialized initialized ? ? ? initialized initialized initialized initialized initialized initialized tcsr_1 initialized initialized ? ? ? ? ? ? ? initialized initialized system flmcr1 initialized ? ? ? ? ? ? ? ? initialized initialized flash flmcr2 initialized ? ? ? ? ? ? ? ? initialized initialized ebr1 initialized ? ? ? ? ? ? ? ? initialized initialized ebr2 initialized ? ? ? ? ? ? ? ? initialized initialized section 21 list of registers rev.6.00 jun. 03, 2008 page 655 of 698 rej09b0074-0600 register name power-on reset manual reset high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby module port1 ? ? ? ? ? ? ? ? ? ? ? port port3 ? ? ? ? ? ? ? ? ? ? ? port4 ? ? ? ? ? ? ? ? ? ? ? port7 ? ? ? ? ? ? ? ? ? ? ? port9 ? ? ? ? ? ? ? ? ? ? ? porta ? ? ? ? ? ? ? ? ? ? ? portb ? ? ? ? ? ? ? ? ? ? ? portc ? ? ? ? ? ? ? ? ? ? ? portd ? ? ? ? ? ? ? ? ? ? ? porte ? ? ? ? ? ? ? ? ? ? ? portf ? ? ? ? ? ? ? ? ? ? ? portg ? ? ? ? ? ? ? ? ? ? ? notes: ? : is not initialized. * the usb registers are no initialized by a power-on reset triggered by the wdt. section 21 list of registers rev.6.00 jun. 03, 2008 page 656 of 698 rej09b0074-0600 section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 657 of 698 rej09b0074-0600 section 22 electrical characteristics 22.1 absolute maximum ratings table 22.1 lists the absolute maximum ratings. table 22.1 absolute maximum ratings item symbol value unit power supply voltage v cc , pllv cc , drv cc ?0.3 to +4.3 v input voltage v in ?0.3 to v cc +0.3 v reference voltage v ref ?0.3 to v cc +0.3 v analog input voltage v an ?0.3 to v cc +0.3 v operating temperature t opr regular specifications: ?20 to +75 c wide-range specifications: ?40 to +85 * c storage temperature t stg ?55 to +125 c caution: permanent damage to the chip may result if absolute maximum rating are exceeded. note: * the operating temperature ranges for fl ash memory programming/erasing are t a = ?20c to +75c. section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 658 of 698 rej09b0074-0600 22.2 power supply voltage and operating frequency range power supply voltage and operating frequency ranges (shaded areas) are shown in figure 22.1. (4) when using the on-chip usb (3) f-ztat version (1) mask rom versions (except for d32210s) system clock sub clock sub clock system clock system clock frequency f 24 mhz 16 mhz 0 2.7 3.0 3.6 power ssupply voltage vcc, pllvcc, drvcc (v) power ssupply voltage vcc, pllvcc, drvcc (v) power ssupply voltage vcc, pllvcc, drvcc (v) 6 mhz 32.768 khz 2.4 vcc = pllvcc = drvcc = 2.4 to 3.6v vref = 2.4v to vcc vss = pllvss = drvss = 0v ta = -20 to +75 (regular specifications) ta = -40 to +85 (wide-range specifications) f = 32.768 khz, 6 mhz condition a: condition c: condition b: condition a: condition b: condition c: vcc = pllvcc = drvcc = 2.7 to 3.6v vref = 2.7v to vcc vss = pllvss = drvss = 0v ta = -20 to +75 (regular specifications) ta = -40 to +85 (wide-range specifications) f = 32.768 khz, 6 to 16 mhz vcc = pllvcc = drvcc = 3.0 to 3.6v vref = 3.0v to vcc vss = pllvss = drvss = 0v ta = -20 to +75 (regular specifications) ta = -40 to +85 (wide-range specifications) f = 32.768 khz, 6 to 24 mhz condition d: vcc = pllvcc = drvcc = 3.0 to 3.6v vref = 3.0v to vcc vss = pllvss = drvss = 0v ta = -20 to +75 (regular specifications) ta = -40 to +85 (wide-range specifications) f = 32.768 khz, 16 to 24 mhz none vcc = pllvcc = drvcc = 2.7 to 3.6v vref = 2.7v to vcc vss = pllvss = drvss = 0v ta = -20 to +75 (regular specifications) ta = -40 to +85 (wide-range specifications) f = 32.768 khz, 6 to 16 mhz vcc = pllvcc = drvcc = 3.0 to 3.6v vref = 3.0v to vcc vss = pllvss = drvss = 0v ta = -20 to +75 (regular specifications) ta = -40 to +85 (wide-range specifications) f = 32.768 khz, 6 to 24 mhz frequency f 24 mhz 16 mhz 0 2.7 3.0 3.6 6 mhz 32.768 khz 2.4 frequency f 24 mhz 16 mhz 0 2.7 3.0 3.6 6 mhz 32.768 khz 2.4 system clock sub clock (2) masked rom version (d32210s) frequency f 24 mhz 16 mhz 0 2.7 3.0 3.6 power ssupply voltage vcc, pllvcc, drvcc (v) 6 mhz 32.768 khz 2.4 system clock sub clock figure 22.1 power supply voltage and operating ranges section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 659 of 698 rej09b0074-0600 22.3 dc characteristics table 22.2 lists the dc characteristics. tabl e 22.3 lists the permissible output currents. table 22.2 dc characteristics condition a: v cc = pll v cc = dr v cc = 2.4 v to 3.6 v, vref = 2.4 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = pll v cc = dr v cc = 2.7 v to 3.6 v, vref = 2.7 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 16 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) condition c: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) item symbol min. typ. max. unit test conditions schmitt irq0 to irq4 v t ? v cc 0.2 ? ? v trigger input irq7 v t + ? ? v cc 0.8 v voltage v t + ? v t ? v cc 0.05 ? ? v input high voltage res , stby , nmi, md2 to md0, trst , tck, tms, tdi, emle, vbus, ubpm , fwe * 4 v ih v cc 0.9 ? v cc + 0.3 v extal, ports 1, 3, 4, 7, 9, and a to g v cc 0.8 ? v cc + 0.3 v section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 660 of 698 rej09b0074-0600 item symbol min. typ. max. unit test conditions input low voltage res , stby , md2 to md0, trst , tck, tms, tdi, emle, vbus, ubpm , fwe * 4 v il ?0.3 ? v cc 0.1 v extal, nmi, ports 1, 3, 4, 7, 9, and a to g ?0.3 ? v cc 0.2 v all output pins v oh v cc ? 0.5 ? ? v i oh = ?200 a output high voltage v cc ? 1.0 ? ? v i oh = ?1 ma output low voltage all output pins v ol ? ? 0.4 v i ol = 0.8 ma input leakage current res , vbus, ubpm , stby , nmi, emle, md2 to md0, fwe * 4 , ports 4, 9 | i in | ? ? 1.0 a v in = 0.5 to v cc ? 0.5 v three-state leakage current (off state) ports 1, 3, 7, and a to g | i tsi | ? ? 1.0 a v in = 0.5 to v cc ? 0.5 v input pull-up mos current ports a to e tdi, tck, tms, trst ? i p 10 ? 300 a v in = 0 v input capacitance res , nmi c in ? ? 30 pf v in = 0 v f = 1 mhz all input pins other than res , nmi ? ? 15 pf t a = 25c current dissipation * 1 normal operation i cc * 2 ? 22 v cc = 3.3 v 35 v cc = 3.6 v ma f = 16 mhz (usb halts) ? 31 v cc = 3.3 v 50 v cc = 3.6 v ma f = 24 mhz section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 661 of 698 rej09b0074-0600 item symbol min. typ. max. unit test conditions ? 30 v cc = 3.3 v 45 v cc = 3.6 v ma f = 16 mhz, when pll3 is used current dissipation * 1 normal operation (usb operates) i cc * 2 ? 41 v cc = 3.3 v 60 v cc = 3.6 v ma f = 24 mhz, when pll2 is used sleep mode ? 16 v cc = 3.3 v 30 v cc = 3.6 v ma f = 16 mhz, when usb and pll are halted ? 22 v cc = 3.3 v 45 v cc = 3.6 v ma f = 24 mhz, when usb and pll are halted ? 16 v cc = 3.3 v ? ma f = 16 mhz (reference value) all modules other than flash memory stopped ? 24 v cc = 3.3 v ? ma f = 24 mhz (reference value) ? 45 180 a subactive mode ? 30 * 5 ? ? 35 100 a subsleep mode ? 20 * 5 ? watch mode ? 5 40 a vcc = 3.3 v, emle = 0 when crystal resonator (32.768 khz) is used standby mode * 3 ? 1.0 10 a t a 50c 32.768 khz rtc halted emle = 0 ? ? 50 a 50c < t a 32.768 khz rtc halted emle = 0 during a/d conversion al cc ? 1.3 2.5 ma v ref = 3.3 v reference power supply current idle ? 0.01 5.0 a ram standby voltage v ram 2.0 ? ? v notes: if the a/d converter is not used, the vref pin should not be open. even if the a/d converter is not used, connect the vref pin to vcc. section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 662 of 698 rej09b0074-0600 1. current dissipation values are for v ih min. = v cc ? 0.2 v and v il max. = 0.2 v, with all output pins unloaded and the on-chip mos pull-up transistors in the off state. 2. i cc depends on v cc and f as follows (reference): i cc max. = 5 (ma) + 0.52 (ma/(mhz x v)) v cc f (normal operation, usb halted) i cc max. = 9 (ma) + 0.60 (ma/(mhz x v)) v cc f (normal operation, usb operated) i cc max. = 1 (ma) + 0.51 (ma/(mhz x v)) v cc f (sleep mode) 3. the values are for v ram < v cc < 2.7 v, v ih min. = v cc 0.9, and v il max. = 0.3 v. 4. the fwe pin is effective only in the f-ztat version. 5. reference value when setting the flash memory module stop mode is carried out while the on-chip ram program is executed. the value is effective in the f-ztat version. table 22.3 permissible output currents condition a: v cc = pll v cc = dr v cc = 2.4 v to 3.6 v, vref = 2.4 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = pll v cc = dr v cc = 2.7 v to 3.6 v, vref = 2.7 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 16 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition c: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 24 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) item symbol min. typ. max. unit permissible output low current (per pin) all output pins i ol ? ? 1.0 ma permissible output low current (total) total of all output pins i ol ? ? 60 ma permissible output high current (per pin) all output pins ?i oh ? ? 1.0 ma permissible output high current (total) total of all output pins ?i oh ? ? 30 ma note: to protect chip reliability, do not exceed the output current values in table 22.3. section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 663 of 698 rej09b0074-0600 22.4 ac characteristics figure 22.2 shows, the test conditions for the ac characteristics. 3 v r l r h c l s i output p i n c = 30 p f r l = 2 .4 k r h = 12 k i nput / output t i m i ng measurement l eve l s ? l ow l eve l : 1 . 3 v (2 .4 v vcc < 2 . 7 v) : 0 . 8 v (2 . 7 v vcc 3 . 6 v) ? hi gh l eve l : 1 . 3 v (2 .4 v vcc < 2 . 7 v ) : 2 . 0 v (2 . 7 v vcc 3 . 6 v) figure 22.2 output load circuit section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 664 of 698 rej09b0074-0600 22.4.1 clock timing table 22.4 lists the clock timing table 22.4 clock timing condition a: v cc = pll v cc = dr v cc = 2.4 v to 3.6 v, vref = 2.4 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = pll v cc = dr v cc = 2.7 v to 3.6 v, vref = 2.7 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 16 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition c: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 24 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) condition a condition b condition c condition d item symbol min. max. min. max. min. max. min. max. unit test conditions clock cycle time t cyc 166.6 62.5 166.6 41.6 166.6 41.6 62.5 ns clock high pulse width t ch 50 ? 20 ? 13 ? 13 ? ns clock low pulse width t cl 50 ? 20 ? 13 ? 13 ? ns clock rise time t cr ? 25 ? 10 ? 7 ? 7 ns clock fall time t cf ? 25 ? 10 ? 7 ? 7 ns oscillation stabilization time at reset (crystal) t osc1 40 ? 20 ? 20 ? 20 ? ms figure 22.4 oscillation stabilization time in software standby (crystal) t osc2 16 ? 8 ? 8 ? 8 ? ms figures 20.4, 19.2 c l1 = c l2 = 10 to 22 pf 16 ? 8 ? 4 ? 4 ? ms figures 20.4, 19.2 c l1 = c l2 = 10 to 15 pf section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 665 of 698 rej09b0074-0600 condition a condition b condition c condition d item symbol min. max. min. max. min. max. min. max. unit test conditions external clock output stabilization delay time t dext 1000 ? 500 ? 500 ? 500 ? s figure 22.4 subclock stabilization time t osc3 ? 4 ? 2 ? 2 ? 2 s subclock oscillator frequency f sub 32.768 32.768 32.768 32.768 khz subclock ( sub ) cycle time f sub 30.5 30.5 30.5 30.5 s t cr t c l t cf t c h t cyc figure 22.3 system clock timing t osc1 t osc1 ext a l v cc stby res t d ext t d ext figure 22.4 oscillation stabilization timing section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 666 of 698 rej09b0074-0600 22.4.2 control signal timing table 22.5 lists the control signal timing. table 22.5 control signal timing condition a: v cc = pll v cc = dr v cc = 2.4 v to 3.6 v, vref = 2.4 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = pll v cc = dr v cc = 2.7 v to 3.6 v, vref = 2.7 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 16 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition c: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 24 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) condition a condition b, c, d item symbol min. max. min. max. unit test conditions res setup time t ress 350 ? 250 ? ns figure 22.5 res pulse width t resw 20 ? 20 ? t cyc mres setup time t mress 350 ? 250 ? ns mres pulse width t mresw 20 ? 20 ? t cyc nmi setup time t nmis 350 ? 250 ? ns figure 22.6 nmi hold time t nmih 10 ? 10 ? ns nmi pulse width (exiting software standby mode) t nmiw 300 ? 200 ? ns irq setup time t irqs 350 ? 250 ? ns irq hold time t irqh 10 ? 10 ? ns irq pulse width (exiting software standby mode) t irqw 300 ? 200 ? ns section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 667 of 698 rej09b0074-0600 t r e sw t r e ss t mr e ss t mr e ss t mr e sw t r e ss res mres figure 22.5 reset input timing t i r q s irq edge i nput t i r qh t n m i s t n m ih t i r q s irq l eve l i nput n m i irq t n m i w t i r q w figure 22.6 interrupt input timing section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 668 of 698 rej09b0074-0600 22.4.3 bus timing table 22.6 shows, bus timing. table 22.6 bus timing condition a: v cc = pll v cc =dr v cc =2.4 v to 3.6 v, vref=2.4 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = pll v cc =dr v cc =2.7 v to 3.6 v, vref=2.7 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 16 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition c: v cc = pll v cc =dr v cc =3.0 v to 3.6 v, vref=3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 24 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) condition a condition b condition c, d test item symbol min. max. min. max. min. max. unit conditions address delay time t ad ? 90 ? 50 ? 30 ns address setup time t as 0.5 t cyc ? 60 ? 0.5 t cyc ? 30 ? 0.5 t cyc ? 20 ? ns address hold time t ah 0.5 t cyc ? 30 ? 0.5 t cyc ? 15 ? 0.5 t cyc ? 8 ? ns figures 22.7, 22.8, 22.10 cs delay time t csd ? 90 ? 50 ? 30 ns figures 22.7, 22.8 as delay time t asd ? 90 ? 50 ? 25 ns figures 22.7, 22.8, 22.10 rd delay time 1 t rsd1 ? 90 ? 50 ? 25 ns figures 22.7, 22.8 rd delay time 2 t rsd2 ? 90 ? 50 ? 25 ns read data setup time t rds 50 ? 30 ? 20 ? ns read data hold time t rdh 0 ? 0 ? 0 ? ns figures 22.7, 22.8, 22.10 read data access time 2 t acc2 ? 1.5 t cyc ? 90 ? 1.5 t cyc ? 65 ? 1.5 t cyc ? 35 ns figure 22.7 section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 669 of 698 rej09b0074-0600 condition a condition b condition c, d test item symbol min. max. min. max. min. max. unit conditions read data access time 3 t acc3 ? 2.0 t cyc ? 90 ? 2.0 t cyc ? 65 ? 2.0 t cyc ? 40 ns figures 22.7, 22.10 read data access time 4 t acc4 ? 2.5 t cyc ? 90 ? 2.5 t cyc ? 65 ? 2.5 t cyc ? 35 ns read data access time 5 t acc5 ? 3.0 t cyc ? 90 ? 3.0 t cyc ? 65 ? 3.0 t cyc ? 40 ns figure 22.8 wr delay time 1 t wrd1 ? 90 ? 50 ? 20 ns figure 22.8 wr delay time 2 t wrd2 ? 90 ? 50 ? 25 ns figures 22.7, 22.8 wr pulse width 1 t wsw1 1.0 t cyc ? 60 ? 1.0 t cyc ? 30 ? 1.0 t cyc ? 20 ? ns figure 22.7 wr pulse width 2 t wsw2 1.5 t cyc ? 60 ? 1.5 t cyc ? 30 ? 1.5 t cyc ? 20 ? ns figure 22.8 write data delay time t wdd ? 100 ? 50 ? 30 ns figures 22.7, 22.8 write data setup time t wds 0.5 t cyc ? 80 ? 0.5 t cyc ? 30 ? 0.5 t cyc ? 20 ? ns figure 22.8 write data hold time t wdh 0.5 t cyc ? 60 ? 0.5 t cyc ? 15 ? 0.5 t cyc ? 10 ? ns figures 22.7, 22.8 wait setup time t wts 90 ? 50 ? 25 ? ns wait hold time t wth 10 ? 10 ? 5 ? ns figure 22.9 breq setup time t brqs 90 ? 50 ? 25 ? ns figure 22.11 back delay time t bacd ? 90 ? 50 ? 35 ns bus-floating time t bzd ? 160 ? 80 ? 50 ns section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 670 of 698 rej09b0074-0600 t rsd2 t 1 t ad as a 23 to a0 t asd rd (read) t 2 t csd t as t asd t acc2 t as t as t rsd1 t acc3 t rds t rd h t wrd2 t wdd t wsw1 t wd h t a h cs5 to cs0 d15 to d0 (read) hwr , lwr (wr i te) d15 to d0 (wr i te) t a h t wrd2 figure 22.7 basic bus timing (two-state access) section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 671 of 698 rej09b0074-0600 t rsd2 t 2 as a 23 to a0 t asd rd (read) t 3 t as t a h t asd t acc 4 t rsd1 t acc5 t as t rds t rd h t wrd1 t wrd2 t wds t wsw2 t wd h t a h cs5 to cs0 d15 to d0 (read) hwr , lwr (wr i te) d15 to d0 (wr i te) t 1 t csd t wdd t ad figure 22.8 basic bus timing (three-state access) section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 672 of 698 rej09b0074-0600 t w as a 23 to a0 rd (read) t 3 cs5 to cs0 d15 to d0 (read) hwr , lwr (wr i te) d15 to d0 (wr i te) t 2 t w t s t 1 t w th t w t s t w th wait figure 22.9 basic bus timing (three- state access with one wait state) section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 673 of 698 rej09b0074-0600 t rsd2 t 1 a s a 23 to a0 t 2 t a h t acc3 t rds cs0 d15 to d0 (read) t 2 or t 3 t as t 1 t asd t asd t rd h t ad rd (read) figure 22.10 burst rom access timing (two-state access) section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 674 of 698 rej09b0074-0600 breq a 23 to a0, cs5 to cs0 , t br q s t bacd t bzd t bacd t bzd t br q s back as , rd , hwr , lwr figure 22.11 external bus release timing section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 675 of 698 rej09b0074-0600 22.4.4 timing of on-chip supporting modules table 22.7 lists the timing of on-chip supporting modules. table 22.7 timing of on-chip supporting modules condition a: v cc = pll v cc = dr v cc = 2.4 v to 3.6 v, vref = 2.4 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = pll v cc = dr v cc = 2.7 v to 3.6 v, vref = 2.7 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 16 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition c: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 24 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) condition a condition b condition c, d item symbol min. max. min. max. min. max. unit test conditions i/o port output data delay time t pwd ? 150 ? 60 ? 40 ns figure 22.12 input data setup time t prs 80 ? 50 ? 30 ? input data hold time t prh 50 ? 50 ? 30 ? tpu timer output delay time t tocd ? 150 ? 60 ? 40 ns figure 22.13 timer input setup time t tics 60 ? 40 ? 30 ? timer clock input setup time t tcks 60 ? 40 ? 30 ? ns figure 22.14 single edge t tckwh 1.5 ? 1.5 ? 1.5 ? t cyc timer clock pulse width both edges t tckwl 2.5 ? 2.5 ? 2.5 ? section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 676 of 698 rej09b0074-0600 condition a condition b condition c,d item symbol min. max. min. max. min. max. unit test conditions sci input clock asynchro- nous t scyc 4 ? 4 ? 4 ? t cyc figure 22.15 cycle synchro- nous 6 ? 6 ? 6 ? input clock pulse width t sckw 0.4 0.6 0.4 0.6 0.4 0.6 t scyc input clock rise time t sckr ? 1.5 ? 1.5 ? 1.5 t cyc input clock fall time t sckf ? 1.5 ? 1.5 ? 1.5 transmit data delay time t txd ? 150 ? 60 ? 40 ns figure 22.16 receive data setup time (synchronous) t rxs 150 ? 60 ? 40 ? receive data hold time (synchronous) t rxh 150 ? 60 ? 40 ? a/d converter trigger input setup time t trgs 60 ? 40 ? 30 ? ns figure 22.17 tck cycle time t tcyc 166.6 ? 62.5 ? 41.6 ? ns boundary scan tck high level pulse width t tckh 0.4 0.6 0.4 0.6 0.4 0.6 t tcyc tck low level pulse width t tckl 0.4 0.6 0.4 0.6 0.4 0.6 t tcyc figure 22.18 trst pulse width t trsw 20 ? 20 ? 20 ? t tcyc trst setup time t trss 350 ? 250 ? 250 ? ns figure 22.19 tdi setup time t tdis 80 ? 30 ? 20 ? ns tdi hold time t tdih 10 ? 10 ? 10 ? tms setup time t tmss 80 ? 30 ? 20 ? figure 22.20 tms hold time t tmsh 10 ? 10 ? 10 ? tdo delay time t tdod ? 100 ? 40 ? 35 section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 677 of 698 rej09b0074-0600 ports 1, 3, 4 , 7, 9 , a to g (read) t prs t 1 t 2 t pwd t pr h ports 1, 3, 7, a to g (wr i te) figure 22.12 i/o port input/output timing t ti cs t t ocd output compare output * i nput capture i nput * n ote : * ti oca0 to ti oca2, ti ocb0 to ti ocb2, ti occ0, ti ocd0 figure 22.13 tpu input/output timing t t c k s t t c k s t c lk a to t c lk d t t c k w h t t c k w l figure 22.14 tpu clock input timing section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 678 of 698 rej09b0074-0600 t scyc t sc k r t sc k w sc k 0, sc k 2 t sc k f figure 22.15 sck clock input timing t tx d t r xh t r x s sc k 0, sc k 2 t xd0, t xd2 (transm i t data) rxd0, rxd2 (rece i ve data) figure 22.16 sci input/output timing (clock synchronous mode) t t r g s adtrg figure 22.17 a/d converter external trigger input timing t t c kl t t c kh t c k t t cyc figure 22.18 boundary scan tck input timing t t rsw t t rss t c k t t rss trst figure 22.19 boundary scan trst input timing (at reset hold) section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 679 of 698 rej09b0074-0600 t t d i s t t d ih t c k t d i t ms t do t t mss t t ms h t t dod t t dod figure 22.20 boundary scan data transmission timing section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 680 of 698 rej09b0074-0600 22.5 usb characteristics table 22.8 lists the usb characteristics (usd+ and usd- pins) when the on-chip usb transceiver is used. table 22.8 usb characteristics (usd+ and usd- pins) when on-chip usb transceiver is used conditions: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, v ss = pllv ss = drv ss = 0 v, f = 16 mhz, 24 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) item symbol min. max. unit test condition input characteristics input high level voltage v ih 2.0 ? v figures 22.21, 22.22 input low level voltage v il ? 0.8 v differential input sense v di 0.2 ? v | (d+)-(d-)| differential common mode range v cm 0.8 2.5 v output characteristics output high level voltage v oh 2.8 ? v i oh = -200 a output low level voltage v ol ? 0.3 v i ol = 2 ma crossover voltage v crs 1.3 2.0 v rise time t r 4 20 ns fall time t f 4 20 ns rise time/fall time matching t rfm 90 111.11 % (t r /t f ) output resistance z drv 28 44 including rs = 24 section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 681 of 698 rej09b0074-0600 t r usd + , usd - v crs d i fferent i a l date li nes 9 0 % 10 % 10 % f a ll ti me r i se ti me 9 0 % t f figure 22.21 data signal timing usd + t est po i nt c l = 50 p f t est po i nt c l = 50 p f usd - r s = 2 4 r s = 2 4 figure 22.22 test load circuit section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 682 of 698 rej09b0074-0600 22.6 a/d conversion characteristics table 22.9 lists the a/d conversion characteristics. table 22.9 a/d conversion characteristics condition a: v cc = pll v cc = dr v cc = 2.4 v to 3.6 v, vref = 2.4 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = pll v cc = dr v cc = 2.7 v to 3.6 v, vref = 2.7 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 16 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition c: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 6 mhz to 24 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition d: v cc = pll v cc = dr v cc = 3.0 v to 3.6 v, vref = 3.0 v to v cc , v ss = pllv ss = dr v ss = 0 v, f = 32.768 khz, 16 mhz to 24 mhz, t a = ? 20c to +75c (regular specifications), t a = ? 40c to +85c (wide-range specifications) condition a condition b, c, d item min. typ. max. min. typ. max. unit resolution 10 10 10 10 10 10 bits conversion time 21.8 ? ? 8.1 ? ? s analog input capacitance ? ? 20 ? ? 20 pf permissible signal-source impedance ? ? 5 ? ? 5 k nonlinearity error ? ? 6.0 ? ? 6.0 lsb offset error ? ? 4.0 ? ? 4.0 lsb full-scale error ? ? 4.0 ? ? 4.0 lsb quantization ? ? 0.5 ? ? 0.5 lsb absolute accuracy ? ? 8.0 ? ? 6.0 lsb section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 683 of 698 rej09b0074-0600 22.7 flash memory characteristics table 22.10 lists the flash memory characteristics. table 22.10 flash memory characteristics conditions: v cc = pllv cc = drv cc = 3.0 v to 3.6 v, vref = 2.7 v to v cc , v ss = pllv ss = drv ss = 0 v, t a = ?20 to +75c (programming/erasing operating temperature range) item symbol min. typ. max. unit programming time * 1 * 2 * 4 t p ? 10 200 ms/128 bytes erase time * 1 * 3 * 5 t e ? 50 1000 ms/block reprogramming count n wec 100 * 6 10000 * 7 ? times data retention time * 8 t drp 10 ? ? years programming wait time after psu1 bit setting * 1 y 50 50 ? s wait time after p1 bit setting * 1 * 4 z0 28 30 32 s z1 198 200 202 s z2 8 10 12 s wait time after p1 bit clear * 1 5 5 ? s wait time after psu1 bit clear * 1 5 5 ? s wait time after pv1 bit setting * 1 4 4 ? s wait time after h?ff dummy write * 1 2 2 ? s wait time after pv1 bit clear * 1 2 2 ? s maximum programming count * 1 * 4 n1 ? ? 6 * 4 times n2 ? ? 994 * 4 times common wait time after swe1 bit setting * 1 x 1 1 ? s wait time after swe1 bit clear * 1 100 100 ? s erase wait time after esu1 bit setting * 1 y 100 100 ? s wait time after e1 bit setting * 1 * 5 z 10 10 100 ms wait time after e1 bit clear * 1 10 10 ? s wait time after esu1 bit clear * 1 10 10 ? s wait time after ev1 bit setting * 1 20 20 ? s wait time after h'ff dummy write * 1 2 2 ? s wait time after ev1 bit clear * 1 4 4 ? s maximum erase count * 1 * 5 n ? ? 100 times notes: 1. make each time setting in accordance with the program/program-verify flowchart or erase/erase-verify flowchart. 2. programming time per 128 bytes (shows the total period for which the p-bit in the flash memory control register (flmcr1) is set. it does not include the programming verification time.) section 22 electrical characteristics rev.6.00 jun. 03, 2008 page 684 of 698 rej09b0074-0600 3. block erase time (shows the total period for which the e1-bit flmcr1 is set. it does not include the erase verification time.) 4. maximum programming time value t p (max.) = wait time after p1 bit set (z) maximum programming count (n1 + n2) = (z0 + z2) 6 + z1 994 5. maximum erasure time value t e (max.) = wait time after e1 bit set (z) maximum erasure count (n) 6. minimum times that guarantee all characteristics after programming. (the guaranteed range is 1 to the minimum value.) 7. reference value when the temperature is 25c. (it is reference that reprogramming is normally enabled up to this value.) 8. data hold characteristics when reprogramming is performed within the range of specifications including the minimum value. 22.8 usage note general notice during design for printed circuit board: measures for radiation noise caused by the transient current in this lsi should be taken into consideration. the examples of the measures are shown below. ? to use a multilayer printed circuit board which includes layers for vcc and gnd. ? to mount by-pass capacitors (approximately 0.1 f) between the vcc and gnd (vss) pins, and the pllvcc and pllgnd pins, of this lsi. characteristics of f-ztat and masked rom versions: though the f-ztat version and the masked rom version satisfy electrical characteristics described in this manual, the actual value of electrical characteristics, operating margin, and nois e margin may differ due to the differences of production process, on-chip rom, and layout patterning. when the system has been evaluated with the f-ztat version, the equivalent evaluation should be implemented to the masked rom version when shifted to the masked rom version. appendix rev.6.00 jun. 03, 2008 page 685 of 698 rej09b0074-0600 appendix a. i/o port states in each processing state port name pin name mcu operating mode power-on reset manual reset hardware standby mode software standby mode or watch mode bus right release state program execution state or sleep mode p17 to p14 4 to 7 t keep t keep keep i/o port p13/a23 p12/a22 p11/a21 7 t keep t keep keep i/o port address output selected by aen bit 4 to 6 t keep t [ope=0] t [ope=1] keep t address output port selection 4 to 6 t keep t keep keep i/o port p10/a20 7 t keep t keep keep i/o port 4 and 5 l address output selected by aen bit 6 t keep t [ope=0] t [ope=1] keep t address output port selection 4 to 6 t * 1 keep t keep keep i/o port port 3 4 to 7 t keep t keep keep i/o port port 4 4 to 7 t t t t t input port p77 to p75 * 3 7 t keep t keep keep i/o port p74 * 2 4 to 7 t keep t keep keep i/o port 7 t keep t keep keep i/o port p71/ cs5 * 2 p70/ cs4 * 2 4 to 6 t keep t [ddr ? ope=0] t [ddr ? ope=1] h t [ddr=0] input port [ddr=1] cs5 , cs4 port 9 4 to 7 t t t [daoen=1] keep [daoen=0] t keep input port appendix rev.6.00 jun. 03, 2008 page 686 of 698 rej09b0074-0600 port name pin name mcu operating mode power-on reset manual reset hardware standby mode software standby mode or watch mode bus right release state program execution state or sleep mode port a 7 t keep t keep keep i/o port 4 and 5 l address output selected by aen bit 6 t keep t [ope=0] t [ope=1] keep t address output port selection 4 to 6 t * 1 keep t keep keep i/o port port b * 2 7 t keep t keep keep i/o port address output selected by aen bit 4 and 5 l 6 t keep t [ope=0] t [ope=1] keep t address output port selection 4 to 6 t * 1 keep t keep keep i/o port port c * 2 4 and5 l keep t [ope=0] t [ope=1] keep t address output 6 t keep t [ddr ? ope=0] t [ddr ? ope=1] keep t [ddr=0] input port [ddr=1] address output 7 t keep t keep keep i/o port port d * 2 4 to 6 t t t t t data bus 7 t keep t keep keep i/o port port e 8-bit bus 4 to 6 t keep t keep keep i/o port 16-bit bus 4 to 6 t t t t t data bus 7 t keep t keep keep i/o port appendix rev.6.00 jun. 03, 2008 page 687 of 698 rej09b0074-0600 port name pin name mcu operating mode power-on reset manual reset hardware standby mode software standby mode or watch mode bus right release state program execution state or sleep mode pf7/ 4 to 6 clock output [ddr=0] input port [ddr=1] clock output t [ddr=0] input port [ddr=1] h [ddr=0] input port [ddr=1] clock output [ddr=0] input port [ddr=1] clock output 7 t keep t [ddr=0] input port [ddr=1] h [ddr=0] input port [ddr=1] clock output [ddr=0] input port [ddr=1] clock output pf6/ as * 2 pf5/ rd * 2 pf4/ hwr * 2 4 to 6 h h t [ope=0] t [ope=1] h t as , rd , hwr 7 t keep t keep keep i/o port pf3/ lwr 7 t keep t keep keep i/o port 8-bit bus 4 to 6 (mode 4) h keep t keep keep i/o port 16-bit bus 4 to 6 (modes 5 ,6) t h t [ope=0] t [ope=1] h t lwr pf2/ wait * 2 4 to 6 t keep t [waite=0] keep [waite=1] t [waite=0] keep [waite=1] t [waite=0] i/o port [waite=1] wait 7 t keep t keep keep i/o port pf1/ back * 2 4 to 6 t keep t [brle=0] keep [brle=1] h l [brle=0] i/o port [brle=1] back 7 t keep t keep keep i/o port appendix rev.6.00 jun. 03, 2008 page 688 of 698 rej09b0074-0600 port name pin name mcu operating mode power-on reset manual reset hardware standby mode software standby mode or watch mode bus right release state program execution state or sleep mode pf0/ breq 4 to 6 t keep t [brle=0] keep [brle=1] t t [brle=0] i/o port [brle=1] breq 7 t keep t keep keep i/o port pg4/ cs0 * 2 4 and 5 h 6 t keep t [ddr ? ope=0] t [ddr ? ope=1] h t [ddr=0] i/o port [ddr=1] cs0 (when sleep mode)h 7 t keep t keep keep i/o port pg3/ cs1 * 2 pg2/ cs2 * 2 pg1/ cs3 4 to 6 t keep t [ddr ? ope=0] t [ddr ? ope=1] h t [ddr=0] i/o port [ddr=1] cs1 to cs3 7 t keep t keep keep i/o port pg0 * 3 4 to 7 t keep t keep keep i/o port legend: h: high level l: low level t: high impedance keep: input port level is high impedance, and output port level is retained. ddr: data direction register ope: output port enable waite: wait port enable brle: bus release enable notes: 1. l (address input) in mode 4 or 5 2. supported only by the h8s/2218 group. 3. supported only by the h8s/2212 group. appendix rev.6.00 jun. 03, 2008 page 689 of 698 rej09b0074-0600 b. product model lineup product class part no. model name marking package (code) HD64F2218 HD64F2218tf24 f2218 tf24 100-pin tqfp (tfp-100g, tfp-100gv) h8s/2218 group HD64F2218br24 64f2218br24 112-pin p-lfbga (bp-112, bp-112v) HD64F2218u HD64F2218utf24 f 2218utf24 100-pin tqfp (tfp-100g, tfp-100gv) flash memory version HD64F2218ubr24 64f2218ubr24 112-pin p-lfbga (bp-112, bp-112v) hd6432217 hd6432217( *** )tf 2217( *** )tf 100-pin tqfp (tfp-100g, tfp-100gv) masked rom version hd6432217( *** )br 2217( *** )br 112-pin p-lfbga (bp-112, bp-112v) h8s/2212 group hd64f2212 hd64f2212fp24 2212fp24 64-pin lqfp (fp-64e, fp-64ev) flash memory version hd64f2212np24 f2212np24 64-pin vqfn (tnp-64b, tnp-64bv) hd64f2212u hd64f2212ufp24 2212ufp24 64-pin lqfp (fp-64e, fp-64ev) hd64f2212unp24 f2212unp24 64-pin vqfn (tnp-64b, tnp-64bv) hd64f2211 hd64f2211fp24 2211fp24 64-pin lqfp (fp-64e, fp-64ev) hd64f2211np24 f2211np24 64-pin vqfn (tnp-64b, tnp-64bv) hd64f2211u hd64f2211ufp24 2211ufp24 64-pin lqfp (fp-64e, fp-64ev) hd64f2211unp24 f2211unp24 64-pin vqfn (tnp-64b, tnp-64bv) hd6432211 hd6432211( *** )fp 2211( *** )fp 64-pin lqfp (fp-64e, fp-64ev) masked rom version hd6432211( *** )np 2211( *** )np 64-pin vqfn (tnp-64b, tnp-64bv) hd6432210 hd6432210( *** )fp 2210( *** )fp 64-pin lqfp (fp-64e, fp-64ev) hd6432210( *** )np 2210( *** )np 64-pin vqfn (tnp-64b, tnp-64bv) appendix rev.6.00 jun. 03, 2008 page 690 of 698 rej09b0074-0600 product class part no. model name marking package (code) h8s/2212 group hd6432210s hd6432210s( *** )fp 2210s( *** )fp 64-pin lqfp (fp-64e, fp-64ev) masked rom version hd6432210s( *** )np 2210s( *** )np 64-pin vqfn (tnp-64b, tnp-64bv) legend: ***: rom code appendix rev.6.00 jun. 03, 2008 page 691 of 698 rej09b0074-0600 c. package dimensions the package dimension that is shown in the renesas semiconductor package data book has priority. note) 1. dimensions" * 1"and" * 2" do not include mold flash 2. dimension" * 3"does not include trim offset. index mark * 1 * 2 * 3 p e d e d ym x f 100 125 26 76 75 50 51 e h d h b z z 2 1 1 detail f c a a l a l terminal cross section 1 1 p b c c b h e l e e c 1 a 1 d e a 2 h d a b p b 1 c x y z d z e l 1 reference symbol dimension in millimeters min nom max 1.0 0.10 0 8 0.4 0.12 0.17 0.22 0.13 0.18 0.23 0.00 0.10 0.20 1.20 13.8 14.0 14.2 1.00 12 0.16 0.15 0.4 0.5 0.6 0.07 14.2 14.0 13.8 1.2 12 1.2 p-tqfp100-12x12-0.40 0.4g mass[typ.] tfp-100g/tfp-100gv ptqp0100lc-a renesas code jeita package code previous code figure c.1 tfp-100g and tfp-100gv package dimensions appendix rev.6.00 jun. 03, 2008 page 692 of 698 rej09b0074-0600 l k j h g f e d c b 11 10 9 8 7 6 5 4 3 2 1 ys v b ws a ws ys s b a a 1 1 a a plbg0112ga-a p-lfbga112-10x10-0.80 d e s d s e z d z e z d z e mass[typ.] 0.3g bp-112/bp-112v renesas code jeita package code previous code 0.15 0.20 0.2 y 1 1.00 1.00 w v 0.08 10.00 1.40 0.45 0.40 0.35 0.55 0.50 0.45 0.80 0.10 10.00 y x b a reference symbol dimension in millimeters min nom max a 1 e e e b a s b m 4 d e figure c.2 bp-112 and bp-112v package dimensions appendix rev.6.00 jun. 03, 2008 page 693 of 698 rej09b0074-0600 f y m x 33 48 32 49 16 17 1 64 d e d e p * 3 * 2 * 1 index mark d h e h z z b detail f 1 1 2 c l a l a a 1 1 p terminal cross section b c b c 1.0 11.8 12.0 12.2 1.45 10 reference symbol dimension in millimeters min nom max 0.3 0.5 0.7 10 h e l e e c 1 a 1 d e a 2 h d a b p b 1 c x y z d z e l 1 12.2 12.0 11.8 1.70 0.12 0.17 0.22 0.17 0.22 0.27 0.00 0.20 0.15 0.10 0.20 0 8 0.5 0.10 0.08 1.25 1.25 note) 1. dimensions" * 1"and" * 2" do not include mold flash 2. dimension" * 3"does not include trim offset. p-lqfp64-10x10-0.50 0.4g mass[typ.] fp-64e/fp-64ev plqp0064kc-a renesas code jeita package code previous code figure c.3 fp-64e and fp-64ev package dimensions appendix rev.6.00 jun. 03, 2008 page 694 of 698 rej09b0074-0600 0 . 95 0 . 60 0 . 16 0 . 05 0 . 2 0 . 2 0 . 22 reference symbo l d i mens i on i n m illi meters m i n n om max 8 . 2 8 . 2 0 . 20 0 .4 1 . 0 1 . 0 8 . 0 8 . 0 0 . 05 0 . 23 0 . 18 0 . 13 t y 1 l p y x b 1 b a a 2 e d a 1 e c 1 h d c h e 0 . 89 0 . 005 0 . 02 0 . 0 4 0 . 50 0 . 70 0 . 17 0 . 25 z d z e 2 1 6 4 4 932 17 4 833 16 x m b 1 p 1 c e d d e 1 y x 4 t y 1 b l e c a a a z z h e h d p - vq fn 6 4- 8x8 - 0 .4 00 . 12g mass [t yp .] tn p - 6 4 b /tn p - 6 4 bv pvq n 006 4l b - a r ene sas code j eit a package code prev i ous code figure c.4 tnp-64b and tnp-64bv package dimensions index rev.6.00 jun. 03, 2008 page 695 of 698 rej09b0074-0600 index 16-bit timer pulse unit.......................... 273 a/d conversion time............................. 544 a/d converter ........................................ 535 a/d converter activation....................... 323 absolute address...................................... 59 address space........................................... 38 addressing mode...................................... 58 adi ......................................................... 546 advanced mode........................................ 36 arithmetic operations instructions........... 49 asynchronou s mode ............................... 403 bcc ...................................................... 46, 54 bit manipulation instructions ................... 52 bit rate .................................................... 395 block data transfer instruction................ 56 boot mo de .............................................. 567 boundary scan........................................ 449 branch instructions ................................... 54 break....................................................... 441 buffer operation..................................... 309 bulk-in tr ansfer ..................................... 513 bulk-out transfer................................... 515 bus arbitration ....................................... 155 bus cycle................................................. 133 clock pulse generator ............................ 595 condition field ......................................... 57 condition-code register .......................... 42 control transfer...................................... 506 cpu operating modes.............................. 34 data reading procedure........................... 359 data transfer instructions ........................ 48 dma transfer specifications ................. 520 effective address................................ 58, 62 effective address extension..................... 57 emulation................................................ 577 erase/erase-verify.................................. 581 erasing units ................................... 558, 559 error protection....................................... 583 exception handling .................................. 81 extended control register (exr) ............ 41 external trigger...................................... 545 flash memory......................................... 553 framing error .......................................... 410 free-running count operation.................. 302 general registers...................................... 40 hardware protection ............................... 583 immediate ................................................. 60 input capture function ........................... 305 instruction set ........................................... 45 internal bus masters ................................ 115 interrupt cont rol mode ........................... 103 interrupt controller ................................... 91 interrupt exception handling vector table ............................................................ 101 interrupt mask bit..................................... 42 interrupt mask level .................................. 41 interrupt priority register........................... 91 interrupt-in transfer ............................... 512 interrupts................................................... 87 interval timer mode............................... 344 logic operations instructions................... 50 mark state............................................... 442 masked rom.......................................... 593 memory cycle ......................................... 131 memory indirect ....................................... 61 index rev.6.00 jun. 03, 2008 page 696 of 698 rej09b0074-0600 memory map............................................. 77 nmi interrupt ............................................ 99 normal mode ............................................ 34 on-board programming.......................... 567 operating mode selection......................... 71 operation field.......................................... 57 overflow ................................................. 345 overrun error........................................... 410 parity error .............................................. 410 periodic count operation.......................... 302 phase counti ng m ode ............................. 317 pll circuit ............................................. 604 processing of usb standard commands and class/vendor commands ............. 516 program counter ....................................... 41 program/program-verify ........................ 579 program-counter relative......................... 60 programmer mode .................................. 585 programming un its .......................... 558, 559 programming/erasing in user program mode ................................................... 576 pwm modes ........................................... 313 realtime clock (rtc) ............................ 349 register abwcr ...................... 118, 635, 643, 651 adcr.......................... 540, 638, 647, 654 adcsr ....................... 538, 638, 647, 654 addr ......................... 538, 638, 647, 654 astcr........................ 119, 635, 643, 651 bcrh.......................... 124, 635, 643, 651 bcrl .......................... 125, 635, 643, 651 brr............................. 395, 638, 646, 654 bscanr ............................................. 454 bypass.............................................. 454 dmacr ...................... 163, 637, 646, 653 ebr1........................... 563, 638, 647, 654 ebr2........................... 564, 638, 647, 654 etcr .......................... 162, 635, 643, 652 flmcr1 ..................... 561, 638, 647, 654 flmcr2 ..................... 562, 638, 647, 654 idcode.............................................. 454 ier ................................ 95, 6 34, 641, 650 instr ................................................. 452 ioar ........................... 161, 635, 643, 652 ipr ................................ 94, 6 35, 642, 651 iscr.............................. 96, 6 34, 641, 650 isr ................................ 98, 6 34, 641, 650 lpwrcr .................... 597, 634, 641, 650 mar............................ 161, 635, 643, 652 mdcr ........................... 72, 634, 641, 650 mstpcr ..................... 614, 634, 641, 650 p1ddr ........................ 216, 634, 642, 650 p1dr........................... 217, 636, 644, 652 p3ddr ........................ 223, 634, 642, 650 p3dr........................... 224, 636, 644, 652 p3odr ........................ 225, 634, 642, 651 p7ddr ........................ 228, 634, 642, 650 p7dr........................... 229, 636, 644, 652 paddr ....................... 233, 634, 642, 650 padr .......................... 234, 636, 644, 652 paodr ....................... 235, 634, 642, 651 papcr ........................ 235, 634, 642, 651 pbddr ....................... 239, 634, 642, 650 pbdr .......................... 240, 636, 644, 652 pbpcr ........................ 241, 634, 642, 651 pcddr ....................... 245, 634, 642, 650 pcdr .......................... 246, 636, 644, 652 pcpcr ........................ 247, 634, 642, 651 pdddr ....................... 250, 634, 642, 651 pddr .......................... 251, 636, 644, 652 pdpcr ........................ 252, 634, 642, 651 peddr........................ 255, 634, 642, 651 pedr .......................... 256, 636, 644, 652 pepcr ........................ 257, 634, 642, 651 pfcr ........................... 126, 634, 641, 650 pfddr........................ 262, 634, 642, 651 pfdr........................... 263, 636, 644, 652 pgddr ....................... 268, 634, 642, 651 index rev.6.00 jun. 03, 2008 page 697 of 698 rej09b0074-0600 pgdr...........................269, 636, 644, 652 port1 .........................217, 639, 648, 655 port3 .........................224, 639, 648, 655 port4 .........................227, 639, 648, 655 port7 .........................230, 639, 648, 655 port9 .........................232, 639, 648, 655 porta ........................234, 639, 648, 655 portb ........................240, 639, 648, 655 portc ........................246, 639, 648, 655 portd ........................251, 639, 648, 655 porte.........................256, 639, 648, 655 portf.........................263, 639, 648, 655 portg ........................269, 639, 648, 655 ramer .......................565, 635, 643, 651 rdr .............................368, 638, 646, 654 rhrdr............................................... 352 rmindr .....................351, 637, 646, 653 rsecdr..............................637, 646, 653 rstcsr ......................342, 637, 646, 653 rtccr1 ...................... 354, 637, 646, 653 rtccr2 ...................... 355, 637, 646, 653 rtccsr ......................356, 637, 646, 653 rwkdr ......................353, 637, 646, 653 sbycr ........................611, 634, 641, 650 sckcr ........................596, 634, 641, 650 scmr ..........................383, 638, 646, 654 scr..............................373, 638, 646, 654 scrx...........................566, 633, 641, 650 semra_0....................384, 634, 641, 650 semrb_0....................386, 634, 641, 650 smr.............................369, 638, 646, 654 ssr ..............................377, 638, 646, 654 syscr...........................72, 6 34, 641, 650 tcnt..........................297, 340, 636, 637, ................................644, 646, 652, 653 tcr .............................279, 636, 644, 652 tcsr ...........................340, 637, 646, 653 tdr .............................368, 638, 646, 654 tgr .............................297, 636, 644, 652 tier ............................293, 636, 644, 652 tior............................284, 636, 644, 652 tmdr..........................282, 636, 644, 652 tsr ..............................294, 636, 644, 652 tstr............................297, 635, 642, 651 tsyr ...........................298, 635, 642, 651 uctlr ........................468, 632, 640, 649 ucvr ..........................488, 633, 641, 649 udmar ......................471, 632, 640, 649 udrr ..........................472, 632, 640, 649 udsr...........................487, 633, 641, 649 uedr0i .......................477, 632, 640, 649 uedr0o ......................478, 632, 640, 649 uedr0s .......................477, 632, 640, 649 uestl0.......................476, 632, 640, 649 uestl1.......................477, 632, 640, 649 uesz0o .......................479, 633, 640, 649 uesz2 .........................479, 633, 640, 649 ufclr0 ......................475, 632, 640, 649 uier0 ..........................484, 633, 640, 649 uier1 ..........................485, 633, 640, 649 uier3 ..........................485, 633, 640, 649 uifr0 ..........................480, 633, 640, 649 uifr1 ..........................482, 633, 640, 649 uifr3 ..........................483, 633, 640, 649 uisr0 ..........................486, 633, 640, 649 uisr1 ..........................486, 633, 641, 649 uisr3 ..........................487, 633, 641, 649 utrg0 ........................473, 632, 640, 649 utstr0.......................489, 633, 641, 650 utstr1.......................490, 633, 641, 650 wcrh .........................120, 635, 643, 651 wcrl.......................... 120, 635, 643, 651 register direct .......................................... 58 register field............................................ 57 register indirect........................................ 58 register indirect with displacement......... 59 register indirect with post-increment ...... 59 register indirect with pre-decrement........ 59 reset ......................................................... 83 reset exception handling .......................... 84 scan mode .............................................. 543 index rev.6.00 jun. 03, 2008 page 698 of 698 rej09b0074-0600 serial communication interface.............. 363 shift instructions ....................................... 51 single mode ............................................ 542 software protection................................. 583 stack pointer (sp) ..................................... 40 stack status ............................................... 89 stall operations....................................... 517 suspend and resume............................... 502 synchronous operation ........................... 307 system control instruction........................ 55 tci0v ..................................................... 322 tci1u ..................................................... 322 tci1v ..................................................... 322 tci2u ..................................................... 322 tci2v ..................................................... 322 tgi0a ..................................................... 322 tgi0b ..................................................... 322 tgi0c ..................................................... 322 tgi0d ..................................................... 322 tgi1a ..................................................... 322 tgi1b ..................................................... 322 tgi2a ..................................................... 322 tgi2b ..................................................... 322 toggle output .......................................... 304 trace bit.................................................... 41 traces ........................................................ 87 trap instruction......................................... 88 trapa................................................ 60, 88 universal serial bus................................ 465 usb cable connection/disconnection ... 498 watchdog timer ....................................... 339 waveform output by compare match .... 303 wovi...................................................... 345 renesas 16-bit single-chip microcomputer hardware manual h8s/2218 group, h8s/2212 group publication date: 1st edition, february 2003 rev.6.00, june 3, 2008 published by: sales strategic planning div. renesas technology corp. edited by: customer support department global strategic communication div. renesas solutions corp. ?2008. renesas technology corp., all rights reserved. printed in japan. sales strategic planning div. nippon bldg., 2-6-2, ohte-machi, chiyoda-ku, tokyo 100-0004, japan http://www.renesas.com refer to " http://www.renesas.com/en/network " for the latest and detailed information. renesas technology america, inc. 450 holger way, san jose, ca 95134-1368, u.s.a tel: <1> (408) 382-7500, fax: <1> (408) 382-7501 renesas technology europe limited dukes meadow, millboard road, bourne end, buckinghamshire, sl8 5fh, u.k. tel: <44> (1628) 585-100, fax: <44> (1628) 585-900 renesas technology (shanghai) co., ltd. unit 204, 205, aziacenter, no.1233 lujiazui ring rd, pudong district, shanghai, china 200120 tel: <86> (21) 5877-1818, fax: <86> (21) 6887-7858/7898 renesas technology hong kong ltd. 7th floor, north tower, world finance centre, harbour city, canton road, tsimshatsui, kowloon, hong kong tel: <852> 2265-6688, fax: <852> 2377-3473 renesas technology taiwan co., ltd. 10th floor, no.99, fushing north road, taipei, taiwan tel: <886> (2) 2715-2888, fax: <886> (2) 3518-3399 renesas technology singapore pte. ltd. 1 harbour front avenue, #06-10, keppel bay tower, singapore 098632 tel: <65> 6213-0200, fax: <65> 6278-8001 renesas technology korea co., ltd. kukje center bldg. 18th fl., 191, 2-ka, hangang-ro, yongsan-ku, seoul 140-702, korea tel: <82> (2) 796-3115, fax: <82> (2) 796-2145 renesas technology malaysia sdn. bhd unit 906, block b, menara amcorp, amcorp trade centre, no.18, jln persiaran barat, 46050 petaling jaya, selangor darul ehsan, m alaysia tel: <603> 7955-9390, fax: <603> 7955-9510 renesas sales offices colophon 6.2 h8s/2218 group, h8s/2212 group hardware manual |
Price & Availability of HD64F2218 |
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |