The following document contains information on Cypress products. FUJITSU MICROELECTRONICS CONTROLLER MANUAL CM44-10138-3E F2MC-16LX 16-BIT MICROCONTROLLER MB90980 Series HARDWARE MANUAL F2MC-16LX 16-BIT MICROCONTROLLER MB90980 Series HARDWARE MANUAL The information for microcontroller supports is shown in the following homepage. Be sure to refer to the "Check Sheet" for the latest cautions on development. "Check Sheet" is seen at the following support page "Check Sheet" lists the minimal requirement items to be checked to prevent problems beforehand in system development. http://edevice.fujitsu.com/micom/en-support/ FUJITSU MICROELECTRONICS LIMITED PREFACE ■ Purpose of This Manual and Intenders Thank you very much for purchasing FUJITSU products. MB90980 series is a 16-bit microcontroller designed for applications such as consumer devices requiring high-speed real-time processing. MB90980 series functions are suitable for controlling PHS, cellular phones, CD-ROMs, and VTRs. This manual, intended for engineers developing products using the MB90980 series, explains the MB90980 series functions and operations. Read this manual first, before using the product. For details on the instructions, refer to the "Instruction Manual". Note: F2MC is the abbreviation of FUJITSU Flexible MIcrocontroller. ■ Trademarks The company names and brand names herein are the trademarks or registered trademarks of their respective owners. ■ License Purchase of Fujitsu I2C components conveys a license under the Philips I2C Patent Rights to use, these components in an I2C system provided that the system conforms to the I2C Standard Specification as defined by Philips. ■ Composition of This Manual This manual consists of the following 26 chapters and an appendix. CHAPTER 1 OVERVIEW OF MB90980 SERIES This chapter gives an overview of MB90980 series, including its basic characteristics, block diagram, and its functions. CHAPTER 2 HANDLING THE DEVICE This chapter provides precautions on handling the device. CHAPTER 3 CPU This chapter explains CPU specifications, memory, and the functions of registers to provide readers with a better understanding of the MB90980 functions. CHAPTER 4 INTERRUPT This chapter explains interrupts and direct memory access (DMA). CHAPTER 5 RESET This chapter explains reset for the MB90980 series. CHAPTER 6 CLOCKS This chapter describes the clocks of the MB90980 series. CHAPTER 7 LOW-POWER CONSUMPTION MODE This chapter explains the low-power consumption mode of the MB90980 series. CHAPTER 8 MEMORY ACCESS MODE This chapter explains memory access mode and its operation. i CHAPTER 9 I/O PORT This chapter shows the configuration and explains the functions of the registers used for the I/O port. CHAPTER 10 TIME-BASE TIMER This chapter explains the function and operation of the time-base timer. CHAPTER 11 WATCHDOG TIMER This chapter describes the operation and function of the watchdog timer. CHAPTER 12 WATCH TIMER This chapter has an overview of the watch timer, describes the configuration and functions of the register, and explains the operation of the watch timer. CHAPTER 13 16-BIT INPUT/OUTPUT TIMER This chapter has an overview of the 16-bit input/output timer, describes the configuration and function of its register, and explains its operation. CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER This chapter has an overview of the 8/16-bit up/down counter/timer, describes the configuration and functions of its registers, and explains its operation. CHAPTER 15 16-BIT RELOAD TIMER This chapter provides an overview of the 16-bit reload timer and its operation and explains the configuration and functions of its registers. CHAPTER 16 8/16-BIT PPG TIMER This chapter provides an overview and interrupt of the 8/16-bit PPG timer and its operation and explains the configuration and functions of its registers. CHAPTER 17 DTP/EXTERNAL INTERRUPTS This chapter provides an overview of the DTP/external interrupt, its operation, and notes on usage and explains the configuration and functions of its registers. CHAPTER 18 8/10-BIT A/D CONVERTER This chapter provides an overview of the 8/10-bit A/D converter, configuration and function of its registers, operation, conversion data protection function, and precautions on use. CHAPTER 19 EXPANDED I/O SERIAL INTERFACE This chapter provides an overview, configuration, interrupt, and operation of the expanded I/O serial interface and explains the configuration and functions of its registers. CHAPTER 20 UART This chapter provides an overview, configuration, interrupt, operation, precautions on use, and program example of the UART and explains the configuration and functions of its registers. CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION This chapter explains the overview of the address match detection function, its block diagram, configuration of its register, its operation, and its sample program. CHAPTER 22 ROM MIRROR FUNCTION SELECTION MODULE This chapter describes the overview of the ROM mirror function selection module and its register. CHAPTER 23 1.5M BIT FLASH MEMORY This chapter describes the functions and operations of the 1.5M bit flash memory. ii CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION This chapter shows an example of a serial programming connection using the AF220/AF210/AF120/ AF110 flash microcontroller programmer by Yokogawa Digital Computer Corporation. CHAPTER 25 PWC TIMER This chapter provides an overview of the PWC timer, provides notes on its use, explains its configuration, explains the configuration and functions of its registers, and explains its interrupt and operation. CHAPTER 26 I2C INTERFACE This chapter provides an overview, configuration, interrupt, and operation of the I2C interface and explains the configuration and functions of its registers. APPENDIX The appendix provides the memory map and lists the instructions used in the F2MC-16LX. iii • • • • • • • The contents of this document are subject to change without notice. Customers are advised to consult with sales representatives before ordering. The information, such as descriptions of function and application circuit examples, in this document are presented solely for the purpose of reference to show examples of operations and uses of FUJITSU MICROELECTRONICS device; FUJITSU MICROELECTRONICS does not warrant proper operation of the device with respect to use based on such information. When you develop equipment incorporating the device based on such information, you must assume any responsibility arising out of such use of the information. FUJITSU MICROELECTRONICS assumes no liability for any damages whatsoever arising out of the use of the information. Any information in this document, including descriptions of function and schematic diagrams, shall not be construed as license of the use or exercise of any intellectual property right, such as patent right or copyright, or any other right of FUJITSU MICROELECTRONICS or any third party or does FUJITSU MICROELECTRONICS warrant non-infringement of any thirdparty's intellectual property right or other right by using such information. FUJITSU MICROELECTRONICS assumes no liability for any infringement of the intellectual property rights or other rights of third parties which would result from the use of information contained herein. The products described in this document are designed, developed and manufactured as contemplated for general use, including without limitation, ordinary industrial use, general office use, personal use, and household use, but are not designed, developed and manufactured as contemplated (1) for use accompanying fatal risks or dangers that, unless extremely high safety is secured, could have a serious effect to the public, and could lead directly to death, personal injury, severe physical damage or other loss (i.e., nuclear reaction control in nuclear facility, aircraft flight control, air traffic control, mass transport control, medical life support system, missile launch control in weapon system), or (2) for use requiring extremely high reliability (i.e., submersible repeater and artificial satellite). Please note that FUJITSU MICROELECTRONICS will not be liable against you and/or any third party for any claims or damages arising in connection with above-mentioned uses of the products. Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or loss from such failures by incorporating safety design measures into your facility and equipment such as redundancy, fire protection, and prevention of over-current levels and other abnormal operating conditions. Exportation/release of any products described in this document may require necessary procedures in accordance with the regulations of the Foreign Exchange and Foreign Trade Control Law of Japan and/or US export control laws. The company names and brand names herein are the trademarks or registered trademarks of their respective owners. Copyright © 2007-2008 FUJITSU MICROELECTRONICS LIMITED All rights reserved. iv CONTENTS CHAPTER 1 1.1 1.2 1.3 1.4 1.5 1.6 CHAPTER 2 2.1 CPU ............................................................................................................ 19 Overview of CPU Specifications ....................................................................................................... Memory Space .................................................................................................................................. CPU Registers .................................................................................................................................. Accumulator (A) ........................................................................................................................... User Stack Pointer (USP) and System Stack Pointer (SSP) ....................................................... Processor Status (PS) ................................................................................................................. Program Counter (PC) ................................................................................................................. Program Count Bank Register (PCB) .......................................................................................... Direct Page Register (DPR) ........................................................................................................ General-Purpose Register (Register Bank) ................................................................................. Prefix Codes ..................................................................................................................................... CHAPTER 4 4.1 4.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.4.3 4.4.4 4.4.5 4.5 4.6 4.6.1 4.6.2 4.6.3 4.6.4 4.7 HANDLING THE DEVICE .......................................................................... 15 Precautions on Handling the Device ................................................................................................. 16 CHAPTER 3 3.1 3.2 3.3 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4 OVERVIEW OF MB90980 SERIES .............................................................. 1 Overview of MB90980 Series ............................................................................................................. 2 Block Diagram of MB90980 Series ..................................................................................................... 5 Package Dimensions .......................................................................................................................... 6 Pin Assignment ................................................................................................................................... 7 Pin Functions ...................................................................................................................................... 8 I/O Circuit Type ................................................................................................................................. 11 20 21 25 27 28 29 32 33 34 35 36 INTERRUPT ............................................................................................... 39 Overview of Interrupt ........................................................................................................................ Interrupt Factor and Interrupt Vector ................................................................................................ Interrupt Control Register and Peripheral Function .......................................................................... Interrupt Control Register (ICR00 to ICR15) ............................................................................... Hardware Interrupt ............................................................................................................................ Hardware Interrupt Operation ...................................................................................................... Flow of Hardware Interrupt Operation ......................................................................................... Procedure for Using Hardware Interrupt ...................................................................................... Multiple Interrupts ........................................................................................................................ Hardware Interrupt Processing Time ........................................................................................... Software Interrupt ............................................................................................................................. Interrupt by μDMAC .......................................................................................................................... DMA Descriptor ........................................................................................................................... Individual Registers of DMA Descriptor ....................................................................................... μDMAC Processing Procedure .................................................................................................... μDMAC Processing Time ............................................................................................................ Interrupt by Extended Intelligent I/O Service (EI2OS) ....................................................................... v 40 42 45 46 49 52 54 55 57 59 61 63 66 68 71 72 74 4.7.1 EI2OS descriptor (ISD) ................................................................................................................ 4.7.2 Each Register of EI2OS Descriptor (ISD) .................................................................................... 4.7.3 Operation of EI2OS ...................................................................................................................... 4.7.4 Procedure for Use of EI2OS ........................................................................................................ 4.7.5 Processing Time of the Extended Intelligent I/O Service (EI2OS) ............................................... 4.8 Exception Processing Interrupt ......................................................................................................... 4.9 Stack Operation of Interrupt Processing ........................................................................................... 4.10 Sample Program of Interrupt Processing .......................................................................................... 4.11 Delay Interrupt Generation Module ................................................................................................... 4.11.1 Operation of Delay Interrupt Generation Module ......................................................................... CHAPTER 5 5.1 5.2 5.3 5.4 5.5 5.6 104 106 108 113 117 118 LOW-POWER CONSUMPTION MODE ................................................... 119 Overview of Low-Power Consumption Mode .................................................................................. Block Diagram of Low-Power Consumption Control Circuit ........................................................... Low-Power Consumption Mode Control Register (LPMCR) ........................................................... CPU Intermittent Operation Mode .................................................................................................. Standby Mode ................................................................................................................................. Sleep Mode ............................................................................................................................... Time-base Timer Mode ............................................................................................................. Watch Mode .............................................................................................................................. Stop Mode ................................................................................................................................. State Transition Diagram ................................................................................................................ Pin State in Standby Mode, Hold, and Reset ................................................................................. Caution on Using Low-Power Consumption Mode ......................................................................... CHAPTER 8 8.1 8.2 8.3 CLOCKS ................................................................................................... 103 Overview of Clocks ......................................................................................................................... Block Diagram of Clock Generator ................................................................................................. Clock Selection Register (CKSCR) and PLL Output Selection Register (PLLOS) ......................... Clock Modes ................................................................................................................................... Oscillation Stabilization Wait Time .................................................................................................. Connecting Oscillator to External Clock ......................................................................................... CHAPTER 7 7.1 7.2 7.3 7.4 7.5 7.5.1 7.5.2 7.5.3 7.5.4 7.6 7.7 7.8 RESET ........................................................................................................ 91 Overview of Reset ............................................................................................................................ 92 Reset Factors and Oscillation Stabilization Wait Time ..................................................................... 94 External-Reset Pin ............................................................................................................................ 96 Resetting ........................................................................................................................................... 97 Reset-Factor Bits .............................................................................................................................. 99 Condition of Pins as Result of Reset .............................................................................................. 101 CHAPTER 6 6.1 6.2 6.3 6.4 6.5 6.6 76 78 81 82 83 85 86 88 89 90 120 123 125 128 129 130 132 134 136 138 140 141 MEMORY ACCESS MODE ...................................................................... 145 Overview of Memory Access Mode ................................................................................................ 146 Mode Pins (MD2 to MD0) ............................................................................................................... 147 Mode Data ...................................................................................................................................... 148 vi CHAPTER 9 I/O PORT .................................................................................................. 151 9.1 Functions of I/O Port ....................................................................................................................... 9.2 Registers for I/O Port ...................................................................................................................... 9.2.1 Port registers (PDR2 to PDR4, PDR6 to PDRA) ....................................................................... 9.2.2 Port direction registers (DDR2 to DDR4, DDR6 to DDRA) ........................................................ 9.2.3 Other registers ........................................................................................................................... 152 153 154 155 156 CHAPTER 10 TIME-BASE TIMER .................................................................................. 159 10.1 10.2 10.3 10.4 10.5 10.6 10.7 Overview of Time-base Timer ......................................................................................................... Time-base Timer Configuration ...................................................................................................... Time-base Timer Control Register (TBTC) ..................................................................................... Time-base Timer Interrupt .............................................................................................................. Time-base Timer Operation ............................................................................................................ Notes on Using Time-base Timer ................................................................................................... Sample Programs of Time-base timer ............................................................................................ 160 162 164 166 167 170 171 CHAPTER 11 WATCHDOG TIMER ................................................................................ 173 11.1 11.2 11.3 11.4 11.5 11.6 Overview of Watchdog Timer ......................................................................................................... Watchdog Timer Control Register (WDTC) .................................................................................... Watchdog Timer Configuration ....................................................................................................... Watchdog Timer Operation ............................................................................................................. Notes on Using Watchdog Timer .................................................................................................... Sample Programs of Watchdog Timer ............................................................................................ 174 176 178 180 182 183 CHAPTER 12 WATCH TIMER ........................................................................................ 185 12.1 12.2 12.3 12.4 Overview of Watch Timer ............................................................................................................... Watch Timer Configuration ............................................................................................................. Watch Timer Control Register (WTC) ............................................................................................. Watch Timer Operation ................................................................................................................... 186 187 188 190 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ............................................................... 193 13.1 Overview of 16-bit Input/Output Timer ............................................................................................ 13.2 Configuration of 16-bit Input/Output Timer ..................................................................................... 13.3 Configuration and Function of 16-bit Input/Output Timer Register ................................................. 13.3.1 Free-run timer ............................................................................................................................ 13.3.2 Output compare ......................................................................................................................... 13.3.3 Input capture .............................................................................................................................. 13.4 Interrupt of 16-bit Input/Output Timer ............................................................................................. 13.5 16-bit Input/Output Timer Operation ............................................................................................... 13.5.1 Operation of free-run timer ........................................................................................................ 13.5.2 Operation of output compare ..................................................................................................... 13.5.3 Operation of input capture ......................................................................................................... 13.5.4 Free-run timer timing ................................................................................................................. 13.5.5 Output compare timing .............................................................................................................. 13.5.6 Timing of input capture .............................................................................................................. 13.6 Program Example of 16-bit Input/Output Timer .............................................................................. vii 194 195 199 200 205 209 211 213 214 216 218 219 220 221 222 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER ................................................... 235 14.1 Overview of 8/16-bit Up/Down Counter Timer ................................................................................ 14.2 Configuration of 8/16-bit Up/Down Counter/Timer .......................................................................... 14.3 Configuration and Functions of Registers for 8/16-bit Up/Down Counter/Timer ............................. 14.3.1 Counter Control Register (ch.0) Upper (CCRH0) ...................................................................... 14.3.2 Counter Control Register (ch.1) Upper (CCRH1) ...................................................................... 14.3.3 Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1) .................................................. 14.3.4 Counter Status Register 0/1 (CSR0/CSR1) ............................................................................... 14.3.5 Up/Down Count Register (ch.0/ch.1) (UDCR0/UDCR1) ............................................................ 14.3.6 Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1) ............................................................... 14.4 Interrupt of 8/16-bit Up/Down Counter/Timer .................................................................................. 14.5 8/16-bit Up/Down Counter/Timer Operation ................................................................................... 14.5.1 Reload/Compare Function ......................................................................................................... 14.5.2 Writing Data to Up/Down Count Register (UDCR) .................................................................... 14.6 Program Example of 8/16-bit Up/Down Counter/Timer .................................................................. 236 237 240 241 243 245 247 249 250 251 253 256 259 261 CHAPTER 15 16-BIT RELOAD TIMER ........................................................................... 269 15.1 Overview of 16-Bit Reload Timer .................................................................................................... 15.2 Configuration and Functions of 16-Bit Reload Timer Registers ...................................................... 15.2.1 Timer Control Status Register (TMCSR) ................................................................................... 15.2.2 16-Bit Timer Register (TMR)/16-Bit Reload Register (TMRLR) ................................................. 15.3 Interrupt of 16-Bit Reload Timer ..................................................................................................... 15.4 Operations of the 16-Bit Reload Timer ........................................................................................... 15.4.1 State Transitions During Count Operation ................................................................................. 15.4.2 Operations of Internal Clock Mode (Reload Mode) ................................................................... 15.4.3 Internal Clock Mode (One-Shot Mode) ...................................................................................... 15.4.4 Event Count Mode ..................................................................................................................... 15.5 Program Example of 16-Bit Reload Timer ...................................................................................... 270 274 275 279 281 282 283 284 287 290 292 CHAPTER 16 8/16-BIT PPG TIMER ............................................................................... 299 16.1 Overview of 8/16-Bit PPG Timer ..................................................................................................... 16.2 Configuration of 8/16-Bit PPG Timer .............................................................................................. 16.3 Configuration and Functions of 8/16-Bit PPG Timer Registers ...................................................... 16.3.1 PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2) ............................................ 16.3.2 PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3) ............................................ 16.3.3 PPG0 to PPG3 Output Control Registers (PPG01, PPG23) ..................................................... 16.3.4 Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3) .......................................................... 16.4 Interrupt of 8/16-Bit PPG Timer ...................................................................................................... 16.5 Operations of 8/16-Bit PPG Timer .................................................................................................. 16.6 Program Example of 8/16-Bit PPG Timer ....................................................................................... 300 301 304 305 307 310 312 313 315 321 CHAPTER 17 DTP/EXTERNAL INTERRUPTS .............................................................. 325 17.1 17.2 17.3 17.4 17.5 Overview of DTP/External Interrupt ................................................................................................ Configuration and Functions of DTP/external Interrupt Registers .................................................. DTP/External Interrupt .................................................................................................................... Operations of DTP/external Interrupt .............................................................................................. Notes on DTP/external Interrupt Usage .......................................................................................... viii 326 328 331 333 335 17.6 Program Example of DTP/External Interrupt .................................................................................. 337 CHAPTER 18 8/10-BIT A/D CONVERTER ..................................................................... 341 18.1 Overview of 8/10-Bit A/D Converter ................................................................................................ 18.2 Configuration of 8/10-Bit A/D Converter ......................................................................................... 18.3 Configuration of 8/10-Bit A/D Converter Registers ......................................................................... 18.3.1 Control Status Register 1 (ADCS1) ........................................................................................... 18.3.2 Control Status Register 2 (ADCS2) ........................................................................................... 18.3.3 Data Registers (ADCR2 and ADCR1) ....................................................................................... 18.4 Interrupt of 8/10-Bit A/D Converter ................................................................................................. 18.5 Operations of 8/10-Bit A/D Converter ............................................................................................. 18.5.1 Example of μDMAC Start in Single Mode .................................................................................. 18.5.2 Example of μDMAC Start in Continuous Mode ......................................................................... 18.5.3 Example of μDMAC Start in Stop Mode .................................................................................... 18.6 Conversion Data Protection Function of 8/10-Bit A/D Converter .................................................... 18.7 Precautions When Using the 8/10-Bit A/D Converter ..................................................................... 18.8 Program Example of 8/10-Bit A/D Converter .................................................................................. 342 343 345 346 349 352 353 355 358 360 362 364 366 367 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE .................................................... 373 19.1 Overview of Expanded I/O Serial Interface ..................................................................................... 19.2 Configuration of Expanded I/O Serial Interface .............................................................................. 19.3 Configuration and Functions of Expanded I/O Serial Interface Registers ...................................... 19.3.1 Serial Mode Control Status Register 0/1 (SMCS0/SMCS1) ...................................................... 19.3.2 Serial Data Register 0/1 (SDR0/SDR1) ..................................................................................... 19.3.3 Communication Prescaler Control Register 0/1 (SDCR0/SDCR1) ............................................ 19.4 Interrupt of Expanded I/O Serial Interface ...................................................................................... 19.5 Operation of Expanded I/O Serial Interface .................................................................................... 19.5.1 Shift Clock Modes ...................................................................................................................... 19.5.2 Operational States of Serial I/O Units ........................................................................................ 19.5.3 Start/Stop Timing and Input/Output Timing of Shift Operation .................................................. 19.5.4 Interrupt Function ...................................................................................................................... 19.6 Program Example of Expanded I/O Serial Interface ....................................................................... 374 375 377 378 382 383 385 387 388 389 391 393 394 CHAPTER 20 UART ........................................................................................................ 397 20.1 Overview of the UART .................................................................................................................... 20.2 Configuration of UART .................................................................................................................... 20.3 Configuration and Functions of UART Registers ............................................................................ 20.3.1 Serial Mode Register (SMR) ...................................................................................................... 20.3.2 Serial Control Register (SCR) ................................................................................................... 20.3.3 Serial Input/Output Register (SIDR/SODR) ............................................................................... 20.3.4 Serial Status Register (SSR) ..................................................................................................... 20.3.5 Communication Prescaler Control Register (CDCR) ................................................................. 20.4 Interrupt of UART ............................................................................................................................ 20.5 UART Operations ........................................................................................................................... 20.5.1 Operation in Asynchronous Mode (Operation Modes 0 and 1) ................................................. 20.5.2 Operation in Synchronous Mode (Operation Mode 2) ............................................................... 20.5.3 Two-Way Communication Function (Normal Mode) .................................................................. ix 398 399 401 402 404 407 408 411 413 415 420 423 425 20.5.4 Master/Slave Communication Function (Multiprocessor Mode) ................................................ 427 20.6 Precautions on Using the UART ..................................................................................................... 431 20.7 Program Example of UART ............................................................................................................ 432 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION ......................................... 441 21.1 Overview of Address Match Detection Function ............................................................................. 21.2 Block Diagram of Address Match Detection Function .................................................................... 21.3 Configuration of Registers for Address Match Detection Function ................................................. 21.3.1 Program Address Detection Control Status Register (PACSR) ................................................ 21.3.2 Program Address Detection Registers (PADR0, PADR1) ......................................................... 21.4 Explanation of Operation of Address Match Detection Function .................................................... 21.4.1 Example of using Address Match Detection Function ............................................................... 21.5 Program Example of Address Match Detection Function ............................................................... 442 443 444 445 447 449 450 455 CHAPTER 22 ROM MIRROR FUNCTION SELECTION MODULE ................................ 457 22.1 22.2 Overview of ROM Mirror Function Selection Module ...................................................................... 458 ROM Mirror Function Selection Register (ROMM) ......................................................................... 459 CHAPTER 23 1.5M BIT FLASH MEMORY ..................................................................... 461 23.1 Overview of 1.5M Bit Flash Memory ............................................................................................... 23.2 Sector Configuration of 1.5M Bit Flash Memory ............................................................................. 23.3 Flash Memory Control Status Register (FMCS) ............................................................................. 23.4 Method for Starting the Flash Memory's Automatic Algorithm ........................................................ 23.5 Verifying the Execution State of the Automatic Algorithm .............................................................. 23.5.1 Data Polling Flag (DQ7) ............................................................................................................ 23.5.2 Toggle Bit Flag (DQ6) ................................................................................................................ 23.5.3 Timing Limit Excess Flag (DQ5) ................................................................................................ 23.5.4 Sector Erase Timer Flag (DQ3) ................................................................................................. 23.6 Flash Memory Write/Erase Operations ........................................................................................... 23.6.1 Setting the Flash Memory to Read/Reset State ........................................................................ 23.6.2 Writing Data to Flash Memory ................................................................................................... 23.6.3 Erasing All Data in the Flash Memory (Chip Erase) .................................................................. 23.6.4 Erasing Arbitrary Data in Flash Memory (Sector Erase) ........................................................... 23.6.5 Suspending Sector Erasure for the Flash Memory .................................................................... 23.6.6 Resuming the Sector Erasure of Flash Memory ........................................................................ 462 464 465 472 473 474 476 477 478 479 480 481 483 484 486 487 CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION .......................................................................................... 489 24.1 24.2 24.3 Basic Configuration of Serial Programming Connection with MB90F983 ....................................... 490 Example of Connection in Single-Chip Mode (When Using the User Power Supply) .................... 493 Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) ............................................................................................ 495 CHAPTER 25 PWC TIMER ............................................................................................. 497 25.1 25.2 25.3 Overview of PWC Timer ................................................................................................................. 498 Configuration of PWC Timer ........................................................................................................... 499 Configuration and Functions of PWC Timer Registers ................................................................... 501 x 25.3.1 PWC Control/Status Register (PWCSR0, PWCSR1) ................................................................ 25.3.2 PWC Data Buffer Register (PWCR0, PWCR1) ......................................................................... 25.3.3 Divide Ratio Control Register (DIVR0, DIVR1) .......................................................................... 25.4 Interrupt of PWC Timer ................................................................................................................... 25.5 Operations of PWC Timer ............................................................................................................... 25.5.1 Operations of the Timer Function .............................................................................................. 25.5.2 Operations of the Pulse Width Measurement Function ............................................................. 25.5.3 Selection of Count Clock and Operation Mode ......................................................................... 25.5.4 Start and Stop of Timer/Pulse Width Measurement .................................................................. 25.5.5 Timer Mode Operation ............................................................................................................... 25.5.6 Operation in Pulse Width Measurement Mode .......................................................................... 25.6 Notes on PWC Timer Usage .......................................................................................................... 502 507 509 510 512 513 514 516 518 521 524 530 CHAPTER 26 I2C INTERFACE ....................................................................................... 533 26.1 Overview of I2C Interface ................................................................................................................ 26.2 Configuration of I2C Interface ......................................................................................................... 26.3 Configuration and Functions of I2C Interface Registers ................................................................. 26.3.1 Bus Status Register (IBSR) ....................................................................................................... 26.3.2 Bus Control Register (IBCR) ..................................................................................................... 26.3.3 Clock Control Register (ICCR) .................................................................................................. 26.3.4 Address Register (IADR) ........................................................................................................... 26.3.5 Data Register (IDAR) ................................................................................................................. 26.4 Interrupt of I2C Interface ................................................................................................................. 26.5 I2C Interface Operation ................................................................................................................... 534 535 537 539 541 548 550 551 552 554 APPENDIX ......................................................................................................................... 557 APPENDIX A Memory Map ........................................................................................................................ APPENDIX B I/O Map ................................................................................................................................ APPENDIX C Interrupt Source, Interrupt Vector, and Interrupt Control Register ....................................... APPENDIX D Instructions ........................................................................................................................... D.1 Instruction Types ............................................................................................................................ D.2 Addressing ..................................................................................................................................... D.3 Direct Addressing ........................................................................................................................... D.4 Indirect Addressing ........................................................................................................................ D.5 Execution Cycle Count ................................................................................................................... D.6 Effective address field .................................................................................................................... D.7 How to Read the Instruction List .................................................................................................... D.8 F2MC-16LX Instruction List ............................................................................................................ D.9 Instruction Map ............................................................................................................................... 558 560 568 570 571 572 574 580 588 591 592 595 609 INDEX................................................................................................................................... 631 xi xii Main changes in this edition Page 570 to 630 Changes (For details, refer to main body.) Changed the entire part of "APPENDIX D Instructions" The vertical lines marked in the left side of the page show the changes. xiii xiv CHAPTER 1 OVERVIEW OF MB90980 SERIES This chapter gives an overview of MB90980 series, including its basic characteristics, block diagram, and its functions. 1.1 Overview of MB90980 Series 1.2 Block Diagram of MB90980 Series 1.3 Package Dimensions 1.4 Pin Assignment 1.5 Pin Functions 1.6 I/O Circuit Type 1 CHAPTER 1 OVERVIEW OF MB90980 SERIES 1.1 Overview of MB90980 Series MB90980 series is a 16-bit microcontroller designed for applications such as consumer devices requiring high-speed real-time processing. ■ MB90980 Series Features The MB90980 series has the following features: • Minimum instruction execution time • 40.0 ns/6.25 MHz oscillation multiplied by 4 (25 MHz/3.3 V ± 0.3 V for internal operation) • 62.5 ns/4 MHz oscillation multiplied by 4 (16 MHz/3.0 V ± 0.3 V for internal operation) • PLL clock multiply system • Maximum memory space: 16 Mbytes • Instruction system optimized for control applications • • Available data types: bit, byte, word, long word • Standard addressing modes: 23 types • Improved high-precision operation using a 32-bit accumulator • Signed multiply and divide operations, extensive RETI instruction Instruction system supporting multitasking in high-level languages (such as C) • Use of a system stack pointer • Symmetry of instruction sets and barrel shift instructions • Improved execution speed: 4-byte queue • Improved interrupt function (priority is a programmable setting of up to 8 levels): 8 external interrupts • Data transfer function (μDMAC): maximum of 16 channels • Built-in ROM: FLASH version: 192 K bytes, MASK version: 128 K bytes • Built-in RAM: FLASH version: 12 K bytes, MASK version: 10 K bytes • General-purpose ports: maximum of 48 ports Output open-drain settings available: 10 ports 2 • A/D converter (RC step-by-step compare type): 8 channels (resolution: 10 bits; conversion time: 3.68 μs (25 MHz operation)) • UART: 1 channel • Extensive I/O serial interface (SIO): 2 channels • 8/16-bit PPG: 2 channels (mode switching function of 8 bits x 4 channels and 16 bits x 2 channels) • 8/16-bit up/down timer: 1 channel (8 bits x 2 channels or 16 bits x 1 channel with mode switching function) • 16-bit reload timer: 1 channel • 16-bit input/output timer (input capture x 2 channels; output compare x 4 channels; free-run timer x 1 channel) • Built-in dual-system clock generator • Power-saving mode (stop mode, sleep mode, CPU intermittent operation mode, watch mode/time-base timer mode) • Package: LQFP64 • CMOS technology • 3V single power supply (some port can be operated on 5V power supply.) • I2C interface* 1 channel P77 and P76 are N-ch open drain pins (without P-ch). • 16bit PWC: 2 channels 2 channels have the function of input compare. * : I2C license Purchase of Fujitsu I2C components conveys a license under the Philips I2C Patent Rights to use, these components in an I2C system provided that the system conforms to the I2C Standard Specification as defined by Philips. ■ Product Configuration Table 1.1-1 is an outline of the MB90980 series product configuration. Table 1.1-1 MB90980 Series Product Configuration MB90V485B MB90F983 MB90982 ROM capacity - FLASH 192K bytes 128K bytes RAM capacity 16K bytes 12K bytes 10K bytes EVA product f=25MHz 3-V/5-V power supply*2 built-in PWC, I2C*4 FLASH product f=25MHz 3-V/5-V power supply*3 built-in PWC, I2C*4 MASK product f=25MHz 3-V/5-V power supply*3 built-in PWC, I2C*4 Yes No No Description Emulator dedicated power supply*1 *1: The setting of the jumper switch (TOOL VCC) when using the emulator (MB2147-01). For detailed information, refer to MB2147-01 or MB2147-20 Hardware Manual (switching of 3.3 emulator dedicated power supply). *2: 3-V/5-V: I/F Pin : P20 to P27, P30 to P37, P40 to P47 and P70 to P77. The other pins are for 3-V power supply. *3: 3-V/5-V: I/F pins (P24 to P27, P30 to P37, P40 to P42, P70 to P74, and P76 to P77) The power supply for the other pins is 3 V. *4: If I2C is set, P76/P77 pins are N-ch open drain pin (without P-ch). 3 CHAPTER 1 OVERVIEW OF MB90980 SERIES ■ The Packages of the Corresponding Products ● Package Table 1.1-2 shows the differences of the package. Table 1.1-2 Product List of MB90980 Series MB90V485B MB90F983 MB90982 FPT-64P-M03 ✕ ❍ ❍ PGA-299C ❍ ✕ ✕ ❍: Usable ✕: Unusable ● Memory area Refer to the memory map in appendix for the differences of memory area. ● Current dissipation Refer to "Electrical Characteristics" in Data Sheet for the differences of the current dissipation. 4 1.2 Block Diagram of MB90980 Series This section has a block diagram of the MB90980 series. ■ Block Diagram of MB90980 Series Figure 1.2-1 is a block diagram of the MB90980 series. Figure 1.2-1 Block Diagram of MB90980 Series X0, X1, RST X0A, X1A MD2, MD1, MD0 8 CPU F2MC16LX core Clock control Circuit RAM Interrupt controller 2 PPG0, PPG1 ROM 8/16-bit PPG 8/16-bit up/down counter Communication prescaler 2 PPG2, PPG3 2 2 2 AIN0, AIN1 BIN0, BIN1 ZIN0, ZIN1 2 SIN1, SIN2 SOT1, SOT 2 SCK1, SCK2 AVCC AVRH AVSS ADTG AN0 to AN7 PWC0 PWC1 UART 2 2 2 8 Input/output timer F2MC-16LX Bus SIN0 SOT0 SCK0 I/O extended serial interface × 2 channels 16-bit input capture × 2 2 channels 16-bit output compare × 4 channels 16-bit free-run timer 4 IN0, IN1 OUT0, OUT1, OUT2, OUT3 16-bit reload timer TIN0 TOT0 I2C interface SCL SDA A/D converter ( 10 bits ) External interrupt 8 IRQ0 to IRQ7 PWC × 2 channels I/O port 4 8 3 8 5 2 P24 P30 P40 P60 P70 to to to to to P07 P37 P42 P67 P74 8 P76, P80 to P77 P87 4 2 P90 to P93 4 P96, PA0 to P97 PA3 P40 to P42 (x3): With register for open drain settings P76/P77 pins of I2C are N-ch open drain terminal (without P-ch) Note: In the Figure 1.2-1, the I/O port shares a pin with each built-in function block. The pin cannot be used as an I/O port if it is used as built-in module pin. 5 CHAPTER 1 OVERVIEW OF MB90980 SERIES 1.3 Package Dimensions MB90980 series has one type of package. ■ Package Dimensions (LQFP-64) Figure 1.3-1 is a diagram for the package dimensions of the LQFP-64 type. Figure 1.3-1 Package Dimensions of LQFP-64 Type 64-pin plastic LQFP Lead pitch 0.50 mm Package width × package length 10.0 × 10.0 mm Lead shape Gullwing Sealing method Plastic mold Mounting height 1.70 mm MAX Weight 0.32g Code (Reference) P-LFQFP64-10×10-0.50 (FPT-64P-M03) 64-pin plastic LQFP (FPT-64P-M03) Note 1) * : These dimensions do not include resin protrusion. Note 2) Pins width and pins thickness include plating thickness. Note 3) Pins width do not include tie bar cutting remainder. 12.00±0.20(.472±.008)SQ * 10.00±0.10(.394±.004)SQ 48 0.145±0.055 (.006±.002) 33 49 32 Details of "A" part 0.08(.003) +0.20 1.50 –0.10 +.008 .059 –.004 INDEX 64 0˚~8˚ 17 (Mounting height) 0.10±0.10 (.004±.004) (Stand off) "A" LEAD No. 1 16 0.50(.020) C 0.20±0.05 (.008±.002) 0.08(.003) M 2003 FUJITSU LIMITED F64009S-c-5-8 0.50±0.20 (.020±.008) 0.60±0.15 (.024±.006) Dimensions in mm (inches). Note: The values in parentheses are reference values Please confirm the latest Package dimension by following URL. http://edevice.fujitsu.com/fj/DATASHEET/ef-ovpklv.html 6 0.25(.010) 1.4 Pin Assignment This section shows the MB90980 series pin assignments. ■ Pin Assignment Diagram (LQFP-64) Figure 1.4-1 is a pin assignment diagram for the LQFP-64 type. 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 AVss P60/AN0 P61/AN1 P62/AN2 P63/AN3 P64/AN4 P65/AN5 P66/AN6 P67/AN7 P80/IRQ0 P81/IRQ1 P82/IRQ2 P83/IRQ3 RST X0A X1A Figure 1.4-1 Pin Assignment Diagram of MB90980 Series (LQFP-64) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 LQFP-64P (TOP VIEW) 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 Vss X1 X0 MOD2 MOD1 MOD0 P84/IRQ4 P85/IRQ5 P86/IRQ6 P87/IRQ7 P90/SIN1 P91/SOT1 P92/SCK1 P93/FRCK/ADTG P96/IN0 Vss Vss P41/SOT2 P40/SIN2 P77/SDA P76/SCL P74/TOT0 P73/TIN0 P72/SCK0 P71/SOT0 P70/SIN0 PA3/OUT3 PA2/OUT2 PA1/OUT1 PA0/OUT0 P97/IN1 Vcc3 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 AVcc AVR P27/PPG3 P26/PPG2 P25/PPG1 P24/PPG0 P37/PWC1 P36/PWC0 P35/ZIN1 P34/BIN1 P33/AIN1 P32/ZIN0 P31/BIN0 P30/AIN0 P42/SCK2 Vcc5 - P77 and P76 are N-ch open drain pin (without P-ch). - P24 to P27, P30 to P37, P40 to P42, P70 to P74 and P76, P77 are 3V/5V I/F pin. 7 CHAPTER 1 OVERVIEW OF MB90980 SERIES 1.5 Pin Functions This section explains the MB90980 series pin functions. ■ Pin Functions Table 1.5-1 explains MB90980 series pin function. Table 1.5-1 Pin Functions (1 / 3) Pin No. Pin name I/O Circuit Type 46 X0 A Oscillator pin 47 X1 A Oscillator pin 50 X0A A 32 kHz oscillator pin 49 X1A A 32 kHz oscillator pin 51 RST B Reset input pin P24 to P27 E (CMOS/H) FPT-64P-M03 3 to 6 PPG0 to PPG3 P30 14 AIN0 P31 13 BIN0 P32 12 ZIN0 P33 11 AIN1 P34 10 BIN1 P35 9 ZIN1 P36, P37 7, 8 PWC0, PWC1 P40 19 SIN2 P41 18 SOT2 8 E (CMOS/H) Function These are general purpose I/O port. PPG timer output pins. This is a general purpose I/O port. 8/16-bit up/down counter input pin (channel 0). E (CMOS/H) This is a general purpose I/O port. E (CMOS/H) This is a general purpose I/O port. E (CMOS/H) This is a general purpose I/O port. 8/16-bit up/down counter input pin (channel 0). 8/16-bit up/down counter input pin (channel 0). 8/16-bit up/down counter input pin (channel 1). E (CMOS/H) This is a general purpose I/O port. E (CMOS/H) This is a general purpose I/O port. E (CMOS/H) These are general purpose I/O ports. G (CMOS/H) F (CMOS) 8/16-bit up/down counter input pin (channel 1). 8/16-bit up/down counter input pin (channel 1). These are PWC input pins. This is a general purpose I/O port. Simple serial I/O 2 input pin. This is a general purpose I/O port. Simple serial I/O 2 output pin. Table 1.5-1 Pin Functions (2 / 3) Pin No. Pin name FPT-64P-M03 P42 15 SCK2 P60 to P63 60 to 63 AN0 to AN3 P64 to P67 56 to 59 AN4 to AN7 P70 26 SIN0 P71 25 SOT0 P72 24 SCK0 P73 23 TIN0 P74 22 TOT0 I/O Circuit Type G (CMOS/H) H (CMOS) H (CMOS) G (CMOS/H) F (CMOS) G (CMOS/H) SCL SDA P80 to P83 52 to 55 IRQ0 to IRQ3 P84 to P87 39 to 42 IRQ4 to IRQ7 P90 38 SIN1 P91 37 SOT1 Simple serial I/O 2 clock input/output pin. These are general purpose I/O ports. These are the analog input pins. These are general purpose I/O ports. These are the analog input pins. This is a general purpose I/O port. This is the UART data input pin. This is a general purpose I/O port. This is the UART data output pin. This is a general purpose I/O port. This is the UART clock I/O pin. This is a general purpose I/O port. F (CMOS) This is a general purpose I/O port. This is the 16-bit reload timer event input pin. This is the 16-bit reload timer output pin. This is a general purpose I/O port. I (NMOS/H) P77 20 This is a general purpose I/O port. G (CMOS/H) P76 21 Function Serves as the I2C interface clock I/O pin. During operation of the I2C interface, leave the port output in a high impedance state. This is a general purpose I/O port. I (NMOS/H) E (CMOS/H) E (CMOS/H) E (CMOS/H) D (CMOS) Serves as the I2C interface data I/O pin. During operation of the I2C interface, leave the port output in a high impedance state. These are general purpose I/O ports. External interrupt input pins. These are general purpose I/O ports. External interrupt input pins. This is a general purpose I/O port. Simple serial I/O 1 data input pin. This is a general purpose I/O port. Simple serial I/O 1 data output pin. 9 CHAPTER 1 OVERVIEW OF MB90980 SERIES Table 1.5-1 Pin Functions (3 / 3) Pin No. Pin name FPT-64P-M03 P92 36 SCK1 I/O Circuit Type E (CMOS/H) P93 35 FRCK P96 IN0 P97 31 IN1 PA0 to PA3 Simple serial I/O 1 data input/output pin. E (CMOS/H) When the free run timer is in use, this pin functions as the external clock input pin. When the A/D converter is in use, this pin functions as the external trigger input pin. E (CMOS/H) E (CMOS/H) This is a general purpose I/O port. Input capture channel 0 trigger input pin. This is a general purpose I/O port. Input capture channel 1 trigger input pin. These are general purpose I/O ports. OUT0 to OUT3 D (CMOS) 1 AVcc ___ A/D converter power supply pin. 2 AVRH ___ A/D converter external reference voltage supply pin. 64 AVss ___ A/D converter power supply pin. 43 to 45 MD0 to MD2 J (CMOS/H) 32 VCC3 ___ 3.3 V ± 0.3 V power supply pins (VCC3). 27 to 30 10 This is a general purpose I/O port. This is a general purpose I/O port. ADTG 34 Function Output compare event output pins. Operating mode selection input pins. 16 VCC5 ___ 3 V/5 V power supply pin. 5 V power supply pin when P24 to P27, P30 to P37, P40 to P42, P70 to P74, P76 to P77 are used as 5 V I/F pins. Usually, use VCC = VCC3 = VCC5 as a 3 V power supply (when the 3 V power supply is used alone). 17, 48 VSS ___ power supply input pin (GND). 1.6 I/O Circuit Type This section explains the I/O circuit type of MB90980 series pins. ■ I/O Circuit Type Table 1.6-1 summarizes the I/O circuit type of MB90980 series pins. Table 1.6-1 I/O Circuit Type (1 / 3) Type Circuit X1,X1A Remarks clock input • • Oscillation feedback resistor: • X1, X0: about 1 MΩ • X1A, X0A: about 10 MΩ Use of standby control • Hysteresis input with pull-up • • Use of input pull-up resistor control CMOS level input/output X0,X0A A Standby control signal B Hysteresis input Control P-ch P-ch Digital output N-ch Digital output C CMOS input 11 CHAPTER 1 OVERVIEW OF MB90980 SERIES Table 1.6-1 I/O Circuit Type (2 / 3) Type Circuit Remarks CMOS level input/output P-ch Digital output N-ch Digital output D CMOS input P-ch Digital output N-ch Digital output CMOS Hysteresis input • • Hysteresis input CMOS level output • • CMOS level input/output Use of open-drain control • • • CMOS level output Hysteresis input Use of open-drain control E P-ch Open-drain control signal N-ch Digital output F CMOS input P-ch Open-drain control signal N-ch Digital output CMOS Hysteresis input G 12 Table 1.6-1 I/O Circuit Type (3 / 3) Type Circuit Remarks • • CMOS level input/output Analog input • • Hysteresis input N-ch open drain output P-ch N-ch H CMOS input Analog input N-ch Digital output I Hysteresis input (FLASH product) • CMOS level input • High-voltage control provided for FLASH test (FLASH product) N-ch N-ch N-ch N-ch J Control signal N-ch Mode input Dispersion resistor (Mask product) CMOS Hysteresis input (Mask product) • CMOS Hysteresis input 13 CHAPTER 1 OVERVIEW OF MB90980 SERIES 14 CHAPTER 2 HANDLING THE DEVICE This chapter provides precautions on handling the device. 2.1 Precautions on Handling the Device 15 CHAPTER 2 HANDLING THE DEVICE 2.1 Precautions on Handling the Device This section summarizes the precautions on the device’s power supply voltage and pin treatment. ■ Device Handing Precautions ● Preventing Latch-up Latch-up may occur if voltage higher than VCC or lower than VSS is applied to input and output pins other or if the power supply for AVCC is applied before VCC or if higher than the maximum rating voltage is applied between VCC pin and VSS pin. When latch-up occurs, power supply current increases rapidly and might thermally damage elements. Be sure to apply the voltage to analog system at the same time of VCC or after turning on the digital power supply (If power is OFF, turn off the analog system power supply in advance or at the same time). ● Treatment of Unused Pin Leaving unused input pins unconnected can cause abnormal operation or latch-up, leaving to permanent damage. Unused input pins should always be pulled up or down through resistance of at least 2KΩ. Connect to be AVCC=AVRH=VCC, AVSS=VSS if the A/D converter is not in use. ● Power Supply Pins (VCC pin or VSS pins) In products with multiple VCC or VSS pins, connect all power supply pins to external power supply and a ground line to lower the electro-magnetic emission level, to prevent abnormal operation of strobe signals caused by the rise in the ground level, and to conform to the total output current rating. Moreover, connect the current supply source with the VCC and VSS pins of this device at the low impedance. It is also advisable to connect a capacitor of approximately 0.1μF between VCC and VSS pins near this device. ● Crystal oscillation circuit Noise near the X0, X1 pins and X0A, X1A pins may cause the device to malfunction. Design printed circuit boards so that the crystal oscillator (or ceramic oscillator), and the bypass capacitor to ground are located as close to these pins as possible. In addition, design the printed circuit boards so that the wiring of them does not cross the other wirings as much as possible. It is also strongly recommended that the printed circuit board artwork surrounds these pins with ground to promote stable operation. Please ask the crystal maker to evaluate the oscillation characteristics of the crystal and this device. 16 ● Precautions for Use of External Clock If using an external clock, drive only X0 pin and open X1 pin. Figure 2.1-1 shows how to use the external clock. Figure 2.1-1 Example of Using External Clock X0 Open X1 ● Precautions in PLL clock mode On this microcontroller, if in case the crystal oscillator breaks off or an external reference clock input stops while the PLL clock mode is selected, a self-oscillator circuit contained in the PLL may continue its operation at its self-running frequency. However, Fujitsu will not guarantee results of operations if such failure occurs. ■ Power Supply Handling Precautions ● Stable Supply Voltage Supply voltage should be stabilized. A sudden change in power-supply voltage may cause a malfunction even within the guaranteed operating range of the VCC power-supply voltage. For stabilization, in principle, keep the variation in VCC ripple (p-p value) in a commercial frequency range (50/60Hz) not to exceed 10% of the standard VCC value and suppress the voltage variation so that the transient variation rate does not exceed 0.1V/ms during a momentary change such as when the power supply is switched. Flash serial programming must be performed with operational voltage is VCC=3.13V to 3.6V. Flash programming must be performed with operational voltage is VCC=3V to 3.6V. ● When using the single system product When using the MB90980 series as a single system product, use it with X0A=VSS, X1A=open. ● Precautions when using the dual power supplies MB90980 series usually uses 3V power supply. However, setting VCC3=3V system/VCC5=5V system enables P24 to P27, P30 to P37, P40 to P42, P70 to P74, P76 and P77 as 5V power supplies separately from the main 3V power supply. Analog power supply (AVCC, AVRH) at the time of A/D conversion is used only as a 3V system. 17 CHAPTER 2 HANDLING THE DEVICE 18 CHAPTER 3 CPU This chapter explains CPU specifications, memory, and the functions of registers to provide readers with a better understanding of the MB90980 functions. 3.1 Overview of CPU Specifications 3.2 Memory Space 3.3 CPU Registers 3.4 Prefix Codes 19 CHAPTER 3 CPU 3.1 Overview of CPU Specifications This section gives an overview of the CPU specifications. ■ Overview of CPU Specifications The F2MC-16LX CPU core is a 16-bit CPU designed for devices such as consumer devices that requires high-speed real-time processing. The F2MC-16LX instruction set is designed for controller applications, providing high-speed and high-efficiency control processes. In addition to 16-bit data processing, the F2MC-16LX CPU core can provide 32-bit data processing with an installed internal 32-bit accumulator (some instructions perform 32-bit data processing). Memory spaces are a maximum of 16 M bytes (expandable) and can be accessed by using a linear pointer or bank. Based on the F2MC-8L AT architecture, its instruction system is improved because of increasing the instructions supporting high-level languages, expanding addressing modes, improving multiply and divide operation instructions, and enhancing bit processing. The F2MC-16LX CPU has the following features: ● Minimum instruction execution time • 40.0 ns/6.25 MHz oscillation multiplied by 4 (25 MHz/3.3 V ± 0.3 V for internal operation) • 62.5 ns/4 MHz oscillation multiplied by 4 (16 MHz/3.0 V ± 0.3 V for internal operation) • PLL clock multiply scheme ● Maximum memory space: 16 M bytes, accessing by using a linear pointer or bank ● Instruction system optimized for control applications • Data types available: bit, byte, word, long word • Standard addressing mode: Use of 23-type, 32-bit accumulator for enhancing high-precision operation • Signed multiply and divide operations, expanded RETI instruction ● Enhanced interrupt function: 8 priority levels (programmable) ● CPU independent automatic transfer function: μDMAC up to 16 channels ● Multitasking-compatible instruction system in high-level language (C) Use of system stack pointers, symmetrical instruction set, and barrel shift instruction ● Improved execution speed: 4-byte queue 20 3.2 Memory Space The F2MC-16LX CPU has a 16-M bytes memory space, to which all input to and output from the F2MC-16LX CPU controlled data program is allocated. CPU has a 24-bit address bus to access each resource. ■ Memory Map Figure 3.2-1 shows the F2MC-16LX system and the associated memory map. Figure 3.2-1 Example Showing Correspondence Between F2MC-16LX System and Memory Map Program FFFFFFH FF8000H Data 810000H Interrupt 800000H F2MC-16LX CPU Program area Data area [Device] Peripheral circuit Generalpurpose port 0000C0H 0000B0H 000020H 000000H Interrupt controller Peripheral circuit General-purpose port ■ Address Generation Type The F2MC-16LX CPU has two types of address generation. One is linear addressing that specifies all 24bit addresses with instructions. The other is bank addressing that specifies upper 8-bit addresses with appropriate bank registers and lower 16-bit addresses with instructions. Linear addressing has two types: one uses operands to directly specify 24-bit addresses; the other refers to contents of the lower 24 bits in a 32-bit general-purpose register as addresses. ● Linear addressing (specified with 24-bit operand) Figure 3.2-2 shows an example of linear addressing scheme specified with 24-bit operands. Figure 3.2-2 Linear Addressing (Specified with 24-bit Operand) JMPP 123456H Previous program counter 17 452D 17452DH 123456H New program counter 12 JMPP 123456H Next instruction 3456 21 CHAPTER 3 CPU ● Linear addressing (indirectly specified using 32-bit register) Figure 3.2-3 shows an example of linear addressing scheme indirectly specified using a 32-bit register. Figure 3.2-3 Linear Addressing (Indirectly Specified Using 32-bit Register) MOV A, @RL1+7 Old AL 090700H XXXX 3A +7 RL1 (Upper 8 bits are ignored) New AL 240906F9 003A ■ Addressing Type by Bank Bank addressing divides a 16-M bytes space into 256 banks of 64 K bytes each, using five bank registers to specify banks for each space. • Program bank register (PCB) • Data bank register (DTB) • User stack bank register (USB) • System stack bank register (SSB) • Additional bank register (ADB) A 64-K bytes bank specified with PCB is called the program (PC) space. The PC space includes such information as instruction codes, vector tables, and immediate data. A 64-K bytes bank specified with DTB is called the data (DT) space. The DT space includes writable data, and internal and external resource control/data registers. A 64-K bytes bank specified with USB or SSB is called the stack (SP) space. The SP space is accessed if a stack access occurs by saving the push/pop instruction or interrupt register. The stack space to be accessed is determined by the S-flag in the condition code register. A 64-K bytes bank specified with ADB is called the additional (AD) space. The AD space includes, for example, data that cannot be included in the DT space. As shown in Table 3.2-1, each addressing mode uses a default space defined in advance to improve the efficiency of coding instructions. If an addressing mode uses a space other than the default space, a prefix code corresponding to the bank must be specified prior to the instruction code, enabling access to any bank space corresponding to the prefix code. After resetting, DTB, USB, SSB and ADB are initialized to 00H, and PCB is initialized to the value specified by a reset vector. After resetting, each space for DT, SP and AD is allocated to bank 00H (000000H to 00FFFFH), and each PC space is allocated to the bank specified by the reset vector. 22 Table 3.2-1 Default Space Default space Addressing mode Program space PC indirect, program access, branch instruction Data space Addressing mode using @RW0,@RW1, @RW4, and @RW5; @A; addr16; dir Stack space Addressing mode using PUCHW, POPW, @RW3, and @RW7 Additional space Addressing mode using @RW2 and @RW6 Figure 3.2-4 shows an example of a memory space divided for a register bank. Figure 3.2-4 Physical Address in Each Space FFFFFFH FF0000H Program space FEH : PCB (Program bank register) B3H : ADB (Additional bank register) 92H : USB (User stack bank register) 68H : DTB (Data bank register) 4BH : SSB (System stack bank register) Physical address B3FFFFH B30000H 92FFFFH 920000H Additional space User stack space 68FFFFH 680000H Data space 4BFFFFH 4B0000H System stack space 000000H 23 CHAPTER 3 CPU ■ Allocation for Data of Multi-byte Length in Memory Space Figure 3.2-5 shows the configuration of data of a multi-byte length in memory. The lower 8 bits of a data item are stored at address n, then address n+1, address n+2, address n+3, etc. Figure 3.2-5 Example for Allocating Data of Multi-byte Length in Memory MSB 01010101 H 1100110 LSB 00000000 11111111 01010101 11001100 11111111 Address n 00000000 L Data is written to memory in sequence starting from the lower addresses. Thus, the lower 16 bits of a 32bit data item is transferred first, followed by the upper 16 bits. If a reset signal is input immediately after writing the lower bit, writing the upper bit may fail. ■ Access to Data of Multi-byte Length Figure 3.2-6 shows an example for accessing data of a multi-byte length. In this example, MOVW A, 030FFFFH is executed. Figure 3.2-6 Example for Accessing Data of Multi-byte Length H 80FFFFH AL before execution ?? ?? AL after execution 23H 01H 01H · · · 800000H 23H L 24 3.3 CPU Registers The F2MC-16LX registers are divided into special registers inside CPU and generalpurpose registers on memory. The former is dedicated hardware inside the CPU, and its use is limited because of the CPU architecture. The latter shares CPU address spaces with RAM. A general-purpose register can be accessed without specifying an address, and a user can specify the use of a general-purpose register, which is the same as for memory spaces. ■ Dedicated Registers The F2MC-16LX has the following 11 types of dedicated registers: • Accumulator (A = AH: AL): Two 16-bit accumulators (used as single 32-bit accumulator) • User stack pointer (USP): 16-bit pointer pointing to user stack area • System stack pointer (SSP): 16-bit pointer pointing to system stack area • Processor status (PS): 16-bit register indicating system status • Program counter (PC): 16-bit register containing a program address • Direct page register (DPR): 8-bit register indicating a direct page • Program bank register (PCB): 8-bit register indicating a PC space • Data bank register (DTB): 8-bit register indicating a DT space • User stack bank register (USB): 8-bit register indicating a user stack space • System stack bank register (SSB): 8-bit register indicating a system stack space • Additional bank register (ADB): 8-bit register indicating an AD space Figure 3.3-1 shows the configuration of the dedicated registers. Figure 3.3-1 Configuration of Dedicated Registers AH AL Accumulator USP User stack pointer SSP System stack pointer PS Processor status PC Program counter DPR Direct page register PCB Program bank register DTB Data bank register USB User stack bank register SSB System stack bank register ADB Additional data bank register 8 bits 32 bits 16 bits 25 CHAPTER 3 CPU ■ General-purpose Register The F2MC-16LX general-purpose register resides on the main memory addresses: 000180H to 00037FH (maximum configuration). It uses a register bank register (RP) to indicate which part of addresses are currently used for register banks. Each bank has the three types of registers listed below. They are dependent on one another, as shown in Figure 3.3-2. • R0 to R7: 8-bit general-purpose register • RW0 to RW7: 16-bit general-purpose register • RL0 to RL3: 32-bit general-purpose register Figure 3.3-2 shows the configuration of a general-purpose register. Figure 3.3-2 Configuration of General-purpose Register MSB LSB 16 bits 000180H RP × 10H RW0 RL0 RW1 RW2 RL1 RW3 RW4 R1 R3 R2 RW5 R5 R4 RW6 R7 R6 RW7 RL2 The relationship between upper and lower bytes in a byte register and word register is represented with the following formula: RW(i + 4) = RW(i x 2 + 1) x 256 + R(i x 2) [i = 0 to 3]. The relationship of upper and lower bytes in RLi is represented with the following formula: RW(i) = RW(i x 2 + 1) x 65536 + RW(i x 2) [i = 0 to 3]. 26 3.3.1 Accumulator (A) This section explains the accumulator (A) functions. ■ Accumulator (A) An accumulator (A) consists of two 16-bit arithmetic operation registers (AH/AL) that are used to store operation results and temporarily store data transfer results. For 32-bit data processing, AH is connected with AL. For word processing in the 16-bit data processing mode and for byte processing in the 8-bit data processing mode, only AL is used. Data stored in an accumulator (A) is used together with that in memory and registers (Ri, Rwi, Rli); and similar to F2MC-8L operations, the data item with a smaller word length is transferred to AL. This enables data items in AL before the transfer to be automatically transferred to AH (data hold function). The data hold function and operation between AL-AH support improvements in processing efficiency. During a transfer of a data item with a lower byte length to AL, a sign extension or zero extension is added to the data, and the data is saved in AL as a 16-bit data item. Also, data in AL is handled in either word lengths or byte lengths. If an arithmetic operation instruction of byte processing is executed in AL, the upper 8 bits in AL before the operation is ignored, and the upper 8 bits of operation results are reset to zero. Resetting an accumulator (A) does not initialized it, and it has an undefined value after the reset. Figure 3.3-3 shows 32-bit data transfer processing, and Figure 3.3-4 shows AL-AH transfer processing. Figure 3.3-3 32-bit Data Transfer MOVL A,@RW1+6 A before execution XXXXH XXXXH DTB A after execution 8F74H LSB MSB A6H A61540H 8FH 74H A6153EH 2BH 52H 15H 38H +6 RW1 2B52H Figure 3.3-4 AL-AH Transfer MOVW A,@RW1+6 A before execution XXXXH 1234H DTB A after execution 1234H MSB A6H 2B52H LSB A61540H 8FH 74H A6153EH 2BH 52H 15H 38H +6 RW1 27 CHAPTER 3 CPU 3.3.2 User Stack Pointer (USP) and System Stack Pointer (SSP) This section explains the functions of the user stack pointer (USP) and system stack pointer (SSP). ■ User Stack Pointer (USP) and System Stack Pointer (SSP) The user stack pointer (USP) and system stack pointer (SSP) are 16-bit registers indicating the push/pop instruction or the memory address to which data is saved or restored at subroutine execution. The USP register and SSP register are used in stack-type instructions. If the S-flag in the processor status register is set to "0", the USP register is enabled. If the S-flag is set to "1", SSP register is enabled (see Figure 3.3-5). If an interrupt is accepted, the S-flag is set and then the register value is saved in the memory area indicated by SSP in interrupt processing. SSP is used to execute stack processing of interrupt routines, and USP is used to execute stack processing other than interrupt routines. Only SSP is used if stack space is not divided. In stack processing, the address of upper 8 bits is indicated with SSP -> SSB and USP -> USB. Resetting USP and SSP does not initialize them, but each then has an undefined value. Figure 3.3-5 shows the relationship between stack operation instructions and the stack pointer where the Sflag is set to "0" and "1". Figure 3.3-5 Relationship Between Stack Operation Instructions and Stack Pointer Example 1: PUCHW A where S-flag is set to "0" MSB Before execution AL S-flag After execution AL S-flag LSB A624H USB C6H USP F328H 0 SSB 56H SSP 1234H A624H USB C6H USP F328H 0 SSB 56H SSP 1234H C6F326H A6H 24H 561232H XX XX 561232H A6H 24H C6F326H XX XX Use of user stack because S-flag is set to "0" Example 2: PUCHW A where S-flag is set to "1" Before execution After execution AL A624H USB C6H USP F328H S-flag 1 SSB 56H SSP 1234H AL A624H USB C6H USP F328H S-flag 1 SSB 56H SSP 1232H Use of system stack because S-flag is set to "1" Note: Use an even-numbered address for a stack pointer, in principle. 28 3.3.3 Processor Status (PS) This section explains the processor status (PS) functions. ■ Processor Status (PS) Processor status (PS) consists of bits used to execute CPU operations and bits indicating the CPU state. As shown in Figure 3.3-6, the upper byte in the PS register consists of a register bank pointer (RP) and interrupt level mask register (ILM). RP indicates the header address of a register bank. The lower byte of PS register is the condition code register (CCR) that includes a flag that is set and reset depending on execution results or interrupt events. Figure 3.3-6 shows the configuration of processor status (PS). Figure 3.3-6 Configuration of Processor Status (PS) bit 15 PS 13 12 0 8 7 ILM RPCCR ■ Condition Code Register (CCR) Figure 3.3-7 shows the configuration of the condition code register. Figure 3.3-7 Configuration of Condition Code Register bit 7 6 5 4 3 2 1 0 - I S T N Z V C - 0 1 * * * * * Initial value * : Not defined ● I: Interrupt permission flag An interrupt other than software interrupt is permitted if the I-flag is set to "1" and masked if set to "0". The I-flag is cleared if reset. ● S: Stack flag If the S-flag is set to "0", USP is enabled as the stack operation pointer, and if it is set to "1", SSP is enabled. The S-flag is set if an interrupt or reset occurs. ● T: Sticky bit flag If the logic right shift instruction or arithmetic right shift instruction is executed, there is one or more "1" in the data shifted out by a carry operation, then the T-flag is set to either "1". Otherwise, it is set to "0". If the shift amount is zero, it is set to "0". ● N: Negative flag If MSB in operation results indicates "1", the N-flag is set. Otherwise, it is cleared. 29 CHAPTER 3 CPU ● Z: Zero flag If all operation results indicate "0", the Z-flag is set. Otherwise, it is cleared. ● V: Overflow flag If an overflow with a signed figure occurs as an operation execution result, the V-flag is set. Otherwise, it is cleared. ● C: Carry flag If a shift-in/shift-out operation occurs from MSB as operation execution results, the C-flag is set. Otherwise, it is cleared. ■ Register Bank Pointer (RP) The register bank pointer (RP) shows the relationship between the F2MC-16LX general-purpose register and internal RAM addresses. RP indicates the header memory address in the currently used register bank with the conversion formula [00180H + RP x 10H]. RP consists of 5 bits, with an address ranging from 00H to 1FH. A register bank can be allocated to a memory address in a range of 000180H to 00037FH. Even in this range, however, a register bank cannot be used as a general-purpose register if a register bank is not in internal RAM. An instruction transfers an immediate value of 8 bits to RP, but only the lower 5 bits are actually used. Figure 3.3-8 Configuration of Register Bank Pointer (RP) Initial value B4 B3 B2 B1 B0 0 0 0 0 0 ■ Interrupt Level Mask Register (ILM) The interrupt level mask register (ILM) consists of 3 bits indicating the level of the CPU interrupt mask. Only interrupt request of an interrupt level higher than that represented with the 3 bits is accepted. The highest level is indicated with "0", the lowest level is indicated with "7" (see Table 3.3-1). Thus, to accept an interrupt, its level must be lower than the current ILM value. If an interrupt is accepted, its interrupt level value is set to ILM, and then any interrupts with the same or lower level of the interrupt priority are not accepted. ILM is initialized to zero by a reset. An instruction can transfer an 8-bit immediate value to the ILM register, but only the lower 3 bits are actually used. Figure 3.3-9 shows the configuration of the interrupt level mask register. Table 3.3-1 has explanations of the level indicated in the interrupt level mask register (ILM). Figure 3.3-9 Configuration of Interrupt Level Mask Register ILM2 Initial value 30 0 ILM1 ILM0 0 0 Table 3.3-1 Level Indicated by Interrupt Level Mask Register (ILM) ILM2 ILM1 ILM0 Level value Permitted interrupt level 0 0 0 0 Interrupt prohibited 0 0 1 1 "0" only 0 1 0 2 Level value less than 1 0 1 1 3 Level value less than 2 1 0 0 4 Level value less than 3 1 0 1 5 Level value less than 4 1 1 0 6 Level value less than 5 1 1 1 7 Level value less than 6 31 CHAPTER 3 CPU 3.3.4 Program Counter (PC) This section explains the program counter (PC) functions. ■ Program Counter (PC) PC is a 16-bit counter indicating the lower 16 bits in the memory address of an instruction code to be executed by CPU. An upper 8-bit address is indicated with the program count bank register (PCB). PC contents are updated by condition branch instructions, subroutine call instructions, interrupts, or resets. It may also be used as a base pointer for operand access. Figure 3.3-10 explains the program counter (PC) functions. Figure 3.3-10 Program Counter (PC) Functions PCB FEH PC ABCDH Next instruction executed FEABCDH 32 3.3.5 Program Count Bank Register (PCB) This section explains the program count bank register (PCB) functions. ■ Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector> The program count bank register (PCB) consists of the following registers: • Data bank register (DTB) < Initial value: 00H > • User stack bank register (USB) < Initial value: 00H > • System stack bank register (SSB) < Initial value: 00H > • Additional data bank register (ADB) < Initial value: 00H > Each bank register indicates memory banks to which PC, DT, SP (user), SP (system), and AD space are allocated. All bank registers has a length of 1 byte. They are initialized to "00H" by a reset. Bank registers other than PCB can be read. PCB can be read, but writing to PCB is not permitted. PCB is updated either when the JMPP, CALLP, RETP, RETI, or RETF instruction that branches is executed, and it may then branch to an entire 16-M bytes space. PCB is also updated when an interrupt occurs. For information on the operation of each register, see Section "3.2 Memory Space". 33 CHAPTER 3 CPU 3.3.6 Direct Page Register (DPR) This section explains the direct page register (DPR) functions. ■ Direct Page Register (DPR) <Initial Value: 01H> The direct page register (DPR) specifies, as shown in Figure 3.3-11, addresses 8 to 15 of an instruction operand in the direct addressing mode. DPR has a length of 8 bits, and is initialized to "01H" by a reset. It also allows reading and writing by instructions. Figure 3.3-11 illustrates the generation of a physical address in the direct addressing mode. Figure 3.3-11 Generating a Physical Address in Direct Addressing Mode DTB register MSB 24-bit physical address 34 DPR register Direct address in instruction LSB 3.3.7 General-Purpose Register (Register Bank) This section explains the general-purpose register (register bank) functions. ■ General-purpose Register (Register Bank) A register bank consists of 8 words and is used as a general-purpose register for arithmetic operation in the byte register (R0 to R7), word register (RW0 to RW7), and long-word register (RL0 to RL3). A register bank is also used as an instruction pointer. Table 3.3-2 lists the register functions and Figure 3.3-12 shows the relationship among registers. Register bank values are not initialized by a reset, the same as for RAM spaces, but the state before resetting is kept. At power-on, however, the values are undefined. Table 3.3-2 Register Functions R0 to R7 Used as operand in different instructions Note: R0 is used as the barrel shift counter or normalization instruction counter. RW0 to RW7 Used as a pointer or operand in different instructions Note: RW0 is used as a string instruction counter. RL0 to RL3 Used as a long pointer or operand in different instructions Figure 3.3-12 Relationship Among Registers RW0 RW1 RW2 RW3 R0 R1 R2 R3 RW4 RW5 RL0 R4 RL1 R5 RL2 R6 RW6 RL3 RW7 R7 35 CHAPTER 3 CPU 3.4 Prefix Codes By inserting a prefix code before an instruction, part of an instruction operation may change. Three types of prefix code are provided: bank select prefixes, common register bank prefixes, and flag change suppress prefixes. ■ Bank Select Prefix (PCB, DTB, ADB, SPB) Memory space used in data access is determined according to the addressing mode. By inserting a bank select prefix before an instruction, the instruction may select the memory space used for data access regardless of the addressing mode in use. Table 3.4-1 shows the relationship between the bank select prefix and a selected space. Table 3.4-1 Bank Select Prefix Bank select prefix Selected space PCB PC space DTB Data space ADB AD space SPB Either SSB or USB space is used depending on the stack flag value. Be careful when you are using the following instructions: ● String instruction (MOVS, MOVSW, SCEQ, SCWEQ, FILS, FILSW) This uses bank registers specified with an operand regardless of a prefix. ● Stack operation instruction (PUSHW, POPW) SSB or USB is used depending on the S-flag, regardless of a prefix. ● I/O access instruction MOVA A, io/MOV io, A/MOVX A, io/MOVW A, io/MOVW io, A MOV io, #imm8/MOVW io, #imm8/MOBV A, io: bp/MOVB io: bp, A SETB io: bp/CLRB io: bp/BBC io:bp, rel/BBS io:bp, rel WBTC WBTS The I/O space of a bank is used regardless of whether a prefix is in an instruction. ● Flag change instruction (AND CCR,#imm8,OR CCR,#imm8) An instruction operation is normal, but a prefix affects the next instruction. ● POPW PS Regardless of prefix, SSB or USB is used depending on the S-flag. A prefix affects the next instruction. 36 ● MOV ILM, #imm8 If an instruction operation is normal, but a prefix affects the next instruction. ● RETI SSB is used regardless of prefix. ■ Common Register Bank Prefix (CMR) To facilitate data exchange between multiple tasks, the same register bank needs to be easily accessed regardless of each register bank pointer (RP) value. If CMR is inserted before an instruction that accesses a register bank, the instruction accesses the common bank with addresses ranging from 000180H to 00018FH (register bank selected if RP = 0) regardless of the current RP value. However, be careful when you are using the following instructions: ● String instruction (MOVS, MOVSW, SCEQ, SCWEQ, FILS, FILSW) If an interrupt request is issued while a string instruction with a prefix code is executed, the prefix code is disabled when the string instruction is returned after the interrupt is processed. Thus, with interrupt processing, the string instruction causes an error. Do not add a CMR prefix to such a string instruction. ● Flag change instruction (AND CCR, #imm8, OR CCR, #imm8) An instruction operation is normal, but a prefix affects the next instruction. ● MOV ILM, #imm8 An instruction operation is normal, but a prefix affects the next instruction. ■ Flag Change Suppress Prefix (NCC) To suppress a flag change, specify the flag change suppress prefix code (NCC). By inserting NCC before an instruction, the flag change caused by an instruction is suppressed. However, be careful if you use instructions listed below. ● String instruction (MOVS, MOVSW, SCEQ, SCWEQ, FILS, FILSW) If an interrupt request occurs while a string instruction with prefix code is executed, the prefix code is disabled when the string instruction is returned after the interrupt is processed. Thus, with interrupt processing, the string instruction causes an error. Do not add a CMR prefix to the above string instruction. ● Flag change instruction (AND CCR, #imm8, OR CCR, #imm8) An instruction operation is normal, but a prefix affects the next instruction. ● Interrupt instruction (INT #vct8, INT9, INT addr16, INTO addr24, POPW PS) CCR changes according to the instruction specification regardless of the prefix. ● JCTX@A CCR change according to the instruction specification regardless of the prefix. 37 CHAPTER 3 CPU ● MOV ILM, #imm8 An instruction operation is normal, but a prefix affects the next instruction. ■ Interrupt Suppress Instruction No interrupt requests are sampled on ten types of instruction as follows. MOV ILM, #imm8/PCB/SPB/OR CCR, #imm8/NCC AND CCR, #imm8/ADB/CMR/POPW PS/DTB If an effective interrupt request is issued when any of above instructions is executed, an interrupt may be processed only if instructions other than the above are executed. For more information, see Figure 3.4-1. Figure 3.4-1 Interrupt Suppress Instruction Interrupt suppress instruction (a) (a) Normal instruction Interrupt request Interrupt accept ■ Restrictions on Interrupt Suppress Instruction and Prefix Instruction If a prefix code is inserted before an interrupt is suppressed, the prefix code affects up to the first instruction that appears after any code other than interrupt suppress instructions, as shown in Figure 3.4-2. Figure 3.4-2 Interrupt Suppress Instruction and Prefix Code Interrupt suppress instruction MOV A, FFH NCC ADD A,01H MOV ILM,#imm8 CCR:XXX10XXB No CCR changes are caused by NCC. ■ Continuous Prefix Codes If continuous prefix codes conflict, the latest ones are valid, as shown in Figure 3.4-3. Such conflicting prefix codes mean PCB, ADB, DTB, and SPB, as shown in Figure 3.4-3. Figure 3.4-3 Continuous Prefix Codes Prefix code ADB DTB PCB ADD A,01H PCB is valid as a prefix code. 38 CHAPTER 4 INTERRUPT This chapter explains interrupts and direct memory access (DMA). 4.1 Overview of Interrupt 4.2 Interrupt Factor and Interrupt Vector 4.3 Interrupt Control Register and Peripheral Function 4.4 Hardware Interrupt 4.5 Software Interrupt 4.6 Interrupt by μDMAC 4.7 Interrupt by Extended Intelligent I/O Service (EI2OS) 4.8 Exception Processing Interrupt 4.9 Stack Operation of Interrupt Processing 4.10 Sample Program of Interrupt Processing 4.11 Delay Interrupt Generation Module 39 CHAPTER 4 INTERRUPT 4.1 Overview of Interrupt F2MC-16LX has the following four interrupt functions that temporarily stop processing currently being performed and make the control move to programs defined separately when certain events occur: • Hardware interrupt • Software interrupt • Interrupt by μDMAC • Exception processing ■ Types and Functions of Interrupts ● Hardware interrupt Control is moved to the user-defined interrupt processing program in response to an interrupt request from a peripheral function. ● Software interrupt Control is moved to the user-defined interrupt processing program by execution of a dedicated instruction for software interrupts (e.g., INT instruction). ● Interrupt by μDMAC μDMAC is a function used to automatically transfer data between peripheral functions and memory. Previous data transfers by an interrupt processing program is provided in the same way as the direct memory access (DMA). When a transfer for data of a specified count is completed, an interrupt processing program is automatically executed. Interrupt by μDMAC is a type of hardware interrupts. ● Exception processing Exceptions are handled by interrupting normal processing at the instruction boundary if exception event (execution of undefined instruction) generation is detected. Exception processing is equivalent to software interrupt instruction "INT10". 40 ■ Overall Flow of Interrupt Operation Four types of interrupt functions provide start and return processing, as shown in Figure 4.1-1. Figure 4.1-1 Overall Flow of Interrupt Operation START Main program Valid hardware interrupt request String-type instruction being NO executed* YES Interrupt start and return processing μ DMAC? YES μ DMAC Fetching and decoding of next instruction NO INT instruction? YES Saving dedicated registers in the system stack NO μ DMAC processing Software interrupt and exception processing Hardware interrupt acceptance prohibited (I = 0) Hardware interrupt YES Specified count completed? End of request from peripheral function? Saving dedicated registers in the system stack NO Updating CPU interrupt processing level (ILM) RETI instruction? YES NO Execution of normal instruction NO Execution of interrupt return A dedicated register is returned from the system stack to the routine that exists before the interrupt routine is called. Reading of interrupt vector to update PC and PCB, and then branching to interrupt routine Completed reiteration of string-type instruction* YES Pointer moved to next instruction if PC updated * When a string-type instruction is being executed, the interrupt condition is checked in each step. 41 CHAPTER 4 INTERRUPT 4.2 Interrupt Factor and Interrupt Vector The F2MC-16LX has functions corresponding to 256 types of interrupt factors, and 256 interrupt vector tables are assigned to the highest address in the memory. The interrupt vector is shared by all interrupts. A software interrupt may use all of the above interrupts (INT0 to INT255), although parts of interrupt vectors are shared by hardware interrupt and exception processing interrupt. A hardware interrupt has a specific interrupt vector and interrupt control register (ICR) for each peripheral function. ■ Interrupt Vector Interrupt vector tables referred during interrupt processing are assigned to the memory area of the highest address ("FFFC00H" to "FFFFFFH"). The interrupt vectors for μDMAC, exception processing, hardware interrupt, and software interrupt share the same area. Table 4.2-1 lists the assignment of interrupt numbers and interrupt vectors. Table 4.2-1 Interrupt Vectors Software interrupt instruction Vector address L Vector address M Vector address H Mode data Interrupt No. Hardware interrupt INT0 FFFFFCH FFFFFDH FFFFFEH Unused #0 None : : : : : : : INT7 FFFFE0H FFFFE1H FFFFE2H Unused #7 None INT8 FFFFDCH FFFFDDH FFFFDEH FFFFDFH #8 (RESET vector) INT9 FFFFD8H FFFFD9H FFFFDAH Unused #9 None INT10 FFFFD4H FFFFD5H FFFFD6H Unused #10 < Exception processing > INT11 FFFFD0H FFFFD1H FFFFD2H Unused #11 Hardware interrupt #0 INT12 FFFFCCH FFFFCDH FFFFCEH Unused #12 Hardware interrupt #1 INT13 FFFFC8H FFFFC9H FFFFCAH Unused #13 Hardware interrupt #2 INT14 FFFFC4H FFFFC5H FFFFC6H Unused #14 Hardware interrupt #3 : : : : : : : INT254 FFFC04H FFFC05H FFFC06H Unused #254 None INT255 FFFC00H FFFC01H FFFC02H Unused #255 None Reference: For interrupt vectors that are not used, Fujitsu recommends specifying such vectors for the address for exception processing. 42 ■ Interrupt Factors, Interrupt Vector, and Interrupt Control Register Table 4.2-2 shows the relationship among interrupt factors excluding software interrupts, interrupt vectors, and interrupt control registers. Table 4.2-2 Interrupt Factors, Interrupt Vectors, and Interrupt Control Registers (1 / 2) Interrupt factor Clear of EI2OS μDMAC channel number Interrupt vector Number Address Interrupt control register Number Address Reset x - #08 FFFFDCH - - INT9 instruction x - #09 FFFFD8H - - Exception x - #10 FFFFD4H - - INT0 ❍ 0 #11 FFFFD0H ❍ ICR00 INT1 x #12 FFFFCCH 0000B0H INT2 ❍ x #13 FFFFC8H ❍ ICR01 INT3 x #14 FFFFC4H 0000B1H INT4 ❍ x #15 FFFFC0H ❍ ICR02 INT5 x #16 FFFFBCH 0000B2H INT6 ❍ x #17 FFFFB8H ❍ ICR03 INT7 x #18 FFFFB4H 0000B3H PWC1 ❍ x #19 FFFFB0H ICR04 - #20 FFFFACH 0000B4H - PWC0 ❍ 1 #21 FFFFA8H ICR05 PPG0/PPG1 counter borrow 2 #22 FFFFA4H 0000B5H x PPG2/PPG3 counter borrow x 3 #23 FFFFA0H ICR06 - #24 FFFF9CH 0000B6H - 8/16-bit U/D counter / timer (ch.0,1) / compare / underflow / overflow / up-down reverse ❍ x #25 FFFF98H ICR07 0000B7H Input capture (ch.0) load ❍ 5 #26 FFFF94H Input capture (ch.1) load ❍ 6 #27 FFFF90H ❍ ICR08 Output compare (ch.0) match #28 FFFF8CH 0000B8H 8 Output compare (ch.1) match ❍ 9 #29 FFFF88H ❍ ICR09 Output compare (ch.2) match #30 FFFF84H 0000B9H 10 - - 43 CHAPTER 4 INTERRUPT Table 4.2-2 Interrupt Factors, Interrupt Vectors, and Interrupt Control Registers (2 / 2) Interrupt factor Clear of EI2OS μDMAC channel number Interrupt vector Number Address ❍ x #31 FFFF80H - - - #32 FFFF7CH - - - #33 FFFF78H UART transmit completed ❍ 11 #34 FFFF74H 16-bit free-run timer overflow 16-bit reload timer underflow *2 ❍ 12 #35 UART receive completed ❂ 7 #36 FFFF6CH SI01 (ch.0) ❍ 13 #37 FFFF68H SI02 (ch.1) ❍ 14 #38 FFFF64H I2C interface x x #39 FFFF60H A/D ❍ 15 #40 FFFF5CH FLASH write/delete, time-base timer, watch timer*1 x x #41 FFFF58H Delay interrupt generation module x Output compare (ch.3) match x #42 Interrupt control register Number Address ICR10 0000BAH ICR11 0000BBH ICR12 0000BCH ICR13 0000BDH ICR14 0000BEH ICR15 0000BFH FFFF70H FFFF54H x : The interrupt request flag cannot be cleared by the interrupt clear signal. ❍ : The interrupt request flag is cleared. ❂ : The interrupt request flag is cleared. The stop request is provided. *1 : Caution: The FLASH write/erase, time-base timer, and watch timer cannot be used at the same time. *2 : Please write "0" in the INTE bit, after prohibiting interrupt by setting the IL2 bit to IL0 bit of the interrupt control register to "111B", if the reload timer underflow interrupt setting is changed from enable (INTE bit of TMCSR registers =1) to prohibit (INTE bit of TMCSR registers =0). 44 4.3 Interrupt Control Register and Peripheral Function Interrupt control registers (ICR00 to ICR15) are located in the interrupt controller, and they correspond to every peripheral function that has an interrupt function. This register controls interrupts. ■ List of Interrupt Control Registers Table 4.3-1 lists interrupt control registers and the corresponding peripheral functions. Table 4.3-1 List of Interrupt Control Registers Address Register Abbreviation Corresponding peripheral functions 0000B0H Interrupt control register 00 ICR00 INT0, INT1 0000B1H Interrupt control register 01 ICR01 INT2, INT3 0000B2H Interrupt control register 02 ICR02 INT4, INT5 0000B3H Interrupt control register 03 ICR03 INT6, INT7 0000B4H Interrupt control register 04 ICR04 PWC1 0000B5H Interrupt control register 05 ICR05 8/16-bit PPG timer 0, 1 PWC0 0000B6H Interrupt control register 06 ICR06 8/16-bit PPG timer 2, 3, 4, 5 0000B7H Interrupt control register 07 ICR07 8/16UD counter 0, 1, input capture 0 0000B8H Interrupt control register 08 ICR08 Input capture 1, output compare 0 0000B9H Interrupt control register 09 ICR09 Output compare 1, 2 0000BAH Interrupt control register 10 ICR10 Output compare 3, 4 0000BBH Interrupt control register 11 ICR11 Output compare 5, UART transmit 0000BCH Interrupt control register 12 ICR12 UART receive, 16-bit free-run timer, 16-bit reload timer 0000BDH Interrupt control register 13 ICR13 SIO0, SIO1 0000BEH Interrupt control register 14 ICR14 A/D, I2C interface 0000BFH Interrupt control register 15 ICR15 FLASH write, time-base timer, watch timer, delayed interrupt generation module Note: Avoid accessing the interrupt control register (ICR) with read-modify-write instructions since they may cause incorrect operation. 45 CHAPTER 4 INTERRUPT 4.3.1 Interrupt Control Register (ICR00 to ICR15) The interrupt control register (ICR00 to ICR15) corresponds to every peripheral function that has interrupt functions for controlling processing during interrupt request generation. This register has different functions between write and read operations. ■ Interrupt Control Register (ICR00 to ICR15) Function The interrupt control register (ICR00 to ICR15) consists of bit having the following four functions: • Interrupt level setting bits (IL2 to IL0) • Extended intelligent I/O service (EI2OS) permission bit (ISE) • Extended intelligent I/O service (EI2OS) channel selection bits (ICS3 to ICS0) • Extended intelligent I/O service (EI2OS) status bits (S1, S0) ■ Configuration of Interrupt Control Register (ICR00 to ICR15) Figure 4.3-1 shows the bit configuration of the interrupt control register (ICR00 to ICR15). Figure 4.3-1 Bit Configuration of Interrupt Control Register (ICR00 to ICR15) Interrupt control register (ICR) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 Address 0000B0H ICS3 ICS2 ICS1 ICS0 ISE IL2 IL1 IL0 to 0000BFH W W W W R/W R/W R/W R/W Initial value 00000111B Interrupt control register (ICR) Address 0000B0H to 0000BFH bit7 R/W : R : W : : - bit6 - bit5 bit4 bit3 bit2 bit1 bit0 Initial value S1 S0 ISE IL2 IL1 IL0 XX000111B R R R/W R/W R/W R/W Readable/Writable Read only Write only Undefined Notes: • Only when extended intelligent I/O service (EI2OS) is started, the ICS3 to ICS0 bits are valid. Please set "1" to the ISE bit when EI2OS is started. Please set "0" to the ISE bit when EI2OS is not started. When EI2OS is not started, the setting of the ICS3 to ICS0 bits are unnecessary. • ICS1, ICS0 bits can be only write. S1, S0 bits can be only read. 46 ■ Function of Each Bit in Interrupt Control Register (ICR00 to ICR15) ● Interrupt level setting bits (IL2 to IL0) This specifies the corresponding interrupt level in the peripheral function. A reset initializes the bit to level 7 (no interrupts). Table 4.3-2 lists the relationship between interrupt level setting bits and every interrupt level. Table 4.3-2 Relationship Between Interrupt Level Setting Bits and Interrupt Levels IL2 IL1 IL0 Interrupt level 0 0 0 0 (Highest interrupt) 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 6 (Lowest interrupt) 1 1 1 7 (No interrupt) ● Extended intelligent I/O service (EI2OS) permission bits (ISE) When this bit is "1" at the generating interrupt request, EI2OS is started. When this bit is "0" at the generating interrupt request, the interruption sequence is started. When the EI2OS end requirement is satisfied (without S1, S0=00B), the ISE bit is cleared to "0". Please set "0" to the ISE bit with software when the corresponding resource doesn't have the EI2OS function. The ISE bit is initialized to "0" by reset. 47 CHAPTER 4 INTERRUPT ● Extended intelligent I/O service (EI2OS) channel selection bits (ICS3 to ICS0) The ICS3 to ICS0 bits are write only bits and specify the channel of EI2OS descriptor address is determined depending on the value set to the ICS3 to ICS0 bits. The ICS3 to ICS0 bits are initialized to "0000B" by reset. Table 4.3-3 shows the relation between EI2OS channel selection bit and the descriptor address. Table 4.3-3 Relationship Between EI2OS Channel Selection Bits and Descriptor Address ICS3 ICS2 ICS1 ICS0 Selected channel Descriptor address 0 0 0 0 0 000100H 0 0 0 1 1 000108H 0 0 1 0 2 000110H 0 0 1 1 3 000118H 0 1 0 0 4 000120H 0 1 0 1 5 000128H 0 1 1 0 6 000130H 0 1 1 1 7 000138H 1 0 0 0 8 000140H 1 0 0 1 9 000148H 1 0 1 0 10 000150H 1 0 1 1 11 000158H 1 1 0 0 12 000160H 1 1 0 1 13 000168H 1 1 1 0 14 000170H 1 1 1 1 15 000178H ● Extended intelligent I/O service (EI2OS) status bits (S1, S0) S1, S0 bits are read-only bits. Whether the state is operating or terminated can be read by confirming the S1, S0 bits value at the end of EI2OS. S1, S0 bits are initializes to "00B" by reset. Table 4.3-4 shows the relation between S1, S0 bit and EI2OS status. Table 4.3-4 Relationship Between EI2OS Status Bit and EI2OS State 48 S1 S0 0 0 Operating EI2OS or inactive 0 1 Stop due to end of counting 1 0 Unused 1 1 Stop due to generation of request from resource EI2OS state 4.4 Hardware Interrupt Hardware interrupt is a function to temporarily stop the execution of program being executed by the CPU in response to an interrupt request signal from the peripheral function. It then moves control to the interrupt processing program defined by a user. Also, μDMAC and external interrupt may be executed as a kind of hardware interrupt. ■ Hardware Interrupt Function ● Hardware interrupt function A hardware interrupt compares the interrupt level of an interrupt request signal that is output by the peripheral function with interrupt level mask register (ILM) in the CPU processor status (PS). It then refers to the I-flag in the processor status (PS) to determine whether or not the interrupt is acceptable. If the hardware interrupt is accepted, registered contents in the CPU are automatically saved to the system stack, and the interrupt level currently requested is stored in the interrupt level mask register (ILM). In this event, control then branches to the corresponding interrupt vector. ● Multiple interrupts Multiple hardware interrupts can start at one time. ● μDMAC μDMAC is an automatic transfer function between memory and I/O, and if the transfer is completed, a hardware interrupt starts. μDMAC does not start in a multiplex manner, and if some μDMAC process is executed, other interrupt requests and all μDMAC requests wait temporarily. ● External interrupt An external interrupt (including wake-up interrupt) is accepted as a hardware interrupt via the peripheral function (interrupt request detect circuit). ● Interrupt vector Interrupt processing refers to the interrupt vector table assigned in memory addresses ranging from "FFFC00H" to "FFFFFFH" and shared with software interrupts. For the assignment of interrupt number and interrupt vector, see Section "4.2 Interrupt Factor and Interrupt Vector". 49 CHAPTER 4 INTERRUPT ■ Configuration of Hardware Interrupt The hardware-interrupt mechanism is divided into four parts, as shown in Table 4.4-1. To use hardware interrupts, a program must contain settings for the four locations. Table 4.4-1 Hardware-interrupt Mechanism Hardware-interrupt mechanism Function Peripheral function Interrupt enable bit, interrupt request bit Control of interrupt request by peripheral function Interrupt controller Interrupt control register (ICR) Setting for interrupt level and controlling μDMAC Interrupt enable flag (I) Identifying interrupt enable state Interrupt level mask register (ILM) Comparing request interrupt level with current interrupt level Micro-code Executing interrupt processing routine Interrupt vector table Storing branch address for interrupt processing CPU "FFFC00H" to "FFFFFFH" in memory ■ Suppressing Hardware Interrupt Accepting a hardware interrupt request is suppressed under the following conditions: ● Suppressing hardware interrupts during writing to peripheral function control register area During writing to the peripheral function control register area, no hardware interrupt requests are accepted. This prevents incorrect interrupt-related operations by the CPU during its rewriting of the interrupt control registers with each peripheral function. Peripheral function control register area refers not to a range of "000000H" to "0000FFH" for the I/O addressing area, but to the areas assigned to the control register within peripheral function control registers and data register. Figure 4.4-1 shows hardware interrupt operations during writing to the peripheral function control register area. Figure 4.4-1 Hardware Interrupt Requests during Writing to Peripheral Function Control Register Area Write instruction to peripheral function control register area MOV A,#08 MOV io,A Interrupt request is issued at this point 50 MOV A,2000H Not branched to interrupt Interrupt processing Branched to interrupt ● Suppressing hardware interrupts in the interrupt suppress instruction Hardware interrupt suppress instruction is listed in Table 4.4-2. If a valid hardware interrupt request is generated during execution of these instructions, the interrupt request is not executed until execution of a subsequent instruction is completed. Table 4.4-2 Hardware Interrupt Suppress Instruction Prefix code Instruction that rejects interrupt and hold requests PCB DTB ADB SPB CMR NCC Interrupt and hold suppress instruction (instruction to delay the effect of prefix code) MOV ILM, #imm8 OR CCR, #imm8 AND CCR, #imm8 POPW PS ● A hardware interrupt is suppressed during execution of software interrupt When a software interrupt starts, other interrupt requests are not accepted so that the I-flag is cleared to "0". 51 CHAPTER 4 INTERRUPT 4.4.1 Hardware Interrupt Operation This section explains an operation starting from hardware interrupt request generation until completion of interrupt processing. ■ Starting Hardware Interrupt ● Operation of peripheral function (generating an interrupt request) The peripheral functions including hardware interrupt request functions have the "interrupt request flag" that indicate whether or not to generate an interrupt request and "interrupt enable flag" that selects whether to enable or disable an interrupt request to the CPU. The interrupt request flag is set when a peripheral function specific event is generated, and it issues an interrupt request to the interrupt controller if the interrupt enable flag is set to "enable". ● Operation of interrupt controller (control of interrupt request) The interrupt controller compares interrupt levels (IL) in interrupt requests that are received at one time, and selects the request of the highest level (the lowest value of IL) and notifies it to CPU. If multiple requests have the same level, the one with the lower interrupt number has a priority. ● CPU operation (acceptance of interrupt requests and interrupt processing) CPU compares the levels (ICR: IL2 to IL0) of received interrupts with the interrupt level mask register (ILM). If IL < ILM and the interrupt is permitted (I = 1, in PC: CCR), the interrupt processing microcode starts and interrupt processing is executed, after the instruction currently being executed is completed. Interrupt processing first saves the contents of a dedicated register (12 bytes of A, DPR, ADB, DTB, PCB, PC and PS) in the system stack (system stack space indicated by SSB and SSP). Then, it loads the interrupt vector to the program counter (PCB, PC), updates ILM, and sets the stuffing (S) flag (i.e., sets the CCR Sflag to "1" and enables the system stack). ■ Return from Hardware Interrupt In the interrupt processing program, if the RETI instruction is executed and the interrupt request flag of a peripheral function that is an interrupt factor is cleared, 12 bytes of the data saved in the system stack is returned to the dedicated register to restart the processing in progress before the interrupt branch. By clearing the interrupt request flag, the interrupt request that the peripheral function output to the interrupt controller is automatically removed. 52 ■ Hardware Interrupt Operation Figure 4.4-2 shows the operation from the generation of hardware interrupt until the completion of interrupt processing. Figure 4.4-2 Hardware Interrupt Operation Internal data bus PS,PC (7) Microcode PS I ILM IR Check (6) F2MC-16LX CPU Comparator (5) Other peripheral function (4) (3) Peripheral function generating an interrupt request Level comparator Enable FF Interrupt level IL AND Factor FF (8) (2) (1) Interrupt controller RAM IL PS I ILM IR FF : : : : : : Interrupt level setting bit for interrupt control register (ICR) Processor status Interrupt enable flag Interrupt level mask register Instruction register Flip-flop (1) An interrupt factor is generated in the peripheral function. (2) If an interrupt is permitted after referring to the interrupt enable bit of the peripheral function, the interrupt request is issued from the peripheral to the interrupt controller. (3) The interrupt controller that receives the interrupt request also checks the priority of a requested interrupt, and it then transfers the interrupt level (IL) corresponding to the interrupt request to the CPU. (4) The CPU compares the interrupt level (IL) requested from the interrupt controller with the interrupt level mask register (ILM). (5) If the compare results have a priority higher than the current interrupt processing level, the I-flag of the condition code register (CCR) is checked. (6) As a result of the check in step 5, if the I-flag indicates an interrupt enable (I = 1), the interrupt operation waits until the instruction currently being executed is completed and then sets ILM to the requested level (IL). (7) The contents of the resisters are saved and branched to the interrupt processing routine. (8) Software in the user's interrupt processing routine clears the interrupt factor generated in step 1 for executing the RETI instruction, and then interrupt processing is completed. 53 CHAPTER 4 INTERRUPT 4.4.2 Flow of Hardware Interrupt Operation If an interrupt request is generated by a peripheral function, the interrupt controller transfers its interrupt level to the CPU. If the CPU accepts the interrupt request, the instruction currently being executed is temporarily suspended to execute the interrupt processing routine or to start μDMAC. If a software interrupt is generated by the INT instruction, the interrupt processing routine is executed regardless of the CPU state. Moreover, if a software interrupt is generated by the INT instruction, the hardware interrupt is prohibited. ■ Hardware Interrupt Operation Flow Figure 4.4-3 shows the hardware interrupt operation flow. Figure 4.4-3 Flow of Hardware Interrupt Operation START Main program I&IF&IE=1 AND ILM>IL String-type instruction being executed* Interrupt start and return processing YES NO ENX=1? Reading and decoding of next instruction INT instruction? YES NO Software interrupt and exception processing Saving dedicated registers in the system stack NO YES μDMAC processing Has the specified number of times been completed? Or did a peripheral function issue a complete request? Saving dedicated registers in the system stack Hardware interrupt I 0 Hardware interrupt prohibited μDMAC YES NO ILM IL (If an interrupt request is accepted, its interrupt level is transferred to ILM.) YES RETI instruction? Execution of interrupt return NO Execution of normal instruction (Including interrupt processing) Return of dedicated registers from system stack and then its return to routine that existed before calling of interrupt routine Completed NO reiteration of string-type instruction* S 1 (Enabling system stack) PCB, PC Interrupt vector (Branching to interrupt processing routine) YES Moving of pointer to next instruction if PC updated *: When a string-type instruction is being executed, the interrupt condition is determined in each step. I: Interrupt permission flag of condition code register (CCR) IF : Interrupt request flag of peripheral function IE : Interrupt permission flag of peripheral function ILM : Interrupt level mask register (in PS) 54 ENX : Request flag executing DMA of DMA enable register (DER) Interrupt level setting bit in interrupt control register IL : (ICR) Stack flag in condition code register (CCR) S: PCB : Program bank register PC : Program counter 4.4.3 Procedure for Using Hardware Interrupt To use hardware interrupts, necessary setup including the system stack area, peripheral functions, and interrupt control registers (ICR) must be performed. ■ Procedure for Using Hardware Interrupt Figure 4.4-4 shows an example of a procedure for using hardware interrupts. Figure 4.4-4 Procedure for Using Hardware Interrupt Start (1) Setup of the system stack area (2) Initial setup of peripheral functions (3) Setup of ICR in the interrupt controller (4) Start for the operation of peripheral functions The interrupt enable bit is set to "permit" (5) Setup of ILM and I in PS Interrupt processing program Stack processing Branches to the interrupt vector (8) Execution of interrupt in a peripheral function (execution of an interrupt processing routine) (9) Clearing of interrupt factor (10) Interrupt return instruction (RETI) (7) Processing by hardware Main program (6) Generation of an interrupt request Main program (1) The system stack area is set up. (2) The initial setup of peripheral functions for which interrupt requests can be generated is performed. (3) The interrupt control register (ICR) is set up in the interrupt controller. (4) The peripheral function is set to the operation start state, and the interrupt enable bit is set to "permit". (5) The interrupt level mask register (ILM) and interrupt enable flag (I) are set to "interrupt acceptable". (6) A hardware interrupt request is generated by generation of a peripheral function interrupt. (7) Interrupt processing hardware saves registers to branch to the interrupt processing program. 55 CHAPTER 4 INTERRUPT (8) The interrupt processing program processes peripheral functions because of interrupt generation. (9) The interrupt request from peripheral function is canceled. (10) The interrupt return instruction is executed, and the program is restored to what it was before branching. 56 4.4.4 Multiple Interrupts Multiple hardware interrupt can be executed by specifying a different interrupt level for each interrupt level setting bit (IL0 to IL2) in the interrupt control register (ICR) in response to multiple interrupt request from the peripheral function. μDMACs cannot be started in duplicate, however. ■ Multiple Interrupt Operations While an interrupt processing routine is executed, if an interrupt request with a higher level is generated, the interrupt processing is interrupted and then the higher interrupt request is accepted. In this case, after execution of the interrupt with the higher level is completed, the interrupt processing being stopped is restarted. The interrupt level can be set in a range of 0 to 7, but a CPU does not accept the interrupt request when the level is set to 7. While an interrupt is executed, if another interrupt request with the same or lower level occurs, that interrupt request waits until the current interrupt is completed, unless ILM is changed by the I-flag. In the interrupt processing routine, if the I-flag in the condition code register (CCR) is set to "interrupt prohibited" (I in CCR set to "0") or the interrupt level mask register (ILM) is set to "interrupt prohibited" (ILM set to "000B"), the starting of multiple interrupts within the interrupt can be temporarily prohibited. Note: μDMAC cannot be started in duplicate. All other interrupt requests and μDMAC requests have to wait during execution of μDMAC. 57 CHAPTER 4 INTERRUPT ■ Example of Multiple Interrupts Suppose a timer interrupt has priority over the A/D converter. In this case, the interrupt level of the A/D converter is "2" whereas that of timer interrupt is "1". If a timer interrupt is generated while an A/D converter interrupt is executed, the processing shown in the Figure 4.4-5 is performed. Figure 4.4-5 Example of Multiple Interrupts Main program Peripheral (1) initialized A/D interrupt processing Interrupt level 2 (ILM = 010B) Timer interrupt processing Interrupt level 1 (ILM = 001B) (3) Timer interrupt generated A/D interrupt (2) generated (4) Timer interrupt processing Interrupt Restart Main process (8) restart (6) A/D interrupt processing (5) Timer interrupt return (7) A/D interrupt return ● A/D interrupt generation When the A/D converter interrupt processing starts, the interrupt level mask register (ILM) is automatically set to the same interrupt level (i.e., 2 in this example) as that for the A/D converter (IL2 to IL0 in ICR). In this example, if an interrupt request of level 1 or 0 is generated, the interrupt with higher priority is executed first. ● End of interrupt processing If interrupt processing is completed and a return instruction (RETI) is then executed, the values of the dedicated registers (A, DPR, ADB, DTB, PCB, PC, PS) saved in the stack are returned and the values of the interrupt level mask register (ILM) are specified to those defined before the interrupt. 58 4.4.5 Hardware Interrupt Processing Time The time period starting from generation of a hardware interrupt request until the execution of interrupt handling routine requires the time until the instruction currently being executed is completed plus the interrupt processing time. ■ Hardware Interrupt Processing Time The time period starting from generation of a hardware interrupt request and acceptance of the interrupt until the execution of interrupt handling routine requires the interrupt request sample waiting time and interrupt handling time (time required for preparing interrupt processing). Figure 4.4-6 illustrates the interrupt processing time. Figure 4.4-6 Interrupt Processing Time Normal instruction execution CPU operation Interrupt waiting time Interrupt request sample waiting time Interrupt handling Interrupt processing routine Interrupt handling time ( θ machine cycle)* Interrupt request generated : Last cycle of the instruction. The interrupt request is sampled in this part. * : One machine cycle corresponds with one clock interval of the machine clock interval (φ). ● Interrupt request sample waiting time Refers to a time period starting after an interrupt request is generated until the instruction currently being executed is completed. Sampling is performed in the last cycle of each instruction to determine whether an interrupt request is generated or not. Thus, during execution of each instruction, the CPU is unable to recognize an interrupt request, resulting in a waiting time. The interrupt request sample waiting time reaches the maximum value if an interrupt request occurs immediately after the start of PCPW, RW0, ... RW7 instructions (45 machine cycles), which have the longest execution cycle. 59 CHAPTER 4 INTERRUPT ● Interrupt processing time (θ machine cycles) After the CPU accepts an interrupt request, the CPU saves the dedicated registers in the system stack and fetches the interrupt vector. The interrupt processing time is thus derived from the following formula: θ = 24 + 6 x Z machine cycles • At interrupt start: • At interrupt return: θ = 11 + 6 x Z machine cycles (RETI instruction) The interrupt processing time differs depending on the address indicated by the stack pointer. Table 4.4-3 lists correction values (Z) for interrupt processing times. One machine cycle corresponds to a clock interval of machine clocks (φ). Table 4.4-3 Correction Values (Z) for Interrupt Processing Times Address pointed by stack pointer 60 Correction value (Z) External 8 bits +4 External even address +1 External odd address +4 Internal even address 0 Internal odd address +2 4.5 Software Interrupt Software interrupt is a function used to move control to the user-defined program for interrupt processing from a program that the CPU is being executed if a software interrupt instruction (INT instruction) is executed. A hardware interrupt is stopped while a software interrupt is executed. ■ Start of Software Interrupt ● Software interrupt start To start a software interrupt, execute the INT instruction. A software interrupt request has neither the interrupt request flag nor enable flag. It always generates an interrupt request if the INT instruction is executed. ● Hardware interrupt suppressed Because the INT instruction has no interrupt levels, the interrupt level mask register (ILM) is not updated. During INT instruction execution, the I-flag in the condition code register (CCR) is set to "0" to mask hardware interrupts. To permit a hardware interrupt during software interrupt processing, set the I-flag to "1" in the software interrupt processing routine. ● Software interrupt operation If the CPU obtains the INT instruction and execute it, a microcode for software interrupt processing starts. This microcode is used to save the registers inside the CPU in the system stack and to mask hardware interrupts (set the I-flag in CCR to "0"), leading to branch to the corresponding interrupt vector. For the assignment of interrupt numbers and interrupt vectors, see Section "4.2 Interrupt Factor and Interrupt Vector". ■ Return from Software Interrupt If an interrupt return instruction (RETI instruction) is executed in the interrupt processing program, the 12byte data saved in the system stack is restored to the dedicated registers, returning control to the processing that was executed before the interrupt processing. 61 CHAPTER 4 INTERRUPT ■ Software Interrupt Operation Figure 4.5-1 shows the operation starting from software interrupt generation until interrupt processing completion. Figure 4.5-1 Software Interrupt Operation Internal data bus PS,PC (2) Microcode (1) PS I S IR Queue Fetch RAM PS I S IR : : : : Processor status Interrupt enable flag Stack flag Instruction register (1) Run a software interrupt instruction. (2) Based on the microcode corresponding to the software interrupt instruction, the necessary processes are performed, such as save of the dedicated registers. The branch processing is then executed. (3) The RETI instruction is executed in user's interrupt processing routine to end interrupt processing. ■ Notes on Software Interrupts If the program bank register (PCB) is set to "FFH", the CALLV instruction vector area is duplicated with the table for INT #vct8 instructions. When creating software, make sure that the CALLV instruction and INT #vct8 instruction have no address duplication. 62 4.6 Interrupt by μDMAC The μDMAC controller is a simplified DMA that has the same function as EI2OS. DMA transfers are set up using the DMA descriptor. ■ μDMAC Functions μDMAC has the functions listed below. • Provides an automatic data transfer between a peripheral resource (I/O) and memory. • CPU program execution stops during the DMA start sequence. • The DMA transfer channel has 16 channels (a smaller channel number is assigned a higher DMA transfer priority) • Allow selection of whether or not to increment the transfer source and transfer destination addresses. • The DMA transfer starts with an interrupt factor of the peripheral resource (I/O). • DMA transfers are controlled with the (a) DMA enable register, (b) DMA stop status register, (c) DMA status register and (e) descriptor (assigned to a range of 000100H to 00017FH in RAM). • STOP requests are issued as a means to stop DMA transfers from a resource. • After the end of the DMA transfer, a flag is set to the bit corresponding to the transfer end channel of the DMA status register, and an end interrupt is then output to the interrupt controller. ■ List of μDMAC Registers ● μDMAC enable register (DER) μDMAC enable register (DER) has the bit configuration shown in the diagram below. Figure 4.6-1 Bit Configuration of μDMAC Enable Register (DER) 14 13 12 11 10 9 8 0000ADH EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 R/W R/W R/W R/W R/W R/W R/W R/W 7 6 5 4 3 2 1 0 EN7 EN6 EN5 EN4 EN3 EN2 EN1 EN0 R/W R/W R/W R/W R/W R/W R/W R/W bit 0000ACH 15 DERH Initial value 00000000B DERL Initial value 00000000B μDMAC enable register (DER) has the bit functions listed below. Table 4.6-1 Bit Function of μDMAC Enable Register (DER) ENx bit 0 (Initial value) 1 Function Outputs an interrupt request from a resource to the interrupt controller. (An interrupt request from a resource is not used as a DMA start request). An interrupt request output from a resource is used as a DMA start request. Cleared to "0" when the DMA transfer byte count reaches "0". 63 CHAPTER 4 INTERRUPT Note: If transiting to the standby modes (sleep mode, stop mode, watch mode, time-base timer mode) or CPU intermittent operation modes (main clock intermittent operation mode, PLL clock intermittent operation mode, sub clock intermittent operation mode), never forget to write "0000H" to μDMAC enable register (DER) before transiting to the mode. ● μDMAC stop status register (DSSR) The bit configuration of the μDMAC stop status register (DSSR) is shown below. Figure 4.6-2 Bit Configuration of μDMAC Stop Status Register (DSSR) bit 0000A4H 7 6 5 4 3 2 1 0 STP7 STP6 STP5 STP4 STP3 STP2 STP1 STP0 R/W R/W R/W R/W R/W R/W R/W R/W DSSR Initial value 00000000B The function of each bit in the μDMAC stop status register (DSSR) is shown below. Table 4.6-2 Bit Function of μDMAC Stop Status Register (DSSR) STPx bit Function 0 (Initial value) No STOP request is accepted in a DMA transfer. STOP request is accepted in a DMA transfer to stop DMA operation. STOP request is accepted the UART receive (channels 7) only. The bits other than the bit7 are not valid. Writing "1" by running software is not valid. 1 ● μDMAC status register (DSR) The bit configuration of the μDMAC status register (DSR) is shown below. Figure 4.6-3 Bit Configuration of μDMAC Status Register (DSR) bit 15 00009DH bit 00009CH 64 14 13 12 11 10 9 8 DE15 DE14 DE13 DE12 DE11 DE10 DE9 DE8 R/W R/W R/W R/W R/W R/W R/W R/W 7 6 5 4 3 2 1 0 DE7 DE6 DE5 DE4 DE3 DE2 DE1 DE0 R/W R/W R/W R/W R/W R/W R/W R/W DSRH Initial value 00000000B DSRL Initial value 00000000B The functions of each bit in the μDMAC status register (DSR) is shown in the table below. Table 4.6-3 Bit Function of μDMAC Status Register (DSR) DEx bit Function 0 (Initial value) 1 No DMA transfer has ended. If the DMA transfer ends, an interrupt request is output to the interrupt controller. Note: If "1" is written, DMA transfer does not end. An interrupt is output to the interrupt controller. ■ μDMAC Operations Figure 4.6-4 shows μDMAC operations. Data transfer using DMA is performed as described below. (1) A peripheral resource (I/O) requests the DMA transfer. (2) The DMA controller reads a descriptor. (3) The transfer source, transfer destination, and transfer data count are read from the descriptor. (4) The DMA transfer between I/O and memory starts. (5) For no transfer end: The interrupt request of a resource is cleared. For transfer end: After the DMA transfer ends, the μDMAC status register is set to the transfer end flag, thereby causing output of an interrupt request to the interrupt controller. Figure 4.6-4 μDMAC Operations Memory space by IOA I/O register I/O register Peripheral function (I/O) (1) (3) DMA descriptor (3) DER DMA controller (2) by BAP Buffer (4) by DCT CPU IOA BAP DER DCT : : : : Interrupt controller I/O address pointer Buffer address pointer DMA enable register (also selects ENx) Data counter 65 CHAPTER 4 INTERRUPT 4.6.1 DMA Descriptor The DMA descriptor is located in internal RAM within a range from "000100H" to "00017FH" consisting of 8 bytes x 16 channels. ■ DMA Descriptor Configuration The DMA descriptor consists of 8 bytes x 16 channels. Each DMA descriptor has the configuration shown in the Figure 4.6-5. Table 4.6-4 lists the relationship between channel number and DMA descriptor address. Figure 4.6-5 Configuration of DMA Descriptor MSB LSB Upper 8 bits of data counter (DCTH) "H" Lower 8 bits of data counter (DCTL) Upper 8 bits of I/O register address pointer (IOAH) Lower 8 bits of I/O register address pointer (IOAL) DMA control register (DMACS) Upper 8 bits of buffer address pointer (BAPH) Middle 8 bits of buffer address pointer (BAPM) Descriptor header address "L" Lower 8 bits of buffer address pointer (BAPL) Table 4.6-4 Relationship Between Channel Number and Descriptor Address (1 / 2) 66 μDMAC enable register Channel Descriptor address EN0 0 000100H INT0 EN1 1 000108H PWC0 EN2 2 000110H PPG0/PPG1 counter borrow EN3 3 000118H PPG2/PPG3 counter borrow EN4 4 000120H EN5 5 000128H Input capture (channel 0) load EN6 6 000130H Input capture (channel 1) load EN7 7 000138H UART receive completed EN8 8 000140H Output compare (channel 0) match EN9 9 000148H Output compare (channel 1) match Resource interrupt request ⎯ Table 4.6-4 Relationship Between Channel Number and Descriptor Address (2 / 2) μDMAC enable register Channel Descriptor address EN10 10 000150H Output compare (channel 2) match EN11 11 000158H UART transmit completed EN12 12 000160H 16-bit FRT/16-bit reload timer overflow EN13 13 000168H SIO1 EN14 14 000170H SIO2 EN15 15 000178H A/D converter Resource interrupt request 67 CHAPTER 4 INTERRUPT 4.6.2 Individual Registers of DMA Descriptor Each DMA descriptor consists of the following registers: • Data counter (DCT) • I/O register address pointer (IOA) • DMA control status register (DMACS) • Buffer address pointer (BAP) The registers must be initialized because their initial values become undefined when they are reset. ■ Data Counter (DCT) The data counter (DCT) is a register with a length of 16 bits and corresponds to the transfer data count. After each item of data is transferred, the counter decrements by one. If this counter reaches "0", DMA ends. Figure 4.6-6 shows the configuration of the data counter (DCT). If the data counter (DCT) is set to "0", the maximum data transfer count (i.e., 65536) is defined. Figure 4.6-6 Configuration of Data Counter (DCT) DCTH bit DCT 15 14 13 12 B12 B15 B14 B13 DCTL 05 04 03 02 01 11 10 09 08 07 06 B03 B02 B01 B11 B10 B09 B08 B07 B06 B05 B04 00 Initial value B00 XXXXXXXXXXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/Writable x : Undefined ■ I/O Register Address Pointer (IOA) The I/O register address pointer (IOA) is a register with a length of 16 bits, and it indicates the lower address (A15 to A0) of the I/O register providing a buffer for data transfers. All of the upper addresses (A23 to A16) are set to "0". Any I/O in a range of "000000H" to "00FFFFH" can be specified with the address. Figure 4.6-7 shows the configuration of the I/O register address pointer (IOA). Figure 4.6-7 Configuration of I/O Register Address Pointer (IOA) IOAH bit IOA 15 14 13 12 A15 A14 A13 A12 IOAL 05 04 03 02 01 11 10 09 08 07 06 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 00 Initial value A00 XXXXXXXXXXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/Writable x : Undefined 68 ■ DMA Control Status Register (DMACS) The DMA control status register (DMACS) has a length of 8 bits that indicate the update or fixed state, transfer data format (byte/word), and transfer directions for the buffer address pointer (BAP) and I/O register address pointer (IOA). Figure 4.6-8 shows the configuration of the DMA control status register (DMACS). Figure 4.6-8 Configuration of DMA Control Status Register (DMACS) bit 07 06 05 RESV RESV RESV 04 03 02 01 00 IF BW BF DIR SE Initial value XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W DMA end control bit SE 0 1 Operation is not ended by a request from a peripheral function. Operation is ended by a request from a peripheral function. DIR 0 1 Data transfer direction specify bit I/O register address pointer -> buffer address pointer Buffer address pointer → I/O register address pointer BF BAP update/fixed selection bit 0 1 The buffer address pointer is updated after a data transfer.*1 BW Transfer data length setting bit 0 1 The buffer address pointer is not updated after a data transfer. Byte Word IF IOA update/fixed selection bit 0 1 The I/O register address pointer is updated after a data transfer.*2 RESV Reserve bit The I/O register address pointer is not updated after a data transfer. Always set these bits to "0". R/W x *1 *2 : Readable/Writable : Undefined : The buffer address pointer changes at the lower 16 bits, and it can only be incremented. : I/O register address pointer can only be incremented. 69 CHAPTER 4 INTERRUPT ■ Buffer Address Pointer (BAP) The buffer address pointer (BAP) has a length of 24 bits, containing the address used in the next DMA transfer. BAP is independent from each DMA channel, so each DMA channel can transfer data between any of 16M bytes addresses and I/O. If the BF bit (BAP update/fixed selection bit) in the DMA control status register (DMACS) is set to "update provided", BAP changes at the lower 16 bits (BAPM and BAPL), but the upper 8 bits (BAPH) do not change. Figure 4.6-9 shows the configuration of BAP. Figure 4.6-9 Configuration of Buffer Address Pointer (BAP) bit 23 BAP 16 15 BAPH (R/W) 8 7 BAPM (R/W) 0 BAPL Initial value XXXXXXH (R/W) R/W : Readable/Writable X : Undefined Notes: • The I/O register address pointer (IOA) can be used to specify an area ranging from "000000H" to "00FFFFH". • The buffer address pointer (BAP) can be used to specify an area ranging from "000000H" to "FFFFFFH". 70 4.6.3 μDMAC Processing Procedure If an interrupt request is generated by a peripheral resource (I/O) and the corresponding μDMAC enable register (DER) has a setting of DMA start, then a DMA transfer is performed. If a data transfer ends at the specified count, an interrupt request is output to the interrupt controller. ■ μDMAC Processing Procedure Figure 4.6-10 shows a simple μDMAC processing procedure. Figure 4.6-10 μDMAC Processing Procedure Software processing Hardware processing Start Initial setup Setting up of system stack area Setup of DMA descriptor Initial setup of peripheral function Setup of interrupt control register (ICR) Initial setup of DMA controller Setting up of ILM and I in PS Clearing of peripheral interrupt (Interrupt request) and (DER: ENx = 1) Execution of user program DMA data transfer Evaluation of end request from countout event or resource (DMA transfer end) Clearing of peripheral interrupt NO YES DSRx=1 Clearing of DSR register by software RETI DERx: DMA enable register DSRx: DMA status register 71 CHAPTER 4 INTERRUPT 4.6.4 μDMAC Processing Time Time consumed in μDMAC processing varies with the following factors: • Settings of DMA control status register (DMACS) • Address (area) indicated by the I/O register address pointer (IOA) • Address (area) indicated by the buffer address pointer (BAP) • External data bus width for external access • Data length of transfer data When the μDMAC data transfer ends, a hardware interrupt starts, and then the interrupt processing time is added. ■ μDMAC Processing Time (Time Per One-time Transfer) ● If data transfer continues The μDMAC processing time during a continuation of a data transfer depends on the setting of DMA control status register (DMACS), as shown in Table 4.6-5. Table 4.6-5 μDMAC Execution Time Setting of IOA update/fixed selection bit (IF) BAP address update/fixed Setting of selection bit (BF) Note: Fixed Update Fixed 17 19 Update 19 21 In units of machine cycles. One machine cycle corresponds to one clock interval of the machine clock (φ). Correction is required depending on the condition at μDMAC execution, as shown in Table 4.6-6. Table 4.6-6 Correction Values of Data Transfer for μDMAC Execution Time Internal access External access I/O register address pointer B/even Odd B/even 8/odd B/even 0 +2 +1 +4 Odd +2 +4 +3 +6 B/even +1 +3 +2 +5 8/odd +4 +6 +5 +8 Internal access Buffer address pointer External access Note: 72 B indicates a byte data transfer, 8 indicates a word transfer with an external bus width of 8 bits, even indicates word transfer of an even-numbered address, and odd indicates a word transfer of an odd-numbered address. ● Transfer performance Minimum transfer speed 1.7 μs/10 MHz (machine clock) 1.07 μs/16 MHz (machine clock) • Built-in I/O → built-in RAM; or built-in RAM → built-in I/O without address increment • Even-numbered address → even-numbered address or 8-bit access Maximum transfer speed 2.8 μs/10 MHz (machine clock) 1.75 μs/16 MHz (machine clock) Table 4.6-7 indicates the correction values for interrupt handling time. Table 4.6-7 Correction Values (Z) for Interrupt Handling Time Address indicated by stack pointer Correction value (Z) External 8 bits +4 External even-numbered address +1 External odd-numbered address +4 Internal even-numbered address 0 Internal odd-numbered address +2 ● If a transfer is ended with an end request from a peripheral function (I/O) If the μDMAC data transfer ends partway (DEx = 1) because of an end request by a peripheral function (I/ O), the data transfer fails and a hardware interrupt starts. The μDMAC processing time in this case is calculated with the following formula. Z in the formula indicates a correction value for interrupt processing time (see Table 4.6-7). The μDMAC processing time if a transfer ends partway is: 36 + 6 x Z machine cycle where one machine cycle corresponds to one clock interval of the machine clock (φ). 73 CHAPTER 4 INTERRUPT 4.7 Interrupt by Extended Intelligent I/O Service (EI2OS) Extended Intelligent I/O Services (EI2OS) are a function that automatically transfers data between the peripheral function (resource) and RAM. After completion of the data transfer, hardware interruptions will occur. ■ Extended Intelligent I/O Service (EI2OS) Extended Intelligent I/O Service (EI2OS) is a kind of the hardware interrupt. Extended Intelligent I/O Service is a function that transfers data between the I/O area and RAM. Customer can have data transfers performed just by creating in advance a completion program and a setting program for the EI2OS activation. ● Advantages of EI2OS The advantages over interruption processing routine-based data transfers are as follows: • Since the creation of transfer program is not required, the program size can be reduced. • Because the transfer is activated by the interrupt source of peripheral function (resource), the data transfer source needs not to be set for polling. • Transferring address increment can be set. • Increment and no update of I/O register address ca be set. ● Interrupt by EI2OS termination Upon completion of the EI2OS data transfer(s), the completion condition branches to the interrupt routine. The factor for an EI2OS completion can be confirmed by checking the EI2OS status bit (ICR:S1,S0) by the interruption processing program. Interrupt number and interrupt vector are fixed by each peripheral function. For details, see "4.2 Interrupt Factor and Interrupt Vector". ● Interrupt control register (ICR) EI2OS activation, EI2OS channel can be set. And EI2OS status at EI2OS end can be confirmed. ● EI2OS descriptor (ISD) This is an 8-byte × 16-channel register that is deployed in the “000100H” to “00017FH” area of built-in RAM and used to specify the transfer mode, address of peripheral function (resource), number of bytes to be transferred and destination address. A channel number is allocated to each of these channels by the interrupt control register (ICR: ICS3 to ICS0). Note: The CPU stops while the EI2OS is in operation. 74 ■ Operation of EI2OS Figure 4.7-1 Operation of EI2OS Memory Space Peripheral function (Resource) by I/OA Resource register Resource register (5) CPU Interrupt request (3) ISD (3) by ICS (2) (1) Interrupt Control Register (ICR) Interrupt controller by BAP (4) Buffer Count by DCT ISD : EI2OS descriptor I/OA : I/O address pointer BAP : Buffer address pointer ICS : EI2OS channel select bit of Interrupt control register (ICR) DCT : Data counter (1) The EI2OS will be activated from the peripheral function (resource). (2) The interruption controller sets the EI2OS descriptor according to the interrupt control register (ICR) setting. (3) The address pointers for the transfer origination or destination are read from the EI2OS descriptor. (4) The data is transferred based on the address pointers for the transfer origination and destination. (5) The interrupt request flag bit of the peripheral function is cleared after the data transferring completed. 75 CHAPTER 4 INTERRUPT 4.7.1 EI2OS descriptor (ISD) EI2OS descriptor (ISD) which is in "000100H" to "00017FH" of built-in RAM is consists of 8-byte x 16 channels. ■ Configuration of EI2OS Descriptor (ISD) ISD comprises 8-byte x 16 channels. Figure 4.7-2 Configuration of EI2OS Descriptor (ISD) MSB Data counter upper 8bit (DCTH) LSB "H" Data counter lower 8bit (DCTL) I/O address pointer upper 8bit (IOAH) I/O address pointer lower 8bit (IOAL) EI2OS Status register(ISCS) Buffer address pointer upper 8bit (BAPH) Buffer address pointer middle 8bit (BAPM) ISD Starting Address (000100H + 8 × ICS) MSB: Highest bit LSB: Lowest bit 76 Buffer address pointer lower 8bit (BAPL) "L" Table 4.7-1 Relation Between Channel Number and Descriptor Address Channel Descriptor address* 0 000100H 1 000108H 2 000110H 3 000118H 4 000120H 5 000128H 6 000130H 7 000138H 8 000140H 9 000148H 10 000150H 11 000158H 12 000160H 13 000168H 14 000170H 15 000178H *:The address of ISD indicates the first address of 8-byte. 77 CHAPTER 4 INTERRUPT Each Register of EI2OS Descriptor (ISD) 4.7.2 Extended intelligent I/O service (EI2OS) descriptor (ISD) is configurated by following 4 types of 8-byte registers. • Data counter (DCT: 2 bytes) • I/O register address pointer (IOA: 2 bytes) • EI2OS status register (ISCS: 1 byte) • Buffer address pointer (BAP: 3 bytes) The register reset values will become indeterminate. ■ Data Counter (DCT) Data counter (DCT) is 16-bit register. Specifies the number of bytes of transfer data. When a data transfer is made, 1 is decremented. When the data counter (DCT) value becomes “0000H”, the EI2OS is completed. Figure 4.7-3 Configuration of Data Counter (DCT) DCTL DCTH bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 Initial value 0 DCT B15 B14 B13 B12 B11 B10 B09 B08 B07 B06 B05 B04 B03 B02 B01 B00 XXXXXXXXXXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/Writable X : Undefined ■ I/O Register Address Pointer (IOA) I/O register address pointer (IOA) is 16-bit register. Specifies the lower-order address (A15 to A0) for the data transfer. The higher-order address (A23 to A16) is set to “00H”. The area from “000000H” to “00FFFFH” can be used when specifying an address. Figure 4.7-4 Configuration of I/O Register Address Pointer (IOA) I/OAH bit 15 14 IOA 13 12 11 I/OAL 10 9 8 7 6 5 4 3 2 1 0 A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/Writable X :Undefined 78 Initial value XXXXXXXXXXXXXXXXB ■ EI2OS Status Register (ISCS) EI2OS status register (ISCS) is 8-bit register. The methods to renew the buffer address pointer and I/O address pointer, the transfer data type (byte/word) and the transfer direction can be specified. Figure 4.7-5 Configuration of EI2OS Status Register (ISCS) bit Initial value 7 6 5 4 3 2 1 0 Reserved Reserved Reserved IF BW BF DIR SE R/W R/W R/W R/W R/W R/W R/W R/W XXXXXXXXB El2OS termination control bit SE 0 Don't terminate by the termination request from a peripheral resource. 1 Terminate by the termination request from a peripheral resource. Data transfer direction specification bit DIR 0 I/O register address pointer → transfer to Buffer address pointer 1 Buffer address pointer → transfer to I/O register address pointer BAP update/fixed selection bit BF 0 Update Buffer address pointer after completion transfer. *1 1 Don't update Buffer address pointer after completion transfer. Transfer data data length specification bit BW 0 Byte 1 Word IF I/OA update/fixed selection bit 0 Update I/O register address pointer after completion transfer. *2 1 Don't update I/O register address pointer after completion transfer. Reserved Reserved bit Always set this bit to "0". R/W : Readable/Writable X : Undefined *1 : Buffer address pointer varies only in the lower 16 bits and can be incremented. *2 : I/O register address pointer allows only incrementing. 79 CHAPTER 4 INTERRUPT ■ Buffer Address Pointer (BAP) Buffer address pointer (BAP) is 24-bit register. EI2OS operation set the memory address of the data transferring source. Buffer address pointer exists in each channel. So, the data can be transferring between the 16M-byte memory address and the peripheral function (resource) address. If the BAP updated/fixed setting bit (BF) is set to "0", the lower 16-bit (BAPM, BAPL) is incremented, and the higher 8-bit (BAPH) is not incremented. • The maximum transfer count that can be set by the data counter (DCT) is 65,536 (64K bytes). • The area that can be set by the I/O address pointer (IOA) is “000000H” to “00FFFFH”. • The area that can be set by the buffer address pointer (BAP) is “000000H” to “FFFFFFH”. Figure 4.7-6 Configuration of Buffer Address Pointer (BAP) bit23 BAP to BAPH (R/W) R/W: Readable/Writable X : Undefined 80 bit16 bit15 to bit8 bit7 to BAPM BAPL (R/W) (R/W) bit0 Initial value XXXXXXH 4.7.3 Operation of EI2OS CPU transfers the data by EI2OS, when the interrupt request is output from the peripheral function (resource) and the interrupt control register has been set to the start of EI2OS. When the EI2OS operation ends, hardware interrupt is done. ■ Flowchart of Operation of EI2OS Figure 4.7-7 Flowchart of Operation of EI2OS Interrupt request generation of Peripheral function ISE=1 NO YES Interrupt processing ISD/ISCS Read With finish request from peripheral functions? YES YES SE=1 NO NO DIR=1 ISD : EI2OS descriptor ISCS : EI2OS status register : IOA update/fixed selection bit IF : Data transfer length specification bit BW : BAP update/fixed selection bit BF DIR : Data transfer direction specification bit : EI2OS termination control bit SE DCT : Data counter : I/O address pointer IOA BAP : Buffer address pointer : EI2OS enable bit (ICR) ISE S1, S0 : EI2OS status (ICR) YES NO Data is set to IOA (data transfer) Memory is set to BAP Data is set to BAP (data transfer) Memory is set to IOA YES IF=0 NO Renewal value depends on BW. IOA Update Renewal value depends on BW. BAP Update YES BF=0 NO DCT decrement DCT=00B (-1) YES EI2OS End processing NO Set S1, S0 to "00B" Set S1, S0 to "01B" Set S1, S0 to "11B" Clear Peripheral function interrupt request Clear ISE to "0" CPU Operation return Interruption processing 81 CHAPTER 4 INTERRUPT Procedure for Use of EI2OS 4.7.4 The setting of extended intelligent I/O service (EI2OS) is set by the system stack area, the extended intelligent I/O service (EI2OS) descriptor, the peripheral function (resource), and the interrupt control register (ICR). ■ Procedure for Use of EI2OS Figure 4.7-8 Procedure for Use of EI2OS Software processing Hardware processing START Initialization Setting System stack area Setting EI2OS descriptor Initializing peripheral function Setting Interrupt control register (ICR) Set the built-in resource to start operation Set the interrupt enable bit (ICR) Setting ILM,I in PS S1,S0 = 00B (Interrupt request) and (ISE=1) Execute User program Data transfer Decide whether to count out NO or to branch to an interrupt by termination request from resource (Branch to interrupt vector) Re-setting of extended intelligent I/O service (Switching channels) Process data in the buffer RETI ISE : Enable bit of interrupt control register (ICR) S1,S0 : EI2OS status of interrupt control register (ICR) 82 YES S1,S0 = 01B or S1,S0 = 11B 4.7.5 Processing Time of the Extended Intelligent I/O Service (EI2OS) The time required for processing the extended intelligent I/O service (EI2OS) depends on setting of the extended intelligent I/O service descriptor (ISD). • • • • • EI2OS status register (ISCS) setting Address (setting) pointed to by the I/O register address pointer (IOA) Address (setting) pointed to by the buffer address pointer (BAP) External data bus width for external access Transfer data length Because the hardware interrupt is activated when data transfer by EI2OS terminates, the interrupt handling time is added. ■ Processing Time (One Transfer Time) of the Extended Intelligent I/O Service (EI2OS) ● When data transfer continues The EI2OS processing time for data transfer continuation is shown in Table 4.7-2 based on the EI2OS status register (ISCS) setting. Table 4.7-2 Extended Intelligent I/O Service Execution Time EI2OS termination control bit (SE) setting Terminates due to termination request from the peripheral IOA update/fixed selection bit (IF) setting BAP address update/fixed selection bit (BF) setting Ignores termination request from the peripheral Fixed Update Fixed Update Fixed 32 34 33 35 Updated 34 36 35 37 Unit: Machine cycle (One machine cycle corresponds to one clock cycle of the machine clock, φ). As shown in Table 4.7-3, interpolation is necessary for the EI2OS processing time when the data transfer is continued depending on the EI2OS execution condition. Table 4.7-3 Data Transfer Interpolation Value for EI2OS Execution Time Internal access External access I/O register address pointer Internal access Buffer address pointer External access B 8 Even Odd B/Even Odd B/Even 8/Odd B/Even 0 +2 +1 +4 Odd +2 +4 +3 +6 B/Even +1 +3 +2 +5 8/Odd +4 +6 +5 +8 : Byte data transfer : External bus width using the 8-bit word transfer : Even-numbered address word transfer : Odd-numbered address word transfer 83 CHAPTER 4 INTERRUPT ● When the data counter (DCT) count terminates (final data transfer) Because the hardware interrupt is activated when data transfer by EI2OS terminates, the interrupt handling time is added. The EI2OS processing time when counting terminates is calculated with the following formula: EI2OS processing time when counting terminates = EI2OS processing time when data is transferred (21 + 6 × Z) machine cycle ↑ Interrupt handling time The interrupt handling time is different for the address stored by the stack pointer. Table 4.7-4 Interpolation Value (Z) for the Interrupt Handling Time Address pointed to by the stack pointer Interpolation value (Z) External interrupt is 8-bit +4 External interrupt is even-numbered address +1 External interrupt is odd-numbered address +4 Internal interrupt is even-numbered address 0 Internal interrupt is odd-numbered address +2 ● For termination by a termination request from the peripheral function (resource) When data transfer by EI2OS is terminated before completion due to a termination request from the peripheral function (resource) (ICR: S1, S0 = 11B), the data transfer is not performed and a hardware interrupt is activated. The EI2OS processing time is calculated with the following formula. Z in the formula indicates the interpolation value for the interrupt handling time (Table 4.7-4). EI2OS processing time for termination before completion = 36 + 6 × Z machine cycle Reference: One machine cycle corresponds to one clock cycle of the machine clock (φ). 84 4.8 Exception Processing Interrupt In the F2MC-16LX, the execution of an undefined instruction results in exception processing. Exception processing is basically the same as an interrupt. When the generation of an exception processing is detected on the instruction boundary, ordinary processing is interrupted and exception processing is executed. Because exception processing occurs as the result of an unexpected operation, it should be used only to activate recovery software required for debugging or an emergency. ■ Exception Processing due to Execution of Undefined Instruction ● Exception processing operation The F2MC-16LX handles all codes that are not defined in the instruction map as undefined instructions. When an undefined instruction is executed, processing equivalent to the INT #10 software interrupt instruction is executed. The following processing is executed before exception processing branches to the interrupt routine: • The A, DPR, ADB, DTB, PCB, PC and PS registers are saved to the system stack. • The I flag of the condition code register (CCR) is cleared to "0", and hardware interrupts are suppressed. • The S flag of the condition code register (CCR) is set to "1", and the system stack is enabled. The program counter (PC) value saved to the stack is an address where the undefined instruction is stored. For 2-byte or longer instruction codes, the code identified as undefined is stored at this address. When the exception factor type must be determined within the exception processing routine, use the saved PC value. ● Return from exception processing When returning by the RETI instruction from exception processing, exception processing is performed again because the PC is pointing to the undefined instruction. Take measures such as resetting software. 85 CHAPTER 4 INTERRUPT 4.9 Stack Operation of Interrupt Processing If an interrupt is accepted, contents of the dedicated registers are automatically saved in the system stack before branching to interrupt processing. Return from the stack is also automatically performed when interrupt processing is completed. ■ Stack Operation when Interrupt Processing Starts With an accepted interrupt, CPU automatically saves the contents of the current dedicated registers in the system stack in the following sequence: 1. Accumulator (A) 2. Direct page register (DPR) 3. Additional data bank register (ADB) 4. Data bank register (DTB) 5. Program bank register (PCB) 6. Program counter (PC) 7. Processor status (PS) Figure 4.9-1 shows the stack operation when interrupt processing starts. Figure 4.9-1 Stack Operation at Start of Interrupt Processing Immediately before interrupt SSB SSP A Address 08FFH 08FEH 00H 08FEH 0000H 08FEH AH AL DPR 01H ADB 00H DTB 00H PCB FFH PC 803FH PS 20E0H 08F2H Immediately after interrupt Memory SSB Address 08FFH 08FEH 00H SP XXH "H" XXH XXH XXH XXH XXH XXH XXH XXH XXH XXH "L" XXH SSP A Memory 08F2H 0000H 08FEH AH AL DPR 01H ADB 00H DTB 00H PCB FFH PC 803FH PS 20E0H Byte 08F2H SP 00H 00H 08H FEH 01H 00H 00H FFH 80H 3FH 20H E0H Byte AH AL DPR ADP DTB PCB PC PS SP after updating ■ Stack Operation during Return from Interrupt Processing At the end of interrupt processing, if the interrupt return instruction (RSTI) is executed, PS, PC, PCB, DTB, ADB, DPR, and A values are returned from the stack in the reverse order of the start of the interrupt processing. The dedicated registers are then restored to their previous state (i.e., immediately before the interrupt started). 86 ■ Stack Area ● Assigning the stack area The stack area is used for storage and return of the program counter (PC) required for executing interrupt processing, subroutine call instruction (CALL) and vector call instruction (CALLV), as well as temporary save and return of registers executed by using the PUSHW and POPW instructions. The stack area is assigned in RAM in addition to the data area. Figure 4.9-2 shows the stack area. Figure 4.9-2 Stack Area Vector table FFFFFFH (Reset/interrupt vector call instructions) FFFC00H ROM area FC0000H*1 003100H*2 Built-in RAM area Stack area 000380H General-purpose register bank area 000180H 000100H 0000D0H 000000H Built-in I/O area *1 Built-in ROM capacity differs depending on the product type. *2 Built-in RAM capacity differs depending on the product type. Notes: • If specifying addresses of the stack pointers (SSP and USP), specify them with even numbers. • Assign the system stack area, user stack area, and data area while avoiding duplication with one another. ● System stack and user stack Interrupt processing uses the system stack area. Even if the user stack area is being used when an interrupt occurs, it is forcibly switched to the system stack. Thus, the system that primarily uses the user stack area must also correctly prepare the system stack area. Use only the system stack unless the stack space must be separated. 87 CHAPTER 4 INTERRUPT 4.10 Sample Program of Interrupt Processing A sample program for interrupt processing is shown below. ■ Sample Program for Interrupt Processing ● Processing specification An example of an interrupt program using external interrupt 0 (INT0) is shown. Sample coding from the program is shown below. [Coding example] DDR1 ENIR EIRR ELVR ICR00 STACK EQU 000011H ;Port 1 direction register EQU 028H ;Interrupt/DTP enable register EQU 029H ;Interrupt/DTP flag EQU 02AH ;Request level set register EQU 0B0H ;Interrupt control register SSEG ;Stack RW 100 STACK_T RW 1 STACK ENDS ;-----------Main program----------------------------------------------------CODE CSEG START: MOV RP,#0 ;General-purpose register use of header bank MOV ILM,#07H ;PS:ILM is set to level 7 MOV A,#!STACK_T ;Setting of system stack MOV SSB,A MOVW A,#STACK_T ;Setting of stack pointer, where MOVW SP,A ;it is set to SSP since S-flag = 1 MOV DDR1,#00000000B ;P10/INT0 pin is set to input OR CCR,#40H ;I-flag in PS:CCR is set for interrupt ena MOV I:ICR00,#00H ;Interrupt set to level 0 (highest) MOV I:ELVR,#00000001B ;INT0 is set to H-level request MOV I:EIRR,#00H ;INT0 interrupt factor cleared MOV I:ENIR,#01H ;INT0 input enable : LOOP: NOP ;Dummy loop NOP NOP NOP BRA LOOP ;Unconditional jump ;-----------Interrupt program-------------------------------------------ED_INT1: MOV I:EIRR,#00H ;Prohibition of acceptance of new ;INT0 NOP NOP NOP NOP NOP NOP RETI ;Return from interrupt CODE ENDS ;-----------Vector setting--------------------------------------------------VECT CSEG ABS=OFFH ORG OFFDOH ;Vector is set to interrupt #11(0BH) DSL ED_INT1 ORG OFFDCH ;Reset vector setting DSL START DB 00H ;Set to single chip mode VECT ENDS END START 88 4.11 Delay Interrupt Generation Module The delay interrupt generation module is a module that generates an interrupt for task switching. Using this module allows generation and clearing of an interrupt request to the F2MC-16LX CPU by software. ■ Block Diagram of Delay Interrupt Generation Module Figure 4.11-1 is a block diagram of the delay interrupt generation module. Figure 4.11-1 Block Diagram of Delay Interrupt Event Module F2MC-16LX bus Delay interrupt request generate/clear decoder Factor latch ■ List of Registers in Delay Interrupt Generation Module The delay interrupt generation module, delay interrupt factor originate/clear register (DIRR: delayed interrupt request register), has the register configuration shown below. Figure 4.11-2 Register Configuration of Delay Interrupt Generation Module bit 15 14 00009FH 13 12 11 10 9 8 Initial value R0 -------0B R/W R/W: Readable/Writable The delay interrupt factor originate/clear register (DIRR) is a register used to generate/clear the delay interrupt factor. Writing "1" to the register results in a request to delay an interrupt, and writing "0" clears the delay interrupt request. Resetting causes the factor clear state. Either "0" or "1" can be written to the reserve bit area. For future expansion, however, Fujitsu recommends using the set bit or clear bit instructions to access this register. 89 CHAPTER 4 INTERRUPT 4.11.1 Operation of Delay Interrupt Generation Module If CPU writes "1" to the relevant DIRR bit with software, the request latch in the delay interrupt generation module is set to generate an interrupt request to the interrupt controller. ■ Operation of Delay Interrupt Generation Module If CPU writes "1" to the relevant DIRR bit with software, the request latch in the delay interrupt generation module is set to generate an interrupt request to the interrupt controller. If other interrupt requests have a priority lower than this interrupt or there are no other interrupt requests, the interrupt controller generates an interrupt to the F2MC-16LX CPU. The F2MC-16LX CPU compares the interrupt request with the ILM bit in the internal CCR register, and if the request level is higher than that of the ILM bit, the hardware interrupt processing micro-program starts immediately after the instruction currently being executed is completed. As a result, the interrupt routine for this interrupt is executed. By writing "0" to the relevant DDIR bit within the interrupt processing routine, this interrupt factor is cleared and the task is switched. The above operation flow is illustrated in the Figure 4.11-3. Figure 4.11-3 Operation of Delay Interrupt Generation Module Delay interrupt originate module Interrupt controller F2MC-16LX CPU Other request ICRYY DIRR IL CMP ICRXX CMP ILM INTA ■ Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch) This latch is set by writing "1" to the relevant DIRR bit, and cleared by writing "0" to the same bit. Be sure to create software so that a factor is cleared in the interrupt processing routine. Otherwise, interrupt processing starts soon after the system returns from interrupt factor processing. 90 CHAPTER 5 RESET This chapter explains reset for the MB90980 series. 5.1 Overview of Reset 5.2 Reset Factors and Oscillation Stabilization Wait Time 5.3 External-Reset Pin 5.4 Resetting 5.5 Reset-Factor Bits 5.6 Condition of Pins as Result of Reset 91 CHAPTER 5 RESET 5.1 Overview of Reset If a reset factor occurs, the CPU immediately stops the processing currently in progress and stands by for cancellation of the reset. After the reset is canceled, processing starts at the address specified by the reset vector. A reset is triggered by the following four factors: • Power-on reset • Watchdog timer overflow • External reset request from RST pin • Software reset request ■ Reset Factors Table 5.1-1 summarizes the reset factors. Table 5.1-1 Reset Factors Reset Reset factor Machine clock Watchdog timer Waits until oscillation is stabilized? Power on When power is turned on Main clock (MCLK) Stopped Yes Watchdog timer Watchdog timer overflow Main clock (MCLK) Stopped No External pin "L"-level input to pin RST Main clock (MCLK) Stopped No Software "0" is written in internal reset signal bit (RST) of low-power consumption mode control register (LPMCR) Main clock (MCLK) Stopped No Main clock: clock of oscillation clock divided by two ● Power-on reset A power-on reset occurs when the power is turned on. The oscillation stabilization wait time is fixed at 217/ HCLK (about 32.77 ms where the oscillation clock is 4 MHz). A reset is performed after the end of the oscillation stabilization wait time. ● Watchdog reset A watchdog reset is triggered by a watchdog timer overflow if "0" is not written in the watchdog control bit (WTE) of the watchdog timer control register (WDTC) within a preset time after the watchdog timer is activated. The oscillation stabilization wait time can be specified in the clock selection register (CKSCR). 92 ● External reset An external reset is triggered by input of the "L" level to the external-reset pin (pin RST). More than 16 machine cycles (16/φ) is required for the "L"-level input time to pin RST. An external reset (pin RST input reset) does not require the oscillation stabilization wait time. After an instruction processing ends, the reset cancellation waiting state is set only when a reset request is issued via pin RST because of the event where a reset factor is triggered during writing (such as the MOV instruction while a transfer instruction is being executed). Writing thus ends normally even if a reset is input during writing. However, string instructions (such as the MOVS instruction) accept a reset before a transfer completes at the specified count, so the transfer of all data cannot be assured. Reset requests are also accepted when a bus cycle extension with pin RDY continues for more than 16 machine cycles during external bus access. ● Software reset In a software reset, an internal reset is triggered by writing "0" in the internal reset signal bit (RST) of the low-power consumption mode control register (LPMCR). A software reset does not require the oscillation stabilization wait time. Definition of clock HCLK: Oscillation clock (clock supplied via high-speed oscillation pin) MCLK: Main clock (clock of HCLK divided by two) SCLK: Sub clock (clock divided by four, supplied via low-speed oscillation pin) φ: Machine clock (CPU operation clock) 1/φ: Machine cycle (CPU operation clock period) Refer to Section "6.1 Overview of Clocks", for a detailed information on machine clocks. Note: The oscillation stabilization wait time of 217/HCLK (about 32.77 ms where the oscillation clock is 4 MHz) is required if a reset is triggered in the stop mode or the sub clock mode. Refer to Section "6.4 Clock Modes", for a detailed information on clock modes. 93 CHAPTER 5 RESET 5.2 Reset Factors and Oscillation Stabilization Wait Time The four types of reset factors can occur in the MB90980 series devices. The oscillation stabilization wait time during a reset varies depending on the reset factor. ■ Reset Factors and Oscillation Stabilization Wait Time Table 5.2-1 summarizes the reset factors and the oscillation stabilization wait time. Table 5.2-1 Reset Factors and Oscillation Stabilization Wait Time Oscillation stabilization wait time The value in parentheses ( ) is a period when oscillation clock is 4 MHz Reset factors Power-on reset 217/HCLK (about 32.77 ms) Watchdog timer None: Bits WS1 and WS0 are initialized to "11B". External reset via pin RST None: Bits WS1 and WS0 are initialized to "11B". Software reset None: Bits WS1 and WS0 are initialized to "11B". HCLK: Oscillation clock WS1, WS0: Bits for selecting oscillation stabilization wait time of clock selection register (CKSCR) Figure 5.2-1 shows the oscillation stabilization wait time for evaluation devices, FLASH devices, and mask devices during a power-on reset. Figure 5.2-1 Waiting Times to Stable Oscillation for Evaluation Devices/Flash Memory Devices and Mask ROM Devices during Power-on Reset Evaluation device Vcc 217/HCLK 217/HCLK CLK CPU operation Stabilization wait time of regulator oscillation stabilization wait time Mask device/FLASH device Vcc 217/HCLK CLK CPU operation oscillation stabilization wait time HCLK: Oscillation clock 94 Note: Ceramic and crystal oscillators generally require an oscillation stabilization wait time ranging from several milliseconds to several ten milliseconds after the start of oscillation until oscillation stabilizes at a specific frequency. Therefore, specify a oscillation stabilization wait time suitable for the oscillator used. Refer to Section "6.5 Oscillation Stabilization Wait Time", for more information. ■ Reset State Waiting for Stable Oscillation A reset during the power-on sequence and a reset in response to a reset request in the stop and sub clock modes is performed after the end of the oscillation stabilization wait time created by the time-base timer. In this event, a reset is performed after an external reset is canceled unless external reset input is cleared. 95 CHAPTER 5 RESET 5.3 External-Reset Pin The external-reset pin (pin RST) is a pin dedicated for the input of resets, and it triggers an internal reset by input of the "L" level. The MB90980 series devices have resets synchronized to the CPU operation clock. However, only external pins (e.g., I/O ports) change asynchronously to a reset state. ■ Block Diagram of External-reset Pin Figure 5.3-1 shows the block diagram of internal reset. Figure 5.3-1 Block Diagram of Internal Reset CPU operation clock (PLL multiplier circuit, clock of HCLK divided by two) RST CPU P-ch Synchronization circuit Pin N-ch Input buffer Peripheral function I/O ports, etc. HCLK: Oscillation clock Note: To prevent damage to the memory contents by a reset during writing, input to pin RST is accepted in a cycle that precludes damage to memory contents. A clock is required to initialize internal circuits. Input of a clock is required during input of a reset when an external clock is used for operation. 96 5.4 Resetting After the cancellation of a reset, a read from operation of mode data and the reset vector can be selected by setting the mode pin to perform mode fetching. Mode fetching determines the CPU operation mode and the start address of execution after the end of a reset. When the power is turned on or when the system is returned from the stopmode by a reset, perform mode fetching after the end of the oscillation stabilization wait time. ■ Overview of Resetting Figure 5.4-1 shows the flow of resetting. Figure 5.4-1 Flow of Resetting Power-on reset Stop mode Sub clock mode Reset in progress Mode fetching (reset) External reset Software reset Watchdog timer reset Reset state to wait for stable oscillation Fetch of mode data Pin state and function changes related to external bus mode Fetch of reset vector Normal operation (run state) Fetch of instruction code from addresses indicated by a reset vector, and execution of instruction ■ Mode Pins Mode pins (MD2 to MD0) specify a method to fetch reset vectors and mode data. A reset vector and mode data are fetched in a sequence for resetting. Refer to Section "8.2 Mode Pins (MD2 to MD0)", for details of the mode pins. 97 CHAPTER 5 RESET ■ Mode Fetch After a reset is canceled, the CPU transfers the reset vectors and mode data to the applicable registers in the CPU core. The reset vectors and mode data are allocated to four bytes, namely "FFFFDCH" to "FFFFDFH". Upon a reset cancellation, the CPU immediately outputs these addresses to a bus and fetches reset vectors and mode data. During mode fetching, the CPU starts processing from the address specified by the reset vector. Figure 5.4-2 shows transfer of reset vectors and mode data. Figure 5.4-2 Transfer of Reset Vectors and Mode Data F2MC-16LX CPU Core Memory space FFFFDFH Mode data FFFFDEH Reset vector bits 23 to 16 FFFFDDH Reset vector bits 15 to 8 FFFFDCH Reset vector bits 7 to 0 Mode register Micro ROM Sequence for resetting PCB PC Note: Use a mode pin, from which reset vectors and mode data are read, to specify either internal ROM or external memory. If the external vector mode is specified with a mode pin, however, external memory and not internal ROM is accessed to read reset vectors and mode data. Fujitsu recommends specifying the internal vector mode with a mode pin when the single-chip mode and internal ROM external bus mode are used. ● Mode data (Address: FFFFDFH) The data in the mode register can be modified only by a reset, and the mode register settings become effective after a reset. Refer to Section "8.3 Mode Data", for details on mode data. ● Reset vector (Address: FFFFDCH to FFFFDEH) Write the execution start address after the end of a reset. Execution starts from this address. 98 5.5 Reset-Factor Bits Reset factors can be determined by reading the watchdog timer control register (WDTC). ■ Reset-Factor Bits As shown in the Figure 5.5-1, each reset factor has a corresponding flip-flop assigned to it. This information can be obtained by reading the watchdog timer control register (WDTC). If a reset factor must be determined after a reset cancellation, run software to process the read value of the WDTC register, and branch to an appropriate program. Figure 5.5-1 Block Diagram of Reset-Factor Bits Pin RST Power-on detection circuit External reset request detection circuit Watchdog timer control register (WDTC) S F/F Q R No periodic clearing RST="L" Power on S S R F/F Watchdog timer reset detection circuit R LPMCR and RST bit writing detection circuit S F/F Q Q RST bit set F/F R Delay circuit Q Reading of watchdog timer control register (WDTC) F2MC-16LX Internal bus S: Set; R: Reset; Q: Output; F/F: Flip-flop 99 CHAPTER 5 RESET ■ Correspondence Between Reset-Factor Bits and Reset Factors Figure 5.5-2 shows the configuration of the reset-factor bits for the watchdog timer control register (WDTC). Table 5.5-1 shows the correspondence between reset-factor bits and reset factors. For details, refer to Section "11.2 Watchdog Timer Control Register (WDTC)". Figure 5.5-2 Configuration of Reset-Factor Bits (Watchdog Timer Control Register) bit 0000A8H 15 to 8 (TBTC) 7 6 5 4 PONR Reserved WRST ERST X R X R X R 3 SRST 2 WTE 1 WT1 0 WT0 X R 1 W 1 W 1 W X R Initial value R/W R: Read only; W: Write only Table 5.5-1 Correspondence Between Reset-Factor Bits and Reset Factors Reset factor PONR WRST ERST SRST Power-on reset 1 X X X Watchdog timer overflow * 1 * * External reset request via pin RST * * 1 * Software reset request * * * 1 Note: An asterisk (*) indicates an undefined bit. ■ Cautions about Reset-Factor Bits ● If more than one reset factor occurs If more than one reset factor occurs, the individual reset-factor bits of the WDTC register are set to "1". For example, if an external reset via pin RST is requested at the same time as a watchdog timer overflow occurs, bits ERST and WRST of the reset-factor bits are set to "1". ● Power-on reset During a power-on reset, bit PONR of the reset-factor bits is set to "1". However, the reset-factor bits other than bit PONR are undefined. Therefore, if bit PONR is "1", create software so that reset-factor bits other than bit PONR are ignored. ● Clearing reset-factor bits The reset-factor bits is cleared only if the data in the WDTC register is read. Bits corresponding to reset factors that have occurred once are not cleared even if a reset is triggered (remains "1"). Note: The values of the WDTC register may not be assured if the power is turned on under a condition that precludes a power-on reset. 100 5.6 Condition of Pins as Result of Reset This section explains the states of pins after a reset. ■ Pin States during a Reset States of the pins during a reset are determined by the settings of mode pins (MD2 to MD0). ● If the internal vector mode is set (MD2 to MD0 = 011B) All I/O pins (resource pins) become set at the high-impedance state, and mode data is read from internal ROM. Refer to Section "7.7 Pin State in Standby Mode, Hold, and Reset", for the states of pins during a reset. ■ Pin States after Mode Data is Read The states of the pins after mode data is read are determined by mode data (M1, M0). ● If the single-chip mode is set (M1, M0 = 00B) All I/O pins (resource pins) become set at the high-impedance state, and mode data is read from the internal ROM. Note: Take care with the pins that have the high-impedance state during a reset so that equipment connected to the pins do not malfunction. 101 CHAPTER 5 RESET 102 CHAPTER 6 CLOCKS This chapter describes the clocks of the MB90980 series. 6.1 Overview of Clocks 6.2 Block Diagram of Clock Generator 6.3 Clock Selection Register (CKSCR) and PLL Output Selection Register (PLLOS) 6.4 Clock Modes 6.5 Oscillation Stabilization Wait Time 6.6 Connecting Oscillator to External Clock 103 CHAPTER 6 CLOCKS 6.1 Overview of Clocks The clock generator controls the operations of internal clocks, which are the operation clocks of the CPU and peripheral functions. In this document, the clocks are called as follows according to clock type: • Machine clock:Defined as an internal clock. • Machine cycle:Defined as one period of a machine clock. • Oscillation clock:Defined as a clock supplied via a high-speed oscillation pin. • PLL clock:Defined as a clock using internal PLL oscillation. • Sub clock:Clock divided by four, provided from a low-speed oscillation pin. ■ Overview of Clocks The clock generator contains an oscillation circuit and generates an oscillation clock and sub clock by using an external connection to an oscillator. The generator generates an oscillation clock by inputting a clock generated externally. The generator contains a PLL clock multiplier circuit and generates four multiplication clocks of an oscillation clock. The clock generator controls the oscillation stabilization wait time, PLL clock multiplication, and operations of internal clocks by changing the clock of the clock selector. ● Oscillation clock (HCLK) This clock is generated by connecting an oscillator to the high-speed oscillation pin or by inputting an external clock. ● Sub clock (SCLK) This clock operates the watch timer. It can also be used as a low-speed machine clock. This clock is divided by four and created by connecting an oscillator to the low-speed oscillation pin or by inputting an external clock. ● Main clock (MCLK) This is a clock of the oscillation clock divided by two, and is used as an input clock to the time-base timer and clock selector. ● PLL clock (PCLK) This clock is a clock obtained by multiplying with built-in PLL clock multiplier circuit (PLL oscillation circuit). Four types of the clocks can be selected. ● Machine clock (φ) This clock is an operation clock of the CPU and peripheral functions. One period of this clock is used as a machine cycle (1/φ). One clock can be selected from among the main clock (clock of oscillation clock divided by two), sub clock, and four types of multiplication clocks. 104 Notes: • Oscillation clocks have an oscillation frequency ranging from 4.5 to 25 MHz. To use PLL to generate machine clock in the range from 20 to 25Mz, set the PLL2 bit of the PLLOS register to "1". The maximum operating frequency of the CPU and peripheral functions is 25 MHz. If a multiply-by rate exceeding the maximum operating frequency is specified, the device will not operate correctly. • PLL oscillation can be between 4.5 and 25 MHz. This oscillation range varies depending on operating voltage and the multiplication rate. ■ Clock Supply Map Machine clocks generated by the clock generator are supplied as operation clocks of the CPU and peripheral functions. Therefore, operations of the CPU and peripheral functions are affected by changes between the main clock and PLL clock (clock mode) and by changes in the PLL clock multiplication rate. The clock-divided outputs of the time-base timer are supplied to some peripheral functions, and the peripheral functions can select their own operation clocks. Figure 6.1-1 shows a clock supply map. Figure 6.1-1 Clock Supply Map Peripheral functions 4 Watchdog timer 4 8/16-bit PPG timer 0 Clock generator 8/16-bit PPG timer 1 Watch timer X0A Pin X1A Pin X1 Pin PPG2, 3 Pin Time-base timer Sub clock generator circuit 1 2 3 4 16-bit reload timer PLL multiplier circuit X0 Pin PPG0, 1 Pin Clock divided by four SCLK PCLK System Clock divided clock Clock selector by two generator MCLK circuit HCLK φ UART0 I/O extensive serial interface 2 channels CPU, μ DMAC 8/16-bit U/D counter 16-bit output compare 16-bit freerunning timer HCLK : MCLK : SCLK : PCLK : φ : 16-bit input capture Oscillation clock Main clock Sub clock PLL clock Machine clock 10-bit A/D converter External interrupt 3 TIN0 Pin TOT0 Pin SCK0, SIN0 Pin SOT0 Pin SCK1, SCK2 SIN1, SIN2 Pin SOT1, SOT2 Pin AIN0, AIN1 BIN0, BIN1 ZIN0, ZIN1 Pin OUT0, OUT1, OUT2, OUT3 Pin FRCK Pin IN0, IN1 Pin AN0 to AN7, ADTG Pin IRQ0 to IRQ7 Pin Control of oscillation stabilization wait 105 CHAPTER 6 CLOCKS 6.2 Block Diagram of Clock Generator The clock generator consists of the following five blocks: • System clock generator circuit/sub clock generator circuit • PLL multiplier circuit • Clock selector • Clock Selection Register (CKSCR) and PLL Output Selection Register (PLLOS) • Selector for oscillation stabilization wait time ■ Block Diagram of Block Generator Figure 6.2-1 is a block diagram of the clock generator. Figure 6.2-1 also includes the standby control circuits and time-base timer circuit. Figure 6.2-1 Block Diagram of Clock Generator Low-power consumption mode control register (LPMCR) STP SLP SPL RST TMD CG1 CG0 Reserved Pin highimpedance control circuit RST Internal reset generator circuit Pin CPU intermittent operation selector Interrupt reset Internal reset Intermittent cycle selection CPU-clock control circuit 2 Pin high-impedance control CPU clock Stop and sleep signal Standby control circuit Stop signal Peripheral Machine clock Peripheral clock clock control Cancel waiting time circuit to stable oscillation Clock generator Clock selector PLL12 PLL output selection register (PLLOS) Clock SCLK divided by four 2 Selector for waiting time to stable oscillation 2 Sub clock generator circuit PLL multiplier circuit System clock generator circuit X0A Pin X1A Pin X0 Pin X1 Pin 106 SCM MCM WS1 WS0 SCS MCS CS1 CS0 Clock selection register (CKSCR) Clock Clock HCLK divided MCLK divided by 1024 by two Clock divided by two Clock divided by four Clock divided by four Clock Clock divided divided by four by two Time-base timer HCLK : Oscillation clock MCLK : Main clock SCLK : Sub clock To watchdog timer ● System clock generator circuit This circuit generates an oscillation clock (HCLK) by using an oscillator connected to the high-speed oscillation pin. Also, an external clock can be input to it. ● Sub clock generator circuit This circuit generates a sub clock (SCLK) by using an oscillator connected to the low-speed oscillation pin. Also, an external clock can be input to it. ● PLL multiplier circuit This circuit multiplies an oscillation clock by using PLL oscillation and supplies it to the CPU clock selector. ● Clock selector This circuit selects clocks from among the main clock, sub clock, and four PLL clocks supplied to the CPU clock control circuit and peripheral clock control circuit. ● Clock selection register (CKSCR) This register changes between the oscillation clock and PLL clocks, selects the oscillation stabilization wait time, and selects the multiplication rate of the PLL clocks. ● PLL output selection register (PLLOS) Use this register to specify doubling of the multiply-by rate specified in the CKSCR register for the PLL to be used when a machine clock is used at a frequency of 20 to 25 MHz. ● Selector for the oscillation stabilization wait time This circuit selects the oscillation stabilization wait time of the oscillation clock when the stop mode is reset and during watchdog reset. Four types of the time-base timer output are selected. 107 CHAPTER 6 CLOCKS 6.3 Clock Selection Register (CKSCR) and PLL Output Selection Register (PLLOS) The clock selection register (CKSCR) switches among the main clock, sub clock, and PLL clock, and it selects the oscillation stabilization wait time and PLL clock multiplication rate. The PLL output selection register (PLLOS) must be set for the PLL to be used when a machine clock is used at a frequency of 20 to 25 MHz. ■ Configuration of Clock Selection Register (CKSCR) Figure 6.3-1 shows the configuration of the clock selection register (CKSCR). Table 6.3-1 has explanations for the functions of bits in the clock selection register. Figure 6.3-1 Configuration of Clock Selection Register (CKSCR) Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 bit7 0000A1H SCM MCM WS1 WS0 SCS MCS CS1 CS0 R R R/W R/W R/W R/W bit0 Initial value (LPMCR) 11111100B R/W R/W Multiplication rate selection bit CS1 CS0 Values in ( ) are for 4 MHz oscillation clock 0 0 1 × HCLK ( 4 MHz) 0 1 1 0 2 × HCLK ( 8 MHz) 3 × HCLK (12 MHz) 1 1 4 × HCLK (16 MHz) Note: To ensure the internal circuit operation with a frequency at 20 to 25 MHz, set the PLL2 bit of the PLLOS register to 1 to double the above multiply-by rate. However, do not set the PLL2 bit to 1 when CS1 = 1 and CS0 = 1. PLL clock selection bit MCS 0 1 PLL clock selection Main clock selection Sub clock selection bit SCS 0 Sub clock selection 1 Main clock selection Oscillation stabilization wait time selection bits WS1 WS0 Values in ( ) are for 4 MHz oscillation clock 0 0 0 1 1 0 210/HCLK (about 256 μs) 213/HCLK (about 2.05 ms) 215/HCLK (about 8.19 ms) 1 1 217/HCLK (about 32.77 ms) * During a power-on reset, evaluation devices and FLASH devices become 218/HCLK (about 65.54 ms), and mask devices become 217/HCLK (about 32.77 ms). PLL clock display bit MCM 0 In use by PLL clock 1 In use by main clock or sub clock HCLK : Oscillation clock R/W : Readable/Writable R : Read only : Initial value 108 Sub clock display bit SCM 0 In use by sub clock 1 In use by main clock or PLL clock Note: When reset, the machine clock selection (MCS) bit is initialized to the main clock selection. Table 6.3-1 Functions of Bits in Clock Selection Register (CKSCR) (1 / 2) Bit name bit15 bit14 bit13, bit12 Function SCM: Sub clock display bit This bit displays whether the main clock or sub clock is selected as a machine clock. • If the bit is "0", the sub clock is selected. If "1", the main clock or PLL clock is selected. • If SCS = 1 and SCM = 0, the mode is the waiting time for stable oscillation of the main clock. • Write doesn't affect operation. MCM: PLL clock display bit This bit displays whether the main clock or PLL clock is selected as a machine clock. • If this bit is "0", the PLL clock is selected. If "1", the main clock or sub clock is selected. • If PLL clock selection bit (MCS) = 0 and MCM = 1, the mode is the waiting time for stable oscillation of the PLL clock. • Write doesn't affect operation. WS1, WS0: Oscillation stabilization wait time selection bits Selects the waiting time for stable oscillation of oscillation clock in a change from the sub clock mode to the main clock mode or from the sub clock mode to the PLL clock mode if the stop mode is canceled. Initialized to "11B" by all reset factors. Note: The specified value of the waiting time for stable oscillation must be suitable for the oscillator used. Refer to Section "5.2 Reset Factors and Oscillation Stabilization Wait Time", for more information. Specify "00B" only if the mode is the main clock mode. When the main clock is switched to PLL clock mode, the PLL clock oscillation stabilization wait time is fixed at 214/HCLK. When sub clock mode is switched to PLL clock mode or when PLL stop mode is returned to PLL clock mode, the oscillation stabilization wait time uses the specified values in the WS1 and WS0 bits. For PLL clock oscillation stabilization wait time, at least 214 /HCLK is required. Accordingly, when sub clock mode is switched to PLL clock mode, or when PLL clock mode is switched to PLL stop mode, set WS1 and WS0 bits to "10B" or "11B". 109 CHAPTER 6 CLOCKS Table 6.3-1 Functions of Bits in Clock Selection Register (CKSCR) (2 / 2) Bit name bit11 bit10 bit9, bit8 SCS: Sub clock selection bit This bit specifies selection of the main clock or sub clock as a machine clock. • If this bit is "0", the sub clock is selected. If "1", the main clock is selected. • When this bit is rewritten from "1" to "0", the mode is switched to the sub clock mode synchronizing the sub clock (approx. 130 μs.). • Writing "1" when this bit is "0" generates a standby period for stable oscillation of the main clock. The time-base timer is automatically cleared. • Initialized to "1" by all reset factors. Note: Use the sub clock as an operation clock when the sub clock is selected. (The machine clock changes to a frequency of 8 kHz during low-speed oscillation at 32 kHz) If both SCS and MCS are "0", SCS is assigned with priority, and the sub clock is selected. MCS: PLL clock selection bit This bit specifies selection of the main clock or PLL clock as a machine clock. • If this bit is "0", the PLL clock is selected. If "1", the main clock is selected. • Writing "0" when this bit is "1" generates a waiting time for stable oscillation of the PLL clock. The time-base timer is automatically cleared. The interrupt request flag bit (TBOF) of the time-base timer control register (TBTC) is also cleared. • When the main clock is switched to PLL clock mode, the oscillation stabilization wait time is fixed at 214/HCLK. (The oscillation stabilization wait time is about 4.1 ms if the oscillation clock has a frequency of 4 MHz.) When sub clock mode is switched to PLL clock, the oscillation stabilization wait time uses the specified values in the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0). • When the main clock is selected, the operation clock is the oscillation clock divided by 2. (The operation clock is 2 MHz if the oscillation clock is 4 MHz.) • Initialized to "1" by all reset factors. Note: Writing "0" when the MCS bit is "1", write while the time-base timer interrupt is masked by using the interrupt request enable bit (TBIE) of the TBTC register or the interrupt level register (ILM). CS1, CS0: Multiplication rate selection bit This bit selects the multiplication rate of the PLL clocks. Selection is from four multiplication rates. All reset factors initialize it to "00B". Note: Writing is disabled if the MCS bit or MCM bit is "0". Rewrite the CS1 and CS0 bits after setting the MCS bit to "1" (main clock mode). HCLK: Oscillation clock 110 Function ■ Configuration of PLL Output Selection Register (PLLOS) Figure 6.3-2 shows the configuration of the PLL output selection register (PLLOS). Table 6.3-2 explains the functions of the bits for the PLL output selection register. Figure 6.3-2 Configuration of PLL Output Selection Register (PLLOS) bit15 bit14 bit13 bit12 bit11 bit10 bit9 Address 0000CFH Initial value DIV2 PLL2 W PLL2 0 W bit8 Write only Undefined Initial value 1 DIV2 ------00B W PLL output frequency doubling selection bit Use the multiply-by rate set in the CS1 and CS0 bits of the CKSCR register unchanged. Double the multiply-by rate set in the CS1 and CS0 bits of the CKSCR register. PLL input divided selection bit 0 Input the input frequency to PLL. 1 Two dividing the input frequency and it inputs it to PLL. 111 CHAPTER 6 CLOCKS Table 6.3-2 Functions of Bits for PLL Output Selection Register (PLLOS) Bit name bit15 to bit10 Undefined bits Function Not used • • • • • bit9 DIV2: PLL input divided selection bit • • bit8 112 PLL2: PLL output frequency doubling selection bit This bit selects dividing of input clock to PLL or input as it is. It is initialized to "0" by all reset sources. Read value is always "1". Please do not change this bit when you use the clock of PLL. Please set DIV2 bit of PLLOS register = 1 and PLL2 bit = 1 during PLL1, PLL2, PLL3, PLL4 multiplication setting and internal clock with 20 MHz < fCP ≤ 25MHz. (During PLL 4 multiplication setting, please set input frequency is 60MHz or more.) Example: If sending frequency = 24 MHz and PLL1 multiplication setting: CKSCR register: CS1 bit = 0, CS0 bit = 0 PLLOS register: DIV2 bit = 1, PLL2 bit = 1 Example: If sending frequency = 8 MHz and PLL3 multiplication setting: CKSCR register: CS1 bit = 1, CS0 bit = 0 PLLOS register: DIV2 bit = 1, PLL2 bit = 1 It is possible to set the following during PLL 2, 4 multiplication setting and internal clock with 20 MHz < fCP ≤ 25MHz; PLL 2 multiplication: CKSCR register: CS1 bit = 0, CS0 bit = 0 PLLOS register: DIV2 bit = 0, PLL2 bit = 1 PLL 4 multiplication: CKSCR register: CS1 bit = 0, CS0 bit = 1 PLLOS register: DIV2 bit = 0, PLL2 bit = 1 Please set DIV2 bit of PLLOS register = 0 and PLL2 bit = 1 during PLL6, 8 multiplication setting. Example: If sending frequency = 4 MHz and PLL6 multiplication setting: CKSCR register: CS1 bit = 1, CS0 bit = 0 PLLOS register: DIV2 bit = 0, PLL2 bit = 1 Example: If sending frequency = 3 MHz and PLL8 multiplication setting: CKSCR register: CS1 bit = 1, CS0 bit = 1 PLLOS register: DIV2 bit = 0, PLL2 bit = 1 This bit specifies doubling of the multiply-by rate for the PLL to be used when a machine clock is used at a frequency of 20 to 25 MHz. • Initialized to "0" by all reset sources. • The readout value is always "1". • Do not change this bit when a PLL clock is being used. 6.4 Clock Modes The clock modes are the main clock, PLL clock, and sub clock modes. ■ Main Clock Mode, PLL Clock Mode, and Sub Clock Mode ● Main clock mode The main clock mode uses a clock obtained by dividing the oscillation clock by two as the operation clock of the CPU and peripheral resources. This mode stops the PLL clock. ● PLL clock mode The PLL clock mode uses the PLL clock obtained as the operation clock of the CPU and peripheral functions. The multiplication rate of the PLL clock can be selected with the clock selection register (CKSCR). ● Sub clock mode The sub clock mode uses a sub clock as the operation clock of the CPU and peripheral resources. This mode stops the main and PLL clocks. ■ Change of Clock Mode The clock mode changes to the main clock, PLL clock, or sub clock mode according to the writing of the PLL clock selection bit (MCS) and sub clock selection bit (SCS) in the CKSCR register. ● Change from the main clock mode to the PLL clock mode Rewriting the MCS bit in the CKSCR register from "1" to "0" in the main clock mode changes the main clock to the PLL clock after the end of the oscillation stabilization wait time of the PLL clock (214/HCLK). ● Change from the PLL clock mode to the main clock mode Rewriting the MCS bit in the CKSCR register from "0" to "1" in the PLL clock mode changes the PLL clock to the main clock adjusted to the timing where the edges of the PLL clock and main clock match (after 1 to 8 PLL clocks). ● Change from the main clock mode to the sub clock mode Rewriting the SCS bit in the CKSCR register from "1" to "0" in the main clock mode changes the main clock to the sub clock synchronizing the sub clock (approx. 130 μs.). ● Change from the sub clock mode to the main clock mode Rewriting the SCS bit in the CKSCR register from "0" to "1" in the sub clock mode changes the sub clock to the main clock after end of the oscillation stabilization wait time of the main clock. Select the oscillation stabilization wait time by using selection bits (WS1, WS0) for the oscillation stabilization wait time of the CKSCR register. 113 CHAPTER 6 CLOCKS ● Change from the PLL clock mode to the sub clock mode Rewriting the sub clock selection bit (SCS) of the clock selection register (CKSCR) from "1" to "0" in the PLL clock mode changes the PLL clock to the sub clock. ● Change from the sub clock mode to the PLL clock mode Rewriting the SCS bit in the CKSCR register from "0" to "1" in the sub clock mode changes the sub clock to the PLL clock after the end of the oscillation stabilization wait time of the main clock. Select the oscillation stabilization wait time by using selection bits (WS1, WS0) for the oscillation stabilization wait time of the CKSCR register. Notes: • Rewriting the PLL clock selection bit (MCS) or SCS bit in the CKSCR register does not change the machine clock immediately. When operating a resource that depends on a machine clock, make sure that the intended machine clock change has completed by checking the PLL clock display bit (MCM) and sub clock display bit (SCM) in the CKSCR register. Then operate the resource. • If both of the SCS and MCS bits are "0", SCS is assigned with priority, and the sub clock mode is set. • When the clock mode is switched, do not switch to low-power consumption mode and other clock mode before this switching is completed. Confirm the completion of clock mode switching by referring to the MCM and SCM bits of the clock selection register (CKSCR). If the mode is switched to another clock mode or low-power consumption mode before completion of switching, the mode may not be switched. ■ Selection of PLL Clock Multiplication Rate If "00B" to "11B" are written to the CS1 and CS0 bits of the CKSCR register, four types of PLL clock multiply-by rates can be selected: multiply-by 1 to 4. ■ Machine Clock The PLL clock, main clock, and sub clock output by the PLL multiplier circuit are machine clocks, which are supplied to the CPU and peripheral functions. The main clock, PLL clock, and sub clock can be selected by writing in the SCS or MCS bit of the CKSCR register. Figure 6.4-1 is a state transition diagram of machine clock selection. 114 Figure 6.4-1 State Transition Diagram of Machine Clock Selection (8) Main MCS=1 MCM=1 (1) SCS=1 SCM=1 CS1,CS0=xx (10) Main→Sub MCS=1 MCM=1 (9) SCS=0 SCM=1 CS1,CS0=xx (16) (10) Sub→Main (11) (8) MCS=1 MCM=1 SCS=1 (8) (6) SCM=0 Main→PLLx (2) CS1,CS0=xx (12) Sub→PLL MCS=0 (3) (13) MCS=0 MCM=1 (14) MCM=1 (4) SCS=1 (15) SCS=1 (5) SCM=0 SCM=1 CS1,CS0=xx CS1,CS0=xx (7) (7) (7) (7) Sub MCS=1 MCM=1 SCS=0 SCM=0 CS1,CS0=xx PLL1→Main MCS=1 MCM=0 SCS=1 SCM=1 CS1,CS0=00 PLL multiplied by one MCS=0 MCM=0 (6) SCS=1 (8) SCM=1 CS1,CS0=00 PLL1→Sub MCS=1 MCM=0 SCS=0 SCM=1 CS1,CS=00 PLL2→Main MCS=1 MCM=0 SCS=1 SCM=1 CS1,CS0=01 PLL multiplied by two MCS=0 MCM=0 (6) SCS=1 (8) SCM=1 CS1,CS0=01 PLL2→Sub MCS=1 MCM=0 (17) SCS=0 SCM=1 CS1,CS0=01 PLL3→Main MCS=1 MCM=0 SCS=1 SCM=1 CS1,CS0=10 PLL multiplied by three MCS=0 MCM=0 (8) (6) SCS=1 SCM=1 CS1,CS0=10 PLL3→Sub MCS=1 (17) MCM=0 SCS=0 SCM=1 CS1,CS0=10 PLL4→Main MCS=1 MCM=0 SCS=1 SCM=1 CS1,CS0=11 PLL multiplied by four MCS=0 MCM=0 (6) SCS=1 (8) SCM=1 CS1,CS0=11 PLL4→Sub MCS=1 (17) MCM=0 SCS=0 SCM=1 CS1,CS0=11 (17) 115 CHAPTER 6 CLOCKS (1) MCS bit "0" write (2) Waiting for PLL clock oscillation stability is complete. &CS1, CS0 = 00B (3) Waiting for PLL clock oscillation stability is complete. &CS1, CS0 = 01B (4) Waiting for PLL clock oscillation stability is complete. &CS1, CS0 = 10B (5) Waiting for PLL clock oscillation stability is complete. &CS1, CS0 = 11B (6) MCS bit "1" write (includes watchdog reset) (7) Synchronization timing of PLL and main clocks (8) SCS bit "0" write (9) End of waiting time for sub clock oscillation stability (maximum 214/SCLK) (10) SCS bit "1" write (11) Waiting for main clock oscillation stability is complete. (12) Waiting for main clock oscillation stability is complete. &CS1, CS0 = 00B (13) Waiting for main clock oscillation stability is complete. &CS1, CS0 = 01B (14) Waiting for main clock oscillation stability is complete. &CS1, CS0 = 10B (15) Waiting for main clock oscillation stability is complete. &CS1, CS0 = 11B (16) SCS bit "1" write, MCS bit "0" write (17) Synchronization timing of PLL and sub clocks MCS: PLL clock selection bit of clock selection register (CKSCR) MCM: PLL clock display bit of clock selection register (CKSCR) SCS: Sub clock selection bit of clock selection register (CKSCR) SCM: Sub clock display bit of clock selection register (CKSCR) CS1, CS0: Multiplication rate selection bit of clock selection register (CKSCR) Note: The initial value of the machine clocks is the main clock (MCS = 1, SCS = 1). If both of the SCS and MCS bits are "0", SCS is assigned with priority and the sub clock is set. When sub clock mode is switched to PLL clock mode, set "10B" or "11B" in the oscillation stabilization wait time selection bits (WS1, WS0) of the CKSCR register. 116 6.5 Oscillation Stabilization Wait Time When the power is turned on, when stop mode is released, or switching from the sub clock to the main clock or from sub clock to the PLL clock occurs, an oscillation stabilization wait time is required after oscillation begins because the oscillation clock is stopped. When switching from the main clock to the PLL clock or from the main clock to the sub clock occurs, an oscillation stabilization wait time is required. ■ Oscillation Stabilization Wait Time Ceramic and crystal oscillators generally require a waiting time ranging from several milliseconds to several ten milliseconds after the start of oscillation until oscillation stabilizes to a natural frequency (oscillation frequency). Therefore, disable CPU operation immediately after the start of oscillation, and supply a clock to the CPU when oscillation completely stabilizes following the elapse of the oscillation stabilization wait time. Specify a oscillation stabilization wait time suitable for the oscillator used because the time required for oscillation to stabilize varies depending on the type of oscillator (crystal, ceramic, or other material). The oscillation stabilization wait time can be selected by defining the clock selection register (CKSCR). When the clock mode is switched from the main clock to the PLL clock, the main clock to the sub clock, the sub clock to the main clock, or the sub clock to the PLL clock, the CPU runs in the clock mode set before switching. After the oscillation stabilization wait time, the CPU changes to the selected clock mode. Figure 6.5-1 illustrates operation immediately after the start of oscillation. Figure 6.5-1 Operation Immediately after Start of Oscillation Oscillator oscillation time oscillation stabilization wait time Switching to operation start or changing to PLL clock/sub clock X1 Start of Oscillation Stable Oscillation 117 CHAPTER 6 CLOCKS 6.6 Connecting Oscillator to External Clock Devices in the MB90980 series contain a system clock generator circuit and generate clocks using an externally connected oscillator. Also, an external clock can be input to it. ■ Connection of Oscillator and External Clock ● Example of Connecting Crystal or Ceramic oscillator Connect a crystal oscillator or a ceramic oscillator as shown in the example in Figure 6.6-1. Figure 6.6-1 Example of Connecting Crystal or Ceramic Oscillator MB90980 series X0(X0A) X1(X1A) ● Example of connecting external clock Connect an external clock to pin X0 and set up pin X1 to be open as shown in the example in the Figure 6.6-2. Figure 6.6-2 Example of Connecting External Clock MB90980 series X0(X0A) X1(X1A) Open 118 CHAPTER 7 LOW-POWER CONSUMPTION MODE This chapter explains the low-power consumption mode of the MB90980 series. 7.1 Overview of Low-Power Consumption Mode 7.2 Block Diagram of Low-Power Consumption Control Circuit 7.3 Low-Power Consumption Mode Control Register (LPMCR) 7.4 CPU Intermittent Operation Mode 7.5 Standby Mode 7.6 State Transition Diagram 7.7 Pin State in Standby Mode, Hold, and Reset 7.8 Caution on Using Low-Power Consumption Mode 119 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.1 Overview of Low-Power Consumption Mode The following CPU operation modes are available on the MB90980 series devices by selecting a suitable operation clock and by controlling clock operation. • Clock modes (Main clock mode, and sub clock mode) • CPU intermittent operation modes (PLL clock intermittent operation mode, main clock intermittent operation mode, and sub clock intermittent operation mode) • Standby modes (sleep mode, time-base timer mode, stop mode, and watch mode) ■ CPU Operation Mode and Current Consumption Figure 7.1-1 illustrates the relationship between CPU operation mode and current consumption. Figure 7.1-1 CPU Operation Mode and Current Consumption Current consumption CPU operation mode Several ten mA PLL clock mode Clock multiplied by four Clock multiplied by three Clock multiplied by two Clock multiplied by one Clock multiplied by four PLL clock intermittent operation mode Clock multiplied by three Clock multiplied by two Clock multiplied by one Main clock mode (1/2 clock mode) Main clock intermittent operation mode Several mA Sub clock mode Sub clock intermittent operation mode Several μA Standby mode Sleep mode Time-base timer mode Watch mode Stop mode Low-power consumption mode Note: This diagram is just an example of each mode, so its values may differ from actual current consumption. 120 ■ Clock Modes ● Main clock mode This mode operates the CPU and peripheral functions by using the clock of the oscillation clock (HCLK) divided by two. The PLL multiplier circuit stops its operation in the main clock mode. ● Sub clock mode This mode operates the CPU and peripheral functions by using the sub clock (SCLK). The main clock and the PLL multiplier circuit stop their operation in the sub clock mode. The clock mode includes the PLL clock mode except the low power consumption mode. Refer to Section "6.4 Clock Modes", for more information on clock modes. ■ CPU Intermittent Operation Mode The CPU intermittent operation mode operates the CPU intermittently while supplying a high-speed clock to the peripheral functions, thereby reducing power consumption. This mode inputs an intermittent clock only to the CPU while the CPU accesses registers, built-in memory, peripheral functions, and external devices. ■ Standby Mode The standby mode reduces current consumption by stopping supply of a clock to the CPU by using the lowpower consumption control circuit (sleep mode), stopping supply of a clock to the CPU and peripheral functions (time-base timer mode), and stopping oscillation clocks (stop mode). ● Sleep mode The sleep mode stops the CPU operation clock in each clock mode. The CPU stops, and the peripheral functions operates with the clock before the sleep mode shifts. The clock mode when shifting to sleep mode divides into the main sleep mode, PLL sleep mode, and the sub sleep mode. ● Time-base timer mode The time-base timer mode stops clocks and operations other than the oscillation clock, time-base timer, and watch timer. Functions other than the time-base timer and watch timer are stopped. ● Watch mode The watch mode operates only the watch timer. In this mode, only the sub clock operates. The main clock and PLL multiplier circuit are stopped. ● Stop mode The stop mode stops source oscillation, and all functions are stopped. In the stop mode, the oscillation clock stops and data can be retained with the lowest consumption of power. 121 CHAPTER 7 LOW-POWER CONSUMPTION MODE Note: In stop mode, oscillation clock stops and data is maintained with the minimum power dissipation. When changing to clock mode, do not change to other low-power consumption modes or clock modes before changing to stop mode is completed. Verify that changing to clock mode is completed by referring to MCM, SCM bits of clock selection register (CKSCR). Mode may not be changed if changing to other low-power consumption modes or clock modes performed before completion of changing. 122 7.2 Block Diagram of Low-Power Consumption Control Circuit The low-power consumption control circuit is composed of the following seven blocks: • CPU intermittent operation selector • Standby control circuit • CPU-clock control circuit • Peripheral clock control circuit • Pin high-impedance control circuit • Internal reset generator circuit • Low-power consumption mode control register (LPMCR) ■ Block Diagram of Low-Power Consumption Control Circuit Figure 7.2-1 shows the block diagram of the low-power consumption control circuit. Figure 7.2-1 Block Diagram of Low-Power Consumption Control Circuit Low-power consumption mode control register (LPMCR) STP SLP SPL RST TMD CG1 CG0 Reserved Pin highimpedance control circuit RST Pin high-impedance control Internal reset generator circuit Pin CPU intermittent operation selector Internal reset Intermittent cycle selection CPU-clock control circuit 2 Interrupt reset Stop and sleep signal Standby control circuit Machine clock Cancel waiting time to stable oscillation Clock generator Clock selector Clock SCLK divided by four CPU clock Stop signal Peripheral Peripheral clock clock control circuit PLL2 PLL output selection register (PLLOS) 2 Selector for waiting time to stable oscillation 2 Sub clock generator circuit PLL multiplier circuit System clock generator circuit X0A Pin X1A Pin X0 Pin X1 Pin SCM MCM WS1 WS0 SCS MCS CS1 CS0 Clock selection register (CKSCR) Clock Clock HCLK divided MCLK divided by 1024 by two Clock divided by two Clock divided by four Clock divided by four Clock divided by four Clock divided by two Time-base timer HCLK : Oscillation clock MCLK : Main clock SCLK : Sub clock To watchdog timer 123 CHAPTER 7 LOW-POWER CONSUMPTION MODE ● CPU intermittent operation selector The CPU intermittent operation selector selects the number of pause clocks in the CPU intermittent operation mode. ● Standby control circuit The standby control circuit controls the CPU-clock control circuit and peripheral clock control circuit for resetting and changing to the low-power consumption mode. ● CPU-clock control circuit The CPU-clock control circuit controls clocks supplied to the CPU. ● Peripheral clock control circuit The peripheral clock control circuit controls clocks supplied to peripheral functions. ● Pin high-impedance control circuit The pin high-impedance control circuit changes the states of external pins to high impedance in the timebase timer mode and stop mode. In the stop mode, the circuit isolates pull-up resistance with pins for which the pull-up option is selected. ● Internal reset generator circuit The internal reset generator circuit generates an internal reset signal. ● Low-power consumption mode control register (LPMCR) The low-power consumption mode control register (LPMCR) performs functions, such as resetting and changing to the standby mode and defining the CPU intermittent operation function. 124 7.3 Low-Power Consumption Mode Control Register (LPMCR) The low-power consumption mode control register (LPMCR) performs functions including changing the current mode to the low-power consumption mode, canceling from the low-power consumption mode, and specifying the number of CPU-clock pause cycles in the CPU intermittent operation mode. ■ Low-Power Consumption Mode Control Register (LPMCR) Figure 7.3-1 shows the configuration of the low-power consumption mode control register (LPMCR). Figure 7.3-1 Configuration of Low-Power Consumption Mode Control Register (LPMCR) Address 0000A0H bit15 (CKSCR) bit8 bit7 bit6 bit5 bit4 bit3 bit2 bit1 STP SLP SPL RST TMD CG1 CG0 Reserved W W R/W W R/W R/W bit0 00011000B R/W R/W Reserved Initial value Reserved bit Reading and writing has no effect on operation CG1 CG0 Bit for number of CPU-clock pause cycles 0 0 0 cycle (CPU clock = Resource clock) 0 1 8 cycles (CPU clock: Resource clock = 1: About 3 to 4) 1 0 16 cycles (CPU clock: Resource clock = 1: About 5 to 6) 1 1 32 cycles (CPU clock: Resource clock = 1: About 9 to 10) Watch mode or time-base timer mode bit TMD 0 Change to time-base timer mode 1 RST No change, no effect on others Internal reset signal generator bit 0 Generates an internal reset signal of 3 machine cycles 1 No change, no effect on others SPL 0 1 Pin state specification bit (in watch, time-base timer and stop modes) Hold High impedance Sleep mode bit SLP 0 No change, no effect on others 1 R/W : Readable/Writable W : Write only : Initial value STP Change to sleep mode Stop mode bit 0 No change, no effect on others 1 Change to stop mode 125 CHAPTER 7 LOW-POWER CONSUMPTION MODE Table 7.3-1 Functions of Bits in Low-Power Consumption Mode Control Register (LPMCR) Bit name Function STP: Stop mode bit This bit instructs a change to the stop mode. • Write "1" in this bit to change the mode to the stop mode. • Writing "0" in this bit does not affect operation. • Cleared to "0" by a reset or if an interrupt request is generated. • "0" is always read when this bit is read. bit6 SLP: Sleep mode bit This bit instructs a change to the sleep mode. • Write "1" in this bit to change the mode to the sleep mode. • Writing "0" in this bit does not affect operation. • Cleared to "0" by a reset or if an interrupt request is generated. • "0" is always read when this bit is read. bit5 SPL: Pin state specification bit (in watch, time-base timer, and stop modes) This bit is effective only in the watch, time-base timer, and stop modes. • If this bit is "0", the levels of external pins are retained. • If this bit is "1", the levels of external pins are changed to high impedance. • Initialized to "0" when reset. bit4 RST: Internal reset signal generator bit This bit generates the software reset. • Write "0" in this bit to generate an internal reset signal of 3 machine cycles. • Writing "1" in this bit does not affect operation. • "1" is always read when this bit is read. bit3 TMD: watch and time-base timer mode bit This bit instructs a change to the watch or time-base timer mode. • Write "0" in this bit at the main clock or PLL clock mode to change the mode to the time-base timer mode. • Write "0" in this bit at the sub clock mode to change the mode to the watch mode. • Initialized to "1" by a reset or if an interrupt request is generated. • "1" is always read when this bit is read. bit2, bit1 CG1, CG0: Bit for selecting number of CPU-clock pause cycles This bit specifies the number of pause cycles of the CPU clock in the CPU intermittent operation function. • Stops supply of CPU clocks for the specified number of cycles per instruction. • Capable selected from four clock numbers. • Initialized to "00B" by a reset. bit0 Reserved: Reserved bit bit7 126 Reading and writing has no effect on operation. ■ Accessing Low-Power Consumption Mode Control Register Writing in the low-power consumption mode control register executes a change to the standby mode (stop, sleep, time-base timer and watch modes). Use the instructions listed in Table 7.3-2. The low-power consumption mode transition instruction in Table 7.3-2 must always be followed by an array of instructions highlighted by a line below. MOV LPMCR,#H'xx NOP NOP JMP $+3 MOV A,#H'10 ; The low-power consumption mode transition instruction in Table 7.3-2. ; Jump to next instruction ; Any instruction The devices does not guarantee its operation after releasing from the standby mode if you place an array of instructions other than the one enclosed in the line. To access the low-power consumption mode control register (LPMCR) with C language, refer to "7.8 Caution on Using Low-Power Consumption Mode". When writing to the low-power consumption mode control register with a length of words, use even addresses only. Performing transition by using an odd address for writing may result in operation errors. Any instruction may be used to control functions not listed in Table 7.3-1. Table 7.3-2 Instructions Used for Change to Low-power Consumption Mode MOV io,#imm8 MOV dir,#imm8 MOV eam,#imm8 MOV eam,Ri MOV io,A MOV dir,A MOV addr16,A MOV eam,A MOVW io,#imm16 MOVW dir,#imm16 MOVW eam,#imm16 MOVW eam,RWi MOVW io,A MOVW dir,A MOVW addr16,A MOVW eam,A SETB io:bp SETB dir:bp SETB addr16:bp CLRB io:bp CLRB dir:bp CLRB addr16:bp MOV @RLi+disp8,A MOVW @RLi+disp8,A ■ Priority of STP, SLP, and TMD Bits Requests are processed with the following order of priority in the event that stop mode, sleep mode, and time-base timer mode requests are issued simultaneously. Stop-mode request > Time-base timer mode request > Sleep mode request 127 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.4 CPU Intermittent Operation Mode The CPU intermittent operation mode reduces power consumption by intermittently operating the CPU while operating external buses and peripheral functions at high speeds. ■ CPU Intermittent Operation Mode To delay activation of the internal bus cycle, the CPU intermittent operation mode stops clocks supplied to the CPU for a preset period for each instruction during access to registers, embedded memory (ROM or RAM), I/O, peripheral functions, and external buses. Low-power consumption processing is possible by lowering the CPU execution speed while high-speed peripheral clocks are supplied to peripheral functions. • Select the number of clock pause cycles supplied to the CPU using a bit for selecting the number of CPU-clock pause cycles (CG1 or CG0) of the low-power consumption mode control register (LPMCR). • Use the same clock as that for the peripheral functions when operating external buses. • The instruction execution time when the CPU intermittent operation mode is set can be calculated by dividing the number of instruction executions for accessing registers, embedded memory, embedded peripheral functions, and external buses by the number of pauses cycles. The correction value thus obtained is added to the usual execution time. Figure 7.4-1 illustrates operation clocks in the CPU intermittent operation mode. Figure 7.4-1 Clocks in CPU Intermittent Operation Mode Peripheral clock CPU clock Pause cycle One instruction execution cycle Internal bus activation 128 7.5 Standby Mode The standby mode is divided into four modes, namely, the sleep (PLL sleep, main sleep, and sub sleep), time-base timer, watch, and stop modes. ■ Operational States in Standby Mode Table 7.5-1 lists operational states in the standby mode. Table 7.5-1 Operational States in Standby Mode Standby mode PLL sleep mode Change Main clock condition Sub clock Machine clock CPU Peripheral Pin Cancellation method SCS = 1 MCS = 0 SLP = 1 In operation Sleep mode Main sleep mode Sub sleep mode SCS = 0 SLP = 1 Time-base timer mode (SPL = 0) SCS = 1 TMD = 0 Time-base timer mode Time-base timer mode (SPL = 1) Watch mode SCS = 1 MCS = 1 SLP = 1 In operation In operation Stopped In operation Hold In operation Stopped SCS = 0 TMD = 0 Watch mode (SPL = 1) SCS = 0 TMD = 0 Stop mode (SPL = 0) STP = 1 Reset or interrupt Stopped*1 SCS = 1 TMD = 0 Watch mode (SPL = 0) In operation Hi-Z Hold Stopped Stopped*2 Hi-Z Stopped Stop mode Stopped Stop mode (SPL = 1) *1 *2 SPL SLP STP TMD MCS SCS Hi-Z RST Hold Stopped STP = 1 Hi-Z : The time-base timer and watch timer are operating. : The watch timer is operating : Pin-state specification bit of low-power consumption mode control register (LPMCR) : Sleep mode bit of low-power consumption mode control register (LPMCR) : Stop mode bit of low-power consumption mode control register (LPMCR) : Watch/time-base timer mode bit of low-power consumption mode control register (LPMCR) : Machine clock selection bit of the clock selection register (CKSCR) : Machine clock selection bit (Sub) of the clock selection register (CKSCR) : High impedance : External-reset pin 129 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.5.1 Sleep Mode The sleep mode stops CPU operation clocks, allowing devices other than the CPU to continue operation. ■ Change to Sleep Mode Writing "1" in the sleep mode bit (SLP), "1" in the watch/time-base timer mode bit (TMD), and "0" in the stop mode bit (STP) of the low-power consumption mode control register (LPMCR) changes the mode to the sleep mode. Note: If "1" is simultaneously written in the SLP and STP bits of the LPMCR register, the STP bit has the priority and the device is changed to the stop mode. If writing "1" in the SLP bit and writing "0" in the TMD bit of the low-power consumption mode control register are performed at the same time, the TMD bit has the priority and the device is changed to the time-base timer mode or watch mode. ● Data hold function This function in the sleep mode holds data of the internal RAM and dedicated registers such as an accumulator. ● Hold function The external bus hold function operates in the sleep mode. A hold state is set if a hold request is issued. ● Operation during interrupt request The sleep mode is not set if an interrupt request is issued while "1" is written in the SLP bit of the LPMCR register. The CPU executes a next instruction if an interrupt request is not accepted. If the CPU can accept an interrupt request, the request is immediately branched to an interrupt processing routine. ● Pin state In the sleep mode, the previous states are maintained except for pins used for bus input and output or for bus control. 130 ■ Canceling the Sleep Mode The low-power consumption control circuit cancels the sleep mode by input of a reset or by an interrupt. ● Restore by a reset Reset initializes to the main clock mode. ● Restore by interrupt The sleep mode is canceled if an interrupt request whose interrupt level is higher than 7 is generated in a peripheral circuit, etc., in the sleep mode. After the sleep mode is canceled, the interrupt is processed with the same method as for ordinary interrupt processing. If interrupts are accepted by setting the I-flag of the condition code register (CCR), interrupt level mask register (ILM), or the interrupt control register (ICR), then the CPU executes the interrupts. If the interrupts cannot be accepted, the CPU continues processing beginning from an instruction next to the instruction specifying the sleep mode. Figure 7.5-1 illustrates the canceling of the sleep mode by an interrupt. Figure 7.5-1 Canceling of Sleep Mode by Interrupt Setting interrupt enable flag from peripheral functions INT generates (IL<7) NO Sleep not canceled Sleep not canceled YES I=0 YES Next instruction Sleep canceled NO YES ILM < IL Executes next instruction NO Interrupt executed Note: When executing an interrupt, an instruction next to the instruction that specified the sleep mode is normally executed first before an interrupt request is processed. If a change to the sleep mode occurs at the same time as an external bus hold request is received, an interrupt may be executed first before the next instruction is executed. 131 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.5.2 Time-base Timer Mode The time-base timer mode stops operations except for source oscillation, time-base timer and watch timer. All functions except the time-base timer and watch timer are stopped. ■ Change to Time-base Timer Mode To change the mode to the time-base timer mode, write "0" in watch/time-base timer mode bit (TMD) of the low-power consumption mode control register (LPMCR) in the PLL clock mode or the main clock mode (sub clock display bit (SCM) = 1 of the clock selection register (CKSCR)). ● Data hold function This function in the time-base timer mode holds data of the internal RAM and dedicated registers such as an accumulator. ● Hold function In the time-base timer mode, the external bus hold function is stopped and hold requests cannot be accepted even if they are input. If a hold request is input during a change to the time-base timer mode, the level of the HAK signal may not change to "L" while the bus is set to the high-impedance state. ● Operation during interrupt request The time-base timer mode is not set if an interrupt request is issued while "0" is written to the TMD bit of the low-power consumption mode control register (LPMCR). ● Pin state Pin state specification bit (SPL) of the LPMCR register can control whether to maintain the state of an external pin in the time-base timer mode in the previous state or in the high-impedance state. ■ Canceling the Time-base Timer Mode The low-power consumption control circuit cancels the time-base timer mode by input of a reset or by an interrupt. ● Return by external reset External reset initializes to the main clock mode. 132 ● Return by interrupt The time-base timer mode is canceled by the low-power consumption control circuit if an interrupt request whose interrupt level is higher than 7 (other than IL2, IL1, and IL0=111B of the interrupt control register (ICR)) is generated in a peripheral circuit, etc., in the time-base timer mode. After the time-base timer mode is canceled, interrupts are processed with the same method as for ordinary interrupt processing. If interrupts are accepted by setting the I-flag of the condition code register (CCR), interrupt level mask register (ILM), or the interrupt control register (ICR), then the CPU executes the interrupts. If an interrupt cannot be accepted, the CPU continues processing beginning from an instruction that was processed before the time-base timer mode was set. Note: When executing an interrupt, an instruction next to the instruction specifying the time-base timer mode is normally executed first before an interrupt request is processed. If a change to the timebase timer mode occurs at the same time as an external bus hold request is received, an interrupt may be executed first before the next instruction is executed. 133 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.5.3 Watch Mode The watch mode stops operations other than those of the sub clock and watch timer. ■ Change to Watch Mode To change the mode to the watch mode, write "0" in watch/time-base timer mode bit (TMD) of the lowpower consumption mode control register (LPMCR) in the sub clock mode (sub clock display bit (SCS) = 0 of the clock selection register (CKSCR)). ● Data hold function This function in the watch mode holds data of the internal RAM and dedicated registers such as an accumulator. ● Hold function In the watch mode, the external bus hold function is stopped and hold requests cannot be accepted even if they are input. Note: If a hold request is input during a change to the watch mode, the level of the HAK signal may not change to "L" while the bus is set to the high-impedance state. ● Operation during interrupt request The watch mode is not set if an interrupt request is issued while "0" is set in the TMD bit of the LPMCR register. ● Pin state setting Pin state specification bit (SPL) of the LPMCR register can control whether to maintain the state of an external pin in the watch mode in the previous state or in the high-impedance state. ■ Canceling the Watch Mode The low-power consumption control circuit cancels the watch mode by input of a reset or by an interrupt. ● Return by a reset When the watch mode is canceled by a reset factor, the watch mode is canceled first, and a reset state for standing by for stable oscillation is set. The sequence for resetting is executed after the end of the oscillation stabilization wait time. 134 ● Return by interrupt The watch mode is canceled by the low-power consumption control circuit if an interrupt request whose interrupt level is higher than 7 (other than IL2, IL1, and IL0=111B of the interrupt control register (ICR)) is generated in a peripheral circuit, etc., in the watch mode. The mode immediately changes to the sub clock mode. After the change to the sub clock mode, interrupts are processed with the same method as for ordinary interrupt processing. If interrupts are accepted by setting the I-flag of the condition code register (CCR), interrupt level mask register (ILM), or the interrupt control register (ICR), then the CPU executes the interrupts. If an interrupt cannot be accepted, the CPU continues processing beginning from an instruction next to the instruction that was processed before the watch mode was set. Note: When executing an interrupt, an instruction next to the instruction specifying the watch mode is normally executed first before an interrupt request is processed. If a change to the watch mode occurs at the same time as an external bus hold request is received, an interrupt may be executed first before the next instruction is executed. Figure 7.5-2 illustrates the cancel operation of the watch mode. Figure 7.5-2 Cancel Operation of Watch Mode (External Reset) RST pin Watch mode Oscillation stabilization wait PLL clock Sub clock Not operating Oscillation Main clock During oscillation Not operating Oscillating CPU clock Not operating CPU operation Not operating Main clock Processing Sequence for resetting Reset cancel Watch mode cancel 135 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.5.4 Stop Mode The stop mode stops source oscillation and stops all functions, thereby enabling retention of data with the lowest consumption of power. ■ Change to Stop Mode Write "1" in the stop mode bit (STP) of the low-power consumption mode control register (LPMCR) to change the mode to the stop mode. ● Data hold function This function in the stop mode holds data of the internal RAM and dedicated registers such as an accumulator. ● Hold function In the stop mode, the external bus hold function is stopped and hold requests cannot be accepted even if they are input. If a hold request is input during a change to the stop mode, the level of the HAK signal may not change to "L" while the bus is set to the high-impedance state. ● Operation during interrupt request The stop mode is not set if an interrupt request is issued while "1" is set in the STP bit of the LPMCR register. ● Pin state setting Pin state specification bit (SPL) of the LPMCR register can specify whether to maintain the state of an external pin in the stop mode in the previous state or in the high-impedance state. ■ Canceling the Stop Mode The low-power consumption control circuit releases the stop mode when a reset is input or an interrupt occurs. Because the oscillation clock (HCLK) and sub clock (SCLK) are halted, the stop mode is released after the oscillation stabilization wait interval of the main clock or sub clock. ● Restore by a reset When the stop mode is canceled by a reset factor, the stop mode is canceled first and the reset state standing by for stable oscillation is set. The sequence for resetting is executed after the end of the oscillation stabilization wait time. 136 ● Restore by interrupt The stop mode is canceled by the low-power consumption control circuit if an interrupt request whose interrupt level is higher than 7 (other than IL2, IL1, and IL0=111B of the interrupt control register (ICR)) is generated in a peripheral circuit, etc., in the stop mode. After the stop mode is canceled, interrupts are processed with the same method as for ordinary interrupt processing, following the elapse of the oscillation stabilization wait time for the main clock specified by the selection bits (WS1, WS0) for the oscillation stabilization wait time of the clock selection register (CKSCR). If the interrupts are accepted by setting the I-flag of the condition code register (CCR), interrupt level mask register (ILM) or the interrupt control register (ICR), the CPU executes interrupts. If an interrupt cannot be accepted, the CPU continues processing beginning from an instruction next to the instruction that was processed before the stop mode was set. Notes: • When executing an interrupt, an instruction next to the instruction that specified the stop mode is normally executed first before an interrupt request is processed. If a change to the stop mode occurs at the same time as an external bus hold request is received, an interrupt may be executed first before the next instruction is executed. • In PLL stop mode, the main clock and PLL multiplication circuit stop. During recovery from PLL stop mode, it is necessary to allot the main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time. The oscillation stabilization wait times for the main clock and PLL clock are counted simultaneously according to the value specified in the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register. The oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register must be selected accordingly to account for the longer of main clock and PLL clock oscillation stabilization wait time. The PLL clock oscillation stabilization wait time, however, requires 214/ HCLK or more. Set the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register to "10B" or "11B". Figure 7.5-3 shows the cancel operation of the stop mode. Figure 7.5-3 Cancel Operation of Stop Mode (External Reset) RST pin Stop mode Oscillation stabilization wait PLL clock CPU clock CPU operation Oscillation Main clock During oscillation Not operating Main clock Not operating Processing Sequence for resetting Reset cancel Stop-mode cancel 137 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.6 State Transition Diagram This section explains the transition of operational states for the MB90980 series and describes the transition conditions. ■ State Transition Diagram Figure 7.6-1 illustrates the transition of operational states for the MB90980 series and the transition conditions. Figure 7.6-1 State Transition and Transition Conditions External reset, watchdog timer reset, software reset Power on Reset Power-on reset SCS=0 End of oscillation stabilization wait SCS=1 Main clock mode SLP=1 MCS=0 PLL clock mode MCS=1 SLP=1 Interrupt Main sleep mode TMD=0 Interrupt TMD=0 STP=1 End of oscillation stabilization wait Oscillation stabilization wait of main clock 138 Interrupt Sub clock mode SLP=1 TMD=0 Interrupt Watch mode STP=1 PLL stop mode Interrupt Interrupt Sub sleep mode PLL time-base timer mode Main stop mode Interrupt SCS=1 Interrupt PLL sleep mode Main time-base timer mode STP=1 SCS=0 Sub stop mode End of oscillation Interrupt stabilization wait Oscillation stabilization wait of main clock End of oscillation stabilization wait Oscillation stabilization wait of sub clock ■ Operational State in Low-Power Consumption Mode Table 7.6-1 lists operational states in the low-power consumption mode. Table 7.6-1 Operational States in Low-Power Consumption Mode Operational state Main clock Sub clock PLL clock PLL clock mode CPU Peripheral Watch Time-base timer Operating Operating Not operating Not operating Operating Operating Operating Operating Not operating Not operating Operating Operating Clock source Operating Operating PLL sleep mode Operating Operating Operating PLL stop mode Not operating Not operating Not operating Standby for stable oscillation of PLL clock mode Operating Operating Operating PLL time-base timer mode Main clock mode Not operating Not operating PLL clock Operating Operating Main sleep mode Operating Operating Main time-base timer mode Main stop mode Not operating Not operating Standby for stable oscillation of main clock Operating Operating Not operating Sub clock mode Not operating Not operating Main clock Operating Operating Sub sleep mode Operating Operating Watch mode Sub clock stop mode Not operating Standby for stable oscillation of sub clock Not operating Not operating Not operating Operating Power-on reset Operating Reset Not operating Operating Not operating Not operating Sub clock Operating Main clock Operating Not operating Not operating Not operating Operating Operating 139 CHAPTER 7 LOW-POWER CONSUMPTION MODE 7.7 Pin State in Standby Mode, Hold, and Reset The states of the pins in the standby mode and in the hold and reset states are described for each memory access mode. ■ Pin State in Single Chip Mode Table 7.7-1 lists the pin states in the single-chip mode. Table 7.7-1 Pin States in Single Chip Mode When stopped Pin name In sleep state In hold state SPL = 0 SPL = 1 Input cutoff/ Maintains the previous state *2, *3 Input cutoff/ Output Hi-Z *3 When reset P27 to P24 P37 to P30 P42 to P40 P67 to P60 P77, P76 Maintains the previous state *2 P74 to P70 This state does not exist Input disabled/ Output Hi-Z P97, P96 P93 to P90 PA3 to PA0 P87 to P80 Input enabled *1 Input enabled *1 Input disabled *1: Same as in other ports when used in the output state. "Input enabled" means that input functions are ready and require pull up/pull down or external input. *2: The state output immediately before this mode was set is output as it is. If it is input, input is disabled. "Input disabled" means that operations of input gates located very close to the pins are enabled, but pin states cannot be accepted in internal operations because internal circuits are not operating. *3: "Input cutoff" means that operations of input gates located very close to the pins are disabled. "Output Hi-Z" means that the pin-drive transistors are disabled and the pins are set to the high-impedance state. 140 7.8 Caution on Using Low-Power Consumption Mode When operating in the low-power consumption mode, exercise reasonable care concerning the following: • Change to the standby mode and interrupts • Cancellation of standby mode by interrupt • Cancellation of stop mode • Oscillation stabilization wait time • Notes on accessing the low-power consumption mode control register (LPMCR) to enter the standby mode ■ Change to Standby Mode and Interrupts When a peripheral function issues an interrupt request to the CPU, the setting of "1" to the stop mode bit (STP) and sleep mode bit (SLP) in the low-power consumption mode control register (LPMCR) and "0" to the watch/time-base timer mode bit (TMD) is ignored. A change to the appropriate standby mode is not executed. (Neither is a change to the standby mode executed after interrupt processing.) In this event, the acceptance of interrupt requests by the CPU if the interrupt level is higher than 7 is irrelevant. Even when the CPU is processing an interrupt, the interrupt request flag bit is cleared, and a change to the standby mode is possible unless there is another interrupt request. ■ Cancellation of Standby Mode by Interrupt The standby mode is canceled if a peripheral function or other device issues an interrupt request whose interrupt level is higher than 7 in the sleep, time-base timer, or stop mode. This is irrelevant to whether or not the CPU accepts an interrupt. After the standby mode is canceled by an interrupt, branching to an interrupt processing routine is performed as in a normal interrupt operation if the priority of interrupt level setting bit (bits IL2, IL1, and IL0 of the ICR register) corresponding to an interrupt request is higher than the interrupt level mask register (ILM) and if interrupts are enabled (I = 1) by the I-flag of the condition code register (CCR). If an interrupt is not accepted, operation is resumed beginning from an instruction next to the instruction specifying the standby mode. In the execution of interrupt processing, interrupt processing is normally started after execution of an instruction next to the instruction specifying the standby mode. However, depending on the conditions under which the mode is changed to the standby mode, interrupt processing may be started before the next instruction is executed. Disabling of interrupts or other actions are required before setting the standby mode if branching to an interrupt processing routine is not performed immediately after a return. 141 CHAPTER 7 LOW-POWER CONSUMPTION MODE ■ Oscillation Stabilization Wait Time ● Oscillation stabilization wait time of oscillation clock The oscillator for source oscillation is stopped in the stop mode, and a oscillation stabilization wait time must be provided. Specify the oscillation stabilization wait time selected with the selection bits (WS1 and WS0) for the oscillation stabilization wait time of the clock selection register (CKSCR). Set "00B" in the selection bits (WS1 and WS0) for the oscillation stabilization wait time of the clock selection register (CKSCR) only in the main clock mode. ● Oscillation stabilization wait time of PLL clock In main clock mode, the PLL multiplication circuit stops. When changing to PLL clock mode, it is necessary to reserve the PLL clock oscillation stabilization wait time. The CPU runs in main clock mode till the PLL clock oscillation stabilization wait time has elapsed. When the main clock mode is switched to PLL clock mode, the PLL clock oscillation stabilization wait time is fixed at 214/HCLK (HCLK: oscillation clock). In sub clock mode, the main clock and PLL multiplication circuit stop. When changing to PLL clock mode, it is necessary to reserve the main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time. The oscillation stabilization wait times for main clock and PLL clock are counted simultaneously according to the value specified in the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register. The oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register must be selected accordingly to account for the longer of the main clock and PLL clock oscillation stabilization wait times. The PLL clock oscillation stabilization wait time, however, requires 214/HCLK or more. Set the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register to "10B" or "11B". In PLL stop mode, the main clock and PLL multiplication circuit stop. During recovery from PLL stop mode, it is necessary to allot the main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time. The oscillation stabilization wait times for the main clock and PLL clock are counted simultaneously according to the value specified in the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register. The oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register must be selected accordingly to account for the longer of main clock and PLL clock oscillation stabilization wait time. The PLL clock oscillation stabilization wait time, however, requires 214/HCLK or more. Set the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register to "10B" or "11B". ■ Switching the Clock Mode When the clock mode is switched, do not switch to low-power consumption mode and other clock mode before this switching is completed. Confirm the completion of clock mode switching by referring to the MCM and SCM bits of the clock selection register (CKSCR). If the mode is switched to another clock mode or low-power consumption mode before completion of switching, the mode may not be switched. 142 ■ Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode • To access the low-power consumption mode control register (LPMCR) with assembler language - To set the low-power consumption mode control register (LPMCR) to enter the standby mode, use the instruction listed in Table 7.3-2. - The low-power consumption mode transition instruction in Table 7.3-2 must always be followed by an array of instructions highlighted by a line below. MOV LPMCR,#H'xx NOP NOP JMP MOV $+3 A,#'10 ; the low-power consumption mode transition instruction in Table 7.3-2. ; jump to next instruction ; any instruction The devices does not guarantee its operation after releasing from the standby mode if you place an array of instructions other than the one enclosed in the line. • To access the low-power consumption mode control register (LPMCR) with C language To enter the standby mode using the low-power consumption mode control register (LPMCR), use one of the following methods (1) to (3) to access the register: (1) Specify the standby mode transition instruction as a function and insert two _wait_nop() built-in functions after that instruction. If any interrupt other than the interrupt to return from the standby mode can occur within the function, optimize the function during compilation to suppress the LINK and UNLINK instructions from occurring. Example: Watch mode or time-base timer mode transition function void enter_watch(){ IO_LPMCR.byte = 0x10; /* Set LPMCR TMD bit to "0" */ _wait_nop(); _wait_nop(); } (2) Define the standby mode transition instruction using _asm statements and insert two NOP and JMP instructions after that instruction. Example: Transition to sleep mode _asm(" MOV I: _IO_LPMCR,#H'58"); /* Set LPMCR SLP bit to "1" */ _asm(" NOP"); _asm(" NOP"); 143 CHAPTER 7 LOW-POWER CONSUMPTION MODE (3) Define the standby mode transition instruction between #pragma asm and #pragma endasm and insert two NOP and JMP instructions after that instruction. Example: Transition to stop mode MOV I: _IO_LPMCR,#H'98 /* Set LPMCR STP bit to "1" */ NOP NOP JMP $+3 #pragma endasm 144 /* Jump to next instruction */ CHAPTER 8 MEMORY ACCESS MODE This chapter explains memory access mode and its operation. 8.1 Overview of Memory Access Mode 8.2 Mode Pins (MD2 to MD0) 8.3 Mode Data 145 CHAPTER 8 MEMORY ACCESS MODE 8.1 Overview of Memory Access Mode The F2MC-16LX has different modes in each access system and access area. Each mode is set according to a mode pin at the reset state and according to mode data obtained by mode-fetch. ■ Overview of Memory Access Mode Table 8.1-1 Mode Pin and Mode Operation mode Bus mode RUN mode Single-chip mode Flash programming - ■ Operation Modes Operation modes are used to control the operating conditions of devices, and they are set by mode setting pins (MDx) and with the contents of the Mx bits in mode data. By selecting an operation mode, normal operation activation or flash serial programming can be performed. ■ Bus Modes MB90980 series does not support external bus function. Use single-chip mode. 146 8.2 Mode Pins (MD2 to MD0) Mode pins are three external pins (MD2 to MD0) that specify the reset vector and mode data fetching method. ■ Settings of Mode Pins (MD2 to MD0) Table 8.2-1 Contents of Mode Pin Settings MD2 MD1 MD0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Mode name Reset vector access area Remarks Setting not allowed Internal vector mode Internal Operation after reset sequence is controlled with mode data Setting not allowed FLASH serial write mode FLASH memory mode - Mode when the parallel writer is used. Note: MD2 to MD0: Specify 0=VSS or 1=VCC. The flash serial write mode cannot be executed by just setting the mode pins. Other terminal also need to be set. For details, see "CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION". 147 CHAPTER 8 MEMORY ACCESS MODE 8.3 Mode Data Mode data stored at address "FFFFDFH" in memory specifies the operation immediately after the reset sequence. Mode data is read and stored in the CPU automatically by mode fetching. ■ Mode Data During the reset sequence, mode data at address "FFFFDFH" is sent to the mode register in the CPU core. The CPU uses this mode data to set the memory access mode. The contents of the mode register can be changed only by the reset sequence. Furthermore, mode data settings become valid only after the reset sequence. The configuration of mode data is shown in the figure below. Figure 8.3-1 Configuration of Mode Data bit 7 Mode data M1 6 5 4 3 2 1 0 M0 0 S1 S0 0 0 0 Bus mode setting bits Setting bits of different modes Function expansion bits (reserved area) ■ Bus Mode Setting Bits (M1, M0) Bits M1 and M0 specify the operation mode that is set after completion of the reset sequence. Table 8.3-1 lists the contents of the settings for bits M1 and M0. Table 8.3-1 Contents of Bit M1 and M0 Settings 148 M1 M0 0 0 0 1 1 0 1 1 Functions Single-chip mode (Setting is prohibited) ■ Correspondence Between Access Areas and Physical Address Figure 8.3-2 shows the correspondence between access areas and physical addresses. Figure 8.3-2 Relationship Between Access Areas and Physical Addresses Single chip FFFFFFH ROM area Address #1 FC0000H 010000H ROM area, image of FF bank Address #2 Address #3 RAM Register 000100H 0000D0H Peripheral 000000H Internal access No access Note: "Address #X" is determined based on individual models. See "APPENDIX A Memory Map", for details. ■ Relationship Between Mode Pins and Mode Data (an Example Showing Recommended Relationship) Table 8.3-2 shows the relationship between mode pins and mode data. Table 8.3-2 Relationship Between Mode Pins and Mode Data Mode Single chip MD2 MD1 MD0 M1 M0 0 1 1 0 0 Note: MB90980 series can use only single-chip mode. 149 CHAPTER 8 MEMORY ACCESS MODE 150 CHAPTER 9 I/O PORT This chapter shows the configuration and explains the functions of the registers used for the I/O port. 9.1 Functions of I/O Port 9.2 Registers for I/O Port 151 CHAPTER 9 I/O PORT 9.1 Functions of I/O Port This section outlines the functions of the I/O port. ■ Functions of I/O Port The I/O port has functions to output data from the CPU to I/O pins and introduce the signals input to I/O pins to the CPU by using the port register (PDR). Furthermore, the I/O port enables input to and output from I/O pins to be set in any direction in units of bits by using the port direction register (DDR). The MB90980 series has 48 input/output pins. 152 9.2 Registers for I/O Port This section shows the configuration and explains the functions of the registers used for the I/O port. ■ Registers for I/O Port The registers for the I/O port are listed below: • Port registers (PDR2 to PDR4 and PDR6 to PDRA) • Port direction registers (DDR2 to DDR4 and DDR6 to DDRA) • Output pin registers (ODR7, ODR4) • Analog input enable register (ADER) • Up/down timer input enable register (UDER) 153 CHAPTER 9 I/O PORT 9.2.1 Port registers (PDR2 to PDR4, PDR6 to PDRA) This section shows the configuration and explains the functions of port registers (PDR2 to PDR4, PDR6 to PDRA) ■ Port Registers (PDR2 to PDR4, PDR6 to PDRA) Figure 9.2-1 shows a list of port registers (PDR2 to PDR4, PDR6 to PDRA). Figure 9.2-1 List of Port Registers (PDR2 to PDR4, PDR6 to PDRA) PDR2 bit Address:000002H PDR3 bit Address:000003H PDR4 bit Address:000004H PDR6 bit Address:000006H PDR7 bit Address:000007H PDR8 bit Address:000008H PDR9 bit Address:000009H PDRA bit Address:00000AH 7 P27 7 P37 7 7 P67 7 P77 7 P87 7 P97 7 - 6 P26 6 P36 6 6 P66 6 P76 6 P86 6 P96 6 - 5 P25 5 P35 5 5 P65 5 5 P85 5 5 - 4 P24 4 P34 4 4 P64 4 P74 4 P84 4 4 - 3 3 P33 3 3 P63 3 P73 3 P83 3 P93 3 PA3 2 2 P32 2 P42 2 P62 2 P72 2 P82 2 P92 2 PA2 1 1 P31 1 P41 1 P61 1 P71 1 P81 1 P91 1 PA1 0 0 P30 0 P40 0 P60 0 P70 0 P80 0 P90 0 PA0 Initial value Access XXXXXXXXB R/W * XXXXXXXXB R/W * XXXXXXXXB R/W * XXXXXXXXB R/W * 11XXXXXXB R/W * XXXXXXXXB R/W * XXXXXXXXB R/W * ----XXXXB R/W * * : R/W access to I/O ports slightly differs in operation from R/W access to memory. Be careful about such R/W access because it operates as follows: - 0: Input mode -- During reading: The level of the relevant pins is read and output. -- During writing: Writing is performed on the latch for output. - 1: Output mode - During reading: The value of the data register latch is read and output. 154 9.2.2 Port direction registers (DDR2 to DDR4, DDR6 to DDRA) This section shows the configuration and explains the functions of port direction registers (DDR2 to DDR4, DDR6 to DDRA). ■ Port Direction Registers (DDR2 to DDR4, DDR6 to DDRA) Figure 9.2-2 shows a list of port direction registers (DDR2 to DDR4, DDR6 to DDRA). Figure 9.2-2 List of Port Direction Registers (DDR2 to DDR4, DDR6 to DDRA) DDR2 bit Address:000012H DDR3 bit Address:000013H DDR4 bit Address:000014H DDR6 bit Address:000016H DDR7 bit Address:000017H DDR8 bit Address:000018H DDR9 bit Address:000019H DDRA bit Address:00001AH 7 D27 7 D37 7 7 D67 7 7 D87 7 D97 7 - 6 D26 6 D36 6 6 D66 6 6 D86 6 D96 6 - 5 D25 5 D35 5 5 D65 5 5 D85 5 5 - 4 D24 4 D34 4 4 D64 4 D74 4 D84 4 4 - 3 3 D33 3 3 D63 3 D73 3 D83 3 D93 3 DA3 2 2 D32 2 D42 2 D62 2 D72 2 D82 2 D92 2 DA2 1 1 D31 1 D41 1 D61 1 D71 1 D81 1 D91 1 DA1 0 0 D30 0 D40 0 D60 0 D70 0 D80 0 D90 0 DA0 Initial value 0000XXXXB Access R/W 00000000B R/W XXXXX000B R/W 00000000B R/W XXX00000B R/W 00000000B R/W 00XX0000B R/W - - - -0000B R/W ● When each pin functions as a port When each pin functions as a port, it controls the corresponding pin as follows: • 0: Input mode • 1: Output mode, which can be set to "0" by a reset. Notes: • If this register is accessed with a command of the read-modify-write type (such as the bit-set command), the contents of the output registers corresponding to the other bits specified for input are replaced with the input value of the pin at the time of access even if the bit specified by the command is set to the required value. Therefore, when a pin for input is switched to a pin for output, be sure to define DDR after writing the desired value to PDR, and then switch it to a pin for output. • P77 and P76 of MB90980 series do not have DDR function. Data is always valid as a port. So set the PDR value to "1" when P77 and P76 are used as I2C pins. (When using as P77 and P76, stop I2C.) Also this port has the open drain output format (without P-ch), therefore it is necessary to set the PDR value to "1" in order to turn off the output transistor and to add a pull-up resistor to external output when this port is used as an input port. 155 CHAPTER 9 I/O PORT 9.2.3 Other registers This section shows the configuration and explains the functions of registers other than port registers (PDR2 to PDR4, PDR6 to PDRA) or port direction registers (DDR2 to DDR4, DDR6 to DDRA). ■ Port Output Pin Registers (ODR7, ODR4) The bit configuration of port output pin registers (ODR7, ODR4) is shown in the figure below. Figure 9.2-3 Bit Configuration of Port Output Pin Registers (ODR7, ODR4) ODR7 bit Address:00001EH ODR4 bit Address:00001BH 7 7 - 6 6 - 5 5 - 4 3 2 1 0 Initial value Access OD74 OD73 OD72 OD71 OD70 XXX00000B R/W 4 3 2 1 0 OD42 OD41 OD40 XXXXX000B R/W Port output pin registers (ODR7, ODR4) perform open drain control in the output mode. • 0: Sets a standard output port in the output mode • 1: Sets an open-drain output port in the output mode Note: P77 and P76 are N-ch open drain pin (without P-ch). Output pin registers (ODR7, ODR4) have no function in the input mode (Output Hi-Z). The input or output mode is determined by the setting of the direction register (DDR). This function is prohibited when an external bus is used. Do not write to this register. 156 ■ Analog Input Enable Register (ADER) The bit configuration of the analog input enable register (ADER) is shown in the figure below. Figure 9.2-4 Bit Configuration of Analog Input Enable Register (ADER) ADER bit 7 6 5 4 3 2 1 0 Address:00001FH ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 ADE0 Initial value Access 11111111B R/W The analog input enable register (ADER) controls the pins of port 6 as follows: • 0: Sets the port I/O mode • 1: Set the analog I/O mode. "1" is restored by a reset. In the MB90980 series, each bit is set as follows: • ADE0: P60/AN0 • ADE1: P61/AN1 • ADE2: P62/AN2 • ADE3: P63/AN3 • ADE4: P64/AN4 • ADE5: P65/AN5 • ADE6: P66/AN6 • ADE7: P67/AN7 ■ Up/Down Timer Input Enable Register (UDER) The bit configuration of the up/down timer input enable register (UDER) is shown in the figure below. Figure 9.2-5 Bit Configuration of Up/Down Timer Input Enable Register (UDER) UDER bit Address:00000BH 7 - 6 - 5 4 3 2 1 0 Initial value Access UDE5 UDE4 UDE3 UDE2 UDE1 UDE0 XX000000B R/W The up/down timer input enable register (UDER) controls the pins of port 3 as follows: • 0: Sets the port input mode • 1: Sets the up/down timer input mode. "0" is restored by a reset. In the MB90980 series, each bit is set as follows: • UDE0: P30/AIN0 • UDE1: P31/BIN0 • UDE2: P32/ZIN0 • UDE3: P33/AIN1 • UDE4: P34/BIN1 • UDE5: P35/ZIN1 157 CHAPTER 9 I/O PORT 158 CHAPTER 10 TIME-BASE TIMER This chapter explains the function and operation of the time-base timer. 10.1 Overview of Time-base Timer 10.2 Time-base Timer Configuration 10.3 Time-base Timer Control Register (TBTC) 10.4 Time-base Timer Interrupt 10.5 Time-base Timer Operation 10.6 Notes on Using Time-base Timer 10.7 Sample Programs of Time-base timer 159 CHAPTER 10 TIME-BASE TIMER 10.1 Overview of Time-base Timer The time-base timer, which is an 18-bit free-run counter (time-base timer counter) that counts up in synchronization with the internal count clock (the source clock frequency divided by 2), has the interval timer function to enable selection for four types of interval times. Furthermore, it also has functions to supply operation clocks including timer output for the oscillation stabilization wait time as well as the watchdog timer. ■ Interval Timer Function The interval timer function generates repetitive interval interrupt requests. • An interrupt request is generated when the bit for the interval timer in the time-base counter overflows. • The bit for the interval timer (interval time) can be selected out of four types. Table 10.1-1 shows the interval time of the time-base timer. Table 10.1-1 Interval Time of Time-base Timer Internal count clock cycle Interval cycle 212 / HCLK (approximately 1.0 ms) 2 / HCLK (0.5 μs) 214 / HCLK (approximately 4.1 ms) 216 / HCLK (approximately 16.4 ms) 219 / HCLK (approximately 131.1 ms) HCLK: Oscillation clock The value during operation of the oscillation clock at 4 MHz is shown in ( ). 160 ■ Clock Supplying Function The clock supplying function is the function supplying the timer for the oscillation stabilization wait time and the operation clocks to some peripheral functions. Table 10.1-2 lists the cycles of the clocks supplied by the time-base timer to individual peripheral functions. Table 10.1-2 Clock Cycles Supplied by Time-base Timer Function to which clock is supplied Clock cycle 213 / HCLK (approximately 2.0 ms) Oscillation stabilization wait time 215 / HCLK (approximately 8.2 ms) 217 / HCLK (approximately 32.8 ms) Remarks Oscillation stabilization wait time for ceramic resonator Oscillation stabilization wait time for crystal resonator 212 / HCLK (approximately 1.0 ms) 214 / HCLK (approximately 4.1 ms) Watchdog timer Up-count clock for watchdog timers 216 / HCLK (approximately 16.4 ms) 219 / HCLK (approximately 131.1 ms) HCLK: Oscillation clock The value during operation of the oscillation clock at 4 MHz is shown in ( ). Because the oscillation cycle immediately after the start of oscillation is unstable, the oscillation stabilization wait time is merely a guideline. 161 CHAPTER 10 TIME-BASE TIMER 10.2 Time-base Timer Configuration The time-base timer is composed of the following four blocks: • Time-base timer counter • Counter clear circuit • Interval timer selector • Time-base timer control register (TBTC) ■ Block Diagram of Time-base Timer Figure 10.2-1 is a block diagram of the time-base timer. Figure 10.2-1 Block Diagram of Time-base Timer To watchdog timer To PPG timer Time-base timer counter HCLK frequency divided by 2 × 21 × 2 2 × 23 × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 × 216 × 217 × 218 OF OF Power-on reset Stop mode start CKSCR : MCS = 1→ 0 (*1) CKSCR : SCS = 0 → 1 (*2) OF OF To selector of oscillation stabilization wait time in clock control section Counter clear circuit Interval timer selector TBOF set TBOF clear Time-base timer control register (TBTC) RESV TBIE TBOF TBR TBC1 TBC0 Time-base timer interrupt signal OF HCLK *1 *2 : Undefined : Overflow : Oscillation clock : Switching the machine clock from the main clock or the sub clock to the PLL clock : Switching the machine clock from the sub clock to the main clock ● Time-base timer counter This is an 18-bit up-counter that uses the oscillation clock (HCLK) frequency divided by 2 as the count clock. ● Counter clear circuit This circuit clears the counter at the time of writing of "0" to the time-base timer initializing bit (TBR) in the time-base timer control register (TBTC), a power-on reset, a transition to the main stop mode, a transition to the PLL stop mode, switching from the main clock mode to the PLL clock mode, switching from sub clock mode to the PLL clock mode, and switching from the sub clock mode to main clock mode. 162 ● Interval timer selector Selects one of the four types for time-base timer counter output. Overflow of the selected bit causes an interrupt. ● Time-base timer control register (TBTC) Selects the interval time, clears the counter, controls interrupt requests, and checks the current state. 163 CHAPTER 10 TIME-BASE TIMER 10.3 Time-base Timer Control Register (TBTC) This register selects the interval time, clears the counter, controls interrupt requests, and checks the state. ■ Time-base Timer Control Register (TBTC) Figure 10.3-1 Time-base Timer Control Register (TBTC) Address bit15 bit14 0000A9H RESV R/W bit13 bit12 bit11 bit10 bit9 bit8 bit7 bit0 TBIE TBOF TBR TBC1 TBC0 R/W R/W W R/W (TBTC) Initial value 1XX00100B R/W TBC1 TBC0 Interval time selection bit 0 0 212/HCLK (approximately 1.0 ms) 0 1 214/HCLK (approximately 4.1 ms) 1 0 216/HCLK (approximately 16.4 ms) 1 1 219/HCLK (approximately 131 ms) The value during operation of the oscillation clock at 4 MHz is shown in ( ). TBR Time-base timer initializing bit During reading During writing Clears TBOF bit of time-base timer counter. 0 1 TBOF 164 Interrupt request flag bit During reading During writing No overflow of specified bit Clears this bit. 1 Overflow of specified bit No change, no effect on other functions Interrupt request permit bit 0 Prohibits interrupt request output. 1 Permits interrupt request output. RESV : Readable/Writable : Write only : Undefined bit x : Undefined HCLK : Oscillation clock : Initial value No change, no effect on other functions 0 TBIE R/W W "1" is always read and output Reserved bit Always write "1" to this bit. Table 10.3-1 Functions of Bits in Time-base Timer Control Register (TBTC) Bit name Function bit15 RESV: Reserved bit bit14, bit13 Undefined bits • • bit12 TBIE: Interrupt request permit bit This bit permits or prohibits output of interrupt requests to the CPU. • An interrupt request is output if this bit and the interrupt request flag bit (TBOF) are set to "1". TBOF: Interrupt request flag bit This bit is set to "1" when the bit specified by the time-base timer counter overflows. • An interrupt request is output if this bit and the interrupt request permit bit (TBIF) are set to "1". • This bit is cleared by writing "0" but is not changed by writing "1" so that this operation does not affect other functions. Notes: • Clearing of the interrupt request flag bit (TBOF) must be implemented in the state where the time-base timer interrupt is prohibited by the interrupt request permit bit (TBIE) or by the interrupt level mask register (ILM) setting of the processor status (PS). • This bit is cleared to "0" by writing "0", a transition to the main stop mode, a transition to the PLL stop mode, a transition from the sub clock mode to the main clock mode, a transition from the sub clock mode to the PLL clock mode, a transition from the main clock mode to the PLL clock mode, writing "0" to the time-base timer initializing bit (TBR) or a reset. bit10 TBR: Time-base timer initializing bit This bit clears the time-base timer counter. • When "0" is written to this bit, the counter is cleared and the TBOF bit is cleared. This bit is not changed by writing "1" so that this operation does not affect other functions. [Reference] The readout value is always "1". bit9, bit8 TBC1, TBC0: Interval time selection bit This bit specifies the cycle of the interval timer. • The bit for the interval timer in the time-base timer counter is specified. • The interval time can be selected out of four types. bit11 Always write "1" to this bit. Undefined value in reading No effect on write operation 165 CHAPTER 10 TIME-BASE TIMER 10.4 Time-base Timer Interrupt The time-base timer can generate the interrupt request caused by an overflow of the specified bit in the time-base timer counter (interval timer function). ■ Time-base Timer Interrupt When the time-base timer counter counts up using the internal count clock and the bit for the selected interval timer overflows, the interrupt request flag bit (TBOF) of the time-base timer control register (TBTC) is set to "1". In this event, if an interrupt request is permitted because the interrupt request permit bit (TBIE) is set to "1", an interrupt request is generated in the CPU. Clear this interrupt request by writing "0" to the TBOF bit using the interrupt processing routine. Incidentally, TBOF bit is set when the specified bit overflows regardless for the value for the interrupt request permit bit (TBIE). Notes: • Clearing of the interrupt request flag bit (TBOF) in the time-base timer control register (TBTC) must be implemented in the state where the time-base timer interrupt is prohibited by the interrupt request permit bit (TBIE) or by the interrupt level mask register (ILM) setting of the processor status (PS). • If the TBOF bit is set to "1", an interrupt request is generated immediately when the TBIE bit is switched from prohibit (0) to permit (1). • μDMAC cannot be used in the time-base timer. ■ Time-base Timer Interrupt and μDMAC Table 10.4-1 lists time-base timer interrupts and μDMAC. Table 10.4-1 Time-base Timer Interrupt and μDMAC Interrupt level setting register Address of the vector table Interrupt No. #41 Register name Address Low-order High-order Bank ICR15 0000BFH FFFF58H FFFF59H FFFF5AH μDMAC x x: Not used Note: ICR15 is commonly used by the time-base timer interrupt, the watch timer interrupt, and FLASH write. Although interrupt can be used for these three purposes, the interrupt level is the same. 166 10.5 Time-base Timer Operation The time-base timer has the interval timer function as well as the clock supplying function for some peripheral functions. ■ Operation of Interval Timer Function (Time-base Timer) The interval timer function generates interrupt requests at any defined interval times. For its operation as an interval timer, the settings shown in Figure 10.5-1 are required. Figure 10.5-1 Time-base Timer Settings Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 0000A9H TBTC RESV 1 bit8 bit7 TBIE TBOF TBR TBC1 TBC0 0 bit0 (WDTC) 0 : Bits in use : Undefined bits 0 : "0" is set 1 : "1" is set • The time-base timer counter continues counting up in synchronization with the internal count clock (the source clock frequency divided by 2) as long as the clock is oscillating. • When the counter has been cleared, the starts from "0", and an overflow of the bit used for the interval timer sets the interrupt request flag bit (TBOF) to "1". In this event, if the interrupt request output is permitted (TBIE = 1), interrupts are generated at the selected interval times with the clearing time used as a reference time point. • The interval time may become longer than the specified time, e, when the time-base timer was cleared. ■ Timer Function for Oscillation Stabilization Wait Time The time-base timer can also be used as the oscillation clock as well as the timer for the oscillation stabilization wait time of the PLL clock. The oscillation stabilization wait time is the time in which counting starts when the counter is set to "0" (clearing of counter) and continues until an overflow occurs in the bit for the oscillation stabilization wait time. However, during return from the time-base timer mode to the PLL clock mode or main clock mode, the waiting time differs because the time-base timer counter is not cleared and the time count does not start from zero. Table 10.5-1 explains the time-base timer counter clear operation and oscillation stabilization wait time. 167 CHAPTER 10 TIME-BASE TIMER Table 10.5-1 Time-base Timer Counter Clear Operation and Oscillation Stabilization Wait Time. Operation Counter clear TBOF clear Writing "0" to time-base timer initializing bit (TBR) for timebase timer control register (TBTC) Oscillation stabilization wait time − Power-on reset Watchdog reset ✕ Oscillation stabilization wait time of main clock Release of the main stop mode Release of the PLL stop mode Release of the sub stop mode ✕ ✕ Oscillation stabilization wait time of sub clock Switching from main clock mode to PLL clock mode (SCM: transition from 1 to 0) Oscillation stabilization wait time of PLL clock Transition from sub clock mode to main clock mode (SCM: transition from 0 to 1) Oscillation stabilization wait time of main clock Release of time-base timer mode ✕ ✕ − Release of sleep mode ✕ ✕ − : Cleared ✕: Not cleared ■ Clock Supplying Function The time-base timer supplies a clock to the watchdog timer. Clearing of the time-base timer counter affects the operation of the watchdog timer. 168 ■ Operation of Time-base Timer Operations in the following states are shown in Figure 10.5-2: • Where the power-on reset has occurred • Where transition to the sleep mode has occurred during processing for the interval timer function • Where transition to the stop mode has occurred • Where clearing of the counter is requested Transition to the stop mode clears the time-base timer to stop operation. After restoration from the stop mode, the time-base timer starts an up-count of the oscillation stabilization wait time. Figure 10.5-2 Operation of Time-base Timer Counter value 3FFFFH Clearing by transition to stop mode Overflow during oscillation stabilization wait time 00000H Start of CPU operation Power-on reset (option) Interval cycle (TBTC : TBC1, TBC0 = 11B) Clearing of counter (TBTC : TBR = 0) Clearing by the interrupt processing routine TBOF bit TBIE bit Sleep SLP bit (LPMCR register) Release of interval interrupt sleep Stoppage STP bit (LPMCR register) Release of stoppage by external interrupt "11B" is set to the interval time selection bit (TBTC; TBC1, TBC0) in the time-base timer control register (219/HCLK). : Oscillation stabilization wait time HCLK : Oscillation clock 169 CHAPTER 10 TIME-BASE TIMER 10.6 Notes on Using Time-base Timer This section explains notes on using the time-base timer, including the effects of clearing an interrupt request or clearing the time-base timer on peripheral functions. ■ Notes on Using Time-base Timer ● Clearing an interrupt request Clearing the interrupt request flag bit (TBOF) of the time-base timer control register (TBTC) must be implemented in the state where the time-base timer interrupt is masked by the interrupt request permit bit (TBIE) or by the interrupt level mask register (ILM) setting of the processor status (PS). ● Effect of clearing the time-base timer Clearing the time-base timer counter affects the following: • Operations where the interval timer function (interval interrupt) is used by the time-base timer • Operations using the watchdog timer ● Use of the timer for the oscillation stabilization wait time When power is turned on, the oscillation clock is stopped in the main stop mode. In such a case, after the oscillator starts operating, the oscillation stabilization wait time of the oscillation clock must be provided by using as a timing reference the operation clock supplied by the time-base timer. An appropriate oscillation stabilization wait time must be selected depending on the type of oscillator (resonator) connected to the high-speed oscillation pin. See Section "6.5 Oscillation Stabilization Wait Time", for details. ● Caution on using peripheral functions whose operation clock is supplied from the time-base timer In a mode where the main clock stops, the counter is cleared and the time-base timer stops operating. Furthermore, because the clock supplied by the time-base timer is reset to the initial state and is supplied again when the time-base timer counter is cleared, the period of "H" level may become shorter or the period of "L" level may become longer by a maximum of a 1/2 cycle. Although the clock for the watchdog timer is also supplied from the initial state, the watchdog timer operates at normal cycles because the watchdog time counter is cleared at the same time. 170 10.7 Sample Programs of Time-base timer Sample programs for the time-base timer are shown below. ■ Sample Programs of Time-base Timer ● Specifications for processing Repetitively generate an interval interrupt of 212/HCLK (oscillation clock). The interval time in this case is approximately 1.0 ms (when operating at 4 MHz). ● Sample coding ICR12 EQU 0000BCH ; Interrupt control register for time-base timer TBTC EQU 0000A9H ; Time-base timer control register TBOF EQU TBTC:3 ; Interrupt request flag bit ;---------- Main program ------------------------------------------CODE CSEG START: ; : ; Assumption that stack pointer ; (SP), etc., have been initialized AND CCR, #0BFH ; Disabling interrupts MOV I:ICR12, #00H ; Interrupt level 0 (highest) MOV I:TBTC, #10010000B ; Three high-order bits must be fixed ; Permitting interrupts, clearing of TBOF ; Clearing the counter ; Selection for interval time of 212/HCLK MOV ILM, #07H ; Setting ILM in PS to level 7 OR CCR, #40H ; Enabling interrupts LOOP: MOV A,#00H ; Infinite loop MOV A,#01H BRA LOOP ;---------- Interrupt program -------------------------------------WARI: CLR bit BOF ; Clearing the interrupt request flag ; : ; User processing ; : RETI ; Restoration from interrupt CODE ENDS ;---------- Specifying vectors ------------------------------------VECT CSEG ABS=0FFH ORG 0FF6CH ; Specifying the interrupt vector DSL WARI ORG 0FFDCH ; Specifying the reset vector DSL START DB 00H ; Setting to the single-chip mode VECT ENDS END START 171 CHAPTER 10 TIME-BASE TIMER 172 CHAPTER 11 WATCHDOG TIMER This chapter describes the operation and function of the watchdog timer. 11.1 Overview of Watchdog Timer 11.2 Watchdog Timer Control Register (WDTC) 11.3 Watchdog Timer Configuration 11.4 Watchdog Timer Operation 11.5 Notes on Using Watchdog Timer 11.6 Sample Programs of Watchdog Timer 173 CHAPTER 11 WATCHDOG TIMER 11.1 Overview of Watchdog Timer The watchdog timer is a 2-bit counter that uses the output of the time-base timer or the watch timer as the count clock, and if it is not cleared within a certain period of time after startup, this timer resets the CPU. ■ Functions of Watchdog Timer The watchdog timer is a counter used to prevent runaway programs. Once it is started, this timer must be cleared periodically within a certain period of time. If it is not cleared within a certain period of time because a program is running in an infinite loop, it generates a watchdog reset to the CPU. The interval time of the watchdog timer can be specified on the WT1 and WT0 bits in the watchdog timer control register (WDTC), as shown in Table 11.1-1. If the watchdog timer is not cleared, a watchdog reset is generated between the minimum time and the maximum time. Be sure to clear the timer within the minimum time. The output destination of the clock source is set by the watchdog clock selection bit (WTC:WDCS) of the clock timer control register. Table 11.1-1 Interval Time for Watchdog Timer Interval time WT1 WT0 WDCS SCM Number of clock cycles Minimum * Maximum * 0 0 1 1 Approximately 3.58 ms Approximately 4.61 ms (214 ± 211) HCLK cycles 0 1 1 1 Approximately 14.33 ms Approximately 18.43 ms (216 ± 213) HCLK cycles 1 0 1 1 Approximately 57.23 ms Approximately 73.73 ms (218 ± 215) HCLK cycles 1 1 1 1 Approximately 458.75 ms Approximately 589.82 ms (221 ± 218) HCLK cycles 0 0 Approximately 0.457 s Approximately 0.576 s (212 ± 29) SCLK cycles 0 1 Approximately 3.584 s Approximately 4.608 s (215 ± 212) SCLK cycles 1 0 Approximately 7.168 s Approximately 9.216 s (216 ± 213) SCLK cycles 1 1 Approximately 14.336 s Approximately 18.432 s (217 ± 214) SCLK cycles Combination other than the above *: Values during operation of the oscillation clock (HCLK) at 4 MHz and the sub clock (SCLK) at 32 kHz frequency divided by 4 (= 8 kHz) The maximum and minimum watchdog timer interval times and the number of the oscillation clock cycles depend on the timing of the clear operation. The interval time is 3.5 to 4.5 times as large as the cycle of the count clock (clock supplied by the time-base timer). For the watchdog timer interval times, see Section "11.4 Watchdog Timer Operation". 174 Note: The watchdog counter is composed of a 2-bit counter to count the carry signals of the time-base timer. Therefore, if the time-base timer counter has been cleared, the time until the occurrence of watchdog reset may become longer than the specified time. To use the sub clock as a machine clock, please select the output of the clock timer by setting the watchdog timer clock source selection bit (WDCS) of the clock timer control register (WTC) to "0". 175 CHAPTER 11 WATCHDOG TIMER 11.2 Watchdog Timer Control Register (WDTC) The watchdog timer control register (WDTC) is used for the start and clearing of the watchdog timer and the display of reset causes. ■ Watchdog Timer Control Register (WDTC) Figure 11.2-1 shows the configuration of the watchdog timer control register (WDTC), and Table 11.2-1 explains the function of each bit in the WDTC register. Figure 11.2-1 Watchdog Timer Control Register (WDTC) Address 0000A8H bit15 bit8 (TBTC) bit7 bit6 PONR ⎯ R bit5 bit4 bit3 bit2 bit1 WRST ERST SRST WTE WT1 R R R W bit0 Initial value WT0 XXXXX111B W W Interval time selection bit (at HCLK: 4 MHz; SCLK: 32 kHz) Interval time Number of oscillation & SCM clock cycles Minimum Maximum WT1 WT0 WDCS 0 0 1 Approximately 3.58 ms Approximately 4.61 ms (214 ± 211) HCLK cycles 0 1 1 Approximately 14.33 ms Approximately 18.3 ms (216 ± 213) HCLK cycles 1 0 1 Approximately 57.23 ms Approximately 73.73 ms (218 ± 215) HCLK cycles 0 1 1 Approximately 458.75 ms Approximately 589.82 ms (221 ± 218) HCLK cycles 0 0 Approximately 0.576 s (212 ± 29) SCLK cycles 1 0 0 Approximately 0.457 s 0 Approximately 3.584 s Approximately 4.608 s (215 ± 212) SCLK cycles 1 0 0 Approximately 7.168 s Approximately 9.216 s (216 ± 213) SCLK cycles 1 1 0 Approximately 14.336 s Approximately 18.432 s (217 ± 214) SCLK cycles HCLK: Oscillation clock SCLK: Sub clock Watchdog control bit WTE 0 Starts the watchdog timer (at first write event after reset) Clears the watchdog timer (at second write event after reset) 1 No operation ⎯ Reading and writing has no effect on operation Reset cause bits Reset cause PONR WRST ERST SRST R W x * : Read only : Write only : Undefined : Undefined bit : The previous state is held. : Default value 1 X X X Power on * 1 * * Watchdog timer * * 1 * External pin (RST = "L" input) * * * 1 RST bit (software reset) The interval time is 3.5 to 4.5 times as large as the count clock (output value of the time-base timer) cycle. See Section "11.4 Watchdog Timer Operation", for details. 176 Table 11.2-1 Function of Bits in Watchdog Timer Control Register (WDTC) Bit name Function bit7, bit5, bit4, bit3 PONR, WRST, ERST, SRST: Reset cause bits These are read-only bits that indicate reset causes. Each of these bits is set to "1" when the corresponding reset cause has occurred. • All of these bits are cleared to "0" after reading of the WDTC register. • When power is turned on, the contents of bits other than the PONR bit are not assured. Therefore, if the PONR bit is set to "1", ignore the contents of other bits. bit6 Undefined When read: When written: WTE: Watchdog control bit This is a bit for starting or clearing the watchdog timer. • When "0" is written to this bit, the watchdog timer is started (at the first write event after a reset) or the 2-bit counter is cleared (at the second and succeeding write events after a reset). • Writing "1" does not affect operation. bit2 • • bit1, bit0 WT1, WT0: Interval time selection bits • • • The bits contain indeterminate values. The bits have no effect. These are the bits for selecting the interval time of the watchdog timer. The interval time varies, as shown in Figure 11.2-1, between the case where the sub clock mode is selected as the clock mode (the sub clock display bit (SCM) of the clock selection register (CKSCR) is "0") or the clock source of the watchdog timer is set to the watch timer by the watch timer control register (WTC) (the watchdog timer clock source selection bit (WDCS) is set to "0") and the case where the main clock mode or PLL clock mode is selected as the clock mode while the WDCS bit of WTC is set to "1". Only data that has been defined before the start of the watchdog timer are effective. Any data that is written after the start of the watchdog timer is ignored These bits are write-only. 177 CHAPTER 11 WATCHDOG TIMER 11.3 Watchdog Timer Configuration The watchdog timer is composed of the following five blocks: • Count clock selector • Watchdog counter (2-bit counter) • Watchdog reset generation circuit • Counter clear control circuit • Watchdog timer control register (WDTC) ■ Block Diagram of Watchdog Timer Figure 11.3-1 is a block diagram of the watchdog timer. Figure 11.3-1 Block Diagram of Watchdog Timer Watchdog timer control register (WDTC) PONR Reserved WRST ERST SRST WTE WT1 WT0 WDCS bit in watch timer control register (WTC) SCM bit in clock selection register (CKSCR) Watch mode start Time-base timer mode start Sleep mode start Hold state start Watchdog timer Stop mode start 2 CLR and start Counter clear control circuit Count clock selector 2-bit counter Overflow CLR Watchdog reset generation circuit To internal reset generation circuit CLR 4 Clear 4 (Time-base timer counter) HCLK frequency divided by 2 × 21 × 22 × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 × 216 × 217 × 218 SCLK × 21 × 22 × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 × 216 × 217 × 218 HCLK: Oscillation clock SCLK: Sub clock ● Count clock selector This circuit selects the count clock of the watchdog timer from among four types of time-base timer output and four types of watch timer output. This selection determines the time for generating a watchdog reset. ● Watchdog counter (2-bit counter) This is a 2-bit up-counter that uses time-base timer output as the count clock. ● Watchdog reset generation circuit This circuit generates a reset signal for an overflow of the watchdog counter. 178 ● Counter clear control circuit This circuit controls the clearing of the watchdog counter and the start and stop of the counter. ● Watchdog timer control register (WDTC) This register is used for the start and clearing of the watchdog timer, and holding of the reset cause. 179 CHAPTER 11 WATCHDOG TIMER 11.4 Watchdog Timer Operation The watchdog timer generates a watchdog reset for an overflow of the watchdog counter. ■ Operation of Watchdog Timer Figure 11.4-1 shows the settings required for operation of the watchdog timer. Figure 11.4-1 Watchdog Timer Settings Address bit15 0000A8H WDTC bit8 (TBTC) bit7 bit6 bit5 bit4 bit3 bit2 bit1 PONR Reserved WRST ERST SRST WTE WT1 bit0 WT0 0 : Bits being used 0 : Set to "0" ● Starting the watchdog timer • After a reset, the watchdog timer starts operation when the first "0" is written to the watchdog control bit (WTE) in the watchdog timer control register (WDTC). The interval time is then specified at the same time on the interval time selection bits (WT1, WT0) in the WDTC register. ● Clearing of the watchdog timer • The 2-bit counter of the watchdog timer is cleared when the second or subsequent "0" is written to the WTE bit. If the counter is not cleared within the interval time, the counter overflows to generate a watchdog reset. • The watchdog counter is cleared when a reset occurs and by a transition to the sleep mode, stop mode, time-base timer mode, or timer mode. Note: When a transition to the time-base timer mode or watch mode occurs, the watchdog counter is cleared once, but be careful because the watchdog counter does not stop after being cleared. ● Interval time of the watchdog timer Figure 11.4-2 shows the relationship between the clear timing and interval time of the watchdog timer. The interval time varies depending on the timing when the watchdog timer is cleared, which takes 3.5 to 4.5 times as much time as the count clock cycle. ● Check of reset causes After a reset, the reset cause can be found by checking the reset cause bits (PONR, WRST, ERST, and SRST) in the WDTC register. 180 Figure 11.4-2 Clearing Timing and Interval Time of Watchdog Timer [Block diagram of watchdog timer] 2-bit counter Clock selector a WTE bit frequency divide-by-2 circuit Count permit output circuit b frequency divide-by-2 circuit c d Reset circuit Reset signal Count permit and clear [Minimum interval time] The WTE bit is cleared immediately before the count clock starts. Start of count Counter clearing Count clock a frequency divide-by-2 value b frequency divide-by-2 value c Count permit Reset signal d 7 × (count-clock-cycles/2) WTE bit clearing Occurrence of watchdog reset [Maximum interval time] The WTE bit is cleared immediately after the count clock starts. Start of count Counter clearing Count clock a frequency divide-by-2 value b frequency divide-by-2 value c Count permit Reset signal 9 × (count-clock-cycles/2) WTE bit clearing Occurrence of watchdog reset 181 CHAPTER 11 WATCHDOG TIMER 11.5 Notes on Using Watchdog Timer This section explains notes on using the watchdog timer. ■ Notes on Using Watchdog Timer ● Stopping the watchdog timer The watchdog timer stops by all reset causes. ● Interval time Because the interval time uses the carry signals of the time-base timer as the count clock, the interval time of the watchdog timer may become longer than the specified time when the time-base timer is cleared. The time-base timer is also cleared by writing "0" to the TBR bit in the time-base timer control register (TBTC), transition from main clock mode to PLL clock mode, transition from sub clock mode to main clock mode, and transition from sub clock mode to PLL clock mode. ● Selection of the interval time The interval time can be specified when the watchdog timer is started. Any data written after the start of the watchdog timer is ignored. ● Caution on creating programs When creating a program that clears the watchdog timer repetitively in the main loop, the main loop processing time, including interrupt processing, must be less than the minimum interval time of the watchdog timer. ● Caution at sub clock mode Please select the output of the clock timer by setting the watchdog timer clock source selection bit (WDCS) of the clock timer control register (WTC) to "0" on sub clock mode. 182 11.6 Sample Programs of Watchdog Timer Sample programs for the watchdog timer are shown below. ■ Sample Programs for Watchdog Timer ● Specifications for processing • Clears the watchdog timer once per loop of the main program. • The main loop must complete a circuit within the minimum interval time of the watchdog timer. ● Sample coding WDTC EQU 0000A8H ; Watchdog timer control register WTE EQU WDTC:2 ; Watchdog control bit ;---------- Main program -----------------------------------------------------CODE CSEG START: ; : ; Assumption that the stack pointer (SP), ; etc., have been initialized. WDG_START: MOV WDTC, #00000011B ; Start of watchdog timer Selection of ;interval time of 221 ± 218 cycles ;---------- Main loop --------------------------------------------------------MAIN: CLRB I:WTE ; Clearing of watchdog timer ; : ; Periodic 2-bit clearing ; User processing ; : JMP MAIN ; Loop time shorter than interval ; time of watchdog timer CODE ENDS ;---------- Specifying vectors -----------------------------------------------VECT CSEG ABS=0FFH ORG 0FFDCH ; Specifying the reset vector DSL START DB 00H ; Setting to the single-chip mode VECT ENDS END START 183 CHAPTER 11 WATCHDOG TIMER 184 CHAPTER 12 WATCH TIMER This chapter has an overview of the watch timer, describes the configuration and functions of the register, and explains the operation of the watch timer. 12.1 Overview of Watch Timer 12.2 Watch Timer Configuration 12.3 Watch Timer Control Register (WTC) 12.4 Watch Timer Operation 185 CHAPTER 12 WATCH TIMER 12.1 Overview of Watch Timer The watch timer is a 15-bit timer using the sub clock. This timer can generate interval interrupts. Furthermore, depending on the setting, this timer can be used as the clock source for the watchdog timer. ■ Functions of Watch Timer The watch timer is composed of a 15-bit timer and a circuit to control interval interrupts. The watch timer uses the sub clock regardless of the PLL clock selection bit (MCS) or the sub clock selection bit (SCS) in the clock selection register (CKSCR). Table 12.1-1 lists the interval times of the watch timer. Table 12.1-1 Interval Times of Watch Timer WTC2 WTC1 WTC0 Interval time * 0 0 0 31.25 ms 0 0 1 62.5 ms 0 1 0 125 ms 0 1 1 250 ms 1 0 0 500 ms 1 0 1 1.000 s 1 1 0 2.000 s 1 1 1 Setting is prohibited *: Sub clock: 32 kHz frequency divided by 4 (= 8 kHz) 186 12.2 Watch Timer Configuration The watch timer is composed of four blocks that include the following: • Interval selector • Watch counter • Watch timer interrupt generating circuit • Watch timer control register (WTC) ■ Block Diagram of Watch Timer Figure 12.2-1 is a block diagram of the watch timer. Figure 12.2-1 Block Diagram of Watch Timer Watch timer control register (WTC) WDCS SCE WTIE WTOF Watch counter Sub clock 212 213 214 WTR Clear 28 29 210 211 212 213 214 215 WTC2 WTC1 WTC0 Interval selector Interrupt generating circuit Interrupt of watch timer To watchdog timer ● Watch counter This is a 15-bit up-counter that uses the sub clock as the clock source. ● Interval selector This selector selects watch timer interrupt intervals. ● Interrupt generating circuit This circuit generates the interval interrupts of the watch timer. ● Watch timer control register (WTC) This register controls operation of the watch timer and watch timer interrupt, and it specifies the clock source for the watchdog timer. 187 CHAPTER 12 WATCH TIMER 12.3 Watch Timer Control Register (WTC) The watch timer control register (WTC) controls operation of the watch timer. This register also controls the time of interval interrupts. ■ Configuration of Watch Timer Control Register (WTC) Figure 12.3-1 shows the configuration of the watch timer control register (WTC), and Table 12.3-1 lists the functions of bits in the watch timer control register (WTC). Figure 12.3-1 Configuration of Watch Timer Control Register (WTC) Address bit15 0000AAH bit8 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0 R/W R R/W R/W R/W R/W R/W WTC2 WTC1 WTC0 Initial value 10001000B R/W Watch timer interval selection bit Interval time (sub clock 32 kHz) 0 0 0 0 0 1 31.25 ms 62.5 ms 0 1 0 125 ms 0 1 1 0 1 0 250 ms 500 ms 1 0 1 1 1 0 1.000 s 2.000 s 1 1 1 Setting is prohibited WTR 0 1 WTOF 0 1 Watch counter clear bit All bits of the watch timer counter are cleared to "0". Nothing happens. This bit is always read during reading. Watch timer interrupt request flag bit No interrupt request is generated. An interrupt request is generated. Watch timer interval interrupt permit bit WTIE 0 Interrupt prohibited. 1 Interrupt permitted. SCE 0 1 R/W : Readable/Writable R : Read only : Default value 188 Bit indicating end of waiting time to stable oscillation of sub clock The waiting time to stable oscillation is ongoing. The waiting time to stable oscillation has ended. Watchdog timer clock source selection bit WDCS 0 Select the clock for the watch timer 1 Select the clock for the time-base timer. Table 12.3-1 Functions of Bits in Watch Timer Control Register (WTC) Bit name Function WDCS: Watchdog timer clock source selection bit This bit is for selecting the clock source for the watchdog timer. • If set to "0", this bit specifies clock for the watch timer; if set to "1", it specifies clock for the time-base timer. If the mode transits to the sub clock mode with setting to "1", the watchdog timer stops. • This bit is initialized to "1" by a reset. bit6 SCE: Bit indicating end of oscillation stabilization wait time for sub clock This bit indicates that the oscillation stabilization wait time of the sub clock has ended. • If set to "0", this bit indicates that the oscillation stabilization wait time of the sub clock is ongoing. • The oscillation stabilization wait time of the sub clock is fixed at 214 cycles of the sub clock. • This bit is initialized to "0" by a power-on reset or stoppage. bit5 WTIE: Watch timer interval interrupt permit bit This bit is for permitting interval interrupts by the watch timer. • If set to "1", this bit permits interrupts; if set to "0", it prohibits interrupts. • This bit is initialized to "0" by a reset bit4 WTOF: Watch timer interrupt request flag bit This bit indicates that an interrupt request by the watch timer has been issued. • If this bit is set to "1" and the WTIE bit is set to "1", an interrupt request has been issued. • This bit is set to "1" at each interval time specified by the WTC2 to WTC0 bits. • This bit is cleared to "0" by writing "0", a transition to the stop mode, and a reset. • Writing "1" to this bit has no effect. bit3 WTR: Watch counter clear bit This bit is for clearing all bits to "0" in the watch timer counter. • Writing "0" to this bit clears the watch timer counter to "0". • Writing "1" to this bit has no effect. • During reading, "1" is always read and output. bit2, bit1, bit0 WTC2, WTC1, WTC0: Watch timer interval selection bits These bits specify the interval of the watch timer. • These bits are initialized to "000B" by a reset. • When changing the bit settings, clear the WTOF bit at the same time. bit7 189 CHAPTER 12 WATCH TIMER 12.4 Watch Timer Operation The watch timer functions as a clock source for the watchdog timer, timer for the oscillation stabilization wait time of the sub clock, and interval timer to generate interrupts at fixed intervals. ■ Watch Counter The watch counter is composed of a 15-bit counter to count the sub clock, and it always continues counting as long as the sub clock is input. ● Clearing the watch counter The operation of clearing the watch counter is affected by a power-on reset, a transition to the stop mode, and writing "0" to the watch counter clear bit (WTR) in the watch timer control register (WTC). Notes: • Clearing the watch counter affects the watchdog timer and interval interrupts that use watch timer output. • To clear the watch timer by writing "0" to the WTR bit in the watch timer control register (WTC), set the WTIE bit to "0" and set the watch timer to interrupt inhibited state. Before permitting an interrupt, clear the interrupt request issued by writing "0" to the WTOF flag. ■ Interval Interrupt Function of Watch Timer This function generates interrupts at fixed intervals by using the carry signals of the watch counter. ● Specification of the interval time The interval time can be specified with the WTC2, WTC1, and WTC0 bits in the WTC register. ● Generation of watch timer interrupts The watch timer interrupt request flag bit (WTOF) is set at each interval time specified by the WTC2 to 0 bits. Consequently, when interrupts are permitted by setting the watch timer interval interrupt permit bit (WTIE) to "1", a watch timer interrupt occurs. The timing, when the WTOF bit is set, depends on the timing as a time reference when the watch timer was cleared for the last time. Because the watch timer is used as the timer for the oscillation stabilization wait time of the sub clock after a transition to the stop mode, the WTOF bit is simultaneously cleared at the transition to this mode. 190 ■ Clock Source for Watchdog Timer Specifying Function The clock source for the watchdog timer can be specified with the watchdog timer clock source selection bit (WDCS) of the WTC register. If the sub clock is used as the machine clock, set the WDCS bit to "0" and select the output of the watch timer. If the mode transits to the sub clock mode with the WDCS bit setting to "1", the watchdog timer stops. ■ Sub Clock Oscillation Stabilization Wait Time Function For a power-on reset, restoration from the stop mode or the watch timer functions as the timer for the oscillation stabilization wait time of the sub clock. The oscillation stabilization wait time of the sub clock is fixed at 214 cycles of the sub clock. 191 CHAPTER 12 WATCH TIMER 192 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER This chapter has an overview of the 16-bit input/output timer, describes the configuration and function of its register, and explains its operation. 13.1 Overview of 16-bit Input/Output Timer 13.2 Configuration of 16-bit Input/Output Timer 13.3 Configuration and Function of 16-bit Input/Output Timer Register 13.4 Interrupt of 16-bit Input/Output Timer 13.5 16-bit Input/Output Timer Operation 13.6 Program Example of 16-bit Input/Output Timer 193 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER 13.1 Overview of 16-bit Input/Output Timer The 16-bit input/output timer consists of one module of a 16-bit free-run timer, four modules of output compare, and two modules of input capture. This function provides an output of six independent waveforms based on the 16-bit free-run time, enabling measurement of input pulse widths and external clock intervals. ■ Configuration and Function of 16-bit Input/Output Timer The 16-bit input/output timer consists of a free-run timer, output compare, and input capture, whose functions are explained below. ● Free-run timer (x 1) Free-run timer consists of 16-bit up-counter, control register, and prescaler. The output value of the freerun timer uses as a base time (base timer) of input capture and output compare. Clock for the count operation can be selected from 8 types of clocks. • Internal clock: 8 (φ, φ/2, φ/4, φ/8, φ/16, φ/32, φ/64, φ/128) • Either internal clock or external clock (FRCK) can be selected as a base machine clock. Interrupt occurs in the counter overflow event or compare match event with compare clear register (compare match requires the mode setting). Counter can be initialized by reset event, clear event by software or compare match event with compare clear register 0. ● Output compare (x 4) Output compare consists of four 16-bit compare registers, a compare output latch, and a control register. If a free-run timer and compare register have matching values, the output level is reversed with a generation of an interrupt. • Four compare registers can operate independently. Each compare register has a corresponding output pin and interrupt flag. • Two compare registers are used as a pair to control the output pin. • Sets the output pin to its initial value. • Interrupt is generated by compare match. ● Input capture (x 2) Input capture consists of two independent external input pins and corresponding capture registers, control registers, and edge detection circuit. If any edge of a signal input from the external input pin is detected, the free-run timer value is retained in the capture register and, at the same time, an interrupt is generated. • The edge of an external input signal can be selected from its rising edge, falling edge or both edges. • The two input capture operate independently. Interrupts occur at the valid edge of external input signals. Input capture can start DMA by the interrupt. 194 13.2 Configuration of 16-bit Input/Output Timer The 16-bit input/output timer consists of three modules for the free-run timer, output compare, and input capture. ■ Block Diagram Figure 13.2-1 is a block diagram of the 16-bit input/output timer. Figure 13.2-1 Block Diagram of 16-bit Input/Output Timer To each block Control logic Interrupt Free-run timer 16-bit timer Clear Output compare 0 Compare register 0 TQ OUT0 TQ OUT1 TQ OUT2 TQ OUT3 Bus Output compare 1 Compare register 1 Output compare 2 Compare register 2 Output compare 3 Compare register 3 Input capture 0 Capture register 0 Edge selection IN0 Edge selection IN1 Input capture 1 Capture register 1 195 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ■ Block Diagram of Free-run Timer Figure 13.2-2 is a block diagram of the free-run timer. Figure 13.2-2 Block Diagram of Free-run Timer φ Interrupt request Prescaler IVF IVF STOP MODE SCLR CLK2 CLK1 CLK0 Bus Clock Free-run timer Compare clear register Compare circuit MSI2 to MSI0 Counter value output T15 to T00 ICLR ICRE Interrupt request ■ Block Diagram of Output Compare Figure 13.2-3 is a block diagram of output compare. Figure 13.2-3 Block Diagram of Output Compare 16-bit timer counter value (T15 to T00) Compare control TQ OTE0 OUT0 (2) OTE1 OUT1 (3) Bus Compare register 0 (2) 16-bit timer counter value (T15 to T00) CMOD TQ Compare control Compare register 1 (3) ICP1 ICP0 ICE0 ICE0 Control section Control blocks 196 Compare 1 (3) interrupt Compare 0 (2) interrupt ■ Block Diagram of Input Capture Figure 13.2-4 is a block diagram of input capture. Figure 13.2-4 Block Diagram of Input Capture Edge detect Capture data register 0 EG11 EG10 EG01 EG00 Bus 16-bit timer counter value (T15 to T00) IN0 Edge detect Capture data register 1 ICP1 ICP0 ICE1 IN1 ICE0 Interrupt Interrupt ■ Pin Related to 16-bit Input/Output Timer The pin related to the 16-bit input/output timer has the IN0/IN1 and OUT0/OUT1/OUT2/OUT3 pins. The IN0/IN1 pins function as the general-purpose I/O port (P96/IN0, P97/IN1) and input capture input pin. The OUT0/OUT1/OUT2/OUT3 pins function as the general-purpose I/O port (PA0/OUT0, PA1/OUT1, PA2/ OUT2, PA3/OUT3) and output compare output pin. ● Setting when using as IN0/IN1 pins When using as the IN0/IN1 pins, the P96/IN0 and P97/IN1 pins should be set the port direction register to input port (DDR9 bit7, bit6→"0"). ● Setting when using as OUT0/OUT1/OUT2/OUT3 pins When using the OUT0/OUT1/OUT2/OUT3 pins as output, be sure to set the control register (OCS01/ OCS23) to the output compare pin output (OCS01/OCS23 bit10, bit11→"1"). ● Setting when using as FRCK pin When using as the FRCK pin, the P93/FRCK pin should be set the port direction register to input port (DDR9 bit3→"0"). 197 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ■ Block Diagram of Pin Related to 16-bit Input/Output Timer Figure 13.2-5 Block Diagram of Pin Related to 16-bit Input/Output Timer Peripheral function input (IN0/IN1) Port data register (PDR) Peripheral function output (OUT0 to OUT3) Peripheral function output enable Open drain control signal (P46/P47 only) Internal data bus PDR Read Output latch P-ch Pin PDR Write Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Standby control (SPL=1) Standby control:Stop mode (SPL=1), time-base timer mode (SPL=1), watch mode (SPL=1) 198 13.3 Configuration and Function of 16-bit Input/Output Timer Register The 16-bit input/output timer registers are classified as follows: • Free-run timer • Output compare • Input capture This section shows the configuration and explains the functions of these registers. ■ Configuration of 16-bit Input/Output Timer Register The 16-bit input/output timer has the register configuration listed below. ● Free-run timer Figure 13.3-1 Register Configuration of Free-run Timer bit15 bit0 000066H/000067H CPCLR 000062H/000063H TCDT Timer counter data register 000064H/000065H TCCS Timer counter control status register Compare clear register ● Output compare Figure 13.3-2 Register Configuration of Output Compare 00004AH,00004CH,00004EH 000050H,00004BH,00004DH, 00004FH,000051H 000056H,000058H 000057H,000059H bit15 bit0 OCCP0 to OCCP3 OCS1/OCS3 Output compare register OCS0/OCS2 Output compare control register ● Input capture Figure 13.3-3 Register Configuration of Input Capture 00005CH,00005EH 00005DH,00005FH 000060H bit15 bit0 IPCP0, IPCP1 Input capture register ICS01 Input capture control status register 199 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER 13.3.1 Free-run timer This section shows the configuration and explains the functions of free-run timer registers. ■ List of Free-run Timer Registers Figure 13.3-4 shows a list of the free-run timer registers. Figure 13.3-4 List of Free-run Timer Registers bit 15 000067H CL15 (R/W) bit 7 000066H CL07 (R/W) bit 15 000063H T15 (R/W) bit 7 000062H T07 (R/W) bit 15 000065H ECKE (R/W) bit 7 000064H IVF (R/W) 200 14 CL14 (R/W) 6 CL06 (R/W) 14 T14 (R/W) 6 T06 (R/W) 14 (R/W) 6 IVFE (R/W) 13 12 11 CL13 CL12 CL11 (R/W) (R/W) (R/W) 5 4 3 CL05 CL04 CL03 (R/W) (R/W) (R/W) 13 12 11 T13 T12 T11 (R/W) (R/W) (R/W) 5 4 3 T05 T04 T03 (R/W) (R/W) (R/W) 13 12 11 MSI2 MSI1 (R/W) (R/W) (R/W) 5 4 3 STOPMODE SCLR (R/W) (R/W) (R/W) 10 CL10 (R/W) 2 CL02 (R/W) 10 T10 (R/W) 2 T02 (R/W) 10 MSI0 (R/W) 2 CLK2 (R/W) 9 CL09 (R/W) 1 CL01 (R/W) 9 T09 (R/W) 1 T01 (R/W) 9 ICLR (R/W) 1 CLK1 (R/W) 8 CL08 (R/W) 0 CL00 (R/W) 8 T08 (R/W) 0 T00 (R/W) 8 ICRE (R/W) 0 CLK0 (R/W) CPCLR Compare clear register Initial value XXXXXXXXB CPCLR Compare clear register Initial value XXXXXXXXB TCDT Timer counter data register Initial value 00000000B TCDT Timer counter data register Initial value 00000000B TCCS Timer counter control/status register Initial value 0 - - 00000B TCCS Timer counter control/status register Initial value 00000000B ■ Compare Clear Register (CPCLR) Figure 13.3-5 shows the bit configuration of the compare clear register (CPCLR). Figure 13.3-5 Bit Configuration of the Compare Clear Register (CPCLR) bit 15 000067H CL15 (R/W) bit 7 000066H CL07 (R/W) 14 CL14 (R/W) 6 CL06 (R/W) 13 12 CL13 CL12 (R/W) (R/W) 5 4 CL05 CL04 (R/W) (R/W) 11 CL11 (R/W) 3 CL03 (R/W) 10 CL10 (R/W) 2 CL02 (R/W) 9 CL09 (R/W) 1 CL01 (R/W) 8 CL08 (R/W) 0 CL00 (R/W) CPCLR Compare clear register Initial value XXXXXXXXB CPCLR Compare clear register Initial value XXXXXXXXB The compare clear register (CPCLR) is a compare register used to make a comparison with the 16-bit freerun timer. An initial value of a register is undefined. Therefore, set the initial value, then allow the interrupt operation. This register requires word access. When the MODE bit of the timer counter control status register (TCCS) is set to "1", the free-run timer value initializes to "0000H" at matching this register value and the value of the free-run timer. When this register value matches the value of the free-run timer, a compare clear interrupt flag is set. When the compare interrupt flag is set to "1", an interrupt request issues to the CPU at allowing the interrupt operation. ■ Timer Counter Data Register (TCDT) Timer counter data register (TCDT) has the bit configuration shown below. Figure 13.3-6 Bit Configuration of Timer Counter Data Register (TCDT) bit 15 000063H T15 (R/W) bit 7 000062H T07 (R/W) 14 T14 (R/W) 6 T06 (R/W) 13 12 T13 T12 (R/W) (R/W) 5 4 T05 T04 (R/W) (R/W) 11 T11 (R/W) 3 T03 (R/W) 10 T10 (R/W) 2 T02 (R/W) 9 T09 (R/W) 1 T01 (R/W) 8 T08 (R/W) 0 T00 (R/W) TCDT Timer counter data register Initial value 00000000B TCDT Timer counter data register Initial value 00000000B The timer counter data register (TCDT) is a 16-bit up counter and is used to read the value of the free-run timer counter. The counter value is cleared to "0000" by a reset. Writing to this register must be performed in the stopped (STOP = 1) state, and the written value defines the timer value. This register requires word access. The free-run timer is initialized with the following causes: • Reset • Clear bit (SCLR) of timer counter control status register (TCCS) • Matching between the compare clear register (CPCLR) of output compare and timer counter value (TCCS: MODE = 1) (requiring mode setting). 201 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ■ Timer Counter Control Status Register (TCCS) Timer counter control status register (TCCS) has the bit configuration shown below. Figure 13.3-7 Bit Configuration of Timer Counter Control Status Register (TCCS) bit 15 14 13 12 000065H ECKE MSI2 (R/W) (R/W) (R/W) (R/W) bit 7 6 5 4 000064H IVF IVFE STOP MODE (R/W) (R/W) (R/W) (R/W) 11 MSI1 (R/W) 3 SCLR (R/W) 10 MSI0 (R/W) 2 CLK2 (R/W) 9 ICLR (R/W) 1 CLK1 (R/W) 8 ICRE (R/W) 0 CLK0 (R/W) TCCS Timer counter control status register Initial value 0--00000B TCCS Timer counter control status register Initial value 00000000B Timer counter control status register (TCCS) consists of bits that have the functions explained below. [bit15] ECKE This bit is used to select whether the count clock source of the free-run timer is internal or external. Since the clock is changed soon after being written to this bit, change the bit setting when output compare and input capture are in the stopped state. 0 Internal clock source is selected (initial value) 1 Clock inputted by external pin (FRCK) is selected. [bit14, bit13] Unused bits These bits are not used. [bit12, bit11, bit10] MSI2, MSI1, MSI0 These bits specify the count with which a compare clear interrupt is masked. It consists of 3-bit reload counter that reloads the count value every time the counter value reaches "000B". During writing to this register, the count value is also loaded, where mask count = specified count (e.g., set to "010B" when masked twice and the third time is interrupted). However, if "000B" is set, no interrupt cause is masked. [bit9] ICLR This bit is the interrupt request flag for compare clear. If the compare clear register and free-run timer are found to have matching values by compare result, this bit is set to "1". If the interrupt request permit bit (bit8: ICRE) is set, an interrupt occurs. This bit is cleared by writing "0". Writing "1" has no effect. An instruction of the read-modify-write type always reads "1". 0 No interrupt request issued (initial value) 1 Interrupt request issued [bit8] ICRE This bit is the interrupt permit bit for compare clear. If this bit is set to "1" and the interrupt flag (bit9: ICLR) is set to "1", then an interrupt occurs. 202 0 Interrupt prohibited (initial value) 1 Interrupt permitted [bit7] IVF This bit is the interrupt request flag of the free-run timer. If the free-run timer causes an overflow or mode setting results in a match between the compare clear register and compare results of free-run timer, then the IVF bit is set to "1". If the interrupt request permit bit (bit5: IVFE) is set, an interrupt occurs. This bit is cleared by setting "0". Setting "1" has no effect. An instruction of the read-modifywrite type reads "1". 0 No interrupt request used (initial value) 1 Interrupt request used [bit6] IVFE This bit is the interrupt permit bit for the free-run timer. If this bit is set to "1" when the write flag (bit5: IVF) is set to "1", an interrupt occurs. 0 Interrupt prohibit (initial value) 1 Interrupt permit [bit5] STOP This bit is set to enable or disable the counting by the free-run timer. If this bit is set to "1", the timer stops counting, and if it is set to "0", the timer starts counting. 0 Count permit (operation) (initial value) 1 Count prohibit (stop) If the free-run timer stops counting, the output compare operation also stops. [bit4] MODE This bit specifies the initialization conditions of the free-run timer. If set to "0", the reset and clear bit (bit3: SCLR) initialize the counter value. If set to "1", in addition to the reset and clear bit (bit3: SCLR), matching the compare clear register (CPCLR) value with the free-run timer, initializes the counter value. 0 Initialized by reset and clear bit (initial value) 1 Initialized by reset, clear bit, and compare clear register The counter value initialization occurs at the point the counter value changes. 203 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER [bit3] SCLR This bit is for initializing the value of the free-run timer in operation to "0000B". Writing "1" initializes the counter value to "0000B". Writing "0" has no effect. The read value is always "0". The counter value initialization occurs synchronizing with the counter value change point. 0 No effect (initial value) 1 Initializes the counter value to "0000B" If it is initialized at the time of stopping the timer, write "0000B" to the data register. Note: Counter is not initialized if "0" is written to this bit before next count clock after writing "1". [bit2, bit1, bit0] CLK2, CLK1, CLK0 These bits are used to select the count clock of the free-run timer. Since the clock changes after this bit is written, change the bit setting when output compare and input capture are in the stopped state. CLK2 CLK1 CLK0 Count clock φ = 20MHz φ = 16MHz φ = 8MHz φ = 4MHz φ = 1MHz 0 0 0 φ 50 ns 62.5 ns 0.125 μs 0.25 μs 1.0 μs 0 0 1 φ/2 100 ns 0.125 μs 0.25 μs 0.5 μs 2.0 μs 0 1 0 φ/4 0.2 μs 0.25 μs 0.5 μs 1.0 μs 4.0 μs 0 1 1 φ/8 0.4 μs 0.5 μs 1.0 μs 2.0 μs 8.0 μs 1 0 0 φ/16 0.8 μs 1.0 μs 2.0 μs 4.0 μs 16.0 μs 1 0 1 φ/32 1.6 μs 2.0 μs 4.0 μs 8.0 μs 32.0 μs 1 1 0 φ/64 3.2 μs 4.0 μs 8.0 μs 16.0 μs 64.0 μs 1 1 1 φ/128 6.4 μs 8.0 μs 16.0 μs 32.0 μs 128.0 μs 204 13.3.2 Output compare This section shows the configuration and explains the functions of registers for output compare. ■ List of Output Compare Registers Figure 13.3-8 shows a list of the registers for output compare. Figure 13.3-8 Registers of Output Compare 00004BH bit 15 14 13 12 11 10 9 8 OCCP0 to OCCP3 00004DH C15 C14 C13 C12 C11 C10 C09 C08 Output compare register 00004FH 000051H (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value 00000000B 00004AH bit 7 6 5 4 3 2 1 0 OCCP0 to OCCP3 00004CH C07 C06 C05 C04 C03 C02 C01 C00 Output compare register 00004EH 000050H (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value 00000000B 000057H 000059H bit 15 (-) 14 (-) 13 12 11 10 9 8 OCS01/23 - CMOD OTE1 OTE0 OTD1 OTD0 Output compare control register (-) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value - - -00000B 000056H 000058H bit 7 6 5 4 ICP1 ICP0 ICE1 ICE0 (R/W) (R/W) (R/W) (R/W) 3 (-) 2 (-) 1 0 OCS01/23 CST1 CST0 Output compare control register (R/W) (R/W) Initial value 0000- -00B Note: To rewriting the compare register, perform within the compare interrupt routine or compare operation disabled state. Be sure not to occur a compare result match and writing the compare register simultaneously. 205 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ■ Block Diagram of Output Compare Figure 13.3-9 shows a block diagram of output compare Figure 13.3-9 Block Diagram of Output Compare 16-bit timer counter value (T15 to T00) Compare control TQ OTE0 OUT0 (2) OTE1 OUT1 (3) Compare register 0 (2) Bus 16-bit timer counter value (T15 to T00) CMOD TQ Compare control Compare register 1 (3) ICP1 ICP0 ICE0 ICE0 Control unit Compare 1 (3) interrupt Control block Compare 0 (2) interrupt ■ Output Compare Register (OCCP0 to OCCP3) Output compare register (OCCP0 to OCCP3) has the bit configuration shown below. Figure 13.3-10 Bit Configuration of Output Compare Register (OCCP0 to OCCP3) 00004BH bit 15 14 13 12 11 10 9 8 OCCP0 to OCCP3 00004DH C15 C14 C13 C12 C11 C10 C09 C08 Compare register 00004FH 000051H (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value 00000000B 00004AH bit 7 6 5 4 3 2 1 0 OCCP0 to OCCP3 00004CH C07 C06 C05 C04 C03 C02 C01 C00 Compare register 00004EH 000050H (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value 00000000B The compare register (OCCP0 to OCCP3) is a 16-bit compare register used to comparison with the free-run timer. This register is initialized at reset. This register uses word access. If this register and the free-run timer have matching values, a compare signal is generated to set the output compare interrupt flag. If output enable is given, the output level corresponding to the compare register value is reversed and outputted. 206 ■ Output Compare Control Register (OCS01/OCS23) The output compare control register (OCS01/OCS23) has the bit configuration shown below. Figure 13.3-11 Bit Configuration of Output Compare Control Register (OCS01/OCS23) bit 15 000057H 000059H (-) 14 (-) 13 12 11 10 9 8 OCS01/OCS23 - CMOD OTE1 OTE0 OTD1 OTD0 Control register (-) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value - - -00000B bit 7 6 5 4 000056H ICP1 ICP0 ICE1 ICE0 000058H (R/W) (R/W) (R/W) (R/W) 3 (-) 2 (-) 1 0 OCS01/OCS23 CST1 CST0 Control register (R/W) (R/W) Initial value 0000- -00B The functions of the output compare control register bits (OCS01/OCS23) are shown below. [bit15, bit14, bit13] Unused bits These bits are not used. They are always set to "0". [bit12] CMOD This bit is for switching the pin output level reverse operation mode in compare result matching if pin output is permitted (OTE1 = 1 or OTE0 = 1). • If CMOD = 0 (initial value), the level corresponding to the compare register value is reversed. - OUT0/OUT2: Level is reversed if a match for compare register 0/2 is found - OUT1/OUT3: Level is reversed if a match for compare register 1/3 is found • If CMOD = 1, compare register 0 (2) inverts the output level in the same manner as in cases where CMOD = 0; however, the pin OUT1 (OUT3) output level corresponding to compare register 1 (3) inverts the output level only when both compare register 0 (2) and compare register 1 (3) have a match. Also, if compare registers 0 (2) and 1 (3) have the same value, the operation is the same as that for one compare register. - OUT0/OUT2: Level is reversed if a match for compare register 0/2 is found - OUT1/OUT3: Level is reversed if a match for compare register 0/2 and 1/3 is found [bit11, bit10] OTE1, OTE0 These bits permit pin output of output compare. These bits take an initial value of "0". 0 General-purpose support (initial value) 1 Operate as pin output of output compare • OTE1: Corresponds with output compare 1/3 • OTE0: Corresponds with output compare 0/2 [bit9, bit8] OTD1, OTD0 These bits change the pin output level if pin output of output compare is permitted. The initial value of compare pin output is set to "0". A write operation is performed after the compare operation stops. In a read operation, the output value of the output compare pin is read. 0 Compare pin output set to "0" (initial value) 1 Compare pin output set to "1" • OTD1: Corresponds to output compare 1/3 • OTD0: Corresponds to output compare 0/2 207 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER [bit7, bit6] ICP1, ICP0 These bits are the interrupt flags for output compare. Set them to "1" if the compare register and freerun timer have matching values. If the interrupt request bit (ICE1, ICE0) is set to "enabled", and this bit is set, an output compare interrupt occurs. This bit is cleared if "0" is written. Writing "1" has no effect. An instruction of the read-modify type only reads "1". 0 No compare match (initial value) 1 Compare result match • ICP1: Corresponds to output compare 1/3 • ICP0: Corresponds to output compare 0/2 [bit5, bit4] ICE1, ICE0 These bits are the interrupt permit bits of output compare. If these bits are set to "1" and an interrupt flag (ICP1, ICP0) is set, an output compare interrupt occurs. 0 Output compare interrupt prohibit (initial value) 1 Output compare interrupt permit • ICE1: Corresponds to output compare 1/3 • ICE0: Corresponds to output compare 0/2 [bit3, bit2] Unused bits These bits are not used. [bit1, bit0] CST1, CST0 These bits permit a matching operation with the compare register and free-run timer. 0 Compare operation prohibit (initial value) 1 Compare operation permit • CST1: Corresponds to output compare 1/3 • CST0: Corresponds to output compare 0/2 Before a compare operation is permitted, specify the compare register value. Note: Output compare operates in sync with the free-run timer clock. Thus, if the free-run timer stops, the compare operation also stops. 208 13.3.3 Input capture This section describes the configuration and functions of the registers for the input capture. ■ List of Input Capture Registers Figure 13.3-12 shows a list of the input capture registers. Figure 13.3-12 Input Capture Registers bit 15 14 13 12 11 10 9 8 ch.0 00005DH ch.1 00005FH CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 (R) (R) (R) (R) (R) (R) (R) (R) IPCP0, IPCP1 Input capture data register Initial value XXXXXXXXB bit 7 6 5 4 3 2 1 0 ch.0 00005CH ch.1 00005EH CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 (R) (R) (R) (R) (R) (R) (R) (R) IPCP0, IPCP1 Input capture data register Initial value XXXXXXXXB bit 7 6 5 4 3 2 1 0 ICS01 000060H ICP1 ICP0 ICE1 ICE0 EG11 EG10 EG01 EG00 Input capture control status register (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value 00000000B ■ Input Capture Data Register (IPCP0, IPCP1) The input capture data register (IPCP0, IPCP1) has the bit configuration shown below. Figure 13.3-13 Bit Configuration of Input Capture Data Register (IPCP0, IPCP1) bit 15 14 13 12 11 10 9 8 ch.0 00005DH CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 ch.1 00005FH (R) (R) (R) (R) (R) (R) (R) (R) IPCP0, IPCP1 Input capture data register Initial value XXXXXXXXB bit 7 6 5 4 3 2 1 0 ch.0 00005CH CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 ch.1 00005EH (R) (R) (R) (R) (R) (R) (R) (R) IPCP0, IPCP1 Input capture data register Initial value XXXXXXXXB The input capture data register (IPCP0, IPCP1) is a register containing the free-run timer value when a valid edge of the external pin input waveform is detected. This register uses word access. Writing to this register is not permitted. 209 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ■ Control Status Register (ICS01) The input capture control status register (ICS01) has the bit configuration shown below. Figure 13.3-14 Bit Configuration of Input Capture Control Status Register (ICS01) bit 7 6 5 4 3 2 1 0 ICS01 000060H ICP1 ICP0 ICE1 ICE0 EG11 EG10 EG01 EG00 Input capture control status register (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Initial value 00000000B The input capture control status register (ICS01) consists of bits that have the functions explained below. [bit7, bit6] ICP1, ICP0 These bits are the interrupt flags of input capture. When a valid edge of the external input pin is detected, this bit is set to "1". If the interrupt permit bit (ICE1, ICE0) is set, an interrupt may be occurred when a valid edge is detected. This bit is cleared when "0" is written. Writing "1" has no effect. An instruction of the read-modifywrite type always reads "1". 0 No valid edge detected (initial value) 1 Valid edge detected • ICP1: Corresponds to input capture 1 • ICP0: Corresponds to input capture 0 [bit5, bit4] ICE1, ICE0 These bits are used as the interrupt permit bits of input capture. If these bits are set to "1" and the interrupt flag (ICP1, ICP0) is set, then an input capture interrupt occurs. 0 Interrupt prohibit (initial value) 1 Interrupt permit • ICE1: Corresponds to input capture 1 • ICE0: Corresponds to input capture 0 [bit3, bit2, bit1, bit0] EG11, EG10, EG01, EG00 These bits specify the valid edge polarity of external input. Also, they are used to specify the enable of input capture operations. 210 EG11/EG01 EG10/EG00 Edge detection polarity 0 0 No edge detected (stop state) (initial value) 0 1 Rising edge detected 1 0 Falling edge detected 1 1 Both edges detected • EG11/EG10: Corresponds to input capture 1 • EG01/EG00: Corresponds to input capture 0 13.4 Interrupt of 16-bit Input/Output Timer The interrupt of the 16-bit input/output timer occurs when the counter value of the freerun timer overflows, the trigger edge input to the input capture input pin is performed, and a match with the output compare is detected. The DMA transfer and extended intelligent I/O service (EI2OS) can be activated for the interrupt of the input capture and output compare. ■ Interrupt of 16-bit Input/Output Timer Table 13.4-1 shows the interrupt control bit and interrupt source of the 16-bit input/output timer. Table 13.4-1 Interrupt of 16-bit Input/Output Timer Timer counter overflow interrupt Input capture interrupt Output compare interrupt Interrupt request flag TCCS: IVF (bit7) ICS01: ICP1 (bit7) ch.1 ICS01: ICP0 (bit6) ch.0 OCS01/23: ICP1 (bit7) ch.1, ch.3 OCS01/23: ICP0 (bit6) ch.0, ch.2 Interrupt request output enable bit TCCS: IVFE (bit6) ICS01: ICE1 (bit5) ch.1 ICS01: ICE0 (bit4) ch.0 OCS01/23: ICE1 (bit5) ch.1, ch.3 OCS01/23: ICE0 (bit4) ch.0, ch.2 Interrupt generation source Counter overflow of 16-bit free-run timer Valid edge input to input capture input pin Match between output compare register value and counter value ICS01: ICP0/ICE0 correspond to input capture pin (IN0). ICS01: ICP1/ICE1 correspond to input capture pin (IN1). OCS01/OCS23: ICP0/ICE0 correspond to output compare pins (OUT0/OUT2). OCS01/OCS23: ICP1/ICE1 correspond to output compare pins (OUT1/OUT3). ● Timer counter overflow interrupt When the timer counter overflow interrupt request flag is set The timer counter overflow generation flag in the timer counter control status register is set when the following is occurred (TCCS: IVF=1) • When an overflow ("FFFFH"Æ"0000H") occurs in counting up of the free-run timer • When the initialization by compare clear register is set to enable (TCCS: MODE=1) and an match between the setting value of the free-run timer and the value of the compare clear register occurs. When the timer counter overflow interrupt request occurs If the timer counter overflow interrupt request is set to enable (TCCS: IVFE=1), the interrupt request is generated when the timer counter overflow generation flag is set to 1 (TCCS: IVF=1). ● Input capture interrupt The interrupt operation when the valid edge (ICS: EG) set by the input capture pin is detected is shown as follows: • The count value of the free-run timer upon detection is stored in the input capture register. • The valid edge detection flag in the control status register is set to 1 (ICS: ICP=1). • When the input capture interrupt request output is set to enable (ICS: ICE=1), the interrupt request occurs. 211 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ● Output compare interrupt The interrupt operation when a match between the count value of the free-run timer and the setting value of the compare register is detected is shown as follows: • The output compare match flag in the control register is set to 1 (OCS:IOP=1). • When the output compare interrupt request is set to enable (OCS: IOE=1), the interrupt request occurs. ■ Interrupt of 16-bit Input/Output Timer, DMA Transfer, and EI2OS Table 13.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 13.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register EI2OS clear μDMAC channel number Number Input capture (channel 0) fetch* ❍ 5 #26 FFFF94H Input capture (channel 1) fetch ❍ 6 #27 FFFF90H Output compare (channel 0) match ❍ 8 #28 FFFF8CH Output compare (channel 1) match ❍ 9 #29 FFFF88H Output compare (channel 2) match ❍ 10 #30 FFFF84H Output compare (channel 3) match ❍ × #31 FFFF80H − − × #32 FFFF7CH − − × #33 ❍ 12 #35 Interrupt source 16-bit free-run timer overflow,* 16-bit reload timer underflow Interrupt vector Address Interrupt control register Number Address ICR07 0000B7H ICR08 0000B8H ICR09 0000B9H ICR10 0000BAH FFFF78H ICR11 0000BBH FFFF70H ICR12 0000BCH × : Interrupt request flag is not cleared. ❍ : Interrupt request flag is cleared. * : This interrupt source shares the interrupt source and interrupt number of other peripheral function. For details, see Table 4.2-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function The input capture and free-run timer correspond to the DMA transfer and EI2OS functions. The output compare corresponds to the DMA transfer function only for EI2OS function and channels 0 to 2. When the DMA or EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 212 13.5 16-bit Input/Output Timer Operation This section explains the operation and timing of the 16-bit input/output timer. ■ Operation and Timing of 16-bit Input/Output Timer The 16-bit input/output timer handles the operation and timing for the following items: • Free-run timer operation • Output compare operation • Input capture operation • Free-run timer timing • • • Count timing • Clear timing Output compare timing • Interrupt timing • Change timing of the output pin Timing of input capture • Capture timing to the input signal 213 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER 13.5.1 Operation of free-run timer This section explains the operation and timing of the free-run timer. ■ Operation of Free-run Timer The free-run timer starts counting at a counter value of "0000B" after a reset operation is cleared. This counter value is used as a reference time for output compare and input capture. The count value is cleared by a clear operation under the following conditions: • Overflow occurs • Compare match is found with the output compare value 0 (mode setting is required) • SCLR bit of TCCS register is set to "1" during operation • TCDT register is set to "0000B" during operation • Reset occurs An interrupt occurs if an overflow is generated or the counter value of free-run timer the value of compare register 0 matches compare results (a compare results match interrupt requires mode setting). Figure 13.5-1 shows the timing chart of the counter cleared because of an overflow. Figure 13.5-2 shows the timing chart of the counter cleared because of a compare results match. Figure 13.5-1 Timing Chart of Counter Cleared Because of Overflow Counter value FFFFH BFFFH 7FFFH 3FFFH 0000H Reset Interrupt 214 Time Figure 13.5-2 Timing Chart of Counter Cleared Because of Compare Results Match Counter value FFFFH BFFFH 7FFFH 3FFFH 0000H Reset Compare register value Time BFFFH Interrupt 215 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER 13.5.2 Operation of output compare Output compare compares the specified compare register value with the 16-bit free-run timer value, and if they match, it sets an interrupt request flag and reverses the output level. ■ Examples of Output Waveform Examples of output waveform are shown below. ● Example of output waveform where compare registers 0 and 1 are used Figure 13.5-3 shows an example of output waveform where the initial value of output is specified as "0". Figure 13.5-3 Example of Output Waveform where Compare Registers 0 and 1 are Used (Initial Value of Output = 0) Counter value FFFFH BFFFH 7FFFH 3FFFH 0000H Reset Compare register 0 value Compare register 1 value Time BFFFH 7FFFH OUT0 OUT1 Compare 0 interrupt Compare 1 interrupt If CMOD = 1, two pairs of compare registers may be used to change the output level. 216 ● Example of output waveform from two pairs of compare registers Figure 13.5-4 shows an example of output waveform where the initial value of output is specified as "0". Figure 13.5-4 Example of Output Waveform from Two Pairs of Compare Registers (Initial Value of Output = 0) Counter value FFFFH BFFFH 7FFFH 3FFFH 0000H Reset Compare register 0 value Compare register 1 value Time BFFFH 7FFFH OUT0 Corresponding to compare 0 OUT1 Corresponding to compare 1 Compare 0 interrupt Compare 1 interrupt Note: To rewriting the compare register, perform within the compare interrupt routine or compare operation disabled state. Be sure not to occur a compare result match and writing the compare register simultaneously. 217 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER 13.5.3 Operation of input capture Input capture is generated interrupts by reading and storing the free-run timer value into the capture register if the specified edge is detected as being valid. ■ Example of Input Capture Timing Figure 13.5-5 shows an example of input capture timing Figure 13.5-5 Example of Input Capture Timing Counter value FFFFH BFFFH 7FFFH 3FFFH 0000H Time Reset IN0 IN1 Example of IN Capture 0 Unspecified 3FFFH 7FFFH Capture 1 Unspecified Example of capture Capture 0 interrupt Capture 1 interrupt Example-of-capture interrupt 218 Unspecified BFFFH 7FFFH 13.5.4 Free-run timer timing The free-run timer is incremented according to the timing of input clock (internal or external clock). If an external clock is selected, counting is performed at the rising edge. ■ Count Timing of Free-run Timer Figure 13.5-6 shows the count timing of the free-run timer. Figure 13.5-6 Count Timing of Free-run Timer φ External clock input Count clock N Counter value N+1 The counter is cleared by either a reset, clear by software, or a match with compare register 0 and free-run timer. Counter clear by a reset or software occurs when a clear operation is performed. Counter clear because of a match with compare register 0 occurs in sync with count timing. ■ Clear Timing of Free-run Timer (Match with Compare Register 0) Figure 13.5-7 shows the clear timing of the free-run timer caused by a match with compare register 0. Figure 13.5-7 Clear Timing of Free-run Timer (Match with Compare Register 0) φ N Compare register value Compare match Counter value N 0000 219 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER 13.5.5 Output compare timing The output compare is used to issue compare match signals when the free-run timer and the compare register have matching values, to reverse the output value, and to generate interrupts. Output reverse timing at the compare match is in sync with the counter timing. ■ Interrupt Timing Figure 13.5-8 shows the interrupt timing of output compare. Figure 13.5-8 Interrupt Timing of Output Compare φ Counter value N Compare register value N N+1 Compare match Compare match ■ Change Timing of Output Pin Figure 13.5-9 shows the change timing of the output pin for output compare. Figure 13.5-9 Change Timing of Output Pin for Output Compare Counter value Compare register value N N+1 N N+1 N Compare match signal Output pin Note: To rewriting the compare register, perform within the compare interrupt routine or compare operation disabled state. Be sure not to occur a compare result match and writing the compare register simultaneously. 220 13.5.6 Timing of input capture This section describes a capture timing of the input signal for input capture. ■ Capture Timing to Input Signal Figure 13.5-10 shows the capture timing of input signal for input capture. Figure 13.5-10 Capture Timing of Input Signal for Input Capture φ Counter value Input capture N N+1 Valid edge Capture signal Capture register N+1 Interrupt 221 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER 13.6 Program Example of 16-bit Input/Output Timer This section describes the program example of the 16-bit input/output timer. ■ Program Example of Free-run Timer Example of setting procedure Program example Count number of times overflow by free-run timer, clock =φ/ 2^4, and interrupt processing void FREE_RUN_TIMER_sample(void) { FREERUN_initial(); FREERUN_start(); } <Initial setting> • Control free-run timer void FREERUN_initial(void) { IO_TCCS.word = 0x006C; /* Setting value=0000_0000_0110_1100 */ /* bit15 = 0 ECKE internal clock source */ /* bit7 = 0 IVF interrupt request flag */ /* bit6 = 1 Enable IVFE interrupt */ /* bit5 = 1 Disable STOP count */ /* bit4 = 0 Initialize by MODE reset, clear bit */ /* bit3 = 1 Initialize SCLR free-run timer value */ /* bit2 to bit0 = 100 CLK2 to CLK0 count clock f/16 */ IO_TCDT = 0x0000; /* Initialize timer data value */ Set control register Clock selection>> Interrupt request flag>> Interrupt request enable>> Count operation>> TCCS .ECKE .IVF .IVFE .STOP Initialization condition of timer>> .MODE TCDT clear>> .SCLR Count clock>> .CLK2 to CLK0 Set timer data value TCDT • Interrupt related Set interrupt level Set I flag ICR12 (CCR) IO_ICR12.byte = 0x00; __EI(); count = 0; /* Set interrupt level of free-run timer (arbitrary value) */ /* Enable interrupt */ } • Set variable void FREERUN_start(void) <Start> • Start free-run timer ch.0 Register name. bit name Start count operation { IO_TCCS.bit.STOP = 0; TCCS .STOP /* bit5 = 0 Enable STOP count */ } __interrupt void FREE_RUN_TIMER_int(void) <Interrupt> • Interrupt processing Register name. bit name Clear interrupt request flag { IO_TCCS.bit.IVF = 0; TCCS .IVF (Arbitrary processing) Count of variable /* bit7 = 0 Clear IVF overflow flag */ count++; } <Interrupt vector> • Set vector table #pragma intvect FREE_RUN_TIMER_int 35 Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See the chapter of clock and interrupt. Note: 222 For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". ■ Setting Method Other than Program Example ● Type of internal clock and selection method There are eight internal clocks and they are set by the clock selection bit (TCCS.ECKE) and count clock bit (TCCS.CLK[2:0]). Table 13.6-1 Type of Internal Clock and Selection Method Setting Internal clock Count cycle Clock selection bit (ECKE) Count clock bit (CLK[2:0]) φ = 20MHz φ = 16MHz To select φ Set to "0" Set to "000B" 50ns 62.5ns To select φ/2 Set to "0" Set to "001B" 100ns 0.125μs To select φ/4 Set to "0" Set to "010B" 0.2μs 0.25μs To select φ/8 Set to "0" Set to "011B" 0.4μs 0.5μs To select φ/16 Set to "0" Set to "100B" 0.8μs 1.0μs To select φ/32 Set to "0" Set to "101B" 1.6μs 2.0μs To select φ/64 Set to "0" Set to "110B" 3.2μs 4.0μs To select φ/128 Set to "0" Set to "111B" 6.4μs 8.0μs ● Selection method of external clock Set by the clock selection bit (TCCS.ECKE), data direction bit, and port function bit. Table 13.6-2 Selection Method of External Clock Setting Set clock selection bit (ECKE) to 1 Set data direction bit (DDR9.P93) to "0" Pin Count cycle FRCK φ/2 or more ● Method to enable/disable the count operation of free-run timer Set by count operation bit (TCCS.STOP) Table 13.6-3 Method to Enable/Disable the Count Operation of Free-run Timer Operation Count operation bit (STOP) To enable the count operation of free-run timer Set to "0" To disable the count operation of free-run timer Set to "1" 223 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ● Method to clear the free-run timer The following method is used to clear the free-run timer. • Set by clear bit (TCCS.SCLR) Table 13.6-4 Method to Clear the Free-run Timer Operation Clear bit (SCLR) To clear the free-run timer Write "1" • Match between free-run timer value and compare clear register value (set by timer initialization condition bit (TCCS.MODE)) Table 13.6-5 Method to Clear the Free-run Timer Operation Timer initialization condition bit (MODE) To clear the free-run timer by match of comparison result Set to "1" • Reset The free-run timer is cleared by reset (external reset, watchdog reset, software reset). • Set "0000H" to timer counter data register (TCDT) When "0000H" is written to the timer counter data register (TCDT) during operation of the free-run timer is stopped, the count value is cleared to "0000H". ● Interrupt related register The relationship between the interrupt level and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 13.6-6 Relationship Between the Interrupt Level and Interrupt Vector Interrupt vector Interrupt level setting register #35 Address: 0FFFF70H Interrupt level register (ICR12) Address: 000BCH Clear the interrupt request flag (TCCS.IVF) with software before returning from the interrupt processing because the flag does not clear automatically (write "0" to IVF bit). ● Type of interrupt One interrupt is provided only. It generates by overflow of the free-run timer. 224 ● Method to enable interrupt Enabling/disabling interrupt sets using the interrupt request enable bit (TCCS.IVFE). Table 13.6-7 Method to Enable Interrupt Control Interrupt request enable bit (IVFE) Disable interrupt Set to "0" Enable interrupt Set to "1" Clearing the interrupt request sets using the interrupt request bit (TCCS.IVF). Table 13.6-8 Clear the Interrupt Request Control Interrupt request bit (IVF) Clear interrupt request Write "0" ● Method to stop operation of free-run timer Set by count operation bit (TCCS.STOP). Table 13.6-9 Method to Stop Operation of Free-run Timer Operation Count operation bit (STOP) To stop count operation of free-run Set to "1" 225 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ■ Program Example of Output Compare Example of setting procedure 2-channel independent output compare operation (7FFFF, BFFFF), interrupt generation, no compare clear <Initial setting> • Control free-run timer Set control register Clock selection>> Interrupt request flag>> Interrupt request enable>> Count operation>> Initialization condition of timer>> TCDT clear>> Count clock>> Set timer data value TCCS .ECKE .IVF .IVFE .STOP .MODE .SCLR .CLK2 to CLK0 TCDT • Control output compare Register name. bit name Set control register Reverse operation of pin output level>> Pin output enable>> Specify pin output level>> Interrupt request flag>> Interrupt request enable>> Set operation enable>> Set compare value ch.0 Set compare value ch.1 OCS01 .CMOD Program example void OUTPUT01_sample(void) { freerun_initial(); OUTPUT01_initial(); OUTPUT01_start(); freerun_start(); } void freerun_initial(void) { IO_TCCS.word = 0x0020; /* Setting value=0000_0000_0010_0000 */ /* bit15 = 0 ECKE internal clock source*/ /* bit7 = 0 IVF interrupt request flag */ /* bit6 = 0 Enable IVFE interrupt */ /* bit5 = 1 Disable STOP count */ Initialize by MODE reset, clear bit */ /* bit4 = 0 /* bit3 = 0 Initialize SCLR free-run timer value */ /* bit2 to bit0 = 000B CLK2 to CLK0 count clock φ/4=32MHz/4 */ IO_TCDT = 0x0000; /* Initialize timer data value */ } void OUTPUT01_initial(void) { IO_OCS01.word = 0x0C00; /* Setting value=0000_1100_0000_0000 */ /* bit15 to13 = 000B Undefined bit*/ .OTE1,OTE0 .OTD1,OTD0 .ICP1,ICP0 .ICE1,ICE0 .CST1.CST0 OCCP0 OCCP1 /* bit12 = 0 /* bit11, bit10 = 11B Reverse CMOD ch.0,ch.1 level */ Enable OTE1,OTE0 pin output */ /* bit9, bit8 = 00B OTD1,OTD0 compare pin output 0 */ /* bit7, bit6 = 00B Clear ICP1,ICP0 output compare flag */ /* bit5, bit4 = 00B Disable ICE1,ICE0 output compare interrupt */ /* bit3, bit2 = 00B Undefined bit */ /* bit1, bit0 = 00B Disable CST1,CST0 compare operation */ IO_OCCP0 = BFFF; IO_OCCP1 = 7FFF; /* Set Compare register ch.0 */ /* Set Compare register ch.1 */ IO_ICR08.byte = 0x00; IO_ICR09.byte = 0x00; __EI(); /* Set output compare ch.0 interrupt level (arbitrary value) */ /* Set output compare ch.1 interrupt level (arbitrary value) */ /* Enable interrupt */ • Interrupt related Set interrupt level Set interrupt level Set I flag ICR08 ICR09 (CCR) } <Start> • Start output compare Register name. bit name Interrupt control Start compare operation OCS01 .ICE1.ICE0 OCS01 .CST1.CST0 • Start free-run timer Register name. bit name Start count operation TCCS .STOP void OUTPUT01_start(void) { IO_OCS01.word = 0x0C30; /* bit5, bit4 = 11 IO_OCS01.word = 0x0C33; /* bit1, bit0 = 11 } void freerun_start(void) { IO_TCCS.bit.STOP = 0; /* bit4 = 0 } Enable ICE1,ICE0 output compare interrupt */ Enable CST1,CST0 compare operation */ Enable STOP count */ (Continued) 226 (Continued) <Interrupt> • Interrupt processing __interrupt void OUTPUT0_int(void) { IO_OCS01.bit.ICP0 = 0; /* bit6 = 0 Register name. bit name Clear interrupt request flag OCS01 .ICP0 } __interrupt void OUTPUT1_int(void) { IO_OCS01.bit.ICP1 = 0; /* bit7 = 0 •••••••••• Clear interrupt request flag Clear ICP0 interrupt flag */ • • • • • • (Arbitrary processing) OCS01 .ICP1 Clear ICP1 interrupt flag */ • • • • • • (Arbitrary processing) } •••••••••• #pragma intvect OUTPUT0_int 28 #pragma intvect OUTPUT1_int 29 <Interrupt vector> • Set vector table Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See the chapter of clock and interrupt. Note: For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". ■ Setting Method Other than Program Example ● Method to set compare value The compare value is written to the compare registers (OCCP0 to OCCP3). ● Method to set compare mode (valid for OUT1, OUT2, OUT3 output) Set by compare mode bit (OCS01.CMOD, OCS23.CMOD). Table 13.6-10 Method to Set Compare Mode Operation Compare mode bit To reverse OUT1 output by a match with comparison result between free-run timer and compare register 1 Set (OCS01.CMOD) bit to "0" To reverse OUT3 output by a match with comparison result between free-run timer and compare register 3 Set (OCS23.CMOD) bit to "0" To reverse Out1 output by match with comparison result between free-run timer and compare register 0 and between free-run timer and compare register 1 Set (OCS01.CMOD) bit to "1" To reverse Out3 output by match with comparison result between free-run timer and compare register 2 and between free-run timer and compare register 3 Set (OCS23.CMOD) bit to "1" The following is output regardless of the CMOD bit. • OUT0 output reverses output by a match with comparison result between free-run timer and compare register 0. • OUT2 output reverses output by a match with comparison result between free-run timer and compare register 2. 227 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ● Method to enable/disable compare operation Set by compare operation bit (OCS01. CST[1:0], OCS23. CST[1:0]). Table 13.6-11 Method to Enable/Disable Compare Operation Operation Compare Compare operation enable bit Compare 0 Set (OCS01.CST0) to "0". Compare 1 Set (OCS01.CST1) to "0". Compare 2 Set (OCS23.CST0) to "0". Compare 3 Set (OCS23.CST1) to "0". Compare 0 Set (OCS01.CST0) to "1". Compare 1 Set (OCS01.CST1) to "1". Compare 2 Set (OCS23.CST1) to "1". Compare 3 Set (OCS23.CST0) to "1". To stop (disable) compare operation To enable compare operation ● Method to set the initial level of compare pin output Set by compare pin output specification bit (OCS01.OTD[1:0], OCS23.OTD[1:0]). Table 13.6-12 Method to Set the Initial Level of Compare Pin Output 228 Operation Compare pin output specification bit Set compare 0 pin to "L" Set (OCS01.OTD0) to "0" Set compare 0 pin to "H" Set (OCS01.OTD0) to "1" Set compare 1 pin to "L" Set (OCS01.OTD1) to "0" Set compare 1 pin to "H" Set (OCS01.OTD1) to "1" Set compare 2 pin to "L" Set (OCS23.OTD0) to "0" Set compare 2 pin to "H" Set (OCS23.OTD0) to "1" Set compare 3 pin to "L" Set (OCS23.OTD1) to "0" Set compare 3 pin to "H" Set (OCS23.OTD1) to "1" ● Method to set compare pin OUT0-OUT3 to output Set by port function register (OCS01.OTE[1:0], OCS23.OTE[1:0]). Table 13.6-13 Method to Set Compare Pin to Output Operation Port function bit To set compare 0 pin (OUT0) to output Set (OCS01.OTE0) to "1" To set compare 1 pin (OUT1) to output Set (OCS01.OTE1) to "1" To set compare 2 pin (OUT2) to output Set (OCS23.OTE0) to "1" To set compare 3 pin (OUT3) to output Set (OCS23.OTE1) to "1" ● Method to clear free-run timer Set by clear bit (TCCS.SCLR). Table 13.6-14 Method to Clear the Free-run Timer Operation Clear bit (SCLR) To clear free-run timer Write "1" For other methods, see Section "13.3.1 Free-run timer". ● Method to enable compare operation Set by the compare operation enable bit (OCS01.CST[1:0], OCS23.CST[1:0]). ● Method to clear the free-run timer when the free-run timer value matches with the compare register value Set by timer initialization condition bit (TCCS.MODE). Table 13.6-15 Method to Clear the Free-run Timer Operation Timer initialization condition bit (MODE) To clear free-run timer 0 by match of compare 0 Set (TCCS.MODE) to "1" 229 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ● Interrupt related register The relationship between channel, interrupt level, and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 13.6-16 Relationship Between Channel, Interrupt Level, and Interrupt Vector Channel Interrupt vector Interrupt level setting register Output compare 0 #28 Address : 0FFFF8CH Interrupt level register (ICR08) Address : 000B8H Output compare 1 #29 Address : 0FFFF88H Interrupt level register (ICR09) Address : 000B9H Output compare 2 #30 Address : 0FFFF84H Interrupt level register (ICR09) Address : 000B9H Output compare 3 #31 Address : 0FFFF80H Interrupt level register (ICR10) Address : 000BAH Clear the interrupt request flag (OCS01.ICP[1:0], OCS23.ICP[1:0]) by writing "0" to ICP[1:0] bit with software before returning from the interrupt processing because the flag does not clear automatically. ● Type of interrupt One interrupt is provided. It generates by a match of the comparison result. ● Method to enable interrupt Enabling the interrupt is set by the interrupt request enable bit (OCS01.ICE[1:0], OCS23.ICE[1:0]). Table 13.6-17 Method to Enable Interrupt Control Interrupt request enable bit (ICE0, ICE1) Disable interrupt Set to "0" Enable interrupt Set to "1" The interrupt request is cleared by the interrupt request bit (OCS01.ICP[1:0], OCS23.ICP[1:0]). Table 13.6-18 Clear Interrupt Request 230 Control Interrupt request bit (ICP0, ICP1) Clear interrupt request Write "0" ● Calculation method of compare value • Toggle output pulse (Example) Cycle: A, method to output 2-phase pulse of 1/4 phase difference Figure 13.6-1 Method to Output 2-Phase Pulse A OP0 OP1 Phase difference1/4 Formula: Compare 0 value = (A/2)/ count clock Compare 1 value = (A/4)/ count clock (Count clock: time set by free-run timer) Note: Setting to clear the free-run timer 0 by a match of compare 0 (TCCS0.MODE = 1 ) and Setting of CMOD = 0 are required. Calculation example: A=1024μs, Count clock=125ns Compare 0 value = (1024000 / 2) / 125 - 1 = 4095 = FFFH Compare 1 value = (1024000 / 4) / 125 - 1 = 1023 = 7FFH • PWM output (Example) Cycle: A, method to output PWM of 1/4 to 3/4 duty (L) Figure 13.6-2 Method to Output PWM A OP1 1/4-3/4 Formula: Compare 0 value = A / Count clock Compare 1 value = (A/4) / Count clock (at 1/4 duty) (A×3/4) / Count clock (at 3/4 duty) (Count clock: time set by free-run timer) Note: Setting to clear the free-run timer 0 by a match of compare 0 (TCCS0.MODE=1) and setting of CMOD= 1 are required. Calculation example: A=1024 μs, Count clock=125ns Compare 0 value = 1024000 / 125 - 1 = 8191 = 1FFFH Compare 1 value = (1024000 / 4) / 125 - 1 = 1023 = 7FFH (at 1/4 duty) (1024000×3 / 4) / 125 - 1 = 1023 = BFFH (at 3/4 duty) 231 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ■ Program Example of Input Capture Example of setting procedure Rising edge of the pulse input to IN0 is detected, and the value of the free-run timer is recorded. Repeat this twice and measure the time between triggers. However reading of capture value and calculation processing is interrupt processing. <Initial setting> • Control free-run timer Set control register Clock selection>> Interrupt request flag>> Interrupt request enable>> Count operation>> Initialization condition of timer>> TCDT clear>> Count clock>> Set timer data value TCCS .ECKE .IVF .IVFE .STOP .MODE .SCLR .CLK2 to CLK0 TCDT • Port Register name. bit name Set IN0 input of port Program example void INPUT0_sample(void) { freerun_initial(); INPUT0_initial(); INPUT0_start(); freerun_start(); } void freerun_initial(void) { IO_TCCS.word = 0x20; /* Setting value=0000_0000_0010_0000 */ /* bit15 = 0 ECKE internal clock source */ /* bit7 = 0 IVF interrupt request flag */ /* bit6 = 0 IVFE disable interrupt */ /* bit5 = 1 Disable STOP count */ /* bit4 = 0 Initialize by MODE reset, clear bit */ /* bit3 = 0 Initialize SCLR free-run timer value */ /* bit2 to bit0 = 000B CLK2 to CLK0 count clock φ*/ IO_TCDT = 0x0000; void INPUT0_initial(void) { IO_DDR9.byte = 0x00; /* DDR9 IN0(P96) input */ DDR9 .P96 IO_ICS01.byte = 0x01; • Control input capture Set control register Interrupt request flag>> Interrupt request enable>> Select ch.1 valid edge polarity>> Select ch.0 valid edge polarity>> ICS01 .ICP1,ICP0 .ICE1,ICE0 .EG11,EG10 .EG01,EG00 • Interrupt related Set interrupt level Set I flag Register name. bit name ICS01 .ICE0 • Start Free-run timer Register name. bit name TCCS .STOP <Interrupt> • Interrupt processing Register name. bit name Clear interrupt request flag /* bit5, bit4 = 00B Disable ICE1, ICE0 interrupt */ /* bit3, bit2 = 00B No EG11, EG10 ch.1 edge detection */ /* bit1, bit0 = 01B EG01, EG00 ch.0 rising edge detection */ } <Start> • Start input capture ch.0 Start count operation /* Setting value=0000_0001 */ /* bit7, bit6 = 00B Clear ICP1, ICP0 valid edge flag */ IO_ICR07.byte = 0x10; /* Set input capture ch.0 interrupt level (arbitrary value) */ __EI(); /* Enable interrupt */ count = 0; ICR07 (CCR) • Set variable Interrupt control /* Initialize timer data value */ } ICS01 .ICP0 (Arbitrary processing) •••••••••• void INPUT0_start(void) { IO_ICS01.bit.ICE0 = 1; } void freerun_start(void) { IO_TCCS.bit.STOP = 0; } /* bit4 = 1 Enable ICE0 ch.0 interrupt */ /* bit5 = 0 Enable STOP count */ __interrupt void INPUT0_int(void) { IO_ICS01.bit.ICP0 = 0; /* bit6 = 0 Clear ICP0 valid edge detection flag */ if(count==0) Data1 = IO_IPCP0; /* Record value of free-run timer (first time) */ else if(count==1) { Data2 = IO_IPCP0; /* Record value of free-run timer (second time) */ cycle = (data2-data1)*125; /* Measure time */ } count++; } <Interrupt vector> • Set vector table #pragma intvect INPUT0_int 26 Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: 232 For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". ■ Setting Method Other than Program Example ● Type of external input valid edge polarity and selection method The valid edge polarity has rising edge, falling edge, and both edges. Set by the valid edge polarity bit of external input (ICS01.EG[01:00], ICS01.EG[11:10]). Table 13.6-19 Type of External Input Valid Edge Polarity and Selection Method Operation Valid edge polarity bit of external input (EG[01:00], EG[11:10]) To select rising edge Select "00" To select falling edge Select "10" To select both edges Select "11" ● Method to set to external input pin (IN0, IN1) Set by data direction bit (DDR9.P96, DDR9.P97). Table 13.6-20 Method to Set to External Input Pin Operation Data direction bit (P96, P97) To set to external input pin (IN0, IN1) Set to "0" ● Interrupt related register The relationship between channel, interrupt level, and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 13.6-21 Relationship Between Channel, Interrupt Level, and Interrupt Vector Channel Interrupt vector Interrupt level setting register Input capture 0 #26 Address: 0FFFF94H Interrupt level register (ICR07) Address : 000B7H Input capture 1 #27 Address: 0FFFF90H Interrupt level register (ICR08) Address : 000B8H The interrupt request flag (ICS01.ICP0, ICS01.ICP1) is not cleared automatically. Clear the flag by writing "0" to the input capture interrupt request flag (ICP1, ICP0) with software before returning from interrupt processing. ● Type of interrupt One interrupt is provided only. It generates at edge detection of the input signal. 233 CHAPTER 13 16-BIT INPUT/OUTPUT TIMER ● Method to enable interrupt Enabling the interrupt sets using the interrupt request enable bit (ICS01.ICE0, ICS01.ICE1). Table 13.6-22 Method to Enable Interrupt Interrupt request enable bit (ICE0, ICE1) Disable interrupt Set to "0" Enable interrupt Set to "1" Clearing the interrupt request set using the interrupt request bit ( ICS01.ICP0, ICS01.ICP1). Table 13.6-23 Clear Interrupt Request Interrupt request bit (ICP0, ICP1) Clear interrupt request Write "0" ● Method to measure pulse width of input signal • H width measurement: Both edges are set at edge detection. Rising edge is detected and then falling edge is detected. Pulse width = { value recorded at falling (value of input capture register) + 10000H × number of times overflow value recorded at rising (value of input capture register)} × count clock width of free-run timer Example: Value recorded at falling = 2320H, value recorded at rising = A635H, number of times overflow = 1, count clock = 125ns → pulse width = (2320H 10000H - A635H) × 125ns = 3997.375μs • Cycle measurement: Rising (or falling) is set at edge detection. Edge is detected twice. Cycle = {value recorded at second time (value of input capture register) + 10000H × number of times overflow value recorded at first time (value of input capture register)} × count clock width of free-run timer 234 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER This chapter has an overview of the 8/16-bit up/down counter/timer, describes the configuration and functions of its registers, and explains its operation. 14.1 Overview of 8/16-bit Up/Down Counter Timer 14.2 Configuration of 8/16-bit Up/Down Counter/Timer 14.3 Configuration and Functions of Registers for 8/16-bit Up/Down Counter/Timer 14.4 Interrupt of 8/16-bit Up/Down Counter/Timer 14.5 8/16-bit Up/Down Counter/Timer Operation 14.6 Program Example of 8/16-bit Up/Down Counter/Timer 235 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER 14.1 Overview of 8/16-bit Up/Down Counter Timer The 8/16-bit up/down counter/timer consists of six event input pins, two 8-bit up/down counter registers, two 8-bit reload/compare registers, and their control circuits. ■ Major Functions of 8/16-bit Up/Down Counter/Timer • • • • • • • • • • 236 8-bit count register used for counting in a range of 0 to 255 (in the 16 bits x one operation mode, counting in a range of 0 to 65535 is possible). Four types of count modes can be selected for the count clock. • Timer mode • Up/down count mode • Phase difference decremented mode (two times) • Phase difference decremented mode (eight times) In the timer mode, the count clock (for 25 MHz) is selected from two types of internal clocks: • 80 ns (12.5 MHz: frequency divided by 2) • 0.32 μs (3.125 MHz: frequency divided by 8) In the up/down count mode, a detection edge of the external pin input signal may be selected: • Falling edge detection • Rising edge detection • Both falling and rising edges detection • Edge detection prohibited The phase difference count mode is suitable for counting encoder output such as motor, where encoder output from phases A, B, and Z is used as input, thereby facilitating high-precision counting of rotation angle and rotations. The ZIN pin is used to select from two types of functions: • Counter clear function • Gate function Compare and reload functions are provided, where each function or a combination of them are available. Starting both functions allows up/down counting with any time width. • Compare function (an interrupt is issued during compare) • Compare function (an interrupt is issued and the counter is cleared during compare) • Reload function (an interrupt is issued and reloaded during compare) • Compare and reload functions (an interrupt is issued and the counter is cleared during compare, and an interrupt is issued and reloaded when an underflow occurs) • Compare and reload prohibited Interrupt generation is individually controlled during compare, a reload (underflow), or an overflow. The count direction flag identifies the count direction of the last counter operation An interrupt occurs when the count direction is switched 14.2 Configuration of 8/16-bit Up/Down Counter/Timer The 8-bit up/down counter/timer has two channels and consists of three event input pins, one 8-bit up/down count, and one 8-bit reload/compare register per channel. Also, one of two 8-bit up/down counter/timer channels can be used as the 16-bit up/down counter/timer. (When using as the 16-bit up/down counter/timer, the register of ch.0 is valid.) ■ Block Diagram of 8/16-bit Up/Down Counter/Timer Figure 14.2-1 and Figure 14.2-2 are block diagrams of the 8/16-bit up/down counter/timer. Figure 14.2-1 Block Diagram of 8/16-bit Up/Down Counter/Timer (Channel 0) Data bus 8 bits CGE1 ZIN0 CGE0 CGSC Edge/level detected RCR0 (reload/compare register 0) CTUT Reload control UCRE UDCC RLDE Counter clear 8 bits UDCR0 (up/down count register 0) Carry CMPF CES1 CES0 UDFF OVFF CMS1 CMS0 Count clock UDMS AIN0 BIN0 CITE UDIE Up/down count clock selection UDF1 UDF0 CDCF CFIE Prescaler CSTR Interrupt output CLKS 237 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER Figure 14.2-2 Block Diagram of 8/16-bit Up/Down Counter/Timer (Channel 1) Data bus 8 bits CGE1 ZIN1 CGE0 CGSC Edge/level detected RCR1 (reload/compare register 1) CTUT Reload control UCRE UDCC RLDE Counter clear 8 bits UDCR1 (up/down count register 1) CMPF UDFF OVFF CMS1 CMS0 CES1 CES0 M16E UDMS CITE UDIE Carry AIN1 BIN1 Count clock Up/down count clock selection Prescaler UDF1 UDF0 CDCF CFIE CSTR Interrupt output CLKS ■ Pin Related to 8/16-bit Up/Down Counter/Timer The pin related to the 8/16-bit up/down counter/timer has the AIN0/BIN0/ZIN0 and AIN1/BIN1/ZIN1 pins. The AIN0/BIN0/ZIN0 pin functions as the general-purpose I/O port (AIN0/P30, BIN0/P31, ZIN0/ P32) and the input pin of the up/down counter/timer. The AIN1/BIN1/ZIN1 pin functions as the generalpurpose I/O port (AIN1/P33, BIN1/P34, ZIN1/P35) and the input pin of the up/down counter/timer. ● Setting when using as AIN0/BIN0/ZIN0 and AIN1/BIN1/ZIN1 pins When using as the AIN/BIN/ZIN input pin, the AIN0/P30, BIN/P31, ZIN0/P32 and AIN1/P33, BIN1/P31, ZIN1/P35 pins should be set to input port by the port direction register (DDR3 bit0, bit1, bit2, bit3, bit4, bit5 → "0"). 238 ■ Block Diagram of Pin Related to 8/16-bit Up/Down Counter/Timer Figure 14.2-3 Block Diagram of Pin Related to 8/16-bit Up/Down Counter/timer Peripheral function input (AIN0/BIN0/ZIN0 AIN1/BIN1/ZIN1) Port data register (PDR) Internal data bus PDR Read Output latch P-ch Pin PDR Write Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Stand-by control (SPL=1) Stand-by control: Stop mode (SPL=1), Time-base timer mode (SPL=1), Watch mode (SPL=1) 239 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER 14.3 Configuration and Functions of Registers for 8/16-bit Up/ Down Counter/Timer This section shows the configuration and explains the function of the 8/16-bit up/down counter/timer registers. ■ List of 8/16-bit Up/Down Counter/Timer Registers Figure 14.3-1 shows a list of registers for the 8/16-bit up/down counter/timer. Figure 14.3-1 List of Registers for 8/16-bit Up/Down Counter/Timer bit 15 87 0 UDCR1 RCR1 Reserve area CCRH0 Reserve area CCRH1 UDCR0 RCR0 CSR0 CCRL0 CSR 1 CCRL1 8 bits 8 bits bit 7 ch.0 UDCR0 Address: 000068H D07 6 D06 5 D05 4 D04 3 D03 2 D02 1 D01 0 D00 Initial value 00000000B bit 15 ch.1 UDCR1 Address: 000069H D17 14 D16 13 D15 12 D14 11 D13 10 D12 9 D11 8 D10 Initial value 00000000B bit 7 ch.0 RCR0 Address: 00006AH D07 6 D06 5 D05 4 D04 3 D03 2 D02 1 D01 0 D00 Initial value 00000000B bit 15 ch.1 RCR1 Address: 00006BH D17 14 D16 13 D15 12 D14 11 D13 10 D12 9 D11 8 D10 Initial value 00000000B ch.0 CSR0 bit 7 6 5 4 3 2 1 0 Initial value Address: 000072H CSTR CITE UDIE CMPF OVFF UDFF UDF1 UDF0 00000000B ch.1 CSR1 Address: 000074H ch.0 CCRL0 bit 7 6 5 4 3 2 1 0 Initial value Address: 00006CH UDMS CTUT UCRE RLDE UDCC CGSC CGE1 CGE0 0X00X000B ch.1 CCRL1 Address: 000070H 240 bit 15 14 13 12 11 10 9 8 ch.0 CCRH0 M16E CDCF CFIE CLKS CMS1 CMS0 CES1 CES0 Address: 00006DH Initial value 00000000B bit 15 ch.1 CCRH1 Address: 000071H Initial value -0000000B 14 13 12 11 10 9 8 CDCF CFIE CLKS CMS1 CMS0 CES1 CES0 14.3.1 Counter Control Register (ch.0) Upper (CCRH0) This section shows the configuration and explains the function of counter control register (ch.0) upper (CCRH0). ■ Counter Control Register (ch.0) Upper (CCRH0) The bit configuration of counter control register (ch.0) upper (CCRH0) is shown below. Figure 14.3-2 Bit Configuration of Counter Control Register (ch.0) Upper (CCRH0) 14 13 12 11 10 9 8 bit 15 CCRH0 ch.0 Address: 00006DH M16E CDCF CFIE CLKS CMS1 CMS0 CES1 CES0 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B Counter control register (ch.0) upper (CCRH0) consists of bits that have the functions explained below. [bit15] M16E (16-bit mode permit) This bit is used to select (switch) an operation mode of 8 bits x 2 channels or 16 bits x 1 channel. M16E Setting 16-bit mode permit 0 8 bits x 2 channels operation mode (initial value) 1 16 bits x 1 channel operation mode If this bit is rewritten after its start, the count value is not assured. [bit14] CDCF (count direction reversal flag) This bit is a flag that is set when the count direction is switched. It is set in the count start mode when the count direction is switched from either up to down or down to up. The initialization (writing "0") is only permitted. Read-modify-write type instructions reads "1" irrespective of bit values. CDCF Direction reversal detection 0 No reversal of direction (initial value) 1 One or more reversals of direction 241 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER [bit13] CFIE (count direction reversal interrupt enable) If CDCF is defined, this bit is used to control interrupt output to the CPU. An interrupt generates if count direction changes even a single time in the count start mode when this bit is set to "1". CFIE Direction reversal interrupt output 0 Direction reversal interrupt output prohibit (initial value) 1 Direction reversal interrupt output permit [bit12] CLKS (built-in prescaler selection) This bit is used to select the frequency of built-in prescaler in the selection of the timer mode. It is valid in the timer mode, and only decrementing (down count) is permitted. CLKS Internal clock selected 0 2 machine cycles (initial value) 1 8 machine cycles If this bit is rewritten after its start, the count value is not assured. [bit11, bit10] CMS1, CMS0 (count mode selection) These bits are used to select the count mode. CMS1 CMS0 Count mode 0 0 Timer mode [decremented] (initial value) 0 1 Up/down count mode 1 0 Phase difference count mode: frequency multiplied by 2 1 1 Phase difference count mode: frequency multiplied by 4 If this bit is rewritten after its start, the count value is not assured. [bit9, bit8] CES1, CES0 (count clock edge selection) These bits are used to select the detection edge of external pins AIN and BIN in the up/down count mode. This setting is invalid in modes other than up/down count. CES1 CES0 Selected edge 0 0 Edge detect prohibit (initial value) 0 1 Falling edge detect 1 0 Rising edge detect 1 1 Both rising and falling edges detected If this bit is rewritten after its start, the count value is not assured. 242 14.3.2 Counter Control Register (ch.1) Upper (CCRH1) This section describes the configuration and explains the function of counter control register (ch.1) upper (CCRH1). ■ Counter Control Register (ch.1) Upper (CCRH1) The bit configuration of the counter control register (ch.1) upper (CCRH1) is shown below. Figure 14.3-3 Bit Configuration of Counter Control Register (ch.1) Upper (CCRH1) bit 15 CCRH1 ch.1 Address: 000071H 14 13 12 11 10 9 8 CDCF CFIE CLKS CMS1 CMS0 CES1 CES0 R/W R/W R/W R/W R/W R/W R/W Initial value -0000000B Counter control register (ch.1) upper (CCRH1) consists of bits that have the functions explained below. [bit14] CDCF (count direction reversal flag) This bit is set when the count direction changes. It is set in the count start mode when the count direction changes from up to down or from down to up. The initialization (writing "0") is only permitted. Read-modify-write type instructions read "1" irrespective of bit values. CDCF Direction reversal detection 0 No direction reversals (initial value) 1 One or more reversals of direction [bit13] CFIE (count direction reversal interrupt enable) This bit is used to control interrupt output to the CPU if CDCF is defined. It generates an interrupt in the count start mode when the count direction changes if this bit is set to "1". CFIE Direction reversal interrupt output 0 Direction reversal interrupt output prohibit (initial value) 1 Direction reversal interrupt output permit 243 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER [bit12] CLKS (built-in prescaler selection) This bit is used to select the frequency of built-in prescaler when the timer mode is selected. This is only valid in the timer mode, where only decrementing is permitted. CLKS Selection internal clock 0 2 machine cycles (initial value) 1 8 machine cycles If this bit is rewritten after its start, the count value is not assured. [bit11, bit10] CMS1, CMS0 (count mode selection) These bits are used to select the count mode. CMS1 CMS0 Count mode 0 0 Timer mode [decremented] (initial value) 0 1 Up/down count mode 1 0 Phase difference count mode: frequency multiplied by 2 1 1 Phase difference count mode: frequency multiplied by 4 If this bit is rewritten after its start, the count value is not assured. [bit9, bit8] CES1, CES0 (count clock edge selection) These bits are used in the up/down count mode to select a detection edge for external pins AIN and BIN. This setting is invalid in modes other than up/down count. CES1 CES0 Selected edge 0 0 Edge detect prohibit (initial value) 0 1 Falling edge detect 1 0 Rising edge detect 1 1 Both rising and falling edges detected If this bit is rewritten after its start, the count value is not assured. 244 14.3.3 Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1) This section describes the configuration and explains the function of counter control register (ch.0/ch.1) lower (CCRL0/CCRL1). ■ Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1) The bit configuration of counter control register (ch.0/ch.1) lower (CCRL0/CCRL1) is shown below. Figure 14.3-4 Bit Configuration of Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1) bit 7 6 5 4 3 2 1 0 CCRL0 ch.0 Address: 00006CH UDMS CTUT UCRE RLDE UDCC CGSC CGE1 CGE0 CCRL1 W R/W R/W W R/W R/W R/W ch.1 Address: 000070H R/W Initial value 0X00X000B Counter control register (ch.0/ch.1) lower (CCRL0/CCRL1) consists of bits that have the functions explained below. [bit7] UDMS (up/down counting mode selection) This bit is used to control the up/down counting at the falling edge of the BIN pin in the phase difference counter mode at frequency multiplied by 2. It is initialized to "0" by a reset. Read and write operations are possible. UDMS Operation 0 Decremented if the AIN pin value detected at the falling edge of the BIN pin is "H" (initial value) Incremented if the AIN pin value detected at the falling edge of the BIN pin is "L" (initial value) 1 Decremented if the AIN pin value detected at the falling edge of the BIN pin is "L" Incremented if the AIN pin value detected at the falling edge of the BIN pin is "H" If this bit is rewritten after its start, the count value is not assured. [bit6] CTUT (counter write) This bit is used to control data transfers from RCR to UDCR. If this bit is set to "1", data is transferred from RCR to UDCR. Writing "0" has no effect. 245 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER [bit5] UCRE (UDCR clear enable) This bit is used to control UDCR clear caused by compare. This does not affect the UDCR clear function (such as caused by the ZIN pin setting) other than clear because of compare generation. UCRE Counter clear caused by compare 0 Counter clear prohibit (initial value) 1 Counter clear permit [bit4] RLDE (reload enable) This bit is used to control the start of the reload function. The RCR value is transferred to UDCR if an underflow occurs when the reload function starts. RLDE Reload function 0 Reload function prohibit (initial value) 1 Reload function permit [bit3] UDCC (UDCR clear) This bit is used to clear UDCR. Writing "0" to this bit clears UDCR to "0000H". Writing "1" has no effect. [bit2] CGSC (counter clear/gate selection) This bit is used to select a function of external pin ZIN. CGSC ZIN function 0 Counter clear function (initial value) 1 Gate function [bit1, 0] CGE1, CGE0 (counter clear/gate edge selection) These bits are used to select a detection edge/level for external pin ZIN. CGE1 CGE0 For selecting the counter clear function For selecting the gate function 0 0 Edge detect prohibited (initial value) Level detect prohibited (count disable) 0 1 Falling edge "L" level 1 0 Rising edge "H" level 1 1 Setting is prohibited Setting is prohibited If this bit is rewritten after its start, the count value is not assured. 246 14.3.4 Counter Status Register 0/1 (CSR0/CSR1) This section describes the configuration and explains the function of counter status register 0/1 (CSR0/CSR1). ■ Counter Status Register 0/1 (CSR0/CSR1) The bit configuration of the counter status register 0/1 (CSR0/CSR1) is shown below. Figure 14.3-5 Bit Configuration of Counter Status Register 0/1(CSR0/CSR1) bit 7 6 5 4 3 2 1 0 CSR0 ch.0 Address: 000072H CSTR CITE UDIE CMPF OVFF UDFF UDF1 UDF0 CSR 1 R R ch.1 Address: 000074H R/W R/W R/W R/W R/W R/W Initial value 00000000B Counter status register 0/1 (CSR0/CSR1) consists of bits that have the functions explained below. [bit7] CSTR (count start) This bit is used to control the UDCR count start/stop operation. CSTR Count start/stop operation 0 Count operation stop (initial value) 1 Count operation start [bit6] CITE (compare interrupt output control) This bit is used to control permit/prohibition of interrupt output to the CPU if CMPF is defined (if a compare occurs). CITE Permit/prohibit of compare interrupt output 0 Compare interrupt output prohibited (initial value) 1 Compare interrupt output permitted [bit5] UDIE (overflow/underflow interrupt output control) This bit is used to control the permit/prohibition of interrupt output to the CPU if OVFF/UDFF is defined (if overflow/underflow occurs). UDIE Permit/prohibit of overflow/underflow interrupt output 0 Overflow/underflow interrupt output prohibited (initial value) 1 Overflow/underflow interrupt output permitted 247 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER [bit4] CMPF (compare detect flag) This bit is a flag indicating that the UDCR and RCR values match each other after a comparison. The initialization (writing "0") is only permitted. Read-modify-write type instructions read "1" irrespective of bit values. CMPF Match/no match at compare detection 0 No match in compare results (initial value) 1 Match in compare results [bit3] OVFF (overflow detect flag) This bit is a flag indicating an overflow occurred. The initialization (writing "0") is only permitted. Read-modify-write type instructions read "1" irrespective of bit values. OVFF Overflow occurrence 0 No overflow occurred (initial value) 1 Overflow occurred [bit2] UDFF (underflow detect flag) This bit is a flag indicating that an underflow occurs. The initialization (writing "0") is only permitted. Read-modify-write type instructions read "1" irrespective of bit values. UDFF Underflow occurrence 0 No underflow occurred (initial value) 1 Underflow occurred [bit1, bit0] UDF1, UDF0 (up/down flag) These bits are used to indicate the last count operation (up/down) performed. Only reading is permitted but writing is not. 248 UDF1 UDF0 Detect edge 0 0 No input (initial value) 0 1 Decremented 1 0 Incremented 1 1 Simultaneous up/down occurred 14.3.5 Up/Down Count Register (ch.0/ch.1) (UDCR0/UDCR1) Up/down count register (ch.0/ch.1) (UDCR0/UDCR1) has the configuration and function explained below. ■ Up/Down Count Register (ch.0/ch.1) (UDCR0/UDCR1) The bit configuration of the up/down count register (ch.0/ch.1) (UDCR0/UDCR1) is shown below. Figure 14.3-6 Bit Configuration of Up/Down Count Register (ch.0/ch.1) (UDCR0/UDCR1) bit 15 UDCR 1 ch.1 Address: 000069H D17 R bit 7 UDCR 0 ch.0 Address: 000068H D07 R 14 D16 R 6 D06 R 13 D15 R 5 D05 R 12 D14 R 4 D04 R 11 D13 R 3 D03 R 10 D12 R 2 D02 R 9 D11 R 1 D01 R 8 D10 R 0 D00 R Initial value 00000000B Initial value 00000000B This register is an 8-bit count register. With an internal prescaler or AIN/BIN pin input, an up/down count operation is performed. It operates as a 16-bit count register in the 16-bit count mode. In this case, the highorder 8-bit setting of the control register is disabled. This register is not allowed to write. This register must be written via RCR. The value to be written to this register must first be written to RCR, and then it is transferred from RCR value to this register by setting the CCRL: CTUT bit to "1" (reloading by software). This register uses word access for reading. 249 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER 14.3.6 Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1) This section describes the configuration and explains the function of reload/compare register (ch.0/ch.1) (RCR0/RCR1). ■ Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1) Reload/compare register (ch.0/ch.1) (RCR0/RCR1) has the bit configuration shown below. Figure 14.3-7 Bit Configuration of Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1) bit 15 RCR1 ch.1 Address: 00006BH D17 W bit 7 RCR0 ch.0 Address: 00006AH D07 W 14 D16 W 6 D06 W 13 D15 W 5 D05 W 12 D14 W 4 D04 W 11 D13 W 3 D03 W 10 D12 W 2 D02 W 9 D11 W 1 D01 W 8 D10 W 0 D00 W Initial value 00000000B Initial value 00000000B Reload/compare registers (ch.0/ch.1) (RCR0/RCR1) are used to specify a reload value and compare value. The reload value and compare value have the same value and, by starting the reload function and compare function, an up/down count is available between the "00H" and RCR values (16-bit operation mode: "0000H" to RCR value). This register allows write-only operations but not read operations. By writing "1" to the CCR0/CCR1: CTUT bit, this register value can be transferred to UDCR (reloading by software). Write to this register with word access. 250 14.4 Interrupt of 8/16-bit Up/Down Counter/Timer The interrupt of the 8/16-bit up/down counter/timer occurs when the count direction is changed only once during count start, when an match of comparison result is detected, or the overflow/underflow occurs. The DMA transfer and extended intelligent I/O service (EI2OS) cannot be activated for the interrupt of the 8/16-bit up/down counter/timer. ■ Interrupt of 8/16-bit Up/Down Counter/Timer Table 14.4-1 shows the interrupt control bit and interrupt source of the 8/16-bit up/down counter/timer. Table 14.4-1 Interrupt of 8/16-bit Up/Down Counter/Timer Count direction detection interrupt Overflow/ underflow interrupt Counter compare match interrupt Interrupt request flag CCRH0: CDCF (bit14) ch.0 CCRH1: CDCF (bit14) ch.1 CSR0: OVFF (bit3) ch.0 UDFF (bit2) CSR1: OVFF (bit3) ch.1 UDFF (bit2) CSR0: CMPF (bit4) ch.0 CSR1: CMPF (bit4) ch.1 Interrupt request output enable bit CCRH0: CFIE (bit13) ch.0 CCRH1: CFIE (bit13) ch.1 CSR0: UDIE (bit5) ch.0 CSR1: UDIE (bit5) ch.1 CSR0: CITE (bit6) ch.0 CSR1: CITE (bit6) ch.1 Interrupt generation source Up/down counter direction detection Overflow/ underflow detection Match between value of up/down counter and that of reload/compare register CCRH0 correspond to up/down counter pins (AIN0/BIN0/ZIN0). CCRH1 correspond to up/down counter pins (AIN1/BIN1/ZIN1). ● Count direction change interrupt The operation for generating the count direction change interrupt is shown below. • Bit14: CDCF flag of the counter control register (CCRH0/CCRH1) is set to "1". • While bit13: CFIE of the interrupt request (CCRH0/CCRH1) is enabled (1). When the count direction is changed only once during count start, the interrupt occurs. ● Overflow/underflow interrupt The operation for generating the overflow/underflow interrupt is shown below. • Bit5: UDIE flag of the counter status register (CSR0/CSR1) is set to "1". • If bit3: OVFF or bit2: UDFF of the counter status register (CSR0/CSR1) is set to "1", the interrupt request occurs. ● Counter compare match interrupt The operation for generating the compare interrupt is shown below. • Bit6: CITE flag of the counter status register (CSR0/CSR1) is set to "1". • When a comparison result between the UDCR value and RCR value using bit4: CMPF of the counter status register (CSR0/CSR1) matches, the interrupt request occurs. 251 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER ■ Interrupt of 8/16-bit Up/Down Counter/Timer, DMA Transfer, and EI2OS Table 14.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 14.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register Interrupt source 8/16-bit up/down counter/timer* (ch.0, ch.1) Compare/underflow/overflow/reverse up/down EI2OS clear ❍ μDMAC channel number × Interrupt vector Number #25 Address FFFF98H Interrupt control register Number ICR07 Address 0000B7H × : Interrupt request flag is not cleared. ❍ : Interrupt request flag is cleared. * : This interrupt source shares the interrupt source and interrupt number of other peripheral function. For details, see Table 4.3-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function The 8/16-bit up/down counter/timer does not correspond to the DMA transfer function, but the EI2OS function. When the EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 252 14.5 8/16-bit Up/Down Counter/Timer Operation This section explains different count modes in the 8/16-bit up/down counter/timer and the operation of the reload/compare function. ■ Selection of Count Mode The 8/16-bit up/down counter/timer has 4 types of count modes. These count modes are selected with CCRH: CMS1 or CMS0. Table 14.5-1 Selection of Count Mode CMS1 CMS0 Count mode 0 0 Timer mode (decremented) 0 1 Up/down count mode 1 0 Phase difference count mode: frequency multiplied by 2 1 1 Phase difference count mode: frequency multiplied by 4 ● Timer mode (decremented) In the timer mode, output of the internal prescaler is decremented. The built-in prescaler enables selection of either 2 machine cycles or 8 machine cycles with CCRH: CLKS. ● Up/down count mode In the up/down count mode, counting the input of external pins AIN and BIN enables an up/down count. AIN pin input controls increments, and BIN pin input controls decrements. Input of the AIN pin and BIN pin indicates an edge detection for input, enabling selection of a detection edge with CCRH: CES1 and CES0. Table 14.5-2 Selection of Edge Detection CES1 CES0 Detect edge 0 0 Edge detect prohibit 0 1 Falling edge detect 1 0 Rising edge detect 1 1 Both falling and rising edges detected ● Phase difference count mode (at frequency multiplied by 2/frequency multiplied by 4) In the phase difference count mode, to count the encoder phase difference between output signal phases A and B, the BIN pin input level is checked for counting if the AIN pin input edge is detected, and the AIN pin input level is checked for counting if the BIN pin input edge is detected. In the modes at frequency multiplied by 2 and frequency multiplied by 4, the phase difference is checked 253 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER between AIN and BIN pin inputs. If the AIN pin is advanced, it is incremented and, if the BIN pin is advanced, it is decremented. In the mode at frequency multiplied by 2, at the timing of both the rising and falling edges of the BIN pin, counting is done as required by checking for the AIN pin value. Count operations in this case are as follows: • Incremented if the AIN pin value detected at the rising edge of the BIN pin is "H" • Decremented if the AIN pin value detected at the rising edge of the BIN pin is "L" The AIN pin value detected at the falling edge of the BIN pin is selected from the following two types 1) and 2): 1) Decremented if the AIN pin value detected at the falling edge of BIN pin is "H" Incremented if the AIN pin value detected at the falling edge of the BIN pin is "L" 2) Decremented if the AIN pin value detected at the falling edge of the BIN pin is "L" Incremented if the AIN pin value detected at the falling edge of the BIN pin is "H" Figure 14.5-1 Outline of Phase Difference Count Mode (at Frequency Multiplied by 2) Operation AIN pin BIN pin Count in falling edge detect 1) Count value 0 +1 1 +1 2 +1 3 +1 4 +1 5 -1 4 +1 5 -1 4 -1 3 -1 2 -1 1 -1 0 Count in falling edge detect 2) Count value 0 +1 -1 +1 -1 +1 +1 +1 +1 -1 +1 -1 +1 1 0 1 0 1 2 3 4 3 4 3 4 In the mode at frequency multiplied by 4, the AIN pin value is checked for counting at the timing of both the BIN pin rising and falling edges. BIN pin value is checked for counting at the timing of both the AIN pin rising and falling edges. Count operations for such cases are described below. 254 • Incremented if the AIN pin value detected at the rising edge of the BIN pin is "H" • Decremented if the AIN pin value detected at the rising edge of the BIN pin is "L" • Decremented if the AIN pin value detected at the falling edge of the BIN pin is "H" • Incremented if the AIN pin value detected at the falling edge of the BIN pin is "L" • Decremented if the BIN pin value detected at the rising edge of the AIN pin is "H" • Incremented if the BIN pin value detected at the rising edge of the AIN pin is "L" • Incremented if the BIN pin value detected at the falling edge of the AIN pin is "H" • Decremented if the BIN pin value detected at the falling edge of the AIN pin is "L" Figure 14.5-2 Outline of Phase Difference Count Mode (at Frequency Multiplied by 4) Operation AIN pin BIN pin +1 +1 +1 +1 Count value 0 1 2 3 4 +1 +1 +1 +1 5 6 7 8 +1 +1 9 10 -1 9 +1 10 -1 9 -1 -1 -1 -1 8 7 6 5 -1 -1 -1 -1 4 3 2 1 In counting the encoder output, the input condition must be arranged by defining the relationship between the phases and pins shown below. Thus, high-precision detection can enable the rotation angle, rotation count, and rotation direction to be measured. • Inputting phase A to the AIN pin • Inputting phase B to the BIN pin • Inputting phase Z to the ZIN pin If this count mode is selected, the selection of detection edge via CCRH: CES1/CES0 and CCRL: CGE1/ CGE0 is disabled. 255 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER 14.5.1 Reload/Compare Function The 8/16-bit up/down counter/timer has reload and compare functions. These two functions may be mixed for processing. ■ Selection of Reload and Compare Functions Table 14.5-3 shows an example of selecting reload and compare functions. Table 14.5-3 Selection Example of Reload/Compare Function RLDE, UCRE Reload and compare functions 00B Reload/compare prohibit (initial value) 01B Compare permit 10B Reload permit 11B Reload/compare permit ■ Reload Function At the start of the reload function, the RCR value is transferred to UDCR at the timing of the down-count clock next to the clock in which an underflow occurs. In this example, UDFF is specified, and an interrupt request occurs. In a mode where there is no down counting (decrement), the start of this function is disabled. Figure 14.5-3 Outline of Reload Function Operation (0FFFFH) 0FFH Reload/interrupt generated Reload/interrupt generated RCR 00H 256 Underflow Underflow ■ Compare Function The compare function is available in any modes other than the timer mode. If RCR and UDCR values match at the start of the compare function, CMPF is specified and an interrupt request generates. When the compare clear function starts, UDCR is cleared at the next timing of the incremented clock. In a mode where there is no up counting, the start of this function is disabled. Figure 14.5-4 Outline of Compare Function Operation (0FFFFH) 0FFH Compare result matched Compare result matched RCR 00H Counter cleared, interrupt generated Counter cleared, interrupt generated ■ Up/Down Count at Any Width When a reload/compare function starts, an up/down count is available at any width. When an underflow occurs by the reload function, the RCR value is transferred to UDCR. The compare function clears UDCR if RCR and UDCR have matching values. Using both functions, an up/down count is performed in a range of 00H to RCR. Figure 14.5-5 Outline of Operation where Reload and Compare Functions Start at One Time (0FFFFH) 0FFH RCR 00H Compare result Compare result Reload matched matched Counter clear Counter clear Underflow Reload Reload Underflow Underflow Compare result matched Counter clear If a reload (underflow) occurs or compare result finds a match, an interrupt can be generated to CPU. These interrupt outputs are controlled so that they are enabled independently. The timing of reload and clear operations for UDCR varies between the count start and stop modes. 257 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER ● If reload or clear events are generated in a count operation All operations are in sync with the count clock. Figure 14.5-6 shows an example of reloading 080H. Figure 14.5-6 Normal Operation Counting UDCR 065H 066H 080H 081H ↓ Synchronized with this clock Reload/clear event Count clock ● If reload and clear events are generated before the count operation stops If counting stops in the count clock sync wait mode (state where count input is held for synchronization), reload and clear operations are performed when the stop occurs. Figure 14.5-7 shows an example of reloading 080H. Figure 14.5-7 Count Stop Operation in Count Clock Sync Signal Wait Mode UDCR 065H 066H 080H Reload/clear event Count clock Count enable Enable (count permitted) Disable (count prohibited) ● If reload and clear events are generated in the count stop mode Update of UDCR is performed when an event occurs. Figure 14.5-8 shows an example of reloading 080H. Figure 14.5-8 Operation when Reload/Clear Event Occurs in Count Stop Mode UDCR 065H 080H Reload/clear event A clear operation caused by compare is performed if the UDCR and RCR values match and incrementing (up count) occurs. Even if the UDCR and RCR values match, no clear operation is performed if a downcount or count stop occurs subsequently. A clear operation is performed at the above timing for all events other than reset input. Reload is also performed at the above timing in any event. If clear and reload events occur at the same time, the clear event has priority. 258 14.5.2 Writing Data to Up/Down Count Register (UDCR) Writing data directly to UDCR from a data bus is not permitted. This section includes procedures for writing any data to UDCR. ■ Writing Data to UDCR Data can be written to UDCR with the following procedures: 1. Data to be written to UDCR is first saved to RCR. Make sure that RCR data is discarded. 2. Writing "1" to CCRH: CTUT transfers the data from RCR to UDCR. ■ Clearing the Counter The following procedures clear the counter. • Clearing with reset input (initialize) • Clearing with an edge input from the ZIN pin • Clearing by writing "0" to CCRL: UDCC • Clearing with the compare function Such a clear operation is performed regardless of the occurrence for count start/stop. ■ Count Clear/Gate Function The ZIN pin is used by CCRH: CGSC as either a count clear or gate function. If the count clear function starts, the counter is cleared at the edge input from the ZIN pin. The edge of the ZIN pin input signal used to clear the count is selected using CCRL: CGE1/CGE0. This function is used to input the phase Z output of the encoder to the pin, enabling UDCR to be cleared at the start of encoder counting. If the gate function starts, the count is enabled or disabled depending on the level input from the ZIN pin. The level of the ZIN pin input signal used to enable the count selects using CCRL: CGE1/CGE0. This function is available for all count modes. Table 14.5-4 Selection of ZIN Pin Function CGSC ZIN pin function CGE1, CGE0 Counter clear function Gate function 0 Counter clear function 00B Detect prohibited Detect prohibited 1 Gate function 01B Rising edge "L" level 10B Falling edge "H" level 259 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER ■ Count Direction Flag, Count Direction Reversal Flag The count direction flag (UDF1, UDF0) indicates whether the last count operation was either an up-count or down-count if an up- or down-count was performed. By evaluating the count clock generated by input of both the AIN and BIN pins, a flag is updated at every count operation. If information on the current rotation direction is required for controlling the motor, it is identified by checking this flag. This function is available in all count modes. Table 14.5-5 Count Direction Flag UDF1, UDF0 Count direction 01B Down count (decrement) 10B Up count (increment) 11B Up/down simultaneously generated (no count operation performed) The count direction reversal flag (CDCF) is set when the count direction is switched between counting up and counting down. When this flag is set, an interrupt is generated to the CPU. By referring to this interrupt and the count direction flag (UDF1, UDF0), changes of direction are identified. However, note that the direction indicated by the flag may be restored to the original one and the correct count direction reversal cannot be detected after one reversal of direction if the duration of the direction reversal is short and/or occurs repeatedly. Table 14.5-6 Count Direction Reversal Flag CDCF 260 Count direction reversal detection 0 No direction reversal 1 Direction reversal (one or more times) 14.6 Program Example of 8/16-bit Up/Down Counter/Timer This section describes the program example of the 8/16-bit up/down counter/timer. ■ Program Example of 8/16-bit Up/Down Counter/Timer Example of setting procedure Program example 16-bit mode timer mode (down count) Count clock = 8 division Reload count value and generate interval interrupt. Interrupt source = underflow void UD0_sample_1(void) { UD0_initial(); UD0_start(); } <Initial setting> • Control up/down counter ch.0 void UD0_initial(void) { IO_CCR0.word = 0x9018; /*Setting value=1001_0000_0001_1000 */ /* bit15 = 1 M16E 16bit×1ch operation mode */ /* bit14 = 0 Clear CDCF count direction reversal flag */ /* bit13 = 0 Disable CFIE direction reversal interrupt */ /* bit12 = 1 CLKS 8 machine cycles */ /* bit11, bit10 = 00B CMS1, CMS0 timer mode */ Set control register Set 16-bit mode enable>> Reverse count direction>> CCR0 .M16E .CDCF .CFIE Enable count direction reversal interrupt>> Select built-in prescaler>> Select count mode>> Select count clock edge>> Select up/down mode>> Write counter>> Enable UDCR clear>> Enable reload function>> UDCR clear>> Counter clear/gate selection>> Counter clear/gate edge selection>> .CLKS .CMS1, CMS0 .CES1, CES0 .UDMS .CTUT .UCRE .RLDE .UDCC .CGSC .CGE1, CGE0 /* bit9, bit8 = 00B Disable CES1, CES0 edge detection */ /* bit7 = 0 /* bit6 = 0 /* bit5 = 0 /* bit4 = 1 /* bit3 = 1 /* bit2 = 0 /* bit1, bit0 = 00B Select UMDS up/down mode */ Write CTUT counter (invalid) */ Disable UCRE counter clear */ Enable RLDE reload function */ Clear UDCC UDCR (invalid) */ CGSC ZIN counter clear function */ Disable CGE1, CGE0 ZIN edge detection */ • Set reload value/compare value Set reload value RCR0 RCR1 IO_RCR0 = 0xff; IO_RCR1 = 0xff; /* Set 16-bit mode reload value (arbitrary value) */ IO_ICR07.byte = 0x10; __EI(); /* Set interrupt level (arbitrary value) */ /*Enable interrupt */ • Interrupt related Set UD counter 0 interrupt level Set I flag ICR07 (CCR) } void UD0_start(void) { <Start> • Start up/down counter ch.0 Register name. bit name Control underflow interrupt CSR0 .UDIE CCR0 .CTUT CSR0 .CSTR Transfer data from RCR to UDCR Start count operation <Interrupt> • Interrupt processing Check underflow detection flag Clear interrupt request flag CSR0 .UDFF (Arbitrary processing) IO_CSR0.bit.UDIE = 1; IO_CCR0.bit.CTUT = 1; IO_CSR0.bit.CSTR = 1; /* bit5 = 1 /* bit6 = 1 /* bit7 = 1 Enable UDIE underflow interrupt */ Write CTUT counter */ Activate CSTR count operation */ } __interrupt void UD0_int(void) { if(IO_CSR0.bit.UDFF) { IO_CSR0.bit.UDFF = 0; ••••• } } /* bit2 = 0 Clear UDFF underflow detection flag */ <Interrupt vector> • Set vector table #pragma intvect UD0_int 25 Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". 261 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER ■ Setting Method Other than Program Example ● Method to select 8-bit or 16-bit operation Set by the 16-bit mode enable setting bit (CCR0.M16E). Table 14.6-1 Method to Select 8-bit or 16-bit Operation Bit length of up/down counter 16-bit mode enable setting bit (M16E) To set to 8-bit Set to "0" To set to 16-bit Set to "1" ● Type of count mode and setting method There are four count modes. The count mode sets using the count mode selection bits (CCR0.CMS[1:0], CCR1.CMS[1:0]). Table 14.6-2 Type of Count Mode and Setting Method Count mode Count mode selection bit (CMS[1:0]) To set to timer mode Set to "00B" To set to up/down count mode Set to "01B" To set to phase difference count mode (2 multiplication) Set to "10B" To set to phase difference count mode (4 multiplication) Set to "11B" ● Method to select count source at timer mode operation Set by built-in prescaler selection bit (CCR0.CLKS, CCR1.CLKS). Table 14.6-3 Method to Select Count Source at Timer Mode Operation 262 Count source at timer mode operation Built-in prescaler selection bit (CLKS) To set clock that is frequency of φ divided by 2 Set to "0" To set clock that is frequency of φ divided by 8 Set to "1" ● Method to select edge when input signals (AIN, BIN) are detected at up/down counter operation Set by the count clock edge selection bits (CCR0.CES[1:0], CCR1.CES[1:0]). Table 14.6-4 Method to Select Edge when Input Signals (AIN, BIN) are Detected at Up/Down Counter Operation Count detection edge Count clock edge selection bit (CES[1:0]) To set detection prohibition Set to "00B" To set falling detection Set to "01B" To set falling detection Set to "10B" To set both-edge detection Set to "11B" ● Method to set the value to up/down counter The value can be set to the up/down counter when "1" is written to the counter write bit (CCR0.CTUT, CCR1.CTUT) after the value is written to the reload/compare register (RCR). ● Method to enable up/down counter clear when up count value of up/down counter and compare value (RCR[0:1]) match and up count is performed Set by the up/down counter clear enable bit (CCR0.UCRE, CCR1.UCRE). Table 14.6-5 Method to Enable Up/Down Counter Clear when Up Count Value of Up/Down Counter and Compare Value (RCR[0:1]) Match and Up Count is Performed Operation Up/down counter clear enable bit (UCRE) To disable up/down counter clear Set to "0" To enable up/down counter clear Set to "1" ● Method to enable the reload value (RCR[1:0]) to reload to the up/down counter when underflow of the up/down counter is generated Set by the reload enable bit (CCR0.RLDE, CCR1.RLDE). Table 14.6-6 Method to Enable the Reload Value (RCR[1:0]) to Reload to the Up/Down Counter when Underflow of the Up/Down Counter is Generated Operation Reload enable bit (RLDE) To disable the reload value (RCR) reloading from up/down counter Set to "0" To enable the reload value (RCR) to reload to up/ down counter Set to "1" 263 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER ● Method to clear up/down counter The up/down counter can be cleared using the following methods • Write "0" to the up/down counter clear bit (CCR0.UDCC, CCR1.UDCC) • Edge input to ZIN pin • Match between compare value and up count value of up/down counter • Count up operation from full count • Reset input (external reset, watchdog reset, software reset) ● Method to clear up/down counter by ZIN pin Set by the counter clear gate bit (CCR0.CGSC, CCR1.CGSC) and counter clear gate edge selection bits (CCR0.CGE[1:0], CCR1.CGE[1:0]). (valid for all count modes). Table 14.6-7 Method to Clear Up/Down Counter by ZIN Pin ZIN pin input Counter clear gate bit (CGSC) Counter clear gate edge selection bit (CGE[1:0]) To disable edge detection (no clear) Set to "0" Set to "00B" To clear up/down counter at falling edge Set to "0" Set to "01B" To clear up/down counter at rising edge Set to "0" Set to "10B" Setting GCE[1:0]=11B is prohibited ● Method to control up/down count operation by ZIN pin Set by the counter clear gate bit (CCR0.CGSC, CCR1.CGSC) and counter clear gate edge selection bits (CCR0.CGE[1:0], CCR1.CGE[1:0]). (valid for all count modes). Table 14.6-8 Method to Control Up/Down Count Operation by ZIN Pin ZIN pin input Counter clear gate bit (CGSC) Counter clear gate edge selection bit (CGE[1:0]) To disable level detection (count disabled state) Set to "1" Set to "00B" To operate up/down count at "L" level and stop up/ down count at "H" level Set to "1" Set to "01B" To stop up/down count at "L" level and operate up/ down count at "H" level Set to "1" Set to "10B" Setting GCE[1:0]=11B is prohibited 264 ● Method to enable/disable count operation of up/down counter Set by the count start bit (CSR0.CSTR, CSR1.CSTR) . Table 14.6-9 Method to Enable/Disable Count Operation of Up/Down Counter Operation Count start bit (CSR0.CSTR, CSR1.CSTR) To disable count operation of up/down counter Set to "0" To enable count operation of up/down counter (for start) Set to "1" Starting counter is depending on the count mode. Timer mode → Start count by internal clock Up/down count mode → Start count upon detection edge of AIN pin, BIN pin Phase difference count mode → Start count upon detection of phase difference of AIN pin, BIN pin However, it is necessary to detect the count operation enable level when the gate function of the ZIN pin is selected. ● Method to know the previous count direction (method to know the current rotation direction) Set by the up/down flag (CSR0.UDF[1:0], CSR1.UDF[1:0]) . Table 14.6-10 Method to Know the Previous Count Direction (Method to Know the Current Rotation Direction) Setting Up/down flag (UDF[1:0]) 00B No count after a reset 01B Down count 10B Up count 11B Up and down occur simultaneously (neither up nor down count) Because this flag has no connection the interrupt, use the count direction reversal flag (CCR0.CDCF, CCR1.CDCF) when processing the interrupt. ● Method to know direction reversal Set by the count direction reversal flag (CCR0.CDCF, CCR1.CDCF) . Table 14.6-11 Method to Know Direction Reversal Setting Count direction reversal flag (CDCF) 0 No direction reversal after flag clear 1 Direction reversal after flag clear ("1" or more) 265 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER ● Method to know a match of comparison result Set by the compare detection flag (CSR0.CMPF, CSR1.CMPF). Table 14.6-12 Method to Know a Match of Comparison Result Setting Compare detection flag (CMPF) 0 No match between count value of up/down counter and compare value 1 Match between count value of up/down counter and compare value • This flag is set to "1" when the comparison result of operation is matched regardless of the up/down operation, setting value, and reload value. ● Method to know generation of overflow/underflow Set by the overflow detect flag (CSR0.OVFF, CSR1.OVFF) and underflow detect flag (CSR0. UDFF, CSR1. UDFF). Table 14.6-13 Method to Know Generation of Overflow/Underflow (OVFF = 1) Up/down counter generates overflow (UDFF = 1) Up/down counter generates underflow ● Method to set reload value and compare value Set the value to the reload/compare registers (RCR0, RCR1) (same value is set for compare value and reload value). ● Interrupt related register The relationship between the up/down counter number, interrupt level, and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 14.6-14 Relationship Between the Up/Down Counter Number, Interrupt Level, and Interrupt Vector Source Interrupt vector Interrupt level setting register Up/down counter #25 Address : 0FFFF98H Interrupt level register (ICR07) Address : 000B7H Interrupt request flag Count direction reversal: (CCR0.CDCF), (CCR1.CDCF) Compare detection: (CSR0.CMPF), (CSR1.CMPF) Overflow: (CSR0.OVFF), (CSR1.OVFF) Underflow: (CSR0.UDFF), (CSR1.UDFF) The above interrupt request flag does not clear automatically. Write "0" to the interrupt request flag with software before returning from the interrupt processing. 266 ● Type of interrupt and selection method The following three interrupt sources are provided: count direction reversal, match of comparison result, overflow/underflow The interrupt occurs with OR of the above three interrupt sources. The interrupt source is selected by the interrupt request enable bit. ● Method to enable (select)/disable/clear interrupt Enabling (selecting)/disabling interrupt sets using the interrupt request enable bits below: Count direction reversal interrupt request enable bit: (CCR0.CFIE), (CCR1.CFIE) Compare interrupt request enable bit: (CSR0.CITE), (CSR1.CITE) Overflow/underflow interrupt request enable bit: (CSR0.UDIE), (CSR1.UDIE) Table 14.6-15 Method to Enable (Select)/Disable/Clear Interrupt Control Interrupt request enable bit (CFIE, CITE, UDIE) To disable interrupt request Set to "0" To enable interrupt request Set to "1" Clearing interrupt request sets using the interrupt request bits below: Count direction reversal: (CCR0.CDCF), (CCR1.CDCF) Compare detection: (CSR0.CMPF), (CSR1.CMPF) Overflow: (CSR0.OVFF), (CSR1.OVFF) Underflow: (CSR0.UDFF), (CSR1.UDFF) Table 14.6-16 Method to Clear Interrupt Request Control Interrupt request bits (CDCF, CMPF, OVFF, UDFF) To clear interrupt request Write "0" 267 CHAPTER 14 8/16-BIT UP/DOWN COUNTER/TIMER 268 CHAPTER 15 16-BIT RELOAD TIMER This chapter provides an overview of the 16-bit reload timer and its operation and explains the configuration and functions of its registers. 15.1 Overview of 16-Bit Reload Timer 15.2 Configuration and Functions of 16-Bit Reload Timer Registers 15.3 Interrupt of 16-Bit Reload Timer 15.4 Operations of the 16-Bit Reload Timer 15.5 Program Example of 16-Bit Reload Timer 269 CHAPTER 15 16-BIT RELOAD TIMER 15.1 Overview of 16-Bit Reload Timer The 16-bit reload timer has the following functions: • Clock mode can be selected from the internal clock mode and event count mode. • When an underflow of 16-bit timer register (TMR) occurred, the count operation can select from the reload mode to continue its operation after the one-shot mode to stop the operation and count setting value are reloaded. • When an underflow of 16-bit timer register (TMR) generated, the timer can be used as the interval timer by generating an interrupt. ■ Operation Modes of the 16-bit Reload Timer Operation modes of the 16-bit reload timer are shown below. Table 15.1-1 Operation Modes of the 16-bit Reload Timer Clock mode Counting Reload mode Internal clock mode One-shot mode Event count mode (External clock mode) 16-bit reload timer operation Software trigger operation External trigger operation External gate input operation Reload mode Software trigger operation One-shot mode ■ Internal Clock Mode One type of count clock can be selected among three types of internal clocks to enable the following operations: ● Software trigger operation Sets the TRG bits of the timer control status register (TMCSR) to "1" to start a counting operation. Trigger input can also be enabled by the TRG bit when external trigger operation and external gate input operation are performed. ● External trigger operation Starts counting as soon as the selected edge (rising, falling edges, or both) is input to the TIN0 pin. ● External gate input operation Continues counting if a signal of the selected signal level ("L" or "H") is input to the TIN0 pin. ■ Event Count Mode (External Clock Mode) A mode in which countdown starts as soon as an edge with a valid edge selected (rising, falling, or both) is input to the TIN0 pin. This can also be used to provide an interval timer if an external clock with constant interval time is used. 270 ■ Counter Operation Modes ● Reload mode If countdown causes an underflow("0000H" --> "FFFFH"), the specified count value is reloaded to continue with counting. An underflow can generate an interrupt request that can then be used to provide an interval timer. A toggle waveform that reverses itself at every underflow is used to output from the TOT0 pin. Count clock Internal clock External clock Count clock interval Interval time φ / 21 (80 ns) 80 ns to 5.243 ms φ / 23 (0.32 μs) 0.32 μs to 20.972 ms φ / 25 (1.28 μs) 1.28 μs to 83.886 ms φ / 23 (0.32 μs) 0.32 μs or more Notes: • Machine cycle (φ) = 25 MHz Example) 25 MHz/21 = 12.5 MHz = 80 ns • Maximum value of interval time is 0000H to FFFFH. : Example) φ/21(80 ns) × 65536 = 5.243 ms ● One-shot mode If countdown generates an underflow ("0000H" → "FFFFH"), counting will stop. An underflow is generated an interrupt. While counting is in progress, a square wave that indicates that counting is in progress is output from the TOT0 pin. Reference: The 16-bit reload timer can be used to trigger A/D converter operation. 271 CHAPTER 15 16-BIT RELOAD TIMER ■ Block Diagram of the 16-bit Reload Timer Figure 15.1-1 Block Diagram of the 16-bit Reload Timer Internal data bus TMRLR 16-bit reload register Reload signal TMR Reload control circuit 16-bit timer register (down-counter) UF CLK Count clock generation circuit Machine clock frequency φ 3 Prescaler Gate input Circuit to determine which clock is valid Clear Wait signal CLK To A/D converter Output signal generation circuit Reversed Pin (TIN0) Input control circuit Output signal generation circuit Clock selector External clock Function selection 3 Selection signal Pin (TOT0) EN 2 OUTL RELD Operation control circuit OUTE Timer control status register (TMCSR) ■ Pin Related to 16-bit Reload Timer The pin related to the 16-bit reload timer has the TIN0 and TOT0 pins. The TIN0 pin functions as the general-purpose I/O port (P73/TIN0) and the input pin of the 16-bit reload timer. The TOT0 pin functions as the general-purpose I/O port (P74/TOT0) and the output pin of the 16-bit reload timer. ● Setting when using as TIN0 pin When the TIN0 pin is used as input, P73/TIN0 pin should be set to the input port by the port direction register (DDR7 bit3→"0"). ● Setting when using as TOT0 pin When the using TOT0 pin is used as output, be sure to set the timer control status register (TMCSR) to output enable (OUTE bit6→"1"). 272 ■ Block Diagram of Pin Related to 16-bit Reload Timer Figure 15.1-2 Block Diagram of Pin Related to 16-bit Reload Timer Peripheral function input (TIN0) Port data register (PDR) Peripheral function output (TOT0) Peripheral function output enable Open drain control signal (P73/P74) Internal data bus PDR Read Output latch P-ch Pin PDR Write Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Stand-by control (SPL=1) Stand-by control: Stop mode (SPL=1), Time-base timer mode (SPL=1), Watch mode (SPL=1) 273 CHAPTER 15 16-BIT RELOAD TIMER 15.2 Configuration and Functions of 16-Bit Reload Timer Registers This section describes the configuration and functions of the registers used in the 16bit reload timer. ■ Configuration of 16-bit Reload Timer Registers Figure 15.2-1 shows the registers of the 16-bit reload timer. Figure 15.2-1 16-bit Reload Timer Registers bit 0000CBH 15 (-) (-) 14 (-) (-) 13 (-) (-) 12 (-) (-) 11 10 9 8 CSL1 CSL0 MOD2 MOD1 (R/W) (R/W) (R/W) (R/W) (0) (0) (0) (0) TMCSR Timer control status register (upper bits) Reading/writing Initial value bit 7 6 5 4 3 2 1 0 TMCSR 0000CAH MOD0 OUTE OUTL RELD INTE UF CNTE TRG Timer control status register(lower bits) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Reading/writing (0) (0) (0) (0) (0) (0) (0) (0) Initial value bit 15 0000CDH D15 14 D14 13 D13 12 D12 11 D11 10 D10 9 D09 8 D08 TMR/TMRLR 16-bit timer register/ 16-bit reload register (upper bits) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Reading/writing (X) (X) (X) (X) (X) (X) (X) (X) Initial value bit 7 0000CCH D07 6 D06 5 D05 4 D04 3 D03 2 D02 1 D01 0 D00 TMR/TMRLR 16-bit timer register/ 16-bit reload register (lower bits) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Reading/writing (X) (X) (X) (X) (X) (X) (X) (X) Initial value 274 15.2.1 Timer Control Status Register (TMCSR) This section describes the configuration and functions of the timer control status register (TMCSR). ■ Timer Control Status Register (TMCSR) The timer control status register (TMCSR) is used to control the operation mode and interrupts of the16-bit reload timer. If CNTE = 0, bits other than UF/CNTE/TRG are modified. The figure below shows the bit configuration of the timer control status register (TMCSR). Figure 15.2-2 Bit Configuration of the Timer Control Status Register (TMCSR) bit 0000CBH 15 (-) (-) 14 (-) (-) 13 (-) (-) 12 (-) (-) 11 10 9 8 CSL1 CSL0 MOD2 MOD1 (R/W) (R/W) (R/W) (R/W) (0) (0) (0) (0) TMCSR Timer control status register (upper bits) Reading/writing Initial value bit 7 6 5 4 3 2 1 0 TMCSR 0000CAH MOD0 OUTE OUTL RELD INTE UF CNTE TRG Timer control status register(lower bits) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Reading/writing (0) (0) (0) (0) (0) (0) (0) (0) Initial value The functions of the bits in the timer control status register (TMCSR) are described below. [bit11, bit10] CSL1, CSL0 (Clock selection) These bits are used to select the clock source using the count clock selection bit. Clock source (machine clock φ = 25 MHz) CSL1 CSL0 0 0 φ/21 (0.08 μs) (initial value) 0 1 φ/23 (0.32 μs) 1 0 φ/25 (1.28 μs) 1 1 Event count mode [bit9, bit8, bit7] MOD2, MOD1, MOD0 These bits set the operation mode and the input/output pin functions. With MOD2 = 0, the input pin operates as a trigger. If an active edge is input to the input pin while count operation is in progress, the data from the reload register is loaded into the counter. With MOD2 = 1, the timer operates in gate counter mode and the input pin operates as a gate input. In this mode, the counter only counts when the active level is applied to the input pin. By combination of the MOD2 to MOD0 bits, the internal clock mode and event counter mode can be selected from the modes listed in Table 15.2-1 and Table 15.2-2. 275 CHAPTER 15 16-BIT RELOAD TIMER Table 15.2-1 Internal Clock Mode (CLS1/CLS0 = 00B, 01B, or 10B) MOD2 MOD1 MOD0 0 0 0 0 0 1 0 1 0 0 1 1 1 X 0 Input pin function Trigger invalid Active edge or level - (Initial value) Rising edge Trigger input Falling edge Both edges "L" level Gate input 1 X 1 "H" level Table 15.2-2 Event Count Mode (CLS1, CLS0 = 11B) MOD2 MOD1 MOD0 X 0 0 X 0 1 X 1 0 X 1 1 Input pin function Trigger invalid Active edge or level - (Initial value) Rising edge Trigger input Falling edge Both edges [bit6] OUTE (Output enable) This bit is used to control output enable. The TOT pin operates as a general-purpose port if the OUTE bit is set to "0", or as a timer output pin if the OUTE bit is set to "1". In reload mode, the output waveform becomes a toggle waveform. In oneshot mode, the TOT pin outputs a square wave that indicates the counting is in progress. OUTE Function 0 General-purpose port (initial value) 1 Timer output [bit5] OUTL (Output level) This bit is used to specify the output level of the TOT pin. Depending on whether OUTL is set to "0" or "1", the output pin level becomes reversed. 276 OUTL One-shot mode (RELD = 0) Reload mode (RELD = 1) 0 Square wave of "H"-level in counting mode 0 (Initial value) 1 Square wave of "L" level in counting mode 1 X 1 0 X 1 1 [bit4] RELD (Reload operation enable) This bit enables reload operation. With RELD set to "1", the timer operates in reload mode. In this mode, the timer loads the reload register data into the counter and continues counting if an underflow occurs. With RELD set to "0", the timer operates in one-shot mode. If an underflow occurs in this mode, counter operation stops. RELD Function 0 One-shot mode (initial value) 1 Reload mode [bit3] INTE (Timer interrupt request enable) This bit is used to enable timer interrupt requests. With INTE = 0, no interrupt request is generated even if UF is set to "1". INTE Function 0 Interrupt request output prohibited (initial value) 1 Interrupt request output allowed Note: Please write "0" in the INTE bit, after prohibiting interrupt by setting the IL2 bit to IL0 bit of the interrupt control register to "111B", if the reload timer underflow interrupt setting is changed from enable (INTE bit of TMCSR registers =1) to prohibit (INTE bit of TMCSR registers =0). [bit2] UF (Timer interrupt request flag) This bit is used as a timer interrupt request flag. If an underflow occurs, UF is set to "1". It is cleared by writing "0" or by μDMAC. Writing "1" has no effect. Read-modify-write instruction always reads "1". UF At reading At writing 0 No counter underflow (initial value) This bit is cleared (initial value) 1 Counter underflow generated No change (no effect on others) [bit1] CNTE (Timer counter enable) This bit enables the timer counter. CNTE Function 0 Counter operation stopped (initial value) 1 Counter operation allowed (start trigger wait) 277 CHAPTER 15 16-BIT RELOAD TIMER [bit0] TRG (Software trigger) This bit operates as a software trigger bit. With TRG set to "1", a software trigger is applied, data from the timer reload register is loaded into the counter and counting starts. Writing "0" has no effect. Read operations always read "0". Only when CNTE = 1, this bit is valid irrespective of the operation mode. TRG 278 Function 0 No change (initial value) 1 Count operation start 15.2.2 16-Bit Timer Register (TMR)/16-Bit Reload Register (TMRLR) This section describes the configuration and functions of the 16-bit timer register (TMR)/16-bit reload register (TMRLR). ■ 16-bit Timer Register (TMR)/16-bit Reload Register (TMRLR) The bit configuration of the 16-bit timer register (TMR)/16-bit reload register (TMRLR) is shown below. Figure 15.2-3 Bit Configuration of the 16-bit Timer Register (TMR)/16-bit Reload Register (TMRLR) bit 15 14 13 12 11 10 9 8 0000CDH D15 D14 D13 D12 D11 D10 D09 D08 TMR/TMRLR (upper bits) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Reading/writing (X) (X) (X) (X) (X) (X) (X) (X) Initial value bit 7 6 5 4 3 2 1 0 0000CCH D07 D06 D05 D04 D03 D02 D01 D00 TMR/TMRLR (lower bits) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) (R/W) Reading/writing (X) (X) (X) (X) (X) (X) (X) (X) Initial value ■ 16-bit Timer Register (TMR) This register reads the counter value of the 16-bit decrement counter. If counter operation is enabled (TMCSR: CNTE = 1) and counting starts, the value in the 16-bit reload register is loaded into this register to start count-down. In count stop state (TMCSR: CNTE = 0), the value of this register is retained. Note: This register can be read during count operation, but always use a word transfer instruction (such as "MOVW A 003AH"). The 16-bit timer register (TMR) is functionally a read-only register, though it is allocated at the same address as the write-only 16-bit reload register (TMRLR). Thus, write operations will not affect the TMR value, even though writing to TMRLR is performed. 279 CHAPTER 15 16-BIT RELOAD TIMER ■ 16-bit Reload Register (TMRLR) The 16-bit reload register sets the initial counter value while count operation is disabled (TMCSR: CNTE=0). When the counter is started by enabling counter operation (TMCSR: CNTE=1), the count-down will start from the value that was written to this register. The value set in this register is reloaded to the counter in reload mode if an underflow occurs, and count-down continues. In one-shot mode, the counter stops at "FFFFH" after an underflow occurs. Note: Write to this register only in counter stop mode (TMCSR: CNTE = 0), and always write by using a word transfer instruction (such as "MOVW A 003AH"). The 16-bit reload register (TMRLR) is functionally a write-only register; however, it is allocated at the same address as the read-only 16-bit timer register (TMR). Thus, the valid returned value in read operations is the value of the TMR value. Read-modify-write (RMW) instructions (such as the INC or DEC instructions) cannot be used. 280 15.3 Interrupt of 16-Bit Reload Timer The interrupt of the 16-bit reload timer generates when underflow of the counter is detected. The underflow interrupt of counter can activate the DMA transfer and extended intelligent I/O service (EI2OS). ■ Interrupt of 16-bit Reload Timer Table 15.3-1 shows the interrupt control bit and interrupt source of the 16-bit reload timer. Table 15.3-1 Interrupt of 16-bit Reload Timer Reload timer Underflow interrupt Interrupt request flag TMCSR: UF (bit2) Interrupt request output enable bit TMCSR: INTE (bit3) Interrupt generation source Underflow of 16-bit reload timer When the value of the TMR is decremented from "0000H" to "FFFFH" during the TMR count operation, an underflow occurs. When an underflow occurs, the underflow generation flag (UF = 1) in the timer control status register (TMCSR) is set. When an underflow interrupt is enabled (INTE = 1), an interrupt request is generated. ■ Interrupt of 16-bit Reload Timer, DMA Transfer, and EI2OS Table 15.3-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 15.3-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register Interrupt source 16-bit free-run timer overflow, * 16-bit reload timer underflow EI2OS clear μDMAC channel number Number Address Number Address ❍ 12 #35 FFFF70H ICR12 0000BCH Interrupt vector Interrupt control register ❍: Interrupt request flag is cleared. * : This interrupt source shares the interrupt source and interrupt number of other peripheral function.For details, see Table 4.2-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function The 16-bit reload timer corresponds to the DMA transfer function and EI2OS function. When the DMA or EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 281 CHAPTER 15 16-BIT RELOAD TIMER 15.4 Operations of the 16-Bit Reload Timer This section describes the settings of the 16-bit reload timer. ■ Settings of the 16-bit Reload Timer ● Settings for Internal Clock Mode For interval timer operation, the settings shown in Figure 15.4-1 are required. Figure 15.4-1 Settings of Internal Clock Mode bit 15 - TMCSR 14 13 12 - - - 11 10 9 8 7 6 5 4 3 CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE 2 UF 1 0 CNTE TRG 1 Other than "11B" Initial counter value setting (reload value) TMRLR : Bit used 1 : Set to "1" ● Settings for event count mode For event count mode operation, the settings shown in Figure 15.4-2 are required. Figure 15.4-2 Settings of Event Counter Mode bit 15 - TMCSR 14 13 12 - - - 11 1 TMRLR 10 9 8 7 5 4 1 Initial counter value setting (reload value) DDR9 : Bit used 1 : Set to "1" : Set the bit corresponding to the used pin to "0" 282 6 3 CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE 2 UF 1 0 CNTE TRG 1 15.4.1 State Transitions During Count Operation This section describes the state transitions during count operation. ■ State Transitions during Count Operation Figure 15.4-3 State Transition during Counter Operation STOP state CNTE=1, WAIT=1 TIN pin: Input disabled TOT pin: General-purpose port Counter: Retains the value at stop. Undefined immediately after reset. Reset CNTE=0 CNTE=0 CNTE=1 TRG=0 WAIT state CNTE=1, WAIT=1 TIN pin: Valid for trigger input only TOT pin: Initial value output Counter: Retains the value at stop. Undefined until load immediately after reset. TRG=1 (Software trigger) External trigger from TIN CNTE=1 TRG=1 UF=1 & RELD=0 RUN state CNTE=1, WAIT=0 TIN pin: Functions as TIN pin. TOT pin: Functions as TOT pin. One-shot mode Counter: Operation UF=1 & RELD=1 TRG=1 Reload mode (Software trigger) LOAD CNTE=1, WAIT=0 Loads the reload register value into Load end the counter. : State transition by hardware : State transition by register access WAIT : WAIT signal (internal signal) TRG : Software trigger bit in timer control status register (TMCSR) CNTE : Counter enable bit in timer control status register (TMCSR) : Underflow interrupt request flag in timer control status register (TMCSR) UF RELD : Reload selection bit in timer control status register (TMCSR) 283 CHAPTER 15 16-BIT RELOAD TIMER 15.4.2 Operations of Internal Clock Mode (Reload Mode) The counter operates in sync with the internal count clock to count down the 16-bit counter and generate an interrupt request to the CPU in case of counter underflow. The counter also outputs a toggle waveform from the timer output pin. ■ Operations of Internal Clock Mode (Reload Mode) If, with count operation enabled (TMCSR: CNTE = 1), the software trigger bit (TMCSR: TRG) or external trigger is set to start the timer, the value in the reload register (TMRLR) is loaded into the counter, and counter operation starts. If both the counter enabled bit and the software trigger bit become "1" at the same time, counting will start as soon as counter operation is enabled. If the counter value causes an underflow(0000H --> FFFFH), the value in the 16-bit reload register (TMRLR) is loaded into the counter to continue with the counting operation. At this time, the underflow interrupt request flag bit (UF) is set to "1", and if the interrupt request enable bit (INTE) is set to "1", an interrupt request is generated. It outputs a toggle waveform that is inverted at every underflow via the TOT pin. ● Software trigger operation With the TRG bit of the timer control status register (TMCSR) set to "1", the counter is started. Figure 15.4-4 shows the software trigger operation for a reload. Figure 15.4-4 Count Operation in Reload Mode (Software Trigger Operation) Count clock Reload data Counter -1 0000H Reload data -1 0000H Reload data -1 0000H Reload data Data load signal UF bit CNTE bit TRG bit T* TOT pin T : Machine cycle * : The time from trigger input to loading the reload data is 1T. 284 -1 ● External trigger operation The counter is started if a valid edge (rising, falling, or both edges can be selected) is input to the TIN pin. Figure 15.4-5 shows the external trigger operation in reload mode. Figure 15.4-5 Count Operation in Reload Mode (External Trigger Operation) Count clock Counter Reload data -1 0000H Reload data -1 0000H Reload data -1 0000H Reload data -1 Data load signal UF bit CNTE bit TIN pin * TOT pin 2T to 2.5T T : Machine cycle * : It takes 2T to 2.5T from external trigger input to loading reload data. Note: The trigger pulse width input to the TIN pin shall be 2T (T: machine cycle) or more. 285 CHAPTER 15 16-BIT RELOAD TIMER ● External gate input operation Counting starts when the software trigger bit (TRG) is set to "1" while the count enable bit (CNTE) of the timer control status register (TMCSR) is set to "1". Counting starts when a valid level ("L" level or "H" level can be selected) of gate input specified in the operation mode setting bits(MOD2, MOD1, and MOD0) is input to the TIN pins. Figure 15.4-6 Count Operation in Reload Mode (External Gate Input Operation) Internal count clock Reload data Counter -1 -1 -1 0000H Reload data -1 -1 Data load signal UF bit CNTE bit TRG bit TIN pin 1T* TOT pin T : Machine cycle * : It takes 1T from trigger input to loading reload data. Note: The trigger pulse width input to the TIN pin shall be 2T (T: machine cycle) or more. 286 15.4.3 Internal Clock Mode (One-Shot Mode) The counter is in synchronization with the internal count clock in this mode to count down the 16-bit counter and generate an interrupt request to the CPU at counter underflow. It also outputs a square wave from the TOT pin to indicate that counting is in progress. ■ Operation of Internal Clock Mode (One-Shot Mode) When count operation is allowed (TMCSR: CNTE=1) and the timer is started by the software trigger bit (TMCSR: TRG) or external trigger, count operation will start. When both the count enable bit and software trigger bit are set to "1", counting will start at the same time counting becomes enabled. If the counter value causes an underflow (0000H --> FFFFH), the counter stops at "FFFFH", and the underflow flag bit for interrupt requests (UF) is set to "1". If the enable bit for interrupt request (INTE) is set to "1", an interrupt request generates. The TOT pin outputs a square wave to indicate that counting is in progress. ● Software Trigger Operation The counter will be started as soon as the TRG bit of the timer control status registers (TMCSR) is set to "1". Figure 15.4-7 shows the software trigger operation in one-shot mode. Figure 15.4-7 Count Operation in One-Shot Mode (Software Trigger Operation) Count clock Reload data Counter 0000H FFFFH Reload data 0000H FFFFH Data load signal UF bit CNTE bit TRG bit T* TOT pin Waiting for start trigger input T : Machine cycle * : It takes 1T from trigger input to loading reload data. 287 CHAPTER 15 16-BIT RELOAD TIMER ● External trigger operation When a valid edge (leading, trailing, or both can be selected) is input to the TIN pins, the counter will be started operation. Figure 15.4-8 shows the external trigger operation in one-shot mode. Figure 15.4-8 Count Operation in One-Shot Mode (External Trigger Operation) Count clock Counter Reload data -1 0000H FFFFH Reload data -1 0000H FFFFH Data load signal UF bit CNTE bit TIN pin 2T to 2.5T TOT pin Waiting for start trigger input T: Machine cycle * : It takes 2T to 2.5T from external trigger input to loading reload data. Note: The trigger pulse width input to the TIN pin shall be 2T (T: machine cycle) or more. 288 ● External gate input operation When a valid level ("H" and "L" level can be selected) is input to the TIN pin, the counter starts operation. Figure 15.4-9 shows the gate input operation in one-shot mode. Figure 15.4-9 Count Operation in One-Shot Mode (External Gate Input Operation) Internal count clock Reload data Counter Reload data Data load signal UF bit CNTE bit TRG bit TIN pin 1T* TOT pin T : Machine cycle * : It takes 1T from trigger input to loading reload data. Note: The trigger pulse width input to the TIN pin shall be 2T (T: machine cycle) or more. 289 CHAPTER 15 16-BIT RELOAD TIMER 15.4.4 Event Count Mode In this mode, the counter counts input edges from the TIN pin to count down the 16-bit counter and generate an interrupt request to the CPU when a counter underflow occurs. The TOT pin can output either a toggle waveform or a square wave. ■ Event Count Mode When count operation is allowed (TMCSR: CNTE=1) to start the counter (TMCSR: TRG=1), data from the 16-bit reload registers (TMRLR) is loaded into the counter for a countdown whenever a valid edge (leading, trailing, or both edges can be selected) of pulses (external count clock) input to the TIN pin is detected. When both the count enable bit and software trigger bit are set to "1", counting will start as soon as counting becomes enabled. ● Operation in reload mode If the counter value has an underflow (0000H --> FFFFH), data from the 16-bit reload registers (TMRLR) is loaded into the counter to continue counting. In this case, an interrupt request is issued when the underflow flag bit for interrupt requests (UF) and enable bit for interrupt requests (TMCSR: INTE) are both set to "1". The TOT pin outputs a toggle waveform, which is reversed at every occurrence of underflow. Figure 15.4-10 shows the counting operation in reload mode. Figure 15.4-10 Count Operation in Reload Mode (Event Count Mode) TIN pin Reload data Counter -1 0000H Reload data -1 0000H Reload data -1 0000H Reload data -1 Data load signal UF bit CNTE bit TRG bit T* TOT pin T: Machine cycle * : It takes 1T from trigger input to loading reload data. Note: Both the "H" width and "L" width of clock input to the TIN pin shall be 4T (T: machine cycle) or more. 290 ● Operation in one-shot mode If the counter value causes an underflow (0000H --> FFFFH), the counter stops at FFFFH. In this case, the underflow request flag bit (UF) is set to "1". If the interrupt request enable bit (INTE) is also set to "1", an interrupt request is generated. The TOT pin outputs a square wave that indicates counting in progress. Figure 15.4-11 shows the count operation in one-shot mode. Figure 15.4-11 Count Operation in One-Shot Mode (Event Count Mode) TIN pin Reload data Counter -1 0000H FFFFH Reload data -1 0000H FFFFH Data load signal UF bit CNTE bit TRG bit T* TOT pin Waiting for start trigger input T : Machine cycle * : It takes 1T from trigger input to loading reload data. Note: Both the "H" width and "L" width of clock input to the TIN pin shall be 4T (T: machine cycle) or more. 291 CHAPTER 15 16-BIT RELOAD TIMER 15.5 Program Example of 16-Bit Reload Timer This section explains the program example of the 16-bit reload timer. ■ Program Example of 16-bit Reload Timer Example of setting procedure Program example Software trigger output pulse from TOT0, duty1/2, normal polarity void RT_sample(void) { RT_initial(); RT_start(); } <Initial setting> void RT_initial(void) { IO_TMRLR = 0xAA ; • Setting Set reload value • Control reload timer 0 Set control register Select clock source>> Select trigger>> Enable output>> Select output level>> Select operation mode>> Disable interrupt>> Clear interrupt flag>> Stop count>> Software trigger (no processing) Register name. bit name TMRLR TMCSR .CSL1,CSL0 .MOD .OUTE .OUTL .RELD .INTE .UF .CNTE .TRG IO_TMCSR.word = 0x0050; /* Setting value =0000_0000_0101_0000 */ /* bit15 to bit12=0000B Undefined bit */ /* bit11, bit10=00B • Interrupt related Interrupt level of reload timer Set I flag /* Insert any value for reload value */ ICR12 (CCR) IO_ICR12.byte =0x10; __EI(); CSL1,CSL0 internal clock φ/2 */ /* bit9 to bit7=000B MOD software trigger */ /* bit6=1 /* bit5=0 /* bit4=1 /* bit3=0 /* bit2=0 /* bit1=0 /* bit0=0 Enable OUTE output */ OUTL external output level Low */ Enable RELD reload */ Disable INTE interrupt */ Clear UF interrupt request flag */ Stop CNTE count */ TRG software trigger */ /* Set interrupt level */ /* Enable interrupt */ } <Start> • Start reload timer Register name. bit name Start PPG Clear interrupt flag>> Enable interrupt>> Enable count>> Software trigger (start)>> TMCSR UF .INTE .CNTE .TRG <Interrupt> • Interrupt processing (Arbitrary processing) Clear interrupt request flag TMCSR.UF void RT_start(void) { IO_TMCSR.word = 0x005B; /* bit3=1 /* bit2=0 /* bit1=1 /* bit0=1 Enable INTE interrupt */ Clear UF interrupt request flag */ Start CNTE count */ TRG software trigger */ } __interrupt void RT_int(void) { ........ IO_TMCSR.bit.UF = 0; } /* Interrupt occurs at generation of underflow */ /* Any processing operation */ /* bit2=0 Clear UF interrupt request flag */ Interrupt vector • Set vector table #pragma intvect RT_int 35 Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". 292 ■ Setting Method Other than Program Example ● Method to set (rewrite) reload value The reload value sets to the 16-bit reload register (TMRLR). The following shows the calculation formula of the set value. <Formula> TMRLR register value = {Reload interval/count clock} -1 <Range that can be set> TMRLR register value = 0H to FFFFH (65535) ● Type of count clock and selection method The count clock can be selected by the count clock selection bits (TMCSR.CSL[1:0]) from four kinds of clocks as shown in the following table. Table 15.5-1 Type of Count Clock and Selection Method Count clock Count clock selection bits Example of count clock CSL1 CSL0 At φ = 32MHz At φ = 16MHz At φ = 8MHz φ/2 0 0 62.5ns 125ns 250ns φ/8 0 1 250ns 500ns 1.0μs φ/32 1 0 1.0μs 2.0μs 4.0μs External event 1 1 Pulse width: 2/φmin ● Method to enable/stop count operation of reload timer Set by the count enable bit (TMCSR.CNTE) of the timer. Table 15.5-2 Method to Enable/Stop Count Operation of Reload Timer Content of control Operation enable bit (CNTE) To stop reload timer Set to "0" To enable count operation of reload timer Set to "1" It cannot restart from the stopped state. Operation is enabled before or simultaneously starting it. 293 CHAPTER 15 16-BIT RELOAD TIMER ● Method to set mode (reload/one-shot) of reload timer Set by the mode selection bit (TMCSR.RELD). Table 15.5-3 Method to Set Mode (Reload/One-shot) of Reload Timer Operation mode Mode selection bit (RELD) To set to one-shot Set to "0" To set to reload Set to "1" ● Method to reverse output level The output level is shown in the following table. Set by the timer output level bit (TMCSR.OUTL). Table 15.5-4 Method to Reverse Output Level Output level Timer output level bit (OUTL) Reload mode, "L" level output of initial value Set to "0" L Reload mode, "H" level output of initial value (Reverse) Set to "1" H One-shot mode, "H" level output while counting Set to "0" H One-shot mode, "L" level output while counting (Reverse) Set to "1" L 294 ● Start method • There are four start triggers in the internal clock mode. Set by the trigger selection bits (TMCSR. MOD[2:0]). Table 15.5-5 Start Triggers in the Internal Clock Mode Trigger Trigger setting bits (MOD[2:0]) Software trigger (set TRG bit) Set to "000" External trigger from TIN0 pin (rising edge) Set to "001" External trigger from TIN0 pin (falling edge) Set to "010" External trigger from TIN0 pin (both edge) Set to "011" • Event count mode is activated with software. The counter enable bit (CNTE) and software trigger bit (TRG) in the timer control status register (TMCSR) are set to "1" simultaneously. ● Type of valid edge in event count mode and selection method Set by the trigger selection bits (TMCSR.MOD[1:0]). Three valid edges are provided. Table 15.5-6 Type of Valid Edge in Event Count Mode and Selection Method Valid edge Trigger selection bits (MOD1, MOD0) Rising edge Set to "01" Falling edge Set to "10" Both edges Set to "11" Setting MOD2 has no meaning regardless of the value of "0" or "1". ● Method to set TIN pin to external event input pin or external trigger input pin "0" is written to the data direction specification bit (DDR7.P73). Table 15.5-7 Method to Set TIN Pin to External Event Input Pin or External Trigger Input Pin Pin TIN0 pin Control bit Port 7 direction register (DDR7) Data direction bit (P73) 295 CHAPTER 15 16-BIT RELOAD TIMER ● Method to generate start trigger • Method to generate software trigger Set by the software trigger bit (TMCSR.TRG). Writing "1" to the software trigger bit (TGR) generates the trigger. To enable and start operation at the same time, set the count enable bit (TMCSR.CNTE) and software trigger bit (TMCSR.TRG) simultaneously. • Method to generate external trigger When the edge specified by the trigger selection bits is input to the trigger pin corresponding to each reload timer, the trigger occurs. Table 15.5-8 Method to Generate Start Trigger Timer Trigger pin Reload timer TIN0 ● Interrupt related register The relationship among the reload timer number, interrupt level, and interrupt vector, and interrupt control register is shown below. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 15.5-9 Relationship Among the Reload Timer Number, Interrupt Level, and Interrupt Vector, and Interrupt Control Register Reload timer Interrupt vector Interrupt level setting register #35 Address: 0FFFF70H Interrupt control register 12 (ICR12) Address: 000BCH Clear the interrupt request flag (TMCSR.UF) by writing "0" to the UF bit before returning from the interrupt processing because the flag is not cleared automatically. 296 ● Method to enable interrupt Interrupt request enabled, interrupt request flag Enabling interrupt is set by the interrupt request enable bit (TMCSR.INTE). Table 15.5-10 Method to Enable Interrupt Interrupt request enable bit (INTE) To disable interrupt request Set to "0" To enable interrupt request Set to "1" The interrupt request is cleared by the interrupt request bit (TMCSR.UF). Table 15.5-11 Method to Clear Interrupt Request Interrupt request bit (UF) To clear interrupt request Set to "0" Note: Please write "0" in the INTE bit, after prohibiting interrupt by setting the IL2 to IL0 bit of the interrupt control register to "111B", if the reload timer underflow interrupt setting is changed from enable (INTE bit of TMCSR registers =1) to prohibit (INTE bit of TMCSR registers =0). ● Method to stop reload timer Set by the reload timer stop bit. Table 15.5-12 Method to Stop Reload Timer Content of control Operation enable bit (CNTE) To stop reload timer Set to "0" 297 CHAPTER 15 16-BIT RELOAD TIMER 298 CHAPTER 16 8/16-BIT PPG TIMER This chapter provides an overview and interrupt of the 8/ 16-bit PPG timer and its operation and explains the configuration and functions of its registers. 16.1 Overview of 8/16-Bit PPG Timer 16.2 Configuration of 8/16-Bit PPG Timer 16.3 Configuration and Functions of 8/16-Bit PPG Timer Registers 16.4 Interrupt of 8/16-Bit PPG Timer 16.5 Operations of 8/16-Bit PPG Timer 16.6 Program Example of 8/16-Bit PPG Timer 299 CHAPTER 16 8/16-BIT PPG TIMER 16.1 Overview of 8/16-Bit PPG Timer The 8/16-bit PPG timer is a 6-channel reload timer module that can be used any interval and output pulse of duty ratio. On the hardware level, the timer consists of four 8-bit decrement counters, eight 8-bit reload timers, two 16-bit control registers, four external pulse output pins and four interrupt outputs. The MB90980 series has four channels that can be used for 8-bit PPG, enabling paired operation of PPG0/PPG1 and PPG2/PPG3 for 16-bit PPG operation (2 channels). ■ Function of 8/16-bit PPG Timer ● 8-bit PPG output 4-channel independent operation mode Provides independent PPG output operation with four channels. ● 16-bit PPG output operation mode Provides 16-bit PPG output operation with two channels. This is achieved by combining PPG0 + PPG1 and PPG2 + PPG3. ● 8 + 8-bit PPG output operation mode PPG0 (PPG2) output is inputted to PPG1 (PPG3) clock, enabling an arbitrary interval to be used for 8-bit PPG output. ● PPG output operation Provides an arbitrary interval and duty ratio for pulse wave output. Used in combination with an externally attached circuit for providing a D/A converter. 300 16.2 Configuration of 8/16-Bit PPG Timer This section shows the configuration of ch.0/ch.2 and ch.1/ch.3 of the 8/16-bit PPG timer. ■ Block Diagram of the 8/16-bit PPG Timer Figure 16.2-1 shows a block diagram of ch.0, ch.2. Figure 16.2-2 shows a block diagram of ch.1, ch.3. Figure 16.2-1 Block Diagram of the 8/16-bit PPG Timer (ch.0/ch.2) Peripheral clock: divide-by-16 Peripheral clock: divide-by-8 Peripheral clock: divide-by-4 PPG0/PPG2 output allowed Peripheral clock: divide-by-2 Peripheral clock PPG0/PPG2 A/D converter PPG0/PPG2 output latch PEN0 S R Q IRQ PCNT(down-counter) ch.1/ch.3 borrow "L"/"H" selector Count clock select PUF0 Time-base counter output Main clock: divide-by-512 PIE0 "L"/"H" select PRLL PRLBH PPGC0 (operation mode control) PRLL "L" data bus "H" data bus 301 CHAPTER 16 8/16-BIT PPG TIMER Figure 16.2-2 Block Diagram of the 8/16-bit PPG Timer (ch.1/ch.3) PPG1/PPG3 output enable Peripheral clock: divide-by-16 Peripheral clock: divide-by-8 Peripheral clock: divide-by-4 Peripheral clock: divide-by-2 Peripheral clock PPG1/PPG3 UART0 PPG1/PPG3 output latch PEN1 S R Q IRQ PCNT (down-counter) "L"/"H" selector Count clock select PUF1 Time-base counter output Main clock: divide-by-512 PIE1 "L"/"H" select PRLL PRLBH PPGC1 (operation mode control) PRLL "L" data bus "H" data bus ■ Pin Related to 8/16-bit PPG Timer Pin related to the 8/16-bit PPG timer has the PPG0/PPG1/PPG2/PPG3 pins. These pins function as the general-purpose I/O port (P24/PPG0, P25/PPG1, P26/PPG2, P27/PPG3) and the output pin of the PPG timer. ● Setting when using as PPG0/PPG1/PPG2/PPG3 pins When the PPG0/PPG1/PPG2/PPG3 pins are used as output, they are set to the output pin automatically regardless of the value of the port direction register (DDR). 302 ■ Block Diagram of Pin Related to 8/16-bit PPG Timer Figure 16.2-3 Block Diagram of Pin Related to 8/16-bit PPG Timer Peripheral function output (PPG0 to PPG3) Port data register (PDR) Peripheral function output enable Internal data bus PDR Read Output latch P-ch PDR Write Pin Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Standby control (SPL=1) Standby control : Stop mode (SPL=1), time-base timer mode (SPL=1), watch mode (SPL=1) 303 CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration and Functions of 8/16-Bit PPG Timer Registers This section describes the configuration and functions of the registers used in the 8/16-bit PPG timer. ■ List of 8/16-bit PPG Timer Registers Figure 16.3-1 shows a list of the registers for the 8/16-bit PPG timer. Figure 16.3-1 List of 8/16-bit PPG Timer Registers Operation mode control register (PPGC0/PPGC2) Address: bit7 bit6 bit5 bit4 bit3 bit2 00003AH PE00 PIE0 PUF0 00003CH PEN0 R/W R/W R/W R/W - bit1 - Operation mode control register (PPGC1/PPGC3) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 00003BH PE10 PIE1 PUF1 MD1 MD0 00003DH PEN1 R/W R/W R/W R/W R/W R/W- bit0 Reserved bit8 Reserved Reload register "H" (PRLH0 to PRLH3) Address: 00002FH bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 000031H 000033H D15 D14 D13 D12 D11 D10 D09 D08 R/W R/W R/W R/W R/W R/W R/W R/W 000035H 304 0X000XX1B - Output control register (PPG01/PPG23) Address: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 000040H 000042H PCS2 PCS1 PCS0 PCM2 PCM1 PCM0 Reserved Reserved R/W R/W R/W R/W R/W R/W Reload register "L" (PRLL0 to PRLL3) Address: 00002EH bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 000030H D07 D06 D05 D04 D03 D02 D01 D00 000032H R/W R/W R/W R/W R/W R/W R/W R/W 000034H R/W: Readable/writable -: Undefined Initial value 0X000001B 00000000B XXXXXXXXB XXXXXXXXB 16.3.1 PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2) This section describes the configuration and functions of the PPG0/PPG2 operation mode control register (PPGC0/PPGC2). ■ PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2) The PPG0/PPG2 operation mode control register (PPGC0/PPGC2) is used to select the channel 0/2 operation mode, control the pin output, select the count clock, and control the trigger. The bit configuration of the PPG0/PPG2 operation mode control register (PPGC0/PPGC2) is shown below. Figure 16.3-2 Bit Configuration of the PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2) Operation mode control register (PPGC0/PPGC2) Address: bit7 bit6 bit5 bit4 bit3 bit2 ch.0 00003A H PE00 PIE0 PUF0 ch.2 00003C H PEN0 R/W R/W R/W R/W R/W: Readable/writable -: Undefined bit1 - bit0 Initial value Reserved 0X000XX1B - The functions of the bits in the PPG0/PPG2 operation mode control register (PPGC0/PPGC2) are described below. [bit7] PEN0: ppg Enable (operation enable) This bit is used to select the PPG operation mode. PEN0 Operation state 0 Operation stop ("L" level output is retained) 1 PPG operation enable • When this bit is set to "1", the PPG starts counting. • This bit is initialized to "0" at reset. • Reading and writing are allowed. [bit5] PE00: ppg output Enable 00 (PPG0/PPG2 output pin enable) This bit is used to allow/prohibit pulse output via the pulse output external pin PPG0/PPG2. PE00 Operation state 0 General-purpose port pin (pulse output prohibited) 1 PPG0/PPG2 pulse output (pulse output allowed) • This bit is initialized to "0" at reset. • Reading and writing are allowed. 305 CHAPTER 16 8/16-BIT PPG TIMER [bit4] PIE0:ppg Interrupt Enable (PPG interrupt enable) This bit is used to allow or prohibit PPG interrupts. PIE0 Operation state 0 Interrupts prohibited 1 Interrupts allowed • If PUF0 is changed to "1" while this bit is "1", an interrupt request generates. If this bit is "0", no interrupts generate. • This bit is initialized to "0" at reset. • Reading and writing are allowed. [bit3] PUF0: ppg Underflow Flag (PPG counter underflow) This bit indicates the result of a PPG counter underflow detection. PUF0 Operation state 0 No PPG counter underflow detected 1 PPG counter underflow detected In 8-bit channel mode (PPG0/PPG1, PPG2/PPG3) and 8-bit prescaler + 8-bit PPG mode, this bit is set to "1" if an underflow occurs because the counter value for channel 0/2 changes 00H → FFH. In 16-bit PPG2 channel mode (PPG0/PPG1, PPG2/PPG3), this bit is set to "1" due to underflow if the counter value of channel 1, 3 or channel 0, 2 changes 0000H → FFFFH. Writing "0" clears this bit to "0". Writing "1" has no effect. Reading by read-modify-write type instructions always read "1". • This bit is initialized to "0" at reset. • Reading and writing are allowed. [bit0] reserved bit This bit is reserved. When setting PPGC0/PPGC2, always set this bit to "1". 306 16.3.2 PPG1/PPG3 Operation Mode Control Register (PPGC1/ PPGC3) This section describes the configuration and functions of the PPG1/PPG3 operation mode control register (PPGC1/PPGC3). ■ PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3) The PPG1/PPG3 operation mode control register (PPGC1/PPGC3) is used to select the channel 1/3 operation mode, control pin output, and select the count clock. It is also used for trigger control. The bit configuration of the PPG1/PPG3 operation mode control register (PPGC1/PPGC3) is shown below. Figure 16.3-3 Bit Configuration of the PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3) Operation mode control register (PPGC1/PPGC3) Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 ch.1 00003BH PEN1 PE10 PIE1 PUF1 MD1 MD0 ch.3 00003DH R/W R/W R/W R/W R/W R/W- bit8 Reserved Initial value 0X000001B R/W: Readable/writable -: Undefined The functions of the bits in the PPG1/PPG3 operation mode control register (PPGC1/PPGC3) are described below. [bit15] PEN1: ppg Enable (operation enable) This bit is used to select the PPG operation mode. PEN1 Operation state 0 Operation stop ("L" level output is retained) 1 PPG operation enabled • When this bit is set to "1", PPG count starts. • This bit is initialized to "0" at reset. • Reading and writing are allowed. [bit13] PE10: ppg output Enable 10 (PPG1/PPG3 output pin enable) This bit is used to allow or prohibit pulse output to the pulse output external pin PPG1/PPG3. PE10 Operation state 0 General-purpose port pin (pulse output prohibited) 1 PPG1/PPG3 pulse output (pulse output allowed) • This bit is initialized to "0" at reset. • Reading and writing are allowed. 307 CHAPTER 16 8/16-BIT PPG TIMER [bit12] PIE1: ppg Interrupt Enable (PPG interrupt enable) This bit is used to prohibit or allow PPG interrupts. PIE1 Operation state 0 Interrupts prohibited 1 Interrupts allowed If PUF0 is set to "1" when this bit is "1", an interrupt request generates. When this bit is "0", no interrupts generate. • This bit is initialized to "0" at reset. • Reading and writing are allowed. [bit11] PUF1: ppg Underflow Flag (PPG counter underflow) This bit is used to indicate the result of PPG counter underflow detection. PUF1 Operation state 0 No PPG counter underflow detected 1 PPG counter underflow detected In 8-bit PPG4 channel mode (PPG0/PPG1, PPG2/PPG3) and 8-bit prescaler + 8-bit PPG mode, this bit is set to "1" when an underflow occurs because the counter value of channel 1, 3 changes 00H → FFH. In 16bit PPG2 channel mode (PPG0/PPG1, PPG2/PPG3), this bit is set to "1" when an underflow occurs because the counter value of channel 1, 3 or channel 0, 2 changes 0000H → FFFFH. Writing "0" clears this bit to "0". Writing "1" has no effect. Reading by read-modify-write type instructions will always read "1". 308 • This bit is initialized to "0" at reset. • Reading and writing are allowed. [bit10, bit9] MD1, MD0: ppg count Mode (operation mode selection) These bits are used to select the PPG timer operation mode. MD1 MD0 Operation mode 0 0 8-bit PPG2 channel independent mode (✕ 2) 0 1 8-bit prescaler + 8-bit PPG1ch 1 0 Reserved (setting prohibited) 1 1 16-bit PPG1 channel mode (✕ 2) • These bits are initialized to "0" at reset. • Reading and writing are allowed. Notes: • Do not set these bits to "10B". • To set these bits to "01B", do not set the PEN0 bit of PPGC0/PPGC2 and the PEN1 bit of PPGC1/ PPGC3 to "01B". It is recommended that the PEN0 bit and the corresponding PEN1 bit be set to "11B" or "00B" at the same time. • To set these bits to "11B", rewrite the contents of PPGC0/PPGC2/PPGC1/PPGC3 by word transfer and set the PEN0/PEN1 bits to "11B" or "00B" at the same time. [bit8] reserved bit This bit is reserved. When setting PPGC1/PPGC3, always set this bit to "1". 309 CHAPTER 16 8/16-BIT PPG TIMER 16.3.3 PPG0 to PPG3 Output Control Registers (PPG01, PPG23) This section describes the configuration and functions of the PPG0 to PPG3 output control registers (PPG01, PPG23). ■ PPG0 to PPG3 Output Control Registers (PPG01, PPG23) The bit configuration of the PPG0 to PPG3 output control registers (PPG01, PPG23) is described below. Figure 16.3-4 Bit Configuration of the PPG0 to PPG3 Output Control Registers (PPG01, PPG23) Output control register (PPG01/PPG23) Address bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ch.0,ch.1 000040H PCS2 PCS1 PCS0 PCM2 PCM1 PCM0 Reserved Reserved ch.2,ch.3 000042H R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B R/W: Readable/writable The functions of the bits in the PPG0 to PPG3 output control registers (PPG01, PPG23) are described below. [bit7, bit6, bit5] PCS2 to PCS0:ppg Count Select (count clock selection) These bits are used to select the operation clock for the down counter of channels 1 and 3. PCS2 PCS1 PCS0 Operation mode 0 0 0 Peripheral clock (40 ns machine clock for 25 MHz) 0 0 1 Peripheral clock/2 (80 ns machine clock for 25 MHz) 0 1 0 Peripheral clock/4 (160 ns machine clock for 25 MHz) 0 1 1 Peripheral clock/8 (320 ns machine clock for 25 MHz) 1 0 0 Peripheral clock/16 (640 ns machine clock for 25 MHz) 1 1 1 Input clock from the time-base counter (29 x 250 ns = 128 μs oscillation for 4 MHz) • These bits are initialized to "000B" at reset. • Reading and writing are allowed. Note: In 8-bit prescaler + 8-bit PPG mode and in 16-bit PPG mode, setting bits PCS2 to PCS0 is disabled since the PPG of channels 1 and 3 receives the counter clock signal from channels 0 and 2. 310 [bit4, bit3, bit2] PCM2 to PCM0: ppg Count Mode (count clock selection) These bits are used to select the operation clock for the down counter of channels 0 and 2. PCM2 PCM1 PCM0 Operation mode 0 0 0 Peripheral clock (40 ns machine clock for 25 MHz) 0 0 1 Peripheral clock/2 (80 ns machine clock for 25 MHz) 0 1 0 Peripheral clock/4 (160 ns machine clock for 25 MHz) 0 1 1 Peripheral clock/8 (320 ns machine clock for 25 MHz) 1 0 0 Peripheral clock/16 (640 ns machine clock for 25 MHz) 1 1 1 Input clock from the time-base counter (29 x 250 ns = 128 μs oscillation for 4 MHz) • These bits are initialized to "000B" at reset. • Reading and writing are allowed. [bit1, bit0] reserved bits These bits are reserved. When setting PPG01 and PPG23, always set these bits to "00B". 311 CHAPTER 16 8/16-BIT PPG TIMER 16.3.4 Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3) This section describes the configuration and functions of the reload registers (PRLL0 to PRLL3, PRLH0 to PRLH3). ■ Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3) The bit configuration of the reload registers (PRLL0 to PRLL3, PRLH0 to PRLH3) is shown below. Figure 16.3-5 Bit Configuration of the Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3) Reload register "L" (PRLL0 to PRLL3) Address ch.0 00002EH bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ch.1 000030H D07 D06 D05 D04 D03 D02 D01 D00 ch.2 000032H R/W R/W R/W R/W R/W R/W R/W R/W ch.3 000034H Reload register "H" (PRLH0 to PRLH3) Address ch.0 00002FH bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 ch.1 000031H D15 D14 D13 D12 D11 D10 D09 D08 ch.2 000033H R/W R/W R/W R/W R/W R/W R/W R/W ch.3 000035H Initial value XXXXXXXXB XXXXXXXXB R/W: Readable/writable The reload registers (PRLL0 to PRLL3, PRLH0 to PRLH3) are 8-bit registers which each store a reload value for the down counter (PCNT). The registers have the following functions. Register name Function PRLL Stores the L-side reload value PRLH Stores the H-side reload value Both registers can be read and written. Note: It is therefore recommended that PRLL and PRLH for channels 0/2 be set to the same value in 8-bit prescaler + 8-bit PPG mode. 312 16.4 Interrupt of 8/16-Bit PPG Timer The interrupt of the 8/16-bit PPG timer occurs when the PPG counter underflow is detected. The interrupt of the PPG counter underflow cannot activate the DMA transfer and extended intelligent I/O service (EI2OS). ■ Interrupt of 8/16-bit PPG Timer Table 16.4-1 shows the interrupt control bit and interrupt source of the 8/16-bit PPG timer. Table 16.4-1 Interrupt of 8/16-bit PPG Timer PPG0/PPG2 overflow interrupt PPG1/PPG3 overflow interrupt Interrupt request flag PPG0:PUF0 (bit3) PPG2:PUF0 (bit3) ch.0 ch.2 PPG1:PUF1 (bit3) PPG3:PUF1 (bit3) ch.1 ch.3 Interrupt request output enable bit PPG0:PUE0 (bit4) PPG2:PUE0 (bit4) ch.0 ch.2 PPG1:PUE1 (bit4) PPG3:PUE1 (bit4) ch.1 ch.3 Interrupt generation source Overflow in PPG0/PPG2 down counter Overflow in PPG1/PPG3 down counter ■ Interrupt of PPG Counter Underflow ● 8-bit PPG and 8 + 8-bit PPG output operation mode • In the 8-bit PPG 4-channel independent operation mode or the 8 + 8-bit PPG output operation mode, the interrupt can be generated independently. • When the value of the PPG down counter is decremented from "00H" to "FFH", an underflow occurs. When an underflow occurs, the underflow bit in the channel causing an underflow is set (PUF0 = 1, PUF1 = 1). ● 16-bit PPG output operation mode • In the 16-bit PPG output operation mode, when the values of the PPG0 + PPG1/PPG2 + PPG3 down counters are decremented from "0000H" to "FFFFH", an underflow occurs. When an underflow occurs, the underflow generation bits in the two channels are set at one time (PIF0 = 1, PIF1 = 1). • When an underflow occurs with either of the two channels of the interrupt requests enabled (PIE0 = 0 + PIE1 = 1, PIE0 = 1 + PIE1 = 0), an interrupt is generated. • To prevent duplication of interrupt requests, disable either of the two channels of the underflow interrupt enable bits (PIE0 = 0 + PIE1 = 1, PIE0 = 1 + PIE1 = 0). • When the two channels of the underflow generation flag bits are set (PUF0 = 1, PUF1 = 1), clear the two channels at the same time. 313 CHAPTER 16 8/16-BIT PPG TIMER ■ Interrupt of 8/16-bit PPG Timer, DMA Transfer, and EI2OS Table 16.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 16.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register EI2OS clear μDMAC channel number PPG0/PPG1 counter borrow* × × #22 FFFFA4H PPG2/PPG3 counter borrow × × #23 FFFFA0H - - #24 FFFF9CH Interrupt source - Interrupt vector Number Address Interrupt control register Number Address ICR05 0000B5H ICR06 0000B6H ×: Interrupt request flag is not cleared. * : This interrupt source shares the interrupt source and interrupt number of other peripheral function. For details, see Table 4.2-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, the other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function The 8/16-bit PPG timer does not correspond to the DMA transfer function and EI2OS function. 314 16.5 Operations of 8/16-Bit PPG Timer The 8/16-bit PPG timer contains an 8-bit PPG unit for four channels (PPG0/PPG1,PPG2/ PPG3). Each of them can operate three types of operation modes in total, the 8-bit prescaler + 8-bit PPG mode and 16-bit PPG mode by performing the direct connection (PPG0 + PPG1/PPG2 + PPG3) operation in addition to the independent mode. ■ Outline of 8/16-bit PPG Timer Operation Each 8-bit PPG unit has two 8-bit reload registers, one "L"-side and the other "H"-side register (PRLL, PRLH). The values in these registers are reloaded into the corresponding L/H sides of the 8-bit down counter (PCNT) alternately and decremented at every count clock. The value of the output pin is inverted at reloading when a count borrow occurs. This operation ensures that the output pin outputs pulses with an L/ H width that corresponds to the reload register values. Operation start or restart are initiated by setting the corresponding bit in the register. The relationship between the reload operation and pulse output is shown below. Table 16.5-1 Relationship Between Reload Operation and Pulse Output Reload operation PRLH → PCNT Pin output change PPG0/PPG1[0 → 1] rising If bit4 (PIE0) of PPGC0/PPGC2 register is set to "1" and bit12 (PIE1) of PPGC1/PPGC3 register is set to "1", 00H → FFH counter borrow for each counter (in 16-bit PPG mode, 0000H to FFFFH counter borrow) will cause an interrupt request. ■ Operation Mode The 8/16-bit PPG timer has three operation modes: two-channel independent mode, 8-bit prescaler + 8-bit PPG mode, and 16-bit PPG mode (the MB90980 series has 3 channels per mode). Two-channel independent mode allows the two channels to be used independently as 8-bit PPGs. The PPG0 pin is connected to the PPG output of ch.0, and the PPG1 pin is connected to the PPG output of ch.1 (PPG2, PPG3 correspond to ch.2, ch.3). 8-bit prescaler + 8-bit PPG mode is a mode in which ch.0 (ch.2) operates as 8-bit prescaler while ch.1 (ch.3) is counted with a borrow output of ch.0 (ch.2), which allows an 8-bit PPG waveform of an arbitrary interval to be output. The PPG0 (PPG2) pin is connected with the prescaler output of ch.0 (ch.2), and the PPG1 pin (PPG3) is connected with the PPG output of ch.1 (ch.3). 16-bit PPG1 channel mode (the MB90980 series has 3 channels) is an operation mode in which ch.0 and ch.1 are directly connected (direct connection between ch.2 and ch.3) to allow 16-bit PPG operation. Both PPG 0 and PPG1 are connected with the 16-bit PPG output. 315 CHAPTER 16 8/16-BIT PPG TIMER ■ PPG Output Operation For the 8/16-bit PPG timer, PPG operation of ch.0 (ch.2) is started by setting bit 7 (PEN0) of the PPGC0/ PPGC2 register to "1". Similarly, PPG operation of ch.1 (ch.3) is started by setting bit 15 (PEN1) of the PPGC1/PPGC3 register to "1" to start counting. By subsequently setting bit 7 (PEN0) of the PPGC0/ PPGC2 or bit 15 (PEN1) of the PPGC1/PPGC3 to "0", the count operation is stopped, and the pulse output level is fixed at "L". In 8-bit prescaler + 8-bit PPG mode, do not set ch.0 (ch.2) to stop mode and ch.1 (ch.3) to active mode. In 16-bit PPG mode, use bit 7 (PEN0) of the PPGC0/PPGC2 register and bit 15 (PEN1) of the PPGC1/ PPGC3 register to control simultaneous start or stop of operation. In the following, the operation for PPG output is described. During PPG operation, a pulse wave with an arbitrary interval and duty ratio (ratio of "H"-level pulse wave to "L"-level pulse wave) is repeatedly output. After it starts to output the pulse wave, the PPG will not stop until operation stop is specified. Figure 16.5-1 shows the output waveform during PPG output operation. Figure 16.5-1 Output Waveform during PPG Output Operation PEN Operation start by PEN (from "L" side) Output pin PPG T × (L + 1) (Start) T × (H + 1) L : PRLL value H : PRLH value T : Peripheral clock (by PPGC clock selection) 316 ■ Relationship Between Reload Value and Pulse Width The width of the output pulse can be calculated by adding "1" to the reload register value, and multiplying the result by the count clock interval. In other words, if the reload register value during 8-bit PPG operation is 00H, or that in 16-bit PPG operation is 0000H, the pulse width will be equal to one interval length of the count clock. If the reload register value during 8-bit PPG operation is FFH, the pulse width is equal to 256 intervals of the count clock, and if the reload register value during 16-bit PPG operation is FFFFH, the pulse width is equal to 65,536 intervals of the count clock. The pulse width is expressed with the formula below: PL = T x (L + 1) PH = T x (H + 1) Where PL : Width of L pulse PH : Width of H pulse T : Input clock interval L : PRLL value H : PRLH value ■ Selection of Count Clock The 8/16-bit PPG timer uses the input from the peripheral clock and time-base counter as a counter clock, allowing a selection from six types of count clock input. Bit4 to bit2 (PCM2 to PCM0) of the PPG01/PPG23 registers are used to select the clock of ch.0 (ch.2), and bit7 to bit5 (PCS2 to PCS0) of the PPG01/PPG23 registers are used to select the clock of ch.1 (ch.3). The clock is selected from among the machine clock multiplied by 1/16 to "1" and the time-base counter input. Notes: • In 8-bit prescaler + 8-bit PPG mode and in 16-bit PPG mode, the value in bit 14 (PCS1) of the PPGC1/PPGC3 register is invalid. • If the input from time-base timer is used, the first count cycle after a trigger or stop event may be out of sync. If the time-base counter is initialized while the 8/16-bit PPG timer is running, cycles may be out of sync. • If, in 8-bit prescaler + 8-bit PPG mode, ch.0/ch.2 is in active mode and ch.1/ch.3 is in stopped mode, the first count cycle may be out of sync when operation of ch.1 (ch.3) starts. 317 CHAPTER 16 8/16-BIT PPG TIMER ■ Pin Output Control of Pulses Pulses generated by the 8/16-bit PPG timer are output from the external pins (PPG0 to PPG3). To output pulses from an external pin, set the bit corresponding to the pin to "1". For enabling PPG0/PPG2 pin output, bit 5 (PE00) of PPGC0/PPGC2 is used, and for enabling PPG1/PPG3 pin output, bit 13 (PE10) of PPGC1/PPGC3 is used. If the respective bit is set to "0" (initial value), the external pin does not output pulses, but is used as a general-purpose port. In 16-bit PPG mode, PPG0 to PPG3 output the same waveform. For this reason, it is sufficient to enable pin output for either of the corresponding pins to obtain the same output. In 8-bit prescaler + 8-bit PPG mode, PPG0/PPG2 output a toggle waveform of the 8- bit prescaler, and PPG1/PPG3 output a waveform of 8-bit PPG. Output waveform in this mode is illustrated in Figure 16.5-2. Figure 16.5-2 Waveform in 8-bit Prescaler + 8-bit PPG Mode Output Operation PH0 PL0 PPG0 PPG1 PH1 PL1 The pulse width shown in Figure 16.5-2 can be expressed with the following formulas. PL0 = T x (L0 + 1) PH0 = T x (L0 + 1) PL1 = T x (L0 + 1) x (L1 + 1) PH1 = T x (L0 + 1) x (H1 + 1) Where L0 : PRLL value of channel 0 and PRLH value of channel 1 L1 : PRLL value of channel 1 H1 : PRLH value of channel 1 T : Input clock cycle PH0 : H pulse width of PPG0 PL0 : L pulse width of PPG0 PH1 : H pulse width of PPG1 PL1 : L pulse width of PPG1 Note: Set PRLL of channel 0 and PRLH of channel 1 to the same value. 318 ■ Interrupts of the 8/16-bit PPG Timer The interrupt unit of the 8/16-bit PPG timer becomes active as soon as a counter borrow occurs after the reload value is counted out. In 8-bit PPG2 channel mode or 8-bit prescaler/9-bit PPG mode (3 channels are provided for MB90980 series), each borrow will cause a separate interrupt request. In 16-bit PPG mode, however, PUG0 and PUG1 will be set at the same time when a borrow from the 16-bit counter occurs. To unify interrupt sources, only one of either PIE0 or PIE1 is allowed. Interrupt sources are also cleared at the same time for PUF0 and PUF1. ■ Initial Value of Hardware Components The hardware components of the 8/16-bit PPG timer are initialized to the following values at reset. < Registers > < pulse output > < interrupt request > PPGC0 PPGC1 PPG01 PPG0 PPG1 PE00 PE10 IRQ0 IRQ1 → → → → → → → → → 0X000001B 00000001B XXXXXX00B "L" "L" PPG0 output prohibited PPG1 output prohibited "L" "L" Hardware components other than above mentioned are not initialized. ■ Write Timing to the Reload Register It is recommended that word transfer instructions be used for writing data to the reload registers PRLL and PRLH in modes other than 16-bit PPG mode. Writing data to the register two times by separate byte transfer instructions may result in an unexpected output pulse width, depending on the timing. Figure 16.5-3 shows the timing for writing to the reload register. Figure 16.5-3 Timing Chart of Writing to the Reload Register PPG0 A B A B C B C D C D (1) In Figure 16.5-3, PRLL is changed from A to C before (1), and the PRLH value is changed from B to D after (1). However, since the PRL values at (1) are PRLL = C and PRLH = B, the pulses for the L-side count of C and the H-side count of B are generated only once. Similarly, to write data to the PRL of ch.0/ ch.2 and ch.1/ch.3 in the 16-bit PPG mode, use a long word transfer instruction or use a word transfer instruction in the order ch.0 → ch.1 (ch.2 → ch.3). In this mode, data is temporarily written from ch.0/ch.2 to the PRL; when data is then written from ch.1/ch.3 to the PRL, it is actually written to the PRL of ch.0. In modes other than 16-bit PPG mode, writing to ch.0/ch.2 and ch.1/ch.3 are performed independently. 319 CHAPTER 16 8/16-BIT PPG TIMER Figure 16.5-4 shows a block diagram of the PRL write operation. Figure 16.5-4 Block Diagram of the PRL Write Operation Write data for PRL of ch.0 Writing from ch.0 in a mode other than 16-bit PPG mode Temporary latch PRL of ch.0 320 Write data for PRL of ch.1 Transfer in sync with writing from ch.1 in 16-bit PPG mode Write data for ch.1 PRL of ch.1 16.6 Program Example of 8/16-Bit PPG Timer This section describes the program example of the 8/16-bit PPG timer. ■ Program Example of 8/16-bit PPG Timer Example of setting procedure Program example Generate interval interrupt and output PPG. void PPG_sample(void) { PPG01_initial(); PPG01_start(); } (PPG output from PPG1 pin, software trigger) void PPG01_initial(void) { <Initial setting> • Control PPG01 Register name. bit name Set control register Select count clock >> Set control register Enable pulse output >> Enable interrupt >> Select operation mode >> PPG01 .PCS2 to PCS0 *1 IO_PPG01.bit.PCS = 1; /* bit7 to bit5 = 0 *2 IO_PPGC01.word = 0x3101; /* bit15 = 0 /* bit13 = 1 /* bit12 = 1 /* bit11 = 0 /* bit10, bit9 = 00B PPGC01 .PE10 .PIE1 .MD1, MD0 /* bit8 = 1 /* bit0 = 1 • Set duty Set PPG01 duty Set I flag ICR05 (CCR) <Start> • Start PPG01 Register name. bit name Enable interrupt Start PPG01 PPGC01.PIE1 PPGC01.PEN1 <Interrupt> Reserved bit */ Reserved bit */ *3 IO_PRL0.word = 0x7f7f; /* IO_ICR05.byte = 0x10; __EI(); /* Interrupt level (arbitrary value) */ /* Enable interrupt */ Set PPG duty ratio */ } void PPG01_start(void) { IO_PPGC01.bit.PIE1 = 1; IO_PPGC01.bit.PEN1 = 1; } /* bit12= 1 /* bit15 = 1 Enable PIE1 interrupt request */ Start PEN1 PPG operation */ __interrupt void PPG01_int(void) { • Interrupt processing Any processing Clear interrupt request flag Stop PPG operation */ Enable PPG1/PPG3/PPG5 pulse output */ Enable PPG interrupt */ Clear PUF1 interrupt request flag */ 8-bit PPG 2ch */ PRL0 • Interrupt related Set PPG01 interrupt level Select PPG1 count clock */ PPGC01.PUF1 <Interrupt vector> • Set vector table IO_PPGC01.bit.PUF1 = 0; /* Any processing */ /* bit11 = 0 PUF1 interrupt request flag */ } #pragma intvect PPG01_int 22 <Other> Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". *1: io_PPG01 represents PPG1 register and PPG0 register. *2: io_PPGC01 represents PPGC1/PPGC3 register and PPGC0/PPGC2 register. *3: io_PRL0 represents PRLL0 register and PRLH0 register. 321 CHAPTER 16 8/16-BIT PPG TIMER ■ Setting Method Other than Program Example ● Method to enable/stop PPG operation Set by the PPG operation enable bit (PPGC0/PPGC2 to PPGC3: PEN0 or PEN1). Control PPG operation enable bit (PEN0 or PEN1) To stop PPG operation Set to "0" To enable PPG operation Set to "1" Enable the PPG operation before the PPG is started. ● Method to set PPG operation mode Set by the mode selection bits (PPGC0/PPGC2 to PPGC3: MD[1:0]). ● Type of count clock and selection method ch.1, ch.3, ch.5 can select using the count clock selection bits (PPG01.PCS[2:0]/PPG23. PCS[2:0].PCS[2:0]). ch.0, ch.2, ch.4 can select using the count clock selection bits (PPG01.PCM[2:0]/PPG23. PCM[2:0].PCM[2:0]). ● Interrupt related register The relationship between channel, interrupt level, and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 16.6-1 Relationship Between Channel, Interrupt Level, and Interrupt Vector Channel Interrupt vector Interrupt level setting register PPG0 #22 Address : 0FFFFA4H Interrupt control register 05 (ICR05) Address : 000B5H #23 Address : 0FFFFA0H Interrupt control register 06 (ICR06) Address : 000B6H #24 Address : 0FFFF9CH Interrupt control register 06 (ICR06) Address : 000B6H PPG1 PPG2 PPG3 PPG4 PPG5 Clear the interrupt request flag (PPG01/PPG23/PPG45.PUF0 or PUF1) with software before returning from the interrupt processing because the flag is not cleared automatically (write "0" to PUF0 or PUF1 bit). 322 ● Type of interrupt One interrupt is provided. It generates with underflow of the PPG counter. ● Method to enable/disable/clear interrupt Enabling/disabling interrupt is set by the interrupt request enable bit (PPGC0 to PPGC3: PIE0 or PIE1). Table 16.6-2 Method to Enable/Disable Interrupt Content of control Interrupt request enable bit (PIE0 or PIE1) To disable interrupt request Set to "0" To enable interrupt request Set to "1" Clearing interrupt request is set by the interrupt request bit (PPG01/PPG23: PUF0 or PUF1). Table 16.6-3 Method to Clear Interrupt Request Content of control Interrupt request bit (PUF0 or PUF1) To clear interrupt request Write "0" 323 CHAPTER 16 8/16-BIT PPG TIMER 324 CHAPTER 17 DTP/EXTERNAL INTERRUPTS This chapter provides an overview of the DTP/external interrupt, its operation, and notes on usage and explains the configuration and functions of its registers. 17.1 Overview of DTP/External Interrupt 17.2 Configuration and Functions of DTP/external Interrupt Registers 17.3 DTP/External Interrupt 17.4 Operations of DTP/external Interrupt 17.5 Notes on DTP/external Interrupt Usage 17.6 Program Example of DTP/External Interrupt 325 CHAPTER 17 DTP/EXTERNAL INTERRUPTS 17.1 Overview of DTP/External Interrupt The DTP (Data Transfer Peripheral) unit is a peripheral control section located between the peripheral units outside the device and the F2MC-16LX CPU. It is used to receive DMA request or interrupt requests from the external peripheral device and report such requests to the F2MC-16LX CPU to start μDMAC, EI2OS, or interrupt handling. ■ Overview of DTP/External Interrupt For μDMAC or EI2OS, the request level can be selected from two types, "H" and "L". For external interrupt requests, it can be selected from four types: rising edge, falling edge, "H", and "L". ■ Block Diagram of DTP/External Interrupt Figure 17.1-1 shows a block diagram of the DTP/external interrupt. Figure 17.1-1 Block Diagram of DTP/External Interrupt F2MC-16LX bus 4 4 4 8 Interrupt/DTP enable register Gate Source F/F Edge detection circuit 4 Request input Interrupt/DTP source register Request level setting register ■ Pin Related to DTP/External Interrupt The pin related to the external interrupt has the IRQ0/IRQ1/IRQ2/IRQ3/IRQ4/IRQ5/IRQ6/IRQ7 pins and functions as an input port. The IRQ0/IRQ1/IRQ2/IRQ3/IRQ4/IRQ5/IRQ6/IRQ7 pins function as the general-purpose I/O port (P80/IRQ0,P81/IRQ1,P82/IRQ2,P83/IRQ3,P84/IRQ4,P85/IRQ5,P86/IRQ6,P87/ IRQ7) and external interrupt input pin. ● Setting when using as IRQ0/IRQ1/IRQ2/IRQ3/IRQ4/IRQ5/IRQ6/IRQ7 pins When the P80/IRQ0,P81/IRQ1,P82/IRQ2,P83/IRQ3,P84/IRQ4,P85/IRQ5,P86/IRQ6,P87/IRQ7 pins are used as an input pin, be sure to set the port direction register to the input port (DDR8: bit0 to bit7 → "0"). 326 ■ Block Diagram of Pin Related to DTP/External Interrupt Figure 17.1-2 Block Diagram of Pin Related to DTP/External Interrupt Peripheral function input (IRQ0/IRQ1/IRQ2/IRQ3/IRQ4/IRQ5/IRQ6/IRQ7) Port data register (PDR) Internal data bus PDR Read Output latch P-ch PDR Write Pin Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Standby control (SPL=1) Standby control : Stop mode (SPL=1), time-base timer mode (SPL=1), watch mode (SPL=1) 327 CHAPTER 17 DTP/EXTERNAL INTERRUPTS 17.2 Configuration and Functions of DTP/external Interrupt Registers This section describes the configuration and functions of the registers used in the DTP/ external interrupt. ■ List of Registers for DTP/External Interrupt Figure 17.2-1 shows a list of the registers for the DTP/external interrupt. Figure 17.2-1 List of DTP/External Interrupt Registers Interrupt/DTP enable register (ENIR) bit7 bit6 bit5 Address: 00000CH EN7 EN6 EN5 R/W R/W R/W Interrupt/DTP source register (EIRR) bit15 bit14 bit13 Address: 00000DH ER7 ER6 ER5 R/W R/W R/W Request level setting register (ELVR) bit7 bit6 bit5 Address: 00000EH LB3 LA3 LB2 R/W R/W R/W Request level setting register (ELVR) bit15 bit14 bit13 Address: 00000FH LB7 LA7 LB6 R/W R/W R/W bit4 EN4 R/W Initial value 00000000B bit2 EN2 R/W bit1 EN1 R/W bit0 EN0 R/W bit12 bit11 bit10 ER4 ER3 ER2 R/W R/W R/W bit9 ER1 R/W bit8 ER0 R/W XXXXXXXXB bit2 LA1 R/W bit1 LB0 R/W bit0 LA0 R/W 00000000B bit12 bit11 bit10 LA6 LB5 LA5 R/W R/W R/W bit9 LB4 R/W bit8 LA4 R/W 00000000B bit4 LA2 R/W bit3 EN3 R/W bit3 LB1 R/W R/W: Readable/writable ■ Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register) The bit configuration of the interrupt/DTP enable register (ENIR) is shown below. Figure 17.2-2 Bit Configuration of Interrupt/DTP Enable Register (ENIR) Interrupt/DTP enable register (ENIR) bit7 bit6 bit5 bit4 Address: 00000CH EN7 EN6 EN5 EN4 R/W R/W R/W R/W bit3 EN3 R/W bit2 EN2 R/W bit1 EN1 R/W bit0 EN0 R/W Initial value 00000000B R/W: Readable/writable The interrupt/DTP enable register (ENIR) enables or disables an external interrupt/DTP request for an external interrupt/DTP channel. If the interrupt/DTP enable bits (ENs) of ENIR and the interrupt/DTP request flag bits (ENs) of EIRR are all set to "1", an interrupt request for the corresponding interrupt/DTP pin is generated. Signal inputs to this register are not interrupted during standby mode. 328 ■ Interrupt/DTP Source Register (EIRR: External Interrupt Request Register) The bit configuration of the interrupt/DTP source register (EIRR) is shown below. Figure 17.2-3 Bit Configuration of Interrupt/DTP Source Register (EIRR) Interrupt/DTP source register (EIRR) bit15 bit14 bit13 bit12 bit11 bit10 Address: 00000DH ER7 ER6 ER5 ER4 ER3 ER2 R/W R/W R/W R/W R/W R/W bit9 ER1 R/W bit8 ER0 R/W Initial value XXXXXXXXB R/W: Readable/writable The interrupt/DTP source register (EIRR) is set to "1" if the edge or level signal set in the detection condition selection bits (LB, LA) of the request level setting register (ELVR) is input to the external interrupt pin. If the register is set to "1", an interrupt request for the corresponding interrupt/DTP channel is generated when the interrupt/DTP request enable bits (EN) of ENIR are set to "1". If the register is set to "0", it is cleared. If the register is set to "1", the interrupt request status is not affected. Notes: • Reading by read-modify-write type instructions always reads "1". If multiple external interrupt request outputs are enabled (ENIR: EN7 to EN0=1), only the bits for which the CPU accepts an interrupt (bits for which "1" was set in EN7 to EN0) are cleared to "0". No other bits must be cleared unconditionally. • The value of DTP/external interrupt request flag bit is only valid when the corresponding DTP/ external interrupt request output enable bit (ENIR: EV) is "1". If DTP/external interrupt is not disabled (ENZR: EN=0), DTP/external interrupt request flag bit may be set regardless of the existence of the DTP/external interrupt source. • Clear the corresponding DTP/external interrupt request flag bit (EIRR: ER=0) just before enabling the DTP/external interrupt (ENIR: EN=1). ■ Request Level Setting Register (ELVR: External Level Register) The bit configuration of the request level setting register (ELVR) is shown below. Figure 17.2-4 Bit Configuration of Request Level Setting Register (ELVR) Request level setting register (ELVR) bit7 bit6 bit5 Address: 00000EH LB3 LA3 LB2 R/W R/W R/W Request level setting register (ELVR) bit15 bit14 bit13 Address: 00000FH LB7 LA7 LB6 R/W R/W R/W bit4 LA2 R/W bit3 LB1 R/W bit2 LA1 R/W bit1 LB0 R/W bit0 LA0 R/W bit12 bit11 bit10 LA6 LB5 LA5 R/W R/W R/W bit9 LB4 R/W bit8 LA4 R/W Initial value 00000000B 00000000B R/W: Readable/writable 329 CHAPTER 17 DTP/EXTERNAL INTERRUPTS The request level setting register (ELVR) is used to select a request detection level. Two bits are assigned for each pin, as shown in Table 17.2-1. If the setting for a request input indicates a level, the corresponding level will be set again when it is cleared, provided the input is active. Table 17.2-1 ELVR Assignment (LA0 to LA7, LB0 to LB7) 330 LBx LAx Operation 0 0 Request by "L" level 0 1 Request by "H" level 1 0 Request by rising edge 1 1 Request by falling edge 17.3 DTP/External Interrupt The interrupt related to the DTP/external interrupt occurs when the edge or level input to input pin is detected. The DTP/external interrupt can activate the DMA transfer and extended intelligent I/O service (EI2OS). ■ DTP/External Interrupt The interrupt control bit and interrupt source of the DTP/external interrupt is shown in the following table. Table 17.3-1 Interrupt Control Bit and Interrupt Source of DTP/External Interrupt External interrupt When ISE of ICR = 0 DTP interrupt when ISE of ICR = 1 Interrupt request flag EIRR:ER (bit8 to bit15) EIRR:ER (bit8 to bit15) Interrupt request output enable bit ENIR:EN (bit0 to bit7) ENIR:EN (bit0 to bit7) Interrupt generation source Detect external interrupt Detect external interrupt ● Setting procedure To use the DTP/external interrupt, set each register by using the following procedure: 1. Set the interrupt request enable bit corresponding to the DTP/external interrupt channel to be used to "0" (ENIR:EN). 2. Use the detection condition select bit corresponding to the DTP/external interrupt channel to be used to set the edge or level to be detected (ELVR:LA/LB). 3. Set the interrupt request flag corresponding to the DTP/external interrupt channel to be used to "0" (EIRR:ER). 4. Set the corresponding interrupt request enable bit to "1" (ENIR:EN). Notes: • When setting the registers for the DTP/external interrupt, the external interrupt request must be disabled (ENIR:EN=0). • When enabling the DTP/external interrupt (ENIR:EN=1), the corresponding DTP/external interrupt request flag bit must be cleared in advance (EIRR:ER=0). These actions prevent the mistaken interrupt request from occurring when setting the register. ● Selecting of DTP function or external interrupt function Whether the DTP function or the external interrupt function is executed depends on the setting of the EI2OS enable bit in the corresponding interrupt control register (ICR:ISE) or that of the DMA enable register (DER:EN). If the ISE bit is set to "1", the EI2OS sets the EN bit to "1" and the DMA transfer is enabled. If the ISE and EN bits are set to "0", the EI2OS and DMA transfer are disabled and the external interrupt function is executed. 331 CHAPTER 17 DTP/EXTERNAL INTERRUPTS Notes: • All interrupt requests assigned to one interrupt control register have the same interrupt level (IL2 to IL0). • If two or more interrupt requests are assigned to one interrupt control register and EI2OS is started for any of them, other interrupt requests cannot be used. ■ DTP/External Interrupt, DMA Transfer, and EI2OS Table 17.3-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 17.3-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register EI2OS clear μDMAC channel number Number Address INT0 (IRQ0) ❍ 0 #11 FFFFD0H INT1 (IRQ1) ❍ × #12 FFFFCCH INT2 (IRQ2) ❍ × #13 FFFFC8H INT3 (IRQ3) ❍ × #14 FFFFC4H INT4 (IRQ4) ❍ × #15 FFFFC0H INT5 (IRQ5) ❍ × #16 FFFFBCH INT6 (IRQ6) ❍ × #17 FFFFB8H INT7 (IRQ7) ❍ × #18 FFFFB4H Interrupt source Interrupt vector Interrupt control register Number Address ICR00 0000B0H ICR01 0000B1H ICR02 0000B2H ICR03 0000B3H ×: Interrupt request flag is not cleared. ❍: Interrupt request flag is cleared. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, the other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function EI2OS function and ch.0 in the DTP/external interrupt correspond to the DMA transfer function. When the DMA or EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 332 17.4 Operations of DTP/external Interrupt This section describes the operations of the DTP/external interrupt. ■ Operation of External Interrupt Unit If, after an external interrupt request has been set, the interrupt request specified in the ELVR register is input to the corresponding pin, this resource will generate an interrupt request signal for the interrupt controller. Interrupts that are generated by the interrupt controller at the same time will be distinguished by priority. The interrupt controller will generate an interrupt request to the F2MC-16LX CPU if the interrupt from the corresponding resource has the highest priority. The F2MC-16LX CPU compares the interrupt level mask register (ILM) in the processor status (PS) with the interrupt request level. If the request level is found to be higher than the value expressed by the ILM bits, the hardware interrupt handling microprogram starts immediately after the currently executed instruction is completed. Figure 17.4-1 shows the operational flow for external interrupts. Figure 17.4-1 External Interrupt Operation External interrupt/DTP unit F2MC-16LX CPU Interrupt controller Other request ELVR Source CMP CMP EIRR ENIR IL ICRyy ICRxx ILM INTA The interrupt handling microprogram reads data from the interrupt vector area and generates an interrupt acknowledge signal for the interrupt controller. After that, it transfers the jump destination address of the macro instruction, which is obtained from the interrupt vector, to the program counter, and execution continues with the user's interrupt handling program. 333 CHAPTER 17 DTP/EXTERNAL INTERRUPTS ■ DTP Operation To start μDMAC in a user program, the following initialization operations are performed: The I/O address pointer in the μDMAC descriptor is set to the register address allocated in 000000H to 0000FFH, and the buffer address pointer is set to the start address of the memory buffer. The operational sequence for DTP is almost the same as that for external interrupts. At the start of μDMAC, the corresponding read or write signal is transferred to the external peripheral device whose address was specified, and data transfer is performed with this chip. Ensure that the external peripheral device side is required to withdraw the interrupt request to the chip within three machine cycles after data transfer. At the end of data transfer, the descriptor is updated, and a signal to clear the interrupt source is generated by the interrupt controller. After receiving the signal, the DTP unit clears the flip-flop that retains the interrupt source and waits for the next request from the pin. Figure 17.4-2 shows the timing for withdrawing the external interrupt request at the end of DTP operation. Figure 17.4-3 shows an example for an interface with the external peripheral device. Figure 17.4-2 Timing for Withdrawing an External Interrupt Request at the End of DTP Operation Interrupt source Internal operation ↑ Rising Edge request or "H"-level request * μDMAC for transferring from I/O register to memory Descriptor selection/read Address bus pin Read address Write address Read data Data bus pin Read signal Write data (1) Write signal (2) Withdrawn within 3 machine cycles Data, address, and bus Internal bus Register External peripheral unit Figure 17.4-3 Example of Interface with an External Peripheral Device IRQ DTP INT Withdrawn within 3 machine cycles after the end of transfer MB90980 series 334 (2) (1) CORE MEMORY 17.5 Notes on DTP/external Interrupt Usage This section provides notes on using the DTP/external interrupt. ■ Conditions for External Connection of Peripheral Devices For support by the DTP unit, external peripheral devices must be able to automatically clear a request after successful data transfer. If a transfer request fails to be withdrawn within three machine cycles after the transfer operation starts (interim value), the DTP unit will proceed as if a new transfer request had been generated. ■ Procedure for DTP/External Interrupt Operation Set the values of registers in the DTP/external interrupt as follows: (1) Set the pin used as an external interrupt input and the general-purpose I/O port used combinedly to the input port. (2) Set the bits for the registers to be enabled to "disable". (3) Set the bits of the request level setting register. (4) Clear the bits in the source register. (5) Set the bits for the registers to be enabled to "enable". Steps (4) and (5) allow simultaneous writing by word-length specification. To set the contents of DTP/external interrupt registers, first disable the registers to be enabled. Before enabling the registers to be enabled again, clear the source register in order to avoid accidental generation of an interrupt source in register setting of interrupt enabled state. 335 CHAPTER 17 DTP/EXTERNAL INTERRUPTS ■ External Interrupt Request Level • If edge request has been selected for the request level, at least a pulse width of three machine cycles is required for detecting edge. • If level setting has been selected for the request input level, note that an external request that has been input remains active with respect to the interrupt controller even if it is later withdrawn, since the interrupt controller contains an internal source retention circuit. To withdraw a request with respect to the interrupt controller, the source retention circuit must be cleared. Figure 17.5-1 Clearing the Source Retention Circuit when Setting the Request Level Interrupt source Level detection Source F/F (source retention circuit) Enable gate To interrupt controller Source is retained until cleared Figure 17.5-2 Interrupt Sources and Interrupt Requests to the Interrupt Controller when Interrupts are Enabled Interrupt source "H" level Interrupt request to interrupt controller Turned to inactive by clearing source F/F 336 17.6 Program Example of DTP/External Interrupt This section describes the program example of the DTP/external interrupt. ■ Program Example of DTP/External Interrupt Example of setting procedure Program example Generate external interrupt at rising edge of signal input by INT0. void EX_INT_sample_1() { EX_INT0_initial(); } <Initial setting> Port Select INT0 port input •Control INT0 Select external interrupt detection Register name. bit name DDR8 .P80 void EX_INT0_initial(void) { IO_DDR8.bit.D80= 0; Register name. bit name ELVR LB7,LA7 to LB1,LA1 LB0, LA0 IO_ELVR.word= 0x0001; Set I flag •Interrupt related 2 INT0 interrupt source Enable INT0 interrupt /* Setting value:F00000001 (bit) */ /* bit7 to bit2= 000000B */ /* bit1, bit0= 01B Detect H level */ •Interrupt related 1 Set INT0 interrupt level /* INT0 input */ ICR00 (CCR) EIRR. ER0 ENIR. EN0 IO_ICR00 = 0x00 __EI(); /* Arbitrary value */ /*Enable interrupt */ IO_EIRR.bit.ER0= 0; IO_ENIR.bit.EN0= 0; /* Clear ER0 interrupt flag */ /* Enable EN0 interrupt */ } <Interrupt> Read conversion value Register name. bit name Clear interrupt request flag EIRR. ER0 (Arbitrary processing) __interrupt void INT0_int(void) { IO_EIRR.bit.ER0= 0; } /* */ /* Clear ER0 interrupt flag */ <Interrupt vector> •Set vector table #pragma intvect INT0_int 11 Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". 337 CHAPTER 17 DTP/EXTERNAL INTERRUPTS ■ Setting Method Other than Program Example ● Type of detection level and setting method 4 types of the detection level are provided ("L" level, "H" level, rising, falling). Set by the detection level bit (ELVR. LBx,LAx) x=0 to 7. Table 17.6-1 Type of Detection Level and Setting Method Operation mode Detection level bit (LBx, LAx) x=0 to 7 To detect "L" level Set to "00B" To detect "H" level Set to "01B" To detect rising Set to "10B" To detect falling Set to "11B" ● Method to input IRQ pin Set by the port 8 direction register (DDR8). Table 17.6-2 Method to Input IRQ Pin 338 Operation Direction bits (P80 to P87) Setting To input IRQ0 pin DDR8: P80 Set to "0" To input IRQ1 pin DDR8: P81 Set to "0" To input IRQ2 pin DDR8: P82 Set to "0" To input IRQ3 pin DDR8: P83 Set to "0" To input IRQ4 pin DDR8: P84 Set to "0" To input IRQ5 pin DDR8: P85 Set to "0" To input IRQ6 pin DDR8: P86 Set to "0" To input IRQ7 pin DDR8: P87 Set to "0" ● Interrupt related register The relationship between the external interrupt pin, interrupt level, and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 17.6-3 Relationship Between External Interrupt Pin, Interrupt Level, and Interrupt Vector External interrupt pin Interrupt vector Interrupt level setting bit IRQ0 #11 Address : 0FFFFD0H Interrupt control register 00 (ICR00) Address : 000B0H IRQ1 #12 Address : 0FFFFCCH Interrupt control register 00 (ICR00) Address : 000B0H IRQ2 #13 Address : 0FFFFC8H Interrupt control register 01 (ICR01) Address : 000B1H IRQ3 #14 Address : 0FFFFC4H Interrupt control register 01 (ICR01) Address : 000B1H IRQ4 #15 Address : 0FFFFC0H Interrupt control register 02 (ICR02) Address : 000B2H IRQ5 #16 Address : 0FFFFBCH Interrupt control register 02 (ICR02) Address : 000B2H IRQ6 #17 Address : 0FFFFB8H Interrupt control register 03 (ICR03) Address : 000B3H IRQ7 #18 Address : 0FFFFB4H Interrupt control register 03 (ICR03) Address : 000B3H ● Type of interrupt The interrupt source is external interrupt only. There is no bit to be selected. ● Method to enable/disable/clear interrupt Enabling/disabling interrupt is set by the interrupt enable bit (ENIR.ENx x=0 to 7). Table 17.6-4 Method to Enable/Disable Interrupt Content of control Interrupt enable bit (ENx x=0 to 7) To disable interrupt request Set to "0" To enable interrupt request Set to "1" Clearing interrupt request is set by the interrupt request bit (EIRR.ERx x=0 to 7). Table 17.6-5 Method to Clear Interrupt Request Content of control Interrupt request bit (ERx x=0 to 7) To clear interrupt request Write "0" 339 CHAPTER 17 DTP/EXTERNAL INTERRUPTS 340 CHAPTER 18 8/10-BIT A/D CONVERTER This chapter provides an overview of the 8/10-bit A/D converter, configuration and function of its registers, operation, conversion data protection function, and precautions on use. 18.1 Overview of 8/10-Bit A/D Converter 18.2 Configuration of 8/10-Bit A/D Converter 18.3 Configuration of 8/10-Bit A/D Converter Registers 18.4 Interrupt of 8/10-Bit A/D Converter 18.5 Operations of 8/10-Bit A/D Converter 18.6 Conversion Data Protection Function of 8/10-Bit A/D Converter 18.7 Precautions When Using the 8/10-Bit A/D Converter 18.8 Program Example of 8/10-Bit A/D Converter 341 CHAPTER 18 8/10-BIT A/D CONVERTER 18.1 Overview of 8/10-Bit A/D Converter This section describes the features of the 8/10-bit A/D converter and provides its block diagram. ■ Features of the 8/10-bit A/D Converter The 8/10-bit A/D converter features the following functions: • Conversion time: Minimum of 3.68 μs per channel (92 machine cycles/machine clock at 25 MHz, with sampling time included) • Sampling time: Minimum of 1.92 μs per channel (48 machine cycles/machine clock at 25 MHz) • RC-type sequential comparison conversion system with sample and hold circuit • 8- or 10-bit resolution can be selected. • Analog input by program via eight channels can be selected. • Single conversion mode: Selection and conversion of a single channel • Scan conversion mode: Several channels can be converted in succession. A maximum of eight channels can be programmed. • Continuous conversion mode: Conversion of the specified channels is performed repeatedly. • Stop conversion mode: Pauses after conversion of one channel is completed and stands by until next activation is triggered. (Conversion starts can be synchronized) When A/D conversion ends, an interrupt request for end of A/D conversion is generated to the CPU. This interrupt starts μDMAC, enabling the transfer of data resulting from A/D conversion to memory. The converter is therefore suitable for continuous processing. As the start source, either of the software, external triggers (falling edge) and timer (rising edge) can be selected. 342 18.2 Configuration of 8/10-Bit A/D Converter This section describes the block diagram and configuration of 8/10-bit A/D converter. ■ Block Diagram of 8/10-bit A/D Converter Figure 18.2-1 shows a block diagram of the 8/10-bit A/D converter. Figure 18.2-1 Block Diagram of 8/10-bit A/D Converter AVCC AVRH AVSS D/A converter Sequential comparison register Comparator Data bus AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 Input circuit MPX Decoder Sample and hold circuit Data registers ADCR1, ADCR2 Control status register 1 Control status register 2 ADTG ADCS1, ADCS2 Trigger start Timer start Timer (PPG1 output) φ Operation clock Prescaler 343 CHAPTER 18 8/10-BIT A/D CONVERTER ■ Pin Related to 8/10-bit A/D Converter The pin related to 8/10-bit A/D converter has analog input AN0/AN1/AN2/AN3/AN4/AN5/AN6/AN7 pins and input trigger ADTG pin. The general-purpose I/O port (P60/AN0, P61/AN1, P62/AN2, P63/AN3, P64/ AN4, P65/AN5, P66/AN6, P67/AN7) functions as the analog input pin of A/D, and the general-purpose I/O port (P93/ADTG) functions as the trigger input of A/D. ● Setting when using as AN0/AN1/AN2/AN3/AN4/AN5/AN6/AN7 pins When using as an analog input, be sure to set the port direction register (DDR6: bit7, bit6, bit5, bit4, bit3, bit2, bit1, bit0 → "0") and analog enable register (ADER: bit7, bit6, bit5, bit4, bit3, bit2, bit1, bit0 → "1"). ● Setting when using as ADTG pin When using as external trigger of the A/D converter, P93/ADTG pin should be set to the input port by port direction register (DDR9: bit3 → "0"). ■ Block Diagram of Pin Related to 8/10-bit A/D Converter Figure 18.2-2 Block Diagram of Pin Related to 8/10-bit A/D Converter ADER Port data register (PDR) Peripheral function input (ADTG) Analog input (AN0 to AN7) Internal data bus PDR Read Output latch P-ch PDR Write Pin Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Standby control (SPL=1) Standby control : Stop mode (SPL=1), time-base timer mode (SPL=1), watch mode (SPL=1) 344 18.3 Configuration of 8/10-Bit A/D Converter Registers This section describes the configuration and function of the registers used in the 8/10bit A/D converter. ■ List of Registers for 8/10-bit A/D Converter Figure 18.3-1 illustrates the list of registers for 8/10-bit A/D Converter. Figure 18.3-1 List of Registers for 8/10-bit A/D Converter bit15 bit0 bit8 bit7 ADCS2 ADCR2 ADCS1 ADCR1 8 bits 8 bits Control status register (ADCS1) bit7 bit6 ADCS1 MD1 MD0 Address: 000046H R/W R/W Control status register (ADCS2) bit15 bit14 ADCS2 BUSY INT Address: 000047H R/W R/W Data register (ADCR1) bit7 ADCR1 D7 Address: 000048H R bit6 D6 R 00000000B bit13 bit12 bit11 bit10 bit9 bit8 INTE PAUS STS1 STS0 STRT Reserved R/W R/W R/W R/W W R/W 00000000B bit5 D5 R bit4 D4 R bit3 D3 R bit2 D2 R Data register (ADCR2) bit15 bit14 bit13 bit12 bit11 bit10 ADCR2 S10 ST1 ST0 CT1 CT0 Address: 000049H W W W W W R R/W: R: W: Initial value bit5 bit4 bit3 bit2 bit1 bit0 ANS2 ANS1 ANS0 ANE2 ANE1 ANE0 R/W R/W R/W R/W R/W R/W bit1 D1 R bit0 D0 R XXXXXXXXB bit9 D9 R bit8 D8 R 00000XXXB Readable/writable Read only Write only 345 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3.1 Control Status Register 1 (ADCS1) The control status register 1 (ADCS1) controls the A/D converter and displays the status of operation. ■ Control Status Register 1 (ADCS1) The bit configuration of the control status register 1 (ADCS1) is illustrated below. Figure 18.3-2 Bit Configuration of Control Status Register 1 (ADCS1) Control status register (ADCS1) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ADCS1 MD1 MD0 ANS2 ANS1 ANS0 ANE2 ANE1 ANE0 Address: 000046H R/W R/W R/W R/W R/W R/W R/W R/W R/W: Initial value 00000000B Readable/writable Note: Do not rewrite control status register 1 (ADCS1) during A/D conversion. The function of each bit of the control status register 1 (ADCS1) is described below. [bit7, bit6] MD1, MD0: A/D converter MoDe set (operation mode) These bits specify the operation mode. Operation modes that can be selected are shown below. Table 18.3-1 Operation Mode Setting MD1, MD0 Operation mode 00B Single mode, all ongoing operations can be restarted 01B Single mode, ongoing operations cannot be restarted 10B Continuous mode, ongoing operations cannot be restarted 11B Stop mode, ongoing operations cannot be restarted The functions of each mode are as follows: 346 • Single mode: A/D conversion is continuously performed from the specified channels in the range of ANS2 to ANS0 to the specified channels in the range of ANE2 to ANE0. Operation stops when one cycle of conversion operations ends. • Continuous mode: A/D conversion is repeated from the specified channels in the range of ANS2 to ANS0 to the specified channels in the range of ANE2 to ANE0. • Stop mode: A/D conversion is performed per channel from the specified channels in the range of ANS2 to ANS0 to the specified channels in the range of ANE2 to ANE0. After that, operation temporarily stops. Resuming conversion is triggered by a start source. These bits are initialized to "00B" at reset. Each operation mode operates as follows: • After start of A/D conversion in continuous or stop mode, conversion will continue until operation is stopped via the BUSY bit. • Operation in each operation mode is stopped by setting the BUSY bit to "0". • "Restart disable" in the single, continuous, and stop modes affects all start factors by timer, external trigger, and software. [bit5, bit4, bit3] ANS2, ANS1, ANS0: ANalog Start channel set Set a start channel for A/D conversion using these bits. At the startup of the A/D converter, A/D conversion starts with the channel selected by these bits. Table 18.3-2 Start Channel Setting of A/D Conversion • • ANS2 ANS1 ANS0 Start channel 0 0 0 AN0 0 0 1 AN1 0 1 0 AN2 0 1 1 AN3 1 0 0 AN4 1 0 1 AN5 1 1 0 AN6 1 1 1 AN7 During read out • These bits are used for reading conversion channels during A/D conversion. • When conversion stops in stop mode, the previous conversion channels will be read out. These bits are initialized to "000B" at reset The read values of these bits are updated during the start of A/D conversion, and before A/D conversion starts, the previous conversion channel will be read even if these bits have already been set to the new value. 347 CHAPTER 18 8/10-BIT A/D CONVERTER [bit2, bit1, bit0] ANE2, ANE1, ANE0: ANalog End channel set These bits specify the end channel for A/D conversion. Table 18.3-3 End Channel Setting of A/D Conversion ANE2 ANE1 ANE0 End channel 0 0 0 AN0 0 0 1 AN1 0 1 0 AN2 0 1 1 AN3 1 0 0 AN4 1 0 1 AN5 1 1 0 AN6 1 1 1 AN7 • Specifying the same channels as for ANS2 to ANS0 will result in one-channel conversion (Single conversion). • If continuous mode or stop mode is set, the channels specified by ANS2 to ANS0 will be set again when conversion of the channels specified by these bits ends. • If ANS < ANE, conversion will start from the channel set by ANS; after conversion has been performed up to channel 7, the setting channel will be set to channel 0, and conversion will be performed up to end channel set by ANE. • These bits are initialized to "000B" at reset. Example: Channel setting: Operation: Single Mode with ANS = ch.6 and ANE = ch.3 conversion channel ch.6 → ch.7 → ch.0 → ch.1 → ch.2 → ch.3 Note: Please do not set the A/D conversion mode setting bits (MD1, MD0) and the A/D conversion end channel selection bits (ANE2, ANE1 and ANE0) by the read-modify-write type instruction after setting the start channel to the A/D conversion start channel selection bits (ANS2, ANS1, ANS0). The last conversion channel is read from the ANS2, ANS1 and ANS0 bits until the A/D conversion operating starts. Therefore, when MD1, MD0, ANE2, ANE1 and ANE0 bits are set by the read-modify-write type instruction after setting the start channel to ANS2, ANS1 and ANS0 bits, the value of the ANE2, ANE1 and ANE0 bits may be overwritten. 348 18.3.2 Control Status Register 2 (ADCS2) The control status register 2 (ADCS2) is used for A/D converter control and status display. ■ Control Status Register 2 (ADCS2) The bit configuration of the control status register 2 (ADCS2) is illustrated below. Figure 18.3-3 Bit Configuration of Control Status Register 2 (ADCS2) Control status register (ADCS2) bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 ADCS2 BUSY INT INTE PAUS STS1 STS0 STRT Reserved Address: 000047H R/W R/W R/W R/W R/W R/W W R/W R/W: W: Initial value 00000000B Readable/writable Write only The function of each bit of the control status register 2 (ADCS2) is described below. [bit15] BUSY: busy flag and stop • During reading: This bit indicates A/D converter operation. It is set when A/D conversion starts and cleared when A/D conversion ends. • During writing: Setting this bit by writing "0" during A/D operation will forcibly stop operation. Use this bit to force stopping in continuous mode or stop mode. When the bit is used for operation display, it cannot be set by writing "1". RMW-instructions will always read "1". In single mode, this bit is cleared when A/D conversion ends. In continuous and stop mode, the bit is not cleared until operation is stopped by writing "0". This bit is initialized to "0" at reset. Note: Do not execute forced stop and software start simultaneously. (BUSY = 0, STRT = 1) [bit14] INT: Interrupt This bit is a data indication bit. This bit will be set when conversion data is written to the ADCR. Setting this bit when bit5 (INTE) is "1" generates an interrupt request. If μDMAC start is enabled, μDMAC will be started. Writing "1" has no effect. Write "0" and use a μDMAC interrupt clear signal to clear. This bit is initialized to "0" at reset. See "■ Caution when Using the Conversion Data Protection Function" in Section "18.6 Conversion Data Protection Function of 8/10-Bit A/D Converter". Note: Clear this bit by writing "0" only while A/D conversion is not being performed. 349 CHAPTER 18 8/10-BIT A/D CONVERTER [bit13] INTE: interrupt enable This bit is used to enable or disable interrupts at conversion end. • 0: Interrupts prohibited • 1: Interrupts allowed Set this bit when using μDMAC. An interrupt request will then trigger μDMAC start. This bit is initialized to "0" at reset. See "■ Caution when Using the Conversion Data Protection Function" in Section "18.6 Conversion Data Protection Function of 8/10-Bit A/D Converter". [bit12] PAUS: A/D converter pause This bit is set when A/D conversion pauses. There is only one register for storing the results of A/D conversion. When conversion is performed continuously, unless conversion results have to be transferred by μDMAC, or data stored previously will be overwritten. To prevent overwriting data, the next conversion result cannot be stored before the contents of the data register has been transferred by μDMAC, and A/D conversion will be stopped in between. The A/D converter resumes conversion as soon as data transfer by μDMAC ends. This register is effective only when μDMAC is used. See "■ Caution when Using the Conversion Data Protection Function" in Section "18.6 Conversion Data Protection Function of 8/10-Bit A/D Converter". This bit is initialized to "0" at reset. 350 [bit11, bit10] STS1, STS0: start source select These bits select A/D start sources. Table 18.3-4 Selection of A/D Start Sources STS1 STS0 Function 0 0 Software start 0 1 Start by an external pin trigger and by software 1 0 Start by timer and software 1 1 Start by an external pin trigger, timer, and software In a mode for which two start sources apply, the first of the sources to occur will trigger start. Start sources become effective from the time they are rewritten. Exercise caution when rewriting during A/D operation. • When an external pin trigger is selected, a falling edge is detected. • When the external trigger input level is "L", A/D conversion will start as soon as this bit is rewritten to select the external trigger start. • The output of PPG1 is selected at the time the timer is selected. These bits are initialized to "00B" at reset. Note: When starting the A/D converter by an external trigger or an internal timer, set the input value of the internal timer and the external trigger only in inactive state. For setting STS1 and STS0, set in the state of ADTG=1 input and internal timer (PPG1) = 0 output. [bit9] STRT: start 8/10-bit A/D converter is started by software. • Set this bit by writing "1" to start A/D conversion. • For restarting, write this bit again. • When stop mode is set, operation cannot be restarted by an operational function. • This bit is initialized to "0" at reset. • The byte/word instructions read "1". • The read-modify-write type instructions read "0". Note: Do not execute forced stop and software start simultaneously. (BUSY = 0, STRT = 1) [bit8] Reserved In write operations, write "0". 351 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3.3 Data Registers (ADCR2 and ADCR1) The configurations and functions of the data registers (ADCR2 and ADCR1) are explained below. ■ Data Registers (ADCR2 and ADCR1) The bit configuration for the data registers (ADCR2 and ADCR1) is described below. Figure 18.3-4 Bit Configuration of Data Registers (ADCR2 and ADCR1) Data register (ADCR1) bit7 ADCR1 D7 Address: 000048H R bit6 D6 R bit5 D5 R bit4 D4 R bit3 D3 R bit2 D2 R Data register (ADCR2) bit15 bit14 bit13 bit12 bit11 bit10 ADCR2 S10 ST1 ST0 CT1 CT0 Address: 000049H W W W W W R R: Read only W: Write only bit1 D1 R bit0 D0 R bit9 D9 R bit8 D8 R Initial value XXXXXXXXB 00000XXXB The data registers (ADCR2 and ADCR1) are registers for storing conversion results as digital values. The upper two bits of conversion values are stored in ADCR2, and the lower eight bits are stored in ADCR1. The values of these registers are updated at the end of each conversion. Normally, the last conversion value is stored. The S10-bits must be rewritten if A/D operation stops before conversion ends. Rewriting after conversion may result in an undefined ADCR data. To read ADCR registers with 10-bit mode specified, always use a word instruction. The ADCR registers have a conversion data protection function. Refer to Section "18.6 Conversion Data Protection Function of 8/10-Bit A/D Converter". Do not write data to these registers during A/D operation. When S10 bit is set to "0", conversion results will be output in units of ten bits; when S10 bit is set to "1", conversion results will be output in units of eight bits. Table 18.3-5 Setting of Sampling Time and Compare Time ST1 ST0 Sampling time setting bit CT1 CT0 Compare time setting bit 0 0 20 machine cycles (0.8 μs@25MHz) 0 0 44 machine cycles (1.76 μs@25MHz) 0 1 32 machine cycles (1.28 μs@25MHz) 0 1 66 machine cycles (2.64 μs@25MHz) 1 0 48 machine cycles (1.92 μs@25MHz) 1 0 88 machine cycles (3.52 μs@25MHz) 1 1 128 machine cycles (5.12 μs@25MHz) 1 1 176 machine cycles (7.04 μs@25MHz) Note: 352 Setting ST1 and ST0 = 00 or 01 during operation at 25 MHz may prevent the proper analog voltages from being obtained. 18.4 Interrupt of 8/10-Bit A/D Converter The 8/10-bit A/D converter generates the interrupt request when the A/D conversion is terminated, and the conversion result is stored to the A/D data register (ADCR). Also, it can activate the DMA transfer and extended intelligent I/O service (EI2OS). ■ Interrupt of 8/10-bit A/D Converter The interrupt control bit and the interrupt source of the 8/10-bit A/D converter is shown in the following table. Table 18.4-1 Interrupt of A/D Conversion and Interrupt Source Interrupt of A/D conversion Interrupt source Interrupt request flag ADCS:INT (bit14) Interrupt request output enable bit ADCS:INTE (bit13) Interrupt generation source A/D conversion result is stored to A/D data register (ADCR). ■ Interrupt of A/D Converter When A/D conversion of the analog input voltage is terminated and its results are stored in the data register (ADCR), the interrupt request flag bit in the A/D control status register (ADCS: INT) is set to "1". Interrupt request is generated when the interrupt request flag bit (ADCS: INT=1) is set with interrupt request output enabled (ADCS: INTE=1). ■ Interrupt of 8/10-bit A/D Converter, DMA Transfer, and EI2OS Table 18.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 18.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register Interrupt source A/D converter* ❍: *: EI2OS clear μDMAC channel number Number Address Number Address ❍ 15 #40 FFFF5CH ICR14 0000BEH Interrupt vector Interrupt control register Interrupt request flag is cleared. This interrupt source shares the interrupt source and interrupt number of other peripheral function. For details, see Table 4.2-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, the other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. 353 CHAPTER 18 8/10-BIT A/D CONVERTER ■ Correspondence to DMA Transfer and EI2OS Function The interrupt of the A/D converter corresponds to the DMA transfer function and EI2OS function. When the DMA or EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 354 18.5 Operations of 8/10-Bit A/D Converter The 8/10-bit A/D converter operates based on a sequential comparison method and has a 10-bit resolution. The 8/10-bit A/D converter has only one register for storing results of conversion (10bit). Data registers (ADCR1 and ADCR2) are updated whenever one conversion operation ends. The converter therefore does not support continuous conversion processing. It is recommended that conversion be performed while transferring conversion data to memory using the μDMAC function of F2MC-16LX. This section describes the operations of the 8/10-bit A/D converter. ■ Operation Modes ● Single Mode In this mode, analog input set by the bits ANS and ANE is sequentially converted. The converter stops conversion operation when conversion up to the end channel set by the bit ANE is finished. If the start and end channels are the same (ANS = ANE), one-channel conversion will be performed. Example: ANS = 000B, ANE = 011B Start --> AN0 --> AN1 --> AN2 --> AN3 --> End ANS = 010B, ANE = 010B Start --> AN2 --> End ● Continuous Mode In this mode, analog input set by the bits ANS and ANE is sequentially converted. The converter continues conversion operation by returning to ANS analog input when conversion up to the end channel set by the bit ANE is finished. One-channel conversion operation will continue if the start and end channels are the same. (ANS = AME) Example: ANS = 000B, ANE = 011B Start --> AN0 --> AN1 --> AN2 --> AN3 --> AN0 ...... --> Repeat ANS = 010B, ANE = 010B Start --> AN2 --> AN2 --> AN2 ...... --> Repeat When conversion is performed in continuous mode, conversion operation will be repeated until the BUSY bit is set by writing "0". Set the BUSY bit to "0" to forcibly stop operation. When operation is stopped forcibly, data before the completion of conversion will be stored in the conversion registers. 355 CHAPTER 18 8/10-BIT A/D CONVERTER Note: When operation is forcibly stopped in continuous mode, conversion data retains data before operation of forced stop. ● Stop Mode In this mode, analog input specified by the bits ANS and ANE is sequentially converted. However, conversion operation stops temporarily after conversion of each channel. To release the temporary stop, it is necessary to start A/D conversion again. Analog input of channel set by ANS will be resumed and A/D conversion will continue when conversion up to the end channel specified by the bit ANE ends. One-channel conversion will be performed if the start and end channels are the same. (ANS = ANE) Example: ANS = 000B, ANE = 011B Start --> AN0 --> Stop --> Activate --> AN1 --> Stop --> Activate --> --> AN2 --> Stop --> Activate --> AN3 --> Stop --> Activate --> AN0 ...... --> Repeat ANS = 010B, ANE = 010B Start --> AN2 --> Stop --> Activate --> AN2 --> Stop --> Activate --> AN2 ...... --> Repeat Only A/D startup sources specified by STS1 and 0 can be used in this mode. Operation in this mode enables synchronizing the start of multiple conversions. 356 ■ Conversion Operation Using μDMAC Figure 18.5-1 shows an example of the operational flow (in continuous mode) from start of A/D conversion to transfer of conversion data. Figure 18.5-1 Example of Operation Flow (in Continuous Mode) from Start of A/D Conversion to Transfer of Conversion Data A/D conversion start Sample and hold μDMAC start Conversion Data transfer Interrupt processing Conversion end Interrupt clear Interrupt triggered The result of the decision operation marked by " μDMAC. " in the diagram is decided based on the settings of 357 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5.1 Example of μDMAC Start in Single Mode An example of μDMAC start in the single mode is described below. ■ Example of μDMAC Start in Single Mode An example of start operation is based on the conditions described below: • Conversion finishes after conversion up to analog input (AN1 to AN3). • Conversion data is transferred to addresses 200H to 206H sequentially. • Start by software • The highest interrupt level is used Setting item Sample program MOV ICR14,#00H Operation Sets highest interrupt level and enables interrupts MOV BAPL,#00H MOV BAPM,#02H Address to transfer conversion data MOV BAPH,#00H μDMAC setting MOV DMACS,#18H Set DMA control status register (Transfers word data and increments the transfer address after transfer). MOV IOA,#48H Stores A/D converter results in registers MOV DCT,#03H Set the number of transfer (three transfers) MOVW DERL,#8000H Setting for the μDMAC enable register (EN15) MOV ADCS1,#0BH Single mode, start channel AN1, end channel AN3 MOV ADCS2,#A2H Start by software, A/D conversion start WBTC io ADCS2:7 Determines end of A/D conversion MOV ADCS2,#000H Resource interrupt clear MOVW DSRL,#0000H μDMAC status register clear RETI Return from interrupt A/D converter setting μDMAC end sequence ICR14: BAPL: BAPM: BAPH: ISCS: IOA: DCT: 358 Interrupt control register Buffer address pointer lower Buffer address pointer middle Buffer address pointer higher Status register Address register Data counter Figure 18.5-2 shows an example of the operational flow for start of conversion. Figure 18.5-2 Sample Operation Flow for μDMAC Start Operation in Single Mode Start AN1 Interrupt → μDMAC transfer AN2 Interrupt → μDMAC transfer AN3 Interrupt → μDMAC transfer End Interrupt sequence Performed in parallel 359 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5.2 Example of μDMAC Start in Continuous Mode An example of μDMAC start in the continuous mode is described below. ■ Example of μDMAC Start in Continuous Mode An example of start operation is based on the conditions described below: • Analog input (AN3 to AN5) is converted, and two items of data for conversion are obtained from each channel. • Conversion data is transferred to addresses 600H to 60CH sequentially. • Start by an external edge • The highest interrupt level is used. Setting item Sample program MOV ICR14,#00H Operation Sets highest interrupt level and enables interrupts MOV BAPL,#00H MOV BAPM,#06H Address to transfer conversion data MOV BAPH,#00H μDMAC setting MOV DMACS,#18H Set DMA control status register (Transfers word data and increments the transfer address after transfer). MOV IOA,#48H Stores A/D converter results in registers MOV DCT,#06H Set the number of transfer (six transfers) MOVW DERL,#8000H Setting for the μDMAC enable register (EN15) MOV ADCS1,#9DH Single mode, start channel AN3, end channel AN5 MOV ADCS2,#A4H Start by external edge, start of A/D conversion WBTC io ADCS2:7 Determines end of A/D conversion MOV ADCS2,#000H Resource interrupt clear MOVW DSRL,#0000H μDMAC status register clear RETI Return from interrupt A/D converter setting μDMAC end sequence ICR14: BAPL: BAPM: BAPH: ISCS: IOA: DCT: 360 Interrupt control register Buffer address pointer lower Buffer address pointer middle Buffer address pointer higher Status register Address register Data counter Figure 18.5-3 shows a sample operation flow for start processing. Figure 18.5-3 Sample Operation Flow for μDMAC Start Operation in Continuous Mode Start AN3 Interrupt → μDMAC transfer AN4 Interrupt → μDMAC transfer AN5 Interrupt → μDMAC transfer After completing all 6 transfer sessions Interrupt sequence End 361 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5.3 Example of μDMAC Start in Stop Mode An example of μDMAC start in stop mode is described below. ■ Example of μDMAC Start in Stop Mode An example of start operation is based on the conditions described below: • Analog input (AN3) is converted 12 times in preset intervals. • Conversion data is transferred to addresses 600H to 618H sequentially. • Start by an external edge • Interrupts have the highest interrupt level Setting item Sample program MOV ICR14,#00H Operation Sets highest interrupt level and enables interrupts MOV BAPL,#00H MOV BAPM,#06H Address to transfer conversion data MOV BAPH,#00H μDMAC setting MOV DMACS,#18H Set DMA control status register (Transfers word data and increments the transfer address after transfer). MOV IOA,#48H Stores A/D converter results in registers MOV DCT,#0CH Set the number of transfer (twelve transfers) MOVW DERL,#8000H Setting for the μDMAC enable register (EN15) MOV ADCS1,#DBH Continuous mode, start channel AN3, end channel AN3 (onechannel conversion) MOV ADCS2,#A4H Start by external edge, start of A/D conversion WBTC io ADCS2:7 Determines end of A/D conversion MOV ADCS2,#000H Resource interrupt clear MOVW DSRL,#0000H μDMAC status register clear RETI Return from interrupt A/D converter setting μDMAC end sequence ICR14: BAPL: BAPM: BAPH: ISCS: IOA: DCT: 362 Interrupt control register Buffer address pointer lower Buffer address pointer middle Buffer address pointer higher Status register Address register Data counter Figure 18.5-4 shows a sample operation flow for the start operation. Figure 18.5-4 Sample Operation Flow of μDMAC Start Operation in Stop Mode Start AN3 Stop Start by external edge Interrupt → μDMAC transfer After completing all 12 transfer sessions Interrupt sequence End 363 CHAPTER 18 8/10-BIT A/D CONVERTER 18.6 Conversion Data Protection Function of 8/10-Bit A/D Converter This 8/10-bit A/D converter has a conversion data protection function to enable continuous conversion and saving of multiple data items by μDMAC. ■ Conversion Data Protection Function The 8/10-bit A/D converter has only a single conversion data register. In continuous A/D conversion, conversion data is lost when the next conversion operation ends and its result is stored in the register. To prevent this, the A/D converter temporarily stops A/D conversion without storing a conversion result to the register in cases when a conversion has been completed, but the result of the previous conversion has not been transferred yet to memory via μDMAC. The temporary stop is canceled after the conversion data has been transferred to memory by μDMAC. Provided conversion data is transferred normally, A/D conversion continuously performs without pausing. ■ Caution when Using the Conversion Data Protection Function This function corresponds to the INT and INTE bits of ADCS2 register. The conversion data protection function operates only in the interrupt enabled state (INTE = 1). In interrupt disabled state (INTE = 0), this function does not operate. In continuous A/D conversion, conversion results will be stored to the register in succession and older results are lost. If μDMAC is not used in the interrupt enabled state (INTE = 1), the INT bit will not be cleared and the data protection function becomes effective, stopping the operation of the 8/10-bit A/D converter temporarily. Clear the INT bit by the interrupt sequence in this case to cancel the stop. When interrupts are disabled during DMA operation while A/D conversion is temporarily stopped, data in the conversion data registers will sometimes change before A/D conversion starts and data is transferred. Data that was stored during the stop will be lost if data conversion is restarted during operation stop. 364 ■ Operation Flow of Conversion Data Protection Function (when μDMAC is Used) Figure 18.6-1 shows the operation flow of the conversion data protection function. Figure 18.6-1 Operation Flow of Conversion Data Protection Function (when μDMAC is Used) μDMAC setting The operation flow for the case in which the A/D converter is not running is omitted. Start of continuous A/D conversion First conversion finished *: Conversion data will be lost if conversion is restarted during a temporary stop. Store the result in the data register μDMAC start Second conversion finished End of μDMAC NO YES Store the result in the data register Third conversion finished A/D converter pause* YES μDMAC ends NO μDMAC starts Continued All conversions finished μDMAC starts Interrupt routine End A/D converter stop 365 CHAPTER 18 8/10-BIT A/D CONVERTER 18.7 Precautions When Using the 8/10-Bit A/D Converter This section explains precautions required when the 8/10-bit A/D converter is used. ■ Precautions when Starting by External Trigger/Internal Timer To start the A/D converter by an external trigger or the internal timer, specify the input values of the external trigger and internal timer only in the inactive state. When STS1 and STS0 are set, perform conversion with ADTG = 1 input and internal timer (PPG1) = 0 output. ■ Handling of Analog Input Pins Be sure to set the ADER bits corresponding to the pins used in analog input to "1". Figure 18.7-1 Handling of Analog Input Pins bit 7 6 5 4 3 2 1 0 Initial value Address: 00001FH ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 ADE0 11111111B R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/writable The settings for pin control of the pins of port 6 are as follows: • 0: Port input/output mode • 1: Analog input mode At reset, "1" will be set. 366 18.8 Program Example of 8/10-Bit A/D Converter This section describes the program example of the 8/10-bit A/D converter. ■ Program Example of 8/10-bit A/D Converter Example of setting procedure Program example An example that A/D-converts the level input by AN0 (single conversion, software trigger) is shown below. void AD_sample() { AD0_INITIAL(); AD0_ch0_start(); } <Initial setting> void AD0_INITIAL(void) { IO_DDR6.bit.D60 = 0; IO_ADER.bit.ADE0 = 1; •Enable AN0 input Set port input Enable A/D input of AN0 •A/D0 conversion time Set conversion time Set sampling time>> Set compare time>> Register name. bit name DDR6. P60 ADER.ADE0 ADCR2 .ST1, ST0 .CT1, CT0 •Control A/D0 Register name. bit name Control status register 1 ADCS1 .MD1, MD0 .ANS2 to ANS0 .ANE2 to ANE0 Select operation mode>> Set start channel>> Set end channel>> Control status register 2 Clear interrupt request flag>> Disable interrupt>> Select start trigger>> ADCS2 .BUSY .INT .INTE .PAUS .STS1, STS0 .STRT .Reserved bit IO_ADCR2.byte = 0x70; /* Value is recommended value */ /* 11 */ /* 10 */ IO_ADCS1.byte= 0x00; /* Setting value : 00000000 (bit) */ /* bit7, bit6=00: single mode */ /* bit5 to bit3=000: AN0 */ /* bit2 to bit0=000: AN0 */ IO_ADCS2.byte= 0x00; /*Setting value : 00000000 (bit) */ /* bit15=0: (no effect) */ /* bit14=0: Clear interrupt request */ /* bit13=0: Disable interrupt */ /* bit12=0: */ /* bit11, bit10=00: Software trigger */ /* bit9=0: */ /* bit8=0: "0" Write */ IO_ICR14.byte= 0x00; __EI(); /* Arbitrary value */ /* Enable interrupt */ •Interrupt related Set A/D interrupt level Set I flag ICR14 (CCR) /* DDR6 AN0(P60) input */ /* AN0 only, A/D input */ } <Start A/D> •Start AN0 Enable A/D0 interrupt Register name. bit name Start A/D0 software ADCS2 .STRT ADCS2 .INT .INTE void AD0_ch0_start(void) { IO_ADCS2.byte= 0x20; /* bit14=0: Clear AD0 interrupt flag */ /* bit13=1: Enable AD0 interrupt */ IO_ADCS2.byte= 0xA2; /* bit9=1: Start software */ } (Continued) 367 CHAPTER 18 8/10-BIT A/D CONVERTER (Continued) <Interrupt> •Read conversion value Disable interrupt, clear interrupt request flag Register name. bit name __interrupt void AD0_ch0_int(void) { ADCS2 .INT .INTE Read conversion value ADCR1- 2 Enable interrupt ADCS2 .INTE IO_ADCS2.bit.INT = 0; IO_ADCS2.bit.INTE = 0; /* */ /* Bit14=0: Clear AD0 interrupt flag */ /* Bit13=0: Disable AD0 interrupt */ [Any storage location] = IO_ADCR1-2; IO_ADCS2.bit.INTE = 1; /* Store conversion value */ /* Bit13=1: Enable AD0 interrupt */ } <Interrupt vector> • Set vector table #pragma intvect AD0_ch0_int 40 Note: Setting related to clock and setting of _set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC16LX FAMILY MB90980 SERIES". ■ Setting Method Other than Program Example ● Type of conversion mode and setting method The following three conversion modes are available. • Single conversion mode to convert once and terminate • Continuous conversion mode to convert specified channels • Stop mode to temporarily stop after specified channels are converted The conversion mode is set by the conversion mode selection bits (ADCS1. MD[1:0]). Table 18.8-1 Type of Conversion Mode and Setting Method Operation mode Conversion mode selection bits (MD[1:0]) To set to single conversion mode Set to "00B", "01B" To set to continuous conversion mode Set to "10B" To set to stop mode Set to "11B" ● Method to specify bit length Set by the number of storage bits of conversion result (ADCR.S10). Table 18.8-2 Method to Specify Bit Length Operation mode Number of storage bits of conversion result (S10) To store to ADCR1, 2 register with 10-bit Set to "0" To store to ADCR1, 2 register with 8-bit Set to "1" ● Method to select channel Channel to start the conversion is set by the A/D conversion start channel bits (ADCS1.ANS[2:0]). Channel to end the conversion is set by the A/D conversion end channel bits (ADCS1.ANE[2:0]). 368 ● Method to enable analog pin input Set by the analog input enable register (ADER) Table 18.8-3 Method to Enable Analog Pin Input Operation Control bit Setting To input AN0 pin (ADER.ADE0) Set to "1" To input AN1 pin (ADER.ADE1) Set to "1" To input AN2 pin (ADER.ADE2) Set to "1" To input AN3 pin (ADER.ADE3) Set to "1" To input AN4 pin (ADER.ADE4) Set to "1" To input AN5 pin (ADER.ADE5) Set to "1" To input AN6 pin (ADER.ADE6) Set to "1" To input AN7 pin (ADER.ADE7) Set to "1" ● Method to select start of A/D converter The following three start triggers are provided. • Software trigger • Rising signal of reload timer • Falling signal of external trigger input The start trigger is set by the start source select bits (ADCS2.STS[1:0]). Table 18.8-4 Method to Select Start of A/D Converter A/D start source Start source select bits (STS[1:0]) To specify software trigger Set to "00B" To specify external trigger/software trigger Set to "01B" To specify reload timer/software trigger Set to "10B" To specify external trigger/reload timer/software trigger Set to "11B" The A/D converter starts with first source among the selected sources. 369 CHAPTER 18 8/10-BIT A/D CONVERTER ● Method to start A/D converter • Method to generate software trigger The software trigger is set by the A/D conversion software trigger bit (ADCS2:STRT). Table 18.8-5 Method to Generate Software Trigger Operation A/D conversion software trigger bit (STRT) To generate software trigger Write "1" • Method to start by reload timer 0, reload timer 1 It is necessary to set and start the reload timer. For details, see "CHAPTER 15 16-BIT RELOAD TIMER". The start trigger occurs due to underflow of the reload timer when output signal of the reload timer is set to rising edge. • Method to start by external trigger The external trigger is set by the external trigger input pin (ADTG). The external trigger input pin is set by the data direction bit (DDR9.P93). Table 18.8-6 Method to Start by External Trigger Operation Setting To set ADTG pin to trigger input Set bit in data direction register (DDR9:P93) to "0". ● Method to confirm termination of conversion There are two methods to confirm the termination of conversion. • Method to confirm using A/D conversion end interrupt request bit (ADCS2.INT). Table 18.8-7 Method to Confirm Using A/D Conversion End Interrupt Request Bit (INT) Meaning Read value is "0" No interrupt request upon termination of A/D conversion Read value is "1" Interrupt request upon termination of A/D conversion • Method to confirm using operation confirmation bit (ADCS2.BUSY) Table 18.8-8 Method to Confirm Using Operation Confirmation Bit 370 (BUSY) Setting Read value is "0" A/D conversion is terminated (stopping). Read value is "1" A/D conversion is in progress. ● Method to read conversion value The conversion value can be read by the data registers (ADCR1, ADCR2). ● Method to stop A/D conversion operation forcibly Set by the forced stop bit (ADCS2:BUSY). Table 18.8-9 Method to Stop A/D Conversion Operation Forcibly Operation Forced stop bit (BUSY) To stop A/D conversion operation forcibly Write "0" Writing "1" to forced stop bit (BUSY) does not affect the A/D operation. ● Interrupt related register The relationship between the interrupt level and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 18.8-10 Relationship Between Interrupt Level and Interrupt Vector Interrupt vector Interrupt level setting bit #40 Address: 0FFFF5CH Interrupt control register 14 (ICR14) Address: 000BEH ● Type of interrupt The interrupt source is used only when the A/D conversion is ended. There is no bit to be selected. ● Method to enable/disable/clear interrupt Enabling interrupt is set by the interrupt request enable bit (ADCS2:INTE). Table 18.8-11 Method to Enable/Disable Interrupt Content of control Interrupt request enable bit (INTE) To disable interrupt request Set to "0" To enable interrupt request Set to "1" Clearing interrupt request is set by the interrupt request bit (ADCS2:INT). Table 18.8-12 Method to Clear Interrupt Request Content of control Interrupt request bit (INT) To clear interrupt request Write "0" or start A/D. 371 CHAPTER 18 8/10-BIT A/D CONVERTER 372 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE This chapter provides an overview, configuration, interrupt, and operation of the expanded I/O serial interface and explains the configuration and functions of its registers. 19.1 Overview of Expanded I/O Serial Interface 19.2 Configuration of Expanded I/O Serial Interface 19.3 Configuration and Functions of Expanded I/O Serial Interface Registerss 19.4 Interrupt of Expanded I/O Serial Interface 19.5 Operation of Expanded I/O Serial Interface 19.6 Program Example of Expanded I/O Serial Interface 373 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE 19.1 Overview of Expanded I/O Serial Interface The expanded I/O serial interface is a serial I/O interface with an 8-bit/1-channel configuration that is used to transfer data by clock synchronization. For data transfer, LSB first or MSB first can be selected. ■ Overview of Expanded I/O Serial Interface The expanded I/O serial interface has the following two operation modes: 374 • Internal shift clock mode: This mode transfers data by synchronization with the internal clock. • External shift clock mode: This mode transfers data by synchronization with a clock that is supplied via an external pin (SCK). Data can also be transferred with instruction of CPU in this mode by using a general-purpose port that shares the external pin (SCK). 19.2 Configuration of Expanded I/O Serial Interface The expanded I/O serial interface consists of the serial mode control status register and serial data register. ■ Block Diagram of Expanded I/O Serial Interface Figure 19.2-1 shows a block diagram of the expanded I/O serial interface. Figure 19.2-1 Block Diagram of Expanded I/O Serial Interface Internal data bus Initial value D7 to D0 (LSB First) (MSB First) D0 to D7 Select transfer direction SIN1, SIN2 Read Write SDR (Serial data register) SOT1, SOT2 SCK1, SCK2 Control circuit Shift clock counter Internal clock 2 1 0 SMD2 SMD1 SMD0 SIE SIR BUSY STOP STRT MODE BDS SOE SCOE Interrupt request Internal data bus ■ Pin Related to Expanded I/O Serial Interface The pin related to the expanded I/O serial interface has 2ch of SIN1/SOT1/SCK1, SIN2/SOT2/SCK2 pins. The SIN1/SIN2 pins function as the serial input port, the SOT1/SOT2 pins the serial output port, and the SCK1/SCK2 pins the external clock input port. The SIN1, SCK1, SIN2, SCK2 pins function as the generalpurpose I/O port (P90/SIN1, P92/SCK1, P40/SIN2, P42/SCK2) and the input pin of the expanded I/O serial interface, and the SOT1, SOT2 pins function as the general-purpose I/O port (P91/SOT1, P41/SOT2) and the output pin of the expanded I/O serial interface. 375 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE ● Setting when using as SIN1/SCK1/SIN2/SCK2 pins When the SIN1/SCK1/SIN2/SCK2 pins are used as input by the expanded I/O serial interface, P90/SIN1, P92/SCK1, P40/SIN2, P42/SCK2 pins should be set to the input port by the port direction register (DDR9 bit0, bit2→0 DDR4 bit0, bit2→0). ● Setting when using as SOT1/SOT2 pins When the SOT1/SOT2 pins are used as the data output pin by the expanded I/O serial interface, be sure to set the serial mode control status registers 0/1 (SMCS0/SMCS1) to enable serial output (SOE bit1→1). ■ Block Diagram of Pin Related to Expanded I/O Serial Interface Figure 19.2-2 Block Diagram of Pin Related to Expanded I/O Serial Interface Peripheral function input (SIN0/SCK0) Port data register (PDR) Peripheral function output (SOT1/SOT2) Peripheral function output enable Open drain control signal (only P40/P41/P42) PDR Read Internal data bus Output latch P-ch Pin PDR Write Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Stand-by control (SPL=1) Stand-by control: Stop mode (SPL=1), Time-base timer mode (SPL=1), Watch mode (SPL=1) 376 19.3 Configuration and Functions of Expanded I/O Serial Interface Registers This section describes the configuration and functions of the registers used by the expanded I/O serial interface. ■ List of Registers for Expanded I/O Serial Interface Figure 19.3-1 shows a list of the registers used by the expanded I/O serial interface. Figure 19.3-1 List of Registers for the Expanded I/O Serial Interface Serial mode control status register 0/1 (SMCS0/SMCS1) bit15 bit14 bit13 bit12 bit11 bit10 ch.0 Address : 000027H SMD2 SMD1 SMD0 SIE SIR BUSY ch.1 00002BH R/W R/W R/W R/W R/W *1 R Serial mode control status register 0/1 (SMCS0/SMCS1) SMCS0/SMCS1 bit7 bit6 bit5 bit4 bit3 bit2 ch.0 Address : 000026H MODE BDS ch.1 00002AH R/W R/W Serial data register 0/1 (SDR0/SDR1) bit7 bit6 bit5 bit4 bit3 bit2 SDR0/SDR1 ch.0 Address : 000028H D7 D6 D5 D4 D3 D2 ch.1 00002CH R/W R/W R/W R/W R/W R/W Communication prescaler control register 0/1 (SDCR0/SDCR1) SDCR0/SDCR1 bit7 bit6 bit5 bit4 bit3 bit2 ch.0 Address : 000029H MD DIV3 DIV2 ch.1 00002DH R/W R/W R/W R/W: Readable/writable R: Read only -: Undefined *1: Only "0" can be written. *2: Only "1" can be written. Reading always returns "0". bit9 bit8 STOP STRT R/W R/W *2 bit1 bit0 SOE SCOE R/W R/W bit1 D1 R/W bit0 D0 R/W bit1 bit0 DIV1 DIV0 R/W R/W Initial value 00000010B ----0000B XXXXXXXXB (Undefined) 0---0000B 377 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE 19.3.1 Serial Mode Control Status Register 0/1 (SMCS0/SMCS1) This section describes the configuration and functions of the serial mode control status register 0/1 (SMCS0/SMCS1). ■ Serial Mode Control Status Register 0/1 (SMCS0/SMCS1) The serial mode control status register 0/1 (SMCS0/SMCS1) controls the data transfer mode of serial I/O operations. The bit configuration of the serial mode control status register 0/1 (SMCS0/SMCS1) is illustrated below. Figure 19.3-2 Serial Mode Control Status Register 0/1 (SMCS0/SMCS1) Serial mode control status register 0/1 (SMCS0/SMCS1) bit15 bit14 bit13 bit12 bit11 bit10 ch.0 Address : 000027H SMD2 SMD1 SMD0 SIE SIR BUSY ch.1 00002BH R/W R/W R/W R/W R/W *1 R Serial mode control status register 0/1 (SMCS0/SMCS1) SMCS0/SMCS1 bit7 bit6 bit5 bit4 bit3 bit2 ch.0 Address : 000026H MODE BDS ch.1 00002AH R/W R/W bit9 bit8 STOP STRT R/W R/W *2 bit1 bit0 SOE SCOE R/W Initial value 00000010B ----0000B R/W R/W: Readable/writable *1: *2: Only "0" can be written. Only "1" can be written. Reading always returns "0." The functions of the bits of the serial mode control status register 0/1 (SMCS0/SMCS1) are described below. [bit15, bit14, bit13] SMD2, SMD1 and SMD0: Serial Shift Clock Mode (Shift clock select) These bits select the serial shift clock mode. Table 19.3-1 shows the settings for the serial shift clock mode. Table 19.3-1 Settings of Serial Shift Clock Mode SMD2 SMD1 SMD0 φ=16MHz φ=16MHz φ=8MHz φ=4MHz Division div=8 div=8 div=4 div=4 value (Machine clock) Div MD DIV3 DIV2 D1IV D1IV Recommended machine clock cycle 0 0 0 1.56MHz 1MHz 1MHz 500kHz 2 1 1 0 0 0 0 2MHz 0 0 1 781.3kHz 500kHz 500kHz 250kHz 4 2 1 0 0 0 1 4MHz 0 1 0 195.3kHz 125kHz 125kHz 62.5kHz 16 3 1 0 0 1 0 6MHz 0 1 1 97.7kHz 62.5kHz 62.5kHz 31.2kHz 32 4 1 0 0 1 1 8MHz 48.8kHz 31.2kHz 31.2kHz 15.6kHz 64 1 0 0 5 1 0 1 0 0 10MHz 1 0 1 External shift clock mode 6 1 0 1 0 1 12MHz 1 1 0 Reserved 7 1 0 1 1 0 14MHz 1 1 1 Reserved 8 1 0 1 1 1 16MHz or above 378 At reset, the settings will be initialized to "000B". These bits cannot be rewritten while data transfer is in progress. The shift clock can be selected from among five internal shift clocks and one external shift clock. The combinations of SMD2, SMD1, SMD0 = "110B" and "111B" are reserved and must not be set. Shifting can also be performed for individual instructions by setting SCOE = 0 to select the clock and using a port that shares the pins SCK1 and SCK2. [bit12] SIE: Serial I/O Interrupt Enable (Serial I/O interrupt enable) This bit controls serial I/O interrupt requests as shown below. SIE Operation 0 Serial I/O interrupts prohibited (initial value) 1 Serial I/O interrupts allowed • This bit is initialized to "0" at reset. • This bit can be read and written. [bit11] SIR: Serial I/O Interrupt Request Flag (Serial I/O interrupt request) This bit is set to "1" when serial data transfer ends. When this bit becomes "1" in the interrupt enabled state (SIE = 1), an interrupt request to the CPU will be generated. The condition for clearing this bit depends on the setting of the MODE bit: • Cleared by setting the SIR bit to "0" in a write operation when the MODE bit is "0". • Cleared by reading or by writing to the SDR when the MODE bit is "1". • Cleared by reset or by writing "1" for the STOP bit regardless of the value of the MODE bit. • Writing "1" for this bit has no effect. • Reading by read-modify-write instructions always read "1". [bit10] BUSY (transfer status display) This bit indicates whether serial transfer is currently being executed. BUSY Operation 0 Operation is stopped or the serial data register is in the Read/Write wait state (initial value). 1 Serial transfer takes place. • This bit is initialized to "0" at reset. • This bit can only be read. 379 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE [bit9] STOP (Stop bit) This bit is used to forcibly interrupt serial transfer. Setting this bit to "1" will result in operation stop. STOP Operation 0 Normal operation 1 Stop of transfer because of STOP = 1. (initial value) • This bit is initialized to "1" at reset. • This bit can be read and written. [bit8] STRT: Start (start bit) This bit is used to start serial transfer. Write "1" in the stopped state to start transfer. Writing "1" will be ignored during serial transfer operation or in serial shift register Read/Write wait state. • Writing "0" has no effect. • Read operations always read "0". [bit3] MODE (serial mode selection) This bit selects the condition to start from the stopped state. Rewriting this bit during operation is prohibited. MODE Operation 0 STRT = 1 will start operation. (initial value) 1 Started by reading/writing the serial data register. • This bit is initialized to "0" at reset. • This bit can be read and written. • This bit is set to "1" at μDMAC start. [bit2] BDS: Bit Direction Select (Selection of transfer direction) This bit selects whether to start transfer with the LSB side (LSB first) or MSB side (MSB first) during input and output of serial data. BDS Operation 0 LSB first (initial value) 1 MSB first • This bit is initialized to "0" at reset. • This bit can be read and written. Note: Specify the transfer direction before writing data to the SDR. 380 [bit1] SOE: Serial Output Enable (Enable serial output) This bit is used to control the output of the external output pins (SOT1 and 2) for serial I/O. SOE Operation 0 General-purpose port pin (initial value) 1 Serial data output • This bit is initialized to "0" at reset. • This bit can be read and written. [bit0] SCOE: Shift Clock Output Enable (Enable shift clock output) This bit controls output of the external input/output pins (SCK1 and 2) for the shift clock. SCOE Operation 0 Use of general-purpose port pins, transfer for each instruction (initial value) 1 Shift clock output pin Set to "0" when transferring data for each instruction in external shift clock mode. • This bit is initialized to "0" at reset. • This bit can be read and written. 381 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE 19.3.2 Serial Data Register 0/1 (SDR0/SDR1) This section describes the configuration and functions of the serial data register 0/1 (SDR0/SDR1). ■ Serial Data Register 0/1 (SDR0/SDR1) The bit configuration of the serial data register 0/1 (SDR0/SDR1) is illustrated below. Figure 19.3-3 Bit Configuration of Serial Data Register 0/1 (SDR0/SDR1) Serial data register 0/1 (SDR0/SDR1) bit7 bit6 SDR0/SDR1 D6 ch.0 Address : 000028H D7 ch.1 00002CH R/W R/W R/W: bit5 bit4 D5 D4 R/W R/W bit3 D3 R/W bit2 D2 R/W bit1 D1 R/W bit0 D0 R/W Initial value XXXXXXXXB (Undefined) Readable/writable The serial data register 0/1 (SDR0/SDR1) stores transfer data of the serial I/O unit. The SDR cannot be read or written during data transfer. 382 19.3.3 Communication Prescaler Control Register 0/1 (SDCR0/SDCR1) This section describes the configuration and functions of the communication prescaler control register 0/1 (SDCR0/SDCR1). ■ Communication Prescaler Control Register 0/1 (SDCR0/SDCR1) The bit configuration of the communication prescaler control register 0/1 (SDCR0/SDCR1) is illustrated below. Figure 19.3-4 Bit Configuration of Communication Prescaler Control Register 0/1(SDCR0/SDCR1) Communication prescaler control register 0/1 (SDCR0/SDCR1) SDCR0/SDCR1 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 Initial value ch.0 Address : 000029H MD DIV3 DIV2 DIV1 DIV0 0---0000B ch.1 00002DH R/W R/W R/W R/W R/W R/W: Readable/writable -: Undefined The functions of the bits for the communication prescaler control register 0/1 (SDCR0/SDCR1) are described below. [bit15] MD: Machine clock divide moDe select This bit is used to enable operation of the communication prescaler. MD Operation 0 The communication prescaler stops. 1 The communication prescaler operates. [bit11, bit10, bit9, bit8] DIV3, DIV2, DIV1, DIV0: DIVide3 to DIVide0 These bits determine the division ratio of the machine clocks. DIV3 to DIV0 Division Ratio 0000B Division by 1 0001B Division by 2 0010B Division by 3 0011B Division by 4 0100B Division by 5 0101B Division by 6 0110B Division by 7 0111B Division by 8 383 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE Note: When changing the clock division ratio, wait for time of 2 division as a clock stabilization time before the communication is performed. 384 19.4 Interrupt of Expanded I/O Serial Interface The interrupt of the expanded I/O serial interface generates when the transfer of data is terminated. The interrupt of the expanded I/O serial interface can activate the DMA transfer and extended intelligent I/O service (EI2OS). ■ Interrupt of Expanded I/O Serial Interface The following table shows the interrupt control bit and interrupt source of the expanded I/O serial interface. Table 19.4-1 Interrupt Control Bit and Interrupt Source of Expanded I/O Serial Interface Interrupt of serial I/O Interrupt request flag SMCS0:SIR (bit11) ch.0 SMCS1:SIR (bit11) ch.1 Interrupt request output enable bit SMCS0:SIE (bit12) ch.0 SMCS1:SIE (bit12) ch.1 Interrupt generation source Terminate transfer of serial data ■ Interrupt Source Related to Expanded I/O Serial Interface The interrupt of the expanded I/O serial interface generates when the transfer of data is terminated. When the SIE (bit12) flag in the serial mode control status register (SMCS) is set if SIE (bit11): interrupt enable is "1", the interrupt request to CPU is executed. ■ Interrupt of Expanded I/O Serial Interface, DMA Transfer, and EI2OS Table 19.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 19.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register EI2OS clear μDMAC channel number Number Address SIO1 ❍ 13 #37 FFFF68H SIO2 ❍ 14 #38 FFFF64H Interrupt source Interrupt vector Interrupt control register Number Address ICR13 0000BDH ❍: Interrupt request flag is cleared. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, the other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. 385 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE ■ Correspondence to DMA Transfer and EI2OS Function The expanded I/O serial interface corresponds to the DMA transfer function and EI2OS function. When the DMA or EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 386 19.5 Operation of Expanded I/O Serial Interface The expanded I/O serial interface consists of the serial mode control status register (SMCS) and serial data register (SDR). This interface is used for input and output of 8-bit serial data. This section describes the operations of the expanded I/O serial interface. ■ Overview of Operation for Expanded I/O Serial Interface Input and output with serial data are individually performed as follows: ● Serial data input By synchronizing with the rising edge of a serial shift clock (external or internal clock), data is input to the SDR (serial data register) from a serial input pin (SIN1 pin). The shift direction (data transfer beginning with the MSB or LSB) specifies the direction specify bit (BDS) of the serial mode control status register (SMCS). After data transfer is completed, the operation enters the stop state or data register Read/Write wait state as determined by the MODE bit of the serial mode control status register (SMCS). Set the following operation to change from each state to the transfer state: • For return from the stop state, set the STOP bit to "0" and write "1" to the STRT bit to set it. (STOP and STRT can be set simultaneously) • For return from the wait state, perform a read or write operation for the data register. ● Serial data output By synchronizing the shift register with the falling edges of a serial shift clock (external or internal clock), data is output from the serial output pin (SOT1 pin). 387 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE 19.5.1 Shift Clock Modes The shift clock has two modes, the internal shift clock mode and the external shift clock mode. These two modes are specified by the setting of the SMCS. Change the mode only when the serial I/O interface is not operating. This condition can be determined by reading the BUSY bit. ■ Internal Shift Clock Mode This mode uses an internal clock, and a shift clock with a duty ratio of 50% is output via the SCK pin for synchronous timing output. One bit of data is transferred for each clock. The data transfer speed can be calculated as follows: Transfer speed (S) = A Internal clock machine cycle (A) "A" is the following division ratio selected by the SMD bit of SMCS. (φ ÷ div)/2, (φ ÷ div)/22, (φ ÷ div)/24, (φ ÷ div)/25, (φ ÷ div)/26 ■ External Shift Clock Mode In synchronization with an external shift clock supplied via the SCK pin, one bit of data is transferred for each clock. Data can be transferred at a speed up to 1/(8 machine cycles) from DC. For example, data can be transferred at a speed of up to 2 MHz when one machine cycle is 62.5 ns. Transfer for individual instructions can be achieved making the following settings: • Select the external shift clock mode and set the SCOE bit of SMCS to "0". • Write "1" to the direction register of the port that shares the SCK pin, then set the port to output mode. After making the above settings, write "1" and "0" to the port data register (PDR) to obtain the value of the port that is output to the SCK pin for supplying the external clock for data transfer. Start the shift clock as soon as the "H"-level is input. Note: Writing to the SMCS and SDR during serial I/O operation is prohibited. 388 19.5.2 Operational States of Serial I/O Units Four serial I/O states are used, namely, STOP, halt, SDR Read/Write wait, and transfer. ■ Operational States of Serial I/O Units ● STOP State The shift counter is initialized at reset or by writing "1" to the STOP bit of SMCS, resulting in SIR = 0. For returning from the STOP state, set STOP = 0 and STRT= 1 (these bits can be set simultaneously). Because the STOP bit has a higher priority than the STRT bit, data transfer will not be executed even when STRT = 1 is set while STOP = 1. ● Halt State When the MODE bit is set to "0", the BUSY and SIR bits of SMCS will become BUSY = 0 and SIR = 1 after data transfer ends. The counter will then be initialized and set to the halt state. For returning from the halt state, set STRT = 1 to resume data transfer operation. ● Serial Data Register Read/Write Wait State When the MODE bit of SMCS is "1", serial transfer ends, this will result in BUSY = 0 and SIR = 1 and the serial data register Read/Write wait state will be entered. If the interrupt enable register is set to "enable", the applicable block will issue an interrupt signal. When returning from the Read/Write wait state, the BUSY becomes BUSY = 1 and data transfer operation will be resumed as soon as a read or write operation is performed for the serial data register. ● Transfer State In this state, serial transfer is performed if BUSY = 1. Depending on the setting of the MODE bit, the halt or Read/Write wait state will be entered. Figure 19.5-1 shows the state transitions during operation of expanded I/O serial interface. Figure 19.5-2 illustrates the concept of reading and writing the serial data register. 389 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE Figure 19.5-1 State Transitions during Operation of Expanded I/O Serial Interface Reset STOP=0 & STRT=0 Transfer end STOP STOP=1 STRT=0, BUSY=0 MODE=0 MODE=0 STOP=0 & & STOP=0 STRT=1 & End STOP=1 STRT=0, BUSY=0 STOP=0 & STRT=1 Transfer operation MODE = 1 & End & STOP = 0 STRT=1, BUSY=1 SDR Read/Write & MODE=1 STOP=1 Serial data register Read/Write wait STRT=1, BUSY=0 MODE=1 Serial data Figure 19.5-2 Concept of Read and Write for Serial Data Registers SOT Data bus Read SIN Write Interrupt output Expanded I/O serial interface Data bus Read Write CPU (1) (2) Interrupt input Data bus Interrupt controller 1. For MODE = 1, data transfer is ended by the shift clock counter. A read/write wait state will be entered after SIR is set to 1. If the SIE bit is "1", an interrupt signal is generated. An interrupt signal will not be generated; however, if the SIE is inactive or when data transfer is stopped by setting the STOP bit by writing "1". 2. As soon as the serial data register is read or written, the interrupt request will be cleared and serial transfer will start. 390 19.5.3 Start/Stop Timing and Input/Output Timing of Shift Operation Start/stop timing and input/output timing of the shift operation are described below. ■ Start/Stop Timing and Input/Output Timing of Shift Operation • Start Set the STOP bit and STRT bit of SMCS to "0" and "1", respectively. • Stop Operation is stopped by the end of data transfer or as soon as STOP = 1. - If operation stopped because of STOP = 1: Stop is performed while SIR is "0", regardless of the MODE bit. - For an operation stop because of the end of data transfer: SIR is set to "1" and operation is stopped regardless of the MODE bit. Irrespective of the MODE bit, the BUSY bit becomes "1" in the serial data transfer state and "0" during the stop state or Read/Write wait state. Read this bit for checking the data transfer state. Timing charts illustrating the transfer operation in various modes are provided below. DO7 to DO0 in the diagram represent output data. ● Internal shift clock mode (LSB First) Figure 19.5-3 Start/Stop Timing in Shift Operation (Using the Internal Clock) SCK1,SCK2 STRT Output of "1" (Transfer end) (Transfer start) When MODE=0 BUSY SOT1,SOT2 DO7 (Data hold) DO0 ● External shift clock mode (LSB first) Figure 19.5-4 Start/Stop Timing in Shift Operation (Using the External Clock) SCK1,SCK2 STRT (Transfer start) (Transfer end) When MODE=0 BUSY SOT1,SCK2 DO0 DO7 (Data hold) 391 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE ● Instruction shift in external shift clock mode (LSB first) During instruction shift, "H" will be output if the bit corresponding to SCK in PDR is set to "1" and "L" will be output if the bit is set to "0". (If SCOE = 0 when external shift clock mode is selected.) Figure 19.5-5 Instruction Shift in External Shift Clock Mode SCK1,SCK2 PDR SCK bit "0" STRT PDR SCK bit "1" PDR SCK bit "0" (Transfer end) If MODE = 0 BUSY DO6 SOT1,SOT2 DO7 (Data hold) ● Stop by STOP = 1 (LSB first, internal clock used) Figure 19.5-6 Stop Timing when the STOP Bit is Set to "1" SCK1,SCK2 STRT Output of "1" (Transfer end) (Transfer start) If MODE = 0 BUSY STOP DO3 SOT1,SOT2 DO4 DO5 (Data hold) ■ Operation during Serial Data Transfer During serial data transfer, data from the serial output pin (SOT2) is output at a falling edge of the shift clock. Data from the serial input pin (SIN) is input at a rising edge. ● LSB first (if the BDS bit is "0") Figure 19.5-7 Input and Output Shift Timing (LSB First) SCK1,SCK2 SIN1,SIN2 SIN input DI0 DI1 DI2 DI3 DI4 DI5 DI6 DI7 DO4 DO5 DO6 DO7 SOT output SOT1,SOT2 DO0 DO1 DO2 DO3 ● MSB first (If the BDS bit is "1") Figure 19.5-8 Input and Output Shift Timing (MSB First) SCK1,SCK2 SIN1,SIN2 SIN input DI7 DI6 DI5 DI4 DI3 DI2 DI1 DI0 DO3 DO2 DO1 DO0 SOT output SOT1,SOT2 392 DO7 DO6 DO5 DO4 19.5.4 Interrupt Function The expanded I/O serial interface can generate interrupt requests for the CPU. ■ Interrupt Function of Expanded I/O Serial Interface An interrupt request is output to the CPU when the SIR bit, which acts as an interrupt flag, is set at the end of data transfer provided that the SIE bit of the SMCS, which enables interrupts, is "1". Figure 19.5-9 shows the timing for output of interrupt signals. Figure 19.5-9 Timing for Interrupt Signal Output SCK1,SCK2 (Transfer end) BUSY SIR For MODE = 1 SIE=1 SDR RD/WR SOT1,SOT2 DO6 DO7 (Data hold) 393 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE 19.6 Program Example of Expanded I/O Serial Interface This section describes the program example of the expanded I/O serial interface. ■ Program Example of Expanded I/O Serial Interface Table 19.6-1 Program Example of Expanded I/O Serial Interface Example of setting procedure Program example Send data of 1 byte with sio1 (channel 0) void sio_sample(void) { sio_initial(); sio_start(); } <Initial setting> void sio_initial(void) { •Control SIO Set mode register Select shift clock >> Set interrupt enable >> Set interrupt request >> Display transfer state >> Set SOT1, 2 pins >> Set SCK1, 2 pins >> Set control register Set communication prescaler >> Set division ratio >> Register name. bit name SMCS0 .SMD2 to SMD0 .SIE .SIR .BUSY .SOE .SCOE SDCR0 .MD IO_SMCS0.word = 0x3003; /* Setting value = 0011_0000_0000_0011 */ /* bit15 to bit13 = 001 4 division */ /* bit12 = 1 Enable interrupt */ /* bit11 = 0 Clear interrupt request */ /* bit10 = 0 R/W wait state */ /* bit1 = 1 Enable SOE serial output */ /* bit0 = 1 Enable SCOE shift clock output */ IO_SDCR0.byte = 0x83; /* Setting value =1000_0011 */ Enable communication prescaler */ /* bit15 = 1 /* bit11 to bit8 = 11B 4 division */ .DIV3 to DIV0 ÅEInterrupt related Set interrupt level Set I flag IO_ICR13.byte = 0x10; ICR13 (CCR) __EI(); /* Set SIO transmission completion interrupt level (arbitrary value) */ /* Enable interrupt */ } <Start> •Start SIO Send any data Start SIO operation Register name. bit name SDR0 SMCS0 .STRT <Interrupt> •Transmission interrupt processing Initialize interrupt flag Register name. bit name SMCS0 .SIR void sio_start(void) { IO_SDR0 = 0xaa; IO_SMCS0.bit.STRT = 1; } __interrupt void sio_int(void) { IO_SMCS0.bit.SIR = 0; } /* Send any value of data */ /* bit1 = 1 Enable SIO operation */ /* bit0 = 0 Initialize SIR interrupt flag */ <Interrupt vector> •Set vector table #pragma intvect sio_int 37 Note: Setting related to clock and setting of __set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". 394 ■ Setting Method Other than Program Example ● Type of operation clock and selection method There are two operation clocks: internal timer and external clock. Set by the shift clock select bits (SMCS0.SMD[2:0], SMCS1.SMD[2:0]). Table 19.6-2 Type of Operation Clock and Selection Method Content of control Shift clock select bits (SMD[2:0]) To select internal timer Set to "000B" to "100B" To select external clock Set to "101B" ● Method to control SCK, SIN, SOT pins Set by SIO1, SIO2. Table 19.6-3 Method to Control SCK, SIN, SOT Pins Operation SIO1 SIO2 To input SCK pin DDR9: P92 = 0 DDR4: P42 = 0 To output SCK pin SMCS0: SCOE = 1 SMCS1: SCOE = 1 To input SIN pin DDR9: P90 = 0 DDR4: P40 = 0 To output SOT pin SMCS0: SOE = 1 SMCS1: SOE = 1 ● Method to enable/stop SIO operation Set by the start bit (SMCS0.STRT, SMCS1.STRT). Table 19.6-4 Method to Enable SIO Operation Content of control Start bit (STRT) Start serial transfer Set to "1" Set by the stop bit (SMCS0.STOP, SMCS1.STOP). Table 19.6-5 Method to Stop SIO Operation Content of control Stop bit (STOP) Stop serial transfer Set to "1" 395 CHAPTER 19 EXPANDED I/O SERIAL INTERFACE ● Method to set transfer direction Set by the setting direction selection bit (SMCS0.BDS, SMCS1.BDS). The transfer direction of LSB/MSB can be selected from any operation mode. Table 19.6-6 Method to Set Transfer Direction Content of control Setting direction selection bit (BDS) To set to LSB transfer (from least significant bit) Set to "0" To set to MSB transfer (from most significant bit) Set to "1" ● Interrupt related register The relationship between the SIO number, interrupt level, and interrupt vector is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 19.6-7 Relationship Between SIO Number, Interrupt Level, and Interrupt Vector Interrupt vector Interrupt level setting bit SIO1 #37 Address : 0FFFF68H Interrupt level register (ICR13) Address : 000BDH SIO2 #38 Address : 0FFFF64H Interrupt level register (ICR13) Address : 000BDH ● Type of interrupt One interrupt is provided. It generates when transfer of the serial data is terminated. ● Method to enable/disable/clear interrupt Enabling/disabling interrupt is set by the interrupt request enable bit (SMCS0.SIE, SMCS1.SIE). Table 19.6-8 Method to Enable/Disable Interrupt Content of control Interrupt request enable bit (SIE) To disable interrupt request Set to "0" To enable interrupt request Set to "1" Clearing interrupt request is set by the interrupt request flag (SMCS0.SIR, SMCS1.SIR). Table 19.6-9 Method to Clear Interrupt Request 396 Content of control Interrupt request flag (SIR) To clear interrupt request Set to "0" CHAPTER 20 UART This chapter provides an overview, configuration, interrupt, operation, precautions on use, and program example of the UART and explains the configuration and functions of its registers. 20.1 Overview of the UART 20.2 Configuration of UART 20.3 Configuration and Functions of UART Registers 20.4 Interrupt of UART 20.5 UART Operations 20.6 Precautions on Using the UART 20.7 Program Example of UART 397 CHAPTER 20 UART 20.1 Overview of the UART The UART is a serial I/O port for asynchronous (start-stop synchronization) communications or CLK synchronous communication. ■ UART Features The UART has the following features: 398 • Built-in full-duplex double buffer • Both asynchronous (start-stop synchronization) and CLK synchronous communication (no start bit and stop bit) are available • Support of multiprocessor mode • Built-in dedicated baud rate generator • In asynchronous: 76923/38461/19230/9615/500k/250kbps • In CLK synchronous: 16M/8M/4M/2M/1M/500kbps • Free baud rate setting via external clock • Internal clock supplied by PPG1 can be used • Data length: 7 bits (asynchronous normal mode only)/8 bits • Master/slave communication function (in multiprocessor mode): 1 (master) to n (slaves) communication enabled • Error detection function (parity, framing, overrun) • Transfer signal: NRZ code • DMA support (reception/transmission) 20.2 Configuration of UART The UART consists of the serial mode register, serial control register, serial status register, communication prescaler control register, serial input/output register. ■ UART Block Diagram Figure 20.2-1 shows a block diagram of the UART. Figure 20.2-1 Block Diagram of the UART Control signal Reception interrupt (to CPU) Dedicated baud rate generator PPG1 (internal connection) SCK0 Clock selector circuit Reception Transmission clock Send interrupt (to CPU) clock External clock SIN0 Reception control circuit Transmission control circuit Start-bit detector circuit Transmission start circuit Reception bit counter Transmission bit counter Reception parity counter Transmission parity counter SOT0 Reception state detection circuit Reception shift register Reception DMAC reception control circuit error transmission Serial input signal (to CPU) register (SIDR) Transmission shift register Transmission start Serial output register (SODR) F2MC-16LX bus Serial mode register (SMR) MD1 PEN MD0 P CS2 CS1 CS0 Serial control register (SCR) SBL CL A/D REC PE ORE Serial status register (SSR) FRE RDRF TDRE BDS SCKE REX RIE SOE TXE TIE Control signal 399 CHAPTER 20 UART ■ Pin Related to UART The pin related to the UART has the SIN0/SOT0/SCK0 pins. The SIN0 pin functions as the serial input port, the SOT0 pin the serial output port, and the SCK0 pin the external clock input port. The SIN0, SCK0 pins function as the general-purpose I/O port (P70/SIN0, P72/SCK0) and the input pin of UART, and the SOT0 pin functions as the general-purpose I/O port (P71/SOT0) and the output pin of UART. ● Setting when using as SIN0/SCK0 pins When the SIN0/SCK0 are used as the input pin by the UART, the P70/SIN0, P72/SCK0 pins should be set to the input port by the port direction register (DDR7 bit0, bit2→0). ● Setting when using as SOT0 pin When the SOT0 is used as the data output pin by the UART, be sure to set the serial mode register (SMR) to the serial data output (SOE bit0→1). ■ Block Diagram of Pin Related to UART Figure 20.2-2 Block Diagram of Pin Related to UART Peripheral function input (SIN0/SCK0) Port data register (PDR) Peripheral function output (SOT1/SOT2) Peripheral function output enable Open drain control signal (only P40/P41/P42) PDR Read Internal data bus Output latch P-ch Pin PDR Write Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Stand-by control (SPL=1) Stand-by control: Stop mode (SPL=1), Time-base timer mode (SPL=1), Watch mode (SPL=1) 400 20.3 Configuration and Functions of UART Registers This section describes the configuration and functions of the registers used by the UART. ■ List of UART Registers Figure 20.3-1 lists the UART registers. Figure 20.3-1 List of UART Registers bit15 bit8 bit7 SCR SSR CDCR 8 bits bit0 SMR SIDR(R)/SODR(W) - (R/W) (R/W) 8 bits Serial mode register (SMR) Address: bit7 bit6 bit5 bit4 bit3 bit2 bit1 000020H MD1 MD0 CS2 CS1 CS0 Reserved SCKE R/W R/W R/W R/W R/W R/W R/W Serial control register (SCR) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 000021H PEN P SBL CL A/D REC RXE R/W R/W R/W R/W R/W W R/W Serial input register (SIDR)/serial output register (SODR) Address: bit7 bit6 bit5 bit4 bit3 bit2 bit1 D6 D5 D4 D3 D2 D1 000022H D7 R/W R/W R/W R/W R/W R/W R/W Serial status register (SSR) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 000023H PE ORE FRE RDRF TDRE BDS RIE R R R R R R/W R/W Communication prescaler control register (CDCR) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 DIV3 DIV2 DIV1 000025H MD SRST R/W R/W R/W R/W R/W R/W: R: W: -: (R/W) Initial value bit0 SOE R/W 00000X00B bit8 TXE R/W 00000100B bit0 D0 R/W XXXXXXXXB bit8 TIE R/W 00001000B bit8 DIV0 R/W 00--0000B Readable/writable Read only Write only Undefined Note: When setting a UART register, set the communication mode while the UART is not in operation. When the communication mode is changed while operation is in progress, the data in send/receive operations cannot be assured. 401 CHAPTER 20 UART 20.3.1 Serial Mode Register (SMR) This section describes the configuration and functions of the serial mode register (SMR). ■ Serial Mode Register (SMR) The bit configuration of the serial mode register (SMR) is illustrated below. Figure 20.3-2 Bit Configuration of Serial Mode Register (SMR) Serial mode register (SMR) Address: bit7 bit6 bit5 bit4 bit3 000020H MD1 MD0 CS2 CS1 CS0 R/W R/W R/W R/W R/W R/W: bit2 bit1 bit0 Reserved SCKE SOE R/W R/W R/W Initial value 00000X00B Readable/writable The functions of the bits for the serial mode register (SMR) are as follows. [bit7, bit6] MD1, MD0: Mode Select These bits are used to select the UART operation mode. Mode MD1 MD0 Operation mode 0 0 0 Asynchronous (start-stop synchronization) normal mode 1 0 1 Asynchronous (start-stop synchronization) multiprocessor mode 2 1 0 CLK synchronous mode - 1 1 Setting prohibited In mode 1, the asynchronous (start-stop synchronization) multiprocessor mode is used when several slave CPUs are connected to one host CPU. UART cannot distinguish the data format of reception data; therefore, it only supports the master in multiprocessor mode. The parity check function cannot be used. Set the PEN bit of the SCR register to "0". 402 [bit5, bit4, bit3] CS2, CS1, CS0: Clock Select These bits select the baud rate clock sources. When a dedicated baud rate generator is selected, the baud rate will be determined at the same time. CS2 to CS0 000B to 101B Clock input Dedicated baud rate generator 110B Internal clock 111B External clock • PPG1 will be selected in the MB90980 series if an internal clock is selected. • Please do not use the following setting when dedicated baud rate generator is used at synchronous transfer. 1) CS2 to CS0 = 000B 2) CS2 to CS0 = 001B, DIV3 to DIV0 = 0000B [bit2] not used This bit is not used. [bit1] SCKE: SCLK Enable This bit specifies whether to use SCK0 as a clock input pin or as a clock output pin during communication in CLK synchronous mode (mode 2). Set this bit to "0" in CLK asynchronous mode or external clock mode. • 0: The pin functions as clock input pin. • 1: The pin functions as clock output pin. Note: An external clock source must be selected in advance when specifying use as a clock input pin via this bit. [bit0] SOE: Serial Output Enable This bit specifies whether to use the external pin (SOT0), which is used also as a general-purpose I/O port pin, as a serial output pin or as an I/O port pin. • 0: The pin functions as a general-purpose I/O port pin. • 1: The pin functions as the serial data output pin (SOT0). 403 CHAPTER 20 UART 20.3.2 Serial Control Register (SCR) This section describes the configuration and functions of the serial control register (SCR). ■ Serial Control Register (SCR) The bit configuration of the serial control register (SCR) is illustrated below. Figure 20.3-3 Bit Configuration of Serial Control Register (SCR) Serial control register (SCR) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 000021H PEN P SBL CL A/D REC RXE TXE R/W R/W R/W R/W R/W W R/W R/W R/W: R: Initial value 00000100B Readable/writable Read only The functions of the bits for the serial control register (SCR) are as follows: [bit15] PEN: Parity ENable This bit specifies whether to add a parity bit during transmission and to detect it during receiving when processing serial data. PEN Operation 0 No parity 1 Parity provided Note: Parity can be added only in normal mode (mode 0) in asynchronous (start-stop synchronization) communication mode. Parity cannot be added in multiprocessor mode (mode 1) or in CLK synchronous communication (mode 2). [bit14] P: Parity This bit specifies whether to use even or odd parity in data communications with parity. P 404 Operation 0 Even parity 1 Odd parity [bit13] SBL: Stop Bit Length This bit specifies the bit length of the stop bit, which is a frame end mark in asynchronous (start-stop synchronization) communication. SBL Operation 0 1 stop bit 1 2 stop bits [bit12] CL: Character Length This bit specifies the data length of one frame to be sent or received. CL Operation 0 7-bit data 1 8-bit data Note: Only the normal mode (mode 0) in asynchronous (start-stop synchronization) communications can handle 7-bit data. Specify 8-bit data only in multiprocessor mode (mode 1) or CLK synchronous mode (mode 2). [bit11] A/D: Address/Data This bit specifies the data format for frames to be sent and received in multiprocessor mode (mode 1) during asynchronous (start-stop synchronization) communication. A/D Operation 0 Data frame 1 Address frame [bit10] REC: Receiver Error Clear Writing "0" to this bit clears the error flags (PE, ORE, FRE) of the SSR register. Writing "1" has no effect. Read operations always read "1". 405 CHAPTER 20 UART [bit9] RXE: Receiver Enable This bit controls the reception state of the UART. RXE Operation 0 Disables reception operation 1 Enables reception operation If reception operation becomes disabled while reception is in progress (while data is input to the reception shift register), reception operation will only be disabled after reception of the frame completes and the reception data is stored in the SIDR register from the reception data buffer. [bit8] TXE: Transmitter Enable This bit controls the UART transmission states. TXE Operation 0 Disables transmission operation 1 Enables transmission operation If transmission operation becomes disabled while transmission is in progress (while data is output from the transmission register), transmission operation will only be disabled after the serial output register (SODR) no longer contains transmission data. Transmission is resumed by synchronization with an internal serial clock after writing a value to the serial output register (SODR). Disabling of transmission (TXE = 0) is invalid when the TDRE flag is "0". 406 20.3.3 Serial Input/Output Register (SIDR/SODR) This section describes the configuration and functions of the serial input/output register (SIDR/SODR). ■ Serial Input/Output Register (SIDR/SODR) The bit configuration of the serial input/output register (SIDR/SODR) is illustrated below. Figure 20.3-4 Bit Configuration of Serial Input/Output Register (SIDR/SODR) Serial input register (SIDR)/serial output register (SODR) Address: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 D6 D5 D4 D3 D2 D1 D0 000022H D7 R/W R/W R/W R/W R/W R/W R/W R/W R/W: Initial value XXXXXXXXB Readable/writable The upper bit (D7) of the serial input/output register (SIDR/SODR) will become invalid when the stored data elements are 7 bits long. Always set the TDRE of the SSR register to "1" when writing data elements to the SODR register. Note: Write data elements at this address by the same method as that in writing data elements in the SODR register. This address is read by the same method as that used in reading the SIDR register. 407 CHAPTER 20 UART 20.3.4 Serial Status Register (SSR) This section describes the configuration and functions of the serial status register (SSR). ■ Serial Status Register (SSR) The bit configuration of the serial status register (SSR) is illustrated below. Figure 20.3-5 Bit Configuration of Serial Status Register (SSR) Serial status register (SSR) Address: bit15 bit14 bit13 bit12 bit11 bit10 000023H PE ORE FRE RDRF TDRE BDS R R R R R R/W R/W: R: bit9 bit8 RIE TIE R/W R/W Initial value 00001000B Readable/writable Read only The SSR provides a flag that represents the UART status. The functions of the bits for the serial status register (SSR) bits are described below. [bit15] PE: Parity Error This bit acts as an interrupt request flag that is set when a parity error occurs during receiving. Set the REC bit (bit10) of the SCR register to "0" to clear a flag that has been set. The data in the SIDR becomes invalid when this bit is set. PE Operation 0 No parity error 1 Parity error detected [bit14] ORE: Over Run Error This bit is an interrupt request flag that is set in case an overrun error occurs during reception. Set the REC bit (bit10) of the SCR register to "0" to clear a flag that has been set. The data in the SIDR becomes invalid when this bit is set. ORE 408 Operation 0 No overrun error 1 Overrun error detected [bit13] FRE: FRaming Error This bit is an interrupt request flag that is set in case a framing error occurs during reception. Set the REC bit (bit10) of the SCR register to "0" to clear a flag that has been set. The data in the SIDR becomes invalid when this bit is set. FRE Operation 0 No framing error 1 Framing error detected [bit12] RDRF: Receiver Data Register Full This bit is an interrupt request flag that indicates that the SIDR register has stored reception data. This flag is set when reception data is loaded into the SIDR register and is cleared automatically when the SIDR register is reads. RDRF Operation 0 No reception data 1 Reception data loaded [bit11] TDRE: Transmitter Data Register Empty This bit acts as an interrupt request flag that indicates that transmission data can be written to the SODR register. This flag is cleared when transmission data is written to the SODR register. The flag will be set again to indicate that the next item of transmission data can be written as soon as written data has been loaded into the transmission shift register unit and data transfer starts. TDRE Operation 0 Prohibit writing of transmission data 1 Allow writing of transmission data [bit10] BDS This bit is used to control the selection of a data transfer direction. BDS Operation 0 Serial data is transferred starting with the LSB side. (LSB first) 1 Serial data is transferred starting with the MSB side. (MSB first) Note: When this bit is rewritten after writing data to the SDR register to switch between the upper side and lower side of data, the data in the serial data register (SDR) becomes invalid in read and write operations. 409 CHAPTER 20 UART [bit9] RIE: Receiver Interrupt Enable This bit controls reception interrupts. RIE Operation 0 Prohibit interrupts. 1 Allow interrupts. In addition to PE, ORE, and FRE errors, normal reception by RDRF also acts as reception interrupt source. [bit8] TIE: Transmitter Interrupt Enable This bit controls transmission interrupts. TIE Operation 0 Prohibit interrupts. 1 Allow interrupts. Note: If transmission operation becomes disabled during transmission, the transmission operation stops after no more data remains in the serial output register (SODR). For writing "0", wait a predefined time after data has been written to SODR register. In clock asynchronous transfer mode, the term "predefined time" means 1/16 the time corresponding to the baud rate. In clock synchronous transfer mode, this term refers to the time corresponding to the baud rate. 410 20.3.5 Communication Prescaler Control Register (CDCR) This section describes the configuration and functions of the communication prescaler control register (CDCR). ■ Communication Prescaler Control Register (CDCR) The bit configuration of the communication prescaler control register (CDCR) is illustrated below. Figure 20.3-6 Bit Configuration of Communication Prescaler Control Register (CDCR) Communication prescaler control register (CDCR) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 DIV3 DIV2 DIV1 DIV0 000025H MD SRST R/W R/W R/W R/W R/W R/W R/W: -: Initial value 00--0000B Readable/writable Undefined The CDCR register controls machine clock division. The UART operation clocks are obtained by dividing the machine clock. This communication prescaler is allowed to obtain the constant baud rates with respect to various machine clocks. [bit15] MD: Machine clock divide moDe select This bit is used to enables operation of the communication prescaler. MD Operation 0 The communication prescaler stops. 1 The communication prescaler operates. [bit14] SRST: Set ReSeT This bit resets all operations of the UART. It initializes all data and register values. SRST Operation 0 Initial value (has no effect) 1 Forced reset Note: Setting this bit will forcibly clear all data and register values of the UART. Set all data and registers again to return to their initial values. Data being transferred as well as saved data will be invalid until the respective settings have been made again. 411 CHAPTER 20 UART [bit11, bit10, bit9, bit8] DIV3, DIV2, DIV1, DIV0 These bits are used to determine the division ratios of the machine clocks. DIV3 to DIV0 Division Ratio 0000B Division by 1 0001B Division by 2 0010B Division by 3 0011B Division by 4 0100B Division by 5 0101B Division by 6 0110B Division by 7 0111B Division by 8 Notes: • When changing the clock division ratio, wait for time of 2 division as a clock stabilization time before the communication is performed. • Please do not use the following setting when the dedicated baud rate generator is used at the synchronous transfer. - CS2 to CS0 = 000B - CS2 to CS0 = 001B, DIV3 to DIV0 = 0000B 412 20.4 Interrupt of UART The UART has the reception and transmission interrupts. The interrupt of the UART can activate the DMA transfer and extended intelligent I/O service (EI2OS). ■ Interrupt of UART The following table shows the interrupt control bit and interrupt source of the UART. Table 20.4-1 Interrupt Control Bit and Interrupt Source of UART UART reception interrupt UART transmission interrupt Interrupt request flag Data reception completion SSR: RDRF (bit12) Framing error SSR:FRE (bit13) Overrun error SSR:ORE (bit14) Parity error SSR:PE (bit15) SSR:TDRE (bit11) Interrupt request output enable bit SSR:RIE (bit9) SSR:TIE (bit8) Interrupt generation source At receiving UART At transmitting UART ■ Interrupt Source Related to UART The interrupts occurs at receiving and transmitting UART. The interrupt request occurs with the sources as shown below. • When the reception data is loaded to the serial input register (SIDR) • When the reception error (parity, overrun, framing error) occurs • When the transmission data is transferred from the serial output register (SODR) to the transmission shift register 413 CHAPTER 20 UART ■ Interrupt of UART, DMA Transfer, and EI2OS Table 20.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register. Table 20.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register Interrupt source UART transmission completion * UART reception completion * EI2OS clear μDMAC channel number ❍ Interrupt vector Interrupt control register Number Address Number Address 11 #34 FFFF74H ICR11 0000BBH 7 #36 FFFF6CH ICR12 0000BCH ❍: Interrupt request flag is cleared. *: : Interrupt request flag is cleared (stop request). This interrupt source shares the interrupt source and interrupt number of other peripheral function. For details, see Table 4.2-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, the other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function The UART corresponds to the DMA transfer function and EI2OS function. When the DMA or EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 414 20.5 UART Operations This section describes the operations of the UART. ■ Operation Modes UART has the operation modes shown below. The modes can be changed by setting values in the SMR and SCR registers. Mode Parity Data length Operation mode Provided/not provided 7 Provided/not provided 8 Asynchronous (start-stop synchronization) normal mode 0 1 None 8 + 1 *1 Asynchronous (start-stop synchronization) multiprocessor mode 2 None 8 CLK synchronous mode Stop bit length 1 bit or 2 bits *2 None *1: The "+1" term represents the address/data selection bit (A/D) used in communication control. *2: Only one bit can be detected as stop bit during reception. The stop bit length in asynchronous (start-stop synchronization) mode can only be specified for send operations. The bit length in reception operations is always one bit. Do not set the stop bit length other than asynchronous (start-stop synchronization) mode. UART operation mode 1 is used only for the master in master/slave connection. ● Connection between CPUs 1:1 connection (normal mode) or master/slave connection (multiprocessor mode) can be selected. The data length, whether or not to add a parity bit, synchronization, and other specifications for these two systems must be the same across all CPUs. The following operation modes can be selected: • In 1:1 connection (normal mode), the same operation mode, either operation mode 0 or operation mode 2, must be selected for both CPUs. Select operation mode 0 for asynchronous operation. Select operation mode 2 for synchronous operation. • In master/slave connection (multiprocessor mode), use operation mode 1. Select operation mode 1 and use this device as the master. For this type of connection, select "no parity". 415 CHAPTER 20 UART ■ UART Clock Selection ● Dedicated Baud Rate Generator - Asynchronous baud rate = φ / (prescaler division ratio) / (asynchronous transfer clock division ratio) - Synchronous baud rate = φ / (prescaler division ratio) / (synchronous transfer clock division ratio) φ: Machine clock • The division ratios provided by the prescaler (common for asynchronous/synchronous operation) are listed in Table 20.5-1. Table 20.5-1 Division Ratios by the Prescaler • MD DIV3 to DIV0 DIV 0 φ Stop 1 0000B 1 1 0001B 2 1 0010B 3 1 0011B 4 1 0100B 5 1 0101B 6 1 0110B 7 1 0111B 8 For the division ratios of the synchronous transfer clock, see Table 20.5-2. Table 20.5-2 Division Ratios of the Synchronous Transfer Clock CS2 CS1 CS0 CLK synchronous Calculation formula SCK0 0 0 1 12.5Mbps (φ / DIV)/2 (φ / DIV)/2 0 1 0 6.25Mbps (φ / DIV)/4 (φ / DIV)/4 0 1 1 3.125Mbps (φ / DIV)/8 (φ / DIV)/8 1 0 0 1.5625Mbps (φ / DIV)/16 (φ / DIV)/16 1 0 1 781.25Kbps (φ / DIV)/32 (φ / DIV)/32 φ: Calculated based on the machine clock (internal frequency f=25 MHz) for DIV=1. 416 Note: Please do not use the following setting when the dedicated baud rate generator is used at the synchronous transfer. • CS2 to CS0 = 000B • CS2 to CS0 = 001B, DIV3 to DIV0 = 0000B • For the division ratios of the asynchronous transfer clock, see Table 20.5-3. Table 20.5-3 Division Ratios of the asynchronous Transfer Clock CS2 CS1 CS0 CLK synchronous Calculation formula SCK0 0 0 0 120192bps (φ / DIV)/(8 × 13 × 2) (φ / DIV)/(13 × 2) 0 0 1 60096bps (φ / DIV)/(8 × 13 × 4) (φ / DIV)/(13 × 4) 0 1 0 30048bps (φ / DIV)/(8 × 13 × 8) (φ / DIV)/(13 × 8) 0 1 1 15024bps (φ / DIV)/(8 × 13 × 16) (φ / DIV)/(13 × 16) 1 0 0 781.25Kbps (φ / DIV)/(8 × 2 × 2) (φ / DIV)/2 1 0 1 390.625Kbps (φ / DIV)/(8 × 2 × 4) (φ / DIV)/4 φ: Calculated based on the machine clock (internal frequency f=25 MHz) for DIV=1. 417 CHAPTER 20 UART ● Internal timer The applicable baud rate when CS2 to CS0 are set to "110B" and the internal timer (PPG1) is selected can be calculated by the following expressions: Asynchronous (start-stop synchronization): (φ / N) /(16 x 2 x (n + 1)) CLK synchronous: (φ / N)/(2 x (n + 1)) N: Count clock source of the timer (PPG1) n: Reload value of the timer (PPG1) Table 20.5-4 shows the relationship between the baud rate and reload value when the machine clock frequency is 7.3728 MHz. Table 20.5-4 Relationship Between Baud Rate and Reload Value (Machine Clock Frequency: 7.3728 MHz) Reload value Baud rate Clock asynchronous (Start-Stop synchronization) Clock synchronous N = 21 (divide-by-2 of machine clock) N = 23 (divide-by-8 of machine clock) N = 21 (divide-by-2 of machine clock) N = 23 (divide-by-8 of machine clock) 38400 2 - 47 11 19200 5 - 95 23 9600 11 2 191 47 4800 23 5 383 95 2400 47 11 767 191 1200 95 23 1535 383 600 191 47 3071 767 300 383 95 6143 1535 - : Indicates that a setting is prohibited Note: Please do not use the following setting at the clock synchronization. N = 1, n = 0 418 ● External Clock The baud rate when CS2 to CS0 are set to "111B" can be calculated by the following expressions: Asynchronous (start-stop synchronization): f / 16 CLK synchronous: f' f can be up to 1/2 of the machine clock. f' can be up to 1/8 of the machine clock. 419 CHAPTER 20 UART 20.5.1 Operation in Asynchronous Mode (Operation Modes 0 and 1) Transfer operation becomes asynchronous when the UART is used in operation mode 0 (normal mode) or in operation mode 1 (multiprocessor mode). ■ Operation in Asynchronous Mode (Operation Modes 0 and 1) ● Transfer data format Transfer data always starts with a start bit ("L"-level), a transfer operation of a specified data bit length is performed LSB first, and transfer ends with a stop bit ("H"-level). • In normal mode of operation mode 0, the data length can be set to 7 bits or 8 bits. • In operation mode 1, the data length is fixed at 8 bits and a parity bit is not added. Instead, an A/D (address/data selection bit) is added. Figure 20.5-1 Transfer Data Format (Asynchronous Mode) Operation mode 0 ST D0 D1 D2 D3 D4 D5 D6 D7*1/P*2 SP Operation mode 1 ST D0 D1 D2 D3 D4 D5 D6 D7 A/D *1 : D7 (Data bit 7) ..... without parity *2 : P (Parity bit) ......... with parity SP ST : Start bit SP : Stop bit A/D : Address/data selection bit in operation mode 1 (multiprocessor mode) ● Transmission Operation When the transmission data empty flag bit (SSR: TDRE) is "1", transmission data is written to the output data register (SODR). The data is sent if send operation is enabled (SCR: TXE = 1) at that time. Transmission data is sent to the send shift register and sending starts. The TDRE flag is then reset to "1" to enable setting of the next item of transmission data. If transmission interrupt requests are enabled (SSR: TIE = 1), a transmission interrupt request is output to request writing of the transmission data to the SODR. The TDRE flag is cleared to "0" when transmission data has been written to the SODR. 420 ● Reception Operation Reception is always performed if reception operation is enabled (SCR: RXE = 1). When the start bit is detected, one frame of data is received in accordance with the data format determined by the serial control register (SCR). When the error flag is set at the time of error after one frame has been received, the reception data full flag bit (SSR: RDRF) is set to "1". If reception interrupt requests are enabled (SSR: RIE = 1), a reception interrupt request is output in this case. Each flag of the serial status register (SSR) is checked. If reception was performed normally, the serial input register (SIDR) is read; if an error is detected, error processing is performed. The RDRF flag is cleared to "0" after reception data is read from the SIDR. ● Detecting the start bit Implement the following settings to detect the start bit: • Set the communication line level to H (attach the mark level) before the communication period. • Specify reception permission (RXE = H) while the communication line level is H (mark level). • Do not specify reception permission (RXE = H) for periods other than the communication period (without mark level). • After the stop bit is detected (the RDRF flag is set to 1), specify reception inhibition (RXE = L) while the communication line level is H (mark level). Figure 20.5-2 Normal Operation Communication period Non-communication period Mark level Start bit SIN ST Non-communication period Stop bit Data D0 D1 D0 D1 D2 D3 D4 D5 D6 D7 SP (Sending 01010101B) RXE Receive clock Sampling clock Receive clock (8 pulse) Recognition by the microcontroller ST Generating sampling clocks by dividing the receive clock by 16 D2 D3 D4 D5 D6 D7 SP (Receiving 01010101B) Note that specifying reception permission at the timing shown below obstructs the correct recognition of the input data (SIN) by the microcontroller. • Example of operation if reception permission (RXE = H) is specified while the communication line level is L. Figure 20.5-3 Error Operation Communication period Non-communication period Mark level Start bit SIN (Sending 01010101B) RXE Non-communication period Stop bit Data ST D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7 SP SP Receive clock Sampling clock Recognition by the microcontroller ST recognition (Receiving 10101010B) PE,ORE,FRE Occurrence of a reception error 421 CHAPTER 20 UART ● Stop bit Use of one or two stop bits can be selected for sending. The receiving unit, however, will only identify the first stop bit. ● Error detection • Mode 0: Parity errors, overrun errors, and frame errors can be detected. • Mode 1: Overrun and frame errors can be detected. Parity errors cannot be detected. ● Parity Parity can be used only in operation mode 0 (asynchronous and normal modes). Whether to use parity can be set with the PEN bit, while use of even or odd parity can be selected with the P bit of the serial control register (SCR). Parity cannot be used in operation mode 1 (asynchronous and multiprocessor modes) and operation mode 2 (CLK synchronous mode). Figure 20.5-4 shows the data format for send and receive data when parity is used. The items "ST" and "SP" in the diagram indicate the "start bit" and "stop bit" respectively. Figure 20.5-4 Transfer Data Format when Using Parity SIN0 ST SP 1 SOT0 0 1 1 0 0 during reception with even parity 0 ST A parity error has occurred (SCR: P = 0) SP Sending of even parity 1 SOT0 0 1 1 0 0 1 ST SP 1 0 1 Data 1 0 0 0 Parity Note: Parity cannot be used in operation modes 1 and 2. 422 (SCR: P = 0) Sending of odd parity (SCR: P = 1) 20.5.2 Operation in Synchronous Mode (Operation Mode 2) The transfer operation becomes clock-synchronous when the UART operates in operation mode 2 (CLK synchronous mode). ■ Operation in CLK Synchronous Mode (Operation Mode 2) ● Transfer Data Format In synchronous mode, 8-bit data is transferred with LSB first, and no start bit or stop bit is added. Figure 20.5-5 shows the transfer data format in CLK synchronous mode: Figure 20.5-5 Transfer Data Format (in CLK Synchronous Mode) Send data write Mark level Transmission/reception clock RXE,TXE Transmission/reception data 1 LSB 0 1 1 0 Data 0 1 0 MSB ● Clock Supply In a clock synchronous (expanded I/O serial) operation, a number of clock equivalent to the number of bits in the transmission/reception data must be supplied. When an internal clock (dedicated baud rate generator or internal timer) is selected, a data reception synchronous clock will be supplied automatically when data is sent. If an external clock is selected, the serial output register (SODR) in the UART of the transmission side system must contain data. After confirmation that TDRE of the SSR is 0, clock for one byte must be supplied correctly from the outside. Always set the mark level "H" before and after sending data. ● Error Detection Only overrun errors can be detected. Parity and framing errors cannot be detected. 423 CHAPTER 20 UART ● Initialization The appropriate setting values for the control registers when using synchronous mode are shown below. [Serial mode register (SMR)] • MD1 and MD0: "10B" • CS2, CS1, CS0: Specify the clock source determined by the clock selector. • SCKE: "1" if the dedicated baud rate generator or internal clock is used, "0" when the external clock is used. • SOE: "1" for sending. "0" for only receiving. [Serial control register (SCR)] • PEN: "0" • P, SBL, A/D: These bits have no effect. • CL: "1" (8-bit data) • REC: "0" (Error flag clear for initialization) • REX,TXE: Ensure that at least one of RXE and TXE is "1". [Serial status Register (SSR)] • RIE: "1" when interrupts are used. "0" if no interrupts are used. • TIE: "0" ● Communication start Start communication by writing to the serial output register (SODR). Note that temporary data must be written to the SODR before starting communication, even when receiving data. ● Communication end After the end of transmission and reception of one data frame, the RDRF flag of the serial status register (SSR) is set to "1". During reception, check the overrun error flag bit (SSR: ORE) and decide whether communication has been performed normally. 424 20.5.3 Two-Way Communication Function (Normal Mode) Normal serial two-way communication in a 1:1 connection can be performed in operation modes 0 and 2. The synchronization type is "asynchronous" for operation mode 0 and "synchronous" for operation mode 2. ■ Register Settings in Two-Way Communication Set the registers as shown in Figure 20.5-6 before starting two-way communication. Figure 20.5-6 Register Settings in Two-Way Communication 15 14 13 12 Bit SCR/SMR PEN P SBL CL Mode 0 1 Mode 2 0 11 10 9 8 7 6 5 4 3 2 1 0 AD REC RXE TXE MD1 MD0 CS2 CS1 CS0 BCH SCKE SOE 0 0 0 0 1 0 SSR, SIDR/SODR PE ORE FRE TDRF Mode 0 Mode 2 DDR7* - RIE TIE Set conversion data (during write)/store reception data (during read) - - - P74 P73 P72 P71 P70 * : When UART0 is used, set the bit0 and bit2 of DDR7. : Bit used : Bit undefined 1 : Set to "1" 0 : Set to "0" : Set "0" when pin input is used ■ Connection Between CPUs in Two-Way Communication Figure 20.5-7 shows the connection between CPUs in two-way communication. Figure 20.5-7 Connection Between CPUs in Two-Way Communication SOT0 SOT0 SIN0 SCK0 SIN0 SCK0 Output CPU1 Input CPU2 425 CHAPTER 20 UART ■ Communication Procedure for Two-Way Communication Function Communication is started by the sending side with an arbitrary timing when data for transmission is ready. The receiving side receives the transmission data and periodically returns ANS (in this example, separately for each byte). Figure 20.5-8 illustrates the procedure for communication with the two-way communication function. Figure 20.5-8 Communication Procedure for Two-Way Communication Function (Transmission side) (Transmission side) Start Start Setting the operation mode (Matching the setting of the transmission side) Setting the operation mode (0 or 2) Sending data Communication after storing 1-byte data in SODR NO Reception data available? YES NO Reception data available? YES Reading and processing reception data Sending data Reading and processing reception data Sending 1-byte data (ANS) 426 20.5.4 Master/Slave Communication Function (Multiprocessor Mode) The UART enables communication in a master/slave connection in which more than one CPU is connected. Operation mode 1 is used in this case. The UART itself can be used only as the master system. ■ Register Settings in Master/Slave Communication Set the registers as shown in Figure 20.5-9 before starting master-slave communication. Figure 20.5-9 Register Settings in Master/Slave Communication 15 14 13 12 Bit SCR/SMR PEN P SBL CL 1 Mode 1 0 SSR, SIDR/SODR PE ORE FRE TDRF Mode 1 DDR7* 11 10 9 8 7 6 5 4 3 2 1 0 AD REC RXE TXE MD1 MD0 CS2 CS1 CS0 BCH SCKE SOE 0 0 1 0 - RIE TIE Set conversion data (during write)/store reception data (during read) - * 1 0 - - P74 P73 P72 P71 P70 : When UART0 is used, set the bit0 and bit2 of DDR7. : Bit used : Bit undefined : Set to "1" : Set to "0" : Set "0" when pin input is used 427 CHAPTER 20 UART ■ Connection Between CPUs in Master/Slave Communication Figure 20.5-10 shows the connection between CPUs in master/slave communication. Figure 20.5-10 Connection Between CPUs in Master/Slave Communication SOT0 SIN0 SOT SIN SOT SIN Master CPU Slave CPU #0 428 Slave CPU #0 ■ Function Selection Table 20.5-5 lists settings for selecting the communication method in master/slave communication. Table 20.5-5 Function Selection in Master/Slave Communication Operation mode Master CPU Slave CPU Mode 1 - Sending and reception of addresses Sending and reception of data Data Parity Synchronous operation Stop bit AD = 1 + 8-bit address None Asynchronous 1 or 2 bits AD = 0 + 8-bit address ■ Communication Procedure of Master/Slave Communication Function Communication is started by the master CPU sending address data. Address data is data for which the AD bit is "1"; the address is used to select the slave CPU that becomes the communication destination. Each slave CPU interprets the address data by a program. If the address data matches the address assigned to the system, communication (transfer of ordinary data) with the master CPU is established. Figure 20.5-11 shows the procedure for communication using the master/slave communication function. 429 CHAPTER 20 UART Figure 20.5-11 Procedure for Communication Using the Master/Slave Communication Function (Master CPU) Start Set operation mode 1 The SIN pin is specified as serial data input Specify one-byte data (address data) for selecting the slave CPUs in D0 to D7, and send data (AD = 1) Set AD to "0" Enable reception operation Communication with slave CPUs Communication end? NO YES Communications with other slave CPUs? YES Prohibit reception operation 430 END NO 20.6 Precautions on Using the UART Notes the following points when using the UART. ■ Precautions on Using the UART ● Enabling operation The serial control register (SCR) of the UART contains operation enable bits for enabling sending and receiving, namely, TXE (sending) and RXE (reception). By default (as initial value), both sending and receiving must be disabled. If required, the operation of sending and reception is enabled. ● Communication mode setting Set the communication mode while the UART is not in operation. Transmission and reception data cannot be assured if the mode is changed during data transmission or reception. ● Synchronous mode The clock synchronous mode (operation mode 2) of the UART uses a clock control (expanded I/O serial) operation, and a start bit or stop bit is not added to data. ● Transmission data empty flag bit By default (as initial value), the transmission data empty flag bit (TDRE of SSR) is set to "1" (no transmission data, transmission data can be written). Therefore, when transmission interrupt requests are enabled (TIE of SSR = 1), a transmission interrupt request will be triggered immediately. Be sure that the sending data is available before setting the TIE flag to "1". ● Clock setting in synchronous transfer • Please do not use the following setting when the dedicated baud rate generator is used at the synchronous transfer. 1) CS2 to CS0 = 000B 2) CS2 to CS0 = 001B, DIV3 to DIV0 = 0000B • Please do not use the following setting when the internal timer (PPG1) is used at the synchronous transfer. N = 1, n = 0 431 CHAPTER 20 UART 20.7 Program Example of UART This section describes the program example of the UART. ■ Program Example of UART Table 20.7-1 Program Example of UART Example of setting procedure Program example Send data of 1 byte by UART. Asynchronous normal mode void Asynch_uart_sample(void) { INT_initial(); Asynch_uart_initial(); Uart_start(); } <Initial setting> void INT_initial(void) { IO_ICR11.byte = 0x10; •Interrupt related Set interrupt level Set I flag ICR11 (CCR) __EI(); /* Set UART transmission completion interrupt level (arbitrary value) */ /* Enable interrupt */ } •Control UART Set mode register Register name. bit name SMR Set operation mode >> .MD1,MD0 Set operation clock >> .CS2 to CS0 Set SCK0 pin >> Set SOT0 pin >> void Asynch_uart_initial(void) { IO_SMR.byte = 0x19; ; .SCKE .SOE SCR Set control register Set parity or no parity >> Set even/odd parity >> Set stop bit length Set data length of one frame >> Set data format of frame >> Error flag >> Set reception operation enable >> Set transmission operation enable >> Control interrupt Set transmission data MD1,MD0 asynchronous normal mode */ /* bit5 to bit3 = 011B CS2 to CS0 dedicated baud rate generator */ IO_SSR.bit.TIE = 1; IO_SIDR = 0x0aa; /* Send any value of data */ IO_SCR.byte = 0x10; .TIE /* bit7, bit6 = 00B /* bit2 = 0 Undefined bit */ /* bit1 = 0 SCKE clock input pin */ /* bit0 = 1 SOE external pin */ /* Setting value =0001_0000 */ /* bit15 = 0 PEN no parity */ /* bit14 = 0 P even parity */ /* bit13 = 0 SBL 1 stop bit */ /* bit12 = 1 CL 8-bit data */ /* bit11 = 0 A/D data frame */ /* bit10 = 0 REC error flag clear */ /* bit9 = 0 RXE reception operation disable */ /* bit8 = 0 TXE transmission operation disable */ /* bit8 = 1 TIE transmission interrupt enable */ .PEN .P .SBL .CL .A/D .REC .RXE .TXE SSR SIDR /* Setting value =0001_1001 */ } <Start> void Uart_start(void) •Start UART Start UART0 transmission operation Register name. bit name SCR0 .TXE <Interrupt> •Transmission interrupt processing Send any data Register name. bit name SIDR { IO_SCR.bit.TXE = 1; Enable TXE transmission operation */ __interrupt void uart_tx_int(void) { IO_SIDR = 0x0aa; /* Send any value of data */ } <Interrupt vector> •Set vector table #pragma intvect uart_tx_int 34 Note: Setting related to clock and setting of __set_il (numeric value) are required in advance. See "CHAPTER 4 INTERRUPT" and "CHAPTER 6 CLOCKS". Note: 432 /* bit8 = 1 } For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR F2MC-16LX FAMILY MB90980 SERIES". ■ Setting Method Other than Program Example ● Combination that can be set The combination is shown below. Table 20.7-2 Combination that can be Set Operation mode (MD[1:0]) Data length (CL) 7bits (0) 0 Asynchronousnormal mode (00B) 2 Not provided (0) -- 1bit (0) 2bits (1) Even (0) 1bit (0) 2bits (1) Odd (1) 1bit (0) 2bits (1) -- 1bit (0) 2bits (1) Even (0) 1bit (0) 2bits (1) Odd (1) 1bit (0) 2bits (1) Address (1) 1bit (0) 2bits (1) Address (0) 1bit (0) 2bits (1) Data format (A/D) Provided (1) Selection of STOP bit length (SBL) * -Not provided (0) 8bits (1) 1 Parity (PEN) Parity selection (P) Provided (1) -- Asynchronousmultiprocessor mode (01B) 8bits (1) CLK synchronous mode (10B) 8bits (1) Not provided (0) Not provided (0) -- -- -- Presence or absence of error flags Overrun (ORE) Framing (FRE) Parity (PE) ❍ ❍ ❍ ❍ ❍ -- ❍ -- -- *: STOP bit can be selected only at transmission. First bit is detected only at reception (second bit is ignored). ● Method to select operation modes Set by the operation mode bits (SMR.MOD[1:0]) Table 20.7-3 Method to Select Operation Mode Operation mode Operation mode bit (MOD[1:0]) Mode 0 Asynchronous-normal mode Set to "00B" Mode 1 Asynchronous-multiprocessor mode Set to "01B" Mode 2 CLK synchronous mode Set to "10B" ----- Setting "11B" is disabled. 433 CHAPTER 20 UART ● Type of operation clock and selection method Set by the operation clock select bit (SMR.CS[2:0]). Table 20.7-4 Type of Operation Clock and Selection Method Clock input Operation clock select bits (CS[2:0]) Dedicated baud rate generator Set to "000B" to "101B" To select internal clock Set to "110B" To select external clock Set to "111B" ● Method to control SCK, SIN and SOT pins Set as follows. Table 20.7-5 Method to Control SCK, SIN and SOT Pins UART register To input SCK pin DDR7.P72 = 0 SMR.SCKE = 0 To output SCK pin SMR.SCKE = 1 To input SIN pin DDR7.P70 = 0 To output SOT pin SMR.SOE = 1 ● Method to enable/stop UART operation Set by the reception control bit (SCR.RXE). Table 20.7-6 Method to Enable/Stop UART Reception Operation Content of control Reception control bit (RXE) To disable reception operation (stop) Set to "0" To enable reception operation Set to "1" Set by the transmission control bit (SCR.TXE). Table 20.7-7 Method to Enable/Stop UART Transmission Operation 434 Content of control Transmission control bit (TXE) To disable transmission operation (stop) Set to "0" To enable transmission operation Set to "1" ● Method to set parity Set by the parity setting bit (SCR.PEN) and parity select bit (SCR.P). Table 20.7-8 Method to Set Parity Operation Parity setting bit, parity select bit (PEN, P) Set to "00B" or "01B" To set no parity To set to even parity Set to "10B" To set to odd parity Set to "11B" ● Method to set data length Set by the data length select bit (SCR.CL). Table 20.7-9 Method to Set Data Length Operation Data length select bit (CL) To set to 7-bit length Set to "0" To set to 8-bit length Set to "1" ● Method to select STOP bit length Set by the STOP bit length select bit (SCR, SBL). Table 20.7-10 Method to Select STOP Bit Length Operation Stop bit length select bit (SBL) To set STOP bit to 1 bit Set to "0" To set STOP bit to 2 bits Set to "1" ● Method to clear error flag Set by the error flag clear bit (SCR.REC). Table 20.7-11 Method to Clear Error Flag Content of control To clear error flag (PE, OFE, PRE) Error flag clear bit (REC) Write "0" 435 CHAPTER 20 UART ● Method to set transfer direction Set by the setting direction selection bit (SSR.BDS). The transfer direction of LSB/MSB can be selected from any operation mode. Table 20.7-12 Method to Set Transfer Direction Content of control Setting direction selection bit (BDS) To set LSB transfer (from least significant bit) Set to "0" To set MSB transfer (from most significant bit) Set to "1" ● Method to clear reception completion flag Perform in the following method. Table 20.7-13 Method to Clear Reception Completion Flag Content of control Serial input register (SIDR) To clear reception completion flag Read SIDR register Reading the SIDR register for the first time starts the reception. ● Type of error flag and meaning There are three error flags, and they have meaning as follows. Table 20.7-14 Type of Error Flag and Meaning Error flag Parity error (PE) Meaning Error is found in the received value (numeric value). Overrun error (ORE) Next data is received before the reception data is read. Framing error (FRE) Error is found in format of the received data. ● Storage register of reception data The reception data is stored in the serial input register (SIDR). ● Status confirm method of write timing of transmission data The transmission data can be checked by the transmission buffer empty flag (SSR.TDRE). ● Write register of transmission data The transmission data is written to the serial output register (SODR). 436 ● Method to clear the transmission buffer empty flag Perform in the following method. Table 20.7-15 Method to Clear Transmission Buffer Empty Flag Content of control Serial output register (SODR) To clear transmission buffer empty flag Write to SODR register Writing to the SODR register for the first time starts the transmission. ● Method to select data format (address/data) Set by the data length select bit (SCR.AD) . Table 20.7-16 Method to Select Data Format (Address/Data) Operation Data length select bit (AD) To set 8-bit to data ("L" level) Set to "0" To set 8-bit to address ("H" level) Set to "1" It is valid only at the transmission. AD bit is ignored at the reception. ● Method to start reception/transmission Perform in the following method. • Mode 0/1, transmission: 1. Enable the transmission operation. 2.Write data to the serial output register (SODR). ( = start transmission) • Mode 0/1, reception: 1. Enable reception. 2. Read the serial input register (SIDR). (Dummy read = start reception) • Mode 2, transmission/ 1. Enable transmission. (Enabling reception can be omitted.) reception: 2. Write data to the serial output register (SODR). ( = start transmission/reception) (It is necessary to write to the serial output register (SODR) only in the reception operation.) ● Operation stop and state • Mode 0/1, transmission: When the transmission operation is disabled, last transmission data is transmitted after the transmission buffer is empty. Thus, the operation is stopped after the STOP bit is transmitted. • Mode 0/1, reception: After the currently received data is completed (after reception of STOP bit) when the reception operation is disabled, the reception data is transferred from shifter to register and then the operation is stopped. • Mode 2, transmission/reception: When both reception and transmission operations are disabled, the operation is stopped after data to be transmitted/received is completed and then the reception data is transferred from shifter to register. 437 CHAPTER 20 UART ● Method to check completion of operation Perform in the following method. • Mode 0/1, transmission: Check the SSR register empty flag after next transmission data is written. (completion can be checked when next transmission data is transferred from register to shifter and the empty flag in the serial output register is set to "1".) • Mode 0/1, reception: Check register full flag. (Completion can be checked when the full flag in the serial input register is set to "1".) • Mode 2, transmission/reception: Check register full flag. (Completion can be checked when the full flag in the serial input register is set to "1".) ● Method to set baud rate See Section "20.5 UART Operations". ● Interrupt related register The relationship between the UART interrupt vector and UART interrupt level setting register is shown in the following table. For details of the interrupt level and interrupt vector, see "CHAPTER 4 INTERRUPT". Table 20.7-17 Relationship Between UART Interrupt Vector and UART Interrupt Level Setting Register UART reception UART transmission Interrupt vector Interrupt level setting bit #36 Address: 0FFFF6CH Interrupt control register 12 (ICR12) Address: 000BCH #34 Address: 0FFFF74H Interrupt control register 11 (ICR11) Address: 000BBH ● Type of interrupt 4 interrupt sources are provided at reception side and one at transmission side. Table 20.7-18 Type of Interrupt Type of Interrupt UART reception UART transmission 438 The interrupt request occurs due to the sources that occurred first among reception completion (serial input register full), parity error, overrun error, and framing error. The interrupt request occurs at the transmission buffer empty. ● Method to enable/disable/clear interrupt Enabling/disabling interrupt is set by the interrupt request enable bit (SSR.RIE, SSR.TIE). Table 20.7-19 Method to Enable/Disable Interrupt UART reception UART transmission Interrupt request enable bit (RIE) Interrupt request enable bit (TIE) To disable interrupt request Set to "0" To enable interrupt request Set to "1" The interrupt request is cleared in the following method. Table 20.7-20 Method to Clear Interrupt Request UART reception To clear interrupt request UART transmission The reception completion flag (RDRF) is set to "0" by reading the serial input register (SIDR). The transmission buffer empty flag (TDRE) is set to "0" when data is written to the serial output register (SODR). The error flag (PE, ORE, FRE) is set to "0" when "0" is written to the error flag clear bit (REC). - 439 CHAPTER 20 UART 440 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION This chapter explains the overview of the address match detection function, its block diagram, configuration of its register, its operation, and its sample program. 21.1 Overview of Address Match Detection Function 21.2 Block Diagram of Address Match Detection Function 21.3 Configuration of Registers for Address Match Detection Function 21.4 Explanation of Operation of Address Match Detection Function 21.5 Program Example of Address Match Detection Function 441 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION 21.1 Overview of Address Match Detection Function If the address of the instruction to be processed next to the instruction currently processed by the program matches the address set in the program address detection registers, the address match detection function forcibly replaces the next instruction to be processed by the program with the INT9 instruction to branch to the interrupt processing program. Since the address match detection function can use the INT9 interrupt, the program can be corrected by patch processing. ■ Overview of Address Match Detection Function There are two program address detection registers (PADR0 and PADR1), each of which has an interrupt enable bit. The generation of an interrupt due to a match between the address held in the address latch and the address set in the detection address setting registers can be enabled and disabled for each register. 442 21.2 Block Diagram of Address Match Detection Function The address match detection module consists of the following blocks: • Address latch • Program address detection control status register (PACSR) • Program address detection registers (RADR) ■ Block Diagram of Address Match Detection Function Figure 21.2-1 shows the block diagram of the address match detection function. Figure 21.2-1 Block Diagram of the Address Match Detection Function PADR0 (24 bits) Program address detection register 0 PADR1 (24 bits) Comparator Internal data bus Address latch INT9 instruction (INT9 interrupt generation) Program address detection register 1 PACSR Reserved Reserved Reserved Reserved ADE1 Reserved ADE0 Reserved Program address detection control status register (PACSR) Reserved: Always set to "0" ● Address latch The address latch stores the value of the address output to the internal data bus. ● Program address detection control status register (PACSR) The program address detection control status register enables or disables output of an interrupt at an address match. ● Program address detection registers (PADR0, PADR1) The program address detection registers set the address that is compared with the value of the address latch. Note: The addresses of the program address detection register are 1FF0H to 1FF5H and are overlapped with the RAM area. Therefore, the access to the RAM area should not be performed during the use of this function. 443 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION 21.3 Configuration of Registers for Address Match Detection Function This section details the registers used by the address match detection function. ■ List of Registers and Initial Values of Address Match Detection Function Figure 21.3-1 List of Registers and Initial Values of Address Match Detection Function Program address detection control status register (PACSR) Address: 00009EH bit7 bit6 bit5 Reserved Reserved Reserved bit4 Reserved bit3 bit2 bit1 bit0 ADE1 Reserved ADE0 Reserved Initial value 0 0 0 0 0 0 00B R/W R/W R/W R/W R/W R/W R/W R/W Program address detection register 0 (PADR0):Upper Address: 001FF2H bit7 bit6 D23 D22 bit5 bit4 bit3 bit2 bit1 bit0 D21 D20 D19 D18 D17 D16 X X X X X X XXB R/W R/W R/W R/W R/W R/W R/W R/W Program address detection register 0 (PADR0):Middle Address: 001FF1H bit15 bit14 D15 D14 bit13 bit12 bit11 D13 D11 D10 D12 bit10 bit9 D9 bit8 D8 X X X X X X XXB R/W R/W R/W R/W R/W R/W R/W R/W Program address detection register 0 (PADR0):Lower Address: 001FF0H bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 D7 D6 D5 D4 D3 D2 D1 D0 X X X X X X XXB R/W R/W R/W R/W R/W R/W R/W R/W Program address detection register 1 (PADR1):Upper Address: 001FF5H bit7 bit6 D23 D22 bit5 bit4 bit3 bit2 bit1 bit0 D21 D20 D19 D18 D17 D16 X X X X X X XXB R/W R/W R/W R/W R/W R/W R/W R/W Program address detection register 1 (PADR1):Middle Address: 001FF4H bit15 bit14 D15 D14 bit13 bit12 bit11 bit10 bit9 bit8 D13 D11 D10 D9 D8 D12 X X X X X X XXB R/W R/W R/W R/W R/W R/W R/W R/W Program address detection register 1 (PADR1):Lower Address: 001FF3H bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 D7 D6 D5 D4 D3 D2 D1 D0 R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/writable X: Undefined 444 X X X X X X XXB 21.3.1 Program Address Detection Control Status Register (PACSR) The program address detection control status register (PACSR) enables or disables output of an interrupt at an address match. If an address match is detected when output of an interrupt at an address match is enabled, the INT9 interrupt is generated. ■ Program Address Detection Control Status Register (PACSR) Figure 21.3-2 Program Address Detection Control Status Register (PACSR) bit 7 6 5 4 3 2 1 0 Initial value 00000000B Address 009EH R/W R/W R/W R/W R/W R/W R/W R/W bit 0 Reserved bit Reserved 0 Always set to "0" bit 1 Address match detection enable bit 0 ADE0 0 Disables address match detection in PADR0 1 Enables address match detection in PADR0 bit 2 Reserved bit Reserved 0 Always set to "0" bit 3 Address match detection enable bit 1 ADE1 0 Disables address match detection in PADR1 1 Enables address match detection in PADR1 bit 4 Reserved bit Reserved 0 Always set to "0" bit 5 Reserved bit Reserved 0 Always set to "0" bit 6 Reserved bit Reserved 0 Always set to "0" bit 7 Reserved bit Reserved R/W : Readable/Writable : Initial value 0 Always set to "0" 445 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION Table 21.3-1 Functions of Program Address Detection Control Status Register (PACSR) Bit Name bit7 to bit4 Function Reserved: reserved bits Always set to "0". bit3 ADE1: Address match detection enable bit 1 The address match detection operation with the program address detection register 1 (PADR1) is enabled or disabled. When set to "0": Disables the address match detection operation. When set to "1": Enables the address match detection operation. • When the value of program address detection registers 1 (PADR1) matches with the value of address latch at enabling the address match detection operation (AD1E = 1), the INT9 instruction is immediately executed. bit2 Reserved: reserved bit Always set to "0". bit1 ADE0: Address match detection enable bit 0 The address match detection operation with the program address detection register 0 (PADR0) is enabled or disabled. When set to "0": Disables the address match detection operation. When set to "1": Enables the address match detection operation. • When the value of program address detection register 0 (PADR0) matches with the value of address latch at enabling the address match detection operation (AD0E = 1), the INT9 instruction is immediately executed. bit0 Reserved: reserved bit Always set to "0". 446 21.3.2 Program Address Detection Registers (PADR0, PADR1) The value of an address to be detected is set in the program address detection registers. When the address of the instruction processed by the program matches the address set in the program address detection registers, the next instruction is forcibly replaced by the INT9 instruction, and the interrupt processing program is executed. ■ Program Address Detection Registers (PADR0, PADR1) Figure 21.3-3 Program Address Detection Registers (PADR0, PADR1) PADR0, PADR1: High Address 001FF2H, 001FF5H bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Initial value D23 D20 D19 XXXXXXXXB D22 D21 D18 D17 D16 R/W R/W R/W R/W R/W R/W R/W R/W bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 PADR0, PADR1: Middle Address 001FF1H, 001FF4H D15 D14 D13 D12 D11 D10 D9 D8 Initial value XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit 7 bit 6 b i t 5 b i t 4 b i t 3 b i t 2 bit 1 bit 0 PADR0, PADR1: Low Address 001FF0H, 001FF3H D7 D6 D5 D4 D3 D2 D1 D0 Initial value XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/Writable X : Undefined 447 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION ■ Functions of Program Address Detection Registers (PADR0 and PADR1) There are two program address detection registers (PADR0 and PADR1) that consist of a high byte, middle byte, and low byte, totaling 24 bits. Table 21.3-2 Address Setting of Program Address Detection Registers Register Name Program address detection register 0 (PADR0) Program address detection register 1 (PADR1) Interrupt Output Enable Address Setting High PACSR: ADE0 PACSR: ADE1 Set the upper 8 bits of program address 0 (bank). Middle Set the middle 8 bits of program address 0. Low Set the lower 8 bits of program address 0. High Set the upper 8 bits of program address 1 (bank). Middle Set the middle 8 bits of program address 1. Low Set the lower 8 bits of program address 1. In the program address detection registers (PADR0 and PADR1), starting address (first byte) of instruction to be replaced by INT9 instruction should be set. Figure 21.3-4 Setting of Starting Address of Instruction Code to be Replaced by INT9 Instruction Set to detection address (High : FFH, Middle : 00H, Low : 1FH) Address Instruction code FF001C : FF001F : FF0022 : A8 00 00 4A 00 00 4A 80 08 Mnemonic MOVW MOVW MOVW RW0, #0000 A, #0000 A,#0880 Notes • :When an address of other than the first byte is set to the program address detection registers (PADR0 and PADR1), the instruction code is not replaced by INT9 instruction and a program of an interrupt processing is not performed. When the address is set to the second byte or subsequent, the address set by the instruction code is replaced by "01H" (INT9 instruction code) and, which may cause malfunction. • The program address detection registers (PADR0 and PADR1) should be set after disabling the address match detection (PACSR: ADE0: bit1 = 0 or ADE1: bit3 = 0) of corresponding program address detection control status registers. If the program address detection registers are changed without disabling the address match detection, the address match detection function will work immediately after an address match occurs during writing address, which may cause malfunction. • The address match detection function can be used only for addresses of the internal ROM area. If addresses of the external memory area are set, the address match detection function will not work and the INT9 instruction will not be executed. 448 21.4 Explanation of Operation of Address Match Detection Function If the addresses of the instructions executed in the program match those set in the program address detection registers (PADR0 and PADR1), the address match detection function will replace the first instruction code executed by CPU with the INT9 instruction (01H) to branch to the interrupt processing program. ■ Operation of Address Match Detection Function Figure 21.4-1 shows the operation of the address match detection function. Figure 21.4-1 Operation of Address Match Detection Function Program execution Address FF001C : The instruction address to be FF001F : executed by program matches program address detection register 0(H, M, L) FF0022 : Instruction code A8 00 00 4A 00 00 4A 80 08 Mnemonic MOVW MOVW MOVW RW0, #0000 A, #0000 A, #0880 Replaced by INT9 instruction (01H) ■ Setting Detection Address Disable the program address detection register 0 (PADR0) where the detect address is set for address match detection (PACSR: ADE0: bit1 = 0). Set the detected address in the program address detection register 0 (PADR0). Set "FFH" at the higher bits of the program address detection register 0 (PADR0), "00H" at the middle bits, and "1FH" at the lower bits. Enable the program address detection register 0 (PADR0) where the detection address is set for address match detection (PACSR: ADE0: bit1 = 1). ■ Program Execution If the address of the instruction to be executed in the program matches the set detect address, the first instruction code at the matched address is replaced by the INT9 instruction code (01H). When the INT9 instruction is executed, INT9 interrupt is generated and then interrupt processing program is executed. 449 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION 21.4.1 Example of using Address Match Detection Function This section gives an example of patch processing for program correction using the address match detection function. ■ System Configuration and E2PROM Memory Map ● System configuration Figure 21.4-2 gives an example of the system configuration using the address match detection function. Figure 21.4-2 Example of System Configuration Using Address Match Detection Function Serial E2PROM interface MCU E2PROM Storing patch program MB90980 series SIN0 450 ■ E2PROM Memory Map Figure 21.4-3 shows the allocation of E2PROM patch program and data. Figure 21.4-3 Allocation of E2PROM Patch Program and Data E2PROM Address PADR0 PADR1 0000H Patch program byte count 0001H Detection address 0 (Low) 0002H Detection address 0 (Middle) 0003H Detection address 0 (High) 0004H Patch program byte count 0005H Detection address 1 (Low) 0006H Detection address 1 (Middle) 0007H Detection address 1 (High) 0010H Patch program 0 (main body) 0020H Patch program 1 (main body) For patch program 0 For patch program 1 ● Patch program byte count The total byte count of the patch program (main body) is stored. If the byte count is "00H", it indicates that no patch program is provided. ● Detection address (24 bits) The address where the instruction code is replaced by the INT9 instruction code due to program error is stored. This address is set in the program address detection registers (PADR0 and PADR1). ● Patch program (main body) The program executed by the INT9 interrupt processing when the program address matches the detect address is stored. Patch program 0 is allocated from any predetermined address. Patch program 1 is allocated from the address indicating <starting address of patch program 0 + total byte count of patch program 0>. 451 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION ■ Setting and Operating State ● Initialization E2PROM data are all cleared to "00H". ● Occurrence of program error By using the connector (UART), information about the patch program is transmitted to the MCU (MB90980) from the outside according to the allocation of the E2PROM patch program and data. The MCU (MB90980) stores the information received from outside in the E2PROM. ● Reset sequence After reset, the MCU (MB90980) reads the byte count of the E2PROM patch program to check the presence or absence of the correction program. If the byte count of the patch program is not "00H", the higher, middle and lower bits at detection addresses 0 and 1 are read and set in the program address detection registers 0 and 1 (PADR0 and PADR1). The patch program (main body) is read according to the byte count of the patch program and written to RAM in the MCU (MB90980). The patch program (main body) is allocated to the address where the patch program is executed in the INT9 interrupt processing by the address match detection function. Address match detection is enabled (PACSR: ADE0: bit1 = 1, ADE1: bit3 = 1). ● INT9 Interrupt processing Interrupt processing is performed by the INT9 instruction. The MB90980 series has no interrupt request flag by address match detection. Therefore, if the stack information in the program counter is discarded, the detect address cannot be checked. When checking the detect address, check the value of program counter stacked in the interrupt processing routine. The patch program is executed, branching to the normal program. 452 ■ Operation of Address Match Detection Function at Storing Patch Program in E2PROM Figure 21.4-4 shows the operation of the address match detection function at storing the patch program in E2PROM. Figure 21.4-4 Operation of Address Match Detection Function at Storing Patch Program in E2PROM 000000H (3) Patch program RAM Program address detection register E2PROM (1) Detection address setting (reset sequence) Serial E2PROM interface . Patch program byte count . Address for address detection . Patch program ROM (2) (4) Program error FFFFFFH (1) Execution for detection address setting of reset sequence and normal program (2) Branch to patch program which expanded in RAM with INT9 interrupt processing by address match detection (3) Patch program execution by branching of INT9 processing (4) Execution of normal program which branches from patch program 453 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION ■ Flow of Program Patch Processing Figure 21.4-5 shows the flow of the program patch processing. Figure 21.4-5 Flow of Program Patch Processing 0000H E2PROM Patch program byte count : 80H 0001H Detect address (Low) : 00H 0002H Detect address (Middle) : 80H 0003H Detect address (High) : FFH MB90980 series 000000H I/O area 000100H Register/RAM area 000400H Patch program 000480H RAM area RAM Stack area 000900H 0010H Patch program Program address detection register 0090H FFFFH FF0000H FF8000H ROM Program error FF8050H FFFFFFH YES Reset INT9 Read 00H of E2PROM Branch to patch program JMP 000400H Execution of patch program 000400H to 000480H E2PROM : 0000H =0 NO End of patch program JMP FF8050H Read detection address E2PROM : 0001H to 0003H ↓ MOV MCU : Set to PADR0 Read patch program E2PROM : 0010H to 008FH ↓ MCU : 000400H to 00047FH Enable address match detection (PACSR : ADE0 = 1) Execution of normal program NO 454 Program address PC = PADR0 YES INT9 21.5 Program Example of Address Match Detection Function This section gives a program example for the address match detection function. ■ Program Example for Address Match Detection Function ● Processing specifications If the address of the instruction to be executed by the program matches the address set in the program address detection register (PADR0), the INT9 instruction is executed. ● Coding example PACSR EQU 00009EH ; Program address detection control status register PADRL EQU 000001H ; Program address detection register 0 (Low) PADRM EQU 000002H ; Program address detection register 0 (Middle) PADRH EQU 000003H ; Program address detection register 0 (High) ; ;-----Main program--------------------------------------------------------------CODE CSEG START: ; Stack pointer (SP), etc., ; already initialized MOV PADRL,#00H ; Set Program address detection register 0 (Low) MOV PADRM,#00H ; Set Program address detection register 0 (Middle) MOV PADRH,#00H ; Set Program address detection register 0 (High) ; MOV I:PACSR,#00000010B ; Enable address match detection : processing by user : LOOP: : processing by user : BAR LOOP ;-----Interrupt program---------------------------------------------------------WARI: : processing by user : RETI ; Return from interrupt processing CODE ENDS ;-----Vector setting------------------------------------------------------------VECT CSEG ABS=0FFH ORG 00FFDCH ; Set reset vector DSL START DB 00H ; Set to single-chip mode VECT ENDS END START 455 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION 456 CHAPTER 22 ROM MIRROR FUNCTION SELECTION MODULE This chapter describes the overview of the ROM mirror function selection module and its register. 22.1 Overview of ROM Mirror Function Selection Module 22.2 ROM Mirror Function Selection Register (ROMM) 457 CHAPTER 22 ROM MIRROR FUNCTION SELECTION MODULE 22.1 Overview of ROM Mirror Function Selection Module The ROM mirror function selection module is set to read the ROM data arranged in FF bank with access to 00 bank. ■ Block Diagram of the ROM Mirror Function Selection Module Figure 22.1-1 shows a block diagram of the ROM mirror function selection module. Figure 22.1-1 Block Diagram of the ROM Mirror Function Selection Module F2MC-16LX bus ROM mirror function selection Address area Address Data FF bank 00 bank ROM ■ Registers of the ROM Mirror Function Selection Module The following diagram shows the ROM mirror function selection register (ROMM). Figure 22.1-2 ROM Mirror Function Selection Register (ROMM) ROMM Address: bit15 bit14 bit13 bit12 bit11 bit10 00006FH R/W: Readable/writable 458 bit9 MS R/W bit8 MI R/W Initial value ------01B 22.2 ROM Mirror Function Selection Register (ROMM) This section describes the configuration and functions of the ROM mirror function selection register (ROMM). ■ ROMM (ROM Mirror Function Selection Register) The diagram below shows the bit configuration of the ROM mirror function selection register (ROMM). Figure 22.2-1 Bit Configuration of ROM Mirror Function Selection Register (ROMM) ROMM Address: bit15 bit14 bit13 bit12 bit11 bit10 00006FH - bit9 MS R/W bit8 MI R/W Initial value ------01B R/W: Readable/writable [bit9] MS This bit selects the ROM mirror area. • 1: The ROM mirror area is 32 K bytes (008000H to 00FFFFH). • 0: The ROM mirror area is 48 K bytes (004000H to 00FFFFH). [bit8] MI This bit sets whether to enable or disable the ROM mirror function. • 1: Enable the mirror function. • 0: Disable the mirror function. Notes: • Do not access this register during accesses to address 004000H to 00FFFFH (008000H to 00FFFFH). • If the ROM mirror function is started, addresses FF4000H to FFFFFFH (FF8000H to FFFFFFH) are mirrored at addresses 004000H to 00FFFFH (008000H to 00FFFFH) in 00 bank. ROM addresses of FF3FFFH (FF7FFFH) or below are not mirrored in Bank 00 even if the ROM mirror function is enabled. 459 CHAPTER 22 ROM MIRROR FUNCTION SELECTION MODULE 460 CHAPTER 23 1.5M BIT FLASH MEMORY This chapter describes the functions and operations of the 1.5M bit flash memory. The following three operations are available for writing data to or erasing data from flash memory. • Writing/erasing via the program • Writing via a serial programmer • Writing a flash memory programmer This chapter will explain the operations for writing/ erasing via the program and writing via a serial programmer. 23.1 Overview of 1.5M Bit Flash Memory 23.2 Sector Configuration of 1.5M Bit Flash Memory 23.3 Flash Memory Control Status Register (FMCS) 23.4 Method for Starting the Flash Memory's Automatic Algorithm 23.5 Verifying the Execution State of the Automatic Algorithm 23.6 Flash Memory Write/Erase Operations 461 CHAPTER 23 1.5M BIT FLASH MEMORY 23.1 Overview of 1.5M Bit Flash Memory The 1.5M bit flash memory is mapped to the FC to FF bank (memory cells from FC0000H to FC7FFFH and FE0000H to FE7FFFH) in the CPU memory map. The functions of the flash memory interface circuit enable read-access and program access from the CPU in the same way as mask ROM. Writing data to flash memory and erasing data from flash memory is enabled with instructions from the CPU via the flash memory interface circuit. Thus, the contents of the flash memory can be rewritten in implementation mode under control from built-in CPU, enabling the efficient tuning of programs and data. Selector operations, such as enable sector protect, are not available. ■ Features of the 1.5M Bit Flash Memory The 1.5M bit flash memory has the following features: • 192K words x 8 bits/96K words x 16 bits (16K + 8K + 8K + 32K + 32K + 64K + 32K) sector configuration • Automatic program algorithm (Embedded Algorithm*, which is the same as that for the MBM29F400TA) • Built-in erasure suspend/erasure resume functions • Detection of completion for write/erase operations using data polling and a toggle bit • Detection of completion for write/erase operations using CPU interrupts • Compatibility with JEDEC-standard commands • Sector-level erasure is available (any combination of sectors is allowed) • Minimum write/erase count: up to 10,000 *: Embedded Algorithm is a trademark of Advanced Micro Devices, Inc. ■ Methods for Writing/Erasing Flash Memory Flash memory cannot be written and read at the same time. Write/erase operations of programs operating on flash memory must therefore be implemented in the following steps: Data must first be copied to RAM, then the program operates on the RAM data, and finally the result is written back to flash memory. In other words, program execution of flash memory must be performed without read accesses. 462 ■ Flash Memory Control Status Register (FMCS) The following diagram shows the bit configuration of the flash memory control status register (FMCS) used by the flash memory. Figure 23.1-1 Bit Configuration of Flash Memory Control Status Register (FMCS) Used by Flash Memory Flash memory control status register (FMCS) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 Address: 0000AEH INTE RDYINT WE RDY Reserved LPM1 Reserved LPM0 R/W R/W R/W W W R/W W Initial value 000X0000B R/W R/W: Readable/writable W: Write only 463 CHAPTER 23 1.5M BIT FLASH MEMORY 23.2 Sector Configuration of 1.5M Bit Flash Memory This section describes the sector configuration of the 1.5M bit flash memory. ■ Sector Configuration Figure 23.2-1 shows the sector configuration of the 1.5M bit flash memory. The addresses in the figure indicate the upper and lower addresses of each sector. In accesses from the CPU, SA0 is allocated in the FC bank register, SA1 is allocated in the FD bank register, SA2 is allocated in the FE bank register, and SA3 to SA6 are allocated in the FF bank register. Figure 23.2-1 Sector Configuration of 1.5M Bit Flash Memory Flash memory CPU address FFFFFFH *Writer address 3FFFFH FFC000H FFBFFFH 3C000H 3BFFFH FFA000H FF9FFFH 3A000H 39FFFH FF8000H FF7FFFH 38000H 37FFFH FF0000H FEFFFFH 30000H 2FFFFH FE8000H FE7FFFH 28000H 27FFFH FE0000H FDFFFFH 20000H 1FFFFH FD0000H FCFFFFH 10000H 0FFFFH FC8000H FC7FFFH 08000H 07FFFH FC0000H 00000H SA6 (16K bytes) SA5 ( 8K bytes) SA4 ( 8K bytes) SA3 (32K bytes) SA2 (32K bytes) unused SA1 (64K bytes) SA0 (32K bytes) unused ● Writer address The writer address shown in Figure 23.2-1 is the address corresponding to the CPU address when data is written to the flash memory with a parallel programmer. When using a general-purpose programmer for write/erase operations, this address is used for write/erase operations. 464 23.3 Flash Memory Control Status Register (FMCS) The flash memory control status register (FMCS) is used for write/erase operations on flash memory via the registers in the flash memory interface circuit. ■ Flash Memory Control Status Register (FMCS) The diagram below shows the bit configuration of the flash memory control status register (FMCS). Figure 23.3-1 Bit Configuration of Flash Memory Control Status Register (FMCS) Flash memory control status register (FMCS) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 Address: 0000AEH INTE RDYINT WE RDY Reserved LPM1 Reserved LPM0 R/W R/W R/W W W R/W W Initial value 000X0000B R/W R/W: Readable/writable W: Write only The bits in the flash memory control status register (FMCS) have the following functions. [bit7] INTE: INTerrupt Enable This bit is used to enable or disable an interrupt request to the CPU due to the end of a flash memory write/erase access. If the INTE bit is set to "1" and the RDYINT bit is set to "1", an interrupt is issued to the CPU. If the INTE bit is set to "0", no interrupt is issued. INTE Operation 0 Interrupt at the end of write/erase operations prohibited 1 Interrupt at the end of write/erase operations allowed [bit6] RDYINT: ReaDY INTerrupt This bit indicates the operation state of the flash memory. At the end of a flash memory write/erase operation, this bit is normally set to "1". When this bit remains "0" after the end of a flash memory write/erase operation, further flash memory write/erase operations are not allowed. Only after this bit has been set to "1" at the end of the write/erase operations, the next write/erase operation for flash memory is allowed. This bit is cleared by writing "0". Writing "1" has no effect. This bit is set to "1" according to the end timing of the flash memory automatic algorithm (Refer to Section "23.4 Method for Starting the Flash Memory's Automatic Algorithm"). Read-modify-write (RMW) instructions always read "1" for this bit. RDYINT Operation 0 Write/erase operation in progress 1 End of write/erase operation (interrupt request generation) 465 CHAPTER 23 1.5M BIT FLASH MEMORY [bit5] WE: Write Enable This bit is a write-enable bit for the flash memory area. If this bit is "1", a command sequence that targets banks FC to FF (refer to Section "23.4 Method for Starting the Flash Memory's Automatic Algorithm") will result in a write operation in the flash memory area. If this bit is "0", no write/erase signals are generated. This bit is used for initiating write/erase commands with respect to the flash memory. In order to prevent accidental writing of any data to the flash memory, Fujitsu recommends always setting this bit to "0" whenever no write/erase operations are to be executed. WE Operation 0 Flash memory write/erase prohibited 1 Flash memory write/erase allowed [bit4] RDY: ReadDY This bit is used to allow flash memory write/erase operations to be performed. If this bit is "0", write/erase operations with respect to the flash memory are not allowed. However, the command of read/reset and sector erase suspend can be accepted in this state. RDY Operation 0 Write/erase operation in progress 1 End of write/erase operation (next data write/erase operation is enabled) [bit3] Reserve bit This bit is reserved. Always set this bit to "0" for ordinary use. [bit1] Unused bit This bit is unused. Always set this bit to "0" for ordinary use. 466 [bit2, bit0] LPM1, LPM0: Low Power Mode These bits are used to control flash memory power consumption. If these bits are set to "00B", flash memory operations are performed normally. If these bits are set to "01B", "10B" or "11B", however, access to flash memory according to the select signal will be performed in low power consumption mode. In this case, access time increases significantly compared to access with LPM = 00B, and memory access will be disabled during high-speed operation of the CPU. To use this mode, use a CPU with a frequency 4 MHz, 8 MHz, or 10 MHz. LPM1 LPM0 Power consumption mode 0 0 Normal power consumption mode 0 1 Power saving mode (operation with an internal operation frequency of 4MHz or less) 1 0 Power saving mode (operation with an internal operation frequency of 8MHz or less) 1 1 Power saving mode (operation with an internal operation frequency of 10MHz or less) Note: For a CPU operation frequency of 10 MHz or higher, always use normal mode. 467 CHAPTER 23 1.5M BIT FLASH MEMORY ■ End Timing of the Automatic Algorithm Figure 23.3-2 shows the relationship among the end timing of the automatic algorithm, the RDYINT bit, and the RDY bit. The RDYINT bit and RDY bit do not change at the same time. Write programs so as to determine the end of automatic algorithm using either of one bit. Figure 23.3-2 Relationship Among Automatic Algorithm End Timing, RDYINT Bit and RDY Bit End timing of the automatic algorithm RDYINT bit RDY bit One machine cycle ■ Precaution on Using Sub Clock Mode When the sub clock mode is used, the low-power consumption mode selection bits (LPM1, LPM0) of the flash memory control status register (address AEH: FMCS register) must be set to select other than the normal power consumption mode (LPM1, LPM0 = 0, 0), as shown in Table 23.3-1. Therefore, when the device is operating at an internal clock frequency above 10 MHz, the mode cannot be changed to sub clock mode. Table 23.3-1 Low-Power Consumption Mode Selection Bits Low-power consumption mode selection bits LPM1 LPM0 Low-power consumption mode 468 Setting in sub clock mode 0 0 Normal power consumption mode 0 1 Low-power consumption mode at internal clock frequency of 4 MHz or less setting allowed 1 0 Low-power consumption mode at internal clock frequency of 8 MHz or less setting allowed 1 1 Low-power consumption mode at internal clock frequency of 10 MHz or less setting allowed setting prohibited ■ Setting Sub Clock Mode If the sub clock mode is used, the following settings are required: ● If sub clock mode is used at an internal clock frequency of 10 MHz or less To use the sub clock mode, change the low-power consumption mode selection bits (LPM1, LPM0) of the flash memory control status register to other than 0, 0 at initialization. Figure 23.3-3 shows a flowchart example in which sub clock mode is used at an internal clock frequency of 10 MHz or less. Figure 23.3-3 Flowchart Example in which Sub Clock Mode is Used at an Internal Clock Frequency of 10 MHz or Less START Set low-power consumption mode Set FMCS register LPM1, LPM0=11B, 10B or 01B Is mode changed to sub clock mode? NO YES Change to sub clock mode Set CKSCR register SCS=0 Enter sub clock mode 469 CHAPTER 23 1.5M BIT FLASH MEMORY ● If sub clock mode is used at an internal clock frequency of more than 10 MHz To use sub clock mode, first set the internal clock frequency to 10 MHz or less and next change the lowpower consumption mode selection bits (LPM1, LPM0) to other than "00B" before changing to sub clock mode. Figure 23.3-4 shows a flowchart example in which sub clock mode is used at an internal clock frequency of more than 10 MHz. Figure 23.3-4 Flowchart Example in which Sub Clock Mode is Used at an Internal Clock Frequency of More than 10 MHz START NO Is mode changed to sub clock mode? YES Set internal clock frequency to 10 MHz or less Set CKSCR register Set low-power consumption mode Set FMCS register LPM1, LPM0=11B, 10B or 01B Change to sub clock mode Set CKSCR register SCS=0 Enter sub clock mode 470 For operation at an internal clock frequency of more than 10 MHz after sub clock mode is canceled, change the mode to main clock mode or PLL clock mode (internal clock frequency becomes 10 MHz or less), change the low-power consumption mode selection bits (LPM1, LPM0) to "00B", and then set the internal clock frequency to more than 10 MHz. Figure 23.3-5 shows a flowchart example in which sub clock mode is used at an internal clock frequency of more than 10 MHz. Figure 23.3-5 Flowchart Example in which Sub Clock Mode is Used at an Internal Clock Frequency of More than 10 MHz Operation in sub clock mode Is mode changed to main/PLL clock mode? NO YES Change to main/PLL clock mode Set CKSCR register Was mode changed to main/PLL clock mode? NO YES Set low-power consumption mode Set FMCS register LPM1, LPM0=00B Set internal clock frequency to more than 10 MHz Set CKSCR register Start operation at internal clock frequency of more than 10 MHz Note: To use the sub clock mode, input a clock signal of 20 MHz or less to the main clock. If a clock signal of more than 20 MHz is input, the internal clock frequency cannot be set to 10 MHz or less and the sub clock mode cannot be used. 471 CHAPTER 23 1.5M BIT FLASH MEMORY 23.4 Method for Starting the Flash Memory's Automatic Algorithm There are four kinds of commands for starting the automatic algorithm for flash memory: read/reset, write, chip erase, and sector erase. For sector erase operations, control of suspension and resuming is provided. ■ Command Sequence Table Table 23.4-1 lists the Command sequence table. Although the data for writing to the command register is indicated in units of bytes, use word access during actual operations. The contents of the upper byte are ignored in this case. Table 23.4-1 Command Sequence Table Command sequence Bus write cycle 1st bus write cycle 2nd bus write cycle 3rd bus write cycle 4th bus write cycle 5th bus write cycle 6th bus write cycle Address Data Address Data Address Data Address Data Address Data Address Data XXF0 - - - - - - - - - - Read/reset * 1 FxXXXX Read/reset * 4 FxAAAA XXAA Fx5554 XX55 FxAAAA XXF0 RA RD - - - - Write program 4 FxAAAA XXAA Fx5554 XX55 FxAAAA XXA0 PA (even) PD (word) - - - - Chip erase 6 FxAAAA XXAA Fx5554 XX55 FxAAAA XX80 FxAAAA XXAA Fx5554 XX55 FxAAAA XX10 Sector erase 6 FxAAAA XXAA Fx5554 XX55 FxAAAA XX80 FxAAAA XXAA Fx5554 XX55 SA (even) XX30 Sector erase suspend Entering data (xxB0H) at address "FxXXXXH" will suspend a erasure in sector erase mode. Sector erase resume Entering data (xx30H) at address "FxXXXXH" will resume erasure in sector erase suspend mode. RA: Read address PA: Write address. Only even addresses can be specified. SA: Sector address (Refer to Section "23.2 Sector Configuration of 1.5M Bit Flash Memory") RD: Read data PD: Write data; only words can be specified * : Both read and reset commands allow the flash memory to be reset to read mode. Note1: The address Fx in the table represents FF, FE, FD or FC. Specify the actual value corresponding to the bank to be accessed in each operation. Note2: The address in the table indicates the value in the CPU memory map. Addresses and data are indicated in hexadecimal representation; "X" indicates an arbitrary value. 472 23.5 Verifying the Execution State of the Automatic Algorithm In the flash memory, writing/erase flow is executed by an automatic algorithm. Therefore, MB90980 Series has the hardware sequence flag to inform that the state of operation and operation in the flash memory were completed. ■ Hardware Sequence Flags The hardware sequence flags consist of the four bits DQ7, DQ6, DQ5, and DQ3. These bits have the following functions: DQ7 is the data polling flag, DQ6 is the toggle bit flag, DQ5 is the timing limit excess flag, and DQ3 is the sector erase timer flag. The hardware sequence flags are therefore used to confirm that writing or chip sector erase has been completed or that erase code write is valid. Table 23.5-1 shows the bit assignments of the hardware sequence flags. Table 23.5-1 Bit Assignments of Hardware Sequence Flags Bit number Hardware sequence flag 7 6 5 4 3 2 1 0 DQ7 DQ6 DQ5 - DQ3 - - - To refer the hardware sequence flag, read the address of the sector for the internal flash memory after the corresponding command sequence has been set (refer to Table 23.4-1). The execution state of automatic algorithm can be checked in the following method. • Check by referring to hardware sequence flag • Check by referring to RDY bit of flash memory control status register (FMCS) When creating actual program, perform the subsequent instruction after completion of executing automatic algorithm is checked using the above verification method. The hardware sequence flags are described below. Table 23.5-2 lists the hardware sequence flag functions. Table 23.5-2 List of Hardware Sequence Flag Functions State DQ7 DQ6 DQ5 DQ3 DQ7 → DATA: 7 Toggle → DATA: 6 0→ DATA: 5 0→ DATA: 3 0→1 Toggle → Stop 0→1 1 0 Toggle 0 0→1 Erase operation --> sector erase suspend (sector being erased) 0→1 Toggle → 1 0 1→0 Sector erase suspend --> erase resume (sector being erased) 1→0 1 → Toggle 0 0→1 DATA: 7 DATA: 6 DATA: 5 DATA: 3 DQ7 Toggle 1 0 0 Toggle 1 1 Write operation --> write completed (specifying the write address) Chip sector erase operation --> erase completed State change in normal operation mode Sector erase wait --> erase start Sector erase suspend mode (sector not being erased) Operational error During write operation During chip sector erase operation 473 CHAPTER 23 1.5M BIT FLASH MEMORY 23.5.1 Data Polling Flag (DQ7) The data polling flag (DQ7) is a flag that is used to indicate via the data polling function whether execution of the automatic algorithm is in progress or has ended. ■ State Transitions of the Data Polling Flag (DQ7) ● State changes during normal operation Operation state Write operation → completed Chip sector erase → completed Sector erase wait → start Sector erase → erase suspend (sector being erased) Sector erase suspend → resume (sector being erased) Sector erased suspend mode sector not being erased DQ7 DQ7 → DATA: 7 0→1 0 0→1 1→0 DATA: 7 ● State changes in operation error mode Operation state Write operation Chip sector erase operation DQ7 DQ7 0 ■ Write Operation During read accesses while the automatic write algorithm is executed, the reverse data for bit7 of the last data item written to flash memory is referred and output, regardless of the specified address. If the read operation is performed at the time when the automatic write algorithm has ended, the read value of bit7 for the specified address in flash memory is output. ■ Chip/Sector Erase Operation When the chip erase/sector erase algorithm is being executed, "0" is output in read operations of the flash memory, either for the sector currently erased in sector erase mode or independently of addressing in chip erase mode. "1" is output when the chip erase/sector erase algorithm has ended. 474 ■ Sector Erase Suspend Read operations of the flash memory while sector erase is suspended will output "1" if an address for the sector being erased has been specified, or will output the read value of bit7 (DATA: 7) for the specified data item will be output in other cases. Which sector is being erased, and whether that sector is in sector suspend state, can be identified by referring to the toggle bit flag (DQ6). Note: If the automatic algorithm starts, read accesses to the specified address are not effective. Data can be read after the end of data polling flag (DQ7). Thus, read data after the end of the automatic algorithm only after the read access that confirms the end of data polling. 475 CHAPTER 23 1.5M BIT FLASH MEMORY 23.5.2 Toggle Bit Flag (DQ6) Like the data polling flag (DQ7), the toggle bit flag (DQ6) is a flag mainly used to indicate whether the automatic algorithm is being executed or has ended. In the case of the toggle bit flag, a toggle bit function is used for that purpose. ■ State Transitions of the Toggle Bit Flag (DQ6) ● State transitions in normal operation Operation state Write operation → completed Chip sector erase → completed Sector erase wait → start Sector erase → erase suspend (sector being erased) Sector erase suspend → resume (sector being erased) Sector erased suspend mode sector not being erased DQ6 Toggle → DATA: 6 Toggle → Stop Toggle Toggle → 1 1 → Toggle DATA: 6 ● State transitions in operation error mode Operation state Write operation Chip sector erase operation DQ6 Toggle Toggle ■ Write/Chip Sector Erase Operations In the case of repeated read accesses when the automatic write algorithm and the chip sector erase algorithm are being executed, the flash memory toggles between output of 1 and 0 in toggle mode for each read operation independent of addressing. When repeated read accesses are performed when the automatic write algorithm and chip/sector erase algorithm have ended, the flash memory stops with the toggle operation of bit6, and instead outputs bit6 (DATA: 6) of the read value for the specified address. ■ Sector Erase Suspend If read access is performed when a sector erase operation is suspended, the flash memory outputs "1" when the specified address belongs to the sector being erased. In other cases, bit6 (DATA: 6) of the read value for the specified address will be output. Reference: If, in write operations, the sector to be written is rewrite-protected, toggle operation is performed for about 2 μs before the operation ends without any data being rewritten. If, in erase operation, all sectors selected are rewrite-protected, toggle operation is performed for about 100 μs before the device returns to the read/reset state without any data being changed. 476 23.5.3 Timing Limit Excess Flag (DQ5) The timing limit excess flag (DQ5) is used to indicate when the execution of the automatic algorithm exceeds the time (internal pulse count) specified in the internal flash memory. ■ State Transitions of the Timing Limit Excess Flag (DQ5) ● State transitions in normal operation Operation state Write operation → completed Chip sector erase → completed DQ5 0 → DATA: 5 0→1 Sector erase wait → start Sector erase → erase suspend (sector being erased) Sector erase suspend → resume (sector being erased) Sector erased suspend mode sector not being erased 0 0 0 DATA: 5 ● State transitions in operation error mode Operation state Write operation Chip sector erase operation DQ5 1 1 ■ Write/Chip Sector Erase Operation When a read access is performed after a writing operation occurs or the chip sector erase automatic algorithm starts, "0" is output if the specified time (for write/erase operations) is not exceeded, while "1" is output if this time is exceeded. This operation is independent of whether the automatic algorithm is being executed or has ended, thus allowing whether a failure has occurred during a write/erase operation to be determined. If this flag indicates "1" while the automatic algorithm is still being executed according to the data polling function or toggle bit function, it can be assumed that a failure during a write operation has occurred. For example, if there is an attempt to write "1" to a flash memory address whose corresponding value has already been set to "0", a failure occurs. In this case, the flash memory will be locked, and the automatic algorithm will not end. Occasionally, it is likely to end normally as be able to be written "1". As a result, the data polling flag (DQ7) will output that there is no valid data. The toggle bit flag (DQ6) will continue with the toggle operation until the time limit is exceeded, and the timing limit excess flag (DQ5) will output "1". This indicates that the flash memory is not defective, but was used incorrectly. If this state occurs, execute the reset command. 477 CHAPTER 23 1.5M BIT FLASH MEMORY 23.5.4 Sector Erase Timer Flag (DQ3) The sector erase timer flag (DQ3) indicates whether the device is waiting for the end of sector erase after starting of the sector erase command. ■ State Transitions of Sector Erase Timer Flag (DQ3) ● State changes during normal operation Operation state Write operation → completed Chip sector erase → completed DQ3 0 → DATA: 3 1 Sector erase wait → start Sector erase → erase suspend (sector being erased) Sector erase suspend → resume (sector being erased) Sector erased suspend mode sector not being erased 0→1 1→0 0→1 DATA: 3 ● State changes in operation error mode Operation state Write operation Chip sector erase operation DQ3 0 1 ■ Sector Erase Operation In read accesses after the sector erase command starts, the flash memory outputs "0" if the sector erase waiting time is in progress, irrespective of the address specified by the address signal for the sector that issued the command, or it outputs "1" if the sector erase waiting time was exceeded. If the data polling function or toggle bit function shows that the erase algorithm is being executed and this flag is set to "1", erasure under internal control will start. Subsequent commands other than writing the sector erase code or erase suspend are ignored until the erasure is completed. If this flag is set to "0", the flash memory will accept writing of the additional sector erase code. Fujitsu recommends checking the state of the flag before subsequent sector erase codes are written to verify the operational state of the device. If a second state check returns the flag to "1", the erase code for an additional sector may not have been accepted. ■ Sector Erase Suspend If read access is performed when a sector erase operation is suspended, the flash memory outputs "1" for an address of a sector being erased. Otherwise, the read value of bit3 (DATA: 3) for the corresponding address will be output. 478 23.6 Flash Memory Write/Erase Operations This section explains the procedure of write/erase of the flash memory by the activating of an automatic algorithm. ■ Flash Memory Write/Erase The automatic algorithm can be started by writing one of read/reset, write, chip erase, sector erase, sector erase suspend, and erase resume in the command sequence (see Table 23.4-1) from CPU to the flash memory. Write cycle from CPU to the flash memory must be executed consecutively. The end of the automatic algorithm can be detected with such functions as the data polling function. After a normal end, the operational state returns to the read/reset state. This section describes the following items related to flash memory write/erase operations. • Setting the flash memory to read/reset state • Writing data • Erasing all data (entire chip erase) • Erasing arbitrary data (sector erase) • Suspending sector erase • Resuming sector erase 479 CHAPTER 23 1.5M BIT FLASH MEMORY 23.6.1 Setting the Flash Memory to Read/Reset State This section describes the procedures for issuing read/reset commands and setting the flash memory to read/reset state. ■ Setting the Flash Memory to the Read/Reset State To set the flash memory to the read/reset state, continuously send the read/reset command in the command sequence table (see Table 23.4-1) to the relevant sector in the flash memory. Read/reset commands use two types of command sequences: execution in one bus operation and execution in three bus operations. There are no basic differences in between command sequences. The read/reset state is the initial state of the flash memory. It occurs at power-on or at normal end of a command. The read/reset state is a state in which the device waits for input of other commands. The read/reset state enables data to be read with normal read accesses. Program access from the CPU is performed in the same way that it is for mask ROM. However, this command does not require that a data read operation ends normally: This command is mainly used to initialize the automatic algorithm if a command does not end for some reason. 480 23.6.2 Writing Data to Flash Memory This section describes the procedures for issuing a write command to write data to the flash memory. ■ Writing Data to Flash Memory To start the automatic data write algorithm for the flash memory, repeatedly send the write command in the command sequence table (see Table 23.4-1) to the relevant sector in the flash memory. When data writing to the target address is completed in the 4th cycle, the automatic algorithm, and therefore automatic writing, will be started. ● Address specification method Only an even write address can be specified in the write data cycle. Specifying an odd address will cause a failure during writing. It is necessary to write to even addresses in word units. Any order of addresses or even addresses exceeding the sector boundary are acceptable in write operations. However, a single write command can only write one word of data. ● Notes on writing data Data polling flag (DQ7) or toggle bit flag (DQ6) doesn't enter the state of the end if data in the flash memory is written from "0" in "1". So, it is judged that the flash memory element is defective, and falls into the following states. Therefore, please do not return data in the flash memory from "0" to "1" by write. • Time limit excess flag (DQ5) becomes the error state by exceeding the write regulation time. • In the appearance, it becomes the state that "1" seems to be written in data on the flash memory. (Data is "0" when read the data at read/reset state. Please erase it when you return data from "0" to "1".) During execution of automatic write, all other commands are ignored. Note that if a hardware reset starts while a write operation is in progress, the data that is written to the address is not assured. 481 CHAPTER 23 1.5M BIT FLASH MEMORY ■ Operation for Writing to Flash Memory Figure 23.6-1 shows an example of the procedure for writing to flash memory. Using the hardware sequence flag (see Section "23.5 Verifying the Execution State of the Automatic Algorithm"), the operational state of the automatic algorithm operating on the flash memory can be determined. In this example, the data polling flag (DQ7) is used to indicate the end of writing. During the flag check, data is read from the last address data was written to. The data polling flag (DQ7) changes at the same time as the timing limit excess flag (DQ5). Even if the timing limit excess flag (DQ5) is "1", the data polling flag bit (DQ7) must be checked again. Since the toggle bit flag (DQ6) also stops the toggle operation when the timing limit excess flag bit (DQ5) is set to "1", the toggle bit flag (DQ6) must be checked again in this case. Figure 23.6-1 Example of the Flash Memory Write Procedure Start of write operation FMCS:WE(bit5) Enable flash memory write Write command sequence (1) FxAAAA XXAA (2) Fx5554 XX55 (3) FxAAAA XXA0 (4) Write address write data Next address Internal address read Data polling(DQ7) Data Data 0 Timing limit(DQ5) 1 Internal address read Data Data polling(DQ7) Data Write error Last address FMCS:WE(bit5) Flash memory write prohibited Write completed 482 Check by hardware sequence flag 23.6.3 Erasing All Data in the Flash Memory (Chip Erase) This section describes the procedure for issuing the chip erase command to erase all data in the flash memory. ■ Erasing All Data in the Flash Memory (Chip Erase) To erase all data in the flash memory, repeatedly send the chip erase command in the command sequence table (see Table 23.4-1) to the relevant sector in the flash memory. The chip erase command is executed in six bus operations. When the write operation is completed in the 6th cycle, the chip erase operation will start. During the chip erase operation, the user does not need to write to the flash memory before erasing; during execution of the automatic erase algorithm, "0" will automatically be written to all cells of the flash memory for verification before erasure. 483 CHAPTER 23 1.5M BIT FLASH MEMORY 23.6.4 Erasing Arbitrary Data in Flash Memory (Sector Erase) This section describes the procedure for issuing a sector erase command to erase an arbitrary sector in flash memory. This procedure allows either erasure of individual sectors or erasure of multiple sectors at the same time to be specified. ■ Erasing Arbitrary Data in the Flash Memory (Sector Erase) To erase an arbitrary sector in flash memory, repeatedly send the sector erase command in the command sequence table (see Table 23.4-1) to the relevant sector in the flash memory. ● Method for specifying a sector The sector erase command is performed in six bus operations. To start a sector erase wait of 50μs, write the sector erase code (30H) in the 6th cycle to an arbitrary even address in the target sector that can be accessed. To erase multiple sectors using the above procedure, write the erase code (30H) sequentially to the addresses of the target sector to be erased. ● Notes on specifying multiple sectors Erase operation starts when the sector erase wait time of 50 μs has elapsed after the last sector erase code has been written. In other words, to erase multiple sectors at the same time, enter the next erase sector address and erase code (which must be entered in the 6th cycle of the command sequence) within 50 μs. Whether the next sector erase code can be written can be checked using the sector erase timer (hardware sequence flag:DQ3). In this case, the address for reading the sector erase timer must also specify the sector to be erased. ■ Procedure for Sector Erasure The hardware sequence flag (see Section "23.5 Verifying the Execution State of the Automatic Algorithm") can be used to identify the operational state of the automatic algorithm operating on the internal flash memory. Figure 23.6-2 shows an example of the procedure for sector erasure of the flash memory. In this example, the toggle bit flag (DQ6) is used to check for the end of erasure. Be sure that the data read in the flag check is read from the sector to be erased. The toggle bit flag (DQ6) stops the toggle operation when the timing limit excess flag (DQ5) changes to "1". Therefore, even if DQ5 is "1", check the toggle bit flag (DQ6) again (processing in the doted line in Figure 23.6-2). The data polling flag (DQ7) also changes when the timing limit excess flag (DQ5) changes. Therefore, check the data polling flag (DQ7) again. 484 Figure 23.6-2 Example of Sector Erase Procedure for Flash Memory Start of deletion FMCS:WE(bit5) Flash memory deletion enabled Delete command sequence (1) FxAAAA XXAA (2) Fx5554 XX55 (3) FxAAAA XX80 (4) FxAAAA XXAA (5) Fx5554 XX55 (6) Enter code to the delete sector (30H) YES Any other delete sector? NO Internal address read 1 Next sector Internal address read 2 NO YES Toggle bit(DQ6) Data 1 (DQ6) = data 2 (DQ6) Sector erase completed ? YES NO 0 Timing limit(DQ5) 1 Internal address read 1 Internal address read 2 NO Toggle bit(DQ6) Data 1 (DQ6) = data 2 (DQ6) YES NO Delete error Last sector YES FMCS:WE(bit5) Flash memory deletion disabled Delete completed Check using hardware sequence flag 485 CHAPTER 23 1.5M BIT FLASH MEMORY 23.6.5 Suspending Sector Erasure for the Flash Memory This section describes the procedure for issuing the sector erase suspend command to suspend a sector erase operation for the flash memory. During erase suspension, data can be read from any sector that is not subject to erasure. ■ Suspending Sector Erasure for the Flash Memory To suspend sector erasure for the flash memory, send the sector erase suspend command in the command sequence table (see Table 23.4-1) from CPU to the internal flash memory. The sector erase suspend command is used to suspend the erasure during a sector erase operation, allowing data from a sector that is not being erased to be read. In this state, only reading is allowed; writing is prohibited. This command is enabled only in sector erase mode, including within the erase wait time, and ignored in chip erase mode or during write operations. This operation is executed by writing the erase suspend code (B0H). To do so, specify an arbitrary address in flash memory. During the erase suspend state, repeatedly issued erase suspend commands are ignored. If a sector erase suspend command is entered during the sector erase wait time, sector erase wait ends immediately, the erase operation is interrupted, and the operational state changes to erase stop. If a erase suspend command is entered during a sector erase operation after the sector erase wait time, the system enters the erase suspend mode after 20 μs have elapsed or earlier. Please execute the sector erase suspend command after issuing the sector erase command or sector erase resume command and 20 μs or more. 486 23.6.6 Resuming the Sector Erasure of Flash Memory This section describes the procedure for issuing the sector erase resume command and resuming a suspended flash memory sector erase operation. ■ Resuming the Sector Erasure of Flash Memory To resume a suspended sector erase operation, send the sector erase resume command in the command sequence table (see Table 23.4-1) to the internal flash memory. The sector erase resume command is used to resume a sector erasure from the sector erase suspend mode caused by a sector erase suspend command. This command is executed by writing the erase restart code (30H) while specifying an arbitrary address in the flash memory area. Issuing the sector erase restart command during a sector erase operation will be ignored. 487 CHAPTER 23 1.5M BIT FLASH MEMORY 488 CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION This chapter shows an example of a serial programming connection using the AF220/AF210/AF120/AF110 flash microcontroller programmer by Yokogawa Digital Computer Corporation. 24.1 Basic Configuration of Serial Programming Connection with MB90F983 24.2 Example of Connection in Single-Chip Mode (When Using the User Power Supply) 24.3 Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) 489 CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION 24.1 Basic Configuration of Serial Programming Connection with MB90F983 The MB90F983 supports serial on-board writing (Fujitsu standard) of the flash ROM. This section provides the related specifications. ■ Basic Configuration of Serial Programming Connection with MB90F983 Fujitsu standard serial on-board writing uses the Yokogawa Digital Computer Corporation flash microcontroller programmer. It is possible to write it by selecting either of the program that operates by the single chip mode or the internal ROM external bus mode. Figure 24.1-1 shows the basic configuration for the example for serial programming connection. Figure 24.1-1 Basic Configuration for the Example for Serial Programming Connection Host interface cable (AZ201) RS232C Flash microcontroller programmer + memory card General-purpose common cable (AZ210) CLK synchronous serial connection MB90F983 User system Operable in stand-alone mode For information on the functions of and operational procedures related to the flash microcontroller programmer (AF220/AF210/AF120/AF110), the general-purpose common cable (AZ210) for connection, and the connector, contact Yokogawa Digital Computer Corporation. 490 ■ Pins Used for Fujitsu Standard Serial On-Board Writing Table 24.1-1 shows the functions of the related pins used for Fujitsu standard serial on-board writing. Table 24.1-1 Function of Pins Pin MD2, MD1, MD0 Function Supplementary Information Mode pins Set MD2=1, MD1=1, and MD0=0 to enter the serial programming mode. X0, X1 Oscillation pins As, in the serial programming mode, CPU internal operation clock is the PLL clock multiplied-by-1, the internal operation clock frequency is equal to the oscillation clock frequency. Consequently, the frequencies that can be input to the high-speed oscillation input pin for serial writing are from 4.5 to 25 MHz. P80, P81 Programming program start pins Input "L" level to P80 and "H" level to P81. RST Reset pin SIN0 Serial data input pin SOT0 Serial data output pin SCK0 Serial clock input pin VCC Power voltage supply pin If the programming voltage (VCC = 3.3 V ± 5%) VSS GND pin Must be shared with GND of the flash microcontroller programmer. - Use UART0 for CLK sync mode. To use the P80, P81, SIN0, SOT0, and SCK0 pins within the user system as well, the control circuit shown in the Figure 24.1-2 is required. Using the flash microcontroller programmer’s /TICS signal for outputting "L", the user circuit can be disconnected in serial programming mode. Figure 24.1-2 Pin Control Circuit AF220/AF210/AF120/AF110 Write control pin 10 kΩ MB90F983 Write control pin AF220/AF210/AF120/AF110 /TICS pin User circuit 491 CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION ■ Oscillation Clock Frequency and Serial Clock Input Frequency The serial clock frequencies that can be used for input to the MB90F983 can be calculated from the following formula. Use the flash microcontroller programmer settings to set the serial clock input frequency for the required oscillation clock frequency. Serial clock frequency to be input = 0.125 × oscillation clock frequency Table 24.1-2 shows a serial clock frequency that can be input. Table 24.1-2 Example of Serial Clock Frequency that can be Input Oscillation clock frequency Maximum serial clock frequency that can be input to microcontroller Maximum serial clock frequency that can be set for AF220/AF210/ AF120/AF110 Maximum serial clock frequency that can be set for AF200 8 MHz 1MHz 850kHz 500kHz 16 MHz 2MHz 1.25MHz 500kHz ■ System Configuration of Flash Microcontroller Programmer (Yokogawa Digital Computer Corporation) Table 24.1-3 shows the system configuration of the flash microcontroller programmer. Table 24.1-3 System Configuration of the Flash Microcontroller Programmer Model Main body Function AF220/AC4P Model with built-in Ethernet interface /100 V to 220 V power adapter AF210/AC4P Standard model /100 V to 220 V power adapter AF120/AC4P Model with built-in single key Ethernet interface /100 V to 220 V power adapter AF110/AC4P Single key model AZ221 Programmer dedicated RS232C cable for PC/AT AZ210 Standard target probe (a) length: 1 m FF201 Fujitsu F2MC-16LX flash microcontroller control module AZ290 Remote controller /P2 2M bytes PC Card (Option) FLASH memory capacity of up to 128 K bytes supported /P4 4M bytes PC Card (Option) FLASH memory capacity of up to 512 K bytes supported Inquiries: Yokogawa Digital Computer Corporation Telephone number: (81)-42-333-6224 492 /100 V to 220 V power adapter 24.2 Example of Connection in Single-Chip Mode (When Using the User Power Supply) In the user system, mode pins MD2 and MD0, which are set to single-chip mode, are supplied with the inputs MD2=1 and MD0=0 by TAUX3 and TMODE of AF220/AF210/ AF120/AF110, and the system is set to serial programming mode (serial programming mode: MD2, MD1, MD0=110B). ■ Example of Connection in Single-Chip Mode (When Using the User Power Supply) Figure 24.2-1 Example of Serial Programming Connection in Single Chip Mode for MB90F983 (when Using the User Power Supply) AF220/AF210/AF120/AF110 Flash microcontroller programmer User system TAUX3 Connector DX10-28S MB90F983 MD2 (19) 10 kΩ 10 kΩ MD1 10 kΩ TMODE (12) 4.5 MHz to 25 MHz TAUX (23) /TICS (10) MD0 X0 X1 P80 10 KΩ User circuit 10 kΩ 10 kΩ /TRES (5) RST 10 kΩ User circuit P81 TTXD (13) SIN0 TRXD (27) (6) SOT0 TCK TVcc (2) GND SCK0 Power supplied from user (7, 8, 14, 15, 21, 22, 1, 28) Pin 14 Pins 3, 4, 9, 11, 16, 17, 18, 20, 24, 25, and 26 are open. Vss Pin 1 DX10-28S Pin 28 DX10-28S: Right angle type Vcc Pin 15 Pin assignments of connector (Hirose Electric) 493 CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION Note: Similarly to P80, using the SIN0, SOT0, and SCK0 pins in the user system requires a control circuit as shown in Figure 24.2-2. The user circuit is disconnected in serial programming mode by the flash microcontroller programmer’s "/TICS" signal for outputting "L". Figure 24.2-2 Pin Control Circuit AF220/AF210/AF120/AF110 Write control pin AF220/AF210/AF120/AF110 10 kΩ /TICS pin MB90F983 Write control pin User circuit Note: Connect to AF220/AF210/AF120/AF110 when the power supply of the user system is turned off. 494 24.3 Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) If, in serial programming mode, pins (MD2, MD0, and P80) are set as shown below, MD2, MD0, and P80 do not need to be connected with the flash microcontroller programmer. ■ Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) Figure 24.3-1 shows an example of minimum connection with the flash microcontroller programmer of MB90F983 (when using the user power supply). Figure 24.3-1 Example of Connection with Flash Microcontroller Programmer of MB90F983 (when Using the User Power Supply) AF220/AF210/AF120/AF110 Flash microcontroller programmer User system 10 kΩ Serial rewrite 1 MB90F983 MD2 Serial rewrite 1 10 kΩ 10 kΩ MD1 10 kΩ 10 kΩ MD0 Serial rewrite 0 10 kΩ 4.5 MHz to 25 MHz X0 X1 P80 Serial rewrite 0 10 kΩ 10 kΩ User circuit P81 Serial rewrite 1 User circuit Connector DX10-28S /TRES TTXD TRXD 10 kΩ (5) RST (13) SIN0 SOT0 (27) (6) TCK TVcc (2) (7, 8, 14, 15, 21, 22, 1, 28) GND SCK0 Power supplied from user Pin 14 Pins 3, 4, 9, 10, 11, 12, 16, 17, 18, 19, 20, 23, 24, 25, and 26 are open. Vss Pin 1 DX10-28S Pin 28 DX10-28S: Right angle type Vcc Pin 15 Pin assignments of connector(Hirose Electric) 495 CHAPTER 24 EXAMPLES OF MB90F983 SERIAL PROGRAMMING CONNECTION Note: Using the pins SIN0, SOT0, and SCK0 in the user system requires a control circuit as shown in Figure 24.3-2. The user circuit is disconnected in serial programming mode by the flash microcontroller programmer’s "/TICS" signal for outputting "L". Figure 24.3-2 Pin Control Circuit MB90F983 Write control pin AF220/AF210/AF120/AF110 Write control pin 10 kΩ AF220/AF210/AF120/AF110 /TICS pin User circuit Note: Connect to AF220/AF210/AF120/AF110 when the power supply of the user system is turned off. 496 CHAPTER 25 PWC TIMER This chapter provides an overview of the PWC timer, provides notes on its use, explains its configuration, explains the configuration and functions of its registers, and explains its interrupt and operation. 25.1 Overview of PWC Timer 25.2 Configuration of PWC Timer 25.3 Configuration and Functions of PWC Timer Registers 25.4 Interrupt of PWC Timer 25.5 Operations of PWC Timer 25.6 Notes on PWC Timer Usage 497 CHAPTER 25 PWC TIMER 25.1 Overview of PWC Timer The PWC timer is a 16-bit multifunctional up-count timer used to measure the pulse width of input signals. PWC: Pulse Width Count (for pulse width measurement) ■ PWC Timer Functions On the hardware level, the PWC timer consists of one 16-bit up-count timer, one input pulse divider and divide ratio control register, one measurement input pin, and one 16-bit control register. When regarding each 16-bit control register as one channel, the PWC timer has a total of two channels. The PWC timer provides the following functions. ● Timer function • Each time the timer function has been set, an interrupt request will be generated • An internal clock used as a reference clock can be selected from three types (Divided-by 4/16/32 of machine clock). ● Pulse width measurement function 498 • Measures the time between any events input from the outside via the pulse input • An internal clock used as a reference clock can be selected from three types (Divided-by 4/16/32 of machine clock) • Various measurement modes • "H" pulse width (rising edge to falling edge)/"L" pulse width (rising edge to falling edge) • Rising interval (rising edge to rising edge)/falling interval (falling edge to falling edge) • Measurement between edges (rising edge or falling edge to falling edge or rising edge) • An 8-bit input divider is used for divide measurement with "divide-by-22 x n" (n = 1,2,3,4) of the input pulse. • At the end of measurement, an interrupt can be generated. • Either one-time measurement or repeated measurement can be selected. 25.2 Configuration of PWC Timer The PWC timer consists of the PWC control/status register, PWC data buffer, and divide ratio control register. ■ Block Diagram of PWC Timer Figure 25.2-1 shows a block diagram of the PWC timer. Figure 25.2-1 Block Diagram of the PWC Timer PWCR read Error detection ERR Internal clock(machine clock/4) PWCR 16 Reload Data transfer 16 F2MC-16LX bus Overflow Clock 22 16-bit up-count timer Clock divider 3 2 Timer clear Count enabled Control bit output Control circuit Flag set, etc. CKS1/CKS0 Divider clear Start edge End edge selection selection Measurement start edge Measurement end edge Divide ON/OFF Input waveform comparator Edge detection Measurement end interrupt request Overflow interrupt request PWCSR PIS0/PIS1 PWC0 PWC1 8-bit divider ERR CKS0/CKS1 Divide ratio selection 15 2 DIVR 499 CHAPTER 25 PWC TIMER ■ Pin Related to PWC Timer The pin related to the PWC timer has 2 channels of PWC0/PWC1 and functions as the input port when the PWC is used. The PWC0/PWC1 pins function as the general-purpose I/O port (P36/PWC0, P37/PWC1) and input pin. ● Setting when using as PWC0/PWC1 pins When the PWC0/PWC1 are used as input by the PWC timer, the P36/PWC0,P37/PWC1 pins should be set to the input port by the port direction register (DDR3 bit6, bit7→"0"). ■ Block Diagram of Pin Related to PWC Timer Figure25.2-2 Block Diagram of Pin Related to PWC Timer Peripheral function input (PWC0, PWC1) Port data register (PDR) Internal data bus PDR Read Output latch P-ch PDR Write Pin Port direction register (DDR) Direction latch N-ch DDR Write DDR Read Stand-by control(SPL=1) Stand-by control : Stop mode (SPL=1), Time-base timer mode (SPL=1), Watch mode (SPL=1) 500 25.3 Configuration and Functions of PWC Timer Registers This section describes the configuration and functions of the registers used in the PWC timer. ■ List of PWC Timer Registers Figure 25.3-1 shows a list of the PWC timer registers. Figure 25.3-1 List of PWC Timer Registers bit15 bit8 bit7 bit0 PWCSR0,PWCSR1 (R/W) PWCR0,PWCR1 (R/W) DIVR0, DIVR1 PWC control/status register (PWCSR0,PWCSR1) Address: 000077H bit15 bit14 bit13 bit12 bit11 bit10 00007BH STRT STOP EDIR EDIE OVIR OVIE R R/W R/W R/W R/W R/W PWC control/status register (PWCSR0,PWCSR1) Address: bit7 bit6 bit5 bit4 bit3 bit2 000076H 00007AH CKS1 CKS0 PIS1 PIS0 S/C MOD2 R/W R/W R/W R/W R/W R/W (R/W) bit9 bit8 ERR Reserved R bit1 PWC data buffer register (PWCR0,PWCR1) Address: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 000078H D6 D5 D4 D3 D2 D1 D0 00007CH D7 R/W R/W R/W R/W R/W R/W R/W R/W R/W: R: -: bit2 - bit1 bit0 DIV1 DIV0 R/W 00000000B R/W PWC data buffer register (PWCR0,PWCR1) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 000079H D15 D14 D13 D12 D11 D10 D9 D8 00007DH R/W R/W R/W R/W R/W R/W R/W R/W Divide ratio control register (DIVR0,DIVR1) Address: bit7 bit6 bit5 bit4 bit3 000082H 000084H - 0000000XB bit0 MOD1 MOD0 R/W Initial value 00000000B 00000000B ------00B R/W Readable/writable Read only Undefined 501 CHAPTER 25 PWC TIMER 25.3.1 PWC Control/Status Register (PWCSR0, PWCSR1) This section describes the configuration and functions of the PWC control/status register (PWCSR0, PWCSR1). ■ PWC Control/Status Register (PWCSR0, PWCSR1) Figure 25.3-2 shows the bit configuration of the PWC control/status register (PWCSR0, PWCSR1). Figure 25.3-2 Bit Configuration of the PWC Control/Status Register (PWCSR0, PWCSR1) PWC control/status register (PWCSR0,PWCSR1) Address: bit15 bit14 bit13 bit12 bit11 bit10 000077H STRT STOP EDIR EDIE OVIR OVIE 00007BH R R/W R/W R/W R/W R/W PWC control/status register (PWCSR0,PWCSR1) Address: bit7 bit6 bit5 bit4 bit3 bit2 000076H CKS1 CKS0 PIS1 PIS0 S/C MOD2 00007AH R/W R/W R/W R/W R/W R/W R/W: R: -: bit9 ERR R bit8 Reserved bit1 bit0 0000000XB - MOD1 MOD0 R/W Initial value 00000000B R/W Readable/writable Read only Undefined The functions of bits in the PWC control/status register (PWCSR0, PWCSR1) are described below. [bit15, bit14] STRT, STOP (timer start bit, timer stop bit) These bits are used to start/restart/stop the 16-bit up-count timer. The operation state of the timer is displayed in read operations. The tables below show the functions of the STRT and STOP bits. Table 25.3-1 Functions Related to Write Operations (Operation Control of 16-bit Up-count Timer) STRT STOP Operation control function 0 0 No function/no effect on operation 0 1 Timer start/restart (when counting is allowed) * 1 0 Timer operation forcible stop (when counting is prohibited)* 1 1 No function/no effect on operation * : A clear bit-operation instruction is available. 502 Table 25.3-2 Functions Related to Read Operations (Indicating the Operation State of the 16-bit Up-count Timer) STRT STOP Operation control function 0 0 Timer stop mode (not started or end of measurement) (initial value) 1 1 Timer count operation mode (measurement in progress) • At reset, initialized to "00B". • Reading and writing are allowed. However, the meaning of the register contents is different for write and read operations, as indicated in Table 25.3-1 and Table 25.3-2. • The reading value returned in read-modify-write instructions is fixed at "11B" regardless of all bit values. • Writing the STRT/STOP bit to start/stop the timer can be performed for individual bits in order to execute bit operation instructions (bit clear). However, note that no bit operation instruction is available to read the operation state (the result of reading is always "1"). [bit13] EDIR (measurement end interrupt request flag) This bit is a flag that indicates the end of measurement in pulse width measurement. By setting this bit when measurement end interrupt sources are enabled (bit12: EDIE = 1), a measurement end interrupt request is generated. EDIR Cause of setting or clearing Cause for setting Set when pulse width measurement ends (when the PWCR contains the measurement result) Cause of clearing Cleared when the PWCR (measurement result) is read • Initialized to "0" at reset. • Only reading is allowed. • Bit values cannot be changed by writing. [bit12] EDIE (measurement end interrupt enable) This bit is used for control of measurement end interrupt requests when pulse width measurement is performed as shown in the table below. EDIE Operation 0 Measurement end interrupt request output prohibited (no interrupts occur even if EDIR is set) [initial value] 1 Measurement end interrupt request output allowed (interrupt occurs if EDIR is set) • Initialized to "0" at reset. • Reading or writing is allowed. 503 CHAPTER 25 PWC TIMER [bit11] OVIR (timer overflow interrupt request flag) This bit is a flag used to indicate an overflow of the 16-bit up-count timer to the area from FFFFH to 0000H. If this bit is set when timer overflow interrupt requests are enabled (bit10:OVIE = 1), a timer overflow interrupt request is generated. OVIR Cause of setting or clearing Cause for setting Set if a timer overflow occurs (to the area from FFFFH to 0000H) Cause of clearing Writing "0" or clearing by μDMAC • Initialized to "0" at reset. • Reading and writing are allowed; however, only writing "0" is effective, while writing "1" causes no changes in the bit value. • Read-modify-write type instructions read "1" irrespective of bit values. [bit10] OVIE (timer overflow interrupt request enable) This bit is used for control of measurement end interrupt requests during pulse width measurement, as shown in the following table. OVIE Operation 0 Overflow interrupt request output prohibited (No interrupts occur even if OVIR is set) [initial value] 1 Overflow interrupt request output allowed (An interrupt occurs if OVIR is set) • Initialized to "0" at reset. • Reading and writing are allowed. [bit9] ERR (Error Flag) This bit is a flag that indicates that, in the repeated measurement mode of pulse width measurement, a measurement operation has completed before the previous measurement result was read out from the PWCR. In this case, the PWCR value will be updated to the new measurement result while the immediately previous measurement result will be lost. Measurement will continue irrespective of the value for this bit. ERR Cause of setting or clearing Cause for setting This bit is set if a measurement result that has not been read out is overwritten by the next result. Cause of clearing This bit is cleared whenever the PWCR (measurement result) is read • Initialized to "0" at reset. • Only reading is allowed. Write operations have no effect. [bit8] Reserved bit This bit is reserved. 504 [bit7, bit6] CKS1, CKS0 (clock selection) These bits are used to select one internal count clock out of the three types listed in Table 25.3-3. Table 25.3-3 Count Clocks of the 16-bit Up-count Timer CKS1 CKS0 Count clock selection 0 0 Divide-by-4 clock of the machine clock (0.16 μs for a machine clock of 25 MHz) [initial value] 0 1 Divide-by-16 clock of the machine clock (0.64 μs for a machine clock of 25 MHz) 1 0 Divide-by-32 clock of the machine clock (1.28 μs for a machine clock of 25 MHz) 1 1 Setting prohibited (result of setting is undefined) • Initialized to "00B" at reset • Reading and writing are allowed. However, setting to "11B" is prohibited. Note: Rewriting after PWC timer start is prohibited. Write only before the timer is started or after the timer is stopped. [bit5, bit4] PIS1, PIS0 (Pulse width measurement input pin select) These bits are used to select the pulse width measurement input pin. Table 25.3-4 Selection of Pulse Width Measurement Input Pin PIS1 PIS0 Input clock selection 0 0 (Selecting PWC0 pin) [initial value] 0 1 Two inputs selected for compare (rising edge compare) 1 0 Two inputs selected for compare (falling edge compare) 1 1 Setting prohibited (result of setting is undefined) • Initialized to "00B" at reset. • Reading and writing are allowed. However, setting to "11B" is prohibited. • This bit is only valid in PWC0. (PWC0/PWC1 are used for input). For details, refer to Section "25.5.2 Operations of the Pulse Width Measurement Function". Note: Rewriting after PWC timer start is prohibited. Write only before the timer is started or after the timer is stopped. 505 CHAPTER 25 PWC TIMER [bit3] S/C (Selection of Measurement Mode (one-shot/repeated)) This bit is used to select the measurement mode. Table 25.3-5 Selection of the Measurement Mode for the 16-bit Up-Count Timer S/C Measurement mode selection Timer mode Pulse width 0 One-shot measurement mode [initial value] No reload (one-shot) Stopped after one-time measurement 1 Repeated measurement mode With reload (reload timer) Repeated measurement: buffer register enabled • Initialized to "0" at reset. • Reading and writing are allowed. Note: Rewriting after PWC timer start is prohibited. Write always either before the timer is started or after the timer is stopped. [bit2, bit1, bit0] MOD2, MOD1, MOD0 (Selection of operation mode or measurement edge) These bits are used to select the operation mode and an edge at which width measurement is performed. Table 25.3-6 Selection of Operation Mode or Measurement Edge for the 16-bit Up-count Timer MOD2 MOD1 MOD0 Selection of operation mode/measurement edge 0 0 0 Timer mode [initial value] 0 0 1 Timer mode (reload mode only) 0 1 0 Pulse width measurement mode between all edges (rising edge or falling edge to falling edge or rising edge) 0 1 1 Divide interval measurement mode (input divide enabled) 1 0 0 Interval measurement mode between rising edges (rising edge to rising edge) 1 0 1 "H"-level pulse width measurement mode (rising edge to falling edge) 1 1 0 "L"-level pulse width measurement mode (falling edge to rising edge) 1 1 1 Interval measurement mode between falling edges (falling edge to falling edge) • Initialized to "00B" at reset. • Reading and writing are allowed. Note: Rewriting immediately after PWC timer start is prohibited. Write always either before the timer is started or after the timer is stopped. 506 25.3.2 PWC Data Buffer Register (PWCR0, PWCR1) This section describes the configuration and functions of the PWC data buffer register (PWCR0, PWCR1). ■ PWC Data Buffer Register (PWCR0, PWCR1) Figure 25.3-3 shows the bit configuration of the PWC data buffer register (PWCR0, PWCR1). Figure 25.3-3 Bit Configuration of the PWC Data Buffer Register (PWCR0, PWCR1) PWC data buffer register (PWCR0,PWCR1) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 000079H D15 D14 D13 D12 D11 D10 D9 D8 00007DH R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B PWC data buffer register (PWCR0,PWCR1) Address: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 000078H D7 D6 D5 D4 D3 D2 D1 D0 00007CH R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/writable 00000000B The function of the PWC data buffer register (PWCR0, PWCR1) depends on whether the timer mode is selected (by setting the PWCSR register bit2 to bit0 (MOD2 to MOD0)) or the pulse width measurement mode is selected. ● Timer mode (reading/writing allowed) In a reload timer operation (PWCSR bit3:S/C = 1), the PWC data buffer register operates as a buffer register to store reload data. In this case, both reading and writing are allowed. In one-shot timer operation mode (PWCSR bit3:S/C = 0), the PWC data buffer register is used to directly access the up-count timer. In this case, both reading and writing are allowed, though writing can only be performed when the timer is stopped. Reading is available at any time, enabling the timer value to be read during counting. 507 CHAPTER 25 PWC TIMER ● Pulse width measurement mode (Only reading allowed) In repeated measurement mode (PWCSR bit3: S/C = 1), the PWC data buffer register operates as a buffer register to store the results of previous measurement. In this case, only reading is allowed. Write operations do not change the value of the register. In one-shot mode (PWCSR bit3: S/C = 0), the PWC data buffer register is used to directly access the upcount timer. In this case, only reading is allowed. Write operations do not change the value of the register. Reading is available at any time, enabling the timer value to be read during counting. After the measurement ends, the PWC data buffer register stores the measurement result. Note: This register can be accessed only via word transfer instructions. At reset, the register is initialized to "00B". 508 25.3.3 Divide Ratio Control Register (DIVR0, DIVR1) This section describes the configuration and functions of the divide ratio control register (DIVR0, DIVR1). ■ Divide Ratio Control Register (DIVR0, DIVR1) Figure 25.3-4 shows the bit configuration of the divide ratio control register (DIVR0, DIVR1). Figure 25.3-4 Bit Configuration of the Divide Ratio Control Register (DIVR0, DIVR1) Divide ratio control register (DIVR0,DIVR1) Address: bit7 bit6 bit5 bit4 bit3 000082H 000084H R/W : -: bit2 - bit1 bit0 DIV1 DIV0 R/W Initial value ------00B R/W Readable/writable Undefined This register is only used in divide interval measurement mode (PWCSR: bit2, bit1, bit0:MOD2, MOD1, MOD0 = 001B); it is not used in other modes. In divide interval measurement mode, pulses input to the measurement pin are divided according to the divide ratio set in this register. This allows measuring one interval width. Table 25.3-7 Selection of Divide Ratio DIV1 DIV0 Count clock selection 0 0 Divide-by-4 [initial value] 0 1 Divide-by-16 1 0 Divide-by-64 1 1 Divide-by-256 • Initialized to "00B" at reset • Reading and writing are allowed. Note: Rewriting after PWC timer start is prohibited. Write always either before the timer is started or after it is stopped. 509 CHAPTER 25 PWC TIMER 25.4 Interrupt of PWC Timer The interrupt of the PWC timer generates when an overflow of the up counter in timer function and the pulse width measurement are terminated. The PWC0 is used for PWC interrupt that can activate the DMA transfer and extended intelligent I/O service (EI2OS). ■ Interrupt of PWC Timer The interrupt control bit and interrupt source of the PWC timer is shown in the following table. Table 25.4-1 Interrupt Control Bit and Interrupt Source of PWC Timer Interrupt of termination for pulse width measurement Overflow interrupt of timer at operation of timer mode Interrupt request flag PWCSR0:EDIR (bit13) ch.0 PWCSR1:EDIR (bit13) ch.1 PWCSR0:OVIR (bit11) ch.0 PWCSR1:OVIR (bit11) ch.1 Interrupt request output enable bit PWCSR0:EDIE (bit12) ch.0 PWCSR1:EDIE (bit12) ch.1 PWCSR0:OVIE (bit10) ch.0 PWCSR1:OVIE (bit10) ch.1 When pulse width measurement is terminated When 16-bit up count timer overflows from FFFFH → 0000H Interrupt generation source ■ Interrupt Source Related to PWC Timer The following two interrupt sources are available. • In the timer function, overflow interrupt occurs if the OVIE (bit10) is "1" when the OVIR (bit11) flag in the PWC control/status register (PWCSR0, PWCSR1) is set. • In the pulse width measurement, the interrupt occurs if the EDIE (bit12) is "1" (termination of transmission) when the EDIR (bit13) flag in the PWC control/status register (PWCSR0, PWCSR1) is set. 510 ■ Interrupt of PWC Timer, DMA Transfer, and EI2OS Table 25.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 25.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register EI2OS clear μDMAC channel number Number Address PWC1 ❍ × #19 FFFFB0H ⎯ ⎯ ⎯ #20 FFFFACH PWC0* ❍ 1 #21 FFFFA8H Interrupt source ×: ❍: *: Interrupt vector Interrupt control register Number Address ICR04 0000B4H ICR05 0000B5H Interrupt request flag is not cleared. Interrupt request flag is cleared. This interrupt source shares the interrupt source and interrupt number of other peripheral function. For details, see Table 4.2-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, the other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function The PWC timer does not correspond to the DMA transfer function, but the EI2OS function. When the EI2OS function is used, it is necessary to disable other interrupt that shares the interrupt control register (ICR). 511 CHAPTER 25 PWC TIMER 25.5 Operations of PWC Timer This section describes the operations of the PWC timer. ■ Outline of PWC Timer Operations The PWC timer is a multifunction timer based on an 16-bit up-count timer, which integrates measurement input pins with the 8-bit input divide circuit. The PWC timer has the two major functions listed below: • Timer function • Pulse width count function For either function, a count clock can be selected among three types of clocks (divide-by 4/16/32 of machine clock). The basic performance and operation of each function are described below. 512 25.5.1 Operations of the Timer Function This timer is an up-count (incrementing) timer providing both reload and one-shot operations. ■ Operation of Timer Functions After the timer starts, its value is incremented at each pulse of the count clock. If an overflow occurs in the range FFFFH --> 0000H, an interrupt request may be generated. If an overflow is generated, the following operations may be performed depending on the mode: • In one-shot mode: Counting stops • In reload mode: Reload register data is reloaded into the timer to restart counting. Figure 25.5-1 shows the operations of the timer functions in one-shot mode and reload mode. Figure 25.5-1 Operations of Timer Functions [One-shot mode] (Solid line: timer count value) Overflow Overflow FFFFH Writing to PWCR (Restarting prohibited) 0000H Timer start OVIR flag set/timer stop Timer start OVIR flag set/timer stop Time [Reload mode] Timer count value Overflow Overflow Overflow Overflow Overflow FFFFH Reload PWCR write value 0000H Reload PWCR write Timer start * Reload Reload Reload * * Reload * Restart Reload * Timer stop Time *: OVIR flag set 513 CHAPTER 25 PWC TIMER 25.5.2 Operations of the Pulse Width Measurement Function With this function, the timer can be used to measure the time interval between any input pulse events. ■ Operations of the Pulse Width Measurement Function After the start of the pulse width measurement function, counting does not start before the specified measurement start edge is input. The timer is cleared to 0000H whenever a start edge is detected, and counting up starts. Counting stops when a stop edge is detected. The count value during this period is stored in the register as the pulse width. The end of measurement is detected by an interrupt. After measurement ends, the following operations are performed depending on the measurement mode: • In one-shot measurement mode: Operation is interrupted. • In repeated measurement mode: The timer value is transferred to the buffer register and the measurement is suspended until input of the next start edge. Figure 25.5-2 shows the pulse width measurement operation (one-shot measurement mode/"H"-level pulse width measurement). Figure 25.5-3 shows the pulse width measurement operation (repeated measurement mode/ "H"-level pulse width measurement). Figure 25.5-2 Pulse Width Measurement Operation (One-shot Measurement Mode/"H"-level Pulse Width Measurement) PWC input pulses to be measured (Solid line indicates timer count value) Timer count value FFFFH Timer clear 0000H Measurement Timer starts start Timer stop EDIR flag set (measurement end) 514 Time Figure 25.5-3 Pulse Width Measurement Operation (Repeated Measurement Mode/"H"-level Pulse Width Measurement) PWC input pulses to be measured (Solid line indicates timer count value) Timer count value Overflow FFFFH Data transfer to PWCR Timer clear Timer clear 0000H Measurement Timer starts start Timer stop Timer start Time EDIR flag set (measurement end) EDIR flag set 515 CHAPTER 25 PWC TIMER 25.5.3 Selection of Count Clock and Operation Mode This section describes the selection of the count clock and the operation mode. ■ Count Clock Selection A timer count clock can be selected from among three types of internal clocks by setting PWCSR: bit7 (CKS1) and bit6 (CKS0). Table 25.5-1 shows how to select the count clock. Table 25.5-1 Count Clock Selection PWCSR/bit7, bit6: CKS1, CKS0 Internal count clock selected 00B 1/4 of machine clock (0.16 μs for 25 MHz machine clock) [initial value] 01B 1/16 of machine clock (0.64 μs for 25 MHz machine clock) 10B 1/32 of machine clock (1.28 μs for 25 MHz machine clock) After reset, the divide-by-4 clock of the machine clock is initially selected. Note: Select the count clock before timer start. ■ Selection of Operation Mode The operation mode or measurement mode is selected by setting the PWCSR bits. • Selection of the operation mode: PWCSR: bit2, bit1, bit0 (MOD2, MOD1, MOD0 bits) Selecting the timer mode/pulse width measurement mode and specifying the measurement edge. • Setting the measurement mode: PWCSR: bit3 (S/C bit) Selecting between one-shot measurement/repeated measurement or reload/one-shot Table 25.5-2 shows the settings for selection of the operation mode/measurement mode. 516 Table 25.5-2 Settings of Operation Mode/Measurement Mode Operation mode Timer S/C MOD2 MOD1 MOD0 One-shot timer 0 0 0 0 Reload timer 1 0 0 0 One-shot measurement: buffer disabled 0 0 1 0 Repeated measurement: buffer enabled 1 0 1 0 One-shot measurement: buffer disabled 0 0 1 1 Repeated measurement: buffer enabled 1 0 1 1 One-shot measurement: buffer disabled 0 1 0 0 Repeated measurement: buffer enabled 1 1 0 0 One-shot measurement: buffer disabled 0 1 0 1 Repeated measurement: buffer enabled 1 1 0 1 One-shot measurement: buffer disabled 0 1 1 0 Repeated measurement: buffer enabled 1 1 1 0 One-shot measurement: buffer disabled 0 1 1 1 Repeated measurement: buffer enabled 1 1 1 1 - Rising edge or falling edge to rising edge or falling edge Measurement between all edges Divide interval measurement (Divide-by 1 to 256) Rising edge to rising edge Interval measurement between rising edges Pulse width measurement Rising edge to falling edge "H"-level pulse width measurement Falling edge to rising edge "L"- level pulse width measurement Falling edge to falling edge Interval measurement between falling edges The one-shot timer is selected initially after reset. Note: Select the operation mode always before the start of the timer. 517 CHAPTER 25 PWC TIMER 25.5.4 Start and Stop of Timer/Pulse Width Measurement Start/restart/stop/forcible stop of each operation are controlled by setting the PWCSR: bit15, bit14 (STRT, STOP bits). ■ Start and Stop of Timer/Pulse Width Measurement Start/restart of the timer/pulse width measurement is initiated by setting the STRT bit to "0", while a forcible stop is initiated by setting the STOP bit to "0". However, this is only effective if the values are complementary to each other. When using instructions other than bit operation instructions (such as byte instructions), be sure to set only the bit combinations indicated in Table 25.5-3. Table 25.5-3 Function of STRT Bit and STOP Bit STRT STOP Function 0 1 Start/restart of timer/pulse width measurement 1 0 Forcible stop of timer/pulse width measurement When using bit operation instructions (the clear bit-operation instruction), special care is not required, since the hardware will ensure that only the combinations of values indicated in Table 25.5-3 are written. ■ Operation After Measurement Start The operation of timer mode and pulse width measurement mode after measurement start are as follows. ● Timer mode Count operation starts immediately. ● Pulse width measurement mode Counting will not start until the measurement start edge is detected. After the measurement start edge is detected, the 16-bit up-count timer is cleared to "0000B" to start counting. 518 ■ Restart Restart is defined as a start operation (setting the STRT bit to "0") performed after entering timer/pulse width measurement mode. Restart operates as follows depending on the mode: ● One-shot timer mode Restart has no effect. ● Reload Timer Mode Reload is performed and operation continues. If a restart occurs at the same time as an overflow, the overflow flag (OVIR) is set. ● Pulse width measurement mode In the measurement start edge wait state, restart has no effect on the operation. In measurement mode, counting stops and the measurement start edge wait state is entered. If, in this mode, measurement end edge detection and restart occur at the same time, the measurement end interrupt request flag (EDIR) is set. In repeated measurement mode, the result will be transferred to the PWCR. ■ Stop In one-shot timer mode or one-shot measurement mode, no explicit stop operation needs to be performed because counting will automatically stop at a timer overflow or at measurement end. However, in other modes, the timer must be forcibly stopped. Moreover, providing an explicit stop operation allows the timer to stop before it would stop automatically. ● Comparing and selection of two inputs If a forcible stop is performed before the edge selected via PWC1 has been detected, the first measurement result after restart of measurement will contain an error. Be sure to perform a forcible stop only after the edge in PWC1 has been detected. 519 CHAPTER 25 PWC TIMER ■ Confirmation of Operation State The STRT/STOP bits, which have been explained above, operate as operation state indicator bits when read. Table 25.5-4 shows the function of the operation state indicator bits. Table 25.5-4 Function of the Operation State Indicator Bits STRT STOP Operation state 0 0 Timer stop (except in measurement start edge wait state): Indicates that the timer has not started or that measurement has ended. 1 1 Timer counting is being performed or the system is in measurement start edge wait state Note: The same value is read regardless of whether STRT or STOP bit is read. If these bits are read with read-modify-write instructions (such as bit operation instructions), "11B" is always returned. Do not use read-modify-write instructions for reading. 520 25.5.5 Timer Mode Operation This section describes the device operation in timer mode. ■ Clearing the Timer In the following cases, the 16-bit up-count timer is cleared to "0000H": • At reset • If, in pulse width measurement mode, a measurement start edge is detected and counting starts ■ One-Shot Operation Mode In one-shot operation mode, the timer count is incremented with every count clock after timer starts. If an overflow occurs while incrementing from FFFFH to 0000H, the timer automatically stops. If the PWCR is set to any value before timer starts, counting will start with that value. In this case, the value that was previously set will not be preserved, and the PWCR value will always indicate the current count value. ■ Reload Operation Mode In reload operation mode, the timer is set to the reload value stored in PWCR, and the timer will be incremented with every count clock after the timer starts. If an overflow occurs while incrementing from FFFFH to 0000H, the reload value in PWCR will be loaded again into the timer (reload operation), and counting will be repeated from that value. The timer does not stop until it is forcibly stopped due to writing the PWCSR: STOP bit, or due to a reset. The value set in the PWCR before the timer starts is retained during counting as a reload value, and will be loaded into the timer if a start/restart or an overflow occurs. If the value that is set in the PWCR changes during counting, this new, changed reload value will be used at the next overflow or timer restart. ■ Timer Value and Reload Value In one-shot operation mode, the PWCR is directly accessed by the up-count timer. Any value written to the PWCR will also be written to the timer as it is. When reading the PWCR while the timer is in progress, the value of the current timer count will be returned. If any value is set to the PWCR before the timer starts, counting will start from this value. In reload operation mode, accessing the up-count timer is prohibited. The PWCR operates as a reload register that stores a reload value. If a start/restart/overflow occurs, the timer is always set to the value stored in the PWCR. When reading the PWCR, the stored reload value will be read. If the timer is placed in one-shot operation mode after the reload operation mode is forcibly canceled, the PWCR value and timer value are not specified. Be sure to always specify these values before using the timer. ■ Interrupt Generation Request In timer mode, an interrupt request may be generated due to a timer overflow. If an overflow occurs due to incrementing the counter, the overflow flag is set and an overflow interrupt request is generated, if such requests are allowed. 521 CHAPTER 25 PWC TIMER ■ Timer Interval In one-shot operation mode, after PWCR is set to "0000H" to start the timer, an overflow is generated after the count 65536 is reached and counting will stop. The time that elapses from start to stop can be calculated with the following formula: T1 = (65536 - n1) x t Where T1: time from start to stop [μs] n1: timer value stored in the PWCR at the start t: count clock interval [μs] In reload operation mode, after PWCR is set to "0000H" to start the timer, an overflow will be generated every time the counter reaches 65536. The reload interval time can be calculated with the following formula: TR = (65536 - nR) x t Where TR: reload interval (overflow interval) [μs] nR: reload value stored in PWCR t: count clock interval [μs] ■ Count Clock and Maximum Interval In timer mode, the maximum interval is obtained when setting PWCR to the value "0000H". Count clock interval and maximum timer interval for the case when the machine clock (represented as φ hereafter) is 25 MHz are shown in Table 25.5-5. Table 25.5-5 Count Clock and Interval Count clock selection CSK1, CSK0 = 00B: (φ/4) CSK1, CSK0 = 00B: (φ/16) CSK1, CSK0 = 00B: (φ/32) Count clock interval 0.25 μs 1.0 μs 2.0 μs Maximum timer interval 16.38 ms 65.5 ms 131.1 ms 522 ■ Timer Operation Flow Figure 25.5-4 shows the operation flow of the timer. Various settings Figure 25.5-4 Operational Flow of the Timer Count clock selection Operation/measurement mode selection Interrupt flag clear Interrupt enable Set value to PWCR Restart Reload operation mode Start via the STRT bit One-shot operation mode Read the PWCR value into the timer Start count Start count Incrementing Incrementing Overflow occurs → OVIR flag set Overflow occurs → OVIR flag set Stop of counting Operation stop 523 CHAPTER 25 PWC TIMER 25.5.6 Operation in Pulse Width Measurement Mode This section describes operation in pulse width measurement mode. ■ One-Shot Measurement and Repeated Measurement There are two modes for pulse width measurement: a mode for one-time measurement and a mode for repeated measurement. The mode to use is selected via the PWCSR: S/C bit (Refer to Section "25.5.3 Selection of Count Clock and Operation Mode"). ● One-Shot Measurement Mode As soon as the first measurement end edge is detected, the timer counter will stop and the measurement end interrupt request flag (EDIR) in the PWCSR is set, causing a stop of measurement (however, if restart occurs at the same time, the device will wait for measurement to start again). ● Repeated measurement mode If a measurement end edge is detected, the timer counter stops, the PWCSR's measurement end interrupt request flag (EDIR) is set, and counting stops until the next measurement start edge is detected. As soon as the next measurement start edge is detected, the timer is cleared to 0000H, and measurement starts again. At the end of measurement, the measurement result of the timer is transferred to the PWCR. Note: Be sure to change the measurement mode only while the timer is stopped. ■ Measurement Result Data One-shot measurement mode and repeated measurement mode differ in handling of the measurement result, timer values, and PWCR functions. Measurement results in both modes are as follows: ● In one-shot measurement mode • The timer value while measurement is in progress can be obtained by reading the PWCR. • The end result data of measurement can be obtained by reading the PWCR after measurement has ended. ● In repeated measurement mode • At the end of measurement, the timer measurement result is transferred to the PWCR. • Reading the PWCR will return the immediately previously obtained measurement result, because the previous measurement result is kept during the measurement operation. The timer value while measurement is in progress cannot be read. In this mode, if a measurement result is not read out before the next measurement operation ends, the measurement result will be overwritten with the next measurement result. In this case, an error flag (ERR) in the PWCSR is set. The error flag (ERR) is automatically cleared by reading the PWCR. 524 ■ Selection of Input Pin The PWC timer provides two channels, PWC0 and PWC1, that are used as input signal pins for the pulse width counting. Each of these channels can therefore be used independently. Combining PWC0 and PWC1 with PIS1 and PIS0 in PWCSR0 enables the time between each input waveform's rising and falling edges to be measured. Note that the PWC register used in this case is PWC0. Figure 25.5-5 shows the relationship between input waveform and internal measurement waveform. Figure 25.5-5 Input Waveform and Internal Measurement Waveform PWC0 input waveform PWC1 input waveform PWC internal measurement waveform when PIS1 and PIS0 = 01B The time between rising/falling edges can be obtained by measuring the width of "H" within this internal measurement waveform. PWC internal measurement waveform when PIS1 and PIS0 = 10B Notes: • In comparing two inputs, start counting from PWC0 regardless of whether rising or falling edges are detected and stop with PWC1. • If necessary, change the detection mode of rising and falling edges after measurement ends. 525 CHAPTER 25 PWC TIMER ■ Measurement Mode and Counter Operation The measurement mode is selected from among six types depending on which portions of the input pulse are to be measured. For a high precision measurement of a high frequency pulse width, a dedicated mode is provided to arbitrarily divide the input pulse for interval measurement. Table 25.5-6 shows a list of the measurement modes. Table 25.5-6 List of Measurement Modes (1 / 2) Measurement mode MOD2 MOD1 MOD0 Measurement items (W: pulse width to be measured) W "H" pulse width measurement 1 0 1 Start of counting W Stop of counting Start Stop Measures the width of the "H" pulse. Start of counting (measurement): When rising edge is detected End of counting (measurement): When falling edge is detected W "L" pulse width measurement 1 1 0 Start of counting W Stop of counting Start Stop Measures the width of the "L" pulse. Start of counting (measurement): When rising edge is detected End of counting (measurement): When falling edge is detected W Interval measurement between rising edges W W Stop of counting 1 0 0 Start of counting Start Stop Start Stop Measures the interval between rising edges. Start of counting (measurement): When rising edge is detected End of counting (measurement): When rising edge is detected W Interval measurement between falling edges W W Stop of counting 1 1 1 Start of counting Start Stop Start Stop Measures the interval between falling edges. Start of counting (measurement): When falling edge is detected End of counting (measurement): When falling edge is detected 526 Table 25.5-6 List of Measurement Modes (2 / 2) Measurement mode MOD2 MOD1 MOD0 Measurement items (W: pulse width to be measured) W W W Stop of counting Pulse width measurement for all edges 0 1 0 Start of counting Start Stop Start Stop Measures the pulse width between repeatedly input edges Start of counting (measurement): When an edge is detected End of counting (measurement): When an edge is detected W Divide interval measurement 0 1 1 W W Stop of counting Start of counting (Example of divide-by-4) Start Stop Measures an interval by dividing the input pulse with a divide ratio selected in the divide ratio control register DIVR. Start of counting (measurement): When a rising edge is detected soon after the start End of counting (measurement): When an interval ends after dividing In any mode, counting is not performed by the timer during the time from the start of counting to the input of the count start edge. When the count start edge is input, the timer is cleared to 0000H, and the timer counts every count clock until a count end edge is input. When a count end edge is entered, the following operations are executed: 1. Set the PWCSR's measurement end interrupt request flag (EDIR) 2. Stop the timer count operation (except in cases when the edge is input for a restart) 3. In repeated measurement mode, the timer value (measurement result) is transferred to the PWCR, and the count operation is suspended until the next measurement start edge is entered. 4. In one-shot measurement mode, the measurement will end (except in cases when the edge is input for a restart) If, in repeated measurement mode, pulse width measurement between all edges or divide measurement is performed, the end edge defines the next edge for measurement. ■ Minimum Input Pulse Width The following restriction applies to pulses that are input to the pulse width measurement input pins (PWC1, PWC0): • The pulse width must be four machine cycles or more (0.16 μs for a 25 MHz machine clock). 527 CHAPTER 25 PWC TIMER ■ Pulse Width/Interval Calculation Method The pulse width/interval to be measured can be calculated with the following formula: TW = n × t / DIV [μs] Where TW: pulse width/interval to be measured [μs] n: measurement result data in PWCR t: count clock interval [μs] DIV: divide ratio selected via the divide ratio control register DIVR (use 1, except in divide frequency measurement mode) ■ Range for Counting the Pulse Width/Interval Depending on the selected combination of count clock and divide ratio of the input divider, the allowed pulse width/interval range for measurement will vary. Table 25.5-7 shows a list of measurement ranges when a machine clock (φ, hereafter) of 25MHz is applied. Table 25.5-7 List of Pulse Width Measurement Ranges Divide ratio DIV1 DIV0 CKS1,CKS0=00 (φ/4) CKS1,CKS0=01 (φ/16) CKS1,CKS0=10 (φ/32) No division − − 0.16μs to 10.49ms [0.16μs] 0.16μs to 41.94ms [0.64μs] 0.16μs to 83.89ms [1.28μs] Divide-by-4 0 0 0.16μs to 2.62ms [0.04μs] 0.16μs to 10.49ms [0.16μs] 0.16μs to 20.97ms [0.64μs] Divide-by-16 0 1 0.16μs to 0.66ms [10ns] 0.16μs to 2.62ms [0.04μs] 0.16μs to 5.24ms [0.16μs] Divide-by-64 1 0 0.16μs to 164μs [2.5ns] 0.16μs to 0.66ms [10ns] 0.16μs to 1.31ms [0.04μs] Divide-by-256 1 1 0.16μs to 41μs [0.625ns] 0.16μs to 164μs [2.5ns] 0.16μs to 328μs [10ns] Note: The value in [ ] indicates the resolution per bit. ■ Generation of Interrupt Requests In pulse width measurement mode, two types of interrupt requests can be generated, as listed below: ● Interrupt requests due to timer overflows If an overflow occurs due to incrementing in measurement mode, an overflow flag is set. If overflow interrupt requests are enabled, an interrupt request is generated. ● Interrupt requests due to the end of measurement If measurement end interrupt requests are enabled, an interrupt request is generated when a measurement end edge is detected and the PWCSR's measurement end flag (EDIR) is set. The measurement end flag EDIR is automatically cleared when the measurement result is read out from the PWCR. 528 ■ Operational Flow of Pulse Width Measurement Figure 25.5-6 shows the operational flow of pulse width measurement. Various settings Figure 25.5-6 Operational Flow of Pulse Width Measurement Count clock selection Operation/measurement mode selection Interrupt flag clear Interrupt enable Restart Start with STRT bit Repeated measurement mode One-shot measurement mode Measurement start edge detected Measurement start edge detected Clearing of timer Clearing of timer Start of counting Start of counting Incrementing Incrementing Overflow generated → OVIR flag set Overflow generated → OVIR flag set Measurement end edge detected → EDIR flag set Measurement end edge detected → EDIR flag set Stop of counting Stop of counting Timer value transferred to PWCR Operation end 529 CHAPTER 25 PWC TIMER 25.6 Notes on PWC Timer Usage This section provides notes on using the PWC timer. ■ Notes on PWC Timer Usage ● Notes on rewriting the register Rewriting the bits in the PWCSR is prohibited. Rewrite the register either before the timer is started or after the timer stops. • [bit7, bit6] CKS1, CKS0 (clock selection) • [bit5, bit4] PIS1, PIS0 (input signal selection) • [bit3] CKS1,CKS0 (clock selection) • [bit2, bit1, bit0] MOD2, MOD1, MOD0 (operation mode/measurement edge selection) • Rewriting DIVR during timer operation is prohibited. Rewrite it either before start or after stop of timer operation. ● Handling the measurement end flag in timer mode The value of the PWCSR's measurement end interrupt request flag (EDIR) is not significant in timer mode. Consequently, set the PWCSR's measurement end interrupt enable bit (EDIE) to "0" if it is to be used in timer mode. ● Handling of STRT and STOP bits in the PWCSR Note that the meaning of these two bits is different depending on whether a write or read operation is performed (Refer to Section "25.3.1 PWC Control/Status Register (PWCSR0, PWCSR1)"). The read value returned in read-modify-write instructions is always "11B" irrespective of the value for these bits. Be sure, therefore, not to use bit operation instructions for reading the operation state (these bits will always return "operation in progress"). However, bit operation instructions (such as bit clear) can be used for writing the STRT and STOP bits to start or stop the timer. ● Timer Clear In pulse width measurement mode, the timer is cleared at the measurement start edge. The timer data will therefore be invalid before the start of measurement. ● PWCR and timer values when the mode changes 530 • If the timer is forcibly stopped and set to one-shot timer mode from reload timer mode, the timer value and the value stored in the PWCR will become unspecified. Be sure to define these values before using the timer. • If the timer is used in one-shot timer mode, the PWCR value is unspecified. Use the timer only after defining the value. • To switch the mode from pulse width measurement mode to timer mode, specify the PWCR value again before starting the timer. ● Minimum pulse width The following restrictions apply to pulses that can be input to the pulse width measurement input pin. • Minimum pulse width: machine clock divided-by-2 (0.16 μs or more for 25 MHz machine clock) • Minimum input frequency: machine clock divided-by-4 (6.25 MHz or less for 25 MHz machine clock) If a pulse with lower width or higher frequency than specified above is input, correct operation cannot be assured. In the event that the input signal might contain noise, eliminate the noise using a filter externally from the chip before inputting the pulse. ● Divide frequency measurement mode In divide interval measurement mode, which is one of the pulse width measurement modes, the input pulse is divided. Note that the pulse width as calculated from the measurement results will therefore be an averaged value. ● Handling of clock selection bit Do not set [bit7, bit6] of the PWCR (clock selection bits CKS1 and CKS0) to "11B". ● Handling of reserved bit [bit8] in the PWCR is reserved. If necessary, clear this bit by writing "0". ● Restart during operation Restarting after the count operation has been started may cause the following events depending on the timing of restart: • If, in reload timer mode, a restart occurs at the same time as an overflow: The restart is performed, but the overflow flag (OVIR) is set. • If, in pulse width one-shot measurement mode, a restart occurs at the same time as detection of a measurement end edge: Restart is performed, and the measurement end interrupt request flag (EDIR) is set. • If, in pulse width repeated measurement mode, a restart occurs at the same time as measurement end edge detection: Restart is performed, but the measurement end interrupt request flag (EDIR) is set and the measurement result is transferred to the PWCR. ● If the PWC timer is used in "H"-pulse or L- pulse width measurement mode as the repeated measurement mode If, after the end of pulse width measurement, the pulse width measurement start wait state is entered, the timer to be stopped might continue with the overflow flag (OVIR) being set before the pulse width measurement starts. In other words, even if no overflow occurs at the next pulse width measurement end, the overflow flag may be set. Therefore, do not use the overflow flag when you use the PWC timer in "H"pulse or "L"-pulse width measurement mode as repeated measurement mode. 531 CHAPTER 25 PWC TIMER 532 CHAPTER 26 I2C INTERFACE This chapter provides an overview, configuration, interrupt, and operation of the I2C interface and explains the configuration and functions of its registers. 26.1 Overview of I2C Interface 26.2 Configuration of I2C Interface 26.3 Configuration and Functions of I2C Interface Registers 26.4 Interrupt of I2C Interface 26.5 I2C Interface Operation 533 CHAPTER 26 I2C INTERFACE 26.1 Overview of I2C Interface The I2C interface is a serial I/O port supporting the Inter IC BUS, allowing master/slave devices to operate over the I2C bus. ■ I2C Interface Function The I2C interface has the following functions. 534 • Master/slave transmit/receive function • Arbitration function • Clock synchronization function • Slave address/general call address detection function • Transfer direction detection function • Repeated issuance of start conditions and start condition detection function • Bus error detection function 26.2 Configuration of I2C Interface ■ Block Diagram of the I2C Interface Figure 26.2-1 shows a block diagram of the I2C interface. Figure 26.2-1 Block Diagram of I2C Interface F2MC-16LX bus ICCR EN I2C enable ICCR Clock divider 1 5 6 7 8 CS4 Peripheral clock Clock selector 1 CS3 Clock divider 2 2 4 8 16 32 64 128 256 CS2 CS1 CS0 Sync Clock selector 2 Shift clock edge change timing IBSR BB RSC LRB Shift clock generator Bus busy Repeat start Last bit Start/stop condition detection Transmit/ receive TRX Error First byte FBT Arbitration lost detection AL IBCR SCL BER BEIE Interrupt request INTE IRQ SDA INT IBCR SCC MSS ACK GCAA End Start Master ACK permit Start/stop condition generation GC-ACK permit IDAR IBCR AAS GCA Slave Global call Slave address compare IADR 535 CHAPTER 26 I2C INTERFACE ■ Pin Related to I2C Interface The pin related to the I2C interface has the SDA data input/output pin and SCL clock input/output pin. The SCL/SDA pins function as the general-purpose I/O port (P76/SCL, P77/SDA) and I2C interface. When using as the general-purpose I/O port, data is always enabled as port because P76, P77 of the port direction register (DDR) do not exist (MB90980 series only). In MB90980 series, the P76/SCL, P77/SDA pins are N-ch open-drain pin. ● Setting when using as SCL/SDA pin When using as the I2C interface, the port data register should be set (PDR7 : bit14, bit15 → "1"). Also, when using as the input port, the pull-up resistor must be added to the external pin. ■ Block Diagram of Pin Related to I2C Interface Figure 26.2-2 Block Diagram of Pin Related to I2C Interface Peripheral function input (SCL/SDA) Port data register(PDR) Peripheral function output (SCL/SDA) Peripheral function output enable Internal data bus PDR Read Output latch Pin PDR Write N-ch Standby control(SPL=1) Standby control : Stop mode (SPL=1), time-base timer mode (SPL=1), watch mode (SPL=1) 536 26.3 Configuration and Functions of I2C Interface Registers This section describes the configuration and functions of the I2C interface registers. ■ List of I2C Interface Registers ● Bus status register (IBSR) Figure 26.3-1 Bus Status Register (IBSR) Bus status register(IBSR) bit7 Address: 000088H bit6 bit5 bit4 bit3 bit2 bit1 bit0 Initial value BB RSC AL LRB TRX AAS GCA FBT R R R R R R R 00000000B R R: Read only ● Bus control register (IBCR) Figure 26.3-2 Bus Control Register (IBCR) Bus control register (IBCR) bit15 bit14 bit13 bit12 bit11 bit10 Address: bit9 Initial value bit8 000089H BER BEIE SCC MSS ACK GCAA INTE INT 00000000B R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/writable ● Clock control register (ICCR) Figure 26.3-3 Clock Control Register (ICCR) Clock control register (ICCR) Address: 00008AH R/W: -: Readable/writable Undefined bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 - - EN CS4 CS3 CS2 CS1 CS0 - - R/W R/W R/W R/W R/W R/W Initial value --0XXXXXB ● Address register (IADR) Figure 26.3-4 Address Register (IADR) Address register (IADR) Address: 00008BH R/W: -: bit15 bit14 bit13 bit12 bit11 bit10 - Readable/writable Undefined A6 A5 A4 A3 A2 bit9 bit8 Initial value A1 A0 -XXXXXXXB R/W R/W R/W R/W R/W R/W R/W 537 CHAPTER 26 I2C INTERFACE ● Data register (IDAR) Figure 26.3-5 Data Register (IDAR) Data register (IDAR) R/W: 538 Address: bit7 bit6 bit5 00008CH D7 D6 D5 bit4 bit3 D4 D3 bit2 bit1 bit0 D2 D1 D0 R/W R/W R/W R/W R/W R/W R/W R/W Readable/writable Initial value XXXXXXXXB 26.3.1 Bus Status Register (IBSR) This section describes the configuration and functions of the bus status register (IBSR). ■ Bus Status Register (IBSR) The diagram below shows the bit configuration of the bus status register (IBSR). Figure 26.3-6 Bit Configuration of Bus Status Register (IBSR) Bus status register(IBSR) Address: 000088H bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 BB RSC AL LRB TRX AAS GCA FBT R R R R R R R Initial value 00000000B R R: Read only The functions of bits in the bus status register (IBSR) are described below. [bit7] BB: Bus Busy This bit is used to indicate the I2C bus status. BB Operation 0 Stop condition is detected. 1 Start condition is detected (bus is used). [bit6] RSC: Repeated Start Condition This bit is used to detect a repeated start condition. RSC Operation 0 Repeated start condition is not detected. 1 Start condition is detected again when bus is used. This bit is cleared by setting the INT bit to "0", addressing in a mode other than slave mode, detecting a start condition in bus idle state, or detecting a stop condition. [bit5] AL: Arbitration Lost This bit is used to detect the arbitration lost state. AL Operation 0 Arbitration lost is not detected. 1 Arbitration lost is generated in master transfer mode, or the MSS bit is set to "1" while another system is using the bus. Cleared if the INT bit is set to "0". 539 CHAPTER 26 I2C INTERFACE [bit4] LRB: Last Received bit This bit is an acknowledge storage bit used to store an acknowledgement from the reception side. LRB Operation 0 Reception is acknowledged. 1 Reception is not acknowledged. This bit is cleared if a start or stop condition is detected. [bit3] TRX: Transfer/Receive This bit is used to indicate transmission or reception for data transfer. TRX Operation 0 Reception 1 Transmission [bit2] AAS: Addressed As Slave This bit is used to detect the addressing mode. AAS Operation 0 Addressing was performed in a mode other than slave mode. 1 Addressing was performed in slave mode. This bit is cleared if a start or stop condition is detected. [bit1] GCA: General Call Address This bit is used to detect the general call address (00H). GCA Operation 0 No general call address is received in slave mode. 1 A general call address is received in slave mode. This bit is cleared if a start or stop condition is detected. [bit0] FBT: First Byte Transfer This bit is used to detect the first byte (address data). FBT Operation 0 The data received is not first byte. 1 The data received is first byte (address data). This bit is cleared if the INT bit is set to "0" or addressing was performed in a mode other than slave mode, even though the bit was set to "1" because of detection for a start condition. 540 26.3.2 Bus Control Register (IBCR) This section describes the configuration and functions of the bus control register (IBCR). ■ Bus Control Register (IBCR) The diagram below shows the bit configuration of the bus control register (IBCR). Figure 26.3-7 Bit Configuration of Bus Control Register (IBCR) Bus control register (IBCR) Address: bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 000089H BER BEIE SCC MSS ACK GCAA INTE INT Initial value 00000000B R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/writable The functions of bits in the bus control register (IBCR) are as follows. [bit15] BER: Bus ERror This bit is a bus error interrupt request flag. The function of this bit in write and read operations is different. (During writing) BER Operation 0 Bus error interrupt request flag is cleared. 1 Not applicable. (During reading) BER Operation 0 No bus error was detected. 1 An illegal start or stop condition was detected in data transfer mode. If this bit is set, the EN bit of the ICCR register is cleared and the I2C interface enters the stop state with the data transfer interrupted. [bit14] BEIE: Bus Error Interrupt Enable This bit is used to enable bus error interrupts. BEIE Operation 0 Bus error interrupts prohibited. 1 Bus error interrupts allowed. If, with this bit set to "1", the BER bit is set to "1", an interrupt is generated. 541 CHAPTER 26 I2C INTERFACE [bit13] SCC: Start Condition Continue This bit is used to generate a start condition. (During writing) SCC Operation 0 Not applicable. 1 Start condition is generated again in master transfer mode. Read operations always return "0" for this bit. [bit12] MSS: Master Slave Select This bit is used to select between master mode and slave mode. MSS Operation 0 After the stop condition is generated and transferred, the device enters slave mode. 1 The device enters master mode, the start condition is generated, and transfer starts. This bit is cleared if arbitration lost is detected in master transfer mode. The device then enters slave mode. Note: When using on the following condition, the transmission of the general call address is prohibited because it cannot receive it as a slave. • When other LSI that becomes a mastering mode besides this LSI exists on the bus and this LSI transmits the general call address as a master and the arbitration lost is generated since the second byte. [bit11] ACK: ACKnowledge This bit is used to allow acknowledge generation when data is received. ACK Operation 0 No acknowledge generated. 1 Acknowledge generated. This bit is invalid if address data is received in slave mode. [bit10] GCAA: General Call Address Acknowledge This bit is used to enable acknowledge generation when a general call address (00H) is received. GCAA 542 Operation 0 No acknowledge generated. 1 Acknowledge generated. [bit9] INTE: INTerrupt Enable This bit is used to enable interrupts. INTE Operation 0 Interrupts prohibited. 1 Interrupts allowed. If this bit is set to "1" when the INT bit is set to "1", an interrupt is generated. [bit8] INT: INTerrupt This bit is used as a transfer end interrupt request flag. (During writing) INT Operation 0 Clears the transfer end interrupt request flag. 1 Not applicable. (During reading) INT Operation 0 Transfer has not ended. 1 This bit is set if the following conditions are met when one byte including an acknowledge bit is transferred: • Byte transferred in bus master transfer • Byte transferred in slave mode with addressing • General call address is received • Arbitration lost occurs • Attempt to generate a start condition while other systems use the bus. If this bit is "1", the SCL line is kept at the "L" level. This bit is cleared by writing "0" before the SCL line is opened for transfer of the next byte. Alternatively, this bit is reset to "0" if, in master mode, a start or stop condition is generated. 543 CHAPTER 26 I2C INTERFACE Notes: When an instruction which generates a start condition is executed (the MSS bit is set to 1) at the timing shown in Figure 26.3-8 and Figure 26.3-9, arbitration lost detection (AL bit = 1) prevents an interrupt (INT bit = 1) from being generated. • Condition 1 in which an interrupt (INT bit = 1) upon detection of " AL bit = 1 " does not occurs When an instruction which generates a start condition is executed (setting the MSS bit in the IBCR register to 1) with no start condition detected (BB bit = 0) and with the SDA or SCL pin at the " L " level. Figure 26.3-8 Diagram of Timing at which an Interrupt Upon Detection of "AL Bit = 1" does not Occur SCL or SDA pin at "L" level SCL pin 1 "L" SDA pin "L" I2C operating enable state (EN bit = 1) Master mode setting (MSS bit = 1) Arbitration lost detection (AL bit = 1) 544 Bus busy (BB bit ) 0 Interrupt (INT bit ) 0 • Condition 2 in which an interrupt (INT bit = 1) upon detection of " AL bit = 1 " does not occurs When an instruction which generates a start condition by enabling I2C operation (EN bit = 1) is executed (setting the MSS bit in the IBCR register to 1) with the I2C bus occupied by another master. This is because, as shown in Figure 26.3-9, when the other master on the I2C bus starts communication with I2C disabled (EN bit = 0), the I2C bus enters the occupied state with no start condition detected (BB bit = 0). Figure 26.3-9 Diagram of Timing at which an Interrupt Upon Detection of "AL Bit = 1" does not Occur Start condition The INT bit interrupt does not occur in the ninth clock cycle. Stop condition SCL pin SDA pin SLAVE ADDRESS ACK DAT ACK EN bit MSS bit AL bit BB bit 0 0 INT bit If a symptom as described above can occur, follow the procedure below for software processing. 1) Execute the instruction that generates a start condition (set the MSS bit to 1). 2) Use, for example, the timer function to wait for the time* for three - bit data transmission at the I2C transfer frequency set in the ICCR register. Example: Time for three - bit data transmission at an I2C transfer frequency of 100 kHz {1/(100 x 103)} x 3 = 30 μs 3) Check the AL and BB bits in the IBSR register and, if the AL and BB bits are 1 and 0, respectively, set the EN bit in the ICCR register to 0 to initialize I2C. When the AL and BB bits are not so, perform normal processing. 545 CHAPTER 26 I2C INTERFACE A sample flow is given below. Master mode setting Set the MSS bit in the bus control register (IBCR) to "1". Wait * for the time of three - bit data transmission at the I2C transfer frequency set in the clock control register (ICCR). NO BB bit = 0 and AL bit = 1 ? YES to normal process Set the EN bit to "0" to initialize I2C *: When "arbitration lost" is detected, the MSS bit is set to 1 and then the AL bit is set to 1 without fail after the time for three - bit data transmission at the I2C transfer frequency. • Example of occurrence for an interrupt (INT bit = 1) upon detection of "AL bit = 1" When an instruction which generates a start condition is executed (setting the MSS bit to 1) with "bus busy" detected (BB bit = 1) and arbitration is lost, the INT bit interrupt occurs upon detection of "AL bit = 1". Figure 26.3-10 Diagram of Timing at which an Interrupt Upon Detection of "AL Bit = 1" Occurs Start condition Interrupt in the ninth clock cycle SCL pin SDA pin SLAVE ADDRESS ACK DAT EN bit MSS bit AL bit BB bit INT bit 546 Clearing the AL bit by software Releasing the SCL by clearing the INT bit by software ■ Notes on Using the Bus Control Register (IBCR) Setting the SCC bit to "1" and the MSS bit to "0" at the same time is prohibited. Writing to the SCC, MSS, and INT bits at the same time will cause a conflict between transfer of the next byte and generation of start or stop conditions. In this case, the priority is specified as follows. ● Next byte transfer and stop condition generation If the INT and MSS bits are set to "0", setting of the MSS bit to "0" has priority and the stop condition is generated. ● Next byte transfer and start condition generation If the INT bit is set to "0" and the SCC bit is set to "1", setting of the SCC bit to "1" has priority and the start condition is generated. ● Start condition generation and stop condition generation Setting the SCC bit to "1" and the MSS bit to "0" at the same time is prohibited. 547 CHAPTER 26 I2C INTERFACE 26.3.3 Clock Control Register (ICCR) This section describes the configuration and functions of the clock control register (ICCR). ■ Clock Control Register (ICCR) The diagram below shows the bit configuration of the clock control register (ICCR). Figure 26.3-11 Bit Configuration of Clock Control Register (ICCR) Clock control register (ICCR) Address: bit7 bit6 - - EN CS4 CS3 CS2 CS1 CS0 - - R/W R/W R/W R/W R/W R/W 00008AH R/W: -: Readable/writable Undefined bit5 bit4 bit3 bit2 bit1 bit0 Initial value --0XXXXXB The functions of the clock control register (ICCR) are as follows. [bit7, bit6] Unused These bits are unused. [bit5] EN: ENable This bit is used to enable I2C interface operation. EN Operation 0 Operation disabled 1 Operation enabled • When this bit is set to "0", each bit of the IBSR register and the IBCR register (except for the BER and BEIE bits) is cleared. • Setting the BER bit clears this bit. [bit4 to bit0] CS4 to CS0: Clock Period Select 4 to 0 These bits are used to set the frequency of the serial clock. The shift clock frequency fsck is set in this register according to the following formula. The values for m and n must be as shown in Table 26.3-1 for CS4 to CS0. fsck = 548 φ m×n+4 φ: Machine clock Table 26.3-1 Serial Clock Frequency Settings m CS4 CS3 n CS2 CS1 CS0 5 0 0 4 0 0 0 6 0 1 8 0 0 1 7 1 0 16 0 1 0 8 1 1 32 0 1 1 64 1 0 0 128 1 0 1 256 1 1 0 512 1 1 1 Note: The "+ 4" cycle in the formula reflects the minimum overhead for checking whether the output level of the SCL pin has changed. If the rising edge of the SCL pin is delayed or a slave device delays the clock, the overhead increases. Do not set the serial clock frequency to 100 kHz or more. 549 CHAPTER 26 I2C INTERFACE 26.3.4 Address Register (IADR) This section describes the configuration and functions of the address register (IADR). ■ Address Register (IADR) The diagram below shows the bit configuration of the address register (IADR). Figure 26.3-12 Bit Configuration of Address Register (IADR) Address register (IADR) Address: 00008BH R/W: -: bit15 bit14 bit13 bit12 bit11 bit10 - Readable/writable Undefined A6 A5 A4 A3 A2 bit9 bit8 Initial value A1 A0 -XXXXXXXB R/W R/W R/W R/W R/W R/W R/W [bit14 to bit8] A6 to A0 These bits are a slave address bit and used as a register to specify the slave address. In slave mode, received address data is compared with the data in the IDAR register. If the data matches, the device transmits an acknowledge signal to the master. [bit15] Unused This bit is unused. 550 26.3.5 Data Register (IDAR) This section describes the configuration and functions of the data register (IDAR). ■ Data Register (IDAR) The diagram below shows the bit configuration of the data register (IDAR). Figure 26.3-13 Bit Configuration of Data Register (IDAR) Data register (IDAR) R/W: Address: bit7 bit6 bit5 00008CH D7 D6 D5 bit4 bit3 D4 D3 bit2 bit1 bit0 D2 D1 D0 Initial value XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W Readable/writable [bit7 to bit0] D7 to D0 These bits are used as data bits. These bits constitute a data register for serial transfer starting with the MSB. If data is received (TRX = 0), the data output value becomes "1". With respect to writing, this register consists of a double buffer. If the bus is active (BB = 1), write data is loaded into the register for serial transfer. When the register is directly read for serial transfer, note that the receive data is only valid if the INT bit of the IBCR register is set. 551 CHAPTER 26 I2C INTERFACE 26.4 Interrupt of I2C Interface The interrupt of I2C interface occurs when the transfer of data is terminated. ■ Interrupt Control Bit and Interrupt Source of I2C Interface The interrupt control bit and interrupt source of I2C interface is shown in the following table. Table 26.4-1 Interrupt Control Bit and Interrupt Source of I2C Interface I2C interrupt Interrupt request flag IBCR:INT (bit8) Interrupt request output enable bit IBCR:INTE (bit9) Interrupt generation source End of I2C transfer ■ Interrupt Source of I2C Interface Only one interrupt source is provided on the I2C bus. The interrupt generates if the interrupt conditions are met when 1 byte transfer is terminated. Each flag must be checked in the interrupt routine because multiple interrupt conditions are determined using one interrupt. The interrupt conditions at termination of 1 byte transfer are shown as follows. • Byte transferred in bus master transfer • Byte transferred in slave mode with addressing • General call address is received • Arbitration lost occurs 552 ■ Interrupt of I2C Interface, DMA Transfer, and EI2OS Table 26.4-2 shows the relationship between the interrupt source, interrupt vector, and interrupt control register other than software interrupt. Table 26.4-2 Interrupt Source, Interrupt Vector, and Interrupt Control Register Interrupt source I2C interface * EI2OS clear μDMAC channel number Number Address Number Address × × #39 FFFF60H ICR14 0000BEH Interrupt vector Interrupt control register × : Interrupt request flag is not cleared. * : This interrupt source shares the interrupt source and interrupt number of other peripheral function. For details, see Table 4.2-2. Note: If there are two interrupt sources in the same interrupt number, resource clears both interrupt request flags. Therefore, when one of two sources uses the EI2OS/μDMAC function, the other interrupt function cannot use. The interrupt request enable bit of the relevant resource is set to "0" to execute the software polling processing. ■ Correspondence to DMA Transfer and EI2OS Function The I2C interface does not correspond to the DMA transfer function and EI2OS function. 553 CHAPTER 26 I2C INTERFACE 26.5 I2C Interface Operation The I2C bus performs communication using two bidirectional bus lines that consist of one serial data line (SDA) and one serial clock line (SCL). The I2C interface has instead two open drain input/output pins (SDA, SCL) that allow hard-wired logic to be used. ■ Start Condition If the bus is open (BB = 0, MSS = 0) and the MSS bit is set to "1", the I2C interface enters master mode and the start condition is generated as well. Even if the bus is active (BB = 1) in master mode, the start condition will be generated again if the SCC bit is set to "1". There are two ways to generate the start condition: • In the state where the bus is not used (MSS = 0 & BB = 0 & INT = 0 & AL = 0), setting of the MSS bit to "1" • In interrupt state and bus master mode (MSS = 1 & BB = 1 & INT = 1 & AL = 0), setting of the SCC bit to "1" If the MSS bit is set to "1" when another system uses the bus (in idle state), the AL bit is set to "1". In states other than the above, setting the MSS bit and SCC bit to "1" is ignored. ■ Stop Condition If the MSS bit is set to "0" in master mode (MSS = 1), a stop condition is generated and the devices enter slave mode. A stop condition is generated when the following conditions exist: • If the MSS bit is set to "0" in bus master mode and in interrupt state (MSS = 1 & BB = 1 & INT = 1 & AL = 0). In the other modes, setting the MSS bit to "0" is ignored. ■ Addressing If, in master mode, a start condition is generated by setting BB = 1 and TRX = 1, the contents of the IDAR register are output starting with the MSB. When, after the address data has been transmitted, acknowledge is received from the slave, the TRX bit is set to the opposite value of bit0 for the transmitted data (IDAR register: bit0 after transmission). In slave mode, after a start condition is generated by setting BB = 1 and TRX = 0, transmitted data from the master is received in the IDAR register. After the address data has been received, the IDAR register and IADR register are compared. If the contents of these registers match, AAS is set to "1", and acknowledge is transmitted to the master. Next, the TRX bit is set to the same value as bit0 of the received data (IDAR register: bit0 after reception). ■ Arbitration If, when a master transmits, another master transmits data at the same time, arbitration occurs. If the signal of the locally transmitted data represents "1" and the data on the SDA line is represented by the "L" level, AL is set to "1" on the assumption that local arbitration is lost. As previously described, AL is set to "1" when a start condition occurs, even though the bus is active at the time. Setting AL to "1" results in MSS = 0 and TRX = 0, and the device enters slave reception mode. 554 ■ Acknowledge Acknowledge is transmitted from the receiving side to the transmitting side. The ACK bit is used to represent an acknowledge upon data reception. If data is transmitted, an acknowledge from the receive side is stored in the LRB bit. If no acknowledge is received from the master side (receiving device) after reception from the slave (transmitting side), the TRX bit is set to "0" and the device enters slave reception state. The master device will in this case generate a stop condition when the slave opens the SCL line. ■ Bus Error If the following conditions are satisfied, it can be assumed that a bus error occurred, and the I2C interface will enter stop mode. • If an I2C bus basic standard violation is detected in data transfer mode (when an ACK bit is included). • If a stop condition is detected in master mode • If an I2C bus basic standard violation is detected in bus idle mode. ■ Other Considerations ● Processing after arbitration lost is detected When arbitration lost is detected, the software has to determine whether local addressing was applied. If arbitration lost occurs, the device enters slave mode on the hardware level, and after 1-byte transfer has been completed, both the CLK line and DATA line are set to "L" level. Consequently, without proper addressing, both the CLK line and DATA line will be immediately opened. With addressing, slave transmission or slave reception will have been set up before the CLK line and DATA line are opened (all of these preparations must be performed by software). ● Interrupt sources when arbitration lost is detected If arbitration lost is detected, an interrupt source is not generated immediately, but only after the transfer of one byte is completed. If arbitration lost is detected, the device enters slave mode on the hardware level. Even if this occurs in slave mode, a total of nine clocks will be output before the interrupt source is generated. Since interrupt sources are not generated immediately, no interrupt processing is performed after arbitration lost occurs. 555 CHAPTER 26 I2C INTERFACE ● Interrupt conditions There is only one interrupt that can be generated related to the I2C bus. The interrupt source is generated either after the end of the transfer for one byte, or because another predefined interrupt condition was met. Since there is only one interrupt, which of multiple interrupt conditions responsible for the interrupt must be identified by checking flags in the interrupt routine. Possible interrupt conditions after transfer of one byte has been performed are listed below. • Interrupt in bus master mode • Interrupt during slave mode with addressing • Interrupt after a general call address is received • "Arbitration lost" occurred ● Transfer speed Note that the maximum transfer speed of the I2C bus is 100 kHz (the frequency of the serial clock). 556 APPENDIX The appendix provides the memory map and lists the instructions used in the F2MC-16LX. APPENDIX A Memory Map APPENDIX B I/O Map APPENDIX C Interrupt Source, Interrupt Vector, and Interrupt Control Register APPENDIX D Instructions 557 APPENDIX APPENDIX A Memory Map Memory space is divided according to three usage modes. ■ Memory Space The memory space is divided according to three usage modes shown in Figure A-1. Figure A-1 Memory Map Single chip FFFFFFH ROM area Address #1 FC0000H 010000H ROM area, Image of bank FF Address #2 Address #3 RAM Register 000100H 0000D0H Peripheral 000000H : Internal : No access Note :There is no external area available for product type for which address #3 and address #2 overlap. Table A-1 shows the relationship among address #1, address #2, and address #3 for each product type. 558 APPENDIX A Memory Map Table A-1 Relationship Among address #1, address #2, and address #3 by Product Type Type Address #1 MB90F983 FC0000H*1 MB90982 FD0000H*2 Address #2 The MS bit of the ROMM register can be used to select 004000H or 008000H. Address #3 003100H 002900H *1 : Memory cell is not available at FC0000H to FC7FFFH and FE0000H to FE7FFFH. *2 : Memory cell is not available at FE0000H to FEFFFFH. In MB90F983 model, the ROM contents of bank FF (between FC0000H and FC7FFFH or between FE0000H and FE7FFFH) can be viewed as an image in the upper part of bank 00, allowing the C compiler's small model to be more efficiently utilized. Because the lower 16-bit address of bank FF and that of bank 00 are identical, pointer declarations do not require the "far" specification to refer the table in ROM. For example, an access to 00C000H will actually be performed as access to the ROM contents at FFC000H. However, because the ROM area in bank FF exceeds 48 KB if the MS bit of the ROMM register is set to 0, not all of the areas can be viewed via their image in bank 00. For this reason, an image of the area from FF4000H to FFFFFFH can be seen in bank 00, while an image of the area from FF0000H to FF3FFFH can only be viewed via bank FF. 559 APPENDIX APPENDIX B I/O Map Table B-1 shows the addresses assigned to the registers for each peripheral function. ■ I/O Map Table B-1 shows the addresses assigned to the registers for each peripheral function. Table B-1 I/O Map (1 / 8) Address Register 000000H, 000001H Abbreviation Access Resource Initial value (Reserved area) 000002H Port 2 data register PDR2 R/W Port 2 XXXXXXXXB 000003H Port 3 data register PDR3 R/W Port 3 XXXXXXXXB 000004H Port 4 data register PDR4 R/W Port 4 XXXXXXXXB 000005H (Reserved area) 000006H Port 6 data register PDR6 R/W Port 6 XXXXXXXXB 000007H Port 7 data register PDR7 R/W Port 7 11XXXXXXB 000008H Port 8 data register PDR8 R/W Port 8 XXXXXXXXB 000009H Port 9 data register PDR9 R/W Port 9 XXXXXXXXB 00000AH Port A data register PDRA R/W Port A - - - - XXXXB 00000BH Up/down timer input enable register UDER R/W Up/down timer input control XX 0 0 0 0 0 0B 00000CH Interrupt/DTP enable register ENIR R/W 00000DH Interrupt/DTP source register EIRR R/W 00000EH Request level setting register R/W 0 0 0 0 0 0 0 0B DTP/external interrupts XXXXXXXXB 0 0 0 0 0 0 0 0B ELVR 00000FH Request level setting register 000010H, 000011H 0 0 0 0 0 0 0 0B R/W (Reserved area) 000012H Port 2 direction register DDR2 R/W Port 2 0 0 0 0 XXXXB 000013H Port 3 direction register DDR3 R/W Port 3 0 0 0 0 0 0 0 0B 000014H Port 4 direction register DDR4 R/W Port 4 0 0 0 0 0 0 0 0B 000015H (Reserved area) 000016H Port 6 direction register DDR6 R/W Port 6 0 0 0 0 0 0 0 0B 000017H Port 7 direction register DDR7 R/W Port 7 XXX 0 0 0 0 0B 560 APPENDIX B I/O Map Table B-1 I/O Map (2 / 8) Address Register Abbreviation Access Resource Initial value 000018H Port 8 direction register DDR8 R/W Port 8 0 0 0 0 0 0 0 0B 000019H Port 9 direction register DDR9 R/W Port 9 0 0 XX 0 0 0 0B 00001AH Port A direction register DDRA R/W Port A - - - - 0 0 0 0B 00001BH Port 4 output pin register ODR4 R/W Port 4 (Open-drain control) XXXXX 0 0 0B 00001CH, 00001DH (Reserved area) 00001EH Port 7 output pin register ODR7 R/W Port 7 (Open-drain control) XXX0 0 0 0 0B 00001FH Analog input enable register ADER R/W Port 6, A/D 1 1 1 1 1 1 1 1B 000020H Serial mode register SMR R/W 000021H Serial control register SCR W, R/W 0 0 0 0 0 X 0 0B 0 0 0 0 0 1 0 0B UART 000022H Serial input/output register 000023H Serial status register 000024H SIDR/ SODR R/W XXXXXXXXB SSR R, R/W 0 0 0 0 1 0 0 0B (Reserved area) 000025H Communication prescaler control register CDCR R/W 000026H Serial mode control status register 0 SMCS0 R, R/W 000027H Serial mode control status register 0 SMCS0 R, R/W 000028H Serial data register 0 SDR0 R/W 000029H Communication prescaler control register 0 SDCR0 R/W 00002AH Serial mode control status register 1 SMCS1 R, R/W 00002BH Serial mode control status register 1 SMCS1 R, R/W 00002CH Serial data register 1 SDR1 R/W 00002DH Communication prescaler control register 1 SDCR1 R/W Communication prescaler (UART) 0 0 -- 0 0 0 0B - - - - 0 0 0 0B SIO1 (ch.0) 0 0 0 0 0 0 1 0B XXXXXXXXB Communication prescaler SIO1 (ch.0) 0 - - - 0 0 0 0B - - - - 0 0 0 0B SIO2 (ch.1) 0 0 0 0 0 0 1 0B XXXXXXXXB Communication prescaler SIO2 (ch.1) 0 - - - 0 0 0 0B 561 APPENDIX Table B-1 I/O Map (3 / 8) Address Register Abbreviation Access Resource Initial value 00002EH Reload register L (ch.0) PRLL0 R/W XXXXXXXXB 00002FH Reload register H (ch.0) PRLH0 R/W XXXXXXXXB 000030H Reload register L (ch.1) PRLL1 R/W XXXXXXXXB 000031H Reload resister H (ch.1) PRLH1 R/W 000032H Reload register L (ch.2) PRLL2 R/W 000033H Reload register H (ch.2) PRLH2 R/W XXXXXXXXB 000034H Reload register L (ch.3) PRLL3 R/W XXXXXXXXB 000035H Reload register H (ch.3) PRLH3 R/W XXXXXXXXB 000036H to 000039H PPG0 operating mode control register PPGC0 R/W 00003BH PPG1 operating mode control register PPGC1 R/W 00003CH PPG2 operating mode control register PPGC2 R/W 00003DH PPG3 operating mode control register PPGC3 R/W 00003EH, 00003FH XXXXXXXXB 0 X 0 0 0XX 1B 8/16-bit PPG (ch.0 to ch.3) 0 X 0 0 0 0 0 1B 0 X 0 0 0XX 1B 0 X 0 0 0 0 0 1B (Reserved area) PPG0, PPG1 output control register 000041H 000042H XXXXXXXXB (Reserved area) 00003AH 000040H 8/16-bit PPG (ch.0 to ch.3) PPG01 R/W 8/16-bit PPG 0 0 0 0 0 0 0 0B 8/16-bit PPG 0 0 0 0 0 0 0 0B (Reserved area) PPG2, PPG3 output control register PPG23 R/W 000043H (Reserved area) 000044H, 000045H (Reserved area) 000046H ADCS1 R/W ADCS2 W, R/W 0 0 0 0 0 0 0 0B Control status register 000047H 0 0 0 0 0 0 0 0B A/D converter 000048H ADCR1 R XXXXXXXXB ADCR2 W, R 0 0 0 0 0 XXXB Data register 000049H 562 APPENDIX B I/O Map Table B-1 I/O Map (4 / 8) Address 00004AH Register Abbreviation Access OCCP0 R/W Output compare register (ch.0) upper digits 00004CH Output compare register (ch.1) lower digits 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B OCCP1 00004DH Output compare register (ch.1) upper dig-its 00004EH Output compare register (ch.2) lower digits OCCP2 00004FH Output compare register (ch.2) upper digits 000050H Output compare register (ch.3) lower digits R/W R/W 16-bit input/output timer output compare (ch.0 to ch.3) 0 0 0 0 0 0 0 0B 00000000B 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B OCCP3 R/W 0 0 0 0 0 0 0 0B Output compare register (ch.3) upper digits 000052H to 000055H Initial value 0 0 0 0 0 0 0 0B Output compare register (ch.0) lower digits 00004BH 000051H Resource (Reserved area) 000056H Output compare control register (ch.0, ch.1) lower digits 000057H Output compare control register (ch.0, ch.1) upper digits R/W 000058H Output compare control register (ch.2, ch.3) lower digits R/W 000059H Output compare control register (ch.2, ch.3) upper digits 0 0 0 0 - - 0 0B R/W OCS01 16-bit input/output timer output compare (ch.0 to ch.3) - - - 0 0 0 0 0B 0 0 0 0 - - 0 0B OCS23 00005AH, 00005BH 00005CH - - - 0 0 0 0 0B R/W (Reserved area) Input capture data register (ch.0) lower digits XXXXXXXXB R IPCP0 00005DH 00005EH Input capture data register (ch.0) upper digits Input capture data register (ch.1) lower digits R IPCP1 00005FH Input capture data register (ch.1) upper digits 000060H Input capture control status register 000061H XXXXXXXXB R ICS01 16-bit input/output timer input capture (ch.0, ch.1) XXXXXXXXB R XXXXXXXXB R/W 0 0 0 0 0 0 0 0B (Reserved area) 000062H Timer counter data register lower digits TCDT R/W 0 0 0 0 0 0 0 0B 000063H Timer counter data register upper digits TCDT R/W 0 0 0 0 0 0 0 0B 000064H Timer counter control status register TCCS R/W 000065H Timer counter control status register TCCS R/W 000066H Compare clear register lower digits CPCLR R/W 000067H Compare clear register upper digits 16-bit input/output timer free run timer 0 0 0 0 0 0 0 0B 0 - - 0 0 0 0 0B XXXXXXXXB XXXXXXXXB 563 APPENDIX Table B-1 I/O Map (5 / 8) Address Register Abbreviation Access Resource Initial value 000068H Up/down count register (ch.0) UDCR0 R 0 0 0 0 0 0 0 0B 000069H Up/down count register (ch.1) UDCR1 R 0 0 0 0 0 0 0 0B 00006AH Reload/compare register (ch.0) RCR0 W 00006BH Reload/compare register (ch.1) RCR1 W 00006CH Counter control register (ch.0) lower digits CCRL0 W, R/W 0 X 0 0 X 0 0 0B 00006DH Counter control register (ch.0) upper digits CCRH0 R/W 0 0 0 0 0 0 0 0B 00006EH 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B (Reserved area) 00006FH ROM mirror function select register ROMM R/W 000070H Counter control register (ch.1) lower digits CCRL1 R/W 000071H Counter control register (ch.1) upper digits CCRH1 R/W 000072H Counter status register (ch.0) CSR0 R/W 000073H 000074H 8/16-bit up/down timer counter ROM mirroring function ------01B 0 X 0 0 X 0 0 0B 8/16-bit up/down counter/timer - 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B (Reserved area) Counter status register (ch.1) 000075H CSR1 R, R/W 8/16-bit up/down counter/timer 0 0 0 0 0 0 0 0B (Reserved area) 000076H 0 0 0 0 0 0 0 0B PWC control/status register PWCSR0 R, R/W 000077H 0 0 0 0 0 0 0 XB PWC timer (ch.0) 000078H 0 0 0 0 0 0 0 0B PWC data buffer register PWCR0 R/W 000079H 0 0 0 0 0 0 0 0B 00007AH 0 0 0 0 0 0 0 0B PWC control/status register PWCSR1 R, R/W 00007BH 0 0 0 0 0 0 0 XB PWC timer (ch.1) 00007CH 0 0 0 0 0 0 0 0B PWC data buffer register PWCR1 R/W 00007DH 0 0 0 0 0 0 0 0B 00007EH to 000081H 000082H (Reserved area) Dividing ratio control register 000083H 000084H 000085H to 000087H 564 DIVR0 R/W PWC (ch.0) - - -- - - 0 0B PWC (ch.1) - - -- - - 0 0B (Reserved area) Dividing ratio control register DIVR1 R/W (Reserved area) APPENDIX B I/O Map Table B-1 I/O Map (6 / 8) Address Register Abbreviation Access Resource Initial value 000088H Bus status register IBSR R 0 0 0 0 0 0 0 0B 000089H Bus control register IBCR R/W 0 0 0 0 0 0 0 0B 00008AH Clock control register ICCR R/W 00008BH Address register IADR R/W - X X X X X X XB 00008CH Data register IDAR R/W XXXXXXXXB 00008DH, 00008EH (Reserved area) 00008FH to 00009BH (Disabled) I2C -- 0 X X X X XB 00009CH μDMAC status register DSRL R/W μDMAC 0 0 0 0 0 0 0 0B 00009DH μDMAC status register DSRH R/W μDMAC 0 0 0 0 0 0 0 0B 00009EH Program address detection control status resister PACSR R/W Address match detection function 0 0 0 0 0 0 0 0B 00009FH Delay interrupt source generate/ cancel register DIRR R/W Delay interrupt generation module - - - - --- 0B 0000A0H Low-power consumption mode control register LPMCR W, R/W Low-power consumption 0 0 0 1 1 0 0 0B 0000A1H Clock select register CKSCR R, R/W Low-power consumption 1 1 1 1 1 1 0 0B μDMAC 0 0 0 0 0 0 0 0B 0000A2H, 0000A3H 0000A4H (Reserved area) μDMAC stop status register 0000A5H to 0000A7H DSSR R/W (Reserved area) 0000A8H Watchdog timer control register WDTC R, W Watchdog timer XXXXX 1 1 1B 0000A9H Time-base timer control register TBTC W, R/W Time-base timer 1 X X 0 0 1 0 0B 0000AAH Watch timer control register WTC R, R/W Watch timer 1 0 0 0 1 0 0 0B 0000ABH (Reserved area) 0000ACH μDMAC enable register DERL R/W μDMAC 0 0 0 0 0 0 0 0B 0000ADH μDMAC enable register DERH R/W μDMAC 0 0 0 0 0 0 0 0B 0000AEH Flash memory control status register FMCS W, R/W Flash memory I/F 0 0 0 X 0 0 0 0B 0000AFH (Disabled) 565 APPENDIX Table B-1 I/O Map (7 / 8) Address Register Abbreviation Access 0000B0H Resource Initial value Interrupt control register 00 ICR00 W, R/W X X X X 0 1 1 1B 0000B1H Interrupt control register 01 ICR01 W, R/W X X X X 0 1 1 1B 0000B2H Interrupt control register 02 ICR02 W, R/W X X X X 0 1 1 1B 0000B3H Interrupt control register 03 ICR03 W, R/W X X X X 0 1 1 1B 0000B4H Interrupt control register 04 ICR04 W, R/W X X X X 0 1 1 1B 0000B5H Interrupt control register 05 ICR05 W, R/W X X X X 0 1 1 1B 0000B6H Interrupt control register 06 ICR06 W, R/W X X X X 0 1 1 1B 0000B7H interrupt control register 07 ICR07 W, R/W X X X X 0 1 1 1B Interrupt controller 0000B8H Interrupt control register 08 ICR08 W, R/W X X X X 0 1 1 1B 0000B9H Interrupt control register 09 ICR09 W, R/W X X X X 0 1 1 1B 0000BAH Interrupt control register 10 ICR10 W, R/W X X X X 0 1 1 1B 0000BBH Interrupt control register 11 ICR11 W, R/W X X X X 0 1 1 1B 0000BCH Interrupt control register 12 ICR12 W, R/W X X X X 0 1 1 1B 0000BDH Interrupt control register 13 ICR13 W, R/W X X X X 0 1 1 1B 0000BEH Interrupt control register 14 ICR14 W, R/W X X X X 0 1 1 1B 0000BFH Interrupt control register 15 ICR15 W, R/W X X X X 0 1 1 1B 0000C0H to 0000C9H (Reserved area) 0 0 0 0 0 0 0 0B 0000CAH Timer control status register TMCSR R/W 0000CBH - - - - 0 0 0 0B 16-bit reload timer 0000CCH 16-bit timer register/ 16-bit reload register 0000CDH 0000CEH 0000CFH TMR/ TMRLR (Reserved area) PLL output selection register PLLOS W 0000D0H to 0000FFH (External area) 000100H to #H (RAM area) 566 XXXXXXXXB R/W Low-power consumption - - - - - - 0 0B APPENDIX B I/O Map Table B-1 I/O Map (8 / 8) Address Register 001FF0H Program address detection resister 0 (Low order address) 001FF1H Program address detection resister 0 (Middle order address) 001FF2H Program address detection resister 0 (High order address) 001FF3H Program address detection resister 1 (Low order address) 001FF4H Program address detection resister 1 (Middle order address) 001FF5H Program address detection resister 1 (High order address) Abbreviation Access Resource Initial value PADR0 R/W Address match detection function XXXXXXXXB PADR1 R/W Address match detection function XXXXXXXXB Note: Descriptions for access R/W : Readable and writable R : Read only W : Write only Descriptions for initial value 0 : The initial value of this bit is "0". 1 : The initial value of this bit is "1". X : The initial value of this bit is undefined. - : This bit is not used. 567 APPENDIX APPENDIX C Interrupt Source, Interrupt Vector, and Interrupt Control Register Table C-1 shows the relationship between interrupt sources and the interrupt vector/ interrupt control registers. ■ Interrupt Sources, Interrupt Vectors, and Interrupt Control Registers Table C-1 Relationship Between Interrupt Sources and Interrupt Vector/Interrupt Control Registers (1 / 2) μDMAC channel number Number Address Number Address Reset - #08 FFFFDCH - - INT9 instruction - #09 FFFFD8H - - Exception - #10 FFFFD4H - - INT0 0 #11 FFFFD0H × ICR00 0000B0H INT1 #12 FFFFCCH INT2 × #13 FFFFC8H × ICR01 0000B1H INT3 #14 FFFFC4H INT4 × #15 FFFFC0H × ICR02 0000B2H INT5 #16 FFFFBCH INT6 × #17 FFFFB8H × ICR03 0000B3H INT7 #18 FFFFB4H PWC1 × #19 FFFFB0H − ICR04 0000B4H - #20 FFFFACH PWC0 × #21 FFFFA8H ICR05 0000B5H PPG0/PPG1 counter borrow 2 #22 FFFFA4H PPG2/PPG3 counter borrow 3 #23 FFFFA0H ICR06 0000B6H - - #24 FFFF9CH 8/16-bit up/down counter timer compare/underflow/ overflow/up-down reverse (ch.0, ch.1) × #25 FFFF98H ICR07 0000B7H ICR08 0000B8H Interrupt source 568 Interrupt vector Input capture (ch.0) load 5 #26 FFFF94H Input capture (ch.1) load 6 #27 FFFF90H Output compare (ch.0) match 8 #28 FFFF8CH Interrupt control register APPENDIX C Interrupt Source, Interrupt Vector, and Interrupt Control Register Table C-1 Relationship Between Interrupt Sources and Interrupt Vector/Interrupt Control Registers (2 / 2) μDMAC channel number Number Address Output compare (ch.1) match 9 #29 FFFF88H Output compare (ch.2) match 10 #30 FFFF84H Output compare (ch.3) match × #31 FFFF80H - − #32 FFFF7CH - − #33 FFFF78H UART transmit completed 11 #34 FFFF74H 16-bit free-run timer/16-bit reload timer overflow 12 #35 FFFF70H UART receive completed 7 #36 FFFF6CH SIO1 13 #37 FFFF68H SIO2 14 #38 FFFF64H I2C interface × #39 FFFF60H A/D 15 #40 FFFF5CH FLASH write/delete, time-base timer/watch timer * × #41 FFFF58H Delay interrupt generate module × #42 FFFF54H Interrupt source Interrupt vector Interrupt control register Number Address ICR09 0000B9H ICR10 0000BAH ICR11 0000BBH ICR12 0000BCH ICR13 0000BDH ICR14 0000BEH ICR15 0000BFH * : Make sure that FLASH write/delete operations are not used during operation of the time-base timer and watch timer. ×: The interrupt request can not be cleared by the interrupt clear signal. Note: If the same interrupt number is assigned to two interrupt sources, the resource is cleared only if both interrupt request flags are cleared by DMA interrupt clear signals. Therefore, if either of two interrupt functions uses the DMA function, the other interrupt function cannot be used. Set the relevant resource's interrupt request enable bit to "0" and use software polling processing to handle this situation. 569 APPENDIX APPENDIX D Instructions APPENDIX D describes the instructions used by the F2MC-16LX. D.1 Instruction Types D.2 Addressing D.3 Direct Addressing D.4 Indirect Addressing D.5 Execution Cycle Count D.6 Effective address field D.7 How to Read the Instruction List D.8 F2MC-16LX Instruction List D.9 Instruction Map Code: CM44-00202-1E 570 APPENDIX D Instructions D.1 Instruction Types The F2MC-16LX supports 351 types of instructions. Addressing is enabled by using an effective address field of each instruction or using the instruction code itself. ■ Instruction Types The F2MC-16LX supports the following 351 types of instructions: • 41 transfer instructions (byte) • 38 transfer instructions (word or long word) • 42 addition/subtraction instructions (byte, word, or long word) • 12 increment/decrement instructions (byte, word, or long word) • 11 comparison instructions (byte, word, or long word) • 11 unsigned multiplication/division instructions (word or long word) • 11 signed multiplication/division instructions (word or long word) • 39 logic instructions (byte or word) • 6 logic instructions (long word) • 6 sign inversion instructions (byte or word) • 1 normalization instruction (long word) • 18 shift instructions (byte, word, or long word) • 50 branch instructions • 6 accumulator operation instructions (byte or word) • 28 other control instructions (byte, word, or long word) • 21 bit operation instructions • 10 string instructions 571 APPENDIX D.2 Addressing With the F2MC-16LX, the address format is determined by the instruction effective address field or the instruction code itself (implied). When the address format is determined by the instruction code itself, specify an address in accordance with the instruction code used. Some instructions permit the user to select several types of addressing. ■ Addressing The F2MC-16LX supports the following 23 types of addressing: 572 • Immediate (#imm) • Register direct • Direct branch address (addr16) • Physical direct branch address (addr24) • I/O direct (io) • Abbreviated direct address (dir) • Direct address (addr16) • I/O direct bit address (io:bp) • Abbreviated direct bit address (dir:bp) • Direct bit address (addr16:bp) • Vector address (#vct) • Register indirect (@RWj j = 0 to 3) • Register indirect with post increment (@RWj+ j = 0 to 3) • Register indirect with displacement (@RWi + disp8 i = 0 to 7, @RWj + disp16 j = 0 to 3) • Long register indirect with displacement (@RLi + disp8 i = 0 to 3) • Program counter indirect with displacement (@PC + disp16) • Register indirect with base index (@RW0 + RW7, @RW1 + RW7) • Program counter relative branch address (rel) • Register list (rlst) • Accumulator indirect (@A) • Accumulator indirect branch address (@A) • Indirectly-specified branch address (@ear) • Indirectly-specified branch address (@eam) APPENDIX D Instructions ■ Effective Address Field Table D.2-1 lists the address formats specified by the effective address field. Table D.2-1 Effective Address Field Code Representation 00 R0 RW0 RL0 01 R1 RW1 (RL0) 02 R2 RW2 RL1 03 R3 RW3 (RL1) 04 R4 RW4 RL2 05 R5 RW5 (RL2) 06 R6 RW6 RL3 07 R7 RW7 (RL3) 08 @RW0 09 @RW1 Address format Default bank Register direct: Individual parts correspond to the byte, word, and long word types in order from the left. None DTB DTB Register indirect 0A @RW2 ADB 0B @RW3 SPB 0C @RW0+ DTB 0D @RW1+ DTB Register indirect with post increment 0E @RW2+ ADB 0F @RW3+ SPB 10 @RW0+disp8 DTB 11 @RW1+disp8 DTB Register indirect with 8-bit displacement 12 @RW2+disp8 ADB 13 @RW3+disp8 SPB 14 @RW4+disp8 DTB 15 @RW5+disp8 DTB Register indirect with 8-bit displacement 16 @RW6+disp8 ADB 17 @RW7+disp8 SPB 18 @RW0+disp16 DTB 19 @RW1+disp16 DTB Register indirect with 16-bit displacement 1A @RW2+disp16 ADB 1B @RW3+disp16 SPB 1C @RW0+RW7 Register indirect with index DTB 1D @RW1+RW7 Register indirect with index DTB 1E @PC+disp16 PC indirect with 16-bit displacement PCB 1F addr16 Direct address DTB 573 APPENDIX D.3 Direct Addressing An operand value, register, or address is specified explicitly in direct addressing mode. ■ Direct Addressing ● Immediate addressing (#imm) Specify an operand value explicitly (#imm4/ #imm8/ #imm16/ #imm32). Figure D.3-1 Example of Immediate Addressing (#imm) MOVW A, #01212H (This instruction stores the operand value in A.) Before execution A 2233 4455 After execution A 4455 1 2 1 2 (Some instructions transfer AL to AH.) ● Register direct addressing Specify a register explicitly as an operand. Table D.3-1 lists the registers that can be specified. Figure D.3-2 shows an example of register direct addressing. Table D.3-1 Direct Addressing Registers General-purpose register Special-purpose register Byte R0, R1, R2, R3, R4, R5, R6, R7 Word RW0, RW1, RW2, RW3, RW4, RW5, RW6, RW7 Long word RL0, RL1, RL2, RL3 Accumulator A, AL Pointer SP * Bank PCB, DTB, USB, SSB, ADB Page DPR Control PS, CCR, RP, ILM *: One of the user stack pointer (USP) and system stack pointer (SSP) is selected and used depending on the value of the S flag bit in the condition code register (CCR). For branch instructions, the program counter (PC) is not specified in an instruction operand but is specified implicitly. 574 APPENDIX D Instructions Figure D.3-2 Example of Register Direct Addressing MOV R0, A (This instruction transfers the eight low-order bits of A to the generalpurpose register R0.) Before execution A 0716 2534 Memory space R0 After execution A 0716 2564 ?? Memory space R0 34 ● Direct branch addressing (addr16) Specify an offset explicitly for the branch destination address. The size of the offset is 16 bits, which indicates the branch destination in the logical address space. Direct branch addressing is used for an unconditional branch, subroutine call, or software interrupt instruction. Bit23 to bit16 of the address are specified by the program counter bank register (PCB). Figure D.3-3 Example of Direct Branch Addressing (addr16) JMP 3B20H (This instruction causes an unconditional branch by direct branch addressing in a bank.) Before execution After execution PC 3 C 2 0 PC 3 B 2 0 PCB 4 F PCB 4 F Memory space 4F3B20H Next instruction 4F3C20H 62 4F3C21H 20 4F3C22H 3B JMP 3B20H 575 APPENDIX ● Physical direct branch addressing (addr24) Specify an offset explicitly for the branch destination address. The size of the offset is 24 bits. Physical direct branch addressing is used for unconditional branch, subroutine call, or software interrupt instruction. Figure D.3-4 Example of Direct Branch Addressing (addr24) JMPP 333B20H (This instruction causes an unconditional branch by direct branch 24-bit addressing.) Before execution After execution PC 3 C 2 0 PC 3 B 2 0 PCB 4 F PCB 3 3 Memory space 333B20H Next instruction 4F3C20H 63 4F3C21H 20 4F3C22H 3B 4F3C23H 33 JMPP 333B20H ● I/O direct addressing (io) Specify an 8-bit offset explicitly for the memory address in an operand. The I/O address space in the physical address space from 000000H to 0000FFH is accessed regardless of the data bank register (DTB) and direct page register (DPR). A bank select prefix for bank addressing is invalid if specified before an instruction using I/O direct addressing. Figure D.3-5 Example of I/O Direct Addressing (io) MOVW A, i : 0C0H (This instruction reads data by I/O direct addressing and stores it in A.) Before execution After execution 576 A 0716 2534 A 2534 FFEE Memory space 0000C0H EE 0000C1H FF APPENDIX D Instructions ● Abbreviated direct addressing (dir) Specify the eight low-order bits of a memory address explicitly in an operand. Address bits 8 to 15 are specified by the direct page register (DPR). Address bits 16 to 23 are specified by the data bank register (DTB). Figure D.3-6 Example of Abbreviated Direct Addressing (dir) MOV S : 20H, A (This instruction writes the contents of the eight low-order bits of A in abbreviated direct addressing mode.) Before execution A 4455 DPR 6 6 After execution A 4455 DPR 6 6 1212 DTB 7 7 Memory space 776620H 1212 DTB 7 7 ?? Memory space 776620H 12 ● Direct addressing (addr16) Specify the 16 low-order bits of a memory address explicitly in an operand. Address bits 16 to 23 are specified by the data bank register (DTB). A prefix instruction for access space addressing is invalid for this mode of addressing. Figure D.3-7 Example of Direct Addressing (addr16) MOVW A, 3B20H (This instruction reads data by direct addressing and stores it in A.) Before execution After execution A 2020 A AABB AABB 0123 DTB 5 5 Memory space 553B21H 01 553B20H 23 DTB 5 5 577 APPENDIX ● I/O direct bit addressing (io:bp) Specify bits in physical addresses 000000H to 0000FFH explicitly. Bit positions are indicated by ":bp", where the larger number indicates the most significant bit (MSB) and the lower number indicates the least significant bit (LSB). Figure D.3-8 Example of I/O Direct Bit Addressing (io:bp) SETB i : 0C1H : 0 (This instruction sets bits by I/O direct bit addressing.) Memory space Before execution 0000C1H 00 Memory space After execution 0000C1H 01 ● Abbreviated direct bit addressing (dir:bp) Specify the eight low-order bits of a memory address explicitly in an operand. Address bits 8 to 15 are specified by the direct page register (DPR). Address bits 16 to 23 are specified by the data bank register (DTB). Bit positions are indicated by ":bp", where the larger number indicates the most significant bit (MSB) and the lower number indicates the least significant bit (LSB). Figure D.3-9 Example of Abbreviated Direct Bit Addressing (dir:bp) SETB S : 10H : 0 (This instruction sets bits by abbreviated direct bit addressing.) Memory space Before execution DTB 5 5 DPR 6 6 556610H 00 Memory space After execution DTB 5 5 DPR 6 6 556610H 01 ● Direct bit addressing (addr16:bp) Specify arbitrary bits in 64 kilobytes explicitly. Address bits 16 to 23 are specified by the data bank register (DTB). Bit positions are indicated by ":bp", where the larger number indicates the most significant bit (MSB) and the lower number indicates the least significant bit (LSB). Figure D.3-10 Example of Direct Bit Addressing (addr16:bp) SETB 2222H : 0 (This instruction sets bits by direct bit addressing.) Memory space Before execution DTB 5 5 552222H 00 Memory space After execution 578 DTB 5 5 552222H 01 APPENDIX D Instructions ● Vector Addressing (#vct) Specify vector data in an operand to indicate the branch destination address. There are two sizes for vector numbers: 4 bits and 8 bits. Vector addressing is used for a subroutine call or software interrupt instruction. Figure D.3-11 Example of Vector Addressing (#vct) CALLV #15 (This instruction causes a branch to the address indicated by the interrupt vector specified in an operand.) Before execution PC 0 0 0 0 Memory space PCB F F After execution FFC000H EF FFFFE0H 00 FFFFE1H D0 CALLV #15 PC D 0 0 0 PCB F F Table D.3-2 CALLV Vector List Instruction Vector address L Vector address H CALLV #0 XXFFFEH XXFFFFH CALLV #1 XXFFFCH XXFFFDH CALLV #2 XXFFFAH XXFFFBH CALLV #3 XXFFF8H XXFFF9H CALLV #4 XXFFF6H XXFFF7H CALLV #5 XXFFF4H XXFFF5H CALLV #6 XXFFF2H XXFFF3H CALLV #7 XXFFF0H XXFFF1H CALLV #8 XXFFEEH XXFFEFH CALLV #9 XXFFECH XXFFEDH CALLV #10 XXFFEAH XXFFEBH CALLV #11 XXFFE8H XXFFE9H CALLV #12 XXFFE6H XXFFE7H CALLV #13 XXFFE4H XXFFE5H CALLV #14 XXFFE2H XXFFE3H CALLV #15 XXFFE0H XXFFE1H Note: A PCB register value is set in XX. Note: When the program counter bank register (PCB) is FFH, the vector area overlaps the vector area of INT #vct8 (#0 to #7). Use vector addressing carefully (see Table D.3-2). 579 APPENDIX D.4 Indirect Addressing In indirect addressing mode, an address is specified indirectly by the address data of an operand. ■ Indirect Addressing ● Register indirect addressing (@RWj j = 0 to 3) Memory is accessed using the contents of general-purpose register RWj as an address. Address bits 16 to 23 are indicated by the data bank register (DTB) when RW0 or RW1 is used, system stack bank register (SSB) or user stack bank register (USB) when RW3 is used, or additional data bank register (ADB) when RW2 is used. Figure D.4-1 Example of Register Indirect Addressing (@RWj j = 0 to 3) MOVW A, @RW1 (This instruction reads data by register indirect addressing and stores it in A.) Before execution A 0716 2534 Memory space RW1 D 3 0 F After execution DTB 7 8 78D30FH EE 78D310H FF A 2534 FFEE RW1 D 3 0 F DTB 7 8 ● Register indirect addressing with post increment (@RWj+ j = 0 to 3) Memory is accessed using the contents of general-purpose register RWj as an address. After operand operation, RWj is incremented by the operand size (1 for a byte, 2 for a word, or 4 for a long word). Address bits 16 to 23 are indicated by the data bank register (DTB) when RW0 or RW1 is used, system stack bank register (SSB) or user stack bank register (USB) when RW3 is used, or additional data bank register (ADB) when RW2 is used. If the post increment results in the address of the register that specifies the increment, the incremented value is referenced after that. In this case, if the next instruction is a write instruction, priority is given to writing by an instruction and, therefore, the register that would be incremented becomes write data. 580 APPENDIX D Instructions Figure D.4-2 Example of Register Indirect Addressing with Post Increment (@RWj+ j = 0 to 3) MOVW A, @RW1+ (This instruction reads data by register indirect addressing with post increment and stores it in A.) Before execution A 0716 2534 Memory space RW1 D 3 0 F After execution DTB 7 8 78D30FH EE 78D310H FF A 2534 FFEE RW1 D 3 1 1 DTB 7 8 ● Register indirect addressing with offset (@RWi + disp8 i = 0 to 7, @RWj + disp16 j = 0 to 3) Memory is accessed using the address obtained by adding an offset to the contents of general-purpose register RWj. Two types of offset, byte and word offsets, are used. They are added as signed numeric values. Address bits 16 to 23 are indicated by the data bank register (DTB) when RW0, RW1, RW4, or RW5 is used, system stack bank register (SSB) or user stack bank register (USB) when RW3 or RW7 is used, or additional data bank register (ADB) when RW2 or RW6 is used. Figure D.4-3 Example of Register Indirect Addressing with Offset (@RWi + disp8 i = 0 to 7, @RWj + disp16 j = 0 to 3) MOVW A, @RW1+10H (This instruction reads data by register indirect addressing with an offset and stores it in A.) Before execution A 0716 2534 (+10H) RW1 D 3 0 F After execution DTB 7 8 Memory space 78D31FH EE 78D320H FF A 2534 FFEE RW1 D 3 0 F DTB 7 8 581 APPENDIX ● Long register indirect addressing with offset (@RLi + disp8 i = 0 to 3) Memory is accessed using the address that is the 24 low-order bits obtained by adding an offset to the contents of general-purpose register RLi. The offset is 8-bits long and is added as a signed numeric value. Figure D.4-4 Example of Long Register Indirect Addressing with Offset (@RLi + disp8 i = 0 to 3) MOVW A, @RL2+25H (This instruction reads data by long register indirect addressing with an offset and stores it in A.) Before execution A 0716 2534 (+25H) RL2 F 3 8 2 After execution 4B02 Memory space 824B27H EE 824B28H FF A 2534 FFEE RL2 F 3 8 2 4B02 ● Program counter indirect addressing with offset (@PC + disp16) Memory is accessed using the address indicated by (instruction address + 4 + disp16). The offset is one word long. Address bits 16 to 23 are specified by the program counter bank register (PCB). Note that the operand address of each of the following instructions is not deemed to be (next instruction address + disp16): • DBNZ eam, rel • DWBNZ eam, rel • CBNE eam, #imm8, rel • CWBNE eam, #imm16, rel • MOV eam, #imm8 • MOVW eam, #imm16 Figure D.4-5 Example of Program Counter Indirect Addressing with Offset (@PC + disp16) MOVW A, @PC+20H (This instruction reads data by program counter indirect addressing with an offset and stores it in A.) Before execution A 0716 2534 Memory space PCB C 5 PC 4 5 5 6 After execution A 2534 FFEE PCB C 5 PC 4 5 5 A 582 +4 C54556H 73 C54557H 9E C54558H 20 C54559H 00 C5455AH . . . +20H C5457AH EE C5457BH FF MOVW A, @PC+20H APPENDIX D Instructions ● Register indirect addressing with base index (@RW0 + RW7, @RW1 + RW7) Memory is accessed using the address determined by adding RW0 or RW1 to the contents of generalpurpose register RW7. Address bits 16 to 23 are indicated by the data bank register (DTB). Figure D.4-6 Example of Register Indirect Addressing with Base Index (@RW0 + RW7, @RW1 + RW7) MOVW A, @RW1+RW7 (This instruction reads data by register indirect addressing with a base index and stores it in A.) Before execution A 0716 RW1 D 3 0 F WR7 0 1 0 1 After execution A 2534 RW1 D 3 0 F 2534 + DTB 7 8 Memory space 78D410H EE 78D411H FF FFEE DTB 7 8 WR7 0 1 0 1 583 APPENDIX ● Program counter relative branch addressing (rel) The address of the branch destination is a value determined by adding an 8-bit offset to the program counter (PC) value. If the result of addition exceeds 16 bits, bank register incrementing or decrementing is not performed and the excess part is ignored, and therefore the address is contained within a 64-kilobyte bank. This addressing is used for both conditional and unconditional branch instructions. Address bits 16 to 23 are indicated by the program counter bank register (PCB). Figure D.4-7 Example of Program Counter Relative Branch Addressing (rel) BRA 10H (This instruction causes an unconditional relative branch.) Before execution After execution PC 3 C 2 0 PC 3 C 3 2 PCB 4 F PCB 4 F Memory space 4F3C32H Next instruction 4F3C21H 10 4F3C20H 60 BRA 10H ● Register list (rlst) Specify a register to be pushed onto or popped from a stack. Figure D.4-8 Configuration of the Register List MSB LSB RW7 RW6 RW5 RW4 RW3 RW2 RW1 RW0 A register is selected when the corresponding bit is 1 and deselected when the bit is 0. 584 APPENDIX D Instructions Figure D.4-9 Example of Register List (rlist) POPW, RW0, RW4 (This instruction transfers memory data indicated by the SP to multiple word registers indicated by the register list.) SP 34FA SP 34FE RW0 ×× ×× RW0 02 01 RW1 ×× ×× RW1 ×× ×× RW2 ×× ×× RW2 ×× ×× RW3 ×× ×× RW3 ×× ×× RW4 ×× ×× RW4 04 03 RW5 ×× ×× RW5 ×× ×× RW6 ×× ×× RW6 ×× ×× RW7 ×× ×× RW7 ×× ×× Memory space SP Memory space 01 34FAH 01 34FAH 02 34FBH 02 34FBH 03 34FCH 03 34FCH 04 34FDH 04 34FDH 34FEH SP Before execution 34FEH After execution ● Accumulator indirect addressing (@A) Memory is accessed using the address indicated by the contents of the low-order bytes (16 bits) of the accumulator (AL). Address bits 16 to 23 are specified by a mnemonic in the data bank register (DTB). Figure D.4-10 Example of Accumulator Indirect Addressing (@A) MOVW A, @A (This instruction reads data by accumulator indirect addressing and stores it in A.) Before execution A 0716 2534 DTB B B After execution A 0716 Memory space BB2534H EE BB2535H FF FFEE DTB B B 585 APPENDIX ● Accumulator indirect branch addressing (@A) The address of the branch destination is the content (16 bits) of the low-order bytes (AL) of the accumulator. It indicates the branch destination in the bank address space. Address bits 16 to 23 are specified by the program counter bank register (PCB). For the Jump Context (JCTX) instruction, however, address bits 16 to 23 are specified by the data bank register (DTB). This addressing is used for unconditional branch instructions. Figure D.4-11 Example of Accumulator Indirect Branch Addressing (@A) JMP @A (This instruction causes an unconditional branch by accumulator indirect branch addressing.) Before execution PC 3 C 2 0 A 6677 After execution PC 3 B 2 0 A 6677 PCB 4 F 3B20 Memory space 4F3B20H Next instruction 4F3C20H 61 JMP @A PCB 4 F 3B20 ● Indirect specification branch addressing (@ear) The address of the branch destination is the word data at the address indicated by ear. Figure D.4-12 Example of Indirect Specification Branch Addressing (@ear) JMP @@RW0 (This instruction causes an unconditional branch by register indirect addressing.) Before execution After execution 586 PC 3 C 2 0 PCB 4 F RW0 7 F 4 8 DTB 2 1 PC 3 B 2 0 PCB 4 F RW0 7 F 4 8 DTB 2 1 Memory space 217F48H 20 217F49H 3B 4F3B20H Next instruction 4F3C20H 73 4F3C21H 08 JMP @@RW0 APPENDIX D Instructions ● Indirect specification branch addressing (@eam) The address of the branch destination is the word data at the address indicated by eam. Figure D.4-13 Example of Indirect Specification Branch Addressing (@eam) JMP @RW0 (This instruction causes an unconditional branch by register indirect addressing.) Before execution PC 3 C 2 0 PCB 4 F RW0 3 B 2 0 After execution PC 3 B 2 0 PCB 4 F Memory space 4F3B20H Next instruction 4F3C20H 73 4F3C21H 00 JMP @RW0 RW0 3 B 2 0 587 APPENDIX D.5 Execution Cycle Count The number of cycles required for instruction execution (execution cycle count) is obtained by adding the number of cycles required for each instruction, "correction value" determined by the condition, and the number of cycles for instruction fetch. ■ Execution Cycle Count The number of cycles required for instruction execution (execution cycle count) is obtained by adding the number of cycles required for each instruction, "correction value" determined by the condition, and the number of cycles for instruction fetch. In the mode of fetching an instruction from memory such as internal ROM connected to a 16-bit bus, the program fetches the instruction being executed in word increments. Therefore, intervening in data access increases the execution cycle count. Similarly, in the mode of fetching an instruction from memory connected to an 8-bit external bus, the program fetches every byte of an instruction being executed. Therefore, intervening in data access increases the execution cycle count. In CPU intermittent operation mode, access to a general-purpose register, internal ROM, internal RAM, internal I/O, or external data bus causes the clock to the CPU to halt for the cycle count specified by the CG0 and CG1 bits of the low power consumption mode control register. Therefore, for the cycle count required for instruction execution in CPU intermittent operation mode, add the "access count x cycle count for the halt" as a correction value to the normal execution count. 588 APPENDIX D Instructions ■ Calculating the Execution Cycle Count Table D.5-1 lists execution cycle counts and Table D.5-2 and Table D.5-3 summarize correction value data. Table D.5-1 Execution Cycle Counts in Each Addressing Mode (a) * Code Operand 00 | 07 Ri Rwi RLi 08 | 0B Execution cycle count in each addressing mode Register access count in each addressing mode See the instruction list. See the instruction list. @RWj 2 1 0C | 0F @RWj+ 4 2 10 | 17 @RWi+disp8 2 1 18 | 1B @RWi+disp16 2 1 1C 1D 1E 1F @RW0+RW7 @RW1+RW7 @PC+disp16 addr16 4 4 2 1 2 2 0 0 *: (a) is used for ~ (cycle count) and B (correction value) in "D.8 F2MC-16LX Instruction List". 589 APPENDIX Table D.5-2 Cycle Count Correction Values for Counting Execution Cycles (b) byte * Operand (c) word * (d) long * Cycle count Access count Cycle count Access count Cycle count Access count Internal register +0 1 +0 1 +0 2 Internal memory Even address +0 1 +0 1 +0 2 Internal memory Odd address +0 1 +2 2 +4 4 External data bus 16-bit even address +1 1 +1 1 +2 2 External data bus 16-bit odd address +1 1 +4 2 +8 4 External data bus 8-bits +1 1 +4 2 +8 4 *: (b), (c), and (d) are used for ~ (cycle count) and B (correction value) in "D.8 F2MC-16LX Instruction List". Note: When an external data bus is used, the cycle counts during which an instruction is made to wait by ready input or automatic ready must also be added. Table D.5-3 Cycle Count Correction Values for Counting Instruction Fetch Cycles Instruction Byte boundary Word boundary Internal memory - +2 External data bus 16-bits - +3 External data bus 8-bits +3 - Notes: • When an external data bus is used, the cycle counts during which an instruction is made to wait by ready input or automatic ready must also be added. • Actually, instruction execution is not delayed by every instruction fetch. Therefore, use the correction values to calculate the worst case. 590 APPENDIX D Instructions D.6 Effective address field Table D.6-1 shows the effective address field. ■ Effective Address Field Table D.6-1 Effective Address Field Code 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F Representation R0 RW0 R1 RW1 R2 RW2 R3 RW3 R4 RW4 R5 RW5 R6 RW6 R7 RW7 @RW0 @RW1 @RW2 @RW3 @RW0+ @RW1+ @RW2+ @RW3+ @RW0+disp8 @RW1+disp8 @RW2+disp8 @RW3+disp8 @RW4+disp8 @RW5+disp8 @RW6+disp8 @RW7+disp8 @RW0+disp16 @RW1+disp16 @RW2+disp16 @RW3+disp16 @RW0+RW7 @RW1+RW7 @PC+disp16 addr16 RL0 (RL0) RL1 (RL1) RL2 (RL2) RL3 (RL3) Address format Byte count of extended address part * Register direct: Individual parts correspond to the byte, word, and long word types in order from the left. - Register indirect 0 Register indirect with post increment 0 Register indirect with 8-bit displacement 1 Register indirect with 16-bit displacement 2 Register indirect with index Register indirect with index PC indirect with 16-bit displacement Direct address 0 0 2 2 *1: Each byte count of the extended address part applies to + in the # (byte count) column in "D.8 F2MC-16LX Instruction List". 591 APPENDIX D.7 How to Read the Instruction List Table D.7-1 describes the items used in "D.8 F2MC-16LX Instruction List", and Table D.7-2 describes the symbols used in the same list. ■ Description of Instruction Presentation Items and Symbols Table D.7-1 Description of Items in the Instruction List (1/2) Item Mnemonic Uppercase, symbol: Represented as is in the assembler. Lowercase: Rewritten in the assembler. Number of following lowercase: Indicates bit length in the instruction. # Indicates the number of bytes. ~ Indicates the number of cycles. See Table D.2-1 for the alphabetical letters in items. RG B Operation Indicates the number of times a register access is performed during instruction execution. The number is used to calculate the correction value for CPU intermittent operation. Indicates the correction value used to calculate the actual number of cycles during instruction execution. The actual number of cycles during instruction execution can be determined by adding the value in the ~ column to this value. Indicates the instruction operation. LH Indicates the special operation for bit15 to bit08 of the accumulator. Z: Transfers 0. X: Transfers after sign extension. -: No transfer AH Indicates the special operation for the 16 high-order bits of the accumulator. *: Transfers from AL to AH. -: No transfer Z: Transfers 00 to AH. X: Transfers 00H or FFH to AH after AL sign extension. I S T N Z V C 592 Description Each indicates the state of each flag: I (interrupt enable), S (stack), T (sticky bit), N (negative), Z (zero), V (overflow), C (carry). *: Changes upon instruction execution. -: No change S: Set upon instruction execution. R: Reset upon instruction execution. APPENDIX D Instructions Table D.7-1 Description of Items in the Instruction List (1/2) Item Description RMW Indicates whether the instruction is a Read Modify Write instruction (reading data from memory by the I instruction and writing the result to memory). *: Read Modify Write instruction -: Not Read Modify Write instruction Note: Cannot be used for an address that has different meanings between read and write operations. Table D.7-2 Explanation on Symbols in the Instruction List (1/2) Symbol A Explanation The bit length used varies depending on the 32-bit accumulator instruction. Byte: Low-order 8 bits of byte AL Word: 16 bits of word AL Long word: 32 bits of AL and AH AH 16 high-order bits of A AL 16 low-order bits of A SP Stack pointer (USP or SSP) PC Program counter PCB program counter bank register DTB Data bank register ADB Additional data bank register SSB System stack bank register USB User stack bank register SPB Current stack bank register (SSB or USB) DPR Direct page register brg1 DTB, ADB, SSB, USB, DPR, PCB, SPB brg2 DTB, ADB, SSB, USB, DPR, SPB Ri R0, R1, R2, R3, R4, R5, R6, R7 RWi RW0, RW1, RW2, RW3, RW4, RW5, RW6, RW7 RWj RW0, RW1, RW2, RW3 RLi RL0, RL1, RL2, RL3 dir Abbreviated direct addressing addr16 Direct addressing addr24 Physical direct addressing 593 APPENDIX Table D.7-2 Explanation on Symbols in the Instruction List (1/2) Symbol ad24 0-15 Bit0 to bit15 of addr24 ad24 16-23 Bit16 to bit23 of addr24 io I/O area (000000H to 0000FFH) #imm4 4-bit immediate data #imm8 8-bit immediate data #imm16 16-bit immediate data #imm32 32-bit immediate data ext (imm8) 16-bit data obtained by sign extension of 8-bit immediate data disp8 8-bit displacement disp16 16-bit displacement bp 594 Explanation Bit offset vct4 Vector number (0 to 15) vct8 Vector number (0 to 255) ( )b Bit address rel PC relative branch ear Effective addressing (code 00 to 07) eam Effective addressing (code 08 to 1F) rlst Register list APPENDIX D Instructions D.8 F2MC-16LX Instruction List Table D.8-1 to Table D.8-18 list the instructions used by the F2MC-16LX. ■ F2MC-16LX Instruction List Table D.8-1 41 Transfer Instructions (Byte) Mnemonic MOV MOV MOV MOV MOV MOV MOV MOV MOV MOVN MOVX MOVX MOVX MOVX MOVX MOVX MOVX MOVX MOVX MOVX MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV XCH XCH XCH XCH A,dir A,addr16 A,Ri A,ear A,eam A,io A,#imm8 A,@A A,@RLi+disp8 A,#imm4 A,dir A,addr16 A,Ri A,ear A,eam A,io A,#imm8 A,@A A,@RWi+disp8 A,@RLi+disp8 dir,A addr16,A Ri,A ear,A eam,A io,A @RLi+disp8,A Ri,ear Ri,eam ear,Ri eam,Ri Ri,#imm8 io,#imm8 dir,#imm8 ear,#imm8 eam,#imm8 @AL,AH A,ear A,eam Ri,ear Ri,eam # ~ RG B 2 3 1 2 2+ 2 2 2 3 1 2 3 2 2 2+ 2 2 2 2 3 2 3 1 2 2+ 2 3 2 2+ 2 2+ 2 3 3 3 3+ 2 2 2+ 2 2+ 3 4 2 2 3 + (a) 3 2 3 10 1 3 4 2 2 3 + (a) 3 2 3 5 10 3 4 2 2 3 + (a) 3 10 3 4 + (a) 4 5 + (a) 2 5 5 2 4 + (a) 3 4 5 + (a) 7 9 + (a) 0 0 1 1 0 0 0 0 2 0 0 0 1 1 0 0 0 0 1 2 0 0 1 1 0 0 2 2 1 2 1 1 0 0 1 0 0 2 0 4 2 (b) (b) 0 0 (b) (b) 0 (b) (b) 0 (b) (b) 0 0 (b) (b) 0 (b) (b) (b) (b) (b) 0 0 (b) (b) (b) 0 (b) 0 (b) 0 (b) (b) 0 (b) (b) 0 2 × (b) 0 2 × (b) Operation byte (A) ← (dir) byte (A) ← (addr16) byte (A) ← (Ri) byte (A) ← (ear) byte (A) ← (eam) byte (A) ← (io) byte (A) ← imm8 byte (A) ← ((A)) byte (A) ← ((RLi)+disp8) byte (A) ← imm4 byte (A) ← (dir) byte (A) ← (addr16) byte (A) ← (Ri) byte (A) ← (ear) byte (A) ← (eam) byte (A) ← (io) byte (A) ← imm8 byte (A) ← ((A)) byte (A) ← ((RWi)+disp8) byte (A) ← ((RLi)+disp8) byte (dir) ← (A) byte (addr16) ← (A) byte (Ri) ← (A) byte (ear) ← (A) byte (eam) ← (A) byte (io) ← (A) byte ((RLi)+disp8) ← (A) byte (Ri) ← (ear) byte (Ri) ← (eam) byte (ear) ← (Ri) byte (eam) ← (Ri) byte (Ri) ← imm8 byte (io) ← imm8 byte (dir) ← imm8 byte (ear) ← imm8 byte (eam) ← imm8 byte ((A)) ← (AH) byte (A) ↔ (ear) byte (A) ↔ (eam) byte (Ri) ↔ (ear) byte (Ri) ↔ (eam) LH AH I S T N Z V C RMW Z Z Z Z Z Z Z Z Z Z X X X X X X X X X X Z Z - * * * * * * * * * * * * * * * * * * - - - - * * * * * * * * * R * * * * * * * * * * * * * * * * * * * * * * * * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - - - Note: See Table D.5-1 and Table D.5-2 for information on (a) and (b) in the table. 595 APPENDIX Table D.8-2 38 Transfer Instructions (Word, Long Word) Mnemonic MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW XCHW XCHW XCHW XCHW MOVL MOVL MOVL MOVL MOVL A,dir A,addr16 A,SP A,RWi A,ear A,eam A,io A,@A A,#imm16 A,@RWi+disp8 A,@RLi+disp8 dir,A addr16,A SP,A RWi,A ear,A eam,A io,A @RWi+disp8,A @RLi+disp8,A RWi,ear RWi,eam ear,RWi eam,RWi RWi,#imm16 io,#imm16 ear,#imm16 eam,#imm16 @AL,AH A,ear A,eam RWi, ear RWi, eam A,ear A,eam A,#imm32 ear,A eam,A # ~ RG B 2 3 1 1 2 2+ 2 2 3 2 3 2 3 1 1 2 2+ 2 2 3 2 2+ 2 2+ 3 4 4 4+ 2 2 2+ 2 2+ 2 2+ 5 2 2+ 3 4 1 2 2 3 + (a) 3 3 2 5 10 3 4 1 2 2 3 + (a) 3 5 10 3 4 + (a) 4 5 + (a) 2 5 2 4 + (a) 3 4 5 + (a) 7 9 + (a) 4 5 + (a) 3 4 5 + (a) 0 0 0 1 1 0 0 0 0 1 2 0 0 0 1 1 0 0 1 2 2 1 2 1 1 0 1 0 0 2 0 4 2 2 0 0 2 0 (c) (c) 0 0 0 (c) (c) (c) 0 (c) (c) (c) (c) 0 0 0 (c) (c) (c) (c) 0 (c) 0 (c) 0 (c) 0 (c) (c) 0 2 × (c) 0 2 × (c) 0 (d) 0 0 (d) Operation word (A) ← (dir) word (A) ← (addr16) word (A) ← (SP) word (A) ← (RWi) word (A) ← (ear) word (A) ← (eam) word (A) ← (io) word (A) ← ((A)) word (A) ← imm16 word (A) ← ((RWi)+disp8) word (A) ← ((RLi)+disp8) word (dir) ← (A) word (addr16) ← (A) word (SP) ← (A) word (RWi) ← (A) word (ear) ← (A) word (eam) ← (A) word (io) ← (A) word ((RWi)+disp8) ← (A) word ((RLi)+disp8) ← (A) word (RWi) ← (ear) word (RWi) ← (eam) word (ear) ← (RWi) word (eam) ← (RWi) word (RWi) ← imm16 word (io) ← imm16 word (ear) ← imm16 word (eam) ← imm16 word ((A)) ← (AH) word (A) ↔ (ear) word (A) ↔ (eam) word (RWi) ↔ (ear) word (RWi) ↔ (eam) long (A) ← (ear) long (A) ← (eam) long (A) ← imm32 long (ear) ← (A) long(eam) ← (A) LH AH I S T N Z V C RMW - * * * * * * * * * * - - - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - - Note: See Table D.5-1 and Table D.5-2 for information on (a), (c), and (d) in the table. 596 APPENDIX D Instructions Table D.8-3 42 Addition/Subtraction Instructions (Byte, Word, Long Word) Mnemonic # ~ RG B ADD ADD ADD ADD ADD ADD ADDC ADDC ADDC ADDDC A,#imm8 A,dir A,ear A,eam ear,A eam,A A A,ear A,eam A 2 2 2 2+ 2 2+ 1 2 2+ 1 2 5 3 4 + (a) 3 5 + (a) 2 3 4 + (a) 3 0 0 1 0 2 0 0 1 0 0 0 (b) 0 (b) 0 2 × (b) 0 0 (b) 0 SUB SUB SUB SUB SUB SUB SUBC SUBC SUBC SUBDC A,#imm8 A,dir A,ear A,eam ear,A eam,A A A,ear A,eam A 2 2 2 2+ 2 2+ 1 2 2+ 1 2 5 3 4 + (a) 3 5 + (a) 2 3 4 + (a) 3 0 0 1 0 2 0 0 1 0 0 0 (b) 0 (b) 0 2 × (b) 0 0 (b) 0 ADDW ADDW ADDW ADDW ADDW ADDW ADDCW ADDCW SUBW SUBW SUBW SUBW SUBW SUBW SUBCW SUBCW ADDL ADDL ADDL SUBL SUBL SUBL A A,ear A,eam A,#imm16 ear,A eam,A A,ear A,eam A A,ear A,eam A,#imm16 ear,A eam,A A,ear A,eam A,ear A,eam A,#imm32 A,ear A,eam A,#imm32 1 2 2+ 3 2 2+ 2 2+ 1 2 2+ 3 2 2+ 2 2+ 2 2+ 5 2 2+ 5 2 3 4+(a) 2 3 5+(a) 3 4+(a) 2 3 4+(a) 2 3 5+(a) 3 4+(a) 6 7+(a) 4 6 7+(a) 4 0 1 0 0 2 0 1 0 0 1 0 0 2 0 1 0 2 0 0 2 0 0 0 0 (c) 0 0 2 × (c) 0 (c) 0 0 (c) 0 0 2 × (c) 0 (c) 0 (d) 0 0 (d) 0 Operation byte (A) ← (A) + imm8 byte (A) ← (A) + (dir) byte (A) ← (A) + (ear) byte (A) ← (A) + (eam) byte (ear) ← (ear) + (A) byte (eam) ← (eam) + (A) byte (A) ← (AH) + (AL) + (C) byte (A) ← (A) + (ear)+ (C) byte (A) ← (A) + (eam)+ (C) byte (A) ← (AH) + (AL) + (C) (decimal) byte (A) ← (A) - imm8 byte (A) ← (A) - (dir) byte (A) ← (A) - (ear) byte (A) ← (A) - (eam) byte (ear) ← (ear) - (A) byte (eam) ← (eam) - (A) byte (A) ← (AH) - (AL) - (C) byte (A) ← (A) - (ear) - (C) byte (A) ← (A) - (eam) - (C) byte (A) ← (AH) - (AL) - (C) (decimal) word (A) ← (AH) + (AL) word (A) ← (A) + (ear) word (A) ← (A) + (eam) word (A) ← (A) + imm16 word (ear) ← (ear) + (A) word (eam) ← (eam) + (A) word (A) ← (A) + (ear) + (C) word (A) ← (A) + (eam) + (C) word (A) ← (AH) - (AL) word (A) ← (A) - (ear) word (A) ← (A) - (eam) word (A) ← (A) - imm16 word (ear) ← (ear) - (A) word (eam) ← (eam) - (A) word (A) ← (A) - (ear) - (C) word (A) ← (A) - (eam) - (C) long (A) ← (A) + (ear) long (A) ← (A) + (eam) long (A) ← (A) + imm32 long (A) ← (A) - (ear) long (A) ← (A) - (eam) long (A) ← (A) - imm32 LH AH I S T N Z V C RMW Z Z Z Z Z Z Z Z Z - - - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - Z Z Z Z Z Z Z Z - - - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - - - - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - Note: See Table D.5-1 and Table D.5-2 for information on (a) to (d) in the table. 597 APPENDIX Table D.8-4 12 Increment/decrement Instructions (Byte, Word, Long Word) Mnemonic # ~ RG B INC ear 2 3 2 0 INC eam 2+ 5+(a) 0 2 × (b) Operation LH AH I S T N Z V C RMW byte (ear) ← (ear) + 1 - - - - - * * * - - byte (eam) ← (eam) + 1 - - - - - * * * - * DEC ear 2 3 2 0 byte (ear) ← (ear) - 1 - - - - - * * * - - DEC eam 2+ 5+(a) 0 2 × (b) byte (eam) ← (eam) - 1 - - - - - * * * - * INCW ear 2 3 2 0 word (ear) ← (ear) + 1 - - - - - * * * - - INCW eam 2+ 5+(a) 0 2 × (c) word (eam) ← (eam) + 1 - - - - - * * * - * DECW ear 2 3 2 0 DECW eam 2+ 5+(a) 0 2 × (c) INCL ear 2 7 4 0 INCL eam 2+ 9+(a) 0 2 × (d) DECL ear 2 7 4 0 DECL eam 2+ 9+(a) 0 2 × (d) word (ear) ← (ear) - 1 - - - - - * * * - - word (eam) ← (eam) - 1 - - - - - * * * - * long (ear) ← (ear) + 1 - - - - - * * * - - long (eam) ← (eam) + 1 - - - - - * * * - * long (ear) ← (ear) - 1 - - - - - * * * - - long (eam) ← (eam) - 1 - - - - - * * * - * Note: See Table D.5-1 and Table D.5-2 for information on (a) to (d) in the table. Table D.8-5 11 Compare Instructions (Byte, Word, Long Word) Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW - CMP A 1 1 0 0 byte (AH) - (AL) - - - - - * * * * CMP A,ear 2 2 1 0 byte (A) - (ear) - - - - - * * * * - CMP A,eam 2+ 3+(a) 0 (b) byte (A) - (eam) - - - - - * * * * - CMP A,#imm8 2 2 0 0 byte (A) - imm8 - - - - - * * * * - CMPW A 1 1 0 0 word (AH) - (AL) - - - - - * * * * - CMPW A,ear 2 2 1 0 word (A) - (ear) - - - - - * * * * - CMPW A,eam 2+ 3+(a) 0 (c) word (A) - (eam) - - - - - * * * * - CMPW A,#imm16 3 2 0 0 word (A) - imm16 - - - - - * * * * - CMPL A,ear 2 6 2 0 long (A) - (ear) - - - - - * * * * - CMPL A,eam 2+ 7+(a) 0 (d) long (A) - (eam) - - - - - * * * * - CMPL A,#imm32 5 3 0 0 long (A) - imm32 - - - - - * * * * - Note: See Table D.5-1 and Table D.5-2 for information on (a) to (d) in the table. 598 APPENDIX D Instructions Table D.8-6 11 Unsigned Multiplication/Division Instructions (Word, Long Word) Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW DIVU A 1 *1 0 0 word (AH) / byte (AL) quotient → byte (AL) remainder → byte (AH) - - - - - - - * * - DIVU A,ear 2 *2 1 0 word (A) / byte (ear) quotient → byte (A) remainder → byte (ear) - - - - - - - * * - DIVU A,eam 2+ *3 0 *6 word (A) / byte (eam) quotient → byte (A) remainder → byte (eam) - - - - - - - * * - DIVUW A,ear 2 *4 1 0 long (A) / word (ear) quotient → word (A) remainder → word (ear) - - - - - - - * * - DIVUW A,eam 2+ *5 0 *7 long (A) / word (eam) quotient → word (A) remainder → word (eam) - - - - - - - * * - MULU A 1 *8 0 0 byte (AH) * byte (AL) → word (A) - - - - - - - - - MULU A,ear 2 *9 1 0 byte (A) * byte (ear) → word (A) - - - - - - - - - - MULU A,eam 2+ *10 0 (b) byte (A) * byte (eam) → word (A) - - - - - - - - - - MULUW A 1 *11 0 0 word (AH) * word (AL) → Long (A) - - - - - - - - - MULUW A,ear 2 *12 1 0 word (A) * word (ear) → Long (A) - - - - - - - - - - MULUW A,eam 2+ *13 0 (c) word (A) * word (eam) → Long (A) - - - - - - - - - - *1: 3: Division by 0 7: Overflow 15: Normal *2: 4: Division by 0 8: Overflow 16: Normal *3: 6+(a): Division by 0 9+(a): Overflow 19+(a): Normal *4: 4: Division by 0 7: Overflow 22: Normal *5: 6+(a): Division by 0 8+(a): Overflow 26+(a): Normal *6: (b): Division by 0 or overflow 2 × (b): Normal *7: (c): Division by 0 or overflow 2 × (c): Normal *8: 3: Byte (AH) is 0. 7: Byte (AH) is not 0. *9: 4: Byte (ear) is 0. 8: Byte (ear) is not 0. *10: 5+(a): Byte (eam) is 0, 9+(a): Byte (eam) is not 0. *11: 3: Word (AH) is 0. 11: Word (AH) is not 0. *12: 4: Word (ear) is 0. 12: Word (ear) is not 0. *13: 5+(a): Word (eam) is 0. 13+(a): Word (eam) is not 0. Note: See Table D.5-1 and Table D.5-2 for information on (a) to (c) in the table. 599 APPENDIX Table D.8-7 11 Signed Multiplication/Division Instructions (Word, Long Word) Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW DIV A 2 *1 0 0 word (AH) / byte (AL) quotient → byte (AL) remainder → byte (AH) Z - - - - - - * * - DIV A,ear 2 *2 1 0 word (A) / byte (ear) quotient → byte (A) remainder → byte (ear) Z - - - - - - * * - DIV A,eam 2+ *3 0 *6 word (A) / byte (eam) quotient → byte (A) remainder → byte (eam) Z - - - - - - * * - DIVW A,ear 2 *4 1 0 long (A) / word (ear) quotient → word (A) remainder → word (ear) - - - - - - - * * - DIVW A,eam 2+ *5 0 *7 long (A) / word (eam) quotient → word (A) remainder → word (eam) - - - - - - - * * - MUL A 2 *8 0 0 byte (AH) * byte (AL) → word (A) - - - - - - - - - - MUL A,ear 2 *9 1 0 byte (A) * byte (ear) → word (A) - - - - - - - - - - byte (A) * byte (eam) → word (A) - - - - - - - - - - word (AH) * word (AL) → Long (A) - - - - - - - - - - 0 word (A) * word (ear) → Long (A) - - - - - - - - - - (c) word (A) * word (eam) → Long (A) - - - - - - - - - - MUL A,eam 2+ *10 0 (b) MULW A 2 *11 0 0 MULW A,ear 2 *12 1 MULW A,eam 2+ *13 0 *1: *2: *3: *4: 3: Division by 0, 8 or 18: Overflow, 18: Normal 4: Division by 0, 11 or 22: Overflow, 23: Normal 5+(a): Division by 0, 12+(a) or 23+(a): Overflow, 24+(a): Normal When dividend is positive; 4: Division by 0, 12 or 30: Overflow, 31: Normal When dividend is negative; 4: Division by 0, 12 or 31: Overflow, 32: Normal *5: When dividend is positive; 5+(a): Division by 0, 12+(a) or 31+(a): Overflow, 32+(a): Normal When dividend is negative; 5+(a): Division by 0, 12+(a) or 32+(a): Overflow, 33+(a): Normal *6: (b): Division by 0 or overflow, 2 × (b): Normal *7: (c): Division by 0 or overflow, 2 × (c): Normal *8: 3: Byte (AH) is 0, 12: result is positive, 13: result is negative *9: 4: Byte (ear) is 0, 13: result is positive, 14: result is negative *10: 5+(a): Byte (eam) is 0, 14+(a): result is positive, 15+(a): result is negative *11: 3: Word (AH) is 0, 16: result is positive, 19: result is negative *12: 4: Word (ear) is 0, 17: result is positive, 20: result is negative *13: 5+(a): Word (eam) is 0, 18+(a): result is positive, 21+(a): result is negative Notes: • The execution cycle count found when an overflow occurs in a DIV or DIVW instruction may be a pre-operation count or a post-operation count depending on the detection timing. • When an overflow occurs with DIV or DIVW instruction, the contents of the AL are destroyed. • See Table D.5-1 and Table D.5-2 for information on (a) to (c) in the table. 600 APPENDIX D Instructions Table D.8-8 39 Logic 1 Instructions (Byte, Word) Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW - AND A,#imm8 2 2 0 0 byte (A) ← (A) and imm8 - - - - - * * R - AND A,ear 2 3 1 0 byte (A) ← (A) and (ear) - - - - - * * R - - AND A,eam 2+ 4+(a) 0 (b) byte (A) ← (A) and (eam) - - - - - * * R - - byte (ear) ← (ear) and (A) - - - - - * * R - - byte (eam) ← (eam) and (A) - - - - - * * R - * AND ear,A 2 3 2 0 AND eam,A 2+ 5+(a) 0 2 × (b) OR A,#imm8 2 2 0 0 byte (A) ← (A) or imm8 - - - - - * * R - - OR A,ear 2 3 1 0 byte (A) ← (A) or (ear) - - - - - * * R - - OR A,eam 2+ 4+(a) 0 (b) byte (A) ← (A) or (eam) - - - - - * * R - - OR ear,A 2 3 2 0 byte (ear) ← (ear) or (A) - - - - - * * R - - OR eam,A 2+ 5+(a) 0 2 × (b) byte (eam) ← (eam) or (A) - - - - - * * R - * XOR A,#imm8 2 2 0 0 byte (A) ← (A) xor imm8 - - - - - * * R - - XOR A,ear 2 3 1 0 byte (A) ← (A) xor (ear) - - - - - * * R - - XOR A,eam 2+ 4+(a) 0 (b) byte (A) ← (A) xor (eam) - - - - - * * R - - XOR ear,A 2 3 2 0 byte (ear) ← (ear) xor (A) - - - - - * * R - - XOR eam,A 2+ 5+(a) 0 2 × (b) byte (eam) ← (eam) xor (A) - - - - - * * R - * NOT A 1 2 0 0 byte (A) ← not (A) - - - - - * * R - - NOT ear 2 3 2 0 byte (ear) ← not (ear) - - - - - * * R - - NOT eam 2+ 5+(a) 0 2 × (b) byte (eam) ← not (eam) - - - - - * * R - * ANDW A 1 2 0 0 word (A) ← (AH) and (A) - - - - - * * R - - ANDW A,#imm16 3 2 0 0 word (A) ← (A) and imm16 - - - - - * * R - - ANDW A,ear 2 3 1 0 word (A) ← (A) and (ear) - - - - - * * R - - ANDW A,eam 2+ 4+(a) 0 (c) word (A) ← (A) and (eam) - - - - - * * R - - word (ear) ← (ear) and (A) - - - - - * * R - - word (eam) ← (eam) and (A) - - - - - * * R - * 0 word (A) ← (AH) or (A) - - - - - * * R - - 0 word (A) ← (A) or imm16 - - - - - * * R - - 1 0 word (A) ← (A) or (ear) - - - - - * * R - - 4+(a) 0 (c) word (A) ← (A) or (eam) - - - - - * * R - - 2 3 2 0 word (ear) ← (ear) or (A) - - - - - * * R - - eam,A 2+ 5+(a) 0 2 × (c) word (eam) ← (eam) or (A) - - - - - * * R - * XORW A 1 2 0 0 word (A) ← (AH) xor (A) - - - - - * * R - - XORW A,#imm16 3 2 0 0 word (A) ← (A) xor imm16 - - - - - * * R - - XORW A,ear 2 3 1 0 word (A) ← (A) xor (ear) - - - - - * * R - - ANDW ear,A 2 3 2 0 ANDW eam,A 2+ 5+(a) 0 2 × (c) ORW A 1 2 0 ORW A,#imm16 3 2 0 ORW A,ear 2 3 ORW A,eam 2+ ORW ear,A ORW XORW A,eam 2+ 4+(a) 0 (c) word (A) ← (A) xor (eam) - - - - - * * R - XORW ear,A 2 3 2 0 word (ear) ← (ear) xor (A) - - - - - * * R - - XORW eam,A 2+ 5+(a) 0 2 × (c) word (eam) ← (eam) xor (A) - - - - - * * R - * NOTW A 1 2 0 0 word (A) ← not (A) - - - - - * * R - - NOTW ear 2 3 2 0 word (ear) ← not (ear) - - - - - * * R - - NOTW eam 2+ 5+(a) 0 2 × (c) word (eam) ← not (eam) - - - - - * * R - * Note: See Table D.5-1 and Table D.5-2 for information on (a) to (c) in the table. 601 APPENDIX Table D.8-9 6 Logic 2 Instructions (Long Word) Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW ANDL A,ear 2 6 2 0 long (A) ← (A) and (ear) - - - - - * * R - - ANDL A,eam 2+ 7+(a) 0 (d) long (A) ← (A) and (eam) - - - - - * * R - - ORL A,ear 2 6 2 0 long (A) ← (A) or (ear) - - - - - * * R - - ORL A,eam 2+ 7+(a) 0 (d) long (A) ← (A) or (eam) - - - - - * * R - - XORL A,ear 2 6 2 0 long (A) ← (A) xor (ear) - - - - - * * R - - XORL A,eam 2+ 7+(a) 0 (d) long (A) ← (A) xor (eam) - - - - - * * R - - Note: See Table D.5-1 and Table D.5-2 for information on (a) and (d) in the table. Table D.8-10 6 Sign Inversion Instructions (Byte, Word) Mnemonic NEG A # ~ RG B 1 2 0 0 byte (A) ← 0 - (A) byte (ear) ← 0 - (ear) - - - - - * * * * - byte (eam) ← 0 - (eam) - - - - - * * * * * word (A) ← 0 - (A) - - - - - * * * * - NEG ear 2 3 2 0 NEG eam 2+ 5+(a) 0 2 × (b) NEGW A 1 2 0 0 NEGW ear 2 3 2 0 NEGW eam 2+ 5+(a) 0 2 × (c) Operation LH AH I S T N Z V C RMW X - - - - * * * * - word (ear) ← 0 - (ear) - - - - - * * * * - word (eam) ← 0 - (eam) - - - - - * * * * * Note: See Table D.5-1 and Table D.5-2 for information on (a) to (c) in the table. Table D.8-11 1 Normalization Instruction (Long Word) Mnemonic NRML A,R0 # ~ RG B 2 *1 1 0 Operation long (A) ← Shift left to the position where '1' is set for the first time. byte (R0) ← Shift count at that time *1: 4 when all accumulators have a value of 0; otherwise, 6+(R0) 602 LH AH I S T N Z V C RMW - - - - - - * - - - APPENDIX D Instructions Table D.8-12 18 Shift Instructions (Byte, Word, Long Word) Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW RORC A 2 2 0 0 byte (A) ← Right rotation with carry - - - - - * * - * - ROLC A 2 2 0 0 byte (A) ← Right rotation with carry - - - - - * * - * - RORC ear 2 3 2 0 byte (ear) ← Right rotation with carry - - - - - * * - * - RORC eam 2+ 5+(a) 0 2 × (b) byte (eam) ← Right rotation with carry - - - - - * * - * * ROLC ear 2 3 2 0 byte (ear) ← Left rotation with carry - - - - - * * - * - ROLC eam 2+ 5+(a) 0 2 × (b) byte (eam) ← Left rotation with carry - - - - - * * - * * ASR A,R0 2 *1 1 0 byte (A) ← Arithmetic right shift (A, 1 bit) - - - - * * * - * - LSR A,R0 2 *1 1 0 byte (A) ← Logical right barrel shift (A, R0) - - - - * * * - * - LSL A,R0 2 *1 1 0 byte (A) ← Logical left barrel shift (A, R0) - - - - - * * - * - ASRW A 1 2 0 0 word (A) ← Arithmetic right shift (A, 1 bit) - - - - * * * - * - LSRW A/SHRW A 1 2 0 0 word (A) ← Logical right shift (A, 1 bit) - - - - * R * - * - LSLW A/SHLW A 1 2 0 0 word (A) ← Logical left shift (A, 1 bit) - - - - - * * - * - ASRW A,R0 2 *1 1 0 word (A) ← Arithmetic right barrel shift (A, R0) - - - - * * * - * - LSRW A,R0 2 *1 1 0 word (A) ← Logical right barrel shift (A, R0) - - - - * * * - * - LSLW A,R0 2 *1 1 0 word (A) ← Logical left barrel shift (A, R0) - - - - - * * - * - ASRL A,R0 2 *2 1 0 long (A) ← Arithmetic right barrel shift (A, R0) - - - - * * * - * - LSRL A,R0 2 *2 1 0 long (A) ← Logical right barrel shift (A, R0) - - - - * * * - * - LSLL A,R0 2 *2 1 0 long (A) ← Logical left barrel shift (A, R0) - - - - - * * - * - *1: 6 when R0 is 0; otherwise, 5 + (R0) *2: 6 when R0 is 0; otherwise, 6 + (R0) Note: See Table D.5-1 and Table D.5-2 for information on (a) and (b) in the table. 603 APPENDIX Table D.8-13 31 Branch 1 Instructions Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW BZ/BEQ rel 2 *1 0 0 Branch on (Z) = 1 - - - - - - - - - - BNZ/ BNE rel 2 *1 0 0 Branch on (Z) = 0 - - - - - - - - - - BC/BLO rel 2 *1 0 0 Branch on (C) = 1 - - - - - - - - - - BNC/ BHS rel 2 *1 0 0 Branch on (C) = 0 - - - - - - - - - - BN rel 2 *1 0 0 Branch on (N) = 1 - - - - - - - - - - BP rel 2 *1 0 0 Branch on (N) = 0 - - - - - - - - - - BV rel 2 *1 0 0 Branch on (V) = 1 - - - - - - - - - - BNV rel 2 *1 0 0 Branch on (V) = 0 - - - - - - - - - - BT rel 2 *1 0 0 Branch on (T) = 1 - - - - - - - - - - BNT rel 2 *1 0 0 Branch on (T) = 0 - - - - - - - - - - BLT rel 2 *1 0 0 Branch on (V) xor (N) = 1 - - - - - - - - - - BGE rel 2 *1 0 0 Branch on (V) xor (N) = 0 - - - - - - - - - - BLE rel 2 *1 0 0 Branch on ((V) xor (N)) or (Z) = 1 - - - - - - - - - - BGT rel 2 *1 0 0 Branch on ((V) xor (N)) or (Z) = 0 - - - - - - - - - - BLS rel 2 *1 0 0 Branch on (C) or (Z) = 1 - - - - - - - - - - BHI rel 2 *1 0 0 Branch on (C) or (Z) = 0 - - - - - - - - - - BRA rel 2 *1 0 0 Unconditional branch - - - - - - - - - - JMP @A 1 2 0 0 word (PC) ← (A) - - - - - - - - - - JMP addr16 3 3 0 0 word (PC) ← addr16 - - - - - - - - - - JMP @ear 2 3 1 0 word (PC) ← (ear) - - - - - - - - - JMP @eam 2+ 4+(a) 0 (c) word (PC) ← (eam) - - - - - - - - - - JMPP @ear *3 2 5 2 0 word (PC) ← (ear), (PCB) ← (ear+2) - - - - - - - - - - JMPP @eam *3 2+ 6+(a) 0 (d) JMPP addr24 4 4 0 0 word (PC) ← (eam), (PCB) ← (eam+2) - - - - - - - - - - word (PC) ← ad24 0-15, (PCB) ← ad24 16-23 - - - - - - - - - - CALL @ear *4 2 6 1 (c) word (PC) ← (ear) - - - - - - - - - - CALL @eam *4 2+ 7+(a) 0 2 × (c) word (PC) ← (eam) - - - - - - - - - - CALL addr16 *5 3 6 0 (c) word (PC) ← addr16 - - - - - - - - - - CALLV #vct4 *5 1 7 0 2 × (c) Vector call instruction - - - - - - - - - - CALLP @ear *6 2 10 2 2 × (c) word (PC) ← (ear), (PCB) ← (ear+2) - - - - - - - - - - CALLP @eam *6 2+ 11+(a) 0 *2 CALLP addr24 *7 4 10 0 2 × (c) word (PC) ← (eam), (PCB) ← (eam+2) - - - - - - - - - - word (PC) ← ad24 0-15, (PCB) ← ad24 16-23 - - - - - - - - - - *1: 4 when a branch is made; otherwise, 3 *2: 3 × (c) + (b) *3: Read (word) of branch destination address *4: W: Save to stack (word) R: Read (word) of branch destination address *5: Save to stack (word) *6: W: Save to stack (long word), R: Read (long word) of branch destination address *7: Save to stack (long word) Note: See Table D.5-1 and Table D.5-2 for information on (a) to (d) in the table. 604 APPENDIX D Instructions Table D.8-14 19 Branch 2 Instructions Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW CBNE A,#imm8,rel 3 *1 0 0 Branch on byte (A) not equal to imm8 - - - - - * * * * - CWBNE A,#imm16,rel 4 *1 0 0 Branch on word (A) not equal to imm16 - - - - - * * * * - CBNE ear,#imm8,rel 4 *2 1 0 Branch on byte (ear) not equal to imm8 - - - - - * * * * - CBNE eam,#imm8,rel *9 4+ *3 0 (b) Branch on byte (eam) not equal to imm8 - - - - - * * * * - CWBNE ear,#imm16,rel 5 *4 1 0 Branch on word (ear) not equal to imm16 - - - - - * * * * - CWBNE eam,#imm16,rel*9 5+ *3 0 (c) Branch on word (eam) not equal to imm16 - - - - - * * * * - DBNZ ear,rel 3 *5 2 0 byte (ear) ← (ear) - 1, Branch on (ear) not equal to 0 - - - - - * * * - * DBNZ eam,rel 3+ *6 2 DWBNZ ear,rel 3 *5 2 DWBNZ eam,rel 3+ *6 2 2 × (b) byte (eam) ← (eam) - 1, Branch on (eam) not equal to 0 - - - - - * * * - - - - - - * * * - - 2 × (c) word (eam) ← (eam) - 1, Branch on (eam) not equal to 0 - - - - - * * * - * 0 word (ear) ← (ear) - 1, Branch on (ear) not equal to 0 INT #vct8 2 20 0 8 × (c) Software interrupt - - R S - - - - - - INT addr16 3 16 0 6 × (c) Software interrupt - - R S - - - - - - INTP addr24 4 17 0 6 × (c) Software interrupt - - R S - - - - - - 1 20 0 8 × (c) Software interrupt - - R S - - - - - - INT9 RETI LINK #imm8 UNLINK 1 *8 0 *7 Return from interrupt - - * * * * * * * - 2 6 0 (c) Saves the old frame pointer in the stack upon entering the function, then sets the new frame pointer and reserves the local pointer area. - - - - - - - - - - 1 5 0 (c) Recovers the old frame pointer from the stack upon exiting the function. - - - - - - - - - - RET *10 1 4 0 (c) Return from subroutine - - - - - - - - - - RETP *11 1 6 0 (d) Return from subroutine - - - - - - - - - - *1: 5 when a branch is made; otherwise, 4 *2: 13 when a branch is made; otherwise, 12 *3: 7+(a) when a branch is made; otherwise, 6+(a) *4: 8 when a branch is made; otherwise, 7 *5: 7 when a branch is made; otherwise, 6 *6: 8+(a) when a branch is made; otherwise, 7+(a) *7: 3 × (b) + 2 × (c) when jumping to the next interruption request; 6 × (c) when returning from the current interruption *8: 15 when jumping to the next interruption request; 17 when returning from the current interruption *9: Do not use RWj+ addressing mode with a CBNE or CWBNE instruction. *10: Return from stack (word) *11: Return from stack (long word) Note: See Table D.5-1 and Table D.5-2 for information on (a) to (d) in the table. 605 APPENDIX Table D.8-15 28 Other Control Instructions (Byte, Word, Long Word) Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW PUSHW A 1 4 0 (c) word (SP) ← (SP) - 2, ((SP)) ← (A) - - - - - - - - - - PUSHW AH 1 4 0 (c) word (SP) ← (SP) - 2, ((SP)) ← (AH) - - - - - - - - - - PUSHW PS 1 4 0 (c) word (SP) ← (SP) - 2, ((SP)) ← (PS) - - - - - - - - - - PUSHW rlst 2 *3 *5 *4 (SP) ← (SP) - 2n, ((SP)) ← (rlst) - - - - - - - - - - POPW A 1 3 0 (c) word (A) ← ((SP)), (SP) ← (SP) + 2 - * - - - - - - - - POPW AH 1 3 0 (c) word (AH) ← ((SP)), (SP) ← (SP) + 2 - - - - - - - - - - POPW PS 1 4 0 (c) word (PS) ← ((SP)), (SP) ← (SP) + 2 - - * * * * * * * - POPW rlst 2 *2 *5 *4 (rlst) ← ((SP)), (SP) ← (SP) + 2n - - - - - - - - - - JCTX @A 1 14 0 6 × (c) Context switch instruction - - * * * * * * * - AND CCR,#imm8 2 3 0 0 byte (CCR) ← (CCR) and imm8 - - * * * * * * * - OR CCR,#imm8 2 3 0 0 byte (CCR) ← (CCR) or imm8 - - * * * * * * * - MOV RP,#imm8 2 2 0 0 byte (RP) ← imm8 - - - - - - - - - - MOV ILM,#imm8 2 2 0 0 byte (ILM) ← imm8 - - - - - - - - - - MOVEA RWi,ear 2 3 1 0 word (RWi) ← ear - - - - - - - - - - MOVEA RWi,eam 2+ 2+(a) 1 0 word (RWi) ← eam - - - - - - - - - - MOVEA A,ear 2 1 0 0 word (A) ← ear - * - - - - - - - - MOVEA A,eam 2+ 1+(a) 0 0 word (A) ← eam - * - - - - - - - - ADDSP #imm8 2 3 0 0 word (SP) ← (SP) + ext(imm8) - - - - - - - - - - ADDSP #imm16 3 3 0 0 word (SP) ← (SP) + imm16 - - - - - - - - - - MOV A,brg1 2 *1 0 0 byte (A) ← (brg1) Z * - - - * * - - - MOV brg2,A - 2 1 0 0 byte (brg2) ← (A) - - - - - * * - - NOP 1 1 0 0 No operation - - - - - - - - - - ADB 1 1 0 0 Prefix code for AD space access - - - - - - - - - - DTB 1 1 0 0 Prefix code for DT space access - - - - - - - - - - PCB 1 1 0 0 Prefix code for PC space access - - - - - - - - - - SPB 1 1 0 0 Prefix code for SP space access - - - - - - - - - - NCC 1 1 0 0 Prefix code for flag no-change - - - - - - - - - - CMR 1 1 0 0 Prefix code for common register bank - - - - - - - - - - *1: PCB, ADB, SSB, USB, SPB: 1, DTB, DPR: 2 *2: 7 + 3 × (POP count) + 2 × (POP last register number), 7 when RLST = 0 (no transfer register) *3: 29 + 3 × (PUSH count) - 3 × (PUSH last register number), 8 when RLST = 0 (no transfer register) *4: (POP count) × (c) or (PUSH count) × (c) *5: (POP count) or (PUSH count) Note: See Table D.5-1 and Table D.5-2 for information on (a) and (c) in the table. 606 APPENDIX D Instructions Table D.8-16 21 Bit Operand Instructions Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW MOVB A,dir:bp 3 5 0 (b) byte (A) ← (dir:bp)b Z * - - - * * - - - MOVB A,addr16:bp 4 5 0 (b) byte (A) ← (addr16:bp)b Z * - - - * * - - - MOVB A,io:bp 3 4 0 (b) byte (A) ← (io:bp)b Z * - - - * * - - - MOVB dir:bp,A 3 7 0 2 × (b) bit (dir:bp)b ← (A) - - - - - * * - - * MOVB addr16:bp,A 4 7 0 2 × (b) bit (addr16:bp)b ← (A) - - - - - * * - - * MOVB io:bp,A 3 6 0 2 × (b) bit (io:bp)b ← (A) - - - - - * * - - * * SETB dir:bp 3 7 0 2 × (b) bit (dir:bp)b ← 1 - - - - - - - - - SETB addr16:bp 4 7 0 2 × (b) bit (addr16:bp)b ← 1 - - - - - - - - - * SETB io:bp 3 7 0 2 × (b) bit (io:bp)b ← 1 - - - - - - - - - * * CLRB dir:bp 3 7 0 2 × (b) bit (dir:bp)b ← 0 - - - - - - - - - CLRB addr16:bp 4 7 0 2 × (b) bit (addr16:bp)b ← 0 - - - - - - - - - * CLRB io:bp 3 7 0 2 × (b) bit (io:bp)b ← 0 - - - - - - - - - * BBC dir:bp,rel 4 *1 0 (b) Branch on (dir:bp) b = 0 - - - - - - * - - - BBC addr16:bp,rel 5 *1 0 (b) Branch on (addr16:bp) b = 0 - - - - - - * - - - BBC io:bp,rel 4 *2 0 (b) Branch on (io:bp) b = 0 - - - - - - * - - - BBS dir:bp,rel 4 *1 0 (b) Branch on (dir:bp) b = 1 - - - - - - * - - - BBS addr16:bp,rel 5 *1 0 (b) Branch on (addr16:bp) b = 1 - - - - - - * - - - BBS io:bp,rel 4 *2 0 (b) Branch on (io:bp) b = 1 - - - - - - * - - - SBBS addr16:bp,rel 5 *3 0 2 × (b) Branch on (addr16:bp) b = 1, bit (addr16:bp) b ← 1 - - - - - - * - - * WBTS io:bp 3 *4 0 *5 Waits until (io:bp) b = 1 - - - - - - - - - - WBTC io:bp 3 *4 0 *5 Waits until (io:bp) b = 0 - - - - - - - - - - AH I S T N Z V C RMW *1: 8 when a branch is made; otherwise, 7 *2: 7 when a branch is made; otherwise, 6 *3: 10 when the condition is met; otherwise, 9 *4: Undefined count *5: Until the condition is met Note: See Table D.5-1 and Table D.5-2 for information on (b) in the table. Table D.8-17 6 Accumulator Operation Instructions (Byte, Word) Mnemonic # ~ RG B Operation LH SWAP 1 3 0 0 byte (A)0-7 ↔ (A)8-15 - - - - - - - - - - SWAPW 1 2 0 0 word (AH) ↔ (AL) - * - - - - - - - - EXT 1 1 0 0 Byte sign extension X - - - - * * - - - EXTW 1 2 0 0 Word sign extension - X - - - * * - - - ZEXT 1 1 0 0 Byte zero extension Z - - - - R * - - - ZEXTW 1 1 0 0 Word zero extension - Z - - - R * - - - 607 APPENDIX Table D.8-18 10 String Instructions Mnemonic # ~ RG B Operation LH AH I S T N Z V C RMW - MOVS / MOVSI 2 *2 *5 *3 byte transfer @AH+ ← @AL+, counter = RW0 - - - - - - - - - MOVSD 2 *2 *5 *3 byte transfer @AH- ← @AL-, counter = RW0 - - - - - - - - - - SCEQ / SCEQI 2 *1 *8 *4 byte search @AH+ ← AL, counter = RW0 - - - - - * * * * - SCEQD 2 *1 *8 *4 byte search @AH- ← AL, counter = RW0 - - - - - * * * * FILS / FILSI 2 6m+6 *8 *3 byte fill @AH+ ← AL, counter = RW0 - - - - - * * - - - MOVSW / MOVSWI 2 *2 *5 *6 word transfer @AH+ ← @AL+, counter = RW0 - - - - - - - - - - MOVSWD 2 *2 *5 *6 word transfer @AH- ← @AL-, counter = RW0 - - - - - - - - - - SCWEQ / SCWEQI 2 *1 *8 *7 word search @AH+ - AL, counter = RW0 - - - - - * * * * - SCWEQD 2 *1 *8 *7 word search @AH- - AL, counter = RW0 - - - - - * * * * - FILSW / FILSWI 2 6m+6 *8 *6 word fill @AH+ ← AL, counter = RW0 - - - - - * * - - - *1: 5 when RW0 is 0, 4 + 7 × (RW0) when the counter expires, or 7n + 5 when a match occurs *2: 5 when RW0 is 0; otherwise, 4 + 8 × (RW0) *3: (b) × (RW0) + (b) × (RW0) When the source and destination access different areas, calculate the (b) item individually. *4: (b) × n *5: 2 × (b) × (RW0) *6: (c) × (RW0) + (c) × (RW0) When the source and destination access different areas, calculate the (c) item individually. *7: (c) × n *8: (b) × (RW0) Note: m: RW0 value (counter value), n: Loop count See Table D.5-1 and Table D.5-2 for information on (b) and (c) in the table. 608 APPENDIX D Instructions D.9 Instruction Map Each F2MC-16LX instruction code consists of 1 or 2 bytes. Therefore, the instruction map consists of multiple pages. Table D.9-2 to Table D.9-21 summarize the F2MC-16LX instruction map. ■ Structure of Instruction Map Figure D.9-1 Structure of Instruction Map Basic page map Bit operation instructions Character string operation instructions 2-byte instructions : Byte 1 ea instructions × 9 : Byte 2 An instruction such as the NOP instruction that ends in one byte is completed within the basic page. An instruction such as the MOVS instruction that requires two bytes recognizes the existence of byte 2 when it references byte 1, and can check the following one byte by referencing the map for byte 2. Figure D.9-2 shows the correspondence between an actual instruction code and instruction map. 609 APPENDIX Figure D.9-2 Correspondence between Actual Instruction Code and Instruction Map Some instructions do not contain byte 2. Instruction code Length varies depending on the instruction. Byte 1 Byte 2 Operand Operand ... [Basic page map] XY +Z [Extended page map]* UV +W *: The extended page map is a generic name of maps for bit operation instructions, character string operation instructions, 2-byte instructions, and ea instructions. Actually, there are multiple extended page maps for each type of instructions. An example of an instruction code is shown in Table D.9-1. Table D.9-1 Example of an Instruction Code Byte 1 (from basic page map) Byte 2 (from extended page map) NOP 00 +0=00 - AND A, #8 30 +4=34 - MOV A, ADB 60 +F=6F 00 +0=00 @RW2+d8, #8, rel 70 +0=70 F0 +2=F2 Instruction 610 +F +E +D +C +B +A +9 +8 +7 +6 +5 +4 +3 +2 +1 +0 A ZEXT SWAP ADDSP DTB ADB SPB #8 A, #8 dir, A A, dir io, A A, io JMP BRA 60 MULU DIVU ea @A instruction 2 A MOVW MOVX RET SP, A A, addr16 A0 B0 C0 ea instruction 8 D0 E0 rel rel LSRW ASRW LSLW SWAPW ZEXTW XORW ORW ANDW ORW PUSHW POPW A, #16 AH AH MOVW ea, RWi Bit operation MOV A instruction ea, Ri MOVW RWi, ea PUSHW POPW 2-byte XCHW A rlst rlst instruction RWi, ea Character XORW PUSHW POPW XCH operation A A, #16 PS PS string Ri, ea instruction A ANDW PUSHW POPW A A, #16 A CMPW MOVL MOVW RETI A, #16 A, #32 addr16, A ADDSP MULUW NOTW A #16 A A A EXTW A BHI BLS BGT BLE rel rel rel rel rel BGE CMPL CMPW A, #32 NEGW A rel rel rel rel rel rel BLT BT BNV BV BP BN BNC/BHS rel BC/BLO BNZ/BNE rel BZ/BEQ MOV MOV CBNE A, CWBNE A, MOVW MOVW INTP MOV RP, #8 ILM, #8 #8, rel #16, rel A, #16 A,addr16 addr24 Ri, ea #4 F0 rel ADDW MOVW MOVW INT ea MOVW MOVW MOVW MOV A, MOVW A, #16 A, dir A, io #vct8 instruction 9 A, RWi RWi, A RWi, #16 @RWi+d8 @RWi+d8, A NOT ea instruction 7 MOVX MOVX CALLP ea A, dir A, io addr24 instruction 6 MOVW MOVW RETP A, #8 A, SP io, #16 A, #8 90 BNT SUBL SUBW A, #32 A A A XOR OR OR CCR, #8 80 ea MOV MOV MOV MOV MOVX A, MOV CALL rel instruction 1 A, Ri Ri, A Ri, #8 A, Ri @RWi+d8 A, #4 70 MOV JMP ea A, addr16 addr16 instruction 3 MOV MOV 50 MOVX MOV JMPP ea A, #8 A, #8 addr16, A addr24 instruction 4 MOV MOV MOV 40 SUBW MOVW MOVW INT MOVEA A A, #16 dir, A io, A addr16 RWi, ea UNLINK A CMP A A, #8 A, #8 SUBC SUB ADD 30 AND AND MOV MOV CALL ea CCR, #8 A, #8 dir, #8 io, #8 addr16 instruction 5 CMP A A, dir A, dir ADDC SUB ADD 20 LINK ADDL ADDW #imm8 A, #32 EXT @A PCB A JCTX SUBDC ADDDC NEG NCC INT9 A CMR 10 NOP 00 APPENDIX D Instructions Table D.9-2 Basic Page Map 611 612 +F +E +D +C +B +A +9 +8 +7 +6 +5 +4 +3 +2 +1 +0 10 MOVB io:bp, A 20 30 CLRB io:bp 40 50 SETB io:bp 60 70 BBC io;bp, rel 80 90 BBS io:bp, rel A0 B0 MOVB MOVB A, MOVB MOVB CLRB CLRB SETB SETB BBC BBC BBS BBS A, dir:bp addr16:bp dir:bp, A addr16:bp,A dir:bp addr16:bp dir:bp addr16:bp dir:bp, rel addr16:bp,rel dir:bp, rel addr16:bp,rel MOVB A, io:bp 00 WBTS io:bp C0 D0 WBTC io:bp E0 SBBS addr16:bp F0 APPENDIX Table D.9-3 Bit Operation Instruction Map (First Byte = 6CH) MOVSI MOVSD PCB, PCB PCB, DTB PCB, ADB PCB, SPB DTB, PCB DTB, DTB DTB, ADB DTB, SPB ADB, PCB ADB, DTB ADB, ADB ADB, SPB SPB, PCB SPB, DTB SPB, ADB SPB, SPB +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F 10 +0 00 MOVSWI 20 MOVSWD 30 40 50 60 70 90 A0 B0 C0 SPB ADB DTB SPB ADB DTB SPB ADB DTB SPB ADB DTB SPB ADB DTB SCEQI SCEQD SCWEQI SCWEQD FILSI PCB PCB PCB PCB PCB 80 D0 FILSI SPB ADB DTB PCB E0 F0 APPENDIX D Instructions Table D.9-4 Character String Operation Instruction Map (First Byte = 6EH) 613 614 LSLW LSLL LSL MOVW MOVW A, R0 A, R0 A, R0 @RL2+d8, A A, @RL2+d8 MOVW MOVW NRML A, @A @AL, AH A, R0 ASRW ASRL ASR MOVW MOVW A, R0 A, R0 A, R0 @RL3+d8, A A, @RL3+d8 LSRW LSRL LSR A, R0 A, R0 A, R0 +D +E +F MOVW MOVW @RL1+d8, A A, @RL1+d8 MOVW MOVW @RL0+d8, A A, @RL0+d8 +C +B +A +9 +8 A MOV MOV MOVX MOV MOV A, PCB A, @A A, @RL3+d8 @RL3+d8, A A, @RL3+d8 +6 ROLC MOV MOV A, @A @AL, AH +5 A MOV MOV MOVX MOV MOV A, DPR DPR, A A, @RL2+d8 @RL2+d8, A A, @RL2+d8 +4 ROLC MOV MOV A, USB USB, A +3 +7 MOV MOV MOVX MOV MOV A, SSB SSB, A A, @RL1+d8 @RL1+d8, A A, @RL1+d8 +2 40 MOV MOV A, ADB ADB, A 30 +1 20 MOV MOV MOVX MOV MOV A, DTB DTB, A A, @RL0+d8 @RL0+d8, A A, @RL0+d8 10 +0 00 50 DIVU MULW MUL 60 A A A 70 80 90 A0 B0 C0 D0 E0 F0 APPENDIX Table D.9-5 2-byte Instruction Map (First Byte = 6FH) 50 90 B0 D0 @RW1, @RW1+d16 CMPL CMPL A, ANDL ANDL A, ORL ORL A, XORL XORL A, #16, rel #16, rel A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 @RW2, @RW2+d16 CMPL CMPL A, ANDL ANDL A, ORL ORL A, XORL XORL A, #16, rel #16, rel A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 @RW3, @RW3+d16 CMPL CMPL A, ANDL ANDL A, ORL ORL A, XORL XORL A, #16, rel #16, rel A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 SUBL SUBL A, A, RL2 @RW5+d8 SUBL SUBL A, A, RL3 @RW6+d8 SUBL SUBL A, A, RL3 @RW7+d8 ADDL ADDL A, A, RL2 @RW5+d8 ADDL ADDL A, A, RL3 @RW6+d8 ADDL ADDL A, A, RL3 @RW7+d8 ADDL ADDL A, SUBL SUBL A, A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 ADDL ADDL A, SUBL SUBL A, A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 ADDL ADDL A, SUBL SUBL A, A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 ADDL ADDL A, SUBL SUBL A, A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 ADDL ADDL A, SUBL SUBL A, Use @RW0+RW7 CMPL CMPL A, ANDL ANDL A, ORL ORL A, XORL XORL A, Use @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 prohibited #16, rel A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 prohibited ,#8, rel ADDL ADDL A, SUBL SUBL A, Use @RW1+RW7 CMPL CMPL A, ANDL ANDL A, ORL ORL A, XORL XORL A, Use @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 prohibited #16, rel A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 prohibited ,#8, rel ADDL ADDL A, A,@RW2+ @PC+d16 ADDL ADDL A, SUBL SUBL A, Use A,@RW3+ addr16 A,@RW3+ addr16 prohibited +5 +6 +7 +8 +9 +A +B +C +D +E +F SUBL SUBL A, A,@RW2+ @PC+d16 @RW0, @RW0+d16 CMPL CMPL A, ANDL ANDL A, ORL ORL A, XORL XORL A, #16, rel #16, rel A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 SUBL SUBL A, A, RL2 @RW4+d8 Use prohibited ANDL ANDL A, A,@RW2+ @PC+d16 ANDL ANDL A, A, RL3 @RW7+d8 ANDL ANDL A, A, RL3 @RW6+d8 ANDL ANDL A, A, RL2 @RW5+d8 ANDL ANDL A, A, RL2 @RW4+d8 ORL ORL A, A,@RW2+ @PC+d16 ORL ORL A, A, RL3 @RW7+d8 ORL ORL A, A, RL3 @RW6+d8 ORL ORL A, A, RL2 @RW5+d8 ORL ORL A, A, RL2 @RW4+d8 XORL XORL A, A,@RW2+ @PC+d16 XORL XORL A, A, RL3 @RW7+d8 XORL XORL A, A, RL3 @RW6+d8 XORL XORL A, A, RL2 @RW5+d8 XORL XORL A, A, RL2 @RW4+d8 XORL XORL A, A, RL1 @RW3+d8 addr16, ,#8, rel Use @PC+d16, prohibited ,#8, rel @RW3, @RW3+d16 #8, rel ,#8, rel @RW2, @RW2+d16 #8, rel ,#8, rel @RW1, @RW1+d16 #8, rel ,#8, rel @RW0, @RW0+d16 #8, rel ,#8, rel R7, @RW7+d8, #8, rel #8, rel R6, @RW6+d8, #8, rel #8, rel R5, @RW5+d8, #8, rel #8, rel R4, @RW4+d8, #8, rel #8, rel R3, @RW3+d8, #8, rel #8, rel addr16, CMPL CMPL A, ANDL ANDL A, ORL ORL A, XORL XORL A, Use #16, rel A,@RW3+ addr16 A,@RW3+ addr16 A,@RW3+ addr16 A,@RW3+ addr16 prohibited @PC+d16, CMPL CMPL A, #16, rel A,@RW2+ @PC+d16 RW7, @RW7+d8 CMPL CMPL A, #16, rel #16, rel A, RL3 @RW7+d8 RW6, @RW6+d8 CMPL CMPL A, #16, rel #16, rel A, RL3 @RW6+d8 RW5, @RW5+d8 CMPL CMPL A, #16, rel #16, rel A, RL2 @RW5+d8 RW4, @RW4+d8 CMPL CMPL A, #16, rel #16, rel A, RL2 @RW4+d8 ORL ORL A, A, RL1 @RW3+d8 R2, @RW2+d8, #8, rel #8, rel R1, @RW1+d8, #8, rel #8, rel ADDL ADDL A, A, RL2 @RW4+d8 ANDL ANDL A, A, RL1 @RW3+d8 XORL XORL A, A, RL1 @RW2+d8 XORL XORL A, A, RL0 @RW1+d8 +4 RW3, @RW3+d8 CMPL CMPL A, #16, rel #16, rel A, RL1 @RW3+d8 ORL ORL A, A, RL1 @RW2+d8 ORL ORL A, A, RL0 @RW1+d8 SUBL SUBL A, A, RL1 @RW3+d8 ANDL ANDL A, A, RL1 @RW2+d8 ANDL ANDL A, A, RL0 @RW1+d8 ADDL ADDL A, A, RL1 @RW3+d8 RW2, @RW2+d8 CMPL CMPL A, #16, rel #16, rel A, RL1 @RW2+d8 RW1, @RW1+d8 CMPL CMPL A, #16, rel #16, rel A, RL0 @RW1+d8 +3 CBNE ↓ F0 R0, @RW0+d8, #8, rel #8, rel CBNE ↓ E0 SUBL SUBL A, A, RL1 @RW2+d8 XORL XORL A, A, RL0 @RW0+d8 C0 ADDL ADDL A, A, RL1 @RW2+d8 ORL ORL A, A, RL0 @RW0+d8 A0 +2 ANDL ANDL A, A, RL0 @RW0+d8 80 SUBL SUBL A, A, RL0 @RW1+d8 70 ADDL ADDL A, A, RL0 @RW1+d8 60 RW0, @RW0+d8 CMPL CMPL A, #16, rel #16, rel A, RL0 @RW0+d8 CWBNE ↓ CWBNE ↓ 40 +1 30 +0 20 SUBL SUBL A, A, RL0 @RW0+d8 10 ADDL ADDL A, A, RL0 @RW0+d8 00 APPENDIX D Instructions Table D.9-6 ea Instruction 1 (First Byte = 70H) 615 616 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL3 @@RW7+d8 @RL3 @@RW7+d8 RL3 @RW7+d8 RL3 @RW7+d8 A, RL3 @RW7+d8 RL3, A @RW7+d8,A R7, #8 @RW7+d8,#8 A, RW7 @RW7+d8 JMPP JMPP @ CALLP CALLP @ INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW0 @RW0+d16 @@RW0 @RW0+d16 @RW0 @RW0+d16 @RW0 @RW0+d16 A,@RW0 @RW0+d16 @RW0,A @RW0+d16,A @RW0, #8 @RW0+d16,#8 A,@RW0 @RW0+d16 JMPP JMPP @ CALLP CALLP @ INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW1 @RW1+d16 @@RW1 @RW1+d16 @RW1 @RW1+d16 @RW1 @RW1+d16 A,@RW1 @RW1+d16 @RW1,A @RW1+d16,A @RW1, #8 @RW1+d16,#8 A,@RW1 @RW1+d16 JMPP JMPP @ CALLP CALLP @ INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW2 @RW2+d16 @@RW2 @RW2+d16 @RW2 @RW2+d16 @RW2 @RW2+d16 A,@RW2 @RW2+d16 @RW2,A @RW2+d16,A @RW2, #8 @RW2+d16,#8 A,@RW2 @RW2+d16 JMPP JMPP @ CALLP CALLP @ INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW3 @RW3+d16 @@RW3 @RW3+d16 @RW3 @RW3+d16 @RW3 @RW3+d16 A,@RW3 @RW3+d16 @RW3,A @RW3+d16,A @RW3, #8 @RW3+d16,#8 A,@RW3 @RW3+d16 JMPP JMPP @ CALLP CALLP @ INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW0+ @RW0+RW7 @@RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 @RW0+,A @RW0+RW7,A @RW0+, #8 @RW0+RW7,#8 A,@RW0+ @RW0+RW7 JMPP JMPP @ CALLP CALLP @ INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW1+ @RW1+RW7 @@RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 @RW1+,A @RW1+RW7,A @RW1+, #8 @RW1+RW7,#8 A,@RW1+ @RW1+RW7 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW2+ @@PC+d16 @@RW2+ @@PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 A,@RW2+ @PC+d16 @RW2+,A @PC+d16, A @RW2+, #8 @PC+d16, #8 A,@RW2+ @PC+d16 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @@RW3+ @addr16 @@RW3+ @addr16 @RW3+ addr16 @RW3+ addr16 A,@RW3+ addr16 @RW3+,A addr16, A @RW3+, #8 addr16, #8 A,@RW3+ addr16 +8 +9 +A +B +C +D +E +F F0 +7 E0 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL3 @@RW6+d8 @RL3 @@RW6+d8 RL3 @RW6+d8 RL3 @RW6+d8 A, RL3 @RW6+d8 RL3, A @RW6+d8,A R6, #8 @RW6+d8,#8 A, RW6 @RW6+d8 D0 +6 C0 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL2 @@RW5+d8 @RL2 @@RW5+d8 RL2 @RW5+d8 RL2 @RW5+d8 A, RL2 @RW5+d8 RL2, A @RW5+d8,A R5, #8 @RW5+d8,#8 A, RW5 @RW5+d8 B0 +5 A0 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL2 @@RW4+d8 @RL2 @@RW4+d8 RL2 @RW4+d8 RL2 @RW4+d8 A, RL2 @RW4+d8 RL2, A @RW4+d8,A R4, #8 @RW4+d8,#8 A, RW4 @RW4+d8 90 +4 80 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL1 @@RW3+d8 @RL1 @@RW3+d8 RL1 @RW3+d8 RL1 @RW3+d8 A, RL1 @RW3+d8 RL1, A @RW3+d8,A R3, #8 @RW3+d8,#8 A, RW3 @RW3+d8 70 +3 60 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL1 @@RW2+d8 @RL1 @@RW2+d8 RL1 @RW2+d8 RL1 @RW2+d8 A, RL1 @RW2+d8 RL1, A @RW2+d8,A R2, #8 @RW2+d8,#8 A, RW2 @RW2+d8 50 +2 40 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL0 @@RW1+d8 @RL0 @@RW1+d8 RL0 @RW1+d8 RL0 @RW1+d8 A, RL0 @RW1+d8 RL0, A @RW1+d8,A R1, #8 @RW1+d8,#8 A, RW1 @RW1+d8 30 +1 20 JMPP JMPP CALLP CALLP INCL INCL DECL DECL MOVL MOVL A, MOVL MOVL MOV MOV MOVEA MOVEA A, @RL0 @@RW0+d8 @RL0 @@RW0+d8 RL0 @RW0+d8 RL0 @RW0+d8 A, RL0 @RW0+d8 RL0, A @RW0+d8,A R0, #8 @RW0+d8,#8 A, RW0 @RW0+d8 10 +0 00 APPENDIX Table D.9-7 ea Instruction 2 (First Byte = 71H) D0 E0 F0 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 @RW0+, A @RW0+RW7,A A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 @RW1+, A @RW1+RW7,A A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 A,@RW2+ @PC+d16 @RW2+, A @PC+d16, A A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 A,@RW3+ addr16 @RW3+, A addr16, A A,@RW3+ addr16 A,@RW3+ addr16 +D +E +F DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R7 @RW7+d8 A, R7 @RW7+d8 R7, A @RW7+d8,A A, R7 @RW7+d8 A, R7 @RW7+d8 DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R6 @RW6+d8 A, R6 @RW6+d8 R6, A @RW6+d8,A A, R6 @RW6+d8 A, R6 @RW6+d8 DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R5 @RW5+d8 A, R5 @RW5+d8 R5, A @RW5+d8,A A, R5 @RW5+d8 A, R5 @RW5+d8 DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R4 @RW4+d8 A, R4 @RW4+d8 R4, A @RW4+d8,A A, R4 @RW4+d8 A, R4 @RW4+d8 DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R3 @RW3+d8 A, R3 @RW3+d8 R3, A @RW3+d8,A A, R3 @RW3+d8 A, R3 @RW3+d8 DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R2 @RW2+d8 A, R2 @RW2+d8 R2, A @RW2+d8,A A, R2 @RW2+d8 A, R2 @RW2+d8 DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R1 @RW1+d8 A, R1 @RW1+d8 R1, A @RW1+d8,A A, R1 @RW1+d8 A, R1 @RW1+d8 +C INC DEC R7 @RW7+d8 C0 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW3 @RW3+d16 @RW3 @RW3+d16 @RW3 @RW3+d16 @RW3 @RW3+d16 A,@RW3 @RW3+d16 @RW3, A @RW3+d16,A A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 ROLC RORC RORC INC R7 @RW7+d8 R7 @RW7+d8 ROLC INC DEC R6 @RW6+d8 B0 +B ROLC RORC RORC INC R6 @RW6+d8 R6 @RW6+d8 ROLC INC DEC R5 @RW5+d8 A0 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW2 @RW2+d16 @RW2 @RW2+d16 @RW2 @RW2+d16 @RW2 @RW2+d16 A,@RW2 @RW2+d16 @RW2, A @RW2+d16,A A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 ROLC RORC RORC INC R5 @RW5+d8 R5 @RW5+d8 ROLC INC DEC R4 @RW4+d8 90 +A ROLC RORC RORC INC R4 @RW4+d8 R4 @RW4+d8 ROLC INC DEC R3 @RW3+d8 INC DEC R2 @RW2+d8 INC DEC R1 @RW1+d8 80 DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, R0 @RW0+d8 A, R0 @RW0+d8 R0, A @RW0+d8,A A, R0 @RW0+d8 A, R0 @RW0+d8 70 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW1 @RW1+d16 @RW1 @RW1+d16 @RW1 @RW1+d16 @RW1 @RW1+d16 A,@RW1 @RW1+d16 @RW1, A @RW1+d16,A A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 ROLC RORC RORC INC R3 @RW3+d8 R3 @RW3+d8 ROLC 60 INC DEC R0 @RW0+d8 50 +9 ROLC RORC RORC INC R2 @RW2+d8 R2 @RW2+d8 ROLC 40 ROLC ROLC RORC RORC INC INC DEC DEC MOV MOV A, MOV MOV MOVX MOVX A, XCH XCH A, @RW0 @RW0+d16 @RW0 @RW0+d16 @RW0 @RW0+d16 @RW0 @RW0+d16 A,@RW0 @RW0+d16 @RW0, A @RW0+d16,A A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 ROLC RORC RORC INC R1 @RW1+d8 R1 @RW1+d8 ROLC 30 ROLC RORC RORC INC R0 @RW0+d8 R0 @RW0+d8 20 ROLC 10 +8 +7 +6 +5 +4 +3 +2 +1 +0 00 APPENDIX D Instructions Table D.9-8 ea Instruction 3 (First Byte = 72H) 617 618 JMP JMP @ CALL CALL @ INCW INCW @ DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @@RW3 @RW3+d16 @@RW3 @RW3+d16 @RW3 @RW3+d16 @RW3 @RW3+d16 A,@RW3 @RW3+d16 @RW3, A @RW3+d16,A @RW3, #16 @RW3+d16,#16 A,@RW3 @RW3+d16 +B JMP JMP CALL CALL INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @@RW3+ @addr16 @@RW3+ @addr16 @RW3+ addr16 @RW3+ addr16 A,@RW3+ addr16 @RW3+, A addr16, A @RW3+, #16 addr16, #16 A,@RW3+ addr16 INCW @ +F INCW JMP JMP CALL CALL INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @@RW2+ @@PC+d16 @@RW2+ @@PC+d16 @RW2+ @@PC+d16 @RW2+ @PC+d16 A,@RW2+ @PC+d16 @RW2+, A @PC+d16, A @RW2+, #16 @PC+d16, #16 A,@RW2+ @PC+d16 CALL @ +E CALL DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 @RW1+, A @RW1+RW7,A @RW1+, #16 @RW1+RW7,#16 A,@RW1+ @RW1+RW7 XCHW XCHW A, A, RW7 @RW7+d8 XCHW XCHW A, A, RW6 @RW6+d8 XCHW XCHW A, A, RW5 @RW5+d8 +D @@RW1+ @RW1+RW7 @@RW1+ @RW1+RW7 @RW1+ @RW1+RW7 INCW @ MOVW MOVW RW7, #16 @RW7+d8,#16 MOVW MOVW RW6, #16 @RW6+d8,#16 MOVW MOVW RW5, #16 @RW5+d8,#16 XCHW XCHW A, A, RW4 @RW4+d8 DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 @RW0+, A @RW0+RW7,A @RW0+, #16 @RW0+RW7,#16 A,@RW0+ @RW0+RW7 INCW INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW7 @RW7+d8 RW7 @RW7+d8 A, RW7 @RW7+d8 RW7, A @RW7+d8,A INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW6 @RW6+d8 RW6 @RW6+d8 A, RW6 @RW6+d8 RW6, A @RW6+d8,A INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW5 @RW5+d8 RW5 @RW5+d8 A, RW5 @RW5+d8 RW5, A @RW5+d8,A MOVW MOVW RW4, #16 @RW4+d8,#16 +C @@RW0+ @RW0+RW7 @@RW0+ @RW0+RW7 @RW0+ @RW0+RW7 JMP @ JMP JMP @ CALL CALL @ INCW INCW @ DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @@RW2 @RW2+d16 @@RW2 @RW2+d16 @RW2 @RW2+d16 @RW2 @RW2+d16 A,@RW2 @RW2+d16 @RW2, A @RW2+d16,A @RW2, #16 @RW2+d16,#16 A,@RW2 @RW2+d16 +A JMP JMP JMP @ CALL CALL @ INCW INCW @ DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @@RW1 @RW1+d16 @@RW1 @RW1+d16 @RW1 @RW1+d16 @RW1 @RW1+d16 A,@RW1 @RW1+d16 @RW1, A @RW1+d16,A @RW1, #16 @RW1+d16,#16 A,@RW1 @RW1+d16 +9 CALL @ JMP JMP @ CALL CALL @ INCW INCW @ DECW DECW MOVW MOVW A, MOVW MOVW MOVW MOVW XCHW XCHW A, @@RW0 @RW0+d16 @@RW0 @RW0+d16 @RW0 @RW0+d16 @RW0 @RW0+d16 A,@RW0 @RW0+d16 @RW0,A @RW0+d16,A @RW0, #16 @RW0+d16,#16 A,@RW0 @RW0+d16 +8 CALL CALL CALL RW7 @@RW7+d8 JMP JMP @RW7 @@RW7+d8 +7 JMP @ CALL CALL RW6 @@RW6+d8 JMP JMP @RW6 @@RW6+d8 +6 JMP CALL CALL RW5 @@RW5+d8 JMP JMP @RW5 @@RW5+d8 +5 INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW4 @RW4+d8 RW4 @RW4+d8 A, RW4 @RW4+d8 RW4, A @RW4+d8,A XCHW XCHW A, A, RW3 @RW3+d8 XCHW XCHW A, A, RW2 @RW2+d8 XCHW XCHW A, A, RW1 @RW1+d8 CALL CALL RW4 @@RW4+d8 MOVW MOVW RW3, #16 @RW3+d8,#16 MOVW MOVW RW2, #16 @RW2+d8,#16 MOVW MOVW RW1, #16 @RW1+d8,#16 JMP JMP @RW4 @@RW4+d8 INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW3 @RW3+d8 RW3 @RW3+d8 A, RW3 @RW3+d8 RW3, A @RW3+d8,A INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW2 @RW2+d8 RW2 @RW2+d8 A, RW2 @RW2+d8 RW2, A @RW2+d8,A INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW1 @RW1+d8 RW1 @RW1+d8 A, RW1 @RW1+d8 RW1, A @RW1+d8,A +4 F0 XCHW XCHW A, A, RW0 @RW0+d8 E0 CALL CALL RW3 @@RW3+d8 D0 MOVW MOVW RW0, #16 @RW0+d8,#16 C0 JMP JMP @RW3 @@RW3+d8 B0 +3 A0 CALL CALL RW2 @@RW2+d8 90 JMP JMP @RW2 @@RW2+d8 80 +2 70 CALL CALL RW1 @@RW1+d8 60 JMP JMP @RW1 @@RW1+d8 50 INCW INCW DECW DECW MOVW MOVW A, MOVW MOVW RW0 @RW0+d8 RW0 @RW0+d8 A, RW0 @RW0+d8 RW0, A @RW0+d8,A 40 +1 30 CALL CALL RW0 @@RW0+d8 20 JMP JMP @RW0 @@RW0+d8 10 +0 00 APPENDIX Table D.9-9 ea Instruction 4 (First Byte = 73H) ADD A, SUB SUB SUB ADDC A, ADDC A, ADDC ADDC A, A, CMP CMP CMP CMP A, A, A, AND AND AND AND AND AND A, A, A, OR OR A, XOR XOR A, DBNZ DBNZ @ A,@RW2+ @PC+d16, A,@RW2+ @PC+d16 @RW2+, r PC+d16, r +F A,@RW3+ ADD ADD SUB SUB ADDC ADDC CMP CMP AND AND OR OR XOR XOR DBNZ DBNZ A, addr16 A,@RW3+ A, addr16 A,@RW3+ A, addr16 A,@RW3+ A, addr16 A,@RW3+ A, addr16 A,@RW3+ A, addr16 A,@RW3+ A, addr16 @RW3+, r addr16, r +E A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 ADD SUB CMP XOR XOR A, DBNZ DBNZ @R A,@RW1+ @RW1+RW7 @RW1+, r W1+RW7, r A, CMP OR OR A, A,@RW1+ @RW1+RW7 ADD ADD ADDC A, +D A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 ADDC XOR XOR A, DBNZ DBNZ @R A,@RW0+ @RW0+RW7 @RW0+, r W0+RW7, r A, OR OR A, A,@RW0+ @RW0+RW7 SUB +C A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 SUB XOR XOR A, DBNZ DBNZ @R A,@RW3 @RW3+d16 @RW3, r W3+d16, r ADD ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 +B A, XOR XOR A, DBNZ DBNZ @R A,@RW2 @RW2+d16 @RW2, r W2+d16, r ADD ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 +A ADD XOR XOR A, DBNZ DBNZ @R A,@RW1 @RW1+d16 @RW1, r W1+d16, r ADD ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 +9 ADD XOR XOR A, DBNZ DBNZ @R A,@RW0 @RW0+d16 @RW0, r W0+d16, r ADD ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R7 @RW7+d8 A, R7 @RW7+d8 A, R7 @RW7+d8 A, R7 @RW7+d8 A, R7 @RW7+d8 A, R7 @RW7+d8 A, R7 @RW7+d8 R7, r RW7+d8, r ADD F0 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R6 @RW6+d8 A, R6 @RW6+d8 A, R6 @RW6+d8 A, R6 @RW6+d8 A, R6 @RW6+d8 A, R6 @RW6+d8 A, R6 @RW6+d8 R6, r RW6+d8, r E0 ADD D0 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R5 @RW5+d8 A, R5 @RW5+d8 A, R5 @RW5+d8 A, R5 @RW5+d8 A, R5 @RW5+d8 A, R5 @RW5+d8 A, R5 @RW5+d8 R5, r RW5+d8, r C0 ADD B0 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R4 @RW4+d8 A, R4 @RW4+d8 A, R4 @RW4+d8 A, R4 @RW4+d8 A, R4 @RW4+d8 A, R4 @RW4+d8 A, R4 @RW4+d8 R4, r RW4+d8, r A0 ADD 90 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R3 @RW3+d8 A, R3 @RW3+d8 A, R3 @RW3+d8 A, R3 @RW3+d8 A, R3 @RW3+d8 A, R3 @RW3+d8 A, R3 @RW3+d8 R3, r RW3+d8, r 80 ADD 70 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R2 @RW2+d8 A, R2 @RW2+d8 A, R2 @RW2+d8 A, R2 @RW2+d8 A, R2 @RW2+d8 A, R2 @RW2+d8 A, R2 @RW2+d8 R2, r RW2+d8, r 60 ADD 50 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R1 @RW1+d8 A, R1 @RW1+d8 A, R1 @RW1+d8 A, R1 @RW1+d8 A, R1 @RW1+d8 A, R1 @RW1+d8 A, R1 @RW1+d8 R1, r RW1+d8, r 40 ADD 30 ADD A, SUB SUB A, ADDC ADDC A, CMP CMP A, AND AND A, OR OR A, XOR XOR A, DBNZ DBNZ @ A, R0 @RW0+d8 A, R0 @RW0+d8 A, R0 @RW0+d8 A, R0 @RW0+d8 A, R0 @RW0+d8 A, R0 @RW0+d8 A, R0 @RW0+d8 R0, r RW0+d8, r 20 ADD 10 +8 +7 +6 +5 +4 +3 +2 +1 +0 00 APPENDIX D Instructions Table D.9-10 ea Instruction 5 (First Byte = 74H) 619 620 NOT NOT R2 @RW2+d8 SUB SUB SUB SUB ADD SUB SUB @RW1+RW7,A @RW1+, A @RW1+RW7,A ADD @R @RW0+RW7,A @RW0+, A @RW0+RW7,A ADD @R +F ADD ADD @RW3+, A addr16, A SUB SUB @RW3+, A addr16, A +E @RW2+, A @PC+d16,A @RW2+, A @PC+d16,A ADD +D @RW1+, A ADD +C @RW0+, A ADD NOT NOT @RW1+ @RW1+RW7 NOT NOT @RW0+ @RW0+RW7 SUBC SUBC A, NEG NEG A, AND AND A,@RW3+ addr16 @RW3+ addr16 @RW3+, A addr16, A OR OR @RW3+, A addr16, A XOR XOR @RW3+, A addr16, A NOT NOT @RW3+ addr16 SUBC SUBC A, NEG NEG A, AND AND OR OR XOR XOR NOT NOT A,@RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+, A @PC+d16,A @RW2+, A @PC+d16,A @RW2+, A @PC+d16,A @RW2+ @PC+d16 SUBC SUBC A, NEG NEG A, AND AND OR OR XOR XOR A,@RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+, A @RW1+RW7,A @RW1+, A @RW1+RW7,A @RW1+, A @RW1+RW7,A SUBC SUBC A, NEG NEG A, AND AND OR OR XOR XOR A,@RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+, A @RW0+RW7,A @RW0+, A @RW0+RW7,A @RW0+, A @RW0+RW7,A NOT NOT @RW3 @RW3+d16 ADD ADD @R SUB SUB SUBC SUBC A, NEG NEG A, AND AND OR OR XOR XOR @RW3, A @RW3+d16,A @RW3, A @RW3+d16,A A, @RW3 @RW3+d16 @RW3 @RW3+d16 @RW3, A @RW3+d16,A @RW3, A @RW3+d16,A @RW3, A @RW3+d16,A +B XOR NOT NOT R7, A @RW7+d8, A R7 @RW7+d8 XOR NOT NOT R6, A @RW6+d8, A R6 @RW6+d8 XOR NOT NOT R5, A @RW5+d8, A R5 @RW5+d8 XOR NOT NOT R4, A @RW4+d8, A R4 @RW4+d8 XOR NOT NOT R3, A @RW3+d8, A R3 @RW3+d8 XOR R2, A @RW2+d8,A XOR NOT NOT R1, A @RW1+d8, A R1 @RW1+d8 NOT NOT @RW2 @RW2+d16 XOR F0 ADD ADD @R SUB SUB SUBC SUBC A, NEG NEG A, AND AND OR OR XOR XOR @RW2, A @RW2+d16,A @RW2, A @RW2+d16,A A, @RW2 @RW2+d16 @RW2 @RW2+d16 @RW2, A @RW2+d16,A @RW2, A @RW2+d16,A @RW2, A @RW2+d16,A NEG A, AND AND OR OR R7 @RW7+d8 R7, A @RW7+d8, A R7, A @RW7+d8, A XOR XOR XOR XOR XOR XOR E0 XOR NOT NOT R0, A @RW0+d8, A R0 @RW0+d8 D0 +A ADD SUB SUB SUBC SUBC A, NEG R7, A @RW7+d8, A R7, A @RW7+d8, A A, R7 @RW7+d8 ADD NEG A, AND AND OR OR R6 @RW6+d8 R6, A @RW6+d8, A R6, A @RW6+d8, A NEG A, AND AND OR OR R5 @RW5+d8 R5, A @RW5+d8, A R5, A @RW5+d8, A NEG A, AND AND OR OR R4 @RW4+d8 R4, A @RW4+d8, A R4, A @RW4+d8, A NEG A, AND AND OR OR R3 @RW3+d8 R3, A @RW3+d8, A R3, A @RW3+d8, A NEG A, AND AND OR OR R2 @RW2+d8 R2, A @RW2+d8,A R2, A @RW2+d8,A NEG A, AND AND OR OR R1 @RW1+d8 R1, A @RW1+d8, A R1, A @RW1+d8, A XOR C0 NOT NOT @RW1 @RW1+d16 ADD SUB SUB SUBC SUBC A, NEG R6, A @RW6+d8, A R6, A @RW6+d8, A A, R6 @RW6+d8 ADD B0 ADD ADD @R SUB SUB SUBC SUBC A, NEG NEG A, AND AND OR OR XOR XOR @RW1, A @RW1+d16,A @RW1, A @RW1+d16,A A, @RW1 @RW1+d16 @RW1 @RW1+d16 @RW1, A @RW1+d16,A @RW1, A @RW1+d16,A @RW1, A @RW1+d16,A ADD SUB SUB SUBC SUBC A, NEG R5, A @RW5+d8, A R5, A @RW5+d8, A A, R5 @RW5+d8 ADD A0 +9 ADD SUB SUB SUBC SUBC A, NEG R4, A @RW4+d8, A R4, A @RW4+d8, A A, R4 @RW4+d8 ADD 90 NOT NOT @RW0 @RW0+d16 ADD SUB SUB SUBC SUBC A, NEG R3, A @RW3+d8, A R3, A @RW3+d8, A A, R3 @RW3+d8 ADD 80 NEG A, AND AND OR OR R0 @RW0+d8 R0, A @RW0+d8, A R0, A @RW0+d8, A 70 ADD ADD SUB SUB SUBC SUBC A, NEG NEG A, AND AND OR OR XOR XOR @RW0, A @RW0+d16,A @RW0, A @RW0+d16,A A, @RW0 @RW0+d16 @RW0 @RW0+d16 @RW0, A @RW0+d16,A @RW0, A @RW0+d16,A @RW0, A @RW0+d16,A ADD SUB SUB SUBC SUBC A, NEG R2, A @RW2+d8,A R2, A @RW2+d8,A A, R2 @RW2+d8 60 ADD 50 ADD SUB SUB SUBC SUBC A, NEG R1, A @RW1+d8, A R1, A @RW1+d8, A A, R1 @RW1+d8 40 ADD 30 ADD SUB SUB SUBC SUBC A, NEG R0, A @RW0+d8, A R0, A @RW0+d8, A A, R0 @RW0+d8 20 ADD 10 +8 +7 +6 +5 +4 +3 +2 +1 +0 00 APPENDIX Table D.9-11 ea Instruction 6 (First Byte = 75H) ADDW A, SUBW ADDW ADDCW CMPW ADDCW A, CMPW ADDCW A, ANDW CMPW A, ANDW CMPW A, ORW ORW ANDW A, ORW ANDW A, ANDW A, ORW ORW ORW A, A, A, XORW XORW A, DWBNZ DWBNZ +F A,@RW3+ ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ addr 16 A,@RW3+ addr 16 A,@RW3+ addr 16 A,@RW3+ addr 16 A,@RW3+ addr 16 A,@RW3+ addr16 A,@RW3+ addr 16 @RW3+, r addr16, r +E A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16, A,@RW2+ @PC+d16 @RW2+, r @PC+d16,r SUBW A, ADDCW SUBW A, ANDW XORW XORW A, DWBNZ DWBNZ A,@RW1+ @RW1+RW7 @RW1+, r @RW1+RW7,r SUBW ADDW A, ADDW CMPW A, +D A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 CMPW XORW XORW A, DWBNZ DWBNZ A,@RW0+ @RW0+RW7 @RW0+, r @RW0+RW7,r ADDCW A, +C A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 ADDCW XORW XORW A, DWBNZ DWBNZ A,@RW3 @RW3+d16 @RW3, r @RW3+d16,r ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 +B SUBW A, XORW XORW A, DWBNZ DWBNZ A,@RW2 @RW2+d16 @RW2, r @RW2+d16,r ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 +A SUBW XORW XORW A, DWBNZ DWBNZ A,@RW1 @RW1+d16 @RW1, r @RW1+d16,r ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 +9 ADDW A, XORW XORW A, DWBNZ DWBNZ A,@RW0 @RW0+d16 @RW0, r @RW0+d16,r ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 +8 ADDW ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW7 @RW7+d8 A, RW7 @RW7+d8 A, RW7 @RW7+d8 A, RW7 @RW7+d8 A, RW7 @RW7+d8 A, RW7 @RW7+d8 A, RW7 @RW7+d8 RW7, r @RW7+d8,r F0 +7 E0 ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW6 @RW6+d8 A, RW6 @RW6+d8 A, RW6 @RW6+d8 A, RW6 @RW6+d8 A, RW6 @RW6+d8 A, RW6 @RW6+d8 A, RW6 @RW6+d8 RW6, r @RW6+d8,r D0 +6 C0 ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW5 @RW5+d8 A, RW5 @RW5+d8 A, RW5 @RW5+d8 A, RW5 @RW5+d8 A, RW5 @RW5+d8 A, RW5 @RW5+d8 A, RW5 @RW5+d8 RW5, r @RW5+d8,r B0 +5 A0 ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW4 @RW4+d8 A, RW4 @RW4+d8 A, RW4 @RW4+d8 A, RW4 @RW4+d8 A, RW4 @RW4+d8 A, RW4 @RW4+d8 A, RW4 @RW4+d8 RW4, r @RW4+d8,r 90 +4 80 ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW3 @RW3+d8 A, RW3 @RW3+d8 A, RW3 @RW3+d8 A, RW3 @RW3+d8 A, RW3 @RW3+d8 A, RW3 @RW3+d8 A, RW3 @RW3+d8 RW3, r @RW3+d8,r 70 +3 60 ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW2 @RW2+d8 A, RW2 @RW2+d8 A, RW2 @RW2+d8 A, RW2 @RW2+d8 A, RW2 @RW2+d8 A, RW2 @RW2+d8 A, RW2 @RW2+d8 RW2, r @RW2+d8,r 50 +2 40 ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW1 @RW1+d8 A, RW1 @RW1+d8 A, RW1 @RW1+d8 A, RW1 @RW1+d8 A, RW1 @RW1+d8 A, RW1 @RW1+d8 A, RW1 @RW1+d8 RW1, r @RW1+d8,r 30 +1 20 ADDW ADDW A, SUBW SUBW A, ADDCW ADDCW A, CMPW CMPW A, ANDW ANDW A, ORW ORW A, XORW XORW A, DWBNZ DWBNZ A, RW0 @RW0+d8 A, RW0 @RW0+d8 A, RW0 @RW0+d8 A, RW0 @RW0+d8 A, RW0 @RW0+d8 A, RW0 @RW0+d8 A, RW0 @RW0+d8 RW0, r @RW0+d8,r 10 +0 00 APPENDIX D Instructions Table D.9-12 ea Instruction 7 (First Byte = 76H) 621 622 NEGW NEGW ANDW ANDW ORW ORW XORW XORW NOTW NOTW @RW3 @RW3+d16 @RW3, A @RW3+d16,A @RW3, A @RW3+d16,A @RW3, A @RW3+d16,A @RW3 @RW3+d16 SUBW SUBW @RW3+, A addr16, A ADDW ADDW @RW3+, A addr16, A +F SUBCW SUBCW A, NEGW NEGW ANDW ANDW A,@RW3+ addr16 @RW3+ addr16 @RW3+, A addr16, A ORW ORW @RW3+, A addr16, A XORW XORW @RW3+, A addr16, A NOTW NOTW @RW3+ addr16 SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW XORW XORW NOTW NOTW A,@RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+, A @PC+d16,A @RW2+, A @PC+d16,A @RW2+, A @PC+d16,A @RW2+ @PC+d16 SUBW SUBW @RW2+, A @PC+d16,A ADDW ADDW @RW2+, A @PC+d16,A +E SUBCW A, ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW XORW XORW NOTW NOTW @RW1+, A @RW1+RW7,A @RW1+, A @RW1+RW7,A A,@RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+, A @RW1+RW7,A @RW1+, A @RW1+RW7,A @RW1+, A @RW1+RW7,A @RW1+ @RW1+RW7 SUBCW +D SUBW SUBCW A, ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW XORW XORW NOTW NOTW @RW0+, A @RW0+RW7,A @RW0+, A @RW0+RW7,A A,@RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+, A @RW0+RW7,A @RW0+, A @RW0+RW7,A @RW0+, A @RW0+RW7,A @RW0+ @RW0+RW7 SUBW SUBCW +C ADDW ADDW SUBW SUBCW A, +B @RW3, A @RW3+d16,A @RW3, A @RW3+d16,A A, @RW3 @RW3+d16 SUBW SUBCW NEGW NEGW ANDW ANDW ORW ORW XORW XORW NOTW NOTW @RW2 @RW2+d16 @RW2, A @RW2+d16,A @RW2, A @RW2+d16,A @RW2, A @RW2+d16,A @RW2 @RW2+d16 ADDW ADDW SUBW +A @RW2, A @RW2+d16,A @RW2, A @RW2+d16,A A, @RW2 @RW2+d16 SUBW NEGW NEGW ANDW ANDW ORW ORW XORW XORW NOTW NOTW @RW1 @RW1+d16 @RW1, A @RW1+d16,A @RW1, A @RW1+d16,A @RW1, A @RW1+d16,A @RW1 @RW1+d16 ADDW ADDW SUBCW A, +9 @RW1, A @RW1+d16,A @RW1, A @RW1+d16,A A, @RW1 @RW1+d16 SUBCW NEGW NEGW ANDW ANDW ORW ORW XORW XORW NOTW NOTW @RW0 @RW0+d16 @RW0, A @RW0+d16,A @RW0, A @RW0+d16,A @RW0, A @RW0+d16,A @RW0 @RW0+d16 SUBW NOTW NOTW RW7 @RW7+d8 NOTW NOTW RW6 @RW6+d8 NOTW NOTW RW5 @RW5+d8 +8 @RW0, A @RW0+d16,A @RW0, A @RW0+d16,A A, @RW0 @RW0+d16 SUBW XORW XORW RW7, A @RW7+d8, A ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW RW7, A @RW7+d8, A RW7, A @RW7+d8, A A, RW7 @RW7+d8 RW7 @RW7+d8 RW7, A @RW7+d8, A RW7, A @RW7+d8, A +7 ADDW XORW XORW RW6, A @RW6+d8, A ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW RW6, A @RW6+d8, A RW6, A @RW6+d8, A A, RW6 @RW6+d8 RW6 @RW6+d8 RW6, A @RW6+d8, A RW6, A @RW6+d8, A +6 ADDW XORW XORW RW5, A @RW5+d8, A ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW RW5, A @RW5+d8, A RW5, A @RW5+d8, A A, RW5 @RW5+d8 RW5 @RW5+d8 RW5, A @RW5+d8, A RW5, A @RW5+d8, A +5 NOTW NOTW RW4 @RW4+d8 XORW XORW RW4, A @RW4+d8, A ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW RW4, A @RW4+d8, A RW4, A @RW4+d8, A A, RW4 @RW4+d8 RW4 @RW4+d8 RW4, A @RW4+d8, A RW4, A @RW4+d8, A +4 F0 NOTW NOTW RW0 @RW0+d8 E0 NOTW NOTW RW3 @RW3+d8 D0 XORW XORW RW3, A @RW3+d8, A C0 ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW RW3, A @RW3+d8, A RW3, A @RW3+d8, A A, RW3 @RW3+d8 RW3 @RW3+d8 RW3, A @RW3+d8, A RW3, A @RW3+d8, A B0 +3 A0 NOTW NOTW RW2 @RW2+d8 90 ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW XORW XORW RW2, A @RW2+d8,A RW2, A @RW2+d8,A A, RW2 @RW2+d8 RW2 @RW2+d8 RW2, A @RW2+d8,A RW2, A @RW2+d8,A RW2, A @RW2+d8,A 80 +2 70 NOTW NOTW RW1 @RW1+d8 60 XORW XORW RW1, A @RW1+d8, A 50 ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW RW1, A @RW1+d8, A RW1, A @RW1+d8, A A, RW1 @RW1+d8 RW1 @RW1+d8 RW1, A @RW1+d8, A RW1, A @RW1+d8, A 40 +1 30 XORW XORW RW0, A @RW0+d8, A 20 ADDW ADDW SUBW SUBW SUBCW SUBCW A, NEGW NEGW ANDW ANDW ORW ORW RW0, A @RW0+d8, A RW0, A @RW0+d8, A A, RW0 @RW0+d8 RW0 @RW0+d8 RW0, A @RW0+d8, A RW0, A @RW0+d8, A 10 +0 00 APPENDIX Table D.9-13 ea Instruction 8 (First Byte = 77H) DIV DIV A, DIVW DIVW A, A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 DIV DIV A, DIVW DIVW A, A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, A, @RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, A, @RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, A, @RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 MULU MULU A, MULUW MULUW A, A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 MULU MULU A, MULUW MULUW A, A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 MULU MULU A, MULUW MULUW A, A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 A,@RW0+ @RW0+RW7 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 A,@RW1+ @RW1+RW7 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 A,@RW2+ @PC+d16 +9 +A +B +C +D +E +F A, @RW3+ MULU DIV DIV A, DIVW DIVW A, A,@RW3 @RW3+d16 A,@RW3 @RW3+d16 MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, A, @RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 MULU MULU A, MULUW MULUW A, A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 +8 MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV addr16 A,@RW3+ addr16 A,@RW3+ addr16 A,@RW3+ addr16 A,@RW3+ addr16 A,@RW3+ addr16 A,@RW3+ A, DIVW DIVW A, addr16 A,@RW3+ addr16 DIV DIV A, DIVW DIVW A, A,@RW2 @RW2+d16 A,@RW2 @RW2+d16 DIV DIV A, DIVW DIVW A, A,@RW1 @RW1+d16 A,@RW1 @RW1+d16 DIV DIV A, DIVW DIVW A, A,@RW0 @RW0+d16 A,@RW0 @RW0+d16 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R7 @RW7+d8 A, RW7 @RW7+d8 A, R7 @RW7+d8 A, RW7 @RW7+d8 A, R7 @RW7+d8 A, RW7 @RW7+d8 A, R7 @RW7+d8 A, RW7 @RW7+d8 F0 +7 E0 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R6 @RW6+d8 A, RW6 @RW6+d8 A, R6 @RW6+d8 A, RW6 @RW6+d8 A, R6 @RW6+d8 A, RW6 @RW6+d8 A, R6 @RW6+d8 A, RW6 @RW6+d8 D0 +6 C0 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R5 @RW5+d8 A, RW5 @RW5+d8 A, R5 @RW5+d8 A, RW5 @RW5+d8 A, R5 @RW5+d8 A, RW5 @RW5+d8 A, R5 @RW5+d8 A, RW5 @RW5+d8 B0 +5 A0 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R4 @RW4+d8 A, RW4 @RW4+d8 A, R4 @RW4+d8 A, RW4 @RW4+d8 A, R4 @RW4+d8 A, RW4 @RW4+d8 A, R4 @RW4+d8 A, RW4 @RW4+d8 90 +4 80 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R3 @RW3+d8 A, RW3 @RW3+d8 A, R3 @RW3+d8 A, RW3 @RW3+d8 A, R3 @RW3+d8 A, RW3 @RW3+d8 A, R3 @RW3+d8 A, RW3 @RW3+d8 70 +3 60 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R2 @RW2+d8 A, RW2 @RW2+d8 A, R2 @RW2+d8 A, RW2 @RW2+d8 A, R2 @RW2+d8 A, RW2 @RW2+d8 A, R2 @RW2+d8 A, RW2 @RW2+d8 50 +2 40 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R1 @RW1+d8 A, RW1 @RW1+d8 A, R1 @RW1+d8 A, RW1 @RW1+d8 A, R1 @RW1+d8 A, RW1 @RW1+d8 A, R1 @RW1+d8 A, RW1 @RW1+d8 30 +1 20 MULU MULU A, MULUW MULUW A, MUL MUL A, MULW MULW A, DIVU DIVU A, DIVUW DIVUW A, DIV DIV A, DIVW DIVW A, A, R0 @RW0+d8 A, RW0 @RW0+d8 A, R0 @RW0+d8 A, RW0 @RW0+d8 A, R0 @RW0+d8 A, RW0 @RW0+d8 A, R0 @RW0+d8 A, RW0 @RW0+d8 10 +0 00 APPENDIX D Instructions Table D.9-14 ea Instruction 9 (First Byte = 78H) 623 624 MOVEA MOVEA RW1 RW1,RW4 ,@RW4+d8 MOVEA MOVEA RW1 RW1,RW5 ,@RW5+d8 MOVEA MOVEA RW1 RW1,RW6 ,@RW6+d8 MOVEA MOVEA RW1 RW1,RW7 ,@RW7+d8 MOVEA MOVEA RW1 RW1,@RW0 ,@RW0+d16 MOVEA MOVEA RW1 RW1,@RW1 ,@RW1+d16 MOVEA MOVEA RW1 RW1,@RW2 ,@RW2+d16 MOVEA MOVEA RW1 RW1,@RW3 ,@RW3+d16 MOVEA MOVEA RW0 RW0,RW4 ,@RW4+d8 MOVEA MOVEA RW0 RW0,RW5 ,@RW5+d8 MOVEA MOVEA RW0 RW0,RW6 ,@RW6+d8 MOVEA MOVEA RW0 RW0,RW7 ,@RW7+d8 MOVEA RW0 MOVEA RW0 MOVEA RW0 MOVEA RW0 MOVEA RW0 MOVEA RW0 MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA +4 +5 +6 +7 50 70 90 B0 C0 D0 F0 MOVEA MOVEA RW3 RW3,@RW2+ ,@PC+d16 MOVEA MOVEA RW4 RW4,@RW2+ ,@PC+d16 MOVEA MOVEA RW7 RW7,@RW2+ ,@PC+d16 MOVEA MOVEA MOVEA MOVEA RW6,@RW3+ RW6, addr16 RW7@RW3+ RW7, addr16 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,@RW2+ ,@PC+d16 RW6,@RW2+ ,@PC+d16 MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA MOVEA RW0,@RW3+ RW0, addr16 RW1,@RW3+ RW1, addr16 RW2,@RW3+ RW2, addr16 RW3,@RW3+ RW3, addr16 RW4,@RW3+ RW4, addr16 RW5,@RW3+ RW5, addr16 MOVEA MOVEA RW2 RW2,@RW2+ ,@PC+d16 +F MOVEA MOVEA RW1 RW1,@RW2+ ,@PC+d16 MOVEA MOVEA RW0 RW0,@RW2+ ,@PC+d16 MOVEA RW1 +E MOVEA MOVEA MOVEA RW5 MOVEA MOVEA RW6 MOVEA MOVEA RW7 RW5,@RW1+ ,@RW1+RW7 RW6,@RW1+ ,@RW1+RW7 RW7,@RW1+ ,@RW1+RW7 MOVEA MOVEA RW7 RW7,@RW3 ,@RW3+d16 MOVEA MOVEA RW7 RW7,@RW2 ,@RW2+d16 MOVEA MOVEA RW7 RW7,@RW1 ,@RW1+d16 MOVEA MOVEA RW7 RW7,@RW0 ,@RW0+d16 MOVEA MOVEA RW7 RW7,RW7 ,@RW7+d8 MOVEA MOVEA RW7 RW7,RW6 ,@RW6+d8 MOVEA MOVEA RW7 RW7,RW5 ,@RW5+d8 MOVEA MOVEA RW7 RW7,RW4 ,@RW4+d8 MOVEA MOVEA RW7 RW7,RW3 ,@RW3+d8 MOVEA MOVEA RW7 RW7,RW2 ,@RW2+d8 MOVEA MOVEA RW7 RW7,RW1 ,@RW1+d8 MOVEA MOVEA RW7 RW7,RW0 ,@RW0+d8 E0 MOVEA MOVEA RW2 MOVEA MOVEA RW3 MOVEA MOVEA RW4 RW2,@RW1+ ,@RW1+RW7 RW3,@RW1+ ,@RW1+RW7 RW4,@RW1+ ,@RW1+RW7 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,@RW3 ,@RW3+d16 RW6,@RW3 ,@RW3+d16 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,@RW2 ,@RW2+d16 RW6,@RW2 ,@RW2+d16 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,@RW1 ,@RW1+d16 RW6,@RW1 ,@RW1+d16 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,@RW0 ,@RW0+d16 RW6,@RW0 ,@RW0+d16 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW7 ,@RW7+d8 RW6,RW7 ,@RW7+d8 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW6 ,@RW6+d8 RW6,RW6 ,@RW6+d8 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW5 ,@RW5+d8 RW6,RW5 ,@RW5+d8 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW4 ,@RW4+d8 RW6,RW4 ,@RW4+d8 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW3 ,@RW3+d8 RW6,RW3 ,@RW3+d8 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW2 ,@RW2+d8 RW6,RW2 ,@RW2+d8 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW1 ,@RW1+d8 RW6,RW1 ,@RW1+d8 MOVEA MOVEA RW5 MOVEA MOVEA RW6 RW5,RW0 ,@RW0+d8 RW6,RW0 ,@RW0+d8 A0 +D RW0,@RW1+ ,@RW1+RW7 RW1,@RW1+ ,@RW1+RW7 MOVEA MOVEA RW4 RW4,@RW3 ,@RW3+d16 MOVEA MOVEA RW4 RW4,@RW2 ,@RW2+d16 MOVEA MOVEA RW4 RW4,@RW1 ,@RW1+d16 MOVEA MOVEA RW4 RW4,@RW0 ,@RW0+d16 MOVEA MOVEA RW4 RW4,RW7 ,@RW7+d8 MOVEA MOVEA RW4 RW4,RW6 ,@RW6+d8 MOVEA MOVEA RW4 RW4,RW5 ,@RW5+d8 MOVEA MOVEA RW4 RW4,RW4 ,@RW4+d8 MOVEA MOVEA RW4 RW4,RW3 ,@RW3+d8 MOVEA MOVEA RW4 RW4,RW2 ,@RW2+d8 MOVEA MOVEA RW4 RW4,RW1 ,@RW1+d8 MOVEA MOVEA RW4 RW4,RW0 ,@RW0+d8 80 MOVEA MOVEA RW5 MOVEA MOVEA RW6 MOVEA MOVEA RW7 RW5,@RW0+ ,@RW0+RW7 RW6,@RW0+ ,@RW0+RW7 RW7,@RW0+ ,@RW0+RW7 MOVEA MOVEA RW3 RW3,@RW3 ,@RW3+d16 MOVEA MOVEA RW3 RW3,@RW2 ,@RW2+d16 MOVEA MOVEA RW3 RW3,@RW1 ,@RW1+d16 MOVEA MOVEA RW3 RW3,@RW0 ,@RW0+d16 MOVEA MOVEA RW3 RW3,RW7 ,@RW7+d8 MOVEA MOVEA RW3 RW3,RW6 ,@RW6+d8 MOVEA MOVEA RW3 RW3,RW5 ,@RW5+d8 MOVEA MOVEA RW3 RW3,RW4 ,@RW4+d8 MOVEA MOVEA RW3 RW3,RW3 ,@RW3+d8 MOVEA MOVEA RW3 RW3,RW2 ,@RW2+d8 MOVEA MOVEA RW3 RW3,RW1 ,@RW1+d8 MOVEA MOVEA RW3 RW3,RW0 ,@RW0+d8 60 MOVEA MOVEA RW2 MOVEA MOVEA RW3 MOVEA MOVEA RW4 RW2,@RW0+ ,@RW0+RW7 RW3,@RW0+ ,@RW0+RW7 RW4,@RW0+ ,@RW0+RW7 MOVEA MOVEA RW2 RW2,@RW3 ,@RW3+d16 MOVEA MOVEA RW2 RW2,@RW2 ,@RW2+d16 MOVEA MOVEA RW2 RW2,@RW1 ,@RW1+d16 MOVEA MOVEA RW2 RW2,@RW0 ,@RW0+d16 MOVEA MOVEA RW2 RW2,RW7 ,@RW7+d8 MOVEA MOVEA RW2 RW2,RW6 ,@RW6+d8 MOVEA MOVEA RW2 RW2,RW5 ,@RW5+d8 MOVEA MOVEA RW2 RW2,RW4 ,@RW4+d8 MOVEA MOVEA RW2 RW2,RW3 ,@RW3+d8 MOVEA MOVEA RW2 RW2,RW2 ,@RW2+d8 MOVEA MOVEA RW2 RW2,RW1 ,@RW1+d8 MOVEA MOVEA RW2 RW2,RW0 ,@RW0+d8 40 +C RW0,@RW0+ ,@RW0+RW7 RW1,@RW0+ ,@RW0+RW7 +B RW0,@RW3 ,@RW3+d16 +A RW0,@RW2 ,@RW2+d16 +9 RW0,@RW1 ,@RW1+d16 MOVEA RW1 MOVEA MOVEA RW1 RW1,RW3 ,@RW3+d8 MOVEA MOVEA RW0 RW0,RW3 ,@RW3+d8 +3 MOVEA MOVEA MOVEA RW1 RW1,RW2 ,@RW2+d8 MOVEA MOVEA RW0 RW0,RW2 ,@RW2+d8 +2 +8 RW0,@RW0 ,@RW0+d16 MOVEA MOVEA RW1 RW1,RW1 ,@RW1+d8 MOVEA MOVEA RW0 RW0,RW1 ,@RW1+d8 +1 30 MOVEA MOVEA RW1 RW1,RW0 ,@RW0+d8 20 MOVEA MOVEA RW0 RW0,RW0 ,@RW0+d8 10 +0 00 APPENDIX Table D.9-15 MOVEA RWi, ea Instruction (First Byte = 79H) MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R7 @RW7+d8 R1, R7 @RW7+d8 R2, R7 @RW7+d8 R3, R7 @RW7+d8 R4, R7 @RW7+d8 R5, R7 @RW7+d8 R6, R7 @RW7+d8 R7, R7 @RW7+d8 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0,@RW0 @RW0+d16 R1,@RW0 @RW0+d16 R2,@RW0 @RW0+d16 R3,@RW0 @RW0+d16 R4,@RW0 @RW0+d16 R5,@RW0 @RW0+d16 R6,@RW0 @RW0+d16 R7,@RW0 @RW0+d16 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0,@RW1 @RW1+d16 R1,@RW1 @RW1+d16 R2,@RW1 @RW1+d16 R3,@RW1 @RW1+d16 R4,@RW1 @RW1+d16 R5,@RW1 @RW1+d16 R6,@RW1 @RW1+d16 R7,@RW1 @RW1+d16 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0,@RW2 @RW2+d16 R1,@RW2 @RW2+d16 R2,@RW2 @RW2+d16 R3,@RW2 @RW2+d16 R4,@RW2 @RW2+d16 R5,@RW2 @RW2+d16 R6,@RW2 @RW2+d16 R7,@RW2 @RW2+d16 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0,@RW3 @RW3+d16 R1,@RW3 @RW3+d16 R2,@RW3 @RW3+d16 R3,@RW3 @RW3+d16 R4,@RW3 @RW3+d16 R5,@RW3 @RW3+d16 R6,@RW3 @RW3+d16 R7,@RW3 @RW3+d16 MOV R0, MOV R0, MOV R1, MOV R1, MOV R2, MOV R2, MOV R3, MOV R3, MOV R4, MOV R4, MOV R5, MOV R5, MOV R6, MOV R6, MOV R7, MOV R7, @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 @RW0+ @RW0+RW7 MOV R0, MOV R0, MOV R1, MOV R1, MOV R2, MOV R2, MOV R3, MOV R3, MOV R4, MOV R4, MOV R5, MOV R5, MOV R6, MOV R6, MOV R7, MOV R7, @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 @RW1+ @RW1+RW7 MOV R0, MOV R0, MOV R1, MOV R1, MOV R2, MOV R2, MOV R3, MOV R3, MOV R4, MOV R4, MOV R5, MOV R5, MOV R6, MOV R6, MOV R7, MOV R7, @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 @RW2+ @PC+d16 MOV R0, MOV R0, MOV R1, MOV R1, MOV R2, MOV R2, MOV R3, MOV R3, MOV R4, MOV R4, MOV R5, MOV R5, MOV R6, MOV R6, MOV R7, MOV R7, @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 @RW3+ addr16 +8 +9 +A +B +C +D +E +F F0 +7 E0 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R6 @RW6+d8 R1, R6 @RW6+d8 R2, R6 @RW6+d8 R3, R6 @RW6+d8 R4, R6 @RW6+d8 R5, R6 @RW6+d8 R6, R6 @RW6+d8 R7, R6 @RW6+d8 D0 +6 C0 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R5 @RW5+d8 R1, R5 @RW5+d8 R2, R5 @RW5+d8 R3, R5 @RW5+d8 R4, R5 @RW5+d8 R5, R5 @RW5+d8 R6, R5 @RW5+d8 R7, R5 @RW5+d8 B0 +5 A0 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R4 @RW4+d8 R1, R4 @RW4+d8 R2, R4 @RW4+d8 R3, R4 @RW4+d8 R4, R4 @RW4+d8 R5, R4 @RW4+d8 R6, R4 @RW4+d8 R7, R4 @RW4+d8 90 +4 80 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R3 @RW3+d8 R1, R3 @RW3+d8 R2, R3 @RW3+d8 R3, R3 @RW3+d8 R4, R3 @RW3+d8 R5, R3 @RW3+d8 R6, R3 @RW3+d8 R7, R3 @RW3+d8 70 +3 60 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R2 @RW2+d8 R1, R2 @RW2+d8 R2, R2 @RW2+d8 R3, R2 @RW2+d8 R4, R2 @RW2+d8 R5, R2 @RW2+d8 R6, R2 @RW2+d8 R7, R2 @RW2+d8 50 +2 40 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R1 @RW1+d8 R1, R1 @RW1+d8 R2, R1 @RW1+d8 R3, R1 @RW1+d8 R4, R1 @RW1+d8 R5, R1 @RW1+d8 R6, R1 @RW1+d8 R7, R1 @RW1+d8 30 +1 20 MOV MOV R0, MOV MOV R1, MOV MOV R2, MOV MOV R3, MOV MOV R4, MOV MOV R5, MOV MOV R6, MOV MOV R7, R0, R0 @RW0+d8 R1, R0 @RW0+d8 R2, R0 @RW0+d8 R3, R0 @RW0+d8 R4, R0 @RW0+d8 R5, R0 @RW0+d8 R6, R0 @RW0+d8 R7, R0 @RW0+d8 10 +0 00 APPENDIX D Instructions Table D.9-16 MOV Ri, ea Instruction (First Byte = 7AH) 625 626 MOVW MOVW RW5, RW5,@RW3 @RW3+d16 MOVW MOVW MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW0,@RW1 @RW1+d16 RW1,@RW1 @RW1+d16 RW2,@RW1 @RW1+d16 RW3,@RW1 @RW1+d16 RW4,@RW1 @RW1+d16 MOVW MOVW MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW0,@RW2 @RW2+d16 RW1,@RW2 @RW2+d16 RW2,@RW2 @RW2+d16 RW3,@RW2 @RW2+d16 RW4,@RW2 @RW2+d16 MOVW MOVW MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW0,@RW3 @RW3+d16 RW1,@RW3 @RW3+d16 RW2,@RW3 @RW3+d16 RW3,@RW3 @RW3+d16 RW4,@RW3 @RW3+d16 MOVW MOVW MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, MOVW MOVW RW5, MOVW MOVW RW6, MOVW MOVW RW7, RW0,@RW0+ @RW0+RW7 RW1,@RW0+ @RW0+RW7 RW2,@RW0+ @RW0+RW7 RW3,@RW0+ @RW0+RW7 RW4,@RW0+ @RW0+RW7 RW5,@RW0+ @RW0+RW7 RW6,@RW0+ @RW0+RW7 RW7,@RW0+ @RW0+RW7 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, @RW2+ @PC+d16 RW2, @RW2+ @PC+d16 RW3, @RW2+ @PC+d16 RW4, @RW2+ @PC+d16 MOVW MOVW RW1, @RW3+ RW1, addr16 MOVW RW0, @RW1+ MOVW MOVW RW0, @RW2+ @PC+d16 MOVW MOVW RW0, @RW3+ RW0, addr16 +9 +A +B +C +D +E +F MOVW MOVW RW2, @RW3+ RW2, addr16 MOVW MOVW RW3, @RW3+ RW3, addr16 MOVW MOVW RW5, @RW3+ RW5, addr16 MOVW MOVW RW5, @RW2+ @PC+d16 MOVW MOVW RW6, @RW3+ RW6, addr16 MOVW MOVW RW6, RW6, @RW2+ @PC+d16 MOVW MOVW RW7, @RW3+ RW7, addr16 MOVW MOVW RW7, RW7, @RW2+ @PC+d16 MOVW RW7, @RW1+RW7 MOVW MOVW RW7, RW7,@RW3 @RW3+d16 MOVW MOVW RW7, RW7,@RW2 @RW2+d16 MOVW MOVW RW7, RW7,@RW1 @RW1+d16 MOVW MOVW RW7, RW7,@RW0 @RW0+d16 MOVW MOVW RW7, RW7, RW7 @RW7+d8 MOVW MOVW RW7, RW7, RW6 @RW6+d8 MOVW MOVW RW7, RW7, RW5 @RW5+d8 MOVW MOVW RW7, RW7, RW4 @RW4+d8 MOVW RW6, MOVW @RW1+RW7 RW7, @RW1+ MOVW MOVW RW6, RW6,@RW3 @RW3+d16 MOVW MOVW RW6, RW6,@RW2 @RW2+d16 MOVW MOVW RW6, RW6,@RW1 @RW1+d16 MOVW MOVW RW6, RW6,@RW0 @RW0+d16 MOVW MOVW RW6, RW6, RW7 @RW7+d8 MOVW MOVW RW6, RW6, RW6 @RW6+d8 MOVW MOVW RW6, RW6, RW5 @RW5+d8 MOVW MOVW RW6, RW6, RW4 @RW4+d8 MOVW MOVW @RW1+RW7 RW6, @RW1+ MOVW MOVW RW5, RW5, RW6 @RW6+d8 MOVW MOVW RW5, RW5, RW5 @RW5+d8 MOVW RW4, MOVW @RW1+RW7 RW5, @RW1+ MOVW MOVW RW4, @RW3+ RW4, addr16 MOVW RW3, MOVW @RW1+RW7 RW4, @RW1+ MOVW MOVW RW5, RW5,@RW2 @RW2+d16 MOVW MOVW MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW0,@RW0 @RW0+d16 RW1,@RW0 @RW0+d16 RW2,@RW0 @RW0+d16 RW3,@RW0 @RW0+d16 RW4,@RW0 @RW0+d16 +8 MOVW RW2, MOVW @RW1+RW7 RW3, @RW1+ MOVW MOVW RW5, RW5,@RW1 @RW1+d16 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW7 @RW7+d8 RW2, RW7 @RW7+d8 RW3, RW7 @RW7+d8 RW4, RW7 @RW7+d8 MOVW MOVW RW0, RW7 @RW7+d8 +7 MOVW RW1, MOVW @RW1+RW7 RW2, @RW1+ MOVW MOVW RW5, RW5,@RW0 @RW0+d16 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW6 @RW6+d8 RW2, RW6 @RW6+d8 RW3, RW6 @RW6+d8 RW4, RW6 @RW6+d8 MOVW MOVW RW0, RW6 @RW6+d8 +6 MOVW MOVW @RW1+RW7 RW1, @RW1+ MOVW MOVW RW5, RW5, RW7 @RW7+d8 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW5 @RW5+d8 RW2, RW5 @RW5+d8 RW3, RW5 @RW5+d8 RW4, RW5 @RW5+d8 MOVW MOVW RW0, RW5 @RW5+d8 +5 MOVW MOVW RW5, RW5, RW4 @RW4+d8 MOVW MOVW RW7, RW7, RW3 @RW3+d8 MOVW MOVW RW7, RW7, RW2 @RW2+d8 MOVW MOVW RW7, RW7, RW1 @RW1+d8 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW4 @RW4+d8 RW2, RW4 @RW4+d8 RW3, RW4 @RW4+d8 RW4, RW4 @RW4+d8 MOVW MOVW RW6, RW6, RW3 @RW3+d8 MOVW MOVW RW6, RW6, RW2 @RW2+d8 MOVW MOVW RW6, RW6, RW1 @RW1+d8 MOVW MOVW RW0, RW4 @RW4+d8 MOVW MOVW RW5, RW5, RW3 @RW3+d8 MOVW MOVW RW5, RW5, RW2 @RW2+d8 MOVW MOVW RW5, RW5, RW1 @RW1+d8 +4 F0 MOVW MOVW RW7, RW7, RW0 @RW0+d8 E0 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW3 @RW3+d8 RW2, RW3 @RW3+d8 RW3, RW3 @RW3+d8 RW4, RW3 @RW3+d8 D0 MOVW MOVW RW6, RW6, RW0 @RW0+d8 C0 MOVW MOVW RW0, RW3 @RW3+d8 B0 MOVW MOVW RW5, RW5, RW0 @RW0+d8 A0 +3 90 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW2 @RW2+d8 RW2, RW2 @RW2+d8 RW3, RW2 @RW2+d8 RW4, RW2 @RW2+d8 80 MOVW MOVW RW0, RW2 @RW2+d8 70 +2 60 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW1 @RW1+d8 RW2, RW1 @RW1+d8 RW3, RW1 @RW1+d8 RW4, RW1 @RW1+d8 50 MOVW MOVW RW0, RW1 @RW1+d8 40 +1 30 MOVW MOVW RW1, MOVW MOVW RW2, MOVW MOVW RW3, MOVW MOVW RW4, RW1, RW0 @RW0+d8 RW2, RW0 @RW0+d8 RW3, RW0 @RW0+d8 RW4, RW0 @RW0+d8 20 MOVW MOVW RW0, RW0 @RW0+d8 10 +0 00 APPENDIX Table D.9-17 MOVW RWi, ea Instruction (First Byte = 7BH) +F +E +D +C +B +A +9 +8 MOV MOV MOV MOV MOV MOV MOV MOV MOV @RW3+, R1 addr16, R1 MOV MOV @RW3+, R0 addr16, R0 MOV MOV MOV @RW2+, R1 @PC+d16, R1 @RW2+, R0 @PC+d16, R0 MOV MOV MOV MOV MOV @RW0+, R1 @RW0+RW7, R1 MOV @RW3, R1 @RW3+d16, R1 MOV @RW2, R1 @RW2+d16, R1 MOV @RW1, R1 @RW1+d16, R1 MOV @RW1+, R1 @RW1+RW7, R1 MOV MOV @RW0, R1 @RW0+d16, R1 MOV @RW1+, R0 @RW1+RW7, R0 MOV @RW0+, R0 @RW0+RW7, R0 MOV @RW3, R0 @RW3+d16, R0 MOV @RW2, R0 @RW2+d16, R0 MOV @RW1, R0 @RW1+d16, R0 MOV @RW0, R0 @RW0+d16, R0 MOV MOV MOV MOV MOV MOV MOV MOV MOV @RW3+, R2 addr16, R2 MOV @RW2+, R2 @PC+d16, R2 MOV @RW1+, R2 @RW1+RW7, R2 MOV @RW0+, R2 @RW0+RW7, R2 MOV @RW3, R2 @RW3+d16, R2 MOV @RW2, R2 @RW2+d16, R2 MOV @RW1, R2 @RW1+d16, R2 MOV @RW0, R2 @RW0+d16, R2 MOV MOV MOV MOV MOV MOV MOV MOV MOV @RW3+, R3 addr16, R3 MOV @RW2+, R3 @PC+d16, R3 MOV @RW1+, R3 @RW1+RW7, R3 MOV @RW0+, R3 @RW0+RW7, R3 MOV @RW3, R3 @RW3+d16, R3 MOV @RW2, R3 @RW2+d16, R3 MOV @RW1, R3 @RW1+d16, R3 MOV @RW0, R3 @RW0+d16, R3 MOV MOV MOV MOV MOV MOV MOV MOV MOV @RW3+, R4 addr16, R4 MOV @RW2+, R4 @PC+d16, R4 MOV @RW1+, R4 @RW1+RW7, R4 MOV @RW0+, R4 @RW0+RW7, R4 MOV @RW3, R4 @RW3+d16, R4 MOV @RW2, R4 @RW2+d16, R4 MOV @RW1, R4 @RW1+d16, R4 MOV @RW0, R4 @RW0+d16, R4 MOV MOV MOV MOV MOV MOV MOV MOV MOV @RW3+, R5 addr16, R5 MOV @RW2+, R5 @PC+d16, R5 MOV @RW1+, R5 @RW1+RW7, R5 MOV @RW0+, R5 @RW0+RW7, R5 MOV @RW3, R5 @RW3+d16, R5 MOV @RW2, R5 @RW2+d16, R5 MOV @RW1, R5 @RW1+d16, R5 MOV @RW0, R5 @RW0+d16, R5 MOV MOV MOV MOV MOV MOV MOV MOV MOV @RW3+, R6 addr16, R6 MOV @RW2+, R6 @PC+d16, R6 MOV @RW1+, R6 @RW1+RW7, R6 MOV @RW0+, R6 @RW0+RW7, R6 MOV @RW3, R6 @RW3+d16, R6 MOV @RW2, R6 @RW2+d16, R6 MOV @RW1, R6 @RW1+d16, R6 MOV @RW0, R6 @RW0+d16, R6 MOV MOV MOV MOV MOV MOV MOV MOV MOV @RW3+, R7 addr16, R7 MOV @RW2+, R7 @PC+d16, R7 MOV @RW1+, R7 @RW1+RW7, R7 MOV @RW0+, R7 @RW0+RW7, R7 MOV @RW3, R7 @RW3+d16, R7 MOV @RW2, R7 @RW2+d16, R7 MOV @RW1, R7 @RW1+d16, R7 MOV @RW0, R7 @RW0+d16, R7 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R7, R0 @RW7+d8, R0 R7, R1 @RW7+d8, R1 R7, R2 @RW7+d8, R2 R7, R3 @RW7+d8, R3 R7, R4 @RW7+d8, R4 R7, R5 @RW7+d8, R5 R7, R6 @RW7+d8, R6 R7, R7 @RW7+d8, R7 F0 +7 E0 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R6, R0 @RW6+d8, R0 R6, R1 @RW6+d8, R1 R6, R2 @RW6+d8, R2 R6, R3 @RW6+d8, R3 R6, R4 @RW6+d8, R4 R6, R5 @RW6+d8, R5 R6, R6 @RW6+d8, R6 R6, R7 @RW6+d8, R7 D0 +6 C0 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R5, R0 @RW5+d8, R0 R5, R1 @RW5+d8, R1 R5, R2 @RW5+d8, R2 R5, R3 @RW5+d8, R3 R5, R4 @RW5+d8, R4 R5, R5 @RW5+d8, R5 R5, R6 @RW5+d8, R6 R5, R7 @RW5+d8, R7 B0 +5 A0 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R4, R0 @RW4+d8, R0 R4, R1 @RW4+d8, R1 R4, R2 @RW4+d8, R2 R4, R3 @RW4+d8, R3 R4, R4 @RW4+d8, R4 R4, R5 @RW4+d8, R5 R4, R6 @RW4+d8, R6 R4, R7 @RW4+d8, R7 90 +4 80 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R3, R0 @RW3+d8, R0 R3, R1 @RW3+d8, R1 R3, R2 @RW3+d8, R2 R3, R3 @RW3+d8, R3 R3, R4 @RW3+d8, R4 R3, R5 @RW3+d8, R5 R3, R6 @RW3+d8, R6 R3, R7 @RW3+d8, R7 70 +3 60 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R2, R0 @RW2+d8, R0 R2, R1 @RW2+d8, R1 R2, R2 @RW2+d8, R2 R2, R3 @RW2+d8, R3 R2, R4 @RW2+d8, R4 R2, R5 @RW2+d8, R5 R2, R6 @RW2+d8, R6 R2, R7 @RW2+d8, R7 50 +2 40 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R1, R0 @RW1+d8, R0 R1, R1 @RW1+d8, R1 R1, R2 @RW1+d8, R2 R1, R3 @RW1+d8, R3 R1, R4 @RW1+d8, R4 R1, R5 @RW1+d8, R5 R1, R6 @RW1+d8, R6 R1, R7 @RW1+d8, R7 30 +1 20 MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV R0, R0 @RW0+d8, R0 R0, R1 @RW0+d8, R1 R0, R2 @RW0+d8, R2 R0, R3 @RW0+d8, R3 R0, R4 @RW0+d8, R4 R0, R5 @RW0+d8, R5 R0, R6 @RW0+d8, R6 R0, R7 @RW0+d8, R7 10 +0 00 APPENDIX D Instructions Table D.9-18 MOV ea, Ri Instruction (First Byte = 7CH) 627 628 MOVW MOVW@RW2 @RW2, RW1 +d16, RW1 MOVW MOVW@RW3 @RW3, RW1 +d16, RW1 MOVW MOVW@RW0 @RW0+, RW1 +RW7,RW1 MOVW MOVW@RW1 @RW1+,RW1 +RW7,RW1 MOVW MOVW@PC @RW2+,RW1 +d16, RW1 MOVW MOVW @RW3+,RW1 addr16, RW1 MOVW MOVW@RW2 @RW2, RW0 +d16, RW0 MOVW MOVW@RW3 @RW3, RW0 +d16, RW0 MOVW MOVW@RW0 @RW0+,RW0 +RW7,RW0 MOVW MOVW@RW1 @RW1+,RW0 +RW7,RW0 MOVW MOVW@PC @RW2+,RW0 +d16, RW0 MOVW MOVW @RW3+,RW0 addr16, RW0 +B +C +D +E +F MOVW MOVW @RW3+,RW2 addr16, RW2 MOVW MOVW@PC @RW2+,RW2 +d16, RW2 MOVW MOVW@RW1 @RW1+,RW2 +RW7,RW2 MOVW MOVW@RW0 @RW0+,RW2 +RW7,RW2 MOVW MOVW@RW3 @RW3, RW2 +d16, RW2 MOVW MOVW@RW2 @RW2, RW2 +d16, RW2 MOVW MOVW @RW3+,RW3 addr16, RW3 MOVW MOVW@PC @RW2+,RW3 +d16, RW3 MOVW MOVW@RW1 @RW1+,RW3 -+RW7,RW3 MOVW MOVW@RW0 @RW0+,RW3 +RW7,RW3 MOVW MOVW@RW3 @RW3, RW3 +d16, RW3 MOVW MOVW@RW2 @RW2, RW3 +d16, RW3 MOVW MOVW@RW1 @RW1, RW3 +d16, RW3 MOVW MOVW @RW3+,RW4 addr16, RW4 MOVW MOVW@PC @RW2+,RW4 +d16, RW4 MOVW MOVW@RW1 @RW1+,RW4 +RW7,RW4 MOVW MOVW@RW0 @RW0+,RW4 +RW7,RW4 MOVW MOVW@RW3 @RW3, RW4 +d16, RW4 MOVW MOVW@RW2 @RW2, RW4 +d16, RW4 MOVW MOVW@RW1 @RW1, RW4 +d16, RW4 MOVW MOVW @RW3+,RW5 addr16, RW5 MOVW MOVW@PC @RW2+,RW5 +d16, RW5 MOVW MOVW@RW1 @RW1+,RW5 +RW7,RW5 MOVW MOVW@RW0 @RW0+,RW5 +RW7,RW5 MOVW MOVW@RW3 @RW3, RW5 +d16, RW5 MOVW MOVW@RW2 @RW2, RW5 +d16, RW5 MOVW MOVW@RW1 @RW1, RW5 +d16, RW5 MOVW MOVW @RW3+,RW6 addr16, RW6 MOVW MOVW @PC @RW2+,RW6 +d16, RW6 MOVW MOVW@RW1 @RW1+,RW6 +RW7,RW6 MOVW MOVW@RW0 @RW0+,RW6 +RW7,RW6 MOVW MOVW@RW3 @RW3, RW6 +d16, RW6 MOVW MOVW@RW2 @RW2, RW6 +d16, RW6 MOVW MOVW@RW1 @RW1, RW6 +d16, RW6 MOVW MOVW @RW3+,RW7 addr16, RW7 MOVW MOVW@PC @RW2+,RW7 +d16, RW7 MOVW MOVW@RW1 @RW1+,RW7 +RW7,RW7 MOVW MOVW@RW0 @RW0+,RW7 +RW7,RW7 MOVW MOVW@RW3 @RW3, RW7 +d16, RW7 MOVW MOVW@RW2 @RW2, RW7 +d16, RW7 MOVW MOVW@RW1 @RW1, RW7 +d16, RW7 MOVW MOVW@RW0 @RW0, RW7 +d16, RW7 +A MOVW MOVW@RW1 @RW1, RW2 +d16, RW2 MOVW MOVW@RW0 @RW0, RW6 +d16, RW6 MOVW MOVW@RW1 @RW1, RW1 +d16, RW1 MOVW MOVW@RW0 @RW0, RW5 +d16, RW5 MOVW MOVW@RW1 @RW1, RW0 +d16, RW0 MOVW MOVW@RW0 @RW0, RW4 +d16, RW4 +9 MOVW MOVW@RW0 @RW0, RW3 +d16, RW3 MOVW MOVW@RW0 @RW0, RW1 +d16, RW1 MOVW MOVW@RW0 @RW0, RW0 +d16, RW0 +8 MOVW MOVW@RW0 @RW0, RW2 +d16, RW2 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW7, RW0 @RW7+d8, RW0 RW7, RW1 @RW7+d8, RW1 RW7, RW2 @RW7+d8, RW2 RW7, RW3 @RW7+d8, RW3 RW7, RW4 @RW7+d8, RW4 RW7, RW5 @RW7+d8, RW5 RW7, RW6 @RW7+d8, RW6 RW7, RW7 @RW7+d8, RW7 F0 +7 E0 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW6, RW0 @RW6+d8, RW0 RW6, RW1 @RW6+d8, RW1 RW6, RW2 @RW6+d8, RW2 RW6, RW3 @RW6+d8, RW3 RW6, RW4 @RW6+d8, RW4 RW6, RW5 @RW6+d8, RW5 RW6, RW6 @RW6+d8, RW6 RW6, RW7 @RW6+d8, RW7 D0 +6 C0 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW5, RW0 @RW5+d8, RW0 RW5, RW1 @RW5+d8, RW1 RW5, RW2 @RW5+d8, RW2 RW5, RW3 @RW5+d8, RW3 RW5, RW4 @RW5+d8, RW4 RW5, RW5 @RW5+d8, RW5 RW5, RW6 @RW5+d8, RW6 RW5, RW7 @RW5+d8, RW7 B0 +5 A0 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW4, RW0 @RW4+d8, RW0 RW4, RW1 @RW4+d8, RW1 RW4, RW2 @RW4+d8, RW2 RW4, RW3 @RW4+d8, RW3 RW4, RW4 @RW4+d8, RW4 RW4, RW5 @RW4+d8, RW5 RW4, RW6 @RW4+d8, RW6 RW4, RW7 @RW4+d8, RW7 90 +4 80 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW3, RW0 @RW3+d8, RW0 RW3, RW1 @RW3+d8, RW1 RW3, RW2 @RW3+d8, RW2 RW3, RW3 @RW3+d8, RW3 RW3, RW4 @RW3+d8, RW4 RW3, RW5 @RW3+d8, RW5 RW3, RW6 @RW3+d8, RW6 RW3, RW7 @RW3+d8, RW7 70 +3 60 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW2, RW0 @RW2+d8, RW0 RW2, RW1 @RW2+d8, RW1 RW2, RW2 @RW2+d8, RW2 RW2, RW3 @RW2+d8, RW3 RW2, RW4 @RW2+d8, RW4 RW2, RW5 @RW2+d8, RW5 RW2, RW6 @RW2+d8, RW6 RW2, RW7 @RW2+d8, RW7 50 +2 40 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW1, RW0 @RW1+d8, RW0 RW1, RW1 @RW1+d8, RW1 RW1, RW2 @RW1+d8, RW2 RW1, RW3 @RW1+d8, RW3 RW1, RW4 @RW1+d8, RW4 RW1, RW5 @RW1+d8, RW5 RW1, RW6 @RW1+d8, RW6 RW1, RW7 @RW1+d8, RW7 30 +1 20 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW RW0, RW0 @RW0+d8, RW0 RW0, RW1 @RW0+d8, RW1 RW0, RW2 @RW0+d8, RW2 RW0, RW3 @RW0+d8, RW3 RW0, RW4 @RW0+d8, RW4 RW0, RW5 @RW0+d8, RW5 RW0, RW6 @RW0+d8, RW6 RW0, RW7 @RW0+d8, RW7 10 +0 00 APPENDIX Table D.9-19 MOVW ea, Rwi Instruction (First Byte = 7DH) XCH XCH XCH XCH R1, XCH XCH R1, R1,@RW2 W2+d16, A XCH XCH R2, XCH XCH R2, R2,@RW2 W2+d16, A XCH XCH R3, XCH XCH R3, R3,@RW2 W2+d16, A XCH XCH R4, XCH XCH R4, R4,@RW2 W2+d16, A XCH XCH R5, XCH XCH R5, R5,@RW2 W2+d16, A XCH XCH R6, XCH XCH R6, R6,@RW2 W2+d16, A XCH XCH R7, XCH XCH R7, R7,@RW2 W2+d16, A XCH XCH XCH XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, +F R0,@RW3+ R0, addr16 XCH XCH R1,@RW3+ R1, addr16 XCH XCH R2,@RW3+ R2, addr16 XCH XCH R3,@RW3+ R3, addr16 XCH XCH R4,@RW3+ R4, addr16 XCH XCH R5,@RW3+ R5, addr16 XCH XCH R6,@RW3+ R6, addr16 XCH XCH R7,@RW3+ R7, addr16 +E R0,@RW2+ @PC+d16 R1,@RW2+ @PC+d16 R2,@RW2+ @PC+d16 R3,@RW2+ @PC+d16 R4,@RW2+ @PC+d16 R5,@RW2+ @PC+d16 R6,@RW2+ @PC+d16 R7,@RW2+ @PC+d16 R0, XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, @RW1+RW7 R1,@RW1+ @RW1+RW7 R2,@RW1+ @RW1+RW7 R3,@RW1+ @RW1+RW7 R4,@RW1+ @RW1+RW7 R5,@RW1+ @RW1+RW7 R6,@RW1+ @RW1+RW7 R7,@RW1+ @RW1+RW7 +D R0,@RW1+ XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, @RW0+RW7 R1,@RW0+ @RW0+RW7 R2,@RW0+ @RW0+RW7 R3,@RW0+ @RW0+RW7 R4,@RW0+ @RW0+RW7 R5,@RW0+ @RW0+RW7 R6,@RW0+ @RW0+RW7 R7,@RW0+ @RW0+RW7 XCH +C R0,@RW0+ +B R0,@RW3 @RW3+d16 R1,@RW3 @RW3+d16 R2,@RW3 @RW3+d16 R3,@RW3 @RW3+d16 R4,@RW3 @RW3+d16 R5,@RW3 @RW3+d16 R6,@RW3 @RW3+d16 R7,@RW3 @RW3+d16 R0, +A R0,@RW2 W2+d16, A R0, XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0,@RW1 @RW1+d16 R1,@RW1 @RW1+d16 R2,@RW1 @RW1+d16 R3,@RW1 @RW1+d16 R4,@RW1 @RW1+d16 R5,@RW1 @RW1+d16 R6,@RW1 @RW1+d16 R7,@RW1 @RW1+d16 +9 XCH XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0,@RW0 @RW0+d16 R1,@RW0 @RW0+d16 R2,@RW0 @RW0+d16 R3,@RW0 @RW0+d16 R4,@RW0 @RW0+d16 R5,@RW0 @RW0+d16 R6,@RW0 @RW0+d16 R7,@RW0 @RW0+d16 +8 XCH XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R7 @RW7+d8 R1, R7 @RW7+d8 R2, R7 @RW7+d8 R3, R7 @RW7+d8 R4, R7 @RW7+d8 R5, R7 @RW7+d8 R6, R7 @RW7+d8 R7, R7 @RW7+d8 F0 +7 E0 XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R6 @RW6+d8 R1, R6 @RW6+d8 R2, R6 @RW6+d8 R3, R6 @RW6+d8 R4, R6 @RW6+d8 R5, R6 @RW6+d8 R6, R6 @RW6+d8 R7, R6 @RW6+d8 D0 +6 C0 XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R5 @RW5+d8 R1, R5 @RW5+d8 R2, R5 @RW5+d8 R3, R5 @RW5+d8 R4, R5 @RW5+d8 R5, R5 @RW5+d8 R6, R5 @RW5+d8 R7, R5 @RW5+d8 B0 +5 A XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R4 @RW4+d8 R1, R4 @RW4+d8 R2, R4 @RW4+d8 R3, R4 @RW4+d8 R4, R4 @RW4+d8 R5, R4 @RW4+d8 R6, R4 @RW4+d8 R7, R4 @RW4+d8 90 +4 80 XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R3 @RW3+d8 R1, R3 @RW3+d8 R2, R3 @RW3+d8 R3, R3 @RW3+d8 R4, R3 @RW3+d8 R5, R3 @RW3+d8 R6, R3 @RW3+d8 R7, R3 @RW3+d8 70 +3 60 XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R2 @RW2+d8 R1, R2 @RW2+d8 R2, R2 @RW2+d8 R3, R2 @RW2+d8 R4, R2 @RW2+d8 R5, R2 @RW2+d8 R6, R2 @RW2+d8 R7, R2 @RW2+d8 50 +2 40 XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R1 @RW1+d8 R1, R1 @RW1+d8 R2, R1 @RW1+d8 R3, R1 @RW1+d8 R4, R1 @RW1+d8 R5, R1 @RW1+d8 R6, R1 @RW1+d8 R7, R1 @RW1+d8 30 +1 20 XCH XCH R0, XCH XCH R1, XCH XCH R2, XCH XCH R3, XCH XCH R4, XCH XCH R5, XCH XCH R6, XCH XCH R7, R0, R0 @RW0+d8 R1, R0 @RW0+d8 R2, R0 @RW0+d8 R3, R0 @RW0+d8 R4, R0 @RW0+d8 R5, R0 @RW0+d8 R6, R0 @RW0+d8 R7, R0 @RW0+d8 10 +0 00 APPENDIX D Instructions Table D.9-20 XCH Ri, ea Instruction (First Byte = 7EH) 629 630 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0,@RW2+ @PC+d16 RW1,@RW2+ @PC+d16 RW2,@RW2+ @PC+d16 RW3,@RW2+ @PC+d16 RW4,@RW2+ @PC+d16 RW5,@RW2+ @PC+d16 RW6,@RW2+ @PC+d16 RW7,@RW2+ @PC+d16 XCHW XCHW RW0,@RW3+ RW0, addr16 +E +F XCHW XCHW RW7,@RW3+ RW7, addr16 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0,@RW1+ @RW1+RW7 RW1,@RW1+ @RW1+RW7 RW2,@RW1+ @RW1+RW7 RW3,@RW1+ @RW1+RW7 RW4,@RW1+ @RW1+RW7 RW5,@RW1+ @RW1+RW7 RW6,@RW1+ @RW1+RW7 RW7,@RW1+ @RW1+RW7 +D XCHW XCHW RW6,@RW3+ RW6, addr16 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0,@RW0+ @RW0+RW7 RW1,@RW0+ @RW0+RW7 RW2,@RW0+ @RW0+RW7 RW3,@RW0+ @RW0+RW7 RW4,@RW0+ @RW0+RW7 RW5,@RW0+ @RW0+RW7 RW6,@RW0+ @RW0+RW7 RW7,@RW0+ @RW0+RW7 +C XCHW XCHW RW5,@RW3+ RW5, addr16 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0,@RW3 @RW3+d16 RW1,@RW3 @RW3+d16 RW2,@RW3 @RW3+d16 RW3,@RW3 @RW3+d16 RW4,@RW3 @RW3+d16 RW5,@RW3 @RW3+d16 RW6,@RW3 @RW3+d16 RW7,@RW3 @RW3+d16 +B XCHW XCHW RW4,@RW3+ RW4, addr16 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0,@RW2 @RW2+d16 RW1,@RW2 @RW2+d16 RW2,@RW2 @RW2+d16 RW3,@RW2 @RW2+d16 RW4,@RW2 @RW2+d16 RW5,@RW2 @RW2+d16 RW6,@RW2 @RW2+d16 RW7,@RW2 @RW2+d16 +A XCHW XCHW RW3,@RW3+ RW3, addr16 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0,@RW1 @RW1+d16 RW1,@RW1 @RW1+d16 RW2,@RW1 @RW1+d16 RW3,@RW1 @RW1+d16 RW4,@RW1 @RW1+d16 RW5,@RW1 @RW1+d16 RW6,@RW1 @RW1+d16 RW7,@RW1 @RW1+d16 +9 XCHW XCHW RW2,@RW3+ RW2, addr16 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0,@RW0 @RW0+d16 RW1,@RW0 @RW0+d16 RW2,@RW0 @RW0+d16 RW3,@RW0 @RW0+d16 RW4,@RW0 @RW0+d16 RW5,@RW0 @RW0+d16 RW6,@RW0 @RW0+d16 RW7,@RW0 @RW0+d16 +8 XCHW XCHW RW1,@RW3+ RW1, addr16 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW7 @RW7+d8 RW1, RW7 @RW7+d8 RW2, RW7 @RW7+d8 RW3, RW7 @RW7+d8 RW4, RW7 @RW7+d8 RW5, RW7 @RW7+d8 RW6, RW7 @RW7+d8 RW7, RW7 @RW7+d8 F0 +7 E0 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW6 @RW6+d8 RW1, RW6 @RW6+d8 RW2, RW6 @RW6+d8 RW3, RW6 @RW6+d8 RW4, RW6 @RW6+d8 RW5, RW6 @RW6+d8 RW6, RW6 @RW6+d8 RW7, RW6 @RW6+d8 D0 +6 C0 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW5 @RW5+d8 RW1, RW5 @RW5+d8 RW2, RW5 @RW5+d8 RW3, RW5 @RW5+d8 RW4, RW5 @RW5+d8 RW5, RW5 @RW5+d8 RW6, RW5 @RW5+d8 RW7, RW5 @RW5+d8 B0 +5 A0 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW4 @RW4+d8 RW1, RW4 @RW4+d8 RW2, RW4 @RW4+d8 RW3, RW4 @RW4+d8 RW4, RW4 @RW4+d8 RW5, RW4 @RW4+d8 RW6, RW4 @RW4+d8 RW7, RW4 @RW4+d8 90 +4 80 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW3 @RW3+d8 RW1, RW3 @RW3+d8 RW2, RW3 @RW3+d8 RW3, RW3 @RW3+d8 RW4, RW3 @RW3+d8 RW5, RW3 @RW3+d8 RW6, RW3 @RW3+d8 RW7, RW3 @RW3+d8 70 +3 60 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW2 @RW2+d8 RW1, RW2 @RW2+d8 RW2, RW2 @RW2+d8 RW3, RW2 @RW2+d8 RW4, RW2 @RW2+d8 RW5, RW2 @RW2+d8 RW6, RW2 @RW2+d8 RW7, RW2 @RW2+d8 50 +2 40 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW1 @RW1+d8 RW1, RW1 @RW1+d8 RW2, RW1 @RW1+d8 RW3, RW1 @RW1+d8 RW4, RW1 @RW1+d8 RW5, RW1 @RW1+d8 RW6, RW1 @RW1+d8 RW7, RW1 @RW1+d8 30 +1 20 XCHW XCHW RW0, XCHW XCHW RW1, XCHW XCHW RW2, XCHW XCHW RW3, XCHW XCHW RW4, XCHW XCHW RW5, XCHW XCHW RW6, XCHW XCHW RW7, RW0, RW0 @RW0+d8 RW1, RW0 @RW0+d8 RW2, RW0 @RW0+d8 RW3, RW0 @RW0+d8 RW4, RW0 @RW0+d8 RW5, RW0 @RW0+d8 RW6, RW0 @RW0+d8 RW7, RW0 @RW0+d8 10 +0 00 APPENDIX Table D.9-21 XCHW RWi, ea Instruction (First Byte = 7FH) INDEX INDEX The index follows on the next page. This is listed in alphabetic order. 631 INDEX Index Numerics 1.5M Bit Flash Memory Features of the 1.5M Bit Flash Memory.............. 462 16-bit Input/Output Timer Block Diagram of Pin Related to 16-bit Input/Output Timer ................................................. 198 Configuration and Function of 16-bit Input/Output Timer ................................................. 194 Configuration of 16-bit Input/Output Timer Register .............................................. 199 Interrupt of 16-bit Input/Output Timer................ 211 Interrupt of 16-bit Input/Output Timer, DMA Transfer, and EI2OS ............................ 212 Operation and Timing of 16-bit Input/Output Timer ................................................. 213 Pin Related to 16-bit Input/Output Timer............ 197 16-bit Input/Output Timer Register Configuration of 16-bit Input/Output Timer Register .............................................. 199 16-bit Reload Register 16-bit Reload Register (TMRLR)....................... 280 16-bit Timer Register (TMR)/ 16-bit Reload Register (TMRLR).......... 279 16-bit Reload Timer Block Diagram of Pin Related to 16-bit Reload Timer ............................ 273 Block Diagram of the 16-bit Reload Timer ......... 272 Configuration of 16-bit Reload Timer Registers ............................................ 274 Interrupt of 16-bit Reload Timer ........................ 281 Interrupt of 16-bit Reload Timer, DMA Transfer, and EI2OS ................................................ 281 Operation Modes of the 16-bit Reload Timer ................................................. 270 Pin Related to 16-bit Reload Timer .................... 272 Program Example of 16-bit Reload Timer........... 292 Settings of the 16-bit Reload Timer.................... 282 16-bit Reload Timer Register Configuration of 16-bit Reload Timer Registers ............................................ 274 16-bit Timer Register 16-bit Timer Register (TMR)............................. 279 16-bit Timer Register (TMR)/ 16-bit Reload Register (TMRLR).......... 279 8/10-bit A/D Converter Block Diagram of 8/10-bit A/D Converter .......... 343 Block Diagram of Pin Related to 8/10-bit A/D Converter ........................................... 344 Features of the 8/10-bit A/D Converter............... 342 Interrupt of 8/10-bit A/D Converter.................... 353 632 Interrupt of 8/10-bit A/D Converter, DMA Transfer, and EI2OS .......................................... 353 List of Registers for 8/10-bit A/D Converter ....... 345 Pin Related to 8/10-bit A/D Converter ............... 344 Program Example of 8/10-bit A/D Converter ........................................... 367 8/16-bit PPG Block Diagram of Pin Related to 8/16-bit PPG Timer ............................. 303 Block Diagram of the 8/16-bit PPG Timer.......... 301 Function of 8/16-bit PPG Timer ........................ 300 Interrupt of 8/16-bit PPG Timer ........................ 313 Interrupt of 8/16-bit PPG Timer, DMA Transfer, and EI2OS ................................................ 314 Interrupts of the 8/16-bit PPG Timer.................. 319 List of 8/16-bit PPG Timer Registers ................. 304 Outline of 8/16-bit PPG Timer Operation ........... 315 Pin Related to 8/16-bit PPG Timer..................... 302 Program Example of 8/16-bit PPG Timer ........... 321 8/16-bit PPG Timer Register List of 8/16-bit PPG Timer Registers ................. 304 8/16-bit Up/Down Counter/Timer Block Diagram of 8/16-bit Up/Down Counter/Timer .................................... 237 Block Diagram of Pin Related to 8/16-bit Up/Down Counter/Timer .................................... 239 Interrupt of 8/16-bit Up/Down Counter/Timer .................................... 251 Interrupt of 8/16-bit Up/Down Counter/Timer, DMA Transfer, and EI2OS................... 252 List of 8/16-bit Up/Down Counter/Timer Registers ............................................ 240 Major Functions of 8/16-bit Up/Down Counter/Timer .................................... 236 Pin Related to 8/16-bit Up/Down Counter/Timer .................................... 238 Program Example of 8/16-bit Up/Down Counter/Timer .................................... 261 8/16-bit Up/Down Counter/Timer Register List of 8/16-bit Up/Down Counter/Timer Registers ............................................ 240 INDEX A A Accumulator (A)................................................ 27 A/D Converter Block Diagram of 8/10-bit A/D Converter .......... 343 Block Diagram of Pin Related to 8/10-bit A/D Converter ........................................... 344 Features of the 8/10-bit A/D Converter .............. 342 Interrupt of 8/10-bit A/D Converter ................... 353 Interrupt of 8/10-bit A/D Converter, DMA Transfer, and EI2OS .......................................... 353 Interrupt of A/D Converter................................ 353 List of Registers for 8/10-bit A/D Converter ....... 345 Pin Related to 8/10-bit A/D Converter ............... 344 Program Example of 8/10-bit A/D Converter ........................................... 367 Access Access to Data of Multi-byte Length.................... 24 Accessing Low-Power Consumption Mode Control Register.............................................. 127 Correspondence Between Access Areas and Physical Address.............................................. 149 Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode ............................... 143 Overview of Memory Access Mode................... 146 Accumulator Accumulator (A)................................................ 27 Acknowledge Acknowledge................................................... 555 ADB Bank Select Prefix (PCB, DTB, ADB, SPB) ......... 36 ADCR Data Registers (ADCR2 and ADCR1)................ 352 ADCS Control Status Register 1 (ADCS1).................... 346 Control Status Register 2 (ADCS2).................... 349 Address Generation Address Generation Type.................................... 21 Address Match Detection Function Block Diagram of Address Match Detection Function............................................. 443 List of Registers and Initial Values of Address Match Detection Function .............................. 444 Operation of Address Match Detection Function............................................. 449 Operation of Address Match Detection Function at Storing Patch Program in E2PROM ...... 453 Overview of Address Match Detection Function............................................. 442 Program Example for Address Match Detection Function............................................. 455 Address Register Address Register (IADR).................................. 550 Addressing Addressing...............................................554, 572 Addressing Type by Bank ...................................22 Direct Addressing .............................................574 Indirect Addressing...........................................580 ADER Analog Input Enable Register (ADER) ...............157 Allocation Allocation for Data of Multi-byte Length in Memory Space....................................................24 Analog Input Enable Register Analog Input Enable Register (ADER) ...............157 Arbitrary Data Erasing Arbitrary Data in the Flash Memory (Sector Erase)......................................484 Arbitration Arbitration .......................................................554 Asynchronous Mode Operation in Asynchronous Mode (Operation Modes 0 and 1) ...................420 Automatic Algorithm End Timing of the Automatic Algorithm.............468 B Bank Select Prefix Bank Select Prefix (PCB, DTB, ADB, SPB) .........36 BAP Buffer Address Pointer (BAP) .......................70, 80 Basic Configuration Basic Configuration of Serial Programming Connection with MB90F983.................490 Block Diagram Block Diagram .................................................195 Block Diagram of 8/10-bit A/D Converter...........343 Block Diagram of 8/16-bit Up/Down Counter/Timer.....................................237 Block Diagram of Address Match Detection Function .............................................443 Block Diagram of Block Generator ....................106 Block Diagram of Delay Interrupt Generation Module .................................................89 Block Diagram of DTP/External Interrupt...........326 Block Diagram of Expanded I/O Serial Interface .............................................375 Block Diagram of External-reset Pin ....................96 Block Diagram of Free-run Timer ......................196 Block Diagram of Input Capture ........................197 Block Diagram of Low-Power Consumption Control Circuit ................................................123 Block Diagram of MB90980 Series ........................5 Block Diagram of Output Compare ............196, 206 Block Diagram of Pin Related to 16-bit Input/Output Timer .................................................198 633 INDEX Block Diagram of Pin Related to 16-bit Reload Timer ............................ 273 Block Diagram of Pin Related to 8/10-bit A/D Converter ........................................... 344 Block Diagram of Pin Related to 8/16-bit PPG Timer ............................. 303 Block Diagram of Pin Related to 8/16-bit Up/Down Counter/Timer .................................... 239 Block Diagram of Pin Related to DTP/External Interrupt ............................................. 327 Block Diagram of Pin Related to Expanded I/O Serial Interface ............................................. 376 Block Diagram of Pin Related to I2C Interface ....................................... 536 Block Diagram of Pin Related to PWC Timer ........................................ 500 Block Diagram of Pin Related to UART ............. 400 Block Diagram of PWC Timer .......................... 499 Block Diagram of the 16-bit Reload Timer ......... 272 Block Diagram of the 8/16-bit PPG Timer .......... 301 Block Diagram of the I2C Interface .................... 535 Block Diagram of the ROM Mirror Function Selection Module............................................... 458 Block Diagram of Time-base Timer ................... 162 Block Diagram of Watch Timer......................... 187 Block Diagram of Watchdog Timer ................... 178 UART Block Diagram ...................................... 399 Buffer Address Pointer Buffer Address Pointer (BAP) ....................... 70, 80 Bus Control Register Bus Control Register (IBCR)............................. 541 Notes on Using the Bus Control Register (IBCR) ............................................... 547 Bus Error Bus Error......................................................... 555 Bus Mode Bus Modes....................................................... 146 Bus Mode Setting Bits Bus Mode Setting Bits (M1, M0) ....................... 148 Bus Status Register Bus Status Register (IBSR) ............................... 539 C Calculating Calculating the Execution Cycle Count .............. 589 Calculation Pulse Width/Interval Calculation Method ........... 528 Canceling Canceling the Sleep Mode................................. 131 Canceling the Stop Mode .................................. 136 Canceling the Time-base Timer Mode................ 132 Canceling the Watch Mode ............................... 134 Cancellation Cancellation of Standby Mode by Interrupt......... 141 634 Capture Block Diagram of Input Capture........................ 197 Capture Timing to Input Signal ......................... 221 Example of Input Capture Timing ..................... 218 Input Capture Data Register (IPCP0, IPCP1) ...... 209 List of Input Capture Registers .......................... 209 Program Example of Input Capture.................... 232 Caution Caution when Using the Conversion Data Protection Function............................................. 364 Cautions about Reset-Factor Bits....................... 100 CCR Condition Code Register (CCR) .......................... 29 CCRH Counter Control Register (ch.0) Upper (CCRH0) ........................................... 241 Counter Control Register (ch.1) Upper (CCRH1) ........................................... 243 CCRL Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1)................................ 245 CDCR Communication Prescaler Control Register (CDCR) ............................................. 411 Change Change of Clock Mode..................................... 113 Change Timing of Output Pin ........................... 220 Change to Sleep Mode...................................... 130 Change to Standby Mode and Interrupts............. 141 Change to Stop Mode ....................................... 136 Change to Time-base Timer Mode..................... 132 Change to Watch Mode .................................... 134 Flag Change Suppress Prefix (NCC).................... 37 Chip Chip/Sector Erase Operation ............................. 474 Erasing All Data in the Flash Memory (Chip Erase) ....................................... 483 Example of Connection in Single-Chip Mode (When Using the User Power Supply).............. 493 Pin State in Single Chip Mode........................... 140 Write/Chip Sector Erase Operation .................... 477 Write/Chip Sector Erase Operations................... 476 CKSCR Configuration of Clock Selection Register (CKSCR) ........................................... 108 Clear Clear Timing of Free-run Timer (Match with Compare Register 0) ......... 219 Clearing the Counter ........................................ 259 Clearing the Timer ........................................... 521 Compare Clear Register (CPCLR) ..................... 201 Count Clear/Gate Function ............................... 259 CLK Synchronous Mode Operation in CLK Synchronous Mode (Operation Mode 2)............................. 423 INDEX Clock Change of Clock Mode ..................................... 113 Clock Control Register (ICCR) ......................... 548 Clock Modes ................................................... 121 Clock Source for Watchdog Timer Specifying Function............................................. 191 Clock Supply Map ........................................... 105 Clock Supplying Function......................... 161, 168 Configuration of Clock Selection Register (CKSCR) ........................................... 108 Connection of Oscillator and External Clock .................................... 118 Count Clock and Maximum Interval .................. 522 Count Clock Selection ...................................... 516 Event Count Mode (External Clock Mode) ......... 270 External Shift Clock Mode................................ 388 Internal Clock Mode......................................... 270 Internal Shift Clock Mode................................. 388 Machine Clock ................................................ 114 Main Clock Mode, PLL Clock Mode, and Sub Clock Mode ................................................. 113 Operation of Internal Clock Mode (One-Shot Mode) ................................ 287 Operations of Internal Clock Mode (Reload Mode).................................... 284 Oscillation Clock Frequency and Serial Clock Input Frequency .......................................... 492 Precaution on Using Sub Clock Mode ................ 468 Selection of Count Clock .................................. 317 Selection of PLL Clock Multiplication Rate ................................................... 114 Setting Sub Clock Mode ................................... 469 Sub Clock Oscillation Stabilization Wait Time Function............................................. 191 Switching the Clock Mode ................................ 142 UART Clock Selection ..................................... 416 Clock Control Register Clock Control Register (ICCR) ......................... 548 Clock Frequency Oscillation Clock Frequency and Serial Clock Input Frequency .......................................... 492 Clock Mode Change of Clock Mode ..................................... 113 Clock Modes ................................................... 121 Event Count Mode (External Clock Mode) ......... 270 External Shift Clock Mode................................ 388 Internal Clock Mode......................................... 270 Internal Shift Clock Mode................................. 388 Main Clock Mode, PLL Clock Mode, and Sub Clock Mode ................................................. 113 Operation of Internal Clock Mode (One-Shot Mode) ................................ 287 Operations of Internal Clock Mode (Reload Mode).................................... 284 Precaution on Using Sub Clock Mode ................ 468 Setting Sub Clock Mode ................................... 469 Switching the Clock Mode ................................142 Clock Selection Configuration of Clock Selection Register (CKSCR) ............................................108 Count Clock Selection.......................................516 UART Clock Selection......................................416 Clock Selection Register Configuration of Clock Selection Register (CKSCR) ............................................108 Clock Supply Map Clock Supply Map ............................................105 CMR Common Register Bank Prefix (CMR) .................37 Command Sequence Table Command Sequence Table ................................472 Common Register Bank Prefix Common Register Bank Prefix (CMR) .................37 Communication Communication Prescaler Control Register (CDCR) ..............................................411 Communication Prescaler Control Register 0/1 (SDCR0/SDCR1) ................................383 Communication Procedure for Two-Way Communication Function .....................426 Communication Procedure of Master/Slave Communication Function .....................429 Connection Between CPUs in Master/Slave Communication ...................................428 Connection Between CPUs in Two-Way Communication ...................................425 Register Settings in Master/Slave Communication ...................................427 Register Settings in Two-Way Communication ...................................425 Communication Prescaler Control Register Communication Prescaler Control Register (CDCR) ..............................................411 Communication Prescaler Control Register 0/1 (SDCR0/SDCR1) ................................383 Compare Block Diagram of Output Compare ............196, 206 Clear Timing of Free-run Timer (Match with Compare Register 0)..........219 Compare Clear Register (CPCLR)......................201 Compare Function ............................................257 List of Output Compare Registers ......................205 Output Compare Control Register (OCS01/OCS23)..................................207 Output Compare Register (OCCP0 to OCCP3).............................206 Program Example of Output Compare ................226 Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1).....................................250 Selection of Reload and Compare Functions ............................................256 635 INDEX Compare Clear Register Compare Clear Register (CPCLR) ..................... 201 Condition Conditions for External Connection of Peripheral Devices .............................................. 335 Condition Code Register Condition Code Register (CCR)........................... 29 Configuration Basic Configuration of Serial Programming Connection with MB90F983 ................ 490 Configuration and Function of 16-bit Input/Output Timer ................................................. 194 Configuration of 16-bit Input/Output Timer Register .............................................. 199 Configuration of 16-bit Reload Timer Registers ............................................ 274 Configuration of Clock Selection Register (CKSCR)............................................ 108 Configuration of EI2OS Descriptor (ISD) ............. 76 Configuration of Hardware Interrupt .................... 50 Configuration of Interrupt Control Register (ICR00 to ICR15).................................. 46 Configuration of PLL Output Selection Register (PLLOS) ............................................ 111 Configuration of Watch Timer Control Register (WTC) ............................................... 188 DMA Descriptor Configuration ........................... 66 Product Configuration........................................... 3 Sector Configuration......................................... 464 System Configuration and E2PROM Memory Map ................................................... 450 System Configuration of Flash Microcontroller Programmer (Yokogawa Digital Computer Corporation) ....................................... 492 Confirmation Confirmation of Operation State ........................ 520 Connection Basic Configuration of Serial Programming Connection with MB90F983 ................ 490 Conditions for External Connection of Peripheral Devices .............................................. 335 Connection Between CPUs in Master/Slave Communication................................... 428 Connection Between CPUs in Two-Way Communication................................... 425 Connection of Oscillator and External Clock .................................... 118 Example of Connection in Single-Chip Mode (When Using the User Power Supply) .............. 493 Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) .............................................. 495 Continuous Continuous Prefix Codes..................................... 38 Example of μDMAC Start in Continuous Mode ................................................. 360 636 Control Status Register Control Status Register (ICS01) ........................ 210 Control Status Register 1 (ADCS1) ................... 346 Control Status Register 2 (ADCS2) ................... 349 Conversion Caution when Using the Conversion Data Protection Function............................................. 364 Conversion Data Protection Function................. 364 Conversion Operation Using μDMAC ............... 357 Operation Flow of Conversion Data Protection Function (when μDMAC is Used) ........ 365 Correspondence Correspondence Between Access Areas and Physical Address.............................................. 149 Correspondence Between Reset-Factor Bits and Reset Factors ............................................... 100 Correspondence to DMA Transfer and EI2OS Function............. 212, 252, 281, 314, 332, 354, 386, 414, 511, 553 Count Clear Count Clear/Gate Function ............................... 259 Count Clock Count Clock and Maximum Interval .................. 522 Count Clock Selection...................................... 516 Selection of Count Clock .................................. 317 Count Direction Count Direction Flag, Count Direction Reversal Flag ................................................... 260 Count Timing Count Timing of Free-run Timer ....................... 219 Counter Block Diagram of 8/16-bit Up/Down Counter/Timer .................................... 237 Block Diagram of Pin Related to 8/16-bit Up/Down Counter/Timer .................................... 239 Clearing the Counter ........................................ 259 Counter Control Register (ch.0) Upper (CCRH0) ........................................... 241 Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1)................................ 245 Counter Control Register (ch.1) Upper (CCRH1) ........................................... 243 Counter Operation Modes ................................. 271 Counter Status Register 0/1 (CSR0/CSR1) ......... 247 Data Counter (DCT)..................................... 68, 78 Interrupt of 8/16-bit Up/Down Counter/Timer .................................... 251 Interrupt of 8/16-bit Up/Down Counter/Timer, DMA Transfer, and EI2OS................... 252 Interrupt of PPG Counter Underflow ................. 313 List of 8/16-bit Up/Down Counter/Timer Registers ............................................ 240 Major Functions of 8/16-bit Up/Down Counter/Timer .................................... 236 Measurement Mode and Counter Operation........ 526 INDEX Pin Related to 8/16-bit Up/Down Counter/Timer .................................... 238 Program Counter (PC) ........................................ 32 Program Example of 8/16-bit Up/Down Counter/Timer .................................... 261 Timer Counter Control Status Register (TCCS) .............................................. 202 Timer Counter Data Register (TCDT) ................ 201 Watch Counter................................................. 190 Counter Control Register Counter Control Register (ch.0) Upper (CCRH0)............................................ 241 Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1)................................ 245 Counter Control Register (ch.1) Upper (CCRH1)............................................ 243 Counter Operation Counter Operation Modes ................................. 271 Measurement Mode and Counter Operation........ 526 Counter Status Register Counter Status Register 0/1 (CSR0/CSR1) ......... 247 CPCLR Compare Clear Register (CPCLR) ..................... 201 CPU Connection Between CPUs in Master/Slave Communication .................................. 428 Connection Between CPUs in Two-Way Communication .................................. 425 CPU Intermittent Operation Mode ............. 121, 128 CPU Operation Mode and Current Consumption ...................................... 120 Overview of CPU Specifications ......................... 20 CSR Counter Status Register 0/1 (CSR0/CSR1) ......... 247 Current Consumption CPU Operation Mode and Current Consumption ...................................... 120 D Data Counter Data Counter (DCT)..................................... 68, 78 Data Polling Flag State Transitions of the Data Polling Flag (DQ7) ................................................ 474 Data Protection Caution when Using the Conversion Data Protection Function............................................. 364 Conversion Data Protection Function ................. 364 Operation Flow of Conversion Data Protection Function (when μDMAC is Used) ........ 365 Data Register Data Register (IDAR)....................................... 551 Data Registers (ADCR2 and ADCR1)................ 352 DCT Data Counter (DCT) .....................................68, 78 DDR Port Direction Registers (DDR2 to DDR4, DDR6 to DDRA) ......155 Dedicated Register Dedicated Registers ............................................25 Delay Block Diagram of Delay Interrupt Generation Module .................................................89 List of Registers in Delay Interrupt Generation Module .................................................89 Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch) ..............90 Operation of Delay Interrupt Generation Module .................................................90 Description Description of Instruction Presentation Items and Symbols..............................................592 Descriptor Configuration of EI2OS Descriptor (ISD)..............76 DMA Descriptor Configuration............................66 Device Conditions for External Connection of Peripheral Devices...............................................335 Device Handing Precautions ................................16 Direct Addressing Direct Addressing .............................................574 Direct Page Register Direct Page Register (DPR) <Initial Value: 01H> ..............................34 Divide Ratio Control Register Divide Ratio Control Register (DIVR0, DIVR1).................................509 DIVR Divide Ratio Control Register (DIVR0, DIVR1).................................509 DMA Correspondence to DMA Transfer and EI2OS Function ............ 212, 252, 281, 314, 332, 354, 386, 414, 511, 553 DMA Control Status Register (DMACS) ..............69 DMA Descriptor Configuration............................66 DTP/External Interrupt, DMA Transfer, and EI2OS.................................................332 Interrupt of 16-bit Input/Output Timer, DMA Transfer, and EI2OS.............................212 Interrupt of 16-bit Reload Timer, DMA Transfer, and EI2OS.................................................281 Interrupt of 8/10-bit A/D Converter, DMA Transfer, and EI2OS...........................................353 Interrupt of 8/16-bit PPG Timer, DMA Transfer, and EI2OS.................................................314 Interrupt of 8/16-bit Up/Down Counter/Timer, DMA Transfer, and EI2OS ...................252 637 INDEX Interrupt of Expanded I/O Serial Interface, DMA Transfer, and EI2OS ................... 385 Interrupt of I2C Interface, DMA Transfer, and EI2OS ................................................ 553 Interrupt of PWC Timer, DMA Transfer, and EI2OS ................................................ 511 Interrupt of UART, DMA Transfer, and EI2OS ................................................ 414 DMA Control Status Register DMA Control Status Register (DMACS) .............. 69 DMA Transfer Correspondence to DMA Transfer and EI2OS Function .............212, 252, 281, 314, 332, 354, 386, 414, 511, 553 DTP/External Interrupt, DMA Transfer, and EI2OS ................................................ 332 Interrupt of 16-bit Input/Output Timer, DMA Transfer, and EI2OS ............................ 212 Interrupt of 16-bit Reload Timer, DMA Transfer, and EI2OS ................................................ 281 Interrupt of 8/10-bit A/D Converter, DMA Transfer, and EI2OS .......................................... 353 Interrupt of 8/16-bit PPG Timer, DMA Transfer, and EI2OS ................................................ 314 Interrupt of 8/16-bit Up/Down Counter/Timer, DMA Transfer, and EI2OS ................... 252 Interrupt of Expanded I/O Serial Interface, DMA Transfer, and EI2OS ................... 385 Interrupt of I2C Interface, DMA Transfer, and EI2OS ................................................ 553 Interrupt of PWC Timer, DMA Transfer, and EI2OS ................................................ 511 Interrupt of UART, DMA Transfer, and EI2OS ................................................ 414 DMACS DMA Control Status Register (DMACS) .............. 69 DPR Direct Page Register (DPR) <Initial Value: 01H> .............................. 34 DQ State Transitions of Sector Erase Timer Flag (DQ3) ................................................ 478 State Transitions of the Data Polling Flag (DQ7) ................................................ 474 State Transitions of the Timing Limit Excess Flag (DQ5) ................................................ 477 State Transitions of the Toggle Bit Flag (DQ6) ................................................ 476 DTB Bank Select Prefix (PCB, DTB, ADB, SPB) ......... 36 DTP DTP Operation................................................. 334 Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register)................... 328 Interrupt/DTP Source Register (EIRR: External Interrupt Request Register)................... 329 638 DTP/External Interrupt Block Diagram of DTP/External Interrupt .......... 326 Block Diagram of Pin Related to DTP/External Interrupt ............................................. 327 DTP/External Interrupt ..................................... 331 DTP/External Interrupt, DMA Transfer, and EI2OS ................................................ 332 List of Registers for DTP/External Interrupt ....... 328 Overview of DTP/External Interrupt .................. 326 Pin Related to DTP/External Interrupt................ 326 Procedure for DTP/External Interrupt Operation ........................................... 335 Program Example of DTP/External Interrupt ............................................. 337 E E2PROM E2PROM Memory Map.................................... 451 Operation of Address Match Detection Function at Storing Patch Program in E2PROM ...... 453 System Configuration and E2PROM Memory Map ................................................... 450 Effective Address Field Effective Address Field ............................ 573, 591 EI2OS Configuration of EI2OS Descriptor (ISD) ............. 76 Correspondence to DMA Transfer and EI2OS Function............. 212, 252, 281, 314, 332, 354, 386, 414, 511, 553 DTP/External Interrupt, DMA Transfer, and EI2OS ................................................ 332 2 EI OS Status Register (ISCS).............................. 79 Extended Intelligent I/O Service (EI2OS) ............. 74 Flowchart of Operation of EI2OS ........................ 81 Interrupt of 8/10-bit A/D Converter, DMA Transfer, and EI2OS .......................................... 353 Interrupt of 8/16-bit Up/Down Counter/Timer, DMA Transfer, and EI2OS................... 252 Interrupt of Expanded I/O Serial Interface, DMA Transfer, and EI2OS................... 385 Interrupt of I2C Interface, DMA Transfer, and EI2OS ................................................ 553 Interrupt of PWC Timer, DMA Transfer, and EI2OS ................................................ 511 Interrupt of UART, DMA Transfer, and EI2OS ................................................ 414 Operation of EI2OS............................................ 75 Procedure for Use of EI2OS ................................ 82 Processing Time (One Transfer Time) of the Extended Intelligent I/O Service (EI2OS)............... 83 EI2OS Status Register EI2OS Status Register (ISCS).............................. 79 EIRR Interrupt/DTP Source Register (EIRR: External Interrupt Request Register) .................. 329 INDEX ELVR Request Level Setting Register (ELVR: External Level Register) ................................... 329 End End Timing of the Automatic Algorithm ............ 468 ENIR Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register) .................. 328 Erase Chip/Sector Erase Operation ............................. 474 Erasing All Data in the Flash Memory (Chip Erase) ....................................... 483 Erasing Arbitrary Data in the Flash Memory (Sector Erase) ..................................... 484 Flash Memory Write/Erase ............................... 479 Methods for Writing/Erasing Flash Memory ............................................. 462 Sector Erase Operation ..................................... 478 Sector Erase Suspend ....................... 475, 476, 478 State Transitions of Sector Erase Timer Flag (DQ3) ................................................ 478 Write/Chip Sector Erase Operation .................... 477 Write/Chip Sector Erase Operations................... 476 Error Bus Error ........................................................ 555 Event Count Mode Event Count Mode ........................................... 290 Event Count Mode (External Clock Mode) ......... 270 Example Example of Connection in Single-Chip Mode (When Using the User Power Supply).............. 493 Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) .............................................. 495 Example of Input Capture Timing...................... 218 Example of μDMAC Start in Continuous Mode ................................................. 360 Example of μDMAC Start in Single Mode ......... 358 Example of μDMAC Start in Stop Mode ............ 362 Example of Multiple Interrupts............................ 58 Examples of Output Waveform ......................... 216 Program Example for Address Match Detection Function............................................. 455 Program Example of 16-bit Reload Timer .......... 292 Program Example of 8/10-bit A/D Converter ........................................... 367 Program Example of 8/16-bit PPG Timer ........... 321 Program Example of 8/16-bit Up/Down Counter/Timer .................................... 261 Program Example of DTP/External Interrupt ............................................. 337 Program Example of Expanded I/O Serial Interface............................................. 394 Program Example of Free-run Timer.................. 222 Program Example of Input Capture.................... 232 Program Example of Output Compare ................226 Program Example of UART ..............................432 Relationship Between Mode Pins and Mode Data (an Example Showing Recommended Relationship).......................................149 Setting Method Other than Program Example ............................. 223, 227, 233, 262, 293, 322, 338, 368, 395, 433 Exception Processing Exception Processing due to Execution of Undefined Instruction.............................................85 Execution Exception Processing due to Execution of Undefined Instruction.............................................85 Program Execution ...........................................449 Execution Cycle Count Calculating the Execution Cycle Count...............589 Execution Cycle Count......................................588 Extended Intelligent I/O Service Extended Intelligent I/O Service (EI2OS)..............74 Processing Time (One Transfer Time) of the Extended Intelligent I/O Service (EI2OS) ...............83 External Clock Connection of Oscillator and External Clock.....................................118 Event Count Mode (External Clock Mode)..........270 External Interrupt Block Diagram of DTP/External Interrupt...........326 Block Diagram of Pin Related to DTP/External Interrupt..............................................327 DTP/External Interrupt......................................331 DTP/External Interrupt, DMA Transfer, and EI2OS.................................................332 External Interrupt Request Level ........................336 Interrupt/DTP Source Register (EIRR: External Interrupt Request Register) ...................329 List of Registers for DTP/External Interrupt ........328 Operation of External Interrupt Unit ...................333 Overview of DTP/External Interrupt...................326 Pin Related to DTP/External Interrupt ................326 Procedure for DTP/External Interrupt Operation............................................335 Program Example of DTP/External Interrupt..............................................337 External Interrupt Request Register Interrupt/DTP Source Register (EIRR: External Interrupt Request Register) ...................329 External Level Register Request Level Setting Register (ELVR: External Level Register) ....................................329 External Shift Clock Mode External Shift Clock Mode ................................388 External-reset Block Diagram of External-reset Pin ....................96 639 INDEX F F2MC-16LX Instruction List F2MC-16LX Instruction List ............................. 595 Features Features of the 1.5M Bit Flash Memory.............. 462 Features of the 8/10-bit A/D Converter............... 342 MB90980 Series Features ..................................... 2 UART Features ................................................ 398 Fetch Mode Fetch........................................................ 98 Flag Count Direction Flag, Count Direction Reversal Flag ................................................... 260 Flag Change Suppress Prefix (NCC) .................... 37 Hardware Sequence Flags ................................. 473 State Transitions of Sector Erase Timer Flag (DQ3) ................................................ 478 State Transitions of the Data Polling Flag (DQ7) ................................................ 474 State Transitions of the Timing Limit Excess Flag (DQ5) ................................................ 477 State Transitions of the Toggle Bit Flag (DQ6) ................................................ 476 Flash Memory Erasing All Data in the Flash Memory (Chip Erase)........................................ 483 Erasing Arbitrary Data in the Flash Memory (Sector Erase) ..................................... 484 Features of the 1.5M Bit Flash Memory.............. 462 Flash Memory Control Status Register (FMCS) ...................................... 463, 465 Flash Memory Write/Erase................................ 479 Methods for Writing/Erasing Flash Memory ............................................. 462 Operation for Writing to Flash Memory.............. 482 Resuming the Sector Erasure of Flash Memory..................................... 487 Setting the Flash Memory to the Read/Reset State................................................... 480 Suspending Sector Erasure for the Flash Memory .......................... 486 Writing Data to Flash Memory .......................... 481 Flash Memory Control Status Register Flash Memory Control Status Register (FMCS) ...................................... 463, 465 Flash Microcontroller Programmer Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) .............................................. 495 System Configuration of Flash Microcontroller Programmer (Yokogawa Digital Computer Corporation) ....................................... 492 Flow Flow of Program Patch Processing..................... 454 Hardware Interrupt Operation Flow...................... 54 640 Operation Flow of Conversion Data Protection Function (when μDMAC is Used) ........ 365 Operational Flow of Pulse Width Measurement ...................................... 529 Overall Flow of Interrupt Operation..................... 41 Timer Operation Flow ...................................... 523 Flowchart Flowchart of Operation of EI2OS ........................ 81 FMCS Flash Memory Control Status Register (FMCS) ..................................... 463, 465 Free-run Timer Block Diagram of Free-run Timer ..................... 196 Clear Timing of Free-run Timer (Match with Compare Register 0) ......... 219 Count Timing of Free-run Timer ....................... 219 List of Free-run Timer Registers........................ 200 Operation of Free-run Timer ............................. 214 Program Example of Free-run Timer ................. 222 Free-run Timer Register List of Free-run Timer Registers........................ 200 Fujitsu Standard Pins Used for Fujitsu Standard Serial On-Board Writing .............................................. 491 Function Block Diagram of Address Match Detection Function............................................. 443 Block Diagram of the ROM Mirror Function Selection Module .............................................. 458 Caution when Using the Conversion Data Protection Function............................................. 364 Clock Source for Watchdog Timer Specifying Function............................................. 191 Clock Supplying Function ........................ 161, 168 Communication Procedure for Two-Way Communication Function..................... 426 Communication Procedure of Master/Slave Communication Function..................... 429 Compare Function............................................ 257 Configuration and Function of 16-bit Input/Output Timer................................................. 194 Conversion Data Protection Function................. 364 Correspondence to DMA Transfer and EI2OS Function............. 212, 252, 281, 314, 332, 354, 386, 414, 511, 553 Count Clear/Gate Function ............................... 259 Function of 8/16-bit PPG Timer ........................ 300 Function of Each Bit in Interrupt Control Register (ICR00 to ICR15) ................................. 47 Function Selection ........................................... 429 Functions of I/O Port........................................ 152 Functions of Program Address Detection Registers (PADR0 and PADR1) ......................... 448 Functions of Watch Timer ................................ 186 Functions of Watchdog Timer ........................... 174 Hardware Interrupt Function ............................... 49 INDEX I2C Interface Function ...................................... 534 Interrupt Control Register (ICR00 to ICR15) Function............................................... 46 Interrupt Function of Expanded I/O Serial Interface............................................. 393 Interval Interrupt Function of Watch Timer ........ 190 Interval Timer Function .................................... 160 List of Registers and Initial Values of Address Match Detection Function .............................. 444 Major Functions of 8/16-bit Up/Down Counter/Timer .................................... 236 μDMAC Functions............................................. 63 Operation Flow of Conversion Data Protection Function (when μDMAC is Used) ........ 365 Operation of Address Match Detection Function............................................. 449 Operation of Address Match Detection Function at Storing Patch Program in E2PROM ...... 453 Operation of Interval Timer Function (Time-base Timer) .............................. 167 Operation of Timer Functions ........................... 513 Operations of the Pulse Width Measurement Function............................................. 514 Overview of Address Match Detection Function............................................. 442 Pin Functions....................................................... 8 Program Example for Address Match Detection Function............................................. 455 PWC Timer Functions ...................................... 498 Registers of the ROM Mirror Function Selection Module .............................................. 458 Reload Function............................................... 256 ROMM (ROM Mirror Function Selection Register) ............................................ 459 Selection of Reload and Compare Functions ........................................... 256 Sub Clock Oscillation Stabilization Wait Time Function............................................. 191 Timer Function for Oscillation Stabilization Wait Time .................................................. 167 Types and Functions of Interrupts........................ 40 G Gate Count Clear/Gate Function................................ 259 General-purpose Register General-purpose Register.................................... 26 General-purpose Register (Register Bank) ............ 35 Generation Address Generation Type.................................... 21 Block Diagram of Delay Interrupt Generation Module ................................................ 89 Generation of Interrupt Requests ....................... 528 Interrupt Generation Request............................. 521 List of Registers in Delay Interrupt Generation Module ................................................ 89 Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch) ..............90 Operation of Delay Interrupt Generation Module .................................................90 H Handling Handling of Analog Input Pins...........................366 Power Supply Handling Precautions .....................17 Hardware Interrupt Configuration of Hardware Interrupt.....................50 Hardware Interrupt Function................................49 Hardware Interrupt Operation ..............................53 Hardware Interrupt Operation Flow ......................54 Hardware Interrupt Processing Time.....................59 Procedure for Using Hardware Interrupt ...............55 Return from Hardware Interrupt ...........................52 Starting Hardware Interrupt .................................52 Suppressing Hardware Interrupt ...........................50 Hardware Sequence Flags Hardware Sequence Flags..................................473 I I/O Block Diagram of Expanded I/O Serial Interface .............................................375 Block Diagram of Pin Related to Expanded I/O Serial Interface .............................................376 Extended Intelligent I/O Service (EI2OS)..............74 Functions of I/O Port ........................................152 I/O Circuit Type .................................................11 I/O Map ...........................................................560 I/O Register Address Pointer (IOA)................68, 78 Interrupt Function of Expanded I/O Serial Interface .............................................393 Interrupt of Expanded I/O Serial Interface...........385 Interrupt of Expanded I/O Serial Interface, DMA Transfer, and EI2OS ...................385 Interrupt Source Related to Expanded I/O Serial Interface .............................................385 List of Registers for Expanded I/O Serial Interface .............................................377 Operational States of Serial I/O Units .................389 Overview of Expanded I/O Serial Interface .........374 Overview of Operation for Expanded I/O Serial Interface .............................................387 Pin Related to Expanded I/O Serial Interface .............................................375 Processing Time (One Transfer Time) of the Extended Intelligent I/O Service (EI2OS) ...............83 Program Example of Expanded I/O Serial Interface .............................................394 Registers for I/O Port ........................................153 I/O Circuit I/O Circuit Type .................................................11 641 INDEX I/O Map I/O Map........................................................... 560 I/O Port Functions of I/O Port ........................................ 152 Registers for I/O Port........................................ 153 I/O Register Address Pointer I/O Register Address Pointer (IOA) ............... 68, 78 2 I C Block Diagram of Pin Related to I2C Interface ....................................... 536 Block Diagram of the I2C Interface .................... 535 I2C Interface Function ...................................... 534 Interrupt Control Bit and Interrupt Source of I2C Interface ............................................. 552 Interrupt of I2C Interface, DMA Transfer, and EI2OS ................................................ 553 Interrupt Source of I2C Interface........................ 552 List of I2C Interface Registers ........................... 537 Pin Related to I2C Interface............................... 536 2 I C Interface Register List of I2C Interface Registers ........................... 537 IADR Address Register (IADR) .................................. 550 IBCR Bus Control Register (IBCR)............................. 541 Notes on Using the Bus Control Register (IBCR) ............................................... 547 IBSR Bus Status Register (IBSR) ............................... 539 ICCR Clock Control Register (ICCR).......................... 548 ICR Configuration of Interrupt Control Register (ICR00 to ICR15).................................. 46 Function of Each Bit in Interrupt Control Register (ICR00 to ICR15).................................. 47 Interrupt Control Register (ICR00 to ICR15) Function ............................................... 46 ICS Control Status Register (ICS01)......................... 210 IDAR Data Register (IDAR) ....................................... 551 ILM Interrupt Level Mask Register (ILM) ................... 30 Indirect Addressing Indirect Addressing .......................................... 580 Initial Value Direct Page Register (DPR) <Initial Value: 01H> .............................. 34 Initial Value of Hardware Components............... 319 List of Registers and Initial Values of Address Match Detection Function .............................. 444 642 Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector>................................................ 33 Input Capture Block Diagram of Input Capture........................ 197 Example of Input Capture Timing ..................... 218 Input Capture Data Register (IPCP0, IPCP1) ...... 209 List of Input Capture Registers .......................... 209 Program Example of Input Capture.................... 232 Input Capture Data Register Input Capture Data Register (IPCP0, IPCP1) ...... 209 Input Capture Register List of Input Capture Registers .......................... 209 Input Frequency Oscillation Clock Frequency and Serial Clock Input Frequency .......................................... 492 Instruction Description of Instruction Presentation Items and Symbols ............................................. 592 Exception Processing due to Execution of Undefined Instruction ............................................ 85 F2MC-16LX Instruction List............................. 595 Instruction Types ............................................. 571 Interrupt Suppress Instruction ............................. 38 Restrictions on Interrupt Suppress Instruction and Prefix Instruction .................................. 38 Structure of Instruction Map ............................. 609 Instruction Presentation Items and Symbols Description of Instruction Presentation Items and Symbols ............................................. 592 Intelligent I/O Service Extended Intelligent I/O Service (EI2OS) ............. 74 Processing Time (One Transfer Time) of the Extended Intelligent I/O Service (EI2OS)............... 83 Interface Block Diagram of Expanded I/O Serial Interface............................................. 375 Block Diagram of Pin Related to Expanded I/O Serial Interface............................................. 376 Block Diagram of Pin Related to I2C Interface....................................... 536 Block Diagram of the I2C Interface.................... 535 I2C Interface Function ...................................... 534 Interrupt Control Bit and Interrupt Source of I2C Interface............................................. 552 Interrupt Function of Expanded I/O Serial Interface............................................. 393 Interrupt of Expanded I/O Serial Interface .......... 385 Interrupt of Expanded I/O Serial Interface, DMA Transfer, and EI2OS................... 385 Interrupt of I2C Interface, DMA Transfer, and EI2OS ................................................ 553 Interrupt Source of I2C Interface ....................... 552 Interrupt Source Related to Expanded I/O Serial Interface............................................. 385 INDEX List of I2C Interface Registers ........................... 537 List of Registers for Expanded I/O Serial Interface............................................. 377 Overview of Expanded I/O Serial Interface ........ 374 Overview of Operation for Expanded I/O Serial Interface............................................. 387 Pin Related to Expanded I/O Serial Interface............................................. 375 Pin Related to I2C Interface............................... 536 Program Example of Expanded I/O Serial Interface............................................. 394 Intermittent CPU Intermittent Operation Mode ............. 121, 128 Internal Clock Mode Internal Clock Mode......................................... 270 Operation of Internal Clock Mode (One-Shot Mode) ................................ 287 Operations of Internal Clock Mode (Reload Mode).................................... 284 Internal Shift Clock Mode Internal Shift Clock Mode................................. 388 Internal Timer Precautions when Starting by External Trigger/ Internal Timer..................................... 366 Interrupt Block Diagram of Delay Interrupt Generation Module ................................................ 89 Block Diagram of DTP/External Interrupt .......... 326 Block Diagram of Pin Related to DTP/External Interrupt ............................................. 327 Cancellation of Standby Mode by Interrupt ........ 141 Change to Standby Mode and Interrupts ............. 141 Configuration of Hardware Interrupt .................... 50 Configuration of Interrupt Control Register (ICR00 to ICR15) ................................. 46 DTP/External Interrupt ..................................... 331 DTP/External Interrupt, DMA Transfer, and EI2OS ................................................ 332 Example of Multiple Interrupts............................ 58 External Interrupt Request Level ....................... 336 Function of Each Bit in Interrupt Control Register (ICR00 to ICR15) ................................. 47 Generation of Interrupt Requests ....................... 528 Hardware Interrupt Function ............................... 49 Hardware Interrupt Operation.............................. 53 Hardware Interrupt Operation Flow ..................... 54 Hardware Interrupt Processing Time .................... 59 Interrupt Control Bit and Interrupt Source of I2C Interface............................................. 552 Interrupt Control Register (ICR00 to ICR15) Function............................................... 46 Interrupt Factors, Interrupt Vector, and Interrupt Control Register.................................... 43 Interrupt Function of Expanded I/O Serial Interface............................................. 393 Interrupt Generation Request............................. 521 Interrupt Level Mask Register (ILM)....................30 Interrupt of 16-bit Input/Output Timer ................211 Interrupt of 16-bit Input/Output Timer, DMA Transfer, and EI2OS.............................212 Interrupt of 16-bit Reload Timer ........................281 Interrupt of 16-bit Reload Timer, DMA Transfer, and EI2OS.................................................281 Interrupt of 8/10-bit A/D Converter ....................353 Interrupt of 8/10-bit A/D Converter, DMA Transfer, and EI2OS...........................................353 Interrupt of 8/16-bit PPG Timer .........................313 Interrupt of 8/16-bit PPG Timer, DMA Transfer, and EI2OS.................................................314 Interrupt of 8/16-bit Up/Down Counter/Timer.....................................251 Interrupt of 8/16-bit Up/Down Counter/Timer, DMA Transfer, and EI2OS ...................252 Interrupt of A/D Converter ................................353 Interrupt of Expanded I/O Serial Interface...........385 Interrupt of Expanded I/O Serial Interface, DMA Transfer, and EI2OS ...................385 Interrupt of I2C Interface, DMA Transfer, and EI2OS.................................................553 Interrupt of PPG Counter Underflow ..................313 Interrupt of PWC Timer ....................................510 Interrupt of PWC Timer, DMA Transfer, and EI2OS.................................................511 Interrupt of UART ............................................413 Interrupt of UART, DMA Transfer, and EI2OS.................................................414 Interrupt Source of I2C Interface ........................552 Interrupt Source Related to Expanded I/O Serial Interface .............................................385 Interrupt Source Related to PWC Timer..............510 Interrupt Source Related to UART .....................413 Interrupt Sources, Interrupt Vectors, and Interrupt Control Registers .................................568 Interrupt Suppress Instruction ..............................38 Interrupt Timing ...............................................220 Interrupt Vector ..................................................42 Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register) ...................328 Interrupt/DTP Source Register (EIRR: External Interrupt Request Register) ...................329 Interrupts of the 8/16-bit PPG Timer ..................319 Interval Interrupt Function of Watch Timer .........190 List of Interrupt Control Registers ........................45 List of Registers for DTP/External Interrupt ........328 List of Registers in Delay Interrupt Generation Module .................................................89 Multiple Interrupt Operations...............................57 Notes on Software Interrupts ...............................62 Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch) ..............90 Operation of Delay Interrupt Generation Module .................................................90 Operation of External Interrupt Unit ...................333 643 INDEX Overall Flow of Interrupt Operation ..................... 41 Overview of DTP/External Interrupt .................. 326 Pin Related to DTP/External Interrupt ................ 326 Procedure for DTP/External Interrupt Operation ........................................... 335 Procedure for Using Hardware Interrupt ............... 55 Program Example of DTP/External Interrupt ............................................. 337 Restrictions on Interrupt Suppress Instruction and Prefix Instruction................................... 38 Return from Hardware Interrupt........................... 52 Return from Software Interrupt............................ 61 Sample Program for Interrupt Processing.............. 88 Software Interrupt Operation ............................... 62 Stack Operation during Return from Interrupt Processing ............................................ 86 Stack Operation when Interrupt Processing Starts.................................................... 86 Start of Software Interrupt................................... 61 Starting Hardware Interrupt................................. 52 Suppressing Hardware Interrupt........................... 50 Time-base Timer Interrupt ................................ 166 Time-base Timer Interrupt and μDMAC............. 166 Types and Functions of Interrupts ........................ 40 Interrupt Control Register Configuration of Interrupt Control Register (ICR00 to ICR15).................................. 46 Function of Each Bit in Interrupt Control Register (ICR00 to ICR15).................................. 47 Interrupt Control Register (ICR00 to ICR15) Function ............................................... 46 Interrupt Factors, Interrupt Vector, and Interrupt Control Register .................................... 43 Interrupt Sources, Interrupt Vectors, and Interrupt Control Registers................................. 568 List of Interrupt Control Registers........................ 45 Interrupt Function Hardware Interrupt Function ............................... 49 Interrupt Function of Expanded I/O Serial Interface ............................................. 393 Interval Interrupt Function of Watch Timer......... 190 Interrupt Level Mask Register Interrupt Level Mask Register (ILM) ................... 30 Interrupt Request External Interrupt Request Level........................ 336 Generation of Interrupt Requests........................ 528 Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register)................... 328 Interrupt/DTP Source Register (EIRR: External Interrupt Request Register)................... 329 Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch).............. 90 Interrupt Sources Interrupt Sources, Interrupt Vectors, and Interrupt 644 Control Registers ................................ 568 Interrupt Vector Interrupt Factors, Interrupt Vector, and Interrupt Control Register.................................... 43 Interrupt Sources, Interrupt Vectors, and Interrupt Control Registers ................................ 568 Interrupt Vector ................................................. 42 Interrupt/DTP Enable Register Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register) .................. 328 Interrupt/DTP Source Register Interrupt/DTP Source Register (EIRR: External Interrupt Request Register) .................. 329 Interval Interrupt Function Interval Interrupt Function of Watch Timer ........ 190 Interval Timer Interval Timer Function .................................... 160 Operation of Interval Timer Function (Time-base Timer) .............................. 167 IOA I/O Register Address Pointer (IOA) ............... 68, 78 IPCP Input Capture Data Register (IPCP0, IPCP1) ...... 209 ISCS EI2OS Status Register (ISCS).............................. 79 ISD Configuration of EI2OS Descriptor (ISD) ............. 76 L Latch Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch) ............. 90 Level Mask Interrupt Level Mask Register (ILM) ................... 30 List List of 8/16-bit PPG Timer Registers ................. 304 List of 8/16-bit Up/Down Counter/Timer Registers ............................................ 240 List of Free-run Timer Registers........................ 200 List of I2C Interface Registers ........................... 537 List of Input Capture Registers .......................... 209 List of Interrupt Control Registers ....................... 45 List of μDMAC Registers ................................... 63 List of Output Compare Registers...................... 205 List of PWC Timer Registers ............................ 501 List of Registers and Initial Values of Address Match Detection Function.............................. 444 List of Registers for 8/10-bit A/D Converter ....... 345 List of Registers for DTP/External Interrupt ....... 328 List of Registers for Expanded I/O Serial Interface............................................. 377 List of Registers in Delay Interrupt Generation Module ................................................ 89 INDEX Low-Power Consumption Accessing Low-Power Consumption Mode Control Register.............................................. 127 Block Diagram of Low-Power Consumption Control Circuit................................................ 123 Low-Power Consumption Mode Control Register (LPMCR) ........................................... 125 Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode ............................... 143 Operational State in Low-Power Consumption Mode ................................................. 139 Low-Power Consumption Mode Control Register Accessing Low-Power Consumption Mode Control Register.............................................. 127 Low-Power Consumption Mode Control Register (LPMCR) ........................................... 125 Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode ............................... 143 LPMCR Low-Power Consumption Mode Control Register (LPMCR) ........................................... 125 Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode ............................... 143 LQFP-64 Package Dimensions (LQFP-64)............................ 6 Pin Assignment Diagram (LQFP-64) ..................... 7 M Machine Clock Machine Clock ................................................ 114 Main Clock Mode Main Clock Mode, PLL Clock Mode, and Sub Clock Mode ................................................. 113 Major Functions Major Functions of 8/16-bit Up/Down Counter/Timer .................................... 236 Mask Interrupt Level Mask Register (ILM) ................... 30 Master Communication Procedure of Master/Slave Communication Function..................... 429 Connection Between CPUs in Master/Slave Communication .................................. 428 Register Settings in Master/Slave Communication .................................. 427 MB90980 Series Block Diagram of MB90980 Series ....................... 5 MB90980 Series Features ..................................... 2 MB90F983 Basic Configuration of Serial Programming Connection with MB90F983 ................ 490 MD Settings of Mode Pins (MD2 to MD0) ................147 μDMAC Conversion Operation Using μDMAC ................357 Example of μDMAC Start in Continuous Mode..................................................360 Example of μDMAC Start in Single Mode ..........358 Example of μDMAC Start in Stop Mode.............362 List of μDMAC Registers....................................63 μDMAC Functions .............................................63 μDMAC Operations............................................65 μDMAC Processing Procedure ............................71 μDMAC Processing Time (Time Per One-time Transfer) .................72 Time-base Timer Interrupt and μDMAC .............166 Measurement Measurement Mode and Counter Operation ........526 Measurement Result Data..................................524 One-Shot Measurement and Repeated Measurement.......................................524 Operation After Measurement Start ....................518 Operational Flow of Pulse Width Measurement.......................................529 Operations of the Pulse Width Measurement Function .............................................514 Start and Stop of Timer/Pulse Width Measurement.......................................518 Memory Allocation for Data of Multi-byte Length in Memory Space....................................................24 E2PROM Memory Map.....................................451 Erasing All Data in the Flash Memory (Chip Erase) ........................................483 Erasing Arbitrary Data in the Flash Memory (Sector Erase)......................................484 Features of the 1.5M Bit Flash Memory ..............462 Flash Memory Control Status Register (FMCS) ......................................463, 465 Flash Memory Write/Erase ................................479 Memory Map .....................................................21 Memory Space .................................................558 Methods for Writing/Erasing Flash Memory..............................................462 Operation for Writing to Flash Memory ..............482 Overview of Memory Access Mode ...................146 Resuming the Sector Erasure of Flash Memory .....................................487 Setting the Flash Memory to the Read/Reset State ...................................................480 Suspending Sector Erasure for the Flash Memory...........................486 System Configuration and E2PROM Memory Map....................................................450 Writing Data to Flash Memory...........................481 Memory Map E2PROM Memory Map.....................................451 645 INDEX Memory Map ..................................................... 21 System Configuration and E2PROM Memory Map ................................................... 450 Memory Space Allocation for Data of Multi-byte Length in Memory Space ................................................... 24 Memory Space ................................................. 558 Methods Methods for Writing/Erasing Flash Memory ............................................. 462 Microcontroller Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) .............................................. 495 System Configuration of Flash Microcontroller Programmer (Yokogawa Digital Computer Corporation) ....................................... 492 Minimum Input Pulse Width Minimum Input Pulse Width ............................. 527 Mode Accessing Low-Power Consumption Mode Control Register .............................................. 127 Bus Mode Setting Bits (M1, M0) ....................... 148 Bus Modes....................................................... 146 Canceling the Sleep Mode................................. 131 Canceling the Stop Mode .................................. 136 Canceling the Time-base Timer Mode................ 132 Canceling the Watch Mode ............................... 134 Cancellation of Standby Mode by Interrupt......... 141 Change of Clock Mode ..................................... 113 Change to Sleep Mode ...................................... 130 Change to Standby Mode and Interrupts ............. 141 Change to Stop Mode ....................................... 136 Change to Time-base Timer Mode ..................... 132 Change to Watch Mode..................................... 134 Clock Modes.................................................... 121 Counter Operation Modes ................................. 271 CPU Intermittent Operation Mode ............. 121, 128 CPU Operation Mode and Current Consumption ...................................... 120 Event Count Mode ........................................... 290 Event Count Mode (External Clock Mode) ......... 270 Example of Connection in Single-Chip Mode (When Using the User Power Supply) .............. 493 Example of μDMAC Start in Continuous Mode ................................................. 360 Example of μDMAC Start in Single Mode.......... 358 Example of μDMAC Start in Stop Mode ............ 362 External Shift Clock Mode ................................ 388 Internal Clock Mode......................................... 270 Internal Shift Clock Mode ................................. 388 Low-Power Consumption Mode Control Register (LPMCR) ........................................... 125 Main Clock Mode, PLL Clock Mode, and Sub Clock Mode ................................................. 113 Measurement Mode and Counter Operation ........ 526 646 Mode Data ...................................................... 148 Mode Fetch ....................................................... 98 Mode Pins ......................................................... 97 Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode ............................... 143 One-Shot Operation Mode ................................ 521 Operation in Asynchronous Mode (Operation Modes 0 and 1)................... 420 Operation in CLK Synchronous Mode (Operation Mode 2)............................. 423 Operation Mode............................................... 315 Operation Modes ............................. 146, 355, 415 Operation Modes of the 16-bit Reload Timer................................................. 270 Operation of Internal Clock Mode (One-Shot Mode) ................................ 287 Operational State in Low-Power Consumption Mode ................................................. 139 Operational States in Standby Mode .................. 129 Operations of Internal Clock Mode (Reload Mode).................................... 284 Overview of Memory Access Mode................... 146 Pin State in Single Chip Mode........................... 140 Pin States after Mode Data is Read .................... 101 PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2) ................................ 305 PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3) ................................ 307 Precaution on Using Sub Clock Mode................ 468 Relationship Between Mode Pins and Mode Data (an Example Showing Recommended Relationship) ...................................... 149 Reload Operation Mode.................................... 521 Selection of Count Mode .................................. 253 Selection of Operation Mode............................. 516 Serial Mode Control Status Register 0/1 (SMCS0/SMCS1) ............................... 378 Serial Mode Register (SMR) ............................. 402 Setting Sub Clock Mode ................................... 469 Settings of Mode Pins (MD2 to MD0) ............... 147 Standby Mode ................................................. 121 Switching the Clock Mode................................ 142 Mode Data Mode Data ...................................................... 148 Pin States after Mode Data is Read .................... 101 Relationship Between Mode Pins and Mode Data (an Example Showing Recommended Relationship) ...................................... 149 Mode Fetch Mode Fetch ....................................................... 98 Mode Pins Mode Pins ......................................................... 97 Relationship Between Mode Pins and Mode Data (an Example Showing Recommended Relationship) ...................................... 149 INDEX Settings of Mode Pins (MD2 to MD0)................ 147 Module Block Diagram of Delay Interrupt Generation Module ................................................ 89 Block Diagram of the ROM Mirror Function Selection Module .............................................. 458 List of Registers in Delay Interrupt Generation Module ................................................ 89 Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch).............. 90 Operation of Delay Interrupt Generation Module ................................................ 90 Registers of the ROM Mirror Function Selection Module .............................................. 458 Multi-byte Length Access to Data of Multi-byte Length.................... 24 Allocation for Data of Multi-byte Length in Memory Space ................................................... 24 Multiple Example of Multiple Interrupts............................ 58 Multiple Interrupt Operations .............................. 57 Multiplication Selection of PLL Clock Multiplication Rate ................................................... 114 N NCC Flag Change Suppress Prefix (NCC) .................... 37 Notes Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode ............................... 143 Notes on PWC Timer Usage ............................. 530 Notes on Software Interrupts ............................... 62 Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch).............. 90 Notes on Using the Bus Control Register (IBCR)............................................... 547 Notes on Using Time-base Timer ...................... 170 Notes on Using Watchdog Timer....................... 182 O OCCP Output Compare Register (OCCP0 to OCCP3) ............................ 206 OCS Output Compare Control Register (OCS01/OCS23) ................................. 207 One-Shot Measurement One-Shot Measurement and Repeated Measurement ...................................... 524 One-Shot Mode Operation of Internal Clock Mode (One-Shot Mode) ................................ 287 One-Shot Operation Mode One-Shot Operation Mode.................................521 Operating Setting and Operating State ...............................452 Operation Chip/Sector Erase Operation..............................474 Confirmation of Operation State ........................520 Conversion Operation Using μDMAC ................357 Counter Operation Modes..................................271 CPU Intermittent Operation Mode..............121, 128 CPU Operation Mode and Current Consumption.......................................120 DTP Operation .................................................334 Flowchart of Operation of EI2OS .........................81 Hardware Interrupt Operation ..............................53 Hardware Interrupt Operation Flow ......................54 μDMAC Operations............................................65 Measurement Mode and Counter Operation ........526 Multiple Interrupt Operations...............................57 One-Shot Operation Mode.................................521 Operation After Measurement Start ....................518 Operation and Timing of 16-bit Input/Output Timer .................................................213 Operation during Serial Data Transfer ................392 Operation Flow of Conversion Data Protection Function (when μDMAC is Used) .........365 Operation for Writing to Flash Memory ..............482 Operation in Asynchronous Mode (Operation Modes 0 and 1) ...................420 Operation in CLK Synchronous Mode (Operation Mode 2) .............................423 Operation Mode ...............................................315 Operation Modes ..............................146, 355, 415 Operation Modes of the 16-bit Reload Timer .................................................270 Operation of Address Match Detection Function .............................................449 Operation of Address Match Detection Function at Storing Patch Program in E2PROM .......453 Operation of Delay Interrupt Generation Module .................................................90 Operation of EI2OS.............................................75 Operation of External Interrupt Unit ...................333 Operation of Free-run Timer ..............................214 Operation of Internal Clock Mode (One-Shot Mode).................................287 Operation of Interval Timer Function (Time-base Timer) ...............................167 Operation of Time-base Timer ...........................169 Operation of Timer Functions ............................513 Operation of Watchdog Timer ...........................180 Operational Flow of Pulse Width Measurement.......................................529 Operational State in Low-Power Consumption Mode..................................................139 Operational States in Standby Mode ...................129 647 INDEX Operational States of Serial I/O Units................. 389 Operations of Internal Clock Mode (Reload Mode) .................................... 284 Operations of the Pulse Width Measurement Function ............................................. 514 Outline of 8/16-bit PPG Timer Operation ........... 315 Outline of PWC Timer Operations ..................... 512 Overall Flow of Interrupt Operation ..................... 41 Overview of Operation for Expanded I/O Serial Interface ............................................. 387 PPG Output Operation ...................................... 316 PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2)................................. 305 PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3)................................. 307 Procedure for DTP/External Interrupt Operation ........................................... 335 Reload Operation Mode .................................... 521 Sector Erase Operation ..................................... 478 Selection of Operation Mode ............................. 516 Software Interrupt Operation ............................... 62 Stack Operation during Return from Interrupt Processing ............................................ 86 Stack Operation when Interrupt Processing Starts.................................................... 86 Start/Stop Timing and Input/Output Timing of Shift Operation ........................................... 391 State Transitions during Count Operation ........... 283 Timer Operation Flow ...................................... 523 Write Operation ............................................... 474 Write/Chip Sector Erase Operation .................... 477 Write/Chip Sector Erase Operations ................... 476 Operation Flow Hardware Interrupt Operation Flow...................... 54 Operation Flow of Conversion Data Protection Function (when μDMAC is Used)......... 365 Timer Operation Flow ...................................... 523 Operation Mode Counter Operation Modes ................................. 271 CPU Intermittent Operation Mode ............. 121, 128 CPU Operation Mode and Current Consumption ...................................... 120 One-Shot Operation Mode ................................ 521 Operation in Asynchronous Mode (Operation Modes 0 and 1) ................... 420 Operation in CLK Synchronous Mode (Operation Mode 2) ............................. 423 Operation Mode ............................................... 315 Operation Modes.............................. 146, 355, 415 Operation Modes of the 16-bit Reload Timer ................................................. 270 PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2)................................. 305 PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3)................................. 307 Reload Operation Mode .................................... 521 648 Selection of Operation Mode............................. 516 Oscillation Clock Frequency Oscillation Clock Frequency and Serial Clock Input Frequency .......................................... 492 Oscillation Stabilization Wait Time Oscillation Stabilization Wait Time ........... 117, 142 Reset Factors and Oscillation Stabilization Wait Time .................................................... 94 Sub Clock Oscillation Stabilization Wait Time Function............................................. 191 Timer Function for Oscillation Stabilization Wait Time .................................................. 167 Oscillator Connection of Oscillator and External Clock.................................... 118 Other Other Considerations........................................ 555 Setting Method Other than Program Example ..................................... 223, 227, 233, 262, 293, 322, 338, 368, 395, 433 Outline Outline of 8/16-bit PPG Timer Operation ........... 315 Outline of PWC Timer Operations..................... 512 Output Compare Block Diagram of Output Compare ........... 196, 206 List of Output Compare Registers...................... 205 Output Compare Control Register (OCS01/OCS23) ................................. 207 Output Compare Register (OCCP0 to OCCP3) ............................ 206 Program Example of Output Compare ............... 226 Output Compare Control Register Output Compare Control Register (OCS01/OCS23) ................................. 207 Output Compare Register List of Output Compare Registers...................... 205 Output Compare Register (OCCP0 to OCCP3) ............................ 206 Output Pin Change Timing of Output Pin ........................... 220 Port Output Pin Registers (ODR7, ODR4).......... 156 Output Waveform Examples of Output Waveform ......................... 216 Overall Flow Overall Flow of Interrupt Operation..................... 41 Overview Overview of Address Match Detection Function............................................. 442 Overview of Clocks ......................................... 104 Overview of CPU Specifications ......................... 20 Overview of DTP/External Interrupt .................. 326 Overview of Expanded I/O Serial Interface ........ 374 Overview of Memory Access Mode................... 146 Overview of Operation for Expanded I/O Serial Interface............................................. 387 INDEX Overview of Resetting ........................................ 97 P Package Package Dimensions (LQFP-64)............................ 6 The Packages of the Corresponding Products.......... 4 PACSR Program Address Detection Control Status Register (PACSR)............................................ 445 PADR Functions of Program Address Detection Registers (PADR0 and PADR1) ......................... 448 Program Address Detection Registers (PADR0, PADR1)............................... 447 PC Program Counter (PC) ........................................ 32 PCB Bank Select Prefix (PCB, DTB, ADB, SPB) ......... 36 Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector>................................................ 33 PDR Port Registers (PDR2 to PDR4, PDR6 to PDRA) ........ 154 Physical Address Correspondence Between Access Areas and Physical Address.............................................. 149 Pin Block Diagram of External-reset Pin.................... 96 Block Diagram of Pin Related to 16-bit Input/Output Timer................................................. 198 Block Diagram of Pin Related to 16-bit Reload Timer ............................ 273 Block Diagram of Pin Related to 8/10-bit A/D Converter ........................................... 344 Block Diagram of Pin Related to 8/16-bit PPG Timer ............................. 303 Block Diagram of Pin Related to 8/16-bit Up/Down Counter/Timer .................................... 239 Block Diagram of Pin Related to DTP/External Interrupt ............................................. 327 Block Diagram of Pin Related to Expanded I/O Serial Interface............................................. 376 Block Diagram of Pin Related to I2C Interface....................................... 536 Block Diagram of Pin Related to PWC Timer ........................................ 500 Block Diagram of Pin Related to UART............. 400 Change Timing of Output Pin............................ 220 Handling of Analog Input Pins .......................... 366 Mode Pins ......................................................... 97 Pin Assignment Diagram (LQFP-64) ..................... 7 Pin Functions....................................................... 8 Pin Output Control of Pulses ............................. 318 Pin Related to 16-bit Input/Output Timer ........... 197 Pin Related to 16-bit Reload Timer ....................272 Pin Related to 8/10-bit A/D Converter ................344 Pin Related to 8/16-bit PPG Timer .....................302 Pin Related to 8/16-bit Up/Down Counter/Timer.....................................238 Pin Related to DTP/External Interrupt ................326 Pin Related to Expanded I/O Serial Interface .............................................375 Pin Related to I2C Interface ...............................536 Pin Related to PWC Timer ................................500 Pin Related to UART ........................................400 Pin State in Single Chip Mode ...........................140 Pin States after Mode Data is Read.....................101 Pin States during a Reset ...................................101 Pins Used for Fujitsu Standard Serial On-Board Writing ...............................................491 Port Output Pin Registers (ODR7, ODR4) ..........156 Relationship Between Mode Pins and Mode Data (an Example Showing Recommended Relationship).......................................149 Selection of Input Pin........................................525 Settings of Mode Pins (MD2 to MD0) ................147 Pin Assignment Pin Assignment Diagram (LQFP-64) ......................7 Pin Functions Pin Functions .......................................................8 Pin State Pin State in Single Chip Mode ...........................140 Pin States after Mode Data is Read.....................101 Pin States during a Reset ...................................101 PLL Clock Main Clock Mode, PLL Clock Mode, and Sub Clock Mode..................................................113 Selection of PLL Clock Multiplication Rate....................................................114 PLL Output Selection Register Configuration of PLL Output Selection Register (PLLOS).............................................111 PLLOS Configuration of PLL Output Selection Register (PLLOS).............................................111 Port Functions of I/O Port ........................................152 Port Direction Registers (DDR2 to DDR4, DDR6 to DDRA) ......155 Port Output Pin Registers (ODR7, ODR4) ..........156 Port Registers (PDR2 to PDR4, PDR6 to PDRA).........154 Registers for I/O Port ........................................153 Port Direction Register Port Direction Registers (DDR2 to DDR4, DDR6 to DDRA) ......155 Port Output Pin Register Port Output Pin Registers (ODR7, ODR4) ..........156 649 INDEX Port Register Port Registers (PDR2 to PDR4, PDR6 to PDRA) ........ 154 Power Supply Example of Connection in Single-Chip Mode (When Using the User Power Supply) .............. 493 Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply) .............................................. 495 Power Supply Handling Precautions..................... 17 PPG Block Diagram of Pin Related to 8/16-bit PPG Timer ............................. 303 Block Diagram of the 8/16-bit PPG Timer .......... 301 Function of 8/16-bit PPG Timer......................... 300 Interrupt of 8/16-bit PPG Timer......................... 313 Interrupt of 8/16-bit PPG Timer, DMA Transfer, and EI2OS ................................................ 314 Interrupt of PPG Counter Underflow .................. 313 Interrupts of the 8/16-bit PPG Timer .................. 319 List of 8/16-bit PPG Timer Registers.................. 304 Outline of 8/16-bit PPG Timer Operation ........... 315 Pin Related to 8/16-bit PPG Timer ..................... 302 PPG Output Operation ...................................... 316 PPG0 to PPG3 Output Control Registers (PPG01, PPG23) ................................. 310 PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2)................................. 305 PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3)................................. 307 Program Example of 8/16-bit PPG Timer ........... 321 PPG0 to PPG3 Output Control Register PPG0 to PPG3 Output Control Registers (PPG01, PPG23) ................................. 310 PPG0/PPG2 Operation Mode Control Register PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2)................................. 305 PPG1/PPG3 Operation Mode Control Register PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3)................................. 307 PPGC PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2)................................. 305 PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3)................................. 307 Precaution Device Handing Precautions................................ 16 Power Supply Handling Precautions..................... 17 Precaution on Using Sub Clock Mode ................ 468 Precautions on Using the UART ........................ 431 Precautions when Starting by External Trigger/ Internal Timer ..................................... 366 Prefix Bank Select Prefix (PCB, DTB, ADB, SPB) ......... 36 Common Register Bank Prefix (CMR) ................. 37 650 Continuous Prefix Codes .................................... 38 Flag Change Suppress Prefix (NCC).................... 37 Restrictions on Interrupt Suppress Instruction and Prefix Instruction .................................. 38 Prescaler Communication Prescaler Control Register (CDCR) ............................................. 411 Communication Prescaler Control Register 0/1 (SDCR0/SDCR1)................................ 383 Priority Priority of STP, SLP, and TMD Bits.................. 127 PRLH Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3).............................. 312 PRLL Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3).............................. 312 Procedure Communication Procedure for Two-Way Communication Function..................... 426 Communication Procedure of Master/Slave Communication Function..................... 429 μDMAC Processing Procedure............................ 71 Procedure for DTP/External Interrupt Operation ........................................... 335 Procedure for Sector Erasure............................. 484 Procedure for Use of EI2OS ................................ 82 Procedure for Using Hardware Interrupt............... 55 Processing Exception Processing due to Execution of Undefined Instruction ............................................ 85 Flow of Program Patch Processing .................... 454 Hardware Interrupt Processing Time.................... 59 μDMAC Processing Procedure............................ 71 μDMAC Processing Time (Time Per One-time Transfer) ................ 72 Processing Time (One Transfer Time) of the Extended Intelligent I/O Service (EI2OS)............... 83 Sample Program for Interrupt Processing ............. 88 Stack Operation during Return from Interrupt Processing ............................................ 86 Stack Operation when Interrupt Processing Starts ................................................... 86 Processor Status Processor Status (PS) ......................................... 29 Product Product Configuration .......................................... 3 Program Flow of Program Patch Processing .................... 454 Functions of Program Address Detection Registers (PADR0 and PADR1) ......................... 448 Operation of Address Match Detection Function at Storing Patch Program in E2PROM ...... 453 Program Address Detection Control Status Register (PACSR)............................................ 445 INDEX Program Address Detection Registers (PADR0, PADR1)............................... 447 Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector>................................................ 33 Program Counter (PC) ........................................ 32 Program Example for Address Match Detection Function............................................. 455 Program Example of 16-bit Reload Timer .......... 292 Program Example of 8/10-bit A/D Converter ........................................... 367 Program Example of 8/16-bit PPG Timer ........... 321 Program Example of 8/16-bit Up/Down Counter/Timer .................................... 261 Program Example of DTP/External Interrupt ............................................. 337 Program Example of Expanded I/O Serial Interface............................................. 394 Program Example of Free-run Timer.................. 222 Program Example of Input Capture.................... 232 Program Example of Output Compare................ 226 Program Example of UART .............................. 432 Program Execution........................................... 449 Sample Program for Interrupt Processing ............. 88 Sample Programs for Watchdog Timer............... 183 Sample Programs of Time-base Timer ............... 171 Setting Method Other than Program Example ...................................... 223, 227, 233, 262, 293, 322, 338, 368, 395, 433 Program Address Detection Register Functions of Program Address Detection Registers (PADR0 and PADR1) ......................... 448 Program Address Detection Registers (PADR0, PADR1)............................... 447 Program Count Bank Register Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector>................................................ 33 Program Counter Program Counter (PC) ........................................ 32 Program Example Program Example for Address Match Detection Function............................................. 455 Program Example of 16-bit Reload Timer .......... 292 Program Example of 8/10-bit A/D Converter ........................................... 367 Program Example of 8/16-bit PPG Timer ........... 321 Program Example of 8/16-bit Up/Down Counter/Timer .................................... 261 Program Example of DTP/External Interrupt ............................................. 337 Program Example of Expanded I/O Serial Interface............................................. 394 Program Example of Free-run Timer.................. 222 Program Example of Input Capture.................... 232 Program Example of Output Compare................ 226 Program Example of UART ..............................432 Setting Method Other than Program Example ......................................223, 227, 233, 262, 293, 322,338, 368, 395, 433 Program Patch Processing Flow of Program Patch Processing .....................454 Programmer Example of Connection with Flash Microcontroller Programmer (When Using the User Power Supply)...............................................495 System Configuration of Flash Microcontroller Programmer (Yokogawa Digital Computer Corporation)........................................492 Programming Connection Basic Configuration of Serial Programming Connection with MB90F983.................490 Protection Function Caution when Using the Conversion Data Protection Function .............................................364 Conversion Data Protection Function .................364 Operation Flow of Conversion Data Protection Function (when μDMAC is Used) .........365 PS Processor Status (PS) ..........................................29 Pulse Width Minimum Input Pulse Width..............................527 Operational Flow of Pulse Width Measurement.......................................529 Operations of the Pulse Width Measurement Function .............................................514 Pulse Width/Interval Calculation Method............528 Range for Counting the Pulse Width/Interval .....................................528 Relationship Between Reload Value and Pulse Width.........................................317 Start and Stop of Timer/Pulse Width Measurement.......................................518 PWC Block Diagram of Pin Related to PWC Timer.........................................500 Block Diagram of PWC Timer...........................499 Interrupt of PWC Timer ....................................510 Interrupt of PWC Timer, DMA Transfer, and EI2OS.................................................511 Interrupt Source Related to PWC Timer..............510 List of PWC Timer Registers .............................501 Notes on PWC Timer Usage ..............................530 Outline of PWC Timer Operations .....................512 Pin Related to PWC Timer ................................500 PWC Control/Status Register (PWCSR0, PWCSR1) ..........................502 PWC Data Buffer Register (PWCR0, PWCR1) ..............................507 PWC Timer Functions.......................................498 651 INDEX PWC Control/Status Register PWC Control/Status Register (PWCSR0, PWCSR1).......................... 502 PWC Data Buffer Register PWC Data Buffer Register (PWCR0, PWCR1).............................. 507 PWC Timer Block Diagram of Pin Related to PWC Timer ........................................ 500 Block Diagram of PWC Timer .......................... 499 Interrupt of PWC Timer .................................... 510 Interrupt of PWC Timer, DMA Transfer, and EI2OS ................................................ 511 Interrupt Source Related to PWC Timer ............. 510 List of PWC Timer Registers............................. 501 Notes on PWC Timer Usage.............................. 530 Outline of PWC Timer Operations ..................... 512 Pin Related to PWC Timer ................................ 500 PWC Timer Functions ...................................... 498 PWCR PWC Data Buffer Register (PWCR0, PWCR1).............................. 507 PWCSR PWC Control/Status Register (PWCSR0, PWCSR1).......................... 502 R Range Range for Counting the Pulse Width/Interval..................................... 528 RCR Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1) .................................... 250 Read Pin States after Mode Data is Read .................... 101 Setting the Flash Memory to the Read/Reset State................................................... 480 Register 16-bit Reload Register (TMRLR)....................... 280 16-bit Timer Register (TMR)............................. 279 16-bit Timer Register (TMR)/ 16-bit Reload Register (TMRLR).......... 279 Accessing Low-Power Consumption Mode Control Register .............................................. 127 Address Register (IADR) .................................. 550 Analog Input Enable Register (ADER) ............... 157 Bus Control Register (IBCR)............................. 541 Bus Status Register (IBSR) ............................... 539 Clear Timing of Free-run Timer (Match with Compare Register 0) ......... 219 Clock Control Register (ICCR).......................... 548 Common Register Bank Prefix (CMR) ................. 37 Communication Prescaler Control Register (CDCR).............................................. 411 652 Communication Prescaler Control Register 0/1 (SDCR0/SDCR1)................................ 383 Compare Clear Register (CPCLR) ..................... 201 Condition Code Register (CCR) .......................... 29 Configuration of 16-bit Input/Output Timer Register ............................................. 199 Configuration of Clock Selection Register (CKSCR) ........................................... 108 Configuration of Interrupt Control Register (ICR00 to ICR15) ................................. 46 Configuration of PLL Output Selection Register (PLLOS) ............................................ 111 Configuration of Watch Timer Control Register (WTC) ............................................... 188 Control Status Register (ICS01) ........................ 210 Control Status Register 1 (ADCS1) ................... 346 Control Status Register 2 (ADCS2) ................... 349 Counter Control Register (ch.0) Upper (CCRH0) ........................................... 241 Counter Control Register (ch.0/ch.1) Lower (CCRL0/CCRL1)................................ 245 Counter Control Register (ch.1) Upper (CCRH1) ........................................... 243 Counter Status Register 0/1 (CSR0/CSR1) ......... 247 Data Register (IDAR)....................................... 551 Data Registers (ADCR2 and ADCR1) ............... 352 Dedicated Registers............................................ 25 Direct Page Register (DPR) <Initial Value: 01H>.............................. 34 Divide Ratio Control Register (DIVR0, DIVR1) ................................ 509 DMA Control Status Register (DMACS) ............. 69 EI2OS Status Register (ISCS).............................. 79 Flash Memory Control Status Register (FMCS) ..................................... 463, 465 Function of Each Bit in Interrupt Control Register (ICR00 to ICR15) ................................. 47 Functions of Program Address Detection Registers (PADR0 and PADR1) ......................... 448 General-purpose Register.................................... 26 General-purpose Register (Register Bank)............ 35 I/O Register Address Pointer (IOA) ............... 68, 78 Input Capture Data Register (IPCP0, IPCP1) ...... 209 Interrupt Control Register (ICR00 to ICR15) Function............................................... 46 Interrupt Factors, Interrupt Vector, and Interrupt Control Register.................................... 43 Interrupt Level Mask Register (ILM) ................... 30 Interrupt Sources, Interrupt Vectors, and Interrupt Control Registers ................................ 568 Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register) .................. 328 Interrupt/DTP Source Register (EIRR: External Interrupt Request Register) .................. 329 List of 8/16-bit PPG Timer Registers ................. 304 List of 8/16-bit Up/Down Counter/Timer Registers ............................................ 240 INDEX List of Free-run Timer Registers........................ 200 List of I2C Interface Registers ........................... 537 List of Input Capture Registers .......................... 209 List of Interrupt Control Registers ....................... 45 List of μDMAC Registers ................................... 63 List of Output Compare Registers...................... 205 List of PWC Timer Registers ............................ 501 List of Registers and Initial Values of Address Match Detection Function .............................. 444 List of Registers for 8/10-bit A/D Converter ....... 345 List of Registers for DTP/External Interrupt ....... 328 List of Registers for Expanded I/O Serial Interface............................................. 377 List of Registers in Delay Interrupt Generation Module ................................................ 89 List of UART Registers .................................... 401 Low-Power Consumption Mode Control Register (LPMCR) ........................................... 125 Notes on Accessing the Low-Power Consumption Mode Control Register (LPMCR) to Enter the Standby Mode ............................... 143 Notes on Using the Bus Control Register (IBCR)............................................... 547 Output Compare Control Register (OCS01/OCS23) ................................. 207 Output Compare Register (OCCP0 to OCCP3) ............................ 206 Port Direction Registers (DDR2 to DDR4, DDR6 to DDRA)...... 155 Port Output Pin Registers (ODR7, ODR4).......... 156 Port Registers (PDR2 to PDR4, PDR6 to PDRA) ........ 154 PPG0 to PPG3 Output Control Registers (PPG01, PPG23) ................................. 310 PPG0/PPG2 Operation Mode Control Register (PPGC0/PPGC2)................................. 305 PPG1/PPG3 Operation Mode Control Register (PPGC1/PPGC3)................................. 307 Program Address Detection Control Status Register (PACSR)............................................ 445 Program Address Detection Registers (PADR0, PADR1)............................... 447 Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector>................................................ 33 PWC Control/Status Register (PWCSR0, PWCSR1) ......................... 502 PWC Data Buffer Register (PWCR0, PWCR1) ............................. 507 Register Bank Pointer (RP) ................................. 30 Register Settings in Master/Slave Communication .................................. 427 Register Settings in Two-Way Communication .................................. 425 Registers for I/O Port ....................................... 153 Registers of the ROM Mirror Function Selection Module .............................................. 458 Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3) ..............................312 Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1).....................................250 Request Level Setting Register (ELVR: External Level Register) ....................................329 ROMM (ROM Mirror Function Selection Register) .............................................459 Serial Control Register (SCR) ............................404 Serial Data Register 0/1 (SDR0/SDR1)...............382 Serial Input/Output Register (SIDR/SODR) ........407 Serial Mode Control Status Register 0/1 (SMCS0/SMCS1) ................................378 Serial Mode Register (SMR)..............................402 Serial Status Register (SSR) ..............................408 Time-base Timer Control Register (TBTC) .........164 Timer Control Status Register (TMCSR) ............275 Timer Counter Control Status Register (TCCS)...............................................202 Timer Counter Data Register (TCDT).................201 Up/Down Count Register (ch.0/ch.1) (UDCR0/UDCR1) ...............................249 Up/Down Timer Input Enable Register (UDER) ..............................................157 Watchdog Timer Control Register (WDTC) ........176 Write Timing to the Reload Register ..................319 Register Bank Common Register Bank Prefix (CMR) .................37 General-purpose Register (Register Bank).............35 Register Bank Pointer (RP)..................................30 Relationship Relationship Between Mode Pins and Mode Data (an Example Showing Recommended Relationship).......................................149 Relationship Between Reload Value and Pulse Width.........................................317 Reload 16-bit Reload Register (TMRLR) .......................280 Block Diagram of Pin Related to 16-bit Reload Timer.............................273 Block Diagram of the 16-bit Reload Timer..........272 Configuration of 16-bit Reload Timer Registers.............................................274 Interrupt of 16-bit Reload Timer ........................281 Interrupt of 16-bit Reload Timer, DMA Transfer, and EI2OS.................................................281 Operation Modes of the 16-bit Reload Timer .................................................270 Operations of Internal Clock Mode (Reload Mode) ....................................284 Pin Related to 16-bit Reload Timer ....................272 Program Example of 16-bit Reload Timer ...........292 Relationship Between Reload Value and Pulse Width.........................................317 Reload Function ...............................................256 Reload Operation Mode ....................................521 653 INDEX Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3) .............................. 312 Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1) .................................... 250 Selection of Reload and Compare Functions............................................ 256 Settings of the 16-bit Reload Timer.................... 282 Timer Value and Reload Value.......................... 521 Write Timing to the Reload Register .................. 319 Reload Mode Operations of Internal Clock Mode (Reload Mode) .................................... 284 Reload Operation Mode Reload Operation Mode .................................... 521 Reload Register Reload Registers (PRLL0 to PRLL3, PRLH0 to PRLH3) .............................. 312 Write Timing to the Reload Register .................. 319 Reload Timer Block Diagram of Pin Related to 16-bit Reload Timer ............................ 273 Block Diagram of the 16-bit Reload Timer ......... 272 Configuration of 16-bit Reload Timer Registers ............................................ 274 Interrupt of 16-bit Reload Timer ........................ 281 Interrupt of 16-bit Reload Timer, DMA Transfer, and EI2OS ................................................ 281 Operation Modes of the 16-bit Reload Timer ................................................. 270 Pin Related to 16-bit Reload Timer .................... 272 Program Example of 16-bit Reload Timer........... 292 Settings of the 16-bit Reload Timer.................... 282 Reload Value Relationship Between Reload Value and Pulse Width ........................................ 317 Timer Value and Reload Value.......................... 521 Reload/Compare Register Reload/Compare Register (ch.0/ch.1) (RCR0/RCR1) .................................... 250 Request External Interrupt Request Level........................ 336 Generation of Interrupt Requests........................ 528 Interrupt Generation Request ............................. 521 Interrupt/DTP Enable Register (ENIR: ENable Interrupt Request Register)................... 328 Notes on Using Delay Interrupt Generation Module (Delay Interrupt Request Latch).............. 90 Request Level Setting Register (ELVR: External Level Register).................................... 329 Request Level Setting Register Request Level Setting Register (ELVR: External Level Register).................................... 329 Reset Cautions about Reset-Factor Bits ....................... 100 654 Correspondence Between Reset-Factor Bits and Reset Factors ............................................... 100 Overview of Resetting........................................ 97 Pin States during a Reset .................................. 101 Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector>................................................ 33 Reset Factors ..................................................... 92 Reset Factors and Oscillation Stabilization Wait Time .................................................... 94 Reset State Waiting for Stable Oscillation ............ 95 Reset-Factor Bits ............................................... 99 Setting the Flash Memory to the Read/Reset State .................................................. 480 Restart Restart ............................................................ 519 Restrictions Restrictions on Interrupt Suppress Instruction and Prefix Instruction .................................. 38 Result Measurement Result Data ................................. 524 Resuming Resuming the Sector Erasure of Flash Memory .................................... 487 Return Return from Hardware Interrupt .......................... 52 Return from Software Interrupt ........................... 61 Stack Operation during Return from Interrupt Processing ............................................ 86 ROM Block Diagram of the ROM Mirror Function Selection Module .............................................. 458 Registers of the ROM Mirror Function Selection Module .............................................. 458 ROMM (ROM Mirror Function Selection Register) ............................................ 459 ROMM ROMM (ROM Mirror Function Selection Register) ............................................ 459 RP Register Bank Pointer (RP) ................................. 30 S Sample Program Sample Program for Interrupt Processing ............. 88 Sample Programs for Watchdog Timer .............. 183 Sample Programs of Time-base Timer ............... 171 SCR Serial Control Register (SCR) ........................... 404 SDR Serial Data Register 0/1 (SDR0/SDR1) .............. 382 Sector Chip/Sector Erase Operation ............................. 474 INDEX Erasing Arbitrary Data in the Flash Memory (Sector Erase) ..................................... 484 Procedure for Sector Erasure ............................. 484 Resuming the Sector Erasure of Flash Memory .................................... 487 Sector Configuration ........................................ 464 Sector Erase Operation ..................................... 478 Sector Erase Suspend ....................... 475, 476, 478 State Transitions of Sector Erase Timer Flag (DQ3) ................................................ 478 Suspending Sector Erasure for the Flash Memory .......................... 486 Write/Chip Sector Erase Operation .................... 477 Write/Chip Sector Erase Operations................... 476 Sector Configuration Sector Configuration ........................................ 464 Sector Erase Chip/Sector Erase Operation ............................. 474 Erasing Arbitrary Data in the Flash Memory (Sector Erase) ..................................... 484 Sector Erase Operation ..................................... 478 Sector Erase Suspend ....................... 475, 476, 478 State Transitions of Sector Erase Timer Flag (DQ3) ................................................ 478 Write/Chip Sector Erase Operation .................... 477 Write/Chip Sector Erase Operations................... 476 Sector Erase Timer Flag State Transitions of Sector Erase Timer Flag (DQ3) ................................................ 478 Selection Block Diagram of the ROM Mirror Function Selection Module .............................................. 458 Configuration of Clock Selection Register (CKSCR) ........................................... 108 Configuration of PL