The following document contains information on Cypress products. FUJITSU SEMICONDUCTOR CONTROLLER MANUAL CM44-10144-4E F2MC-16LX 16-BIT MICROCONTROLLER MB90860E Series HARDWARE MANUAL F2MC-16LX 16-BIT MICROCONTROLLER MB90860E Series HARDWARE MANUAL For the information for microcontroller supports, see the following web site. This web site includes the "Customer Design Review Supplement" which provides the latest cautions on system development and the minimal requirements to be checked to prevent problems before the system development. http://edevice.fujitsu.com/micom/en-support/ FUJITSU SEMICONDUCTOR LIMITED MB90860E Series Preface ■ Objectives and Intended Reader Thank you very much for your continued patronage of Fujitsu semiconductor products. The MB90860E series has been developed as one of the general-purpose products of the F2MC-16LX families, which is an original 16-bit single-chip microcontroller compatible with the Application Specific IC (ASIC). This manual describes the functions and operation of the MB90860E series for engineers who actually use this semiconductor to design products. Please read this manual first. Note: F2MC is the abbreviation of FUJITSU Flexible Microcontroller. ■ Trademark The company names and brand names herein are the trademarks or registered trademarks of their respective owners. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED i MB90860E Series ■ Overall Structure of This Manual This manual consists of the following 27 chapters and an appendix. CHAPTER 1 OVERVIEW This chapter describes the features and basic specifications of the MB90860E series. CHAPTER 2 CPU This chapter explains the setting and operation of the CPU. CHAPTER 3 INTERRUPTS This chapter describes the interrupts, the extended intelligent I/O service (EI2OS), and the exceptions. CHAPTER 4 μDMAC This chapter describes the functions and operations of the μDMAC. The μDMAC is the simplified DMA having functions equivalent to the extended intelligent I/O service (EI2OS). CHAPTER 5 DELAY INTERRUPT This chapter describes the functions and operations of the delayed interrupt. CHAPTER 6 CLOCK This chapter describes the clock. CHAPTER 7 RESET This chapter describes the reset. CHAPTER 8 LOW-POWER CONSUMPTION MODE This chapter explains the low-power consumption mode. CHAPTER 9 MEMORY ACCESS MODE This chapter explains the functions and operations of the memory access mode. CHAPTER 10 I/O PORTS This chapter explains the functions of I/O ports. CHAPTER 11 TIME-BASE TIMER This chapter explains the function and operation of the time-base timer. CHAPTER 12 WATCHDOG TIMER This chapter explains the function and operation of the watchdog timer. CHAPTER 13 16-BIT I/O TIMER This chapter describes the functions and operations of the 16-bit I/O timer. CHAPTER 14 16-BIT RELOAD TIMERS This chapter describes the functions and operations of 16-bit reload timers. CHAPTER 15 WATCH TIMER This chapter explains the functions and operations of the watch timer. CHAPTER 16 8/16-BIT PPG TIMER This chapter explains the functions and operations of the 8/16-bit PPG timer. CHAPTER 17 DTP/EXTERNAL INTERRUPT This chapter explains the functions and operations of the DTP/external interrupt. CHAPTER 18 8/10-BIT A/D CONVERTER This chapter explains the functions and operations of the 8/10-bit A/D converter. ii FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 19 CLOCK MONITOR FUNCTION This chapter explains the functions and operations of the clock monitor. CHAPTER 20 LIN-UART This chapter explains the functions and operations of LIN-UART. CHAPTER 21 I2C INTERFACE (400 kHz) This chapter explains the functions and operations of the high-speed I2C interface. CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION This chapter describes the functions and operations of the address match detection function. CHAPTER 23 ROM MIRRORING FUNCTION SELECT MODULE This chapter explains the functions and operations of the ROM mirroring function select module. CHAPTER 24 1M-BIT FLASH MEMORY This chapter explains the functions and operation of the 1M-bit flash memory. CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS This chapter shows examples of serial programming connection using the AF220/AF210/AF120/AF110 flash microcontroller programmers by Yokogawa Digital Computer Corporation. CHAPTER 26 ROM SECURITY FUNCTION This chapter explains the ROM security function. CHAPTER 27 CLOCK MODULATOR This chapter explains the overview, operations, and register configuration of the clock modulator. APPENDIX The appendixes provide I/O maps, F2MC-16LX instructions, and other information. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED iii MB90860E Series • • • • • • • 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 SEMICONDUCTOR device; FUJITSU SEMICONDUCTOR 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 SEMICONDUCTOR 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 SEMICONDUCTOR or any third party or does FUJITSU SEMICONDUCTOR warrant non-infringement of any third-party's intellectual property right or other right by using such information. FUJITSU SEMICONDUCTOR 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 SEMICONDUCTOR 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. Copyright2006-2010 FUJITSU SEMICONDUCTOR LIMITED All rights reserved. iv FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CONTENTS CHAPTER 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 CHAPTER 2 2.1 2.2 2.3 2.4 2.5 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.7 2.8 2.9 CPU ............................................................................................................ 29 Overview of the CPU ........................................................................................................................ Memory Space .................................................................................................................................. Linear Addressing ............................................................................................................................. Bank Addressing ............................................................................................................................... Multibyte Data in Memory Space ...................................................................................................... Registers ........................................................................................................................................... Accumulator (A) ........................................................................................................................... User Stack Pointer (USP) and System Stack Pointer (SSP) ....................................................... Processor Status (PS) ................................................................................................................. Program Counter (PC) ................................................................................................................. Bank Registers (PCB, DTB, USB, SSB, ADB) ............................................................................ Direct Page Register (DPR) ........................................................................................................ Register Bank ................................................................................................................................... Prefix Codes ..................................................................................................................................... Interrupt Disable Instructions ............................................................................................................ CHAPTER 3 3.1 3.2 3.3 3.4 3.5 3.5.1 3.5.2 3.5.3 3.6 3.7 3.7.1 3.8 3.9 OVERVIEW ................................................................................................... 1 Overview of the MB90860E Series ..................................................................................................... 2 Block Diagram of the MB90860E Series ............................................................................................ 8 Package Dimensions ........................................................................................................................ 10 Pin Assignment ................................................................................................................................. 12 Pin Function ...................................................................................................................................... 14 I/O Circuit Type ................................................................................................................................. 21 Precautions When Handling Devices ............................................................................................... 25 INTERRUPTS ............................................................................................. 55 Overview of Interrupts ....................................................................................................................... Interrupt Vector ................................................................................................................................. Interrupt Control Register (ICR00 to ICR15) ..................................................................................... Interrupt Flow .................................................................................................................................... Hardware Interrupts .......................................................................................................................... Hardware Interrupt Operation ...................................................................................................... Occurrence and Release of Hardware Interrupt .......................................................................... Multiple Interrupts ........................................................................................................................ Software Interrupts ........................................................................................................................... Extended Intelligent I/O Service (EI2OS) .......................................................................................... Extended Intelligent I/O Service Descriptor (ISD) ....................................................................... Operation Flow of Extended Intelligent I/O Service (EI2OS) and its Application Procedure ............. Exceptions ........................................................................................................................................ CM44-10144-4E 30 31 34 35 37 38 41 42 44 47 48 49 50 51 54 FUJITSU SEMICONDUCTOR LIMITED 56 60 62 66 68 69 70 72 73 75 77 80 83 v MB90860E Series CHAPTER 4 4.1 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.3 4.3.1 4.3.2 4.3.3 4.3.4 4.4 4.5 Overview of μDMAC ......................................................................................................................... 86 Registers of μDMAC ......................................................................................................................... 87 DMA Descriptor Channel Specification Register (DCSR) ............................................................ 89 DMA Status Register (DSR) ........................................................................................................ 91 DMA Stop Status Register (DSSR) ............................................................................................. 92 DMA Enable Register (DER) ....................................................................................................... 94 DMA Descriptor Window Register (DDWR) ...................................................................................... 95 Data Counter (DCT) .................................................................................................................... 96 I/O Register Address Pointer (IOA) ............................................................................................. 97 DMA Control Register (DMACS) ................................................................................................. 98 DMA Buffer Address Pointer (BAP) ........................................................................................... 100 Operations of μDMAC .................................................................................................................... 101 Notes on Using μDMAC .................................................................................................................. 105 CHAPTER 5 5.1 5.2 5.3 5.3.1 5.4 5.5 5.6 8.1 8.2 8.3 8.4 vi 116 119 121 122 126 128 132 133 RESET ...................................................................................................... 135 Overview of Reset .......................................................................................................................... Reset Source and Oscillation Stabilization Wait Times .................................................................. External Reset Pin .......................................................................................................................... Reset Operation .............................................................................................................................. Reset Source Bits ........................................................................................................................... Status of Pins by Reset .................................................................................................................. CHAPTER 8 108 109 110 111 112 113 114 CLOCK ..................................................................................................... 115 Clock ............................................................................................................................................... Block Diagram of the Clock Generation Block ................................................................................ Register in the Clock Generation Block ..................................................................................... Clock Selection Registers (CKSCR) ............................................................................................... PLL/Sub Clock Control Register (PSCCR) ..................................................................................... Clock Mode ..................................................................................................................................... Oscillation Stabilization Wait Time .................................................................................................. Connection of the Oscillator and External Clock ............................................................................ CHAPTER 7 7.1 7.2 7.3 7.4 7.5 7.6 DELAY INTERRUPT ................................................................................ 107 Overview of Delay Interrupt ............................................................................................................ Block Diagram of Delay Interrupt .................................................................................................... Configuration of Delay Interrupt ...................................................................................................... Delay Interrupt Request Generation/Release Register (DIRR) ................................................. Operating Explanation of Delay Interrupt ........................................................................................ Precautions when Using Delay Interrupt ........................................................................................ Program Example that uses Delay Interrupt ................................................................................... CHAPTER 6 6.1 6.2 6.2.1 6.3 6.4 6.5 6.6 6.7 μDMAC ....................................................................................................... 85 136 138 139 140 142 144 LOW-POWER CONSUMPTION MODE ................................................... 145 Overview of the Low-power Consumption Mode ............................................................................ Block Diagram of the Low-power Consumption Circuit .................................................................. Low-power Consumption Mode Control Register (LPMCR) ........................................................... CPU Intermittent Operation Mode .................................................................................................. FUJITSU SEMICONDUCTOR LIMITED 146 149 151 154 CM44-10144-4E MB90860E Series 8.5 8.5.1 8.5.2 8.5.3 8.5.4 8.6 8.7 8.8 Standby Mode ................................................................................................................................. Sleep Mode ............................................................................................................................... Watch Mode .............................................................................................................................. Time-base Timer Mode ............................................................................................................. Stop Mode ................................................................................................................................. State Transition of the Standby Mode ............................................................................................ Pin State in the Standby Mode and at the Time of Reset ............................................................... Notes on Using the Low-power Consumption Mode ...................................................................... CHAPTER 9 155 157 159 161 163 166 167 172 MEMORY ACCESS MODE ...................................................................... 175 9.1 Overview of the Memory Access Mode .......................................................................................... 9.1.1 Mode Pin ................................................................................................................................... 9.1.2 Mode Data ................................................................................................................................. 9.1.3 Memory Space by Bus Mode .................................................................................................... 9.2 External Memory Access (Bus Pin Control Circuit) ........................................................................ 9.2.1 Register for External Memory Access (External Bus Pin Control Circuit) .................................. 9.2.2 Auto Ready Selection Register (ARSR) .................................................................................... 9.2.3 External Address Output Control Register (HACR) ................................................................... 9.2.4 Bus Control Signal Selection Register (ECSR) ......................................................................... 9.3 External Memory Access Control Signal Operations ...................................................................... 9.3.1 Ready Function ......................................................................................................................... 9.3.2 Hold Function ............................................................................................................................ 176 177 178 179 181 182 183 185 186 189 191 193 CHAPTER 10 I/O PORTS ................................................................................................ 195 10.1 I/O Ports .......................................................................................................................................... 10.2 Register List for I/O Ports ............................................................................................................... 10.2.1 Port Data Register (PDR0 to PDRA) ......................................................................................... 10.2.2 Port Data Direction Register (DDR0 to DDRA) ......................................................................... 10.2.3 Pull-up Control Register (PUCR0 to PUCR3) ............................................................................ 10.2.4 Analog Data Input Enabling Register (ADER5 to ADER7) ........................................................ 10.2.5 Input Level Selection Register (ILSR0, ILSR1) ......................................................................... 196 197 198 200 203 204 205 CHAPTER 11 TIME-BASE TIMER .................................................................................. 207 11.1 Overview of the Time-base Timer ................................................................................................... 11.2 Block Diagram of the Time-base Timer .......................................................................................... 11.3 Configuration of the Time-base Timer ............................................................................................ 11.3.1 Time-base Timer Control Register (TBTC) ................................................................................ 11.4 Interrupt of the Time-base Timer .................................................................................................... 11.5 Operating Explanation of the Time-base Timer .............................................................................. 11.6 Notes on Using the Time-base Timer ............................................................................................. 11.7 Programming Example of the Time-base Timer ............................................................................. 208 210 212 213 215 216 220 221 CHAPTER 12 WATCHDOG TIMER ................................................................................ 223 12.1 Overview of the Watchdog Timer ................................................................................................... 12.2 Configuration of the Watchdog Timer ............................................................................................. 12.3 Register of the Watchdog Timer ..................................................................................................... 12.3.1 Watchdog Timer Control Register (WDTC) ............................................................................... CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 224 225 227 228 vii MB90860E Series 12.4 12.5 12.6 Operating Explanation of the Watchdog Timer ............................................................................... 230 Notes on Using the Watchdog Timer .............................................................................................. 234 Programming Example of the Watchdog Timer .............................................................................. 236 CHAPTER 13 16-BIT I/O TIMER ..................................................................................... 237 13.1 Overview of 16-bit I/O Timer ........................................................................................................... 13.2 Block Diagram of 16-bit I/O Timer .................................................................................................. 13.2.1 Block Diagram of 16-bit Free-running Timer ............................................................................. 13.2.2 Block Diagrams of Input Capture Units ..................................................................................... 13.2.3 Block Diagram of Output Compare Unit .................................................................................... 13.3 Configuration of 16-bit I/O Timer .................................................................................................... 13.3.1 Timer Control Status Register (Upper) (TCCSH0, TCCSH1) .................................................... 13.3.2 Timer Control Status Register (Lower) (TCCSL0, TCCSL1) ..................................................... 13.3.3 Timer Data Register (TCDT0, TCDT1) ...................................................................................... 13.3.4 Input Capture Control Status Registers (ICS) ........................................................................... 13.3.5 Input Capture Registers (IPCP0 to IPCP7) ............................................................................... 13.3.6 Input Capture Edge Registers (ICE01, ICE23, ICE45, ICE67) .................................................. 13.3.7 Output Compare Control Status Register (OCS) (Upper) ......................................................... 13.3.8 Output Compare Control Status Register (OCS) (Lower) ......................................................... 13.3.9 Output Compare Registers (OCCP0 to OCCP7) ....................................................................... 13.4 Interrupts from 16-bit I/O Timer ...................................................................................................... 13.5 Operations of 16-bit Free-running Timer ........................................................................................ 13.6 Input Capture Operations ............................................................................................................... 13.7 Output Compare Operations ........................................................................................................... 13.8 Notes on Using the 16-bit I/O Timer ............................................................................................... 13.9 Sample Programs for 16-bit I/O Timer ............................................................................................ 238 240 242 243 246 248 250 251 254 255 257 259 263 266 268 270 272 275 277 280 281 CHAPTER 14 16-BIT RELOAD TIMERS ........................................................................ 285 14.1 Overview of 16-bit Reload Timers .................................................................................................. 14.2 Block Diagram of 16-bit Reload Timer ............................................................................................ 14.3 Configuration of 16-bit Reload Timers ............................................................................................ 14.3.1 Upper Byte of Timer Control Status Register (TMCSR:H) ......................................................... 14.3.2 Lower Byte of Timer Control Status Register (TMCSR:L) ......................................................... 14.3.3 16-bit Timer Register (TMR) ...................................................................................................... 14.3.4 16-bit Reload Register (TMRLR) ............................................................................................... 14.4 Interrupts of 16-bit Reload Timers .................................................................................................. 14.5 Operations of 16-bit Reload Timers ................................................................................................ 14.5.1 Operations in Internal Clock Mode ............................................................................................ 14.5.2 Operations in Event Count Mode .............................................................................................. 14.6 Notes on Using 16-bit Reload Timers ............................................................................................. 14.7 Sample Programs for 16-bit Reload Timers ................................................................................... 286 289 292 297 299 302 303 304 305 307 312 315 316 CHAPTER 15 WATCH TIMER ........................................................................................ 319 15.1 Overview of Watch Timer ............................................................................................................... 15.2 Block Diagram of Watch Timer ....................................................................................................... 15.3 Configuration of Watch Timer ......................................................................................................... 15.3.1 Watch Timer Control Register (WTC) ........................................................................................ viii FUJITSU SEMICONDUCTOR LIMITED 320 322 324 325 CM44-10144-4E MB90860E Series 15.4 15.5 15.6 Interrupt of Watch Timer ................................................................................................................. 327 Operating Explanation of Watch Timer ........................................................................................... 328 Example Program of Watch Timer .................................................................................................. 330 CHAPTER 16 8/16-BIT PPG TIMER ............................................................................... 333 16.1 Overview of 8/16-bit PPG Timer ..................................................................................................... 16.2 Block Diagram of 8/16-bit PPG Timer ............................................................................................. 16.2.1 Block Diagram of 8/16-bit PPG Timer 0 .................................................................................... 16.2.2 Block Diagram of 8/16-bit PPG Timer 1 .................................................................................... 16.3 Configuration of 8/16-bit PPG Timer ............................................................................................... 16.3.1 PPG0 Operation Mode Control Register (PPGC0) .................................................................... 16.3.2 PPG1 Operation Mode Control Register (PPGC1) .................................................................... 16.3.3 PPG0/1 Count Clock Selection Register (PPG01) .................................................................... 16.3.4 PPG Reload Registers (PRLL0/PRLH0, PRLL1/PRLH1) .......................................................... 16.4 Interrupts of 8/16-bit PPG Timer ..................................................................................................... 16.5 Operating Explanation of 8/16-bit PPG Timer ................................................................................ 16.5.1 8-bit PPG Output 2-channel Independent Operation Mode ....................................................... 16.5.2 16-bit PPG Output Operation Mode .......................................................................................... 16.5.3 8+8-bit PPG Output Operation Mode ........................................................................................ 16.6 Notes on Using 8/16-bit PPG Timer ............................................................................................... 334 337 338 341 344 347 349 351 353 355 357 358 361 364 367 CHAPTER 17 DTP/EXTERNAL INTERRUPT ................................................................. 369 17.1 Overview of DTP/External Interrupt ................................................................................................ 17.2 Block Diagram of DTP/External Interrupt ........................................................................................ 17.3 Configuration of DTP/External Interrupt .......................................................................................... 17.3.1 DTP/External Interrupt Source Register (EIRR0/EIRR1) .......................................................... 17.3.2 DTP/External Interrupt Enable Register (ENIR0/ENIR1) ........................................................... 17.3.3 Detection Level Setting Register (ELVR0/ELVR1) .................................................................... 17.3.4 External Interrupt Source Select Register (EISSR) ................................................................... 17.4 Explanation of Operation of DTP/External Interrupt ....................................................................... 17.4.1 External Interrupt Function ........................................................................................................ 17.4.2 DTP Function ............................................................................................................................. 17.5 Notes on Using DTP/External Interrupt .......................................................................................... 17.6 Program Example of DTP/External Interrupt Function ................................................................... CHAPTER 18 8/10-BIT A/D CONVERTER ................................................................... 397 18.1 Overview of 8/10-bit A/D Converter ................................................................................................ 18.2 Block Diagram of 8/10-bit A/D Converter ........................................................................................ 18.3 Configuration of 8/10-bit A/D Converter .......................................................................................... 18.3.1 A/D Control Status Register 1 (ADCS1) .................................................................................... 18.3.2 A/D Control Status Register 0 (ADCS0) .................................................................................... 18.3.3 A/D Data Registers 0/1 (ADCR0/ADCR1) ................................................................................. 18.3.4 A/D Setting Register (ADSR0/ADSR1) ...................................................................................... 18.3.5 Analog Input Enable Register (ADER5 to ADER7) ................................................................... 18.4 Interrupt of 8/10-bit A/D Converter .................................................................................................. 18.5 Operating Explanation of 8/10-bit A/D Converter ........................................................................... 18.5.1 Single Conversion Mode ........................................................................................................... CM44-10144-4E 370 371 374 377 379 381 383 385 389 390 391 393 FUJITSU SEMICONDUCTOR LIMITED 398 400 403 406 410 412 413 417 419 420 421 ix MB90860E Series 18.5.2 Continuous Conversion Mode ................................................................................................... 18.5.3 Stop Conversion Mode .............................................................................................................. 18.5.4 Conversion Operation with μDMAC or EI2OS Function ............................................................ 18.5.5 A/D Conversion Data Protection Function ................................................................................. 18.6 Notes on Using 8/10-bit A/D Converter .......................................................................................... 423 425 427 428 431 CHAPTER 19 CLOCK MONITOR FUNCTION ................................................................ 433 19.1 Overview of Clock Monitor Function ............................................................................................... 19.2 Block Diagram of Clock Monitor Function ....................................................................................... 19.3 Configuration of Clock Monitor Function ......................................................................................... 19.3.1 Clock output enable register (CLKR) ......................................................................................... 19.4 Program Example of Clock Monitor Function ................................................................................. 434 435 436 437 438 CHAPTER 20 LIN-UART ................................................................................................. 439 20.1 Overview of LIN-UART ................................................................................................................... 20.2 Configuration of LIN-UART ............................................................................................................. 20.3 Pins of LIN-UART ........................................................................................................................... 20.4 Registers of LIN-UART ................................................................................................................... 20.4.1 Serial Control Register (SCR) ................................................................................................... 20.4.2 LIN-UART Serial Mode Register (SMR) .................................................................................... 20.4.3 Serial Status Register (SSR) ..................................................................................................... 20.4.4 Reception Data Register / Transmit Data Register (RDR/TDR) ................................................ 20.4.5 Extended Status Control Register (ESCR) ................................................................................ 20.4.6 Extended Communication Control Register (ECCR) ................................................................. 20.4.7 Baud Rate Generator Register 0, 1 (BGRn0/BGRn1) ............................................................... 20.5 Interrupts of LIN-UART ................................................................................................................... 20.5.1 Timing of Reception Interrupt Generation and Flag Set ............................................................ 20.5.2 Timing of Transmit Interrupt Generation and Flag Set .............................................................. 20.6 Baud Rate of LIN-UART ................................................................................................................. 20.6.1 Baud Rate Setting ..................................................................................................................... 20.6.2 Reload Counter ......................................................................................................................... 20.7 Operation of LIN-UART .................................................................................................................. 20.7.1 Operation of Asynchronous Mode (Operation Mode 0, 1) ......................................................... 20.7.2 Operation of Synchronous Mode (Operating Mode 2) ............................................................... 20.7.3 Operation of LIN Function (Operating Mode 3) ......................................................................... 20.7.4 Serial Pin Direct Access ............................................................................................................ 20.7.5 Bidirectional Communication Function (Normal Mode) ............................................................. 20.7.6 Master/Slave Mode Communication Function (Multiprocessor Mode) ...................................... 20.7.7 LIN Communication Function .................................................................................................... 20.7.8 Example Flowchart of LIN-UART LIN Communication (Operating Mode 3) .............................. 20.8 Notes on Using LIN-UART .............................................................................................................. 440 443 448 450 451 454 456 459 461 464 466 467 470 471 473 475 478 480 482 486 490 493 494 496 499 500 502 CHAPTER 21 I2C INTERFACE (400 kHz) ...................................................................... 509 21.1 Overview of I2C Interface (400 kHz) ............................................................................................... 21.2 Registers of I2C Interface ............................................................................................................... 21.2.1 Bus Status Register (IBSR0, IBSR1) ......................................................................................... 21.2.2 Bus Control Register (IBCR0, IBCR1) ....................................................................................... x FUJITSU SEMICONDUCTOR LIMITED 510 512 514 518 CM44-10144-4E MB90860E Series 21.2.3 10-Bit Slave Address Register (ITBAH0/ITBAH1, ITBAL0/ITBAL1) .......................................... 21.2.4 10-Bit Slave Address Mask Register (ITMK0, ITMK1) .............................................................. 21.2.5 7-Bit Slave Address Register (ISBA0, ISBA1) ........................................................................... 21.2.6 7-Bit Slave Address Mask Register (ISMK0, ISMK1) ................................................................ 21.2.7 Data Register (IDAR0, IDAR1) .................................................................................................. 21.2.8 Clock Control Register (ICCR0, ICCR1) .................................................................................... 21.3 Operations of I2C Interface ............................................................................................................. 21.4 Programming Flowcharts ................................................................................................................ 526 527 529 530 531 532 535 538 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION ......................................... 541 22.1 Overview of Address Match Detection Function ............................................................................. 22.2 Block Diagram of Address Match Detection Function .................................................................... 22.3 Configuration of Address Match Detection Function ...................................................................... 22.3.1 Address Detection Control Register (PACSR0/PACSR1) ......................................................... 22.3.2 Detection Address Setting Registers (PADR0 to PADR5) ........................................................ 22.4 Explanation of Operation of Address Match Detection Function .................................................... 22.4.1 Example of Using Address Match Detection Function .............................................................. 22.5 Program Example of Address Match Detection Function ............................................................... 542 543 544 545 549 552 553 558 CHAPTER 23 ROM MIRRORING FUNCTION SELECT MODULE ................................ 561 23.1 23.2 Overview of ROM Mirroring Function Select Module ...................................................................... 562 ROM Mirroring Function Select Register (ROMM) ......................................................................... 564 CHAPTER 24 1M-BIT FLASH MEMORY ........................................................................ 565 24.1 Outline of 1M-Bit Flash Memory ..................................................................................................... 24.2 Block Diagram of the Entire Flash Memory and Sector Configuration of the Flash Memory .......... 24.3 Write/Erase Modes ......................................................................................................................... 24.4 Flash Memory Control Status Register (FMCS) ............................................................................. 24.5 Starting the Flash Memory Automatic Algorithm ............................................................................ 24.6 Confirming the Automatic Algorithm Execution State ..................................................................... 24.6.1 Data Polling Flag (DQ7) ............................................................................................................ 24.6.2 Toggle Bit Flag (DQ6) ................................................................................................................ 24.6.3 Timing Limit Exceeded Flag (DQ5) ........................................................................................... 24.6.4 Sector Erase Timer Flag (DQ3) ................................................................................................. 24.7 Detailed Explanation of Writing to and Erasing Flash Memory ....................................................... 24.7.1 Setting Flash Memory to the Read/Reset State ........................................................................ 24.7.2 Writing Data to Flash Memory ................................................................................................... 24.7.3 Erasing All Data (Erasing Chips) of Flash Memory ................................................................... 24.7.4 Erasing Optional Data (Erasing Sectors) in Flash Memory ....................................................... 24.7.5 Suspending Sector Erase of Flash Memory .............................................................................. 24.7.6 Restarting Sector Erase of Flash Memory ................................................................................. 24.8 Notes on Using 1M-bit Flash Memory ............................................................................................ 24.9 Flash Security Feature .................................................................................................................... 24.10 Example of the 1M-Bit Flash Memory Program .............................................................................. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 566 567 569 571 574 575 577 578 579 580 581 582 583 585 586 588 589 590 592 593 xi MB90860E Series CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS.............................................................................. 597 25.1 25.2 25.3 25.4 25.5 Basic Configuration of Serial Programming Connection for Flash Memory Products .................... 598 Example of Serial Programming Connection (User Power Supply Used) ...................................... 601 Example of Serial Programming Connection (Power Supplied from Programmer) ........................ 603 Example of Minimum Connection to Flash Microcontroller Programmer (User Power Supply Used) ......................................................................................................................................................... 605 Example of Minimum Connection to Flash Microcontroller Programmer (Power Supplied from Programmer) ................................................................................................................................... 607 CHAPTER 26 ROM SECURITY FUNCTION ................................................................... 609 26.1 Overview of ROM Security Function ............................................................................................... 610 CHAPTER 27 CLOCK MODULATOR ............................................................................. 611 27.1 27.2 27.3 Overview of Clock Modulator .......................................................................................................... 612 Clock Modulator Control Registers (CMCR) ................................................................................... 613 Notes on Using Clock Modulator .................................................................................................... 615 APPENDIX ......................................................................................................................... 617 APPENDIX A I/O Maps .............................................................................................................................. APPENDIX B Memory Map ........................................................................................................................ APPENDIX C Instructions ........................................................................................................................... C.1 Instruction Types ............................................................................................................................ C.2 Addressing ..................................................................................................................................... C.3 Direct Addressing ........................................................................................................................... C.4 Indirect Addressing ........................................................................................................................ C.5 Execution Cycle Count ................................................................................................................... C.6 Effective address field .................................................................................................................... C.7 How to Read the Instruction List .................................................................................................... C.8 F2MC-16LX Instruction List ............................................................................................................ C.9 Instruction Map ............................................................................................................................... APPENDIX D Timing Diagrams in Flash Memory Mode ............................................................................ APPENDIX E List of Interrupt Vectors ........................................................................................................ 618 633 634 635 636 638 644 652 655 657 660 674 696 703 INDEX................................................................................................................................... 707 xii FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series Major changes in this edition Page 2 Changes (For details, refer to main body.) CHAPTER 1 OVERVIEW 1.1 Overview of the MB90340E Series 4 Corrected "Minimum instruction execution time" in "● Clock". (42 ns → 41.7 ns) Corrected the title of ● item. ("● Program patch function" → "● Address match detection (program patch) function)" Corrected the row "System clock" in Table 1.1-1. (42 ns → 41.7 ns) 5 Corrected the note (*) in "■ Product Lineup". (· MB2147-01 → MB2147-01-E) · Emulator hardware manual → Emulator operation manual) Corrected the row "LIN-UART" in Table 1.1-2. (the dedicated reload timer → the dedicated baud rate generator (reload timer)) 6 8 CHAPTER 1 OVERVIEW 1.2 Block Diagram of the MB90340E Series Corrected Figure 1.2-1. (· Prescaler → Baud rate generator · DMA → μDMAC) Corrected Figure 1.2-2. (· Prescaler → Baud rate generator · DMA → μDMAC) 9 10 CHAPTER 1 OVERVIEW 1.3 Package Dimensions Changed Figure 1.3-1. (FPT-100P-M05 → FPT-100P-M20) 13 CHAPTER 1 OVERVIEW 1.4 Pin Assignment Changed Figure 1.4-2. (FPT-100P-M05 → FPT-100P-M20) 18 CHAPTER 1 OVERVIEW 1.5 Pin Function Corrected the timer name in Table 1.5-1. (16-bit I/O timer → 16-bit free-run timer) Changed the note "*2" of Table 1.5-1. (FPT-100P-M05 → FPT-100P-M20) 20 28 CHAPTER 1 OVERVIEW 1.7 Precautions when Handling Devices Added the bellow items. "● Serial communication" "● Characteristic difference between flash device and mask ROM device" CHAPTER 2 CPU Deleted the bellow section. "Precautions for Use of "DIV A, Ri" and "DIVW A, RWi" Instructions" - Moved "Mmory map" to "APPENDIX B". 30 CHAPTER 2 CPU 2.1 Overview of the CPU ■ Overview of the CPU CM44-10144-4E Corrected the explanation. (16Mbytes of memory space (expandable) → 16Mbytes of memory space) Corrected "● Minimum instruction execution time". (42ns → 41.7ns) FUJITSU SEMICONDUCTOR LIMITED xiii MB90860E Series Page Changes (For details, refer to main body.) CHAPTER 2 CPU 2.3 Linear Addressing Corrected the summary. (• Deleted "Directly specifies a 24-bit address using operands". • Deleted "Uses the lower 24-bit of a 32-bit general-purpose register contents as the address.".) 34 Added the title "■ 32-bit Register Indirect Specification". 35 36 Added the title "■ Bank Addressing and Default Space". Added the title "■ Initial Value of Bank Register". CHAPTER 2 CPU 2.6.2 User Stack Pointer (USP) and System Stack Pointer (SSP) Added the description in "Note". CHAPTER 2 CPU 2.6.3 Processor Status (PS) Corrected the name. ("Interrupt Level Mask Register (ILM)" → "Interrupt Level Mask (ILM)") 48 CHAPTER 2 CPU 2.6.5 Bank Registers (PCB, DTB, USB, SSB, ADB) Corrected the explanation of "■ Bank Registers (PCB, DTB, USB, SSB, ADB)". (Bank registers other than PCB can be read. → Bank registers other than PCB can be read and written.) CHAPTER 2 CPU 2.6.6 Direct Page Register (DPR) Added the title of item. 49 50 CHAPTER 2 CPU 2.7 Register Bank Added the column "Address" in Table 2.7-2. 54 CHAPTER 2 CPU 2.9 Interrupt Disable Instructions Corrected summary. (not sampled → not accepted) CHAPTER 3 INTERRUPTS 3.3 Interrupt Control Register (ICR00 to ICR15) Corrected the attribute of "ICS1/S1" and "ICS0/S0". 62 77 CHAPTER 3 INTERRUPTS 3.7.1 Extended Intelligent I/O Service Descriptor (ISD) Corrected the register name in Figure 3.7-2. (I/O address pointer → I/O register address pointer) 79 CHAPTER 3 INTERRUPTS 3.7.1 Extended Intelligent I/O Service Descriptor (ISD) Corrected the register name in [bit1]. (I/O address pointer → I/O register address pointer) Corrected the register name inTable 3.8-1 and Table 3.8-2. (I/O address pointer → I/O register address pointer) 81 CHAPTER 3 INTERRUPTS 3.8 Operation Flow of Extended Intelligent I/O Service (EI2OS) and its Application Procedure 85 CHAPTER 3 INTERRUPTS Moved "3.9 μDMAC" to "CHAPTER 4 μDMAC". 87 CHAPTER 4 μDMAC 4.2 Registers of μDMAC Corrected the summary. 43 45, 46 xiv CHAPTER 2 CPU 2.4 Bank Addressing FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series Page Changes (For details, refer to main body.) CHAPTER 4 μDMAC 4.2.4 DMA Enable Register (DER) Moved the second "Note" to "4.5 Notes on Using μDMAC". 94 CHAPTER 4 μDMAC 4.3.3 DMA Control Register (DMACS) Moved "Note" to "4.5 Notes on Using μDMAC". 99 101 CHAPTER 4 μDMAC 4.4 Operations of μDMAC Corrected the register name in Figure 4.4-1. (IOA : I/O address pointer → IOA : I/O register address pointer) 105 CHAPTER 4 μDMAC 4.5 Notes on Using μDMAC Added "4.5 Notes on Using μDMAC". 196 CHAPTER 10 I/O PORTS 10.1 I/O Ports Deleted the explanation of "■ Overview of I/O Ports". CHAPTER 10 I/O PORTS 10.2.1 Port Data Register (PDR0 to PDRA) Added Table 10.2-1. Numbered an existing table as Table 10.2-2. 199 CHAPTER 13 16-BIT I/O TIMER 13.3.2 Timer Control Status Register (Lower) (TCCSL0, TCCSL1) ■ Timer Control Status Register (Lower) (TCCSL0, TCCSL1) Corrected the table of Figure 13.3-2. Added Note to bit7 and bit6 of Table 13.3-4. 256 13.3.4 Input Capture Control Status Registers (ICS) ■ Input Capture Control Status Register (ICS) Added Notes to bit7 and bit6 of Table 13.3-10. 267 13.3.8 Output Compare Control Status Register (OCS) (Lower) ■ Output Compare Control Status Register (OCS) (Lower) 277 13.7 Output Compare Operations Added Note to "■ Output Compare Operations". 296 14.3 Configuration of 16-bit Reload Timers Added the explanation to "■ Generation of an Interrupt Request by a 16-bit Reload Timer". 14.5.1 Operations in Internal Clock Mode Added the explanation to Note of "■ Operations in Internal Clock Mode". 251 252 253 309 310 Added Notes to bit7 of Table 13.3-3. Corrected the bit name and table of Table 13.3-3. (Count clock cycle select bits → Count clock setting bits) 314 326 Corrected the Note of "■ Operations in Internal Clock Mode". Corrected the Note of "■ Operations in Event Count Mode". CHAPTER 15 WATCH TIMER 15.3 Configuration of Watch Timer CM44-10144-4E Corrected the bit4 in Table 15.3-1 FUJITSU SEMICONDUCTOR LIMITED xv MB90860E Series Page Changes (For details, refer to main body.) Corrected the Notes. 328 CHAPTER 15 WATCH TIMER 15.5 Operating Explanation of Watch Timer Added Note in Figure 17.4-2. 388 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.4 Explanation of Operation of DTP/External Interrupt 401 18.2 Block Diagram of 8/10bit A/D Converter ■ Block Diagram of 8/10-bit A/D Converter ● Details of pins in block diagram Corrected the pin name of AVCC pin and AVSS pin. (VCC input pin → A/D converter power supply pin VSS input pin → A/D converter analog GND pin) Added the explanation to bit4 to bit1 and bit0 of Table 18.3-3. 411 18.3.2 A/D Control Status Register 0 (ADCS0) ■ A/D Control Status Register 0 (ADCS0) Added Notes to bit15 to bit13 of Table 18.3-5. 414 18.3.4 A/D Setting Register (ADSR0/ADSR1) ■ A/D Setting Register (ADSR0/ADSR1) CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10bit A/D Converter Corrected the formula of the sampling time in "■ Setting for Sampling Time (ST2 to ST0 Bits)". 20.1 Overview of LIN-UART ■ Functions of LIN-UART ● Functions of LIN-UART Corrected the parity error in Reception error detection of Table 20.1-1. (Parity error (Not supported in operating mode 1) → Parity error (Not supported in operation mode 1 and operation mode 3)) 20.4.1 Serial Control Register (SCR) ■ Serial Control Register (SCR) Corrected the explanation of bit9 in Table 20.4-1. (data frame reception → reception) Added the sentence to Notes of bit9. Added Note to bit7, bit6 in Table 20.4-2. 455 20.4.2 LIN-UART Serial Mode Register (SMR) ■ LIN-UART Serial Mode Register (SMR) Added the sentence to Notes of bit11 in Table 20.4-3. 457 20.4.3 Serial Status Register (SSR) ■ Serial Status Register (SSR) 416 440 452 453 xvi Added Note to bit12 to bit10 of Table 18.3-5. Corrected "■ Setting for Compare Time (CT2 to CT0 Bits)". (Conversion accuracy is not assured · · · → Refer to the data sheet for details.) Corrected the explanation of bit8 in Table 20.4-1. (data frame reception → reception) Added the sentence to Notes of bit8. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series Page 462 465 Changes (For details, refer to main body.) 20.4.5 Extended Status Control Register (ESCR) ■ Bit Configuration of Extended Status Control Register (ESCR) Added the sentence to Notes of bit9 in Table 20.4-4. CHAPTER 20 LIN-UART 20.4.6 Extended Communication Control Register (ECCR) Added Note to bit4 in Table 20.4-6. Added Note to bit8 in Table 20.4-4. Added the explanation of bit3 in Table 20.4-6. Corrected the explanation of bit0 in Table 20.4-6. 467 CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART ■ Interrupts of LIN-UART Added the below to Clearing interrupt request flag of RX in Table 20.5-1. Writing "1" to programmable reset bit (SMR:UPCL) 468 CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART Corrected "Note" in "● Reception interrupts". 474 CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART Corrected Figure 20.6-1. (Reset → REST) 476 CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART ■ External Clock" Corrected the explanation of "● External Clock". (synchronous mode 2 → operation mode 2,) CHAPTER 20 LIN-UART 20.6.2 Reload Counter Added the below to "For both transmit/reception reload counters" of "● Restart". Writing to the baud rate generator register (BGR1, BGR0) 20.7.2 Operation of Synchronous Mode (Operating Mode 2) ■ Operation of Synchronous Mode (Operating Mode 2) Added the explanation to "● Clock supply". CHAPTER 20 LIN-UART 20.7.4 Serial Pin Direct Access Added the sentence to Notes of "■ LIN-UART Pin Direct Access". 20.8 Notes on Using LINUART ■ Notes on Using LIN-UART Corrected the explanation of "● Bus idle function". 478 487 488 493 503 Added the below. "• ESCR:LBD bit" "• ESCR:SCES bit" Added the below. "• Serial communication" 504 Added "● Handling framing errors". 504 to 507 510 Added the below. "• Parity" "• Stop bit" "• Data signaling" "• Data transfer method" 21.1 Overview of I2C Interface (400 kHz) CM44-10144-4E Corrected the explanation of "■ Features of I2C Interface (400 kHz)". (General-purpose call → General call) FUJITSU SEMICONDUCTOR LIMITED xvii MB90860E Series Page 511 514 515 519 521 Changes (For details, refer to main body.) 21.1 Overview of I2C Interface (400 kHz) ■ Block Diagram of I2C Interface Corrected Figure 21.1-1. (General-purpose call → General call) 21.2.1 Bus Status Register (IBSR0, IBSR1) Corrected the explanation of "■ Functions of the Bus Status Register (IBSR0, IBSR1)". (General-purpose call → General call) 21.2.1 Bus Status Register (IBSR0, IBSR1) ■ Bit Function of the Bus Status Register (IBSR0, IBSR1) Corrected the explanation of bit1 in Figure 21.2-2. (General-purpose call → General call received → detected) CHAPTER 21 I2C INTERFACE (400 kHz) 21.2.2 Bus Control Register (IBCR0, IBCR1) ■ Bit Function of Bus Control Register (IBCR0, IBCR1) Corrected the explanation of bit10 in Figure 21.2-3. (General-purpose call → General call) Corrected the column "Function" of "bit11" in Table 21.2-2. (INIT=1 → INT=1) Corrected the column "Function" of "bit10" in Table 21.2-2. (INIT=1 → INT=1) Corrected the explanation of bit10 in Table 21.2-2. (General-purpose call → General call received → detected) Corrected the explanation of bit8 in Table 21.2-2. (General-purpose call → General call) 522 Corrected the explanation of bit6 to bit0 in Table 21.2-5. (General-purpose call → General call) 529 21.2.5 7-Bit Slave Address Register (ISBA0, ISBA1) ■ Functions of 7-Bit Slave Address Register (ISBA0, ISBA1) 537 21.3 Operations of I2C Interface Added Note to "■ Acknowledgement". 540 21.4 Programming Flowcharts ■ Example of Interrupt Handler Corrected Figure 21.4-3. (General-purpose call → General call) Deleted the explanation of "2M-bit/3M-bot flash memory" in Table 24.5-1. 574 24.5 Starting the Flash Memory Automatic Algorithm ■ Command Sequence Table 24.6 Confirming the Automatic Algorithm Execution State ■ Hardware Sequence Flags Deleted the explanation of "DQ2". 580 24.6.5 Toggle Bit-2 Flag (DQ2) Deleted "24.6.5 Toggle Bit-2 Flag (DQ2)". 24.7 Detailed Explan ation of Writing to and Erasing Flash Memory Changed the flowchart of Figure 24.7-2. 587 575 576 xviii Deleted the explanation of "DQ2" in Table 24.6-2. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series Page Changes (For details, refer to main body.) Added "● Mode transition during data write/erase operation". 590 24.8 Notes on Using 1M-bit Flash Memory ■ Notes on Using Flash Memory 638 C.3 Direct Addressing ● Register direct addressing Corrected Table C.3-1. ( S flag bit → stack flag (S)) ● I/O direct addressing (io) Corrected Figure C.3-5. (MOVW A, i : 0C0H → MOVW A, I:0C0H) 640 Added the note to Figure C.3-5. 641 ● Abbreviated direct addressing (dir) Added the note to Figure C.3-6. ● I/O direct bit addressing (io:bp) Corrected Figure C.3-8. (SETB i : 0C1H : 0 → SETB I:0C1H:0) 642 Added the note to Figure C.3-8. ● Abbreviated direct bit addressing (dir:bp) Added the note to Figure C.3-9. ● Vector Addressing (#vct) Corrected Table C.3-2. Corrected the explanation of XX. (Note: A PCB register value is set in XX. → * : XX is replaced by the value of the program counter bank register (PCB).) C.4 Indirect Addressing ● Program counter relative branch addressing (rel) Corrected Figure C.4-7. (BRA 10H → BRA 3C32H) ● Register list (rlst) Corrected Figure C.4-9. (POPW, RW0, RW4 → POPW RW0, RW4) 660 C.8 F2MC-16LX Instruction List ■ F2MC-16LX Instruction List Corrected Table C.8-1. Corrected the number of bytes (#) for "MOVX A, Ri" instruction. (2→1) 675 C.9 Instruction Map ■ Structure of Instruction Map Corrected column: instruction in Table C.9-1. (@RW2+d8, #8, rel → CBNE @RW2+d8, #8, rel) 643 648 649 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED xix MB90860E Series Page Changes (For details, refer to main body.) C.9 Instruction Map 676 Corrected the operand at row: +0, column: E0 in Table C.9-2. (#4 → #vct4) Corrected the mnemonic at row: +0, column: D0 in Table C.9-2. (MOV → MOVN) Corrected the mnemonic at row: +0, column: B0 in Table C.9-2. (MOV → MOVX) Corrected the mnemonic at row: +8, column: B0 in Table C.9-2. (MOV → MOVW) 678 Corrected the mnemonic at row: +0, column: E0 in Table C.9-4. (FILSI → FILSWI) 679 Corrected Table C.9-5. (- Moved "MUL A" and "MULW A" instruction from column:60 to column:70.) - Changed mnemonic and moved the Instruction from column:60, row:+A to column:70, row:+A. (DIVU → DIV) 680 Corrected the operand at row: +E and +F, column: F0 in Table C.9-6. (,#8, rel → #8, rel) 683 Corrected the operand at row: +8 to +E, column: 50 in Table C.9-9. (@@ → @) Corrected the operand at row: +0 to +7, column: 20 in Table C.9-9. (RWi → @RWi) 684 Corrected the operand at column: E0 and F0 in Table C.9-10. (,r → ,rel) 685 Corrected the operand at column: 70 in Table C.9-11. (NEG A, → NEG) 686 Corrected the operand at column: E0 and F0 in Table C.9-12. (,r → ,rel) 694 Corrected Table C.9-20 XCH Ri, ea Instruction (First Byte = 7EH). Column "A" → Column "A0", Changed row "+A" ( W2+d16,A → @RW2+d16 )) The vertical lines marked in the left side of the page show the changes. xx FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW This chapter describes the features and basic specifications of the MB90860E series. 1.1 Overview of the MB90860E Series 1.2 Block Diagram of the MB90860E Series 1.3 Package Dimensions 1.4 Pin Assignment 1.5 Pin Function 1.6 I/O Circuit Type 1.7 Precautions When Handling Devices CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 1 CHAPTER 1 OVERVIEW 1.1 Overview of the MB90860E Series 1.1 MB90860E Series Overview of the MB90860E Series MB90860E series is the 16-bit microcontrollers designed for in-vehicle applications. Consisting of the I2C, capture, compare timer, A/D converter, and others, it is equipped with functions that are suitable for personal computer peripheral devices such as displays and audio devices, and control of devices that support in-vehicle communications. ■ Feature of the MB90860E Series MB90860E series has the following features: ● Clock • Built-in PLL clock multiplier circuit • Machine clock (PLL clock) selectable from divide-by-two of oscillation clock or multiply-by-one to multiply-by-six of oscillation clocks (4 to 24 MHz when oscillation clock is 4 MHz) • Sub clock operation: Capable of maximum 50 kHz (when operating with 100 kHz and divide-by-two of oscillation clock) of internal operation clock frequency (only for the product without S-suffix in the part number) • Minimum instruction execution time: 41.7 ns (when operating with 4 MHz of oscillation clock and multiply-by-six of PLL clock) ● 16 MB CPU memory space Internal 24-bit addressing ● Instruction system optimized for controllers • Various data types (bit, byte, word, long word) • Various addressing modes (23 types) • Enhanced signed instructions of multiplication/division and RETI • High-accuracy operations enhanced by 32-bit accumulator ● Instruction system for high-level language (C language)/multitask • System stack pointer • Enhanced pointer indirect instructions • Barrel shift instructions ● Higher execution speed 4-byte instruction queue 2 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.1 Overview of the MB90860E Series MB90860E Series ● Powerful interrupt function • Powerful interrupt function with 8 levels and 34 factors • Supports maximum 16 channels of external interrupt ● CPU-independent automatic data transfer function • Extended intelligent I/O service (EI2OS): Maximum 16 channels • DMA function: Maximum 16 channels ● Low-power consumption (standby) mode • Sleep mode (that stops CPU operating clock) • Time-base timer mode (that operates only the oscillation clock, sub clock, time-base timer, and watch timer) • Watch mode (that operates only sub clock and watch timer) • Stop mode (that stops the oscillation clock and sub clock) • CPU intermittent operation mode ● Process CMOS technology ● I/O port • General-purpose I/O ports (CMOS output): - 80 ports (products without S-suffix in the part number; sub clock compatible device) - 82 ports (products with S-suffix in the part number; sub clock non-compatible device) ● Timers • Time-base timer, watch timer, watchdog timer: 1 channel • 8/16-bit PPG timer: 8-bit × 16 channels or 16-bit × 8 channels • 16-bit reload timer: 4 channels • 16-bit I/O timer - 16-bit free-run timer: 2 channels (FRT0: ICU0/1/2/3, OCU0/1/2/3, FRT1: ICU4/5/6/7, OCU4/5/6/7) - 16-bit input capture (ICU) : 8 channels - 16-bit output compare (OCU) : 8 channels ● LIN-UART: 4 channels • Full-duplex, double buffering • Available for clock asynchronous/clock synchronous serial transfer ● I2C interface: 2 channels Capable of maximum 400 kbps of communication CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 3 CHAPTER 1 OVERVIEW 1.1 Overview of the MB90860E Series MB90860E Series ● DTP/External interrupt: 16 channels Starts EI2OS/DMA and generates an external interrupt by an external input ● Delayed interrupt generation module Generates an interrupt request for task switching ● 8/10-bit A/D converter: 24 channels • The resolution can be switched between 8 and 10 bits • Starts by an external trigger input • Conversion time: 3 μs (including sampling time when 24 MHz machine clock) ● Address match detection (program patch) function Detects address match for 6 address pointers ● Variable port input voltage level • Automotive input level/CMOS schmitt input level (the initial value for the single chip mode is Automotive level) • TTL input level (supports pins for the external bus mode only; the initial values for these pins are TTL in the external bus mode) ● ROM security function Protects the contents of the ROM (only for the mask ROM product) ● External bus interface ● Clock monitor function ● Clock modulator function 4 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.1 Overview of the MB90860E Series MB90860E Series ■ Product Lineup Table 1.1-1 shows the product lineup for the MB90860E series. Table 1.1-1 Product Lineup List for MB90860E Series Features MB90V340E-101, MB90V340E-102 MB90F867E/ES MB90867E/ES CPU F2MC-16LX CPU System clock On-chip PLL clock multiplier method (×1, ×2, ×3, ×4, ×6, 1/2 when PLL stops) Minimum instruction execution time of 41.7 ns (at original oscillation of 4 MHz, multiply-by-six) ROM size External Flash memory: 128 KB MASK ROM: 128 KB RAM size 30 KB 6 KB 6 KB Technology 0.35 μm CMOS with on-chip voltage regulator for internal power supply 0.35 μm CMOS with on-chip voltage regulator for internal power supply + Flash memory with on-chip charge pump for voltage programming 0.35 μm CMOS with on-chip voltage regulator for internal power supply Package PGA-299 QFP-100, LQFP-100 Emulator-dedicated power supply* Included — *: It is a setting for the jumper switch (TOOL VCC) when the emulator (MB2147-01-E) is used. Refer to the Emulator Operation manual for details. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 5 CHAPTER 1 OVERVIEW 1.1 Overview of the MB90860E Series MB90860E Series ■ Features Table 1.1-2 Peripheral Functions of the MB90860E Series (1 / 2) Function MB90V340E-101, MB90V340E-102 MB90F867E/ES, MB90867E/ES 4 channels 5 channels LIN-UART A wide-range communication speed can be set with the dedicated baud rate generator (reload timer). LIN function can be used as a LIN master and LIN slave. I2C (400 kbps) 2 channels 24 channels A/D converter 10/8-bit resolution Conversion time: Minimum 3 μs including sampling time (per channel) 16-bit reload timer (4 channels) Operating clock frequency: fsys/21, fsys/23, fsys/25 (fsys=system clock frequency) Supports the external event count function 16-bit free run timer (2 channels) Outputs an interrupt signal at overflowing Supports timer clear when a match with output compare (ch.0 and ch.4) Operating clock frequency: fsys/21, fsys/22, fsys/23, fsys/24, fsys/25, fsys/26, fsys/27 (fsys=system clock frequency) Free run timer 0 (clock input FRCK0) corresponds to ICU 0/1/2/3, OCU 0/1/2/3 Free run timer 1 (clock input FRCK1) corresponds to ICU 4/5/6/7, OCU 4/5/6/7 16-bit output compare (8 channels) Outputs an interrupt signal when a match with 16-bit free run timer and output compare registers Up to 3 of compare registers can be used to generate an output signal 16-bit input capture (8 channels) Performs the retention of 16-bit free run timer value and the generation of interrupt by the pin input (rising edge, falling edge, or both edges) 8/16-bit PPG (8 channels) Supports 8-bit and 16-bit operating modes 8-bit reload counter × 16 Lower 8-bit reload register × 16 Upper 8-bit reload register × 16 A pair of 8-bit reload counters can be configured as one 16-bit reload counter or as 8-bit prescaler plus 8-bit reload counter Operating clock frequency: fsys, fsys/21, fsys/22, fsys/23, fsys/24 or 128 μs when fosc = 4 MHz (fsys=system clock frequency, fosc=oscillation clock frequency) CAN interface External interrupt (16 channels) D/A converter 6 — 3 channels Edge detection or level detection can be configured — 2 channels Only MB90V340E102 supports this function Sub clock (maximum 100 kHz) Only the products without S-suffix in their part number support this function I/O port General-purpose I/O ports (CMOS output): - 80 ports (products without S-suffix in the part number; sub clock compatible device) - 82 ports (products with S-suffix in the part number; sub clock non-compatible device) Input level setting: - Port0 to Port3: Selectable among CMOS/Automotive/TTL levels - Port4 to PortA: Selectable among CMOS/Automotive levels FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.1 Overview of the MB90860E Series MB90860E Series Table 1.1-2 Peripheral Functions of the MB90860E Series (2 / 2) Function MB90F867E/ES, MB90867E/ES MB90V340E-101, MB90V340E-102 Flash memory Supports automatic programming, Embedded Algorithm, Write/Erase/ Erase-Suspend/ Resume commands A flag indicating completion of the algorithm Number of erase cycles: 10,000 times Data retention time: 20 years Boot block configuration Erase can be performed on each block Block protection with external programming voltage Flash security function to protect the contents of the flash ROM security Protects the contents of the ROM (only for mask ROM product) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED - 7 CHAPTER 1 OVERVIEW 1.2 Block Diagram of the MB90860E Series 1.2 MB90860E Series Block Diagram of the MB90860E Series This section describes the block diagram of the MB90860E series. ■ Block Diagram of the MB90V340E-101/102 Figure 1.2-1 shows the block diagram of the MB90V340E-101/102. Figure 1.2-1 Block Diagram of the MB90V340E-101/102 X0,X1 X0A,X1A* RST Clock control circuit F2MC-16LX core 16-bit free run timer 0 RAM 30K Baud rate generator (5 ch) AVcc AVss AN23 to AN0 AVRH AVRL ADTG DA01 to DA00 10-bit D/A converter 2 ch PPGF to PPG0 8/16-bit PPG 16 ch SDA1 to SDA0 SCL1 to SCL0 I2C interface 2 ch μDMAC IN7 to IN0 Output compare 8 ch OUT7 to OUT0 CAN controller 3 ch LIN-UART 5 ch 10-bit A/D converter 24 ch Input capture 8 ch 16-bit free run timer 1 Internal data bus SOT4 to SOT0 SCK4 to SCK0 SIN4 to SIN0 FRCK0 16-bit reload timer 4 ch External bus FRCK1 RX2 to RX0 TX2 to TX0 TIN3 to TIN0 TOT3 to TOT0 AD15 to AD00 A23 to A16 ALE RD WRL WRH HRQ HAK RDY CLK DTP/ External interrupt INT15 to INT8 (INT15R to INT8R) INT7 to INT0 Clock monitor CKOT *: Only for MB90V340E-102 8 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.2 Block Diagram of the MB90860E Series MB90860E Series ■ Block Diagram of the MB90867E(S) and MB90F867E(S) Figure 1.2-2 shows the block diagram of the MB90867E(S) and MB90F867E(S). Figure 1.2-2 Block Diagram of the MB90867E(S) and MB90F867E(S) X0,X1 X0A,X1A* RST Clock control circuit F2MC-16LX core 16-bit free run timer 0 RAM 6K ROM/Flash 128K Baud rate generator (4 ch) AVcc AVss AN23 to AN0 AVRH AVRL ADTG PPGF to PPG0 SDA1 to SDA0 SCL1 to SCL0 Input capture 8 ch IN7 to IN0 Output compare 8 ch OUT7 to OUT0 16-bit free run timer 1 FRCK1 16-bit reload timer 4 ch TIN3 to TIN0 TOT3 to TOT0 External bus AD15 to AD00 A23 to A16 ALE RD WRL WRH HRQ HAK RDY CLK LIN-UART 4 ch 10-bit A/D converter 24 ch Internal data bus SOT3 to SOT0 SCK3 to SCK0 SIN3 to SIN0 FRCK0 8/16-bit PPG 16 ch I2 C interface 2 ch DTP/ External interrupt μDMAC Clock monitor INT15 to INT8 (INT15R to INT8R) INT7 to INT0 CKOT *: Products without S-suffix in their part number CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 9 CHAPTER 1 OVERVIEW 1.3 Package Dimensions 1.3 MB90860E Series Package Dimensions Two types of the package are provided for the MB90860E series. These package dimensions are only a reference. Please ask us when you need the official version. ■ Package Dimension (LQFP-100) Figure 1.3-1 shows the LQFP-100 type package dimension. Figure 1.3-1 LQFP-100 Type Package Dimension 100-pin plastic LQFP Lead pitch 0.50 mm Package width × package length 14.0 mm × 14.0 mm Lead shape Gullwing Sealing method Plastic mold Mounting height 1.70 mm Max Weight 0.65 g Code (Reference) P-LFQFP100-14×14-0.50 (FPT-100P-M20) 100-pin plastic LQFP (FPT-100P-M20) 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. 16.00±0.20(.630±.008)SQ * 14.00±0.10(.551±.004)SQ 75 51 76 50 0.08(.003) Details of "A" part +0.20 26 100 1 C 0.50±0.20 (.020±.008) 0.60±0.15 (.024±.006) 25 0.20±0.05 (.008±.002) 0.08(.003) M 2005 -2010 FUJITSU SEMICONDUCTOR LIMITED F100031S-c-3-5 0.10±0.10 (.004±.004) (Stand off) 0°~8° "A" 0.50(.020) +.008 1.50 –0.10 .059 –.004 (Mounting height) INDEX 0.145±0.055 (.006±.002) 0.25(.010) 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/package/en-search/ 10 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.3 Package Dimensions MB90860E Series ■ Package Dimension (QFP-100) Figure 1.3-2 shows the QFP-100 type package dimension. Figure 1.3-2 QFP-100 Type Package Dimension 100-pin plastic QFP Lead pitch 0.65 mm Package width × package length 14.00 × 20.00 mm Lead shape Gullwing Sealing method Plastic mold Mounting height 3.35 mm MAX Code (Reference) P-QFP100-14×20-0.65 (FPT-100P-M06) 100-pin plastic QFP (FPT-100P-M06) 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. 23.90±0.40(.941±.016) * 20.00±0.20(.787±.008) 80 51 81 50 0.10(.004) 17.90±0.40 (.705±.016) *14.00±0.20 (.551±.008) INDEX Details of "A" part 100 0.25(.010) +0.35 3.00 –0.20 +.014 .118 –.008 (Mounting height) 0~8° 31 1 30 0.65(.026) 0.32±0.05 (.013±.002) 0.13(.005) M 0.17±0.06 (.007±.002) 0.80±0.20 (.031±.008) 0.88±0.15 (.035±.006) "A" C 2002-2010 FUJITSU SEMICONDUCTOR LIMITED F100008S-c-5-7 0.25±0.20 (.010±.008) (Stand off) 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/package/en-search/ CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 11 CHAPTER 1 OVERVIEW 1.4 Pin Assignment 1.4 MB90860E Series Pin Assignment This section describes the pin assignments of the MB90860E series, depending on two types of packages. ■ Pin Assignment (QFP-100) Figure 1.4-1 shows the QFP-100 type pin assignment. MD2 MD0 MD1 RST P76/AN22/INT6 P77/AN23/INT7 P80/TIN0/ADTG/INT12R P81/TOT0/CKOT/INT13R P82/SIN0/TIN2/INT14R P83/SOT0/TOT2 P84/SCK0/INT15R P85/SIN1 P86/SOT1 P87/SCK1 Vcc Vss P90/PPG1(0) P91/PPG3(2) P92/PPG5(4) P93/PPG7(6) P94/OUT0 P95/OUT1 P96/OUT2 P97/OUT3 PA0/INT8R PA1 P00/AD00/INT8 P01/AD01/INT9 P02/AD02/INT10 P03/AD03/INT11 Figure 1.4-1 Pin Assignment (QFP-100) 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 P04/AD04/INT12 81 50 P75/AN21/INT5 P05/AD05/INT13 82 49 P74/AN20/INT4 P06/AD06/INT14 83 48 P73/AN19/INT3 P07/AD07/INT15 84 47 P72/AN18/INT2 P10/AD08/TIN1 85 46 P71/AN17/INT1 P11/AD09/TOT1 86 45 P70/AN16/INT0 P12/AD10/SIN3/INT11R 87 44 Vss P13/AD11/SOT3 88 43 P67/AN7/PPGE(F) P14/AD12/SCK3 89 42 P66/AN6/PPGC(D) Vcc 90 41 P65/AN5/PPGA(B) Vss 91 40 P64/AN4/PPG8(9) X1 92 39 P63/AN3/PPG6(7) X0 93 38 P62/AN2/PPG4(5) P15/AD13 94 37 P61/AN1/PPG2(3) P16/AD14 95 36 P60/AN0/PPG0(1) P17/AD15 96 35 AVss P20/A16/PPG9(8) 97 34 AVRL P56/AN14 P55/AN13 P54/AN12/TOT3 P53/AN11/TIN3 P52/AN10/SCK2 P51/AN9/SOT2 P50/AN8/SIN2 P47/SCL1 P46/SDA1 P45/SCL0/FRCK1 P44/SDA0/FRCK0 P43/IN7 P42/IN6/INT9R P34/HRQ/OUT4 C 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Vss 8 Vcc 7 P41/X1A* 6 P40/X0A* 5 P37/CLK/OUT7 4 P36/RDY/OUT6 3 P35/HAK/OUT5 2 P33/WRH P57/AN15 1 P32/WRL/WR/INT10R 31 P31/RD/IN5 100 P30/ALE/IN4 AVcc P23/A19/PPGF(E) P27/A23/IN3 AVRH 32 P26/A22/IN2 33 99 P25/A21/IN1 98 P24/A20/IN0 P21/A17/PPGB(A) P22/A18/PPGD(C) (FPT-100P-M06) * : X0A, X1A : MB90F867E, MB90867E P40, P41 : MB90F867ES, MB90867ES 12 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.4 Pin Assignment MB90860E Series ■ Pin Assignment (LQFP-100) Figure 1.4-2 shows the LQFP-100 type pin assignment. MD0 RST P76/AN22/INT6 P77/AN23/INT7 P80/TIN0/ADTG/INT12R P81/TOT0/CKOT/INT13R P82/SIN0/TIN2/INT14R P83/SOT0/TOT2 P84/SCK0/INT15R P85/SIN1 P86/SOT1 P87/SCK1 Vcc Vss P90/PPG1(0) P91/PPG3(2) P92/PPG5(4) P93/PPG7(6) P94/OUT0 P95/OUT1 P96/OUT2 P97/OUT3 PA0/INT8R PA1 P00/AD00/INT8 Figure 1.4-2 Pin Assignment (LQFP-100) 48 P75/AN21/INT5 P04/AD04/INT12 79 47 P74/AN20/INT4 P05/AD05/INT13 80 46 P73/AN19/INT3 P06/AD06/INT14 81 45 P72/AN18/INT2 P07/AD07/INT15 82 44 P71/AN17/INT1 P10/AD08/TIN1 83 43 P70/AN16/INT0 P11/AD09/TOT1 84 42 Vss P12/AD10/SIN3/INT11R 85 41 P67/AN7/PPGE(F) P13/AD11/SOT3 86 40 P66/AN6/PPGC(D) P14/AD12/SCK3 87 39 P65/AN5/PPGA(B) Vcc 88 38 P64/AN4/PPG8(9) Vss 89 37 P63/AN3/PPG6(7) X1 90 36 P62/AN2/PPG4(5) X0 91 35 P61/AN1/PPG2(3) P15/AD13 92 34 P60/AN0/PPG0(1) P16/AD14 93 33 AVss P17/AD15 94 32 AVRL P20/A16/PPG9(8) 95 31 AVRH P21/A17/PPGB(A) 96 30 AVcc P22/A18/PPGD(C) 97 29 P57/AN15 P23/A19/PPGF(E) 98 28 P56/AN14 P24/A20/IN0 99 27 P55/AN13 P25/A21/IN1 100 P54/AN12/TOT3 P53/AN11/TIN3 P52/AN10/SCK2 P51/AN9/SOT2 P50/AN8/SIN2 P47/SCL1 P46/SDA1 P45/SCL0/FRCK1 P44/SDA0/FRCK0 P43/IN7 P42/IN6/INT9R C 26 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Vss 7 8 Vcc 6 P41/X1A * 5 P40/X0A * 4 P37/CLK/OUT7 3 P36/RDY/OUT6 2 P35/HAK/OUT5 1 P33/WRHX P34/HRQ/OUT4 78 P32/WRL/WR/INT10R MD2 P03/AD03/INT11 P31/RD/IN5 MD1 49 P30/ALE/IN4 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 77 P27/A23/IN3 76 P26/A22/IN2 P01/AD01/INT9 P02/AD02/INT10 (FPT-100P-M20) * : X0A, X1A : MB90F867E, MB90867E P40, P41 : MB90F867ES, MB90867ES CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 13 CHAPTER 1 OVERVIEW 1.5 Pin Function 1.5 MB90860E Series Pin Function This section describes the pin function of the MB90860E series. ■ Pin Function Table 1.5-1 Pin Function of the MB90860E Series (1 / 7) Pin No. Pin name LQFP100 *2 QFP100 *1 90 92 X1 91 93 X0 52 54 RST I/O circuit type*3 A E 77 to 84 AD00 to AD07 G INT8 to INT15 85 G I/O pin for the external address/data bus (AD08). This function is valid when the external bus is enabled. TIN1 Event input pin for the reload timer 1 86 87 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. G AD09 I/O pin for the external address/data bus (AD09). This function is valid when the external bus is enabled. TOT1 Output pin for the reload timer 1 AD10 SIN3 INT11R 14 I/O pin for the external address/data bus lower 8-bit. This function is valid when the external bus is enabled. AD08 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. P12 85 Reset input General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. P11 84 Oscillation input pin External interrupt request input pin for INT8 to INT15 P10 83 Oscillation output pin General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. P00 to P07 75 to 82 Function N I/O pin for the external address/data bus (AD10). This function is valid when the external bus is enabled. Serial data input pin for UART3 External interrupt request input pin for INT11 (sub) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.5 Pin Function MB90860E Series Table 1.5-1 Pin Function of the MB90860E Series (2 / 7) Pin No. Pin name LQFP100 *2 QFP100 *1 I/O circuit type*3 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. P13 86 88 G AD11 I/O pin for the external address/data bus (AD11). This function is valid when the external bus is enabled. SOT3 Serial data output pin for UART3 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. P14 87 89 G AD12 I/O pin for the external address/data bus (AD12). This function is valid when the external bus is enabled. SCK3 Clock I/O pin for UART3 P15 92 93 94 95 to 98 CM44-10144-4E Function 94 N General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. AD13 I/O pin for the external address/data bus (AD13). This function is valid when the external bus is enabled. P16 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. 95 G AD14 I/O pin for the external address/data bus (AD14). This function is valid when the external bus is enabled. P17 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function is valid in the single chip mode. 96 G AD15 I/O pin for the external address/data bus (AD15). This function is valid when the external bus is enabled. P20 to P23 General-purpose I/O port. You can set a pull-up resistor On/Off by setting the register. In the external bus mode, it is enabled as a general-purpose I/O port when the corresponding bit to the external address output control register (HACR) is set to "1". 97 to 100 G A16 to A19 Output pins for the external address/data bus A16 to A19. It is enabled as the upper address output pins (A16 to A19) when the corresponding bit to the external address output control register (HACR) is set to "0". PPG9, PPGB, PPGD, PPGF Output pins for PPG FUJITSU SEMICONDUCTOR LIMITED 15 CHAPTER 1 OVERVIEW 1.5 Pin Function MB90860E Series Table 1.5-1 Pin Function of the MB90860E Series (3 / 7) Pin No. Pin name LQFP100 *2 QFP100 *1 I/O circuit type*3 General-purpose I/O port. You can set a pull-up resistor On/Off by setting the register. In the external bus mode, it is enabled as a general-purpose I/O port when the corresponding bit to the external address output control register (HACR) is set to "1". P24 to P27 99 to 2 3 4 5 1 to 4 G A20 to A23 Output pins for the external address/data bus A20 to A23. It is enabled as the upper address output pins (A20 to A23) when the corresponding bit to the external address output control register (HACR) is set to "0". IN0 to IN3 Data sample input pins for the input capture ICU0 to ICU3 P30 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid in the single chip mode. 5 G ALE Address latch enable output pin. This function becomes valid when the external bus mode is enabled. IN4 Data sample input pin for the input capture ICU4 P31 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid in the single chip mode. 6 G RD Read strobe output pin for the data bus. This function becomes valid when the external bus is enabled. IN5 Data sample input pin for the input capture ICU5 P32 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid when the single chip mode or the WR/WRL pin output is disabled. 7 G WRL/ WR INT10R 16 Function Write strobe output pin for the data bus. This function becomes valid when the external bus or the WR/WRL pin output is enabled. WRL is the write strobe output pin for the data bus lower 8-bit on 16-bit access. WR is the write strobe output pin for the data bus 8-bit on 8-bit access. External interrupt request input pin for INT10 (sub) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.5 Pin Function MB90860E Series Table 1.5-1 Pin Function of the MB90860E Series (4 / 7) Pin No. LQFP100 *2 QFP100 *1 Pin name I/O circuit type*3 P33 6 7 8 G WRH P34 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid when the single chip mode or the hold function is disabled. 9 G HRQ Hold request input pin. This function is valid when the external bus and the hold function are enabled. OUT4 Wave form output pin for the output compare OCU4 10 G Hold acknowledgment output pin. This function is valid when the external bus and the hold function are enabled. OUT5 Wave form output pin for the output compare OCU5 11 G 11, 12 CM44-10144-4E General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid when the single chip mode or the external ready function is disabled. RDY Ready input pin. This function becomes valid when the external bus and external ready function are enabled. OUT6 Wave form output pin for the output compare OCU6 P37 10 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid when the single chip mode or the hold function is disabled. HAK P36 9 General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid when the single chip mode, external bus 8-bit mode or the WRH pin output is disabled. Write strobe output pin for the data bus upper 8-bit. This function becomes valid when the external bus is enabled and in the external bus 16-bit mode, and WRH pin output is enabled. P35 8 Function 12 G General-purpose I/O port. You can set a pull-up resistor On/Off by setting a register. This function becomes valid when the single chip mode or the CLK output is disabled. CLK CLK output pin. This function becomes valid when the external bus and CLK output are enabled. OUT7 Wave form output pin for the output compare OCU7 P40, P41 F General-purpose I/O port (Products with S-suffix in their part number) X0A, X1A B Oscillation input pin for the sub clock (Products without S-suffix in their part number) 13, 14 FUJITSU SEMICONDUCTOR LIMITED 17 CHAPTER 1 OVERVIEW 1.5 Pin Function MB90860E Series Table 1.5-1 Pin Function of the MB90860E Series (5 / 7) Pin No. LQFP100 *2 QFP100 *1 Pin name I/O circuit type*3 P42 16 18 IN6 General-purpose I/O port F INT9R 17 19 P43 IN7 20 SDA0 F H SCL0 H 21 23 SDA1 General-purpose I/O port H P47 SCL1 23 24 25 AN8 O 25 27 Serial data input pin for UART2 P51 General-purpose I/O port AN9 I AN10 General-purpose I/O port I Clock I/O pin for UART2 P53 General-purpose I/O port AN11 I AN12 29 28, 29 30, 31 P55 AN13 General-purpose I/O port I 18 Analog input pin for A/D converter Output pin for the reload timer 3 I P56, P57 AN14, AN15 Analog input pin for A/D converter Event input pin for the reload timer 3 TOT3 27 Analog input pin for A/D converter SCK2 P54 28 Analog input pin for A/D converter Serial data output pin for UART2 TIN3 26 Analog input pin for A/D converter SIN2 P52 26 Serial clock I/O pin for I2C1 General-purpose I/O port SOT2 24 Serial data I/O pin for I2C1 General-purpose I/O port H P50 22 Serial clock I/O pin for I2C0 Input for 16-bit free-run timer 1 P46 22 Serial data I/O pin for I2C0 General-purpose I/O port FRCK1 20 Data sample input pin for the input capture ICU7 Input for 16-bit free-run timer 0 P45 21 General-purpose I/O port General-purpose I/O port FRCK0 19 Data sample input pin for the input capture ICU6 External interrupt request input pin for INT10 (sub) P44 18 Function General-purpose I/O port Analog input pin for A/D converter General-purpose I/O port J Analog input pin for A/D converter FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.5 Pin Function MB90860E Series Table 1.5-1 Pin Function of the MB90860E Series (6 / 7) Pin No. LQFP100 *2 QFP100 *1 Pin name I/O circuit type*3 P60 to P67 General-purpose I/O port AN0 to AN7 34 to 41 36 to 43 PPG0, PPG2, PPG4, PPG6, PPG8, PPGA, PPGC, PPGE Analog input pin for A/D converter I Output pins for PPG P70 to P77 43 to 48, 53, 54 45 to 50, 55, 56 AN16 to AN23 General-purpose I/O port I INT0 to INT7 57 TIN0 ADTG General-purpose I/O port F INT12R 58 TOT0 CKOT F SIN0 TIN2 M SOT0 F SCK0 General-purpose I/O port F INT15R 60 62 61 63 CM44-10144-4E P85 SIN1 P86 SOT1 Serial data output pin for UART0 Output pin for the reload timer 2 P84 61 Event input pin for the reload timer 2 General-purpose I/O port TOT2 59 Serial data input for UART0 External interrupt request input pin for INT14 (sub) P83 60 Output pin for the clock monitor General-purpose I/O port INT14R 58 Output pin for the reload timer 0 External interrupt request input pin for INT13 (sub) P82 59 Trigger input pin for A/D converter. General-purpose I/O port INT13R 57 Event input pin for the reload timer 0 External interrupt request input pin for INT12 (sub) P81 56 Analog input pin for A/D converter External interrupt request input pin for INT0 to INT7 P80 55 Function Clock I/O pin for UART0 External interrupt request input pin for INT15 (sub) M F General-purpose I/O port Serial data input pin for UART1 General-purpose I/O port Serial data output pin for UART1 FUJITSU SEMICONDUCTOR LIMITED 19 CHAPTER 1 OVERVIEW 1.5 Pin Function MB90860E Series Table 1.5-1 Pin Function of the MB90860E Series (7 / 7) Pin No. LQFP100 *2 62 QFP100 *1 64 Pin name P87 SCK1 I/O circuit type*3 F P90 to P93 65 to 68 67 to 70 PPG1, PPG3, PPG5, PPG7 Function General-purpose I/O port Clock I/O pin for UART1 General-purpose I/O port F P94 to P97 Output pins for PPG General-purpose I/O port 71 to 74 73 75 74 76 PA1 F General-purpose I/O port 30 32 AVCC K VCC power supply input pin for the analog circuit 31 33 AVRH L Reference voltage input for A/D converter. Make sure that AVCC is applied greater voltage than AVRH when turning on and off the power supply. 32 34 AVRL K Lower reference voltage input for A/D converter 33 35 AVSS K VSS power supply input pin for the analog circuit 50, 51 52, 53 MD1, MD0 C Input pins for operating mode selection 49 51 MD2 D Input pin for operating mode selection 13, 63, 88 15, 65, 90 VCC — Power supply input pins (3.5V to 5.5 V) 14, 42, 64, 89 16, 44, 66, 91 VSS — Power supply input pin (0 V) 15 17 C K Power supply stabilization capacitor pin. Connects a ceramic capacitor of over 0.1 μF. OUT0 to OUT3 PA0 INT8R F Wave form output pins for the output compare OCU0 to OCU3. This function becomes valid when the wave form output is enabled. 69 to 72 F General-purpose I/O port External interrupt request input pin for INT8 (sub) *1:FPT-100P-M06 *2:FPT-100P-M20 *3: Refer to Section "1.6 I/O Circuit Type" for the I/O circuit type. 20 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.6 I/O Circuit Type MB90860E Series 1.6 I/O Circuit Type This section describes the I/O circuit types for each pin of the MB90860E series. ■ I/O Circuit Type Table 1.6-1 I/O Circuit Type (1 / 4) Classification Circuit X1 A Remarks Oscillation circuit • High speed oscillation feedback resistor = Approximately 1 MΩ Xout X0 Standby control signal X1A B Oscillation circuit • Low speed oscillation feedback resistor = Approximately 10 MΩ Xout X0A Standby control signal R C R D CMOS hysteresis input CMOS hysteresis input Pull-down resistor Mask ROM and evaluation device • CMOS hysteresis input Flash memory products • CMOS input Mask ROM and evaluation device • CMOS hysteresis input • Pull-down resistor value = Approximately 50 kΩ Flash memory products • CMOS input • No pull-down • CMOS hysteresis input • Pull-up resistor value = Approximately 50 kΩ Pull-up resistor E R CM44-10144-4E CMOS hysteresis input FUJITSU SEMICONDUCTOR LIMITED 21 CHAPTER 1 OVERVIEW 1.6 I/O Circuit Type MB90860E Series Table 1.6-1 I/O Circuit Type (2 / 4) Classification F Circuit P-ch Pout N-ch Nout R CMOS hysteresis input Remarks • CMOS level output (IOL = 4 mA, IOH = - 4 mA) • CMOS hysteresis input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) Automotive input Input cut-off standby control Pull-up control P-ch Pout N-ch Nout R G CMOS hysteresis input Automotive input • CMOS level output (IOL = 4 mA, IOH = - 4 mA) • CMOS hysteresis input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) • TTL (with the input cut-off function on standby) • Pull-up resistor configurable resistor: Approximately 50 kΩ TTL input Input cut-off standby control H P-ch Pout N-ch Nout R CMOS hysteresis input • CMOS level output (IOL = 3 mA, IOH = - 3 mA) • CMOS hysteresis input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) Automotive input Input cut-off standby control 22 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.6 I/O Circuit Type MB90860E Series Table 1.6-1 I/O Circuit Type (3 / 4) Classification Circuit P-ch Pout N-ch Nout Remarks R CMOS hysteresis input I • CMOS level output (IOL = 4 mA, IOH = - 4 mA) • CMOS hysteresis input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) • A/D analog input Automotive input Input cut-off standby control Analog input P-ch Pout N-ch Nout R CMOS hysteresis input J Automotive input • CMOS level output (IOL = 4 mA, IOH = - 4 mA) • CMOS hysteresis input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) • A/D analog input • D/A analog output Input cut-off standby control Analog input Analog output • Power supply input protection circuit P-ch K N-ch P-ch L N-ch CM44-10144-4E ANE P-ch AVR N-ch ANE • With A/D converter reference voltage input pin power supply protection circuit. AVRH pin in the flash memory products doesn't have the protection circuit for VCC. FUJITSU SEMICONDUCTOR LIMITED 23 CHAPTER 1 OVERVIEW 1.6 I/O Circuit Type MB90860E Series Table 1.6-1 I/O Circuit Type (4 / 4) Classification M Circuit P-ch Pout N-ch Nout R CMOS input Remarks • CMOS level output (IOL = 4 mA, IOH = - 4 mA) • CMOS input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) Automotive input Input cut-off standby control Pull-up control P-ch Pout N-ch Nout R N CMOS input Automotive input • CMOS level output (IOL = 4 mA, IOH = - 4 mA) • CMOS input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) • TTL input (with the input cut-off function on standby) • Pull-up resistor configurable resistor: Approximately 50 kΩ TTL input Input cut-off standby control P-ch Pout N-ch Nout R O CMOS input • CMOS level output (IOL = 4 mA, IOH = - 4 mA) • CMOS input (with the input cut-off function on standby) • Automotive input (with the input cut-off function on standby) • A/D analog input Automotive input Input cut-off standby control Analog input 24 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.7 Precautions When Handling Devices MB90860E Series 1.7 Precautions When Handling Devices This section describes the precautions when handling the MB90860E series. ■ Precautions When Handling Devices ● Preventing latch-up For a CMOS IC, a latch-up phenomenon may occur when: • A voltage higher than VCC or a voltage lower than VSS is applied to the I/O pin • A voltage that exceeds the rated voltage is applied between VCC and VSS • Power supply for AVCC is supplied prior to the VCC voltage Latch-up may cause a sudden increase in supply current, resulting in thermal damage to the device. Therefore, the maximum voltage ratings must not be exceeded. By the same token, make sure that the analog supply voltage (AVCC and AVRH) should not exceed the digital supply voltage. ● Handling unused pins If unused input pins remain open, a malfunction or latch-up may cause permanent damage, so take countermeasures such as pull-up or pull-down using a 2 kΩ or larger resistor. Leave unused I/O pins open in the output state or, if left in the input state, treat them in the same manner as for input pins in use. ● Precautions when using external clock When using an external clock, drive only the X0 (X0A) pin and open the X1 (X1A) pin. Figure 1.7-1 Example of Using External Clock MB90860E series X0 (X0A) Open X1 (X1A) ● Precautions when not using sub clock If an oscillator is not connected to the X0A and X1A pins, make a pull-down pin process to the X0A pin and leave the X1A pin open. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 25 CHAPTER 1 OVERVIEW 1.7 Precautions When Handling Devices MB90860E Series ● Precautions while operating 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 pins (VCC/VSS) When the device is provided with multiple VCC pins and VSS pins, the pins designed to have equal potential are internally connected to them to prevent malfunctions such as latch-up. However, be sure to connect all of the potentially equal pins to the power supply and ground outside the device to reduce unwanted radiation, prevent the strobe signal from malfunctioning due to a rise of ground level, and follow the standards of total output current (See Figure 1.7-2). The power pins should be connected to VCC and VSS of this device at the lowest possible impedance from the current supply source. We also recommend to connect an approximately 0.1 μF capacitor between VCC and VSS as a bypass capacitor near the pins of this device. Figure 1.7-2 Power Supply Pins (VCC/VSS) Vcc Vss Vcc Vss Vss Vcc MB90860E series Vcc Vss Vss Vcc ● Pull-up/pull-down resistors The MB90860E series does not support internal pull-up/pull-down resistors (However, only port0 to port3 have built-in pull-up resistors). Make pull-up/pull-down pin process when needed. ● Crystal oscillation circuit Noise near the X0 and X1 pins may cause this device to malfunction. Place the X0 and X1 pins, the crystal (or ceramic) oscillator, and the bypass capacitor leading to the ground as close to one another as possible and prevent the wiring patterns for the crystal oscillator from crossing other wiring as much as possible. For stable operation, the printed circuit board is strongly recommended to have the artwork with the X0 and X1 pins enclosed by a ground line. Please ask the crystal maker to evaluate the oscillational characteristics of the crystal and this device. 26 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 1 OVERVIEW 1.7 Precautions When Handling Devices MB90860E Series ● Procedure of A/D converter/analog input power-on Always apply the A/D converter power (AVCC, AVRH and AVRL) and the analog input (AN0 to AN23) after the digital power (VCC) is turned on. Always turn off the A/D converter power and the analog input before the digital power is turned down. Make sure that AVRH should not exceed AVCC at turn on or off. ● Unused pin processing of A/D converter When not using the A/D converter, the pins should be connected so that AVCC = VCC, AVSS = AVRH = AVRL = VSS. ● Precautions at power on To prevent a malfunction of the internal step-down circuit, the voltage rising time at power-on should be 50 μs or more (0.2V to 2.7 V). ● Stabilization of supplied voltage A sudden change in the supply voltage may cause the device to malfunction even within the specified VCC supply voltage operating range. Therefore, the VCC supply voltage should be stabilized. For stabilization reference, the supply voltage should be controlled so that VCC ripple variations (peak-topeak values) at commercial frequencies (50Hz to 60Hz) fall below 10% of the standard VCC supply voltage and the transient fluctuation rate does not exceed 0.1 V/ms in the momentary fluctuation, such as switching the power supply. ● Output of port0 to port3 when turning on the power supply (external bus mode) Note that the output signals of port0 to port3 may become unstable when turning on the power supply in the external bus mode (See Figure 1.7-3). Figure 1.7-3 Output Between Port0 and Port3 When Power is On VDD 5 VDD 3 Port 0 to Port 3 Output between port0 and port3 can be unstable CM44-10144-4E Output between port0 and port3 = Hi-Z FUJITSU SEMICONDUCTOR LIMITED 27 CHAPTER 1 OVERVIEW 1.7 Precautions When Handling Devices MB90860E Series ● Flash security function Security bit is placed in the flash memory area. When you write the protecting code "01H" into the security bit, the security function is enabled. If you don't use this function, don't write "01H" into the address. Refer to the following table for the security bit address. Flash memory size MB90F867E/ES 1 M-bit flash memory equipped Security bit address FE0001H ● Serial communication There is a possibility to receive wrong data due to noise or other causes on the serial communication. Therefore, design a printed circuit board so as to avoid noise. Consider receiving of wrong data when designing the system. For example, apply a checksum to detect an error. If an error is detected, retransmit the data. ● Characteristic difference between flash device and mask ROM device In the flash device and the mask ROM device, the electrical characteristic including current consumption, ESD, latch-up, the noise characteristic, and oscillation characteristic, etc. is different according to the difference between the chip layout and the memory structure. Reconfirm the electrical characteristic when the product is replaced by another product of the same series. 28 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU This chapter explains the setting and operation of the CPU. 2.1 Overview of the CPU 2.2 Memory Space 2.3 Linear Addressing 2.4 Bank Addressing 2.5 Multibyte Data in Memory Space 2.6 Registers 2.7 Register Bank 2.8 Prefix Codes 2.9 Interrupt Disable Instructions Code: CM44-00101-3E Page: 30, 30 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 29 CHAPTER 2 CPU 2.1 Overview of the CPU 2.1 MB90340E Series Overview of the CPU The F2MC-16LX CPU core is a 16-bit CPU designed for applications that require highspeed real-time processing, such as consumer or vehicle-mounted equipments. The F2MC-16LX instruction set is designed for controller applications, and is capable of high-speed, highly efficient control processing. ■ Overview of the CPU In addition to 16-bit data, the F2MC-16LX CPU core can process 32-bit data using an internal 32-bit accumulator. Up to 16Mbytes of memory space can be used, which can be accessed by either the linear pointer or bank method. The instruction set, based on the F2MC-8L A-T architecture, has been reinforced by adding instructions compatible with high-level languages, expanding addressing modes, reinforcing multiplication and division instructions, and enhancing bit processing. The features of the F2MC-16LX CPU are explained below: ● Minimum execution time 41.7 ns (at 4-MHz oscillation, multiply-by-six) ● Maximum memory space 16Mbytes, accessed in linear or bank method ● Instruction set optimized for controller applications • Rich data types: Bit, byte, word, long word • Extended addressing modes: 23 types • Reinforced high-precision operation (32-bit length) with 32-bit accumulator ● Powerful interrupt function 8 priority levels (programmable) ● CPU-independent automatic transfer function • Up to 16 channels of the extended intelligent I/O service (EI2OS) • Up to 16 channels of the DMA transfer (μDMAC) ● Instruction set for high-level language (C language)/multitask System stack pointer/instruction set symmetry/barrel-shift instructions ● Higher execution speed 4-byte queue 30 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.2 Memory Space MB90340E Series 2.2 Memory Space F2MC-16LX CPU has the memory space of 16Mbytes. ■ Overview of CPU Memory Space A CPU has 16Mbytes of memory space where all data program I/Os managed by the F2MC-16LX CPU are located. The CPU accesses the resources by indicating their addresses using a 24-bit address bus. Figure 2.2-1 shows a sample relationship between the F2MC-16LX system and memory map. Figure 2.2-1 Sample Relationship between F2MC-16LX System and Memory Map F2MC-16LX device FFFFFFH FFFC00H Programs FF0000H*1 Vector table area ROM area Program area 100000H External area*3 010000H 008000H ROM area (FF bank image) 2 F MC-16LX CPU Internal Data Bus Peripheral circuits I/O area 007900H 001900H*2 Data EI2OS 000380H 000180H 000100H Data area General-purpose registers RAM area EI 2OS descriptor area External area*3 Peripheral circuits Interrupts 0000F0H 0000C0H 0000B0H Peripheral circuits General-purpose ports 000020H 000000H Peripheral function control register area Interrupt control register area Peripheral function control register area I/O port control register area I/O area *1: The size of the built-in ROM varies depending on the model. *2: The size of the built-in RAM varies depending on the model. *3: Access is not possible in single chip mode. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 31 CHAPTER 2 CPU 2.2 Memory Space MB90340E Series ■ ROM Area ● Vector table area (address: FFFC00H to FFFFFFH) • This area is used as a vector table for the reset, interrupt, and CALLV vectors. • This area is allocated at the highest addresses of the ROM area. The start address of the corresponding processing routine is set as data in each vector table address. ● Program area (address: Up to FFFBFFH) • ROM is built in as an internal program area. • The size of internal ROM varies depending on the model. ■ RAM Area ● Data area (address: 000100H to 0018FFH (for 6Kbytes)) • The static RAM is built in as an internal data area. • The size of internal RAM varies depending on the model. ● General-purpose register area (address: 000180H to 00037FH) • Auxiliary registers, used for 8-bit, 16-bit, and 32-bit arithmetic operations and transfer, are allocated in this area. • Since this area is allocated to a part of the RAM area, it can be used as ordinary RAM. • When this area is used as a general-purpose register, general-purpose register addressing enables high speed access with short instructions. ● Extended intelligent I/O service (El2OS) descriptor area (address: 0000100H to 00017FH) • This area retains the transfer modes, I/O addresses, transfer count, and buffer addresses. • Since this area is allocated to a part of the RAM area, it can be used as ordinary RAM. ■ I/O Area ● Interrupt control register area (address: 0000B0H to 0000BFH) The interrupt control registers (ICR00 to ICR15) support all peripheral functions that have an interrupt function, and perform the interrupt levels setting and the control of the extended intelligent I/O service (EI2OS). ● Peripheral function control register area (address: 000020H to 0000AFH, 0000C0H to 0000EFH, and 007900H to 007FFFH) This register controls the peripheral functions and inputs/outputs of data. ● I/O port control register area (address: 000000H to 00001FH) This register controls I/O ports, and inputs/outputs of data. 32 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.2 Memory Space MB90340E Series ■ Address Generation Methods The F2MC-16LX has the following two addressing methods: ● Linear addressing An 24-bit address is specified by an instruction. ● Bank addressing Upper 8-bit of an address are specified by an appropriate bank register, and the remaining lower 16-bit of an address are specified by an instruction. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 33 CHAPTER 2 CPU 2.3 Linear Addressing 2.3 MB90340E Series Linear Addressing There are two types of linear addressing: • 24-bit operand specification • 32-bit register indirect specification ■ 24-bit Operand Specification It is a method to specify a 24-bit address directly by the operand. Figure 2.3-1 shows the example of the linear method (24-bit operand specification). Figure 2.3-1 Example of Linear Method (24-bit Operand Specification) JMPP 123456H 17452DH Old program counter 17 program bank 452D JMPP 123456H 123456H Next instruction New program counter 12 program bank 3456 ■ 32-bit Register Indirect Specification It is a method to use the lower 24-bit of a 32-bit general-purpose register (RLi) as the address. Figure 2.3-2 shows the example of the linear method (32-bit register indirect specification). Figure 2.3-2 Example of Linear Method (32-bit Register Indirect Specification) MOV A,@RL1+7 Old AL 090700H XXXX 3AH 7 RL1 240906F9H (The upper 8-bit are ignored) New 34 AL 003A FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90340E Series 2.4 Bank Addressing CHAPTER 2 CPU 2.4 Bank Addressing In the bank method, the 16 M byte space is divided into 256 of 64 K byte banks. The following five bank registers are used to specify the banks corresponding to each space: • Program counter bank register (PCB) • Data bank register (DTB) • User stack bank register (USB) • System stack bank register (SSB) • Additional data bank register (ADB) ■ Bank Addressing ● Program counter bank register (PCB) The 64Kbyte bank specified by the program counter bank register (PCB) is called a program (PC) space. The PC space typically contains instruction codes, vector tables, and immediate data. ● Data bank register (DTB) The 64Kbyte bank specified by the data bank register (DTB) is called a data (DT) space. The DT space typically contains readable/ writable data, and control/data registers for internal and external resources. ● User stack bank register (USB) and System stack bank register (SSB) The 64Kbyte bank specified by the user stack bank register (USB) or system stack bank register (SSB) is called a stack (SP) space. The SP space is accessed when a stack access occurs during a push/pop instruction or interrupt register saving. The stack flag (S) in the condition code register determines which stack space is to be accessed. ● Additional data bank register (ADB) The 64Kbyte bank specified by the Additional data bank register (ADB) is called an additional (AD) space. The AD space typically contains data that cannot fit into the data (DT) space. ■ Bank Addressing and Default Space Table 2.4-1 lists the default spaces used in each addressing mode, which are pre-determined to improve instruction coding efficiency. To use a non-default space for an addressing mode, specify a prefix code corresponding to a bank before the instruction. This enables access to the bank space corresponding to the specified prefix code. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 35 CHAPTER 2 CPU 2.4 Bank Addressing MB90340E Series Table 2.4-1 Default Space Default space Addressing Program space PC indirect, program access, branch Data space @A, addr16, dir, and addressing using @RW0, @RW1, @RW4, or @RW5 Stack space Addressing using PUSHW, POPW, @RW3, or @RW7 Additional space Addressing using @RW2 or @RW6 The example of the physical address of the memory space divided into the register bank is shown in Figure 2.4-1. Figure 2.4-1 The Example of Physical Addresses of Each Space FFFFFFH Program space FF0000H FFH : PCB (Program counter bank register) B3H : ADB (Additional data bank register) 92H : USB (User stack bank register) B3FFFFH Additional space Physical address B30000H 92FFFFH User stack space 920000H 68FFFFH Data space 680000H 68H : DTB (Data bank register) 4BFFFFH System stack space 4B0000H 4BH : SSB (System stack bank register) 000000H ■ Initial Value of Bank Register By resetting, the DTB, USB, SSB, and ADB are initialized to 00H. The PCB is initialized to a value specified by the reset vector. After reset, the DT, SP, and AD spaces are allocated in bank 00H (000000H to 00FFFFH), and the PC space is allocated in the bank specified by the reset vector. 36 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.5 Multibyte Data in Memory Space MB90340E Series 2.5 Multibyte Data in Memory Space Multibyte data is allocated from the low-order addresses to the high-order addresses in the memory space in the order from the byte in LSB to the byte in MSB. ■ Multibyte Data Allocation in Memory Space Data is written to memory from the low-order addresses. Therefore, for a 32-bit data item, the lower 16 bits are transferred before the upper 16 bits. If a reset signal is input immediately after the lower bits are written, the upper bits might not be written. Figure 2.5-1 shows a sample allocation of multibyte data 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 2.5-1 Sample Allocation of Multibyte Data in Memory High-order addresses MSB 01010101B n+3 01010101B n+2 11001100B n+1 11111111B n 00010100B LSB 11001100B 11111111B 00010100B low-order addresses ■ Accessing Multibyte Data Basically, all accesses are made within a bank. For an instruction accessing a multibyte data item, the next address of FFFFH location is 0000H location of the same bank. Figure 2.5-2 shows an example of an instruction accessing multibyte data. Figure 2.5-2 Example of Accessing Multibyte Data High-order addresses AL before execution 80FFFFH ?? 01H · · · 800000H ?? 23H Execution of "MOVW A, 080FFFFH" AL after execution 23H 01H low-order addresses CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 37 CHAPTER 2 CPU 2.6 Registers 2.6 MB90340E Series Registers The F2MC-16LX registers are largely classified into two types: dedicated registers and general-purpose registers. The dedicated registers exist as dedicated internal hardware of the CPU, and they have specific use defined by the CPU architecture. The applications of the general-purpose registers can be specified by the user, as is ordinary memory space. Sharing the CPU address space with RAM, the generalpurpose registers are the same as the dedicated registers in that they can be accessed without using an address. ■ Dedicated Registers The F2MC-16LX CPU core has the following 11 dedicated registers: • Accumulator (A=AH: AL) : 2 × 16-bit accumulators (Can be used as a single 32-bit accumulator.) • User stack pointer (USP) : 16-bit pointer indicating the user stack area • System stack pointer (SSP) : 16-bit pointer indicating the system stack area • Processor status (PS) : 16-bit register indicating the system status • Program counter (PC) : 16-bit register containing the address where the program is stored • Program counter bank register (PCB) : 8-bit register indicating the PC space • Data bank register (DTB) : 8-bit register indicating the DT space • User stack bank register (USB) : 8-bit register indicating the user stack space • System stack bank register (SSB) : 8-bit register indicating the system stack space • Additional data bank register (ADB) : 8-bit register indicating the AD space • Direct page register (DPR) : 8-bit register indicating a direct page Figure 2.6-1 shows the configuration of the dedicated registers. 38 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.6 Registers MB90340E Series Figure 2.6-1 Dedicated Resisters AH AL Accumulator USP User stack pointer SSP System stack pointer PS Processor status PC Program counter DPR Direct page register PCB Program counter bank register DTB Data bank register USB User bank register SSB System stack bank register ADB Additional data bank register 8 bits 16 bits 32 bits CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 39 CHAPTER 2 CPU 2.6 Registers MB90340E Series ■ General-purpose Registers As described in Figure 2.6-2, the F2MC-16LX general-purpose registers are located from 000180H to 00037FH (maximum configuration) of main storage. The register bank pointer (RP) indicates which of the above addresses is currently being used as a register bank. Each bank has the following three types of registers. These registers are mutually dependent and have a relationship as shown below: • R0 to R7 : 8-bit general-purpose registers • RW0 to RW7 : 16-bit general-purpose registers • RL0 to RL3 : 32-bit general-purpose registers Figure 2.6-2 General-purpose Registers MSB LSB 16 bits 000180H RP × 10 H RW0 Lower RL0 Starting address of general-purpose register RW1 RW2 RL1 RW3 R1 R0 RW4 R3 R2 RW5 R5 R4 RW6 R7 R6 RW7 RL2 RL3 Upper The relationship between the upper/lower bytes of a byte or word register is expressed as follows: RW(i+4)=R(i × 2+1) × 256 + R(i × 2) [i=0 to 3] The relationship between the upper/lower bytes of RLi and RW is expressed as follows: RL(i)=RW(i × 2+1) × 65536 + RW(i × 2) [i=0 to 3] 40 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.6 Registers MB90340E Series 2.6.1 Accumulator (A) The accumulator (A) consists of 2 × 16-bit arithmetic operation registers (AH and AL), and is used as a temporary register for operation results and transfer data. ■ Accumulator (A) During 32-bit data processing, AH and AL are used together (see Figure 2.6-3). Only AL is used for word processing in 16-bit data processing mode or for byte processing in 8-bit data processing mode (see Figure 2.6-4). The data stored in the accumulator (A) can be operated upon with the data in memory or registers (Ri, RWi, and RLi). In the same manner as with the F2MC-8L, when a word or shorter data item is transferred to AL, the previous data item in AL is automatically sent to AH (data preservation function). The data preservation function and operation between AL and AH help improve processing efficiency. When a byte or shorter data item is transferred to AL, the data is sign-extended or zero-extended and stored as a 16-bit data item in AL. The data in AL can be handled either as word or byte long. When a byte-processing arithmetic operation instruction is executed on AL, the upper 8 bits of AL before operation are ignored. The upper 8 bits of the operation result all become "0". The accumulator (A) is not initialized by a reset and holds an undefined value right after the reset. Figure 2.6-3 and Figure 2.6-4 show the processing of 32-bit data transfer and AL to AH transfer, respectively. Figure 2.6-3 An Example of 32-bit Data Transfer MOVL A,@RW1+6 A before execution XXXXH MSB XXXXH 8F74H 8FH 74H A6153EH 2BH 52H 15H 38H +6 2B52H AH A61540H A6H DTB A after execution LSB RW1 AL Figure 2.6-4 An Example of AL to AH Transfer MSB MOVW A,@RW1+6 A before execution XXXXH 1234H DTB A6H LSB A61540H 8FH 74H A6153EH 2BH 52H 15H 38H +6 A after execution CM44-10144-4E 1234H 2B52H RW1 FUJITSU SEMICONDUCTOR LIMITED 41 CHAPTER 2 CPU 2.6 Registers 2.6.2 MB90340E Series User Stack Pointer (USP) and System Stack Pointer (SSP) User stack pointer (USP) and system stack pointer (SSP) are 16-bit registers that indicate the memory addresses for saving/restoring data when a push/pop instruction or subroutine is executed. ■ User Stack Pointer (USP) and System Stack Pointer (SSP) User stack pointer (USP) and system stack pointer (SSP) registers are used by the stack instructions. However, the USP register is enabled when the stack flag (S) in the processor status (PS) is "0", and the SSP register is enabled when the S flag is "1" (see Figure 2.6-5). Since the S flag is set when an interrupt is accepted, register values are always saved in the memory area indicated by SSP during interrupt processing. SSP is used for stack processing in an interrupt routine, while USP is used for stack processing other than in an interrupt routine. If you do not need to divide the stack space, use only the SSP. During stack processing, the upper 8 bits of an address are indicated by SSB (for SSP) or USB (for USP). USP and SSP are not initialized by a reset. Instead, they hold undefined values. Figure 2.6-5 shows the relationship between the stack manipulation instructions and the stack pointers when the stack flag (S) is "0" or "1". Figure 2.6-5 Stack Manipulation Instruction and Stack Pointer Example of PUSHW A when the S flag is "0" Before execution AL S flag After execution AL S flag MSB C6F326H LSB A624 H USB C6H USP F328H 0 SSB 56H SSP 1234H A624 H USB C6H USP F326H 0 SSB 56H SSP 1234H C6F326H A6H 24H 561232H XX XX 561232H A6H 24H XX XX System stack is used because the S flag is "0". Example of PUSHW A when the S flag is "1" AL S flag AL S flag 42 A624 H USB C6H USP F328H 1 SSB 56H SSP 1234H A624 H USB C6H USP F328H 1 SSB 56H SSP 1232H System stack is used because the S flag is "1". FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.6 Registers MB90340E Series Note: When you specify a value to be set in the stack pointer, use an even-numbered address whenever possible. If an odd-numbered address is set, the word access is divided into two times. Therefore, the processing efficiency decreases. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 43 CHAPTER 2 CPU 2.6 Registers 2.6.3 MB90340E Series Processor Status (PS) The processor status (PS) register consists of the bits controlling the CPU operation and the bits indicating the CPU status. ■ Processor Status (PS) As shown in Figure 2.6-6, the upper bytes of the PS register consist of the register bank pointers (RP) and the interrupt level mask (ILM) that indicate the starting address of a register bank. The lower bytes of the PS register consist of the condition code register (CCR), containing the flags to be set or reset depending on the results of instruction execution or interrupt occurrences. Figure 2.6-6 Processor Status (PS) Structure bit 15 13 PS 12 8 ILM 7 0 RP CCR ■ Condition Code Register (CCR) Figure 2.6-7 shows the structure of the condition code register. Figure 2.6-7 Structure of Condition Code Register (CCR) bit Initial value 7 6 5 4 3 2 1 0 - I S T N Z V C - 0 1 * * * * * : CCR * : Undefined value ● Interrupt enable flag (I) Interrupts other than software interrupts are enabled when the I flag is "1", and are disabled when the I flag is "0". The I flag is cleared to "0" by a reset. ● Stack flag (S) When the S flag is "0", USP is enabled as the stack manipulation pointer. When the S flag is "1", SSP is enabled as the stack manipulation pointer. The S flag is set to "1" by an interrupt reception or a reset. ● Sticky bit flag (T) "1" is set in the T flag when there is one or more "1" in the data shifted out from the carry after execution of a logical right/arithmetic right shift instruction. Otherwise, "0" is set in the T flag. ● Negative flag (N) The "1" is set in the N flag when the MSB of the operation result is "1". Otherwise, N flag is cleared to "0". 44 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.6 Registers MB90340E Series ● Zero flag (Z) The Z flag is set to "1" when the operation result is all "0". Otherwise, Z flag is cleared to "0". ● Overflow flag (V) The V flag is set when an overflow of a signed value occurs as a result of operation execution. In other cases, V flag is cleared to "0". ● Carry flag (C) The C flag is set when a carry-up or carry-down from the MSB occurs as a result of operation execution. In other cases, C flag is cleared to "0". ■ Register Bank Pointer (RP) As shown in Figure 2.6-8, the register bank pointer (RP) register indicates the relationship between the general-purpose registers of the CPU and the internal RAM addresses where the general-purpose registers exist. Specifically, the RP register indicates the starting memory address of the currently used register bank in the following conversion expression: [00180H + (RP) × 10H]. The RP register that consists of five bits can take a value between 00H and 1FH and allocate the register banks at addresses from 000180H to 00037FH in the memory. Even within that range, however, the register banks cannot be used as generalpurpose registers if the banks are not in internal RAM. All RP registers are initialized to "0" by a reset. An instruction may transfer an 8-bit immediate value to the RP register but, only the lower 5 bits of that data are used. Figure 2.6-8 Register Bank Pointer (RP) Initial value B4 B3 B2 B1 B0 0 0 0 0 0 : RP ■ Interrupt Level Mask (ILM) As described in Figure 2.6-9, the interrupt level mask (ILM) consists of 3 bits, indicating the CPU interrupt masking level. Only an interrupt request of which interrupt level is higher than that indicated by these 3 bits will be accepted. Level 0 is the highest priority interrupt, and level 7 is the lowest priority interrupt (see Table 2.6-1). Therefore, for an interrupt to be accepted, its level value must be smaller than the current ILM value. When an interrupt is accepted, the level value of that interrupt is set in ILM. Thus, a subsequent interrupt of the same or lower level cannot be accepted. All ILMs are initialized to "0" by a reset. An instruction may transfer an 8-bit immediate value to the ILM register, but only the lower 3 bits of that data are used. Figure 2.6-9 Interrupt Level Mask (ILM) Initial value CM44-10144-4E ILM2 ILM1 ILM0 0 0 0 : ILM FUJITSU SEMICONDUCTOR LIMITED 45 CHAPTER 2 CPU 2.6 Registers MB90340E Series Table 2.6-1 Levels Indicated by the Interrupt Level Mask (ILM) 46 ILM2 ILM1 ILM0 Level value Acceptable interrupt level 0 0 0 0 Interrupts disabled 0 0 1 1 Level value less than 1 (0 only) 0 1 0 2 Level value less than 2 (0 and 1) 0 1 1 3 Level value less than 3 (0, 1 and 2) 1 0 0 4 Level value less than 4 (0, 1, 2 and 3) 1 0 1 5 Level value less than 5 (0, 1, 2, 3 and 4) 1 1 0 6 Level value less than 6 (0, 1, 2, 3, 4 and 5) 1 1 1 7 Level value less than 7 (0, 1, 2, 3, 4, 5 and 6) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.6 Registers MB90340E Series 2.6.4 Program Counter (PC) Program counter (PC) shows lower 16-bit of the memory address of the instruction code that CPU should execute. ■ Program Counter (PC) The program counter (PC) register is a 16-bit counter that indicates the lower 16 bits of the memory address of an instruction code to be executed by the CPU. The upper 8 bits of the address are indicated by the PCB. The PC register is updated by a conditional branch instruction, subroutine call instruction, interrupt, or reset. The PC register can also be used as a base pointer for operand access. Figure 2.6-10 shows the program counter. Figure 2.6-10 Program Counter PCB FEH PC ABCDH Next instruction to be executed FEABCDH CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 47 CHAPTER 2 CPU 2.6 Registers 2.6.5 MB90340E Series Bank Registers (PCB, DTB, USB, SSB, ADB) The bank register shows the memory bank where the program space, the data space, the user stack space, the system stack space, and the Additional space are arranged. ■ Bank Registers (PCB, DTB, USB, SSB, ADB) The bank registers includes the following five registers. • Program Count Bank Register (PCB) <Initial Value: Value in Reset Vector> • 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 and written. PCB can only be read. 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 "2.2 Memory Space". 48 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.6 Registers MB90340E Series 2.6.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 2.6-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 2.6-11 illustrates the generation of a physical address in the direct addressing mode. Figure 2.6-11 Generating a Physical Address in Direct Addressing Mode DTB register DPR register MSB Direct address in instruction LSB 24-bit physical address CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 49 CHAPTER 2 CPU 2.7 Register Bank 2.7 MB90340E Series Register Bank A register bank that consists of 8 words can be used as the general-purpose registers for the arithmetic operations or as the pointers for the instructions, such as byte registers (R0 to R7), word registers (RW0 to RW7), and long word registers (RL0 to RL3). In addition, RL0 to RL3 can also be used as the linear pointers to access directly to the entire space in the memory space. ■ Register Bank Table 2.7-1 lists the register functions. Table 2.7-2 shows the relationship between each register. In the same manner as for an ordinary RAM area, the register bank values are not initialized by a reset. The status before a reset is maintained. When the power is turned-on, however, the register bank will have an undefined value. Table 2.7-1 Register Functions Used as operands of instructions. Note: R0 is also used as a counter for barrel shift or normalization instruction R0 to R7 RW0 to RW7 Used as pointers and operands of instructions. Note: RW0 is used as a counter for string instructions. RL0 to RL3 Used as long pointers and operands of instructions. Table 2.7-2 Relationship between Registers Address Byte register 000180H + RP × 10H + 0 Long word register RW0 000180H + RP × 10H + 1 RL0 000180H + RP × 10H + 2 RW1 000180H + RP × 10H + 3 000180H + RP × 10H + 4 RW2 000180H + RP × 10H + 5 RL1 000180H + RP × 10H + 6 RW3 000180H + RP × 10H + 7 50 Word register 000180H + RP × 10H + 8 R0 000180H + RP × 10H + 9 R1 000180H + RP × 10H + 10 R2 000180H + RP × 10H + 11 R3 000180H + RP × 10H + 12 R4 000180H + RP × 10H + 13 R5 000180H + RP × 10H + 14 R6 000180H + RP × 10H + 15 R7 RW4 RL2 RW5 RW6 RL3 RW7 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.8 Prefix Codes MB90340E Series 2.8 Prefix Codes Placing a prefix code before an instruction can partially change the operation of the instruction. 3 types of prefix codes can be used: bank select prefix, common register bank prefix, and flag change disable prefix. ■ Bank Select Prefix The memory space used for accessing data depends on each addressing mode. When a bank select prefix is placed before an instruction, the memory space used for accessing data by that instruction can be selected regardless of the addressing mode. Table 2.8-1 shows the bank select prefixes and selected memory spaces. Table 2.8-1 Bank Select Prefix Bank select prefix Selected space PCB PC space DTB Data space ADB AD space SPB Either the SSP or USP space is used according to the stack flag (S) value. In using the following instructions, the effect of prefix codes is different: • String instructions MOVS MOVSW SCEQ SCWEQ FILS FILSW The bank register specified by an operand is used regardless of the prefix. • Stack manipulation instructions PUSHW POPW SSB or USB is used according to the stack flag (S) regardless of the prefix. I/O access instructions MOV A,io MOVW io,A MOVB io:bp,A BBS io:bp,rel MOV io,A MOV io,#imm8 SETB io:bp WBTC MOVX A,io MOVW io,#imm16 CLRB io:bp WBTS MOVW A,io MOVB A,io:bp BBC io:bp,rel The I/O space of the bank is used regardless of the prefix. • Flag change instructions AND CCR,#imm8 OR CCR,#imm8 The instruction is executed normally, but the prefix affects the next instruction. • Other control instructions (Stack manipulation) POPW PS Either SSB or USB is used according to the stack flag (S) regardless of the prefix. The prefix affects the next instruction. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 51 CHAPTER 2 CPU 2.8 Prefix Codes MB90340E Series • Other control instructions (Interrupt control) MOV ILM,#imm8 The instruction is executed normally, but the prefix affects the next instruction. • Branch instructions RETI SSB is used regardless of the prefix. ■ Common Register Bank Prefix (CMR) To simplify data exchange between multiple tasks, the same register bank must be accessed regardless of the register pointer (RP) value. When the common register bank prefix (CMR) is placed before an instruction that accesses the register bank, that instruction accesses the common bank (the register bank selected when RP=0) at addresses from 000180H to 00018FH regardless of the current RP value. In using the following instructions, the effect of prefix codes is different: • String instructions MOVS MOVSW SCEQ SCWEQ FILS FILSW If an interrupt request occurs during execution of a string instruction with a prefix code, the string instruction is executed falsely because the prefix becomes invalid for the string instruction after the interrupt is returned. Do not attach CMR prefix to any of the above string instructions. • Other control instructions (Flag change) AND CCR,#imm8 OR CCR,#imm8 POPW PS The instruction is executed normally, but the prefix affects the next instruction. • Other control instructions (Interrupt control) MOV ILM,#imm8 The instruction is executed normally, but the prefix affects the next instruction. ■ Flag Change Disable Prefix (NCC) To disable a flag change, use the flag change disable prefix code (NCC). Placing NCC before an instruction that disables an unwanted flag change can disable flag changes associated with that instruction. In using the following instructions, the effect of prefix codes is different: • String instructions MOVS MOVSW SCEQ SCWEQ FILS FILSW If an interrupt request occurs during execution of a string instruction with a prefix code, the string instruction is executed falsely because the prefix becomes invalid for the string instruction after the interrupt is returned. Do not attach NCC prefix to any of the above string instructions. • Flag change instructions AND CCR,#imm8 OR CCR,#imm8 POPW PS The instruction is executed normally, but the prefix affects the next instruction. • Interrupt instructions INT #vct8 / INT9 INT addr16 INTP addr24 RETI CCR changes according to the instruction specifications regardless of the prefix. 52 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 2 CPU 2.8 Prefix Codes MB90340E Series • Other control instructions (Switch of tasks) JCTX @A CCR changes according to the instruction specifications regardless of the prefix. • Other control instructions (Interrupt control) MOV ILM, #imm8 The instruction is executed normally, but the prefix affects the next instruction. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 53 CHAPTER 2 CPU 2.9 Interrupt Disable Instructions 2.9 MB90340E Series Interrupt Disable Instructions Interrupt requests are not accepted about following 10 instructions: MOV ILM, #imm8 AND CCR, #imm8 PCB ADB SPB CMR OR CCR, #imm8 POPW PS NCC DTB ■ Interrupt Disable Instructions As shown in Figure 2.9-1, if a valid hardware interrupt request occurs during execution of any of the above instructions, the interrupt can be processed only when an instruction other than the above is executed. Figure 2.9-1 Interrupt Disable Instructions Interrupt disable instructions •••••••• ••• (a) (a) : Ordinary instruction Interrupt request generated Interrupt accepted ■ Restrictions on Interrupt Disable Instructions and Prefix Instructions As shown in Figure 2.9-2, when a prefix code is placed before an interrupt disable instruction, the prefix code affects the first instruction after the code other than the interrupt disable instruction. Figure 2.9-2 Interrupt Disable Instructions and Prefix Codes Interrupt disable instructions MOV A, FFH NCC •••• MOV ILM,#imm8 ADD A,01H CCR:XXX10XXB CCR:XXX10XXB CCR does not change with NCC. ■ Consecutive Prefix Codes As shown in Figure 2.9-3, when competitive prefix codes are placed consecutively, the latter one becomes valid. Competitive prefix codes are PCB, ADB, DTB, and SPB. Figure 2.9-3 Consecutive Prefix Codes Prefix codes ••••• ADB DTB PCB ADD A,01H ••••• PCB becomes valid as the prefix code 54 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS This chapter describes the interrupts, the extended intelligent I/O service (EI2OS), and the exceptions. 3.1 Overview of Interrupts 3.2 Interrupt Vector 3.3 Interrupt Control Register (ICR00 to ICR15) 3.4 Interrupt Flow 3.5 Hardware Interrupts 3.6 Software Interrupts 3.7 Extended Intelligent I/O Service (EI2OS) 3.8 Operation Flow of Extended Intelligent I/O Service (EI2OS) and its Application Procedure 3.9 Exceptions Code: CM44-00106-2E Page: 59, 73 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 55 CHAPTER 3 INTERRUPTS 3.1 Overview of Interrupts 3.1 MB90860E Series Overview of Interrupts The F2MC-16LX has interrupt functions that suspend the currently executing processing and transfer control to another specified program when a specified event occurs. There are 5 types of interrupt functions: • Hardware interrupt • Software interrupt • Extended intelligent I/O service (EI2OS) • μDMAC • Exception ■ Hardware Interrupts A hardware interrupt is activated by an interrupt request from a peripheral resource. A hardware interrupt request occurs when both the interrupt request flag and the interrupt enable flag in a peripheral resource are set. A peripheral resource has an interrupt request flag and interrupt enable flag to use a hardware interrupt. ● Specifying an interrupt level An interrupt level can be specified for the hardware interrupt. To specify an interrupt level, use the level setting bits (IL0, IL1, and IL2) of the interrupt controller. ● Masking a hardware interrupt request A hardware interrupt request can be masked by using the interrupt enable flag (I) and the interrupt level mask (ILM) of the processor status (PS) in the CPU. When an unmasked interrupt request occurs, the CPU saves 12 bytes of data that consists of registers PS, PC, PCB, DTB, ADB, DPR, AH, and AL in the memory area indicated by the SSB and SSP registers. Figure 3.1-1 Overview of Hardware Interrupt Microcode IR ILM Check Comparator PS I ILM IR : Processor status : Interrupt enable flag : Interrupt level mask : Instruction register Peripheral AND Source FF Interrupt level IL F2MC-16LX CPU Enabling FF 56 I PS Level comparator F2MC-16LX bus Register file Interrupt controller FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.1 Overview of Interrupts MB90860E Series ■ Software Interrupts The software interrupt function transfers control from the program that is currently being executed by the CPU to another interrupt processing program that is defined by the user. Software interrupts are requested by executing the INT instruction. An interrupt request by the INT instruction does not have an interrupt request or enable flag. An interrupt request is issued always by executing the INT instruction. No interrupt level is assigned to the INT instruction. Therefore, interrupt level mask (ILM) is not updated when the INT instruction is used. Instead, the interrupt enable flag (I) is cleared and the continuing interrupt requests are suspended. Figure 3.1-2 Overview of Software Interrupt F2MC-16LX bus Register file PS I S B unit Microcode IR F2MC-16LX CPU Queue Fetch PS I S IR B unit : Processor status : Interrupt enable flag : Stack flag : Instruction register : Bus interface unit Save Instruction bus RAM ■ Extended Intelligent I/O Service (EI2OS) The extended intelligent I/O service automatically transfers data between an internal peripheral and memory. This processing is traditionally performed by an interrupt processing program, but the EI2OS enables data to be transferred in a manner similar to a DMA (direct memory access) operation. To use the extended intelligent I/O service function by a peripheral resource, the interrupt control register (ICR00 to ICR15) of the interrupt controller has an extended intelligent I/O service enable flag (ISE). The extended intelligent I/O service is activated by the occurrence of an interrupt request when the ISE flag is set to "1". To generate a normal interrupt using a hardware interrupt request, set the ISE flag to "0". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 57 CHAPTER 3 INTERRUPTS 3.1 Overview of Interrupts MB90860E Series Figure 3.1-3 Overview of Extended Intelligent I/O Service (EI2OS) Memory space IOA CPU I/O register I/O register Peripheral Interrupt request (3) ISD (3) (1) ICS (2) Interrupt control register Interrupt controller BAP (4) Buffer DCT IOA: I/O register address pointer BAP: Buffer address pointer (1) I/O requests transfer. (2) Interrupt controller selects a descriptor. (3) Transfer source/destination is read from the descriptor. (4) Data is transferred between I/O and memory. 58 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.1 Overview of Interrupts MB90860E Series ■ Direct Memory Access (DMA) μDMAC is one of the hardware interrupts by which an automatic data transfer is performed between a peripheral function and memory. μDMA enables the data that is transferred by an interrupt processing program to be transferred in a manner similar to a Direct Memory Access (DMA) operation. The interrupt processing program is automatically executed once a specified number of data transfers are completed. This series is equipped with the μDMAC function. About the operation of μDMAC, see "CHAPTER 4 μDMAC". Figure 3.1-4 Overview of Direct Memory Access (DMA) Memory space Descriptor RAM IOA I/O register Peripheral function (I/O) I/O register (4) (a) (1) (2) (3) DMA controller DMA descriptor (2) (4) (b) BAP Buffer Interrupt controller CPU DCT IOA : I/O register address pointer DER: DMA enable register BAP: Buffer address pointer DCT: Data counter (1) A peripheral (I/O) requests DMA transfer. (2) When the corresponding bit of the DMA enable register (DER) is set to "1", the DMAC controller reads transfer data (transfer source address, destination address and transfer channel) from the descriptor. (3) DMA data transfer starts between I/O and memory. (4) After one item (either byte data or word data) is transferred: (a) If the transfer is not completed (DCT is not "0"), it will request the peripheral to clear the DMA transfer request. (b) If the transfer is completed (DCT=0), a transfer end flag will be set in the DMA status register upon the completion of the DMA transfer, and an interrupt request will be output to the interrupt controller. To write to an internal register (DSRH, DSRL, DSSR, DERH, or DERL), use a read-modify-write (RMW) instruction. ■ Exception Processing Exception processing is basically the same as interrupt processing. When an exception is detected between instructions, the normal processing is suspended and exception processing is performed instead. In general, exception processing occurs as a result of an unexpected operation. Therefore, it is recommended to use exception processing only for debugging programs or for activating recovery software in an emergency. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 59 CHAPTER 3 INTERRUPTS 3.2 Interrupt Vector 3.2 MB90860E Series Interrupt Vector An interrupt vector uses the same area for both hardware and software interrupts. For example, interrupt request number (INT42) is used for a delayed hardware interrupt and for software interrupt (INT #42). Therefore, the external interrupt and INT #42 call the same interrupt processing routine. Interrupt vectors are allocated between addresses FFFC00H and FFFFFFH as shown in Table 3.2-1. ■ Interrupt Vector Table 3.2-1 Interrupt Vector (1 / 2) Interrupt request Interrupt source Interrupt control register No. Address Vector address: Low Vector address: Middle Vector address: High Mode register INT 0 * - - - FFFFFCH FFFFFDH FFFFFEH Unused INT 1 * - - - FFFFF8H FFFFF9H FFFFFAH Unused - - - . . . . . . . . . . . . - - - FFFFE0H FFFFE1H FFFFE2H Unused . . . INT 7 * INT 8 Reset - - FFFFDCH FFFFDDH FFFFDEH FFFFDFH INT 9 INT9 instruction - - FFFFD8H FFFFD9H FFFFDAH Unused INT 10 Exception processing - - FFFFD4H FFFFD5H FFFFD6H Unused INT 11 Hardware interrupt 0000B0H FFFFD0H FFFFD1H FFFFD2H Unused ICR00 FFFFCCH FFFFCDH FFFFCEH Unused FFFFC8H FFFFC9H FFFFCAH Unused FFFFC4H FFFFC5H FFFFC6H Unused FFFFC0H FFFFC1H FFFFC2H Unused FFFFBCH FFFFBDH FFFFBEH Unused FFFFB8H FFFFB9H FFFFBAH Unused FFFFB4H FFFFB5H FFFFB6H Unused FFFFB0H FFFFB1H FFFFB2H Unused FFFFACH FFFFADH FFFFAEH Unused FFFFA8H FFFFA9H FFFFAAH Unused FFFFA4H FFFFA5H FFFFA6H Unused INT 12 Hardware interrupt INT 13 Hardware interrupt INT 14 Hardware interrupt INT 15 Hardware interrupt INT 16 Hardware interrupt INT 17 Hardware interrupt INT 18 Hardware interrupt INT 19 Hardware interrupt INT 20 Hardware interrupt INT 21 Hardware interrupt INT 22 60 Hardware interrupt ICR01 ICR02 ICR03 ICR04 ICR05 0000B1H 0000B2H 0000B3H 0000B4H 0000B5H FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.2 Interrupt Vector MB90860E Series Table 3.2-1 Interrupt Vector (2 / 2) Interrupt request INT 23 Interrupt source No. Address ICR06 0000B6H Hardware interrupt INT 24 Hardware interrupt INT 25 Hardware interrupt INT 26 Hardware interrupt INT 27 Hardware interrupt INT 28 Hardware interrupt INT 29 Hardware interrupt INT 30 Hardware interrupt INT 31 Hardware interrupt INT 32 Hardware interrupt INT 33 Hardware interrupt INT 34 Hardware interrupt INT 35 Hardware interrupt INT 36 Hardware interrupt INT 37 Hardware interrupt INT 38 Hardware interrupt INT 39 Hardware interrupt INT 40 Hardware interrupt INT 41 Hardware interrupt INT 42 Interrupt control register Hardware interrupt INT 43 ICR07 ICR08 ICR09 ICR10 ICR11 ICR12 ICR13 ICR14 ICR15 0000B7H 0000B8H 0000B9H 0000BAH 0000BBH 0000BCH 0000BDH 0000BEH 0000BFH Vector address: Low Vector address: Middle Vector address: High Mode register FFFFA0H FFFFA1H FFFFA2H Unused FFFF9CH FFFF9DH FFFF9EH Unused FFFF98H FFFF99H FFFF9AH Unused FFFF94H FFFF95H FFFF96H Unused FFFF90H FFFF91H FFFF92H Unused FFFF8CH FFFF8DH FFFF8EH Unused FFFF88H FFFF89H FFFF8AH Unused FFFF84H FFFF85H FFFF86H Unused FFFF80H FFFF81H FFFF82H Unused FFFF7CH FFFF7DH FFFF7EH Unused FFFF78H FFFF79H FFFF7AH Unused FFFF74H FFFF75H FFFF76H Unused FFFF70H FFFF71H FFFF72H Unused FFFF6CH FFFF6DH FFFF6EH Unused FFFF68H FFFF69H FFFF6AH Unused FFFF64H FFFF65H FFFF66H Unused FFFF60H FFFF61H FFFF62H Unused FFFF5CH FFFF5DH FFFF5EH Unused FFFF58H FFFF59H FFFF5AH Unused FFFF54H FFFF55H FFFF56H Unused - - - FFFF50H FFFF51H FFFF52H Unused - - - . . . . . . . . . . . . INT 254 - - - FFFC04H FFFC05H FFFC06H Unused INT 255 - - - FFFC00H FFFC01H FFFC02H Unused . . . *: When the program counter bank register (PCB) is FFH, the vector area for the CALLV instruction is the same as that for #0 to #7 values setting #vct8 item in the "INT #vct8" instruction. Care must be taken when using the vector for the CALLV instruction. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 61 CHAPTER 3 INTERRUPTS 3.3 Interrupt Control Register (ICR00 to ICR15) 3.3 MB90860E Series Interrupt Control Register (ICR00 to ICR15) The interrupt control registers are in the interrupt controller. Each interrupt control register has a corresponding I/O that has an interrupt function. The interrupt control registers have the following three functions: • Setting an interrupt level for corresponding peripherals • Selecting whether to use an ordinary interrupt or extended intelligent I/O service for the corresponding peripherals • Selecting the extended intelligent I/O service channel Do not access an interrupt control register (ICR00 to ICR15) by using a read-modifywrite (RMW) instruction, as doing so causes a malfunction. ■ Interrupt Control Register (ICR00 to ICR15) Figure 3.3-1 shows the bit configuration of an interrupt control register (ICR00 to ICR15). Figure 3.3-1 Bit Configuration of an Interrupt Control Register(ICR00 to ICR15) bit 7 6 5 4 3 ICS3 ICS2 ICS1 or S1 ICS0 or S0 ISE W W R, W* R, W* R/W 2 1 0 IL2 IL1 IL0 R/W R/W R/W When interrupt control register is reset: 00000111B R/W : Readable/Writable W : Write only *: ICS1 and ICS0 are valid for write (W) only. S1 and S0 are valid for read (R) only. Additional information The extended intelligent I/O service channel select bits (ICR:ICS3 to ICS0) are valid for write only. The extended intelligent I/O service status bits (ICR:S1, S0) are valid for read only. In read operation, "1" is read from bit6, bit7 (ICS2, ICS3). Note: ICS3 to ICS0 are valid only when EI2OS is activated. Set "1" in ISE to activate EI2OS, and set "0" in ISE not to activate it. When EI2OS is not to be activated, any value can be set in ICS3 to ICS0. 62 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.3 Interrupt Control Register (ICR00 to ICR15) MB90860E Series [bit7 to bit4] ICS3 to ICS0: extended intelligent I/O service channel select bits These bits are used for write operation only. These bits specify the EI2OS channel. The values set in these bits determine the intelligent I/O service descriptor addresses in memory. ICS3 to ICS0 is initialized to 0000B by a reset. Table 3.3-1 shows the relationship between the ICS3 to ICS0 bits, channel numbers, and descriptor addresses. Table 3.3-1 ICS3 to ICS0 Bits, Channel Numbers, and Descriptor Addresses CM44-10144-4E ICS3 ICS2 ICS1 ICS0 Channel to be selected 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 FUJITSU SEMICONDUCTOR LIMITED 63 CHAPTER 3 INTERRUPTS 3.3 Interrupt Control Register (ICR00 to ICR15) MB90860E Series [bit5, bit4] S0, S1: extended intelligent I/O service status bits These are EI2OS end status bits and used for read operation only. The values set in these bits indicate the end condition of EI2OS. They are initialized to 00B by a reset. Table 3.3-2 shows the relationship between the S1, S0 bits and the end conditions. Table 3.3-2 S1, S0 Bits and End Conditions S1 S0 End condition 0 0 EI2OS running or not activated 0 1 Terminated by completion of count 1 0 Reserved 1 1 Terminated by request from internal peripheral [bit3] ISE: extended intelligent I/O service enable bits These bits are used to enable EI2OS. In response to an interrupt request, EI2OS is activated when "1" is set in the ISE bit and an interrupt sequence is activated when "0" is set in the ISE bit. Upon completion of EI2OS (either due to completion of a count, or a request from a internal peripheral), the ISE bit is cleared to "0". If the corresponding peripheral does not have the EI2OS function, the ISE bit must be set to "0" on the software side. These bits are readable and writable. The ISE bit is initialized to "0" by a reset. [bit2 to bit0] IL2 to IL0: interrupt level setting bits These bits specify the interrupt level of the corresponding internal peripherals, and they are readable and writable. Upon a reset, these bits are initialized to level 7 (no interrupt). Table 3.3-3 describes the relationship between the interrupt level setting bits and interrupt levels. 64 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.3 Interrupt Control Register (ICR00 to ICR15) MB90860E Series Table 3.3-3 Interrupt Level Setting Bits and Interrupt Levels CM44-10144-4E IL2 IL1 IL0 Interrupt level 0 0 0 0 (Highest interrupt) 0 0 1 1 0 1 0 2 0 1 1 3 1 0 0 4 1 0 1 5 1 1 0 6 (Lowest interrupt) 1 1 1 7 (No interrupt) FUJITSU SEMICONDUCTOR LIMITED 65 CHAPTER 3 INTERRUPTS 3.4 Interrupt Flow 3.4 MB90860E Series Interrupt Flow Figure 3.4-1 shows the interrupt flow. ■ Interrupt Flow Figure 3.4-1 Interrupt Flow I : Interrupt enable flag in CCR ILM : Interrupt level mask IF : Peripheral resource interrupt request IE : Peripheral resource interrupt enable flag ENx: DMA activation request flag in DMA enable register ISE : EI2OS enable flag IL : Peripheral resource interrupt request level S : Stack flag in CCR START NO* ENx = 1 YES DMA processing Specified number of transfers ended? Or, any end request from peripheral function? YES I & IF & IE = 1 AND ILM > IL NO YES YES ISE = 1 NO Fetching and decoding the next instruction INT instruction NO Saving PS, PC, PCB, DTB, DPR, AH and AL into the stack of SSP, and setting ILM=IL Processing the extended intelligent I/O service YES NO Executing an ordinary instruction NO Saving PS, PC, PCB, DTB, ADB, DPR, AH and AL into the stack of SSP, and setting I ← 0, ILM ← IL Completion of string instruction repetition YES Updating PC S←1 Fetching the interrupt vector *: For the product without μDMAC, "NO" is always selected. 66 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.4 Interrupt Flow MB90860E Series Figure 3.4-2 Register Saving during Interrupt Processing Word (16 bits) "H" MSB LSB SSP (SSP value before interrupt) AH AL DPR ADB DTB PCB PC SSP (SSP value after interrupt) "L" CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 67 CHAPTER 3 INTERRUPTS 3.5 Hardware Interrupts 3.5 MB90860E Series Hardware Interrupts In response to an interrupt request signal from a peripheral resource, the CPU temporarily suspends the current program execution and transfers control to the interrupt processing program defined by the user. ■ Hardware Interrupt A hardware interrupt occurs when the relevant conditions are satisfied as a result of two operations: comparison between the interrupt request level and the value in the interrupt level mask (ILM), and hardware reference to the interrupt enable flag (I). The CPU performs the following processing when a hardware interrupt occurs: • Saves the values in the PC, PS, AH, AL, PCB, DTB, ADB, and DPR registers of the CPU to the system stack. • Sets ILM in the PS register. The currently requested interrupt level is automatically set. • Fetches the corresponding interrupt vector value and branches to the processing indicated by that value. ■ Structure of Hardware Interrupt Hardware interrupts are handled by the following three sections: ● Peripheral resource Interrupt enable and request bits: Used to control interrupt requests from peripherals. ● Interrupt controller ICR: Assigns interrupt levels and determines the priority levels of simultaneously requested interrupts. ● CPU I and ILM: Compares the requested and current interrupt levels and identifies the interrupt enable status Microcode: Interrupt processing step The status of these sections is indicated by the peripheral control registers for peripheral resources, the ICR for the interrupt controller, and the CCR value for the CPU. To use a hardware interrupt, set the three sections beforehand by using software. The interrupt vector table referenced during interrupt processing is assigned to addresses FFFC00H to FFFFFFH in memory. These addresses are shared with software interrupts. 68 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.5 Hardware Interrupts MB90860E Series 3.5.1 Hardware Interrupt Operation A internal peripheral with the hardware interrupt request function has 2 types of flags: the interrupt request flag, which indicates whether an interrupt request exists; and the interrupt enable flag, which determines whether it requests an interrupt to the CPU. An interrupt request flag is set when an event specific to that internal peripheral is generated. When the interrupt enable flag is set to Enable, the peripheral outputs an interrupt request to the interrupt controller. ■ Hardware Interrupt Operation When more than one request are received at the same time, the interrupt controller compares the interrupt levels (IL) in ICR, selects the request with the highest level (the smallest IL value), then reports that request to the CPU. If multiple requests are at the same level, the interrupt controller selects the request with the smaller interrupt number. The relationship between the interrupt requests and ICRs is determined by the hardware. The CPU compares the received interrupt level (IL) with the interrupt level mask (ILM). If the IL is smaller than the ILM value and the interrupt enable flag (I) set to "1", the CPU activates the interrupt processing microcode after completing the currently executing instruction. The CPU references the ISE bit of the ICR in the interrupt controller at the beginning of the interrupt processing microcode to check that the ISE bit is "0" (interrupt sequence start). If the ISE bit is "0", the CPU activates the interrupt processing body. The interrupt processing body saves 12 bytes (PS, PC, PCB, DTB, ADB, DPR, AH, and AL) to the memory area indicated by SSB and SSP, fetches three bytes of interrupt vector and loads them onto PC and PCB, updates the ILM of PS to a level value of the received interrupt, sets the S flag to "1", then performs branch processing. Then, the microcode performs branch processing. As a result, the interrupt processing program defined by the user application program is executed next. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 69 CHAPTER 3 INTERRUPTS 3.5 Hardware Interrupts 3.5.2 MB90860E Series Occurrence and Release of Hardware Interrupt Figure 3.5-1 illustrates the flow from the occurrence of a hardware interrupt until there is no interrupt request in the interrupt processing program. ■ Occurrence and Release of Hardware Interrupt Figure 3.5-1 Flow from Occurrence to Release of Hardware Interrupt Register file Microcode F2MC-16LX bus I PS IR ILM Check (5) F2MC-16LX CPU Comparator (1) PS I ILM IR : Processor status : Interrupt enable flag : Interrupt level mask : Instruction register Enabling FF AND (7) Source FF (1) (2) Interrupt level (IL) Peripheral Level comparator (3) Interrupt controller (1) An interrupt source is generated in a peripheral. (2) The interrupt enable bit in the peripheral is referenced. If an interrupt is enabled, the peripheral issues an interrupt request to the interrupt controller. (3) Upon reception of the interrupt request, the interrupt controller determines the priority levels of simultaneously requested interrupts. Then, the interrupt controller transfers the interrupt level of the corresponding interrupt to the CPU. (4) The CPU compares the interrupt level (IL) requested by the interrupt controller with the interrupt level mask (ILM) of the processor status (PS). (5) If the comparison shows that the requested level is higher than the current interrupt processing level, the interrupt enable flag (I) value of the processor status (PS) is checked. (6) If the check in step (5) shows that the I flag indicates interrupt enable status, the requested level is written to the ILM. Interrupt processing is performed as soon as the currently executing instruction is completed, then control is transferred to the interrupt processing routine. (7) When the interrupt source of step (1) is cleared by software in the user interrupt processing routine, the interrupt request is completed. The time required for the CPU to execute the interrupt processing in steps (6) and (7) is shown below. For the cycle count correction values, see Table 3.5-1. Interrupt start : 24 + 6 × cycle count correction value Interrupt return : 15 + 6 × cycle count correction value (RETI instruction) 70 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.5 Hardware Interrupts MB90860E Series Table 3.5-1 Correction Values for Interrupt Processing Cycle Count Address indicated by the stack pointer CM44-10144-4E Correction value [cycle] External 8-bit +4 External even-numbered address +1 External odd-numbered address +4 Internal even-numbered address 0 Internal odd-numbered address +2 FUJITSU SEMICONDUCTOR LIMITED 71 CHAPTER 3 INTERRUPTS 3.5 Hardware Interrupts 3.5.3 MB90860E Series Multiple Interrupts As a special case, no hardware interrupt request can be accepted while data is being written to the I/O area. This is intended to prevent the CPU from causing an interruptrelated malfunction due to an interrupt request issued while an interrupt control register for a peripheral is being updated. If an interrupt occurs during interrupt processing, a higher level interrupt is processed first. ■ Multiple Interrupts The F2MC-16LX CPU supports multiple interrupts. If an interrupt of a higher level occurs while another interrupt is being processed, control is transferred to the high-level interrupt after the currently executing instruction is completed. After processing of the high-level interrupt is completed, the original interrupt processing is resumed. An interrupt of the same or lower level may be generated while another interrupt is being processed. If this happens, the new interrupt request is suspended until the current interrupt processing is completed, unless the interrupt level mask (ILM) or interrupt enable flag (I) value is changed by an instruction. The extended intelligent I/O service cannot be activated from multiple sources: while an extended intelligent I/O service is being processed; all other interrupt requests or extended intelligent I/O service requests are suspended. Figure 3.5-2 shows the order of the registers saved in the stack. Figure 3.5-2 Registers Saved in Stack Word (16 bits) MSB LSB "H" SSP (SSP value before interrupt) AH AL DPR ADB DTB PCB PC PS SSP (SSP value after interrupt) "L" 72 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.6 Software Interrupts MB90860E Series 3.6 Software Interrupts In response to execution of a special instruction, control is transferred from the program currently executed by the CPU to the interrupt processing program defined by the user. A software interrupt occurs whenever the software interrupt instruction is executed. ■ Software Interrupts The CPU performs the following processing when a software interrupt occurs: • Saves the values in the PC, PS, AH, AL, PCB, DTB, ADB, and DPR registers of the CPU to the system stack. • The interrupt enable flag (I) of the processor status (PS) is set to "1". Interrupts are automatically disabled. • Fetches the corresponding interrupt vector value and branches to the address indicated by the interrupt vector. A software interrupt request issued by the INT instruction has no interrupt request or enable flag. A software interrupt request is always issued by executing the INT instruction. The INT instruction does not have an interrupt level. Therefore, the INT instruction does not update interrupt level mask (ILM). The INT instruction sets the interrupt enable flag (I) to "0" to suspend subsequent interrupt requests. Software interrupts are handled within the CPU. ■ List of Interrupt Vectors About the interrupt vector table of this series, see the appendix. As shown in the interrupt vector table, software interrupts share the same interrupt vector area with hardware interrupts. For example, interrupt request number INT 12 is used for external hardware interrupt as well as for INT #12 of a software interrupt. Therefore, the external interrupt and INT #12 call the same interrupt processing routine. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 73 CHAPTER 3 INTERRUPTS 3.6 Software Interrupts MB90860E Series ■ Software Interrupt Operation When the CPU fetches and executes the software interrupt instruction, the software interrupt processing microcode is activated. The software interrupt processing saves 12 bytes (PS, PC, PCB, DTB, ADB, DPR, AH, and AL) to the memory area indicated by SSB and SSP. The microcode fetches 3 bytes of interrupt vector and loads them onto PC and PCB, resets the I flag to "0", sets the S flag to "1", then performs branch processing. As a result, the interrupt processing program defined by the user application program is executed next. Figure 3.6-1 illustrates the flow from the occurrence of a software interrupt until there is no interrupt request in the interrupt processing program. Figure 3.6-1 Flow from Occurrence to Release of Software Interrupt F2MC-16LX bus Register file (2) Microcode F2MC-16LX CPU (1) I PS S B unit IR Queue Fetch PS I S IR B unit : Processor status : Interrupt enable flag : Stack flag : Instruction register : Bus interface unit Save Instruction bus RAM (1) The software interrupt instruction is executed. (2) Dedicated CPU registers in the register file are saved according to the microcode corresponding to the software interrupt instruction. (3) The interrupt processing is completed with the RETI instruction in the user interrupt processing routine. ■ Other Information When the program counter bank register (PCB) is FFH, the CALLV instruction vector area overlaps the table of the "INT #vct8" instruction. When designing software, the CALLV instruction does not use the same address as that of the "INT #vct8" instruction. 74 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.7 Extended Intelligent I/O Service (EI2OS) MB90860E Series 3.7 Extended Intelligent I/O Service (EI2OS) The extended intelligent I/O service (EI2OS) is a type of hardware instruction operations, and automatically transfers data between I/O and memory. An interrupt processing program was conventionally used for such processing, but EI2OS enables data transfer to be performed like DMA (direct memory access). ■ Extended Intelligent I/O Service (EI2OS) EI2OS has the following advantages over the conventional method: • The program size can be reduced because it is not necessary to write a transfer program. • High transfer speed is enabled by eliminating the need for saving register as no internal register is used for transfer. • Transfer can be terminated by I/O, when required, preventing unnecessary data from being transferred. • The buffer address may either be incremented or left unupdated. • The I/O register address may either be incremented or left unupdated (when update is available for the buffer address). At the end of EI2OS, processing automatically branches to an interrupt processing routine after the end condition is set. Thus, the user can identify the type of the end condition. To implement EI2OS, the hardware is distributed in two blocks. Each block has the following registers and descriptors. ● Interrupt control register: Exists in the interrupt controller and indicates the extended intelligent I/O service descriptor (ISD) address. ● Extended intelligent I/O service descriptor Exists in RAM and holds the transfer mode, I/O address, number of transfers, and buffer address. Note: When REALOS is used, the extended intelligent I/O service (EI2OS) cannot be used. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 75 CHAPTER 3 INTERRUPTS 3.7 Extended Intelligent I/O Service (EI2OS) MB90860E Series Figure 3.7-1 shows the overview of the extended intelligent I/O service. Figure 3.7-1 Overview of Extended Intelligent I/O Service Memory space by IOA CPU I/O register ··············· I/O register Peripheral Interrupt request (1) (3) (3) ISD by ICS (2) Interrupt control register Interrupt controller by BAP (4) Buffer by DCT BAP : Buffer address pointer IOA : I/O register address pointer ICS : Extended intelligent I/O service channel select bits DCT : Data counter (1) I/O requests transfer. (2) The interrupt controller selects the descriptor. (3) Transfer source/destination is read from the descriptor. (4) Data is transferred between I/O and memory. Notes: • The area that can be specified by IOA is between 000000H and 00FFFFH. • The area that can be specified by BAP is between 000000H and FFFFFFH. • The maximum transfer count that can be specified by DCT is 65,536. ■ Structure of Extended Intelligent I/O Service (EI2OS) EI2OS is handled by the following four sections: • Peripheral resources : Interrupt request flag bits, and interrupt request enable bits: Controls interrupt requests from peripherals • Interrupt controller : ICR:Assigns interrupt levels, determines the priority levels of simultaneously requested interrupts, and selects the EI2OS operation. 76 • CPU: I and ILM : Used to compare the requested and current interrupt levels and to identify the interrupt enable status. • RAM: Descriptor : Describes the EI2OS transfer information. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.7 Extended Intelligent I/O Service (EI2OS) MB90860E Series 3.7.1 Extended Intelligent I/O Service Descriptor (ISD) The extended intelligent I/O service descriptor exists between 000100H and 00017FH in internal RAM, and consists of the following items: • Data counter • I/O register address pointer • Status data • Buffer address pointer ■ Extended Intelligent I/O Service Descriptor (ISD) Figure 3.7-2 shows the configuration of the extended intelligent I/O service descriptor. Figure 3.7-2 Configuration of Extended Intelligent I/O Service Descriptor "H" Upper 8 bits of data counter (DCTH) 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) EI2OS status (ISCS) Upper 8 bits of buffer address pointer (BAPH) Middle 8 bits of buffer address pointer (BAPM) 000100H + 8 x ICS ISD starting address Lower 8 bits of buffer address pointer (BAPL) "L" ■ Data Counter (DCT) This is a 16-bit register that works as a counter corresponding to the number of data items transferred. This counter is decremented by 1 after data transfer. EI2OS is completed when the counter is set to 0000H. Figure 3.7-3 shows the configuration of the data counter. Figure 3.7-3 Configuration of Data Counter bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 DCT B15 B14 B13 B12 B11 B10 B09 B08 B07 B06 B05 B04 B03 B02 B01 B00 (Undefined at a reset) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 77 CHAPTER 3 INTERRUPTS 3.7 Extended Intelligent I/O Service (EI2OS) MB90860E Series ■ I/O Register Address Pointer (IOA) This is a 16-bit register that indicates the lower address (A15 to A00) of the buffer and I/O register used for data transfer. All of upper addresses (A23 to A16) are "0", and any I/O between addresses 000000H and 00FFFFH can be specified. Figure 3.7-4 shows the configuration of the I/O register address pointer. Figure 3.7-4 Configuration of the I/O Register Address Pointer bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 IOA A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00 (Undefined at a reset) ■ Buffer Address Pointer (BAP) This 24-bit register holds the address used for the next EI2OS transfer. BAP exists for each EI2OS channel independently. Therefore, each EI2OS channel can be used for transfer with anywhere in the 16Mbyte space. If the BF bit of ISCS is set to "0" (update enabled), only the lower 16 bits of BAP changes and BAPH does not change. ■ EI2OS Status Register (ISCS) This 8-bit register indicates whether the buffer address pointer or I/O register address pointer is updated or fixed. It also indicates the transfer data length (byte/word) and transfer direction of the buffer address pointer and the I/O register address pointer. Figure 3.7-5 shows the configuration of the ISCS. Always write "0" to bit7 to bit5 of ISCS. Figure 3.7-5 Configuration of ISCS bit 7 6 5 Reserved Reserved Reserved 4 3 2 1 0 IF BW BF DIR SE ISCS (Undefined at a reset) Each bit is explained as follows. [bit4] IF: IOA update/fix selection bit This bit determines whether the I/O register address pointer is to be updated or fixed. 0: The I/O register address pointer is updated (incremented) after data transfer. 1: The I/O register address pointer is fixed after data transfer. Note: Only update (increment) is allowed. [bit3] BW: Transfer data length specification bit This bit specifies the transfer data length. 0: Byte 1: Word 78 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.7 Extended Intelligent I/O Service (EI2OS) MB90860E Series [bit2] BF: BAP update/fix selection bit This bit specifies whether the buffer address pointer is updated or fixed. 0: The buffer address pointer is updated (incremented) after data transfer. 1: The buffer address pointer is fixed after data transfer. Note: Only the lower 16 bits of the buffer address pointer are updated. [bit1] DIR: Data transfer direction bit This bit specifies the data transfer direction. 0: I/O register address pointer → Buffer address pointer 1: Buffer address pointer → I/O register address pointer [bit0] SE: EI2OS completion control bit This bit controls the termination of the extended intelligent I/O service based on requests from internal peripherals. 0: The service is not terminated by a peripheral request. 1: The service is terminated by a peripheral request. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 79 CHAPTER 3 INTERRUPTS 3.8 Operation Flow of Extended Intelligent I/O Service (EI2OS) and its Application Procedure 3.8 MB90860E Series Operation Flow of Extended Intelligent I/O Service (EI2OS) and its Application Procedure Figure 3.8-1 illustrates the operation flow of the extended intelligent I/O service (EI2OS) and Figure 3.8-2 shows its application procedure. ■ Operation Flow of Extended Intelligent I/O Service (EI2OS) Figure 3.8-1 Operation Flow of Extended Intelligent I/O Service (EI2OS) Interrupt request issued from internal peripheral ISE = 1 BAP NO YES Interrupt sequence Reading ISD/ISCS YES End request from a peripheral NO DIR = 1 : Buffer address pointer : I/O register address pointer : EI2OS descriptor ISCS : EI2OS status DCT : Data counter ISE : EI2OS enable bits S1, S0 : EI2OS end status bits IOA ISD SE = 1 YES NO Register indicated by IOA (Data transfer) Memory indicated by BAP IF = 0 Memory transferred by BAP (Data transfer) Register indicated by IOA YES NO BF = 0 Update value depending on BW Updating IOA Update value depending on BW Updating BAP YES NO Decrementing DCT DCT = 00B NO Setting S1 and S0 to 00B 80 YES Setting S1 and S0 to 01B Setting S1 and S0 to 11B Clearing peripheral interrupt request Clearing ISE to "0" CPU operation return Interrupt sequence FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 3 INTERRUPTS 3.8 Operation Flow of Extended Intelligent I/O Service (EI2OS) and its Application Procedure Figure 3.8-2 Application Procedure Flow of Extended Intelligent I/O Service (EI2OS) Processing by EI2OS Processing by CPU EI2OS initialization JOB execution (Interrupt request) Normal termination AND(ISE=1) Data transfer Interrupt occurs due to count end or termination request from peripheral Setting extended intelligent I/O service (Switching channels) Processing data in buffer The extended EI2OS execution time for each flow is described below. ● When data transfer continues (when the stop condition is not satisfied) (Table 3.8-1 + Table 3.8-2) machine cycle ● When a stop request is issued from a peripheral (36 + 6 × Table 3.8-3) machine cycle ● When the counting is completed (Table 3.8-1 + Table 3.8-2 + (21 + 6 × Table 3.8-3)) machine cycle Table 3.8-1 Execution Time when EI2OS Continues ISCS: SE bit Set to "0" I/O register address pointer Set to "1" Fixed Updated Fixed Updated Fixed 32 34 33 35 Updated 34 36 35 37 Buffer address pointer Table 3.8-2 Data Transfer Correction Values for EI2OS Execution Time Internal access I/O register address pointer Buffer address pointer B/E O B/E 0 +2 O +2 +4 Internal access B : Byte data transfer E : Even-numbered address word transfer O : Odd-numbered address word transfer CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 81 CHAPTER 3 INTERRUPTS 3.8 Operation Flow of Extended Intelligent I/O Service (EI2OS) and its Application Procedure Table 3.8-3 Correction Values for Interrupt Handling Times Address indicated by the stack pointer 82 MB90860E Series Correction value [cycle] External 8-bit +4 External even-numbered address +1 External odd-numbered address +4 Internal even-numbered address 0 Internal odd-numbered address +2 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 3 INTERRUPTS 3.9 Exceptions MB90860E Series 3.9 Exceptions The F2MC-16LX performs exception processing when the following events occur. ■ Execution of an Undefined Instruction Exception processing is fundamentally the same as interrupt processing. When an exception is detected between instructions, exception processing is performed separately from ordinary processing. In general, exception processing is performed as a result of an unexpected operation. Therefore, use exception processing only for debugging or for activating emergency recovery software. ■ Exception Due to Execution of an Undefined Instruction 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 performed. Specifically, the AL, AH, DPR, DTB, ADB, PCB, PC, and PS values are saved into the system stack first, then the interrupt enable flag (I) is set to "0", the stack flag (S) is set to "1", and processing branches to the routine indicated by the vector with the interrupt number 10. The PC value saved in the stack is the address at which the undefined instruction is stored. For an instruction code of 2 bytes or more, the saved value is the address at which the code identified as undefined is stored. Processing can be restored by the RETI instruction, but is of no use, however, because the same exception occurs again. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 83 CHAPTER 3 INTERRUPTS 3.9 Exceptions 84 MB90860E Series FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC This chapter describes the functions and operations of the μDMAC. The μDMAC is the simplified DMA having functions equivalent to the extended intelligent I/O service (EI2OS). 4.1 Overview of μDMAC 4.2 Registers of μDMAC 4.3 DMA Descriptor Window Register (DDWR) 4.4 Operations of μDMAC 4.5 Notes on Using μDMAC Code: CM44-00108-1E Page: 90, 93, 105 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 85 CHAPTER 4 μDMAC 4.1 Overview of μDMAC 4.1 MB90340E Series Overview of μDMAC Provided with a descriptor register, μDMAC can transfer data faster than EI2OS. ■ Overview of μDMAC μDMAC has the following functions: • Data is automatically transferred between a peripheral (I/O) and memory. • The execution of a program by the CPU is stopped while DMA is running. • The watchdog timer operates during DMA transfer. • There are 16 DMA transfer channels available (The channel with the smallest channel number has the highest priority for DMA transfer.) • Increment or no increment option can be selected for the transfer source and destination addresses. • DMA transfer is activated by an interrupt source from a peripheral (I/O). • DMA transfer is controlled by (a) DMA enable register (DER), (b) DMA stop status register (DSSR), (c) DMA status register (DSR), (d) DMA descriptor channel specification register (DCSR), and (e) Descriptor (DMACS). • STOP request can be used as a method for stopping DMA transfer from a peripheral. • Upon completion of DMA transfer, a flag is set in the corresponding bit of the DMA status register (DSR) and an interrupt is output to the interrupt controller. 86 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.2 Registers of μDMAC MB90340E Series 4.2 Registers of μDMAC μDMAC has 4 registers: DCSR, DSR, DSSR, and DER. This section describes the DMA descriptors used for DMA transfer setting. ■ List of Registers • DMA Descriptor Channel Specification Register (DCSR) bit Address 00009BH 15 14 13 12 11 STPctrl Reserved Reserved Reserved DCSR3 R/W R/W 10 9 8 DCSR2 DCSR1 DCSR0 R/W R/W R/W R/W R/W R/W Initial value 00000000B R/W: Readable/Writable • DMA status register (DSR) bit Address 00009DH bit Address 00009CH 15 14 13 12 11 10 9 8 DSRH DTE15 DTE14 DTE13 DTE12 DTE11 DTE10 DTE9 DTE8 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B 7 6 5 4 3 2 1 0 DSRL DTE7 DTE6 DTE5 DTE4 DTE3 DTE2 DTE1 DTE0 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B R/W: Readable/Writable • DMA Stop Status Register (DSSR) bit Address 0000A4H bit Address 0000A4H 7 6 5 4 3 2 1 0 DSSR STP15 STP14 STP13 STP12 STP11 STP10 STP9 STP8 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B 7 6 5 4 3 2 1 0 DSSR STP7 STP6 STP5 STP4 STP3 STP2 STP1 STP0 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B R/W: Readable/Writable Note: DSSR uses STP8 to STP15 when the STPctrl bit in DCSR is set to "0", and uses STP0 to STP7 when it is set to "1". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 87 CHAPTER 4 μDMAC 4.2 Registers of μDMAC MB90340E Series • DMA Enable Register (DER) bit Address 0000ADH bit Address 0000ACH 15 14 13 12 11 10 9 8 DERH EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 Initial value 00000000B R/W R/W R/W R/W R/W R/W R/W R/W 7 6 5 4 3 2 1 0 DERL EN7 EN6 EN5 EN4 EN3 EN2 EN1 EN0 Initial value 00000000B R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/Writable 88 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.2 Registers of μDMAC MB90340E Series 4.2.1 DMA Descriptor Channel Specification Register (DCSR) The DMA descriptor channel specification register (DCSR) switches the descriptor between channels. Use this register to specify a channel and then set the descriptor. ■ DMA Descriptor Channel Specification Register (DCSR) Address bit 15 00009BH 14 13 12 11 STPctrl Reserved Reserved Reserved DCSR3 R/W R/W R/W R/W R/W 10 9 8 DCSR2 DCSR1 DCSR0 R/W R/W R/W Initial value 00000000B R/W: Readable/Writable [bit15] STPctrl (STP control bit) STPctrl bit Functions 0 [Initial value] Selects STP8 to STP15 as DSSR. 1 Selects STP0 to STP7 as DSSR. [bit14 to bit12] Reserved (reserved bits) Reading the bits always returns "0". Always write "0" to these bits. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 89 CHAPTER 4 μDMAC 4.2 Registers of μDMAC MB90340E Series [bit11 to bit8] DCSR3 to DCSR0 (DMA descriptor channel specification bits) Table 4.2-1 Relationship between DCSR and Selected Channel DCSR3 to DCSR0 Selected channel Peripheral interrupt request 0000B 0 16-bit reload timer 0 0001B 1 16-bit reload timer 1 0010B 2 16-bit reload timer 2 0011B 3 External interrupt 0 to 3, 8 to 11 0100B 4 External interrupt 4 to 7, 12 to 15 0101B 5 A/D converter 0110B 6 Input capture 4/5, I2C1 0111B 7 Output compare 0/1/4/5 1000B 8 Input capture 0 to 3 1001B 9 Output compare 2/3/6/7 1010B 10 UART0 RX 1011B 11 UART0 TX 1100B 12 UART1 RX, UART3 RX 1101B 13 UART1 TX, UART3 TX 1110B 14 UART2 RX, UART4 RX 1111B 15 UART2 TX, UART4 TX Note: Based on the DCSR setting, the descriptor channel is selected from the 16 channels. For details, see "4.3 DMA Descriptor Window Register (DDWR)". 90 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.2 Registers of μDMAC MB90340E Series 4.2.2 DMA Status Register (DSR) The DMA status register (DSR) indicates that DMA transfer is completed. When "1" is set in this register, an interrupt occurs simultaneously. ■ DMA Status Register (DSR) Address bit 15 00009DH Address 14 13 12 11 10 9 8 DSRH DTE15 DTE14 DTE13 DTE12 DTE11 DTE10 DTE9 DTE8 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B 6 5 4 3 2 1 0 DSRL DTE7 DTE6 DTE5 DTE4 DTE3 DTE2 DTE1 DTE0 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B bit 7 00009CH R/W: Readable/Writable [bit15 to bit0] DTE15 to DTE0 (DMA status bits) DTEx bit 0 [Initial value] 1 Functions No interrupt has occurred due to completion of DMA transfer. When DTEx are "0", always write "0" to these bits. This indicates that DMA transfer is completed and an interrupt is being requested. The bits cannot be set to "1" when DMA transfer is stopped by a STOP request, except for the final transfer. When DTEx are "1", writing "0" to these bits clears them to "0", and writing "1" retains the previous data. Note: To write to DSR, use a read-modify-write (RMW) instruction. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 91 CHAPTER 4 μDMAC 4.2 Registers of μDMAC 4.2.3 MB90340E Series DMA Stop Status Register (DSSR) The DMA stop status register (DSSR) indicates that DMA transfer has been stopped by a STOP request. The meaning of the bit indicated in this register varies depending on the STPctrl bit in the DMA descriptor channel specification register (DCSR). ■ DMA Stop Status Register (DSSR) When DCSR:STPctrl bit = 0 Address bit 7 0000A4H 6 5 4 3 2 1 0 STP15 STP14 STP13 STP12 STP11 STP10 STP9 STP8 R/W R/W R/W R/W R/W R/W R/W R/W 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 Initial value 00000000B When DCSR:STPctrl bit = 1 Address bit 7 0000A4H Initial value 00000000B R/W: Readable/Writable [bit7 to bit0] STP15 to STP0 (DMA stop status bits) STPx bit Functions 0 [Initial value] A STOP request has not been accepted from a peripheral during DMA transfer. When STPx = 0, always write "0". 1 This indicates that DMA transfer has stopped upon reception of a STOP request from a peripheral during the DMA transfer. Note however that when a STOP request is accepted at the final transfer, STPx bits are not set to "1". When the SE bit in the DMA control register is set to "1" and a STOP request is accepted for the corresponding channel, the corresponding bit of the DMA enable register is cleared to "0". When STPx = "1", writing "0" clears them to "0" and writing "1" retains the previous data. Note: To write to DSSR, use a read-modify-write (RMW) instruction. 92 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.2 Registers of μDMAC MB90340E Series The following 3 channels support the STOP request Channel Corresponding STPx bit Peripherals ch.10 STP10 UART0 RX ch.12 STP12 UART1 RX, UART3 RX ch.14 STP14 UART2 RX, UART4 RX Bits other than STP10, STP12 and STP14 have no meaning. Note: DSSR is controlled by the highest bit (STPctrl) of DCSR. When STPctrl is "0", STP8 to STP15 are selected as DSSR. When STPctrl is "1", STP0 to STP7 are selected as DSSR. As the initial value of STPctrl is "0", STP8 to STP15 are originally selected. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 93 CHAPTER 4 μDMAC 4.2 Registers of μDMAC 4.2.4 MB90340E Series DMA Enable Register (DER) The DMA enable register (DER) enables DMA transfer. When "1" is set in this register and an interrupt request occurs at the corresponding channel, it is regarded as a DMA transfer request and DMA transfer starts. ■ DMA Enable Register (DER) Address bit 15 0000ADH Address 14 13 12 11 10 9 8 DERH EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B 6 5 4 3 2 1 0 DERL EN7 EN6 EN5 EN4 EN3 EN2 EN1 EN0 R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B bit 7 0000ACH R/W: Readable/Writable [bit15 to bit0] EN15 to EN0: (DMA enable bits) ENx bit 0 [Initial value] 1 Functions DMA transfer is not executed. An interrupt request from a peripheral is handled as a DMA start request and the interrupt request is output to the interrupt controller upon completion of the DMA transfer. Cleared to "0" when there is no more DMA transfer, or when DMA transfer is stopped by a STOP request from the peripheral. Note: To write to DER, use a read-modify-write (RMW) instruction. 94 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.3 DMA Descriptor Window Register (DDWR) MB90340E Series 4.3 DMA Descriptor Window Register (DDWR) The DMA descriptor consists of 16 channels of 8 bytes and is used to set DMA transfer. Out of the 16 channels, one specified channel is mapped to the DMA descriptor window register (DDWR) and can be accessed. The DDWR addresses are 0000D0H to 0000D7H. ■ Configuration of DMA Descriptor Window Register (DDWR) The DMA descriptor consists of 16 channels of 8 bytes, and each channel is structured as illustrated in Figure 4.3-1. The descriptor of the channel selected by the DMA descriptor channel specification register (DCSR) or the interrupt request channel number is mapped to the DMA descriptor window register (DDWR). For the relationship between the DMA descriptor channel specification register (DCSR) and the selected channel, see Table 4.2-1. Figure 4.3-1 Configuration of DMA Descriptor Window Register (DDWR) Address 0000D7H Upper 8 bits of data counter (DCTH) 0000D6H Lower 8 bits of data counter (DCTL) 0000D5H Upper 8 bits of I/O register address pointer (IOAH) 0000D4H Lower 8 bits of I/O register address pointer (IOAL) 0000D3H DMA Control Register (DMACS) 0000D2H Upper 8 bits of buffer address pointer (BAPH) 0000D1H Middle 8 bits of buffer address pointer (BAPM) 0000D0H Lower 8 bits of buffer address pointer (BAPL) ■ Registers of DMA Descriptor The registers that form the DMA descriptor are explained on the following pages. The initial value of each register is undefined at a reset. Therefore, always initialize it before setting ENx to "1". Note: When the channel descriptor is switched by the DMA descriptor channel specification register (DCSR), the DMA descriptor window register (DDWR) is not allowed to be accessed during 2 machine cycles. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 95 CHAPTER 4 μDMAC 4.3 DMA Descriptor Window Register (DDWR) 4.3.1 MB90340E Series Data Counter (DCT) The data counter (DCT) is a register that sets the number of data transfers. When the data counter (DCT) is set to 0000H, the DMA transfer is completed. ■ Data Counter (DCT) The data counter (DCT) is a 16-bit register that corresponds to the number of transfers. After the transfer of each data item, the counter decrements (decreases) the values by 1, regardless of whether it is a word or byte transfer. The DMA transfer is terminated when this counter reaches "0". Figure 4.3-2 shows the configuration of the data counter (DCT). Setting 0000H in DCT sets the maximum number of data transfers (65536). Figure 4.3-2 Data Counter (DCT) Address 0000D7H /0000D6H bit 15 DCT 14 13 DCTH 12 11 DCTL 10 9 8 7 6 5 4 3 2 1 0 B15 B14 B13 B12 B11 B10 B09 B08 B07 B06 B05 B04 B03 B02 B01 B00 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 Initial value XXXXXXXXXXXXXXXXB R/W : Readable/writable X : Undefined ■ Setting Value of Data Counter (DCT) The relationship between the number of transfer bytes and the data counter (DCT) is as follows. DMACS DCT BW bit BYTEL bit 0 — N 1 0 N/2 1 1 (N+1)/2 N: Number of transfer bytes 96 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.3 DMA Descriptor Window Register (DDWR) MB90340E Series 4.3.2 I/O Register Address Pointer (IOA) The I/O register address pointer (IOA) sets the I/O address pointer. The upper bits of the address (A23 to A16) are fixed to 00H. ■ I/O Register Address Pointer (IOA) The I/O register address pointer (IOA) is a 16-bit register that indicates the lower 16 bits (A15 to A00) of the I/O register address. All of upper addresses (A23 to A16) are "0", and any I/O between addresses 000000H and 00FFFFH can be specified. When the IF bit (IOA update/fixing selection bit) in the DMA control register (DMACS) is set to "perform update", IOA is updated by "+1" for a byte transfer, and by "+2" for a word transfer. When the IF bit is set to "perform no update", IOA is fixed. Figure 4.3-3 shows the configuration of the I/O register address pointer (IOA). Figure 4.3-3 Configuration of the I/O Register Address Pointer (IOA) Address 0000D5H /0000D4H bit 15 IOA 14 13 IOAH 12 11 IOAL 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 Initial value 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 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 97 CHAPTER 4 μDMAC 4.3 DMA Descriptor Window Register (DDWR) 4.3.3 MB90340E Series DMA Control Register (DMACS) The DMA control register (DMACS) controls DMA transfers. The DMA control register (DMACS) can be used to control the following: • Direction control (IOA → BAP, BAP → IOA) • Transfer bit length (byte, word) • Address update (enabled, disabled) • Transfer interval • Odd-numbered byte control during word transfer ■ DMA Control Register (DMACS) The DMA control register (DMACS) is an 8-bit register that updates or fixes the buffer address pointer and the I/O register address pointer. It also indicates the transfer data length (byte/word), specifies the transfer direction and byte transfer option, and gives a wait indication. Figure 4.3-4 shows the configuration of the DMA control register (DMACS). 98 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.3 DMA Descriptor Window Register (DDWR) MB90340E Series Figure 4.3-4 Configuration of DMA Control Register (DMACS) 7 bit Address RDY2 0000D3H R/W 6 5 4 3 2 1 0 RDY1 BYTEL IF BW BF DIR SE R/W R/W R/W R/W R/W R/W R/W SE Initial value XXXXXXXXB DMA transfer end control bit 0 Does not end transfer by request from peripheral function 1 Ends transfer by request from peripheral function DIR Data transfer direction specification bit 0 I/O register address pointer → Buffer address pointer 1 Buffer address pointer → I/O register address pointer BF BAP update/fixing selection bit 0 Updates buffer address pointer after data transfer 1 Does not update buffer address pointer after data transfer BW Transfer data length specification bit 0 Byte 1 Word IF IOA update/fixing selection bit 0 Updates I/O register address pointer after data transfer 1 Does not update I/O register address pointer after data transfer BYTEL Byte transfer specification bit (Only valid for word transfer) 0 Even-numbered byte 1 Odd-numbered byte Wait bits(See (SeeFigure Figure3.9-6) 4.3-5) Wait indication indication bits RDY2 RDY1 R/W: Readable/writable X: Undefined 0 0 Does not place a wait between transfers 0 1 Place 1 cycle of wait between transfers 1 0 Place 2 cycles of wait between transfers 1 1 Place 3 cycles of wait between transfers Figure 4.3-5 Explanation of Wait Indication Bits Reading transfer source Writing transfer destination Wait Reading transfer source Writing transfer destination RDY2 and RDY1 are used to define the length of the waiting part of transfer as shown in the above figure. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 99 CHAPTER 4 μDMAC 4.3 DMA Descriptor Window Register (DDWR) 4.3.4 MB90340E Series DMA Buffer Address Pointer (BAP) The DMA buffer address pointer (BAP) is a register that sets the buffer address pointer. A23 to A00 can be set to the DMA buffer address pointer (BAP). ■ DMA Buffer Address Pointer (BAP) The DMA buffer address pointer (BAP) is a 24-bit register that stores the address used for DMA transfer. As BAP exists independently, corresponding to separate DMA channels, each channel of DMA can transfer data between any 16Mbyte address and I/O. When the BF bit (BAP update/fixing selection bit) in the DMA control register (DMACS) is set to "perform update", the lower 16 bits of BAP (BAPM, BAPL) are updated by "+1" for a byte transfer, and by "+2" for a word transfer. The upper 8 bits (BAPH) remain unchanged. Figure 4.3-6 shows the configuration of the buffer address pointer (BAP). Figure 4.3-6 Configuration of the Buffer Address Pointer (BAP) Address : 0000D2H /0000D1H /0000D0H bit23 BAP to bit16 bit15 to bit8 bit7 BAPH BAPM R/W R/W to BAPL bit0 Initial value XXXXXXH R/W R/W: Readable/writable X: Undefined Notes: • The I/O register address pointer (IOA) can specify the area from "000000H" to "00FFFFH". • The area that can be specified by the buffer address pointer (BAP) is between 000000H and FFFFFFH. • It is prohibited to set IOA and BAP to the addresses of μDMAC internal registers (DCSR, DSRH, DSRL, DSSR, DERH and DERL), and the address of the DMA descriptor window register (DDWR). 100 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.4 Operations of μDMAC MB90340E Series 4.4 Operations of μDMAC This section explains the operation of μDMAC. ■ Operation of μDMAC Figure 4.4-1 shows a block diagram for explaining the operation of μDMAC. Note: To write to an internal register (DSRH, DSRL, DSSR, DERH, or DERL), use a read-modify-write (RMW) instruction. Figure 4.4-1 Operation of μDMAC Memory space IOA I/O register Peripheral function (I/O) I/O register (4) (a) Descriptor RAM (1) (2) (3) DMA controller (2) DMA descriptor (4) (b) BAP Buffer CPU Interrupt controller DCT (1) A peripheral (I/O) requests DMA transfer. (2) When the DMA enable register (DER) is "1", DMAC reads the transfer source and destination addresses of the specified channel as well as transfer data such as the number of transfers from the descriptor. (3) DMA data transfer starts between I/O and memory. (4) After 1 byte or 1 word is transferred: (a) If the transfer is not completed (data counter (DCT) ≠ 0), the peripheral will be requested to clear the DMA transfer request. (b)If the transfer is completed (data counter (DCT) = 0), a transfer end flag is set in the DMA status register upon completion of the DMA transfer, and an interrupt request is output to the interrupt controller. CM44-10144-4E IOA : I/O register address pointer DER : DMA enable register BAP: Buffer address pointer DCT : Data counter FUJITSU SEMICONDUCTOR LIMITED 101 CHAPTER 4 μDMAC 4.4 Operations of μDMAC MB90340E Series ■ μDMAC Application Procedure Figure 4.4-2 shows the application procedure for μDMAC. Figure 4.4-2 μDMAC Application Procedure Software processing Harware processing (Interrupt occurs) Start NO Relevant channel: ENx=1 Setting of system stack area Initial setting YES YES Initial setting of peripheral function STOP request and SE=1 NO Setting of interrupt control register DMA transfer (BAP) (IOA) Initial setting of μDMAC BF = 0 NO NO IF = 0 YES Execution of user program BW = 1 YES NO BW = 1 YES BYTEL = 0 YES YES NO NO BAP = BAP+2 NO BYTEL = 0 YES DCT = 0 YES NO IOA = IOA+2 BAP = BAP+1 NO DCT = 0 YES IOA = IOA+1 NO STPx = 1 DCT = 0 YES DTEx = 1 (To interrupt routine) Interrupt processing ENx = 0 * Interrupt generation NO Another interrupt occurs YES YES NO Processing completed ENx : Relevant bit of DMA enable register DTEx: Relevant bit of DMA status register STPx : Relevant bit of DMA stop status register * : Outputting interrupt request to interrupt controller 102 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 4 μDMAC 4.4 Operations of μDMAC MB90340E Series ■ Number of Data Transfer Cycles (Internal Transfer) When μDMAC obtains the bus grant and data is transferred within the LSI, the number of transfer cycles is as follows. Table 4.4-1 Cycles from Obtaining Bus Grant until Transfer Start Match between DCSR3 to DCSR0 in DCSR and interrupt request channels Mismatch between DCSR3 to DCSR0 in DCSR and interrupt request channels 1 Machine cycle 2 Machine cycles Table 4.4-2 Transfer Cycles Address pointer DMACS Number of cycles BAP IOA BW BYTEL ⎯ ⎯ 0 ⎯ 4 + (RDY2, RDY1)*1 Machine cycle O E 1 ⎯ 6 + (RDY2, RDY1)*2 Machine cycle E O O O 1 ⎯ 8 + (RDY2, RDY1)*2 Machine cycle E E 1 ⎯ 4 + (RDY2, RDY1)*1 Machine cycle *1: RDY2, RDY1 becomes 00B at the final transfer. *2: When BYTEL is "1", the number of cycles is 4, and RDY2, RDY1 becomes 00B. When BYTEL is "0", RDY2, RDY1 becomes 00B. O : Odd-numbered address E : Even-numbered address CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 103 CHAPTER 4 μDMAC 4.4 Operations of μDMAC MB90340E Series ■ Watchdog Timer Figure 4.4-3 shows the operation of the watchdog timer during DMA transfer. A reset occurs during transfer, when the transfer exceeds the interval time of the watchdog timer set by the WT1/WT0 bits in the watchdog timer control register (WDTC). Figure 4.4-3 Watchdog Timer during DMAC Transfer Count continues Count starts Count starts Reset (1) Reset canceled WTEbit=0 WTEbit=0 μMDAC register settings DCSR : Channel selected DER : DMA enabled DDWR: DDCT = 10 The number of transfers: 10 DW=0 Byte transfer 104 (2) (3) (4) (5) (6) (7) μDMAC activated 1st transfer starts Interrupt source generated (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) 1st 1-byte transfer in progress 2nd 1-byte transfer in progress 3rd 1-byte transfer in progress 4th 1-byte transfer in progress 5th 1-byte transfer in progress 6th 1-byte transfer in progress 7th 1-byte transfer in progress 8th 1-byte transfer in progress 9th 1-byte transfer in progress 10th 1-byte transfer in progress FUJITSU SEMICONDUCTOR LIMITED (8) (9) (10) Time Jump to interrupt routine Interrupt processing executed μDMAC transfer completed To interrupt controller Interrupt request generated CM44-10144-4E MB90340E Series 4.5 Notes on Using μDMAC CHAPTER 4 μDMAC 4.5 Notes on Using μDMAC This section explains notes on the using μDMAC. ■ Changing to the Low-power Consumption Mode Please shift to the mode after setting 0000H to DMA enable register (DER) whenever shifting to stand-by mode (sleep mode, stop mode, watch mode, time-base timer mode) or (main clock intermittent operation mode, PLL clock intermittent operation mode, sub clock intermittent operation mode). ■ Use of μDMAC in LIN-UART When transfer data is written to LIN-UART using μDMAC, do not set to 00B in RDY2 and RDY1 bits of DMA control register (DMACS). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 105 CHAPTER 4 μDMAC 4.5 Notes on Using μDMAC 106 MB90340E Series FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 5 DELAY INTERRUPT This chapter describes the functions and operations of the delayed interrupt. 5.1 Overview of Delay Interrupt 5.2 Block Diagram of Delay Interrupt 5.3 Configuration of Delay Interrupt 5.4 Operating Explanation of Delay Interrupt 5.5 Precautions when Using Delay Interrupt 5.6 Program Example that uses Delay Interrupt Code: CM44-00109-3E Page: 108 CM44-10144-4E FUJITSU MICROELECTRONICS LIMITED 107 CHAPTER 5 DELAY INTERRUPT 5.1 Overview of Delay Interrupt 5.1 MB90860E Series Overview of Delay Interrupt The delay interrupt is a function to generate the hardware interruption used for the task switch such as Realtime Operating Systems. Software can generate a hardware interrupt request. ■ Overview of Delay Interrupt By using the delay interruption, a hardware interruption demand is generated, and can be released with software. Table 5.1-1 shows the overview of delay interrupt. Table 5.1-1 Overview of Delay Interrupt Function and Control 108 Interrupt source An interrupt request is generated by setting the R0 bit in the delay interrupt request generation/release register to "1" (DIRR: R0 = 1), an interrupt request is generated. An interrupt request is generated by setting the R0 bit in the delay interrupt request generation/release register to "0" (DIRR: R0 = 0), an interrupt request is generated. Interrupt No. #42 (2AH) Interrupt control Register does not enable any setting. Interrupt flag The interrupt flag is held in the R0 bit in the DIRR register. EI2OS/μDMAC It does not support the extended intelligent I/O service and DMA transfer. FUJITSU MICROELECTRONICS LIMITED CM44-10144-4E CHAPTER 5 DELAY INTERRUPT MB90860E Series 5.2 5.2 Block Diagram of Delay Interrupt Block Diagram of Delay Interrupt The delay interrupt consists of the following blocks: • Interrupt request latch • Delay Interrupt Request Generation/Release Register (DIRR) ■ Block Diagram of Delay Interrupt Figure 5.2-1 Block Diagram of Delay Interrupt Internal data bus - - - - - - - R0 Delay Interrupt Request Generation/Release Register (DIRR) S R Interrupt request signal Interrupt Request Latch − : Undefined bit ● Interrupt request latch This latch keeps the settings (delay interrupt request generation or release) of the delay interrupt request generation/release register (DIRR). ● Delay Interrupt Request Generation/Release Register (DIRR) Generates or releases a delay interrupt request. ■ Interrupt No. The interrupt number used by the delay interrupt is interrupt number #42 (2AH). CM44-10144-4E FUJITSU MICROELECTRONICS LIMITED 109 CHAPTER 5 DELAY INTERRUPT 5.3 Configuration of Delay Interrupt 5.3 MB90860E Series Configuration of Delay Interrupt This section lists registers for the delay interrupt and its details. ■ List of Registers and Initial Values Figure 5.3-1 List of Registers for Delay Interrupt and its Initial Values Delay Interrupt Request Generation/ Release register (DIRR) Address: 00009FH X 110 bit 7 6 5 4 3 2 1 0 X X X X X X X 0 : Undefined FUJITSU MICROELECTRONICS LIMITED CM44-10144-4E CHAPTER 5 DELAY INTERRUPT MB90860E Series 5.3.1 5.3 Configuration of Delay Interrupt Delay Interrupt Request Generation/Release Register (DIRR) The delay interrupt request generation/release register (DIRR) generates or releases a delay interrupt request. ■ Delay Interrupt Request Generation/Release Register (DIRR) Figure 5.3-2 Delay Interrupt Request Generation/Release Register (DIRR) Address bit 00009FH − R/W X 7 6 5 4 3 2 1 0 − − − − − − − R0 − − − − − − − R/W : Undefined bit : Readable/Writable : Undefined : Initial value Initial value XXXXXXX0B bit0 R0 Delay interrupt request generation bit 0 Releases the delay interrupt request 1 Generates the delay interrupt request Table 5.3-1 Functions of Delay Interrupt Request Generation/Release Register (DIRR) Bit name CM44-10144-4E Function bit7 to bit1 Undefined bit Read : The value is undefined. Write : No effect bit0 R0: Delay interrupt request generation bit Generates or releases a delay interrupt request. When set to "0": Releases the delay interrupt request When set to "1": Generates a delayed interrupt request FUJITSU MICROELECTRONICS LIMITED 111 CHAPTER 5 DELAY INTERRUPT 5.4 Operating Explanation of Delay Interrupt 5.4 MB90860E Series Operating Explanation of Delay Interrupt The delay interrupt has a function for generating or releasing an interrupt request by software. ■ Operating Explanation of Delay Interrupt To use the delay interrupt, the setting shown in Figure 5.4-1 is required. Figure 5.4-1 Setting for Delay Interrupt DIRR − bit7 6 5 4 3 2 1 bit0 − − − − − − − R0 : Undefined bits : Used bit An interrupt request is generated by setting the R0 bit in the delay interrupt request generation/release register to "1" (DIRR: R0 = 1). There is no enable bit for an interrupt request. ● Operation of delay interrupt generation module • When the R0 bit in the delay interrupt request generation/release register (DIRR) is set to "1", the interrupt request latch is set to "1" and an interrupt request is generated to the interrupt controller. • An interrupt request is generated to the CPU when the interrupt controller prioritizes the interrupt request over other requests. • On the CPU side, if the level of an interrupt request (ICR:IL) is higher than that of the interrupt level mask in the condition code register (CCR:ILM), the CPU generates delay interrupt processing after completion of the current instruction execution. • Within the interrupt processing, the user program sets the R0 bit to "0" to release the interrupt request and switch the task. Figure 5.4-2 shows the operation of the delay interrupt. Figure 5.4-2 Operation of Delay Interrupt Delay interrupt generation module Other request DIRR Interrupt controller ICR YY CPU IL CMP CMP ICR XX 112 ILM FUJITSU MICROELECTRONICS LIMITED Interrupt processing CM44-10144-4E CHAPTER 5 DELAY INTERRUPT MB90860E Series 5.5 5.5 Precautions when Using Delay Interrupt Precautions when Using Delay Interrupt When using the delay interrupt, take the following precautions. ■ Precautions when Using Delay Interrupt • Restart the interrupt processing when returned from interrupt processing without setting the R0 bit in the delay interrupt request generation/release register (DIRR) to "0" within an interrupt processing routine. • Unlike software interrupts, interrupts in the delay interrupt generation module are accompanied by delays. CM44-10144-4E FUJITSU MICROELECTRONICS LIMITED 113 CHAPTER 5 DELAY INTERRUPT 5.6 Program Example that uses Delay Interrupt 5.6 MB90860E Series Program Example that uses Delay Interrupt The program example that uses the delay interruption is shown. ■ Program Example of Delay Interrupt ● Processing specifications The main program writes "1" to the R0 bit in the delay interrupt request generation/release register (DIRR) to generate a delay interrupt request and performs task switching. ● Coding example ICR15 DIRR ;Interrupt control register ;Delay interrupt source generation/ ;release register DIRR_R0 EQU DIRR:0 ;Delay interrupt request generation ;bit ;---------Main program----------------------------------------------CODE CSEG START: ;Data such as stack pointer (SP) ;are supposed to be initialized AND CCR,#0BFH ;Interrupt prohibited MOV I:ICR15,#00H ;Interrupt level 0 (highest) MOV ILM,#07H ;ILM in PS set to level 7 OR CCR,#40H ;Interrupt allowed SETB I:DIRR_R0 ;Delay interrupt request generated LOOP MOV A,#00H ;Infinite loop MOV A,#01H BRA LOOP ;---------Interrupt program-----------------------------------------WARI: CLRB I:DIRR_R0 ;Interrupt request flag cleared : ; User process ; : RETI ;Returns from the interrupt CODE ENDS ;---------Vector setting--------------------------------------------VECT CSEG ABS=0FFH ORG 0FF54H ;Sets a vector for the interrupt #42 ;(2AH) VECT 114 EQU EQU 0000BFH 00009FH DSL ORG DSL DB ENDS END WARI 0FFDCH START 00H ;Reset vector set ;Setting to the single chip mode START FUJITSU MICROELECTRONICS LIMITED CM44-10144-4E CHAPTER 6 CLOCK This chapter describes the clock. 6.1 Clock 6.2 Block Diagram of the Clock Generation Block 6.3 Clock Selection Registers (CKSCR) 6.4 PLL/Sub Clock Control Register (PSCCR) 6.5 Clock Mode 6.6 Oscillation Stabilization Wait Time 6.7 Connection of the Oscillator and External Clock CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 115 CHAPTER 6 CLOCK 6.1 Clock 6.1 MB90860E Series Clock The clock generation block controls the internal clock that controls operation of the CPU and peripheral functions. The clock generated in the clock generation block is referred to as machine clock and its one cycle as machine cycle. In addition, the clock provided from a high-speed oscillator is referred as oscillation clock and the divide-bytwo frequency of the oscillation clock is referred as main clock. The divide-by-two or divide-by-four frequency of the clock that is provided from a low-speed oscillator is referred as sub clock, and a clock generated by the PLL oscillation as PLL clock. ■ Clock The clock generation block contains the oscillation circuit that generates the oscillation clock by connecting the oscillator to the oscillation pin. The oscillation clock can also be supplied by inputting an external clock to the oscillation pin. The clock generation block also contains the PLL clock multiplier circuit and it can generate 5 clocks of which frequencies are multiples of the oscillation clock frequency. The clock generation block controls the oscillation stabilization wait time and PLL clock multiplication and switching operation of the internal clock by the clock selector. ● Oscillation clock (HCLK) The oscillation clock is generated either by connecting the high-speed oscillation pins (X0, X1) to an oscillator or by inputting an external clock. ● Main clock (MCLK) The clock that has the divided-by-two frequency of the oscillation clock supplies the input clock to the time-base timer and the clock selector. ● Sub clock (SCLK) The clock generated by connecting an oscillator to the low-speed oscillation pins (X0A, X1A) or by dividing the clock, generated by inputting an external clock, by 4 or 2. The division ratio of the sub clock is set with SCDS bit in the PLL/sub clock control register (PSCCR). This clock can be used as the operating clock in the watch timer or the low-speed machine. ● PLL clock (PCLK) The PLL clock is obtained by multiplying the oscillation clock with the PLL clock multiplier circuit (PLL oscillation circuit). You can select among 5 types of clocks, depending on the setting of the multiplication rate select bits (CKSCR: CS1, CS0, PSCCR: CS2). 116 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.1 Clock MB90860E Series ● Machine clock This is the operation clock for the CPU and peripheral functions. One cycle of the machine clock is defined as a machine cycle (1/φ). A machine clock can be selected among any of the main clock, sub clock or 5 types of PLL clocks. Note: CM44-10144-4E When the operating voltage is 5 V, an oscillation clock of 3 to 16 MHz can be generated. When inputting an external clock, you can use an external clock from 3 to 24 MHz. The maximum operating frequency for the CPU and peripheral functions is 24 MHz. Therefore if the multiplier rate that exceeds the max operating frequency, devices will not operate correctly. Therefore, when inputting a 24 MHz of external clock, only 1 can be set for the multiplication rate of the PLL clock. Although the PLL oscillation can generate from 4 to 24 MHz, the oscillation range of PLL depends on the operating voltage and multiplication rate. Refer to "Data sheet" for details. FUJITSU SEMICONDUCTOR LIMITED 117 CHAPTER 6 CLOCK 6.1 Clock MB90860E Series ■ Clock Supply Map Machine clock generated in the clock generation block is supplied as the operating clock for the CPU and peripheral functions. The operation of the CPU and the peripheral functions are affected by switching between main clock and sub clock, switching the PLL clock (clock mode) and by a change in the PLL clock multiplication rate. Since some peripheral functions receive divided output from the time-base timer, a peripheral unit can select the clock best suited for this operation. Figure 6.1-1 shows the clock supply map. Figure 6.1-1 Clock Supply Map Peripheral function 4 Watch timer 4 Watchdog timer Time-base timer Clock generation block X0A Pin X1A Pin X0 Pin X1 Pin 1 2 3 4 Pin PPG0 to PPGF 16-bit reload timer 0 to 3 Pin TIN0 to TIN3 Pin TOT0 to TOT3 A/D converter (24ch) Pin AN0 to AN23 6 PLL multiplier circuit PCLK (PLL clock) Clock generation circuit 8/16-bit PPG timer 0 to F Clock selector Divide-by four/two Clock modulator (Sub clock) SCLK Clock Divide-by-two Clock selector generation HCLK MCLK φ circuit (Oscillation clock) (Main clock) (Machine clock) UART0 to 4 serial I/O Pin SCK0 to SCK4 Pin SIN0 to SIN4 Pin SOT0 to SOT4 Pin OUT0 to OUT7 Pin IN0 to IN7 Pin SDA0, SDA1 Pin SCL0, SCL1 Pin CKOT I/O timer μDMA Output compare 0 to 7 CPU Free-run timer 0 and 1 Input capture 0 to 7 I2CO, 1 HCLK : MCLK : PCLK : SCLK : φ : φC : 118 Oscillation clock Main clock PLL clock Sub clock Machine clock CAN0 to CAN2 clock Clock monitor 4 Oscillation stabilization wait control FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.2 Block Diagram of the Clock Generation Block MB90860E Series 6.2 Block Diagram of the Clock Generation Block The clock generation block consists of the following blocks: • Oscillation clock generation circuit/sub clock generation circuit • PLL multiplier circuit • Clock selector • Clock selection registers (CKSCR) • PLL/sub clock control registers (PSCCR) • Oscillation stabilization wait time selector ■ Block Diagram of the Clock Generation Block Figure 6.2-1 shows a block diagram of the clock generation block, including the standby control circuit and the time-base timer circuit. Figure 6.2-1 Block Diagram of the Clock Generation Block Low-power consumption mode control register (LPMCR) STP SLP SPL RST TMD CG1 CG0 Reserved RST Pin CPU intermittent operation cycle selector Pin high impedance control circuit Pin Hi-Z control Internal reset generation circuit Internal reset Intermittent cycle select CPU clock control circuit Reset (release) Watch, stop and sleep signals Standby control circuit 2 Watch and stop signals Peripheral Peripheral functions clock control operating clock circuit Interrupt (release) Sub clock oscillation stabilization wait release Main clock oscillation stabilization wait Clock generation block Operating clock selector Machine clock 2 CS2 PLL/Sub clock control resisters (PSCCR):bit8 Oscillation stabilization wait selector 2 PLL multiplier circuit SCM MCM WS1 WS0 SCS MCS CS1 CS0 Clock selection register (CKSCR) Divideby-two X0 Pin X1 Pin CPU operating clock Oscillation clock (HCLK) Oscillation clock oscillation circuit Sub clock (SCLK) X0A Pin Divide-byfour/divideby-two Divide- Divide- by-four Main by-512 clock Time-base timer Divideby-1024 Divideby-two Divideby-two Divideby-two Divideby-two Divideby-two Divideby-four To watchdog timer Divideby-eight Divideby-two Divideby-two Watch timer X1A Pin SCDS Sub clock oscillation circuit CM44-10144-4E PLL/sub clock control resisters (PSCCR):bit10 FUJITSU SEMICONDUCTOR LIMITED 119 CHAPTER 6 CLOCK 6.2 Block Diagram of the Clock Generation Block MB90860E Series ● Oscillation clock generation circuit The oscillation clock (HCLK) is generated either by connecting the high-speed oscillation pins to the oscillator or by inputting an external clock. ● Sub clock generation circuit The sub clock (SCLK) is generated either by connecting the low-speed oscillation pins (X0A, X1A) to an oscillator or by inputting an external clock. ● PLL multiplier circuit The PLL multiplier circuit multiplies the oscillation clock with the PLL oscillation and supplies the clock as a PLL clock (PCLK) to the clock selector. ● Clock selector It selects the clock to supply to the CPU and peripheral functions among the main clock, sub clock and 5 types of PLL clocks. ● Clock selection registers (CKSCR) The clock selection register switches the oscillation clock/PLL clock and main clock/sub clock, and selects an oscillation stabilization wait time and a PLL clock multiplication rate. ● PLL/sub clock control registers (PSCCR) This register selects the PLL clock multiplication rate (selects by the setting of CS0 and CS1 bits in the clock selection register, and setting of CS2 bit in this register) and sets the sub clock division ratio (divideby-two/divide-by-four). ● Oscillation stabilization wait time selector This selector selects an oscillation stabilization wait time. Selection is made from among 4 types of timebase timer outputs. 120 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.2 Block Diagram of the Clock Generation Block MB90860E Series 6.2.1 Register in the Clock Generation Block This section explains the register in the clock generation block. ■ List of the Register in the Clock Generation Block and Its Initial Value Figure 6.2-2 List of Clock Selection Register and Its Initial Value bit 15 14 13 12 11 10 9 8 Clock selection register (CKSCR) 1 1 1 1 1 1 0 0 PLL/sub clock control registers (PSCCR) × × × × 0 0 0 0 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 121 CHAPTER 6 CLOCK 6.3 Clock Selection Registers (CKSCR) 6.3 MB90860E Series Clock Selection Registers (CKSCR) The clock selection register (CKSCR) switches the PLL clock, main clock and sub clock, and selects an oscillation stabilization wait time and the PLL clock multiplication rate. ■ Clock Selection Registers (CKSCR) Figure 6.3-1 Clock Selection Register (CKSCR) Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 0000A1H SCM MCM WS1 WS0 SCS MCS CS1 CS0 11111100B R R bit8 Initial value R/W R/W R/W R/W R/W R/W CS2 (PSCCR register: bit8) bit9 bit8 CS2 CS1 CS0 0 0 0 1 × HCLK (4 MHz) 0 0 1 2 × HCLK (8 MHz) 0 1 0 3 × HCLK (12 MHz) 0 1 1 4 × HCLK (16 MHz) 1 1 0 6 × HCLK (24 MHz) 1 1 1 Setting disabled Multiplier selection bits The results when the oscillation clock (HCLK) frequency is 4 MHz is shown between parentheses bit10 MCS PLL clock selection bit 0 Selects PLL clock 1 Selects main clock bit11 SCS Sub clock selection bit 0 Selects sub clock 1 Selects main clock bit13 bit12 Oscillation stabilization wait time selection bits WS1 WS0 The results when the oscillation clock (HCLK) frequency is 4 MHz is shown between parentheses 0 0 210/HCLK (approx. 256 μs) 0 1 213/HCLK (approx. 2.05 ms) 1 0 217/HCLK (approx. 32.77 ms) 1 1 215/HCLK (approx. 8.19 ms; except power-on reset) 216/HCLK (approx. 16.38 ms; power-on reset only) bit14 MCM HCLK R/W R 1 Operating with main clock or sub clock bit15 : Readable/Writable SCM : Initial value 122 Operating with PLL clock : Oscillation clock : Read only PLL clock operating bit 0 Sub clock operating bit 0 Operating with sub clock 1 Operating with PLL clock or main clock FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.3 Clock Selection Registers (CKSCR) MB90860E Series Table 6.3-1 Functions of Clock Selection Register (CKSCR) (1 / 3) Bit name bit15 bit14 bit13, bit12 CM44-10144-4E Function SCM: Sub clock operation flag bit Indicates whether the main clock or sub clock has been selected as the machine clock. • When the sub clock operating flag bit (CKSCR: SCM) is "0" and the sub clock selection bit (CKSCR: SCS) is "1", it indicates that it is in the transition period from the sub clock to the main clock. On the other hand, when SCM is "1" and SCS is "0", it indicates that it is in the transition period from the main clock to the sub clock. • Writing to this bit has no effect on operation. MCM: PLL clock operating flag bit Indicates whether the main clock or PLL clock has been selected as the machine clock. • When the PLL clock operating flag bit (CKSCR: MCM) is "1" and the PLL clock selection bit (CKSCR: MCS) is "0", it indicates that it is during the PLL clock oscillation stabilization wait time. • Writing to this bit has no effect on operation. WS1, WS0: Oscillation stabilization wait time selection bits Selects the oscillation stabilization wait time of the oscillation clock when releasing the stop mode, transiting from sub clock to main clock mode, and transiting from sub clock to PLL clock mode. • Selects from among 4 types of time-base timer outputs. Returns to the initial value by resetting all. Note: An appropriate value must be set for the oscillation stabilization wait time according to the oscillator. Refer to Section "7.2 Reset Source and Oscillation Stabilization Wait Times" for details. The oscillation stabilization wait time is fixed to 214/HCLK when switching from the main clock to the PLL clock mode (when the oscillation clock frequency is 4 MHz: approx. 4.1 ms). The oscillation stabilization wait time depends on the value set in the bits when switching from the sub clock to the PLL clock mode or returning from PLL stop to PLL clock mode. Since the PLL clock oscillation stabilization wait time requires 214/HCLK or more, when switching from sub clock to PLL clock mode or transiting to PLL stop mode, set 10B or 11B for these bits. FUJITSU SEMICONDUCTOR LIMITED 123 CHAPTER 6 CLOCK 6.3 Clock Selection Registers (CKSCR) MB90860E Series Table 6.3-1 Functions of Clock Selection Register (CKSCR) (2 / 3) Bit name bit11 bit10 124 Function SCS: Sub clock selection bit MCS: PLL clock selection bit Specifies whether the main clock or sub clock to be selected as the machine clock. • When switching from the main clock to sub clock (CKSCR: SCS=1 → 0), it is switched to 1/SCLK (when the oscillation clock frequency is 32.768 kHz and divide-by-four setting: approx. 130 μs) sub clock mode, synchronizing with the sub clock. • When switching from the sub clock to main clock (CKSCR: SCS=0 → 1), it is switched to the main clock mode after the main clock oscillation stabilization wait time is generated. The time-base time will be cleared automatically. Returns to the initial value by resetting all. Notes: 1) When both MCS and SCS bits are "0", SCS is preferred, and the sub clock is selected. 2) When both sub clock selection bit (CKSCR: MCS) and PLL clock selection bit (CKSCR: SCS) are "0", the sub clock is preferred. 3) Write after switching from the main clock to sub clock (CKSCR: SCS=1 → 0), disables the time-base timer interrupt through the interrupt enable bit (TBTC: TBIE) in the time-base timer or the interrupt level mask registers (ILM: ILM2 to 0). 4) When turning on the power or releasing form the stop mode, a sub clock oscillation stabilization wait time 214/SCLK (when the oscillation clock frequency is 32.768 kHz and divide-by-four setting: approx. 2 s) is generated. Therefore, if switching from the main clock to the sub clock mode during that period, an oscillation stabilization wait time will be generated. Specifies whether the main clock or PLL clock to be selected as the machine clock. When switched from the main clock to the PLL clock (CKSCR: MCS=1→0), the PLL clock oscillation stabilization wait time is generated, and then the transition to the PLL clock mode is made. The time-base timer is cleared automatically. The oscillation stabilization wait time is fixed to 214/HCLK (when the oscillation clock frequency is 4 MHz: approx. 4.1ms) when switching from the main clock to the PLL clock mode. The oscillation stabilization wait time when switching from the sub clock to the PLL clock mode depends on the value set in the oscillation stabilization wait time selection bits (CKSCR: WS1, WS0). Returns to the initial value by resetting all. Notes: 1) When both MCS and SCS bits are "0", SCS is preferred, and the sub clock is selected. 2) Write after switching from the main clock to PLL clock (CKSCR: MCS=1 → 0), disables the time-base timer interrupt through the interrupt enable bit (TBTC: TBIE) in the time-base timer or the interrupt level mask registers (ILM: ILM2 to 0). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.3 Clock Selection Registers (CKSCR) MB90860E Series Table 6.3-1 Functions of Clock Selection Register (CKSCR) (3 / 3) Bit name Function • • • bit9, bit8 CS1, CS0: Multiplication rate selection bits These bits and CS2 bit in the PLL/Sub clock control register (PSCCR) select a multiplication rate for the PLL clock. Select from among 5 types of multiplication rates for the PLL clock. Returns to the initial value by resetting all. Settings for CS0, CS1 and CS2: CS2 CS1 CS0 PLL clock multiplication rate 0 0 0 ×1 0 0 1 ×2 0 1 0 ×3 0 1 1 ×4 1 1 0 ×6 1 1 1 Setting disabled Note: Setting CS2 to CS0 to 111B is disabled. When PSCCR: CS2 is set to "1", don't set CKSCR: CS1 and CS0 to 11B. When the PLL clock is selected (CKSCR: MCS=0), writing is controlled. When rewrite the multiplication rate, first write "1" into the PLL clock selection bit (CKSCR: MCS) temporarily, then rewrite the multiplication rate selection bits (CKSCR: CS1, CS0) and return the PLL clock selection bit (CKSCR: MCS) to "0". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 125 CHAPTER 6 CLOCK 6.4 PLL/Sub Clock Control Register (PSCCR) 6.4 MB90860E Series PLL/Sub Clock Control Register (PSCCR) PLL/sub clock control register selects the PLL multiplication rate and the sub clock division ratio. This register is write-only. The value read from this bit is always "1". ■ PLL/Sub Clock Control Register (PSCCR) Figure 6.4-1 shows the configuration of the PLL/sub clock control register (PSCCR). Table 6.4-1 describes the function of each bit in the PLL/sub clock control register (PSCCR). Figure 6.4-1 Configuration of PLL/Sub Clock Control Registers (PSCCR) Address 0000CFH 15 14 13 12 11 10 9 8 Initial value SCDS Reserved CS2 XXXX0000B W W W − − − − Reserved − − − − W bit8 CS2 0 1 Multiplier selection bits See the clock selection registers (CKSCR) bit9 Reserved bit Reserved 0 Always write "0" to this bit The value read from this bit is always "1" bit10 W : Write only X : Undefined value − : Undefined : Initial value SCDS Sub clock division selection bit 0 Divide-by-four 1 Divide-by-two bit11 Reserved bit Reserved 0 126 Always write "0" to this bit The value read from this bit is always "1" FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.4 PLL/Sub Clock Control Register (PSCCR) MB90860E Series Table 6.4-1 Function of Each Bit in PLL/Sub Clock Control Register (PSCCR) Bit name Function bit15 to bit12 Undefined These bits are not used. • Writing to these bits has no effect. • The value read from this bit is always "1". bit11 Reserved bit • • bit10 SCDS: Sub clock division selection bit Selects a division ratio for the sub clock. • When you write "0", divide-by-four is selected. • When you write "1", divide-by-two is selected. • The value read from this bit is always "1". • Initialized to "0" by all reset sources. bit9 Reserved bit • • Always write "0" to this bit. The value read from this bit is always "1". • This bit determines the multiplication rate for PLL, together with CS1 and CS0 bits in the clock selection register (CKSCR). bit8 CS2: Multiplication rate selection bit Always write "0" to this bit. The value read from this bit is always "1". CS2 CS1 CS0 PLL clock multiplication rate 0 0 0 ×1 0 0 1 ×2 0 1 0 ×3 0 1 1 ×4 1 1 0 ×6 1 1 1 Setting disabled • The value read from this bit is always "1". • Initialized to "0" by all reset sources. Note: When the MCS or MCM bit is "0", changing the setting of this bit is not allowed. Change this bit when in the main clock mode. • Setting CS2 to CS0 to 111B is disabled. When CKSCR: CS1 and CS0 are set to 11B, don't set this bit to "1". Note: CM44-10144-4E The PSCCR register is a write-only register, so the read value is different from the write value. Therefore, don't use RMW instructions, such as SETB/CLRB. FUJITSU SEMICONDUCTOR LIMITED 127 CHAPTER 6 CLOCK 6.5 Clock Mode 6.5 MB90860E Series Clock Mode There are 3 clock modes: main clock, PLL clock, and sub clock modes. ■ Clock Mode ● Main clock mode The main clock mode uses the divided-by-two oscillation clock, generated either by connecting the highspeed pins (X0, X1) to an oscillator or by inputting an external clock, as the operating clock for the CPU and peripheral functions. ● Sub clock mode The sub clock mode uses the divided-by-two or divided-by-four clock, generated either by connecting the low-speed pins (X0A, X1A) to an oscillator or by inputting an external clock, as the operating clock for the CPU and peripheral functions. The division ratio for the sub clock can be set with SCDS bit in the PLL/sub clock control register (PSCCR). ● PLL clock mode The PLL clock mode uses the oscillation clock, multiplied by the PLL clock multiplier circuit (PLL oscillation circuit), as operating clock for the CPU and peripheral functions. The multiplication rate for PLL clock can be set with the clock selection register (CKSCR: CS1, CS0) and PLL/sub clock control register (PSCCR: CS2). ■ Transition of the Clock Mode Clock mode can make the transition to the main clock, sub clock, and PLL clock modes by setting the PLL clock selection bit (CKSCR: MCS) and the sub clock selection bit (CKSCR: SCS). ● Transition from main clock mode to PLL clock mode When rewriting the PLL clock selection bit (CKSCR: MCS) from "1" to "0", main clock is switched to PLL clock after the PLL oscillation stabilization wait time (214/HCLK) has elapsed. ● Transition from PLL clock mode to main clock mode When rewriting the PLL clock selection bit (CKSCR: MCS) from "0" to "1", PLL clock is switched to main clock at the timing (after 1 to 12 PLL clocks) the PLL and main clock edges match. ● Transition from main clock mode to sub clock mode When rewriting the sub clock selection bit (CKSCR: SCS) from "1" to "0", main clock is switched to sub clock when the sub clock edge is detected. 128 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.5 Clock Mode MB90860E Series ● Transition from sub clock mode to main clock mode When rewriting the sub clock selection bit (CKSCR: SCS) from "0" to "1", sub clock is switched to main clock after the main clock oscillation stabilization wait time has elapsed. ● Transition from PLL clock mode to sub clock mode When rewriting the sub clock selection bit (CKSCR: SCS) from "1" to "0", PLL clock is switched to sub clock. ● Transition from sub clock mode to PLL clock mode When rewriting the sub clock selection bit (CKSCR: SCS) from "0" to "1", sub clock is switched to PLL clock after the main clock oscillation stabilization wait time has elapsed. ■ Selection of PLL Clock Multiplication Rate One of 5 types of PLL clock multiplication rates (1 to 4, and 6 multiplications) can be selected by writing "000B" to "011B" and "110B" in the multiplication rate selection bits (CKSCR: CS1, CS0, PSCCR: CS2). ■ Machine Clock The PLL clock, main clock or sub clock output from the PLL multiplication circuit will be the machine clock. This machine clock is supplied to the CPU and peripheral functions. One of main clock, PLL clock, and sub clock can be selected by writing to the sub clock selection bit (CKSCR: SCS) and the PLL clock selection bit (CKSCR: MCS). Notes: CM44-10144-4E • When you rewrite the PLL clock selection bit (CKSCR: MCS) and sub clock selection bit (CKSCR: SCS), the machine clock is not switched immediately. If you want to operate a machine clock-dependent peripheral function, refer to the values on the PLL clock operating flag bit (CKSCR: MCM) or on the sub clock operating flag bit (CKSCR: SCM) and make sure that the machine clock has been switched before the operation. • When the PLL clock selection bit (CKSCR: MCS) is "0" (PLL clock mode) and the sub clock selection bit (CKSCR: SCS) is "0" (sub clock mode), SCS bit is preferred, and the sub clock mode begins. • When switching the clock mode, do not switch to other clock mode or the low-power consumption mode until the switch is completed. You can refer to MCM and SCM bits in the clock selection register (CKSCR) for the completion of switching. If the switch is not completed, switching to other clock mode or the low-power consumption mode may not take effect. FUJITSU SEMICONDUCTOR LIMITED 129 CHAPTER 6 CLOCK 6.5 Clock Mode MB90860E Series Figure 6.5-1 shows the state transition diagram by machine clock switching. Figure 6.5-1 State Transition Diagram by Machine Clock Selection Main MCS = 1 MCM = 1 SCS = 1 SCM = 1 CS1, CS0 = xx B CS2=x (9) (11) (10) (1) (18) (12) (7) Main --> PLLx MCS = 0 MCM = 1 SCS = 1 SCM = 1 CS1, CS0 = xx B CS2=x PLL1 --> Main (8) MCS = 1 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 00 B CS2=0 PLL2 --> Main (8) MCS = 1 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 01B CS2=0 PLL3 --> Main (8) MCS = 1 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 10 B CS2=0 PLL4 --> Main (8) MCS = 1 MCM = 0 SCS = 1 SCM= 1 CS1, CS0 = 11B CS2=0 PLL6 --> Main (8) MCS = 1 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 10 B CS2=1 130 Main --> Sub MCS = 1 MCM = 1 SCS = 0 SCM = 1 CS1, CS0 = xx B CS2=x (2) (3) (4) (5) (6) Sub --> Main MCS = 1 MCM = 1 SCS = 1 SCM = 0 CS1, CS0 = xx B CS2=x (7) (7) (7) (7) (7) (11) (10) PLL1:Multiplied MCS = 0 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 00 B CS2=0 PLL2:Multiplied MCS = 0 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 01B CS2=0 PLL3:Multiplied MCS = 0 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 10 B CS2=0 PLL4:Multiplied MCS = 0 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 11B CS2=0 PLL6:Multiplied MCS = 0 MCM = 0 SCS = 1 SCM = 1 CS1, CS0 = 10 B CS2=1 Sub MCS = X MCM = 1 SCS = 0 SCM = 0 CS1, CS0 = xx B CS2=x (9) (13) (14) (15) (16) (17) (9) (9) (9) (9) (9) FUJITSU SEMICONDUCTOR LIMITED Sub --> PLL MCS = 0 MCM = 1 SCS = 1 SCM = 0 CS1, CS0 = xx B CS2=0 PLL1 --> Sub MCS = 1 MCM = 0 SCS = 0 SCM = 1 CS1, CS = 00 B CS2=0 (19) PLL2 --> Sub (19) MCS = 1 MCM = 0 SCS = 0 SCM = 1 CS1, CS0 = 01B CS2=0 PLL3 --> Sub (19) MCS = 1 MCM = 0 SCS = 0 SCM = 1 CS1, CS0 =10 B CS2=0 PLL4 --> Sub (19) MCS = 1 MCM = 0 SCS = 0 SCM = 1 CS1, CS0 = 11B CS2=0 PLL6 --> Sub MCS = 1 MCM = 0 SCS = 0 SCM = 1 CS1, CS0 =10B CS2=1 (19) CM44-10144-4E CHAPTER 6 CLOCK 6.5 Clock Mode MB90860E Series (1) MCS bit "0" write (2) End of PLL clock oscillation stabilization wait time &CS1, CS0 = 00B & CS2 = 0 (3) End of PLL clock oscillation stabilization wait time &CS1, CS0 = 01B & CS2 = 0 (4) End of PLL clock oscillation stabilization wait time &CS1, CS0 = 10B & CS2 = 0 (5) End of PLL clock oscillation stabilization wait time &CS1, CS0 = 11B & CS2 = 0 (6) End of PLL clock oscillation stabilization wait time &CS1, CS0 = 10B & CS2 = 1 (7) MCS bit "1" write (including the resets) (8) Synchronous timing of PLL clock and main clock (9) SCS bit "0" write (10) Synchronous timing of main clock and sub clock (11) SCS bit "1" write (MCS1) (12) End of main clock oscillation stabilization wait time (13) End of main clock oscillation stabilization wait time & CS1, CS0 = 00B & CS2 = 0 (14) End of main clock oscillation stabilization wait time & CS1, CS0 = 01B & CS2 = 0 (15) End of main clock oscillation stabilization wait time & CS1, CS0 = 10B & CS2 = 0 (16) End of main clock oscillation stabilization wait time & CS1, CS0 = 11B & CS2 = 0 (17) End of main clock oscillation stabilization wait time & CS1, CS0 = 10B & CS2 = 1 (18) SCS bit "1" write (MCS0) (19) Synchronous timing of PLL clock and sub clock MCS Notes: CM44-10144-4E : Machine clock selection bit in the clock selection register (CKSCR) MCM : Machine clock selection bit in the clock selection register (CKSCR) SCS : Machine clock display bit (sub) in the clock selection register (CKSCR) SCM : Machine clock display bit (sub) in the clock selection register (CKSCR) CS1, CS0 : Multiplication rate selection bits in the clock selection register (CKSCR) CS2 : Multiplication rate selection bit in the PLL/sub clock control register (PSCCR) • Initial value of the machine clock is the main clock (CKSCR: MCS=1, SCS=1). • When both MCS and SCS bits are "0", SCS is preferred, and the sub clock is selected. • When switching from the sub clock to PLL clock mode, set CKSCR: WS1, WS0 to 10B or 11B. FUJITSU SEMICONDUCTOR LIMITED 131 CHAPTER 6 CLOCK 6.6 Oscillation Stabilization Wait Time 6.6 MB90860E Series Oscillation Stabilization Wait Time When the power is turned on where the oscillation clock is suspended or when stop mode is open, the oscillation clock requires some time to stabilize (the oscillation stabilization wait time) after oscillation begins. When switching the clock mode, such as from the main to PLL, main to sub, sub to main, or sub to PLL, an oscillation stabilization wait time is also required. ■ Operation During Oscillation Stabilization Wait Time Generally, ceramic or crystal oscillator requires time of several to several dozen of milliseconds until the oscillation is stabilized at the natural frequency (oscillation frequency) after starting the oscillation. Accordingly, CPU operation should be disabled immediately after the oscillation starts and the clock supply to the CPU is not enabled until the oscillation stabilization wait time has elapsed and the oscillation becomes stable. Since the oscillation stabilization wait time depends on the type of oscillator (such as crystal, ceramic), the proper oscillation stabilization wait time must be selected for your oscillator. The oscillation stabilization wait time can be set with the clock selection register (CKSCR). When switching the clock mode from the main clock to PLL clock, main clock to sub clock, sub clock to main clock, or sub clock to PLL clock, the CPU continues to operate on the original clock during the oscillation stabilization wait time. After the wait time has elapsed, the operating clock switches to the desire clock. Figure 6.6-1 shows the operation right after the oscillation starts. Figure 6.6-1 Operation Immediately After the Oscillation Starts Oscillation time of oscillator Oscillation stabilization wait time Starting normal operation or switching to PLL clock/sub clock X1 Oscillation starts 132 Oscillation stabilized FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 6 CLOCK 6.7 Connection of the Oscillator and External Clock MB90860E Series 6.7 Connection of the Oscillator and External Clock The MB90860E series contains a system clock generation circuit. Connecting the oscillator to the oscillation pin generates an internal clock. The clock input to the oscillation pin can be regarded as an oscillation clock. ■ Connection of the Oscillator and External Clock ● Example of connection of crystal oscillator or ceramic resonator Figure 6.7-1 Example of Connection of Crystal Oscillator or Ceramic Resonator X0 X1 C1 MB90860E series C2 X0A X1A C3 C4 ● Connection example of external clock Figure 6.7-2 Connection Example of External Clock X0 ~ Open X1 MB90860E series X0A ~ CM44-10144-4E Open X1A FUJITSU SEMICONDUCTOR LIMITED 133 CHAPTER 6 CLOCK 6.7 Connection of the Oscillator and External Clock 134 FUJITSU SEMICONDUCTOR LIMITED MB90860E Series CM44-10144-4E CHAPTER 7 RESET This chapter describes the reset. 7.1 Overview of Reset 7.2 Reset Source and Oscillation Stabilization Wait Times 7.3 External Reset Pin 7.4 Reset Operation 7.5 Reset Source Bits 7.6 Status of Pins by Reset CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 135 CHAPTER 7 RESET 7.1 Overview of Reset 7.1 MB90860E Series Overview of Reset When a reset source is generated, the CPU immediately stops the current execution process and assumes the reset release wait state. Once the reset is open, the CPU then begins processing with the address indicated by the reset vector. The reset has the following 4 sources: • Power-on reset • External reset request via the RST pin • Software reset request • Watchdog timer overflow ■ Reset Source Table 7.1-1 lists the sources of a reset. Table 7.1-1 Reset Sources Reset Source Machine clock Watchdog timer Oscillation stabilization wait Power-on When the power is turned on Main clock (MCLK) Stop Yes External pin "L" level input to the RST pin Main clock (MCLK) Stop No "0" is written to the internal reset signal generation bit (RST) in the low-power consumption mode control register (LPMCR). Main clock (MCLK) Stop No Watchdog timer overflow Main clock (MCLK) Stop No Software Watchdog timer MCLK: Main clock (divide-by-two clock of the oscillation clock) ● Power-on reset A power-on reset is generated when the power is turned-on. The oscillation stabilization wait time is fixed to 216 oscillation clock cycles (216/HCLK) (about 16.38 ms: at 4 MHz oscillation). When the oscillation stabilization wait time has elapsed, the reset is executed. ● External reset An external reset is generated by inputting the "L" level to an external reset pin (RST pin). The "L" level input time to the RST pin should be 500 ns or longer. The oscillation stabilization wait time is not required for the external resets. 136 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 7 RESET 7.1 Overview of Reset MB90860E Series • Only for the reset requests via the RST pin, if the reset source is generated during a write operation, the CPU assumes the reset release wait state after completion of the instruction. Therefore, even though a reset is input while writing, the writing process will be completed successfully. However, beware of the following: • For the string instructions, a reset is accepted before a specified number of counter are transferred, so that all data will never be transferred completely. • A reset is forcibly accepted without waiting for the completion of the instruction, if the cycle is extended to a certain level by the RDY input during access to the external bus. A reset is forcibly accepted with 16 machine cycles. • When returning from the stop mode, sub clock mode, sub clock sleep mode, and watch mode to the main clock mode via the external reset pin (RST pin), input Oscillation time of the oscillator* + 100 μs or more "L" level. *: Oscillation time of the oscillator is the time when the amplitude reaches to 90%. Several to several dozen ms for the crystal oscillator, several hundred μs to several ms for the ceramic resonator, and 0 ms for the external clock. • When returning from the time-base timer mode to the main clock mode via the external reset pin (RST pin), input 100 μs or more "L" level. Notes: ● Software reset A software reset is an internal reset generated by writing "0" to the RST bit of the low-power consumption mode control register (LPMCR). The oscillation stabilization wait time is not required for the software reset. ● Watchdog reset A watchdog reset is generated by a watchdog timer overflow that occurs when "0" is not written to the watchdog control bit (WTE) in the watchdog timer control register (WDTC) within a given time after the watchdog timer is activated. This reset doesn't take the oscillation stabilization wait time. Clock definitions HCLK : Oscillation clock frequency MCLK: Main clock frequency SCLK : Sub clock frequency φ : Machine clock (CPU operating clock) frequency 1/φ : Machine cycle (CPU operating clock period) See Section "6.1 Clock" for details. Note: CM44-10144-4E When a reset is generated in stop or sub clock mode, 215/HCLK oscillation stabilization wait time is required (approximately 8.19 ms, using HCLK=4 MHz oscillation). Refer to Section "6.6 Oscillation Stabilization Wait Time" for details. FUJITSU SEMICONDUCTOR LIMITED 137 CHAPTER 7 RESET 7.2 Reset Source and Oscillation Stabilization Wait Times MB90860E Series Reset Source and Oscillation Stabilization Wait Times 7.2 The MB90860E series has 4 types of reset sources. The oscillation stabilization wait time when resetting varies, depending on the reset source. ■ Reset Source and Oscillation Stabilization Wait Times Table 7.2-1 lists the reset sources and oscillation stabilization wait times. Table 7.2-1 Reset Sources and Oscillation Stabilization Wait Times Reset Oscillation stabilization wait time The oscillation clock frequency at 4 MHz is given in parentheses. Reset source Power-on When the power is turned on 216/HCLK (approx. 16.38 ms) Watchdog Watchdog timer overflow None: WS1 and WS0 bits are initialized to 11B, however. External "L" input from the RST pin None: WS1 and WS0 bits are initialized to 11B, however. Software Writing "0" to the RST bit in the low-power consumption mode control register (LPMCR). None: WS1 and WS0 bits are initialized to 11B, however. HCLK: Oscillation clock frequency WS1, WS0: Oscillation stabilization wait time selection bits in the clock select register (CKSCR) Figure 7.2-1 shows the oscillation stabilization wait times at a power-on reset. Figure 7.2-1 Oscillation Stabilization Wait Times at a Power-on Reset Vcc 215/HCLK 215/HCLK CLK CPU Operation Voltage step-down circuit stabilization wait time Note: Oscillation stabilization wait time Ceramic and crystal oscillators generally require several to several dozen ms of oscillation stabilization wait time, until the oscillation is stabilized at a specific frequency from the start of the oscillation. A proper oscillation stabilization wait time must be set for the particular oscillator to be used. See Section "6.6 Oscillation Stabilization Wait Time", for details. ■ Oscillation Stabilization Wait Reset State The reset operations in response to a reset at power-on, or during the stop mode and sub clock mode are performed after the oscillation stabilization wait time, created by the time-base timer, has elapsed. If the external reset input has not been open after the wait time, the reset operation is performed after the external reset is open. 138 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 7 RESET 7.3 External Reset Pin MB90860E Series 7.3 External Reset Pin The external reset pin (RST pin) is a dedicated reset input pin that generates an internal reset by inputting an "L" level. For the MB90860E series, resets are generated in synchronization with the CPU operating clock however, only the external pin generates a reset in asynchronous manner. ■ Block Diagram of the External Reset Pin Figure 7.3-1 Block Diagram of External Reset Pin CPU operating clock (PLL multiplier circuit with an HCLK frequency divided by 2) RST P-ch Synchronization circuit Pin CPU peripheral functions N-ch Input buffer HCLK: Oscillation clock Note: CM44-10144-4E Inputs to the RST pin are accepted during cycles in which memory is not affected in order to prevent memory from being destroyed by a reset during a write operation. A clock is required to initialize the internal circuit. In particular, an operation with an external clock requires clock input together with reset input. FUJITSU SEMICONDUCTOR LIMITED 139 CHAPTER 7 RESET 7.4 Reset Operation 7.4 MB90860E Series Reset Operation When a reset is open, the memory locations from which the mode data and the reset vectors are read are selected according to the setting of the mode pins, and a mode fetch is performed. The mode fetch determines the CPU operating mode and the execution start address after a reset operation ends. When returning by a reset at power-on or a reset from sub clock and stop mode, a mode fetch is performed when the oscillation stabilization wait time elapses. ■ Overview of Reset Operation Figure 7.4-1 shows the reset operation flow. Figure 7.4-1 Reset Operation Flow Power-on reset Stop mode Sub clock mode During a reset External reset Software reset Watchdog timer reset Oscillation stabilization wait reset state Fetching the reset vector Mode fetch (Reset operation) Fetching the mode data Normal operation (RUN state) CPU executes an instruction, fetching the instruction codes from the address indicated by the reset vector. ■ Mode Pins Setting the mode pins (MD0 to MD2) specifies how to fetch the reset vector and the mode data. Fetching the reset vector and the mode data is performed in the reset sequence. See Section "9.1.1 Mode Pin", for details on mode pins. ■ Mode Fetch When the reset is open, the CPU transfers the reset vector and the mode data to the appropriate registers in the CPU core by hardware. The reset vector and mode data are allocated to the 4 bytes from FFFFDCH to FFFFDFH. The CPU outputs these addresses to the bus immediately after the reset is open and then fetches the reset vector and mode data. Using the mode fetch, the CPU can begin processing at the address indicated by the reset vector. Figure 7.4-2 shows the transfer of the reset vector and mode data. 140 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 7 RESET 7.4 Reset Operation MB90860E Series Figure 7.4-2 Transfer of Reset Vector and Mode Data F2MC-16LX CPU core Memory Space Mode register FFFFDFH Mode data FFFFDEH Reset vector bits (23 to 16) Micro-ROM Reset sequence FFFFDDH Reset vector bits (15 to 8) FFFFDCH Reset vector bits (7 to 0) PCB PC ● Mode data (address: FFFFDFH) Only a reset operation can change the contents of the mode register. The mode register setting becomes valid after a reset operation. See Section "9.1.2 Mode Data", for details on mode data. ● Reset vector (address: FFFFDCH to FFFFDEH) The execution start address after the reset operation ends is written as the reset vector. Execution starts with the address contained in the reset vector. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 141 CHAPTER 7 RESET 7.5 Reset Source Bits 7.5 MB90860E Series Reset Source Bits A reset source can be identified by reading the watchdog timer control register (WDTC). ■ Reset Source Bits As shown in Figure 7.5-1, each reset source has a corresponding flip-flop. The contents of the flip-flops can be obtained by reading the watchdog timer control register (WDTC). If the source of a reset must be identified after the reset has been open, the value read from the WDTC should be processed by the software and branched to the appropriate program. Figure 7.5-1 Block Diagram of Reset Source Bits RST pin Power-on S R S F/F Q Watchdog timer reset generation detection circuit External reset request detection circuit Power-on detection circuit Watchdog timer control register (WDTC) No periodic clear RST=L R S F/F Q R S F/F Q R F/F Q RST bit set LPMCR: RST bit write detection circuit Delay circuit Reading of watchdog timer control register (WDTC) Internal data bus S : Set R : Reset Q : Out Put F/F : Flip Flop ■ Correspondence Between Reset Source Bits and Reset Sources Figure 7.5-2 shows the configuration of the reset source bits of the watchdog timer control register (WDTC). Table 7.5-1 maps the correspondence between the reset source bits and reset sources. See Section "12.3.1 Watchdog Timer Control Register (WDTC)", for details. 142 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 7 RESET 7.5 Reset Source Bits MB90860E Series Figure 7.5-2 Configuration of the Reset Source Bits (Watchdog Timer Control Register) Watchdog timer control register (WDTC) Address bit15 0000A8H R : Read only W : Write only X : Undefined ........ bit8 (TBTC) bit7 bit6 PONR − R − bit5 bit4 bit3 WRST ERST SRST R R R bit2 bit1 bit0 Initial value WTE WT1 WT0 W W W XXXXX111B Table 7.5-1 Correspondence Between Reset Source Bits and Reset Sources Reset source Power-on reset request generated PONR WRST ERST SRST 1 X X X Watchdog timer overflow reset request generated 1 External reset request via the RST pin 1 Software reset request generated 1 : Previous state retained X : Undefined ■ Notes on Reset Source Bits ● When multiple reset sources are generated When multiple reset sources are generated at the same time, the corresponding reset source bits of the watchdog timer control register (WDTC) are set to "1". For example, an external reset request via the RST pin and the watchdog timer overflow occur at the same time, both ERST and the WRST bits are set to "1". ● Power-on reset For a power-on reset, the PONR bit is set to "1" but all other reset source bits are undefined. Because of it, the software should be programmed so that it will ignore all reset source bits except the PONR when it is "1". ● Clearing the reset source bits The reset source bits are cleared only when the watchdog timer control register (WDTC) is read. Any flag generated in the bit corresponding to a reset source is not cleared even though another reset is generated and remains to "1". Note: CM44-10144-4E If the power is turned-on under conditions where no power-on reset occurs, the value in this register may not be guaranteed. FUJITSU SEMICONDUCTOR LIMITED 143 CHAPTER 7 RESET 7.6 Status of Pins by Reset 7.6 MB90860E Series Status of Pins by Reset This section describes the status of pins when a reset occurs. ■ Status of Pins During a Reset The status of pins during a reset depends on the settings of mode pins (MD2 to MD0). Refer to Section "8.7 Pin State in the Standby Mode and at the Time of Reset" for the status of pins during a reset ● When internal vector mode has been set (MD2 to MD0 = 011B) All I/O pins (peripheral function pins) are high impedance, and mode data is read from the internal ROM. ■ Status of Pins after Mode Data is Read The status of pins after mode data has been read depends on the mode data (M1 and M0). ● When single chip mode has been selected (M1 and M0 = 00B) All I/O pins (peripheral function pins) are high impedance, and mode data is read from the internal ROM. Note: 144 For those pins that change to high impedance when a reset source is generated, confirm that devices connected to those pins do not malfunction. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE This chapter explains the low-power consumption mode. 8.1 Overview of the Low-power Consumption Mode 8.2 Block Diagram of the Low-power Consumption Circuit 8.3 Low-power Consumption Mode Control Register (LPMCR) 8.4 CPU Intermittent Operation Mode 8.5 Standby Mode 8.6 State Transition of the Standby Mode 8.7 Pin State in the Standby Mode and at the Time of Reset 8.8 Notes on Using the Low-power Consumption Mode CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 145 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.1 Overview of the Low-power Consumption Mode 8.1 MB90860E Series Overview of the Low-power Consumption Mode CPU operation modes can be classified into the following operation modes based on the operation clock selection and the clock oscillation control. Operation modes except for the PLL clock mode belong to the low-power consumption mode. • Clock modes (main clock mode, PLL clock mode, and sub clock mode) • CPU intermittent operation modes (main clock intermittent operation mode, PLL clock intermittent operation mode, and sub clock intermittent operation mode) • Standby modes (sleep mode, stop mode, watch mode, and time-base timer mode) ■ CPU Operation Modes and Current Dissipation Figure 8.1-1 shows the relationship between CPU operation modes and their current dissipation. Figure 8.1-1 CPU Operation Modes and Current Dissipation Current dissipation Tens of mA CPU operation mode PLL clock mode Multiply-by-six clock Multiply-by-four clock Multiply-by-three clock Multiply-by-two clock Multiply-by-one clock PLL clock intermittent operation mode Multiply-by-six clock Multiply-by-four clock Multiply-by-three clock Multiply-by-two clock Multiply-by-one clock Main clock mode (1/2HCLK) Main clock intermittent operation mode Sub clock mode (divide-by-four or divide-by-two of oscillation frequency) Sub clock intermittent operation mode Some mA Standby mode Sleep mode Time-base timer mode Watch mode Some μA Stop mode Low-power consumption mode This figure shows the outline of operation modes, and actual current dissipation may differ. 146 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.1 Overview of the Low-power Consumption Mode MB90860E Series ■ Clock Modes ● PLL clock mode This is a mode that uses PLL multiplier clocks of the oscillation clock (HCLK) to operate CPU and peripheral functions. ● Main clock mode This is a mode that uses the divide-by-two clock of the oscillation clock (HCLK) to operate CPU and peripheral functions. During the main clock mode, the PLL multiplier circuit stops. ● Sub clock mode This is a mode that uses the sub clock (SCLK) to operate CPU and peripheral functions. Either divide-bytwo or divide-by-four of the sub clock oscillation clock can be selected for the sub clock. During the sub clock mode, the main clock and PLL multiplier circuit stop. When power is turned on or the stop mode is canceled, a sub clock oscillation stabilization wait time 214/SCLK occurs (in the case oscillation clock frequency is 32.768 kHz with divide-by-four setting: about two seconds). Therefore, if the main clock mode is switched to the sub clock mode therein, an oscillation stabilization wait time occurs. Reference: See "CHAPTER 6 CLOCK" for details on the clock mode. ■ CPU Intermittent Operation Mode This is a mode that reduces power consumption by operating a CPU intermittently while providing highspeed clock to peripheral functions. The CPU intermittent operation mode provides intermittent clock only to a CPU when registers, internal memory peripheral functions, and external accesses are being used. ■ Standby Mode The standby mode reduces power consumption by stopping providing operation clock to a CPU and peripheral functions using a standby control circuit or stopping the oscillation clock (HCLK). ● Sleep mode The sleep mode is a mode that stops providing operation clock to a CPU while a clock mode is operating. The CPU stops, and peripheral functions operate at the clock before switching to the sleep mode. Depending on the clock mode when transiting to the sleep mode, it is classified into the main sleep mode, PLL sleep mode, or sub sleep mode. ● Watch mode The watch mode is a mode that operates the sub clock (SCLK) and watch timer only. The main clock and PLL clock stop. Peripheral functions except the watch timer also stop. If the WDCS bit in WTC register is "0", the watchdog timer continues to operate. ● Time-base timer mode The time-base timer mode is a mode that operates the oscillation clock (HCLK), sub clock (SCLK), the watchdog timer, time-base timer and watch timer only. Peripheral functions except the time-base timer, watchdog timer and watch timer stop. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 147 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.1 Overview of the Low-power Consumption Mode MB90860E Series ● Stop mode The stop mode is a mode that stops the oscillation clock (HCLK) and sub clock (SCLK) while a clock mode is operating. Data can be kept with lowest power consumption. Note: 148 When a clock mode is being switched, do not again switch to other clock modes or the lowpower consumption mode before the switching completes. The completion of switching can be checked by referring to the MCM bit and SCM bit in the clock selection register (CKSCR). If a mode is switched again to other clock modes or the low-power consumption mode before the first switching is finished, the second switching may not complete. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.2 Block Diagram of the Low-power Consumption Circuit MB90860E Series 8.2 Block Diagram of the Low-power Consumption Circuit This section shows the block diagram of the low-power consumption circuit. ■ Block Diagram of the Low-power Consumption Circuit Figure 8.2-1 Block Diagram of the Low-power Consumption Circuit Low-power consumption mode control register ( LPMCR) STP SLP SPL RST TMD CG1 CG0 Reserved RST Pin CPU intermittent operation cycle selector Pin high impedance control circuit Pin Hi-Z control Internal reset generation circuit Internal reset Intermittent cycle selected CPU clock control circuit Reset (cancel) Watch, sleep, and stop signals Standby control circuit 2 CPU operation clock Watch and stop signals Peripheral Peripheral functions clock control operation clock circuit Sub clock oscillation stabilization wait canceled Main clock oscillation stabilization wait canceled Interrupt (cancel) Clock generation block Operation clock selector Machine clock 2 CS2 PLL/Sub clock control register (PSCCR):bit8 Oscillation stabilization wait time selector 2 PLL multiplier circuit SCM MCM WS1 WS0 SCS MCS CS1 CS0 Clock selection register (CKSCR) X0 Pin X1 Pin Divideby-two Divide- Divide- by-four Main by-512 Oscillation clock clock ( HCLK) Time-base timer Oscillation clock oscillation circuit Sub clock ( SCLK) X0A Pin Divide-byfour/divideby-two Divideby-1024 Divideby-two Divideby-two Divideby-two Divideby-two Divideby-two Divideby-four To watchdog timer Divideby-eight Divideby-two Divideby-two Watch timer X1A Pin SCDS Sub clock oscillation circuit CM44-10144-4E PLL/Sub clock control register (PSCCR):bit10 FUJITSU SEMICONDUCTOR LIMITED 149 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.2 Block Diagram of the Low-power Consumption Circuit MB90860E Series ● CPU intermittent operation selector Selects the pause cycle count for CPU clock in the CPU intermittent operation mode. ● Standby control circuit Switches to and cancels the standby mode by switching CPU operation clock and peripheral function operation clock using the CPU clock control circuit and peripheral clock control circuit. ● CPU clock control circuit This is a circuit that provides operation clock to a CPU. ● Pin high impedance control circuit Switches an I/O pin to high impedance state when the mode is the watch mode, time-base timer mode, or stop mode. ● Internal reset generation circuit Generates internal reset signals. ● Low-power consumption mode control register (LPMCR) Switches to and cancels the standby mode, or configures the CPU intermittent operation mode. 150 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.3 Low-power Consumption Mode Control Register (LPMCR) MB90860E Series 8.3 Low-power Consumption Mode Control Register (LPMCR) The low-power consumption mode control register (LPMCR) switches to and cancels the low-power consumption mode, generates internal reset signals, and sets the pause cycle count of the CPU intermittent operation mode. ■ Low-power Consumption Mode Control Register (LPMCR) Figure 8.3-1 Low-power Consumption Mode Control Register (LPMCR) 7 6 5 4 3 2 1 STP SLP SPL RST TMD CG1 CG0 W W R/W W W 0 Initial value Reserved 00011000B R/W R/W R/W bit0 Reserved bit Reserved 0 Always set to "0" bit2 bit1 CG1 CG0 CPU pause cycle count selection bits 0 0 0 cycle (CPU clock = peripheral clock) 0 1 8 cycles (CPU clock : peripheral clock = 1: approx. 3 to 4) 1 0 16 cycles (CPU clock : peripheral clock = 1: approx. 5 to 6) 1 1 32 cycles (CPU clock : peripheral clock = 1: approx. 9 to 10) bit3 Watch mode bit TMD 0 Transits to the watch mode or time-base timer mode 1 No effect bit4 Internal reset signal generation bit RST Generates internal reset signals at 3 machine cycles 0 No effect 1 bit5 SPL 0 1 Pin state specifying bit Keeps an input/output pin state High impedance Enabled only in the time-base timer, watch, and stop modes bit6 Sleep mode bit SLP No effect 0 1 Transits to the sleep mode bit7 STP R/W : Readable/writable : Write only W : Initial value CM44-10144-4E Stop mode bit 0 No effect 1 Transits to the stop mode FUJITSU SEMICONDUCTOR LIMITED 151 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.3 Low-power Consumption Mode Control Register (LPMCR) MB90860E Series Table 8.3-1 Functions of Low-power Consumption Mode Control Register (LPMCR) Bit name Function STP: Stop mode bit Switches to the stop mode. When set to "0": No effect. When set to "1": Switches to the stop mode. When reading: "0" is consistently read. • Initialized to "0" by a reset or an external interrupt. SLP: Sleep mode bit Switches to the sleep mode. When set to "0": No effect. When set to "1": Switches to the sleep mode. When reading : "0" is consistently read. • Initialized to "0" by a reset or an external interrupt. • If "1" is set to the STP bit and SLP bit concurrently, the STP bit has priority, switching to the stop mode. bit5 SPL: Pin state setting bit Sets the state of an input/output pin when switching to the stop mode, watch mode, and time-base timer mode. When set to "0": Keeps the current level of an input/output pin. When set to "1": Switches the input/output pin to high impedance state. • Initialized to "0" by a reset. bit4 RST: Internal reset signal generation bit Generates a software reset. When set to "0": Generates internal reset signals at 3 machine cycles. When set to "1": No effect. When reading : "1" is consistently read. bit7 bit6 bit3 TMD: Watch mode bit Switches to the watch mode or time-base timer mode. When set to "0": Switches to the time-base timer mode if the mode is the main clock mode or PLL clock mode. Switches to the watch mode if the mode is the sub clock mode. When set to "1": No effect. • "1" is set by a reset or interrupt. When reading : "1" is consistently read. 152 bit1, bit2 CG1, CG0: CPU pause cycle count selection bits Sets the pause cycle count for CPU clock in the CPU intermittent operation mode. bit0 Reserved: Reserved bit Always set to "0". • Returns to initial values by all kinds of reset. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.3 Low-power Consumption Mode Control Register (LPMCR) MB90860E Series Notes: • Use the instructions in Table 8.3-2 to configure the settings for switching to the low-power consumption mode in the low-power consumption mode control register (LPMCR). Operations cannot be assured if instructions other than shown in the list below are used to switch to the low-power consumption mode. • Immediately after using the standby mode transition instructions in Table 8.3-2, be sure to add the instructions shown in the dotted square below. MOV LPMCR, #H’xx ; Low-power consumption mode transition instruction in Table 8.3-2 NOP NOP JMP $+3 ; Jump to next instruction MOV A, #H’10 ; Any instruction If instruction lines other than shown in the dotted square are added, operations after canceling the standby mode will not be assured. • If the C language is used to access the low-power consumption mode control register, see "■ Notes on Accessing the Low-power Consumption Mode Control Register (LPMCR) for Switching to the Standby Mode" in Section "8.8 Notes on Using the Low-power Consumption Mode". • Use even number addresses to write in the low-power consumption mode control register (LPMCR) in units of words. If an odd number address is used to write, it may cause malfunction. • During the stop mode, watch mode, or time-base timer mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the STP bit to "1" or TMD bit to "0" in the low-power consumption mode control register (LPMCR). Table 8.3-2 List of Instructions Used when Transiting to the Low-power Consumption Mode CM44-10144-4E MOV io,#imm8 MOV dir,#imm8 MOV eam,#imm8 MOV eam,Ri MOV io,A MOV dir,A MOV addr16,A MOV eam,A MOV @Rli+disp8,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 MOVW @Rli+disp8,A SETB io:bp SETB dir:bp SETB addr16:bp CLRB io:bp CLRB dir:bp CLRB addr16:bp FUJITSU SEMICONDUCTOR LIMITED 153 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.4 CPU Intermittent Operation Mode 8.4 MB90860E Series CPU Intermittent Operation Mode The CPU intermittent operation mode is a mode that reduces power consumption by operating a CPU intermittently while providing operation clock to the CPU and peripheral functions. ■ Operation of CPU Intermittent Operation Mode When the CPU accesses the register, internal memory, I/O, peripheral functions, and external buses, the CPU intermittent operation mode temporarily holds the clock provided to CPU every time an instruction is executed to delay the activation of internal buses. It can reduce power consumption by lowering the CPU execution speed while providing high-speed clock to peripheral functions. • The machine cycle count to temporarily stop providing clock to CPU is set at the CG1 and CG0 bits in the low-power consumption mode control register (LPMCR). • The instruction execution time of the CPU intermittent operation mode can be calculated by adding the normal execution time to the adjusted value that is the number of accesses to the register, internal memory, peripheral functions, and external buses multiplied by the number of pause cycle count. Figure 8.4-1 shows the clock operation of the CPU intermittent operation mode. Figure 8.4-1 Clock Operation of the CPU Intermittent Operation Mode Peripheral clock CPU clock One instruction execution cycle Pause cycle Internal bus activated 154 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series 8.5 Standby Mode The standby mode can reduce power consumption by stopping providing operation clock to a CPU and peripheral functions using a standby control circuit or stopping the oscillation clock. ■ Types and Operation States of the Standby Mode Table 8.5-1 shows the types and operation states of the standby mode. Table 8.5-1 Types and Operation States of the Standby Mode (1 / 2) Mode name Transition conditions Oscillation clock (HCLK) Sub clock (SCLK) Machine clock CPU Watchdog timer Peripheral functions Pin Release method Main sleep mode MCS=1 SCS=1 SLP=1 ❍ ❍ ❍ × ❍*7 ❍ ❍ External reset or interrupt Sub sleep mode MCS=X SCS=0 SLP=1 WDCS=0 × ❍ ❍ × ❍*7 ❍ ❍ External reset or interrupt Sub sleep mode MCS=X SCS=0 SLP=1 WDCS=1 × ❍ ❍ × −*8 ❍ ❍ External reset or interrupt PLL sleep mode MCS=0 SCS=1 SLP=1 ❍ ❍ ❍ × ❍*7 ❍ ❍ External reset or interrupt SPL=0 MCS=X SCS=1 TMD=0 ❍ ❍ × × ❍*7 ×*1 External reset or interrupt*4 SPL=1 MCS=X SCS=1 TMD=0 ❍ ❍ × × ❍*7 ×*1 Hi-Z*3 External reset or interrupt*4 SPL=0 MCS=X SCS=0 TMD=0 WDCS=0 × ❍ × × ❍*7 ×*2 External reset or interrupt*5 SPL=1 MCS=X SCS=0 TMD=0 WDCS=0 × ❍ × × ❍*7 ×*2 Hi-Z*3 External reset or interrupt*5 SPL=0 MCS=X SCS=0 TMD=0 WDCS=1 × ❍ × × −*8 ×*2 External reset or interrupt*5 SPL=1 MCS=X SCS=0 TMD=0 WDCS=1 × ❍ × × −*8 ×*2 Hi-Z*3 External reset or interrupt*5 Sleep mode Time-base timer mode Watch mode CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 155 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series Table 8.5-1 Types and Operation States of the Standby Mode (2 / 2) Mode name Transition conditions Oscillation clock (HCLK) Sub clock (SCLK) Machine clock CPU Watchdog timer Peripheral functions Pin Release method SPL=0 STP=1 × × × × × × External reset or interrupt*6 SPL=1 STP=1 × × × × × × Hi-Z*3 External reset or interrupt*6 Stop mode ❍: Operating ×: Stopped : Keeps the state before transition Hi-Z : High impedance *1 : The time-base timer and watch timer operate. *2 : The watch timer operates. *3 : The input pin for DTP/external interrupt operates. *4 : Watch timer, time-base timer, and external interrupt *5 : Watch timer and external interrupt *6 : External interrupt *7 : The watchdog timer will be cleared when transiting to a different mode. *8 : The watchdog timer is not available. MCS : PLL clock selection bit of the clock selection register (CKSCR) SCS : Sub clock selection bit of the clock selection register (CKSCR) SPL : Pin state setting bit of the low-power consumption mode control register (LPMCR) SLP : Sleep mode bit of the low-power consumption mode control register (LPMCR) STP : Stop mode bit of the low-power consumption mode control register (LPMCR) TMD : Watch mode bit of the low-power consumption mode control register (LPMCR) Note: 156 During the stop mode, watch mode, or time-base timer mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the STP bit to "1" or TMD bit to "0" in the low-power consumption mode control register (LPMCR). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series 8.5.1 Sleep Mode The sleep mode is an operation mode that stops providing operation clock to a CPU while a clock mode is operating. The CPU stops, but peripheral functions continue to operate. ■ Switching to the Sleep Mode When the mode is switched to the sleep mode by the low-power consumption mode control register settings (LPMCR: SLP=1, STP=0), the transition to the sleep mode bases on the settings in the MCS bit and SCS bit of the clock selection register (CKSCR). Table 8.5-2 shows the correspondence between the sleep mode and the settings of the MCS bit and SCS bit in the clock selection register (CKSCR). Table 8.5-2 Clock Selection Register (CKSCR) Settings and Their Sleep Modes Clock selection register (CKSCR) Sleep mode to switch to MCS SCS 1 1 Main sleep mode 0 1 PLL sleep mode 1 0 0 0 Sub sleep mode Note: If "1" is concurrently set to the STP bit and SLP bit in the low-power consumption mode control register (LPMCR), the STP bit has priority, switching to the stop mode. Also, if "1" is set to the SLP bit and "0" to the TMD bit concurrently, the TMD bit has priority, switching to the time-base timer mode or watch mode. ● Data retaining function During the sleep mode, data stored in internal RAMs and dedicated registers such as an accumulator will be retained. ● External bus hold function During the sleep mode, the external bus hold function operates. If a hold request is generated to CPU, the state transits to hold state. ● Operations while an interrupt request exists While "1" is set to the SLP bit in the low-power consumption mode control register (LPMCR), if an interrupt request exists, the mode does not switch to the sleep mode. If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. On the other hand, if the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 157 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series ● Pin state During the sleep mode, pins except ones that are used for bus input/output or bus control will keep the state before switching to the sleep mode. ■ Returning from the Sleep Mode Generation of a reset source or interrupt will cancel the sleep mode. ● Returning by a reset source If the sleep mode is canceled by a reset source, after canceling the sleep mode, the mode switches to the main clock mode and then to a reset sequence. ● Returning by an interrupt During the sleep mode, if an interrupt request with interrupt level (IL) higher than seven is generated by peripheral functions or the like, the sleep mode will be canceled. And after canceling the sleep mode, generated interrupt requests will be judged based on the I flag in the condition code register (CCR) and the settings in the interrupt level mask register (ILM) and interrupt control register (ICR) as in the case with normal interrupt processing. • If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. • If the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. Figure 8.5-1 shows the canceling of the sleep mode by an interrupt. Figure 8.5-1 Canceling of the Sleep Mode by an Interrupt Interrupt flag settings of peripheral functions INT occurs (IL < 7) YES NO Does not cancel sleep Does not cancel sleep Cancels sleep I=0 YES Executes the next instruction NO ILM < IL YES NO Executes interrupt processing Note: 158 When executing an interrupt processing, it will be normally done after executing the next instruction of the instruction having a sleep mode specification. However, if the switching to sleep mode and the reception of external bus hold request are done simultaneously, the transition to interrupt processing may occur before executing the next instruction. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series 8.5.2 Watch Mode The watch mode is a mode that operates the sub clock (SCLK) and watch timer only. The main clock and PLL clock stop. If the WDCS bit in WTC register is "0", the watchdog timer continues to operate. ■ Switching to the Watch Mode If "0" is written in the TMD bit of LPMCR because of the setting of low-power consumption mode control register (LPMCR) during the sub clock mode, the mode switches to the watch mode. ● Data retaining function During the watch mode, data stored in internal RAMs and dedicated registers such as an accumulator will be retained. ● External bus hold function During the watch mode, the external bus hold function stops. Although a hold request to CPU is input, it will not be accepted. If a hold request is input during the transition to watch mode, the HAK signal may not change to "L" level while keeping buses in high impedance state. ● Operations while an interrupt request exists While "0" is set to the TMD bit in the low-power consumption mode control register (LPMCR), if an interrupt request exists, the mode does not switch to the watch mode. If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. On the other hand, if the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. ● Pin state The state of input/output pins during the watch mode can be specified to set either to change to high impedance state or to keep the state before transiting to the watch mode, by setting the SPL bit in the lowpower consumption mode control register (LPMCR). Note: CM44-10144-4E During the watch mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the TMD bit in the lowpower consumption mode control register (LPMCR) to "0". FUJITSU SEMICONDUCTOR LIMITED 159 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series ■ Returning from the Watch Mode Generation of a reset source or interrupt will cancel the watch mode. ● Returning by a reset source If the watch mode is canceled by a reset source, after canceling the watch mode, the mode switches to the main clock mode and then to a reset sequence. ● Returning by an interrupt During the watch mode, if an interrupt request with interrupt level (IL) higher than seven is generated by the watch timer and an external interrupt, the watch mode will be canceled. And after canceling the watch mode, the interrupt requests will be judged based on the I flag in the condition code register (CCR) and the settings in the interrupt level mask register (ILM) and interrupt control register (ICR) as in the case with normal interrupt processing. In the case of sub watch mode, because it does not have oscillation stabilization wait time, the interrupt request will be judged immediately after returning to the watch mode. • If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. • If the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. Note: 160 When executing an interrupt processing, it will be normally done after executing the next instruction of the instruction having a watch mode specification. However, if the switching to watch mode and the reception of external bus hold request are done simultaneously, the transition to interrupt processing may occur before executing the next instruction. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 8.5.3 Time-base Timer Mode CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode The time-base timer mode is a mode that operates the oscillation clock (HCLK), sub clock (SCLK), the time-base timer and watch timer only. Peripheral functions except the time-base timer, watchdog timer and watch timer stop. ■ Switching to the Time-base Timer Mode If "0" is written in the TMD bit of low-power consumption mode control register (LPMCR) while the PLL clock mode or main clock mode is operating (CKSCR: SCM=1), the mode switches to the time-base timer mode. ● Data retaining function During the time-base timer mode, data stored in internal RAMs and dedicated registers such as an accumulator will be retained. ● External bus hold function During the time-base timer mode, the external bus hold function stops. Although a hold request to CPU is input, it will not be accepted. If a hold request is input during the transition to time-base timer mode, the HAK signal may not change to "L" level while keeping buses in high impedance state. ● Operations while an interrupt request exists While "0" is set to the TMD bit in the low-power consumption mode control register (LPMCR), if an interrupt request exists, the mode does not switch to the time-base timer mode. If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. On the other hand, if the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. ● Pin state The state of input/output pins during the time-base timer mode can be specified to set either to change to high impedance state or to keep the state before transiting to the time-base timer mode, by setting the SPL bit in the low-power consumption mode control register (LPMCR). Note: CM44-10144-4E During the time-base timer mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the TMD bit in the low-power consumption mode control register (LPMCR) to "0". FUJITSU SEMICONDUCTOR LIMITED 161 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series ■ Returning from the Time-base Timer Mode Generation of a reset source or interrupt will cancel the time-base timer mode. ● Returning by a reset source If the time-base timer mode is canceled by a reset source, after canceling the time-base timer mode, the mode switches to the main clock mode and then to a reset sequence. ● Returning by an interrupt During the time-base timer mode, if an interrupt request with interrupt level (IL) higher than seven is generated by the watch timer, time-base timer and an external interrupt, the time-base timer mode will be canceled. And after canceling the time-base timer mode, generated interrupt requests will be judged based on the I flag in the condition code register (CCR) and the settings in the interrupt level mask register (ILM) and interrupt control register (ICR) as in the case with normal interrupt processing. • If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. • If the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. • The time-base timer mode has the following two types: - Main clock to/from time-base timer mode - PLL clock to/from time-base timer mode Note: 162 When executing an interrupt processing, it will be normally done after executing the next instruction of the instruction having a time-base timer mode specification. However, if the switching to time-base timer mode and the reception of external bus hold request are done simultaneously, the transition to interrupt processing may occur before executing the next instruction. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series 8.5.4 Stop Mode The stop mode is a mode that stops the oscillation clock (HCLK) and sub clock (SCLK) while a clock mode is operating. Data can be kept with lowest power consumption. ■ Stop Mode If "1" is written in the STP bit of low-power consumption mode control register (LPMCR) while the PLL clock mode is operating (CKSCR: MCS=1, SCS=0), the mode switches to the stop mode based on the settings of MCS bit and SCS bit in the clock selection register (CKSCR). Table 8.5-3 shows the correspondence between the stop mode and the settings of the MCS bit and SCS bit in the clock selection register (CKSCR). Table 8.5-3 Clock Selection Register (CKSCR) Settings and Their Stop Modes Clock selection register (CKSCR) Stop mode to switch to MCS SCS 1 1 Main stop mode 0 1 PLL stop mode 1 0 0 0 Sub stop mode Note: If "1" is concurrently set to the STP bit and SLP bit in the low-power consumption mode control register (LPMCR), the STP bit has priority, switching to the stop mode. ● Data retaining function During the stop mode, data stored in internal RAMs and dedicated registers such as an accumulator will be retained. ● External bus hold function During the stop mode, the external bus hold function stops. Although a hold request to CPU is input, it will not be accepted. If a hold request is input during the transition to stop mode, the HAK signal may not change to "L" level while keeping buses in high impedance state. ● Operations while an interrupt request exists While "1" is set to the STP bit in the low-power consumption mode control register (LPMCR), if an interrupt request exists, the mode does not switch to the stop mode. If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. On the other hand, if the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 163 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode MB90860E Series ● Pin state The state of input/output pins during the stop mode can be specified to set either to change to high impedance state or to keep the state before transiting to the stop mode, by setting the SPL bit in the lowpower consumption mode control register (LPMCR). Note: During the stop mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the STP bit in the lowpower consumption mode control register (LPMCR) to "1". ■ Returning from the Stop Mode Generation of a reset source or interrupt will cancel the stop mode. When returning from the stop mode, because the oscillation clock (HCLK) and sub clock (SCLK) are suspended, the stop mode will be canceled after the main clock or sub clock oscillation stabilization wait time having elapsed. ● Returning by a reset source If the stop mode is canceled by a reset source, the main clock oscillation stabilization wait time will be necessary. After the main clock oscillation stabilization wait time elapses, the stop mode is canceled and transits to the reset sequence. Figure 8.5-2 shows the returning process from the sub stop mode caused by an external reset. Figure 8.5-2 Returning Process from the Sub Stop Mode Caused by an External Reset RST pin Stop mode Main clock Oscillation stabilization waiting Oscillating Sub clock Oscillation stabilization waiting Oscillating Oscillation stabilization waiting PLL clock CPU operation clock CPU operation Main clock Stopped Reset sequence Oscillating PLL clock Normal process Stop mode canceled Reset canceled 164 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.5 Standby Mode ● Returning by an interrupt During the stop mode, if an interrupt request with interrupt level (IL) higher than seven is generated by an external interrupt, the stop mode will be canceled. In the case of stop mode, a main clock oscillation stabilization wait time or sub clock oscillation time will be required after canceling the stop mode. And after finishing the main clock oscillation stabilization wait time or sub clock oscillation wait time, generated interrupt requests will be judged based on the I flag in the condition code register (CCR) and the settings in the interrupt level mask register (ILM) and interrupt control register (ICR) as in the case with normal interrupt processing. • If the CPU cannot accept an interrupt request, the next instruction of the current one will be executed. • If the CPU can accept an interrupt request, it will immediately branch to the interrupt processing routine. Notes: CM44-10144-4E • When executing an interrupt processing, it will be normally done after executing the next instruction of the instruction having a stop mode specification. However, if the switching to stop mode and the reception of external bus hold request are done simultaneously, the transition to interrupt processing may occur before executing the next instruction. When switching to the PLL stop mode, set 10B or 11B to the oscillation stabilization wait time selection bit (CKSCR: WS1, WS0) in the clock selection register. • During the PLL stop mode, a main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time have to be secured when returning from the PLL stop mode because the main clock and PLL multiplier circuits are stopped. The oscillation stabilization wait time in this case bases upon the values set in the oscillation stabilization wait time selection bit in the clock selection register (CKSCR:WS1, WS0), and the main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time will be counted together. Therefore, set a value to the "CKSCR:WS1,WS0" bit in line with the longest one of the oscillation stabilization wait times. However, because 214/HCLK or more is needed for the PLL clock oscillation stabilization wait time, set 10B or 11B to the "CKSCR: WS1, WS0" bit. FUJITSU SEMICONDUCTOR LIMITED 165 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.6 State Transition of the Standby Mode 8.6 MB90860E Series State Transition of the Standby Mode Operation states and transitions of the clock mode and standby mode in MB90860E series are shown in a chart. ■ State Transition Chart Figure 8.6-1 State Transition Chart Power turned on External reset, watchdog timer reset, software reset Power-on reset Reset SCS=0 SCS=1 Oscillation stabilization wait done Main clock mode MCS=0 PLL clock mode MCS=1 SLP=1 Interrupt Main sleep mode TMD=0 Interrupt Main time-base timer mode STP=1 SCS=0 SCS=1 SLP=1 Interrupt PLL sleep mode TMD=0 Interrupt PLL time-base timer mode STP=1 Main stop mode Sub clock mode PLL stop mode SLP=1 Interrupt Sub sleep mode TMD=0 Interrupt Watch mode STP =1 Sub stop mode Interrupt Oscillation stabili- Interrupt Oscillation stabili- Interrupt Oscillation stabilization wait done zation wait done zation wait done Main clock oscillation stabilization waiting 166 PLL clock oscillation stabilization waiting FUJITSU SEMICONDUCTOR LIMITED Sub clock oscillation stabilization waiting CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.7 Pin State in the Standby Mode and at the Time of Reset MB90860E Series 8.7 Pin State in the Standby Mode and at the Time of Reset This section shows the input/output pin states in the standby mode and at the time of reset, for each access mode. ■ Input/Output Pin State (Single Chip Mode) Table 8.7-1 Input/Output Pin State (Single Chip Mode) During stop/watch/time-base timer*6 Pin name During sleep At the time of reset SPL=0 P17 to P13, P11, P10 P27 to P20 P37 to P33, P31, P30 P47 to P43, P41, P40 P57 to P50 P67 to P60 P87 to P85, P83 P97 to P90 PA1 SPL=1 Shuts off input*4/ Keeps the previous state*2 Shuts off input*4/ Outputs Hi-Z*5 Input unavailable*3/ Outputs Hi-Z*5 Keeps the previous state*2 P07 to P00*7 P77 to P70*9 Input available*1 PA0, P42, P32, P12, P80 to P82, P84*8 *1: "Input available" means that input functions can be used. If the pin is set as an input port, apply pull-up/pull-down processing or input external signals. If the pin is set as an output port, it transits to the same state as other pins. *2: If the state immediately before transiting to a standby mode is output or input as is, this means "Input unavailable". This means that if an outputting peripheral function is operating, output is obtained according to the state of the peripheral function, and if output is obtained from an output pin, the output will be retained. *3: "Input unavailable" means that the pin data cannot be accepted internally because the internal circuit is stopped while the operation of input gate at the pin is allowed. *4: During shut-off state, input is masked, and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. *5: "Outputs Hi-Z" means that the pin-driving transistor is prohibited from driving, and the pin is switched to high impedance state. *6: The pull-up function in port 0 to 3 will be disabled in these modes. *7: Can be input in the stop/watch/time-base timer mode when the INTxR bit in external interrupt source selection register EISSR is "0" and the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. *8: Can be input in the stop/watch/time-base timer mode when the INTxR bit in external interrupt source selection register EISSR is "1" and the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. *9: Can be input in the stop/watch/time-base timer mode when the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly. Note: CM44-10144-4E During the stop mode, watch mode, or time-base timer mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the STP bit to "1" or TMD bit to "0" in the low-power consumption mode control register (LPMCR). FUJITSU SEMICONDUCTOR LIMITED 167 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.7 Pin State in the Standby Mode and at the Time of Reset MB90860E Series ■ Input/Output Pin State (16-bit Access Mode) Table 8.7-2 Input/output Pin State (16-bit access Mode) During stop/watch/ time-base timer Pin name During sleep During hold SPL=0 P07 to P00 (AD07 to AD00) Input unavailable/ SPL=1 P17 to P10 (AD15 to AD08) Outputs Hi-Z Shuts off input/ Outputs Hi-Z P27 to P20 (A23 to A16) Output state *1, *3 Output state *1,*3 Input unavailable/ Outputs Hi-Z *3 P37(CLK) Input unavailable/ Output available*2,*3 Input unavailable/ Output state *1, *3 Input unavailable/ Output available*2,*3 Keeps the previous state*4 Shuts off input/ Keeps the previous state*4 P36(RDY) P35(HAK) Shuts off input/ Outputs Hi-Z *5 Outputs Hi-Z/ Outputs Hi-Z/ Input available Input available Output state*1 Input unavailable/ Outputs Hi-Z *3 Outputs "H" Outputs "H" P30(ALE) Outputs "L" Outputs "L" P47 to P43, P41, P40 P57 to P50 P67 to P60 P87 to P85, P83*7 P97 to P90 PA1 Keeps the previous state*4 Keeps the previous state*4 Outputs Hi-Z/ Outputs Hi-Z/ Input available Input available Outputs "L"*3 P33(WRH) P31(RD) Keeps the previous address Input unavailable/ Output Hi-Z/ Input unavailable/ Outputs Hi-Z*3 Inputs "1"*3 Outputs "H"*3 Outputs "H"*3 At the time of internal ROM access after accessing external ROM Input unavailable/ Outputs Hi-Z P34(HRQ) P32(WRL) At the time of internal ROM At the time of access after reset canceling reset Input unavailable/ Outputs Hi-Z Outputs "H" Outputs "H" Outputs "H" Outputs "L" Outputs "L" Outputs "L" Keeps the previous state*4 Input unavailable/ Outputs Hi-Z Outputs Hi-Z/ Outputs Hi-Z/ Input available Input available P77 to P70*9 PA0, P42, P82 to P80, P84*8 168 Input available*6 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.7 Pin State in the Standby Mode and at the Time of Reset *1: "Output state" means that the fixed value of "H" level or "L" level will be output because the internal circuit stops operating while the pin-driving transistor is allowed to drive. If the output function is being used while internal peripheral circuits are operating, the output fluctuates except at the time of reset. (There is no output fluctuation at the time of reset.) *2: "Output available" means that operation data will be output to pins because the internal circuit operation is allowed and the pindriving transistor is driving. *3: If it is used as an output port, the value just previously output will be kept. *4: If the state immediately before transiting to a standby mode is output or input as is, this means "Input unavailable". This means that if an outputting peripheral function is operating, output is obtained according to the state of the peripheral function, and if output is obtained from an output pin, the output will be retained. "Input unavailable" means that the pin data cannot be accepted internally because the internal circuit is stopped while the operation of input gate at the pin is allowed. *5: During shut-off state, input is masked, and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. "Outputs Hi-Z" means that the pin-driving transistor is prohibited from driving, and the pin is switched to high impedance state. *6:"Input available" means that input functions can be used. If the pin is set as an input port, apply pull-up/pull-down processing or input external signals. If the pin is set as an output port, it transits to the same state as other pins. *7:Can be input in the stop/watch/time-base timer mode when the INTxR bit in external interrupt source selection register EISSR is "0" and the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. *8:Can be input in the stop/watch/time-base timer mode when the INTxR bit in external interrupt source selection register EISSR is "1" and the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. *9:Can be input in the stop/watch/time-base timer mode when the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly. Note: CM44-10144-4E During the stop mode, watch mode, or time-base timer mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the STP bit to "1" or TMD bit to "0" in the low-power consumption mode control register (LPMCR). FUJITSU SEMICONDUCTOR LIMITED 169 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.7 Pin State in the Standby Mode and at the Time of Reset MB90860E Series ■ Input/Output Pin State (8-bit Access Mode) Table 8.7-3 Input/output Pin State (8-bit Access Mode) During stop/watch/ time-base timer Pin name During sleep During hold SPL=0 P07 to P00 (AD07 to AD00) P17 to P10 (AD15 to AD08) Input unavailable/ Outputs Hi-Z SPL=1 Shuts off input/Outputs Hi-Z Input unavailable/ Outputs Hi-Z P27 to P20 (A23 to A16) Output state *1, *3 Output state *1, *3 Input unavailable/ Outputs Hi-Z *3 P37(CLK) Input unavailable/ Output available *2,*3 Input unavailable/ Output state *1, *3 Input unavailable/ Output available*2, *3 P36(RDY) P35(HAK) P34(HRQ) Keeps the previous state*4 Shuts off input/Keeps the previous state*4 Shuts off input/ Outputs Hi-Z *5 Input unavailable/ Outputs Hi-Z *3 P32(WR) Outputs "H"*3 Outputs "H"*3 Input unavailable/ Outputs Hi-Z *3 P31(RD) Outputs "H" Outputs "H" P30(ALE) Outputs "L" Outputs "L" Keeps the previous state*4 Output state*1 Keeps the previous address Input unavailable/ Outputs Hi-Z Outputs Hi-Z/ Outputs Hi-Z/ Input available Input available Inputs "1"*3 Keeps the previous state*4 Shuts off input/ Keeps the previous state*4 At the time of internal ROM access after accessing external ROM Outputs Hi-Z/ Outputs Hi-Z/ Input available Input available Outputs "L"*3 P33 P47 to P43, P41, P40 P57 to P50 P67 to P60 P87 to P85, P83*7 P97 to P90 PA1 At the time of internal ROM At the time of access after reset canceling reset Input unavailable/ Outputs Hi-Z Outputs "H" Outputs "H" Outputs "H" Outputs "L" Outputs "L" Outputs "L" Keeps the previous state*4 Input unavailable/ Outputs Hi-Z Outputs Hi-Z/ Outputs Hi-Z/ Input available Input available P77 to P70*9 PA0, P42, P82 to P80, P84*8 170 Input available*6 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.7 Pin State in the Standby Mode and at the Time of Reset *1: "Output state" means that the fixed value of "H" level or "L" level will be output because the internal circuit stops operating while the pin-driving transistor is allowed to drive. If the output function is being used while internal peripheral circuits are operating, the output fluctuates except at the time of reset. (There is no output fluctuation at the time of reset.) *2: "Output available" means that operation data will be output to pins because the internal circuit operation is allowed and the pindriving transistor is driving. *3: If it is used as an output port, the value just previously output will be kept. *4: If the state immediately before transiting to a standby mode is output or input as is, this means "Input unavailable". This means that if an outputting peripheral function is operating, output is obtained according to the state of the peripheral function, and if output is obtained from an output pin, the output will be retained. "Input unavailable" means that the pin data cannot be accepted internally because the internal circuit is stopped while the operation of input gate at the pin is allowed. *5: During shut-off state, input is masked, and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. "Outputs Hi-Z" means that the pin-driving transistor is prohibited from driving, and the pin is switched to high impedance state. *6: "Input available" means that input functions can be used. If the pin is set as an input port, apply pull-up/pull-down processing or input external signals. If the pin is set as an output port, it transits to the same state as other pins. *7: Can be input in the stop/watch/time-base timer mode when the INTxR bit in external interrupt source selection register EISSR is "0" and the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. *8: Can be input in the stop/watch/time-base timer mode when the INTxR bit in external interrupt source selection register EISSR is "1" and the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. *9: Can be input in the stop/watch/time-base timer mode when the DTP/external interrupt is enabled (ENIR:EN=1). In other settings, the input is masked and the "L" level will be sent inwardly. Note: CM44-10144-4E During the stop mode, watch mode, or time-base timer mode, in order to set the pin sharing a port with peripheral functions to high impedance state, after prohibiting the output by peripheral functions, set the STP bit to "1" or TMD bit to "0" in the low-power consumption mode control register (LPMCR). FUJITSU SEMICONDUCTOR LIMITED 171 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.8 Notes on Using the Low-power Consumption Mode 8.8 MB90860E Series Notes on Using the Low-power Consumption Mode Take notice of the following points when using the low-power consumption mode. ■ Switching to the Standby Mode Even if "0" is set to the TMD bit or "1" is set to the STP and SLP bits of the low-power consumption mode control register (LPMCR) while peripheral functions generate interrupt requests to the CPU, the modes do not switch to their standby modes (do not switch even after finishing interrupt processing). While the CPU is processing interrupts, the interrupt request flags being processed will be cleared, and the mode is ready to switch to the standby mode unless other interrupt requests exist. ■ Notes on Switching to the Standby Mode Follow the instructions below to change the pin that shares a port with other peripheral functions to high impedance state during the stop mode, watch mode, or time-base timer mode. 1) Prohibit output by peripheral functions. 2) In the low-power consumption mode control register (LPMCR), set the SPL bit to "1", STP bit to "1", or TMD bit to "0". ■ Canceling by the Interrupt of Standby Mode During the sleep mode, watch mode, time-base timer mode, or stop mode, if an interrupt request with interrupt level (IL) higher than seven is generated by the operating peripheral functions and an external interrupt, the standby mode will be canceled. Canceling of the standby mode by an interrupt is independent of whether the CPU accepts the interrupt or not. Note: If you do not want to branch to interrupt processing after the returning from the standby mode, take measures such as prohibiting an interrupt before setting the standby mode. ■ Notes on Canceling the Standby Mode Before entering into the stop mode, the standby mode can be canceled by inputting according to the settings of input source of external interrupt. "H" level, "L" level, rising edge, and falling edge are available for the input source. ■ Oscillation Stabilization Wait Time ● Main clock oscillation stabilization wait time Because the main clock oscillation is stopped during the sub clock mode, watch mode, and stop mode, a main clock oscillation stabilization wait time has to be secured. The WS1 and WS0 bits in the clock selection register (CKSCR) set the oscillation stabilization wait time. 172 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.8 Notes on Using the Low-power Consumption Mode MB90860E Series ● Sub clock oscillation stabilization wait time Because the sub clock (SCLK) oscillation is stopped during the sub stop mode, a sub clock oscillation stabilization wait time has to be secured. The oscillation stabilization wait time is fixed at 214/SCLK (SCLK: Sub clock). ● PLL clock oscillation stabilization wait time During the main clock mode, because the PLL multiplier circuit is stopped, a PLL clock oscillation stabilization wait time has to be secured when switching to the PLL clock mode. During the PLL clock oscillation stabilization wait time, the main clock operates. At the time the mode is switched from the main clock mode to PLL clock mode, the PLL clock oscillation stabilization wait time is fixed at 214/HCLK (HCLK: oscillation clock). During the sub clock mode, a main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time have to be secured when switching to the PLL clock mode because the main clock and PLL multiplier circuits are stopped. The oscillation stabilization wait time in this case bases upon the values set in the oscillation stabilization wait time selection bit in the clock selection register (CKSCR:WS1, WS0), and the main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time will be counted together. Therefore, set a value to the "CKSCR:WS1, WS0" bit in line with the longest one of the oscillation stabilization wait times. However, because 214/HCLK or more is needed for the PLL clock oscillation stabilization wait time, set 10B or 11B to the "CKSCR: WS1, WS0" bit. During the PLL stop mode, a main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time have to be secured when returning from the PLL stop mode because the main clock and PLL multiplier circuits are stopped. The oscillation stabilization wait time in this case bases upon the values set in the oscillation stabilization wait time selection bit in the clock selection register (CKSCR:WS1, WS0), and the main clock oscillation stabilization wait time and PLL clock oscillation stabilization wait time will be counted together. Therefore, set a value to the "CKSCR:WS1, WS0" bit in line with the longest one of the oscillation stabilization wait times. However, because 214/HCLK or more is needed for the PLL clock oscillation stabilization wait time, set 10B or 11B to the "CKSCR: WS1, WS0" bit. ■ Clock Mode Switch When the clock mode has been switched, do not again switch to the low-power consumption mode or other clock modes before the switching completes. The completion of switching can be checked by referring to the MCM bit and SCM bit in the clock selection register (CKSCR). If a mode is switched again to other clock modes or the low-power consumption mode before the first switching is finished, the second switching may not complete. ■ Notes on Accessing the Low-power Consumption Mode Control Register (LPMCR) for Switching to the Standby Mode ● When accessing the low-power consumption mode control register (LPMCR) using an assemble language Use the instructions in Table 8.3-2 to configure the settings for switching to the standby mode in the lowpower consumption mode control register (LPMCR). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 173 CHAPTER 8 LOW-POWER CONSUMPTION MODE 8.8 Notes on Using the Low-power Consumption Mode MB90860E Series Immediately after using the standby mode transition instructions in Table 8.3-2, be sure to add the instructions shown in the dotted square below. MOV LPMCR, #H’xx ; Low-power consumption mode transition instruction in Table 8.3-2 NOP NOP JMP $+3 ; Jump to next instruction MOV A, #H’10 ; Any instruction If instruction lines other than shown in the dotted square are added, operations after canceling the standby mode will not be assured. ● When accessing the low-power consumption mode control register (LPMCR) using C language Use one of the following instructions 1 to 3 to configure the settings for switching to the standby mode in the low-power consumption mode control register (LPMCR). 1. Prepare a function for the instruction to be switched to the standby mode, and insert two "__wait_nop()" built-in functions behind the standby mode transition instruction. If there is a possibility that an interrupt except a standby returning interrupt may occur within the function, optimize the program while compiling to prevent the occurrence of LINK/UNLINK instructions. Example (Transition function to the watch mode or time-base timer mode) void enter_watch(){ IO_LPMCR.byte = 0x10; /* Set the TMD bit of LPMCR to 0 */ __wait_nop(); __wait_nop(); } 2. Write an instruction to switch to the standby mode using the "__asm" statement, and insert two NOP and a JMP instructions behind the standby mode transition instruction. Example (Transition to the sleep mode) __asm( " MOV I:_IO_LPMCR, #H’58"); /* Set 1 to the SLP bit of LPMCR */ __asm( " NOP"); __asm( " NOP"); __asm( " JMP $+3"); /* Jump to next instruction */ 3. Write an instruction to switch to the standby mode between "#pragma asm" and "#pragma endasm", and insert two NOP and a JMP instructions behind the standby mode transition instruction. Example (Transition to the stop mode) #pragma asm MOV I:_IO_LPMCR, #H’98 /* Set 1 to the STP bit of LPMCR */ NOP NOP JMP $+3 /* Jump to next instruction */ #pragma endasm 174 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE This chapter explains the functions and operations of the memory access mode. 9.1 Overview of the Memory Access Mode 9.2 External Memory Access (Bus Pin Control Circuit) 9.3 External Memory Access Control Signal Operations CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 175 CHAPTER 9 MEMORY ACCESS MODE 9.1 Overview of the Memory Access Mode 9.1 MB90860E Series Overview of the Memory Access Mode F2MC-16LX has several modes for access methods and access areas. ■ Overview of the Memory Access Mode Table 9.1-1 Mode Pins and Their Modes Operation mode Bus mode Access mode − Single chip 8-bit Internal ROM external bus RUN 16-bit 8-bit External ROM external bus 16-bit Flash programming − − ● Operation mode Operation mode refers to a mode that controls the operation states of devices. It is specified by the MDx mode setting pin and the Mx bit in mode data. Selecting an operation mode allows to start a normal operations or write to a flash memory. ● Bus mode Bus mode refers to a mode that controls the operations of internal ROM and external access functions. It is specified by the mode setting pins (MD2 to MD0) and the Mx bit in mode data. The mode setting pins (MD2 to MD0) specifies the bus mode when it reads reset vectors and mode data, and the Mx bit in mode data specifies the bus mode in normal operations. ● Access mode Access mode refers to a mode that controls external data bus widths. It is specified by the MDx mode setting pin and the S0 bit in mode data. Selecting an access mode specifies the length of external data bus, either 8-bit or 16-bit. 176 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.1 Overview of the Memory Access Mode MB90860E Series 9.1.1 Mode Pin By combining the three external pins MD2 to MD0, the operations shown in Table 9.1-2 can be specified. ■ Mode Pin Table 9.1-2 Mode Pins and Their Modes Mode pin setting Mode name Reset vector access area External data bus width MD2 MD1 MD0 0 0 0 External vector mode 0 External 8-bit 0 0 1 External vector mode 1 External 16-bit 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 Flash serial writing* − − 1 1 1 Flash memory − − Note Reset vector 16-bit bus width access Specification not allowed Internal vector mode Internal (Mode data) Mode data will control after reset sequence Specification not allowed Mode when using parallel writer *: Serial writing to a flash memory cannot be done by the mode pin settings alone. Other pin settings are required. See "CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS" for details. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 177 CHAPTER 9 MEMORY ACCESS MODE 9.1 Overview of the Memory Access Mode 9.1.2 MB90860E Series Mode Data Mode data is stored in FFFFDFH of the main memory and used to control CPU operations. During the reset sequence, this data is fetched in the mode register in the device. It is the reset sequence only that can change the mode register values. The settings by this register will be enabled after the reset sequence. Be sure to set "0" to the reserved bit. ■ Mode Data Figure 9.1-1 Mode Data Configuration 7 Address: FFFFDFH M1 6 5 4 M0 Reserved Reserved 3 2 1 0 S0 Reserved Reserved Reserved [bit7, bit6] M1, M0 (Bus mode setting bits) M1 and M0 are the bits that specify the operation mode after the reset sequence. The relationship between the M1 and M0 bit and their functions is shown in Table 9.1-3. Table 9.1-3 Functions of M1 and M0 (Bus Mode Setting Bits) M1 M0 Function 0 0 Single chip mode 0 1 Internal ROM - external bus mode 1 0 External ROM - external bus mode 1 1 Setting not allowed Note [bit3] S0 (Bus mode setting bit) S0 is the bit to specify the bus mode and access mode after the reset sequence. The relationship between the S0 bit and its functions is shown in Table 9.1-4. Table 9.1-4 Functions of S0 (Mode Setting Bit) S0 178 Function 0 External data bus 8-bit mode 1 External data bus 16-bit mode FUJITSU SEMICONDUCTOR LIMITED Note CM44-10144-4E MB90860E Series 9.1.3 Memory Space by Bus Mode CHAPTER 9 MEMORY ACCESS MODE 9.1 Overview of the Memory Access Mode Figure 9.1-2 shows the correspondence between access areas and their physical addresses specified by bus modes. ■ Memory Space by Bus Mode Figure 9.1-2 Relationship Between Access Areas and Their Physical Addresses FFFFFFH ROM area ROM area ROM area ROM area (FF bank image) (FF bank image) Extended I/O area Extended I/O area Address#1 010000H 008000H Extended I/O area 007900H Address#2 RAM 000100H 0000F0H 000000H Model Generalpurpose register RAM Generalpurpose register RAM Generalpurpose register I/O I/O I/O Single chip Internal ROM external bus External ROM internal bus : Internal : External : Access not allowed Address#1 Address#2 MB90F867E/ES MB90867E/ES FE0000H 001900H MB90V340E-101/102 F80000H 007900H CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 179 CHAPTER 9 MEMORY ACCESS MODE 9.1 Overview of the Memory Access Mode MB90860E Series ■ Recommended Settings Table 9.1-5 shows the recommended setting examples for mode pins and mode data. Table 9.1-5 Recommended Setting Examples for Mode Pins and Mode Data Setting example MD2 MD1 MD0 M1 M0 S0 Single chip 0 1 1 0 0 × Internal ROM external bus mode - 16-bit bus 0 1 1 0 1 1 Internal ROM external bus mode - 8-bit bus 0 1 1 0 1 0 External ROM external bus mode - 16-bit bus - Vector 16-bit bus width 0 0 1 1 0 1 External ROM external bus mode - 8-bit bus 0 0 0 1 0 0 External pins have different signal functions for each mode. Table 9.1-6 External Pin Functions for Each Mode Function Pin name External data bus expansion Single chip Flash programming 8-bit P07 to P00 16-bit AD07 to AD00 P17 to P10 A15 to A08 AD15 to AD08 DQ07 to DQ00 AQ15 to AQ08 P27 to P20 A23 to A16* AQ07 to AQ00 P30 ALE AQ16 P31 RD CE P32 P33 Port WR* WRL* OE Port WRH* WE P34 HRQ* AQ17 P35 HAK* AQ18 P36 RDY* BYTE P37 CLK* RY/BY *: The output pins placed in a high address, WRL/WR, WRH, HRQ, HAK, RDY, and CLK pins can be used as a port by specifying a function. See Section "9.2 External Memory Access (Bus Pin Control Circuit)" for details. 180 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) MB90860E Series 9.2 External Memory Access (Bus Pin Control Circuit) The external bus pin control circuit controls the external bus pin to expand the CPU address and data bus outward. ■ External Memory Access (External Bus Pin Control Circuit) Use the address, data, and control signal as shown below to access the external memory / peripherals of this device. • CLK(P37): Machine cycle clock (KBP) output pin • RDY(P36): External ready input pin • WRH(P33): Write strobe signal for the upper 8-bit of data bus. It operates only in the 16-bit bus mode. • WRL/WR(P32): In 16-bit bus mode, it functions as a write strobe signal for the upper 8-bit of data bus. In 8-bit bus mode, it functions as a write strobe signal. • RD(P31): Read strobe signal • ALE(P30): Address latch enable signal The external bus pin control circuit controls the external bus pin and allows the CPU address and data bus to expand outward. ■ Block Diagram of External Memory Access Figure 9.2-1 External Bus Controller P0 P1 P2 P3 P0 data P3 P0 P0 direction RB Data control Address control Access control CM44-10144-4E Access control FUJITSU SEMICONDUCTOR LIMITED 181 CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) 9.2.1 MB90860E Series Register for External Memory Access (External Bus Pin Control Circuit) There are three types of register for external memory access (external bus pin control circuit). • Auto ready selection register • External address output control register • Bus control signal selection register ■ List of Registers for External Memory Access Figure 9.2-2 List of Registers for External Memory Access (External Bus Pin Control Circuit) Auto ready selection register bit 15 14 13 12 11 10 9 8 − − Read/write → W W W W − − W W Initial value → 0 0 1 1 × × 0 0 Address: 0000A5H IOR1 IOR0 HMR1 HMR0 LMR1 LMR0 ARSR External address output control register bit Address: 0000A6H 7 6 5 4 3 2 1 0 E23 E22 E21 E20 E19 E18 E17 E16 Read/write → W W W W W W W W Initial value → 0 0 0 0 0 0 0 0 12 11 10 9 8 HACR Bus control signal selection register bit Address: 0000A7H 15 14 13 CKE RYE HDE IOBS HMBS WRE LMBS − Read/write → W W W W W W W − Initial value → 0 0 0 0 0 0 0 × ECSR W: Write only 182 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) MB90860E Series 9.2.2 Auto Ready Selection Register (ARSR) Auto ready selection register (ARSR) sets an auto wait time of memory access for each area when externally accessing. ■ Auto Ready Selection Register (ARSR) Figure 9.2-3 Configuration of Auto Ready Selection Register Auto ready selection register bit Address: 0000A5H 15 IOR1 14 13 12 IOR0 HMR1 HMR0 11 10 − − 9 8 LMR1 LMR0 Read/write W W W W − − W W Initial value 0 0 1 1 × × 0 0 ARSR W: Write only [bit15, bit14] IOR1, IOR0 The IOR1 and IOR0 bit specifies the auto wait function when the 0000F0H to 0000FFH area is accessed externally. The combination of IOR1 and IOR0 bit configures the settings as shown in Table 9.2-1. Table 9.2-1 Functions of IOR1 and IOR0 (Auto Wait Function Specification Bit) IOR1 IOR0 Function 0 0 Auto wait prohibited [Initial value] 0 1 Auto wait of 1 cycle is inserted during external access 1 0 Auto wait of 2 cycles is inserted during external access 1 1 Auto wait of 3 cycles is inserted during external access [bit13, bit12] HMR1, HMR0 The HMR1 and HMR0 specify the auto wait function when the 800000H to FFFFFFH area is accessed externally. The combination of HMR1 and HMR0 bit configures the settings as shown in Table 9.2-2. Table 9.2-2 Functions of HMR1 and HMR0 (Auto Wait Function Specification Bit) CM44-10144-4E HMR1 HMR0 Function 0 0 Auto wait prohibited 0 1 Auto wait of 1 cycle is inserted during external access 1 0 Auto wait of 2 cycles is inserted during external access 1 1 Auto wait of 3 cycles is inserted during external access [Initial value] FUJITSU SEMICONDUCTOR LIMITED 183 CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) MB90860E Series [bit9, bit8] LMR1, LMR0 The LMR1 and LMR0 specifies the auto wait function when the 008000H to 7FFFFFH area is accessed externally. The combination of LMR1 and LMR0 bit configures the settings as shown in Table 9.2-3. Table 9.2-3 Functions of LMR1 and LMR0 (Auto Wait Function Specification Bit) 184 LMR1 LMR0 Function 0 0 Auto wait prohibited [Initial value] 0 1 Auto wait of 1 cycle is inserted during external access 1 0 Auto wait of 2 cycles is inserted during external access 1 1 Auto wait of 3 cycles is inserted during external access FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) MB90860E Series 9.2.3 External Address Output Control Register (HACR) The external address output control register (HACR) is a register to control the external output by the addresses (A23 to A16). Each bit corresponds to the address A23 to A16 and controls each address output pin as shown in Figure 9.2-4. All bits of this register are write-only. "1" will be used for read. ■ External Address Output Control Register (HACR) Figure 9.2-4 Configuration of External Address Output Control Register External address output control register bit Address: 0000A6H 7 6 5 4 3 2 1 0 E23 E22 E21 E20 E19 E18 E17 E16 Read/write → W W W W W W W W Initial value → 0 0 0 0 0 0 0 0 HACR W: Write only The HACR register controls the output for the addresses (A23 to A16) that lead to external circuits. The eight bits correspond to the addresses A23 to A16 and control the address output pin as shown below. The HACR register cannot access when the device is in the single chip mode. In this case, all pins function as I/O ports regardless of the values in this register. All bits of this register are write-only. "1" will be used for read. Table 9.2-4 Functions of External Address Output Control Register (E23 to E16 Bit) CM44-10144-4E 0 Pins correspond to address outputs (AXX). [Initial value] 1 Pins correspond to I/O port (P2X). Set this bit to "1" if it is used as a peripheral resource. FUJITSU SEMICONDUCTOR LIMITED 185 CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) 9.2.4 MB90860E Series Bus Control Signal Selection Register (ECSR) Bus control signal selection register (ECSR) is a register to set the control functions of bus operations in the external bus mode. It cannot access when the device is in the single chip mode. In this case, all pins function as I/O ports regardless of the values in this register. All bits of bus control signal selection register are write-only. "1" will be used for read. ■ Bus Control Signal Selection Register (ECSR) Figure 9.2-5 Configuration of Bus Control Signal Selection Register Bus control signal selection register bit Address: 0000A7H 15 14 13 CKE RYE HDE 12 11 10 9 IOBS HMBS WRE LMBS 8 − Read/write → W W W W W W W − Initial value → 0 0 0 0 0 0 0 × ECSR W: Write only [bit15] CKE The CKE bit controls the output of external clock signal pin (CLK) as shown in Table 9.2-5. Table 9.2-5 Functions of CKE (External Clock (CLK) Output Control Bit) 0 I/O port (P37) operation (Clock output prohibited) [Initial value] 1 Clock signal (CLK) output allowed [bit14] RYE The RYE bit controls the input of external ready (RDY) signal pin as shown in Table 9.2-6. Table 9.2-6 Functions of RYE (External Ready (RDY) Input Control Bit) 0 I/O port (P36) operation (External RDY input prohibited) [Initial value] 1 External ready (RDY) input allowed [bit13] HDE The HDE bit specifies the input/output allowance for hold-related signals. The settings of HDE bit will control the hold request input signal (HRQ) and hold acknowledgment output signal (HAK) as shown in Table 9.2-7. 186 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) MB90860E Series Table 9.2-7 Functions of HDE (Input/Output Allowance Specification Bit for Hold-related Pin) 0 I/O port (P35, P34) operation (Hold function input/output prohibited) [Initial value] 1 Hold request (HRQ) input/Hold acknowledgment (HAK) output allowance [bit12] IOBS The IOBS bit specifies the bus width when the area 0000F0H to 0000FFH is externally accessed during the external data bus 16-bit mode. Table 9.2-8 shows the control by the setting of this bit. Table 9.2-8 IOBS (Bus Width Specification Bit) 0 16-bit bus width access [Initial value] 1 8-bit bus width access [bit11] HMBS The HMBS bit specifies the bus width when the area 800000H to FFFFFFH is externally accessed during the external data bus 16-bit mode. Table 9.2-9 shows the control by the setting of this bit. Table 9.2-9 Functions of HMBS (Bus Width Specification Bit) 0 16-bit bus width access [Initial value] 1 8-bit bus width access [bit10] WRE The WRE bit controls the output of external write signal (both WRH and WRL pins, in the case of external data bus 16-bit mode, and WR pin, in the case of external data bus 8-bit mode) as shown in Table 9.2-10. When in the external data bus 8-bit mode, P33 functions as an I/O port, regardless of the value set in this bit. Table 9.2-10 Functions of WRE (External Write Signal Output Control Bit) CM44-10144-4E 0 I/O port (P33, P32) operation (Write signal output prohibited) [Initial value] 1 Write strobe signal (both WRH and WRL, or WR only) allowed to output FUJITSU SEMICONDUCTOR LIMITED 187 CHAPTER 9 MEMORY ACCESS MODE 9.2 External Memory Access (Bus Pin Control Circuit) MB90860E Series [bit9] LMBS The LMBS bit specifies the bus width when the area 002000H to 7FFFFFH is externally accessed during the external data bus 16-bit mode. Table 9.2-11 shows the control by the setting of this bit. Table 9.2-11 Functions of LMBS (Bus Width Specification Bit) Notes: 188 0 16-bit bus width access [Initial value] 1 8-bit bus width access • When in the external data bus 16-bit mode, switch P33 and P32 to an input mode if the WR, WRH, and WRL functions are allowed with the WRE bit (Set the bit3 and bit2 in DDR3 register to "0"). • When in the external data bus 8-bit mode, switch P32 to an input mode if the WR function is allowed with the WRE bit (Set the bit2 in DDR3 register to "0"). • Even if RDY and HRQ signal input is allowed with the RYE and HDE bits, the I/O port function of this port will be enabled. Therefore, be sure to write "0" (input mode) in the DDR3 register that corresponds to the port. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.3 External Memory Access Control Signal Operations MB90860E Series 9.3 External Memory Access Control Signal Operations External memory will be accessed in three cycles if the ready function is not used. The 8-bit bus width access in the external 16-bit bus mode is a function to read from and writes to peripheral chips with 8-bit width when peripheral chips with 8-bit width and 16bit width are connected to an external bus in a mixed manner. ■ External Memory Access Control Signal The HMBS/LMBS/IOBS bits in ECSR register specify whether the 16-bit bus width access or the 8-bit bus width access will be performed in the external data bus 16-bit mode. Note that bus operations may not actually be performed by only outputting addresses and ALE signal asserts, and by not asserting RD/WRL/WRH/WR. Be careful not to perform access to peripheral chips using ALE signal only. Figure 9.3-1 Access Timing Chart in the External Data Bus 8-bit Mode Read Write Read P37/CLK P33/WRH (Port data) P32/WRL/WR P31/RD P30/ALE P27 to 20/A23 to 16 Read address Write address Read address P17 to 10/A15 to 08 Read address Write address Read address P07 to 00/AD07 00 Read address Write address Read data CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED Read address Write data 189 CHAPTER 9 MEMORY ACCESS MODE 9.3 External Memory Access Control Signal Operations MB90860E Series Figure 9.3-2 Access Timing Chart in the External Data Bus 16-bit Mode (16-bit Bus Width Access) 8-bit bus width bite read Even number address bite read 8-bit bus width bite write Even number address bite write P37/CLK P33/WRH P32/WRL/WR P31/RD P30/ALE Read address P27 to 20/A23 to 16 P17 to 10/AD15 to 08 Read address P07 to 00/AD07 to 00 Read address Write address Disabled (Undefined) Write address Write address Read data Read address Read address Read address Write data Odd number address bite read Odd number address bite write Read address Write address P37/CLK P33/WRH P32/WRL/WR P31/RD P30/ALE P27 to 20/A23 to 16 P17 to 10/AD15 to 08 Read address P07 to 00/AD07 to 00 Read address Write address Disabled Read address Write address (Undefined) Read address Write data Read data Even number address bite read Read address Even number address bite write P37/CLK P33/WRH P32/WRL/WR P31/RD P30/ALE Read address P27 to 20/A23 to 16 Write address P17 to 10/AD15 to 08 Read address Write address Read address P07 to 00/AD07 to 00 Read address Write address Read address Read data Note: 190 Read address Write data Set external circuits to consistently read in units of words. The settings in the P36/RYD pin and the auto ready selection register (ARSR) will allow the access to low speed memory or peripheral circuits. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.3 External Memory Access Control Signal Operations MB90860E Series 9.3.1 Ready Function The settings in the P36/RDY pin and the auto ready selection register (ARSR) will allow the access to low speed memory or peripheral circuits. If the RYE bit in the bus control signal selection register (ECSR) is set to "1", the wait cycle will be used while the "L" level is input to the P36/RDY signal during the access to an external circuit, resulting in an extended access cycle. ■ Ready Function Figure 9.3-3 Ready Function Timing Chart Even number address word read Even number address word write P37/CLK P33/WRH P32/WRL/WR P31/RD P30/ALE P27 to 20/A23 to 16 Read address Write address P17 to 10/AD15 to 08 Read address Write address P07 to 00/AD07 to 00 Read address Write address P36/RDY Read data RDY pin fetched Even number address word write Write data Even number address word read P37/CLK P33/WRH P32/WRL/WR P31/RD P30/ALE P27 to 20/A23 to 16 Write address Read address P17 to 10/AD15 to 08 Write address Address P07 to 00/AD07 to 00 Write address Address Write data Extended cycled by auto ready CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 191 CHAPTER 9 MEMORY ACCESS MODE 9.3 External Memory Access Control Signal Operations MB90860E Series MB90860E Series has two types of auto ready functions for external memory access. The auto ready function is a function that can extend access cycles by automatically inserting a wait cycle with 1 to 3 cycles without external circuits when an access is generated to lower address external areas located between address 008000H to 7FFFFFH and upper address external areas located between address 800000H to FFFFFFH. This function is enabled to start by the settings in the LMR1/LMR0 bit (lower address external area) of ARSR and the HMR1/HMR0 bit (upper address external area) of ARSR. In addition, MB90860E Series has an auto ready function for I/O independently of the one for memory. Setting "0" to the IOR1/IOR0 bit in the ARSR register will extend the access cycle by automatically inserting a wait cycle with 1 to 3 cycles without external circuits during the access to the external area between address 0000F0H to 0000FFH. If the RYE bit of either the external memory auto ready or the external I/O auto ready is set to "1", the wait cycle remains unchanged if the "L" level continues to be input to the P36/RDY after the end of wait cycle by the auto ready function described above. 192 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 9 MEMORY ACCESS MODE 9.3 External Memory Access Control Signal Operations MB90860E Series 9.3.2 Hold Function If the HDE bit in the bus control signal selection register (ECSR) is set to "1", the external address hold function by the P34/HRQ and P35/HAK pins will be enabled. ■ Hold Function Inputting the "H" level to the P34/HRQ pin will change the state to hold state after CPU instructions are finished (in the case of string instructions, after finishing processing the "1" element data), changing the state of the pins shown below to high impedance state by outputting "L" level signals from the P35/HAK pin. • Address output : P27/A23 to P20/A16 • Data input/output : P17/AD15 to P00/AD00 • Bus control signal : P30/ALE, P31/RD, P32/WRL/WR, P33/WRH This allows the use of external buses through device external circuits. If "L" level signals are input to the P34/HRQ pin, the P35/HAK pin will output "H" level, and the external pin state will be restored, causing buses to operate again. In STOP state, no hold request input will be accepted. Figure 9.3-4 Hold Timing Hold cycle Read cycle Write cycle P37/CLK P34/HRQ P35/HAK P33/WRH P32/WRL/WR P31/RD P30/ALE P27 to 20/A23 to 16 (Address) (Address) P17 to 10/AD15 to 08 (Address) P07 to 00/AD07 to 00 (Address) Read data Notes: CM44-10144-4E Write data • If "H" level is input to the P34/HRQ pin, the P34/HRQ pin shall be kept at "H" level until the P35/HAK pin reaches "L" level. • Even during the period the P35/HAK pin is at "L" level, the watchdog timer continues to operate without its timer being cleared. If the hold state continues longer than the interval time of watchdog timer set at the WT1/WT0 bit in the watchdog timer control register (WDTC), a watchdog reset will occur. FUJITSU SEMICONDUCTOR LIMITED 193 CHAPTER 9 MEMORY ACCESS MODE 9.3 External Memory Access Control Signal Operations 194 FUJITSU SEMICONDUCTOR LIMITED MB90860E Series CM44-10144-4E CHAPTER 10 I/O PORTS This chapter explains the functions of I/O ports. 10.1 I/O Ports 10.2 Register List for I/O Ports CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 195 CHAPTER 10 I/O PORTS 10.1 I/O Ports 10.1 MB90860E Series I/O Ports Each pin of I/O ports can specify to be an input or output port by setting the port data direction register (DDR), as long as corresponding peripherals are configured not to use the ports. If a pin is specified as an input, the logic level of the pin will be read. If the pin is specified as an output, the data register value will be read. This also applies to the reading of read-modify-write instruction. ■ Overview of I/O Ports Figure 10.1-1 shows the block diagram of I/O ports. Figure 10.1-1 Block Diagram of I/O Ports Internal data bus Data register read Data register Pin Data register write Direction register Direction register write Direction register read 196 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series 10.2 Register List for I/O Ports There are five types of I/O port registers. • Port data register (PDR0 to A) • Port data direction register (DDR0 to A) • Pull-up control register (PUCR0 to PUCR3) • Analog data input enabling register (ADER) • Input level selection register (ILSR) ■ Register List for I/O Ports Figure 10.2-1 shows the bit configuration of each register for I/O ports. Figure 10.2-1 Register List for I/O Ports Bit number Address: 000000H Address: 000001H Address: 000002H Address: 000003H Address: 000004H Address: 000005H Address: 000006H Address: 000007H Address: 000008H Address: 000009H Address: 00000AH Bit number Address: 000010H Address: 000011H Address: 000012H Address: 000013H Address: 000014H Address: 000015H Address: 000016H Address: 000017H Address: 000018H Address: 000019H Address: 00001AH Bit number Address: 00001CH Address: 00001DH Address: 00001EH Address: 00001FH Bit number Address: 00000BH Address: 00000CH Address: 00000DH Bit number Address: 00000EH Address: 00000FH CM44-10144-4E 7 6 5 4 3 2 1 0 P07 P06 P05 P04 P03 P02 P01 P00 P17 P16 P15 P14 P13 P12 P11 P10 P27 P26 P25 P24 P23 P22 P21 P20 P37 P36 P35 P34 P33 P32 P31 P30 P47 P46 P45 P44 P43 P42 P41 P40 P57 P56 P55 P54 P53 P52 P51 P50 P67 P66 P65 P64 P63 P62 P61 P60 P77 P76 P75 P74 P73 P72 P71 P70 P87 P86 P85 P84 P83 P82 P81 P80 P97 P96 P95 P94 P93 P92 P91 P90 PA1 PA0 7 6 5 4 3 1 0 D07 D06 D05 D04 D03 D02 D01 D00 D17 D16 D15 D14 D13 D12 D11 D10 D27 D26 D25 D24 D23 D22 D21 D20 D37 D36 D35 D34 D33 D32 D31 D30 D47 D46 D45 D44 D43 D42 D41 D40 D57 D56 D55 D54 D53 D52 D51 D50 D67 D66 D65 D64 D63 D62 D61 D60 D77 D76 D75 D74 D73 D72 D71 D70 D87 D86 D85 D84 D83 D82 D81 D80 D97 D96 D95 D94 D93 D92 D91 D90 SIL4 SIL3 SIL2 SIL1 SIL0 DA1 DA0 7 6 1 0 5 4 3 2 2 PU07 PU06 PU05 PU04 PU03 PU02 PU01 PU00 PU17 PU16 PU15 PU14 PU13 PU12 PU11 PU10 PU27 PU26 PU25 PU24 PU23 PU22 PU21 PU20 PU37 PU36 PU35 PU34 PU33 PU32 PU31 PU30 15/7 14/6 13/5 12/4 11/3 10/2 9/1 ADE15 ADE14 ADE13 ADE12 ADE11 ADE10 ADE9 ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 14/6 13/5 12/4 11/3 IL3 IL7 IL6 IL5 IL4 ILT3 ILT2 ILT1 ILT0 10/2 9/1 Port 0 data direction register (DDR0) Port 1 data direction register (DDR1) Port 2 data direction register (DDR2) Port 3 data direction register (DDR3) Port 4 data direction register (DDR4) Port 5 data direction register (DDR5) Port 6 data direction register (DDR6) Port 7 data direction register (DDR7) Port 8 data direction register (DDR8) Port 9 data direction register (DDR9) Port A data direction register (DDRA) Port 0 Pull-up control register (PUCR0) Port 1 Pull-up control register (PUCR1) Port 2 Pull-up control register (PUCR2) Port 3 Pull-up control register (PUCR3) 8/0 ADE8 Port 5 Analog data input enabling register (ADER5) ADE0 Port 6 Analog data input enabling register (ADER6) ADE23 ADE22 ADE21 ADE20 ADE19 ADE18 ADE17 ADE16 15/7 Port 0 data register (PDR0) Port 1 data register (PDR1) Port 2 data register (PDR2) Port 3 data register (PDR3) Port 4 data register (PDR4) Port 5 data register (PDR5) Port 6 data register (PDR6) Port 7 data register (PDR7) Port 8 data register (PDR8) Port 9 data register (PDR9) Port A data register (PDRA) Port 7 Analog data input enabling register (ADER7) 8/0 IL2 IL1 IL0 ILA IL9 IL8 Input level selection register (ILSR0) Input level selection register (ILSR1) FUJITSU SEMICONDUCTOR LIMITED 197 CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports 10.2.1 MB90860E Series Port Data Register (PDR0 to PDRA) The reading and writing of I/O port operate differently from those of memory, as described below. • Input mode When reading : Corresponding pin labels will be read. When writing : Written to the latch for output. • Output mode When reading : The value of data register latch will be read. When writing : Written to the latch for output, and output to the corresponding pin. Figure 10.2-2 shows the details of bit configuration for the port data register (PDR). ■ Port Data Register (PDR) Figure 10.2-2 Port Data Register (PDR) Bit number PDR0 Address: 000000H Bit number PDR1 Address: 000001H Bit number PDR2 Address: 000002H Bit number PDR3 Address: 000003H Bit number PDR4 Address: 000004H Bit number PDR5 Address: 000005H Bit number PDR6 Address: 000006H Bit number PDR7 Address: 000007H Bit number PDR8 Address: 000008H Bit number PDR9 Address: 000009H Bit number PDRA Address: 00000AH 198 7 6 5 4 3 2 1 0 Initial value Access P07 P06 P05 P04 P03 P02 P01 P00 XXXXXXXXB R/W 7 6 5 4 3 2 1 0 P17 P16 P15 P14 P13 P12 P11 P10 XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W XXXXXXXXB R/W 7 6 5 4 3 2 1 0 P27 P26 P25 P24 P23 P22 P21 P20 7 6 5 4 3 2 1 0 P37 P36 P35 P34 P33 P32 P31 P30 7 6 5 4 3 2 1 0 P47 P46 P45 P44 P43 P42 P41 P40 7 6 5 4 3 2 1 0 P57 P56 P55 P54 P53 P52 P51 P50 7 6 5 4 3 2 1 0 P67 P66 P65 P64 P63 P62 P61 P60 7 6 5 4 3 2 1 0 P77 P76 P75 P74 P73 P72 P71 P70 7 6 5 4 3 2 1 0 P87 P86 P85 P84 P83 P82 P81 P80 7 6 5 4 3 2 1 0 P97 P96 P95 P94 P93 P92 P91 P90 7 6 5 4 3 2 1 0 PA1 PA0 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series ■ Reading of the Port Data Register The value obtained at the time of reading the port data register (PDR) depends on the state of port data direction register (DDR) and the state of peripheral functions connected to the pins. The values obtained for each combination are shown in Table 10.2-1 and Table 10.2-2. Table 10.2-1 Reading value of the port data register for port 3 to port 0 DDR value Output state of peripheral functions Read value 0 (input) Enabled Output value from peripheral functions 1 (output) Enabled Value of output latch (PDR) 0 (input) Disabled Pin state 1 (output) Disabled Value of output latch (PDR) Table 10.2-2 Reading value of the port data register for port A to port 4 DDR value Output state of peripheral functions Read value 0 (input) Enabled Output value from peripheral functions 1 (output) Enabled Output value from peripheral functions 0 (input) Disabled Pin state 1 (output) Disabled Value of output latch (PDR) Set the DDR of connected pin to 0 (input), when it is used as an input in peripheral functions. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 199 CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports 10.2.2 MB90860E Series Port Data Direction Register (DDR0 to DDRA) The port data direction register has the following functions. • Sets the data direction for the pin used as a port. • Sets the input level of the SIN (Serial input of LIN-UART) pin. ■ Port Data Direction Register (DDR0 to DDRA) Figure 10.2-3 shows the details of bit configuration for the port data direction register (DDR0 to DDRA). Figure 10.2-3 Port Data Direction Register (DDR0 to DDRA) Bit number DDR0 Address: 000010H Bit number DDR1 Address: 000011H Bit number DDR2 Address: 000012H Bit number DDR3 Address: 000013H Bit number DDR4 Address: 000014H Bit number DDR5 Address: 000015H Bit number DDR6 Address: 000016H Bit number DDR7 Address: 000017H Bit number DDR8 Address: 000018H Bit number DDR9 Address: 000019H Bit number DDRA Address: 00001AH 7 6 5 4 3 2 1 0 D07 D06 D05 D04 D03 D02 D01 D00 7 6 5 4 3 2 1 0 D17 D16 D15 D14 D13 D12 D11 D10 7 6 5 4 3 2 1 0 D27 D26 D25 D24 D23 D22 D21 D20 7 6 5 4 3 2 1 0 D37 D36 D35 D34 D33 D32 D31 D30 7 6 5 4 3 2 1 0 D47 D46 D45 D44 D43 D42 D41 D40 7 6 5 4 3 2 1 0 D57 D56 D55 D54 D53 D52 D51 D50 7 6 5 4 3 2 1 0 D67 D66 D65 D64 D63 D62 D61 D60 7 6 5 4 3 2 1 0 D77 D76 D75 D74 D73 D72 D71 D70 7 6 5 4 3 2 1 0 D87 D86 D85 D84 D83 D82 D81 D80 7 6 5 4 3 2 1 0 D97 D96 D95 D94 D93 D92 D91 D90 7 6 5 4 3 2 SIL4 SIL3 SIL2 SIL1 SIL0 W W W W W 1 0 DA1 DA0 R/W R/W Initial value Access 00000000B R/W 00000000B R/W 00000000B R/W 00000000B R/W 00000000B R/W 00000000B R/W 00000000B R/W 00000000B R/W 00000000B R/W 00000000B R/W 00000100B R/W [bit7 to bit0] D00 to D97: DDR0 to DDRA These bits set the input and output directions for ports. If pins are used as ports, the corresponding pins are controlled in the manner as follows. When set to "0": Sets the corresponding pins to input mode. When set to "1": Sets the corresponding pins to output mode. 200 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series [bit7 to bit3] SIL4 to SIL0:DDRA (bit7 to bit3) These bits forcefully set the input level of the SIN (Serial input of LIN-UART) pin. SIL0 to SIL4 correspond to SIN0 (LIN-UART0) to SIN4 (LIN-UART4), respectively. When set to "0": The ILTx bit settings and the ILx bit to which ILSR corresponds will select CMOS, automotive, or TTL for the input level. See Section "10.2.5 Input Level Selection Register (ILSR0, ILSR1)" for details of ILSR. When set to "1": CMOS will be selected for the input level, independently of the ILx bit and its setting corresponding to ILSR. The initial value for these bits is "0". Table 10.2-3 SIN0/SIN1 Input Level Settings DDRA ILSR SIL0/SIL1 bit IL8 bit 0 0 Automotive level 0 1 CMOS level 1 x CMOS level SIN0(P82) / SIN1(P85) input level Table 10.2-4 SIN2 Input Level Settings DDRA ILSR SIL2 bit IL5 bit 0 0 Automotive level 0 1 CMOS level 1 x CMOS level SIN2(P50) input level Table 10.2-5 SIN3/SIN4 Input Level Settings DDRA ILSR SIN3(P12) / SIN4(P15) input level Note: CM44-10144-4E SIL3/SIL4 bit ILT1 bit IL1 bit 0 0 0 Automotive level 0 0 1 CMOS level 0 1 x TTL level 1 x x CMOS level SIL0 to SIL4 bits are for writing only. When these bits are read, "1" is consistently read. Therefore, do not use instructions such as INC/DEC instruction that perform read-modify-write (RMW) to DDRA registers. FUJITSU SEMICONDUCTOR LIMITED 201 CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series [bit3] DDRA: Unused bit "1" is consistently read from this bit. Writing to this bit does not have any effect. 202 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series 10.2.3 Pull-up Control Register (PUCR0 to PUCR3) Each pin for port 0 to 3 has a programmable pull-up resistor. Each bit of this register will control whether or not use the corresponding pull-up resistor. Figure 10.2-4 shows the bit configuration for the pull-up control register (PUCR0 to PUCR3), and Figure 10.2-5 shows the block diagram for it. ■ Pull-up Control Register (PUCR0 to PUCR3) Figure 10.2-4 Bit Configuration for the Pull-up Control Register (PUCR0 to PUCR3) Address: 00001CH Read/Write Initial value Address: 00001DH Read/Write Initial value Address: 00001EH Read/Write Initial value Address: 00001FH Read/Write Initial value 7 6 5 4 3 2 1 0 PU07 PU06 PU05 PU04 PU03 PU02 PU01 PU00 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 15 14 13 12 11 10 9 8 PU17 PU16 PU15 PU14 PU13 PU12 PU11 PU10 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 7 6 5 4 3 2 1 0 PU27 PU26 PU25 PU24 PU23 PU22 PU21 PU20 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 15 14 13 12 11 10 9 8 PU37 PU36 PU35 PU34 PU33 PU32 PU31 PU30 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 R/W 0 Bit number PUCR0 Bit number PUCR1 Bit number PUCR2 Bit number PUCR3 R/W: Readable/writable ■ Block Diagram for the Pull-up Control Register (PUCR0 to PUCR3) Figure 10.2-5 Block Diagram for the Pull-up Control Register (PUCR0 to PUCR3) Data register Pull-up resistor (about 50 kΩ) P-ch Port input/output Direction register Pull-up control register Internal data bus Controls the pull-up resistor during input mode. When set to "0": No pull-up resistor during input mode. When set to "1": Pull-up resistor during input mode. Note: CM44-10144-4E This is not applied for the output mode (no pull-up resistor). The port data direction register (DDR) determines the I/O mode. When in the stop mode (SPL=1), no pull-up resistor (High impedance). If a port is used as an external bus, this function is disabled, and no data will be written to the register. FUJITSU SEMICONDUCTOR LIMITED 203 CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series Analog Data Input Enabling Register (ADER5 to ADER7) 10.2.4 Figure 10.2-6 shows the bit configuration of the analog data input enabling register (ADER5 to ADER7). ■ Analog Data Input Enabling Register (ADER5 to ADER7) Figure 10.2-6 Bit Configuration for the Analog Data Input Enabling Register (ADER5 to ADER7) ADER7 bit Address: 00000DH ADER6 bit Address: 00000CH ADER5 bit Address: 00000BH 15 14 13 12 11 10 9 8 ADE23 ADE22 ADE21 ADE20 ADE19 ADE18 ADE17 ADE16 7 6 5 4 3 2 1 0 ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 ADE0 15 14 13 12 11 10 9 8 ADE9 ADE8 ADE15 ADE14 ADE13 ADE12 ADE11 ADE10 Initial value Access 11111111B R/W 11111111B R/W 11111111B R/W R/W: Readable/writable Each bit for ADER5 to ADER7 enables and disables the analog input for the pins of Port 7 to Port 5. ADER5 to ADER7 correspond to Port 7 to Port 5, respectively. When set to "0": Analog input will be disabled at the corresponding pin. The pins with disabled analog input can be used as an I/O pin for I/O ports and peripheral functions other than an A/D converter. When set to "1": Sets the corresponding pins to the analog input mode. The pin set to the analog input mode will be a dedicated pin for analog input of an A/D converter. It cannot be used as an I/O pin for I/O ports and other peripheral functions. Note: 204 If "1" is set to the analog data input enabling bit (ADE23 to ADE0), each pin of Port 7 to Port5 will become an analog input pin for an A/D converter. Because the initial value of ADEx bit is 1, each pin of Port 7 to 5 cannot be used as an I/O port or an I/O pin of peripheral functions other than an A/D converter, if it is in the initial state. To use it as an I/O port or an I/O pin for other peripheral devices, set the ADEx bit to "0". FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series 10.2.5 Input Level Selection Register (ILSR0, ILSR1) The input level selection register allows to change the setting from the automotive hysteresis input level to the CMOS hysteresis input level or to the TTL input level. ■ Input Level Selection Register (ILSR0, ILSR1) Figure 10.2-7 Bit Configuration of the Input Level Selection Register (ILSR0, ILSR1) Address 15 14 13 12 ILSR1: 00000FH ILSR0: 00000EH ILT3 ILT2 ILT1 ILT0 Read/Write: R/W R/W R/W R/W Initial value: 0/1 0/1 0/1 0/1 R/W : Readable/writable — : Undefined 11 10 9 8 7 6 5 4 3 2 1 0 - ILA IL9 IL8 IL7 IL6 IL5 IL4 IL3 IL2 IL1 IL0 - R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W 0 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 [bit10 to bit0] ILA to IL0 These bits specify the input level of corresponding ports. IL0 to ILA correspond to Port 0 to Port A, respectively. When set to "0": Automotive input level. When set to "1": CMOS input level. The initial values for these bits depend on the settings of operation mode (mode pin). • Flash memory mode - Initial value "1" (CMOS input) • Other modes - Initial value "0" (Automotive) [bit11] Unused bit "0" is consistently read from this bit. Writing has no effect. [bit15 to bit12] ILT3 to ILT0 These bits specify the input level of corresponding ports to either TTL or CMOS/Automotive. ILT0 to ILT3 bits correspond to Port 0 to Port 3, respectively. When set to "0": The IL0 to ILA bits specify the input level of corresponding ports to either CMOS input level or automotive input level. When set to "1": Sets to TTL input level, independently of the settings in IL0 to ILA bits. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 205 CHAPTER 10 I/O PORTS 10.2 Register List for I/O Ports MB90860E Series ■ Initial Value of Input Level Selection Register (ILSR0, ILSR1) The initial values for the bits in ILSR0 and ILSR1 registers depend on the state of pin MD2, MD1, and MD0 after the external reset input is canceled, as shown the table below. See "CHAPTER 9 MEMORY ACCESS MODE" for details about the operation modes. Table 10.2-6Relationship Between the Mode Pins and the Input Level Selection Register (ILSR0, ILSR1) Initial Values Initial value MD2 MD1 MD0 Operation modes Port input level ILT0 to ILT3 IL0 to ILA Port 0 to Port 3 Port 4 to Port A 0 0 0 External vector mode 0 1 0 TTL Automotive 0 0 1 External vector mode 1 1 0 TTL Automotive 0 1 0 0 1 1 Automotive Automotive 1 0 0 1 0 1 1 1 0 Flash serial writing 0 0 Automotive Automotive 1 1 1 Flash memory 0 1 CMOS CMOS Reserved Internal vector mode 0 0 Reserved 206 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 11 TIME-BASE TIMER This chapter explains the function and operation of the time-base timer. 11.1 Overview of the Time-base Timer 11.2 Block Diagram of the Time-base Timer 11.3 Configuration of the Time-base Timer 11.4 Interrupt of the Time-base Timer 11.5 Operating Explanation of the Time-base Timer 11.6 Notes on Using the Time-base Timer 11.7 Programming Example of the Time-base Timer CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 207 CHAPTER 11 TIME-BASE TIMER 11.1 Overview of the Time-base Timer 11.1 MB90860E Series Overview of the Time-base Timer The time-base timer is an 18-bit free-run counter (time-base timer counter) that counts up in synchronization with the main clock (divide-by-two of the main oscillation clock). • Provides four different types of interval time and can generate interrupt requests for each interval time. • Provides operating clock to the oscillation stabilization wait time timer or peripheral functions. ■ Interval Timer Function • When the counter of the time-base timer reaches the interval time set at the interval time selection bits (TBTC:TBC1, TBC0), an overflow (carry) occurs (TBTC: TBOF=1), resulting in an interrupt request. • If an interrupt caused by an overflow is allowed (TBTC: TBIE=1), an overflow (TBTC: TBOF=1) triggers an interrupt. • The interval time for the time-base timer can be selected from the following four types. Table 11.1-1 shows the interval time for the time-base timer. Table 11.1-1 Interval Time for the Time-base Timer Count clock Interval time 212/HCLK (about 1.0 ms) 2/HCLK (0.5 μs) 214/HCLK (about 4.1 ms) 216/HCLK (about 16.4 ms) 219/HCLK (about 131.1 ms) HCLK: Oscillation clock The time in parenthesis applies when the oscillation clock operates at 4 MHz. 208 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 11 TIME-BASE TIMER 11.1 Overview of the Time-base Timer MB90860E Series ■ Clock Provision • Provides operating clock to the oscillation stabilization wait time timer and peripheral functions including the PPG timer or watchdog timer. Table 11.1-2 shows the clock cycles provided to the each peripheral from the time-base timer. Table 11.1-2 Clock Cycles Provided from the Time-base Timer Clocking provided to Clock cycle 210/HCLK (about 256 μs) 213/HCLK (about 2.0 ms) Oscillation stabilization wait time* 215/HCLK (about 8.2 ms) 217/HCLK (about 32.8 ms) 212/HCLK (about 1.0 ms) 214/HCLK (about 4.1 ms) Watchdog timer 216/HCLK (about 16.4 ms) 219/HCLK (about 131.1 ms) PPG timer 29/HCLK (about 128 μs) HCLK: Oscillation clock The time in parenthesis applies when the oscillation clock operates at 4 MHz. *: The oscillation stabilization wait time is an estimated time because the oscillation cycle is unstable right after starting oscillating. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 209 CHAPTER 11 TIME-BASE TIMER 11.2 Block Diagram of the Time-base Timer 11.2 MB90860E Series Block Diagram of the Time-base Timer The time-base timer consists of the following blocks. • Time-base timer counter • Counter clearing circuit • Interval timer selector • Time-base timer control register (TBTC) ■ Block Diagram of the Time-base Timer Figure 11.2-1 Block Diagram of the Time-base Timer To watchdog timer To PPG timer Time-base timer counter 21/HCLK × 21 × 22 × 23 ⋅⋅⋅ ⋅⋅⋅ × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 × 216 × 217 × 218 OF OF OF OF Power-on reset Stop mode CKSCR : MCS=1→0*1 CKSCR : SCS=0→1*2 To clock control part oscillation stabilization wait time selector Counter clearing circuit Interval timer selector TBOF cleared Time-base timer control register (TBTC) Reserved ⎯ TBOF set ⎯ TBIE TBOF TBR TBC1 TBC0 Time-base timer interrupt signal OF HCLK *1 *2 : Overflow : Oscillation clock : Switches the machine clock from main clock to PLL clock : Switches the machine clock from sub clock to main clock The actual interrupt request number of the time-base timer is as follows. Interrupt request number: #25 (19H) 210 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 11 TIME-BASE TIMER 11.2 Block Diagram of the Time-base Timer MB90860E Series ● Time-base timer counter An 18-bit up counter that uses the divide-by-two clock of the oscillation clock (HCLK) as count clock. ● Counter clearing circuit The value of the time-base timer counter will be cleared due to the following sources. • The time-base timer counter clearing bit of the time-base timer control register (TBTC: TBR=0) • Power-on reset • Transition to the main stop mode or PLL stop mode (CKSCR:SCS=1, LPMCR: STP=1) • Switching of clock modes (from the main clock mode to the PLL clock mode, from the sub clock mode to the PLL clock mode, or from the sub clock mode to the main clock mode) ● Interval timer selector Selects the time-base timer counter output from the four different types. When an overflow (carry) occurs at the bit of the selected interval time due to a count up, an interrupt request is generated. ● Time-base timer control register (TBTC) Selects the interval time, clears the time-base timer counter, allows/prohibits an interrupt, and checks the state of an interrupt request and clears it. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 211 CHAPTER 11 TIME-BASE TIMER 11.3 Configuration of the Time-base Timer 11.3 MB90860E Series Configuration of the Time-base Timer Explains the time-base timer register and interrupt sources. ■ List of the Time-base Timer Register and Its Initial Value Figure 11.3-1 List of the Time-base Timer Register and Its Initial Value bit Time-base timer control register (TBTC) 15 14 13 12 11 10 9 8 1 × × 0 0 1 0 0 × : Undefined ■ Generation of an Interrupt Request in the Time-base Timer When the counter bit for the selected interval timer reaches the interval time, the time-base timer sets "1" in the overflow interrupt request flag bit in the time-base timer control register (TBTC:TBOF). When the overflow interrupt request flag bit is set (TBTC: TBOF=1) while an interrupt is allowed (TBTC: TBIE=1), an interrupt request is generated. 212 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 11 TIME-BASE TIMER 11.3 Configuration of the Time-base Timer MB90860E Series 11.3.1 Time-base Timer Control Register (TBTC) Time-base timer control register (TBTC) allows the following settings. • Selecting the interval time for the time-base timer • Clearing the counter value for the time-base timer • Allowing and prohibiting an interrupt request due to an overflow • Checking the state of and clearing the interrupt request flag due to an overflow ■ Time-base Timer Control Register (TBTC) Figure 11.3-2 Time-base Timer Control Register (TBTC) Address 15 0000A9H Reserved TBIE TBOF TBR TBC1 TBC0 R/W R/W R/W W R/W R/W 14 13 12 11 10 9 8 Initial value 1XX00100 B bit9 bit8 TBC1 TBC0 Interval time selection bits 0 0 212/HCLK (about 1.0 ms) 0 1 214/HCLK (about 4.1 ms) 1 0 216/HCLK (about 16.4 ms) 1 1 219/HCLK (about 131.1 ms) HCLK: Oscillation clock The time in parenthesis applies when the oscillation clock operates at 4 MHz. bit10 TBR 0 Time-base timer counter clearing bit Reading Writing Clears time-base timer counter Clears TBOF the bit "1" is consistently read 1 No effect bit11 TBOF Overflow interrupt request flag bit Reading Writing 0 No overflow at the selected Cleared counter bit 1 Overflow at the selected counter bit No effect bit12 TBIE Overflow interrupt allowance bit 0 Overflow interrupt request prohibited 1 Overflow interrupt request allowed bit15 Reserved bit Reserved R/W : Readable/Writable : Write only W : Undefined X : Initial value : Undefined CM44-10144-4E 1 Always set to "1". FUJITSU SEMICONDUCTOR LIMITED 213 CHAPTER 11 TIME-BASE TIMER 11.3 Configuration of the Time-base Timer MB90860E Series Table 11.3-1 Functions of the Time-base Timer Control Register (TBTC) Bit name bit15 Reserved: Reserved bit Always set to "1". bit14, bit13 Undefined bits When reading : The value is undefined. When writing : No effect. TBIE: Overflow interrupt allowance bit Allows or prohibits an interrupt caused by the overflow at the interval timer bit in the time-base timer counter. When set to "0": An interrupt request is not generated even when an overflow occurs (TBOF = 1). When set to "1": An interrupt request is generated when an overflow occurs (TBOF = 1). bit11 TBOF: Overflow interrupt request flag bits Shows an overflow (carry) at the interval timer bit in the time-base timer counter. When an overflow (carry) occurs (TBOF=1) while an interrupt is allowed (TBIE=1), an interrupt request is generated. When set to "0" : Cleared. When set to "1" : Invalid. No change. When read with a read-modify-write instruction :"1" is read. Notes: 1) In the case of clearing the TBOF bit, be sure to prohibit an interrupt (TBIE=0) or mask an interrupt in the interrupt mask register (ILM) of processor status before clearing it. 2) The TBOF bit is cleared in the case of writing of "0", transition to the main stop mode, transition to the PLL stop mode, transition from the sub clock mode to the main clock mode, transition from the sub clock mode to the PLL clock mode, transition from the main clock mode to the PLL clock mode, writing of "0" into the time-base timer counter clearing bit (TBR), and reset. bit10 TBR: Time-base timer counter clearing bit Clears all bits in the time-base timer counter. When set to "0": Clears all bits in the time-base timer counter to "0". The TBOF bit is also cleared. When set to "1": Invalid. No change. When reading : "1" is consistently read. bit9, bit8 TBC1, TBC0: Interval time selection bits bit12 214 Function Sets a cycle for the interval timer in the time-base timer counter. • The setting in the TBC1 and TBC0 bits configures the interval time for the time-base timer. • Four different types of interval time are selectable. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 11.4 Interrupt of the Time-base Timer CHAPTER 11 TIME-BASE TIMER 11.4 Interrupt of the Time-base Timer Carrying (overflowing) the interval time bit in the time-base timer counter corresponding to the interval time configured in the time-base timer control register causes the time-base timer to generate an interrupt request (interval timer function). ■ Interrupt of the Time-base Timer • The time-base timer continues to count up while the main clock (divide-by-two of the oscillation clock) is input. • As soon as the interval time configured at the TBC1 and TBC0 bits in the time-base timer control register has been reached, the interval time selection bit corresponding to the interval time selected in the time-base timer counter is carried to generate an overflow. • When an overflow is generated at the interval time selection bit, the overflow interrupt request flag bit in the time-base timer control register (TBTC: TBOF) is set to "1". • When the overflow interrupt request flag bit in the time-base timer control register is set (TBTC: TBOF=1) while an interrupt is allowed (TBTC: TBIE=1), an interrupt request is generated. • The overflow interrupt request flag bit in the time-base timer control register (TBTC: TBOF) will be set when the configured interval time is reached, regardless of whether an interrupt is allowed or prohibited (TBTC: TBIE). • To clear the overflow interrupt request flag bit (TBTC: TBOF), prohibit the interrupt by the time-base timer in interrupt handling (TBTC: TBIE=0) or mask the interrupt by the time-base timer using the ILM bit in the processor status (PS), and then write "0" into the TBOF bit to clear. Note: When an interrupt is allowed (TBTC: TBIE=1) while the overflow interrupt request flag bit in the time-base timer control register is set (TBTC: TBOF=1), an interrupt request will be generated immediately. ■ Interrupt of Time-base Timer and Support for EI2OS/DMA Transfer • The time-base timer does not support the extended intelligent I/O service (EI2OS) and DMA transfer. • For interrupt numbers, the interrupt control register, and interrupt vector addresses, see Section "3.2 Interrupt Vector". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 215 CHAPTER 11 TIME-BASE TIMER 11.5 Operating Explanation of the Time-base Timer 11.5 MB90860E Series Operating Explanation of the Time-base Timer The time-base timer operates as an interval timer or oscillation stabilization wait time timer. It also provides operating clock to peripheral functions. ■ Interval Timer Function When an interrupt is generated for each interval time, it can be used as an interval timer. To operate the time-base timer as an interval timer, the setting in Figure 11.5-1 is necessary. ● Setting of the time-base timer Figure 11.5-1 Setting of the Time-base Timer Time-base timer control register (TBTC) bit15 14 Reserved 1 13 12 11 10 9 bit 8 TBIE TBOF TBR TBC1TBC0 0 0 : Undefined bit : Used bit 0 : Set to "0" 1 : Set to "1" ● Interval timer function operation The time-base timer can be used as an interval timer by generating an interrupt for each set interval time. • The time-base timer continues to count up synchronizing to the main clock (divide-by-two of the oscillation clock), as long as the oscillation clock is working. • When the interval time configured at the interval time selection bits in the time-base timer control register (TBTC:TBC1, TBC0) has been reached, an overflow carrying occurs in the time-base timer counter, resulting in setting "1" in the overflow interrupt request flag bit (TBTC: TBOF). • An overflow interrupt request flag bit is set (TBTC: TBOF=1) while an interrupt is allowed (TBTC: TBIE=1), an interrupt request is generated. Note: 216 An interval time can be longer than the configured interval time due to the clearing operation by the time-base timer counter. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 11 TIME-BASE TIMER 11.5 Operating Explanation of the Time-base Timer MB90860E Series ● Operating example of the time-base timer Interval timer operations in the following states are shown in Figure 11.5-2. • When a power-on reset occurs • When transiting to the sleep mode while the interval timer function is operating • When transiting to the stop mode while the interval timer function is operating • When time-base timer counter clearing is requested When transiting to the stop mode, the time-base timer counter is cleared and count-up operation terminates. When returning from the stop mode, the time-base timer starts counting the main clock oscillation stabilization wait time. Figure 11.5-2 Operating Example of the Time-base Timer Counter value Cleared due to transition to the stop mode 3FFFFH Oscillation stabilization wait overflow 00000H CPU operation Interval period starts (TBTC: TBC1, TBC0 = 11B) Power-on reset Counter cleared (TBTC: TBR = 0) Cleared due to interrupt TBOF bit TBIE bit Sleep SLP bit (LPMCR register) Sleep canceled due to interrupt by time-base timer interval Stop STP bit (LPMCR register) When 11B is set at the interval time selection bits (TBTC: TBC1, TBC0) (219/HCLK) : Oscillation stabilization wait time HCLK : Oscillation clock CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 217 CHAPTER 11 TIME-BASE TIMER 11.5 Operating Explanation of the Time-base Timer MB90860E Series ■ Operation of Oscillation Stabilization Wait Time Timer The time-base timer can be used as an oscillation stabilization wait time timer for the main clock and PLL clock. • The oscillation stabilization wait time is a time period from when the time-base timer counter starts counting up from "0" to when the configured oscillation stabilization wait time selection bit is overflowed (carried). Table 11.5-1 shows time-base timer clearing conditions and oscillation stabilization wait time. Table 11.5-1 Time-base Timer Clearing Conditions and Oscillation Stabilization Wait Time (1 / 2) Counter cleared TBOF cleared ❍ ❍ Power-on reset ❍ ❍ After the main clock oscillation stabilization wait time is terminated, switches to the main clock mode Watchdog reset × ❍ None External reset × ❍ None Software reset × ❍ None Main clock to PLL clock (CKSCR: MCS=1 to 0) ❍ ❍ After the PLL clock oscillation stabilization wait time is terminated, switches to the PLL clock mode Main clock to sub clock (CKSCR: SCS=1 to 0) × × After the sub clock oscillation stabilization wait time is terminated, switches to the sub clock mode Sub clock to main clock (CKSCR: SCS=0 to 1) ❍ ❍ After the main clock oscillation stabilization wait time is terminated, switches to the main clock mode Sub clock to PLL clock (CKSCR: MCS=0, SCS=0 to 1) ❍ ❍ After the main clock oscillation stabilization wait time is terminated, switches to the PLL clock mode PLL clock to main clock (CKSCR: MCS=0 to 1) × × None PLL clock to sub clock (CKSCR: MCS=0, SCS=1 to 0) × × None Operation Writing "0" in the time-base timer counter clearing bit (TBTC: TBR) Oscillation stabilization wait time Reset Clock mode switch 218 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 11 TIME-BASE TIMER 11.5 Operating Explanation of the Time-base Timer MB90860E Series Table 11.5-1 Time-base Timer Clearing Conditions and Oscillation Stabilization Wait Time (2 / 2) Counter cleared TBOF cleared Oscillation stabilization wait time Canceling the main stop mode ❍ ❍ After the main clock oscillation stabilization wait time is terminated, switches to the PLL clock mode Canceling the PLL stop mode ❍ ❍ After the main clock oscillation stabilization wait time is terminated, switches to the PLL clock mode Canceling the sub stop mode × × After the sub clock oscillation stabilization wait time is terminated, switches to the sub clock mode × × None Returning to the main clock mode × × None Returning to the sub clock mode × × None Returning to the PLL clock mode × × None Canceling the main sleep mode × × None Canceling the sub sleep mode × × None Canceling the PLL sleep mode × × None Operation Cancellation of stop modes Cancellation of watch modes Canceling the sub watch mode Cancellation of time-base timer modes Cancellation of sleep modes ■ Operating Clock Provision The time-base timer provides operating clock to the PPG timer and watchdog timer. Note: Take notice that clearing the time-base timer counter affects the operation of peripheral functions such as watchdog timer or PPG timer that uses the time-base timer output. Reference: • See "CHAPTER 16 8/16-BIT PPG TIMER" for details on the PPG timer. • See "CHAPTER 12 WATCHDOG TIMER" for details on the watchdog timer. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 219 CHAPTER 11 TIME-BASE TIMER 11.6 Notes on Using the Time-base Timer 11.6 MB90860E Series Notes on Using the Time-base Timer This section shows some notes on using the time-base timer. ■ Notes on Using the Time-base Timer ● When clearing an interrupt request To clear the overflow interrupt request flag bit of the time-base timer control register (TBTC: TBOF=0), prohibit the interrupt (TBTC: TBIE=0) or mask the interrupt by the time-base timer using the interrupt level mask register in the processor status. ● When clearing the time-base timer counter Take notice that clearing the time-base timer counter affects the following operations. • The time-base timer is used as an interval timer (interval interrupt) • The watchdog timer is in use • The time-base timer provides operating clock of the PPG timer ● When using as an oscillation stabilization wait time timer • The oscillation clock is not operating after power is turned on or in main stop, PLL stop, and sub clock modes. Therefore, when oscillation starts, the time-base timer provides main clock oscillation stabilization wait time. Depending on the type of oscillator connected to the high-speed oscillator input pins, suitable oscillation stabilization wait time needs to be specified. Reference: See Section "6.6 Oscillation Stabilization Wait Time" for details on the oscillation stabilization wait time. ● Peripheral functions to which the time-base timer provides clock • When transiting to the operation mode where the oscillation clock pauses (the PLL stop mode, sub clock mode, and main clock mode), the time-base timer counter is cleared and the time-base timer stops operating. • When the time-base timer counter is cleared, an interval time from the point of clearance is needed. Therefore, "L" level becomes longer by 1/2 period or "H" level becomes shorter in clock provided by the time-base timer. • In the case of watchdog timer, the watchdog timer counter normally counts because it is cleared concurrently with the time-base timer counter. 220 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 11 TIME-BASE TIMER 11.7 Programming Example of the Time-base Timer MB90860E Series 11.7 Programming Example of the Time-base Timer This section shows programming examples of the time-base timer. ■ Programming Example of the Time-base Timer ● Processing Repeatedly generates interval interrupts at 212/HCLK (HCLK: oscillation clock). The interval time is approximately 1.0 ms (when operating at 4 MHz). ● Coding example ICR07 EQU 0000B7H ;Time-base timer interrupt control ;register TBTC EQU 0000A9H ;Time-base timer control register TBOF EQU TBTC:3 ;Interrupt request flag bit TBIE EQU TBTC:2 ;Interrupt allowance bit ;-------Main program------------------------------------CODE CSEG START: ;Data such as stack pointer (SP) are ;supposed to be initialized AND CCR,#0BFH ;Interrupt prohibited MOV I:ICR07 #00H ;Interrupt level 0 (highest) MOV I:TBTC,#10000000B ;Upper three bits are fixed ;TBOF cleared, ;Counter clearing interval time ;212/HCLK selected ;Interrupt allowed ;ILM in PS set to level seven ;Interrupt allowed ;Infinite loop SETB I:TBIE MOV ILM,#07H OR CCR,#40H LOOP: MOV A,#00H MOV A,#01H BRA LOOP ;-------Interrupt program-------------------------------WARI: CLRB I:TBIE ;Interrupt allowance bit cleared CLRB I:TBOF ;Interrupt request flag cleared • User process • SETB I:TBIE ;Interrupt allowed RETI ;Returned from interrupt process CODE ENDS ;-------Vector setting----------------------------------- CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 221 CHAPTER 11 TIME-BASE TIMER 11.7 Programming Example of the Time-base Timer VECT VECT 222 CSEG ORG ABS=0FFH 0FF98H DSL ORG DSL DB ENDS END WARI 0FFDCH START 00H MB90860E Series ;Setting a vector for interrupt number ;#25 (19H) ;Reset vector set ;Setting to the single chip mode START FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 12 WATCHDOG TIMER This chapter explains the function and operation of the watchdog timer. 12.1 Overview of the Watchdog Timer 12.2 Configuration of the Watchdog Timer 12.3 Register of the Watchdog Timer 12.4 Operating Explanation of the Watchdog Timer 12.5 Notes on Using the Watchdog Timer 12.6 Programming Example of the Watchdog Timer CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 223 CHAPTER 12 WATCHDOG TIMER 12.1 Overview of the Watchdog Timer 12.1 MB90860E Series Overview of the Watchdog Timer The watchdog timer is a 2-bit counter that uses the time-base timer or the watch timer as count clock. If the counter is not cleared within an interval time, the CPU will be reset. ■ Watchdog Timer Function • The watchdog timer is a timer counter that prevents program hang-ups. Once the watchdog timer activates, the watchdog timer counter shall be continuously cleared to stay within the configured interval time. As soon as the watchdog timer counter reaches the interval time without being cleared, the CPU will be reset. This is referred to as a watchdog timer. • The interval time of the watchdog timer is based on the clock cycle input as count clock, and a watchdog reset occurs between the minimum time and maximum time. • The clock source output destination is set with the watchdog clock selection bit in the watch timer control register (WTC: WDCS). • The interval time of the watchdog timer is set with the time-base timer output selection bit and watch timer output selection bit (WDTC: WT1, WT0) in the watchdog timer control register. Table 12.1-1 shows the interval time for the watchdog timer. Table 12.1-1 Interval Time for the Watchdog Timer Minimum Maximum Clock cycle Minimum Maximum Clock cycle About 3.58 ms About 4.61 ms 214 ±211/ HCLK About 0.457 s About 0.576 s 212 ±29/ SCLK About 14.33 ms About 18.3 ms 216 ±213/ HCLK About 3.584 s About 4.608 s 215 ±212/ SCLK About 57.23 ms About 73.73 ms 218 ±215/ HCLK About 7.168 s About 9.216 s 216 ±213/ SCLK About 458.75 ms About 589.82 ms 221 ±218/ HCLK About 14.336 s About 18.432 s 217 ±214/ SCLK HCLK: Oscillation clock (4 MHz), SCLK: Sub clock (8.192 kHz) Notes: 224 • In the case where the count clock of the watchdog timer is used as a time-base timer output (carry signal), the generation time of a watchdog reset may become longer when the timebase timer is cleared. • When sub clock is used as machine clock, be sure to set "0" to the watchdog timer clock source selection bit (WDCS) in the watch timer control register (WTC) to specify the watch timer output. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 12 WATCHDOG TIMER 12.2 Configuration of the Watchdog Timer MB90860E Series 12.2 Configuration of the Watchdog Timer The watchdog timer consists of the following blocks. • Count clock selector • Watchdog timer counter (2-bit counter) • Watchdog reset generation circuit • Counter clearing control circuit • Watchdog timer control register (WDTC) ■ Block Diagram of the Watchdog Timer Figure 12.2-1 Block Diagram of the Watchdog Timer Watch timer control register (WTC) Watchdog timer control register (WDTC) WRST ERST SRST WTE WT1 WT0 PONR Watchdog Timer 2 Transits to the timebase timer mode Counter clearing control circuit Count clock selector Transits to the watch mode Transits to the stop mode Reset generated Stop Activate Reset generated Transits to the sleep mode WDCS 2-bit counter Watchdog reset generation circuit Internal reset generation circuit Clear 4 4 (Time-base timer counter) Main clock (divideby-two of HCLK) × 21 × 22 ⋅⋅⋅ × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 × 216 × 217 × 218 (Watch counter) Sub clock SCLK* × 21 × 22 ⋅⋅⋅ × 25 × 26 × 27 × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 HCLK: Oscillation clock SCLK: Sub clock *: SCLK will be divide-by-two or divide-by-four of the clock being input in low speed oscillator pins X0A and X1A. The division ratio will be set at the SCDS bit of PLL/Sub clock control register (PSCCR). (See "CHAPTER 6 CLOCK") CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 225 CHAPTER 12 WATCHDOG TIMER 12.2 Configuration of the Watchdog Timer MB90860E Series ● Count clock selector Specify the time-base timer or the watch timer as count clock to be input to the watchdog timer. Four different types of interval time are selectable from each timer output. ● Watchdog timer counter (2-bit counter) This is a 2-bit up counter that uses the time-base timer or the watch timer output as count clock. The clock source output destination is set with the watchdog clock selection bit in the watch timer control register (WTC: WDCS). ● Watchdog reset generation circuit Sends a reset signal after the overflow (carry) of the watchdog timer. ● Counter clearing circuit Clears the watchdog timer counter. ● Watchdog timer control register (WDTC) Activates and clears the watchdog timer, sets an interval time, and keeps a reset generation source. 226 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 12 WATCHDOG TIMER 12.3 Register of the Watchdog Timer MB90860E Series 12.3 Register of the Watchdog Timer This section explains the register used to set the watchdog timer. ■ List of the Watchdog Timer Register and the Reset Value Figure 12.3-1 List of the Watchdog Timer Register and the Reset Value bit Watchdog timer control register (WDTC) 7 6 5 4 3 2 1 0 1 1 1 : Undefined CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 227 CHAPTER 12 WATCHDOG TIMER 12.3 Register of the Watchdog Timer MB90860E Series Watchdog Timer Control Register (WDTC) 12.3.1 Activates and clears the watchdog timer, sets an interval time, and keeps a reset generation source. ■ Watchdog Timer Control Register (WDTC) Figure 12.3-2 Watchdog Timer Control Register (WDTC) 7 Address 0000A8H PONR R 6 5 4 3 2 1 0 Initial value WRST ERST SRST WTE WT1 WT0 R R R W W W XXXXX111B bit1 bit0 Interval time selection bits (Time-base timer output selection) WT1 WT0 Interval time Minimum Maximum Clock cycle 0 0 About 3.58 ms About 4.61 ms 214 ±211/HCLK 0 1 About 14.33 ms About 18.3 ms 216 ±213/HCLK 1 0 About 57.23 ms About 73.73 ms 218 ±215/HCLK 1 1 About 458.75 ms About 589.82 ms 221 ±218/HCLK HCLK: Oscillation clock The interval time in parenthesis applies when HCLK operates at 4 MHz. bit1 bit0 Interval time selection bits (Watch timer output selection) WT1 WT0 Interval time Minimum Maximum Clock cycle 0 0 About 0.457 s About 0.576 s 212 ±29/SCLK 0 1 About 3.584 s About 4.608 s 215 ±212/SCLK 1 0 About 7.168 s About 9.216 s 216 ±213/SCLK 1 1 About 14.336 s About 18.432 s 217 ±214/SCLK SCLK: Sub clock (See Notes below.) The interval time in parenthesis applies when SCLK operates at 8.192 kHz. bit2 WTE Watchdog timer control bit 0 After resetting, the first writing: After resetting, the second writing or Activates the watchdog timer later: Clears the watchdog timer 1 bit7 No effect bit5 bit4 bit3 Reset source bits Reset source PONR WRST ERST SRST R W * X - : Read only : Write only : Keeps the previous state : Undefined : Undefined 1 X X X Power-on reset ∗ 1 ∗ ∗ ∗ ∗ Watchdog reset 1 ∗ ∗ ∗ External reset (Inputs "L" level in RST pins) ∗ 1 Software reset (Writes "1" in the RST bit) Note: SCLK will be divide-by-two or divide-by-four of the clock being input in low speed oscillator pins X0A and X1A. The division ratio will be set at the SCDS bit of PLL/Sub clock control register (PSCCR). (See "CHAPTER 6 CLOCK") 228 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 12 WATCHDOG TIMER 12.3 Register of the Watchdog Timer MB90860E Series Table 12.3-1 Functions of the Watchdog Timer Control Register (WDTC) Bit name bit7, bit5 to bit3 PONR, WRST, ERST, SRST: Reset source bits Shows the reset source. • When reset occurs, "1" will be set in the bit that corresponds to the reset source. After reset, the watchdog timer control register (WDTC) can be read to check the reset source. • The reset source bit will be cleared after reading the watchdog timer control register (WDTC). Note: The data other than PONR bit will not be secured after power-on reset. If the PONR bit is set when reading, ignore other bit data. bit6 Undefined bit When reading : The value is undefined. When writing : No effect. WTE: Watchdog control bit Activates or clears the watchdog timer. When set to "0" (The first time after reset) : Activates. When set to "0" (The second time or later after reset) : Cleared. WT1, WT0: Interval time selection bits Sets the watchdog timer interval time. The interval time differs as shown in Figure 12.3-2 in the case where the watch timer control register (WTC) specifies the watch timer as a clock source for the watchdog timer (watchdog clock selection bit: WDCS=0), and in the case where the main clock mode or PLL clock mode is selected as a clock mode and the WDCS bit in WTC is "1". In sub clock mode, be sure to set the watchdog clock selection bit (WDCS) in the watch timer control register (WTC) to "0" and select the watch timer output. • The data on activating the watchdog timer will be effective. • The written data after activating the watchdog timer will be ignored. • These bits are for writing only. bit2 bit0, bit1 CM44-10144-4E Function FUJITSU SEMICONDUCTOR LIMITED 229 CHAPTER 12 WATCHDOG TIMER 12.4 Operating Explanation of the Watchdog Timer 12.4 MB90860E Series Operating Explanation of the Watchdog Timer After activating the watchdog timer, when its counter reaches the interval time without being cleared, a watchdog reset occurs. ■ State Transition Chart of the Watchdog Timer The watchdog timer has the following four states. Disabled: Is not operating. Operating: Starts counting from the counter-cleared state. Stopped: Continues the counter-cleared state. Overflowed: Generates a watchdog reset. Figure 12.4-1 State Transition Chart of the Watchdog Timer Disabled (Initial state) Writes "0" in the WTE bit Reset Reset Operating Starts counting from the counter-cleared state Cancels the stop mode by interrupt Stopped Counter-cleared state Transits to the stop mode Counter overflow Overflowed Always Generates a watchdog reset Writes "0" in the WTE bit Transits to the sleep mode Transits to the watch mode Transits to the time-base timer mode 230 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 12 WATCHDOG TIMER 12.4 Operating Explanation of the Watchdog Timer MB90860E Series ■ Watchdog Timer Operations To operate the watchdog timer, the configuration shown in Figure 12.4-2 will be necessary. Figure 12.4-2 Watchdog Timer Settings bit 7 Watchdog timer control register (WDTC) 6 5 4 3 2 1 bit 0 WRST ERST SRST WTE WT1 WT0 PONR 0 bit 7 Watch timer control register (WTC) 6 5 4 3 2 1 bit 0 WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0 : Used bit 0 : Set to "0" ● Selection of a clock input source • The time-base timer or watch timer can be selected as a clock input source for the watchdog timer count clock. The time-base timer is selected when setting "1" to the watchdog clock selection bit (WTC: WDCS), and the watch timer is selected when setting "0" thereto. It returns to "1" (time-base timer) after resetting. • When operating in the sub clock mode, set "0" to the WDCS bit to select the watch timer. Note: In a single clock product, the watchdog timer cannot be used if the watch timer is set as clock for the watchdog timer. ● Setting of interval time • To select the interval time of the watchdog timer, set the interval time selection bits (WDTC: WT1, WT0). • Set an interval time concurrently with the activation. It will be ignored if written after activating the watchdog timer. ● Activation of watchdog timer • When "0" is written to the watchdog timer control bit (WDTC: WTE) after resetting, the watchdog timer activates and starts counting up. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 231 CHAPTER 12 WATCHDOG TIMER 12.4 Operating Explanation of the Watchdog Timer MB90860E Series ● Clearing of the watchdog timer • The watchdog timer will be cleared when "0" is written to the watchdog timer control bit (WDTC: WTE) again within the interval time. If it is not cleared within the interval time, a watchdog timer overflow occurs, resulting in CPU reset. • The watchdog timer is cleared by resetting or transiting to standby modes (the sleep mode, stop mode, and time-base timer mode). • When the time-base timer is in operation, the watch mode is in operation, or the mode is sleep mode, the watchdog timer counter will be cleared while the watchdog timer is activating. • Figure 12.4-3 shows the relationship between the watchdog timer clearing timing and the interval time. The interval time differs depending on the timing to clear the watchdog timer. 232 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 12 WATCHDOG TIMER 12.4 Operating Explanation of the Watchdog Timer MB90860E Series ● Check of reset sources • By reading the reset source bits (WDTC: PONR, WRST, ERST, SRST) in the watchdog timer control register (WDTC) after resetting, reset sources can be checked. Reference: See Section "CHAPTER 7 RESET" for details on reset source bits. Figure 12.4-3 The Watchdog Timer Clearing Timing and Interval Time [Watchdog timer block diagram] 2-bit counter Clock selector a WTE bit Divide-bytwo circuit Count allowance output circuit b Divide-bytwo circuit c Reset circuit d Reset signal Allowing and clearing counts [Minimum interval time] When WTE bit cleared immediately before count clock rises Count starts Counter cleared Count clock a Divide-by-two value b Divide-by-two value c Count allowed Reset signal d 7 × (Count clock cycle/2) Watchdog reset generated WTE bit cleared [Maximum interval time] When WTE bit cleared immediately after count clock rises Count starts Counter cleared Count clock a Divide-by-two value b Divide-by-two value c Count allowed Reset signal 9 × (Count clock cycle/2) WTE bit cleared CM44-10144-4E Watchdog reset generated FUJITSU SEMICONDUCTOR LIMITED 233 CHAPTER 12 WATCHDOG TIMER 12.5 Notes on Using the Watchdog Timer 12.5 MB90860E Series Notes on Using the Watchdog Timer Take notice of the following points when using the watchdog timer. ■ Notes on Using the Watchdog Timer ● Stopping the watchdog timer • The watchdog timer stops on transition to the stop mode. ● Interval time • Because the carry signal of the time-base timer or watch timer is used as count clock for interval time, the interval time of the watchdog timer can be longer when the time-base timer or watch timer is cleared. The time-base timer will also be cleared in the case of transition from the main clock mode to the PLL clock mode, from the sub clock mode to the main clock mode, and from the sub clock mode to the PLL clock mode, in addition to the case where "0" is written to the time-base timer counter clear bit (TBR) in the time-base timer control register (TBTC). • Set an interval time concurrently with the activation of watchdog timer. It will be ignored if set except at the activation. ● Notes on writing programs • When continuously clearing the watchdog timer in the main loop, set a shorter time than the watchdog timer interval time for the main loop processing time including interrupt processing. • Because the watchdog timer is operating during DMA transfer, the hold state, the sleep and time-base timer mode, or the watch mode, the operation time (such as interval time) in each mode has to be taken into consideration in user programs. ● Notes on using sub clock mode • In sub clock mode, be sure to set the watchdog clock selection bit (WDCS) in the watch timer control register (WTC) to "0" and select the watch timer output. ● Operations of watchdog timer in the sleep mode, time-base timer mode, and watch mode • When transiting to the sleep mode, time-base timer mode, and watch mode, the watchdog timer is cleared and restarts counting (see Table 12.5-1). ● Operations of watchdog timer during DMA transfer • Because the watchdog timer operates during DMA transfer, a watchdog reset may occur during DMA transfer. To prevent a reset, take necessary measures in user programs (see Table 12.5-1). 234 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 12 WATCHDOG TIMER 12.5 Notes on Using the Watchdog Timer MB90860E Series ● Watchdog timer operations in hold state (external bus mode) • Because the watchdog timer operates during DMA transfer, a watchdog reset may occurs during DMA transfer. To prevent a reset, take necessary measures in user programs (see Table 12.5-1). ● Operations of watchdog timer in stop mode • When transiting to the stop mode, the watchdog timer is cleared and stopped. As soon as the stop mode is canceled, the watchdog timer starts counting again (see Table 12.5-1). ● Operations of watchdog timer in reset • The watchdog timer will be disabled by all reset sources. After the reset is cancelled, the watchdog timer remains disabled (see Table 12.5-1). Table 12.5-1 Watchdog Timer Clearing Conditions Operation mode Reset WDTC register WTE=0 Stop mode Sleep mode Time-base timer mode Watch mode Hold μDMAC Clear In transition In writing In transition In transition In transition In transition None None Operating (Starts counting after clearing) Operating (Starts counting after clearing) Operating (Starts counting after clearing) Operating (Continues counting) Operating (Continues counting) Watchdog timer state in modes Disabled - Stopped (Keeps cleared) Watchdog reset in modes Not occur - Not occur Occur Occur Occur Occur Occur Operating Operating (Restarts counting after clearing) Operating (Continues counting) Operating (Continues counting) Operating (Continues counting) Operating (Continues counting) Operating (Continues counting) Watchdog timer state after canceling and returning modes CM44-10144-4E Disabled FUJITSU SEMICONDUCTOR LIMITED 235 CHAPTER 12 WATCHDOG TIMER 12.6 Programming Example of the Watchdog Timer 12.6 MB90860E Series Programming Example of the Watchdog Timer This section shows programming examples of the watchdog timer. ■ Programming Example of the Watchdog Timer ● Processing specifications • Clears the watchdog timer each time in the main program loop. • The main program has to go around once within the minimum interval time of watchdog timer. ● Coding example WDTC EQU 0000A8H ;Watchdog timer control register WTE EQU WDTC:2 ;Watchdog control bit ; ;---------Main program--------------------------------------CODE CSEG START: ;Data such as stack pointer (SP) are ;supposed to be initialized MOV I:WDTC,#00000011B ;Activation of watchdog timer ;Selects a 221+218 cycle for interval ;time LOOP: CLRB I:WTE ;Clearing of the watchdog timer • User process • BRA LOOP ;---------Vector setting------------------------------------VECT CSEG ABS=0FFH ORG 00FFDCH ;Reset vector set DSL START DB 00H ;Setting to the single chip mode VECT ENDS END START 236 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER This chapter describes the functions and operations of the 16-bit I/O timer. 13.1 Overview of 16-bit I/O Timer 13.2 Block Diagram of 16-bit I/O Timer 13.3 Configuration of 16-bit I/O Timer 13.4 Interrupts from 16-bit I/O Timer 13.5 Operations of 16-bit Free-running Timer 13.6 Input Capture Operations 13.7 Output Compare Operations 13.8 Notes on Using the 16-bit I/O Timer 13.9 Sample Programs for 16-bit I/O Timer CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 237 CHAPTER 13 16-BIT I/O TIMER 13.1 Overview of 16-bit I/O Timer 13.1 MB90860E Series Overview of 16-bit I/O Timer The 16-bit I/O timer consists of two 16-bit free-running timers, eight input capture channels, and eight output compare channels. Based on the 16-bit free-running timers, the 16-bit I/O timer can output eight independent waveforms and measure input pulses and external clock cycles. ■ Modules Making Up the 16-bit I/O Timer The 16-bit I/O timer contains the following modules: ● 16-bit free-running timer × 2 • 16-bit free-running timer 0 (ch.0) • 16-bit free-running timer 1 (ch.1) ● Input capture channels × 8 • Input capture unit 0: Captures 16-bit free-running timer 0. - Input capture 0 (ch.0) - Input capture 1 (ch.1) - Input capture 2 (ch.2) - Input capture 3 (ch.3) • Input capture unit 1: Captures 16-bit free-running timer 1. - Input capture 4 (ch.4) - Input capture 5 (ch.5) - Input capture 6 (ch.6) - Input capture 7 (ch.7) ● Output compare channels × 8 • Output compare unit 0: Compares register values with16-bit free-running timer 0. (Comparison and match detection) - Output compare 0 (ch.0) - Output compare 1 (ch.1) - Output compare 2 (ch.2) - Output compare 3 (ch.3) • Output compare unit 1: Compares register values with16-bit free-running timer 1. (Comparison and match detection) - Output compare 4 (ch.4) - Output compare 5 (ch.5) - Output compare 6 (ch.6) - Output compare 7 (ch.7) 238 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.1 Overview of 16-bit I/O Timer MB90860E Series ■ Functions of 16-bit I/O Timer ● Functions of 16-bit free-running timer Each 16-bit free-running timer consists of a 16-bit up-counter, a prescaler, and control registers. The count value of the 16-bit free-running timer is used as the reference time for the input capture and output compare units. • The count clock cycle can be selected from among eight options. • An interrupt request can be generated when the counter overflows. • The counter of the 16-bit free-running timer is cleared to 0000H at a reset, when the timer is cleared (TCCSL: CLR=1), or upon detection of an output compare match. ● Functions of input capture units The input capture units contain eight 16-bit capture registers corresponding to external input pins, control registers, and edge detection circuits. When a trigger edge is input to an external input pin, the 16-bit free-running timer holds its counter value and generates an interrupt request at the same time. • A capture interrupt can be generated independently for each channel. • The input capture unit can activate DMA transfer or Extended Intelligent I/O Service (EI2OS). • The trigger edge can be selected from among the rising edge, falling edge, and both edges. • Each channel works independently, allowing up to eight inputs to be measured. • If you set LIN-UART as the input signal, the baud rate can be measured in LIN slave mode. ● Functions of output compare unit The output compare unit contains eight 16-bit compare registers, control registers, compare control circuits, and output control circuits. The output compare unit compares its register value with the counter value of the 16-bit free-running timer. When they match, the output compare unit inverts the output level of the corresponding output compare pin and generates an interrupt request at the same time. • The output compare unit can activate DMA transfer or Extended Intelligent I/O Service (EI2OS). • The output compare unit has the output pins and interrupt request flags corresponding to its eight output compare registers and allows the individual registers to operate independently. • The output level can be inverted upon detection of compare matches of at least two channels such as output compare ch.0 and ch.1. (The OUT0 and OUT4 pin outputs are not supported.) • The output level of each pin can be set upon activation. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 239 CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer 13.2 MB90860E Series Block Diagram of 16-bit I/O Timer The 16-bit I/O timer consists of the following modules: • 16-bit free-running timer • Input capture units • Output compare units ■ Block Diagram of 16-bit I/O Timer Figure 13.2-1 Block Diagram of 16-bit I/O Timer Internal data bus Input capture unit Dedicated bus 16-bit free-running timer Dedicated bus Output compare unit ● 16-bit free-running timer The count value of the 16-bit free-running timer is used as the reference time for the input capture and output compare units. ● Input capture unit When a trigger edge is input to an external input pin or when the trigger edge for LIN slave baud rate measurement is input from LIN-UART, the 16-bit free-running timer holds its counter value and generates an interrupt request at the same time. ● Output compare unit The output compare unit compares its register value with the counter value of the 16-bit free-running timer. When they match, the output compare unit inverts the output level of the corresponding pin and generates an interrupt request at the same time. 240 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer MB90860E Series ■ Pin Summary and Interrupt Numbers Table 13.2-1 lists the pins used for the 16-bit I/O timer and their respective interrupts. Table 13.2-1 Pin Summary and Interrupt Numbers Interrupt No. DMA channel I2OS support #33 (21H) 8 ❍ 6 ❍ P31/IN5 #31 (1FH) IN6 P42/IN6/ INT9R #13 (0DH) — × IN7 P43/IN7 #14 (0EH) — × OUT0 P94/ OUT0 #32 (20H) 7 ❍ #34 (22H) 9 ❍ #32 (20H) 7 ❍ #34 (22H) 9 ❍ #30 (1EH) — × Dedicated pin Pin name Input capture ch.0 (using 16-bit free-running timer ch.0) IN0 P24/IN0 Input capture ch.1 (using 16-bit free-running timer ch.0) IN1 P25/IN1 Input capture ch.2 (using 16-bit free-running timer ch.0) IN2 P26/IN2 Input capture ch.3 (using 16-bit free-running timer ch.0) IN3 P27/IN3 Input capture ch.4 (using 16-bit free-running timer ch.1) IN4 P30/IN4 Input capture ch.5 (using 16-bit free-running timer ch.1) IN5 Input capture ch.6 (using 16-bit free-running timer ch.1) Input capture ch.7 (using 16-bit free-running timer ch.1) Channel Output compare ch.0 (using 16-bit free-running timer ch.0) Output compare ch.1 (using 16-bit free-running timer ch.0) OUT1 P95/ OUT1 Output compare ch.2 (using 16-bit free-running timer ch.0) OUT2 P96/ OUT2 Output compare ch.3 (using 16-bit free-running timer ch.0) OUT3 P97/ OUT3 Output compare ch.4 (using 16-bit free-running timer ch.1) OUT4 P34/ OUT4 Output compare ch.5 (using 16-bit free-running timer ch.1) OUT5 P35/ OUT5 Output compare ch.6 (using 16-bit free-running timer ch.1) OUT6 P36/ OUT6 Output compare ch.7 (using 16-bit free-running timer ch.1) OUT7 P37/ OUT7 16-bit free-running timer ch.0 (overflow interrupt or output compare ch0 compare match interrupt) FRCK0 P44/ FRCK0/ SDA0 16-bit free-running timer ch.1 (overflow interrupt or output compare ch.4 compare match interrupt) CM44-10144-4E FRCK1 P45/ FRCK1/ SCL0 FUJITSU SEMICONDUCTOR LIMITED 241 CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer 13.2.1 MB90860E Series Block Diagram of 16-bit Free-running Timer The MB90860E series contains two channels of 16-bit free-running timer, each of which consists of the following blocks: ■ Block Diagram of 16-bit Free-running Timer Figure 13.2-2 Block Diagram of 16-bit Free-running Timer Output count values to input capture and output compare units. Timer data register (TCDT0,♦TCDT1) OF 16-bit counter CLK STOP CLR External clock Prescaler Output compare register 0 match signal (♦ Output compare register 4) 3 Timer control status register (lower) (TCCSL0,♦TCCSL1) Internal data bus (TCDT0,♦TCDT1) IVF IVFE STOP MODE CLR CLK2 CLK1 CLK0 Free-running timer overflow interrupt request Timer control status register (upper) (TCCSH0,♦TCCSH1) ECKE φ : Machine clock OF : Overflow ♦ : Name for 16-bit free-running timer ch.1 ● Prescaler The prescaler divides the frequency of the machine clock signal and supplies the product to the 16-bit counter as its count clock signal. The count clock cycle can be selected from among eight options, depending on the settings (TCCSL: CLK2 to CLK0) in the timer control status register. ● Timer data register (TCDT) The timer data register can read the counter value of the 16-bit free-running timer. While the 16-bit freerunning timer is inactive, the counter value can be set by writing it to the TCDT register. ● Timer control status registers (TCCSH, TCCSL) The timer control status registers (upper and lower) can be used to select the count clock, select the counter clear condition, clear the counter, enable counting, enable interrupt requests, and to check the overflow generation flag. 242 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer MB90860E Series 13.2.2 Block Diagrams of Input Capture Units The individual input capture units consist of the blocks illustrated below. ■ Block Diagrams of Input Capture Units Figure 13.2-3 Block Diagram of Input Capture Unit 0 16-bit free-running timer Edge detection circuit IN3 Input capture data register 3 (IPCP3) Pin IN2 Input capture data register 2 (IPCP2) Pin Input capture edge register (ICE23) IEI3 IEI2 2 2 ICP3 ICP2 ICE3 ICE2 EG31 EG30 EG21 EG20 Input capture interrupt request Input capture control status register (ICS01) Internal data bus Input capture control status register (ICS23) ICP1 ICP0 ICE1 ICE0 EG11 EG10 EG01 EG00 2 2 Input capture edge register (ICE01) ICUS1 ICUS0 IEI1 IEI0 IN1 Pin Input capture data register 1 (IPCP1) LIN-UART1 IN0 Pin Input capture data register 0 (IPCP0) LIN-UART0 Edge detection circuit CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 243 CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer MB90860E Series Figure 13.2-4 Block Diagram of Input Capture Unit 1 16-bit free-running timer Edge detection circuit IN7 Pin Input capture data register 7 (IPCP7) LIN-UART3 IN6 Pin Input capture edge register 6 (IPCP6) LIN-UART2 LIN-UART4 2 ICUS7 ICUS61 ICUS60 IEI7 IEI6 Input capture edge register (ICE67) 2 2 ICP7 ICP6 ICE7 ICE6 EG71 EG70 EG61 EG60 Input capture interrupt request Input capture control status register (ICS45) Internal data bus Input capture control status register (ICS67) ICP5 ICP4 ICE5 ICE4 EG51 EG50 EG41 EG40 2 2 Input capture edge register (ICE45) IEI5 IEI4 IN5 Pin Input capture data register 5 (IPCP5) IN4 Pin Input capture data register 4 (IPCP4) Edge detection circuit 244 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer MB90860E Series ● Input capture data registers 0 to 7 (IPCP0 to IPCP7) • The input capture data registers hold the captured counter value of the 16-bit free-running timers. • Input capture data registers 0 to 3 hold the counter value of 16-bit free-running timer 0. • Input capture data registers 4 to 7 hold the counter value of 16-bit free-running timer 1. ● Input capture control status registers 01 to 67 (ICS01 to ICS67) • The input capture control status registers can be used to select the edge trigger, enable capturing, enable capture interrupt requests, and to check the valid edge detection flag for the individual input capture units. • There are four input capture control status registers. These are used to control the input capture operations of their respective channels as shown in Table 13.2-2. ● Input capture edge registers 01 to 67 (ICE01 to ICE67) • The input capture edge registers display the polarities of edges detected through the input capture of their respective channels. They are also used to select the input signal (external pin INx or LIN-UART). When LIN-UART is selected as the input, the baud rate can be measured in LIN slave mode (see Section "20.7.3 Operation of LIN Function (Operating Mode 3)"). • There are four input capture edge registers. These are used to control the input capture operations of their respective channels as shown in Table 13.2-2. Table 13.2-2 Correspondence Between Input Capture Registers and Pins Input capture control status register Input capture edge register ICS01 ICE01 Input capture unit 0 ICS23 ICS45 Input pin Input from LIN-UART IPCP0 IN0 UART0 IPCP1 IN1 UART1 IPCP2 IN2 — IPCP3 IN3 — IPCP4 IN4 — IPCP5 IN5 — IPCP6 IN6 UART2, 4 IPCP7 IN7 UART3 ICE23 ICE45 Input capture unit 1 ICS67 Input capture data register ICE67 ● Edge detection circuit The edge detection circuit detects the edges of signals input to the external input pins. The edge type to be detected can be selected from among the rising edge, falling edge, both edges, and no detection (capture off). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 245 CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer 13.2.3 MB90860E Series Block Diagram of Output Compare Unit The output compare unit consists of the following blocks: ■ Block Diagram of Output Compare Unit Figure 13.2-5 Block Diagram of Output Compare Unit 0 (1) Output compare interrupt request Output compare control status register OCS2, 3 (OCS6, 7) CMOD1 CMOD0 OTE3 OTE2 OTD3 OTD2 IOP3 IOP2 IOE3 IOE2 2 2 CST3 CST2 2 2 Timer data register TCDT0 (TCDT1) 16-bit free-running timer 0 (1) Compare control circuit 3 (7) OCCP3 (OCCP7) Output compare register 3 (7) Compare control circuit 2 (6) OUT3 (OUT7) Output control circuit 3 (7) Internal data bus OCCP2 (OCCP6) Output compare register 2 (6) Pin OUT2 (OUT6) Output control circuit 2 (6) Pin Compare control circuit 1 (5) OUT1 (OUT5) OCCP1 (OCCP5) Output control circuit 1 (5) Output compare register 1 (5) Pin OUT0 (OUT4) Output control circuit 0 (4) Compare control circuit 0 (4) Pin OCCP0 (OCCP4) Output compare register 0 (4) 2 2 CMOD1 CMOD0 OTE1 OTE0 OTD1 OTD0 IOP1 IOP0 IOE1 IOE0 Output compare control status register OCS0, 1(OCS4, 5) CST1 CST0 Output compare interrupt request Components of output compare unit 1 are designated as in parentheses (). 246 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.2 Block Diagram of 16-bit I/O Timer MB90860E Series ● Output compare registers 0 to 7 (OCCP0 to OCCP7) • The output compare registers contain the values to be compared with the counter value of the 16-bit free-running timer. • The values set in output compare registers 0 to 3 are compared with the counter value of 16-bit freerunning timer 0. • The values set in output compare registers 4 to 7 are compared with the counter value of 16-bit freerunning timer 1. • When a value set in output compare registers 0 to 7 matches the counter value of the free-running timer, the output level of the corresponding output compare output pin is inverted and an interrupt request is issued. ● Output compare control status registers 0 to 7 (OCS0 to OCS7) • The output compare control status registers can be used to set and check the output levels of the output compare pins, enable their output, select the output level inversion mode, enable and check compare match interrupts, and to enable output comparison. • There are four output compare control status registers. These are used to control the output comparison of their respective channels as shown in Table 13.2-3. Table 13.2-3 Correspondence Between Output Compare Control Status Registers and Pins Register name Output compare unit 0 Output compare unit 1 Output compare register controlled Output pin Output compare control status register 0,1 (OCS0,1) Output compare register 0 OUT0 Output compare register 1 OUT1 Output compare control status register 2,3 (OCS2,3) Output compare register 2 OUT2 Output compare register 3 OUT3 Output compare control status register 4,5 (OCS4,5) Output compare register 4 OUT4 Output compare register 5 OUT5 Output compare control status register 6,7 (OCS6,7) Output compare register 6 OUT6 Output compare register 7 OUT7 ● Compare control circuits 0 to 7 The compare control circuits compare the output compare register values with the 16-bit free-running timer value and, if a compare match is detected, output a compare match signal to the corresponding output control circuit. ● Output control circuits 0 to 7 The output control circuits inverts the output level of an output compare pin when the output compare register value matches the 16-bit free-running timer value. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 247 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer 13.3 MB90860E Series Configuration of 16-bit I/O Timer This section details the pins, interrupt triggers, and registers for the 16-bit I/O timer. ■ Pins for 16-bit I/O Timer The pins used for the 16-bit I/O timer also serve as general-purpose I/O ports. Table 13.3-1 lists the pins, their functions, and the settings for use by the 16-bit I/O timer. Table 13.3-1 Pins for 16-bit I/O Timer Channel Pin name Pin function 16-bit free-running timer 0 P44/ SDA0/ FRCK0 General-purpose I/O port / I2C0 data input/output / external clock input • Use the port direction register (DDR) to set the pins as input ports. • Disable I2C0 operation (ICCR0:EN=0). 16-bit free-running timer 1 P45/ SCL0/ FRCK1 General-purpose I/O port / I2C0 clock input/output / external clock input • Use the port direction register (DDR) to set the pins as input ports. • Disable I2C0 operation (clock control register ICCR0:EN=0). Input capture 0 P24/IN0 Use the port direction register (DDR) to set the pin as an input port. Input capture 1 P25/IN1 Use the port direction register (DDR) to set the pin as an input port. Input capture 2 P26/IN2 Input capture 3 P27/IN3 Input capture 4 P30/IN4 Use the port direction register (DDR) to set the pin as an input port. Input capture 5 P31/IN5 Use the port direction register (DDR) to set the pin as an input port. Input capture 6 P42/ IN6/ INT9R General-purpose I/O port / capture input / external interrupt input Use the port direction register (DDR) to set the pin as an input port. Input capture 7 P43/ IN7 General-purpose I/O port / capture input Use the port direction register (DDR) to set the pin as an input port. General-purpose I/O port / capture input Setting required for pin use Use the port direction register (DDR) to set the pin as an input port. Use the port direction register (DDR) to set the pin as an input port. Output compare 0 P94/OUT0 Enable output compare output (OCS1: OTE0=1) Output compare 1 P95/OUT1 Enable output compare output (OCS1: OTE1=1) Output compare 2 P96/OUT2 Enable output compare output (OCS3: OTE2=1) Output compare 3 P97/OUT3 Output compare 4 P34/OUT4 Output compare 5 P35/OUT5 Enable output compare output (OCS5: OTE5=1) Output compare 6 P36/OUT6 Enable output compare output (OCS7: OTE6=1) Output compare 7 P37/OUT7 Enable output compare output (OCS7: OTE7=1) 248 General-purpose I/O port / compare output Enable output compare output (OCS3: OTE3=1) Enable output compare output (OCS5: OTE4=1) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series ■ Generation of Interrupt Requests by the 16-bit I/O Timer The 16-bit I/O timer can generate the following types of interrupt requests: ● Timer counter overflow interrupt An interrupt request is generated when either of the following events occurs with overflow interrupt requests enabled (TCCSL: IVFE=1): • The 16-bit free-running timer causes an overflow. • The counter of the 16-bit free-running timer is cleared (with TCCSL:MODE=1) as the counter value matches an output compare register value. ● Input capture interrupt When input capture interrupt requests have been enabled (ICS01:ICE=1), an interrupt request is generated if a trigger edge is detected at the input capture pin or if the trigger edge for LIN slave baud rate measurement is input from LIN-UART. ● Output compare interrupt When output compare interrupt requests have been enabled (OCS0: IOE=1), an interrupt request is generated if the counter value of the 16-bit free-running timer matches an output compare register value. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 249 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer 13.3.1 MB90860E Series Timer Control Status Register (Upper) (TCCSH0, TCCSH1) The timer control status register (upper) can be used to select the count clock and counter clear condition, clear the counter, enable counting and interrupts, and to check the interrupt request flag. ■ Timer Control Status Register (Upper) (TCCSH0, TCCSH1) Figure 13.3-1 Timer Control Status Register (Upper) (TCCSH0, TCCSH1) Address: TCCSH0 : 007943H TCCSH1 : 007947H 15 14 13 12 11 10 9 8 ECKE - - - - - - - R/W - - - - - - - Initial value 0XXXXXXXB bit15 External clock input enable bit ECKE 0 Use internal clock (prescaler output). 1 Use external clock (FRCK0/1 pin input). R/W : Readable/writable : Undefined X : Undefined bit : Initial value Table 13.3-2 Functions of Timer Control Status Register (Upper) (TCCSH0, TCCSH1) Bit name bit15 ECKE: External clock input enable bit This bit selects the count clock for the 16-bit free-running timer. Setting the bit to "1": Selects the clock signal input via the external pin FRCK0/FRCK1. Setting the bit to "0": Selects the internal clock signal (output from the prescaler). Note: Set the ECKE bit with the free-running timer inactive (TCCSL:STOP=1). Undefined bits When read : The bits contain indeterminate values. When written : The bits have no effect. bit14 to bit8 250 Function FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series 13.3.2 Timer Control Status Register (Lower) (TCCSL0, TCCSL1) The timer control status register (lower) can be used to select the count clock and counter clear condition, clear the counter, enable counting and interrupts, and to check the interrupt request flag. ■ Timer Control Status Register (Lower) (TCCSL0, TCCSL1) Figure 13.3-2 Timer Control Status Register (Lower) (TCCSL0, TCCSL1) Address 7 TCCSL0:007942H TCCSL1:007946H IVF 6 5 4 3 2 1 0 Initial value IVFE STOP MODE CLR CLK2 CLK1 CLK0 00000000 B R/W R/W R/W R/W R/W R/W R/W R/W bit2 bit1 bit0 Count clock setting bits CLK2 CLK1 CLK0 Count φ=16MHz φ=18MHz φ=4MHz φ=1MHz clock 0 0 0 φ 62.5 ns 0.125 μs 0.25 μs 1 μs 0 0 1 φ/2 0.125 μs 0.25 μs 0.5 μs 2 μs 0 1 0 φ/4 0.25 μs 0.5 μs 1 μs 4 μs 0 1 1 φ/8 0.5 μs 1 μs 2 μs 8 μs 1 0 0 φ/16 1 μs 2 μs 4 μs 16 μs 1 0 1 φ/32 2 μs 4 μs 8 μs 32 μs 1 1 0 φ/64 4 μs 8 μs 16 μs 64 μs 1 1 1 φ/128 8 μs 16 μs 32 μs 128 μs φ: Machine clock bit3 CLR Timer clear bit 0 No effect 1 Clears the counter (TCDT = 0000H). bit4 MODE Clear condition select bit 0 Clears the counter at a reset or with the clear bit set. 1 Clears the counter at a reset, with the clear bit set, or with a compare register match. bit5 STOP Timer operation stop bit 0 Enables timer operation. 1 Disables (stops) timer operation. bit6 IVFE Timer overflow interrupt enable bit 0 Disables timer overflow interrupts. 1 Enables timer overflow interrupts. bit7 IVF R/W : Readable/writable Timer overflow generation flag When read When written 0 Causes no timer overflow. Clears this IVF bit. 1 Causes a timer overflow. No effect : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 251 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series Table 13.3-3 Functions of Timer Control Status Register (Lower) (TCCSL0, TCCSL1) (1 / 2) Bit name Function bit7 IVF: Timer overflow generation flag This bit indicates the occurrence of a timer overflow. [Condition for setting the bit to "1"] The bit is set in either of the following two conditions: • The 16-bit free-running timer causes an overflow. • The counter is cleared upon detection of a compare match between the counter value of 16bit free-running timer 0/1 and the value of output compare register 0/4 (only with TCCSL: MODE=1). [When the bit is set to "1"] When the IVF bit is set to "1" with timer overflow interrupt requests enabled (TCCSL:IVFE=1), an interrupt request is generated. Setting the bit to "0": Clears the flag. Setting the bit to "1": Has not effect. Notes: • If "1" is set while at the same time "0" is written, "0" is registered. • When read by a read-modify-write instruction, the bit always returns "1". bit6 IVFE: Timer overflow interrupt enable bit This bit enables or disables interrupt requests to be generated when the timer overflow generation flag bit (TCCSL: IVF) is set to "1". Setting the bit to "1": Generates an interrupt request when the IVF bit is set to "1". Setting the bit to "0": Disables the generation of interrupt requests. STOP: Timer operation stop bit This bit enables or disables (stops) the operation of the 16-bit free-running timer. Setting the bit to "0": Enables timer operation, allowing the timer to be incremented based on the count clock set by CLK2 to CLK0. Setting the bit to "1": Stops timer operation. Note: When the 16-bit free-running timer stops operation, the output compare operation is stopped as well. MODE: Clear condition select bit This bit selects the condition for clearing the counter value of the 16-bit free-running timer (TCDT register). Setting the bit to "0": Clears the TCDT counter value in either of the following conditions: • A reset occurs. • The timer clear bit is set to "1" (TCCSL:CLR=1). Setting the bit to "1": Clears the TCDT counter value in any of the following conditions: • A reset occurs. • The timer clear bit is set to "1" (TCCSL:CLR=1). • 16-bit free-running timer 0 is cleared when the counter value of 16-bit free-running timer 0 matches the value of output compare register 0. • 16-bit free-running timer 1 is cleared when the counter value of 16-bit free-running timer 1 matches the value of output compare register 4. CLR: Timer clear bit This bit clears the counter (TCDT) of the 16-bit free-running timer in synchronization with a transition point of the counter. Setting the bit to "1": Clears the TCDT to 0000H. Setting the bit to "0": Has no effect. When read: The bit always returns "0". Notes: • To clear the counter with the 16-bit free-running timer inactive (TCCSL:STOP=1), write 0000H directly to the TCDT. • Writing "0" to this bit before the next count clock cycle after writing "1" prevents the counter value from being initialized. bit5 bit4 bit3 252 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer Table 13.3-3 Functions of Timer Control Status Register (Lower) (TCCSL0, TCCSL1) (2 / 2) Bit name bit2, bit1, bit0 CLK2, CLK1, CLK0: Count clock setting bits Function These bits set the count clock cycle for the 16-bit free-running timer. Note: Select the count clock cycle with the output compare unit inactive (TCCSL:STOP=1) and the input capture units inactive (ICSnm: EGn1, EGno=00B or ICSnm:EGm1, EGm0=00B). n = 0, 2, 4, 6 m = n+1 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 253 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer 13.3.3 MB90860E Series Timer Data Register (TCDT0, TCDT1) The timer data register is a 16-bit up-counter. • The timer data register can read the counter value of the 16-bit free-running timer. • While the 16-bit free-running timer is inactive, the counter value can be set. ■ Timer Data Register (TCDT0, TCDT1) Figure 13.3-3 Timer Data Register (TCDT0, TCDT1) Address TCDT0 upper: 007941H TCDT0 upper: 007945H bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 Tn15 Tn14 Tn13 Tn12 Tn11 Tn10 Tn9 Tn8 Initial value 00000000B R/W R/W R/W R/W R/W R/W R/W R/W TCDT0 lower: 007940H TCDT0 lower: 007944H bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 Initial value Tn7 Tn6 Tn5 Tn4 Tn3 Tn2 Tn1 Tn0 00000000B R/W R/W R/W R/W R/W R/W R/W R/W R/W: Readable/writable n = 0, 1 This register allows the counter value of the 16-bit free-running timer to be read from. [Conditions for clearing the counter value] The counter value is cleared to 0000H in any of the following conditions: • An overflow occurs. • A compare match occurs (only with TCCSL: MODE=1). • The timer clear bit in the timer control status register is set to "1" (TCCSL: CLR=1). • The timer data register is set to 0000H with the 16-bit free-running timer inactive. • A reset occurs. [Setting the counter value] If you set the timer by writing a timer value in the timer data register (TCDT), access the TCDT with the timer inactive (TCCSL: STOP=1). Note: 254 To read from or write to the timer data register, be sure to use a word instruction (MOVW). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series 13.3.4 Input Capture Control Status Registers (ICS) This section describes the functions of input capture control status registers. ICS01 to ICS67 correspond to input pins as follows: ICS01: IN0 IN1 Input capture ch.0, ch.1 ICS23: IN2 IN3 Input capture ch.2, ch.3 ICS45: IN4 IN5 Input capture ch.4, ch.5 ICS67: IN6 IN7 Input capture ch.6, ch.7 ■ Input Capture Control Status Register (ICS) Figure 13.3-4 Input Capture Control Status Register (ICS) Address 7 6 5 4 3 2 1 0 ICS01 : 000050H ICS23 : 000052H ICPm ICPn ICEm ICEn EGm1 EGm0 EGn1 EGn0 ICS45 : 000054H R/W R/W R/W R/W R/W R/W R/W R/W ICS67 : 000056H Initial value 00000000B bit1 EGn1 0 0 1 1 bit0 EGn0 0 1 0 1 Edge select bits n Detect no edge. (Operation stopped) Detect the rising edge. Detect the falling edge. Detect both edges. bit3 EGm1 0 0 1 1 bit2 EGm0 0 1 0 1 Edge select bits m Detect no edge. (Operation stopped) Detect the rising edge. Detect the falling edge. Detect both edges. bit4 ICEn 0 1 Capture interrupt enable bit n Disables input capture 0 interrupts. Enables input capture 0 interrupts. bit5 ICEm Capture interrupt enable bit m 0 Disables input capture 1 interrupts. 1 Enables input capture 1 interrupts. bit6 ICPn 0 1 Valid edge detection flag bit n When read When written Valid edge not detected for input Clears this ICP0 bit. capture 0 Valid edge detected for input No effect capture 0 bit7 ICPm 0 R/W : Readable/writable : Initial value CM44-10144-4E n = 0, 2, 4, 6 m = n+1 1 Valid edge detection flag bit m When read When written Valid edge detected for input Clears this ICP1 bit. capture 1 Valid edge detected for input No effect capture 1 FUJITSU SEMICONDUCTOR LIMITED 255 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series Table 13.3-4 Functions of Input Capture Control Status Register (ICS) Bit name Function ICPm: Valid edge detection flag bit m This bit is set to "1" upon detection of a valid edge at the INm pin. If input capture m interrupt requests have been enabled (ICSnm:ICEm=1), an interrupt request is generated when the ICPm bit is set. Setting the bit to "0": Clears the flag. Setting the bit to "1": Has no effect. Note: If "1" is set while at the same time "0" is written, "0" is registered. bit6 ICPn: Valid edge detection flag bit n This bit is set to "1" upon detection of a valid edge at the INn pin. • If input capture n interrupt requests have been enabled (ICSnm:ICEn=1), an interrupt request is generated when the ICPn bit is set. Setting the bit to "0": Clears the flag. Setting the bit to "1": Has no effect. Note: If "1" is set while at the same time "0" is written, "0" is registered.. bit5 ICEm: Capture interrupt enable bit m This bit enables or disables input capture m interrupt requests. Setting the bit to "1": Generates an interrupt request when valid edge detection flag bit m is set to "1" (ICSnm: ICPm=1). bit4 ICEn: Capture interrupt enable bit n This bit enables or disables input capture n interrupt requests. Setting the bit to "1": Generates an interrupt request when valid edge detection flag bit n is set to "1" (ICSnm: ICPn=1). bit3, bit2 EGm1, EGm0: Edge select bits m These bits select the capture trigger edge for input capture register m. • Trigger edge setting enables or disables capturing as well. Setting the bits to "00B": Detects no edge and stops capturing. bit1, bit0 EGn1, EGn0: Edge select bits n These bits select the capture trigger edge for input capture register n. • Trigger edge setting enables or disables capturing as well. Setting the bits to "00B": Detects no edge and stops capturing. bit7 n = 0, 2, 4, 6 m = n+1 256 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series 13.3.5 Input Capture Registers (IPCP0 to IPCP7) • Input capture registers contain counter values captured from the 16-bit free-running timer. • These are 16-bit read-only registers. There are input capture registers 0 to 7 (IPCP0 to IPCP7). ■ Input Capture Registers (IPCP0 to IPCP7) Figure 13.3-5 Input Capture Registers (IPCP0 to IPCP7) Address IPCP0 (upper): 007921H bit15 bit14 bit13 bit12 bit11 bit10 bit9 Initial value bit8 CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP0 (lower): 007920H R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 IPCP1 (upper): 007923H CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP1 (lower): 007922H R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 IPCP2 (upper): 007925H CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP2 (lower): 007924H R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 IPCP3 (upper): 007927H CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP3 (lower): 007926H R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 IPCP4 (upper): 007929H CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP4 (lower): 007928H R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 IPCP5 (upper): 00792BH CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP5 (lower): 00792AH R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 IPCP6 (upper): 00792DH CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP6 (lower): 00792CH R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 IPCP7 (upper): 00792FH CP15 CP14 CP13 CP12 CP11 CP10 CP09 CP08 R R bit7 IPCP7 (lower): 00792EH R X : Read-only : Undefined CM44-10144-4E R bit6 R bit5 R bit4 R bit3 R bit2 XXXXXXXXB R bit1 bit0 CP07 CP06 CP05 CP04 CP03 CP02 CP01 CP00 XXXXXXXXB R R R R R R R R FUJITSU SEMICONDUCTOR LIMITED 257 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series When the capture trigger edge (set by ICSnm: EGn1, Egn0; or EGm1, EGm0) is detected at the IN0 to IN7 pin, input capture register 0 to 7 corresponding to the pin contains the counter value of the 16-bit freerunning timer. For input capture registers 0, 1, 6, and 7, however, the signal from LIN-UART can be selected as the input signal (by using the ICE:IEI bit). For details, see Section "13.3.6 Input Capture Edge Registers (ICE01, ICE23, ICE45, ICE67)". • Input capture registers are read-only; they cannot be written to. n = 0, 2, 4, 6 m = n+1 Note: 258 To read input capture registers, be sure to use a word instruction (MOVW). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series 13.3.6 Input Capture Edge Registers (ICE01, ICE23, ICE45, ICE67) Input capture edge registers are used to indicate the detected edge direction and to select the external pin or LIN-UART as the input signal source. In combination with LINUART, the input capture edge registers can measure the baud rate during LIN slave operation. ICE01 to ICE67 correspond to input capture channels and input pins (UART) as follows: ICE01: Input capture ch.0, ch.1 IN0 (/UART0) IN1 (/UART1) ICE23: Input capture ch.2, ch.3 IN2 IN3 ICE45: Input capture ch.4, ch.5 IN4 IN5 ICE67: Input capture ch.6, ch.7 IN6 (/UART2, 4) IN7 (/UART3) ■ Input Capture Edge Registers (ICE01, ICE23, ICE45, ICE67) Figure 13.3-6 Input Capture Edge Registers (ICE01, ICE23, ICE45, ICE67) ICE01: 000051H bit 15 14 13 12 11 10 9 8 − − − − − − ICUS1 R/W − − ICUS0 R/W IEI1 R IEI0 R Initial value XXX0X0XXB bit10 ICUS0 Input signal select bit 0 0 External pin IN1 input signal 1 Signal from UART0 bit12 ICUS1 Input signal select bit 1 0 External pin IN1 input signal 1 Signal from UART1 ICE23: 000053H ICE45: 000055H ICE67: 000057H bit 15 14 13 12 11 10 9 8 − − − − − − − − − − − − IEI3 R IEI2 R bit 15 14 13 12 11 10 9 8 − − − − − − − − − − − − IEI5 R IEI4 R bit 15 14 13 12 11 10 − − − − − − ICUS7 ICUS61 ICUS60 R/W R/W R/W 9 8 IEI7 R IEI6 R Initial value XXXXXXXXB Initial value XXXXXXXXB Initial value XXX000XXB bit11 bit8 IEIn Detected edge display bit n 0 Detects falling edge. 1 Detects rising edge. bit9 IEIm Detected edge display bit m 0 Detects falling edge. 1 Detects rising edge. bit10 ICUS61 ICUS60 R/W R − X : Readable/writable : Read-only : Undefined : Undefined : Initial value n = 0, 2, 4, 6 m = n + 1 CM44-10144-4E 0 0 1 1 0 1 0 1 Input signal select bits 61, 60 External pin IN6 input signal Signal from UART2 Signal from UART4 bit12 ICUS7 0 1 Input signal select bit 7 External pin IN7 input signal Signal from UART3 FUJITSU SEMICONDUCTOR LIMITED 259 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series Table 13.3-5 Functions of Input Capture Edge Register 01 (ICE01) Bit name bit15 Function Undefined bits When read : The bits contain indeterminate values. When written : The bits have no effect. bit12 ICUS1: Input signal select bit 1 This bit selects the input signal to be used to trigger input capture 1. Setting the bit to "0": Selects external pin IN1. Setting the bit to "1": Selects LIN-UART1. bit11 Undefined bit When read : The bit contains an indeterminate value. When written: The bit has no effect. bit10 ICUS0: Input signal select bit 0 This bit selects the input signal to be used to trigger input capture 0. Setting the bit to "0": Selects external pin IN0. Setting the bit to "1": Selects LIN-UART0. IEI1: Detected edge display bit 1 This bit indicates the type (rising or falling) of edge detected by input capture 1. • This bit is read-only. "0": Indicates that the falling edge has been detected. "1": Indicates that the rising edge has been detected. Note: The value of this bit remains invalid while capturing is stopped (ICS01: EG11, EG10=00B). IEI0: Detected edge display bit 0 This bit indicates the type (rising or falling) of edge detected by input capture 0. • This bit is read-only. "0": Indicates that the falling edge has been detected. "1": Indicates that the rising edge has been detected. Note: The value of this bit remains invalid while capturing is stopped (ICS01: EG01, EG00=00B). to bit13 bit9 bit8 260 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer Table 13.3-6 Functions of Input Capture Edge Registers 23, 45 (ICE23, ICE45) Bit name bit15 to bit10 bit9 bit8 Function Undefined bits When read : The bits contain indeterminate values. When written : The bits have no effect. IEI3, IEI5: Detected edge display bit 3/ 5 This bit indicates the type (rising or falling) of edge detected by input capture 3 or 5. • This bit is read-only. "0": Indicates that the falling edge has been detected. "1": Indicates that the rising edge has been detected. Note: The value of this bit remains invalid while capturing is stopped (ICSnm:EGm1, EGm0=00B). (n = 2, 4 m = n+1) IEI2, IEI4: Detected edge display bit 2/ 4 This bit indicates the type (rising or falling) of edge detected by input capture 2 or 4. • This bit is read-only. "0": Indicates that the falling edge has been detected. "1": Indicates that the rising edge has been detected. Note: The value of this bit remains invalid while capturing is stopped (ICSnm:EGn1, EGn0=00B). (n = 2, 4 m = n+1) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 261 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series Table 13.3-7 Functions of Input Capture Edge Register 67 (ICE67) Bit name bit15 Function Undefined bits When read : The bits contain indeterminate values. When written : The bits have no effect. bit12 ICUS7: Input signal select bit 7 This bit selects the input signal to be used to trigger input capture 7. Setting the bit to "0": Selects external pin IN7. Setting the bit to "1": Selects LIN-UART3. bit11, bit10 ICUS61, ICU60: Input signal select bits 61, 60 These bits select the input signal to be used to trigger input capture 6. Setting the bits to "00B": Selects external pin IN6. Setting the bits to "01B": Selects LIN-UART2. Setting the bits to "11B" or "10B": Selects LIN-UART4. IEI7: Detected edge display bit 7 This bit indicates the type (rising or falling) of edge detected by input capture 7. • This bit is read-only. "0": Indicates that the falling edge has been detected. "1": Indicates that the rising edge has been detected. Note: The value of this bit remains invalid while capturing is stopped (ICS67: EG71, EG70=00B). IEI6: Detected edge display bit 6 This bit indicates the type (rising or falling) of edge detected by input capture 6. • This bit is read-only. "0": Indicates that the falling edge has been detected "1": Indicates that the rising edge has been detected. Note: The value of this bit remains invalid while capturing is stopped (ICS67: EG61, EG60=00B). to bit13 bit9 bit8 Note: 262 If the LIN-UART is selected as the input signal source (ICEnm: ICUS) for input capture channel 0, 1, 6, or 7, the input capture channel is used to calculate the baud rate with the LIN-UART operating in LIN slave mode. In this case, enable input capture interrupts (ICSnm: ICEn=1 or ICEm=1) and select the detection of both edges (ICSnm: EGn1, EGn0=11B or EGm1, EGm0=11B). For details on baud rate calculation, see Section "20.7.3 Operation of LIN Function (Operating Mode 3)". n = 0, 2, 4, 6 m = n+1 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series 13.3.7 Output Compare Control Status Register (OCS) (Upper) The output compare control status register (OCS) (upper) can be used to enable the output of output compare pins, set and check their output level, and to select the output level inversion mode. OCS1, OCS3, OCS5, and OCS7 correspond to output pins and channels as follows: OCS1: OUT0 OUT1 Output compare ch.0, ch.1 OCS3: OUT2 OUT3 Output compare ch.2, ch.3 OCS5: OUT4 OUT5 Output compare ch.4, ch.5 OCS7: OUT6 OUT7 Output compare ch.6, ch.7 ■ Output Compare Control Status Register (OCS) (Upper) Figure 13.3-7 Output Compare Control Status Register (OCS) (Upper) Address 15 14 OCS1 : 000059 H OCS3 : 00005B H CMOD1 OCS5 : 00005DH OCS7 : 00005F H R/W 13 12 CMOD0 11 10 9 8 OTEm OTEn OTDm OTDn Initial value 0XX00000 B R/W R/W R/W R/W R/W bit8 OTDn Output level setting bit n 0 Sets OUTn output level to "L". OUTn pin output level 1 Sets OUTn output level to "H". bit9 OTDm Output level setting bit m 0 Sets OUTm output level to "L". OUTm pin output level 1 Sets OUTm output level to "H". bit10 OTEn Compare output enable bit n 0 General-purpose I/O port 1 Output compare output (OUTn) bit11 OTEm Compare output enable bit m 0 General-purpose I/O port 1 Output compare output (OUTm) R/W : Readable/writable : Undefined X : Undefined : Initial value bit15 bit12 CMOD1 CMOD0 Output level inversion mode select bits 0 0 0 1 Set the condition for inverting the pin output level. For details, see Table 13.3-9. 1 0 1 1 n = 0, 2, 4, 6 m = n+1 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 263 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series Table 13.3-8 Functions of Output Compare Control Status Register (OCS) (Upper) Bit name Function bit15, bit12 CMOD1, CMOD0: Output level inversion mode select bits These bits set the compare match detection condition for inverting the pin output level. • Table 13.3-9 lists the output level inversion modes and compare match detection conditions. bit14, bit13 Undefined bits When read : The bits contain indeterminate values. When written : The bits have no effect. bit11 OTEm: Compare output enable bit m This bit enables the output of output compare pin OUTm. Setting the bit to "1": Assigns the pin as an output compare output pin. Setting the bit to "0": Assigns the pin as a general-purpose I/O port. bit10 OTEn: Compare output enable bit n This bit enables the output of output compare pin OUTn. Setting the bit to "1": Assigns the pin as an output compare output pin. Setting the bit to "0": Assigns the pin as a general-purpose I/O port. OTDm: Output level setting bit m This bit sets the output level of the OUTm pin. • When output compare pin output is enabled (OCS: OTEm=1), the "L" or "H" level set by the OTDm bit is output at the OUTm pin. • Set the OTDm bit while output comparison is stopped (OCS: CSTm=0). When read: The bit returns the output level of the OUTm pin. OTDn: Output level setting bit n This bit sets the output level of the OUTn pin. • When output compare pin output is enabled (OCS: OTEn=1), the "L" or "H" level set by the OTDn bit is output at the OUTn pin. • Set the OTDn bit while output comparison is stopped (OCS: CSTn=0). When read: The bit returns the output level of the OUTn pin. bit9 bit8 n = 0, 2, 4, 6 m = n+1 264 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series Table 13.3-9 Output Level Inversion Mode and Compare Match Detection Controlled register name Output level inversion mode CMOD1 CMOD0 X 0 Output inverted pin name Compared register name Output inverted pin name Free-running timer 0: OCCP1 Free-running timer 0: OCCP0 X 1 Free-running timer 0: OCCP0 Free-running timer 0: OCCP1 0 0 Free-running timer 0: OCCP3 OCS1 OUT0 OUT1 Free-running timer 0: OCCP2 0 OUT2 1 Free-running timer 0: OCCP2 Free-running timer 0: OCCP3 1 OCS3 OUT3 0 Free-running timer 0: OCCP0 Free-running timer 0: OCCP2 1 1 X 0 Free-running timer 1: OCCP5 Free-running timer 1: OCCP4 X 1 Free-running timer 1: OCCP4 Free-running timer 1: OCCP5 0 0 Free-running timer 1: OCCP7 OUT4 OUT5 Free-running timer 1: OCCP6 0 1 1 Free-running timer 1: OCCP6 Free-running timer 1: OCCP7 1 0 OUT6 OUT7 Free-running timer 1: OCCP4 Free-running timer 1: OCCP6 CM44-10144-4E Free-running timer 0: OCCP0 Free-running timer 0: OCCP3 Free-running timer 0: OCCP0Free-running timer 0: OCCP2 Free-running timer 0: OCCP3 OCS5 OCS7 Compared register name 1 FUJITSU SEMICONDUCTOR LIMITED Free-running timer 1: OCCP4 Free-running timer 1: OCCP7 Free-running timer 1: OCCP4 Free-running timer 1: OCCP6 Free-running timer 1: OCCP7 265 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer 13.3.8 MB90860E Series Output Compare Control Status Register (OCS) (Lower) This section describes the functions of the output compare control status register. OCS0, OCS2, OCS4, and OCS6 correspond to output pins and channels as follows: OCS0: Output compare ch.0, ch.1 OCS2: Output compare ch.2, ch.3 OCS4: Output compare ch.4, ch.5 OCS6: Output compare ch.6, ch.7 ■ Output Compare Control Status Register (OCS) (Lower) Figure 13.3-8 Output Compare Control Status Register (OCS) (Lower) Address OCS0: 000058H OCS2: 00005AH OCS4: 00005CH OCS6: 00005EH 7 6 5 4 3 2 1 0 IOPm IOPn IOEm IOEn CSTm CSTn R/W R/W R/W R/W R/W R/W Initial value 0000XX00B bit0 CSTn Compare operation enable bit n 0 Disables operation of output compare ch n. 1 Enables operation of output compare ch n. bit1 CSTm Compare operation enable bit m 0 Disables operation of output compare ch m. 1 Enables operation of output compare ch m. bit4 IOEn Compare match interrupt enable bit n 0 Disables output compare ch n interrupts. 1 Enables output compare ch n interrupts. bit5 IOEm Compare match interrupt enable bit m 0 Disables output compare ch m interrupts. 1 Enables output compare ch m interrupts. bit6 IOPn 0 1 Compare match flag bit n When read When written Detects no compare match Clears this IOPn bit. of output compare ch n. Detects a compare match No effect of output compare ch n. bit7 IOPm R/W : Readable/writable : Undefined X : Undefined : Initial value 0 1 Compare match flag bit m When read When written Detects no compare match Clears this IOPm bit. of output compare ch m. Detects a compare match of No effect output compare ch m. n = 0, 2, 4, 6 m = n+1 266 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer Table 13.3-10 Functions of Output Compare Control Status Register (OCS) (Lower) Bit name Function IOPm: Compare match flag bit m This bit is set to "1" when the value of output compare register m matches the counter value of the corresponding 16-bit free-running timer. • If compare match interrupt requests have been enabled (OCS:IOEm=1), an interrupt request is generated when the IOPm bit is set to "1". Setting the bit to "0": Clears the flag. Setting the bit to "1": Has no effect. Notes: • If "1" is set while at the same time "0" is written, "0" is registered. • When read by a read-modify-write instruction, the bit always returns "1". bit6 IOPn: Compare match flag bit n This bit is set to "1" when the value of output compare register n matches the counter value of the corresponding 16-bit free-running timer. • If compare match interrupt requests have been enabled (OCS:IOEn=1), an interrupt request is generated when the IOPn bit is set to "1". Setting the bit to "0": Clears the flag. Setting the bit to "1": Has no effect. Notes: • If "1" is set while at the same time "0" is written, "0" is registered. • When read by a read-modify-write instruction, the bit always returns "1". bit5 IOEm: Compare match interrupt enable bit m This bit enables or disables interrupt requests to be generated when the value of output compare register m matches the counter value of the corresponding 16-bit free-running timer. Setting the bit to "1": Generates an interrupt request when compare match flag bit m (OCS:IOPm) is set to "1". bit4 IOEn: Compare match interrupt enable bit n This bit enables or disables interrupt requests to be generated when the value of output compare register n matches the counter value of the corresponding 16-bit free-running timer. Setting the bit to "1": Generates an interrupt request when compare match flag bit n (OCS:IOPn) is set to "1". bit3, bit2 Undefined bits When read : The bits contain indeterminate values. When written : The bits have no effect. bit1 CSTm: Compare operation enable bit m This bit enables or disables comparison of output compare ch m. Setting the bit to "0": Disables comparison. Setting the bit to "1": Enables comparison. Note: When a 16-bit free-running timer is stopped (TCCSL:STOP=1), the operation of the corresponding output compare channel is stopped. bit0 CSTn: Compare operation enable bit n This bit enables or disables comparison of output compare ch n. Setting the bit to "0": Disables comparison. Setting the bit to "1": Enables comparison. Note: When a 16-bit free-running timer is stopped (TCCSL:STOP=1), the operation of the corresponding output compare channel is stopped. bit7 n = 0, 2, 4, 6, m = n+1 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 267 CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer 13.3.9 MB90860E Series Output Compare Registers (OCCP0 to OCCP7) Output compare registers contain values to be compared with the counter value of the 16-bit free-running timer. • There are eight channels: output compare registers 0 to 7 (OCCP0 to OCCP7). ■ Output Compare Registers (OCCP0 to OCCP7) Figure 13.3-9 Output Compare Registers (OCCP0 to OCCP7) Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP0 (upper): 007931H C15 C14 C13 C12 C11 bit8 C10 C09 C08 Initial value XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 OCCP0 (lower): 007930H C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP1 (upper): 007933H C15 C14 C13 C12 C11 bit8 C10 C09 C08 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 OCCP1 (lower): 007932H C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP2 (upper): 007935H OCCP2 (lower): 007934H C15 C14 C13 C12 C11 bit8 C10 C09 C08 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP3 (upper): 007937H C15 C14 C13 C12 C11 bit8 C10 C09 C08 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 OCCP3 (lower): 007936H C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/writable X : Undefined 268 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.3 Configuration of 16-bit I/O Timer MB90860E Series Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP4 (upper): 007939H C15 C14 C13 C12 C11 bit8 C10 C09 C08 Initial value XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 OCCP4 (lower): 007938H C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP5 (upper): 00793BH C15 C14 C13 C12 C11 bit8 C10 C09 C08 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 OCCP5 (lower): 00793AH C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP6 (upper): 00793DH C15 C14 C13 C12 C11 bit8 C10 C09 C08 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 OCCP6 (lower): 00793CH C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 OCCP7 (upper): 00793FH C15 C14 C13 C12 C11 bit8 C10 C09 C08 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 OCCP7 (lower): 00793EH C07 C06 C05 C04 C03 C02 C01 C00 XXXXXXXXB R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/writable X : Undefined Output compare register values are compared with the counter value of the free-running timer. When a match is detected, the level at the output compare output pin is inverted and an interrupt request is generated. After a release from a reset, the values of output compare registers are indeterminate. Before enabling comparison, set the registers to the values to be compared. (OCS: CST=1) Note: CM44-10144-4E To read from or write to output compare registers, be sure to use a word instruction (MOVW). FUJITSU SEMICONDUCTOR LIMITED 269 CHAPTER 13 16-BIT I/O TIMER 13.4 Interrupts from 16-bit I/O Timer 13.4 MB90860E Series Interrupts from 16-bit I/O Timer • An interrupt from the 16-bit I/O timer is triggered by the occurrence of an overflow from the counter of the 16-bit free-running timer, the input of a trigger edge to an input capture input pin, the input of a trigger edge for LIN slave baud rate measurement from the LIN-UART, or the detection of an output compare match. • An interrupt via an input capture channel (other than ch6 and ch7) or output compare channel can be used to activate DMA transfer or Extended Intelligent I/O Service (EI2OS). An interrupt via an input capture channel (ch6 or ch7) can be used to activate EI2OS. ■ Interrupts from 16-bit I/O Timer Table 13.4-1 lists the interrupt control bits and interrupt trigger events of the 16-bit I/O timer. Table 13.4-1 Interrupts from 16-bit I/O Timer Timer counter overflow interrupt Input capture interrupt Output compare interrupt Interrupt request flag TCCSL: IVF ICSnm: ICPn, ICPm OCSn: IOPn, IOPm Interrupt request output enable bit TCCSL: IVFE ICSnm: ICEn, ICEm OCSn: IOEn, IOEm Interrupt generation triggers 16-bit free-running timer counter overflow Input of valid edge to input capture input pin, and input of trigger edge for LIN slave baud rate measurement from LINUART Match of output compare register value with counter value n = 0, 2, 4, 6 m = n+1 ● Timer counter overflow interrupt Case in which the timer overflow interrupt request flag is set The timer overflow generation flag is set in the timer control status register in either of the following cases. (TCCSL: IVF=1) • The 16-bit free-running timer is incremented to cause an overflow (FFFFH → 0000H). • A compare match as shown below is detected when clearing by a compare match has been enabled (TCCSL: MODE=1): - The value of output compare register 0 matches the value of 16-bit free-running timer 0. - The value of output compare register 4 matches the value of 16-bit free-running timer 1. Case in which a timer overflow interrupt request is generated An interrupt request is generated when the timer overflow generation flag is set to "1" (TCCSL: IVF=1) with timer overflow interrupt requests enabled (TCCSL: IVFE=1). 270 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.4 Interrupts from 16-bit I/O Timer MB90860E Series ● Input capture interrupt An interrupt is generated as follows when a selected valid edge (ICS: EG) is detected at an input capture pin or when the trigger edge for LIN slave baud rate measurement is input from the LIN-UART (assuming that both edges have been selected as valid edges). • Upon edge detection, the current counter value of the 16-bit free-running timer is held in the input capture register. • The valid edge detection flag in the input capture control status register is set to "1". (ICS: ICP=1) • An interrupt request is generated if the output of input capture interrupt requests has been enabled (ICS: ICE=1). ● Output compare interrupt An interrupt is generated as follows when a match is detected between the value of an output compare register and the counter value of the 16-bit free-running timer. • The output compare match flag in the output compare control status register is set to "1". (OCS:IOP=1) ■ 16-bit I/O • An interrupt request is generated if output compare interrupt requests have been enabled (OCS: IOE=1). Timer Interrupts and EI2OS Reference: See "CHAPTER 3 INTERRUPTS" for interrupt numbers, interrupt control registers, and interrupt vector addresses. ■ Support for DMA Transfer and EI2OS Features The input capture units (other than ch6 and ch7) and the output compare units (all channels) support DMA transfer and EI2OS features. The input capture channels (ch6, ch7) support only the EI2OS feature. Note, however, that other interrupts sharing the interrupt control register (ICR) must be disabled before the DMA or EI2OS feature can be used. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 271 CHAPTER 13 16-BIT I/O TIMER 13.5 Operations of 16-bit Free-running Timer 13.5 MB90860E Series Operations of 16-bit Free-running Timer The 16-bit free-running timer increments its counter from 0000H after a release from a reset. The counter value of the 16-bit free-running timer is used as the reference time for the output compare and input capture units. ■ Operations of 16-bit Free-running Timer The 16-bit free-running timer must be set as shown in Figure 13.5-1 so that it can operate. Figure 13.5-1 Settings for 16-bit Free-running Timer bit15 14 13 12 11 10 9 bit8 bit7 5 4 3 2 1 bit0 IVF IVFE STOP MODE CLR CLK2 CLK1 CLK0 TCCSH/TCCSL ECKE × TCDT 6 × × × × × × 0 0 Counter value of 16-bit free-running timer : Bit used × : Undefined bit 0 : Set to "0" [Setting the counter value of the 16-bit free-running timer] • As the 16-bit free-running timer is enabled for operation after a release from a reset (TCCSL: STOP=0), it is incremented from a counter value of 0000H. • To set the counter value of the 16-bit free-running timer, disable the operation of the 16-bit free-running timer (TCCSL: STOP=1), set the count start value in the timer data register, then enable timer operation (TCCSL: STOP=0). [Generation of a timer overflow and an interrupt request] • When the 16-bit free-running timer causes an overflow (FFFFH → 0000H), the timer overflow generation flag is set to "1" (TCCSL: IVF) and the counter is incremented starting from 0000H. • An interrupt request is generated if timer overflow interrupt requests have been enabled (TCCSL: IVFE=1). 272 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.5 Operations of 16-bit Free-running Timer MB90860E Series [Trigger events and timings for clearing the counter value] • Table 13.5-1 lists the trigger events and timings for clearing the 16-bit free-running timer. Table 13.5-1 Trigger Events and Timings for Clearing the Counter Value Clearing trigger Clearing timing Writing "1" to the timer clear bit in the timer control status register (TCCSL: CLR) Synchronous with the occurrence of the trigger event Writing 0000H to an inactive timer data register Synchronous with the occurrence of the trigger event Occurrence of a reset Synchronous with the occurrence of the trigger event Occurrence of a timer overflow Synchronous with count timing Occurrence of a compare match (TCCSL: MODE=1) Synchronous with count timing • If you enable the clearing on occurrence of a compare match (TCCSL: MODE=1), the compare match flag is set to "1" (OCS: IOP) when a compare match as shown below is detected. At the same time, the counter value is cleared to 0000H and the counter is incremented. - The value of output compare register 0 matches the value of 16-bit free-running timer 0. - The value of output compare register 4 matches the value of 16-bit free-running timer 1. Figure 13.5-2 shows the timing of clearing the counter when a match with a compare register is detected. Figure 13.5-2 16-bit Free-running Timer Clear Timing φ Count clock Compare match Counter value Compare register value φ: Machine clock CM44-10144-4E N-1 0000H N N Counter cleared FUJITSU SEMICONDUCTOR LIMITED 273 CHAPTER 13 16-BIT I/O TIMER 13.5 Operations of 16-bit Free-running Timer MB90860E Series Figure 13.5-3 shows the clearing of the counter on occurrence of an overflow. Figure 13.5-3 Clearing the Counter upon Overflow Counter value Overflow FFFFH BFFFH 7FFFH 3FFFH 0000H Time Reset Figure 13.5-4 shows the clearing of the counter on occurrence of a match with a compare register. Figure 13.5-4 Clearing the Counter upon Detection of a Compare Match Counter value FFFFH BFFFH Match Match 7FFFH 3FFFH 0000H Time Reset Compare register value 274 BFFFH FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.6 Input Capture Operations MB90860E Series 13.6 Input Capture Operations Upon detection of the valid edge of an input signal from an external input pin or upon input of the trigger edge for LIN slave baud rate measurement from the LIN-UART, the input capture unit stores the counter value of the 16-bit free-running timer in the input capture register and generates an interrupt request. ■ Input Capture Operations The input capture unit must be set as shown in Figure 13.6-1 so that it can be used. Figure 13.6-1 Settings for Input Capture Operation bit15 14 13 ICE/ICS × × × 12 11 10 ICUS1/ ICUS0/ ICUS61 ICUS7 ICUS60 9 bit8 bit7 6 5 4 3 2 1 bit0 IEIm IEIn ICPm ICPn ICEm ICEn EGm1EGm0 EGn1 EGn0 Holding the capture counter value IPCP DDR port direction register Set that bit to "0" which corresponds to the pin to be used as a capture input pin. : Bits used (Set the bits corresponding to the channels to be used.) : Bits used (These bits exist only in ICE01 and ICE67. Set the bits for baud rate measurement in LIN slave mode.) n = 0, 2, 4, 6 m = n+1 [Input capture operations] The following operations are performed when the selected valid edge (ICS: EG) is detected at an input capture pin or when the trigger edge for LIN slave baud rate measurement is input from the LIN-UART: • Upon detection, the current counter value of the 16-bit free-running timer is held in the input capture register. • The direction of the detected edge is held in the detected edge display bit. (Rising edge: IEI=1, falling edge: IEI=0) • The valid edge detection flag in the input capture control status register is set to "1". (ICS:ICP=1) • An interrupt request is generated when input capture interrupt requests have been enabled (ICS: ICE=1). • To measure the baud rate in LIN slave mode, set the LIN-UART as the input signal source (ICE: ICUS), enable input capture interrupt requests (ICS: ICE=1), and select both edges as valid edges (ICE: EG1, EG0=11B). For calculation of the baud rate, see Section "20.7.3 Operation of LIN Function (Operating Mode 3)". Figure 13.6-2 shows the timing of data capturing by the input capture unit. Figure 13.6-3 shows the input capture operations with the rising edge/falling edge set as the valid edge. Figure 13.6-4 shows the input capture operations with both edges set as valid edges. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 275 CHAPTER 13 16-BIT I/O TIMER 13.6 Input Capture Operations MB90860E Series Figure 13.6-2 Timing of Data Capturing by Input Capture Unit φ Counter value N N+1 Input capture input Valid edge Capture signal Capture register N+1 Data captured φ: Machine clock Figure 13.6-3 Input Capture Operations (Rising Edge/Falling Edge) Counter value FFFFH BFFFH 7FFFH 3FFFH Time 0000H Reset INn (Rising edge) INn (Falling edge) Capture n Indeterminate Capture m Indeterminate 3FFFH 7FFFH n = 0, 2, 4, 6 m = n+1 Figure 13.6-4 Input Capture Operations (Both Edges) Counter value FFFFH BFFFH 7FFFH 3FFFH 0000H Time Reset INn (Both edges) Capture example Indeterminate BFFFH 3FFFH n = 0 to 7 276 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.7 Output Compare Operations MB90860E Series 13.7 Output Compare Operations The output compare unit compares the set compare value with the counter value of the 16-bit free-running timer. When a match is detected, it inverts the output level at the output compare pin and generates an interrupt request. ■ Output Compare Operations The output compare unit must be set as shown in Figure 13.7-1 so that it can be used. Figure 13.7-1 Settings for Output Compare Operations bit15 14 13 12 11 10 9 bit8 bit7 6 5 4 3 2 × × 1 bit0 CSTm CSTn CMOD0 OTEm OTEn OTDm OTDn IOPm IOPn IOEm IOEn OCSm/OSCn CMOD1 × × Set the value to compare. OCCP : Bit used : Undefined bit × : Set that bit to "1" which corresponds to the output compare pin to be used. n = 0, 2, 4, 6 m = n+1 [Output compare operations] • The output compare unit compares the output compare register value with the counter value of the 16bit free-running timer. When a match is detected, it performs the following operations: - The level at the output compare output pin is inverted. - The output compare match flag in the output compare control status register is set to "1". (OCS:IOP=1) - An interrupt request is generated if output compare interrupt requests have been enabled (OCS: IOE=1). [Output level setting and inversion timing] • The output level at the output compare pin can be set by the output level setting bit (OCS: OTD) in the output compare control status register. • When a compare match is detected, the output level is inverted in synchronization with the count timing of the 16-bit free-running timer. • Comparison with the counter value of the 16-bit free-running timer is not performed while the output compare register is being updated.. Note: CM44-10144-4E Avoid simultaneous occurrence of comparison result match when rewriting the compare register. Execute this action within a compare interrupt routine, or while the compare operation is stopped. FUJITSU SEMICONDUCTOR LIMITED 277 CHAPTER 13 16-BIT I/O TIMER 13.7 Output Compare Operations MB90860E Series Figure 13.7-2 to Figure 13.7-4 show output compare operations. Figure 13.7-2 Output Compare Timing φ Counter value N Compare register value N+1 N Compare match φ: Machine clock Figure 13.7-3 Inversion of the Output Level at Output Compare Output Pin Counter value N N+1 Compare register value N N+1 N Compare match signal Output pin Figure 13.7-4 Compare Operations with Output Compare Register Being Updated Counter value Value of compare register 0 N M N+2 N+1 No match signal generated N+1 N+3 Write to compare register 0 Value of compare register 1 M N+3 Write to compare register 1 Compare 0 stopped 278 FUJITSU SEMICONDUCTOR LIMITED Compare 1 stopped CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.7 Output Compare Operations MB90860E Series ● Output inversion using two or three compare registers Depending on the settings of the output level inversion mode select bits (OCS: CMOD1, CMOD0), the output level at the OUT pin (other than OUT0 and OUT4) can be inverted when a compare match occurs on any of up to three output compare channels. See Table 13.3-9 for the settings of the output level inversion mode select bits and relevant pin output level inversion triggers. Figure 13.7-5 shows a sample waveform to be output when the output level at the OUT (m) pin is inverted upon detection of a match between output compare ch (n) and output compare ch (m). Figure 13.7-5 Output Compare Sample Output Waveform Counter value FFFFH BFFFH 7FFFH 3FFFH Time 0000H Reset Value of compare register (n) BFFFH Value of compare register (m) 7FFFH Corresponding to compare (n) OUT(n) Corresponding to compare (n) and compare (m) OUT (m) n = 0, 2, 4, 6 CM44-10144-4E m = n+1 FUJITSU SEMICONDUCTOR LIMITED 279 CHAPTER 13 16-BIT I/O TIMER 13.8 Notes on Using the 16-bit I/O Timer 13.8 MB90860E Series Notes on Using the 16-bit I/O Timer Pay attention to the following points in using the 16-bit I/O timer. ■ Notes on Using the 16-bit I/O Timer ● Note on enabling output comparison When the 16-bit free-running timer stops counting, the output compare operation is stopped as well because the output compare operation is synchronous with the clock of the 16-bit free-running timer. Even if output compare operation is enabled (OCS:CST=1), compare match does not generate without enabling (TCCS:STOP=0) 16-bit free-running timer operation. ● Notes on setting the 16-bit free-running timer • Do not update the count clock select bits (TCCSL: CLK2 to CLK0) during operation of the 16-bit freerunning timer (TCCSL: STOP=0). • The counter value of the 16-bit free-running timer is initialized to 0000H at a reset. • Before setting the counter value by directly writing it to the timer data register (TCDT), stop the 16-bit free-running timer (TCCSL: STOP=1). • To write to the TCDT, be sure to use a word instruction. ● Operation delay owing to synchronization As the input capture and output compare units are synchronous with the operating clock, they involve a delay in operation time. The input capture unit captures data in synchronization with the machine clock after detecting the trigger signal from the pin. The output compare unit performs comparison in synchronization with the count clock of the free-running timer. ● Delay in match detection owing to the updating of the output compare register If a match with the counter value of the 16-bit free-running timer is detected with the output compare register being updated, the match detection is nullified. In advance, read and check the count value of the free-running timer or clear the free-running timer to 0000H. 280 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.9 Sample Programs for 16-bit I/O Timer MB90860E Series 13.9 Sample Programs for 16-bit I/O Timer This section provides sample programs for the 16-bit I/O timer. ■ Sample Program for 16-bit I/O Timer ● Processing specifications • Measure the cycle of the signal to be input to the IN0 pin. • Use 16-bit free-running timer 0 and input capture 0. • Select the rising edge as the trigger edge to be detected. • Set machine clock (φ) to 24 MHz and select 4/φ (0.17 μs) as the count clock of the free-running timer. • Use the timer overflow interrupt and the capture interrupt of input capture 0. • Count free-running timer overflow interrupts to be used for cycle calculation. • Cycle can be calculated as follows: Cycle = (overflow count × 10000H + N-th IPCP0 value - (N-1)-th IPCP0 value) × count clock cycle = (overflow count × 10000H + N-th IPCP0 value - (N-1)-th IPCP0 value) × 0.17 μs ● Coding example ICR09 ICR11 DDR2 TCCSL TCDT ICS01 IPCP0 IVF0 ICP0 DATA EQU EQU EQU EQU EQU EQU 0000B9H 0000BBH 000012H 007942H 007940H 000050H ;Interrupt control register ;Interrupt control register ;Port-2 direction data register ;Timer control status register ;Timer data register ;Input capture control status register ;Status register ;Input capture register 0 ;Timer overflow generation flag bit ;Valid edge detection flag bit EQU 007920H EQU TCCSL:7 EQU ICS01:6 DSEG ABS=00H ORG 0100H OV_CNT RW 1H DATA ENDS ;Overflow counter ; ;---------Main program--------------------------------------------CODE CSEG START: ; ;Initialize resources such as the stack ;pointer (SP) in advance. AND CCR,#0BFH ;Disable interrupts. MOV I:ICR09,#00H ;Interrupt level 0 (Highest) MOV I:ICR11,#00H ;Interrupt level 0 (Highest) MOV I:DDR2,#00000000B ;Set the port-2 direction. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 281 CHAPTER 13 16-BIT I/O TIMER 13.9 Sample Programs for 16-bit I/O Timer MOV MOV MOV OR MB90860E Series I:TCCSL,#01001010B ;Enable counting and clear the counter; ;Enable overflow interrupts; ;Select count clock 4/φ and clear the ;counter. I:ICS01,#00010001B ;Select the IN0 pin. External trigger. ;Set IPCP0 to select the rising edge. ;Set IPCP1 to select no edge detection. ;Clear each valid edge detection flag. ;Enable input capture interrupt requests. ILM,#07H ;Set PS's ILM to level 7. CCR,#40H ;Enable interrupts. LOOP: • User processing • BRA LOOP ;---------Interrupt program----------------------------------------WARI0: CLRB I:ICP0 ;Clear the valid edge detection flag. • ;Save the OV-CNT and input capture values. User processing • MOV A,0 ;Clear the overflow counter MOV OV_CNT,A ;for the next cycle measurement. RETI ;Return from the interrupt service. WARI1: CLRB I:IVF0 ;Clear the timer overflow generation flag. INC OV_CNT ;Increment the overflow counter. • User processing • RETI ;Return from the interrupt service. CODE ENDS ;---------Vector setting------------------------------------------VECT CSEG ABS=0FFH ORG 00FF78H ;Set a vector at interrupt No. #33 (21H). ;(Input capture) DSL WARI0 ORG 00FF84H ;Set a vector at interrupt No. #30 (1EH). ;(Overflow) DSL WARI1 ORG 00FFDCH ;Set a reset vector. DSL START DB 00H ;Set single-chip mode. VECT ENDS END START 282 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 13 16-BIT I/O TIMER 13.9 Sample Programs for 16-bit I/O Timer MB90860E Series ■ Sample Program for Output Compare Unit ● Processing specifications • Use 16-bit free-running timer 0 and output compare 0. • Use an output compare value of 5555H, OUT0 pin, and OCCP0 register. • Invert the pin output level upon detection of a compare match and generate an interrupt at the same time. • Set machine clock (φ) to 24 MHz and select 4/φ (0.17 μs) as the count clock for the 16-bit free-running timer. ● Coding example ICR10 EQU 0000BAH ;Interrupt control register TCCS EQU 007942H ;Timer control status register TCDT EQU 007940H ;Timer data register OCS0 EQU 000058H ;Output compare control status register OCS1 EQU 000059H ;Output compare control status register OCCP0 EQU 007930H ;Output compare register IOP0 EQU OCS0:6 ;Compare match flag bit ; ;---------Main program--------------------------------------CODE CSEG START: ; ;Initialize resources such as the stack ;pointer (SP) in advance. AND CCR,#0BFH ;Disable interrupts MOV I:ICR10,#00H ;Interrupt level 0 (Highest) MOV I:TCCSL,#00001010B ;Enable counting and clear the counter. ;Disable overflow interrupts; Select count ;clock 4/φ. MOVW I:OCCP0,#5555H ;Set the compare register. MOV I:OCS0,#00010001B ;Clear the compare match flag; Enable the ;operation of output compare 0. MOV I:OCS1,#00000100B ;Enable the output of output compare 0; Set ;the pin output level to "L". MOV ILM,#07H ;Set PS's ILM to level 7. OR CCR,#40H ;Enable interrupts. LOOP: • User processing • BRA LOOP ;---------Interrupt program---------------------------------WARI: CLRB I:IOP0 ;Clear the compare match flag. • User processing • RETI ;Return from the interrupt service. CODE ENDS ;---------Vector setting------------------------------------- CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 283 CHAPTER 13 16-BIT I/O TIMER 13.9 Sample Programs for 16-bit I/O Timer VECT VECT 284 CSEG ORG DSL ORG DSL DB ENDS END ABS=0FFH 00FF7CH WARI 00FFDCH START 00H MB90860E Series ;Set a vector at interrupt No. #32 (20H). ;Set a reset vector. ;Set single-chip mode. START FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS This chapter describes the functions and operations of 16-bit reload timers. 14.1 Overview of 16-bit Reload Timers 14.2 Block Diagram of 16-bit Reload Timer 14.3 Configuration of 16-bit Reload Timers 14.4 Interrupts of 16-bit Reload Timers 14.5 Operations of 16-bit Reload Timers 14.6 Notes on Using 16-bit Reload Timers 14.7 Sample Programs for 16-bit Reload Timers CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 285 CHAPTER 14 16-BIT RELOAD TIMERS 14.1 Overview of 16-bit Reload Timers 14.1 MB90860E Series Overview of 16-bit Reload Timers The 16-bit reload timer has the following features: • Allowing the count clock to be selected from among three types of internal clocks and an external event clock. • Capable of selecting a software trigger or external trigger as the activation trigger. • Capable of generating an interrupt to the CPU when the 16-bit timer register underflows; therefore available as an interval timer using an interrupt. • Offering a choice of two different modes for use when the 16-bit timer register (TMR) underflows. One is one shot mode that causes the TMR register to stop counting and the other is reload mode that allows the TMR to continue counting with the 16-bit reload register value reloaded. • Supporting extended intelligent I/O service (EI2OS, for all of the 4 channels) and DMA transfer (16-bit reload timers 0 to 2 only). • The MB90860E series contains four channels of 16-bit reload timers. ■ 16-bit Reload Timer Operation Mode Table 14.1-1 shows the operation modes of the 16-bit reload timer. Table 14.1-1 16-bit Reload Timer Operation Modes Count clock Activation trigger Operation when an underflow occurs Internal clock mode Software trigger External trigger One shot mode Reload mode Event count mode Software trigger One shot mode Reload mode ■ Internal Clock Mode • Setting the count clock select bits in the timer control status register (TMCSR:CSL1, CSL0) to 00B, 01B, or 10B places the 16-bit reload timer in internal clock mode. • In internal clock mode, the 16-bit reload timer counts down in synchronization with the internal clock. • The count clock select bits in the timer control status register (TMCSR:CSL1, CSL0) can be used to select one of the three different count clock cycles. • The activation trigger is the software trigger or external trigger set for edge detection. 286 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.1 Overview of 16-bit Reload Timers MB90860E Series ■ Event Count Mode • Setting the count clock select bits in the timer control status register (TMCSR:CSL1, CSL0) to 11B places the 16-bit reload timer in event count mode. • In event count mode, the 16-bit reload timer is decremented in synchronization with edge detection of the external event clock input to the TIN pin. • The activation trigger is the software trigger. • The 16-bit reload timer can be used as an interval timer using an external clock signal of a fixed period. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 287 CHAPTER 14 16-BIT RELOAD TIMERS 14.1 Overview of 16-bit Reload Timers MB90860E Series ■ Operation When an Underflow Occurs When the activation trigger is input, the value set in the 16-bit reload register is reloaded into the 16-bit timer register and the 16-bit reload timer starts being decremented in synchronization with the count clock. An underflow occurs when the 16-bit timer register is decremented from 0000H to FFFFH. • An underflow interrupt occurs when an underflow occurs with underflow interrupts enabled (TMCSR:INTE=1). • The operation to be performed by the 16-bit reload timer when an underflow occurs is set by the reload select bit in the timer control status register (TMCSR:RELD). [One shot mode (TMCSR:RELD=0) ] When an underflow occurs in this mode, the16-bit timer register (TMR) stops counting. When the next activation trigger is input, the TMR register is reloaded with the value set in the 16-bit reload register (TMRLR) to start counting. • In one shot mode, the TOT0 to TOT3 pins output "H" or "L" level rectangular waves while the 16-bit timer register is counting. • The rectangular wave level ("H" or "L") can be set by the pin output level select bit in the timer control status register (TMCSR:OUTL). [Reload mode (TMCSR:RELD=1) ] When an underflow occurs in this mode, the 16-bit timer register (TMR) is reloaded with the value set in the 16-bit reload register and continues counting. • In reload mode, a toggle wave is output each time the TMR register underflows during counting. The toggle wave inverts the TOT pin output level. • The toggle wave level ("H" or "L") at reload timer activation can be set by the pin output level select bit in the timer control status register (TMCSR:OUTL). • The 16-bit reload timer can be used as an interval time using underflow interrupts. Table 14.1-2 16-bit Reload Timer Time Intervals Count clock Count clock cycle Internal clock mode Event count mode Time interval example 21T (0.083 μs) 0.083 μs to 5.46 ms 23T (0.33 μs) 0.33 μs to 21.8 ms 25T (1.3 μs) 1.3 μs to 87.4 ms 23T or more 0.33 μs or more T: Machine cycle The time interval examples and the values in ( ) are calculated assuming a machine clock frequency of 24 MHz. Reference: 288 16-bit reload timer 1 can be used as the activation trigger for the A/D converter. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.2 Block Diagram of 16-bit Reload Timer MB90860E Series 14.2 Block Diagram of 16-bit Reload Timer Each of 16-bit reload timers 0, 1, 2, and 3 consists of the following blocks: • Count clock generator circuit • Reload control circuit • Output control circuit • Operation control circuit • 16-bit timer register (TMR) • 16-bit reload register (TMRLR) • Timer control status register (TMCSR) ■ Block Diagram of 16-bit Reload Timer Figure 14.2-1 Block Diagram of 16-bit Reload Timer Internal data bus TMRLR 16-bit reload register Reload signal TMR 16-bit timer register UF Counter clock generator circuit Machine clock Prescaler 3 Reload control circuit CLK Gate input Effective clock decision circuit φ Wait signal To A/D converter (ch.1 only) Clear Internal clock Pin TIN Input control circuit Output control circuit CLK Clock selector Output signal generator circuit Pin TOT EN External clock 3 2 Select signal Operation control circuit Function selection CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE UF CNTE TRG Timer control status register (TMCSR) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED Interrupt request output 289 CHAPTER 14 16-BIT RELOAD TIMERS 14.2 Block Diagram of 16-bit Reload Timer MB90860E Series ● Details of pins and other items in the block diagram The MB90860E series contains four channels of 16-bit reload timers. Listed below are the actual pin names, internal peripheral resource output, interrupt request numbers, and DMA channels of the individual channels of 16-bit reload timers. Table 14.2-1 Pin Names, Internal Peripheral Resource Output, Interrupt Numbers, and DMA Channels of 16-bit Reload Timers Reload timer 0 Reload timer 1 Reload timer 2 Reload timer 3 TIN pin P80 P10 P82 P53 TOT pin P81 P11 P83 P54 Output to internal peripheral resource — A/D converter — — #17(11H) #18(12H) #19(13H) #20(14H) 0 1 2 — Interrupt request No. DMA channel No. ● Count clock generator circuit This block generates a count clock signal to be supplied to the 16-bit timer register (TMR) based on the machine clock signal or external event clock signal. ● Reload control circuit This block reloads the 16-bit timer register (TMR) with the value set in the 16-bit reload register either to start 16-bit reload timer operation or when the TMR register underflows. ● Output control circuit This block inverts the TOT pin output when an underflow occurs and enables or disables TOT pin output. ● Operation control circuit This block activates or stops the 16-bit reload timer. ● 16-bit timer register (TMR) This block is a 16-bit down counter. When read, it returns the current count value. ● 16-bit reload register (TMRLR) This block sets the time interval for the 16-bit reload timer. The value set in the 16-bit reload register is reloaded into the 16-bit timer register (TMR) either to start 16-bit reload timer operation or when the TMR register underflows. 290 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.2 Block Diagram of 16-bit Reload Timer MB90860E Series ● Timer control status register (TMCSR) This block is used to select the 16-bit reload timer operation mode, set operating conditions, select the activation trigger, activate the reload timer using the software trigger, select the reload operation mode, enable/disable interrupt requests, set the TOT pin output level, and set TOT output pins. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 291 CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers 14.3 MB90860E Series Configuration of 16-bit Reload Timers This section describes the pins, registers, and interrupt sources of 16-bit reload timers. ■ Pins of 16-bit Reload Timers The pins of 16-bit reload timers can serve as general-purpose I/O ports as well. Table 14.3-1 shows the functions of the pins and their required settings for use for 16-bit reload timers. Table 14.3-1 Pins of 16-bit Reload Timers (1 / 2) Pin names Pin functions Settings required for use as 16-bit reload timer General-purpose I/O port/ A/D converter trigger input/ External interrupt 12/ 16-bit reload timer input 0 • Port direction register: Set the register for use as an input port (DDR8:D80=0). • Disable external interrupts (by setting the external interrupt enable register ENIR1:EN12 = 0) or use P04 in place of P80 as an external interrupt input port (by setting the external interrupt source select register EISSR:INT12R = 0). • A/D control register: Set the register to disable trigger activation (ADCS1:STS1, STS0 = 00B/10B) P81 / CKOT / INT13R/ TOT0 General-purpose I/O port/ Clock monitor output/ External interrupt 13/ 16-bit reload timer output 0 • Disable external interrupts (by setting the external interrupt enable register ENIR1:EN13 = 0) or use P05 in place of P81 as an external interrupt input port (by setting the external interrupt source select register EISSR:INT13R = 0). • Clock output enable register: Disable clock monitor output (CLKR:CKEN=0). • Timer control status register: Enable timer output (TMCSR0:OUTE=1). P10 / TIN1 General-purpose I/O port/ 16-bit reload timer input 1 • Port direction register (DDR1): Set the register for use as an input port (DDR1:D10=0). P11 / TOT1 General-purpose I/O port/ 16-bit reload timer output 1 • Timer control status register: Enable timer output (TMCSR1:OUTE=1). P82 / SIN0 / INT14R / TIN2 General-purpose I/O port/ UART input 0/ External interrupt 14/ 16-bit reload timer input 2 • Port direction register: Set the register for use as an input port (DDR8:D82=0). • Serial control register: Set the register to disable reception (SCR0:RXE=0). • Disable external interrupts (by setting the external interrupt enable register ENIR1:EN14 = 0) or use P06 in place of P82 as an external interrupt input port (by setting the external interrupt source select register EISSR:INT14R = 0). P83 / SOT0 / TOT2 General-purpose I/O port/ UART output 0/ 16-bit reload timer output 2 • Serial control register: Set the register to disable transmission (SCR0:TXE=0). • Timer control status register: Enable timer output (TMCSR2:OUTE=1). P53 / AN11 / TIN3 General-purpose I/O port/ A/D converter analog input 11/ 16-bit reload timer input 3 • Port direction register: Set the register for use as an input port (DDR5:D53=0). • Analog input enable register: Set the register to disable analog input (ADER5:ADE11=0). P80 / ADTG / INT12R/ TIN0 292 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series Table 14.3-1 Pins of 16-bit Reload Timers (2 / 2) Pin names P54 / AN12 / TOT3 Pin functions Settings required for use as 16-bit reload timer General-purpose I/O port/ A/D converter analog input 12/ 16-bit reload timer output 3 CM44-10144-4E • Analog input enable register: Set the register to disable analog input (ADER5:ADE12=0). • Timer control status register: Enable timer output (TMCSR3:OUTE=1). FUJITSU SEMICONDUCTOR LIMITED 293 CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series ■ Registers of Each 16-bit Reload Timer and Their Reset Values ● Registers of 16-bit reload timer 0 Figure 14.3-1 Registers of 16-bit Reload Timer 0 and Their Reset Values bit Timer control status register: Upper byte (TMCSR0) bit Timer control status register: Lower byte (TMCSR0) bit 16-bit timer register: Upper byte (TMR0) bit 16-bit timer register: Lower byte (TMR0) bit 16-bit reload register: Upper byte (TMRLR0) bit 16-bit reload register: Lower byte (TMRLR0) 15 14 13 12 11 10 9 8 X X X X 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X X : Undefined ● Registers of 16-bit reload timer 1 Figure 14.3-2 Registers of 16-bit Reload Timer 1 and Their Reset Values bit Timer control status register: Upper byte (TMCSR1) bit Timer control status register: Lower byte (TMCSR1) bit 16-bit timer register: Upper byte (TMR1) bit 16-bit timer register: Lower byte (TMR1) bit 16-bit reload register: Upper byte (TMRLR1) bit 16-bit reload register: Lower byte (TMRLR1) 15 14 13 12 11 10 9 8 X X X X 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X X :Undefined 294 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series ● Registers of 16-bit reload timer 2 Figure 14.3-3 Registers of 16-bit Reload Timer 2 and Their Reset Values bit Timer control status register: Upper byte (TMCSR2) bit Timer control status register: Lower byte (TMCSR2) bit 16-bit timer register: Upper byte (TMR2) bit 16-bit timer register: Lower byte (TMR2) bit 16-bit reload register: Upper byte (TMRLR2) bit 16-bit reload register: Lower byte (TMRLR2) 15 14 13 12 11 10 9 8 X X X X 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X X :Undefined ● Registers of 16-bit reload timer 3 Figure 14.3-4 Registers of 16-bit Reload Timer 3 and Their Reset Values bit Timer control status register: Upper byte (TMCSR3) bit Timer control status register: Lower byte (TMCSR3) bit 16-bit timer register: Upper byte (TMR3) bit 16-bit timer register: Lower byte (TMR3) bit 16-bit reload register: Upper byte (TMRLR3) bit 16-bit reload register: Lower byte (TMRLR3) 15 14 13 12 11 10 9 8 X X X X 0 0 0 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X 15 14 13 12 11 10 9 8 X X X X X X X X 7 6 5 4 3 2 1 0 X X X X X X X X X :Undefined CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 295 CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series ■ Generation of an Interrupt Request by a 16-bit Reload Timer When a 16-bit reload timer is activated and the count value in the 16-bit timer register (TMR) is decremented from 0000H to FFFFH, the register causes an underflow and the UF bit in the timer control status register is set to "1" (TMCSR:UF). An interrupt request is generated when underflow interrupts have been enabled (TMCSR:INTE=1). If setting of the UF bit to "1" and writing "0" occur simultaneously, the latter takes precedence, and "0" is written. 296 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series 14.3.1 Upper Byte of Timer Control Status Register (TMCSR:H) The upper byte of the timer control status register (TMCSR:H) is used to set the operation mode and count clock. Note that bit 7 in lower byte of the timer control status register (TMCSR:L) is also covered in this section. ■ Upper Byte of Timer Control Status Register (TMCSR:H) Figure 14.3-5 Upper Byte of Timer Control Status Register (TMCSR:H) Address: TMCSR0 TMCSR1 TMCSR2 TMCSR3 15 14 : 000061H : 000063H : 000065H : 000067H 13 12 11 10 9 8 7 CSL1 CSL0 MOD2 MOD1 MOD0 Initial value XXXX00000B R/W R/W R/W R/W R/W bit9 bit8 bit7 MOD2 MOD1 MOD0 0 0 0 0 0 1 Operation mode select bits (internal clock mode) (CSL1, CSL0=00B, 01B, 10B) Input pin function 1 0 0 1 1 1 X 0 1 X 1 bit9 bit8 bit7 MOD2 MOD1 MOD0 X 0 0 Trigger input X 0 1 R/W : Readable/writable X : Undefined − : Undefined bit 1 0 1 1 bit11 bit10 CSL1 CSL0 0 0 0 1 1 0 1 1 Falling edge Both edges "L" level Gate input "H" level Operation mode select bits (event count mode) (CSL1, 0=11B) Input pin function X − Rising edge 0 X Effective edge/level Trigger prohibition Effective edge − − Rising edge Trigger input Falling edge Both edges Count clock select bits Count clock Count clock cycle 21T Internal clock mode 23T 25T Event count mode External event clock T: Machine cycle : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 297 CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series Table 14.3-2 Functions of Upper Bytes of Timer Control Status Register (TMCSR:H) Bit name bit15 to bit12 bit11, bit10 bit9 to bit7 298 Function Undefined bits When the bits are read : The values are indeterminate. When the bits are written to : Operation is not affected. CSL1, CSL0: Count clock select bits Select the count clock for the 16-bit reload timer. When the bits are set to other than "11B": The internal clock is used for counting (internal clock mode). When the bits are set to "11B": Edges of the external event clock signal are counted (event count mode). MOD2, MOD1, MOD0: Operation mode select bits Set the operating conditions for the 16-bit reload timer. [In internal clock mode] The MOD2 bit selects the function of the input pin. When the MOD2 bit is "0": The input pin serves as a trigger input. The MOD1 and MOD0 bits select the edge to be detected. When the edge is detected, the value set in the 16-bit reload register is reloaded into the 16-bit timer register (TMR) to start the count operation of the TMR register. When the MOD2 bit is "1": The input pin serves as a gate input. The MOD1 bit is not used; the MOD0 bit selects the signal level ("H", "L") to be detected. The 16-bit timer register performs counting only when the signal level is input. [In event count mode] The MOD2 bit is not used. The input pin inputs an external event clock signal. The MOD1 and MOD0 bits are used to select the edge to be detected. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series 14.3.2 Lower Byte of Timer Control Status Register (TMCSR:L) The lower byte of the timer control status register (TMCSR:L) is used to enable/disable the timer operation, set the software trigger, check whether an underflow has occurred, enable/disable underflow interrupts, select reload mode, and set the TOT pin output. ■ Lower Byte of Timer Control Status Register (TMCSR:L) Figure 14.3-6 Lower Byte of Timer Control Status Register (TMCSR:L) Address: 7 TMCSR0 : 000060H TMCSR1 : 000062H TMCSR2 : 000064H TMCSR3 : 000066H 6 5 4 3 2 1 0 OUTE OUTL RELD INTE UF CNTE TRG Initial value 00000000B R/W R/W R/W R/W R/W R/W R/W bit0 TRG Software trigger bit 0 Has no effect on operation. 1 Starts counting after reloading. bit1 CNTE Timer operation enable bit 0 Disables timer operation. 1 Enables timer operation (waiting for an activation trigger). bit2 UF Underflow detection flag bit When read When written to 0 No underflow The UF bit is cleared. 1 Underflow detected No effect bit3 INTE Underflow interrupt enable bit 0 Disables underflow interrupts. 1 Enables underflow interrupts. bit4 RELD Reload select bit 0 One shot mode 1 Reload mode bit5 OUTL TOT pin output level select bit One shot mode (RELD=0) Reload mode (RELD=1) 0 Outputs "H"-level rectangular wave during counting. Outputs "L"-level toggle wave at reload timer activation. 1 Outputs "L"-level rectangular wave during counting. Outputs "H"-level toggle wave at reload timer activation. bit6 TOT pin output enable bit OUTE R/W : Initial value * Pin function : Readable/writable 0 General-purpose I/O port 1 TOT output : For MOD0 (bit7), see Section "14.3.1 Upper Byte of Timer Control Status Register (TMCSR:H)". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 299 CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series Table 14.3-3 Functions of Lower Byte of Timer Control Status Register (TMCSR:L) (1 / 2) Bit name OUTE: TOT output enable bit Sets the function of the TOT pin of the 16-bit reload timer. When the bit is set to "0": The pin serves as a general-purpose I/O port. When the bit is set to "1": The pin serves as the TOT pin for the 16-bit reload timer. OUTL: TOT pin output level select bit Sets the output level of the output pin of the 16-bit reload timer. <When one shot mode is selected (RELD=0)> When the bit is set to "0": The pin outputs "H"-level rectangular wave while the timer register is counting. When the bit is set to "1": The pin outputs "L"-level rectangular wave while the timer register is counting. <When reload mode is selected (RELD=1)> When the bit is set to "0": The pin outputs "L"-level toggle wave at reload timer activation. When the bit is set to "1": The pin outputs "H"-level toggle wave at reload timer activation. bit4 RELD: Reload select bit Sets the reload operation to be performed when an underflow occurs. When the bit is set to "1": When an underflow occurs, the 16-bit timer register is reloaded with the value set in the 16bit reload register to continue counting (reload mode). When the bit is set to "0": When an underflow occurs, the 16-bit timer register stops counting (one shot mode). bi3 INTE: Underflow interrupt enable bit Enables or disables underflow interrupts. An interrupt request occurs when an underflow occurs (TMCSR:UF=1) with underflow interrupts enabled (TMCSR:INTE=1). bit2 UF: Underflow detection flag bit Indicates that the timer register has caused an underflow. When the bit is set to "0": The flag is cleared. When the bit is set to "1": No effect is produced. When the bit is read by a read-modify-write instruction: "1" is read. CNTE: Timer operation enable bit Enables or disables the operation of the 16-bit reload timer. When the bit is set to "1": The 16-bit reload timer waits for an activation trigger. When the activation trigger is input, the reload timer causes the timer register to restart counting. When the bit is set to "0": The 16-bit reload timer causes the timer register to stop counting. bit6 bit5 bit1 300 Function FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers MB90860E Series Table 14.3-3 Functions of Lower Byte of Timer Control Status Register (TMCSR:L) (2 / 2) Bit name bit0 CM44-10144-4E Function TRG: Software trigger bit Activates the 16-bit reload timer by software. The software trigger function works only when the timer operation is enabled (CNTE=1). When the bit is set to "0": The setting is invalid and makes no change. When the bit is set to "1": The 16-bit timer register (TMR) is reloaded with the value set in the 16-bit reload register to start counting. When the bit is read: "0" is always read. FUJITSU SEMICONDUCTOR LIMITED 301 CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers 14.3.3 MB90860E Series 16-bit Timer Register (TMR) The 16-bit timer register is a 16-bit down counter. The current count value is read from the timer register. ■ 16-bit Timer Register (TMR) Figure 14.3-7 16-bit Timer Register (TMR) 15 Address: TMR0 : 007949 H TMR1 : 00794BH TMR2 : 00794DH TMR3 : 00794F H D15 D14 Address: TMR0 : 007948 H TMR1 : 00794AH TMR2 : 00794CH TMR3 : 00794EH R : Read-only X : Undefined 14 R 13 12 D13 D12 D11 D10 R R 11 R 10 R 9 8 Initial value D9 D8 XXXXXXXX B R R R 7 6 5 4 3 2 1 0 D7 D6 D5 D4 D3 D2 D1 D0 R R R R R R R R Initial value XXXXXXXX B When the activation trigger is input with the timer operation enabled (TMCSR:CNTE=1), the 16-bit timer register (TMR) is reloaded with the value set in the 16-bit reload register (TMRLR) to start counting. If the timer operation is disabled (TMCSR:CNTE=0), the TMR register retains its value. An underflow occurs if the TMR register decrements its value from 0000H to FFFFH during counting. [In reload mode] When the 16-bit timer register (TMR) underflows, it is reloaded with the value set in the 16-bit reload register (TMRLR) to restart counting. [In one shot mode] When the 16-bit timer register (TMR) underflows, it stops counting and enters the activation trigger input wait state. The TMR register retains its value as FFFFH. Notes: 302 • Although the 16-bit timer register (TMR) can be read even during counting, be sure to use a word instruction (MOVW). • The 16-bit timer register (TMR) is located at the same address as that of the 16-bit reload register (TMRLR). Write access to that address writes a set value to the TMRLR register without affecting the TMR register. Read access to the address reads the current count value from the TMR register. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 14.3.4 16-bit Reload Register (TMRLR) CHAPTER 14 16-BIT RELOAD TIMERS 14.3 Configuration of 16-bit Reload Timers The 16-bit reload register sets the value to be reloaded into the 16-bit timer register (TMR). When the activation trigger is input, the 16-bit timer register is reloaded with the value set in the 16-bit reload register to start counting. ■ 16-bit Reload Register (TMRLR) Figure 14.3-8 16-bit Reload Register (TMRLR) Address: TMRLR0 : 007949 H TMRLR1 : 00794B H TMRLR2 : 00794DH TMRLR3 : 00794F H Address: TMRLR0 : 007948 H TMRLR1 : 00794A H TMRLR2 : 00794CH TMRLR3 : 00794E H W : Write-only X :Undefined 15 14 D15 D14 W 13 12 D13 D12 D11 D10 W W 11 W 10 W W 9 8 Initial value D9 D8 XXXXXXXX B W W 7 6 5 4 3 2 1 0 D7 D6 D5 D4 D3 D2 D1 D0 W W W W W W W W Initial value XXXXXXXX B Before setting the 16-bit reload register, disable the timer operation (TMCSR:CNTE=0). After setting the 16-bit reload register, enable the timer operation (TMCSR:CNTE=1). When the activation trigger is input, the 16-bit timer register (TMR) is reloaded with the value set in the 16-bit reload register (TMRLR) to start counting. Notes: CM44-10144-4E • Before writing to the 16-bit timer register, disable the 16-bit reload timer operation (TMCSR:CNTE=0). Be sure to use a word instruction (MOVW) to write to the timer register. • The 16-bit reload register (TMRLR) is located at the same address as that of the 16-bit timer register (TMR). Write access to that address writes a set value to the TMRLR register without affecting the TMR register. Read access to the address reads the current count value from the TMR register. • Read-modify-write (RMW) instructions such as INC/DEC cannot be used. FUJITSU SEMICONDUCTOR LIMITED 303 CHAPTER 14 16-BIT RELOAD TIMERS 14.4 Interrupts of 16-bit Reload Timers 14.4 MB90860E Series Interrupts of 16-bit Reload Timers The 16-bit reload timer generates an interrupt request when the 16-bit timer register underflows. ■ Interrupts of 16-bit Reload Timers The 16-bit timer register (TMR) underflows when its value is decremented from 0000H to FFFFH during counting. When an underflow occurs, the underflow detection flag bit in the timer control status register (TMCSR:UF) is set to "1". An interrupt request occurs when underflow interrupts have been enabled (TMCSR:INTE=1). Table 14.4-1 Interrupt Control Bits and Interrupt Sources of 16-bit Reload Timers 16-bit reload timer 0 16-bit reload timer 1 16-bit reload timer 2 16-bit reload timer 3 Interrupt request flag bit TMCSR0: UF TMCSR1: UF TMCSR2: UF TMCSR3: UF Interrupt request enable bit TMCSR0: INTE TMCSR1: INTE TMCSR2: INTE TMCSR3: INTE Interrupt source Underflow of 16-bit timer register (TMR0) Underflow of 16-bit timer register (TMR1) Underflow of 16-bit timer register (TMR2) Underflow of 16-bit timer register (TMR3) ■ 16-bit Reload Timer Interrupts, EI2OS, and DMA Transfer Reference: See "CHAPTER 3 INTERRUPTS" for interrupt numbers, interrupt control registers, and interrupt vector addresses. ■ EI2OS Features and DMA Transfer of 16-bit Reload Timers 16-bit reload timers 0 to 3 support EI2OS features. 16-bit reload timers 0 to 2 support DMA transfer. EI2OS or DMA transfer can be activated when the 16-bit timer register underflows. Note, however, that EI2OS/DMA can be used only when any other peripheral resource sharing the interrupt control register (ICR) is not using an interrupt. 16-bit reload timers 0 and 1 share ICR03; 16-bit reload timers 2 and 3 share ICR04. When 16-bit reload timers 0 to 3 use EI2OS/DMA, disable interrupts by the other 16-bit reload timers sharing the same ICR register. 304 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series 14.5 Operations of 16-bit Reload Timers This section describes the settings for the 16-bit reload timer and its counter operating states. ■ 16-bit Reload Timer Settings ● Settings for internal clock mode Counting the internal clock signal requires the settings in Figure 14.5-1. Figure 14.5-1 Settings for Internal Clock Mode bit15 14 13 12 TMCSR 11 10 9 8 7 6 5 4 3 CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE 2 1 bit0 UF CNTE TRG 1 Other than 11B Value to be reloaded into 16-bit timer register TMRLR : Bit used 1 : Set to "1" ● Settings for event count mode The operation using external event inputs requires the settings in Figure 14.5-2. Figure 14.5-2 Settings for Event Count Mode bit15 14 13 12 − − − − TMCSR 11 9 8 7 6 5 4 3 2 1 bit0 CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE UF CNTE TRG 1 TMRLR 10 1 1 Value to be reloaded into 16-bit timer register Set that bit in the port direction register (DDR) to "0" which corresponds to the pin to be used as a TIN pin. : Bit used 1 : Set to "1" CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 305 CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series ■ Operating States of 16-bit Timer Register The operating state of the 16-bit timer register is determined by the timer operation enable bit in the timer control status register (TMCSR:CNTE) and the WAIT signal. The operating states available are the stopped state (STOP state), activation trigger input wait state (WAIT state), and executing state (RUN state). Figure 14.5-3 illustrates the transitions of the operating state of the 16-bit timer register. Figure 14.5-3 Operating State Transition Diagram STOP state CNTE=0, WAIT=1 TIN pin: Input disabled Reset TOT pin: General-purpose I/O port 16-bit timer register: Retains the value existing when the operation is stopped. The value immediately after a reset is indeterminate. CNTE=0 CNTE=0 CNTE=1 TRG=0 WAIT state CNTE=1, WAIT=1 TIN pin: Accepts trigger input only. TOT pin: Outputs the 16-bit reload register value. 16-bit timer register: Retains the value existing when the operation is stopped. The value immediately after a reset is indeterminate. TRG=1 (Software trigger) External trigger from TIN CNTE=1 TRG=1 UF=1& RELD=0 RUN state CNTE=1, WAIT=0 TIN pin: Serves as the input pin for the 16-bit reload timer. TOT pin: Serves as the output pin for the 16-bit reload timer. (One shot mode) UF=1& 16-bit timer register: Operating RELD=1 (Reload mode) TRG=1 LOAD CNTE=1, WAIT=0 (Software trigger) Loads the content of the 16-bit reload End of loading register into the 16-bit timer register. : State transition by hardware WAIT TRG CNTE UF RELD 306 : State transition by register access : WAIT signal (internal signal) : Software trigger bit (TMCSR) : Timer operation enable bit (TMCSR) : Underflow detection flag bit (TMCSR) : Reload select bit (TMCSR) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series 14.5.1 Operations in Internal Clock Mode In internal clock mode, you can select one of the three different operation modes by setting the operation mode select bits in the timer control status register (TMCSR: MOD2 to MOD0). The TOT pin outputs the rectangular or toggle wave depending on the operation mode and reload mode settings. ■ Settings for Internal Clock Mode • Setting the count clock select bits (CSL1, CSL0) in the timer control status register to 00B, 01B, or 10B places the 16-bit reload timer in internal clock mode. • In internal clock mode, the 16-bit timer register counts down in synchronization with the internal clock. • You can select one of the three different count clock cycles by setting the count clock select bits (CSL1, CSL0) in the timer control status register. [Setting the value to be reloaded into the 16-bit timer register] After the 16-bit reload timer is activated, the value set in the 16-bit reload register (TMRLR) is reloaded into the 16-bit timer register (TMR). 1. Disable the timer operation (TMCSR:CNTE=0). 2. Set the 16-bit reload register to the value to be reloaded into the 16-bit timer register. 3. Enable the timer operation (TMCSR:CNTE=1). Note: CM44-10144-4E It takes a time period of 1 T (T: machine cycle) for the value set in the 16-bit reload register (TMRLR) to be reloaded into the 16-bit timer register (TMR) after the activation trigger is input. FUJITSU SEMICONDUCTOR LIMITED 307 CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series ■ Operations When the 16-bit Timer Register Underflows The 16-bit timer register (TMR) underflows when its value is decremented from 0000H to FFFFH during counting. • When an underflow occurs, the underflow detection flag bit in the timer control status register (TMCSR:UF) is set to "1". • An underflow interrupt occurs when the underflow interrupt enable bit in the timer control status register (TMCSR:INTE) contains "1". • The reload operation to be performed when an underflow occurs is set by the reload select bit in the timer control status register (TMCSR:RELD). [In one shot mode (TMCSR:RELD=0)] When the 16-bit timer register (TMR) underflows, it stops counting and enters the activation trigger input wait state. When the next activation trigger is input, the TMR register restarts counting. In one shot mode, the TOT pin outputs rectangular wave while the TMR register is counting. You can select the rectangular wave level ("H" or "L") by setting the pin output level select bit in the timer control status register (TMCSR:OUTL). [In reload mode (TMCSR:RELD=1)] When the 16-bit timer register (TMR) underflows, it is reloaded with the value set in the 16-bit reload register (TMRLR) to continue counting. In reload mode, a toggle wave is output each time the TMR register underflows during counting. The toggle wave inverts the TOT pin output level. The toggle wave level ("H" or "L") at reload timer activation can be selected by setting the pin output level select bit in the timer control status register (TMCSR:OUTL). ■ Operations in Internal Clock Mode Internal clock mode, you can select the operation mode by setting the operation mode select bits in the timer control status register (TMCSR:MOD2 to MOD0). Disable the timer operation by setting the timer operation enable bit in the timer control status register (TMCSR:CNTE) to "0". 308 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series [Software trigger mode (MOD2 to MOD0=000B)] When you select software trigger mode, set the software trigger bit in the timer control status register (TMCSR:TRG) to "1" to activate the 16-bit reload timer. When the 16-bit reload timer is activated, the 16bit timer register (TMR) is reloaded with the value set in the 16-bit reload register (TMRLR) to start counting. Note: If you set the timer operation enable bit (TMCSR:CNTE) and software trigger bit (TMCSR:TRG) in the timer control status register to "1" at the same time, the 16-bit timer register starts counting simultaneously with the activation of the 16-bit reload timer. However, timer activation during gate input operation can only be enabled by software triggering. Figure 14.5-4 Count Operations in Software Trigger Operation Mode (One Shot Mode) Counter clock Counter Reload data -1 0000 H FFFF H Reload data -1 0000 H FFFFH Data load signal UF bit CNTE bit TRG bit T* TOT pin Activation trigger input wait state T : Machine cycle * : It takes a time period of 1 T to load data from the reload register after trigger input. Figure 14.5-5 Count Operations in Software Trigger Operation Mode (Reload Mode) Counter clock Counter Reload data -1 0000 H Reload data -1 0000 H Reload data -1 0000 H Reload data -1 Data load signal UF bit CNTE bit TRG bit T* TOT pin T : Machine cycle * : It takes a time period of 1 T to load data from the reload register after trigger input. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 309 CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series [External trigger mode (MOD2 to MOD0=001B, 010B, 011B)] When you select external trigger mode, input an external effective edge to the TIN pin to activate the 16-bit reload timer. When the 16-bit reload timer is activated, the 16-bit timer register (TMR) is reloaded with the value set in the 16-bit reload register (TMRLR) to start counting. • You can select the rising edge, falling edge, or both edges to be detected, by setting the operation mode select bits in the timer control status register (TMCSR:MOD2 to MOD0). Note: For trigger pulse width to be input to the TIN pin, as well as the pulse width of the gate input, refer to the value of data sheet. Figure 14.5-6 Count Operations in External Trigger Mode (One Shot Mode) Counter clock Counter Reload data -1 0000 H FFFF H Reload data -1 0000 H FFFF H Data load signal UF bit CNTE bit TIN pin 2T to 2.5T * TOT pin Activation trigger input wait state T : Machine cycle * : It takes a time period of 2 to 2.5 T to load data from the reload register after external trigger input. Figure 14.5-7 Count Operations in External Trigger Mode (Reload Mode) Counter clock Counter Reload data -1 0000 H Reload data -1 0000 H Reload data -1 0000 H Reload data -1 Data load signal UF bit CNTE bit TIN pin TOT pin 2T to 2.5T * T : Machine cycle * : It takes a time period of 2 to 2.5 T to load data from the reload register after external trigger input. 310 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series [External gate input operation mode (MOD2 to MOD0=1x0B, 1x1B)] When you select external gate input operation mode, set the software trigger bit in the timer control status register (TMCSR:TRG) to "1" to activate the 16-bit reload timer. When the 16-bit reload timer is activated, the value set in the 16-bit reload timer (TMRLR) is reloaded into the 16-bit timer register (TMR). • While the set gate input level remains input to the TIN pin after the 16-bit reload timer is activated, the 16-bit timer register continues counting. • You can select the gate input level ("H" or "L") by setting the operation mode select bits in the timer control status register (TMCSR: MOD2 to MOD0). Figure 14.5-8 Count Operations in External Gate Input Operation Mode (One Shot Mode) Counter clock Counter Reload data -1 0000 H -1 Reload data FFFFH -1 -1 Data load signal UF bit CNTE bit TRG bit T* T* TIN pin TOT pin Activation trigger input wait state T : Machine cycle * : It takes a time period of 1 T to load data from the reload register after trigger input. Figure 14.5-9 Count Operations in External Gate Input Operation Mode (Reload Mode) Counter clock Counter Reload data -1 -1 -1 0000H Reload data -1 -1 Data load signal UF bit CNTE bit TRG bit TIN pin T* TOT pin T : Machine cycle * : It takes a time period of 1T to load data from the reload register after trigger input. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 311 CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers 14.5.2 MB90860E Series Operations in Event Count Mode In event count mode, the activated 16-bit reload timer detects the edge of the signal input to the TIN pin to cause the 16-bit timer register to start counting. The TOT pin outputs rectangular or toggle wave depending on the operation mode and reload mode settings. ■ Settings for Event Count Mode • Setting the count clock select bits in the timer control status register (TMCSR: CSL1, CSL0) to 11B places the 16-bit reload timer in event count mode. • In event count mode, the 16-bit timer register is decremented in synchronization with edge detection of the external event clock input to the TIN pin. [Setting the counter initial value] After the 16-bit reload timer is activated, the value set in the 16-bit reload register (TMRLR) is reloaded into the 16-bit timer register (TMR). 1. Disable the 16-bit reload timer operation (TMCSR:CNTE=0). 2. Set the 16-bit reload register to the value to be reloaded into the 16-bit timer register. 3. Enable the 16-bit reload timer operation (TMCSR:CNTE=1). Note: 312 It takes a time period of 1 T (T: machine cycle) for the value set in the 16-bit reload register (TMRLR) to be loaded into the 16-bit timer register (TMR) after the activation trigger is input. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series ■ Operations When the 16-bit Timer Register Underflows The 16-bit timer register (TMR) underflows when its value is decremented from 0000H to FFFFH during counting. • When an underflow occurs, the underflow detection flag bit in the timer control status register (TMCSR:UF) is set to "1". • An underflow interrupt occurs when the underflow interrupt enable bit in the timer control status register (TMCSR:INTE) contains "1". • The reload operation to be performed when an underflow occurs is set by the reload select bit in the timer control status register (TMCSR:RELD). [In one shot mode (TMCSR:RELD=0)] When the 16-bit timer register (TMR) underflows, it stops counting and enters the activation trigger input wait state. When the next activation trigger is input, the TMR register restarts counting. In one shot mode, the TOT pin outputs rectangular wave while the TMR register is counting. You can select the rectangular wave level ("H" or "L") by setting the pin output level select bit in the timer control status register (TMCSR:OUTL). [In reload mode (TMCSR:RELD=1)] When the 16-bit timer register (TMR) underflows, it is reloaded with the value set in the 16-bit reload register (TMRLR) to continue counting. In reload mode, a toggle wave is output each time the TMR register underflows during counting. The toggle wave inverts the TOT pin output level. The toggle wave level ("H" or "L") at reload timer activation can be selected by setting the pin output level select bit in the timer control status register (TMCSR:OUTL). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 313 CHAPTER 14 16-BIT RELOAD TIMERS 14.5 Operations of 16-bit Reload Timers MB90860E Series ■ Operations in Event Count Mode Enable the 16-bit reload timer operation by setting the timer operation enable bit in the timer control status register (TMCSR:CNTE) to "1". Setting the software trigger bit in the timer control status register (TMCSR:TRG) to "1" activates the 16-bit reload timer. When the 16-bit reload timer is activated, the 16-bit timer register (TMR) is loaded with the value set in the 16-bit reload register (TMRLR) to start counting. The TMR register performs counting while detecting edges of the external event clock signal input to the TIN pin after the 16-bit reload timer is activated. • You can select the rising edge, falling edge, or both edges to be detected, by setting the operation mode select bits in the timer control status register (TMCSR: MOD2 to MOD0). Note: For "H" and "L" clock widths to be input to the TIN pin, refer to the value of data sheet. Figure 14.5-10 Count Operations in Event Count Mode (One Shot Mode) TIN pin Counter Reload data -1 0000H FFFFH Reload data -1 0000H FFFFH Data load signal UF bit CNTE bit TRG bit T* TOT pin Activation trigger input wait state T : Machine cycle * : It takes a time period of 1 T to load data from the reload register after trigger input. Figure 14.5-11 Count Operations in Event Count Mode (Reload Mode) TIN pin Counter Reload data -1 0000 H Reload data -1 0000 H Reload data -1 0000H Reload data -1 Data load signal UF bit CNTE bit TRG bit TOT pin T* T : Machine cycle * : It takes a time period of 1 T to load data from the reload register after trigger input. 314 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.6 Notes on Using 16-bit Reload Timers MB90860E Series 14.6 Notes on Using 16-bit Reload Timers Take the following precautions in using 16-bit reload timers: ■ Notes on Using 16-bit Reload Timers ● Notes on programming for setting • Before setting the 16-bit reload register (TMRLR), disable the timer operation (TMCSR:CNTE=0). • Although the 16-bit timer register (TMR) can be read even with the TMR register counting, be sure to use a word instruction for read access. • Before updating the CSL1 and CSL0 bits in the timer control status register (TMCSR), disable the timer operation (TMCSR:CNTE=0). • When detecting both edges is set first detection edge will be the rising edge after the operation is enabled. The counter value set by detecting both edges is initialized by the rising edge but not initialized by the falling edge. ● Notes on interrupts • It is impossible to return from interrupt processing when the UF bit in the timer control status register (TMCSR) contains "1" with underflow interrupt output enabled (TMCSR:INTE=1). Be sure to clear the UF bit. Note, however, that the UF bit is cleared automatically when EI2OS or DMA transfer is used. • When a 16-bit reload timer uses EI2OS or DMA transfer, disable interrupts by 16-bit reload timers sharing the same interrupt control register (ICR). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 315 CHAPTER 14 16-BIT RELOAD TIMERS 14.7 Sample Programs for 16-bit Reload Timers 14.7 MB90860E Series Sample Programs for 16-bit Reload Timers This section provides sample programs to use the 16-bit reload timer in internal clock mode and in event count mode. ■ Sample Program for Internal Clock Mode ● Processing specifications • Use 16-bit reload timer 0 to generate 24-ms interval timer interrupts. • Use the reload timer in reload mode to generate an interrupt repeatedly. • Activate the timer using a software trigger without using the external trigger input. • Neither EI2OS nor DMA is used. • The machine clock is 24 MHz; the count clock is 1.33 μs. ● Coding example ICR03 ;Interrupt control register for 16-bit ;reload timer TMCSR0 EQU 000060H ;Timer control status register TMR0 EQU 007948H ;16-bit timer register TMRLR0 EQU 007948H ;16-bit reload register UF0 EQU TMCSR0:2 ;Interrupt request flag bit CNTE0 EQU TMCSR0:1 ;Counter operation enable bit TRG0 EQU TMCSR0:0 ;Software trigger bit ;--------Main program-------------------------------------CODE CSEG ; : ;Assume that the items such as the stack ;pointer (SP) have been initialized. AND CCR,#0BFH ;Disable interrupts. MOV I:ICR03,#00H ;Interrupt level 0 (Highest) CLRB I:CNTE0 ;Suspend the counter. MOVW I:TMRLR0,#4650H ;Set 24-ms timer data. MOVW I:TMCSR0,#0000100000011011B ;Operate as an interval timer with clock 1.33 μs ;Disable external trigger and external output. ;Select reload mode and enable interrupts. ;Clear the interrupt flag and start counting. MOV ILM,#07H ;Set ILM in PS to level 7. OR CCR,#40H ;Enable interrupts. LOOP: 316 EQU 0000B3H FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 14 16-BIT RELOAD TIMERS 14.7 Sample Programs for 16-bit Reload Timers MB90860E Series • User processing • BRA LOOP ; ;---------Interrupt program-------------------------------WARI: CLR I:UF0 ;Clear the interrupt request flag. • • User processing • • RETI ;Return from interrupt. CODE ENDS ;---------Vector setting----------------------------------VECT CSEG ABS=0FFH ORG 00FFB8H ;Set a vector for interrupt #17(11H). DSL WARI ORG 00FFDCH ;Set a reset vector. DSL START DB 00H ;Set single-chip mode. VECT ENDS END START ■ Sample Program for Event Count Mode ● Processing specifications • Use 16-bit reload timer 0 to generate an interrupt when it counts the rising edge of the pulse input to the external event input pin 10000 times. • Operate the reload timer in one shot mode. • Select the rising edge as the external trigger input. • Neither EI2OS nor DMA is not used. ● Coding example ICR03 ;Interrupt control register for 16-bit ;reload timer TMCSR0 EQU 000060H ;Timer control status register TMR0 EQU 007948H ;16-bit timer register TMRLR0 EQU 007948H ;16-bit reload register DDR8 EQU 000018H ;Port data register UF0 EQU TMCSR0:2 ;Interrupt request flag bit CNTE0 EQU TMCSR0:1 ;Counter operation enable bit TRG0 EQU TMCSR0:0 ;Software trigger bit ;---------Main program------------------------------------CODE CSEG CM44-10144-4E EQU 0000B3H FUJITSU SEMICONDUCTOR LIMITED 317 CHAPTER 14 16-BIT RELOAD TIMERS 14.7 Sample Programs for 16-bit Reload Timers ; MB90860E Series : ;Assume that the items such as the stack ;pointer (SP) have been initialized. ;Assume that no A/D converter is used or ;that the reload timer is used in software ;activation mode (ACS1: STS1, 0 = 00B). AND CCR,#0BFH ;Disable interrupts. MOV I:ICR03,#00H ;Interrupt level 0 (Highest) MOV I:DDR8,00H ;Set the P80/TIN0 pins for input. CLRB I:CNTE0 ;Suspend the counter. MOVW I:TMRLR0,#2710H;Set the reload value to 10,000 (times). MOVW I:TMCSR0,#0000110001001011B ;Operate the counter and select the rising ;edge. ;Disable external output. ;Select one shot mode and enable ;interrupts. ;Clear the interrupt flag and start ;counting. MOV ILM,#07H ;Set the ILM in PS to level 7. OR CCR,#40H ;Enable interrupts. LOOP: • User processing • BRA LOOP ; ;---------Interrupt program-------------------------------WARI: CLR I:UF0 ;Clear the interrupt request flag. • • User processing • • RETI ;Return from interrupt. CODE ENDS ;---------Vector setting----------------------------------VECT CSEG ABS=0FFH ORG 00FFB8H ;Set a vector for interrupt #17(11H). DSL WARI ORG 00FFDCH ;Set a reset vector. DSL START DB 00H ;Set single-chip mode. VECT ENDS END START 318 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 15 WATCH TIMER This chapter explains the functions and operations of the watch timer. 15.1 Overview of Watch Timer 15.2 Block Diagram of Watch Timer 15.3 Configuration of Watch Timer 15.4 Interrupt of Watch Timer 15.5 Operating Explanation of Watch Timer 15.6 Example Program of Watch Timer CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 319 CHAPTER 15 WATCH TIMER 15.1 Overview of Watch Timer 15.1 MB90860E Series Overview of Watch Timer The watch timer is a 15-bit free-run counter that counts up in synchronization with the sub clock. • The interval time can be selected from 8 types and an interrupt request can be generated for each interval time. • An operation clock is supplied to the timer for sub clock oscillation stabilization wait time and to the watchdog timer. • The sub clock is always used as a count clock regardless of the settings of the clock selection register (CKSCR). ■ Interval Timer Function • When the watch timer reaches the interval time set by the interval time selection bits (WTC: WTC2 to WTC0), the bit corresponding to the interval time of the watch timer counter generates an overflow (carry) and the overflow flag bit is set (WTC:WTOF = 1). • If an interrupt due to the generation of overflow is enabled (WTC:WTIE=1), an interrupt request is generated when the overflow flag bit is set (WTC:WTOF=1). • The interval time of the watch timer can be selected from 8 types shown in Table 15.1-1. Table 15.1-1 Interval Time of Watch Timer Sub clock cycle Interval time 28/SCLK (31.25 ms) 29/SCLK (62.5 ms) 210/SCLK (125 ms) 1/SCLK (122 μs) 211/SCLK (250 ms) 212/SCLK (500 ms) 213/SCLK (1.0 s) 214/SCLK (2.0 s) 215/SCLK (4.0 s) SCLK: Sub clock frequency The value within parenthesis ( ) indicates a calculation example of sub clock operating at 8.192 kHz. 320 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 15 WATCH TIMER 15.1 Overview of Watch Timer MB90860E Series ■ Cycle of Clock Supply The watch timer supplies an operation clock to the timer for sub clock oscillation stabilization wait time and to the watchdog timer. Table 15.1-2 shows the cycles of clocks supplied from the watch timer. Table 15.1-2 Cycle of Clock Supplied from Watch Timer Clock supply to Timer for sub clock oscillation stabilization wait time Clock cycle 214/SCLK (4.000 s) 210/SCLK (125 ms) 213/SCLK (1.000 s) Watchdog timer 214/SCLK (2.000 s) 215/SCLK (4.000 s) SCLK: Sub clock frequency The value within parenthesis ( ) indicates a calculation example of sub clock operating at 8.192 kHz. Note: CM44-10144-4E Sub clock SCLK frequency is the value of the clock to be input to low speed oscillation pins (X0A, X1A) dividing by 2 or 4. Division ratio is set by SCDS bit in PLL/sub clock control register (PSCCR). FUJITSU SEMICONDUCTOR LIMITED 321 CHAPTER 15 WATCH TIMER 15.2 Block Diagram of Watch Timer 15.2 MB90860E Series Block Diagram of Watch Timer The watch timer consists of the following blocks: • Watch timer counter • Counter clear circuit • Interval timer selector • Watch timer control register (WTC) ■ Block Diagram of Watch Timer Figure 15.2-1 Block Diagram of Watch Timer To watchdog timer Watch timer counter SCLK × 21 × 2 2 × 2 3 × 2 4 × 2 5 × 2 6 × 27 × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 OF OF OF OF Power-on reset Transition to hardware standby Transition to stop mode OF OF Counter clear circuit OF OF To sub clock oscillation stabilization wait time Interval timer selector Watch timer interrupt OF : Overflow SCLK : Sub clock WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0 Watch timer control register (WTC) The actual interrupt request number of the watch timer is as follows: Interrupt request number: #27 (1BH) ● Watch timer counter This counter is a 15-bit up counter that uses the sub clock (SCLK) as a count clock. ● Counter clear circuit The counter clear circuit clears the watch timer counter. 322 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 15 WATCH TIMER 15.2 Block Diagram of Watch Timer MB90860E Series ● Interval timer selector The interval timer selector sets the overflow flag bit when the watch timer counter reaches the interval time value by referring to the interval time set in the watch timer control register (WTC). ● Watch timer control register (WTC) The watch timer control register selects the interval time, clears the watch timer counter, enables or disables interrupt, checks the overflow (carry) state, and clears the overflow flag bit. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 323 CHAPTER 15 WATCH TIMER 15.3 Configuration of Watch Timer 15.3 MB90860E Series Configuration of Watch Timer This section shows the registers and interrupt sources of the watch timer. ■ List of Registers and Reset Values of Watch Timer Figure 15.3-1 List of Registers and Reset Values of Watch Timer bit Watch timer control register (WTC) 7 6 5 4 3 2 1 0 1 × 0 0 1 0 0 0 X: Undefined ■ Generation of Interrupt Request in Watch Timer • When the interval time that has been set by the interval time selection bits (WTC: WTC2 to WTC0) is reached, the overflow flag bit (WTC:WTOF) is set to "1". • If interrupt by a watch timer counter overflow (carry) is enabled (WTC:WTIE=1), an interrupt request is generated when the overflow flag bit is set (WTC:WTOF=1). 324 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 15.3.1 Watch Timer Control Register (WTC) CHAPTER 15 WATCH TIMER 15.3 Configuration of Watch Timer The functions of the watch timer control register (WTC) are shown below. ■ Watch Timer Control Register (WTC) Figure 15.3-2 Watch Timer Control Register (WTC) Address 0000AAH 7 6 5 4 3 2 1 0 Initial value WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0 R/W R 1X001000B R/W R/W R/W R/W R/W R/W bit2 bit1 bit0 Interval time selection bits WTC2 WTC1 WTC0 0 0 0 28/SCLK (31.25 ms) 0 0 1 29/SCLK (62.5 ms) 0 1 0 210/SCLK (125 ms) 0 1 1 211/SCLK (250 ms) 1 0 0 212/SCLK (500 ms) 1 0 1 213/SCLK (1.0 s) 1 1 0 214/SCLK (2.0 s) 1 1 1 215/SCLK (4.0 s) bit3 WTR 0 1 Watch timer clear bit Read ⎯ Always "1" is read Write Clears watch timer counter No effect bit4 WTOF 0 1 Overflow flag bit Read Write No overflow of the bit Clears WTOF bit corresponding to a set interval time occurred Overflow of the bit No effect corresponding to a set interval time occurred bit5 Overflow interrupt enable bit WTIE 0 Disables interrupt request 1 Enables interrupt request bit6 Oscillation stabilization wait time end bit SCE 0 In oscillation stabilization wait state 1 Oscillation stabilization wait time end bit7 WDCS R/W R X SCLK : Readable/writable : Read only : Undefined : Sub clock : Initial value CM44-10144-4E 0 1 Watchdog clock selection bit (Input clock of watchdog timer) Main or PLL clock mode Sub clock mode Watch timer Set "0" Time-base timer The value within parenthesis ( ) indicates a calculation example of sub clock operating at 8.192 kHz. FUJITSU SEMICONDUCTOR LIMITED 325 CHAPTER 15 WATCH TIMER 15.3 Configuration of Watch Timer MB90860E Series Table 15.3-1 Functions of Watch Timer Control Register (WTC) Bit name Function bit7 WDCS: Watchdog clock selection bit This bit selects the operation clock of the watchdog timer. <Main clock mode or PLL clock mode> When set to "0": Selects the output of watch timer as an operation clock of watchdog timer. When set to "1": Selects the output of time-base timer as an operation clock of watchdog timer. <Sub clock mode> Always set this bit to "0" to select the output of the watch timer. Note: As the watch timer and time-base timer operate asynchronously, the watchdog timer may run fast when WDCS bit is changed from "0" to "1". The watchdog timer must be cleared before and after changing this bit. bit6 SCE: Oscillation stabilization wait time end bit This bit indicates that the oscillation stabilization wait time of the sub clock ends. When cleared to "0": Indicates that the sub clock is in oscillation stabilization wait state. When set to "1" : Indicates that the oscillation stabilization wait time ends. • The oscillation stabilization wait time of the sub clock is fixed at 214/SCLK (SCLK: sub clock frequency). bit5 WTIE: Overflow interrupt enable bit This bit enables or disables generation of an interrupt request due to an overflow (carry) of the watch timer counter. When set to "0": No interrupt request is generated even if an overflow occurs (WTOF=1). When set to "1": An interrupt request is generated if an overflow occurs (WTOF=1). bit4 WTOF: Overflow flag bit This bit is set to "1" when the counter value of the watch timer reaches the value set by the interval time selection bit. If interrupt request is enabled (WTIE=1), an interrupt request is generated when an overflow (carry) occurs (WTOF=1). When set to "0": Clears the flag. When set to "1": No effect. • The overflow flag bit is set to "1" if an overflow (carry) of the bit of the watch timer counter corresponding to the interval time set by the interval time selection bits (WTC2 to WTC0) occurs. Note: To clear the overflow interrupt request flag bit (WTC: WTOF), disable a watch timer interrupt at interrupt processing (WTC: WTIE = 0) or mask watch timer interrupt by using the ILM bit in the processor status (PS). Do not enable watch timer interrupt (WTC: WTIE = 1) and clear interrupt flag (WTC: WTOF = 0) at the same time. bit3 bit2 to bit0 326 WTR: Watch timer clear bit This bit clears the watch timer counter. When set to "0": Clears the watch timer counter to 0000H. When set to "1": No effect. When read : Always "1" is read. WTC2, WTC1, WTC0: Interval time selection bits These bits set the interval time of the watch timer. • When the interval time set by the WTC2 to WTC0 bits is reached, the corresponding bit of the watch timer counter generates an overflow (carry) and the overflow flag bit is set (WTC:WTOF=1). • When setting WTC2 to WTC0 bits, set WTOF bit to "0" at the same time. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 15 WATCH TIMER 15.4 Interrupt of Watch Timer MB90860E Series 15.4 Interrupt of Watch Timer When the interval time is reached, the overflow flag bit is set to "1" and an interrupt request is generated if interrupt of the watch timer is enabled. ■ Interrupt of Watch Timer Table 15.4-1 shows the interrupt control bits and interrupt sources of the watch timer. Table 15.4-1 Interrupt Control Bits of Watch Timer Watch timer Interrupt source Interval time of watch timer counter Interrupt request flag bit WTC: WTOF (overflow flag bit) Interrupt source enable bit WTC: WTIE • When the value set by the interval time selection bits (WTC2 to WTC0) in the watch timer control register (WTC) is reached, the overflow flag bit in WTC is set to "1" (WTC:WTOF=1). • If interrupt is enabled for the watch timer (WTC:WTIE=1), an interrupt request is generated when the overflow flag bit is set (WTC:WTOF=1). • To cancel an interrupt request, set WTOF bit to "0" by interrupt process. ■ Watch Timer Interrupt and EI2OS/DMA Transfer Function • The watch timer does not support the extended intelligent I/O service (EI2OS) function and DMA transfer. • For interrupt number, interrupt control register and interrupt vector address, see "CHAPTER 3 INTERRUPTS". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 327 CHAPTER 15 WATCH TIMER 15.5 Operating Explanation of Watch Timer 15.5 MB90860E Series Operating Explanation of Watch Timer The watch timer operates as an interval timer or a timer for sub clock oscillation stabilization wait time. It also supplies an operation clock to the watchdog timer. ■ Watch Timer Counter The watch timer counter continues to count up in synchronization with the sub clock (SCLK) while the sub clock (SCLK) is operating. ● Clearing watch timer counter The watch timer counter will be cleared to 0000H in the following cases: • Power-on reset • Transition to sleep mode • Setting the watch timer clear bit (WTR) in the watch timer control register (WTC) to "0" Notes: • When a watch timer counter clear occurs, it affects the interrupt operation of the watchdog timer and interval timer that use outputs from the watch timer counter. When clearing the watch timer by setting the watch timer clear bit (WTR) in the watch timer control register (WTC) to "0", do so after setting the overflow interrupt enable bit (WTIE) in WTC to "0" to disable watch timer interrupt. In addition, before enabling the interrupt, clear an interrupt request by setting the overflow bit (WTOF) in WTC to "0". • To clear the overflow interrupt request flag bit (WTC: WTOF), disable a watch timer interrupt at interrupt processing (WTC: WTIE = 0) or mask watch timer interrupt by using the ILM bit in the processor status (PS). Do not enable watch timer interrupt (WTC: WTIE = 1) and clear interrupt flag (WTC: WTOF = 0) at the same time. ■ Interval Timer Function The watch timer can be used as an interval timer by generating an interrupt at each interval time. ● Setting for when using watch timer as interval timer To make the watch timer operate as an interval timer, the setting shown in Figure 15.5-1 is required. Figure 15.5-1 Setting of Watch Timer bit7 WTC 6 5 4 3 2 1 bit 0 WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0 : Used bit : Unused bit • When the value set by the interval time selection bits (WTC1, WTC0) in the watch timer control register (WTC) is reached, the overflow flag bit in WTC is set to "1" (WTC:WTOF=1). • When the overflow flag bit is set (WTC:WTOF = 1) with the overflow interrupt of the watch timer counter enabled (WTC:WTIE = 1), an interrupt request is generated. • The overflow flag bit (WTC:WTOF) is set when the interval time is reached from the timing, as a starting point, at which the watch timer is cleared last. 328 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 15 WATCH TIMER 15.5 Operating Explanation of Watch Timer MB90860E Series ● Clearing overflow flag bit (WTC:WTOF) When the mode transits to stop mode, WTOF bit is cleared concurrently with the mode transition because the watch timer is used as the timer for oscillation stabilization wait time of the sub clock. ■ Setting for Operation Clock of Watchdog Timer The watchdog clock selection bit (WDCS) in the watch timer control register (WTC) can be used to set the clock input source of the watchdog timer. When using the sub clock as the machine clock, be sure to set the WDCS bit to "0" to select watch timer output. ■ Timer for Oscillation Stabilization Wait Time of Sub Clock When the watch time returns from power-on reset or stop mode, it functions as a timer for oscillation stabilization wait timer of the sub clock. • The sub clock oscillation stabilization wait time is fixed at 214/SCLK (SCLK: sub clock). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 329 CHAPTER 15 WATCH TIMER 15.6 Example Program of Watch Timer 15.6 MB90860E Series Example Program of Watch Timer This section shows an example program of the watch timer. ■ Example Program of Watch Timer ● Processing specification An interrupt at 213/SCLK (SCLK: sub clock) interval is generated repeatedly. The interval time of this case is approximately 1.0 s (when the sub clock operates at 8.192 kHz). ● Coding example ICR08 EQU 0000B8H ;Interrupt control register WTC EQU 0000AAH ;Watch timer control register WTOF EQU WTC:4 ;Overflow flag bit ; ;---------Main program--------------------------------------CODE CSEG START: ; ;Stack pointer (SP) etc. should be ;initialized in advance AND CCR,#0BFH ;Disables interrupt MOV I:ICR07,#00H ;Interrupt level 0 (highest) MOV I:WTC,#10100101B ;Enables interrupt ;Clears overflow flag ;Clears watch timer counter ;213/SCLK (approximately 1.0 s) MOV ILM,#07H ;Sets ILM in PS to level 7 OR CCR,#40H ;Enables interrupt LOOP: • User processing • BRA LOOP ;---------Interrupt program---------------------------------WARI: CLRB I:WTOF ;Clears overflow flag • User processing • RETI ;Returns from interrupt processing CODE ENDS ;---------Vector setting------------------------------------VECT CSEG ABS=0FFH ORG 00FF90H ;Sets vector to interrupt #27 (1BH) 330 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 15 WATCH TIMER 15.6 Example Program of Watch Timer MB90860E Series VECT CM44-10144-4E DSL ORG DSL DB ENDS END WARI 00FFDCH START 00H ;Resets vector setting ;Sets to single chip mode START FUJITSU SEMICONDUCTOR LIMITED 331 CHAPTER 15 WATCH TIMER 15.6 Example Program of Watch Timer 332 FUJITSU SEMICONDUCTOR LIMITED MB90860E Series CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER This chapter explains the functions and operations of the 8/16-bit PPG timer. 16.1 Overview of 8/16-bit PPG Timer 16.2 Block Diagram of 8/16-bit PPG Timer 16.3 Configuration of 8/16-bit PPG Timer 16.4 Interrupts of 8/16-bit PPG Timer 16.5 Operating Explanation of 8/16-bit PPG Timer 16.6 Notes on Using 8/16-bit PPG Timer CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 333 CHAPTER 16 8/16-BIT PPG TIMER 16.1 Overview of 8/16-bit PPG Timer 16.1 MB90860E Series Overview of 8/16-bit PPG Timer The 8/16-bit PPG timer is the 2-channel reload timer module (PPG0, PPG1) that can perform pulse output of any cycle and duty ratio. The following operation can be performed by combining the 2 channel modules. • 8-bit PPG output 2-channel independent operation mode • 16-bit PPG output operation mode • 8+8-bit PPG output operation mode The MB90860E series has eight built-in 8/16-bit PPG timers. This section explains the functions of PPG0/1. PPG2/3, PPG4/5, PPG6/7, PPG8/9, PPGA/B, PPGC/D, and PPGE/F have the same functions as PPG0/1. ■ Functions of 8/16-bit PPG Timer The 8/16-bit PPG timer consists of four 8-bit reload registers (PRLH0/PRLL0, PRLH1/PRLL1) and two PPG down counters (PCNT0, PCNT1). • The "H" width and "L" width of an output pulse can be set separately, so the output pulse cycle and duty ratio can be set arbitrarily. • The count clock can be selected from six internal clocks. • The 8/16-bit PPG timer can be used as an interval timer by generating an interrupt request at each interval time. • An external circuit enables the 8/16-bit PPG timer to be used as a D/A converter. 334 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.1 Overview of 8/16-bit PPG Timer MB90860E Series ■ Operation Modes for 8/16-bit PPG Timer ● 8-bit PPG output 2-channel independent operation mode This mode makes each 2-channel module (PPG0, PPG1) operate as an independent 8-bit PPG timer. Table 16.1-1 shows the interval times in 8-bit PPG output 2-channel independent operation mode. Table 16.1-1 Interval Times in 8-bit PPG Output 2-channel Independent Operation Mode PPG0, PPG1 Count clock cycle Interval time Output pulse time 1/φ (41.7 ns) 1/φ to 28/φ 2/φ to 29/φ 2/φ (83.3 ns) 2/φ to 29/φ 22/φ to 210/φ 22/φ (167 ns) 22/φ to 210/φ 23/φ to 211/φ 23/φ (333 ns) 23/φ to 211/φ 24/φ to 212/φ 24/φ (667 ns) 24/φ to 212/φ 25/φ to 213/φ 29/HCLK (128 μs) 29/HCLK to 217/HCLK 210/HCLK to 218/HCLK HCLK: Oscillation clock φ: Machine clock frequency The value within parenthesis ( ) is the value operating at HCLK=4 MHz and φ=24 MHz. ● 16-bit PPG output operation mode This mode concatenates the 2-channel modules (PPG0, PPG1) to operate as a 16-bit 1-channel PPG timer. Table 16.1-2 shows the interval times in 16-bit PPG output operation mode. Table 16.1-2 Interval Times in 16-bit PPG Output Operation Mode Count clock cycle Interval time Output pulse time 1/φ (41.7 ns) 1/φ to 216/φ 2/φ to 217/φ 2/φ (83.3 ns) 2/φ to 217/φ 22/φ to 218/φ 22/φ (167 ns) 22/φ to 218/φ 23/φ to 219/φ 23/φ (333 ns) 23/φ to 219/φ 24/φ to 220/φ 24/φ (667 ns) 24/φ to 220/φ 25/φ to 221/φ 29/HCLK (128 μs) 29/HCLK to 225/HCLK 210/HCLK to 226/HCLK HCLK: Oscillation clock φ: Machine clock frequency The value within parenthesis ( ) is the value operating at HCLK=4 MHz and φ=24 MHz. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 335 CHAPTER 16 8/16-BIT PPG TIMER 16.1 Overview of 8/16-bit PPG Timer MB90860E Series ● 8+8 PPG output operation mode This mode makes the PPG0 of the 2-channel modules operate as an 8-bit prescaler, operated by inputting the PPG0 underflow output as PPG1 count clock. Table 16.1-3 shows the interval times in 8+8-bit PPG output operation mode. Table 16.1-3 Interval Times in 8+8-bit PPG Output Operation Mode PPG0 PPG1 Count clock cycle Interval time Output pulse time Interval time Output pulse time 1/φ (41.7 ns) 1/φ to 28/φ 2/φ to 29/φ 1/φ to 216/φ 2/φ to 217/φ 2/φ (83.3 ns) 2/φ to 29/φ 22/φ to 210/φ 2/φ to 217/φ 22/φ to 218/φ 22/φ (167 ns) 22/φ to 210/φ 23/φ to 211/φ 22/φ to 218/φ 23/φ to 219/φ 23/φ (333 ns) 23/φ to 211/φ 24/φ to 212/φ 23/φ to 219/φ 24/φ to 220/φ 24/φ (667 ns) 24/φ to 212/φ 25/φ to 213/φ 24/φ to 220/φ 25/φ to 221/φ 29/HCLK (128 μs) 29/HCLK to 217/HCLK 210/HCLK to 218/HCLK 29/HCLK to 225/HCLK 210/HCLK to 226/HCLK HCLK: Oscillation clock φ: Machine clock frequency The value within parenthesis ( ) is the value operating at HCLK=4 MHz and φ=24 MHz. 336 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.2 Block Diagram of 8/16-bit PPG Timer MB90860E Series 16.2 Block Diagram of 8/16-bit PPG Timer The MB90860E series contains eight built-in 8/16-bit PPG timers (with two channels each). One 8/16-bit PPG timer consists of 2-channel 8-bit PPG timers. This section shows the block diagrams of the 8/16-bit PPG timer 0 and 8/16-bit PPG timer 1. PPG2, 4, 6, 8, A, C, and E have the same function as PPG0, and PPG3, 5, 7, 9, B, D, and F have the same function as PPG1. ■ Channels and PPG Pins of PPG Timers Figure 16.2-1 shows the relationship between the channels and the PPG pins of the 8/16-bit PPG timers in the MB90860E series. Figure 16.2-1 Channels and PPG Pins of PPG Timers Pin PPG0/1 PPG01: REV PPG0 output pin Pin PPG1 output pin Pin PPG2/3 PPG23: REV PPG2 output pin Pin PPG3 output pin PPG4/5 Pin PPG45: REV PPG4 output pin Pin PPG5 output pin PPG6/7 Pin PPG67: REV PPG6 output pin Pin PPG7 output pin PPG8/9 Pin PPG89: REV PPG8 output pin Pin PPG9 output pin PPGA/B Pin PPGAB: REV PPGA output pin Pin PPGB output pin PPGC/D Pin PPGCD: REV PPGC output pin Pin PPGD output pin PPGE/F Pin PPGEF: REV PPGE output pin Pin PPGF output pin CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 337 CHAPTER 16 8/16-BIT PPG TIMER 16.2 Block Diagram of 8/16-bit PPG Timer 16.2.1 MB90860E Series Block Diagram of 8/16-bit PPG Timer 0 The 8/16-bit PPG timer 0 consists of the following blocks. ■ Block Diagram of 8/16-bit PPG Timer 0 Figure 16.2-2 Block Diagram of 8/16-bit PPG Timer 0 "H" level side data bus "L" level side data bus PPG0 reload register PRLH0 ("H" level side) PPG0 operation mode control register (PPGC0) PRLL0 ("L" level side) PEN0 Reserved PE0 PIE0 PUF0 PPG0 temporary buffer 0 (PRLBH0) Interrupt request R output* S Q 2 Select signal Reload register L/H selector Count start value Reload Clear Pulse selector PPG0 down counter (PCNT0) Operation mode control signal PPG1 underflow PPG0 underflow (to PPG1) Underflow CLK PPG0 Invert output latch Pin PPG output control circuit PPG0 Time-base timer output (512/HCLK) Peripheral clock (1/φ) Peripheral clock (2/φ) Peripheral clock (4/φ) Peripheral clock (8/φ) Peripheral clock (16/φ) PPG1 output Count clock selector 3 Select signal PCS2 PCS1 PCS0 PCM2 PCM1 PCM0 REV PPG0/1 count clock selection register (PPG01) − : Undefined Reserved : Reserve bit HCLK : Oscillation clock frequency φ : Machine clock frequency * : The interrupt output of 8/16-bit PPG timer 0 is combined to one interrupt by OR circuit with the interrupt request output of PPG timers 1, 4 and 5. 338 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.2 Block Diagram of 8/16-bit PPG Timer MB90860E Series ● Details of pins in the block diagram Table 16.2-1 shows the actual pin names and interrupt request numbers of the 8/16-bit PPG timer. Table 16.2-1 Pins and Interrupt Request Numbers in Block Diagram Output pin Channel PPG:REV=0 PPG:REV=1 PPG0 P60 / PPG0 P90 / PPG1 PPG1 P90 / PPG1 P60 / PPG0 PPG2 P61 / PPG2 P91 / PPG3 PPG3 P91 / PPG3 P61 / PPG2 PPG4 P62 / PPG4 P92 / PPG5 PPG5 P92/ PPG5 P62 / PPG4 PPG6 P63 / PPG6 P93 / PPG7 PPG7 P93/ PPG7 P63 / PPG6 PPG8 P64 / PPG8 P20 / PPG9 PPG9 P20 / PPG9 P64 / PPG8 PPGA P65 / PPGA P21 / PPGB PPGB P21 / PPGB P65 / PPGA PPGC P66 / PPGC P22 / PPGD PPGD P22 / PPGD P66 / PPGC PPGE P67/ PPGE P23 / PPGF PPGF P23/ PPGF P67 / PPGE Interrupt request number #21 (15H) #22 (16H) #21 (15H) #22 (16H) #23 (17H) #24 (18H) #23 (17H) #24 (18H) ● PPG0 operation mode control register (PPGC0) This register enables or disables the operation, pin output, and underflow interrupt of the 8/16-bit PPG timer. It also indicates the occurrence of an underflow. ● PPG0/1 count clock selection register (PPG01) This register sets the count clock of the 8/16-bit PPG timer and the switching between PPG0 and PPG1 output pins. ● PPG0 reload registers (PRLH0, PRLL0) These registers set the "H" width or "L" width of output pulse. The values set in PPG0 reload registers are reloaded into the PPG0 down counter (PCNT0) when the 8/16-bit PPG timer is activated. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 339 CHAPTER 16 8/16-BIT PPG TIMER 16.2 Block Diagram of 8/16-bit PPG Timer MB90860E Series ● PPG0 down counter (PCNT0) This counter is an 8-bit down counter that counts down by alternately reloading the values set in the PPG0 reload registers (PRLH0, PRLL0). When an underflow occurs, the pin output is inverted. This counter can be used as a 1-channel 16-bit PPG down counter by concatenating 2-channel PPG down counters (PPG0, PPG1). ● PPG0 temporary buffer (PRLBH0) This buffer prevents deviation of the output pulse width caused by the timing of writing to the PPG reload registers (PRLH0, PRLL0). This buffer stores the PRLH0 value temporarily and enables the set value of the PRLH0 in synchronization with the timing of writing to the PRLL0. ● Reload register L/H selector This selector detects the current pin output level to select which side of the reload register, "L" side (PRLL0) or "H" side (PRLH0), is reloaded into the PPG0 down counter. ● Count clock selector This selector selects the count clock to be input to the PPG down counter 0 from five divided clocks of the machine clock or the divided clock of the time-base timer. ● PPG output control circuit This circuit inverts the pin output level and the output when an underflow occurs. 340 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.2 Block Diagram of 8/16-bit PPG Timer MB90860E Series 16.2.2 Block Diagram of 8/16-bit PPG Timer 1 The 8/16-bit PPG timer 1 consists of the following blocks. ■ Block Diagram of 8/16-bit PPG Timer 1 Figure 16.2-3 Block Diagram of 8/16-bit PPG Timer 1 "H" side data bus "L" side data bus PPG1 operation mode control register (PPGC1) PPG1 reload register PRLH1 ("H" side) PRLL1 ("L" side) PEN1 PE1 PIE1 PUF1 MD1 MD0 Operation mode control signal Reserved 2 PPG1 temporary buffer (PRLBH1) R S Reload selector L/H selector Count start value PPG0 underflow (from PPG0) Q Select signal Reload Clear PPG1 down counter Underflow (PCNT1) PPG1 underflow (to PPG0) Interrupt request output* Invert CLK PPG1 output latch Pin PPG1 PPG output control circuit MD0 PPG0 output Time-base timer output (512/HCLK) Peripheral clock (1/φ) Peripheral clock (2/φ) Peripheral clock (4/φ) Peripheral clock (8/φ) Peripheral clock (16/φ) Counter clock selector 3 Select signal PCS2 PCS1 PCS0 PCM2 PCM1 PCM0 REV − : Undefined PPG0/1 count clock selection register (PPG01) Reserved : Reserved bit HCLK : Oscillation clock frequency φ : Machine clock frequency * : The interrupt output of 8/16-bit PPG timer 1 is combined to one interrupt by OR circuit with the interrupt request output of PPG timers 0, 4 and 5. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 341 CHAPTER 16 8/16-BIT PPG TIMER 16.2 Block Diagram of 8/16-bit PPG Timer MB90860E Series ● Details of pins in the block diagram Table 16.2-2 shows the actual pin names and interrupt request numbers of the 8/16-bit PPG timer. Table 16.2-2 Pins and Interrupt Request Numbers in Block Diagram Output pin Channel PPG:REV=0 PPG:REV=1 PPG0 P60 / PPG0 P90 / PPG1 PPG1 P90 / PPG1 P60 / PPG0 PPG2 P61 / PPG2 P91 / PPG3 PPG3 P91 / PPG3 P61 / PPG2 PPG4 P62 / PPG4 P92 / PPG5 PPG5 P92/ PPG5 P62 / PPG4 PPG6 P63 / PPG6 P93 / PPG7 PPG7 P93/ PPG7 P63 / PPG6 PPG8 P64 / PPG8 P20 / PPG9 PPG9 P20 / PPG9 P64 / PPG8 PPGA P65 / PPGA P21 / PPGB PPGB P21 / PPGB P65 / PPGA PPGC P66 / PPGC P22 / PPGD PPGD P22 / PPGD P66 / PPGC PPGE P67/ PPGE P23 / PPGF PPGF P23/ PPGF P67 / PPGE Interrupt request number #21 (15H) #22 (16H) #21 (15H) #22 (16H) #23 (17H) #24 (18H) #23 (17H) #24 (18H) ● PPG1 operation mode control register (PPGC1) This register sets the operation mode of the 8/16-bit PPG timer. It enables or disables the operation, pin output, and underflow interrupt of the 8/16-bit PPG timer 1. It also indicates the occurrence of an underflow. ● PPG0/1 count clock selection register (PPG01) This register sets the count clock of the 8/16-bit PPG timer. ● PPG1 reload registers (PRLH1, PRLL1) These registers set the "H" width or "L" width of output pulse. The values set in PPG1 reload registers are reloaded into the PPG1 down counter (PCNT1) when the 8/16-bit PPG timer 1 is activated. 342 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.2 Block Diagram of 8/16-bit PPG Timer MB90860E Series ● PPG1 down counter (PCNT1) This counter is an 8-bit down counter that counts down by alternately reloading the values set in the PPG1 reload registers (PRLH1, PRLL1). When an underflow occurs, the pin output is inverted. This counter can be used as a 1-channel 16-bit PPG down counter by concatenating 2-channel PPG down counters (PPG0, PPG1). ● PPG1 temporary buffer (PRLBH1) This buffer prevents deviation of the output pulse width caused by the timing of writing to the PPG reload registers (PRLH1, PRLL1). This buffer stores the PRLH1 value temporarily and enables the set value of the PRLH1 in synchronization with the timing of writing to the PRLL1. ● Reload register L/H selector This selector detects the current pin output level to select which side of the reload register, "L" side (PRLL1) or "H" side (PRLH1), is reloaded into the PPG1 down counter. ● Count clock selector This selector selects the count clock to be input to the PPG1 down counter from five divided clocks of the machine clock or the divided clock of the time-base timer. ● PPG output control circuit This circuit inverts the pin output level and the output when an underflow occurs. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 343 CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer 16.3 MB90860E Series Configuration of 8/16-bit PPG Timer This section shows the pins, registers and interrupt sources of the 8/16-bit PPG timer. ■ Pins of 8/16-bit PPG Timer The pins of the 8/16-bit PPG timer serve as general-purpose I/O ports. Table 16.3-1 shows the pin functions and pin settings for using the 8/16-bit PPG timer. Table 16.3-1 Pins of 8/16-bit PPG Timer (1 / 2) Channel 344 Pin name Pin function Setting required for use of 8/16-bit PPG timer PPG0 P60 / AN0 / PPG0 General-purpose I/O port/ A/D converter analog input 0/ PPG output 0 • Analog input enable register: Set to disable (ADER6:ADE0=0) • PPG operation mode control register: Enable pin output (PPGC0:PE0=1) PPG1 P90 / PPG1 General-purpose I/O port/ PPG output 1 • PPG operation mode control register: Enable pin output (PPGC1:PE1=1) PPG2 P61 / AN1 / PPG2 General-purpose I/O port/ A/D converter analog input 1/ PPG output 2 • Analog input enable register: Set to disable (ADER6:ADE1=0) • PPG operation mode control register: Enable pin output (PPGC2:PE0=1) PPG3 P91 / PPG3 General-purpose I/O port/ PPG output 3 • PPG operation mode control register: Enable pin output (PPGC3:PE1=1) PPG4 P62 / AN2 / PPG4 General-purpose I/O port/ A/D converter analog input 2/ PPG output 4 • Analog input enable register: Set to disable (ADER6:ADE2=0) • PPG operation mode control register: Enable pin output (PPGC4:PE0=1) PPG5 P92 / PPG5 General-purpose I/O port/ PPG output 5 • PPG operation mode control register: Enable pin output (PPGC5:PE1=1) PPG6 P63 / AN3 / PPG6 General-purpose I/O port/ A/D converter analog input 3/ PPG output 6 • Analog input enable register: Set to disable (ADER6:ADE3=0) • PPG operation mode control register: Enable pin output (PPGC6:PE0=1) PPG7 P93 / PPG7 General-purpose I/O port/ PPG output 7 • PPG operation mode control register: Enable pin output (PPGC7:PE1=1) PPG8 P64 / AN4 / PPG8 General-purpose I/O port/ A/D converter analog input 4/ PPG output 8 • Analog input enable register: Set to disable (ADER6:ADE4=0) • PPG operation mode control register: Enable pin output (PPGC8:PE0=1) PPG9 P20 / PPG9 General-purpose I/O port/ PPG output 9 • PPG operation mode control register: Enable pin output (PPGC9:PE1=1) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series Table 16.3-1 Pins of 8/16-bit PPG Timer (2 / 2) Channel CM44-10144-4E Pin name Pin function Setting required for use of 8/16-bit PPG timer PPGA P65 / AN5 / PPGA General-purpose I/O port/ A/D converter analog input 5/ PPG output A • Analog input enable register: Set to disable (ADER6:ADE5=0) • PPG operation mode control register: Enable pin output (PPGCA:PE0=1) PPGB P21 / PPGB General-purpose I/O port/ PPG output B • PPG operation mode control register: Enable pin output (PPGCB:PE1=1) PPGC P66 / AN6 / PPGC General-purpose I/O port/ A/D converter analog input 6/ PPG output C • Analog input enable register: Set to disable (ADER6:ADE6=0) • PPG operation mode control register: Enable pin output (PPGCC:PE0=1) PPGD P22 / PPGD General-purpose I/O port/ PPG output D • PPG operation mode control register: Enable pin output (PPGCD:PE1=1) PPGE P67 / AN7 / PPGE General-purpose I/O port/ A/D converter analog input 7/ PPG output E • Analog input enable register: Set to disable (ADER6:ADE7=0) • PPG operation mode control register: Enable pin output (PPGCE:PE0=1) PPGF P23 / PPGF General-purpose I/O port/ PPG output F • PPG operation mode control register: Enable pin output (PPGCF:PE1=1) FUJITSU SEMICONDUCTOR LIMITED 345 CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series ■ List of Registers and Reset Values of 8/16-bit PPG Timer Figure 16.3-1 List of Registers and Reset Values of 8/16-bit PPG Timer PPG0 operation mode control register: H (PPGCm) PPG0 operation mode control register: L (PPGCn) PPGn/m count clock selection register (PPGnm) bit 15 14 0 bit 7 6 0 13 12 11 10 9 8 0 0 0 0 0 1 5 4 3 2 1 0 0 0 0 1 7 6 5 4 3 2 0 0 0 0 0 0 bit 15 14 13 12 11 10 9 8 bit 7 6 5 4 3 2 1 0 bit 15 14 13 12 11 10 9 8 bit 7 6 5 4 3 2 1 0 bit 1 0 0 PPGn reload register: H (PRLHn) PPGm reload register: L (PRLLn) PPGm reload register: H (PRLHm) PPGm reload register: L (PRLLm) ×: Undefined n = 0, 2, 4, 6, 8, A, C, E m = 1, 3, 5, 7, 9, B, D, F ■ Generation of Interrupt in 8/16-bit PPG Timer In the 8/16-bit PPG timer, the underflow generation flag bits in the PPG operation mode control register (PPGCn: PUFn, PPGCm: PUFm) are set to "1" when an underflow occurs. If underflow interrupt of the channel causing an underflow is enabled (PPGCn:PIE0=1, PPGCm:PIE1=1), an underflow interrupt request is generated to the interrupt controller. 346 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series 16.3.1 PPG0 Operation Mode Control Register (PPGC0) The PPG0 operation mode control register provides the following settings for the 8/16bit PPG timer 0 operation: • Enabling or disabling operation of 8/16-bit PPG timer 0 • Switching between pin functions (enabling or disabling pulse output) • Enabling or disabling underflow interrupt • Setting interrupt request flag set by the occurrence of underflow Only the function of PPGC0 is explained in this section. PPGC2, 4, 6, 8, A, C, and E have the same function as PPGC0, setting the respective 8/16-bit PPG timers 2, 4, 6, 8, A, C, and E. ■ PPG0 Operation Mode Control Register (PPGC0) Figure 16.3-2 PPG0 Operation Mode Control Register (PPGC0) ch.0 PPGC0 7 Address 000030H PEN0 Other channels: ch.2 PPGC2 ch.4 PPGC4 ch.6 PPGC6 ch.8 PPGC8 ch.A PPGCA ch.C PPGCC ch.E PPGCE 000034H 000038H 00003CH 000040H 000044H 000048H 00004CH 6 5 4 3 2 1 0 − PE0 PIE0 PUF0 − − Reserved R/W − R/W R/W R/W − − W Initial value 0X000XX1B bit0 Reserved 1 Reserved bit Be sure to set this bit to "1" bit3 PUF0 0 1 Underflow generation flag bit Read No underflow Underflow detected Write Clears PUF0 bit No effect bit4 PIE0 0 1 Underflow interrupt enable bit Disables interrupt request Enables interrupt request bit5 PPG0 pin output enable bit PE0 0 1 General-purpose I/O port (Disables pulse output) PPG0 output (Enables pulse output) bit7 PPG0 operation enable bit PEN0 R/W : Readable/writable W : Write only X : Undefined − : Undefined 0 1 Disables count operation (Retains "L" level output) Enables count operation : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 347 CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series Table 16.3-2 Functions of PPG0 Operation Mode Control Register (PPGC0) Bit name 348 Function bit7 PEN0: PPG0 operation enable bit This bit enables or disables the count operation of the 8/16-bit PPG timer 0. When set to "0": Disables count operation When set to "1": Enables count operation • When the pulse output is enabled (PE0=1) while the count operation is disabled (PEN0=0), "L" level output is retained. bit6 Undefined bit Read : The value is undefined Write : No effect bit5 PE0: PPG0 pin output enable bit This bit switches between PPG0 pin functions and enables or disables the pulse output. When set to "0": Functions as a general-purpose I/O port. The pulse output is disabled When set to "1": Functions as PPG0 output pin. The pulse output is enabled bit4 PIE0: Underflow interrupt enable bit This bit enables or disables interrupt. When set to "0": Generates no interrupt request even when an underflow occurs (PUF0 = 1) When set to "1": Generates an interrupt request when an underflow occurs (PUF0 = 1) bit3 PUF0: Underflow generation flag bit 8-bit PPG output 2-channel independent operation mode, 8+8-bit PPG output operation mode: Generates an underflow (PUF0 = 1) when the value of the PPG0 down counter is counted down from 00H to FFH 16-bit PPG output operation mode: Generates an underflow (PUF0 = 1) when the value of the PPG0+PPG1 down counter is counted down from 0000H to FFFFH • When an underflow occurs (PUF0=1) while underflow interrupt is enabled (PIE0=1), an interrupt request is generated. When set to "0": Clears this bit When set to "1": No effect Read by a read-modify-write instruction: "1" is read bit2, bit1 Undefined bits Write : No effect Read : The value is undefined. bit0 Reserved: Reserved bit Be sure to set this bit to "1" FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series 16.3.2 PPG1 Operation Mode Control Register (PPGC1) The PPG1 operation mode control register provides the following settings for the 8/16bit PPG timer 1 operation: • Enabling or disabling operation of 8/16-bit PPG timer 1 • Switching between pin functions (enabling or disabling pulse output) • Enabling or disabling underflow interrupt • Setting interrupt request flag set by the occurrence of underflow • Setting operation mode for 8/16-bit PPG timers 1 and 0 Only the function of PPGC1 is explained in this section. PPGC3, 5, 7, 9, B, D, and F have the same function as PPGC1, setting the respective 8/16-bit PPG timers 3, 5, 7, 9, B, D, and F. ■ PPG1 Operation Mode Control Register (PPGC1) Figure 16.3-3 PPG1 Operation Mode Control Register (PPGC1) ch.1 PPGC1 Other channels: ch.3 PPGC3 ch.5 PPGC5 ch.7 PPGC7 ch.9 PPGC9 ch.B PPGCB ch.D PPGCD ch.F PPGCF Address 15 14 000031H PEN1 − PE1 PIE1 PUF1 MD1 MD0 Reserved − R/W R/W R/W R/W R/W W R/W 000035H 000039H 00003DH 000041H 000045H 000049H 00004DH 13 12 11 10 9 8 Initial value 0X000001B bit8 Reserved 1 Reserved bit Be sure to set this bit to "1" bit10 bit9 MD1 MD0 0 0 0 1 1 1 0 1 Operation mode selection bits 8-bit PPG output 2-channel independent operation mode 8+8-bit PPG output operation mode Setting is prohibited 16-bit PPG output operation mode bit11 PUF1 0 1 Underflow generation flag bit Read Write No underflow Clears PUF1 bit Underflow detected No effect bit12 PIE1 0 1 Underflow interrupt enable bit Disables underflow interrupt request Enables underflow interrupt request bit13 PE1 0 1 R/W : Readable/writable bit15 W : Write only PEN1 X : Undefined − : Undefined 0 1 PPG1 pin output enable bit General-purpose I/O port (Disables pulse output) PPG1 output (Enables pulse output) PPG1 operation enable bit Disables count operation (Retains "L" level output) Enables count operation : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 349 CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series Table 16.3-3 Functions of PPG1 Operation Mode Control Register (PPGC1) Bit name bit15 PEN1: PPG1 operation enable bit This bit enables or disables the count operation of the 8/16-bit PPG timer 1. When set to "0": Disables count operation When set to "1": Enables count operation • When the pulse output is enabled (PE1=1) while the count operation is disabled (PEN1=0), "L" level output is retained. bit14 Undefined bit Read : The value is undefined Write : No effect bit13 PE1: PPG1 pin output enable bit This bit switches between PPG1 pin functions and enables or disables the pulse output. When set to "0": Functions as a general-purpose I/O port. The pulse output is disabled When set to "1": Functions as PPG1 output pin. The pulse output is enabled bit12 PIE1: Underflow interrupt enable bit This bit enables or disables interrupt. When set to "0": Generates no interrupt request even when an underflow occurs (PUF1 = 1) When set to "1": Generates an interrupt request when an underflow occurs (PUF1 = 1) PUF1: Underflow generation flag bit 8-bit PPG output 2-channel independent operation mode, 8+8-bit PPG output operation mode: Generates an underflow (PUF1 = 1) when the value of the PPG1 down counter is counted down from 00H to FFH 16-bit PPG output operation mode: Generates an underflow (PUF1 = 1) when the value of the PPG0+PPG1 down counter is counted down from 0000H to FFFFH • When an underflow occurs (PUF1=1) while underflow interrupt request is enabled (PIE1=1), an interrupt request is generated. When set to "0": Clears this bit When set to "1": No effect Read by a read-modify-write instruction: "1" is read MD1, MD0: Operation mode selection bits These bits set the operation mode of the 8/16-bit PPG timer. [Any mode other than 8-bit PPG output 2-channel independent operation mode] • Set the two bits of the PPG operation enable bits (PEN0, PEN1) at the same time using a word instruction. • Do not set operation of only one of the two channels (PEN1=0/PEN0=1 or PEN1=1/PEN0=0). Note: Do not set MD1, MD0=10B. Reserved: Reserved bit Be sure to set this bit to "1" bit11 bit10, bit9 bit8 350 Function FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series 16.3.3 PPG0/1 Count Clock Selection Register (PPG01) The PPG0/1 count clock selection register selects the count clock and the output pin for the 8/16-bit PPG timers 0 and 1. Only the function of PPG01 is explained in this section. PPG23, 45, 67, 89, AB, CD, and EF have the same function as PPG01, setting the respective 8/16-bit PPG timers 2 and 3, 4 and 5, 6 and 7, 8 and 9, A and B, C and D, and E and F. ■ PPG0/1 Count Clock Selection Register (PPG01) Figure 16.3-4 PPG0/1 Count Clock Selection Register (PPG01) ch.1 PPG01 Other channels: ch.3 PPG23 ch.5 PPG45 ch.7 PPG67 ch.9 PPG89 ch.B PPGAB ch.D PPGCD ch.F PPGEF Address 000032H 7 6 5 4 3 2 PCS2 PCS1 PCS0 PCM2 PCM1 PCM0 000036H R/W R/W R/W R/W R/W R/W 00003AH 00003EH 000042H 000046H 00004AH 00004EH 1 0 − REV Initial value 0 0 0 0 0 0 X 0B R/W bit0 REV 0 1 bit4 PPG output pin selection bit Outputs pulses from the standard output pins Switches between output pin PPGn and PPGm bit3 bit2 PCM2 PCM1 PCM0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 bit7 bit6 bit5 PCS2 PCS1 PCS0 R/W : Readable/writable : Undefined X : Undefined : Initial value HCLK : Oscillation clock : Machine clock frequency φ 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 PPG0 count clock selection bits 1/φ (41.7 ns) 2/φ (83.3 ns) 22/φ (167 ns) 23/φ (333 ns) 24/φ (667 ns) Setting is prohibited Setting is prohibited 29/HCLK (128 μs) PPG1 count clock selection bits 1/φ (41.7 ns) 2/φ (83.3 ns) 22/φ (167 ns) 23/φ (333 ns) 24/φ (667 ns) Setting is prohibited Setting is prohibited 29/HCLK (128 μs) The value within parenthesis ( ) is the value operating at HCLK=4 MHz and φ=24 MHz. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 351 CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series Table 16.3-4 Functions of PPG0/1 Count Clock Selection Register (PPG01) Bit name Function These bits set the count clock of the 8/16-bit PPG timer 1. bit7 to bit5 PCS2 to PCS0: PPG1 count clock selection bits • The count clock is selected from five divided clocks of the machine clock or the divided clock of the time-base timer. • The settings of the PPG1 count clock select bits (PCS2 to PCS0) are valid only in 8-bit PPG output 2-channel independent mode (PPGC1: MD1, MD0=00B). PCM2 to PCM0: PPG0 count clock selection bits bit1 Undefined bit Read : The value is undefined Write: No effect REV: PPG output pin selection bit This bit switches the output pins of the 8/16-bit PPG timers 0 and 1. When set to "0": Outputs from the standard output pins PPG0 → PPG0 output pin PPG1 → PPG1 output pin When set to "1": Switches output pins PPG0 → PPG1 output pin PPG1 → PPG0 output pin bit0 352 These bits set the count clock of the 8/16-bit PPG timer 0. bit4 to bit2 • The count clock is selected from five divided clocks of the machine clock or the divided clock of the time-base timer. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series 16.3.4 PPG Reload Registers (PRLL0/PRLH0, PRLL1/PRLH1) The value (reload value) from which the PPG down counter starts counting is set in the PPG reload registers. The registers have an 8-bit for each "L" level side and "H" level side. Only the function of PRLL0/PRLH0 and PRLL1/PRLH1 is explained in this section. PRLL2/PRLH2 to PRLLF/PRLHF have the same function as PRLL0/PRLH0, setting the respective 8/16-bit PPG timers 2 to F. ■ PPG Reload Registers (PRLL0/PRLH0, PRLL1/PRLH1) Figure 16.3-5 PPG Reload Registers (PRLL0/PRLH0, PRLL1/PRLH1) ch.0 PRLH0 ch.1 PRLH1 Address bit15 bit14 bit13 bit12 bit11 bit10 007901H 007903H Other channels: ch.2 ch.3 ch.4 ch.5 ch.6 ch.7 ch.8 ch.9 ch.A ch.B ch.C ch.D ch.E ch.F PRLH2 PRLH3 PRLH4 PRLH5 PRLH6 PRLH7 PRLH8 PRLH9 PRLHA PRLHB PRLHC PRLHD PRLHE PRLHF 007905H 007907H 007909H 00790BH 00790DH 00790FH 007911H 007913H 007915H 007917H 007919H 00791BH 00791DH 00791FH Address ch.0 PRLL0 ch.1 PRLL1 007900H 007902H Other channels: ch.2 ch.3 ch.4 ch.5 ch.6 ch.7 ch.8 ch.9 ch.A ch.B ch.C ch.D ch.E ch.F PRLL2 PRLL3 PRLL4 PRLL5 PRLL6 PRLL7 PRLL8 PRLL9 PRLLA PRLLB PRLLC PRLLD PRLLE PRLLF bit9 bit8 Initial value D15 D14 D13 D12 D11 D10 D9 D8 R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 D7 D6 D5 D4 R/W R/W R/W R/W R/W D3 bit2 bit1 XXXXXXXX B bit0 D2 D1 D0 R/W R/W R/W Initial value XXXXXXXX B 007904H 007906H 007908H 00790AH 00790CH 00790EH 007910H 007912H 007914H 007916H 007918H 00791AH 00791CH 00791EH R/W : Readable/writable × : Undefined CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 353 CHAPTER 16 8/16-BIT PPG TIMER 16.3 Configuration of 8/16-bit PPG Timer MB90860E Series Table 16.3-5 shows each register function of the PPG reload registers. Table 16.3-5 Functions of PPG Reload Registers Notes: 354 Function 8/16-bit PPG timer 0 8/16-bit PPG timer 1 Retains the reload value at "L" level side PRLL0 PRLL1 Retains the reload value at "H" level side PRLH0 PRLH1 • In 16-bit PPG output operation mode (PPGC1: MD1, MD0=11B), set the reload registers using a long-word instruction or set the PPG0 and PPG1 in this order using a word instruction. • In 8+8-bit PPG output operation mode (PPGC1: MD1, MD0=01B), set both "L" level and "H" level sides of the PPG reload register (PRLL0/PRLH0) in the 8/16-bit PPG timer 0 to the same value. Setting a different value in "L" level and "H" level sides may cause the 8/16-bit PPG timer 1 to have a different PPG output wave form for each clock cycle. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 16.4 Interrupts of 8/16-bit PPG Timer CHAPTER 16 8/16-BIT PPG TIMER 16.4 Interrupts of 8/16-bit PPG Timer The 8/16-bit PPG timer can generate an interrupt request when an underflow of the PPG down counter occurs. It also supports the extended intelligent I/O service (EI2OS) and DMA transfer. ■ Interrupts of 8/16-bit PPG Timer Table 16.4-1 shows the interrupt control bits and interrupt sources of the 8/16-bit PPG timer. Table 16.4-1 Interrupt Control Bits of 8/16-bit PPG Timer PPGn PPGm Interrupt request flag bit PPGCn: PUF0 PPGCm: PUF1 Interrupt request enable bit PPGCn: PIE0 PPGCm: PIE1 Interrupt source Generation of PPGn down counter underflow Generation of PPGm down counter underflow Note: n = 0, 2, 4, 6, 8, A, C, E m=n+1 [8-bit PPG output 2-channel independent operation mode, 8+8-bit PPG output operation mode] • In 8-bit PPG output 2-channel independent operation mode or 8+8-bit PPG output operation mode, the PPGn and PPGm can generate an interrupt independently. • When the PPGn or PPGm down counter is counted down from 00H to FFH, an underflow occurs. When an underflow occurs, the underflow generation flag bit of the channel generating the underflow is set (PPGCn: PUF0=1 or PPGCm: PUF1=1). • If interrupt request of the channel that causes an underflow is enabled (PPGCn: PIE0=1 or PPGCm: PIE1=1), an interrupt request is generated. [16-bit PPG output operation mode] • In 16-bit PPG output operation mode, when the PPGn+PPGm down counter is counted down from 0000H to FFFFH, an underflow occurs. When an underflow occurs, the underflow generation flag bits of the two channels are set at the same time (PPGCn: PUF0=1 and PPGCm: PUF1=1). • An interrupt request is generated when an underflow occurs if interrupt request of either of the two channels is enabled (PPGCn: PIE1=0, PPGCm: PIE1=1 or PPGCn: PIE0=1, PPGCm: PIE1=0). • To prevent duplication of interrupt requests, disable the underflow interrupt enable bit of either of the two channels in advance (PPGCn: PIE0=0, PPGCm: PIE1=1 or PPGCn: PIE0=1, PPGCm: PIE1=0). • If the underflow generation flag bits of the two channels are set (PPGCn: PUF0=1 and PPGCm: PUF1=1), clear the two channels at the same time. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 355 CHAPTER 16 8/16-BIT PPG TIMER 16.4 Interrupts of 8/16-bit PPG Timer MB90860E Series ■ Interrupts of 8/16-bit PPG Timer For interrupt number, interrupt control register, and interrupt vector address, see "CHAPTER 3 INTERRUPTS". 356 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series 16.5 Operating Explanation of 8/16-bit PPG Timer The 8/16-bit PPG timer outputs a pulse width of any frequency and any duty ratio continuously. ■ Operation of 8/16-bit PPG Timer ● Output operation of 8/16-bit PPG timer • The 8/16-bit PPG timer has two ("L" level side and "H" level side) 8-bit reload registers (PRLLn/ PRLHn, PRLLm/PRLHm) for each channel. • The values set in the reload registers (PRLLn/PRLHn, PRLLm/PRLHm) are reloaded alternately into the PPG down counters (PCNTn, PCNTm). • After reloading the value into the PPG down counters, counting down starts in synchronization with the count clock set by the PPG count clock select bits (PPGnm: PCM2 to PCM0, PCS2 to PCS0). • If the values set in the reload registers are reloaded to the PPG down counters due to underflow, the pin output is inverted. Figure 16.5-1 shows the output wave form of 8/16-bit PPG timer. Figure 16.5-1 Output Wave Form of 8/16-bit PPG Timer Operation start Operation stop PPG operation enable bit (PEN) PPG output pin T × (L + 1) T × (H + 1) L : Value of PPG reload register (PRLL) H : Value of PPG reload register (PRLH) T : Count clock cycle ● Operation mode of 8/16-bit PPG timer While the operation of the 8/16-bit PPG timer is enabled (PPGCn: PEN0=1, PPGCm: PEN1=1), a pulse wave is output continuously from the PPG output pin. The pulse wave can be set to any frequency and duty ratio. The pulse output of the 8/16-bit PPG timer will not stop until operation of the 8/16-bit PPG timer is stopped (PPGCn: PEN0=0, PPGCm: PEN1=0). • 8-bit PPG output 2-channel independent operation mode • 16-bit PPG output operation mode • 8+8-bit PPG output operation mode Note: CM44-10144-4E n = 0, 2, 4, 6, 8, A, C, E m=n+1 FUJITSU SEMICONDUCTOR LIMITED 357 CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series 8-bit PPG Output 2-channel Independent Operation Mode 16.5.1 In 8-bit PPG output 2-channel independent operation mode, the 8/16-bit PPG timer is set as an 8-bit PPG timer with two independent channels. PPG output operation and interrupt request generation can be performed independently for each channel. ■ Setting for 8-bit PPG Output 2-channel Independent Operation Mode To operate in 8-bit PPG output 2-channel independent operation mode, the setting shown in Figure 16.5-2 is required. Figure 16.5-2 Setting for 8-bit PPG Output 2-channel Independent Operation Mode bit15 14 PPGCm/PPGCn PEN1 13 12 11 10 9 bit8 bit7 Re- PE1 PIE1 PUF1 MD1 MD0 served PEN0 1 0 0 1 6 5 4 3 2 PE0 PIE0 PUF0 1 1 bit0 Reserved 1 PPGnm (Reserved area) PRLHn/PRLLn Set PPGn "H" level side reload value Set PPGn "L" level side reload value PRLHm/PRLLm Set PPGm "H" level side reload value Set PPGm "L" level side reload value PCS2PCS1 PCS0 PCM2PCM1 PCM0 REV : Used bit − : Undefined bit 1 : Set to "1" 0 : Set to "0" Note: Note: 358 n = 0, 2, 4, 6, 8, A, C, E m=n+1 Set both "H" level side and "L" level side of the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) at the same time using a word instruction. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer ● Operation in 8-bit PPG output 2-channel independent operation mode • The 8-bit PPG timer with two channels performs an independent PPG operation in each channel. • When pin output is enabled (PPGCn:PE0=1, PPGCm:PE1=1), a PPGn pulse wave is output from the PPGn pin and a PPGm pulse wave is output from the PPGm pin if the PPG output pin selection is set to standard (PPGnm:REV=0). If PPG output pin switching is set (PPGnm:REV=1), a PPGm pulse wave is output from the PPGn pin and a PPGn pulse wave is output from the PPGm pin. • When the reload value is set in the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) to enable the operation of the PPG timer (PPGCn: PEN0=1, PPGCm: PEN1=1), the PPG down counter of the enabled channel starts counting. • To stop the count operation of the PPG down counter, disable the operation of the PPG timer of the channel to be stopped (PPGCn: PEN0=0, PPGCm: PEN1=0). The count operation of the PPG down counter is stopped and the output of the PPG output pin is held at "L" level. • When the PPG down counter of one channel generates an underflow, the reload values set in the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) are reloaded into the PPG down counter in which the underflow occurs. • When an underflow occurs, the underflow generation flag bit in the channel that causes the underflow is set (PPGCn: PUF0=1, PPGCm: PUF1=1). If interrupt request is enabled at the channel that causes the underflow (PPGCn: PIE0=1, PPGCm: PIE1=1), an interrupt request is generated. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 359 CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series ● Output wave form in 8-bit PPG output 2-channel independent operation mode • Both the "L" and "H" pulse widths to be output are determined by adding 1 to the values of the PPG reload register of each channel and multiplying them by the count clock cycle. For example, if the value of the PPG reload register is 00H, the pulse width becomes one cycle of the count clock, and if the value is FFH, the pulse width becomes 256 cycles of the count clock. The calculation formulas for pulse width are given below: PL=T × (L+1) PH=T × (H+1) PL : "L" width of output pulse PH : "H" width of output pulse L : 8-bit value of PPG reload register (PRLLn or PRLLm) H : 8-bit value of PPG reload register (PRLHn or PRLHm) T : Count clock cycle Figure 16.5-3 shows the output wave form in 8-bit PPG output 2-channel independent operation mode. Figure 16.5-3 Output Wave Form in 8-bit PPG Output 2-channel Independent Operation Mode Operation start Operation stop PPG operation enable bit (PEN) PPG output pin T × (L + 1) T × (H + 1) L : Value of PPG reload register (PRLL) H : Value of PPG reload register (PRLH) T : Count clock cycle Note: 360 n = 0, 2, 4, 6, 8, A, C, E m=n+1 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series 16.5.2 16-bit PPG Output Operation Mode In 16-bit PPG output operation mode, the 8/16-bit PPG timer is set as a 16-bit PPG timer with one channel. ■ Setting for 16-bit PPG Output Operation Mode To operate in 16-bit PPG output operation mode, the setting shown in Figure 16.5-4 is required. Figure 16.5-4 Setting for 16-bit PPG Output Operation Mode bit15 14 PPGCm/PPGCn PEN1 1 13 12 11 10 9 PE1 PIE1 PUF1 MD1 MD0 1 1 bit8 bit7 Reserved PEN0 1 6 5 4 3 2 PE0 PIE0 PUF0 1 1 bit0 Reserved 1 PPGnm (Reserved area) PRLHn/PRLLn Set lower 8 bits of PPGn "H" level side reload value PRLHm/PRLLm Set upper 8 bits of PPGm "H" level side reload value Set upper 8 bits of PPGm "L" level side reload value × − 1 0 PCS2 PCS1 PCS0 PCM2 PCM1 PCM0 REV Set lower 8 bits of PPGn "L" level side reload value : Used bit : Unused bit : Undefined bit : Set to "1" : Set to "0" Note: Note: CM44-10144-4E n = 0, 2, 4, 6, 8, A, C, E m=n+1 Set values in the PPG reload registers using a long-word instruction or set the PPGn and PPGm (PRLLn → PRLLm, PRLHn → PRLHm) in this order using a word instruction. FUJITSU SEMICONDUCTOR LIMITED 361 CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series ● Operation in 16-bit PPG Output Operation Mode • When pin output of either PPGn pin or PPGm pin is enabled (PPGCn:PE0=1, PPGCm: PE1=1), a pulse wave of the same wave form is output from both the PPGn and PPGm pins. • When the reload value is set in the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) to enable operation of the PPG timers (PPGCn:PEN0=1 and PPGCm: PEN1=1) simultaneously, the PPG down counters start counting as a 16-bit down counter (PCNTn + PCNTm). • To stop the count operation of the PPG down counters, disable the operation of the PPG timers of both channels (PPGCn: PEN0=0 and PPGCm: PEN1=0) simultaneously. The count operation of the PPG down counters is stopped and the output of the PPG output pin is held at "L" level. • If the PPGm down counter generates an underflow, the reload values set in the PPGn and PPGm reload registers (PRLLn/PRLHn, PRLLm/PRLHm) are reloaded into the PPG down counter (PCNTn + PCNTm) simultaneously. • When an underflow occurs, the underflow generation flag bits in both channels are set simultaneously (PPGCn:PUF0=1, PPGCm:PUF1=1). If interrupt request is enabled at either channel (PPGCn: PIE0=1, PPGCm: PIE1=1), an interrupt request is generated. Notes: • In 16-bit PPG output operation mode, the underflow generation flag bits in the two channels are set simultaneously (PPGCn:PUF0=1 and PPGCm:PUF1=1) when an underflow occurs. To prevent duplication of interrupt requests, disable either of the underflow interrupt enable bits in the two channels (PPGCn:PIE0=0, PPGCm:PIE1=1 or PPGCn:PIE0=1, PPGCm:PIE1=0). • If underflow generation flag bits are set, clear the two channels at the same time (PPGCn: PUF0=0 and PPGCm: PUF1=0). The value of "m" and "n" is as follows. n = 0, 2, 4, 6, 8, A, C, E m=n+1 362 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series ● Output wave form in 16-bit PPG output operation mode • Both the "L" and "H" pulse widths to be output are determined by adding 1 to the values of the PPG reload register of each channel and multiplying them by the count clock cycle. For example, if the value of the PPG reload register is 0000H, the pulse width becomes one cycle of the count clock, and if the value is FFFFH, the pulse width becomes 65,536 cycles of the count clock. The calculation formulas for pulse width are given below: PL=T × (L+1) PH=T × (H+1) PL : "L" width of output pulse PH : "H" width of output pulse L : 16-bit value of PPG reload register (PRLLn+PRLLm) H : 16-bit value of PPG reload register (PRLHn+PRLHm) T : Count clock cycle Figure 16.5-5 shows the output wave form in 16-bit PPG output operation mode. Figure 16.5-5 Output Wave Form in 16-bit PPG Output Operation Mode Operation start Operation stop PPG operation enable bit (PEN) PPG output pin T × (L + 1) T × (H + 1) L : 16-bit value of PPG reload register (PRLLm+PRLLn) H : 16-bit value of PPG reload register (PRLHm+PRLHn) T : Count clock cycle Note: n = 0, 2, 4, 6, 8, A, C, E m=n+1 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 363 CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer 16.5.3 MB90860E Series 8+8-bit PPG Output Operation Mode In 8+8-bit PPG output operation mode, the 8/16-bit PPG timer is set as an 8-bit PPG timer in which PPG0 operates as an 8-bit prescaler and PPG1 operates using PPG output of the PPG0 as a clock source. ■ Setting for 8+8-bit PPG Output Operation Mode To operate in the 8+8-bit PPG output operation mode, the setting shown in Figure 16.5-6 is required. Figure 16.5-6 Setting for 8+8-bit PPG Output Operation Mode bit15 14 PPGCm/PPGCn PEN1 1 PPGnm 11 10 9 PE1 PIE1 PUF1 MD1 MD0 0 1 bit8 bit7 Reserved PEN0 1 (Reserved area) 6 5 4 3 2 PE0 PIE0 PUF0 1 PCS2 PCS1 PCS0 PCM2 PCM1 PCM0 1 bit0 Reserved 1 REV Set PPGn "H" level side reload value Set PPGn "L" level side reload value PRLHm/PRLLm Set PPGm "H" level side reload value Set PPGm "L" level side reload value : Used bit : Unused bit : Undefined bit : Set to "1" : Set to "0" Note: 364 12 PRLHn/PRLLn × − 1 0 Note: 13 n = 0, 2, 4, 6, 8, A, C, E m=n+1 Set both "H" level side and "L" level side of the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) at the same time using a word instruction. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series ● Operation in 8+8-bit PPG output operation mode • The PPGn operates as the prescaler of the PPGm timer and the PPGm operates using the PPGn output as a count clock. • When pin output is enabled (PPGCn: PE0=1, PPGCm: PE1=1), a PPGn pulse wave is output from the PPGn pin and a PPGm pulse wave is output from the PPGm pin if the PPG output pin selection is set to standard (PPGnm: REV=0). If PPG output pin switching is set (PPGnm: REV=1), the output pins of PPGn and PPGm will be switched. • When the reload value is set in the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) to enable operation of the PPG timer (PPGCn:PEN0=1 and PPGCm: PEN1=1), the PPG down counter starts counting. • To stop the count operation of the PPG down counter, disable the operation of the PPG timers of both channels (PPGCn: PEN0=0 and PPGCm: PEN1=0) at the same time. The count operation of the PPG down counter is stopped and the output of the PPG output pin is held at "L" level. • When the PPG down counter of one channel generates an underflow, the reload values set in the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) are reloaded into the PPG down counter in which the underflow occurs. • When an underflow occurs, the underflow generation flag bit in the channel that causes the underflow is set (PPGCn:PUF0=1, PPGCm:PUF1=1). If interrupt request is enabled at the channel that causes the underflow (PPGCn: PIE0=1, PPGCm: PIE1=1), an interrupt request is generated. Notes: • Do not operate PPGm (PPGCm:PEN1=1) when PPGn is stopped (PPGCn:PEN0=0). • It is recommended to set both "L" level and "H" level sides of the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) to the same value. The value of "m" and "n" is as follows. n = 0, 2, 4, 6, 8, A, C, E m=n+1 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 365 CHAPTER 16 8/16-BIT PPG TIMER 16.5 Operating Explanation of 8/16-bit PPG Timer MB90860E Series ● Output wave form in 8+8-bit PPG output operation mode • Both the "L" and "H" pulse widths to be output are determined by adding 1 to the values of the PPG reload register of each channel and multiplying them by the count clock cycle. The calculation formulas for pulse width are given below: PL=T × (Ln+1) × (Lm+1) PH=T × (Hn+1) × (Hm+1) PL : "L" width of output pulse from PPGm pin PH : "H" width of output pulse from PPGm pin Ln : 8-bit value of PPG reload register (PRLLn) Hn : 8-bit value of PPG reload register (PRLHn) Lm : 8-bit value of PPG reload register (PRLLm) Hm : 8-bit value of PPG reload register (PRLHm) T : Count clock cycle Figure 16.5-7 shows the output wave form in 8+8-bit PPG output operation mode. Figure 16.5-7 Output Wave Form in 8+8-bit PPG Output Operation Mode Operation disable Operation start PPG operation enable bit (PEN0, PEN1) T × (L 0 + 1) T × (H 0 + 1) PPGn output pin PPGm output pin T × (L0 + 1) × (L1+ 1) Ln Hn Lm Hm T : 8-bit value of PPG reload register (PRLLn) : 8-bit value of PPG reload register (PRLHn) : 8-bit value of PPG reload register (PRLLm) : 8-bit value of PPG reload register (PRLHm) : Count clock cycle Note: 366 T × (H 0 + 1) × (H 1 + 1) n = 0, 2, 4, 6, 8, A, C, E m=n+1 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 16.6 Notes on Using 8/16-bit PPG Timer CHAPTER 16 8/16-BIT PPG TIMER 16.6 Notes on Using 8/16-bit PPG Timer Note the following when using the 8/16-bit PPG timer. ■ Notes on Using 8/16-bit PPG Timer ● Effect on 8/16-bit PPG timer when using time-base timer output • If output of the time-base timer is used as count clock input of the 8/16-bit PPG timer (PPGnm: PCM2 to PCM0=111B, PCS2 to PCS0=111B), deviation may occur in the first count cycle in which the PPG timer is started by trigger input or in the count cycle immediately after the PPG timer is stopped. • When the time-base timer counter is cleared (TBTC:TBR=0) during count operation of the PPG down counter, deviation may occur in the count cycle. ● Setting of PPG reload registers when using 8-bit PPG timer • The "L" level side and "H" level side pulse widths are determined at the timing of reloading the values in the "L" level PPG reload registers (PRLLn, PRLLm) into the PPG down counter. • If the 8-bit PPG timer is used in 8-bit PPG output 2-channel independent operation mode or 8+8-bit PPG output operation mode, set both "H" level side and "L" level side of the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) at the same time using a word instruction. Using a byte instruction may cause an unexpected pulse to be generated. [Example of rewriting PPG reload registers using a byte instruction] If the value in the "H" level side PPG reload register (PRLH) is rewritten after the value in the "L" level side PPG reload register (PRLL) is rewritten using a byte instruction immediately before the signal level of the PPG pin switches from "H" to "L", a pulse having "L" width set after rewriting and "H" width set before rewriting will be generated just one time. Figure 16.6-1 shows a wave form of when the values in the PPG reload registers are rewritten using a byte instruction. Note: CM44-10144-4E n = 0, 2, 4, 6, 8, A, C, E m=n+1 FUJITSU SEMICONDUCTOR LIMITED 367 CHAPTER 16 8/16-BIT PPG TIMER 16.6 Notes on Using 8/16-bit PPG Timer MB90860E Series Figure 16.6-1 Wave Form of When PPG Reload Registers Are Rewritten Using a Byte Instruction PRLL A PRLH B C D A +B A +B B +C C+D B B C+D C+D D D Timing of updating reload value PPG pin A B A C C C <1> <2> <1>: Change the value (A→ C) of PPG reload register (PRLL) <2>: Change the value (B → D) of PPG reload register (PRLH) ● Setting of PPG reload registers when using 16-bit PPG timer • Set the PPG reload registers (PRLLn/PRLHn, PRLLm/PRLHm) using a long-word instruction or set PPGn → PPGm (PRLLn/PRLHn → PRLLm/PRLHm) in this order using a word instruction. [Reload timing in 16-bit PPG output operation mode] In 16-bit PPG output operation mode, the reload values written to the PPGn reload register are written temporarily to the temporary latch and then transferred to the PPGn reload register (PRLLn, PRLHn) after reload values are written to the PPGm reload register. Therefore, when setting PPGm reload values, it is necessary to set reload values in the PPGn reload register simultaneously or set reload values in the PPGn reload register before setting reload values in the PPGm reload register. Figure 16.6-2 shows the reload timing in 16-bit PPG output operation mode. Figure 16.6-2 Reload Timing in 16-bit PPG Output Operation Mode Reload value of PPGn Write to PPGn in any mode other than 16-bit PPG output operation mode 16-bit PPG output operation mode only Temporary latch 368 Write to PPGm Transfer in synchronization with writing to PPGm PPG reload register (PRLLn, PRLHn) Note: Reload value of PPGm PPG reload register (PRLLm, PRLHm) n = 0, 2, 4, 6, 8, A, C, E m=n+1 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT This chapter explains the functions and operations of the DTP/external interrupt. 17.1 Overview of DTP/External Interrupt 17.2 Block Diagram of DTP/External Interrupt 17.3 Configuration of DTP/External Interrupt 17.4 Explanation of Operation of DTP/External Interrupt 17.5 Notes on Using DTP/External Interrupt 17.6 Program Example of DTP/External Interrupt Function CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 369 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.1 Overview of DTP/External Interrupt 17.1 MB90860E Series Overview of DTP/External Interrupt The DTP/external interrupt sends interrupt requests from external peripheral devices or data transfer requests to CPU to generate an external interrupt request, or activates the DMA extended intelligent I/O service (EI2OS). ■ DTP/External Interrupt Function The DTP/external interrupt follows the same procedure as resource interrupts to send interrupt requests from external peripheral devices to the CPU to generate an external interrupt request, or activates the DMA extended intelligent I/O service (EI2OS). If the extended intelligent I/O service (EI2OS) is disabled in the interrupt control register (ICR:ISE=0) and the DMA transfer is disabled in the DMA enable register (DER:EN=0), the external interrupt function is enabled, branching to interrupt processing. If the DMA or the EI2OS is enabled, the DTP function is enabled and automatic data transfer is performed, branching to interrupt processing after the completion of data transfer for the specified number of times. Table 17.1-1 shows an overview of the DTP/external interrupt. Table 17.1-1 Overview of DTP/External Interrupt External Interrupt Input pin DTP Function 16 pins: INT0 to INT7, INT8 to INT15 (INT8R to INT15R) Set for each pin using the detection level setting registers (ELVR). Interrupt source Input of "H" level/"L" level Interrupt number #26(1AH), #28(1CH) Interrupt control The interrupt request output is enabled/disabled using the DTP/external interrupt enable register (ENIR) Interrupt flag The interrupt source is held using the DTP/external interrupt source register (EIRR) Processing selection DMA and EI2OS is disabled. (DER:EN=0 and ICR: ISE=0) DMA and EI2OS is enabled. (DER:EN=1 and ICR: ISE=1) A branch is caused to the external interrupt processing routine DMA or EI2OS performs automatic data transfer and completes the specified number of time for data transfers, causing a branch to the interrupt processing Process 370 Input of "H" level/"L" level/rising edge/ falling edge FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.2 Block Diagram of DTP/External Interrupt MB90860E Series 17.2 Block Diagram of DTP/External Interrupt A block diagram of the DTP/external interrupt is shown below. ■ Block Diagram of DTP/External Interrupt Figure 17.2-1 Block Diagram of DTP/External Interrupt Detection level setting register (ELVR0) LB7 LA7 LB6 LA6 LB5 LA5 LB4 LA4 Pin Level edge selector INT7 Pin Level edge selector Internal data bus Level edge selector Pin Level edge selector INT2 Level edge selector INT5 Pin Pin INT3 INT6 Pin LB3 LA3 LB2 LA2 LB1 LA1 LB0 LA0 Pin Level edge selector INT1 Level edge selector INT4 Pin Level edge selector INT0 DTP/external interrupt input detection circuit ER7 ER6 ER5 ER4 ER3 ER2 ER1 ER0 Interrupt request signal DTP/external interrupt source register (EIRR0) Interrupt request signal EN7 EN6 EN5 EN4 EN3 EN2 EN1 EN0 DTP/external interrupt enable register (ENIR0) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 371 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.2 Block Diagram of DTP/External Interrupt MB90860E Series Figure 17.2-2 Block Diagram of DTP/External Interrupt Detection level setting register (ELVR1) LB15 LA15 LB14 LA14 LB13 LA13 LB12 LA12 Pin Level edge selector INT15 Pin Level edge selector Internal data bus Level edge selector Pin Level edge selector INT10 Level edge selector INT13 Pin Pin INT11 INT14 Pin LB11 LA11 LB10 LA10 LB9 LA9 LB8 LA8 Pin Level edge selector INT9 Level edge selector INT12 Pin Level edge selector INT8 DTP/external interrupt input detection circuit ER15 ER14 ER13 ER12 ER11 ER10 ER9 ER8 Interrupt request signal DTP/external interrupt source register (EIRR1) Interrupt request signal EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 DTP/external interrupt enable register (ENIR1) ● DTP/external interrupt input detection circuit This circuit detects interrupt requests or data transfer requests generated from external peripheral devices. The interrupt request flag bit corresponding to the pin whose level or edge set by the detection level setting register is detected is set to "1" (EIRR1:ER). 372 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.2 Block Diagram of DTP/External Interrupt MB90860E Series ● Detection level setting register (ELVR0/ELVR1) This register sets the level or edge of input signals from external peripheral devices that cause DTP/external interrupt source. ● DTP/external interrupt source register (EIRR0/EIRR1) This register holds DTP/external interrupt sources. If a valid signal is input to the DTP/external interrupt pin, the corresponding DTP/external interrupt request flag bit is set to "1". ● DTP/external interrupt enable register (ENIR0/ENIR1) This register enables or disables DTP/external interrupt requests from external peripheral devices. ■ Details of Pins and Interrupt Numbers Table 17.2-1 shows the pins and interrupt numbers used in the DTP/external interrupt. Table 17.2-1 Pins and Interrupt Numbers Used by DTP/External Interrupt Pin Channel P70 INT0 P71 INT1 P72 INT2 P73 INT3 P74 INT4 P75 INT5 P76 INT6 P77 INT7 P00 / PA0 INT8 / INT8R P01 / P42 INT9 / INT9R P02 / P32 INT10 / INT10R P03 / P12 INT11 / INT11R P04 / P80 INT12 / INT12R P05 / P81 INT13 / INT13R P06 / P82 INT14 / INT14R P07 / P84 INT15 / INT15R Interrupt Number DMA Number #26(1AH) 3 #28(1CH) 4 #26(1AH) 3 #28(1CH) 4 INT8 to INT15 / INT8R to INT15R are selected in the external interrupt source select register (EISSR). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 373 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt 17.3 MB90860E Series Configuration of DTP/External Interrupt This section lists and details the pins, interrupt sources, and registers in the DTP/ external interrupt. ■ Pins of DTP/External Interrupt The pins used by the DTP/external interrupt serve as general-purpose I/O ports. Table 17.3-1 lists the pin functions and the pin setting required for use in the DTP/external interrupt. Table 17.3-1 Pins of DTP/External Interrupt (1 / 2) Pin Name Pin Function Pin Settings Required for Use in DTP/External Interrupt P70/INT0/AN16 P71/INT1/AN17 P72/INT2/AN18 P73/INT3/AN19 P74/INT4/AN20 General-purpose I/O ports / DTP external interrupt inputs / A/D converter analog input • Set as input ports in port direction register (DDR7) • Set the analog input enable register (ADER7) as disabled General-purpose I/O ports / DTP external interrupt inputs / Address data bus lower I/O • Set the external interrupt source select register (EISSR) to 0 • Set as input ports in port direction register (DDR0) Note: Available only in the single-chip mode P75/INT5/AN21 P76/INT6/AN22 P77/INT7/AN23 P00/INT8/AD00 P01/INT9/AD01 P02/INT10/AD02 P03/INT11/AD03 P04/INT12/AD04 P05/INT13/AD05 P06/INT14/AD06 P07/INT15/AD07 374 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series Table 17.3-1 Pins of DTP/External Interrupt (2 / 2) Pin Name Pin Function PA0/ INT8R General-purpose I/O ports / DTP external interrupt inputs P42/ INT9R/ IN6 General-purpose I/O ports / DTP external interrupt inputs / Input capture input IN6 P32/ INT10R/ WR1/WR General-purpose I/O ports / DTP external interrupt inputs / Write strobe outputs P12/ INT11R/ AD10/ SIN3 General-purpose I/O ports / DTP external interrupt inputs / Address data bus upper I/O UART3 input SIN3 P80/ INT12R/ TIN0/ ADTG General-purpose I/O ports / DTP external interrupt inputs / Reload timer 0 trigger input TIN0 / A/D converter trigger input ADTG P81/ INT13R/ TOT0/ CKOT General-purpose I/O ports / DTP external interrupt inputs / Reload timer 0 output TOT0 / Clock monitor output CKOT P82/ INT14R/ SIN0/ TIN2 General-purpose I/O ports / DTP external interrupt inputs / UART0 input SIN0 / Reload timer 2 trigger input TIN2 P84/ INT15R/ SCK0 General-purpose I/O ports / DTP external interrupt inputs / UART0 clock I/O SCK0 CM44-10144-4E Pin Settings Required for Use in DTP/External Interrupt • Set the external interrupt source select register (EISSR) to 1 • Set as input ports in port direction register (DDR) • Set the external interrupt source select register (EISSR) to 1 • Set as input ports in port direction register (DDR) • Set the timer control status register (TMCSR0:OUTE) as disabled • Set the clock output enable register (CLKR:CKEN) as disabled • Set the external interrupt source select register (EISSR) to 1 • Set as input ports in port direction register (DDR) FUJITSU SEMICONDUCTOR LIMITED 375 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series ■ List of Registers and Reset Values in DTP/External Interrupt Figure 17.3-1 List of Registers and Reset Values in DTP/External Interrupt 7 6 5 4 3 2 1 0 Initial value EN7 EN6 EN5 EN4 EN3 EN2 EN1 EN0 00000000 B 7 6 5 4 3 2 1 0 EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 15 14 13 12 11 10 9 8 Address: 0000C7H ER7 ER6 ER5 ER4 ER3 ER2 ER1 ER0 bit EIRR1 Address: 0000CB H 15 14 13 12 11 10 9 8 ER15 ER14 ER13 ER12 ER11 ER10 ER9 ER8 7 6 5 4 3 2 1 0 LB3 LA3 LB2 LA2 LB1 LA1 LB0 LA0 15 14 13 12 11 10 9 8 LB7 LA7 LB6 LA6 LB5 LA5 LB4 LA4 7 6 5 4 3 2 1 0 LB11 LA11 LB10 LA10 LB9 LA9 LB8 LA8 15 14 13 12 11 10 9 8 LB15 LA15 LB14 LA14 LB13 LA13 LB12 LA12 7 6 5 4 3 2 1 0 ENIR0 bit Address: 0000C6 H ENIR1 bit Address: 0000CA H EIRR0 ELVR0 bit bit Address: 0000C8 H ELVR0 bit Address: 0000C9 H ELVR1 bit Address: 0000CCH ELVR1 bit Address: 0000CDH EISSR bit Address: 0000CE H INT15R INT14R INT13R INT12R INT11R INT10R INT9R INT8R 376 FUJITSU SEMICONDUCTOR LIMITED 00000000 B XXXXXXXXB XXXXXXXXB 00000000 B 00000000B 00000000B 00000000B 00000000B CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series 17.3.1 DTP/External Interrupt Source Register (EIRR0/EIRR1) This register holds DTP/external interrupt sources. If a valid signal is input to the DTP/external interrupt pin, the corresponding interrupt request flag bit is set to "1". EIRR0 corresponds to INT0 to INT7, and EIRR1 corresponds to INT8 to INT15/INT8R to INT15R. ■ DTP/External Interrupt Source Register (EIRR0/EIRR1) Figure 17.3-2 DTP/External Interrupt Source Register (EIRR0/EIRR1) Address EIRR0: 0000C7H 15 14 13 12 11 10 9 8 ER7 ER6 ER5 ER4 ER3 ER2 ER1 ER0 R/W R/W R/W R/W R/W R/W R/W R/W Initial value: XXXXXXXB bit15 to bit8 ER7 to ER0 0 1 Address EIRR1: 0000CBH 15 14 13 12 11 10 9 R/W R/W R/W R/W R/W R/W R/W R/W Writing Clear of ER bit No effect Initial value: XXXXXXXB bit15 to bit8 ER15 to ER8 CM44-10144-4E Reading No DTP/external interrupt input DTP/external interrupt input 8 ER15 ER14 ER13 ER12 ER11 ER10 ER9 ER8 R/W: Readable/writable X : Undefined DTP/External interrupt request flag bit 0 1 DTP/External interrupt request flag bit Reading No DTP/external interrupt input DTP/external interrupt input FUJITSU SEMICONDUCTOR LIMITED Writing Clear of ER bit No effect 377 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series Table 17.3-2 Function of DTP/External Interrupt Source Register (EIRR) Bit name bit15 to bit8, bit7 to bit0 Notes: 378 Function ER15 to ER8(EIRR1), ER7 to ER0(EIRR0): DTP/External interrupt request flag bits These bits are set to "1" when the edges or level signals set by the detection condition select bits in the detection level setting register (ELVR1:LB, LA) are input to the DTP/external interrupt pins. When set to "1": When the DTP/external interrupt request enable bit (ENIR1:EN) is set to "1", an interrupt request is generated to the corresponding DTP/external interrupt channel. When set to "0": Cleared. When set to "1": No effect. Note: For a read-modify-write (RMW) instruction, "1" is always read. If more than one DTP/external interrupt request is enabled (ENIR1:EN=1), clear only the bit in the channel that accepts an interrupt (EIRR1:ER=0). No other bits must be cleared unconditionally. Reference: When the DMA transfer or extended intelligent I/O service (EI2OS) is activated, the interrupt request flag bit is automatically cleared after the completion of data transfer (EIRR1:ER=0). • The value of the DTP/external interrupt source bit (EIRR:ER) is enabled only when the corresponding DTP/external interrupt enable bit is set to "1". If the DTP/external interrupt is not enabled (ENIR:EN=0), DTP/external interrupt source bit may be set regardless of the existence of DTP/external interrupt source. • Clear the corresponding DTP/external interrupt source bit (EIRR:ER) just before enabling the DTP/external interrupt (ENIR:EN=1). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series 17.3.2 DTP/External Interrupt Enable Register (ENIR0/ENIR1) The DTP/external interrupt enable register (ENIR0/ENIR1) enables/disables the DTP/ external interrupt request in the external peripheral devices. ENIR0 corresponds to INT0 to INT7, and ENIR1 corresponds to INT8 to INT15/INT8R to INT15R. ■ DTP/External Interrupt Enable Register (ENIR0/ENIR1) Figure 17.3-3 DTP/External Interrupt Enable Register (ENIR0/ENIR1) 7 Address ENIR0: 0000C6H 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 Initial value: 00000000B bit7 to bit0 EN7 to EN0 0 1 7 Address ENIR1: 0000CAH 6 5 4 3 2 1 0 EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 R/W R/W R/W R/W R/W R/W R/W R/W Initial value: 00000000B bit7 to bit0 EN15 to EN8 0 1 R/W : Readable/writable : Initial value DTP/external interrupt request enable bit DTP/external interrupt disable DTP/external interrupt enable DTP/external interrupt request enable bit DTP/external interrupt disable DTP/external interrupt enable Table 17.3-3 Functions of DTP/External Interrupt Enable Register (ENIR0/1) Bit name bit7 to bit0 Note: CM44-10144-4E Function EN15 to EN8(ENIR1), EN7 to EN0(ENIR0): DTP/external interrupt request enable bit These bits enable or disable the DTP/external interrupt request to the DTP/external interrupt channel. If the DTP/external interrupt request enable bit (ENIR1:EN) and the DTP/external interrupt request flag bit (EIRR1:ER) are set to "1", the interrupt request is generated to the corresponding DTP/ external interrupt pin. Reference: The state of the DTP/external interrupt pin can be read directly using the port data register irrespective of the setting of the DTP/ external interrupt request enable bit. Clear the corresponding DTP/external interrupt source bit (EIRR:ER) just before enabling the DTP/external interrupt (ENIR:EN=1). FUJITSU SEMICONDUCTOR LIMITED 379 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series Table 17.3-4 Correspondence Among DTP/External Interrupt Pins, DTP/External Interrupt Request Flag Bits, and DTP/External Interrupt Request Enable Bits 380 DTP/external interrupt pin DTP/external interrupt request flag bit DTP/external interrupt request enable bit INT0 ER0 EN0 INT1 ER1 EN1 INT2 ER2 EN2 INT3 ER3 EN3 INT4 ER4 EN4 INT5 ER5 EN5 INT6 ER6 EN6 INT7 ER7 EN7 INT8 / INT8R ER8 EN8 INT9 / INT9R ER9 EN9 INT10 / INT10R ER10 EN10 INT11 / INT11R ER11 EN11 INT12 / INT12R ER12 EN12 INT13 / INT13R ER13 EN13 INT14 / INT14R ER14 EN14 INT15 / INT15R ER15 EN15 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series 17.3.3 Detection Level Setting Register (ELVR0/ELVR1) The detection level setting register sets the level or edge of input signals that cause the interrupt sources of the DTP/external interrupt pin. ELVR0 corresponds to INT0 to INT7, and ELVR1 corresponds to INT8 to INT15/INT8R to INT15R. ■ Detection Level Setting Register (ELVR0/ELVR1) Figure 17.3-4 Detection Level Setting Register (ELVR0/ELVR1) Address ELVR0: 0000C8B 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Initial value LB7 LA7 LB6 LA6 LB5 LA5 LB4 LA4 LB3 LA3 LB2 LA2 LB1 LA1 LB0 LA0 0000000000000000B 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 bit15 to bit0 LB7, LA7, LB6, LA6, LB5, LA5, LB4, LA4, LB3, LA3, LB2, LA2, LB1, LA1, LB0, LA0 0 0 0 1 1 0 1 Address ELVR1: 0000CCB 15 14 13 12 11 10 9 8 7 6 5 4 3 1 2 1 Detection condition select bit "L" level detection "H" level detection Rising edge detection Falling edge detection 0 Initial value LB15 LA15 LB14 LA14 LB13 LA13 LB12 LA12 LB11 LA11 LB10 LA10 LB9 LA9 LB8 LA8 0000000000000000B 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 bit15 to bit0 LB15, LA15, LB14, LA14, LB13, LA13, LB12, LA12, LB11, LA11, LB10, LA10, LB9, LA9, LB8, LA8 0 0 0 1 1 0 R/W : Readable/writable : Initial value 1 1 Detection condition select bit "L" level detection "H" level detection Rising edge detection Falling edge detection Table 17.3-5 Functions of Detection Level Setting Register (ELVR0/1) Bit name bit15 to bit0 Function ELVR1… LB15, LA15 to LB8, LA8 ELVR0… LB7, LA7 to LB0, LA0 Detection condition select bits CM44-10144-4E These bits set the levels or edges of input signals from external peripheral devices that cause interrupt sources in the DTP/external interrupt pins. • Two levels or two edges are selectable for external interrupts, and two levels are selectable for DMA or EI2OS. Reference: When the set detection signal is input to the DTP/external interrupt pins, the DTP/external interrupt request flag bits are set to "1" even if DTP/external interrupt requests are disabled (ENIR1:EN=0). FUJITSU SEMICONDUCTOR LIMITED 381 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt Notes: MB90860E Series • If any setting of this register is changed, the interrupt source flag can be set. Therefore, If you want to change the setting of this register, disable the interrupt (or, set the corresponding bit of ENIR0/ENIR1 to "0") in advance. To enable the interrupt (or, set the corresponding bit of ENIR0/ENIR1 to "1") after the setting of this register is changed, be sure to clear the interrupt source flag bit (the corresponding bit of EIRR0/EIRR1). • When the DTP/external interrupt is disabled (ENIR:EN=0) in the stop/watch/time-base timer mode, the input is masked and the "L" level will be sent inwardly if CMOS/Automotive is selected and the "H" level will be sent inwardly if TTL is selected. If the sent level matches the detection level setting, interrupt source flag bit will be set. Table 17.3-6 Correspondence Between Detection Level Setting Register and Channels DTP/External Interrupt Pin Register Name Bit name INT0 LB0, LA0 INT1 LB1, LA1 INT2 LB2, LA2 INT3 LB3, LA3 ELVR0 INT4 LB4, LA4 INT5 LB5, LA5 INT6 LB6, LA6 INT7 LB7, LA7 INT8 / INT8R LB8, LA8 INT9 / INT9R LB9, LA9 INT10 / INT10R LB10, LA10 INT11 / INT11R LB11, LA11 ELVR1 382 INT12 / INT12R LB12, LA12 INT13 / INT13R LB13, LA13 INT14 / INT14R LB14, LA14 INT15 / INT15R LB15, LA15 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series 17.3.4 External Interrupt Source Select Register (EISSR) This register can change the assignment of the external interrupt pin of upper 8 bits. This allows the external interrupt of upper 8-bits when the external bus is used. ■ Selection of External Interrupt Source The external interrupt pin of the upper 8-bit is normally assigned to INT15 to INT8, and shares the port 0/ external bus and pin. In the external bus mode, the port 0 cannot be used as the external interrupt pin. However, those external interrupt can be used by assigning them to other pins (INT15R to INT8R). The pin is switched by the external interrupt source select register (EISSR). See Table 17.3-8 for the pin function of INT15R to INT8R. Figure 17.3-5 DTP/External Interrupt Source Select Register (EISSR) 7 6 5 4 3 2 1 0 Address EISSR: 0000CEH INT15R INT14R INT13R INT12R INT11R INT10R INT9R INT8R Initial value: 00000000B R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/writable X : Undefined : Initial value bit7 to bit0 INT15R to INT8R External Interrupt Source Select Bit 0 1 Set pins INT15 to INT8 as external interrupt source Set pins INT15R to INT8R as external interrupt source * See Table 17.3-8 for the pin assignment of INT15R to INT8R. Table 17.3-7 Function of DTP/External Interrupt Source Register (EIRR) Bit name bit7 to bit0 CM44-10144-4E Function INT15R to INT8R: External interrupt source select bits When these bits are set to "1", the input pin of the corresponding external interrupt source (upper 8-bit) is assigned to the INT15R to INT8R. When set to "0": The external interrupt source of the upper 8-bit is assigned to INT15 to INT8 pins. When set to "1": The external interrupt source of the upper 8-bit is assigned to the INT15R to INT8R pins. FUJITSU SEMICONDUCTOR LIMITED 383 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.3 Configuration of DTP/External Interrupt MB90860E Series Table 17.3-8 External Interrupt Source Select (Upper 8-bit) 384 EISSR Bit "0" (Initial Value) INT8R INT8 : P00 INT8R : PA0 INT9R INT9 : P01 INT9R : P42 (IN6) INT10R INT10: P02 INT10R: P32 INT11R INT11: P03 INT11R: P12 (SIN3) INT12R INT12: P04 INT12R: P80 (TIN0/ADTG) INT13R INT13: P05 INT13R: P81 (TOT0/CKOT) INT14R INT14: P06 INT14R: P82 (SIN0/TIN2) INT15R INT15: P07 INT15R: P84 (SCK0) FUJITSU SEMICONDUCTOR LIMITED "1" CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.4 Explanation of Operation of DTP/External Interrupt MB90860E Series 17.4 Explanation of Operation of DTP/External Interrupt The DTP/external interrupt has an external interrupt function and a DTP function. This section explains the setting and operation of each function. ■ Setting of DTP/External Interrupt Using the DTP/external interrupt requires the setting shown in Figure 17.4-1. Figure 17.4-1 Setting of DTP/External Interrupt bit15 14 ICR Interrupt Control Register (EI2 At DTP OS) At DTP (DMA) ENIR1/ENIR0 – 11 10 9 bit8 bit7 6 5 4 3 2 1 bit0 – – – 0 1 – – – 0 1 EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 EN7 EN6 EN5 EN4 EN3 EN2 EN1 EN0 – – – – – – – – – – – – – – – – – – – – – – 0 1 0 1 – – – – – – EN15 EN14 EN13 EN12 EN11 EN10 EN9 EN8 EN7 EN6 EN5 EN4 EN3 EN2 EN1 EN0 ❍ EIRR1/EIRR0 12 ICS3 ICS2 ICS1 ICS0 ISE IL2 IL1 IL0 ICS3 ICS2 ICS1 ICS0 ISE IL2 IL1 IL0 At external interrupt/DTP (DMA) – At DTP (EI2OS) DER (DMA enable register) 13 ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ER15 ER14 ER13 ER12 ER11 ER10 ER9 ER8 ER7 ER6 ER5 ER4 ER3 ER2 ER1 ER0 ELVR0 LB7 LA7 LB6 LA6 LB5 LA5 LB4 LA4 LB3 LA3 LB2 LA2 LB1 LA1 LB0 LA0 ELVR1 LB15 LA15 LB14 LA14 LB13 LA13 LB12 LA12 LB11 LA11 LB10 LA10 LB9 LA9 LB8 LA8 DDR port direction register Set the bit corresponding to pin used for the DTP/external interrupt input to "0" ADER7 (Analog input enable) Only when using INT7 to 0 TMCSR0 (Timer control) Only when using INT13R ● ● ● ● – – – – – – – – ● ● ● ● CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE UF CNTE TRG – – – – – 0 – – CLKR (Clock output enable) Only when using INT13R − ❍ ● 0 1 – – – – CKEN FRQ2 FRQ1 FRQ0 – – – – – – – – – – – – 0 – – – : Undefined bit : Used bit : Set the bit corresponding to used pin to "1" : Set the bit corresponding to used pin to "0" : Set "0" : Set "1" CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 385 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.4 Explanation of Operation of DTP/External Interrupt MB90860E Series ● Setting procedure To use the DTP/external interrupt, set each register by using the following procedure: 1. Set the input port to the general-purpose I/O port, which is shared with the terminal to be used as external interrupt input. 2. Set the interrupt request enable bit corresponding to the DTP/external interrupt channel to be used to "0" (ENIR:EN). 3. Use the detection condition select bit corresponding to the DTP/external interrupt pin to be used to set the edge or level to be detected (ELVR1:LA, LB). 4. Set the interrupt request flag bit corresponding to the DTP/external interrupt channel to be used to "0" (EIRR:ER). 5. Set the interrupt request enable bit corresponding to the DTP/external interrupt channel to be used to "1" (ENIR:EN). • When setting the registers for the DTP/external interrupt, the external interrupt request must be disabled in advance (ENIR:EN=0). • When enabling the DTP/external interrupt request (ENIR:EN=1), the corresponding DTP/external interrupt request flag bit must be cleared in advance (EIRR:ER=0). These actions prevent an interrupt request from mistakenly occurring when setting the register. ● Selecting of external interrupt function and DTP function Whether the external interrupt function or the DTP function is executed depends on the setting of the EI2OS enable bit (ICR:ISE) and DMA enable register (DER:EN) in the corresponding interrupt control register. If the ISE bit is set to "1", the extended intelligent I/O service (EI2OS) is enabled. If the EN bit is set to "1", the DMA transfer is enabled. If both the ISE and EN bits are set to "0", the EI2OS or DMA transfer is disabled, and the external interrupt function is executed. Notes: 386 • All interrupt requests assigned to one interrupt control register have the same interrupt levels (IL2 to IL0). • If two or more interrupt requests are assigned to one interrupt control register and the EI2OS is used in one of them, other interrupt requests cannot be used. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.4 Explanation of Operation of DTP/External Interrupt MB90860E Series ■ DTP/External Interrupt Operation Table 17.4-1 shows the control bits and the interrupt sources for the DTP/external interrupt. Table 17.4-1 Control Bits and Interrupt Sources for DTP/External Interrupt DTP/External Interrupt Interrupt request flag bit EIRR0: ER7 to ER0, EIRR1: ER15 to ER8 Interrupt request enable bit ENIR0: EN7 to EN0, ENIR1: EN15 to EN8 Interrupt source INT15 to INT0, INT15R to INT8R Input of valid edge/level to If the interrupt request from the DTP/external interrupt is output to the interrupt controller and the EI2OS enable bit (ICR:ISE) and DMA enable register (DER:EN) in the interrupt control register are set to "0", the interrupt processing is executed. If either of the bits is set to "1", the extended intelligent I/O service (EI2OS) or DMA transfer is executed. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 387 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.4 Explanation of Operation of DTP/External Interrupt MB90860E Series Figure 17.4-2 shows the operation of the DTP/external interrupt. Figure 17.4-2 Operation of DTP/External Interrupt DTP/external interrupt circuit Other request ELVR Interrupt controller CPU ICR YY EIRR IL CMP CMP ILM ICR XX ENIR Interrupt processing Source DMA activation DTP/external interrupt request generated Memory ↔ Peripheral data transfer Interrupt controller reception judge Renewal of descriptor Descriptor data counter CPU interrupt reception judge =0 Interrupt processing ≠0 Reset or stop Interrupt processing microprogram activation Recovery from DTP processing Recovery from DMA processing (DTP processing) 1 DER:EN EI2OS activation 0 1 Memory ↔ Peripheral data transfer ICR:ISE Renewal of descriptor 0 External interrupt activation Descriptor data counter =0 Interrupt processing ≠0 Processing and interrupt flag clear Reset or stop Recovery from external interrupt Note: 388 Recovery from DTP processing Do not use DMA and EI2OS simultaneously. Recovery from EI2OS processing (DTP processing) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.4 Explanation of Operation of DTP/External Interrupt MB90860E Series 17.4.1 External Interrupt Function The DTP/external interrupt has an external interrupt function for generating an interrupt request by detecting the signal (edge or level) in the DTP/external interrupt pin. ■ External Interrupt Function • When the signal (edge or level) set in the detection level setting register is detected in the DTP/external interrupt pin, the interrupt request flag bit in the DTP/external interrupt source register (EIRR:ER) is set to "1". • If the interrupt request enable bit in the DTP/external interrupt enable register is enabled (ENIR1:EN=1) with the interrupt request flag bit set to "1", the interrupt request generation is posted to the interrupt controller. • If an interrupt request is preferred to other interrupt request by the interrupt controller, the interrupt request is generated. • If the level of an interrupt request (ICR:IL) is higher than that of the interrupt level mask bit in the condition code register (CCR:ILM) and the interrupt enable bit is enabled (CCR:I=1), the CPU performs interrupt processing after completion of the current instruction execution and branches to interrupt processing. • At interrupt processing, set the corresponding DTP/external interrupt request flag bit to "0" and clear the DTP/external interrupt request. Notes: CM44-10144-4E • When the DTP/external interrupt activation source is generated, the DTP/external interrupt request flag bit (EIRR:ER) is set to "1", regardless of the setting of the DTP/external interrupt request enable bit (ENIR:EN). • When the interrupt processing is activated, clear the DTP/external interrupt request flag bit that caused the activation source. Control cannot be returned from the interrupt while the DTP/external interrupt request flag bit is set to "1". When clearing, do not clear any flag bit other than the accepted DTP/external interrupt source. FUJITSU SEMICONDUCTOR LIMITED 389 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.4 Explanation of Operation of DTP/External Interrupt 17.4.2 MB90860E Series DTP Function The DTP/external interrupt has the DTP function that detects the signal of the external peripheral device from the DTP/external interrupt pin to activate the DMA transfer or extended intelligent I/O service (EI2OS). ■ DTP Function The DTP function detects the signal level set by the detection level setting register of the DTP/external interrupt function to activate the DMA transfer or EI2OS. • When the DMA transfer is already enabled (DER:EN=1) at the point when the interrupt request is accepted, DMA is activated and the data starts to be transferred. • When the EI2OS operation is already enabled (ICR:ISE=1) at the point when the interrupt request is accepted, EI2OS is activated and the data starts to be transferred. • When transfer of one data item is completed, the descriptor is updated and the DTP/external interrupt request flag bit is cleared to prepare for the next request from the DTP/external interrupt pin. • When the DMA/EI2OS completes transfer of all the data, control branches to the interrupt processing. Figure 17.4-3 Example of Interface with External Peripheral Device (When Using EI2OS in Single-Chip Mode) "H" level request (ELVR:LB0, LA0=01B) Input to INT0 pin (DTP source) Descriptor CPU internal operation select and read Renewal of descriptor Peripheral device of external connection Internal data bus Read and write operation*2 DTP source*1 Data transfer request Interrupt INT DTP/external request interrupt circuit CPU (EI 2OS) Internal memory *1: This must be cancelled within three machine clocks after the start of data transfer. *2: When the extended intelligent I/0 service is "peripheral function → internal memory transfer". 390 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.5 Notes on Using DTP/External Interrupt MB90860E Series 17.5 Notes on Using DTP/External Interrupt This section explains the precautions when using the DTP/external interrupt. ■ Notes on Using DTP/External Interrupt ● Condition of external-connected peripheral device when DTP function is used • When using the DTP function, the peripheral device must automatically clear a data transfer request when data transfer is performed. • Inactivate the transfer request signal within three machine clocks after starting data transfer. If the transfer request signal remains active, the DTP/external interrupt regards the transfer request signal as a generation of next transfer request. ● External interrupt input polarity • When the edge detection is set in the detection level setting register, the minimum pulse width is required to detect the edge described in the data sheet. See the data sheet. • When a level causing an interrupt source is input with level detection set in the detection level setting register, the interrupt request flag bit (EIRR:ER) in the DTP/external interrupt source register is set to "1" and the source is held as shown in Figure 17.5-1. With the source is held in the interrupt request flag bit (EIRR:ER), the request to the interrupt controller remains active if the interrupt request is enabled (ENIR1:EN=1) even after the DTP/external interrupt source is cancelled. To cancel the request to the interrupt controller, clear the interrupt request flag bit (EIRR:ER) as shown in Figure 17.5-2. Figure 17.5-1 Clearing Interrupt Request Flag Bit (EIRR:ER) When Level is Set DTP/external interrupt source DTP/interrupt input detection circuit Interrupt request flag bit (EIRR:ER) Enable gate To interrupt controller (interrupt request) The source remains held unless cleared. Figure 17.5-2 DTP/External Interrupt Source and Interrupt Request Generated When Interrupt Request is Enabled DTP/external interrupt source (when "H" level detected) Interrupt source cancelled Interrupt request issued to interrupt controller The interrupt request is inactivated by clearing the interrupt request flag bit (EIRR:ER) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 391 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.5 Notes on Using DTP/External Interrupt MB90860E Series ● Precautions on interrupts • When the DTP/external interrupt is used as the external interrupt function, no return from interrupt processing can be made with the DTP/external interrupt request flag bit set to "1" (EIRR:ER=1) and the DTP/external interrupt request set to "enabled" (ENIR:EN=1). Always set the DTP/external interrupt request flag bit to "0" (EIRR:ER=0) at interrupt processing. • When the level detection is set in the detection level setting register and the level that becomes the interrupt source remains input, the DTP/external interrupt request flag bit is reset immediately even when cleared (EIRR:ER=0). Disable the DTP/external interrupt request output as needed (ENIR:EN=0), or cancel the interrupt source itself. 392 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.6 Program Example of DTP/External Interrupt Function MB90860E Series 17.6 Program Example of DTP/External Interrupt Function This section gives a program example for the DTP/external interrupt function. ■ Program Example of DTP/External Interrupt Function ● Processing specification An external interrupt is generated by detecting the rising edge of the pulse input to the INT0 pin. ● Coding example ICR07 DDR7 ENIR0 EQU EQU EQU 0000B7H 000017H 0000C6H ;Interrupt control register ICR7 ;Port 7 direction register ;DTP/external interrupt enable ;register 0 EIRR0 EQU 0000C7H ;DTP/external interrupt source ;register 0 ELVR0L EQU 0000C8H ;Detection level setting register ;0:"L" ELVR0H EQU 0000C9H ;E Detection level setting register ;0:"H" ADER7 EQU 00000DH ;Port7 analog input enable register ER0 EQU EIRR0:0 ;INT0 Interrupt request flag bit EN0 EQU ENIR0:0 ;INT0 Interrupt request enable bit ;---------Main program--------------------------------------CODE CSEG START: ;Stack pointer (SP), etc., already initialized MOV I:ADER7,#00000000B ;Set analog input of Port7 to ;disabled MOV I:DDR7,#00000000B ;Set DDR7 to input port AND CCR,#0BFH ;Interrupts disabled MOV I:ICR07,#00H ;Interrupt level 0 (highest) CLRB I:EN0 ;INT0 disabled using ENIR MOV I:ELVR0L,#00000010B;Rising edge selected for INT0 CLRB I:ER0 ;INT0 interrupt flag cleared using ;EIRR SETB I:EN0 ;INT0 interrupt request enabled using ;ENIR MOV ILM,#07H ;Set ILM in PS to level 7 OR CCR,#40H ;Interrupt enabled LOOP: • Processing by user • BRA CM44-10144-4E LOOP FUJITSU SEMICONDUCTOR LIMITED 393 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.6 Program Example of DTP/External Interrupt Function MB90860E Series ;---------Interrupt program---------------------------------WARI: CLRB I:ER0 ;Interrupt request flag cleared • Processing by user • RETI ;Return from interrupt processing CODE ENDS ;---------Vector setting------------------------------------VECT CSEG ABS=0FFH ORG 00FF94H ;Set vector to interrupt number ;#26(1AH) DSL WARI ORG 00FFDCH ;Set reset vector DSL START DB 00H ;Set to single-chip mode VECT ENDS END START ■ Program Example of DTP Function ● Processing specification • Channel 0 of the extended intelligent I/O service (EI2OS) is activated by detecting the "H" level of the signal input to the INT0 pin. • RAM data is output to port 0 by performing DTP processing (EI2OS). ● Coding example 394 ICR07 EQU 0000B7H DDR0 DDR7 ENIR0 EQU EQU EQU 000010H 000017H 0000C6H EIRR0 EQU 0000C7H ELVR0L ELVR0H ADER7 ER0 EN0 ; BAPL BAPM BAPH ISCS IOAL IOAH EQU EQU EQU EQU EQU 0000C8H 0000C9H 00000DH EIRR:0 ENIR:0 ;DTP/external interrupt control ;register ;Port 0 direction register ;Port 7 direction register ;DTP/external interrupt enable ;register 0 ;DTP/external interrupt source ;register 0 ;Detection level setting register 0: L ;Detection level setting register 0: H ;Port7 analog input enable register ;INT0 Interrupt request flag bit ;INT0 Interrupt request enable bit EQU EQU EQU EQU EQU EQU 000100H 000101H 000102H 000103H 000104H 000105H ;Buffer address pointer lower ;Buffer address pointer middle ;Buffer address pointer higher ;EI2OS status register ;I/O address register lower ;I/O address register higher FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.6 Program Example of DTP/External Interrupt Function MB90860E Series DCTL EQU 000106H ;Data counter lower DCTH EQU 000107H ;Data counter higher ; ;---------Main program--------------------------------------CODE CSEG START: ;Stack pointer (SP), etc., already initialized MOV I:ADER7,#00000000B ;Set analog input of Port7 to ;disabled MOV I:DDR0,#11111111B ;Set DDR0 to output port MOV I:DDR7,#00000000B ;Set DDR7 to input port AND CCR,#0BFH ;Interrupts disabled MOV I:ICR07,#08H ;Interrupt level 0 (highest) EI2OS ;ch.0 ;Data bank register (DTB) = 00H MOV BAPL,#00H ;Address for storing output data set MOV BAPM,#06H ;(600H to 60AH used) MOV BAPH,#00H MOV ISCS,#12H ;Byte transfer, buffer address + 1, ;I/O address fixed, transfer from ;memory to I/O MOV IOAL,#00H ;Set port 0 as transfer destination MOV IOAH,#00H ;address pointer MOV DCTL,#0AH ;Set transfer count to 10 MOV DCTH,#00H ; CLRB I:EN0 ;INT0 disabled using ENIR MOV I:ELVR0L,#00000001B ;"H" level detection set for INT0 CLRB I:ER0 ;INT0 interrupt flag cleared using ;EIRR SETB I:EN0 ;INT0 interrupt request enabled using ;ENIR MOV ILM,#07H ;Set ILM in PS to level 7 OR CCR,#40H ;Interrupt enabled LOOP: • Processing by user • BRA LOOP ;---------Interrupt program---------------------------------WARI: CLRB I:ER0 ;INT0 interrupt request flag cleared • Processing by user • RETI ;Return from interrupt processing CODE ENDS ;---------Vector setting------------------------------------- CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 395 CHAPTER 17 DTP/EXTERNAL INTERRUPT 17.6 Program Example of DTP/External Interrupt Function VECT VECT 396 CSEG ORG ABS=0FFH 00FF94H DSL ORG DSL DB ENDS END WARI 00FFDCH START 00H MB90860E Series ;Set vector to interrupt number ;#26(1AH) ;Set reset vector ;Set to single-chip mode START FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER This chapter explains the functions and operations of the 8/10-bit A/D converter. 18.1 Overview of 8/10-bit A/D Converter 18.2 Block Diagram of 8/10-bit A/D Converter 18.3 Configuration of 8/10-bit A/D Converter 18.4 Interrupt of 8/10-bit A/D Converter 18.5 Operating Explanation of 8/10-bit A/D Converter 18.6 Notes on Using 8/10-bit A/D Converter CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 397 CHAPTER 18 8/10-BIT A/D CONVERTER 18.1 Overview of 8/10-bit A/D Converter 18.1 MB90860E Series Overview of 8/10-bit A/D Converter The 8/10-bit A/D converter converts an analog input voltage to an 8- or 10-bit digital value by using RC-type successive approximation conversion method. • The input signal can be selected from analog input pins of up to 24 channels. • The activation trigger can be selected from software trigger, internal timer output, and external trigger. ■ Functions of 8/10-bit A/D Converter The 8/10-bit A/D converter converts an analog voltage (input voltage) that is input to the analog input pin to an 8- or 10-bit digital value (A/D conversion). The 8/10-bit A/D converter has the following functions: • A/D conversion time is a minimum of 1.9 μs* per channel including sampling time. • Sampling time is a minimum of 0.5 μs* per channel. • Conversion method is RC-type successive approximation conversion method with sample & hold circuit. • A resolution of 8 bits or 10 bits can be set. • The analog input pins can be used up to 24 channels. • An interrupt request can be generated by storing an A/D conversion result to the A/D data register. • When an interrupt request is generated, μDMAC or EI2OS can be activated. • The activation trigger can be selected from software, internal timer output, and external trigger (falling edge). *: It operates with machine clock frequency ; 24 MHz, AVCC ≥ 4.5 V 398 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.1 Overview of 8/10-bit A/D Converter MB90860E Series ■ Conversion Modes of 8/10-bit A/D Converter The following types of conversion modes are available for the 8/10-bit A/D converter. Table 18.1-1 Conversion Modes of 8/10-bit A/D Converter Conversion mode CM44-10144-4E Description Single conversion mode A/D conversion is performed sequentially from the start channel to the end channel. When A/D conversion for the end channel ends, the A/D conversion function is stopped. Continuous conversion mode A/D conversion is performed sequentially from the start channel to the end channel. When A/D conversion for the end channel ends, the A/D conversion continues to operate by returning to the start channel. Stop conversion mode A/D conversion is performed stopping by one channel. When A/D conversion for the end channel ends, it returns to the start channel and repeats A/D conversions and the stops. FUJITSU SEMICONDUCTOR LIMITED 399 CHAPTER 18 8/10-BIT A/D CONVERTER 18.2 Block Diagram of 8/10-bit A/D Converter 18.2 MB90860E Series Block Diagram of 8/10-bit A/D Converter The 8/10-bit A/D converter consists of the following blocks. ■ Block Diagram of 8/10-bit A/D Converter Figure 18.2-1 Block Diagram of 8/10-bit A/D Converter Interrupt request output A/D control status register BUSY INT INTE PAUS STS1 STS0 STRT ⎯ MD1 MD0 S10? ⎯ (ADCS0/ADCS1) ⎯ ⎯ ⎯ Reserved 2 ADTG Pin From 16-bit reload timer 1 TO Activation selector Software activation 2 Sample & hold circuit AN0 to AN7 AN15 to AN8 AN23 to AN16 Comparator Control circuit Analog channel selector AVRH/AVRL AVcc AVss D/A converter Successive approximation register Internal data bus φ 3 3 A/D data register D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 (ADCR0/ ADCR1) Decoder 10 A/D setting register (ADSR0/ ST2 ST1 ST0 CT2 CT1 CT0 ANS4 ANS3 ANS2 ANS1 ANS0 ANE4 ANE3 ANE2 ANE1 ANE0 ADSR1) TO ⎯ Reserved φ 400 : Internal timer output : Undefined : Be sure to set to "0" : Machine clock FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.2 Block Diagram of 8/10-bit A/D Converter MB90860E Series ● Details of pins in block diagram Table 18.2-1 shows the actual pin names and interrupt request numbers for the 8/10-bit A/D converter. Table 18.2-1 Pins and Interrupt Request Numbers in Block Diagram Pin name/interrupt request number in block diagram Actual pin name/interrupt request number ADTG Trigger input pin P80/ADTG TO Internal timer output Output of 16-bit reload timer 1 AN0 to AN7 Analog input pins ch.0 to ch.7 P60/AN0 to P67/AN7 AN8 to AN15 Analog input pins ch.8 to ch.15 P50/AN8 to P57/AN15 AN16 to AN23 Analog input pins ch.16 to ch.23 P70/AN16 to P77/AN23 AVRH / AVRL Vref+ / Vref- input pin AVRH / AVRL AVCC A/D converter power supply pin AVCC AVSS A/D converter analog GND pin AVSS Interrupt request output Interrupt request output #29(1DH) ● A/D control status register (ADCS) This register activates the A/D conversion function, selects the activation trigger for the A/D conversion function, selects the conversion mode, enables or disables interrupt request, checks and clears the interrupt request flag, pauses A/D conversion operation and checks the status during conversion, and selects the resolution by software. ● Successive approximation register (SAR) This circuit performs a successive approximation for each bit and stores the conversion result. The A/D conversion result in this circuit is destroyed, once the next A/D conversion starts. ● A/D data register (ADCR) An A/D conversion result is stored for each 1 bit in the successive approximation circuit during A/D conversion and then stored in this register when the A/D conversion ends and the conversion result is determined. The A/D conversion result can be read from this register. ● A/D setting register (ADSR) This register sets the start channel, end channel, compare time and sampling time for A/D conversion. ● Activation selector This selector selects the trigger to start A/D conversion. An internal timer output or external pin input can be set as the start trigger. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 401 CHAPTER 18 8/10-BIT A/D CONVERTER 18.2 Block Diagram of 8/10-bit A/D Converter MB90860E Series ● Decoder This decoder selects the analog input pin to be used for A/D conversion based on the settings of the A/D conversion start channel selection bits (ADSR: ANS4 to ANS0) and the A/D conversion end channel selection bits (ADSR: ANE4 to ANE0) in the A/D setting register. ● Analog channel selector This selector selects the pin to be used for A/D conversion from analog input pins of 24 channels by receiving a signal from the decoder. ● Sample & hold circuit This circuit holds the input voltage selected by the analog channel selector. The conversion can be performed without being affected by the fluctuation of the input voltage during the A/D conversion by holding the input voltage immediately after A/D conversion is stared. ● D/A converter This converter generates the reference voltage to compare it with the input voltage held in the sample & hold circuit. ● Comparator This comparator compares the D/A converter output voltage with the input voltage held in the sample & hold circuit to determine which voltage has a larger/smaller size. ● Control circuit This circuit determines the A/D conversion value by receiving the large/small signal from the comparator. When the conversion result is determined, the result data is stored in the A/D data register. If interrupt request is enabled, an interrupt is generated. 402 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series 18.3 Configuration of 8/10-bit A/D Converter This section shows the pins, registers, and interrupt sources of the A/D converter. ■ Pins of 8/10-bit A/D Converter The pins of the 8/10-bit A/D converter serve as general-purpose I/O ports. Table 18.3-1 shows the pin functions and pin settings for using the 8/10-bit A/D converter. Table 18.3-1 Pins of 8/10-bit A/D Converter (1 / 2) Function name Pin name Trigger input P80 / ADTG ch.0 P60 / AN0 ch.1 P61 / AN1 ch.2 P62 / AN2 ch.3 P63 / AN3 ch.4 P64 / AN4 ch.5 P65 / AN5 ch.6 P66 / AN6 ch.7 P67 / AN7 ch.8 P50 / AN8 ch.9 P51 / AN9 ch.10 P52 / AN10 ch.11 P53 / AN11 ch.12 P54 / AN12 ch.13 P55 / AN13 ch.14 P56 / AN14 ch.15 P57 / AN15 CM44-10144-4E Settings for using 8/10-bit A/D converter Pin function General-purpose I/O port / external trigger input Set as input port in port direction register DDR8 General-purpose I/O port / analog input / PPG output Enable input of analog signal (Set the bits corresponding to ADER6: ADE7 to ADE0 to "1") General-purpose I/O port / analog input / UART2 I/O General-purpose I/O port / analog input / reload timer 3 I/O Enable input of analog signal (Set the bits corresponding to ADER5: ADE15 to ADE8 to "1") General-purpose I/O port / analog input FUJITSU SEMICONDUCTOR LIMITED 403 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series Table 18.3-1 Pins of 8/10-bit A/D Converter (2 / 2) 404 Function name Pin name ch.16 P70 / AN16 ch.17 P71 / AN17 ch.18 P72 / AN18 ch.19 P73 / AN19 ch.20 P74 / AN20 ch.21 P75 / AN21 ch.22 P76 / AN22 ch.23 P77 / AN23 Settings for using 8/10-bit A/D converter Pin function General-purpose I/O port/ analog input / external interrupt input Enable input of analog signal (Set the bits corresponding to ADER7: ADE23 to ADE16 to "1") FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series ■ List of Registers and Initial Values of 8/10-bit A/D Converter Figure 18.3-1 List of Registers and Initial Values of 8/10-bit A/D Converter A/D control status register 1 ADCS1 15 14 Address: 000069H BUSY INT R/W 13 12 11 10 9 Initial value 0000000XB INTE PAUS STS1 STS0 STRT R/W R/W R/W R/W R/W A/D control status register 0 ADCS0 7 6 5 4 3 2 Address: 000068H 8 W 1 0 MD1 MD0 S10 Reserved R/W R/W R/W A/D data register 1 ADCR1 15 R/W 14 13 12 11 10 Address: 00006BH 9 8 D9 R D8 R Initial value 000XXXX0B Initial value XXXXXX00B A/D data register 0 ADCR0 Address: 00006AH 7 6 5 4 3 2 1 0 Initial value D7 D6 D5 D4 D3 D2 D1 D0 00000000B R R R R R R R R ADSR1 A/D setting register 1 ADSR1 15 14 13 ST2 R/W ST1 R/W ST0 R/W A/D setting register 0 ADSR0 7 6 5 Address: 00006DH Address: 00006CH 12 11 10 CT2 CT1 R/W R/W 4 3 9 8 Initial value CT0 ANS4 ANS3 R/W R/W R/W 2 1 0 ANS2 ANS1 ANS0 ANE4 ANE3 ANE2 ANE1 ANE0 R/W R/W R/W R/W R/W R/W R/W 00000000B Initial value 00000000B R/W R/W : Readable/writable R : Read only W : Write only : Undefined bit X : Undefined CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 405 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter 18.3.1 MB90860E Series A/D Control Status Register 1 (ADCS1) The A/D control status register 1 (ADCS1) provides the following settings: • Activating A/D conversion function by software • Selecting activation trigger for A/D conversion • Enabling or disabling interrupt request by storing A/D conversion result in the A/D data register • Checking and clearing interrupt request flag by storing A/D conversion result in the A/ D data register • Pausing A/D conversion operation and checking the status during conversion ■ A/D Control Status Register 1 (ADCS1) Figure 18.3-2 A/D Control Status Register 1 (ADCS1) 15 Address 14 13 12 11 10 9 000069 H BUSY INT INTE PAUS STS1 STS0 STRT R/W R/W R/W R/W R/W R/W W 8 Initial value - 0000000XB bit8 - Undefined bit Read value is always "1" bit9 STRT A/D conversion software activation bit 0 Does not activate A/D conversion function 1 Activates A/D conversion function bit11 bit10 A/D conversion activation trigger selection bits STS1 STS0 0 0 Activation by software 0 1 Activation by software or external pin trigger 1 0 Activation by software or 16-bit reload timer 1 1 Activation by software, external pin trigger or 16-bit reload timer bit12 Pause flag bit PAUS (Enabled only when EI2OS or DMA is used) Read 0 1 Write Conversion is not paused Clears to "0" Conversion is paused No effect bit13 Interrupt request enable bit INTE Disables interrupt request 0 Enables interrupt request 1 bit14 INT 0 1 Interrupt request flag bit Read A/D conversion uncompleted Write Clears to "0" A/D conversion completed No effect bit15 BUSY R/W : Readable/writable W : Write only : Undefined bit : Undefined X : Initial value 406 A/D conversion operating flag bit 0 Read A/D conversion completed (non-activated state) Write Terminates A/D conversion function forcibly 1 A/D conversion in progress No effect FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter Table 18.3-2 Function of A/D Control Status Register 1 (ADCS1) (1 / 3) bit15 bit14 bit13 Bit name Function BUSY: A/D conversion operating flag bit This bit forcibly terminates the 8/10-bit A/D converter. When this bit is read, it indicates whether the 8/10-bit A/D converter is operating or stopped. When set to "0": 8/10-bit converter is forcibly terminated When set to "1": No effect When reading : "1" is read when the 8/10-bit A/D converter is operating and "0" is read when the converter is stopped If in "stop state" in stop conversion mode, "1" is read Notes: • "1" is read when this bit is read by a RMW instruction. • In single conversion mode, this bit is cleared when A/D conversion is completed. • In continuous conversion mode and stop conversion mode, this bit will not be cleared until "0" is written to stop. • Do not terminate the A/D converter forcibly (BUSY=0) and activate it (by any of the triggers: software (STRT=1)/external trigger/timer) simultaneously. INT: Interrupt request flag bit This bit indicates that an interrupt request is generated. • The INT bit is set to "1" when an A/D conversion is completed and its result is stored in the A/D data register (ADCR). • When the interrupt request flag bit is set (INT=1) if interrupt request is enabled (INTE=1), an interrupt request is generated. • This bit is cleared when "0" is written to it. In addition, it will be cleared automatically when a transfer of A/D conversion result data by EI2OS/μDMAC is completed. When set to "0": Clears this bit When set to "1": No effect Note: • "1" is read when this bit is read by a RMW instruction. INTE: Interrupt request enable bit This bit enables or disables interrupt request output. • When the interrupt request flag bit is set (INT=1) if interrupt request is enabled (INTE=1), an interrupt request is generated. Note: Be sure to set this bit to "1" if transferring A/D conversion result by EI2OS/μDMAC. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 407 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series Table 18.3-2 Function of A/D Control Status Register 1 (ADCS1) (2 / 3) Bit name bit12 bit11, bit10 408 Function PAUS: Pause flag bit PAUS bit indicates that the A/D conversion data protection function has been worked. PAUS bit is valid only if interrupt request output is set to enable (ADCS:INTE=1). When A/D conversion data protection function worked: Sets this bit to "1" When set to "0": Clears to "0" When set to "1": Sets to "1" • When A/D conversion is performed with interrupt request output enabled (ADCS:INTE=1), an interrupt request is generated at the same time as the interrupt request flag bit (ADCS:INT) is set after the A/D conversion ends once. If the next A/D conversion ends without clearing the interrupt request flag bit (ADCS:INT), the A/D conversion operation will be paused to prevent the previous data from being overwritten and destroyed (A/D conversion data protection function). When an A/D conversion operation is paused, PAUS bit is set to "1". • When the interrupt request flag bit (ADCS:INT) is cleared, the 8/10-bit A/D converter cancels the pause state and restarts the A/D conversion operation. • The interrupt request flag bit (ADCS:INT) is cleared by writing "0" to it. In addition, if an A/D conversion result is transferred from the A/D data register using EI2OS/μDMAC, the interrupt request flag bit (ADCS:INT) is cleared by EI2OS/μDMAC once the transfer of the A/D conversion result is completed. Notes: • For the A/D conversion data protection function, see Section "18.5.5 A/D Conversion Data Protection Function". • PAUS bit is not cleared automatically even when the pause state is cancelled. Write "0" to clear PAUS bit. STS1, STS0: A/D conversion activation trigger selection bits These bits select the trigger (activation trigger) to activate the 8/10-bit A/D converter. • 00B: Software activation • 01B: External pin trigger/software activation • 10B: 16-bit reload timer 1/software activation • 11B: External pin trigger/16-bit reload timer 1/software activation Notes: • When external pin trigger is selected (01B, 11B), A/D conversion starts when an falling edge is detected at ADTG pin. • When 16-bit reload timer is selected (10B, 11B), A/D conversion starts when the output of the 16-bit reload timer 1 becomes "1". Notes: • When multiple activation triggers are set (settings other than STS1, STS0=00B), 8/10-bit A/D converter will be activated by the first-generated activation trigger. • When changing the activation trigger setting, set while the operation of peripheral functions which may generate an activation trigger is stopped (in trigger inactive state). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series Table 18.3-2 Function of A/D Control Status Register 1 (ADCS1) (3 / 3) Bit name bit9 STRT: A/D conversion software activation bit bit8 Undefined bit CM44-10144-4E Function This bit activates the 8/10-bit A/D converter by software. When set to "1": Activates 8/10-bit A/D converter • If an A/D conversion operation is paused in stop conversion mode, the operation is restarted by writing "1" to STRT bit. When set to "0": Ignored. No change Notes: • "0" is read when this bit is read by a RMW instruction • When reading by an instruction other than RMW instruction, "1" is read instead of a written value. • Do not terminate the 8/10-bit A/D converter forcibly (BUSY=0) and activate by software (STRT=1) simultaneously. • Read : Always "1" is read • Write : No effect FUJITSU SEMICONDUCTOR LIMITED 409 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter 18.3.2 MB90860E Series A/D Control Status Register 0 (ADCS0) The A/D control status register 0 (ADCS0) provides the following settings: • Selecting A/D conversion mode • Selecting A/D conversion start channel and end channel ■ A/D Control Status Register 0 (ADCS0) Figure 18.3-3 A/D Control Status Register 0 (ADCS0) Address 7 6 5 4 3 2 1 0 000068H MD1 MD0 S10 - - - - Reserved R/W R/W R/W - - - - R/W Initial value 000XXXX0B bit0 Reserved 0 bit5 S10 0 1 R/W : Readable/writable - : Undefined bit X : Undefined : Initial value 410 Reserved bit Always write "0" to this bit Resolution selection bit Set A/D conversion resolution to 10 bits Set A/D conversion resolution to 8 bits bit7 bit6 MD1 MD0 0 0 1 0 0 1 1 1 A/D conversion mode selection bits Single conversion mode 1 Single conversion mode 2 Continuous conversion mode Stop conversion mode FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series Table 18.3-3 Function of A/D Control Status Register 0 (ADCS0) Bit name Function MD1, MD0: A/D conversion mode selection bits These bits set the A/D conversion mode. For details on how to use each mode, see Section "18.5 Operating Explanation of 8/ 10-bit A/D Converter". Single conversion mode 1 and single conversion mode 2: • A/D conversion is continuously performed through analog inputs from the start channel (ADSR : ANS4 to ANS0) to the end channel. • A/D conversion operation stops when the A/D conversion of the end channel is completed. • See Section "18.5 Operating Explanation of 8/10-bit A/D Converter" on the difference between single conversion modes 1 and 2. Continuous conversion mode: • A/D conversion for analog inputs from the start channel (ADSR: ANS4 to ANS0) to the end channel (ADSR: ANE4 to ANE0) is performed continuously. • After completing the A/D conversion of the end channel, it returns to the analog input of the start channel and continues the A/D conversion. Stop conversion mode: • A/D conversion starts from the start channel (ADSR: ANS4 to ANS0). A/D conversion operation stops when the A/D conversion for one channel is completed. When an activation trigger is input while A/D conversion operation pauses, the A/D conversion for the next channel is performed. • A/D conversion operation pauses at the completion of A/D conversion for the end channel. When an activation trigger is input while A/D conversion operation pauses, the A/D conversion is continued by returning to the analog input for the start channel. Note: If changing the conversion mode, perform in the stop state before A/D conversion is started. bit5 S10: Resolution selection bit This bit sets the A/D conversion resolution. When set to "0": Sets the A/D conversion resolution to 10 bits of the A/D conversion data bits D9 to D0. When set to "1": Sets the A/D conversion resolution to 8 bits of the A/D conversion data bits D7 to D0. Note: When changing S10 bit, perform in the stop state before A/D conversion is started. If S10 bit is changed after A/D conversion is started, the conversion result stored in the A/D conversion data bits (D9 to D0) will become invalid. bit4 to bit1 Undefined bit Only reading is allowed. The initial value is "1". bit0 Reserved bit Always write "0" to this bit. bit7, bit6 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 411 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter 18.3.3 MB90860E Series A/D Data Registers 0/1 (ADCR0/ADCR1) The A/D data registers (ADCR0/ADCR1) are used to store digital values generated as a result of a conversion. ADCR0 stores the lower 8 bits and ADCR1 stores the highest 2 bits of a conversion result. These registers are rewritten after each conversion is completed, and normally the last conversion value is stored in them. ■ A/D Data Registers (ADCR0/ADCR1) Figure 18.3-4 A/D Data Registers (ADCR0/ADCR1) A/D data register 1 Address ADCR1 00006BH A/D data register 0 Address ADCR0 00006AH 15 14 13 12 11 10 9 8 Initial value - - - - - - D9 D8 XXXXXX00B R R 7 6 5 4 3 2 1 0 Initial value D7 D6 D5 D4 D3 D2 D1 D0 00000000B R R R R R R R R R : Read only X : Undefined - : Undefined bit Table 18.3-4 Function of A/D Data Registers (ADCR0/1) Bit name bit15 to bit10 bit9 to bit0 412 Function Undefined bits When reading, always "1" is read. D9 to D0: A/D conversion data bits These bits store the result of an A/D conversion When resolution is set to 10 bits (S10=0): Stores conversion data in 10 bits from D9 to D0 When resolution is set to 8 bits (S10=1): Stores conversion data in 8 bits from D7 to D0. At this time, the read values of D9 to D8 become "1" Notes: • Writing to these registers is prohibited. • Use a word instruction (MOVW) to read the conversion result stored in the A/D conversion data bits (D9 to D0). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series 18.3.4 A/D Setting Register (ADSR0/ADSR1) The A/D setting register (ADSR0/1) provides the following settings: • Setting A/D conversion times (sampling time, compare time) • Setting sampling channels (start channel, end channel) • Displaying the current sampling channel ■ A/D Setting Register (ADSR0/ADSR1) Figure 18.3-5 A/D Setting Register (ADSR0/ADSR1) 15 14 13 12 11 10 9 7 8 6 5 4 3 2 1 0 Initial value Address 00006CH ST2 ST1 ST0 CT2 CT1 CT0 ANS4 ANS3 ANS2 ANS1 ANS0 ANE4 ANE3 ANE2 ANE1 ANE0 0000000000000000B 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 bit4 to bit0 ANE4 to ANE0 11111B to 00000 (Initial value: 00000B) A/D conversion end channel selection bits AN31 pin (*) to AN0 pin bit9 to bit5 A/D conversion start channel selection bits ANS4 to ANS0 Write Read during (inactive state) conversion Read during pause in stop conversion mode Channel number Channel number where the AN31 pin* where the conver- conversion was performed to AN0 pin sion is running immediately before the pause (Initial value: 00000B) 11111B to 00000 bit12 bit11 bit10 CT2 CT1 CT0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 bit15 bit14 bit13 ST2 ST1 ST0 R/W : Readable/writable : Machine clock : Initial value φ 0 0 0 0 0 1 0 0 1 1 1 1 1 1 0 0 1 1 0 1 0 1 0 1 Compare time selection bits 22/φ (φ = 20 MHz: 1.1 μs) 33/φ (φ = 24 MHz: 1.4 μs) 44/φ (φ = 24 MHz: 1.8 μs) 66/φ (φ = 24 MHz: 2.75 μs) 88/φ (φ = 8 MHz: 11.0 μs) 132/φ (φ = 16 MHz: 8.25 μs) 176/φ (φ = 20 MHz: 8.8 μs) 264/φ (φ = 24 MHz: 11.0 μs) Sampling time selection bits 4/φ (φ = 8 MHz: 0.5 μs) 6/φ (φ = 8 MHz: 0.75 μs) 8/φ (φ = 16 MHz: 0.5 μs) 12/φ (φ = 24 MHz: 0.5 μs) 24/φ (φ = 8 MHz: 3.0 μs) 36/φ (φ = 16 MHz: 2.25 μs) 48/φ (φ = 16 MHz: 3.0 μs) 128/φ (φ = 24 MHz: 5.3 μs) *: AN23 to AN0 can be set. AN24 or pins with the higher number are not available. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 413 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series Table 18.3-5 Function of A/D Setting Register (ADSR0/ADSR1) (1 / 2) Bit name bit15 to bit13 bit12 to bit10 bit9 to bit5 414 Function ST2 to ST0: Sampling time selection bits These bits set the A/D conversion sampling time. • These bits set the time from starting A/D conversion to holding the input analog voltage via sampling & hold circuit. • For the settings of these bits, see Table 18.3-6. Notes: • Analog voltage may not be captured correctly if disallowed setting is initiated. • While A/D conversion is in process, do not set sample time. CT2 to CT0: Compare time selection bits These bits set the A/D conversion compare time. • These bits set the time from A/D converting the analog input to store it in data bits (D9 to D0). • For the settings of these bits, see Table 18.3-7. Note: Analog voltage may not be captured correctly if disallowed setting is initiated. ANS4 to ANS0: A/D conversion start channel selection bits These bits set the channel at which an A/D conversion starts. If reading these bits, you can verify the currently converted channel number if in the process of A/D conversion, and the last A/D converted channel number if the A/D conversion is completed or stopped. In addition, even if a value is set to these bits, the previous A/D converted channel number instead of the set value will be read until an A/D conversion starts. These bits are initialized to 00000B at reset. Start channel < End channel: An A/D conversion starts at the channel set by A/D conversion start channel selection bits (ANS4 to ANS0) and ends at the channel set by A/D conversion end channel selection bits (ANE4 to ANE0) Start channel = End channel: A/D conversion is performed only for one channel set by A/D conversion start (= end) channel selection bits (ANS4 to ANS0 = ANE4 to ANE0) Start channel > End channel: Do not set this setting Continuous conversion mode, stop conversion mode: When an A/D conversion ends at the channel set by the A/D conversion end channel selection bits (ANE4 to ANE0), it returns to the channel set by the A/D conversion start channel selection bits (ANS4 to ANS0) When reading (in a mode except stop conversion mode): The channel number (31 to 0) under A/D conversion is read When reading (in stop conversion mode): When reading during a stop, the channel number A/D-converted immediately before the stop is read Notes: • Do not set the A/D conversion start channel bits (ANS4 to ANS0) during A/D conversion. • When writing to this bit, use word access. If byte write or bit manipulation is performed, an A/D conversion may start from an unexpected channel. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter Table 18.3-5 Function of A/D Setting Register (ADSR0/ADSR1) (2 / 2) Bit name bit4 to bit0 ANE4 to ANE0: A/D conversion end channel selection bits CM44-10144-4E Function These bits set the channel at which an A/D conversion ends. Start channel < End channel: An A/D conversion starts at the channel set by A/D conversion start channel selection bits (ANS4 to ANS0) and ends at the channel set by A/D conversion end channel selection bits (ANE4 to ANE0) Start channel = End channel: A/D conversion is performed only for one channel set by A/D conversion start (= end) channel selection bits (ANS4 to ANS0 = ANE4 to ANE0) Start channel > End channel: Do not set this setting Continuous conversion mode, stop conversion mode: When an A/D conversion ends at the channel set by the A/D conversion end channel selection bits (ANE4 to ANE0), it returns to the channel set by the A/ D conversion start channel selection bits (ANS4 to ANS0) Notes: • Do not set the A/D conversion end channel selection bits (ANE4 to ANE0) during A/D conversion. • After the A/D conversion start channel selection bits (ANS4, ANS3,ANS2, ANS1, ANS0) are set, do not set the sampling time selection bits (ST2, ST1, ST0), compare time selection bits (CT2, CT1, CT0) and A/D conversion end channel selection bits (ANE4, ANE3, ANE2, ANE1, ANE0) using a readmodify-write instruction. Because the previous conversion channel is read from ANS4, ANS3, ANS2, ANS1, ANS0 bits until a new A/D conversion operation starts, the values of ANS4, ANS3, ANS2, ANS1, ANS0 bits may be rewritten if ST2, ST1, ST0 bits, CT2, CT1, CT0 bits and ANE4, ANE3, ANE2, ANE1, ANE0 bits are set using a read-modify instruction after setting ANS4, ANS3, ANS2, ANS1, ANS0 bits. FUJITSU SEMICONDUCTOR LIMITED 415 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series ■ Setting for Sampling Time (ST2 to ST0 Bits) Table 18.3-6 Relationship Between ST2 to ST0 Bits and Sampling Time Setting example (φ: internal operation frequency) ST2 ST1 ST0 Sampling time setting 0 0 0 4 machine cycles φ = 8 MHz: 0.5 μs 0 0 1 6 machine cycles φ = 8 MHz: 0.75 μs 0 1 0 8 machine cycles φ = 16 MHz: 0.5 μs 0 1 1 12 machine cycles φ = 24 MHz: 0.5 μs 1 0 0 24 machine cycles φ = 8 MHz: 3 μs 1 0 1 36 machine cycles φ = 16 MHz: 2.25 μs 1 1 0 48 machine cycles φ = 16 MHz: 3.0 μs 1 1 1 128 machine cycles φ = 24 MHz: 5.3 μs The sampling time must be set in accordance with the drive impedance (Rext), which is connected to the analog input. Refer to the data sheet for each parameter. • Rext ≤ Rext max: Set sampling time to STmin or more. • Rext > Rext max: Set the sampling time to ST shown in the following expression, or higher. ST = (Rin + Rext) × Cin × 7 ■ Setting for Compare Time (CT2 to CT0 Bits) Table 18.3-7 Relationship Between CT2 to CT0 Bits and Compare Time Setting example (φ: internal operation frequency) CT2 CT1 CT0 Compare time setting 0 0 0 22 machine cycles φ = 20 MHz: 1.1 μs 0 0 1 33 machine cycles φ = 24 MHz: 1.4 μs 0 1 0 44 machine cycles φ = 24 MHz: 1.8 μs 0 1 1 66 machine cycles φ = 24 MHz: 2.75 μs 1 0 0 88 machine cycles φ = 8 MHz: 11.0 μs 1 0 1 132 machine cycles φ = 16 MHz: 8.25 μs 1 1 0 176 machine cycles φ = 20 MHz: 8.8 μs 1 1 1 264 machine cycles φ = 24 MHz: 11.0 μs The compare time must be set in accordance with the analog supply voltage AVCC. Refer to the data sheet for details. 416 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series 18.3.5 Analog Input Enable Register (ADER5 to ADER7) This register enables or disables analog input pins used for the 8/10-bit A/D converter. ■ Analog Input Enable Register (ADER5 to ADER7) Figure 18.3-6 Analog Input Enable Register (ADER5 to ADER7) 15 Address 14 13 12 11 10 9 8 Initial value ADER5: 00000BH ADE15 ADE14 ADE13 ADE12 ADE11 ADE10 ADE9 ADE8 11111111B R/W R/W R/W R/W R/W R/W R/W R/W bit15 to bit8 ADE15 to ADE8 Analog input enable bits 15 to 8 (AN15 to AN8) Disables analog input 0 1 Enables analog input Address ADER6: 00000CH 7 6 5 4 3 2 1 0 Initial value 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 bit7 to bit0 Analog input enable bits 7 to 0 (AN7 to AN0) ADE7 to ADE0 Disables analog input 0 1 Enables analog input Address 15 14 13 12 11 10 9 8 Initial value ADER7: 00000DH ADE23 ADE22 ADE21 ADE20 ADE19 ADE18 ADE17 ADE16 11111111B R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/writable : Initial value bit15 to bit8 ADE23 to ADE16 Analog input enable bits 23 to 6 (AN23 to AN16) Disables analog input 0 1 Enables analog input Table 18.3-8 Function of Port 5 Analog Input Enable Register (ADER5) Bit name bit15 to bit8 ADE15 to ADE8: Analog input enable bit15 to bit8 Function These bits enable or disable analog input of the A/D conversion analog input pins AN15 to AN8 placed on port 5. When set to "0": Disables analog input When set to "1": Enables analog input Table 18.3-9 Function of Port 6 Analog Input Enable Register (ADER6) Bit name bit7 to bit0 ADE7 to ADE0: Analog input enable bit 7 to bit 0 CM44-10144-4E Function These bits enable or disable analog input of the A/D conversion analog input pins AN7 to AN0 placed on port 6. When set to "0": Disables analog input When set to "1": Enables analog input FUJITSU SEMICONDUCTOR LIMITED 417 CHAPTER 18 8/10-BIT A/D CONVERTER 18.3 Configuration of 8/10-bit A/D Converter MB90860E Series Table 18.3-10 Function of Port 7 Analog Input Enable Register (ADER7) Bit name bit15 to bit8 Notes: 418 ADE23 to ADE16: Analog input enable bit 23 to bit 16 Function These bits enable or disable analog input of the A/D conversion analog input pins AN23 to AN16 placed on port 7. When set to "0": Disables analog input When set to "1": Enables analog input • To use as an analog input pin, set it to analog input by writing "1" to the bit in the analog input enable register corresponding to the pin to be used. • Setting an analog input pin to ADERx=0 is prohibited. Always set to ADERx=1. • Each analog input pin serves as a general-purpose I/O port and an input/output of peripheral functions. The pin set to ADERx=1 automatically becomes an analog input pin regardless of the I/O settings in port direction register (DDR5 to DDR7) and in each peripheral function, and cannot be used for other purposes. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.4 Interrupt of 8/10-bit A/D Converter MB90860E Series 18.4 Interrupt of 8/10-bit A/D Converter The 8/10-bit A/D converter can generate an interrupt request when the conversion result is set in the A/D data register (ADCR) after an A/D conversion is completed. The μDMAC and the extended intelligent I/O service (EI2OS) can be used. ■ Interrupt of A/D Converter When the A/D conversion of an analog input voltage is completed and the A/D result is stored in the A/D data register (ADCR), the interrupt request flag bit in the A/D control status register (ADCS: INT) is set to "1". When the interrupt request flag bit is set (ADCS: INT=1) with interrupt request output enabled (ADCS: INTE=1), an interrupt request is generated. ■ Interrupt of 8/10-bit A/D Converter, and μDMAC and EI2OS Reference: See "CHAPTER 3 INTERRUPTS" for details of the interrupt number, interrupt control register, and interrupt vector address. ■ μDMAC and EI2OS of 8/10-bit A/D Converter In the 8/10-bit A/D converter, the μDMAC or EI2OS function can be used to transfer the A/D conversion result from the A/D data register (ADCR) to memory. For information on how to use the DMAC/ EI2OS functions, see Section "18.5.4 Conversion Operation with μDMAC or EI2OS Function" and Section "18.5.5 A/D Conversion Data Protection Function". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 419 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter 18.5 MB90860E Series Operating Explanation of 8/10-bit A/D Converter For A/D conversion operation of the 8/10-bit A/D converter, the following A/D conversion modes are available. Each mode is set based on the setting of the A/D conversion mode selection bits (ADCS: MD1, MD0) in the A/D control status register. • Single conversion mode • Continuous conversion mode • Stop conversion mode ■ Single Conversion Mode (ADCS: MD1, MD0=00B or 01B) • When an activation trigger is input, the analog inputs from the start channel (ADSR: ANS4 to ANS0) to the end channel (ADSR: ANE4 to ANE0) are A/D-converted continuously. • A/D conversion operation stops at the time of completing of the A/D conversion for the end channel. Notes: • In single conversion mode 1 (ADCS:MD1, MD0=00B), do not input an activation trigger during A/D conversion or a pause* as this may cause a restart of the 8/10-bit A/D converter. In single conversion mode 2 (ADCS:MD1, MD0=01B), a restart of the 8/10-bit A/D converter will not occur even if an activation trigger is input during A/D conversion or a pause*. • To restart in either single conversion mode 1 or 2, follow the order indicated in Section "18.5.1 Single Conversion Mode". *: The pause state is in a state which conversion is suspended due to the A/D conversion protection function. For details, see Section "18.5.5 A/D Conversion Data Protection Function". ■ Continuous Conversion Mode (ADCS: MD1, MD0=10B) • When an activation trigger is input, the analog inputs from the start channel (ADSR: ANS4 to ANS0) to the end channel (ADSR: ANE4 to ANE0) are A/D-converted continuously. • When A/D conversion for the end channel is completed, it is continued by returning to the analog input of the start channel. ■ Stop Conversion Mode (ADCS: MD1, MD0=11B) • When a start trigger is input, A/D conversion starts for the start channel (ADSR: ANS4 to ANS0). The A/D conversion operation stops at the completion of A/D conversion for one channel. This state is called the "stop state". When a start trigger is input while the A/D conversion operation stops, A/D conversion is performed for the next channel. • The A/D conversion operation stops at the completion of A/D conversion for the end channel. When a start trigger is input while the A/D conversion operation stops, A/D conversion is continued by returning to the analog input of the start channel. 420 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 18.5.1 Single Conversion Mode CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter In single conversion mode, A/D conversion is performed sequentially from the start channel to the end channel. The A/D conversion operation stops at the completion of the A/D conversion for the end channel. ■ Setting for Single Conversion Mode To operate the 8/10-bit A/D converter in single conversion mode, the settings shown in Figure 18.5-1 are required. Figure 18.5-1 Setting for Single Conversion Mode bit15 14 13 12 11 10 ADCS 9 bit8 bit7 6 5 4 3 2 1 bit0 BUSY INT INTE PAUS STS1 STS0 STRT − MD1 MD0 S10 − − − − 0 ADCR − − − − − − Reserved 0 D9 to D0 (Holds conversion results) ADSR ST2 ST1 ST0 CT2 CT1 CT0 ANS4 ANS3 ANS2 ANS1 ANS0 ANE4 ANE3 ANE2 ANE1 ANE0 ADER5 ADE15 ADE14 ADE13 ADE12 ADE11 ADE10 ADE9 ADE8 ADER7/6 ADE23 ADE22 ADE21 ADE20 ADE19 ADE18 ADE17 ADE16 ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 ADE0 − : Undefined : Used bit : Set the bit corresponding to the pin to be used as an analog input pin to "1" 0 : Set to "0" CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 421 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter MB90860E Series ■ Single Conversion Mode Operation and How to Use It • When a start trigger is input, A/D conversion starts from the channel set by the A/D conversion start channel selection bits (ANS4 to ANS0) and is performed continuously up to the channel set by the A/D conversion end channel selection bits (ANE4 to ANE0). • The A/D conversion operation stops at the completion of the A/D conversion for the channel set by the A/D conversion end channel selection bits (ANE4 to ANE0). • To terminate an A/D conversion operation forcibly, write "0" to the A/D conversion operating flag bit (ADCS:BUSY) in the A/D control status register. [If start channel and end channel are the same] • If the start and end channels are set to the same channel number (ADSRS: ANS4 to ANS0=ADSR: ANE4 to ANE0), A/D conversion for only one channel set as the start channel (= end channel) is performed only once and terminated. [Conversion order in single conversion mode] Table 18.5-1 shows an example of the conversion order in single conversion mode. Table 18.5-1 Conversion Order in Single Conversion Mode Start channel End channel Conversion order in single conversion mode AN0 pin (ADSR: ANS=00000B) AN3 pin (ADSR: ANE=00011B) AN0 → AN1 → AN2 → AN3 → End AN3 pin (ADSR: ANS=00011B) AN3 pin (ADSR: ANE=00011B) AN3 → End [Restart] To restart A/D conversion during A/D conversion execution or a pause state, terminate the conversion forcibly once and then restart it. Follow the procedure below: 1) Clear the A/D conversion operating flag bit (ADCS:BUSY) 2) Clear the interrupt request flag bit (ADCS:INT) 3) Set the A/D conversion software activation bit (ADCS:STRT) 422 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter MB90860E Series 18.5.2 Continuous Conversion Mode In continuous conversion mode, A/D conversion is performed sequentially from the start channel to the end channel. When the A/D conversion for the end channel is completed, the A/D conversion operation is continued by returning to the start channel. ■ Setting for Continuous Conversion Mode To operate the 8/10-bit A/D converter in continuous conversion mode, the settings shown in Figure 18.5-2 are required. Figure 18.5-2 Setting for Continuous Conversion Mode bit15 14 13 12 11 10 ADCS 9 bit8 bit7 6 4 3 2 1 bit0 BUSY INT INTE PAUS STS1 STS0 STRT − MD1 MD0 S10 − − − − 1 ADCR − − − − − − 5 0 Reserved 0 D9 to D0 (Holds conversion results) ADSR ST2 ST1 ST0 CT2 CT1 CT0 ANS4 ANS3 ANS2 ANS1 ANS0 ANE4 ANE3 ANE2 ANE1 ANE0 ADER5 ADE15 ADE14 ADE13 ADE12 ADE11 ADE10 ADE9 ADE8 ADER7/6 ADE23 ADE22 ADE21 ADE20 ADE19 ADE18 ADE17 ADE16 ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 ADE0 − : Undefined : Used bit : Set the bit corresponding to the pin to be used as an analog input pin to "1" 1 : Set to "1" 0 : Set to "0" ■ Continuous Conversion Mode Operation and How to Use It • When a start trigger is input, an A/D conversion starts from the channel set by the A/D conversion start channel selection bits (ANS4 to ANS0) and is performed continuously up to the channel set by the A/D conversion end channel selection bits (ANE4 to ANE0). • When the A/D conversion for the channel set by the A/D conversion end channel selection bits (ANE4 to ANE0) is completed, the A/D conversion is continued by returning to the channel set by the A/D conversion start channel selection bits (ANS4 to ANS0). • To terminate an A/D conversion forcibly, write "0" to the A/D conversion operating flag bit (ADCS:BUSY) in the A/D control status register. [If start channel and end channel are the same] • If the start and end channels are set to the same channel (ADSR: ANS4 to ANS0=ADSR: ANE4 to ANE0), the A/D is repeatedly converted for one channel set as the start channel. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 423 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter MB90860E Series [Conversion order in continuous conversion mode] Table 18.5-2 shows an example of the conversion order in continuous conversion mode. Table 18.5-2 Conversion Order in Continuous Conversion Mode Conversion order in continuous conversion mode Start channel End channel AN0 pin (ADSR: ANS=00000B) AN3 pin (ADSR: ANE=00011B) AN0 → AN1 → AN2 → AN3 → AN0 → Repeat AN3 pin (ADSR: ANS=00011B) AN3 pin (ADSR: ANE=00011B) AN3 → AN3 → Repeat [Restart] To restart A/D conversion during A/D conversion execution or a pause state, terminate the conversion forcibly once and then restart it. Follow the procedure below: 1) Clear the A/D conversion operating flag bit (ADCS:BUSY) 2) Clear the interrupt request flag bit (ADCS:INT) 3) Set the A/D conversion software activation bit (ADCS:STRT) 424 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 18.5.3 Stop Conversion Mode CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter In stop conversion mode, A/D conversion is performed by repeatedly starting and stopping for each channel. When a start trigger is input after an A/D conversion operation stops at the completion of the A/D conversion for the end channel, the A/D conversion is continued by returning to the start channel. ■ Setting for Stop Conversion Mode To operate the 8/10-bit A/D converter in stop conversion mode, the settings shown in Figure 18.5-3 are required. Figure 18.5-3 Setting for Stop Conversion Mode bit15 14 13 12 11 10 ADCS 9 bit8 bit7 6 4 3 2 1 bit0 BUSY INT INTE PAUS STS1 STS0 STRT − MD1 MD0 S10 − − − − 1 ADCR − − − − − − 5 1 Reserved 0 D9 to D0 (Holds conversion results) ADSR ST2 ST1 ST0 CT2 CT1 CT0 ANS4 ANS3 ANS2 ANS1 ANS0 ANE4 ANE3 ANE2 ANE1 ANE0 ADER5 ADE15 ADE14 ADE13 ADE12 ADE11 ADE10 ADE9 ADE8 ADER7/6 ADE23 ADE22 ADE21 ADE20 ADE19 ADE18 ADE17 ADE16 ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 ADE0 − : Undefined : Used bit : Set the bit corresponding to the pin to be used as an analog input pin to "1" 1 : Set to "1" 0 : Set to "0" ■ Stop Conversion Mode Operation and How to Use It • When a start trigger is input, an A/D conversion starts at the channel set by the A/D conversion start channel selection bits (ANS4 to ANS0). The A/D conversion operation stops at the completion of the A/D conversion for one channel. When a start trigger is input while the A/D conversion operation stops, A/D conversion for the next channel is performed. • The A/D conversion operation stops at the completion of the A/D conversion for the channel set by the A/D conversion end channel selection bits (ANE4 to ANE0). When a start trigger is input while the A/D conversion operation stops, the A/D conversion is continued by returning to the channel set by the A/D conversion start channel selection bits (ANS4 to ANS0). • In order to terminate an A/D conversion forcibly, write "0" to the A/D conversion operating flag bit (ADCS:BUSY) in the A/D control status register. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 425 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter MB90860E Series [If start channel and end channel are the same] • If the start and end channels are set to the same channel (ADSR:ANS4 to ANS0=ADSR: ANE4 to ANE0), A/D conversion for one channel set as the start channel (= end channel) and stop are repeated. [Conversion order in stop conversion mode] Table 18.5-3 shows an example of the conversion order in stop conversion mode. Table 18.5-3 Conversion Order in Stop Conversion Mode Start channel End channel Conversion order in stop conversion mode AN0 pin (ADSR: ANS=00000B) AN3 pin (ADSR: ANE=00011B) AN0 → stop start → AN1 → stop start → AN2 → stop start → AN3 → stop start → AN0 → repeat AN3 pin (ADSR: ANS=00011B) AN3 pin (ADSR: ANE=00011B) AN3 → stop start → AN3 → stop start → repeat [Restart] To restart A/D conversion during A/D conversion execution or a pause state, terminate the conversion forcibly once and then restart it. Follow the procedure below: 1) Clear the A/D conversion operating flag bit (ADCS:BUSY) 2) Clear the interrupt request flag bit (ADCS:INT) 3) Set the A/D conversion software activation bit (ADCS:STRT) 426 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter MB90860E Series 18.5.4 Conversion Operation with μDMAC or EI2OS Function The 8/10-bit A/D converter can transfer an A/D conversion result to memory by using the μDMAC or EI2OS function. ■ Conversion Operation with μDMAC/EI2OS Function Figure 18.5-4 shows the conversion operation flow when the μDMAC or EI2OS function is used. Figure 18.5-4 Conversion Operation Flow When μDMAC/EI2OS Function Is Used Activate A/D converter Sample & hold Start A/D conversion End A/D conversion Generate interrupt Activate μDMAC or EI2OS Transfer conversion result Completed a specified number of times? * NO Interrupt clear YES Process interrupt *: The number of times is determined by the DMA or EI2OS setting CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 427 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter 18.5.5 MB90860E Series A/D Conversion Data Protection Function The data protection function is triggered when A/D conversion is performed while interrupt request output is enabled. ■ Explanation of A/D Conversion Data Protection Function in 8/10-bit A/D Converter The A/D conversion data protection function is to prevent unexpectedly failing to take some A/D conversion data. The 8/10-bit A/D converter has one A/D data register (ADCR1/ADCR0) for storing conversion data and one successive approximation circuit for storing the data currently being A/D converted. During A/D conversion execution, the 8/10-bit A/D converter stores conversion data by one bit in the successive approximation circuit, and when the A/D conversion is completed, it stores the A/D conversion result in the A/D data register. The 8/10-bit A/D converter operations with/without using the A/D conversion data protection function are shown below. • When the interrupt request enable bit is set to (ADCS:INTE)=0, the data protection function will be disabled. In this case, if A/D conversion is performed continuously, the 8/10-bit A/D converter stores the conversion result in the A/D data register every time the converter ends the conversion. (This means that the latest conversion data is always stored.) • When the interrupt request enable bit is set to (ADCS:INTE)=1, the data protection function will be valid. If A/D conversion is performed continuously in this state, the interrupt request flag bit is set to ADCS:INT=1 when the first conversion is completed. Then, the next A/D conversion is performed. If the conversion ends with INT=1 state, the 8/10-bit A/D converter enters "pause state" immediately before it transfers the conversion result from the successive approximation circuit to the A/D data register to prevent the conversion data from being overwritten. The pause flag bit (ADCS: PAUS) in the A/D control status register is set to "1" at this time. If the interrupt request flag bit (ADCS:INT) is cleared to "0" during a pause state, the data stored in the successive approximation circuit will be transferred to the A/D data register (see Figure 18.5-5). Figure 18.5-5 Operation of A/D Conversion Data Protection Function A/D (1) conversion time Sampling time Compare time A/D conversion data register ADCR A/D conversion interrupt (INTbit) Sampling time A/D conversion data protection function operation A/D (3) conversion time Compare time A/D (1) conversion result INT=0 A/D conversion data protection function (PAUSbit) 428 A/D (2) conversion time INT=1 A/D (2) conversion result INT clear PAUS=0 PAUS=1 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter ● A/D conversion data protection function for the case A/D conversion result is read by CPU • After an analog input is A/D converted, the interrupt request flag bit (ADCS: INT) in the A/D control status register is set to "1" when the A/D conversion result is stored in the A/D data register (ADCR). • If the interrupt request flag bit (ADCS: INT) that was set at the completion of the previous A/D conversion remains set at the end of the next A/D conversion, the A/C conversion operation pauses to protect the data immediately before overwriting new data to the A/D data register, if interrupt request is enabled (ADCS: INTE=1). • Since interrupt request in the A/D control status register is enabled (ADCS: INTE=1), an interrupt request is generated when the INT bit is set. When the INT bit is cleared, a pause state of the A/D conversion operation will be cancelled. • If A/D conversion is performed continuously, the 8/10-bit A/D converter starts the next A/D conversion operation. At this time, the pause flag bit (ADCS: PAUS) is not cleared to "0" automatically. In order to clear, write 0 to this bit. Notes: • If interrupt request output is disabled (ADCS:INTE=0) during a pause state, this may start A/ D conversion and rewrite the data in the A/D data register. • If A/D conversion is performed continuously for more than once, read the data stored in the A/D data register before clearing the interrupt request flag bit (ADCS:INT). If the interrupt request flag bit (ADCS:INT) is cleared before reading the data stored in the A/D data register when A/D conversion is in a pause state, the first stored conversion data will be overwritten by the next conversion data and destroyed. ● A/D conversion protection function for the case A/D conversion result is transferred by μDMAC/EI2OS After an A/D conversion, if the next A/D conversion ends while the A/D conversion result is being transferred from the A/D data register to memory using the DMA or EI2OS function, the A/D conversion operation pauses to protect data immediately before it overwrites new data to the A/D data register. When an A/D conversion operation pauses, the pause flag bit (ADCS: PAUS) in the A/D control status register is set to "1". When a memory transfer of an A/D conversion result is completed by using the μDMA or EI2OS function, a pause state of A/D conversion will be cancelled. If A/D conversion is performed continuously, the A/D conversion operation is restarted. At this time, the pause flag bit (ADCS: PAUS) is not cleared to "0" automatically. In order to clear, write 0 to this bit. Notes: CM44-10144-4E • Do not clear the interrupt request flag bit (ADCS: INT=0) from CPU when an A/D conversion result is transferred to memory by using the μDMAC or EI2OS function. Otherwise the data in the A/D data register in transfer process may be rewritten. • Do not disable interrupt request output when an A/D conversion result is transferred to memory by using the μDMAC or EI2OS function. If interrupt request output is disabled (ADCS:INTE=0) during a pause state, this may start A/D conversion and rewrite the data in the A/D data register. • Do not restart when an A/D conversion result is transferred to memory using the μDMAC or EI2OS function. If the converter is restarted during a conversion pause state, the conversion result may be destroyed. FUJITSU SEMICONDUCTOR LIMITED 429 CHAPTER 18 8/10-BIT A/D CONVERTER 18.5 Operating Explanation of 8/10-bit A/D Converter MB90860E Series ● Processing flow of A/D conversion data protection function when μDMAC/EI2OS is used Figure 18.5-6 shows the processing flow of the A/D conversion data protection function when μDMAC/ EI2OS is used. Figure 18.5-6 Processing Flow of A/D Conversion Data Protection Function When μDMAC/EI2OS Is Used Set μDMAC or EI2OS Activate A/D continuous conversion Complete the first conversion Store data in A/D data register Activate μDMAC or EI2OS Complete the second conversion μDMAC/ EI2OS end? NO Pause A/D YES Store data in A/D data register Third conversion Activate μDMAC or EI2OS Continue Complete all conversions μDMAC/ EI2OS end? NO Pause A/D YES Activate μDMAC or EI2OS Interrupt processing Stop A/D conversion Note: Flows for A/D converter operation during stop are omitted. 430 End FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 18 8/10-BIT A/D CONVERTER 18.6 Notes on Using 8/10-bit A/D Converter MB90860E Series 18.6 Notes on Using 8/10-bit A/D Converter Note the following points when using the 8/10-bit A/D converter. ■ Notes on Using 8/10-bit A/D Converter ● Analog input pin • The analog input pins serve as general-purpose I/O ports of ports 5 to 7. When using the pin as an analog input pin, switch the pin to analog input pin by setting the analog input enable register (ADER5 to ADER7). • When using the pin as an analog input pin, write "1" to the bit in the analog input enable register (ADER5 to ADER7) corresponding to the pin to be used to set it to analog input enable. • If an intermediate-level signal is input to the pin being set as a general-purpose I/O port, input leakage current will flow in the gate. When using the pin as an analog input pin, be sure to set the pin to analog input enable. ● Note on the case of activating by internal timer or external trigger • In order to activate the 8/10-bit A/D converter by internal timer output or external trigger, set the level of the timer output and external trigger to the inactive side ("H" side for external trigger) when setting the A/D activation trigger selection bits (ADCS: STS1, STS0) in the A/D control status register. Holding the input value of the activation trigger at the active side may cause the converter to start concurrently with the setting of the A/D activation trigger selection bits (ADCS: STS1, STS0) in the A/D control status register. ● Order of turning on the 8/10-bit A/D converter power supply and analog input • Be sure to turn on the digital power supply (VCC) before turning on the 8/10-bit A/D converter power supply and analog inputs (AN0 to AN23 pins). • Turn off the digital power supply after turning off the 8/10-bit A/D power supply and analog inputs. • Turn on and off AVRH in order not to exceed AVCC. ● Supply voltage of 8/10-bit A/D converter • For latch-up prevention, the 8/10-bit A/D converter power supply (AVCC) must not exceed the voltage of the digital power supply (VCC). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 431 CHAPTER 18 8/10-BIT A/D CONVERTER 18.6 Notes on Using 8/10-bit A/D Converter 432 FUJITSU SEMICONDUCTOR LIMITED MB90860E Series CM44-10144-4E CHAPTER 19 CLOCK MONITOR FUNCTION This chapter explains the functions and operations of the clock monitor. 19.1 Overview of Clock Monitor Function 19.2 Block Diagram of Clock Monitor Function 19.3 Configuration of Clock Monitor Function 19.4 Program Example of Clock Monitor Function CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 433 CHAPTER 19 CLOCK MONITOR FUNCTION 19.1 Overview of Clock Monitor Function 19.1 MB90860E Series Overview of Clock Monitor Function The clock monitor function outputs division clock of the machine clock for monitoring from the clock monitor pin (CKOT). ■ Overview of Clock Monitor Function • When the output enable bit of the clock output enable register is set to "1" (CLKR:CKEN=1), the clock is output from the clock monitor pin (CKOT). • The frequency of the clock to be output is set by the output frequency selection bit of the clock output enable register (CLKR: FRQ2 to FRQ0). Table 19.1-1 shows the frequency of the clock to be output using the clock monitor function. Table 19.1-1 Output Frequency for Clock Monitor Function FRQ2 to FRQ0 Bit Clock Output Frequency 000B φ=24MHz φ=16MHz φ=8MHz Cycle Frequency Cycle Frequency Cycle Frequency φ/21 83 ns 12 MHz 125 ns 8 MHz 250 ns 4 MHz 001B φ/22 167 ns 6 MHz 250 ns 4 MHz 500 ns 2 MHz 010B φ/23 333 ns 3 MHz 500 ns 2 MHz 1.0 μs 1 MHz 011B φ/24 667 ns 1.5 MHz 1.0 μs 1 MHz 2.0 μs 500 kHz 100B φ/25 1.3 μs 750 kHz 2.0 μs 500 kHz 4.0 μs 250 kHz 101B φ/26 2.7 μs 375 kHz 4.0 μs 250 kHz 8.0 μs 125 kHz 110B φ/27 5.3 μs 187.5 kHz 8.0 μs 125 kHz 16.0 μs 62.5 kHz 111B φ/28 10.7 μs 93.75 kHz 16.0 μs 62.5 kHz 32.0 μs 31.25 kHz φ: Machine clock frequency 434 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 19 CLOCK MONITOR FUNCTION 19.2 Block Diagram of Clock Monitor Function MB90860E Series 19.2 Block Diagram of Clock Monitor Function The clock monitor function module consists of the following blocks: • Prescaler • Count clock selector • Clock output enable register ■ Block Diagram of Clock Monitor Function Figure 19.2-1 Block Diagram of Clock Monitor Function Internal data bus Prescaler Count clock selector Pin CKOT Output enable Clock output enable register (CLKR) 3 CKEN FRQ2 FRQ1 FRQ0 − : Undefined φ : Machine clock frequency ● Prescaler Divides the machine clock φ and provides it to the count clock selector. ● Count clock selector Selects the clock to be output from 8 types of division clock. ● Clock output enable register Enables the clock output and selects the output frequency. ■ Details of Pin The following shows the detail of the pin of the clock monitor function: CKOT pin: P81/CKOT CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 435 CHAPTER 19 CLOCK MONITOR FUNCTION 19.3 Configuration of Clock Monitor Function 19.3 MB90860E Series Configuration of Clock Monitor Function This section details the pins and registers of the clock monitor function. ■ Pin of Clock Monitor Function The clock monitor pin (CKOT) serve as general-purpose I/O ports. Table 19.3-1 shows the setting to be used in the pin function and clock monitor function. Table 19.3-1 Pin of Clock Monitor Function Pin Name P81/ TOT0/ INT13R/ CKOT 436 Pin Function General-purpose I/O ports / 16-bit reload timer input 0 / External interrupt 13 / Clock monitor output Required Setting for Use of Clock Monitor Function • • • Reload timer output disabled (TMCSR0: OUTE=0) External interrupt 13 disabled (ENIR1: EN13=0) or use P05 instead of P81 (EISSR: INT13R=0) Clock output enabled (CLKR: CKEN=1) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 19 CLOCK MONITOR FUNCTION 19.3 Configuration of Clock Monitor Function MB90860E Series 19.3.1 Clock output enable register (CLKR) Clock output enable register (CLKR) enables the clock output and selects the output frequency. ■ Clock Output Enable Register (CLKR) Figure 19.3-1 Clock Output Enable Register (CLKR) Address 7 6 5 4 00796CH - - - - 3 2 1 0 Initial value CKEN FRQ2 FRQ1 FRQ0 XXXX0000B R/W R/W R/W R/W bit2 bit1 bit0 FRQ2 FRQ1 FRQ0 Output Frequency Select Bit 0 0 0 φ/21 0 0 1 φ/22 0 1 0 φ/23 0 1 1 φ/24 1 0 0 φ/25 1 0 1 φ/26 1 1 0 φ/27 1 1 1 φ/28 bit3 CKEN R/W : Readable/writable X : Undefined Output Enable Bit 0 General-purpose I/O port 1 Clock output : Initial value Table 19.3-2 Functions of Clock Output Enable Register (CLKR) Bit name Function bit7 to bit4 Undefined bit Read : The value is undefined. Write : No effect. bit3 CKEN: Output Enable Bit Enables the output of clock monitor pin (CKOT). When set to "1": Set to the clock monitor pin. When set to "0": Set to general-purpose I/O port. bit2 to bit0 FRQ0, FRQ1, FRQ2: Output frequency select bit Sets the frequency of the clock to be output. The division rate for the machine clock can be selected and set from 8 types. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 437 CHAPTER 19 CLOCK MONITOR FUNCTION 19.4 Program Example of Clock Monitor Function 19.4 MB90860E Series Program Example of Clock Monitor Function This section gives a program example of the clock monitor. ■ Program Example of Clock Monitor ● Processing specification • When the machine clock is φ=24MHz, the clock at the frequency of 750 kHz is output from the CKOT pin. • The bits FRQ2 to FRQ0 are 100B (clock: φ/25). ● Coding example CLKR EQU 00796CH ;Clock output control register ; ;---------Main program--------------------------------------------CODE CSEG START: ; ;Stack pointer (SP), etc., already ;initialized MOV I:CLKR,#00001100B ;Clock output enabled, φ/25 set ; • Processing by user • CODE ENDS END START ;---------Vector setting------------------------------------------VECT CSEG ABS=0FFH ORG 00FFDCH ;Set reset vector DSL START DB 00H ;Set to single-chip mode 438 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART This chapter explains the functions and operations of LIN-UART. 20.1 Overview of LIN-UART 20.2 Configuration of LIN-UART 20.3 Pins of LIN-UART 20.4 Registers of LIN-UART 20.5 Interrupts of LIN-UART 20.6 Baud Rate of LIN-UART 20.7 Operation of LIN-UART 20.8 Notes on Using LIN-UART CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 439 CHAPTER 20 LIN-UART 20.1 Overview of LIN-UART 20.1 MB90860E Series Overview of LIN-UART The LIN (Local Interconnect Network)-UART is a general-purpose serial data communication interface for synchronous or asynchronous (start-stop synchronization) communication with external devices. In addition to a bidirectional communication function (normal mode) and master/slave communication function (multiprocessor mode: supports both master and slave operation), the LIN-UART also supports the special functions used by the LIN bus. ■ Functions of LIN-UART ● Functions of LIN-UART The LIN-UART is a general-purpose serial data communication interface for exchanging serial data with other CPUs and peripheral devices. Table 20.1-1 lists the functions of the LIN-UART. Table 20.1-1 Functions of LIN-UART (1 / 2) Function Data buffer Full-duplex double-buffer Serial input The LIN-UART oversamples received data for 5 times to determine the received value by majority (only asynchronous mode). Transfer mode • Clock synchronization (Select start/stop synchronization, or start/stop bit) • Clock asynchronous (Start/stop bits available) Baud rate • Dedicated baud rate generator provided (made of a 15-bit reload counter) • The external clock can be input and also be adjusted by the reload counter. Data length • 7 bits (not in synchronous or LIN mode) • 8 bits Signal type NRZ (Non Return to Zero) Start bit timing Synchronization with the falling edge of the start bit in asynchronous mode. Reception error detection • Framing error • Overrun error • Parity error (Not supported in operation mode 1 and operation mode 3) Interrupt request • Reception interrupts (reception completed, reception error detected, LIN Synch break detected) • Transmit interrupts (transmit data empty) • Interrupt request to ICU (LIN Synch field detected: LSYN) • Extended intelligent I/O service (EI2OS) and DMA function can be supported for both transmission and reception. Master/slave mode communication function (Multiprocessor mode) Capable of 1 (master) to n (slaves) communication (support both the master and slave system) Synchronous mode Master or slave function 440 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.1 Overview of LIN-UART MB90860E Series Table 20.1-1 Functions of LIN-UART (2 / 2) Function Pin access Serial I/O pin state can be read directly. • • • • • LIN bus option Master device operation Slave device operation LIN Synch break detection LIN Synch break generation Detection of LIN Synch field start/stop edges connected to the input capture 0, 1, 6 and 7 Synchronous serial clock Continuous output to the SCK pin is possible for synchronous communication using the start/stop bits. Clock delay option Special synchronous clock mode for delaying the clock (used for SPI) The LIN-UART operates in four different modes. The operating mode is selected by the MD0 and MD1 bits in the LIN-UART serial mode register (SMR). Modes 0 and 2 are used for bidirectional serial communication; mode 1 for master/slave communication; and mode 3 for LIN master/slave communication. Table 20.1-2 LIN-UART Operating Modes Data length Operating mode No parity 0 Normal mode 1 Multi processor mode 2 Normal mode 3 LIN mode With parity 7 bits or 8 bits Synchronous method Stop bit length Data bit format Asynchronous 1 bit or 2 bits 7 bits or 8 bits +1* — 8 8 — Asynchronous LSB first MSB first Synchronous None, 1 bit, 2 bits Asynchronous 1 bit LSB first — : Unavailable setting * : "+1" is the address/data selection bit (AD) used for communication control in multiprocessor mode. The MD1 and MD0 bits in the LIN-UART serial mode register (SMR) are used to select the following LIN-UART operating modes. Table 20.1-3 LIN-UART Operating Modes CM44-10144-4E MD1 MD0 Mode Type 0 0 0 Asynchronous (Normal mode) 0 1 1 Asynchronous (Multiprocessor mode) 1 0 2 Synchronous (Normal mode) 1 1 3 Asynchronous (LIN mode) FUJITSU SEMICONDUCTOR LIMITED 441 CHAPTER 20 LIN-UART 20.1 Overview of LIN-UART Notes: MB90860E Series • Mode 1 supports both master and slave operation when the master and slave are connected. • Mode 3 is fixed to communication format 8N-1, LSB first. • When the mode is changed, the UART stops transmission/reception and waits until the next communication starts. ■ LIN-UART Interrupts and EI2OS Table 20.1-4 LIN-UART Interrupts and EI2OS Interrupt control register Channel Interrupt No. Vector table address EI2OS Register name Address Lower Upper Bank μDMAC channel LIN-UART0 reception #35(23H) ICR12 0000BCH FFFF70H FFFF71H FFFF72H *1 DRQ10*3 LIN-UART0 transmission #36(24H) ICR12 0000BCH FFFF6CH FFFF6DH FFFF6EH *2 DRQ11 LIN-UART1/3 reception #37(25H) ICR13 0000BDH FFFF68H FFFF69H FFFF6AH *1 DRQ12*3 LIN-UART1/3 transmission #38(26H) ICR13 0000BDH FFFF64H FFFF65H FFFF66H *2 DRQ13 LIN-UART2/4 reception #39(27H) ICR14 0000BEH FFFF60H FFFF61H FFFF62H *1 DRQ14*3 LIN-UART2/4 transmission #40(28H) ICR14 0000BEH FFFF5CH FFFF5DH FFFF5EH *2 DRQ15 *1: ICR12 to ICR14 are shared with multiple interrupt sources; therefore, they are only available when such sources are not used as interrupts. EI2OS stop function is available when a reception error is detected. *2: ICR12 to ICR14 are shared with multiple interrupt sources; therefore, they are only available when such sources are not used as interrupts. *3: DMA stop function is available when a reception error is detected. 442 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 20.2 Configuration of LIN-UART CHAPTER 20 LIN-UART 20.2 Configuration of LIN-UART This section briefly outlines the blocks that form the LIN-UART. ■ LIN-UART Consists of the Following Blocks. • Reload counter • Reception control circuit • Reception shift register • Reception data register (RDR) • Transmission control circuit • Transmit shift register • Transmit data register (TDR) • Error detection circuit • Oversampling circuit • Interrupt generation circuit • LIN Synch break/Synch Field detection circuit • Bus idle detection circuit • LIN-UART serial mode register (SMR) • Serial control register (SCR) • Serial status register (SSR) • Extended communication control register (ECCR) • Extended status control register (ESCR) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 443 CHAPTER 20 LIN-UART 20.2 Configuration of LIN-UART MB90860E Series ■ Block Diagram of LIN-UART Figure 20.2-1 Block Diagram of LIN-UART OTO, EXT, REST CLK PE ORE FRE Transmission clock Reception clock Reload counter SCKn Interrupt generation circuit Transmission control circuit Reception control, twice Pin Start bit detection circuit Transmission start circuit Reception bit counter Transmission bit counter Pin Oversampling circuit Reception parity counter Transmission parity counter RBI TBI Reception IRQ SINn Restart reception reload counter TIE RIE LBIE LBD Transmission TDRE IRQ SOTn Pin RDRF SOTn SINn Internal signal to capture LIN break/ Synch Field detection circuit To DMA/ EI2OS SINn Transmit shift register Reception shift register Transmission start Bus idle detection circuit Error detection circuit PE ORE FRE LIN break generation circuit RDRn LBR LBL1 LBL0 TDRn RBI LBD TBI Internal data bus PE ORE FRE RDRF TDRE BDS RIE TIE SSRn register MD1 MD0 OTO EXT REST UPCL SCKE SOE SMRn register PEN P SBL CL AD CRE RXE TXE SCRn register LBIE LBD LBL1 LBL0 SOPE SIOP CCO SCES LBR ESCRn register MS SCDE SSM ECCRn register RBI TBI n = 0, 1, 2, 3, 4 444 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.2 Configuration of LIN-UART MB90860E Series ■ Explanation of Each Block ● Reload counter This block is a 15-bit reload counter serving as a dedicated baud rate generator. The block consists of a 15bit register for reload values; it generates the transmission/reception clock from the external or internal clock. The count value in the transmission reload counter is read from BGRn1 and BGRn0. ● Reception control circuit This block consists of a reception bit counter, a start bit detection circuit, and a reception parity counter. The reception bit counter counts the reception data bits and sets a flag in the serial status register when one data reception is completed according to the specified data length. If the reception interrupt is enabled at this time, a reception interrupt request is generated. The start bit detection circuit detects a start bit in a serial input signal. When a start bit is detected, the circuit sends a signal to the reload counter in synchronization with the start bit falling edge. The reception parity counter calculates the parity of the received data. ● Reception shift register This register retrieves data received from the SINn pin while bit-shifting and transfers it to the RDR register upon completion of reception. ● Reception data register (RDR) This register retains the received data. Serial input data is converted and stored in the reception data register. ● Transmission control circuit This block consists of a transmission bit counter, a transmission start circuit, and a transmission parity counter. The transmission bit counter counts the transmit data bits and sends 1 data item according to the specified data length. A flag is set in the serial status register when the transmission bit counter starts sending the data to be written. If the transmit interrupt is enabled at this time, a transmit interrupt request is generated. The transmission start circuit starts transmission when data is written to the TDR. The transmission parity counter generates a parity bit for data to be transmitted if the data is parity-checked. ● Transmit shift register The data written to TDR is transferred to the transmit shift register, and output to the SOTn pin while bitshifting. ● Transmit data register (TDR) This register sets the transmit data. The written data is converted to serial data and output. ● Error detection circuit This circuit detects an error upon completion of reception, if any. If an error occurs, the corresponding error flag is set. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 445 CHAPTER 20 LIN-UART 20.2 Configuration of LIN-UART MB90860E Series ● Oversampling circuit In asynchronous mode, the LIN-UART oversamples received data for 5 times to determine the received value by majority. The LIN-UART stops during operation in synchronous mode. ● Interrupt generation circuit This circuit controls all interrupt sources. An interrupt is generated immediately if the corresponding interrupt enable bit has been set. ● LIN Synch break/Synch Field detection circuit This circuit detects a LIN Synch break when the LIN master node transmits a message header. The LBD flag is set when the LIN Synch break is detected. An internal signal (LSYN) is output to the capture in order to detect the 1st and 5th falling edges of the LIN Synch Field and to measure the actual serial clock synchronization transmitted by the master node. ● LIN Synch break generation circuit This circuit generates a LIN Synch break with the specified length. ● Bus idle detection circuit This circuit detects that no transmission or reception is in progress, and generates the TBI and RBI flag bits. ● LIN-UART serial mode register (SMR) Operating functions are as follows: • Selects the LIN-UART operating mode • Selects a clock input source • Selects between 1-to-1 connection or reload counter connection for the external clock • Resets a dedicated reload timer • LIN-UART software reset (maintains register settings) • Enables/disables output to the serial data pin • Enables/disables output to the clock pin ● Serial control register (SCR) Operating functions are as follows: • Sets the availability of the parity bit • Selects the parity bit • Sets the stop bit length • Sets the data length • Selects the frame data format in mode 1 • Clears the error flag • Enable/disable transmission • Enable/disable reception 446 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.2 Configuration of LIN-UART MB90860E Series ● Serial status register (SSR) Operating functions are as follows: • Checks transmission/reception or error status • Selects the transfer direction (LSB first or MSB first) • Enables/disables reception interrupts • Enables/disables transmit interrupts ● Extended status control register (ESCR) • Enables/disables LIN Synch break interrupts • Detects LIN Synch breaks • Selects the LIN Synch break length • Direct access to the SINn and SOTn pins • Sets continuous clock output in LIN-UART synchronous clock mode • Selects the sampling clock edge ● Extended communication control register (ECCR) • Bus idle detection • Synchronous clock setting • LIN Synch break generation CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 447 CHAPTER 20 LIN-UART 20.3 Pins of LIN-UART 20.3 MB90860E Series Pins of LIN-UART This section lists and details the pins, interrupt sources and registers of LIN-UART. ■ Pins of LIN-UART The LIN-UART pins also serve as general-purpose ports. Table 20.3-1 shows their functions and I/O format as well as the settings for when the LIN-UART is used. Table 20.3-1 Pins of LIN-UART Pin name Pin function P82/SIN0 P85/SIN1 P50/SIN2 P12/SIN3 P15/SIN4 Port input/output, serial data input P83/SOT0 P86/SOT1 P51/SOT2 P13/SOT3 P16/SOT4 Port input/output, serial data output P84/SCK0 P87/SCK1 P52/SCK2 P14/SCK3 P17/SCK4 I/O format Pull-up selection Standby control Settings required to use the pin Set to the input port (DDR: corresponding bit = 0) CMOS output, CMOS/auto motive input P12-P17: With pull-up, Others: No pull-up Available Set to enable output (SMRn: SOE = 1) Set to the input port when inputting clock (DDR: corresponding bit = 0) Port input/output, serial clock input/output Set to enable output when outputting clock (SMRn: SCKE = 1) See the Data Sheet "■ Electrical Characteristics - 3 DC Rating" for the rating. 448 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.3 Pins of LIN-UART MB90860E Series ■ Block Diagram of LIN-UART Pins Figure 20.3-1 Block Diagram of LIN-UART Pins Peripheral input Port data register (PDR) Peripheral output Peripheral output enable Internal data bus PDR read Output write P-ch PDR read Pin Port direction register (DDR) N-ch Direction latch General-purpose I/O pin/SIN General-purpose I/O pin/SCK General-purpose I/O pin/SOT DDR write Standby control (SPL = 1) DDR read Standby control: Stop mode (SPL =1), watch mode (SPL =1), time-base timer mode (SPL =1) Note: A peripheral I/O signal is input and output using a pin with a peripheral function. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 449 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART 20.4 MB90860E Series Registers of LIN-UART This section lists the registers of LIN-UART. ■ List of LIN-UART Registers Figure 20.4-1 List of LIN-UART Registers • LIN-UART0 Address: bit15 bit8 bit7 bit0 000021H, 000020H SCR0 (Serial control register) SMR0 (Serial mode register) 000023H, 000022H SSR0 (Serial status register) RDR0/TDR0 (Reception data register / Transmit data register) 000025H, 000024H ESCR0 (Extended status control register) ECCR0 (Extended communication control register) 000027H, 000026H BGR01 (Baud rate generator register) BGR00 (Baud rate generator register) • LIN-UART1 Address: bit15 bit8 bit7 bit0 000029H, 000028H SCR1 (Serial control register) SMR1 (Serial mode register) 00002BH, 00002AH SSR1 (Serial status register) RDR1/TDR1 (Reception data register / Transmit data register) 00002DH, 00002CH ESCR1 (Extended status control register) ECCR1 (Extended communication control register) 00002FH, 00002EH BGR11 (Baud rate generator register) BGR10 (Baud rate generator register) • LIN-UART2 Address: bit15 bit8 bit7 bit0 0000D9H, 0000D8H SCR2 (Serial control register) SMR2 (Serial mode register) 0000DBH, 0000DAH SSR2 (Serial status register) RDR2/TDR2 (Reception data register / Transmit data register) 0000DDH, 0000DCH ESCR2 (Extended status control register) ECCR2 (Extended communication control register) 0000DFH, 0000DEH BGR21 (Baud rate generator register) BGR20 (Baud rate generator register) • LIN-UART3 Address: bit15 bit8 bit7 bit0 007951H, 007950H SCR3 (Serial control register) SMR3 (Serial mode register) 007953H, 007952H SSR3 (Serial status register) RDR3/TDR3 (Reception data register / Transmit data register) 007955H, 007954H ESCR3 (Extended status control register) ECCR3 (Extended communication control register) 007957H, 007956H BGR31 (Baud rate generator register) BGR30 (Baud rate generator register) • LIN-UART4 Address: bit15 bit8 bit7 bit0 007959H, 007958H SCR4(Serial control register) SMR4 (Serial mode register) 00795BH, 00795AH SSR4 (Serial status register) RDR4/TDR4 (Reception data register / Transmit data register) 00795DH, 00795CH ESCR4 (Extended status control register) ECCR4 (Extended communication control register) 00795FH, 00795EH BGR41 (Baud rate generator register) BGR40 (Baud rate generator register) 450 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series 20.4.1 Serial Control Register (SCR) The serial control register (SCR) is used to set parity, select the stop bit length and data length, select the frame data format in mode 1, clear the reception error flag, and enable/disable transmission/reception. ■ Serial Control Register (SCR) Figure 20.4-2 Serial Control Register (SCR) Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 bit7 SCR0 : 000021H PEN P SBL CL SCR1 : 000029H R/W R/W R/W R/W SCR2 : 0000D9H SCR3 : 007951H SCR4 : 007959H AD R/W Initial value bit0 CRE RXE TXE W 00000000B R/W R/W bit8 TXE Transmit enable bit 0 Disables transmission 1 Enables transmission bit9 RXE Reception enable bit 0 Disables reception 1 Enables reception bit10 CRE Reception error flag clear bit Write Read 0 No effect "0" is always read 1 Clears reception error flag (PE, FRE, ORE) bit11 AD Address/data format selection bit 0 Data frame 1 Address frame bit12 CL Data length selection bit 0 7-bit 1 8-bit bit13 SBL Stop bit length selection bit 0 1-bit 1 2-bit bit14 P Even parity 1 Odd parity R/W : Readable/Writable bit15 W : Write only PEN : Initial value CM44-10144-4E Parity selection bit 0 Parity enable bit 0 No parity 1 With parity FUJITSU SEMICONDUCTOR LIMITED 451 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series Table 20.4-1 Functions of Each Bit in Serial Control Register (SCR) (1 / 2) Bit name Function bit15 PEN: Parity enable bit Specifies whether or not to add (at transmission) and detect (at reception) a parity bit. Note: The parity bit is added only in operating mode 0, or in operating mode 2 with the settings that start/stop is set (ECCR:SSM = 1). This bit is fixed to "0" in operation mode 1 and operation mode 3 (LIN). bit14 P: Parity selection bit Sets either odd parity (1) or even parity (0) if the parity bit has been selected (SCR:PEN = 1). bit13 SBL: Stop bit length selection bit Sets the bit length of the stop bit (frame end mark in transmit data) in operating mode 0, 1 (asynchronous) or in operating mode 2 (synchronous) with the settings that start/ stop bit is set (ECCR:SSM = 1). This bit is fixed to "0" in mode 3. Note: At reception, only the first bit of the stop bit is always detected. bit12 CL: Data length selection bit Specifies the data length to be transmitted and received. This bit is fixed to "1" in mode 2 and mode 3. AD: Address/data format selection bit Specifies the data format for the frame to be transmitted and received in multiprocessor mode (mode 1). Write to this bit in master mode; read this bit in slave. • When set to "0": Set to data frame. • When set to "1": Set to address data frame. The value of last received data format is read. Note: See Section "20.8 Notes on Using LIN-UART" for using this bit. CRE: Reception error flag clear bit This bit clears the FRE, ORE, and PE flags in the serial status register (SSR). • Writing "1": Clears the error flag. • Writing "0": No effect. Reading this bit always returns "0". Note: Clear the reception error flag after disabling reception (RXE=0). When the reception error flag is cleared without disabling the reception, the reception is interrupted once at that timing and then it restarts. Therefore, when the reception is restarted, Incorrect data might be received. RXE: Reception enable bit Enables or disables the reception of LIN-UART. • Setting to "0": Disables reception. • Setting to "1": Enables reception. The LIN Synch break detection in mode 3 is not affected. Notes: • When the reception is disabled (RXE = 0) during reception, the reception halts immediately. In that case, the data is not guaranteed. • When the transmission is disabled (TXE = 0) during reception while ECCR:MS=0 in operation mode 2, the reception (RXE=0) must also be disabled. bit11 bit10 bit9 452 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series Table 20.4-1 Functions of Each Bit in Serial Control Register (SCR) (2 / 2) Bit name bit8 TXE: Transmit enable bit CM44-10144-4E Function Enables or disables the transmission of LIN-UART. • Setting to "0": Disables transmission. • Setting to "1": Enables transmission. Notes: • When the transmission is disabled (TXE = 0) during transmission, the transmission halts immediately. In that case, the data is not guaranteed. • Prior to enabling the transmission (TXE=1) while ECCR:MS=1 in operation mode 2, serial clock must first be set to the mark level. FUJITSU SEMICONDUCTOR LIMITED 453 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART 20.4.2 MB90860E Series LIN-UART Serial Mode Register (SMR) The LIN-UART serial mode register (SMR) is used to select the operating mode, specify the baud rate clock, and enable/disable output to the serial data and clock pins. ■ LIN-UART Serial Mode Register (SMR) Figure 20.4-3 Serial Mode Register (SMR) Address SMR0:000020H SMR1:000028H SMR2:0000D8H SMR3:007950H SMR4:007958H bit15 bit8 bit7 bit6 bit5 bit4 bit2 bit3 bit1 bit0 Initial value MD1 MD0 OTO EXT REST UPCL SCKE SOE 00000000B R/W R/W R/W R/W W W R/W R/W bit0 SOE LIN-UART serial data output enable bit 0 General-purpose I/O port 1 LIN-UART serial data output pin bit1 SCKE LIN-UART serial clock output enable bit 0 General-purpose I/O port or LIN-UART clock input pin 1 LIN-UART serial clock output pin bit2 UPCL LIN-UART programmable clear bit Write 0 No effect 1 LIN-UART reset Read "0" is always read bit3 REST Reload counter restart bit Write 0 No effect 1 Restarts the reload counter Read "0" is always read bit4 EXT External serial clock source selection bit 0 Uses the baud rate generator (reload counter) 1 Uses the external serial clock source bit5 OTO R/W : Readable/Writable W : Write only 1-to-1 external clock input enable bit 0 Uses the baud rate generator (reload counter) 1 Uses the external clock directly bit7 bit6 MD1 MD0 0 0 Operating mode setting bit Mode 0: Asynchronous normal 0 1 Mode 1: Asynchronous multiprocessor 1 0 Mode 2: Synchronous 1 1 Mode 3: Asynchronous LIN : Initial value 454 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series Table 20.4-2 Functions of Each Bit in Serial Mode Register (SMR) Bit name Function bit7, bit6 MD1, MD0: Operating mode selection bits These bits set the operating mode. Note: The operating mode must be set while LIN-UART is not in operation. Data transmitted/received while setting the operating mode cannot be guaranteed of its integrity. If changing mode setting configuration after writing to the transmission data register (TDR), TDR becomes write-disabled, and the transmission data empty flag (SSR:TDRE) is set. bit5 OTO: 1-to-1 external clock enable bit Writing "1" enables the external clock to be used directly as the LIN-UART serial clock. It is used for slave operation (ECCR:MS = 1) in operating mode 2. When EXT = 0, the OTO bit is fixed to "0". bit4 EXT: External serial clock selection bit Selects a clock input. Setting to "0" selects the clock of the internal baud rate generator (reload counter), while setting to "1" selects the external serial clock source. bit3 REST: Reload counter restart bit Writing "1" restarts the reload counter. Writing "0" has no effect. "0" is always read. UPCL: LIN-UART programmable clear bit (LIN-UART software reset) Writing "1" resets the LIN-UART immediately (LIN-UART software reset). Note however that the register settings are maintained. At that time, transmission and reception are suspended. All of the transmit/reception interrupt sources (TDRE, RDRF, LBD, PE, ORE, FRE) are reset. Reset the LIN-UART after the interrupt and transmission are disabled. Also, the reception data register is cleared (RDR = 00H), and the reload counter is restarted. Writing "0" to this bit has no effect. Reading this bit always returns "0". Note: Execute LIN-UART software reset (UPCL=1) when the TXE bit of the serial control register (SCR) is "0". SCKE: LIN-UART serial clock output enable bit Controls the serial clock I/O port. When "0" is written, the SCKn pin works as a general-purpose I/O port or a serial clock input pin. When "1" is written, this pin serves as the serial clock output pin and outputs the clock in operating mode 2. When ECCR:MS=1, the SCKE bit is fixed to "0". Note: When the SCKn pin is used as a serial clock input (SCKE = 0), set the corresponding DDR bits in the general-purpose I/O port as an input port. Also, select the external clock (EXT = 1) by using the clock selection bit. Reference: When the SCKn pin is set as a serial clock output (SCKE = 1), this pin works as a serial clock output pin regardless of the state of the general-purpose I/O port. SOE: LIN-UART serial data output enable bit Enables or disables output of serial data. When "0" is set, the SOTn pin serves as a general-purpose I/O port. When "1" is set, it works as a serial data output pin (SOTn). Reference: When set as a serial data output (SOE = 1), the SOTn pin works as a SOTn pin regardless of the state of a general-purpose I/O port. bit2 bit1 bit0 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 455 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART 20.4.3 MB90860E Series Serial Status Register (SSR) The serial status register (SSR) is used to check the status of transmission/ reception or error, and to enable/disable interrupts. ■ Serial Status Register (SSR) Figure 20.4-4 Serial Status Register (SSR) Address bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 bit7 SSR0:000023H PE ORE FRE RDRF TDRE BDS RIE TIE SSR1:00002BH SSR2:0000DBH R R R R R R/W R/W R/W SSR3:007953H bit8 SSR4:00795BH TIE 0 1 bit0 Initial value 00001000B Transmit interrupt enable bit Disables transmit interrupts. Enables transmit interrupts. bit9 RIE Reception interrupt enable bit 0 Disables reception interrupts. 1 Enables reception interrupts. bit10 BDS Transfer direction selection bit 0 LSB first (transfer from the least significant bit) 1 MSB first (transfer from the most significant bit) bit11 TDRE Transmit data empty flag bit 0 Transmit data register (TDR) contains data. 1 Transmit data register (TDR) is empty. bit12 RDRF Reception data full flag bit 0 Reception data register (RDR) is empty. 1 Reception data register (RDR) contains data. bit13 FRE Framing error flag bit 0 No framing error 1 Framing error exists. bit14 ORE Overrun error flag bit 0 No overrun error 1 Overrun error exists. bit15 PE R/W : Readable/Writable R : Read only Parity error flag bit 0 No parity error 1 Parity error exists. : Initial value 456 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series Table 20.4-3 Functions of Each Bit in Serial Status Register (SSR) (1 / 2) Bit name Function bit15 PE: Parity error flag bit • This bit is set to "1" when a parity error occurs during reception with PE = 1, and cleared by writing "1" to the CRE bit in the LIN-UART serial control register (SCR). • Outputs a reception interrupt request when both PE bit and RIE bit are "1". • When this flag is set, the data in the reception data register (RDR) is invalid. bit14 ORE: Overrun error flag bit • This bit is set to "1" when an overrun occurs during reception, and cleared by writing "1" to the CRE bit in the LIN-UART serial control register (SCR). • Outputs a reception interrupt request when both ORE bit and RIE bit are "1". • When this flag is set, the data in the reception data register (RDR) is invalid. bit13 FRE: Framing error flag bit • This bit is set to "1" when a framing error occurs during reception, and cleared by writing "1" to the CRE bit in the LIN-UART serial control register (SCR). • Outputs a reception interrupt request when both FRE bit and RIE bit are "1". • When this flag is set, the data in the reception data register (RDR) is invalid. Note: When SCR:SBL is 1, and a framing error is detected at the first or second bit (stop bit), this bit is set to "1" regardless of which stop bit. Therefore, it is necessary to determine whether the reception data is valid or invalid at the second stop bit. bit12 RDRF: Reception data full flag bit • This flag shows the status of the reception data register (RDR). • This bit is set to "1" when received data is loaded into RDR, and cleared to "0" by reading the reception data register (RDR). • Outputs a reception interrupt request when both RDRF bit and RIE bit are "1". TDRE: Transmit data empty flag bit • This flag shows the status of the transmit data register (TDR). • This bit is set to "0" by writing the transmit data to TDR, and indicates that the TDR has valid data. This bit is set to "1" when data is loaded into the transmit shift register and the transmission starts, and indicates that the TDR does not have valid data. • Outputs a transmit interrupt request when both TDRE bit and TIE bit are "1". • When the TDRE bit is "1", setting the LBR bit in the extended communication control register (ECCR) to "1" changes the TDRE bit to "0". Then, the TDRE bit goes back to "1" after LIN Synch break is generated. Notes: • The initial state is TDRE = 1. • If operating mode (SMR.MD[1:0]) is set after TDRE=0 is initiated by writing to the transmission data register (TDR), transmitted data becomes null, and TDRE is set to "1". BDS: Transfer direction selection bit • Specifies whether the transfer serial data is transferred from the least significant bit (LSB first, BDS = 0) or from the most significant bit (MSB first, BDS = 1). It is fixed to "0" in mode 3. Note: Data values are exchanged between the upper and lower when reception data is written to the reception data register (RDR). Consequently, if the BDS bit is rewritten after reception data is written to RDR, the RDR data will be invalid. bit11 bit10 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 457 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series Table 20.4-3 Functions of Each Bit in Serial Status Register (SSR) (2 / 2) Bit name Function bit9 RIE: Reception interrupt request enable bit • Enables or disables the output of a reception interrupt request to the CPU. • Outputs a reception interrupt request when both the RIE bit and the reception data flag bit (RDRF) are "1", or when one or more error flag bits (PE, ORE, FRE) is "1". bit8 TIE: Transmit interrupt request enable bit • Enables or disables the output of a transmit interrupt request to the CPU. • Outputs a transmit interrupt request when both TIE bit and TDRE bit are "1". 458 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series 20.4.4 Reception Data Register / Transmit Data Register (RDR/TDR) The reception and transmit data registers are located at the same address. If read, they work as the reception data register; if written, they work as the transmit data register. ■ Bit Configuration of Reception Data Register / Transmit Data Register (RDR/TDR) Figure 20.4-5 shows the bit configuration of the reception register. Figure 20.4-5 Reception Data Register / Transmit Data Register (RDR/TDR) Address RDR0/TDR0: 000022H RDR1/TDR1: 00002AH RDR2/TDR2: 0000DAH RDR3/TDR3: 007952H RDR4/TDR4: 00795AH bit 7 6 5 4 3 2 1 0 Initial value 00000000B [RDR] 11111111B [TDR] R/W R/W R/W R/W R/W R/W R/W R/W bit7 to bit0 R/W: Readable/Writable R/W Data register Read Reads from the reception data register Write Writes to the transmit data register ■ Reception Data Register (RDR) The reception data register (RDR) is the data buffer register for the serial data reception. The serial data signal sent to the serial input pin (SINn pin) is converted via a shift register and stored in the reception data register (RDR). If the data length is 7 bits, the upper 1 bit (RDR:D7) is "0". The reception data full flag bit (SSR:RDRF) is set to "1" when received data is stored into the reception data register (RDR). If the reception interrupt is enabled (SSR:RIE = 1), a reception interrupt request is generated. Read the reception data register (RDR) when the reception data full flag bit (SSR:RDRF) is "1". The reception data full flag bit (SSR:RDRF) is automatically cleared to "0" by reading the reception data register (RDR). Also, the reception interrupt is cleared when the reception interrupt is enabled and no error occurs. When the reception error occurs (any of SSR:PE, ORE, or FRE is "1"), the data in the reception data register (RDR) is invalid. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 459 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series ■ Transmit Data Register (TDR) The transmit data register (TDR) is the data buffer register for the serial data transmission. If the data to be transmitted is written to the transmit data register (TDR) when transmission is enabled (SCR:TXE = 1), the transmit data is transferred to the transmit shift register, converted to serial data, and output from the serial data output pin (SOTn pin). If the data length is 7 bits, the data in the upper 1 bit (TDR:D7) is invalid. The transmit data empty flag (SSR:TDRE) is cleared to "0" when transmit data is written to the transmit data register (TDR). The transmit data empty flag (SSR:TDRE) is set to "1" after the data is transferred to the transmit shift register and the transmission starts. If the transmit data empty flag (SSR:TDRE) is "1", the next transmit data can be written. If the transmit interrupt is enabled, a transmit interrupt is generated. The next transmit data should be written when the transmit interrupt is generated or the transmit data empty flag (SSR:TDRE) is in a state of "1". Note: 460 The transmit data register is a write-only register; the reception data register is a read-only register. Since both registers are located at the same address, the write value and read value are different. Thus, read-modify-write (RMW) instructions such as the INC/DEC instruction cannot be used. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series 20.4.5 Extended Status Control Register (ESCR) The extended status control register (ESCR) has the settings for enabling/ disabling LIN Synch break interrupt, LIN Synch break length selection, LIN Synch break detection, direct access to the SINn and SOTn pins, continuous clock output in LIN-UART synchronous clock mode and sampling clock edge. ■ Bit Configuration of Extended Status Control Register (ESCR) Figure 20.4-6 shows the bit configuration of the extended status control register (ESCR). Table 20.4-4 shows the function of each bit. Figure 20.4-6 Bit Configuration of Extended Status Control Register (ESCR) Address bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 ESCR0 : 000025H LBIE LBD LBL1 LBL0 SOPE SIOP CCO SCES ESCR1 : 00002DH ESCR2 : 0000DDH R/W R/W R/W R/W R/W R/W R/W R/W ESCR3 : 007955H ESCR4 : 00795DH Sampling clock edge selection bit (mode 2) Sampling at the rising edge of the clock (normal) Sampling at the falling edge of the clock (inverted clock) bit9 CCO 0 1 Continuous clock output enable bit (mode 2) Disables continuous clock output Enables continuous clock output 0 1 Serial I/O pin access setting bit Write (SOPE = 1) Read Fixes SOTn pin to "0" Read the value of SINn pin Fixes SOTn pin to "1" bit11 SOPE 0 1 Serial output pin direct access enable bit Disables serial output pin direct access Enables serial output pin direct access bit12 LBL0 0 1 0 1 bit13 LBL1 0 0 1 1 bit14 LBD 0 1 : Readable/Writable : Undefined 00000X00B bit8 SCES 0 1 bit10 SIOP R/W X Initial value bit 0 bit15 LBIE 0 1 LIN Synch break length selection bits 13 bits 14 bits 15 bits 16 bits LIN Synch break detection flag bit Write Read Clears LIN Synch break No LIN Synch break detection flag detection No effect With LIN Synch break detection LIN Synch break detection interrupt enable bit Disables LIN Synch break detection interrupt Enables LIN Synch break detection interrupt : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 461 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series Table 20.4-4 Functions of Each Bit in Extended Status Control Register (ESCR) Bit name Function LBIE: LIN Synch break detection interrupt enable bit This bit enables or disables LIN Synch break detection interrupts. An interrupt is generated when the LIN Synch break detection flag (LBD) is "1" and the interrupt is enabled (LBIE = 1). This bit is fixed to "0" in mode 1 and mode 2. bit14 LBD: LIN Synch break detection flag bit This bit is set to "1" when the LIN Synch break is detected in operating mode 3 (the serial input is "0" when bit width is 11 bits or more). Also, writing "0" clears the LBD bit and the interrupt. Although the bit is always read as "1" when the RMW instruction is executed, this does not indicate that a LIN Synch break has been detected. Note: To detect a LIN Synch break, enable the LIN Synch break detection interrupt (LBIE = 1), and then disable the reception (SCR:RXE = 0). bit13, bit12 LBL1/0: LIN Synch break length selection bits These bits specify the bit length for the LIN Synch break generation time. The LIN Synch break length for reception is always 11 bits. bit11 SOPE: Serial output pin direct access enable bit* Setting this bit to "1" when serial data output is enabled (SMR:SOE = 1) enables direct writing to the SOTn pin.* SIOP: Serial I/O pin direct access bit* Normal read instruction always returns the value of the SINn pin. When direct access to the serial output pin is enabled (SOPE = 1), the SOTn pin reflects the value written to this bit. Notes: • The bit operation instruction returns the bit value of the SOTn pin in the read cycle.* • A set value of this bit is effective only for the TXE bit of serial control register (SCR) is "0". CCO: Continuous clock output enable bit If the SCKn pin is set to output clock when operating mode 2 and master setting are selected, this will enable the continuous serial clock output from the SCKn pin. Notes: When the CCO bit is "1", the SSM bit in the ECCR should be set to "1". Set up the SCK pin to output clock (SMR:SCKE=1). If the CCO bit is set to "1", add the start/stop bit (ECCR:SSM=1). • This bit should be set to "0" while in operation mode 0, 1, 3, as well as under slave setting in operation mode 2. • While serial clock output is enabled (SMR:SCKE="1"), and the CCO and SCES bits are set under the following circumstances, specified clock width may not be output to serial clock output pin (SCK pin) immediately after switching of serial clock output. Afterward, normal output is expected. • The SCES bit is changed while the CCO bit is set to "1" • The CCO bit and SCES bit are modified simultaneously • The CCO bit is changed from "1" to "0" SCES: Sampling clock edge selection bit When SCES is set to "1" in operating mode 2 with the slave setting, the sampling edge switches from the rising edge to the falling edge. When the SCKn pin is set to output clock in operating mode 2 with the master setting (ECCR:MS=0), the internal serial clock and the output clock signal are inverted. This bit should be fixed to "0" in operating modes 0, 1, and 3. Note: When SCES bit is "1", it is prohibited to occur software reset. And change this bit only when transferring and receiving is disabled. bit15 bit10 bit9 bit8 462 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series *: Table 20.4-5 Interaction Between SOPE and SIOP SOPE SIOP Write to SIOP Read from SIOP 0 R/W No effect (but the write value is retained) Return the SINn value 1 R/W Write "0" or "1" to SOTn Return the SINn value 0 RMW No effect (but the write value is retained) Return the SOTn value 1 RMW Write "0" or "1" to SOTn Return the SOTn value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 463 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART 20.4.6 MB90860E Series Extended Communication Control Register (ECCR) The extended communication control register (ECCR) is used for the bus idle detection, the synchronous clock setting, and the LIN Synch break generation. ■ Bit Configuration of Extended Communication Control Register (ECCR) Figure 20.4-7 shows the bit configuration of the extended communication control register (ECCR). Table 20.4-6 shows the function of each bit. Figure 20.4-7 Bit Configuration of Extended Communication Control Register (ECCR) Address bit15 ECCR0:000024H ECCR1:00002CH ECCR2:0000DCH ECCR3:007954H ECCR4:00795CH bit8 bit7 bit6 bit5 LBR W bit4 bit3 bit2 bit1 bit0 MS SCDE SSM RBI TBI R/W R/W R/W R R Initial value X0000XXXB bit0 TBI* 0 1 Transmit bus idle detection flag bit In transmission No transmission bit1 RBI* 0 1 Reception bus idle detection flag bit In reception No reception bit2 Unused bit The read value is "0". Always write "0". bit3 SSM 0 1 bit4 SCDE 0 1 bit5 MS 0 1 bit6 LBR 0 1 R/W R W X : Readable/Writable : Read only : Write only : Undefined Start/stop enable bit (mode 2) No start/stop bit With start/stop bit Serial clock delay enable bit (mode 2) Disables clock delay Enables clock delay Master/slave function selection bit (mode 2) Master mode (serial clock generation) Slave mode (external serial clock reception) LIN Synch break generation bit Write Read No effect "0" always read LIN Synch break generation bit7 Unused bit The read value is "0". Always write "0". : Initial value *: Not used when SSM is "0" in operating mode 2 464 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART MB90860E Series Table 20.4-6 Functions of Each Bit in Extended Communication Control Register (ECCR) Bit name Function bit7 Unused bit This bit is unused. The read value is undefined. Always write "0". bit6 LBR: Lin Synch break generation bit Setting this bit to "1" in mode 3 generates a LIN Synch break which has the length specified by LBL 0/1 in the ESCR. Set the bit to "0" in mode 0. MS: Master/slave mode selection bit In mode 2, the master or slave can be selected. When MS is set to "0" (master mode selected), a synchronous clock is generated. When MS is set to "1" (slave mode selected), the external serial clock is received. In modes 0, 1 and 3, it is fixed to "0". Modify this bit only when the SCR:TXE bit is "0". Note: When slave mode is selected, set the clock source to the external clock to enable the input of the external clock. (SMR:SCKE=0, EXT=1, OTO=1) SCDE: Serial clock delay enable bit Setting the SCDE bit to "1" in the master mode operation during mode 2 outputs a delayed serial clock as shown in Figure 20.7-5. This bit is effective in SPI. In modes 0, 1 and 3, it is fixed to "0". Note: Use "0" under slave mode (MS=1) in operation mode 2. Setting this bit to "1" is disabled while ESCR:CCO="1", and serial clock will not be delayed. bit3 SSM: Start/stop bit mode enable bit This bit adds the start/stop bit to the synchronous data format when set to "1" in mode 2. In modes 0, 1 and 3, it is fixed to "0". • When "0" is set: start/stop bit is not added. • When "1" is set: upon transmitting, start/stop bit is added. Upon receiving, start bit is detected, and receiving initiated. Stop bit is used to detect framing errors. bit2 Unused bit This bit is unused. The read value is undefined. Always write "0". bit1 RBI: Reception bus idle detection flag bit This bit is set to "1" when the SIN pin is set to "H" level and reception is not performed. Do not use this bit in operating mode 2. bit0 TBI: Transmit bus idle detection flag bit This bit is set to "1" when there is no transmission at the SOTn pin. Use this bit under master mode (MS=0) in operation mode 2. bit5 bit4 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 465 CHAPTER 20 LIN-UART 20.4 Registers of LIN-UART 20.4.7 MB90860E Series Baud Rate Generator Register 0, 1 (BGRn0/BGRn1) The baud rate generator register 0, 1 (BGRn0/BGRn1) sets the division ratio of the serial clock. Moreover, the count value in the transmit reload counter is read from this generator. ■ Bit Configuration of Baud Rate Generator Register (BGRn0/BGRn1) Figure 20.4-8 shows the bit configuration of the baud rate generator register (BGRn0/BGRn1). Figure 20.4-8 Bit Configuration of Baud Rate Generator Register (BGRn0/BGRn1) Address BGR00: 000026H BGR01: 000027H BGR10: 00002EH BGR11: 00002FH BGR20: 0000DEH BGR21: 0000DFH BGR30: 007956H BGR31: 007957H BGR40: 00795EH BGR41: 00795FH Initial value bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 00000000B 00000000B R 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 bit7 to bit0 Write Read Baud rate generator register n0 Write to reload counter bits 0 to 7. Read transmit reload counter bits 0 to 7. bit14 to bit8 Write Read Baud rate generator register n1 Write to reload counter bits 8 to 14. Read transmit reload counter bits 8 to 14. bit15 Unused bit The read value is "0". Writing has no effect on operation. R/W : Readable/Writable R : Read only n = 0, 1, 2, 3, 4 The baud rate generator register sets the division ratio of the serial clock. BGRn1 is associated with the upper bits; BGRn0 is associated with the lower bits. The reload value of the counter can be written and the transmit reload counter value can be read from them. Byte/word access is also possible. Writing a reload value other than "0" to the baud rate generator registers causes the reload counter to start counting. 466 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART MB90860E Series 20.5 Interrupts of LIN-UART The LIN-UART has reception interrupts and transmit interrupts, which are generated by following interrupt sources. • When received data is set in the reception data register (RDR), or when a reception error occurs • When transmit data is transferred from the transmit data register (TDR) to the transmit shift register and the transmission starts • When a LIN Synch break is detected Each interrupt supports the extended intelligent I/O service (EI2OS) and DMA. ■ Interrupts of LIN-UART Table 20.5-1 shows the interrupt control bits and interrupt sources of the LIN-UART. Table 20.5-1 Interrupt Control Bits and Interrupt Sources of LIN-UART TX/RX/ Capture Interrupt request flag bit Flag register Operating mode Interrupt source 0 1 2 3 Interrupt source Enable bit Reading reception data, Writing "1" to programmable reset bit SMR:UPCL) RDRF SSR ❍ ❍ ❍ ❍ Writing reception data to RDR ORE SSR ❍ ❍ ❍ ❍ Overrun error FRE SSR ❍ ❍ ❍ Framing error PE SSR ❍ × × Parity error ❍ Detecting LIN Synch ESCR:LBIE break Writing "0" to ESCR:LBD, Writing "1" to programmable reset bit (SMR:UPCL) Transmit register being SSR:TIE empty Writing SSR:TIE transmit data; writing "1" to LIN Synch bread generation bit (ECCR:LBR) 1st falling edge in LIN Synch field ICS01:ICE0/1 5th falling edge in LIN ICS67:ICE6/7 Synch field Disabling ICP0/1/6/7 SSR:RIE RX LBD Input capture ❍ ESCR × × × TDRE SSR ❍ ❍ ❍ ❍ ICP0/1/6/7 ICS01/ ICS67 × × × ❍ ICP0/1/6/7 ICS01/ ICS67 × × × ❍ TX Clearing interrupt request flag Writing "1" to reception error flag clear bit (SCR:CRE), Writing "1" to programmable reset bit (SMR:UPCL) : Used bit × : Unused bit : Available only when ECCR:SSM=1 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 467 CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART MB90860E Series ● Reception interrupts Each flag bit in the serial status register (SSR) is set to "1" when any of the following operation occurs in reception mode: Data reception completed When the reception data is transferred from the reception shift register to the reception data register (RDR) (RDRF = 1) Overrun error When RDRF is 1, and the next reception data is transferred from the reception shift register to the reception data register (RDR) (ORE=1) without RDR being read by the CPU Framing error Stop bit reception error (FRE=1) Parity error Parity detection error (PE=1) A reception interrupt request is generated if the reception interrupt is enabled (SSR:RIE=1) when any of the above flag bits is "1". The RDRF flag is automatically cleared to "0" by reading the reception data register (RDR). All of error flags are cleared to "0" by writing "1" to the reception error flag clear bit (CRE) in the serial control register (SCR). Note: Disable reception (RXE=0) and then clear reception error flags in CRE bit. If the reception error flag is cleared without disabling reception, the reception is interrupted once at that timing and then the reception is resumed. By this operation, some data may not be received normally at the resumption. ● Transmit Interrupts The transmit data register empty flag bit (TDRE) in the serial status register (SSR) is set to "1" when the transmit data is transferred from the transmit data register (TDR) to the transmit shift register, and the transmission starts. If the transmit interrupt is enabled (SSR:TIE=1) in this case, a transmit interrupt request is generated. Note: Since the initial value of TDRE is "1" after hardware/software reset, an interrupt is generated immediately after the TIE bit is set to "1". Moreover, the TDRE is cleared by writing data to the transmit data register (TDR), or by writing "1" to the LIN Synch break generation bit (ECCR:LBR). ● LIN Synch break interrupts This works for LIN slave operation in operation mode 3. The LIN Synch break detection flag bit (LBD) in the extended status control register (ESCR) is set to "1" when the bus (serial input) is "0" for 11 bits or longer. The LIN Synch break interrupt and the LBD flag are cleared by writing "0" to the LBD flag. The LBD flag must be cleared before the capture interrupt is generated in the LIN Synch field. To detect a LIN Synch break, the reception must be disabled (SCR:RXE=0). 468 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART MB90860E Series ● LIN Synch field edge detection interrupt This works for LIN slave operation in operation mode 3. After a LIN Synch break is detected, the internal signal is set to "1" at the first falling edge of the LIN Synch field, and set to "0" after the fifth falling edge. When the capture side is configured to input the internal signal (ICU0/1/6/7) and to detect both edges, an input capture interrupt is generated if enabled. The difference in the count values detected by the capture function corresponds to the 8 bits in the master serial clock. The new baud rate can be calculated from this value. When a falling edge of the start bit is detected, the reload counter restarts automatically. ■ LIN-UART Interrupts and EI2OS Table 20.5-2 LIN-UART Interrupts and EI2OS Interrupt control register Channel Vector table address EI2OS Interrupt No. Register name Address Lower Upper Bank DMA channel LIN-UART0 reception #35(23H) ICR12 0000BCH FFFF70H FFFF71H FFFF72H *1 DRQ10*3 LIN-UART0 transmission #36(24H) ICR12 0000BCH FFFF6CH FFFF6DH FFFF6EH *2 DRQ11 LIN-UART1/3 reception #37(25H) ICR13 0000BDH FFFF68H FFFF69H FFFF6AH *1 DRQ12*3 LIN-UART1/3 transmission #38(26H) ICR13 0000BDH FFFF64H FFFF65H FFFF66H *2 DRQ13 LIN-UART2/4 reception #39(27H) ICR14 0000BEH FFFF60H FFFF61H FFFF62H *1 DRQ14*3 LIN-UART2/4 transmission #40(28H) ICR14 0000BEH FFFF5CH FFFF5DH FFFF5EH *2 DRQ15 *1: ICR12 to ICR14 are shared with multiple interrupt sources; therefore, they are only available when such sources are not used as interrupts. EI2OS stop function is available when a reception error is detected. *2: ICR12 to ICR14 are shared with multiple interrupt sources; therefore, they are only available when such sources are not used as interrupts. *3: DMA stop function is available when a reception error is detected. ■ EI2OS Function of LIN-UART LIN-UART has a circuit supporting the EI2OS. As a result, the EI2OS can be activated individually for each reception/transmit interrupt. ● Reception As the interrupt control register is also shared by transmit interrupts and other UART, the EI2OS is available only when no other interrupts are enabled. ● Transmission As the interrupt control register is also shared by reception interrupts and other UART, the EI2OS is available only when no other interrupts are enabled. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 469 CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART 20.5.1 MB90860E Series Timing of Reception Interrupt Generation and Flag Set Reception interrupts include a reception completion (SSR:RDRF) and an occurrence of a reception error (SSR:PE, ORE, FRE). ■ Timing of Reception Interrupt Generation and Flag Set Received data is stored in the reception data register (RDR) when the first stop bit is detected in mode 0, 1, 2 (SSM=1), 3, or when the last data bit is detected in mode 2 (SSM=0). Each error flag is set when a reception is completed (SSR:RDRF=1), or when a reception error occurs (SSR:PE, ORE, FRE = 1). If the reception interrupt is enabled (SSR:RIE=1) at this time, a reception interrupt is generated. Note: When a reception error occurs in each mode, the data in the reception data register (RDR) is invalid. Figure 20.5-1 shows the timing of reception and flag set. Figure 20.5-1 Timing of Reception and Flag Set Reception data (Mode 0/Mode 3) ST D0 D1 D2 … D5 D6 D7/P SP ST Reception data (Mode 1) ST D0 D1 D2 … D6 D7 AD SP ST D0 D1 D2 … D4 D5 D6 D7 D0 Reception data (Mode 2) PE*1, FRE RDRF ORE*2 (RDRF = 1) Reception interrupts generated *1: PE flag is always "0" in mode 1 and mode 3. *2: An overrun error occurs if the next data is transferred before received data is read (RDRF = 1). ST: Start bit, SP: Stop bit, AD: Mode 1 (multiprocessor) address data selection bit Note: Figure 20.5-1 does not show all receptions in mode 0. It only shows examples for "7P1" and "8N1" (P = "even parity" or "odd parity"). Figure 20.5-2 ORE Flag Set Timing Reception data RDRF ORE 470 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART MB90860E Series 20.5.2 Timing of Transmit Interrupt Generation and Flag Set Transmit interrupts are generated when the transmit data is transferred from the transmit data register (TDR) to the transmit shift register and then the transmission starts. ■ Timing of Transmit Interrupt Generation and Flag Set When the data written to the transmit data register (TDR) is transferred to the transmit shift register and then the transmission starts, the next data becomes writable (SSR:TDRE=1). If the transmit interrupt is enabled (SSR:TIE=1) at this time, a transmit interrupt is generated. TDRE bit is a read-only bit and cleared to "0" only by writing data to the transmit data register (TDR). Figure 20.5-3 shows the timing of the transmission and flag set in each LIN-UART mode. Figure 20.5-3 Timing of Transmission and Flag Set Transmit interrupt generated Transmit interrupt generated Mode 0, Mode1, Mode2 (SSM=1) or Mode 3: Write to TDR TDRE Serial output ST D0 D1 D2 D3 D4 D5 D6 D7 P SP ST D0 D1 D2 D3 D4 D5 D6 D7 P SP AD AD Transmit interrupt generated Transmit interrupt generated Mode 2 (SSM=0): Write to TDR TDRE Serial output D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 ST: Start bit, D0 to D7: Data bits, P: Parity (SSM=1 in modes 0 and 2), SP: Stop bit AD: Address data selection bit (mode 1) Note: CM44-10144-4E Figure 20.5-3 does not show all transmissions in mode 0. It only shows an example for "8p1" (p = "even parity" or "odd parity"). No parity bit or address data selection bit are transmitted in mode 3, or in mode 2 with SSM=0. FUJITSU SEMICONDUCTOR LIMITED 471 CHAPTER 20 LIN-UART 20.5 Interrupts of LIN-UART MB90860E Series ■ Transmit Interrupt Request Generation Timing If the TDRE flag is set to "1" when the transmit interrupt is enabled (SSR:TIE=1), a transmit interrupt request is generated. Note: 472 Since the TDRE bit is initially set to "1", a transmit interrupt is generated immediately after the transmit interrupt is enabled (SSR:TIE=1). Be careful with the timing for enabling the transmit interrupt since the TDRE bit can be cleared only by writing new data to the transmit data register (TDR). FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 20.6 Baud Rate of LIN-UART CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART One of the following can be selected for the LIN-UART transmission/reception clock source: • Dedicated baud rate generator (reload counter) • External clock input to the baud rate generator (reload counter) • External clock (using the SCKn pin input clock directly) ■ LIN-UART Baud Rate Selection The baud rate can be selected from the following three different rates. Figure 20.6-1 shows the baud rate selection circuit. ● Baud rate derived from the internal clock divided by the dedicated baud rate generator (reload counter) Two internal reload counters are provided and assigned to the transmit and reception serial clock respectively. The baud rate is selected by setting a 15-bit reload value in the baud rate generator register 1, 0 (BGRn1, BGRn0). The reload counter divides the internal clock by the specified value. It is used in asynchronous mode and in synchronous mode (master). To set the clock source, select the use of the internal clock and baud rate generator (SMR:EXT=0, OTO=0). ● Baud rate derived from the external clock divided by the dedicated baud rate generator (reload counter) The external clock is used as the clock source for the reload counter. The baud rate is selected by setting a 15-bit reload value in the baud rate generator register 1, 0 (BGRn1, BGRn0). The reload counter divides the external clock by the specified value. It is used in asynchronous mode. To set the clock source, select the use of the external clock and baud rate generator (SMR:EXT=1, OTO=0). This mode is available in case that an oscillator with a special frequency is divided for use. ● Baud rate by the external clock (1-to-1 mode) The clock input from the clock input pin (SCKn) of the LIN-UART is used as the baud rate (synchronous mode 2, slave operation (ECCR:MS=1)). It is used in synchronous mode (slave). To set the clock source, select the external clock and its direct use (SMR:EXT=1, OTO=1). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 473 CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART MB90860E Series Figure 20.6-1 LIN-UART Baud Rate Selection Circuit REST Start bit Falling edge detection Reload value: v Reception 15-bit reload counter Reception clock Set Rxc = 0? Reload FF 0 Reset Rxc = v/2? 1 Reload value: v CLK 0 SCKn (External clock input) 1 Transmit 15-bit reload counter Counter value: TXC EXT Set Txc = 0? OTO FF Reload 0 Reset Txc = v/2? 1 Transmit clock Internal data bus EXT REST OTO SMRn register BGR14 BGR13 BGR12 BGR11 BGR10 BGR9 BGR8 BGRn1 register BGR7 BGR6 BGR5 BGR4 BGR3 BGR2 BGR1 BGR0 BGRn0 register n=0,1,2,3,4 474 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART MB90860E Series 20.6.1 Baud Rate Setting This section shows baud rate settings and the calculation result of serial clock frequencies. ■ Baud Rate Calculation The two 15-bit reload counters are set by the baud rate generator register 1, 0 (BGRn1, BGRn0). The expressions for the baud rate are as follows. Reload value: v = (φ / b)-1 v: Reload value, b: Baud rate, φ: Machine clock or external clock frequency Calculation example Assuming that the machine clock is 16 MHz, the internal clock is used, and the baud rate is set to 19200 bps: Reload value: v= ( 16 × 106 19200 ) -1 = 832 Thus, the actual baud rate can be calculated as follows. b= Note: CM44-10144-4E φ (v + 1) = 16 × 106 = 19207.6831 833 The reload counter halts if the reload value is set to "0". Therefore, the minimum division ratio should be 2. For transmission/reception in asynchronous mode, the reload value must be at least "4" in order to determine the reception value by oversampling for 5 times. FUJITSU SEMICONDUCTOR LIMITED 475 CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART MB90860E Series ■ Reload Value and Baud Rate for Each Clock Speed Table 20.6-1 shows the reload value and baud rate for each clock speed. Table 20.6-1 Reload Value and Baud Rate 8 MHz 10 MHz 16 MHz 20 MHz 24 MHz Baud rate value dev. value dev. value dev. value dev. value dev. 4M — — — — — — — — 5 0 2M — — — — 7 0 9 0 11 0 1M 7 0 9 0 15 0 19 0 23 0 500000 15 0 19 0 31 0 39 0 47 0 460800 — — — — — — — — 51 -0.16 250000 31 0 39 0 63 0 79 0 95 0 230400 — — — — — — — — 103 -0.16 153600 51 -0.16 64 -0.16 103 -0.16 129 -0.16 155 -0.16 125000 63 0 79 0 127 0 159 0 191 0 115200 68 -0.64 86 0.22 138 0.08 173 0.22 207 -0.16 76800 103 -0.16 129 -0.16 207 -0.16 259 -0.16 311 -0.16 57600 138 0.08 173 0.22 277 0.08 346 -0.06 416 0.08 38400 207 -0.16 259 -0.16 416 0.08 520 0.03 624 0 28800 277 0.08 346 < 0.01 554 -0.01 693 -0.06 832 -0.03 19200 416 0.08 520 0.03 832 -0.03 1041 0.03 1249 0 10417 767 < 0.01 959 < 0.01 1535 < 0.01 1919 < 0.01 2303 < 0.01 9600 832 0.04 1041 0.03 1666 0.02 2083 0.03 2499 0 7200 1110 < 0.01 1388 < 0.01 2221 < 0.01 2777 < 0.01 3332 < 0.01 4800 1666 0.02 2082 -0.02 3332 < 0.01 4166 < 0.01 4999 0 2400 3332 < 0.01 4166 < 0.01 6666 < 0.01 8332 < 0.01 9999 0 1200 6666 < 0.01 8334 0.02 13332 < 0.01 16666 < 0.01 19999 0 600 13332 < 0.01 16666 < 0.01 26666 < 0.01 — — — — 300 26666 < 0.01 — — — — — — — — The unit of frequency deviation (dev.) is %. Note: The maximum baud rate for synchronous mode is 1/6 of the machine clock (value=5). ■ External Clock The external clock is selected by writing "1" to the EXT bit in the LIN-UART serial mode register (SMR). In the baud rate generator, the external clock can be used in the same way as the internal clock. When slave operation is used in operation mode 2, select the 1-to-1 external clock input mode (SMR:OTO=1). In this mode, the external clock input to SCKn is input directly to the UART serial clock. Note: 476 The external clock signal is synchronized with the internal clock in the LIN-UART. Therefore, If the external clock used cannot be synchronized, the LIN-UART operation becomes unstable. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART MB90860E Series ■ Reload Counter Operation Figure 20.6-2 shows the operation of the 2 reload counters when the reload value is 832. Figure 20.6-2 Operation of Reload Counter Transmit/reception clock Reload counter 001 000 832 831 830 829 828 827 413 412 411 410 Reload counter value Transmit/reception clock Reload counter Note: CM44-10144-4E 417 416 415 414 The falling edge of the serial clock signal is generated after the reload value divided by 2 ((v+1)/2) is counted. FUJITSU SEMICONDUCTOR LIMITED 477 CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART 20.6.2 MB90860E Series Reload Counter This block is a 15-bit reload counter serving as a dedicated baud rate generator. It generates the transmit/reception clock from the external or internal clock. The count value in the transmit reload counter can be read from the baud rate generator registers (BGRn1, BGRn0). ■ Function of Reload Counter There are two kinds of reload counters: transmit and reception. They work as the dedicated baud rate generator. The block consists of a 15-bit register for reload values; it generates the transmit/reception clock from the external or internal clock. The count value in the transmit reload counter can be read from the baud rate generator registers (BGRn1, BGRn0). ● Count start Writing a reload value other than "0" to the baud rate generator registers (BGRn1, BGRn0) causes the reload counter to start counting. ● Restart The reload counter restarts under the following conditions: For both transmit/reception reload counters • Writing to the baud rate generator registers (BGR1, BGR0) • UART programmable reset (SMR:UPCL bit) • Programmable restart (SMR:REST bit) For reception reload counter • Detection of the falling edge of the start bit in asynchronous mode 478 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.6 Baud Rate of LIN-UART MB90860E Series Two reload counters restart at the next clock cycle when the REST bit in the serial mode register (SMR) is set to "1". This function enables the transmit reload counter to be used as a simple timer. Figure 20.6-3 shows an example of using this function (when reload value is 100). Figure 20.6-3 Example of Using a Simple Timer by Restarting the Reload Timer Machine clock Clock output of reload counter REST Reload counter 37 36 35 100 99 98 97 96 95 94 93 92 91 90 89 88 87 BGRn0/BGRn1 read 90 Data bus : don't care The number of machine cycles "cyc" after restart in this example is obtained by the following expression. cyc = v - c + 1 = 100 - 90 + 1 = 11 v: Reload value, c: Reload counter value Note: The reload counters also restart when the UART is reset by writing "1" to the SMR:UPCL bit. • Automatic restart (reception reload counter only) The reception reload counter is restarted when the falling edge of the start bit is detected in asynchronous mode. This is the function to synchronize the reception shift register with the reception data. ● Clearing the counter When a reset occurs, the reload values in the baud rate generator registers (BGRn1, BGRn0) and the reload counter are cleared to 00H, and the reload counter halts. Although the counter value is temporarily cleared to 00H by the LIN-UART reset (writing "1" to SMR:UPCL), the reload counter restarts since the reload value is retained. The counter value is not cleared to 00H by the restart setting (writing "1" to SMR:REST), and the reload counter restarts. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 479 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART 20.7 MB90860E Series Operation of LIN-UART LIN-UART operates in mode 0 for bidirectional serial communication, in mode 1 for master/slave multiprocessor communication, and in modes 2 and 3 for master/slave bidirectional communication. ■ Operation of LIN-UART ● Operating mode The LIN-UART has four operation modes (0 to 3), allowing the connections and the data transfer methods between CPUs to be selected as listed in Table 20.7-1. Table 20.7-1 LIN-UART Operating Modes Data length Operating mode No parity 0 Normal mode 1 Multiprocessor mode 2 Normal mode 3 LIN mode With parity 7 bits or 8 bits * 8 8 Stop bit length Data bit format 1 bit or 2 bits LSB first MSB first Asynchronous — 7 bits or 8 bits + 1 Synchronization method — Asynchronous Synchronous None, 1 bit, 2 bits Asynchronous 1 bit LSB first —: Unavailable setting *: "+1" is the address/data selection bit (AD) used for communication control in multiprocessor mode. Note: Both master and slave operation are supported in a system with master/slave connection in mode 1. In mode 3, the communication format is fixed to 8N1, LSB first. When the mode is switched, the UART stops all transitions and receptions and waits for the next operation. ■ Inter-CPU Connection Method You can select either external clock 1-to-1 connection (normal mode) or master/slave connection (multiprocessor mode). In either method, data length, parity setting, synchronization type must be the same between all CPUs and thus the operating mode must be selected as follows. • 1-to-1 connection: Two CPUs must use the same method as in either operating mode 0 or 2. Select the operating mode 0 for asynchronous method or the operating mode 2 for synchronous method. Also, for the operating mode 2, set one CPU as the master and the other as the slave. • Master/slave connection: Select operating mode 1. Use the system as a master/slave system. 480 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series ■ Synchronous Method In asynchronous method, the reception clock is synchronized with the falling edge of the reception start bit. In synchronous method, it can be synchronized by the master clock signal or the clock signal generated in master operation. ■ Signaling NRZ (Non Return to Zero). ■ Enabling Transmission/Reception The LIN-UART uses the SCR:TXE bit and the SCR:RXE bit to control transmission and reception, respectively. To disable transmission or reception, follow the procedure described below. • If the reception is in progress, wait until the reception is completed, read the reception data register (RDR), and then disable the reception. • If the transmission is in progress, wait until the transmission is completed, and then disable the transmission. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 481 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART 20.7.1 MB90860E Series Operation of Asynchronous Mode (Operation Mode 0, 1) When LIN-UART is used in operating mode 0 (normal mode) or operating mode 1 (multiprocessor mode), the transfer method is asynchronous. ■ Asynchronous Mode Operation ● Transmit/reception data format Transmit/reception data always begins with a start bit ("L" level) followed by transmission/reception for a specified data bit length, and ends with at least one stop bit ("H" level). The bit transfer direction (LSB first or MSB first) is determined by the BDS bit in the serial status register (SSR). When a parity is used, the parity bit is always placed between the last data bit and the first stop bit. In operating mode 0, select 7-bit or 8-bit for the data length. You can select whether or not to use a parity. Also, the stop bit length (1 or 2) can be selected. In operating mode 1, the data length is 7-bit or 8-bit, the parity is not added, and the address/data bit is added. The stop bit length (1 or 2) can be selected. The bit length of transmit/reception frame is calculated as follows: Length = 1 + d + p + s (d = Number of data bits [7 or 8], p = parity [0 or 1], s = Number of stop bits [1 or 2]) Figure 20.7-1 shows the data format in asynchronous mode. 482 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series Figure 20.7-1 Transmit/Reception Data Format (Operating Mode 0, 1) [Operating mode 0] ST D0 ST D0 D1 D2 D3 D4 D5 D6 D7 SP SP P: Not used D1 D2 D3 D4 D5 D6 D7 SP Data 8-bit ST D0 D1 D2 D3 D4 D5 D6 D7 P SP SP P: Used ST D0 D1 D2 D3 D4 D5 D6 D7 ST D0 D1 D2 D3 D4 D5 D6 SP SP ST D0 D1 D2 D3 D4 D5 D6 SP ST D0 D1 D2 D3 D4 D5 D6 P SP P: Not used Data 7-bit P SP SP P: Used ST D0 D1 D2 D3 D4 D5 D6 P SP ST D0 D1 D2 D3 D4 D5 D6 D7 AD SP SP ST D0 D1 D2 D3 D4 D5 D6 D7 AD SP ST D0 D1 D2 D3 D4 D5 D6 A/D SP SP [Operating mode 1] Data 8-bit Data 7-bit ST D0 ST SP P AD D1 D2 D3 D4 D5 D6 A/D SP : Start bit : Stop bit : Parity bit : Address/data bit Note: When the BDS bit in the serial status register (SSR) is set to "1" (MSB first), the bits are processed in the order of D7, D6, … D1, D0 (P). ● Transmission If the transmit data register empty flag bit (TDRE) in the serial status register (SSR) is "1", transmit data can be written into the transmit data register (TDR). Writing data sets the TDRE flag to "0". If transmission is enabled (TXE in the serial control register (SCR) is set to 1) at this time, the data is written to the transmit shift register and the transmission is started sequentially from the start bit in the next serial clock cycle. An interrupt is generated if the TDRE flag is set when the transmit interrupt is enabled (TIE=1). Care must be taken that as the TDRE initial value is "1", an interrupt is generated immediately after "1" is written to TIE in that state. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 483 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series When the data length is set to 7-bit (CL=0), the MSB in the TDR is an unused bit regardless of the transfer direction selection bit (BDS) setting (LSB first or MSB first). Note: Since the initial value of transmit data empty flag bit (SSR:TDRE) is "1", an interrupt is generated as soon as transmit interrupts are enabled (SSR:TIE=1). ● Reception The reception is performed when reception is enabled (SCR:RXE=1). When the start bit is detected, 1 frame data is received according to the data format defined in the serial control register (SCR). If an error occurs, the error flag (SSR:PE, ORE, FRE) is set. After the reception of the 1 frame data is completed, the received data is transferred from the reception shift register to the reception data register (RDR), and the reception data register full flag bit (SSR:RDRF) is set to "1". If the reception interrupt request is enabled (SSR:RIE=1) at this time, a reception interrupt request is output. To read the received data, check the error flag status after 1 frame data reception is completed and read the received data from the reception data register (RDR) if the reception is normal. If a reception error occurs, perform error processing. When the received data is read, the reception data register full flag bit (SSR:RDRF) is cleared to "0". When the data length is set to 7-bit (CL=0), the MSB in the TDR is an unused bit regardless of the transfer direction select bit (BDS) setting (LSB first or MSB first). Note: Data in the LIN-UART reception data register (RDR) becomes valid when the reception data register full flag bit (SSR:RDRF) is set to "1" and no error occurs (SSR:PE, ORE, FRE=0). ● Clock to be used Internal or external clock is used. For the baud rate, select the baud rate generator (SMR:EXT = 0 or 1, OTO = 0). ● Stop bit You can select 1 or 2 stop bits at transmission. When 2 bits of the stop bit are selected, both of the stop bits are detected during reception. When the first stop bit is detected, the reception data register full flag (SSR:RDRF) is set to "1". When no start bit is detected after that, the reception bus idle flag (ECCR:RBI) is set to "1", indicating that the reception is not performed. ● Error detection In mode 0, parity, overrun, and frame errors can be detected. In mode 1, overrun and frame errors can be detected. Parity errors, on the other hand, cannot be detected. 484 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series ● Parity You can specify whether or not to add (at transmission) and detect (at reception) a parity bit. The parity enable bit (SCR:PEN) can be used to determine whether or not to use a parity; the parity selection bit (SCR:P) can be used to select the odd or even parity. In operating mode 1, the parity cannot be used. Figure 20.7-2 Transmission Data when Parity is Enabled SIN ST SP 1 0 1 1 0 0 0 0 0 SOT ST Parity error occurs in even parity during reception (SCR:P = 0) SP Transmission of even parity (SCR:P = 0) SP Transmission of odd parity (SCR:P = 1) 1 0 1 1 0 0 0 0 1 SOT ST 1 0 1 1 0 0 0 0 0 Data Parity ST: Start bit, SP: Stop bit, Parity used (PEN = 1) Note: In operating mode 1, the parity cannot be used. ● Data signaling NRZ data format. ● Data transfer method LSB first or MSB first can be selected for the data bit transfer method. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 485 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART 20.7.2 MB90860E Series Operation of Synchronous Mode (Operating Mode 2) When LIN-UART is used in operating mode 2 (normal mode), the transfer method is clock synchronous. ■ Operation of Synchronous Mode (Operating Mode 2) ● Transmit/reception data format In synchronous mode, you can transmit and receive 8-bit data and select whether or not to include the start bit and stop bit (ECCR:SSM). When the start/stop bit is included (ECCR:SSM = 1), you can select whether or not to include the parity bit (SCR:PEN). Figure 20.7-3 shows the data format in synchronous mode. Figure 20.7-3 Transmit/Reception Data Format (Operating Mode 2) Transmit/reception data (ECCR:SSM=0,SCR:PEN=0) D0 D1 D2 D3 D4 D5 D6 D7 * Transmit/reception data (ECCR:SSM=1,SCR:PEN=0) ST D0 D1 D2 D3 D4 D5 D6 D7 SP Transmit/reception data (ECCR:SSM=1,SCR:PEN=1) ST D0 P SP * D1 D2 D3 D4 D5 D6 D7 SP SP *: When 2 stop bits are set (SCR:SBL = 1) ST: Start bit, SP: Stop bit, P: Parity bit, LSB first ● Clock inversion function When the SCES bit in the extended status control register (ESCR) is "1", the serial clock is inverted. In slave mode, the LIN-UART samples data at the falling edge of the received serial clock. Note that, in master mode, the mark level is set to "0" when the SCES bit is "1". Figure 20.7-4 Transmit Data Format During Clock Inversion Transmit/reception clock (SCES = 0, CCO = 0): Mark level Transmit/reception clock (SCES = 1, CCO = 0): Mark level Transmit/reception data (SSM=1) (No parity, 1 stop bit) ST SP Data frame ● Start/stop bit When the SSM bit in the extended communication control register (ECCR) is "1", the start and stop bits are added as in asynchronous mode. 486 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series ● Clock supply In clock synchronous mode (normal), the number of the transmit/reception bits must be equal to the number of the clock cycles. When the start/stop bit is enabled, the number of the added start/stop bits must be equal, as well. When the serial clock output is enabled (SMR:SCKE=1) in master mode (ECCR:MS=0), a synchronous clock is output automatically at transmission/reception. When the serial clock output is disabled (SMR:SCKE=0) or the slave mode is selected (ECCR:MS=1), the clock for each bit of transmit/reception data must be supplied from the outside. The clock signal must remain at the mark level as long as it is irrelevant to transmission/reception. Setting the SCDE bit in the ECCR to "1", a delayed transmit clock is output as shown in Figure 20.7-5. This function is required when the receiving device samples data at the rising or falling edge of the clock. Figure 20.7-5 Transmission Clock Delay (SCDE=1) Write transmit data Reception data sample edge (SCES = 0) Transmit/reception clock (normal) Mark level Transmit/reception clock (SCDE=1) Transmit/reception data Mark level Mark level 0 1 1 LSB 0 1 0 Data 0 1 MSB When the SCES bit in the extended status register (ESCR) is "1", the LIN-UART clock is inverted, and received data is sampled at the falling edge of the clock. At this time, the value of the serial data must be enabled at the timing of the clock falling edge. When the CCO bit in the ESCR is "1", the serial clock output from the SCKn pin is supplied continuously in master mode. In this mode, add the start/stop bit (SSM=1) in order to clarify the beginning and end of the data frame. Figure 20.7-6 shows the operation of this function. Figure 20.7-6 Continuous Clock Supply (Mode 2) Transmit/reception clock (SCES = 0, CCO = 1): Transmit/reception clock (SCES = 1, CCO = 1): Transmit/reception data (SSM=1) (No parity, 1 stop bit) ST SP Data frame Software reset is disabled while sampling clock edge selection bit (ESCR:SCES) is set to "1". • When switching the sampling clock edge selection bit (ESCR:SCES) from "0" to "1": After disabling sending/receiving, and initiating software reset (SCR:UPCL=1), change the sampling clock edge selection bit (ESCR:SCES) to "1". • CM44-10144-4E When switching the sampling clock edge selection bit (ESCR:SCES) from "1" to "0": After disabling sending/receiving, and changing the sampling clock edge selection bit (ESCR:SCES) to "0", initiate software reset (SCR:UPCL=1)." FUJITSU SEMICONDUCTOR LIMITED 487 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series ● Error detection When the start/stop bits are disabled (ECCR:SSM=0), only overrun errors are detected. • Parity Adding (at transmission) and detecting (at reception) of the parity bit can be specified. The parity enable bit (SCR:PEN) determines parity on/off, while the parity selection bit (SCR:P) specifies odd/even parity. Parity is disabled when the start/stop bit is not used. • Stop bit Upon transmission, the stop bit can be set to either 1-bit or 2-bit. • Data signaling NRZ data format. • Data transfer method LSB first or MSB first can be selected for the data bit transfer method. ● Communication settings for synchronous mode To communicate in synchronous mode, the following settings are required. • Baud rate generator register (BGRn0/BGRn1) Set the dedicated baud rate reload counter to a required value. • Serial mode register (SMR) MD1, MD0: 10B (Mode 2) SCKE : "1" . . . . . . Use the dedicated baud rate reload counter. "0" . . . . . . Input external clock. SOE : "1" . . . . . . Enable transmission/reception. "0" . . . . . . Enable reception only. • Serial control register (SCR) RXE, TXE: Set "1" to either one of them. AD : The value of this bit is disabled, as the address/data format selection function cannot be used. CL : This bit is set to 8-bit length automatically, and its value is disabled. CRE : "1" . . . . . . . The error flag is cleared, and reception is suspended. --- For SSM=0: PEN, P, SBL: Since not used, parity bit and stop bit are disabled. --- For SSM=1: PEN : "1" . . . . . . . Add/detect parity bit, "0" . . . . . . . Not use parity bit P "0" . . . . . . . Odd parity : "1" . . . . . . . Even parity, SBL : "1" . . . . . . . Stop bit length 2, "0" . . . . . . . Stop bit length 1 • Serial status register (SSR) BDS: "0" . . . . . . . LSB first, "1" . . . . . . . MSB first RIE : "1" . . . . . . . Enable reception interrupt, "0" . . . . . . . Disable reception interrupt TIE : "1" . . . . . . . Enable transmit interrupt, "0" . . . . . . . Disable transmit interrupt • Extended communication control register (ECCR) SSM : "0" . . . . . . . Not use start/stop bit (normal) "1" . . . . . . . Use start/stop bit (extended function) 488 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series MS : "0" . . . . . . . Master mode (serial clock output) "1" . . . . . . . Slave mode (input serial clock from master device) Note: CM44-10144-4E To start communication, write data into the transmit data register (TDR). To only receive data, disable the serial output (SMR:SOE=0), and then write dummy data into the TDR. Enabling continuous clock and start/stop bit allows bidirectional communication as in asynchronous mode. FUJITSU SEMICONDUCTOR LIMITED 489 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART 20.7.3 MB90860E Series Operation of LIN Function (Operating Mode 3) In operating mode 3, the LIN-UART works as the LIN master and the LIN slave. In operating mode 3, the data format is set to 8N1-LSB first. ■ Asynchronous LIN Mode Operation ● Operation as LIN master In LIN mode, the master determines the baud rate for the entire bus, and the slave synchronizes to the master. The baud rate is fixed to the requested value when the master starts operating after the initial setting. Writing "1" to the LBR bit in the extended communication control register (ECCR) outputs 13 to 16 bits at the "L" level from the SOTn pin. These bits are the LIN Synch break indicating the beginning of a LIN message. The TDRE flag bit in the serial status register (SSR) is set to "0". After the break, it is set to "1" (initial value), if no valid data is contained in the transmit data register (TDR). If the TIE bit in SSR is "1" at this time, a transmit interrupt is output. The length of the LIN break transmitted is set by the LBL0/1 bits in ESCR as in the following table. Table 20.7-2 LIN Break Length LBL0 LBL1 Break length 0 0 13 bits 1 0 14 bits 0 1 15 bits 1 1 16 bits Synch field is transmitted as byte data 0 x 55 following the LIN break. 0 x 55 can be written to the TDR after the LBR bit is set to "1" even if the TDRE flag is "0". ● Operation as LIN slave In LIN slave mode, the LIN-UART must synchronize to the baud rate for the master. The LIN-UART generates a reception interrupt when LIN break interrupt is enabled (LBIE=1) even though reception is disabled (RXE=0). The LBD bit in the ESCR is set to "1" at this time. Writing "0" to the LBD bit clears the reception interrupt request flag. For calculation of the baud rate, the following example shows the operation of the UART0. When the UART0 detects the first falling edge of Synch field, the internal signal to be input to the input capture (ICU0) is set to "H" to start ICU0. The internal signal should be "L" at the fifth falling edge. ICU0 must be set to LIN mode (ICE01). Also, ICU0 interrupts must be enabled and set for the detection at both edges (ICS01). The time for which the input signal to ICU0 is the value obtained by multiplying the baud rate by 8. The baud rate setting value is calculated by the following expressions. 490 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series When the free-run timer is not overflowing: BGR value = {(b - a) × Fe / (8 × φ)} -1 When the free-run timer is overflowing: BGR value = {(max + b - a) × Fe / (8 × φ)} -1 max : Maximum value of free-run timer a : ICU data register value after the 1st interrupt b : ICU data register value after the 2nd interrupt φ : Machine clock frequency (MHz) Fe : External clock frequency (MHz) Calculation based on the internal baud rate generator in use (EXT=0), and Fe=φ Note: Do not set the baud rate if the new BGR value calculated based on Synch field as above in LIN slave mode involves an error over ±15%. For the relationship between the UART and ICU, see Section "13.5 Operations of 16-bit Free-running Timer" and Section "13.6 Input Capture Operations". ● LIN Synch break detection interrupt and flag The LIN break detection (LBD) flag in ESCR is set to "1" when the LIN Synch break is detected in slave mode. When the LIN break interrupt is enabled (LBIE=1), an interrupt is generated. Figure 20.7-7 Timing of LIN Synch Break Detection and Flag Set Serial clock cycle # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Serial clock Serial input (LIN bus) FRE (RXE=1) LBD (RXE=0) Reception interrupt occurs when RXE=1 Reception interrupt occurs when RXE=0 The above diagram shows the timing of the LIN Synch break detection and flag. Since the data framing error (FRE) flag bit in SSR generates a reception interrupt 2 bits earlier than a LIN break interrupt (for 8N1), set the RXE to "0" when a LIN break is used. The LIN Synch break detection works only in operating mode 3. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 491 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series Figure 20.7-8 shows the beginning of a typical LIN message and the LIN-UART operation. Figure 20.7-8 UART Operation in LIN Slave Mode Serial clock Serial input (LIN bus) LBR cleared by CPU LBD ICU input (LSYN) Synch break (when set to 14 bits) Synch field ● LIN bus timing Figure 20.7-9 LIN Bus Timing and UART Signals Previous serial clock No clock (Calculation frame) Newly calculated serial clock ICU count LIN bus (SIN) RXE LBD (IRQ0) LBIE ICU input (LSYN) IRQ(ICU) RDRF (IRQ0) RIE RDR read by CPU Reception interrupt enabled LIN break starts LIN break detected, interrupt generated IRQ cleared by CPU (LBD->0) LBIE disabled IRQ (ICU) IRQ cleared: ICU started IRQ(ICU) IRQ cleared: Baud rate calculated and set Reception enabled Falling edge of start bit 1 byte of reception data saved to RDR RDR read by CPU 492 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 20.7.4 Serial Pin Direct Access CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART Transmission pin (SOTn) or reception pin (SINn) can be accessed directly. ■ LIN-UART Pin Direct Access The LIN-UART allows the programmer to directly access the serial I/O pins. The status of the serial input pin (SINn) can be read by using the serial I/O pin direct access bit (ESCR:SIOP). You can set the value of the serial output pin (SOTn) arbitrarily when the serial output is enabled (SMR:SOE=1) after direct write to the serial output pin (SOTn) is enabled (ESCR:SOPE=1), and then "0" or "1" is written to the serial I/O pin direct access bit (ESCR:SIOP). In LIN mode, this feature is used for reading transmitted data or for error handling when a LIN bus line signal is physically incorrect. Notes: CM44-10144-4E • Direct access is allowed only when transmission is not in progress (the transmit shift register is empty). • Before enabling transmission (SMR:SOE=1), write a value to the serial output pin direct access bit (ESCR:SIOP). This prevents a signal of an unexpected level from being output since the SIOP bit holds a previous value. • While the value of the SINn pin is read by normal read, the value of the SOTn pin is read for the SIOP bit by the RMW instructions. • While SCR:TXE=1, and in transmission or under slave mode in operation mode 2, the SOTn pin cannot be accessed directly regardless of the setting of this bit. FUJITSU SEMICONDUCTOR LIMITED 493 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART 20.7.5 MB90860E Series Bidirectional Communication Function (Normal Mode) Normal serial bidirectional communication can be performed in operation mode 0 or 2. Asynchronous communication can be selected in operating mode 0, while synchronous communication can be selected in operating mode 2. ■ Bidirectional Communication Function To operate the LIN-UART in normal mode (operating mode 0 or 2), the settings shown in Figure 20.7-10 are required. Figure 20.7-10 Settings of LIN-UART Operating Modes 0 and 2 bit15 bit14 bit13 bit12 bit11 bit10 bit9 SCRn, SMRn PEN P bit8 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 SBL CL A/D CRE RXE TXE MD1 MD0 OTO EXT REST UPCL SCKE SOE Mode 0 Mode 2 SSRn, TDRn/RDRn PE ORE FRE RDRF TDRE BDS RIE TIE Mode 0 Mode 2 ESCRn, ECCRn LBIE LBD LBL1 LBL0 SOPE SIOP CCO SCES Set conversion data (during writing) Retain reception data (during reading) LBR MS SCDE SSM RBI TBI Mode 0 Mode 2 : Used bit : Unused bit : Set "1" : Set "0" : Used when SSM = 1 (Synchronous start/stop bit mode) : Bit automatically set correctly n = 0, 1, 2, 3, 4 ● Inter-CPU connection For bidirectional communication, two CPUs are interconnected as shown in Figure 20.7-11. Figure 20.7-11 Connection Example of Bidirectional Communication in LIN-UART Mode 2 SOT SOT SIN Output Input SCK SIN SCK CPU-1 (Master) CPU-2 (Slave) ● Communication procedure The communication is started from transmitting end at arbitrary timing when data is ready to be transmitted. The receiving end returns ANS (per 1 byte in this example) regularly after the transmitted data is received. Figure 20.7-12 shows an example of bidirectional communication flowchart. 494 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series Figure 20.7-12 Example of Bidirectional Communication Flowchart (Transmitting end) (Receiving end) Start Start Set operating mode (0 or 2) Set operating mode (Match with the transmitting end) Communicate with 1 byte data set in TDR Data transmission NO NO Read and process received data CM44-10144-4E YES Received data exists YES Received data exists Read and process received data Data transmission Transmit 1 byte data (ANS) FUJITSU SEMICONDUCTOR LIMITED 495 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART 20.7.6 MB90860E Series Master/Slave Mode Communication Function (Multiprocessor Mode) Operating mode 1 allows communication between multiple CPUs connected in master/ slave mode. It can be used as a master or slave. ■ Master/Slave Mode Communication Function To operate the LIN-UART in multiprocessor mode (operating mode 1), the settings shown in Figure 20.713 are required. Figure 20.7-13 Settings of LIN-UART Operating Mode 1 bit15 bit14 bit13 bit12 bit11 bit10 SCRn, SMRn PEN P SBL CL bit9 bit8 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 A/D CRE RXE TXE MD1 MD0 OTO EXT REST UPCL SCKE SOE Mode 1 SSRn, TDRn/RDRn PE ORE FRE RDRF TDRE BDS RIE TIE Set conversion data (during writing) Retain reception data (during reading) Mode 1 ESCRn, ECCRn LBIE LBD LBL1 LBL0 SOPE SIOP CCO SCES LBR MS SCDE SSM RBI TBI Mode 1 : Used bit : Unused bit : Set "1" : Set "0" : Bit automatically set correctly n = 0, 1, 2, 3, 4 ● Inter-CPU connection For master/slave mode communication, a communication system is configured by connecting between 1 master CPU and multiple slave CPUs with 2 common communication lines, as shown in Figure 20.7-14. The LIN-UART can be used as the master or slave. Figure 20.7-14 Connection Example of LIN-UART Master/Slave Mode Communication SOT SIN Master CPU SOT SIN Slave CPU#0 496 SOT SIN Slave CPU#1 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series ● Function selection For master/slave mode communication, select the operating mode and the data transfer method, as shown in Table 20.7-3. Table 20.7-3 Selection of Master/Slave Mode Communication Function Operating mode Master CPU Address Transmission/ reception Data transmission/ reception Mode 1 (AD bit transmission/ reception) Slave CPU Mode 1 (AD bit transmission/ reception) Data Parity Synchronous method Stop bit Bit direction None Asynchronous 1 bit or 2 bits LSB first or MSB first AD = 1 + 7- or 8-bit address AD = 1 + 7- or 8-bit address ● Communication procedure Communication is started by transmitting address data from the master CPU. The address data, whose AD bit is set as "1", determines the slave CPU to be the destination. Each slave CPU checks address data by using a program, and communicates with the master CPU when the data matches an assigned address. Figure 20.7-15 shows a flowchart for master/slave mode communication (multiprocessor mode). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 497 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series Figure 20.7-15 Master/Slave Mode Communication Flowchart (Master CPU) (Slave CPU) Start Start Set to operating mode 1 Set to operating mode 1 Set SINn pin to serial data input Set SOTn pin to serial data output Set SINn pin to serial data input Set SOTn pin to port input Set 7 or 8 data bits Set 1 or 2 stop bits Set 7 or 8 data bits Set 1 or 2 stop bits Set "1" in AD bit Enable transmission/ reception Enable transmission/ reception Receive bytes Transmit address to slave AD bit = 1 NO YES Match with slave address Set "0" in AD bit YES Communicate with master CPU Communicate with slave CPU Terminate communication? NO Terminate communication? NO NO YES YES Communicate with another slave CPU NO YES Disable transmission/ reception End 498 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series 20.7.7 LIN Communication Function For LIN-UART communication, a LIN device can be used in the LIN master system or the LIN slave system. ■ LIN Master/Slave Mode Communication Function Figure 20.7-16 shows the required settings for the LIN communication mode of LIN-UART (operating mode 3). Figure 20.7-16 Settings of LIN-UART Operating Mode 3 SCRn, SMRn PEN P SBL CL A/D CRE RXE TXE MD1 MD0 OTO EXT REST UPCLSCKE SOE Mode 3 SSRn, TDRn/RDRn PE ORE FRE RDRFTDRE BDS RIE TIE Set conversion data (during writing) Retain reception data (during reading) Mode 3 ESCRx, ECCRx LBIE LBD LBL1 LBL0 SOPE SIOP CCO SCES LBR MS SCDESSM RBI TBI Mode 3 : Used bit : Unused bit : Set "1" : Set "0" : Bit automatically set correctly n = 0, 1, 2, 3, 4 ● LIN device connection Figure 20.7-17 shows the communication system between 1 LIN master and LIN slave. The LIN-UART can serve as the LIN master or LIN slave. Figure 20.7-17 Example of LIN Bus System Communication SOT SOT LIN bus SIN LIN master CM44-10144-4E SIN Transceiver Transceiver FUJITSU SEMICONDUCTOR LIMITED LIN slave 499 CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART 20.7.8 MB90860E Series Example Flowchart of LIN-UART LIN Communication (Operating Mode 3) This section shows example flowcharts of LIN-UART LIN communication. ■ LIN Master Device Figure 20.7-18 LIN Master Flowchart Start Initial settings: Set to operating mode 3 Enable serial data output, Set baud rate, Set Synch break length TXE = 1, TIE = 0, RXE = 1, RIE = 1 NO Message? (Reception) YES YES Wake up? (0x80 reception) NO Receive Data field? RDRF = 1 Reception interrupt RXE = 0 Enable Synch break interrupts Transmit Synch break ECCR: LBR = 1 Transmit Synch field: TDR = 0x55 (Transmission) RDRF = 1 Reception interrupt Receive Data 1*1 YES NO Set transmit data 1, TDR = Data 1, Enable transmit interrupts TDRE = 1 Transmit interrupt Receive Data N*1 Set transmit data N, TDR = Data N, Disable transmit interrupts LBD = 1 Synch break interrupt RDRF = 1 Reception interrupt Enable reception LBD = 0 Disable Synch break interrupts Receive Data 1 *1 Read Data 1 RDRF = 1 Reception interrupt RDRF = 1 Reception interrupt Receive Synch field *1 Set Identify field: TDR = lD Receive Data N *1 Read Data N RDRF = 1 Reception interrupt Receive ID field*1 No error? NO Process error*2 YES *1: Process an error if it occurs. *2: • If the FRE or ORE flag is set "1", write "1" to the SCR:CRE bit to clear the error flag. • If the ESCR:LBD bit is set to "1", execute the UART reset. Note: Detect an error in each process and handle it appropriately. 500 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.7 Operation of LIN-UART MB90860E Series ■ LIN Slave Device Figure 20.7-19 LIN Slave Flowchart Start Initial settings: Set to operating mode 3 Enable serial data output TXE = 1, TIE = 0, RXE = 0, RIE = 1 Connect UART with ICU Disable reception Enable ICU interrupts Enable Synch break interrupts (Reception) ICU interrupt Receive Data field? NO (Transmission) RDRF = 1 Reception interrupt LBD = 1 Synch break interrupt Clear Synch break detection ESCR: LBD = 0 Disable Synch break interrupts YES Set transmit data 1 TDR = Data 1 Enable transmit interrupts Receive Data 1*1 RDRF = 1 Reception interrupt TDRE = 1 Transmit interrupt Receive Data N*1 Set transmit data N, TDR = Data N, Disable transmit interrupts Read ICU data Clear ICU interrupt flag ICU interrupt Disable reception RDRF = 1 Reception interrupt Read ICU data Adjust baud rate Enable reception Clear ICU interrupt flag Disable ICU interrupts Receive Data 1 *1 Read Data 1 RDRF = 1 Reception interrupt RDRF = 1 Reception interrupt Receive Data N *1 Read Data N Disable reception Receive Identify field*1 No error? NO Process error*2 YES Sleep mode? NO YES Wake-up received? *1: Process an error if it occurs. *2: • If the FRE or ORE flag is set "1", write "1" to the SCR:CRE bit to clear the error flag. • f the ESCR:LBD bit is set to "1", execute the UART reset. Note: Detect an error in each process and handle it appropriately. CM44-10144-4E YES NO Wake-up transmitted? YES FUJITSU SEMICONDUCTOR LIMITED NO Transmit wake-up code 501 CHAPTER 20 LIN-UART 20.8 Notes on Using LIN-UART 20.8 MB90860E Series Notes on Using LIN-UART This section shows notes on using the LIN-UART. ■ Notes on Using LIN-UART ● Enabling operation The LIN-UART has the TXE (transmission) and RXE (reception) enable bit in the serial control register (SCR) for transmission and reception, respectively. As both transmission and reception are disabled by default (initial value), these operations must be enabled before transfer. Also, you can disable these operations to stop transfer as required. ● Setting communication mode The communication mode must be set while the LIN-UART is stopped. If the mode is set during transmission/reception, the transmitted/received data is not guaranteed. ● Timing of enabling transmit interrupts Since the default (initial) value of the transmit data empty flag bit (SSR:TDRE) is "1" (no transmit data, transmit data write enabled), a transmit interrupt request is generated immediately when transmit interrupt request is enabled (SSR:TIE=1). To prevent this, be sure to set the transmit data before setting the TIE flag to "1". ● Changing operation setting It is recommended to reset the LIN-UART after changing its settings, such as adding the start/stop bit or changing the data format. The correct operation settings are not guaranteed even if you reset the LIN-UART (SMR:UPCL=1) at the same time as setting the LIN-UART serial mode register (SMR). Therefore, it is recommended to reset the LIN-UART (SMR:UPCL=1) once again, after setting the bit in LIN-UART serial mode register (SMR). ● Using LIN function Although the LIN functions are available in operating mode 3, the LIN format is automatically set in mode 3 (8-bit data, no parity, 1 stop bit, LSB first). While the length of LIN break transmit bit is variable, the detection bit length is fixed to 11 bits ● Setting LIN slave When starting LIN slave mode, be sure to set the baud rate before receiving the LIN Synch break in order to ensure that at least 13 bits of the LIN Synch break is detected. 502 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.8 Notes on Using LIN-UART MB90860E Series ● Program compatibility Although the LIN-UART resembles the old FJ-UART, there is no program compatibility between them. Even when the same programming pattern is used, the register structure is different. Moreover, a reload value is currently used to determine the baud rate setting, rather than selecting a preset value. ● Bus idle function In operation mode 2, reception bus idle detection function cannot be used. Also, when slave mode is selected (MS=1), transmit bus idle detection function is disabled as well. ● AD bit (Serial control register (SCR): Address/data format selection bit) • The AD bit is used to select the address/data for transmission in write operation, and to read the AD bit received last in read operation. Internally, the AD bit values for transmission and reception are stored in separate registers. The transmit AD bit value is read when RMW instructions are used. Otherwise, the received AD data is read. • At transmission, when the TDRE bit changes from "0" to "1", the transmit AD bit is also loaded to the transmit shift register along with the data in the transmit data register (TDR). Therefore, set the transmit AD bit before writing to the transmit data register (TDR). ● LIN-UART software reset Execute the LIN-UART software reset (SMR:UPCL=1) when the TXE bit in the serial control register (SCR) is "0". ● Synch break detection In mode 3 (LIN mode), when Serial input more than 11 bits is "0", the LBD bit in the extended status control register (ESCR) is set to "1" (Synch break detection) and the LIN-UART waits for the Synch field. As a result, when Serial input more than 11 bits is "0", the LIN-UART recognizes that the Synch break is input (LBD=1), and then waits for the Synch field. In this case, execute the LIN-UART reset (SMR: UPCL=1). • ESCR:LBD bit After detection of LIN Synchk break, write-accessing the ESCR register while at the same time the LBD bit is set to "1", "1" cannot be set to the bit. In operation mode 3, setting of the ESCR register should therefore be done at the time of initialization, or after the LBD bit is set to "1". • ESCR:SCES bit Software reset is disabled while the sampling clock edge selection bit (ESCR:SCES) is set to "1". - Switching the sampling clock edge selection bit (ESCR:SCES) from "0" to "1": After disabling sending/receiving, and initiating software reset (SCR:UPCL=1), change the sampling clock edge selection bit (ESCR:SCES) to "1". - Switching the sampling clock edge selection bit (ESCR:SCES) from "1" to "0": After disabling sending/receiving, and changing the sampling clock edge selection bit (ESCR:SCES) to "0", initiate software reset (SCR:UPCL=1). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 503 CHAPTER 20 LIN-UART 20.8 Notes on Using LIN-UART MB90860E Series • Serial communication There is a possibility to receive wrong data due to noise or other causes on the serial communication. Therefore, design a printed circuit board so as to avoid noise. Consider receiving of wrong data when designing the system. For example, apply a checksum to detect an error. If an error is detected, retransmit the data. ● Handling framing errors 1) CRE resets reception state machine and next falling edge at SINn starts reception of new byte (See Figure 20.8-1). Therefore either set CRE bit immediately (within half bit time) after receiving errors to prevent data stream desynchronization (See Figure 20.8-2) or wait an application dependent time after receiving errors and set CRE, when SINn is idle. 2) Please note, that in case a framing error occurred (stop bit: SINn = 0) and next start bit (SINn = 0) follows immediately, this start bit is recognized regardless of no falling edge before (See Figure 20.8-3). This is used to remain UART synchronized to the data stream and to detect that serial data input (SINn) keeps "L" level (See Figure 20.8-3 above) by producing next framing errors. If this behavior is not wanted, please disable the reception temporarily RXE = 1 → 0 → 1) after framing error. In this case, reception goes on at next falling edge on SINn. (See Figure 20.8-3 below). 504 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 20 LIN-UART 20.8 Notes on Using LIN-UART MB90860E Series Figure 20.8-1 Timing of CRE Bit CRE bit timing within ½ Bit Time of Stop Bit Last Data Bit Stop Bit SIN Start Bit ½ Bit Time Sample Point Error Flags CRE Reception State Machine is reset Falling Edge detected: Receive new Frame CRE bit timing out of ½ Bit Time of Stop Bit Last Data Bit Stop Bit SIN Start Bit ½ Bit Time Sample Point Error Flags CRE Falling Edge detected: Receive new Frame Reception State Machine is reset, Start Bit Condition is reset, actual Reception is desynchronized CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 505 CHAPTER 20 LIN-UART 20.8 Notes on Using LIN-UART MB90860E Series Figure 20.8-2 Data Stream Desynchronization Example for Desynchronization SIN CRE during Start Bit CRE Reception is reset RX read Next falling Edge is treated as Start Bit 1st Frame 1st desynchronized Frame 2nd Frame Missed Bits 506 FUJITSU SEMICONDUCTOR LIMITED Begin of 2nd desynchronized Frame Missed Bits CM44-10144-4E CHAPTER 20 LIN-UART 20.8 Notes on Using LIN-UART MB90860E Series Figure 20.8-3 Dominant Bus Operation USART Dominant Bus Behaviour Reception always enabled (RXE = 1) SIN FRE CRE Framing Error occurs Error is cleared Reception is ongoing Next Framing regardless of no falling Error occurs edge Falling Edge is next Start Bit Edge Reception disabled temporary (RXE = 1 0 1) SIN FRE CRE RXE Framing Error occurs Reception is reset: Waiting for falling Edge Error is cleared Reception is ongoing regardless of no falling edge CM44-10144-4E No further Errors FUJITSU SEMICONDUCTOR LIMITED Falling Edge is next Start Bit Edge 507 CHAPTER 20 LIN-UART 20.8 Notes on Using LIN-UART 508 MB90860E Series FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 2 I C INTERFACE (400 kHz) This chapter explains the functions and operations of the high-speed I2C interface. 21.1 Overview of I2C Interface (400 kHz) 21.2 Registers of I2C Interface 21.3 Operations of I2C Interface 21.4 Programming Flowcharts CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 509 CHAPTER 21 I2C INTERFACE (400 kHz) 21.1 Overview of I2C Interface (400 kHz) 21.1 MB90860E Series Overview of I2C Interface (400 kHz) The I2C interface is a serial I/O port that supports internal IC BUS and operates as the master/slave devices on I2C bus. The MB90860E series provides two I2Cs. ■ Features of I2C Interface (400 kHz) The I2C interface (400 kHz) has the following features: • Master/slave sending and receiving function • Arbitration function • Clock synchronization function • General call addressing function • Transfer direction detection function • Function that generates and detects the re-activation condition • Bus error detection function • 7-bit master/slave addressing • 10-bit master/slave addressing • Interface for 7-bit and 10-bit slave address • Disabling of acknowledgement for slave address reception (only in master mode) • Address mask function to provide the interface for composite slave addresses (in 7-bit and 10-bit modes) • Transmission at up to 400 kbps • Built-in noise filters for SDA/SCL • Data reception at 400 kbps when the machine clock exceeds 6 MHz regardless of the prescaler setting • Generation of transfer interrupts and bus error interrupts • Lowering of speed by slave at the bit level and byte level The I2C interface does not support the SCL clock stretching at the bit level because the interface can receive the data in full scale at 400kbps when the machine clock exceeds 6 MHz regardless of the prescaler setting. However, the clock stretching is executed at the byte level when SCL becomes "L" during the interrupt (INT=1 in the IBCR register). ■ Block Diagram of I2C Interface Figure 21.1-1 shows a block diagram of the I2C interface (400 kHz). 510 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.1 Overview of I2C Interface (400 kHz) MB90860E Series Figure 21.1-1 Block Diagram of I2C Interface (400 kHz) ICCR I2C enable EN ICCR 2 CS4 Clock division 1 3 4 5 ... 32 CS3 5 CS2 5 Synchronous Clock selector CS1 CS0 IBSR BB RSC LRB Clock division 2 (divided by 12) SCL duty cycle generator Shift clock generator Bus busy Repeat activation Bus observer Last bit Bus error Send/receive TRX Address data ADT Internal data bus AL Arbitration loss detector ICCR NSF Enable IBCR BER BEIE MCU IRQ Interrupt request INTE INT Noise filter SCL SDA SCL SDA IBCR SCC MSS ACK Activation Activate-stop condition generator Master ACK enable GC-ACK enable ACK generator GCAA 8 IBSR AAS IDAR 8 Slave General call GCA ISMK 7-bit mode enable ENSB ITMK 10-bit mode enable ENTB Reception address length RAL 10 Slave address comparator 7 10 ITBA ITMK 7 ISBA ISMK 10 10 7 7 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 511 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface 21.2 MB90860E Series Registers of I2C Interface This section explains the function of the registers used in the I2C interface. ■ Register List of I2C Interface Figure 21.2-1 shows a register list of the I2C interface. Figure 21.2-1 Register List of I2C Interface (1/2) Bus control register (IBCR0/IBCR1) Address: IBCR0: 007971H IBCR1: 007981H 15 14 13 12 11 10 9 8 BER BEIE SCC MSS ACK GCAA INTE INT R/W R/W W R/W R/W R/W R/W R/W IBCR0/IBCR1 Initial value 00000000B Bus status register (IBSR0/IBSR1) Address: IBSR0: 007970H IBSR1: 007980H 7 6 5 BB RSC AL R R R 4 3 2 1 0 IBSR0/IBSR1 LRB TRX AAS GCA ADT Initial value R R R 00000000B 10 9 8 ITBAH0/ITBAH1 (High) R R 10-bit slave address register (ITBA0/ITBA1) Address: 15 14 13 12 11 ITBAH0: 007973H ITBAH1: 007983H Address: ITBAL0: 007972H ITBAL1: 007982H 7 6 5 4 3 2 TA9 TA8 Initial value R/W R/W 00000000B 1 0 ITBAL0/ITBAL1 TA7 TA6 TA5 TA4 TA3 TA2 TA1 TA0 Initial value R/W R/W R/W R/W R/W R/W R/W R/W 00000000B (Low) 10-bit slave address mask register (ITMK0/ITMK1) Address: ITMKH0: 007975H ITMKH1: 007985H Address: ITMKL0: 007974H ITMKL1: 007984H 15 14 13 12 11 10 9 8 ENTB RAL TM9 TM8 R/W R/W R/W R/W 7 6 5 4 3 2 1 0 ITMKH0/ITMKH1 (High) Initial value 00111111B ITMKL0/ITMKL1 (Low) TM7 TM6 TM5 TM4 TM3 TM2 TM1 TM0 Initial value R/W R/W R/W R/W R/W R/W R/W R/W 11111111B 7-bit slave address register (ISBA0/ISBA1) Address: 7 ISBA0: 007976H ISBA1: 007986H R/W W R — 512 6 5 4 3 2 1 0 ISBA0/ISBA1 SA6 SA5 SA4 SA3 SA2 SA1 SA0 Initial value R/W R/W R/W R/W R/W R/W R/W 00000000B : Readable/writable : Write-only : Read-only : Undefined FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Figure 21.2-1 Register List of I2C Interface (2/2) 7-bit slave address mask register (ISMK0/ISMK1) Address: 15 ISMK0: 007977H ISMK1: 007987H 14 13 12 11 10 9 8 ENSB SM6 SM5 SM4 SM3 SM2 SM1 SM0 R/W R/W R/W R/W R/W R/W R/W R/W ISMK0/ISMK1 Initial value 01111111B Data register (IDAR0/IDAR1) Address: 7 IDAR0: 007978H IDAR1: 007988H 6 5 4 3 2 1 0 D7 D6 D5 D4 D3 D2 D1 D0 R/W R/W R/W R/W R/W R/W R/W R/W IDAR0/IDAR1 Initial value 00000000B Clock control register (ICCR0/ICCR1) Address: 15 ICCR0: 00797BH ICCR1: 00798BH 14 13 12 11 10 9 8 NSF EN CS4 CS3 CS2 CS1 CS0 R/W R/W R/W R/W R/W R/W R/W ICCR0/ICCR1 Initial value 00011111B R/W : Readable/writable — : Undefined CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 513 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface 21.2.1 MB90860E Series Bus Status Register (IBSR0, IBSR1) This section explains the function of the bus status register (IBSR0, IBSR1). ■ Functions of the Bus Status Register (IBSR0, IBSR1) The bus status register (IBSR0, IBSR1) has the following functions: • Bus busy detection • Re-activation condition detection • Arbitration loss detection • Acknowledgement detection • Data transfer direction indication • Addressing detection as slave • General call address detection • Address data transfer detection ■ Bit Function of the Bus Status Register (IBSR0, IBSR1) This register is read-only. All bits of this register is controlled by hardware. All the bits are cleared when the interface is not enabled (EN=0 in ICCR). Figure 21.2-2 shows the bit configuration of the bus status register (IBSR0, IBSR1). 514 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Figure 21.2-2 Bit Configuration of Bus Status Register (IBSR0, IBSR1) Address: 7 IBSR0: 007970H IBSR1: 007980H 6 5 4 3 2 1 0 BB RSC AL LRB TRX AAS GCA ADT R R R R R R R R IBSR0/IBSR1 Initial value 00000000B bit0 ADT 0 1 Address data transfer bit Received data is not an address data (or the bus is open) Received data is an address data bit1 General call slave call address detection bit GCA 0 No general call address is detected 1 General call address is detected bit2 AAS Slave addressing bit 0 No addressing as slave 1 Received data is an address data bit3 TRX Transmission bit 0 Data transmission is not in progress 1 Data transmission is in progress bit4 LRB Reception bit 0 Reception is detected 1 Reception is not detected bit5 AL Arbitration lost detection flag bit 0 Arbitration loss is not detected 1 Arbitration loss is detected during master transmission bit6 RSC Re-activation condition detection flag bit 0 Re-activation condition is not detected 1 Re-activation condition is detected (bus busy) R : Read-only bit7 BB Bus busy detection fag bit 0 Stop condition is detected (bus idle) 1 Activation condition is detected (bus busy) : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 515 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Table 21.2-1 Functions of Bus Status Register (IBSR0, IBSR1) (1 / 2) Bit name Function bit7 BB: Bus busy flag bit This bit indicates the state of the I2C bus. "0": Stop condition is detected (bus idle) "1": Activation condition is detected (bus busy) This bit is set to "1" when the activation condition is detected. It is reset when the stop condition is detected. bit6 RSC: Re-activation condition detection bit This bit indicates the state of the re-activation condition. "0": Re-activation condition is not detected "1": Bus busy, re-activation condition is detected This bit is cleared when the address data transfer ends (ADT=0) or when the stop condition is detected. AL: Arbitration loss flag bit This bit indicates the state of the arbitration loss. "0": Arbitration loss is not detected "1": Arbitration loss occurs during master transmission This bit is cleared when writing "0" to the INT bit or "1" to the MSS bit of the IBCR register. Arbitration loss occurs if: • The transmission data does not match the data on the SDA line at the rising edge of SCL pin. • Another master generates a re-activation condition in the first bit of the data byte. • The interface cannot generate an activation or stop condition because the SCL pin line is driven to "L" by another slave device. LRB: Reception detection bit This bit is used to store an acknowledgement message from the receiving device to the transmitter. "0": Reception is detected "1": Reception is not detected This bit is changed if the hardware receives bit9 (response bit), and cleared if an activation or stop condition is detected. TRX: Transmission operation indication bit This bit indicates the transmission operation during the data transfer. "0": Data is not transmitted "1": Data is being transmitted • This bit is set to "1" if: - An activation condition occurs in master mode. - The first byte has been transferred, and read access is executed in slave mode, or the data is being sent in master mode. • This bit is set to "0" if: - The bus is idle (BB=0 in IBSR). - An arbitration loss occurs. - "1" is written to the SCC bit in the master interrupt status (MSS=1, INT=1). - The MSS bit is cleared in the master interrupt status (MSS=1, INT=1). - Interface is running in slave mode and the last transferred byte is not detected. - Interface is running in slave mode and the data is being received. - Interface is running in master mode and the data is being read from the slave. bit5 bit4 bit3 516 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface Table 21.2-1 Functions of Bus Status Register (IBSR0, IBSR1) (2 / 2) Bit name Function bit2 AAS: Slave addressing detection bit This bit indicates the state of the slave addressing detection. "0": The interface is not specified as a slave "1": The interface is specified as a slave This bit is cleared when a re-activation or stop condition is detected. This bit is set when either 7-bit or 10-bit slave address or both of the slave addresses are detected. bit1 GCA: General call address detection bit This bit indicates the state of the general call address (00H) detection. "0": General call address is not detected "1": General call address is detected This bit is cleared when a re-activation or stop condition is detected. ADT: Address data transfer detection bit This bit indicates the state of the address data transfer detection. "0": Received data is not an address data (or the bus is open) "1": Received data is an address data This bit is set to "1" if an activation condition is detected. It is cleared after the second byte if the 10-bit slave address header along with the write access is detected. Otherwise, it is cleared after the first byte. "After the first or second byte" means the following: • "0" is written to the MSS bit during master interrupt (MSS=1, INT=1 in IBCR). • "1" is written to the SCC bit during master interrupt (MSS=1, INT=1 in IBCR). • The INT bit is cleared. • All the bytes start to be transferred if the interface is not used as a master or slave for the current transfer. bit0 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 517 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface 21.2.2 MB90860E Series Bus Control Register (IBCR0, IBCR1) This section explains the function of the bus control register (IBCR0, IBCR1). ■ Functions of Bus Control Register (IBCR0, IBCR1) The bus control register (IBCR0, IBCR1) has the following functions: • Interrupt enable • Interrupt generation • Bus error detection • Re-activation condition generation • Master/slave mode selection • General call acknowledgement generation enable • Data byte acknowledgement generation enable ■ Bit Function of Bus Control Register (IBCR0, IBCR1) The write access to this register occurs only if INIT=1 or the transfer is started. When the ACK bit or GCAA bit is changed, the bus error can occur. Therefore, user cannot perform the write access to this register during the transfer operation. All the bits except BER and BEIE are cleared if the interface is not enabled (EN=0 in ICCR). Figure 21.2-3 shows the bit configuration of the bus control register (IBCR0, IBCR1). 518 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Figure 21.2-3 Bit Configuration of Bus Control Register (IBCR0, IBCR1) Address: IBCR0: 007971H IBCR1: 007981H 15 14 13 12 11 10 9 8 BER BEIE SCC MSS ACK GCAA INTE INT IBCR0/IBCR1 Initial value 00000000B R/W R/W W R/W R/W R/W R/W R/W bit8 INT 0 1 Interrupt flag bit See Table 21.2-2 bit9 Interrupt enable bit INTE Interrupt disable bit 0 Interrupt enable bit 1 bit10 General call address acknowledgement bit GCCA No acknowledgement occurs 0 Acknowledgement occurs 1 bit11 ACK 0 1 Data byte acknowledgement setting bit No acknowledgement occurs when a data byte is received Acknowledgement occurs when a data byte is received bit12 Master/slave selection bit MSS Slave mode 0 1 Master mode (See Table 21.2-2 for details) bit13 Repeated activation condition generation bit SCC N/A 0 1 Repeated activation condition occurs during the master transfer bit14 Bus error interrupt enable bit BEIE Bus error interrupt disabled 0 Bus error interrupt enabled 1 bit15 BER R/W W : Readable/writable 0 : Write-only 1 Bus error flag bit Writing Bus error interrupt is cleared N/A Reading No error is detected An error is detected : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 519 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Table 21.2-2 Functions of Bus Control Register (IBCR0, IBCR1) (1 / 3) Bit name Function This bit is the bus error interrupt flag. The bit is set by hardware and cleared by user. For a read-modify-write access, "1" is always read. Write access "0": Bus error interrupt flag is cleared "1": N/A Read access "0": No bus error is detected "1": One of the following error states is detected: If this bit is set, the EN bit of the ICCR register is cleared. The I2C interface is stopped, and data transfer is halted. All the bits of the IBSR and IBCR registers except BER and BEIE are cleared. The BER bit must be cleared before the interface is enabled again. • This bit is set to "1" if: - An activation or stop condition is detected at an illegal location during the transfer of the address data or bit2 to bit9 (acknowledgement bits). - The 10-bit address header with 10-bit read access is received before the 10-bit write access is performed. • When the interface is enabled during the transfer, the detection of the first two conditions shown above is enabled after the first stop condition is received, in order to prevent an incorrect bus error report from being issued. bit15 BER: Bus error flag bit bit14 BEIE: Bus error interrupt enable bit This bit enables the bus error interrupt. Only user can change this bit. "0": Bus error interrupt disabled "1": Bus error interrupt enabled If this bit is set to "1", occurrence of interrupt is enabled when the BER bit is set to "1". SCC: Re-activation condition occurrence bit This bit is used to generate the re-activation condition. This bit is write-only and "0" is always read. "0": N/A "1": Re-activation condition occurs in the master transfer. If "1" is written to this bit in master mode (MSS=1, INT=1), a re-activation condition is generated and the INT bit is automatically cleared. bit13 520 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface Table 21.2-2 Functions of Bus Control Register (IBCR0, IBCR1) (2 / 3) Bit name bit12 bit11 bit10 Function MSS: Master/slave mode selection bit This bit is the master/slave mode selection bit. Only user can set this bit. It can be cleared by both user and hardware. "0": Enters the slave mode. "1": Enters the master mode and generates an activation condition to send the data byte of the address IDAR register. This bit is cleared when arbitration loss occurs during master transmission. If "0" is written to this bit during setting a master interrupt (MSS=1, INT=1), the INT bit is automatically cleared and a stop condition is generated to end the data transfer. Note that the MSS bit is immediately reset and the stop condition can be checked by polling the BB bit of the IBSR register. • If "1" is written to this bit when the bus is idle (MSS=0, BB=0), an activation condition is generated and the content (address data) of the IDAR register is sent. • If "1" is written to this bit while the bus is busy (BB=1, TRX=0 in IBSR; MSS=0 in IBCR), the interface waits for the bus to be open and starts transmission. • If the interface is specified as a slave for the address that is accompanied by a write access (data reception), the transmission starts after the transfer ends and the bus is open again. If the interface is transmitting the data as a slave (AAS=1, TRX=1 in IBSR), the data transmission does not start even if the bus is open again. It is important to check whether the interface is specified as a slave (AAS=1 in IBSR) for the address, whether the data transmission has ended normally (MSS=1 in IBCR), or whether the data byte transmission has failed (AL=1 in IBSR) at the next interrupt. Note: The transmission of the general call address is prohibited, because the receiving as the slave cannot be operation on the following condition. When (1) other LSI that is a master mode without this LSI exists on the bus, and (2) this LSI transmits the general call address as master, and (3) the arbitration lost is generated since the second byte. ACK: Data byte acknowledgement bit This bit enables an acknowledgement generation when a data byte is received. Only user can change this bit. "0": Acknowledgement does not occur when a data byte is received. "1": Acknowledgement occurs when a data byte is received. This bit is disabled when an address byte is received in slave mode. If the interface detects a 7-bit or 10-bit slave address, it acknowledges whether the corresponding enable bits (ITMK ENTB or ISMK ENTB) are set. The write access to this bit occurs only if an interrupt is in progress (INT=1) or the bus is idle (BB=0 in the IBSR register). The write access to this bit is available only if the interface is enabled (EN=1 in the ICCR register) and no bus error occurs (BER=0 in the IBCR register). GCAA: General call address acknowledgement bit This bit enables the acknowledgement generation when a general call address is received. Only user can change this bit. "0": Acknowledgement does not occur when a general call address is detected. "1": Acknowledgement occurs when a general call address is detected. The write access to this bit occurs only if an interrupt is in progress (INT=1) or the bus is idle (BB=0 in the IBSR register). The write access to this bit is available only if the interface is enabled (EN=1 in the ICCR register) and no bus error occurs (BER=0 in the IBCR register). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 521 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Table 21.2-2 Functions of Bus Control Register (IBCR0, IBCR1) (3 / 3) Bit name bit9 bit8 522 Function INTE: Interrupt enable bit This bit enables an interrupt generation. Only user can change this bit. "0": Interrupts disabled "1": Interrupt enabled If this bit is set to "1", occurrence of interrupt is enabled when the INT bit is set to "1" by hardware. INT: Interrupt flag bit This bit is the transfer end interrupt request flag. This bit is changed by hardware and can be cleared by user. For a read-modify-write access, "1" is always read. Write access "0": Clears the transfer end interrupt request flag "1": N/A Read access "0": The transfer is not ended, not related to the current transfer, or the bus is idle "1": This bit is set to "1" when a 1-byte data transmission/reception, including an acknowledgement bit, is completed, if the following conditions are met: • Device is a bus master • Device is specified as a slave for the address • General call address was received • Arbitration loss occurred If the device is specified as a slave for the address, this bit is set after the address data is received, including an acknowledgement bit (after the first byte for the 7-bit address reception, or after the second byte for the 10-bit address reception). If this bit is set to "1", the SCL line is maintained at the "L" level. If "0" is written to this bit, the settings are cleared. Then, the SCL pin line is opened to transfer the next byte, and a re-activation or stop condition is generated. This bit is cleared when "1" is written to the SCC bit or the MSS bit is cleared. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series ■ Contention of SCC, MSS, and INT Bits If data is simultaneously written to the SCC, MSS, and INT bits, contention occurs among the next-byte transfer, re-activation condition generation, and stop condition generation. If this situation occurs, the priorities are as follows: • Next-byte transfer and stop condition generation: When "0" is written to the INT bit and "0" is written to the MSS bit, writing of the MSS bit has precedence and a stop condition is generated. • Next-byte transfer and re-activation condition generation: When "0" is written to the INT bit and "1" is written to the SCC bit, writing of the SCC bit has precedence. A re-activation condition is generated, and the content of the IDAR register is transmitted. • Re-activation condition generation and stop condition generation: When "1" is written to the SCC bit and "0" is written to the MSS bit, clearing of the MSS bit has precedence. A stop condition is generated and the interface enters the slave mode. When an instruction that generates a start condition is executed (set "1" to the MSS bit) at timing as shown in Figure 21.2-4 and Figure 21.2-5, an arbitration loss detection (AL bit = 1) prevents an interrupt (INT bit = 1) from being generated. • Condition 1 in which an interrupt (INT bit = 1) does not occur upon detection of AL bit = 1 When an instruction that generates a start condition is executed (set "1" to the MSS bit in the IBCR register) with no start condition detected (BB bit = 0) and with the SDA or SCL pin at the "L" level. Figure 21.2-4 Diagram of Timing at Which an Interrupt Does Not Occur upon Detection of AL Bit = 1 SCL pin "L" SDA pin "L" 1 I2C operation enable state (EN bit = 1) Master mode setting (MSS bit = 1) Arbitration loss detection (AL bit) Bus busy (BB bit) 0 Interrupt (INT bit) CM44-10144-4E 0 FUJITSU SEMICONDUCTOR LIMITED 523 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series • Condition 2 in which an interrupt (INT bit = 1) does not occur upon detection of AL bit = 1 When an instruction that generates a start condition by enabling an I2C operation (EN bit = 1) is executed (set "1" to the MSS bit in the IBCR register) with the I2C bus occupied by another master. This is because, as shown in Figure 21.2-5, 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 21.2-5 Diagram of Timing at Which an Interrupt Does Not Occur upon Detection of AL Bit = 1 Start condition The INT bit interrupt does not occur in the 9th 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 shown below for software processing: 1) Execute the instruction that generates a start condition (set "1" to the MSS bit) 2) Use, for example, the timer function to wait for the time for 3-bit data transmission at the I2C transfer frequency set in the ICCR register.* Example: I2C transfer frequency of 100 kHz Time for 3-bit data transmission {1/(100 × 103)} × 3 = 30 3) Check the AL and BB bits in the IBSR register and, if the AL bit =1 and BB bit = 0, set the EN bit in the ICCR register to "0" to initialize I2C. When AL bit is not 1 and BB bit is not 0, perform normal processing. 524 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series A sample flow is given below: Master mode setting Set "1" to the MSS bit in the bus control register (IBCR) Wait for the time for 3-bit data transmission at the I2C transfer frequency set in the clock control register (ICCR)* NO BB bit = 0 and AL bit = 1 YES Set the EN bit to 0 to initialize I2C To normal process *: If an arbitration loss is detected, the AL bit is 1 after the time for 3-bit data transmission at the I2C transfer frequency has elapsed when the MSS bit is set to 1. • Example in which an interrupt (INT bit = 1) occurs upon detection of AL bit = 1 When an instruction which generates a start condition is executed (setting "1" to the MSS bit) with "bus busy" detected (BB bit = 1) and arbitration is lost, the INT bit interrupt occurs upon detection of AL bit = 1. Figure 21.2-6 Diagram of Timing at Which an Interrupt Occurs upon Detection of AL Bit = 1 Start condition Interrupt at the 9th clock SCL pin SDA pin Slave address ACK DAT EN bit MSS bit AL bit Clear AL bit by software BB bit INT bit CM44-10144-4E Open SCL pin clearing INT bit by software FUJITSU SEMICONDUCTOR LIMITED 525 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface 21.2.3 MB90860E Series 10-Bit Slave Address Register (ITBAH0/ITBAH1, ITBAL0/ITBAL1) This register (ITBAH0/ITBAH1, ITBAL0/ITBAL1) specifies the 10-bit slave address. ■ Functions of 10-Bit Slave Address Register (ITBAH0/ITBAH1, ITBAL0/ITBAL1) Write access to this register is available only if the interface is not enabled (EN=0 in ICCR). Figure 21.2-7 shows the bit configuration of the 10-bit slave address register (ITBAH0/ITBAH1, ITBAL0/ITBAL1). Figure 21.2-7 Bit Configuration of 10-Bit Slave Address Register (ITBAH0/ITBAH1, ITBAL0/ITBAL1) Address: 15 14 13 12 11 10 ITBAH0: 007973 H ITBAH1: 007983 H 9 8 TA9 TA8 R/W R/W Address: ITBAL0: 007972H ITBAL1: 007982H 7 6 5 4 3 2 1 0 ITBAH0/ITBAH1 (High) Initial value 00000000B ITBAL0/ITBAL1 (Low) TA7 TA6 TA5 TA4 TA3 TA2 TA1 TA0 Initial value R/W R/W R/W R/W R/W R/W R/W R/W 00000000B R/W : Readable/writable — : Unused bit Table 21.2-3 Functions of 10-Bit Slave Address Register (ITBAH0/ITBAH1, ITBAL0/ITBAL1) Bit name bit15 to bit10 bit9 to bit0 Function Unused bits "0" is always read from these bits. TA9 to TA0: 10-bit slave address bits If a 10-bit address is enabled (ENTB=1 in the ITMK register), the address data is received in the slave mode and then compared with the ITBA register. An acknowledgement is sent to the master after the address header of a 10-bit*1 with write access is received. Then, 2nd received byte is compared with the ITBAL register. If a match is detected, an acknowledgement signal is sent to the master device and the AAS bit is set. In addition, the interface generates a positive response when it receives the 10-bit header*2 with read access after a re-activation condition is generated. All bits of the slave address can be masked using the ITMK register. The received 10bit slave address is written back to the ITBA register. This is valid only when the AAS bit of the IBSR register is set to "1". * 1: The bit sequence for the 10-bit header (write access) consists of 11110, TA9, TA8, and 0. 2: The bit sequence for the 10-bit header (read access) consists of 11110, TA9, TA8, and 1. * 526 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series 21.2.4 10-Bit Slave Address Mask Register (ITMK0, ITMK1) This register includes the 10-bit slave address mask and 10-bit slave address enable bit. ■ Functions of 10-Bit Slave Address Mask Register (ITMK0, ITMK1) Figure 21.2-8 shows the bit configuration of the 10-bit slave address mask register (ITMK0, ITMK1). Figure 21.2-8 Bit Configuration of 10-Bit Slave Address Mask Register (ITMK0, ITMK1) 15 Address: 14 13 12 11 10 9 8 ITMKH0/ITMKH1 (High) Initial value ITMKH0: 007975H ITMKH1: 007985H ENTB RAL TM9 TM8 R/W R/W R/W R/W 7 Address: ITMKL0: 007974H ITMKL1: 007984H 6 5 4 3 2 1 0 TM7 TM6 TM5 TM4 TM3 TM2 TM1 TM0 00111111B ITMKL0/ITMKL1 (Low) Initial value 11111111B R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/writable — : Unused bits CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 527 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Table 21.2-4 Functions of 10-Bit Slave Address Mask Register (ITMK0, ITMK1) Bit name Function ENTB: 10-bit slave address enable bit This bit enables a 10-bit slave address (and the reception response). Write access to this bit is available only if the interface is not enabled (EN=0 in ICCR). "0": 10-bit slave address disabled "1": 10-bit slave address enabled bit14 RAL: Reception slave address length This bit indicates whether the interface is specified as a 7-bit or 10-bit slave for the address. This bit is read-only. "0": Specified as a 7-bit slave for the address "1": Specified as a 10-bit slave for the address If both the 10-bit and 7-bit slave addresses are enabled (ENTB=1, ENSB=1), this bit can be used to determine whether the interface is specified as a 7-bit or 10-bit slave for the address. The content is valid only if the AAS bit of the IBSR register is set to "1". This bit is reset when the interface is disabled (EN=0 in ICCR). bit13 to bit10 Unused bits "1" is always read from these bits. TM: 10-bit slave address mask bits This register is used to mask the 10-bit slave address of the interface. Write access to these bits is available only if the interface is disabled (EN=0 in ICCR). "0": Bits are not used for comparison of slave addresses "1": Bits are used for comparison of slave addresses These bits can be used to make the interface check for multiple 10-bit slave addresses. Only the bit set as "1" in this register is used for comparison of 10-bit slave addresses. The received slave address is written back to the ITBA register. The slave address can be determined by reading the ITBA register when the AAS bit of the IBSR register is "1". Note: If the address mask is changed after the interface is enabled, the slave address that was previously received can be overwritten and the slave address should be set again. bit15 bit9 to bit0 528 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series 21.2.5 7-Bit Slave Address Register (ISBA0, ISBA1) This register specifies the 7-bit slave address. ■ Functions of 7-Bit Slave Address Register (ISBA0, ISBA1) Write access to this register is available only if the interface is not enabled (EN=0 in ICCR). Figure 21.2-9 shows the bit configuration of the 7-bit slave address register (ISBA0, ISBA1). Figure 21.2-9 Bit Configuration of 7-Bit Slave Address Register (ISBA0, ISBA1) Address: ISBA0: 007976H ISBA1: 007986H 7 6 5 4 3 2 1 0 ISBA0/ISBA1 SA6 SA5 SA4 SA3 SA2 SA1 SA0 R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B R/W : Readable/writable — : Unused bit Table 21.2-5 Functions of 7-Bit Slave Address Register (ISBA0, ISBA1) Bit name bit7 bit6 to bit0 Function Unused bit "0" is always read from this bit. SA6 to SA0: 7-bit slave address bits If a 7-bit address is enabled (ENSB=1 in the ISMK register), the address data is received in the slave mode and then compared with the ISBA register. If a match is detected, an acknowledgement signal is sent to the master device and the AAS bit is set. All bits of the slave address can be masked using the ISMK register. The received 7bit slave address is written back to the ISBA register. This is valid only when the AAS bit of the IBSR register is set to "1". The interface does not compare the received data and the content of this register when a 10-bit header or a general call is received. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 529 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface 21.2.6 MB90860E Series 7-Bit Slave Address Mask Register (ISMK0, ISMK1) This register includes the 7-bit slave address mask (ISMK0, ISMK1) and 7-bit mode enable bit. ■ Functions of 7-Bit Slave Address Mask Register (ISMK0, ISMK1) Write access to this register is available only if the interface is not enabled (EN=0 in ICCR). Figure 21.2-10 shows the bit configuration of the 7-bit slave address mask register (ISMK0, ISMK1). Figure 21.2-10 Bit Configuration of 7-Bit Slave Address Mask Register (ISMK0, ISMK1) Address: 15 14 13 12 11 10 9 8 ISMK0: 007977H ISMK1: 007987H ENSB SM6 SM5 SM4 SM3 SM2 SM1 SM0 R/W R/W R/W R/W R/W R/W R/W R/W ISMK0/ISMK1 Initial value 01111111B R/W : Readable/writable Table 21.2-6 Functions of 7-Bit Slave Address Mask Register (ISMK0, ISMK1) Bit name bit15 bit14 to bit8 530 Function ENSB: 7-bit address enable bit This bit enables a 7-bit slave address (and the reception response). 0: 7-bit slave address disabled 1: 7-bit slave address enabled SM: 7-bit slave address mask bits This register is used to mask the 7-bit slave address of the interface. 0: Bits are not used for comparison of slave addresses 1: Bits are used for comparison of slave addresses These bits can be used to make the interface check for multiple 7-bit slave addresses. Only the bit set as "1" in this register is used for comparison of 7-bit slave addresses. The received slave address is written back to the ISBA register. The slave address can be determined by reading the ISBA register when the AAS bit of the IBSR register is "1". Note: If the address mask is changed after the interface is enabled, the slave address that was previously received can be overwritten and the slave address should be set again. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series 21.2.7 Data Register (IDAR0, IDAR1) Data register (IDAR0, IDAR1) is used for the serial data transfer. ■ Functions of Data Register (IDAR0, IDAR1) Figure 21.2-11 shows the bit configuration of the data register (IDAR0, IDAR1). Figure 21.2-11 Bit Configuration of Data Register (IDAR0, IDAR1) Address: IDAR0: 007978H IDAR1: 007988H 7 6 D7 D6 5 4 3 2 1 0 D5 D4 D3 D2 D1 D0 R/W R/W R/W R/W R/W R/W R/W R/W IDAR0/IDAR1 Initial value 00000000B R/W : Readable/writable Table 21.2-7 Functions of Data Register (IDAR0, IDAR1) Bit name bit7 to bit0 D7 to D0: Data bits CM44-10144-4E Function The data register is used for serial data transfer. Data from MSB is transferred first. Since the writing side of this register is configured as double buffers, the data written when the bus is being used (BB=1) is loaded into the register for serial transfer. When the INT bit of the IBCR register is cleared or the bus is idle (BB=0 in IBSR), the data byte is loaded into the internal transfer register. Since the internal register is directly read during reading, the received data value in this register is valid only if INT=1 in the IBCR register. FUJITSU SEMICONDUCTOR LIMITED 531 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface 21.2.8 MB90860E Series Clock Control Register (ICCR0, ICCR1) The clock control register (ICCR0, ICCR1) has the following functions: • Test mode enable • I/O pad noise filter enable • I2C interface operation enable • Serial clock frequency setting ■ Functions of Clock Control Register (ICCR0, ICCR1) Figure 21.2-12 shows the bit configuration of the clock control register (ICCR0, ICCR1). Figure 21.2-12 Bit Configuration of Clock Control Register (ICCR0, ICCR1) Address: ICCR0: 00797BH ICCR1: 00798BH 15 14 13 12 11 10 9 8 ICCR0/ICCR1 NSF EN CS4 CS3 CS2 CS1 CS0 Initial value R/W R/W R/W R/W R/W R/W R/W 00011111B R/W : Readable/writable — : Unused bit 532 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series Table 21.2-8 Functions of Clock Control Register (ICCR0, ICCR1) Bit name bit15 bit14 bit13 Function Unused bit "0" is always read from this bit. NSF: I/O pad noise filter enable bit This bit enables the noise filter built in the SDA and SCL I/O pad. 0: Noise filter disabled 1: Noise filter enabled This noise filter controls the single spike from the pulse width 0ns (minimum) to 1 to 1.5 cycles (maximum) of the internal bus. The maximum width of the spike wave that can be controlled is determined by the phase relationship between the I2C signal (SDA, SCL) and the machine clock. This bit should be set to "1" if the interface transmits/receives the data at speed of 100 kbps or more. EN: Enable bit This bit enables the operation of the I2C interface. Only user can set this bit. It can be cleared by both user and hardware. 0: Interface disabled 1: Interface enabled If this bit is set to "0", all bits of the IBSR and IBCR registers (except the BER and BEIE bits) are cleared. The module operation is disabled and the I2C line remains open. This bit is cleared by hardware if the bus error occurs (BER=1 in IBCR). Notes: • When operating the I2C interface is prohibited, sending and receiving is stopped at once. • Prohibit operating after confirming the generation of the sop condition (BB=0 in IBSR) (EN=0 in ICCR), when the I2C interface operating is prohibited after the stop condition is generated by writing "0" in the MSS bit. These bits set the serial bit transfer speed. These bits can be changed only if the interface is disabled (EN=0) or the EN bit is cleared simultaneously at the time of writing. n 1 bit12 to bit8 CS4 to CS0: Clock prescaler bits CS4 CS3 CS2 CS1 CS0 0 0 0 0 1 Bit rate: φ/28 (+1) 2 0 0 0 1 0 Bit rate: φ/40 (+1) 3 0 0 0 1 1 Bit rate: φ/52 (+1) 4 0 0 1 0 0 Bit rate: φ/64 (+1) … 31 1 1 1 1 1 Bit rate: φ/400 (+1) (+1): If the noise filter is enabled, add 1 to the divisor. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 533 CHAPTER 21 I2C INTERFACE (400 kHz) 21.2 Registers of I2C Interface MB90860E Series ■ Clock Prescaler Setting The values of CS0 to CS4 are calculated using the following formula: Bit rate = Bit rate = φ n*12 + 16 φ n*12 + 17 n>0, φ: Machine clock, noise filter disabled n>0, φ: Machine clock, noise filter disabled Table 21.2-9 Prescaler Setting n CS4 CS3 CS2 CS1 CS0 1 0 0 0 0 1 2 0 0 0 1 0 3 0 0 0 1 1 1 1 1 • • • 31 Note: 1 1 Do not use n=0 for the prescaler setting, because it is a violation against the SDA/SCL timing. ■ General Clock Frequency Table 21.2-10 shows the general machine clock frequency and the transmission bit transfer speed by the prescaler setting. Table 21.2-10 Relationship Between Prescaler Setting Value and Transmission Bit Transfer Speed 100 kbps (Noise filter disabled) Machine Clock [MHz] 534 400 kbps (Noise filter enabled) n Bit Transfer Speed [kbps] n Bit Transfer Speed [kbps] 24 19 98 4 369 20 16 96 3 377 16 12 100 2 390 40/3=13.3 10 98 2 325 12 9 96 2 292 64/6=10.6 8 94 1 367 10 7 100 1 344 8 6 90 1 275 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 21.3 Operations of I2C Interface CHAPTER 21 I2C INTERFACE (400 kHz) 21.3 Operations of I2C Interface The I2C bus consists of two bidirectional bus lines used for communication: one serial data line (SDA) and one serial clock line (SCL). The I2C interface has two corresponding open-drain I/O pins (SDA/SCL), enabling wired logic. ■ Activation Condition If "1" is written to the MSS bit when the bus is open (BB=0 in IBSR, MSS=0 in IBCR) to place the I2C interface in master mode and to generate an activation condition. If "1" is written to this bit when the bus is idle (MSS=0, BB=0), an activation condition is generated and the content (address data) of the IDAR register is sent. If "1" is written to the SCC bit during interrupt when the bus is running in the master mode (MSS=1, INT=1 in IBCR), a re-activation condition can be generated. If "1" is written to the MSS bit when the bus is busy (BB=1, TRX=0 in IBSR; MSS=0, INT=0 in IBCR), the interface waits for the bus to be open and starts transmission. If the interface is specified as a slave for the address that is accompanied by a write access (data reception), the transmission starts after the transfer ends and the bus is open again. If the interface is transmitting the data as a slave, the data transmission does not start even if the bus is open again. It is important to check whether the interface is specified as a slave (MSS=0 in IBCR, AAS=1 in IBSR) for the address, whether the data byte transmission has ended normally (MSS=1 in IBCR), or whether the data byte transmission has failed (AL=1 in IBSR) at the next interrupt. Otherwise, writing "1" to the MSS or SCC bit has no effect. ■ Stop Condition If "0" is written to the MSS bit in master mode (MSS=1, INT=1 in IBCR) to generate a stop condition and to place the device in slave mode. Otherwise, writing "1" to the MSS bit has no effect. After the MSS bit is cleared, the interface tries to generate a stop condition. However, a stop condition will fail to be generated if the SCL line is driven to the "L" level. An interrupt is generated after the next byte is transferred. ■ Slave Address Detection In slave mode, BB is set to "1" after an activation condition is generated. The data sent from the master device is received by the IDAR register. After the 8-bit data is received, the content of the IDAR register is compared to the ISBA register using the bit mask stored in ISMK if the ENSB bit in the ISMK register is "1". If the comparison result is a match, the AAS bit is set to "1" and the acknowledgement signal is sent to the master. Then, bit0 of the received data (bit0 of the IDAR register) is inverted and stored in the TRX bit. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 535 CHAPTER 21 I2C INTERFACE (400 kHz) 21.3 Operations of I2C Interface MB90860E Series If the ENTB bit in the ITMK register is "1" and the 10-bit address header (11110, TA9, TA8, 0) is detected, the interface sends an acknowledgement signal to the master and stores the last inverted data bit in the TRX register. No interrupt occurs. Then, the transferred byte is compared to the low-order byte of the ITBA register (using the bit mask stored in ITMK). If the result is a match, an acknowledgement signal is sent to the master, the AAS bit is set to 1, and an interrupt occurs. If the interface has been specified as a slave for the address and a re-activation condition is detected, the AAS bit is set to "1" and an interrupt occurs after the 10-bit address header (11110, TA9, TA8, 1) is received. 10-bit and 7-bit addresses and its bit masks have its own registers. Setting "1" to the ENSB bit of ISMK and the ENTB bit of ITMK enables the interface to check both of the addresses. The received slave address length can be determined whether to be 7 bits or 10 bits by reading the RAL bit of the ITMK register (this bit is valid only if the AAS bit is set to 1). If the interface is to be used only as a master, set both of the bits to "0" can prevent a slave address from being given to the interface. All the slave address bits can be masked by setting the corresponding mask register (ITMK or ISMK). ■ Slave Address Mask Only the bits set to "1" in the mask register (ITMK/ISMK) can be used for the address comparison. Other bits are all ignored. The received slave address can be read from the ITBA register (RAL=1: for a 10-bit address) or the ISBA register (RAL=0: for a 7-bit address) if the AAS bit is "1" in the IBSR register. If the bit mask is cleared, the interface can be used as the bus monitor because it is always specified as a slave for the address. Note that this feature does not become a real bus monitor because it generates an acknowledgement when a slave address is received even though no other slave device is available. ■ Slave Addressing In master mode, the BB and TRX bits are set to "1" after an activation condition is generated. The content of the IDAR register is sent starting with MSB first. When an acknowledgement signal is received from the slave device after the address data is sent, bit0 (bit0 of the IDAR register that is already sent) of the sent data is inverted and stored in the TRX bit. The acknowledgement response of the slave can be checked using the LRB bit of the IBSR register. This procedure also applies to the re-activation condition. 2 bytes must be sent for a 10-bit slave address for write access. The first byte is the 10-bit address header consisting of 11110, TA9, TA8, 0, and the second byte that follows includes the low-order 8 bits of the 10bit slave address (TA7 to TA0). The 10-bit slave is accessed for read, when the above byte sequence is sent and a re-activation condition (SCC bit of IBCR) is generated as well as the read access 10-bit address header (11110, TA9, TA8, 1). 536 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.3 Operations of I2C Interface MB90860E Series The address data bytes can be summarized as follows: • 7-bit slave, write access : Activation condition - TA6 TA5 TA4 TA3 TA2 TA1 TA0 0 • 7-bit slave, read access : Activation condition - TA6 TA5 TA4 TA3 TA2 TA1 TA0 1 • 10-bit slave, write access: Activation condition - 1 1 1 1 0 TA9 TA8 0 - TA7 TA6 TA5 TA4 TA3 TA2 TA1 TA0 • 10-bit slave, read access : Activation condition - 1 1 1 1 0 TA9 TA8 1 - TA7 TA6 TA5 TA4 TA3 TA2 TA1 TA0 - re-activation - 1 1 1 1 0 TA9 TA8 1 ■ Arbitration If other master device is sending the data simultaneously when the data is being sent in the master mode, the arbitration will occur. If the device sends the data value "1" and the data on the SDA line is the "L" level, the device assumes arbitration to have been lost and sets the AL bit to "1". The AL bit is set to "1" when neither an activation condition nor a stop condition can be generated for any reason even if the interface detects an activation condition in the first bit of the data byte. If the arbitration loss is detected, the MSS and TRX bits are cleared and the device enters the slave mode, and it can determine that its own arbitration loss occurs when the device's slave address is sent. ■ Acknowledgement The acknowledgement bit is sent from the receiver to the sender. The ACK bit of the IBCR register can be used to specify whether an acknowledgement is sent when the data byte is received. Even if an acknowledgement is not returned from the master during data transmission in slave mode (read access from other master), the TRX bit is set to "0" and the device enters the reception mode. This allows the master to generate a stop condition when the slave releases the SCL line. In master mode, an acknowledgement from the slave can be checked by reading the LRB bit of the IBSR register. Note: CM44-10144-4E General call address transmission cannot be used in multi-master mode. FUJITSU SEMICONDUCTOR LIMITED 537 CHAPTER 21 I2C INTERFACE (400 kHz) 21.4 Programming Flowcharts 21.4 MB90860E Series Programming Flowcharts This section provides programming example for transmission and reception to use the I2C interface (400 kHz) module. ■ Example of Slave Addressing and Data Transmission Figure 21.4-1 shows the sample flowcharts for the slave addressing and data transmission. Figure 21.4-1 Sample Flowcharts for Slave Addressing and Data Transmission 7-bit slave addressing Data transmission Start Start Specify the writing slave for the address Clear the BER bit (if it is 1) Interface enabled EN=1 IDAR = Data byte; INT = 0 IDAR: = sl.address<<1+RW; MSS : = 1; INT : = 0 NO INT=1? NO INT=1? YES YES YES BER = 1? YES Bus error BER = 1? NO NO AL = 1? YES ACK? (LRB = 0?) Transfer resumed. Check whether it is AAS AL = 1? YES Transfer resumed. Check whether it is AAS NO ACK? (LRB = 0?) NO NO YES YES Data transmission ready The last byte transmitted? YES NO No ACK from the slave. Generate a re-activation or stop condition Transfer completed. Re-activation condition or stop condition generated 538 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 21 I2C INTERFACE (400 kHz) 21.4 Programming Flowcharts MB90860E Series ■ Example of Data Reception Figure 21.4-2 shows the sample flowchart for the data reception. Figure 21.4-2 Sample Flowchart for Data Reception Start Specify the reading slave for the address Clear the ACK bit of IBCR if the data is the last byte to be read from the slave; INT: = 0 NO INT = 1? YES BER= 1? YES Bus error NO NO The last byte transmitted? YES Transfer completed. Re-activation condition or stop condition generated CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 539 CHAPTER 21 I2C INTERFACE (400 kHz) 21.4 Programming Flowcharts MB90860E Series ■ Example of Interrupt Handler Figure 21.4-3 shows the sample flowchart for the interrupt handler. Figure 21.4-3 Sample Flowchart for Interrupt Handler Start INT=1? Interrupt reception from another module NO YES Bus error BER = 1? YES GCA = 1? YES General call as slave NO NO YES YES AL = 1? Record the transfer failure and retry the transfer YES AAS = 1? AL = 1? NO YES Arbitration loss. Transfer resumed NO No ACK from the slave YES Generate a LRB = 1? re-activation or stop condition ADT = 1? NO Start to transfer new data upon the next INT. If required, change the ACK bit NO TRX = 1? TRX = 1? YES YES NO NO Read received byte from the IDAR register. If required, change the ACK bit Store the next sent byte to the IDAR register Read received byte from the IDAR register. If required, change the ACK bit Store the next sent byte to the IDAR register or clear MSS Clear the INT bit End 540 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION This chapter describes the functions and operations of the address match detection function. 22.1 Overview of Address Match Detection Function 22.2 Block Diagram of Address Match Detection Function 22.3 Configuration of Address Match Detection Function 22.4 Explanation of Operation of Address Match Detection Function 22.5 Program Example of Address Match Detection Function Code: CM44-00110-2E CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 541 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.1 Overview of Address Match Detection Function 22.1 MB90860E Series Overview of Address Match Detection Function The address match detection function is a function that compulsorily replaces the instruction with the INT9 instruction by the program, when the instruction address to be executed with CPU matches to the address set in the detection address setting register, and diverges to the interrupt processing program. Since the address match detection function can use the INT9 interrupt for instruction processing, the program can be corrected by patch processing. ■ Overview of Address Match Detection Function • The address of the instruction to be processed next to the instruction currently processed by the program is always held in the address latch through the internal data bus. The address match detection function always compares the value of the address held in the address latch with that of the address set in the detection address setting registers. When these compared values match, the next instruction to be processed by the CPU is forcibly replaced with the INT9 instruction, and the interrupt processing program is executed. • There are 6 detection address setting registers (PADR0 to PADR5), 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 or disabled for each register. 542 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.2 Block Diagram of Address Match Detection Function MB90860E Series 22.2 Block Diagram of Address Match Detection Function The address match detection module consists of the following blocks: • Address latch • Address detection control register (PACSR0/PACSR1) • Detection address setting registers (PADR0 to PADR5) ■ Block Diagram of Address Match Detection Function Figure 22.2-1 shows the block diagram of the address match detection function. Figure 22.2-1 Block Diagram of Address Match Detection Function Address latch Comparator INT9 instruction (INT9 interrupt generation) Detection address setting register 0 PADR0 (24-bit) Detection address setting register 1 Detection address setting register 5 … … … Internal data bus PADR1 (24-bit) PADR5 (24-bit) PACSR0 Reserved Reserved AD2E Reserved AD1E Reserved AD0E Reserved AD3E Reserved Address detection control register 0 (PACSR0) PACSR1 Reserved Reserved AD5E Reserved AD4E Reserved Address detection control register 1 (PACSR1) Reserved: Be sure to set to "0" ● Address latch The address latch stores the value of the address output to the internal data bus. ● Address detection control register (PACSR0/PACSR1) The address detection control register enables or disables output of an interrupt at an address match. ● Detection address setting registers (PADR0 to PADR5) The detection address setting registers set the address that is compared with the value of the address latch. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 543 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function 22.3 MB90860E Series Configuration of Address Match Detection Function This section lists and details the registers used by the address match detection function. ■ List of Registers and Initial Values of Address Match Detection Function Figure 22.3-1 List of Registers and Initial Values of Address Match Detection Function bit Address detection control register 0 (PACSR0) bit Address detection control register 1 (PACSR1) bit Detection address setting register 0 (PADR0): Lower bit Detection address setting register 0 (PADR0): Medium bit Detection address setting register 0 (PADR0): Upper bit Detection address setting register 1 (PADR1): Lower bit Detection address setting register 1 (PADR1): Medium bit Detection address setting register 1 (PADR1): Upper bit Detection address setting register 2 (PADR2): Lower bit Detection address setting register 2 (PADR2): Medium bit Detection address setting register 2 (PADR2): Upper bit Detection address setting register 3 (PADR3): Lower bit Detection address setting register 3 (PADR3): Medium bit Detection address setting register 3 (PADR3): Upper bit Detection address setting register 4 (PADR4): Lower bit Detection address setting register 4 (PADR4): Medium bit Detection address setting register 4 (PADR4): Upper bit Detection address setting register 5 (PADR5): Lower bit Detection address setting register 5 (PADR5): Medium bit Detection address setting register 5 (PADR5): Upper 7 0 15 0 7 x 15 x 7 x 15 x 7 x 15 x 7 x 15 x 7 x 7 x 15 x 7 x 15 x 7 x 15 x 7 x 15 x 7 x 6 0 14 0 6 x 14 x 6 x 14 x 6 x 14 x 6 x 14 x 6 x 6 x 14 x 6 x 14 x 6 x 14 x 6 x 14 x 6 x 5 0 13 0 5 x 13 x 5 x 13 x 5 x 13 x 5 x 13 x 5 x 5 x 13 x 5 x 13 x 5 x 13 x 5 x 13 x 5 x 4 0 12 0 4 x 12 x 4 x 12 x 4 x 12 x 4 x 12 x 4 x 4 x 12 x 4 x 12 x 4 x 12 x 4 x 12 x 4 x 3 0 11 0 3 x 11 x 3 x 11 x 3 x 11 x 3 x 11 x 3 x 3 x 11 x 3 x 11 x 3 x 11 x 3 x 11 x 3 x 2 0 10 0 2 x 10 x 2 x 10 x 2 x 10 x 2 x 10 x 2 x 2 x 10 x 2 x 10 x 2 x 10 x 2 x 10 x 2 x 1 0 9 0 1 x 9 x 1 x 9 x 1 x 9 x 1 x 9 x 1 x 1 x 9 x 1 x 9 x 1 x 9 x 1 x 9 x 1 x 0 0 8 0 0 x 8 x 0 x 8 x 0 x 8 x 0 x 8 x 0 x 0 x 8 x 0 x 8 x 0 x 8 x 0 x 8 x 0 x x: Undefined 544 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function MB90860E Series 22.3.1 Address Detection Control Register (PACSR0/PACSR1) The address detection control register enables or disables output of an interrupt at an address match. When an address match is detected if output of an interrupt at an address match is enabled, the INT9 interrupt is output. ■ Address Detection Control Register 0 (PACSR0) Figure 22.3-2 Address Detection Control Register 0 (PACSR0) Address bit 7 6 5 4 3 2 1 0 ReReReReRe00009EH served served AD2E served AD1E served AD0E served R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B bit 0 Reserved 0 Reserved bit Be sure to set the value to "0". bit 1 AD0E Address match detection enable bit 0 0 Disables address match detection in PADR0 1 Enables address match detection in PADR0 bit 2 Reserved 0 Reserved bit Be sure to set the value to "0". bit 3 AD1E Address match detection enable bit 1 0 Disables address match detection in PADR1 1 Enables address match detection in PADR1 bit 4 Reserved 0 Reserved bit Be sure to set the value to "0". bit 5 AD2E Address match detection enable bit 2 0 Disables address match detection in PADR2 1 Enables address match detection in PADR2 bit 6 Reserved 0 Reserved bit Be sure to set the value to "0". bit 7 Reserved R/W : Readable/Writable 0 Reserved bit Be sure to set the value to "0". : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 545 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function MB90860E Series Table 22.3-1 Functions of Address Detection Control Register 0 (PACSR0) Bit name bit7, bit6 Function Reserved bits Be sure to set these bits to "0". bit5 AD2E: Address match detection enable bit 2 The address match detection operation with the detection address setting register 2 (PADR2) 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 detection address setting registers 2 (PADR2) matches with the value of address latch at enabling the address match detection operation (AD2E=1), the INT9 instruction is immediately executed. bit4 Reserved bit Be sure to set this bit to "0". bit3 AD1E: Address match detection enable bit 1 The address match detection operation with the detection address setting 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 detection address setting 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 bit Be sure to set this bit to "0". bit1 AD0E: Address match detection enable bit 0 The address match detection operation with the detection address setting 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 detection address setting registers 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 bit Be sure to set this bit to "0". 546 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function MB90860E Series ■ Address Detection Control Register 1 (PACSR1) Figure 22.3-3 Address Detection Control Register 1 (PACSR1) Address bit 15 00003BH 14 13 12 11 10 9 8 ReReReReReserved served AD5E served AD4E served AD3E served R/W R/W R/W R/W R/W R/W R/W R/W Initial value 00000000B bit 8 Reserved 0 Reserved bit Be sure to set the value to "0". bit 9 AD3E Address match detection enable bit 3 0 Disables address match detection in PADR3 1 Enables address match detection in PADR3 bit 10 Reserved 0 Reserved bit Be sure to set the value to "0". bit 11 AD4E Address match detection enable bit 4 0 Disables address match detection in PADR4 1 Enables address match detection in PADR4 bit 12 Reserved 0 Reserved bit Be sure to set the value to "0". bit 13 AD5E Address match detection enable bit 5 0 Disables address match detection in PADR5 1 Enables address match detection in PADR5 bit 14 Reserved 0 Reserved bit Be sure to set the value to "0". bit 15 Reserved R/W : Readable/Writable 0 Reserved bit Be sure to set the value to "0". : Initial value CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 547 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function MB90860E Series Table 22.3-2 Functions of Address Detection Control Register 1 (PACSR1) Bit name bit15, bit14 Function Reserved bits Be sure to set these bits to "0". bit13 AD5E: Address match detection enable bit 5 The address match detection operation with the detection address setting register 5 (PADR5) 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 detection address setting registers 5 (PADR5) matches with the value of address latch at enabling the address match detection operation (AD5E=1), the INT9 instruction is immediately executed. bit12 Reserved bit Be sure to set this bit to "0". bit11 AD4E: Address match detection enable bit 4 The address match detection operation with the detection address setting register 4 (PADR4) 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 detection address setting registers 4 (PADR4) matches with the value of address latch at enabling the address match detection operation (AD4E=1), the INT9 instruction is immediately executed. bit10 Reserved bit Be sure to set this bit to "0". bit9 AD3E: Address match detection enable bit 3 The address match detection operation with the detection address setting register 3 (PADR3) 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 detection address setting registers 3 (PADR3) matches with the value of address latch at enabling the address match detection operation (AD3E=1), the INT9 instruction is immediately executed. bit8 Reserved bit Be sure to set this bit to "0". 548 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function MB90860E Series 22.3.2 Detection Address Setting Registers (PADR0 to PADR5) The value of an address to be detected is set in the detection address setting registers. When the address of the instruction processed by the program matches the address set in the detection address setting registers, the next instruction is forcibly replaced with the INT9 instruction, and the interrupt processing program is executed. ■ Detection Address Setting Registers (PADR0 to PADR5) Figure 22.3-4 Detection Address Setting Registers (PADR0 to PADR5) Address PADR5: Upper PADR2: Upper PADR5: Medium PADR2: Medium PADR5: Lower PADR2: Lower PADR4: Upper PADR1: Upper PADR4: Medium PADR1: Medium PADR4: Lower PADR1: Lower 0079F8 H 0079E8H bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 Initial value D23 D22 D21 D20 D19 D18 D17 D16 XXXXXXXX B 0079F7 H 0079E7H R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 D15 D14 D13 D12 D11 D10 D9 D8 Initial value 0079F6 H 0079E6H R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 D7 D6 D5 D4 D3 D2 D1 D0 Initial value R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 0079F5 H 0079E5H 0079F4 H 0079E4H 0079F3 H 0079E3H D23 D22 D21 D20 D19 D18 D17 D16 D13 D12 D11 D10 D9 D8 R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 D7 D6 D5 D4 D3 D2 D1 D0 R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 PADR3: Upper PADR0: Upper PADR3: Medium PADR0: Medium PADR3: Lower PADR0: Lower 0079F2 H 0079E2H 0079F1 H 0079E1H 0079F0 H 0079E0H D23 D22 D21 D20 D19 D18 D17 XXXXXXXX B Initial value XXXXXXXX B R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 D15 D14 XXXXXXXX B D16 Initial value XXXXXXXX B Initial value XXXXXXXX B Initial value XXXXXXXX B R/W R/W R/W R/W R/W R/W R/W R/W bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 D15 D14 D13 D12 D11 D10 D9 D8 Initial value R/W R/W R/W R/W R/W R/W R/W R/W bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 D7 D6 D5 D4 D3 D2 D1 D0 Initial value XXXXXXXX B XXXXXXXX B R/W R/W R/W R/W R/W R/W R/W R/W R/W : Readable/Writable X : Undefined CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 549 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function ■ Functions of Detection Address Setting Registers MB90860E Series • There are 6 detection address setting registers (PADR0 to PADR5) that consist of a upper byte (bank), medium byte, and lower byte, totaling 24 bits. Table 22.3-3 Address Setting of Detection Address Setting Registers Register name Interrupt output enabled Address setting upper Detection address setting register 0 (PADR0) Detection address setting register 1 (PADR1) Detection address setting register 2 (PADR2) Detection address setting register 3 (PADR3) Detection address setting register 4 (PADR4) Detection address setting register 5 (PADR5) 550 PACSR0: AD0E PACSR0: AD1E PACSR0: AD2E PACSR1: AD3E PACSR1: AD4E PACSR1: AD5E Set the upper 8 bits of detection address 0 (bank) medium Set the middle 8 bits of detection address 0 Lower Set the lower 8 bits of detection address 0 upper Set the upper 8 bits of detection address 1 (bank) medium Set the middle 8 bits of detection address1 Lower Set the lower 8 bits of detection address 1 upper Set the upper 8 bits of detection address 2 (bank) medium Set the middle 8 bits of detection address 2 Lower Set the lower 8 bits of detection address 2 upper Set the upper 8 bits of detection address 3 (bank) medium Set the middle 8 bits of detection address 3 Lower Set the lower 8 bits of detection address 3 upper Set the upper 8 bits of detection address 4 (bank) medium Set the middle 8 bits of detection address 4 Lower Set the lower 8 bits of detection address 4 upper Set the upper 8 bits of detection address 5 (bank) medium Set the middle 8 bits of detection address 5 Lower Set the lower 8 bits of detection address 5 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.3 Configuration of Address Match Detection Function MB90860E Series • In the detection address setting registers (PADR0 to PADR5), starting address (first byte) of instruction to be replaced with the INT9 instruction should be set. Figure 22.3-5 Setting of Starting Address of Instruction Code to be Replaced with INT9 Instruction Set to detection address (High: FFH, Middle: 00H, Low: 1FH) Address FF001CH: FF001FH: FF0022H: Instruction code A8 00 00 4A 00 00 4A 80 08 Mnemonic MOVW MOVW MOVW RW0,#0000 A,#0000 A,#0880 Notes: • When an address other than the first byte is set to the detection address setting registers (PADR0 to PADR5), the instruction code is not replaced with the INT9 instruction and a program of an interrupt processing is not be performed. When the address is set to the second byte or subsequent, the address specified by the instruction code is replaced with 01H (INT9 instruction code) and, which may cause malfunction. • The detection address setting registers (PADR0 to PADR5) should be set after disabling the address match detection (PACSR: ADnE=0) of the corresponding address match control registers. If the detection address setting 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. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 551 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.4 Explanation of Operation of Address Match Detection Function 22.4 MB90860E Series Explanation of Operation of Address Match Detection Function If the addresses of the instructions executed in the program match those set in the detection address setting registers (PADR0 to PADR5), the address match detection function will replace the first instruction code executed by the CPU with the INT9 (01H) instruction to branch to the interrupt processing program. ■ Operation of Address Match Detection Function Figure 22.4-1 shows the operation of the address match detection function. Figure 22.4-1 Operation of Address Match Detection Function Program execution Address Address of the instruction to be executed by program matches detection address setting register 0 FF001CH: FF001FH: FF0022H: Instruction code A8 00 00 4A 00 00 4A 80 08 Mnemonic MOVW MOVW MOVW RW0,#0000 A,#0000 A,#0880 Replaced with the INT9 instruction (01H) ■ Setting Detection Address • Disable the detection address setting register 0 (PADR0) where the detection address is set for address match detection (PACSR0: AD0E=0). • Set the detection address in the detection address setting register 0 (PADR0). Set FFH at the upper bits, 00H at the medium bits, and 1FH at the lower bits of the detection address setting register 0 (PADR0). • Enable the detection address setting register 0 (PADR0) where the detection address is set for address match detection (PACSR0: AD0E=1). ■ Program Execution • If the address of the instruction to be executed in the program matches the set detection address, the first instruction code at the matched address is replaced with the INT9 instruction code (01H). • INT9 instruction is executed. INT9 interrupt is generated and then interrupt processing program is executed. 552 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.4 Explanation of Operation of Address Match Detection Function MB90860E Series 22.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 22.4-2 gives an example of the system configuration using the address match detection function. Figure 22.4-2 Example of System Configuration Using Address Match Detection Function Serial E2PROM interface MCU E2PROM F2MC-16LX Storing patch program Pull-up resistor SIN CM44-10144-4E Connector (UART) Fetching patch program from the outside FUJITSU SEMICONDUCTOR LIMITED 553 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.4 Explanation of Operation of Address Match Detection Function MB90860E Series 2 ■ E PROM Memory Map Figure 22.4-3 shows the allocation of the patch program and data to store the patch program in E2PROM. Figure 22.4-3 Allocation of E2PROM Patch Program and Data E2PROM address PADR0 PADR1 0 0 0 0H Patch program byte count 0 0 0 1H Detection address 0 (Low) 0 0 0 2H Detection address 0 (Middle) 0 0 0 3H Detection address 0 (High) 0 0 0 4H Patch program byte count 0 0 0 5H Detection address 1 (Low) 0 0 0 6H Detection address 1 (Middle) 0 0 0 7H Detection address 1 (High) • • • PADR5 For patch program 1 • • • 0 0 1 4H Patch program byte count 0 0 1 5H Detection address 5 (Low) 0 0 1 6H Detection address 5 (Middle) 0 0 1 7H Detection address 5 (High) 0 0 2 0H 0 0 3 0H • • • 0070 For patch program 0 For patch program 5 Patch program 0 (main body) Patch program 1 (main body) • • • H Patch program 5 (main body) ● 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 with the INT9 instruction code due to program error is stored. This address is set in the detection address setting registers (PADR0 to PADR5). ● Patch program (main body) The program executed by the INT9 interrupt processing when the program address matches the detection 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>. It is much the same for the correction program 2 to 5. 554 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.4 Explanation of Operation of Address Match Detection Function MB90860E Series ■ Setting and Operation State ● Initial setting All the E2PROM data are cleared to 00H. ● Occurrence of program error • By using the connector (UART), information about the patch program is transmitted to the MCU from the outside according to the allocation of the E2PROM patch program and data. • The MCU stores the information received from outside in the E2PROM. ● Reset sequence • After reset, the MCU reads the byte count of the E2PROM patch program to check the presence or absence of the patch program. • If the byte count of the patch program is not 00H, the upper, medium and lower bits at detection addresses 0 to 5 are read and set in the detection address setting registers 0 to 5 (PADR0 to PADR5). The patch program (main body) is read according to the byte count of the patch program and written to RAM in MCU. • 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 operation is enabled (PACSR: AD0E=1, AD1E=1 ... AD5E=1). ● INT9 interrupt processing • Interrupt processing is performed by the INT9 instruction. This series has no interrupt request flag by address match detection. Therefore, if the stack information in the program counter is discarded, the detection address cannot be checked. When checking the detection address, check the value of program counter stacked in the interrupt processing routine. • The patch program is executed, branching to the normal program. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 555 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.4 Explanation of Operation of Address Match Detection Function MB90860E Series ■ Operation of Address Match Detection Function at Storing Patch Program in E2PROM Figure 22.4-4 shows the operation of the address match detection function at storing the patch program in E2PROM. Figure 22.4-4 Operation of Address Match Detection Function at Storing Patch Program in E2PROM 000000H (3) Patch program RAM Detection address setting registers (1) Detection address setting (reset sequence) E2PROM Serial E2PROM interface • Patch program byte count • Address for address detection • Patch program ROM (2) (4) Program error FFFFFFH (1) Execution of 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 556 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.4 Explanation of Operation of Address Match Detection Function MB90860E Series ■ Flow of Patch Processing for Patching Program Figure 22.4-5 shows the patch processing flow of the patch program using the address match detection function. Figure 22.4-5 Flow of Patch Processing for Patch Program 000000H I/O area 0000H E2PROM Patch program byte count: 80H 000100H Register/RAM area 0001H Detection address (Lower): 00H 000400H Patch program 0002H Detection address (Medium): 80H 000480H RAM area 0003H Detection address (Upper): FFH MCU (This series) RAM Stack area 0010H Patch program 000900H Detection address setting register 0090H FFFFH FF0000H Program error FF8000H ROM FF8050H FFFFFFH Reset YES INT9 E2PROM: Read 00H Branch to patch program JMP 000400H E2PROM : 0000H = 0 Execution of patch program 000400H to 000480H NO End of patch program JMP FF8050H Read detection address E2PROM: 0001H to 0003H ↓ MCU: Set to PADR0 Read patch program E2PROM: 0010H to 008FH ↓ MCU: 000400H to 000047FH Enable address match detection (PACSR: AD0E = 1) Execution of normal program NO CM44-10144-4E Program address = PADR0 YES INT9 FUJITSU SEMICONDUCTOR LIMITED 557 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.5 Program Example of Address Match Detection Function 22.5 MB90860E Series Program Example of Address Match Detection Function This section gives a program example for the address match detection function. ■ Program Example of Address Match Detection Function ● Processing specifications If the address of the instruction to be executed by the program matches the address set in the detection address setting register (PADR0), the INT9 instruction is executed. ● Coding example PACSR0 EQU PADRL EQU 00009EH 0079E0H PADRM EQU 0079E1H PADRH EQU 0079E2H ;Address detection ;Detection address ;(Low) ;Detection address ;(Middle) ;Detection address ;(High) control register 0 setting register 0 setting register 0 setting register 0 ; ;---------Main program----------------------------------------------CODE CSEG START: ;Assume that the items such as the ;stack pointer (SP) have been ;initialized. MOV PADRL,#00H ;Set address detection register 0 ;(Low) MOV PADRM,#00H ;Set address detection register 0 ;(Middle) MOV PADRH,#00H ;Set address detection register 0 ;(High) ; MOV I:PACSR0,#00000010B ;Enable address match • User processing • LOOP: • User processing • BRA LOOP ;---------Interrupt program-----------------------------------------WARI: • 558 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.5 Program Example of Address Match Detection Function User processing • RETI ;Returns from interrupt processing CODE ENDS ;---------Vector setting--------------------------------------------VECT CSEG ABS=0FFH ORG 00FFD8H DSL WARI ORG 00FFDCH ;Sets reset vector DSL START DB 00H ;Sets to single chip mode VECT ENDS END START CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 559 CHAPTER 22 ADDRESS MATCH DETECTION FUNCTION 22.5 Program Example of Address Match Detection Function 560 FUJITSU SEMICONDUCTOR LIMITED MB90860E Series CM44-10144-4E CHAPTER 23 ROM MIRRORING FUNCTION SELECT MODULE This chapter explains the functions and operations of the ROM mirroring function select module. 23.1 Overview of ROM Mirroring Function Select Module 23.2 ROM Mirroring Function Select Register (ROMM) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 561 CHAPTER 23 ROM MIRRORING FUNCTION SELECT MODULE 23.1 Overview of ROM Mirroring Function Select Module 23.1 MB90860E Series Overview of ROM Mirroring Function Select Module The ROM mirroring function select module provides a setting so that ROM data in the FF bank can be read by access to the 00 bank. ■ Block Diagram of ROM Mirroring Function Select Module Figure 23.1-1 Block Diagram of ROM Mirroring Function Select Module ROM Mirroring Function Select Register (ROMM) Internal data bus ReReReReReReReserved served served served served served served MI Address Address area 00 bank FF bank Data ROM ■ Access to FF Bank by ROM Mirroring Function Figure 23.1-2 shows the location in memory when the ROM mirroring function allows access to the 00 bank to read ROM data in the FF bank. Figure 23.1-2 Access to FF Bank by ROM Mirroring Function 008000H 00 bank ROM mirror area 00FFFFH F90000 H MB90V340E FE0000H MB90F867E/ES MB90867E/ES FF8000 H FFFFFFH 562 FF bank (area for ROM mirror) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 23 ROM MIRRORING FUNCTION SELECT MODULE 23.1 Overview of ROM Mirroring Function Select Module MB90860E Series ■ Memory Space with ROM Mirroring Function Enabled/Disabled Figure 23.1-3 shows the availability of access to memory space when the ROM mirroring function is enabled or disabled. Figure 23.1-3 Memory Space with ROM Mirroring Function Enabled/Disabled Single chip Internal ROM/ external bus External ROM/ external bus ROM area ROM area ROM area (image of FF bank) ROM area (image of FF bank) Extended I/O area Extended I/O area FFFFFFH Address #1 010000 H 008000 H 007900 H Extended I/O area : Internal Address #2 RAM 000100 H 0000F0H 000000 H Generalpurpose register RAM Generalpurpose register RAM : External : Access disabled I/O I/O I/O Generalpurpose register Address #1 Address #2 MB90F867E/ES MB90867E/ES Product type FE0000H 001900H MB90V340E-101/102 F80000H 007900H ■ List of Registers and Reset Values of ROM Mirroring Function Select Module Figure 23.1-4 List of Registers and Reset Values of ROM Mirroring Function Select Module bit ROM mirroring function select register (ROMM) 15 14 13 12 11 10 9 8 × × × × × × × 1 ×: Undefined CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 563 CHAPTER 23 ROM MIRRORING FUNCTION SELECT MODULE 23.2 ROM Mirroring Function Select Register (ROMM) 23.2 MB90860E Series ROM Mirroring Function Select Register (ROMM) The ROM mirroring function select register enables or disables the ROM mirroring function. When the ROM mirroring function is enabled, ROM data in the FF bank can be read by access to the 00 bank. ■ ROM Mirroring Function Select Register (ROMM) Figure 23.2-1 ROM Mirroring Function Select Register (ROMM) Address 15 14 13 12 11 10 9 8 MI 00006FH Initial value XXXXXXX1B W bit8 W X : Write only MI : Undefined 0 ROM mirroring function disabled : Undefined 1 ROM mirroring function enabled ROM mirroring function select bit : Initial value Table 23.2-1 Functions of ROM Mirroring Function Select Register (ROMM) Bit name bit15 to bit9 bit8 Note: 564 Function Undefined bits Read : The value is undefined. Write : No effect. MI: ROM mirroring function select bit This bit enables or disables the ROM mirroring function. When set to "0" : Disables ROM mirroring function. When set to "1" : Enables ROM mirroring function. • When the ROM mirroring function is enabled (MI=1), the data at ROM addresses "FF8000H" to "FFFFFFH" can be read by accessing the addresses "008000H" to "00FFFFH". While the ROM area at addresses "008000H" to "00FFFFH" is being used, access to the ROM mirroring function select register (ROMM) is prohibited. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY This chapter explains the functions and operation of the 1M-bit flash memory. The following three methods are available for writing data to and erasing data from the flash memory: 1) Parallel programmer 2) Serial programmer 3) Executing programs to write/erase data This chapter explains "3) Executing programs to write/ erase data". 24.1 Outline of 1M-Bit Flash Memory 24.2 Block Diagram of the Entire Flash Memory and Sector Configuration of the Flash Memory 24.3 Write/Erase Modes 24.4 Flash Memory Control Status Register (FMCS) 24.5 Starting the Flash Memory Automatic Algorithm 24.6 Confirming the Automatic Algorithm Execution State 24.7 Detailed Explanation of Writing to and Erasing Flash Memory 24.8 Notes on Using 1M-bit Flash Memory 24.9 Flash Security Feature 24.10 Example of the 1M-Bit Flash Memory Program CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 565 CHAPTER 24 1M-BIT FLASH MEMORY 24.1 Outline of 1M-Bit Flash Memory 24.1 MB90860E Series Outline of 1M-Bit Flash Memory The 1M-bit flash memory is mapped to the FFH to F9H banks in the CPU memory map. The functions of the flash memory interface circuit enable read-access and programaccess from the CPU in the same way as mask ROM. Instructions from the CPU can be used via the flash memory interface circuit to write data to and erase data from the flash memory. Internal CPU control therefore enables rewriting of the flash memory while it is mounted. As a result, improvements in programs and data can be performed efficiently. ■ Features of 1M-bit Flash Memory • Use of automatic program algorithm (Embedded Algorithm: Equivalent to MBM29LV200) • Erase pause/restart function provided • Detection of completion of writing/erasing using data polling or toggle bit functions • Detection of completion of writing/erasing using CPU interrupts • Sector erase function (any combination of sectors) • Minimum of 10,000 write/erase operations • Flash read cycle time (min.): 2 machine cycle Note: The manufacturer code and device code do not have the reading function. These codes cannot be accessed by the command. ■ Writing to/Erasing Flash Memory The flash memory cannot be written to and read at the same time. That is, when data is written to or erased from the flash memory, the program in the flash memory must first be copied to RAM. The entire process is then executed in RAM so that data is simply written to the flash memory. This eliminates the need for the program to access the flash memory from the flash memory itself. ■ Flash Memory Register (FMCS) Figure 24.1-1 Flash Memory Control Status Register (FMCS) Flash memory control status register (FMCS) Address: 0000AEH Read/write Initial value 7 6 5 4 3 2 1 0 INTE RDYINT WE RDY ReReReserved served served Reserved (R/W) (R/W) (R/W) (0) (0) (0) (R) (X) (R/W) (R/W) (R/W) (R/W) (0) (0) (0) (0) FMCS R/W : Readable/writable R : Read only 566 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.2 Block Diagram of the Entire Flash Memory and Sector Configuration of the Flash Memory MB90860E Series 24.2 Block Diagram of the Entire Flash Memory and Sector Configuration of the Flash Memory Figure 24.2-1 shows a block diagram of the entire flash memory with the flash memory interface circuit included. Figure 24.2-2 shows the sector configuration of the flash memory. ■ Block Diagram of the Entire Flash Memory Figure 24.2-1 Block Diagram of the Entire Flash Memory Flash memory interface circuit Port 0 Port 1 Port 2 Port 3 Port 4 Port 5 F2MC-16LX bus BYTE 1M-bit flash memory BYTE CE CE OE OE WE WE AQ0 to AQ18 AQ0 to AQ17 AQ -1 DQ0 to DQ15 DQ0 to DQ15 INT RY/BY RY/BY RESET Write enable interrupt signal (to CPU) External reset signal CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED RY/BY Write enable signal 567 CHAPTER 24 1M-BIT FLASH MEMORY 24.2 Block Diagram of the Entire Flash Memory and Sector Configuration of the Flash Memory ■ Sector Configuration of the 1M-bit Flash Memory MB90860E Series Figure 24.2-2 shows the sector configuration of the 1M-bit flash memory. The addresses in the figure indicate the high-order and low-order addresses of each sector. Figure 24.2-2 Sector Configuration of the 1M-bit Flash Memory MB90F867E/ES SA4 (16 K bytes) SA3 (8 K bytes) Programmer address* CPU address 7FFFFH FFFFFFH 7BFFFH FFBFFFH 79FFFH FF9FFFH 77FFFH FF7FFFH 6FFFFH FEFFFFH 60000H FE0000H SA2 (8 K bytes) SA1 (32 K bytes) SA0 (64 K bytes) *: The programmer address corresponds with CPU address for writing data to a flash memory with parallel programmer. Use the programmer address for writing/erasing with a general-purpose programmer. 568 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 24.3 Write/Erase Modes CHAPTER 24 1M-BIT FLASH MEMORY 24.3 Write/Erase Modes The flash memory can be accessed in two different ways: flash memory mode and alternative mode. Flash memory mode enables data to be directly written to or erased from the external pins. Alternative mode enables data to be written to or erased from the CPU via the internal bus. Use the mode external pins to select the mode. ■ Flash Memory Mode The CPU stops when the mode pins are set to 111 while the reset signal is asserted. The flash memory interface circuit is connected directly to ports 0, 1, 2, 3, 4, and 5, enabling direct control from the external pins. This mode makes the MCU seem like a standard flash memory to the external pins, and write/erase can be performed using a flash memory programmer. In flash memory mode, all operations supported by the flash memory automatic algorithm can be used. ■ Alternative Mode The flash memory is located in the FE/FC/F9 to FF banks of the CPU memory space and, like ordinary mask ROM, can be read-accessed and program-accessed from the CPU via the flash memory interface circuit. Since writing/erasing the flash memory is performed by instructions from the CPU via the flash memory interface circuit, this mode allows rewriting even when the MCU is soldered on the target board. Sector protect operations cannot be performed in these modes. ■ Flash Memory Control Signals Table 24.3-1 lists the flash memory control signals in flash memory mode. There is almost a one-to-one correspondence between the flash memory control signals and the external pins of the MBM29LV200. The VID (12 V) pins required by the sector protect operations are MD0, MD1, and MD2 instead of A9, RESET, and OE in the MBM29LV200. In flash memory mode, the external data bus signal width is limited to eight bits, enabling only one-byte access. The DQ15 to DQ8 pins are not supported. The BYTE pin should always be set to 0. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 569 CHAPTER 24 1M-BIT FLASH MEMORY 24.3 Write/Erase Modes MB90860E Series Table 24.3-1 Flash Memory Control Signals MB90F867E/ES Pin number Flash memory mode MBM29LV200 LQFP QFP 3 5 P30 AQ16 A15 4 6 P31 CE CE 5 7 P32 OE OE 6 8 P33 WE WE 7 (8) 9 (10) P34 (P35) AQ17 (AQ18) A16 9 11 P36 BYTE BYTE 10 12 P37 RY/BY RY/BY 16 to 19 18 to 21 P42 to P45 AQ8 to AQ11 A7 to A10 20, 21 22, 23 P46, P47 AQ12, AQ13 A11, A12 22, 23 24, 25 P50, P51 AQ14, AQ15 A13, A14 51 53 MD0 MD0 A9(VID) 50 52 MD1 MD1 RESET(VID) 49 51 MD2 MD2 OE(VID) 75 to 82 77 to 84 P00 to P07 DQ0 to DQ7 DQ0 to DQ7 83 to 86 85 to 88 P10 to P13 DQ8 to DQ11 DQ8 to DQ11 52 54 RST RESET RESET 87, 92 to 94 89, 94 to 96 P14 to P17 DQ12 to DQ15 DQ12 to DQ15 97 to 100, 1 to 4 P20 to P27 AQ0 to AQ7 A-1, A0 to A6 95 to 98, 99 to 2 570 Normal function FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.4 Flash Memory Control Status Register (FMCS) MB90860E Series 24.4 Flash Memory Control Status Register (FMCS) The flash memory control status register (FMCS) functions are described below. ■ Flash Memory Control Status Register (FMCS) Figure 24.4-1 Flash Memory Control Status Register (FMCS) Address: 0000AEH 7 6 INTE RDYINT 5 WE 4 3 2 1 0 Initial value ReReReReRDY served served served served R/W R/W R/W R 000X0000B R/W R/W R/W R/W bit0 Reserved bit Reserved 0 Be sure to set "0". bit1 Reserved bit Reserved 0 Be sure to set "0". bit2 Reserved bit Reserved 0 Be sure to set "0". bit3 Reserved bit Reserved 0 Be sure to set "0". bit4 RDY Flash memory write/erase status bit 0 Write/Erase operation executing (next write/erase operation disabled) 1 Write/erase operation completed (next write/erase operation enabled) bit5 WE Flash memory write/erase operations enable bit 0 Write/erase operation of flash memory area disabled 1 Write/erase operation of flash memory area enabled bit6 RDYINT Flash memory operation flag bit Reading Writing 0 Write/erase operation executing Clearing RDYINT bit 1 Write/erase operation completed No effect bit7 INTE R/W : Readable/writable R : Read only W : Write only X : Undefined : Initial value CM44-10144-4E Flash memory write/erase interrupt enable bit 0 Disable interrupt at write/erase completion 1 Enable interrupt at write/erase completion FUJITSU SEMICONDUCTOR LIMITED 571 CHAPTER 24 1M-BIT FLASH MEMORY 24.4 Flash Memory Control Status Register (FMCS) MB90860E Series Table 24.4-1 Function Description in the Control Status Register (FMCS) Bit name Function INTE: Flash memory write/erase interrupt enable bit This bit enables or disables an interrupt request output upon completion of the flash memory write/erase operation. When "1" is set, setting "1" in the flash memory operation flag bit (FMCS:RDYINT=1) causes an interrupt request to be output. RDYINT: Flash memory operation flag bit This bit shows the flash memory operation status. When the flash memory automatic algorithm ends upon completion of the flash memory write/ erase operation, this bit is set to "1". • When interrupt upon completion of writing/erasing the flash memory is enabled (FMCS:INTE=1), setting this bit to "1" causes an interrupt request to be generated. • When this bit is "0", writing/erasing the flash memory is disabled. When "0" is set, this bit is cleared. When "1" is set, operation is not affected. When using the read-modify-write (RMW) instruction, "1" is always read out. bit5 WE: Flash memory write/erase operations enable bit This bit enables or disables writing to/erasing flash memory area. This bit is set before starting the writing to/erasing flash memory command. When "0" is set, write/erase signal is not generated by executing the F9/FC/FE to FF bank write/erase command sequence. When "1" is set, write/erase to flash memory is enabled after executing the F9/FC/FE to FF bank write/erase command sequence. • When performing no write/erase operation, set this bit to "0" to avoid write/erase flash memory in mistake. bit4 RDY: Flash memory write/erase status bit This bit shows status of writing/erasing flash memory. • While this bit is "0", flash memory write/erase operation is disabled. • Even while this bit is "0", a read/reset command such as sector erase pause is accepted. When writing/erasing operation is ended, "1" is set. bit3 to bit0 Reserved: Reserved bits Be sure to set these bits to "0". bit7 bit6 Notes: 572 • The RDYINT and RDY bits cannot be changed at the same time. Create a program so that decisions are made using either of these bits. (See Figure 24.4-2). • This register can be accessed only with byte-access. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 24 1M-BIT FLASH MEMORY 24.4 Flash Memory Control Status Register (FMCS) Figure 24.4-2 Change Timing of RDYINT Bit and RDY Bit Automatic algorithm termination timing RDYINT bit RDY bit 1 machine cycle CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 573 CHAPTER 24 1M-BIT FLASH MEMORY 24.5 Starting the Flash Memory Automatic Algorithm 24.5 MB90860E Series Starting the Flash Memory Automatic Algorithm Four types of commands are available for starting the flash memory automatic algorithm: Read/Reset, Write, Chip Erase, and Sector Erase. Control of suspend and restart is enabled for Sector Erase. ■ Command Sequence Table Table 24.5-1 lists the commands used for flash memory write/erase. All of the data written to the command register is in bytes, but use word access to write. The data in the high-order bytes at this time is ignored. Table 24.5-1 Command Sequence Table Command sequence Bus write access 1st bus write cycle Address Data 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 — — — — — — — — — Read/reset* 1 FxXXXX XXF0 — 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) Sector erase suspend Entering address FxXXXX data (xxB0H) suspends erasing during sector erase. Sector erase restart Entering address FxXXXX data (xx30H) restarts erasing after erasing is suspended during sector erase. XX30 Notes: • The addresses Fx in the table should be used as the access target bank values for operations. This means FF/FE for 1M-bit flash memory, • The addresses in the table are the values in the CPU memory map. All addresses and data are represented using hexadecimal notation. However, X is an optional value. • RA: Read address • PA: Write address. Only even addresses can be specified. • SA: Sector address. See Section "24.2 Block Diagram of the Entire Flash Memory and Sector Configuration of the Flash Memory". • RD: Read data • PD: Write data. Only word data can be specified. *: Both of the two types of Read/Reset commands can reset the flash memory to read mode. 574 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.6 Confirming the Automatic Algorithm Execution State MB90860E Series 24.6 Confirming the Automatic Algorithm Execution State Because the write/erase flow of the flash memory is controlled using the automatic algorithm, the flash memory has hardware for posting its internal operating state and completion of operation. This automatic algorithm enables confirmation of the operating state of the built-in flash memory using the following hardware sequence flags. ■ Hardware Sequence Flags The hardware sequence flags are configured from the five-bit output of DQ7, DQ6, DQ5, and DQ3. The functions of these bits are those of the data polling flag (DQ7), toggle bit flag (DQ6), timing limit exceeded flag (DQ5), and sector erase timer flag (DQ3). The hardware sequence flags can therefore be used to confirm that writing or chip sector erase has been completed or that erase code write is valid. The hardware sequence flags can be referred by read-accessing the addresses of the target sectors in the flash memory after setting of the command sequence (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm"). Table 24.6-1 lists the bit assignments of the hardware sequence flags. Table 24.6-1 Bit Assignments of Hardware Sequence Flags CM44-10144-4E Bit No. 7 6 5 4 3 2 1 0 Hardware sequence flags DQ7 DQ6 DQ5 − DQ3 − − − FUJITSU SEMICONDUCTOR LIMITED 575 CHAPTER 24 1M-BIT FLASH MEMORY 24.6 Confirming the Automatic Algorithm Execution State MB90860E Series To determine whether automatic writing or chip sector erase is being executed, the hardware sequence flags can be checked or the status can be determined from the RDY bit of the flash memory control register (FMCS) that indicates whether writing has been completed. After writing/erasing has terminated, the state returns to the read/reset state. When creating a program, use one of the flags to confirm that automatic writing/erasing has terminated. Then, perform the next processing operation, such as data read. In addition, the hardware sequence flags can be used to confirm whether a second or subsequent sector erase code write is valid. The following sections describe each hardware sequence flag separately. Table 24.6-2 lists the functions of the hardware sequence flags. Table 24.6-2 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 Sector erase wait → Erase started 0 Toggle 0 0→1 Erase → Sector erase suspended (sector being erased) 0→1 Toggle → 1 0 1→0 Sector erase suspend → Erase restarted (sector being erased) 1→0 1→ Toggle 1 0→1 DATA:7 DATA:6 DATA:5 DATA:3 DQ7 Toggle 1 0 0 Toggle 1 1 Write → Write completed (write address specified) Chip sector erase → Erase completed State change for normal operation Sector erase suspended (sector not being erased) Write Abnormal operation Chip sector erase 576 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 24.6.1 Data Polling Flag (DQ7) CHAPTER 24 1M-BIT FLASH MEMORY 24.6 Confirming the Automatic Algorithm Execution State The data polling flag (DQ7) uses the data polling function to post that the automatic algorithm is being executed or has terminated. ■ Data Polling Flag (DQ7) Table 24.6-3 and Table 24.6-4 list the state transitions of the data polling flag. Table 24.6-3 Data Polling Flag State Transitions (State Change for Normal Operation) Operating state Write → Completed Chip/sector erase → Completed DQ7 DQ7 → DATA:7 0→1 Sector erase wait → Started Sector erase → Erase suspend (sector being erased) Sector erase suspend → Restarted (sector being erased) Sector erase suspended (sector not being erased) 0 0→1 1→0 DATA:7 Table 24.6-4 Data Polling Flag State Transitions (State Change for Abnormal Operation) Operating state Write Chip/sector erase DQ7 DQ7 0 ● Write Read-access during execution of the automatic write algorithm causes the flash memory to output the opposite data of bit 7 last written, regardless of the value at the address specified by the address signal. Read-access at the end of the automatic write algorithm causes the flash memory to output bit 7 of the read value of the address specified by the address signal. ● Chip/sector erase For a sector erase, read-access during execution of the chip erase/sector erase algorithm causes the flash memory to output 0 from the sector currently being erased. For a chip erase, read-access causes the flash memory to output "0" regardless of the value at the address specified by the address signal. Read-access at the end of the automatic erase algorithm causes the flash memory to output "1" in the same way. ● Sector erase suspend Read-access for an access from sector erase suspend causes the flash memory to output "1" if the address specified by the address signal belongs to the sector being erased. The flash memory outputs bit 7 (DATA: 7) of the read value at the address specified by the address signal if the address specified by the address signal does not belong to the sector being erased. Referencing this flag together with the toggle bit flag (DQ6) enables a decision to be made on whether the flash memory is in the sector erase suspended state and which sector is being erased. Note: CM44-10144-4E When the automatic algorithm is being started, read-access to the specified address is ignored. Since termination of the data polling flag (DQ7) can be accepted for a data read and other bits output, data read after the automatic algorithm has terminated should be performed after read-access has confirmed that data polling has terminated. FUJITSU SEMICONDUCTOR LIMITED 577 CHAPTER 24 1M-BIT FLASH MEMORY 24.6 Confirming the Automatic Algorithm Execution State 24.6.2 MB90860E Series Toggle Bit Flag (DQ6) Like the data polling flag (DQ7), the toggle bit flag (DQ6) uses the toggle bit function to post that the automatic algorithm is being executed or has terminated. ■ Toggle Bit Flag (DQ6) Table 24.6-5 and Table 24.6-6 list the state transitions of the toggle bit flag. Table 24.6-5 Toggle Bit Flag State Transitions (State Change for Normal Operation) Operating state Write → Completed Chip/sector erase → Completed DQ6 Toggle → DATA:6 Toggle → Stop Sector erase wait → Started Sector erase → Erase suspend (sector being erased) Sector erase suspend → Restarted (sector being erased) Sector erase suspended (sector not being erased) Toggle Toggle → 1 1 → Toggle DATA:6 Table 24.6-6 Toggle Bit Flag State Transitions (State Change for Abnormal Operation) Operating state Write Chip/sector erase DQ6 Toggle Toggle ● Write and chip/sector erase Continuous read-access during execution of the automatic write algorithm and chip/sector erase algorithm causes the flash memory to toggle the "1" or "0" state alternately for every read cycle, regardless of the value at the address specified by the address signal. Continuous read-access at the end of the automatic write algorithm and chip/sector erase algorithm causes the flash memory to stop toggling bit 6 and output bit 6 (DATA: 6) of the read value of the address specified by the address signal. ● Sector erase suspend Read-access during a sector erase suspend causes the flash memory to output "1" if the address specified by the address signal belongs to the sector being erased. The flash memory outputs bit 6 (DATA: 6) of the read value at the address specified by the address signal if the address specified by the address signal does not belong to the sector being erased. Reference: 578 For a write, if the sector where data is to be written is rewrite-protected, the toggle bit terminates the toggle operation after approximately 2 μs and without any data being rewritten. For an erase, if all of the selected sectors are rewrite-protected, the toggle bit performs toggling for approximately 100 μs and then returns to the read/reset state without any data being rewritten. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.6 Confirming the Automatic Algorithm Execution State MB90860E Series 24.6.3 Timing Limit Exceeded Flag (DQ5) The timing limit exceeded flag (DQ5) is used to post that execution of the automatic algorithm has exceeded the time (internal pulse count) prescribed in the flash memory. ■ Timing Limit Exceeded Flag (DQ5) Table 24.6-7 and Table 24.6-8 list the state transitions of the timing limit exceeded flag. Table 24.6-7 Timing Limit Exceeded Flag State Transitions (State Change for Normal Operation) Operating state Write → Completed Chip/sector erase → Completed DQ5 0 → DATA:5 0→1 Sector erase wait → Started Sector erase → Erase suspend (sector being erased) Sector erase suspend → Restarted (sector being erased) Sector erase suspended (sector not being erased) 0 0 0 DATA:5 Table 24.6-8 Timing Limit Exceeded Flag State Transitions (State Change for Abnormal Operation) Operating state Write Chip/sector erase DQ5 1 1 ● Write and chip/sector erase Read-access after write or chip/sector erase automatic algorithm activation causes the flash memory to output "0" if the time is within the prescribed time (time required for write/erase) or to output "1" if the prescribed time has been exceeded. Because this is done regardless of whether the automatic algorithm is being executed or has terminated, it is possible to determine whether write/erase was successful or unsuccessful. That is, when this flag outputs "1", writing can be determined to have been unsuccessful if the automatic algorithm is still being executed by the data polling function or toggle bit function. For example, writing "1" to a flash memory address where "0" has been written will cause the fail state to occur. In this case, the flash memory will lock and execution of the automatic algorithm will not terminate. In rare cases, it may terminate normally with writing "1". As a result, valid data will not be output from the data polling flag (DQ7). In addition, the toggle bit flag (DQ6) will exceed the time limit without stopping the toggle operation and the timing limit exceeded flag (DQ5) will output "1". Note that this state indicates that the flash memory is not faulty, but has not been used correctly. When this state occurs, execute the Reset command. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 579 CHAPTER 24 1M-BIT FLASH MEMORY 24.6 Confirming the Automatic Algorithm Execution State 24.6.4 MB90860E Series Sector Erase Timer Flag (DQ3) The sector erase timer flag (DQ3) is used to post whether the automatic algorithm is being executed during the sector erase wait period after the Sector Erase command has been started. ■ Sector Erase Timer Flag (DQ3) Table 24.6-9 and Table 24.6-10 list the state transitions of the sector erase timer flag. Table 24.6-9 Sector Erase Timer Flag State Transitions (State Change for Normal Operation) Operating state Write → Completed Chip/sector erase → Completed DQ3 0 → DATA:3 1 Sector erase wait → Started Sector erase → Erase suspend (sector being erased) Sector erase suspend → Restarted (sector being erased) Sector erase suspended (sector not being erased) 0→1 1→0 0→1 DATA:3 Table 24.6-10 Sector Erase Timer Flag State Transitions (State Change for Abnormal Operation) Operating state Write Chip/sector erase DQ3 0 1 ● Sector erase Read-access after the Sector Erase command has been started causes the flash memory to output "0" if the automatic algorithm is being executed during the sector erase wait period, regardless of the value at the address specified by the address signal of the sector that issued the command. The flash memory outputs "1" if the sector erase wait period has been exceeded. When the data polling function or toggle bit function indicates that the erase algorithm is being executed, internally controlled erase has already started if this flag is "1". Continuous write of the sector erase codes or commands other than the Sector Erase Suspend command will be ignored until erase is terminated. If this flag is "0", the flash memory will accept write of additional sector erase codes. To confirm this, it is recommended that the state of this flag be checked before continuing to write sector erase codes. If this flag is "1" after the second state check, it is possible that additional sector erase codes may not be accepted. ● Sector erase Read-access during execution of sector erase suspend causes the flash memory to output "1" if the address specified by the address signal belongs to the sector being erased. The flash memory outputs bit 3 (DATA: 3) of the read value of the address specified by the address signal if the address specified by the address signal does not belong to the sector being erased. 580 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory MB90860E Series 24.7 Detailed Explanation of Writing to and Erasing Flash Memory This section describes each operation procedure of flash memory Read/Reset, Write, Chip Erase, Sector Erase, Sector Erase Suspend, and Sector Erase Restart when a command that starts the automatic algorithm is issued. ■ Detailed Explanation of Flash Memory Write/Erase The flash memory executes the automatic algorithm by issuing a command sequence (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm") for a write cycle to the bus to perform Read/Reset, Write, Chip Erase, Sector Erase, Sector Erase Suspend, or Sector Erase Restart operations. Each bus write cycle must be performed continuously. In addition, whether the automatic algorithm has terminated can be determined using the data polling or other function. At normal termination, the flash memory is returned to the read/reset state. Each operation of the flash memory is described in the following order: • Setting the read/reset state • Writing data • Erasing all data (erasing chips) • Erasing optional data (erasing sectors) • Suspending sector erase • Restarting sector erase CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 581 CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory 24.7.1 MB90860E Series Setting Flash Memory to the Read/Reset State This section describes the procedure for issuing the Read/Reset command to set the flash memory to the read/reset state. ■ Setting the Flash Memory to the Read/Reset State The flash memory can be set to the read/reset state by sending the Read/Reset command in the command sequence table (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm") continuously to the target sector in the flash memory. The Read/Reset command has two types of command sequences that execute the first and third bus operations. However, there are no essential differences between these command sequences. The read/reset state is the initial state of the flash memory. When power is supplied on and when a command terminates normally, the flash memory is set to the read/reset state. In the read/reset state, other commands wait for input. In the read/reset state, data is read by regular read-access. As with the mask ROM, program access from the CPU is enabled. The Read/Reset command is not required to read data by a regular read. The Read/Reset command is mainly used to initialize the automatic algorithm in such cases as when a command does not terminate normally. 582 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory MB90860E Series 24.7.2 Writing Data to Flash Memory This section describes the procedure for issuing the Write command to write data to the flash memory. ■ Writing Data to the Flash Memory The data write automatic algorithm of the flash memory can be started by sending the Write command in the command sequence table (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm") continuously to the target sector in the flash memory. When data write to the target address is completed in the fourth cycle, the automatic algorithm and automatic write are started. ● Specifying addresses Only even addresses can be specified as the write addresses specified in a write data cycle. Odd addresses cannot be written correctly. That is, writing to even addresses must be done in units of word data. Writing can be done in any order of addresses or even if the sector boundary is exceeded. However, the Write command writes only data of one word for each execution. ● Notes on writing data Writing cannot return data "0" to data "1". When data "1" is written to data "0", the data polling algorithm (DQ7) or toggle operation (DQ6) does not terminate and the flash memory elements are determined to be faulty. If the time prescribed for writing is thus exceeded, the timing limit exceeded flag (DQ5) is determined to be an error. Otherwise, the data is viewed as if dummy data "1" had been written. However, when data is read in the read/reset state, the data remains 0. Data 0 can be set to data "1" only by erase operations. All commands are ignored during execution of the automatic write algorithm. If a hardware reset is started during writing, the data of the written addresses will be unpredictable. ■ Writing to the Flash Memory Figure 24.7-1 is an example of the procedure for writing to the flash memory. The hardware sequence flags (see Section "24.6 Confirming the Automatic Algorithm Execution State") can be used to determine the state of the automatic algorithm in the flash memory. Here, the data polling flag (DQ7) is used to confirm that writing has terminated. The data read to check the flag is read from the address written to last. The data polling flag (DQ7) changes at the same time that the timing limit exceeded flag (DQ5) changes. For example, even if the timing limit exceeded flag (DQ5) is "1", the data polling flag bit (DQ7) must be rechecked. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 583 CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory MB90860E Series Also for the toggle bit flag (DQ6), the toggle operation stops at the same time that the timing limit exceeded flag bit (DQ5) changes to "1". The toggle bit flag (DQ6) must therefore be rechecked. Figure 24.7-1 Example of the Flash Memory Write Procedure Start erasing FMCS:WE(bit5) Enable erasing to flash memory Erase commandsequence (1) FxAAAAH <- XXAAH (2) Fx5554H <- XX55H (3) FxAAAAH <- XX80H (4) FxAAAAH <- XXAAH (5) Fx5554H <- XX55H (6) Sectoraddress <- Erase code (XX30H) YES Another erase sector? NO (6) Sectoraddress <- Erase code (XX30H) Read internal address 1 Read internal address Read internal address 2 1 YES Toggle bit (DQ6) Data 1 (DQ6)=Data 2 (DQ6) 0 Erase specification has not been added within 50 s. Set remainder re-execution flag,and terminate erase once NO 0 Secter erase timer (DQ3) Timing limit (DQ5) 1 Read internal address 1 Read internal address 2 NO Toggle bit (DQ6) Data 1 (DQ6)=Data 2 (DQ6) YES Erase error Remainder re-execution flag? YES NO FMCS:WE(bit5) Disable erasing to flash memory X: Any value Complete erasing 584 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory MB90860E Series 24.7.3 Erasing All Data (Erasing Chips) of Flash Memory This section describes the procedure for issuing the Chip Erase command to erase all data in the flash memory. ■ Erasing All Data (Erasing Chips) in the Flash Memory All data can be erased from the flash memory by sending the Chip Erase command in the command sequence table (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm") continuously to the target sector in the flash memory. The Chip Erase command is executed in six bus operations. When writing of the sixth cycle is completed, the chip erase operation is started. For chip erase, the user need not write to the flash memory before erasing. During execution of the automatic erase algorithm, the flash memory writes 0 for verification before all of the cells are erased automatically. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 585 CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory 24.7.4 MB90860E Series Erasing Optional Data (Erasing Sectors) in Flash Memory This section describes the procedure for issuing the Sector Erase command to erase optional data (erase sector) in the flash memory. Individual sectors can be erased. Multiple sectors can also be specified at one time. ■ Erasing Optional Data (Erasing Sectors) in the Flash Memory Optional sectors in the flash memory can be erased by sending the Sector Erase command in the command sequence table (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm") continuously to the target sector in the flash memory. ● Specifying sectors The Sector Erase command is executed in six bus operations. Sector erase wait of 50 μs is started by writing the sector erase code (30H) to an accessible even-numbered address in the target sector in the sixth cycle. To erase multiple sectors, write the erase code (30H) to the addresses in the target sectors after the above processing operation. ● Notes on specifying multiple sectors Erase is started when the sector erase wait period of 50 μs terminates after the final sector erase code has been written. That is, to erase multiple sectors at one time, the address of the next erase sector and the erase code (sixth cycle of the command sequence) must be written within 50μs. Otherwise, the address and erase code may not be accepted. The sector erase timer (hardware sequence flag DQ3) can be used to check whether writing of the subsequent sector erase code is valid. At this time, specify so that the address used for reading the sector erase timer indicates the sector to be erased. ■ Erasing Sectors in the Flash Memory The hardware sequence flags (see Section "24.6 Confirming the Automatic Algorithm Execution State") can be used to determine the state of the automatic algorithm in the flash memory. Figure 24.7-2 shows an example of the procedure for erasing sectors in the flash memory. Here, the toggle bit flag (DQ6) is used to confirm that erasing has terminated. Note that the data that is read to check the flag is read from the sector to be erased. The toggle bit flag (DQ6) stops the toggle operation at the same time that the timing limit exceeded flag (DQ5) is changed to 1. For example, even if the timing limit exceeded flag (DQ5) is 1, the toggle bit flag (DQ6) must be rechecked. The data polling flag (DQ7) also changes at the same time that the timing limit exceeded flag bit (DQ5) changes. As a result, the data polling flag (DQ7) must be rechecked. 586 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory MB90860E Series Figure 24.7-2 Example of the Flash Memory Sector Erase Procedure Start erasing FMCS:WE(bit5) Enable erasing to flash memory Erase command sequence (1) FxAAAAH <- XXAAH (2) Fx5554H <- XX55H (3) FxAAAAH <- XX80H (4) FxAAAAH <- XXAAH (5) Fx5554H <- XX55H (6) Sector address <- Erase code (XX30H) YES Another erase sector? NO (6) Sector address <- Erase code (XX30H) Read internal address 1 Read internal address Read internal address 2 1 Toggle bit (DQ6) Data 1 (DQ6)=Data 2 (DQ6) YES 0 Erase specification has not been added within 50 μs. Set remainder re-execution flag, and terminate erase once NO 0 Secter erase timer (DQ3) Timing limit (DQ5) 1 Read internal address 1 Read internal address 2 NO Toggle bit (DQ6) Data 1 (DQ6)=Data 2 (DQ6) YES Erase error Remainder re-execution flag? YES NO FMCS:WE(bit5) Disable erasing to flash memory X: Any value Complete erasing CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 587 CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory 24.7.5 MB90860E Series Suspending Sector Erase of Flash Memory This section describes the procedure for issuing the Sector Erase Suspend command to suspend erasing of flash memory sectors. Data can be read from sectors that are not being erased. ■ Suspending Sector Erase of Flash Memory Erasing of flash memory sectors can be suspended by sending the Sector Erase Suspend command in the command sequence table (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm") continuously to the target sector in the flash memory. The Sector Erase Suspend command suspends the sector erase operation being executed and enables data to be read from sectors that are not being erased. In this state, only reading is enabled; data cannot be written. This command is valid only during sector erase operations that include an erase wait time. The command will be ignored during chip erase or write operations. This command is implemented by writing the erase suspend code (B0H). At this time, specify an optional address in the flash memory for the address. An Erase Suspend command issued again during erasing of sectors will be ignored. Entering the Sector Erase Suspend command during the sector erase wait period will immediately terminate sector erase wait, cancel the erase operation, and set the erase stop state. Entering the Erase Suspend command during the erase operation after the sector erase wait period has terminated will set the erase suspend state after a maximum period of 20 μs has elapsed. Sector Erase Suspend command should be entered more than 20 μs after Sector Erase command or Sector Erase Restart command is issued. 588 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.7 Detailed Explanation of Writing to and Erasing Flash Memory MB90860E Series 24.7.6 Restarting Sector Erase of Flash Memory This section describes the procedure for issuing the Sector Erase Restart command to restart suspended erasing of flash memory sectors. ■ Restarting Sector Erase of Flash Memory Suspended erasing of flash memory sectors can be restarted by sending the Sector Erase Restart command in the command sequence table (see Table 24.5-1 in Section "24.5 Starting the Flash Memory Automatic Algorithm") continuously to the target sector in the flash memory. The Sector Erase Restart command is used to restart erasing of sectors from the sector erase suspend state set using the Sector Erase Suspend command. The Sector Erase Restart command is implemented by writing the erase restart code (30H). At this time, specify an optional address in the flash memory area for the address. If a Sector Erase Restart command is issued during sector erase, the command will be ignored. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 589 CHAPTER 24 1M-BIT FLASH MEMORY 24.8 Notes on Using 1M-bit Flash Memory 24.8 MB90860E Series Notes on Using 1M-bit Flash Memory This section contains notes on using 1M-bit flash memory. ■ Notes on Using Flash Memory ● Mode transition during data write/erase operation Do not change to the sub clock mode or a standby mode (sleep mode, stop mode, watch mode, time-base timer mode) when the flash memory is enabled for write operation (FMCS:WE=1). ● Input of a hardware reset (RST) To input a hardware reset when the automatic algorithm has not been started and reading is in progress, a minimum low-level width of 500 ns must be maintained. In this case, a minimum of 500 ns is required until data can be read from the flash memory after a hardware reset has been activated. Similarly, to input a hardware reset when the automatic algorithm has been activated and writing or erasing is in progress, a minimum low-level width of 500 ns must be maintained. In this case, 20 μs are required until data can be read after the operation for initializing the flash memory has terminated. A hardware reset during writing the data being written to be undefined. A hardware reset during erasing and power supply cut-off may make the sector being erased unusable. ● Canceling of a software reset and watchdog timer reset When the flash memory is being written to or erased with CPU access and if reset conditions occur while the automatic algorithm is active, the CPU may run out of control. This occurs because these reset conditions cause the automatic algorithm to continue without initializing the flash memory unit, possibly preventing the flash memory unit from entering the read state when the CPU starts the sequence after the reset has been deasserted. These reset conditions must be disabled during writing to or erasing of the flash memory. ● Program access to flash memory When the automatic algorithm is operating, read access to the flash memory is disabled. With the memory access mode of the CPU set to internal ROM mode, writing or erasing must be started after the program area is switched to another area such as RAM. In this case, when sectors (1M-bit flash memory: SA4, 2Mbit flash memory: SA6, and 3M-bit flash memory: SA8) containing interrupt vectors are erased, writing or erasing interrupt processing cannot be executed. ● Hold function When the CPU accepts a hold request, the write signal WE of the flash memory unit may be skewed, causing erroneous writing or erasing due to an erroneous write. When the acceptance of a hold request is enabled (HDE bit of ECSR set to 1), ensure that the WE bit of the control status register (FMCS) is 0. 590 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series CHAPTER 24 1M-BIT FLASH MEMORY 24.8 Notes on Using 1M-bit Flash Memory ● DMA transfer and extended intelligent I/O service (EI2OS) Because write and erase interrupts issued to the CPU from the flash memory interface circuit cannot be accepted by the DMA and EI2OS, they should not be used. ● Applying VID Applying VID required for the sector protect operation should always be started and terminated when the supply voltage is on. CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 591 CHAPTER 24 1M-BIT FLASH MEMORY 24.9 Flash Security Feature 24.9 MB90860E Series Flash Security Feature The flash security feature provides possibilities to protect the content of the flash memory. ■ Overview If the protection code of 01H is written in the security bit of flash memory, access to the flash memory is restricted. Once the flash memory is protected, performing the chip erase operation only can unlock the function otherwise read/write access to the flash memory from any external pins is not generally possible. This function is suitable for applications requiring security of self-containing program and data stored in the flash memory. Address of the security bit is depending on the flash memory size. Table 24.9-1 shows address of the security bit. Table 24.9-1 Address of Flash Security Bit Flash memory size MB90F867E/ES 1M-bit flash memory installed Address of security bit FE0001H ■ Setting Security To set the security, write the protection code 01H in security bit and perform external reset or restart the system. ■ Releasing Security Perform the chip erase ■ Operation with Security Enabled Read : Invalid data is read. Write : No writing can be performed. ■ Other Information • For setting the general-purpose parallel programmer, see the specification of the general-purpose parallel programmer to be used. • Writing the protection code is generally recommended to take place at the end of the flash programming. This is to avoid unnecessary protection during the programming. Notes: • Security bit is allocated in the flash memory area. Writing the protection code 01H makes security enable. Therefore, do not write 01H in the address when the security feature is not used. For address of the security bit, see Table 24.9-1. • Specifying sector of flash memory to set security for each sector cannot be performed. Security feature is only for all flash memory area. • When security enabled, the interrupt analysis of the flash memory cannot be performed. 592 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.10 Example of the 1M-Bit Flash Memory Program MB90860E Series 24.10 Example of the 1M-Bit Flash Memory Program This section provides an example of the 1M-bit flash memory program. ■ Example of the 1M-bit Flash Memory Program NAME FLASHWE TITLE FLASHWE ;-----------------------------------------------------------------;1Mbit-FLASH Sample program ; ;1:Transferring the program (address FFA000H, sector SA3) in FLASH to the ; RAM (address 001500H) ;2:Executing the program on the RAM ;3:Writing a PDR1 value to FLASH (address FE0000H, sector SA0) ;4:Reading the written value (address FF0000H, sector SA1) and outputting it ; to PDR2 ;5:Deleting the written sector (SA1) ;6:Outputting the deletion data confirmation ; Conditions ; • Number of RAM transfer bytes: 100H (256 Byte) ; • Judgment for the end of writing and deletion ; Judgment with DQ5 (timing limit excess flag) ; Judgment with DQ6 (toggle bit flag) ; Judgment with RDY (FMCS) ; • Error handling ; Outputting "Hi" to P00 to P07 ; Issuing the reset command ;-----------------------------------------------------------------; RESOUS IOSEG ABS=00 ;Definition of the RESOUS I/O segment ORG 0000H PDR0 RB 1 PDR1 RB 1 PDR2 RB 1 PDR3 RB 1 ORG 0010H DDR0 RB 1 DDR1 RB 1 DDR2 RB 1 DDR3 RB 1 ORG 00A1H CKSCR RB 1 ORG 00AEH FMCS RB 1 ORG 006FH ROMM RB 1 RESOUS ENDS ; SSTA SSEG RW 0127H STA_T RW 1 SSTA ENDS ; CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 593 CHAPTER 24 1M-BIT FLASH MEMORY 24.10 Example of the 1M-Bit Flash Memory Program MB90860E Series DATA DSEG ABS=0FFH ;FLASH command address ORG 5554H COMADR2 RW 1 ORG 0AAAAH COMADR1 RW 1 DATA ENDS ;-----------------------------------------------------------------;Main program (SA1) ;-----------------------------------------------------------------CODE CSEG START: ;---------------------------------------------------------;Initialization ;---------------------------------------------------------MOV CKSCR,#0BAH ;Setting to multiply-by-three MOV RP,#0 MOV A,#!STA_T MOV SSB,A MOVW A,#STA_T MOVW SP,A MOV ROMM,#00H ;Mirror OFF MOV PDR0,#00H ;For error confirmation MOV DDR0,#0FFH MOV PDR1,#00H ;Data input port MOV DDR1,#00H MOV PDR2,#00H ;Data output port MOV DDR2,#0FFH ;---------------------------------------------------------;The FLASH write deletion program (FFA000H) is transferred ;to the RAM(address 1500H). ;---------------------------------------------------------MOVW A,#1500H ;Transfer destination RAM area MOVW A,#0A000H ;Transfer source address (program location) MOVW RW0,#100H ;Number of bytes to be transferred MOVS ADB,PCB ;100H transfer from FFA000H to 001500H CALLP 001500H ;Jump to the address in which transferred program ;exists ;---------------------------------------------------;Data output ;---------------------------------------------------OUT MOV A,#0FEH MOV ADB,A MOVW RW2,#0000H MOVW A,@RW2+00 MOV PDR2,A END JMP * CODE ENDS ;-----------------------------------------------------------------;FLASH write deletion program (SA3) ;-----------------------------------------------------------------RAMPRG CSEG ABS=0FFH ORG 0A000H ;---------------------------------------------------------;Initialization ;---------------------------------------------------------MOVW RW0,#0500H ;RW0:RAM space for input data acquisition 00:0500 594 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 24 1M-BIT FLASH MEMORY 24.10 Example of the 1M-Bit Flash Memory Program MB90860E Series MOVW MOV MOV MOV MOV RW2,#0000H A,#00H DTB,A A,#0FFH ADB,A MOV MOV PDR3,#00H DDR3,#00H ;to ;RW2:Flash memory writing address FD:0000 to ;DTB change ;@RW0 bank specification ;ADB change 1 ;Specification of the bank for the write mode ;specification address ;Switch initialization ; WAIT1 BBC PDR3:0,WAIT1 ;PDR3:0 Start of writing with Hi ; ;-----------------------------------------------------------------; Writing(SA1) ;-----------------------------------------------------------------MOV A,PDR1 MOVW @RW0+00,A ;Allocation of PDR1 data in the RAM MOV FMCS,#20H ;Write mode setting MOVW ADB:COMADR1,#00AAH ;Flash write command 1 MOVW ADB:COMADR2,#0055H ;Flash write command 2 MOVW ADB:COMADR1,#00A0H ;Flash write command 3 ; MOVW A,@RW0+00 ;Writing of input data (RW0) into the flash ;memory (RW2) ; MOVW @RW2+00,A WRITE ;Wait time check ;---------------------------------------------------------;Error when the time limit excess check flag is set and the ;toggle operation is ongoing ;---------------------------------------------------------MOVW A,@RW2+00 AND A,#20H ;DQ5 time limit check BZ NTOW ;Time limit over MOVW A,@RW2+00 ;AH MOVW A,@RW2+00 ;AL XORW A ;XOR of AH and AL (1 if the value is different) AND A,#40H ;Is the DQ6 toggle bit different? BNZ ERROR ;If it is different, go to ERROR. ;---------------------------------------------------------;Write end check (FMCS-RDY) ;---------------------------------------------------------NTOW MOV A,FMCS AND A,#10H ;Extraction of the FMCS RDY bit (4 bits) BZ WRITE ;Is writing ended? MOV FMCS,#00H ;Release of the write mode ;---------------------------------------------------------;Write data output ;---------------------------------------------------------MOVW RW2,#0000H ;Write data output MOVW A,@RW2+00 MOV PDR2,A ; WAIT2 BBC PDR3:1, WAIT2; PDR:1 Start of the sector deletion with Hi ; ;------------------------------------------------------------------ CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 595 CHAPTER 24 1M-BIT FLASH MEMORY 24.10 Example of the 1M-Bit Flash Memory Program MB90860E Series ;Sector deletion (SA1) ;-----------------------------------------------------------------MOV @RW2+00,#0000H ;Address initialization MOV FMCS,#20H ;Deletion mode setting MOVW ADB:COMADR1,#00AAH ;Flash deletion command 1 MOVW ADB:COMADR2,#0055H ;Flash deletion command 2 MOVW ADB:COMADR1,#0080H ;Flash deletion command 3 MOVW ADB:COMADR1,#00AAH ;Flash deletion command 4 MOVW ADB:COMADR2,#0055H ;Flash deletion command 5 MOV @RW2+00,#0030H ;Issuance of the deletion command to the ;sector to be deleted 6 ELS ;Wait time check ;---------------------------------------------------------;Error when the time limit excess check flag is set and the ;toggle operation is ongoing ;---------------------------------------------------------MOVW A,@RW2+00 AND A,#20H ;DQ5 time limit check BZ NTOE ;Time limit over MOVW A,@RW2+00 ;Hi and low are alternately output for each MOVW A,@RW2+00 ;AL reading from DQ6 during AH writing. XORW A ;XOR of AH and AL (1 writing (writing ongoing) ;if the DQ6 value is different) AND A,#40H ;Is the DQ6 toggle bit Hi? BNZ ERROR ;If it is Hi, go to ERROR. ;---------------------------------------------------------;Deletion end check (FMCS-RDY) ;---------------------------------------------------------NTOE MOV A,FMCS ; AND A,#10H ;Extraction of the FMCS RDY bit (4 bits) BZ ELS ;Is sector deletion ended? MOV FMCS,#00H ;Release of the FLASH deletion mode RETP ;Return to the main program ;-----------------------------------------------------------------;Error ;-----------------------------------------------------------------ERROR MOV ADB:COMADR1,#0F0H ;Reset command (reading possible) MOV FMCS,#00H ;Release of the FLASH mode MOV PDR0,#0FFH ;Confirmation of the error handling RETP ;Return to the main program RAMPRG ENDS ;-----------------------------------------------------------------VECT CSEG ABS=0FFH ORG 0FFDCH DSL START DB 00H VECT ENDS ; END START 596 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS This chapter shows examples of serial programming connection using the AF220/AF210/AF120/AF110 flash microcontroller programmers by Yokogawa Digital Computer Corporation. 25.1 Basic Configuration of Serial Programming Connection for Flash Memory Products 25.2 Example of Serial Programming Connection (User Power Supply Used) 25.3 Example of Serial Programming Connection (Power Supplied from Programmer) 25.4 Example of Minimum Connection to Flash Microcontroller Programmer (User Power Supply Used) 25.5 Example of Minimum Connection to Flash Microcontroller Programmer (Power Supplied from Programmer) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 597 CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.1 Basic Configuration of Serial Programming Connection for Flash Memory Products 25.1 MB90860E Series Basic Configuration of Serial Programming Connection for Flash Memory Products The MB90F867E/ES supports serial on-board writing (Fujitsu standard) of the flash ROM. This section provides the related specifications. ■ Basic Configuration of Serial Programming Connection Fujitsu standard serial on-board writing uses the AF220/AF210/AF120/AF110 flash microcontroller programmers by Yokogawa Digital Computer Corporation. You can use either program running in the single-chip mode or program running in the internal ROM/external bus mode. Figure 25.1-1 shows the basic configuration for the serial programming connection. Figure 25.1-1 Basic Configuration of Serial Programming Connection Host interface cable RS232C General-purpose common cable (AZ210) AF220/AF210/ AF120/AF110 flash microcontroller programmer + memory card CLK synchronous serial MB90F867E/ES user system Stand-alone operation enabled Note: 598 For information on the functions of and operational procedures related to the flash microcontroller programmers (AF220/AF210/AF120/AF110), the general-purpose common cable (AZ210) for connection, and the connector, contact Yokogawa Digital Computer Corporation. FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.1 Basic Configuration of Serial Programming Connection for Flash Memory Products MB90860E Series Table 25.1-1 Pin Used for Fujitsu Standard Serial On-Board Programming Pin MD2, MD1, MD0 Function Additional information Mode pins Controls the programming mode from the flash microcontroller programmer. X0, X1 Oscillation pins In programming mode, the CPU internal operation clock signal is one multiple of the PLL clock signal frequency. Therefore, because the oscillation clock frequency becomes the internal operation clock signal, the oscillator used for serial reprogramming is 3 MHz to 16 MHz. P00, P01 Programming activation pins Input "L" level to P00 and "H" level to P01. RST Reset pin SIN0 Serial data input pin SOT0 Serial data output pin SCK0 Serial clock input pin C C pin This pin is used to stabilize the power supply. Connect to an external ceramic capacitor of approximately 0.1 μF. VCC Power voltage supply pin Programming voltage (5 V ±10%) VSS GND pin Common to GND of the flash microcontroller programmer. — Use UART0 as the CLK synchronous mode. If the P00, P01, SIN0, SOT0, and SCK0 pins are also used for the user system, the control circuit shown in Figure 25.1-2 is required. (The /TICS signal of the flash microcontroller programmer can be used to disconnect the user circuit during serial programming.) Figure 25.1-2 Control Circuit AF220/AF210/AF120/AF110 write control pin MB90F867E/ES write control pin AF220/AF210/AF120/AF110 /TICS pin User The following sections present examples these four types of serial programming connection. See each section as required. • Example of serial programming connection in internal vector mode (user power supply used) • Example of serial programming connection in internal vector mode (power supplied from programmer) • Example of minimum connection to flash microcontroller programmer (user power supply used) • Example of minimum connection to flash microcontroller programmer (power supplied from programmer) CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 599 CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.1 Basic Configuration of Serial Programming Connection for Flash Memory Products MB90860E Series Table 25.1-2 System Configuration of Flash Microcontroller Programmers (Manufactured by Yokogawa Digital Computer Corporation) Model Main unit Function AF220/AC4P Ethernet interface built-in model/100 V to 220 V power adapter AF210/AC4P Standard model/100 V to 220 V power adapter AF120/AC4P Single-key Ethernet interface built-in model/100 V to 220 V power adapter AF110/AC4P Single-key model/100 V to 220 V power adapter AZ221 RS232C cable for programmer PC/AT AZ210 Standard target probe (a) cable length: 1 m FF201 Fujitsu F2MC-16LX flash microcontroller control module AZ290 Remote controller /P2 2MB PC Card (optional) for flash memory sizes up to 128 KB /P4 4MB PC Card (optional) for flash memory sizes up to 512 KB Contact address: Yokogawa Digital Computer Co., Ltd. Tell: +81-042-333-6222 Note: Although the AF200 flash microcontroller programmer is no longer manufactured, the programmer still can be used in combination with the FF201 control module. Examples of serial programming connection can correspond to the connection example as shown in "■ Oscillating Clock Frequency and Serial Clock Input Frequency". ■ Oscillating Clock Frequency and Serial Clock Input Frequency The equation listed below can be used to calculate the serial clock frequencies that can be specified for the flash memory products: Serial clock frequency that can be specified = 0.125 × Example of oscillation clock frequency Set an appropriate serial clock input frequency in the flash microcontroller programmer according to the oscillating clock frequency in use. Table 25.1-3 Examples of Serial Clock Frequencies That Can be Specified Oscillating clock frequency Maximum Serial Clock Frequency That Can be Specified for Microcontrollers Maximum Serial Clock Frequency That Can be Specified for AF220/AF210/AF120/AF110 Maximum Serial Clock Frequency That Can be Used for AF200 4 MHz 500 kHz 500 kHz 500 kHz 8 MHz 1 MHz 850 kHz 500 kHz 16 MHz 2 MHz 1.25 MHz 500 kHz 600 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.2 Example of Serial Programming Connection (User Power Supply Used) MB90860E Series 25.2 Example of Serial Programming Connection (User Power Supply Used) Figure 25.2-1 shows an example of a serial programming connection when the supply voltage of the microcontroller is supplied from the user power supply. 1 and 0 are input to mode pins MD2 and MD0 from TAUX3 and TMODE of the AF220/AF210/AF120/AF110 programmer. Serial reprogramming mode: MD2, MD1, MD0=110B ■ Example of Serial Programming Connection (User Power Supply Used) Figure 25.2-1 Example of Serial Programming Connection in Single-Chip Mode (User Power Supply Used) AF220/AF210/AF120/AF110 Flash microcontroller programmer User system TAUX3 Connector DX10-28S DX20-28S MB90F867E/ES (19) MD2 MD1 (12) TMODE 4 MHz to 16 MHz TAUX (23) /TICS (10) MD0 X0 X1 P00 User /TRES (5) RST P01 User C TTXD TRXD TCK (13) (27) (6) TVcc (2) GND (7,8, 14,15, 21,22, 1,28) • 3, 4, 9, 11, 16, 17, 18, 20, 24, 25 and 26 pins are OPEN • DX10-28S: Write-angle type • DX20-28S: Straight type CM44-10144-4E SIN0 SOT0 SCK0 Vcc User power supply Vss 14 pin 1 pin 28 pin 15 pin DX10-28S DX20-28S Connector (manufactured by Hirose Electronics Ltd.) pin arrangement FUJITSU SEMICONDUCTOR LIMITED 601 CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.2 Example of Serial Programming Connection (User Power Supply Used) MB90860E Series • Even if the SIN0, SOT0, and SCK0 pins are used for the user system, the control circuit shown in the figure below is required in the same way that it is for P00. (The /TICS signal of the flash microcontroller programmer can be used to disconnect the user circuit during serial programming.) Figure 25.2-2 Control Circuit AF220/AF210/AF120/AF110 Write control pin MB90F867E/ES write control pin AF220/AF210/AF120/AF110 /TICS pin User • Connect AF220/AF210/AF120/AF110 while the user power is off. 602 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.3 Example of Serial Programming Connection (Power Supplied from Programmer) MB90860E Series 25.3 Example of Serial Programming Connection (Power Supplied from Programmer) Figure 25.3-1 shows an example of a serial programming connection when power is supplied from the programmer. 1 and 0 are input to mode pins MD2 and MD0 from TAUX3 and TMODE of the AF220/AF210/AF120/AF110 programmer. Serial reprogramming mode: MD2, MD1, MD0=110B ■ Example of Serial Programming Connection (Power Supplied from Programmer) Figure 25.3-1 Example of Serial Programming Connection in Single-Chip Mode (Power Supplied from Programmer) AF220/AF210/AF120/AF110 Flash microcontroller programmer TAUX3 User system Connector DX10-28S DX20-28S MB90F867E/ES (19) MD2 MD1 TMODE (12) 4 MHz to 16 MHz TAUX (23) /TICS (10) MD0 X0 X1 P00 User /TRES (5) RST User P01 C TTXD TRXD TCK TVcc Vcc TVPP1 (13) (27) (6) (2) (3) (16) GND (7,8, 14,15, 21,22, 1,28) • 4, 9, 11, 17, 18, 20, 24, 25 and 26 pins are OPEN • DX10-28S: Write-angle type • DX20-28S: Straight type SIN0 SOT0 SCK0 Vcc Vss 14 pin 1 pin 28 pin 15 pin DX10-28S DX20-28S Connector (manufactured by Hirose Electronics Ltd.) pin arrangement CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 603 CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.3 Example of Serial Programming Connection (Power Supplied from Programmer) • Even if the SIN0, SOT0, and SCK0 pins are used for the user system, the control circuit shown in the figure below is required in the same way that it is for P00. (The /TICS signal of the flash microcontroller programmer can be used to disconnect the user circuit during serial programming.) MB90860E Series Figure 25.3-2 Control Circuit AF220/AF210/AF120/AF110 Write control pin MB90F867E/ES Write control pin AF220/AF210/AF120/AF110 /TICS pin User • Connect AF220/AF210/AF120/AF110 while the user power is off. • When the programming power is supplied from AF220/AF210/AF120/AF110, be careful not to shortcircuit the user power supply. 604 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.4 Example of Minimum Connection to Flash Microcontroller Programmer (User Power Supply Used) MB90860E Series 25.4 Example of Minimum Connection to Flash Microcontroller Programmer (User Power Supply Used) Figure 25.4-1 shows an example of the minimum connection to the flash microcontroller programmer when the supply voltage of the microcontroller is supplied from the user power supply. Serial reprogramming mode: MD2, MD1, MD0=110B ■ Example of Minimum Connection to Flash Microcontroller Programmer (User Power Supply Used) For a flash memory write, the MD2, MD1, MD0 and P00 pins and flash microcontroller programmer need not be connected if the pins are set as shown in Figure 25.4-1. Figure 25.4-1 Example of Minimum Connection to Flash Microcontroller Programmer (User Power Supply Used) AF220/AF210/AF120/AF110 User system Flash microcontroller programmer MB90F867E/ES 1 for serial reprogramming MD2 1 for serial reprogramming MD1 MD0 0 for serial reprogramming 4 MHz to 16 MHz X0 X1 P00 0 for serial reprogramming User circuit P01 1 for serial reprogramming User circuit C Connector DX10-28S DX20-28S /TRES TTXD TRXD TCK TVcc GND (5) RST (13) SIN0 SOT0 SCK0 Vcc (27) (6) (2) (7,8, 14,15, 21,22, 1,28) User power supply • 3, 4, 9, 10, 11, 12, 16, 17, 18, 19, 20, 23, 24, 25 and 26 pins are OPEN • DX10-28S: Write-angle type • DX20-28S: Straight type Vss 14 pin 1 pin DX10-28S DX20-28S 28 pin 15 pin Connector (manufactured by Hirose Electronics Ltd.) pin arrangement CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 605 CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.4 Example of Minimum Connection to Flash Microcontroller Programmer (User Power Supply Used) • Even if the SIN0, SOT0, and SCK0 pins are used for the user system, the control circuit shown in the figure below is required. (The /TICS signal of the flash microcontroller programmer can be used to disconnect the user circuit during serial programming.) MB90860E Series Figure 25.4-2 Control Circuit AF220/AF210/AF120/AF110 Write control pin MB90F867E/ES write control pin AF220/AF210/AF120/AF110 /TICS pin User • Connect AF220/AF210/AF120/AF110 while the user power is off. 606 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.5 Example of Minimum Connection to Flash Microcontroller Programmer (Power Supplied from Programmer) MB90860E Series 25.5 Example of Minimum Connection to Flash Microcontroller Programmer (Power Supplied from Programmer) Figure 25.5-1 shows an example of the minimum connection to the flash microcontroller programmer when the power is supplied from the Programmer. Serial reprogramming mode: MD2, MD1, MD0=110B ■ Example of Minimum Connection to Flash Microcontroller Programmer (Power Supplied from Programmer) For a flash memory write, the MD2, MD1, MD0 and P00 pins and flash microcontroller programmer need not be connected if the pins are set as shown in Figure 25.5-1. Figure 25.5-1 Example of Minimum Connection to Flash Microcontroller Programmer (Power Supplied from Programmer) AF220/AF210/AF120/AF110 User system Flash microcontroller programmer MB90F867E/ES 1 for serial reprogramming MD2 1 for serial reprogramming MD1 MD0 0 for serial reprogramming 4 MHz to 16 MHz X0 X1 P00 0 for serial reprogramming User circuit P01 1 for serial reprogramming User circuit Connector DX10-28S DX20-28S /TRES TTXD TRXD TCK TVcc Vcc TVPP1 GND (5) (13) (27) (6) C RST SIN0 SOT0 SCK0 (2) (3) (16) Vcc (7,8, 14,15, 21,22, 1,28) Vss • 3, 4, 9, 1, 11, 12, 17, 18, 19, 20, 23, 24, 25 and 26 pins are OPEN • DX10-28S: Write-angle type • DX20-28S: Straight type 14 pin 1 pin DX10-28S DX20-28S 28 pin 15 pin Connector (manufactured by Hirose Electronics Ltd.) pin arrangement CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 607 CHAPTER 25 EXAMPLES OF SERIAL PROGRAMMING CONNECTION FOR FLASH MEMORY PRODUCTS 25.5 Example of Minimum Connection to Flash Microcontroller Programmer (Power Supplied from Programmer) • Even if the SIN0, SOT0, and SCK0 pins are used for the user system, the control circuit shown in the figure below is required. (The /TICS signal of the flash microcontroller programmer can be used to disconnect the user circuit during serial programming.) MB90860E Series Figure 25.5-2 Control Circuit AF220/AF210/AF120/AF110 Write control pin MB90F867E/ES write control pin AF220/AF210/AF120/AF110 /TICS pin User • Connect AF220/AF210/AF120/AF110 while the user power is off. • When the programming power is supplied from AF220/AF210/AF120/AF110, be careful not to shortcircuit the user power supply. 608 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 26 ROM SECURITY FUNCTION This chapter explains the ROM security function. 26.1 Overview of ROM Security Function CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 609 CHAPTER 26 ROM SECURITY FUNCTION 26.1 Overview of ROM Security Function 26.1 MB90860E Series Overview of ROM Security Function The ROM security function protects the content of ROM. ■ Overview of ROM Security Function The ROM security function is used to prevent the ROM data from being visible to third party by limiting the access to ROM. Please contact sales representatives about details of this function. 610 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 27 CLOCK MODULATOR This chapter explains the overview, operations, and register configuration of the clock modulator. 27.1 Overview of Clock Modulator 27.2 Clock Modulator Control Registers (CMCR) 27.3 Notes on Using Clock Modulator CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 611 CHAPTER 27 CLOCK MODULATOR 27.1 Overview of Clock Modulator 27.1 MB90860E Series Overview of Clock Modulator This section explains the overview of the clock modulator. ■ Overview of Clock Modulator The clock modulator is intended for the reduction of electromagnetic interference (EMI), by spreading the spectrum of the clock signal over a wide range of frequencies. This module uses triangular wave to modulate the phase the clock signal provided from the PLL circuit. 612 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E CHAPTER 27 CLOCK MODULATOR 27.2 Clock Modulator Control Registers (CMCR) MB90860E Series 27.2 Clock Modulator Control Registers (CMCR) The clock modulator control register (CMCR) enables/disables the phase modulation. ■ Clock Modulator Control Registers (CMCR) Figure 27.2-1 Configuration of Clock Modulator Control Registers (CMCR) 7 6 PMOD 5 4 Reserv- Reserv- Reserved bit ed bit ed bit 3 - R/W R/W R/W R/W - 2 1 0 Reserv- Reserv- Reserved bit ed bit ed bit R R/W R/W CMCR Initial value 0 0 0 1 X 0 0 0B Bits 0, 1, 2, 4, 5, 6 Reserved Bit bit 0,1 Always write 0. bit 2 The write is disabled. bit 4 Always write 1. bit 5,6 Always write 0. Bit 7 PMOD R/W R X - CM44-10144-4E : : : : Readable/writable Read-only Indetermination Undefined : Reset value Phase Modulation Enable Bit 0 Phase modulation disabled 1 Phase modulation enabled FUJITSU SEMICONDUCTOR LIMITED 613 CHAPTER 27 CLOCK MODULATOR 27.2 Clock Modulator Control Registers (CMCR) MB90860E Series ■ Functions of Clock Modulator Control Registers Table 27.2-1 Function of Bits of Clock Modulator Control Registers Bit name Function bit7 PMOD: Phase modulation enable "0": Phase modulation disabled (default). "1": Phase modulation enabled. MCU operates based on the modulated clock. • PMOD must be set to 1 to operate the modulator in the phase mode. • The PLL clock must be consistent before enabling the modulator (See "CHAPTER 6 CLOCK" for information on stable wait time). • The phase modulation mode can be used between 15MHz and 24MHz. • If the PLL output frequency is changed or PLL is turned off (e.g. power down mode), disable the clock modulator in advance → 4 cycle of NOP is required after PMOD=0. • When the phase modulation is enabled, the clock immediately switches to the modulated one. Glitch does not occur at that point. See notes on usage for information on the phase modulation activation sequence. • You can see operating status of the phase modulation from PMOD. If PMOD=1, the clock is modulated. • The pulse width of the modulated clock signal changes at ±0.8 ns. Example: F0 = 24 MHz, T0 = 41.7 ns TModMin = 41.7 ns - 0.8 ns = 40.9 ns --> FModMax = 1/40.9 ns = 24.45 MHz bit6, bit5 Reserved bit Always write "0" to this bit. bit4 Reserved bit Always write "1" to this bit. bit3 Unused bit bit2 Reserved bit This bit is read only. Writing this bit has no effect. The read value is always "0". bit1, bit0 Reserved bit Always write "0" to this bit. 614 — FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series 27.3 Notes on Using Clock Modulator CHAPTER 27 CLOCK MODULATOR 27.3 Notes on Using Clock Modulator This section explains the start/stop sequence. ■ Start/Stop Sequence of Phase Modulation Mode Start 1. Turn ON PLL 2. PLL consistent wait time (see explanation about the MCM flag in "CHAPTER 6 CLOCK"). 3. Enable the phase modulation mode (PMOD=1) The clock phase is immediately modulated. . . . Operating . . . Stop Note: CM44-10144-4E 4. Disable the phase modulation mode (PMOD=0) 5. NOP 4 cycle 6. Stop PLL, switch to the power down mode, etc... Do not enable the modulator before the PLL wait time has elapsed. Do not stop PLL when the modulation is in progress. FUJITSU SEMICONDUCTOR LIMITED 615 CHAPTER 27 CLOCK MODULATOR 27.3 Notes on Using Clock Modulator 616 FUJITSU SEMICONDUCTOR LIMITED MB90860E Series CM44-10144-4E APPENDIX The appendixes provide I/O maps, F2MC-16LX instructions, and other information. APPENDIX A I/O Maps APPENDIX B Memory Map APPENDIX C Instructions APPENDIX D Timing Diagrams in Flash Memory Mode APPENDIX E List of Interrupt Vectors CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 617 APPENDIX APPENDIX A I/O Maps MB90860E Series APPENDIX A I/O Maps The following table lists the addresses assigned to the registers in each resource of the MB90860E series. ■ I/O Maps (Address: 000000H to 0000FFH) Table A-1 I/O Maps (000000H to 0000FFH) (1 / 8) Address Abbreviation Register Access Resource Initial value 000000H Port 0 data register PDR0 R/W Port 0 XXXXXXXXB 000001H Port 1 data register PDR1 R/W Port 1 XXXXXXXXB 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 Port 5 data register PDR5 R/W Port 5 XXXXXXXXB 000006H Port 6 data register PDR6 R/W Port 6 XXXXXXXXB 000007H Port 7 data register PDR7 R/W Port 7 XXXXXXXXB 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 XXXXXXXXB 00000BH Analog input enable register 5 ADER5 R/W Port 5, A/D 1 1 1 1 1 1 1 1B 00000CH Analog input enable register 6 ADER6 R/W Port 6, A/D 1 1 1 1 1 1 1 1B 00000DH Analog input enable register 7 ADER7 R/W Port 7, A/D 1 1 1 1 1 1 1 1B 00000EH Input level select register 0 ILSR0 R/W Port 0 to 7 XXXXXXXXB 00000FH Input level select register 1 ILSR1 R/W Port 0 to 3, 8 to A XXXX0XXXB 000010H Port direction register (for port 0) DDR0 R/W Port 0 0 0 0 0 0 0 0 0B 000011H Port direction register (for port 1) DDR1 R/W Port 1 0 0 0 0 0 0 0 0B 000012H Port direction register (for port 2) DDR2 R/W Port 2 0 0 0 0 0 0 0 0B 000013H Port direction register (for port 3) DDR3 R/W Port 3 0 0 0 0 0 0 0 0B 000014H Port direction register (for port 4) DDR4 R/W Port 4 0 0 0 0 0 0 0 0B 618 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-1 I/O Maps (000000H to 0000FFH) (2 / 8) Address Abbreviation Register Access Resource Initial value 000015H Port direction register (for port 5) DDR5 R/W Port 5 0 0 0 0 0 0 0 0B 000016H Port direction register (for port 6) DDR6 R/W Port 6 0 0 0 0 0 0 0 0B 000017H Port direction register (for port 7) DDR7 R/W Port 7 0 0 0 0 0 0 0 0B 000018H Port direction register (for port 8) DDR8 R/W Port 8 0 0 0 0 0 0 0 0B 000019H Port direction register (for port 9) DDR9 R/W Port 9 0 0 0 0 0 0 0 0B 00001AH Port direction register (for port A) DDRA R/W Port A 0 0 0 0 0 1 0 0B 00001BH Reserved area 00001CH Pull-up control register (for port 0) PUCR0 R/W Port 0 0 0 0 0 0 0 0 0B 00001DH Pull-up control register (for port 1 PUCR1 R/W Port 1 0 0 0 0 0 0 0 0B 00001EH Pull-up control register (for port 2) PUCR2 R/W Port 2 0 0 0 0 0 0 0 0B 00001FH Pull-up control register (for port 3) PUCR3 R/W Port 3 0 0 0 0 0 0 0 0B 000020H Serial mode register 0 SMR0 W, R/W 0 0 0 0 0 0 0 0B 000021H Serial control register 0 SCR0 W, R/W 0 0 0 0 0 0 0 0B 000022H Reception/transmit data register 0 RDR0/ TDR0 R/W 0 0 0 0 0 0 0 0 B/ 1 1 1 1 1 1 1 1B 000023H Serial status register 0 SSR0 R, R/W 000024H Extended communication control register 0 ECCR0 R, W, R/W X 0 0 0 0 XXXB 000025H Extended status control register 0 ESCR0 R/W 0 0 0 0 0 X 0 0B 000026H Baud rate generator register 00 BGR00 R, R/W 0 0 0 0 0 0 0 0B 000027H Baud rate generator register 01 BGR01 R, R/W 0 0 0 0 0 0 0 0B 000028H Serial mode register 1 SMR1 W, R/W 0 0 0 0 0 0 0 0B 000029H Serial control register 1 SCR1 W, R/W 0 0 0 0 0 0 0 0B 00002AH Reception/transmit data register 1 RDR1/ TDR1 R/W 0 0 0 0 0 0 0 0 B/ 1 1 1 1 1 1 1 1B 00002BH Serial status register 1 SSR1 R, R/W 0 0 0 0 1 0 0 0B 00002CH Extended communication control register 1 ECCR1 R, W, R/W X 0 0 0 0 XXXB UART0 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED UART1 0 0 0 0 1 0 0 0B 619 APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-1 I/O Maps (000000H to 0000FFH) (3 / 8) Address Abbreviation Register Access Resource Initial value 00002DH Extended status control register 1 ESCR1 R/W 00002EH Baud rate generator register 10 BGR10 R, R/W 00002FH Baud rate generator register 11 BGR11 R, R/W 0 0 0 0 0 0 0 0B 000030H PPG0 operation mode control register PPGC0 W, R/W 0 X 0 0 0 XX1B 000031H PPG1 operation mode control register PPGC1 W, R/W 000032H PPG0/1 count clock select register PPG01 R/W 000033H PPG2 operation mode control register PPGC2 W, R/W 000035H PPG3 operation mode control register PPGC3 W, R/W 000036H PPG2/3 count clock select register PPG23 R/W 000037H 16-bit PPG 0/1 0 0 0 0 0 0 0 0B 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B 0 X 0 0 0 XX1B 16-bit PPG 2/3 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B Reserved area 000038H PPG4 operation mode control register PPGC4 W, R/W 000039H PPG5 operation mode control register PPGC5 W, R/W 00003AH PPG4/5 count clock select register PPG45 R/W 00003BH Address detection register 1 PACSR1 R/W 00003CH PPG6 operation mode control register PPGC6 W, R/W 00003DH PPG7 operation mode control register PPGC7 W, R/W 00003EH PPG6/7 count clock select register PPG67 R/W 00003FH 0 X 0 0 0 XX1B 16-bit PPG 4/5 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B Address match detection 1 0 0 0 0 0 0 0 0B 0 X 0 0 0 XX1B 16-bit PPG 6/7 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B Reserved area 000040H PPG8 operation mode control register PPGC8 W, R/W 000041H PPG9 operation mode control register PPGC9 W, R/W 000042H PPG8/9 count clock select register PPG89 R/W 000043H 0 X 0 0 0 XX1B 16-bit PPG 8/9 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B Reserved area 000044H PPGA operation mode control register PPGCA W, R/W 000045H PPGB operation mode control register PPGCB W, R/W 000046H PPGA/B count clock select register PPGAB R/W 620 UART1 Reserved area 000034H 000047H 0 0 0 0 0 X 0 0B 0 X 0 0 0 XX1B 16-bit PPGA/B 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B Reserved area FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-1 I/O Maps (000000H to 0000FFH) (4 / 8) Address Abbreviation Register Access 000048H PPGC operation mode control register PPGCC W, R/W 000049H PPGD operation mode control register PPGCD W, R/W 00004AH PPGC/D count clock select register PPGCD R/W 00004BH Resource Initial value 0 X 0 0 0 XX1B 16-bit PPGC/D 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B Reserved area 00004CH PPGE operation mode control register PPGCE W, R/W 00004DH PPGF operation mode control register PPGCF W, R/W 00004EH PPGE/F count clock select register PPGEF R/W 00004FH 0 X 0 0 0 XX1B 16-bit PPGE/F 0 X 0 0 0 0 0 1B 0 0 0 0 0 0 X 0B Reserved area 000050H Input capture control status 0/1 ICS01 R/W 000051H Input capture edge 0/1 ICE01 R/W, R 000052H Input capture control status 2/3 ICS23 R/W 000053H Input capture edge 2/3 ICE23 R 000054H Input capture control status 4/5 ICS45 R/W 000055H Input capture edge 4/5 ICE45 R 000056H Input capture control status 6/7 ICS67 R/W 000057H Input capture edge 6/7 ICE67 R/W, R 000058H Output compare control status 0 OCS0 R/W 000059H Output compare control status 1 OCS1 R/W 00005AH Output compare control status 2 OCS2 R/W 00005BH Output compare control status 3 OCS3 R/W 00005CH Output compare control status 4 OCS4 R/W 00005DH Output compare control status 5 OCS5 R/W 00005EH Output compare control status 6 OCS6 R/W 00005FH Output compare control status 7 OCS7 R/W 000060H Timer control status 0 TMCSR0 R/W 000061H Timer control status 0 TMCSR0 R/W 000062H Timer control status 1 TMCSR1 R/W 000063H Timer control status 1 TMCSR1 R/W CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED Input capture 0/1 Input capture 2/3 Input capture 4/5 Input capture 6/7 Output compare 0/1 Output compare 2/3 Output compare 4/5 Output compare 6/7 16-bit reload timer 0 16-bit reload timer 1 0 0 0 0 0 0 0 0B XXX0X0XXB 0 0 0 0 0 0 0 0B XXXXXXXXB 0 0 0 0 0 0 0 0B XXXXXXXXB 0 0 0 0 0 0 0 0B XXX 0 0 0XXB 0 0 0 0 XX 0 0B 0 XX 0 0 0 0 0B 0 0 0 0 XX 0 0B 0 XX 0 0 0 0 0B 0 0 0 0 XX 0 0B 0 XX 0 0 0 0 0B 0 0 0 0 XX 0 0B 0 XX 0 0 0 0 0B 0 0 0 0 0 0 0 0B XXXX 0 0 0 0B 0 0 0 0 0 0 0 0B XXXX 0 0 0 0B 621 APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-1 I/O Maps (000000H to 0000FFH) (5 / 8) Address Abbreviation Register Access Resource Initial value 000064H Timer control status 2 TMCSR2 R/W 000065H Timer control status 2 TMCSR2 R/W 000066H Timer control status 3 TMCSR3 R/W 000067H Timer control status 3 TMCSR3 R/W 000068H A/D control status 0 ADCS0 R/W 0 0 0 XXXX 0B 000069H A/D control status 1 ADCS1 R/W 0 0 0 0 0 0 0 XB 00006AH A/D data 0 ADCR0 R 16-bit reload timer 2 16-bit reload timer 3 0 0 0 0 0 0 0 0B XXXX 0 0 0 0B 0 0 0 0 0 0 0 0B XXXX 0 0 0 0B 0 0 0 0 0 0 0 0B A/D converter 00006BH A/D data 1 ADCR1 R XXXXXX 0 0B 00006CH ADC setting 0 ADSR0 R/W 0 0 0 0 0 0 0 0B 00006D ADC setting 1 ADSR1 R/W 0 0 0 0 0 0 0 0B 00006EH 00006FH Reserved area ROM mirror function select 000070H to 00009AH ROMM W ROM mirror XXXXXXX1B Reserved area 00009BH DMA descriptor channel specification register DCSR R/W 00009CH DMA status register L DSRL R/W 00009DH DMA status register H DSRH R/W 00009EH Address detection control register 0 PACSR0 R/W Address match detection 0 0 0 0 0 0 0 0 0B 00009FH Delayed interrupt issuance/cancel register DIRR R/W Delayed interrupt issuance module XXXXXXX0B 0000A0H Low-power consumption mode control register LPMCR W, R/W Low-power consumption control circuit 0 0 0 1 1 0 0 0B 0000A1H Clock select register CKSCR R, R/W Low-power consumption control circuit 1 1 1 1 1 1 0 0B DMA 0 0 0 0 0 0 0 0B 0000A2H, 0000A3H 0000A4H 622 0 0 0 0 0 0 0 0B DMA 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B Reserved area DMA stop status DSSR R/W FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-1 I/O Maps (000000H to 0000FFH) (6 / 8) Address Abbreviation Register Access Resource Initial value 0 0 1 1 XX 0 0B 0000A5H Automatic ready function select register ARSR W 0000A6H External address output control register HACR W 0000A7H Bus control signal select register ECSR W 0000A8H Watchdog timer control register WDTC R, W Watchdog timer XXXXX111B 0000A9H Time-base timer control register TBTC W, R/W Time-base timer 1 XX 0 0 1 0 0B 0000AAH Clock timer control register WTC R, R/W Clock timer 1 X 0 0 1 0 0 0B 0000ABH 0000ACH External memory access 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 XB Reserved area DMA enable register L DERL 0 0 0 0 0 0 0 0B R/W DMA 0000ADH DMA enable register H DERH R/W 0000AEH Flash control status register (only for flash device) FMCS R, R/W 0000AFH 0 0 0 0 0 0 0 0B Flash memory 0 0 0 X 0 0 0 0B Reserved area 0000B0H Interrupt control register 00 ICR00 W, R/W 0 0 0 0 0 1 1 1B 0000B1H Interrupt control register 01 ICR01 W, R/W 0 0 0 0 0 1 1 1B 0000B2H Interrupt control register 02 ICR02 W, R/W 0 0 0 0 0 1 1 1B 0000B3H Interrupt control register 03 ICR03 W, R/W 0 0 0 0 0 1 1 1B 0000B4H Interrupt control register 04 ICR04 W, R/W 0 0 0 0 0 1 1 1B 0000B5H Interrupt control register 05 ICR05 W, R/W 0 0 0 0 0 1 1 1B Interrupt control 0000B6H Interrupt control register 06 ICR06 W, R/W 0 0 0 0 0 1 1 1B 0000B7H Interrupt control register 07 ICR07 W, R/W 0 0 0 0 0 1 1 1B 0000B8H Interrupt control register 08 ICR08 W, R/W 0 0 0 0 0 1 1 1B 0000B9H Interrupt control register 09 ICR09 W, R/W 0 0 0 0 0 1 1 1B 0000BAH Interrupt control register 10 ICR10 W, R/W 0 0 0 0 0 1 1 1B 0000BBH Interrupt control register 11 ICR11 W, R/W 0 0 0 0 0 1 1 1B 0000BCH Interrupt control register 12 ICR12 W, R/W 0 0 0 0 0 1 1 1B 0000BDH Interrupt control register 13 ICR13 W, R/W 0 0 0 0 0 1 1 1B Interrupt control 0000BEH Interrupt control register 14 ICR14 W, R/W 0 0 0 0 0 1 1 1B 0000BFH Interrupt control register 15 ICR15 W, R/W 0 0 0 0 0 1 1 1B CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 623 APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-1 I/O Maps (000000H to 0000FFH) (7 / 8) Address Abbreviation Register Access 0000C0H D/A converter data 0 DAT0 R/W 0000C1H D/A converter data 1 DAT1 R/W Resource Initial value XXXXXXXXB XXXXXXXXB D/A converter 0000C2H D/A control 0 DACR0 R/W XXXXXXX0B 0000C3H D/A control 1 DACR1 R/W XXXXXXX0B 0000C4H, 0000C5H Reserved area 0000C6H External interrupt enable 0 ENIR0 R/W 0000C7H External interrupt cause 0 EIRR0 R/W 0000C8H Detection level setting 0 ELVR0 R/W 0000C9H Detection level setting 0 ELVR0 R/W 0 0 0 0 0 0 0 0B 0000CAH External interrupt enable 1 ENIR1 R/W 0 0 0 0 0 0 0 0B 0000CBH External interrupt cause 1 EIRR1 R/W XXXXXXXXB 0000CCH Detection level setting 1 ELVR1 R/W 0000CDH Detection level setting 1 ELVR1 R/W 0 0 0 0 0 0 0 0B 0000CEH External interrupt cause select EISSR R/W 0 0 0 0 0 0 0 0B 0000CFH PLL sub clock control register PSCCR W 0000D0H DMA buffer address pointer L BAPL R/W XXXXXXXXB 0000D1H DMA buffer address pointer M BAPM R/W XXXXXXXXB 0000D2H DMA buffer address pointer H BAPH R/W XXXXXXXXB 0000D3H DMA control DMACS R/W 0 0 0 0 0 0 0 0B External interrupt 0 External interrupt 1 PLL XXXXXXXXB 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B XXXX 0 0 0 0B XXXXXXXXB DMA 0000D4H I/O register address pointer L IOAL R/W XXXXXXXXB 0000D5H I/O register address pointer H IOAH R/W XXXXXXXXB 0000D6H Data counter L DCTL R/W XXXXXXXXB 0000D7H Data counter H DCTH R/W XXXXXXXXB 624 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-1 I/O Maps (000000H to 0000FFH) (8 / 8) Address Abbreviation Register Access Resource Initial value 0000D8H Serial mode register 2 SMR2 W, R/W 0 0 0 0 0 0 0 0B 0000D9H Serial control register 2 SCR2 W, R/W 0 0 0 0 0 0 0 0B 0000DAH Reception/transmit data register 2 RDR2/ TDR2 R/W 0 0 0 0 0 0 0 0 B/ 1 1 1 1 1 1 1 1B 0000DBH Serial status register 2 SSR2 R, R/W 0000DCH Extended communication control register 2 ECCR2 R, W, R/ W X 0 0 0 0 XXXB 0000DDH Extended status control register 2 ESCR2 R/W 0 0 0 0 0 X 0 0B 0000DEH Baud rate generator register 20 BGR20 R, R/W 0 0 0 0 0 0 0 0B 0000DFH Baud rate generator register 21 BGR21 R, R/W 0 0 0 0 0 0 0 0B 0000E0H to 0000FFH CM44-10144-4E UART2 0 0 0 0 1 0 0 0B External area FUJITSU SEMICONDUCTOR LIMITED 625 APPENDIX APPENDIX A I/O Maps MB90860E Series ■ I/O Maps (Address: 007900H to 007FFFH) Table A-2 I/O Maps (007900H to 007FFFH) (1 / 6) Address Register Abbreviation Access Resource Initial value XXXXXXXXB 007900H Reload register L0 PRLL0 R/W 007901H Reload register H0 PRLH0 R/W 007902H Reload register L1 PRLL1 R/W XXXXXXXXB 007903H Reload register H1 PRLH1 R/W XXXXXXXXB 007904H Reload register L2 PRLL2 R/W XXXXXXXXB 007905H Reload register H2 PRLH2 R/W 007906H Reload register L3 PRLL3 R/W XXXXXXXXB 007907H Reload register H3 PRLH3 R/W XXXXXXXXB 007908H Reload register L4 PRLL4 R/W XXXXXXXXB 007909H Reload register H4 PRLH4 R/W 00790AH Reload register L5 PRLL5 R/W XXXXXXXXB 00790BH Reload register H5 PRLH5 R/W XXXXXXXXB 00790CH Reload register L6 PRLL6 R/W XXXXXXXXB 00790DH Reload register H6 PRLH6 R/W 00790EH Reload register L7 PRLL7 R/W XXXXXXXXB 00790FH Reload register H7 PRLH7 R/W XXXXXXXXB 007910H Reload register L8 PRLL8 R/W XXXXXXXXB 007911H Reload register H8 PRLH8 R/W 007912H Reload register L9 PRLL9 R/W XXXXXXXXB 007913H Reload register H9 PRLH9 R/W XXXXXXXXB 007914H Reload register LA PRLLA R/W XXXXXXXXB 007915H Reload register HA PRLHA R/W 007916H Reload register LB PRLLB R/W XXXXXXXXB 007917H Reload register HB PRLHB R/W XXXXXXXXB 007918H Reload register LC PRLLC R/W XXXXXXXXB 007919H Reload register HC PRLHC R/W 00791AH Reload register LD PRLLD R/W XXXXXXXXB 00791BH Reload register HD PRLHD R/W XXXXXXXXB 626 16-bit PPG 0/1 16-bit PPG 2/3 16-bit PPG 4/5 16-bit PPG 6/7 16-bit PPG 8/9 16-bit PPG A/B 16-bit PPG C/D FUJITSU SEMICONDUCTOR LIMITED XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB CM44-10144-4E APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-2 I/O Maps (007900H to 007FFFH) (2 / 6) Address Register Abbreviation Access Resource Initial value 00791CH Reload register LE PRLLE R/W 00791DH Reload register HE PRLHE R/W 00791EH Reload register LF PRLLF R/W XXXXXXXXB 00791FH Reload register HF PRLHF R/W XXXXXXXXB 007920H Input capture 0 IPCP0 R XXXXXXXXB 007921H Input capture 0 IPCP0 R 007922H Input capture 1 IPCP1 R 007923H Input capture 1 IPCP1 R XXXXXXXXB 007924H Input capture 2 IPCP2 R XXXXXXXXB 007925H Input capture 2 IPCP2 R 007926H Input capture 3 IPCP3 R 007927H Input capture 3 IPCP3 R XXXXXXXXB 007928H Input capture 4 IPCP4 R XXXXXXXXB 007929H Input capture 4 IPCP4 R 00792AH Input capture 5 IPCP5 R 00792BH Input capture 5 IPCP5 R XXXXXXXXB 00792CH Input capture 6 IPCP6 R XXXXXXXXB 00792DH Input capture 6 IPCP6 R 00792EH Input capture 7 IPCP7 R 00792FH Input capture 7 IPCP7 R XXXXXXXXB 007930H Output compare 0 OCCP0 R/W XXXXXXXXB 007931H Output compare 0 OCCP0 R/W 007932H Output compare 1 OCCP1 R/W 007933H Output compare 1 OCCP1 R/W XXXXXXXXB 007934H Output compare 2 OCCP2 R/W XXXXXXXXB 007935H Output compare 2 OCCP2 R/W 007936H Output compare 3 OCCP3 R/W 007937H Output compare 3 OCCP3 R/W XXXXXXXXB 16-bit PPG E/F CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED Input capture 0/1 Input capture 2/3 Input capture 4/5 Input capture 6/7 Output compare 0/1 Output compare 2/3 XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB 627 APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-2 I/O Maps (007900H to 007FFFH) (3 / 6) Address Register Abbreviation Access Resource Initial value 007938H Output compare 4 OCCP4 R/W 007939H Output compare 4 OCCP4 R/W 00793AH Output compare 5 OCCP5 R/W 00793BH Output compare 5 OCCP5 R/W XXXXXXXXB 00793CH Output compare 6 OCCP6 R/W XXXXXXXXB 00793DH Output compare 6 OCCP6 R/W 00793EH Output compare 7 OCCP7 R/W 00793FH Output compare 7 OCCP7 R/W XXXXXXXXB 007940H Timer data 0 TCDT0 R/W 0 0 0 0 0 0 0 0B 007941H Timer data 0 TCDT0 R/W 007942H Timer control status 0 TCCSL0 R/W 007943H Timer control status 0 TCCSH0 R/W 0XXXXXXXB 007944H Timer data 1 TCDT1 R/W 0 0 0 0 0 0 0 0B 007945H Timer data 1 TCDT1 R/W 007946H Timer control status 1 TCCSL1 R/W 007947H Timer control status 1 TCCSH1 R/W TMR0/ TMRLR0 R/W Timer 0/Reload 0 007948H 007949H 00794AH Timer 1/Reload 1 00794BH 00794CH Timer 2/Reload 2 00794DH 00794EH 00794FH 628 Timer 3/Reload 3 TMR1/ TMRLR1 TMR2/ TMRLR2 TMR3/ TMRLR3 R/W R/W R/W R/W R/W R/W R/W FUJITSU SEMICONDUCTOR LIMITED XXXXXXXXB Output compare 4/5 Output compare 6/7 Free-run timer 0 Free-run timer 1 XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B 0 0 0 0 0 0 0 0B 0XXXXXXXB 16-bit reload timer 0 16-bit reload timer 1 16-bit reload timer 2 16-bit reload timer 3 XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB XXXXXXXXB CM44-10144-4E APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-2 I/O Maps (007900H to 007FFFH) (4 / 6) Address Abbreviation Register Access Resource Initial value 007950H Serial mode register 3 SMR3 W, R/W 0 0 0 0 0 0 0 0B 007951H Serial control register 3 SCR3 W, R/W 0 0 0 0 0 0 0 0B 007952H Reception/transmit data register 3 RDR3/ TDR3 R/W 0 0 0 0 0 0 0 0B / 1 1 1 1 1 1 1 1B 007953H Serial status register 3 SSR3 R, R/W 007954H Extended communication control register 3 ECCR3 R, W, R/W X 0 0 0 0 XXXB 007955H Extended status control register 3 ESCR3 R/W 0 0 0 0 0 X 0 0B 007956H Baud rate generator register 30 BGR30 R, R/W 0 0 0 0 0 0 0 0B 007957H Baud rate generator register 31 BGR31 R, R/W 0 0 0 0 0 0 0 0B 007958H Serial mode register 4 SMR4 W, R/W 0 0 0 0 0 0 0 0B 007959H Serial control register 4 SCR4 W, R/W 0 0 0 0 0 0 0 0B 00795AH Reception/transmit data register 4 RDR4/ TDR4 R/W 0 0 0 0 0 0 0 0B / 1 1 1 1 1 1 1 1B 00795BH Serial status register 4 SSR4 R, R/W 00795CH Extended communication control register 4 ECCR4 R, W, R/W X 0 0 0 0 XXXB 00795DH Extended status control register 4 ESCR4 R/W 0 0 0 0 0 X 0 0B 00795EH Baud rate generator register 40 BGR40 R, R/W 0 0 0 0 0 0 0 0B 00795FH Baud rate generator register 41 BGR41 R, R/W 0 0 0 0 0 0 0 0B 007960H to 00796BH 00796CH UART3 UART4 0 0 0 0 1 0 0 0B 0 0 0 0 1 0 0 0B Reserved area Clock output enable register 00796DH to 00796FH CM44-10144-4E CLKR R/W Clock monitor XXXX 0 0 0 0B Reserved area FUJITSU SEMICONDUCTOR LIMITED 629 APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-2 I/O Maps (007900H to 007FFFH) (5 / 6) Address Abbreviation Register Access Resource Initial value 007970H I2C bus status register 0 IBSR0 R 0 0 0 0 0 0 0 0B 007971H I2C bus control register 0 IBCR0 W, R/W 0 0 0 0 0 0 0 0B ITBAL0 R/W 0 0 0 0 0 0 0 0B ITBAH0 R/W 0 0 0 0 0 0 0 0B ITMKL0 R/W ITMKH0 R/W 0 0 1 1 1 1 1 1B 007972H 007973H 007974H 007975H I2C 10-bit slave address register 0 I2C 10-bit slave address mask register 0 I2C interface 0 1 1 1 1 1 1 1 1B 007976H I2C 7-bit slave address register 0 ISBA0 R/W 0 0 0 0 0 0 0 0B 007977H I2C 7-bit slave address mask register 0 ISMK0 R/W 0 1 1 1 1 1 1 1B 007978H I2C data register 0 IDAR0 R/W 0 0 0 0 0 0 0 0B 007979H, 00797AH 00797BH Reserved area I2C clock control register 0 00797CH to 00797FH ICCR0 R/W I2C interface 0 0 0 0 1 1 1 1 1B Reserved area 007980H I2C bus status register 1 IBSR1 R 0 0 0 0 0 0 0 0B 007981H I2C bus control register 1 IBCR1 W, R/W 0 0 0 0 0 0 0 0B ITBAL1 R/W 0 0 0 0 0 0 0 0B ITBAH1 R/W 0 0 0 0 0 0 0 0B ITMKL1 R/W ITMKH1 R/W 0 0 1 1 1 1 1 1B 007982H 007983H 007984H 007985H I2C 10-bit slave address register 1 2 I C 10-bit slave address mask register 1 I2C interface 1 1 1 1 1 1 1 1 1B 007986H I2C 7-bit slave address register 1 ISBA1 R/W 0 0 0 0 0 0 0 0B 007987H I2C 7-bit slave address mask register 1 ISMK1 R/W 0 1 1 1 1 1 1 1B 007988H I2C data register 1 IDAR1 R/W 0 0 0 0 0 0 0 0B 007989H, 00798AH 00798BH Reserved area I2C clock control register 1 00798CH to 0079C1H 0079C2H 630 ICCR1 R/W I2C interface 1 0 0 0 1 1 1 1 1B Clock modulator 0 0 0 1 X 0 0 0B Reserved area Clock module control register CMCR R, R/W FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX A I/O Maps MB90860E Series Table A-2 I/O Maps (007900H to 007FFFH) (6 / 6) Address Abbreviation Register 0079C3H to 0079DFH Access Resource Initial value Reserved area 0079E0H Detection address setting 0 PADR0 R/W XXXXXXXXB 0079E1H Detection address setting 0 PADR0 R/W XXXXXXXXB 0079E2H Detection address setting 0 PADR0 R/W XXXXXXXXB 0079E3H Detection address setting 1 PADR1 R/W XXXXXXXXB 0079E4H Detection address setting 1 PADR1 R/W 0079E5H Detection address setting 1 PADR1 R/W XXXXXXXXB 0079E6H Detection address setting 2 PADR2 R/W XXXXXXXXB 0079E7H Detection address setting 2 PADR2 R/W XXXXXXXXB 0079E8H Detection address setting 2 PADR2 R/W XXXXXXXXB 0079E9H to 0079EFH Address match detection 0 XXXXXXXXB Reserved area 0079F0H Detection address setting 3 PADR3 R/W XXXXXXXXB 0079F1H Detection address setting 3 PADR3 R/W XXXXXXXXB 0079F2H Detection address setting 3 PADR3 R/W XXXXXXXXB 0079F3H Detection address setting 4 PADR4 R/W XXXXXXXXB 0079F4H Detection address setting 4 PADR4 R/W 0079F5H Detection address setting 4 PADR4 R/W XXXXXXXXB 0079F6H Detection address setting 5 PADR5 R/W XXXXXXXXB 0079F7H Detection address setting 5 PADR5 R/W XXXXXXXXB 0079F8H Detection address setting 5 PADR5 R/W XXXXXXXXB 0079F9H to 007FFFH Note: CM44-10144-4E Address match detection 1 XXXXXXXXB Reserved area A write access to reserved area in I/O maps should not be performed. Unknown value is read from any reserved area. FUJITSU SEMICONDUCTOR LIMITED 631 APPENDIX APPENDIX A I/O Maps MB90860E Series ■ Explanation of Write and Read R/W : Both read and write enabled R : Only read enabled W : Only write enabled ■ Explanation of 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. 632 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX B Memory Map MB90860E Series APPENDIX B Memory Map Figure B-1 shows the memory map of the MB90860E series. ■ Memory Map As shown in Figure B-1, the upper part of the bank 00 is an image of the ROM data in the FF bank and enables the small model C compiler. Since the same is true on the lower 16-bit, the table in the ROM can be referenced without using the far specification in the pointer declaration. For example, when you try to access to 00C000H, you actually access to the value of FFC000H in the ROM. The ROM area in the bank FF can't display the entire image into the bank 00, exceeding 32 Kbytes. The image between FF8000H and FFFFFFH is visible in bank 00, whereas the image between FF0000H and FF7FFFH is only visible in bank FF. Figure B-1 Memory Map MB90867E/ES MB90F867E/ES MB90V340E-101/102 FFFFFFH FF0000H FEFFFFH ROM (FF bank) ROM (FE bank) FE0000H FDFFFFH FFFFFFH ROM (FF bank) FF0000H FEFFFFH ROM (FE bank) FE0000H ROM (FD bank) FD0000H FCFFFFH ROM (FC bank) FC0000H FBFFFFH FB0000H FAFFFFH FA0000H F9FFFFH F90000H F8FFFFH ROM (FB bank) ROM (FA bank) ROM (F9 bank) ROM (F8 bank) 00FFFFH F80000H 00FFFFH 008000H 007FFFH ROM (image of FF bank) 008000H 007FFFH ROM (image of FF bank) Peripheral 007900H Peripheral 007900H 0078FFH RAM 30 Kbytes 0018FFH RAM 6 Kbytes 000100H 000100H 0000EFH 000000H Peripheral 0000EFH 000000H Peripheral : Access not possible CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 633 APPENDIX APPENDIX C Instructions MB90860E Series APPENDIX C Instructions APPENDIX C describes the instructions used by the F2MC-16LX. C.1 Instruction Types C.2 Addressing C.3 Direct Addressing C.4 Indirect Addressing C.5 Execution Cycle Count C.6 Effective address field C.7 How to Read the Instruction List C.8 F2MC-16LX Instruction List C.9 Instruction Map Code: CM44-00202-4E 634 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E MB90860E Series C.1 Instruction Types APPENDIX APPENDIX C Instructions 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 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 635 APPENDIX APPENDIX C Instructions C.2 MB90860E Series 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: 636 • 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) FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series ■ Effective Address Field Table C.2-1 lists the address formats specified by the effective address field. Table C.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 CM44-10144-4E 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 FUJITSU SEMICONDUCTOR LIMITED 637 APPENDIX APPENDIX C Instructions C.3 MB90860E Series 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 C.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 C.3-1 lists the registers that can be specified. Figure C.3-2 shows an example of register direct addressing. Table C.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 stack flag (S) in the condition code register (CCR). For branch instructions, the program counter (PC) is not specified in an instruction operand but is specified implicitly. 638 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series Figure C.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 C.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 CM44-10144-4E 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 FUJITSU SEMICONDUCTOR LIMITED JMP 3B20H 639 APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.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 C.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 A 0716 2534 Memory space 0000C0H EE 0000C1H FF A 2534 FFEE Note : "I:" is Addressing Specifier that shows the I/O Direct Addressing. 640 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.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 Note : "S:" is Addressing Specifier that shows the Abbreviated Direct Addressing. ● 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 C.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 CM44-10144-4E A 2020 A AABB AABB 0123 DTB 5 5 Memory space 553B21H 01 553B20H 23 DTB 5 5 FUJITSU SEMICONDUCTOR LIMITED 641 APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.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 00 0000C1H Memory space After execution 0000C1H 01 Note : "I:" is Addressing Specifier that shows the I/O Direct Addressing. ● 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 C.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 01 556610H Note : "S:" is Addressing Specifier that shows the Abbreviated Direct Addressing. ● 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 C.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 642 DTB 5 5 552222H FUJITSU SEMICONDUCTOR LIMITED 01 CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.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 C.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 * : XX is replaced by the value of the program counter bank register (PCB). 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 C.3-2). CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 643 APPENDIX APPENDIX C Instructions C.4 MB90860E Series 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 C.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. 644 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series Figure C.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 C.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 78D31FH EE 78D320H FF A 2534 FFEE RW1 D 3 0 F CM44-10144-4E DTB 7 8 Memory space DTB 7 8 FUJITSU SEMICONDUCTOR LIMITED 645 APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.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 C.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 646 +4 C54556H 73 C54557H 9E C54558H 20 C54559H 00 MOVW A, @PC+20H C5455AH . . . +20H C5457AH EE C5457BH FF FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.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 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 647 APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.4-7 Example of Program Counter Relative Branch Addressing (rel) BRA 3C32H (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 3C32H ● Register list (rlst) Specify a register to be pushed onto or popped from a stack. Figure C.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. 648 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series Figure C.4-9 Example of Register List (rlst) 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 C.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 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 649 APPENDIX APPENDIX C Instructions MB90860E Series ● 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 C.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 C.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 650 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 FUJITSU SEMICONDUCTOR LIMITED JMP @@RW0 CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series ● Indirect specification branch addressing (@eam) The address of the branch destination is the word data at the address indicated by eam. Figure C.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 CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 651 APPENDIX APPENDIX C Instructions C.5 MB90860E Series 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. 652 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series ■ Calculating the Execution Cycle Count Table C.5-1 lists execution cycle counts and Table C.5-2 and Table C.5-3 summarize correction value data. Table C.5-1 Execution Cycle Counts in Each Addressing Mode (a) * Code Operand 00H | 07H Ri Rwi RLi 08H | 0BH 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 0CH | 0FH @RWj+ 4 2 10H | 17H @RWi+disp8 2 1 18H | 1BH @RWi+disp16 2 1 1CH 1DH 1EH 1FH @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 "C.8 F2MC-16LX Instruction List". CM44-10144-4E FUJITSU SEMICONDUCTOR LIMITED 653 APPENDIX APPENDIX C Instructions MB90860E Series Table C.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 "C.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 C.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. 654 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series C.6 Effective address field Table C.6-1 shows the effective address field. ■ Effective Address Field Table C.6-1 Effective Address Field (1/2) Code CM44-10144-4E Representation 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 00H R0 RW0 RL0 01H R1 RW1 (RL0) 02H R2 RW2 RL1 03H R3 RW3 (RL1) 04H R4 RW4 RL2 05H R5 RW5 (RL2) 06H R6 RW6 RL3 07H R7 RW7 (RL3) 08H @RW0 09H @RW1 0AH @RW2 0BH @RW3 0CH @RW0+ 0DH @RW1+ 0EH @RW2+ 0FH @RW3+ 10H @RW0+disp8 11H @RW1+disp8 12H @RW2+disp8 13H @RW3+disp8 14H @RW4+disp8 15H @RW5+disp8 16H @RW6+disp8 17H @RW7+disp8 18H @RW0+disp16 19H @RW1+disp16 1AH @RW2+disp16 1BH @RW3+disp16 1CH @RW0+RW7 Register indirect with index 0 1DH @RW1+RW7 Register indirect with index 0 1EH @PC+disp16 PC indirect with 16-bit displacement 2 FUJITSU SEMICONDUCTOR LIMITED 655 APPENDIX APPENDIX C Instructions MB90860E Series Table C.6-1 Effective Address Field (1/2) Code 1FH Representation addr16 Address format Direct address Byte count of extended address part * 2 *1: Each byte count of the extended address part applies to + in the # (byte count) column in "C.8 F2MC-16LX Instruction List". 656 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series C.7 How to Read the Instruction List Table C.7-1 describes the items used in "C.8 F2MC-16LX Instruction List", and Table C.7-2 describes the symbols used in the same list. ■ Description of Instruction Presentation Items and Symbols Table C.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 C.2-1 for the alphabetical letters in items. RG B Operation CM44-10144-4E Description 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. FUJITSU SEMICONDUCTOR LIMITED 657 APPENDIX APPENDIX C Instructions MB90860E Series Table C.7-1 Description of Items in the Instruction List (1/2) Item Description I 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. S T N Z V C 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 C.7-2 Explanation on Symbols in the Instruction List (1/2) Symbol A 658 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 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series Table C.7-2 Explanation on Symbols in the Instruction List (1/2) Symbol 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 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 CM44-10144-4E 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 00H to 07H) eam Effective addressing (code 08H to 1FH) rlst Register list FUJITSU SEMICONDUCTOR LIMITED 659 APPENDIX APPENDIX C Instructions C.8 MB90860E Series F2MC-16LX Instruction List Table C.8-1 to Table C.8-18 list the instructions used by the F2MC-16LX. ■ F2MC-16LX Instruction List Table C.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 1 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 C.5-1 and Table C.5-2 for information on (a) and (b) in the table. 660 FUJITSU SEMICONDUCTOR LIMITED CM44-10144-4E APPENDIX APPENDIX C Instructions MB90860E Series Table C.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 ea