-, . jo,;-: ~ . :. .' ;~': . ,-. " . HD6301 iHD6303 SERIES HANDBOOK • USER'S MANUALS: o HD6301 V1 IHD6303R t!) HD63701V (1) HD6301XO/HD6303X/HD63701XO @ HD6301 YO/HD6303Y IHD63701 YO III SOFTWARE APPLICATION NOTES til HARDWARE APPLICATION NOTES II C LANGUAGE PROGRAMMING TECHNIOUES III APPENDIX: o HD6301 V IHD6303R Q and A (£) HD6301XO/HD6303X OSCILLATOR CIRCUIT CD WIDE TEMPERATURE RANGE SPECIFICATIONS -40°C to +85°C (J VERSION) #U07 When using this document, keep the following in mind: 1. This document may, wholly or partially, be subject to change without notice. 2. All rights are reserved: No one is permitted to reproduce or duplicate, in any form, the whole or part of this document without Hitachi's permission. 3. Hitachi will not be held responsible for any damage to the user that may result from accidents or any other reasons during operation of the user's unit according to this document. 4. Circuitry and other examples described herein are meant merely to indi- cate the characteristics and performance of Hitachi's semiconductor prod- ucts. Hitachi assumes no responsibility for any intellectual property claims or other problems that may result from applications based on the examples described herein. 5. No license is granted by implication or otherwise under any patents or other rights of any third party or Hitachi, Ltd. 6. MEDICAL APPLICATIONS: Hitachi's products are not authorized for use in MEDICAL APPLICATIONS without the written consent of the appropriate officer of Hitachi's sales company. Such use includes, but is not limited to, use in life support systems. Buyers of Hitachi's products are requested to notify the relevant Hitachi sales offices when planning to use the products in MEDICAL APPLICATIONS. ii September 1989 ©Copyright 1989, Hitachi America, Ltd. Printed in U.S.A. INDEX Quick Reference Guide Addressing Modes, CPU Architecture, and Instruction Set HD6301 V1 /HD6303R User's Manual HD63701 V User's Manual HD6301X0!HD6303X1HD63701XO User's Manual I HD6301 YO/HD6303Y/HD63 701 YO User's Manual Software Application Notes Hardware Application Notes C Language Programming 1echniques APPENDIX: HD6301 V11HD6303R Q and A-HD6301XO/HD6303X Oscillation Circuit Wide 1emperature Range Specifications, -40°C to +85°C, (J Version) Hitachi Sales Offices Section 10, Page 1318 iii ~HITACHI iv TABLE OF CONTENTS Section 1 Quick Reference Guide Page QUICK REFERENCE GUiDE ......................................... . PACKAGE REFERENCE GUIDE ......... , . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Section 2 Addressing Modes, CPU Architecture, and Instruction Set Page 1. ASSEMBLY LANGUAGE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.1 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.2 CPU Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 1.3 Instruction Set Details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Section 3 HD6301V1/HD6303R User's Manual Page Notice on HD6301 V1 and HD6303R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 1. OVERViEW.................................................... 128 1.1 Features of HD6301V1 ... '............... ...................... 128 1.2 Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 1.3 Functional Pin Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 2. INTERNAL ARCHITECTURE AND OPERATIONS...................... 130 2.1 Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 2.2 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 2.3 Registers ..................................... '. . . . . . . . . . . . . . 140 2.4 1/0 Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 2.5 Programmable Timer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 2.6 Serial Communication Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 2.7 Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 2.8 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 2.9 Oscillator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 2.10 Strobe Signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 2.11 RAM Control Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 2.12 Low Power Consumption Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 2.13 TRAP Function ..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 ~HITACHI v 3. INSTRUCTIONS................................................ 168 3.1 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 168 3.2 Instruction Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 170 3.3 Instryction Execution Cycles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 175 3.4 System Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 4. PIN ARRANGEMENT AND PACKAGE INFORMATION. . . . . . . . . . . . . . . . . . 183 5. ELECTRICAL CHARACTERISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 186 6. APPLICATIONS................................................. 191 6.1 Use of External Expanded Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 6.2 Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 195 6.3 Address Trap, OP-Code Trap Application. . . . . . . . . . . . . . . . . . . . . . . . .. 198 6.4 Slow Memory Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 199 6.5 Interface to HN61256.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 200 6.6 Interface to the Realtime Clock (HD146818). . . . . . . . . . . . . . . . . . . . . . .. 205 6.7 Reference Data of Battery Service Life .............. . . . . . . . . . . . .. 208 7. PRECAUTIONS................................................. 209 7.1 Write-Only Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 209 7.2 Address Strobe (AS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 209 7.3 Mode o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 209 7.4 Trap Interrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 209 7.5 Power-on Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 211 7.6 Precaution to the Board Design of Oscillation Circuit . . . . . . . . . .. . . . .. 211 7.7 Application Note for High Speed System Design Using the HD6301V1 .. 212 APPENDIX I. EPROM on Package HD63P01 M1 218 II. Program Development Procedure and Support System ............. . 226 III. Q&A ..................................................... . 233 Section 4 HD63701 V User's Manual Page 1. OVERViEW ............................................... ;.... 251 1.1 Features of HD63701VO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 251 1.2 Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 251 1.3 Functional Pin Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 252 ~HITACHI vi 2. INTERNAL ARCHITECTURE ..................................... . 253 2.1 Mode Selection ............................................. . 253 2.2 Memory Map ............................................... . 258 2.3 CPU Registers .............................................. . ,263 2.4 Ports ......, ................................................ . 265 2.5 Timer ............................................. ; ....... . 269 2.6 Serial Communication Interface ................................ . 273 2.7 Interrupts .................................................. . 281 2.8 Reset ..................................................... . 283 2.9 Oscillator .................................................. . 285 2.10 Strobe Signals .............................................. . 286 2.11 RAM Control Register ........................................ . 287 2.12 Low Power Consumption Mode ................................. . 287 2.13 TRAP Function ............................................. . 292 3. .EPROM (PROM) PROGRAMMING AND TECHNICAL SPECIFICATIONS .. . 293 3.1 PROM Mode ............................................... . 293 3.2 ProgramminglVerification ..................................... . 294 3.3 Erasure ................................................... . 295 3.4 On-Chip PROM Characteristics and Application ................... . 296 3.5 Instruction Set Overview ....................... : .............. . 300 3.6 Addressing Modes ........................................... . 300 3.7 Instruction Set .............................................. . 302 3.8 Instruction Execution Cycles ................................... . 307 3.9 System Flowchart ........................................... . 313 3.10 Pin Arrangement and Package Information ....................... . 315 3.11 Electrical Characteristics ...................................... . 316 4. APPLiCATIONS ................................................ . 322 4.1 Use of External Expanded Mode ............................... . 322 4.2 Standby Mode .............................................. . 327 4.3 Address Trap, OP-Code Trap Application ......................... . 330 4.4 Slow Memory Interface ....................................... . 331 4.5 Interface to HN61256 ......................................... . 332 4.6 Interface to the Realtime Clock (HD146818) ....................... . 337 4.7 Reference Data of Battery Service Life .......................... . 340 5. PRECAUTIONS ................................................ . 341 5.1 Write Only Register .......................................... . 341 5.2 Address Strobe (AS) ......................................... . 341 5.3 Mode 0 .................................................... . 341 5.4 Trap Interrupt ............................................... . 341 ~HITACHI vii 5.5 Precaution to the Board Design of Oscillation Circuit . . . . . . . . . . . . . . . . 343 5.6 Application Note for High Speed System Design Using the HD63701VO. 343 5.7 Differences between HD6301V and HD63701V. . . . . . . . . . . . . . . . . . . .. 347 APPENDIX I. Support Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 353 II. Q &A...................................................... 355 Section 5 HD6301XO/HD6303X/HD63701XO User's Manual Page 1. OVERViEW.................................................... 375 1.1 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 375 1.2 Block Diagrams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 377 1.3 Pin Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 380 2. INTERNAL ARCHITECTURE AND OPERATION. . . . . . . . . . . . . . . . . . . . . .. 383 2.1 Operation Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 383 2.2 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 386 2.3 Function Pin Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 388 2.4 Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 393 2.5 RAM/Port 5 Control Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 397 3. CPU FUNCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 399 3.1 CPU Registers. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 399 3.2 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 400 3.3 Instruction Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 402 3.4 CPU Instruction Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408 3.5 Low Power Dissipation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 3.6 Trap Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 413 3.7 Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 414 3.8 Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 4. TIMER 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 418 4.1 Free-Running Counter (FRC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 419 4.2 Output Compare Registers (OCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 419 4.3 Input Compare Register (ICR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 4.4 Timer Control/Status Register 1 (TCSR1). . . . . . . . . . . . . . . . . . . . . . . . .. 420 4.5 Timer Control/Status Register 2 (TCSR2). . . . . . . . . . . . . . . . . . . . . . . . .. 421 4.6 Timer Status Flags .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 423 4.7 Precautions on Cleaning the OCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 423 ~HITACHI viii 5. TIMER 2 ...................................................... . 425 5.1 Timer 2 Upcounter (T2CNT) ................................... . 425 5.2 Timer Constant Register (TCONR) .............................. . 426 5.3 Timer Control/Status Register 3 (TCSR3) ......................... . 426 5.4 Timer Status Flags .......................................... . 428 6. SERIAL COMMUNICATIONS INTERFACE. .......................... . 429 6.1 Initialization ................................................ . 429 6.2 Asynchronous Mode ......................................... . 430 6.3 Clock Synchronous Mode ..................................... . 431 6.4 Transmit/Receive Control Status Register (TRCSR) ................. . 433 6.5 Transmit Rate/Mode Control Register (RMCR) ..................... . 434 6.6 SCI Receiving Margin ........................................ . 438 6.7 Timer, SCI Status Flags ....................................... . 438 6.8 Precaution for Clock-Synchronous Serial Communication Interface .... . 439 7. HD63701XO PROGRAMMABLE ROM (EPROM) ...................... . 441 7.1 Programming and Verification .................................. . 443 7.2 Erasing (Window Package) .................................... . 444 7.3 Characteristics and Applications ................................ . 444 8. APPLICATIONS ................................................ . 447 8.1 HD6301XO or HD63701XO in Expanded Mode ..................... . 447 8.2 HD6301XO or HD63701XO in Single-Chip Mode ................... . 448 8.3 Timer Applications ........................................... . 448 8.4 SCI Applications ............................................ . 452 8.5 Lowering Operating Current ................................... . 454 8.6 Memory Ready Application .................................... . 457 8.7 Halt Application ............................................. . 458 8.8 RD, WR Application .......................................... . 459 8.9 LCD-II Interface Application ................................... . 460 8.10 Oscillation Board Design ...................................... . 461 APPENDIX I. ELECTRICAL CHARACTERISTICS ........................ . 463 APPENDIX II. INSTRUCTION EXECUTION CYCLES ...................... . 485 APPENDIX III. QUESTIONS AND ANSWERS ........................... . 491 111.1 Parallel Ports ............................................... . 491 111.2 Serial Ports ................................................ . 492 111.3 Timer/Counter .............................................. . 495 ~HITACHI ix lilA Bus Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 111.5 Interrupt Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 500 111.6 Oscillation Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 III. 7 Reset.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 502 111.8 Low Power Dissipation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 505 111.9 Software......... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 111.10 Others..................................................... 508 APPENDIX IV. THE DIFFERENCES BETWEEN HD63701XO and HD6301XO . . . 509 APPENDIX V. PROGRAM DEVELOPMENT PROCEDURE AND SUPPORT SySTEM....... .................... ..... 510 Section 6 HD6301 YO/HD6303YIHD63701 YO User's Manual Page 1. OVERViEW.................................................... 519 1.1 Features ..... ;......... ..................................... 519 1.2 Block Diagrams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 520 104 Pin Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 523 2. INTERNAL ARCHITECTURE AND OPERATION. . . . . . . . . . . . . . . . . . . . . .. 526 2.1 Operation Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 526 2.2 Memory Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 527 2.3 Function Pin Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528 2.4 Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 531 2.5 RAM/Port 5 Control Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543 2.6 Port 6 Control/Status Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546 3. CPU FUNCTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 3.1 CPU Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 548 3.2 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 549 3.3 Instruction Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 304 CPU Instruction Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 557 3.5 Low Power Dissipation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 559 3.6 Trap Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 562 3.7 Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 563 3.8 Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 564 4. TIMER 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567 4.1 Free-Running Counter (FRG) . . . .. . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . 568 4.2 Output Compare Registers (OCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568 ~HITACHI x 4.3 Input Compare Register (ICR) .................................. . 569 4.4 . Timer Control/Status Register 1 (TCSR1) ......................... . 569 4.5 Timer Control/Status Register 2 (TCSR2) ....................... , .. 570 4.6 Timer Status Flags .......................................... . 572 4.7 Precautions on Cleaning the OCF .............................. . 572 5. TIMER 2 ...................................................... . 574 5.1 Timer 2 Upcounter (T2CNT) ................................... . 574 5.2 Timer Constant Register (TCONR) ............ '.................. . 575 5.3 Timer Control/Status Register 3 (TCSR3) ......................... . 575 5.4 Timer Status Flags .......................................... . 576 5.5 Precaution for Toggle Pulse Function of HD6301YO/HD6303Y/ HD63701YO Timer 2 ......................................... . 577 6. SERIAL COMMUNICATIONS INTERFACE. .......................... . 578 6.1 Initialization ................................................ . 578 6.2 Asynchronous Mode ......................................... . 579 6.3 Clock Synchronous Mode ..................................... . 580 6.4 Transmit/Receive Control Status Register (TRCSR) ................. . 582 6.5 Transmit Rate/Mode Control Register (RMCR) ..................... . 583 6.6 SCI Receiving Margin ........................................ . 586 6.7 SCI Status Flags ............................................ . 587 6.8 Precaution for Clock-Synchronous Serial Communication Interface .... . 588 7. HD63701Y0 Programming ROM (EPROM) ........................... . 589 7.1 Programming and Verification .................................. . 590 7.2 Erasing (Window Package) .................................... . 591 7.3 Characteristics and Applications ................................ . 591 8. APPLICATIONS ................................................ . 593 8.1 HD6301 YO in Expanded Mode ................................. . 593 8.2 HD6301 YO in Single-Chip Mode ................................ . 594 8.3 Timer Applications ........................................... . 594 8.4 SCI Applications ............................................ . 598 8.5 Lowering Operating Current ................................... . 600 8.6 Memory Ready Application .................................... . 603 8.7 Halt Application ............................................. . 604 8.8 RD, WR Application .......................................... . 605 8.9 LCD-II Interface Application ................................... . 605 8.10 Oscillation Circuit Board Design ................................ . 606 ~HITACHI xi APPENDIX I. ELECTRICAL CHARACTERISTICS ........................ , 608 APPENDIX II. INSTRUCTION EXECUTION CYCLES . . . . . . . . . . . . . . . . . . . . .. 630 APPENDIX III. QUESTIONS AND ANSWERS . . . . . . . . . . . . . . . . . . . . . . . . . . .. 636 111.1 parallel Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 636 111.2 Serial Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 639 111.3 Timer/Counter.......................................... . . . .. 644 111.4 Bus Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 647 111.5 Interrupt Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 650 111.6 Oscillation Circuit .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 653 111.7 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 653 111.8 Low Power Dissipation Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . ... 657 111.9 Software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 660 111.10 Others..................................................... 661 APPENDIX IV. THE DIFFERENCES BETWEEN HD63701YO and HD6301Y0 ... 663 APPENDIX V. PROGRAM DEVELOPMENT PROCEDURE AND SUPPORT SySTEM..................... ..................................... 664 V.1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 664 V.2 Single Chip Microcomputer ROM Ordering Procedure .... ; . . . . . . . . .. 666 Section 7 Software Application Notes Page 1. HOW TO USE APPLICATION NOTES ........ " . . . . . . . . . . . . . . . . . . . . .675 1.1 Formats ................................... ·.................. 675 1.1 .1 Specification Format (Format 1) ............ ; . . . . . . . . . .. . . .... . 677 1.1 .2 Description Format (Format 2) . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . .. 683 1.1.3 Flowchart Format (Format 3). . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. 686 1.1.4 Program Listing Format (Format 4). . . . . . . . . . . . . . . . . . . . . . . . . . .. . 688 1.2 How to Execute Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690 1.3 Symbols..................................................... 692 PROGRAM APPLICATION EXAMPLES Program Application Table. . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . 693 MOVING DATA 1. Filling Constant Values (Fill) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694 2, Moving Memory Blocks (Move) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698 ~HITACHI xii 3. Moving Strings (Moves) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 BRANCHING FROM TABLE 4. Branching From Table (CCASE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 HANDLING ASCII 5. Converting ASCII Lowercase Into Uppercase (TPR) ......... . . . . . . . . . .. 714 6. Converting ASCII Into 1-Byte Hexadecimal (Nibble). . . . . . . . . . . . . . . . . . . . . 719 7. Converting 8-Bit Binary Data Into ASCII (CO BYTE) . . . . . . . . . . . . . . .. . . . . . 724 BIT MANIPULATION 8. Counting Number of Logical "1" Bits In 8-Bit Data (HCNT). . . . . . . . . . . . . .. 729 9. Shifting 32-Bit Data (SHR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 COUNTER 10. 4-Digit BCD Counter (DECNT) ........ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738 COMPARISON 11. Comparing 32-Bit Binary Data (CMP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 743 ARITHMETIC OPERATION 12. Adding 32-Bit Binary Data (ADD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 749 13. Subtracting 32-Bit Binary Data (SUB). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 14. Multiplying 16-Bit Binary Data (MUL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 761 15. Dividing 16-Bit Binary Data (DIV). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 768 16. Adding 8-Digit BCD (ADDD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 774 17. Subtracting 8-Digit BCD (SUBD). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 18. 16-Bit Square Root (SQRT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 786 CONVERTING BCD INTO HEXADECIMALS 19. Converting 2-Byte Hexadecimals Into 5-Digit BCD (HEX) .............. . 791 20. Converting 5-Digit BCD Into 2-Byte Hexadecimals (BCD) .............. . 796 SORTING 21. Sorting (SORT) ................................................ . 803 Section 8 Hardware Application Notes Page APPLICATION NOTES GUIDE. ....................................... . 815 1. Symbols ...................................................... . 815 2. Application Example Configuration ................................. . 817 ~HITACHI xiii 3. 1st Section (Hardware) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 819 4. 2nd Section (Software). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 823 5. 3rd Section (Program Module) ..................................... 825 5.1 Specification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 826 5.2 Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 832 5.3 Flowchart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836 6. 4th Section (Subroutine) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 837 7. 5th Section (Program Listing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. .. 840 8. Program Module Execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 845 SYSTEM APPLICATION EXAMPLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 848 System Application Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 848 I/O PORT APPLICATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 849 1. HD61830 (LM200) Graphic Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 849 2. Darlington Transistor Drive (LED Dynamic Display) . . . . . . . . . . . . . . . . . . . .. 883 TIMER APPLICATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 896 3. Duty Control of Pulse Output and DA Conversion . . . . . . . . . . . . . . . . . . . . .. 896 4. Pulse Width Measurement .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 912 5. Input Pulse Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 922 6. 8 x 4 Key Matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 932 INTERRUPT APPLICATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 947 7. A/D Converter (HA 16613A) Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 947 PARALLEL HANDSHAKE APPLICATIONS ... , . . . . . . . . . . . . . . . . . . . . . . . . . .. 956 8. Standard Keyboard Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 956 9. Centronics Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 970 SCI APPLICATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 982 10. Data Transfer With Asynchronous SCI . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 982 11. Liquid Crystal Drived (HD61100A) Control. . . . . . . . . . . . . . . . .. . . . . . . . . .. 998 EXTERNAL EXPANSION APPLICATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1010 12; External Expansion ............................................. 1010 13. Slow Device Interface ........................................... 1043 LOW POWER DISSIPATION/FAIL-SAFE APPLICATIONS ................... 1057 14. Low Power Dissipation Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1057 15. HA1835P Control and Error Detection. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1074 ~HITACHI xiv Section 9 C Language Programming Techniques Page 1. HOW TO USE APPLICATION NOTES .............................. . 1105 1.1 Hardware Section ............................................. . 1107 1.1.1 Function ................................................... . 1107 1.1.2 Microcontroller Applications ................................... . 1107 1.1.3 Circuit Diagram ............................................. . 1108 1.1.4 Memory Map ............................................... . 1109 1.1.5 Pin Functions ............................................... . 1110 1.1.6 Hardware Operation ......................................... . 1111 1.2 Software Section .............................................. . 1112 1.2.1 Program Module Configuration ................................. . 1112 1.2.2 Program Module Functions .................................... . 1113 1.2.3 Program Module Sample Application (Main Program) ............... . 1114 1.3 Program Module Section ........................................ . 1116 1 .3.1 Page Heading .............................................. . 1117 1 .3.2 Function ................................................... . 1117 1.3.3 Arguments ................................................. . 1117 1.3.4 Libraries Required for Program Execution ........................ . 1118 1 .3.5 Specifications .............................................. . 1119 1 .3.6 Description .................................................. . 1120 1.3.7 PAD ...................................................... . 1123 1.4 Subroutine Section ............................................ . 1124 1.4.1 Page Heading .............................................. . 1125 1.4.2 Function ................................................... . 1125 1.4.3 Basic Operation ............................................. . 1125 1.4.4 Program Modules That Use This Function ........................ . 1126 1.4.5 PAD ...................................................... . 1126 1.5 Program Listing Section ........................................ . 1127 1.5.1 Page Heading .............................................. . 1127 1.5.2 Function ................................................... . 1128 1.5.3 Output Object Listing of C Compliler ............................ . 1131 1.5.4 Linkage Listing .............................................. . 1132 1.6 Program Module Use ........................................... . 1135 ~HITACHI xv 1.7 Pad Symbols Description .......................................•. 1137 1.8 Symbols...................................................... 1138 2. DARLINGTON TRANSISTOR DRIVE (LED DYNAMIC DISPLAY) . . . . . . . . .. 1139 2.1 Hardware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1139 2.1.1 Function ....................·................................ 1139 2.1.2 Microcontroller Applications ... '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1139 2.1.3 Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . .. 1139 2.1.4 PinFunctions ................................................ 1140 2.1.5 Hardware Operation .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1141 2.2 Software Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. 1142 2.2.1 Program Module Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1142 2.2.2 Program Module Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1142 2.2.3 Program Module Sample Application (Main Program). . . . . . . . . . . . . . .. 1143 2.3 Program Module Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1144 2.4 Program Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1152 2.4.1 Main Program Listing ............................. o• • • 0 •••••••1152 , , 2.4.2 C Source Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. 1153 2.4.3 Output Object Listing of C Complier. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1154 2.4.4 Linkage Listing .............................................. , 1157 3. 8x4 KEY MATRiX ............................................... 1159 3.1 Hardware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1159 , I 3.1.1 Function ........................................ J • • • • • • • • • •• 1159 3.1.2 Microcontroller Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1159 3.1.3 Circuit Diagram .................................. : . . . . . . . . . .. 1160 3.1.4 Pin Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1161 3.1.5 Hardware Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1161 3.2 Software Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1162 3.2.1' Program Module Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1162 3.2.2 Program Module Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1162 3.2.3 Program Module Sample Application (Main Program). . . . . . . . . . . . . . .. 1163 3.3 Program Module Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1165 3.4 Program Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1177 3.4.1 Main Program Listing ........ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1177 ~HITACHI xvi 3.4.1 Main Program Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1177 3.4.2 C Source Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1178 3.4.3 Output Object Listing of C Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1180 3.4.4 Linkage Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1185 4. - EXTERNAL EXPANSION ......................................... 1187 4.1 Hardware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1187 4.1.1 Function.................................................... 1187 4.1.2 Microcontroller Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1187 4.1.3 Circuit Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1187 4.1.4 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1188 4.1.5 Hardware Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1189 4.2 Software Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1190 4.2.1 Program Module Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1190 4.2.2 Program Module Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1190 4.2.3 Program Module Sample Application (Main Program). . . . . . . . . . . . . . .. 1192 4.3 Program Module Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1194 4.4 Program Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1220 4.4.1 Main Program Listing ... . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1220 4.4.2 C Source Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1222 4.4.3 Output Object Listing of C Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1226 4.4.4 Linkage Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1232 APPENDIXA. C Program and Assembly Program Comparison .......................... 1235 Section 10-Appendix HD6301V1/HD6303R Q & A-HD6301XO/HD6303X Oscillation Circuit Wide Temperature Range Specifications, -40°C to + 85°C, (J Version) Page 1. HD6301V1/HD6303R Q & A ...................................... . 1239 (a) Parallel Port (1) Process to Use a Port as an Output ............................. . 1241 (b~ Serial Port (1) Relation between Writing into the FRC and SCI Operation ........... . 1242 (2) Writing into the FRC during Serial Receive/Transmit ................ . 1243 (3) RDRF State When SCI Receiving ............................... . 1244 (4) Serial I/O Operation .......................................... . 1245 (5) Serial I/O Register Read ...................................... . 1246 (6) Detection of the HD6301 V1 Serial Start Bit ....................... . 1247 ~HITACHI xvii (c) Timer/Counter (1) Free Running Counter Read. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1249 (2) Preset Method of the Free Running Counter. . . . . . . . . . . . . . . . . . . . . .. 1250 (d) BUS Interface (1) Output of Address Strobe (AS) in the Multiplexed Mode. . . . . . . . . . . . .. 1252 (e) Interrupt (1) IRQ1 Acceptance ............................................. 1253 (2) Timer Interrupt and External Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1254 (3) IRQ1 Interrupt and Other Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1255 (4) CLilnstruction and Interrupt Operation. . . . . . . . . . . . . . . . . . . . . . . . . .. 1257 (f) Oscillator (1) Relation between the External Clock (EXTAL Clock) and Enable Clock (E Clock) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1258 (g) Reset (1) Constants of the Reset Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1259 (2) Schmitt Trigger Circuit of RES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1260 (3) I/O Port State on Resetting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1261 (4) SCI (Pin 39) State on Resetting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1262 (5) Port Output after Resetti ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1263 (h) Low Power Consumption (1) Schmitt Trigger Circuit of STBY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1264 (2) I/O Port State During Standby. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1265 (3) Return from Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1266 (4) Going into the Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1267 (5) Timing for the Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1268 (i) EPROM-on-Package (1) Usage of EPROM Socket Pins for the HD63P01 M (No.1). . . . . . . . . . . .. 1269 (2) Usage of EPROM Socket Pins for the HD63P01 M (No.2). . . . . . . . . . . .. 1270 (3) Usage of EPROM Socket Pins for the HD63P01 M (No.3). . . . . . . . . . . .. 1271 0) Software (1) Usage of Bit Manipulation Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . .. 1272 (2) Usage of Bit Manipulation Instructions to the Port. . . . . . . . . . . . . . . . . .. 1274 (k) Others (1) RAM Access Disable during Program Execution. . . . . . . . . . . . . . . . . . .. 1275 2. HD6301XO/HD6303X OSCILLATOR CIRCUIT .......................... 1276 3. Wide Temperature Range Specifications -40°C to + 85°C (J Version) ....... 1283 HD6301V1, HD63A01V1, HD63B01V1 .................................... 1284 HD6301XO, HD63A01XO, HD63B01XO .................................... 1289 HD6301YO, HD63A01YO, HD63B01YO, HD63C01YO ........................ 1294 HD6303R, HD63A03R, HD63B03R ...................................... 1300 HD6303X, HD63A03X, HD63B03X ...................................... 1305 HD6303Y, HD63A03Y, HD63B03Y, HD63C03Y ............................. 1310 [ HITACHI SALES OFFICES PAGE 1318 ~HITACHI xviii HD6301/HD6303 SERIES HANDBOOK Section One • Ouick -- Reference Guide and • Package Reference Guide· ~HITACHI QUICK REFERENCE G U I D E - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8-BIT SINGLE-CHIP MICROCOMPUTER • CMOS a-BIT SINGLE-CHIP MICROCOMPUTER HD6301 SERIES HD6301Vl HD6301XO Type No. HD63A01Vl HD63A01XO HD63B01Vl HD63B01XO 1.0 (HD6301Vl) 1.0 (HD6301XO) Bus Timing (MHz) 1.5 (HD63A01Vl) 1.5 (HD63A01XO) 2.0 (HD63B01V1) 2.0 (HD63B01XO) LSI Characteristics Supply Voltage (V) 5.0 5.0 Operating Temperature (C) 0- +70. 3 .*. 0- +70. 3 --- Package t DP-40. FP-54. CG-40. CP-44. CP-52 DP-64S. FP-80. CP·68 ROM (k byte) 4 4 Memoty RAM (byte) 128 192 I/O Port 29 24 I/O Port Input Port 29 - 53 8 Output Port - 21 External 2 3 Soft 2 2 Interrupt Timer 3 4 Functions Serial 1 1 16-bit xl 16-bit xl ( Free running counter X l ) ( Free running counter Xl) Output compare register x 1 Output compare register x2 Timer Input capture register xl Input capture register xl 8-bit xl (8-bit up counter XI) Time constant register x 1 SCI Asynchronous Asynchronous/Synchronous External Memory Expansion 65k bytes 65k bytes o Error detection oError detection Other Features oLow power dissipation oLow power dissipation modes (sleep and standby) modes (sleep and standby) oSlow memory interface oHalt HD63701VOC HD63701XOC EPROM on Chip Type HD637A01VOC HD637A01 XOC HD637B01VOC HD637BOl XOC EPROM on the Package Type HD63P01Ml -- .1 Preliminarv .2 Under development .3 Wide temperature range (-40 - +85°C) version is available . • 4 Wide temperature range (-40 - +12So C) version is available. tOP; Plastic DIP, FP; Plastic Flat Package. CG; Glass-sealed Ceramic leadless Chip Carrier. CP; Plastic leaded Chip Carrier (J-bend leads) ~HITACHI 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Q U I C K REFERENCE GUIDE HD6301YO HD6303R HD6303X HD6303Y HD63A01Y0 HD63A03R HD63A03X HD63A03Y HD63B01YO HD63B03Y HD63C01YO HD63B03R HD63B03X HD63C03Y 1.0 IfD6301YO) 1.0 (HD6303R) 1.0 (HD6303X) 1.0 rD6303Y~ 19i ~g~~~g, ~g) 1.5 HD63AOI YO) 1.5 (HD63A03R) 1.5 (HD63A03X) 1.5 H D63A03 ) 2.0 HD63B03Yj 2.0 (HD63B03R) 2.0 (HD63B03X) 3.0 HD63C03Y 5.0 5.0 5.0 5.0 0- +70" 0-- +70·),· .. 0-+70" 0- +70" DP-64S. FP-64. FP-64A. CP-68 Dp·40. Fp·54. CG·40. CP·52 DP·64S. FP·80. CP·68 DP-64S. Fp·64. FP-64A. CP-68 16 - - - 256 12B 192 256 48 13 16 -24. _ - - 53 - 13 - 24 a 24 - 5 - - - 3 2 3 3 2 2 2 2 4 3 4 4 1 1 1 1 16·bit xl 16·bit x 1 16·bit x 1 16·bit x 1 (Free running counter xl ) (Free running counter x 1 ) (Free running counter x 1 ) (Free running counter x 1 ) Output compare register x 2 Output compare register x 1 Output compare register x 2 Output compare register x 2 Input capture register x 1 Input capture register x 1 Input capture register x I Input capture register x 1 a·bit x I a·bit xl 8·bit x 1 (8-bit up counter x 1 ) ( 8·bit up 'counter x 1 ) (B.bit up counter x 1 ) Time constant register x 1 Time constant register x 1 Time constant register x 1 Asynchronous/Synchronous Asynchronous Asynchronous/Synchronous Asynchronous/Synchronous 65k bytes 65k bytes 65k bytes 65k bytes - Error detection - Error detection -Error detection oError detection - Low power dissipation -Low power dissipation oLow power dissipation oLow power dissipation modes (sleep and standby) modes (sleep and standby) modes (sleep and standby) modes (sleep and standby) oSlow memory interface .Slow memory interface .Slow memory interface oHalt -Halt oHalt HD6370lYOC HD637A01YOC HD637B01YOC - - - - - - - ~HITACHI 3 PACKAGE REFERENCE GUIDE Hitachi microcomputer devices include various types of multi-function types, applicable to each kind of mounting package which meet a lot of requirements such as ever smaller, method. Also, plastic and ceramic materials are offered ac- thinner and more versatile electric appliances. When selecting a cording to use. package suitable for the customers' use, please refer 10 the Fig. I shows the package classification according to the following for Hitachi microcompu ter packages. mounting types on the Printed Circuit Board (PCB) and the materials. 1. Package Classification There are pin insertion types, surface mounting types and Standard Outtine. Plastic DIP Pin Insertion Type Ceramic DIP Shrink Outline Shrink Typel Plastic DIP Shrink Type 'Ceramic DIP Package Classification Flat Package SOP IPlastic) FPP (Plastic) Surface Mounting Type Ch ip Carrier PLCC (Plastic) LCC EPROM on the Package IGlass Sealed Ceramic) Multi-function Type Type DIP; DUAL IN LINE PACKAGE S·DIP;SHRINK DUAL IN LINE PACKAGE PGA: PIN GRID ARRAY FLAT-DIP; FLAT DUAL IN LINE PACKAGE FLAT·QUIP; FLAT QUAD IN LINE PACKAGE CC: CHIP CARRIER SOP;SMALL OUTLINE PACKAGE FPP; FLAT PLASTIC PACKAGE PLCC; PLASTIC LEADED CHIP CARRIER LCC ; LEADLESS CHIP CARRIER Fig. 1 Package Classification according to the Mounting Type on the Printed Circuit Board and the Materials. ~HITACHI 4 PLASTIC DIP Unit: mm(inch) Scale: 1/1 • Dp·40 52812079) 54.0mlx.(2.126ma...) 21 '0 ; -$- ~ 20 10.047) 15.24 .. ~-I ~! 10.600) 2.54:0.25 0.4810.1 .~~ <0.100:0.010) (0.019:0.004) :; gO ... IS· N~ CERAMIC DIP Unit: mmlf,ch) Scale: 1/1 • DC·40 .. r--·----1~~9~:1--------i o Unit: mm(inch) SHRINK TYPE PLASTIC Scale: 1/1 • DP·64S .. 576(2'268) SB.6ma •.(Z.301mad " o ~HITACHI 5 I CERAMIC SHRINK TYPE I Unit: mm(inch) Scale: 1/1 '\ • DC-64S t:~:::IQI:::::::1~ . I II 0.9(0.035) -= .. E .. ~~~HFI -I~5'1.11 (o.DlO:tIll) ~HITACHI 6 FLAT PACKAGE • FP-54 2.9max. Unit: mm(inch) Scale: 3/2 I (O.114max.) JL O.IS±O.OS (0006 ±0.0021 • FP-64 Z.9max. (Q.lljmu.) -k, O,\!IotO,O!lZ) lO.OOo"O.OO ..AiUUUI)lilUU)l)lIIIIliIlii)l)liLi~ ~'Q.OIZ.). D"-I5" 1.11: 0.')(0. • FP-64A 17 ao 3(0 677±0 012) 8 14.0(0.SSI) 3 .= I =:... I 2.90(0.1I4)max . -;;; C! 49 3 .. 0.1 (0.004) (STANO OFF) ~ -Ii - == . .~~ Ci'<=: ~ ~ -Ii - ~ 64 I II 1+IO.IS(o.oo~f@1 O.IS±O.OS o 3S+0.0S I 0.014 ± 0.002 (0.006±o.o02) r.=r.;c-;-::;=-== (0.03!) ~HITACHI 7 • FP-80 4£~(OOI~;~i~miW!iiB OIS:l:O.OS I!!.:.! _L (0.006:1:0.ooZ) .J ~ ~UUUllUUUUUDUUUUUjlJmUU~ 0·- lS- 1.7 :1:0.3(0.067:1:0.01 Z) 172:1:03(0677:1:0012) • FP-80A 14.0(0.551) I 2.90(0.114)max 60 41 0.1 (0.004) 4 (STANO OFF) U BO o 3P+!I.lIS II .012±0.002) ,+, 0.13(0.OOS~20 I 0.15:1:0.05 (0.006:1:0.002) =-0;;-; ~~ ~0"-5" O.B 0.100.004) (0.031) ~HITACHI 8 • FP·80B 2,9max. (O,114ma".) ~UUUOUUUUUUU~.l- ~ ,2:l:.0.• L (O.o;'1:l:.0.00S)01 0.1510.00611 O·-IO·t Unit: mm(inch) PLASTIC LEADED CHIP CARRIER Scale: 3/2 • CP·44 § 1 n.S3±O 12(0 6!O±O OOS) 1'44 .. ... ci 0 " ~ l< d ... ~Il ,. ~ /I " ::I~ ... I'! :~ 16.51(0.&53) !... ~ ~ci ... ~ 15.SO±O.5O(O.6ID±O.020) ZOO7:t:O 12 (O.190.tO.OO5) • CP·52 I 1 ". " 0 ~ zo ~ J3 " 19.12 (0.753) ::I! ~;:I Innni ... ~....,. 'TTl.2lo:omr 11.~±O.5 (O.7IDiD.ozal ~HITACHI 9 J ~0 ~ q '" 5P44 .u 27 43 o 0.10(0.004) ( SEATING PLANE) (0.910±0.020) ~HITACHI 10 LEADLESS CHIP CARRIER • CG·40 Unit: mm(inch) Scale: 3/2 I a.75m••• (a.030m •••) 110 gonno non n=#Ff=Tl ~ ..ui18~~ 1 6 15 ...; ~ N ~ 16 ~HITACHI 11 • HITACHI 12 HD63011HD6303 SERIES HANDBOOK I Section Two Addressing Modes, CPU Architecture, and Instruction Set ~HITACHI 13 ~HITACHI 14 Section 2 Addressing Modes, CPU Architecture, and Instruction Set Table of Contents Page 1. ASSEMBLY LANGUAGE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 1.2 1.3 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CPU Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Instruction Set Details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 17 26 28 I ~HITACHI 15 ~HITACtil 16 ADDRESSING MODES, CPU ARCHITECTURE, AND INSTRUCTION SET 1. ASSEMBLY LANGUAGE 1.1 Addressing Modes The assembler determines the addressing mode by referencing the operator and operand fields. There are seven different addressing modes available. (1) Accumulator addressing (2) Implied addressing (3) Immediate addressing (4) Direct addressing (5) Extended addressing (6) Indexed addressing (7) Relative addressing ~HITACHI 17 Before going into details about individual addressing modes, we explain the dual operand mode in which an instruction has two operands. For eight instructions AIM, OIM, ElM, TIM, BCLR, BSET, BTGL and BTST, the operand .field requires two operands (the first and second operands). The first operand includes the immediate data (constant) for AIM, OIM and TIM; and the bit number for bit operation for BCLR, BSET, BTGL and BTST. The second operand specifies a memory address in either indexed or direct addressing mode· (1) Accumulator Addressing Thirteen instructions allow Accumulator A or B as an operand. They are: ASL, ASR, CLR, COM, DEC, INC, LSR, NEG, PSH, PUL, ROL, ROR and TST. In this case, an ~ or ~ between the operator and the operand may be omitted. Each accumulator addressing instructions is converted into a one-byte machine code by the assembler. Example: Instruction code Machine code (Hexadecimal) ASL A or ASLA 48 ASR B or ASRB 57 (2) Implied Addressing In the implied addressing mode, the instruction contained in the operator field permits the address for operation to be clear-cut. The operand is therefore unnecessary. This implied addressing includes 31 instructions: ABA, ABX, ASLD, CBA, CLC, CLI, CLV, DAA, DES, DEX, INS, lNX, LSRL, MUL, NOP, PSHX, PULX, RTI, RTS, SBA, SEC, SEl, SEV, SWI, TAB, TAP, TBA, TPA, TSX, TXS and WAI. Each instruction is converted into a one-byte machine code by the assembler. ~HITACHI 18 (3) Immediate Addressing There are 16 instructions that allow immediate addressing. They are: ADC, ADD, AND, BIT, CMP, CPX, EOR, LDA, LDS, I LDX, ORA, SBC, SUB, LDD, ADDD and SUBD. The operand field starts with #, followed by numerical data in decimal, hexadecimal, octal or binary, symbols (labels) that will take specific values during assembling, expressions and ASCII constants. In any case, the assembler converts the immediate data (operand) into an unsigned 8-bit binary, or 16-bit binary for CPX, LOS, LOX, LOO, AOO and SUBO. The resulting immediate data range from 0 to 255, or 0 to 65535 for 16-bit operand instructions. Example: rilachine code (Hexadecimal) Statement Label = 100 Byte 1 Byte 2 Byte 3 LDA A #25 86 19 - LOA A #LABEL 86 64 - LOA A #LABEL + 25 86 7D - LDA A # 'A 86 41 - CPX #256 8C 01 00 In this case, the characters following "'" are converted into 7-bit ASCII data. The #'conversion is not generally used with CPX, LOS ~nd LOX instructions. If it is used, however, the converted ASCII,data is stored into byte 3. The assembler enables each immediate addressing instruction to be converted into 2 bytes in machine code (3 bytes in the case of CPX, LDS, LOX, LOO, ADOO and SUBO). Figure 1-1-1 shows how data flows in immediate addressing mode. ~HITACHI 19 CPU CPU [E ACCA O_~r¢: RAM --3 AM <= ...- Program memory Pr ogram memory PC Instruc- pc- 5002 I.OA A tion ..... ~ -- Data 25 Outline flowchart Example Fig. 1-1-1 Data Activity in Immediate Addressing Mode (4) Direct Addressing and Extended Addressing In direct addressing mode, the assembler converts the instruc- tion into 2 bytes of machine code. The second byte, after conversion, includes an unsigned a-bit binary address. In extended addressing mode, the assembler converts the instruction into 3 bytes of machine code. The second byte includes the upper a bits of the address; and the third byte includes the lower a bits. Both of them are unsigned a-bit in binary notation. The assembler permits both direct addressing and extended addressinq to be translated into absolute addresses. The assembler automatically selects direct addressing if the address is within 0 - 255; and extended addressing if the address is greater than 255. ~HITACHI 20 Example: Machine code (Hexadecimal) Statement Label address = 100 Byte 1 Byte 2 Byte 3 LOA A 100 LOA A LABEL LOA A LABEL + 200 96 96 B6 64 64 01 - - 2C I Figures 1-1-2 and 1-1-3 show how data flows in direct addressing and extended addressing modes, respectively. CPU CPU ACCA r<==-- QJ <-= _RAM . / RAM Address Data f<= Address ~ 100 35 <= - Pr ogram memory Pr ogram memory --- PC - Instruc- tion PC=5004 LDA A. ~ -'- ~ 100 ..... Address Address= 0 s:: 2S S - - Outline flowchart Example Fig. 1-1-2 Data Activity in Direct Addressing Mode ~HITACHI 21 CPU CPU ACCS f--..=: ~ RAM ,--- - Address Data f<;:= - Pr ogram memory Program memory Instruc- LOA S tion .c'--:: PC Address P C-500 300 Address Address ::?; 256 Outline flowchart Example Fig. 1-1-3 Data Activity in Extended Addressing Mode (5) Indexed Addressing In Indexed addressing mode, the assembler converts the operand into an unsigned 8-bit displacement "Disp". The displacement "Disp" is added to the contents of the Index Register to determine the effective address M. M = Disp + (X) As other addressing modes, the operand may contain symbols (labels) and expression that are ~valuated during assembling. They must range from 0 to 255. ~HITACHI 22 Example: Machine code (Hexadecimal) Statement Label address = 100 I Byte 1 Byte 2 LOA B X E6 00 LOA B, X E6 00 LOA B 5, X E6 05 LOA B LABEL, X E6 64 LOA B LABEL + 5, X E6 69 Figure 1-1-4 shows how data flows in indexed addressing mode. CPU CPU I OTI ~- ACCS Ind ex register RAM EJ Address=Index ~====::::::==l RA ~ register+ Displacement Data Address a 405 59 f::;= - Program memory Pr ogram memory PC Instruc- tion PC a 500 6 -- LOA B Displace- ¢- 5 ment - Displacement s:: 256 Outline flowchart Example Fig. 1-1-4 Data Activity in Indexed Addressing Mode ~HITACHI 23 (6) Relative Addressing This mode is limited to branch instructions. A relative addressing instruction is converted into 2 bytes of machine code by the assembler. The second byte indudes an a-bit relative address (ReI., used as two's complement). On execution, the relative address (ReI.), the contents of the Program Counter (PC), and 2 are added to obtain the absolute address (D) of the branch destination as follows. D (PC) + 2 + Rel. D absolute address of branch destination Rel relative address Therefore, the branch destination is within -126 and +129 from the OP-code address. Example: Machine code (Hexadecimal) Statement Label address - (PC) -2 = 100 Byte 1 Byte 2 BEQ *+17 27 OF BEQ LABEL 27 64 BEQ LABEL - 105 27 FB If, however, the branch destination is more than -126 to +129 away, JMP and JSR instructions can be used as shown below. ~HITACHI 24 Example: Machine code (Hexadecimal) Statement Byte 1 I Byte 2 Byte 3 JMP 300 7E 01 2C JSR 300 BD 01 2C Figure 1-1-5 shows how data flows in relative addressing mode. CPU CPU ~ HINZVC r---.;= RAM RAM - ~ .-.. .-"\. -.......r- .......- Pro gram memory - - Pr ogram memory - Instruc- - PC tion <"- ..... PC= 5008 SEQ ~ Dis~lace- men 15 Next 1n- Next in- (PC+2) struction PC- 5010 struction (Z)!o;O - r-- Next 1n- (PC+ 2) + struction PC a 5025 Next in- (Z)=o struction Displacement ....... - ~ Fig. 1-1-5 Data Activity in Relative Addressing Mode ~HITACHI 25 1.2 CPU Registers The CPU has three 16.;bit registers and three 8-bit registers. The register configuration of the CPU is shown in Fig. 1-2-1. is shown in Fig. 1-2-1. 7 0 I ACCA I Accumulator A 7 0 I .~CC B I Accumulator B 15 0 I IX I Index Register 15 0 I PC I Program Counter 15 0 I SP I Stack Pointer 7 0 CCR 11111BI rlNlzlvlcl Condition Code Register L Carry-borrow, from bit 7 Overflow - Zero Negative Interrupt mask Half-carry, from bit 3 Fig. 1-2-1 CPU Registers (l) Accumulators (ACCA & ACCB) The CPU has two a-bit accumulators that store the result of arithmetic and logical operation. If a double accumulator is specified, a pair of registers ACCA and ACCB can be functions as an l6-bit register. 15 87 0 I ACCA ACCB I Fig. 1-2-2 ACCAB (Double Accumulator) (2) Index register (IX) The index register is a 2-byte (l6-bit) register that stores a l6-bit memory address used in indexed addressing mode or a l6-bit immediate data. ~HITACHI 26 (3) Program counter (PC) The program counter is a 2-byte (l6-bit) register that indi- cates the address of the instruction being executed by the cpu. (4) After the instruction execution, the program counter is automatically incremented, indicating the address of the next instruction. Stack pointer (SP) I The stack pointer is a 2-byte (l6-bit) register that indi- cates the next available location in the memory pushdown/ popup stacks. Any area of memory may serve as stacks; and random access (read/write) memory is generally used as stacks. In an application system which must hold data in stacks even an application system which must hold data in stacks even when power supply is off, the stacks normally use battery- backed CMOS memory. (5) Condition code register (CCR) The condition code register indicates the result of arithmetic operation, etc. It consists of six bits: zero (Z), negative (N), overflow (V), carry-borrow from bit 7 (C), half-carry from bit 3 (H), and interrupt mask (I). These bits may be tested by a variety of conditional branch instructions, which is limited to relative addressing. It should be noted that the upper two bits of the contition code register cannot be used. ~HITACHI 27 1.3 Instruction Set Details l-1eanings of symbols and mnemonics: (1) Operation symbols () Contents Direction of data transfer From stack To stack AND operation o OR operation $ Exclusive-OR operation - NOT operation (2) Registers within MPU ACCA Accumulator ~. ACCB = Accumulator B ACCX Accumulator A or B ACCD Double accumulator (ACCA + ACCB) CC Condition-code register IX Index register, 16 bits IXH MSB 8 bits of index register IXL = LSB 8 bits of index register PC Program counter, 16 bits PCH MSB 8 bits of program counter PCL LSB 8 bits of program counter SP Stack pointer, 16 bits SPH MSB 8 bits of stack pointer SPL LSB 8 bits of stack pointer (3) Memory and addressing modes M liJemory address MH MSB 8 bits of memory address ML LSB 8 bits of memory address M+l Memory addres.s of memory address M + 1 Imm Immediate data ~HITACHI 28 ImmH MSB 8 bits of immediate value Im.'TIL LSB 8 bits of immediate value Disp Displacement = M - (IX) I ReI Relative addressing = Branch destination absolute address - (PC) - 2 ACCX Accumulator addressing IMMED Immediate addressing DIRECT Direct addressing INDEX Index addressing EXTEND Extended addressing RELATIVE Relative addressing IMPL Implied addressing (4) Meaning of bits 0 through 5 of condition-code register C Carry and borrow; bit 0 V Overflow for 2's complement; bit 1 Z Zero; bit 2 N Negative; bit 3 I Interrupt mask; bit 4 H Half carry from bit 3 to bit 4 ; bit 5 (5) Bit status before run of instruction An Bit n of ACCA (n = 7, 6, 5, ••• I 0) Bn Bit n of ACCB (n = 7, 6, 5, ... , 0) Dn Bit n of double accmulator (n = 15, 14, 13, ... , 0) IXn Bit n of IX (n = 15, 14, 13, ... , 0) IXHn Bit n of IXH (n 7, 6, 5 , ... , 0) IXLn Bit n of IXL (n 7, 6, 5, ... , 0) Mn Bit n of M (n = 15, 14, 13, ... , 0) SPHn Bit n of SPH (n 7, 6, 5, ... , 0) SPLn Bit n of SPL (n 7, 6, 5, ... , 0) Xn Bit n of ACCX (n = 7, 6, 5, ... , 0) (6) Bit status after run of instruction Rn Bit n of result (n = 15, 14, 13, ... , 0) RHn Bit n of resulting high-order byte (n = 7, 6, 5, ..• , 0) RLn Bit n of resulting low-order byte (n = 7,6,5, ... ,0) ~HITACHI 29 Add accumulator B to accumulator A L ABA Category Function " Arithmetic operation ACCA - (ACCA) + (ACCB) (Two Adds the contents of ACCB to the contents of ACCA, operands) and stores the result into the ACCA. I, Effects on the condition codes H = A3'B3@B3'R~R3'A3: Set i f a carry from bit 3 is generated; cleared otherwise. I : Not affected. N = R7: Set i f the result's HSB is "l"i cleared otherwise. Z = R7·R6·R5·R4·R3·R2·Rl·RO: Set i f the result is zero; cleared otherwise. V = A7·B7·R70A7.B7·R7: Set if the result overflows; cleared otherwise. C = A7·B70B7·R70R7·A7: Set if a carry from the MSB is generated cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL ABA IB 1 1 ~HITACHI 30 Add accumulator B to indeX register / ABX category Function I Arithmetic IX - (IX) + (ACCB) operation Adds the unsigned contents of ACCB to the contents of the IX taking into account a carry from the low-order byte of the IX, and stores the result into the IX. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL ABX 3A 1 1 ~HITACHB 31 ADd with Carry L ADC Category Function Arithmetic operation ACCX - (ACCX) + (M) + (C) (Two Adds the contents of ACCX, memory M, and carry bit C, operands) and stores the result into the ACCX. Effects on the condition codes H = X3·M39M3·R39R3·X3: Set i f a carry from bit 3 is generated; cleared otherwise. I : Not affected. N = R7: Set if the result's MSB is "III; cleared otherwise. Z = R7·R6·R5·R4·R3·R2·Rl·RO: Set i f the result is zero; cleared otherwise. V = X7·M7·R79X7·M7·R7: Set i f the result overflows; cleared otherwise. C = X7·M79M7·R79R7·X7: Set if a carry from the MSB is generated; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. byte byte byte code cycles IMMED ADC A Unun 89 Inun 2 2 DIRECT ADC A M 99 M 2 3 EXTND ADC A M B9 MH ML 3 4 INDEX ADC A Disp,X A9 Disp 2 4 IMMED ADC B #Inun C9 Inun 2 2 DIRECT ADC B M 09 ~1 2 3 EXTND ADC B M F9 MH ML 3 4 INDEX ADC B Disp,X E9 Disp 2 4 ~HITACHI 32 ADD without carry / ADD category Function - I Aritrunetic ACCX (ACCX) + (M) operation (Two operand) Adds the contents of memory M to the contents of ACCX and stores the result into the ACCX_ Effects on the condition codes H = X3-M38M3-R38R3-X3: Set i f a carry from bit 3 is generated; cleared otherwise_ I : Not affected_ N = R7: Set i f the result's MSB is "l"i cleared otherwise_ Z = R7-R6-RS-R4-R3-R2-Rl-RO: Set i f the result is zero; cleared otherwise_ V = X7-M7-R78X7-M7-R7: Set i f the result overflows; cleared otherwise_ C = X7-M78M7-R7GR7-X7: Set i f a carry from the MSB 16 generated; cleared otherwise_ .. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr_ cycles byte byte byte code IMMED ADD A #Inun 8B I nun 2 2 DIRECT ADD A M 9B M 2 3 EXTND ADD A M BB MH ML 3 4 INDEX ADD A Disp,X AB Disp 2 4 IMMED ADD B #Inun CB Inun 2 2 DIRECT ADD B M DB M 2 3 EXTND ADD B M FB MH ML 3 4 INDEX ADD B Disp,X EB Disp 2 4 ~HITACHI 33 Double ADD without carry / ADDD Category Function Arithmetic operation ACCD - (ACCD) + (M:M+l) Adds the contents of memories M and M+l to the contents of ACCD, and stores the result into the ACCD. Effects on the condition codes H : Not affected. I : Not affected. N : N=R1S; Set i f the result's MSB is Ill"; cleared otherwise. Z = R1S·R14·R13·········RO: Set i f the result is zero; cleared otherwise. V = AB1S·M1S·R1S0AB1S·M1S·R1S: Set i f the result overflows; cleared otherwise. C = AB1S·M1S0M1S·R1S0R1S·AB1S: Set if a carry from the MSB is generated; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code -- IMMED ADDD #Imm C3 ImmH ImmL 3 3 - DIRECT ADDD M D3 M 2 4 EXT NO ADDD M F3 MH ML 3 5 INDEX ADDD Disp,X E3 Disp 2 5 @HITACHI 34 And IMmediate / AIM Category Function Logic M- 1M - (M) operation ANDs the immediate data and the contents of the memory M, and stores the result into the meory M_ I Effects on the condition codes H : Not affected_ I : Not affected_ N = R7: Set i f the result's MSB is "1"; cleared otherwise_ Z = R7-R6-RS-R4-R3-R2-Rl-RO: Set if the "resul t is zero; cleared otherwise_ V = 0:Cleared_ C : Not affected_ Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr_ cycles byte byte byte code DIRECT AIM iImm,M 71 Imm M 3 6 INDEX AIM iImm,Disp,X 61 Imm Disp 3 7 ~HITACHI 35 logical AND / AND Category Function Logic ACCX - (ACCX) . (M) operation ANDs the contents of ACCX and the memory M, and stores the results into the ACCX. Effects on the condition codes H : Not affected_ I : Not affected. N = R7: Set i f the result's MSB is "I"; cleared otherwise. Z = R7-R6-RS-R4·R3-R2-Rl·RO: Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr_ cycles byte byte byte code IMMED AND A Umm 84 Imm 2 2 DIRECT AND A M 94 M 2 3 EXTND AND A M B4 MH ML 3 4 INDEX AND A Disp,X A4 Disp 2 4 IMMED AND B Umm C4 Imm 2 2 DIRECT AND B M D4 M 2 3 EXTND AND B M F4 MH ML 3 4 INDEX AND B Disp,X E4 Disp 2 4 ~HITACHI 36 Arithmetic Shift Left / ASL Category Function Shift & I rotation [D-l I I I I I I I I - 0 b, b. Shifts ACCX or memory M by one bit to the left. Bit 0 takes "0". The original value of bit 7 moves into the carry bit C. Effects on the condition codes H : Not affected. I : Not affected. N == R7: Set if the result's MSB is "1"; cleared otherwise. Z == R7'R6'~'R4'R4'R3'~'Rl'RO: Set if the result is zero; cleared otherwise. V == NEIlC: Set if either N=l and C=O or N==O and C=l after the shift operation; cleared otherwise. Note: The Nand Care those. obtained after operation. C == M7: Set if the MSB of ACCX or the memory is "1" before the shift operation; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX ASL A 48 1 1 ACCX ASL B 58 1 1 EXTND ASL M 78 MH ML 3 6 INDEX ASL Disp,X 68 Disp 2 6 ~HITACHI 37 Arithmetic Double Shift Left A:B / ASLD Category Function Shift & rotation 0-1 I I I I I I I I I I I I I I I I-@] b" bo Shifts ACCD by one bit to the left. Bit 0 takes "0". The original value of bit 15 moves into carry bit C. Effects on the condition codes H : Not affected. II I : N = R15: Set if the result's MSB is "1"; cleared otherwise. Z = R15·R14·R13··········RO: Set if the result is zero; cleared otherwise. V = Nec: Set if either N=l and C=O or N=O and C=l after the shift operation; cleared otherwise. Note: The N and C are those obtained after operation. C = A B15 : Set i f the MSB of ACCAB is "I" before the shift operation; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL ASLD 05 1 1 I ~HITACHI 38 Arithmetic Shift Right L ASR category Function I Shift & rotation Y":I I I I I I I• r-@] b, bo Shifts the contents of ACCX or nlemory M by one bit to the right. Bit 7 is not affected. The original value of bit 0 moves into carry flag. Effects on the condition codes H : Not affected. I I Not affected. N = R7: Set if the result's MSB is IIl"i cleared otherwise. X ::: ~'M'~'M'R3'R2'~'RO: Set i f the result is zero; cleared otherwise. V '" N$C: Set if either N=l and C=O or N=O and Col after the shift operation; cleared otherwise. Note: The Nand Care those obtained after operation. C = MO: Set if the LSB is '''1'' before the shift operation; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX ASR A 47 1 1 ACCX ASR B 57 1 1 EXTND ASR M 77 MH ML 3 6 INDEX ASR Disp,X 67 Disp 2 6 - ~HITACHI 39 Branch if Carry Clear / BCC Category Function Condi- PC - (PC) + 0002 + Rel If (C) = 0 tional branch Tests the state of carry bit C and causes a branch i f C = O. Effects on the condition codes H . Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BCC Rel 24 Rel 2 3 $HITACHI 40 Bit CLeaR / BCLR Category Function Logic Mi - 0 I operation Clears bit i (i=O to 7) of the memory M. Other bits are not affected. * The machine code of this instruction is the same as AIM. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "1"; cleared otherwise. Z = R7 • R6 • RS • R4 • R3 • R2 • Rl • RO : Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruct'ion code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code DIRECT BCLR O,M 71 FE M 3 6 " BCLR 1,M " FD " " " " BCLR 2,M " FB " " " " BCLR 3,M " F7 " " " " BCLR 4,M " EF " " " " BCLR 5,M " DF " " " " BCLR 6,M " BF " " " " BCLR 7,M " 7F " " " INDEX BCLR O,Disp,X 61 FE Disp 3 7 " BCLR 1,Disp,X " FD " " " " BCLR 2,Disp,X " FB " " " " BCLR 3,Disp,X " F7 " " " " BCLR 4,Disp,X " EF " " " " BCLR 5,Disp,X " DF " " " " BCLR 6,Disp,X " BF " " " " BCLR 7,Disp,X " 7F " " " ~HITACHI 41 Branch if Carry Set / BCS Category Function Condi- PC - (PC) + 0002 + ReI If (C) = 1 tional branch Tests the state of carry bit C and causes a branch ifC=l. I Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BCS ReI 25 ReI 2 3 1-" ~HITACHI 42 Branch if EQual / BEQ Category Function I Condi- PC - (PC) + 0002 + Rel I f (Z) = 1 tional branch Tests the state of bit Z and causes a branch i f Z=l. Effects on the condition codes H : Not affected. I : II II N : II Z : II V : ·11 C : Addressing modes and CPU cycles Addressing Operand Instruction code Bytes of I CPU ' mode Mnemonic format 1st 2nd 3rd instr.II cycles byte byte byte code RELATIVE BEQ Rel 27 Rel 2 3 ~HITACHI 43 Branch i f Greater than or Equal to zero / BGE Category Function Condi- PC - (PC) + 0002 + ReI i f (N) $ (V) = 0 tional branch that is, (ACCX) > (M) ; in the case of two's complement Branches if N=l and V=l or if N=O and V=O. When a BGE instruction is executed immediately after an instruction such as CBA, CMP, SBA or SUB has been executed, a branch occurs if the minuend (ACCX) as a two's complement is greater than, or equal to, the subtracter (M) as a two's complement. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BGE ReI 2C ReI 2 3 I ~HITACHI 44 Branch i f Greater Than zero / BGT Category Function I Condi- PC - (PC) + 0002 + Rel I f (Z)0[ (N)€D(V) 1 = 0 tional branch that is, (ACCX) > (M) ; in the case of two's complement Branches i f z=O and N&V=l or i f Z=O and N&V=O. When a BGT instruction is executed immediately after an instruction such as CBA, CMP, SBA or SUB has been executed, a branch occurs i f the minuend (ACCX) as a two's complement is greater than the subtracter (M) as a two's complement. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BGT Rel 2E Rel 2 3 ~HITACHI 45 Branch if HIgher / BHI Category Function Condi- PC - (PC) + 0002 + Rel I f (C)0(Z) = 0 tional That is, (ACCX) > (M) ; in the case of unsigned binary branch Branches i f C=O and z=o. When a BHI instruction is executed immediately after an instruction such as CBA, CMP, SBA or SUB has been executed, a branch occurs i f the minuend (ACCX) as a unsigned binary is greater than the subtracter (M) as a unsigned binary. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BHI Rel 22 Rel 2 3 ~HITACHI 46 BIt Test I BIT Category Function -_._- . (M) I Logic (ACCX) operation Performs the logical "AND" operation between the contents of ACCX and those of memory (M) . Then, the condition codes reflect the result_ The contents of the ACCX and those of memory M remain unchanged_ Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "111; cleared otherwise. Z = R7'R6-R5-R4'R3-R2'Rl'RO: Set i f all bits of the result are zeros; cleared otherwise. V = 0: Cleared. C : Not affected. Address~ng modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMMED BIT A # Irnrn 85 Irnrn 2 2 DIRECT BIT A M 95 1-1 2 3 EXTND BIT A M B5 MH ML 3 4 INDEX BIT A Disp,X AS Disp 2 4 IMMED BIT B # Irnrn C5 Irnrn 2 2 DIRECT BIT B M 05 M 2 3 EXTND BIT B M F5 MH ML 3 4 INDEX BIT B Disp, X E5 Disp 2 4 ~HITACHI 47 Branch. if Less than or Equal to zero / BLE Category Function Condi- tional PC - That is, (PC) + 0002 + Rel I f (Z) 0 [ (N) ED (V) 1 = 1 (ACCX) ~ (M) ; in the case of two's complement branch Branches i f Z=l or N=l & v=o or N=O & V=l. When aBLE instruction is executed immediately after an instruction such as CBA, CMP, SBA or SUB has been executed, a branch occurs i f the minuend (ACCX) as a two's complement is smaller than, or equal to, the subtracter (M) as a two's complement. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BLE Rel 2F Rel 2 3 i ~HITACHI 48 Branch i f Lower or Same / BLS Category ,_. Function --- Condi- tional PC - (PC) + 0002 + Rel I f (C) e (Z) = 1 That is, (ACCX) ~ (M) ; in the case of unsigned binary branch Branches i f C=l or Z=l. When a BLS instruction is executed immediately after an instruction such as CBA, CMP, SBA or SUB has been executed, a branch occurs i f the minuend (ACCX) as a unsigned binary is smaller than, or equal to, the subtracter (M) as a unsigned binary. Effects on the condition codes H : Not affected. It I : It N : Z : It V : It It C : Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BLS Rel 23 Rel 2 3 ~HITACHI 49 Branch if Less Than zero / BLT Category Function Condi- PC - (PC) + 0002 + ReI I f (N) 61 (V) = 1 tional branch That is, (ACCX) < (M) 1 in the case of two's complement Branches if N=l & V=O or N=O & V=l. When a BLT instruction is executed immediately after an instruction such as CBA, CMP, SBA or SUB has been executed, a branch occurs if the minuend (ACCX) as a two's complement is smaller than the substracter (M) as a two's complement. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BLT ReI 20 ReI 2 3 ~HITACHI 50 Branch if MInus / BMI Category Function I Condi- PC - (PC) + 0002 + Rel If (N) = 1 tional branch Tests the state of negative bit N and causes a branch i f N=l. Effects on the condition c0des H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BNI Rel 2B Rel 2 3 ~HITACHI 51 Branch if Not Equal / BNE Category Function Condi- PC - (PC) + 0002 + ReI I f (Z) =0 tional branch Tests the state of zero bit Z and causes a branch if z=o. - Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BNE ReI 26 ReI 2 3 $ HITACHI 52 Branch if PLus / BPL Category Function - I Condi- PC (PC) + 0002 + Rel. I f (N) = 0 tiona1 branch Tests the state of negative bit N and causes a branch i f N=O. Effects on the condition codes H : Not affected I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BPL Re1 2A Re1 2 3 ~HITACHI 53 BRanch Always / BRA Category Function Uncondi- P C - (PC) + 0002 + Rel tional branch & jump Branches unconditionally to the address resulting from the above expression. "Rel" is the relative address stored as a two's complement in the second byte of the machine code of a branch instruction. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BRA Rel 20 Rel 2 3 ~HITACHI 54 BRanch Never I BRN Category Function I Uncondi- P C - (PC) + 0002 tional branch & jump A two-byte 3-cycle instruction that is equivalent to NOP instruction. As a feature of the HD6301, this instruction provides a function opposite to the BRA instruction. Note: The second byte of the instruction code takes an arbitrary value (0 to $FF) at which a branch may occur. Effects on the condition codes H : Not affected. I : II N : II II Z : V : II C : II Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BRN Rel 21 Rel 2 3 ~HITACHI 55 Bit SET I BSET Category Function Mi --- 1 Logic Sets bit i of the memory. (i = 0 to 7) Other bits operi'\tion are not affected. * The machine code of this instruction is the same as OIM. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "1"i cleared otherwise. Z = R7 • R6 • R5 • R4 • R3 • R2 • Rl . RO : Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU ~ycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code DIRECT BSET o ,M 72 01 M 3 6 " BSET 1,M " 02 " " " " BSET 2,M " 04 " " " I " BSET 3,M " I 08 " " " " BSET 4,M " 10 " " " " BSET 5,M " 20 " " " " BSET 6,M " 40 " " " " BSET 7,M " 80 " " " INDEX BSET O,Disp,X 62 01 Disp 3 7 " BSET 1,Disp,X " 02 " " " " BSET 2,Disp,X " 04 " " " " BSET 3,Disp,X " 08 " " " " BSET 4,Disp,X " 10 " " " " BSET 5,Disp,X " 20 " " " " BSET 6,Disp,X " 40 " " " " BSET 7,Disp,X " 80 " " " ~HITACHI 56 Branch to SubRoutine / BSR Category Function - (PC) + 0002 I Subroutine PC 1. Increments the PC by two. control I (PCL) 2. Saves the low-order byte of the SP I - (PCH) (SP) - 0001 program counter into the stack. 3. Decrements the SP by one. SP - (SP) - 0001 4. Saves the high-order byte of the PC into the stack. 5. Decrements the SP by one. PC - (PC) + Rel 6. Branches to the address indicated by the program. Effects on the condition codes H : Not affected. I : . N : .. Z : . V : . C : . Addressing modes and CPU cycles Instruction code Bytes Addressing' Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BSR Rel 80 Rel 2 5 ~HITACHI 57 Bit ToGgLe / BTGL Category Function Mi - MI Logic Inverts bit i of the memory M. (i = 0 to 7) Other operation bits are not affected. NOTE) BTGL has the same instruction code as ElM. Effects on the condition codes H : Not affected. I : Not affected. N : R7: Set i f the result's MSB is "l"; cleared otherwise. Z = R7 . R6 . R5 • R4 . R3 • R2 • Rl . RO : Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code DIRECT BTGL D,M 75 01 M 3 6 " BTGL I,M " 02 " " " " BTGL 2,M " 04 " " " " BTGL 3,M " 08 " " " " BTGL 4,M " 10 " " " " BTGL 5,M " 20 " " " " BTGL 6,M " 40 " " " " BTGL 7,M " 80 " " " INDEX BTGL O,Disp,X 65 01 Disp 3 7 " BTGL 1,Disp,X " 02 " " " " BTGL 2,Disp,X " 04 " " " " BTGL 3,Disp,X " 08 " " " " BTGL 4,Disp,X " 10 " " " II " BTGL 5,Disp,X " 20 "- - ------,. " " BTGL .6,Disp,X " 40 " - -- .. " " " BTGL 7,Disp,X " 80 " " " ~HITACHI 58 Bit TeST / BTST Category Function Mi . 1 I Logic Performs the logical "AND" operation between bit i operation (i=O to 7) of the memory M and Ill". Then, the condition codes reflect the result. NOTE) BTST has the same instruction code as TIM. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "l"i cleared otherwise. Z = R7·R6·RS·R4.R3·R2·Rl·RO: Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code DIRECT BTST o,M 7B 01 M 3 4 II II II BTST 1,M " 02 II i, II II II BTST 2,M 04 II II II II II BTST 3,M 08 II II II II II BTST 4,M 10 II II II BTST S,M II 20 " II II II II II BTST 6,M 40 II II II II II BTST 7,M 80 II INDEX BTST O,Disp,X 6B 01 Disp 3 5 II II II BTST 1,Disp,X II 02 II II II II II BTST 2,Disp,X 04 II II II II II BTST 3,Disp,X 08 II II II II II BTST 4,Disp,X 10 II II II II II BTST S,Disp,X 20 II II II II II BTST 6,Disp,X 40 II II II II II BTST 7,Dis: ,X 80 II ~HITACHI 59 Branch if oVerflow Clear / BVe Category Function Condi- PC - (PC) + 0002 + Rel If (V) = 0 tional branch Tests the state of overflow bit V and causes a branch i f V = o. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and· CPU cycles Instr\lction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BVC Rel 28 Rel. 2 3 ~HITACHI 60 Branch i f oVerflow Set / BVS Category Function Condi- PC - (PC) + 0002 + ReI If (V) =1 tional branch Tests the state of overflow bit V and causes a branch i f V = l. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code RELATIVE BVS ReI 29 ReI 2 3 ~HITACHI 61 Compare Accumulators / CBA Category Function Compare & (ACCA) - (ACCB) test Compares the contents of ACCA to those of ACCB and sets the condition codes according to the result. Used for a conditional branch in arithmetic or logical operation. Both operands are not affected. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the MSB of the result is "1"; cleared otherwise. Z = R7· R6. R5· R4. R3· R2. Rl. RO: Set i f the result is zero; cleared otherwise. V = A7·B7·R7GA7·B7·R7: Set i f the result overflows; cleared otherwise. C = A7·B70B7·R7GR7·A7: Set if a borrow is generated; cleared otherwise. Addressing modes and CPU cycles --- Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL CBA 11 1 1 I ~HITACHI 62 CLear Carry / CLC Category Function Bit Bit C - 0 control Clears carry bit C. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C=O : Cleared. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL CLC OC 1 1 ~HITACHI 63 CLear Interrupt mask / CLI Category Function Bit control Bit I - 0 Clears the interrupt mask bit I of the condition code. When an interrupt occurs in response to an interrupt request from a peripheral, this instruction enables the microprocessor to receive the interrupt request. Effects on the condition codes H : Not affected. I=O : Cleared. N : Not affected. Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL CLI OE 1 1 ~HITACHI 64 CLeaR / CLR Category Function I Arithmetic ACCX --- 00 or M --- 00 operation (One operand) Cleares the contents of ACCX or those of memory M to zero. Effects on the condition codes H : Not affected. I : " N=O : Cleared. Z=l : Set· v=o : Cleared. c=o : Cleared. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX CLR A 4F 1 1 ACCX CLR B SF 1 1 EXTND CLR M 7F MH ML 3 S INDEX CLR Disp,X 6F Disp 2 S ~HITACHI 65 : CLear two's complement oVerflow bit / CLV Category Function Bit Bit V - 0 control Clears the overflow bit V of the condition code. Effects on the condition codes H : Not affected. I : " N : " Z : " V=O : Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addr.essing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL CLV OA 1 1 ~HITACHI 66 CoMPare / CMP Category Function Compare (ACCX) - (M) .& Test Compares the contents of ACCX to those of memory M and changes the condition codes 'according to the result. The contents of the condition codes may be referenced by the following conditional branch instruction. Both operands are not affected. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set if the MSB of the result is "111; cleared otherwise. Z = R7· R6· R5· R4· R3· R2 ·Rl· RO: Set i f the result is zero; cleared otherwise. V = X7·M7·R7@X7·M7·R7: Set i f the result overflows; cleared otherwise. C = X7·M78M7·R7@R7·X7: Set if the absolute value of the memory is greater than those of the accumulator; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMMED CMP A iImm 81 Imm 2 2 DIRECT CMP A M 91 M 2 3 EXTND CMP A M B1 MIl ML 3 4 INDEX CMP A Disp,X A1 Disp 2 4 IMMED CMP B iImm C1 Imm 2 2 DIRECT CMP B M D1 M 2 3 EXTND CMP B M F1 MH ML 3 4 INDEX CMP B Disp,X E1 Disp 2 4 ~HITACHI 67 COMplement / COM Category Function Logic ACCX - -(ACCX) = FF - (ACCX) or operation M-_(M) = FF - (M) Takes one's complement of each bit in ACCX or memory M. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "1"; cleared otherwise. Z = R7'R6'R5'R4'R3'R2'Rl'RO: Set i f the result is zero; cleared otherwise. V = 0: Cleared. C = 1: Set. , Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX COM A 43 1 1 ACCX COM B 53 1 1 EXTND COM M 73 MH ML 3 6 INDEX COM Disp,X 63 Disp 2 6 ~HITACHI 68 ComPare indeX register / CPX Category Function - (M : M + 1) I Index (IX) register control Compares the contents of the IX to those of memories M and M+l. Effects on the condition codes H : Not affected. I : Not affected. N = R1S: Set i f the MSB of the result is "lili cleared otherwise. Z = (RlS· Rl4 . R13· R12· RH· RIO· R9· RB . R7· R6· R5· R4 . R3 . R2· RI· RO) : Set i f the result is "0"; cleared otherwise. V = IXIS·MlS·R1S@IXlS·MlS·RIS: Set i f the result overflows; and cleared otherwise. C = IXIS·MIS@MlS·R1S@RlS·IXIS: Set i f the absolute value of the memory is greater than that of the index register; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format cycles 1st 2nd 3rd instr. byte byte byte code IMMED CPX #Imm BC ImmH ImmL 3 3 DIRECT CPX M 9C M 2 4 EXTND CPX M BC MH ML 3 S INDEX CPX Disp,X AC Disp 2 S @HITACHI 69 Decimal Adjust ACCA / DAA Category Function Bit C before 0 0 0 0 0 0 I I I Adds the hexa- OAA decimal data, High-order 00, 06, 60 and 4 bits 0-9 0-8 0-9 A-F 9-F A-F 0-2 0-2 0-3 66, to ACCA IBits 4 - 71 according to Ini tial bi t H the table. (Half carry) 0 0 I 0 0 I 0 0 I Low-order For BCO(binary- 4 bits 0-9 A-F 0-3 0-9 A-F 0-3 0-9 A-F 0-3 coded decimal) i(Bits 0 - 3) addition by an Hex. data I instruction added to such as ABA,ADD ACCX by OAA 00 06 06 60 66 66 60 66 66 or ADC, OAA executes this Bit c after function if the OAA 0 0 0 I I I I I I result is in bits C and H of ACCA. Effects on the condition codes H : Not affected. I : Not affected. N : R7: Set if the MSB of the result is "1", cleared otherwise. Z m~·R·B·u·n·U·n·Mr Set i f the result is zero, cleared otherwise. V : Not affected. C : Set or cleared as shown in the above table. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL DAA 19 1 2 ~HITACHI 70 DECrement / DEC Category Function Arithmetic ACCX - (ACCX) - 01 or I operation M- (M) - 01 Subtracts 1 from the contents of ACCX or those of memory M. Bits N, Z and V are set according to the result. Bit C is not affected. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the MSB of the result is 111"; cleared otherwise. Z = R7·R6·RS·R4·R3·R2·R1·RO: Set i f the result is zero; cleared otherwise. V = X7·X6·XS·X4·X3·X2·X1·XO = R7·R6·RS·R4·R3·R2·R1·RO : Set i f the result overflows; cleared otherwise. An over- flow occurs i f the contents of ACCX or those of the memory before operation are 80. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX DEC A 4A 1 1 ACCX DEC B SA 1 1 EXTND DEC M 7A MH ML 3 6 INDEX DEC Disp,X 6A Disp 2 6 ~HITACHI 71 DEcrement Stack pointer / DES Category Function Stack S P - (SP) - 0001 pointer control Subtracts 1 from the SP. Effects on the condition codes H : Not affected. I . II II N : II Z : II V : II C : Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL DES 34 1 1 ~HITACHI 72 DEcrement indeX register / DEX category Function - 0001 I Index IX - ( IX) register control Subtracts 1 from the IX_ Bit Z is set or reset according to the result_ Effects on the condition codes H : Not affected_ I : Not affected_ N : Not affected_ Z = (RH7-RH6·RHS·RH4-RH3-RH2-RH1-RHO)· (RL7·RL6·RLS·RL4·RL3·RL2· RLl.RLO) : Set i f the result is zero; cleared otherwise_ V : Not affected ... C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL DEX 09 1 1 ~HITACHI 73 E-or IMmediate I ElM category Function -- Logic M - 1M $ (M) operation Performs the logical exclusive "OR" operation between the immediate data and the contents of memory M, and stores the result into the memory M. Effects on the condition codes H : Not affected. I : Not affected. N = M7: Set i f the M's MSB is "1"; cleared otherwise. Z = M7 ·M6 ·M5 ·M4 ·M3 ·M2 ·Ml·MO: Set i f the contents of M is zero, cleared oth~rwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code DIRECT ElM #Imm,M 75 Imm M 3 6 INDEX ElM #Imm,Disp,X 65 Imm Disp 3 7 -- ~HITACHI 74 Exclusive OR L EOR Category Function I Logic ACCX - (ACCX) (Jl (M) operation Performs the logical exclusive "OR" operation between the contents of ACCX and those of memory M, and stores the result into the ACCX. Effects on the condition codes H : Not affected. I : Not affected. N = R7 : Set i f the MSB of the result is '.1 11 i cleared otherwise. Z = R7 . R6 . RS . R4 . R3 . R2 . Rl . RO : Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format cycles 1st 2nd 3rd instr. byte byte byte code IMMED EOR A Umm 88 Imm 2 2 DIRECT EOR A M 98 M 2 3 EXTND EOR A M B8 MH ML 3 4 INDEX EOR A Disp,X A8 Disp 2 4 IMMED EOR B Umm C8 Imm 2 2 DIRECT EOR B M D8 M 2 3 EXTND EOR B M F8 MH ML 3 4 INDEX EOR B Disp,X E8 Disp 2 4 @HITACHI 75 INCrement / INC Catego.ry Function Arithmetic ACCX - (ACCX) + 01 or operation M- (M) + 01 Adds 1 to the contents of ACCX or those of memory M. Bits N, Z and V are set according to the result. Bit C is not affected. Effects on the condition codes H : Not affected. I : Not affected. N = R7: set i f the MSB of the result is "111; cleared otherwise. Z = R7·R6·RS·R4·R3·R2·Rl·RO: Set i f the result is zero; cleared otherwise. V = X7'X6-XS-X4-X3'X2-Xl'XO = R7 - R6 - RS . R4 - R3 - R2 - Rl . RO : Set i f the result overflows; cleared otherwise_ An over- flow occurs i f the contents of ACCX or those of the memory before operation are 7F. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format cycles 1st 2nd 3rd instr. byte byte byte code ACCX INC A 4C 1 1 ACCX INC B SC 1 1 EXTND INC M 7C MH ML 3 6 INDEX INC Disp,X 6C Disp 2 6 ~HITACHI 76 INcrement Stack pointer / INS Category Function I Stack SP - (SP) + 0001 pointer control Adds 1 to the SP. - Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL INS 31 1 1 ~HITACHI 77 INcrement indeX register / INX category Function Index I X - (IX) + 0001 register control Adds 1 to the IX. Only bit Z is set or reset according to the result. Effects on the condition codes· H : Not affected. I : Not affected. N : Not affected. Z = (RH7·RH6·RHS·RH4·RH3·RH2·RH1·RHO)· (RL7·RL6·RLS·RL4·RL3·RL2· RL1·RLO) : set i f the result ·is zero; cleared otherwise. V : Not affected. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPt} mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL INX 08 1 1 i I -- I ~HITACHI 78 JuMP / JMP category Function I Uncondi- PC - address tional branch & jump Branches to the instruction at the specified address. The branch destination is computed by using extended addressing or indexed addressing modes. Effects on the condition codes H : Net affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand ~PQ of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ._- EXTND JMP M 7E MH ML 3 3 INDEX JMP Disp,X 6E Disp 2 3 ~HBTACHI 79 Jump to SubRoutine / JSR Category Function Subroutine PC - (PC)+OOO3(EXTND) Increments the program counter control or by two or three according to PC t - (PC)+OOO2(INDEX) (PCL) the addressing mode, saves .it in the 2-byte stack, and SP I - (SP)-OOOl (PCH) updates the stack pointer. Then branches to the specified SP - (SP)-OOOl address. The branch destina- PC - numeric address tion is computed by using extended addressing or indexed addressing. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : ., Addressing modes and CPU cycles Instruction code Bytes C!>y Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code EXTND JSR M BD MH ML 3 6 INDEX JSR Disp,X AD Disp 2 5 DIRECT JSR M 90 M 2 5 -- -- ~HITACHI 80 LoaD Accumulator / LOA category Function I Transfer ACCX - (M) Loads the contents of memory M into the ACCX. Effects on the condition codes H : Not affected. I : Not affected. N = R7 : Set i f the MSB of the result is "111; cleared otherwise. Z = R7· R6· RS· R4 . R3· R2· Rl· RO: Set if the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 3rd instr. cycles 2nd byte byte byte code IMMED LOA A #Imm 86 Imm 2 2 DIRECT LOA A M 96 M 2 3 EXTND LOA A M B6 MH ML 3 4 INDEX LOA A Disp,X A6 Disp 2 4 IMMED LOA B #Imm C6 Imm 2 2 DIRECT LOA B M 06 M 2 3 EXTND LOA B M F6 MH ML 3 4 INDEX LOA B Disp,X E6 Disp 2 4 ~HITACHI 81 Doubl~ LoaD accumulator A:B / LDD Category Function Load & store ACeD - (M:M+l) Loads the 2-byte contents of memories M and M+l into ACCD. Effects on the condition codes H : Not affected. I : Not affected. N = R1S: Set i f the result's MSB is "1"; cleared otherwise. Z = R1S·R14·R13 .......... RO: Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles -- Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMr-1ED LDD Umm CC ImmH ImmL 3 3 DIRECT LDD M DC M 2 4 EXTND LDD M FC MH HL 3 5 INDEX LDD Disp,X EC Disp 2 5 ~HITACHI 82 LoaD Stack pointer / LOS category Function Stack SPH -- (M) I pointer SPL (M+l) control Loads the contents of memory M into the upper byte of the SP. Then, loads the contents of memory M+l (which results when memory address M is incremented by one) into the Lower byte of the SP. , Effects on the condition codes H : Not affected. I : Not affected. N = RH7: Set. i f the MSB of the SP is "111; cleared otherwise. Z = (RH7'RH6'RHS'RH4'RH3'RH2'RH1'RHO)' (RL7'RL6'RLS'RL4'RL3'RL2' RLl.RLO) : Set i f the SP contents is zero after the load; cleared otherwise. V = 0: cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of cycles mode Mnemonic format 1st 2nd 3rd instr. byte byte byte code IMMEO LOS ItImm BE ImmH ImmL 3 3 DIRECT LOS M 9E M 2 4 EXTNO LOS M BE MH ML 3 5 INDEX LOS Oisp,X AE Oisp 2 5 ~HITACHI 83 LoaD indeX register / LDX Category Function Ind"ex IXH - (M) register control IXL - (M+l) Loads the contents of memory M into the upper byte of the IX. Then, loads the contents of memory M+I into the lower byte of the IX. Effects on the condition codes H : Not affected. I : Not affected. N = RH7: Set i f the MSB of the IX is "I"; cleared otherwise. Z = (RH7·RH6.RHS·RH4·RH3·RH2·RHI·RHO)· (RL7·RL6·RLS·RL4·RL3·RL2· RLI·RLO) : Set if the IX contents is zero after the load; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles I Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMMED LDX Umm CE ImmH ImmL 3 3 DIRECT LDX M DE M 2 4 EXTND LDX M FE MH ML 3 5 INDEX LDX Disp,X EE Disp 2 5 - ~HITACHI 84 Logical Shift Right / LSR Category Function Shift & I rotation r:I 0-\ I I I I I I I I i I i ila I-~ bT Shifts the contents of ACCX or memory M by one bit to the right. Bit 7 takes O. The bit C is loaded from the LSB of ~CCX or memory M. Effects on the condition codes H : Not affected. I : Not affected. N = 0: Cleared. Z = R15'R14'R13 .... RO; Set if the result is zero; cleared otherwise. V = NEIIC: Set if either N=l and C=O or N=O and C=l; cleared otherwise. Note: The N and Care those obtained after operation. C = ABO: Set if the LSB of ACCX or M is a 1 before the instruction is executed; cleared otherwise. Addressing modes and CPU cycles 'Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX LSR A 44 1 1 ACCX LSR B 54 1 1 EXTND LSR M 74 MH ML 3 6 INDEX LSR Disp,X 64 Disp 2 6 ~HITACHI 85 Logical Double Shift Right A:B / LSRD category Function Shift & rotation 0-1 I I i I I I I I I I I I I I I 1-0 b.. bo Shifts the contents of ACCD by one bit to the right. Bit 15 takes O. The bit C is loaded from the LSB of the AceD. Effects on the condition codes H : Not affected. I : Not affected. N = 0: Cleared. -- ---- Z = R15· R14. R13 ...... M; : Set i f the result is zero; cleared otherwise. V = N61C: Set i f either N=l and C=O or N=O and C=l; cleared otherwise. Note: The N and C are those obtained after operation. C = ABO: Set i f the LSB of ACCD is "I" before the instruction is executed; cleared otherwise. -- Addressing modes and CPU cycles ------- Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL LSRD 04 1 1 ~HITACHI 86 MULtiply unsigned / MUL Category Function - (ACCA) * (ACCB) I Arithmetic ACCD operation Multiplies the contents of ACCA by those of ACCB, I and stores the resulting unsigned 16 bits into ACCD. The highest-order byte of the result is stored into the ACCA. I Effects on the condition codes H : Not affected. I : " N : " n Z : V : " C = R7: Set if the result's bit 7 is 11111; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL MUL 3D 1 7 ~HITACHI 87 NEGate / NEG Category Function Arithmetic ACCX - -(ACCX) = OO-(ACCX) or operation M - -(M) = OO-(M) Takes two's complement of the contents of ACCX or memory M, and stores the result into ACCX or memory M. No change is caused if the contents of ACCX or memory M is $80(-128). Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "1"; cleared otherwise. Z = R1·Rb·R3"·R4·R3·R2·RT·RO: Set i f the result is zero; cleared otherwise. V = R7·R6·R3"·R4·R3·R2·R[·RO: Set i f the result overflows; cleared otherwise. The bit is set only when the contents of ACCX or M is $80. C = R79R69RS9R49R39R29R19RQ: Set if a borrow is generated cleared otherwise. The bit is set only when the contents of ACCX or M is not zero. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX NEG A 40 1 1 ACCX NEG B 5.0 1 1 EXTND NEG M 70 MH ML 3 6 INDEX NEG Disp,X 60 Disp 2 6 ~HITACHI 88 No OPeration ! NOP Category Function -~---- I Uncondi- Updates the program counter only and has no effect tional branch & on other registers. jump I Effects on the condition codes H : Not affected. II I : II N : II Z : II V : II C : Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of GfY mode l-1nemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL NOP 01 1 1 -- -- ~HITACHI 89 Or IMmediate / OIM Category Function Logical operation M - 1M 0 (M) Ors the immediate data and the contents of memory M, and stores the result into the memory M. Effects on the condition codes H : Not affected. I : Not affected. N = R7" Set i f the result's MSB is Ill"; cleared otherwise. Z = R7·R6·R5·R4·R3·~·fl·RO: Set i f the result is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code DIRECT OIM #Imm,M 72 Imm M 3 6 INDEX OIM #Imm,Disp,X 62 Imm Disp 3 7 "- -- -- ~HITACHI 90 inclusive OR / ORA Category Function Logical ACCX - (ACCX) 0 (M) I operation Performs logical OR between the contents of ACCX and the contents of memory M, and stores the result into the ACCX, Effects on the condition codes H : Not affected, I : Not affected, N = R7: Set i f the result's MSB is 11111; cleared if not, Z = R7'R6'RS'R4'R3'R2'Rl'RO: Set i f all the bits of the result are zero's; cleared otherwise, V = 0: Cleared, C : Not affected. Addressing modes and CPU cycles -- Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st. 2nd 3rd instr, cycles byte byte byte code ~ IMl4ED ORA A #Imm SA Imm 2 2 DIRECT ORA A M 9A M 2 3 EXTND ORA A M BA MH ML 3 4 INDEX ORA A Disp,X AA Disp 2 4 IMMED ORA B #Imm CA Imm 2 2 DIRECT ORA B M DA M 2 3 EXTND ORA B M FA MH ML 3 4 INDEX ORA B Disp,X EA I Disp 2 4 ~HITACH8 91 PuSH data onto stack / PSH Category Function Transfer f (ACCX) SP - (SP) - 0001 Pushes the contents of ACCX onto the stack indicated by the SP. The SP is decremented by one. Effects on the condition codes H : Not affected. I : " N : . Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX PSH A 36 1 4 ACCX PSH B 37 1 4 i ~HITACHI 92 PuSH indeX register onto stack / PSHX Category Function - Transfer l (IXL) , SP - (SP) - 0001 I (IXH), SP - (SP) - 0001 PU$hes the contents of the IX onto the stack indicated by the SP. The SP is decremented by two. I I Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of f;JlU mode· Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL PSHX 3C 1 5 ~HITACHI 93 PULl data from stack / PUL Category Function Transfer SP t - ACCX (SP) + 0001 Increments the SP by one, and pulls ACCX from the stack. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte; byte code ACCX PUL A 32 I 1 3 ACCX PUL B 33 1 3 - 1 -- - ~HITACHI 94 PULl indeX register from stack / PULX Category Function - I Transfer SP (SP) + 0001 ; t IXH SP - (SP) + 0001 ; t IXL Increments the SP by one, and pulls the IX from the stack. The SP is incremented by two in total. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressirig modes and CPU cycles Instruction code Bytes Addressing 9..~g Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL PULX 38 1 4 ~HITACHI 95 ROtate Left / ROL Category Function Shift & ! • rotation 0-1 I I I I, I I I 1-0 b7 b. Shifts the contents of ACCX or memory M by one bit to the left. The original value of bit C is moved into bO, and the original value bit b7 to the bit C. Effects on the condition codes H : Not affected. I : Not affected. N : R7: Set if the MSB of the result is "111; cleared otherwise. Z = R7·R6·RS·R4·R3·R2·Rl·RO: Set if all bits of the result are zero's; cleared otherwise. V = N6lC: Set if either N=l and C=O or N=O and C=l after the instruction is executed; cleared otherwise. Note: The N anc Care those obtained after operation. C = M7: Set if the MSB of ACCX or M is "1" before the instruction is executed; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of , CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX ROL A 49 _. 1 1 ACCX ROL B 59 1 1 - EXTND ROL M 79 l-m ML 3 6 INDEX ROL Disp,X 69 Disp 2 6 I ~HITACHI 96 ROtate Right / ROR Category Function Shift & p rotation @]-I i I I I I I I I-@] b. bo Shifts the contents of ACCX or memory M by one bit to the right. The original value of bit C is moved into bit 7 and the original value bit 0 to the bit C. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the MSB of the result is "1"; cleared otherwise. Z = R1. g.Rs-.R'4. R!·iU·Rl·RO: Set if the result is zero; cleared otherwise. V = NIIIC: Set if either N=l and c=o or N=O and C=l after the instruction is executed; cleared otherwise. Note: The N and C are those obtained after operation. C = MO: Set if the LSB of ACCX or M is "1" before the instruction is executed; cleared otherwise. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code ACCX ROR A 46 1 1 ACCX ROR B 56 1 1 EXTND ROR M 76 MH ML 3 6 INDEX ROR Disp,X 66 Disp 2 6 ~HITACHI 97 ReTurn from Interrupt I RTI Category Function Interrupt control SP SP -- (SP) + 0001, fCC (SP) + 0001, t ACCB -- SP (SP) + 0001, f ACCA SP (SP) + 0001, t IXH SP SP -- (SP) + 0001, f IXL (SP) + 0001, t PCH SP - (SP) + 0001, I PCL Pulls the CCR, ACCB, ACCA, IXH, IXL, PCH and from the stack sequentially with incrementing SP by one at a time. Note that I=O results if the interrupt mask bit I of CCR having been saved in the stack is zero. Effects on the condition codes H : Set or cleared according to the bit pulled from the stack. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL RTI 3B 1 10 -- -- ~HITACHI 98 ReTurn from Subroutine / RTS Category Function SP - (SP) + 0001 I Subroutine control , PCH SP t - PCL (SP) + 0001 Increments the SP by one and pulls the upper byte of the PC from the stack. Again increments the SP by one, and pulls the lower byte of the SP from the stack. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL RTS 39 1 5 - $ HITACHI 99 SuBtract Accumulators / SBA Category Function Arithmetic operation ACCA - (ACCA) - (ACCB) Subtracts the contents of ACCB from those of ACCA, and stores the result into the ACCA. The contents of the ACCB remain unchanged. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "I"; cleared otherwise. Z = R7·R6·R5·R4·R3·~·~·RO: Set i f the result is zero~ cleared otherwise. V = A7 ·Bi·R10A1· B7· R7: Set i f the result overflows: cleared otherwise. C = A7·B70B7·R70R7·A1: Set i f the absolute value of ACCB is greater than that of ACCA: cleared otherwise. Addressing modes and CPU cycles _._- Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL SBA 10 1 1 - ~HITACHI 100 SuBtract with Carry / SBC Category Function - - (M) - (C) I Arithmetic ACCX (ACCX) operation Subtracts the contents of memory M and the contents of bit C from those of ACCX, and stores the result into the ACCX. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is IIl"i cleared otherwise. Z = R'j.R'00goRi·R3oR2·Rl·RO: Set i f the result is zero; cleared otherwise. V = X7·M7·R76X7oM7oR7: Set i f the result overflows; cleared otherwise ° . C = X7·M76M7·R70R7·Xi: Set i f the absolute value of M contents plus e is greater than that of Aeex contents; cleared otherwise. Addressing modes and epu cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 3rd instr. cycles 2nd byte byte byte code IMMED SBe A ltImm 82 Imm 2 2 DIRECT SBe A M 92 M 2 3 EXTND SBC A M B2 MH ML 3 4 INDEX SBe A Disp,X A2 Disp 2 4 IMMED SBe B Umm e2 Imm 2 ;2 DIRECT SBe B M D2 M 2 3 EXTND SBe B M F2 MH ML 3 4 INDEX SBe B Disp,X E2 Disp 2 4 ~HITACHI 101 SEt Carry / SEC Category Function Bit control Bit C - 1 Sets the carry bit C of the CCR. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C=l : Set Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL SEC 00 1 1 ~HITACHI 102 SEt Interrupt mask I SEI Category Function .... . - ---- ---.------ - ---------_. __._----- - I Bit Bit I 1 control Sets the interrupt mask bit of the CCR. When the I bit is set, all maskable interrupts are inhibited. and the MPU will recognize only a Non- Maskable Interrupt (NMI) request. Effects on the condition codes H : Not affected. I=l : Set N : Not affected. Z : . V : . C : . Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL SEI OF 1 1 ~HITACHI 103 SEt two's complement oVerflow bit / SEV Category Function Bit control Bit V - 1 Sets the overflow bit V of the CCR. Effects on the condition codes H : Not affected. I : " II N : Z : " V=l : Set C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code f---- IMPL SEV OB 1 1 --- 1------ ------- -- ------_. - --- . - i -- - - r-- ~HITACHI 104 SLeeP / SLP Category Function Low power Brings the CPU to a halt. All the internal register I dissipatior: states are held as they are. mode The timer, serial communication interface and interrupt control are not affected by this instruction. I f a CPU inter- rupt request occurs, the SLEEP mode is released. After releasing, following instructions are executed when bit I has been set by a maskable interrupt. When bit I has not been set by either maskable or non-maskable interrupt, the MCU sets bit I and loads the interrupt vectoring address into the program counter to start execution. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL SLP lA 1 4 --- '-------- ' - - - - - ----- 1---- ~HITACHI 105 STore Accumulator / STA Category Function ---_._---------_._--- Load & store M - (ACCX) Stores the contents of ACCX into the memory M. The contents of the ACCX remains unchanged. Effects on the condition codes H : Not affected. I : Not affected. N = X7: Set i f the MSB of ACCX is "1"; cleared otherwise. Z = X7·X6·XS·X4·X3·X2·Xl·XO: Set i f the contents of ACCX is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code I-----------t--- DIRECT STA A M 97 M 2 3 -- - - - --_.._--- EXTND . STA A M B7 MH ML 3 4 .------ -_.- -- ----,. - .. -- "-_ .._- . -------.-- - INDEX STA A Disp,X A7 Disp 2 4 _._------- DIRECT STA B M D7 M 2 3 --f-- EXTND STA B M F7 MH ML 3 4 --'-- -- r---- -- INDEX STA B Disp,X E7 Disp 2 4 1------ ~HITACHI 106 Double STore accwnulator A:B / STD category Function .. --,-------_._- .._ ...... __ ._--- - I Load & M:M+l (ACCD) store Stores the contents of ACCD into the memories M and M+l. The contents of the ACCD remains unchanged. Effects on the condition codes H : Not affected. I : Not affected. N = AB15: Set if the MSB of ACCD is "111; cleared otherwise. Z = ABlS·ABl4 ·AB13· ....... ·ABO: Set i f the contents of ACCD is zero; cleared otherwise. V = 0: Cleared. C = Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code 1----- DIRECT STD M DD M 2 4 EXTND STD M ML 3 5 ---_._._.._- INDEX STD Disp,X -- -- ED FD I-MB--- Disp 1--- 2 5 $HITACHI 107 STore Stack pointer / STS Category Function "-----_... _-_.._._---- --_._._--_. __... _----_._--------_._------ Stack pointer control M M+1 -- (SPH) (SPL) Stores the upper byte of the SP into the memory M, and then the lower byte of the SP into the memory M+1_ Effects on the condition codes H : Not affected_ I : Not affected_ N = SPH7: Set i f the MSB of the stack pointer is "1" ;' cleared otherwise_ Z = (SPH7-SPH6-SPHS-SPH4-SPH3-SPH2-SPH1-SPH0)- (SPL7-SPL6-SPLS. SPL4-SPL3·SPL2·SPL1-SPLO) : Set i f the contents of the stack pointer is zero; cleared otherwise. V = 0: Cleared_ C : Not affected. Addressing modes and CPU cycles ._------, Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr_ cycles byte byte byte code 1--. DIRECT STS M 9F M 2 4 EXTND STS M BF MH ...... _._._- 3 ML 5 ---_._---"---- - - - - --_._-- t-- ..---- INDEX STS Disp,X AF Disp 2 5 - ~HITACHI 108 STore indeX register / STX Category Function -- .._--_._---_._--.------ - I Index M (IXH) register control M+l - (IXL) Stores the upper byte of the IX into the memory M, then the lower byte of the IX into the memory M+l. Effects on the condition codes H : Not affected. I : Not affected. N = IXH7: Set if the MSB of the index register is 11111; cleared otherwise. Z = (IXH7·IXH6·IXHS·IXH4·IXH3·IXH2·IXH1·IXH0)· (IXL7·IXL6·IXLS· IXL4·IXL3·IXL2·IXL1·IXLO): Set i f the contents of the index register is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycleS byte byte byte code I--- DIRECT STX M DF M 2 4 EXTND INDEX STX STX .----. M __ FF MH ML 3 ._---- ---.--..... ... _---- - ..-.- .--.. - ---.-.- Disp,X EF Disp 2 5 5 '----_. .---.---- .- . .. ~HITACHI 109 SUBtract / SUB Category Function -----_.------------_.__.. Arithmetic operation ACCX - (ACCX) - eM) Subtracts the contents of memory M from those of ACCX, and stores the result into the ACCX. Effects on the condition codes H : Not affected. I : Not affected_ N = R7: Set i f the result's MSB is "1"; cleared otherwise_ Z = R7·M-~-R4-R3-R2-Rl·RO: Set i f the result's contents is zero; cleared otherwise_ V = X7-M7-R70X7-M7-R7: Set i f the result overflows; cleared otherwise_ C = X7-M70M7-R70R7-X7: Set i f the absolute value of memory contents is greater than that of ACCX contents: cleared otherwise. Addressing modes and CPU cycles Addressing mode 1----- ;Eerand Mnemonic fo:~a~ Instruction code 1st byte 2nd byte 3rd byte Bytes of instr. code CPU cycles 2 2 IMMED SUB A ltImm -- - -80 Imm - - . - -------- - DIRECT SUB A M 90 M 2 3 -----_._- . __ .,- ------ .----_ ...... ------ - -----. ----_._- EXTND SUB A M BO HH ML 3 4 -- f--- --.!NDEX SUB A Disp,X AD : Disp 2 4 -- IMMED SUB B M Umm ~-~~ 2 2 2 3 DIRECT SUB B D°ti 4 SUB B M ML 3 EXTND ---_.- _~O_ ~H INDEX SUB B Disp,X EO ID~sp 2 4 ~HITACHI 110 Double SUBtract without carry / SUBD Category Function _._--_._-,._----------- Aritlunetic ACCD - (ACCD) - (M:M+1) I operation Subtracts the contents of memories M: M+l from the contents of ACCD, and stores the result into the ACCD. Effects on the condition codes H : Not affected. I : Not affected. N = RlS: Set i f the Result's MSB is 11111; cleared otherwise. Z = R1S·R14·ID· .......... • RO: Set i f the result's contents is zero; cleared otherwise. V = DlS·MlS·R1S·D1S-M1S·R1S: Set i f the result overflows; cleared otherwise. C = D1S-M1S·M1S-R1S·R1S-D1S: Set if the absolute value of memory contents is greater than that of ACCD contents; cleared otherwise_ A~dressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code -_._------ IMMED SUBD #Inun 83 InunH ImmL 3 3 - DIRECT SUBD M 93 ._- M 2 4 -- ---------.. ---- ._---- EXTND SUBD M B3 MH ML 3 5 INDEX SUBD Disp,X A3 Disp 2 5 - ~HITACHI 111 SoftWare Interrupt / SWI category Function .. ----.--------.----~--.------.- -- .. Interrupt PC - (PC) + 0001 Increments PC by one and pushes control I (PCL) , SP - (SP)-OOOI it onto the stack in the order t (PCH) , SP t (IXL) , SP -- (SP)-OOOI (SP)-OOOI of PCL, PCH, IXL, IXH, ACCA, ACCB and CCR. The stack pointer SP is decremented by 1 after each byte of data is stored on t (IXH) , S P - (SP)-OOOI the stack. Concerning CCR, t(ACCA),SP t(ACCB),SP -- (SP) -0001 (SP) -0001 transfers bit 0 through bit 5 as they are and bits b6 and b7 - as being set. Then sets the interrupt mask bit I, and loads J(CC),SP (SP)-OOOI the contents of the memory highest-order address minus 5 -- ($FFFA) and those minus 4 ($FFFB) into the PC. I 1 - 0005) - PCH (Highest-order address PCL (Highest-order address - 0004) Effects on the condition codes H : Not affected. I=l : Set N : Not affected. Z : " V : " C : " ---- Addressing modes and CPU cycles ------- Addressing I Operand Instruction code Bytes of CPU cycles mode Mnemonic format 1st 2nd 3rd instr. byte byte byte code r------ -------1 - - - - - - - - - - - - IMPL SWI 3F 1 12 ~------- - - - - - - - - - - - - - - - - - - - - - - - - ----- _.-.--- f----- - f - - - - - - - - - - - - - - ---- --._.-_., --. ..... --- ---- --- ------ --- . ---,-- -- ... "', .. --_._- -- ------------------- - - - - - - - - - - ------- f--- ---. ---=r-- 1 - - - - - - - - - - - - ----------..- - - - - - - . - - - - - ------- - - - ------- --- ---- ------ - - -1 - - - - - - - - - - - - - - - - - - -.-.-- f------ - - . - - - - - - r- ~HITACHI 112 Transfer from accumulator A to accumulator B / TAB Category Function Transfer ACCB - (ACCA) Transfers the contents of ACCA into ACCB. The contents of the ACCA remains unchanged. Effects on the condition codes H : Not affected. I : Not affected. \ N = R7: Set i f the MSB of ACCA is "1"; cleared otherwise. Z = R7·R6·R5·M·RJ·~·m·M: Set i f the contents of ACCA is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles .. Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL .TAB 16 •..- ----_. 1 1 ------.. ----- ..--- .-----..--- ..- ..----. .- ..----- --. - =4----= ~HITACHI 113 Transfer fran aceurW.ator A to Processor condition codes register / TAP Category Function .- ---- --.---- -------" ..... ---_. __ ._-_._--- Transfer CC - 7 6 5 4 3 2 1 0 (ACCA) I I I I I I I I I ACCA t t \ t , \ IHIIINlzlvlcl cc E Carry- Borrow Over flow Zero Negati ve Interrupt Mask Half Carry Transfers bits 0 through 5 of ACCA to the corre- sponding bits of the CCR. The contents of the ACCA remains unchanged. Effects on the condition codes H : Bit 5 of ACCA I : Bit 4 of ACCA N : Bit 3 of ACCA Z : Bit 2 of ACCA V : Bit 1 of ACCA C : Bit 0 of ACCA ---.-------- Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code - - - - - - - f----.---- .--- ..- - ..------ IMPL TAP 06 1 1 - - - - _ ... ---_ .. -----_ .._---- - ----- - - - - --.------ - _ . . _ . _ - - ._-_... _--......... -... -- ._-_._- .. --.-- --_._- -- 1--'-'--' ---------- - - - - - - - - - _ . _ - ----,_._- - - - -I--' -_._--------_... - ----- - - - - . - - - ----- ..-- ..- -. - . - - .-.------ ..-.--.--.--.. - - - - - . ~HITACHI 114 Transfer from accumulator B to accumulator A L TBA Category Function _.. _-_._-------------_... _-_ ... Transfer ACCA - (ACCB) Transfers the contents of ACCB into ACCA. The contents of the ACCB remains unchanged. I I Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the MSB of ACCB is 111"; cleared otherwise. Z = ~·R6·e·M·~·~·n·RO: Set i f the contents of ACCB is zero; cleared otherwise. V = 0: Cleared. C : Not affected. Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code 1---- IMPL TBA 17 1 1 f---- -_ "- -- - - - .. '----- - - - ---- ---- , -- ~HITACHI 115 Test ~Mmediate / TIM Category Function Logical IM ·(M) operation ANDs the immediate data and the contents of memory M to change the condition codes. The contents of the CCR can be referenced by the following branch instruction. Both operands remain unchanged. Effects on the condition codes H : Not affected. I : Not affected. N = R7: Set i f the result's MSB is "1"; cleared otherwise. Z = R1·~·B·R4·R3·R2·Rl·RO: Set i f the result is zero~ cleared otherwise. V = Cleared. C : Not affected. \ Addressing modes and CPU cycles Instruction code Bytes Addressing Operand· of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code -. DIRECT TIM #Imm,M 7B Imm M 3 4 INDEX TIM #Imm,Disp,X 6B Imm Disp -_._- 3 5 - ._....- ... _---- f----- ------ ,....---- - -- I ~HITACHI 116 Transfer fran Processor condition codes register to accunrulator A / TPA Category Function Transfer ACCA - (CC) 1 1 7 6 5 4 3 2 1 0 ~I I ! ! I ; ~ l§cmy. "". t I f 1 If. IH!IIN!Z!v!ci I I ' II I ACCA cc Overflow I I I Zero Negati ve I Interrupt Mask Half Carry Transfers bits 0 through 5 of the CCR to the corre- sponding bits of ACCA. The contents of CCR remains unchanged. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL TPA 07 1 1 ------ - - - ----- - ~HITACHI 117 TeST / TST category Function - Comparison & test (ACCA) - 00 (M) - 00 Sets bits Nand Z of the CCR according to the contents of ACCX or memory M. Effects on the condition codes H : Not affected. I : Not affected. N : M7: Set if the MSB of ACCX or M is "l"; cleared otherwise. Z = Wf·M"b·M5"·M4 ·M3 ·M2 ·Ml·MO: Set i f the contents of ACCX or M is zero; cleared otherwise. V = 0: Cleared. C = 0: Cleared. Addressing modes and CPU cycles Instruction code Bytes CPU Addressing Operand of mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code -- c----- ACCX TST A 4D 1 1 ---- 1------ ----- ACCX TST B 5D 1 1 -- -,----- r------ --_ .._._----_. EXTND TST M 7D MH ML 3 4 INDEX TST Disp,X 6D Disp 2 4 ~HITACHI 118 Transfer from Stack pointer to indeX register / TSX .Category Function Transfer IX - (SP) + 0001 Increments the contents of the SP by one, and loads it into the IX. The contents of the SP remain unchanged. 1 Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " 1----------- Addressing modes and CPU cycles Addressing I Operand Instruction code Bytes of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code 1--------_. --.--. --- ---+-- IMPL TSX 30 1 1 i--------------- ----,-------- ----- ~- .. --- .. - ----- r--.--------------- r----- ---._-. -_ ..... _- _._._--. -- -- - -- -----_ .._--- ------ - ----- --c---- - - -------- _. ~HITACHI 119 Transfer from indeX register to Stack pointer / TXS Categ'ory Function ._._-_.--------- Transfer SP - (I}{) - 0001 Decrements the contents of the IX by one, and loads i t into the SP. The contents of the IX remain unchanged. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code I 1--- - IMPL TXS 35 1 1 --- - - - - ----- -- ---.. ----- "'"--"- ---------- --------- ------- -_.__ ._-" - -- ------- ~HITACHI 120 WAit for Interrupt / WAI category Function Interrupt - - --r-------------- - - - ------------ PC (PC) + 0001 Increments PC by one and pushes I control it onto the stack in the order I (PCL) ,SP (SP)-OOOI of PCL, PCH, IXL, IXH, ACCA, I (PCH) , SP -(SP)-OOOI ACCB and CCR. I (IXL),SP -(SP)-OOOI The SP is decremented by I (IXH) , SP -(SP)-OOOI 1 after each byte of data is pushed onto the stack. I (ACCA) ,SP -(SP)-OOOI Concerning CCR, transfers bits 0 I (ACCB) , SP t (CC) ,SP - -(SP)-OOOI (SP)-OOOI through 5 as they are and bits 6 and 7 as being set. The program execution stops temporarily until interrupt from a peripheral device occurs. I f bit I is a 0 before an interrupt occurs, the following processings takes place when the interrupt has occurred. That is: sets bit I; and loads the interrupt vectoring address to the PC. Effects on the condition codes H : Not affected. I : Not affected until an interrupt occurs and set i f bit I is a 0 when the interrupt has occurred. N : Not affected. Z : " V : " C : " Addressing modes and CPU cycles Instruction code Bytes Addrming mode I Mnemonic Operand format 1st 2nd 3rd of instr. CPU cycles byte byte byte code r------ IMPL WAI 3E 1 9 -.--- ---- - - - - f----- r---- - - - - - - - - - -- - - - - -1-------- f------ -_.- - - ~HITACHI 121 eXchanGe accD and iX / XGDX Category Function - Exchange IX - ACCD Exchanges the contetns of IX with those of ACCD. Effects on the condition codes H : Not affected. I : " N : " Z : " V : " C : " Addressing modes and CPU cycles Instruction· code Bytes Addressing Operand of CPU mode Mnemonic format 1st 2nd 3rd instr. cycles byte byte byte code IMPL XGDX 18 1 2 -.- r---- 1----- ---.~* ------- - -- ~HITACHI 122 HD6301/HD6303 SERIES HANDBOOK Section Three HD6301Vl/HD6303R User's Manual ~HITACHI 123 Section 3 HD6301 V1/HD6303R User's Manual Table of Contents Page Notice on HD6301 V and HD6303R . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . 126 1. OVERViEW.................................................... 128 1.1 Features of HD6301V1 ........................................ 128 1.2· Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 1.3 Functional Pin Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 2. INTERNAL ARCHITECTURE AND OPERATIONS. . . . . . . . . . . . . . . . . . . . . . 130 2.1 Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 2.2 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 2.3 Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 2.4 1/0 Ports. . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 2.5 Programmable Timer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 2.6 Serial Communication Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 2.7 Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 2.8 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 2.9 Oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 2.10 Strobe ,Signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 2.11 RAM Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 2.12 Low Power Consumption Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 2.13 TRAP Function .:.......... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 3. INSTRUCTIONS................................................ 168 3.1 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 3.2 Instruction Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 3.3 Instruction Execution Cycles ....... '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 3.4 System Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 4. PIN ARRANGEMENT AND PACKAGE INFORMATION.................. 183 ~HITACHI 124 5. ELECTRICAL CHARACTERISTICS ................................ . 186 6. APPLICATIONS ................................................ . 191 6.1 Use of External Expanded Mode ............................... . 191 6.2 Standby Mode .............................................. . 195 6.3 Address Trap, OP-Code Trap Application ......................... . 198 6.4 Slow Memory Interface ....................................... . 199 6.5 6.6 6.7 7. Interface to HN61256 ......................................... . Interface to the Realtime Clock (HD146818) ....................... . Reference Data of Battery Service Life ................ ; ......... . PRECAUTIONS ................................................ . 200 205 208 209 I 7.1 Write-Only Register .......................................... . 209 7.2 Address Strobe (AS) ......................................... . 209 7.3 Mode o.................................................... . 209 7.4 Trap Interrupt ............................................... . 209 7.5 Power-on Reset ............................................. . 211 7.6 Precaution to the Board Design of Oscillation Circuit ............... . 211 7.7 Application Note for High Speed System Design Using the HD6301V1 .. 212 APPENDIX I. EPROM on Package HD63P01 M1 218 II. Program Development Procedure and Support System. . . . . . . . . . . . .. 226 III. Q & A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 233 ~HITACHI 125 "Notice on HD630iVi" The HD6301VO (including A and B version) was upgraded to the HD6301Vl series in early 1983. The spec. deviation between the HD6301VO series and the HD6301Vl series is as follows. Please refer to the data sheet for detailed spec. of the HD6301Vl series. Table. Spec. Deviation between the HD6301VO and the HD6301Vl Items HD6301VO HD6301Vl Mode 2 : Not defined Mode 2 ; Expanded Multi- Operating Mode plexed Mode (equivalent to Mode 4) Mode 3 : Not defined Mode 3 ; Not defined The electrical cha- The 2MHz version is racteristics of guaranteed. Electrical Characteristics 2MHz version (B version) are not specified. Timer Has problem in output Fixed compare function. (Can be avoided by software.) ~HITACHI 126 HD6303Rl HD6301Vl HD6303R GND Noise HD63P01Ml R!W~~_ _ _ _ _~r ==:x Ai Di -C==)~_--J>- A Noise If load capacitance in each data x::: Noise is reduced by 33%. I line and GND impedance are large, noise may appear on address bus during MCU write cycle and data won't be written into RAM correctly. The noise is caused by GND impedance which becomes large when large transient current flows into GND at High to Low transition of data line. HD 6301Vl HD6303R HD6303Rl HD63P01Ml When framing error occurs, Receive data is receive data is not transferred fram transferred from the Receive Shift SCI Receive Shift Register to Register to RDR Receive Data Register (RDR) • even if framing error occurs. I RDR I I). P 23 - \ Receive Shift Register I "Notice on HD6303R" The HD6303R is the same die as the HD6301Vl. The on-chip Mask ROM is disabled by mask option; Therefore not all modes of operation are available on the HD6303R. Please note that wherever HD6301Vl is referenced, the information also applies to the HD6303R. "Notice on HD6303Rl" The HD6303R has been upgraded to HD6303Rl. Refer to the following figures for differences between the devices. All other characteristics remain the same. ~HITACHD 127 1. OVERVIEW 1.1 Features of HD6301Vl The HD6301Vl provides the following features: - Expanded instruction set of the HD6801 family - Abundant on-chip functions compatible with the HD6801 family: 4k-byte of ROM, 128-byte of RAM, 29 parallel I/O Lines, 2 data strobe Lines, 16-bit timer, serial communication interface - Low power consumption mode: sleep/standby mode - Minimum instruction execution time: l~s (f = IMHz), 0.67~s (f=1.5MHz), 0.5~s (f=2MHz) - Bit manipulation and bit test instruction - Error detection: Address trap and operation code trap - Address space up to 65k words - Wide operation range: Vee = 3 to 6V (f 0.1 'V O. 5MHz) , f = 0.1 to 2.0MHz (Vee = 5V ± 10%) - TTL compatible input/output 1.2 Block Diagram A block diagram of HD6301Vl is given in Fig. 1-2-1 Fig. 1-2-1 Block Diagram of HD6301Vl ~HITACHI 128 1.3 Functional Pin Description Table 1-3-1 lists the pin functions. Refer to "2. INTERNAL ARCHITECTURE AND OPERATIONS" for more details. Table 1-3-1 Pin Functions a Pin Function VCC' VSS Power supply and GND pins XTAL Crystal connection pin. When external clock is used, input it to EXTAL EXTAL, and XTAL should be open. RES Reset input pin. When this pin is in "Law ll state, MCU is set to reset state. STBY Standby input pin. When this pin is in "Low ll state, MCU is set to standby state. NMI Nonmaskable interrupt input pin for edge detection (Negative edge) . IRQ 1 Interrupt input pin for level detection (Active Low) E System clock output pin. The frequency is 1/4 of the crystal oscillator frequency. P 2 0/TIN 5-bit I/O port Timer input-capture input pin P 2 l/TOUT Timer output-compare output pin P 22 /SCLK SCI clock I/O port P 23 /RX SCI receiving pin P 2 4/ TX SCI transmitting pin Following pins function depending on each operation mode - Mode 7 - Mode 0,2,4 Mode 1 Mode 5 Mode 6 8-bit Lower address 8-bit PORT 1 (Ao",A 7 ) I/O port I/O port Data (Do"'D7 ) - Data (D 0"'D7) PORT 3 Lower address (Ao"'A7) Mul tiplexed Bus Data Bus Do"'D7 Lower address Lower address (Ao"'A7) Multiplexed Bus Upper address - P,ORT 4 upper address (Aa"'A1S) .. (Ao"'A7) or Input-only (Aa"'Als) or Input-only 8-bit I/o port pin pin ~ Address strobe I/O strobe Address strobe I~t strobe SCI (AS) output (lOS) output (AS) output (IS3) output pin pin pin pin - - Read/write SC 2 signal (R/W) output pin - Output strobe (053) output pin ~HITACHI 129 2. INTERNAL ARCHITECTURE AND OPERATIONS This section describes the internal architecture of the HD6301Vl and its operation. 2.1 Mode Selection After the MCU is reset, a user must determine the operation mode of the HD6301Vl by strapping three pins 8, 9 and 10 which are connected by hardware externally. These pins correspond to P 20 , P 21 and P 22 respectively. Individual signals on the above three pins are latched and loaded into the program control bits PCO, PCl and PC2, the most significant three bits of I/O port 2 register, when the RES signal goes "High". The bit assignment of the port 2 data register is shown below. Port 2 Data Register $0003 7 6 5 4 3 2 1 0 Ipc2lpcllpcolI/0 41I/0 31I/0 21I/0 lII/O 01 An example of an external hardware for mode selection is shown in Fig. 2-1-1. The HD14053B may be used to separate the MCU from its peripheral devices during reset (Data confliction should be avoided between the peripheral devices and mode generator circuit). Because bits 5, 6 and 7 of port 2 are for read only, so the operation mode cannot be altered by software. The mode selection in the HD6301Vl is summarized in Table 2-1-1. The HD6301Vl has three basic operation modes: 1) Single chip mode 2) Expanded multiplexed mode (Compatible Bus with HMCS6800 peripheral LSIs) 3) Expanded non-multiplexed mode (Compatible Bus with HMCS6800 peripheral LSIs) @HITACHI 130 Truth Table Control Input On Switch Binary to 1 ·of·2 SelecI Decoder with Inh,b,' C B A HDI405JB Inhibit 0 0 0 0 Z. V. X. 0 0 0 I Z. V. X, Z. V, X. Xo - o~~1 -- 0 I 0 I I Z. V, X, X, X 0 1 0 0 Z, V. X. YO 0 1 0 1 Z, V. X, Y, Y 0 I I 0 Z, V, X. ZoO 0 1 1 1 Z, V, X, Z, Z 1 X X X - HD14053B Multiplexers/De-Multiplexers Vee ( R ~ R, R, R, 6 - RES R U 4 ABC X. V. 'X B 9 HD6301Vl p,. (PCOI ~ Z. V P" (PCII 10 p,. X, Z P" (PC2) P" V, P" Z, HD14053B Inh Note 1) Figure of Mode 7 ( C ??? Mode Jr 2) AC""Aeset Constant I Control 3) A, =10kn ~ Sw,tch Fig, 2-1-1 Recommended Circuit for Mode Selection ~HITACHI 131 Table 2-1-1 Mode Selection Summary p.. P21 p.. Interrupt Bus Operating Mode ROM RAM (PC2) (PC1) (PCO) Vectors Mode Mode 7(4) H H H I I· I I Single Chip 6(4) H H L I I I MUX3) Multiplexed/Partial Decode 5(4) H L H I I I NMUX3 ) Non·Multiplexed/Partial Decode 4 H L L E'I I E MUX Multiplexed/RAM ~ L H H - - - - Not Used 2 L H L Ell I E MUX Multiplexed/RAM 1 L L H E'I I E NMUX Non·Multiplexed 0(4) L L L I I 121 MUX Multiplexed Test LEGEND: (NOTES) I -Internal 11 Internal ROM is disabled. E - External 2) Reset vector is external for 3 or 4 cvcles after MUX - Multiplexed FjES goes "h igh". NMUX - Non-Multiplexed 3) Idle lines of Port 4 address outputs can L - Logic "0" be assigned to Input Port. H - Logic "I" 4) Not available on HD6303R or HD6303R1 (1) Single Chip Mode In the Single Chip Mode, all ports will become I/O. This is shown in figure 2-1-2. In this mode, SCI, SC2 pins are configured for control. lines of Port 3 and can be used as input strobe (IS3) and output strobe (OS3) for handshaking data. (2) Expanded Multiplexed Mode In this mode, Port 4 is configured for I/O (inputs only) or address lines. The data bus and the lower order address bus are multiplexed in Port 3 and can be separated by an output called Address Strobe. Port 2 is configured for 5 parallel I/O or Serial I/O, or Timer, or any combination thereof. Port 1 is configured for 8 parallel I/O. In this mode HD630lVI is expandable to 65k words (See Fig. 2-1~3). Since the data bus is multiplexed with the lower order address bus in Port 3 in the expanded multiplexed mode, address bits must be latched outside. 74LS373 (Octal- D type transparent latches) is required for address latch. Latch connection of the HD630lVI is shown in Fig. 2-1-4. ~HITACHI 132 Vee Enable Port 1 Port 3 8 110 Lones 8110 Lones Port 4 Port 2 8110 Lones 5110 lines SCI Timer Fig. 2-1-2 HD6301Vl MCU Single-Chip Mode Vcc Enable Port 1 8 Lines 8 I/O Lines Multiplexed Data/Address Port 2 Port 4 5 I/O Lines To 8 Address SCI Lines or To Timer 8 I/O Lines (Inputs Only) VSS Fig. 2-1-3 HD6301Vl MCU Expanded Multiplexed Mode ~Hn'TACH6 133 GND AS IM_~-', II G DC 0, D, Function Table Port 3 74LS373 Addre~s/Data l- Output Enable Output Control G 0 0 0, C, L H H H L H L L L L X 0, H X X Z 0> j "''', -. Fig. 2-1-4 Latch Connection (3) Expanded Non Multiplexed Mode In this mode, the HD6301Vl can directly address HMCS6800 peripherals with no address latch. In mode 5, Port 3 be- comes a data bus. Port 4 becomes Ao to A7 address bus or partial address bus and I/O (inputs only). Port 2 is con- figured for a parallel I/O, Serial I/O, Timer or any combination. Port 1 is configured as a parallel I/O only. In this mode, HD6301Vl is expandable to 256 locations. In the application system with fewer addresses, idle pins of Port 4 can be used as I/O lines (inputs only) (See Fig. 2-1-5) . In mode 1, Port 3 becomes a data bus and Port 1 becomes Ao to A7 address bus, and Port 4 becomes As to A15 address bus. Port 2 is configured for a parallel I/O, Serial I/O, Timer or any combination. In this mode, the HD6301Vl is expandable to 65k words with no address latch. (See Fig. 2-1-5) . ~HITACHI 134 Vee Vee Port 1 Port 3 POri 1 Port 3 B Parallel 1/0 B Data Lines To B Address Lines B Data Lines Port 2 a Port 4 Pan 2 Port 4 5 Parallel I/O To B Address 5 Parallel I/O To 8 Address SCI Lines or To SCI Lines Timer 81/0 Lines Timer (Inputs Onlv) VSS Vss (a) Mode 5 (b) Mode 1 Fig. 2-1-5 HD6301Vl MCU Expanded Non Multiplexed Mode (4) Mode and Port Summary MCU Signal Description This section gives a description of the MCU signals for the various modes. SC 1 and SC2 are signals which vary with the chip mode. Table 2-1-2 Feature of each mode and Lines PORT 1 PORT 2 PORT 3 PORT 4 MODE SC, SC, Eight Lines Five Lines Eight Lines Eight Lines SINGLE CHIP I/O I/O I/O I/O IS3 (I) I OS3(0) 1--- ADDRESS BUS (Ao-A,) ADDRESS BUS' EXPANDED MUX I/O I/O AS(O) R/W(O) DATA BUS (A.-A,,) (00-0,) DATA BUS ADDRESS BUS' EXPANDED i Mode 5 R/W(O) i I/O I/O (00-0,) (Ao-A,) ---- 10S(0) ADDRESS BUSI DATA BUS ADDRESS BUS- NON-MUX i Mode I (Ao-A,) I/O I I (00- 0,) (A.-A,,) Not Used R/WiO) *These lines can be substituted for I/O (Input Only) starting with the MSB (except Mode 0, 2, 4). When they are not used as address lines. I = Input is:! = Input Strobe SC Strobe Control o = Output 053 = Output Strobe AS Address Strobe R/iN = Read!WrOie 105 = 1/0 Select 2.2 Memory Map The MCU can address up to 65k bytes depending on the operating mode. Fig. 2-2-1 shows a memory map for each operating mode. The first 32 locations of each map are for the MCU's internal register only, as shown in Table 2-2-1. ~HITACHI 135 Table 2-2-1 Internal Register Area R/W*4/Initialize at RESET Register Address 7 6 5 4 3 2 1 0 Port 1 Data Direction Register $00*1 W $00 Port 2 Data Direction Register $01 W $00 R/W *5 Port 1 Data Register $02*1 Undefined Port 2 Data Register/Mode Register $03 R *6 R/W *5 P22 P21 P20 Undefined Port 3 Data Direction Register $04*2 W $00 Port 4 Data Direction Register $05*3 W $00 R/W *5 Port 3 Data Register $06*2 Undefined R/W *5 Port 4 Data Register $07*3 Undefined R R R R/W R/W R/W R/W R/W Timer Control and Status Register $08 a a 0 a a a a 0 R/W Counter (High Byte) $09 $00 R/W Counter (Low Byte) $OA $00 R/W Output Compare Register (High Byte) SOB $FF R/W Output Co~pare Register (Low Byte) SOC $FF R Input Capture Register (High Byte) SOD $00 R Input Capture Register (Low Byte) $OE $00 R R/W Un- used R/W R/W Unused Port 3 Control and Status Register $OF*2 a a 1 a a 1 1 1 $10 Unused W W W W Rate and Mode Control Register 1 1 1 1 a a a 0 Transmit/Receive Control and $11 R R R R/W R/W R/W R/W R/W Status Regi ster a a 1 0 a a a a Receive Data Register $12 R $00 Transmit Data Register $13 W $00 RAM Control Regi ster $14 R/W R/W Unused *7 1 1 1 1 1 1 1 ~ Reserved $l~$lF (*1 through 8 are shown in the next page.) ~HITACHI 136 *1 External address in mode 1. *2 External address in modes 0, 1, 2, 4, 5, 6; cannot be accessed in mode 5. *3 External address in modes 0, 1, 2, 4. *4 R: Read-only register, W Write-only register, R/W : Read/Write register. *5 The pin state is read instead of the data of the register when reading Ports. (Refer to "2.4 I/O Ports" for I/O Port 3.) *6 The values of program control bit (PCo ~ PC2) depend on *7 P20 ~ P21 during reset. Refer to "2.12 Low Power Consumption Mode" for standby mode. I HD6301V10 Mode HD6301V1 Mode 1 Multiplexed Test mode Non-Multiplexed ~~~~~ $0000 $OOoolt) Internal Registers Internal Registers $001 F ~ $OOlF External Memory Space External Memory Space $0080 $0080 m,'77T."", Internal RAM Internal RAM $00 F F t"''''''''"''' $OOFF External Memory Space External Memory Space $FOOO Internal ROM 12 $FFFF ' - - - - - ' INOTES] INOTE] 1) Excludes the following addresses which may be Excludes the following addresses which may be used externally: $04, $05, $06, $07 and $OF. used externally; $00, $02, $04, $05, $06, $07 2) Addresses $FFFE and $FFFF are considered and $OF, external if accessed within 3 or 4 cycles after a positive edge of RES and internal at all other times. 3) After 3 or 4 MPU cycles, there must be no overlapping of internal and external memory spaces to avoid driving the data bus with more than one device. 4) This mode is the only mode which is used for testing. (to be continued) Fig. 2-2-1 HD6301V1 Memory Maps ~HITACHI 137 HD6301V1 Mode 2 HD6301V14 Mode HD6301V15 Mode Multiplexed/RAM Non-Multiplexed/Partial Decode $0000 Internal Registers $OOlF External Memory Space S0080 ) Internal RAM Internal RAM SOOFF S0100 } External Memory Space SOlFF '-_...,...._.......1 External Memor.y Space $FOOO Internal ROM $FFFF ' -_ _ _..... , $FFFF [NOTE! Excludes the following address which [NOTE! Excludes $04, $06, $OF. may be used externally; $04, $05, $06, $07, $OF. These address cannot be used externally. (to be continued) Fig. 2-2-1 HD6301 V1 Memory Maps ~HITACHI 138 HD6301V16 HD6301V17 Mode Mode Multiplexed/Partial Decode Single Chip Internal Registers $OOOO~) Internal Registers $OOlF $001 F ~=.<¥"='" I External Memory Space Unusable $0080 $0080 """""~""".. Internal RAM $OOFF $OOFF~=~='-I E xt~rnal Memory Space $FOOO Internal ROM $FFF F [NOTE) Excludes the following address which may be used externally: $04, $06, $OF. Fig. 2-2-1 HD6301V1 Memory Maps ~HITACHI 139 2.3 Registers The followings describe the HD6301Vl internal architectures and operations. fIS----"'- --_0:U~ 0 - - - ~- - - 3 : 8·8itAccumulatonAand8 Or 16·Bi, Doubla Accumulator D 1. 5 X 01 Index Register (XI 1. 5 s. 01 Stack .Pointer (SP) 1. 5 PC 01 Program Counter (PC) 7 0 ~ Condition Code Register (eCR) Carry/Borrow from MSa Overflow Zero Negative Interrupt Half carry (From Bit 3) Fig. 2-3-1 Registers of HD6301V1 (1) Accumulators (A & B, or D) Two 8-bit registers (ACCA and ACCB) that store the/ result of arithmetic/logical operation and data. When combined, they make up a l6-bit register (ACCD) used for l6-bit operations. Note that the contents of ACCA and ACCB are destroyed after an ACCD-based operation. (2) Index Register (IX) A 16-bit register that stores either l6-bit data intended for use. in indexed addressing mode or ordinary 16-bit data. (3) Stack Pointer (SP) A l6-bit register whose contents indicate the address of a stack operation. This may be used also as a register for ordinary l6-bit data. (4) Program Counter (PC) A l6-bit register whose contents indicate the address of the program being currently executed. Note that software cannot access to this register • • HITACHI 140 (5) Condition Code Register (CCR) A register consisting of the following bits: carry (C), overflow (V), zero (Z), negative (N), interrupt mask (I), and half-carry (H). After an instruction is executed, these bits change its states depending on the result of operation and are tested by different conditional branch instructions. The upper 2 bits of this register cannot be used. Individual bits are detailed below. Refer to the following description of each instruction for more details. (a) Half-carry (H) This bit is set to "1" if a carry from bit 3 to bit 4 occurs during execution of an ADD, ABA or ADC instruction; I it is cleared if no carry takes place. (b) Interrupt mask (I) When set at "1", this bit disables any maskable inter- rupt (IRQl, IRQ2). (c) Negative (N) After an instruction is executed, this bit is set to "1" if the MSB as the result of operation is "1"; it is cleared if the MSB is "0". (d) Zero (Z) After an instruction is executed, this bit is set to "1" if the result of operation is "0"; otherwise, it is cleared. (e) Overflow (V) After an instruction is executed, this bit is set if the result of operation shows a 2's complement overflow; it is cleared if no overflow occurs. (f) Carry (C) After an instruction is executed, this bit is set to "1" if a carry or a borrow generates from MSB; it is cleared in any other case. ~HgTACHO 141 2.4 I/O Ports There are four I/O ports on HD6301Vl MCU (three 8-bit ports and one 5-bit port). 2 control pins are connected to one of the 8-bit port. Each port has an independent write-only data direction register to program individual I/O pins for input or output.* When the bit of associated Data Direction Register is "1", I/O pin is programmed for output, if "0", then programmed for an input. There are four ports; Port 1, Port 2, Port 3, and Port 4. Addresses of each port and associated Data Direction Register are shown in Table 2-4-1. * Only one exception is bit 1 of Port 2 which becomes either a data input or a timer output. It cannot be used as an output port. Table 2-4-1 Port and Data Direction Register Addresses Data Direction Ports Port Address Register Address I/O Port 1 ~0002 ~OOOO I/O Port 2 ~0003 ~OOOI I/O Port 3 ~0006 ~0004 I/O Port 4 $0007 $0005 (1) I/O Port 1 This is an 8-bit port, each bit being defined individually as inputs or outputs by associated Data Direction Register. The 8-bit output buffers have three-state capability, maintaining in high impedance state when they are used for input. In order to be read accurately, the voltage on the input lines must be more than 2.0V for logic "1" and less than 0.8V for logic "0". These are TTL compatible. After the MCU has been reset, I all I/O lines are configured as inputs in all modes except mode 1. In all modes other than expanded non multiplexed mode 1, Port 1 is always parallel I/O. In mode 1, Port 1 will be output line for lower order address lines (Ao to A7) • ~HITACHI 142 (2) I/O Port 2 This port has five lines, whose I/O direction depends on its data direction register. The 5-bit output buffers have three-state capability, going high impedance state when used as inputs. In order to be read accurately, the voltage on the input pins must be more than 2.0V for logic "1" and less than 0.8V for logic "0". After the MCU has been reset, I/O pins are configured as inputs. These pins on Port 2 (pins 10, 9, 8 of the chip) are used to program the operating mode during reset. The values of these three pins during reset are latched into the upper 3 bits (bit 7,6 and 5). Refer to "2.1 Mode Selection" for more details. In all modes, Port 2 can be configured as I/O lines. This port also provides access to the Serial I/O and the Timer. However, note that bit 1 (PZl) is the only pin restricted to data input or Timer output. (3) I/O Port 3 This is an 8-bit port which can be configured as I/O lines, a data bus, or an address bus multiplexed with data bus. Its function depends on hardware operation mode programmed by the user using 3 bits of Port 2 during Reset. Port 3 as a data bus is bi-directional. For an input from peripherals, regular TTL level must be supplied, that is greater than 2.0V for a logic "1" and less than 0.8V for a logic "0". This TTL compatible three-state buffer can drive one TTL load and 90pF capacitance. In the expanded Modes, data direction register will be inhibited after Reset and data flow will be dependent on the state of the R/W signal. Function of Port 3 for each mode is explained below. Single Chip Mode (Mode 7): Parallel Inputs/Outputs as programmed by its corresponding Data Direction Register. There are two control lines associated with this port in this mode, an input strobe (IS3) and an output strobe (053), both being used for handshaking. They are ~HITACHI 143 controlled by I/O Port 3 Control/Status Register. Additional 3 characteristics of Port 3 are summarized as follows: (1) Port 3 input data can be latched using IS3 (SCI) as a control signal. (2) OS3 (SC 2 ) can be generated by MPU read or write to Port 3's data register. (3) IRQl interrupt can be generated by an IS3 falling edge. Port 3 strobe and latch timings are shown in Figs. 5-5 and 5-6, respectively. I/O Port 3 Control/Status Register Bit 0 Not used. Bit 1 Not used. Bit 2 Not used. Bit 3 LATCH ENABLE. Bit 3 is used to control tbe input latch of Port 3. If t6e bit is set to "1", the input data on Port 3 is latched by the falling edge of IS3. The latch is cleared by the MCU read to Port 3; it can be latched again. Bit 3 is cleared by a reset. Bit 4 ass (Output Strobe Select) This bit identifies the cause of output strobe generation: a write operation or read operation to I/O Port 3. When the bit is cleared, the strobe will be generated by a read operation to Port 3. When the bit ~s not cleared, the strobe will be generated by a write operation. Bit 4 is cleared by reset. Bit 5 Not used. Bit 6 IS3 ENABLE. If the IS3 flag (bit 7) is set with bit 6 set, an interrupt ~HITACHI 144 is enabled. Clearing the flag causes the interrupt to be disabled. The bit is cleared by reset. Bit 7 IS3 FLAG. Bit 7 is a read-only bit which is set by the falling edge of IS3 (SCI)' It is cleared by a read of the Control/ Status Register followed by a read/write of I/O Port 3. The bit is cleared by reset. Expanded Non Multiplexed Mode (mode 1, 5) In this mode, Port 3 becomes the data bus. Expanded Multiplexed Mode (mode 0, 2, 4, 6) Port 3 becomes both the data bus (Do ~ 0 7 ) and lower 8 I bits of the address bus (Ao ~ A 7 ). An address strobe output is "High" when the address is on the port. (4) I/O Port 4 This is an 8-bit port that becomes either I/O or address output depending on the operation mode selected. In order to be read accurately, the voltage at the input lines must be greater than 2.0V for a logic "I", and less than 0.8V for a logic "0". For outputs, each line is TTL compatible and can drive one TTL load and 90pF capacitance. After reset, this port becomes inputs. To use these pins as addresses, they should be programmed as outputs. Function of Port 4 for each mode is explained below. Single Chip Mode (Mode 7): Parallel Inputs/Outputs as programmed by its associated data direction register. Expanded Non Multiplexed Mode (Mode 5): In this mode, Port 4 becomes the lower address lines (Ao to A7) by writing "l"s on the data direction register. When all of the eight bits are not required as addresses, the remaining lines can be used as I/O lines (Inputs only). Expanded Non Multiplexed Mode (Mode 1): In this mode, Port 4 becomes output for upper order address lines (As to Al 5) • ~HITACHI 145 Expanded Multiplexed Mode (Mode 0, 2, 4): In this mode, Port 4 becomes output for upper order address lines (As to A1S) regardless of the value of data direction register. The relation between each mode and I/O port 1 to 4 is summarized in Table 2-1-2. 2.5 Programmable Timer The HD6301Vl provides 16-bit programmable timer which can measure input waveform and generate an output waveform. The pulse width of both input/output may vary from micro- seconds to seconds. microseconds to many seconds. The timer hardware consists of an 8-bit control and status register a 16-bit free running counter a 16-bit output compare register, and a 16-bit input capture register A block diagram of the timer is shown in Figure 2-5-1. Bill PO'12 "R j--- -- OIl1;pll'Comput" Pulse - - - - _I : OuIPUt Input ~I Edge Bit 1 BilO Port2 Port2 Fig. 2-5-1 Programmable Timer Block Diagram ~HITACHI 146 (1) Free Running Counter ($0009:000A) The key timer element is a l6-bit free running counter, that is driven by an E (Enable) clock to increment its values. The counter value is readable by the MPU soft- ware at any time with no effects on the counter. The counter is cleared during reset. When writing to the upper byte ($09), the CPU writes the preset value ($FFF8) into the counter (address $09, $OA) regardless of the write data value. But when writing to the lower byte ($OA) after the upper byte writing, the CPU writes not only the lower byte data into lower 8 bit, but also the upper byte data into higher 8 bit of the FRC. The counter value written to the counter using the double store instruction is shown in Figure 2-5-2. ($5AF3 written to the counter) Fig. 2-5-2 Counter Write Timing * To write to the counter can disturb serial opera- tions, so it should be inhibited during using the SCI. (2) Output Compare Register (~OOOB:$OOOC) This is a l6-bit read/write register which is used to control an output waveform. The data of this register is constantly compared with the free running counter. When the data matches, a flag (OCF) in the timer controll status register (TCSR) is set and the current value of an output level Bit (OLVL) in the TCSR is transferred to Port 2 bit 1. When bit 1 of the Port 2 data direction register is "1" (output) the OLVL value will appear on the bit 1 of Port 2. Then, the value of Output Compare Register and Output level bit should be changed to control an output level again on the next compare values. ~HITACHI 147 The output compare register is set to $FFFF during reset. The compare function is inhibited at the cycle of writing to the upper bytes of the output compare register and at the cycle just after that. It is also inhibited in same manner at the cycle of writing to the free running counter. * For the data write to The OCR (Output Compare Register) , 2-byte transfer instructions such as STD, STX are available. (3) Input Capture Register ($OOOD:~OOOE) The input capture register is a 16-bit read-only register used to store the FRC's value obtained when the proper transition of an external input signal occurs. The input transition change required to trigger the counter transfer is controlled by the input Edge bit (IEDG) . To allow the external input signal to gate in the edge detector, the bit of the Data Direction Register corresponding to bit 0 of Port 2 must have been cleared (to zero) . To insure input capture in all cases, the width of an input pulse requires at least 2 Enable cycles. (4) Timer Control/Status Register (TCSR) ($0008) This is an 8-bit register. All 8 bits are readable and the lower 5 bits may be written. The upper 3 bits are read-only, indicating the timer status information below. (a) Defined transition of the timer input signal causes the counter to transfer its data to the ICR. (b) A match has been found between the value in the free running counter and the output compare register (OCF). (c) The counter value reached to $0000 as a result of counting-up (TOF). Each flag may contain an individual enable bit in TCSR which controls whether or not an interrupt request may be ~HITACHI 148 output to internal interrupt signal (IRQz). If the I-bit in Condition Code Register has been cleared, a priority vectored address occurs corresponding to each flag being set. Each bit is described as follows. Timer Control/Status Register 7 654 3 2 1 0 LI_IC_F~I_o_C_F~I_T_O_F-L_E_I~C_I~I_E_O_C_I-LI_E_T_O_I-L_I_E_D_G~_O_LV_L~ $0008 Bit 0 OLVL (Output Level); When a match is found in the value between the counter and the output compare register, this bit is transferred to the Port 2 bit 1. I If the DDR corresponding to Port 2 bit 1 is set to "1", the value will appear on the output pin of Port 2 bit 1. Bit 1 IEDG (Input Edge); This bit control which transition of an input of Port 2 bit 0 will trigger the data transfer from the counter to the input capture register. The DDR corresponding to Port 2 bit 0 must be cleared in advance of using this function. When IEDG = 0, trigger takes place on a falling edge ("High"-to-"Low" transition). When IEDG = 1, trigger takes place on a rising edge ("Low"-to- "High" transition). Bit 2 ETOI (Enable Timer Overflow Interrupt); When set, this bit enables TOF interrupt to generate the inter- rupt request (IRQ2) but when cleared, the interrupt is inhibited. Bit 3 EOCI (Enable Output Compare Interrupt); When set, this bit enables OCF interrupt to generate the interrupt request (IRQ2), when cleared, the interrupt is inhibited. ~HITACHI 149 Bit 4 EICI (Enable Input Capture Interrupt); When set, this bit enables ICF interrupt to generate the interrupt reguest (IRQ2) but when cleared, the inter- rupt is inhibited. Bit 5 TOF (Timer Overflow Flag); This read-only bit is set'-'when the counter value is $0000. It is cleared by CPU read of TCSR (with TOF set) followed by an CPU read of the counter ($0009). Bit 6 OCF (Output Compare Flag); This read-only bit is set when a match is found in the value between the output compare register and the counter. It is clear- ed by a read of TCSR (with OCF set) followed by an CPU write to the output compare register ($OOOB or ~OOOC) . Bit 7 ICF (Input Capture Flag); The read-only bit is,set when an input signal to edge detector makes a transi- tion as defined by IEDG, and is cleared by a read of TCSR (with ICF set) followed by an CPU read of Input Capture Register ($OOOD). Each bit of Timer Control and Status Register is cleared during reset. 2.6 Serial Communication Interface The HD6301Vl contains a full-duplex asynchronous Serial Communication Interface (SCI). SCI may select the several kinds of the data transmit rate and comprises a transmitter and a receiver which operate independently on each other but at the same data transmit rate. Both of transmitter and receiver communicate with the CPU by the data bus, and with the outside through Port 2 bit 2, 3 and 4. Descrip- tion of hardware, software register is as follows. (1) Wake-Up Function In typical multiprocessor applications the software protocol has the destination address at the initial byte of the message. The purpose of Wake-Up function is to have the non-selected MCU neglect the remainder of the message. Thus the non-selected MCU can inhibit ~HITACHI 150 the all further interrupt process until the next message begins. Wake-Up function is triggered by a ten consecutive "l"s which indicates an idle transmit line. Therefore soft- ware protocol needs an idle period between the messages. With this hardware feature, the non-selected MPU is re- enabled (or "wakes-up") for the appearing next message. (2) Programmable option The HD6301Vl has the following optional features provided for its Serial I/O. They are all programmable. data format; standard mark/space (NRZ) start bit + 8 bit data + 1 stop bit I Clock source; external or internal baud rate; one of 4 rates per given MCU E clock frequency or 1/8 of external clock wake-up function; enabled or disabled • Interrupt requests; enabled or masked individually for transmitter and receive data registers Clock Output; internal clock enabled or disabled to Port 2 bit 2 • Port 2 (bits 3,4); dedicated or not dedicated to serial I/O individually for receiver and transmitter (3) Serial Communication Hardware The serial communications hardware is controlled by 4 registers as shown in Figure 2-6-1. The registers include: an 8-bit control/status register a 4-bit rate/mode control register (write-only) an 8-bit read-only receive data register an 8-bit write-only transmit data register Besides these 4 registers, Serial I/O utilizes Port 2 bit 3 (input) and bit 4 (output). Port 2 bit 2 can be used when an option is selected for the internal-clack-out or the external-clack-in. (4) Transmit/Receive Control Status Register (TRCSR) TRCS Register consists of 8 bits which all may be read @HHTACHU 151 while only bits 0 to 4 may be written. The register is initialized to $20 on RES. The bits of the TRCS register are defined as follows. Transmit/Receive Control Status Register 76543 210 I RDRF I ORFE I TORE I RIE I RE I TIE I TE I WU I ADDR: $0011 Bit 0 WU (Wake Up); Set by software and cleared by hard- ware on receipt of ten consecutive "l"s. It should be noted that RE flag has already set in advance of WU flag's set. Bit 1 TE (Transmit Enable); Set to produce preamble of ten consecutive "l"s and to enable the data of trans- mitter to output subsequently to the Port 2 bit 4 independently of its corresponding DDR value. When cleared, serial I/O affects nothing on Port 2 bit 4. Bit 2 TIE (Transmit Interrupt Enable); When this bit is set with TORE (bit 5) set, it will permit an IRQ2 interrupt. When cleared, TORE interrupt is masked. Bit 3 RE (Receive Enable); When set, gates Port 2 bit 3 to input of receiver regardless of DDR value for this bit. When cleared, the serial I/O affects nothing on Port 2 bit 3. Bit 4 RIE (Receive Interrupt Enable); When this bit is set with bit 7 (RDRF) or a bit 6 (ORPE) set, it will permit an IRQz. When cleared, IRQ2 interrupt is masked. Bit 5 TORE (Transmit Data Register Empty); When the data transfer is made from the Transmit Data Register to Output Shift Register, it is set by hardware. The bit is cleared by reading the status register (with TORE set) and followed by writing the next new data into the Transmit Data Register. TORE is initialized to 1 by RES. Bit 6 ORFE (Over Run Framing Error); When overrun or framing error occurs (receive only), it is set by hardware. Over Run Error occurs if the attempt is made to transfer the new byte to the receive data ~HITACHI 152 register with theRDRF set. Framing Error occurs when the bit counters are not synchronized with the boundary of the byte in the bit stream. The bit is cleared by reading the status register (with ORFE set) followed by reading the receive data register, or by RES. Bit 7 RDRF (Receive Data Register Full); It is set by hardware when the data transfer is made from the receive shift register to the receive data register. It is cleared by reading the status register (with RDRF set) and followed by reading the receive data register, or by RES. Bit 7 Rate and Mode Control Register Bit 0 I I eel Ieeol 55115501$10 Transmit/Receive Control and Status Register IADAFjOAFE1TDAEl AlE I I I Iwu AE TIE TE 1$11 Receive Data Register $12 Port2 I~~ ~___ I_I____ ~_________A_ec_._ive_S~h_ift_A_.9_is_t._r______ -J Clock 10 B~t 1----------------1 I+-----E '--_-,-_....J Transmit Shift Register $13 Transmit Oats Register Fig. 2-6-1 SCI Register 6 5 4 3 1 0 x I x x I x I eel I ceo I SSl SSO AD DR $0010 Rate I Mode Control Register Table 2-6-1 SCI Bit Times and Transfer Rates XTAL 2.4576 MHz 4.0 MHz 4.9152MHz 551 550 E 614.4 kHz 1.0MHz 1.2288MHz 0 0 E.;- 16 26 1'5/38,400 8aud 16 1'5/62,500 8aud 13 1'5 I 76,8ooBaud 0 1 E.;- 128 2081'5/4,800 Baud 128 1'5/7812.58aud 104.21'5 I 9,600Baud 1 0 E.;- 1024 1.67m5/6oo Baud 1.024m5/976.6 Baud 833.31'$ I 1,200Baud 1 1 E.;- 4096 6.67m5/150 Baud 4.096m5/244.1 Baud 3.333m$ I 300Baud ~HITACHI 153 Table 2-6-2 SCI Format and Clock Source Control CC1,CCO Format Clock Source Port 2 Bit2 Port 2 Bit3 Port 2 Bit4 00 01 - NRZ - Internal - Not Used"· .... - ....- 10 11 NRZ NRZ Internal External Output· Input .. .. .. Clock output is available regardless of values for bits R E and TE . ... Bit 3 is used for serial input if RE = "1" in TReS. _._Bit 4 is used for serial output if TE = "1" in TReS. It can be used as I/O port. (5) Transmit Rate/Mode Control Register (RMCR) The register controls the following serial I/O variables: ·Baud rate ·clock source ·Port 2, bit 2 function It is 4-bit write-only register, cleared by RES. The 4 bits are considered as a pair of 2-bit fields. The lower 2 bits control the bit rate of internal clock while the upper 2 bits control the clock select logic. Bit 0 sso 1 Bit 1 SSI J Speed Select These bits select the Baud rate for the internal clock. The selectable 4 rates are function of E clock frequency within the MCU. Table 2-6-1 lists the available Baud Rates. Bit 2 cco 1 f Bit 3 CCI Clock Control/Format Select These bits control the clock select logic. Table 2-6-2 defines the bit field. (6) Internally Generated Clock When using the internal clock for the SCI externally, the followings should be noted. • The values of RE and TE have no effect. • CCl, CCO must be set to "10". • The maximum clock rate is E/16. • The clock is once the bit rate. (7) Externally Generated Clock When supplying an external clock for the SCI, the followings should be noted. ~HITACHI 154 • The CC1, CCO, in the Rate and Mode Control Register must be set to "11" (See Table 2-6-2). • The external clock frequency must be set to 8 times the desired baud rate. The maximum external clock frequency is half of E clock. (8) Serial Operations The serial I/O hardware must be initialized by the HD6301Vl software prior to operation. as follows . The sequence is normally • Writing the desired operation control bits to the Rate and Mode Control Register . I • writing the desired operation control bits to the TRCS Register. If using Port 2 bit 3, 4 for serial I/O exclusively, TE, RE bits may be preserved set. When TE, RE bit cleared during SCl operation, and subsequently set again, it should be noted that the setting of TE, RE must refrain for at least one bit time of the current baud rate. If set within one bit time, there may be the case where the initializing of internal function for transmit and receive does not take place. (9) Transmit Operation Data transmission is enabled by the TE bit in the TRCS register. When set, outpu~s the data of the serial transmit shift register to Port 2 bit 4 which is un- conditionally configured as an output irrespectively of corresponding DDR value. Following RES, the user should configure both the RMC ~egister and the TRCS register for desired operation. Setting the TE bit during this procedure causes a trans- mission of ten-bit preamble of "l"s. Following the preamble, internal synchronization is established and the transmitter section is ready to operate. Then either of the followings operates. ~HITACHI 155 (a) If the transmit data register is empty (TDRE = 1) , the consecutive "l"s are transmitted indicating an idle lines. (b) If the data has been loaded into the Transmit Data Register (TDRE = 0), it is transferred to the output shift register and data transmission begins. During the data transfer, the "0" start bit is first transferred. Next the 8-bit data (beginning at bit 0) and the "1" stop bit. When the transmit data register has been empty, the hardware sets the TDRE flag bit: If the CPU fails to respond to the flag within the proper time, TDRE is preserved set and then a "1" will be sent (instead of a "0" at start bit time) and more "l"s will be set consecutively until the data is supplied to the data register. While the TDRE remains a "1", no "0" will be sent. (10) Receive Operation The receive operation is enabled by the RE bit. The serial input is connected with Port 2 bit 3. The receive operation is determined by the contents of the TRCS and RMC register. The received bit stream is synchronized by the first "0" (space). During 10-bit time, the data is strobed approximately at the center of each bit. If the tenth bit is not "1" (stop bit), the system assumes a framing error and the ORFE is set. (RDRF is not set.) If the tenth bit is "1", the data is transferred to the receive data register, with the interrupt flag set(RDRF).If the tenth bit of the next data is received, however, still RDRF is preserved set, then ORFE is set indicating that an overrun error has occurred. After the CPU read of the status register as a response to RDRF flag or ORFE flag followed by the CPU read of the receive data. register, RDRF or ORFE will be cleared. (11) Timer, SCI Status Flag The set and reset condition of each status flag of timer and SCI is shown in Table 2-7. ~HITACHI 156 2.7 Interrupts The H06301Vl has two external interrupt pins (NMI, IRQ1) and 8 internal interrupt source (Soft-TRAP, SWI, Timer-ICF, OCF, TOF, SCI-RDRF, ORFE, TORE). The features of these interrupt are detailed in the following paragraphs. (1) Non maskable Interrupt (NMI) When the input signal of this pin is recognized to fall, NMI sequence starts. The current instruction is continued to the last if NMI signal is detected as well as the follow- ing IRQl interrupt. Interrupt mask bit in Condition Code I Register has no effect on NMI interrupt. In response to NMI interrupt, the contents of Program Counter, Index Register Accumulators, and Condition Code Register are stored on the stack. On completion of this sequence, vectoring address $FFFC and $FFFO will occur to load the contents to the program counter and branch to a non maskable interrupt service routine. Inputs IRQ!, and NMI are hardware interrupt lines sampled by internal clock. After the execution of instructions, start the interrupt routine in synchronization with E. (2) Interrupt Request (IRQ1) This is the level-sensitive pin which requests an internal interrupt sequence to the cpu. At interrupt request, the cpu will complete the current instruction before the acceptance of the request. Unless the interrupt mask in the condition code register is set, , the CPU starts an interrupt sequence; if set, the interrupt request will be ignored. When the sequence starts, the contents of Program Counter, Index Register, Accumulator, Condition Code Register are stored on the stack. Then the CPU sets the interrupt mask bit and will not acknowledge the maskable request. At the end of the cycle, the CPU generates 16 bit vectoring addresses indicating memory addresses ~FFF8 and ~FFF9, and locates the contents in Program Counter to branch to an interrupt service routine. ~Il-IIDTACHD 157 (3) Internal interrupts For an internal interrupt requested from the timer or SCI, an internal interrupt signal IRQ2 is activated. This interrupt is identical to IRQ! except that it uses vector addresses $FFFO through $FFF7. The IRQl has the priority to the IRQ2 when interrupt requests have taken place at the same time. When the interrupt mask bit in the condi- tion code register is set, both interrupts are inhibited. The SWI is an instruction which requests an interrupt by software. The state of CCR mask bit doesn't influence the SWI. If an address error or operation code error (see "2.13 Error Processing") occurs, TRAP takes place whose priority is next to the reset. In the case of TRAP, CPU starts the interrupt sequence regardless of the state of the mask bit. The vectors corresponding to this interrupt are $FFEE and $FFEF. The memory map for inter- rupt vectors is shown in Table 2-7-1 and the interrupt sequence are shown in Fig. 2-7-1. Fig. 2-7-2 shows the logic of the interrupt circuit. Table 2-7-1 Interrupt Vectoring Memory Map Vector Interrupt MSB LSB Highest Priority FFFE FFFF RES FFEE FFEF TRAP FFFC FFFD NMI FFFA FFFB Software Interrupt (SWI) FFF8 FFF9 IRQl (or IS3) FFF6 FFF7 rCF (Timer Input Capture) FFF4 FFF5 OCF (Timer Output Compare) FFF2 FFF3 TOF (Timer Overflow) Lowest Priority FFFO FFFl SCI (RDRF+ORFE+TDRE) ~HITACHI 158 Interrupt Test Internal Address Bus -_J\..+~~=~~,.d"-=.,A-::S"'p.J\""S""P""olJ."'S"'P"'o2.,.Jl.."SP""o""3A...Sp""o...JL..,.SP-o""SA""S""Po""6.AV-ec-to-,Av-eo-.to-,AN-eW-pJciL_J..... NMi. IRQI. IR02 ~::ress k~~ress Address Internal Data au. _ _.A_.....J~=A=~"l-..-.J\___~_J'--_A_-lL_A_-lL_A_ ~~:~nal ~g~5 :~~- :~~; ACCA ACCa CCR Internal _____~I \ I Write Fig. 2-7-1 Interrupt Sequence ICF------r-~------------~IC~I~ EICI OCI TOF RDRF-----"',--... OR FE - - - - z . - " Interrupt Request Signal TORE-----------r~ iS3 FLAG------r-.... fS3 ENABLE Sleep NMI Release Signal TRAP SWI----------------------------------------~ Fig. 2-7-2 Logic of Interrupt Circuit 2.8 Reset (RES) This input is used to reset the MCU and start it from a power-off condition. During Power-on, RES pin must be held "Low" for at least 20ms. To reset the MCU during system operation, it must be held "Low" at least 3 system clock cycles. At the 3rd cycle during "Low" level, all address buses become "High impedance" while RES is "Low". Detecting "High" level, MCU operates as followings. ~HITACHI 159 (1) Latch I/O Port 2 bits 2, 1, a into bits PC2, PC1, pca of mode register. (2) Put the contents (=start address) of the last two addresses ($FFFE, $FFFF) into the program counter and start the program from this address. (Refer to Table 2-7-1) (3) Set the interrupt mask bit. For the CPU to recognize the maskable interrupts IRQl and IRQ2, this bit should be cleared in advance. Fig. 2-8-1 shows the reset timing, and Table 2-8-1 shows the pin condi- tion during reset. :;""n.' _ :&\\\Wl~\\\\\\\\\\\\\ ,:=:c:l.f----\r-I- - - - ~'''n.. _~\\\\\\§\§\\\\\\\\\ :~r------II-\- - - - - - RIW _ ~\\\\\\\\\\§§\\\\\\\\II ~:·_~\\\\\\\\\\\§\\\§\\\\\\\\§\\\t----------i'r"- - - - Fig. 2-8-1 Reset Timing Table 2-8-1 Pin Condition during RESET ~ Pin 0 1 2,4 5 6 7 Port 1 P1O'VP17 High impedance (input) 4 .. .. • .. port 2 P2 OII .. .. .. .. SC2 "1" output (READ) .. .. .. .. "1" output SC, E,"l" output I E:High impedance .. . "1" output E, "1" output E,High impedance High impedance (input) ~HITACHI 160 2.9 Oscillator XTAL, EXTAL pins interface with an AT-cut parallel resonant crystal. Divide-by-four circuit is on chip, so if 4 MHz crystal oscillator is used, the system clock is 1 MHz for example. EXTAL pin can be drived by the external clock with 45% to 55% duty. The system clock which is one fourth frequency of the external clock is generated in the LSI. When using the external clock, XTAL pin should be open. Fig. 2-9-1 shows examples of connection circuit. AT Cut Parallel Resonance Crystal Co = 7 pF max Rs = 60 n max XTAL ~ C Ll = C L2 = 10-22pF ± 20% EXTAL T (3.2 -SMHz) Fig. 2-9-1 ±"t" Crystal Interface 2.10 Strobe Signals Two pins, SCI (39 pin) and SC2 (38 pin) are used as the strobe signals in each mode. Followings are applied only to Port 3 in single. chip mode. (1) Input Strobe (IS3) (SCI) This signal controls IS3 interrupt and the latch of Port 3. When the falling edge of this signal is detected, the flag of Port 3 Control Status Register is set. For respective bits of Port 3 Control Status Register, see the "2.4 I/O Ports" section. (2) output Strobe (OS3) (SCz) This signal is used by the processor to strobe an external device, indicating effective data is on the I/O pins. The timing chart for Output Strobe are shown in figure 5-5. The following pins are available for Expanded Modes. ~HITACHI 161 (3) Read/Write (R/W) (SC2) This TTL compatible output signal indicates peripheral and memory devices whether the CPU is in Read (nHigh"), or in Write ("Low"). The normal stand-by state of this signal is Read ("High"). This output can drive one TTL load and 90pF capacitance. (4) I/O Strobe (lOS) (SCi) In expanded non multiplexed mode 5 of operation, lOS becomes "Low" when Ag through A15 are "O"s and As is "1". This allows external access of 256 addresses from $0100 to $OlFF in memory. The timing chart is shown in Figure 5-2. (5) Address Strobe (AS) (SCI) In the expanded multiplexed mode of operation, address strobe is output to this pin. This signal is used to latch the i', lower 8 bits addresses multiplexed with data at Port 3 and to control the 8-bit latch by address strobe as shown in Figure 2-1-4. Thereby, I/O Port 3 can become data bus during E pulse. The timing chart of this signal is shown in Figure 5-1. 2.11 RAM Control Register The register assigned to the address $0014 gives a status information about standby RAM. RAM Control Register 7 6 5 4 3 2 1 o STBY x x x $0014 PWR Bit 0 Not used. Bit 1 Not used. Bit 2 Not used. Bit 3 Not used. Bit 4 Not used. Bit 5 Not used. Bit 6 RAM Enable. USing this control bit, the user can disable the RAM. RAM Enable bit is set on the positive edge of RES and RAM is enabled. With the program control, it is capable of writing "I" or "0'''. With the disabled RAM (logic "0"), $HITACHI 162 the RAM address becomes external address and the CPU may read the data from the outside memory. Bit 7 Standby Bit This bit is cleared when VCC is not provided in standby mode. This bit is a read/write status flag that user can read. If this bit is preserved set, indicating that VCC voltage is applied and the data in the RAM is valid. 2.12 Low Power Consumption Mode The HD6301Vl has two low power consumption modes; sleep and standby. (1) Sleep Mode On execution of SLP instruction, the CPU is brought to the sleep mode. In the sleep mode, the CPU stops its operation, but the contents of the register in the CPU are retained. In this mode, the peripherals of MPU will remain operational. So the operations such as transmit and receive of the SCI data and counter may keep on functioning. In this mode, the power consump- tion is one-sixth that of operating condition. The MCU returns from this mode by interrupt, RES, STBY. The RES resets the MCU and the STBY brings it into the standby mode (This will be mentioned later). When the CPU acknowledges an interrupt request, it cancels the sleep mode, returns to the operation mode and branches to the interrupt routine. When the CPU masks the interrupt, it cancels the sleep mode and executes the next instruction. However, for example, if the timer 1 or 2 prohibits a timer interrupt, the CPU doesn't cancel the sleep mode because of no interrupt request. This sleep mode is available to reduce the power con- sumption for a system with no need of the HD6301Vl's consecutive operation. Please refer to Table 2-12-1 for other pins except VCC, clock pin, input-only pin, E clock pin (their function are the same as operating condition) . ~HITACHI 163 (2) Standby Mode The HD6301Vl stops all the clocks and goes into the reset state with STBY "Low". In this~mode, the power consumption is reduced conspicuously. In the standby mode, the power is supplied to the HD6301Vl, so the contents of RAM are retained. The standby mode should escape by bringing ST'BY "High". Transitions among the active mode, sleep mode, standby mode and reset are shown in Fig. 2-12-2. Table 2-12-1 Pin Condition in Sleep Mode -::----::e 0 1 2.4 5 6 7 .. Pin Port 1 Function I/O Port Lower Address Bus I/O Port .. . PiO vP 17 Keep the con- Condition dition just Output "1" Keep the con- dition just .. .. .. .. before sleep .. before sleep Function I/O Port .. . . Port 2 P20'VP24 Keep the con- Condition dition just before sleep .. ... .. .. .. E:Lower E:Lower E:Lower Function Address Bus Data Bus Address Bus Data-Bus Address Bus I/O Port Port 3 E:Data Bus E:Data Bus E:Data Bus P 30'VP37 E:Output "1" E:Output "1" E:Output "1" Keep the con- Condition E:High impe- High impedanc e E:High impe- High impedance E : High impe- dition just dance dance dance before sleep Function Upper Address .. .. LoWer Address Bus or Input Port Upper Address Bus or Input Port I/O Port Port 4 Address Bus: .. P"O"'P47 Condition Output "1" . Output 11111 Port: Keep the condition . Keep the con- dition just before sleep just before sleep SC2 Output "1" (Read Con- dition) .. .. .. .. Output "1" SCI Output Ad- dress Strobe . .. Output "1" Output Ad- dress Strobe Input Pin ~HITACHI 164 Internal E clock Stop in sleep I mode clock Sleep cleared Address ~ bus - Sleep is cleared with interrupt ::E: masked ~ (') Data bus L-I ~ ~~l @i+l \.§;+2 :I I Sleep I Interrupt save routine instruction PCn-l 1--J ~ Interrupt Address --+ PCn+l bus where sleep is ~~~~~~~~~~~-J~~~~____ PCn occurs PCn+l cleared without PCn+2 interrupt masked PCn+3 program Fig. 2-12-1 Sleep Instruction Timing Chart ...... ffi -- Fig. 2-12-2 Transitions among Active Mode, Standby Mode Sleep Mode, and Reset ~HITACHI 166 2.13 TRAP Function The CPU generates an interrupt with the highest priority (TRAP) when fetching an undefined instruction or an instruc- tion from non-memory space. The TRAP prevents the system- burst caused by noise or a program error. (1) Op-Code Error When fetching an undefined op-code, the CPU saves register as well as a normal interrupt and branches to the TRAP ($FFEE, $FFEF). (2) Address Error This has the priority next to reset. When an instruction is fetched from excluding internal I ROM, RAM, or an external memory area, the MCU generates the same interrupt as op-code error. If the instruction is fetched from external memory area without memory devices, this function is not applicable. Table 2-13-1 shows addresses where an address error occurs to each mode. This function is available only for the instruction fetch, and is not applicable to the access of normal data read/write. Table 2-13-1 Addresses Applicable to Address Errors Mode 0 1 4 5 6 7 $0000 $0000 $0000 $0000 $0000 $0000 I I I I I I Address $OOIF $OOIF $OOIF ~007F $OOIF ~007F 0200 0100 I I $EFFF $EFFF ~HITACHI 167 3. INSTRUCTIONS The HD6301Vl Provides object code upward. Besides having object code compatible with the HD6801 series, the HD6301Vl the predecessor with additional instructions; enhances bit control instructions (AIM, ElM, aIM, TIM), index/accumulator exchange instruction (XGDX), and sleep instruction (SLP). These new instructions improve programming efficiency. 3.1 Addressing Modes The HD6301Vl provides seven addressing modes. The adequate selection of these addressing mode will permit to implement an efficient and easy programming. The addressing mode is determined by an instruction type and code. The addressing mode for each instruction is shown in Table 3-2-1 to 3-2-4 with execution time counted by the machine cycles. When the clock frequency is 4 MHz, the machine cycle time will be microseconds. Accumulator (ACCX) Addressing Only an accumulator is addressed. Either accumulator A or B is selected. This is a one-byte instruction. Immediate Addressing In this mode, the data is stored in the second byte of the instruction except that LDS and LDX, store a data in the second and the third byte exceptionally. These are two or three-byte instructions. Direct Addressing In this mode, the second byte of an instruction indicates the address where the data is stored. 256 bytes ($0 through $255) can be addressed directly. Execution times can be reduced by storing data in these locations. In configurating system, it is recommended that these locations should be RAM for users' data area. These are two-byte instructions, while the AIM, aIM. ElM and TIM are three- byte. ~HITACHI 168 Extended Addressing In this mode, the second byte indicates the upper 8 bits addresses where the data is stored, and the third byte indicates the lower 8 bits. These are three-byte instruc- tions. Indexed Addressing In this mode, the contents of the second byte and the lower 8 bits in the Index Register are added. As for AIM, I OIM, ElM and TIM instructions, the contents of the third byte and the lower 8 bits in the Index Register are added. In addition, this carry is added to the upper 8 bits in the Index Register. The result is used for addressing memory. The modified address is held in the Temporary Address Register, so there is no change to the contents of the Index Register. These are two-byte instructions, while AIM, OIM, ElM and TIM are three-byte. Implied Addressing In this mode, the instruction itself gives the address. That is, the instruction addresses an accumulator, stack pointer, index register, etc. This is a one-byte instruction. Relative Addressing In this mode, the contents of the second byte and the lower 8 bits in the program counter are added. The carry or borrow is added to the upper 8 bits. So addressing from -126 to +129 bytes of the current instruction is enabled. These are two-byte instructions. ~HITACHI 169 3.2 Instruction Set TheHD6301Vl has an upward object code compatible with the HD6801 to utilize all instruction sets of the HMCS6800. The execution time of the key instruction is reduced to increase the system through-put. In addition, the bit manipulation instruction, the exchange instruction of the index and the accumulator, the sleep instruction are added. The followings are described here. • Accumulator and memory manipulation instructions (See Table 3-2-l). Additional instructions. • Index register and stack manipulation instructions (See Table 3-2-2). • Jump and branch instructions (See Table 3-2-3). • Condition code register manipulation instructions (See Table 3-2-4). • Op-code map (See Table 3-2-S). ~HITACHI 170 Table 3-2-1 Accumulator, Memory Manipulation Instructions ConditIon Code Addressing Modes Register Operation, Mnemonic .- Boolean/ IMMED DIRECT INDEX EXTEND IMPLIED Arithmetic Operation 5 4 3 2 1 0 DP - # OP - # OP - # OP - # OP - # H I N Z V C Add ADDA ADDB 8B C8 2 2 2 2 9B DB 3 2 A8 4 3 2 EB 4 2 88 2 FB 4 4 3 3 A + M.... A 8+M-e I I ·· I I I I I I I I Add Double Add Accumulltors ADDD A8A C3 3 3 03 4 2 E3 5 2 F3 5 3 lB 1 1 A B + M: M ... 1- A :B A + B- A · ·· I I I I I I I I I Add Wit" Carry ADCA ADC8 89 C9 2 2 2 2 99 09 3 2 A9 3 2 E9 4 4 2 2 89 F9 4 4 3 3 A+MtC-A B+M+C-B I I ·· : I I I I I I I AND ANDA AN DB 84 C4 2 2 94 2 2 04 3 3 2 2 A4 E4 4 4 2 B4 2 F4 4 4 3 3 A·M-A B·M- B ·· ·· I I I I R R·· ·· ·· · I Bit Test BIT A 85 2 2 95 3 2 AS 4 2 B5 4 3 A·M I I R BIT B C5 2 2 05 3 2 E5 4 2 F5 4 3 B·M I I "· Clear CLR CLRA 6F 5 2 7F 5 3 4F 1 00 - M 1 00 - A ·· ·· R R S R R S R R ··· ··· CLRB SF 1 1 00 - B R S R R Compare CMPA 81 2 2 91 3 2 Al 4 2 Bl 4 3 A-M I I I I CMPB Cl 2 2 01 3 .2 El 4 2 Fl 4 3 B-M I I I I Compare Accumulators Complement, ,'s CeA COM 63 6 2 73 6 3 11 1 1 A-B M-M ·· ·· I I I I I R S I COMA COMB 43 53 1 1 1 A -A 1 8 -B ·· ·· I I I I R S R S Complement, 2', (Nega.a' NEG NEGA 60 6 2 70 6 3 40 1 oo-M-M 1 00 - A - A ·· ·· I I I I (i)'2) (T) '2) ··· ··· NEGB 50 1 1 oo-B-B I I (I) 1,2) Converts btnary add of BCD Oec:mal Adjust. A DAA 19 2 1 characters into BCD format I I I @ Oecrement DEC 6A 6 2 7A 6 3 M-l -M I I (~ ·. ··· ··· DECA 4A 1 1 A-I - A I I @ • DEC8 5A 1 1 B-l-B I I (,,~, Exclusive OR EORA 88 2 2 98 3 2 A8 4 2 88 4 3 A@M-A I ·· I R ·· ·· EORB CB 2 2 DB 3 2 E8 4 2 F8 4 3 B@M- 8 I I R Increment INC 6C 6 2 7C 6 3 M+l-M I I ® • INCA INCB 4C 5C 1 1 1 1 A + 1 .... A B ... 1- B ·· ·· I I I I @ • @ • ··· ··· ··· Load LDAA 86 2 2 96 3 2 A6 4 2 B6 4 3 M-A I I R Accumulator M-B I R LDAB C6 2 2 06 3 2 E6 4 2 F6 4 3 I Load Oouble FC M + 1- B. M- A I R LDD CC 3 3 DC 4 2 EC 5 2 5 3 I Accumulator Multiply Unsigned OR, Inclusive MUL ORAA 8A 2 2 9A 3 2 AA 4 2 BA 4 3 3D 7 1 A x 8 .... A :B A +M- A ·· ·· · · · · I I R @ Push Data ORAB PSHA CA 2 2 DA 3 2 EA 4 2 FA 4 3 36 4 B ... M- B 1 A - MoP. SP - 1 - SP ·· ·· · · · ·· I I R Pull Data PSH8 PULA 37 32 4 3 1 B - Mop. SP - 1 - SP 1 SP+ l-SP,Msp- A ·· ·· ·· ·· ·· ·· PULB 33 3 1 SP + 1 ...... SP, Msp - B ·· ·· · · · · Rotate Le't ROL ROLA ROLB 69 6 2 79 6 3 49 59 1 1 1 1 . ., ~}?IIIIII 1,:1 bO ·· ·· I I I I I I @ (~ @ I I I Rotate Right ROR RORA 66 6 2 76 6 3 46 1 1 :l?,' 1 I I I 1 If) ·· ·· I I I I @ I (8) I RORB Note) Condition Code Register will be 56 1 1 bO ·· I I (to be continued) '0, I explained in Note of Table 3-2-4. $ HITACHI 171 Table 3-2-1 Accumulator, Memory Manipulation Instructions Condition Code I Addressing Modes Register Operations I Mnemonic IMME-Olol-RECT OP - # OP - # OP INDEX - # EXTEND OP - # IMPLIED OP - # Booleanl Arithmetic Operation 5 H 4 3 2 I N Z V C 1 0 Shift Left Arithmetic ASL ASLA ASL8 68 6 2 78 6 3 48 sa 1 1 1 1 Mj A B [)--!1111111t-o C b1 ··• ··• _ bO I I I I @I I @I I 6 I Double Shift ~thmetic ASLo 05 1 1 ~ A7 •· ACe AI Ace B l-O AO 87 BO I I ~ I f..9 · • I I 6 I Shift Right Arithmetic ASR ASRA ASR8 67 6 2 77 6 3 47 57 1 1 1 1 B :1 CCII® I b7 ·· ··• bO I I 6 I I I 6 I Shift Right Logical LSR LSRA 64 6 2 74 6 3 44 54 1 1 1 1 .:j0-oi., ------ ··· ·· I IIIIIIJ~ ~ R I 6 I R I @I R I @I ., LSRB Double Shift Right Logical LSRo 04 1 1 0--0{ ·· Ace AI Ace a AO 87 80 ~ R I @I Store Accumulator -~-~ STAA ----~ STAB - - 97 07 3 3 2 2 A7 E7 4 4 2 2 B7 F7 4 4 3 3 A_ M B-M ·· ·· I I I I R R • • Store Double Accumulator STo DO 4 2 ED 5 2 Fo 5 3 A_M B _ M+ 1 •· I I R · ··• ·• Subtract SU8A 80 2 2 90 3 2 AO 4 2 BO 4 3 A -M_A • I I I I SU88 CO 2 2 DO 3 2 EO 4 2 FO 4 3 8 -M-8 I I I I Double Subtract SU80 83 3 3 93 4 2 A3 5 2 B3 5 3 A:8-M : M + 1- A: 8 I I I I Subtract Accumulators Subtract SBA SBCA 82 2 2 92 3 2 A2 4 2 82 4 3 10 1 1 A- 8- A A-M-C-A ·· ·· I I I I I I I I With Carrv funsfer rsscB TAB C2 2 2 02 3 2 E2 4 2 F2 4 3 16 1 1 A-B B-M-C-B ·· ·· I I I I I I R ·· Accumulators Test Zero or T8A TST 60 4 2 70 4 3 17 1 1 B_A M -00 ·· ·· I I R I I R R Minus TSTA TSTB --- 40 50 1 1 1 A -00 1 B - 00 ·· ·· I I I I R R R R And Immediate AIM 71 3 61 6 7 3 M·IMM-M •• : : R • OR Immediate OIM 72 3 62 6 7 3 M+IMM-M •• : : R• EOR Immediate ElM 75 6 3 65 7 3 M+'IMM-·M •• : : R• Test Immediate TIM 78 4 3 68 5 3 M·IMM ••: : R• Note) Condition Code Register will be explained in Note of Table 3-2-4. Additional Instructions In addition to the HD6801 Instruction Set, the HD630lVl has the following new instructions: AIM (M) • (IMM) ->- (M) Executes "AND" operation to the immediate data and the memory contents and stores the result in the memory. aIM --- (M) + (IMM) ->- (M) Executes "OR" operation to the immediate data and the memory contents and stores the result in the memory_ ElM --- (M) Ef) (IMM) -+ (M) Executes "EaR" operation to the immediate data and the memory contents and stores the result in the memory. ~HITACHI 172 TIM --- (M) • (IMM) Executes "AND" operation to the immediate data and the memory contents and changes the flag of associated condition code register. Each instruction has three bytes; the first. is op-code, the second is immediate data, the third is address modifier. XGDX (ACCD) ...... (IX) Exchanges the contents of accumulator and the index register. SLP --- The MCU goes to the sleep mode. Refer to "Low Power Dissipation Mode" for more details of the sleep mode. Table 3-2-2 Index Register, Stack Manipulation Instructions Condition Code Addressing Modes Booleanl Register POinter Operations MnemoniC IMMED. DIRECT INDEX EXTEND IMPLIED Arithmetic Operation 5 4 J 1 0 OP - # OP - # OP - # OP - # OP - # H I N Z V C 1---------- Pull Data PULX Exchange XGDX 18 1 ACCD··IX •••••• Note) Condition Code Register will be explained in Note of Table 3-2-4. ~HITACHI 173 Table 3-2-3 Jump, Branch Instruction Operations MnemonIC i:~t. . B hN Branc,", Alwavs rane ever .._- ~- BRN--t-'-21--t-322W_.l__ BRA . i i ' , --:- 20 3 t-- N - one .-----+-+-.- t--+ None· t ~- ;"1 •• • .-. • .~_ Branch If Carrv Clear BCe 24 3 2 l i e " ,0 • .'. • • Branch If Carry Set BCS 25 J -~- C" 1 • • .-+A f-;- 1--:c::-:-~:-:-"'::-':-z:Cz:':'rr°":o--t---::C:~-'~:--+I":~C.~-+I-~:-+!~ i ! -t- __+-+-+_1-+-+_1-_·_1-j- _- _I-j-":.::~=~:+=1V==.=o========~~=~=t=:~:=:~:=:~t-f;--1 Branch If > Zero Branch If Higher BBGHT, 2 2f3.-L1:2 E Z+- (N 0 VI '" 0 C +- Z " 0 •• • • I. I- i· :. • • i. • Branch If..;; Zero BlE 2F 3 I 2+--+-f---+--t--1-f--+ -t-I-++-+-=Z-:+-":'N-:G,)i+C'CC VC"I-_""'I--+.+.-+'-.+0-1,1-.+0--1 Branch If low--er-:o:Cr-+-~L~ 2-;tj3-i"1'-2+--1.-- - -I-- -. -- t---t--. C+Z 1 •• I. ,.-t-:i. ++ L+_ = ~e.,-c:--::-_-jI---_'C"':=--·I-=+c:-t·L-::-i-t-. Branch If < Zero elT 2D 12 - N 3 v'" 1 • • I. .'. 1-1-=-_~_~_;.~: . :_:_:_:_~_~n_;-~_E': '$Q~U~a_,~ ~ ~:_-:=:=~-__j-~_:~:~_~:';_2~_t:i=_-~ j-i:=_-I:=_'-:~I- ~ :~=_t:=_-I:=_-~:;_-~: ~: ~ ~:~ :~=~:~ O~_:-~:~_o-I~=~ =~ =~ =~ =~ =~:i"~ ~:~f'I-:~ ,~t:-: Branch If Overflow Clear BVC 28 V• 0 • ~. j. • , • I • 1--'------:----1-- - - ' +- Branch If Overflow Set BVS 29 _ __ __ V '" ' _ _ _ _ _ _ro+0-r0'-j-04.:c0-t-'._ ~~f:~~~routine BPl 2A 3 2 _+_ __ N· 0 0 ~t-;~;.- +--cB~S~R.-_+8-~_I_~~_- - - "'SE ~'2' 7'E- 3-' .~ .:° 1;. °1·- • t--.,-Jum--p---- ___,_ _ _ r---;-~mp To Subroutine JMP JSR I i 90 5 ~- AD 5 -2-~D 1 _~ __ ~_ I- i - ~_ • 0 • _ r;-r;- - I ! - - I- • L~L_ .. _ 39 5 1 ~~=-·ttr ~t.-0.-~~ . .. , . 3F 12 1 ;" S "1-- ---- 3E 9 1,,- ® ~l.t;l;- Sleep SlP lA 4 1 o 0 • e I_ • Note) *WAI puts R/W high; Address Bus goes to FFFF; Data Bus goes to the three state level.Condition Register will be explained in Note of Table 3-2-4. Table 3-2-4 Condition Code Register Manipulation Instructions !Addressing Modes Condition Code Register Operations Mnemonic IMPLIED Boolean Operation 5 3 2 1 0 4 OP - # HI VC N Z Clear Carry Clear Interrupt Mask ClC Cli OC 1 1 OE 1 1 O-C 0-1 · · ·· · · · 0R ° R 0 · ·· ··· ··· ·· ·· Clear Overflow ClV OA 1 1 O-V ° R Set Cerry SEC 00 1 1 1- C 1-- t-s Set Interrupt Mask SEI OF 1 1 1-1 0 5 Set Overflow Accumulator A - eeR SEV TAP OB 1 1 OS 1 1 I-V A- CCR ···· · S ~-@-- eeR - Accumulator A TPA 07 1 1 CCR- A ··· • I • I· [NOTE] Condition Code Register Notes: (Bit set if test is true and cleared otherwise) CD (Bit V) Test: Result = 10000000? @ (Bit C) Test: Result'" OOOOOOOO? @ (Bit C) Test: BCD Character of high-order byte greater than 10? (Not cleared if previously sed @ (Bit V) Test: Operand = 10000000 prior to execution? @ (Bit V) Test: Operand = 01111111 prior to execution? ® (Bit V) Test: Set equal to N@C=1 after the execution of instructions (]) (Bit N) Test: Result less than zero? (Bit 15=1) @ (All) Load Condition Code Register from Stack, tID (Bit I) Set when interrupt occurs. If previously set, a Non-Maskable Interrupt is required to exist the wait state. (All Bit) Set according to the contents of Accumulator A. (Bit C) Result of Multiplication Bit 7=1? (ACeB) ~HITACHI 174 Table 3-2-5 OP-Code Map ~ ACCA or SP ACCB or X OP ACC 1 A~C INO CODE A DIR IMM 1 OIR 1-iNO~XT 'IMM ToiRTiNO 1 EXT 1000 1 1001 ! 1010 1100 1 1101 1 1110 L 1111 ~ 0000 OO~I 0010 0011 0100 I 0101 0110 0111 1011 LO 2 7 B ! 9 A i B C 1 o 1 E ! F --- 0 I 3 4 5 6 ODOO 0 ~ SB!I BRA TSX NEG SUB 0 0001 1 NOP CBA BRN INS AIM CMP I 0010' 2 / / BHI PULA DIM - - ---- SBC 2 3 / ~ I AD DO --- 0011 BLS PULB COM SUBD 3 - DIDO 4 LSRD / BCC DES LSR AND 4 0101 5 ASLD ~'BCS TXS ElM BIT 5 0110 6 TAP TAB BNE PSHA ROR LOA 6 01 !1 7 TPA TBA BEQ PSHB ASR /' STA ~'I STA 7 1000 B INX XGDX BVC PULX ASL EOR B I 1001 9 DEX DAA BVS RTS ROL ADC 9 - 1010 1011 1100 1101 1110 A B C 0 E CLV SEV CLC SEC CLI SLP ABA / / BPL BMI BGE BLT BGT ABX RTI PSHX MUL WAI --- ~i/I DEC L INC TST TIM JMP . ------------- _B':;~_ I CPX LOS JSR 9 RA ADD -----·--LDo------c L1 - - - - -. ._- - -STD LOX --------- A B 0_. E 1111 F SEI 0 ----- ----- 1 BLE 2 SWI 3 4 CLR : 5 1 6 1 7 ------------I B J 9 j STS At B ""'------1 C STX 1 o .1 E .1 F F UNDEFINED OP CODE c;;::::::J • Only each instructions of AIM, OIM, ElM, TIM 3.3 Instruction Execution Cycles In the HMCS6800 series, the executLon cycle of each instruction is counted from the start of the op-code fetch. The HD630lVl employs a mechanism of the pipeline control for the instruction fetch and the subsequent instruction fetch is performed during the current instruction being executed. Therefore, the method to count instruction cycles used in the HMCS6800 series cannot be applied to the instruction cycles such as MULT, PULL, DAA and XGDX in th~ HD630lVl. Table_3-3-l, provides the information about the relationship among each data on the Address Bus, Data Bus,and R/W status in cycle by cycle basis during the execution of each instruction. $HHTACHB 175 Table 3-3-1 Cycle by Cycle Operation Address Mode & Cycles Cycle Address Bus - R!W Data Bus # Instructions IMPLIED ADC ADD 1 Op Code Address + 1 1 Operand Data AND BIT 2 Op Code Address + 2 1 Next Op Code CMP EOR 2 LDA ORA SBC SUB ADDD CPX 1 Op Code Address + 1 1 Operand Data (MSB) LDD LDS 3 2 Op Code Address + 2 1 Operand Data (LSB) LDX SUBD 3 Op Code Address + 3 1 Next Op Code DIRECT ADC ADD 1 Op Code Address + 1 1 Address of Operand (LSB) AND BIT 2 Address of Operand 1 Operand Data CMP EOR 3 3 Op Code Addresf; + 2 1 Next Op Code LDA ORA SBC SUB STA 1 Op Code Address + 1 1 Destination Address 3 2 Destination Address 0 Accumulator Data 3 Op Code Address + 2 1 Next Op Code ADDD CPX 1 Op Code Address + 1 1 Address of Operand (LSB) LDD LDS 2 Address of Operand 1 Operand Data (MSB) 4 LDX SUBD 3 Address of Operand + 1 1 Operand Data (LSB) 4 Op Code Address + 2 1 Next Op Code STD STS 1 Op Code Address + 1 1 Destination Address (LSB) STX 2 Destination Address 0 Register Data (MSB) 4 3 Destination Address + 1 0 Register Data (LSB) 4 Op Code Address + 2 1 Next Op Code JSR 1 Op Code Address + 1 1 Jump Address (LSB) 2 FFFF 1 Restart Address (LSB) 5 3 Stack Pointer 0 Return Address (LSB) 4 Stack Pointer - 1 0 Return Address (MSB) 5 Jump Address 1 First Subroutine Op Code TIM 1 Op Code Address + 1 1 Immediate Data 2 Op Code Address + 2 1 Address of Operand (LSB) 4 3 Address of Operand 1 Operand Data 4 Op Code Address + 3 1 Next Op Code AIM ElM 1 Op Code Address + 1 1 Immediate Data OIM 2 Op Code Address + 2 1 Address of Operand (LSB) 3 Address of Operand 1 Operand Data 6 4 FFFF 1 Restart Address (LSB) 5 Address of Operand 0 New Operand Data 6 Op Code Address + 3 1 Next Op Code (to be cont1nued) ~HITACHI 176 Address Mode Cycle & Cycles Address Bus R/W Data Bus Instructions # INDEXED JMP 1 Op Code Address + 1 1 Offset 3 2 FFFF 1 Restart Address (LSB) 3 Jump Address 1 First Op Code of Jump Routine ADC ADD 1 Op Code Address + 1 1 Offset AND BIT 2 FFFF 1 Restart Address (LSB) CMP EOR 4 3 IX + Offset 1 Operand Data LOA ORA 4 Op Code Address + 2 1 Next Op Code I SBC SUB TST" STA 1 Op Code Address + 1 1 Offset 2 FFFF 1 Restart Address (LSB) 4 3 IX + Offset 0 Accumulator Data 4 Op Code Address + 2 1- Next Op Code ADDD 1 Op Cede Address + 1 1 Offset CPX LDD 2 FFFF ~ 1 Restart Address (LSB) LOS LOX 5 3 IX + Offset 1 Operand Data (MSB) SUBD 4 IX + Offset + 1 1 Operand Data (LSB) 5 Op Code Address + 2 1 Next Op Code .. STD STS 1 Op Code Address + 1 1 Offset STX 2 FFFF 1 Restart Address (LSB) 5 3 IX + Offset 0 .Register Data (MSB) 4 IX + Offset + 1 0 Register Data (LSB) 5 Op Code Address + 2 1 Next Op Code JSR 1 Op Code Address + 1 1 Offset 2 FFFF 1 Restart Address (LSB) 5 3 Stack Pointer 0 Return Address (LSB) 4 Stack Pointer - 1 0 Return Address (MSB) 5 IX + Offset 1 First Subroutine Op Code ASL ASR 1 Op Code Address + 1 1 Offset COM DEC 2 FFFF 1 Restart Address (LSB) INC LSR 3 IX + Offset 1 Operand Data 6 NEG ROL 4 FFFF 1 Restart Address (LSB) ROR 5 IX + Offset 0 New Operand Data 6 Op Code Address + 2 1 Next Op Code TIM 1 Op Code Address + 1 1 Immediate Data 2 Op Code Address + 2 1 Offset 5 3 FFFF 1 Restart Address (LSB) 4 IX + Offset 1 Operand Data 5 Op Code Address + 3 1 Next Op Code CLR 1 Op Code Address + 1 1 Offset 2 FFFF 1 Restart Address (LSB) 5 3 IX + Offset 1 Operand Data 4 IX + Offset 0 00 5 Op Code Address + 2 1 Next Op Code AIM ElM 1 Op Code Address + 1 1 Immediate Data aIM 2 Op Code Address + 2 1 Offset 3 FFFF 1 Restart Address (LSB) 7 4 IX + Offset 1 Operand Data 5 FFFF 1 Restart Address (LSB) 6 IX + Offset 0 New Operand Data 7 Op Code Address + 3 1 next Op Code (to be cont1nued) ~HITACHI 177 Address Mode Cycle Address Bus - & Cycles R/W Data Bus # Instructions EXTEND JMP 1 Op Code Address + 1 1 Jump Address (MSB) 3 2 Op Code Address + 2 1 Jump Address (LSB) 3 Jump Address 1 Next Op Code ADC ADD TST 1 Op Code Address + 1 1 Address of Operand (MSB) AND BIT 2 Op Code Address + 2 1 Address of Operand (LSB) 4 CMP EOR 3 Address of Operand 1 Operand Data LDA ORA 4 Op Code Address + 3 1 Next OP Code SBC SUB STA 1 Op Code Address + 1 1 Destination Address (MSB) 2 OP ·Code Address + 2 1 Destination Address (LSB) 4 3 Destination Address 0 Accumulator Data 4 Op Code Address + 3 1 Next Op Code ADDD 1 Op Code Address + 1 1 Address of Operand (MSB) CPX LDD 2 Op Code Address + 2 1 Address of Operand (LSB) LDS LDX 5 3 Address of Operand 1 Operand Data (MSB) SUBD 4 Address of Operand + 1 1 Operand Data (LSB) 5 Op Code Address + 3 1 Next Op Code STD STS 1 Op Code Address + 1 1 Destination Address (MSB) STX 2 Op Code Address + 2 1 Destination Address (LSB) 5 3 Destination Address 0 Register Data (MSB) 4 Destination Address + 1 0 Register Data (LSB) 5 Op Code Address + 3 1 Next OP Code JSR 1 Op Code Address + 1 1 Jump Address (MSB) 2 Op Code Address + 2 1 Jump Address (LSB) 3 FFFF 1 Restart Address (LSB) 6 4 Stack Pointer 0 Return Address (LSB) 5 Stack Pointer - 1 0 Return Address (MSB) 6 Jump Address 1 First Subroutine Op Code ASL ASR 1 Op Code Address + 1 1 Address of Operand (MSB) COM DEC 2 Op Code Address + 2 1 Address of Operand (LSB) INC LSR 3 Address of Operand 1 Operand Data 6 NGE ROL 4 FFFF 1 Restart Address (LSB) ROR 5 Address of Operand 0 New Operand Data 6 Op Code Address + 3 1 Next Op Code CLR 1 Op Code Address + 1 1 Address of Operand (MSB) 2 Op Code Address + 2 1 Address of Operand (LSB) 5 3 Address of Operand 1 Operand Data 4 Address of Operand 0 00 5 Op Code Address + 3 1 Next Op Code (to be continued) ~HITACHI 178 Address Mode & Cycles Cycle Address Bus - R/W Data Bus Instructions # IMPLIED ABA ABX 1 Op Code Address + 1 1 Next Op Code ASL ASLD ASR CBA CLC CLI CLR r.LV COM DEC DES DEX I INC INS INX LSR 1 LSRD ROL ROR NOP SBA SEC SEI SEV TAB TAP TBA TPA TST TSX TXS DAA XGDX 1 Op Code Address + 1 1 Next Op Code 2 2 FF'FF 1 Restart Address (LSB) PULA PULB 1 00 Code Address + 1 1 Next Op Code 3 2 FFFF 1 Restart Address (LSB) 3 Stack Pointer + 1 1 Data from Stack PSHA PSHB 1 Op Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) 4 3 Stack Pointer 0 Accumulator Data 4 Op Code Address + 1 1 Next Op Code PULX 1 Op Code Address + 1 1 Next 00 Code 2 FFFF 1 Restart Address (LSB) 4 3 Stack Pointer + 1 1 Data from Stack (MSB) 4 Stack Pointer + 2 1 Data from Stack (LSB) PSHX 1 Op Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) 5 3 Stack Pointer 0 Index Register (LSB) 4 Stack Pointer - 1 0 Index Register (MSB) 5 Op Code Address + 1 1 Next Op Code RTS 1 Op Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) 5 3 Stack Pointer + 1 1 Return Address (MSB) 4 Stack Pointer + 2 1 Return Address (LSB) 5 Return Address 1 First Op Code of Return Routine MUL 1 Op Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) 3 FFFF 1 Restart Address (LSB) 7 4 FFFF 1 Restart Address (LSB) 5 FFFF 1 Restart Address (LSB) 6 FFFF 1 Restart Address (LSB) 7 FFFF 1 Restart Address (LSB) (to be continued) ~HITACHI 179 Address Node Cycle - & Cycles Address Bus R/W Data Bus Instructions # IMPLIED WAI 9 1 Op Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) 3 Stack Pointer 0 Return Address (LSB) 4 Stack Pointer - 1 0 Return Address (HSB) 5 Stack Pointer - 2 0 Index Register (LSB) 6 Stack Pointer - 3 0 Index Register (MSB) 7 Stack Pointer - 4 0 Accumulator A 8 Stack Pointer - 5 0 Accumulator B 9 Stack Pointer - 6 0 Conditional Code Register RTI 10 1 Op.Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) 3 Stack Pointer + 1 1 Conditional Code Register 4 Stack Pointer + 2 1 Accumulator B 5 Stack Pointer + 3 1 Accumulator A 6 Stack Pointer + 4 1 Index Register (MSB) 7 Stack Pointer + 5 1 Index Register (LSB) 8 Stack Pointer + 6 1 Return Address (MSB) 9 Stack Pointer + 7 1 Return Address (LSB) 10 Return Address 1 First Op Code of Return Routine SWI 12 1 Op Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) 3 Stack Pointer 0 Return Address (LSB) 4 Stack Pointer - 1 0 Return Address (MSB) 5 Stack Pointer - 2 0 Index Register (LSB) 6 Stack Pointer - 3 0 Index Register (MSB) 7 Stack Pointer - 4 0 Accumulator A 8 Stack Pointer - 5 0 Accumulator B 9 Stack Pointer - 6 0 Conditional Code Register 10 Vector Address FFFA 1 Address of SWI Routine (MSB) 11 Vector Address FFFB 1 Address of SWI Routine (LSB) 12 Address of SWI Routine 1 First Op Code of SWI Routine SLP 4 1 Op Code Address + 1 1 Next Op Code 2 FFFF 1 Restart Address (LSB) i Sleep FFFF High Impedance - Non MPX Mode Address Bus - MPX Mode 13 FFFF ! Restart Address (LSB) 4 Op Code Address + 1 Next Op Code (to be continued) ~HITACHI 180 Address Mode Cycle - & Cycles Address Bus R/W Data Bus # Instructions RELATIVE BCC BCS 1 Op Code Address + 1 1 Branch Offset BEQ BGE 3 2 FFFF 1 Restart Address (LSB) BGT BLE BHI BLS 3 rranCh Addreaa Test = "1" 1 First Op Code of Branch Routine BLT BMT Op Code Address Next Op Code BNE BPL Test = 110 11 BRA BRN I BVC BVS BSR 1 Op Code Address + 1 1 Offset 2 FFFF 1 Restart Address (LSB) 5 3 Stack Pointer 0 Return Address (LSB) 4 S~ack Pointer - 1 0 Return Address (MSB) 5 Branch Address 1 First Op Code of Subroutine 3.4 System Flowchart A system flow of the HD6301Vl is given in Fig. 3-4-1. ~HRTACHI 181 VECTORIN A FFFE·FFFF PCL~ MSP PCH ~MSP·1 IXL ~ MSP·2 IXH -~ MSP-3 ACCA ·.MSP-4 AceB -+ MSP·5 CCR ~MSP-6 Fig. 3-4-1 HD6301Vl System Flowchart ~HITACHI 182 4.1.1 PIN ARRANGEMENT AND PACKAGE INFORMATION • HD6301V1P, HD63A01V1P • HD6301V1FG, HD63A01V1F HD63B01 V1 P (DP-40) HD63B01 V1 FG (FP-54) se, se. p .. P" P" P" I P .. p ... PH P" Po> P.. POI POI p .. P .. P .. P" PI' ~ __________ ~~ Vee • HD6301V1CG, HD63A01V1CG • HD6301V1CP, HD63A01V1CP HD63B01V1CG (CG-40) HD63B01V1CP (CP-52) f f ~ ~ t f l ~ f ~ t~J l;J L8J :"~J ~C:;J ~~ t~ t~J t~l L~l P31 ~ [~s P44 P30 37] ~~ P4!> NC P" SC2 3~J (2) P4a P" p .. SC, 3!J [2~ P.7 P" NC P" I E {oJ [~1 Vee P" P" p.. 1] ~~ PI7 p.. ,P.,. Vss p" NC NC XTAL ~] [Ij PHI P" p" EXTAL~J ~=8 PH P" p .. NMI ~] r1'7 PI4 NC NC IRa, ~J ~~ P". HD6301V1 L, HD63A01V1 L '1""!9"I;I"!!rE!I'1!!I"'I;;rB!JlI!"1IrE""'.,....-J [.01 [;'1 r~l f0.1 r~1 r:=1 r~l r~l f;!1 r~1 HD63B01 V1 L (CP-44) ~ f l.l J. i. ~ ~ l 2 l f !if mEcE~~ffa:i.~ loe~o~gJ -~fillOi !!;Iz w:!:.x > w ~ rtJ Do Do l P32 l POl l P34 (NO) l P35 l P36 l P37 l (NC) 31 P40 1 P41 P42 1T0pView) Fig. 4-1-1 Pin Arrangement (Tbp View) ~HITACHI 183 4.1.2 PIN ARRANGEMENT AND PACKAGE INFORMATION • HD6303RP, HD63A03Rp, • HD6303RF, HD63A03RF, • HD6303RCG, HD63A03RCG HD63B03RP (DP-40) HD63B03RF (FP-54) HD63B03RCG (CG-40) 0 ..s Rm ~:gJ L;J L8l :"~J ~;:;~ ~~.! t~~ t~J ~~J L~J OoIAo w«CI:OOV 'RES D,/A, STi'iY 1 4 DJ/AJ D4/A. P21 4 p" D./A. P" D./A. p,. 9 D7/A7 AD/PtD As A,/P" A,/P12 AtD Fig. 4-1-2 Pin Arrangement (Top View) ~HITACHI 184 PACKAGE DIMENSIONS Un.lt·. mm (i nch) DP-40 52.8(2.079) 54.0mox. (2. I 26mox.) • CG·40 12.19±0.3 (0.480±0.012) ~ ~ D ~O +I ~ ~~ • 0:5:0X (0.030mox.) ,- -=n=n;::nn;:;n;:;;:n~ll Ilnnnn _ ~~ ~ ~ j . a NO 26 -.9 ....... ----------- 0.( 1.0~~==~~~--:-~~~~~II~nff~ormation Fig. 4- 2 Package (to be continued) ~HITACHI 185 Unit: mm(inch) ~CP-44 17S3±D 12(0 690±O 005) I'•• 40 ~r;t,~~~~~~39 Y-7'f'_-~ ~ 0 I... o 9" -~§~I8~~~~H~~~~~~ 1"4~ . ~~ .~ 1651(0653) j ~ 'J L 1.27 O.DSO IS.50±O.50(O.610±O.020l 1 I .CP-52 2001±O 12 (0.790 ± Q.OOS) '" " 0 !~ ~ a " 33 " 21 1912 10.153) :;:!I ...... lflAm i j ::~ J LLlli!ill!!lI .;; II 18.04+0.5 ...11f,;... ~ (O.7IUtC.OlD) ::l!! a Fig. 4-2 Package Information 5. ELECTRICAL CHARACTERISTICS •.ABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply Voltage Vee -0.3 -+7.0 V Input Voltage V in -0.3 - Vee+0.3 V Operating Temperature T opr 0 - +70 °c Storage Temperature Tstg -55 -+150 °c (NOTE) This product has protection circuits in input pin from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend Vin, V out : Vss :a; (V in or Voutl ;;;; Vee. ~HITACHI 186 • ELECTRICAL CHARACTERISTICS (HD6301V1 and HD6303R) • DC CHARACTERISTICS (Vee = 5.0V ± 10%, f = 0.1 - 2.0 MHz, Vss = OV, Ta = 0 - +70°C, unless otherwise noted.) Item Symbol Test Condition min typ max Unit RES, STBY Vee-0•5 - Vee Input "High" Voltage EXTAL V IH Vee xO.7 - +0.3 V Other Inputs 2.0 - Input "Low" Voltage All Inputs V IL -0.3 - O.B V Input Leakage Current NMI, IRQ!, RES, STBY II in I V in = 0.5-V ee -0.5 - - 1.0 p.A Three State (off-state) PIO -P I1 , P20 -P 24 , a Leakage Current P30 -P 37 , P40 -P47 , IS3 II T51 1 V in = 0.5-V ee -0.5 - - 1.0 p.A 10H = -200p.A 2.4 - - V Output "High" Voltage All Outputs V OH 10H = -10p.A Vee- 0.7 - - V Output "Low" Voltage All Outputs VOL 10L = 1.6mA - - 0.55 V Vin=OV,.f= 1.0MHz, Input Capacitance All Inputs Cin Ta = 25°C - - 12.5 pF Standby Current Non Operation lee V IL (STBY)=0-0.6V - 2.0 15.0 pA. V IH (RES) =Vee-05- Vee V V IL (RES) =0-0.6V Operating (f=lMHz**) - 6.0 10.0 Current Dissipation" lee rnA Sleeping (f = 1MHz' ') - 1.0 2.0 RAM Stand-By Voltage V RAM 2.0 - - V V IH min = Vee -1.0V, VI L max = O.BV A 11 output pins have no load. Current Dissipation of the operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about Current Dissipations at X MHz operation are decided according to the following formulas. typo valua (f = X MHz) = typo value (f = 1MHz) xX max. value (f = X MHz) = max. value (f =1MHz) xX (both the sleeping and operating) PERIPHERAL PORT TIMING Test HD6301V11 HD63A01Vll , HD63B01VlI HD6303R HD63A03R H063B03R Item Symbol Con- Unit dition min typ max min typ max min typ max Peripheral Data. Fig. Set-up Time Port 1, 2, 3, 4 tp05U 5-3 200 - - 200 - - 200 - - ns Peripheral Data Fig. Hold Time Port 1, 2, 3, 4 tpOH 5-3 200 - - 200 - - 200 - - ns Delay Time, Enable Positive Fig. Transition to 0S3 Negative t0501 5-5 - - 300 - - 300 - - 300 ns Transition Delay Time, Enable Positive Transition to m Positive t0502 Fig. 5-5 - - 300 - - 300 - - 300 ns Transition Delay Time, Enable Nega-I Port 1 Fig. tive Transition to Peri- 2· 3 4 tpWO 5-4 - - 300 - - 300 - - 300 ns pheral Data Valid ' , Input Strobe Pulse Width tpWI5 F~26 200 - - 200 - - 200 - - ns Input Data Hold Time I Port 3 tlH F.t26 150 - - 150 -- 150 - - ns Input Data Setup Time I Port 3 tl5 F~~~ 0 - - 0 - - 0 - - ns • Except P21 ~HITACHI 187 • AC CHARACTERISTICS (\t:C = 5.0V ± 10%, f = 0.1 - 2.0 MHz, Vss .OV, Ta = 0 - +70·C, unless otherwise noted.) BUS TIMING HD6301Vll HD63A01V1I -. HD63B01Vll Test Item Symbol HD6303R HD63A03R HD63B03R Con· Unit dition min typ max min typ max min typ max Cycle Time teye 1 - 10 0.666 - - 10 0.5 10 - III Address Strobe Pulse Width "High" PW ASH 220 - - - 150 - 110 - - ns Address Strobe Rise Time tAS, - - 20- - 20 - - 20 ns Address Strobe Fall Time tASf - - 20- - 20 - - 20 ns Address Strobe Delay Time tASD 60 - - 40 - - 20 - - ns Enable Rise Time tE, - - 20 - - 20 - - 20 ns Enable Fall Time tEf - - 20 - - 20 - - 20 ns Enable Pulse Width "High" Level PWEH 450 - - 300 - - 220 - - ns Enable Pulse Width "Low" Level PWEL 450 - - 300 - - 220 - - n. Address Strobe to Enable Delay t ASED 60 - - 40 - - 20 - - ns Time Address Delay Time tAD1 Fig. - - 260 - - 190 - - 160 ns tAD2 5-1, - - 250 - - 190 - - 160 ns Address Delay Time for Latch tADL Fig. - - 250 - - 190 - - 160 ns Data Set-up Time Write 5-2 t Dsw 230 - - 150 - - 100 - - ns Read tDSR 80 - - 60 - - 50 - - n. Data Hold Time Read tHR 0 - - 0 - - 0 - - ns Write tHW 20 - - 20 - - 20 - - ns Address Set·up Time for Latch tASL 60 - - 40 - - 20 - - ns Address Hold Time for latch tAHL 20 - - 20 - - 20 - - ns Address Hold Time tAH 20 - - 20 - - 20 - - ns Ao - A, Set·up Time Before E tASM 200 - - 110 - - 60 - - ns Non-Multiplexed Peripheral Read Bus (tACCN) - - 650 - - 395 - - 270 ns Access Time Multiplexed Bus (tACCM) - .,.. 650 - - 395 - - 270 ns Oscillator, stabilization Time tRC Fig_ 2-7-1, 20 - - 20 - - 20 - - ms Processor Control Set-up Time tpcs ~:i:l 200 - - 200 - - 200 - - ns TIMER, SCI TIMING Test HD6301Vl1 HD63A01Vll HD63B01Vll , HD6303R HD63A03R HD63B03R Item Symbol Con- Unit dition min typ max min typ max min typ max Timer Input Pulse Width tPWT 2.0 - - 2.0 - - 2.0 - - teye Delay Time, Enable Positive Fig. Transition to Timer Out tTOD 5-7 - - 400 - - 400 - - 400 ns SCI Input Clock Cycle t Scye 2.0 - - 2.0 - - 2.0 - - teye SCI Input Clock Pulse Width tpwSCK 0.4 - 0.6 0.4 - 0.6 0.4 - 0.6 tScye MODE PROGRAMMING Test HD6301Vll HD63A01VlI HD63B01Vll HD6303R HD63A03R HD63B03R Item Symbol Con- Unit dition min typ max min typ max min typ max RES "Low" Pulse Width PWR;TL 3 - - 3 - - 3 - - teve Mode Programming Set·up Time t MPS Fig. 2 - - 2 - - 2 - - t,;.,c 5-8 Mode Programming Hold Time tMPH 150 - - 150 - - 150 - - ns ~HITACHI 188 2.4V Address Strobe (AS) O.8V II--------PWEH------__l\ Enable tEl 'E, 'Ef I tA01 RM, AI-An (SC1 1IPort4) MCUWrite Do-D"Ao-A. (Port 3) MCU Read 0 0 -0" Ao-A, (Port 31 ~ NotValid Fig. 5-1 Expanded Multiplexed Bus Timing tcyc Enable !I----PWEH IE) \1-------- PWEL Ao -A1 (Port4) 2.4V R/w (SC,) Address Valid O.BV 105 (Sed MCUWrite 00-01 ------r--------+----------~~ (Port 3) MCU Read 0 0 -0 1 IPort 3) ------1-------------------------------a1'-________-+-'1 A o -A1 (Port 1) A. -Au (Port 4) ~ Not Valid Fig. 5-2 Expanded Non-Multiplexed Bus Timing ~HITACHI 189 r-MCURead rMCUWrite PIO - Pl7 2.0V PIG - P,.. O.8V p.O - p., Inputs p)O - P}1 All Data ) 24V Inpuls· Port Outputs _ _ _ _ _....J O~BV Data Valid ·Port 3 Non-Latched Operation Note) Port 2: Except P, I Fig. 5-3 Port Data Set-up and Hold Times Fig. 5-4 Port Data Delay Times (MCU Read) (MCU Write) .ov Add,." - - - " ,.-+----.... ,.-+---- 8u. 053------....:.:., ' .. -'n-::.=f'-,.,.__.,-_->/....... Inpun ...::;~ ___ • Access matches Output Strobe Select (055 = 0, a read; 055 = I, a write) Fig. 5-5 Port 3 Output Strobe Timing Fi g. 5-6 Port 3 Latch Timing (Single Chip Mode) (Single Chip Mode) '.4V Timer Counter I:'~~~l'~~~:: )-----=-<1 Data Valid __ ~2;;.;'O..;.V O.SV 1"'=~-------r O.SV P" Output Fig. 5-8 Mode Programming Timing Fig. 5-7 Timer Output Timing m Vee RL =2.2kn (4.0kfl for E) Test POint 152074 ,j..t, or Equ,v C R C 90pFforP Io -P3?P. O - p."SC\,SC 2 30 pF for PIO - P17, P10 - P,.. '" 40pFforE R ,2 kn Fig. 5-9 Bus Timing Test Loads (TTL Load) ~HITACHI 190 6. APPLICATIONS 6.1 Use of External Expanded Mode The HD630lVl supports five operation modes 1, 2, 4, 5 and 6 as external expanded modes. Usage of these modes is detailed in the following parag~aphs. (1) Non-multiplexed modes (a) Mode 1 (New Mode) In this mode, port 3 works as data bus, port 1 as lower address bus address bus (Ao - A7), and port 4 as upper (As - AlS). Since l6-bit addresses are sent out in parallel, the HD630lVl can access to a 65k memory space with no address latch externally under this mode. I HD630lVl Meu Et- Ao"vA7 As"vAl 5 Do"vD7 R/W 8 8 8 ROM I RAM I PIA I GPIA I PTM I Address Address Data Bus Bus Bus (LSB) (MSB) Fig. 6-1-1 HD6301V1, Mode 1 ~HITACHI 191 In the case when a write operation is performed to the internal memory including I/O and registers, the same data is also written into the external memory located by the same address if a memory exists. In the case when a read operation is performed to the internal memory, however, only a data of the internal memory is read and no external data pointed by the same address is read. Read/write operation to the internal/external memory with the internal memory address range is also applied to the mode 2, 4, 5 and 6. Under this mode, the internal mask ROM of which location is $FOOO through $FFFF to address is no more access able and an external memory can be accessed with this address range. After reset, Port 1 is a lower addiess bus (Ao - A7), Port 4 is a upper address bus (Ae - A1s). (b) Mode 5 (Equivalent to Mode 5 of HD6801V) Port 3 works as data bus; and port 4 as address bus (Ao - A7) or input pin by DDR. In this mode, pin 39 provides the result of the following decoding: This output signal may be used as a chip select or chip enable signal permits to access an external memory up to 256 byte locations ($0100 - $OlFF). The pin function of Port 4 can be changed from an address line to an input port in the case that the system does not need all of the 8 address lines by writing zero into the corresponding bit of Port 4 DDR. An example of connection with PIA (HD6821, HD6321) is shown in Fig. 6-1-2. 192 Do'VD7 8/ Do'VD7 8 PA o'V PA 7 8 Ao RSo PBo'VPB7 Al RS 1 HD630lVl Az CSo HD6821 =:q~ddres~1 A7 " decoder CSI HD6321 vee CAl CB I ~ IRQA CA z IRQ IRQB CBz lOS CSz E R/W E R/W I I t I I Fig. 6-1-2 Connection of HD6301V1 with PIA (2) Multiplex Modes (Modes 2, 4 & 6) Any mUltiplex mode provides a time multiplexed address and data on port 3. Therefore, an address latch is required externally. AS (pin 39) signal is used for an address latch strobe. An example is illustrated in Fig. 6-1-3 to show how CMOS latch is used with the HD6301V1. It should be noted, however, that the output address from this latch is delayed. ~HITACHI 193 HD14508B 7fr[l MR DIS Address buses P3) Do Qo Ao to A7 P 31 D1 Q1 P32 D2 Q2 P33 D3 Q3 HD6301Vl P~ Do Qo P35 D1 Q1 p$ D2 Q2 P37 D3 Q3 STASTB ~ AS I Data buses Do to D7 c Fig. 6-1-3 CMOS Latch For high-speed operation, 74LS373 or high speed CMOS latch (74HC373) is desirable to minimize the delay time. (a) Mode 2, 4 (Equivalent to Mode 2 of HD6801V) In this mode, the internal mask ROM (~FOOO through $FFFF) is disabled and external memory becomes valid instead. Port 4 works as the upper address bus. (b) Mode 6 (Equivalent to Mode 6 of HD6801V) In this mode, the internal mask ROM is enabled. Port 4 works as address bus (As - A1S) input. Since Port 4 becomes input mode after reset, "I" must be written into DDR by program if it is required to use the port as address buses. ~HITACHI 194 I Address Data Bus Bus Fig. 6-1-4 HD6301V1 MCU Expanded Multiplex Mode 6.2 Standby Mode Bringing STBY "Low", the HD6301V1 goes into the Standby mode. In this mode, the CPU becomes reset and all clocks of the HD6301V1 become inactive. The contents of the internal RAM is retained as long as VCC is supplied (VCC ~ 2V). Under Standby Mode, memory back-up is possible with only a few \lA of leakage current. With "1" level at STBY pin, the MCU exits from Standby Mode. When "1" level is 'detected at STBY pin, a clock generator begins to oscillate and the internal reset condition is released. At this time, RES signal should be set at "0" level for at least OSC stabilization time (t RC ) before the CPU operation restarts. Otherwise, the normal operation is not guaranteed. A typical flowchart to use a Standby Mode is shown in Fig. 6-2-1. ~HITACHI 195 l.Store the contents of registers into RAM (if necessary) aSet each bit in RAM Control Status Register to RAME="O", STBY="l" PWR Restart Routine 3. SLP executed Test and judge STBY bit in RAM Control Status Register " l" : VCC was supplied. "O":V was not CC supplied. Fig. 6-2-1 Flowchart of Standby Mode Application $ HITACHI 196 The timing relationship shown in Fig. 6-2-2 must be satisfied. NMI , ,,, , IS RES' ~, 15 , RESl 1* I (\ STBY t--k I I II STBYl : ' I I I 1*, I II I I I , Restart .---- NMI:Routine I .----. ,, I ~I: , I : , I I 0 Register Save Oscillator Stabilization Time 0 RAM Control Status Register Bits set Fig. 6-2-2 Timing Chart of Each Signal * Either RESl or STBYl can become "a" level as long as the execution time of NMI routine is guaranteed. Fig. 6-2-3 shows an example of a circuit to implement the timing sequence shown in the Fig. 6-2-2. System power line To other device of the system ~----------------~NMI STBYI Switc~ 1 Rl« R2. HD6301Vl R . C »20ms r r Fig. 6-2-3 Example of Circuit Diagram for a Standby Operation ~ ~HITACHI 197 The Standby power bit in the RAM control status register detects that VCC is supplied or not. When the VCC rise time is equal or less than 100~s, the Standby power bit may not be cleared. To avoid this, the VCC rise time should be more than 100~s, for example, by using the larger bypass capasitor. 6.3 Address Trap, OP-Code Trap Application The H06301Vl facilitates two trap functions, the operation code trap and the address trap, to protect the H06301Vl to proceed an erroneous operation. The operation code trap is a trap when an operation code currently fetched is illegal or undefined. Therefore, when undefined codes listed below are fetched, a trap is caused and the H06301Vl avoids further erroneous operation. The priority level of the interrupt caused by this operation code trap is next to the RESET. Undefined codes of the H06301Vl are: $00, $02, ~03, $12, $13, $14, $15, $lC, $10, $lE, $lF, $41, $42, $45, $4B, $4E, $51, $52, $55, $5B, $5E, $87, $8F, $C7, $CO and $CF. The address trap is a TRAP when an operation code is fetched from the memory area shown in Table 2-3-1. It should be noted, however, this function works only under op-code fetch (not for data access). Under the support of error processing program in trap service routine, the user can protect the system from further erroneous operation. If RTI instruction is executed at the end of the trap service routine, the program control returns to the location where the trap is caused previously and then another trap may be caused again. So, please take special care when a programmer uses this trap function. ~HITACHI 198 6.4 Slow Memory Interface Here described is the example of clock width cantrall circuit and its timing chart, where E-clock high time is extended to assure enough access time. The expanded enable high pulse width (PW'EH)' which is implemented by using the circuit shown below, is calculated as follows: where n I t 4- CS AS R/W l 4D 30 20 40 30 20 ~ CE ti.r--'~ 10 10 E r - I-- Gl-GZ CK $OOOO'V$7FFF HN6l256 7T CS: Active-high HD6301Vl (Mode 6) LS173 CE: Active-low * The detail of this circuit is described in Fig. 6-4-1. Fig. 6-5-4 PW'EH Fig; 6-5-5 HN61256 Read Timing ~HITACHI 204 In this example, PW EH of which timing is extended by using the clock control circuit (Fig. 6-4-1) must be at least 4 ~s. The LS173 is to assure enough address set up time (t AS ) of HN6l256. 6.6 Interface to the Realtime Clock (HD1468l8) The HD1468l8 (realtime clock + RAM : RTC) isa CMOS micro- computer peripheral LSI that incorporates the clock and calendar functions to compute year, month, day, day of week, and time. When this HD1468l8 is interfaced to the HD6301Vl, this LSI provides a real time clock information to be I displayed. In addition to the real time clock function of the HD1468l8, this device also be utilized as a system interval timer and a square waves generator. An example of the interface between the HD146818 and the HD6301V1 is shown in Fig. 6-6-1. It can be interfaced under the expanded multiplexed mode (mode 4 or 6) of the HD6301Vl. ~HITACHI 205 SQWt----; .nr Port 4 B bits 8 I/O Portl .-I ~ CS Lines A< co .-I o SC2 R/W R/W .-i CV') co ~ 2 \0 Cl E DS , H 6 DAY OF WK 06 C\l s:: -r! 7 DATE OF MON 07 III 50-byte 8 MONTH 08 user RAM 9 YEAR 09 10 Control register A OA ,, 1""1 .... _"- _ _ 1 register B ~: \"..vu .... .L..U..L 631 13F \E 13 ~----------------------------------------------------------- Control register C Control register D ~ I Fig. 6-6-2 HD146818 Built-in RAM Address Map ~HITACHI 206 Table 6-6-1. HD146818 Time, Calendar, & Alarm Data Display Data range Data range (Hexadecimal) Address Function (Decimal) Binary data BCD data mode mode 0 SECONDS 0 to 59 00 to 3B 00 to 59 1 SECONDS ALARM 0 to 59 00 to 3B 00 to 59 2 MINUTES 0 to 59 00 to 3B 00 to 59 3 MINUTES ALARM 0 to 59 00 to 3B 00 to 59 4 HOURS 12-hour 1 to 12 01 to OC/ 01 to 12/ mode 81 to 8C* 81 to 92* 24-hour 0 to 23 00 to 17 00 to 23 mode 5 HOURS 12-hour 1 to 12 01 to oci 01 to 12/ ALARM mode 81 to 8C* 81 to 92* 24-hour 0 to 23 00 to 17 00 to 23 mode 6 DAY OF THE WEEK 1 to 7** 01 to 07 01 to 07 7 DAY OF THE MONTH 1 to 31 01 to lF 01 to 31 8 MONTH 1 to 12 01 to DC 01 to 12 - 9 YEAR 0 to 99*** 00 to 63 00 to 99 [Notes] *: The most significant bit differentiates bet.ween AM and PM. That is, 0 = AM and 1 = PM. **: 1 Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, and 7 = Saturday ***: This takes the lower two digits of the calendar year. The information of the calendar and the time are stored on the built-in RAM and updated every second. The built-in RAM includes not only the display RAM but also 50-byte user RAM which stores data necessary for the system. The HD6301Vl gets the calendar and time information by reading the built-in RAM of the HD146818. The HD146818 generates three different types of interrupts, update interrupt, alarm interrupt and periodic interrupt, to the HD6301Vl. The HD6301Vl proceedes a service for each of these interrupt requests by a software control. ~HITACHI 207 Such a combination of the HD6301Vl and the HD1468l8 easily implements a compact real time system with reduced power dissipation. Note: For details of the HD1468l8, refer to "HD1468l8 Data Sheet" . 6.7 Reference Data of Battery Service Life Fig. 6-7-1 shows the battery service life taken from a silver oxide battery: SR44w (by Hitachi Maxe11). ---------- : Estimated 3000 ,1'\ 2590 I" '" ~ H ;::l o .r:: 720 300 '" ..... , ,, ,, , , (!) 4.; ,, ·ri H ,, ,, (!) ,, .~ 100 :> H (!) , , U) ,, " , 30 , I I 10 I I I I 6070 250 600 6000 Current (]JA) Fig. 6-7-1 Battery Service Life (Maxe11 SR44w) ~HITACHI 208 7. PRECAUTIONS 7 .1 Write-Only Register When a write-only register such as the DDR of the port is read by the MPU, "$FF" always appears on the data bus. Note that when an instruction which reads the memory contents and does some arithmetic operation on the contents of the write-only register, it always gets $FF as the arithmetic and logical results. AIM, OIM and ElM instruc- tions are unable to apply especially for the bit mani- pulation of the DDR of the I/O port. 7.2 Address Strobe (AS) The AS signal is used as an address latch strobe and is always accompanied with the E-clock. This means the AS is available in both Operation and Sleep Mode whenever the E-clock is generated. The AS signal is disabled in Mode 5, 7 or under Standby Mode and the Pin 39 is used for other purposes in these cases. 7.3 Mode 0 This mode is used for the test purpose only. It is not recommended to use this mode for the other purposes. 7.4 Trap Interrupt When executing an RTI instruction at the end of the inter- rupt routine, trap interrupt different from other inter- rupts returns to the address where the trap interrupt was generated. Attention is necessary when using several trap interrupts in the program. See Fig. 7-4-1 and 7-4-2 for details. ~HITACHI 209 B FFOl OPn FF02 Operand FF03 Undefinition OPn+l C FF04 ~ "'" Fig. 7-4-'1 Fetching an Undefined Op-code After executing OPn instruction, the HD6301Vl fetches and decodes an undefined op-code inside to generate a trap interrupt. When RTI instruction is executed in this trap interrupt servicing routine, the HD6301Vl will set $FF03 in PC, fetch the undefined code again, generate a trap interrupt and repeat ABC endless-loop. FF02 BSR FF03 01 FF04 OPn Fig. 7-4-2 Fetching Erroneously After performing BSR instruction, the branch destination address is output on an address bus to fetch the first op-code of a subroutine. If $0001 is output as an address by some mistake the HD6301Vl decodes it inside and generates a trap interrupt. When RTI instruction is performed in this trap interrupt servicing routine, the HD6301Vl will set $0001 in PC and start from this address, which causes a trap interrupt again and repeat this endless-loop. ~HITACHI 210 7.5 Power-on Reset At power-on it is necessary to hold RES "low" to reset the internal state of the device and to provide sufficient time for the oscillator to stabilize. Pay attention to the following. * Just after power-on, the MPU doesn't enter reset state until the oscillation starts. This is because the reset signal is input internally, with the clocked synchroniza- tion as shown below. 1 ~ ~ RES pin Internal reset signal D Q D Q Inside the LSI Fig. 7-5-1 Reset Circuit Thus, just after power-on the LSI state (I/O port, mode condition etc.) is unstable until the oscillation starts. If it is necessary to inform the LSI state to the ex- ternal devices during this period, it needs to be done by the external circuits. 7.6 Precaution to the Board Design of Oscillation Circuit As shown in Fig. 7-6-1 there is a case that the cross- talk disturbs the normal oscillation if signal lines are put near the oscillation circuit. When designing a board, pay attention to this. Crystal and CL must be put as near the HD6301Vl as possible. @HITACHI 211 .. .. .'" .'" ~ c ~ c iii iii, CL : ,, ~~i XTAL ,, , ,pel EXTAL H06301Vl Do not use this kind of print board design. 30-----' Fig. 7-6-1 Precaution to the Board HD6301Vl Design of Oscillation Circuit (Top view) Fig. 7-6-2 Example of Oscillation Circuits in Board Design 7.7 Application Note for High Speed System Design Using the HD6301V1 This note describes the solutions of the potential problem caused by noise generation in the system using the HD6301V1. The CMOS ICs and LSls featured by low power consumption and high noise immunity are generally considered to be enough with simply designed power source and the GND line. But this does not apply to the applications configured of high speed system or of high speed parts. Such high speed system may have a chance to work incorrectly because of the noise by the transient current generated during switching. The noise generation owing to the over current (Sometimes it may be several hundreds rnA for peak level.) during switching may cause data write error. This noise problem may be observed only at the Expanded Mode (Mode 1, 2, 4, 5 and 6) of the HD6301V1. The Single Chip Mode (Mode 7j of the HD6301Vl has no such a problem. Assuming the HD6301V1 is used as CPU in a system. 7.7.1 Noise Occurrence If the HD6301V1 is connected to high speed RAM, a write error ~HITACHI 212 may occu~ As shown in Fig. 7-7-1 the noise is generated in address bus during write cycle and data is written into an unexpected address from the HD6301Vl. This phenomenon causes random failures in systems whose data bus load capacitance exceeds the specification value (90 pF max.) and/or the impe- dance of the GND line is high. E \ / \ AS / \ / Rm (SC, 1 \ I A. -Au (Port 41 X A-- Noise X ----_'X Do-D, (Port 31 < >-- Fig. 7-7-1 Noise Occurrence in Address Bus During Write Cycle If the data bus Do ~ 0 7 changes from "FF" to "00", extremely large transient current flows through the GND line. Then the noise is generated on the LSI's VSS pins proportioning to the transient current and to the impedance (Zg) of the GND line. Do-~-;I-< , I 63~2 HD _ _---I Fig. 7-7-2 Noise Source This noise level, Vnl appears on all output pins on the LSI including the address bus. Fig. 7-7-3 shows the dependency of the noise voltage on the each parameter. ~HITACHI 213 Vn: Noise Voltage Zg: GND Impedance Cd: Data bus load capacitance N: Number of data bus lines switching from H to L Fig. 7-7-3 Dependency of the Noise Voltage on each Parameter 7.7.2 Noise Protection To avoid the noise on the address bus during the system operation mentioned before, there are two solutions as follows: The one method is to isolate the HD6301Vl from peripheral devices so that peripherals are not affected by the noise. The other is to reduce noise level to the extent of not af- fecting peripherals using analog method. (1) Noise Isolation Addresses should be latched at the negative edge of the AS signal or at the positive edge of the E signal. The 74LS373 is often used in this case. r---------~-.Do-D, LS373 Ao - A, G HD6301Vl P 40 - P471------1---+1':/ A----/ AI -- Au AS ' " Additional Latch 174LS373 for noise isolation) ~HITACHI 214 2. Noise Reduction As the noise level depends on each parameter such Cd, VCC' Zg, the noise level can be reduced to the allowable level by controlling those analog parameters. (a) Transient Current Reduction (i) Reduce the data bus load capacitance. If large load capacitance is expected, a bus buffer should be in- serted. (ii) Lower the power supply voltage VCC within specifi- cation. (iii) Increase a time constant at transient state by insert- ing a resistor (100 ~ 200~) to Data Buses in series to keep noise level down. Table 8-1 shows the relationship between a series resistors and noise level or a resistor and DC/AC characteristics. R Di~~---- R=O f'O '/0'8V~: o I R=100n ------------ 1---- > 5: ~R=200n '0 Z 0.5 ~ ~~ng : V~ : R: Series Resistor OL-------.-----~.-------- 50 100 Cd (pF) Data bus load capacitance Fig. 7-7-4 *Note: The value of series resistor should be carefully selected because it heavily depends on each parameter of actual application system. Fig. 7-7-5 shows the typical wave form of the noise. E pin A. pin Fig. 7-7-5 ~HITACHI 216 (b) Reduction of GND line impedance (i) Widen the GND line width on the pe board. (ii) Place the HD630lVl close by power source. (iii) Insert a bypass capacitor between the Vee line and the GND of the HD630lVl. A tantalum capacitor (about I O.l~F) is effective on the reduction. ~~------'--------'------'---~'r---- Power Source ~~-------L------~~------~~r----- (Recommendedi ~~ ~ ~~ Power Source ________ ________L -______ recommended) Fig. 7-7-6 Layout of the HD6301Vl on the PC Board ~HITACHI 217 APPENDIX I. EPROM ON PACKAGE HD63POIM1 1. Overview The HD63P01M1 is an 8-bit CMOS single-chip microcomputer unit, which can use 4k bytes or 8k bytes of EPROM on the package instead of internal ROM. The HD63P01M1 can be used to debug or emulate the HD6301V1 for software development. And also it can be used in low-volume production. (1) Features • Pin Compatible with HD6301V1 • On Chip Function Compatible with HD6301V1 128 Bytes of RAM 29 Parallel I/O 2 Lines of Data Strobe 16 Bit Programmable Timer Serial Communiction Interface 2 Interrupt Pins • Low Power Consumption Mode Sleep Mode, Standby Mode • Minimum Instruction cycle Time lp.s (f=1MHz) • Bit Manipulation, Bit Test Instruction • Protection from System Upset Address Trap, Op-Code Trap • Applicable to 4k or 8k Bytes of EPROM 4096 Bytes HN482732A 8192 Bytes : HN482764, HN27C64 II. 1.5 MHz & 2 MHz Operation in Single Chip Mode of HD63P01M1 HD63P01M1 now in mass production is guaranteed to be operated in 1 MHz. But if it satisfies the conditions belo~ it can be operated in up to 2 MHz. Note (1) Only single chip mode (mode 7) is available. Note (2) The access time is limited when the operating frequency is more than 1 MHz. So, use the EPROM which satisfies the condition belo~ While operating in 1.5 MHz, the access time must be less than or equal to 400 ns. While operating in 2 MHz, the access time must be less than or equal to 250 ns. Note (3) Temperature Range : Ta=ooC-70oC Operating Voltage : Vcc=5V±10% Note (4) This data is only for reference, and does not guarantee this characteristic. ~HITACHI 218 (2) Pin Arrangement o OVcc OA 12 OA, OA. I OA. OA. Al1 0 OA 3 Vss 0 OA2 A,. 0 OA, CE 0 OA. 0, 0 00. O. 0 00, O. 0 002 O. 0 OVss 03 0 (Top View) (NOTE) EPROM is nol included. (3) Dimensional Outline eDC-40P 50.28 (1.980) I e 20 O.25~:~ (O.OIO~:::::) Note) Inch value indicated for your reference ~HITACHI 219 (4) Block Diagram p •• P" p.. P" P" p .. P.. P" r------------- 1 I A<> AI As As As As Ai A, EPROM Ai Ai A,. HN482732AJ A"I Alii HN482764 HN27C64 llE"1 I I I 0.1 0,1 0. 1 Data 0.1 Input 0. ' 0. ' I 0.1O'I--~____~ IL _ _ _ _ _ _ _ _ _ _ ...II ~HITACHI 220 (5) Memory Map and Operation Mode The operation mode of the HD63P01Ml is similar to the HD6301Vl. As for the memory map, EPROM address space is 8k Bytes ($EOOO to $FFFF) in the HD63P01Ml, while ROM address space is 4k Bytes ($FOOO to $FFFF) in the HD6301Vl. HD63P01Ml0 Mode HD63P01Ml Mode 1 Multiplexed Test mode Non-Multiplexed ;Partial Decode $0000 11 I $0000 Internal Registers Internal Registers $001 F F"'=""'="9 $001F External Memory Space External Memory Space $0080 $0080 Internal RAM Internal RAM $OOFF $OOFF External Memory Space External Memory Space EPROM $FFFF L-________,; [NOTES] INOTE] 1 J Excludes the following addresses which may be Exctudes the follOWing addresses which may be used externally: $04, $05, $06, $07 and $OF. used externally; $00, $02, $04, $05, $06, $07 21 Addresses $FFFE and $FFFF are considered and $OF. external if accessed within 4 cycles after a positive edge of RES and internal at all other times. 3) After 4 CPU cycles, there must be no overlap- ping of internal and external memory spaces to avoid driving the data bus with more than one device. 4) This mode is the only mode which is used for testing. (to be continued) ~HITACHI 221 HD63P01M12 HD63P01M14 HD63P01M15 Mode Mode Mode Multiplexed/RAM Non·Multlplexed/Partial Decode $0000 Internal Registers Internal Registers SOOIF E xter nat Memory Space $0080 S0080 ) Internal RAM Internal RAM SOOFF SOIOO SooFF } External Memory Space -"T'"-- SOl F F ...... External Memory Space $EOOO EPROM SFFFF ~_ _ _..... , SFFFF Internal Interrupt Vectors (NOTEI Excludes the following address which (NOTEI Excludes S04, S06, SOF. may be used externally: $04, $05, $06, These address cannot be used $07,$OF. externally. (to be continued) ~HITACHI 222 HD63P01M16 HD63P01M17 Mode Mode Multiplexed/Partial Decode Single Chip Internal RegLsters Internal Registers $OO1F External Memory Space S0080 Internal RAM $OOFF External Memory Space $EOOO $EOOO EPROM EPROM Internal Interrupt Vectors Internal Interrupt Vectors $FFFF $FFFF [NOTE[ Excludes the followmg address which may be used externally: $04, $06, $OF. ~HITACHI 223 2. Precautions to Use the HD63P01Ml (1) Precaution to Emulate the HD6301Vl by HD63P01Ml Please use 4k bytes of EPROM address space located from $FOOO through $FFFF. But do not use 4k bytes from $EOOO through $EFFF because these addresses are internal for the HD63P01Ml, while these are external for the HD6301Vl. (2) Precaution to Use the EPROM On-Package 8-bit Single Chip Microcomputer Please pay attention to the followings, since this MCU has special structure with pin socket on the package. (a) Don't apply high static voltage or surge voltage over MAXIMUM RATINGS to the socket pins as well as the LSI pins. If not, that may cause permanent damage to the device. (b) When using 32k EPROM (24 pin), insert it on the mark side and let the four above pins open. / 4 Pins (On index side) open. 24 Pin EPROM should be inserted on the mark side with 4 above open. (C) When using this in production like mask ROM type single chip microcomputer, pay attention to the followings to keep the good contact between the EPROM pins and socket pins. (i) When soldering the LSI on a print circuit board, the recommended condition is Temperature : lower than 250°C Time : within 10 sec. (ii) Note that the detergent or coating will not get in the socket during flux washing or board coating after soldering, because that may cause bad effect on socket contact. ~HITACHI 224 (iii) Avoid permanent application of this under the condi- tion of vibratory place and system. (iv) The socket, inserted and pulled repeatedly loses its contactability. It is recommended to use new one when applied in production. Ask our sales agent about anything unclear. I ~HITACHI 225 II PROGRAM DEVELOPMENT PROCEDURE AND SUPPORT SYSTEM 1. Overview The cross assembler and the hardware emulator using various types of computer are prepared by the company as supporting systems to develop user's programs. User's programs are mask programmed into the ROM and delivered as the LSI by the company. Fig. II-1 shows the typical program design procedure and Table II-l shows the system development support tool for the HD6301Vl which are used in these processes. Text Editor/CRT Editor Host computer Cross Assembler Host computer Emulator EPROM on-chip LSI, H06,3701VOC EPROM on-package LSI, H06,3P01Ml Fig. 11-1 Program Design Procedure (Explanation) Q) When the user programs the system using the HD6301Vl series, a functional assignment of each I/O pin and an allocation of RAM area should be specified adjusting to designed system before actual programming. GD A flowchart is designed to implement the functions and it is coded by using the HD6301Vl mnemonic code. ~HITACHI 226 GD Write the software coded according to the flowchart on a floppy disk to make a source program. QD Assemble the source program to generate an object program I using a computer. Assembly errors are also detected. ~ Verify the program through hardware emulation with an emulato~ EPROM on-chip or EPROM on-package type microcomputer. ~ Send the completed program to the company in the form of EPROM. Send "Single-chip microcomputer order specifica- tion" and "Mask option list" at that time. G) ROM and mask option are masked by the company. LSI is testatively produced and the sample is handed in to the user. If a user doesn't see any problem in programming, mass production can be started. ~HITACHI 227 Table II-l Support Tools Part Emulator EPROM on- EPROM on-chip LSI Pro~ram- EPROM on- IBM PC IBM PC No. chip LSI ming Socket Adapter package LSI cross assembler C Compiler HD6301Vl, H31MIX4 HD63701VOC H31VSAOIA HD63POIMl S31IBMPC US31PCLI1SF HD6303R, (HS31VEML04H) HD6303Rl HD6301Vl and HD6303R Development Tools ~HITACHI 228 2. Single Chip Microcomputer ROM Ordering Procedure (1) Development Flowchart Single chip microcomputer device is developed according to the following flowchart after program development. Hitachi Customer Remarks (DROM code *1 *1 2 sets of EPROM @ Mask Option List *2 I *2 Part specific Q)ordering Specifica- *3 Generic for Hitachi tions *3 microcomputers Computer processing I V *4 The same ROM code as ROM code for confirma- submitted tion of ROM fabricating specifications *4 *5 Send it back after approving OK I~ Verification Listing t I *5 *6 3 pcs Mask I *7 Start the following flowchart after approving *8 Send back signed working sample approval form Sample I *9 10 pcs Working Sample (WS) l *6 I ! ® Confirmation of func- tion, characteristics *7, *8 OK + Engineering Sample (ES) l *9 I Confirmation of func- tion, characteristics, quality 1 I Commercial Sample (CS) I (E~) (Note) Please send in CD , ®, and ® at ROM ordering, and send back ~ , ® after approvin·;J. Device Development Flowchart ~HaTACHI 229 (2) Data you send and precautions (a) Ordering specifications ----- Common style for all Hitachi single chip microcomputer devices. Please enter as for the followings. The format is shown in the next page. o Basic ITEM o Environment Check List o Check List of attached data o Customer (b) ROM code Please send in the ordering ROM code by 2 sets of EPROM the same contents are written. Enter ROM code No. in them. It is de- sirable to send in program list for easy confirmation of the program contents. (3) Change of ROM code Note that if you change the ROM code once sended in or other specification, the ROM must be developed from the beginning. The cost of mask charge should be provided again in this case. (4) Samples and Mass production (Working Sample) ----------- Sample for confirmation of the contents of ROM code and that of mask option. Normally 3 samples are sent, but not guarante~d as for reliability. Please evaluate and approve immediately because the following sample making and mass production are set about after obtaining your evaluation. (Engineering Sample) ------- Sample for evaluating also re- liability. 10 pcs are included in mask charge. ~HITACHI 230 (Conunercial Sample) -------- Samples for pre-production which maybe purchased separately. (Mass Product) ------------- Products for actual mass produc- tion. Please enter the plan of mass production in full. I ~HITACHI 231 II 2.5. HD6301Vl ORDERING SPECIFICATIONS (1) GENERAL CHARACTERISTICS (Fill in blank space or check appropriate box 0.) Customer Package Outline (See page 183.) DDP-40 D CP-44 Device Type DFP-54 D CP-52 Application DCG-40 (be specific) Customer Options/Remarks: ROMCodeID ZTAT TM DYes D No Conversion ROM Code DEPROM Must Specify: Customer Programmed Start Address Media OZTATTM Customer Programmed Stop Address Operating Temperature o Standard D J (-40· C to +85· C) version if offered Remask DYes 0 No Previous Hitachi PIN (2) OPERATING CHARACTERISTICS (Fill in blank space or appropriate box 0.) LSI Ambient Typical ·C Target Level Of Reliability D 1000 Fit D( ) Temperature Range ·C- ·C D 500 Fit LSI Ambient Typical % Acceptable Electrical Quality D 0.25% l J < ) Range %- Major D 0.65% D< ) Humidity % Level Vi.",,, 1 Power On Typical Hours/Day LSI Operating Speed Duration (SJl~cifyMHz or KHz) Remarks: Power Max. V Maximum Applied Suoolv Voltage To LSI I/O Max. V (3) ELECTRICAL CHARACTERISTICS (Fill in blank space or check appropriate box 5J .) o Purchasing Specifications o Hitachi's Standard Specifications Refer To Data Sheet: ( For Hitachi Use Only) (4) CUSTOMER APPROVAL (5) ROM CODE VERIFICATION Customer Name,_ _ _ _ _ _ _ _ _ _ _ _ _ __ LSI Type No. PO# _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ___ Shipping Date of Approved By (print),_ _ _ _ _ _ _ _ _ _ _ ___ ROM To Customer Approved By (signature) Approved Date of Date ROM From Customer ~HITACHI 232 III Q & A Theme QUllstion Answer Process to Use When using an I/O port as an output, Store the data to the Data Register at first and then set a Port as an is the data stored to the Data DDR (DDR=l); if not, unknown data is output from the Outputs Register or is the Data Direction port. Register (DDR) set at first? Relation between How are writing into the timer Free The source of the clock input to the SCI Shift Registers Writing into the Running Counter(FRC) and the Serial is the timer FRC. FRC and SCI Communication Interface(SCI) related? Therefore, if new data is written into the FRC, SCI Operation operations are disturbed. See the following diagram. $09,$OA /W ~ :I ~ ~ E JL FRC ...J1.. Baud Rate - - - Genera tor Receive Shift] Register I o Transmit Shift1 Register :I * A write into the FRC is prohibited during SCI operations. Writing into the Is it prohibited to write data into Yes. If data is wri~ten into the FRC during serial FRC during Seria the Free Running Counter (FRC) during receive/transmit, the FRC stops counting up and the baud Receive/Transmit serial receive/transmit? rate changes. In condition other than serial receive/transmit, it's possible to write. N .. (,) (,) I\) ~ Theme Question Answer $09, $OA ~te Receive Shift EJL _ ,JcIJl Baud Rate Generator Register I Transmit Shift Register ------l I 1 II i~ n L...-...J r1' - - - The counter stops and the baud rate changes. ~ RDRF State When I What is the state of the Receive Data When the wake-up flag is set (WU=l) the RDRF flag cannot be set. (RDRF=O) SCI Receiving Register Full(RDRF) flag when the :I HD6301Vl/HD6303R SCI can receive ~ signals (RE=l) and the wake-up flag (WU bit) is set? (') TRCSR :I 765 432 1 0 $0011 I RDRFIORFEITDREIRIE IRE ITIE I TE I wu I + ? t1 + 1 Theme Question Answer Serial I/O The serial I/O does not operate Just after the initialization of serial I/O, the data Operation satisfactorily. Initialization does transmit is not operative during 10 cycles of Baud Rate not seem to be wrong, but the data is after setting the TE. The reason is as follows. not transmitted. What is wrong? Setting the transmit enable bit (TE bit) causes ten consecutive "I" of preamble and makes the transmitter Initialize by User Program section operative. In other words, the transmitter (1) Set the Rate/Mode Control Register section gets ready after one frame (10 bits) transmitt- (RMCR) to the desired operation. ing time according to the Baud rate. (2) Set the Transmit/Receive Control (ex.) When the Baud rate is set to 9600 Baud (104.2vs Status Register (TRCSR) to the at 1 bit) , desired operation. Set the Baud rate Set TE Transmit OK '7hfi//Il//T~/lITfl//////Zl ____ u o ____ ~ ~104.2vs x 10=1.042ms:- • ~: Transmit Inoperative Period ~ Preamble Causing Period 1.042ms after setting the TE, the transmitter section I: is operative. ~ (') Serial I/O Register Read When transmitting the data, is reading the Transmit/Receive Control Register The TORE flag shows if the TORE register is empty or not. When writing a data to the TOR with TORE=l, it's (TRCSR) required? not necessary to check the TORE. But reading the TORE :I When the transfer interval is long enough flag tells us the contents of TOR. For example, when compared with the Baud rate, Transmit new data is written to the TOR with TORE "0" (TOR Oata Register Empty (TORE) will be set. already has a data); the old data will be erased. In that case, are there any problems When the transfer interval is long enough compared with when transmitting data without checking the Baud rate, there's no problem. However, check the TORE flag in the TRCSR? TRCSR if possible. I\) W 01 -- ~ Q) Theme Question Answer Detection of the HD6301Vl Serial (1) What is the relation between the (1) The serial sampling clock frequency is eight times the Start Bit HD6301Vl serial sampling clock baud rate. frequency and the baud rate ? (2) "Sampling error" means receive margin at the serial (2) What does "Sampling error" mean ? operation time. Receive margin: The HD6301Vl detects the start bit and samples the data bit using the falling edge of the sampling clock. The general equation is shown as follows. 1.) General equation M= [(0.5-1/N) - (D-0.5)/N- (L-0.5)F] x 100 (%) M: Receive margin • N: Ratio of baud rate to sampling clock (0 to 0.5) D: Duty of the longer sampling clock of "B", and "LII :r: L: Frame length (7 to 12 bits) ~ F: Absolute value of deviation of sampling clock fr~uency (') 2.) Abbreviated equation :r: M = (0.5-1/N) x 100 (%) Conditions: D = 0.5, F 0 N 8 16 32 64 Note M 37.5 43.75 46.875 48.4375 In the HD6301Vl, N=8. (%) (Fig.l) Figure 1 12345678 Clock I I!----J--'- - - - - - l Rx { r : 50% : Start bit lIN Start bit sampling Tr~er J r 0.5 1 Theme Question Answer Free Running When the FRC of the HD6301Vl/HD6303R is The FRC of the HD6301Vl/HD6303R contains a parallel Counter Read read with the double byte load instruc- temporary register. When the high byte of the FRC is tions (2 cycle execution for FRC read- read, the low byte is set in the temporary register. ing), is it read correctly? The Low byte data in the temporary register is set to Double byte load instructions require the AccD at the next cycle. Therefore, it is possible two cycles to be executed and the cycle to read the FRC correctly. to read the low byte of FRC becomes the next cycle of the high byte. Is it OK ? ,IHlg . h Read'I Low Read'I E (EX) I I I I : High Read: Low Read: , I FRC ,-- I $F7 FF --,, $F8 00 , E FRC ($09, $OA) :(1 cycle) : $F7FF : (2 cycle): : $F800 Temporaly Register I : ---, 'FF, 1--- ! I I 'T '::::t..I I ' ~ Read Data I $F7 $FF : AccD F7 00 , I t *, :I AccD 1F7 : FFI', ~ (When reading $F7FF from the counter) (When reading $F7FF from the counter) " :I Preset Method of What is the difference between the The FRC preset method of the HD6801V is different from the Free Running HD6801V and HD6301Vl in writing data the HD6301Vl. Counter into the free running counter ? Type Preset Method HD6801V The FRC is always preset to "$FFF8". HD6301Vl 1. Writing to the high byte presets the FRC to $FFF8. 2. The FRC is set to desirable data by a double byte store instruction. rv CAl -..J -- ~ Q) Theme Question Answer (1) The HD6801V Preset Method I I I I$09Write I $OAWrite: #$5AF3 :.. ($5A) -:.. ($F3)-' $09 E I I FRC $FFF8 $FFF9 $FFFAl- The FRC is always preset to $FFF8. (2) The HD6301Vl Preset Method 1. $FFF8 $09Write LDD #$5AF3 ~ E I.. ($5A) I ..I I ... .. I I -STAA $09 J: ~ (') PRC I $FFF8 ,I Writing to the high byte presets the FRC to $FFF8. $FFF9: I $FFFAl- I J: 2. Optional valve (In this case$5AF3) ~09write ..:...$OAWrit5: _LDD #$5AF3 I ($5A) , ($F3) I STD $09 , I I E I I PRC $FFF8 $5AF3 I $5AF41- The FRC is set to desirable data ($5AF3) by a double byte store instruction. Strobes (AS) in I Output of Address Is AS always output when using the HD6301Vl in the expanded multiplexed Yes. AS is always output in the expanded multiplexed mode, even when the MPU accesses the internal RAM, ROM, the Multiplexed mode (mode 2, 4, 6)? etc. Mode Theme Question Answer IRQl Acceptance (1) Is IRQl ignored when the Condition (1) If the Condition Code Register I mask is set, IRQl Code Register I mas~ is set? is completely ignored. (2) After the I mask is reset, will (2) With the I mask set, the interrupt request flag will the interrupt sequence start by not be latched. the interrupt request flag having been latched? (1) (2) Reset starts Reset starts CLI 1=1 SEI IRQl IRQl ~ :I ~ IRQl is ignored. IRQl is ignored. C') Timer Interrupt In the routine below, when is the The next timer interrupt is accepted in the main routine :I and External next timer interrupt accepted? just after RTI instruction execution. Interrupt Main Timer (OCI) External Routine Routine Interrupt Main Timer (OCI) External Interrupt (Execution time (IRQ) Routine Routine Routine (IRQ) Routine =1.5ms) (Execution time=3ms) Read the TCSR Store 2.6ms at timer Inter- per iod to the OCR Execution time is longer than rupt V Next Timer Inter- l\. r---..... .1 • timer in ter- rupt per iod. I=1 Request Next Timer rupt (OCI) Routine Request RTI I\) w (0 -- I\) Theme Question Answer t) IRQl Interrupt IRQl pin (pin 5) is held at low for (1) IRQl is a level sensitive interrupt pin which needs and Other lO~s but an interrupt does not occur. a minimum of 2 machine cycles (2~s at IMHz) to accept an Interrupts What should be done to generate an interrupt. However, if another interrupt has been interrupt sequence? already generated, no interrupt request is accepted with IRQ! at low for lO~s. In such a case, IRQ! should be held at low until the request is accepted. E ~J--lL-- IRQl :I E 1 :; I I IRQl I I lO~s . I :I'I~· I P: ~2 I machine cycles~ I (2) In this case, as a timer interrupt is executed the interrupt mask is automatically set. So IRQl is ignored. ~ See the followings for the illustration of IRQ 1 and other interrupts and a countermeasure. :I IRQl and Other Interrupts ~ o Main Routine Timer Routine IRQl Routine :I IRQ! Interrupt Request ~",""'1. I ~ ~I=l IRQ! is . . . . . . .1 ignored. Countermeasure Clear the I mask at the beginning of the timer interrupt routine. Main Timer IRQl Routine Routine Routine ~ ~ IRQl is acceptable. *CLI : Clears the interrupt mask {I=O}. Wi th this method, note the following ; (1) IRQl may be ignored when the request occurs during timer interrupt vectoring. (2) Interrupts form NMI or SWI are excluded. Theme Question Answer CLI Instruction In the HD6301Vl, a timer interrupt To accept an interrupt, two machine cycles are necessary and Interrupt is not accepted in the following between CLI and SEI. That is, in this program, two NOP Operation program. Is there any problem? instructions are necessary. The same thing can be said --~---:--I when using TAP for CLI and SEI. Maln Routlne I Using CLI Using TAP LOl CLI I NOP I-LOl CLI TAP (Clears the I mask) SEI I NOP NOP 1 I NOP NOP I I SEI TAP (Sets the I mask) I BRA LOl I 1 1_ _ _ _ _ _ _ 1 I I BRA LOl 1 Relation between With which edges of the EXTAL clock It changes synchronously with the falling edge q) of the ~ the External Clock (EXTAL does the E clock change synchronously, rising edge (tl or falling edge (.)? EXTAL clock. 1: Clock) and ~ (") Enable Clock (E Clock) ~XTAL~ J: Constants of the iDoes the capacitor of the recommended Capacitor Cr does not have upper limit because of the Reset Circuit reset circuit in the HD6303R (HD6301Vl) Schmitt trigger circuit provided with the RES. have an upper limit? Available if Rr.Cr»20ms To the system power supply ~ ~I f I~ III~ f ~;;; Rr+ INMI Vee I r;:,.... STBYl m l ~ .... , STBY IV-- + RS mCS Rr RESI~l J P" -14 ...L. C r To HD6301V peripherals I\) .. RIC: R2,RroCr»20ms ~ t Theme \Question Answer Port Output What data does a port output when the After resetting, since the Data Register of a port is After Resetting Data Direction Register(DDR)=1 undefined, undefined data is output when the DDR=I. after resetting? Input definite data by programming in the Data Register before setting the DDR=I. Schmitt Trigger Is the Schmitt trigger circuit Yes. Circui t of STBY provided with the HD630lVI STBY? • % ~ C) Return from Standby Mode What occurs when returning from the standby mode without using RES? The CPU does not operate normally because the contents of each register are not definite. Therefore, always use the RES when returning from the standby mode. % Going into the Does the CPU go into the standby mode No. Because there is no connection between the instruc- Standby Mode after current instruction execution tion execution sequence and the standby mode. That is, is completed? when the STBY pin goes into "Low", the state is latched at the next rising edge of E clock. Then the internal registers are reset at the next falling edge. ! - - Internal registers : are reset. E I I I STBY I I t Theme Question Answer Timing for the The timing for the standby mode is After the RAM Control Register is set in the NMI routine, Standby Mode shown in the HD630lV user's manual. either STBY or RES can be in the low state with no TI is not defined. How long is TI? priority. © NMI~ '2" -RE-S :-,- ,_ _ _ _---J ICJ I,~ T I L-'- ______ == L....... ....;r- ® STBY I II ' ~ , I I - I ~ j+- ~T2~ RAM Control ,I- Register set Reset Start T2 Oscillation Stabilization Time ~ Usage of EPROM Socket Pins for Are the data buses of the EPROM socket pins for the HD63POIM bi- The data bus output from EPROM socket pins for the HD63POIM is Read only. J: the HD63POIM directional in order to access not o~ (No.!) only the EPROM but the RAM? J: Usage of EPROM In EPROM socket pins for the HD63POIM, CE is a NAND circuit of the address bus (A13 to A15) and Socket Pins for what is CE composed of? the MCU internal R/W signal. the HD63POIM (Refer below.) (No.2) Therefore, CE does not output in the dummy cycle. (When not accessing EPROM of HD63POIM) I-~rw-I- r---I I I I I I Ao I I I I I I I I Au I I I Al .. l~ I I CE I ,I___A1S !I . I____ J ~ -- t Theme Question Answer Usage of EPROM With EPROM socket pins for the (1) The current of each pin is too little to drive one Socket Pins for HD63P01M, TTL load. the HD63POlM (1) Can pins drive one TTL load or (2) Each pin can drive one NMOS load. (No.3) more? (2) If not, what can pins drive? Usage of Bit How the bit manipulation instructions They are written as follows; Manipulator of the HD6301V should be written? Instructions OIM # $ 0 4 , $ 1 0 (Direct Addressing) OIM # $ 0 4 , $ 1 0 , X (Index Addressing) T Immediate Data T~ Address Index Register • l: ~ (') This is an example of OR operation of the immediate data and the memory and storing the result in the memory. The HD6301V has the following bit manipulation instructions. OIM AIM (IMM) • (M) - (M) (IMM) + (M) - (M) l: ElM TIM (IMM) e (M) -(M) (IMM) • (M) These instructions are written in the same way. The following bit manipulations have different mnumonics in the same OP code. Bit Manipulation Instruction OP code I Mnumonics . Function o "Mi 71161 A I M B C L R 1 The memory bit i(i=O to 7) is cleared and the other bits don't change. l .. Hi' The memory bit i(i=O to 7) is 72 1 62 o I M B SET set and the other bits don't change. Theme Question Answer Mi +Mi The memory bit i(i=O to 7) is 75 I 65 E I M B T G L inverted and the other bits don I t change. 1 . Mi AND operation test of the memory bit i(i=O to 7) and 7B I 6B TIM B T S T "1" is executed and its corresponding condition code is changed. t _____ Direct Index Addressing Addressing ~ The mnumonics mentioned above can be written as follows. :I BCLR 3,$10 ~AIM #$F7, $10 (Direct Addressing) ~ BCLR 3,$10,X~AIM #$F7, $lO,X (Index Addressing) C') BSET 3,$10 ~OIM #$08, $10 (Direct Addressing) :I BSET 3,$10,X~OIM #$08, $lO,X (Index Addressing) TT~ Bit Address Index Register ..,.. I\) 01 ~ I\) -I>- Theme Question Answer Ol Usage of Bit Are the bit manipulation instructions It can be used if the port is in the output state Manipulation (AIM, OIM, ElM, TIM) executable when (DDR=l). However, the bit manipulation instruction Instructions to a port is in the output state is executed as follows the Port (DDR=l)? 1 Reads specified address. 2 Executes logical operation. 3 Writes the result into the specified address. Since the specified address(l) reads the pin state of the port, the data is influenced by the pins even if any data is output from the port. RAM Access When executing a program with the RAME (1) The external RAM can be accessed; the internal RAM Disable during bit of the RAM Control Register is neither readable nor writable when the RAME bit Program disabled, is disabled. ~ Execution :I (1) What occurs if the internal RAM (2) If there is no stacking area other than the internal address is accessed? RAM, the MPU will burst when returning from the ~ (') (2) What occurs if the interrupt requests are generated? interrupt sequence. :I HD6301 iHD6303 SERIES HANDBOOK Section Four I HD63701V User's Manual ~HITACHI 247 ~HITACHI 248 Section 4 HD63701 V User's Manual Table of Contents Page 1. OVERViEW ................................................... . 251 1.1 Features of HD63701 VO ...................................... . 251 1.2 Block Diagram .............................................. . 251 1.3 Functional Pin Description .................................... . 252 2. INTERNAL ARCHITECTURE ..................................... . 253 2.1 Mode Selection ............................................. . 253 2.2 Memory Map ............................................... . 258 2.3 CPU Registers .............................................. . 263 2.4 2.5 2.6 2.7 Ports ...................................................... . Timer ..................................................... . Serial Communication Interface ................................ . Interrupts .................................................. . 265 269 273 281 I 2.8 Reset ..................................................... . 283 2.9 Oscillator .................................................. . 285 2.10 Strobe Signals .............................................. . 286 2.11 RAM Control Register ........................................ . 287 2.12 Low Power Consumption Mode ................................. . 287 2.13 TRAP Function ............................................. . 292 3. EPROM (PROM) PROGRAMMING AND TECHNICAL SPECIFICATIONS .. . 293 3.1 PROM Mode ................................................ . 293 3.2 ProgrammingNerification ..................................... . 294 3.3 Erasure ................................................... . 295 3.4 On-Chip PROM Characteristics and Application ................... . 296 3.5 Instruction Set Overview ...................................... . 300 3.6 Addressing Modes ........................................... . 300 3.7 Instruction Set .............................................. . 302 3.8 Instruction Execution Cycles ................................... . 307 3.9 System Flowchart ........................................... . 313 3.10 Pin Arrangement and Package Information ....................... . 315 3.11 Electrical Characteristics ...................................... . 316 ~HITACHI 249 4. APPLICATIONS................................................. 322 4.1 Use of External Expanded Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 4.2 Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... 327 4.3 Address Trap, OP-Code Trap Application. . . . . . . . . . . . . . . . . . . . . . . . . . 330 4.4 Slow Memory Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . 331 4.5 Interface to HN61256. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 332 4.6 Interface to the Realtime Clock (HD146818). . . . . . . . . . . . . . . . . . . . . . . . 337 4.7 Reference Data of Battery Service Life ....................... . . .. 340 5. PRECAUTIONS................................................. 341 5.1 Write Only Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. ·341 5.2 Address Strobe (AS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 341 5.3 Mode O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 341 5.4 Trap Interrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 341 5.5 Precaution to the Board Design of Oscillation Circuit . . . . . . . . . . . . . . .. 343 5.6 Application Note for High Speed System Design Using the HD63701 VO . 343 5.7 Differences between HD6301V and HD63701V . . . . . . . . . . . . . . . . . . . .. 347 APPENDIX I. Support Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 353 II. Q & A............................. ................. ........ 355 ~HITACHI 250 1. OVERVIEW 1.1 Features of HD63701VO The HD63701VO provides the following features: - Compatible with the HD6301V - Expanded instruction set of the HD6801 family - Abundant on-chip functions compatible witth the HD6801/ HD6301 family: 4k-byte of EPROM, 192-byte of RAM, 29 parallel I/O Lines, 2 data strobe Lines, 16-bit time~ serial communciation interface - Low power consumption mode: sleep/standby mode I - Minimum instruction execution time: l~s (f = 1MHz) , 0.67~s (f=1.5MHz)! 0.5~s (f=2MHz) - Bit manipulation and bit test instruction - Error detection: Address trap and op-code trap - Address space up to 65k words - Wide operation range: f = 0.1 to 2.0MHz (Vee = 5V ± 10%) - TTL compatible input/output 1.2 Block Diagram A block diagram of HD63701VO is given in Fig. 1-2-1. PROM MODE Fig. 1-2-1 HD63701VO Block Diagram ~HITACHI 251 1.3 Functional Pin Description Table 1-3-1 lists the pin functions. Refer to "2. INTERNAL ARCHITECTURE" for more details. Table 1-3-1 Pin Functions Pin Function Vec, VSS Power supply and GND pins XTAL Crystal connection pin. When external clock is used, input it to EXTAL EXTAL, and XTAL should be open. RES Reset input pin. When this pin is asserted "Low", MCU is set to reset state. STBY Standby input pin. When this pin is asserted "Low", MCU is set to standby state. NMI Edge sensitive (negative edge) non-maskable interrupt input pin. IRQ 1 Level sensitive maskable interrupt input pin (active Low). E System clock output pin. The frequency is 1/4 of the crystal oscillator frequency. P,o/TIN 5-bit I/O port Timer input-capture input pin P,,/TOUT Timer output-compare output pin P'2/SCLK SCI clock I/O port P, ,/RX SCI receiving pin P'4/ TX SCI transmitting pin Following pins function depending on each operation mode PORT 1 Mode 0,2 8-bit I/O port Mode 1 Lower address 8-bit (Ao"'A,) Mode 5 I/O port - Mode 6 - Mode 7 - - Data (00",0, ) Oata (Do"'O, ) Lower address Lower address Data Bus (Ao",A,) PORT 3 (Ao"'A,) 00",0, Mul tiplexed Multiplexed Bus Bus Lower address Upper address PORT 4 Upper address (As"'AlS) .. (Ao"'A,) or Input-only (As"'A,S) or Input-only 8-bit I/o port pin pin ~ Address strobe I/O strobe Address strobe I!!E,!!t strobe SC l (AS) output (TIiS) output (AS) output (IS3) output pin pin pin pin - - Read/write O~ut strobe signal SC 2 ~ (OS) output (R!W) output pin pin ~HITACHI 252 2. INTERNAL ARCHITECTURE This section describes the HD63701VO internal architecture. 2.1 Mode Selection After the MCU is reset, a user must determine the operation mode of the HD63701VO by strapping three pins and which are connected by hardware externally. Individual signals on the above three pins are latched into the program control bits PC2, PCl and PCO of I/O port 2 Data register, when the RES signal goes "High". of the Port 2 Data Register is shown below. Port 2 Data Register The bit assignment I $0003 7 6 5 4 3 2 1 0 IpC2lpCllpcolI/0 411/0 311/0 211/0 111/0 01 An example of an external circuit for mode selection is shown in Fig. 2-1-1. The HD14053B may be used to separate the MCU from its peripheral devices during reset (Data confliction should be avoided between the peripheral devices and mode selection circuit). Because bits 5, 6 and 7 of port 2 are for read only, so the operation mode cannot be altered by software. The mode selection in the HD63701VO is summarized in Table 2-1-1. The HD63701VO has three basic operation modes: 1) Single chip mode 2) Expanded multiplexed mode (Bus Compatible with HMCS6800 peripheral LSls) 3) Expanded non-multiplexed mode (Bus Compatible with HMCS6800 peripheral LSls) ~HITACHI 253 Truth Table Control Input On Switch Binary to 1-of-2 SeI.cl Decoder with Inhibit C B A HD14053B Inhibit 0 0 0 0 Za Yo X. 0 0 0 1 Zo Yo X, 0 0 I 0 Zo VI X. xoo---------------~~~~~__, 0 0 1 1 Zo V"' X, X,o-----------------~~~~~ x 0 I 0 0 Z. Yo X. yocr------------------~~+_r__. 0 1 0 1 Z, Yo X, y y,cr--------------------~~~~ 0 1 1 0 Z,VI X. Zocr--------------------~~+__, 0 1 1 I Z,V I X, Z Z,o-----------------------~--J 1 X X X - HD14053B Multiplexers/De-Multiplexers Vee ~ R RI RI R, 6 RES R J ... 8 X. C 8 HD6370,VO V. ·x p,. (PCOI V 9 ~ Z. P" (PC" P,. X, Z 10 P" (PC21 P" v, P" Z, HOl40538 Inh Note 1) Figure of Mode 7 1- ?? Jr C 2) RC"'Reset Constant Mode I Conltol 3) R, =10kn ~ SWitch Fig. 2-1-1 Recommended Circuit for Mode Selection ~HITACHI 254 Table 2-1-1 Mode Selection Summary Pn P" P,. Interrupt Bus Operating Mode (PC2) (PCI) (PCO) ROM RAM Vectors Mode Mode 7 H H H I I- I I Single Chip 6 H H L I I I MUX'" Multiplexed/Partial Decode 5 H L H I I I NMUX31 Non·Multiplexed/Partial Decode 4 H L L - - - - Not Used 3 L H H - - - - Not Used 2 L H L E'l I E MUX Multiplexed/RAM I L L H E'l I E NMUX Non·Multiplexed 0 L L L I I 121 MUX Multiplexed Test LEGEND: (NOTES) I - Internal 1) Internal ROM is disabled. E - External 2) Reset vector is external for 3 or 4 cycles after MUX - Multiplexed fj3 goes "high". I NMUX - Non·Multiplexed 3) Idle lines of Port 4 address outputs can L - Logic "0" be assigned to I"put Port. H - Logic "1" (1) Single Chip Mode In the Single Chip Mode, all ports will function as I/O. This is shown in figure 2-1-2. In this mode, SCi, SCz pins are configured as Port 3 control lines and functions as input strobe (IS3) and output strobe (OS3) for handshaking data respectively. (2) Expanded Multiplexed Mode In this mode, Port 4 is configured as I/O (inputs only) Port or address lines. Port 3 functions as multiplexed lower address/data bus and Address Strobe (AS) selects the function of Port 3. Port 2 is configured as a 5-bit parallel I/O port or Serial I/O, or Timer, or any combination thereof. Port 1 is configured as an 8-bit parallel I/O port. In this mode HD63701VO is expandable to 65k words (See Fig. 2-1-3). Since the data bus is multiplexed with the lower address bus in Port 3 in the expanded multiplexed mode, address bits must be latched outside. 74LS373 (Octal-D type transparent latches) is required for address latch. Latch connection to the HD63701VO is shown in Fig. 2-1-4. ~HITACHI 255 Vee Enable = Port 1 Port 3 8110 LInes 8110 Lines Port 4 Port 2 8 I/O Line, 51/0 Line. SCI Timer Vss Fig. 2-1-2 HD63701VO MCU Single-Chip Mode Vee Enable Port 3 Port 1 8 Lines 8 I/O lines Multiplexed Data/Address Port 2 Port 4 51/0 lines To 8 Address SCI Lines or To Timer 8 I/O lines (Inputs Only) Vss Fig. 2-1-3 HD63701VO MCU Expanded Multiplexed Mode ~HITACHI 256 GND , AS . 11 GDe ] D, 0, Pon J r 74LS373 -'.".- .. Function Table - Addreu/D.la l- OutPUt En.ble OutptJt Control G D 0 D, 0, L H H H . L H L L ]~,.-. L L X 0, H X X Z ~ . I Fig. 2-1-4 Latch Connection (3) Expanded Non Multiplexed Mode In this mode, the HD63701VO can directly address HMCS6800 peripherals with no address latch. In mode 5, Port 3 functions as a data bus. Port 4 is configured as Ao to A7 address bus or partial address bus and I/O (inputs only) port. Port 2 is configured as a parallel I/O port, Serial I/O port, Timer or any combination. Port 1 is configured as a parallel I/O port only. In this mode, the HD63701VO can access up to 256 bytes of external address space. In the application system with fewer addresses, idle pins of Port 4 can be used as I/O lines (inputs only) (See Fig. 2-1-5). In mode 1, Port 3 functions as a data bus, Port 1 functions as Ao to A7 address bus, and Port 4 is configured as As to A15 address bus. Port 2 is configured as a parallel I/O port, Serial I/O port, Timer or any combination. In this mode, the HD63701VO is expandable up to 65k words with no address latch. (See Fig. 2-1-5). ~HITACHI 257 Vee Vee POrt 1 Pori 3 Ponl Port 3 8 Parallel flO 8 Oala Lmes To 8 Address lines 8 Data Lines Port 2 Pon 4 Port 2 Port 4 5 Parallel I/O To 8 Address 5 Parallel 1/0 To SAddre" SC' Lines or To Timer Se' Lines 81/0 Lines Timer flnputs Only, Vss (al Mode 5 (b) Mode 1 Fig. 2-1-5 HD63701VO MCU Expanded Non Multiplexed Mode (4) Mode and Port Summary MCU Signal Description This section gives a description of the MCU signals for the various modes. SCI and SC2 function depending on the operating mode. Table 2-1-2 Feature of each mode and Lines PORT 1 PORT 2 PORT 3 PORT 4 SC, SC, MODE Eight Lines Five Lines Eight Lines Eight Lines SINGLE CHIP I/o I/O I/O I/O IS3 (I) OS3(01 ADDRESS BUS EXPANDED MUX (A.-A,I ADDRESS BUS' AS(OI RM(OI I/O I/o DATA BUS (A.-A"I (0.-·0,1 EXPANDED Mode 5 DATA BUS ADDRESS BUS' R/W(OI I/O I/o (0.-0,1 (A.-A;) 10S(0) NON-MUX Mode 1 ADDRESS BUS I/O DATA BUS ADDRESS BUS Not Used R/WiOI (A.-A,I (0.-0,1 (A,-A"I *These I ines can be substituted for I/O (Input Only) starting with the MSB (except Mode 0,2,4). When they are not used as address lines. I • Input 153 = I nput Strobe SC = Strobe Control o = Output 053 = Output Strobe AS = Address Strobe A/iiii = Aead/Wrl'ii 105 = 1/0 Select 2.2 Memory Map The MCU can address up to 65k bytes depending on the operating mode. Fig. 2-2-1 shows a memory map for each operating mode. The first 32 locations of eacb map are reserved for the MCU's internal register as shown in Table 2-2-1. ~HITACHI 258 Table 2-2-1 Internal Register Area R/W*4/Initialize at RESET Register Address 7 6 5 4 3 2 1 0 Port 1 Data Direction Register $00*1 W $00 Port 2 Data Direction Register $01 W $00 R/W *5 Port 1 Data Register $02*1 Undefined Port 2 Data Register/Mode Register $03 R *6 R/W *5 P2 2 PZ1 P20 Undefined Port 3 Data Direction Register $04*2 W $00 Port 4 Data Direction Regi ster $05*3 W $00 I R/W ~o Port 3 Data Register $06*2 Undefined R/W *5 Port 4 Data Register $07*3 Undefined R R R R/W R/W R/W R/W R/W Timer Control and Status Regi ster $08 0 0 0 0 0 0 0 0 R/W Counter (High Byte) $09 $00 R/W Counter (Low Byte) $OA $00 R/W Output Compare Regi ster (Hi gh Byte) SOB $FF R/W Output Compare Register (Low Byte) SOC $FF R Input Capture Register (High Byte) SOD $00 R Input Capture Register (Low Byte) $OE $00 R R/W Un- used R/W R/W Unused Port 3 Control and Status Register $OF*2 0 0 1 0 0 1 1 1 Rate and Mode Control Register $10 Unused W W W W 1 1 1 1 0 0 0 0 Transmit/Receive Control and $11 R R R R/W R/W R/W R/W R/W Status Register 0 0 1 0 0 0 0 0 Receive Data Register $12 R $00 Transmit Data Register $13 W $00 RAM Control Register $14 R/W R/W Unused *7 1 1 1 1 1 1 1 ~ Reserved $l!Yv$lF (*1 through 8 are shown in the next page.) $HITACHI 259 *1 External address in mode 1. *2 External address in modes 0, 1, 2, 5, 6; cannot be accessed in mode 5. *3 External address in modes 0, 1, 2, *4 R: Read-only register, W Write-only register, R/W : Read/Write register. *5 The pin state is read instead of the data of the register when reading Ports. (Refer to "2.4 I/O Ports" for I/O Port 3.) *6 The values of program control bit (PCo '" PC2) depend on P20 '" P21 during reset. *7 Refer to "2.12 Low Power Consumption Mode" for standby mode. HD63701VOQ Mode HD63701VO Mode 1 Multiplexed Test mode Non-Multiplexed $0000 111 Internal Registers Internal Registers SOOIF SOOIF External Memory Space EICternal Memory Space SOO8O Inlernal RAM Interna' RAM SOOFF EIe tern.1 Memory Space External Memorv Space Internal PROM 12 SFFFF .....- - _... ' [NOTES) [NOTEI Exclude. Ihe following .delre.... which may be 11 Excludes the following addresses which may u..d exlern.lly; $00. S02. $04. S05. $06. S07 be used externally: $04, $05, $06, $07 and and SOF_ $OF. 21 R_t vectors $FFFE and $FFFF are locat- ed in external memory address space. However, if $FFFE and $FFFF are accessed by soft- ware, Internal addresses will be accessad. 31 If internal address is read, the data in the address is output through the data bus_ 41 This mode is used only for testing. (to be conlinued) Fig. 2-2-1 HD63701VO Memory Maps ~HITACHI 260 HD63701VO Mode 2 HD63701VO Mode 5 Multiplexed/RAM Non·Mulliplexed/Partial Decode $0000 $0000 . .) Internal Registers Internal Registers SOOlF t::.-="i''''':.:<..:1 I SOOlF Un External Memory Space S0040 $0040 Internal RAM ~~~~~ In.emal RAM SOOFF ~ SooFF SOlOO ) External Memory Space SOl F F L - - - r - -.... I External Memor.y Space SFOOOra Internal PROM SFFFF L-_ _ _... , $FFFF {NOTEI Excludes the following address which {NOTEI Excludes $04, S06, SOF. may be used externally; S04, S05, S06, S07, $OF. These address cannot be used externally. (to be continued) Fig. 2-2-1 HD63701VO Memory Maps ~HITACHI 261 HD63701VO Mode 6 HD63701V07 Mode Multiplexed/Partial Decode Single Chip $0000 50000 Internal Registers Internal Registers SOOIF SOOIF External Memory Space S0040 $0040 Inlernal RAM Internal RAM SOOFF SOOFF EXlernal Memory Space SFOOD SFOOD Internlll PROM Internlll PROM SFFFF $FFFF [NOTE] Excludes Ihe following address which may be used externally: $04, $06, SOF. Fig. 2-2-1 HD63701VO Memory Maps ~HITACHI 262 2.3 CPU Registers The followings describe the HD6370lVO internal architectures and operations. ~ 15- - - A - - - - - °U 0 7 - - - - - • - - - 3 $L B·BI, Aceumul.,." A .nd • Or 16·BItDoubl. Accumulator 0 I" x 01 Index Ragilter (XI lIS so 01 Stack Pointer ISPI 115 PC 01 Program Counter (PC) 7 0 ~ I Condition Code Register (CCRI Carry/Borrow from MSa Overflow Z.ro Negative Interrupt Half carry (From Bit 3) Fig. 2-3-1 HD63701VO CPU Registers (I) Accumulators (A & B, or D) Two a-bit registers (ACCA and ACCB) store the result of arithmetic/logic.al operation and data. When combined, they make up a 16-bit register (ACCD) used for 16-bit operations. Note that the contents of ACCA and ACCB are modified after an ACCD-based operation. (2) Index Register (IX) The 16-bit register IX stores a 16-bit data for use in indexed addressing mode or for general purpose. (3) Stack Pointer (SP) The 16-bit register SP indicates the address of the next available location in the stack. This can also be used as a general purpose register. (4) Program Counter (PC) The 16-bit register PC indicates the address of the instruction being currently executed. Note that the PC cannot be accessed by software. ~HITACHI 263 (5) Condition Code Register (CCR) The CCR consists of the following bits: carry (C), overflow (V), zero (Z), negative (N), interrupt mask (I), and half-carry (H). After an instruction is executed-, these bits reflect the result of operation. They can be tested by different conditional branch instructions. The upper 2 bits of this register cannot be used. Individual bits are detailed below. Refer to the following description of each instruction for more details. (a) Half-carry (H) This bit is set to "1" if a carry occurs between bit 3 and bit 4 during execution of an ADD, ABA or ADC instruction; cleared otherwise. (b) Interrupt mask (I) When set to "1", this bit disables any maskable inter- rupt (IRQI, IRQ2). (c) Negative (N) After an instruction is executed, this bit is set to "1" if the MSB of the result is "1"; cleared otherwise. (d) Zero (Z) After an instruction is executed, this bit is set to "1" if the result is "0"; cleared otherwise. (e) Overflow (V) After an instruction is executed, this bit is set if the result of operation shows a 2's complement overflow; cleared otherwise. (f) Carry (C) After an instruction is executed, this bit is set to "1" if a carry or a borrow generates from MSB; it is cleared cleared otherwise. ~HITACHI 264 2.4 Ports The HD63701VO has four I/O ports (three 8-bit ports and one 5-bit port). 2 control pins are connected to one of the a-bit port. Each port has an independent write-only Data Direction Register to program individual I/O pins for input or output.* When the bit of associated Data Direction Register is "1", I/O pin is programmed for output, if "0", then programmed for an input. I Addresses of each port and associated Data Direction Register are shown in Table 2-4-1. * Only one exception is bit 1 of Port 2 which becomes either a data input or a timer output. It cannot be used as an output. Table 2-4-1 Port and Data Direction Register Addresses Data Direction Ports Port Address Register Address Port 1 $0002 $0000 Port 2 $0003 ~0001 Port 3 ~0006 $0004 Port 4 $0007 I $0005 (1) Port 1 Port 1 is an 8-bit I/O port, each bit being individually defined as inputs or outputs by the Port 1 Data Direction Register. The 8-bit output buffers have three-state capability, maintaining in high impedance state when they are used for input. These are TTL compatible and can drive one ~TL load and 90pF capacitance. After the MCU has been reset, all I/O pins are configured as inputs in all modes except mode 1. In all modes other than expanded non multiplexed mode 1, Port 1 is always parallel I/O. In mode 1, Port 1 is configured as output lines for lower order address lines (Ao to A7). ~HBTACHI 265 (2) Port 2 Port 2 has five lines, whose I/O direction depend on its Data Direction Register. The 5-bit output buffers have three-state capability, going high impedance state when used as inputs. After the MCU has been reset, Port 2 I/O pins are configured as inputs. P20 - P22 (pins 10 - 8) are used to program the operating mode. during reset. r The values of P20 - P22 during reset are latched into the upper 3 bits (bit 7, 6 and 5) of Port 2 Data Direction Register. Refer to "2.1 Mode Selection" for more details. In all modes, Port 2 can be configured as I/O lines. This port can also function as I/O pins for the SCI and the Timer. However, note that bit 1 (P21) is the only pin restricted to data input or Timer output. (3) Port 3 Port is an 8-bit port which can be configured as I/O Port, a data bus, or an address bus multiplexed with data bus. Its function depends on operation mode, determined by user using 3 bits of Port 2 during Reset. (Refer to 2.1 Mode Selection.) Port 3 as a data bus is bi-directiona1. This TTL compatible three-state buffer can drive one TTL load and 9 OpE; capacitance. In the expanded Modes, Data Direction Register is inhibited after Reset and data flow is contro1ed by the state of the R/W signal. Function of Port 3 for each mode is explained below. (a) Single Chip Mode (Mode 7): Parallel I/O Port, whose I/O direction are programmed by the Port 3 Data Direction Register. There are two control lines associated with this port in this mode, an input strobe (IS3) and an output strobe (OS3), both being used for handshaking. They are $ HITACHI 266 controlled by I/O Port 3 Control/Status Register. Additional 3 characteristics of Port 3 are summarized as follows: (1) Port 3 input data can be latched using IS3 (SCI) as a control signal. (2) 5Sl (SC 2 ) can be generated by MPU read or write to Port 3's data register. (3) IRQl interrupt can be generated by an YS1 falling edge. Port 3 strobe and latch timings are shown in Figs. 5-5 and 5-6, respectively. I/O Port 3 Control/Status Register Bit 0 Not used. Bit 1 Not used. Bit 2 Not used. Bit 3 LATCH ENABLE. Controls the input latch of Port 3. If the bit is set, the input data on Port 3 is latched by the falling edge of IS3. The latch is cleared by the MCU read to Port 3; it can be latched again. Bit 3 is cleared by a reset. Bit 4 ass (Output Strobe Select) Determines the cause of output strobe generation: a write operation or read operation to I/O Port 3. When the bit is cleared, the strobe will be generated by a read operation to Port 3. When the bit is set, the strobe will be generated by a write operation. Bit 4 is cleared by reset. Bit 5 Not used. ~HITACHI 267 Bit 6 IS3 ENABLE. If the IS3 flag (bit 7) is set with bit 6 set, an interrupt is enabled. Clearing the flag causes the interrupt to be disabled. The bit is cleared by reset. Bit 7 IS3 FLAG. Bit 7 is a read-only bit which is set by the falling edge or IS3 (SCI). It is cleared by a read of the Control/Status Register followed by a read/write of I/O Port 3. The bit is cleared by reset. (b) Expanded Non Multiplexed Mode (mode 1, 5) In this mode, Port 3 is configured as data bus. (c) Expanded Multiplexed Mode (mode 0, 2, 6) Port 3 is configured as either data bus (Do to 07) or lower a bits of the address bus (Ao to A7). An address strobe output is "High" when the address is on the port. (4) Port 4 Port 4 is an a-bit port that becomes either I/O Port or address bus depending on the operation mode selected. Each line is TTL compatible and can drive one TTL load and 90pF capacitance. After reset, this port becomes inputs. To use Port 4 as address bus, Port 4 pins should be programmed as outputs. Function of Port 4 for each mode is explained below. (a) Single Chip Mode (Mode 7): Parallel I/O Port, whose I/O direction is programmed by the Port 4 Data Direction Register. (b) Expanded Non Multiplexed Mode (Mode 5): In this mode, Port 4 becomes the lower address lines (Ao to A7) by writing "l"s on the Data Direction Register. When all of the eight bits are not required as addresses, ~HITACHI 268 the remaining lines can be used as I/O lines (Inputs only). (c) Expanded Non Multiplexed Mode (Mode 1): In this mode, Port 4 becomes output for upper address lines (As to A1S). (d) Expanded Multiplexed Mode (Mode 0, 2): In this mode, Port 4 becomes output for upper address lines (As to A1S) regardless of the value of Data Direction Register. The relation between each mode and ports 1 to 4 is summarized in Table 2-1-2. 2.5 Timer The HD63701VO provides 16-bit programmable timer which can measure input waveform and generate an output waveform. The pulse widths of both input/output can vary from micro- I seconds to seconds. microseconds to many seconds. The timer hardware consists of an a-bit Control and Status Register a 16-bit Free Running Counter a 16-bit Output Compare Register, and a 16-bit Input Capture Register A block diagram of the timer is shown in Figure 2-5-1. ..." 8il1 DO. r-·- -- - - - - _I ellnp.. , 1_, ~ ~':'O ""'12 """2 Fig. 2-5-1 Programmable Timer Block Diagram ~HITACHI 269 (l) Free Running Counter (FRC) ($0009:$000A) The key timer element is a l6-bit Free Running Counter (FRC), that is driven by E (Enable) clock to increment its values. The FRC value is readable by software at any time with no effects on the FRC. The FRC is cleared during reset. When writing to the upper byte of the FRC ($09), the CPU writes the preset value ($FFF8) into the FRC (address $09, $OA) regardless of the write data. But when writing to the lower byte ($OA) after the upper byte writing, the CPU writes not only the lower byte data into lower byte of the FRC, but also the upper byte data into upper byte of the FRC. The FRC value written by the double store instruction is shown in Figure 2-5-2. ($5AF3 written to ~he counter) Fig. 2-5-2 Counter Write Timing * A write to the counter can disturb serial opera- tions, so it should be inhibited during the SCI operation. (2) Output Compare Register (OCR) (~OOOB: $OOOC) The Output Compare Register (OCR) is a l6-bit read/write register which is used to control an output waveform. The data of the OCR is constantly compared with the FRC. When the data matches, a flag (OCF) in the Timer Controll Status Register (TCSR) is set and the current value of an output level Bit (OLVL) in the TCSR is transferred to Port 2 bit 1. When bit 1 of the Port 2 Data Direction Register is "1" (output) the OLVL value will appear on the bit 1 of Port 2. Then, the value of the OCR and Output level bit should be changed to control an output level again on the next compare values. @HITACHI 270 The OCR is initialized to $FFFF during reset. The compare function is inhibited at the cycle of writing to the upper bytes of the OCR and at the cycle just after that. It is also inhibited at the cycle of writing to the Free Running Counter. * For the data write to the OCR, 2-byte transfer instruc- tions such as STD, STX should be used. (3) Input Capture Register ($OOOD:$OOOE) The Input Capture Register (ICR) is a l6-bit read-only register used to store the FRC's value when the proper transition of an external input signal occurs as defined by the input edge bit (IED1) in the TCSR. The input transition change required to trigger the I counter transfer is controlled by the input Edge bit (IEDG) • To allow the external input signal to gate in the edge detector, the bit of the Port 2 Data Direction Register corresponding to bit 0 of Port 2 must have been cleared (to zero) . To insure input capture in all cases, the width of an input pulse requires at least 2 E clock cycles. (4) Timer Control/Status Register (TCSR) ($0008) This is an 8-bit register. All 8 bits are readable and the lower 5 bits can be written. The upper 3 bits are read-only, indicating the timer status information below. (a) Defined transition of the timer input signal causes the counter to transfer its data to the ICR. (b) A match has occurred between the value in the FRC and the OCF. (c) The counter value reached to $0000 by counting-up (TOF). @HHTACHI 271 Each of the upper three flags can generate an IRQ2 interrupt and is controlled by an corresponding enable bit in the TCSR. If the I-bit in the CCR has been cleared, a priori- tized vectored address occurs corresponding to each flag being set. Each bit is described as follows. Timer Control/Status Register (TCSR) 765 432 1 0 [!cF I OCF I TOF EICI I EOCI I ETOI IEDG I OLVL] $0008 Bit 0 OLVL (Output Level): When a match occurs between the FRC and the OCR, this bit is transferred to the Port 2 bit 1. If the DDR corresponding to Port 2 bit 1 is set to "1", the value will appear on the output pin of Port 2 bit 1. Bit 1 IEDG (Input Edge): This bit control which transition of Port 2 bit 0 input (P20) will trigger the data transfer from the FRC to the ICR. The DDR correspond- ing to Port 2 bit 0 must be cleared in advance of using this function. When IEDG = 0, data transfer is triggered on a falling edge ("High"-to-"Low" transition) of P20. When IEDG = 1, data transfer is triggered on a rising edge ("Low"-to-"High" transition) of P20. Bit 2 ETOI (Enable Timer Overflow Interrupt): When set, this bit enables TOF interrupt to generate the inter- rupt request (IRQ2); when cleared, the interrupt is inhibited. Bit 3 EOCI (Enable Output Compare Interrupt): When set, this bit enables OCF interrupt to generate the interrupt request (IRQz); when cleared, the interrupt is inhibited. ~HITACHI 272 Bit 4 EICI (Enable Input Capture Interrupt): When set, this bit enables ICF interrupt to generate the interrupt reguest (IRQ2); when cleared, the inter- rupt is inhibited. Bit 5 TOF (Timer Overflow Flag): This read-only bit is set when the counter value is $0000. It is cleared by CPU read of TCSR (with TOF set) followed by CPU read of the counter ($0009). Bit 6 OCF (Output Compare Flag): This read-only bit is set when a match occurs between the OCR and the FRC. It is cleared by read of TCSR (with OCF set) followed by CPU write to the OCR ($OOOB or $OOOC). Bit 7 ICF (Input Capture Flag): The read-only bit is set when an input signal to edge detector makes a transi- I tion as defined by IEDG. It is cleared by read of TCSR (with ICF set) followed by CPU read of the ICR ($0000). Each bit of TCSR is cleared during reset. 2.6 Serial Communication Interface (SCI) The HD63701VO contains a full-duplex asynchronous Serial Communication Interface (SCI). The SCI can select the several kinds of the data transmit rate and comprises a transmitter and a receiver which operate independently on each other but at the same data transmit rate. Both of transmitter and receiver communicate with the CPU by the data bus, and with the outside. through Port 2 bit 2,3 and 4. Descrip- tions of hardware, software, and the SCI registers are as follows. (1) Wake-Up Function In typical multiprocessor applications the software protocol has the destination address at the initial byte of the message. The purpose of Wake-Up function is to have the non-selected MCU ignore the remainder of the message. Thus the non-selected MCU can inhibit ~HITACHI 273 the all further interrupt process until the next message begins. Wake-Up function is triggered by a ten consecutive "l"s which indicates an idle transmit line. Therefore soft- ware protocol needs an idle period between the messages. With this hardware feature, the non-selected MPU is re- enabled (or "wakes-up") for the appearing next message. (2) Programmable Options The HD63701VO SCI has the following programmable features. data format; standard mark/space (NRZ) start bit + 8 bit data + 1 stop bit Clock source; external or internal baud rate; one of 4 rates per given MCU E clock frequency or 1/8 of external clock • wake-up function; enabled or disabled • Interrupt requests; enabled or masked individually for transmitter and receive data registers Clock Output; internal clock enabled or disabled to Port 2 bit 2 • Port 2 (bits 3,4); dedicated or not dedicated to serial I/O individually for receiver and transmitter (3) SCI Hardware The SCI hardware is controlled by 4 registers as shown in Figure 2-6-1. The registers include: • an 8-bit Transmit/Receive Control Status Register (TRCSR) • a 4-bit write-only Transmit Rate/Mode Control Register (RMCR) • an 8-bit read-only Receive Data Register (RDR) • an 8-bit write-only Transmit Data Register (TDR) Besides these 4 registers, the SCI utilizes Port 2 bit 3 (input) and bit 4 (output). Port 2 bit 2 can be used when an option is selected for the internal-clack-out or the external-clack-in. (4) Transmit/Receive Control Status Register (TRCSR) TRCSR consists of 8 bits which all may be read @HITACHI 274 while only bits 0 to 4 may be written. The register is initialized to $20 during RES. The bits of the TRCSR are defined as follows. Transmit/Receive Control Status Register (TRCSR) 765 432 1 0 I RDRF I ORFE I TORE RIE RE TIE TE WU ADOR: $0011 Bit 0 WU (Wake Up): Set by software and cleared by hard- ware on receipt of ten consecutive "l"s. It should be noted that RE flag has already set in advance of WU flag's set. Bit 1 TE (Transmit Enable): Set to produce preamble of ten consecutive "l"s and to enable the data of trans- mitter to output subsequently to the Port 2 bit 4 independently of its corresponding ODR value. When I cleared, the SCI affects nothing on Port 2 bit 4. Bit 2 TIE (Transmit Interrupt Enable): When set with TORE (bit 5) set, an IRQz interrupt is enabled. When cleared, IRQz interrupt is masked. Bit 3 RE (Receive Enable): When set, gates Port 2 bit 3 to input of receiver regardless of DDR value for this bit. When cleared, the SCI affects nothing on Port 2 bit 3. Bit 4 RIE (Receive Interrupt Enable): When set with bit 7 (RDRF) or bit 6 (ORFE) set, IRQ2 interrupt is enabled. When cleared, IRQz interrupt is masked. Bit 5 TORE (Transmit Data Register Empty): When the data is transmitted from the Transmit Data Register to Output Shift Register, it is set by hardware. The bit is cleared by reading the TRCSR (with TDRE set) and followed by writing the next new data into the Transmit Data Register. TDRE is initialized to 1 during RES. Bit 6 ORFE (Over Run Framing Error): When overrun or framing error occurs (receive only), it is set by hardware. Over Run Error occurs if the attempt is made to transmit the new byte to the receive data ~HITACHI 275 register with the RDRF still set. Framing Error occurs when the bit counters are not synchronized to the byte boundaries of the bit stream. The bit is cleared by reading the TRCSR (with ORFE set) followed by reading the RDR, or by RES. Bit 7 RDRF (Receive Data Register Full): It is set by hardware when the data is transmitted from the RSR to the RDR. It is cleared by reading the TRCSR (with RDRF set) and followed by reading the RDR, <;>r by RES. B,I 1 Rate end Mode Control Regluer Bit 0 I I I I I eel eeo SSI SSO 1$10 Transmit/Receive Control end Status Register IRDRFEAFEITDREI AlE I I I RE TIE TE I WU 1$11 Receive Date Register $12 Port2 I~~ ~___ I_I____ ~________~A~~~.I~W~S~h;~ft~R~••~;.~t.~,______.J Clock 10 Bit k---------------~ I-----E 2 ~ .x B't 4 12 _ _ _ _ _ _ _ _ Transmit Data Register Fig. 2-6-1 SCI Register 6 5 o eel eeo 5S1 SSO AD DR $0010 Rate I Mode Control Register Table 2-6-1 SCI Bit Times and Transfer Rates XTAL 2.4576 MHz 4.0 MHz 4.9152MHz SSI SSO E 614.4 kHz 1.0MHz 1.2288MHz 0 0 E.;. 16 26 1',/38,400 Baud 16 1',/62,500 Baud 13 jJ.S /76,800Baud 0 1 E.;. 128 208)J,/4,800 Baud 128 )Js/7812.5 Baud 104.2jJ.' / 9,600Baud 1 0 E.;. 1024 1.67ms/600 8aud 1.024m,/976.6 Baud 833,3jJ.s / 1,200Baud 1 1 E.;. 4096 6.67m,/150 8aud 4.096m,/244.1 Baud 3.333ms / 300Baud ~HITACHI 276 Table 2-6-2 SCI Format and Clock Source Control CC1, CCO Format Cloc~ Source Port 2 Bit 2 Port 2 Bit 3 Port 2 Bit 4 00 - - - - - 01 NRZ Not Used ••• .. .. Internal .. .. 10 11 NRZ NRZ Internal External Output* Input .. .. • Clock output is available regardless of values for bits RE and TE . •• Bit 3 is used for serial input If RE == "1" in TACS. Bit 4 is used for serial output if TE = "1" in TReS. ···'t con be used as 110 port. (5) Transmit Rate/Mode Control Register (RMCR) Transmit Rate/Mode Control Register (RMCR) controls the following SCI variables: ·Baud rate ·clock source ·Port 2 bit 2 function The RMCR is a 4-bit write-only register, cleared by RES . . The 4 bits are considered as a pair of 2-bit fields. The lower 2 bits control the bit rate of internal clock while the upper 2 bits control the clock select logic. Bit 0 sso 1 Bit 1 SSl J Clock Speed Select These bits select the Baud rate for the internal clock. The selectable 4 rates are function of E clock frequency within the MCU. Table 2-6-1 lists the available Baud Rates. Bit 2 CCOI Bit 3 CCI J Clock Control/Format Select These bits control the clock select logic. Table 2-6-2 defines the bit field. (6) Internally Generated Clock When using the SCI internal clock for external devices, the followings should be noted. The values of RE and TE have no effect • • CCl, CCO must be set to "10". The maximum clock rate is E/16. The clock is equal to the bit rate. (7) Externally Generated Clock When supplying an external clock for the SCI, the followings should be noted. ~HITACHU 277 The CCl, and CCO in the RMCR must be set to "11" (See Table 2-6-2). The external clock frequency must be set to 8 times the desired baud rate. • The maximum external clock frequency is half of E clock. (8) Serial Operations The SCI hardware must be initialized by the HD6370lVO software prior to operation. The sequence is normally as follows. Writing the desired operation control bits to the RMCR. Writing the desired operation control bits to the TRCSR. If using Port 2 bits 3 and 4 for the SCI exclusively, TE and RE bits may be preserved set. WhenTE and RE bits are cleared during the SCI operation, and subsequently set again, it should be noted that the setting of TE, RE must refrain for at least one bit time of' the current baud rate. If set within one bit time, internal function for transmit and receive may not occur. (9) Transmit Operation Data transmission is enabled by the TE bit in the TRCSR. When TE is set, outputs the data of the SCI Transmit Shift Register to Port 2 bit 4 which is unconditionally configured as an output irrespectively of the corresponding DDR value. Following RES, the user should program both the RMCR and the TRCSR for desired operation. Setting the TE bit during this procedure causes a trans- mission of ten-bit preamble of "l"s. Following the preamble, internal synchronization is established and the transmitter section is ready to operate. Then either of the followings operates. ~HITACHI 278 (a) If the TOR is empty (TORE = 1), the consecutive "l"s are transmitted indicating an idle lines. (b) If the data has been loaded into the TOR (TORE 0) , it is transferred to the Transmit Shift Register and data transmission begins. During the data transfer, the "0" start bit is first transferred. Next the 8-bit data (beginning at bit 0) and the "1" stop bit. When the TOR has been empty, the TORE flag bit is set. If the CPU fails to respond to the flag within the a proper time, TORE is preserved set and then a "1" will be sent (instead of a "0" at start bit time) consecutively until the data is supplied to the Transmit Oata Register. While the TORE remains a "1", no "0" will be sent. (10) Receive Operation The receive operation is enabled by the RE bit. The serial input is connected with Port 2 bit 3. The receive operation is determined by the contents of the TRCSR RMCR. The received bit stream is synchronized by the first "0" (space). During 10-bit time, the data is strobed approximately at the center of each bit. If the tenth bit is not "1" (stop bit), the system assumes a framing error and the ORFE is set. (RDRF is not set.) If the tenth bit is "1", the data is transferred to the RDR, with the interrupt flag set (RDRF). If the tenth bit of the next data is received, however, still RORF is preserved set, then ORFE is set indicating that an overrun error has occurred. After the CPU read of the TRCSR as a response to RDRF flag or ORFE flag followed by the CPU read of the ROR, RDRF or ORFE will be cleared. (11) Timer, SCI Status Flag The set and reset condition of each status flag of timer and SCI is shown in Table 2-6-3. ~HITACHI 279 Table 2-6-3 Timer and SCI Status Flag Status Flag Set Condition Reset Condition ICF FRC + ICR by edge input to P20. l. Read the TCSR then ICRH, when ICF=l 2. RES=O OCF OCR=FRC l. Read the TCSR then write to the OCRH or OCRL, when Timer OCF=l 2. RES=O TOF FRC=$FFFF+l cycle l. Read the TCSR then FRCH, when TOF=l 2. RES=O RDRF Receive Shift Register + RDR l. Read the TRCSR then RDR, when RDRF=l 2. RES=O ORFE l. Framing Error (Async hronous l. Read the TRCSR then RDR, Mode) when ORFE=l Stop Bit = 0 rnT ?, RES=O 2. Ov~rrun Error (Asynchronous Mode) Receive Shift Register + RDR when RDRF=l TDRE l. TDR + Transmit Shift Read the TRCSR then write to Register the TDR, when TDRE=l 2. RES=O The receive margin of the HD63701VO SCI is shown below. START 1 2 3 4 5 6 7 8 STOP Ideal Waveform I Bit length ~Character length TO------------------~.~I Real Waveform ~-----------------T--------------------~ Bit distortion tolerance Character distortion tolerance (t-to) Ito {T-To)/To +3.75% ±3 7.5% -2.5% ~HITACHI 280 2.7 Interrupts The HD63701VO has two external interrupt terminals (NMI, IRQ1) and 8 internal interrupt sources (Soft-TRAP, SWI, Timer-ICF, OCF, TOF, SCI-RDRF, ORFE, TDRE). The features of these interrupt are detailed in the following paragraphs. (1) Non maskable Interrupt (NMI) When the high-to low transition of NMI is detected, NMI acknowledge sequence starts. The current instruction is completed if NMI signal is detected as well as the follow- ing IRQl interrupt. Interrupt mask bit in the Condition Code Register has no effect on NMI interrupt. In response to NMI I interrupt, the contents of Program Counter, Index Register Accumulators, and Condition Code Register are pushed onto the stack. On completion of this sequence, the CPU generates vecotr addresses $FFFC and $FFFD, and loads the contents into the Program Counter and branch to a non maskable interrupt service routine. (2) Interrupt Request (IRQ1) IROl is the level-sensitive pin which requests an IRO, interrupt to the CPU. When IRQl interrupt request occurs, the: CPU will complete the current instruction before the acceptance of the request. If the I bit of the Condition Code Register is cleared, the CPU starts an interrupt acknowledge sequence; if set, the interrupt request will be ignored. When the IRQl acknowledge sequence starts, the contents of Program Counter, Index Register, Accumulator, and Condition Code Register are pushed onto the stack. Then the CPU sets the I bit to ignore another IRQl or IRQ2 interrupt request. At the end of the cycle, the CPU generates l6-bit vector addresses $FFFB and $FFF9, and loads the contents into the Program Counter to branch to an interrupt service routine. ~HITACHI 281 (3) Internal interrupts (IRQ2) When an internal interrupt is requested from the timer or SCI, an internal interrupt signal IRQ2 is activated. This interrupt is identical to IRQl except that it uses vector addresses $FFFO through $F~F7. The IRQl has the priority to the IRQ2 when interrupt requests occurs at the same time. When the interrupt mask bit in the condition code register is set, both interrupts are inhibited. The SWI is an instruction which requests an interrupt by software. The state of CCR mask bit doesn't influence the SWI. If an address error or op-code error (see "2.13 Error Processing") occurs, TRAP occurs whose priority is next to the reset. In the case of TRAP, CPU starts the interrupt sequence reqardless of the state of the mask bit. The vector for the TRAP interrupt are $FFFE and $FFEF. The interrupt sources and their corresponding vector are listed in Table 2-7-1 and the interrupt sequence are shown in Fig. 2-7-1. Fig. 2-7-2 shows the interrupt generation circuit. Table 2-7-1 Interrupt Vector Vector Upper Lower Interrupt Source Byte Byte Highest Priority FFFE FFFF RES FFEE FFEF TRAP FFFC FFFD NMI FFFA FFFB Software Interrupt (SWI) FFF8 FFF9 IRQl (or IS3) FFF6 FFF7 ICF (Timer Input Capture) FFF4 FFFS OCF (Timer Output Compare) FFF2 FFF3 TOF (Timer Overflow) Lowest Priority FFFO FFFI SCI (RDRF+ORFE+TDRE) ~HITACHI 282 Interrupt Test Intern.1 Addr~~-- __~-r~~~~~~~~~~~~~~~~h_ __ ~~ __ __ ____ __ ___J'-__ __ ~ ~ ~ ~ ~ ~~ NMI. IRQ,. IRQJ Intern.1 ----v--'r---v--,r--v--'"....---v----Ir"--"""----..,...--"""----..,...---v--,~--_v----..,... D.t.&n ____ __ ~ _J~ __ ~__ __ ___ J ' ___ ~~ ~ ____h___ ~____h___ ____h___~ __ __ ____ ~ ~ ~'_ ~ ~ PC8- IXO- IX8- ACCA Acca CCA Intern.1 PC1S IX7 IX15 Reod Internel Write I \ Fig. 2-7-1 Interrupt Sequence ICF TOF EICI ETO' OCI ICI IlceR bit 5) I RORF ORFE RIE Interrupt Request Signal TORE TIE iS3 FLAG IRQ, IRQ I Sleep NMI Release NMI Signal TRAP SWI-----------------------------------------J Fig. 2-7-2 Interrupt Generation Circuit 2.8 Reset (RES) This input is used to reset the MCU and start it from a power-off condition. During Power-on, RES pin must be held "Low" for at least 20ms. To reset the MCU during system operation, RES must be held "Low" for at least 3 system clock cycles. All address buses become "High impedance" state while RES is "Low". When RES is brought "high" again, the MCU operates as followings. @HRTACHI 283 (1) Latch I/O Port 2 bits 2, 1, and a into bits PC2, PC1, and pca of the Port 2 Data Register. (2) Load the contents (=start address) of the last two addresses ($FFFE, $FFFF) into the program counter and start the program from this address. (Refer to Table 2-7-1) (3) Set the interrupt mask bit. For the CPU to recognize the maskable interrupts IRQl and IRQz, this bit should be cleared in advance. Fig. 2-8-1 shows the reset timing, and Table 2-8-1 shows the pin condi- tion during reset. When RES is asserted "Low", all I/O pins enters into reset mode (high impedance state) asynchronously to the E clock while the MCU enters into the reset mode synchronously to the E clock. Both the MCU and I/O pins recover from reset mode synchronously to the E clock. :;'...... _~\\\\'Wl\\\\\\\\\\\\\\\ '>---v---\ '~~~l--------- ... :;'.' -~\\\\\\\\\\\\\\\\\\\\\\ :~~I ~1II:J~I$~tllMl~~m~MmI~II~'~----------------'~~r;--------- Fig. 2-8-J Reset Timing ~HITACHI 284 Table 2-8-1 Pin Condition during RESET ~Pin 0 1 2 5 6 7 Port 1 PIO""P17 High impedance (input) . .. .. . .. port 2 P2 O"'P2 It High impedance (input) . . . .. . E:"l" output E: "1'1 output E:"l" output Port 3 High impedance E:"l" output High impedance E:"l" output High impedance E:"l" output P30"'P3' (input) (High impedance) (High impedance) (High impedance) Port 4 Pit O"'PIt 7 High impedance (input) of .. .. . . SC2 "1" output (READ) . .. .. .. "1" output SC, E:"l" output I E : High impedance • .. "1" output E: "1" output E: High impedance High impedance (input) 2.9 Oscillator XTAL and EXTAL pins interface with either an AT-cut parallel resonant crystal or external clock. four circuit internally divides the input frequency by four The on-chip divide-by- I to produce the system clock. For example, 4MHz of a crystal or external clock input corresponds to lMHz of system clock. When using a crystal, a 10-22 pF ± 20% capacitor should be tied from each crystal pin to ground. Alternately, EXTAL can be driven by external clock with 45% to 55% duty cycle. When external clock is input to EXTAL, XTAL should be left open. Fig. 2-9-1 shows an example of crystal interface and crystal spec if ica tion. ~HITACHI 285 AT Cut Parallel Resonance Crvstal Co = 7 pF max R, = 60!l max XTAL ck C LI • C L2 -10-22pF ± 20% 13.2-SMHzl EXTAL T lCL2 - Cll J;Jr Fig. 2-9-1 Crystal Interface 2.10 Strobe Signals Two pins, SCl (39 pin) and Se2 (38 pin) are used as the strobe signals in each mode. Followings are applied only to Port 3 in single chip mode. (1) Input Strobe (IS3) (SCI) This signal controls IS3 interrupt and the latch of Port 3. When the falling edge of this signal is detected, the IS3 flag of Port 3 Control Status Register is set. For respective bits of Port 3 Control Status Register, see the "2.4 Ports" section. (2) Output Strobe (OS3) (SC2) This signal is used by the processor to strobe an external device, indicating effective data is on the I/O pins. The timing chart for Output Strobe are shown in figure 6-5. The following pins are available for Expanded Modes. (3) Read/Write (R/W) (SC2) This TTL compatible output signal indicates peripheral and memory devices whether the CPU is in Read ("High"), or in Write ("Low"). The normal stand-by state of this signal is Read ("High"). This output can drive one TTL load and 90pF capacitance. (4) I/O Strobe (lOS) (SCI) In expanded non multiplexed mode 5 lOS becomes "Low" when A9 through A1S are "O"s and As is "1". This allows external device access located in $0100 through $OlFF in memory. The timing chart is shown in Figure 6-2. ~HITACHI 286 (5) Address Strobe (AS) (SCI) In the expanded multiplexed mode, address strobe is output to this pin. This signal is used to latch the J.', lower 8 bits addresses multiplexed with data at Port 3. The 8-bit latch is controlled by address strobe as shown in Figure 2-1-4. Thereby, I/O Port 3 can functions as data bus while E is "high". The timing chart of this signal is shown in Figure 6-1. 2.11 RAM Control Register The register located in the memory address $0014 gives a status I information about standby RAM. RAM Control Register 7 6 5 4 3 2 1 o STBY x x $0014 PWR Bit 0 Not used. Bit 1 Not used. Bit 2 Not used. Bit 3 Not used. Bit 4 Not used. Bit 5 Not used. Bit 6 RAM Enable. Using this control bit, the user can disable the RAM. RAME bit is set on the positive edge of RES and RAM is enabled. RAME can be program to "1" or "0". If RAME is cleared (logic "0"), any access to a RAM address is external. Bit 7 Standby Bit This bit is cleared when VCC is not provided in standby mode. This bit is a read/write status flag that user ca~ read. If this bit is preserved set, indicating that VCC voltage is applied and the data in the standby RAM is valid. 2.12 Low Power Consumption Mode The HD6370lVO has two low power consumption modes; sleep and standby. ~HITACHI 287 (1) Sleep Mode On execution of SLP instruction, the CPU is brought to the sleep mode. In the sleep mode, the CPU stops its operation, but the contents of the register in the CPU are retained. In this mode, on-chip peripherals such as the SCI and Timer continue their operations. In this mode, the power consumption is one-sixth that of normal operation mode. The MCU returns from this mode by interrupt, RES, or STBY. The RES resets the MCU and the STBY brings it into the standby mode (This will be mentioned later). When the CPU acknowledges an interrupt request, it cancels the sleep mode, returns to the operation mode and branches to the interrupt routine. When the CPU masks the interrupt, it cancels the sleep mode and executes the next instruction. However, for example, if the timer 1 or 2 prohibits a timer interrupt, the CPU doesn't cancel the sleep mode because of no interrupt request. The sleep mode is available to reduce the power con- sumption for a system with no need of the HD63701VO's consecutive operation. Please refer to Table 2-12-1 for other pins except VCC, clock pin, input-only pin, E clock pin (their function are the same as normal operating condition) . (2) Standby Mode The HD63701VO stops all the clocks and goes into the reset state with STBY "LoW". In this mode, the power consumption is reduced conspicuously. In the standby mode, the power is supplied to the HD63701VO, so the contents of RAM are retained. The MCU returns from the standby mode by bringing STBY "High" and restarts execution at the same restart address as reset. If external clock is used during standby mode, EXTAL must be brought "High" not increase standby current by 5-10~A. If the increase of standby current does not ~HITACHI 288 affect the MCU, EXTAL can be held either "Low" or "High". Transitions among the active mode, sleep mode, standby mode and reset are shown in Fig. 2-12-2. Table 2-12-1 Pin Condition in Sleep Mode ::-----,,-:e 0 1 2 5 6 7 Pin Function I/O Port Lower Address I/O Port • --- .. I Bus .. - Port 1 P lO"P1? Keep the con- Keep the con- • ---- ... Condition dition just Output "1" dition just before sleep before sleep Function r/o Port .. ., oil Port 2 P2.0""P2lj Keep the con- Condition dition just Function before sleep E:Lower CI Address Bus Data Bus - E:Lower Address Bus CI Data Bus E:Lower Address Bus I/O Port Port 3 E:Data Bus E : Data Bus E:Data Bus ~30"'P37 E:Output "1 11 E :OutP1.tt '11" E:Output "1" Keep the con- Condition E :High impe- High impedance E : High impe- High impedance E:High impe- dition just before sleep --- - dance dance dance Lower Address Upper Address Function Upper Address Bus or Input Bus or Input I/O Port Port Port Port 4 - Address Bus: PlfO",p,,? Output "I" Keep the con- Condition Output "1" • Port: Keep the condition • dition just before sleep just before sleep SC2 Output "1" (Read Con- dition) . .. . . Output "1" SCi Output Ad- dress Strobe . • Output "1" Output Ad- dress Strobe Input Pin ~HITACHI 289 ~ o Internal E clock Stop in sleep / t ~ mode clock Sleep cleared :I Address ~ (') bus n n+ FFFF FFFF + n+2 - Sleep is recovered with interrupt masked :I Data bus L.J~1--- ~l-- ~2 I Sleep I Interrupt save routine instruction PCn-l 1----J ~ Interrupt Address - PC + PC +2 FF bus where sleep is SP SP- PCn SLP occurs cleared without PCn+l OPn+l PCn+2 OPn+2 interrupt masked PCn+3 OPn+3 Program Fig. 2-12-1 Sleep Instruction Timing Chart Fig. 2-12-2 Transitions among Active Mode, Standby Mode I Sleep Mode, and Reset ~HITACHI 291 2.13 TRAP Function The CPU generates a TRAP interrupt with the highest priority when fetching an undefined op-code or an instruc- tion from non-memory space. The TRAP prevents the system- burst caused by noise or a program error. (1) Op-Code Error When fetching an undefined op-code, the CPU saves register as well as a normal interrupt and branches to the TRAP service routine (vector address=$FFEE, $FFEF). This has the priority next to reset. (2) Address Error When an instruction is fetched from excluding internal ROM, RAM, or an external memory area, the MCU qenerates a TRAP interrupt as op-code error. If the instruction is fetched from external memory area without memory devices, this function is not applicable. Table 2-13-1 shows addresses where an address error occurs to each mode. This function is available only for the instruction fetch, and is not applicable to the normal data read/write. Table 2-13-1 Address Applicable to Address Errors Mode 0 1 2 5 6 7 $0000 $0000 $0000 $0000 $0000 $0000 I I I I I I Address $OOlF $OOlF $OOlF ~007F $OOlF :007F 0200 0100 I I $EFFF $EFFF ~HITACHI 292 3. EPROM (PROM) PROGRAMMING AND TECHNICAL SPECIFICATIONS 3.1 PROM Mode In PROM mode, on-chip EPROM can be programmed while other MCU functions stop operating. The HD63701VO can be configured in the PROM mode by connect- ing P20 to Vee, P21 to VSS' P22 to GND, XTAL, STBY and NMI to GND, and EXTAL to Vee respectively. See Figure 3-2. The on-chip EPROM can be programmed and read in the same way as the 27256. Therefore, general purpose PROM programmer can I perform programming the on-chip PROM. At this time, a socket adaptor which changes the number of pins from 40-pin to 28-pin is necessary. Note that the address range must be $0000 through $OOFF because the on-chip EPROM is 4k bytes. Fill remainder of EPROM area with FFFF for PROM programmer to correctly verify. The Memory map in PROM mode is shown in Figure 3-3. GND 1 40 NC GND 2 39 NC Vee 3 38 NC GND 4 37 00 Vee Vee A9 5 36 01 VPP 6 35 02 EXTAL GND 7 34 03 P20 Vee 8 33 O. P2l Port 3 PROM Vee 9 32 05 Data 00 '" 07 HD63701VO Ae/ p 40 l"~ GND 10 31 OG HD63701VO MCU NC II 30 07 NC 12 29 Aa Address AO 13 28 Al. Al 14 27 A10 h A2 15 26 All Port 1 PROM A3 16 25 A12 Address Control Line A" 17 24 Al3 (Ao '\,A7) (OE. CEI As 18 23 OE A6 19 22 CE A7 20 21 Vee Fig. 3-1 HD63701VO Pin Assignment Fig. 3-2 Symbolical Pin Configuration in PROM Mode in PROM Mode ~HITACHI 293 HD63701VO I I PROM Mode MCU mode PROM Mode "1 " *NOTE - - - - __ J $7FFF *NOTE: If an address in this area is read in PROM mode, it is always read as $FF. Fig. 3-3 Memory Map in PROM Mode 3.2 Programming/Verification The on-chip EPROM can be programmed in high speed programming scheme, which allows the on-chip EPROM to be programmed effectively without damaging the device by voltage and provides high reliability. The basic programming flow is shown in Figure 3-4. ~HITACHI 294 SET PROG. /VERIFY MODE Vpp=12.5±O.3V, VCC =6.0::0.25V Address+l + Address NO 5=25 Vcc =5.0±O.SV Vpp=Vcc ±O.6V OOGO FAIL Fig. 3-4 Programming Flow Table 3-1 Mode Selection Mode _Pin CE OE Vpp 00 'V 07 Read L L Vee D out Output Disable L H Vee High Z High performance Program L H Vpp D in Verify H L Vpp D out Program Inhibit H H Vpp High Z 3.3 Erasure (with window package type) The EPROM is erased by exposing an LSI to ultraviolet light. All erased bits are in the "1" state. The conditions for erasing are: ultraviolet light with wavelength of 2573A, and a minimum irradiation of 15W·sec/cm 2 . These condi- tions are satisfied by exposing the LSI to an ultraviolet lamp rated at 12,000~w/cm2 for 20 minutes, at a distance of about one ~HITACHI 295 inch. Dust of the cap must be removed by a solvent which does not damage the package, because the dust reduces the transmittance of the ultraviolet light. 3.4 On-chip .PROM Characteristics and Application (1) Principles of programming/erasure The HD63701VO's memory cells are the same as the EPROM's. Therefore, they are programmed by applying high voltage to control gates and drains, which injects hot electrons into the floating gate. The condensed electrons in the floating gate are stable, surrounded by an energy barrier of Si02 film, and the proper bit becomes "0" due to the memory threshold voltage change. Electrons in memory devices decrease as time goes by. This is caused by the following: CD Ultraviolet light, discharged by photo emitting electrons (erasure principle) ; (2) Heat, discharged by thermal emitting electrons; CD High voltage; discharged by a high electric field, control gate or drain. If the oxide film covering a floating gate is defective, the erasure becomes great. Normally electron erasing does not occur because defective devices are removed. The proper bit for a memory device whose floating gate does not condense electrons is "1". ~HITACHI 296 Control . ~ Control Gate Gate S~02 I . Si02 Floa t~ng Gate ~ / Gate Source le3'::*.x;*W~" ---- Drain Programming ( "0") Erasure ("1") Fig. 3-5 Cross Section of EPROM Memory Cell (2) Precautions on programming The higher the program voltage VPP or the longer program I pulse width (tpW)' better the programming because many electrons flow. However, data should be programmed under specific'j voltage and timing conditions. If over- voltage is applied to Vpp , the p-n junction may be damaged and permanent damage may occur. Pay particularly attention to PROM programmer overshoot. Minus voltage noise causes a parasitic transistor effect, which may cause apparent breakdown voltage. The HD63701VO is connected electrically to the PROM programmer through a socket adapter, so also pay attention to the followings: G) Confirm before programming that the socket adapter is firmly fixed on the PROM writer. GD Do not touch the socket adapter or the LSI during programming because writing malfunction may occur from bad contacts. ~HITACHI 297 (3) Precautions for using the window package type after programming (NOTES) Q) Transient current may cause permanent damage to the device if the socket adaptor and the device are not installed in the PROM programmer correctly. Care must be taken to install the socket adaptor and the device in the PROM programmer correctly before programming the PROM. QD Note that the HD6370lVO programming voltage VPP must be l2.5V, not 2lV. If the VPP is set to 2lV, it may cause permanent damage to the device. Select the Intel 27256 mode in the PROM programmer to apply l2.5V to the Vpp. (a) Glass window for erasure If the glass window comes in contact with plastic or something else with a statick charge, the LSI may malfunction due to electrostatic charge on the surface of the window. If this occurs, exposing the LSI to ultraviolet light for a few minutes neutralizes the charge and restores it to normal function. However, charge weight stored in the floating gate decreases at the same time, so re-programming is recommended. Electrostatic charge buildup on the window is a fundamental cause of malfunction. Measurement for its prevention are the same as those for preventing electrostatic break-down: CD Operators should be grounded when handling equipment. GD Do not rub the glass window with plastics. CD Be careful of coolant sprays, which may include a few ions. ~ The ultraviolet shading label (which includes conductive material) is effective for neutralizing the charge. ~HITACHI 298 (b) Precautions after programming the EPROM If the device is exposed to fluorescent light or sun light, its memory contents may be reversed because they include a small quantity of ultraviolet light. In strong light the MCU may malfunction under the influence of photo-current. To prevent these problems, it is recommended that the device be used with the glass window for erasure covered with the ultraviolet shading label after programming. A special label is on the market for this purpose. Labels made with metal are effective because they I absorb ultraviolet light. Note the following when selecting a shading label. G) Adhesion (mechanical intenSity) ---- Adhesion is reduced with re-use or dust. When peeling the label, static electricity may occur. As a result, erasure and rewriting by ultraviolet light are recommended after peeling. (Sticking a new label above the old one can be done to change labels.) GD Allowable temperature range ---- The allowable temperature range and environment temperature of the shading label should be noted. If it is used under conditions exceeding this range, the paste may stiffen or adhere to the label, caus- ing paste to remain on the window after peeling. GD Moisture resistance ---- The allowable moisture range and environment conditions of the label should be noted. It is difficult to find a shade label applicable to all allowable environ- mental conditions of the MCU. The proper label should be selected depending on use. ~HITACHI 299 3.5 INSTRUCTION SET OVERVIEW Besides having object code compatible with the HD6801 series, the HD63701VO adds 6 new instructions; enhances bit control instructions (AIM, ElM, aIM, TIM), index/accumulator exchange instruction (XGDX), and sleep instruction (SLP). These new instructions improve programming efficiency. 3 .6 Address ing Modes The HD63701VO provides seven addressing modes. The adequate selection of these addressing mode will permit to implement an efficient and easy programming. The addressing mode is determined by an instruction type and code. The addressing mode for each instruction is shown in Table 3-7 to 3-7-4 with execution time counted by the machine cycles. When the clock frequency is 4 MHz, the machine cycle time will be microseconds. (1) Accumulator (ACCX) Addressing Operand is contained in either accumulator A or B. (2) Immediate Addressing Operand is contained in the second byte of the instruction except LDS and LDX which contain operand in the second and the third bytes. These are two or three-byte instruc tions. (3) Direct Addressing The second byte of an instruction contains an effective address of operand. 256 byte area $0 through $255 can be addressed directly. Execution times can be reduced by storing operand in these locations. In configurating system, it is recommended that these locations should be RAM for users' data area. These are two-byte instructions, while the AIM, aIM, ElM and TIM are three- byte instructions. ~HITACHI 300 (4) Extended Addressing The second and third bytes of the instruction contain the effective address of the operand. These are three-byte instructions. (5) Indexed Addressing The effective address of the operand is the sum of the contents of the second byte and the lower byte of the Index Register. As for AIM, OIM, ElM and TIM instructions, the effective address is calculated by adding the contents of the third byte and the lower byte of the Index Register. The effective address is held in the Temporary Address Register, so the contents of the Index Register is not changed. These are two-byte instructions, while AIM, OIM, ElM and TIM are three-byte. (6) Implied Addressing The instruction itself gives the address. That is, the instruction addresses an Accumulator, Stack Pointer, Index Register, etc. This is a one-byte instruction. (7) Relative Addressing Relative addressing mode is only used in branch instruc- tions. The branch address is calculated by adding the contents of the second byte and the lower byte of the Program Counter. At this time, a carry or borrow is added to the upper byte of the Program Counter. The span of relative addressing is from -126 to +129 from the op-code address. These are two-byte instructions. ~HITACHI 301 3.7 Instruction Set The HD63701VO has an upward object code compatible with the HD6801 to utilize all instruction sets of the HMCS6800. The execution time of the key instruction is reduced to increase the system through-put. In addition, the bit manipulation instruction, the exchange instruction of the index and the accumulator, the sleep instruction are added. The followings are described here. • Accumulator and memory manipulation instructions (See Table 3-7). Additional instructions. • Index register and stack manipulation instructions (See Table 3-7-2). • Jump and branch instructions (See Table 3-7-3). • Condition code register manipulation instructions (See Table 3-7-4). • Op-code map (See Table 3-7-5). ~HITACHI 302 Table 3-7 Accumulato~ Memory Manipulation Instructions Condition Cod_ Addressing Modes A.gistt, Oper'tions Mnemonic Bool .. nl IMMEO OIRECr-T-iNOEX EXTEND IMPLIED 5 4 J 2 1 0 Arithmetic Oper.tion OP -• - OP # OP - • OP - # OP -• H I N Z V C Add AOOA AOOB 88 C8 2 2 9B 2 2 08 J J 2 AB 4 2 EB 4 2 2 88 FB 4 4 J J A+M- A 8+M-O I I ·· I I I I I I I I Add Doabl, Add Accumulators AOOO ABA CJ 3 3 OJ 4 2 E3 5 2 FJ 5 3 IB A: B + M: M+l-A:8 1 1 A + 8- A I· ·· I I I I I I I I Add Wi.n Carry AOCA AOCB 89 C9 2 2 99 2 2 09 J J 2 2 A9 E9 4 4 2 B9 2 F9 4 3 4 J A+M+C-A 8+M+C-B I I ·· : I I I I I I I AND ANOA AN DB 84 C4 2 2 94 2 2 04 J J 2 2 A4 E4 4 4 2 B4 2 F4 4 J 4 J A·M-A 8·M-8 ·· ·· I I I I R R ·· Bit Tilt 81TA BIT B B5 C5 2 2 95 2 2 05 3 3 2 2 E5 A5 4 4 2 B5 2 F5 4 J 4 3 A·M 8·M ·· ·· I I I I R F. ·· CI.1f' CLR CLRA 6F 5 2 7F 5 3 4F oo-M 1 1 00- A ·· • R S R R S R R Compl'. CLR8 CMPA 81 2 2 91 3 2 AI 4 2 81 4 3 5F 1 1 00-8 A-M ·· · • • R R I S R R I I I Compar. CMPB CeA Cl 2 2 01 3 .2 El 4 2 FI 4 3 11 I 1 8-M A-8 ·· ·· I I I I I I I I ··· ··· Aecumul.tors I Compliment, t', COM 63 6 2 73 6 3 M-M I I R S COMA 43 I 1 A -A I I R S COMB 53 1 1 8 -8 I I R S ComplIment. 2" tNogotl) NEG NEGA 60 6 2 70 6 3 40 OO-M-M 1 1 00 - A- A ·· ·· I I I (i)~ I Ii) :~ ···· NEGB 50 1 1 00-8-8 0 I I (i) t}J Converts bln.ry 8dd of BCD I (j) Oed",,! Adjust. A OAA 19 2 1 characters into BCD format 0 I I Decrement DEC SA 6 2 7A 6 3 M-l -M I I @ • ···· · OECA 4A I 1 A-I - A 0 I I @ • OECB 5A I 1 8 - l-B I I (4) 0 EORA 88 2 2 98 2 AS 2 88 4 3 4 A (!I M-A 0 I I R ······ '" ·. ExcluliYII OR 3 EOR8 C8 2 2 08 3 2 E8 2 F8 4 3 4 B (!IM- B I I R Increment INC 6C 6 2 7C 6 3 M+l-M I I @ • INCA 4C 1 1 A + 1 .... A I I L_ INCB 2 2 96 2 A6 4 2 B6 4 3 5C I 1 B + 1- B M....,A ···· · I I I I @ • R ··· ··· · · ·· LOAA B6 3 Accumulator M-B I I R LOAS C6 2 2 06 3 2 E6 4 2 F6 4 3 L_Ooublo EC 5 FC M + 1 ..... B. M- A I I R LOO CC 3 3 OC 4 2 2 5 3 Accumulator 3D 7 1 AxB-A:B ·· ··· · · · ··· Multiply Unsigned MUL • ® OR, IncluliYII ORAA 8A 2 2 9A 3 2 AA 4 2 8A 4 3 A+M-A 0 I I R ORAB CA 2 2 OA 3 2 EA 4 2 FA 4 3 B + M- B I I R 36 4 1 A .... Map. SP - 1 .... SP ·· ·· ·· ·· ·· ·· Push D,tl PSHA PSHB 37 4 1 B - Mil>. SP - 1 - SP 3 1 SP+l-SP,MtP- A · · · ··· Pul) O.t. PULA 32 33 3 1 SP+l-SP.M.. -B :1 ~.J U; ·· ·· PULB Rotlt. Left ROL 69 6 2 79 6 3 I I @ I ROLA 49 I 1 I I (<<> I ROLS 59 1 1 ·· I III =} 4i1' ,, P · · I I I CIl I I @ I ···· Rotl" Right ROR 66 6 2 76 6 3 RORA 46 I 1 I I I I I I (4) I 8 b1 bO RORS 56 1 1 I I "i) I Note) Condition Code Register will be ho be continued) explained in Note of Table 3-7-4. ~HITACHI 303 Table 3-7-1 Accumulato~ Memory Manipulation Instructions Condition Code I Addressing Modes Register Operations I Mnemonic f-;"MMEo oP - .. 10lAECT OP - .. INDEX OP EXTEND - . - .. - OP IMPLIED OP It Boole.nl Arithmetic Operation 5 H 4 3 I N Z V 2 I 0 C Shih Left Arithmetic ASl ASlA 68 6 2 78 6 3 48 1 1 M\ _ I(111111111--0 ·· ·· I I @I I I @I ·· ·· A • b7 bO ASlB 58 1 1 I I 6 I Double Shih ~thmetic ASlo 05 1 1 ~ Ace;y Ace' 1-0 I I~ I ··· ··· 11.7 AO .7 80 Shift Right ASA 67 6 2 77 6 3 MI _ I I 6 I Arithmetic ASAA 47 1 1 A CCI I I I I I I K;l I I 6 I II b7 bO ASA8 57 1 1 I I 6 I Shift Right Logial lSA lSAA 64 6 2 74 6 3 44 1 1 M Alo..j • .7I IIIIIU~ - ·· ·· R I~I R I@I ··· ··· · lSAB 54 1 1 R II I R • Q) I R • · .· R • (I) I • .....".PU-II--=O- ..- . - - - - - PULX 38 4 I SP + I - SP, Moo. - XH sP +1- SP,M.. - XL ·. .. . . Exchange XGDX 18 2 1 ACCD"IX •••••• Note) Condition Code Register will be explained in Note of Table 3-7-4. ~HITACHI 305 Table 3-7-3 Jump, Branch Instruction Addressing Modes ConCtil ion Code Aegister Operations Mnemonic I - - - - - r - - - - r----,--- - - , - - Branch Test RELATIVE DIRECT INDEX EXTEND IMPLIED 5 4 3 2 1 0 OP - tI. OP - " OP - " OP - " OP - II H INZVC ~B~r~.n~<~h~A~lw~.~y~.____~~B~R~A~~~2~0~3~2~--~~+-_r_t_+--+_~~- __ None I-B=r.::.nc;<~h~N:.:.-,- ..=-r__~-1!--CBAN None :::::~ 21 3 2 Branch If Carry Clear BCC 24 3 2 C'O Branch If Carry Set SCS 25 3 2 C·l Branch If II Zero BEQ 27 3 2 Z- 1 Branch If ;> Zero aGE 2C 3 2 Branch If > Zero SGT 2E 3 2 Z + IN VI- 0 Branch If Higher BHI 22 3 2 c+z-o Sranch If < Zero BlE 2F 3 2 Z + IN VI- 1 • •• • i- • :::h If Lower Or SLS 23 3 2 Branch If < Zero BLT 20 3 2 Branch If Minus 8MI 28 3 2 ~~~Ch If Not Equal SNE 26 3 2 ~B~r=-.n~<-h-lf~D~.. ~rf~~-w--~--B-V-C--~-2-B~3-r2-r--~t-+--r-t-+--+-~~-+~--~V-_--O-----------ro-to-t-o+.- ~~ Cle.r Branch If Overflow Set avs 29 3 2 V -=--'!-________ -""1f-'0'-f0'-f0'-f0'-f0"-f0=-j r-s-";~ch If Plus aPL 2A 3 2 N .. 0 ~hT~~S"Ub-r-ou-,-;n-.~~BS~A~--+=-8~D~5~2-r~--~t--r-r-t--t-+-+--r-+--+-~~--------~ro-ro-ro-to-to-to-i Jump ---------t~J~M~P~--~--r-t-+--t-+-~6E.t~3~2~7E.+~3~3-~--+-~--1 ~o~o~o~~o~o+-.- Jump To Subroutine JSA 90 5 2 AD 5 2 BO 6- j Advances Prog. entr. No Operation NOP 01 1 1 Only ~- From Interrupt Subroutine RTI ~iurn F~m---'----'-+-------I--+-t-+--t-+-+-· -- r---. - Software Interrupt RTS SWI r--+-- _. - 38 10 1 1--- - -- - - 39 3F 5 12'- 1 · . .. . . ® -;- 5 ; I-;-f;-f;- ~W::.::'It::'f=o'-'r'-'ln~,.:':r:';'ru"'po.: ••'---r-W~;':A"-I---1f-~-+-+--I-t-+---+- ~--t--I-+-;E -g-, • ® •••• t-~Sl~"~p~----~---t-'S"L~P~--I--+-+-+--+-+-~-+~ lA 4 1 • ••••• Note) *WAI puts R!W high; Address Bus goes to FFFF; Data Bus goes to the three state level. Condi tion Code Register will be explained in Note of Table 3-7-4. Table 3-7-4 Condition Code Register Manipulation Instructions ~ddr."lngMod.. Condition Cod!' Register Oper~tionl Mnemonic IMPLIED Boolean Operation 5 4 3 2 1 0 OP - • H • I N Z V C Clor Carry Clear Interrupt Malt ClC Cli OC oe 1 1 1 , O-C 0-1 0 0 A 0 0 0 0 0 0 R 0 Cle.rOwrflow ClV OA 1 1 O-V 0 0 0 0 R 0 SEC Set Carry SEI 00 1 1 OF , I-C 0 0 S 0 0 0 S Set Interrupt Malt 1 , 1-1 0 0 0 0 0 Set Overflow SEV DB 1 , I-V 0 0S 0 0 0 Accvmulator A - CCR CCR - Accumulator A TAP TPA 06 07 1 1 , A- CCA CCA-A ---@--- oJojojo 0 0 [NOTE) Condition Code Register Notes: tBit set jf test is true and cleared otherwise) (j) (Bit V) Test: Result = l0000000? @ (Bit C) Test: Result 'I OOOOOOOO? @ (Bit C) Test: BCD Character of high-order byte greater than 10? (Not cleared if previously sed @ (Bit V) Te." Operand - 10000000 prior to execution? @ (Bit V) Test: Operand· 01111111 prior to execution? ® (Bit V) Test: Set equal to NeC-l after the execution of instructions (l) (Bit N) Test: Result Ie.. than zero? (Bit 15=1) ® (All) Load Condition Code Register from Stack. @ tBit I) Set when interrupt occurs. If previously set, a Non-Maskable Interrupt is required to exist the wait state. @J (All Bid Set according to the contents of Accumulator A. J-...:=_ _ __ • Access matches Output Strobe Select (aSS == 0, a read; OSS = 1. a write) Fig. 3-11-5 Port 3 Output Strobe Timing Fig. 3-11-6 Port 3 Latch Timing (Single Chip Mode) (Single Chip Mode) ~HnTACH8 319 E Timer Counll' _ _ _ _-1 ... _+=..;.;;._" , ____ P" Output Fig. 3-11-7 Timer Output Timing 1.4V Mode InpulS _ _ _ _ -=::.:.(( Dala Valid 2.0V IP ul • p". P12) O.8V ~;"'------;If"" O.BV Fig. 3-11-8 Mode Programming Timing RL ·2.2kn Test POlnl - .UI ., 152074 ® or Equn,. R ~ I C • 90 pF fo, p.o - PI1. ">0 - P3'. p.. - P4,. SCI. 5C,. E • 30pF for PXI - P", R • ,2 kn Fig. 3-11-9 Bus Timing Test Loads (TTL Load) ~HITACHI 320 • PROGRAMMING ELECTRICAL CHARACTERISTICS • DC CHARACTERISTICS (Vee a 6.0V ± O.25V. Vpp = 12.5V ± O.3V. Vss a OV. Ta a 25°C ± 5°C unless otherwise noted.) Item Symbol Test Condition min typ max Unit Input "High" Voltage 0 0 -0,. A o-A I4 • OE. CE VIH 2.2 - Vee +0.3 V Input "Low" Voltage 0 0 -0,. A o-A I4 • OE. CE Vil -0.3 - 0.8 V Output "High" Voltage °0-°7 VOH IOH - - 200,.A 2.4 - - V Output "Low" Voltage °0-°7 VOL IOl - 1.6mA - - 0.45 V Input Leakage Current 0 0 -0,. Ao-A I4 • OE. CE III VIN .- 5.25V10.5V - - 2 ,.A Vee Current Icc - - 30 mA Vpp Current Ipp - - 30 mA • AC CHARACTERISTICS (Vee = 6.0V±O.25V. Vpp = 12.5V±O.3V. Vss = OV. Ta = 25°C±5°C unless otherwise noted.) Test Item Symbol min ty max Unit condition Address Set-up Time tAs 2 - ,.s CE Set-up Time tOES 2 - - ,.s Data Set-up Time los 2 - - ,.s Address Hold Time tAH 0 - - ,.s Data Hold Time tOH 2 - - ,.s Data Output Disable Time tOF Fig.6-10'-' - - 130 ns Vpp Set-up Time tvps 2 - - ,.s Program Pulse Width (High Speed Writing) tpw 0.95 1.0 1.05 ms Program Pulse Width topw 2.85 - 78.75 ms Vee Set-up Time tvcs 2 - - ,.s Data Output Delay Time tOE 0 - 150 ns " Inpul Pulse level- 0.8-2.2V Inpul Rise Time/Fall Time ~ 20no. Tuning Reference level Inpul: '.OV. 2.0V. Oulpul: O.BV. 2.0V. P rogram Ven'fy Address - r--- '--- Data tAS Data In Stable r Data Out Valid tos IOH ~ Vpp Vpp Vee Ivps Vee Vee GND Ives tOES tOE ~ -I 1 ~. Fig. 3-11-10 PROM ProgramNerify Timing ~HITACHI 321 4. APPLICATIONS 4.1 Use of External Expanded Mode The HD63701VO supports four operation modes 1, 2, 5 and 6 as external expanded modes. Usage of these modes is detailed in the following paragiaphs. (1) Non-multiplexeQ modes (a) Mode 1 (New Mode) In this mode, Port 3 functions as data bus, Port 1 as lower address bus (AD - A7), and Port 4 as upper address bus (As - A1S). Since l6-bit addresses are sent out in parallel, the HD63701VO can access up to 65k memory space with no address latch externally in this mode. ~HITACHI 322 HD63701VO MCU E f-- Ao""A7 Aa""Al 5 Do""D7 R/W I 8 , 8 8 ROM -, -1 I RAM _L , PIA GPIA PTM Address Address Data Bus Bus Bus (LSB) (MSB) Fig. 4-1-1 HD63701VO, Mode 1 ~HITACHI 323 If an internal memory address and an external memory address are overlapped, the memory address can be accessed as follows. When writing, the same data can be written into both internal and external memories simultaneously. When reading, only internal memory can be read while the external memory can not be read. The same operations can be applied to modes 2, 5, and 6. In mode 1, external memory addresses range from $OOFF to $FFFF and so internal mask ROM located in $FOOO through $FFFF can not be accessed. After reset, Port 1 functions as lower address bus (Ao - A7), Port 4 is a upper address bus (As - A1S). (b) Mode 5 (Equivalent to Mode 5 of HD6801V) Port 3 works as data bus; and Port 4 as address bus (Ao - A7) or input pin by programming the DDR. In this mode, pin 39 provides the result of the following decoding: This output signal may be used as a chip select or chip enable signal permitting to access an external memory up to 256 byte locations ($0100 - $OlFF). The pin function of Port 4 can be changed from an address line to an input port if the system does not need all of the 8 address lines by writing zero into the corresponding bit of Port 4 DDR. An example of connection with PIA (HD6821, HD6321) is shown in Fig. 4-1-2. ~HITACHI 324 8 Do'VD7 Do'VD7 8 PA o'VPA7 8 Ao RSo PB o'V PB 7 Al RS I HD63701VO A2 CSo HD6821 p:j~ddres~1 A7 " decoder CSI HD6321 vee CAl CB I ~ IRQA CA 2 IRQ IRQB CB2 lOS CS2 E R/W E R/W I t J I I Fig. 4-1-2 Connection of HD63701VO with PIA (2) Multiplex Modes (Modes 2 & 6) I Any multiplex mode provides a time multiplexed address and data on port 3. Therefore, an address latch is required externally to access external devices. As (Pin 39) signal is used for an address latch strobe. An example of HD63701VO and CMOS latch interface is shown in Fig. 4-1-3. It should be noted, however,. that the HD6370lVO can not operate at more than 500 kHz when interfaced with the latch. ~HITACHB 325 HD14508B -m=tl MR DIS Pso Address buses Do Qo Ao to A, P31 Dl Ql P32 D2 Q2 P33 D3 Q3 HD63701VO p ,. Do Qo p Dl Ql Pas D2 Q2 p., 3 Q3 S...TASTB AS I Y Data buses Do to D, Fig. 4-1-3 CMOS Latch For high-speed operation, 74LS373 or high speed CMOS latch (74HC373) is desirable to minimize the delay time. (a) Mode 2 (Equivalent to HD680lV Mode 2) In this mode, the internal mask ROM (~FOOO through $FFFF) is disabled and external.memory becomes valid instead. Port 4 functions as the upper address bus. (b) Mode 6 (Equivalent to HD680lV Mode 6) In this mode, the internal mask ROM is enabled. Port 4 functions as address bus (As - A1S) • Since Port 4 becomes input mode after reset, the DDR must be programmed to "I" to use the port as address bus. ~HITACHI 326 Address Bus Data Bus I Fig. 4-1-4 HD63701VO MCU Expanded Multiplexed Mode 4.2 Standby Mode Bringing STBY "Low", the HD63701VO goes into the Standby mode. In this mode, the epu becomes reset and all clocks of the HD63701VO become inactive. The contents of the internal RAM is retained as long as Vee is supplied (Vee;;; 2V). Under Standby Mode, memory back-up is possible with only a few ~A of leakage current. When STBY is brought "High", the MCU exits from Standby Mode. When "1" level is 'detected at STBY pin, a clock generator begins to oscillate and the internal reset condition is released. At this time, RES signal must be held "Low" for at least OSC stabilization time (tRC ) before the CPU operation restarts. Otherwise, the normal operation is not guaranteed. Fig. 4-2-1. ~HITACHI 327 I.Store the contents of registers into RAM (if necessary) ~Set each bit in RAM Control Status Register to RAME="O", STBY="I" PWR Restart Routine 3. SLP executed Test and judge STBY bit in RAM Control Status Register "I" : VCC was supplied. "O":V was not CC supplied. Fig. 4-2-1 Flowchart of Standby Mode Application ~HITACHI 328 The timing relationship shown in Fig. 4-2-2 must be satisfied. NMI ,, ,I II RES , ' , I :~ I I Ij ~ : I RESl I I I I 1* I II STBY ~ : I S\ I I STBYl 1*, II I I Restart I NMI:Routine I .--- I .----. t---I o , I , I I I Register Save Ii Oscillator Stabilization Time o RAM Control Status Register Bits set Fig. 4-2-2 Timing Chart of Each Signal * Either RESl or STBYl can become "0" level as long as the execution time of NMI routine is quaranteed. Fig. 4-2-3 shows an example of a circuit to implement the timing sequence shown in the Fig. 4-2-2. System power line . ~ .... 'I>---;h. " I To other device of the system ~ i NMI Vee R2 ... STBY STBYI 7Ir I .. 1 R r RS l cs RES J>.,.RESl V sWitc~l ICr 1 Rl« Rz, HD6370lVO R.C »20ms r r Fig. 4-2-3 Example of Circuit Diagram for a Standby Operation ~HITACHI 329 The Standby power bit in the RAM control status register detects that VCC is supplied or not. When the VCC rise time is equal or less than lOO~s, the Standby power bit may not be cleared. To avoid this, the VCC rise time should be more than lOO~s, for example, by using the larger bypass capasitor. 4.3 Address Trap, OP-Code Trap Application The HD6370lVO facilitates two trap functions, the op-code trap and the address trap, to protect the HD6370lVO to proceed an erroneous operation. The op-code trap is generated when an illegal or undefined op-code is fetched. Therefore, when undefined codes listed below are fetched, a trap is caused and the HD6370lVO avoids further erroneous operation. The priority level of the op-code trap interrupt is next to the RESET. Undefined codes of the HD6370lVOare: $00, $02, $03, $12, $13, $14, $15, $lC, $10, $lE, $lF, $41, $42, $45, $4B, $4E, $51, $52, $55, $5B, $5E, $87, $8F, $C7, $CO and $CF. The address trap is generated when an op-code is fetched from the memory area shown in Table 2-3-1. It should be noted, however, this function works only under op-code fetch (not for data access). Under the support of error processing program in trap service routine, the user can realize the proper error processing for the application system. An example of restarting from the trap service routine is shown below. If RTI instruction is ex'~cuted at the end of the trap service routine, the program is restarted at the location where the trap interrupt is generated and then another trap may occur again. So, special care must be taken when a programmer uses trap function. Main Routine TRAP Service Routine START LOS STACK JMP START ~HITACHI 330 4.4 Slow Memory Interface Here described is the example of clock width cantrall circuit and its timing chart, where E-clock high time is extended to assure enough access time. The expanded enable high pulse width (PW'EH)' which is implemented by using the circuit shown below, is calculated as follows: where n t 4 ¢cyc: 4~ clock cycle time (~s) PWEH PWEL tw Enable High pulse width Enable Low pulse width approx. 0.45 • Cext(pF) (~s) (~s) • Rext(kn) x 10- 3 (~s) I The circuit shown is for a reference purpose. It is assumed that users will refine it for actual design. 416 C ext\ VCC CK EXTAL E N.C. XTAL Rex Jc ext Q2 address Address Bj QI D2 HD63701VO decoder Al CLR CLR HD74LS123* HD74LS174* * Equivalent CMOS gates To CS, etc. are available. Fig. 4-4-1 Clock Control Circuit ~HITACHI 331 4¢ EXTAL Input E Address Oata Fig. 4-4-2 Clock Timing 4.5 Interface to HN61256 An examples of the interface to a slow memory device, HN6l256 (CMOS 256k bit Mask programmable ROM), is described here. The AC characteristics and the access timing of the HN6l256 is shown in Fig. 3-5-1. Item Symbol min max Unit Read Cycle Time t RC 4.0 - )Js Address Access Time t AACC - 3.5 )JS Chip Enable Access Time t EACC - 3.0 )JS Oata Hold Time from Address tOF 0.05 0.5 )JS Address Set-up Time t AS 0.5 - )Js Address Hold Time tAH 0 - )JS Chip Enable ON Time tCE 3.0 - )JS Chip Enable OFF Time tCE 0.5 - )JS Fig. 4-5-1 AC Characteristics and Access Timing of HN61256 ~HITACHI 332 4.5.1 Use of Two Latches Two HD14508Bs are used in order to latch 16 bit address. An example of the program and its access timing are shown in Table 4-5-1 amd Fig. 4-5-3, respectively. B B P40 "'P 47 Do"'D7 - I B 7 D Q As"'AI4 STI 1 CS P 30 r-- P 31 B B P32 II ,srz D Q I Ao"'A7 - CE HD1450BB HN61256 HD63701VO (Single Chip Mode) Fig. 4-5-2 HD63701VO and HN61256 Interface by Two Latches ~HITACHI 333 Table 4-5-1 An Example of the Program Mnemonic Cycles LDAA #$FF 2 STAA P4DDR 3 Port 4 is the output port. LDD #$ADDRSI 3 Data that is the address's upper 8 bits including CS signal and changes STI into high and ST2 into low. STD PORT3 4 Enables STl, disables ST2, and moves the address's upper 8 bits into Port 4. LDD #$ADDRS2 3 Data that is the address's lower 8 bits and changes STI into low and ST2 into high. STD PORT3 4 Disables STl, enables ST2, and stores the address's lower 8 bits into Port 4. LDAA #IMMI 2 Data that changes STI and ST2 into low and CE into active. STAA PORT3 3 Disables STI and ST2 and enables CEo LDAB #$00 2 STAB P4DDR 3 Port 4 becomes the input port. LDAA PORT4 Reads data. ~HITACHI 334 Port 4 Read E Address Ae'VAI4'CS _____...J)( A e'VAI4,CS ~ I Address Ao'VA7 --x A o'VA7 ----------------------~ :I ----1- \~ _ _ _ _ _ _ _ _ _ _ _ _ _ __ ~ STI STz (') :I ~ / \~----------------- CE \ Data -----.(X XXXXXX Data Valid c.> c.> 01 Fig. 4-5-3 Access Timing -- 4.5.2 Extending E clock Fig. 4-5-4 is an example circuitry to extend the E clock. The operation mode of the HD63701VO is in mode 6; and the clock frequency of 4¢ is 4 MHz. - .-t~WCK 4¢ )J-* CONTRa EXTAL P 30 'V P 37 8 8 I , Do'VD7 ~LATCH: 8 7 Ao'VA7 P40'VP~{; As'VA 14 P 47 -/) CS AS R/W l 4D 30 20 40 30 20 ~ CE E ~rf 10 10 m·"'CK $OOOO'V$7FFF HN6l256 77 CS: Active-high HD63701VO (Mode 6) LS173 CE: Active-low *The detail of this circuit is described in Fig. 4-4-1. Fig. 4-5-4 HD63701VO and HN61256 Interface by extending E clock cycle PW'EH Fig. 4-5-5 HN61256 Read Timing ~HITACHI 336 In this example, PW EH of which timing is extended by using the clock control circuit (Fig. 4-4-1) must be at least 4 ~s. The LSl73 is to assure enough address set up time (t AS ) of HN6l256. 4.6 Interface to the Realtime Clock (HDl468l8) The HDl468l8 (realtime clock + RAM : RTC) is a 010S micro- computer peripheral LSI that incorporates the clock and calendar functions to compute year, month, day, day of week, and time. When this HDl468l8 is interfaced to the HD6370lVO, this LSI provides a real time clock information to be displayed. In addition, the HDl468l8 can be also utilized as a system interval timer and a square waves generator. An example of the HD146818 and the HD63701VO interface is shown in Fig 4-6-1. It can be interfaced under the expanded multiplexed mode I (mode 6) of the HD6370lVO. ~HITACHI 337 SQW Jl..f Add- S bits cs III 00 R/W .-t 00 5 I/O Port 2 ~ (Y) \0 DS ....-t ID SCI ::r: Q :t: X-tal Timer SCI Address Strobe AS 4.l94304MHz NMI S bits Fig. 4-6-1 HD63701VO and HD146818P Interface (MCU Expanded Multiplexed Mode) The calendar and clock display functions of HD146818 are shown below. 0 00 0 SECONDS 00 14 bytes 1 SEC ALARM 01 13 00 2 MINUTES 02 14 OE 3 MIN ALARM 03 ~ 4 HOURS 04 u ~ 5 HR ALARM 05 "- >. ~ 6 DAY OF WK 06 I1l c • .-j 7 DATE OF MON 07 ~ 50-byte 8 MONTH 08 user RAM 9 YEAR 09 10 Control register A OA 11 Control register B OB 12 Control register C OC 63 3F 13 Control register 0 00 Fig. 4-6-2 HD146818 On-chip RAM Address Map ~HITACHI 338 Table 4-6-1 HD146818 Time, Calendar, & Alarm Data Display - - Data range Data range (H exadec ima l) Address Function (Decimal) Binary data BCD data mode mode 0 SECONDS 0 to 59 00 to 3B 00 to 59 1 SECONDS ALARM 0 to 59 00 to 3B 00 to 59 2 MINUTES 0 to 59 00 to 3B 00 to 59 3 MINUTES ALARM 0 to 59 00 to 3B 00 to 59 4 HOURS 12-hour 1 to 12 01 to OC/ 01 to 12/ mode 81 to 8C* 81 to 92* 24-hour 0 to 23 00 to 17 00 to 23 mode I 5 HOURS 12-hour 1 to 12 01 to oci 01 to 12/ ALARM mode 81 to 8C* 81 to 92* 24-hour 0 to 23 00 to 17 00 to 23 J mode 6 DAY OF THE WEEK 1 to 7** 01 to 07 01 to 07 7 DAY OF THE MONTH 1 to 31 01 to lF 01 to 31 8 MONTH 1 to 12 01 to DC 01 to 12 9 YEAR 0 to 99*** 00 to 63 00 to 99 [Notes] *: The most significant bit differentiates bet.ween AM and PM. That is, 0 = AM and 1 = PM. **: 1 Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 Thursday, 6 = Friday, and 7 = Saturday ***: This takes the lower two digits of the calendar year. The information of the calendar and the time are stored on the on-chip RAM and updated every second. The on-chip RAM includes not only the display RAM but also 50-byte user RAM which stores data necessary for the system. The HD63701VO gets the calendar and time information by reading the on-chip RAM of the HD146818. The HD146818 generates three interrupts, update interrupt, alarm inter- rupt, and periodic interrupt, to the HD63701VO. The HD63701VO can service proper routine for the application system by accepting the HD146818 three interrupts. ~HITACHI 339 Such a combination of the HD63701VO and the HD146818 easily implements a compact real time system with reduced power dissipation. Note: Refer to "HD146818 Data Sheet" for details. 4.7 Reference Data of Battery Service Life Fig. 4-7-1 shows the battery service life taken from a silver oxide battery: SR44w (by Hitachi Maxell). -- -- : Estimated 3000 "- 2590 ,""'- " ~ H ;:l o ..c: 720 300 '" , ,, ,, , , OJ 'H ,, OM ..:I ,, ,, OJ ,, o~ 100 :> H OJ , U) , ,, ,, 30 , 10 6070 250 600 6000 Current (\lA) Fig. 4-7-1 Battery Service Life (Maxell SR44w) ~HITACHI 340 5. PRECAUTIONS 5 .1 Write-Only Register When a write-only register such as the DDR of the port is read by the MPU, "$FF" always appears on the data bus. Note that when an instruction which reads the memory contents and does some arithmetic operation on the contents of the write-only register, it always gets $FF as the arithmetic and logical results. AIM, OIM and ElM instruc- tions can not be used for the bit manipulation of the DDR of the I/O port. 5.2 Address Strobe (AS) The AS signal is used as an address latch strobe and is always accompanied with the E-clock. This means the AS is available in both Normal Operation Mode and Sleep Mode whenever the E clock is generated. 5.3 Mode 0 This mode is used for the test purpose only. It is not recommended to use this mode for the other purposes. 5 .4 Trap Interrupt When executing an RTI instruction at the end of the inter- rupt routine, trap interrupt different from other inter- rupts returns to the address where the trap interrupt was generated. Care must be taken when using trap interrupts in the program. See Fig. 5-4-1 and 5-4-2 for details. ~HITACHI 341 B $FFOl OPn $FF02 Operand Undefined $FF03 op-code OPn+l C $FF04 Fig. 5-4-1 Undefined Op-code Trap After executing OPn instruction, the HD63701VO fetches and decodes an undefined op-code to generate a trap interrupt. When RTI instruction is executed at the end of the trap interrupt service routine, the HD63701VO will set $FF03 in PC, fetch the undefined code again, generate a trap interrupt and repeat ABC endless-loop. $FF02 BSR $FF03 01 $FF04 OPn Fig. 5-4-2 Address Trap After performing BSR instruction, the branch destination address is output on an address bus to fetch the first op-code of a subroutine. If $0001 is output as an address by some mistake, the HD63701VO internally decodes it executed at the end of this trap interrupt servicing routine, the HD63701VO will set $0001 in PC and restart from this address, which causes a trap interrupt again and repeat this endless-loop. ~HITACHI 342 5.5 Precaution on the Board Design of Oscillation Circuit As shown in Fig. 5-5-1, the cross talk disturbs the normal oscillation if signal lines are put near the oscillation circuit. When designing a board, pay attention not to do that. In addition, crystal and CL must be put as close to the HD63701VO as possible. OJ OJ I=: I=: .,-l.,-l r---~----Power source .-l.-l I .-l.-l I\J I\J I=: I=: 0'0' .,-l .,-l UJ UJ EXTAL HD63701VO Do not use this kind of print board design. Fig. 5-5-1 Precaution to the Board Design of Oscillation Circuit 5.6 Application Note for High Speed System Design Using the HD63701VO When interfacing the HD63701VO to the high speed memory (ex. HM6264) in expanded multiplexed mode, noise may appear on the address bus. Therefore, the following countermeasure must be taken to prevent this noise from occurring. However, when using the HD63701VO in single chip mode, no problem of this sort occur in the bus. 5.6.1 Problem If load capacitance of the data bus exceeds th' specification ~HITACHI 343 and the GND impedance is high in HD63701VO application system, noise may appear on the address bus during the write cycle and a write error may occu~ The timing is shown in Fig. 5-6-1. E \ / \ AS I \ I R/W (SC 2) \ I As '" A15 (Port 4) X uu)( ___ Noise J\. X ~ Do '" D7 (Port 3) < Fig. 5-6-1 Noise Occurrence in Address Bus During Write Cycle 5.6.2 Cause If the data bus changes from "High" to "Low" (from FFB to OOB) , extremely large transient current flows through the GND and noise may appear on the GND because of the GND impedance. This noise level appears on all outputs including address bus. (See Fig. 5-6-2.) Fig. 5-6-3 shows the dependency of the noise level on each parameter• ."~ '"~ Vee Cd DO-.....-;~-< Cd,-'d ml. • E'd ~l. '-A- Im :::> :::> :::> :::> :::> I RAM Address : $0040-$00FF RAM $OOFF r < < < < < <1 Opera tion Mode I Mode 4: Expanded Multiplexed Mode Mode 2 HD63701VO does not have Mode 4 After providing supply voltage, output level The Output Level Register is initialized is undefined (0 or 1) unless the contents of to 0 by reset. ~ I::: o the Output Compare Register matches with those J: -.-I .j.l of the Free Running Counter. The Output Level Register is not initialized by reset. o~ U § r.. J: Timer 8.11 Bit 1 I"on2 DDR 'OIl' DOR om; :--rr iRQ, ___ . . _: c-·-nI;:: _____1 OutPUt flIP'll ~I .......... 8111 •. ,0 1.11 Port2 1,10 I'tIrt2 'on2 Port 2 Fig. 20 Programmable Timer Block Diagram Fig. 20 Programmable Timer Block Diagram ~ .. "-.I (,) .... (Xl Item HD6301V HD63701VO HD 6301Vl HD6303R Receive data is transferred from Receive HD6303Rl HD63P01Ml Shift Register to RDR even if framing error occurs. When framing error occurs, Receive data is receive data is not transferred from transferred from the Receive Shift SCI Receive Shift Register to Register to RDR Receive Data Register (RDR). even if framing error· occurs. The DDR of port is reset synchronously The DDR of port is reset asynchronously ~ § with E clock. I/O state is undefined from providing power supply till oscillation start with E clock. CPU enters into high impedance state (input state) by bringing :I •.-1 Port Reset +l (max. 20ms). RES Low. ~ () ~ ;:J Reset release and MCU internal reset is r.. Heu internal reset o performed synchronously with E clock. J: RES E !" STBY signal is latched synchronously with E STBY signal is latched asynchronously clock. with E clock. CPU enters into standby state by bringing STBY Low. Standby Mode STBY STBY --19>--1>0-- STBY Item HD6301V HD63701VO HD6301Vl HD63P01Ml E, HD6303R HD6303Rl l I E~ Ei L 1 output HI-Z --1 :L ___________ _r- AS __ - ' AS~ AS AS ( Address) Strobe In Expanded Multi- During reset, AS During reset, AS functions normally. plexed Mode (mode functions normally. ~ 0, 2, 4 or 6), AS § becomes high impedance 1: ..... .j..l state for a half E ~ u clock cycle during C ;::! reset. f<. o Therefore, I/O Port 3 functions as data bus :I during reset. w ~ <0 t.) 01 o Item HD630lV H06370lVO HD630lVl The SCI receive margin is shown below. HD6303R HD6303Rl Ho63pOlMl The SCI receive The SCI receive margin START 1 2 3 4 5 6 7 8 STOP margin is shown below. is shown below. I Bit distortion tolerance ±37. 5~ Bit distortion tolerance ±25% Ideal waveform, I to (t-to) Ito (t-to)/to To .1 SCI Receive Character Character Margin distor-tion +3.75~ distortion tolerance -2.5% tolerance ±3.75% I (T-To)/To (T-To) /To Real 1 waveform. ~ .1 • T § :I -.-I .jJ Bit distortion tolerance ~ 0 t: ±37.5% ::l (t-to) Ito '" Character distortion " :I HD630lVl HD6303R H06303Rl HD63pOlMl tolerance (T-To)/To ±3.75% i Supply Voltage VCC =5V±10% (f=O.l'V2MHz) VCC=5V±10%(f=0.1'V2MHZ) VCC=5V±10%(f=0.1'VlMHz) =3'V6V(f=0.1'V0.5MHz) tAH = 20 ns min t AH , tHW = 60 ns (f=lMHz) = 40 ns ( =1.5MHz) tHW = 20 ns min ~~ Address/Data = 30 ns ( =2MHz) Hold Time tAH and tHW are constant independently of tAH and tHW are proportion (tAH,tHW ) operating frequency. to l/f. (f= operating frequency) 0 1 2 'IMB&> Item HD630lV HD6370lVO (1) tADl and tAD2 are constant independently t ADl , tAD2 and tADL are related to of operating frequency. In HD63BOlV operating frequency (They are in (B version of HD630lV), tADl and tAD2 are proportion to lifo f: operating frequency). Address Delay 160 ns max. at O.lMHz through 2MHz Therefore, if HD637BOlV operates at lower Time operation. operating frequency, tADl' tAD2 and tADL will become 160 ns or more. tADl' tAD 2 (2) tADL is related to operating frequency. and tADL are calculated as follows. (tADL is in proportion to lifo 1 f: operating frequency) tAD (f MHz) * 250 ns (1 MHz) x i(MHz) lin = 10]JA max. Cin = 50pF max. lin and Cin lin = 1.0]JA max. Cin = l2.5pF max. Since RES is multiplexed with Vpp, Cin of RES and lin are larger than those of HD6301V. I • l: ~ () u (IJ III Load Capacitance a. of E Load Capacitance 2 - LSTTL + 40pF IOL = 0.8 rnA 1 - TTL + 30pF IOH = -200]JA 1 - TTL + 90pF IOL = 1.6mA 1 - TTL + 90pF IOH = -200]JA I of Port 1 l: Spec. of Spec. Spec. Crystal Oscillator Rs = 601l max. II Clock frequency (MHz) 1 2.51 4 . o [ 6.0 I 8.0 I IrRs max. (Ill I 500 1120 I 80 I 60 I Storage Tstg = -55 - +125°C Tstg = -55 - +150 o C Temperature ... CAl t1I c.> (J1 (\) Item HD630lV HD6370lvO HD6303Rl H0630lVl HD6303R GND Noise HD63POlMl E """\ / '-- AS~ R/W~ r Ai ~ A Noise x: D1 ---c::.::) >- Noise is Noise is reduced by 50%. ~ reduced by c: 33%. :I .....o +J ~ o ~ If load capacitance in each data line and GND impedance are large, noise may appear on :I address bus during MCU write cycle and data won't be written into RAM correctly. The noise is caused by GND impedance which becomes large when large transient current flows into GND at High to Low transition of data line. Chip design and manufacturing process of the H0630lV differ from those of the HD6370lVO. Miscellaneous Therefore, actual spec. and margin are different between the HD630lV and the H06370lVO. Please carefully examine your system before applying HD630lV or H06370lVO to your system. APPENDIX General purpose PROM programmer corresponding to the 27256 can perform programming to the HD63701VO. When programming, a socket adaptor which changes the number of pins, 40 pins to 28 pins, is necessary. ~HITACHI 353 PROM Programmer and Socket Adaptor Products name PROM Programmer Socket Adaptor H31VSA01A HD63701VO PROM Programmers for 27256 ~HITACHI 354 II Q&A Category Question Answer Process to Use When using an I/O port as an output, Store the data to the Data Register at first and then set a Port as an is the data stored to the Data DDR (DDR=I); if not, unknown data is output from the Outputs Register or is the Data Direction port. Register (DDR) set at first? Relation between How are writing into the timer Free The source of the clock input to the SCI Shift Registers Wri ting into the Running Counter(FRC) and the Serial is the timer FRC. FRC and SCI Communication Interface(SCI) related? Therefore, if new data is written into the FRC, SCI Operation operations are disturbed. See the following diagram. $09,$OA /W ~ :I ~ ~ E J"L FRC -IL Baud Rate - - - Generator Receive Shift] Register I (') Transmi t Shift :I Register * A write into the FRC is prohibited during SCI operations. Writing into the Is it prohibited to write data into Yes. If data is written into the FRC during serial FRC during Serial the Free Running Counter (FRC) during receive/transmit, the FRC stops counting up and the baud Receive/Transmit serial receive/transmit? rate changes. In condition other than serial receive/transmit, it's possible to write. W 01 01 ~ ~ 0) Category Question Answer 1$09 fOA, 1 Write Receive Shiftl E:&~l\l:n~= Register -----J I 1 (( L.jTransmit Shit, Register n '----'r-l' - - - Ir-------' The counter stops and the baud rate changes • • l: ~ (') RDRF State When SCI Receiving What is the state of the Receive Data Register Full (RDRF) flag when the HD6370lVO SCI can receive signals (RE=l) and the wake-up flag (WO bit) is set? TRCSR When the wake-up flag is set (WU=l) the RDRF flag cannot be set. (RDRF=O) I: 76543210 $0011 I RDRFIORFEITDREIRIE IRE ITIE I TE I wu I + ? J1 + 1 Category Question Answer Serial I/O The serial I/O does not operate Just after the initialization of serial I/O, the data Operation satisfactorily. Initialization does transmit is not operative during 10 cycles of Baud Rate not seem to be wrong, but the data is after setting the TE. The reason is as follows. not transmittred. What is wrong? Setting the transmit enable bit (TE bit) causes ten consecutive "1" of preamble and makes the transmitter Initialize by User Program section operative. In other words, the transmitter (1) Set the Rate/Mode Control Register section gets ready after one frame (10 bits) transmitt- (RMCR) to the desired operation. ing time according to the Baud rate. (2) Set the Transmit/Receive Control (ex.) When the Baud rate is set to 9600 Baud (104.2~s Status Register (TRCSR) to the at 1 bit) , desired operation. Set the Baud rate Set TE Transmit OK ~/I////ff~2lT/l/lJ//zJ. _________~ ~104.2~s x 10=1.042ms:- ~ I'J:I: Transmit Inoperative Period ~ Preamble Causing Period :I 1.042ms after setting the TE, the transmitter section is operative. ~ Serial I/O When transmitting the data, is reading The TDRE flag shows if the TDRE register is empty or " :I Register Read the Transmit/Receive Control Register (TRCSR) required? When the transfer interval is long enough compared with the Baud rate, Transmit not. When writing a data to the TDR with TDRE=l, it's not necessary to check the TORE. But reading the TORE flag tells us the·contents of TDR. For example, when new data is written to the TDR with TDRE "0" (TDR Oata Register Empty (TORE) will be set. already has a data), the old data will be erased. In that case, are there any problems When the transfer interval is long enough compared with when transmitting data without checking the Baud rate, there's no problem. However, check the TDRE flag in the TRCSR? TRCSR if possible. w (1l -..j ~ CAl C11 lO~s .: I :+-2 machine cycles"': I I (2) In this case, as a timer interrupt is executed the interrupt mask is automatically set. So IRQl is ignored. ~ See the followings for the illustration of IRQ l and other interrupts and a countermeasure. :I ~ and Other Interrupts ~ (') Main Routine Timer Routine IRQ, Routine ,1 :I IliQ," Interrupt cfIc··' •• '. . Request ~I=l ' .... , : IRQl is ~~~ ignored. Countermeasure Clear the I masJc at the beginning of the timer interrupt routine. Hain Timer IRQ, Routine Routine Routine IRQ1 is acceptable. OCLI , Clears the interrupt mask (I:(). With this method, note the follovinq ; (1) IRQl may be ignored when the request occurs during timer interrupt vectoring. (2) Interrupts form. NiiI or SWI are excluded. Category Question Answer CLI Instruction In theHD63701VO, a timer interrupt To accept an interrupt, two machine cycles are necessary and Interrupt is not accepted in the following between CLI and SEI. That is, in this program, two NOP Operation program. Is there any problem? instructions are necessary. The same thing can be said when using TAP for CLI and SEI. - ~.: ~utine-l Using CLI Using TAP WI CLI I NOP I-WI eLI - - - - , TAP- (Cle-;;r;- the I ~k) I SEI I NOP I 1 NOP I :: I I I SEI I TAP (Sets the I mask) : I B~ LOI I 1 I I 1_ _ _ _ _ _ _ 1 I I I I BRA LOI I I 1 I J 4Z) Relation between With which edges of the EXTAL clock It changes synchronouslY with the falling edge (P of the the External does the E clock change synchronously, EXTAL clock. 1: Clock (EXTAL rising edge (t) or falling edge (~)? ~ Clock) and Enable Clock :XTAL C') (E Clock) :t Constants of the Does the capacitor of the recommended Capacitor Cr does not have upper limit because of the Reset Circui t reset circuit in the HD6370lVO have an Schmitt trigger circuit provided with the ~. upper limit? Available if Rr.Cr»20ms To the system power supply ~I f I~ III~ 'I~ 1 Vee [:trrl~" Rr r T. r RS ifTCS Rr Iml:I ~ RESl ! ~ -iY ...L.C r To peripherals HD6370lVO Rl« R2 ,Rr "C r »20m,s w OJ W ~ c.> ~ Category Question Answer Port Output What data does a port output when the After resetting, since the Data Register of a port is After Resetting Data Direction Register(DDR)=1 undefined, undefined data is output when the DDR=l. after resetting? Input definite data by programming in the Data Register before setting the DDR=I. Schmitt Trigger Is the Schmitt trigger c,ircuit Yes. Circuit of STBY provided with the HD6370lVO STBY? ~ Return from What occurs when returning from the The CPU does not operate normally because the contents J: Standby Mode standby mode without using RES? of each register are not definite. Therefore, always use the RES when returning from the ~ standby mode. o J: Going into the Does the CPU go into the standby mode No. Because there is no connection between the instruc- Standby Mode after current instruction execution tion execution sequence and the standby mode. That is, is completed? when the STBY pin goes into "low", the state is latched at the next rising edge of E clock. Then the internal registers are reset at the next falling edge. ' - - Internal registers : are reset. E I I I I STBY I t Category Question Answer Timing for the The timing for the standby mode is After the RAM Control Register is set in the NMI routine, Standby Mode shown in the HD63701VO user's manual. either STBY or RES can be in the low state with no Tl is not defined. How long is Tl? priority. © NMI --"I!-______ ® REs I I : Tl b'--.j r-- -- ® STBY I I I I I I I I I ,.T2~ ....., j4- I I--- RAM Control Reset Start Register Set T2 Oscillation Stabilization Time ~ :I Usage of Bit How the bit manipulation instructions They are written as follows; ~ (') Manipulator Instructions of the HD63701VO should be written? OIM # $ 0 4 , $ 1. 0 (Direct Addressing) :I OIM # $ 0 4 , $ 1 0 ,X (Index Addressing) I Immediate Data T~ Address Index Register This is an example of OR operation of the immediate data and the memory and storing the result in the memory. The HD63701VO has the following bit manipulation instructions. OIM (IMM) • (M)~(M) AIM (IMM) + (M) ~ (M) ElM TIM (IMM)e (M) ~ (M) (IMM) • (M) These instructions are written in the same way. The following bit manipulations have different mnumonics in the same OP code. w en .. 01 to) 0) 0) Category Question Answer I Bit Manipulation Instruction OP code Mnumonics Function o -Mi 71161 A I M 1 B C L R 1 The memory bit i(i=O to 7) is cleared and the other bits don't change. l-m The memory bit i(i=O to 7) is 72 1 62 o I M B SET set and the other bits don't change. Hi -Hi 75165 1 ElM BTGL The memory bit i(i=O to 7) is ~ inverted and the other bits don't change. :x 1 . m ~ C') 7B 1 6B 1 TIM BTST AND operation test of the memory bit i (i=O to 7) and :x "1" is executed and its corresponding condition code , ---- is changed. Direct Index Addressing Addressing The mnumonics mentioned above can be written as follows. BCLR 3,$10 -AIM #$F7, $10 (Direct Addressing) BCLR 3,$10,X_AIM #$F7, $lO,X (Index Addressing) BSET 3,$10 ~OIM #$08, $10 (Direct Addressing) BSET 3,$10,X~OIM #$08, $lO,X (Index Addressing) TT~ Bit Address Index Register Category Question Answer Usage of Bit Are the bit manipulation instructions It can be used if the port is in the output state Manipulation (AIM, DIM, ElM, TIM) executable when (DDR=l). However, the bit manipulation instruction Instructions to a port is in the output state is executed as follows the Port (DDR=l)? ~@ Writes Reads specified address. Executes logical operation. the result into the specified address. Since the specified address CD reads the pin state of the port, the data is influenced by the pins even if any data is output from the port. RAM Access When executing a program with the RAME (i) The external RAM can be accessed; the internal RAM Disable during bit of the RAM Control Register is neither readable nor writable when the RAME bit ~ Program Execution disabled, is disabled. :I (1) What occurs if the internal RAM (2) If there is no stacking area other than the internal ~ address is accessed? RAM, the MPU will burst when returning from the (2) What occurs if the interrupt interrupt sequence. C') requests are generated? :I cu (J) ...... ~ ~HITACHI 368 HD6301/HD6303 SERIES HANDBOOK Section Five HD6301XO/ HD6303X/ HD63701XO User s Manual 9 ~HnTACHn 369 ~HITACHI 370 Section 5 HD6301 XO/HD6303X/HD63701 XO User's Manual Table of Contents Page 1. OVERViEW ................................................... . 375 1.1 Features ................................................... . 375 1.2 Block Diagrams ............................................. . 377 1.3 Pin Description ............................................. . 380 2. INTERNAL ARCHITECTURE AND OPERATION ...................... . 383 2.1 Operation Modes ............................................ . 383 2.2 Memory Map ............................................... . 386 2.3 Function Pin Description ...................................... . 388 2.4 Ports ...................................................... . 393 2.5 RAM/Port 5 Control Register ................................... . 397 3. CPU FUNCTION ............................................... . 399 3.1 3.2 3.3 3.4 3.5 CPU Registers .............................................. . Addressing Modes ........................................... . Instruction Set .............................................. . CPU Instruction Flow ......................................... . Low Power Dissipation Modes ................................. . 399 400 402 408 410 I 3.6 Trap Function ............................................... . 413 3.7 Reset ..................................................... . 414 3.8 Interrupts .................................................. . 415 4. TIMER 1 ...................................................... . 418 4.1 Free-Running Counter (FRC) .................................. . 419 4.2 Output Compare Registers (OCR) .............................. . 419 4.3 Input Compare Register (lCR) .................................. . 420 4.4 Timer Control/Status Register 1 (TCSR1) ......................... . 420 4.5 Timer Control/Status Register 2 (TCSR2) ......................... . 421 4.6 Timer Status Flags .......................................... . 423 4.7 Precautions on Cleaning the OCF .............................. . 423 5. TIMER 2 ...................................................... . 425 5.1 Timer 2 Upcounter (T2CNT) ................................... . 425 5.2 Timer Constant Register (TCONR) .............................. . 426 5.3 Timer Control/Status Register 3 (TCSR3) ......................... . 426 5.4 Timer Status Flags .......................................... . 428 ~HRTACHH 371 6. SERIAL COMMUNICATIONS INTERFACE. . . . . . . . . . . . . . . . . . . . . . . . . . .. 429 6.1 Initialization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 429 6.2 Asynchronous Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 430 6.3 Clock Synchronous Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 431 6.4 Transmit/Receive Control Status Register (TRCSR). . . . . . . . . . . . . . . . .. 433 6.5 Transmit Rate/Mode Control Register (RMCR). . . . . . . . . . . . . . . . . . . . .. 434 6.6 SCI Receiving Margin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 438 6.7 Timer, SCI Status Flags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 438 6.8 Precaution for Clock-Synchronous Serial Communication Interface. . . .. 439 7. HD63701XO PROGRAMMABLE ROM (EPROM). . ..... . ... ..... . . .. ... 441 7.1 Programming and Verification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 443 7.2 Erasing (Window Package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 444 7.3 Characteristics and Applications ................................ , 444 8. APPLICATIONS................................................. 447 8.1 HD6301XO or HD63701XO in Expanded Mode.. ..... .. . .. ... .. . .... 447 8.2 HD6301 XO or HD63701 XO in Single-Chip Mode . . . . . . . . . . . . . . . . . . .. 448 8.3 Timer Applications ........................................... , 448 8.4 SCI Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 452 8.5 Lowering Operating Current. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 454 8.6 Memory Ready Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 457 8.7 Halt Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 458 8.8 RD, WR Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 459 8.9 LCD-II Interface Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 460 8.10 Oscillation Board Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 461 APPENDIX I. ELECTRICAL CHARACTERISTICS. . . . . . . . . . . . . . . . . . . . . . . .. 463 APPENDIX II. INSTRUCTION EXECUTION CYCLES. . . . . . . . . . . . . . . . . . . . .. 485 ~HITACHI 372 APPENDIX III. QUESTIONS AND ANSWERS ........................... . 491 111.1 Parallel Ports ............................................... . 491 111.2 Serial Ports ................................................ . 492 111.3 Timer/Counter .............................................. . 493 111.4 Bus Interface ............................................... . 497 111.5 Interrupt Control. ............................................ . 500 111.6 Oscillation Circuit ........................................... . 502 III. 7 Reset ..................................................... . 502 111.8 Low Power Dissipation Mode .................................. . 505 111.9 Software ................................................... . 507 111.10 Others .................................................... . 508 APPENDIX IV. THE DIFFERENCES BETWEEN HD63701XO and HD6301XO ... 509 APPENDIX V. PROGRAM DEVELOPMENT PROCEDURE I AND SUPPORT SYSTEM ............................... . 510 ~HITACHI 373 ~HITACHI 374 Section 1. Overview The HD6301 XO, HD6303X, and the HD63701 XO are high-performance CMOS, 8-bit, single-chip microcomputer units (MCU s) which are object-code compatible with the HD6301 V. In addition to the CPU, these MPUs contain 192 bytes of RAM, a 16-bit 4-function timer, an a-bit reload able timer, a serial communications interface (SCI), and 53 parallel lines. The HD6301XO has 4k bytes of masked ROM. The HD63701XO has 4k bytes of EPROM sometimes referred to as programmable ROM or PROM in this handbook. The HD6303X has no ROM. The MPUs' halt and memory ready functions enable them to release external buses and perform low-speed external memory access. The HD63701XO's programmable ROM is programmed by the same method as the standard 2732A EPROM. It is available in ceramic packages. The ceramic package with window is erasable for use in the debugging development stage. 1.1 Features The HD6301XO, HD6303X, and HD63701XO provide the following features. Instruction set compatible with the HD6301 V1 On-board ROM - 4k bytes programmable (HD63701 XO) - 4k bytes masked (HD6301 XO) 192 bytes RAM 53 parallel I/O lines - 24 common I/O lines (ports 2, 3, and 6) - 21 output only lines (ports 1, 4, and 7) - 8 input only lines (port 5) Darlington transistor direct drive lines (ports 2 and 6) 16-bit programmable timer - 1 input capture register - 1 free-running counter - 2 output compare registers 8-bit reloadable counter - External event counter - Square-wave generator ~HITACHI 375 Serial communications interface (SCI) - Asynchronous mode/clocked synchronous mode - 3 transmit formats (asynchronous mode) - 6 clock sources Memory-ready function for low-speed memory access Halt function Error detection function (address trap. opcode trap) Interrupts -3 external -7 internal MCU operation modes - Mode 1: expanded mode (internal ROM inhibited) - Mode 2: expanded mode (internal ROM valid) - Mode 3: single chip mode PROM mode (HD63701XO) Address space up to 6Sk bytes Low power modes -Sleep mode - Standby mode Minimum instruction time 0.5 J.1S (f = 2.0 MHz) ~HITACHI 376 1.2 Block Diagrams Figures 1-1 ,1-2, and 1-3 are block diagrams for HD6301XO, HD6303X, and HD63701XO respectively. '" ~ cc -- ~~l!lllt III ::;; , Vss " ~ Vss ::;; ~ ::;; P2o(Tinl o N C. a: C C -' « ~ -' ;5 x I~ I~ 1~l§lal w P~I(Tout1) ~ CPu ....-- p,JRD P22(SCLK) t: C it. C ~¥~a:I:; g;a: !::E ~ p,/WR t-- 15'" P23(Rx) '). '" P"/R/W PHITx) c. ~ P,iOR PulTout2) L...-- P,iBA P211(Tout31 P21(TCLK) L., l...- r--- lL! t: C it. c t-- P3r10 I-- P3,/O, 0 f--- t-- P310 L.- -,§ '"it.t: r-- P J0 U 2 3 0- r-- P3iO• i-- P3JO!) I...-- r-- P3a/De i-- P310 , ~~ I '-- r-- I-- P,r/At;) t-- P,,IA, ~ A t-- P,/A 2 ;; t-- P'3/A 3 '---- ~ . L- 0 c. t-- ?14/A4 I-- P,t/As ....-- ~.--- m I-- P,s/A, IRQ, Pso(iRQJ I-- PH/A, Ps,fiRO: IRQ 21 !11 '-- PS2(MR) r-- PS3(HALT) on 15 I-- p.rlAe P" c. t-- P.lAo P" I-- P .. /A,o .., t-- p.iA " Pw P" L-- C ~ t-- P.iA'2 t-- P•./A'3 t-- P"a/Au P eo - - - t-- P,n/AH PSI - - - - - - P82~ P63~ HITACHI 379 1.3 Pin Description Figure 1-4 shows the pin arrangemen's for the various packages. Table 1-1 lists pin functions for the HD6301XO, HD6303X, and the HD63701XO in modes 1, 2, and 3. Table 1-2 lists pin functions for the HD63701 XO in PROM mode. For further pin description, see 2.3 Functional Pin Description, and 2.4 Ports. • HD6301XOp, HD63A01XOp, HD63B01XOP (DP-64S) • HD6301XOF, HD63A01XOF, HD63B01XOF (FP-80) • HD6303Xp, HD63A03Xp, HD63B03XP (DP-64S) • HD6303XF, HD63A03XF, HD63B03XF (FP-80) • HD63701XOC, HD637A01XOC, HD637B01XOC (DC-64S) Vss XTAL ,0 . e. E liD/P7o EXTAL MPa MP, .,•• 80 WR/P7, R/W/P72 UR/P7. D,/P3,/EO, RESNpp 5. BA/P7. NC STBY 58 Do/P30/EOo NMI/EA. D,jP3,/EO, P2o/Tin "•• D2IP32/E02 P2,/Toutl P22/SCLK •• Do/P3./EO• D./P34/EO. P2./Rx D5/P35/EO. P2./Tx Do/P3./EO. P2./Tout2 D,/P3,/EO, P2o/Tout3 AoIPlo/EAo P2,/TCLK A,/Pl,/EAi PSo/IRO, A2/Pl21EA2 PS,/IRO, A2/Plo/EA. PS./MR A./Pl./EA. PS./HALT A./Pl5/EA. ps./iS Ao/Ple/EA. PS./05 A,/Ph/EA, A7/P1,/EA, PS. Vpp/OE Vpp/OE PS, Ae/P40/EA. Aa/P4olEA, PBo A./P4,/EA. PB, A,o/P42/EA,o NC 24 4' PB2 A,,/P4./EA,, P6. A12/P40 PB. A,./P4. P6. A,./P4. PB. A,5/P4, PB, Vee • HD6301XOCp, HD63A01XOCp, HD63B01XOCP (CP-68) • HD6303XCp, HD63A03XCp, HD63B03XCP (CP-68) .. ~ 2 >- ;t.J ~~~f~~f ~~~"E~'~will@i~i ~C~OO.~N_~~~~~~2; P2~~~ ~~ 0 :: ~:~:!:;~: P2 2/SClK 12 58 D~P34/E04 P23/Rx 13 57 Ds/P3 5/EOa P2.1T. 14 56 OIl/P3a1EOe P2 6!ToutZ 15 55 D7/P3 7/EO, P2e/Tovt3 16 54 NC P2,/TCLK 17 53}:: AoI P1 01 EAo P501IR~~ ~: :~F ::~:~ :~::: p:~~:~ ~~ 50,= AyP1VEA3 P5yHALl PS..,'rs 22 ::F :;::~:: 47,= Ae!P1 e1 EA a P6~~ P5, 2: 26 ::F ~:~~~EA7 As/ P401 EAa ~~~gM~~~~~~~~~;~: Note: NC; No connection Figure 1-4. Pin Arrangement ~HITACHI 380 Table 1-1. Pin Functions Number DP-64S FP-80 CP-68 Name Function 73 2 VSS Ground 2,3 74,75 3,4 XTAL,EXTAL Crystal connections. Connect external clock to EXTAL 4,5 77,78 5,6 MPO, MP1 Operation mode 6 79 7 RES Reset input 7 80 8 STBY Standby input 8 9 NMI Nonmaskable interrupt 9 5 10 Tin/P20 * Timer 1 capture input Port 2 10 6 11 Tout1/P21 * Timer 1 OCR1 output 11 7 12 SCLK/P22 * SCI clock input or output 12 8 13 Rx/P23 * SCI receive input 13 9 14 Tx/P24 * SCI transmit input 14 10 15 Tout2/P25 * Timer 1 OCR2 output 15 11 16 Tout3/P26 • Timer 2 output 16 12 17 TCLK/P27, Timer 2 external clock input 17,18 14,15 19,20 IR01/P50'* Level-detect interrupt inputs Port 5 IR02/P51 19 16 21 MR/P52* Memory ready input 20 17 22 HALT/P53 * Halt request input 21-24 18-21 23-26 P54-P57 25-32 25-32 27-34 P60-P67 Port 6 33 33 36 VCC Power supply 34-41 34-40, 37 -44 A15 /P4y-* Address bus, bits15-8 PortA 43 A8 /P4 0 * 42 44 45 \iss * Ground * Mode 1 or Mode 21M ode 3 ~HITACHI 381 Table 1-1. Pin Functions (continued) Number DP-64S FP-80 CP-68 Name Function 43-50 45-52 46-53 A7/P1 7- • Address bus, bits 7-0 Port 1 AO/P1 0 • 51-58 55-59, 55-62 D7/P3r · Data bus Port 3 62,64, DO/P30 • 65 59 66 63 BA/P74 · Bus available output Port 7 60 67 64 LlR/P73 · Opcode fetch cycle output 61 69 65 R/W/P72 . Reacllwrite output 62 70 66 WR/P71 · Write cycle output 63 71 67 RD/P70· Read cycle output 64 72 68 E External clock output ·Mode 1 or Mode 2/Mode 3 Table 1-2. Pin Functions for HD63701 XO PROM Mode Number Name Function DP-64S 7 STBY PROM mode input 38-41 EA11-EA8 Address input bus, bits 11-8 42 Vpp/OE Programming power supply 43-50 EArEAo Address input bus, bits 7-0 51-58 EOrEOo Data input bus Note: Ground all other HD63701 XO pins in PROM mode. Table 1-3. Relationship of HD6301XO, HD6303X, and HD63701XO Operating Modes Mode Device Type 2 3 EPROM HD6301XO X X X HD6303X X HD63701XO X X X X ~HITACHI 382 Section 2. Internal Architecture and Operation 2.1 Operation Modes The HD6301XO and HD63701XO operate in three MCU modes. The HD63701XO also operates in PROM mode. The HD6303X only operates in MCU mode 1. The mode program pins MPO and MP1, and the STBY pin select the mode (table 2-1). • MCU 1 (expanded): external memory access enabled, internal ROM disabled • MCU 2 (expanded): external memory access enabled, internal ROM enabled • MCU 3 (single-chip): external memory access disabled • PROM prgramming: MCU disabled, PROM programming enabled Table 2-1. Mode Selection MP1 MPO STBY ROM RAM Interrupt Vector Operation Mode Low High X External Internal External MCU 1 (expanded) High High Low Low High Low X X Low Internal Internal Internal Internal Internal X Internal Internal X MCU 2 (expanded) MCU 3 (single-chip) PROM programming I Note: X = Don't care ~HITACHI 383 2.1.1 MCU Mode 1 (Expanded) In MCU mode 1, port 3 is the data bus, port 1 is the lower address bus, and port 4 is the upper address bus. They can directly interface with HD6800 buses. Port 7 supplies signals such as R/W. See table 2-2. In mode 1, the ROM is disabled and the external address space is 65k bytes (figure 2-1). Since the HD6303X has no internal ROM, it only operates in mode 1. Vee E _RD '-WR Rm RES DR STBY NMI BA PortZ MCU Port 3 8 I/O Lines Timer 1. Z 8 Data Bus SCI Port 1 Port 5 8 Input Lines 8 Address Bus IRQ•• IRCh Port 4 MR.HALT 8 Address Bus Port 6 8 I/O Lines Figure 2-1. MCU Mode 1 2.1.2 MCU Mode 2 (Expanded) MCU mode 2 is the same as mode 1, except that the ROM is enabled. The external address space is 61 k bytes (figure 2-2).. E An WR c:::::J R/W RES LlR STBY BA NMT Port 2 Port 3 8110 Lines Timer 1. 2 SCI 8 Data Bus Port 5 8 Input Lines Port 1 IRQ ,. IRQ, MR. HALT 8 Address Bus Port 6 Port 4 81/0 Lines 8 Address Bus Figure 2-2. MCU Mode 2 ~HITACHI 384 2.1.3 MCU Mode 3 (Single-Chip) In MCU mode 3, all ports are I/O ports. There is no interface to external buses (figure 2-3). E Port 7 5 Output Lines RES STBY Port 3 NMI Port 2 8110 Lines 8110 Lines Timer 1, 2 SCI Port 1 Port 5 8 Output Lines 8 Input Lines IRO"IRO, Port 6 Port 4 8110 Lines 8 Output Lines 2.1.4 PROM Mode Figure 2-3, MCU Mode 3 In PROM mode, the HD63701XO's EPROM can be programmed (figure 2-4, table 2-2). Refer to Section I 7, Programmable ROM, for details. Vee MP, MP, STBY Port 3 8 Data Bus Port 1 8 Address Bus Port 4 4 Address Bus Figure 2-4. PROM Programming Mode ~HITACHI 385 Table 2-2. Port Signals Port MCU Mode 1 MCU Mode 2 MCU Mode 3 PROM Mode Address bus (AO-A7) Address bus ( AO-A7) Output port Address bus (EAO-EA7) 2 110 port I/O port I/O port Connect to ground 3 Data bus (DrDo). Data bus (07-00) I/O port Data bus (E07-EOO) 4 Address bus (Aa-A1S) Address bus ( Aa-A1S) Output port Address bus (EAa-EA11, pins P40-P43 only) S Input port Input port Input port CE (PS7 only) 6 I/O port I/O port I/O port Connect to ground 7 RD, WR, RIW, LlR, SA RD, WR, RIW, LlR, SA Output port Connect to ground 2.2 Memory Map The HD6301XO, HD6303X, and HD63701XO can access up to 6Sk bytes of external memory, depending on the operating mode. Figure 2-S shows a memory map for each mode. The first 32 locations of each map, from $00 to $1 F, are reserved for the MCU's internal register area (table 2-3). MCU Mode PROM Mode Expanded Mode Expanded Mode Single-chip Mode HD63701XO Mode 1 Mode 2 Mode 3 Internal· $0000 Internal* $ O O O O . } Internal Register Register Register External $OOIF External $OOlF Memory Memory Space $0040 Space $0040 Internal Internal Internal RAM RAM RAM $OOFF $OOFF External Memory Space External Memory Space $FOOO Internal Internal ROM ROM $FFFF '--_ _~, $FFFF~~~..:J) $FFFF • Excludes the following addresses • Excludes the following addresses which may be used externally: which may be used externally: $02, $04, $06, $07, $18. $02, $04, $06, $07, $18. Figure 2-S. Memory Maps ~HITACHI 386 Table 2-3. Internal Register Area Address Register RfW State at RESET 00 01 Port 2 data direction register W $FC 02 Port 1 RNJ Undefined 03 Port 2 RNJ Undefined 04 Port 3 data direction register W $FE 05 06 Port 3 RIW Undefined 07 Port 4 RNJ Undefined 08 Timing controVstatus register 1 RNJ $00 09 Free-running counter (upper byte) RIW $00 I OA Free-running counter (lower byte) RNJ $00 08 Output compare register 1 (upper byte) RNJ $FF OC Output compare register 1 (lower byte) RNJ $FF 00 Input capture register (upper byte) R $00 OE Input capture register (lower byte) R $00 OF Timer controVstatus register 2 RIW $10 10 Rate, mode control register RIW $00 11 Tx/Rx control status register RNJ $20 12 Receive data register R $00 13 Transmit data register W $00 14 RAM/port 5 control register RNJ $7C or$FC 15 Port 5 R 16 Port 6 data direction register W $00 ~HITACHI 387 Table 2-3. Intemal Register Area (continued) Address Register RIW State at RESET 17 Port 6 RIW Undefined 18 Port 7 RIW Undefined 19 Output capture register 2 (upper byte) RIW $FF 1A Output capture register 2 (lower byte) RIW $FF 1B Timer controVstatus register 3 RIW $20 1e Timer constant register W $FF 10 Timer 2 upcounter RIW $00 1E Reserved 1F Reserved 2.3 Functional Pin Description 2.3.1 Power (Vec, VSS) Vee and VSS are the power supply pins. Apply +5 V ± 10% to Vee. Tie VSS to ground. 2.3.2 Clock OCTAL, EXTAL) XTAL and EXTAL connect to an AT-<:ut parallel resonant crystal. The chip has a divide-by-four circuit. For example, if a 4 MHz crystal is used, the system clock will be 1 MHz. Figure 2-6 is an example of the crystal oscillator connection. The crystal and CL 1 and CL2 should be located as close as possible to the XTAL and EXTAL pins. No line must cross the lines between the crystal oscillator and the XTAL and EXTAL pins. The EXTAL pin can be driven by an extemal clock with a 45% to 55% duty cycle.· The LSI divides the extemal clock frequency by four. The extemal clock should therefore be less than four times the maximum clock frequency. When using an extemal clock, the XTAL pin should be left open. ~HITACHI 388 AT Cut Parallel Resonant Crystal Oscillator Co=7 pF max Rs=60 II max XTAL 1---........- - - , ~ CU =C L2 EXTALI-- _T-, =10 pF-22 pF±20% (3.2-8 MHz) 1 CL2 - Cu J-J- (a) Crystal Interface XTAL I--- N.C. EXTAL ~ External Clock (b) External Clock Figure 2-6. Recommended Crystal Oscillator Connection 2.3.3 Standby (STBY) The STBY pin puts the MCU in standby mode. When STBY is low, the oscillation stops, and the internal clock is stabilized to put the MCU in a reset condition. To retain the contents of RAM during standby, write 0 to the RAM enable bit (RAM E). RAME is bit 6 of the RAM/port 5 control register at address $0014. RAM is disabled, and its contents are sustained. Refer to 3.5 Low Power Dissipation Mode for I details on the standby mode. When STBY, MPO, and MP1 are low, the MCU is in PROM mode. Refer to Section 7, Programmable ROM for details. 2.3.4 Reset (RES) This pin resets the MCU's internal state and provides a startup procedure. The RES input must be held low for at least 20 ms during power-on. The CPU registers accumulator, index register, stack pointer, condition code register except for mask bit, RAM, and the data registers of the ports are not initialized during reset, so their contents are undefined. 2.3.5 External Clock (E) E provides a TTL-compatible system clock to external circuits. Its frequency is one-fourth that of the crystal oscillator or external clock. E can drive one TTL load and 90 pF. ~HITACHI 389 2.3.6 Nonmaskable Interrupt (NMI) When CPU detects a falling edge at the NMI input, it begins the internal nonmaskable interrupt sequence. The instruction being executed when the NMI is detected will proceed to completion. The interrupt mask bit of the condition code register does not affect the nonmaskable interrupt. In response to an NMI interrupt, the contents of the program counter, index register, accumulators, and condition code register will be saved onto the stack. After they are saved, a vector is fetched from $FFFC and $FFFD to the program counter, and the nonmaskable interrupt service routine starts. Note: After reset, the stack pointer should be initialized to an appropriate memory location before any NMI input. 2.3.7 Interrupt Requests (IR01. IR02) The interrupt requests are level-sensitive inputs which request an internal interrupt sequence from the CPU. 2.3.8 Mode Program (MPO. MP1) These pins determine the operation mode. Refer to 2.1 Operation Mode for details. Note: The following signals, RD, WR, AIW, L1R, MR, HALT, and SA, are only used in modes 1 and 2. 2.3.9 ReadIWrite (RIW; P72) The readlwrite signal shows whether the MCU is in read (RIW high) or write (RIW low) state to the peripheral or memory devices. It is usually high, in read state. R/W can drive one TTL load and 30 pF. 2.3.10 Read and Write (RD; P70. WR; P71) The read and write outputs show active low outputs to peripherals or memories when the CPU is reading or writing. This enables the CPU to access LSI peripherals with RD and WR inputs easily. These pins can drive one TTL load and 30 pF. 2.3.11 Load Instruction Register (UR; P73) The L1R output low shows that the instruction opcode is on the data bus. L1R can drive one TTL load and 30 pF. ~HITACHI 390 2.3.12 Memory Ready (MR; P52) The memory ready control input lengthens the system clock's high period to allow access to low-speed memory. When MR is high, the system clock operates normally. But when MR is low, the high period will be lengthened depending on its low time in integral multiples of its cycle time. It can be lengthened up to 91JS. During internal address or invalid memory access, MR is prohibited internally from decreasing operation speed. Even in the halt state, MR can lengthen the high period of the system clock to allow peripheral devices to access low-speed memories. MR is also used as P52. The function is chosen by the enable bit in the RAM/port 5 control register (bit 2) at $0014. See 2.5 RAM/Port 5 Control Register for details. 2.3.13 Halt (HALT; P53) The halt control input stops instruction execution and releases the buses. When HALT switches low, the CPU finishes the current instruction, then stops and enters the halt state. When entering the halt state, the CPU sets BA (P74) high, and sets the address bus, data bus, RD, WR, and RlW to high impedance. When an interrupt occurs in the halt state, the CPU cancels the hall, and executes the interrupt service routine. Note: When the CPU is in the interrupt wait state, executing the WAI instruction, HALT should be held high. If halt turns low, the CPU may fetch the incorrect vector after releasing the halt state (figure 2-7). If a halt is expected, a loop should be used instead of WAI (figure 2-8) . . .. .. WAI HALT input ~;::; Incorrect Vector (MSB) Waiting interrupt l (Accept interrupt) ( Incorrect Vector (LSB) Opcode Fetch .. Fetch Vectors • Execute interrupt routine II .. • Branch destination undefined (CPU burst) Figure 2-7. HALT AfterWAI ~HITACHI 391 • • • • CLI CLI LOOP BRA WAI LOOP • • • • • Error Occurs • Recommended Example Figure 2-8. Branch Replacement for WAI 2.3.14 Bus Available (BA; P74) The bus available output control signal goes high when the CPU accepts HALT and releases the buses. It is normally low. The HD6800and HD6802 bring BA high and release the buses at WAI execution, but the HD6301 XO and HD63701 XO don't. But if HALT goes low when the CPU is in the interrupt wait state after having executed a WAI, the CPU sets BA high and releases the buses. When HALT goes high, the CPU returns to the interrupt wait state. The following signals, CE and Vpp/OE, are only used in the HD63701 XO PROM programming mode. 2.3.15 Chip Enable (CE; P57) The chip enable input enables PROM programming and verifying. When this signal is low, the PROM is enabled. The PROM cannot be programmed or verified with CE high. 2.3.16 Program Voltage/Output Enable (Vpp/OE) The program voltage/output enable pin is the input for the program voltage for programming the PROM, and the control for data verification output. To program data from port 3 (EOO-E07) into the PROM, apply 21 V ± 0.5 V to Vpp while holding CE low. Set the PROM address on port 1 and 4 (EAO-EA11). To verify, bring the OE pin low. The data addressed by EAO-EA11 will be output at EOO-E07. When OE is high, port 3will be high impedance. In the MCU modes, connect this pin to VSS. ~HITACHI 392 2.4 Ports The HD63701XO provides seven ports (six 8-bit ports and a 5-bit port). Some pins have other uses, as shown in table 2-2. Table 2-5 shows the addresses of the ports and their data direction registers. Figure 2-9 shows block diagrams of each port. Table 2-6 shows the state of eachport at reset. Table 2-5. Port and Data Direction Register Address Port Port Address Data Direction Register $0002 2 $0003 $0001 3 $0006 $0004 4 $0007 5 $0015 6 $0017 $0016 I 7 $0018 ~HITACHI 393 Data Bus Data Bus Tri-state Control Mode I, 2 Mode I, 2 ...L Address Bus, ..L Address Bus, Control Signal _ _...r""1.._ _ _ _ _--.J Control Signal--..;-..--------l PROM Mode Port 4 (Bit 4 to 7), Port 7 :~~~ss Bus _ _ _ _ _r-L---,___-< (HD637D1 XD only) Port 1, Port 4 (Bit 0 to 3) Data Bus Port 5 Data Bus Data Bus _ _ _---J-'\......_~ CPU Internal Bus _I-----------J PROM Mode PROM Mode ~ _ _ ...L -r,-_ PROM Data Bus _ _ _ _ _ _ _ _...J ..L (HD63701 XO only) (HD63701 XO only) Port 5 (Bit 7) Port 3 Port Write Signal Data Bus Data Bus Timer I, 2, _+-____ ~'____' Trl-state SCI Output Control Port Read Signal ~ Timer I, 2 , _ - - - - - - - -____C Timer 1 Input SCI Input (P2 0 only) --------~ Port 2 Port 6, Port 2 (Bit 0) Figure 2-9. Port Block Diagrams ~HITACHI 394 Table 2-6. Port at Reset (Modes 1 and 2) Port State at Reset 1 (AO-A7) High 2 High impedance 3 (00-07) High impedance 4 (AS-A15) High 5 High impedance 6 High impedance 7 RD, WR, R1W, LlR = High SA = Low Note: All ports are high impedance after reset in mode 3. 2.4.1 Port 1 In the MCU modes, port 1 is an S-bit output port. In mode 3 (single-chip), port 1 is high impedance during reset, and stays high impedance after reset is released. When the CPU writes to the port 1 data register, the data written will appear at port 1. Once port 1 is in the output state, it operates as an output until reset. The CPU can read the port 1 data register for bit manipulation instructions. In modes 1 and 2, port 1 is used for the lower byte of the address bus. Port 1 can drive 1 TTL load and 30 pF. In the PROM mode, port 1 is the lower byte of the PROM address (EAQ-EA7)' 2.4.2 Port 2 Port 2 is an S-bit input/output port. The port 2 data direction register (DDR) controls the VO state (figure 2-10). Bit 0 controls the I/O direction of P20, and bit 1 controls the direction of P21-P27' A 1 specifies input, 0 specifies output. Figure 2-10. Port 2 Data Direction Register Port 2 is also used as I/O pins for the timers and SCI. In this case, port 2 pins except P20 automatically become inputs or outputs regardless of the data direction register's value. ~HITACHI 395 A reset clears the port 2 DDR and configures port 2 as an input port. Port 2 can drive 1 TIL load and 30 pF. In addition, it can produce 1 mA at VOUT = 1.5 V to directly drive the base of Darlington transistors. When a write-only register like a DDR is read by the MCU, $FF always appears on the internal data bus. Whenever the MCU performs an arithmetic or logic operation between memory, and a write-only register, the resun will be $FF. AIM, OIM, and ElM instructions cannot be applied to the DDR. 2.4.3 Port 3 Port 3 is an a-bit I/O port. The port 3 DDR controls its direction. If bit 0 of the DDR is 1, port 3 is an input port. If it is 0, port 3 is an output (figure 2-11). The DDR is cleared during reset. In modes 1 and 2, port 3 is the data bus (DO-D7). In the HD63701XO PROM mode, port 3 is the PROM data bus (EOO-E07). In the PROM mode, port 3's direction is controlled by OE, not the DDR. Port 3 can drive 1 TIL load and 90 pF. 765432 0 I - - I - I - I- I -I - I~oDrt~ I $0004 Figure 2-11. Port 3 Data Direction Register 2.4.4 Port 4 Port 4 is an a-bit output-only port like port 1. In modes 1 and 2, it outputs the upper byte of the address (Aa-A15). In the HD63701XO PROM mode, P40-P43 are used as the upper PROM address bits (EAa- EA 11)· 2.4.5 Port 5 Port 5 is an a-bit input-only port. The lower four bits (P50-P53) are also used for interrupt, MR and HALT input. In the HD63701XO PROM mode, P57 is used as CE to control the PROM. 2.4.6 Port 6 Port 6 is an a-bit I/O port. Each bit in the port 6 data direction register controls the direction of the corresponding bit of port 6. A 1 specifies input, 0 speCifies output. Port 6 ~an drive 1 TIL load and 30 pF. In addition, it can produce 1 mA at VOUT = 1.5 V to directly drive the base of Darlington transistors. A reset clears the port 6 DDR. ~HITACHI 396 2.4.7 Port 7 Port 7 is a 5·bit output port. In mode 3, port 7 is high impedance during and after reset. When the CPU writes to the port 7 register, the data will appear at port 7. Once port 7 is in the output state, it will be an output until reset. The CPU can read the port 7 data register for bit manipulation instructions. Bits 5-7 will be read as 1. In modes 1 and 2, port 7 is used for control signals (RD, WR, RNI, LlR, and BA). Port 7 can drive 1 TTL load and 30 pF. 2.5 RAM/Port 5 Control Register The control register (figure 2-15) located at $0014 controls on-chip RAM and port 5. Figure 2-15. RAM/Port 5 Control Register 2.5.1 IRQ Enable (IRQ1E, IRQ2E) When IRQ1 E and IRQ2E are 1, P50 and P51 are interrupt pins IRQ1 and IRQ2' When these bits are 0, the CPU doesn't accept external interrupts. External interrupts won't cancel the sleep state. These bits are 0 after reset. Bits 0, 1. 2.5.2 Memory Read Enable (MRE) When MRE is 1, P52 is used as the memory ready (MR) signal. When it is 0, the MR signal is inhibited. In mode 3, the MR signal is inhibited regardless of MRE. MRE becomes 1 after reset. Bit 2. 2.5.3 Halt Enable (HL TE) When HLTE is 1, P53 is used as the HALT input. When 0, the halt function is inhibited. In mode 3, the HALT signal is inhibited regardless of the value of HLTE. HLTE becomes 1 after reset. Note: When using P52 and P53 for port bits in modes 1 and 2, clear MRE and HLTE after reset. If P52 or P53 is brought low before MRE or HLTE are cleared, a memory ready or halt will be accepted. Bit 3. ~HBTACHI 397 2.5.4 RAM Enable (RAME) RAME controls on-chip RAM. When RAME is 0, on-chip RAM is disabled, and the CPU can read from external memory at addresses $0040-$OOFF in modes 1 and 2. RAME is 1 after reset and on-chip RAM is enabled. RAME should be set to 0 at the beginning of standby mode to protect on-chip RAM. Bit 6. 2.5.5 Standby Power (STBV PWR) When Vee is not provided in standby mode, STBY PWR is cleared. The STBY PWR flag can be read and written by software. If it is set to 1 before standby mode and remains set after returning from standby mode, Vee has been provided during standby, and on-chip data is valid. Refer to 3.5 Low Power Dissipation Mode. Bit 7. ~HITACHI 398 Section 3. CPU Function 3.1 CPU Registers The CPU has three 16-bit registers and three 8-bit registers (figure 3-1). 7 ~ ____ ! _____ 0 7 U_____ ~ ____ D 1 0 8 -Bit Accumulators A and B Or 16-Bit Double Accumulator D 15 0 15 0 I X I Index Register (X) 15 0 I SP I Stack Pointer (SP) 15 0 I PC I Program Counter (PC) 7 0 11 r I Iz IV IC ICondition Code Register (CCR) 1 1H 1 I N ~ Carry/Borrow from MSB Over flow Zero Negative Interrupt Half Carry (From Bit 3) Figure 3-1. CPU Registers 3.1.1 Accumulators (ACCA, ACCs, ACCD) Two 8-bit accumulators, ACCA and ACCB, store the result of arithmetic/logic operations and data. When combined, these make up the i6-bit accumulator ACCD used for 16-bit operations. Note that the contents of ACCA and ACCB are destroyed by an ACCD operation. 3.1.2 Index Register (IX) The i6-bit register IX stores 16-bit data for use in indexed addressing or for general purposes. 3.1.3 Stack Pointer (SP) The contents of the16-bit register SP indicate the address of a stack. SP can also be used as a general-purpose register. 3.1.4 Program Counter (PC) The contents of the 16-bit PC indicate the address of the instruction being executed. Note that software cannot access this register. @HITACHU 399 3.1.5 Condition Code Register (CCR) The CCR register consists of the carry (C), overflow (V), zero (Z), negative (N), interrupt mask (I), and half-carry (H) bits. After an instruction is executed, the CCR bits change state depending on the result of the operation. They can be tested by conditional branch instructions. The upper two bits of this register are not used. Half-Carry (H):H is set to 1 if a carry at bit 3 or bit 4 occurs during an ADD, ABA, or ADC instruction. It is cleared if no carry occurs. Interrupt Mask (I) :When I is set to 1, it. disables all maskable interrupts (IR01, IR02, and IR03)' Negative (N): N is set to 1 if the MSB of the result of an operation is 1. N is cleared if it is O. Zero (Z): Z is set to 1 if the result of an operation is zero. Z is cleared if it is not zero. Overflow (V): V is set to 1 if the result of an operation shows a two's complement overflow. It is cleared if there is no overflow. Carry (C): C is set to 1 if a carry or borrow is generated from the MSB. If there is no carry or borrow, it is cleared. 3.2 Addressing Modes The HD6301XO, HD6303X, and HD63701XO instructions have seven addressing modes. 3.2.1 Accumulator Addressing (ACCX) The instruction addresses an accumulator and ACCA or ACCB is selected. Accumulator addressing instructions take one byte. 3.2.2 Immediate Addressing Immediate addressing places the data in the second byte of an instruction, except LOS and LOX, which use the second and third bytes. An immediate instruction causes the CPU to address this operand. Immediate instructions take 2 or 3 bytes. 3.2.3 Direct Addressing In direct addressing, the second byte of an instruction holds the address where the data is stored. 256 ¢!)HITACHI 400 bytes ($OO-$FF) can be addressed directly. Storing data in this area reduces instruction time, .so configuring $OO-$FF as user's RAM is recommended. Direct addressing instructions take 2 bytes, or 3 bytes for AIM, OIM, ElM, or TIM. 3.2.4 Extended Addressing In extended addressing, the second byte of an instruction holds the upper eight bits of the absolute address of the stored data, and the third byte holds the lower eight bits. Extended addressing instructions take 3 bytes. 3.2.5 Indexed Addressing In indexed addressing, the second byte of the instruction (third byte for AIM, OIM, ElM, or TIM instructions) is added to the lower eight bits of the index register. The carry is added to the upper eight bits of the index register, and the 16-bit sum is the memory location of the data. The modified address is held in the temporary address register, so the index register doesn't change. Indexed addressing instructions take 2 bytes, or 3 bytes for AIM, OIM, ElM, or TIM. 3.2.6 Implied Addressing In implied addressing, the instruction itself specifies the address. For example, the instruction addresses the stack pointer or index register. Implied addressing instructions take 1 byte. 3.2.7 Relative Addressing In relative addressing, the second byte of the instruction and the lower eight bits of the program counter are added. The carry or borrow is added to the upper eight bits of the program counter. Locations from -126 to +129 bytes from the current location can be addressed. Relative addressing instructions take 2 bytes. ~HITACHI 401 3.3 Instruction Set The HD6301XO, HD6303X, and HD63701XO are object-code upwardly compatible with the HD6801 to use all instructions of the HMCS6800. The instruction time of key instructions has been reduced, improving throughput. 3.3.1 Additional Instructions Bit manipulation, index register and accumulator exchange, and sleep instructions have also been added to the HD6801 instruction set. AIM, OIM, EOM, and TIM are 3 byte instructions. The first byte is the opcode, second byte is the immediate data, and the third byte is the address modifier. AIM: ANDs the immediate data with the memory contents and stores the result in memory. (M) AND (IMM) -. (M). OIM: ORs the immediate data with the memory contents and stores the result in memory. (M) OR (IMM) -. (M). ElM: EORs the immediate data with the memory contents and stores the result in memory. (M) EOR (IMM) -, (M). TIM: ANDs the immediate data with the memory contents and changes the related flag in the condition code register. (M) AND (IMM). XGDX: Exchanges the contents of the accumulator with the contents of the index register. (ACCD) .-, (IX). SLP: Puts the MCU into sleep mode. Refer to 3.5 Low Power Dissipation Mode for details. 3.3.2 Instruction Set Summary Tables 3-1 to 3-5 summarize the instruction set. Accumulator and memory manipulation instructions: table 3-1 • Index register and stack manipulation instructions: table 3-2 • Jump and branch instructions: table 3-3 • Condition code register manipulation: table 3-4 • Opcode map: table 3-5 ~HITACHI 402 Table 3-1. Accumulator and Memory Manipulation Instructions Condition Code Addressing Modes Register IMMED DIRECT· INDEX EXTEND IMPLIED Boolean/ 5 4 3 2 1 0 Operations Mnemonic OP - # OP - # OP - # OP - # OP - # Arithmetic Operation H I N Z V C Add ADDA 8B 2 2 9B 3 2 AB 4 2 BB 4 3 A+M~A I • I I I I ADDB CB 2 2 DB 3 2 EB 4 2 FB 4 3 B+M~B I • J J : J A:B+M: M+l~ Add Double ADDD C3 3 3 D3 4 2 E3 5 2 F3 5 3 A:B • • J J ! J Add Accumulators ABA IB 1 1 A+B~A J • J J J J Add With Carry ADCA 89 2 2 99 3 2 A9 4 2 B9 4 3 A+M+C~A J • J J J J ADCB C9 2 2 D9 3 2 E9 4 2 F9 4 3 B+M+C~B J • J J J ! AND ANDA 84 2 2 94 3 2 A4 4 2 B4 4 3 A· M-·B • • J I R • ANDB C4 2 2 D4 3 2 E4 4 2 F4 4 3 B· M-B • • R • J J Bit Test BIT A 85 2 2 95 3 2 A5 4 2 B5 4 3 A·M 0 • J J R • BIT B C5 2 2 D5 3 2 E5 4 2 F5 4 3 B·M • • J J R • Clear CLR 6F 5 2 7F 5 3 OO~M • • R 5 R R CLRA 4F 1 1 OO~A 0 0 R 5 R R CLRB 5F 1 1 OO~B • • R 5 R R Compare CMPA 81 2 2 91 3 2 Al 4 2 Bl 4 3 A-M • • J J J J CMPB Cl 2 2 Dl 3 2 El 4 2 Fl 4 3 B-M 0 • J J J J Compare Accumulators CBA 11 1 1 A-B • • J J J J Complement, 1's COM 63 6 2 73 6 3 M~M 0 0 J J R S COMA 43 1 1 A~A 0 0 J I R 5 COMB 53 1 1 B~B 0 • I I R 5 Complement, 2'5 NEG 60 6 2 70 6 3 OO-M~M 0 • I J CD (V (Negate) NEGA 40 1 1 OO-A~A • • J J CD m NEGB 50 1 1 OO-B~B • • I I CD m Converts binary add of BCD char- Oecimal Adjust. A DAA 19 2 1 acters into BCD format • • J I I 0) Decrement DEC 6A 6 2 7A 6 3 M-l···M • • I I ® • DECA 4A 1 1 A-l~A 0 • I J • @ DECB 5A 1 1 B-l~B • . I I • @ Exclusive OR EORA 88 2 2 98 3 2 A8 4 2 B8 4 3 AEBM~A 0 • J I R • EORB C8 2 2 D8 3 2 E8 4 2 F8 4 3 BEBM~B • • I ! R • Increment INC 6C 6 2 7C 6 3 M+l~M • • J •! ® INCA 4C 1 1 A+l~A • • J I ® • INCB 5C 1 1 B+l~B • • : I ® • Load Accumulator LDAA 86 2 2 96 3 2 A6 4 2 B6 4 3 M~A • • I J R • LDAB C6 2 2 D6 3 2 E6 4 2 F6 4 3 M-B • • I J R • Load Double Accumulator LDD CC 3 3 DC 4 2 EC 5 2 FC 5 3 M+l~B.M~A • • I ! R • Multiply Unsigned MUL 3D 7 1 AXB-·A: B • • • • • Ijj) OR,lnciusive ORAA 8A 2 2 9A 3 2 AA 4 2 BA 4 3 A+M~A • .1 ! ! R • ORAB CA 2 2 DA 3 2 EA 4 2 FA 4 3 a+M~B • • J I R • A~Msp, Push Data PSHA 36 4 1 SP-l~SP • • • • • • B~Msp, PSHB 37 4 1 SP-l~SP • • • • • • Note: Condition Code Register will be explained in Note of table 3-4. $HITACHD 403 Table 3-1. Accumulator and Memory Manipulation Instructions (Cont.) Condition Code Addressing Modes Register IMMED DIRECT INDEX EXTEND IMPLIED Boolean/ 5 4 3 2 1 0 Operations Mnemonic OP - # OP - # OP - # OP - # OP - # Arithmetic Operation H I N Z V C Pull Data PULA • • • • • • 32 3 1 SP+1-SP. Msp'~A SP+1·.. SP. PULB • • • • • • 33 3 1 Msp-B Rotate Left ROL 69 6 2 79 6 3 • • I I lID I ROLA 49 1 1 "1 • • I I lID I ROLB 59 1 1 • • I I lID I Rotate Right ROR 66 6 2 76 6 3 • • I I lID I RORA 46 1 1 "2 • • I I lID I RORB 56 1 1 • • I I lID I Shift Left Arithmetic ASL 68 6 2 78 6 3 • • I I lID I ASLA 48 1 1 "3 • • I I lID I ASLB 58 1 1 • • I I lID I Double Shift Left, Arithmetic ASLD 05 1 1 "4 • • I I tID I Shift Right Arithmetic ASR 67 6 2 77 6 3 • • I I lID I ASRA 47 1 1 "5 • • I I lID I ASRB 57 1 1 • • I I lID I Shift Right Logical LSR 64 6 2 74 6 3 • • R I lID I LSRA 44 1 1 "6 • • R I lID I LSRB 54 1 1 • • R I lID I Double Shift Right Logical LSRD 04 1 1 "7 • • R I lID ! Store Accumulator STAA 97 3 2 A7 4 2 B7 4 3 A-M • • I I R • STAB D7 3 2 E7 4 2 F7 4 3 B-M • • I I R • Store Double A-M Accumulator STD DD 4 2 ED 5 2 FD 5 3 B-M+1 • • I I R • Subtract SUBA 80 2 2 90 3 2 AO 4 2 BO 4 3 A-M···A • • I I I I SUBB CO 2 2 DO 3 2 EO 4 2 FO 4 3 B-M-B • • I I I I A:8-M: M+1- Double Subtract SUBD 83 3 3 93 4 2 A3 5 2 B3 5 3 A:B • • I I I I . - f-t-- Subtract Accumulators SBA 10 1 1 A-B-A • • I I I I Sabtract With Carry SBCA 82 2 2 92 3 2 A2 4 2 B2 4 3 A-M-C-A • • I I I j SBCB C2 2 2 D2 3 2 E2 4 2 F2 4 3 B-M-C-B • • I I I I Transfer Accumulators TAB 16 1 1 • • I I R • A~B TBA 17 1 1 B-A • • I I R • Test Zero or Minus TST 6D 4 2 7D 4 3 M-OO • • r I R R TSTA 4D 1 1 A-OO • • I I R R TSTB 5D 1 1 B-OO • • I I R R And Immediate AIM 71 6 3 61 7 3 M·IMM-M • • I I R • OR Immediate OIM 72 6 3 62 7 3 M+IMM-M • • I I R • EOR Immediate ElM 75 6 3 65 7 3 MEBIMM-M • • I I R • Test Immediate _. TIM 78 4 3 6B 5 3 M·IMM • • I I R • "1 M A B ll.o-1 I C b7 If--l bO "2 M A B ll..Q.l I C b7 If-l bO "3 M - "4 04 C A7 Ace A I Ace 8 AO 87 80 \--0 "5 ~l[{1 I I I I I I I-[] 8 b7 bO C "6 ~ o--l I I I I I I I I-[] B l b7 bO C "7 o--l Ace A I Ace 8 I-[] ~HITACHI A7 AO .87 80 C 404 Table 3-2. Index Register and Stack Manipulation Instructions Condition Code Addressing Modes Register IMMED DIREC'F INDEX EXTEND IMPLIED 5 4 3 2 I 0 -, -, -, Boolean/ - , Pointer Operations Mnemonic OP - # OP OP OP OP Arilhmetic Operation H I N Z V C Compare Index Reg CPX 8C 3 3 9C 4 2 AC 5 2 BC 5 3 X-M:Mtl • • I I I I Decrement Index Reg DEX 09 I I X-I-X • • • I • • Decrement Stack Pntr DES 34 I I SP-I-'SP • • • • • • Increment Index Reg INX 08 I I Xtl··X • • • I • • Increment Stack Pntr INS 31 I I SPt I--SP • • • • • • M-··XH. Load Index Reg LOX CE 3 3 DE 4 2 EE 5 2 FE 5 3 (Mtl) ··XL • • (ZJ I R • M-,SPH. Load Stack Pntr LOS 8E 3 3 9E 4 2 AE 5 2 BE 5 3 (Mt I) -SPL • • (ZJ I R • Store I ndex Reg STX OF 4 2 EF 5 2 FF 5 3 Xw-M, XL- (Mtl) • • (ZJ I R • SPH -M, Store Stack Pntr STS 9F 4 2 AF 5 2 BF 5 3 SPL -(Mtl) • • (ZJ I R • Index Reg - Stack Pntr TXS 35 I I X-I-SP • • • • • • Stack Pntr-Index Reg TSX 30 I I SPtl-X • • • • • • Add ABX 3A I I BtX-X • • • • • • XL ··Msp, SP I-SP Push Data PSHX 3C 5 I XH -Msp. SP-I-'SP • • • • • • I SPtl-SP,Msp-XH Pull Data PULX 38 4 I SPt I-SP, MSp-XL 0 0 • • • 0 Exchange XGDX 18 2 I ACCD-IX • • • • • • Note: Condition Code Register will be explained in Note of table 3-4. ~HITACHI 405 Table 3-3. Jump and Branch Instructions Condition Code Addressing Modes Register RELATIVE DIRECT INDEX EXTEND IMPLIED 5 4 3 2 1 0 Operations Mnemonic OP - , OP - , -, -, -, OP OP OP Branch Test H I N Z V C Branch Always 'BRA 20 3 2 None • • • • • • Branch Never BRN 21 3 2 None • • • • • • Branch if Carry Clear BCC 24 3 2 C=O • • • • • • Branch if Carry Set BCS 25 3 2 C=l • • • • • • Branch if = Zero BEQ 27 3 2 Z=l • • • • • • Branch if~Zero BGE 2C 3 2 NEfW=O • • • • • • Branch if> Zero BGT 2E 3 2 Z + (NEf'JVl = 0 • • • • • • Branch if Higher BHI 22 3 2 C+Z=O • • • • • • Branch i1~Zero BlE 2F 3 2 Z+(NE!1V)=1 • • • • • • Branch if lower Or Same BlS 23 3 2 C+Z=l • • • • • • Branch if < Zero BlT 20 3 2 NE!1V= 1 • • • • • • Branch if Minus BMI 2B 3 2 N=! • • • • • • Branch if Not Equal Zero BNE 26 3 2 Z=O .. • • . .. .. Branch if Overflow Clear BVC 28 3 2 V=O • • • • • • Branch if Overflow Set BVS 29 3 2 V=I • • • • • • Branch if Plus BPl 2A 3 2 N=O • • • • • • Branch To Subroutine BSR 80 5 2 f---- • • • • • • Jump JMP t-- 6E 3 2 7E 3 3 • • • • • • -1-- Jump To Subroutine JSR 90 5 2 AD 5 2 BD 6 3 • • • • • • No Operation NOP 01 1 1 Adva nces Prog. Cntr. Only • • • .. .. • Return from Interrupt RTI 3B 10 1 ---@I--- Return From Subroutine RTS - - I-- 39 5 1 • • • • • • I - I-- Software Interrupt SWI 3F 12 1 1-- - I-- - • • • • • S Wait for Interrupt' WAI -1- 3E 9 1 --_.- t-- . - --- I-- - - • - • • r-- _.- @ • -• .- r- Sleep SlP lA 4 1 • • • • • • Note: 'WAI puts R/W high; Address Bus goes to FFFF; Data Bus goes to the three state. Condition Code Register will be explained in Note of table 3-4. ~HITACHI 406 Table 3-4. Condition Code Register Manipulation Instructions i : Addressing Modes : : Condition Code Register Operations i Mnemonic J.~;~;~;r:1 Boolean Operation r*iH-H+~ Clear Carry 1 CLC i OC 1 1 I 0 'C .. I • i• I• ~ r:T: : 1 • 1 • ~:_~S~Ma~~___ .___ .-~-+~!- i--~_T'lIT~~' .- ---------=E± : :: ~~Carry _____.. __ J._~_ : OD; 1 iIi 1 ·C i .1. I • I • '. S ~~Pt Ma~~_+s_~ _____ ~ ___ l ~~~_~_~_l_i~~:'- _____________ +;-+2.~+;_~_~_ Set Overflow -----i-c~~V------- __ __l_o~~--.1-LLl.!---~-----~----_t.!J..4IIl!-L4IIL~ Accumulator A-'CCR i TAP I 06 1 : 1 ! A 'CCR i i ------ @---- CCR·Accumulator A I TPA I 07 , i : CCR ·A i • I • I • 1 • I. • Legend Condition Code Symbols OP Operation Code (Hexadecimal) H Half-carry from bit 3 to bit 4 Number of MCU Cycles I Interrupt mask Msp Contents of memory location pointed to by Stack Pointer N Negative (sign bit) # Number of Program Bytes Z Zero (byte) + Arithmetic Plus V Overflow. 2's complement Arithmetic Minus C Carry IBorrow from/to bit 7 • Boolean AND R Reset Always + Boolean Inclusive OR S Set Always EB Boolean Exclusive OR I Set if true after test or clear M Complement of M • Not Affected Transfer into OBit = Zero 00 Byte = Zero Note: Condition Code Register Notes: (Bit set if test is true and cleared otherwise) (i) (Bit V) Test: Result = 10000000? CII (Bit C) Test: Result = OOOOOOOO? ® (Bit C) Test: BCD Character of high-order byte greater than 10? (Not cleared if previously set) ® (Bit V) Test: Operand = 10000000 prior to execution? ® (Bit V) Test: Operand = 01111111 prior to execution? ® (Bit V) Test: Set equal to N + C = 1 after the execution of instructions !J) (Bit N) Test: Result less than zero? (Bit 15= 1) ® (All Bit) Load condition code register from stack. ® (Bit I) Set when interrupt occurs. If previous set, a non-maskable interrupt is required to exist the wait state. ® (AI Bit) Set according to the contents of accumulator A. (jJ) (Bit C) Result of multiplication bit 7= 1? (ACCB) Table 3-5. Memory Map OP ACC ACC IND ~L ACCAorSP ACCB or X CODE A B OIR'i IMM I DIR IND EXT IMM DIR IND I EXT ~ 0000 0001 0010 0011 0100 0101 0110 0111 100011001 1010 1011 1100 1101 111011111 La 0 1 2 3 4 5 6 7 i 8 i 9 A B C D E I F 0000 0 /' SBA BRA TSX NEG SUB 0 0001 1 Nap CBA BRN INS AIM CMP i i 1 0010 2 / / BHI PULA ------- aiM I SBC 2 0011 0100 3 4 / LSRD / / BLS BCC PULB DES ------- COM LSR SUBD : AND ADDD 3 4 0101 5 ASLD V BCS TXS ~: ElM BIT 5 0110 6 TAP TAB BNE PSHA ROR LDA 6 0111 7 TPA TBA BEQ PSHB ASR /1 STA /1 STA 7 1000 8 INX XGDX BVC PULX ASL EaR 8 1001 9 DEX DAA BVS RTS ROL ADC 9 1010 A CLV SLP BPL ABX DEC ORA A lOll B SEV ABA BMI RTI ~ TIM ADD B 1100 C CLC L BGE PSHX INC CPX LOD C 1101 0 SEC / BLT MUL TST BSR i JSR VI STD D 1110 E CLI / ' BGT WAI JMP LOS LOX E Illl F SEI 0 / ' BLE I 2 SWI 3 ------- 4 5 CLR 6 i 7 /1 8 I 9 STS A I B /1 C 1 DiE 1 F STX F IZI UNDEFINED OP CODE • Only AIM, OIM, ElM, TIM instructions ~HITACHI 407 3.4 CPU Instruction Flow When operating, the CPU fetches an instruction from memory and executes the required function. This sequence starts from RES high, and repeats itself continuously if not affected by a special instruction or control signal. SWI, RTI, WAI, and SLP instructions change this operation, and NMI, IR01, IR02, IR03, HALT, and STBY control it. Figure 3-2 shows the CPU mode transitions, and figure 3-3 is the CPU system flowchart. Table 3-6 shows the CPU operating states and port states. Figure 3-2. CPU Operation Mode Transitions ~HITACHI 408 PC-1 PC-1 VECTORING STACK PC, IX ACCA Aces GGR Notes; 1. The program sequence will come to the RES start from any place of the flow during RES. When STBY=O, the sequence will go into the standby mode regardless of the CPU condition. 2. Refer to 3.8 Interrupts for more details of interrupts. ~ J: ~ o :I -l'- o <0 Figure 3-3. System Flowchart -- Table 3-6. CPU Operating States and Port States Port Mode Reset Standby 3 Halt4 Sleep 1 (AO-A7) 1,2 High High impedance High impedance High 3 High impedance High impedance· Keep 2 1,2 High impedance High impedance Keep Keep 3 High impedance High impedance Keep 3 (00-07) 1,2 High impedance High impedance High impedance High impedance 3 High impedance High impedance Keep 4 (Aa-A1S) 1,2 High High impedance High impedance High 3 High impedance High impedance Keep S 1,2 High impedance High impedance High impedance High impedance 3 High impedance High impedance High impedance 6 1,2 High impedance High impedance Keep Keep 3 High impedance High impedance Keep 7 1,2 Note 1 High impedance Note 2 Note 1 3 High impedance High impedance Keep Notes: 1. RO, WR, R1W, LlR =high; BA =low 2. RO, WR, RfW = high impedance; LlR, BA = high 3. E is high impedance in standby state. 4. HALT cannot be accepted in mode 3. 3.5 Low Power Dissipation Modes The MCU has two low power dissipation modes, sleep and standby. Table 3-7 shows the MCU staie in sleep and standby modes. ~HITACHI 410 Table 3-7. Sleep and Standby Modes Sleep Mode Standby Mode Oscillation circuits Continue operation Stop CPU Stop Stop CPU registers Hold Undefined RAM Hold Hold I/O pins Hold High impedance Timers Continue operation Stop SCI Continue operation Stop Internal Registers Hold Reset How to release Interrupt STBY = high before reset start STBY= low (Hold RES low after STBY high until Reset start oscillator stabilizes, 20 ms min) 3.5.1 Sleep Mode The MCU goes into sleep mode when the SLP instruction is executed. In the sleep mode, the CPU stops operation while maintaining the registers' contents. Peripherals such as the timers and the SCI continue their functions. One-fifth as much power is dissipated in sleep mode as in the operating mode. The sleep mode is terminated by an interrupt, or a RES or STBY signal. RES causes the MCU to reset, STBY causes it to go into standby mode. When the CPU receives an interrupt request, it returns to operating mode. If the interrupts are enabled, it branches to the interrupt service routine. If they are masked, it executes the next instruction. However, if timer 1 or 2 prohibits a timer interrupt, the CPU won't cancel the sleep mode because there is no interrupt request to the CPU. The sleep mode reduces power dissipation for a system that doesn't need the CPU's continuous operation. Figure 3-4 is the sleep instruction timinQ chart. Internal f--~------';J-"''''''-~-. EcIOCk.~ Stop In Sleep mode clock Sleep IS cleared with Interrupt masked DATA BUS LJ'T1E2 Sleep Inslructlon ~",,,".".p'.2,.""~e / Address bUSWhe.re --~ sleep ,s cleared without Interrupt Interrupt occurs masked Program Figure 3-4. Sleep Instruction Timing $HITACHI 411 3.5.2 Standby Mode When the STBY input goes low, the MPU stops a" clocks and goes to the reset state. In this mode, power dissipation is greatly reduced. All pins except VCC' VSS' STBY, and XTAL (outputs 0) are detached from the MCU internally, and go to high impedance. In standby mode, power is supplied to the MCU, so that the contents of RAM are retained. The MCU returns from this mode with a reset. An example of the use of this mode follows. First, save the CPU state and SP contents in RAM by an NMI routine. Then disable the RAME bit in the RAM control register and set the STBY PWR bit to go to standby mode. If the STBY PWR bit is still set after reset start, power has been supplied to the MCU and the RAM contents have been retained properly. The system can restore itself by returning the pre-standby information to the SP and registers. Figure 3-5 shows the timing at the NMI, RES and STBY pins. Note: In standby mode, the mode program pins, MPO and MP1, should be held according to the operation mode. If they are opened, the standby current will increase over the specified value. vee NM1 CD N M I Ir----l CD MCU @ RES 111111 I I I ~I II I I I I RES @ CV STSY IIIIII I I I \r-fT I I I I H ~ Save Registers Oscillator RAM/Port 5 Control Start Time Register Set f----- Restart Figure 3-5. Standby Mode Timing $HITACHI 412 3.6 Trap Function The CPU generates an interrupt with the highest priority (TRAP) when it fetches an undefined instruction or an instruction from outside of memory space. The trap function prevents system malfunctions caused by noise or program error. 3.6.1 Opcode Error When the CPU fetches an undefined opcode, it saves the CPU registers as well as performing the normal interrupt procedure and branches to TRAP ($FFEE, $FFEF). This has the highest priority next to reset. 3.6.2 Address Error When an instruction is fetched from outside the intemal ROM, RAM, and external memory area, the MCU generates an address interrupt as well as an opcode error. But on a system with no external memory, a trap is not generated if an instruction is fetched from the external memory area. Table 3-8 shows the I addresses where an address error occurs in each mode. This function is available only for an instruction fetch, and does not apply to data read/write. Table 3-8. Address Error Addresses Mode Address $0000-$001 F 2 $0000-$001 F ·3 $0000-$003F, $0100-$EFFF 3.6.3 Caution The trap function has a retry function other interrupts do not have. The program flow returns to the address where the trap occured when RTI returns the CPU to the main routine from the TRAP routine. The retry can prevent problems caused by noise, etc. However, if another trap occurs, the program can repeat the retryITRAP cycle forever. Consideration is necessary in programming. In figure 3-6, after executing instruction OPn, the MPU fetches and decodes an undefined opcode and generates a trap interrupt. When the RTI is executed in the trap interrupt servicing routine, the MPU will put $FF03 in the PC, fetch the same opcode, and generate the trap again. The MPU will endlessly repeat loop ABC. ~HITACHI 413 , In figure 3-7, after executing the BSR, the branch destination address is output to the address bus to fetch the first instruction of the subroutine. If $0001 is erroneously output as the address, the MPU will decode it and generate a trap interrupt. When the RTI is executed in the trap interrupt servicing routine, the MPU will put $0001 in the PC, and start from this address. This will generate another trap, in an endless loop. $FF01 OPn $FF02 BSR $FF02 Operand $FF03 01 $FF03 Undefinition $FF04 OPn $FF04 OPn+1 c Figure 3-6. Executing an Undefined Opcode Figure 3-7. Erroneous Fetch 3.7 Reset To reset the MCU during operation, hold RES low for at least 3 system-clock cycles. At the third cycle, when the clock signal is low, all the address buses become high. While RES is low, the buses remain high. When RES goes high, the MCU starts the following operations. 1. Latches the value of the mode program pins, MP1 and MPO. 2. Initializes the internal registers (see table 2-3). 3. Sets the interrupt mask bit. For the CPU to recognize the maskable interrrupts IR01, IR02, and IR03, this bit should be cleared in advance. 4. Puts the contents (= start address) of the last two addresses ($FFFE, $FFFF) into the program counter and starts the program from this address. See table 2-4. The MCU cannot accept a reset input until the clock oscillation is stable after power-on (20 ms maximum). This is because the reset signal is internally synchronized to the clock as shown in figure 3-8. Until oscillation starts, the MCU and I/O pins are undefined. External devices that need to know the MPU's state during this period must be informed by external circuits. Refer to 2.4 Ports for the state of the ports rluring reset. Figure 3-9 shows reset timing. RES pin Internal reset signal Inside the LSI Figure 3-8 Reset Circuit ~HITACHI 414 Internal A _~\\\\\\\\\\\\\\\\\\\\ I j~ ~------ ~r---------ij- Internal W _~\\\\~\\\\\\\\\\\~ ~r---------irj---------- RIW _~\\\~\\\\\\\\\\W AD _!\\~\\\\\\\\\\\\\\\\W H~~~j \VA _*\\\\\\\\\\~\\\W jjv \O:}->~i Data Bus .~\\\\'\\\\\\\\\\\\\\\'\\\\\\~)---------y--Q-;~r---------ijj------ PCB peo First pelS PCl Instruction 3.8 Interrupts Figure 3-9 Reset Timing The CPU will complete the current instruction before accepting the request. If the interrupt mask bit in I the condition code register is set, the request will be ignored. When the interrupt sequence starts, the contents of the program counter, index register, accumulators, and condition code register will be saved onto the stack. Then the CPU sets the interrupt mask bit and will not respond to further mask able interrupt requests. In the last cycle of the interrupt, the CPU fetches the vectors shown in table 3-9, transfers their contents to the program counter and branches to the interrupt service routine. The external interrupt pins IR01 and IR02 are also used as P50 and P51. The function is chosen by the enable bits in the RAM/port 5 control register (bits 0 and 1) at $0014. See 2.5 RAM/Port 5 Control Register for details. When one of the internal interrupts, ICI, OCI, TOI, CMI, or SIO is generated, the CPU produces the internal interrupt signal, IR03. IR03 functions just the same as IR01 or IR02, except for its vector address. Table 3-9 is an interrupt vector map, figure 3-10 is the interrupt sequence, and figure 3-11 is the interrupt circuit block diagram. ~HITACHD 415 Table 3-9. Interrupt Vector Memory Map )l~~!;U !.a"ilIiao Priority MSB LSB Interrupt Highest FFFE FFFF RES FFEE FFEF TRAP FFFC FFFD NMI FFFA FFFB SWI (Software interrupt) FFF8 FFF9 IRQ1 FFF6 FFF7 ICI (Timer 1 input capture) FFF4 FFF5 OCI (Timer 1 output compare 1, 2) FFF2 FFF3 TOI (Timer 1 overflow) FFEC FFED CMI (Timer 2 counter match) FFEA FFEB IRQ2 Lowest FFFO FFF1 SIO (RDRF + ORFE + TORE) Interrupt Test E SP-1 SP-2 SP-3 SP-4 sp-5 SP-6 Vector Vector New MSB LSB PC Address Addrss Address Internal Read \~ ______________________________--JI Internal __________........1 \ Write Figure 3-10. Interrupt Sequence ~HITACHI 416 Each Status Register's Interrupt Enable Flag 1 ; Enable, 0; Disable IRQ, Condition Code IRQ, ---- Register I-MASK ICF ..-. ICI o ;Enable 1 ;Disable OCF1 ~o- OCF2 ---0- ~ ...0--0 Interrupt IRQ 3 TOF ---. TOI ~ Request Signal CMI CMF RDRF ---- ---0- ORFE TORE -cr-- ~ .-- Sleep Edge ) Cancel Detective Signal Circuit I j;ddreSS Error TRAP Op Code Error Detective Circuit SWI Figure 3-11, Interrupt Circuit Block Diagram The SEI instruction sets the interrupt mask bit, inhibiting interrupts. The CLI instruction clears the interrupt mask bit, allowing interrupts. The TAP instruction can set and clear the interrupt mask bit also. There must be at least two cycles between clearing the interrupt mask bit and setting it again, or an interrupt which occurs between setting and clearing the bit cannot be accepted (figure 3-12). CLi CLI CLI NOP SEI NOP NOP SEI SEI No No Yes Figure 3-12. CLI and SEI Timing ~HITACHI 417 Section 4. Timer 1 The 16-bit programmable timer, timer 1, can measure an input waveform and independently generate two independent waveforms. The pulse widths of the input and output waveforms can vary from microseconds to seconds. Timer 1 has the following components (figure 4-1). ControVstatus register 1 (8 bits) • ControVstatus register 2 (7 bits) Free-running counter (16 bits) • Output compare register 1 (16 bits) • Output compare register 2 (16 bits) Input capture register (16 bits) ~ Internal Data Bus ::[J:$19.$lA ::[ } : $OB. $OC ~J:$09.$OA II$OD. $OE Output Compare Output Compare Free Running Input Capture I Register 2 I Register 1 16 Bit Counter I Register I I I I - transmit shift register When writing to TDR after TRCSR read, (asynchronous) with TDRE = 1, TDRE is cleared. 2. Transmit shift register is empty. (clock·synchronous) 3. RES = 0) If transmit data is written to TDR, and then TE bit is cleared with TDRE = 0 to stop I transmitting, TDRE remains "0". In this case, even if TE bit is set and transmit data is written again, the TDR data is not transmitted. Please note that TE bit must be cleared after the last data has been transmitted. (This caution is not applied to asynchronous serial communication interface.)- ~HITACHI 439 ~HITACHI 440 Section 7. HD63701 XO Programmable ROM (EPROM) The HD63701XO's on-chip EPROM is programmed in the chip's PROM mode. When MPO, MP1, and STBY are low (table 2-2), the HD63701XO doesn't operate as an MCU. It can be programmed by the same procedure as a standard 2732A EPROM. In the PROM mode, P30-P37 are the data bus, P10-P17 and P40-P43 are the address bus, and P57 is the CE input. See figures 7-1 and 7-2, table 7-1. Port 3 a Data Bus I Port 1 a Address aus Port 4 4 Address Bus Figure 7-1. PROM Mode Table 7-1. Pin Conditions in PROM Mode Pin Name Pin No. Programming Verification PROM Inhibit VCC 33 +5V +5V +5V VSS GND GND GND Vpp/OE 42 Vpp Low Don't care CE 24 Low Low High P30-P37 51-58 Data input Data output High impedance P10-P17 43-50 Address input Address input Don't care P40-P43 38-41 MPO, MP1, 4,5,7 Low Low Low STBY Other pins GND GND GND ~HITACHI 441 Vss G EOo E01 E02 E03 E04 E05 EOs E07 15 50 EAo 1SHD63701 XOC49 EA1 (DC-64S) EA2 EA3 EA4 EA5 EAs EA7 Vpp/OE EAs EA9 EAlO EA" 31 """1i...32_____......:~VCC G: Ground (V 55 level) Figure 7-2. PROM Mode Pin Arrangement ~HITACHI 442 Table 7-2 shows the recommended combinations of PROM programmers and socket adapters for programming the HD63701 XO. The socket adapter converts the pin assignment of the necessary 24 pins to the same assignment as the standard EPROM. Table 7-2. PROM Programmers and Socket Adapters Programmer Socket Adapter Data 1/0 121N121.B,22A1228, DataVO HD63701XO (for 29A1298) 29A1298 Hitachi H67PWA01A 7.1 Programming and Verification When the CE pin is held low after the programming voltage (Vpp) is applied, data can be programmed in PROM one byte at a time through port 3. To verify the data, hold the Vpp/OE and CE pins low after programming, and the programmed data will be output from port 3. When CE is returned high, port 3 will be high impedance, and PROM programming/verification will be inhibited. Programming precautions: The PROM memory cells should be programmed under specific voltage and timing conditions. The higher the program voltage and the longer the program pulse is applied, the more electrons will be injected into the floating gate. However, if an overvoltage is applied to Vpp, the p-n junction may be permanently damaged. Pay particular attention to PROM programmer overshot. Negative voltage noise will cause a parasitic transistor effect, which may reduce breakdown voltage. The HD63701 XO is connected electrically to the PROM programmer through a socket adapter. Therefore, pay attention to the following: 1. Confirm that the socket adapter is firmly fixed on the PROM programmer. 2. Do not touch the socket adapter or the LSI during programming. Mis-programming can be caused by poor contacts. ~HITACHI 443 7.2 Erasing (Window Package) The EPROM is erased by exposing the LSI to ultraviolet light. All erased bits are in 1's. The conditions for erasing are: ultraviolet light with wavelength of 2537 A, and a minimum irradiation of 15 W . sfcm 2 . These conditions are satisfied by exposing the LSI to an ultraviolet light rated at 12,000 IlW/cm2 for 15-20 minutes, at a distance of 1 inch. 7.3 Characteristics and Applications 7.3.1 Principles of Programming/Erasing The HD63701 XO's memory cells are the same as an EPROM's. Therefore they are programmed by applying high voltage to control gates and drains, which injects hot electrons into the floating gate (figure 7-3) .The condensed electrons in the floating gate are stable, surrounded by an energy barrier of Si02 film. Such a cell becomes a 0 bit due to the memory threshold voltage change. A cell with no condensed electrons at its floating gate appears as a 1 bit. • . / Control gate ---r Si02~~1_____ ...J./ Floating gate Source \ §E5i988ff ~ / Orain ( , J . [,' \ The programmed cell (0) The erased cell (1) Figure 7-3. Cross-Section of EPROM Memory Cell The electron charge in memory cells may decrease as time goes by. This can be caused by: 1. Ultraviolet light, discharged by photo-emitting electrons (erasure principle) 2. Heat, discharged by thermal emitting electrons 3. High voltage, discharged by a high electric field at the control gate or drain If the oxide film covering a floating gate is defective, the erasure rate is great. Normally, electron erasure does not occur, because such defective devices are found and removed during testing. ~HITACHI 444 7.3.2 Window-Type Package Precautions Glass Erasure Window: If the glass window comes in contact with plastic or anything with a static charge, the LSI may malfunction due to the electrostatic charge on the surface of the window. If this occurs, exposing the LSI to ultraviolet light for a few minutes neutralizes the charge, and restores the LSI to normal operation. However, charge stored in the floating gate decreases at the same time, so reprogramming is recommended. Electrostatic charge buildup on the window is a fundamental cause of malfunctions. Measures for its prevention are the same as those for preventing electrostatic breakdown: 1. Operators should be grounded when handling equipment. 2. Do not rub the glass window with plastics. 3. Be careful of coolant sprays, which may contain a few ions. 4. The ultraviolet shading label (which includes conductive material) effectively neutralizes charge. I ~HITACHI 445 Ultraviolet Shading Label: If the LSI is exposed to fluorescent light or sunlight, its memory contents may be erased by the small quantity of ultraviolet light in these sources. In strong light, the MCU may fail under the influence of photocurrent. To prevent these problems, it is recommended that the device be used with an ultraviolet shading label covering the erasure window after programming. Special labels are sold for this purpose. They contain metal to absorb ultraviolet light. When choosing a label, note the following: 1. Adhesion (mechanical intensity)-Re-use and dust reduce adhesion. Peeling off a label may cause slatic electricity. Therefore, erasing and rewriting is recommended after peeling. Sticking a new label over the old one is better than replacing a label. 2. Allowable temperature range-The allowable environmental temperature range of the label should be noted. If it is used under conditions outside this range, the paste may stiffen or adhere to the label, causing paste to remain on the window when the label is removed. 3. Moisture resistance-The allowable moisture range and environmental conditions of the label should be noted. It is difficult to find a shade label applicable to all conditions. The proper label should be selected depending on the intended use of the MCU. ~HITACHI 446 Section 8. Applications 8.1 HD6301XO or HD63701XO in Expanded Mode Figure 8-1 shows a microcomputer system using all CMOS peripheral LSI's as an application example of the HD6301XO or HD63701XO in the expanded mode (modes 1,2). Ports 1 and 4 are used for address output, and port 3 is used for data 1/0. The system is controlled by directly connecting RD and WR as memory control signals and RIW and E as peripheral controls. Address decoder A 03 -----v;; r-"'-- A ~B ~cy,- Y ' L ~OSPIA CMOS ACIA Y3- 7'4HC13S CS, HD6321 ~}IIO L . CS, i- i- HD6350 r- Serial MCU E E i- interface R/W r-- I R/W ~ Ao Do-D7 r?- Ao Do-D, r- iA RS,RS o ....:..". RS r- E ~ . RIW I-- h 16 Ao-A'5 Address bus S 0 0 -0 7 Data bus RD WR CS, , CE A,s OE r- CS OE WE OE 13 13 4- Ao-A'2 4- Ao-A'2 ~ Ao-A'4 S --+- 1/0,-1/0, HM6264 -+- 0 0 -0 7 HN27C64 S '-----+- Do-D, HN613256 Sk byte of S-RAM Sk byte of EPROM 32k byte of Mask ROM Figure 8-1. All CMOS Microcomputer System ~HITACHI 447 8.2 HD6301XO or HD63701XO in Single-Chip Mode Figure 8-2 shows a printer controller using the HD6301XO or HD63701XO in the single-chip mode (mode 3). The HD6301XO or HD63701XO controls a 16-dot printer using 1/0 lines as its ports. Data from the host is transferred to the MCU through the serial interface or through a Centronics interface at port 3. Port 1 8 ~ , Centronics I ~! Latch Port 3 interface Head driver V Port 4 8 STRDB Tout1 (Timer) t MCU Serial interface 2 Host Rx Port 7 CR Motor driver computer system Tx I Tout2 I LF Motor driver (Timer) Panel II. switch Port 6 2 display v Port 5 Position detector .. Figure 8-2. Printer Controller 8.3 Timer Applications 8.3.1 Timer 1 Timer 1 is a 16-bit programmable timer with the same architecture as the timer on the HD6301V1, but with an output compare register added. Timer 1 can perform the following four operations: 1. Waveform generation or interval timing using output compare register 1 (OCR1) 2. Waveform generation or interval timing using output compare register 2 (OCR2) 3. Pulse width or pulse cycle measurement using the input capture register 4. Interval timing with overflow interrupt ~HITACHI 448 Wavefonn Generation. The values of the output compare registers (OCR1, OCR2) are compared with the free-running counter (FRC) at every E cycle. When a match occurs, an output compare flag (OCF1, OCF2) is set. When an output enable bit (OE1 E, OE2E) is set, the value of the output level bit (OLVL1, OLVL2) is output at port 2 (Tout1: P21, Tout2: P25). Figure 9-3 is a flowchart for OCR1 waveform generation. Set P2 , to timer output pin ----------Set timer output. 1 toOLVLl '-----'---',-_---J ----------Set O-interval-time B to OCRI '--_--,,-_---J ---------Clear OCFl and add l-interval-time A to OCRI '--_--,;-_---' - - - - - - - - - Clear OCFl and add O-Interval-time B to OCRI I Output Waveform (P2,). I I A-jL~ " Start i I /.. B -/- A -/- B +. Figure 8-3. OCR1 Waveform Generation Pulse Width Measurement. The input capture register (lCR) latches the free-running counter value at the transition of the external input signal, measuring the pulse width or cycle. Figure 8-4 is a flowchart of pulse width measurement. ~HITACHI 449 - - - - - - - - - Detect input rising edge '-----r---..J - - - - - - - - - Store the ICR to M,_and clear ICF '-----r---..J - - - - - - - - Detect Input falling edge - - - - - - - - - Store the ICR to M, and clear ICF ' - -_ _' - -_ _..J --- - - - - - - Pulse width A= (M,J- (M,) __ In_p_ut_w_a_v_ef_or_m~f 1~_______ ~A--1 Figure 8-4. ICR Pulse Width Measurement 8.3.2 Timer 2 The 8-bit reloadable timer provides such functions as an external event counter, interval timer, waveform generator, and SCI baud rate generator. External Event Counter_ Operate timer 2 as an external event counter by setting input clock select, CKSO and CKS1 , to external clock and writing 1 into T2E. The timer 2 upcounter is incremented by the external clock's rising edge. Figure 9-5 shows the routine that generates an interrupt after N extemal events occur (where N is an integer between 1 and 256). ~HITACHI 450 Interrupt routine External clock input - - - - Write 0 into CMF. Interrupt enable - - - - . Set TCONR - - - - Timer 2 enable Input signal T2CNT CMF--------------------~H~--------~ L- Generates CMI • Sets N-1 in the TCONR when the external event counter value which generates the interrupt is N. Figure 8-5. External Event Counter Square-Wave Generator. Timer 2 can generate a continuous square wave without software supervision. Figure 8-6 shows this routine. ----- Select input clock ' -_ _- ,_ _ _--' ----- Set toggle output ----- • Set TCONR '-----r--~ • Set N-1 in the TCONR, when the half cycle of square waveform is N. - - --- Timer 2 enable '-------~ Figure 8-6. Square-Wave Generator ~HITACHI 451 8.4 SCI Applications 8.4.1 Timer 2 Baud Rate Generator The SCI can use six kinds of clock source: timer 1's FRC (four kinds), timer 2, and an external clock. The timer 1 baud rate clocks are not adjustable, but timer 2 can provide any baud rate. Figure 8-7 shows how time 2 can provide the baud rate. CKSI and CKS2 select E or E/a according to the baud rate. Set CKSI,CKSO Value of n to TCONR is TCONR=N f T2E=1 n f: input clock frequency 32 x baud rate n: 0 to 255 SS2=1 Set CC2, CCI, _______ Select timer 2 as a clock source. CCO Select transfer format. _______ To initialize the SCI, set TE and RE after more than I bit cycle at the required baud rate. Figure 8-7. Timer 2 as Baud Rate Generator 8.4.2 Interface between HD6301 XO/HD63701 XO and HD6305XO An HD6301XO/HD63701XO can interface to an HD6305XO in the clock synchronous mode. This gives 99 110 lines, suitable for systems requiring many 110 lines. Figure 9-8 shows an example of this interface. Tx Rx Rx Tx SCLK CK l" P60 C, P6, C, '-' Hand Shake Line HD630IXO/ HD6305XO HD6370lXO Figure 8-8. HD6301XO/HD63701XO to HD6305XO Interface Employing the clock synchronous mode enables the HD6301 XO/HD63701 XO to interface easily to peripheral devices (AID converter, real-time clock, etc) whic:h use a clock synchronous interface, as well as to the HD6305XO. ~HITACHI 452 8.4.3 110 Expansion The SCI can be used in the clock synchronous mode to supplement the available parallel 110 ports. Use an external shift register to perform the serial-to-parallel conversion. Figure 8-9 shows this kind of I/O expansion. 'MSB . Output Data LSB' Vee PORT GND MCU P2, 74LS164 B CK P2, Output Ports Input Data I 'LSB MSB' MCU PORT 74LS165 CLKINH P2 3 QH CK GND P2, Input Ports Figure 8.9 I/O Expansion in Clock Synchronous Mode 8.4.4 SCI Multiplexer Use an analog multiplexer as shown in figure 8-10 to use the SCI with both an asynchronous and a clock synchronous device, such as an HD6305XO and an RS-232C. ~HITACHI 453 HD14503 Analog MPXer MCU HD6305XO ClK Xo X P2, Rx etc. Yo Tx Zo Y P2, X, Rx Y, Z P2 4 Tx Z, Inhi.r1 ABC I 11 PORT PIN ~ RS-232C etc. J Figure 8-10. Multiplexed SCI 8.5 Lowering Operating Current 8.5.1 Lowering Operating Frequency The HD6301 XO/HD6303X1HD63701 XO operating current is approximately proportional to the operating frequency (figure 8-11). Therefore, if the system does not require a high-speed MCU, power can be reduced by lowering the operating frequency. 14 C( .s 10.5 -Y c: " 0 li E 7 ::. CI) c: 0 " 1: ~::. () 0.7 0.1 1.0 1.5 2.0 Operating Frequency (MHz) Figure 8-11. Operating Frequency and Current (Typical) ~HITACHI 454 8.5.2 Sleep Mode The SLP instruction puts the MCU into the sleep roode. In the sleep mode, current consumption is reduced to one-fourth to one-fifth of that in the operating state.When the CPU acknowledges an interrupt request, it cancels the sleep mode. The average power consumption can be reduced by putting the CPU in sleep mode whenever it doesn't actually execute any instructions, such as in interrupt wait state or polling. Figure 8-12 shows a routine which wakes the CPU up every 65 ms, using the overflow interrupt of the timer 1 FRC. _______ Set the Timer 1 as the 65-ms interval timer using FRC overflow interrupt. L -_ _- , -_ _...J- - - - - -- Interrupt wait state. When the main routine processing time is 1 ms. I average operating current Icc is 1.58mA (1= 1MHz). I - 1.5x65+7xl cc - 66 = 1 .58 [mAl (1= 1 MHz) Figure 8-12. Low Power Consumption Using the Sleep Mode 8.5.3 Standby Mode Bringing STBY (pin 7) low puts the MCU·into standby mode. In standby mode, the oscillator stops and the MCU goes into the reset state. The contents of RAM are maintained as long as VCC is greater than or equal to 2 V. In standby mode, current consumption is reduced to a few 1lA. RAM can be maintained by battery. Bringing STBY high cancels standby mode. The MCU releases the reset state and starts oscillation. RES (pin 6) should be held low for at least the oscillation stabilization time (tRC) after S"i'BY high. Figure 8-13 gives an example of a circuit that sets standby from software. Figure 8-14 shows the timing for this circuit, and figure 8-15 is an operating flowchart. ~HITACHI 455 MCU .---------~~~~ST8'V Rr .-+---tRES cr~ Standby mode cancel L------~--~PORT Rr· Cr > 20ms (External input) Figure 8-13. Standby Circuit Example PORT ----·r~--------~rrl----------------- Standby mode cancel ------------1,,)--------.U r---- (External input) SrBY fS I I L---------ff~ ....... I I Oscillation stability • PORT goes to the high-impedance state with STBY low, so it is pulled high by the pull-up resistor. Figure 8-14. Standby Timing Standby mode (20ms) Figure 8-15. Standby Circuit Flowchart ~HITACHI 456 8.6 Memory Ready Application The memory ready function allows the MCU to access low-speed memories or low-speed devices. Figure 8-16 shows a circuit example, and figure 8-17 is its timing chart. L MP , MP o AD CE * ~ .A 0 0 -0'1\ V Data Bus 0 0 -0, 4~(4MHz) EXTAL " / Ao-A14 A Address Bus -'\ Ao-A" ~ -V LA" CS 4-Bit binary MCU counter HD74LS161 Low-speed mask ROM ~~'~CKJ HN61256 A15 Clear ..J.. MR .... I --yo ® ..... E The HN61256 is located In $4000 to $BFFF. Figure 8-16. Low-Speed Memory Access Circuit E ~ x==: C~---JX'---C r · ADB J(I......_----JX'__ _ CS I ®--------rl-~ ~------- MR I If I Data Figure 8-17. Memory Ready Bus Timing ~HITACi-il 457 8.7 Halt Application The halt function enables the MCU in the expanded mode to interface with a DMAC (HD6844) and execute DMA (figure 8-18). r--- r- 1 ---. ~ . Ao-A" Ao-A" ~ A r H .. r MCU 0 0 -0, E ... r---v I--- ... I" 0 0 -0, R/W I--- IRQ I-- r- Memory Unit RES BA HALT U) ::> to U) U) ::> U) to DGRNT DRQH ~ 1/0 Device Controller A ..... "0"0 ~ Ao-A" « 0 l I" H L ..... 0 0 -0, 0 0 -0, ... r---v .. I" RES HD6844 ci>2DMA f--- E RiW CSlTxAKB a i'l I--- I--- ' - - - IRQ R/W RES TxSTB TxRQ o H I--- I--- TxAK TxRQ ~~~~ es Figure 8-18. One-Channel DMAC Interface Example ~HITACHI 458 8.8 RD, WR Application RD and WR, as well as E and RlW, can act as external interface signals. RD and WR allow the MCU to easily interface with the 80xx family peripherals as well as with the 6800 series. Figure 8-19 shows an example of an interface between the MCU and an 8255. 8255 RDr-------------------~ RD WRr--------------------i WR MCU 0 0 -0, Aor--------------------i Ao A,r-------------------~ A, A,-A15 r-______---. ~ I Address Decoder RES RES -----~------------_f :>o----------~ Figure 8-19. HD6301XO/HD63701XO and 8255 Interface ~HITACHI 459 8.9 LCD-II Interface Application Figure 8-20 and 8-21 show examples of interfaces between an HD6301XO/HD63701XO and a liquid crystal driver (LCD-II). The interface lines are TTL compatible. The HD6301XO/HD63701XO in the expanded mode in figure 8-20 interfaces with the LCD-II directly through the external bus lines. Port 3 connects to the LCD-II data bus, RJW connects to RIW, AO connects to RS, and the rest of the address bus is decoded and ANDed with E to connect with E on the LCD-II. The HD6301XO/HD63701XO in the single-chip mode in figure 8-21 interfaces with the LCD-II through the I/O port. The read/write operation should be performed with care for the timing of the LCD-II E signal and others. E E A,s-A, COM,-COM,. RS LCD-II (HD44780) Connecting MCl) Ao to the liquid R/W R/W crystal display SEG,-SEG. o Port 3 DBo-DB, Figure 8-20. LCD-II Interface, Expanded Mode P3. E COM,-COM,. P3 s RS Connecting MCU LCD-II (HD44780) to the liquid P3. R/W crystal display SEG,-SEG. o Port 1 DBo-DB, Figure 8-21. LCD-II Interface, Single-Chip Mode ~HITACHI 460 8.10 Oscillation Circuit Board Design Keep the following rules in mind whefl designing the circuit to connect the crystal resonator with the XTAL and EXTAL pins (figures 8-22, 8-23). 1. The crystal and load capacitors should be as close to the LSI as possible. External noise at the XTAL and EXTAL pins will disturb normal oscillation. 2. Keep the lines from XTAL and E as far apart as possible. Avoid parallel wiring. Interference from E to XTAL will disturb normal oscillation. 3. Do not allow Signal or power lines to cross or run closely parallel to the oscillator lines (signals A, S, C in figure 8-22). They will disturb normal oscillation. Keep the resistance between XTAL and EXTAL pins and the next nearest pins greater than 10 MQ. Avoid these lines /~ The figures in this characteristics represent those when teyc is minimum (=10 the highest speed operation). ~HITACHI 464 Peripheral Port Timing HD6301XO HD63A01XO HD63B01XO Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit ~:~~itlon Peripheral data (Ports 2, 3 tpDSU 200 200 200 ns Fig. 1·5 set-up time 5,6) Peripheral data (Ports 2, 3 tpDH 200 200 200 ns hold time 5,6) Delay time (From (Ports I, 2, 3 enable fall edge to tpWD 300 300 300 ns Fig." 1·6 4,6, 7) peripheral output) Timer, SCI Timing HD630lXO HD63A01XO HD63B01XO Symb Test Item Min Typ Max Min Typ Max Min Typ Max Unit 01 Condition Timer 1 input pulse width tPWT 2.0 2.0 2.0 tcyc Fig. 1·9 Delay time (enable positive Figs. 1·7, tTOD 400 400 400 ns transition to timer output) 1·8 (Async. mode) tScyc 1.0 1.0 1.0 teyc Fig. 1·9 SCI input clock cycle (Clock syno) 2.0 2.0 2.0 Fig. 1·4 teyc SCI transmit data delay tTXD 200 200 200 ns Fig. 1·4 time (Clock sync. mode) SCI receive data set-up tSRX 290 290 290 ns time (Clock sync. mode) I SCI receive data hold time tHRX 100 100 100 ns (Clock sync. mode) SCI input clock pulse width tpWSCK 0.4 0.6 0.4 0.6 0.4 0.6 tScyc Fig. 1·9 Timer 2 input clock cycle ttcyc 2.0 2.0 2.0 tcyc Timer 2 input clock pulse width tPWTCK 200 200 200 ns Timer 1 • 2, SC I input clock tCKr 100 100 100 ns rise time Timer 1 • 2, SCI input clock tCKf 100 100 100 ns fall time ~HITACHI 465 tcyc ~ 2.4V V \ E \ OBV 1\ . PW;L } vi PW;H \ ~ tAH __ !--tAD_ tEo tE' )< 2.4V ~O.BV K I--- tHRW tRWO PWRw '\ O.BV V 2.4V ~tDDW_ I--tHW - 2.4V ~ MCU IMite 00-0, O.BV 4-tDSR_ I---- tHR MCU Read 2.0V 00-07 O.BV E !--tDLR __ I---- tHLR ,V '" O.BV Figure 1-1. Mode 1, Mode 2 Bus Timing ~HITACHI 466 1 - - - - - - PW'MR --------<»1 24V \ \ \ \L ___ _ O.BV ~+-+ __ tHMR tSMR MR Figure 1-2. Memory Ready and E Clock Timing Last Instruction Instruction Execution HALT Cycle Cycle lBA SA O.BV Figure 1-3. HALT and SA Timing 2.0VI2.4V)· Synchronous Clock i<>----t-+-tscyc 2.4V Transmit Data O.BV Receive Data -<~____ ~~t~~~X__tH_"1-<~___ -2.0V is high level when clock input. 2.4V is high level when clock output. Figure 1-4. SCI Clocked Synchronous Timing <@)HOTACHD 467 rMCUWrite E P1o-Ph, P2o-P2, ------,..6:-:;~;--­ P30-P3, (Inputs) P30-P3" P4o-P4, P6o-P6" P7o-P74 _ _ _ _ _J 1"---- (Outputs) Figure 1-5. Port Data Set-up and Hold Figure 1-6. Port Data Delay Times Times (MCU Read) (MCU Write) E~ Output ~ Timer 1 FAC _ _ _..JXy~';'.!h"': X...___ T2CNT tTO,D P2" P2s------!.-;..,V-k2...."'4V".--- r-= P2 6 Outputs _ _ _ _ _ _ _..J,l'l'L:;.:.·""SV'--_ _ Output Figure 1-7. Timer 1 Output Timing Figure 1-8. Timer 2 Output Timing :~ 1 ?- •* teK' •• { Test Point m C R Vee AL =2.2kQ 1S207<\® or equiv. C=90pF for Port 1, Port3, Port 4, E 'Timer 2; ttcyc "Timer 1; tPWT SCI ; tScye TImer 2; tPWTCK =30pF for Port 2, Port 6, Port 7 SCI ; tPWSCK A=12kQ for Port 1-Port4, Port 6, Port 7, E Figure 1-9. Timer 1'2, SCI Input Clock Figure 1-10. Bus Timing Test Loads Timing (TTL Load) ~HITACHI 468 Internal Bus Address :=)(j:JC=X:=)(=:JC=X=J==X::=X=)(==)C=:X:=~;:::J<;;:=X:=)(: SP SP- 1 SP-2 SP-3 SP-4 SP-5 SP-6 ~sll'r ~'i:0r ~~w AddressAddressAddress Internal OamBus----~--~--~'---~--~--~'---~--~~~~--~--~--~'---~--~--~~--A- . Op OperandlrrelsvsntPCQ- PCB- IXO- IXB - ACCA ACeS CCR Vector Vector First Inst. of CodeOp CodeO.t. PC7 PC1S IX7 IX1S MSB LSB Interrupt Routine Internal Read \~-------------------------------'----------------- Internal ------'/ \'-------- \Mite Figure 1-11. Interrupt Sequence _ _ s.sv VcC~'6V tRC-----<~ VcJ-o.sv -------ff-------1f-+-------------------i Sffi Vcc-O.5V m ~S-S-------11------' :~:r.ss _"-=~:::X::=x;;;f..::x:::x;::::x.~~ FFFF FFFF FFFF FFFF FFFF FFFE FFFF New PC II FFFF I FFFF FFFF I R/W._"" ... I!ll • • \~_ WR • •_ _ Data Bus ~" ~~ ~~~---- ,-------------~~~. pe1S PC7 Instruction Figure 1-12. Reset Timing ~HITACHI 469 1.2 HD6303X, HD63A03X, HD63B03X Electrical Characteristics Absolute Maximum Ratings Item Symbol Value Unit Supply voltage Vee -0.3 to +7.0 V Input voltage Vin -0.3·to Vee+0.3 V Operating temperature Topr o to +70 "C Storage temperature Tstg -55 to +150 'C Note: This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend VI~' VOU\: Vss;:;;' (V In or Vout) ~Vcc' Electrical Characteristics DC Characteristics (Vee=5.0 V ± 10%, 1=0.1 to 2.0 MHz, Vss=O V, Ta=O to + 70"C, unless otherwise noted.) Item Symbol Min Typ Max Unit Test Condition Input high voltage RES, STBY VIH Vee-O.S Vee+0.3 V EXTAL VeeXO.7 Vee+0.3 V Other inputs 2.0 Vee+0.3 V Input low voltage All other inputs VIL -0.3 0.8 V Input leakage current RES, PortS Il;nl 1.0 p.A Vin=O.S to Vee-O.S V NMI, STBY, MPo, MP! Three state Ao-A15,Do-D7,RD Ilrsti 1.0 p.A Vin=O.S to Vee-O.S V leakage current WR,R/W',Ports 2,6 Output high voltage VOH 2.4 V IOH--200p.A Vee-0.7 V IOH=-10p.A Output low voltage VOL 0.4 V IOL=1.6 mA Darlington drive Ports 2, 6 -IOH 1.0 10.0 mA Vout=I.S V current Input capacitance All other inputs Cin 12.S pF Vin=OV, 1=1 MHz Ta=2S'C Standby current Not operating ISTB 3.0 15.0 p.A Current dissipation! ISLP 1.5 3.0 mA Sleeping (1-1 MHz2) 2.3 4.5 mA Sleeping (1=1.5 MHz2) 3.0 6.0 mA Sleeping (1-2 MHz2) lee 7.0 10.0 mA Operating (1=1 MHz2) 10.5 15.0 mA Operating (1=1.5 MHz2) 14.0 20.0 mA Operating (1-2 MHz2) RAM standby voltage VRAM 2.0 V Notes: I. VIII min=Vcc-l.OV, VEL max=O.8V (AU output terminals are at no load.) 2. Current dissipation of the operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about current dissipations at x MHz operation are decided according to the following formula: tyPo value (f=x MHz) =typ. value (f=1 MHz) Xx max. value (f=x MHz) =max. value (f=1 MHz) Xx (both the sleeping and operating) ~HITACHI 470 AC Characteristics (Vcc=5.0 v ±10 %,1=0.1 to 2.0 MHz, Vss=O v, Ta=O to +70 'C, unless otherwise noted.) Bus Timing HD6303X HD63A03X HD63B03X Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Unll Condilion Cycle time tcyc 10 0.666 10 0.5 10 ~s Fig. 1·13 Enable rise time lEt 25 25 25 ns Enable fall time IEf 25 25 25 ns Enable pulse width high level l PWEH 450 300 220 ns Enable pulse width low level l PWEL 450 300 220 ns Address, R/W delay time l lAD 250 190 160 ns Data delay time (Write) loow 200 160 120 ns Data set· up time (Read) toSR 70 70 70 ns Address, R/W hold lime l tAH 80 50 35 ns Data hold time (Wrile)I tHW 80 50 40 ns (Read) IHR 0 0 ns RD. WR pulse widlh l PWRW 450 300 220 ns RD, WR delay time tRWo 40 40 40 ns I RD, WR hold time tHRW 30 30 25 ns LlR delay lime tOLR 200 160 120 ns LlR hold lime tHLR 10 10 10 ns MR set-up timel tSMR 400 280 230 ns Fig. 1·14 MR hold lime l tHMR 90 40 0 ns E clock pulse width al MR PWEMR 9 9 9 ~s Fig~ 1-15,. Processor control set-up time tpcs 200 200 200 ns 1·23,1·24 Fig~ 1·14, Processor control rise time tPCr 100 100 100 ns 1·15 Processor control fall time tpCf 100 100 100 ns SA delay time teA 250 190 160 ns Fig.I·15 Oscillator stabilization time tRC 20 20 20 ms Fig. 1·24 Reset pulse width PWRST 3 tcyc Note: 1. These timings change in approximate proportion to tcyc. The figures in this characteristics represent those when tcyc is minimum (;;::;in the highest speed operation). ~HITACHI 471 Peripheral Port Timing HD6303X HD63A03X flD63B03X Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit ~:~!ition Peripheral data (Ports 2, 5, tpDSU 200 200 200 ns Fi9. 1-17 set-up time 6) Peripheral data (Ports 2, 5 tpDH 200 200 200 ns hold time 6) Delay time (From enable fall edge to (Ports 2, 6) tPWD 300 300 300 ns Fig. 1·18 peripheral output) Timer, SCI Timing HD6303X HD63A03X HD63B03X 5ymb Test Item Min Typ Max Min Typ Max Min Typ Max Unit 01 Condition Timer 1 input pulse width tPWT 2.0 2.0 2.0 tcyc Fig. 1·21 Delay time (enable positive Figs. 1·19, tTOD 400 400 400 ns transition to timer output) 1·20 (Async mode) tScyc 1.0 1.0 1.0 tcyc Fig. 1·21 SCI input clock cycle (Clock sync.) 2.0 2.0 2.0 Fig. 1·16 tcyc SCI transmit data delay tTXD 200 200 200 ns Fig. 1·16 time (Clock sync. mode) SCI receive data set-up tSRX 290 290 290 ns time (Clock sync. mode) SCI receive data hold time tHRX 100 100 100 ns (Clock sync. mode) SCI input clock pulse width tPWSCK 0.4 0.6 0.4 0.6 0.4 0.6 tS cyc Fig. 1·21 Timer 2 input clock cycle ttcyc 2.0 2.0 2.0 tcyc Timer 2 input clock pulse width tPWTCK 200 200 200 ns Timer 1 • 2, SCI input clock tCKr 100 100 100 ns rise time Timer 1 • 2, SCI input clock tCKf 100 100 100 ns fall time ~HITACHI 472 tCYC ~ 2.4V V \ E \ \ O.8V PV\h ~V V PWeH \ 1\ <>-tAD-<=- tE, tEl tAH-<> -K 2.4V Ao-Al!'> R!W )< O.8V f<>---'> tHAW tRwn P\NRw '\ O.8V V 2.4V f<>- tDDW --<=0 f<'-tHW ""'" MCU Write 00-07 .J 2.4V "\ O.8V r fco- t os R-<=> ~ tHR f£2.0V MGU Read 1\ 00-07 ~~O.8V [!' -<>-tDLR-Qoo ~ tHLR V Figure 1-13. Bus Timing '" O.8V ~HITACHU 473 "'~ J~~~·2-'4-V-----\-\-~-~::----------~ ~O_._8V ~/ ______ ____ __+-+_IHMR tSMR MR Figure 1-14. Memory Ready and E Clock Timing Last Instruction Instruction Execution HALT Cycle Cycle IBA 2.4V 8A O.8V Figure 1-15. HALT and BA Timing Synchronous Clock Transmit Data Receive Data ·2.0V is high level when clock input. 2.4V is high level when clock output. Figure 1-16. SCI Clocked Synchronous Timing ~HITACHI 474 r- MCU Write P20-P2, P30-P3, P60-P6, (Inputs) (Outputs) Figure 1-17. Port Data Set-up and Figure 1-18. Port Data Delay Times Hold Times (MCU Read) (MCU Write) E~ ____~x;;.~~~ X~_____ Output Timer 1 T2CNT FRC ~ tTOD t- P2" P2 5 -------''----.V;1.::2''"."''4V,.,----- P2 6 Outputs ,"}f2-"'·"'BV.::......_ __ Output Figure 1-19. Timer 1 Output Timing Figure 1-20. Timer 2 Output Timing Vee I j k r 1rl RL~2'2kQ Test Point 1S207<\® C R or equiv. O.BV tCKr •• tCKf •• C~90pF for 00-0" Ao-A", E -Timer 2; tteye "Timer 1 ; tPWT ~30pF for Port2, Port 6, RD, WR, R;W, BA,TiR SCI ; tSeye Timer 2; tPWTCK SCI ; tPWSCK R~12kQ Figure 1-21, Timer 1-2, SCI Input Clock Figure 1-22. Bus Timing Test Loads Timing (TTL Load) ~HITACHI 475 Interrupt Test Internal Bus Address :=:x:t::C=X=:X=::C=X="::Jc:=x::=)(=::::>c::=x::=x.=:J!~::~=X="::JC SP SP-1 SP-2 SP-3 SP-4 SP-5 SP-6 ~§ll" r~'i:0r ~~w AddressAddressAddress Internal DataBus ____A-__ ~ __ _J~ __ A-__~___J~__~__~~-J''___~___A_ __ J ' __ _ A __ _ J, __ _''~ __I ' _ Op OperandlrrelevantPCQ- PCB- IXO- Ixa- ACCA ACee eCR Vector Vector First Inst. of CodeOp CodeData PC7 pe15 IX7 IX15 MSB LSB Interrupt Routine Internal Read ,~------------------------------------~------------------- Internal Wite ------', ,~--------------- Figure 1-23. Interrupt Sequence Address Bus _~Il~I\IlOC:=X::"y"="y"=:J=:JC=:JC=~=:t;~r----C~ FFFF FFFF FFFF FFFF FFFF FFFE FFFF New PC FFFF FFFF FFFF I ~~r-----r!!-------- !;.:~;;·,_.tt'~\, 15 ;~!------f'>-'------- R/W _~\\\\,\\t\\\\\\\\W All .I-\~\\~~\\\\~~~W l~~i--l- - - - - "'.\\~. If WR • • ~~:. ~J_ _~.~~)-,_ __ ~0'--------pc~Y.~'-------------;' PC15 PC7 Instruction Figure 1-24. Reset Timing @HITACHI 476 1.3 HD63701 XO, HD637 A01 XO, HD637B01 XO Electrical Characteristics Absolute Maximum Ratings Item Symbol Value Unit Supply voltage Vee -0.3 to +7.0 V Vpp voltage Vpp -0.3 to +22 V I nput voltage Vin -0.3 to Vee+0.3 V Operating temperature Topr o to +70 'C Storage temperature Tstg -55 to +125 'C Note: This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply Qvervoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend Vtn. VOU.I: Vss ;;;! (V In or VOu.,) ;;;aVec. Electrical Characteristics DC Characteristics (Vee = 5.0 V ± 10%. 1=0.1 to 2.0 MHz. Vss=OV. Ta=-20 to +70'C. unless otherwise noted.) Item Symbol Min Typ Max Unit Test Condition Input high voltage RES, STBY, MPo, MPl VIH Vee-0.5 Vee+0.3 V EXTAL VeexO.7 Vee+0.3 V Pzz(SCLK)3 2.4 Vee+0.3 V I Other inputs 2.0 Vee+0.3 V Input low voltage All other inputs VIL -0.3 O.B V Input leakage current R§ Port 5 Ilinl 1.0 JlA Vin=0.5 to Vee-0.5 V NMI, STBY. MPo. MPl Three state Ports 1. 2, 3, 4, IITsd 1.0 JlA Vin=0.5 to Vee-0.5 V leakage current 6,7 Output high voltage VOH 2.4 V IOH=-200 JlA Vee-0.7 V IOH=-10JlA Output low voltage Ports 2,6 VOL 0.5 V IOL-1.6 rnA Other outputs 0.4 V Darlington drive Ports 2. 6 -IOH 1.0 10.0 rnA Vout=1.5 V current Input capacitance All inputs (except Vpp/OE) Cin 6.5 pF Vin=OV, 1-1 MHz, VpplOE 12.5 pF Ta=25'C Standby current Not operating ISTB 3.0 15.0 JlA Current dissipation l ISLP 1.5 3.0 rnA Sleeping (1-1 MHzZ) 2.3 4.5 rnA Sleeping (1-1.5 MHzZ) 3.0 6.0 rnA Sleeping (1-2 MHzZ) lee 7.0 10.0 rnA Operating (1-1 MHzZ) 10.5 15.0 rnA Operating (1=1.5 MHzZ) 14.0 20.0 rnA Operating (1-2 MHzZ) RAM standby voltage VRAM 2.0 V Notes: 1. Vm min=Vcc -1.0V, V1L max=O.8V (All output terminals are at no load) 2. Current dissipation of the operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about current dissipations at x MHz operation are decided according to the following formula: typo value (I=x MHz) =Iyp. value (1=1 MHz) Xx max. value (I=x MHz) =max. value (1=1 MHz) Xx (bolh Ihe sleeping and opera ling) 3. Only serial clock use. ~HITACHI 477 AC Characteristics (Vee-5.0 v ±1O%, 1-0.1 to 2.0 MHz, Vss-O v, Ta--20 to +70 'C, unless otherwise noted.) Bus Timing HD63701YO HD637AOIYO HD637BOIYO Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit Condition Cycle time tcyc 10 0.666 10 0.5 10 ~s Fig. 1·25 Enable rise time tEr 25 25 25 ns Enable fall time tEf 25 25 25 ns Enable pulse width high level l PWEH 450 300 220 ns Enable pulse width low level l PWEl 450 300 220 ns Address, R/W delay time! tAO 250 190 160 ns Data delay time (Write) toow 200 160 120 ns Data set·up time (Read) toSR 80 70 70 ns Address, R/W hold time l tAH 70 45 30 ns Data hold time (Write)l tHw 70 50 35 ns (Read) tHR 0 0 0 ns RO, WR pulse widthl PWRW 450 300 220 ns RD, WR delay time tRWo 40 40 40 ns RD, WR hold time tHRW 30 30 25 ns LfR delay time tOlR 200 160 120 ns LlR hold time tHlR 30 30 25 ns MR set·up time l tSMR 400 280 230 ns Fig. 1·26 MR hold time! tHMR 90 40 0 ns E clock pulse width at MR PWEMR 9 ~s Figs. 1·27, Processor control set-up time tpes 200 200 200 ns 1·35,1·36 Figs. 1·26, Processor control rise time tPCr 100 100 100 ns 1·27 Processor control fall time tpCf 100 100 100 SA delay time tSA 250 190 160 ns Fig. 1·27 Oscillator stabilization time tRe 20 20 20 ms Fig. 1·36 Reset pulse width PWRST 3 tcyc Note: I. These timings change in approximate proportion to tcyc. The figures in this characteristics represent those when tcyc is minimum (=in the highest speed operation). ~HITACHI 478 Peripheral Port Timing HD63701XO HD637A01XO HD637B01XO Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit ~::~ition Peripheral data (Ports 2, 3 tpDSU 200 200 200 ns Fig. 1·29 set-up time 5,6) Peripheral data (Ports 2, 3 tpDH 200 200 200 ns hold time 5,6) Delay time (From (Ports I, 2, 3 enable fall edge to tpWD 300 300 300 ns Fig.I·30 4,6, 7) peripheral output) Timer, SCI Timing HD63701XO HD637A01XO HD637B01XO 5ymb Test Item Min Typ Max Min Typ Max Min Typ Max Unit 01 Condition Timer 1 input pulse width tPWT 2.0 2.0 2.0 tcyc Fig. 1·33 Delay time (enabl~ positive Figs 1·31 tTOD 400 400 400 ns transition to timer output) 1·32 (Async. mode) tScyc 1.0 1.0 1.0 teyc Fig. 1·33 SCI input clock cycle (Clock sync) 2.0 2.0 2.0 Fig. 1·28 teyc SCI tra nsmit data delay tTXD 200 200 200 ns Fig. 1·28 time (Clock sync. mode) SCI receive data set-up tSRX 290 290 290 ns time (Clock sync. mode) I SCI receive data hold time tHRX 100 100 100 ns (Clock sync. mode) SCI input clock pulse width IpWSCK 0.4 0.6 0.4 0.6 0.4 0.6 tscyc Fig. 1·33 Timer 2 input clock cycle ttcyc 2.0 2.0 2.0 teyc Timer 2 input clock pulse width IpWTCK 200 200 200 ns Timer 1 • 2, SCI input clock tCKr 100 100 100 ns rise time Timer 1 "2, SCI input clock leK! 100 100 100 ns fall time ~HITACHI 479 toy. ~ 2.4V V· \ E \ I\O.BV PWel ,1/ / PWeH \ 1\ !--tAD_ tEr tE' tAH_ >C i<-2.4V Ao-A'!5 RIW )< Ic-O.BV I I - - tHRW tRWD PlIVRw " Jl!C2.4V O.BV I---tDDW_ !--tHW _ >- 2.4V MCU It'.+ite ./ 00-0, ~ O.BV 4-tDSR_ I--- tHR MC;U Read 2.0V 00-0, "- O.BV __ tDlR_ I - - tHlR r " Figure 1-25. Mode 1, Mode 2 Bus Timing O.BV ~HITACHI 480 1 - - - - - - - PW'MR - - - - - - 1 2.4V \ \ \ \ O.BV '----- tSMR MR O.BV Figure 1-26. Memory Ready and E Clock Timing last Instruction Instruction Execution Cycle SA Synchronous Clock Figure 1-27. HALT and SA Timing I Transmit Data Receive Data "2.0V is high level when clock input. 2.4V is high level when clock output. Figure 1-28. SCI Clocked Synchronous Timing ~HITACHI 481 t MCU Aead j MCU Write P2o-P2, ~~~=~~; "'2"".O::-V,u~-----:L...:..u.----- (Inputs) :::.O:..::.8:,,:,V-'l~_ _--'1<""""_---,___ Plo-Ph, P2o-P2, - - - - - - \.....,,-;;,,-- P30-P3,. P4o-P4, P6o-P6,. P7o-P7, _ _ _ _ _......J ......._ __ (Outputs) Figure 1-29. Port Data Set-up and Figure 1-30. Port Data Delay Times Hold Times (MCU Read) (MCU Write) E~ Timer 1 - - - - - . r-.~O~u:;:tP;,;;U,;-t- , r - - - - FAC ___ ......JX~~J,~ X,-___ T2CNT ~ troo P2,. P2 5------'--'""""V;r" r-- 2'.""'4"'V--- P2 6 Outputs f"}}o~::.·"'8.!.V _ __ Output Figure 1-31. Timer 1 Output Timing Figure 1-32. Timer 2 Output Timing Vee 1rl Al~2.2kQ Test Point lS2074ift C R or equiv. C=90pF for Port 1. Port 3, Port 4, E -Timer 2; tteye "Timer 1; tpWT =30pF for Port 2. Port 6. Port 7 SCI ; tSeye Timer 2; tPWTCK SCI ; tpWSCK A=12kQ for Port l-Port4. Port 6. Port 7. E Figure 1-33. Timer 1 '2, SCI Input Clock Figure 1-34. Bus Timing Test Loads Timing (TTL Load) ~HITACHI 482 Interrupt Test Internal Address Bus _-i\....L_"--_.A.._...A_--P'--~"-_"-_..A_-"_..../''-~''-_;:.,.._.A,-_J':-:---''_-J'­ SP SP-l SP-2 SP-3 SP-4 SP-5 SP-6 ~S~r ~siior ~Cw AddressAddressAddress Internal DataBus_-J"-_~_~_~_-E'-~"-_~_~_-"'---''-~''-_J~_J~_J'_-'1,---J'- Op OperandlrrelevantPCO- PC8- IXO- IX8- ACCA ACCB CCA Vector Vector First Inst. of CodeOp CodeData PC7 PC15 IX7 IX15 MSB LSB Interrupt Routine Internal Read \'-------------------~---------- Internal Wite I \~---------------- Figure 1-35. Interrupt Sequence E _.---u-u--4~~r-----{I{lULfUl Vce ___ =£:t~ .1 S Vcc- 0 5V tllC f f :t~' ~~)~~---------- Vce- 0 SV STBY -- - tpcs tpcs ~ Vcc-O.SV RES ----is O.8V 1-------1;f--------- ~;:~n"._~\­ ~~:;;" -.\~\~\\~\\- 5f / I R/W .~~\\.,\~~\W I!1l _~~\~,_ WR • •\\\\\\\\t\' 5f i~~l ~~:.• ~.".~~~~)t--. PCB- PCO- FIrst PC 1 S PC7 Instruction --- Figure 1-36. Reset Timing ~HITACHI 483 Programming Electrical Characteristics DC Characteristics (Vcc=5 v ± 5%, Vpp=21 v ± 0.5 v, Vss=O v, Ta=25 'C ± 5 'C, unless otherwise notes.) Item Symbol Min Typ Max Unit Test Condition Input high voltage V,H 2.2 Vcc+ 1.0 V Input low voltage V,L -0.1 0.8 V Output high voltage VOH 2.0 V IOH~-200!lA Output low voltage VOL 0.45 V IOL+1.6mA Input leakage current IllIl 10 !lA V;n~5.25V/0.4V Vpp voltage Vpp 20.5 21 21.5 mA Vpp current Ipp 30 mA Vpp-21V, CE~V,v AC Characteristics (Vcc=5V± 5%, Vpp=12.5V± 0.3 V, Ta=25'C ± 5'C, unless otherwise noted.) Item Symbol Min Typ Max Unit Test Condition Address set-up time tAS 2 !-Is DE set-up time tOES 2 !-Is DE hold time tOEH 2 Data set-up time tDS 2 !-Is Address hold time tAH 0 Data hold time tDH 2 !-Is Output disable delay time tDr 0 130 ns Data Valid from CE tDV CE pulse width tpw 45 50 55 ms OE pulse rise time tpRT 50 ns Vpp recovery time tVR 2 !-Is Note: tOF is defined when output becomes open because output level can not be refered. Input Pulse level O.B-2.2V Input rising/falling time:a!20ns { input : l.OV, 2.0V Timing reference level Program Program Verify output : O.BV, 2.0V EAo-EA" ~ Address Ess j--tAS_ EOo-EO, --< Data in Stable Data Out Valid I--tDS-- -- -- -- tDH tDY I-- - I>- tDF tAH- Vpp/OE 1\ - t:. -- - - tpw tOEH ~ tOES tPRT- CE I'--' J " Figure 1-37. PROM ProgramminglVerify Timing ~HITACHI 484 Appendix II. Instruction Execution Cycles 11.1 Instruction Execution Cycles By the pipeline control of the HD6370lXO, MULT, PUL, DAA and XGDX instructions etc. pre fetch the next instruction. So attention is necessary to the counting of the instruction cycles because it is different from the existent one······ op-code fetch to the next instruction op-code. Address Mode & Address Bus Data Bus Instructions IMMEDIATE ADC ADD 1 Op Code Address + 1 1 0 1 1 Operand Data AND BIT 2 Op Code Address + 2 1 0 1 0 Next Op Code CMP EOR 2 LDA ORA SBC SUB ADDD CPX 1 Op Code Address + 1 1 0 1 1 Operand Data (MSB) LDD LDS 3 2 Op Code Address + 2 1 0 1 1 Operand Data (LSB) LDX SUBD 3 Op Code Address + 3 1 0 1 0 Next Op Code DIRECT ADC ADD 1 Op Code Address + 1 1 0 1 1 Address of Operand (LSB) AND BIT 2 Address of Opera nd 1 0 1 1 Operand Data CMP EOR 3 3 Op Code Address + 2 1 0 1 0 Next Op Code LDA ORA SBC SUB STA 1 Op Code Address + 1 1 0 1 1 Destination Address 3 2 Destination Address 0 1 0 1 Accumulator Data 3 Op Code Address + 2 1 0 1 0 Next Op Code ADDD CPX 1 Op Code Address + 1 1 0 1 1 Address of Operand (LSB) LDD LDS 2 Address of Opera nd 1 0 1 1 Operand Data (MSB) 4 LDX SUBD 3 Address of Opera nd + 1 1 0 1 1 Operand Data (LSB) 4 Op Code Address+2 1 0 1 0 Next Op Code STD STS 1 Op Code Address + 1 1 0 1 1 Destination Address (LSB) STX 2 Destination Address 0 1 0 1 Register Data (MSB) 4 3 Destination Address + 1 0 1 0 1 Register Data (LSB) 4 Op Code Address + 2 1 0 1 0 Next Op Code JSR 1 Op Code Address + 1 1 0 1 1 Jump Address (LSB) 2 FFFF 1 1 1 1 Restart Address (LSB) 5 3 Stack Pointer 0 1 0 1 Return Address (LSB) 4 Stack Pointer-l 0 1 0 1 Return Address (MSB) 5 Jump Address 1 0 1 0 First Subroutine Op Code TIM 1 Op Code Address+ 1 1 0 1 1 Immediate Data 2 Op Code Address+2 1 0 1 1 Address of Operand (LSB) 4 3 Address of Opera nd 1 0 1 1 Operand Data 4 Op Code Address + 3 1 0 1 0 Next Op Code AIM ElM 1 Op Code Address + 1 1 0 1 1 Immediate Data OIM 2 Op Code Address + 2 1 0 1 1 Address of Operand (LSB) 3 Address of Operand 1 0 1 1 Operand Data 6 4 FFFF 1 1 1 1 Restart Address (LSB) 5 Address of Operand 0 1 0 1 New Operand Data 6 Op Code Address+3 1 0 1 0 Next Op Code (conltnued) ~HITACHI 485 Address Mode & Address Bus Data Bus Instructions INDEXED JMP 1 Op Code Address+ 1 i 0 1 1 Offset 2 FFFF 1 1 1 1 Restart Address (LSB) 3 3 Jump Address 1 0 1 0 First Op Code of Jump Routine ADC ADD 1 Op Code Address + 1 1 0 1 1 Offset AND BIT 2 FFFF 1 1 1 1 Restart Address (LSB) CMP EOR 3 IX+Offset 1 0 1 1 Opera nd Data 4 LDA ORA 4 Op Code Address + 2 1 0 1 0 Next Op Code SBC SUB TST STA 1 Op Code Address + 1 1 0 1 1 Offset 2 FFFF 1 1 1 1 Restart Address (LSB) 4 3 IX+Offset 0 1 0 1 Accumulator Data 4 Op Code Address+ 2 1 0 1 0 Next Op Code ADDD CPX 1 Op Code Address + 1 1 0 1 1 Offset LDD LDS 2 FFFF 1 1 1 1 Restart Address (LSB) LOX SUBD 5 3 IX+Offset 1 0 1 1 Operand Data (MSB) ADD 4 IX+Offset+ 1 1 0 1 1 Operand Data (LSB) 5 Op Code Address + 2 1 0 1 0 Next Op Code STD STS 1 Op Code Address + 1 1 0 1 1 Offset STX 2 FFFF 1 1 1 1 Restart Address (LSB) 5 3 IX+Offset 0 1 0 1 Register Data (MSB) 4 IX+Offset+l 0 1 0 1 Register Data (LSB) 5 Op Code Address+ 2 1 0 1 0 Next Op Code JSR 1 Op Code Address+ 1 1 0 1 1 Offset 2 FFFF 1 1 1 1 Restart Address (LSB) 5 3 Stack Pointer 0 1 0 1 Return Address (LSB) 4 Stack Pointer-l 0 1 0 1 Return Address (MSB) 5 IX+Offset 1 0 1 0 First Subroutine Op Code ASL ASR 1 Op Code Address+ 1 1 0 1 1 Offset COM DEC 2 FFFF 1 1 1 1 Restart Address (LSB) INC LSR 3 IX + Offset 1 0 1 1 Opera nd Data 6 NEG ROL 4 FFFF 1 1 1 1 Restart Address (LSB) ROR 5 IX+Offset 0 1 0 1 New Opera nd Data 6 Op Code Address+ 2 1 0 1 0 Next Op Code TIM 1 Op Code Address+ 1 1 0 1 1 Immediate Data 2 Op Code Address+ 2 1 0 1 1 Offset 5 3 FFFF 1 1 1 1 Restart Address (LSB) 4 IX + Offset 1 0 1 1 Opera nd Da ta 5 Op Code Address + 3 1 0 1 0 Next Op Code CLR 1 Op Code Address + 1 1 0 1 1 Offset 2 FFFF 1 1 1 1 Restart Address (LSB) 5 3 IX + Offset 1 0 1 1 Operand Data 4 IX + Offset 0 1 0 1 00 5 Op Code Address + 2 1 0 1 0 Next Op Code AIM ElM 1 Op Code Address+ 1 1 0 1 1 Immediate Data OIM 2 Op Code Address + 2 1 0 1 1 Offset 3 FFFF 1 1 1 1 Restart Address (LSB) 7 4 IX + Offset 1 0 1 1 Opera nd Da ta 5 FFFF 1 1 1 1 Restart Address (LSB) 6 IX + Offset 0 1 0 1 New Opera nd Data 7 Op Code Address+3 1 0 1 0 Next Op Code (continued) ~HITACHI 486 Address Mode & Address Bus Data Bus Instructions EXTEND JMP 1 Op Cope Address + 1 1 0 1 1 Jump Address (MSB) 3 2 Op Code Address + 2 1 0 1 1 Jump Address (LSB) 3 Jump Address 1 0 1 0 Next Op Code ADC ADD TST 1 Op Code Address + 1 1 0 1 1 Address of Operand (MSB) AND BIT 2 Op Code Address + 2 1 0 1 1 Address of Operand (LSB) CMP EOR 4 3 Address of Operand 1 0 1 1 Operand Data LDA ORA 4 Op Code Address + 3 1 0 1 0 Next Op Code SBC SUB STA 1 Op Code Address + 1 1 0 1 1 Destination Address (MSB) 2 Op Code Address + 2 1 0 1 1 Destination Address (LSB) 4 3 Destination Address 0 1 0 1 Accumulator Data 4 Op Code Address + 3 1 0 1 0 Next Op Code ADOO 1 Op Code Address+ 1 1 0 1 1 Address of Operand (MSB) CPX LOO 2 Op Code Address + 2 1 0 1 1 Address of Operand (LSB) LOS LOX 5 3 Address of Opera nd 1 0 1 1 Operand Data (MSB) SUBD 4 Address of Operand+ 1 1 0 1 1 Operand Data (LSB) 5 Op Code Address + 3 1 0 1 0 Next Op Code STD STS 1 Op Code Address+ 1 1 0 1 1 Destination Address (MSB) STX 2 Op Code Address + 2 1 0 1 1 Destination Address (LSB) 5 3 Destination Address 0 1 0 1 Register Data (MSB) 4 Destination Address + 1 0 1 0 1 Register Data (LSB) 5 Op Code Address+3 1 0 1 0 Next Op Code JSR 1 Op Code Address + 1 1 0 1 1 Jump Address (MSB) I 2 Op Code Address + 2 1 0 1 1 Jump Address (LSB) 3 FFFF 1 1 1 1 Restart Address (LSB) 6 4 Stack Pointer 0 1 0 1 Return Address (LSB) 5 Stack Pointer-l 0 1 0 1 Return Address (MSB) 6 Jump Address 1 0 1 0 First Subroutine Op Code ASL ASR 1 Op Code Address + 1 1 0 1 1 Address of Operand (MSB) COM DEC 2 Op Code Address + 2 1 0 1 1 Address of Operand (LSB) INC LSR 3 Address of OP.l!rand 1 0 1 1 Operand Data 6 NEG ROL 4 FFFF 1 1 1 1 Restart Address (LSB) ROR 5 Address of Operand 0 1 0 1 New Opera nd Data 6 Op Code Address + 3 1 0 1 0 Next Op Code CLR 1 Op Code Address + 1 1 0 1 1 Address of Operand (MSB) 2 Op Code Address + 2 1 0 1 1 Address of Operand (LSB) 5 3 Address of Operand 1 0 1 1 Operand Data 4 Address of Opera nd 0 1 0 1 00 5 Op Code Address + 3 1 0 1 0 Next Op Code (continued) ~HITACHI 487 Address Mode & Address Bus Data Bus Instructions IMPLIED ABA ABX 1 Op Code Address + 1 1 0 1 0 Next Op Code ASL ASLD ASR CBA CLC CLI CLR eLV COM DEC DES DEX INC INS INX LSR 1 LSRD ROL ROR NOP SBA SEC SEI SEV TAB TAP TBA TPA TST TSX TXS DAA XGDX 1 Op Code Address + 1 1 0 1 0 Next Op Code 2 2 FFFF 1 1 1 1 Restart Address (LSB) PULA PULB 1 Op Code Address + 1 1 0 1 0 Next Op Code 3 2 FFFF 1 1 1 1 Restart Address (LSB) 3 Stack Pointer+ 1 1 0 1 1 Data from Stack PSHA PSHB 1 Op Code Address + 1 1 0 1 1 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 4 3 Stack Pointer 0 1 0 1 Accumulator Data 4 Op Code Address + 1 1 0 1 0 Next Op Code PULX 1 Op Code Address + 1 1 0 1 0 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 4 3 Stack Pointer+ 1 1 0 1 1 Data from Stack (MSB) 4 Stack Pointer+2 1 0 1 1 Data from Stack (LSB) PSHX 1 Op Code Address + 1 1 0 1 1 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 5 3 Stack Pointer 0 1 0 1 Index Register (LSB) 4 Stack Pointer-l 0 1 0 1 Index Register (MSB) 5 Op Code Address + 1 1 0 1 0 Next Op Code RTS 1 Op Code Address + 1 1 0 1 1 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 5 3 Stack Pointer+ 1 1 0 1 1 Return Address (MSB) 4 Stack Pointer+ 2 1 0 1 1 Return Address (LSB) 5 Return Address 1 0 1 0 First Op Code of Return Routine MUL 1 Op Code Address + 1 1 0 1 0 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 3 FFFF 1 1 1 1 Restart Address (LSB) 7 4 FFFF 1 1 1 1 Restart Address (LSB) 5 FFFF 1 1 1 1 Restart Address (LSB) 6 FFFF 1 1 1 1 Restart Address (LSB) 7 FFFF 1 1 1 1 Restart Address (LSB) (continued) ~HITACHI 488 Address Mode & Instructions Address Bus Data Bus IMPLIED WAI 1 Op Code Address + 1 1 0 1 1 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 3 Stack Pointer 0 1 0 1 Return Address (LSB) 4 Stack Pointer-1 0 1 0 1 Return Address (MSB) 9 5 Stack Pointer-2 0 1 0 1 Index Register (LSB) 6 Stack Pointer-3 0 1 0 1 Index Register (MSB) 7 Stack Pointer-4 0 1 0 1 Accumulator A 8 Stack Pointer- 5 0 1 0 1 Accumulator B 9 Stack Pointer-6 0 1 0 1 Conditional Code Register RTI 1 Op Code Address + 1 1 0 1 1 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 3 Stack Pointer+ 1 1 0 1 1 Conditional Code Register 4 Stack Pointer+2 1 0 1 1 Accumulator A 5 Stack Pointer+3 1 0 1 1 Accumulator B 10 6 Stack Pointer+4 1 0 1 1 Index Register (MSB) 7 Stack Pointer+ 5 1 0 1 1 Index Register (LSB) 8 Stack Pointer+6 1 0 1 1 Return Address (MSB) 9 Stack Pointer+ 7 1 0 1 1 Return Address (LSB) 10 Return Address 1 0 1 0 First Op Code of Return Routine SWI 1 Op Code Address + 1 1 0 1 1 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 3 Stack Pointer 0 1 0 1 Return Address (LSB) 4 Stack Pointer-1 0 1 0 1 Return Address (MSB) 5 Stack Pointer-2 0 1 0 1 Index Register (LSB) 6 Stack Pointer- 3 0 1 0 1 Index Register (MSB) 7 Stack Pointer-4 0 1 0 1 Accumulator A 12 8 Stack Pointer- 5 0 1 0 1 Accumulator B 9 Stack Pointer-6 0 1 0 1 Conditional Code Register Address of SWI Routine 10 Vector Address FFFA 1 0 1 1 (MSB) Address of SWI Routine 11 Vector Address FFFB 1 0 1 1 (LSB) 12 Address of SWI Routine 1 0 1 0 First Op Code of SWI Routine SLP 1 Op Code Address + 1 1 0 1 1 Next Op Code 2 FFFF 1 1 1 1 Restart Address (LSB) 1 4 Sleep 1 1 I 1 1 1 3 FFFF 1 1 1 1 Restart Address (LSB) 4 Op Code Address + 1 1 0 1 0 Next Op Code (continued) ~HITACHI 489 Address Mode & Address Bus Data Bus Instructions RELATIVE BCC BCS 1 Op Code Address +.1 1 0 1 1 Branch Offset BEQ BGE 2 FFFF 1 1 1 1 Restart Address (lSB) BGT BHI {Branch Address .. ·Test="J" First Op Code of Branch Routine 3 Op Code AddresS+2.. ·Test="Q" 1 0 1 0 BlE BlS 3 Next Op Code BlT BMT BNE BPl BRA BRN BVC BVS BSR 1 Op Code Address+ 1 1 0 1 1 Offset 2 FFFF 1 1 1 1 Restart Address (lSB) 5 3 Stack Pointer 0 1 0 1 Return Address (lSB) 4 Stack Pointer-l 0 1 0 1 Return Address (MSB) 5 Branch Address 1 0 1 0 First Op Code of Subroutine ~HITACHI 490 Appell1ldOJ{ ~~t Questioll1ls all1ld Answers This appendix contains saine frequently asked questions about the HD6301 XO, HD63701 XO, and HD6303X. 111.1 Parallel Ports 111.1.1 DDR and Data Register Question: Should the data or DDR (data direction register) be set first, when an I/O port functions as an output port? Answer: Output data should be stored in the data register first, then DDR should be set (DDR = 1). If DDR is set first, unknown data will be output from the port . .Supplement: DDR (data direction register) DDR programs I/O port as an input or output. DDR = 1: output DDR = 0: input DDR is initialized to 0 during reset. 111.1.2 Port 7 Upper Bits Question: What is the state of the upper 3 bits in port 7 (5-bit output port) when reading port 7 in mode 3 (single chip mode)? Answer: The upper 3 bits in port 7 are all set to 1. Port 7 DDR can read the contents of the data register by using the bit manipulation instruction. Supplement: Ports 1 and 4 can also be read with bit manipulation instructions. 111.1.3 SCLKlP22 Pin Question: How do you use the P22 (SCLKlP22 multiplexed pin) as an I/O port? Answer: To use the P22 as an I/O port, set bit 1 in the port 2 DDR (data direction register), and CCO, CC1, and CC2 in the RMCR (rate/mode control register) as in table 111-1. ~HBTACHD 491 Table 111-1. P22 I/O Settings Bit Setting Bit 1 of port 2 DDR o (Input port) (Note1 ) 1 (Output port) CCO (Note 2) CC1 o CC2 Oar 1 Notes: 1. Bit 1 of the port 2 DDR selects the direction of 7 bits P21 - P27. 2. During reset, CCO, CC1 and CC2 are cleared to 0 and the P22 functions as SCLK pin. Supplement: The CCO, CC1, and CC2 (clock control format select) program the SCI data format and the SCI clock direction. The DDR (data direction register) programs the direction of the 1/0 port. DDR = 0: Input DDR = 1: Output 111.1.4 P5a/HALT Pin Question: How can P53 (P53/HALT multiplexed pin) be used as an input-only port in expanded mode (modes 1 and 2)? Answer: In expanded mode, P53 functions as HALT pin with HLTE bit = 1 during reset. To use P53 as an input port, hold it high until 0 is written in the HLTE after reset, inhibiting HALT input. 111.2 Serial Port 11.2.1 RDRF in Wake-Up Mode Question: When using the SCI in the asynchronous mode with the receive enable bit (RE) of the transmiVreceive control status register (TRCSR) = 1 and wake-up bit (WU) = 1, what is the state of the receive data register full bit (RDRF)? 7 6 5 4 3 2 o TRCSR I RDRF I ORFE I TORE I RIE RE TIE TE wu o 1 1 Figure 111-1. Transmit/Receive Control Status Register in Wake-Up Mode ~HITACHI 492 Answer: When the wake-up flag is set (WU = 1), the RDRF flag is not set (RDRF = 0). 111.2.2 SCLK Direction and DDR Question: When using the P22 (SCLKJbit 2 of 1/0 port 2) as the SCI clock 1/0, is the clock direction determined by CCO, CC1 and CC2 (clock controVform select) in the RMCR (rate/mode control register) regardless of bit 2 of the port 2 DDR? Answer: Yes, it is determined by CCO, CC1 and CC2 independently of the port 2 DDR. When used as an 1/0 port, its 1/0 direction is determined by bit 2 of the port 2 DDR. In this case, CCO, CC1 and CC2 should be set to a mode where P22 is not used as SCI clock (CCO, CC1, and CC2 set to 101, or 100). CCO, CC1, and CC2 are cleared to a at reset (table 111-2). Table 111·2. P22 Direction P22 SCLK Port 2 DDR Input or output No effect CCO CC1 CC2 0 oor 1 CCO, CC1, CC2 determine clock form, direction I Supplement: The CCO, CC1, and CC2 (clock control format select) program the SCI data format and the SCI clock direction. The DDR (data direction register) programs the direction of the 1/0 port. DDR =0: Input DDR =1: Output 111.2.3 Receive Sampling Clock Question: What is the relation between the receive data sampling clock at the SCI receive, and the data transfer rate? Answer: The sampling clock is sixteen times as fast as the transfer rate. ~HITACHI 493 111.2.4 Sampling Error Question: What does "sampling error" mean? Answer: "Sampling error" means receive margin in SCI operation. The HD63701 XO detects a start bit at the negative edge of the sampling clock, and samples the start bit and data bit at the positive edge of the sampling clock. The general equation of the receive margin is shown as follows (figure 111.2). M = {(0.5 - 1/2N) - (D - 0.5)/N - (L - 0.5)Fl x1 00 (%) M: Receive margin N: Baud rate ratio to sampling clock D: Duty of the longer sampling clock of high and low (0.5 - 1) L: Frame Length (7 - 12) F: Absolute value of deviation of sampling clock frequency An abbreviated version is: M = (0.5 -1/2N) x 100 (%) (Condition: D = 0.5, F =0) N 8 16 32 64 Note M 43.75 46.875 48.4375 49.21875 HD63701XO: (%) N=16 o 2 3 4 5 6 7 7.5,8 Clock 1 i I I Rx 1TlL-+iI_______________ I ! r--t-i4-6.8-75% ~, i 50% ! 46.875% 1/N I ,. ..~. I Start Bit 0.5 r:: I 11/2N Start bit activates Start bit sampling Figure 111-2. Sampling Error ~HITACHI 494 111.3 Timer/Counter 111.3.1 Reading the FRC Question: When you read the free-running counter (FRC) of the timer 1 by a double-byte load instruction, is the read value correct? Answer: It is correct. In the first cycle, the high byte of the FRC is read, when the low byte is set in a temporary register. At the next cycle, the data stored in the temporary register is read (figure 111-3). , high byte read I low byte read I I I I I I I E FRC $.EZ FF $F8 00 Temporary register T fFFl t.. __ J Read data $F7 $FF I Accumulator D F7 FF (When reading $F7FF from the FRC) Figure 111-3. FRC Double-Byte Read Supplement: To read the timer FRC correctly, use double-byte load instructions (LDD,LDX). 11.3.2 Reading the FRC in the HD6801V Question: How is FRC writing in the HD6301XO, HD6303X, and HD63701XO different from the HD6801V? Answer: The difference is shown in table 111-3. Table 111-3. HD6301 XO/HD6303X1HD63701 XO and HD6801V Write Differences Type How to Write (Preset) HD6801V The FRC is always preset to $FFF8. HD6301XO, HD6303X, Writing to the high byte presets the FRC to $FFF8. HD63701XO Data is always set in the FRC by a double-byte store instruction. See figure 111-4 for an example. ~HITACHO 495 (I) The H06801 V preset method LOO #$5AF3 - STO$09 E I I FRC I $FFFB II $FFF9 I $FFFA 1 i- The FRC Is always preset to $FFFB. (2) The H06301 XO/H06303X1H063701 XO preset method ($5FA3) $FFFB LOO #$5AF3 -STAA$09 E FRC $FFFB $FFF9 $FFFA Writing to the high by1e $09 the FRC to $FFFB. - Optional value (In this case $5AF3) LOO #$5AF3 E -STO$09 FRC $FFFB , $5AF3 $5AF4 - A double-by1e store instruction presets the FRC to optional ($5AF3) value Figure 111-4. FRC Writing for HD6301XOIHD6303X1HD63701XO and HD6801V 111.3.3 ECMllnterrupt Question: Timer 2 is used by writing 0 to enable counter match interrupt (ECMI) of the timer controVstatus register 3 (TCSR3). When a counter match flag (CMF) of TCSR3 becomes 1, 1 is written to ECMI. Does this generate an interrupt? Answer: Yes. When the time constant register (TCONR) matches the timer 2 counter, the CMF is set to 1 and kept at 1 unless 0 is written in by software. An interrupt will occur if ECMI = 1 after CMF = 1. Supplement: A timer 2 interrupt is generated with CMF = 1 and ECMI = 1. ECMI defines internal interrupt (lRQ3) enable/disable. ECMI =0: disable ECMI = 1: enable 111.3.4 SCI and Writing to Timers Question: When the SCI is operating, can data be written into the timer 1 FRC or timer 2 T2CNT? Answer: If the SCI is using an extemal clock, the timer 1 FRC and the timer 2 T2CNT can be written ~HITACHI 496 into. In the case of an internal clocl<, either the FRC or the T2CNT is used as a clock-source counter (note 1). No clocl<-source counter can be written to. Note that there are some restrictions, as follows: 1. External clock operation a. Timer 1 FRC can be written to b. Timer 2 T2CNT can be written to 2. Internal clock operation a. Using timer 1 FRC as an internal clock - Don't write to the timer 1 FRC during SCI operation. - Timer 2 T2CNT can be written to. b. Using timer 2 T2CNT as an internal clock - The timer 1 FRC can be written to, except when input clock to T2CNT is El8 or El128. El8, El128 come from the timer 1 FRC. If these clocks are selected as T2CNT input clocks, writing to the FRC will delay them. - Don't write to timer 2 T2CNT during SCI operation. Supplement: When an internal clock is operating the SCI, writing to the clock-source counter will delay the SCI transfer rate. 111.4 Bus Inter1ace 111.4.1 E and Memory Ready Question: What is the internal E clocl< state when the CPU uses the memory ready function? Answer: Internal E clock operates at normal frequency (figure 111-5). Since the timer count and the SCI transfer rate are set by the internal E clocl<, they are not also affected by the memory ready function. Internal E External E MR (Memory ready signal) Figure 111-5. Internal and External E Clocks Supplement: It is impossible to examine the internal E clock from an external pin when using the memory ready function. @IHWiiACHll 497 111.4.2 Memory Ready and Halt After Reset Question: After reset, are memory ready and halt functions enabled or disabled? Answer: Both are enabled. MR and HALT in three operating modes is shown in table 111-4. Table·III-4. Operating Modes Operating Mode Memory Ready Halt Expanded mode Enabled (note) Enabled 2 Enabled (note) Enabled Single-chip mode No memory ready function No halt function Note: Invalid when accessing internal address space Supplement: In the expanded mode (modes 1, 2), the memory ready bit (MRE) and halt enable bit (HLTE) of the RAM/port 5 control register are set to 1 during reset, enabling memory ready and halt functions. 111.4.3 Buses at Internal Address Access Question: When you access internal memory space, what states are the address buses, data buses, and control lines in? Answer: Address buses and control lines (RD, WR, R/W) are always output regardless of internal or external address space accessing. During writes to the internal address space, the same data is output from the data bus. During reads, the data buses become high impedance. 111.4.4 External Access to Register Addresses Question: When using external memory at the addresses shown below in expanded modes (modes 1,2), some addresses overlap internal registers and RAM addresses (figure 111-6). In such a case, are there any problems? ~HITACHI 498 Internal Memory Map External Memory Map Internal register r7'7'T7'7'T7'77'T'1'TT7TT7'r ~o RES pin Internal reset signal 0 Q 0 Q Internal Figure 111-12. Reset Circuit 111.7.4 Reset Circuit Capacitance Question: Does Cr in the reset circuit shown in figure 111-13 (Rr x Cr > 20 rns), have an upper limit? r--------------------+--~--_;STBY Rr crJ; '--------------+-------...., PORT Release Standby mode Rr· Cr > 20ms (External input) Figure 111-13. Reset Input Circuit Answer: No, because RES is provided with a Schmitt trigger circuit (figure 111-12). ~HITACHI 504 111.8 Low Power Dissipation Mode 111.8.1 Standby During Instruction Execution Question: Does the CPU wait until the current instruction is executed to enter the standby mode? Answer: No. The CPU enters standby mode regardless of the current instruction; the CPU goes into reset condition and the oscillator stops with STBY low (figure 111-14). ~ Oscillator Stop Internal reset I I E I STBY ----------------------~ Figure 111-14. E During Standby 111.8.2 Standby Timing Question: The timing for the standby mode is shown in figure 111-15 (see also figure 3-5). Is T1 in the figure defined? Vcc r-----.., CDNMll~-------_jI~ I I I I CD NMI I i T,I I......., MCU STBY @RES--I-i:11. m11.LL. li-------iJIf--~1 I I I CD I--tl I I I I CD STBY--.... I I11111 1 f t ". . , J,tl ! I Oscillator RES I I 1 I J I Stabilization 1 : : I Time ® I I ' • • 1. I I Standby Mode _I.I I I 1 o Register Save o RAM/Port 5 Control Register Set ~ Restart Figure 111-15. Standby Mode Timing Answer: It is not, but if the time for nonmaskable interrupt (NMI) is guaranteed, either RES or STBY can go low with no priority. Supplement: The CPU goes to the standby mode independently of instruction execution sequence. Use the NMI routine before entering standby mode. ~HITACHI 505 111.8.3 Ports at Standby Question: What is the state of each I/O port during standby? Answer: Each I/O port and E pin during standby is high impedance. 111.8.4 Return from Standby Without Reset Question: What occurs when the CPU returns from the standby mode without using reset start? Answer: The CPU does not operate normally because the contents of each register are not defined. Therefore, always use the reset start when returning from the standby mode. 111.8.5 Sleep and. Standby Internal States Question: What are the internal states in the sleep or standby mode? Answer: They are as shown in table 111-7. Table 111-7. Sleep and Standby Mode States Sleep Mode Standby Mode Oscillation circuit Continues Stops CPU (register) Stops (retained) Stops (undefined) RAM Retained Retained I/O Retained High impedance Timer Continues Stops Serial communications Continues Stops Internal registers Retained Reset Cancel Interrupt Reset start after STBY = high STBY = low Reset start Supplement: Internal states in the standby mode are the same as those in reset start. Use the reset start when returning from the standby mode. In this case RES should be kept low from STBY = high during oscillation stabilization time (20 ms minimum). @HITACHI 506 111.9 Software 111.9.1 Bit Manipulation Instructions Question: How should the bit manipulation instructions of the HD6301 XO, HD6303X, and HD63701 XO be written? Answer: They are written as shown in figure 111-16. aiM # $ aiM # $ °° 4 . $ 1 4 . $ 1 °°. (Direct Addressing) X (Index Addressing) I~~ Immediate Data Address Index Register Figure 111-16. aiM Example This is an example of OR operation between the immediate data and the memory which stores the result in the memory. The AIM, ElM, and TIM instructions are wr~ten in the same way. The bit manipulations in table 111-8 have different mnemonics with the same opcode. Table 111-8. Shared Opcodes Bit Manipulation Instructions Having the Same Opcode Instruction Mnemonic Function AIM BCLR OAND Mi The memory bit i (i = 0 to 7) is cleared and the other bits don't change aiM BSET 10RMi The memory bit i (i = 0 to 7) is set and the other bits don't change ElM BTGL Mi EaR Mi The memory bit i (i = 0 to 7) is inverted and the other bits don't change TIM BTST 1 ANDMi AND operation test of the memory b~ i (i =0 to 7) and 1 is executed and its corresponding condition code is changed. The mnemonics mentioned above can be written as in figure 111-17. BCLR 3,$10 - - - AIM #$F7, $10 (Direct Addressing) BCLR 3,$10,X AIM #$F7, $10,X (Index Addressing) BSET 3,$10 aiM #$08, $10 (Direct Addressing) BSET 3,$10,X aiM #$08, $10,X (Index Addressing) ~f Bit Address Index Register Figure 111-17. Shared Opcode Instruction Format ~HITACHI 507 111.10 Others 111.10.1 RAME Disabled Question: When executing a program with the RAM enable bit (RAME) of the RAM/port 5 control register disabled (RAME = 0), 1. What occurs if the internal RAM address is accessed? 2. What occurs if interrupt requests are generated? Answer: 1. The intemal RAM cannot be accessed. lfis neither readable nor writable with RAME = 0, so in mode 1 or 2, the external memory is readlwritten into. 2. Interrupts are accepted, but the CPU will burst when returning from the interrupt with no stacking area other than the internal RAM. Supplement: 1. RAME = 0; internal RAM is invalid. In modes 1 or 2, data can be read from the external memory. 2. RAME = 1; internal RAM is enabled. 111.10.2 RAME at Reset Question: Is the RAM enable bit (RAME) set to 1 on reset at RES low or the rising edge of RES? Answer: It is set at the rising edge of RES (figure 111-18). Internal RAM -t- Internal RAM Disable I Enable (RAME=O) I (RAME=l) I Figure 111-18. RAME at Reset Supplement: RAME is seVcleared by the software. 1. RAME = 0; Internal RAM is invalid. In mode 1 or 2, data can be read from the external memory. 2. RAME = 1; Intemal RAM is enabled. ~HITACHI 508 Appendix IV. The Differences Between HD63701 XO and HD6301XO IV.1 The Differences Between HD63701 XO and HD6301 XO Item HD63701XO HD6301XO Vpp/OE pin Vpp/OE Vss function MCU mode; Connected to VSS voltage Connected to VSS Voltage PROM mode; Input for the programming voltage Input Vpp/OE 25pF max All inputs 12.5pF max capacitance All other inputs 1 2.5pF max Input high VIH = VSS - O.5V min VIH = 2.0V min voltage of MPO, MP1 HD63701XO HD637A01XO HD637B01XO HD6301XO HD63A01XO HD63B01XO Bus Timing tAH 70 45 30 tAH 80 50 35 . Address, I tHw 70 50 35 tHW 80 50 40 R/W, hold Unit:ns Unit: ns timing . Data hold timing Crystal Internal resistance of crystal oscillator Internal resistance of crystal oscillator oscillator RS RS characteristics Frequency (MHz) RS max (n) RS = 60n max Storage T stg = - 55 to 125°C T stg = - 55 to 150°C temperature Caution The HD63701 XO differs from HD6301 XO in chip deSign and manufacturing process. When applying the HD63701 XO system to HD6301 XO, and HD6301 XO system to HD63701 XO, note that characteristic values are not exactly the same even if guaranteed values are the same. @HITACHI 509 Appendix V. Program Development Procedure and Support System V.1 Overview The cross assembler and the hardware emulator using various types of computer are prepared by the company as supporting systems to develop user's programs. User's programs are mask programmed into the ROM and delivered as the LSI by the company. Figure V-1 shows the typical program design procedure and Table V-1 shows the system development support tool for HD6301XO and HD6303X which are used in these processes. Text Edi tor fCRT Editor Host Computer Host Computer Emulator EPROM On-Chip LSI. HD63701YOC Figure V-1. Program Design Procedure ~HITACHI 510 (Explanation) 1. When the user programs the system using the HD6301 XO series, a functional assignment of each I/O pin and an allocation of RAM area should be specified adjusting to designed system before actual programming. 2. A flowchart is designed to implement the functions and it is coded by using the HD6301 XO mnemonic code. 3. Write the software coded according to the flowchart on a floppy disk to make a source program. 4. Assemble the source program to generate an object program using a computer. Assembly errors are also detected. 5. Verify the program through hardware emulation with an emulator or EPROM on-chip type microcomputer. 6. Send the completed program to the company in the form of EPROM. Send Single-chip microcomputer order specification and Masl< option list at that time. 7. ROM and mask option are masked by the company. LSI is testatively produced and the sample is handed in to the user. If a user doesn't see any problem in programming, mass production can be started. Table V-l Support Tools Part No. HD6J01XO, HD6JOJX Emulator HJ1MIX2 (HSJ1XEML02H) EPROM on- chip LSI HD6J701XOC EPRO~! on-chip LSI Programming Socket Adapter H67PWAOl IBM PC Cross Assembler SJlIBMPC IBM PC C Compiler USJ1PCLIlSF I HD6301XO and HD6303X Development Tools ~HITACHI 511 V.2 Single Chip Microcomputer ROM Ordering Procedure V.2.1 Development Flowchart Single chip microcomputer device is developed according to the following flowchart after program development. Device Development Flowchart Hitachi Customer Remarks 1 ROM code *1 *1 2 sets of EPROM 2 Mask Option List *2 3 Ordering Specifications *2 Part specific *3 *3 Generic for Hitachi , Computer processing microcomputers ROM code for confirmation of ROM fabricating *4 The same ROM code specifications *4 as submitted. OK 4 Verification Listing *5 Send it back after approving Mask Sample Working Sample (WS) *6 *6 3 pes. 1 Confirmation of function, *7 Start the following 15 flowchart after characteristics *7, *8 approving *8 Send back signed working sample approval form. OK *9 10 pes. + Engineering Sample (ES) *9 t IConfirmation of function, Icharacteristics, quality 1 Commercial Sample (CS) j (E~D) Note. Please send In 1 , 2, and 3 at ROM ordenng, and send back 4, 5 after approving. ~HITACHI 512 V.2.2 Data you send and precautions (a) Ordering specifications .................... Common style for all Hitachi single chip microcomputer devices. Please enter as for the followings. The format is shown in the next page. Basic ITEM Environment Check List Check List of attached data Customer (b) ROM code ................................ Please send in the ordering ROM code by 2 sets of EPROM the same contents are written. Enter ROM code No. in them. It is desirable to send in program list for easy confirmation of the program contents. I V.2.3 Change of ROM code Note that if you change the ROM code once sended in or other specification, the ROM must be developed from the beginning. The cost of mask charge should be provided again in this case. V.2.4 Samples and Mass production (Working Sample) ........................... . Sample for confirmation of the contents of ROM code and that of mask option. Normally samples are sent but not guaranteed as for reliability. Please evaluate and approve immediately because the following sample making and mass production are set about after obtaining your evaluation. Sample for evaluating also reliability. 10 pcs are (Engineering Sample) ........................ . included in mask charge. Samples for pre-production which may be (Commercial Sample) ........................ . purchased separately. Products for actual mass production. Please enter (Mass Product) .............................. . the plan of mass production in full. ~HITACHI 513 V.2.5 HD6301XO ORDERING SPECIFICATIONS (Fll'In blank space or c heck appropnate ox (1) GENERAL CHARACTERSITICS 1 Customer Device Package Outline (See page 380.) o DP-64S DFP-80 D CP-68 Type Application OptionslRemarks: (be specific) Customer ROM Code ID ZTAT TM DYes DNo Conversion DEPROM ROM Code Must Specify: Customer Programmed Start Address Media DZTATTM Customer Programmed Stop Address Operating Temperature D Standard D J (-40· C to +85·C) version if offered Remask DYes o No Previous Hitachi PIN (2) OPERATING CHARACTERISTICS (Fill in blank space or check appropriate box m.) LSI Ambient Typical ·C Target Level Of Reliability 0 1000 Fit D( ) Temperature Range ·C- ·C 0 500 Fit LSI Typical % Acceptable Electrical D 0.25% D ( ) Ambient Quality Major Humidity Range %- % Level D.0.65% D ( ) Visual Power On Typical Hours/Day LSI Operating Speed (Specify MHz or KHz) Duration Remarks: Power Max. V Maximum Applied Supply Voltage To LSI 1/0 Max. V (3) ELECTRICAL CHARACTERISTICS (Fill in blank space or check appropriate box [KJ.) D Purchasing Specifications D Hitachi's Standard Specifications Refer To Data Sheet: ( For Hitachi Use Only) (4) CUSTOMER APPROVAL (5) ROM CODE VERIFICATION Customer Namec....-_ _ _ _ _.....;.._ _ _-.-,;_ __ LSI Type No. PO# ________________________________ Shipping Date of Approved By (print) _ _ _ _ _ _ _ _ _ _ _ __ ROM To Customer Approved By (signature)_--'-_ _ _ _ _ _ _ __ Approved Date of Date ROM From Customer ~HITACHI 514 HD6301/HD6303 SERIES HANDBOOK Section Six HD6301YO/ HD6303Y/HD63701YO ' ~..•• . I User s Manual 9 , ~HUIlACHU 515 Section 6 HD6301 YO/HD6303YIHD63701 YO User's Manual Table of Contents Page 1. OVERVIEW.................................................... 519 1.1 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 519 1.2 Block Diagrams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 520 1.3 Pin Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 523 2. INTERNAL ARCHITECTURE AND OPERATION. . . . . . . . . . . . . . . . . . . . . .. 526 2.1 Operation Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 526 2.2 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 527 2.3 Function Pin Description ...................................... , 528 2.4 Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 531 2.5 RAM/Port 5 Control Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 543 2.6 Port 6 Control/Status Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 546 3. CPU FUNCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 548 3.1 CPU Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 548 3.2 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 549 3.3 Instruction Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 551 3.4 CPU Instruction Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 557 3.5 Low Power Dissipation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 559 3.6 Trap Function ................... " . . . . . . . . . . . . . . . . . . . . . . . . . .. 562 3.7 Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 563 3.8 Interrupts .................................................. , 564 4. TIMER 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 567 4.1 Free-Running Counter (FRC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 568 4.2 Output Compare Registers (OCR) ......... . . . . . . . . . . . . . . . . . . . . .. 568 4.3 Input Compare Register (ICR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 569 4.4 Timer Control/Status Register 1 (TCSR1) ......................... , 569 4.5 Timer Control/Status Register 2 (TCSR2). . . . . . . . . . . . . . . . . . . . . . . . .. 570 4.6 Timer Status Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 572 4.7 Precautions on Cleaning the OCF .............................. , 572 5. TIMER 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 574 5.1 Timer 2 Upcounter (T2CNT) ................................... , 574 5.2 Timer Constant Register (TCONR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 575 ~HITACHI 516 5.3 Timer Control/Status Register 3 (TCSR3). . . . . . . . . . . . . . . . . . . . . . . . .. 575 5.4 Timer Status Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 576 5.5 Precaution for Toggle Pulse Function of HD6301YO/HD6303Y/HD63701YO Timer 2 .. . . . . . . . . . . . . . . . . . . . . .. 577 6. SERIAL COMMUNICATIONS INTERFACE. . . . . . . . . . . . . . . . . . . . . . . . . . .. 578 6.1 Initialization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 578 6.2 Asynchronous Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579 6.3 Clock Synchronous Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 6.4 Transmit/Receive Control Status Register (TRCSR) ................ " 582 6.5 Transmit Rate/Mode Control Register (RMCR). . . . . . . . . . . . . . . . . . . . .. 583 6.6 SCI Receiving Margin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 586 6.7 SCI Status Flags .........................'. . . . . . . . . . . . . . . . . . .. 587 6.8 Precaution for Clock-Synchronous Serial Communication Interface. . . . . 588 7. HD63701YOProgrammabie ROM (EPROM). . . . . . . . . . . . . . . . . . . . . . . . . . . 589 7.1 Programming and Verification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590 7.2 Erasing (Window Package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 591 7.3 Characteristics and Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 591 8. APPLICATIONS................................................. 593 8.1 HD6301YO in Expanded Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593 8.2 HD6301YO in Single-Chip Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594 8.3 Timer Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 594 8.4 SCI Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 598 8.5 Lowering Operating Current. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 600 8.6 Memory Ready Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 603 8.7 Halt Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 604 8.8 RD, WR Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605 8.9 LCD-II Interface Application '" . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . 605 8.10 Oscillation Circuit Board Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 606 APPENDIX I. ELECTRICAL CHARACTERISTICS. . . . . . . . . . . . . . . . . . . . . . . .. 608 APPENDIX II. INSTRUCTION EXECUTION CYCLES . . . . . . . . . . . . . . . . . . . . . . 630 ~H8TACHI 517 APPENDIX III. QUESTIONS AND ANSWERS . . . . . . . . . . . . . . . . . . . . . . . . . . .. 636 II 1.1 Parallel Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 111.2 Serial Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639 111.3 Timer/Counter..................... . . . . . . . . . . . . . . . . . . . . . . . . . . 644 111.4 Bus Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .647 111.5 Interrupt Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650 111.6 Oscillation Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653 111.7 Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653 111.8 Low Power Dissipation Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 111.9 Software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660 111.10 Others..................................................... 661 APPENDIX IV. THE DIFFERENCES BETWEEN HD63701YO AND HD6301YO... 663 APPENDIX V. PROGRAM DEVELOPMENT PROCEDURE AND SUPPORT SYSTEM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664 V.1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664 V.2 Single Chip Microcomputer ROM Ordering Procedure. . . . . . . . . . . . . . . 666 ~HITACHI 518 Section 1. Overview The HD6301YO, HD6303Y, and HD63701YO are high-performance CMOS, 8-bit, single-chip microcomputer units (MCUs) which are object-code compatible with the HD6301V. In addition to the CPU, these MPUs contain 256 bytes of RMA, a 16-bit 4-function timer, an 8-bit reloadable timer, a serial communications interface (SCI), and 53 parallel lines. The HD6301YO has 16k bytes of masked ROM. The HD6303Y has no ROM. The HD63701YO has 16k bytes of EPROM. The MPU's halt and memory ready functions enable them to release external buses and perform low-speed external memory access. The HD63701YO's programmable ROM is programmed by the same method as the standard 27256 EPROM. It is available in ceramic packages. The ceramic package with window is erasable for use in the debugging development stage. 1.1 Features The HD6301YO, HD6303Y, and HD63701YO provide the following features. o Instruction set compatible with the HD6301V1 o On-board ROM -16k bytes programmable (HD63701YO) -16k bytes masked (HD6301YO) o 256 bytes RAM o 53 parallel I/O lines -48 commori I/O lines (ports 1, 2, 3, 4, 5, 6) -5 output only lines (port 7) o Darlington transistor direct drive lines (ports 2 and 6) o 16-bit programmable timer -1 input capture register -1 free-running counter -2 output compare register o 8-bit reloadable counter I -External event counter -Square-wave generator -2 output compare registers o Serial communications interface (SCI) -Asynchronous mode/clocked synchronous mode -3 transmit formats (asynchronous mode) -6 clock sources o Memory-ready function for low-speed memory access • Halt function o Error detection function (address trap, opcode trap) o Interrupts -3 external -7 internal • MCU operation modes -Mode 1: expanded mode (internal ROM inhibited) -Mode 2: expanded mode (internal ROM valid) -Mode 3: single-chip mode • Address space up to 65k bytes .. Low power modes -Sleep mode -Standby mode • Minimum instruction time O.33JL (f = 3.0MHz) • Wide operating range -Vee = 3 to 5.5V (f = 0.1 to O.5MHz) -Vee = 5V ±10%: HD6301Y0 (f=O.1 to 1.0MHz) HD63A01Y0 (f=O.1 to 1.5MHz) HD63B01YO (f=O.1 to 2.0MHz) HD63C01Y0 (f=O.1 to 3.0MHz) ~HITACHI 519 1.2 Block Diagrams Figures 1-1, 1-2, and 1-3, are block diagrams for HD6301YO, HD6303Y, and HD63701YO, respectively. N " ,- '0 o vcc~ -len I~ cfa..w~~ ::;::;a:enZw ::; _ M VSS~ " 15" rD~ 11 !11111 '0 VSS~ ~ ::; I ...J P2olnn) ~ ~ r---- + + P2tlTout1 ) X X RD /P7o CPu P2,(SCLK) N a: w ~ 89:)9:)9:::; doa: "a:l- WR /P7, 0 I P2,(Rx) I- RNV/P7, a: 0 0 j~ P24(Tx) 0 N 0.. LlR /P7, 0.. 0.. P2s(Tout2) A BA /P74 P26(Tout3) V P2,(TCLK) I------' l4 0..0 ~ M f4- f4- I---- Do/P3o D,/P3, D,fP3, '-- I- a: D,/P3, ~ TIMER 1 0 f4- v 0.. f4- D4/ P34 I---- Ds/P3s :1 1 I-- ,--I---- D6/P36 S D,/P3, SCI f I ld 0..0 I---- f4- Ao/Plo A,/P1, J J TIMER 2 K r- --" v - f-- l- a: :--- A,/Ph A,/P13 ~L~" L 0 0.. I--- A4/P14 ~ ~ As/Pls P5o(lRQ,) - r-- A6/Pl. ~:-- CD P5,(lRO,) P5,(MR) E '0 B ,--I--- A,/Ph a: '0 " 0 '"a:I- A, "c'" A. "C:::> «m As P5.(lRQ,) A. P5,(lRO,) A, P5,(MR) P5,(HALTI A. P5.(iS) A. P5s(OS) . ",:!: A, • Au P5. '" :::> ~m P5, "c'" "C:::> A" «m A" P6. A,. P6, A15 P6, P6, P6. ce n. RAM P6s P6. 256 Bytes P6, Figure 1-2. HD6303Y Block Diagram ~HBTACHI 521 ~ ~ .. PROM Mode HITACHI 524 Table 1-1. -Pin Functions (continued) Pin No. Mode 1, Mode 2 Mode 3 PROM Mode Pin Pin Pin DP·64S FP-64 FP-64ACP·68 Name Function Name Function Name Function 25 18 17 27 P60 Port 6, bits 0-7 P60 Pori 6, bits 0-7 26 19 18 28 P61 P61 27 20 19 29 P62 P62 28 21 20 30 29 22 21 31 30 23 22 32 P65 P65 31 24 23 33 P66 P66 32 25 24 34 33 26 25 36 Vcc + 5V power supply Vcc + 5V power supply VCC + 5 V power supply 34 27 26 37 A15 Address bus, Port 4, bits 7-0 _C_E_ _ _ _ _C_h...:ip_e_n_a_b_le_ _ __ 28 27 38 bits 15-8 P46 35 EA 14 Address bus. 36 29 28 39 A13 P45 -::-EA,...1.:.:3,-_ _ bits 14-10 37 30 29 40 A12 EA12 38 31 30 41 All 39 32 31 42 AlO P42 40 33 32 43 A9 P41 DE Output enable 41 34 33 44 A8 P40 EA8 Address bus. 42 35 34 45 Vss Ground Vss Ground Vss Ground 43 36 35 46 Address bus, P17 Pori 1. bits 7-0 _E:-A,...7-,-_ _ Address bus, 8 bit 44 37 47 bits 7-0 36 A6 P16 _E_A...;6:.-_ _ bits 7-0 45 38 37 48 A5 P15 EA5 46 39 38 49 47 40 39 50 48 41 40 51 P12 EA2 49 42 41 52 Pll 50 43 42 53 AO P10 EAO 51 44 43 55 Data bus, Port 3, bits 7-0 _E-,0:-7-,-__ 0 ata bus, 52 45 44 56 bits 7-0 P36 _E__0_6::.....___ bits 7-0 D6 53 46 45 57 D5 P35 E05 54 47 46 58 55 48 47 59 56 49 48 60 D2 P32 E02 57 50 49 61 01 EOl 58 51 50 62 DO P30 EOo 59 52 51 63 BA Bus available output Pori 7, bits 4-0 60 53 52 64 LlR Load instruction register output 61 54 53 65 R/W Read/Write output 62 55 54 66 WR Write output 63 56 55 67 RD Read output P70 64 57 56 68 E External E External clock output ~ clock output ~HITACHI 525 Section 2. Internal Architecture and Operation 2.1 Operation Modes The HD6301YO and HD63701YO operate in three MCU modes. The HD6303Y only operates in MCU mode 1. The mode program pins MPo and MP 1 , and the STBY pin select the mode (table 2-1). • MCU 1 (expanded): external memory access enabled, internal ROM disabled • MCU 2 (expanded): external memory access enabled, internal ROM enabled • MCU 3 (single-chip): external memory access disabled Table ~-1. Mode Selection MP 1 MPo STBY ROM RAM Interrupt Vector Operation Mode Low High X External Internal External MCU 1 (expanded) High Low X Internal Internal Internal MCU 2 (expanded) High High X Internal Internal Internal MCU 3 (single-chip) Note: X = Don't care 2.1.1 MCU Mode 1 (Expanded) In MCU mode 1, port 3 is the data bus, port 1 is the lower address bus, and port 4 is the upper address bus. They can directly interface with HD6800 buses. Port 7 supplies signals such as RIW. See table 2-2. In mode 1, the ROM is disabled and the external address space is 65k bytes (figure 2-1). Since the HD6303Y has no internal ROM, it only operates in mode 1. ~AD ~WR A/Vii RES-" DR SfBY NMI- BA Port 2 8 I/O lines Port 3 Timer 1,2 SCI B Data Bus PortS Port 1 81/0 line<; 8 Address Bus IRQ" iRili MR. HALT is, OS Port 6 Port 4 8 va lines 8 Address Bus Figure 2-1. MCU Mode 1 2.1.2 MCU Mode 2 (Expanded) MCU mode 2 is the same as mode 1, except that the ROM is enabled. The external address space is 48k bytes (figure 2-2). I"ili WR R/W RES DR S'f8Y NMI BA Pori 2 Pori 3 a 1/0 Lines Timer 1, 2 SCI 8 Dala Bus Port 5 a I/O Lines Port! IRQ" IAQ 1 MA,HALT B Address Bus 1S,05 Pori 4 B Address Bus Figure 2-2. MCU Mode 2 ~HITACHI 526 2.1.3 MCU Mode 3 (Single-Chip) In MCU mode 3, all ports are 110 ports. There is no interface to external buses (figure 2-3). Port 7 5 Output Lines JI£ll STliV Pori 3 NMI a I/D lines Port 2 B I/O Lines Timer I, 2 SCI Port 1 Port 5 8 Output Lines 6 Input Lines nm;,1Allj MR, HAU Ill. OS Pori 6 Pori 4 B 110 Lines 8 Output Lines Figure 2-3. MCU Mode 3 Table 2-2. Port Signals Port MCU Mode 1 MCU Mode 2 MCU Mode 3 1 Address bus (Ao-A7) Address bus (Ao-A7) 110 port 2 110 port 110 port 110 port 3 Data bus (D7"Do) Data bus (D7"Do) 110 port 4 Address bus (Aa-A15) Address bus (Aa-A15) 110 port 5 I/O port 110 port 110 port 6 110 port 110 port 110 port 7 R'D, WR, RIW, LlR, BA RD, WR, RIW, LlR, BA Output port 2.2 Memory Map The HD6301Y0, HD6303Y, and HD63701Y0 can access up to 65k bytes of external memory, depending on the operating mode. Figure 2-4 shows a memory map for each mode. The first 40 locations oj each map, from $00 to $27, are reserved for the MCU's internal register area (table 2-3). MCU Mode expanded Mode Expanded Mode Single-chip Mode Model Mode 2 Mode 3 Inlerna'- $0000 Inlernal- $ O O O O _ } Inlernal Register Register Register $0027 f"''''''''='1< External $0027 External $0027 Memory Memory Space $0040 Space Internal Internal Internal RAM RAM RAM S013F 1'"'''"'''''"''1 $013F $013F External Memory Space External Memory Space Internal Internal ROM ROM SFFFF ' - -_ _JJ • Excludes the following addresses • Excludes the following addresses which may be used externally: which may be used exlemally: $00. $02. $04. $05, $06. $07. $18. $00. $02, $04. $06, $07, $18. Figure 2-4. Memory Maps ~HITACHI 527 Table 2-3. Internal Register Area Address Register R/W State at RESET 00 Port 1 data direction register W $FE 01 Port 2 data direction register W $00 02 Port 1 R/W Undefined 03 Port 2 RIW Undefined 04 Port 3 data direction register W $FE 05 Port 4 data direction register W $00 06 Port 3 RIW Undefined 07 Port 4 RIW Undefined 08 Timing control/status register 1 R/W $00 09 Free-running counter (upper byte) RIW $00 OA Free-running counter (lower byte) RIW $00 OB Output compare register 1 (upper byte) R/W $FF OC Output compare register 1 (lower byte) RIW $FF 00 Input capture register (upper byte) R $00 OE Input capture register (lower byte) R $00 OF Timer control/status register 2 RIW $10 10 Rate, mode control register RIW $CO 11 Tx/Rx control status register 1 RIW $20 12 Receive data register R $00 13 Transmit data register W $00 14 RAM/port 5 control register RIW $F8 or $78 15 Port 5 R Undefined 16 Port 6 data direction register W $00 17 Port 6 R/W Undefined 18 Port 7 RIW Undefined 19 Output capture register 2 (upper byte) R/W $FF 1A Output capture register 2 (lower byte) RIW $FF 1B Timer control/status register 3 RIW $20 1C Timer constant register W $FF 10 Timer 2 upcounter RIW $00 1E Tx/Rx control status register 2 RIW $28 1F Test register 20 Port 5 data direction register W $00 21 Port 6 control/status register RIW $07 2.3 Functional Pin Description 2.3.1 Power (Vcc, V ss) Vce, V 55 are the power supply pins. Apply + 5V ± 10% to Vee. Tie V5S to ground. 2.3.2 Clock (XTAL, EXTAL) XTAL and EXTAL connect to an AT-cut parallel resonant crystal. The chip has a divide-by-four circuit. For example, if a 4 MHz crystal. i5 used, the system clock will be 1 MHz. 528 ~HITACHI Figure 2-5 is an example of the crystal oscillator connection. The crystal and CL1 and C L2 should be located as close as possible to the XTAL and EXTAL pins. No line must cross the lines between the crystal oscillator and the XTAL and EXTAL pins. The EXTAL pin can be driven by an external clock with a 45% to 55% duty cycle. The LSI divides the external clock frequency by four. The external clock should therefore be less than four times the maximum clock frequency. When using an external clock, the XTAL pin should be left open. AT Cut Parallel Resonant Crystal Oscillator Co=7 pF max Rs=BO II max Cl1 =C L2 = 10 pF-22 pF±20% (3.2-12 MHz) EXTAL (a) Crystal Interface XTAL~N.C. EXT AL t---< External Clock (b) External Clock Figure 2-5. Recommended Crystal Oscillator Connection 2.3.3 Standby (STBV) The STBV pin puts the MCU in standby mode. When STBV is low, the oscillation stops, and the internal clock is stabilized to put the MCU in a reset condition. To retain the contents of RAM during standby, write 0 to the RAM enable bit (RAM E). RAME is bit 6 of the RAM/port 5 control register at I address $0014. RAM is disabled, and its contents are sustained. Refer to 3.5 Low Power Dissipation Mode for details on the standby mode. 2.3.4 Reset (RES) This pin resets the MCU's internal state and provides a startup procedure. The RES input must be held low for at least 20 ms during power·on. The CPU registers accumulator, index register, stack pointer, condition code register except for mask bit, RAM, and the data registers of the ports are not initialized during reset, so their contents are undefined. 2.3.5 External Clock (E) E provides a TTL·compatible system clock to external circuits. Its frequency is one-fourth that of the crystal oscillator or external clock. E can drive one TTL load and 90 pF. 2.3.6 Nonmaskable Interrupt (NMI) When CPU detects a falling edge at the NMI input, it begins the internal nonmaskable interrupt sequence. The instruction being executed when the NMI is detected will proceed to completion. The interrupt mask bit of the condition code register does not affect the nonmaskable interrupt. In response to an NMI interrupt, the contents of the program counter, index register, accumulators, and condition code register will be saved onto the stack. After they are saved, a vector is fetched from $FFFC and $FFFD to the program counter, and the nonmaskable interrupt service routine starts. Note: After reset, the stack pOinter should be initialized to an appropriate memory location before any NMI input. 2.3.7 Interrupt Requests (IRQ1' IRQ2) The interrupt requests are level-sensitive inputs which request an internal interrupt sequence from the CPU. eH1TACHI 529 2.3.8 Mode Program (MP o• MP 1) These pins determine the operation mode. Refer to 2.1 Operation Mode for details. Note: The following signals RD, WR, R/W, L1R, MR, HALT, and BA, are only used in modes 1 and 2. 2,3.9 Read/Write (R/W; P72 ) The read/write signal shows whether the MCU is in read (R/W high) or write (R/W low) state to the peripheral or memory devices. It is usually high, in read state. RIW can drive one TTL load and 30 pF. 2.3.10 Read and Write (RD; P70 ' WR; P7 1) The read and write outputs show active low outputs to peripherals or memories when the CPU is reading or writing. This enables the CPU to access LSI peripherals with RD and WR inputs easily. These pins can drive one TTL load and 30 pF. 2.3.11 Load Instruction Register (LlR; P73) The L1R output low shows that the instruction opcode is on the data bus. L1R can drive one TTL load and 30 pF. 2.3.12 Memory Ready (MR; P5 2 ) The memory ready control input lengthens the system clock's high period to allow access to low-speed memory. When MR is high, the system clock operates normally. But when MR is low, the high period will be lengthened depending on its low time in integral multiples of its cycle time. It can be lengthened up to 9 ""s. During internal address or invalid memory access, MR is prohibited internally from decreasing operation speed. Even in the halt state, MR can lengthen the high period of the system clock to allow peripheral devices to access low-speed memories. MR is also used as P5 2 . The function is chosen by the enable bit in the RAM/port 5 control register (bit 2) at $0014. See 2.5 RAM/Port 5 Control Register for details. 2.3.13 Halt (HALT; P5 3) The halt control input stops instruction execution and releases the buses. When HALT switches low, the CPU finishes the current instruction, then stops and enters the halt state. When entering the halt state, the CPU sets BA (P74 ) high, and sets the address bus, data bus, RD, WR, and R/W to high impedance. When an interrupt occurs in the halt state, the CPU cancels the halt, and executes the interrupt service routine. Note: When the CPU is in the interrupt wait state, executing the WAI instruction, HALT should be held high. If halt turns low, the CPU may fetch the incorrect vector after releasing the halt state (figure 2-6). If a halt is expected, a loop should be used instead of WAI (figure 2-7). • • · WAr "RAI.T input ~ Waiting interrupt ::: (Accept interrupt) Incorrect Vector (MSB) ( Incorrect Vector (LSB) Opcode Fetch • Fetch Vectors • Execute interrupt routine • · • Branch destination undetined (CPU burst) Figure 2:6 HALT WAI 530 ~HITACHI • • • • CLI CLI LOOP BRA WAI LOOP • • • • • Error Occurs • Recommended Example Figure 2-7. Branch Replacement for WAI 2.3.14 Bus Available (BA; P74) The bus available output control signal goes high when the CPU accepts HALT and releases the buses. It is normally low. The HD6800 and HD6802 bring BA high and release the buses at WAI execution, but the HD6301YO, HD6303Y, and HD63701YO, don't. But if HALT goes low when the CPU is in the interrupt wait state after having executed a WAI, the CPU sets BA high and releases the buses. When HALT goes high, the CPU returns to the interrupt wait state. 2.4 Ports I The HD6301YO, HD6303Y, and HD63701YO provides seven ports (six 8-bit ports and a 5-bit port). Some pins have other uses, as shown in table 2-2. Table 2-4 shows the addresses of the ports and their data direction registers. Figure 2-9 shows block diagrams of each port. Table 2-5 shows the state of each port at reset. Table 2-4. Port and Data Direction Register Address Port Port Address Data Direction Register $0002 $0000 2 $0003 $0001 3 $0006 $0004 4 $0007 $0005 5 $0015 $0020 6 $0017 $0016 7 $0018 ~HITACHI 531 Table 2-5. Port at Reset (Modes 1 and 2) Port State at Reset High 2 High impedance High impedance High (Mode 1 only) 5 High impedance 6 High impedance 7 RD, WR, RIW, LlR = High BA = Low Note: Port 4 is high impedance in Mode 2. All ports are high impedance after reset in Mode 3. 2.4.1 Port 1 Port 1 is an 8-bit I/O port (figure 2-8). The LSB of the DDR ($0000) selects the data direction of the whole port(figure 2-9). In the expanded modes (1 and 2) port 1 is the lower address bus (A7-AO). Port 1 can drive one TTL load and 90 pF capacitance. WPID Mode 1 Mode2 s ••C D RES R Q P1 DDR· !!l '" Q Dt--+--~ ~ o P1n Data (ij Mode 2 C E .'!l ---L- WPI .E RES Reset Signal RPI WPI D DDR Write Signal -L WPI Port Write Signal RPI Port Read Signal * a-bit Common Register * *Priority: Set > reset Figure 2-8. Port 1 Block Diagram ~HITACHI 532 MSB LSB ;~R 1 Pl DDR ($0000) (Write only, bit 0 is cleared during 1 1 1 1 1 1 1 1 reset.) PORT! ($0002) (R/W, not ini- 1 PI> 1 ,,·1 ,,·1 ,,·1 Ph 1 '" 1 '" 1 "0 1 tialized during reset.) Figure 2-9, Port 1 Register and Data Direction Register 2.4.2 Port 2 Port 2 is an 8-bit 1/0 port (figure 2-10), Each bit of the DDR ($0001) defines the data direction of the corresponding bit of port 2 (figure 2-11). Port 2 can drive one TTL load and 30 pF capacitance, It can produce 1 rnA when VOUT = 1.5 V to directly drive the base of a Darlington transistor. Port 2 pins are also used as 1/0 pins by timers 1, 2, and the SCI (table 2-6). The pin functions are controlled by registers in timers 1, 2, and the SCI. ~HITACHI 533 RES R Q 0 P20DDR C WP2D "'" ED .. B Q P20 Data 0 .~ C C .5 RP2 WP2 WP2D: DDR Write Signal ....L WP2: Port Write Signal RP2: Port Read Signal Tomer 1 Input Capture Input P2o/Tin R Q 0 P2.DDR C WP2D Q 0 SCI, Tomer 1, Tomer 2 P2. Data C r--------- I I WP2 I I 1-1-----------+----'L--- Output Data Output Enable Signal WP2D: DDR Write Signal WP2 : Port Write Signal RP2 : Port Read Signal P2,/Toutl, P24/Tx, P2,/Tout2, P2./Tout3 Figure 2-10, Port 2 Block Diagram ~HITACHI 534 RES P2, DDR C WP2D r---,r-...._-r-r--. Q D t----j--i SCI P2, Data ..---------- C WP2 '--j------,----Clock Input Enable Signal 'L-f------------+-----;---- Output Clock ----------+-----t---- Clock Output Enable L -..... Signal RP2 r-~-~-Input Clock --L WP2D: DDR Write Signal WP2: Port Write Signal RP2: Port Read Signal P2,/SCLK RES r-------------~Q 1------------1 Q Rl P2" DDR WP2D C R2 o I----!---; 00 0 1------1--; ~ CD ~ o "iii ~ E I SCI, Timer 2 P2" Data ,---------- I C I I WP2 L-l------7---- Input Enable signal r-+---e~SCI Receive Data, Timer 2 External Clock WP2D: DDR Write Signal WP2: Port Write Signal RP2: Port Read Signal P2,/Rx, P2,/TCLK Figure 2-10. Port 2 Block Diagram (Cont) ~HITACHI 535 P2DDR ($0001) (Write only, $00 during reset.) PORT2 ($0003) P27 P26 P25 P24 P23 P22 P21 P20 (R/W, not initialized during reset.) Figure 2-11. Port 2 Register and Data Direction Register Table 2-6. Port 2 Pin Functions Port 2 Pin Alternate Function Description P20 Tin Timer 1 input P21 Tout1 Timer 1 output 1 P22 SCLK SCI clock P23 Rx SCI receive input P24 Tx SCI transmit output P25 Tout2 Timer 1 output 2 P26 Tout3 Timer 2 output 3 P27 TCLK Timer 2 clock ~HITACHI 536 2.4.3 Port 3 Port 3 is an 8-bit 1/0 port (figure 2-12). The LSB of the DDR ($0004) selects the data direction of the whole port (figure 2-13). In the expanded modes (1 and 2) port 3 is the lower data bus (D7-DO). Port 3 can drive one TTL load and 90 pF capacitance. WP3D RES Mode3 D Mode 1 Mode 2 DI-4---4 P3" Data e Mode 1 More 2 WP3 WP3D: DDR Write Signal WP3: Port Write Signal RP3: Port Read Signal * a-Bit Common Register Figure 2-12. Port 3 Block Diagram MSB LSB P3DDR ($0004) (Write only. bit 0 I I I I I I I I;;, I is cleared during reset.) I~I~I~I~I~I~I~I~I PORT3 ($0006) (R/W. not ini· tialized during reset.) Figure 2-13. Port 3 Register and Data Direction Register ~HITACHI 537 2.4.4 Port 4 Port 4 is an a-bit I/O port (figure 2-14). Each bit of the DDR ($0005) defines the data direction of the corresponding bit of port 4 (figure 2-15). In the expanded modes (1 and 2), port 4 is the upper address bus (A15-Aa). In mode 1 (expanded mode with no external ROM), the DDR is set automatically and port 4 outputs addresses. In mode 2 (expanded mode with external ROM), the DDR must be set to 1 for port 4 to function as the address bus. Pins that are not needed for the address bus can be used as input pins. Port 4 can drive one TTL load and 90 pF capacitance. Model RES S· R Q 0 en !! P4, DDR ID " ID c ; 0 ::! ~ "0 Mode3 WP4D ] "0 <{ -L- ~ '1ii E Q 0 ~ .E P4, Data ~ 0. C 0. ::> Mode 1 Mode2 WP4 -L- RP4 ---L WP4D: DDR Write Signal WP4: Port Write Signal * Priority: set> reset RP4: Port Read Signal Figure 2-14. Port 4 Block Diagram P4DDR ($0005) (Write only, $00 during reset.) PORT4 ($0007) P46 P45 P44 P40 (R/W, not initialized during reset.) Figure 2-15. Port 4 Register and Data Direction Register ~HITACHI 538 2.4.5 Port 5 Port 5 is an 8-bit I/O port (figure 2-16). Each bit of the DDR ($0020) defines the data direction of the corresponding bit of port 5 (figure 2-21). Port 5 can drive one TTL load and 30 pF capacitance. P5s-P5 0 are also used as control pins (table 2-7). The function of these pins is determined by the RAM/port 5 control register (RP5CR), except for P5 4/IS and P5s/0S, which are controlled by the port 6 control/status register (P6CSR). P55-P50 are also used as control pins (table 2-7). The function of these pins is determined by the RAM/port 5 control register (RP5CR), except for P541IS and P55/0S, which are controlled by the port 6 control/status register (P6CSR). RES R, R2 Q D P5. DDR C WP5D WP5D: DDR Write Signal WP5: Port Write Signal Q D RP5: Port Read Signal P5. Data C RP5 WP5 * RAM/Port -L- 5 Control Register IRQ, )--_ _ _... IRa. ~ __________-+____ ~~/ MR HALT *Value after reset; IRQ' E=O. IRQ2E=O. MRE=O". HLTE='" * * P52 and P5, can be used as I/O ports in spite of the value of this register in Mode 3. P5o!lmIi. P51/'Ilm2. P52/MR. P5,/HALT RES R .-------10 0/----+ P5. DDR C WP50 ~ /-----10 Dr---~ iij 0 WP5D: DDR Write Signal P5. Data E WP5: Port Write Signal C ~ RP5: Port Read Signal WP5 >---,'"::s--------+---- Port 6 Control Status Register P5./fS Figure 2-16. Port 5 Block Diagram ~IHIHTACHO 539 RES ! III P5.DDR C C .. S WP5D: DDR Write Signal WP5: Port Write Signal co RP5: Port Read Signal WP5D E l!l Q 0 .5 P5. Data Port 6 Control/Status Registar C WP5 r--------- I I I OS aSE C0::OS OS output output disable ) RP5 -L- P5.IOS RES R Q 0 P5,DDR C ! III Q WP5D 0 c .. S P5, Data co E C l!l .5 WP5 WP5D: DDR Write Signal RP5 WP5 : Port Write Signal ~ RP5: Port Read Signal P5" P5, Figure 2-16, Port 5 Block Diagram (Cont) ~HITACHI 540 2.4.6 Port 6 Port 6 is an 8-bit 1/0 port (figure 2-17). Each bit of the DDR ($0016) defines the data direction of the corresponding. bit of port 6 (figure 2-18). Port 5 can drive one TTL load and 30 pF capacitance. In addition, it can drive the base of Darlington transistors directly. Port 6 can function as a parallel handshake interface under the control of the port 6 controll status register (P6CSR: $0021). Port 6 has a data latch for input data (is LATCH). RES R r-------l0 0 1 - - - -.. !g P6,OOR CD C ~ o WP60 m E /------10 0 / - - - -... ~ P6, Data C WP6 RES WP6D: DDR Write Signal RP6 WP6: Port Write Signal R -L RP6: Port Read Signal o 0 IS Latch C Port 6 L.--------------Control/Status Register Figure 2-17. Port 6 Block Diagram I P60DR ($0016) (Write only, $00 during reset.) I I I I ,~ I I I I I PORT6 ($0017) (R/W, not ini· P6, eG, eG, P6, P6, P6, P6, tialized during reset.) Figure 2-18. Port 6 Register and Data Direction Register ~HITACHI 541 2.4.7 Port 7 Port 7 is a 5-bit output only port (figures 2-19, 2-20). In the expanded modes (1 and 2), port 7 outputs control signals from the CPU. Port 7 goes to high-impedance state during reset. Port 7 can drive one TTL load and 30 pF capacitance. RE5 R Q WP7 5, Mode 1. Mode 2 52 !!I Mode 3 III ----L- ; Q P7, Data 0 1----+---+ c .. E C ~ WP7: Pon Write Signal WP7 RP7: Pon Read Signal RP7 --L Mode 1 Mode 2 ---L ' - - - - - - - - - - - - - / - + - - - ~rs~fontrol • Priority: S2>R. 5, Figure 2-19. Port 7 Block Diagram MSB LSB PORT7: $0018 P70 (R/W. not deter· mined during rese!.) Figure 2-20. Port 7 Register ~HITACHI 542 2.5 RAM/Port 5 Control Register The RAM port 5 control register (RP5CR:$0014) controls onchip RAM and port 5 (figure 2-22). 2.5.1 IRQ1 E, IRQ2E Setting IRQ1 E and IRQ2E to 1 selects P50 and P51 as the IRQ1 and IRQ2 interrupt inputs. These bits are cleared at reset. 2.5.2 MRE, AMRE When MRE or AMRE is set to 1. P52 becomes the MR input. When both are 0, memory ready is inhibited (table 2-8). In mode 3, memory ready is always inhibited, regardless of these bits. MRE is cleared at reset. AMRE is set to 1. 2.5.3 HLTE When HLTE is set to 1, P53 becomes the HALT input. When 0, HALT is inhibited. In mode 3, HALT is always inhibited, regardless of HLTE. This bit is set to 1 at reset. 2.5.4 STBY FLAG Clearing STBY FLAG by software puts the MCU into standby mode. This flag is set to 1 at reset, so reset cancels the standby mode. If the STBY pin is low, this flag cannot be cleared. 2.5.5 RAME When RAME is set to 1, on-chip RAM is enabled. When 0, it is disabled. RAME is set to 1 at reset. This bit should be set to a before going into standby state to protect on-chip RAM data. 2.5.6 STBY PWR When Vcc is not provided in standby mode, STBY PWR is cleared. If STBY PWR is set before the MCU goes to standby, and remains set after standby Vcc was continuously supplied, and the contents of on-chip RAM are valid. ~HITACHR 543 MSB LSB P5DDR ($0020) P57 P5G P55 P54 P53 P52 P51 P50 (Write only, $00 DDR DDR DDR DDR DDR DDR DDR DDR during reset.) PORT5 ($0015) P55 P54 P50 (R/W, not initialized during reset.) Figure 2-21, Port 5 Register and Data Direction Register Table 2-7. Port 5 Pin Functions Port 5 Pin Alternate Function Description P50 IRQ1 Interrupt input 1 P51 IRQ2 Interrupt input 2 P52 MR Memory ready input P53 HALT Halt input P54 IS Input Strobe P55 OS Output strobe RAM/Port 5 Control Register (RP5CR) 7 6 5 4 3 2 o ~~: I RAME I i~:~ I AMRE I HLTE I MRE I IR~2 I IR~I I $0014 I. IRQI Enable 0-P50 is an I/O port I-P50 is IRQI IRQ2 Enable 0-P51 is an I/O port I-P51 is IRQ2 MR Enable O-Memory ready disa bled I-P52 is MR, memory ready function enabled HALT Enable 0-P53 is an I/O port I-P53 is HALT input Auto Memory Ready Enable O-Automatic memory ready disabled I-P52 is MR, auto memory ready enabled Standby Flag O-Setting this flag to 0 puts MCU in standby mode I-STBY FLAG is set to I by reset, releasing standby mode RAM Enable O-On·chip RAM disabled I-On·chip RAM enabled ~~~f>ower O-Vee has not been provided during standby mode I-Vee has been provided in standby mode Figure 2-22. RAM/Port 5 Control Register ~HITACHI 544 Table 2-8. Memory Ready Function MRE AMRE Function o 0 Memory ready inhibited. o Auto memory ready. When the CPU accesses the external address regardless of MR, E clock automatically stays high one-cycle longer. This state is retained during reset. o Memory ready. MR pin controls E clock high time. When the CPU accesses the external address space with the P52 (MR) pin low the auto memory ready operates. This function useful if there is both high-speed memory and slow memory outside. Input CS signal of slow memory to MR pin. ~HITACHD 545 2.6 Port 6 Control/Status Register The port 6 control/status register (P6CSR: $0021) controls and holds the status of the port 6 handshake interface (figure 2-23). The handshake interface functions as follows. • Latches the data input at port 6 on the falling edge of IS (P54). • Outputs as (P55) when reading or writing to port 6. • When IS FLAG is set by the falling edge of IS, an interrupt occurs (figure 2-24). 2.6.1 LATCH ENABLE The LATCH ENABLE bit controls the port 6 input latch (IS LATCH). When it is set, the input data at port 6 will be latched in at the falling edge of IS (P54). Reading port 6 clears the latch. If LATCH ENABLE is 0, the input latch is disabled, and P54 acts as an ordinary I/O port. LATCH ENABLE is cleared at reset. 2.6.20SS When ass is set, writing to port 6 initiates an output strobe signal (OS/P55). When ass is cleared, reading port 6 initiates an as. ass is cleared at reset. 2.6.30SE When OSE is set, P55 is the output strobe, as. When cleared, it is a normal I/O port. 2.6.4 IS IRQ1 ENABLE When IS IRQ1 ENABLE is set, IS FLAG set causes an IRQ1 interrupt. When cleared, IS FLAG does not cause an interrupt. This bit is cleared during reset. 2.6.5 IS FLAG The IS FLAG is set by the falling edge of IS. It is a read-only flag. It is cleared by reading or writing to port 6 after reading the P6CSR. IS FLAG is cleared during reset. Table 2-9 shows the conditions that set and reset the port 6 control/status register flags. ~HITACHI 546 o $0021 Latch Enable O-Port 6 latch disabled I-Port 6 input la tched by IS Output Strobe Select 0-05 output on port 6 read 1-05 output on port 6 write Output Strobe Enable 0-P55 is I/O port l-P55 is output strobe (OS) Input Strobe Interrupt Enable O-Interrupt on IS FLAG inhibited l-fRQ! interrupt on IS FLAG enabled Input Strobe Flag O-No IS I-IS falling edge detected Figure 2-23. Port 6 Control/Status Register HD63D1YO Port 6 Control/Status Register ) - - - - - - 1 : > iAQ, Figure 2-24. Input Strobe Interrupt Block Diagram Table 2-9. Port 6 Control Status Register Status Flags Set and Reset Conditions Flag Set Condition Clear Condition IS FLAG Falling edge input to P54 (IS) Read the P6CSR then read or write the port 6, when IS FLAG = 1 RES = 0 ICF FRC - ICR by rising or falling Read the TCSR1 or TCSR2 then ICRH, edge input to P20. (Selected by when ICF = 1 IEDG) RES = 0 ~HITACHB 547 Section 3. CPU Function 3.1 CPU Registers The CPU has three 16-bit registers and three 8-bit registers (figure 3-1). 7 0 7 0 ~ ____ ! _____ U_____ ~ ____ 18-Bit Accumulators A and B D Or 16-Bit Double Accumulator D 15 0 15 0 I X I Index Register (X) 15 0 I SP IStack Pointer (SP) 15 0 I PC I Program Counter (PC) 7 0 11 11 I H II I N I Z Iv-Tcl Condition Code Register (CCR) ~ Carry/Borrow from MSB Over flow Zero Negative Interrupt Half Carry (From Bit 3) Figure 3-1. CPU Registers 3.1.1 Accumulators (ACCA, ACCe, ACCD) Two 8-bit accumulators, ACCA and ACCS, store the result of arithmetic/logic operations and data. When combined, these make up the 16-bit accumulator ACCD used for 16-bit operations. Note that the contents of ACCA and ACCS are destroyed by an ACCD operation. 3.1.2 Index Register (IX) The 16-bit register IX stores 16-bit data for use in indexed addressing or for general purposes. 3.1.3 Stack Pointer (SP) The contents of the16-bit register SP indicate the address of a stack. SP can also be used as a general-purpose register. 3.1.4 Program Counter (PC) The contents of the 16-bit PC indicate the address of the instruction being executed. Note that software cannot access this register. ~HITACHI 548 3.1.5 Condition Code Register (CCR) The CCR register consists of the carry (C), overflow (V), zero (Z), negative (N), interrupt mask (I), and half-carry (H) bits. After an instruction is executed, the CCR bits change state depending on the result of the operation. They can be tested by conditional branch instructions. The upper two bits of this register are not used. Half-Carry (H):H is set to 1 if a carry at bit 3 or bit 4 occurs during an ADD, ABA, or ADC instruction. It is cleared if no carry occurs. Interrupt Mask (I):When I is set to 1, it disables all maskable interrupts (IRQ1' IRQ2, and IRQ3)' Negative (N): N is set to 1 if the MSB of the result of an operation is 1. N is cleared if it is O. Zero (Z): Z is set to 1 if the result of an operation is zero. Z is cleared if it is not zero. Overflow (V): V is set to 1 if the result of an operation shows a two's complement overflow. It is cleared if there is no overflow. Carry (C): C is set to 1 if a carry or borrow is generated from the MSB. If there is no carry or borrow, it is cleared. 3.2 Addressing Modes The HD6301YO, HD6303Y and HD63701YO instructions have seven addressing modes. I 3.2.1 Accumulator Addressing (ACCX) The instruction addresses an accumulator and ACCA or ACCB is selected. Accumulator addressing instructions take one byte. 3.2.2 Immediate Addressing Immediate addressing places the data in the second byte of an instruction, except LDS and LDX, which use the second and third bytes. An immediate instruction causes the CPU to address this operand. Immediate instructions take 2 or 3 bytes. 3.2.3 Direct Addressing In direct addressing, the second byte of an instruction holds the address where the data is stored. 256 ~HITACHI 549 bytes ($OO-$FF) can be addressed directly. Storing data in this area reduces instruction time, so configuring $OO-$FF as user's RAM is recommended. Direct addressing instructions take 2 bytes, or 3 bytes for AIM, OIM, ElM, orTIM. 3.2.4 Extended Addressing In extended addressing, the second byte of an instruction holds the upper eight bits of the absolute address of the stored data, and the third byte holds the lower eight bits. Extended addressing instructions take 3 bytes. 3.2.5 Indexed Addressing In indexed addressing, the second byte of the instruction (third byte for AIM, OIM, ElM, or TIM instructions) is added to the lower eight bits of the index register. The carry is added 10 the upper eight bits of the index register, and the 16-bit sum is the memory location of the data. The modified address is held in the temporary address register, so the index register doesn't change., Indexed addressing instructions take 2 bytes, or 3 bytes for AIM, OIM, ElM, or TIM. 3.2.6 Implied Addressing In implied addressing, the instruction itself specifies the address. For example, the instruction addresses the stack pointer or index register. Implied addressing instructions take 1 byte. 3.2.7 Relative Addressing In relative addressing, the second byte of the instruction and the lower eight bits of the program counter are added. The carry or borrow is added to the upper eight bits of the program counter. Locations from -126 to +129 bytes from the current location can be addressed. Relative addressing instructions take 2 bytes. 550 3.3 Instruction Set The HD6301YO, HD6303Y, and HD63701YO are object-code upwardly compatible with the HD6801 to use all instructions of the HMCS6800. The instruction time of key instructions has been reduced improving throughput. 3.3.1 Additional Instructions Bit manipulation, index register and accumulator exchange, and sleep instructions have also been added to the HD6801 instruction set. AIM, OIM, EOM, and TIM are 3 byte instructions. The first byte is the opcode, second byte is the immediate data, and the third byte is the address modifier. AIM: ANDs the immediate data with the memory contents and stores the result in memory. (M) AND (IMM) -. (M). OIM; ORs the immediate data with the memory contents and stores the result in memory. (M) OR (IMM) -. (M). ElM: EORs the immediate data with the memory contents and stores the result in memory. (M) EOR (IMM) -. (M). I TIM: ANDs the immediate data with the memory contents and changes the related flag in the condition code register. (M) AND (IMM). XGDX: Exchanges the contents of the accumulator with the contents of the index register. (ACCD) .-, (IX). SLP: Puts the MCU into sleep mode. Refer to 3.5 Low Power Dissipation Mode for details. 3.3.2 Instruction Set Summary Tables 3-1 to 3-5 summarize the instruction set. Accumulator and memory manipulation instructions: table 3-1 • Index register and stack manipulation instructions: table 3-2 • Jump and branch instructions: table 3-3 • Condition code register manipulation: table 3-4 • Opcode map: table 3-5 ~HITACHI 551 Table 3-1. Accumulator and Memory Manipulation Instructions Condition Code Addressing Modes Register IMMED DIRECT INDEX EXTEND IMPLIED Boolean/ 5 4 3 2 I 0 Operations Mnemonic OP - g OP - # OP - # OP - # OP - # ArithmetiC Operation H I N Z V C Add ADDA 8B 2 2 9B 3 2 AB 4 2 BB 4 3 A+M~A : • 1 : : : AD DB CB 2 2 DB 3 2 EB 4 2 FB 4 3 B+M--B : • ; 1 : : Add Double AD DO C3 3 3 03 4 2 E3 5 2 F3 5 3 A:B+M:M+I~ A:B • • 1 I ; : Add Accumulators ABA IB I I A+B~A : • : : ; : Add With Carry ADCA 89 2 2 99 3 2 A9 4 2 B9 4 3 A+M+C~A : • : : ; ADCB C9 2 2 09 3 2 E9 4 2 F9 4 3 B+M+C~B 1 • 1 1 : ; AND ANDA B4 2 2 94 3 2 A4 4 2 B4 4 3 A'M~B • • 1 I R • ANDB C4 2 2 04 3 2 E4 4 2 F4 4 3 B·M~B • • I ; R • Bit Test BIT A B5 2 2 95 3 2 A5 4 2 B5 4 3 A·M • • : ; R • BIT B C5 2 2 05 3 2 E5 4 2 F5 4 3 B·M • • : 1 R • Clear CLR 6F 5 2 7F 5 3 OO~M • • R 5 R R CLRA 4F I I OO~A • • R 5 R R CLRB 5F I I OO~B • • 5 R R 0 Compare CMPA 81 2 2 91 3 2 Al 4 2 BI 4 3 A-M • • : I : : CMPB CI 2 2 01 3 2 EI 4 2 FI 4 3 B-M • • I I r : Compare Accumulators CBA II I I A-B • • 1 : I j Complement. l' s COM 63 6 2 73 6 3 M~M • • I : R 5 COMA 43 I I A~A • • I I R 5 COMB 53 I I B~B • • 1 1 R 5 Complement, 2'5 NEG 60 6 2 70 6 3 OO-M~M • • 1 I ct ;g; (Negate) NEGA 40 I I OO-A~A • • i 1 CD ~ NEGB 50 I I OO-B~B • • I I ffi ~ Converts binary Decimal Adjust, A DAA 19 2 I add of BCD char· acters into BCD format • • I I I @ Decrement DEC 6A 6 2 7A 6 3 M-I~M • • I I @ • DECA 4A I I A-I~A • • I I @J • DECB SA I I B-I~B • • I I @J • Exclusive OR EORA B8 2 2 9B 3 2 AB 4 2 BB 4 3 AEBM~A • • 1 I R • EORB CB 2 2 08 3 2 E8 4 2 F8 4 3 BEBM~B • • I I R • Increment INC 6C 6 2 7C 6 3 M+I~M • • I I @ • INCA 4C I I A+I~A • • I I @ • INC8 5C I I 8+1~8 • • I I @ • load Accumulator LDAA 86 2 2 96 3 2 A6 4 2 B6 4 3 M~A • • I I R • Load Double LDAB C6 2 2 06 3 2 E6 4 2 F6 4 3 M~8 • • I I R • Accumulator LDD CC 3 3 DC 4 2 EC 5 2 FC 5 3 M+I-B.M~A • • I I R • Multiply Unsigned MUL 3D 7 I AX8~A:8 • • • • •@ OR,lnclusive ORAA 8A 2 2 9A 3 2 AA 4 2 BA 4 3 A+M-A • • I I R • ORAB CA 2 2 DA 3 2 EA 4 2 FA 4 3 s+M-B • • I I R • Push Data PSHA 36 4 I A-Msp. SP-I~SP • • • • • • PSHB 37 4 I B-Msp. SP-I~SP • • • • • • Note: Condition Code Register will be explained in Note of table 3-4. ~HITACHI 552 Table 3-1. Accumulator and Memory Manipulation Instructions (Cont.) Condition Code Addressing Modes Register I DIRECT IMMED INDEX EXTEND IMPLIED 8001ean/ 5 4 3 2 1 0 Operations MnemonIc OP - # OP - # OP - # OP - # OP - # Arlthmettc Operation H I N Z V C Pull Data PULA 32 3 1 SP+l-SP. Msp-A • • • • • • PULB 33 3 1 SP+l-SP. Msp-B • • • • • • Rotate Left ROL 69 6 2 79 6 3 • • I I (6) I ROLA 49 1 1 '1 • • I I (Q) I ROLB 59 1 1 • • I I @ I Rotate Right ROR 66 6 2 76 6 3 • • I I '@ I RORA 46 1 1 '2 • • I I \:Ql I RORB 56 1 1 • • I : '@ r Shilt Left ASL 68 6 2 78 6 3 0 0 I I f§) I Arithmetic ASLA 48 1 1 '3 • • r J ,6) J ASLB 08 1 1 • 0 : I 'lll I Double Shift ,§) ASLD 05 I I '4 0 0 I I I Left, Arithmetic Shift Right ASR 67 6 2 77 6 3 0 0 I r ~l?) r Arithmetic ASRA 47 1 1 ·s 0 0 J I @ I ASRB 57 1 1 0 0 I J @ I Shift Right Logical LSR 64 6 2 74 6 3 • • R J @ I LSRA 44 1 1 '6 0 0 R J @ J LSRB 54 1 1 0 0 R I @ J Double Shift Right Logical LSRD 04 1 1 '7 • 0 R I @ I Store STAA 97 3 2 A7 4 2 B7 4 3 A-M • • J I R • Accumulator STAB D7 3 2 E7 4 2 F7 4 3 8-M • • , I R 0 Store Double A-M Accumulator STD DD 4 2 ED 5 2 FD 5 3 8-M+l • • I I R • Subtract SU8A 80 2 2 90 3 2 AD 4 2 80 4 3 A-M-A • • I I J I SU88 CO 2 2 DO 3 2 EO 4 2 FO 4 3 8-M-B 0 0 I I J I A: 8-M: M+l- Double Subtract SU8D 83 3 3 93 4 2 A3 5 2 B3 5 3 A:8 0 0 I I I I Subtract Accumulators S8A 10 1 1 A-8-A • 0 r J I I Sabtract SBCA 82 2 2 92 3 2 A2 4 2 82 4 3 A-M-C-A • • I I I I • . I With Carry S8CB C2 2 2 D2 3 2 £2 4 2 F2 4 3 8-M-C-8 I I I Transfer Accumulators TAB 16 1 1 A-8 • • I I R 0 T8A 17 I I 8-·A 0 • I I R • Test Zero or Minus TST 6D 4 2 7D 4 3 M-OO • • I I R R TSTA 4D 1 1 A-DO • • I I R R TSTB 5D 1 1 B-OO • • I I R R And Immediate AIM 71 6 3 61 7 3 M·IMM-M • • J I • R OR Immediate OIM 72 6 3 62 7 3 M+IMM-M • • I I R • EOR Immediate ElM 75 6 3 65 7 3 ME!lIMM-M • • I : R • Test Immediate TIM 78 4 3 68 5 3 M·IMM • •------ J I R -- 0 Alo-a - M l ~, '1 '2 M '3 I~ M A B C b7 bO A B 11cH I C b7 IrJ bO 8 C b7 I 1--0 ....L.....L.....L...L..-'-.L..:'bO ~ Io---l I I I I I I I ~ '4 ·s Q-j ~1C?1 I I I I I I f-{] Ace A / Ace 8 1-0 C A7 AO 87 80 '6 8 b7 bO C B b7 bO '7 0--1 A7 ACC A / AO ,87 Ace 8 80 1-0 C ~HITACHI 553 Table 3-2. Index Register and Stack Manipulation Instructions Condition Code Addressing Modes Register IMMED DIRECT INDEX EXTEND IMPLIED 5 4 3 2 1 0 -, -, -, Boolean/ - , - Pointer Operations Mnemonic OP OP I OP OP OP Arilhmelic Operation H I N Z V C Compare Index Reg CPX 8C 3 3 9C 4 2 AC 5 2 BC 5 3 X-M:Mtl • • I I I I Decrement Index Reg DEX 09 1 1 X-I-X • • • I • • Decremenl Stack Pntr DES 34 1 1 SP-l-'SP • • • • • • Increment Index Reg INX 08 1 1 Xtl··X • • • I • • Increment Stack Pntr INS 31 1 1 SPtl-'SP • • • • • • Load Index Reg LDX CE 3 3 DE 4 2 EE 5 2 FE 5 3 M"'XH, (Mtll,·XL • • CZ> I R • Load Stack Pntr LOS 8E 3 3 9E 4 2 AE 5 2 BE 5 3 M"SPH, (Mtll-SPL • • CZ> I R • Xw-M, Store Index Reg STX DF 4 2 EF 5 2 FF 5 3 XL-(Mtll • • CZ> I R • SPH-M, Store Stack Pntr STS 9F 4 2 AF 5 2 BF 5 3 SPL-(Mtll • • CZ> I R • Index Reg - Stack Pntr TXS 35 1 1 X-I-SP • • • • • • Stack Pntr-Index Reg TSX 30 1 1 SPtl-X • • • • • • Add ABX 3A 1 1 BtX-X • • • • • • XL "Msp, SP I-SP Push Data PSHX 3C 5 1 XH-Msp.SP-l-·SP • • • • • • SPt 1 -SP, MSp-XH Pull Data PULX 38 4 1 SPtl-SP,MsP-XL • • • • • • Exchange XGDX 18 2 1 ACCD-IX • • • • • • Note: Condition Code Register will be explained In Note of table 3-4. ~HITACHI 554 Table 3-3. Jump and Branch Instructions Condition Code Addressing Modes Register RELATIVE DIRECT INDEX EXTEND IMPLIED 5 4 3 2 I 0 Op-".tions Mnemonic OP -, op - , - , -, op OP OP - , Branch Test H I N Z V C Branch Always BRA 20 3 2 None • • • • • • Branch Never BRN 21 3 2 None • • • • • • Branch if Carry Clear BCC 24 3 2 C=O • • • • • • Branch if Carry Set BCS 25 3 2 C=I • • • • • • Branch if=Zero BEQ 27 3 2 Z=I • • • • • • Branch if?;Zero BGE 2C 3 2 NE!ON=O • • • • • • Branch if> Zero BGT 2E 3 2 Z+ (NEElY) =0 • • • • • • Branch if Higher BHI 22 3 2 C+Z=O • • • • • • Branch if~Zero BLE 2F 3 2 Z+ (NElON) =1 • • • • • • Branch if Lower Or Same BLS 23 3 2 C+Z=I • • • • • • Branch if < Zero BLT 20 3 2 NEfJV=1 • • • • • • Branch if Minus BMI 2B 3 2 N=I • • • • • • Branch if Not Equal Zero BNE 26 3 2 Z=O • • • • • • Branch if Overflow Clear BVC 28 3 2 V=O • • • • • • 8ranch if Overflow Set BVS 29 3 2 V=I • • • • • • Branch if Plus BPL 2A 3 2 N=O • • • • • • Branch To Subroutine BSR 80 5 2 • • • • • • Jump JMP 6E 3 2 7E 3 3 - • --• • • • • Jump To Subroutine JSR 90 5 2 AD 5 2 BD 6 3 • • • • • • Advances Prog. No Operation Nap 01 I I Cntr. Only • • • • • • Relurn From Inlerrupt RTI 3B 10 I --@-- Return From Subroutine RTS 39 5 I • • • • • • Software Interrupt SWI 3F 12 I • S • • • • Wait for Interrupt· WAI 3E 9 ) • (9J • • • • Sleep SLP IA 4 I • • • • • • Note: • WAI puts R/W high; Address Bus goes to FFFF; Data Bus goes to the three state. Condition Code Register will be explained in Note of table 3-4. ~HITACHI 555 Table 3-4. Condition Code Register Manipulation Instructions Addressing Modes Condition Code Register Implied 5 4 3 2 1 0 Operations Mnemonic OP - # Boolean Operation H I N Z V C Clear Carry ClC OC 1 1 O-C • • • • • R Clear Interrupt Mask CLI OE 1 1 0-1 • R • • • • Clear Overflow ClV OA 1 1 O-V • • • • R • Sat Carry SEC 00 1 1 1-C • • • • • S Set Interrupt Mask SEI OF 1 1 1-1 • S • • • • Set Overflow Accumulator A-CCR SEV OB 1 1 1-V A-CCR • • • • S • TAP 06 1 1 --@J-- CCR-Accumulator A TPA 07 1 1 CCR-A • • • • • • Legend Condition Code Symbols OP Operation Code (Hexadecimal) H Half-carry from bit 3 to bit 4 Number of MCU Cycles I Interrupt mask Msp Contents of memory location pOinted to by Stack Pointer N Negative (sign bit) # Number of Program Bytes Z Zero (byte) + Arithmetic Plus V Overflow, 2's complement Arithmetic Minus C Carry/Borrow from/to bit 7 • Boolean AND R Reset Always + Boolean Inclusive OR S Set Always E9 Boolean Exclusive OR 1 Set if true after test or clear M Complement of M • Not Affected Transfer into a Bit = Zero 00 Byte = Zero Note: Condition Code Register Notes: (Bit set if test is true and cleared otherwise) CD (Bit V) Test: Result = 10000000? (2) (Bit C) Test: Result = OOOOOOOO? CIl (Bit C) Test: BCD Character of high-order byte greater than 10? (Not cleared if previously set) ® (Bit V) Test: Operand = 10000000 prior to execution? ® (Bit V) Test: Operand = 01111111 prior to execution? '® (Bit V) Test: Set equal to N + C = 1 after the execution of instructions rJ) (Bit N) Test: Result less than zero? (Bit 15= 1) ® (All Bit) load condition code register from stack. ® (Bit I) Set when interrupt occurs. If previous set, a non-maskable interrupt is required to exist the wait state. 19 (AI Bit) Set according to the contents of accumulator A. Ij]) (Bit C) Result of multiplication bit 7= 1? (ACCB) Table 3-5. Memory Map XT ~ OP ACC ACC ACCA or SP ACCB or X INO ~-~-'--'---r--r~~~~~~ CODE A B DIR' IMM DIR IND EXT IMM OIR IND EXT 0000 0001 0010 0011 0100 alaI OlIO alII 1000 1001 lOla lOll 1100 1101 lila 1111 3 4 6 8 A B C o 0000 0 / SBA BRA TSX NEG SUB a 0001 I NOP CBA BRN INS ______ AIM CMP I 0010 2 L L BHI PULA __________ DIM SBC 2 0011 3 ~L BLS PULB COM SUBD, AOOD 3 0100 4 LSRO L:::::: BCC DES LSR AND 4 0101 5 ASLD / BCS TXS _______ I ElM BIT 5 OlIO 6 TAP TAB BNE PSHA ROR LOA 6 0111 7 TPA TBA BEQ PSHB ASR / ! STA 1/ i STA 7 1000 8 INX XGDX BVC PULX ASL EOR 8 1001 9 DEX OAA BVS RTS ROL ADC 9 lOla A CLV SLP BPL ABX DEC ORA A lOll B SEV ABA BMI RTI _______, TIM AOD B ~~II~O~O-+~C-+~C~L~C~~~~~B~G~E~'-P~S~H-X~~-----INLC--------~------c~p~x~------rl------~L~O~D~-------~I ~-II-O-I-+--D-+-S-E-C~L~~-B-L-T1-M-U~L-+-------=TS~T~------~B~SR~----~JS~R~-~i~--~r:-----S-T-D--- I 0 lila E CLI / BGT WAI ------I JMP LOS I LOX I E 1 1111 F SEI / BLE SWI I CLR 1/1 STS ~, STX L.::.0--.l--=I__L.::.2J--=3__L 4__-LI--=5__!L6~-L1__7---.-J:L8~ll__9---1,__A D~__E_---,--F_j .L__ B---1i__C__ i __l!'__ IZI UNDEFINED OP CODE • Only AIM, OIM, ElM, TIM instructions ~HITACHI 556 3.4 CPU Instruction Flow When operating, the CPU fetches an instruction from memory and executes the required function. This sequence starts from RES high, and repeats itself continuously if not affected by a special instruction or control signal. SWI, RTI, WAI, and SLP instructions change this operation, and NMI,IR01, IR02, IR03, HALT, and STBY control it. Figure 3-2 shows the CPU mode transitions, and figure 3-3 is the CPU system flowchart. Table 3-6 shows the CPU operating states and port states. Figure 3·2. CPU Operation Mode Transitions ~HITACHI 557 (J1 (J1 (Xl PC-1 pc., v:~~~o~~~~ STACK PC, IX ACCA Acee CCR Notes; 1. The program sequence will come to the RES start from any place of the flow during RES. When STBY=O, the sequence will go into the standby mode regardless of the CPU condition. 2. Refer to 3.8 Interrupts for more details of interrupts. ~ :I ~ (') :I N Figure 3-3. System Flowchart Table 3-6. CPU Operating States and Port States Port Mo~e Reset Standby3 Halt4 Sleep 1 (AO-A7) 1,2 High High impedance High impedance High 3 High impedance High impedance Keep 2 1,2 High impedance High impedance Keep Keep 3 High impedance High impedance Keep 3 (DO-D7) 1,2 High impedance High impedance High impedance High impedance 3 High impedance High impedance Keep 4 (Ae-Als) High High impedance High impedance High 2 High impedance High impedance High impedance NoteS 3 High impedance High impedance Ke~p 5 1,2 High impedance High impedance Keep Keep 3 High impedance High impedance Keep 6 1,2 High impedance High impedance Keep Keep 3 High impedance High impedance Keep I 7 1,2 Note 1 High impedance .Note 2 Note 1 3 High impedance High impedance Keep Notes: 1. RD, WR, R/W, LlR = high; SA = low. 2. RD, WR, R/W = high impedance; LlR, SA = high. 3. E is high impedance in standby state. 4. HALT cannot be accepted in mode 3. 5. Address output pin = high; Input port = high impedance. 3.5 Low Power Dissipation Modes The MCU has two low power dissipation modes, sieep and standby. Table 3-7 shows the MCU state in sleep and standby modes. ~HITACHI 559 Table 3-7. Sleep and Standby Modes Sleep Mode. Standby Mode Oscillation circuits Continue operation Stop CPU Stop Stop CPU registers Hold Undefined RAM Hold Hold I/O pins Hold High impedance Timers Continue operation Stop SCI Continue operation Stop Internal Registers Hold Reset How to release Interrupt STBY = high before reset start STBY=low (Hold RES low after STBY high until Reset start oscillator stabilizes, 20 ms min) 3.5.1 Sleep Mode The MCU goes into sleep mode when the SLP instruction is executed. In the sleep mode, the CPU stops operation while maintaining the registers' contents. Peripherals such as the timers and the SCI continue their functions. One-fifth as much power is dissipated in sleep mode as. in the operating mode. The sleep mode is terminated by an interrupt, or a RES or STBY signal. RES causes the MCU to reset, STBY causes it to go into standby mode. When the CPU receives an interrupt request, it retums to operating mode. If the interrupts are enabled, it branches to the interrupt service routine. If they are masked, it executes the next instruction. However, Htimer 1 or 2 prohibits a timer interrupt, the CPU won't cancel the sleep mode because there is no interrupt request to the CPU. The sleep mode reduces power dissipation for a system that doesn't need the CPU's continuous operation. Figure 3-4 is the sleep instruction timing chart. PCn PCn+ 1 FFFF FFFF PCn 1 PCn+2 Sleep Is cleared wHh interrupt masked DATA BUS LJ'T eY Sleep Instruction I'nlerrupt save rou~ne / Address bus where -~ SP ISP 'C=: sleep is cleared Pen SLP Interrupt occurs ::~~~interrupt PCn" OP.+1 Program Figure 3-4. Sleep Instruction Timing @HITACHI 560 3.5.2 Standby Mode When the STBY input goes low, the MPU stops all clocks and goes to the reset state. In this mode, power dissipation is greatly reduced. All pins except VCC, VSS, STBY, and XTAL (outputs 0) are detached from the MCU internally, and go to high impedance. In standby mode, power is supplied to the MCU, so that the contents of RAM are retained. The MCU returns from this mode with a reset. An example of the use of this mode follows. First, save the CPU state and SP contents in RAM by an NMI routine. Then disable the RAME bit in the RAM control register and set the STBY PWR bit to go to standby mode. If the STBY PWR bit is still set after reset start, power has been supplied to the MCU and the RAM contents have been retained properly. The system can restore itself by returning the pre-standby information to the SP and registers. Figure 3-5 shows the timing at the NMI, RES and STBY pins. Note: In standby mode, the mode program pins, MPO and MP1, should be held according to the operation mode. If they are opened, the standby current will increase over the specified value. vee \~ ~ CD NM~ I I NMl I CDI I I MCU I @IRES I I I 111111 )) I I I I I I I I I I I I I RES CVI STBY I I I I I I 111111 I I I 1r----fT I I HSave Registers f------l Oscillator RAM/Port 5 Control Start Time Register Set I------ Restart Figure 3-5. Standby Mode Timing ~HITACHI 561 3.6 Trap Function The CPU generates an interrupt with the highest priority (TRAP) when it fetches an undefined instruction or an instruction from outside of memory space. The trap function prevents system malfunctions caused by noise or program error. 3.6.1 Opcode Error When the CPU fetches an undefined opcode, it saves the CPU registers as well as performing the normal interrupt procedure and branches to TRAP ($FFEE, $FFEF). This has the highest priority next to reset. 3.6.2 Address Error When an instruction is fetched from outside the intemal ROM, RAM, and extemal memory area, the MCU generates an address interrupt as well as an opcode error. But on a system with no extemal memory, a trap is not generated if an instruction is fetched from the external memory area. Table 3-8 shows the addresses where an address error occurs in each mode. This function is available only for an instruction fetch, and does not apply to data read/write. Table 3-8. Address Error Addresses Mode Address $0000-$001 F 2 $0000-$001 F 3 $0000-$003F, $0100-$EFFF 3.6.3 Caution The trap function has a retry function other interrupts do not have. The program flow returns to the address where the trap occured when RTI retums the CPU to the main routine from the TRAP routine. The retry can prevent problems caused by noise, etc. However, if another trap occurs, the program can repeat the retryITRAP cycle forever. Consideration is necessary in programming. In figure 3-6, after executing instruction OPn, the MPU fetches and decodes an undefined opcode and generates a trap interrupt. When the RTI is executed in the trap interrupt servicing routine, the MPU will put $FF03 in the PC, fetch the same opcode, and generate the trap again. The MPU will endlessly repeat loop ABC. ~HITACHI 562 In figure 3-7, after executing the BSR, the branch destination address is output to the address bus to fetch the first instruction of the subroutine. If $0001 is erroneously output as the address, the MPU will decode it and generate a trap interrupt. When the RTI is executed in the trap interrupt serviCing routine, the MPU will put $0001 in the PC, and start from this address. This will generate another trap, in an endless loop. $FF01 OPn $FF02 BSR $FF02 Operand $FF03 01 $FF03 Undefinition $FF04 OPn $FF04 OPn+ 1 c Figure 3-6. Executing an Undefined Opcode Figure 3-7. Erroneous Fetch 3.7 Reset To reset the MCU during operation, hold RES low for at least 3 system-clock cycles. At the third cycle, when the clock signal is low, all the address buses become high. While RES is low, the buses remain high. When RES goes high, the MCU starts the following operations. 1. Latches the value of the mode program pins, MP1 and MPO' 2. Initializes the internal registers (see table 2-3). 3. Sets the interrupt mask bit. For the CPU to recognize the maskable interrrupts IR01, IR02, and IR03, this bit should be cleared in advance. 4. Puts the contents (= start address) of the last two addresses ($FFFE, $FFFF) into the program counter and starts the program from this address. See table 2-4. The MCU cannot accept a reset input until the clock oscillation is stable after power-on (20 ms maximum). This is because the reset signal is internally synchronized to the clock as shown in figure 3-8. Until oscillation starts, the MCU is undefined. As the I/O ports are controlled directly by the RES pin, they are reset after power-on reset. At this time, the data registers of these ports don't change. Refer to 2.4 Ports for the state of the ports during reset. Figure 3-9 shows reset timing. RES pin Internal reset signal Inside the LSI Figure 3-8 Reset Circuit ~HITACHB 563 E _ Internal R _~\\\\\\\\\\\\\\\\~\\\ I Internal W _~\\\\\\\\\\\\\\\\\\\ ~~~j---------- 55 Riw _~\\\\\\\~\\\\\\\\Wy AD _:""~~""'~tm~\m1&\\tm~\\\m1~\rn'f/~l~"CfD--;~l VIR _~\\~\\\~\\\\\\\\\}' Data Bus _~\\\\\\\\\\\\\\\\\\\~\\\\\\\~ O-O--O-~;l-l- - - - PCB pea First PC15 PC7 Instruction Figure 3-9 Reset Timing 3.8 Interrupts The CPU will complete the current instruction before accepting the request. If the interrupt mask bit in the condition code register is set, the request will be ignored. When the interrupt sequence starts, the contents of the program counter, index register, accumulators, and condition code register will be saved onto the stack. Then the CPU sets the interrupt mask bit and will not respond to further maskable interrupt requests. In the last cycle of the interrupt, the CPU fetches the vectors shown in table 3-9, transfers their contents to the program counter and branches to the interrupt service routine. The extemal interrupt pins IR01 and IR02 are also used as P50 and P51' The function is chosen by the enable bits in the RAM/port 5 control register (bits 0 and 1) at $0014. See 2.5 RAM/Port 5 Control Register for details. When one of the intemalinterrupts.lCl.OCl.TOl.CMl. or SIO is generated, the CPU produces the internal interrupt signal, IR03' IR03 functions just the same as IR01 or IR02, except for its vector address. Table 3-9 is an interrupt vector map, figure 3-10 is the interrupt sequence, and figure 3-11 is the interrupt circuit block diagram. ~HITACHI 564 Table 3-9. Interrupt Vector Memory Map Ve~JQ[ LQ~£!tiQD Priority MSB LSB Interrupt Highest FFFE FFFF RES FFEE FFEF TRAP FFFC FFFO NMI FFFA FFFB SWI (Software interrupt) FFF8 FFF9 IRQ1. ISF (Port 6 input strobe) FFF6 FFF7 ICI (Timer 1 input capture) FFF4 FFF5 OCI (Timer 1 output compare 1. 2) FFF2 FFF3 TOI (Timer 1 overflow) FFEC FFEO CMI (Timer 2 counter matCh) FFEA FFEB IRQ2 Lowest FFFO FFF1 SIO (RORF + ORFE + TORE + PER) Interrupt Test E Internal Address Bus _-'\...1.-'''---,I\-_J\.._J\.._...J\._..J\_..J'~-'''--'''-~''-_''-_''-_.r..._.J\.._-''- NMI. IRO,. SP-1 SP-2 SP-3 SP-4 sp-5 SP-6 :~~~: A£~:SS IRO,.IR0 3 Internal Data Bus _-'''-~~_''-_J\.._...J\.__..J\_~~-J~-J~--'''-_A-_n-_J~_~_~~-'~ Op Code Operand 'Irrelevant PCO- PC8- IXO- IX8- ACCA ACeS eCR vMecS,.or Vector First Insf. 01 Op Code Data PC? PC15 IX7 IX15 LSB Interrupt Routine Internal Read \~ _______________--JI Internal Write I \~--------- Figure 3-1 O. Interrupt Sequence ~H8TACHI 565 Each Status Register's Interrupt Enable Flag 1 ; Enable, 0; Disable ISF 1 Condition ---. TAO, -0 Code iRa, Register I-MASK ICI ICF o ;Enable 1 ;DisablE OCF1 -0- OCF2 ~--o- ~ r-v-- --rr:u-- Interrupt TOI Request TOF IRQ, CMF RDRF PER 1. -- -0- CMI Signal ORFE ---1 TDRE --0- ~ Edge Detective -J Sleep Cancel Signal Circuit Ifddress Error TRAP Op Code Error Detective Circuit SWI Figure 3-11, Interrupt Circuit Block Diagram The SEI instruction sets the interrupt mask bit, inhibiting interrupts, The CLI instruction clears the interrupt mask bit, allowing interrupts, The TAP instruction can set and clear the interrupt mask bit also. There must be at least two cycles between clearing the interrupt mask bit and setting it again. or an interrupt which occurs between setting and clearing the bit cannot be accepted (figure 3-12). CLI CLI CLI NOP SEI NOP NOP SEI SEI No No Yes Figure 3-12. CLI and SEI Timing ~HITACHI 566 Section 4. Timer 1 The 16-bit programmable timer, timer 1, can measure an input waveform and independently generate two independent waveforms. The pulse widths of the input and output waveforms can vary from microseconds to seconds. Timer 1 has the following components (figure 4-1). ControVstatus register 1 (8 bits) ControVstatus register 2 (7 bits) Free-running counter (16 bits) • Output compare register 1 (16 bits) Output compare register 2 (16 bits) Input capture register (16 bits) Internal Data Bus ~):$19,$IA : : [ } SOB, SOC ~ $09,$OA il$OD,$OE' Output Compare Output Com pare Free Running Input Capture I Register 2 I Register 1 16 Bit Counter I Register I I I I ~I I . 7 l~ I ~~ } ~ Output Compare 2 Output Compare 1 Overflow Detect I Edge Detect I r-RES ! I D 0 l~:~ 1~~~ I I I I TOF I EICI IEOCilI ETOI IIEDG IOLVLll : TCSRI - CLK R i I $08 ...--. I I I I I I I D Or- I I I ~;F- ;c~jOCF2{ - [EOc1TlVl21 OE21 OEI I. ClK R IRQ, I TCSR2 $OF ---n:= n- t f-~-- : P25 P21 -- P 20 Figure 4-1, Timer f Block Diagram ~HITACHI 567 4.1 Free-Running Counter (FRC) The key element of timer 1 is the 16-bit free-running counter. It is incremented by the system clock. The counter value can be read by software without affecting the counter. Reset clears the counter. The free-running counter is located at addresses $0009 and $OOOA. When the CPU writes to the high byte of the FRC ($0009), a preset value ($FFF8) is actually written to both bytes of the counter, regardless of the write data value. When the CPU writes to the low byte ($OOOA) after the high byte, both the low and high byte of the write data value are written to the FRC. See figure 4-2. The counter operates this way when written to by double-byte store instructions (STD, STX, etc). Counter value $FFF8 $5AF3 Writing $5AF3 to the FRC. Figure 4-2. Counter Write Timing 4.2 Output Compare Registers (OCR) The output compare registers are 16-bit readlwrite registers that control the output waveforms. They are located at $0008, $OOOC (OCR1) and $0019, $001A (OCR2). The OCR's are constantly compared to the FRC. When the data matches, the output compare flag (OCF) in the timer conlroVstatus register (TCSR) is set. If an output enable bit (DE) in TCSR2 is set to 1, an output level bit (OLVL) will be output to bit 1 (Tout1) and bit 5 (Tout2) of port 2. To determine the output level for the next compare match, change OCR and OLVL. The OCR is set to $FFFF after reset. The compare function is inhibited for a cycle just after a write to the OCR or the upper byte of the FRC. This is so that the 16-bit value will be valid in the OCR, and because $FFF8 is set after the FRC's upper byte is written. To write to the OCR, use a 2-byte transfer instruction, such as STX. ~HITACHI 568 4.3 Input Capture Register (ICR) The input capture register is a 16-bit read-only register located at $OOOD, $OOOE. It stores the FRC's value when an external input signal transition at P20 generates an input capture pulse. Which transition generates the pulse is defined by the input edge bit (IEDG) in TCSR1. To input an edge bit to the edge detector, clear bit 0 of port 2's DDR. When an input transition occurs at the next cycle of the CPU's ICR upper-byte read, the input capture pulse will be delayed one cycle. To ensure input capture, the CPU must read the ICR with a 2-byte transfer instruction. The ICR is cleared to all zeros during reset. 4.4 Timer Control/Status Register 1 (TCSR1) The timer control/status register 1 is an 8-bit register located at $0008 (figure 4-3). All of the bits can be read and the lower 5 can be written to. The 3 upper read-only bits indicate the timer status. 76543210 I'CF 1 OCF11 TOF 1 EICII EOCI11 ETOIIIEDG IOLVL 11 $0008 Figure 4-3. Timer Control/Status Register 1 4.4.1 Output Level 1 (OLVL 1) OLVL 1 is transferred to port 2, bit 1 when a match occurs between the counter and OCR1. If OE1, bit 0 of TCSR2 is set to 1, OLVL 1 will be output at port 2 bit 1. Bit O. 4.4.2 Input Edge (IEDG) IEDG determines whether the rising edge or the falling edge of P20 will trigger data transfer from the counter to the ICA. IEDG = 0 specifies a falling edge (high to low); IEDG = 1 specifies a rising edge (low to high). Bit 0 of port 2's DDR must be cleared for this function to operate. Bit 1. 4.4.3 Enable Timer Overflow Interrupt (ETOI) Setting ETOI to 1 enables timer overflow interrupt (Tal) to trigger an internal interrupt (IR03)' When ETOI is cleared, the interrupt is inhibited. Bit 2. 4.4.4 Enable Output Compare Interrupt 1 (EOCI1) Setting EOCI1 to 1 enables output compare interrupt 1 (OCI1) to trigger an internal interrupt ( IR03)' When EOCI1 is cleared, the interrupt is inhibited. Bit 3. ~HBTACHI 569 4.4.5 Enable Input Capture Interrupt (EICI) Setting EICI to 1 enables input capture interrupt (ICI) to trigger an internal interrupt (IRQ3)' When EICI is cleared, the interrupt is inhibited. Bit 4. 4.4.6 Timer Overflow Flag (TOF) TOF is set when the counter value increments from $FFF to $0000. TOF is cleared when CPU reads the TCSR1, then the counter's upper byte (at $0009). Bit 5, read only. 4.4.7 Output Compare Flag 1 (OCF1) OCF1 is set when a match has occurred between the FCR and OCR1. Writing to OCR1 ($OOOB or $OOOC) after reading the TCSR1 or TCSR2 clears OCF1. Bit 6, read only. 4.4.8 Input Capture Flag (ICF) ICF is set when the transition of the P20 input signal selected by IEDG causes the counter to transfer its data to the ICR. Reading the high byte of the ICR ($OOOD) after reading TCSR1 or TCSR2 clears ICF. Bit 7, read only. 4.5 Timer Control/Status Register 2 (TCSR2) The timer control/status register 2 is a 7-bit register located at $OOOF (figure 4-4). All of the bits can be read and the lower 4 can be written to. The 3 upper read-only bits indicate the timer status. Both TCSR1 and TCSR2 are cleared during reset. 76543210 IICF IOCF110CF21 - IEOCI21oLVL21 OE21 OE1 I $OOOF Figure 4-4. Timer Control/Status Register 2 4.5.1 Output Enable 1 (OE1) Setting OE1 to 1 enables OLVL 1 to appear at P21 when a match has occurred between the counter and the output compare register 1 (OCR1). Clearing OE1 makes P21 an I/O port. Bit O. ~HITACHI 570 4.5.2 Output Enable 2 (OE2) Setting OE2 to 1 enables OLVL2 to appear at P25 when a match occurs between the counter and the output compare register 2 (OCR2). Clearing OE2 makes P2S an 1/0 port. Bit 1. Note: If OE1 or OE2 is set to 1 before the first output compare match after reset, P21 or P2S will output O. 4.5.3 Output Level 2 (OLVL2) OLVL2 is transferred to P2S when a match occurs between the counter and OCR2. If OE2 (bit 1 of TCSR2) is set to 1, OVLV2 will be output at P2S' Bit 2. 4.5.4 Enable Output Compare Interrupt 2 (EOCI2) Setting EOCI2 to 1 enables output compare interrupt 2 (OCI2) to trigger an internal interrupt (IRQ3). When EOCI2 is cleared, the interrupt is inhibited. Bit 3. 4.5.5 Output Compare Flag 2 (OCF2) I OCF2 is set when a match has occurred between the FCR and OCR2. Writing to OCR2 ($0019 or $001A) after reading TCSR2 clears OCF1. Bit 6, read only. 4.5.6 Output Compare Flag 1 (OCF1) and Input Capture Flag (ICF) The OCF1 and ICF addresses are partially decoded. The CPU reading TCSR1ITCSR2 makes it possible to read OCF1 and ICF into bits 6 and 7. ~HITACHI 571 4.6 Timer Status Flags Table 4-1 shows set and clear conditions of each status flag in timer 1. If flag set and clear conditions occur at the same time, timer 1 flags will be set. Table 4-1 Timer 1 Status Flags Flag Set Condition Clear Condition Timer 1 ICF . FRC ~ ICR at edge of P20 . Read TRCSR1 or TRCSR2, then ICRH · RES = 0 OCF1 . OCR1 = FRC · Read TRCSR1 or TRCSR2, then write OCR1 H or OCR1 L . · RES = 0 OCF2 . OCR2 = FRC · Read TRCSR2, then write OCR2H or OCR2L · RES = 0 TOF . FRC=$FFFF+ 1 cycle · Read TRCSR, then FRCH · RES = 0 4.7 Precautions on Clearing OCF Writing to the OCR after reading the TCSR when the OCF is 1 clears the OCF. However, the OCF is not cleared under the following conditions. 1. A compare match is found before the CPU writes to the OCR after reading the TCSR with OCF = O. 2. A compare match is found at the same time as the CPU writes to the OCR after reading the TCSR with OCF = 1. See figure 4-5. The OCF will always be cleared if you assure that a compare match does not occur between the TCSR read and the OCR write. In example 1, figure 4-6, the OCR is loaded with the contents of the free-running counter (FRC) before the TCSR is read. A compare match will not occur until the FRC is counted up. In example 2, an OCR write cycle is executed immediately before and after TCSR read. A compare match will not occur until a match occurs between the contents of the FRC and the OCR write data. ~HITACHI 572 1. When OCF is not cleared (1) case 1 E clock TCSR re,ad OCRH write OCRL write 1 i r---r--' I I : I OCF clear signal -------------+----~,5r_-------.L'_.+.:_..1.'______ I I OCF ______________ ~_ _ _ _~~~-oc-F-set------~lf OCF is not cleared. (2) case 2 E clock TCSR read OCF set signal OCF At conflict. ---J prior set 1..------------ Figure 4-5. OCF Clearing Timing on Condition Iprogram example] LDD STD FRC OCR [program example] I I I I LDD IOCR ADD ~T I LDAA TCSR STD OCR LDAA TCSR CLEAR CLEAR LDD OCR LDD OCR OCT + ~T~ OCR ADD ~T STD OCR STD OCR Figure 4-6 Clearing the OCF <€}HRTACHI 573 Section 5. Timer 2 In addition to timer 1, the HD6301Y0, HD6303Y, and HD63701Y0, have an 8-bit reloadable timer for counting external events, timer 2. Timer 2 has a timer output, so the MCU can generate three independent waveforms. Timer 2 has the following components (figure 5-1). • ControVstatus register 3 (7 bits) Upcounter (8 bits) • Time constant register (8 bits) r---Timer1 FRC J----+-- Port 2 Bit 7 r-r---+--------r_e_Port2 Bit 6 TCSR3 $OOlB IRQ, Figure 5-1. Timer 2 Block Diagram 5.1 Timer 2 Upcounter (T2CNT) The 8-bit upcounter is located at $001 D. It operates from the clock input selected by CKSO and CKS1 of TCSR3. The counter can always be read without being affected. In addition, it can be written to at any time, even during counting. The counter is cleared when the counter value matches the time constant register (TCONR) value, or during reset. ~HITACHI 574 If the CPU writes to the counter during a cycle when it is being cleared, it will not be cleared, but will take the value written by the CPU. 5.2 Time Constant Register (TCONR) The 8-bit write-only time constant register is located at $001 C. It is always being compared to the upcounter. When it matches, the counter match flag (CMF) of the timer controVstatus register 3 (TCSR3) is set. P26 will then output the value selected by TOSO and TOS1 of the TCSR3. When the CMF is set, the counter will be cleared simultaneously and start counting from $00. This enables regular interrupts and waveform output without any software attention. TCONR is set to $FF during reset. When a write-only register like TCONR is read by the MCU, $FF always appears on the data bus. Whenever the MCU performs an arithmetic or logic operation between memory, and a write-only register, the resuh will be $FF. 5.3 Timer Control/Status Register 3 (TCSR3) The 7-bit timer controVstatus register is located at $001 B (figure 5-2). All bits can be read and all bits can be written except CMF (bit 7). TCSR3 is cleared at reset. 76543210 ICMFIECMII - I T2E I TOS1ITOSoICKS1ICKSOI$001B Figure 5-2. Timer ControVStatus Register 3 5.3.1 Input Clock Select 0 and 1 (CKSO, CKS1) CKSO and CKS1 select the counter clock as shown in table 5-1. When the external clock is selected, the (ising edge of P27 increments the counter. The external clock's frequency can be up to one-half the system clock frequency. If the E clock divided by 8 or 128 is selected, the clock comes from timer 1, so do not write to the FRC. Bits 0 and 1. ~HITACHI 575 Table 5-1. Input Clock Select CKS1 CKSO Input Clock o o Eclock o El8 o El128 External clock (P27) 5.3.2 Timer Output Select 0 and 1 (TO SO, TOS1) When the upcounter matches TCONR, timer 2 will output to P26 as selected by TOSO and TOS1 (table 5-2). When TOSQ and TOS1 are 0, P26 will be an I/O port. When toggle output is selected, the P26 output level reverses each time the upcounter and TCONR match. This produces a 50% duty cycle square wav!! at P26 without software support. Bits 2 and 3. Table 5-2. Timer 2 Output Select TOS1 TOSO Timer Output o o Timer output inhibited o Toggle output o Output 0 Output 1 5.3.3 Timer 2 Enable (T2E) When T2E is cleared to 0, the clock input to the upcounter is inhibited, and the upcounter stops. When T2E'is set, the clock selected by CKSO and CKS1 is input to the upcounter. Bit 4. Note: P2S outputs 0 when T2E bit is 0 and timer 2 is enabled by TOSO and TOS1. It also outputs 0 when T2E is 1 and timer 2 is output enabled before the first match occurs. 5.3.4 Enable Counter Match Interrupt (ECMI) Selling ECMI to 1 enables CMI to trigger an internal interrupt (IRa3)' When ECMI is cleared, the interrupt is inhibited. Bit 6. 5.3.5 Counter Match Ftag (CMF) The read-only CM F bit is set when the upcounter matches the TCONA. It is cleared by writing a zero to it. Bit 7. 5.4 Timer Status Flag Table 5-3 shows set and clear condition of each status flag in timer 2. If flag set and clear condition occurs at the same time, timer 2 flag will be set. Tabie 5-3. Timer 2 Status Flag Flag Set Condition Clear Condition CMF . T2CNT = TCONR . Write 0 to CMF • RES = 0 ~HITACHI 576 5.5 Precaution for toggle pulse function of HD6301YO/HD6303Y/HD63701YO Timer 2 Please pay attention to the following items when using Timer 2 as Toggle pulse output function. PHENOMENAN Just when T2CNT's content equals a TCR's content, after writing "1" to T2E bit of TCSR3 to output toggle pulses from P26, the abnormal rising edge occurs at P26 and the first pulse width will be 1/2 E clock cycle. Therefore, in the application which needs off-and-on pulse groups, you can't get 50%-duty output pulse at anytime. Timing chart of Timer 2 and P26 is shown in Fig. 1 when TCR = Nand CKS = 0 CKS1 = 0 to select E-clock as input pulse. Case -_T_E......._W_u....1 $0011 1 Figure 6-3. Transmit/Receive Control Status Register 6.4.1 Wake-Up (WU) In a typical multiprocessor configuration, the software protocol provides the destination address as the first byte of a message. The wake-up function allows uninterested MCU's to ignore the rest of the message. When the WU bit is set, the SCI stops receiving data until the next message. The wake-up function is triggered by one frame length of consecutive 1's (10 bits for 8-bit data, 11 bits for 9-bit data). This function is only available in asynchronous mode. Do not set WU in clock synchronous mode. Receiving these consecutive 1's wakes up the SCI and clears WU. The SCI starts receiving data. The RE flag should be set before WU is set. Bit o. 6.4.2 Transmit Enable (TE) When TE is set, tran!"mit data will appear at P24 after a 1-frame preamble in asynchronous transmission, or immediately in clock :;ynchronous transmission. P24 will be the serial output regardless of the state of bit 4 of port 2's DDR. If TE is cleared, serial 110 doesn, affect P24' Bit 1. 6.4.3 Transmit Interrupt Enable (TIE) Setting TIE enables TDRE to trigger an internal interrupt (IR03)' Clearing TIE inhibits the interrupt. Bit 2. 6.4.4 Receive Enable (RE) Setting RE inputs the signal at P23 regardless of the state of bit 3 of port 2's DDR. When RE is cleared, serial 110 doesn't affect P23. Bit 3. ~HITACHI 582 6.4.5 Receive Interrupt Enable (RIE) Setting RIE enables RDRF or ORFE (lRCSR b~ 6 or 7) to trigger an intemal interrupt (IRQ3)' Clearing RIE inhibits the interrupt. B~ 4. 6.4.6 Transmit Data Register Empty (TORE) In asynchronous mode, the SCI sets lDRE when the lDR is transferred to the lDSA. In the clock synchronous mode, SCI sets lDRE when the lDSR is empty. lDRE is reset by reading the lRCSR and writing new transm~ data to the transmit data register. lDRE is set to 1 at reset. Bit 5, read only. 6.5.7 Overrun/Framing Error (ORFE) The SCI sets ORFE when an overrun or framing error is generated during data receive. An overrun error occurs when new receive data is ready to be transferred to the RDR, and RDRF is still set. A framing error occurs when a stop bit is not O. OR FE is only affected in asynchronous mode. Reading the RDR after reading the TRCSR clears the ORFE. It is cleared at reset. Bit 6, read only. 6.4.8 Receive Data Register Full (RDRF) RDRF is set when the RDSR is transferred to the RDA. Reading the RDR after reading the lRCSR clears the RDRF. It is cleared at reset. Bit 7, read only. Note: When more than 1 of bits 5, 6, and 7 are set, one lRCSR read will clear them all. It is not necessary to read theTRCSR once for each bit. 6.5 Transmit Rate/Mode Control Register (RMCR) lhe RMCR (figure 6-4) controls the following for serial 110: • Baud rate • Clock source • Operation mode • Data fo rrnat • P22 function In addition, if the 9-bit asynchronous format is used, RMCR holds the ninth bit. All bits can be read, and all bits can be wr~ten to, except bit 7 (RD8). ~HITACHI 583 76543210 - 1 - 1 552 1 CC21 CC1 I I I I cco 551 550 $0010 Figure 6-4. Transfer Rate/Mode Control Register 6.5.1 Speed Select (SSO, SS1, SS2) SSO-SS2 control the baud rate used for the SCI. Table 6-1 lists the available baud rates. The timer 1 FRC (882 =0) and the timer 2 upcounter (882 = 1) provide the internal clock to the SCI. When SS2 is set, timer 2 functions as the baud rate generator. Timer 2 generates a baud rate dependent on TCONR as shown in table 6-2. Bits 0, 1, and 5. Table 6-1. SCI Bit Times and Transfer Rates Asynchronous XTAL 2.4576 MHz 4.0 MHz 4.9152 MHz SSO SS1 SS2 E 614.4 kHz 1_0 MHz 1.2288 MHz 0 0 0 El16 26 J1S/38400 baud 16 (.1SI62500 baud 13 (.1SI76800 baud 0 0 El128 208 (.1SI4800 baud 128 (.1SI7812.5 baud 104.2 (.1SI9600 baud 0 0 El1024 1.67 msl600 baud 1.024 ms/976.6 baud 833.3 msl1200 baud 0 El4096 6.67 msl150 baud 4.096 msl244.1 baud 3.333 msl300 baud X X Note 1 Note 1 Note 1 Note: 1. When SS2 = 1, timer 2 is the SCI clock. The baud rate is as follows: Baud rate = fI[32(TCONR +1)) Where: f = timer 2 input clock frequency TCONR = contents of timer constant register, 0-255 ~HITACHI 584 Table 6-1. SCI Bit Times and Transfer Rates (cont.) Clock Synchronous (Note 1) XTAL 4.0 MHz 6.0 MHz 8.0 MHz 12.0 MHz SS2 SS1 SSO E 1.0 MHz 1.5 MHz 2.0 MHz 3.0 MHz 0 0 0 El2 2~/bit 1.33 ~lbit 1 ~/bit 0.667 fLs/bit 0 0 El16 16~bit 10.7 ~/bit 8 ~/bit 5.33 fLs/bit 0 0 El128 128 ~lbit 85.3 ~lbit 64 ~/bit 42.7 fLs/bit 0 El512 512 ~lbit 341 ~/bit 256~bit 171 fLs/bit X X Note 2 Note 2 Note 2 Note 2 Notes: 1. Bit rates for internal clock operation. External clock can operate from DC to 1/2 system clock frequency. 2. When SS2 is 1, timer 2 is the SCI clock. The bit rate is as follows: Bit rate (jJ.sIbit)= 4(TCONR + 1)/f Where: f = timer 2 input clock frequency TCONR = contents of timer constant register, 0-255 Table 6-2. Baud Rate and Time Constant Register Example XTAL Frequency Baud Rate 2.4576 MHz 3.6864 MHz 4.0 MHz 4.9152 MHz 8.0 MHz 12.0 MHz 110 (note 1) 21 32 35 43 70 106 150 127 191 207 255 51 77 300 63 95 103 127 207 38 600 31 47 51 63 103 155 1200 15 23 25 31 51 77 2400 7 11 12 15 25 38 4800 3 5 7 12 19 9600 2 3 9 19200 0 38400 0 Note: 1. Et8 is used as the clock for 110 baud, E is used for all other baud rates. ~HITACHB 585 6.5.2 Clock Control/Format Select (CCO, CC1, CC2) CCO, CC1, and CC2 control the clock source and data format (table 6-3). They are cleared during reset, so the MCU will be in clock synchronous mode with extemal clock. Therefore, P22 starts out as a clock input. To use P22 as an output port, set bit 2 of the port 2 DDR to 1 and set CC1 and CCO to 0, 1. Bits 2, 3, and 4. Table 6-3. SCI Format and Clock Source Control CC2 CC1 ceo Format Mode Clock Source P22 0 0 0 8-bitdata Clock synchronous External Clock input 0 0 8-bit data Asynchronous Internal Not used 0 0 8-bit data Asynchronous Internal Clock output (note 1) 0 8-bitdata Asynchronous· External Clock input 0 0 8-bit data Clock synchronous Internal Clock output 0 7-bit data Asynchronous Internal Not used 0 7-bit data Asynchronous Internal Clock output (note 1) 7-bit data Asynchronous External Clock input Note: 1. Clock output regardless of bits TE and RE of TRCSA. 6.6 SCI Receiving Margin The receiving margin for the SCI is as follows. Allowable deviation of bit error (t - to)ItO = ±43.7% Allowable deviation of character error (T-TO)/TO = ±4.37% T, TO, t, and to are defined in figure 6-5. When a modem is used for communication, waveform distortion may exceed the allowable value, depending on the modem and channel. ~HITACHI 586 START 2 3 4 5 7 r------, Ideal Waveform Real Waveform f - - -_ _ T~_t~ _ _ ___I-I Figure 6-5. Bit and Character Error 6.7 SCI Status Flags Table 6-4 shows set and clear conditions of each status flag in the SCI. If flag set and clear conditions occur at the same time, the SCI flags will be cleared. Table 6-4. SCI Status Flags Flag Set Condition Clear Condition SCI RDRF . RDSR - RDR Read TRCSR1 or TRCSR2, then RDR RES = 0 ~ ORFE Framing error (async mode). Read TRCSR1 or TRCSR2, then Stop bit = 0 RDR Overrun error (async mode). RES = 0 RDSR - ROR when RDRF = 1 TORE TDR - TDSR (async mode) Read TRCSR1 or TRCSR2, then TDSR is empty (clock sync write to TDR mode) PER PEN = 1 Read TRCSR2, then ROR RES = 0 ~HITACHI 587 6.8 Precaution for clock-synchronous serial communication interface When transmitting through clock-synchronous serial communication interface, TE bit should not be cleared with TORE of TRCSR ($11) is "0". The TORE set and clear conditions of SCI are shown as follows. Set Condition Clear Condition 1. TOR -+ transmit shift register When writing to TOR after TRCSR read, (asynchronous) with TORE = 1, TORE is cleared. TORE 2. Transmit shift register is empty. (clock-synchronous) 3. RES = 0 If transmit data is written to TOR, and then TE bit is cleared with TORE = 0 to stop transmitting, TORE remains "0". In this case, even if TE bit is set and transmit data is written again, the TOR data is not transmitted. Please note that TE bit must be cleared after the last data has been transmitted. (This caution is not applied to asynchronous serial communication interface.) ~HITACHI 588 Section 7. HD63701 YO Programmable ROM (EPROM) Programmable ROM Operation The HD63701 YO's on-chip EPROM is programmed in standard 27256 EPROM using a standard PROM the PROM mode (figures 37 and 38). PROM mode is set programmer and a socket adapter. Table 18 lists by bringing MPo, MP" and STBY low. In PROM mode, recommended PROM programmers and socket adapters. the MeV doesn't operate. It can be programmed like a Vee Addresses Addresses in MCU mode in PROM mode MPo ~ ~ $0000 MP, Dala $COOO V / / /.1' / >' / /I Vpp STBV EI)o-EO, Internal PROM ' - - - - - { RES/V" Address EAo-EA7 $FFFF I $3FFF I : (Note) Address EAe-EAI4 I '1' I I I I IL_______ .1I $7FFF P4,i---ct Note: When reading this address space, $FF is output. Figure 7.1 PROM Mode Functional Diagram and Memory Map Table 7.1 PROM Programmers and Socket Adapters PROM Programmer Socket Adapter Type Name Maker Type Name Maker DP-64S. DC-64S Fp·64 CP·68 DATA I/O . 1218 Hitachi HS31YESSIIH HS31 YESFOI H HS31YESCOIH 228 298 Table 7.2 PROM Mode Selection Pin Mode CE OE Vpp EOo-E07 Programming Low High Vpp Data input Verify High Low Vpp Data output Programming inhibited High High Vpp High impedance ~HITACHI 589 G G Vpp G EOo EO, EO, E03 EO. E05 E06 EO, EAo EA, :~HD63701YOC:: EA, ,.(DC-64S) EA3 EA. EA5 EA6 EA, Vss EA. 6E EAIO EAl1 EA" EA'3 EA,. G CE G Vee (Top View) Figure 7-2. PROM Mode Pin Arrangement 7.1 Programming and Verification When the CE pin is held low after the programming voltage (Vpp) is applied, data can be programmed in PROM one byte at a time through port 3. To verify the data, hold the Vpp/OE and CE pins low after programming, and the programmed data will be output from port 3. When CE is returned high, port 3 will be high impedance, and PROM programming/verification will be inhibited. Programming precautions: The PROM memory cells should be programmed under specific voltage and timing conditions. The higher the program voltage and the longer the program pulse is applied, the more electrons will be injected into the floating gate. However, if an overvoltage is applied to Vpp, the p-n junction may be permanently damaged. Pay particular attention to PROM programmer overshot. Negative voltage noise will cause a parasitic transistor effect, which may reduce breakdown voltage. The address range must be $000 through $3FFF because the on-chip EPROM is 16K bytes. Fill remainder of EPROM area with FFFF for PROM programmer to correctly verify. The HD63701 YO is connected electrically to the PROM programmer through a socket adapter. Therefore, pay attention to the following: 1. Confirm that the socket adapter is firmly fixed on the PROM programmer. 2. Do not touch the socket adapter or the LSI during programming. Mis-programming can be caused by poor contacts. ~HITACHI 590 7.2 Erasing (Window Package) The EPROM is erased by exposing the LSI to ultraviolet light. All erased bits are in 1 'so The conditions for erasing are: ultraviolet light with wavelength of 2537 A, and a minimum irradiation of 15 W' s/cm 2 . These conditions are satisfied by exposing the LSI to an ultraviolet light rated at 12,000 IlW/cm2for 15-20 minutes, at a distance of 1 inch. 7.3 Characteristics and Applications 7.3.1 Principles of Programming/Erasing The HD63701YO's memory cells are the same as an EPROM's. Therefore they are programmed by applying high voltage tq,control gates and drains, which injects hot electrons into the floating gate (figure 7-3). The condensed electrons in the floating gate are stable, surrounded by an energy barrier of Si0 2 film. Such a cell becomes a 0 bit due to the memory threshold voltage change. A cell with no condensed electrons at its floating gate appears as a 1 bit. r------( Control gate SiO,~ ~ / Floating gate source\ ~EX3888er /orain ( "J [" \ The programmed cell (0) The erased cell (1) Figure 7-3. Cross-Section of EPROM Memory Cell The electron charge in memory cells may decrease as time goes by. This can be caused by: 1. Ultraviolet light, discharged by photo-emitting electrons (erasure principle) 2. Heat, discharged by thermal emitting electrons 3. High voltage, discharged by a high electric field at the control gate or drain If the oxide film covering a floating gate is defective, the erasure rate is great. Normally, electron erasure does not occur, because such defective devices are found and removed during testing. @HITACHI 591 7.3.2 Window-Type Package Precautions Glass Erasure Window: If the glass window comes in contact with plastic or anything with a static charge, the LSI may malfunction due to the electrostatic charge on the surface of the window. If this occurs, exposing the LSI to ultraviolet light for a few minutes neutralizes the charge, and restores the LSI to normal operation. However, charge stored in the floating gate decreases at the same time, so reprogramming is recommended. Electrostatic charge buildup on the window is a fundamental cause of malfunctions. Measures for its prevention are the same as those for preventing electrostatic breakdown: 1. Operators should be grounded when handling equipment. 2. Do not rub the glass window with plastics. 3. Be careful of coolant sprays, which may contain a few ions. 4. The ultraviolet shading label (which includes conductive material) effectively neutralizes charge. Ultraviolet Shading Label: If the LSI is exposed to fluorescent light or sunlight, its memory contents may be erased by the small quantity of ultraviolet light in these sources. In strong light, the MCU may fail under the influence of photocurrent. To prevent these problems, it is recommended that the device be used with an ultraviolet shading label covering the erasure window after programming. Special labels are sold for this purpose. They contain metal to absorb ultraviolet light. When choosing a label, note the following: 1. Adhesion (mechanical intensity)-Re-use and dust reduce adhesion. Peeling off a label may cause static electricity. Therefore, erasing and rewriting is recommended after peeling. Sticking a new label over the old one is better than replacing a label. 2. Allowable temperature range-The allowable environmental temperature range of the label should be noted. If it is used under conditions outside this range, the paste may stiffen or adhere to the label, causing paste to remain on the window when the label is removed. 3. Moisture resistance-The allowable moisture range and environmental conditions of the label should be noted. It is difficult to find a shade label applicable to all conditions. The proper label should be selected depending on the intended use of the MCU. $HITACHI 592 Section 8. Applications 8.1 HD6301 YO in Expanded Mode Figure 8-1 shows a microcomputer system using all CMOS peripheral LSI's as an application example of the HD6301 YO in the expanded mode (modes 1, 2). Ports 1 and 4 are used for address output, and port 3 is used for data I/O. The system is controlled by directly connecting RD and WR as memory control signals and RIW and E as peripheral controls. Address decoder ~~ A Y, L CMOS PIA CMOS ACIA ~B A,. Y,I-·- cs, cs, r-"'-- c Y 31-- 7'4'HC13B HD6321 ±}"0 1....0. HD6350 Ie>- I- :-- Serial MCU E E r-- Interface E ; r?-- A.-:- ~ RS, R/W 0.-0, RS. --?-Ar- RS R/W 0.-0, -- :--- R/W l - n 16 A.-A,. Ad dress bus B 0.-0, Data bus RD WR t CS, CE A,. DE .-.. cs DE WE TIE 13 +- A.-A" ~ A.-A" 4: A.-A .. B L.r- 1/0,-1/0. + 0.-0, ~ 0.-0, HM6264A HN27C64 HN613256 Bk byte of S-RAM Bk byte of EPROM 32k byte o'-Mask ROM Figure 8-1. All CMOS Microcomputer System ~HaTACH8 593 8.2 HD6301 YO in Single-Chip Mode Figure 8-2 shows a printer controller using the HD6301 YO in the single-chip mode (mode 3). The HD6301 YO controls a 16-dot printer using I/O lines as its ports. Data from the host is transferred to the MCU through the serialinterface or through a Centronics interface at port 3. 1\ " Port3 Port 1 8 , Centronics Interface Latch I j y ~ Head driver Port 4 8 v STROB Tout1 (TImer) t MCU Serial Interface 2 Host Rx Port 7 CR Motor driver computer system Tx I Tout2 I LF Motor driver (Timer) L Panel switch Port 6 2 display y Port 5 Position detector Figure 8-2. Printer Controller 8.3 Timer Applications 8.3.1 Timer 1 Timer 1 is a 16-bit programmable timer with the same architecture as the timer on the HD6301 V1, but with an output compare register added. Timer 1 can perform the following four operations: 1. Waveform generation or interval timing using output compare register 1 (OCR1) 2. Waveform generation or interval timing using output compare register 2 (OCR2) 3. Pulse width or pulse cycle measurement using the input capture register 4. Interval timing with overflow interrupt ~HITACHI 594 Waveform Generation. The values of the output compare registers (OCR1, OCR2) are compared with the free-running counter ~FRC) at every E cycle. When a match occurs, an output compare flag (OCF1, OCF2) is set. When an output enable bit (OEl E, OE2E) is set, the value of the output level bit (OLVL 1, OLVL2) is output at port 2 (Toutl: P21, Tout2: P25)' Figure 9-3 is a flowchart for OCR1 waveform generation. Set P2, to timer output pin - - - - - - - - - - Set timer output. I to OLVL I - - - - - - - - - - Set O-interval-lime B to OCRI '-----,,.-----' ' - _ - - - , , . - - _ - - ' ---------Clear OCFI and add 1-lntervaHime A to OCR 1 '----,-----' Output Waveform (P2,) - - - - - - - - - Clear OCFl and add O-interval-time B to OCRI I I Lr- Start ~ I I I- B .+ A .+ B "I" A--1 Figure 8-3. OCRl Waveform Generation Pulse Width Measurement. The input capture register (ICR) latches the free-running counter value at the transition of the external input signal, measuring the pulse width or cycle. Figure 8-4 is a flowchart of pulse width measurement. ~HITACHI 595 - - - - - - - - - Detect Input rising edge - - - - - - - - - Store the ICA to M, and clear ICF '----'-r-----' - - - - - - - - Detect Input falling edge - - - - - - - - - Store the ICA to M2 and clear ICF '----'-r---' - - - - - - - - - Pulse width A=(M 2)-(M,) '---""";"--'--' __ In_pu_t_w_av_e_fo_rm--,f 1~___________ ~A-1 Figure 8-4. ICR Pulse Width Measurement 8.3.2 Timer 2 The a-bit relDadable timer provides such functions as an external event counter, interval timer, waveform generator, and SCI baud rate generator. External Event Counter. Operate timer 2 as an external event counter by setting input clock select, CKSO and CKS1, to external clock and writing 1 into T2E. The timer 2 upcounter is incremented by the external clock's rising edge. Figure 9-5 shows the routine that generates an Interrupt after N extemal events occur (where N is an integer between 1 and 256). ~HITACHI 596 8.3.2 Timer 2 The a-bit reloadable timer provides such functions as an external event counter, interval timer, waveform generator, and SCI baud rate generator. External Event Counter. Operate timer 2 as an external event counter by setting input clock select, CKSO and CKS1, to extemal clock and writing 1 into T2E. The timer 2 upcounter is incremented by the external clock's rising edge. Figure 9-5 shows the routine that generates an interrupt after N extemal events occur (where N is an integer between 1 and 256). Interrupt routine External clock input - - - - Write 0 into CMF. ~--r-----I Interrupt enable ----. Set TCONR ~--.-----' - - - - Timer 2 enable I N-l~ 02 CMF--------------------;.,----------~\ '--- Generates CMI • Sets N-l In the TCONR when the external event counter value which generates the interrupt is N. Figure 8-5. External Event Counter Square-Wave Generator. Timer 2 can generate a continuous square wave without software supervision. Figure 8-6 shows this routine. ----- Select input clock L -____- . -____--I ----- Set toggle output -----. Set TCONR '----;-----' • Set N- 1 In the TCONR, when the half cycle of square waveform Is N. - - --- Timer 2 enable '-------1 Figure 8-6. Square-Wave Generator ~HITACHI 597 8.4 SCI Applications 8.4.1 Timer 2 Baud Rate Generator The SCI can use six kinds of clock source: timer 1's FRC (four kinds), timer 2, and an external clock. The timer 1 baud rate clocks are not adjustable, but timer 2 can provide any baud rate. Figure 8-7 shows how timer 2 can provide the baud rate. CKS1 and CKS2 select E or Eta according to the baud rate. Set CKS1,CKSO Value of n to TCONR Is TCONR=N T2E=1 ------- n f _ 1 f: Input clock frequency 32 x baud rate n: 0 to 255 SS2=1 Set CC2. CC1, _______ Selectlimer 2 as a clock source. CCO Select transfer formal. _______ To Initialize the SCI, set TE and RE after more than 1 bit cycle at the required baud rate. Figure 8-7. Timer 2 as Baud Rate Generator 8.4.2 Interlace between HD6301YO and HD6305XO An HD6301 YO can interface to an HD6305XO in the clock synchronous mode. This gives 99 I/O lines, suitable for systems requiring many I/O lines. Figure 8-8 shows an example of this interface. Tx Rx Rx Tx SCLK ICK P6 0 f' c 3 P6, \'--' C, Hand Shake Line HD6301YO HD6305XO Figure 8-8. HD6301 YO to HD6305XO Interface Employing the clock synchronous mode enables the HD6301 YO to interface easily to peripheral devices (A/D converter, real-time clock, etc) which use a clock synchronous interface, as well as to the HD6305XO. ~HITACHI 598 8.4.3 I/O Expansion The SCI can be used in the clock synchronous mode to supplement the available parallel I/O ports. Use an external shift register to perform the serial-to-parallel conversion. Figure 8-9 shows this kind of I/O expansion. . Output Data 'MSB PORT ......- ......- - - { > GND MCU P 2 . t - - - - -........-t 74LS164 B CK P2 2 ......- - - - - - - - -...... Output Ports . I Input Data 'LSB MSB\ MCU PORT 74LS165 CLKINH P2 3 QH CK GND P2, Input Ports Figure 8-9. I/O Expansion in Clock Synchronous Mode 8.4.4 SCI Multiplexer Use an analog multiplexer as shown in figure8-1 oto use the SCI with both an asynchronous and a clock synchronous device, such as an HD6305XO and an RS-232C. ~HITACHI 599 HD14503 Analog MPXer MCU HD6305XO ClK Xo X P2, Rx etc. Yo Tx Zo Y I P2 3 X, Rx Y, Z P2, Tx Z, Inhl.r1 A B C lJ J PORT PIN I RS-232C etc. J Figure 8-10. Multiplexed SCI 8.5 Lowering Operating Current 8.5.1 Lowering Operating Frequency The HD6301 YO/HD6303Y operating current is approximately proportional to the operating frequency (figure 8-11). Therefore, if the system does not require a high-speed MCU, power can be reduced by lowering the operating frequency. 21r-------------____________________~ 14 ~ s 10.5 Jl c ~ E 7 ::> III c 8 ~ ::> U 0.7 0.1 1.0 1.5 2.0 3.0 Operallng Frequency (MHz) . Figure 8-11. Operating Frequency and Current (Typical) ~HITACHI 600 8.5.2 Sleep Mode The SLP instruction puts the MCU into the sleep mode. In the sleep mode, current consumption is reduced to one-fourth to one-fifth of that in the operating state.When the CPU acknowledges an interrupt request, it cancels the sleep mode. The average power consumption can be reduced by putting the CPU in sleep mode whenever it doesn't actually execute any instructions, such as in interrupt wait state or polling. Figure8-12shows a routine which wakes the CPU up every 65 rns, using the overflow interrupt of the timer 1 FRC. _______ Set the Timer 1 as the 65-ms interval timer using FRC overflow interrupt. '-----r---..J------- Interrupt wait state. When the main routine processing time is 1 ms, average operating current Icc is 1.58mA (1= 1MHz). I _1.5X65+7 X l cc - 66 = 1.58 [mAl (1= 1MHz) 8.5.3 Standby Mode Figure 8-1 2. Low Power Consumption Using the Sleep Mode I Bringing STBY (pin 7) low puts the MCU into standby mode. In standby mode, the oscillator stops and the MCU goes into the reset state. The contents of RAM are maintained as long as VCC is greater than or equal to 2 V. In standby mode, current consumption is reduced to a few J,1A. RAM can be maintained by battery. Bringing STBY high cancels standby mode. The MCU releases the reset state and starts oscillation. RES (pin 6) should be held low for at least the oscillation stabilization time (tRC) after srnY high. Figure 8-13 gives an example of a circuit that sets standby from software. Figure 8-14 shows the timing for this circuit, and figure 8-15 is an operating flowchart. ~HITACHI 601 MCU r-----------------~~~__1ST!3'Y Rr +-........--1 RES cr;J; Standby mode cancel L-----------~-------IPORT Rr· Cr > 20ms (External Input) Figure 8-13. Standby Circuit Example PORT Standby mode r II fl cancel (External Input) u STBY f5 RES I f ....... I I I Oscillation stability • PORT goes to the high-impedance state with STBY low, so it is pulled high by the pull-up resistor. Figure 8-14. Standby Timing Standby mode (20ms) Figure 8-15. Standby Circuit Flowchart ~HITACHI 602 8.6 Memory Ready Application The memory ready function allows the MCU to access low-speed memories or low-speed devices. Figure 8-16 shows a circuit example, and figure 8-17 is its timing chart. L MP , MP o Rr.i CE * ~ 0 -0, A 0 0 -0, Dala Bus 4~(4 MHz) EXTAL . / 0 AO-A,.- / Address Bus -I\ AO-A,. " lA,. / CS ,---- 4-BII binary MCU counler HD74LS161 Low-speed mask ROM i~'~OKI HN61256 A" Clear MR t.,.. Ao E ® "'" The HN61 256 Is localed In $4000 10 $BFFF. Figure 8-16. Low-Speed Memory Access Circuit E ~ ADB ::x'------'X~_x==:; CS @------------~I--~ r . X=::r-:_----'X'---_L I ~------ MR ~~ ~I__~~~ Dala Figure 8-17. Memory Ready Bus Timing ~HITACHI 603 8.7 Halt Application The halt function enables the MCU in the expanded mode to interface with a DMAC (HD6844) and execute DMA (figure 8-18). r- r- ", I-- A.-A,. A.-A" r-- A I' ; 0.-0, H A 0.-0, 'f I"Y .. MCU E t-- " R/W t-- IRQ I-- - Memory Unit REs BA HALT II) ::l m II) .. e II) ::l m DGRNT DRQH 1/0 Device Controller .( "D "D ~ A.-A,. ..: 0 Il " ~ .4. ...... D._D,V ~ . --.; .. " "0.-0, HD6844 !/>2DMA - E Riw - RiW C§lTxAKB HITACHI 611 ~---------P~MR--------~~ 2.4V \ E \ \ O.8V \ \.._--- tSMR MR Figure 1-2. Memory Ready and E Clock Tirring Instruction Execution HALT Cycle Cycle tB' 8A O.8V Figure 1-3. HALT and SA Timing Synchronous Clock Transmit Data Receive Data *2.0V is high level when clock input. 2.4V is high level when clock output. Figure 1-4. SCI Clocked Synchronous Timing ~HITACHI 612 t MCU Read r-- MCU Write Plo-P1, Iposu P2o-P21~~~______~~~_________ P4o-P4, 2.0V P50-P51~O~.S~VJjF-____~~~__~~____ P6 o-P6, - (Inputs) P30-P3, (Inputs) Figure 1-5. Port Data Set-up and Hold Figure 1-6. Port Data Delay Times Times (MCU Read) (MCU Write) E~ ;~er 1 ______--IX &~~a.: L _____ Output x T2CNT ~ !Too f- P2,. P25------------''-"'''''~.r2"...,.4'''V------ P2 6 OulpulS '1"f2-;;.;·"'SV.::....._____ Output Figure 1-7. Timer 1 Output Timing Figure 1-8. Timer 2 Output Timing j 1 r o.sv tCKr •• •• P5 4 (is) Port 6 r tCKI Data (lnpul) -Timer 2; ttcyc ··Timer 1; tPWT SCI ; ISeye Timer 2; tPWTCK SCI ; IPWSCK Figure 1-9. Timer 1·2, SCI Input Clock Figure 1-10. Port 6 Input Latch Timing Timing Vee 1rl RL~2'2kQ Test Point 1S207<\® C R or equiv. C~90pF for Port 1, Port 3. Port 4, E = 30pF for Port 2, Port 5, Port 6, Port 7 R=12kQ for Port 1- Port 7, E Figure 1-11. Output Strobe Timing Figure 1-12. Bus Timing Test Loads (TTL Load) ~HITACHI 613 Interrupt Test Internal Address Bus :=:xi::)c::::Jc=X:=X=:)(=:::)C=X:=X=:X=:JC::::J~=~:;:X;:::::X=:J:: SP SP·l SP·2 SP·3 SP·4 SP·5 SP·6 ~§ll" ~'i:0r ~~ AddressAddressAddress Internal D8t8Bus __~~__~__~__-A__-J~__~__~__-A__-J~~~__~__~__~__-A~-J~__A- Op' Operandlrrele.anIPCO- PCS- IXO- IXS- ACCA ACCa CCR Veclor VeclorFirsl In.,. of Intemal Read CodeOp CodeData , PC7 PC15 IX7 IX15 MSa LSa Inlerrupl Rouline Intemal W~e I \~----------------- Figure 1-13. Interrupt Sequence _ _ 5.5V \kc~'5V ,.c------I Ikj-O.5V ----Ifr.---i-I----------! !lfiiY ~~~S----------ir_--~ ::~n.I._~ II I fl ~~f----I;r------­ R/W.__'\\\W fl ~f 1m • • \~_w WR • • tw Data Bus ..~~~~------~~'l~~r--~------------_ PC8- pelS PCO- PC7 First Instruction Figure 1-14. Reset Timing ~HITACHI 614 1.2 HD6303Y, HD63A03Y, HD63B03Y, HD63C03Y Electrical Characteristics Absolute Maximum Ratings Item Symbol Value Unit Supply voltage Vee -0.3 to + 7.0 V Input voltage Vin -0.3 to Vee+0.3 V Operating temperature Topr -20 to +70 ·C Storage temperature Tstg -55 to +150 ·C NQte: This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend V,n, Vou,: Vss::l (V In or You,) :fiVer. Electrical Characteristics DC Characteristics (Vee; 5.0 V ± 10%, f; 0.1 to 3.0 MHz, Vss; 0 V, Ta; -20 to + 70°C) Item Symbol Min Typ Max Unit Test Condition Input high voltage RES, STSY VtH Vee-0.5 Vee+0.3 V EXTAL Vee X O.7 Vee+ 0.3 V Other inputs 2.0 Vee+0. 3 V Input low voltage All other inputs V,L -0.3 O.S' 00 V Input leakage current RES, NMI, STBY, Il'nl 1.0 pA V'n;0.5 to Vee-0.5 V MPQ, MP1 Three state Ao-A". 00-0 7• RO IITSd 1.0 pA V'n;0.5 to Vee-0.5 V leakage current WR. R/W. Ports 2. 5. 6 Output high voltage VOH 2.4 V IOH=-200 pA Vee-0.7 V IOH--10pA Output low voltage VOL 0.4 V IOL=1.6 rnA Darlington drive Ports 2, 6 -IOH 1.0 10.0 rnA Vout= 1.5 V a current Input capacitance All other inputs Cin 12.5 pF V'n=OV, 1= 1 MHz Ta=2S'C Siandby current' Not operating ISTB 3.0 15.0 pA Current dissipation* ISLP I.S 3.0 rnA Sleeping (1= 1 MHz") 2.3 4.5 rnA Sleeping (1= 1.5 MHz") 3.0 6.0 rnA Sleeping (1=2 MHz") 4.5 9.0 mA Sleeping (1=3 MHz") Icc 7.0 10.0 rnA Operating (1= 1 MHz") 10.S IS.O rnA Operating (1= 1.5 MHz") 14.0 20.0 rnA Operating (1=2 MHz") 21.0 30.0 mA Operating (1=3 MHz") RAM standby voltage VRAM 2.0 V Notes: V,H min=Vcc-1.OV, VII. max=O.8V (All output terminals are at no load.) Current dissipation of the operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about current dissipations at x MHz operation are decided according to the following formula: typo value (I;x MHz) ;tyfl value (1;1 MHz) Xx max. value (f;x MHz) =max. value (1"=1 MHz) Xx (both the sleeping and operating) In case 01 SCLK Input. V1L = O.6V (- 20°C - OOe) ~HITACHI 615 AC Characteristics (Vcc=5.0 V ± 10%,1=0.1 to 3.0 MHz, Vss =0 V, Ta=-20 to + 70°C) Bus Timing HD6303Y HD63A03Y HD63B03Y HD63C03Y MOo Typ Max Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit Condition Cycle time tcyc 10 0.666 10 0.5 10 0.333 10 pS Fig. i-IS Enable rise time t., 25 25 25 20 ns Enable fall time tEl 25 25 25 20 ns Enable pulse width high level l PWEH 450 300 220 i40 ns Enable pulse width low level I PWEl 450 300 220 140 ns Address, R/W delay time 1 tAD 250 190 160 120 ns Data delay time (Write) toow 200 160 120 100 ns Data set-up time (Read) tOSR 80 70 60 50 ns Address, R/W hold timel tAH 80 50 40 20 ns Data hold time (Write)l tHW 70 50 40 20 ns (Read) tHR 0 0 ns RD, WR pulse widthl PWRW 450 300 220 140 ns RD, WR delay time tRWD 40 40 40 40 ns RD, WR hold time tHRW 20 20 20 20 ns DR delay time tOlR 200 160 120 80 ns DR hold time tHlR 10 10 10 ns Peripheral read access time 1 tAce t80 ns MR set-up timet tSMR 400 280 230 170 ns Fig. i-16 MR hold timet tHMR 100 70 50 25 ns E clock pulse width at MR PWEMR 9 pS Figs. 1-17, Processor control set-up time tpcs 200 200 200 100 ns i-27,1-28 Processor control rise time 100 100 100 50 Figs. i-16, tPCr ns i-17 Processor control fall time tpCf 100 100 100 50 ns SA delay time tSA 250 190 160 120 ns Fig. i-17 Oscillator stabilization time tRe 20 20 20 20 ms Fig. i-28 Reset pulse width PWRST tCyc Note: 1. These timings change in approximate proportion to tcyc. The figures in this characteristics represent those when tcyc is minimum (=in the highest speed operation). ~HITACHI 616 Peripheral Port Timing HD6303Y HD63A03Y HD63B03Y HD63C03Y Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Min Typ Max Unit Condition Peripheral data (Ports 2, 5, ns Fig. 1-19 tpDSU 200 200 200 200 set-up time 6) Peripheral data (Ports 2, 5, ns tpDH 200 200 200 200 hold time 6) Delay time (From (Ports 2, 5, enable fall edge to 6 7) tPWD 300 300 300 300 ns Fig. 1-20 peripheral output) , Input strobe pulse ns Fig. 1-35 tpWIS 200 200 200 200 width Input data hold ns (Port 6) tlH 150 150 150 150 time Input data set-up ns (Port 6) tiS 100 100 100 100 time Output strobe Fig. 1-25 tOSD1 200 200 200 200 ns time tOSD2 Timer, SCI Timing I HD63D3Y HD63A03Y HD63BD3Y HD63C03Y Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Min Typ Max Unit Condition Timer 1 input pulse width tPWT 2.0 2.0 2.0 2.0 teyc Fig. 1-23 Delay time (enable positive Figs. 1-21, troD 400 400 400 400 ns transition to timer output) 1-22 (Async. mode) tS cyc 1.0 1.0 1.0 1.0 tcyc Fig. 1-23 SCI input clock cycle (Clock sync,) 2.0 2.0 2.0 2.0 Fig. 1-18 teyc SCt transmit data delay trxD 220 220 220 220 ns Fig. 1-18 time (Clock sync. mode) SCI receive data set-up tSRX 260 260 260 260 ns time (Clock sync. mode) SCI receive data hold time tHRX 100 100 100 100 ns (Clock sync. mode) SCI input clock pulse width tPWSCK 0.4 0.6 0.4 0.6 0.4 0.6 0.4 0.6 tS cyc Fig. 1-23 Timer 2 input clock cycle ttcyc 2.0 2.0 2.0 2.0 teyc Timer 2 input clock pulse width tpWTCK 200 200 200 200 ns Timer 1 • 2, SCI input clock tCKr 100 100 100 50 ns rise time Timer 1 • 2, SCI input clock tCKf 100 100 100 50 ns fall time ~HITACHI 617 tcyc ~ 2.4V V ~ E \ I\O.8V PIJl.tL j ~V PIJl.tH 1\1\ tAH __ r-- tAO - tE, tEl Ao-A15 R!W ~ 2.4V .... O.8V JK tRWO P",,"w - tHAW /~2.4V ~ O.8V ~ --tHw _ !--toow_ >- 2.4V MCU Vlkite / 00-0, 'I O.8V MC;U Read 00-0, I+--- tACC 2.0V O.8V tOSR-- - tHR ::!I~ ~ !--tOLR-- - tHLR V Figure 1-15. Bus Timing '" k. 0 .8V ~HITACHI 618 ~----------PW£MR----------~ 2.4V \ \ \ \ O.BV \.._--- ---<+--+-_tHMR tSMR MR IpCI Figure 1-16. Memory Ready and E Clock Timing Last Instruction Instruction Execution HALT Cycle Cycle tBA 2.4V BA O.BV Figure 1-17 . HALT and SA Timing I Synchronous Clock Transmit Data Receive Data ·2.0V is high level when clock input. 2.4V is high level when clock output. Figure 1-18. SCI Clocked Synchronous Timing ~HITACHI 619 rMCUWrite P2 a-P2 7 P5a-P5 7 P6a-P67 (Outputs) Figure 1-19. Port Data Set-up and Figure 1-20. Port Data Delay Times Hold Times (MCU Read) (MCU Write) E~ Output Timer 1 FRC ______~X~~i:~ X~______ T2CNT ::::J trOD I- P2,. P2 s---------'--.....yr.i....4""V.,.....---- Outputs _ _ _ _ _ _ _-',l-f-'~"'.S""V'--___ P2 6 Output Figure 1-21. Timer 1 Output Timing Figure 1-22. Timer 2 Output Timing :~ 1 r ** tCKf 'Timer 2; ttcyc •• • -Timer 1; tPWT Port 6 Date (Input) 2.0V O.SV SCI ; tScyc Timer 2; tPWTCK SCI ; tPWSCK Figure 1-23. Timer 1'2, SCI Input Clock Figure 1-24. Port 6 Input Latch Timing Timing Vee -~'.1Fi:;; C=90pF far 00-07. Ao-A'6. E =30pF for Port 2, Port 5, Port 6. RD,WR. Am, SA. Iiii R=12kQ Figure 1-25. Output Strobe Timing Figure 1-26. Bus Timing Test Loads (TTL Load) ~HITACHI 620 Interrupt Test Internal Address Bus _ _"-1-J\._--''-_''-_J\._...JI...._A.._...A_-I'\...._A.._..J\~-'~_0,-_J~c-...J'-_J'- SP SP-l SP-2 SP-3 SP-4 SP-5 SP-6 ~~lfr ~~'1i0r ~~W AddressAddressAddress Internal DataBus ___A.._~_-J'\...._A.._..J\_-I'\...._~_-r'-_''-_~_-'''--'''-_~_J\_...J'-_J'- Op OperandlrrelevantPCQ- PC8- IXO- IX8- ACCA ACCS CCR Vector Vector First Inst, of CodeOp CodeData PC7 PC15 IX7 IX15 MSB L,SS Interrupt Routine Internal Read \~------------------------------------~-------------------- ________--J/r----------------------~\L______________ Internal Wite Figure 1-27. Interrupt Sequence '~~~~ Vee \ f ~~r)------------- STBY Vcc- 0 5V tpcs tpes ~ Vcc- 0 5V Vcc-O,5V RES - - - i \ a.BV i-------I,I-'________ :~:'ess_ ••~~~~~~~~~~ FFFF FFFF FFFF FFFF FFFF FFFE FFFF New PC FFFF FFFF FFFF jj / ~~f-------f»)-- - - - - - - - - - - RD • • Data Bu, -•.. .~_~~r-' \\~\\\\\W 5f ---- I PCS- PCO- First PC15 PCl Instruction Figure 1-28, Reset Timing ~HITACHI 621 1.3 HD63701YO, HD637A01YO, HD637B01YO Electrical Characteristics Absolute Maximum Ratings Item Symbol Value Unit Supply voltage Vee -0.3 to +7.0 V Vpp voltage Vpp -0.3 to +13.0 V Input voltage Yin -0.3 to Vee+0.3 V Operating temperature Topr o to +70 ·C Storage temperature Tstg -55 to +125 ·C Note: This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend VIII, VOU!: Vss:i (V ln or Vou.) :aVl'Co Electrical Characteristics DC Characteristics (Vee = 5.0 V ± 10%, 1=0.1 to 2.0 MHz, Vss=O V, Ta=O to + 70 ·C, unless otherwise noted.) Item Symbol Min Typ Max Unit Test Condition Input high voltage RES, STBY, MPo, MP) VIH Vee-0.5 Vee+0.3 V EXTAL VeeXO.7 Vee+0.3 V Other inputs 2.0 Vee+0.3 V Input low voltage RES, MPo, MP), SCLK (P22)3 VIL -0.3 0.6 V All other inputs -0.3 0.8 V Input leakage current RES Ilinl 10.0 pA Vin=0.5 to Vee-0.5 V NMI, STBY, MPo. MP) 1.0 pA Three state Ports 1, 2, 3, 4, liTSI! 1.0 pA Vin=0.5 to Vee-0.5 V leakage current 5,6,7 Output high voltage VOH 2.4 V IOH=-200pA Vee-0.7 V IOH=-10pA Output low voltage VOL 0.4 V IOL=1.6 mA Darlington drive Ports 2, 6 -IOH 1.0 10.0 mA Vout=1.5 V current Input capacitance RES Cin 65 pF Vin=OV, 1=1 MHz, All other inputs 12.5 pF Ta=25'C Standby current Not operating ISTB 3.0 15.0 pA Current dissipation) ISLP 1.5 3.0 mA Sleeping (1=1 MHz2) 2.3 4.5 mA Sleeping (1= 1.5 MHz2) 3.0 6.0 mA Sleeping (1=2 MHz2) lee 7.0 10.0 mA Operating (1=1 MHz2) 10.5 15.0 mA Operating (1=1.5 MHz2) 14.0 20.0 mA Operating (1=2 MHz2) RAM standby voltage VRAM 2.0 V Notes: l. V"' min=V",·-l.OV. V". max=O.8V (All output terminals are at no load.) 2. Current dissiPation of the operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about current dissipations at x MHz operation are decided according to the following formula: tyPo value (f=xMHz) =typ. value (1=1 MHz) Xx max. value (f=x MHz) = max. value (1=1 MHz)Xx (both the sleeping and operating) 3. Only seria I clock use. ~HITACHI 622 AC Characteristics (Vcc=5.0 V ± 10 %, f=0.1 to 2.0 MHz, Vss=O V, Ta=O to + 70 ·C, unless otherwise noted.) Bus Timing HD63701YO HD637A01YO HD637B01YO Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit Condition Cycle time teye 10 0.666 10 0.5 10 ",5 Fig. 40 Enable rise time tEr 25 25 25 ns Enable fall time tEl 25 25 25 ns Enable pulse width high level I PWEH 450 300 220 ns Enable pulse width low level I PWEL 450 300 220 ns Address, R/'ii delay time l tAD 250 190 160 ns Data delay time (Write) tDDW 200 160 120 ns Data set·up time (Read) tDSR 80 70 60 ns Address, R/'ii hold time l tAH 80 50 40 ns Data hold time (Write) I tHW 80 50 40 ns (Read) tHR 0 0 0 ns RD, WR pulse widthl PWRW 450 300 220 ns I RD, WR delay time tRWD 40 40 40 ns RD, WR hold time tHRW 20 20 20 ns L1R delay time tDLR 200 160 120 ns L1R hold time tHLR 10 10 10 ns MR set·up time l tSMR 400 280 230 ns Fig. 41 MR hold time l tHMR 100 70 50 ns E clock pulse width at MR PWEMR 9 9 9 ",5 Figs. 42, Processor control set·up time tpcs 200 200 200 ns 52,53 Processor control rise time tPCr 100 100 100 ns Figs. 41, 42 Processor control fall time tpCI 100 100 100 ns BA delay time tOA 250 190 160 ns Fig. 42 Oscillator stabilization time tRC 20 20 20 ms Fig. 53 Reset pulse width PWRST 3 3 3 teye Note: l. These timings change in approximate proportion to teye. The figures in this characteristics represent those when teye is minimum (=in the highest speed operation). ~HITACHI 623 Peripheral Port Timing HD6370lYO HD637A01YO HD637B01YO • Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Unot Condition Peripheral data (Ports 1, 2, 3 tposu 200 200 200 ns Fig. 44 set·up time 4,5,6) Peripheral data (Ports 1, 2, 3 tpOH 200 200 200 ns hold time 4,5,6) Delay time (From (Ports 1, 2, 3 enable fall edge to tPWD 300 300 300 ns Fig. 45 4,5,6,7) peripheral output) Input strobe pulse tPWIS 200 200 200 ns Fig. 49 width Input data hold time (Port 6) IIH 150 150 150 ns Input dala sel·up lime (Pori 6) 115 100 100 100 ns Oulpul slrobe delay 10501 200 200 200 ns Fig. 50 lime 10502 Timer, SCI Timing HD63701YO HD637A01YO HD637B01YO Tesl Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit Condition Timer 1 inpul pulse widlh IpWT 2.0 2.0 2.0 tcyc Fig. 48 Delay lime (enable posilive 1100 400 400 400 ns Figs. 46, 47 Iransition 10 limer oulput) (Async. mode) IScyc 1.0 1.0 1.0 Icyc Fig. 48 SCI input clock cycle (Clock sync.) 2.0 2.0 2.0 Fig. 43 Icyc SCI Iransmit dala delay ITXO 220 220 220 ns Fig. 43 time (Clock sync. mode) SCI receive dala set·up ISRX 260 260 260 ns lime (Clock sync. mode) SCI receive dala hold lime IHRX 100 100 100 ns (Clock sync. mode) SCI input clock pulse width IpWSCK 0.4 0.6 0.4 0.6 0.4 0.6 15cyc Fig. 48 Timer 2 input clock cycle Itcyc 2.0 2.0 2.0 Icyc Timer 2 inpul clock pulse width tPWTCK 200 200 200 ns Timer 1 • 2, SCI inpul clock tCKr 100 100 100 ns rise lime Timer 1 • 2, SCI input clock ICKf 100 100 100 ns fall time @HITACHI 624 ~-----------tcyc------------t PVVEL PWoH E tEr tEl tAH Ao-A ... 2.4V A!W O.BV tAWD ~-_.----- O.BV to OW MCU Vllrite, __________________________________t-______ --< 00-07 MCU Read __________________________________t-__________ -< 00-07 Figure 1-29. Mode 1, Mode 2 Bus Timing ~HITACHI 625 '-------PWEMR -----~ 2.4V \ E \ \ \ O.BV '----- --<~-II--tHMR tSMR MR 2.0V O.BV Figure 1-30. Memory Ready and E Clock Timing Instruction Execution HALT Cycle Cycle E BA O.BV Figure 1-31. HALT and BA Timing Synchronous Clock Transmit Data Receive Data • 2. OV is high level when clock input. 2.4V is high level when clock output. Figure 1-32. SCI Clocked Synchronous Timing ~HITACHI 626 r MCU Read r-- MCU Write E E OBV\!'-_ _..J P1o-Ph P2o-P2, ~~~~____~~~~__________ tPWD P4o-P4, 2.0V P50-P5, ~O~.B~V~~______~~~__~~_____ P1o-Ph. P2o-P2, P6o-P6, P3o-P3,. P4o-P4, - - - - - - - - " ...:-:;-.,.,.,.-- (Inputs) P5o-P5,. P6o-P6, ) ~:~~ Data Valid P30-P3, P7o-P74 (Inputs) (Outputs) Figure 1-33. Port Data Set-up and Hold Times Figure 1-34. Port Data Delay Times (MCU Write) (MCU Read) E E Timer 1 FRC _______-'x ~~1~ X"-_______ T2CNT ~ troD t"-- P2,. P25-----------~--~\t~~2~.4~V,------- P2 6 Outputs 'tf2.-""·.;;:8..;.V_______ Output Figure 1-35. Timer 1 Output Timing Figure 1-36. Timer 2 Output Timing ~;~ ::4 .. \-r if .. 'Timer 2; tteye "Timer 1 ; tpWT Port 6 Data (Input) SCI ; tSeye Timer 2; tpWTCK SCI ; tpWSCK Figure 1-37. Timer 1, 2 SCI Input Clock Timing Figure 1-38. Port 6 Input Latch Timing Vee RL=2.2kQ Test POint o--~..-M--; lS2074¢~~~~~:4~B~~~_-_-_-_-_-_-_-_--_-_ P2. Output CMF Figure 111-7. Timing for Timer 2 Output and CMF ~HITACHI 646 111.4 Bus Interface 111.4.1 E and Memory Ready Question: What is the internal E clock state when the CPU uses the memory ready function? Answer: Internal E clock operates at normal frequenCY(figure 111-8) .Since the timer count and the SCI transfer rate are set by the internal E clock, they are not also affected by the memory ready function. Internal E External E MR (Memory ready signal) Figure 111-8. Internal and External E Clocks Supplement: It is impossible to examine the internal E clock from an external pin when using the memory ready function. 111.4.2 Memory Ready and Halt After Reset I Question: After reset, are memory ready and halt functions enabled or disabled? Answer: Both are enabled. MR and HALT in three operating modes is shown in table 111-6. Table 111-6. Operating Modes Operating Mode Memory Ready Halt Expanded mode Enabled (note) Enabled 2 Enabled (note) Enabled Single·chip mode No memory ready function No halt function Note: Invalid when accessing internal address space Supplement: In the expanded mode (modes 1, 2), the memory ready enable bit (MRE) and halt enable bit (HLTE) of the RAM/port 5 control register are set to 1 during reset, enabling memory ready and halt functions. ~HITACHI 647 111.4.3 Buses at Internal Address Access Question: When you access internal memory space, what states are the address buses, data buses, and control lines in? Answer: Address buses and control lines (RD, WR, 'R/W) are always output regardless of internal or extemal address space accessing. During writes to the intemal address space, the same data is output from the data bus. During reads, the data buses become high impedance. 111.4.4 External Access to Register Addresses Question: When using extemal memory at the addresses shown below in expanded modes (modes 1,2), some addresses overlap internal registers and RAM addresses (figure 111-9). In such a case, are there any problems? Internal Memory Map External Memory Map $0000 Internal "..,.,,..,..,.,,..,..,..rrrrrrrrr-rr- - - - - - - - - - - """'M<7'<""""""""""' ' ' ' ' ' ' register .......U-4U-4L.t..LL.t..L......."'+-~~~~ _____ _ Internal """'Tr7Tr7T77"TT>'"T""n"'+-~0.?~~ - - - - - - -b""""",,,,~:I'I." RAM $0140 Internal 1Tr.17T.17T.17T.17T.1"17r:l $COOO ROM ~ = overlapped address space $FFFF (mode 2) Figure 111-9. Overlapping Addresses Answer: There are no problems, but the overlapped addresses in the external memory space should not be used. When writing to the overlapping addresses, the same data is written into the internal and external address space. When reading, data is read fror:n the internal, and the external address data is ignored. Supplement: If the RAM enable bit (RAME) of the RAM/port 5 control register is D, a readlwrite from/lo the internal RAM space is invalid, and both operations are executed to the overlapped external address space. 111.4.5 Buses During WAI Question: What states are address buses, data buses, and control lines in after WAI instruction execution? ~HITACHI 648 Answer: They are as in table 111-7. Table 111-7. WAI State Line State Address bus FFFF (High) Data bus High impedance RJW High RD High WR High 111.4.6 Timing for Memory Ready and E Clock Question: What do tHMR (memory ready hold time) and tSMR (memory ready set up time) mean in the timing for "memory ready" and E clock? See figure 111-10. Answer: tHMR: When MR becomes low within tHMR from the E clock rising edge, the E clock is extended (max setting). tSMR: When MR becomes high within tSMR before the E clock falling edge (point A), E clock becomes low in the cycle (minimum setting) Integer times of cycle time PW EMR ,, \ , '-----'' ___J E \ MR Figure 111-10 Timing for Memory Ready and E Clock ~HITACHI 649 111.4.7 Limit of Halt Time Question: Is the halt time limited? Answer: No. If the halt pin has been low before a restart, the halt functions after a reset vector has been output and after the first instruction has been fetched. Supplement: When the halt signal is set to low, the CPU stops after an instruction being executed finishes, and goes to the halt state. The halted CPU sets the bus available (SA) to high and the RD, WR and R/W to high impedance. 111.5 Interrupt Control 1II.5.1IRQ1 During Standby Question: When the CPU is returning from standby mode (RES = low, STBY = low) with IRQ1 low, can the interrupt be accepted if IRQ110w continues after return? Answer: It cannot. Interrupts can be accepted when IRQ1 E = 1 and I = O. After the CPU returns from standby, it has IRQ1 E = 0 and I = 1. To accept the interrupt, the software should make IRQ1 E = 1, 1=0 after resetting. Supplement: IRQ1 E is the IRQ1 interrupt enable bit of the RAM/port 5 control register. When IRQ1 E = 1, P50 can be used as an interrupt pin. I is the interrupt mask b~. When I = 0, the CPU accepts interrupts. 111.5.2 Trap Interrupt Question: How does the trap interrupt differ from other interrupts (NMI, IRQ1, IRQ2 and IRQ3)? Allswer: The differences are: Return address (figure 111-11) Interrupt sequence (figure 111-12) ~HITACHI 650 CD NMi. IRQ" IRQ, and IRQ. @ Trap Interrupt Main routine Main routine Interrupt routine Interrupt routine (iiIMT. TAO ,. 1RC:i,. IRQ.) (Trap Interrupt) ·1 ·1 ·1: Return address = 1PC+ 11 ·1: Return address = ~ Figure 111-11. Return Address E NMI.IRQ,. IRQ,. IRQ. - r. .________-t_ _ _ _ _ _ _ _ _ _ _ _ _ __ ·2 CDNMI.IRQ, Address Bus ......- Interrupt sequences are different (·3) I ® Trap interrupt I Address Bus ·2: CD = Op code address. ® = Op code address + 1. ® = uFFFFu ·3: Trap interrupt has one more ® cycle (UFFFFU). I Figure 111-12. Interrupt Sequence ~HITACHI 651 111.5.3 LIR During Interrupt Question: What is the output state of load instruction register (LlR) in the interrupt sequence? Answer: The output state of LlR is low in the following cycles: 1. Prefetch cycle of the last instruction cycle opcode just before interrupt sequence 2. Fetch cycle of the first opcode of the interrupt routine The output state of LlR in the interrupt sequence is shown below. 1. Last instruction execution cycle just before the interrupt sequence (figure 111-13). E , Instruction execute cycle --t-- Interrupt sequence NMI, IRQ" _ _ _., IRQ" IRQ 3 Internal Data Bus _ _---'''-_---'''-_---'''-"._---='''-:-.....,...---J~__"~,....."..,,.__..J'---.J u Figure 111-13. Last Cycle Before Interrupt a. LlR output is low at the last instruction execution cycle just before interrupt sequence opcode prefetch. b. The first cycle of the interrupt sequence (b in figure 111-13) is a dummy fetch cycle. In this cycle, there are two cases; an oper~nd is on the data bus, or an opcode is on the bus. In both cases, LlR output is not low. 2. First opcode fetch cycle in the interrupt routine (figure 111-14). E -IL...f --t- Interrupt routine NMI,IRQ" IRQ" IRQ 3 ylr--------------------- Internal Data Bus First Op Code ------~)rlr--------------------.,LJ~---- Figure 111-14. First Cycle in Interrupt LlR output is low when the first opcode of the/interrupt routine is fetched. ~HITACHI 652 Supplement: Load instruction register (UR) low shows that instruction opcode is on Jhe data bus. 111.5.4 Accepting an IS Interrupt Question: Is an input strobe (IS) interrupt accepted during the execution of the IRQ1 interrupt routine? Answer: Yes. When an IS interrupt is generated during the execution of the IRQ1 interrupt routine, with the input strobe enable (IS IRQ1 ENABLE) being set, and the IS flag is set; 1. It is accepted if the interrupt mask bit (I) of condition code register (CCR) has been cleared. However, in this case, the interrupt factor of the IRQ1 must have been cleared before clearing the I bit, that is, by setting the IRQ1 pin low and clearing IRQ1 E. 2. If the I bit of the CCR is set, it is accepted after the IRQ1 interrupt routine finishes. Supplement: Since the IRQ1 and IS share an interrupt vector, levels of the input strobe flag (IS FLAG) and IRQ1 pin are checked to determine which interrupt is generated, by reading P50 (bit 0 of port 5). 111.6 Oscillation Circuit 111.6.1 E Clock Triggering Question: With which edge of the EXTAL clock does the E clock change, the rising or falling edge? Answer: It changes synchronously with the falling edge (figure 111-15). I Figure 111-15. E Clock Timing 111.7 Reset 111.7.1 Ports at Reset Question: What is the state of each port at reset? Answer: It is as shown in table 111-8. ~HITACHI 653 Table 111-8. Port State at Reset Port Mode Reset 1 (AO-A7) 1,2 High 3 High impedance 2 1,2 High impedance 3 High impedance 3 (00-07) 1,2 High impedance 3 High impedance 4 (Aa-A15) High 2, 3 High impedance 5 1,2 High impedance 3 High impedance 6 1,2 High impedance 3 High impedance / 7 1,2 Note 1 3 High impedance Note: 1. RD, WR, R/W, LlR = high; SA = low Supplement: E clock at reset is output at normal frequency after oscillation stabilization time. 111.7.2 I/O Port Output After Reset Question: What data does an I/O port output when the data direction register '(DDR) = 1 after reset? Answer: After reset, undefined data is output from the I/O port, since the data register of an I/O port is undefined. For the output state, put data in the data register before setting the DDR = 1. ~HITACHI 654 111.7.3 RES Schmitt Trigger . Question: Is a Schmitt trigger circuit provided with RES? Answer: Yes (figure 111-16). q, 1> I I Internal reset signal RES pin Ol----ID o Internal Figure 111-16. Reset Circuit 111.7.4 Reset Circuit Capacitance Question: Does Cr in the reset circuit shown in figure 111-17 (Rr x Cr > 20 ms), have an upper limit? Rr Cr ;J; STSY RES I L-------~---~PORT Release Standby mode Rr· Cr > 20 ms (External input) Figure 111-17. Reset Input Circuit Answer: No, because RES is provided with a Schmitt trigger circuit (figu re 111-1 6). ~HITACHB 655 111.7.5 State of I/O Ports during the 20 rns after a Power-on Reset Question: What state are I/O ports in for the 20 ms after a power-on reset during which time the oscillation is unstable? Answer: The 1/0 ports are in the reset state immediately after a power-on reset because it is directly controlled by the RES pin. However, at this time, the contents of the data register of each port are undefined (figure 111-18). Internal reset signal I/O port Inside of the LSI Figure 111-18 Reset Circuit 111.7.6 State of Port 4 after a Reset Question: What is the state of port 4 (8 bit 1/0 port) of the HD6301 YO after a reset? Answer: Table 111-9 shows the state of port 4 after a reset. Table 111-9. Port 4 After Reset Mode State of port 4 Mode 1 Address bus high-order output (*1) Extended modes Mode 2 Input port Single chip mode Mode 3 Input port *1: In mode 1, the data direction register (DDR) is forcibly set and port 4 outputs high-order addresses. ~HITACHI 656 111.7.7 State of Address Bus if Reset during Operation Question: If reset occurs during operation, when does the address bus become $ FFFF? Answer: Timing of RES and the address bus are as follows (figure 111-19). E Address Bus Mode 2 Port 4 Address High impedance Bus Figure 111-19. Timing of RES and the address bus 111.8 Low Power Dissipation Mode 111.8.1 Standby During Instruction Execution Question: Does the CPU wait until the current instruction is executed to enter the standby mode? Answer: No. The CPU enters standby mode regardless of the current instruction; the CPU goes into reset' condition and the oscillator stops with STBY low (figure 111-20). I-- Oscillator Stop Internal reset I I E r Figure 111-20. E During Standby • HITACHI 657 111.8.2 Standby Timing Question: The timing for the standby mode is shown in figure 111-21 (see also figure 3-5). Is T1 in the figure defined? vcc vcc CDNMll I I I I I T I CD NMI I I t I I I r---t I ® RES I I ~~"fo-I I MCU I STBY I 111111 I I 7/ I I I I 0 I I I I I I I o STBY I I ,{I I I stoscillator RES I I11111 I I f : Stabilization I I I I I Time ® I I I I I 'I ... • I1.- .1 .. Standby Mode I I I o Register Save o RAM/port 5 control register set Restart Figure 111-21. Standby Mode Timing Answer: It is not, but if the time for nonmaskable interrupt (NMI) is guaranteed, either RES or STBY can go low with no priority. Supplement: The CPU goes to the standby mode independently of instruction execution sequence. Use the NMI routine before entering standby mode. 111.8.3 Ports at Standby Question: What is the state of each I/O port during standby? Answer: Each I/O port and the E pin during standby are high impedance. 111.8.4 Return from Standby Without Reset Question: What occurs when the CPU returns from the standby mode without using reset start? Answer: The CPU does not operate normally because the contents of each register are not defined. Therefore, always use the reset start when returning from the standby mode. ~HITACHI 658 111.8.5 Sleep and Standby Internal States Question: What are the internal states in the sleep or standby mode? Answer: They are as shown in table 111-10. Table 111-10. Sleep and Standby Mode States Sleep Mode Standby Mode Oscillation circuit Continues Stops CPU (register) Stops (retained) Stops (undefined) RAM Retained Retained 1/0 Retained High impedance Timer Continues Stops Serial communications Continues Stops Internal registers Retained Reset Cancel Interrupt Reset start after STBY = high STBY= low (at hardware standby) Reset start Reset start (at software standby) Supplement: Internal states in the standby mode are the same as those in reset. Use the reset start when returning from the standby mode. In this case RES should be kept low from STBY = high during oscillation stabilization time (20 ms minimum). 111.8.6 Sequence of Going to Standby Mode by Software Question: How can the CPU go to the standby mode using software? Answer: The CPU can go to the standby mode using software by clearing the standby flag (STBY FLAG) of the RAM/port 5 control register. In this case, before going to the standby mode, the standby power bit (STBY PWR) of the RAM/port 5 control register must be set and the RAM enable bit (RAM E) should be cleared. Below is shown an example of the method of going to the standby mode by software. o OIM #$80, $14 - - - (Setting STBY PWR) AIM #$9F, $14 - - - (Clearing RAME, STBY FLAG) ~HnTACHH 659 111.8.7 Timing of Going to the Standby Mode by Software Question: In the case that the CPU goes to the standby mode by clearing the standby flag (STBY FLAG) of the RAM/port 5 control register, how many cycles after clearing does the oscillator stop and does the CPU go into the standby mode? Answer: The oscillator stops and the CPU goes to the standby mode at E clock's low level of the first cycle after the STBY FLAG is cleared (figure 111-22). Clearing STBY FLAG E -----------~ STBY FLAG Standby mode Figure 111-22 Timing of Standby Mode by Software 111.8.8 Writing to STBY PWR Gluestion: Is it possible to write "0" into the standby power bit (STBY PWR) of the RAM/port 5 control register? Answer: Yes. The STBY PWR can be used as a normal read/write flag. 111.9 Software 111.9.1 Bit Manipulation Instructions Question: How should the bit manipulation instructions of the HD6301Y0, HD6303Y, and HD63701Y0, be written? Answer: They are written as shown in figure 111-23. OIM # $ 0 4. $ 1 0 (Direct Addressing) OIM # $ 0 4 • $ 1 0 • X (Index Addressing) I+~ Immediate Data Address Index Register Figure 111-23 OIM Example This is an example of an OR operation between the immediate data and the memory which stores the result in the memory. The AIM, ElM, and TIM instructions are written in the same way. ~HITACHI 660 The bit manipulations in table 111-11 have different mnemonics with the same opcode. Table 111-11. Shared Opcodes Bit Manipulation Instructions Haying the Same QDcode Instruction Mnemonic Function AIM BCLR OANDMi The memory bit i (i = 0 to 7) is cleared and the other bits don't change OIM BSET 10RMi The memory bit i (i = 0 to 7) is set and the other bits don't change ElM BTGL MiEORMi The memory bit i (i = 0 to 7) is inverted and the other bits don't change TIM BTST 1 AND Mi AND operation test of the memory bit i (i = 0 to 7) and 1 is executed and its corresponding condition code is changed. The mnemonics mentioned above can be written as in figure 111-24. BelR 3,$10 - - AIM #$F7. $10 (Direct Addressing) BClR 3,$10,X - - AIM #$F7, $10,X (Index Addressing) I BSET 3,$10 OIM #$08, $10 (Direct Addressing) BSET 3,$10,X OIM #$08, $10,X (Index Addressing) ~f Bit Address Index Register Figure 111-24. Shared Opcode Instruction Format 111.10 Others 111.10.1 RAME Disabled Question: When executing a program with the RAM enable bit (RAME) of the RAM/port 5 control register disabled (RAME =0), 1. What occurs Hthe internal RAM address is accessed? 2. What occurs if Interrupt requests are generated? Answer: 1. The Internal RAM cannot be accessed, It Is neither readable nor writable with RAME = 0, so In mode 1 or 2, the external memory Is read/written Into, 2. Interrupts are accepted, but the CPU will fall when returning from the Interrupt with no ~HITACHI 661 stacking area other than the internal RAM. Supplement: 1. RAME = 0; internal RAM is invalid. In modes 1 or 2, data can be read from the extemal memory. 2. RAME = 1; internal RAM is enabled. 111.10.2 RAME at Reset Question: Is the RAM enable bit (RAME) set on reset at RES low or the rising edge of RES? Answer: It is set at the rising edge of RES (figure 111-25). Internal RAM Disable --r-- I Internal RAM Enable (RAME=O) : (RAME=1) I I Figure 111-25. RAME at Reset Supplement: RAME is seVcleared by the software. 1. RAME = 0; Internal RAM is invalid. In mode 1 or 2, data can be read from the external memory. 2. RAME = 1; Intemal RAM is enabled. ~HITACHI 662 Appendix IV: The Differences Between HD63701 YO and HD6301YO Item HD63701YO HD6301YO Input low VIL = 0.6 V max VIL = 0.8 V max voltage of RES, MPo, MPI lin and Cin lin = 10 pA max lin = 1.0 pA max of RES Cin = 65 pF max Cin = 12.5 pF max lin and Cin are larger than HD6301 YO because RES is also used as VPP. Crystal Internal resistance Internal resistance oscillator of crystal oscillator Rs of crystal oscillator Rs characteristics Frequency (MHz) Rs = 60n max Rs max (0) Storage TsIg = -55 to 125'C TsIg = -55 to 150'C temperature Caution The HD63701 YO differs from HD6301 YO in chip design and manufacturing process. When applying the HD63701 YO system to HD6301 YO, and HD6301 YO system to HD63701 YO, note that characteristic values are not exactly the same even if guaranteed values are the same. I • HITACHI 663 Appendix V: Program Development Procedure and Support System . V.1 Overview The cross assembler and the hardware emulator using various types of computer are prepared by the company as supporting systems to develop user's programs. User's programs are mask programmed into the ROM and delivered as the LSI by the company. Figure V-1 shows the typical program design procedure and table V-1 shows the system development support tool for the HD6301YO which are used in these processes. Text Editor/CRT Editor Host Computer Cra .. Auembler Host Computer Emulator, EPROM On-Chip LSI, HD63701VOC Figure V-1. Program Design Procedure ~HITACHI 664 (Explanation) 1. When the user programs the system using the HD6301 YO series, a functional assignment of each I/O pin and an allocation of RAM area should be specified adjusting to designed system before actual programming. 2. A flowchart is designed to implement the functions and it is coded by using the HD6301 YO mnemonic code. 3. Write the software coded according to the flowchart on a floppy disk to make a source program. 4. Assemble the source program to generate an object program using a computer. Assembly errors are also detected. S. Verify the program through hardware emulation with an emulator, H68SDS/SA, H680SD200 or EPROM on-chip type microcomputer. 6. Send the completed program to the company in the form of EPROM. Send Single-chip microcomputer order specification and Mask option list at that time. 7. ROM and mask option are masked by the company. LSI is testatively produced and the sample is handed in to the user. If a user doesn't see any problem in programming, mass production can be started. Table V-1. Support Tools Part No. Emulator Set EPROM EPROM On-Chip LSI IBM PC' Cross IBM PC On-Chip LSI Programming Assembler C Compiler Socket Adaptor HD6301YO H31MIX3 HD63701YOC HS31 YESS11 H S311BM PC US31 PCLl1 SF I HD6303Y (HS31 YEML03H) Notes: IBM PC IS a trademark of International Business Machine Corporation. CCompllor _ _ _ _ __ HD6301YO and HD6303Y Development Tools ~HITACHI 665 V.2 Single Chip Microcomputer ROM Ordering Procedure V.2.1 Development Flowchart Single chip microcomputer device is developed according to the following flowchart after program development. Device Development Flowchart Hitachi Customer Remarks ---- 1 ROM code *1 *1 2 sets of EPROM 2 Mask Option List *2 3 Ordering Specifications *2 Part specific *3 *3 Generic for Hitachi Microcomputer IComputer processing , ROM code for confirmation of ROM fabricating * 4 The same ROM code as specifications *4 submitted OK 4 Verification Listing *5 *5 Send it back after approving I Mask I Sample IWorking Sample (WS) *6 *6 3 pcs. + Confirmation of function, *7 Start the following 15 Characteristics *7, *8 flowchart after approving *8 Send back signed working sample approval form. OK *9 10 pcs. t l Engineering Sample (ES) *9 IConfirmation of function, l characteristics, quality ICommercial Sample (CS) (E~D) Nole: Please send in 1 , 2, and 3 at ROM ordering, and send back 4, 5 after approving. @HITACHI 666 V.2.2 Data you send and precautions (a) Ordering specifications .................... Common style for all Hitachi single cnip microcomputer devices. Please enter as for the followings. The format is shown in the next page. Basic ITEM Environment Check List Check List of attached data Customer (b) ROM code ................................ Please send in the ordering ROM code by 2 sets of EPROM the same contents are written. Enter ROM code No. in them. It is desirable to send in program list for easy confirmation of the program contents. V.2.3 Change of ROM code Note that if you change the ROM code once sended in or other specification, the ROM must be developed from the beginning. The cost of mask charge should be provided again in this case. V.2.4 Samples and Mass production (Working Sample) ............................ Sample for confirmation of the contents of ROM code and that of mask option. Normally 3 samples are sent, but not guaranteed as for reliability. Please evaluate and approve immediately because the following sample making and m~ss production are set about after obtaining your evaluation. (Engineering Sample) ......................... Sample for evaluating also reliability. 10 pcs are included in mask charge. (Commercial Sample) ......................... Samples for pre-production which may be purchased separately. (Mass Product) ............................... Products for actual mass production. Please enter the plan of mass production in full. ~HITACHI 667 V.2.5 HD6301YO ORDERING SPECIFICATIONS (1) GENERAL CHARACTERISTICS (Fill in blank space or check appropriate box 0 .) Customer Device Package Outline (See page 523.) o DP-64S OCP-68 Type DFP-64 Application Options/Remarks: (be specific) Customer ROMCodelD ZTAT™ Conversion DYes DNo ROM Code Media o EPRO~ D ZTAT Must Specify: Customer Programmed Start Address Customer Programmed Stop Address ------1 Operating Temperature o 0 Standard J (-40· C to +85· C) version if offered Remask o D Yes No Previous Hitachi PIN - - - - - - - - - - - (2) OPERATING CHARACTERISTICS (Fill in blank space or check appropriate box [i].) LSI Typical ·C Target Level o lOOOFit O( ) Ambient Temperature Range ·C- ·C Of Reliability o 500Fit LSI Typical % Acceptable Electrical [ ] 0.25% [ ]( ) Ambient Quality Humidity Range %- % Level Major Visual D 0.65% 0 ( ) Power On Typical Hours/Day LSI Operating Speed I (Specify MHz or KHz) Duration Remarks: Power Max. V Maximum Applied Supplv Voltage To LSI I/O Max. V (3) ELECTRICAL CHARACTERISTICS (Fill in blank space or check appropriate box [Xl.) o Purchasing Specifications (0 Hitachi's Standard Specifications Refer To Data Sheet: ( For Hitachi Use Only) (4) CUSTOMER APPROVAL (5) ROM CODE VERIFICATION Customer Name'--_ _ _ _ _ _ _ _ _ _ _ __ LSI Type No. PO# _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ___ Shipping Date of Approved By (print),_ _ _ _ _ _ _ _ _ _ _ __ ROM To Customer Approved By (signature)_ _ _ _ _ _ _ _ _ __ Approved Date of Date ROM From Customer ~HITACHI 668 HD6301/HD6303 SERIES HANDBOOK Section Seven Software Application Notes I ~HITACHI 669 ~HITACHI 670 FOREWORD The HD630l/HD6303 is a family of 8-bit single chip CMOS microcomputers controlled by microprogramming. This family aids high speed data process by adding bit operation instruction, logical operation instruction, lower power consumption mode instruction, and accumulator and index register swapping instructions and adoping pipeline control, compared with the NMOS HD680l/HD6803 FAMILY. APPLICATION NOTES summarize typical programs for the HD630l/6303 FAMILY to help users better understand instruction set and to provide them with references for making more customized programs. Programs described in APPLICATION NOTES have already been debugged. However, please be sure to check the operation in actual use. I ~HITACHI 671 Section 7 Software Application Notes Table of Contents Page 1. HOW TO USE APPLICATION NOTES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 1.1 Formats..................................................... 675 1.1.1 Specification Format (Format 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677 1.1.2 Description Format (Format 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 1.1 .3 Flowchart Format (Format 3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 1.1.4 Program Listing Format(Format 4). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688 1.2 How to Execute Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 690 1.3 Symbols..................................................... 692 PROGRAM APPLICATION EXAMPLES Program Application Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 693 MOVING DATA 1. Filling Constant Values (Fill) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694 2. Moving Memory Blocks (Move) . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . .. 698 3. Moving Strings (Moves) .< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 BRANCHING FROM TABLE 4. Branching From Table (CCASE) ................. '. . . . . . . . . . . . . . . . . .. 708 HANDLING ASCII 5. Converting ASCII Lowercase Into Uppercase (TPR) .. . . . . . . . . . . . . . . . . .. 714 6. Converting ASCII Into 1-Byte Hexadecimal (Nibble). . . . . . . . . . . . . . . . . . . .. 719 7. Converting 8-Bit Binary Data Into ASCII (COBYTE) . . . . . . . . . . . . . . . . . . . .. 724 BIT MANIPULATION 8. Counting Number of Logical "1" Bits In 8-Bit Data (HCNT). . . . . . . . . . . . . .. 729 9. Shifting 32-Bit Data (SHR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 COUNTER 10. 4-Digit BCD Counter (DECNT) 738 COMPARISON 11. Comparing 32-Bit Binary Data (CMP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743 @HITACHI 672 ARITHMETIC OPERATION 12. Adding 32-Bit Binary Data (ADD)'. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 749 13. Subtracting 32-Bit Binary Data (SUB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 755 14. Multiplying 16-Bit Binary Data (MUL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 761 15. Dividing 16-Bit Binary Data (DIV). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 768 16. Adding 8-Digit BCD (ADDD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 774 17. Subtracting 8-Digit BCD (SUBD). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 780 18. 16-Bit Square Root (SQRT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 786 CONVERTING BCD INTO HEXADECIMALS 19. Converting 2-Byte Hexadecimals Into 5-Digit BCD (HEX) . . . . . . . . . . . . . .. 791 20. Converting 5-Digit BCD Into 2-Byte Hexadecimals (BCD) . . . . . . . . . . . . . .. 796 SORTING 21. Sorting (SORT). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 803 I ~HITACHI 673 ~HITACHI 674 1. How to Use APP.LICATION NOTES 1.1 Formats APPLICATION NOTES consist of Formats 1 to 4, shown in Fig. 1.1. FUNCTION ARGUMENTS CHANGES IN CPU REGISTERS AND FLAGS Format 1 ,I PROGRAMLISTlIIG I i'CU/MPU IHD6)OI/~D6)Ol FAMILY LABEL I SHR Format 1 SPECIFICATIONS DESCRIPTION / L..I I ~U/Hl'U 11ID6l01/IID6JOl FAMILY ILAIlEL I ,HR InOllClIART I I DESCRIPTION fu:;-cnON I )I£U/KPU n;UfMPlJ iHD6JOI/HD6l0lFAH1LY 11lD6)OI/IW6JOl fAMILY ILABEL ILNIEL I SIIR SIIR lFun"inn Details User Notes ARGlW:NTS CRANGESINCPU RECISTERSANDFLACS SPECIFICATIONS I SPECIFICATIONS NOTES --I Byt~ ROt-: (Ilytu) CUL1'~nt. ~~:~~~:~ I.gth . . ' Not affected • : Undefined I :Ile.ult RAH(llytea) ~'" ~" ~" ----;-;;~k(lly~~ Format 2_DESCRIP- RAM 10 No.ofcy<:les "I TION Description ReentT ~ SHIFTING 32-BIT DATA ~-l---------l O[ Item number Program name (2) MCU/MPU: Indicates names of microcomputer and microprocessor family applicable to a program. )DB ~101nm6303 F~ILY O( ~Microcomputer and microprocessor family name: HD630l/HD6303 FAMILY (3) LABEL: Indicates the name identifying program entry point. When using a program as it is, call the label "SHR". )~8~ Entry point label: SHR (4) FUNCTION: Explains program functions. FUNCTION I (a) Shifts 32-bit binary data in IX and ACCD to right. (b) Permits number of shifts to be freely determined. (c) Permits easy multiplication of 32-bit binary data by 2-n . (n:number of shifts) ~HITACHI 678 (5) ARGUMENTS: Explains entry arguments which must be set before execution of a program, and return arguments after execution. (a) Contents: Explains meanings of arguments. (b) Storage Location: Indicates registers and RAMs in which arguments are to be set. The RAM is presented as a labe 1 fo llowed by "(RAM)". (c) Byte length: Indicates byte length of the arguments. ARGUMENTS I Storage Byte Contents Location Lgth. Upper 16 bits of 32-bit binary IX 2 data to be shift- ed to right Entry Lower 16 bi ts of 32-bit Argu- ments binary ACCD '2 data to be shift- ed to right Number of SFCNTR 1 shifts (RAM) Upper 16 I bits of IX 2 shift Re- result turns Lower 16 bi ts of ACeD 2 shift resul t (6) CHANGES IN CPU REGISTERS AND FLAGS: Explains changes in CPU registers after executing a program and flag changes of condition code register. Meanings of ab- breviations and symbols in the table are given as follows: (a) CPU register ACCA: Accumulator A ACCB: Accumulator B ACCD: Double accumulator (ACCA:ACCB) IX: Index register ~HITACHI 679 (b) Flags of condition code register C: Carry/borrow flag (carry and borrow) Y: Overflow flag (Indication in case of 2's complement operation) . Z: Zero flag (Indication in case of 0) N: Negative flag (Indication in case of negative) I: Interrupt flag (Interrupt mask) H: Half carry flag (Carry from bit 3 to bit 4) (c) State of CPU registers and condition code register flags .: Not affected: Maintains previous values after executing a program. x: Undefined Does not maintain previous values after executing a program. ; : Result Be set with the result of executing a program CHANGES IN CPU REGISTERS AND FLAGS (Notes) • : Not affected In the example, after executing a program, x : Undef ined contents of index register (IX), condition I : Result ACCD code register (CCR), bit c, bit V, bit Nand ACCA ACCB bit Z will be destroyed. Thus, register I I IX contents which will be destroyed should be ~ \.....-.!- saved before executing a program. C V x x Z N x x I H • • (7) SPECIFICATIONS: Explains program specifications. (a) ROM (Bytes): Indicates ROM capacity used in a program. (b) RAM (Bytes): Indicates RAM capacity used in a program. (c) Stack (Bytes): Indicates stack size used in a program. The RAM capacity in this table does not include the stack size. When the program is executed, ~HITACHI 680 it is necessary to reserve the stack size in RAM. (d) No. of cycles Indicates maximum number of execution cycles when MCU executes a program. Calculate the execution time of the program as follows: Execution time (sec) = Cycle number x cycle time Cycle time (sec) 4/(External oscillator (Hz» (e) Reentrant Indicates whether a program has a structure which can be called from two or more routines at the same time. (f) Relocation Indicates whether a program can be located in any memory space. (g) Interrupt Indicates whether MCU executes a program normally after serving an interrupt routine during program execution. If impossible, inhibit interrupt before the program is called. SPECIFICATIONS ROM (Bytes) 11 I RAM (Bytes) 1 Stack (Bytes) 0 No. of eye les 261 Reentrant No Relocation No Interrupt Yes @HITACHI 681 (8) DESCRIPTION: Explains function details and user notes of a program. (a) Function Gives an execution example and detailed func- Details tions of a program. (b) User Notes Explains notes and limitations when executing a program. ,~ Be sure to read these items when using the programs without change. DESCRIPTION (1) Function Details (a) Argument details IX Holds upper 16 bits of 32-bit binary data to be shifted to right. After SHR execution, contains upper 16 bits of shift result. ACeD Holds lower 16 bits of 32-bit binary data to be shifted to right., After SHR execution, contains lower 16 bits of shift result. SFCNTR: Holds number of shifts. (RAM) (b) Fig. 1 shows example of SHR execution. If entry arguments are held as shown in part Q) of Fig. 1, 32-bit binary data is shifted to right as shown in part @of Fig. 1. In this case, "0" in upper 2 bits. b7 SFCNTR bO b31 IX ACCD bO CD ~:~~::ntst ~~~~~~~ B3) 101011111010 1110101110 10101110111010101110111+1110111110101111 I Fig. 1 Example of SHR execution (2) User Notes Number of shifts should be held within range of $01 to $lF, otherwise ACCD and IX become "0". (9) SPECIFICATIONS NOTES: Explains notes on data process written in SPECIFICATIONS (7). SPECIFICATIONS NOTES I "No. of cyc les" in "SPECIFICATIONS" represents the number of cycles needed to shift 32-bit binary data 16 bits right. ~HITACHI 682 1.1.2 DESCRIPTION Format (Format 2) The DESCRIPTION Format is represented in Fig. 1.3. It gives remaining Function Details, User Notes, RAM Description. Sample Application and Basic Operation. Each item in the format is described using Fig. 1.3. ITEM NUMBER AND PROGRAM NAME I MCU/MPU I HD630l/HD6303 FAMILY I LABEL I DESCRIPTION 1 (3) RAM Description (4) Sample Application (5) Basic Operation I Fig. 1.3 DESCRIPTION Format (1) ITEM NUMBER AND PROGRAM NAME } (2) MCU/MPU Same as SPECIFICATION Format (3) LABEL ~HITACHI 683 (4) DESCRIPTION: Gives RAM Description, Sample Application, and Basic Operation. (a) RAM Description: Explains label and meaning of the RAM used in a program. 9. SHIFTING HD630l/HD6303 FAMILY SHR DESCRIPTION (3) RAM description Label RAM Description b7 bO SFCNTR Ll_______--'l Number of shifts is stored. (b) Sample Application: Gives a sample application in actual use. (4) Sample Application Subroutine SHR is called after number of shifts and 32-bit binary data to be shifted to right are held. wORln RMB 4 ----------- Reserves memory byte for 32-bit binary data. WORR2 RMB 1 ----------- Reserves memory byte for number of shifts. WORR3 RMB 4 ----------- Reserves memory byte for shift result. LDM WORK2 L____ Stores number of shifts into STM SFCNTR r entry argument (SFCNTR). LDX WORKl ~ ____ Loads 32-bit binary data to be shifted to LDD WORK 1+2 ~ right into entry argument (IX, ACCD) • "II_J_S_R_ _ _S_H_R_.J.JII----- Calls subroutine SHR. SIX WORK 3 } Stores shift result (return argument SID WORR3+2 (IX, ACCD» in RAM. ~HITACHI 684 (c) Basic Operation: Indicates operating principles of a program. (5) Basic Operation (a) Uses 16-bit shift instruction (LSRD) provided in the HD6301/HD6303 FAMILY. (b) Upper 16 bits in 32-bit binary data are shifted to right. Here LSB is rotated to bit c. Lower 16 bits are rotated to right. At this time, LSB in bit C Is rotated to MSB of lower 16 bits. (c) SFCNTR(RAM) is used to keep track of number of shifts. SFCNTR(RAM) is decremented every time (b) is executed. (d) Loops (b) to (c) until SFCNTR (RAM) is "0". / I ~HITACHI 685 1.1.3 FLOWCHART Format (Format 3) The FLOWCHART Format is represented in Fig. 4. It gives a program flowchart. Each item in the format is described using Fig. 1.4.

9. SHIFTING HD6301/HD6303 FAMILY SHR FLOWCHART ___ { Exchanges upper 16 bits with lower 16 bits in 32-bit binary data. ___ { Shifts upper 16 bits in 32-bit binary data to right, and shifts LSB to bit C. Exchanges upper 16 bits with lower 16 bits --- { in 32-bit binary data. Rotates lower 16 bits in 32-bit binary --f data to right. Rotates LSB of upper 16 bits to MSB of lower 16 bi ts. '-------r---------l ---{ Decrements shift counter. ---{ Tests if shift is completed. I ~HITACHI 687 1.1.4 PROGRAM LISTING Format (Format 4) The PROGRAM LISTING Format is represented in Fig. 1.5. Each item in the format is described using Fig. 1.5. (1) ~ ITEM NUMBER AND PROGRAM NAME I HeU IMPU 11ID6301/1lD6303 FAMILY I LABEL I ( 4 )-- PROGRAM LI STING I Fig. 1.5 PROGRAM LISTING Format (1) ITEM NUMBER AND PROGRAM NAME } (2) MCU/MPU Same as SPECIFICATION Format (3) LABEL ~HITACHI 688 (4) PROGRAM LISTING 9. SHIFTING 32-BIT DATA I MCU/MPU 11ID6301/1ID6303 FAMILY I LABEL I SHR PROGRAM LISTING I (al 00001 00002 00003 NAME SHIFTING 32-8IT DATA (SHR) 00004 00005 00006 "'."''''lI< (b) ~:* ole '" "'II< *** "'>Ie'" '" "''''II< "''''''''''lie''''''''''''''''''", *********** "'II< "': 00007 ~: IX IX ---I Increments source address. ~-P-U-S-H-'-(-I-X-)-~ - - - { Saves source address. ~::::::r:::=:~ - --I Loads destination address into IX. L-(_A_C_C_A_)r-->_~_( _I_X_]----I ---I Transfers data in source area to destination area. Increments destination address. '--_(_1_X_)_+_1->_I_X_---l - - - { 1-(_I_X_)_->_D_ErA_:_D_E_A_+_1...J ---I Saves destination address. PULL IX ---{ Restores source address in IX. L-..--~---{ Decrements counter indicating byte length to be moved. ---I L Tests if move is completed. I R T S ~HITACHI 701 2. MOVING MEMORY BLOCKS ! MCU/MPU !lID630l/HD6303 FAMILY ILABEL I MOVE PROGRAM LISTING I 00001 ************************************************ 00002 '" '" 00003 NAME : MOVING MEMORY BLOCKS (MOVE) '" 00004 '" '" '*******************~****************************d " 00005 00006 ,. 00007 '" ENTRY IX (SOURCE ADDR) '" OOOOB '" DEA (DESTINATION ADDR) '" 00009 ' " ACCB (TRANSFER COUNTER) 00010 '" RETURNS : NOTHING '" 00011 '" '" ,. 00012 '"************************************************ 00013 00014A OOBO '" ORG $80 00015 ,. 00016A 0080 0002 A DEA RMB 2 Destination ADDR 00017 00018A FOOO ' " ORG $FOOO 00019 00020 ' FOOO A MOVE" EQU Entry point 00021A FOOO A6 00 A LDAA 'O.X " Load transfer data 00022A F002 08 INX Increment source ADDR 00023A F003 3C PSHX Push source ADDR 00024A F004 DE 80 A LDX DEA Load destination ADDR 0002SA F006 A7 00 A STAA O.X Store transfer data 00026A F008 08 INX Increment destination ADDR 00027A F009 OF 60 A STX DEA Store destination ADDR 00028A FOOB 38 PULX Pull sorce ADDR 00029A FOOC SA DECB Decrement transfer counter 00030A FOOD 26 Fl FOOO BNE MOVE Loop until transfer counter 0 00031A FOOF 39 RTS • HITACHI 702 3. MOVING STRINGS I MCU/MPU I HD630l/HD6303 FMIlLY ILABEL I MOVES FUNCTION I (a) Moves data block in memory to RAM. (b) Terminates moving process when terminator $00 is found in data block. (c) Permits source and destination addresses to be freely selec ted in memory. CHANGES IN CPU SPECIFICATIONS ARGUMENTS I REGISTERS AND FLAGS • x : No t aff ec ted : Undefined ROM (Bytes) 17 Contents Storage Location Byte Lgth. I : Result RAM (Bytes) ACCD 2 Source ACCA ACCB Stack (Bytes) starting IX 2 Entry address Destina- IX x • 2 No. of cycles tion DEAS(RAH) 2 x 507 Argu- starting ments address Reentrant C V No Re- turns - - - • Z x N Relocation No x x Interrupt I H Yes • • DESCRIPTION 1 [" bIS IX bO (1) Function Details CD 1 Entry ($Fooo) I F : 0 I 0 DfJVl : I 0 OFASII arguments P~~~~~ff) I 0 I•: I I : 0 0 (a) Argument details + Address space IX : Holds source starting address ~ in 2-byte hexadecimal number. Oest in.1t ion ..... $OO~Hl stArling $FF ;tddre,c:~ $ 2 (I DEAS(RAM): Holds destination starting OEAS (RAM) I } De"i""cio" I data block address in 2-byte hexade- I ~ cimal number. @Result (b) Fig. 1 shows example of MOVES execution. Sourc .. III ortins"'$r-ooo $FF nddtells IX If entry arguments are as shown in part CD of $ Z I) Fig. 1, data in source ($FOOO) is moved to I I I }OOU' block"" d"," Terminator; $H • destination ($0090) as shown .- indica ting $OU the end of ~ data block Fig. 1 Example of MOVES execution SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed, when terminator is put at the 16th byte. ~HITACHI 703 3. MOVING STRINGS MCU/MPU HD6301/HD6303 FAMILY MOVES DESCRIPTION in part(1)of Fig. 1. When it loads terminator $00, MCU terminates moving process. (2) User Notes (a) Source data block is 64k bytes long or less. Last byte contains $00 as Address space termina tor. Source start~ .. o_~~~~~ __ (b) Source data must not contain any $00 address --} function other than terminator. Destination ® starting ® } (c) Holds entry arguments so that source address -- _ I< 00005 * ************************************************** 00006 * * 00007 ENTRY ACCA (COMMAND ) 00008 * IX (TABLE ADDR) * 00009 * RETURNS IX (MODULE ADDR) 00010 * CARRY(C=l:TRUE,CcO:FALES) * * 00011 * * 00012 ************************************************** 00013 * 00014A FOOD ORG $FOOO 00015 * Entry point 00016 FOOO A CCASE EQU *O.X 00017A FOOO 60 00 A TST Command 0+ teble cO? (0 -> carry) 00018~ F002 27 00 F011 BEQ CCAS2 Branch 1+ command 0+ table c 0 00019A F004 Al 00 A CMPA O.X Commend c command of table? 00020A F006 27 05 FOOD BEQ CCASl Brench 1+ sQuel 00021A F008 08 INX Increment pointer of table ADDR 00022A F009 08 INX 00023A FOOA 08 INX 00024A FOOB 20 F3 FOOO BRA CCASE Branch CeASE 00025A FOOD 08 CCASl INX Increment pointer of table ADDR 00026A FOOE EE 00 A LOX O.X Load module ADDR 00027A F010 00 SEC Set carry bit to "1" 00028A FOll 39 CCAS2 RTS I ~HITACHI 713 5. CONVERTING ASCII LOWERCASE TNTO TlPPF,Rr.ASF I MCU/MPU I HD6301/HD6303 FAMILY 1LABEL I TPR FUNCTION I (a) Converts ASCII lowercase data in ACCA into uppercase and loads result into ACCA. (b) Utilizes 7-bit ASCII in arguments. CHANGES IN CPU ARGUMENTS SPEC IFICATIONS I REGISTERS AND FLAGS •x : : Not affected Undefined ROM (Bytes) 11 Contents Storage Byte t : Result RAM (Bytes) Location Lgth. ACCD 0 ACCA ACCB Stack (Bytes) Entry Lowercase (ASCII) ACCA 1 ~ IX • 0 No. of cycles Argu- ments • 17 Reentrant C V Yes Uppercase Re- x x Relocation (ASCII) ACCA 1 turns Z N Yes x x Interrupt I H Yes I DESCRIPTION j • • (1) Function Details (a) Argument details ACCA: Holds ASCII lowercase data. ACCA b7 I ACCA bO {(,L~wercase) After TPR execution, contains theCD Entry : • I I argument a $61 corresponding uppercase data. 1 (b) Fig. 1 shows example of TPR execution. b7 ACCA bO If lowercase 'a' ($61) { ACCA I • : I I @ Return (uppercase) is held in ACCA as shown in partG) argument 'A' $41 of Fig. 1, it is converted into Fig. 1 Example of TPR execution uppercase 'A' ($41), and the result is contained in ACCA as shown in part CD of Fig. 1. SPECIFICATIONS NOTES J <€)HITACHI 714 5. CONVERTING ASCII LOWERCASE INTO UPPERCASE I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I TPR DESCRIPTION . I (2) User Notes Lowercase data should be held into ACCA, otherwise lowercase data is saved and not converted into uppercase. (3) RAM Description RAM is not used during TPR execution. (4) Sample Application Subroutine TPR is called after lowercase data is held into ACCA. WORIn RMB I ----- Reserves memory byte for lowercase data. WORK2 RMB 2 ----- Reserves memory byte for uppercase data. I I J I I LDAA WORK I Loads lowercase data into entry argument (ACCA) . Calls subroutine TPR. II JSR TPR II STAA WORK2 Stores uppercase data (return argument (ACCA)) in RAM. (5) Basic Operation (a) A compare instruction (CMP) is used to test if entry argument in ACCA is lowercase or not. (b) Entry argument and $DF are ANDed using logical AND instruction (AND), and I lowercase is converted into uppercase by clearing bit 5 of lowercase as shown in Fig. 2. (c) If entry argument is other than in lowercase, subroutine TPR does not execute any operation, and entry argument is saved. @>HITACHI 715 5. CONVERTING ASCII LOWERCASE INTO UPPERCASE MCU/MPU I HD6301/HD6303 FAMILY I LABEL I1!PR DESCRIPTION I bi t 7 6 5 4 3 2 1 0 ~ ~.J ~ ~ ~ ~ ~ a($61) 0 1 1 0 0 0 0 1 b ( $ 6 2 ) 0 1 1 0 0 0 1 0 c($63) 0 1 1 0 0 0 1 1 Lowercase (bit 5="1") I z($7A) 0 1 1 1 1 0 1 0 '== A($41) 0 1 Q0 0 0 0 0 1 B($42) 0 1 0 0 0 0 1 0 C($43) 0 1 0 0 0 0 1 1 Uppercase (bit 5="0") I Z($5A) 0 1 0 1 1 0 1 0 !::: Fi g. 2 Lowercase and uppercase of 7-bit ASCII ~HITACHI 716 5. CONVERTING ASCII LOWERCASE MCU/MPU HD630l/HD6303 FAMILY TPR INTO UPPERCA.~SE~.-__________~________~__________________~____~____~ FLOWCHART TPR (ACCA)<'a' Tests if entry argument is within range of ASCII lowercase 'a' to ASCII lowercase 'z'. (ACCA» 'z' Clears bit 5 of lowercase and converts it into uppercase. I ~HITACHI 717 5. CONVERTING ASCII LOWERCASE INTO UPPERCASE I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I TPR PROGRAM LISTING I 00001 ************************************************ 00002 ** NAME : CONVERTING ASCII LOWERCASE INTO 00003 ** 00004 * UPPERCASE (TPR) * 00005 * * 00006 ************************************************ 00007 * * 00008 ENTRY ACCA (ASCII LOWERCASE) * 00009 * RETURNS ACCA (ASCII UPPERCASE) 00010 * * 00011 ************************************************** 00012 * 00013A FOOO ORG $FOOO 00014 * 00015 FOOO A TPR EQU Entry paint 00016A FOOO 81 61 A CMPA *lI'a ACCA-'a' ? 00017A F002 25 06 FOOA BCS TPR1 Branch If ACCA('a' D0018A F004 81 7A A CMPA !I'z ACCA-'z' ? 00019A F006 22 02 FOOA BHI TPR1 Branch If ACCA)'z' 00020A F008 84 OF A ANOA Ij$OF Convert Lowercase Into Uppercase D0021A FOOA 39 TPR1 RTS ~HITACHI 718 6. CONVERTING ASCII INTO I-BYTE / MCU/MPU HEXADECIMAL /lID6301/HD6303 FAMILY / LABEL / NIBBLE FUNCTION I (a) Converts ASCII '0' to ' 9' and 'A' to 'F' in ACCA into I-byte hexadecimal number and loads result into ACCA. (b) Utilizes 7-bit ASCII in arguments. CHANGES IN CPU ARGUMENTS SPECIFICATIONS / REGISTERS AND FLAGS •x : Not affected : Undefined ROM (Bytes) 20 I : Result RAM (Bytes) Storage Byte Contents ACCD 0 Location Lgth. ACCA ACCB Stack (Bytes) Entry ASCII ACCA I IX I • 0 No. of cycles Argu- I-byte hexa- • 28 Reentrant ments decimal ACCA I C V Yes number Re- I x Relocation turns Conver- Z N Yes sion/not x x Interrupt bit C conver- (CCR) 1 sion I H Yes f--- • x DESCRIPTION I (1) Function Details (a) Argument details ACCA bitC b7 AceA bO if' ' :j I ACCA: Holds ASCII. After NIBBLE CD Entry {(ASCII " I argument 'F' $46 r execution contains I-byte Undefined e hexadecimal number. bitC b7 AeCA bO bit C : Shows state when NIBBLE is (] Returns (AeGA b:r te hexa- " I : F (CCR) arguments dec~mal executed. number $OF bit C=l : Shows entry argument was ASCII Fig. Example of NIBBLE execution 1 other than '0' to '9' or 'A' to 'F' . bit C=O : Shows subroutine NIBBLE is executed nomally. (b) Fig. I shows example of NIBBLE execution. If entry argument is as shown in partG)of Fig. l, $OF, data converted from ASCII into l-byte hexadecimal number, is contained in ACCA as shown in partG)of Fig. 1. SPECIFICATIONS NOTES I ~HITACHI 719 6. ~~~~~6i~LASCII INTO I-BYTE I MCU/MPU . ~ HD6301/HD6303 FAMILY I LABEL I NIBBLE DESCRIPTION I '(2) User Notes Entry argument (ASCII) should be held within range of '0' to '9' or 'A' to 'F', otherwise data in ACCA is destroyed after NIBBLE execution. (3) RAM Description RAM is not used during NIBBLE execution. (4) Sample Application Subroutine NIBBLE is called after ASCII is held. WORKI RMB I ----- Reserves memory byte for I-digit ASCII. WORK 2 RMB I Reserves memory byte for I-byte hexadecimal number. LDM WORK 1 Loads ASCII into entry argument (ACCA). II JSR NIBBLE 11----- Calls subroutine NIBBLE. BCS SKIP If ASCII is other than '0' to '9' or 'A' to 'F', branches to service routine. STM WORK2 Stores I-byte hexadecimal number (return argument (ACCA) ) in RAM. SKIP Service routine for ASCII other than '0' to '9 ' or , A' to 'F' ~HITACHI 720 6. CONVERTING ASCII INTO I-BYTE MCU/MPU HD6301/HD6303 FAMILY HEXADECIMAL NIBBLE DESCRIPTION (5) Basic Operation (a) Bit C, resulting from comparison and subtraction of data in ACCA, is used to test if the data is within range of '0' to 'F' in ASCII table (note: II II blocked area in table). (b) Addition continues between '0' and '@' . Then '.' to '@' (note:~cross hatched area in table) is delected. (c) In cases other than between '0' and '9' or 'A' and 'F', bit C is set during (a) or (b) above. Table 1. ASCII Table LSD o0 0 00 1 o1 0 1 0 1 1 1 U III 0 o 000 NUL DLE SP 1 o0 0 1 SOH DCI A Q 2 o0 10 STX DC2 B R 8 o0 1 1 ETX DC3 • C • o 1 0 0 EaT -J) C 4 D T 5 o10 1 ENG NAK % E U 6 o1 10 ACK SYN & V 7 OIL 1 BEL ETB W B 1 0 0 0 BS CAN X 9 1 0 0 1 HT EM Y A 1 0 1 0 LF SUB Z I B 1 0 1 1 VT ESC + c 1 1 0 0 FF FS D 1 1 0 1 CR GS " E 1 1 1 0 SO RS F 11Ll S[ VS / DEL ~HITACHI 721 6. CONVERTING ASCII INTO I-BYTE MCU/MPU HD6301/HD6303 FAMILY HEXADECIMAL FLOWCHART NIBBLE Tests if entry argument (ASCII) is '0' or less. (bit C)=l Tests if entry argument (ASCII) is 'G' or more. (bit C)=l Tests if entry argument (ASCII) is 'A' or more. bitN=O 'A'to'F' bi t N = I : ' 0' to '@' Tes~s if entry argument (ASCII) is within range of ':' to '@'. bit C = 0 '0' to '9' (bit C)=l bitC=I:':'to'@' ---{ Converts ASCII into I-byte hexadecimal number. - - - { Clears bit C• • HITACHI 722 6. CONVERTING ASCII INTO l-BYTE I MCU/MPU I HD630l/HD6303 FAMILY ILABEL HEXADEC IMAL I'INIBBLE PROGRAM LISTING I 00001 ************************************************ 00002 * * 00003 * NAME : CONVERTING ASCII INTO * 00004 * I-BYTE HEXADECIMAL (NIBBLE> * 00005 * * 00006 ************************************************ 00007 * * 00008 * ENTRY ACCA (ASCII ) * 00009 * RETURNS ACCA (BINARY DATA) * 00010 CARRY(C=l;TRUE,C=O;FALES) ************************************************* * 00011 00012 * 00013A FOOD ORG $FOOO 00014 * 00015 FOOO A NIBBLE EQU * Entry point 00016A FOOD 80 30 A SUBA 11'0 ACCA( ASCII code) - '0' ? OOOl7A F002 25 OF F013 BCS NIB2 Branch if ACCA<'O' 00018A F004 86 E9 A ADDA II$E9 ACCA - 'G' -> ACCA 00019A F006 25 DB FOl3 BCS NIB2 Branch if ACCA>='G' 00020A F008 8B 06 A ADDA 116 Test 'O'_I@' or 'A'-IF' 00021 A FOOA 2A 04 F010 BPL NIBl Branch if ACCA='A'-'F' 00022A FOOC 8B 07 A AODA 117 Test '0'-'9' or I: '_I@' 00023A FOOE 25 03 FOl3 BCS NI82 Branch i f ACCA=':' - , @ , 00024A FOlD 8B OA A NIBl ADDA 11M Convert ASCII into binary data 00025A F012 OC CLC CLear carry 00026A FOl3 39 NIB2 RTS I ~HITACHI 723 7. CONVERTING 8-BIT BINARY DATA I MCU/MPU INTO ASCII I HD630l/HD6303 FAMILY ILABEL ICOBYTE FUNCTION 1 (a) Converts 8-bit binary data in ACCA into two ASCII characters and stores result in RAM. (b) Utilizes 7-bit ASCII in arguments. ARGUMENTS 1 CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS •x : Not affected : Undefined ROM (Bytes) 23 Storage Byte I : Result RAM (Bytes) Contents Location Lgth. ACCD 0 ACCA ACCB Stack (Bytes) 8-bit I I 2 Entry binary ACCB 1 No. of cycles IX data • 57 Reentrant C V Yes Argu- ments x x Relocation Re- 2 ASCII Z N Yes ACCD 2 turns characters x x Interrupt I H Yes • • DESCRIPTION I (1) Function Details (a) Argument details ACCB b7 ACCU bO CD Entry {(8-bit binary) I f' : 3 I ACCB: Holds 8-bit binary data to be argument $F3 ~ ~ converted into ASCII. ACCD: Contains data converted, from ACCD b15 ACCIl bO upper and lower 4 bits of CD Return {0-digit ASCII ~~. : • I .• : .• I . . argument 'F'=$46,'3'=$33 8-bit bLnary data Lnto 2 ASCII characters. Fi g. 1 Example of COBYTE execution (b) Fig. 1 shows example of COBYTE execution. If entry argument is as shown in partCDof Fig. I, data con- verted from 8-bit binary data into ASCII is contained to ACCD as shown in part@of Fig. l. SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to convert $AA into ASCII. ~HITACHI 724 7. CONVERTING 8-BIT BINARY DATA INTO ASCII I MCU/MPU 1HD630l/HD6303 FAMILY ILABEL lCOBYTE DESCRIPTION 1 (2) User Notes 8-bit binary data stored in ACCB is destroyed after COBYTE execution. If 8-bit binary data in ACCB needs to be retained after COBYTE execution, it should be saved in memory before execution. (3) RAM Description RAM is not used during COBYTE execution. (4) Sample Application Subroutine COBYTE is called after 8-bit binary data is held. WORK 1 RMB 1 ----- Reserves memory byte for 8-bit binary data. WORK 2 RMB 2 ----- Reserves memory byte for 2 ASCII characters. LDAB WORK 1 Loads 8-bit binary data into entry argument (ACCB) . II JSR COBYTE I~---- Calls COBYTE subroutine. STD WORK 2 Stores 2 ASCII characters (return argument (ACCD)) in RAM. I ~HITACHI 725 7. CONVERTING 8-BIT BINARY DATA I MCU/MFU HD630l/HD6303 FAMILY ILABEL I COBYTE INTO ASCII DESCRIPTION I (5) Basic Operation (a) 8-bit binary data in ACCB is divided into 4 upper and 4 lower bits. (b) Divided data is then checked by a comparison instruction (CMF). If data is between $00 and $09 (H II: blocked area in ASCII table as shown in Table 1), $30 is added. If data is between $OA and $OF (C===J in Table 1), $37 is added. Result is converted into ASCII. Table 1 ASCII Table ~ LSD o 0 00 o00 o0 I OLE oI 0 SP oI I '"iI I 00 I 0 I P I 10 III , "- 0 NUL I o0 0 1 SOH DCI A Q • o 0 10 STX DC. B n a o0 1 1 ETX OCa • C • o 1 0 0 EOT DC4 0 T 5 o 10 1 ENG NAK % E U 6 o1 10 ACK SYN & F V 7 o1 11 BEL ETB -G IV 8 10 0 0 BS CAN H X • A 1 0 0 1 1 0 1 0 liT LF EM SUB * ==• Y Z B 1 0 1 1 VT ESC + K C 1 1 0 0 FF FS < L "- 0 1 1 0 1 en GS M E 1 1 1 0 SO RS > N F 1111 SI VS / ? 0 DEL ~HITACHI 726 7. CONVERTING 8-BIT BINARY DATA MCU/MPU HD630l/HD6303 FAMILY INTO ASCII COBYTE FLOWCHART ___ { Saves 8-bit binary data (entry argument). ___ { Shifts upper 4 bits of 8-bi t binary data into lower 4 bits. ---{ Converts upper 4 bits into ASCII. ___ { ~tores result of ASCII conversion l.n ACCA. ___ { Restores 8-bit binary data (entry argument). Clears upper 4 bits of 8-bit binary --- { data. ---{ Converts lower 4 bits into ASCII. Converts entry argument between $00 and $09 into ASCII. I Tests if data is $09 or less, or $OA or more. Converts data between $OA and $OF into ASCII. @HITACHI 727 7. CONVERTING 8-BIT BINARY DATA INTO ASCII I MCU/MPU I HD6301/HD6303 FAMILYjLABEL jCOBYTE PROGRAM LISTING J 00001 ************************************************ 00002 '" NAME : CONVERTING 8-BIT BINARY DATA '" 00003 ''"" INTO ASCII (COBYTE) '" 00004 '" 00005 '************************************************ " '" 00006 00007 00008 '" ENTRY ACCB (8-BIT BINARY DATA) '" '" '" RETURNS ACCD (2-BYTE ASCII) 00009 00010 '" '" '" 00011 '" ************************************************ 00012 '" 00013A FOOO ORG $FOOO 00014 00015 '" FOOO A COBYTE EQU '" Entry point 00016A FOOO 37 PSHB Push 8-bit binary data 00017A. FOOl 54 LSRB Shift upper 4 bits to Lower 4 bits 00018A F002 54 LSRB 00019A F003 54 LSRB 00020A F004 54 LSRB 00021A F005 8D 07 FOOE BSR CONIB Convert upper 4 bits into ASCII 00022A F007 17 TBA Transfer ASCII to ACCA 00023A F008 33 PULB PuLL 8-bit binary data 00024A F009 C4 OF A ANDB Ii$OF Mask upper 4 bits 00025A FOOB 8D 01 FOOE BSR CONIB Convert Lower 4 bits to ASCII 00026A FOOD 39 RTS 00027A FOOE CB 30 A CONIB ADDB 1i'0 Convert into ASCII ('0'-'9') 00028A F010 C1 39 A CMPB 1i'9 ACCB= '0'-'9' or 'A'-'F' ? 00029A F012 23 02 F016 BLS CONIB1 Branch if ACCB='0'-'9' 00030A F014 CB 07 A ADDB 1i$07 Convert into ASCII ('A'-'F') 00031A F016 39 CONIB1 RTS ~HITACHI 728 8. COUNTING NUMBER OF LOGICAL "1" BITS IN 8-BIT DATA 1MCU/MPU 1 HD6JOl/HD6JOJ FAMILY 1LABEL ·1 HCNT FUNCTION I (a) Counts number of logical "1" bits in 8-bit data in ACCA, and loads resu1t in ACCB. (b) Permits easy parity checking. CHANGES IN CPU ARGUMENTS I REGISTERS AND FLAGS SPECIFICATIONS •x : Not affec ted : Undefined ROM (Bytes) 13 Contents Storage Byte I : Result RAM (Bytes) Location Lgth. ACCD 0 ACCA ACCB Stack (Bytes) 8-bit Entry data ACCA 1 • IX I 0 No. of cycles x 82 Argu- Reentrant ments C V Yes Re- turns Number of logical "1" bits ACCB 1 • Z x N Relocation Yes x x Interrupt I H Yes • • DESr.RIPTION I (1) Function Details (a) Argument details ACCA b7 ACCA bO I CD Entry {(8-bit 10 1'1.1'1 0 1'1'1 0 1 ACCA: Holds 8-bit data whose number argument data $76) \ I of logical "1" bits is counted. There are 5 number l' s. ACCB: Contains number of logical "1" ACCB bits in 8-bit data. hi, ((The b) 1 bO (b) Fig. 1 shows example of HCNT execution. CD Return number ACe" If entry argument is as shown in argument $05 of I 0 : , I logical "1") part(Dof Fig. I, number of logical "1" bits in 8-bit data is contained Fig. 1 Example of HCNT execution in ACCB as shown in part 00f Fig. 1. (c) Contents of ACCA are saved after HCNT execution. SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to count number of logical "1" bits in $FF data. ~HITACHI 729 8. COUNTING NUMBER OF LOGICAL "1" BITS IN 8-JUT DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I HCNT DESCRIPTION I (2) User Notes When counting number of logical "0" bits, take I's complement of ACCA before HCNT execution. (3) RAM Description RAM is not used during HCNT execution. (4) Sample Application Subroutine HCNT is called after 8-bit data is held. WORI{1 RMB 1 ----- Reserves memory byte for 8-bit data. WORK2 RMB 1 Reverse memory byte for number of logical "1" bits. PSHX Saves register contents that will be destroyed by executing HCNT. LDAA WORK1 'Loads 8-bit data into entry argument (ACCA). II JSR HCNT II Calls subroutine HCNT. Stores number of logical "1" bits STAB WORK 2 (return argument (ACCB) ) in RAM. PULX ----- Restores register. (5) Basic Operation (a) IX is used to indicate number of 8-bit data rotations. (b) Using rotate instruction (ROL) , data in ACCA is loaded into bit C one by one. (c) Bit C is checked. If "1", ACCB is incremented. If "0", no operation applied. (d) IX is decremented each time (b) and (c) is executed. (e) Loops (b) to (d) until IX is "0". ~HITACHI 730 8. COUNTING NUMBER OF LOGICAL MCU/MPU H0630l/HD6303 FAMILY HCNT "1" BITS IN 8-BIT DATA FLOWCHART HeNT ~-----' ---{ 8-bit processing. Loads "8" in counter for execution of ---{ Clears counter (HI bit counter) that keeps track of number of logical "1" bits. Rotates MSB of 8-bit data to bit C. '----r-------' ---{ ___ Tests .1f 8- b·1t d ata .1S "1" or "0". { When 8-bit data 1S . 1 "1", . 1og1ca --- { increments HI bit counter. ---{ D,or'~nt' countor. ___ { Tests if 8-bit processing is completed. I L-------r-----' - - - { R,"ore, "-bit data. R T S ~HITACHI 731 8. COUNTING NUMBER OF LOGICAL MCU/MPU IlID630l/lID6303 FAMILY IWEL I HCNT "1" BITS IN 8-BIT DATA I PROGRAM LISTING I 00001 ************************************************ 00002 '" * 00003 NAME : COUNTING NUMBER OF LOGICAL "~" * 00004 '" BITS IN 8-BIT DATA (HCNT) '" * 00005 * 00006 '" ************************************************ 00007 00008 '" ENTRY ACCA (8-BIT DATA) '" 00009 '" RETURNS ACCB (HIGH BIT COUNTER) *'" 00010 '" * 00011 '" ************************************************ 00012 00013A FOOO '" ORG $FOOO 00014 * 00015 FOOO A HCNT EQU Entry point 00016A FOOO CE OOOB A LOX *l=IB Set rotate counter 00017A F003 SF CLRB Clear high bit counter 0001BA F004 49 HCNTl ROLA Rotate B-bit data left 00019A FOOs 24 01 FOOB BCC HCNT2 Branch if carry=O 00020A F007 SC INCB Increment high bit counter 00021A F008 09 HCNT2 DEX Decrement rotate counter 00022A F009 26 F9 F004 BNE HCNTl Loop until rotate counter=O 00023A FOOB 49 ROLA Replace 8-bit data 00024A FOOC 39 RTS ~HITACHI 732 9. SHIFTING 32-BIT DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I SHR FUNCTION I (a) Shifts 32-bit binary data in IX and ACCD to right. (b) Permits number of shifts to be freely determined. (c) Permits easy multiplication of 32-bit binary data by 2- n . (n:number of shifts) ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPEC IFICATIONS Contents Storage Location Byte Lgth. •x : Not affected : Undefined ROM (Bytes) 11 Upper 16 RAM (Bytes) bits of I : Result 32-bit ACCD 1 binary IX 2 Stack (Bytes) ACCA ACCB data to be shift- I I 0 ed to IX No. of cycles right Entry 261 Lower 16 ! bits of Reentrant 32-bit C No Argu- 2 V binary ACCD ments x x Relocation data to be shift- Z N No ed to right x x Interrupt Number of SFCNTR I H Yes 1 shifts Upper 16 bits of (RAM) • • IX 2 shift Re- result turns Lower 16 bi ts of I ACCD 2 shift result DESCRIPTION I (1) Func tion Details (a) Argument details IX : Holds upper 16 bits of 32-bit binary data to be shifted to right. After SHR execution, contains upper 16 bits of shift result. ACCD : Holds lower 16 bits of 32-bit binary data to be shifted to right. After SHR execution, contains lower 16 bits of shift result. SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to shift 32-bit binary data 16 bits right. ~HITACHI 733 9. SHIFTING 32-BIT DATA MCU/MPU HD630l/HD6303 FAMILY SHR DESCRIPTION SFCNTR: Holds number of shifts. (RAM) (b) Fig. 1 shows example of SHR execution. If entry arguments are held as shown in part (Dof Fig. 1, 32-bit binary data is shifted to right as shown in part @ of Fig. 1. In this case, "0" in upper 2 bits. b7 SFCNTR bO CD Entry arguments { SF~~:~~RAM) I IX:ACCD b3l 0 I X : 2 ~~~~-r~~~~~~~~~~~~~~~-r~~~~ ($C91456CF) 11 00100 J b3l IX AC C D bO ® ~::~::ntsl( ~~~ ~~~~ B3) JoI ol1111o 101110101 110101011101110101 011101 1101 111101 11110101 111I Fig. 1 Example of SHR execution (2) User Notes Number of shifts should be held within range of $01 to $lF, otherwise ACCD and IX become "0". (3) RAM description Label RAM Description b7 bO SFCNTR I~________________~I Number of shifts is stored. ~HITACHI 734 9. SHIFTING 32-BIT DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I SHR DESCRIPTION I (4) Sample Application Subroutine SHR is called after number of shifts and 32-bit binary data to be shifted to right are held. worun RMB 4 ----------- Reserves memory byte for 32-bit binary data. WORK 2 RMB 1 ----------- Reserves memory byte for number of shifts. WORK3 RMB 4 ----------- Reserves memory byte for shift result. LDAA WORK 2 1 Stores number of shifts into STAA SFCNTR r---- entry argument (SFCNTR). LDX WORK 1 1 Loads 32-bit binary data to be shifted to LDD WORK1+2f right into entry argument (IX, ACCD). ullL-_J_S_R______S_H_R__-wI'1 ----- Calls subroutine SHR. STX STD WORK 3 WORK3+2 I Stores shift result (return argument (IX, ACCD» in RAM. (5) Basic Operation (a) Uses l6-bit shift instruction (LSRD) provided in the HD6301/HD6303 FAMILY. I (b) Upper 16 bits in 32-bit binary data are shifted to right. Here LSB is rotated to bit C. Lower 16 bits are rotated to right. At this time, LSB in bit C is rotated to MSB of lower 16 bits. (c) SFCNTR(RAM) is used to keep track of number of shifts. SFCNTR(RAM) is decremented every time (b) is executed. (d) Loops (b) to (c) until SFCNTR (RAM) is "0". ~HITACHI 735 9. SHIFTING 32-BIT DATA MCU/MPU HD6301/HD6303 FAMILY SHR FLOWCHART ___ { Exchanges upper 16 bits with lower 16 bits in 32-bit binary data. ___ { Shifts upper 16 bits in 32-bit binary data to right, and shifts LSB to bit C. Exchanges upper 16 bits with lower 16 bits --- { in 32-bit binary data. Rotates lower 16 bits in 32-bit binary data to right. Rotates LSB of upper 16 bits to MSB of lower 16 bits. ---~ Decrements shift counter. ---{ r"" if ,hift i, comp10 Before {DCNTIt(ItAM) I • :- I u=;J execution ("""") execution. When DECNT is executed, bit C 4-digit BCD counter completes counting CD Re turn { llCN'rH(llAM) (ooou) 0 0 I : I 0 I o : 0 I up as shown in partCDf'f Fig. l. arguments Fi g. 2 Example of counter overflow SPECIFICATIONS NOTEsl ~HITACHI 738 10. 4-DIGIT BCD COUNTER 1 MCU/MPU I HD630l/HD6303 FAMILY ILABEL 1DECNT DESCRIPTION I (2) User Notes If counter overflows as shown in Fig. 2, counter is cleared. (3) RAM Description Label RAM Description b7 bO DCNTR Upper byte - } 4-digit BCD councer " "ored. Lower byte L -________________~ (4) Sample Application WORIn RMB 2 Reserves memory byte for result of counting by 4-digit BCD counter. PSHA PSHB PSHX } Saves register contents that will be destroyed by DECNT execution. JSR DECNT Calls subroutine DECNT. II II BCS OVER When BCD counter overflows, branches to service routine. LDD DCNTR } ____ _ Stores result of counting by 4-digit BCD I STD WORIn counter (return argument (DCNTR) in RAM. PULX PULB PULA } } ----- Restores register. OVER Service routine in case of counter overflow. ~HITACHI 739 10. 4-DIGIT BCD COUNTER I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I DECNT DESCRIPTION I (5) Basic Operation (a) IX is used to indicate address of BCD counter and is also used to keep track of number of addition. (b) Set bit C for counting "l"s. (c) Executes (Formula 1) using index addressing mode. (Bit C is set at the first a-dition. When a carry is generated after (Formula 1) execution, bit C is also set.) o + « DCNTR - 1 + IX» + (bi t C) ACCA ------- (Formula 1) (d) Decrements IX. (e) Loops addition of upper byte and bit C until IX is "0". ~HITACHI 740 10. 4-DIGIT BCD COUNTER MCU/MPU HD630l/HD6303 FAMILY DECNT FLOWCHART DECNT ---{ Loads "2" into pointer indicating address of 4-digit BCD counter and counter indicating number of addition. ---{ Bit C is set and ACCA is cleared in order to count up by 4-digit BCD counter. In the first loop, counts up lower 2 digits in 4-digit BCD counter. In the second loop, adds bit C to value of upper 2 digits. ---{ Adjust result of addition into decimal number and stores it in 4-digit BCD counter DCNTR (RAM). ---{ Decrements pointer indicating address of 4-digit BCD counter and counter indicating number of additions. ---{ Tests if counting up is completed. I ~HITACHI 741 10. 4-DIGIT BCD COUNTER I MCU/MPU IlID6301/HD6303 FAMILY ILABEL I DECNT PROGRAM LISTING I 00001 ************************************************ 00002 * NAME : 4-DIGIT BCD COUNTER (DECNT) * 00003 * * 00004 * * 00005 ************************************************ 00006 00007 ** ENTRY NOTHING ** OOOOB * RETURNS DCNTR (BCD COUNTER) * 00009 * CARRY (C-0;TRUE.C c 1;OVER FLOW) * 00010 00011 * ************************************************ * 00012 * 00013A OOBO ORG SBO 00014 * OOOlSA OOBO 0002 A DCNTR RMB 2 BCD counter 00016 * 00017A FOOO ORG SFOOO 0001B * 00019 FOOO A DECNT EQU *M2 Entry point 00020A FOOO CE 0002 A LOX Loed ADDR pointer (eddltlon counter) 00021A F003 00 SEC Set cerry bit 00022A F004 B6 00 A DECNTl LDAA MO Cleer ACCA 00023A F006 A9 7F A ADCA DCNTR-l.X Increment BCD counter 00024A FOOB 19 DAA Convert Into BCD 0002SA F009 A7 7F A \STAA DCNTR-1.X Store BCD counter 00026A FOOB 09 DEX Decrement ADDR pointer 00027A FOOC 26 F6 F004 BNE DECNTl Loop until ADDR pointer c 0 0002BA FOOE 39 RTS • HITACHI 742 11. COMPARING 32-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I CMP FUNCTION I (a) Determines larger than / smaller than relationship ( >,=,<) of 32-bit binary data of 2 groups, and loads result into bit C and bit Z of CCR. (b) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS .: Not affected x : Undefined ROM (Bytes) 9 Storage Byte Contents Location Lgth. !: Result RAM (Bytes) 4 Upper 16 ACCD Stack (Bytes) bits of IX 2 First ACCA ACCB 0 Lower 16 value • IX • No. of cycles 20 Argu- bits of Entry First value ACCD 2 • Reentrant No ments C V Relocation Second CMT value (RAM) 4 I x No Z N Interrupt Re- Compa- bit C I x Yes bit Z 1 turns rison I H result (CCR) -r • • DESCRIPTION I (1) Function Details (a) Argument details IX : Holds upper 16 bits of the first 32-bit binary value. ACCD: Holds lower 16 bits of the first 32-bit binary value. CMT : Holds the second 32-bit binary value. (RAM) bit C, bit Z: Bit C and bit Z of CCR are contains according to comparison result. (CCR) (b) Table 1 shows example of CMP execution. If entry arguments are as shown in Table 1, bit C and bit Z of CCR are set accordingly. SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed when comparand and comparative number are equal. ~HITACHI 743 11. COMPARING 32-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I CMP DESCRIPTION I (c) After CMP execution, entry arguments are retained. Table 1. Example of CMP execution Entry arguments Return argument First value Second value CCR Large / small relationship CMr :CMr+l :CMr+2 :CMr+3 Bit C IX:ACCD Bit Z $F2FDC621 > $101F17DA 0 0 $20012002 co $20012002 0 1 $4F7B563D < $D677FBAC 1 0 (2) User Notes When not using upper byte, the upper byte should be held to "0", otherwise comparison result will not correct, because comparison is performed with undefined data in the upper byte. (3) RAM Description Label RAM Description b7 bO CMr Upper byte I- - - - The second 32-bit binary value is stored. - Lower byte - ~HITACHI 744 11. COMPARING 32-BIT BINARY DATAl MCU/MFU I HD6301/HD6303 FAMILY I LABEL 1 CMF DESCRIPTION I (4) Sample Application Subroutine CMF is called after the first value and the second value are held. WORKl RMB 4 Reserves memory byte for the first 32-bit binary value. WORK 2 RMB 4 Reserves memory byte for the second 32-bit binary value. LDD WORK2 } STD Stores the second 32-bit binary value LDD ~~~2+2 into entry argument (CMT). STD CMT+2 LDX WORKl } Loads the first 32-bit binary value LDD WORKl+2 into entry argument (IX, ACCD). II JSR Calls subroutine CMF. BEQ SKIP2 Branches to service routine in case of first value=second value. BCC SKIPl Branches to service routine in case of first value>second value. Service routine in case of first valuesecond value. SKIP3 User program ~HITACHI 745 11. COMPARING 32-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I CMP DESCRIPTION I (5) Basic Operation (a) Uses 16-bit comparison instruction (CPX) comparing IX with 2-byte memory, provided in the HD6301/HD6303 FAMILY. (b) Bit C and bit Z of CCR are determined as return argument, after 16-bit comparison instruction (CPX) is executed. (c) Upper 16 bits are compared using 16-bit comparison instruction (CPX). When equal, lower 16 bits are compared. When not equal, subroutine CMP is terminated. ~HITACHI 746 11. COMPARING 32-BIT BINARY DATA MCU/MPU HD630l/HD6303 FAMILY CMP FLOWCHART CMP CDO;lo(CMf:CMf+l) lower - - - { Compares lower 16 bits. Exchange's lower 16 bits with upper --- { 16 bits of the first value. CMPI RTS I ~HITACHI 747 11. COMPARING 32-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY I LABEL I CMP PROGRAM LISTING I 00001 ************************************************ 00002 00003 ** NAME: COMPARING 32-BIT BINARY DATA (CMP) ** 00004 * * 00005 ************************************************ 00006 ** ** 00007 ENTRY IX (UPPER 16-BIT COMPARANO) 00008 * ACCD (LOWER 16-BIT COMPARANO) * 00009 * CMT (32-BIT COMPARATIVE NUMBER) * 00010 * RETURNS: CARRY & BIT Z (COMPARISON RESULT) * 00011 * * 00012 ************************************************ 00013 * 00014A 0080 ORG $80 00015 * 00016A 0080 0004 A CMT RMB 4 Comparative number 00017 * 00018A FOOO ORG $FOOO 00019 * 00020 FOOO A CMP EQU * Entry point 00021A FOOO 9C 80 A CPX CMT Compare IX with CMT+2:CMT+3 00022A F002 26 04 F008 BNE CMP1 Branch if IX equal CMT+2: CMT+3 00023A F004 18 XGOX Exchange ACCD & IX 00024A FOOS 9C 82 A CPX CMT+2 Compare IX with CMT:CMT+1 0002SA F007 18 XGDX 00026A F008 39 CMP1 RTS ~HITACHI 748 12. ADDING 32-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I ADD FUNCTION I (a) Performs addition of 32-bit binary number and loads addition result into IX and ACCD. (b) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU SPECIFICATIONS .: REGISTERS AND FLAGS Not affected X : Undefined ROM (Bytes) 9 Storage Byte Contents Location Lgth. t : Result RAM (Bytes) 4 Upper 16 bits of IX 2 ACCD Stack (Bytes) augend ACCA ACCB 0 Lower 16 Entry bits of ACCD 2 t t No. of cycles augend IX 19 Addend ADER 4 t Reentrant (RAM) No Argu- ments Upper 16 C V Relocation bits of IX 2 addition l x No Re- result Z N Interrupt turns Lower 16 x x Yes bi ts of ACCD 2 addition I H result Carry or Bit C 1 • x I no carry (CCR) DESCRIPTION I (1) Function Details (a) Argument details IX : Holds upper 16 bits of augend. After ADD execution, contains upper 16 bits of addition r~su1t. ACCD: Holds lower 16 bits of augend. After ADD execution, contains lower 16 bits of addition result. ADER: Holds 32-bit binary addend. (RAM) PECIFICATIONS --- ---_.. _-- NOTES I ~HITACHI 749 12. ADDING 32-BIT BINARY DATA I MCU/MPU IHD630l/HD6303 FAMILY ILABEL I ADD DESCRIPTION I bit C (CCR) Indicates whether carry is generated or not after ADD execution. bit C = 1 : Carry is generated in addition result. (see Fig. 2) bit C = 0 : No carry is generated in addition result. (b) Fig. 1 shows example of ADD execution. If entry arguments are as shown in partCDof Fig. 1, addition result is contained in IX and ACCD as shown in part ®of Fig. 1. b3l IX ACCD bO : : : 1_ Augend ~ I A 0 1 8 6 1 C D 1 F 2 Entry { ADER ADERH ADERt2 ADERts arguments +) 1 : I A D : D 2 C: 1 F : 1- Addend bitCFb~3~1-r__~ITX~~__~~__r-~A~CTC~D~~~b~0 .. ® Return arguments { o1 B : B 11 : 3 F A 11 1 1_ !::~~ ~on Fig. Example of ADD execution (2) User Notes (a) As shown in Fig. 3, when not using :•I o: c I •: I F I I D : F upper byte, the upper byte should be +) I : I •: I : I A B : F I I I held to "0", otherwise addition result will not be correct, because bi t c£:QS : Ic : I ,:•I 0 I B F : 0 Carry addition is performed with undefined Fig. 2 Example of addition when data in the upper byte. carry is generated. (b) After ADD execution, augend is destroyed because addition result : I : I : I•: I 0 0 0 0 I F D : I : I 0 I • :•I 0 0 0 F : D is contained in IX and ACCD. If +) augend needs to be retained after bit c01 : I : 0 :c I •: I 0 0 I I 0 ADD execution, it should be saved Fig. 3 Example of addition when in memory before execution. upper byte is not used. $ HITACHI 750 12. ADDING 32-BIT BINARY DATA I MCU /MPU I HD6301/HD6303 FAMILY I LABEL I ADD DESCRIPTION I (3) RAM Description Label RAM Description b7 bO ADER Upper byte f-- - f-- - 32-bit binary addend is stored. f-- Lower byte - (4) Sample Application Subroutine ADD is called after augend and addend are held. WORK 1 RMB 4 ----- Reserves memory byte for 32-bit binary augend. WORK 2 RMB 4 ----- Reserves memory byte for 32-bit binary addend. WORK 3 RMB 4 ----- Reserves memory byte for 32-bit I I binary addition result. I I I I I I I LDD WORK 2 Stores 32-bit binary addend into STD LDD ADER WORK 2+2 }----- entry argument (ADER). I STD ADER+2 LDX WORKI } Loads 32-bit binary augend into LDD WORK 1+2 entry argument (IX, ACCD) . JSR UL_________ AD __D__--u11 ----- Calls subroutine ADD. BCS OVER ----- If carry is generated in addition result, " STX WORK3 branches to service routine. 1----- Stores addition result (return arguments STD WORK3+2 J (IX,ACCD» in RAM. I I OVER Il.n~ervice routine case of carry I I I I I I I I I ~HITACHI 751 12. ADDING 32-BIT BINARY DATA I MCD /MPD 1 HD630l/HD6303 FAMILY ILABEL I ADD DESCRIPTION I (5) Basic Operation (a) Uses l6-bit addition instruction (ADDD) provided in the HD630l/HD6303 FAMILY. (b) (Formula 1) shows addition of lower 16 bits using 16-bit addition instruction (ADDD). When carry is generated after performing (Formula 1), bit C is set. (ACCD) + (ADER+2:ADER+3) -. ACCD ------- (Formula 1) (c) Upper 16 bits are added using 8-bit addition instruction shown in (Formula 2) and (Formula 3) (ADC) considering bit C. (ACCB) + (ADER+l) + (bit C) ACCB --------- (Formula 2) (ACCA) + (ADER) + (bit C) ACCA --------- (Formula 3) Bit C is taken into consideration because there is carry involved with the addition result by executing (b). ~HITACHI 752 12. ADDING 32-BIT BINARY DATA MCU/MPU HD6301 /HD6303F AMILY ADD FLOWCHART ---{ Adds lower 16 bits and loads addition result into augend (ACCD). ---{ Exchanges lower 16 bits of addition result with upper 16 bits of augend. Adds upper 8 bits considering carry which is generated by lower l6-bits addition, and stores result in addend for upper 16 bits area. ---{ Exchanges upper 16 bits with lower 16 bits of addition result. I ~HITACHI 753 12. ADDING 32-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I ADD PROGRAM LISTING I 00001 ************************************************ 00002 '" 00003 '" NAME : ADDING 32-BIT BINARY DATA (ADD) 00004 '" '" ************************************************'" 00005 '" 00006 '" 00007 '" ENTRY IX (UPPER 16-BIT AUGEND) 00008 '" '" ACCD (LOWER 16-BIT AUGEND) ' '"" 00009 ADER (32-BIT ADDEND) '" '" (UPPER 16-BIT SUM) 00010 00011 ''"" RETURNS ACCD IX (LOWER 16-BIT SUM) '" '" 00012 CARRY(C=O;TRUE.C=l;OVER FLOW) '" 00013 '" 00014 '" ************************************************ '" 00015 00016A OOSO '" ORG $SO 00017 ' " 0001SA 0080 0004 A ADER RMB 4 Addend 00019 00020A FOOD '" ORG $FOOO 00021 00022 FOOD A 'ADD " EQU 'ADER+2 " Entery point 00023A FOO~ 03 S2 A ADDD Add ACCD and ADER+2:ADER+3 00024A F002 18 XGDX Exchange ACCD & IX 0002SA F003 09 81 A ADCB ADER+l Add ACCB and ADER+l 00026A FOOS 99 SO A ADCA ADER Add ACCA and ADER 00027A F007 lS XGDX Exchange ACCD & IX 0002SA FOOS 39 RTS ~HITACHI 754 I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I SUB 13. SUBTRACTING 32-BIT BINARY DATA FUNCTION I (a) Performs subtraction of 32-bit binary data and loads subtraction result into IX and ACCD. (b) utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS Storage Byte •x : : Not affected Undefined ROM (Bytes) 9 Contents Location Lgth. t : Result RAM (Bytes) 4 Upper 16 bits of IX 2 ACCD Stack (Bvtes) minuend 0 ACCA ACCB Lower 16 Entry bits of ACCD 2 t t No. of cycles minuend IX 19 Subtra- SBER (RAM) 4 ~ Reentrant hend No Argu- Upper 16 C V Relocation ments bits of sub- traction IX 2 t x No Z N Interrupt result Re- x x Yes Lower 16 turns bits of I H sub- traction result ACCD 2 • • I Borrow or bit C 1 no borrow (CCR) DESCRIPTION I (1) Function Details (a) Argument details IX : Holds upper 16 bits of minuend. Contains upper 16 bits of subtraction result after SUB execution. ACCD: Holds lower 16 bits of minuend. Contains lower 16 bits of subtraction result after SUB execution. SBER: Holds 32-bit binary subtrahend. (RAM) SPECIFICATIONS NOTES I ~HITACHI 755 13. SUBTRACTING 32-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I SUB DESCRIPTION 1 bit C (CCR): Indicates whether borrow is generated or not after SUB execution. bi t C = 1 Borrow is generated in subtraction result. (see Fig. 2) bit C = 0 : No borrow is generated in subtraction result. (b) Fig. 1 shows example of SUB execution. If entry arguments are as shown in partCDof Fig. 1, subtraction result is contained in IX and ACCD as shown in part 00f Fig. 1. b3l IX ACCD bO :~~~~ents{ LI _F__'--C-.JI~9---,:__3---L1__ C--LI__ 6--L__ A - - l I - Mi nuend D-,-__ SBER SBER+ 1 SBER+Z SBER+a CD L...I_6--1:--,:, E C---L_ --L:~B=--L..:.A.:..........:_5---L1_5--,-:_A~I- Subtrahend --~)------------------------------------- o arguments Return { bit C b3l IX ACCD bO 1- Subtrac tion 01 8 : F 1 A C 7 1 8 : o result Fig. 1 Example of SUB execution (2) User Notes (a) When subtraction result is negative, (Minuend ·I.;'.I-Multi~ x) MJ:II MEIHI 1. RI contained in PRDCT (RAM) as \bI Return { b3l PIIIlCT(IIA.\I) bO P l.er shown in part®of Fig. 1. arguments ($13B"."C) 11:a IB;'1-:, I,:c I~ Product },lOn "WCT'I 1'1U1C'T'2 rIllCT,,1 (c) Table 1 shows result when "0" is held as entry arguments. Fig. 1 Example of MUL execution' Table 1. Product when holding "0" as entry arguments Entry arguments Return argument Multiplicand Multiplier Product (MCAND :MCAND+ 1 ) (MER:MER+l) (PRDCT:PRDCT+l:PRDCT+2:PRDCT+3) $ ,* * * * *1 $ o 000 $ 0 0 0 0 0 000 $ 000 0 $ * * * * *1 $ 0 0 0 0 0 000 $ o 0 0 0 $ 000 0 $ 0 0 0 0 000 0 (NOTE) *1 $**** indicates hexadecimals (2) User Notes (a) As shown in Fig. 2, when not using upper byte, the upper byte should be held to "0", otherwise product 10:0 I F:AI-Multiplicand will not be correct, because ~x~)____~I~o=:o=I='=:B=I~-Multiplier multiplication is performed with undefined data in the upper byte. 10:010;'1,:·lo:EI-Product Fig. 2 Multiplication example when upper byte is not used .. ~HITACHI 762 14. MULTIPLYING l6-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I MUL DESCRIPTION J (3) RAM Description Label RAM Description b7 bO MCAND Upper byte t-- - } 16-bi< binary multiplicand is stored. Lower byte MER Upper byte - - } 16-bi , binary multiplier is stored. Lower byte PRDCT Upper byte t-- - t-- - 32-bit binary product is stored. t-- - Lower byte I ~HITACHI 763 14. MULTIPLYING l6-BIT BINARY I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I MUL DATA DESCRIPTION I (4) Sample Application Subroutine MUL is called after multiplicand and multiplier are held. WORK 1 RMB 2 Reserves memory byte for l6-bit binary multiplicand. WORK 2 RMB 2 Reserves memory byte for l6-bit binary multiplier. WORK 3 RMB 4 Reserves memory byte for product. Saves register contents that will be PSHA PSHB ) destroyed by MUL execution. LDD STD WORKl MCAND } Stores l6-bit binary multiplicand into entry argument (MCAND). LDD STD WORK 2 MER } Stores l6-bit binary multiplier into entry argument (MER) . II JSR MUL II Calls subroutine MUL. LDD STD PRDCT 1 Stores 32-bit binary product LDD ::~:+2 (return argument (PRDCT)) in RAM. STD WORK 3+2 PULB PULA )----- Restores register. ~HITACHI 764 14. MULTIPLYING l6-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I MUL DESCRIPTION ~--------------~ I' (5) Basic Operation (a) Uses 8-bit binary multiplication instruction (MUL) provided in the HD6301/ HD6303 FAMILY. (b) Multiplication of l6-bit binary data is executed by obtaining partial products (as shown in Fig. 3 Q) , CD, G) and ®), and adding them to product (Fig. 3 (£» . I II MCAND+1 1----- Multiplicand M CAN D 1M E R II ME R+ 11----- Multiplier x) (MCAND) x (MER+1) -----® Partial products (MCAND+1)x(MER) -----® (MCAND)x(MER) -----@ P RDCT IPRDCT+1 II PRDCT+2 IPRDCT+3 -----@ Product (=(!)+®+®+@) Fig. 3 Multiplication I ~HRTACHI 765 14. MULTIPLYING 16-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I MUL FLOWCHART I Clears RAM for product. Obtains partial product, that is, (lower byte of mUltiplicand) x (lower byte of multiplier), and stores it in RAM for product. Requires partial product of (upper byte of multiplicand) x (lower byte of multiplier). Adds partial product and stores it in RAM for product. Requires partial product of (lower byte of multiplicand) x (upper byte of multiplier) Adds partial product and stores it in RAM for product. As carry may be generated, executes carry process. Requires partial product of (upper byte of multiplicand) x (upper byte of multiplier) Adds partial product and stores it in RAM for product. ~HITACHI 766 14. MULTIPLYING 16-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL MDL I PROGRAM LISTING I 00001 ************************************************ 00002 ,. 00003 '" NAME : MULTIPLYING 16-BIT BINARY DATA (MUl) ''"" 00004 ,. '" 00005 ************************************************ 00006 '" 00007 '" ENTRY MCAND (MULTIPLICAND) 00008 '" MER (MUL TIPLIER) '" 00009 '" RETURNS PRDCT (PRODUCT) '" 00010 " '" ************************************************'" 00011 '" 00012 '" 00013A 0080 ORG $80 00014 '" 00015A 0080 0002 A MCAND RMB 2 MuLtipLicand 00016A 0082 0002 A MER RMB 2 MuLtipLier 00017A 0084 0004 A PRDCT RMB 4 Product 00018 '" 00019A FOOO ORG $FOOO 00020 00021 FOOO A 'MUL " EQU '" Entry point 00022A FOOO 4F CLRA CLear product area 00023A FOOl SF CLRB 00024A F002 DO 84 A STD PRDCT 00025A F004 96 81 A LDAA MCAND+l (MCAND+l) '" (MER+1) -) PRDCT 00026A F006 D6 83 A LDAB MER+1 00027A F008 3D MUL 00028A F009 DD 86 A STD PRDCT+2 00029A FOOS 96 80 A LDAA MCAND (MCAND) '" (MER+l) -) ACCD 00030A FOOD D6 83 A LDAS MER+1 00031A FOOF 3D MUL 00032A F010 D3 85 A ADDD PRDCT+l ACCD + (PRDCT) -) PRDCT 00033A F012 DD 85 A STD PRDCT+l 00034A F014 96 81 A LDAA MCAND+l (MCAND+1) '" (MER) -) ACCD 00035A F016 D6 82 A LDAB MER 00036A F018 3D MUL 00037A F019 03 85 A ADDD PRDCT+l ACCD + (PRDCT) -) PRDCT 00038A F01S DO 85 A STD PRDCT+1 00039A FOlD 79 0084 A ROL PRDCT 00040A F020 96 80 A LDAA MCAND (MCAND) '" (MER) -) ACCD I 00041A F022 06 82 A LDAS MER 00042A F024 3D MUL 00043A F025 03 84 A ADDD PRDCT ACCD + PRDCT -) PRDCT 00044A F027 DD 84 A STD PRDCT 00045A F029 39 RTS ~HITACHI 767 15. DIVIDING l6-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I DIV FUNCTION I (a) Performs divisions of l6-bit binary data and stores result (quotient and residual) in l6-bit binary. (b) Stores dividend and divisor in IX and RAM. (e) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPEC IFICATIONS • : Not affected x : Undefined ROM (Bytes) 25 Storage Byte Contents Location Lgth. ; : Result RAM (Bytes) 3 Dividend IX 2 ACCD Stack (Bytes) ACCA ACCB 0 Entry DVS 1 t No. of cycles Divisor (RAM) 2 IX 476 Argu- ; Reentrant ments IX No Quotient 2 C V Relocation Re- turns x x No Residual ACCD 2 Interrupt Z N x x Yes I H • x DESCRIPTION I (1) Function Details (a) Argument details IX: Holds 16-bit binary dividend. Contains quotient after DIV execution. e DVS (RAM): Holds 16-bit binary divisor. ACCD: Contains 16-bit binary residual. SPECIFICATIONS NOTES I ~HITACHI 768 15. DIVIDING l6-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL DIV DESCRIPTION I @ Return (b) Fig. 1 shows example of DIV execution. arguments If entry arguments are as shown in blS bO blS bO 1,,:01 0 :.1 ... 10 :1'1,,:1>1 partCDof Fig. 1, division result IX A('('I> ($000.) ($" F"ll) is contained in IX and ACCD as shown in blS bO )blS part@ of Fig. l. [!"":!iJ1i:oJ DVS DVS+l a:x bO 14 >. 1 II 1 I ($1000) ($4F3D) (c) Table 1 shows result when "0" is held as entry arguments. CD Entry' arguments Fig. 1 Example of DIV execution Table 1 Result when holding "0" as entry arguments Entry arguments Return arguments Dividend (IX) Divisor (DVS) Quotient (IX) Residual (ACCD) $ * * * * * $ 0 0 o0 $ F F F F $ * * * * * * $ o0 0 0 $ o0 0 0 $ * * * * $ 000 0 $ 000 0 $ 0 o0 0 $ F F F F $ o0 0 0 (NOTE) * $**** indicates hexadecimals. (2) User Notes (a) When not using upper byte as shown in Fig. 2, the upper byte should be held to "0", otherwise division result will not be correct, because division is performed with underfined data I in the upper byte. (b) After DIV execution, dividend is destroyed because quotient is contained Fig. 2 DIV example when upper in IX. If dividend needs to be byte is not used retained after DIV execution, it should be saved in memory before execution. ~HITACHI 769 15. DIVIDING l6-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL IIHV DESCRIPTION I (3) RAM Description Label RAM Description b7 bO DVS Upper byte I l6-bit binary divisor is stored. f-- - Lower byte DICNTR Dividend shift counter is stored. (4) Sample Appli~ation Subroutine DIV is called after dividend and divisor are held. worun RMB 2 Reserves memory byte for 16-bit binary dividend. WORK 2 RMB 2 Reserves memory byte for 16-bit binary divisor. WORK3 RMB 2 Reserves memory byte for 16-bit binary quotient. WORK 4 RMB 2 Reserves memory byte for 16-bit binary residual. I I I LDX WORK 1 Loads l6-bit binary dividend into entry argument (IX). LDD WORK2 } Stores l6-bit binary divisor into STD DVS entry argument (DVS). II JSR DIV II Calls subroutine DIV. STX WORK3} _____ Stores division result in RAM. STD WORK 4 ~HITACHI 770 15 .. DIVIDING l6-BIT BINARY DATA I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I DIV DESCRIPTION I (5) Basic Operation (a) In binary code divison, quotient and residual are obtained by repeated subtraction. Fig. 3 shows example of division ($OD 7 $03). ®® 1 0 0 +-- Quotient Divisor --+ 1 d 1 1 0 1 +-- Dividend -) 1 1 ·.... ·CD 0 0 ...... ® -) 1 1 ...... @ - 0 1 ...... ® +) 1 1 ...... 0) 0 0 1 -) 1 1 - 1 0 +) 1 1 0 0 1 +-- Residual Fig. 3 Division example ($00 7 $03) (b) Refering to Fig. 3, the program is explained as follows: (i) Loads number of shifts in shift counter (DICNTR) and clears ACCD in which residual will be loaded. (ii) Shifts dividend (IX) and ACCD left 1 bit, then shifts MSB of IX to LSB of ACCD. This is because when performing subtraction, the upper bits are I fetched one by one from dividend. (iii) Subtracts divisor (DVS:DVS+l) from ACCD. If subtraction result is positive, sets LSB of IX to "1". (Fig. 3 ®-@--G». If subtraction result is negative, clears LSB of IX, adds divisor to subtraction result and restores the pevious subtraction result. (Fig. 3 G>-®-0. (iv) Decrements shift counter. (v) Loops (ii) to (iv) until shift counter is "0". ~.----------------------------------------------~ ~HITACHI 771 15. DIVIDING l6-BIT BINARY DATA MCU/MPU DIV FLOWCHART D I V ___ { Loads number of shifts into shift counter. ___ { Clears work area where division result will be stored. Shifts MSB of dividend to LSB of Shift (ACCD) 1 bit left work area. (ACCD)-( IX) Rotate (ACCD) 1 bit left ---~ Subtracts divisor from work area. ___ { Sets LSB of IX to "1" where residual will be stored. ___ { Tests if subtraction result is positive. ___ { Adds divisor to subtraction result and returns contents of work area. ___ { Clears LSB of IX where residual will be stored. ___ { Decrements shift counter. (DICNTR)+0 ---{: Te't' if ,hift i, oompleted. R $ HITACHI 772 15. DIVIDING 16-BIT BINARY DATA I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I DIV PROGRAM LISTING I 00001 ************************************************ 00002 * NAME : DIVIDING 16-BIT BINARY DATA (DIV) * 00003 * * 00004 * * 00005 ************************************************ 00006 00007 ** ENTRY IX (DIVIDEND) ** OOOOS * DVS (DIVISOR) * 00009 * RETURNS ACCD (QUOTIENT) * 00010 * IX (RESIDUAL) * 00011 * * 00012 ************************************************ 00013 * 00014A OOSO ORG $SO 00015 * 00016A OOSO 0002 A DVS RMB 2 Divisor 00017A 00S2 0001 A DICNTR RMB 1 Shift counter 0001S * 00019A FOOO ORG $FOOO 00020 * 00021 FOOO A DIV EQU Entry point 00022A FOOO S6 10 A LDAA *1=116 Set shift counter 00023A F002 97 S2 A STAA DICNTR 00024A F004 4F CLRA Clear work (Set quotient afterword) 00025A FOOS SF CLRB 00026A F006 lS DIV1 XGDX Shift dividend and set MSB of- 00027A F007 05 ASLD -dividend to LSB of work 0002SA FOOS lS XGDX 00029A F009 59 ROLB 00030A FOOA 49 ROLA 00031A FOOB 93 80 A SUBD DVS Work - Divisor -) Work 00032A FOOD 08 INX Set hi9h to LSB of residual area 00033A FOOE 24 03 FOl3 BCC DIV2 Branch if work)=divisor 00034A F010 D3 SO A ADDD DVS Work + Divisor -) Work 00035A F012 09 DEX Clear LSB of residual area 00036A F013 7A 00S2 A DIV2 DEC DICNTR Decrement shift counter 00037A F016 26 EE F006 BNE DIV1 Loop until shift counter = a 00038A F01S 39 RTS I ~HITACHI 773 16. ADDING 8-DIGIT BCD I MCU/MPU I lID6301/HD6303 FAMILY ILABEL I ADDD FUNCTION I (a) Performs addition of 8-digit BCD number in RAM, and stores result in 8-digit BCD number in RAM. (b) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPEC IF ICAT ION S e: Not affected ROM (Bytes) X: Undefined 15 Storage Byte Contents Location Lgth. t:Result RAM (Bytes) 8 ABD Stack (Bytes) Augend (RAM) 4 ACCD ACCA ACCB 0 Entry ACD x x No. of cycles Addend (RAM) 4 IX 81 Argu- x Reentrant ments Addition ABD No (RAM) 4 result C V Relocation Re- turns bit C t x No Carry or N Interrupt (CCR) 1 Z no carry x x Yes I H • x DESCRIPTION I (1) Function Details (a) Argument details b3l bO [-~ II : '1- : ' I. : 0I' : 'I-Augend ABD : Holds 8-digit BCD augend. CD 1 Entry 0 ..' ....) ABD AIIDH ABD+HBD13 (RAM) After ADDD execution, contains ACD(RAM) 1,:.1 0: 01 0:.1 0: II~ Addend arguments ('.000.01) +) ACD ACD+-I ACIl+O ACDi3 addition result. bitCb31 bO· . ACD : Holds 8-digit BCD added. (RAM) 0Return {ABD(RAM) (884088938) a: 01-: 01-: 01 ·1·:SI_Add~twn ABD ABDH ABD13 ABDI3 res u 1 t arguments Fig. 1 Example of ADDD execution SPECIFICATIONS NOTES I ~HITACHI 774 16. ADDING 8-DIGIT BCD I MCU/MPU I HD6301/HD6303 FAMILY ILABEL IADDD DESCRIPTION I bit C: Indicates whether a carry is (CCR) generated or not after ADDD execution. 1':'1";, I ,:nl';" I-Augend bit C=l: Carry is generated in +i 1,>I">In:"I<,,I-Addend addition result. bit C CQJ<"I.:nI,:OI, >1_Addition carry result (See Fig. 2) bit C=O: No carry is generated Fig. 2 Addition example when carry is generated in addition result. (b) Fig. 1 shows example of ADDD execution. I" : " I" : " I, :' I:I : • I~ Augend If entry arguments are as sho~1 in +) I';"I";"I';,E::J-Addend partCDof Fig. 1, addition result is bit cG lo:"IU:"I<'I-:'I~Addition contained in ABD(RAM) as shown in part result @of Fig. 1. Fig. 3 Addition example when upper byte is not used (2) User Notes (a) As shown in Fig. 3, when not using upper byte, the upper byte should be held to "0", otherwise addition result will not be correct, because addition is performed with undefined data in the upper byte. (b) After ADDD execution, augend is destroyed because addition result is containd in ABD(RAM). If augend needs to be retained after ADDD execution, it should be saved in memory before execution. (c) BCD number should be held in augend and addend, otherwise addition result will not be correct. I (3) RAM Description Label RAM Description b7 bO ABD Upper byte 8-digit BCD augend is stored before - - execution. - - 8-digit BCD addition result is stored after execution. - - Lower byte ACD Upper byte I-- - 8-digit BCD addend is stored. f-- - f-- - Lower byte ~HITACHI 775 16. ADDING 8-DIGIT BCD I MCU/MPU I HD630l/HD6303 FAMILY ILABEL 1 ADDD DESCRIPTION I (4) Sample Application Subroutine ADDD is called after augend and addend are held. WORIn RMB 4 Reserves memory byte for 8-digit BCD augend. WORK2 RMB 4 Reserves memory byte for 8-digit BCD addend. WORK 3 RMB 4 Reserves memory byte for 8-digit BCD addition results. PSHA PSHB PSHX }----- Saves register contents that will be destroyed by ADDD execution. LDD STD LDD :~:l WORKl+2 } Stores 8-digit BCD augend into entry argument (ABD). STD ABD+2 :~:K2 } LDD STD Stores 8-digit BCD addend into LDD WORK2+2 entry argument (ACD). STD ACD+2 II JSR ADDD II Calls subroutine ADDD. Bes OVER If carry is generated in addition result, branches to service routine. LDD ABD STD LDD STD WORK3 ABD+2 WORK3+2 }----- Stores addition result (return arguments (ABD)) in RAM. PULX PULB PULA OVER I ~ervice routine 1n case of carry J ~HITACHI 776 16. ADDING 8-DIGIT BCD I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I ADDD DESCRIPTION I (5) Basic Operation (a) When addition of more than 2 bytes are executed, addition result can be obtained by repeating addition for each byte. (b) IX is used to indicate augend and addend addresses and is also used to count number of additions. (c) Clears bit C at first. (d) Performs (Formula 1) on each byte of augend and addend using index addressing mode. Augend + Addend + (bit C)--'ACCA --------------- (Formula 1) Bit C is added in (Formula 1) because addition result of lower bytes generate carry. (e) Adjusts addition result of (d) to decimal value using decimal adjust ACCA instruction (DAA), and holds it in augend ABD (RAM). (f) Decrements IX every time (d) to (e) is executed. (g) Loops (d) to (f) until IX is "0". I ~HITACHI 777 16. ADDING 8-DIGIT BCD MCU/MPU ADDD FLOWCHART ADDD Loads "4" in pointer indicating augend address and counter indicating number of addition. Clears bit C for carry operation. ~-----' ---{ Adds addend and bit C to augend. ---{ Adjusts addition result to decimal. Stores decimal-adjusted result in augend ~-----' ---{ RAM. Decrements pointer indicating augend ~-----' ---{ address and counter indicating number of addition. ---{ Tests if addition in all digits is completed or not. R T S ~HITACHI 778 16. ADDING 8-DIGIT BCD I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I ADDD PROGRAM LISTING I 00001 ************************************************ 00002 *>I< NAME : ADDING 8-DIGIT 8CD (ADDD) * 00003 * 00004 >I< ************************************************ * 00005 00006 * ENTRY ABO (AUGEND) * 00007 * ACD (ADDEND) * 00008 * RETURNS ABO (SUM) *>I< 00009 * 00010 CARRY (C~O;TRUE.e~l;OVER FLOW) * 00011 * >I< 00012 ************************************************* 00013 * 00014A 0080 ORG $80 00015 * 00016A 0080 0004 A ABO RMB 4 Augend -) sum 00017A 0084 0004 A ACD RMB 4 Addend 00018 * 00019A FOOO ORG $FOOO 00020 * 00021 FOOO A ADDD EQU Entry point 00022A FOOO CE 0004 A LOX *114 Set ADDR pointer(addition counter) 00023A F003 OC CLC CLear carry bit 00024A F004 A6 7F A ADDDl LOA A ABD-l. X Augend+addend 00025A F006 A9 83 A ADCA ACD-l.X 00026A F008 19 DAA Convert into BCD 00027A F009 A7 7F A STAA ABD-l, X Store in augend area 00028A FOOB 09 DEX Decrement ADDR pointer 00029A FOOe 26 F6 F004 BNE ADDDl Loop untiL ADDR pointer 0 00030A FOOE 39 RTS I ~HITACHI 779 17. SUBTRACTING 8-DIGIT BCD MCU/MPU HD630l/HD6303 FAMILY ILABEL I SUBD I I FUNCTION I (a) Performs subtraction of 8-DIGIT BCD number in RAM and stores result in 8-digit BCD number in RAM. (b) Uti lizes unsigned integers in arguments. ARGUMENTS 1 CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS •x : Not affected : Undefined ROM (Bytes) 29 Storage Byte Contents Location Lgth. t : Result RAM (Bytes) ACCD 8 SUBEDS ACCA ACCB Stack (Bytes) Minuend 4 (RAM) x x 0 Entry No. of cycles IX Subtra- SUBERS x 120 4 hend (RAM) Reentrant Argu- ments C V No Subtrac- SUBEDS tion (RAM) 4 t x Relocation result Z N No Re- turns Borrow x x Interrupt bit C 1 or no I H Yes (CCR) borrow • x DESCRIPTION I (1) Function Details b3l bO ( ",.m'''~ (90123456) I:,,:,,~ 1,,1,,';':,1,,3,,;,,:1,,~,;,,~,1_ Minuend (a) Argument details Entry CD . ar uments SIJREICS(RAM) I;,:,; t~,:,,', I,',L~,I,~,:",~ ,1J ': 'J'-Subtraction partCDof Fig. 1, subtraction result result is contained in SUllEDS (RAM) as shown Fig. 3 Subtraction example when in part ® of Fig. 1. not using upper byte (2) User Notes (a) As shown in Fig. 3, when not using upper byte, the upper byte should by held to "0", otherwise subtraction result will not be correct, because subtraction result is performed with undefined data held in the upper byte. (b) After SUBD execution, minuend LS destroyed because subtraction result is stored in SUBEDS (RAM). If minuend needs to be retained after SUBD execution, it should be saved in memory before execution. (c) BCD number should be held in minuend and subtrahend, otherwise subtraction result will not be correct. I (3) RAM Description Label RAM Description b7 bO SUBEDS Upper byte f-- - 8-digit BCD minuend is stored before execution. f-- - 8-digit BCD subtraction result is f-- - stored after execution. Lower byte , SUBERS Upper byte f-- - f-- - 8-digit BCD subtrahend is stored. f-- - Lower byte ~HITACHI 781 17. SUBTRACTING 8-DIGIT BCD I MCU/MPU I HD6301/HD6303 FAMILY I LABEL I SUBD DESCRIPTION I (4) Sample Application Subroutine SUBD is called after minuend and subtrahend are held. WORI next step by setting bit C (See Formula 2 in "(5) Basic Operation"). ----f Loads "4" in pointer indicating minuend address and counter indicating number of subtraction. ____ [ Adds la's complement of subtrahend and bit C to minuend. ____ { Adjusts addition result to decimal. ____ { Stores decimal-adjusted result in minuend RAM. Decrements pointer indicating minuend { ---- :~~::::t~:~.counter indicating number of ____ { Tests if subtraction in all digits is ( IX)+O completed or not. R T S ~HITACHI 784 17. SUBTRACTING a-DIGIT BCD I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I SUBD PROGRAM LISTING I 00001 00002 ************************************************ * (SUBD) .. 00003 * NAME : SUBTRACTING 8-DIGIT BCD * 00004 * * OOOOS ************************************************ 00006 * * 00007· * ENTRY SUBEDS (MINUEND) * 00008 * SUBERS (SUBTRAHEND) * 00009 * RETURNS SUBEDS (RESIDUAL> * 00010 * CARRY (C=l:TRUE.C=O:BDRROW) * 00011 * * 00012 ************************************************ 00013 * 00014A 0080 ORG $80 OOOlS * 00016A 0080 0004 A SUBEDS RMB 4 Minuend -> Residual 00017A 0084 0004 A SUBERS RMS 4 Subtrahend 0001S * 00019A FOOO ORG $FOOO 00020 * 00021 FOOO A SUSD EQU * Entry point 00022A FOOO CE 0004 A LOX 114 99999999-Subtrahend -) SUSERS 00023A F003 CC 9999 A SUSD1 LDD 1:1$9999 00024A F006 A3 82 A SUSD SUSERS-2.X 0002SA FOOS ED S2 A STD SUSERS-2.X 00026A FOOA 09 DEX 00027A FOOS 09 DEX 00028A FOOC 26 FS F003 SNE SUSD1 00029A FOOE 00 SEC Set carry bit 00030A FOOF CE 0004 A LOX 1:14 Set ADDR pointer (subtraction counter) 00031A F012 A6 7F A SUSD2 LDAA SUSEDS-l.X Minuend+nesstive of subtrahend 00032A F014 A9 83 A ADCA SUSERS-l.X 00033A F016 19 DAA Convert into BCD 00034A F017 A7 7F A STAA SUSEDS-1.X Store in SUSEDS area 0003SA F019 09 DEX Decrement ADDR pointer 00036A FOIA 26 F6 F012 BNE SUSD2 Loop until ADDR pointer 0 00037A F01C 39 RTS I ~HITACHI 785 18. 16-BIT SQUARE ROOT I MCU /MPU IHD6301 /HD6303 FAMILY ILABEL I SQRT FUNCTION I (a) Obtains square root of 16-bit binary data in IX, and stores result in RN1. (b) Utilizes unsigned integers in arguments. CHANGES IN CPU ARGUMENTS I REGISTERS AND FLAGS SPECIFICATIONS I • : Not affected x : Undefined ROM (Bytes) 54 Storage Byte Contents Location Lgth. t : Result RAM (Bytes) ACCD 3 Data ACCA ACCB Stack (Bytes) Entry to be IX 2 x x 0 squared IX No. of cycles x 478 Argu- Reentrant ments C V No Re- Square SANS+l x x Relocation 1 turns root (RAM) Z N No x x Interrupt I H Yes • • DESCRIPTION. I (1) Function Details b15 IX bO LH\;'F) IF: IF: F I (a) Argument details I III;XIJ HEXD+I (RAM) to be converted into BCD number. b19 1 bO DECD : Holds 5-digit BCD number. (RAM) @Return U5\'%llo: 51 z : ' a : argument DECIJ D~;CIJ+ I D~;CD+Z I -I (b) Fig. 1 shows example of HEX execution. If entry argument is as shown in part CD Fig. 1 Example of HEX execution of Fig. I, 5-digit BCD number, in this case "52734" is held in DECD (RAM) (see part @of Fig. 1) . SPECIFICATIONS NOTES\ ~HITACHI 791 19. CONVERTING 2-BYTE HEXADECI- MALS INTO S-DIGIT BCD I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I HEX DESCRIPTION I (2) User Notes "0" is always stored in MS (the 6th digit) of return argument. (3) RAM Description Label RAM Description b7 bO HEXD DECD f.- Upper byte Lower byte Upper byte -} 2-byte hexadecimal number is stored. f.- S-digit BCD number is stored. f.- (4) Sample Application Lower byte =1 Subroutine HEX is called after 2-byte hexadecimal number is held. WORK 1 RMB 2 Reserves memory byte for 2-byte hexadecimal number. WORK 2 RMB 3 Reserves memory byte for S-digit BCD number. PSHA PSHB PSHX }----- Saves register contents that will be destroyed by HEX execution. LDD WORK 1 Stores 2-byte hexadecimal number into STD HEXD }----- entry argument (HEXD). /I JSR HEX /I Calls subroutine HEX. LDD DECD } STD WORK2 Stores S-digit BCD number (return argument (DEGD» in RAM. :~~:::2 LDM STM PULX PULB } ----- . . "'"'"' I< 00003 CONVERTING 5-D!GIT BCD INTO >I< 00004 '" >i' 2-BYTE HEXADECIMALS (BCD) >I< 00005 >I< * 00006 ************************************************ 00007 >I< 00008 '" ENTRY DEC (5-DIGIT BCD) 00009 '" RETURNS HDATA (2-BYTE HEXADECIMALS) '" 00010 >I< '" 00011 >I< ************************************************ '" 00012 >I< 00013A OOBO ORG $80 00014 >I< 00015A 0080 0003 A DEC RMB 3 5-digit BCD 00016A 0083 0002 A HDATA RMB 2 2-byte Hexadecimals 00017A 0085 0001 A BCNTR RMB 1 Digit counter 00018 >I< 00019A FOOO ORG $FOOO 00020 >I< 00021 FOOO A BCD EQU *'IlDEC Entry ooint 00022A FOOD CE OOBO A LDX Load BCD data ADDR 00023A F003 86 05 A LDAA 115 Set figure counter 00024A F005 97 85 A STAA BCNTR 00025A F007 7F 00B3 A CLR HDATA Clear Hex area 00026A FOOA 7F 0084 A CLR HDATA+1 OOOnA FOOD 78 01 B5 BCD1 BTST O,BCNTR Test bitO of BCNTR 00028A F010 27 OF F021 BEQ BCD4 Branch i'f bitO ; 0 00029A F012 E6 00 A LDAB O,X Set lower 4 bits of BCD data 00030A F014 C4 OF A ANDB Il$OF 00031A F016 4F BCD2 CLRA Clear ACCA for work use 00032A FOl7 D3 83 A ADDD HDATA ACCD + HDATA:HDATA+1 - ) HDATA:HDA 00033A F019 DD 83 A STD HDATA 00034A F01B 7A 00B5 A DEC BCNTR Decrement digit counter 00035A F01E 26 09 F029 BNE BCD5 Loop until figure counter; 0 00036A F020 39 RTS 00037A F021 E6 00 A BCD4 LDAB O,X Set upper 4 bits of BCD data 00038A F023 54 LSRB 00039A F024 5" LSRB 00040A F025 54 LSRB 00041A F026 54 LSRB 00042A F027 20 ED F016 BRA BCD2 Branch BCD2 00043A F029 7B 01 85 BCD5 BTST O,BCNTR Test bitO of BCNTR 00044A F02C 26 01 F02F BNE BCD3 Branch if bitO ; 1 00045A F02E 08 INX Increment BCD data ADDR 00046A F02F DC 83 A BCD3 LDD HDATA HDATA:HDATA+1 '" 2 -) ACCD 00047A F031 05 ASLD 00048A F032 DD B3 A STD HDATA ACCD -) HDATA:HDATA+1 00049A F034 05 ASLD HDATA:HDATA+1 '" 4 -) ACCD 00050A F035 05 ASLD 00051A F036 D3 B3 A ADDD HDATA ACCD + HDATA:HDATA+1 -) ACCD 00052A F038 DD 83 A STD HDATA ACCD -) HDATA:HDATA+1 00053A F03A 20 D1 FOOD 8RA BCD1 Branch BCD1 ~HITACHI 802 21- SORTING I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I SORT FUNCTION I (a) Sorts unsigned byte oriented data in RAM in descending order. (b) Permits number of bytes to be sorted to be freely selected. (c) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS Contents Storage Location Byte Lgth. •x : : Not affected Undefined ROM (Bytes) 22 I : Result RAM (Bytes) No. of ACCD 7 bytes to ACCB Stack (Bytes) ACCA 1 ACCA be sorted x x 2 Entry IX No. of cycles Starting x 400 Argu- address Reentrant ments of data IX 2 to be C V No sorted x x Relocation Z N No Re- turns - - - x x Interrupt I H Yes • • DESCRIPTION I b7 AccA bO ACCA($O.) I n: •I (1) Function Details blS IX bO I0 : I I X ( S 00 • 0 ) n : • : n I (a) Argument details RAM argu Starting address ~ Entry ACCA: Holds number of bytes to be ill -ments of data to be~$no.o $1. sorted; (No. of bytes to be sorted sorted (IX) $". $AO - 1) in I-byte hexadecimal number. s I' ~. $ • 6 IX : Holds starting address of data to be sorted in I-byte hexadecimal ~ ['"""~ number. ·0 Result Sorted SA" data $-.0 S I 6 $ 0 8 Fig. 1 Example of SORT execution "='" SPECIFICATIONS NOTESI "No. of cycles" in :'SPECIFICATIONS" represen ts the number of cycles needed to sort S-byte ascending data to descending. ~HITACHI 803 21. SORTING I MCU/MPU I HD6301/HD6303 FAMILY ILABEL I SORT DESCRIPTION I (b) Fig. I shows example of SORT execution. If entry arguments are as shown in part CD of Fig. 1, sorted data is stored from address $90 in descending order (see part @ of Fig. 1). As data to be sorted is 5-byte, $04 (No. of bytes to be sorted ($05) - 1) is held in ACCA. (2) User Notes When loading number of bytes to be sorted, hold "No. of bytes to be sorted - 1" to ACCA for effective loop processing. (3) RAM Description Label RAM Description b7 bO ~I Counter showing how many bytes remain to SCNT be sorted is stored. SCNT Counter showing how many bytes remain to be compared is stored. (4) Sample Application Subroutine SORT is called after starting address and number of bytes to be sorted are held. WORK 1 RMB I Reserves memory byte for number of bytes to be sorted. WORK 2 RMB 2 Reserves memory byte for starting address to be sorted. LDAA WORK 1 Loads number of bytes to be sorted into entry argument (ACCA). LDX WORK 2 Loads starting address of data to be sorted into entry argument (IX). II JSR SORT II Calls subroutine SORT. ~HITACHI 804 21. SORTING J MCU/MPU J HD6301/HD6303 FAMILY ILABEL I SORT DESCRIPTION I (5) Basic Operation (a) Fig. 2 shows how 3-byte values are sorted in descending order. 0 ____8~1 Input data LI_5____1__ Number of bytes First c~mparison times [IX,. 5 ---,III ..,.,.---- ....... 8 H ·········CD ......... @ ......... @ (Note) n=3 shows (n-l=2) I II 5 H comparison Second. c~mparl.son· tl.mes [ I 1\ I ·········0 ......... ~ X shows data exchange (n=2=1) Fig. 2 Example of sorting (i) Finds largest value among three and puts it into left position. (See Fig. 2 CD @ and G» (ii) Compares middle and right values and puts larger one in middle. (See Fig. 2 (0,~) (6) Program Processing 0) Uses IX as two pointers; one shows memory address where data is stored, the other shows memory address where the largest data after comparison is stored. (ii) First, uses IX as pointer showing memory address where data is stored. I (iii) Loads this data into ACCA to be compared. Increments address where data is stored using index addressing mode and compare new value with value in ACCA. (iv) If value is larger than compared value in ACCA, exchange them. (v) Loop (iii) to (iv) untill counter SCNT2 (RAM), showing number of remaining bytes, reaches "0". (vi) When SCNT 2 (RAM) reaches "0", the largest data compared with RAM is loaded into ACCA. (vii) Then use IX as pointer to indicate where the largest data will be stored. (viii) Stores contents of ACCA in address IX points, and load next address, at which the second largest data is to be stored, into IX. (ix) Decrements counter SCNTI (RAM) showing how many bytes remain to be sorted. (x) Loops (ii) to (ix) untill SCNTl (RAM) is "0". ~HITACHI 805 21. SORTING MCU/MPU SORT FLOWCHART ----{ Stores number of bytes to be sorted in SCNTl. 2 ----{ Stores number of bytes to be sorted in SCNT2. ----{ Saves starting address of data to be sorted in RAM. ~---{ Loads ACCA. the first data to be sorted into ----{ Increments address pointer. Compare contents of ACCA with value of ----{ data pointed by IX. Exchanges data in ACCA with that pointed by IX. ----{ Decrements number of bytes to' be compared. ---{ Tests if all comparisons are completed. Continued on next page ~HITACHI 806 21. SORTING MCU/MPU HD6301/HD6303 FAMILY SORT FLOWCHART ~~~~{ Stores the largest data in RAM in descending order. ----{ Indicates address where the second largest number will be stored. ----{ Decrements counter indicating number of bytes remaining to be stored. ----{ Loads number of bytes remaining to be compared. ~~~~1 Tests if all data is sorted. previous page RTS I ~HITACHI 807 21. SORTING I MCU/MPU I HD630l/HD6303 FAMILY ILABEL I SORT PROGRAM LISTING I 00001 ****************************************************** **~***** 00002 * * 00003 NAME SORTING (SORT) *>I< 00004 *>I< 00005 *************************************************************** 00006 >I< >I< 00007 * ENTRY ACCA (VOLUME OF SORTING DATA) >I< 00008 >I< IX (TOP ADDR OF SORTING DATAS) >I< 00009 >I< RETURNS NOTHING >I< 00010 >I< >I< 00011 *************************************************************** 00012 >I< 00013A 0080 ORG $80 00014 >I< 00015A 0080 0001 A SCNT1 RMB Counter tor sorting data 00016A 0081 0001 A SCNT2 RMB Counter tor comparing data 00017 >I< 00018A FOOO ORG $FOOO 00019 >I< 00020 FOOO A SORT EQU >I< Entry point 00021A FOOO 97 80 A STAA SCNT1 Sto re reste of sorting data 00022A F002 97 81 A SORTl STAA SCNT2 Store reste of comparing data 00023A F004 3C PSHX Push sorting data AoDR 00024A FOOS A6 00 A LDAA O.X Load sorting data 0002SA F007 08 SORT2 INX Set next sorting data ADDR 00026A F008 A1 00 A CMPA O,X Compare comparing data with sorting data 00027A FOOA 24 05 FOll BCC SORB Branch if comparing data> sorting data 00028A FOOC E6 00 A LDAB O.X Exchange each data 00029A FOOE A7 00 A STAA O,X 00030A F010 17 TBA Transfer exchanged data 00031A FOll 7A 0081 A SORB DEC SCNT2 Decrement comparing data counter 00032A F014 26 Fl F007 BNE SORT2 Loop untiL comparing data counter 0 00033A F016 38 PULX PuLL sorting data ADDR 00034A F017 A7 00 A STAA O,X Store max data 0003SA F019 08 INX Increment sorting data ADDR 00036A F01A 7A 0080 A DEC SCNTl Decrement soting data counter 00037A FOlD 96 80 A LDAA SCNTl Loop untiL sorting data counter 0 00038A F01F 26 El F002 BNE SORTl 00039A F021 39 RTS ~HITACHI 808 HD63011HD6303 SERIES HANDBOOK Section Eight Hardware Application Notes I ~HITACHI 809 FOREWORD The HD6301/HD6303 are CMOS 8-bit single chip microcomputers controlled by microprogramming. The HD6301/HD6303 provide 8-bit parallel handshake interfacing, pipeline control, halt and memory-ready functions for various kinds of data processing. APPLICATION NOTES are written to help users design hardware systems using examples of simple application functions with circuit diagrams, timing charts and program examples. Application examples in APPLICATION NOTES used in actual systems should be tested for proper operation. ~HITACHI 810 NOTE The following hardware application notes were prepared for HD6301YO/HD6303Y devices. The applications, howeve~ are generic in nature and also apply to HD6301Vl/HD6303R and HD630lXO/HD6303X devices. I ~HITACHI 811 Section 8 Hardware Application Notes Table of Contents Page APPLICATION NOTES GUIDE......................................... 815 1. Symbols....................................................... 815 2. Application Example Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 817 3. 1st Section (Hardware) .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819 4. 2nd Section (Software). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823 5. 3rd Section (Program Module) ..................................... 825 5.1 Specification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826 5.2 Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 832 5.3 Flowchart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836 6. 4th Section (Subroutine) ............................... , . . . . . . . . . . 837 7. 5th Section (Program Listing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 840 8. Program Module Execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 845 SYSTEM APPLICATION EXAMPLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 848 System Application Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848 1/0 PORT APPLICATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849 1. HD61830 (LM200) Graphic Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849 2. Darlington Transistor Drive (LED Dynamic Display) . . . . . . . . . . . . . . . . . . . .. 883 TIMER APPLICATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 896 3. Duty Control of Pulse Output and DA Conversion . . . . . . . . . . . . . . . . . . . . . . 896 4. Pulse Width Measurement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 912 5. Input Pulse Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 922 6. 8 x 4 Key Matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 932 INTERRUPT APPLICATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 947 7. AID Converter (HA16613A) Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 947 PARALLEL HANDSHAKE APPLICATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956 8. Standard Keyboard Interlace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956 9. Centronics Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 970 SCI APPLICATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 982 10. Data Transfer With Asynchronous SCI . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 982 11. Liquid Crystal Drived (HD61100A) Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . 998 $ HITACHI 812 EXTERNAL EXPANSION APPLICATIONS ............................... 1010 12. External Expansion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1010 13. Slow Device Interface ........................................... 1043 LOW POWER DISSIPATION/FAIL-SAFE APPLICATIONS ................... 1057 14. Low Power Dissipation Mode ...................................... 1057 15. HA1835P Control and Error Detection .............................. 1074 I ~HITACHg 813 ~HITACHI 814 1. Symbols Symbols and abbreviations used in APPLICATION NOTES are described below. 1.1 Operation ( ) c Contents «() Index addressing a+b Data transfer from a to + Addition Subtraction x = Multiplication / = Division 1\ = AND v = OR <±) Exclusive OR X NOT 1.2 Register Symbols in MCU/MPU ACCA Accumulator A ACCB Accumulator B ACCD Double accumulator (ACCA ACCB) CCR Condition code register I X a-bit, 16-bit index register IXH Upper a bits of index register IXL Lower a bits of index register. 1.3 Description of bits 0 through 5 of condition code register C Carry or borrow bit 0 V Overflow in 2's complement operation bit 1 I Z Zero bit 2 N Negative bit 3 I Interrupt mask bit 4 H Half carry bit 5 ~HITACHI 815 1.4 Others Equal sign Not-equal sign Greater than Less than Greater than or equal Less than or equal • • = Delineates ASCII characters $ Hexadecimal data Labels of successive addresses SCI Serial communication interface DDR Data direction register FRC Free running counter OCRl Output compare register 1 OCR2 Output compare:oregister 2 ICR Input capture register TCSRl Timer control/status register 1 TCSR2 Timer control/status register 2 TCSR3 Timer control/status register 3 RMCR Transfer rate/mode control register TRCSR TX/Rx contIDol status register RDR Receive data register TDR Transmit data register RPSCR RAM/port 5 control register TCONR Time constant register T2CNT Timer 2 up counter $HITACHI 816 2. Application Example Configuration This chapter explains the configuration of each system application example following this chapter. Each application example in APPLICATION NOTES is divided into 5 sections, as shown in figure 1. ,------------ - - - - - -------- - - --- 1st SECTION------~.~IHARDWARE DESCRIPTION ~ FUNCTION (HARDWARE) I MICROCOMPUTER I OPERATION PERIPHRAL DEVICES CIRCUIT DIAGRAM I PIN FUNCTIONS I 1 HARDWARE L _______________ _____OPERATION _____ _ _-.l r- - - - - - - - - - - - - - - - - - - - - - - - - - - - --, 2nd SECTION ------.....,1 SOFTWARE DESCRIPTIONf PROGRAM MODULE (SOFTWARE): CONFIGURATION I PROGRAM MODULE I FUNCTIONS PROGRAM MODULE PROCESS FLOW (Main Program) I -------------------~ ,---------------------- -----, 3rd SECTION ------.....~ PROGRAM MODULE - FUNCTION I (PROGRAM MODULE) DESCRIPTION-- ARGUMENTS I - CHARGES IN CPU I REGISTERS AND FLAGS I - SPECIFICATIONS - DESCRIPTION --.-Function Details - SPECIFICATIONS - User Notes NOTES -RAM Allocation I FLOWCHART -Sample : Application I -Basic I Operation I r L ____________ _ --- - - - --~ 4th SECTION------.....""ii-S~B;Ot7T~N1~- - - - - - - -F~C-;I;N- - - - - - - - - - - -1 (SUBROUTINE) I DESCRIPTION BASIC OPERATION : I PROGRAM MODULES USING I I THIS SUBROUTINE : I _____________ FLOWCHART ______________ 1 L L ~ r--------------------------~ 5th SECTION - - - - - - - t•..J1 PROGRAM LISTING MAIN PROGRAM LISTING 1 (PROGRAM LISTING) : PROGRAM MODULE : I LISTING I I SUBROUTINE LISTING ~------------------ ~ Figure 1. Application Example Configuration ~HITACHI 817 (I) 1st Section (Hardware) Describes functions, circuit diagram, hardware operation for each hardware application example and making specific use of HD6301YO/HD6303Y's characteristic functions. (2) 2nd Section (Software) Describes program module configuration which controls hardware application example explained in the 1st Section. Also shows main program of sample application. (3) 3rd Section (Program Module) Describes program modules except main program, presented in the 2nd Section, in detail. Each program module is described in the same format so that users can use them independently. (4) 4th Section (Subroutine) Describes subroutine used by each program module. When using program modules explained in the 3rd Section, refer to these subroutines, if necessary. (5) 5th Section (Program Listing) Provides program listings for sample application explained in the 1st section. ,A detailed explanation of all five sections follows. ~HITACHI 818 3. 1st Section (Hardware) 3.1 Function Describes system specifications for the hardware used in a particular application. Example: 1. 1.1 Function Initializes graphic mode and displays dot graphics on the LM200 liquid crystal IJlOdule. 3.2 Microcomputer Operation Describes typical functions of the microcomputer used in a particular application. Example: 1.1.2 Microcomputer Operation The HD630lYO transfers display data to the dot matrix liquid crystal graphic display controller LSI HD6l830 (LCTC) from port 3 onto the LCTC data bus (DBO ~ DE7), and transmits control signals E, R/W, and RS through port 1. Ports 1 and 3 are controlled by softWare. 3.3 Peripheral Devices Describes typical functions of the peripheral devices used in a particular application. I Example: 1.1.3 Peripheral Devices HD6l830 LCTC: Receives control signals and display data from the HD630lYO and in turn controls the HM6ll6 Display RAM and LM200. LM200 Liquid Crystal Module: Receives graphic display data and control signals from the HD6l830 LCTC. A resolution of 64 x 240 pixels is provided in LM200 graphic mode. In this application, the figures "sn", meaning HITACHI, are displayed. ~HITACHI 819 3.4 Circuit Diagram Describes the circuit diagram for the hardware example. Note) All microcomputers described in APPLICATION NOTES use the plastic DIP type package. Example: 1.1.4 Circuit Diagram LCTC control circuit is shown in figure 1-1. MCU HDeSOIYO LCTC +&V .. ~ 140 R~S HD81880 D .7 ' D'I '8 .. Liquid crystal module eL z 11 .0 GND 15C§ ~L~ 5 LM200 .f I. E 17 I\IW nM 10 -5V 18 RS :: DBa pF • XTAL 26 08 1 MAo : tMfbCJ 2& DBa MA, • u DBa MA'~I~________~~~~~~~~~ 8 EXTAL 28 DB4 MAs 80 BBpF 22 DBs 21 g:: MA459 MAs 58 MAIIS'1 HV 3Ukfl 7 R ·C 8 CR MA, 58 MAI5S MA. 540 MAl 8'1 .. 15pF MOo !HI MOl 85 MOl S40 MO, 83 ~g:~.~'~ __________-L~~~~L-I MD. :~ MD, wg13 Figure 1-1. LCTC Control Circuit $ HITACHI 820 3.5 Pin Functions Describes interface between microcomputer and the external circuit using a table. Example: 1.1.5 Pin Functions Pin functions at the interface between the HD6301YO and LCTC are shown in table 1-1. Table 1-1. Pin Functions Pin Name Active Level Pin Name Program (HD6301YO) Input/Output (High or LoW) Function (LCTC) Label P 10 Output High Enables signal E P1DTR Pll Output High Reads data R/W Low Writes data P12 Output High Selects instruction register RS Low Selects data register Pao Input/Output Data Lines DBa P3DTR PH Input/Output ---- DBl P32 Input/Output DB2 P33 Input/Output DB3 P3~ Input/Output DB4 P35 Input/Output DBs P 36 Input/Output DB6 P37 Input/Output ---- DB? "Active Level" in the table indicates the following: I High Logical 1 Low Logical 0 Logical 1 or 0 ~HITACHI 821 3.6 Hardware Operation Describes hardware operation for controlling an external circuit using a timing chart. Example: 1.1.6 Hardware Operation The timing chart for interfacing between the HD6301VO and each signal is shown in figure 1-2. Q) and ® in figure 1-2 show timing for read and write. Q;) Data from LCTC can be read duringQ)period. GD Data can be written to LCTC at the falling edge of signal E. LCTC pin names _ _ _ _.,. RS. R/W E DBo - DB. ______________________- J (HD8801YO .... LCTC) DB. -DB. (HD6801YO-LCTC) Figure 1-2. HD6301YO~LCTC Interface ~HITACHI 822 4. 2nd Section (Software) 4.1 Program Module Configuration Describes program module configuration to control the hardware application example. Each program module is numbered. No. of main program is "0", and the other program modules 'are numbered from 1 to N. Example: 1.2.1 Program Module Configuration The program module configuration for graphic display on the liquid crystal module is shown in figure 1-3. LZHMN LZHINT INITIALIZE MOVE LCTe DISPLAY Figure 1-3. Program Module Configuration 4.2 Program Module Functions Describes function of each program module using a table. "No." in the table matches "No." in the Program Module Configuration. Example: 1.2.2 Program Module Functions Program module functions are summerized in table 1-2. Table 1-2. No. 0 Program Module Functions Program Module Name MAIN PROGRAM Label L2HMN Function Demonstrates graphic display on LM200. I 1 INITIALIZE LCTC L2HINT Initializes LCTC for graphic mode. 2 CLEAR DISPLAY RAM L2HDCR' Clears display RAM to clear display. 3 DISPLAY DOT L2HDST Turns on and off 1 dot specified by row or column coordinate. 4 MOVE DISPLAY L2HMVE Moves dot display up, down, left, or right. ~HITACHI 823 4.3 Program Module Process Flow (Main Program) Describes sample main program to execute program modules, explained in (l) Program Module Configuration. Note) Stack pointer is initialized only in the main program. Example: 1.2.3 Program Module Process Flow (Main Program) The following flowchart (figure 1-4) demonstrates the process for displaying graphics on the LM200 liquid crystal display, using the modules described above. Figure 1-5 shows this applications display. Main Program +_.__.- ___-[ =;C~~~~I~~ initialize LC'l'C ----[ Execute L2HDCR to clear display RNI. ---{ =:. s:~::~:; ::::: ~!o=:,~!:a~~e, ---{load display data inta ACC". ___ -{::~:. data table address of display ---{Test if display data is cocnpleted. ---{'rest 1f 1 dot 1s turned on or off. ----{'l'Ilrn on 1 dot. ---{store instruction to turn off 1 dot. ----{Tum off 1 dot. Fiqurs 1-4. Main Program Flowchart =-- ~~ [ .... ••• .g ..•• n •••••• ••••• '" •••• 1• ••••1 l'dot·1 1 dot 5 dots Figure 1-5. Example of L2f101N Execution ~HITACHI 824 5. 3rd Section (Program Module) The 3rd Section consists of the parts as shown in figure 2. PART 1 ------~-FUNCTION (SPECIFICATION) ~ARGUMENTS CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS SPECIFICATIONS NOTES PART 2 ---------DESCRIPTION lFunction Details (DESCRIPTION) User Notes RAM Allocation Sample Application Basic Operation PART 3 - - - - - - - - FIDWCHART (FLOWCHART) I' ' ' - Modul. '00. , II~ II~ rnow.= I.roil!:" Nodul. . . . . , II~ II~ I ID. .eripti.n, I'<·0'_ Nodul• •oo., II~ II~ I I~ ArlJUll!enta: Contents Storaqe Location No. of Byte. Chan2sa in CPU ReSl1stera and FIlli_: ""COAces Seaclf1cation8. ROM (Bytes): I IICCA Entry I I I RAM (Bytes) I Stack (Byte.) I DC CJ No, of cycles. Reentrant: v . C Relocatablel I I I Interrupt Olt? I Re- Z turns I I I I H I I I • I Not affected " I Undefined t ; Result Descriptionl I- I I- I'p.elfie.tion. Not•• , Figure 2. Program Module Section ~HITACHI 825 5.1 Specification The Specification Part is shown in figure 3 ([ ===J: blocked off area in figure 3). This part explains function, arguments, changes in CPU registers and flags, specifications and specifications notes. Each numbered item in the figure is described below. C(2) 1(3) I r - -- - - - - - - - - - - - - --------------r------------- i --------- j (1)1 ,=,<~ Mod.', N~, II''''I~"' L-L_a_b_e_l-_:_ _ _ _ _ _... (4) ~ Function: L(6) L(7) L L (5) -+ Arguments: Changes in CPU Specifications: Storage No. of Re<;!isters and Flags: I Contents Location Bytes ACCD ROM (Bytes) : ACCA ACCB Entry I I I RAM (Bytes) : Stack (Bytes) : IX I I No. of cycles: Reentrant: C V Relocatable: I I I Interrupt OK?: Re- Z N turns I I I I H I I I • Undefined x Not affected : : t : Result ________ J Description: 1. Function Details 2. User Notes (S'--r-I 'P'o"'oo",o, N."" ~ L ___________________________________________________________ ~ Figure 3. Specification Part ~HITACHI 826 (1) PROGRAM MODULE NAME: Example: Program Module Name: DISPLAY DOT (2) MCUjMPU: Indicates microcomputer and microprocessor applicable to the progr am. Example: MCU/MPU: HD630lYO (3) LABEL: Indicates the name identifying program entry point. When using the program without modification, use this label to call the program. Example: ~L2HDST (4) FUNCTION: Describes program function. Example: Function: Turns on or off 1 dot specified by row and column coordinates in entry arguments. I ~HITACHI 827 (5) ARGUMENTS: Describes entry arguments necessary to execute a program, and return arguments resulting from Program execution. (a) Contents: Describes contents of entry and return arguments. (b) Storage Location: Describes registers and RAM in which entry and return arguments are set. In case of RAM, the storage location is denoted by a label followed by "(RAM)". (c) No. of Bytes: Describes number of bytes for entry and return arguments. Example: Arguments: Storage No. of Contents Location Bytes Entry TUrn on/off DOT SET 1 indicator (RAM) Dot column DTX 1 coordinate (RAM) Dot row DTY 1 coordinate (RAM) Re- turns --- -- - (6) CHANGES IN CPU REGISTERS AND FLAGS: Describes changes in CPU registers and flags after program execution. Symbols and abbreviations in the table are shown below. (a) CPU registers. ACCA: Accumulator A ACCB: Accumulator B ACCD: Double accumulator (ACCA ACCB) IX: Index register ~HITACHI 828 (b) Flags in condition code register C Carry or borrow V OVerflow in 2's complement operation Z Zero N Negative I Interrupt mask H Half carry (c) Status of CPU registers and condition code flags • : NJt affected : Previous values retained after program execution. x Undefined Previous values destroyed after program execution. Result Program result contained. Example: Changes in CPU Registers and Flags: ACCD Note) ACCA ACCB x I x In this example, ACCA, ACCB, IX and bit IX C, bit V, bit N, bit Z of CCR are ~ destroyed after program execution. C V Thus, registers and flags, which will x x be destroyed, should be saved before N execution, if necessary. x x I H • • • x Not affected : Undefined Result I ~HITACHI 829 (7) SPECIFICATIONS: Describes program module specifications. (a) ROM (By~es): Indicates amount of ROM used in.the program module. (b) RAM (Bytes): Indicates amount of RAM used in the program module. RAM used by the stack, however, is not included. (c) Stack (Bytes): Indicates stack size used in the program module. Stack size used by called subroutines however, is not included. When executing a program module, the total stack size must be reserved. (d) No. of cycles: Indicates the maximum number of cycles when executing a program module. Execution time of the program module can be calculated using No. of cycles as follows. Execution time (sec)=No. of cycles x Cycle time Cycle time (sec)=4/(External oscillator (Hz» (e) Reentrant Indic.ates whether or not the program module can be called by two or more programs at the same time. (f) Relocatable Indicates whether or not the program module can be located in other memory space. (g) Interrupt OK?: Indicates whether or not the program module can be interrupted by other programs. If "No", disable interrupts before program execution and enable them after. ~HITACHI 830 Example: Specifications: ROM (Bytes): 134 RAM (Bytes): 9 Stack (Bytes): 6 No. of cycles: 513 Reentrant: No Relocatable: No Interrupt OK?: Yes (8) SPECIFICATIONS NOTES: Describes notes on items listed in"(7) SPECIFICATIONS". Example: Specifications Notes: 1. Values in "Specifications" include values for subroutines called by L2HDST. 2. "No. of cycles" in "Specifications" indicates the number of cycles required when L2HBSY is executed in the minimum number of cycles (no waiting for LM200). I ~HITACHI 831 5.2 Description r - - -, The Description Part is ~hown in figure 4. ( ~ __ J : blocked off area in figure 4). This part explains function details, user notes, RAM allocation, sample application and basic operation. Each numbered item in the figure is described below. (1) (2) (3) (1) (2) (3) r-- --- -- - - ___ L__________________1________________ J___________, r- ________________ 1____________________1__________________l__ ---------, iI ,"09<" Moo"'e N~e, II ~ II ~ Ii IP * 00104 * * 00105 ************************************************ 00106 (a) * * 00107 * ENTRY DTX(DOT COLUMN COORDINATE) * 00108 * DTY(DOT ROW COORDINATE) * 00109 * DOTSEHTURN ON/OFF INDICATOR) * 00110 * RETURNS NOTHING * 00111 (b) * * 00112 ~ ************************************************ 00113A C068 96 4~ ~ LDAA DTX Load coLumn coordinate 00114A C06A 84 F8 A ANDA "$F8 DTX AND $F8-)DTWK OOllSA ·C06C 97 4A A STAA DTWI< 001l6A C06E 44 LSRA (DTX AND $F8)/8-)CCNT 00117A C06F 44 LSRA 001l8A C070 44 LSRA 00119A C071 97 47 A STAA CCNT 00120A C073 96 49 A LDAA DTY DTY*30->IX 00121A C07S C6 lE A LDAB "$1E 00122A C077 3D MUL 00123A C078 18 XGDX 00124A C079 06 47 A LDAB CCNT IX+CCNT-)CURH:CURL 0012SA C07B 3A ABX 00126A C07C 18 XGDX 00127A C07D 97 43 A STAA CURH 00128~ C07F 07 42 A STAB CURL 00129A C081 BD C12S A JSR L2HCST Store cursor address 00130A C084 96 48 A LDAA DTX 00131A C086 D6 4A A LDAB DTWI< 00132A C088 10 SBA DTX-DTWK->DATAR 00133A C089 97 41 A STAA DATAR 00134A C088 96 4B A LDAA DOT SET Store turning on/off data 0013SA C08D 97 40 A STAA INSTR 00136A C08F BD C103 A JSR L2HIST Turn on/off 1 dot 00137A C092 39 RTS (a) Program module title is always followed by the entry point label in parenthesis and description of entry and return arguments. (b) Entry point label. $HITACHI 842 (5) Subroutine: Gives subroutine listing. Example: 00217 1************************************************ 00218 * * 00219 (a) * NAME: L2HIST (STORE DISPLAY INSTRUCTION) * 00220 (b * * 00221 ) " , l**~********************************************* 00222A CI03 80 COEA ~ JSR L2H8SY Check LCTC busy fLag 00223A CI06 86 04 A LOAA ~$04 Set RS=l,R/W=O,E=O 00224A CI08 97 02 A STAA PIOTR 00225A CI0A 86 05 A LOAA ~$05 Set E=l 00226A CI0C 97 02 A STAA PIOTR 00227A CI0E 96 40 A LOAA INSTR Output 1nstruct1on through port3 00228A ClIO 97 06 A STAA P30TR 00229A C112 86 04 A LOAA ~$04 Set E=O 00230A Cl14 97 02 A STAA PIOTR 00231A Cl16 7F 0002 A CLR PIOTR Set RS=O 00232A C119 86 01 A LOAA ~$01 Set E=l 00233A Cl18 97 02 A STAA PIOTR 00234A ClIO 96 41 A LOAA OATAR Output data through port3 00235A CIIF 97 06 A STAA P30TR 00236A C121 7F 0002 A CLR PIOTR Set E=O 00237A C124 39 RTS (a) Subroutine title is followed by the entry point label in parenthesis. (b) Entry Point label. (6) Data Table: Describes data table used in the main program, program modules and subroutines. Example: 00254 ************************************************ 00255 00256 00257 (a) 1** DATA TA8LE ** 00258 (b)", l:**********************************************: 00259A Cl3C 00 ~ FCB $0,$32 *Instruct1on and data- 00260A Cl3E 01 A FCB $1,$07 to 1n1tiaLize LCTC 00261A C140 02 A FCB $2,$10 00262A C142 03 A FCB $3,$lF 00263A C144 04 A FCB $4, $00 00264A C146 08 A FCB $8, $00 00265A C148 09 A FCB $9, $00 00266A C14A OA A FCB $A, $00 00267A C14C OB A FCB $B, $00 00268A C14E 01 A OTOATA FCB $01 *01spLay data 00269A C14F 01 A FCB $01 00270A C150 01 A FCB $01 (a) The title is always "DATA TABLE". (b) Data table label. ~HITACHI 843 (7) vector Address: Describes vector address allocation. Example: 00311 00312 1················································ * * 00313 (a) * VECTOR ADDRESSES * 00314 ************************************************** 00315 00316 * 00317A FFEA ORG $FFEA 0031B * 00319A FFEA COOO A FOB L2HMN IRQ2 00320A FFEC COOO A FOB L2HMN CMI 00321A FFEE COOO A FOB L2HMN TRAP 00322A FFFO COOO A FOB L2HMN SID 00323A FFF2 COOO A FOB L2HMN TOI 00324A FFF4 COOO A FOB L2HMN DCI 00325A FFF6 COOO A FOB L2HMN ICI 00326A FFFB COOO A FOB L2HMN IRQlIISF 00327A FFFA COOO A FOB L2HMN SWI 0032BA FFFC COOO A FOB L2HMN NMI 00329A FFFE COOO A (b) FOB L2HMN RES 00330 * 00331 ~ (a) The title is always "VECTOR ADDRESSES". (b) Indicates the end of a program. This can be moved, if necessary. ~HITACHI 844 8. Program Module Execution The programs ~ .. APPLICATION NOTES have been written considering efficiency and portability. The following shows row to execute these programs and how to modify them according to user requirements. The procedure for calling programs in APPLICATION NOTES from user programs is shown in figure 7. All programs in APPLICATION NOTES are written as subroutines and should be called as shown. An example of a user program in which a program in APPLICATION NOTES is called as a subroutine is shown in figure 8. USER PROGRAM I Initialize (1) before execution (2) Program Module (3) (4) Call subroutine (5) (6) necessary registers Figure 7. Procedure for Calling Program Module in I APPLICATION NOTES ~HITACHI 845 User Program I I I I I LDAA #$00 STAA PlDTR STAA P3DTR LDAA #$01 ) --- Init1a1izes before executing program module. STAA P3DDR JSR L2HINT LDAA #$OF STAA OOTSET LDAA #$08 STAA DTX LDAA#$02 If --- BOlds entry arguments. STAA DTY II JSR L2HDST ---- Calls program module. Figure 8. Example of How to Execute a Program Module Explanation of figure 7. (1) Initialize Examples of items requiring initialization are input/output ports, control registers and counters used by the program module. Refer to Program Module Sample Application for data details. (2) Save registers The program modules use CPU registers for arithmetic operations destroying the original contents. Thus register contents should be saved if needed. Refer to the "CHANGES OF CPU REGISTERS AND FLAGS" column in "SPECIFICATIONS" (Part 1 in the 3rd SECTION-PROGRAM MODULE DESCRIPTION) for register status after a program module is executed. (3) Hold entry arguments Holds entry arguments in CPU registers or m~mory before calling a program module in the user program. Refer to "ARGUMENTS" in SPECIFICATIONS (FOrmat 1 in 3RD SECTION - Program Module) for details. (4) Call subroutine Program module is called. (5) Process result After a program module is executed, the results returned in the return arguments must be processed as required. Refer to "ARGUMENTS" in ~HITACHI 846 SPECIFICATIONS (Format I in 3RD SECTION - Program Module) for details. (6) Restore necessary registers Registers saved in (2) should be restored here. Note that when a program module is used as a subroutine, the stack area shown in SPECIFICATIONS (Format I in 3RD SECTION - Program Module) is necessary in addition to the stack area required by the subroutine calls in the user program. When any subroutine is called, this stack area must be reserved. I ~HITACHI 847 System Application Examples No. Item Microcomputer Function Device Page 1 HD61830 (LM200) HD6301YO I/O Port HD6301YO 39 ( portl) Graphic Mode Port3 HD61830 MM6116 LM200 2 Darlington HD6301YO I/O Port (Portl) HD6301YO 73 Transistor Drive Port6 8-digi t X 8-seg ment LED (LED Dynamic Display) 3 Duty Control of HD6301YO Timer2 HD6301YO 86 Pulse Output and (HD6303Y) Tout 3 pin DA Conversion 4 Pulse width HD6301YO Timer 1 HD6301YO 102 Measurement (HD6303Y) Tin Pin S Input Pulse Count HD6301YO Timer 2 HD6301YO 112 (HD6303Y) TCLK pin 6 8 x 4 Key Matrix HD6301YO I/O Port HD6301YO 122 ( Port 3) Port4 8 x 4 key matrix Timer 1 7 A/D Converter HD6301YO I/O port port3) HD6301YO 137 (HA16613A) Control ( portS HA16613A IRQl pin 8 Standard Keyboard HD6301YO I/O port (port6) HD6301YO 146 Interface (HD6303Y) IS pin ASCII keyboard 9 Centronics HD6301YO I/O port (port6) HD6301YO 160 Interface (HD6303Y) IS pin, as pin Centronics interface printer 10 Data Transfer with HD6301YO I/O port (portS) HD6301YO 172 Asynchronous SCI (HD6303Y) Asynchronous SCI Console typewriter 11 Liquid Crystal HD6301YO I/O port (port2) HD6301YO 188 Drived (HD61100A) (HD6303Y) Clock synchronous HD61100A Control SCI 10-digit X 8-segment LCD 12 External Expansion HD6301YO External expan- HD6301YO 200 (HD6303Y) sion function HD6321, HN27C64 HD63S0, HM6264 H2S71 13 Slow Device HD63B01YO MR pin HD6301YO 233 Interface External expan- HN482764G-3 sion function HM6264LP 14 Low Power HD6301YO Low power dis- HD6301YO 247 Dissipation Mode sipation mode (standbY) \sleep I/O port (Portl) port3 port6 lS HA183SP Control HD6301YO Trap function HD6301YO 264 and Error Detection I/O port (PortS)HA183SP port7 ~HITACHI 848 SECTION 1. HD61830 (IM200) GRAPHIC MODE 1.1 HARDWARE DESCRIPTION 1.1.1 Function Initializes graphic mode and displays dot graphics on the LM200 liquid crystal module. 1.1.2 Microcomputer Operation The HD6301YO transfers display data to the dot matrix liquid crystal graphic display controller LSI HD61830 (LCTC) from port 3 onto the LCTC data bus (DBO ~ DE7), and transmits control signals E, R/W, and RS through port 1. Ports 1 and 3 are controlled by software. 1.1.3 Peripheral Devices HD61830 LCTC: Receives control signals and display data from the HD6301YO and in turn controls the HM6116 Display RAM and LM200. LM200 Liquid Crystal Module: Receives graphic display data and control signals from the HD61830 LCTC. A resolution of 64 x 240 pixels is provided in LM200 graphic mode. In this application, the figures "sn", meaning HITACHI, are displayed. ~HITACHI 849 1.1.4 Circuit Diagram LCTC control circuit is shown in figure 1-1. MCU HD680lYO L C T C HD61880 Liquid crystal module o MPo 5 MP, : : Vee 8 NMI RES 7 STBY 20 GND 15 CS 88 Vee 50 16 E P,o 09 17 IVW P" 08 P 12 18 RS 58 P,. :~ DBo :t-_2_:~"""--2'XTAL f 57 PSI 26 DB, MAo 56 P" 55 25 DB, MA, 2 Display RAM P" 5. 20 DB, MA'r7I~-----------r~~~~__-r~~ 8 EXTAL P" 58 28 DB. 22pF MA, 60 P" 52 22 DB, MA. 59 P" 51 21 DB, MA, 58 P" DB, MAo 57 89kO 7 R MA, 56 MA, 55 6 C MA·54 8 CR MA, 37 15pF MDo 36 MD, 35 MD, 34 MD, 33 ~g!E372~____________L-~~-L~~-/ MD, :~ MD, WE" 13 Figure 1-1. LCTC Control Circuit ~HITACHI 850 1.1.S Pin Functions Pin functions at the interface between the HD630lYO and LCTC are shown in table 1-1. Table 1-1. Pin Functions Pin Name Active Level Pin Name Program (HD630lYO) Input/Output (High or Low) Function (LCTC) Label P 10 Output High Enables signal E PlDTR Pll Output High Reads data R/W -------------------------------------------- Low Writes data P12 Output High Selects instruction register RS Low Selects data register Pao Input/Output Data Lines DBO P3DTR Pn Input/Output ---- DBl P32 Input/Output ---- DB2 P3 3 Input/Output DB3 P34 Input/Output DB .. P3 s Input/Output DBs P 36' Input/Output ---- DB6 P37 Input/Output ---- DB7 1.1.6 Hardware Operation The timing chart for interfacing between the HD630lYO and each signal is shown in figure 1-2. @ and ® in figure 1-2 show timing for read and write. (y Data from LCTC can be read during(yperiod. @ Data can be written to LCTC at the falling edge of signal E. I ~HITACHI 851 LCTC pin names _ _ _ _~ RS. R/W E DBo - DB7 (lID6 3 0 1YO-+ LCTC) DBD - DB7 (HD63 01 YO+--LCTC) Figure 1-2. HD6301YO~LCTC Interface 1.2 SOFTWARE DESCRIPTION 1.2.1 Program Module Configuration The program module configuration for graphic display on the liquid crystal module is shown in figure 1-3. L2HMN ~. MAIN " PROGRAM I / L 2HINT I L2HDCR I L2HDST I L2HMVE I l2.. L:... L:... ~ INITIALIZE CLEAR DISPLAY MOVE LCTC DISPLAY RAM DOT DISPLAY Figure 1-3. Program Module Configuration ~HITACHI 852 1.2.2 Program Module Functions Program module functions are summerized in table 1-2. Table 1-2. Program Module Functions No. Program Module Name Label Function 0 MAIN PROGRAM L2HMN Demonstr ate s graphic display on LM200. 1 INITIALIZE LCTC L2HINT Initializes LCTC for graphic mode. 2 CLEAR DISPLAY RAM L2HDCR Clears display RAM to clear display. 3 DISPLAY DOT L2HDST Turns on and off 1 dot specified by row or column coordinate. 4 MOVE DISPLAY L2HMVE Moves dot display up, down, left, or right. 1.2.3 Program Module Process Flow (Main Program) The following flowchart (figure 1-4) demonstrates the process for displaying graphics on the LM200 liquid crystal display, using the modules described above. Figure 1-5 shows this applications display. I ~HITACHI 853 Main Program ----{ Initialize stack pointer. Initialize port 1 and port 3. Clear internal RAM. ____ [ Execute L2HINT to initialize LCTC for graphic mode. ----I Execute L2HDCR to clear display RAM. ____{LOad starting address of the data table, where display data is stored, into IX. ----[ Load display data into ACCA. ____{save data table address of display data. ----{Test if display data is completed. ----{Test if 1 dot is turned on or off. ----{Turn on 1 dot. U-_--,,-_-'-' ----{store instruction to turn off 1 dot. ----{ Turn off 1 dot. ____{ Restore data table address of display data. ____ { Increment data table address of display data. Figure 1-4. Main Program Flowchart ~HITACHI 854 ~ I~~ [.... . 11 .g LO • • ••••• •••• • • • • •• •••• •••••.1 14 dot~1 .I. 5 dots 1 dot Figure 1-5. Example of L2HMN Execution I • HITACHI 855 1.3 PROGRAM MODULE DESCRIPTION Program Module Name: INITIALIZE LCTC MCU/MPU: HD6301YO Label: L2HINT Function: Initializes LCTC for graphic mode. Arguments: Changes in CPU Speci fica tions.: Registers and Flags: None ACCD ACCA ACCB ROM (Bytes) : 90 x I • RAM (Bytes) : 2 IX Stack (Bytes) : 4 x No. of cycles: 123 Reentrant: No C V Relocatable: No x x Interrupt OK?: Yes Z N x x I H • • • Not affected x : Undefined Resul t Description: 1. Function Details a. L2HINT has no arguments. b. Instruction and data in table 1-3 are written to LCTC to initialize LCTC for graphic mode. Specifications Notes: 1- Values in "Specifications" include values for subroutines called by L2HINT. 2. "No. of cycles" in "Specifications" indicates the number of cycles required when L2HBSY is executed in the minimum number of cycles (no waiting for LM200). ~HITACHI 856 Program Module Name: INITIALIZE LCTC ~M_C_U_/_M_P_U_:_HD __6_3_0_1_Y_0______ ~ I~L_a_b_e_l_: __L_2_H_I_NT ______ ~ Description: Table 1-3. Instruction and Data to initialize LCTC. Instruction Data Function $00 $32 Selects display on, master mode, graphic mode. $01 $07 Displays 8-bit data sent from RAM. $02 $lD Defines number of horizontal bytes. $03 $lF Defines duty rate as 1/32. $04 $00 Selects cursor position. (Note) $08 $00 Selects display starting address to $0000. $09 $00 $OA $00 Selects cursor address to $0000. $OB $00 Note: Display initialized £or graphic mode, cursor is not displayed. c. L2HINT calls subroutines shown in table 1-4. Table 1-4. Subroutines Called by L2HINT Subroutine Name Label Function Stores Display L2HIST Writes data LCTC instruction register and data Instruction register. Check Busy L2HBSY Checks LCTC busy flag. Flag 2. User Notes The following procedure must be executed be£ore L2HDCR execution. I a.. Reserve instructions and data in a data table. b. Select DDR of port 1 and port 3 as output. 3. RAM Allocation Label b7 RAM Description bO INSTRIr-----------, Data to be written to LCTC instruction register DATAR ~. __________ ~ Data to be written to LCTC data register ~HITACHI 857 Program Module Name: INITIALIZE LCTC .I. ....M_C_U_I_M_P_U_:_HD_6_3_0_1_Y_O_ _---' L_a_b_e_l_·:_L_2_H_I_NT _ _ _...... Description: 4. Sample Application I I I I CLRA STAA STAA LDAA P1DTR P3DTR #$01 }..... Initialize port 1 and port 3. STAA P1DDR STAA P3DDR J S R L2HINT ••••• Call L2HINT I LCTCl FCB $0, $32 I •••.• Reserve data table I I 5. Basic Operation a. To initialize graphic mode, instructions and data in table 1-3 are written to LCTC instruction register and data register, respectively. b. Instruction register and data register are used in pairs, and are selected by RS signal. c. Instruction and data in table 1-3 are held in INSTR(RAM) and DATAR(RAM) using index addressing mode. I~ L2HIST is called, data is written to LCTC instruction register and data register. d. In L2HINT, port 1 controls R/W, E, and RS signals • • HITACHI 858 L-p_r_o_g_r_a_m__M_o_d_u_l_e__N_am __e__:_I_N_I_T_I_AL C~ __I_Z_E__L_CT __ LM __C_U_/_M_P_U_:_HD __6_3_0_l_Y_o______ _ ~I~L ab __e_l_:_L_2_H_I_NT ________ ~ Flowchart: Load starting address of data table, -- { where instructions code and data are stored, into address pointer. __ {store instruction code in L2HIST entry argument. - - {Increment address pointer of data table. ---[store data in L2HIST entry argument. __ {Execute L2HIST to write instruction code and data to LCTC and initialize it. ---[Increment address pointer of data table. --{ Test if LCTC initializing is completed. $HITACHI 859 Program Module Name: CLEAR DISPLAY MCU/MPU: HD6301YO Label: L2HDCR RAM Function: Stores $00 in display RAM to clear display on LM200. Arguments: Changes in CPU Specifications: Registers and Flags: None ACCD ROM (Bytes): 133 ACCA ACCB x I • RAM (Bytes): 6 Stack (Bytes): 6 IX • No. of cycles: 211474 Reentrant: No C v Relocatable: No x x Interrupt OK?: Yes Z N x x I H • • • Not affected x : Undefined t Result Description: 1. Function Details a. L2HDCR has no arguments. b. After L2HDCR execution, display or LM200 is cleared. c. L2HDCR calls subroutines shown in table 1-5. Specifications Notes: 1. Values in "Specifications" include values for subroutines called by L2HDCR. 2. "No. of cycles" in "Specifications" indicates the number of cycles required when L2HBSY is executed in the minimum number of cycles (no waiting for LM200). ~HITACHI 860 Program Module Name: CLEAR DISPLAY MCU/MPU: HD6301YO RAM IL O b01' L2HDCR Description: Table 1-5. Subroutines called by L2llDCR Subroutine Name Label Function Store Cursor L2HCST Stores LCTC cursor address. Address Continuous L2HDSP Continuously displays on LM200. Display Store Display L2HIST Stores data in LCTC instruction register Instruction and data register. Check Busy L2HBSY Checks LCTC busy flag. Flag 2. User Notes The following procedure must be executed before L2HDCR execution. a. Select DDR of port 1 and port 3 as output. b. Initialize LCTC display mode. 3. RAM Allocation Label RAM Description b7 bO CURL } Lower byte of cursor address CURH } Upper byte of cursor address DCOUNT - Upper Lower - } Counter for repeated DATA } Display data I 4. Sample Application CLRA ~ STAA PIDTR STAA P3DTR LDAA #$01 •.... Initialize port 1 and port 3. STAA PIDDR STAA P3DDR JSR L2HINT Call L2HINT to initialize LCTC. JSR L2HDCR Call L2HDCR II " ~HITACHI 861 Program Module Name: CLEAR DISPLAY RAM MCU/MPU: HD630lYO I Label , L2HDCR Description: 5. Basic Operation a. When displaying graphics on LM200, cursor address and display data are written to LCTC. b. L2HCTS is called to store $0000 in cursor address. c. LM200 uses 1920 bytes in 1 display screen. d. L2HDSP is called to store $00 throughout RAM so that display on.LM200 can be cleared. L2HDSP uses auto-increment function for cursor address. ~HITACHI 862 Program Module Name: CLEAR DISPLAY RAM MCU/MPU: lID6301YO I~ L2lIDCR Flowchart: __ Jclear L2HCST entry arguments to initialize llcursor address to $0000. __ {Execute L2HCST and initialize cursor address to $0000. Store 1920 in L2lIDSP entry argument to -- { repeat writing 1920 byte data in display RAM. __ {store "$00" in L2lIDSP entry argument to clear display RAM. ---[Execute L2lIDSP to Clear'LM200 Display. I ~HITACHI 863 Program Module Name: DISPLAY DOT MCU/MPU: HD6301YO Label: L2HDST Function: Turns on or off 1 dot specified by row and column coordinates in entry arguments. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: contents Location Bytes ACCD ROM (Bytes): 134 ACCA ACCB Entry Turn on/off DOT SET 1 x x RAM (Bytes): 9 indicator (RAM) Stack (Bytes): 6 IX Dot column DTX 1 x No. of cycles: 513 coordinate (RAM) Reentrant: No Dot row DTY 1 c v Relocatable: No coordinate (RAM) x x Interrupt OK?: Yes Re- Z N turns --- -- x x I H • • • Not affected x : Undefined Result Description: 1. Function Details a. Argument details DOTSET(RAM): Data to indicate turning on or off 1 dot. DOTSET(RAM)=$OE : Turn off 1 dot. DOTSET(RAM)=$OF : Turn on 1 dot. DTX(RAM) Dot column coordinate in hexadecimal number. DTY(RAM) Dot row coordinate in hexadecimal number. Specifications Notes: 1. Values in "Specifications" include values for subroutines called by L2HDST. 2. "No. of cycles" in "Specifications" indicates the number of cycles required when L2HBSY is executed in the minimum number of cycles (no waiting for LM200). ~HITACHI 864 Program Module Name: DISPLAY DOT ---I1\. . LM_C_U_I_M_P_U_:_HD_6_3_0_1_Y_O_ _ L_a_b_e_l_:_L_2_HD_S_T_ __ Description: b. Example of L2HDST execution is shown in figure 1-6. If entry arguments are as shown in partQ) of figure 1-6, 1 dot is displayed as shown in part @ of figure 1-6. DOTSET (RAM) b7 DOTSET bO ( Turn on/Off) data ($OF) I ° :F I CD Entry DTX (RAM) Dot cOlumn) ( coordinate DTX arguments ($03) DTY (RAM) Dot row ~ ( coordinate ($02) 10: 2 + @ Result Figure 1-6. Example of L2HDST Execution c. L2HDST calls subroutines shown in table 1-6. Table 1-6. Subroutines Called by L2HDST Subroutine Name Label Function Store Cursor L2HCST Stores LCTC cursor address. Address Continuous L2HIST Stores data in LCTC instruction register and data Display register. Check Busy Flag L2HBSY Checks LCTC busy flag. 2. User Notes The following procedure must be executed before L2HDST execution. a. Select DDR of port 1 and port 3 as output. b. Initialize LCTC display mode. c. Store entry arguments. ~HITACHI 865 L-p_r_o_g_r_arn __ M_o_d_ll_l_e_N_arn_e_:_D_I_S_P_LA_Y_D_O_T_ _...J ..M_C_U_I_M_P_U_:_HD_6_3_0_l_Y_0_ _---' ...1L_a_b_e_l_:_L_2_HD_S_T_ _---' Description: 3. RAM Allocation Label RAM Description b7 bO INSTR } Data to be written to LCTC instruction register DATAR } Data to be written to LCTC data register DTX } Dot column coordinate DTY } Dot row coordinate CURH } Upper byte of cursor address CURL } Lower byte of cursor address Work area for calculating cursor address based CCNT } on column coordinate Work area for obtaining 1 dot to be turned DTWK } on/off DOTSET } Data to indicate turning on/off 1 dot 4. Sample Application I I I I CLRA STAA PlDTR STAA P3DTR LDAA STAA STAA #$01 PlDDR P3DDR } Initialize port 1 and port 3. JSR L2HINT Call L2HINT to initialize LCTC IDAA STAA '$OFSET ) DOT LDAA #$08 •••.. Store entry arguments STAA DTX IDAA #$02 STAA DTY JSR L2HDST .•••• Call L2HDST I II ~HITACHI 866 Program Module Name: DISPLAY DOT MCU/MPU:HD6301YO Label: L2HDST Description: 5. Basic Operation a. The formula below calculates cursor address and dot to be turned on/off, based on column and row coordinates. Row coordinate x 30 + I (Column coordinate /I $FS) /sl Cursor address ..•••.••.••..•.••.• (Formula 1) Column coordinate - (Column coordinate /I $FS) Number of bits •.••••..••••.•.•..• (Formula 2) b. After cursor address is calculated by Formula 1, upper byte and lower byte of cursor address are held in CURH(RAM) and CURL(RAM), respectively. If L2HCST is executed, cursor address is written to LCTC. c. If number of bits obtained by Formula 2 is held in DATAR(RAM) , L2HIST execution turns on or off 1 dot. I ~HITACHI 867 Program Module Name: DISPLAY DOT MCU/MPU: HD630lYO --- / Label: L2HDST Flowchart: Calculate cursor address using (formula 1) in (5) Basic Operation. (ACCD)-( IX) (ACCD)-+ CURH:CURL --{ Execute L2HCST to store cursor address in LCTC register. (DTX)-+ACCA Calculate bit location using (formula 2) in (5) Basic Operation (DTWK)-+ACCB and store result in L2HIST entry argument. (ACCA)-(ACCB) -+DATAR --{ Store turn on/off instruction in L2HIST entry argument. --{ Execute L2HIST to turn on/off 1 dot. ~HITACHI 868 Program Module Name: MOVE DISPLAY MCU/MPU: HD6301YO Label:L2HMVE Function: Moves current displayed dot up, down, left, or right 1 dot. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes): 200 ACCA ACCB Entry Moving ACCA 1 x x RAM (Bytes): 9 direction Stack (Bytes): 8 IX x No. of cycles: 560 Reentrant: No c v Relocatable: No x x Interrupt OK?: Yes Re- z N turns x x I H • • • Not affected x : Undefined Resul t Description: 1. Function Details a. Argument details ACCA : Data indicatinq which direction 1 dot will be moved. ACCA=$Ol ACCA=$02 ACCA=$03 ACCA=$04 Move Move Move Move 1 dot right. 1 dot left. 1 dot down. 1 dot up. I Specifications Notes: 1. Values in "Specifications" include values for other program modules and subroutines called by L2HMVE. 2. "No. of cycles" in "Specifications" indicates the number of cycles required when L2HBSY is executed in the minimum number of cycles (no waiting for LM200). ~HITACHI 869 Program Module Name: MOVE DISPLAY L2 ....M_C_U_/_M_P_U_:_HD_6_3_0_1_Y_O_ _---' 1 ....L_a_b_e_l_:__ HM_VE _ _ _.....J Description: b. Example of L2HMVE execution is shown in figure 1-7. If entry argument is as shown in part CD of figure 1-7, dots are displayed as shown in part ® of figure 1-7. c. L2HDST calls other program modules and subroutines shown in table 1-7. LM200 display before L2HMVE execution (1,3) ACCA b 7 ACCA bO CD Entry argument { (Moving~ dir~:~ion~l IM200 display @ Result after L2HMVE execution (2,3) Figure 1-7. Example of L2HMVE Execution Table 1-7. Program !-1odules and Subroutines Called by L2HMVE Program Module/ Subroutine Name Label Function Display Dot L2HDST Turns on/off 1 dot. Store Cursor L2HCST Stores LCTC cursor address. Address Continuous L2HIST Stores data in LCTC instruction register and Display data register. Check Busy L2HBSY Checks LCTC busy flag. Flag 2. User Notes The following procedure must be executed before L2HMVE execution. a. Select DDR of port 1 and port 3 as output. b. Initialize LCTC display mode. c. Load entry argument. ~HITACHI 870 ~p_r_o_g_r_am ___M_o_d_u_l_e__N_a_m_e_'_'_M_O_VE ___D__ __ I_S_P_LA Y__ ~ ~M __ C_U_/_M_P_U_:_HD __6_3_0_l_y_0______ ~1~L_a_b_. e__ l_:__L_2_HM __VE ______ ~ Description: 3. RAM Allocation Label RAM Description b7 bO INSTR } Data to be written to LCTC instruction register DATAR } Data to be written to LCTC data register DTX } Dot column coordinate DTY } Dot row coordinate CURH } upper byte of cursor address CURL } Lower byte of cursor address Work area for calculating cursor address based CCNT } on column coordinate Work area for obtaining 1 dot to be turned DTWK } on/off DOT SET } Data to indicate turning on/off 1 dot 4. Sample Application I I CLRA STAA P1DTR STAA P3DTR LDAA #$01 ..... Initialize port 1 and port 3. STAA STAA JSR PlDDR P3DDR L2HINT 1 Call L2HINT to initialize LCTC. LDAA #$01 Load entry argument JSR L2HMVE II Call L2HMVE II 5. Basic Operation a. After moving determined direction, DTX(RAM) pointing to dot column coordinate or DTY(RAM) pointing to row coordinate are incremented or decremented. b. L2HDST is called to display 1 dot specified in (a). ~HITACHI 871 L-p_r_o_g_r_a_m__M_o_d_u_l_e__N_am __e__ :_M_O_V_E__D_I_S_P_LA __y____ ~ ~M __ C_U_/M __P_U_:_H_D_6_3_0_l_y_O______ ~ ~IL__ ab __e_l_:__L_2_HM __V_E______ ~ --{ Test if move 1 dot to right. --{ Test if row coordinate is right most. --{ Increment row coordinate. Test if move 1 dot to left. --{ most. Test if row coordinate is left. ---{ Decrement row coordinate. Test if move 1 dot down. --{ Test if column coordinate is down most. --{ Increment column coordinate. Test if move 1 dot up. Test if column coordinate is up most. Decrement column coordinate. L2HME4~--------~-----------L----------~ __ { Execute L2HDST to rutn on 1 dot. ~HITACHI 872 1.4 SUBROUTINE DESCRIPTION Subroutine Name: CONTINUOUS DISPLAY MCULMPU: HD6301YO Label: L2HDSP Function: Displays specified bytes continuously from the present cursor address. Basic Operation: 1. DCOUNT(RAM) is used as a counter to execute L2HIST, writing display data to LcrC until counter is "0". 2. L2HDSP uses auto-increment function of cursor address. Program Module Using This Subroutine: L2HDCR Flowchart: __ { Store instruction to store display data in L2HIST entry argument. __ { Store display data in L2HIST entry argument. __ {Execute L2HIST to write display data in LCTC. (ACCD)-$Ol Decrement counter for continuous -+ DCOUNT : DCOUNT+1 display. (DCOONf : DCOUNT +1)#0 display is I ~HITACHI 873 Subroutine Name: STORE CURSOR MCULMPU: HD630lYO Label: L2HCST ADDRESS Function: Writes upper and lower bytes of cursor address to LCTC. Basic Operation: L2HIST is called twice since lower byte of cursor address is written to LCTC first, and then upper byte to LCTC. Program Module Using This Subroutine: L2HDCR, L2HDST, L2HMVE Flowchart: __ {store instruction data for loading lower cursor address. - - {stores lower cursor address. __ {write instruction and ,address into LCTC register. __ { Store instruction data for loading upper cursor address. " --{store upper cursor address. __ {write instruction and address into LCTC register. ~HITACHI 874 Subroutine Name: STORE DISPLAY MCULMPU: HD630lYO Label: L2HIST INSTRUCTION Function: Writes instruction and data to LCTC. Basic Operation: 1. LCTC busy flag is checked. 2. Data is written to LCTC through port 1 controlling DS, R/W, E signals of LCTC. Program Module Using This Subroutine: L2HINT, L2HDCR, L2HDST, L2HMVE Flowchart: - - { Execute L2HBSY to check busy flag. __ { Set signal RS to High to select instruction register of LCTC. - - { Set signal E to High. __ {output instruction from port 3 to LCTC register. - - { Set signal E to low. __ { Set signal RS to Low to select data register of LCTC. --{ Set signal E to High. __ {output data from port 3 to LCTC register. - - { Seg signal E to Low. I ~HITACHI 875 Subroutine" Name: CHECK BUSY FLAG McuLMPU: !ID6301YO Label: L2HBSY Function: Tests if LCTC is in operation, and waits until LCTC is ready. Basic Operation: 1. Since the microcomputer cannot access LCTC when LCTC is in operation, microcomputer determines LCTC condition by checking busy flag. 2. Busy flag is read through port 1 controlling RS, R/W, E signals. Program Module Using This Subroutine: L2HINT, L2HDCR, L2HDST, L2HMVE Flowchart: --{ Select port 3 as input to read busy flag. --{ Set signals RS and R/W to High. --{ Set signal E to High. ( P8DTR)-ACCA - - { Read busy flag. $06-PIDTR --{ Set signal E to Low. (ACCA) --1 Check bu'Y flag. --{ Select port 3 as output. ~HITACHI 876 1.5 PROGRAM LISTING 00001 >I< 00002 >1<>1<>1<>1< RAt·1 ALLOCATION >1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1< 00003 >I< 00004A 0040 ORG $40 00005 >I< 00006A 0040 0001 A INSTR RMB 1 LCTC instruction register data 00007A 0041 0001 A DATAR RMB 1 LCTC data register data OOOOBA 0042 0001 A CURL RMB 1 Lower byte of cursor address 00009A 0043 0001 A CURH RMB 1 Upper byte of cursor address 00010A 0044 0002 A DCOUNT RMB 2 Counter for continuous dispLay OOOllA 0046 0001 A DATA RMB 1 DispLay data 00012A 0047 0001 A CCNT RMB 1 Wor!< area for cursor address 00013~) 004B 0001 A DTX RMB 1 Dot coLumn coordinate 00014A 0049 0001 A DTY RMB 1 Dot row coordinate 0001SA 004A 0001 A DTWI< RMB 1 Wor'!< area for turning onloff data 00016A 004B 0001 A DOT SET RMB 1 Turning onloff data 00017 >I< 0001B >1<>1<>1<>1< SYMBOL DEFINITTIONS >1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1< 00019 >I< 00020 0000 A PlDDR EDU $00 Pod data dir'ection register 00021 0002 A PIOTR EQU $02 Por't data register 00022 0004 A P3DOR EDU $04 Pod 3 data dir'ection register 00023 0006 A P3DTR EDU $06 POl't 3 data r'eg i ster' 00024 ***********~:***~:*:k**********~;~:****************** 00025 >I< >I< 00026 >I< MAIN PROGRAM : L2HMN >I< 00027 >I< >I< 00028 ***********~:**~;~;*:I(***~C***:~****~:k**~***********~* 00029 >I< 00030A COOO ORG $COOO 00031 >I< 00032A COOO 8E 013F A L2HMN LOS jj$13F InitiaLize stac!< pointer 00033A C003 4F CLRA 00034A C004 97 02 A STAA PIOTR InitiaLize por't 1 0003SA C006 97 06 A STA(-) P30TR InitiaLize pod 3 00036A C008 86 01 A LOM jj$Ol Select pod ::; as output 00037A COOA 97 00 A STA!~ P10DR ; 00038A COOC 9'( 04 A STA(~ P3DDR 00039A COOF. 4F CLRA CLea,' RAM 00040A COOF CE OOCO A LOX jj$CO 00041A C012 ~\'( 3F A L2HMNl STAA $3F, X 00042A C014 09 DEX 00043A C01S 26 F8 C012 BNE L2H~1N1 00044A C017 SD C052 A JSR L2HINT CLear display RAM 0004SA COlA SD C030 A JSR L2HDCR InitiaLize LCTC 00046A COlD CE C14E A LDX jjDTDATA Load data table starting address 00047A C020 A6 00 A L2HMN2 LDAA O.X Load dispLay data into ACCA 00048A C022 3C PSHX Save data tabLe address 00049A C023 81 FF A CMPA jj$FF loop until dispLay is cOlilPLeted I 00050A C02S 27 14 C03B SED PEND OOOSlA C027 81 00 A CMPA jjOO Test if 1 dot is tUI'I"led on/off 000S2A C029 26 OB C036 BNE L2HMN4 Br'anc!'l i f tUI'lled on 00053A C02B 86 OE A LDAA jj$OE Stor'e instr'uction to lu,'n off 000S4A C02D 97 4B A STAA DOTSET OOOSSA C02F BO C068 ~\ JSR L2HOST Turn off 1 dot 000S6A C032 38 L.2HMN3 PULX Restore data table addr'ess 000S7A C033 08 INX Increment data tab Le addr'ess ~HITACHI 877 000S8A C034 20 EA C020 BRA L2HMN2 000S9A C036 BD C093 A L2HMN4 JSR L2HMVE Turn on 1 dot 00060A C039 20 F7 C032 [~HA L2Ht~N3 00061A C038 20 FE C03B PEND BRA PEND End of program 00062 00063 *>I< * 00064 NAME : L2HDCR (CLEAR RAM) * 00065 >I< * 00066 *********~******************l~********:k****)~***~;* 00067 >I< * 00068 >I< ENrRY : NOTHING * 00069 >I< RETURNS: NOTHING * 00070 * 00071 *******:k*********************************)k***)~.~* 00072A C03D 7F 0043 A L2HDCR CLR CURH Load SOOOO into cursor address 00073A C040 7F 0042 A CLR CURL 00074A C043 BD C12S A JSR L2HCST Wr'He SOOOO to cur'SOl' addl'ess 0007SA C046 CC 0780 A LDD ~1920 Load data to repeat writing 1920 bytes 00076A C049 DD 44 A STD DCOUNT 00077A C04B 7F 0046 A CLR DATA Load SOO 00078A C04E BD CODS A JSR L2HDSP CLear display 00079A COS1 39 RTS OOOBO ******************~(***:~****************'~)k******:~ 00081 'I' 000B2 *>I< NAME: L2HINT (INITIALAIZE LCTC) 00083 '" 00084 * '" 00085 * 00086 * ENTRY : NOTHING 00087 * RETURNS : NOTHING " 0008B * * 00089 ******************************************~(******* 00090A COS2 CE Cl3C A L2HINT LOX IILCTCI Load data tabLe star't' ng addr'ess 00091A COS5 A6 00 A L2HITl LDAA O.X Store LCTC instruction· 00092A COS7 97 40 A STAA INSTR 00093A COS9 08 INX Increment data tabLe address 00094A COSA A6 00 A LDAA O.X Store LCTC data 00095A COSC 97 41 A STAA DATAR 00096A COSE BD C103 A JSR L2HIST Write instructin and data to LCTC 00097A C061 08 INX Increment data tabLe address 00098A C062 8C C14E A CPX IlLCTCl+18 Test if LCTC is initialized 00099A C065 26 EE COSS BNE L2HIT1 00100A C067 39 RTS 00101 ************************************************ 00102 * * 00103 NAME : L2HDST (DISPLAY DOT) 00104 * * 00105 ************************************************** 00106 * * 00107 ENTRY DTX(DOT COLUMN COORDINATE) * 00108 * DTY(DOT ROW COORDINATE) 00109 * DOTSET(TURN ON/OFF INDICATOR) * 00110 * RETURNS NOTHING * 00111 * * 00112 * ************************************************ * 00113A C068 96 48 A L2HDST LDAA DTX Load coLumn coordinate 00114A C06A 84 F8 A ANDA IISF8 DTX AND SF8->DTWK ~HITACHI 878 00115A C06C 97 4A A STAA DTWI( OO1l6A C06E 44 LSRA (OTX AND $F8)/B-)CCNT 00117A C06F 44 LSRA 001l8A C070 44 LSRA 00119A C071 97 47 A STAA CCNT 00120A C073 96 49 A LDAA DTY DTY>I<30-)IX 00121A C075 C6 IE A LDA8 lI$lE 00122A C077 30 MUL 00123A C078 18 XGOX 00124A C079 06 47 A LDA8 CCNT IX+CCNT-)CURH:CURL 00125A C078 3A A8X 00126A C07C 18 XGDX 00127A C070 97 43 A STAA CURH 00128A C07F 07 42 A STA8 CURL 00129A C081 80 C125 A JSR L2HCST Store cursor address 00130A C084 96 48 A LDAA DTX 00131A C086 06 4A A LDA8 DTWI( 00132A COB8 10 SBA DTX-DTWI(-)DATAR 00133A COB9 97 41 A STAA DATAR 00134A C088 96 48 A LDAA DOT SET Store turning on/off data 00135A C080 97 40 A STAA INSTR 00136A COBF 80 C103 A JSR L2HIST Turn on/off 1 dot 00137A C092 39 RTS 00138 >1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<****** 00139 ** ** 00140 NAME : L2HMVE (MOVE DISPLAY) 00141 >I< 00142 ****>1<*****>1<*>1<*>1<>1<****>1<*****************>1<********* * 00143 >I< >I< 00144 ENTRY : ACCA (MOVING DIRECTION) * 00145 * RETURNS : NOTHING 00146 * * 00147 * ****>1<*************>1<****>1<******>1<********>1<*******>1< * 00148A C093 BIOI A L2HMVE CMPA 11$01 Test if move 1 dot right 00149A C095 26 08 COA2 BNE L2HMEl 00150A C097 06 48 A LDAB DTX 00151A C099 C1 EF A CMPB 11239 Test if DTX is right most 00152A C098 27 37 C004 BEQ L2HMES 00153A C090 5C INC8 Increment DTX 00154A C09E 07 48 A STAB DTX 00155A COAO 20 28 COCO BRA L2HME4 00156A COA2 81 02 A L2HMEl CMPA 11$02 Test if move 1 dot Left 00157A COA4 26 08 C081 BNE L2HME2 00158A COA6 06 48 A LDAB OTX Test if OTX is Left most 00159A COA8 C1 00 A CMPB 1100 00160A COAA 27 28 C004 BEQ L2HMES 00161A COAC SA OECB Decrement DTX 00162A COAO 07 48 A STAB DTX 00163A COAF 20 1C COCO BRA L2HME4 00164A COB1 B1 03 A L2HME2 CMPA 11$03 Test if move 1 dot down 00165A C083 26 08 COCO BNE L2HME3 00166A C08S 06 49 A LDAB OTY 00167A C087 C1 3F A CMP8 1163 Test if DTY is bottom 00168A C089 27 19 COD4 BEQ L2HMES Increment DTY I 00169A C088 5C INCB 00170A C08C 07 49 A STAB DTY 00171A C08E 20 00 COCO BRA L2HME4 ~HITACHI 879 00172A COCO 81 04 A L2HME3 CMPA t\$04 Test if move 1 dot UP 00173A COC2 26 10 COD4 BNE L2HME5 00174A COC4 D6 49 A LDAB DTY 00175A COC6 C1 00 A CMPB t\00 Test if DTY is top 00176A COC8 27 OA COD4 BEQ L2HME5 00177A COCA 5A DECB Dec r'ement DTY 00178A COCB D7 49 A STAB DTY 00179A COCD 86 OF A L2HME4 LDAA t\$OF Stot'e tur'n i ng on instruction 00180A COCF 97 4B A STAA DOTSET 00181A CODI BD C068 A JSR L2HDST Turn on 1 dot 00182A COD4 39 L2HME5 RTS 00183 ************************************************ 00184 * * 00185 * NAME : L2HDSP (CONTINUOUS DISPLAY) * 00186 * * 00187 ****~******************************************* 00188A COD5 86 OC A L2HD5P LDAA t\$OC Store instruction 00189A COD7 97 40 A STAA INSTR 00190A COD9 96 46 A LOAA DATA Store dispLay data 00191A CODB 97 41 A STAA DATAR 00192A CODD BD C103 A L2HDW1 JSR L2HIST Write dispLay data to LCTC 00193A COEO DC 44 A LDD DCOUNT Decrement counter 00194A COE2 B3 0001 A SUBD t\$01 00195A COE5 DD 44 A STD DCOUNT 00196A COE7 24 F4 CODD BCC L2HDP1 Test if dispLay is compLeted 00197A COE9 39 RTS 0019B ********~*************************************** 00199 * * 00200 NAME : L2HBSY (CHECK BUSY FLAG) 00201 * * 00202 ******~******************************************* 00203A COEA 4F L2HBS,Y CLRA 00204A COEB 97 04 A STAA P3DDR SeLect port 3 as input 00205A COED 86 06 A LDAA t\$06 Set RS=l.R/W=l.E=O 00206A COEF 97 02 A STAA P1DTR 00207A COFI 86 07 A L2HBY1 LDAA t\$07 00208A COF3 97 02 A STAA PlDTR 00209A COF5 96 06 A LDAA P3DTR Read LCTC busy fLag 00210A COF? C6 06 A LDAB 11$06 Set E=O 00211A COF9 D7 02 A STAB PlDTR 00212A COFB 48 ASLA Set busy fLag to bit C 00213A COFC 25 F3 COF! BCS L2HBYl Test if busy fLag=O ? 00214A COFE 86 01 A LDAA t\$01 SeLect port 3 as output 00215A C100 97 04 A STAA P3DDR 00216A C102 39 RTS 00217 ************************************************ 00218 00219 ** NAME: L2HIST (STORE DISPLAY INSTRUCTION) ** 00220 * * 00221 ************************************************ 00222A C103 BD COEA A L2HIST JSR L2HBSY Check LCTC busy fLag 00223A C106 86 04 A LDAA t\$04 Set RS=l.R/W=O.E=O 00224A C108 97 02 A STAA PIDTR 00225A C10A 86 05 A LDAA t\$05 Set E=l 00226A ClOC 97 02 A STAA P1DTR 00227A C10E 96 40 A LDAA INSTR Output instruction through port3 00228A CllO 97 06 A STAA P3DTR ~HITACHI 880 00229A Cll2 86 04 A LDAA 11$04 Set E=O 00230A Cll4 97 02 A STAA PlDTR 0023lA Cll6 7F 0002 A CLR PlDTR Set RS=O 00232A C1l9 86 01 A LDAA 11$01 Set E=l 00233A Cll8 97 02 A STAA P1DTR 00234A CllD 96 41 A LDAA DATAR Output data through port3 0023SA C11F 97 06 A STAA P3DTR 00236A C121 7F 0002 A CLR P1DTR Set E=O 00237A C124 39 RTS 00238 ************************************************ 00239 * * 00240 * NAME : L2HCST (STORE CURSOR ADDRESS) * 00241 * * 00242 ************************************************ 00243A C12S 86 OA A L2HCST LDAA Il$OA Store instruction 00244A C127 97 40 A STAA INSTR 0024SA C129 96 42 A LDAA CURL Store data 00246A C12B 97 41 A STAA DATAR 00247A C12D BD C103 A JSR L2HIST Write lower cursor ADDR to LCTC 00248A C130 86 OB A LDAA Il$OB Store instruction 00249A C132 97 40 A STAA INSTR 00250A C134 96 43 A LDAA CURH Store datil 002S1A C136 97 41 A STAA DATAR 002S2A C138 BD C103 A JSR L2HIST Write upper cursor ADDR to LCTC 002S3A C13B 39 RTS 00254 ************************************************ 00255 * * 00256 * DATA TABLE * 00257 * * 00258 ************************************************ 002S9A C13C 00 A LCTC1 FCB $0,$32 *Instruction and data- 00260A C13E 01 A FCB $1,$07 to initialize LCTC 00261A C140 02 A FCB $2,$lD 00262A C142 03 A FCB $3,$lF 00263A C144 04 A FCB $4,$00 00264A C146 08 A FCB $8,$00 0026SA C148 09 A FCB $9,$00 00266A C14A OA A FCB $A,$OO 00267A C14C OB A FCB $B,$OO 00268A C14E 01 A DTDATA FCB $01 *Display data 00269A C14F 01 A FCB $01 00270A C1S0 01 A FCB $01 00271A C1Sl 03 A FCB $03 00272A ClS2 03 A FCB $03 00273A C1S3 03 A FCB $03 00274A ClS4 03 A FCB $03 0027SA ClSS 02 A FCB $02 00276A C156 02 A FCB $02 00277A C1S7 02 A FCB $02 00278A ClS8 04 A FCB $04 00279A C1S9 04 A FCB $04 00280A C15A 04 A FCB $04 0028lA ClSB 04 A FCB $04 00282A C1SC 03 A FCB $03 00283A ClSD 03 A FCB $03 I 00284A C15E 01 A FCB $01 0028SA C1SF 01 A FCB $01 ~HITACHI 881 00286A C160 01 A FCB $01 00287A C161 01 A FCB $01 00288A C162 00 A FCB $00 00289A C163 01 A FCB $01 00290A C164 00 A FCB $00 00291A C165 04 A FCB $04 00292A C166 01 A FCB $01 00293A C167 01 A FCB $01 00294A C168 04 A FCB $04 00295A C169 03 A FCB $03 00296A C16A 01 A FCB $01 00297A C16B 01 A FCB $01 0029BA C16C 02 A FCB $02 00299A C16D 03 A FCB $03 00300A C16E 03 A FCB $03 00301A C16F 03 A FCB $03 00302A C170 01 A FCB $01 00303A C171 02 A FCB $02 00304A C172 02 A FCB $02 00305A C173 02 A FCB $02 00306A C174 02 A FCB $02 00307A C175 01 A FCB $01 0030BA C176 04 A FCB $04 00309A C177 04 A FCB $04 00310A C178 FF A FCB $FF 00311 ************************************************ 00312 * * 00313 * VECTOR ADDRESSES * 00314 * * 00315 ************************************************ 00316 * 00317A FFEA ORG $FFEA 0031B * 00319A FFEA COOO A FDB L2HMN IRQ2 00320A FFEC COOO A FDB L2HMN CMI 00321A FFEE COO a A FDB L2HMN TRAP 00322A FFFO COOO A FDB L2HMN SID 00323A FFF2 COOO A FDB L2HMN Tor 00324A FFF4 COOO A FDB L2HMN OCI 00325A FFF6 COOO A FDB L2HMN ICI 00326A FFFB COOO A FDB L2HMN IRQlIISF 00327A FFFA COOO A FDB L2HMN SWI 00328A FFFC COOO A FDB L2HMN NMI 00329A FFFE COOO A FDB L2HMN RES 00330 * 00331 END ~HITACHI SECTION 2. DARLINGTON TRANSISTOR DRIVE (LED DYNAMIC DISPLAY) 2.1 HARDWARE DESCRIPTION 2.1.1 Function Drives LEDs by amplifying signals from the HD6301YO, displaying "76543210" on the LED display. 2.1.2 Microcomputer Operation The HD6301YO executes output compare interrupt 1 every 1.25 ms using timer 1 to drive LEDs by outputting segment data through port 1 and digit data through port 6. Darlington transistor are driven directly through port 6. 2.1.3 Peripheral Devices LEDs: Driven dynamically at a frame frequency of 100 Hz and duty rate of l/S. 2.1.4 Circuit Diagram S-digit x S-segment LED control circuit is shown in figure 2-1. Meu HD 6 3 0 1 Yo LED (8-digit x 8-segment) +5V PIO 50 n 4 5 MP. MPI PII 49 P12 48 I I RD 8 NMI DlG8 DlG7 DiG6 DIG5 DlG4 DIG3 DlG2 DIGl , STBY P u 47 33 Vee PI. 46 f~ 4MHzC1 XTAL Pu 45 ® 3 EXTAL Pu 44 22pF I +5V PI1 43 32 POT P•• 31 Vss p •• Vss Po. 29 P•• 28 p •• 27 o P.I 26 lq~ p •• 25 ®W Figure 2-1. B.-digit x B-segment LED Control Circuit ~HITACHI 883 2.1.5 Pin Functions Pin functions at the interface between the HD6301YO and LED are shown in table 2-1. Table 2-1- Pin Functions Active Level Pin Name Input/ (High or Pin Name Program (HD6301YO) Output low) Function (LED) Label P!H Output High Outputs digit data DIGl P6DTR to LED. DIG2 P S1 Output High P S2 Output High DIG 3 P S3 Output High DIG4 P S4 Output High DIGS Pss Output High DIG6 P ss Output High DIG7 P S7 Output High DIGS PlO Output Low Outputs segment data a P1DTR to LED. l1a-vh" in P ll Output low b Pin Name (LED) P 12 Output Low corresponds .co c PH P 14 Output Output Low low - segment pattern below. a f'- 'b d e - g P 1S Output Low f P 1S Output Low e, 'c d ~h g P 17 Output Low Segment Pattern h 2.1.6 Hardware Operation The timing chart for segment signals and digit signals is shown in figure 2-2. ~HITACHI 884 100 digit ON P. o P. 1 --t---; Segment Signals P•• -+----r---~--~----+_--~--~ digit ON P.7-1----+----r--~r_--;_--_+----~--~ Digit {p 'VP Signals 10 17 17 p. s 10ms(lOOHz) P•• P87--~--------~ 10 6 digit X 10 7 digit / Figure 2-2. Timing Chart of Segment Signals and Digit Signals 2.2 SOFTWARE DESCRIPTION 2.2.1 Program Module Configuration The program module configuration for displaying digits on LED is shown in figure 2-3. L EDSP I LEDMN MAIN PROGRAM I l'!. MOVE I I L..!. STORE l.! DRIVE LED DISPLAY DATA Figure 2-3. Program Module Configuration ~HITACHI 885 2.2.2 Program Module Functions Program module functions are summarized in table 2-2. Table 2-2. Program Module Functions No. Program Module Name Label Function o MAIN PROGRAM LEDMN Demonstrates display data on LED. 1 DRIVE LED LEDSP Displays digits on LED using dynamic drive. 2 STORE DISPLAY DATA MOVE Stores display data in display RAM. Refer to MOVE in HD6301/HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details. 2.2.3 Program Module Process Flow (Main Program) The flowchart in figure 2-4 is an example of the a-digits x a-segment LED display performed by the program module in figure 2-3. The main program in figure 2-4 demonstrates the display on LED shown in figure 2-5. ~HITACHI 886 Main Program --1[Initialize stack pointer. $ 0 l--+DECD --1[Initialize digit data output from port 6. --~'nitiali"O O--+DSCNTR data table pointer. ---{:Select port 1 and port 6 ao output. ___ [Initialize timer control/status register 1 for enabling output compare interrupt 1. o --+ Bit I ---I Enable interrupts. $FIOO--+IX SEGD--+DEA Execute MOVE to move segment data, in data table, to display RAM. Refer to MOVE in HD6301/HD6303 APPLICATION NOTES (SOFTWARE) 8--+ACC13 for details. OCIl Interrupt Routine ---{ Display digits on LED using dynamic drive. Figure 2-4. Program Module Flowchart LED (8-digit x 8-segment) Figure 2-5. Example of 8-digit x 8-segment LED Display ~HITACHI 887 2. 3 PROGRAM MODULE DESCRIPTION Program Module Name: DRIVE LED MCU/MPU: HD6301YO Label:LEDSP Function: Displays digits on a-digit x 8-segment LED using dynamic drive. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: contents Location Bytes ACCD ROM (Bytes) : 48 ACCA ACCB Entry Display SEGD 8 x x RAM (Bytes) : 11 data (RAM) Stack (Bytes) : 0 IX x No. of cycles: 69 Reentrant: No C V Relocatable: No x x Interrupt OK?: No Re- Z N turns x x I H • • • Not affected x : Undefined Result Description: 1. Function Details a. Argument details SEGD(RAM) : Holds display data. b. Example of LEDSP execution is shown in figure 2-6. If entry arguments are as shown in part 1 of figure 2-6, data is displayed on LED as shown in part 2 of figure 2-6. Table 2-3 shows relation between segment data and display. c. LEDSP calls no subroutines. Specifications Notes: "No. of cycles" in "Specifications" indicates the number of cycles required to display the 10 0 digit (rightmost) on LED. ~HITACHI 888 Program Module Name: DRIVE LED MCU/MPU: HD6301YO ILabe" LEDSP ~--------------~ Description: Address Space ~ SEGD(RAM)r-__$_D_8__~ (segment) $ 82 data r---'-$-9-2--~ Q) Entry $ 99 argument $BO $A4 $F9 $CO Figure 2-6. Example of LEDSP Execution Table 2-3. Relation between Segment Data and Display Segment Data Display Segment Data Display n $CO U $92 5 I $F9 I $82 5 .., $A4 2 $D8 I $BO 3 $80 8 2. $99 User Notes Y $90 g The following procedure must be performed before LEDSP execution. I a. Initialize digit data. b. Initialize display RAM pointer. c. Select port 1 and port 6 as output. ~HITACHI 889 ~p_r_o_g_r_am___M_o_d_u_l_e__N_a_m_e_:__D_R_I_VE ___L_E_D______ ~ ~M_C_U_/_M_P_U __: __HD __6_3_0_1_Y_0____ ~ I~L_a_b_e_l __ : __ LE_D __S_P______ ~ Description: d. Initialize timer control/status register 1 so that output compare interrupt 1 can be enabled. e. Enable interrupts. f. Store entry arguments. 3. RAM Allocation Label RAM Description b7 bO SEGD I-- Digit 10 7 - - I-- Digit 10 6 - I-- Digit 10 5 I-- Digit 10 4 - B-digit segment data Digit 10 3 - I-- Digit 10 2 - I-- Digit lOl- l-- Digit 10 0 - DSCNTR I-- DECD - } Used as a pointer indicating display RAM Digit data } 4. Sample Application I I I LDAA #$01 STAA DECD } ..... Initialize digit data CLR DSCNTR LDAA STAA LDAA #$07 DSCNTR+l #$01 } ..... Initialize display RAM pointer STAA P1DDR ..... Select port 1 and port 3 as output. LDAA #$FF STAA LDAA P6DDR #$OB J STAA TCSRl } ..... Enable output compare interrupt. CLI ..... Enable interrupts. LDX #$F100 LDAA STAA LDAB JSR I #SEGD DEA #B MOVE } ..... Load entry arguments. I I ORG $F100 FCB $DB, $82, $92, $99, $BO, $A4, $F9, $CO ...•• Display data I I ~HITACHI 890 Program Module Name: DRIVE LED LM_C_U_/_M_P_U_:__HD __6_3_0_1_Y_O____ ~ LIL_a_b_e_l_:__LE __D_S_P______ ~ Description: 5. Basic Operation a. Each digit is dynamically displayed one by one from the 10 0 digit every interrupt. b. In the interrupt routine, the procedure below is performed. i. A specific digit signal is set to Low to turn off its display. ii. Segment data for next digit is read from display RAM and output to ports. iii. Digit signal is set to High to turn on display. c. DSCNR(RAM) is used as a pointer to display RAM, and incremented every interrupt. After 10 7 digit displayed, DSCNR(RAM) is cleared. d. DECO (RAM) contains digit data, and is shifted 1 bit left to indicate next display digit. I ~HITACHI 891 Program Module Name: DRIVE LED MCU/MPU: HD630lYO I Label, LEDSP Flowchart: Enable output compare interrupt l. ___ { Initialize output compare register 1 to execute interrupt every 1.25 ms hereafter. ___{set digit signal to Low to turn off display. ----[Load pointer to display RAM. ---{ Output segment data to port l. ---{output digit data to port 6. ---{ Decrement pointer to display RAM. (7. DECD)=l ---{ Test if 8 digits have been displayed, digit data for next interrupt. ---{Initialize digit data. ---{Initialize pointer to display RAM. LEDSP2 ~HITACHI 892 2.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 2.5 PROGRAM LISTING 00001 ***** RAM ALLOCATION ************************* 00002 00003 * 00004A 0040 ORG $40 00005 * 00006A 0040 0008 A SEGD RMB 8 8-digit segment data 00007A 0048 0002 A DSCNTR RMB 2 DispLay RAM pointer 00008A 004A 0001 A DECD RMB 1 Digit data 00009A 004B 0002 A DEA RMB 2 Destination address 00010 * 00011 **** SYMBOL DEFINITIONS ******************** 00012 * 00013 0000 A PlDDR EQU $00 Port 1 data direction register 00014 0002 A PIOTR EQU $02 Port 1 data register 00015 0008 A TCSR1 EQU $08 Timer controL/status register 1 00016 0009 A FRC EQU $09 Free running counter 00017 obOB A OCR1 EQU $OB Output compare register 1 00018 0016 A P6DDR EQU $16 Port 6 data direction register 00019 0017 A P6DTR EQU $17 Port 6 data register 00020 ************************************************ 00021 * * 00022 MAIN PROGRAM : LEDMN * 00023 * 00024 * ************************************************ * 00025 00026A COOO * ORG $COOO 00027 * 00028A COOO 8E 013F A LEDMN LOS 1l$l3F InitiaLize stack pointer 00029A C003 86 01 A LDAA 1l$01 InitiaLize digit data 00030A COOS 97 4A A STAA DECO 00031A C007 7F 004B A CLR DSCNTR InitiaLize dispLay RAM pointer 00032A COO A 86 07 A LDAA 117 00033A COOC 97 49 A STAA DSCNTR+l 00034A COOE 86 01 A LDAA 1l$01 SeLect port 1 and port 6 as out~ut 00035A COlO 97 00 A STAA PlDDR 00036A C012 86 FF A LDAA Il$FF 00037A C014 97 16 A STAA P6DDR 00038A C016 86 08 A LDAA 1l$08 EnabLe OCI interrupt 00039A C018 97 08 A STAA TCSRI 00040A COlA OE CLI EnabLe interrupts 00041A C01B CE FIOO A LOX Il$FIOO Load source address 00042A COlE CC 0040 A LDD IlSEGD Load destination address 00043A C021 DO 4B A STD DEA I 00044A C023 C6 08 A LDAB 118 Load no. of bytes to be moved 00045A C025 80 02 C029 BSR MOVE Move segment data to dispLay RAM 00046A C027 20 FE C027 PEND BRA PEND End of program 00047 ************************************************ 00048 00049 * NAME : MOVE (MOVE MEMORY BLOCII< 00117A FFEA COOO A FOB LEOMN IR02 00118A FFEC COOO A FOB LEOMN CMI 00119A FFEE COOO A FOB LEOMN TRAP 00120A FFFO COOO A FOB LEOMN SID 00121A FFF2 COOO A FOB LEOMN TOI 00122A FFF4 C039 A FOB LEOSP OCI 00123A FFF6 COOO A FOB LEOMN ICI 00124A FFF8 COOO A FOB LEOMN IROllISF 00125A FFFA COOO A FOB LEOMN SWI 00126A FFFC COOO A FOB LEOMN NMI 00127A FFFE COOO A FOB LEOMN RES 00128 >I< 00129 END ~HITACHI 895 SECTION 3. DUTY CONTROL OF PULSE OUTPUT AND DA CONVERSION 3.1 HARDWARE DESCRIPTION 3. 1. 1 Function Outputs pulse with 0-100% duty rate and performs digital-to-analog conversion of output pulse with an external integration circuit. 3.1.2 Microcomputer Operation The HD6301YO increases duty rate by 4% every 0.3s. This increase in duty rate changes the output voltage from 0 to 5 V in 0.2 V increments. High or Low is output from the Tout3 pin by executing the counter match interrupt routine with timer 2. In addition, the High and Low Period of the pulse is controlled by changing values in the time constant register. 3.1.3 Peripheral Devices Integration circuit: Performs level conversion of the output pulse through the HD14050B, and converts the result from digital to analog. The operational amplifier here prevents the fluctuation of analog output voltage caused by the load in the user system. 3.1.4 Circuit Diagram Pulse output circu.it is shown in figure 3-1. Meu HD6301Yo (HD6S0SY) +5V 4 MPo MPI 8 NMI STBY 33 f:" : Vee +l2V XTAL EXTAL 22pF 15 +5V P 2s /Tout IS2076 -12V Vss '--+--='-1 V ss Figure 3-1. Pulse Output Circuit ~HITACHI 896 3.1.5 Pin Function Pin function for output pulse is shown in Table 3-1. Table 3-1. Pin Function Pin Name Input/ Active Level Program (HD6301YO) Output (High or Low) Function Label Output Outputs pulse 3.1.6 Hardware Operation Pulse output and DA conversion is shown in figure 3-2. 100 40 60 Tout3 (Duty 40%)- I-- 1 2. 8 rns n IL 1 2. 8 rns Output after 5.0V -----------------------------------------~ I I DA conversion r---' I I I 4.6 V ------------------------------~ I I I ) I m1---~// I I I I I I r- I I o 2V --- I r---' OV I I n I I I I t Figure 3-2. Pulse Output and Output State after DA Conversion ~HITACHI 897 3.2 SOFTWARE DESCRIPTION 3.2.1 Program Module Configuration The program module configuration for pulse output .is shown in figure 3-3. DUMN .~ MAIN PROGRAM I DUSET I DUOUT I l.:. ~ SET DUTY OUTPUT PULSE Figure 3-3. Program Module Configuration 3.2.2 Program Module Functions Program module functions are summarized in table 3-2. Table 3-2. Program Module Functions No. Program Module Name Label Function a MAIN PROGRAM DUMN . Outputs pulse. 1 SET DUTY DUSET Sets duty rate of pulse. 2 OUTPUT PULSE DUOUT Outputs pulse. 3.2.3 Program Module Process Flow (Main Program) The flowchart in figure 3-4 is an example of controlling pulse output and digital-to-analog conversion, using the program module in figure 3-3. ~HITACHI 898 Main Program ---~Initialize stack pointer. ---~Initialize RAM for work area. Initialize timer control register 3 to enable ___ { counter match interrupt, enable clock input to timer 2 up counter, and select E clock/128. ---~Enable interrupt. ---{Load entry argument of DUSET. ---{Execute DUSET to set duty rate of pulse. Increment duty rate for next pulse output. Execute 0.3s software timer. eMI Interrupt Routine. ---~Execute DUOUT to output pulse. I Figure 3-4. Program Module Flowchart ~HITACHI 899 3.3 PROGRAM MODULE DESCRIPTION Program Module Name: SET DUTY MCU/MPU: HD630lYO/ Label: DUSET HD6303Y Function: Defines pulse status, which is output in DUOUT, based on duty rate. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ACCA ACCB ROM (Bytes): 55 Entry Duty VCOUNT 1 x x RAM (Bytes): 4 rate (RAM) Stack (Bytes): 0 IX x No. of cycles: 49 Reentrant: No C V Relocatable: No x x Interrupt OK?: Yes High HTIME 1 Re- period of Z N turns (RAM) pulse x x Low period LTIME 1 I H of pulse (RAM) • x Pulse HIDUT 1 status flag (RAM) • x : Not affected Undefined Result Description: 1. Function Details a. Argument details VCOUNT (RAM) : Duty rate as a hexadecimal number. (Duty rate=1/4 actual duty rate. See "2. User Notes".) HTIME(RAM) High period of pulse. LTIME(RAM) Low period of pulse. HIDUT(RAM) Flag indicating which output is performed: Low consecutive output, High consecutive output, or pulse output. Table 3-3 shows flag functions. Specifications Notes: "No. of cycles" in "Specifications" represents the number of cycles required when duty rate is other than 0% or 100%. ~HITACHI 900 _p_r_o_g_r_am L. __Mo~d_U_le __ __N_a_rn_e_:___ SE_T __D_UT __Y ______ ~ LM_C_U_I_M_P_U_:__HD __6_3_0_l_Y_0_1____-J lL_a_h_e_l_:__D_U_S_E_T______-J HD6303Y . Description: Table 3-3. Flag Functions Label bit 1 bit 0 Function HLOUT 0 0 Outputs Low consecutively from Tout3 pin. 1 0 Outputs Pulse from Tout3 pin. 1 1 Outputs High consecutively from Tout3 pin. b. Example of DUSET execution is VCOUNT shown in figure 3-5. If entry b7 bO argument is as shown in part Q) Entry argument {VCOUNT(RAM) 0 ($ OA). A I of figure 3-5, High and Low period of duty 40% pulse are stored as shown in part @ of figure 3-5. HTIME b7 bO c. DUSET calls neither the program HTI~E$(:f)')1 2 : 7 I modules nor subroutines. LTIME Return arguments LTI~E$(:~~O 3 : BI I 2. User Notes HLOUT HLOUT(RAM) I 0 : 2 ($02). . The following procedure must be executed before DUSET execution. Figure 3-5. Example of DUSET a. Re serve the High and Low Execution period of pulse in a data table. b. Load entry argument. c. When specifying duty rate, load the actual duty rate divided by 4, since duty rate is defined every 4%. d. Data in VCOUNT(RAM) must be within the range $0~VCOUNT~$16, otherwise I neither the High nor Low period of pulse can be obtained. 3. RAM Allocation Label RAM Description b7 bO HTIME } High period of pulse LTIME } Low period of pulse HLOUT } Pulse status flag VCOUNT } Duty rate ~HITACHI 901 Program Module Name: SET DUTY MCU/MPU: HD6301YOI HD6303Y ILab.,' DUSET Description: 4. Sample Application I I I I LDAA #$10 } Load entry argument. STAA VCOUNT II JSR DUSET Call DUSET. 5. Basic Operation a. DUSET executi'on stores High and Low period of pulse in HTIME LTIME (RAM) from a data table based on duty rate Data in data table contains actual High and Low periods less 1 as shown in Formula l. Cycle of pulse= I (High period of pulse +1) + (Low period of pulse +1)\ x 128~s = 12.8 ms • • • • • • •• (Formula 1) b. i. VCOUNT(RAM) is used as a pointer to data table. ii. Duty rate is checked and: If duty rate is 0% or 100%, define pulse status flag to output Low or High consecutively. Next, hold High and Low period of pulse so that counter match interrupt is executed at a duty rate of 50%. If duty rate is 4 ~ 96%, load High and Low period of pulse using index addressing mode, and then define flag to output pulse. ~HITACHI 902 Program Module Name: SET Dory MCU/MPU: HD6301YO! HD6303Y I~ DUSET Flowchart: --{ "'"t if duty rate i" " . __ { Define flag to output Low consecutively from TOut 3 pin. --{ Test if duty rate is 100%. __ { Define flag to output High consecutively from Tout 3 pin. Define High and Low period of pulse to --{ execute interrupt at a duty rate of 50%. --{ Load duty rate. __I Load pointer in data table for High period into IX. I __ { store High period of pulse. __{ Load pointer in data table for Low period,into IX; --{ Store Low period of pulse. 0->0, HLOUT __ { Define flag to output pulse from l->l,HLOUT Tout 3 pin. ~HITACHI 903 Program Module Name: OUTPUT PULSE MCU/MPU: HD630lYO/ Label: DUOUT HD6303Y Function: Output pulse from Tout3 pin. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes): 35 ACCA ACCB Entry High HTIME period of pulse (RAM) 1 x I • RAM (Bytes): 3 Stack (Bytes): 0 IX Low period LTIME 1 of pulse (RAM) • No. of cycles: 41 Reentrant: No Pulse HLOUT 1 C V Relocatable: No status (RAM) flag • x Interrupt OK?: No Re- _."--- Z N turns -- - x x I H • • • Not x affected Undefined : t Result Description: 1. Function Details a. Argument details HTIME(RAM): High period of pulse. LTIME(RAM): Low period of pulse. HLOUT(RAM): Flag indicating which output is performed: Low consecutive output, High consecutive output, or pulse output. Table 374 shows flag functions. Specifications Notes: ~HITACHI 904 Program Module Name: OUTPUT PULSE MCU/MPU: lID6301YO/ lID6303Y IL.b'" DUOUT Description: Table 3-4. Flag Functions Label bit 1 bit 0 Function HLOUT 0 0 Output Low consecutively from Tout3 pin. 1 0 Output Pulse from Tout3 pin. 1 1 Output High consecutively from Tout3 pin. b. Example of DUOUT execution is b7 HT1ME bO shown in figure 3-6. If HT 1ME ( RAM) -...:2=---L-_~...J1 LI entry arguments are as shown ($27) b7 LT1ME bO in part CD of figure 3-6 I duty CD Entry LT1ME(RAM)1 8: I rate 40% pulse is output as argument ($86) b7 HLOUT bO shown in part @ of figure 3-6. HLOUT(RAM)I-i-I-I-I-i-11Iol c. DUOUT calls neither the program modules nor subroutines. 2. User Notes 40.1 .. 60. 1 1.. a. Initialize timer control @ Result { Tout 3 ~ register to enable counter match Duty 40% interrupt, enable clock input to timer 2 up counter, select E Figure 3-6. Example of DUOUT clock 1/128. Execution b. Enable interrupts. c. Store entry arguments. 3. RAM Allocation Label RAM Description b7 bO §~ HTIME High period of pulse LTIME Low period of pulse HLOUT Pulse status flag ~HITACHI 905 Program Module Name: OUTPUT PULSE MCU/MPU:HD6301YO/ HD6303Y \Lab O " DUOUT Description: 4. Sample Application WORKl RMB I 1 ..... Reserve memory for duty rate. I I LDAA STAA #$5A TCSR3 } Initialize timer control register. CLI Enable interrupt. LDAA IDRKl } STAA VCOUNT ..... Load entry argument of DUSET. JSR DUSET 5. Basic Operation a. Data in HTIME(RAM), LTIME(RAM) is loaded in time constant register, and pulse output'. b. i. Output status is checked and converted (High + Low or Low + High) at every timer interrupt. At this time, High and Low period of pulse is loaded into time constant register. ii. If duty rate is 0% or 100%, define time constant register at a duty rate of 50%, and maintain output status (High + High or Low + Low) . ~HITACHI 906 Program Module Name: OUTPUT PULSE MCU/MPU: HD6301YO/ HD6303Y ILab.', DUOUT Flowchart: __ { Clear counter match interrupt request flag. __ { Test if previous output is High or Low. DUOTI (2, TCSR3);6o __ { Load Low period of pulse into time constant register. - - { Test if duty rate is 0%. __ { If duty rate is not 0%, output High from Tout 3 pin. __ { Load High period of pulse into time constant register. - - { Test if duty rate is 100%. __ { I f duty rate is not 100%, output Low from Tout 3 pin. I ~HITACHI 907 3.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 3.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ************************* 00003 * 00004A 0040 ORG $40 00005 * 00006A 0040 0001 A DATA RMB Duty data 00007A 0041 0001 A VCOUNT RMB Duty rate OOOOBA 0042 0001 A HTIME RMB High period of puLse 00009A 0043 0001 A LTIME RMB Low period of puLse 00010A 0044 0001 A HLOUT RMB PuLse status fLag 00011A 0045 0001 A WORK RMB Work area for entry argument 00012 * 00013 **** SYMBOL DEFINITIONS ********************** 00014 * 00015 001B A TCSR3 EOU $lB Timer controL/status register3 00016 001C A TCONR EQU $lC Time constant register 00017 *********************************)k************** 00018 * * 00019 * MAIN PROGRAM : DUMN * 00020 * * 00021 ************************************************ 00022 * 00023~) COOO ORG $COOO 00024 * 00025A COOO 8E 013F A DUMN LOS 1:I$13F InitiaLize stack pointer 00026A C003 4F CLRA CLear RAM for work area 00027A C004 97 45 A STAA WORK 00028A C006 86 SA A LDAA 1:I$5A InitiaLize TCSR3 00029A C008 97 1B A STAA TCSR3 00030A COOA OE CLI EnabLe Interrupt 00031A COOB 96 45 A DUMN1 LDAA WORK Load entry argument of DUSET 00032A COOD 97 41 A STAA VCOUNT 00033A COOF 8D 3E C04F BSR DUSET Execute DUSET 00034A COlI 96 41 A LDAA VCOUNT Increment duty for next puLse 00035A C013 4C INCA DUTY+4%-)entry argument 00036A C014 97 41 A STAA VCOUNT 00037A C016 81 1A A CMPA 1:126 DUTY=104% ? 00038A C018 26 03 COlD BNE DUMN2 00039A COlA 4F CLRA 00040A C018 97 41 A STAA VCOUNT Store 0% duty 00041A COlD 97 45 A DUMN2 STAA WORK Store duty in entry argument 00042A C01F CE OOFF A LDX I:I$FF Execute 0.3s software timer 00043A C022 86 FF A DUMN3 LDAA I:I$FF 00044A C024 4A DUMN4 DEC A 00045A C025 26 FD C024 BNE DUMN4 00046A C027 09 DEX 00047A C028 26 F8 C022 BNE DUMN3 00048A C02A 20 DF COOB BRA DUMN1 00049 **************~(********************************* 00050 * * 00051 * NAME : DUOUT (OUTPUT PULSE) * 00052 * * 00053 ************************~(*********************** 00054 * * 00055 * ENTRY : HTIME (HIGH PERIOD OF PULSE) * 00056 * LTIME (LOW PERIOD OF PULSE) * 00057 * HLOUT (PULSE STATUS FLAG) * ~HITACHI 908 00058 >I< RETURNS : NOTHING >I< 00059 >I< >I< 00060 *********************************~:'k**~C****~:***** 00061A C02C 71 7F 1B DUOUT BCLR 7.TCSR3 CLear 1nterrupt request fLag 00062A C02F 7B 04 1B BTST 2.TCSR3 Output Is HIgh or Low? 00063A C032 27 OE C042 BEQ DUOT1 Branch 1f Low output 00064A C034 96 42 A LDAA HTIME Store H1gh perIod In TCONR 00065A C036 97 1C A STAA TCONR 00066A C038 7B 01 44 BTST O.HLOUT DUTY=100% ? 00067A C03B 26 11 C04E BNE DUOT2 00068A C03D 71 FB 1B BCLR 2.TCSR3 Output Low 00069A C040 20 OC C04E BRA DUOT2 00070A C042 96 43 A DUOT1 LDAA LTIME Store Low per10d In TCONR 00071A C044 97 1C A STAA TCONR 00072A C046 7B 02 44 BTST 1. HLOUT DUTY=O% ? 00073A C049 27 03 C04E BEQ DUOT2 00D74A C04B 72 04 1B BSET 2.TCSR3 Output High 00075A C04E 3B DUOT2 RTI 00076 >1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1< 00077 >I< >I< 00078 >I< NAME : DUSET (SET DUTY) >I< 00079 >I< >I< 00080 >1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1< 00081 >I< >I< 00082 >I< ENTRY VCOUNT (DUTY RATE) >I< 00083 >I< RETURNS : HTIME (HIGH PERIOD OF PULSE) >I< 00084 >I< LTIME (LOW PERIOD OF PULSE) >I< 00085 >I< HLOUT (PULSE STATUS FLAG) >I< 00086 >I< >I< 00087 ************************************************ 00088A C04F 96 41 A DUSET LDAA VCOUNT 00089A C051 26 08 C05B BNE DUSETl Test if duty=O% 00090A C053 71 FE 44 BCLR O.HLOUT Define fLag to output Low 00091A C056 71 FD 44 BCLR 1. HLOUT 00092A C059 20 OA C065 BRA DUSET2 00093A COSB 81 19 A DUSETl CMPA 1l2S Test if duty=100%? 00094A COSO 26 OE C06D BNE DUSET3 0009SA COSF 72 01 44 BSET O.HLOUT DefIne fLag to output Hlgil 00096A C062 72 02 44 BSET 1.HLOUT 00097A C065 86 31 A DUSET2 LDAA 1149 Set 50% duty rate 00098A C067 97 42 A STAA HTIME 00099A C069 97 43 A STAA LTIME 00100A C06B 20 18 COBS BRA DUSET4 00101A C060 06 41 A DUSET3 LOAB VCOUNT 00102A C06F CE C085 A LOX IlHTDATA-1 Load duty rate 00103A C072 3A ABX 00104A C073 A6 00 A LDAA O.X Load HIgh period poInter into IX 00105A C07S 97 42 A STAA HTIME S t 0 t'e HIgh perIod of puLse 00106A C077 CE C090 A LOX tiLTOATA-1 Load Low perIod pointer Into IX 00107A C07A 3A ABX 00108A C07B A6 00 A LOAA O.X 00109A C07D 97 43 A STAA LTIME Store Low perIod of puLse OOllOA C07F 71 FE 44 BCLR O.HLOUT DefIne fLag to output puLse 00111A·C082 72 02 44 BSET 1.HLOUT 00112A C085 39 DUSET4 RTS I 00113 >1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1< 00114 >I< >I< ~HDTACHI 909 00115 * DATA TABLE * 00116 ************************************************* * 00117 0011BA C086 03 A HTDATA FCB 3 *High period of puLse 00119A C087 07 A FCB 7 00120A C088 OB A FCB 11 00121A C089 OF A FCB 15 00122A C08A 13 A FCB 19 00123A C08B 17 A FCB 23 00124A C08C 1B A FCB 27 00125A C08D IF A FCB 31 00126A C08E 23 A FCB 35 00127A C08F 27 A FCB 39 00128A C090 2B A FCB 43 00129A C091 2F A FCB 47 00130A C092 33 A FCB 51 00131A C093 37 A FCB 55 00132A C094 3B A FCB 59 00133A C095 3F A FCB 63 00134A C096 43 A FCB 67 00135A C097 47 A FCB 71 00136A C098 4B A FCB 75 00137A C099 4F A FCB 79 00138A C09A 53 A FCB 83 00139A C09B 57 A FCB 87 00140A C09C 5B A FCB 91 00141A C09D SF A FCB 95 00142A C09E SF A LTDATA FCB 95 *Low perid of puLse 00143A C09F 5B A FCB 91 00144A COAO 57 A FCB 87 00145A COAl 53 A FCB 83 00146A COA2 4F A FCB 79 00147A COA3 4B A FCB 75 00148A COM 47 A FCB 71 00149A COA5 43 A FCB 67 00150A COA6 3F A FCB 63 00151A COA7 3B A FCB 59 00152A COA8 37 A FCB 55 00153A COA9 33 A FCB 51 00154A COAA 2F A FCB 47 00155A COAB 2B A FCB 43 00156A COAC 27 A FCB 39 00157A COAD 23 A FCB 35 00158A COAE IF A FCB 31 00159A COAF IB A FCB 27 00160A COBO 17 A FCB 23 00161A COB1 13 A FCB 19 00162A COB2 OF A FCB 15 00163A COB3 OB A FCB 11 00164A COB4 07 A FCB 7 00165A COBS 03 A FCB 3 00166 ************************************************ 00167 * * 00168 * VECTOR ADDRESSES * 00169 * * 00170 ************************************************ 00171 * ~HITACHI 910 OOl72A FFEA oRG $FFEA 00173 00174A FFEA COOO A* FOB OUMN IRQ2 00175A FFEC C02C A FOB OUOUT CMI 00176A FFEE COOO A FOB OUMN TR(~P OOlnA FFFO COOO A FOB OUMN SID 00178A FFF2 COOO A FOB OUMN TOI 00179A FFF4 COOO A FOB OUMN oCI 00180A FFF6 COOO A FOB OUMN ICI 00181A FFF8 COOO A FOB OUMN IRQlIISF 00182A FFFA COOO A FOB OUMN SWI 00183A FFFC COOO A FOB OUMN NMI 00184A FFFE COOO A FOB OUMN RES 00185 * 00186 ENO I ~HITACHI 911 SECTION 4. PULSE WIDTH MEASUREMENT 4.1 HARDWARE DESCRIPTION 4.1.1 Function Measures the High period of a pulse to determine pulse width in the range from lOO~s to 65535~s x with an accuracy of plus or minus l~s; stores result as a binary coded decimal (BCD) number. 4.1.2 Microcomputer Operation The HD6301YO uses the input capture interrupt function of timer 1 to fetch values in the free running counter on the rising and falling edges of the Tin pin, using the difference between these values to measure the pulse width. 4.1.3 Circuit Diagram Pulse width measurement circuit is shown in figure 4-1. Meu HD6301YO (HD6303Y) 4 MPo 5 MP, 8 NMI 7 STBY f: :.: ::::L 33 Vee 22pF Pulse input +5V 1S207 Figure 4-1. Pulse Width Measurement Circuit ~HITACHI 912 4.1.4 Pin Functions Pin functions for pulse width measurement is shown in table 4-1. Table 4-1. Pin Functions Pin Name Input/ Active level Program (HD6301YO) Output (High or Low) Function Label Input Detects rising and falling edges. 4.1.5 Hardware Operation Figure 4-2 shows pulse width measurement. Since oscillator frequency is 4 MHz, E clock cycle is l~s. In figure 4-2, pulse width is 4~s. Value counted by free running counter=N N=4 E clock --------~I \4----" ------.l.r Pulse width I Figure 4-2. Measure Pulse Width ~HITACHI 913 4.2 SOFTWARE DESCRIPTION 4.2.1 Program Module Configuration The program module configuration for pulse width measurement and BCD conversion is shown in figure 4-3. PWMN l.2.. MAIN PROGRAM I P WeNT I HEX I ~ CONVERT l!. MEASURE HEXADECIMALS PULSE WIDTH INTO BCD Figure 4-3. Program Module Configuration 4.2.2 Program Module ,Functions Program module functions are summarized in table 4-2. Table 4-2. Program Module Functions No. Program Module Name Label Function o MAIN PROGRAM PWMN Measures pulse width as a BCD number. 1 MEASURE PULSE WIDTH PWCNT Obtains pulse width as a 2-byte hexadecimal number. 2 CONVERT HEXADECIMALS HEX Converts 2-byte hexadecimal number IN'IO BCD into BCD number. (Refer to HEX in HD630l/HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details. ~HITACHI 914 4.2.3 Program Module Process Flow (Main Program) The flowchart in figure 4-4 is an example of the pulse width measurement performed by the program module in figure 4-3. Main program - --{ Initialize stack pointer. Initialize flag indicating whether or { not pulse width measurement is completed. ---{ Select port 2 as input. Initialize timer control/status register I ---{ to enable input capture interrupt and trigger on rising edge of Tin pin. ---{ Enable interrupts. ___ {Test if pulse width measurement is completed. ___ {Load 2-byte hexadecimal pulse width into entry argument of HEX. ___ {Clear flag indicating pulse width measurement is completed. Call HEX to convert 2-byte hexadecimal --- [ pulse width into BCD number. Refer to HEX in HD630l/HD6303 FAMILY ) ( APPLICATION NOTES (SOFTWARE) for details. I Input Capture Interrupt Routine ___ {Obtain Pulse width as a 2-byte hexadecimal number. Figure 4-4. Program Module Flowchart ~HITACHI 915 4.3 PROGRAM MODULE DESCRIPTION Program Module Name: MEASURE PULSE MCU/MPU: HD6301YO/ Label:PWCNT WIDTH .HD6303Y Function: Obtains pulse width as a 2-byte hexadecimal number, and stores result in PWDAT (RAM) • Arguments: Chan~es in CPU Specifications: Storage No. of Re9:isters and Fla~s: Contents Location Bytes ACCD ROM (Bytes): 29 ACCA ACCB Entry x I· x RAM (Bytes): 5 Stack (Bytes): 0 IX • No. of cycles: 400 . Reentrant: No C V Relocatable: No x x Interrupt OK?: No Re- Pulse PWDATA 2 Z N turns width (RAM) x x Flag in- ENDF 1 I H dicating (RAM) completion • • of measure- ment • Not x affected Undefined t Result Description: 1. Function Details a. Argument details PWDATA(RAM): Contains pulse width as a 2-byte hexadecimal number. ENDF(RAM) Contains flag indicating whether or not pulse width measurement is completed. Table 4-3 shows flag function. Specifications Notes: ~HITACHI 916 Program Module Name: MEASURE PULSE MCU/MPU: HD6301YO/ WIDTH HD6303Y IL'bel' PWCNT Description: Table 4-3. Flag Functions Label bit 0 Function ENDF o Indicates pulse width measurement is not completed. 1 Indicates pulse width measurement is completed. b. Example of PWCNT execution is shown in figure 4-5. If pulse, whose High period of pulse is 150 I1s, is input as shown in part Q) of figure 4-5, measurement result is ~tored in PWCNT(RAM) as a hexadecimal number and "1" is stored in ENDF(RAM). j f' CD Input pulse Tin 1501's p..:,jl------i 'L @ 2 Return 1 blS PWDATA PWDATA+l bO arguments p~t6~~~)1 0 : 0 I9 : 6 ENDF(RAM) b7 ENDF bO ($01) I0 : 1 I Figure 4-5. Example of PWCNT Execution c. PWCNT calls neither the program modules nor subroutines. I 2. User Notes The following procedure must be performed before PWCNT execution. a. Initialize flag indicating whether or not pulse width measurement is completed. b. Select bit 0 of port 2 as input. c. Initialize timer control/status register 1 to enable input capture interrupt and trigger or rising edge of Tin pin. d. Enable interrupts. @HITACHI 917 Program. Module Name: MEASURE PULSE WIDTH .M_C_U_/_M_P_U_:_HD_6_3_0_l_Y_O_/ I- HD6303Y _ _ ~ I. Label, PWCNT Description: 3. RAM Allocation Label RAM Description Values in input capture register or rising LCRUP edge of input pulse. PWDATA 2-byte hexadecimal pulse width. ENDF Flag indicating whether or not pulse width measurement is completed. 4. Sample Application BCLR O,ENDF Clear flag indicating whether or not pulse width measurement is completed. CLRA STAA P2DDR } Select port 2 as input. LDAA· #$12 STAA TCSRl } Initialize timer control/status register. CLI Enable interrupts. PWMNl BTST o ,ENDF} Test if pulse width measurement is BEQ PWMNl completed. LDD PWDATA} Store return arguments of PWCNT in RAM. STD HEXD I I I 5. Basic Operation a. Input pulse to Tin pin is evaluated as to whether input capture interrupt is generated on rising edge of pulse or on falling edge. b. If rising edge, value in input capture register is stored in ICRUP(RAM) and timer control/status register 1 is defined to generate next interrupt on falling edge of pulse. c. If falling edge, value in ICR(RAM) is subtracted from value in input capture register to obtain pulse width. Then, timer control/status register 1 is defined to generate next interrupt on rising edge of pulse. ~HITACHI 918 Program Module Name: MEASURE PULSE WIDTH M_C_U_I_M_P_U_:_HD_6_3_0_I_Y_O_/ HD6303Y _ _...J .lL_a_b_e_l_:_PW_C_NT _ _ _ _... L.. Flowchart: __ {Clear input capture interrupt request flag. (l,TCSRl) = ° __ { Test whether in'terrupt is generated on rising edge of pulse or falling edge. (1, TCSR1) ,,0 Store value in input capture register on { -- rising edge of pulse. Define timer control/status register I - - { to generate next interrupt on falling edge of pulse. __ { Obtain pulse width by calculating difference between rising edge and falling edge of input capture register. __ {store n 1 n in flag to indicate pulse width measurement is completed. __ { Define timer control/status register I to generate next interrupt or rising edge of pulse. PWCT2 ~HITACHI 919 4.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 4.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ************************* 00003 * 00004A 0040 ORG $40 00005 00006A 0040 * 0002 A ICRUP RMB 2 ICR data on rising edge 00007A 0042 0002 A PWDATA RMB 2 PuLse width data 00008A 0044 0001 A ENDF RMB 1 Measurement compLetion flag 00009A 0045 0002 A HEXD RMB 2 PuLse width In HEX data 00010A 0047 0003 A DECD RMB 3 PuLse width In BCD data 00011 00012 * **** SYMBOL DEFINITIONS ********************** 00013 00014 0001 A * P2DDR EQU $01 Port 2 data dlrctlon register 00015 0008 A TCSR1 EQU $08 Timer controL/status reglster1 00016 OOOD A ICR EQU $OD Input capture register 00017 ************************************************ 00018 00019 ** MAIN PROGRAM : PWMN ** 00020 * * 00021 ************************************************ 00022 * 00023A COOO ORG $COOO 00024 * 00025A COOO 8E 013F A PWMN LDS 1I$13F InitiaLize stack pointer 00026A C003 71 FE 44 BCLR O.ENDF CLear flag 00027A C006 4F CLRA 00028A C007 97 01 A STAA P2DDR 00029A C009 86 12 A LDAA 11$12 InitiaLize TCSR1 00030A COOB 97 08 A STAA TCSR1 00031A COOD OE CLI EnabLe interrupts 00032A COOE 7B 01 44 PWMN1 BTST O.ENDF Test If measure puLse width end? 00033A COlI 27 FB COOE BEQ PWMN1 Branch If not 00034A C013 DC 42 A LDD PWDATA Load puLse width In HEX data 0003SA C01S DD 45 A STD HEXD 00036A C017 71 FE 44 BCLR O.ENDF CLear flag 00037A COlA BD C038 A JSR HEX Convert HEX data Into BCD data 00038A COlD 20 FE COlD PEND BRA PEND End of program 00039 *****************************************>1<********** 00040 * * 00041 * NAME: PWCNT (MEASURE PULSE.WIDTH) * 00042 * * 00043 **************************************************** 00044 * * 00045 * ENTRY NOTHING * 00046 * RETURNS: PWDATA (PULSE WIDTH) * 00047 * ENDF (MEASUREMENT COMPLETION FLAG) >I< 00048 * * 00049 **************************************************** 00050A COIF DC OD A PWCNT LDD ICR CLear' ICF 00051A C021 7B 02 08 BTST 1.TCSR1 Branch If IEDG=O 000S2A C024 27 07 C02D BEQ PWCT1 00053A C026 DD 40 A STD ICRUP 000S4A C028 71 FD 08 BCLR 1,TCSRl Define TCSR1 000S5A C02B 20 OA C037 BRA PWCT2 00056A C02D 93 40 A PWCT1 SUBD ICRUP CaLcuLate puLse width 000S7A C02F DD 42 A STD PWDATA store puLse width In PWDATA ~HITACHI 920 00058A C031 72 01 44 BSET O.ENDF Set fl ag 00059A C034 72 02 OB BSET 1.TCSRI Def1ne TCSR1 00060A C037 38 PWCT2 RTI 00061 *************************************************** 00062 00063 * NAME : HEX (CONVERT 2-BYTE HEXADECIMAL :I< * 00064 * NUMBER INTO 5-DIGIT BCD NUMBER)* 00065 * 00066 * *************************************************** * 00067 00068 * ENTRY : ACCD (2-BYTE HEXADECIMAL NUMBER) * 00069 * RETURNS : DECD (5-DIGIT BCD NUMBER) >I< 00070 * * 00071 ***************************************************** 00072A C038 4F HEX CLRA CLear' ACCA 00073A C039 SF CLRB CLear ACCB 00074A C03A DD 47 A STD DECD CLear 5-dlglt BCD 00075A C03C 97 49 A STAA DECD+2 00076A C03E C6 10 A LDAB tH6 Store shlft counter 00077A C040 7B 0046 A HEX2 ASL HEXD+l Shlft MSB of HEXD to carry 00078A C043 79 0045 A ROL HEXD 00079A C046 CE 0003 A LDX 113 Set addlt10n counter ADDR 00080A C049 A6 46 A HEXI LDAA DECD-l.X DE CD * 2 + C -) ACCA 00081A C04B A9 46 A ADCA DECD-l.X 00082A C04D 19 DAA Convert 1nto BCD data 00083A C04E A7 46 A STAA DECD-l.X Store 5-dlglt BCD area 00084A C05D 09 DEX Decrement AD DR polnter 000B5A C051 26 F6 C049 BNE HEXI LOOD unt1L ADDR Dolnter=O 00086A C053 SA DECB Decrement shlft counter 00087A C054 26 EA C040 BNE HEX2 LOOD untlL sh1ft counter=O 00088A C056 39 RTS 00089 ************************************************ 00090 00091 * VECTOR ADDRESSES * 00092 * * 00093 * ************************************************ * 00094 00095A FFEA * ORG $FFEA 00096 * 00097A FFEA COOO A FDB PWMN IRQ2 00098A FFEC COOO A FDB PWMN CMI 00099A FFEE COOO A FDB PWMN TRAP 00100A FFFO COOO A FDB PWMN SID 00101A FFF2 COOO A FDB PWMN TOI 00102A FFF4 COOO A FDB PWMN OCI 00103A FFF6 COIF A FDB PWCNT ICI 00104A FFF8 COOO A FDB PWMN IRQlIISF 00105A FFFA COOO A FDB PWMN SWI 00106A FFFC COOO A FDB PWMII! NMI 00107A FFFE COOO A FDB PWMrJ RES OOIOB * 00109 END I ~HITACHI 921 SECTION 5. INPUT PULSE COUNT 5.1 HARDWARE DESCRIPTION 5. 1. 1 Function Counts input pulses up to 255 pulses; the count value is returned as a binary coded decimal (BCD) number. 5.1.2 Microcomputer Operation The HD6301YO uses TCLK pin to input pulses and timer 2 up counter to count the input pulses. Beginning and ending of pulse counting is performed by setting and clearing timer 2 enable bit in timer control/ status register 3. 5.1.3 Circuit Diagram Input pulse measurement circuit is shown in figure 5-1. MCU HD6301YO (HD6303Y) 4, MPo MP1 NMI STBY 33 Vee i-=2::!2pF~-=2-l X TAL f4MHzD 1--+_3--1 EXT A L 22pF HV 1S2076 ~+----=--lR E S Pulse input Vss P 27 / TCLK 1-'1,.,6'--_ _ _ _ _ _ _ _ _ _-0 Figure 5-1. Input Pulse Measurement Circuit ~HITACHI 922 5.1.4 Pin Functions Pin functions of HD6301YO for counting pulses is shown in Table 5-1. Table 5-1. Pin Functions Pin Name Input/ Active Level Program (HD6301YO) Output (High or Low) Function Label P27/TCLK Input Inputs pulse event 5.1.5 Hardware Operation Figure 5-2 shows input pulse count using TCLK pin of the HD6301YO. To set start/end timing for counting input pulses, the procedure below must be performed in the main program. i. Set flag in STRTF(RAM). ii. Execute 200 ms software timer. iii. Clear flag is STRTF(RAM). TCLK pin Pulse count start End N: Number of (N=O) (N=5) Pulses Figure 5-2. Input Pulses Count / $ HITACHI 923 5.2 SOFTWARE DESCRIPTION 5.2.1 Program Module Configuration The program module configuration for input pulse count is shown in figure 5-3. PLSMN ~ MAIN PROGRAM I PLSCNT I HEX I ~ CONVERT L:. COUNT HEXADECIMALS PULSES INTO BCD Figure 5-3. Program Module Configuration 5.2.2 Program Module Functions Program module functions are summarized in table 5-2. Table 5-2. Program Module Functions No. Program Module Name Label Function o MAIN PROGRAM PLSMN Counts input pulses as a BCD numbers. 1 COUNT PULSES PLSCNT Counts input pulses as a hexadecimal number. 2 CONVERT HEXADECIMALS HEX Converts 2-byte hexadecimal number IN'ID BCD. into BCD number. Refer to HEX in HD630l/HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details. ~HITACHI 924 5.2.3 Program Module Process Flow (Main Program) The flowchart in figure 5-4 is an example of counting input pulses, performed by the program module in figure 5-3. Main program --{ Initialize stack pointer. Initialize timer control/status register 3 - - { to input external clock and disable clock input to timer 2 up counter. --{ Set "1" in start/stop request flag. --1[Execute PLSCNT to count input pulse. Execute 200ms software timer. __ {Clear start/stop request flag to stop input pulse count. __ {Execute PLSCNT to obtain input pulse count result. __ { Load input pulse count result into entry arguments of HEX. I - - i call HEX to convert hexadecimal count result into a BCD number. Refer to HEX in HD6301/HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details. Figure 5-4. Program Module Flowchart ~HITACHI 925 5.3 PROGRAM MODULE DESCRIPTION Program Module Name: COUNT PULSES MCU/MPU:HD630lYO/ Label: PLSCNT HD6303Y Function: Counts pulses input from TCLK pin, and loads count result into ACCA. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes) : 20 ACCA ACCB Entry Start/stop STRTF 1 request (RAM) x • RAM (Bytes) : 1 flag Stack (Bytes) : 0 IX • No . of cycles: 30 Reentrant: No C V Relocatab1e: No x x Interrupt OK?: Yes Re- Pulse count ACCA 1 Z N turns result x x I H • • • Not affected x : Undefined Result Description: 1. Function Details a. Argument details STRTF(RAM): Holds flag indicating whether input pulse count will start or stop. Table 5-3 shows flag functions. ACCA: Contains input pulse count result as a l-byte hexadecimal number. Specifications Notes: "No. of cycles" in "Specifications" indicates the number of cycles required to start input pulse count. ~HITACHI 926 Program Module Name: COUNT PULSES MCU/MPU: HD6301YO/ PLSCNT HD6303Y ILabe" .Description: b. Example of PLSCNT execution is shown in figure 5-5. i. If bit 0 of entry argument STRTF(RAM) is set to "1", input pulse count starts as shown in port 1<>1<>1<>1< SYMBOL DEFINITIONS ********************** 00011 00012 001B A *TCSR3 EQU $IB Timer control/status register 3 00013 001D A T2CNT EQU $10 Timer 2 UP counter 00014 ************************************************ 00015 * " 00016 * MAIN PROGRAM : PLSMN * 00017 **************************************~**********" 00018 00019 * 00020A COOO ORG $COOO 00021 " 00022A COOO 8E 013F A PLSMN LOS tl$13F Initialize stack pointer 00023A C003 86 03 A LDAA tl$03 Initialize TCSR3 00024A C005 97 IB A STAA TCSR3 00025A C007 72 01 40 BSET O.STRTF Set flag to request starting 00026A COOA 80 19 C025 BSR PLSCNT Start pulse count 00027A COOC CE 00C8 A LDX tl200 Execute 200ms software timer 00028A COOF 86 C8 A PLSMNl LOAA tl200 00029A COIl 4A PLSMN2 OEcr~ 00030A C012 26 FD CO 11 BNE PLSMN2 00031A C014 09 DEX 00032A C015 26 F8 COOF BNE PLSMNI 00033A C017 71 FE 40 BCLR O.STRTF Clear flag to request stop~in9 00034A COlA 80 09 C025 BSR PLSCNT Stop pulse count 00035A COl C .?~ 0041 A CL.R HEXD Clear u~per byte of HEXD 00036A COIF 9/ 42 A STAA HEXD+l Load count result Into lower byte 00037A CO~? \ 8U I? C03(~ BSR HEX Convert count result Into BCD data 00038A C02) 20 FE [023 PEND BRA PEND End of program 00039 *********)k:~****~*'k*************************~*)kl,t 00040 >I< ~ 00041 * NAME : PLSCNT (COUNT PULSE) 00042 ***M(******************************************~~(* 00043 00044 >I< ~ 00045 * ENTRY: STRTF (START/STOP REQUEST FLAG) * 00046 * RETURNS : ACCA (PULSE COUNT RESULT) * 00047 00048 ***********M~:****************~:*****~C:k*********~C** " 00049A C025 7B 01 40 PLSCNT BTST O.STRTF Test if count start or stop? 00050A C028 27 09 C033 BEQ PLSCTl Branch if stop 00051A C02A 7F OOlD A CLR 12CNl Clear T2CNT 00052A C02D 86 13 A LDAA tlS13 Start pulse count 00053A C02F 97 IB A STAA TCSR3 00054A C031 20 06 C039 BRA PLSC T2 00055A C033 86 03 A PLSCTI LDAA ~$03 Stop pulse count 00056A C035 97 IB A STAA TCSR3 00057A C037 96 10 A LDAA T2CNT load pulse count result Into ACCA ~HITACHI 930 00058A C039 39 PLSCT2 RTS 00059 **********************)k*****~'*******~(****~C******~: ** 00060 ** 00061 ** NAME : HEX (CONVERTING ?-BYTE HEXADECIMALS 00062 >\< INTO S--DIGlT BCD) " 00063 >\< 00064 * *********************M;ll:***~)ki;~***:k*~:*A:***'I(** :k****** 00065 * >\< 00066 * ENTRY : HEXD (2-BYTE HEXADECIMAL NUMBER)>\< 00067 >\< RETURNS : DECD (5-DIGIl 8CD NUMBER) * 00068 >\< 00069 00070A C03A 4F HEX CLRA CLear- ACCA 00071A C038 SF CLRB CLeat' ACCB 00072A C03C DD 43 A STD DECD CLear 5-digit BCD are~ 00073A C03E 97 45 A STAA DECD+2 00074A C040 C6 10 A LDAB IH6 Set shift counter 00075A C042 78 0042 A HEX2 ASL HEXD+1 Shift MSB of HEXD to carry 00076A C045 79 0041 A RoL HEXD 00077A C048 CE 0003 A LDX ~3 Set ADDR pointer(addition counter) 00078A C048 A6 42 A HEX1 LDAA DECD-I. X DE CD >I< 2 + C -) ACCA 00079A C04D A9 42 A ADCA DECD-1, X 00080A C04F 19 DAA Convert into BCD 00081A COSO A7 42 A STAA DECD-1, X Store 5-digit BCD area 00082A C052 09 DEX Decrement AD DR pointer 00083A C053 26 F6 C04B BNE HEX1 Loop untiL ADDR polnter=O 00084A C055 SA DECB Decrement shift counter 00085A C056 26 EA C042 BNE HEX2 Loop untiL shift counter=O 00086A C058 39 RTS 00087 ************************************************ 00088 * >I< 00089 >\< VECTOR ADDRESSES >I< 00090 >I< 00091 * ************************************************ 00092 * 00093A FFEA oRG $FFEA 00094 >I< 00095A FFEA COOO A FDB PLSMN IR02 00096A FFEC COOO A FDB PLSMN CMI 00097A FFEE COOO A FDB PLSMN TRAP 00098A FFFO COOO A FDB PLSMN SID 00099A FFF2 COOO A FD8 PLSMN TOI OOlOOA FFF4 COOO A FDB PLSMN oCI 00101A FFF6 COOO A FDB PLSMN ICI 00102A FFF8 COOO A FDB PLSMN IROliISF 00103A FFFA COOO A FDB PLSMN SWI 00104A FFFC COOO A FDB PLSMN NMI 00105A FFFE COOO A FDB PLSMN RES 00106 >I< 00107 END ~HITACHI 931 SECTION 6. 8 x 4 KEY MATRIX 6.1 HARDWARE DESCRIPTION 6.1.1 Function Performs key scan of 8 x 4 key matrix, invalidating simultaneous depression of more than 2 keys by software, and converting valid key data into ASCII characters (AIV Z or 1 IV 6) • 6.1.2 Microcomputer Operation The HD6301YO uses timer 1 to execute output compare interrupt 1 every Bms. Key scan is performed by an output strobe signal through port 4, controlling DDR (data direction register) of port 4. Since all parts except port 4 are input ports (high impedance state), diodes for preventing output signal collision are not necessary. Key scan data is fetched through port 3 during the interrupt routine. 6.1.3 Peripheral Devices 8 x 4 Key matrix : Keys to be depressed. 6.1.4 Circuit Diagram Key scan control circuit is shown in figure 6-1. ~HITACHI 932 +5V MCU HD6301 YO 4 MPo 5 MP1 8 NMI 41 KRO P40 I----="'-{ 7 STBY f 33 22 F 2 Vee P411-4_0_ _K_R-{1 f--!P:""---I XT AL 4MHzCJ 3 EXTAL 1'.2 r3_9_-,K=R2:q 22pF 38 KR3 +5V 1'.31---~~ IS2076 KCo KCl KCZ KC3 KC4 KC5 KC6 P ""'5.:;;.8_ _ _-' 30 57 Vss P 31 1 - - -_ _ _ _----' r P 5_6 _ _ _ _ _ _ _ _-l 32 55 P3SI------------~ P 1"5..:.4_ _ _ _ _ _ _ _ _ _ _ _ ----l S4 53 P35~--------------~ P r5~Z _________________ ~ 36 51 P 37 r------------------------l Figure 6-1. Key Scan Control Circuit I ~HITACHI 933 6.1.5 Pin Functions Pin functions at the interface between the HD6301YO and the key matrix are shown in table 6-1. Table 6-1- Pin Functions Pin Name Input! Active Level Pin Name Program (HD6301YO) Output (High or Low) Function (Key matrix) Label P40 Input! Low Outputs strobe KRo P4DTR Output signal P41 Input! Low KRl Output P42 Input/ Low KR2 Output P43 Input/ Low KR3 Output P 30 Input Inputs key KCo P3DTR P 31 Input data KCl P 32 Input KC2 P 33 Input KC3 P 34 Input KC4 P 3S Input KCs P 36 Input KCG P 37 Input KC7 6.1.6 Hardware Operation The timing chart for key scan is shown in figure 6-2. OFF :~n:~pression ON ____________ _Vyj\:.....L..._______ON__ ----...--.-' Chatter Key fetch CD First key data timing (Timer interrupt) CD ® ® ® Second key data CD ® ® ® Third key data ON Key data valid timing OFF I r Key data is valid Figure 6-2. Chatter Prevention Timing Key depression signal is checked every 8 ms. If key data is the same 3 consective times, it will then be valid, and invalid otherwise. ~HITACHI 934 6. 2 SOFTVIARE DESCRIPTION 6.2.1 Program Module Configuration The program module configuration for key scan of 8 x 4 key matrix is shown in figure 6-3. K84.MN MAIN ~ PROGRAM K 84. SCN I ~ KEY SCAN Figure 6-3. Program Module Configuration 6.2.2 Program Module Functions Program module functions are summarized in table 6-2. Table 6-2. Program Module Functions No. Program Module Name Label Function o MAIN PROGRAM K84MN Performs key scan of 8X4 key matrix and converts key data into ASCII. 1 KEY SCAN K84SCN Performs key scand of 8x4 key matrix. I ~HITACHI 935 6.2.3 Program Module Process Flow (Main Program) The Flowchart in figure 6-4 is an example of a key scan of the 8 x 4 key matrix performed by the program module in fiqure 6-3. Main program --- {Ini tialize stack pointer. ---I C1e= .... uoed by KB4SCN. ___ {Initialize timer control/status register 1 to enable output compare interrupt. ---1[Initialize port 4. ----[Enable interrupt. depressed. valid key number into ACCS. ---{ Clear flag to indicate key is depressed. ---{Load starting address of data table into IX. ---{Load data table pointer into IX. ---{store ASCII in RAM. OCI interrupt routine . - - {Execute I 1, key scan is completed since i t I indicates two keys are pressed at the same time. ~HITACHI 939 I Progr= Module Name: KEY SCAN MCU/MPU: HD630lYO Label: K84SCN Description: d. Key data (NEWKEY(RAM)) obtained in (C) is compared with previous key data (OLDKEY(RAM)). If they are the same, chatter counter (CHATEL(RAM)) is counted up. When chatter counter becomes "3", key data is valid. If key data is valid, MSB of CHATFL(RAM) is set to "1" to indicate key data is valid. CHATFL(RAM) includes both a counter and a flag. CHATFL(RAM) is cleared, when NEWKEY(RAM) data differs from OLDKEY(RAM) data or no key is depressed. ~HITACHI 940 Program Module Name: KEY SCAN MCU/MPU: HD6301YO ~ K84SCN Flowchart: - - 1 Reinitialize output compare register 1 to enable output compare 1 and generate interrupt 8 ms later. __ {Test if key data has been processed in main program. - - { Initialize data for output strobe signal. - - { Initialize RAM for key number. - - { Initialize RAM for number of depressed keys. - - { Initialize RAM for new key number. - - { Output strobe signal. - - { Load key scan data into ACCA. Test if a key is depressed everY time I - - { strobe signal is output. key is depressed, store next starting ~HITACHI 941 Program Module Name: KEY SCAN MCU/MPU: HD630lYO ~ K84SCN Flowchart: Initialize shift counter to test which { -- key is depressed. --{ Shift key scan data 1 bit right. --{ Test if key is depressed. --Il Test if key chatter is generated. If so, complete key scan. __ {store depressed key number in RAM as key data. --{ Increment RAM indicating key number. - - {Decrement shift counter. __ {Test if all keys have been checked whether or not they are depressed. __ {Load strobe signal data to perform key scan for next column. Test if key scan for all columns have been { completed. - - { Test if a key is depressed this time. __ {compare current key data and previous key data. Store current key data in RAM for next key __ [ scan. Clear RAM indicating number of key scan. ~HITACHI 942 Program Module Name: KEY SCAN MCU/MPU: HD6301YO Label: K84SCN Flowchart: ---[Test if key data is valid. Test if key scan has been executed 3 times. ___[Increment RAM indicating number of key scan. __ {set flag to "1" to indicate key data is valid. __ 1r Store valid key number in return argument. '- Set fl'3.g to "1" to indicate a key is { depressed. I ~HITACHI 943 6.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 6.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ************************ 00003 * 00004A 0040 ORG $40 00005 00006A 0040 0001 A *I1<>1<>1<>1<** 00018 * >I< 00019 >I< MAIN PROGRAM : ADMN * 00020 >I< >I< 00021 ************************************************ 00022 * 00023A COOO ORG $COOO 00024 * 00025A COOO 8E 013F A AD~lN LDS tI$13F InitiaLize stacl< pointer 00026A C003 4F CLRA CLear' RAM 00027A C004 97 40 A STAA ADEND 00028A C006 86 E2 A LDAA tI$E2 InitiaLize RAM/Pod 5 contr'oL r'8g i ster' 00029A C008 97 14 A STAA RP5CR 00030A COOA 86 02 A LDAA tI$02 InitiaLize port 5 00031A COOC 97 15 A STAA P5DTR 00032A COOE 97 20 A STAA P5DDR 00033A COlO OE CLI EnabLe i nter-rupts 00034A COll 71 FD 15 BCLR 1,P5DTR Set ADS to Low 00035A C014 7B 01 40 ADMNI BTST O,ADEND Test if AID conversion compLete 00036A C017 27 FB C014 BEQ ADMN1 00037(-'\ C019 71 FE 40 BCLR O,ADEND CLear' compLete Hag 00038A COlC 4F CLRA Load AID COllver's ;on r'esu Lt in HEX data 00039A COlD 97 42 A STAA HEXD 00040A COIF 96 41 (., LDM ADDM 00041A C021 97 43 A STAA HEXD+1 00042A C023 BD C036 A ,JSR HEX Conver't HEX data into BCD data 00043A C026 20 EC C014 BRA ADMNI 00044 ******************~(~::K******~:***~::k*:k***********~!* 00045 00046 NAME : ADIN (INPUT AID CONVERSION 00047 RESULT) 00048 00049 ***~****************~(*~c*******************~~***** 00050 ** 00051 ENTRY NOTHING * 00052 * RETURNS : ADDAT (AID CONVERSION RESULT) * 00053 >I< ADEND (AID CONVERSION COMPLETE* 00054 * FLAG) 00055 * * 00056 ********=K~~************************~C***********~:* 00057A C028 72 02 15 ADIN BSET 1,P5DTR Set ADS to High ~HITACHI 954 00058A C02B 96 06 A LDAA P3DTR Load AID conversion result 00059A C02D 97 41 A S TAA (~DDAT 00060A C02F 72 01 40 SSET O.ADEND Set AID conver'slon complete flag 00061A C032 71 FE 15 BCLR O.PSOTR Set ADS to Low 00062A C035 3B RTI 00063 00064 00065 NAME : HEX (CDNVERT 2-BYTE HEXAOECIMALS 00066 INTO 5-DIGIT BCD) 00067 00068 00069 * 00070 ENTRY : HEXD (2-BYTE HEXADECIMAL NUMBER) 00071 * RETURNS : DECD (S-DIGIT BCD NUMGER) 00072 " * * 00073 *******************~(~(***~·l.,)k~*:k*:I:*:k*~·~I,::~:~*~(**~(******'k 00074A C036 4F HEX CLRA CLear ACeA 00075A C037 SF CLI~B Clea" ~\CCB 00076A C038 DD 44 A STD DECD Clear 5-dlglt BCD 00077A C03A 97 46 A ST(~A DECD+2 00078A C03C C6 10 A LDAB tj16 Store shift counter 00079A C03E 78 0043 A HEX2 ASL HEXD+l Sh 1 ft M:=S of HEXD to r.a'TY 00080A C041 79 0042 A RDl_ !-IDCD 0008lA C044 CE 0003 A LOX tj3 Set AODR ~ointer (addition counter) 00082A C047 A6 43 A HEXI LO~,A JECD-l. X DECD * 2 j C -) ACCA 00083A C049 (W 43 A ADCA DECD- l • X 00084A C04B 19 DAA Conve,'t Into BCD data 00085A C04C f\? 43 ~\ STAA DECD-l. X Store 5-dlglt BCD area 00086A C04E 09 DEX Dec"ernellt (-\aDR PO i nte" 00087A C04F 26 F6 C047 BNE HEX: Loop until ADDR polnter=O 00088A C051 SA DECe DeCI'elllE'llt sll 1 ft CDLm te" 00089A C052 26 E(\ CaSE BNE HEX2 loop until shift cQunter=O 00090A C054 39 RTS 00091 00092 >I> ,I' 00093 )1, VECmR ADDrlESSES 'k 00094 ~ 00095 *t~*********************:k:lc:I:)k***~(*~:i;*:~':iC*~'~~·'~~·~·:!;:I·k 00096 'I' 00097A FFEA ORG U:FEA 00098 'I< 00099A FFEA COOO A FDB ADr1N IR02 OOlOOA FFEC COOO A FOB AD~1N CMI OOlOlA FFEE (000 A rCDB ADI'IN TRAP 00102A FFFO COOO A FDB e\aMI~ SID 00103A FFF2 COOO A FDB ADMN TOI 00104A FFF4 COOO A FDB ADMN OCI 00105A FFF6 COOO A FDB ADMN ICI 00106A FFF8 C028 A FDB ADIN IRQI/ISF 00107A FFFA COOO A FDB ADMN SWI 00108A FFFC COOO A FDB ADMN NMI 00109A FFFE COOO A FDB ADMN RES 00110 00111 " END ~HITACHI 955 SECTION 8. STANDARD KEYBOARD INTERFACE 8.1 HARDWARE DESCRIPTION 8.1.1 Function Receives key data from a standard ASCII keyboard. 8.1.2 Microcomputer Operation The HD6301YO accesses data from an ASCII keyboard using a First In- First Out roll buffer. Port 6 control/status register is selected to perform parallel handshaking between the IS pin and port 6. Input data is read at the falling edge of the STROBE signal and data is written to the roll buffer by input strobe interrupt. 8.1.3 Peripheral Devices ASCII keyboard: Outputs ASCII codes and STIillBE signal. 8.1.4 Circuit Diagram The interface circuit for reading data from an ASCII keyboard is shown in figure 8-1. +5V U HD6301YO (HD6303y) ~ MP. ~ MP, ~ NMI ~ STBY 22 pI" .......ll Vee XTAL 4.\"Iz~ 3 EXTAL pi" r-- IS2 076 ~~ 4.71« 31 p•• Ian p., 6 'ItES 29 PM 128 lid-' p.. 27 ~ p•• 26 ~ Vss p., Po. 25 II 40Z Vss 1<'7 P"./IS 21 STROBE B, B. B. B.B,B. £I., I IIII III I ASCII Keyboard 1m Figure 8-1. Reading Data from ASCII Keyboard $ HITACHI 956 8.1.5 Pin Functions Pin functions at the interface between the HD6301YO and ASCII keyboard are shown in table 8-1. Table 8-1. Pin Functions Active Level Pin Name Pin Name Input/ (High (Key- Program (HD6301YO) Output or Low) Function board) Label PS4/IS Input Low STROBE signal STROBE P 60 Input Key data input signal Bl P6DTR P 61 Input B2 P 62 Input B3 P 63 Input B4 P 64 Input Bs P 6S Input B6 P 66 Input B7 8.1.6 Hardware Operation The timing chart for the ASCII keyboard is shown in figure 8-2. If a key in ASCII keyboard is depressed, data and STROBE signal are output as shown in figure 8-2. ASCII keyboard pin names key data (Bl~B7) ________~(~______________~)~------------------ STROEiE signal (STROBE) --------------.....,U f Input sErobe interrupt generated Figure 8-2. ASCII Keyboard Timing Chart ~HITACHI 957 8.2 SOFTWARE DESCRIPTION 8.2.1 Program Module Configuration The program module configuration for reading key data from ASCII keyboard is shown in figure 8-3, KEYMN MAIN I.! PROGRAM I K EYIN I KEYOUT I RECEIVE l!. READ I.!. KEY DATA KEY DATA Figure 8-3. Program Module Configuration 8.2.2 Program Module Functions Program module functions are summarized in table 8-2. Table 8-2. Program Module Functions No. Program Module Name Label Functions 0 MAIN PROGRAM KEYMN Receives key data from ASCII keyboard and accesses roll buffer. I RECEIVE KEY DATA KEY IN Receives key data and write s then to roll buffer. 2 READ KEY DATA KEYour Reads data in roll buffer. ~HITACHI 958 8.2.3 Program Module Process Flow (Main Program) The flowchart in figure 8-4 is an example of key data input from ASCII keyboard performed by the program module in figure 8-3. Main Program '--__. . . . __--.J----[ Initialize stack pointer. ' -_ _-,-_ _--1 ----fIni tialize pointers to valid data addresses " in roll buffer. ____{ Initialize port 6 control/status register '--_ _........_ _--1 to enable latch and input strobe interrupt. o -. Bit I ----{Enable interrupts. u.._ _-,-_ _ -U----{ Read key data in roll buffer. (Bit ---[Te,t if there i, key data in roll buffer. C)tl ....._ _....L._ _- . , ___ { Store roll buffer data in RAM. Input strobe interrupt routine. ______ [Receive key data and write them to roll L-~~~~~~ buffer. Figure 8-4. Program Module Flowchart ~HITACHI 959 8.3 PROGRAM MODULE DESCRIPTION Program Module Name: RECEIVE KEY MCU/MPU: HD6301YOI Label: KEYIN DATA HD6303Y Function: Receives key data from ASCII key board and writes them to roll buffer. Arguments: None Changes in CPU Specifications: Registers and Flags: ACCD ROM (Bytes): 27 ACCA ACCB x I x RAM (Bytes): 20 Stack (Bytes):O IX x No. of cycles: 48 Reentrant: No C V Relocatable: No x x Interrupt OK?: No Z N x x I H • • • Undefined x Not affected : t Result Description: 1. Function Details a. KEYIN has no arguments. b. Example of KEYIN execution is shown in figure 8-5. If "A" in ASCII keyboard is pressed as shown in part Q) of figure 8-5, key data'is written to roll buffer as shown in part @ of figure 8-5. c. KEYIN calls neither the program modules nor subroutines. Specifications Notes: NIA ~HITACHI 960 Program Module Name! RECEIVE KEY DATA M_C_U_I_M_P_U_!_HD_6_3_0_l_Y_O_/ HD6303Y _ _..... .1L..L_a_b_e_l_!_KE_Y_I_N_ _ _....... L.. Description! Press "A" key b7 PS+l bO Before PS+l (RAM) ($ 0 0) I0 : 0 I execution PE+l PE+l (RAM)($ 0 0) I 0 : 0 I KEYBUF(RAM) PH t )*'* J 1 6 byte ~ b7 PS+-l bO PS+ 1 (RAM) ($ 0 0) I 0 : 0 I @ After ( PE+l execution PE+l (RAM) ($ 01) I 0 : 1 I KEYBUF(RAM) ~ } ~ 1 6 byte * *: Undefined hexadecimal data 1 *'* J Figure 8-5. Example of KEYIN Execution 2. User Notes a. Both KEYIN and KEYOUT must use the same roll buffer. b. The following procedure must be performed before KEYIN execution. i. Initialize pointers to valid data addresses. ii. Initialize port 6 control/status register to enable latch and input strobe interrupt. iii. Enable interrupts. iv. Press a key in ASCII keyboard. 3. RAM Allocation Label RAM Description b7 bO PS r- - } Starting pointer indicating start address of valid data in roll buffer. PE r- - } End pointer indicating last address of valid data in roll buffer. KEYBUF r- :f-- T :j l' 16 bytes roll buffer to which key data will be written. ~HITACHI 961 Program Module Name: RECEIVE KEY DATA MCU/MPU: BD630lYO/ BD6303Y ILabel' KEYIN Description: 4. Sample Application I I I } CLRA CLRB ----- Initialize pointers. STD PS STD PE IDAA STAA #$48 P6CSR } Initialize port 6 control/status register. CLI Enable interrupts. I I I 5. Basic Operation a. Roll buffer operation i. Data in roll buffer is accessed using starting pointer PS(RAM), indicating start address, and e~d pointer PE(RAM), indicating the last address. ii. When data is written to roll buffer, data is stored in the address indicated by PE (RAM); PE (RAM) is .then incremented. iii. When data is read from roll buffer, data is loaded from the address indicated by PS(RAM); PS(RAM) is then incremented. iv. When increment of PS(RAM) and PE(RAM) generates overflow, data is stored from the start address again. v. Roll buffer in this program can store I'\, 15 bytes of data. b. KEYIN Operation i. PE(RAM) is incremented and checked if it equals PS(RAM). ii. If equal, data cannot be written to roll buffer since roll buffer cannot store more data. iii. If not equal, data can written to roll buffer and PE(RAM) is incremented. ~HITACHI 962 Program Module Name: RECEIVE KEY DATA MCU/MPU: HD6301YO/ HD6303Y Icabel, KEY IN Flowchart: --l fClear input strobe interrupt request flag to enable interrupts. --[Load end pointer to last address. __ {Increment end pointer to last address. (If over "$F", it becomes "0".) ~-[Teet if roll buffer ie full. --[store end pointer. --{store key data in roll buffer. I ~HITACHI 963 Program Module Name: READ KEY DATA MCU/MPU: HD630lYO/ Label: KEYOUT HD6303Y Function: Reads key data from roll buffer. 'Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes): 20 ACCA ACCB Entry _ _ x I x RAM (Bytes): 18 Stack (Bytes): 0 IX No. of cycles: 34 I x Reentrant: No C V Relocatable: No x • Interrupt OK?: Yes Re- Data in ACCB 1 Z N turns roll buffer x x Valid data Bit C 1 I H indicator (CCR) • • • Not x Affected Undefined : t Result Description: 1. Function Details a. Argument details ACCB: Contains data read from roll buffer. bit C(CCR): Contains valid data indicator which shows whether or not there are valid data in roll buffer. bit C=O: Indicates data is read from roll buffer. Specifications Notes: N/A ~HITACHI 964 _p_r_o_g_r_am_M_o_d_u_le_N_a_m_e_:_RE_AD IID6303Y _ _..... _ __KE_Y_D_A_T_A_...J ...M_C_U_I_M_P_U_:_IID_6_3_0_I_Y_O_I IL_a_b_e_I_:_KE_Y_O_UT _ _ _......J .. Description: bit C=l: Indicates there is no data in roll buffer. b. Example of KEYOUT execution is shown in fi)lure 8-6. If KEYOUT is ~xecuted with the condition shown in part\1jof figure 8-6, data is stored in ACCB as shown in part@of figure 8-6. b7 PS+l bO PS+l (RAM) ($01) I 0 : 1 PE+1 Before $03 I o : 3 execution KEYB UF 47 (RAM) PS+1 40 30 1 Hbytes PE+1 32 I I I T I 4H r b7 ,I PS+l bO (RAM) I [PS+' ($02) 0 : 2 I PE+l G) After execution PE+1(RAM) ($03) Bit C 0 :3 ACCB m 4 ACCB : 0 Figure 8-6. Example of KEYOUT Execution c. KEYOUT calls neither the program modules nor subroutines. I 2. User Notes Both KEYIN and KEYOUT must use the same roll buffer and must be executed in pairs. ~HITACHI 965 Program Module Name: READ KEY DATA MCU/MPU: HD6301YO/ HD6303Y ILabel, KEYOUT Description: 3. RAM Allocation Label RAM b7 bO Description PS f- - } Starting pointer indicating start address of valid data in roll buffer. PE f- - } End pointer indicating last address of valid data in roll buffer. KEYBUP t- t- 1: =} T 16 bytes roll buffer to which key data will be written. 4. Sample Application I I I LOOP II JSR KEYOUT II ----- Call KEYOUT. BCS LOOP ---- Test if there is data in roll buffer. STAB WORK ---- Store return argument in RAM. I I I I 5. Basic Operation a. Contents of starting pointer PS(RAM), indicating starting data address in roll buffer, is compared with contents of end pointer PE(RAM) , indicating last data address in roll buffer. b. If equal, bit C is set to "1" since there is no data in roll buffer. c. If not equal, data is read from the address indicated by PS+l(RAM) and PS+l(RAM) is incremented. Bit C is cleared to indicate data is read from roll buffer. ~HITACHI 966 Program Module Name: READ KEY DATA MCU/MPU: lID6301YO/ lID6303Y I~ KEYOUT Flowchart: _______ [ Load starting pointer into IX. ______ [ Test if there is data in roll buffer. ______ [Load data in roll buffer into return argument. ....--_ _.L......_---,- - - - - -- Increment starting pointer to start address. _______ [ Clear valid data indicator showing O-+Bit C data is read from roll buffer. Set valid data indicator showing { ------- there is no data in roll buffer. KEYOT2 R T S I ~HITACHI 967 8.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 8.5 PROGRAM LISTING 00001 * 00002 ************ RAM ALLOCATION ***************** 00003 * 00004A 0040 ORG $40 00005 * 00006A 0040 0002 (4 PS RMB 2 Starting pointer 00007A 0042 0002 A PE RMB 2 End po inter' 00008A 0044 0010 A II< * 00047 * ************************************************ 00048A COlA DE 40 A KEYOUT LOX PS Load starting pointer 00049A C01C 9C 42 A CPX PE Check data in roLL buffer 00050A COlE 27 DC C02C BEQ KEYOT1 Branch if no data 00051A C020 E6 44 A LDAB KEYBUF,X Load key data 000S2A C022 96 41 A LDAA PS+1 00053A C024 4C INCA Increment starting pointer 00054A C025 84 OF A ANDA Il$OF 00055A C027 97 41 A STAA PS+1 OOOSM C029 OC CLC CLear carr'y 000S7A C02~) 20 01 C02D BRA II< 00062 NAME: KEYIN (RECEIVE KEY DATA) 00063 * 00064 * *********************************************** * 00065 * *>I< 00066 ENTRY : NOTHING 00067 * RETURNS : NOTHING * * 00068 ************************************************ .iC 00069 00070A C02E 96 21 A KEYIN LDAA P6CSR CLear Interrupt request fLag 00071A C030 96 17 A LDAA P6DTR 00072A C032 DE 42 A LDX PE Load end pointer 00073A C034 D6 43 A LDAA PE+l 00074A C036 5C INCB Increment end pointer 00075A C037 C4 OF A ANDB II$OF 00076A C039 D1 41 A CMPB PS+l 00077A C038 27 04 C041 BEQ II< 00002 **** RAM ALLOCATION ********:k************** 00003 >I< 00004A 0040 ORG $40 00005 >I< 00006A 0040 0002 A DATIX RMB 2 Start address of data table 00007 00008 **** " SYMBOL DEFINITIONS *******'k*********** 00009 >I< 00010 0016 A P6DDR EDU $16 Port 6 data direction register 00011 0017 A P6DTR EDU $17 Port 6 data register 00012 0021 A P6CSR EDU $21 Port 6 control/status register 00013 ****~;******************************** 00014 >I< >I< 00015 MAIN PROGRAM : SENMN 00016 >I< >I< '" >I< 00017 ************************************* 00018 00019A COOO ORG $COOO 00020 >I< 00021A COOO 8E OUF A SENMN LOS tl$13F Initialize stack pointer 00022A C003 86 FF A LD~\(~ H$FF Select por't 6 as output 00023A COOS 97 16 A S T(~n P6DDR 00024A C007 86 70 A LO(~I~ tl$70 Initialize P6CSR 00025A C009 97 21 A STA(-\ P6CSR 00026A COOB OE eLI EnabLe interrupts 00027A COOC CE C02B A LOX tlDMA Load data t~ble pointer 00028A COOF DF 40 A STX DATIX Stole data table pointer 00029A COlI A6 00 A LOAA O.X Load data 00030A C013 97 17 A STAA P6DrR 00031A C015 20 FE C015 PEND 8R~\ PEND 00032 00033 >I< 00034 NAME : SEOUT (SEND DATA) 00035 '" 00036 '" ** ** >I< >I< '* >1<>1<* * >I< 'I< *** >I< >I<}\( *>1<>1< *' ** ** *:k ** * **>1 ·+::t;:I(* 00037 00038 * ENTRY NOTHIG '" >I< 00039 * RETURNS NOTING 00040 * * 00041 * ***************************"'******"''''*'''* '" 00042A C017 96 21 A SEOUT LDAA P6CSR Clear interrupt request flag 00043A C019 DE 40 A LDX DATIX Increment data table pointer 00044A C01B 08 INX 00045A C01C DF 40 A STX DATIX I 00046A COlE A6 00 A LDAA O.X Load data 00047A C020 81 FF A CMPA tl$FF Test if data=$FF 00048A C022 27 04 C028 BED SEOUTl Branch if data=$FF 00049A C024 97 17 A STAA P6DTR Store data 00050A C026 20 02 C02A BRA SEOUT2 Branch always to SEOUT2 00051A C028 96 17 A SEOUTl LDAA P6DTR Dummy read Port 6 00052A C02A 3B SEOUT2 RTI 00053 *******************Ht******************* 00054 '" ** 00055 * DATA TABLE 00056 ********************************~c******** 00057 ~HITACHI 979 000s8A C02B 4D A DATA FCC /M M / >1<1 coLumn data 000s9A C03l 20 A FCC / CCC / 00060A C037 55 A FCC /U U/ 0006lA C03D 20 A FCC / / 00062A C040 48 A FCC /H 1-1 / 00063A C046 44 A FCC /DDD / 00064A C04C 20 A FCC / 66 / 0006sA COs2 33 A FCC /33333 / 00066A COs8 20 A FCC / 000 / 00067A COsE 20 A FCC / 1 / 00068A C062 59 A FCC /y Y / 00069A C068 20 A FCC / 000 / 00070A C06E OD A FCB $OD.$OA 00071A C070 4D A FCC /MM MM / >1<2 coLumn data 00072A C076 43 A FCC /C C /" 00073A C07C 55 A FCC /U U / 00074A C082 20 A FCC / / 0007SA C08S 48 A FCC /1-1 H/ 00076A C08B 44 A FCC /D D / 00077A C091 20 A FCC / 6 / 00078A C097 20 A FCC / 3 / 00079A C09D 30 A FCC /0 0 / 00080A COA3 31 A FCC /11 / 0008lA COA7 59 A FCC /y y / 00082A COAD 30 A FCC /0 o/ 00083A COB3 OD A FCB $OD.$OA 00084A COBS 4D A FCC /M M M / >1<3 coLumn data 0008sA COBB 43 A FCC /C / 00086A COCI 55 A FCC /U U/ 00087A COC7 20 A FCC / / 00088A COCA 48 A FCC /H H/ 00089A CODO 44 A FCC /D D/ 00090A COD6 36 A FCC /6 / 0009lA CODC 20 A FCC / 3 / 00092A COE2 30 A FCC /0 00 / 00093A COE8 20 A FCC / 1 / 00094A COEC 20 A FCC / YY / 0009sA COF2 30 A FCC /0 00 / 00096A COF8 OD A FCB $OD.$OA 00097A COFA 4D A FCC /M M M / >1<4 coLumn data 00098A ClOO 43 A FCC /C / 00099A Cl06 55 A FCC /U U / OOlOOA ClQC 20 A FCC / / OOlOlA ClOF 48 A FCC /HHHHH / 00102A Clls 44 A FCC /D D/ 00103A C11B 36 A FCC /6666 / 00104A C12l 20 A FCC / 3 / OOlOsA C127 30 A FCC /0 0 0 / 00106A C12D 20 A FCC / 1 / 00107A C13l 20 ~~ FCC / y / 00108A C137 30 A FCC /0 0 0 / 00109A C13D OD A FCB $OD.$OA OOlIOA C13F 4D A FCC /M M / >1<5 coLumn data OOlllA Ct45 <;3 p FCC /C / 001I2A C14B 55 A FCC /U U/ 00113A C1sl 20 A FCC / / 001l4A Cls4 48 A FCC /H H/ ~HITACHI 980 00115A 05(-\ 44 A FCC 10 0 I 00116A C160 36 A FCC 16 6 I 00117A C166 20 (-\ FCC I 3 I 00118A C16C 30 A FCC 100 0 I 00119A Cl72 20 A FCC I 1 I 00120A C176 20 A FCC I y I 00121A C17C 30 ~\ FCC 100 o I 00122A C182 00 A FCB $OO.$OA 00123A C184 40 ~\ FCC 1M M I *6 coLumn data 00124A C18A 43 !-\ FCC IC C I 00125A C190 55 A FCC III U I 00126A C196 20 A FCC I I 00127A C199 48 A FCC IH H I 00128A C19F 44 A FCC ID 0 I 00129A C1AS 36 A FCC 16 6 I 00130A C1AB 33 A FCC 13 3 I 00131A C1B1 30 A FCC 10 0 I 00132A C187 20 A FCC I 1 I 00133A C1BB 20 A FCC I Y I 00134A C1C1 30 A FCC 10 oI 00135A C1C7 00 A FCB $OO.$OA 00136A C1C9 40 A FCC 1M M I *7 coLumn data 00137A C1CF 20 A FCC I CCC I 00138A C105 20 A FCC I UUU I 00139A ClOB 20 A FCC / I 00140A C10E 48 A FCC IH H I 00141A C1E4 44 A FCC 1000 I 00142A C1EA 20 A FCC I 666 I 00143A C1FO 20 A FCC I 333 I 00144A C1F6 20 A FCC I 000 I 00145A C1FC 31 A FCC 1111 I 00146A C200 20 A FCC I y / 00147A C206 20 A FCC I 000 I 00148A C20C 00 A FCB $OO.$OA,$FF 00149 *********"'*****",****",*********>1<",>1<",,,,***>1<>1< 00150 * * 00151 * VECTOR ADDRESSES * 00152 >I< 00153 '"**************************************** 00154 * 00155A FFEA oRG $FFEA 00156 >I< 00157A FFEA COOO A FOB SENMN IRQ2 00158A FFEC COOO A FOB SENMN CMI 00159A FFEE COOO A FOB SENMN TRAP 00160A FFFO COOO A FOB SENMN SID 00161A FFF2 COOO A FOB SENMN TOI 00162A FFF4 COOO A FOB SENMN oCI 00163A FFF6 COOO A FOB SENMN ICI 00164A FFF8 C017 A FOB SEoUT IRQlIISF 00165A FFFA COOO A FOB SENMN SWI 00166A FFFC COOO A FOB SENMN NMI 00167A FFFE COOO A FOB SENMN RES 00168 >I< 00169 END I ~HITACHI 981 SECTION 10. DATA TRANSFER WITH ASYNCHRONOUS SCI 10.1 HARDWARE DESCRIPTION 10.1.1 Function Receives ASCII from the console typewriter as asynchronous serial data, and sends ASCII to the console typewriter converting lower case letters into uppercase letters. 10.1.2 Microcomputer Operation The HD6301YO sends/receives data to/from the console typewriter by asynchronous SCI (serial communication interface), defining the band rate as 4800 BPS. RS232C level for data transfer should be selected. Transfer format is defined as 1 start bit + 8 bits of data + 1 stop bit by the rate/mode control register. Signals CTS and RTS of the console typewriter are controlled through bits 0 and 1 of port 5. 10.1.3 Peripheral Devices Console Typewriter: Sends/Receives data to/from the microcomputer. 10.1.4 Circuit Diagram Asynchronous SCI circuit is shown in figure 10-1. +5V M C U HD6301YO (HD6303Y) 4 Console typewriter 5 MPo MPI 33 7 ~ HD75188 8 STBY 17 NMI ):)-_ _ _-\ CTS 22pF Pso HD75189 F"-~ XTAL 18 PSI 1=-------0;:;..1-------; RTS 27k EXTAL 22pF +5V HD 75188 13 Pa/Tx b------iRx HD75189 12 6 P2S/ RX.~--------~~II___--------~Tx RES 1tLF SG Vss -12V 42 Vss Figure 10-1. Asynchronous SCI Circuit ~HITACHI 982 10.1.5 Pin Functions Pin functions at the interface between the HD6301YO and the console typewriter are shown in Table 10-1. Table 10-1. Pin Functions Pin Name Pin Name Input/ Active Level (Console Program (HD6301YO) Output (High or Low) Function Typewriter) Label Pso Output Low Outputs sending data CTS PsDTR request signal to the console type- writer. Input Low Inputs sending data RTS request signal from the console type- writer. Input Receives serial data Tx from the console typewriter. Output - Sends serial data Rx back to the console typewriter. 10.1.6 Hardware Operation The timing chart for sending/receiving data and control signals are shown in figure 10-2. This application example generates the timing by software. HD6 8 0 1 YO O)~=F-4S POI(CTS) Sending ( data _ _-+., Tx Receiving data Start bit Stop bit I Rx Start bit Figure 10-2. Timing Chart for Sending/Receiving Data ~HITACHI 983 10.2 SOFTWARE DESCRIPTION 10.2.1 Program Module Configuration The program module configuration for sending/receiving data to/from the console typewriter is shown in figure 10-3. SCMN ~ MAIN PROGRAM SCI I N I SCIOUT TPR J CONVERT 12. ~ ASCII ~ RECEIVE DATA SEND DATA· LOWERCASE INTO UPPERCASE Figure 10-3. Program Module Configuration 10.2.2 Program Module Functions Program module functions are summarized in table 10-2. Table 10-2. Program Module Functions No. Program Module Name Label Function 0 MAIN PROGRAM SCMN Send/Receive data to/from the console typewriter using asynchronous SCI. 1 RECEIVE DATA SCIIN Receive data from the console typewriter. 2 SEND DATA SCIOUT Send data back to the console typewriter. 3 CONVERT ASCII TPR Converts ASCII lowercase into uppercase. IDWERCASE INTO Refer to TPR in HD630l/HD6303 FAMILY UPPERCASE APPLICATION NOTES (SOFTWARE) for details. ~HITACHI 984 10.2.3 Program Module Process Flow (Main Program) The flowchart in figure 10-4 shows the procedure for sending/receiving data to/from the console typewriter, using the program module in figure 10-3. If ASCII lowercase characters are received, the main program converts them into uppercase. Main Program ---{ Initialize stack pointer. L..-_ _, - - _ - - ' ---[Clear RAM. L..-_ _, - - _ - - ' L-_ _-,-_ _ -.l----[ Set signal RTS to High. - - - [Initialize port 5. 1..---,-----' Initialize rate/mode control register to input the SCI clock from timer 2 and to [ ---- define transfer format as 1 start bit +8 ~---,---~ bit data. ___ [Initialize TX/RX control status register 2 to no parity bit and 1 stop bit. L..-_ _ ,...-_---J Initialize timer control/status register - - - [ 3 to start E clock input into timer 2 up counter. Initialize Tx/Rx control status register - - - [ 1 to enable receiving interrupts and start receiving. ___ [Define time constant register as 4800 BPS. L..-_ _ ,...-_---J I L-_ _.....,._ _ _...1 - - - Gbable interrupts. Figure 10-4. Program Module Flowchart ~HITACHI 985 signal RTS to Low. Test if data is received from the console - - - [ typewriter. receiving data into AOCA. indicating data is L-_ _...,.._ _---l---[set signal RTS to Low. Execute TPR to convert ASCII lowercase _ __ [ into uppercase. Refer to TPR in HD630l/HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details. u..__-.-__ --LJ---[ Send data back to the console typewriter. selIN SCI Interrupt Routine DATA ___ [Receive data from the console typewriter using SCI interrupts. L...._ _....-_--' Figure 10-4. Program Module Flowchart (Cont.) ~HITACHI 986 10.3 PROGRAM MODULE DESCRIPTION Program Module Name: RECEIVE DATA MCU/MPU:HD6301YO/ Label: SCIIN HD6303Y Function: Receives serial data from the console typewriter. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes) : 22 ACCA ACCB Entry -- --- -- x • RAM (Bytes) : 2 IX Stack (Bytes) : 0 No • of cycles: 41 • Reentrant: No C V Relocatable: No • x Interrupt OK?: Yes Re- Data SCIDAT 1 Z N turns received (RAM) x x Receiving INFLG 1 I H complete (RAM) flag • • • Not x affected Undefined : t Result Description: 1. Function Details a. Argument details SCIDAT(RAM): Holds data received. I INFLG(RAM) Used as flag indicating whether or not receiving is completed. Table 10-3 shows flag functions. b. Example of SCIIN execution is shown in figure 10-5. If bit 0 of portS (signal RTS) is set to Low, data sent from the console typewriter is stored in SCIDAT(RAM). Specifications Notes: "No. of cycles" in "Specifications" indicates the number of cycles required to receive data. ~HITACHI 987 ~IL_L_a_b_e_l_:_sc ~ Program Module Name: RECEIVE DATA M_C_U_/_M_P_U_:__ HD_6_3_0_l_Y_0_/____ HD6303Y . __I_I_N______ L_ Description: Table 10-3. Flag Functions Label bit 0 Function INFLG o Indicates data is not received. 1 Indicates data is received. (j) Input ::tn........'--'----'mJt 1LtB MSB f Start bit Stop bit SCIDAT (RAM) b7 SCIDAT bO (Data received ( $61» 6 : 1 ® ReSUlt! INFLG (RAM) INFLG (Receiving o : complete flag ($01» Figure 10-5. Example of SCIIN Execution c. SCIIN calls neither the program modules nor subroutines. 2. User Notes The following procedure must be performed before SCI IN execution. a. Select DDR of bit 0 of port 5 as output. b. Initialize SCI since asynchronous SCI is used. c. Enable interrupts for SCI interrupts. 3. RAM Allocation Label RAM Description b7 bO SCIDAT INFLG B } Data sent from the console typewriter. lUsed as flag indicating whether or not data f is received. ~HITACHI 988 Program Module Name: RECEIVE DATA M_C_U_I_M_P_U_: HD6303Y _H_D6_3_0_1_Y_0_/_ _.-. _ lL_a_b_e_l_:_S_C_I_IN _ _ _---' L.. Description: 4. Sample Application ~ CLRA STAA INFLG } Clear RAM. LDAA STAA STAA #$01 P5DTR P5DDR } Set signal RTS to High. LDAA STAA CLRA #$24 RMCR t Initialize rate/mode control register. STAA TRCSR2 } Initialize Tx/Rx control register 2. LDAA STAA #$14 TCSR3 } Initialize timer control/status register 3. LDAA STAA #$18 TRCSRl } Initialize Tx/Rx control status register l. #$07 LDAA STAA TCONR } Initialize time constant register to 4800 BPS. BCLR O,P5DTR Set signal RTS to Low. SCMNl BTST O,INFLG BEQ SCMNl } Test if receiving data is completed. BCLR O,INFLG Clear receiving complete flag. LDAA SCIDAT Load data received. BCLR O,PSDTR Set signal RTS to Low. 5. Hardware Operation a. If data is received in receive data register, an SCI interrupt is generated and SCIIN is executed. b. Signal RTS is set to high to disable the console typewriter from sending data. c. Tx/Rx control status register detects whether or not overrun/framing I error is generated. i. If overrun/framing error is generated, receive data register is dummy read and error indicator is cleared. ii. If error is not generated, received data is stored in SCIDAT(RAM). ~HITACHI 989 Program Module Name: RECEIVE DATA MCU/MPU: HD630lYO/ HD6303Y ILab,l, SCIIN Flowchart: • L -____ ~----~---[ Clear SCI interrupt request flag. error is received data into entry argument. ' - -____...._ _-..J - - - [ Set receiving complete flag. SCIINl (RDR)"':'ACCA ___ [ Dummy read receive data register and clear flag indicating overrun/framing error. ~HITACHI 990 Program Module Name: SEND DATA MCU/MPU: HD6301YO/ Label: SCIOUT HD6303Y Function: Sends data, loaded into ACCA, back to the console typewriter. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes): 16 ACCA ACCB Entry Data to be ACCA sent I • • RAM (Bytes): 0 Stack (Bytes): 0 IX • No. of cycles: 28 Reentrant: No C v Relocatable: No • x Interrupt OK?: Yes Re- z N turns x x I H • • • Not affected x : Undefined Resul t Description: 1. Function Details a. Argument details ACCA: Holds data to be sent back to the console typewriter. b. c. Example of SCIOUT execution is shown in figure 10-6. If entry argument is as shown in part CD of figure 10-6, data is sent to the console typewriter as shown in part Q) of figure 10-6. SCIOUT calls neither the program modules nor subroutines. I Specifications Notes: N/A ~HITACHI 991 Program Module Name: SEND DATA LM_C_U_/_M_P_U_:__ _ HD_6_3_0_1_Y_0_/____ HD6303Y ~lL_a_b_e_l_:_._SC . __IO_UT ______ ~ Description: b7 ACCA bO fi' Entry { ACCA I 6 3 ~ argument I..__~__~ r r r'T' ,-.-rT'-'-.-r r- rr T'- P51 : ! i :! !: : : I : : : : ! : : i @ Result { pZ-I./Tx MSB Start bit Stop bit Figure 10-6. Example of SCIOUT Execution 2. User Notes Initialize SCI for asynchronous SCI. 3. RAM Allocation RAM is not used during SCIOUT execution. 4. Sample Application LDAA STAA #$24 RMCR } ----- Initialize rate/mode control register. CLRA STAA TRCSR2 }----- Initialize Tx/Rx control status register 2. LDAA STAA #$14 TCSR3 } ----- Initialize timer control/status register 3. LDAA STAA #$18 TRCSRl } ----- Initialize Tx/Rx control status register 2. LDAA STAA #$07 TCONR }----- baud Initialize time constant register and define rate to 4800 BPS. LDAA #$30 Load data to be sent. II JSR SCIOUT II Execute SCIOUT. $ HITACHI 992 Program Module Name: SEND DATA MCU/MPU: BD6301YO/ Label: SCIOUT HD6303Y - -- Description: 5. Basic Operation a. Whether or not there is a sending data request from the console typewriter is determined by signal CTS. b. If signal CTS is Low, data can be sent to the console typewriter. If signal CTS is High, wait until signal CTS is Low. c. Whether or not transmit data register is empty is tested by transmit data register empty bit (bit 5) of TX/Rx control status register 1. d. Transmit enable bit (bit 1) of Tx/Rx control status register 1 is set to "1" and data sending is started. e. Data to be sent is stored in transmit data register. I ~HITACHI 993 Program Module Name: SEND DATA MCU/MPU: HD630lYO/ HD6303Y [~ SCIOUT Flowchart: transmit data register is - - - [start sending data. 1.-_ _,..-_---1 ___ [Load data to be sent into transmit data register. ~--r-----' ~HITACHI 994 10.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 10.5 PROGRAM LISTING 00001 * 00002 ************ RAM ALLOCATION ******************* 00003 00004A 0040 * ORG $40 00005 * 00006A 0040 0001 A INFLG RMB Receiving compLete fLag 00007A 0041 0001 A SCIDAT RMB Data received 00008 * 00009 ************ SYMBOL DEFINITIONS **************** 00010 * 00011 0010 A RMCR EQU $10 RATE/MODE CRTL REG 00012 0011 A TRCSRl EQU $11 Tx/Rx CRTL REG 1 00013 0012 A RDR EQU $12 RECEIVE DATA REG 00014 0013 A TOR EQU $13 TRANSMIT DATA REG 00015 0015 A PSDTR EQU $15 PORTS DATA REG 00016 001B A TCSR3 EQU $lB TIMER CRTL REG 3 00017 OOlC A TCONR EQU $lC TIME CONSTANT REG 00018 001E A TRCSR2 EQU $lE Tx/Rx CRTL REG 2 00019 0020 A PSDDR EQU $20 PORTS DDR 00020 ********************************************* 00021 00022 ** MAIN PROGAM : SCMN ** 00023 00024 * ********************************************* * 00025 00026A COOO * ORG $COOO 00027 * 00028A COOO 8E 013F A SCMN LDS 1:I$13F InitiaLize stack pointer 00029A C003 4F CLRA CLear RAM 00030A C004 97 40 A STAA INFLG 00031A C006 86 01 A LOAA 1:1$01 InitiaLize port 5 00032A C008 97 IS A STAA PSDTR 00033A CODA 97 20 A STAA PSDDR 00034A COOC 86 24 A LDAA 1:1$24 InitiaLize RMCR 0003SA CODE 97 10 A STAA RMCR 00036A COlO 4F CLRA InitiaLize TRCSR2 00037A COlI 97 IE A STAA TRCSR2 00038A C013 86 14 A LDAA 1:1$14 InitiaLize TCSR3 00039A C01S 97 1B A STAA TCSR3 00040A C017 86 18 A LDAA 1:1$18 InitiaLize TRCSRI 00041A C019 97 11 A STAA TRCSR1 00042A C01B 86 07 A LDAA 1:107 Set 4BOOBPS 00043A COlD 97 1C A STAA TCONR 00044A COIF OE CLI EnabLe interrupts 0004SA C020 71 FE IS BCLR O.PSDTR Set RTS=O I 00046A C023 7B 01 40 SCMNI BTST O.INFLG Test if data is received 00047A C026 27 FB C023 BEQ SCMNI 00048A C028 96 41 A LDAA SCIDAT Load SCI data 00049A C02A 71 FE 40 BCLR O. INFLG CLear SCI flag OOOSOA C02D 71 FE 15 BCLR O.PSDTR Set RTS=O OOOSlA C030 BD C038 A JSR TPR Convert Lowercase into uppercase 000S2A C033 BD COS9 A JSR serOUT Send data 000S3A C036 20 EB C023 BRA SCMNI 00054 ********************************************* 00055 * * 00056 * NAME : TPR (CONVERT B BIT BINARY INTO * 00057 * ASCII) * • HITACHI 995 00058 00059 * ********************************************* * 00060 00061 ** ENTRY: ACCA (8 BIT BINARY) ** 00062 * RETURNS: ACCA (8 BIT BINARY) * 00063 * * 00064 ********************************************* 00065 * 00066A C038 81 61 A TPR CMPA tI'a ACCA-'a' 00067A C03A 25 06 C042 BCS TPRI Branch if ACCA<'a' 00068A C03C 81 7A A CMPA tI'z ACCA-'z' 00069A C03E 22 02 C042 BHI TPRI Branch if ACCA)'z' 00070A C040 84 DF A ANDA tI$DF Convert Lowercase into uppercase 00071A C042 39 TPRI RTS 00072 ******************************************** 00073 00074 * NAME : SCIIN (RECEIVE DATA) * 00075 * * 00076 * ******************************************** * 00077 ** ** 00078 ENTRY NOTHING 00079 * RETURNS : SCIDAT (DATA RECEIVED) * 00080 * INFLG (RECEIVING COMPLETE* 00081 * FLAG) * 00082 * * 00083 ******************************************** 00084A C043 96 11 A SCIIN LDAA TRCSRI CLear interrupt request flag 00085A C045 72 01 15 BSET 0.P5DTR Set RTS='l' 00086A C048 7B 40 11 BTST 6.TRCSRl ORFE bit='O' or '1' 00087A C04B 26 09 C056 BNE SCIINI Branch if ORFE='l' OOOSSA C04D 96 12 A LDAA RDR Set receiving compLete flag 00089A C04F 97 41 A STAA SCIDAT 00090A C051 72 01 40 BSET O.INFLG Set SCI fLag 00091A C054 20 02 C058 BRA SCIIN2 00092A C056 96 12 A SCIIN1 LDAA RDR CLear error fLag 00093A C058 38 SCIIN2 RTI 00094 ***************************************** 00095 * * 00096 * NAME : SCIOUT (SEND DATA) 00097 * 00098 *********************~(******************* 00099 00100 ** ENTRY : ACCA (DATA TO BE SENT) * * 00101 * RETURNS : NOTHING * 00102 * • * 00103 *:k****:~:k:k:~*:~**;k******:k******************* 00104A C059 7B 02 15 SCIOUT BTST 1.P5DTR Loop untiL CTS=O 00105A C05C 26 FB C059 BNE serOUT 00106A C05E 7B 20 11 SCIOTI BTST 5.TRCSRI Loop untiL TDRE=O 00107A C061 27 FB C05E BEQ SCIOll 00108A C063 72 02 11 BSET 1.TRCSRl Start sending data 00109A C066 97 13 A STAA TDR Load data to be sent 00l10A C068 39 RTS 00111 ************************************~:**** 00112 00113 * VECTOR ADDRESSES * 00114 * * * * ~HITACHI 996 00115 ***************************************** 00116 * 001l7A FFEA ORG $FFEA 00118 * 001l9A FFEA COOO A FOB SCMN IRQ2 00120A FFEC COOO A FOB SCMN CMI 00121A FFEE COOO A FOB SCMN TRAP 00122A FFFO C043 A FOB SCIIN SID 00123A FFF2 COOO A FOB SCMN TO! 00124A FFF4 COOO A FOB SCMN OCI 0012SA FFF6 COOO A FOB SCMN rCI 00126A FFF8 cooe A FOB SCMN IRQl/ISF 00127A FFFA COOO A FOB SCMN SWI 00128A FFFC cooo A FOB SCMN NMI 00129A FFFE COOO A FOB SCMN RES 00130 * 00131 ENO I ~HITACHI 997 SECTION 11. LIQUID CRYSTAL DRIVED (HD6ll00A) CONTROL 11.1 HARDWARE DESCRIPTION 11.1.1 Function Controls the HD6ll00A liquid crystal driver and displays "9876543210" on an LCD display. 11.1.2 Microcomputer Operation The HD630lYO sends display data and control signals to the HD6ll00A to display graphics on the LCD. Signals M and CLI of the HD6ll00A and signal COMMON of the liquid crystal are controlled through port 2. In addition, the HD6ll00A control signals (signals CL2, DL) are controlled using the clock synchronous SCI (serial communication interface) of port 2 to enable sending of display data to the HD6ll00A. 11.1.3 Peripheral Devices HD6ll00A LCD Driver: Performs static drive on an 8-segment x 10-digit LCD. 11.1.4 Circuit Diagram LCD driver (HD6ll00A) control circuit is shown in figure 11-1. MCV HD6301YO +sv (HD6308Y) 881~11I401481 821501851411 VZL VZR V,LlVSK V1L VIR V4L V4R ! VEE Vee 1415 ~ mID ~r.===C=O=MM==O=N============~ ~ ~HL ~l~~~~er Y/I---ao----'-'\ I CI CI 000 C10DO D I .!!. FCS Y U U IJ U U U U U U U B• -V p.. ~ ..~ M Liquid crystal P2I I"::-g----I CL. ~,LI' '~LLI (8-segments x lO-digits) p •• 1-:-:-_-;-;-;::-;;--:-;-;,.,....,,....,..._-=8.:...J1! - P •• /SCLK~1~1_~H~D~1_+~H~C~0_+~~~_ _~ P.~/Txfm~ ______v_ _ _ _~ Figure 11-1. LCD Driver (HD6ll00A) Control Circuit ~HITACHI 998 11.1.5 Pin Functions Pin functions at the interface between the HD6301YO and the HD61100A are shown in table 11-1. Table 11-1. Pin Functions Pin Name Pin Name Input/ Active Level (HD61100A Program (HD6301YO) Output (High or Low) Function LCD) Label PZl Output Outputs alternate M P2DTR signal for LCD driving output. Pzo Output Resets counter, CLl outputs synchronous signal of latch clock for display data. PZ3 Output Outputs common COMMON signal to LCD. Pzz/SCLK Output Outputs shift clock CL2 for display data. P2'>/'l'x Output Inputs display data. DL 11.1.6 Hardware Operation Timing chart of the HD6301YO, LCD, and the HD61100A is shown in figure 11-2. LCD and HD61100A pin names COMMO~L___________________________________ ______---'1 ----------,L I Controlled by I/O ports M CLI JlL....-_________________ __________IL Controlled { by clock synchronous CL , --------~ SCI DL --------~ 1..J1..J'~~o\..uJt\..P..JU\..t--8JOl..Jb\..iJt\..SJ\..(J1'-OJ\..dJi\..gJi'-t-S) -- --- -- .1 Figure 11-2. Timing Chart of HD6301YO, LCD, and HD61100A @>HITACHI 999 11.2 SOFTWARE DESCRIPTION 11.2.1 Program Module Configuration The program module configuration for character display on LCD is shown in figure 11-3. H61MN MAIN ~ PROGRAM I H 61 DSP I MOVE I DISPLAY II MOVE l!. CHARACTER DISPLAY DATA Figure 11-3.. Program Module Configuration 11.2.2 Program Module Functions Program module functions are summarized in table 11-2. Table 11-2. Program Module Functions No. Program Module Name Label Function o MAIN PROGRAM H61MN Initializes control registers and data addresses used for the interface between the HD6301YO and the HD6ll00A. 1 DISPLAY CHARACTER H61DSP Performs static drive of LCD using the HD6ll00A and displays numerals. 2 MOVE DISPLAY DATA MOVE Moves display data in data table to display RAM. Refer to MOVE in HD6301/ HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details. ~HITACHI 1000 11.2.3 Program Module Process Flow (Main Program) The flowchart in figure 11-4 shows the procedure for displaying numerals on an LCD as performed by the program module in figure 11-3. Main Program ___[ Initialize stock pointer. ___ [ Set signals CLI and M to Low and signal COMMON to High. ---[ Select port 2 as output. Initialize rate/mode control register to 8-bit --- data format, clock synchronous SCI mode, [ internal clock source, bit 2 of port 2 clock output and baud rate 16~s/bit. Initialize transmit/receive c9ntrol status - - { register I to enable data transfer and enable interrupts. ___ [Initialize counter indicating the number of interrupts. ---[Enable interrupts. Load starting address of display data, - - - [ contained in data table, into entry argument of MOVE. ___[ Load starting address of display RAM into entry argument of MOVE. ___[ Load number of bytes to be moved into entry argument of MOVE. Execute MOVE to move display data to display --_ [ RAM. Refer to MOVE in HD630l/HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details. TDRE Interrupt Routine I L..;==:;;:::=::""....I- - { Execute H6lDSP to display numerals on LCD. Figure 11-4. Program Module Flowchart ~HITACHI 1001 In g8l55Y32 IU Figure 11-5. Example of H61MN Execution @HITACHI 1002 11.3 PROGRAM MODULE DESCRIPTION Program Module Name: DISPLAY MCU/MPU: HD6301YO/ Label: H61DSP CHARACTER HD6303Y Function: Sends display data to the HD61100A and displays characters on an LCD. Arguments: Changes in CPU Specifica tions: Storage No. of Registers and Flags: contents Location Bytes ACCD ACCA ACCB ROM (Bytes) : 41 DDATA Entry Display data (RAM) 10 x • RAM (Bytes) : 12 Stack (Bytes) : 0 IX x No. of cycles: 61 Reentrant: No C V Relocatable: No • x Interrupt OK? : No Re- Z N turns x x I H x • • Not affected x : Undefined Result Description: 1. Function Details a. Argument details b. DDATA(RAM): Holds 10 bytes of display data. Example of H61DSP execution is shown in figure 11-6. If entry argument is as shown in part 1 of figure 11-6, characters are displayed as shown in part 2 of figure 11-6. I c. H61DSP calls neither the program modules nor subroutines. Specifications Notes: N/A ~HITACHI 1003 Program Module Name: DISPLAY MCU/MPU: HD6301YO/ Label: H61DSP CHARACTER HD6303Y Description: Address Space ~~ DDATA $77 (RAM) $14 $B3 Q) Entry $B6 argtmlent $D4 Display data $E6 (9,B,7,6,5,4, $E7 3,2,1,0) $74 $F7 -- $F6 LCD ~ '2' \Y Result{ OD'lCOSU=O In ...JU I I I _1'- I U Figure 11-6. Example of H61DSP Execution 2. User Notes The following procedure must be performed before H61DSP execution. a. Select data direction register (DDR) of port 2 as output. b. Initialize clock synchronous SCI to send display data. e. Clear bit I to enable TORE interrupts. d. Store display data in TOR to generate TORE interrupts. 3. RAM Allocation Label Description b7 bO Used as a pointer to display RAM and as a CNTR l- counter indicating number of interrupts. DDATA 10° digit I- ~ 10 1 digit 10 2 digit _ 10 3 digit _ 10" digit Display data 10 5 digit 10 6 digit -- 10 7 10 8 digit. digit. 10 9 digit .. . $ HITACHI 1004 Program Module Name: DISPLAY MCU/MPU: HD6301YO/ Label: H61DSP CHARACTER HD6303Y - -- Description: 4. Sample Application LDAA #$08 STAA LDAA STAA P2DTR #$FF P2DDR }----- Initialize port 2. IDAA #$11 STAA IDAA STAA RMCR #$06 TRCSRl }----- Initialize synchronous SCI. IDX STX #$0001 CNTR }----- Initialize pointer to display RAM and counter for number of interrupts. CLI ----- Enable interrupts. IDX #$F100 Execute MOVE to load display data into IDD #DDATA STD IDAB JSR DEA #$OA MOVE }----- entry argument of H61DSP. (Refer to MOVE in HD6301/HD6303 FAMILY APPLICATION NOTES (SOFTWARE) for details.) 5. Basic Operation a. 10 bytes of display data are sent to the HD61100A to display numerals on an 8 segments x 10 digits LCD. Shift clock and data signal are controlled by the clock synchronous SCI of the HD6301YO. b. Display data is stored in display RAM before execution. Each TDRE interrupt executes display of 1 byte of data. c. Pointer to display RAM and counter for number of interrupts are decremented every interrupt. CNTR(RAM) is reinitialized each time 10 interrupts are executed. d. The first enabling interrupts are performed by the main program. From then on, TDRE interrupts are generated automatically each time display data are outputted. ~HITACHa 1005 Program Module Name: DISPLAY MCU/MPU: HD6301YO/ ~ H61DSP CHARACTER HD6303Y Flowchart: __ {Decrement pointer to display RAM and counter for number of interrupts. - --[ Load pointer to display RAM. __ { Test if interrupt has been executed 10 times. , - - { Reini tialize pointer to display RAM. __ {Reinitialize counter for number of interrupts. 1-+1, P2DTR __ { Set ,ignal eL, to High. --{ Test if signal M is High. __ { Set signal CLl to Low, signal M to Low, and signal COMMON to High. __ { Set signal CLl to Low, signal M to High, and signal COMMON to Low. H61DP1 --{ Load TRCSRl to clear TDRE flag. --{ Store display data in TDR. ~HITACHI 1006 11.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 11.5 PROGRAM LISTING 00001 * 00002 ***************** RAM ALLOCATION **************** 00003 * 00004 * 00005A 0040 ORG $40 00006 * 00007A 0040 OOOA A DDATA RMB 10 DispLay data 00008A 004A 0002 A CNTR RMB 2 Counter for dispLay data 00009A 004C 0002 A DEA RMB 2 Destination address 00010 * 00011 *************** SYMBOL DEFINITIONS ************** 00012 00013 0003 A *P2DTR EQU $03 Port 2 data register 00014 0001 A P2DDR EQU $01 Port 2 data direction register 00015 0010 A RMCR EQU $10 Rate/mode controL register 00016 0011 A TRCSRI EQU $11 Tx/Rx controL status register! 00017 0013 A TOR EQU $13 Transmit data register 00018 ************************************************** 00019 * >I< 00020 >I< MAIN PROGRAM : H61MN >I< 00021 >I< >I< 00022 ***>1<**>1<*>1<***************>1<****>1<*************>1<**>1<**>1< 00023 * 00024A COOO ORG $COOO 00025 * 00026A COOO 8E 013F A H61MN LDS 1oI$13F InitiaLize stack pointer 00027A C003 86 08 A LDAA ta08 Set CL1=0.M=0.COMMON=1 00028A COOS 97 03 A STAA P2DTR 00029A C007 86 FF A LDAA IoI$FF SeLect port 2 as output 00030A C009 97 01 A STAA P2DDR 00031A COOB 86 11 A LDAA 101$11 InitiaLize RMCR 00032A COOD 97 10 A STAA RMCR 00033A COOF 86 06 A LDAA 101$06 InitiaLize TRCSR1 00034A COIl 97 11 A STAA TRCSR1 00035A C013 CE 0001 A LDX 101$0001 InitiaLize counter 00036A C016 DF 4A A STX CNTR 00037A C018 OE CLI EnabLe interrupts 00038A C019 CE F100 A LDX IoI$F100 Load source address 00039A COIC CC 0040 A LDD IoIDDATA Load destination address 00040A COIF DD 4C A STO [)E~) 00041A C021 C6 OA A LDAB H$OA InItiaLize transfer counter 00042A C023 BD C04D A JSR MOVE Move data tabLe to dispLay RAM 00043A C026 20 FE C026 PEND BRA PEND End of pr'ogram 00044 ************************************************** 00045 * >I< I 00046 >I< NAME : H61DSP (DISPLAY CHRACTER) * 00047 >I< * 00048 ************************************************** 00049 >I< * 00050 * ENTRY : DDATA (DISPLAY DATA) * 00051 * RETURNS : NOTHING * 00052 * * 00053 ************************************>1<*********>1<*** 00054A C028 7A 004B A H61DSP DEC CNTR+1 Decrement counter 00055A C02B DE 4A A LOX CNTR Test it CNTR=O ? 00056A C02D 26 11 C040 BNE H61DPI Branch it not CNTR=O 00057A C02F CE OOOA A LDX IoI$OOOA ReinitiaLize counter @HITACHI 1007 00058A C032 OF 4A A STX CNTR 00059A C034 72 02 03 BSET 1, P2DTR Set CL1=l 00060A C037 7B 04 03 BTST 2,P2DTR Branch If M=l 00061A C03A 26 OB C047 BNE H6lDP2 Branch to H61DP2 If M=l 00062A C03C 86 02 A LDAA tjS02 Set CL1=0.M=1.COMMON=Q 00063A C03E 97 03 A STAA P2DTR 00064A C040 96 11 A H61DPl LDAA TRCSRI Clear' TORE 00065A C042 A6 3F A LOAA DDATA-l,X Store display data In TOR 00066A C044 97 13 A STAA TOR 00067A C046 3B RTI 00068A C047 86 08 A H61DP2 LDAA tjS08 Set CL1=0,M=O,COMMON=1 00069A C049 97 03 A STAA P2DTR 00070A C04B 20 F3 C040 BRA H61DP1 00071 ************************************************** 00072 * * 00073 * NAME : MOVE (MOVING MEMORY BLOCKS) * 00074 * * 00075 ************************************************** 00076 * * 00077 * ENTRY IX (SOURCE ADDRESS) * 00078 * DEA (DESTINATION ADDRESS) * 00079 * ACCB (TRANSFER COUNTER) * 00080 * RETURNS: NOTHING * 00081 * * 00082 ************************************************** 00083A C04D A6 00 A MOVE LDAA O,X Load transfer data 00084A C04F 08 INX Increment source address 0008SA COSO 3C PSHX Push sou,'ce addr'ess 00086A C051 DE 4C A LOX DEA Load destination address 00087A C053 A7 00 A STAA O,X Store transfer data 00088A C055 08 INX Increment destination address 00089A C056 OF 4C A STX DEA Store destination address 00090A C058 38 PULX Pull source address 0009 H·' C059 SA DECB Decr'ement tr'ansfer' counter' 00092A COSA 26 Fl C04D BNE MOVE Branch until transfer counter 0 00093A C05C 39 RTS 00094 ************************************************ 00095 * * 00096 * DATA TABLE '" 00097 * * 00098 *************************************"'********** 00099 * OOlOOA FlOO ORG SFlOO 00101 * 00102A FlOO E7 A FCB SE7,$F7,S43,SF6,SE6 *Segment data 00103A F105 CS A FCB SCS,$E3,$B3,$41,$77 00104 ****************************************"'********* 001~ 00106 * * VECTOR ADDRESSES * * 00107 * * 00108 ************************************************** 00109 " OOllOA FFEA ORG SFFEA 00111 * 00112A FFEA COOO A FOB H61MN IRQ2 00113A FFEC COOO A FOB H61MN CMI 00114A FFEE COOO A FOB H61MN TRAP ~HITACHI 1008 OOllSA FFFO C02B A FOB H6IDSP SID 001l6A FFF2 COOO A FOB H61MN TOI 00ll7A FFF4 COCO A FOB H61MN OCI 001l8A FFF6 COOO A FOB H61MN ICI 001l9A FFF8 COOO A FOB H61MN IRQlIISF 00120A FFFA COOO A FOB H61MN SWI 00121A FFFC COOO A FOB H61MN NMI 00122A FFFE COCO A FOB H61MN RES 00123 00124 * END I ~HITACHI 1009 SECTION 12. EXTERNAL EXPANSION 12.1 HARDWARE DESCRIPTION 12.1.1 Function Receives data from the console typewriter, displays it on the H2S7l liquid crystal module, and echoes the same data back to the console typewriter. 12.1.2 Microcomputer Operation The HD6301YO controls the HM6264 RAM, HN27C64 EPROM, HD63S0 ACIA and HD6321 PIA using external expansion mode (mode 1 of this MCU). In this mode, PSO is employed as the IRQl pin to receive interrupts from the ACIA. The MCU converts ASCII lowercase, sent from the console type- writer, into uppercase through software. 12.1.3 Peripheral Devices HD63S0 ACIA: Performs asynchronous SCI with the console typewriter, controlling signals RTS and CTS at a baud rate of 4800. HD6321 PIA: Drives the liquid crystal module through ports A and B after receiving control information from the HD6301YO. HD74HC183 Address decoder: Decodes address signals from the MCU for control of the RAM, EPROM, PIA, and ACIA. 12.1.4 Circuit Diagram External expansion circuit is shown in figure 12-1. ~HITACHI 1010 ROM 5 +5V ~!Yt2 6~ HV~oRHN2'C6~,~;V LEv -20 t1 Vee PGM~ ~ CC~2 CS 1 2 ~pp ~AI2 ~ " ~ All I~ r- 21 All WE 2' +5V f. A" 25 AfJ 'J A, - CEr. 20 r 24!" 1--.12 II r~ A, OE:JZ MCU ' A7 OE or- -.A7 07~19. ~A" gl V W HD630lYO 4?kD HD?4HCI 38 +5V • A" l/O.-H---, tlr---{'~ ~~g"16 i (HD6303Y) 6'--- 5 A, O,~ A, 1/07~ HDHHCOI +5V A" 34 3 16 ~ A. 0, tH- HD?4HC04 35 2 cell HA3 04~ ~I~S ~15 HD?4HCOI IS2~ 4?kD HD ?4HCI4 Au 36 B Y, 9 A, 0, Itt-- ~ r.' r.1 l/O,~ ~ 'l ~_ ~ +5V 6- RES AI! A"tE-- ~::~ ~ "'. As t-#-- F Y,~ A ,10 4 G A Y'r-;;--- G;B 8 GND Y7 '--- A, 10 A, ,t-± GND 0, f:-':'-. 01 ~ 0, til---- ..----:-:: ~ r< TIT I/O,~ I/O,ttf----.i ,-!1 GND l/01~11111 ~ HD?4HC04 t-#-- B A ~ t-#-- PIA Liquid Crystal Module H2571 r"- 33 v A, t1}- I --I ee IID6.l21 if+5V +5Vr--Lcn..:-i---- - - - - - - - - - - - HD ~I , STBY ~ .. MP, A. 1---7::- A3 AI I-f,- A, ~ r.:- 23 _ .l6 (,S, ~ RS, V c 22 c§, 24 CS I 20 Ir--;--a : 2 V 10kD ~ Y:' "'80 11 ~ Vss LCD I 1: _i ~ ~EXTAL 22~TAL 50 / :35 HS , I ~ ~ o 5758 l.l Du I 32 PB 0 10 II II 8, DBo ...... 4Iill-{z 1. I D. I-';'-;;-' I'-fi D, PB, 12 I 9 DB, ;:::, Cl D2 ~ ~ 1)2 PB z 13 10 DBz (') 22 F D, ~ fjji D, PB, 14 II DB, 40 40 D. ~ 28 D4 PB. 15 12 DB. 1: D, -H- D, -""---' ~ D, i'-,g D, PB, 16 PH, 13 DB, DBo 5IP' -¥.-- S ~ D7 D, PB, I' 14 DB, t-.. E 64 2.J E p~ 2 6 E ....I " HD441 0 0 I 42 Vss R/W 61 rI ~~ H/IV HES PA, PA, ! ! !VW RS 4 _ / V I I ss L ____________ -.l +5V m' Console Typewriter Vss~ HD75188 ,-----, 4.'kD ):; : ORxDATA; I I I RQ.f-l!-- ACIA I IITS I liD 6350 I : 22 D V. 12 .-----f-oSG I 21 0 CC 6 11r I I 20 1)1 TxDATA 24 ers I 19 g' ;;:::~ 5 HD?51891 TXDA'rAj 18 D: RxDATA L ____ J :~ D, HD?4HC04 lMO 15 D~ II D, HD"HCO~ 9~ L~==================~1~4 L___________ ~1"l3 CSzE HxCIK UI52MHz '-_____________ IIQ --','li:HJW!!W~T:..X:.:C:.:IKJ 4 Of- o ;J;2OpF ;J; 20pF -'" Figure 12-1. External Expansion Circuit ----~- 12.1.5 Memory Map Memories and peripheral LSIs are allocated to external address space using an address decoder (HD74HC138). Address buses A13 and A14 are connected to pins A and B of the HD74HC138. Address space $8000~$FFFF is divided into 8-byte units. System Address decoding is shown in Table 12-1. Table 12-1. System Address Decode HD74HC138 Address Allocation space Input Output C B A Gl GzA G·2B Yo Yl Y2 Yg Y" Ys Y6 Y7 A1S Al" Au H L L H L L H H H H L H H H $8000 ~ $9FFF RAM H L L H L H H H H H H L H H $AOOO ~ $BFFF PIA H L L H H L H H H H H H L H $COOO ~ $DFFF ACIA H L L H H H H H H H H H H L $EOOO ~ $FFFF ROM System memory map is shown in figure 12-2. $0000 I/O Ports ~ TIMER HD6301YO internal re gisters and internal $OOIF SCI address space Not Used $004.0 RAM ) (192 Byte) $OOFF Not Used $8~00 RAM DDRA/PORTA $AnOO (HM6264.) CRA $AOOI $9FFF DDRB/PORTB $A002 O CRB $A008 $Ar PIA Not Used (HD6821) $BFFF $BFFF $Cooo CTRL/STS $COOO ~ ACIA (HD6850) TDR/RDR $COOl $DFFF $E~OO EPROM Not Used (HN2~C64.) $OFFF $FFFF Figure 12-2. System Memory Map ~HITACHI 1012 The relation between HD6301YO specified addresses and selected PIA re~isters is shown in table 12-2. Table 12-2. HD6301YO addresses and Selected PIA Registers Address Program Pin Name (HD6301YO) Label Selected PIA Register (LCD-II·) Note $AOOO DDRA Data direction Whpn bit 2. of register A control register A=O. PlRA Peripheral interface Bit O:signal E In case of bit 2 register A Bit l:signal R/W of control Bit 2:signal RS register A=l $AOOl CRA Control register A $A002 DDRB Data direction In case of bit 2 register B of control register B=O PIRB Peripheral interface In case of bit 2 register B of control register B=l $A003 CRB Control register B Note: The timing chart between PIA and LCD-II is shown in figure 12-3. CD: Write timing ®: Read timing LCD-II Pin names ----..,. RS. R/W ____J~+_-----------------J E DBo-DB. (P IA--+ LCD- D'-!)_ _ _ _ _ _ _ _- . J lI----4,.J '-_ ___ DBo-DB. ( PIA+- LCD- • D..L.._ _ _ _ _ _ _ _...J l\..____- J ' - - - - - I Figure 12-3. PIA--LCD-II Timing Chart ~HITACHI 1013 The relation between the address of the HD6301YO and the selected ACIA register is shown in table 12-3. Table 12-3. Relation between the Address of the HD6301YO and the Selected ACIA Register Address (HD6301YO) Program Label Selected ACIA Register Note $COOO CR Control register In case of signal R/W=O SR Status register In case of signal R!W=l $COOl TDR Transmit data register In case of signal R/W=O RDR Receive data register In case of signal R/W=l ~HITACHI 1014 12.1.6 Hardware Operation The interface timing chart between the HD6301YO and memories (HN27C64, HM6264) is shown in figure 12-4. -, E HDGSOIYO ADDR ESS \ I J Decoder delay time \ tAO \ teo HN27CG40 t.ce l. 'Og I Dsa ~ ~ DATA (OUT) Decoder delay time I- "'01 Dsa IIR 10E DE \ Data { t .. read HM82640 DATA (OUT) ~ lAS IwP WE II D,lta I DW 100 write{ I. DATA 1 (IN) \ tAD Address delay time I tDBR Data set-up time HD6301YO tn Data hold time tow Data delay time t •• output CE delay time too Output OE delay time HN27C64 tACO Access time tOB Data output hold time tAA Address access time teo 1 Chip select access time HM6264 tAB Address set-up time twp write pulse width tDW Input data set time tDB Input data hold time too Output enable access time Figure 12-4. Interface Timing Chart between HD6301YO and Memories ~HITACHI 1015 12.2 SOFTWARE DESCRIPTION 12.2.1 Program Module Configuration The program module configuration for receiving key data from the console typewriter and displaying data on both the console typewriter and H2571 is shown in figure 12-5. EXPMN l£. MAIN PROGRAM EXPINT I EXPDSpl EXPOUT EXPINP I TPR I 12.. ~ ~ ~ CONVERT ASCII U. INITIALIZE DISPLAY SEND DATA RECEIVE LOWERCASE LCD-II CHARACTERS DATA IN'IO UPPERCASE Figure 12-5. Program Module Configuration 12.2.2 Program Module Functions Program module functions are summarized in table 12-4. Table 12-4. Program Module Functions No. Program Module Name Label Functions o MAIN PROGRAM EXPMN Displays key data, received from the console typewriter, on both the H2571 and console typewriter. 1 INITIALIZE LCD-II EXPINT Initializes LCD-II contained in the H257l. 2 DISPLAY CHARACTERS EXPDSP Displays characters on the H2571. 3 SEND DATA EXPOUT Sends display data to the console type- writer. 4 RECEIVE DATA EXPINT Receives display data from the console typewriter. 5 CONVERT ASCII TPR Converts ASCII lowercase into uppercase. IDWERCASE IN'IO Refer to TPR in HD6301/HD6303 FAMILY UPPERCASE APPLICATION NOTES (SOFTWARE). ~HITACHI 1016 12.2.3 Program Module Process Flow (Main Program) The flowchart in figure 12-6 demonstrates the procedure for displaying key data received from the console typewriter on both the H257l and console typewriter, as performed by the program module in figure 12-5. EXPMN Main Program $18F--+SP --{ Initialize stack pointer. $04--+CRA --{ Select peripheral interface register A of PIA. $OO--+PIRA --{ Set signals RS, R/W, and E of LCD-II to Low. $OO--+CRA --{ Select DDRA of PIA. $FF--+DDRA --{ Select port A of PIA as output. $04--+CRA ---[ Select peripheral interface register A of PIA. $OO--+CRB --{ Select DDRB of PIA. $FF--+DDRB - -{ Select Port B of PIA as output. 04--+CRB -- { Select port B register of PIA. ---[ Initialize LCD-II. --{ Load display ON instruction into entry argument of EXPINS. x PBS Y --{ Check busy flag. x PIN S --{ Store instruction in LCD-II. Initialize transmit control bit of ACIA control 97--+CR --{ register to set RTS=Low, disable interrupts, and I master reset ACIA. --{ divide Initialize ACIA control register to set counter bit to 16, word select bit as 8 bit data +1 stop bit, and enable interrupts. --{ Clear key data receiving flag. --{ Initialize RAM/port 5 control register of the HD6301YO to define P50 to IRQl pins. --{ Enable interrupts. Figure 12-6. Program Module Flowchart ~HITACHI 1017 data is received from the console ---[ Load key data into entry argument of TPR. --{ Clear key data receiving flag. --{ Set signal RTS of ACIA to Low. Convert ASCII lowercase into uppercase. -- { Refer to TPR in HD6301/HD6303 FAMILY APPLICATION NOTES (SOFTWARE). --{ Load ASCII uppercase into entry argument of EXPOUT and EXPDSP. --{ Display characters on H2571. --{ Send display data to the console typewriter. IRQ Interrupt Routine --~ Receive data from the con'ole typewriter. Figure 12-6. Program Module Flowchart (Cont.) ~HITACHI 1018 12.3 PROGRAM MODULE DESCRIPTION Proqram Module Name: INITIALIZE MCU/MPU: HD6301YO/ Label: EXPINT ICD-II HD6303Y Function: Initializes LCD-II contained in the H2571 liquid crystal module. Arguments: Changes in CPU Specifications: None Re~isters and Flags: ACCD ROM (Bytes) : 37 ACCA ACCB x x RAM (Bytes) : 1 IX Stack' (Bytes) : 2 No. of cycles: 45637 • Reentrant: No C V Relocatable: No x x Interrupt OK?: Yes Z N x x I H • • • Not affected x : Undefined t Result Description: 1. Function Details a. EXPINT has no arguments. b. LCD-II is reset by instruction. Data in table 12-5 is sent to initialize display mode. I Specifications Notes: 1. "Specifications" includes those used by called subroutines. 2. "No. of cycles" in "Specifications" indicates the number of cycles required when EXPBSY is executed a minimum number of cycles. @HITACHI 1019 ~lL_a_b_e_l_: ~ Program Module Name: INITIALIZE LCD-II M_C_U_/_M_P_U_:__HD_6 __30_1_Y_0_/____ HD6303Y . __ EX_P_I_NT ______ L.. Description: Table 12-5. Initialize Data for Display Mode Data Function $30 Interface length: 8 bits Columns: 1 Display Font: 5 x 7 dots $08 Display OFF, Cursor OFF, Blink OFF $01 Clear display, set DDRAM address to $00 $06 Increment DDRAM address, No display shift c. EXPINT calls other subroutines as shown in table 12-6. Table 12-6. Subroutines Called by EXPINT Subroutine Name Label Function STORE INSTRUCTION EXPINS Store instruction in LCD-II. CHECK BUSY FLAG EXPBSY Check LCD-II busy flag. 2. User Notes a. The following procedure is required before EXPINT execution. i. Initialize control signals (signals RS, R/W, E) of LCD-II. ii. Select ports A and B as output. iii. Initialize control register of PIA to select peripheral interface registers A and B. b. Instruction data shown in Table 12-5 must be reserved as data table. 3. RAM Allocation Label RAM Description b7 bO INSDAT } Instruction data ~HITACHI 1020 Program Module Name: INITIALIZE LCD-II MCU/MPU: HD6301YO/ HD6303Y ILabel, EXPINT Description: 4. Sample Application I I I LDAA #$04 STAA CRA } Select peripheral interface register A of PIA. LDAA #$02 STAA PIPA } Initialize LCD-II control signal. CLR A STAA CRA } Select data direction register A of PIA. LDAA #$FF STAA DDRA } Select port A of PIA as output. LDAA #$04 Select peripheral interface register A of STAA CRA } PIA. CLR A STAA CRB } Select data direction register B of PIA. LDAA #$FF STAA DDRB } Select port B of PIA as output. LDAA #$04 STAA CRB } Select peripheral register B of PIA. II JSR EXPINT II ----- Execute EXPINT to initialize LCD-II. DMODE FCB $30,$08,$01,$06 ----- Reserve data table 5. Basic Operation a. If peripheral control pin is not used, read/write operation of PIA is executed as described below. The procedure for initializing port A and read operation is as follows. [ Clear bit 2 of port A control register to select data direction register. _____[~elect port A data direction register as ~-----r----~ ~nput. _____[Set bit 2 of port A control register to select ~-----r----~ peripheral interface register A. _____ [Load peripheral interface register A and input ~-----T----~ from port A. Figure 12-7. Read Operation ~HITACHI 1021 Program Module Name: INITIALIZE MCU/MPU: HD630lYO/ Label: EXPINT LCD-II HD6303Y - -- Description: The procedure for initializing port A and write operation is as follows: [ Clear bit 2 of port A control register to select port A data direction register. _____ [Select port A data direction register as output. _____[set bit 2 of port A control register to select peripheral interface register A. _____[store peripheral interface register A and output port A. Figure 12-8. Write Operation b. LCD-II is software reset by the following procedure: Reset LCD-II Wai t for ISms just after power on Figure 12-9. Reset LCD-II ~HITACHI 1022 Program Module Name: INITIALIZE LCD-II MCU/MPU: HD630lYO/ HD6303Y I Label , EXPINT Description: c. Software controls the LCD-II control signal using port A of PIA, and the data bus using port B. d. Programming notes i. Both a lSms wait by software timer and transfer of $30 to the data bus three times is needed reset LCD-II. ii. Index register is used both as a pointer to the instruction data table and as a counter of the number of data transfers. iii. LCD-II busy flag is checked before outputting instruction data. iv. After process (iii) is executed four times, display mode is initialized. ~HITACHI 1023 I~ Program Module Name: INITIALIZE MCU/MPU: HD630lYO/ EXPINT LCD-II HD6303Y Flowchart: L _ _-.-_ _---.J - - - { Initialize counter for three loops. Execute ISms software timer. --{ Load instruction of function set into entry argument of EXPINS. --{ Write instruction to LCD-II. ~----..l ---[ Decrement loop counter. --{ Test if LCD-II reset is complete. --{ Load starting address of data table where display mode data is stored. --{ Load display mode instruction into entry argument of EXPINS. Check busy flag. 1..L..--....,-----l.I - - - ( Write instruction to LCD-II. 1..L..--....,-----l.I - - { --{ Increment pointer to data table of display mode. ---{ Test if all display mode data has been written. ~HITACHI 1024 Program Module Name: RECEIVE DATA MCU/MPU: HD6301YO/ ~ EXPINP HD6303Y Function: Receives key data from the console typewriter and stores it in RAM. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes) : 26 ACCA ACCB Entry -- x I • RAM (Bytes) : 2 Stack (Bytes) : 0 IX • No • of cycles: 43 Reentrant: No C V Relocatable: No x x Interrupt OK?: Yes Re- Received KEYDAT 1 Z N turj'lS data (RAM) x x (ASCII) Received KEYDRF 1 I H flag (RAM) • • • Not x affected Undefined : Result Description: Press "a" 1. Function Details CD Entry { C' a ' = $ 6 1) a. Argument details KEYDAT(RAM): Holds key data from I KEYDAT the console typewriter b7 bO in ASCII. KEYDRF(RAM): Key data receive Flag. KEYDATCRAM) C ' a '=$ 61) I 6 : 1 I Table 12-7 shows flag { Result b7 KEYDRF bO functions. KEY~~;CRAM) I 0 : 1 I Figure 12-10. Example of EXPINP Execution Specifications Notes: ~HITACHI 1025 Program Module Name: RECEIVE DATA MCU/MPU: HD6301YO/ HD6303Y I Label , EXPINP Description: b. Example of EXPINP execution is shown in figure 12-10. If "a" is depressed in console typewriter as shown in partQ) of figure 12-10, key data is stored in KEYDAT(RAM) and $01 is set in KEYDRF(RAM). Table 12-7. Flag Functions Label bit 0 Function KEYDRF o Indicates key data is not received. 1 Indicates key data is received. c. EXPINP calls neither the program modules nor subroutines. 2~ User Notes The following procedure must be executed before EXPINP execution. a. Initialize ACIA since ACIA must interface with peripheral device (receives data from the console typewriter). b. Initialize RAM/port 5 control register since IRQl pin is used. c. Clear bit I to enable interrupts since IRQl interrupt is used. 3. RAM Allocation Label RAM Description b7 bO KEYDAT KEYDRF 1----11 t Key data Used as a flag indicating whether or not key data is received. 4. Sample Application LDAA STAA #$97 CR } Master-reset ACIA. LDAA STAA #$95 CR } Initialize control register of ACIA. BCLR O,KEYDRF Initialize received flag. LDAA #$7D STAA RP5CR } Initialize RAM/port 5 control register. CLI Enable interrupts ~HITACHI 1026 Program Module Name: RECEIVE DATA MCU/MPU: HD6301YO/ Label: EXPINP HD6303Y Description: 5. Basic Operation a. Example of initializing ACIA is shown in figure 12-11. Note: For master-reset, "11" is stored in bits 0 and 1 of control register. Bits 5 and 6 must be defined to obtain specified RTS output. Master-reset ACIA. [ ----- (RTS=Low and disable sending interrupts). Initialize control register of ACIA. _____ [ (Selecting counter devide select bit"'" 16, start bit +8 bits data +1 stop bit, and enable receiver interrupts. ) Figure 12-11. Example of Initializing ACIA b. Programming notes i. Received data is checked for any errors. ii. If an error has ocurred, received data is ignored. iii. If an error has not ocurred, received data is stored in KEYDAT(RAM) and received flag is set. iv. Receive data register of ACIA is read and interrupts are enabled. I ~HITACHI 1027 _p_r_o_g_r_a_m_M_o_d_u_l_e_N_am_e_:_R_E_C_E_I_VE __D_Pi_T_A_--, L.M_C_U_I_M_P_U_: HD6303Y _HD_6_3_0_l_Y_O_I_ _- I .lL_a_b_e_l_:_E_X_P_I_NP _ _ _....J L. Flowchart: Test if framing error or receiver [ overrun error has occurred. - - { Set signal RTS of ACIA to High. ___ [ Clear receive data register full bit. __ { Store data from the console typewriter. - - { Set received flag. EXPIPI ___[ Clear receiver overrun bit and receive data register full bit. EXPIP2 _ _. 1 . . - -..... ~HITACHI 1028 Program Module Name: DISPLAY MCU/MPU: HD6301YO/ Label: EXPDSP CHARACTERS HD6303Y Function: Stores ASCII in display RAM(DDRAM) and displays characters on the LCD. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ACCA ACCB ROM (Bytes): 78 Entry Display DSPDAT 1 x x RAM (Bytes): 1 data (RAM) stack (Bytes): 2 IX • No. of cycles: 106 Reentrant: No C v Relocatable: No x x Interrupt OK?: Yes Re- --- --- - Z N turns x x I H • • • Not affected x : Undefined Resul t Description: 1. Function Details a. Argument details DSPDAT(RAM): Holds display data in 1 byte ASCII. b. Example of EXPDSP execution is shown in figure 12-12. If entry argument is as shown in part CD of figure 12-12, a character is displayed on the LCD as shown in Figure 12-12. Example of EXPDSP part@of figure 12-12. Execution Specifications Notes: L, Values in "Specifications" include those used by subroutines called by EXPDSP. 2. "No. of cycles" in "Specifications" indicates the number of cycles required when EXPBSY is executed the minimum number of cycles. @HITACHI 1029 Program Module Name: DISPLAY MCU/MPU: HD6301YO/ Label: EXPDSP --- CHARACTERS HD6303Y Description: c. EXPDSP calls an other subroutine as shown in table 12-8. Table 12-8. Subroutine Called by EXPDSP Subroutine Name Label Function CHECK BUSY FLAG EXPBSY Checks LCD-II busy flag. 2. User Notes The following procedure must be executed before EXPDSP execution. a. Initialize PIA since PIA must interface with peripheral devices (LCD-II is controlled by ports of PIA). b. Initialize LCD-II by executing EXPINT. 3. RAM Allocation Label RAM Description b7 bO DSPDAT } Display data in ASCII 4. Sample Application I I I LDAA STAA #$04 CRA } Select peripheral interface register A of PIA. LDAA #$02 STAA PlRA } Initialize LCD-II control singal. CLR A STAA CRA } Select data direction register A of PIA. LDAA #$FF STAA DDRA } Select port A of PIA as output. LDAA #$04 STAA CRA } Select peripheral interface register A of PIA. CLR A STAA CRB } Select data direction register B of PIA. LDAA STAA #$FF DDRB } Select port B of PIA as output. LDAA #$04 STAA CRB } Sele.ct peripheral interface register B of PIA. BSR EXPINT Execute EXPINT to initialize LCD-II. LDA #$41 STA DSPDAT } Load entry argument of EXPDSP. II JSR EXPDSP II ----- Execute EXPDSP. ~HITACHI 1030 Program Module Name: DISPLAY CHARACTERS M_C_U_/_M_P_U_:__HD .... __6_30_l_Y_O_/____ HD6303Y .. ~I . L_a_b_e_l_:__ EX_P_D_S_P____ ~ Description: 5. Basic Operation a. LCD-II busy flag is checked by EXPBSY execution. b. Control signal of LCD-II is controlled by port A of PIA and display data is output from port B. ~HITACHI 1031 Program Module Name: DISPLAY CHARAcrERS MCU/MPU: HD630lYO/ HD6303Y I~ EXPDSP Flowchart: - - { Execute EXPBSY to check busy flag. __ {set signal RS to High, signal R/W to Low. - - { Set signal E to High. __ {write display data to port B and display characters on LCD. - - { Set signal E to Low. __ {set signal RS to Low, signal R/W to High, and signal E to Low. ~HITACHI 1032 Program Module Name: SEND DATA MCU/MPU:HD6301YO/ Label: EXPOUT HD6303Y Function: Sends data to the console typewriter. Arguments: Changes in CPU Speci fica tions: Storage No. of Registers and Flags: Contents Location Bytes ACCD ACCA ACCB ROM (Bytes): 13 Entry Sending OUTDAT 1 x RAM (Bytes): 1 data (RAM) Stack (Bytes): 0 IX No. of cycles: 21 Reentrant: No C v Relocatable: No o x Interrupt OK?: Yes Re- z N turns x x I H o I) Q Not affected x : Undefined Result Description: 1. Function Details b7 OUTDAT bO En try { OUI'DA~(RA'v!) I 4 : 1 I a. Argument details argument Sendlng data tI I OUTDAT(RAM): Holds data to be sent (' A' $41) to the console type- Type A writer in ASCII. r-- b. Example of EXPOUT execution is @ Result 0: ~! ~----_._- ~IJ shown in figure 12-13. If entry 01 Q. argument is as shown in part Q) of figure 12-13, a character is printed as shown in part@of Figure 12-13. Example of EXPOUT fiqure 12-13. Execution Specifications Notes: "No. of cycles" in "Specifications" indicates the number of cycles required when the transmit data register is empty. ~HITACHI 1033 Program Module Name: SEND DATA M_C_U_/_M_P_U_:__HD I- __6_3_0_1_Y_O/____ HD6303Y ~lL_a_b_e_l_: ~ . _____O_UT ______ ~ Description: c. EXPOUT calls neither the program modules nor subroutines. 2• User Notes a. The following procedure must be executed before EXPOUT execution. i. Initialize ACIA since ACIA must interface with peripheral devices (data is sent to the console typewriter). b. If data has been previously stored in the transmit data register, EXPOUT waits until it is empty so as not to destroy this data. 3. RAM Allocation Label RAM Description b7 bO Character data to be sent to the console OUTDAT typewri ter. 4. Sample Application LDAA STAA #$97 CR }----- Master-reset ACIA. IDAA STAA #$95 CR }----- Initialize control register of ACIA. LDAA #$41 STAA OUTDAT } Load output data into entry argument. II JSR EXPOUT II ----- Execute EXPOUT. 5. Basic Operation a. Transmit data register empty flag of ACIA is tested for 1 or O. If it is "1", load output data into the transmit data register of ACIA. b. Instruction BTST of the HD6301YO is replaced by instruction ANDA since instruction BTST cannot be used in extended addressing. ~HITACHI 1034 Program Module Name: SEND DATA MCU!MPU: HD630lYO/ HD6303Y I~ EXPOUT Flowchart: EXPOUT __ {Test if transmit data register is empty. Write output data to the transmit -- { data register of ACIA and send it to the console typewriter. I ~HITACHI 1035 12 4 SUBROUTINE DESCRIPTION Subroutine Name: STORE INSTRUCTION MCULMPU: HD6301YO/ Label: EXPINS HD6303Y Function: Stores instruction data in LCD-II instruction register. Basic Operation: Signals RS, R/W, and E are controlled by port A of PIA, and instruction data is output from port B. Program Module Using This Subroutine: EXPINT Flowchart: - - { Set signal R/W to Low. - - { Set signal E to High. ---[ Output instruction data to port B. - - { Set signal E to Low. __ { Set signal RS to Low I signal R/W to High, and signal E to Low. ~HITACHI 1036 Subroutine Name: CHECK BUSY FLAG MCU(MPU: HD6301YOj Labe 1: EXPBSY HD6303Y Function: Checks whether or not LCD-II is in operation and waits until i t is ready. Basic Operation: 1. If LCD-II is in operation, the HD6301YO cannot access if the LCD-II busy flag indicates whether or not it is in operation. 2. Signals RS, RjW, and E are controlled by port A of PIA, and the busy flag is read by port B. Program Module Using This Subroutine: EXPINT, EXPDSP Flowchart: --{ Select data direction register of port B. --{ Select port B as input to read busy flag. --{ port·B. Select peripheral interface register of --{ Set signal E to High. --{ Read LCD-II busy flag. --{ Set signal RS to Low, signal R/W to High, and signal E to Low. (Bit r-_ _-'---'-_..,C)?' 1 LOOp until busy flag=O. --{ Select data direction register of port B. I --{ Select port B as output. --{ Select peripheral interface register of port B. ~HITACHI 1037 12.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCf~TION ~********~;I:'I~*******~:~:**** 00003 * 00004A 0040 ORG $40 00005 * 00006A 0040 0001 A I(EYDRF RMB Existence of r'eceive data 00007 * 00008A 8000 ORG $8000 00009A 8000 0001 A INSDAT RMB 1 Instruction data 00010A 8001 0001 A OUTDAT RMB 1 Data to be sent OOOllA 8002 0001 A DSPDAT RMB 1 Display data 00012A 8003 0001 A I(EYDAT RMB 1 Receive data 00013 * 00014 **** SYMBOL DEFINITIONS ********************** 00015 * 00016 0014 A RP5CR EQU $14 Por't 5 control register 00017 AOOO A DDRA EQU lAOOO Data dir'ection register A(PIA) 00018 AOOl A CRA EQU $AOOI Control register' A(PIA) 00019 A002 A DDRB EQU $A002 Data direction register' B(PIA) 00020 A003 A CRB EQU $A003 Contr'ol register B(PIA) 00021 AOOO A PIRA EQU $AOOO Per' i pher'al r'egister' A(PIA) 00022 A002 A PIRB EQU $A002 Pe r' i pller'a l reg i ster' B(PIA) 00023 COOO A CR EQU $COOO Contr'ol register'(ACIA) 00024 COOO A SR EQU $COOO Status r'eg i ster'(ACIA) 00025 COOl A RDR EQU $COOI Receive data r'eg i ster(ACIA) 00026 COOl A TDR EQU $C001 Tr'ansmit data r'eg i ster'(ACIA) 00027 ******************************************f.***** 00028 * >I< 00029 * MAIN PROGRAM : EXPMN >I< 00030 * >I< 00031 **************************~:****************~,**** 00032 * 00033A COOO ORG $COOO 00034 * 00035A COOO 8E 013F A EXPMN LDS FI$13F Initialize stack pointer 00036A C003 86 04 A LDAA FI$04 Select peripheral register' A 00037A COOS 87 AOOI A STAA CRA 00038A C008 4F CLRA Set RS=O.R/W=O.E=O 00039A C009 87 AOOO A STAA PIRA 00040A COOC B7 AOOI A STAA CRA 00041A COOF 86 FF A LDAA FI$FF Select port A as output 00042A COlI 87 AOOO A STAA DDRA 00043A C014 86 04 A LDAA FI$04 Select per' i pheral register A 00044A C016 87 AOOI A STAA CRA 00045A C019 4F CLRA Select data direction register 8 00046A COlA B7 A003 A STAA CRB 00047A COlD 86 FF A LDAA FI$FF Select port B as output 00048A COIF 87 A002 A STAA DDRB 00049A C022 86 04 A LDAA FI$04 Select peripher'al register B 00050A C024 B7 A003 A STAA CRB 00051A C027 BD COAE A JSR EXPINT Initialize LCD-II 00052A C02A 86 OE A LDAA FI$OE 00053A C02C B7 8000 A STAA INSDAT Store LCD display data 00054A C02F 8D 52 C083 BSR EXPBSY Checl< busy flag 00055A C031 BD COD3 A JSR EXPINS Store instruction 00056A C034 86 97 A LDAA FI$97 Master-reset ACIA 00057A C036 B7 COOO A STAA CR .HITACHI 1038 00058A C039 86 95 A LDAA 11$95 Initial.ize ACIA 00059A C03B B7 COCO A STAA CR 00060A C03E 71 FE 40 BCLR O.I1" 00132 * * ****)k)K*'~*:I(~:*lklk*)k**I~***:~*:k**:k**:k*~*************~(* 00133A COAE C6 03 A EXPINT LOAB 111,03 InitiaL ize counter 00134A CaBO CE OEA6 A EXPIT 1 LOX 113750 E>:ecute softwaer' timer' 00135A COB3 09 EXPIT2 OEX 00136A COB4 26 FO COB3 BNE EXPIT2 00137A COB6 86 30 A LOAA tl1;30 Store function data 00138A COB8 B7 8000 A STAA HJSDIH 00139A COBB 80 16 COD3 BSR EXF'INS Wr' i te i nstr'act i on to LCD-II 00140A COBO SA DECB Decr'ement counter' 00141A COBE 26 FO COBO BNi=: ExrIll Loop untiL TNCNT=O 00142A COCO CE C120 A LOX HDMLlDE Load stat'tins ADOR of dispLay mode data tabL 00143A COC3 A6 00 A EXPIT3 LO(-V~ O.X Store i n~;tt'uct i on data 00144A COC5 B7 8000 A SH\I, INSDAT 00145A COC8 80 B9 C083 BSFl EXPBSY Checi< busy flas 00146A COCA 80 07 C003 BSr, EXF'lN:, Stor'e instr'uction 00147A COCC 09 DEX Decrirnent po inter' 00148A 'COCD 8e C124 ~\ CPX flDMODE+4 Loop until. IX=IWMOOE+4 00149A COOO 26 Fl COC3 BN[, EXPIT3 00150A COD2 39 RTS 00151 **********)k****:k:k*~(*****~(*********************** 00152 * " 00153 NAME : EXPINS (STORE INSTRUCTION) 00154 " " 00155 "~(**+*********~(****~;lk**~~I~*~:**********~(**~:***** **** 00156A COD3 4F EXPINS CLRA Set R/W=O 00157A COD4 B7 AOOO A STAA PIRA 00158A C007 86 01 A LDAA fI$Ol Set E=l 00159A COD9 B7 AOOO A STAA PIRA 00160A CODC B6 8000 A LDAA INSDAT Store instruction 00161A CODF B7 A002 A STAA PIRB 00162A COE2 4F CLRA Set E=O 00163A COE3 B7 AOOO A STAA PIRA 00164A COE6 86 02 A LDAA 11$02 Set RS=O.R/W=l.E=O 00165A COE8 B7 AOOO A STAA PIRA 00166A COEB 39 RTS 00167 ************~(*********************************** 00168 >I< >I< 00169 * NAME : EXPOUT (SEND DATA) * 00170 >I< " 00171 ****************~******************************* @HITACHI 1040 00172 >I< A, 00173 * ENTRY: OUTonT (DATA Tn BE SEN1) 00174 * RETURNS: NoTIlING >I< 00175 * * 00176 ***********>V*****:I'***'I:'j":""W'1 I' j"'I':I"I'*'I'***"'**'I"I'**)I:**~' 00177A COEC 86 02 A EXPoUT LDAA H$02 Te3t If TORE-I 00178A COEE B4 COOO A ANOA SR 00179A COFI 27 F9 COEC BEQ EXPOUT Loop untiL TDRE=O 00180A COF3 B6 8001 A LOAA oUTDAT Store send data 00181A COF6 B7 COOl A STAA TOR 00182A COF9 39 RTS 00183 ***~***.'*~*****>V************.****************** 00184 * * 00185 * NAME: TPR (CONVERT ASCII LOWERCASE >I< 00186 * INTO UPPERCASE) * 00187 * * 00188 **********************>1<************************* 00189 0;: * 00190 * ENTRY : ACCA (ASCII LOWERCASE) * 00191 * RETURNS: ACCA (ASCII UPPERCASE) * 00192 * * 00193 ************************************************ 00194A COFA 81 61 A TPR CMPA a'a ACCA - 'a' ? 00195A COFC 25 06 C104 BCS TPR1 Branch if ACCA < 'a' 00196A COFE 81 7A A CMPA "'z ACCA - 'z' ? 00197A C100 22 02 C104 BHI TPR1 Branch if ACCA > 'z' 00198A C102 84 OF A ANDA "$DF Convert Lowercase into uppercase 00199A C104 39 TPR1 RTS 00200 ************************************************ 00201 * * 00202 * NAME : EXPINP (RECEIVE OATh) * 00203 * * 00204 ************************************************ 00205 * * 00206 * ENTRY NOTHING * 00207 * RETURNS: KEYDAT (RECEIVED DATA) * 00208 *. II< DATA TABLE * 00225 * '" "'*********************************************** I 00226 00227A C120 30 A DMoDE FCB $30.$08.$01.$06 00228 ************************************************ ~HITACHI 1041 00229 * * 00230 * VECTOR ADDRESSES * 00231 * * 00232 ************************************************ 00233 * 00234A FFEA ORG $FFEA 00235 * 00236A FFEA COOO A FDB EXPMN IRQ2 00237A FFEC COOO A FDB EXPMN CMI 00238A FFEE COOO A FDB EXPMN TRAP 00239A FFFO COOO A FDB EXPMN SID 00240A FFF2 COOO A FDB EXPMN TOI 00241A FFF4 COOO A FDB EXPMN OCI 00242A FFF6 COOO A FDB EXPMN ICI 00243A FFF8 Cl05 A FDB EXPINP IRQ1/ISF 00244A FFFA COOO A FDB EXPMN SWI 00245A FFFC COOO A FDB EXPMN NMI 00246A FFFE COOO A FDB EXPMN RES 00247 * 00248 END ~HITACHI 1042 SECTION 13. SLOW DEVICE INTERFACE 13.1 HARDWARE DESCRIPTION 13.1.1 Function Compares a check sum, obtained from a data block in external memory, with a check sum stored beforehand in the data block and indicates whether or not they are the same using an LED. 13.1.2 Microcomputer Operation The HD63B01YO accesses slow devices using the auto-memory-ready function. Signal cSl of the slow devices is input directly to the memory-ready pin by setting both the enable bit of memory-ready and the enable bit of auto-memory-ready to "1". 13.1.3 Peripheral Devices HN482764G-3 EPROM: Used as an external memory. Its maximum access time is 300ms. 13.1.4 Circuit Diagram Memory-ready circuit is shown in figure 13-1. I ~HITACHI 1043 MCU +5V HD68BOIYO MP, EPROM +5V HN482764G-8 8 NMI Do 57 7 D, 56 8TBY D. 55 88 D. 54 22pF Vee D. 58 XTAL D. 52 [WhO 22pF EXTAL Do 51 D. A., 50 A 49 +5V '408 A. 47 O. ~! 0, A. 46 o. 182076 At 45 O. 47kO A. 44 6 O. RE8 A., 48 0, A. 41 O. y'~ A. A. O. 89 A,. 88 All 87 A,. 86 A,. 85 VBS A,. 84 4 20 MP. A" CE 42 VBS 19 P.,/MR 14 22 GND +5V RI> 68 OE WR 62 RAM HM6264LP-I0 Uk0 25 p •• A., I/O, A, I/O. A. I/O. A. I/O. 15 16 At I/O, A, I/O. 11 18 A., I/O. 19 A. I/O. A. +5V 21 A. A,. 28 28 All Vee 2 26 An C8. 20 C8, 22 OE 27 14 E GND Figure 13-1. Memory-ready Circuit ~HITACHI 1044 13.1.5 Pin Fqnctions Pin functions for control of LED connection pins and slow device pins are shown in table 13-1. Table 13-1- Pin Functions Pin Name Input! Active Level Program (HD63B01YO) Output (High or Low) Function Label P60 Output Low Turns on LED. P6DTR PS2!MR Input Low Memory-ready pin. 13.1.6 Memory Map Address decoding for this application example is shown in table 13-2. A slow memory device, the HN482764G-3, is allocated as external memory by the HD74HC138 address decoder. Address buses A13 , A14 and A15 are connected to A, Band C pins, respectively, of the HD74HC138. Address space $8000'" $FFFF is divided into 8k-byte sections. Table 13-2. Address Decoding HD74HC138 Address Allocation Input Output C B A Gl G2A G2B Yo Yl Y2 Y3 Y4 Ys Y6 Y7 A1S A14 A13 H L L H L L H H H H L H H H 8000'" 9FFF EPROM H L L H L H H H H H H L H H AOOO"'BFFF Not Used H L L H H L H H H H H H L H COOO"'DFFF Internal ROM H L L H H H H H H H H H H L EOOO'" FFFF Internal ROM I $ HITACHI 1045 Memory map for this application example is shown in figure 13-2. Internal Registers Not Used Internal RAM (256 bytes) Not Used EPROM HN482764G-3 Not Used Internal ROM (16k-bytes) Figure 13-2. Memory Map 13.1.7 Hardware Operation Timing chart for the HD63B01YO and slow device HN482764G-3 is shown in figure 13-3. E Address Bus )(_ _---1X'-__...JX EPROM address MR (CS signal of slow device) \ Data Bus Figure 13-3. Memory-Ready Bus Timing ~HITACHI 1046 13.2 SOFTWARE DESCRIPTION 13.2.1 Program Module Configuration The program module configuration for determing check sum is shown in figure 13-4. MRMN MAIN ~ PROGRAM MRCHK I l2. CHECK SUM Figure 13-4. Program Module Configuration 13.2.2 Program Module Functions Program module functions are summarized in table 13-3. Table 13-3. Program Module Functions No. Program Module Name Label Function o MAIN PROGRAM MRMN Displays result of comparing check sums. 1 CHECK SUM MRCHK Obtains check sum of data block in external memory. ~HITACHI 1047 13.2.3 Program Module Process Flow (Main Program) The flowchart in figure 13-5 shows the procedure for testing check sums as performed by the program module in figure 13-4. Main Program - - - { Ini tialize stack pointer. ___ {select port 4 as output for upper address output. ----(Initialize RAM/port 5 control register. ___ {Load the starting address of external ROM into entry argument (IX) of MRCHK. ---{Execute MRCHK to obtain check sum. (Bit e) = 1 Test whether or not check sum obtained - - --[ in this program and check sum stored beforehand are the same. Bit ell ___ { If these two check sums are the same, turn on LED. LED ---{If not the same, make LED blink on and off. Figure 13-5. Program Module Flowchart @HITACHI 1048 13.3 PROGRAM MODULE DESCRIPTION Program Module Name: CHECK SUM MCU/MPU: HD630lYO/ Label: MRCHK HD6303Y Function: Obtains check sum of data block and compares check sum obtained with check sum stored beforehand. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes) : 23 ACCA ACCB Data table IX 2 Entry starting x x RAM (Bytes) : 2 address Stack (Bytes) : 0 IX x No. of cycles: 137 Reentrant: No C V Relocatable: No ~ x Interrupt OK?: Yes Re- Check sum bit C 1 bit Z N turns result (CCR) indicator x x I H • x • Not Affected x : Undefined Result Description: 1. Function Details a. Argument details IX: Holds the starting address of data table: bit C(CCR): Used as a flag indicating whether or not contents of external memory are correct, determined by check sum result. Table 13-4 shows flag functions. b. Example of MRCHK execution is shown in figure 13-6. If entry argument is as shown in part Q) of figure 13-6, bit C is set to "I" as shown in part @ of figure 13-6 when the two check sums are the same. Specifications Notes: "No. of cycles" in "Specifications" indicates the number of cycles required to obtain a check sum for 9 bytes. @HITACHI 1049 _p_r_o_g_r_am __M_o_d_u_l_e_N_a_m_e_:_C_H_E_C_K_S_UM _IID_6_3_0_1_Y_0_I_ _---I .lL_a_b_e_l_:_MR_C_H_K_ _ _--I _ _ _ _....J L.M_C_U_/M_P_U_: HD6303Y L. Description: Table 13-4 Flag Functions Register bit C Function CCR 0 Indicates contents of external memory is not correct. 1 Indicates contents of external memory is correct. blS IX bO Q;) Entry argument {~~8000) I 8 : 0 I 0 : 0 I Data Block b7 $8000 $80 Address of $06 check sum $11 $12 Data for which check sum is $13 to be computer $14 $8006 $4A Check sum l Bit C @ Return { Bit C IT] argument (CCR) Figure 13-6. Example of MRCHK Execution c. MRCHK calls neither the program modules nor subroutines. ~HITACHI 1050 Program Module Name: CHECK SUM L-M_C_U_/_M_P_U_: _ __HD __6_3_0_1_Y_O_/____ HD6303Y ~ ILL_a_b_e_1_: _ __MR __C_HK ______ ~ Description: 2. User Notes a. Initialize RAM/port 5 control register since the auto-memory-ready function is used. b. To check the contents of external memory, data, shown in figure 13-7, must be stored in memory. External ROM b7 bO Starting address _ $ 8 0 0 0 f 3 9 8 0 } Address in which LSD of of external $OC check sum is stored. memory, allocated by users. Data $800C [ r Check sum of data above. Figure 13-7. External ROM 3. RAM Allocation Label RAM Description b7 bO CHEND Address in which correct check sum is stored. ~HITACHI 1051 ~lL_a_b_e_l_: ~ Program Module Name: CHECK SUM M_C_U_/_M_P_U_:_HD __ 6_3_0_l_Y_0_/____ HD6303Y _ __ MR_C_HK ________ L- Description: 4. Sample Application LDAA #$F4 STAA RP5CR } Initialize RAM/port 5 control register. LDX #8000 Load starting address of external memory into entry argument of MRCHK. II BSR MRCHK II Call MRCHK. Test whether or not contents of memory BCC ERROR is correct. II SERVICE ROUTINEII Execute service routine if contents of memory are correct. ERROR II ERROR PROGRAM 1/ Execute error program if contents of memory are incorrect. 5. Basic Operation a. IX is used as a pointer to data table. b. Sum of data is obtained by adding to ACCA. c. Data in data table is added to ACCA in sequence using index addressing mode. Carry generation is ignored. d. If contents of IX equals the address following the last byte of data, addition is terminated. e. LSD of addition result is compared with check sum stored beforehead. f. If these two strings of data are the same, bit C is set. If not the same, bit C is cleared and MRCHK execution is terminated. ~HITACHI 1052 _p_r_o_g_r_a_m__M_o_d_U_l_e__N_am l... __e__ :_C_HE __C__ K__S_UM ______ ~ LM __C_U_/M __P_U_:__HD6303Y HD __6_3_0_l_Y_O_/____ ~ lL_a_b_e . __l_:__ MR__ C_HK ________ ~ Flowchart: MRCHK (( IX»)---( CHEND __ {store address in which check sum :CHEND+l) is stored in data table. --{ Clear register for addition. _ _ { Load starting address of data table into data table pointer. (ACCA)+{IX) ---ACCA - - { Add data to ACCA. ---[Increment data table pointer. --{Test if addition of data is completed. __ { Compare LSD of addition result with check sum stored beforehand. (ACCA) = ((IX) _ _ { If these two strings of data are not the same, clear bit C. _ _ { If these two strings of data are the l+Bit C same, set bit C. MRCHK3 ~HITACHI 1053 13.4 SUBROUTINE DESCRIPTION Subroutine Name: DISPLAY LED MCULMPU: HD630lYO/ HD6303Y Function: Turns LED on and off, and executes software timer for 0.5s intervals (blinking LED) Basic Operation: 1. output condition of P60 is tested. If Low, output IHigh to turn off LED. If High, output Low to turn on LED. 2. Software timer for· 0.5s intervals is executed. I Program Module Using This Subroutine: Flowchart.: ---{ Test bit 0 of port 6. r----~~"""'Io.(+o MRLEDI ..._ _ ......,~ _ _...J - - - { Output Low to turn on LED. r--$-F-~--PL..6-D-TR-""'" ---{ Output High to turn off LED. Execute software timer for 0.5s intervals. ~HITACHI 1054 13.5 PROGRAM LISTING 00001 ************* RAM ALLOCATION ****************** 00002 00003 * 00004A 0040 ORG $40 00005 * 00006A 0040 0002 A CHEND RMS 2 Address of check sum 00007 * OOOOS ************ SMYBOL DEFINITIONS ************** 00009 * 00010 0006 A P3DTR EQU $06 Port 3 data register 00011 OOOS A P4DDR EQU $OS Port 4 data direction register 00012 0014 A RPSCR EQU $14 RAM/portS controL register 00013 0017 A P6DTR EQU $17 Port 6 data register 00014 0016 A P6DDR EQU $16 Port 6 data direction register 00015 * 00016 ************************************************ 00017 * * 0001S * MAIN PROGRAM : MRMN * 00019 ************************************************** 00020 00021 * 00022A COOO ORG $COOO 00023 * 00024A COOO SE 013F A MRMN LDS 1I$13F InitiaLize stack pointer 00025A C003 S6 FF A LDAA II$FF InitiaLize port4 DDR 00026A COOS 97 OS A STAA P4DDR 00027A C007 S6 F4 A LDAA II$F4 InitiaLize RAM/portS controL REG 0002SA C009 97 14 A STAA RPSCR 00029A COOB S6 01 A LDAA 1101 InitiaLize port6 00030A COOD 97 17 A STAA P6DTR 00031A COOF 97 16 (-\ STAA P6DDR 00032A COlI CE SOOO A LDX II$SOOO Load strating ADDR of data tabLe 00033A C014 SO OA C020 SSR MRCHI( Execute MRCHI< 00034A C016 25 04 C01C SCS MRMN2 Branch if bit C = 1 0003SA COlS SO lD C037 MRMN1 BSR MRLED Execute LED 00036A COlA 20 FC C01S BRA MRMNI Branch MRMN1 00037A C01C SO 19 C037 MRMN2 BSR MRLED Execute LED 0003SA COlE 20 FE COlE PEND BRA PEND End of program 00039 * 00040 ************************************************ 00041 * * 00042 NAME : CHECK SUM (MRCHK) * 00043 * 00044 ************************************************* * 00045 * 00046 * ENTRY: IX (DATA TABLE STARTING ADDR) ** 00047 * RETURNS: BIT C (C=l:TRUE.C=O:FALSE) * 0004S * * 00049 ************************************************ OOOSOA C020 EC 00 A MRCHK LDD O.X store correct check sum data ADDR OOOSlA C022 DD 40 A STD CHEND 000S2A C024 4F CLRA CLear register for addition 000S3A C02S OS INX Load data tabLe starting address 000S4A C026 OS INX OOOSSA C027 AS 00 A MRCHII< * NAME : MRLED (DISPLAY LED) *>I< 00069 00070 *~(*********~:***************************************** ****>I~ 00071A C037 7B 01 17 MRLED BTST 0.P6DTR Test if LED on or off 00072A C03A 27 05 C041 BEQ MRLED1 Branch if on 00073A C03C 4F CLRA Load data to turn on LED 00074A C03D 97 17 A STM P60TR 00075A C03F 20 04 C045 BRI-) MRLE02 Branch to LED2 00076A C041 86 01 A MRLED1 LDAA ~SOl Load data to turn off LED 00077A C043 97 17 A STAA P6DTR 00078A C045 CE 03E8 A MRLE02 LOX "1000 Execute software timer for 0.55 00079A C048 86 FA A MRLED3 LOAA H2S0 00080A C04A 4A MRLE04 DECA 00081A C04B 26 FD C04A BNE MRLED4 00082A C04D 09 OEX 00083A C04E 26 F8 C048 BNE MRLED3 00084A COSO 39 RTS 00085 >I< 00086 00087 00088 * VECTOR ADDRESSES * 00089 * ~, * 00090 '" 00091 * 00092A FFEA ORG $FFEI~ 00093 >I< 00094A FFEA COOO A FOB ~mMN m02 00095A FF'EC COOO A FDB Mfll1N eMI 00096A FFH. COOO ~) FOB ~IR'1N TRAP 00097A FFFO COOO A FO[, MRI~N SID 00098A FFF2 COOO A FOB MRMN TOI 00099A FFF4 COOO A FOB MRMN OCI 00100A FFF6 COOO A FOB MRMN ICI 00101A FFF8 COOO A FDB MRMN IROlliSF 00102A FFFA COOO A FDB MRMN SWI 00103A FFFC COOO A FDB MRMN NMI 00104A FFFE COOO A FOB MRMN RES 00105 00106 * END ~HITACHI 1056 SECTION 14. LOW POWER DISSIPATION MODE 14.1 HARDWARE DESCRIPTION 14.1.1 Function Executes a test program for two low power dissipation mode: sleep mode and standby mode, and displays current mode and an 8-bit counter on LEDs. 14.1.2 Microcomputer Operation The HD6301YO executes standby mode by clearing standby flag of RAMI port 5 control register during NMI interrupt routine; and executes sleep mode by instruction SLP execution corresponding to switch input. ~e MCU returns from standby mode by reset; returns from sleep mode by timer 2 interrupt. 14.1.3 Peripheral Devices Switches and LEDs: SWl and SW2 are used to execute sleep mode and standby mode, respectively, and LED1-LED3 indicate the current operating state of the HD6301YO. Switch and LED setting for each mode are shown in table 14-1. In addition, LED4-LEDll are used to display an 8-bit counter during sleep mode. Table 14-1. Switch Setting and Display for Each Mode Test Mode Switch Setting Display SWl SW2 LEDl LED2 LED3 Active Mode OFF OFF OFF OFF ON I Sleep Mode ON OFF OFF ON OFF Standby Mode OFF ON ON OFF ON (Note) Note: In standby mode, LEDl is displayed after returned from standby mode. ~HITACHI 1057 14.1.4 Circuit Diagram Low power dissipation mode circuit is shown in figure 14-1. +5V Mev HD6a01YO LED1 2000 4 MP o PI 5 LED2 2000 MP I aa Vee f. 7 STBY XTAL 4MHz ,r. c::::J 8 EXTAL 22pF +5V PS7 51 \EDU ".0 +5V 6 RES 1pF 4.7kO SW8 26 ~~ PM Vss 42 .4.7kO Vss 8 NMI SW2 Figure 14-1. Low Power Dissipation Mode Circuit ~HITACHI 1058 14.1.5 Pin Functions Pin functions at the interface between the HD6301YO and the switches and LEDs are shown in table 14-1. Table 14-1. Pin Functions Pin Name Input/ Active Level Pin Name Program (HD6301YO) Output (High or Low) Function (SW, LED) Label P 10 Output High Drives LED indi- LED3 P1DTR cating active mode operation. P 12 Output High Drives LED after LED2 exiting standby mode. P 13 Output High Drives LED in- LEDl dicating sleep mode. P 30 Output High Drives LEDs used LED4 P3DTR as 8-bit binary P 31 Output High counter. LED5 P 32 Output High LED6 P33 Output High LED7 P Output High LED8 34 P 35 Output High LED9 P 36 Output Hi<,Jh LED10 P 37 Output High LEDll P 61 Input Low Sleep mode switch SW1 P6DTR input NMi Input Low Standby mode Sw2 I swi tch input RES Input Low Standby mode reset SW3 input ~HITACHI 1059 14.1.6 Hardware Operation a. Standby mode The timing chart for entering and exiting standby mode by the STBY flag is shown in figure 14-2. RES 'LS , I I ,, , ,, , t----- Clear Standby mode 'Restart STBY flag (Active model Oscillation stabilization time Figure 14-2. Timing Chart for Standby Mode b. Sleep mode The timing chart for sleep mode is shown in figure 14-3. OFF - - - - - , Sleep mode switch ON ----JI----------! Executing---------; , Program execution --------'--I - ,,, Sleep , '--I ,, '---I '-- ,, I , I I I Timer interrupt timing I I I Figure 14-3. Timing Chart for Sleep Mode ~HITACHI 1060 14.2 SOFTWARE DESCRIPTION 14.2.1 Program Module Configuration The program module configuration for low power dissipation mode is shown in figure 14-4. LWPMN MAIN l..! PROGRAM I LWPSP I LWPST I L.: STANDBY L: SLEEP MODE MODE Figure 14-4. Program Module Configuration 14.2.2 Program Module Functions Program module functions are summarized in table 14-2. Table 14-2. Program Module Functions No. Program Module Name Label Function o MAIN PROGRAM LWPMN Executes low power dissipation mode. 1 SLEEP MODE LWPSP Tests sleep mode operation. 2 STANDBY MODE LWPST Tests standby mode operation. ~HITACHI 1061 14.2.3 Program Module Process Flow (Main Program) The flowchart in figure 14-5 shows the procedure for performing low power dissipation mode, using the program module in figure 14-4. Main Program Test if power is re-supplied during standby mode execution. ---[ Test if reset from standby mode or power ON. ---{ Turn on LED indicating standby mode and active mode. ----[ Load value of stack pointer before entering standby mode. ---{ Turn on LED indicating active mode. ---{ Turn off LEDs for binary counter. ---{ Initialize stack pointer. ---{ Select ports land 3 as output. ----[ Initialize timer control status register 3. ----[ Enable interrupts. ~---{ Clear RAM. ---{ Test for sleep mode request. ---{ Enter sleep mode. ---{ Activate LEDs for binary counter. NMl Interrupt Routine ----[ Enter standby mode. Figure 14-5. Program Module Flowchart ~HITACHI 1062 14.3 PROGRAM MODULE DESCRIPTION Program Module Name: SLEEP MODE MCU/MPU:HD630lYO Label: LWPSP Function: Tests sleep mode operation. Arguments: Changes in CPU Specifications: Registers and Flags: None ACCD ROM (Bytes) : 10 ACCA ACCB x • RAM (Bytes) : 0 Stack (Bytes) : 0 IX • No . of cycles: 19 Reentrant: No C V Relocatable: No • x Interrupt OK?: Yes Z N x x I H • • • Not affected x : Undefined Resul t Description: 1. Function Details a. LWPSP has no arguments. I b. Sleep mode is entered by switch 1 input. c. LWPSP calls neither the program modules nor subroutines. 2. User Note The following procedure must be executed before LWPSP execution. a. Select DDR of port 1 as output. Specifications Notes: N/A ~HITACHI 1063 Program Module Name: SLEEP MODE ~M_C_U_/_M_P_U_: __HD __6_3_0_1_Y_O____ ~ LIL_a_b_e_l_:__L_WP __S_P______ ~ Description: 3. RAM Allocation RAM is not used during LWPSP execution. 4. Sample Application WAA #$FF STAA P1DTR ----- Initialize port 1. WAA STAA #$01 P1DDR t LWPSP II JSR II ----- Call LWPSP. 5. Basic Operation a. The LED indicating sleep mode is turned on and sleep mode is entered by the sleep instruction(SLP). b. Timer 2 interrupt executes return from sleep mode, and the LED indicating sleep mode is turned off. ~HITACHI 1064 Program Module Name: SLEEP MODE MCU/MPU: HD630lYO I~ LWPSP Flowchart: ------[ Turn off LED indicating active mode, and turn on LED indicating sleep mode. ------[ Enter sleep mode. -----[ Turn off LED indicating sleep mode, and turn on LED indicating active mode. I ~HITACHI 1065 Program Module Name: STANDBY MODE MCU/MPU: HD6301YO Label: LWPST Function: Tests standby mode operation. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes) : 16 ACCA ACCB Entry • • RAM (Bytes) : 0 Stack (Bytes) : 0 IX • No. of cycles: 31 Reentrant: No C V Relocatable: No • x Interrupt OK?: Yes Re- Value of STACK 2 Z N turns stack (RAM) x EO inter x LWPST NMIF 1 I H execution (RAM) flag • • • Not affected x : Undefined t Result Description: 1. Function Details a. Argument details STACK(RAM): Value of stack pointer when NMI interrupt is executed. NMIF(RAM): Used as flag indicating LWPST execution, i.e., standby mode. b. Example of LWPST execution is shown in figure 14-6. Contents of CPU registers, before NMI interrupt by switch 2 input, are saved and LWPST is executed. Value of stack pointer is saved in STACK(RAM) and $01 is stored in NMIF(RAM). Specifications Notes: N/A ~HITACHI 1066 L..p_r_o_g_r_aIlI_M_od_u_le_N_aIlI_e_._._S_T_AND_B_:'i_M_O_D_E_---' LM_C_U_I_M_P_U_:__ I HD_6_30_l_Y_0_ _----I Label, LIiPST Description: CD Input { SW2 ON. RAM $129 C C R (i) ACCB ACCA Result I XH I XL P C H $180 P C L B1S STACK STACK+1 bO STt~1)1 0 : : 9 I ($129) b7 NMIF bO ~m~1 0 : I Figure 14-6. Example of LWPST Execution c. LWPST calls neither the program modules nor subroutines. 2. User Notes The following procedure must be executed before LWPST execution. a. Initialize stack pointer since NMI interrupt is executed. 3. RAM Allocation Label RAM Description g I b7 bO STACK } Value of stack pointer NMIF rFlag indicating LWPST execution. 4. Sample Application IDS #$130 ----- Initialize stack pointer. ~HITACHI 1067 Program Module Name: STANDBY MODE L-M_C~U_I_M_P_U_:_HD_6_3_0_l_Y_O ~ I __ Label, LWPST Description: 5. Basic Operation a. Set flag NMIF(RAM) indicating LWPST execution. b. Save stack pointer in STACK(RAM). c. Set standby power bit of RAM/port 5 control register. d. Clear RAM enable bit of RAM/port 5 control register and disable RAM access to protect RAM data. e. Clear standby flag and enter standby mode. ~HITACHI 1068 Program Module Name: STANDBY MODE MCU/MPU: HD630lYO 1Lobel, LWPST Flowchart: Set flag indicating LWPST execution. L---r----' - --{ Save value of stack pointer in STACK L..---,-------..J - - - [ (RAM) • Set standby power bit. L---r-o-----I ---{ Disable RAM access I moved this to L..---,-------..J - - - { "Basic Operation". Clear standby flag and execute standby L - - - r - - - - ' - - - [ mode. ~HITACHI 1069 14 . 4 SUBROUTINE DESCRIPTION Subroutine Name: INCREMENT COUNTER MCULMPU: HD6301YO [ L.bel, LWPCN Function: Increment counter for LED binary display. Basic Operation: 1. This subroutine is executed at every 32ms interrupt. 2. Two counters are used to count one second. 3. LED counter is incremented at every interrupt. When this counter is "31" I l-second counter is counted up. Program Module Using This Subroutine: Flowchart: - - - - - [ Clear interrupt request flag. Count up and turn on LED binary counter every second during sleep mode execution. - - - - - - [ Increment l-second counter. L------=====::r----I ~HITACHI 1070 14.5 PROGRAM LISTING 00001 * 00002 ******* RAM ALLOCATION ********************** 00003 00004A 0040 * ORG $40 00005 * 00006A 0040 0001 A CNTRD RMB 1 I-second counter 00007A 0041 0001 A CNTRI RMB 1 LED counter 00008A 0042 0001 A NMIF R~lB 1 LWPST execution fLag 00009A 0043 0002 A STACK RMB 2 VaLue of stack pointer 00010 *. 00011 ******* SYMBOL DEFINItIONS ****************** 00012 00013 0000 A *P1DDR EQU $00 Portl data direction register 00014 0002 A P1DTR EQU $02 Portl data register 00015 0004 A P3DDR EQU $04 Port3 data direction register 00016 0006 A P3DTR EQU $06 Port3 data register 00017 0016 A P6DDR EQU $16 Port6 data direction register 00018 0017 A P6DTR EQU $17 Port6 data register 00019 OOlB A TCSR3 EQU $lB Timer controL register3 00020 OOlC A TCONR EQU $IC Time constant register 00021 001D A T2CNT EQU $lD Timer2 up counter 00022 0014 A RP5CR EQU $14 RAM/portS controL register 00023 ******************************************>1<**** 00024 00025 *>I< MAIN PROGRAM : LWPMN >I< 00026 * 00027 ***>1<***>1<***************************************** 00028 * 00029A COOO ORG $COOO 00030 * 00031A COOO 7B 80 14 LWPMN BTST 7.RP5CR Test standby power bit 00032A C003 26 OD C012 BNE LWPMN2 00033A COOS 86 FE A LWPMN1 LDAA Ii$FE Turn on active mode LED 00034A C007 97 02 A STAA PlDTR 00035A C009 86 FF A LDAA Ii$FF 00036A COOB 97 06 A STAA P3DTR 00037A COOD 8E 013F A LDS 1i$13F InitiaLize stack pointer 00038A COlO 20 DB COlD BRA LWPMN3 00039A C012 7B 01 42 LWPMN2 BTST O.NMIF Test if standby mode execution 00040A C015 27 EE COOS BEQ LWPt1N1 00041A C017 86 F6 A LDAA Ii$F6 Turn on standby mode LED 00042A C019 97 02 A STAA PlDTR 00043A C01B 9E 43 A LDS STACI< Load stack pointer 00044A COlD 86 01 A LWPMN3 LDI4A 11$01 SeLect pdrts 1 and 3 as output 00045A COIF 97 00 A STAA P1DDR 00046A C021 97 04 A STAA P3DDR 00047A C023 86 52 A LDAA Ii$S2 00048A C025 97 1B A STAA TCSR3 Initialize TCSR3 00049A C027 OE CLI EnabLe interrupts 00050A C028 4F CLRA CLear RAM 00051A C029 97 42 A STAA NMIF 00052A C02B 97 40 A STAA CNTRD 00053A C02D 97 41 A STAA CNTRI 00054A C02F 7B 02 17 LWPMN4 BTST 1.P6DTR Test if sLeep mode execution 00055A C032 27 OS C039 BEQ LWPMNS 00056A C034 BD C040 A JSR LWPSP Execute sLeep mode 00057A C037 20 F6 C02F BRA. LWPMN4 ~HITACHI 1071 00058A C039 96 40 A LWPMNs LDAA CNTRD 00059A C03B 43 COMA 00060A C03C 97 06 A STAA P3DTR Turn on LED binary counter 00061A C03E 20 EF C02F BRA LWPMN4 00062 ******************************************* 00063 * * 00064 NAME : LWPSP (SLEEP MODE) 00065 * * ******************************************** 00066 * 00067 00068 * ENTER : NOTHING * 00069 * 'RETURNS: NOTHING * 00070 * * 00071 ********************************************* 00072A C040 86 FB A LWPSP LDAA n$FB 00073A C042 97 02 A STAA P1DTR Turn on sLeep mode LED 00074A C044 1A SLP Execute sLeep mode 00075A C045 86 FE A LDAA n$FE 00076A C047 97 02 A STAA PlDTR Turn on active mode LED 00077A C049 39 RTS 00078 ******************************************** 00079 00080 * NAME : LWPST (STANDBY MODE) * 00081 * * 00082 * ******************************************** * 00083 00084 * * ENTER NOTHING ** 00085 RETURNS : STACK (STACK POINTER) * 00086 * NMIF (LWPST EXECUTION FLAG)* 00087 * 00088 * ******************************************** * 00089A C04A 72 01 42 LWPST BSET O.NMIF Set LWPST execution fLag 00090A C04D 9F 43 A STS STACK Store stacK pointer 00091A C04F 72 80 14 BSET 7.RPsCR Set standby power bit 00092A COs2 71 FD 14 BCLR 1.RPsCR CLear RAM enabLe bit 00093A COss 71 DF 14 BCLR s.RPsCR CLear standby fLag 00094A COs8 20 FE CO 58 LWPST1 BRA LWPST1 00095 ******************************************* 00096 00097 * NAME : LWPCN (INCREMENT COUNTER) * 00098 * * 00099 * ******************************************* * OOlOOA COsA 71 7F 1B LWPCN BCLR 7.TCSR3 CLear Interrupt request fLag 00101A COsD 7C 0041 A INC CNTRI Increment LED counter 00102A C060 96 41 A LDAA CNTRI 00103A C062 81 IF A CMPA 1131 00104A C064 27 01 C067 BEQ LWPCNI 00105A C066 3B LWPCN2 RTI 00106A C067 4F LWPCN1 CLRA 00107A C068 97 41 A STAA CNTRI Turn on LED binary counter 00108A C06A 7C 0040 A INC CNTRD Increment I-second counter 00109A C06D 20 F7 C066 BRA LWPCN2 00110 ******************************************** 00111 00112 00113 * VECTOR ADDRESSES * 00114 * * * * ~HITACHI 1072 00115 ******************************************* 00116 * 00117A FFEA ORG $FFEA 00118A FFEA COOO A FOB LWPMN lRQ2 00119A FFEC COs A A FOB LWPCN CMI 00120A FFEE COOO A FOB LWPMN TRAP 00121A FFFO COOO A FOB LloJPMN SIO 00122A FFF2 COOO A FOB LWPMN TOl 00123A FFF4 COOO A FOB LWPMN DCI 00124A FFF6 COOO A FOB LWPMN ICI 00125A FFF8 COOO A FOB LWPMN IRQI/ISF 00126A FFFA COOO A FOB LWPMN SWI 00127A FFFC C04A A FOB LWPST NMI 00128A FFFE COOO A FOB LWPMN RES 00129 * 00130 ENO I ~HITACHI 1073 SECTION 15. HA1835P CONTROL AND ERROR DETECTION 15.1 HARDWARE DESCRIPTION 15.1.1 Function Executes test program of MCU runaway error and trap error detection (operation code error and address error), and displays result on LED. 15.1.2 Microcomputer Operation The HD6301YO sends pulse to the HA1835P voltage regulator controlling bit 0 of port 7 and detects watchdog timer error. In addition, detects operation code error and address error using the trap function. 15.1.3 Peripheral Devices Switches and LEDS: Switches SWl-SW3 are used to indicate the above three errors for testing. The generation of those errors and subsequent error handling is indicated by LED1-LED3. The relationship between switch settings and LED display is shown in table 15-1. Table 15-1. SWitch Setting and Display for Each Mode Switch Setting Display Test Mode SWl SW2 SW3 LEDl LED2 LED3 Normal Operation OFF OFF OFF OFF OFF OFF Watchdog Timer Error ON OFF OFF ON OFF OFF Operation Code Error OFF ON OFF OFF ON OFF Address Trap Error OFF OFF ON OFF OFF ON @HITACHI 1074 15.1.4 Circuit Diagram HA183SP and Error Detection Circuit is shown in figure 15-1. MCU f_o HD6301YO 22pF 2 XTAL 3 EXTAL 22pF +5V SW1 4.7kn I' HV 17 P so 18 PSt HDH05/ HV 200.0 P n 62 :r- 4o.7kn LED! IO 61 # 200.0 P'2 P 72 42 LE!} Vss 60 200.0 Vss P'3 LED8 Figure 15-1. HAI83SP-and Error Detection Circuit I ~HITACHI 1075 15.1.5 Pin Functions Pin functions at the interface between the HD6301YO and switches, LEDs, and the HA183sP are shown in table 15-2. Table 15-2. Pin Functions Pin Name Pin Name Input/ Active Level (SW, LED, Program (HD6301YO) Output (High or Low) Function HA183sP) Label Pst Input Low Watchdog timer error SW1 PsDTR generation switch PSI Input Low Operation code trap SW2 error generation switch P S2 Input Low Address trap error SW3 generation switch P 70 Output Outputs pulse to CLK CLK P7DTR pin of HA183sP P 7l Output High Drives LED indicating LED 1 watchdog timer error generation P 72 Output High Drives LED indicating LED2 operation code trap error generation P 73 Output High Drives LED indicating LED3 address trap error generation REs' Input Low Inputs reset. RES 15.1.6 Hardware Operation The timing chart for the watchdog timer function using the HAl83sP is shown in figure 15-2. HAl835> pin n~: e\, J't~ ="':1 eLK JUUUI I ~ 180m·l ~ Automatic reset signal watchdog timer I error generation SW input ----------------~ Figure 15-2. Timing Chart for Watchdog Timer ~HITACHI 1076 15.2 SOFTWARE DESCRIPTION 15.2.1 Program Module Configuration The program module configuration for the HA1835P control and error detection function is shown in figure 15-3. FSMN ~ MAIN PROGRAM I FSWD I FSOP I FSADDR I FSTRP I DETECT l!.. DETECT L:.. DETECT ~ RETURN ~ WATCHDOG OPERATION ADDRESS FROM ERROR TIMER ERROR CODE ERROR ERROR BY TRAP Figure 15-3. Program Module Configuration 15.2.2 Program Module Functions Program module functions are summarized in table 15-3. Table 15-3. Program Module Functions No. Program Module Name Label Functions 0 MAIN PROGRAM FSMN Perform HA1835p control and error detection. 1 DETECT WATCHDOG FSWD Stop pulse output to HA1835p and check TIMER ERROR RES input. I 2 DETECT OPERATION FSOP Execute undefined operation code and CODE ERROR check operation code error generation. 3 DETECT ADDRESS ERROR FSADDR Fetch instruction from other than ROM, RAM and check address error. 4 RETURN FROM ERROR FSTRP Return from operation code error and BY TRAP address error. ~HITACHI 1077 15.2.3 Program Module Process Flow (Main Program) The flowchart in figure 15-4 demonstrates the procedure for detecting watchdog timer error, operation code error, and address error by SWl-3, using the program module in figure 15-3. Main Program L-______, -______ ~ -----{rnitialize stack pointer. SW1: ON, detect watchdog timer error. ---- { SW1: OFF, output pulse having a 20ms cycle. SW2' ON, detect operation code error . ....______, -______..u - - - - - [ SW2; OFF, cci nothing. SW3: ON, detect address error. - --- { : sw 3: OFF, Co nothing • .....- - - r - - - - " " Trap Routine ____ [ Return from operation code error and ~~~ __,-______'" address error. Figure 15-4. Program Module Flowchart $ HITACHI 1078 15.3 PROGRAM MODULE DESCRIPTION Program Module Name: DETECT WATCHDOG MCU/MPU: HD630lYO/ Label: FSWD TIMER ERROR HD6303Y Function: When SWI is ON, detect watchdog timer error. When SWI is OFF, output pulse to bit 0 of port 7 every 20ms. Arguments: Changes in CPU Specifications: None Registers and Flags: ACCD ROM (Bytes): 64 ACCA ACCB x I • RAM (Bytes): Stack (Bytes): 0 2 IX • No. of cycles: 10041 Reentrant: No C V Relocatable: No x x Interrupt OK?: Yes Z N x x I H • • • x : Not affected Undefined t Result Description: 1. Function Details ON SWl OFF a. FSWD has no arguments. b. Example of FSWD execution is shown in figure 15-5. When SWI is OFF, output pulse to bit 0 of port 7 every 20ms. When SWl is ON, stop pulse output and turn on LEDI after reset. RES PYa ON LEDlOFF "L- I When SWI is OFF again, output pulse to bit 0 of port 7 and turn off LEDI. Figure 15-5. Example of FSWD Execution Specifications Notes: ~HITACHI 1079 Program Module Name: DETECT WATCHDOG TIMER ERROR MCU/MPU: HD6301YO/ HD6303Y IL..." FSWD Description: c. FSWD calls neither the program modules nor subroutines. 2. User Notes Use SWI independently of other switches. 3. RAM Allocation Label RAM Description b7 bO CMRAM f ~ } Comparison data for watchdog timer error detection. 4. Sample Application FSWD 1/ ----- Call FSWD. 5. Basic Operation a. When S~l is ON, the following operations are performed. i. After power ON, data is stored in CMRAM(RAM) , an infinite loop is executed, and pulse output to the HA1835P is stop. ii. The HAl835P determines this status as system runaway and sets RES pin to LOW. iii. After reset, data in CMRAM(RAM) is compared with data previously stored. If these are the same, LEDI is turned on. b. When SWI is OFF, 10 ms software timer is executed and the output to bit o of port 7 is inversed. ~HITACHI 1080 Program Module Name: DETECT WATCHDOG TIMER ERROR MCU/MPU: HD6301YO/ HD6303Y I Label, FSWD Flowchart: ---{ Teet i f SWI ie ON. '----""t'"----' - - - { Turn off LEDl. ___ { Initialize RAM for comparison ~--~--~ data. '----r-----i '----""t'"----' - - - - Execute 10 ms software timer. ----[ Teet if bit 0 of port 7 ie 1. '----""t'"--....J - - - { Output High to bit 0 of port 7. - - - { Output Lew to bit 0 of port 7. 2 I FSWD3 R T S ~HITACHI 1081 Program Module Name: DETEcr WATCHDOG TIMER ERROR MCU/MPU: BD6301YO/ BD6303Y I~ FSWD ( CMRAM)#$ 5 5 Test if return from watchdog timer error. (CMRAM+l)#$ (CMRAMt 1) =$AA Store comparison data which tests ------[ return from watchdog timer error. ____ { Turn off LED I to indicate watchdog timer error handled. ~HITACHI 1082 Program Module Name: DETECT MCU/MPU: HD6301YO/ Label: FSOP OPERATION CODE HD6303Y ERROR Function: When SW2 is ON, execute an undefined operation code and generate an operation code error. If operation code error is detected, turn 'on LED2. When Sw2 is turned OFF, turn off LED2. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes) : 27 ACCA ACCB Entry x x RAM (Bytes) : 1 Stack (Bytes) : 0 IX x No. of cycles: 85 Reentrant: No C V Relocatab1e: No • x Interrupt OK?: Yes Re- Error TRMD 1 Z N turns mode (RAM) x x I H • • • Not affected x : Undefined Resul t Description: 1. Function Details a. Argument details SW2 OFF - - , r-- ON L---..J I TRMD(RAM): Contains data indicating operation code error. ON~ LED20FF~ - b. Example of FSOP execution is shown Operation code in figure 15-6. When operation error generation error is generated, turn on LED2. c. FSOP calls an other program module Figure 15-6. Example of as shown in Table 15-4. FSOP Execution Specifications Notes: "No. of cycles" in "Specifications" indicates the number of cycles required to handle an operation code error. ~HITACHI 1083 Program Module Name: DETECT OPERATION CODE MCU/MPU: ED6301YO/ ED6303Y ILabelo FSOF ERROR Description: Table 15-4. Program Module Called by FSOP Program Module Name Label Function RETURN FROM ERROR FSTRP Return from operation code error or address BY TRAP error. 2. User Notes Use SW2 independentry. 3. RAM Allocation Label RAM Description b7 bO T.RMD } Data indicating operation code error. 4. Sample Application 1/ JSR FSOP II ----- Call FSOP. 5. Basic Operation a. When SW2 is ON, execute operation as follows; i. TRMD(RAM) is cleared to indicate operation code error. ii. Undefined operation code "$87" is executed. iii. LED2 is turned on after returning from trap interrupts. b. When sw2 is turned OFF, turn off LED2. ~HITACHI 1084 Program Module Name: DETECT OPERATION CODE MCU/MPU: HD6301YO/ HD6303Y ILabel, FSOP ERROR Flowchart: ---{ Test if SW2 is ON. ---{ Clear TRMD (RAM) and indicate operation code error. ~-----r----~ ---{ Execute undefined operation code. interrupts are generated. { Turn on LED2 to indicate operation code error generation. Test if SW2 is OFF. --{ Turn off LED2. L.----,:::===~ I ~HITACHI 1085 Program Module Name: DETECT ADDRESS MCU/MPU: HD6301YO/ Label: FSADDR ERROR HD6303Y Function: When SW3 is ON, jump to address for I/O ports and generate address error. If address error is detected, turn on LED3. When SW3 is turned OFF, turn off LED3. Arguments: Changes in CPU Specifications: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes) : 30 ACCA ACCB Entry x • RAM (Bytes) : 1 Stack (Bytes) : 0 IX • No • of cycles: 78 Reentrant: No C V Relocatable: No • x Interrupt OK?: Yes Re- Error TRMD 1 z N turns mode (RAM) x x I H • • • Not affected x Undefined t Result Description: 1. Function Details a. Argument details SW3 OFF - - , r- ON L--.....J TRMD(RAM): Contains data indicating ON I I- address error. LED8 OFF ----, b. Example of FSADDR execution is Address error generation shown in figure 15-7. When address error is generated, turn on LED3. Figure 15-7. Example of FSADDR Execution Specifications Notes: "No. of cycles" in "Specifications" indicates the number of cycles required when address error is generated. ~HITACHI 1086 ~IL_L_a_b_e_l_: ~ Program Module Name: DETECT ADDRESS ERROR M_C_U_/_M_P_U_:_HD __6_3_0_1_YO_/ HD6303Y ____ . __F_SAD __D_R____ L_ Description: c. FSADDR calls an other program module as shown in Table 15-5. Table 15-5. Program Module Called in FSADDR Program Module Name Label Functions RETURN FROM ERROR FSADDR Return from operation code error or BY TRAP address error. 2. User Notes Use SW3 independently of other switches. 3. RAM Allocation Label RAM Description b7 bO TRMD } Data indicating address error. 4. Sample Application II JSR FSADDR II ----- Call FSADDR. 5. Basic Operation a. When SW3 is ON, execute operations as follows; 1. Store "1" in TRMD(RAM) to indicate address error. i1. Execute "JMP 3" to jump to port 3 data register. I iii. Turn on LED3 after returning from trap interrupts. b. When SW3 is turned OFF, turn off LED3. ~HITACHI 1087 '- _p_r_o_g_r_a_m__ M_od__ U_le__N_am __e__ : __ERROR __AD D_E_TE_C_T S_S~ __D_RE __ '-M_C_U_/_M_P_U_:___ HD_6__ 30_1_Y_O_/ HD6303Y. ~ ____ I'-L_a_b_e_l_:___F_S_AD_D_R ______ ~ Flowchart: (2.P5DTR)=1 ----[ Test if Sw3 is ON. ---{ Store "1" in TRMD (RAM) and indicate address error. ----{ Jump to address $3. (TRMD) =1 ____ { Test if trap interrupts are generated. _____ [ Turn on LED3 to indicate address error generation. if sw3 is OFF. --{ Turn off LED3. $HITACHI 1088 Program Module Name: RETURN FROM MCU/MPU: HD6301YOj Label: FSTRP ERROR BY TRAP HD6303Y Function: When operation code error or address error is generated, return to the program where interrupts are generated by controlling the program counter. Arguments: Changes in CPU Speci fica tions: Storage No. of Registers and Flags: Contents Location Bytes ACCD ROM (Bytes): 30 ACCA ACCB Entry Error Mode TRMD 1 x x RAM (Bytes): 1 (RAM) Stack (Bytes): 0 IX x No. of cycles: 4S Reentrant: No c v Relocatable: No x x Interrupt OK?: No Re- z N turns x x I H • • • Not affected x : Undefined Result Description: 1. Function Details a. Argument details TRMD(RAM): Holds data indicating what error is generated. b. Table lS-6 shows flag functions. Example of FSTRP execution is shown in figure lS-S. If entry argument is as shown in parte!) of figure lS-S, data for program counter in stack area is changed as shown in part@ of figure lS-S. I Specifications Notes: "No of cycles" in "Specifications" indicates the number of cycles required when operation code error is generated. "HITACHI 1089 Program Module Name: RETURN FROM MCU/MPU: HD630lYO/ ERROR BY TRAP HD6303Y Description: \ Table 15-6. Flag Functions Label bit 0 Function TRMD o Execute routine for operation code error generation. 1 Execute routine for address error generation. TRMD b7 bO I< 00002 **** RAM ALLOCATION ************************ 00003 >I< 00004A 0040 ORG $40 00005 >I< 00006A 0040 0002 A CMRAM RMB 2 Data for comparing 00007A 0042 0001 A TRMD RMB 1 En'or' mode OOOOB >I< 00009 **** SYMBOL DEFINITION 00010 >I< 00011 001B A P7DTR EQU $lB Port 7 data register 00012 0014 A RP5CR EQU $14 RAM/PORTS control register 00013 0015 A P5DTR EQU $15 Port 5 data register 00014 0020 A P5DDR EQU $20 Port 5 data direction register 00015 *********~(************************************** 00016 >I< >I< 00017 >I< MAIN PROGRAM : FSMN >I< 0001B >I< >I< 00019 ************************************************ 00020 >I< 00021A COOO ORG $COOO 00022 >I< 00023A COOO 8E 013F A FSMN LOS 1I$13F Initialize stack pointer 00024A C003 BD 06 COOB FSMNI BSR FS~ID Check watchdog timer error 00025A COOS BD 43 C04A BSR FSOP Check operation error 00026A C007 80 SA C063 BSR FSADDR Check address error OOOnA C009 20 FB C003 BRA FSMNI 0002B ************************************************ 00029 >I< >I< 00030 >I< NAME: FSWD (DETECT WATCHDOG TIMER ERROR) >I< 00031 >I< >I< 00032 **********************************~(******~*****M 00033 >I< >I< 00034 >I< ENTRY : NOTHING >I< 00035 RETURNS : NOTHING 00036 >I< >I< * >I< 00037 ************************************************ 0003BA COOB 7B 01 15 FSWD BTST 0.P5DTR Test if SWl=ON 00039A CODE 27 IF C02F BEQ FSWD4 Branch if SWl=ON 00040A COlO 71 FD 1B BCLR 1.P7DTR Turn off LEDI 00041A COl3 7F 0040 A CLR CMRAM Clear CMRAM 00042A C016 7F 0041 A CLR CMRAM+l 00043A C019 CC 06B2 A LDD 1I$6B2 Execute 10 ms software timer 00044A COIC 83 0001 A FSWDI SUBD III 00045A COIF 26 FB COIC BNE FSWDI 0.P7DTR Test if P70 = I 00046A C021 7B 01 1B BTST 00047A C024 27 05 C02B BEQ FSWD2 Branch if P70 0 0004BA C026 71 FE 18 BCLR 0.P7DTR Output Low to P70 00049A C029 20 03 C02E BRA FSWD3 00050A C02B 72 01 18 FSWD2 BSET 0.P7DTR Output High to P70 00051A C02E 39 FSWD3 RTS 00052A C02F B6 55 A FSWD4 LDAA 11$55 Test if CMRAM=$55 00053A C031 91 40 A CMPA CMRAM 00054A C033 26 DB C040 BNE FSWD5 Branch if not equal 00055A C035 B6 AA A LDAA liMA Test if CMRAM+l=$AA 00056A C037 91 41 A CMPA CMRAM+l 00057A C039 26 05 C040 BNE FSWD5 Branch if not equal ~HITACHI 1093 00058A C03B 72 02 18 BSET 1.P7DTR Turn on LED1 00059A C03E 20 EE C02E BRA FSWD3 00060A C040 86 55 A FSWD5 LDAA 11$55 InitiaLize CMRAM:CMRAM+1 00061A C042 97 40 A STAA CMRAM 00062A C044 86 AA A LDAA II$AA 00063A C046 97 41 A STAA CMRAM+1 00064A C048 20 FE C048 FSWD6 BRA FSWD6 00065 ************************************************ 00066 * NAME : FSOP (DETECT OPERATION CODE ERROR) * 00067 * * 00068 ************************************************** 00069 00070 * * 00071 * ENTRY : NOTHING * 00072 RETURNS : TRMD (ERROR MODE) 00073 * * 00074 * ************************************************ * 00075A C04A 7B 02 15 FSOP BTST 1.P5DTR Test if SW2=ON 00076A C04D 26 10 CO SF BNE FSOP2 Branch if SW2=ON 00077A C04F 7F 0042 A CLR TRMD CLear TRMD 00078A C052 87 A FCB $87 Execut undefined op-code 00079A C053 96 42 A LDAA TRMD Test if TRMD=l? 00080A C055 27 03 C05A BEQ FSOP1 Branch if TRMD=O 00081A C057 72 04 18 BSET 2.P7DTR Turn on LED2 00082A C05A 7B 02 15 FSOP1 BTST 1.P5DTR Test if SW2=OFF 00083A C05D 27 03 C062 BEQ FSOP3 Branch if SW2=OFF 00084A C05F 71 FB 18 FSOP2 BCLR 2.P7DTR Turn off LED2 00085A C062 39 FSOP3 RTS 00086 ************************************************ 00087 * * 00088 NAME : FSADDR (DETECT ADDRESS ERROR) 00089 * * 00090 * ************************************************ * 00091 * 00092 * ENTRY: NOTHING ** 00093 * RETURNS : TRMD (ERROR MODE) * 00094 * * 00095 ************************************************ 00096A C063 7B 04 15 FSADDR BTST 2.P5DTR Test if SW3=ON 00097A C066 26 13 C07B BNE FSADR3 Branch if SW3=ON 00098A C068 86 01 A LDAA 111 Store 1 in TRMD 00099A C06A 97 42 A STAA TRMD 00100A C06C 7E 0003 A JMP 3 Execute address error mode 00101A C06F 96 42 A LDAA TRMD Test if TRMD=O? 00102A C071 26 03 C076 BNE FSADR2 Branch if TRMD=L 00103A C073 72 08 18 FSADR1 BSET 3.P7DTR Turn on LED3 00104A C076 7B 04 15 FSADR2 BTST 2.P5DTR Test if SW3=OFF 00105A C079 26 03 C07E BNE FSADR4 Branch if SW3=ON 00106A C07B 71 F7 18 FSADR3 BCLR 3.P7DTR Turn off LED3 00107A C07E 39 FSADR4 RTS 00108 ************************************************ 00109 * 00110 NAME : FSTRP (RETURN FROM ERROR BY TRAP) * 00111 * * 00112 * ************************************************ * 00113 * * 00114 ENTRY : TRMD (ERROR MODE) * * $HITACHI 1094 00115 * RETURNS : NOTHING * 00116 * * 00117 ************************************************ 00118A C07F 30 FSTRP TSX Load stack po1nter 1nto ACCD 001l9A C080 18 XGDX 00120A C081 C3 0005 A ADDD 1i$5 CaLcurate program counter 00121A C084 18 XGDX 00122A C085 96 42 A LDAA TRMD Test 1f op-code or address error? 00123A C087 26 OB C094 BNE FSTRP1 Br~lnch if address error 00124A C089 86 01 A LDAA iiI Store 1 1n TRMD 00125A C08B 97 42 A STM TRt~D 00126A C08D EC 00 A LOD O.X Increment program counter 00127A C08F C3 0001 A ADDD iiI 00128A C092 20 06 C09A 8RA FSTRP2 00129A C094 7F 0042 A FSTRP1 CLR TRMO CLear TRMD 00130A C097 FC C073 A LOD FSAOR1 0013lA C09A ED 00 A FSTRP2 STD O.X Store program counter 00132A C09C 3B RTI 00133 ************************************************ 00134 * 00135 * VECTOR ADDRESSES ** 00136 * 00137 ************************************************* 00138 * 00139A FFEA ORG $FFEA 00140 * 00141A FFEA COOO A FOB FSMN IR02 00142A FFEC COOO A FOB FSMN CMI 00143A FFEE C07F A FOB FSTRP TRAP 00144A FFFO COOO A FOB FSt1N SID 00145A FFF2 COOO A FOB FSMN TOI 00146A FFF4 COOO A FOB FSMN OCI 00147A FFF6 COOO A FOB FSMN ICI 00148A FFF8 COOO A FOB FSMN IROI/ISF 00149A FFFA COOO A FOB FSMN SWI 00150A FFFC COOO A FDB FSMN NMI 0015lA FFFE COOO A FOB FSMN RES 00152 * 00153 END I ~HITACHI 1095 ~HITACHI 1096 HD63011HD6303 SERIES HANDBOOK Section Nine C Language Programming Thchniques I ~HITACHI 1097 ~HITACHI 1098 Section 9 C Language Programming Techniques Table of Contents Page 1. HOW TO USE APPLICATION NOTES .............................. . 1105 1.1 Hardware Section ............................................. . 1107 1.1.1 Function ................................................... . 1107 1.1.2 Microcontroller Applications ................................... . 1107 1.1.3 Circuit Diagram ............................................. . 1108 1.1.4 Memory Map ............................................... . 1109 1.1.5 Pin Functions ............................................... . 1110 1.1.6 Hardware Operation ......................................... . 1111 1.2 Software Section .............................................. . 1112 1.2.1 Program Module Configuration ................................. . 1112 1.2.2 Program Module Functions .................................... . 1113 1.2.3 Program Module Sample Application (Main Program) ............... . 1114 1.3 Program Module Section ........................................ . 1116 1.3.1 Page Heading .............................................. . 1117 1.3.2 Function ................................................... . 1117 1.3.3 Arguments ................................................. . 1117 1.3.4 Libraries Required for Program Execution ........................ . 1118 1.3.5 Specifications .............................................. . 1119 1.3.6 Description ................................................. . 1120 1.3.7 PAD ...................................................... . 1123 1.4 Subroutine Section ............................................ . 1124 1.4.1 Page Heading .............................................. . 1125 1.4.2 Function ................................................... . 1125 1.4.3 Basic Operation ............................................. . 1125 1.4.4 Program Modules That Use This Function ........................ . 1126 1.4.5 PAD ...................................................... . 1126 1.5 Program Listing Section .......... , ............................. . 1127 1.5.1 Main Program Listing ........................................ . 1127 1.5.2 C Source Listing ............................................. . 1128 1.5.3 Output Object Listing of C Com pliler ............................ . 1131 I 1.5.4 Linkage Listing .............................................. . 1132 ~HITACHI 1099 1.6 Program Module Use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1135 1.7 Pad Symbols Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1137 1.8 Symbols...................................................... 1138 2. DARLINGTON TRANSISTOR DRIVE (LED DYNAMIC DISPLAY) . . . . . . . . .. 1139 2.1 Hardware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1139 2.1.1 Function.................................................... 1139 2.1.2 Microcontroller Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1139 2.1.3 Circuit Diagram .............................................. 1139 2.1.4 Pin Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1140 2.1.5 Hardware Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1141 2.2 Software Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1142 2.2.1 Program Module Configuration ................................ " 1142 2.2.2 Program Module Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1142 2.2.3 Program Module Sample Application (Main Program). . . . . . . . . . . . . . .. 1143 2.3 Program Module Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1144 2.4 Program Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1152 2.4.1 Main Program Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1152 2.4.2 C Source Listing . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1153 2.4.3 Output Object Listing of C Complier. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1154 2.4.4 Linkage Listing ............................................. " 1157 3. 8x4 KEY MATRiX ............................................... 1159 3.1 Hardware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1159 3.1.1 Function .................................................... 1159 3.1.2 Microcontroller Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1159 3.1.3 Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1160 3.1.4 Pin Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1161 3.1.5 Hardware Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1161 3.2 Software Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1162 3.2.1 Program Module Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1162 3.2.2 Program Module Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1162 3.2.3 Program Module Sample Application (Main Program). . . . . . . . . . . . . . .. 1163 ~HITACHI 1100 3.3 Program Module Description .................................... " 1165 3.4 Program Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1177 3.4.1 Main Program Listing .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1177 3.4.2 C Source Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1178 3.4.3 Output Object Listing of C Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1180 3.4.4 Linkage Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1185 4. EXTERNAL EXPANSION ......................................... 1187 4.1 Hardware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1187 4.1.1 Function.................................................... 1187 4.1.2 Microcontroller Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1187 4.1.3 Circuit Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1187 4.1.4 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1188 4.1.5 Hardware Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1189 4.2 Software Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1190 4.2.1 Program Module Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1190 4.2.2 Program Module Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1190 4.2.3 Program Module Sample Application (Main Program). . . . . . . . . . . . . . .. 1192 4.3 Program Module Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1194 4.4 Program Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... 1220 4.4.1 Main Program Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1220 4.4.2 C Source Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1222 4.4.3 Output Object Listing of Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1226 4.4.4 Linkage Listing ............................................. " 1232 APPENDIX A. C Program and Assembly Program Comparison .......................... 1235 ~HITACHI 1101 ~HITACHI 1102 FOREWORD The HD6301 series is composed of 8-bit single chip CMOS microprogrammed microcontrollers. The HD6301 series provides pipeline Control, halt, and memory-ready functions for processing data. This apprication note contains C language programs which are described using application functions routines as examples. In general, it is difficult to write a program in a high-level language like C which carries out low level functions, such as controling ports, timer interrupts, etc. However, this application note's program have been written in C, using mainly the hardware control functions listed above, and have been written to help users design hardware systems, employing specific circuit diagrams, timing charts and program modules. This application note also contains assembly language program descriptions, with functions equivalent to the C language programs. Please use these descriptions to compare the two languages. Caution: Test the application examples, in this application note for proper results before incorporating them into production operations systems. I ~HITACHI 1103 REFERENCES • HD6301 Series Application Notes (C Language) (ADJ-502-003) • HD6301XO, HD6303X Application Notes (Hardware) (68-3-11) • V AXNMS630 1C Compiler User's Manual (HS31VCLVIS) • C Language Manual (S999CLLlM) ~HITACHI 1104 SECTION 1. HOW TO USE APPLICATION NOTES This chapter describes the configuration for all system application examples in this application note. Each application example in this application note is divided into 5 sections, as shown in Figure 1-1. Hardware , ................. L ----;1 Hardware Description : : § ................................................................................................................................................................. ~ Function Microcontrolier Applications Circuit Diagram 1 : : : Memory Map 1 : Pin Functions : : : t Hardware Operation t ..............................................................................................................................................................................................................................................! : ............................................................................................................................................................................................................................................................................................ , Software ------!~ Software Description 1 Program Module Configuration: Program Module 1 1 : Functions: : Program Module Sample 1 · : Application (MAIN PROGRAM) : '............................................................................................................................................................................................................................. .. . ......................................................................................................................................................................................., Program Module~ Program Module Function 1 : Description t-- Arguments : : : · t-- Libraries Required for Program Execution : : . I-- Specifications t-- Description - r- Function : t-- Notes Detans' f- User Notes r- Variable : '- ~tgWCHART r- sa~~:riPtions : Application --Basic • : Operation : '....................................................................................................................................................................................................................... .. Subroutine ---~··s~·b~~~i;~~····································· ................................... ~ DeSCription -C Function Basic Operation : ·, ....................................................................................................................................................................................................................... . ... Pad Flowchart Program Listing ~ E .................................................................................................................................................................................... . --1 Program Listing Main Program Listing I : C Source Listing 1 Output Object Listing of C Compiler : Linkage Listing , ................................................................................................................................................................................................................ . . Figure 1-1. Application Example Configuration @HITACHI 1105 I. Hardware Describes the function, circuit diagram, and hardware operation of the HD6301 hardware example. 2. Software Describes the program module which controls the hardware in the hardware section example and shows the main program using all program modules. 3. Program Module Describes the program modules presented in the software section in detail program written in modular format allow more efficient system use. 4. Subroutine Describes the subroutines used in the above program modules. Refer to this section when necessary while using the program modules. 5. Program Listing Presents the sample application program listings for the above modules. A detailed explanation of all five sections follows. ~HITACHI 1106 1.1 Hardware Section 1.1.1 Function "Function" describes system specifications for the hardware used in the particular application (figure 1-2). 4.1.1 Function The external expansion application controls external memory and peripheral LSls using the HD6301 YO. It uses the HD6350 (ACIA) as an asynchronous serial interface with a console typewriter, It also controls a liquid crystal module H2571 and displays console typewriter input characters using the HD6321 (PIA). Figure 1-2. Function Section 1.1.2 Microcontroller Applications "Microcontroller Applications" describe the functions of the microcontroller, in the particular application (figure 1-3). 4.1.2 Microcontroller Applications This application interfaces with external LSls through an address bus, data bus, and control signals (RiW and E) using the HD6301 YO external expansion function. Figure 1-3. Microcontroller Applications I @HITACHI 1107 1.1.3 Circuit Diagram "Circuit Diagram" shows the circuit diagram for the hardware specified above (figure 1-4). Note: All the microcontrollers described in the application note use plastic DIPs. 4.1.3 Circuit Diagram Figure 4-1 is the application circuit diagram. Figure 4-1. External Expansion Circuit Diagram Figure 1-4. Circuit Diagram Section ~HITACHI 1108 1.1. 4 Memory Map Describes address decoding and system memory map for the application system (figure 1-5). (used in Section 4, "External Expansion" only.) 4.1.4 Memory Map Memories and peripheral LSls are allocated in external address space using an address decoder (HD74HCI38). Address lines A13, AI4 and AI5 are connected to pins A, B and C of the HD74HC138. Address space $8000-$FFFF is divided into 8k-byte units. Table 4-1 shows the system address decoding. Table 4-1. System Address Decoding HD74HC138 Input Output B A Gl G2A G2BC A14 A13 Y4 YS Y6 Y7 Address Allocation H L L L L L L H H H $8000-$9FFF RAM H L L L L H H L H H $AOOO-$BFFF PIA H L L L H L H H L H $COOO-$DFFF ACIA H L L L H H H H H L $EOOO -$FFFF ROM Figure 4-2 shows system memory map. $0000 1/0 Ports TIMER H06301XO internal register and $OOlF SCI internal address space. Not Used $0040 $OOFF $7FFF RAM (192 Bytes) Not Used J $8000 RAM OORNPORTA $ACOO CRA $AOOl $9FFF (HM6117) OORBIP RTB $AC02 $ACOO RB $A003 PIA (H06321) Not Used $BFFF $BFFF $COOO ACIA CTRUSTS $COOO (HD6350) TDR/RDR $COOl $OFFF $EOOO Not Used EPROM (HN27C64) $OFFF $FFFF Figure 4-2. System Memory Map Figure 1-5. Memory Map Section I ~HITACHI 1109 1.1.5 Pin Functions A table describes the pin functions for interfacing with external circuits (figure 1-6). 2.1. 4 Pin Functions Table 2-1 shows the pin functions at the interface between the HD6301XO and an 8-digit x 8-segment LED. Table 2-1. Pin Functions Active Pin Name Input/ Level Pin name Program (HD6301XO) Output (High or Function (LED) Label Low) P60 Output High Outputs digit data to DIOl P61 Output High 8-digit x 8-segment LED. DIG2 P62 Output High DIG3 P63 Output High DIG4 P6DTR P64 Output High DIGS P65 Output High DIG6 P66 Output High DIG7 P67 Output High DIG8 PlO Output Low Outputs segment data to a -- Pll Output Low 8-digit x 8-segment LED. b P12 Output Low a c P13 Output Low Ib d - fl g PlDTR P14 Output Low e ell c h PIS P16 Output Output Low Low d • f g P17 Output Low Segment Pattern h • " Active lever' in table 1 indicates the following: High logical 1 Low logical 0 logical 1 or logical 0 Figure 1-6. Pin Functions Section ~HITACHI 1110 1.1. 6 Hardware Operation Timing charts describe hardware operations required to control external circuits (figure 1-7). 4.1. 5 Hardware Operation Figure 4-3 shows the interface timing chan for the HD6301 YO and external memory (HN27C64, HM6117). --; E - HD6301YO ADDRESS X R/IT -~ Decoder delay time \ ~ l- CE tCE HN27C64 DE tACC l DSR & ...:HIt DATA (OUT) I-- ~coder delay time [~,.a, Data COl 2 tDSR tHR read tACC DATA (OUT) ~ HM6117 [~ twp Data write DATA (IN) f ( ~ tl1W tDR } - tAD: Address delay time tDSR: Data set-up time HD6301YO tHR: Data hold time IOW~ Data delav time tCE: CEOutput delay time tOE: OE Outout delay time HN27C64 IACC: Access time tOH: Data output hold time tAA: Address access time tC01,2: CE1 ,CE2 Output delay time I HM6117 tWP: WrHe pulse width tOW: Input data set time tDH: Input data hold time Figure 4-3. Interface Timing Chart for HD6301YO and External Memory Figure 1·7. Hardware Operation ~HITACHI 1111 1.2 Software Section 1.2.1 Program Module Configuration "Program Module Configuration" describes the program modules for controlling the hardware specified in the hardware section (figure 1-8). Each module in the program module configuration figure has module number (1-N) in the upper right hardcorner. The module number of the main assembly language program is O. 4.2.1 Program Module Configuration Figure 4-4 shows the program module configuration which displays data input from a console typewriter. using the circuit in Figure 4-1. EXPMN Main program 0 (Assembler language) Figure 4-4. Program Module Configuration Refer to Section 4.3 "Program Module Description" discusses these modules for details. Figure 1-8. Program Module Configuration Section ~HITACHI 1112 1.2.2 Program Module Functions "Program Module Functions" explains the functions of each program module presented in the program module configuration. "No." in the table matches the module number in the program module configuration (figure 1-9). 4.2.2 Program Module Functions Table 4-2 summaries the program module functions. Table 4·2. Program Module Functions Program Module Library No. Name Function Function Language o Main program EXPMN Initializes instructions, such as ORO, ASM LOS, and CLI, which do not exist in C. Calls expin function and main function Interrupt EXPINP Receives and processes IRQ interrupt ASM reception 2 Initialization expin Initializes global variables, t-IA, ACIA, C andLCD·II 3 Data processing main Displays key data, input from console C typewriter, on liquid crystal display (H2571) and prints the data on the console typewriter 4 Receive data expip Receives key data from the console C typewriter through an IRQ interrupt 5 LCD·II initialization expint Initializes LCD·II C 6 Display Character expdsp Displays characters on LCD C 7 Send data expout Sends data to console typewriter C Note: C: C Language Program ASM: Assembly Language Program Figure 1·9. Program Module Functions Section I ~HITACHI 1113 1.2.3 Program Module Sample Application (Main Program) "Program Module Sample Application (Main Program)" explains a sample program in flowchart format using the program module described in the program module configuration (figure 1-10). 4.2.3 Program Module Sample Application (Main Program) The flowchan in Figure 4-5 is an example of the execution sequence of the program module in Figure 4·4 when it displays key data input from a console typewriter on a liquid crystal display and prints the data on the console typewriter. ( EXPMN) Main program #$ FF ... SP I···············..··{ Initialize stack pointer Inijialize PIA. ACIA, LCD·II, and f-L--I_eXPin---'-II f·········, ..······{ global variables o . . . bit 1 1.. ·················-[ Enable interrupt After converting the key data input from the console typewrijer into ASCII code, 1-'--11 II[ ma-----,-,'" display the resuH on the liquid crystal display (H2571) and print the resun on the console typewrijer ( END ( EXPINP) IRQ interrupt routine ~II eXP---LJi P Execute 'expip' to receive data from the 11.................. -[ global console typewriter and store it in variable 'keydat' ( Return Figure 4-5. Program Module Flowchart Figure 1-10. Program Module Sample Application (Main Program) ~HITACHI 1114 Further figures described the flow of program modules shown in general flowchart of main program (figure 1-11). Figure 4·6 shows the execution sequence of C language program 'expin'. In 'expin', key data input from console typewriter is displayed on the liquid crystal display (H2571) and printed on the console typewriter. ( expin ) 1 Store function data in Clear global variable (0) I entry argument func o x 30 -+ tunc Select DORA of PIA Store entry mode data Ox 00 -+ * CRA I In entry argument entry o x 06 ..... entry Select part A of PIA as output o x If -+- CRA I expint function Select port A register Ox04-+*CRA I Set H2571 control signal Ox 02-+*PIRA I Master reset ACIA Ox 97 -+*CR Select OOR B of PIA Ox 00-+- CRB I Innialize ACIA Ox95-+-CR 1 startbn + 8bns 1 data + 1 stop bH, 16 Select port B of PIA RTS+O, TIE-O, RIE 31 as output o x If -+* OORB I Select port 5 bit 0 1 as IRa pin o x 7d -+ * PSCR ( Retum Figure 4·6. Program Module Flowchart Figure 1-11. Sample Application (Other Routines) I ~HITACHI 1115 1.3 Program Module Section The program module detailed description format is shown in figure 1-12. / Library Function: PAn Libn.fl Function: Description Librarv Function: Function Arguments Conlcnts Storage Locntion No. or n,.l~s Eo"" Retum Libraries Required for Program Execution l.ibrary Required/Not Required Smndard library Function C31.lm.OBJ NOlrequired Run-Time Routine C31RUN. ODI Required C3IRUNF. OBI Notrcquired Specifications ROM (bytes): RAM (bytes): Slack (bytes): No of cycles: Reentrant: Relocatnble: Inlt'mlplible: NOIe: Description 1- Function Details Argument Details: Example: Figure 1-12. Program Module Format ~HITACHI 1116 1.3.1 Page Heading Each page in this section is headed by the program modules name and the library function by which it is called (figure 1-12). 1.3.2 Function "Function" describes the program module functions (figure 1-13). Function The receive data module receives data from console typewriter and stores key data in global variable 'keydat'. Figure 1-13. Function Section 1.3.3 . Arguments "Arguments" describe both entry and return arguments for the program module (figure 1-14). • Contents: The contens of the arguments. • Storage location: Location of arguments (global variables). • No. of bytes: The argument length. Contents Storage Location No. of Bytes Entry Returns Received data keydat 2 (ASCII code) (global variable) Received data flag keydrf 2 (global variable) Figure 1-14. Arguments Section I ~HITACHI 1117 1.3.4 Libraries Required for Program Execution "Libraries Required for Program Execution" describes the libraries which must be linked for the program to execute (figure 1-15). Standard Library Functions (C31Lffi. OBI): Prior to using a program, the library functions and the subroutines used by the library functions must be linked. The library functions are stored in "C31Lffi, OBI". Run-Time Routines (C31RUN. OBI, C31RUNF. OBI): Run-time routines are called from the object programs, generated by the compiler, during execution. The following two mes are supplied: • C31RUN. OBI • C31RUNF. OBI Link "C31RUN. OBI" when only integers are used in the module or "C31RUNF. OBI" when integers and floating point numbers are used. These files should not both be linked. The module in this example does not use the standard library functions. C31Lffi. OBJ should not be linked, but run-time routine, C31RUN. OBJ should be linked. since it uses only integers. Library Required/Not Required Standard Library Function C31UB. OBI Not required Run-Time Routine C31RUN. OBI Required C31RUNF. OBI Not required Figure 1·15. Libraries Required for Program Execution Section ~HITACHI 1118 1.3.5 Specifications "Specifications" describes the program module specifications as follows (figure 1-16): • ROM (bytes): Amount of ROM used by thr program module. • RAM (bytes): Amount of RAM used by the program module. RAM used for stack is not included. • Stack (bytes): Size of the stack used by the program module. The stack area used by a subroutine called from a user program is not included. When a program module is executed. memory for the stack must be reserved in RAM. • No. of cycles: Maximum number of execution cycles required by the program module, calculated as follows: Execution time (s) = Number of cycles x Cycle time Cycle time (s) =4/(Extemal oscillator (Hz» • Reentrant: Indicates whether a program module has a structure which can be called from two or more routines at the same time. • Relocatable: Indicates whether a program module can be located in any memory space. • Interruptible: Indicates whether the CPU will continue with normal execution after servicing an interrupt routine. If not, inhibit interrupts before and after the program module is called. Specifications ROM (bytes): 48 RAM (bytes): 4 Stack (bytes): 0 No of cycles: 63 (Note) Reentrant: No Relocatable: No Interruptible: No Note: Ox indicates a hexadecimal number in C. Figure 1-16. Specifications Section I ~HITAaHI 1119 1. 3.6 Descri ption "Description" described the functions of the program module in detail and the precautions to follow (figure 1-17). Function Details: "Function Details" gives an execution example and detailed functions of the program module. User Notes: "User Notes" explains notes and limitations on executing the program module. Be sure to read these notes when using the program modules. Argument details: Global variable 'keydat' contains I-byte of key data (ASCII) from the console typewriter. Global variable 'keydrf is a flag indicating that data has been received. Table 4-3 shows flag functions. Example: Figure 4-8 shows an example of program module 'expip' execution. If key "a" on the console typewriter is pressed as shown in CD, the received data is put in the key data buffer and oxff is stored in 'keydrf as shown in (i). ~ - . - 0 x 61 ='a' && keydat<='z') keydat-=Ox20; f. Change lower case to upper *f keydrf=O; f. Clear flag of receive data *f .CR=Ox95; f. Set RTS=low .f outdat=dspdat=keydat; f. Set output data In area .f expout(); f. Transmit data to console .f expdsp(); f. Display characters on LCD-II .f Figure 1·30. C Language Module I ~HITACHI 1129 Program Module: The program module listing is divided into separate functions (figure 1-31): (a) Program module title (b) Library Function I·····················································........................*,/ 1* j. NAME: EXPIP (RECEIVE DATA) .j (a) I·····················································......................../ 1* j. j. ENTRY NOTHING II .j .j j. RETURNS: KEYDAT (RECEIVED DATA) .j j. : KEYDRF (RECEIVED FLAG) .j (b)~ I····················································· ........................ / 1* *1 if «.SRLl)!·O) ( II Test if data Is received _/ .CR-OxdS; j. Set RTS·hiCh .f keydat • IRDR: II Set receive data */ keydrf·Oxff: 1* Oxft if receive data Is set */ ·CR-Ox95 : II Set RTS-low */ Figure 1·31. Program Module Common Subroutine: Next, common subroutines used in the program module are listed (figure 1- 32): (a) Subroutine title (b) Library Function I ••••••••••••••••••••••••••••••••••••••••••••••••••• •••••••••••••••••••••••••• / { /- */ r............................................................................., (a)~: NAME: EXPIN (INITIALIZE PIA.ACrA AND LCD-Z) :~ / (b) Pin () outdat-dspdnt .. keydrr .. keydn t-tncnt .. func"cntry.O: /_ Int tlal1ze ./ .eRA "OxOO; II Select data direction register A II IOOnA-Oxff: /. Select port A os output . / ·,eRA "Ox04: /. Select peripheral register A II .PIRA .. Ox02: /. Set RS .. O, R/W-I, E-O .1 .cnn "OxOO: IODRO .. Oxff: .CRu .Ox04: *, /* Select data direction register 0 -/ ,* II Select port n as output Select peripheral register D It fUnc·Ox30: entry"Ox06: explnt(): 'I II Set function data ' / Set entry mode data II II Initialize LCD-II ./ setins(OxOe); II Set instructlon to LCD-II -/ .CR .. Ox97; I' Master reset of ACIA II 'CR.Ox95: II Initialize AeIA -/ .PSCR .. Ox7d; II Initialize port 6 II Figure 1·32. Common Subroutines ~HITACHI 1130 1.5.3 Output Object Listing of C Compiler 6301 C compiler outputs an object code listing in 6301 assembler language (figure 1-33): (a) Macro definition generated by the compiler (b) Global variable definition (c) Compilation result (assembly language output listing) of a C language source program CP/M-6SK 6301/6801/6800 CROSS MACROASSEMBLER VI.2 ••• ERR SEQ LaC OBJECT PROGRAM EXPC 00001. NAM EXPC 00002 OPT REL 00003 MSEX MACR 00004 CLRA 00005 T5TB 00006 8PL \.0 00007 COMA 00008 \.0 EQU • 00009 ENDM 00010 MLBRA MACR 00011 JMP \0 00012 ENDM 00013 MLBSR MACR 00014 JSR \0 00015 ENDM (a) 00016 MLBEQ MACR 00017 BNE \. a 00018 JMP \0 00019 \.0 EQU • 000'10 E~DM OOOS'l 00062 MLBCS Bce \.0 MACR J 00063 JMP \0 00064 \.0 EQU • 00065 ENDM 000668 0000 BSCT 000678 0000 0002 A OUTDAT BSZ 00068R 0002 RSCT 000698 0002 0002 A DSPDAT BSZ 000708 0004 BSCT 000718 0004 0002 A KEYDRF BSZ 000720 0006 BSCT 000738 aD06 0002 A KEYOAT BSZ (b) 000748 0008 BSCT 000758 0008 0002 A TNCNT BS2 000768 DODA BSCT 000778 OODA 0002 A FUNC BS2 0007B8 OOOC 8SCT 000798 OOOC 0002 A ENTRY BS2 OOOBOP 0000 PSCT OOOB1P 0000 20 31 0033 BRA OOOB2P 0002 DC B . SA003 lOD · $A002l KEYORF O' 00083P 0004 27 20 0033 BEQ · SA004 OOOB4P 0006 DE 06 B LOX KEYDAT OOOBSP OOOB 8C 0061 A CPX #97 C 000B6P 0008 20 OE 0018 BLT .$AOOS , ( ) 00087P 0000 DE 06 B LDX KEYDAT I DOOSBP OOOF BC 007A A CPX #122 : OOOS9P 0012 2E 07 0018 BGT · SAOOS I 00090P 0014 DC 06 B LDD KEYDAT : nnn'll0 nn,o:I 0'1 Figure 1-33. Output Object Listing of C Compiler ~HITACHI 1131 1.5.4 Linkage Listing Linkage Command Listing: The linkage command listing is a sample command main assembly program and a C language sequence for linking and executing a program (figure 1-34): Divide into sections, taking the system memory map into consideration • STRP Program Section • STRB Base Section • STRD Data Section a> Output map listing and symbol listing using OPT command @ Input EXEC command to execute linkage editor ••• HMCS6800 CROSS LINKAGE EDITOR VER 1.2 LOAD=B: EXPMN. OBJ • B: EXPC. OBJ • C31RUN. OBJ .....•.••. I< TCSR1 ~ Wcxk >I< OCR1 + 1250 - - . >I< OCR1 Turn off the entire display for a fixed period before displaying the next data. o ~* P6DRT Output segment data to port 1 segd (count) ------- * P1DTR Output digit data to port 6 deed (count) ~ >I< P6DTR Test if counter indicating Initialize counter segment data and digit indicating segment data pair equals 0 data and digit data count = 0 pair7 ~ count Decrement counter indicating segment data and digit data pair Return Figure 2-12. Drive LED Module PAD ~HITACHI 1151 2.4 Program Listing 2.4.1 Main Program Listing ••• CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER V1.2 ••• ERR SEQ LOC OBJECT PROGRAM 00001 .................................................... _- ...... 00002 • • 00003 • MAIN PROGURAM : LEDMN • 00004 00005 00006 ... _--_ ...... -.. -•.............• __ ........ _-_ ....... -......• •_ OPT REL 00007 XREF PSCT:MAIN,PSCT:LEDINT 00008P 0000 8E OOFF A LEDMN LDS #$FF Set stack pointer 00009P 0003 BD 0000 A JSR LEDINT Initialize variables 00010P 0006 OE CLI Enable interrupt OOOllP 0007 20 FE 0007 PEND BRA PEND End of program 00012 ......................... __ .................... __ ........... 00013 • • 00014 • NAME : MAIN (DRIVE LED) • 00015 00016 00017 ...... • • • _.................... _- ............................... • 00018 • ENTRY SEGD (DISPLAY DATA) • 00019 • RETURNS NOTHING • 00020 00021 00022P 0009 BD 0000 A .........................................................*.- • LEDSP JSR MAIN Drive LED • 00023P OOOC 3B 00024 00025 ...•.....•....•...•...........................•*------......• • RTI 00026 • VECTOR ADDRESS • 00027 00028 ....•............................ -....................... _--• • 00029 00030A FFEA • ORG $FFEA 00031 • 00032A FFEA 0000 P FDB LEDMN IRQ2 00033A FFEC 0000 P FDB LEDMN CMI 00034A FFEE 0000 P FDB LEDMN TRAP 00035A FFFO 0000 P FDB LEDMN SIO 00036A FFF2 0000 P FDB LEDMN TOI 00037A FFF4 0009 P FDB LEDSP OCIl 00038A FFF6 0000 P FDB LEDMN ICI 00039A FFF8 0000 P FDB LEDMN IRQ1 00040A FFFA 0000 P FDB LEDMN SWI 00041A FFFC 0000 P FDB LEDMN NMI 00042A FFFE 0000 P FOB LEDMN RES 00043 • .-.- 00044 TOTAL ERRORS 00000--00000 END ~HITACHI 1152 2.4.2 C Source Listing *1 I********************DECLARATION OF DEFINE--------_._._ •••• _--*-------_._-----/ 1* *1 #define PIDTR «char*)Ox2) I*Port 1 data register*1 #define TCSRl «char*)Ox8) I*Timer control status register*1 #define OCRI «int*)Oxb) I*Output compare register*1 #define PBDDR «char*)OxlB) I*Port B data direction register*1 #define PBDTR ( ( char- ) Oxl 7) I*Port B data register*1 1* /*****.* ••• **********DECLARATION OF GLOBAL VARIABLES**************************I 1* *1 static direct char decd[8)={l28,B4,32,lB,8,4,2,l}; I.Digit data*1 I*Segment data*1 static direct char segd[8)={Oxf8,Ox82,Ox92,Ox99,OxbO,Oxa4,Oxf9,OxcO}; static direct int count; I*Segment,Dlgit counter.1 1-*···_· __ ····_------------_·-·_----*------_· __ ······- ._._._-_._._----_._ .. _._/* I 1* 1* MAIN ROUTINE : MAIN (DRIVE LED) *1 1* *1 1----·_·_----------------------------------·-·_---_·_· ._._--------------------/ 1* *1 1* ENTRY SEGD (DISPLAY DATA) *1 I. RETURNS NOTHING *I 1* *1 1·-·-····_-_·_·_---------------_·_·_--_·_·_-------_·_· -*------_.-.--_._._._._-/ main( ) { char work; work= *TCSRl; I*Timer controller access only *1 .OCR1 +=1250; I*Set interrupt every 1.25 ms*1 *PBDTR = OxO; I*Turn off display*1 *PlDTR =segd[count); I*Output segment data*1 *PBDTR=decd[count); I*Output digit data*1 if(count==O) I*Display 8-digit data?*1 count=7; I*Initialaize counter*1 else count--; I*Decrement segment,digit counter*1 /** •• **********.**********.*.*.**.**.****.**.***~***** -----------_.-._._--_._-/ 1* *1 1* NAME: LEDINT (INITIALIZE) *1 1* *1 1--···-------*_···_-_···_--_· ledint () __ ···_···········_-****·· .. **** •••••• * •• ** •• **.*./ { count=7; I*Initialaize digit,segment counter*1 *PBDDR=Oxff; I*Select portB as output*1 *TCSRl=Ox8; I*Set timer*1 *OCRl=l250; I*Set 0 in portB*1 I ~HITACHI 1153 2.4.3 Output Object Listing of C Compiler ••• CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER V1.2 ••• ERR SEQ LOC OBJECT PROGRAM LEDSP 00001 NAM LEDSP 00002 OPT REL 00003 MSEX MACR 00004 CLRA 00005 TSTB 00006 BPL \.0 00007 COMA 00008 \.0 EQU • 00009 ENDM 00010 MLBRA MACR 00011 JMP \0 00012 ENDM 00013 MLBSR MACR 00014 JSR \0 00015 ENDM 00016 MLBEQ MACR 00017 BNE \.0 00018 JMP \0 00019 \.0 EQU • 00020 ENDM 00021 MLBNE MACR 00022 BEQ \.0 00023 JMP \0 00024 \.0 EQU • 00025 ENDM 00026 MLBGT MACR 00027 BLE \.0 00028 JMP \0 00029 \.0 EQU • 00030 ENDM 00031 MLBGE MACR 00032 BLT \.0 00033 JMP \0 00034 \.0 EQU • 00035 ENDM 00036 MLBLT MACR 00037 BGE \.0 00038 JMP \0 00039 \.0 EQU • 00040 ENDM 00041 MLBLE MACR 00042 BGT \.0 00043 JMP \0 00044 \.0 EQU • 00045 ENDM 00046 MLBHI MACR 00047 BLS \.0 00048 JMP \0 00049 \.0 EQU • 00050 ENDM 00051 MLBLS MACR 00052 BHI \.0 00053 JMP \0 00054 \.0 EQU • 00055 ENDM 00056 MLBCC MACR • HITACHI 1154 ... CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER Vl. 2 ••• ERR SEQ LOC OBJECT PROGRAM LEDSP 00057 BCS \.0 00058 JMP \0 00059 \.0 EQU * 00060 ENOM 00061 MLBCS MACR 00062 BCC \.0 00063 JMP \0 00064 \.0 EQU * 00065 ENOM 000661' 0000 PSCT 00067P 0000 80 A DECD FCB -128 000681' 0001 40 A FCB 64 000691' 0002 20 A FCB 32 000701' 0003 10 A FCB 16 000711' 0004 08 A FCB 8 000721' 0005 04 A FCB 4 000731' 0006 02 A FCB 2 000741' 0007 01 A FCB 1 00075P 0008 PSCT 00076P 0008 F8 A SEGO FCB -8 000771' 0009 82 A FCB -126 000781' OOOA 92 A FCB -110 000791' OOOB 99 A FCB -103 00080P OOOC BO A FCB -80 000811' OOOD A4 A FCB -92 000821' OOOE F9 A FCB -7 000831' OOOF CO A FCB -64 00084B 0000 BSCT 00085B 0000 0002 A COUNT BSZ 2 00086P 0010 PSCT 00087P 0010 34 MAIN DES 000881' 0011 CE 0008 A LOX #8 000891' 0014 E6 00 A LOAB O,X 00090P 0016 30 TSX 000911' 0017 E7 00 A STAB O,X 000921' 0019 CE OOOB A LOX #11 000931' 001C EC 00 A LOO O,X 00094P 001E C3 04E2 A AOOO #1250 000951' 0021 ED 00 A STO O,X 000961' 0023 CE 0017 A LOX #23 000971' 0026 4F CLRA 00098P 0027 5F CLRB 000991' 0028 E7 00 A STAB O,X 00100P 002A CE 0002 A LOX #2 00101P 0020 3C PSHX 00102P 002E CC 0008 P LOO #SEGD 001031' 0031 D3 00 B AODO COUNT 00104P 0033 18 XGOX 001051' 0034 E6 00 A LOAB O,X 001061' 0036 38 PULX 001071' 0037 E7 00 A STAB O.X 00108P 0039 CE 0017 A LDX #23 00l09P 003C 3C PSHX OOllOP 0030 CC 0000 P LOD #OECD 001111' 0040 03 00 B AODD COUNT 001121' 0042 18 XGOX I ~HITACHI 1155 *** CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER V1.2 *** ERR SEQ LOC OBJECT PROGRAM LEOSP 001l3P 0043 E6 00 A LOAB O,X 001l4P 0045 38 PULX 001l5P 0046 E7 00 A STAB O,X 001l6P 0048 OC 00 B LOO COUNT 001l7P 004A 26 05 0051 BNE .$A002 001l8P 004C CC 0007 A LDD #7 001l9P 004F 20 05 0056 BRA .. 1 00120P 0051 DC 00 B .SA002 LOD COUNT 00121P 0053 C3 FFFF A AOOO #-1 00122P 0056 DO 00 B .. 1 STD COUNT 00123P 0058 31 .$A003 INS 00124P 0059 39 RTS 00125P 005A PSCT 00126P 005A CC 0007 A LEDINT LDO #7 00127P 005D DO 00 B STO COUNT 00128P 005F CE 0016 A LDX #22 00129P 0062 CC OOFF A LOO #255 00130P 0065 E7 00 A STAB O,X 00131P 0067 CE 0008 A LDX #8 00132P 006A CC 0008 A LDD #8 00133P 006D E7 00 A STAB O,X 00134P 006F CE OOOB A LDX #11 00135P 0072 CC 04E2 A LDD #1250 00136P 0075 ED 00 A STO O,X 00137P 0077 39 RTS 00138 XDEF LEOINT 00139 XOEF MAIN 00140 END **_. TOTAL ERRORS 00000--00000 ~HITACHI 1156 2.4.4 Linkage Listing *** IIMCS6800 CROSS LINKAGE EDITOR VER 1. 2 *** LOAD=B:LEDMN.OBJ,B:LEDSP.OBJ,C31RUN.OBJ STRP=$FOOO STRB=$60 STRD=$40 OPT=MAP,SYM EXEC *** HMCS6800 CROSS LINKAGE EDITOR VER 1.2 *** *** UNDEFINED SYMBOLS *** NAME SECTION MODULE NAME .ERROR ( ) UNDEFINED SYMBOL = 1 (Note) Note: There is an UNDEFINED SYMBOL=l (library function, ERROR) in the link infonnation but it does not influence the execution of this program. The library function or run-time routines call the ERROR service routine when 0 is used as a divisor in division or modulo operations. Strictly speaking, the user should create an ERROR function. However it is never used in this program, so it is just displayed as an UNDEFINED SYMBOL. *** HMCS6800 CROSS LINKAGE EDITOR VER 1. 2 *** *** MAP LIST *** ** SECTION LOAD MAP SECTION SIZE START END COMMON-SIZE A 0016 FFEA FFFF B 0002 0060 0061 0000 C 0000 D 0004 0040 0043 0000 P 0657 1'000 F656 0000 ** MODULE LOAD MAP NAME BSCT DSCT PSCT FOOO LEDSP 0060 FOOD 0040 F085 ** COMMON LOAD MAP NAME SECTION SIZE START COMMON = 0 I ~HITACHI 1157 *** HMCS6800 CROSS LINKAGE EDITOR VER 1. 2 *** *** DEFINED SYMBOLS *** NAME SECTION START MODULE NAME .$DADD P F656 ( ) .$DCMP P F656 ( ) .$DDEC P F656 ( ) .$DDIV P F656 ( ) .$DINC P F656 ( ) .$DMOV P F656 ( ) .$DMUL P F656 ( ) .$DNEG P F656 ( ) .$DSTK P F656 ( ) .$DSUB P F656 ( ) .$DTOF P F656 ( ) .$DTOI P F656 ( ) .$DTOL P F656 ( ) .$DTST P F656 ( ) .$FDEC P F656 ( ) .$FINC P F656 ( ) .$FMOV P F656 ( ) .$FREG D 0040 ( ) .$FTOD P F656 ( ) .$FTST P F656 ( ) .$IASL P FOFA ( ) .$IASR P F10F ( ) . $IDIV P FOBC ( ) .$IMOD P F139 ( ) .$IMUL P F085 ( ) .$lTOD P F656 ( ) .$ITOL P F39A ( ) .$LADD P F1AC ( ) .$LAND P F2AF ( ) .$LBIT P F47D ( ) .$LCMP P F33C ( ) .$LCPL P F37E ( ) .$LDEC P F3C8 ( ) .$LDIV P F260 ( ) .$LINC P F3B8 ( ) .$LMOD P F287 ( ) .$LMOV P F188 ( ) .$LMUL P FlOE ( ) .$LNEG P F369 ( ) .$LOR P F2CA ( ) .$LSHL P F300 ( ) .$LSHR P F31E ( ) .$LSTK P F3D8 ( ) .$LSUB P F1C5 ( ) .$LTOD P F656 ( ) .$LTST P F3F3 ( ) .$LXOR P F2E5 ( ) .$SBIT P F5AO ( ) .$SW1 P F5E8 ( ) .$SW2 P F617 ( ) .$UDIV P FOD8 ( ) .$ULSR P F124 ( ) .$UMOD P F167 ( ) *** HMCS6800 CROSS LINKAGE EDITOR VER 1.2 --* NAME SECTION START MODULE NAME .$UTOD P F656 ( ) .$UTOL P F3AB ( ) LEDINT P F067 ( LEDSP ) MAIN P FOlD ( LEDSP ) DEFINED SYMBOL = 57 ~HITACHI 1158 SECTION 3. 8 X 4 KEY MATRIX 3.1 Hardware Description 3.1.1 Function The key matrix routine scans an 8 x 4 key matrix using the HD6301XO. It converts the key data into ASCII (A-Z, 1-6). If two keys are pressed simultaneously, the data is invalid. 3.1.2 Microcontroller Applications 1. The interrupt routine is executed every 8 ms by the built-in 16-bit programmable timer (timer 1) and output compare interrupt 1 (OCIl). 2. The interrupt routine executes a key scan outputting a strobe signal from port 6. 3. The interrupt routine prevents key chatter errors. 4. The key scan strobe signal is controlled by changing the I/O direction of the port 6 data direction register (DDR). A diode is not necessary to prevent output signal collision since all ports that do not output a strobe signal are input ports (high-impedance state). ~HITACHI 1159 3.1. 3 Circuit Diagram Figure 3-1 is the application circuit diagram. MCU +5 V HD6301XO +5 V 4 MPO 5 MPI 8 NMI 25 KRO 7 STBY P60 33 KRI 22 pF 2 Vce P61 26 f~'D 3 XTAL P62 27 KR2 EXTAL 22 pF KR3 +5 v P63 28 B C E F G H ' =_ ____'KCO KCl KC2 KG3 KG4 KG5 KG6 P30,.?8 P31r=5:..!.7_ _ _ ____' KG~/ P32r5~6~---______~ P331-"5~5~______________~ P34~5~4~------------------~ P35r5~3~--------_________________' P36r5~2~-----------------------------' P37~5~1~------------------------------~ Figure 3-1. Key Scan Control Circuit ~HITACHI 1160 3 .1.4 Pin Functions Table 3-1 shows the pin functions at the interface between the HD6301XO and the key matrix. Table 3-1. Pin Functions Pin Name Input/ Active Level Pin Name Program (HD630IXO) Function Output (High or Low) (Key matrix) Label P63 8W~~t Low Outputs strobe for KR3 P6DTR bntPtut/ 8 x 4 key matrix P62 tgut Low KR2 retrieval. P61 utJ bntPtQul Low KR1 P60 lrJl~~t Low KRO P30 InEut KCO P3DTR Inputs 8 x 4 key P31 InEut matrix key data. KC1 P32 In~ut KC2 P33 InEut KC3 P34 In~ut KC4 P35 In~ut KC5 P36 InEut KC6 P37 Input KC7 3.1.5 Hardware Operation The program prevents errors caused by key chatter (figure 3-2). Key input signal '1M '-y--J Chatter CD First key data I I I ~ Key fetch timing (Timer interrupt) G) ® G) ® Second key data CD® G) G) Third key data Key input OFF r decision + Test for key input Figure 3-2. The key input signal is sampled every 8 ms. Chatter Prevention Timing If three consecutive key input signals are the same, the key input data is defmed. If two or fewer signals are the same, the key input data is not defined, assuming that chatter has occurred. I ~HITACHI 1161 3.2 Software Description 3.2.1 Program Module Configuration Figure 3-3 shows the program module configuration for executing a key scan of an 8 x 4 key matrix. K84MN Main program 0 (Assembler language) Figure 3-3. Program Module Configuration Refer to Section 3.3, "Program Module Description" discusses these modules for details. 3 .2.2 Program Module Functions Table 3-2 summaries the program module functions. Table 3-2. Program Module Functions Program Module Library No. Name Function Function Language 0 Main program K84MN Initializes instructions, such as ORG, ASM LDS, and CLI, which do not exist in C. Calls K84int function 1 Interrupt K84SCN Receives and process OCI 1 interrupt ASM reception 2 Initialization K84int Initializes global variables, port, and C timer 3 Key scan K84san Converts key data from 8 x 4 key matrix C into ASCII Note: C: C Language Program ASM: Assembly Language Program ~HITACHI 1162 3.2.3 Program Module Sample Application (Main Program) The flowchart in figure 3-4 is an example of an 8 x 4 key matrix key scan performed by the program module in figure 3-3. The main program in Figure 3-4 calls the C language module and demonstrates storing ASCII in global variable 'keyset' main program ~#_$_F_F_. __ S_P-l''''''''''''''''''''''''''''[ Initi.alize stack pointer Initialize global variables and timer used 1-I-__k_8_4_in_t_....L.J ............................ [ in program module 'main', K84SCN t-_O_. __B_it_I-.-I............................ { Enable interrupt Convert key data from 8 x 4 key matrix main ..... { into ASCII OCI 1 interrupt routine C Language program, 'k84 san' using the k84san .............. [ OCI 1 interrupt Execute 8 x 4 key matrix key scan in k84san Fugure 3·4. Program Module Flowchart I ~HITACHI 1163 The C Language Program 'K84int ' (figure 3-5) initializes the timer, port, and global variables. ( k84int Initialize timer and port 6 Ox8 • '" TCSR1 Ox 0 • '" P6DTR o x 1f40 • '" OCR1 Initialize global variables ( Return Figure 3-5. Program Module Flowchart ~HITACHI 1164 The execution sequence of the C Language Program 'main' decides whether a key has been pressed (figure 3-6). If a key has been pressed, K84san converts the scanned data, into ASCII and store the result in grobal variable 'keyset'. ( main Tes," key has been depressed keyonf! = 1 ,< Yes No Convert key number into ASCII Return Store ASCII code in keyset keydat .... keyset Clear flag testing for key press keyonf = 0 Figure 3-6. Program Module Flowchart 3.3 Program Module Description The following pages describe the key Scan Subroutine. I ~HITACHI 1165 Key Scan Module Library Function: K84san Function The key scan module scans an 8 x 4 key matrix and stores key scan data in global variable keydat. Arguments Contents Storage Locaton No. of Bytes Entry Returns key data keydat 1 (global variable) key data keyonf 1 Indicator (global variable) Libraries Required for Program Execution Library Required/Not Required Standard Library Function C31LIB. OBI Not required Run-Time Routine C31RUN. OBI Required C31RUNF. OBI Not required Specifications ROM (bytes): 247 RAM (bytes): 16 Stack (bytes): 8 No of cycles: 1115 Reentrant: No Relocatable: No Interruptible: Yes @HITACHI 1166 Key Scan Module Library Function: K84san Description Function Details Argument Details: Global variable 'keydat' contains key scan data. Global variable 'keyonf indicates that program module K84san is done. Flag functions are shown in table 3-3. Table 3-3. Keyonf Flag Variable Name Condition Indicates Keyonf o Key scan data is not stored in global variable 'keydat' 1 Key scan has executed correctly and the key scan data has been stored in global variable 'keydat' I ~HITACHI 1167 Key Scan Module Library Function: K84san o Key ",essed { Key No.4 has been pressed (In Figure 3-1 of Hardware Description) b15 keydat bO { keydat 1-: - : 0: 41 ® arguments Return b15 keydat bO keyonf 1-: -: 0 : 1 1 Figure3-7. Program Module 'K84san' Execution Example Example: Figure 3-7 showns an example of program module 'K84san' stoves execution. If a key in - HD6301 XO internal register and $001F SCI internal address space. Not Used $0040 RAM $OOFF (192 Bytes) $7FFF Not Used $8000 DORA/PORTA $AOOO RAM CRA $A001 $9FFF (HM6117) DDRB/PORTB $A002 $AOOO CRB $A003 PIA (HD6321) Not Used $BFFF $BFFF $COOO ACIA CTRUSTS $COOO (HD6350) TDR/RDR $C001 $DFFF $EOOO EPROM Not Used (HN27C64) $DFFF $FFFF Figure 4-2. System Memory Map ~HITACHI 1188 4.1. 5 Hardware Operation Figure 4-3 shows the interface timing chart for the HD6301 YO and external memory (HN27C64, HM6117). ~ E HD6301YO ADDRESS R/TJ tAD Decoder delay time CE tCE RN27C64 DE '{ tOR "DSR tACC "OF. ~ DATA (OUT) Decoder delay time I--- Data {"PC<, cCOl 2 tAce tDSR [HR read DATA ~ 1IM6117 (OUT) twp write{ '.c" VIE DATA (IN) } ,"J }- tDR tAD: Address delay time tDSR: Data set-up time HD6301YO tHR: Data hold time tOW· Data delav time tCE: CE Output delay time tOE: OE Outout delay time HN27C64 tACC: Access time tOH: Data output hold time tAA: Address access time tC01,2: CE1 ,CE 2 Output delay time HM6117 tWP: Write pulse width tDW: Input data set time tDH: Input data hold time Figure 4-3. Interface Timing Chart for HD6301YO and External Memory @HITACHI 1189 4.2 Software Description 4.2.1 Program Module Configuration Figure 4-4 shows the program module configuration which displays data input from a console typewriter, using the circuit in Figure 4-1. EXPMN Main program 0 (Assembler language) expin Initialization , ,, expip Receive data \. .............................................................................................................................................................................................................................................................. . Figure 4-4. Program Module Configuration Refer to Section 4.3 "Program Module Description" discusses these modules for details. 4.2.2 Program Module Functions Table 4-2 summaries the program module functions. ~HITACHI 1190 Table 4·2. Program Module Functions Program Module Library No. Name Function Function Language 0 Main program EXPMN Initializes instructions, such as ORG, ASM LDS, and CLI, which do not exist in C. Calls expin function and main function 1 Interrupt EXPINP Receives and processes IRQ interrupt ASM reception 2 Initialization expin Initializes global variables, PIA, ACIA, C and LCD-II 3 Data processing main Displays key data, input from console C typewriter, on liquid crystal display (H2571) and prints the data on the console typewriter 4 Receive data expip Receives key data from the console C typewriter through an IRQ interrupt 5 LCD-II initialization expint Initializes LCD-II C 6 Display Character expdsp Displays characters on LCD C 7 Send data expout Sends data to console typewriter C Note: C: C Language Program ASM Assembly Language Program I ~HITACHI 1191 4.2.3 Program Module Sample Application (Main Program) The flowchart in Figure 4-5 is an example of the execution sequence of the program module in Figure 4-4 when it displays key data input from a console typewriter on a liquid crystal display and prints the data on me console typewriter. Main program #$ FF .... SP ................... { Initialize stack pointer Initialize PIA, ACIA, LCD-II, and expin .................. { global variables o .... bit 1 .................... [ Enable interrupt ~~;" ..... .." ,,[ After converting the key data input from the console typewriter into ASCII code, display the result on the liquid crystal display (H2571) and print the result on the console typewriter IRQ interrupt routine Execute 'expip' to receive data from the l-'---exP_i P ---L.J • • • • • • • • •• { console typewriter and store it in global variable 'keydat' Figure 4-5. Program Module Flowchart ~HITACHI 1192 Figure 4-6 shows the execution sequence of C language program 'expin'. In 'expin', key data input from console typewriter is displayed on the liquid crystal display (H2S71) and printed on the console typewriter. expin 1 Store function data in Clear global variable (0) entry argument func o x 30 ~ lunc Select DORA of PIA Store entry mode data o x 00 ~ * CRA in entry argument entry o x 06 ~ entry Select part A of PIA as output o x If ~* CRA expint function Select port A register Ox 04 ~*CRA Set H2571 control Signal Ox 02 ~ * PIRA Master reset ACIA Ox97~*CR Select OOR B of PIA o x OO~ * CRB Initialize ACIA Ox95~*CR 1 start bit + 8 bits 1 data + 1 stop bit, rr Select port B of PIA RTS +0, TIE= 0, RIE = 1 as output o x If ~* OORB Select port 5 bit 0 1 as IRQ pin o x 7d ~ * PSCR Return Figure 4·6. Program Module Flowchart I ~HITACHI 1193 Figure 4-7 shows the execution sequence of C language program 'main'. In 'main', key data input from console typewriter is displayed on the liquid crystal display (H2571) and printed on the console typewriter. main ¢O Yes Loop while input Test' k"l' dala ( Test if input data data is found has been is lowercase or Convert lowercase ~ while (1) received uppercase into uppercase keydrf ! = 0 keydat > = 'a' && keydat -= 20 =0 keydat < = 'z' e Return Clear key data No received flag keydrf = 0 - Set signal RTS of ACIAlow Ox 95 ~ * CR Store outdat in dspdat and keydat outdat-C:dsPdat keydat expout function expdsp function Figure 4-7. Program Module Flowchart 4.3 Program Module Description The following pages describle the external expansion modules. ~HITACHI 1194 1. Receive Data Module Library Function: expip Function The receive data module receives data from console typewriter and stores key data in global variable 'keydat'. Arguments Contents Storage Location No. of Bytes Entry Returns Received data keydat 2 (ASCII code) (global variable) Received data flag keydrf 2 (global variable) Libraries Required for Program Execution Library Required/Not Required Standard Library Function C31LIB. OBJ Not required Run-Time Function C31RUN.OBJ Required C31RUNF. OBJ Not required Specifications ROM (bytes): 48 RAM (bytes): 4 Stack (bytes): 0 No of cycles: 63 (Note) Reentrant: No Relocatable: Interruptible: No No Note: Ox indicates a hexadecimal number in C. I ~HITACHI 1195 1. Receive Data Module Library Function: expip Description Function Details Argument details: Global variable 'keydat' contains I-byte of key data (ASCII) from the console typewriter. Global variable 'keydrf is a flag indicating that data has been received. Table 4-3 shows flag functions. Example: Figure 4-8 shows an example of program module 'expip' execution. If key nan on the console typewriter is pressed as shown in CD, the received data is put in the key data buffer and oxff is stored in 'keydrf as shown in (i). ~HITACHI 119!;l 1. Receive Data Module Library Function: expip Q ______ 0 x 61 a: press ~ b15 keydat bO Global variable 'keydat' 1 byte data 1-: -: 6 : 11 ® Result { ('a' : 0 x 61) b15 keydrf bO Global variable 'keydrf' o x ff 1-: -: f : f I Figure 4-8. Program Module expip Execution Example Table 4-3. Flag Functions Variable Name Flag Indicates Keydrf OxOO No data has been received Oxff Data has been received and stored in buffer User Notes 1. Initialize ACIA because ACIA is controlled by the microcontroller external extension. After initialization ACIA can receive data from the console typewriter. 2. Clear bit I and enables interrupt for IRQ interrupt. Variable Description The global variables are stored in static memory (figure 4-9). Variable name RAM Description b15 bO IJ . ---I~ Contains received data flag keydat Contains key data buffer for received data keydrf Figure 4-9. Global Variable Storage ~HITACHI 1197 1. Receive Data Module Library Function: expip Sample Application After ACIA is initialized and the interrupt is enabled, an IRQ, interrupt initiates program module 'expip' execution (figure 4-10), * CR Ox 97; } ...... Initialize ACIA * CR Ox 95; Select bit 0 of port 5 as the IRQ, * P5CR Ox 7d; } ...... interrupt pin Figure 4-10. Sample Application Basic Operation Figures 4-11 and 4-12 show ACIA control. Figure 4-11 shows ACIA initialization. Figure 4-12 shows now received data is read after an interrupt. Note that this control method applies to the system in Figure 4-1 and memory map in Figure 4-2 . ....O_x_97_--.- _ _*_C_R........................... [ ACIA Master reset Initialize ACIA ....o_x_95_--.- _ _*_C_R........................... [ (4800 bps, 1 start bit + 8 data bits + 1 stop bit, enables interrupt during data reception) Figure 4-11. ACIA Control (Initialization) ~HITACHI 1198 1. Receive Data Module Library Function: expip Test bit 0 (RDRF) of status register to determine whether the ACIA has received data or not (RDRF = 1: data has been received). =1 Test if bit o or status ( o x d5 ~ * CR /--------' . ...... I [ Set signal RTS of ACIA to high to prohibit sending data from console typewriter register (SR) is 1 ¢ 1 * RDR ~ keydat I. . . . [ Re~dinput data from received data register Figure 4-12. ACIA Control (Receiving Serial Data) When data reception has been completed, set signal RTS to high to prohibit next data transfer. Finally, store received data from RDR of ACIA in key data buffer. ~HITACHI 1199 1. Receive Data Module Library Function: expip PAD C ex pip *0 T.s," data ,,,,.pHon ( Set signal RTS to has been completed high ( * SR & 1) ! = 0) o x d5 --.- * CR =0 Store received data in key data buffer * RDR --.- keydat Set flag indicating Ox ff --.- data received keydrf Set signal RTS to low Ox95.- * CR ( Return Figure 4-13. Receive Data PAD ~HITACHI 1200 2. Send Data Module Library Function: expout Function The send data module sends data to console the typewriter. Arguments Contents Storage Location No. of Bytes Entry Data to be sent outdat 2 (global variable) Returns Libraries Required for Program Execution Library Required/Not Required Standard Library Function C31LIB. OBJ Not required Run-Time Routine C31RUN.OBJ Required C31RUNF.OBJ Not required Specifications ROM (bytes): 15 RAM (bytes): 2 Stack (bytes): 0 No of cycles: 30 (Note) Reentrant: No Relocatable: No Interruptible: Yes Note: "No. of cycles" indicates the number of cycles required when TDR is empty. ~HITACHI 1201 2. Send Data Module Library Function: expout ,Description Function Details Argument Details: Global variable 'outdat' holds data to be sent in ASCII to a console typewriter. Example: Figure 4-14 shows an example of program module 'expout' execution. If entry argument is as shown in CD. the console typewriter prints it as shown in (2) • ~HITACHI 1202 2. Send Data Module Library Function: expout External Routine: Program module 'expout' does not call any other program modules or subroutines. User Notes 1. Initialize ACIA because ACIA is controlled by the microcontroller. After initialization the ACIA can transfer data to the console typewriter. 2. If previous data remains in TDR, program module 'expout' will not be executed until TDR is cleared, so as not to destroy the remaining data. { G[ob~ variable b15 outdat bO CD entry Before execution 'outdat' 1-:-: :1 argument (sending data 'A') TvpeA ., 4 1 " { 0 A 0 0 0 ® After execution 0 0 0 0 0 0 Figure 4-14. Program Module 'expout' Execution Example Variable Description The global variable is stored in static memory (figure 4-15). Variable Name RAM Description b15 bO outdat 1'----_ _---'1 } Contains character data to be sent to console typewriter Figure 4-15. Global Variable Storage I ~HITACHI 1203 2. Send Data Module Library Function: expout Sample Application Program module 'expout' is called after ACIA is initialized and data to be sent is stored (figure 4-16). * CR * CR Ox 97; Ox 95; } Initialize ACIA outdat Ox 41; } Store data to be send in entry argument II expout ); II ...... ·.. · Call expout Figure 4-16. Sample Application Basic Operation 1. Figure 4-17 shows how to control ACIA to send data. ,, ....... { Check bit 1 of status register (TORE) to test if ,, : transmit register is empty (TORE = 1 : empty) ,,, + while (( * SR & 2) ! = 1) : outdat ~ * TOR I f, ,, :....... { Load data to be sent into ,, transmit register ,, ~ figure 4-17. ACIA Control (Sending Serial Data) 2. Test if bit 1 of status register (TDRE) is "0" or "1". When TDRE is "1", store data to be sent in TDR. When TDRE is "0" ,wait until TDRE becomes "1", because TDRE = 0 means data remains in TDR. ~HITACHI 1204 2. Send Data Module Library Function: expout PAD expout Test if TOR is empty Store data to be sent in (TORE = 1) TOR in ACIA and send data while (( .. SR & 2) ! = 0) outdat --..- .. TOR Return Figure 4-18. Send Data Module PAD I ~HITACHI 1205 3. Diagram Characters Module Library Function: expdsp Function The display characters module stores ASCII in (DDRAM) LCD-II display RAM, and displays characters on liquid crystal display. Arguments Contents Storage Location No. of Bytes Entry Display data dspdat 2 (ASCII) (global variable) Returns Libraries Required for Program Execution Library Required/Not Required I Standard Library Function C31LIB. OBI Not required Run-Time Routine C31RUN. OBI Required C31RUNF. OBI Not required Specifications ROM (bytes): 144 RAM (bytes): 2 Stack (bytes): 0 No of cycles: 189 (Note) Reentrant: No Relocatable: No Interruptible: Yes Note: "No. of cycles" in "Specifications" indicates the number of cycles when subroutine expbsy executes in the minimum cycles. ~HITACHI 1206 3. Display Characters Module Library Function: expdsp Description Function Details Argument Details: Global variable 'dspdat' holds display data as 1 ASCII byte. Example: Figure 4-19 shows an example of program module 'expdsp' execution. If entry argument is as shown in -'a' && keydat<-'z') keydat--Ox20; f* Change lower case to upper *f keydrf-O; f* Clear flag of receive data *f *CR-Ox95; f* Set RTS=low *f outdat=dspdat=keydat; f* Set output data in area *f expout(); f* Transmit data to console *f expdsp(); f* Display characters on LCD-II *f /*******************************.* ••••• *****.*.*.***** ••• ********.*.* •••• * •••• / f* *f f* NAME : EXPIN (INITIALIZE PIA,ACIA AND LCD-2) *f f* *f 1··*******····*******···***·**······**·***··**····**** *** •• ****.*** ••• *.*****./ expin() { outdat=dspdat=keydrf=keydat=tncnt=func=entry=O; f* Initialize *f *CRA =OxOO; f* Select data direction registcr A *f *DDRA=Oxff; f* Select port A as output *f *CRA =Ox04; f* Select peripheral register A *f *PIRA=Ox02; f* Set RS=O, RfW=l, E=O *f -CRB =OxOO; f* Select data direction register B *f *DDRB=Oxff; f* Select port B as output *f *CRB =Ox04; f* Select peripheral register n *f func=Ox30; f~ Set function data *f entry=Ox06; f* Set entry mode data *f expint(); f* Initialize LCD-II *; setins(OxOe); f* Set instruction to LCD-II *f *CR=Ox97; f* Master reset of ACIA *f *CR=Ox95; f* Initialize ACIA *f *P5CR=Ox7d; f* Initialize port 5 *f ~HITACHI 1222 /*******************.******************************************.**************/ f* *f f* NAME : EXPIP (RECEIVE DATA) *f f* *f /.**************************************************************.**.**.*******/ f* *f f* ENTRY NOTHING *f f* HETUHNS KEYDAT (RECEIVED DATA) *f f* KEYDRF (RECEIVED FLAG) *f f* *f /**.* •• ***.********************************.* •••• ***** ****·*****·*****·*******1 expip() { i f «*SR&l) !=O) f* Test if data is received *f *CR=Oxd5; f* Set RTS=high *f keydat = *RDR; f* Set receive data *f keydrf=Oxff; f* Oxff if receive data is set *f *CR=Ox95; f* Set RTS=low *f /******************************************.**********************************/ f* *f f* NAME: EXPINT (INITIALIZE LCD-2) *f f* *f /*****.***********************************************************************/ f* *f f* ENTRY FUNC (FUNCTION DATA) *f f* ENTRY (ENTRY MODE DATA) *f f* RETURNS NOTHING *f f* *f / ••••••• *.** ••••• *******.*.***.** •• ***.******.******.**.***.****.*************/ expint() { for(tncnt=0;tncnt<3;tncnt++) { f* Reset LCD-II three times *f expit(); f* Execute I5ms software timer *f expins(Ox30) ; f* Write function data to LCD-II *f *PIRA=Ox02; f* Set RfW=1 *f setins(func) ; f* Set function data to LCD-II *f setins(Ox08) ; f* Set instruction (display off) *f setins(OxOI); f* Set instruction (display clear) *f setins(entry) ; f* Set entry mode data *f /*.**************************************.************************************/ f* *f f* NAME: EXPDSP (DISPLAY CHARACTERS) *f f* *f /*.*****.*********************.******.***************.************************/ f* *f f* ENTRY DSPDAT (DISPLAY DATA) * f* RETURNS NOTHING *f f* *f /**************************************************.**.*** •• ******************/ I ~HITACHI 1223 expdsp () ( expbsy() ; 1* Check busy flag *1 *PIRA=Ox04; 1* Set RS=l, R/W=O, E=O *1 *PIRA=Ox05; 1* Set E=l *1 *PIRB=dspdat; 1* Output data to LCD-II *1 *PIRA=Ox04; 1* Set E=O *1 *PIRA=Ox02; 1* Set R/W=l *1 , •••• *** •• ** ••••• **.*******.**.**.***.****.*** •• ***.** ************************1 1* *1 1* NAME : EXPOUT(SEND DATA) *1 1* *1 /.**** •• ********** ••• *.**.******* ••• ***.*.*.*.****** •• ***** •••• *.*.*******.*.*/ 1* *1 1* ENTRY OUTDAT (DATA TO BE SENT) *1 1* RETURNS NOTHING *1 1* *1 1·***************************·*·***********·****·*·***·***********************1 expout() ( while«*SR&2)!=O) 1* Transmission has been completed *1 *TDR=outdat; 1* Set transmit data in TDR *1 /****** ••• ********** •• ***********************************************.********/ /* *1 /* NAME : EXPBSY (CHECK BUSY FLAG) *1 /* *1 ;*.****************** •• ******* •• *** ••• *********** ••• ********.*****************/ expbsy( ) { int acca=Ox80; *CRB=OxOO; 1* Set data direction register B *1 *DDRB=OxOO; 1* Select port B as input *1 *CRB=Ox04; 1* Select peripheral register B *1 *PIRA=Ox02; 1* Set RS=O, R/W=l, E=O *1 do { *PIRA=Ox03; 1* Set E=l *1 acca=*PIRB; 1* Set PIRB in working area *1 *PIRA=Ox02; 1* Set E=O *1 acca &= Ox80; 1* Read busy flag *1 while (acca==Ox80); *CRB=OxO; 1* Select data direction register B *1 *DDRB=Oxff; 1* Select port B as output *1 *CRB=Ox04; 1* Select peripheral register B *1 } /*.******.** •• **** •••••• ********** ••••• ****.* •••••• ********.**************** •• / 1* *1 1* NAME : EXPINS (STORE INSTRUCTION) *1 1* *1 /*** •• ** ••••• **.******* •• ****** ••• * ••••••• ** •• * ••••• ** ••• ** ••••• * •• *.* •• ****.*/ expins(insdat) lnt insdat; { *PIRA=OxOO; 1* Set RS=O, R/W=O, E=O *1 *PIRA=OxOl; 1* Set E=l *1 *PIRB=insdat; 1* Set instruction in peripheral B *1 *PIRA=OxOO; I*Set E=O *1 ~HITACHI 1224 j ••••••••••••••••••••••••••••••••••••••••••••••••••••• •••••••••••••••.•• * •••••• , /* */ /* NAME: SETINS (SET INSTRUCTION TO LCD-2) */ ,.............................................................................. , /* setins(lnsdat) */ int insdat: ( expbsy{) : expins(insdat): I ~HITACHI 1225 4.4.3 Output Object Listing of C Compiler ••• CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER V1.2 ••• ERR SEQ LOC OBJECT PROGRAM EXPC 00001 NAM EXPC 00002 OPT REL 00003 MSEX MACR 00004 CLRA 00005 TSTB 00006 BPL \.0 00007 COMA 00008 \.0 EQU • 00009 ENDM 00010 MLBRA MACR 00011 JMP \0 00012 ENDM 00013 MLBSR MACR 00014 JSR \0 00015 ENDM 00016 MLBEQ MACR 00017 BNE \.0 00018 JMP \0 00019 \.0 EQU • 00020 ENDM 00021 MLBNE MACR 00022 BEQ \.0 00023 JMP \0 00024 \.0 EQU • 00025 ENDM 00026 MLBGT MACR 00027 BLE \.0 00028 JMP \0 00029 \.0 EQU • 00030 ENDM 00031 MLBGE MACR 00032 BLT \.0 00033 JMP \0 00034 \.0 EQU • 00035 ENDM 00036 MLBLT MACR 00037 BGE \.0 00038 JMP \0 00039 \.0 EQU • 00040 ENDM 00041 MLBLE MACR 00042 BGT \.0 00043 JMP \0 00044 \.0 EQU • 00045 ENDM 00046 MLBUI MACR 00047 BLS \.0 00048 JMP \0 00049 \.0 EQU • 00050 ENDM 00051 MLBLS MACR 00052 BUI \.0 00053 JMP \0 00054 \.0 EQU • 00055 ENDM 00056 MLBCC MACR ~HITACHI 1226 *** CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER V1.2 --- ERR SEQ LOC OBJECT PROGRAM EXPC 00057 Bes \.0 00058 JMP \0 00059 \.0 EQU - 00060 ENOM 00061 MLBCS MACR 00062 BCC \.0 00063 JMP \0 00064 \.0 EQU * 00065 EN OM 00066B 0000 BSCT 00067B 0000 0002 A OUTOAT BSZ 2 00068R 0002 RSr.1' 00069B 0002 0002 A DSPOAT BSZ 2 00070B 0004 BSCT 00071B 0004 0002 A KEYORF BSZ 2 00072B 0006 BSCT 00073B 0006 0002 A KEYOAT BSZ 2 00074B 0008 BSCT 00075B 0008 0002 A TNCNT BSZ 2 00076B OOOA BSCT 00077B OOOA 0002 A FUNC BSZ 2 00078B OOOC BSCT 00079B OOOC 0002 A ENTRY BSZ 2 00080P 0000 PSCT 00081P 0000 20 31 0033 BRA .SA002 00082P 0002 OC 04 B .SA003 LOO KEYORF 00083P 0004 27 20 0033 BEQ .SA004 00084P 0006 OE 06 B LOX KEYOAT 00085P 0008 8C 0061 A CPX #9J 00086P OOOB 20 OE 001B BLT .$A005 00087P 0000 OE 06 B LOX KEYOAT 00088P OOOF 8C 007A A CPX #122 00089P 0012 2E 07 001B BGT .SA005 00090P 0014 OC 06 B LOO KEYOAT 00091P 0016 83 0020 A SUBO #32 00092P 0019 00 06 B STO KEYOAT 00093P 001B 4F .SA005 CLRA 00094P 001C 5F CLRB 00095P 0010 00 04 B STO KEYORF 00096P 001F CE COOO A LOX #-16384 00097P 0022 CC 0095 A LOO #149 00098P 0025 E7 00 A STAB O,X 00099P 0027 OC 06 B LOO KEYOAT 00100P 0029 00 02 B STO OSPOAT 00101P 002B 00 00 B STO OUTOAT 00102P 0020 MLBSR EXPOUT 00103P 0030 MLBSR EXPOSP 00104 0033 P .SA004 EQU 00105 0033 P MAIN EQU 00106P 0033 20 CO 0002 .SA002 BRA 00107P 0035 39 RTS -* .SA003 00l08P 0036 PSCT 00l09P 0036 4F EXPIN CLRA OOllOP 0037 5F CLRB OOlllP 0038 00 OC B STO ENTRY OO1l2P 003A 00 OA B STO FUNC I ~HITACHI 1227 ••• CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER V1.2 ••• ERR SEQ LOC OBJECT PROGRAM EXPC 00113P 003C DD 08 B STD TNCNT 00114P 003E DD 06 B STD KEYDAT 00115P 0040 DD 04 B STD KEYDRF 00116P 0042 DD 02 B STD DSPDAT 00117P 0044 DD 00 B STD OUTDAT 00118P 0046 CE A001 A LDX #-24575 00119P 0049 E7 00 A STAB O,X 00120P 004B CE AOOO A LDX #-24576 00121P 004E CC OOFF A LDD #255 00122P 0051 E7 00 A STAB O,X 00123P 0053 CE A001 A LDX #-24575 00124P 0056 CC 0004 A LDD #4 00125P 0059 E7 00 A STAB O,X 00126P 005B CE AOOO A LDX #-24576 00127P 005E CCOO02 A LDD #2 00128P 0061 E7 00 A STAB O,X 00129P 0063 CE A003 A LDX #-24573 00130P 0066 4F CLRA 00131P 0067 5F CLRB 00132P 0068 E7 00 A STAB O,X 00133P 006A CE A002 A LDX #-24574 00134P 006D CC OOFF A LDD #255 00135P 0070 E7 00 A STAB O,X 00136P 0072 CE A003 A LDX #-24573 00137P 0075 CC 0004 A LDD #4 00138P 0078 E7 00 A STAB O,X 00139P 007A CC 0030 A LDD #48 00140P 007D DD OA B STD FUNC 00141P 007F CC 0006 A LDD #6 00142P 0082 DD OC B STD ENTRY 00143P 0084 MLBSR EXPINT 00144P 0087 CC OOOE A LDD #14 00145P 008A MLBSR SETINS 00146P 008D CE COOO A LDX #-16384 00147~ 0090 CC 0097 A LDD #151 00148 0093 E7 00 A STAB ,O,X 00149P 0095 CE COOO A LDX #-16384 00150P 0098 CC 0095 A LDD #149 00151P 009B E7 00 A STAB O,X 00152P 009D CE 0014 A LDX #20 00153P OOAO CC 007D A LDD #125 00154P 00A3 E7 00 A STAB O,X 00155P 00A5 39 RTS 00156P 00A6 PSCT 00157P 00A6 CE COOO A EXPIP LDX #-16384 00158P 00A9 E6 00 A LDAB 0," 00159P OOAB MSEX 00160P OOBO 4F CLRA 00161P 00B1 C4 01 A ANDB #1 00162P 00B3 27 21 00D6 BEQ .SA008 00163P 00B5 CE COOO A LDX #-16384 00164P 00B8 CC 00D5 A LDD #213 00165P OOBB E7 00 A STAB O,X 00166P OOBD CE COOl A LDX #-16383 00167P OOCO E6 00 A LDAB O,X 00168P 00C2 MSEX 1228 * HITACHI *** CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER Vl.2 *** ERR SEQ LOC OBJECT PROGRAM EXPC 00169P 00C7 DD 06 B STD KEYDAT 00170P 00C9 CC OOFF A LDD #255 00171P OOCC DD 04 B STD KEYDRF 00172P OOCE CE COOO A LDX #-163B4 00173P OODI CC 0095 A LDD #149 00174P 00D4 E7 00 A STAB O,X 001.75P 00D6 39 .$A008 RTS 00176P 00D7 PSCT 00177P 00D7 4F EXPINT CLRA 0017BP OODB 5F CLRB 00179P 00D9 20 OE 00E9 BRA .. 1 OOlBOP OODB .$AOlO MLBSR EXPIT 00181P OODE CC 0030 .A LDD #4B 001B2P OOEI MLBSR EXPINS 001B3P 00E4 DC OB B LDD TNCNT 001B4P 00E6 C3 0001 A ADDD #1 001B5P 00E9 DD DB B .. 1 STD TNCNT 001B6P OOEB DE OB B .$AOll LDX TNCNT 001B7P OOED BC 0003 A CPX #3 001BBP OOFO 2D E9 OODB BLT .$AOlO 001B9P 00F2 CE AOOO A LDX #-24576 00190P 00F5 CC 0002 A LDD #2 0019lP OOFB E7 00 A STAB O,X 00192P OOFA DC OA B LDD FUNC 00193P OOFC MLBSR SETINS 00194P OOFF CC 0008 A LDD #B 00195P 0102 MLBSR SETINS 00196P 0105 CC 0001 A LDD #1 00197P 010B MLBSR SETINS 0019BP 010B DC DC B LDD ENTRY 00199P 010D MLBSR SETINS 00200P 0110 39 RTS 00201P 0111 PSCT 00202P 0111 EXPDSP MLBSR EXPBSY 00203P 0114 CE AOOO A LDX #-24576 00204P 0117 CC 0004 A LDD #4 00205P 011A E7 00 A STAB O,X 00206P 011C CE AOOO A LDX #-24576 00207P 011F CC 0005 A LDD #5 0020BP 0122 E7 00 A STAB O,X 00209P 0124 CE A002 A LDX #-24574 00210P 0127 DC 02 B LDD DSPDAT 00211P 0129 E7 00 A STAB O,X 00212P 012B CE AOOO A LDX #-24576 00213P 012E CC 0004 A LDD #4 00214P 0131 E7 00 A STAB O,X 00215P 0133 CE AOOO A LDX #-24576 00216P 0136 CC 0002 A LDD #2 00217P 0139 E7 00 A STAB O,X 00218P 013B 39 RTS 00219P 013C PSCT 00220P 013C 20 07 0145 BRA .$A014 00221P 013E CE COOl A .$A015 LDX #-16383 00222P 0141 DC 00 B LDD OUTDAT 00223P 0143 E7 00 A STAB O,X 00224 0145 P EXPOUT EQU * I ~HITACHI 1229 ••• CP/M-68K 6301/6801/6800 CROSS MAC~OASSEMBLER V1.2 ••• ERR SEQ LOC OBJECT PROGRAM EXPC 00225P 0145 CE COOO A .$A014 LDX #-16384 00226P 0148 E6 00 A LDAB O,X 00227P 014A MSEX 00228P 014F 4F CLRA 00229P 0150 C4 02 A ANDB #2 00230P 0152 26 EA 013E BNE .$A015 00231P 0154 39 RTS 00232P 0155 PSCT 00233P 0155 3C EXPBSY PSHX 00234P 0156 CC 0080 A LDD #128 00235P 0159 30 TSX 00236P 015A ED 00 A STD O,X 00237P 015C CE A003 A LDX #-24573 00238P 015F 4F CLRA 00239P 0160 5F CLRB 00240P 0161 E7 00 A STAB O,X 00241P 0163 CE A002 A LDX #-24574 00242P 0166 E7 00 A STAB O,X 00243P 0168 CE A003 A LDX #-24573 00244P 016B CC 0004 A LDD #4 00245P 016E E7 00 A STAB O,X 00246P 0170 CE AOOO A LDX #-24576 00247P 0173 CC 0002 A LDD #2 00248P 0176 E7 00 A STAB O,X 00249P 0178 CE AOOO A .$A017 LDX #-24576 00250P 017B CC 0003 A LDD #3 00251P 017E E7 00 A STAB O,X 00252P 0180 CE A002 A LDX #-24574 00253P 0183 E6 00 A LDAB O,X 00254P 0185 MSEX 00255P 018A 30 TSX 00256P 018B ED 00 A STD O,X -o0257P 018D CE AOOO A LDX #-24576 00258P 0190 CC 0002 A LDD #2 00259P 0193 E7 00 A STAB O,X 00260P 0195 30 TSX 00261P 0196 EC 00 A LDD O,X 00262P 0198 4F CLRA 00263P 0199 C4 80 A ANDB #128 00264P 019B ED 00 A STD O,X 00265P 0190 EE 00 A LDX O,X 00266P 019F 8C 0080 A CPX #128 00267P 01A2 27 D4 0178 BEQ .$A017 00268P 01A4 CE A003 A LOX #-24573 00269P 01A7 4F CLRA 00270P 01A8 5F CLRB 00271P 01A9 E7 00 A STAB O,X 00272P 01AB CE A002 A LOX #-24574 00273P 01AE CC OOFF A LOD #255 00274P 01B1 E7 00 A STAB O,X 00275P 01B3 CE A003 A LDX #-24573 00276P 01B6 CC 0004 A LDD #4 00277P 01B9 E7 00 A STAB O,X 00278P 01BB 38 PULX 00279P 01BC 39 RTS 00280P 01BD PSCT ~HITACHI 1230 .** CP/M-68K 6301/6801/6800 CROSS MACROASSEMBLER VI. 2 • ** ERR SEQ LOC OBJECT PROGRAM EXPC 00281P 01BO 37 EXPINS PSHB 00282P 01BE 36 PSHA 00283P 01BF CE AOOO A LDX #-24576 00284P 01C2 4F CLRA 00285P 01C3 5F CLRB 00286P 01C4 E7 00 A STAB O,X 00287P 01C6 CE AOOO A LOX #-24576 00288P 01C9 CC 0001 A LOO #1 00289P 01CC E7 00 A STAB O,X 00290P 01CE CE A002 A LOX #-24574 00291P 0101 3C PSHX 00292P 0102 30 TSX 00293P 0103 EC 02 A LOO 2,X 00294P 0105 38 PULX 00295P 0106 E7 00 A STAB O,X 00296P 0108 CE AOOO A LOX #-24576 00297P 010B 4F CLRA 00298P 010C 5F CLRB 00299P 0100 E7 00 A STAB O,X 00300P 010F 38 PULX 00301P OlEO 39 RTS 00302P 01E1 PSCT 00303P 01E1 37 SETINS,. PSHB 00304P 01E2 36 PSHA 00305P 01E3 MLBSR EXPBSY 00306P 01E6 30 TSX 00307P 01E7 EC 00 A LOO O,X 00308P 01E9 MLBSR EXPINS 00309P 01EC 38 PULX 00310P OlEO 39 RTS 00311 XOEF EXPOSP 00312 XOEF SETINS 00313 XOEF EXPINS 00314 XOEF EXPINT 00315 XOEF EXPBSY 00316 XDEF EXPIN 00317 XDEF EXPOUT 00318 XDEF MAIN 00319 XDEF EXPIP 00320 XREF EXPIT 00321 END •••• TOTAL ERRORS 00000--00000 ~HITACHI 1231 4.4.4 Linkage Listing *** HMCS6800 CROSS LINKAGE EDITOR VER 1.2 *** LOAD;B:EXPMN.OBJ,B:EXPC.OBJ,C31RUN.OBJ STRP;$FOOO STRB;$60 STRD;$40 OPT;MAP,SYM EXEC *** HMCS6800 CROSS LINKAGE EDITOR VER 1.2 *** *** UNDEFINED SYMBOLS *** NAME SECTION MODULE NAME . ERROR ( ) UNDEFINED SYMBOL; 1 (Note) Note: There is an UNDEFINED SYMBOL = 1 (library function, ERROR) in the link information but it does not influence the execution of this program. The library function or run-time routine call the ERROR service routine when 0 is used as a divisor in division or modulo operation. Strictly speaking, the user should create an ERROR funcion. However it is never used in this program, so it is just displayed as an UNDEFINED SYMBOL. (When the library function and run-time routine are not linked, the UNDEFINED SYMBOL is not displayed.) * ** HMCS6800 CROSS LINKAGE EDITOR VER 1.2 *** *** MAP LIST *** ** SECTION LOAD MAP SECTION SIZE START END COMMON-SIZE A 0016 FFEA FFFF B OOOE 0060 006D 0000 C 0000 D 0004 0040 0043 0000 P 07DA FOOO F7D9 0000 ** MODULE LOAD MAP NAME BSCT DSCT PSCT FOOO EXPC 0060 F01A 0040 F208 ** COMMON LOAD MAP NAME SECTION SIZE START COMMON ; 0 ~HITACHI 1232 *** HMCS6800 CROSS LINKAGE EDITOR VER 1.2 *** DEFINED SYMBOLS *** NAME SECTION START MODULE NAME .$DADD P F7D9 ( ) .$DCMP P F7D9 ( ) .$DDEC P F7D9 ( ) .$DDIV P F7D9 ( ) .$DINC P F7D9 ( ) .$DMOV P F7D9 ( ) .$DMUL P F7D9 ( ) .$DNEG P F7D9 ( ) .$DSTK P F7D9 ( ) .$DSUB P F7D9 ( ) .$DTOF P F7D9 ( ) .$DTOI P F7D9 ( ) .$DTOL P F7D9 ( ) .$DTST P F7D9 ( ) .$FDEC P F7D9 ( ) .$FINC P F7D9 ( ) .$FMOV P F7D9 ( ) .$FREG D 0040 ( ) .$FTOD P F7D9 ( ) .$FTST P F7D9 ( ) .$IASL P F27D ( ) .$IASR P F292 ( ) .$IDIV P F23F ( ) .$IMOD P F2BC ( ) .$IMUL P F208 ( ) .$ITOD P F7D9 ( ) . $ITOL P F51D ( ) .$LADD P F32F ( ) .$LAND P F432 ( ) . $LBIT P F600 ( ) .$LCMP P F4BF ( ) .$LCPL P F501 ( ) .$LDEC P ~::;.:to ( ) .$LDIV P F3E3 ( ) .$LINC P F53B ( ) .$LMOD P F40A ( ) .$LMOV P F30B ( ) .$LMUL P F361 ( ) .$LNEG P F4EC ( ) .$LOR P F44D ( ) .$LSHL P F483 ( ) .$LSHR P F4A1 ( ) .$LSTK P F55B ( ) .$LSUB P F348 ( ) .$LTOD P F7D9 ( ) .$LTST P F576 ( ) .$LXOR P F468 ( ) .$SBIT P F723 ( ) .$SW1 P F76B ( ) .$SW2 P F79A ( ) .$UDIV P F25B ( ) .$ULSR P F2A7 ( ) .$UMOD P F2EA ( ) I ~HITACHI 1233 *** HMCS6800 CROSS LINKAGE EDITOR VER 1.2 *** NAME SECTION START MODULE NAME .$UTOD P F7D9 ( ) .$UTOL P F52E ( ) EXPBSY P F16F ( EXPC ) EXPDSP P F12B ( EXPC ) EXPIN P F050 ( EXPC ) EXPINS P F1D7 ( EXPC ) EXPINT P FOFl ( EXPC ) EXPIP P FOCO ( EXPC ) EXPIT P FOOA ( ) EXPOUT P F15F ( EXPC ) MAIN P F04D ( EXPC ) SETINS P F1FB ( EXPC ) DEFINED SYMBOL = 65 ~HITACHI 1234 I APPENDIX A. C Program and Assembly Program Comparison This appendix compares application programs previously introduced assembly language system application examples to the C language examples in this application note. (Assembly language programs are described in the 6301 APPLICATION NOTES (Hardware)). In general, the size of the C language program is greater than that of the assembly language program. These examples are hardware control programs that are difficult to write in C and show how ro use the 6301 C language compiler. The run-time routines are not included in the C language program size descriptions. A.1 Darlington Transistor Drive (LED Dynamic Display) Table A-1 compare Darlington Transistor Drive Routines written in C and assembler. Table A-I. Program Comparison Item Memory Size (Bytes) No. of Cycles (Machine cycle) CProgram 131 200 Assembly program 82 120 Cprogram to 1.6 1.67 assembly program ratio I ~HITACHI 1235 A.2 8 x 4 Key Metrix Table A-2 compares 8 x 4 key Matrix Routines written in C and assembler. Table A-2. Program Comparison Item Memory Size (Bytes) No. of Cycles (Machine cycle) CProgram 336 1240 Assembly program 181 373 C program to 1.86 3.32 assembly program ratio A.3 External Expansion Table A-3 compares External Expansion Routines written in C and assembler. Table A-3. Program Comparison Item Memory Size (Bytes) No. of Cycles (Machine cycle) CProgram 518 1347 Assernblyprogram 318 572 Cprogram to 1.63 2.35 assembly program ratio @HITACHI 1236 HD6301/HD6303 SERIES HANDBOOK Section len APPENDIX 1. HD6301Vl/HD6303R 0. - and A 2. HD6301XO/HD6303X Oscillator Circuit 3. Wide lemperature Range Specifications -40°C to 85°C (J Version) @HITACHI 1237 . ~HITACHI 1238 Section 10-Appendix 1. HD6301V1/HD6303R Q and A Table of Contents Page 1. HD6301V1/HD6303R Q & A ............................................. . 1239 (a) Parallel Port (1) Process to Use a Port as an Output ....... ; ........................... . 1241 (b) Serial Port (1) Relation between Writing into the FRC and SCI Operation ................. . 1242 (2) Writing into the FRC during Serial Receiverfransmit ...................... . 1243 (3) RDRF State When SCI Receiving ..................................... . 1244 (4) Serial 110 Operation ................................................ . 1245 (5) Serial 1/0 Register Read ............................................ . 1246 (6) Detection of the HD6301V1 Serial Start Bit ............................. . 1247 (c) TimerlCounter (1) Free Running Counter Read ......................................... . 1249 (2) Preset Method of the Free Running Counter ............................ . 1250 (d) BUS Interface (1) Output of Address Strobe (AS) in the Multiplexed Mode ................... . 1252 (e) Interrupt (1) IRQ1 Acceptance ............................' ...................... . 1253 (2) Timer Interrupt and External Interrupt. ................................. . 1254 (3) IRQ1 Interrupt and Other Interrupts ................................... . 1255 (4) CLilnstruction and Interrupt Operation ................................ . 1257 (f) Oscillator (1) Relation between the External Clock (EXTAL Clock) and Enable Clock (E Clock) 1258 (g) Reset (1) Constants of the Reset Circuit. ....................................... . 1259 (2) Schmitt Trigger Circuit of RES ....................................... . 1260 (3) 1/0 Port State on Resetting .......................................... . 1261 (4) SCI (Pin 39) State on Resetting ....................................... . 1262 (5) Port Output after Resetting .......................................... . 1263 (h) Low Power Consumption (1) . 1264 Schmitt Trigger Circuit of STBY ....................................... . (2) 1/0 Port State During Standby ........................................ . 1265 ~HITACHI 1239 I · (3) Return from Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1266 (4) Going into the Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1267 (5) Timing for the Standby Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1268 I' (i) EPROM-on-Package (1 ) Usage of EPROM Socket Pins for the HD63P01M (No.1). .. . . . .. . . .. . . . . . .. 1269 (2) Usage of EPROM Socket Pins for the HD63P01 M (No.2). . . . . . . . . . . . . . . . . .. 1270 (3) Usage of EPROM Socket Pins for the HD63P01 M (No.3) . . . . . . . . . . . . . . . . . .. 1271 " 0) Software (1) Usage of Bit Manipulation Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1272 (2) Usage of Bit Manipulation Instructions to the Port. . . . . . . . . . . . . . . . . . . . . . . .. 1274 (k) Others (1) RAM Access Disable during Program Execution . . . . . . . . . . . . . . . . . . . . . . . . .. 1275 2. HD6301XO/HD6303X Oscillator Circuit. ...................................... 1276 3. Wide Temperature Range Specifications -40°C to +85°C (J Version) .............. 1283 HD6301V1, HD63A01V1, HD63B01V1 ........................................... 1284 HD6301XO, HD63A01XO, HD63B01XO .......................................... 1289 HD6301Y0, HD63A01Y0, HD63B01YO, HD63C01Y0 ............................... 1294 HD6303R, HD63A03R, HD63B03R ...................... '" .................... 1300 HD6303X, HD63A03X, HD63B03X .... , ........................................ 1305 HD6303Y, HD63A03Y, HD63B03Y, HD63C03Y .................................... 1310 ~HITACHI 1240 - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301V1 HD6303R JDevice I Evaluation 4S *8S 8M 16M kit Emulator, SD Software SBC I Theme Process to Use a Port as an Outputs Date I Nov. 24, 1983 Question I Classification 1, When using an I/O port as an output, is the data * Parallel Port stored to the Data Register or is the Data Serial Port Direction Register (DDR) set at first? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer J Applicable Manual 1, Store the data to the Data Register at first and Title I then set the DDR (DDR=l) ; if not, unknown data is output from the port. Semiconductor Data Book - 8-Bit Single Chip Microcomputer - Other Data Title I Reference Q & A Sheet ~ Supplement I The DDR defines an I/O port as an input or output. DDR=l : output DDR=O : input @HITACHI 1241 I HD6301 V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301 VI HD6303R I Device I 4S *8S 8M 16M Evaluation kit, Emulator Software SD SBC Operation I Theme Relation between Writing into the FRC and SCI Date Nov. 24, 1983 Question I Classification 1, How are writing into the timer Free Running Parallel Port Counter(FRC) and the Serial Communication Inter- * Serial Port face(SCI) related? Timer/Counter BUS Interface Interrupt AID Converter Oscillator Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1 , The source of the clock input to the SCI Shift Title I Registers is the timer FRC. Therefore, if new data is writteri into the FRC, SCI operations are disturbed. See the following diagram. 1$09 $Oj Other Data :Titlel 1 J, R/W Receive Shift Register I E JL~.FRC I JL Generator Baud Rate Reference Q £. A Sheet Transmit Shift Register I ~ QA63l-002A * A write into the FRC ~s prohibited during SCI QA631-00BA operations. Supplement I ~HITACHI 1242 - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl HD6303R I Device I 4S *8S 8M 16M Evaluation kit Emulator SoftwarE SD SBC ThemE Writing into the FRC during Serial Receive/Transmit I Date Nov. 24, 1983 Question I Classification 1 , Is it prohibited to write data into the Free Parallel Port Running Counter(FRC) during serial receive/trans- * Serial Port mit? Timer /Coun ter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, Yes. If data is written into the FRC during Title I serial receive/transmit, the FRC stops counting up and the baud rate changes. In condition other than serial receive/transmit, it's possible to write. I t0 9, $Oj WRITE Other Data Title I Receive Shiftl J, Register E 4J IJL FRC Baud Rate Generator Transmit Shift I Reference Q & A Sheet 1 ~:rstops Register ~ QA631-001A QA631-008A and the baud rate changes. Sup~lementJ ~HITACHI 1243 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301 VI I Device ,. 4S *8S 8M 16M Software Theme HD6303R RDRF State When SCI Receiving I Evaluation kit Emulator SD Date Nov. 24, 1983 SBC Ques tion I Classification 1, What is the state of the Receive Data Register Parallel Port Full(RDRF) flag when the HD630lVl/HD6303R SCI * Serial Port can receive signals (RE=!) and the wake-up flag Timer/Counter (WU bit) is set? BUS Interface Interrupt TRCSR A/D Converter 7 6 5 4 3 2 1 0 Oscillator $0011 I RDR~ ORF§ TDR§ RIE I RE I TIE I TE I WU I Reset ,J. ,L. J, Low Power Consm. ? 1 1 EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, When the wake-up flag is set (WU=!) the RDRF flag Title J cannot be set. This is mentioned in the HD680l, HD6803 data sheets, but not in the HD6301 and HD6303. Other Data TitleJ Reference Q & A Sheet ~ Supplement I Transmit/Receive Control Status Register(TRCSR) controls the transmitter, receiver, wake-up feature and two individual inter- rupts, and monitors the status of serial operations. ~HITACHI 1244 - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl HD6303R I Device I Evaluation 4S *8S 8M 16M kit Emulator Software SD SB~ ThemE Date I Nov. 24, 1983 Serial I/O Operation Question I Classification 1 , The serial I/O does not operate satisfactorily. Parallel Port Initialization does not seem to be wrong, but the Serial Port * Timer/Counter data is not transmitted. What is wrong? BUS Interface Initialize by User P"rogram Interrupt 1 Set the Rate/Mode Control Register A/D Converter (RMCR) to the desired operation. Oscillator 2 Set the Transmit/Receive Control Reset Status Register (TRCSR) to the Low Power Con sm. desired operation. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, Just after the initialization of serial I/O, the Title I data transmit is not operative during 10 cycles of Baud Rate after setting the TE. The reason is as follows. Setting the transmit enable bit (TE bit) causes ten consesutive "1" of preamble and maKes the transmitter section operative. In other words, Other Data the transmitter section gets ready after one frame Title I (10 bi ts) transmi t ting time according to the Baud rate. (ex.) When the Baud rate is set to 9600 Baud (104.2)s at 1 bi t) , Set the Baud rate Set TE Transmit OK Reference Q & A Sheet J, ~ -l- ~ ~~~~~~~~~~I ~~~~~~~~-----~ I I 1 ~II04.2tLS X lO=1.042m.s 1+- ~ : Transmit I Period Inoperative Preamble Causing Period 1.042ms after setting the TE, the transmitter section is operative. Supp lemen t I ~HITACHI 1245 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301V1 HD6303R IDevice I Evaluation 4S *8S 8M 16M kit, Emulator Software SD SBe Theme Serial I/O Register Read Date I Nov. 24, 1983 Question I Classification 1, When transmitting the data, is reading the Trns- Parallel Port mit/Receive Control Register(TRCSR) required? * Serial Port When the transfer interval is long enough compared Timer/Counter with the Baud rate, Transmit Data Register BUS Interface Empty (TDRE) will be set. In that case, are Interrupt there any problems when transmi,tting data wi thout A/D Converter checking the TDRE flag in the TRCSR? Oscillator Reset Low Power .Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, The TDRE flag shows if the TDRE register is empty Title I or not. When writing a data to the TDR with TDRE=l, it's not necessary to check the TDRE. But reading the TDRE flag tells us the contents of TOR. For example, when new data is written to the TDR with TDRE "O"(TDR already has a data), the old data will be,erased. Other Data When the trans~er interval is long enough comparee Title I with the Baud rate, there's no problem. However, check TRCSR if possible. Reference _Q & A Sheet .Ji2.:J Supplement I ~HITACHI 1246 - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301V1 HD6303R IDevice I Evaluation 4S *8S 8M 16M kit, Emulator Software SD SBC Theme Dete~tion of the HD6301Vl Serial Start Bit Date I (No.1") Nov. 24.1983 Question I Classification Parallel Port 1. * Serial Port (1) What is the relation between the HD6301V1 Timer/Counter serial sampling clock frequenscy and the BUS Interface baud rate ? Interrupt A/D Converter ( 2) What does "Sampling error" mean ? Oscillator Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I 1. (1) The serial sampling clock frequenscy is eight times the baud ra te. Other Data (2) "Sampling error" means receive margin at the Title I serial operation time. Refer to the next page for details. Reference Q & A Sheet ~ r Supplement I ~HITACHI 1247 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301Vl 4S *8S 8M 16U Softwar HD6303R Evaluation kit, Emulator SD SB Them Detection of the HD6301Vl Start Bit (No.2) Answer Receive margin: The HD6301Vl detects the start bit and samples the data bit using the falling edge of the sampling clock. The general equation is shown as follows. 1. General equation M = [ ( 0.5-l/N ) - ( D-0.5 )/N- ( L-0.5)F X 100 (%) H: Receive margin' N: Ratio of baud rate to sampling clock (0 to 0.5 ) D: Duty of the longer sampling clock of "H", and "L" L: Frame length (7 to' 12 bits) F: Absolute value of deviation of sampling clock frequency 2. Abbreviated equation M = ( 0.5-1/N) X 100 (%) Conditions: D ~ 0.5, F 0 N 8 16 32 64 Note M 37.5 43.75 46.875 48.4375 In the HD6301 VI, ·N = 8. (%) (Fig.l) Figure 1 o 1 2 3 4 5 6 7 8 Clock 43.75 % R.x 50 % I~ .... 1\ Start bit 1[\ I1/N - I I Trii:~e~r------~0~.~5~-----------S-t-a-r-t-b-i-t--s-a-m~~ling ~HITACHI 1248 - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl HD6303R I Device 4S I *8S 8U Evaluation kit, Emulator 16M Software SD SBC ThemE Free Running Counter Read Date l Nov.24.1983 Question I Classification 1. When the FRC of the HD6301Vl/HD6303R is read with Parallel Port ~~--~~~------------~ the double byte load instructions(2 cycle Serial Port execution for FRC reading), is it read correctly? * Timer/Counter Double byte load instructions require two cycles r-~~=-~~~--------~ BUS Interface to be executed and the cycle to read the low byte r--r~I~n~t~e~r~r~u~p~t----------~ of FRC becomes the next cycle of the high byte. A/D Converter Is it OK ? I Oscillator 1 1 (EX) I I I Reset High Readl Low Readl Low Power Consm. E EPROtf-on-package FRC (1 cycle) : (2 cycle Software ($09,$OA) I $F7FF 1 $F800 1 Evaluation Kit I T ",5 1 Emulator AccD IF? 001 SD Data Buffer (Whe reading $i7FF from the counter) Others Answer I Applicable }~nual 1. The FRC of the HD6301Vl/HD6303R contains a Title I parallel temporary register. When the high byte of the FRC is read, the low byte is set in the temporaty register. The Low byte data in the temporary register is set to the AccD at the next cycle. Therefore, it is possible to read the FRC correctly. Other Data I I 1 Title I I High Rea I Low Rea I E FRC $F7 FF r $F8 00 --I --I Reference Q & A Sheet Temporaly riF" 1 1 Regist'er ~--"~ ~ : -!t I I Read Data $F7 : $FF I I it I AccD IF~ : FFI (When reading $F7FF from the counter) Supplement 1 FRC: Free Running Counter The base counter of the timer which counts up the E clock. ~HITACHI 1249 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - , - Type HD6801Vl HD6301Vl IDevice J 4S *8S 8M 16M Evaluation kit, Emulator Software SD SBC Theme Preset Method of the Free Running Counter (No.1,) Date I Nov.24.1983 Question I Classification 1. Parallel Port Serial Port ~fuat is the difference between the HD6S01V and * Timer/Counter HD6301Vl in writing data into the free running BUS Interface couter ? Interrupt. A/D Converter Oscillator - Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I I. The FRC preset method of the HD6S0lV is different from the HD6301VI. Semiconductor Data Book ~ S-Bit Single Chip Microcomputer - Type Preset Method HD680lV The FRC is always preset to "$FFFS". Other Data Title I HD630lVI I. Writing to the high byte presets the FRC to $FFF8. 2. The FRC is set to desirable data by a double byte store instruction. Reference Q & A Sheet ~ QA631-001A QA631-002A Supplement I See the next page for the example of this method. ~HITACHI 1250 HD6301V Questions & Answers Type HD6801V1 45 *85 8M 16M Softwar HD6301V1 Evaluation kit, Emulator SD 5B Them Preset Method of the Free Counter (No.2) Answer (1) . The HD6a01V Preset l1ethod II$SAF3 · rLDD STD $09 E I I FRC $FFF8 $FFF9 ! $FFFA I I I -? The FRC is always preset to $FFF8. ( 2) The HD6301V1 Preset l1ethod 1. $FFF8 f-LDD II$SAF3 STAA $09 E I I FRC I I $FFF8 $FFF9 ~ $FFFA -? I Writing to the high byte presets the FRC to $FFF8. 2. Optional valve (In this case $SAF3) ~LDD II$SAF3 STD $09 E I FRC $FFF8 $SAF3 : $SAF4 -7 The FRe is set to desirable data ($SAF3) by a double byte store instruction. ~HITACHI 1251 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301Vl HD6303R IDevice I 4S *8S 8M 16M Evaluation kit Emulator Software SD SBC Theme Output of Address Strobes(AS) in the Multi- plexed Mode 1 Date Nov. 24, 1983 Question I Classification 1, Is AS always output when using the HD6301Vl in Parallel Port the expanded multiplexed mode (mode 2, 4, 6)? Serial Port Timer/Counter BUS Interface * Interrupt A/D Converter Oscillator Reset Low Power Consm. EPROM-on-~ack~e Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 2\ Yes. AS is always output in the expanded Title I mUltiplexed mode, even when the MPU accesses the internal RAM, ROM, etc. Other Data Title I Reference ~ & A Sheet ~ Supplement I In the expanded multiplexed mode,the data buses and lower address buses are multiplexed and output from port 3. AS is the signal needed to demultiplex the data buses and address busses. Mode 2, 4 and 6 of the HD6301Vl are the expanded modes. ~HITACHI 1252 - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301V1 I Device I 4SEvaluation *8S .- 8M 16M Software Date I Nov. HD6303R kit, Emulator SD SBC Theme IRQ1 Acceptance lYtl3 24, Question I Classification 1, (1) Is TRQI ignored when the Condition Code Parallel Port Register I mask ~s set? Serial Port Timer/Counter (2) After the I mask is reset, will the interrupt BUS Interface sequence start by the interrupt request flag Interrupt having been latched? * A/D Converter Oscillator Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, (1) I f the Condition Code Register I mask is set, Title I rRQI ~s completely ignored. (2) With the I mask set, the interrupt request flag ~ill not be latched. 0) (2) Reset starts Reset starts ~~LI Other Data Title I !E-I=l f::"'SEI ,-1 .... -1 , I I Reference Q & A Sheet , .... I ..... /' IRQ1 , .... ... ... I I - - IRQl ,~~ ... /' f I I W!£:.J ... ... f ... ... I ... ... ' ... I ... ~ ....... 1 IRQ! is ignored. IRQl is ignored. Supplement I CLI : Clears the Condition Code Register I mask SEI : Sets the Condition Code Register I mask * NMI is acce~table regardless of the I mask. ~HITACHI 1253 I HD6301V Questions & Answers - - - - - - - , - - - - - - - - - ' - - - - - - - - - - - - - - - Type HD6301 VI HD6303R I Device 45 I*8S 8M 16M Evaluation kit Emulator Software SD SBC Theme Timer Interrupt and External Interrupt I Date Nov. 24, 1983 Question I Classification 1, In the routine below, when is the next timer Parallel Port interrupt accepted? Serial Port Main Timer(OCI) External Interrupt Timer/Counter Routine Routine (IRQ) Routine BUS Interface I {Execution time (~xecution time=3ms) Interrupt * A/D ... ,","" / Store 2.6ms as timer --; period to the OCR Next ~. =1. Sms) ~ Execution timE -0 EOCI- CLI is longer thar Converter Oscillator Reset timer inter- Low Power Consm. Timer , ru'pt period. EPROM-on-package Inter- * 1=1 Software ~~ rupt Evaluation Kit Request Emulator SD RTI RTI Data Buffer Others Answer] Appli ~ab Ie Manual 1, The next timer interrupt is accepted in the main Title I routine just after RTI instruction execution. Main Timer(OCI) External Interrupt ROU~ROU'ine Other Data NOX' __ ~ Title I Timer Inter- RTI rupt Reque" J Next Timer (OCI) Routine Reference Q & A Sheet ~ QA631-012A I Supplement I ~HITACHI 1254 - - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers 8M 16M Softwan Type HD6301 VI HD6303R Device I 4S I *8S Evaluation kit, Emulator SD SBC Theme IRQl Interrupt and Other Interrupts (NO. 1) Date Nov. 24, 1983 I Question I Classification 1, rRQT pin (pin 5) is held at low for 1~s but an Parallel Port interrupt do:s not occur. Wha?t should be done to r--r~TS~~~mr~ei~ra~/l~C~Po~uo~n~r~tt-e-r------~ generate an ~nterrupt sequence. ~ BUS Interface * AID Interruot Converter E IRQl 1 1 II I 1 W~ SS I I , Oscillator Reset Low Power Consm. EPROM-on-package , I I Software I r:::: l~s ">l Evaluation Kit Emulator SD Data Buffer Others Answer 1 Aoplicable Manual 1, (1) IRQl ~s a level sens~t~ve interrupt pin which Ti tIe I' needs a minimum of 2 machine cycles (~s at 1MHz) to accept an interrupt. However, if another interrupt has been already generated, no interrupt request is accepted with IRQ1 at low for 1~s. In such a case, IRQ1 should be held at low until the request ~s acceptre~d~.__, Other Data E _---'I I 1 I ~ Titlel L - I_ - - ' , ~I_~~~R~~~~' ~2 machine cycles~ I I (2) In this case, as a timer interrupt ~s executec Reference Q & A Sheet the interrupt mask is automatically set. SO IRQ1 .J!£:J ~s ignored. QA63l-011A See the next page for the illustration of IRQ1 anc other interrupts and a countermeasure. Supplement I ~HITACHI 1255 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301 VI· 45 *8S 8M 16M 50ftwar HD6303R Evaluation kit, Emulator 5D SB Them IRQl Interrupt and Other Interrupts (No.2) IRQl and Other Interrupts Main Timer IRQ1 Routine Routine Routine IRQl Interrupt ....... .... -------------------~~~, Request ... ...... ,, ~ 1=1 I ... I IRQI is ',j. ignored. Countermeasure Clear the I mask at the beginning of the timer interrupt routine. Main Timer IRQl Routine Routine Routine IRQl is acceptable. * CLI : Clears the interrupt mask (1=0). With this method, note the following ; (1) IRQl may be ignored when the request occurs during timer interrupt vectoring. (2) Interrupts form NMI or SWI are excluded. ~HITACHI 1256 - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301 VI HD6303R Device I 4S I *~S 8M 16M Evaluatlon kit Emulator Software SD SBC ThemE CLI Instruction and Interrupt Operation Date Nov. 24, 1983 I QuestionJ Classification I, In the HD630lV, a timer interrupt is not accepted ~~~P~a~r~a~l~l~e~l~P~o~r~t~------4 in the following program. Is there any problem? Serial Port - - - - - - - - - -., , - Main Timer/Counter I Routine I BUS Interface I LOI CLI I * Interrupt I NOP : AID Converter : SEI I Oscillator I : I Reset r • I Low Power Consm. ~ ____ ~~ _~l__ J EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual I, To accept an interrupt, two machine cycles are Title I necessary between CLI and SEI. That is, in this HD630lX Data Sheet program, two NOP instructions are necessary. The same thing can be said when using TAP for CLI and Semiconductor Data Boo~ SEL - 8-Bit Slngle Chip Microcomouter - Using CLI Using TAP Other Data r------------- - -- -- ---- - ---------, Title I : L01 CLI : TAP (Clears the I mask) Nap I Nap I I I I I Nap I NOP I I SEI I TAP (Sets the I mask) I I.. !'. f--:---::-----,-....,..--....,..--~--_I I I : Reference Q & A Sheet I : I: :~ :.... - - - _ _ BRA L01 ___ r _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _I _ _ _ _ _ _ ..L.. I * This is mentioned in the HD630lX data sheet but not in the HD6301V. Supplement I • HITACHI 1257 I HD6301V Questions & Answers - - - - - ' - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301V1 HD6303R IDevice I 4S *8S 811 1611 Evaluation kit, Emulator Software SD SBC Theme Relation between the External Clock (EXTAL Clock) and Enable Clock (E Clock) I Date Nov. 24, 1983 Question I Classification 1, With which edges of the EXTAL clock does the Parallel Port E clock change synchronously, rising edge ( t ) Serial Port or falling edge ( .r, )7 Timer/Counter BUS Interface Interrupt A/D Converter * Oscillator Reset Low Power Consm. EPROH-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Hanual 1, It changes synchronously with the falling edge Title I ( ,J,) of the EXTAL clock. HD6301V User's Hanual ~ EXTAL Other Data Ti tIe I E Reference Q & A Sheet ~ Supplement I ~HITACHI 1258 - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl HD6303R I Device I Evaluation 4S *8S 8M 16M kit, Emulator Software SD SBC Theme Constants of the Reset Circuit Date I Nov. 24, 1983 Question Classification 1, Does the capacitor of the recommended reset circuit Parallel Port in the HD6303R (HD6301Vl) have an upper limit? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator * Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, Capacitor Cr does not have upper limit because Title I of the Schmitt trigger circuit provided with HD6301V User's Manual the RES. Available if Rr·Cr»2Oms To the system power supply .. -""" ... I ..... Other Data T rrr I Title I NMI 7.7 [ Reference Q & A Sheet To f 11. 9 T Rr ~c r ~. QA631-016A peripherals ~ HD030lV Supplement I ~HITACHI 1259 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301V1 I Device t Evaluation 4S *8S 8M 16M Software Theme HD6303R Schmitt Trigger Circuit of RES - kit, Emulator Date I SD SBC Nov. 24, 1983 Question Classification 1, Is Schmitt trigge r circuit provided with the Parallel Port H.D6303R/H.D6301V1 RES? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator * Reset Low Power Consm. EPROM-an-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, Yes. (Hentioned in the HD6301V User's Manual) Title I HD6301 V User 1s Hanual To the system power supply .. ".. ~ I"" 11& ~ I- I vcr: R. Other Data rrr I .. Iv- STBY ~YI NMI c;;-- Titlel ;;rc. f ,Lt, R. Rr 'l[ES t:>.. RES. ~ Reference Q & A Sheet To peripherals HDU01V ~- QA631-015A Ro« Ik. a ... Cr»20m. QA631-020A Supplement I Effects of the Schmitt trigger circuit: Even on the slow rising edge of input pulse, stable and clear waveform can be output. ~HITACHI 1260 - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl HD6303R IDevice J 4S *8S 8a 16M Evaluation kit, Emulator Software SD SH~ Theme I/O Port State on Resetting I Date Nov. 24, 1983 Question I Classification 1, \Vhat is the state of each port on resetting Parallel Port (RES='O')? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset * Low Power Consm. EPRm1-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Ap~).icable Hanual 1, It is as follows: Title I Port 1 High impedance state Port 2 l' Modes 1, 5 t * Port 3 Modes E: Other Data -E: l' 0,2,4,6 "1" is output. Title I Hode High impedance state Hicrocomputer Technica 7 Information (D1-23) Port 4 t Reference Q & A Sheet * The state of Port 3 differs depending on the mode. ~. QA631-018A Supplement E: The E clock is "H u • -E: The E clock is "L". ~HITACHI 1261 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - : - - - - - - - - - Type HD630lVl HD6303R I Device I Evaluation 4S *8S 8U l6U kit, Emulator Software SD SBe Theme SCI (Pin 39) State on Resetting Date I Nov. 24, 1983 Question Classification 1, \fuat is the state of SCI (Pin 39) on resetting Parallel Port (RES='O')? Serial Port Timer/Counter BUS Interface Interrupt AID Converter Oscillator * Reset Low Power Consm. EPROH-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual l, It is as follows: Title I Mode SCl State 0 The address strobe is output. 1 l' 2 l' 4 l' Other Data 5 "1" is output. Title I 6 The address strobe is output. 7 High impedance state Reference Q & A Sheet ~. QA63l-017A Supplement I SCl: Control signal of the HD630lV. The usage differs depending on the mode. $ HITACHI 1262 - - - - - - - - - - - - . . . . . . - . . , - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301V1 HD6303R I Device I 4S *8S 8M 16M Evaluation kit, Emulator Software SD SBC Theme Port Output After Resetting I Date Nov. 24, 1983 Question I Classification 1, What data does a port output when the Data Parallel Port Direction Register(DDR)=l after resetting? Serial Port Timer/Counter BUS Interface Interruj)t A/D Converter Oscillator * Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, After resetting, since the Data Register of a Title I port is undefined, undefined data is output when the DDR=l. Input definite data by programming in the Data Register before setting the DDR=L Other Data Title I Reference Q & A Sheet ~ Supplement I ~HITACHI 1263 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301V1 HD6303R I Device I Evaluation 4S *8S 8M 16M kit, Emulator Software SD SBC Theme Schmitt Trigger Circuit of STBY Date I Nov. 24, 1983 Question' Classification 1, Is the Schmi t t trigger circuit provided with the Parallel Port HD6303R STBY? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset * Low Power Consm. EPR0!1-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, Yes. (Mentioned in the HD6303R User's Manual.) Title I HD6301V User's Manual To the system power supply ... , ... ~ I '" r I"""' "+ Other Data VC~ R. NMI Title I 7.7 'r ... STBY _r;:;.....STBY, 1;Y" ,~ I I f- R. ;;re. Rr RES J'::;>....RES, -V- (-Ie, .. Reference Q & A Sheet ~. QA631-01SA HD 4:1 0 LV' To 114«R. ,Rr.C:r»!Oma QA631-016A peripherals Supplement I Effects of the Schmitt trigge r ci rcui t : Even on the slow rising edge of the input pulse, stable and clear waveform can be output. ~HITACHI 1264 - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl I Device I 4S *8S 8M 16M Software Theme HD6303R I/O Port State During Standby I Evaluation kit, Emulator SD Date Nov. 24, 1983 SBC Question I Classification 1, What is. the state of each port during standby Parallel Port (STBY='O')? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consm. * EPROM-on-package . Software Evaluation Kit Emulator SD Data Buffer Others Answer Applicable Manual 1, As follows: Title I Port 1 High impedance state Port 2 Port 3 '"+ Port 4 + Other Data Ti t Ie I Microcomputer technical information (D1-23) Reference Q & A Sheet ~. QA631-0l7A QA63l-0l8A Supplement I ~HITACHI 1265 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301Vl HD6303R I Device I Evaluation 4S *8S 8M 16M kit Emulator Software SD SBC Theme Return from Standby Mode Date I Nov. 24, 1983 Question I Classification 1 , What occurs when returning from the standby mode Parallel Port without using RES? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset * Low Power Consm. EPROM-an-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, The MPU does not operate normally because the Ti tIe I contents of. each register are not definite. HD6301Vl data sheet Therefore, always use the RES when returning from HD6301V user's manual the standby mode. Other Data Title I Reference Q & A Sheet ~ Supplement I ~HITACHI 1266 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl HD6303R I Device 1 4S *8S 8M 16M Evaluation kit, Emulator SoftwarE SD SBj: Theme Going into the Standby Mode I Date Nov. 24, 1983 Question I Classification 1, Does the HCU go into the standby mode after Parallel Port current instruction execution is completed? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset * Low Power Consm. EPROH-on-package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Hanual 1, No. Because there is no connection between the Title I instruction execution sequence and the standby mode. That is, when the STBY pin goes into "Low .. , the state is latched at the next rising edge of E clock. Then· the internal registers are reset at the next falling edge. :~ 1; nternal regis ten , are reset. E , Other Data ,, THIel , , -- STBY , I t Reference Q & A Sheet ~. QA631-024A Supplement l As standby mode detection has no connection with the instruction execution sequence, the HCU goes into the standby mode after preparing for standby mode with NMI routine. ~HBTACHn 1267 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301V1 HD6303R I Device I Evaluation 4S *8S 8M 16M kit, Emulator Software SD SBC Theme Timing for the Standby Mode Datel Nov. 24, 1983 Question I Classification 1, The timing for the standby mode is shown in the Parallel Port HD6301V user's manual. Tl is not defined. How Serial Port long is Tl ? Timer/Counter BUS Interface CD NMI ! I Interrupt I I A/D Converter (?) RES ,-' ,I ;I Td"- I Oscillator ,, Reset G) STBY I I * Low Power Consm. EPROH-on-package ~ . ,~ I lT2J. I I ~ ;:>OJ.Lware RAH Control . I Reset Start Evaluation Kit Register Set Emulator SD *T2 : Oscillation Stabilization Time Data Buffer Others Answer I Applicable Manual 1, After the RAM Control Register is set in the NMI Title I routine, either STBY or RES can be in the low HD6301V User's manual state with no priority. Other Data Title I Reference Q & A Sheet ~, QA631-023A Supplement I RAM Control Register Set -7 RAM E bit =0 STB Y P\VR bit = 1 RAM E bit = 0: Internal RAM is not accessable. STB Y P\VR bit = 1: Indicates that the data in standby RAM is valid. ~HITACHI 1268 - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type RD6301V1 I DeviceI 4S *8S 8M 16~1 Software RD6303R I Evaluation kit, Emulator Theme Usage of EPROt1 Socket Pins for the HD63POH1 (No.1) SD Date Nov. 24, 1983 SBC Question I Classification 1, Are the data buses of the EPROH socke t pins for Parallel Port the HD63P01M bi-directional in order to access not Serial Port only the EPROH but the RAM? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consm. * EPROH-on-package Software Evaluation 'Kit Emulator SD Data Buffer Others Answer I Ayplicable Hanual 1, The data bus output from EPROM socket pins for Title I the HD63POH1 is Read only. RD63P01H Data Sheet Other Data Title I Reference Q & A Sheet ~, QA631-026A QA631:-027A Supplement I ~HITACHI 1269 I HD6301V Questions & Answers - - - - - - - - - . - - - - - - - - - - - - - - - - - Type HD6301Vl 8M 16M Software HD6303R kit, Emulator SD SBC Theme Usage of EPROH Socket Pins for the HD63POUl (No.2) I Date Nov.24, 1983 ·QuestionJ Classification 1, In EPROH socket pins for the HD63POUl, what is Parallel Port CE composed of? Serial Port Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consm. * EPROH-on-package Software Evaluation Kit Emulator SD . Data Buffer Others Answer I Applicable Manual 1, CE is a NAND circuit of the address bus (A13 to Title I AlS) and the MCU internal R/~ signal. (Refer below.) Therefore, CE does not output in the dummy cycle. (When not accessing EPROH of HD63POIM) ~········R"/W····~ Other Data ··· ... Title 1 ··· .. A . : 0: ... Reference Q & A Sheet -- --:CE ~. A14 QA631-02SA A 1S :-- .......................... QA631-027A Supplement I ~HITACHI 1270 - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301Vl HD6303R I DeviceI 4S *8S 8M 16M Evaluation kit, Emulator Software SD SBC Theme Usage of EPROH Socket Pins for the HD63POll1 (No.3) I Date Nov. 24, 1983 Question I Classification 1, Wi th EPROM socket pins for the 1ID63P01M, Parallel Port (1) Can pins drive one TIL load or more? Serial Port ( 2) If not, what can pins drive? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consm. * EPROll-on -package Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual 1, (1) The current of each pin is too little to drive Title I one TTL load. ( 2) Each pin can drive one NHOS load. Other Data Title 1 Reference Q & A Sheet ~. QA631-025A QA631-026A Supplement I ~HITACHI 1271 I HD6301V Questions & Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD6301 VI I Device I 4S * 8S 8M 16M Software Theme HD6303R 1 Evaluation kit, Emulator Usage of Bit Manipulator Instructions (No.1) SD Date Nov. 24, 1983 SBC Q Classification 1- How the bit manipulation instructions of the Parallel Port HD630lV should be written? Serial Port Timer/Counter BUS Interface Interrt!E.t A/D Converter Oscillator Reset Low Power Consm. EPROM-on~ackaEe * Software Evaluation Kit Emulator SD Data Buffer Others A AIlpl ic ab Ie Manual 1- They are written as follows; Title! written as follows ; HD6301 V Data Sheet OIM If $ 0 4 , $ 1 0 (Direct Addressing) HD6301 V User's Manual OIM if $ 0 4 , $ 1 0, X (Index Addressing) ~ .-r ~Index Register Immediate Data Address Other Data TitleJ This 1S an example of OR operation of the immediate data and the memory and storing the result 1n the memory. The HD630lV has the following bit manipulation instructions. Reference Q & A Sheet OIM .' ... (IMM) . (M) -7 (M) ~ AIM · ...(IMM) + (M) ~ (M) ElM ·... (IMM) <3 (M) ~ (M) . QA631-029A TIM ·... (IMM) (M) These instructions are written in the same way. * Continued on the nex t --.2.C!.Re. Supplement I ~HITACHI 1272 HD6301V Questions & Answers Type HD6301V1 I Device 4S * 8S I 8M 16M Software HD6303R Evaluation kit, Emulator SD SBC ThemE Usage of Bit Manipulator Instructions (No.2) The following bit manipulations have different mnumon~css ~n the same OP code. OP COdE Bit Manipulation Insturction Mnumonics Function 0 - Mi 71 61 A I M BeL R The memory bit i(i=O to 7) ~s cleared and the other bits don't change. 1 - Mi 72 62 o I M B SET The memory bit i(i=O to 7) ~s set and the other bits don't change. Mi - M~ 75 65 ElM B T GL The memory bit i(i=O to 7) ~s inverted and the other bits don't change. 1 . Mi 7B 6B TIM B T S T AND operation test of the memory bit i(i=O to 7) and "I" ~s executed and its correspond ing condition code ~s changed. .i ~ D~rect Index Addressing Addressing The mnumonics mentiond above can be written as follows. B C L R 3, $ 1 0 BA I M if $ F 7 , $ 1 0 (Direct Addressing) BC L R 3, $ 1 0, X ~A I M 1ft $ F 7 , $ 1 0 , X (Index Addressing) B S E T 3, $ 1 0 HO I M ift $ 0 8 , $ 1 0 (Direct Addressing) B S E T 3, .LU., ! 0 0 I M ift $ 0 8 , $ 1 0 , X (Index Addressing) r Bit t Address ~ Index Register *For details, see HD6301V Users Manual. ~HITACHI 1273 I HD6301V Questions &Answers - - - - - - - - - - - - - - - - - - - - - - - - - - - Type HD630lVl HD6303R IDevice I 4S * 8S 8M 16M Evaluation kit Emulator Software SD SBe Theme Usage of Bit Manipulation Instructions to the Port I Date Nov. 24, 1983 Q Classification 1. Are the bit manipulatiori instructions (AIM, OIM, Parallel Port ElM, TIM) executable when a port is in the output ~-r~S~e~r~i~a~1~P~o~r~t~----4 state (DDR=l)? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consm. EPROM-on-package. * Software Evaluation Kit Emulator SD Data Buffer Others A Applicable Manual Title I 1. It can be used if the port is in the output state (DDR=l). However, the bit manipulation instruc- tion is executed as follows ; 1 Reads specified address. 2 Executes logical operation Other Data 3 Writes the result into the specified address. Ti tIe I Since the specified address(l) reads the pin state of the port, ·the data is influenced by the pins even if any dat~ is output from the port. Reference Q & A Sheet ~ QA631-028A Supplement I DDR : Data Direction Register This register selects whether in the port is the input or the output state. DDR = 0 : Data input DDR = 1 : Data output ~HITACHI 1274 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HD6301V Questions & Answers Type HD6301 VI HD6303R I Device 1 4S *8S 8M 16M Evaluation kit, Emulator Software SD SBC Theme RAM Access Disable during Program Execution pate I Nov. 24, 1983 Question I Classification 1, When executing a program. with the RAME bit of the Parallel Port RAM Control Register disabled, Serial Port Timer/Counter (1) What occurs if the internal RAM address is BUS Interface accessed? Interrupt (2 ) What occurs if the interrupt requests are A/D Converter generated? Oscillator Reset Low Power Consm. EPROM-on-package Software Evaluation Kit Emulator SD Data Buffer * Others Answer I Applicable Manual 1, (1) The external RAM can be accessed; the interna Title I RAM ~s neither readable nor writable when the RAME bit is disabled. HD6301V Data Sheet (2) If there is no stacking area other than the HD6301V User's Manual internal RAM, .the MPU will burst when returning from the interrupt sequence. Other Data Title I Reference Q & A Sheet ~ Supplement I RAM Control Register 7 6 $0014 Ct-----=:I ---- RAME bi t * RAME='O' : Disable the Internal RAM Address ~HITACHI 1275 I 2. HD6301XO/HD6303X OSCILLATOR CIRCUIT . Ci Quartz Oscillation Circuit gm = G.CM + CI gm ----- (3) 1. Quartz oscillation circuit and oscillation G: Inverter B gain conditions (voltage amplification ratio) A typical quartz oscillation circuit and its Inverter A's gm relatively reduces to (3), and load equivalent circuit are shown in Fig. 1. resistance Rz of equation (2) also decreases, Oscillation conditions can be represented as which prevents or stops oscillation. follows: Reducing inverter B's gain G increases gm I -Rzi > Re .............(1) according to (3). When resistance RL is added, Rz = gm/w2C 1C2 • • • • • • • • • (2) inverter B's gain G can be reduced since the bias voltage deviates from the maximum gain -Rz: Quartz circuit resistance (based on pOint. quartz) gm: Inverter transfer conductance However, applying resistance RL reduces the gm: dlout/dVin gain of oscillation inverter A itself. Too small RL results in adverse effects. A stimulation result of Therefore, normal oscillation can be performed if RL:s optimized value is shown in Fig. 5. This is a negative resistance is sufficiently high. transfer curve showing the change of oscillation However, oscillation stability is affected not only circuit loop gain due to presence or absence of by external capacitance C1 and C2, but also by RL. It indicates that RL from 2-100 Mohm gives external factors such as floating capacitance or sufficient gain. However, optimum RL is 10 or resistance dependent on substrate circuit less due to substrate leak current. 2-5 Mohm is patterns, power stability time, and interference best. from other signal lines. Accordingly, sufficient care should be taken to pattern designing of the oscillation terminal periphery. Regarding LSI, oscillation stability is affected by the inverter's gm. gm changes depending on inverter input voltage of the inverter, i.e., bias voltage. 2. Oscillation halt and countermeasure The oscillation circuit works under condition (1) above. However, in some cases, oscillation conditions are not satisfied because of the mutual interference described in 1 above. To assure oscillation start, add resistance RL to the input (EXTAL) terminal of the oscillation circuit to fix bias voltage. 2 to 5 Mohm resistance is best. 3. Explanation of oscillation halt and its countermeasure This section explains oscillation halt based on LSI internal circuits. A quartz oscillation circuit built in a microcomputer consists of inverter A used for oscillation and inverter B providing clocks on the LSI internal circuit. Parasitic capacitance CM between these inverters' output and input generates negative feedback with a feedback ratio of CM/CI. Since inverter B appears in the same phase as inverter A, this negative feedback prevents oscillation. ~HITACHI 1276 Rf (a) Quartz oscillation circuit C Rz LSI Quartz L Re (b) Equivalent circuit Fig. 1 Quartz oscillation circuit and equivalent circuit EXTAL XTAL Fig. 2 Oscillation stop countermeasure @HITACHI 1277 I Cm ,-----11----, )---~ To internal circuit ,, 1--- Ci::::: 7lT Rf Fig. 3 Practical oscillation circuit Rf = 1 Mohm R1> R2 = 500 ohm (ESD protective resistance) Vout Vin = Vout Vin Fig. 4 Inverter transfer curve (Input/output voltage characteristics) Bias voltage moves to the left on the transfer curve by adding RL ~HITACHI 1278 ...J a: <1> ~ () "E c: CII ::J :::di c: 0 en 0 0<1> ~ ~a: (ij "u en E 0 ~ w c: "(ij CJ 0 a. " RES STay P" P" Po> P" P" P" P" P" P" P" P" P,. P,. PH P2I P" P" P" p]) ... P" P" P" P" P" p)'!J- p" P" P" P" Ie: P" SC,4' *Contact Hitachi Sales Office P•• P., p., P" Pori P.. 4 P" P" P" ~HITACHI 1285 I WIDE TEMPERATURE HD6301V1, HD63A01V1, HD63B01V1 SPECIFICATIONS -40°C TO + U5°C (J VERSION) • ABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply Voltage Vee -0.3 - + 7.0 V Input Voltage Vin -0.3 - Vee +0.3 V Operating Temperature * Topr -40 to +85 DC Storage Temperature Tstg -55 to +150 DC (NOTE) This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation. we recommend Vin , Vout : Vss :5 (Vin or Vouu :s Vee. *K version (-40 to + 12SDC) available. Contact sales office. • ELECTRICAL CHARACTERISTICS • DC CHARACTERISTICS IVee =5.0V±10%, Vss = OV, Ta = -40 to +85 C, unless otherwise noted.) D Item Symbol Test Condition min typ max Unit RES, ST8Y Vee-0.5 - Vee Input "High" Voltage EXTAL V'H Vee xO.7 - +0.3 V Other Inputs 2.0 - Input "Low" Voltage All Inputs V'L -0.3 - 0.8 V Input Leakage Current NMI, iRQ., m, STBY lI in I V'n =0.5-V ee -0.5V - - 1.0 J1.A Three State loff-state) p. o-P 17 , P20 -P2., IiTS,I V in = 0.5-V ee -0.5V - - 1.0 J1.A Leakage Current P30-P37 , P4Q-P'7, TS3 IOH = -200J1.A 2.4 - - V Output "High" Voltage All Outputs V OH IOH - -10J1.A Vee- 0.7 - - V Output "Low" Voltage All Outputs VOL IOL = 1.6mA - - 0.55 V Vin=OV, f= 1.0MHz, Input Capacitance All Inputs C in - - 12.5 pF Ta = 25°C Standby Current Non Operation lee V'L(STBY) = 0 - 0.6V - 2.0 15.0 J1.A V'H(RES) = Vee- 0.5- Vee V V,dRES) = 0 - 0.6V Current Dissipation· Operating If=l MHz··) - 6.0 10.0 lee mA Sleeping If=l MHz··) - 1.0 2.0 RAM Stand·By Voltage V RAM 2.0 - - V • VIH,min'" Vcc-'1.0V. VIL max = O.8V •• Current Dissipation of the operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about Current Dissipations at f = x MHz operation are decided according to the following formula; typo value (I· x MHz) • tYP. value (I - 1 MHz) • x max, value tf· x MHz) c max. value If • 1MHz) x x (both the sleeping and operating) ~HITACHI 1286 HD6301V1, HD63A01V1, HD63B01V1 WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) • AC CHARACTERISTICS (Vee· 5.0V±10%, Vss =OV, Ta = -40 to + 8Soe, unless otherwise noted.) BUS ·TIMING Test HD6301Vl HD63A01Vl HD63B01Vl Item Symbol Can· Unit dition min typ max min typ max min typ max Cycle Time t cvc 1 - 10 0.666 - 10 0.5 - 10 IlS Address Strobe Pulse Width "High" PW ASH 220 - - 150 - - - 110 - ns Address Strobe Rise Time tASr - - 20 - - 20 - - 20 ns Aadress Strobe Fall Time tAS! - - 20 - - 20 - - 20 ns Adpress Strobe Delay lime tASO 60 - - 40 - - 20 - - ns Enable Rise Time tEr - - 20 - - 20 - - 20 ns Enable Fall Time tEl - - 20 - - 20 - - 20 ns Enable Pulse Width "High" Level PWEH 450 - - 300 - - 220 - - ns Enable Pulse Width "Low" Level PWEL 450 - - 300 - - 220 - - ns 20 - - Address Strobe to Enable Delay 60 - - 40 - - ns t ASEO Time Address Delay Time ~ Fig: .5.1 - - 250 - - 190 - - 160 ns tA02 - - 250 - - 190 - - 160 ns Address Delay Time for Latch t AOL Fig: .5.2 - - 250 - - 190 - - 160 ns Data Set·up Time Write tosw 230 - - 150 - - 100 - - ns Read tOSR 80 - - 60 - - 50 - - ns Data Hold Time Read tHR 0 - - 0 - - 0 - - ns Write tHW 20 - - 20 - - 20 - - ns Address Set·up Time for Latch t ASL 60 - - 40 - - 20 - - ns Address Hold Time for Latch tAHL 30 - - 20 - - 20 - - ns Address Hold Time tAH 20 - - 20 - - 20 - - ns Ao - A, Set·up Time Before E tASM 200 - - 110 - - 60 - - ns Peripheral Read INon·Multiplexed Bus (tACCN) - - 650 - - 395 - - 270 ns Access Time I MUltiplexed Bus (tACCM - - 650 - - 395 - - 270 ns Oscillator stabilization Time tRC .. Fig.2·7-1 20 , - - 20 - - 20 - - ms Processor Control Set·up Time tpcs Fig.2-B-l 200 - - 200 - - 200 - - ns PERIPHERAL PORT TIMING Test HD6301Vl HD63A01VI HD63B01VI Item Symbol Con- Unit dition min typ max min typ max min typ max Peripheral Data Set·up Time Port 1, 2, 3, 4 tposu .. Fig. 5-3 200 - - 200 - - 200 - - ns Peripheral Data Hold Time Port 1,2,3,4 tpOH Fig. 5-3 200 - - 200 - - 200 - - ns Oelay Time, Enable Positive Transition to OSJ Negative Transition tOSOl .. Fig. 5-5 - - 300 - - 300 - - 300 ns Delay Time, Enable Positive Transition to ~ Positive Transition taS02 .. Fig. 5-5 - - 300 - - 300 - - 300 ns Delay Time, Enable Nega-I Port 1 tive Transition to Peri- pheral Data Valid 2' 3 ,; tpwo ' , Fig .• ~-4 - - 300 - - 300 - - 300 os Input Strobe Pulse Width lpwlS Fig~;-6 200 - - 200 - - 200 - - ns I Port 3 - - - 150 - - I Input Data Hold Time tlH Fig~~-6 150 150 - ns Input Data Setup Time I Port 3 tiS Fig .•~-6 0 - - 0 - - 0 - - ns · Excopt P21 • 'Refer to Pages 189-190 ••• Refer to Pages 159-160 ~HITACHI 1287 WIDE TEMPERATURE HD6301V1, HD63A01V1, HD63B01V1 SPECIFICATIONS -40°C TO +85°C (J VERSION) TIMER, SCI TIMING Test HD6301Vl HD63A01Vl HD63B01Vl Item Symbol Con- Unit dition min typ .max min typ max min typ max Timer Input Pulse Width tpWT 2_0 - - 2_0 - - 2.0 - - tCYC Delay Time, Enable Positive Transition to Timer Out tTOD FI9...S-7 - - 400 - - 400 - - 400 ns SCI Input Clock Cycle t Scve 2.0 - - 2.0 - - 2.0 - - tCyc SCI Input Clock Pulse Width tpWSCK 0.4 - 0.6 0.4 - 0.6 0.4 - 0.6 tSeyc MODE PROGRAMMING Test HD6301Vl HD63A01Vl HD63B01Vl Item Symbol Con- Unit dition min typ max min typ max min typ max RES "low" Pulse Width PW ASTL 3 - - 3 - - 3 - - tCYC Mode Programming Set·up Time tMPS Flg;.S-S 2 - - 2 - - 2 - - tCYC Mode Programming Hold Time tMPH 150 - - 150 - - 150 - - ns ""Refer to Pages 189-190 ~HITACHI 1288 WIDE TEMPERATURE HD6301XO, HD63A01XO, SPECIFICATIONS -40°C TO + 85°C HD63B01XO (J VERSION) The HD6301XO is a CMOS single-chip microcomputer unit HD6301XOPJ, HD63A01XOPJ, (MCU) which includes a CPU compatible with the HD6301Vl, HD63B01XOPJ 4k bytes of ROM, 192 bytes of RAM, 53 parallel 110 pins, a Serial Communication Interface (SCI) and two timers on chip_ • FEATURES • Instruction Set Compatible with the HD6301V1 • Abundant On-chip Functions 4k Bytes of ROM, 192 Bytes of RAM 53 Parallel 110 Ports 16-Bit Programmable Timer 8-Bit Reloadable Timer Serial Communication Interface Memory Ready Halt HD6301 XOCPJ, HD63AOl XOCPJ, Error-Detection (Address Trap, Op Code Trap) HD63B01XOCPJ • Interrupts ___ 3 External, 7 Internal • Operation Mode Mode 1 ___ Expanded (Internal ROM Inhibited) Mode 2 ___ Expanded (Internal ROM Valid) Mode 3 ___ Single-chip Mode • Low Power Dissipation Mode Sleep Standby • Wide Range of Operation Vcc =5V±10%( 1=0.1 to 1.0MHz: HD6303Y ) 1 = 0.1 to I.SMHz: HD63A03Y (CP-68) 1 = 0.1 to 2.0MHz: HD63B03Y 1 = 0.1 to 3.0MHz : HD63C03Y HD6301XOF', HD63A01XOF*, HD63BOl XOF' • GENERIC PART NUMBER HD6301XOPJ,HD63A01XOPJ,HD63B01XOPJ HD6301XOCPJ,HD63A01XOCPJ,HD63B01XOCPJ (FP-80) • Contact Hitachi Sales Office ~HITACHI 1289 I WIDE TEMPERATURE HD6301XO, HD63A01XO, HD63B01XO SPECIFICATIONS -40°C TO +85°C (J VERSION) • PIN A",RANGEMENT • HD6301XOPJ, HD63A01XOPJ, HD63B01XOPJ HD6301XOCPJ,HD63A01XOCPJ • HD6301XOF·, HD63B01XOCPJ HD63A01XOF· , v.. XTAL EXTAl . 0 HD63B01XOF· MP, MP, liES STBY NMi . o ft;j{~5!l .. :':l~l':: ~ :: .... :: PM' P" P" , Pu I P" P" PH P" P" P" ".1; P" ~:c. P" Po. , p.. p.. P" ~~~O~NM~~~~W~O_NM NNNMMMMMMMMMM~~~~ P" P., P" P" ~~f~~~~~g~~~~~~~~ P" P., P" P" P" p.. (Top View) (Top View) p.. p.. , P" p.. (CP·6S) (FP·SO) P" ......_ _ _ _ _ ~v" (Top View) ·Contact Hitachi Sales Office (DP.64S) • BLOCK DIAGRAM ! JI I I purr... " P~riSClICJ I',.rnn, "nCR., P"lTx) ~~i~ r-"LLLLLL-,.,,;;o '"".Nil' P"IAIW p'JtCiR "nCTout21 '-...---~- ....!8A P..tT_31 PIJITCllCl~-ItI+It-l ....cRftr., p"tIJR&l PuCMJItI ...J(RAtT1 ......'" '" ~HITACHI 1290 HD6301XO, HD63A01XO, HD63B01XO WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) • ABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply Voltage Vee -0.3 - + 7.0 V Input Voltage Vin -0.3 - Vee +0.3 V Operating Temperature Topr -40 to +85 °C Storage Temperature Tstg -55 to + 150 °C (NOTE) This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend Yin. Vout : VSS .::5 (V in or Vout) .::5 Vee. • ELECTRICAL CHARACTERISTICS • DC CHARACTERISTICS (Vee = 5.DV±lD%, Vss = DV, Ta = -40 to +85°C, unless otherwise noted.) Item Symbol Test Condition min lyp max Unit RES,STBY Vee- O.S - Vee Input "High" Voltage EXTAL V IH Vee xO.7 - +0.3 V Other Inputs 2.0 - Port 22 V IH 2.2 - V Input "Low" Voltage All Inputs V IL -0.3 - 0.8 V NMI, RES, STBY, Input Leakage Current MPo, MP., Port5 IIlnl Yin = 0.5-V ee -0.5V - - 1.0 p.A Three State (off·state) Leakage Current Ports 1,2,3,4, 6, 7 II Ts ti Yin = 0.5- Vee-0.5V - - 1.0 p.A Output "High" Voltage All Outputs IOH - -200p.A 2.4 - - V V OH IOH = -10p.A Vee-0.7 - - V Output "Low" Voltage All Outputs VOL IOL = 1.6mA - - 0.4 V Darlington Drive Current Ports 2, 6 -loH Vout = 1.5V 1.0 - 10.0 mA Vin=OV,f= lMHz, Input Capacitance All Inputs Cin Ta = 25°C - - 12.5 pF Standby Current Non Operation ISTB - 3.0 15.0 p.A Sleeping (f = lMHz") - 1.5 3.0 mA I SLP Sleeping (f = 1.5MHz··) - 2.3 4.5 mA Current Dissipation' Sleeping (f = 2MHz") - 3.0 6.0 mA Operating If = lMHz") - 7.0 10.0 mA Icc Operating (f = 1.5MHz··) - 10.5 15.0 mA Operating (f = 2MHz") - 14.0 20.0 mA RAM Standby Voltage V RAM 2.0 - - V ·VIH min· Vcc-1.OV. VIL max" O.SV (All output terminals are at no load,) ··Current Dissipation of the operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about Current Dissipations at x MHz operation are decided according to the following formula; typo value (I - x MHz) - typo valuo (I - 1 MHz) x x max. value (f - x MHz) - max. value (f - 1 MHz) x x (both the sleeping and operating) ~HITACHI 1291 WIDE TEMPERATURE HD6301XO, HD63A01XO, HD63B01XO SPECIFICATIONS -40°C TO +85°C (J VERSION) • AC CHARACTERISTICS (Vee = S.OV±10%. Vss K OV. Ta = -40 to + as·c, unless otherwise noted.) BUS TIMING Test HD6301XO HD63A01XO HD63B01XO Item Symbol Unit Condition min typ max min typ max min typ max Cycle Time tcyC 1 - 10 0.666 - 10 0.5 - 10 /JS Enable Rise Time tEr - - 25 - - 25 - - 25 ns Enable Fall Time tEf - - 25 - - 25 - - 25 ns Enable Pulse Width "High" Level' PW EH 450 - - 300 - - 220 - - ns Enable Pulse Width "Low" Level' PWEL 450 - - 300 - - 220 - - ns Address, R/WDelay Time' tAD - - 250 - - 190 - - 160 ns Data Delay Time I Write toow - - 200 - - 160 - - 120 ns Data Set-up Time I Read tOSA Fig. 1-1 80 - - 70 - - 70 - - ns Address, R/WHold Time' tAH " 80 - - 50 - - 35 - - ns Data Hold Time I Write' tHW 80 - - 50 - - 40 - - ns I Read tHA 0 - - 0 - - 0 - - ns RD. WR Pulse Width' PWAW 450 - - 300 - - 220 - - ns RJ:). WA Delay Time tAWO - - 40 - - 40 - - 40 ns RD, WR Hold Time tHAW - - 30 - - 30 - - 25 ns LIR Delay Time tOLA - - 200 - - 160 - - 120 ns [fR Hold Time tHLA 10 - - 10 - - 10 - - ns MR Set-up Time' tSMA 400 - - 280 - - 230 - - ns MR Hold Time' E Clock Pulse Width at MR tHMA PWEMA .. Fig. 1-2 - - - - 90 9 - - - - v 40 9 - - - - 0 9 ns /.IS Fi!,J·l:3 Processor Control Set-up Time tpcs 1-11,1-12 200 - - 200 - - 200 - - ns Processo( Control Rise Time tpcr Fig. 1-2, - - 100 - - 100 - - 100 ns Processor Control Fall Time tPCf 1-3'" ... - - 100 - - 100 - - 100 ns BA Delay Time teA Fig. 1-3 •• - - 250 - - 190 - - 160 ns Oscillator Stabilization Time tAC Fig. 1-12" 20 - - 20 - - 20 - - ms Reset Pulse Width PWAST 3 - - 3 - - 3 - - teyc • These timings change in approximate proportion to tcyc. The figures in this characteristics represent those when tcyc is minimum (- in the high ..t speed operation). , 'Refer to Pages 466-469 PERIPHERAL PORT TIMING Test HD6301XO HD63A01XO HD63B01XO Item Symbol Unit Condition min typ max min typ max min typ max Peripheral Data Fig. 1-5 Set-upTime Ports 2. 3. 5. 6 tposu 200 - - 200 - - 200 - - ns " Peripheral Data .i'orts 2, 3, 5. 6 tpOH Fig.I-S 200 - - 200 - - 200 - - ns Hold Time Delay Time (Enable Negative Transition to I P orts 1,2. tpwo " .. Fig. 1-6 - - 300 - - 300 - - 300 ns Peripheral Data Valid) 3.4.6,7 "Refer to Pages 466-469 ~HITACHI 1292 HD6301XO, HD63A01XO, HD63B01XO WIDE TEMPERATURE SPECIFICATIONS -40°C TO +85°C (J VERSION) TIMER SCI TIMING Test HD6301XO HD63A01XO HD63B01XO Item Symbol Unit Condition min typ max min ~ max min typ max Timer 1 Input Pulse Width tPWT Fig. 1-9* * 2.0 - - 2.0 - - 2.0 - - tcvc Delay Time (Enable Positive Transition to Timer Output) tTOD Flg.H,I-B** - - 400 - - 400 - - 400 ns SCI Input I Async. Mode Fig. 1-9* * 1.0 - - 1.0 - - 1.0 - - tcvc Clock Cycle I Clock Sync. tScvc Fig. 1-4. 1-9" 2.0 - - 2.0 - - 2.0 - - tCYC SCI Transmit Data Delay Time (Clock Sync. Mode) tTXD - - 200 - - 200 - - 200 ns SCI Receive Data Set·up Time (Clock Sync. Mode) tSAX Fig. 1-4*' 290 - - 290 - - 290 - - ns SCI Receive Data Hold Time (Clock Sync. Mode) tHAX 100 - - 100 - - 100 - - ns SCI Input Clock Pulse Width tPWSCK 0.4 - 0.6 0.4 - 0.6 0.4 - 0_6 tScyc Timer 2 Input Clock Cycle ttcvc 2.0 - - 2.0 - - 2.0 - - tCYC Timer 2 Input Clock Pulse Width tPWTCK Fig. 1-9* * 200 - - 200 - - 200 - - ns Timer 1'2, SCI Input Clock Rise Time tCKr - - 100 - - 100 - - 100 ns Timer 1'2, SCI Input Clock Fall Time tCKf - - 100 - - 100 - - 100 ns • * Refer to Pages 466-469 ~HITACHI 1293 I WIDE TEMPERATURE SPECIFICATIONS HD6301YO, HD63A01YO, -40°C TO +85°C (J VERSION) HD63B01YO,HD63C01YO HD6301YOPJ, HD63A01YOPJ, The HD6301 YO is a CMOS 8-bit single-chip microcomputer HD63B01YOPJ,HD63C01YOPJ unit which contains a CPU compatible with the CMOS 8-bit microcomputer HD6jOIV, 16k bytes of ROM, 256 bytes of RAM, 53 parallel 110 pins, Serial Communication Interface (SCD and two timers. • FEATURES • Instruction Set Compatible with the HD6301 VI • 16k Bytes of ROM. 256 Bytes of RAM • 53 Parallel 1/0 Pins (4B 1/0 Pins. 5 Output Pins) • Parallel Handshake Interface (Port 6) • Darlington Transistor Drive (Port 2. 6) • 16-Bit Programmable Timer (DP·64S) Input Capture Register x 1 Free Running Counter x 1 HD6301YOCPJ, HD63A01YOCPJ, Output Compare Register x 2 HD63B01YOCPJ,HD63C01YOCPJ • 8-Bit Reloadable Timer External Event Counter Square Wave Generation • Serial Communication Interface (SCI) Asynchronous Mode 18 Transmit Formats. Hardware Parity) Clocked Synchronous Mode • Memory Ready 3 Kinds of Memory Ready • Halt • Error Detection (Address Error. Op-code Error) • 'Interrupt - External 3. Internal 7 • Operation Mode Mode 1; Expanded Mode (CP·68) Unternal ROM Inhibitedl Mode 2; Expanded Mode HD6301YOF*, HD63A01YOF*, Unternal ROM lIalid) HD63B01YOF*,HD63C01YOF* Mode 3; Single Chip Mode • Maximum 65K Bytes Address Space • Low Power Dissipation Mode Sleep Mode Standby Mode (Hardware Standby. Software Standby) • Minimum Instruction Execution Time - O.5.u-s (f = 2MHz) • Wide .Range of Operation '''''001 to 1.0MHz: HD6301YO :} Vcc=5V± 10% { l~g~ :~~:~~~~: ~g~~~g1~g f=0.1 to3.0MHz: HD63CQ1YO • GENERIC PART NUMBER (FP·64) HD6301YOPJ, HD63A01YOPJ, HD63B01YOPJ, HD63C01YOPJ 'Contact Hitachi Sales Office HD6301YOCPJ, HD63AA01YOCPJ, HD63B01YOCPJ, HD63C01YOCPJ . ~HITACHI 1294 HD6301YO,HD63A01YO,HD63B01YO,HD63C01YO WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) • PIN ARRANGEMENT • HD6301YOPJ,HD63A01YOPJ, HD63B01YOPJ,HD63C01YOPJ • HD6301YOCPJ, HD63A01YOCPJ, HD63B01YOCPJ,HD6301YOCPJ V,. 1 XTAL 2 EXTAL 3 o STBY 7 NMi • 44 P.o ~~~O_NM~~~~W~ M..., -NM "<1""'", .., (Top View) (CP·68) • HD6301YOF*, HD63A01YOF*, HD63B01YOF*,HD63C01YOF* (Top View) ;;;:;; , (DP.64S) '1. J 1!' '. ~'" ~:.: (Top View) (FP·64) * Contact Hitachi Sales Office ~HITACHI 1295 WIDE TEMPERATURE HD6301YO,HD63A01YO,HD63B01YO,HD63C01YO SPECIFICATIONS -40°C TO +85°C (J VERSION) • BLOCK DIAGRAM N i::& Vcc- V.I ..--. v•• ___ .i .., 'll ::& ::& P,.(T1n P,,(TN,' , l l p,o/Im ,, P"CSCllO P,,/WA P,.CA. P"/A/W P.. CT. p,oIrm P,,(TN" P,./SA P..(TN,' P.,CTCll!' Poo/D. P,,/D, P,,/D, P,oID, P,JD. P../D. P,JD. P,,/D, p,o/Ao PIllA, PIllA, P,JlA, p,./Ao POI/A. PIOCIIRI, , p,oIA. p.,CIIRI, , P.. CMA , P,,/A, P••C~' P.. CIB P..COS ,, '"0Ii: a. P.oIA. PulA. P../A,. p.. P.JlA" I'll P••/Au P••/A" PII/A,. 'PII OD P"/A" I'll Po, •Ii: I'll I'i. 2 '10H..- ~HITACHI 1296 HD6301YO, HD63A01YO, HD63B01YO, HD63C01YO WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) Electrical Characteristics HD6301YO, HD63A01YO, HD63B01YO, and HD63C01YO Absolute Maximum Ratings Item Symbol Value Unit Supply voltage Vee -0.3 to +7.0 V Input voltage Vin -0.3 to Vee+0.3 V Operating temperature Topr -40 to +85 'C Storage temperature Tstg -55 to +150 'C Note: This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operatiol\ we recommend Vln • VOU!: Vss:i (V ln or Vou ,) ::'Vcc. Electrical Characteristics DC Characteristics (Vee = 5.0 V ± 10%, f = 0.1 to 3.0 MHz, VSS = OV, Ta = -40 to +85°e, unless otherwise noted.) Item Symbot Min Typ Max Unit Test Condition Input high voltage RES, STBY, V,H Vee-0.5 Vec+0.3 V EXTAL Vee X O.7 Vee+0.3 V Other inputs 2.1 Vee+0.3 V Input low voltage All other inputs V,L -0.3 0.8/0.6 3 V Input leakage current RES, NMI, STBY, I!;nl 1.0 J-IA V,n=O.S to Vee-O.S V MPO, MP, Three state AO-A15, 00-07, RD, IITsd 1.0 J-IA V;n=O.S to Vee-O.S V leakage current WR, R/W, Porls2,5,6 Output high voltage VOH 2.4 V IOH=-200J-lA All Oulpuls Vee-0.7 V IOH=-10 J-IA Output low voltage All Outputs VOL 0.4 V IOL-1.6 mA Darlington drive Ports 2, 6 -IOH 1.0 10.0 rnA Vout=1.S V current Input capaCitance All other inputs Cin 12.= pF V;n=O V, 1=1 MHz, Ta=2S'C Standby current Not operating ISTB 3.0 IS.0 J-IA Current dissipation! ISLP I.S 3.0 rnA Sleeping (1=1 MHz2) 2.3 4.S rnA Sleeping (1=1.5 MHz2) 3.0 6.0 mA Sleeping (1=2 MHz2) 4.5 9.0 rnA Sleeping (f=3 MHz» lee 7.0 10.0 rnA Operating (1= 1 MHz2) 10.S IS.0 rnA Operating (I=I.S MHz2) 14.0 20.0 rnA Operating (1=2 MHz2) 21.0 30.0 rnA Operating (f=3 MHz2) RAM standby voltage VRAM 2.0 V Notes: 1. VIII min=V,,--1.0V. VII_ max=O.8V (All output terminals are at no load,) 2. Current dissipation of the operating or sleeping condition is proportional to the operating frequency. So the tyPo or max. values about current dissipations at x MHz operation are decided according to the following formula: typo value (1=.11' MHz) =typ. value (f:;: 1 MHz) x x max. value (f=xMHz) ;:;;max. value (1=1 MHz)xJC (both the sleeping and operating) 3. In case 01 SCLK ;nput. V,L = 0.6V (- 20°C - O'C) ~HITACHI 1297 I WIDE TEMPERATURE HD6301YO,HD63A01YO,HD63B01YO,HD63C01YO SPECIFICATIONS -40°C TO +85°C (J VERSION) AC Characteristics (Vcc= 5.0V ± 100/0, f= 0.1 to 3.0 MHz, Vss =0 V, Ta =-40 to + 85°C, unless otherwise noted) Bus Timing Item Cycle time Enable ris. time Symbol Icyc tE, Min HD6301YO r,p II.. 10 25 IIln 0.666 HD63A01YO r,p M•• 10 25 Min 0.5 HD63B01YO r,p M•• 10 25 IIIIn 0.333 HDe3C01YO Typ - 10. 20 Unit ~s ns Test Condition Flg.I·P Enab*e fall time tEl 25 25 25 20. ns Enable pulse width high level l PWEH 450 300 220 140 ns Enab'e pulse width low level I PWEl 450 300 220 140 ns Addres~ R/W delay time 1 tAO 250 190 160 120 ns Data delay time (Write) tDOW 200 160 120 100 ns Data set·up time (R.. d) tOSR 80 70 60. 50 ns Address. R/W hotd time l tAH 80 50 40 20 ns Data hold timer (Write) I tHW 80 50 40 20 ns (Read) tHR 0 0 0 ns RD. WR pulse width! PWRW 450 300 220 140 ns RD, WR delay time tRWO 40 40 40 40 ns RD, WR hold time tHRw 20. 20. 20. 20. ns UR delay time IOlR 200 160 120 80 ns UR hold time tHLR ns Peripheral read access tbne 1 tACC 180 ns MR set·up time l ISMR 400 280 230 170. ns Fig. 1·2" MR hold time 1 tHMR 100 70. 50 25 ns E clock pulse width at MR PWEMR 9 9 ~s Figs.I-3. Processor con .....• "'l!t·up time tpcs 200 200 200 100 ns 1·13,1-14' Figs. 1·2, Processor control rise time tpc< 100 100 100 50 ns 1-13' Processor contr~ fall time tpCf 100 100 100 50 ns BA delay time tBA 250 190 160 120 ns Flg.I-3' Oscillator stabitization time tRC 20 20 20 20 ms Fig. 1-14' Reset pulse width PWRST Ic,c Note: 1. These timings chinge in approximate proportion to lcyc. The figures in this characteristics represent those when tcyc is minimum (=in the hilhest .speed operation). *Refer to Pages 611-614 ~HITACHI 1298 HD6301YO, HD63A01YO, HD63B01YO, HD63C01YO WIDE TEMPERATURE SPECIFICATIONS -40°C TO +85°C (J VERSION) Peripheral Port Timing HD6301Y0 HD63A01Y0 HD63B01YO HD63C01YO Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Min Typ Max Unit Condition Peripheral data (Ports 1, 2, 3, tposu 200 200 200 200 ns Fig. l-S' set-up time 4, S, 6) Peripheral data (Ports 1, 2, 3, tpoH 200 200 200 200 ns hold time 4, S, 6) Delay time (From (Ports 1, 2, 3, enable fall edge tpwo 300 300 300 300 ns Fig. 1-6' 4, S, 6, 7) peripheral output) Input strobe pulse tPWIS 200 200 200 200 ns Fig. 1-10- width Input data hold (Port 6) tlH lS0 lS0 lS0 lS0 ns time Input data set-up (Port 6) tiS 100 100 100 100 ns time Output strobe tOS01 200 200 200 200 ns Fig. 1-11' time tOS02 • Refer to Pages 611-614 Timer, SCI Timing HD6301Y0 HD63A01YO HD63B01Y0 HD63C01Y0 Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Min Typ Max Unit Condition Timer 1 input pulse width tPWT 2.0 2.0 2.0 2.0 teye Fig. I-g' Delay time (enable positive tTOO 400 400 400 400 ns Fig. 1-7, 1-8' transition to timer output) (Async. mode) tSeye 1.0 1.0 1.0 1.0 teye Fig. I-g' SCI input clock cycle (Clock sync.) 2.0 2.0 2.0 2.0 teye Fig. 1-4' SCI transmit data delay tTXO 240 240 240 240 ns Fig. 1-4' time (Clock sync. mode) SCI receive data set-up tSRx 260 260 260 260 ns time (Clock sync. mode) SCI receive data hold time tHRX 100 100 100 100 ns (Clock sync. mode) SCI input clock pulse width tpWSCK 0.4 0.6 0.4 0.6 0.4 0.6 0.4 0.6 tSeye Fig. I-g' Timer 2 input clock cycle tteye 2.0 2.0 2.0 2.0 teye Timer 2 input clock pulse width tpWTCK 200 200 200 200 ns Timer 10 2, SCI input clock tCKr 100 100 100 SO ns rise time I Timer 1 0 2, SCI input clock tCKf 100 100 100 SO ns fall time • Refer to Pages 611-614 ~HITACHI 1299 WIDE TEMPERATURE SPECIFICATIONS HD6303R, HD63A03R, -40°C TO +85°C (J VERSION) HD63B03R The HD6303R is an 8·bit CMOS micro processing unit HD6303RPJ, HD63A03RPJ, which has the completely compatible instruction set with the HD63B03RPJ HD6301VI. 128 bytes RAM, Serial Communication Interface (SCI), parallel 1/0 ports and multi function timer are incorpora· ted in the HD6303R. It is bus compatible with HMCS6800 and can be expanded up. to 65k words. Like the HMCS6800 family, 1/0 levels is TIL compatible with +5.0V single power supply. As the HD6303R is CMOS MPU, power disSipation is extremely low. And also HD6303R has Sleep Mode and Stand.by Mode as lower power dissipation mode. Therefore, flexible low power consumption application is possible. • FEATURES • Object Code· Upward Compatible with the HD6BOO. HD68Dl. HD6802 • Multiplexed Bus (Do-D,/Ao-A,l. Non Multiplexed Bus HD6303RCPJ, HD63A03RCPJ, ,. Abundant On-<:hip Functions Compatible with the HD63B03RCPJ HD6301Vl; 128 Bytes RAM. 13 Parallel I/O Lines. 16·bit Timer. Serial Communication Interface (SCI) • Low Power Consumption Mode; Sleep Mode. Stand·By Mode • Minimum Instruction Execution Time l/A1 (t-1MHz). O.67j1$ (t-1.5MHz). O,5ps (f=2.OMHz) • Bit Manipulation. Bit Test Instruction • Error Detecting Function; Address Trap. Op Code Trap • Up to 65k Words Address Space • TYPE OF PRODUCTS (CP·52) Type No. BUI Timing HD6303R 1.0 MHz HD6303RF", HD63A03RF", HD63AD3R 1.6 MHz HD63B03RF" HD63BD3R 2.0MH.z • GENERIC PART NUMBER HD6303RPJ,HD63A03RPJ,HD63B03RPJ HD6303RCPJ,HD63A03RCPJ,HD63B03RCPJ (Fp·54) "Contact Hitachi Sales Office ~HITACHI 1300 HD6303R,HD63A03R,HD63B03R WIDE TEMPERATURE SPECIFICATIONS -40°C TO +85°C (J VERSION) • HD6303RF*, • PIN ARRANGEMENT HD63A03RF * , • HD6303RCPJ, HD63A03RCPJ, HD63B03RF' • HD6303RPJ, HD63A03RPJ, HD63B03RCPJ HD63B03RPJ AS 49 d~C) ANI .8 (Ne) 47 (NC) .. 5 OIIA, ... OJIAI O.jA. .. D./A.. NC "2 0.,,,,. .. D!lA~ 41 0'1 ..... Pll • DuA, .. e,IA, P,. OJ/A, 36 (Ne) NC NC 31 A. Ao/P,Q ) A, )6 AI A,/PI1 1 A, 35 A,g A;./P'l A" 34 (Ne, NC NC 33 (Ne) ..,_ _ _ _ _ _~ Vee (Top View) (Top View) (Top View) (DP-40) (CP-52) (FP-54) * Contact Hitachi Sales Office • BLOCK DIAGRAM -' -'« ~ ~;! ~ 1:!;ldl~ »Xww z~!a: t':1~:t+== P20 p" 1-1-+,,"--- P 22 Address/ I-I-++<~- P 23 Data toi-++r.- P 2' Buffers ~HITACHI 1301 WIDE TEMPERATURE HD6303R,HD63A03R,HD63B03R SPECIFICATIONS -40°C TO + 85°C (J VERSION) • ABSOLUTe MAXIMUM RATINGS Item Symbol Value Unit Supply Voltage VCC -0.3 - +7.0 V Input Voltage Vin -0.3 - VCC +0.3 V Operating Temperature' Topr -40 to +85 DC Storage Temperature T stg -55 to + 150 DC (NOTE) This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend Vin • Vout : Vss S (Vin or Vout) :S Vee· OK version (-40 to + 125°C) available. Contact sales office . • DC CHARACTERISTICS (Vee = 5.0V±10%, Vss = OV, To = -40 to + BSoC, unless otherwise noted.) Item Symbol Test Condition min typ max Unit RES, S'fif'i' Vee-0.5 - Vee Input "High" Voltage EXTAL V'H Vee xO.7 - +0.3 V Other Inputs 2.0 - Input "Low" Voltage All Inputs V'l -0.3 - O.B V Input Leakage Current NMI, IRO., RES, STBY lI'n I V'n -0.5-Vee -o.5V - - 1.0 p.A Three State (off-state) P,o-P 17 , P'O-P'4, Leakage Current 0 0 -0 7 , A.-A" II Ts ,1 V'n =0.5-Vee -o.5V - - 1.0 p.A Output "High" Voltage All Outputs V OH IOH = -200p.A 2.4 - - V IOH - -10p.A Vee- 0.7 - - V Output "Low" Voltage All Outputs VOL IOl = I.SmA - - 0.55 V V'n=OV, f= 1.0MHz, Input Capacitance All Inputs C in - - 12.5 pF Ta = 25D C Standby Cu rrent Non Operation Ice V,~Y)=0-0.6V - 2.0 15.0 p.A V'H(RES)=VCC- 0.5- _ _ Vee V V'L(RES)=0-0.6V Current Dissipation * ioperating(f=1 MHz") - 6.0 10.0 lee rnA Sleeping (f=1 MHz") - 1.0 2.0 RAM Stand· By Voltage V RAM 2.0 - - V 'V'H min = Vcc-1 ..oV, V'l max = O.BV •• Current Dissipation of the' operating or sleeping condition is proportional to the operating frequency. So the typo or max. values about Current Dissipations at f = x MHz operation are decided according to the following formula; tyP. value (I =xMHz) =typo value (I' 1MHz) xx max. value If =xMHz) = max. value (f "'" 1 MHz) x x (both the 'sleeping and operating) ~HITACHI 1302 HD6303R,HD63A03R,HD63B03R WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) • AC CHARACTERISTICS (Vee =5.0V±10%, Vss =OV, Ta = -40 to +85°C, unless otherwise noted.) BUS TIMING Test HD6303R HD63A03R HD63B03R Item Symbol Con· Unit 'dition min typ max min typ max min typ max Cycle Time tcyc - 1 - 10 0.666 10 0.5 - 10 ItS Address Strobe Pulse Width "High" PWASH 220 - - 150 - - - - ns 110 Address Strobe Rise Time, tAs. - - 20 - - 20 -- 20 ns Address Strobe Fall Time tAS! - - 20 - - 20 - - , 20 ns Address Strobe Delay Time tASD' 60 - - 40 - - 20 - - ns Enable Rise Time tE. - - 20 - - 20 - - 20 ns Enable Fall Time tEl - - 20 - - 20 - - 20 ns Enable Pulse Width "High" Level PWEH 450 - - 300 - - 220 - - ns Enable Pulse Width "Low" Level PWEL 450 - - 300 - - 220 - - ns Address Strobe to Enable Delay Time t ASED 60 - - 40 - - 20 - - ns --- - - 250 - - 190 - - 160 ns Address Delay Time ~ Fig. 5·," tAD2 - - 250 - - 190 - - 160 ns Address Delay Time for Latch tADL Fig. 5-2·· - - 250 - - 190 - - 160 ns Data Set-up Time Write t DSW 230 - - 150 - - 100 - - ns Read tDSR 80 - - 60 - - 50 - - ns Read tHR 0 - - 0 - - 0 - - ns Data Hold Time Write tHW 20 - - 20 - - 20 - - ns Address Set-up Time for Latch tASL 60 - - 40 - - 20 - - ns Address Hold Time for Latch tAHL 30 - - 20 - - 20 - - ns Addrtss Hold Time tAH 20 - - 20 - - 20 - - ns Ao - A, Set·up Time Before E tASM 200 - - 110 - - 60 - - ns Peripheral Read I INon·Multiplexed (tACCN) Bus - - 650 - - 395 - - 270 ns Access Time I Multiplexed Bus (tACCM - - 650 - - 395 - - 270 ns Oscillator Slabil ization TIme tRC .. - Fig. 2-1-1 20 - - 20 - - 20 - - ms Pr!lcessor Control Set·up Time Ipes Fig. 2-8-1 200 - - 200 - - 200 - - ns PERIPHERAL PORT TIMING Test HD6303R HD63A03R HD63B03R Item Symbol Con- Unit, dition min typ max min typ max min typ max Peripheral Data. Set·upTime Port I, 2 IpDSU Fig.s-a*· - 200 - 200 - - - - ns 200 'Peripheral Data Hold Time Port 1,2 tpDH Fig. 5-3" 200 - - 200 - - 200 - - ns Delay Time, Enable Nega-I Port 1 tive Transition to Peri· pheral Data Valid 2' ' tPWD Fig.5-S·'· - - 300 - - 300 - - 300 ns • Except Pu •• Refer tD Pages 189-190 ••• Refer to Pages 159-160 ~HITACHI 1303 I WIDE TEMPERATURE HD6303R,HD63A03R,HD63B03R SPECIFICATIONS -40°C TO +85°C (J VERSION) TIMER, SCI TIMING Test HD6303R HD63A03R HD63B03R Item Symbol Con- Unit dition min typ max min typ max min typ max Timer Input Pulse Width tpWT 2.0 - - 2.0 - - 2.0 - - toye Delay Time, Enable Positive Transition to Timer Out tTO O Fi9...5-7 - - 400 - - 400 - - 400 ns SCI Input Clock Cycle t Seve 2.0 - - 2.0 - - 2.0 - - tCYC SCI Input Clock Pulse Width tPWSCK 0.4 - 0.6 0.4 - 0.6 0.4 - 0.6 tScye MODE PROGRAMMING Test HD6303R HD63A03R HD63B03R Item Symbol Con· Unit dition min typ max min typ max min typ max RES "low" Pulse Width PW RSTL 3 - - 3 - - 3 - - toye Mode Programming Set·up Time IMPS FI9;.5-8 2 - - 2 - - 2 - - Icye Mode Programming Hold Time tMPH 150 - - 150 - - 150 - - ns "Refer to Pages 189-190 .HITACHI 1304 WIDE TEMPERATURE HD6303X, HD63A03X, SPECIFICATIONS -40°C TO + 85°C HD63B03X (J VERSION) The HD6303X is a CMOS 8-bit micro processing unit (MPU) HD6303XPJ, HD63A03XPJ, which includes a CPU compatible with the HD630IVI, 192 HD63B03XPJ bytes of RAM, 24 parallel I/O pins, a Serial Communication Interface (SCI) and two timers on chip. II FEATURES II Instruction Set Compatible with the HD6301Vl II Abundant On-chip Functions 192 Bytes of RAM 24 Parallel 1/0 Ports 16-Bit Programmable Timer B-Bit Reloadable Timer Serial Communication Interface Memory Ready Halt Error-Detection (Address Trap, Op Code Trap) II Interrupts ... 3 External, 7 Internal II Up to 65k Bytes Address Space " Low Power Dissipation Mode (DP-64S) Sleep Standby II Minimum Instruction Execution Time HD6303XCPJ, HD63A03XCPJ, 1115 (f = 1 MHz). 0.67 115 (f = 1.5 MHz). 0.5115 (f = 2.0 HD63B03XCPJ MHz) o Wide Operating Range VCC = 3 - 6V (f =0.1 - 0,5MHz). f = 0.1 to 2.0 MHz (Vee = 5V ± 10%) II TYPE OF PRODUCTS Type No. Bus Timing HD6303X 1 MHz HD63A03X 1.5 MHz HD63B03X 2MHz (Cp·68) HD6303XF* , HD63A03XF* , .. GENERIC PART NUMBER HD63B03XF* HD6303XPJ,HD63A03XPJ,HD63B03XPJ HD6303XCPJ, HD63A03XCPJ, HD63B03XCPJ (FP-60) *Contact HItachi Sales Office ~HITACHI 1305 WIDE TEMPERATURE HD6303X, HD63A03X, HD63B03X SPECIFICATIONS -40°C TO + 85°C (J VERSION) • PIN ARRANGEMENT • HD6303XCPJ, HD63A03XCPJ, HD63B03XCPJ • HD6303XF', HD63A03XF', • HD6303XPJ, HD63A03XPJ, HD63B03XF' HD63B03XPJ ~~w~igl,M_~I~!~6. v. I~ 0 XTAL .. ... _ " UTAl 1 .',, ~I~: ~:t 'ijMf • OIl .A o U, )9 D. mv 0, 0, "'"" 0, 'rIO...• , ,e I 0, u 0, 0, '"' . " 'to ' 0, .. 54 He 1' .. p. . . 1'" ' • , 0, H 0, 'D, '" ',,' 0, , 0, '" '. 1',. " " U " Ne o. '. ' A, '" ," " .. Ne Po. 1 A, A, '" OJ A. '".::~' '" A, P,. " " A, A, p .. '. ' .. 1 Pot •• • A, A, '" A, '" POI " '" A, P" •• .. A. '"'" v. P.. ot " A, '" ' A, 'Pot.. .. A, '" ." '" A" A.. (Top View) (CP-68) NC .. Ne .. '" fA" ."''"'... A" A.. A.. (Top View) (Top View) (FP-BO) (DP-64S) • BLOCK DIAGRAM 'Contact Hitachi Sales Office V(C _ _ ' _ vu--- Vu _ _ _' P,e>lTlnl P"Houl1! Pu(SClK) '0 w< Pul Rx , P,.lhl R:W PnHout21 0' P,.lToutJI P,,(Tclkl D. 0, 0, 0, 0, 0, 0, 0, A, A, A, A, A, A, P,o(iJRJ., - A, Ps,11Rill1 P"fMR) Pu(~rTl '. A, A, '" A" ''"' ' - A .. A .. Au A .. '. A" '" '" '" '" '" '" '" ~HITACHI 1306 HD6303X, HD63A03X, HD63B03X WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) • ABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply Voltage Vee -0.3 - + 7.0 V Input Voltage Vin -0.3 - Vee +0.3 V Operating Temperature Topr -40 to +85 °C Storage Temperature Tstg -55 to +150 °C (NOTE) This product has protection circuits in input terminal from high static electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation, we recommend V in • Voul: Vss :.S (Vin or Vouu :S Vee. • ELECTRICAL CHARACTERISTICS • DC CHARACTERISTICS IVee. 5.0V±10%. Vss· OV. Ta = -40 to +85°C, unless otherwise noted.) Item Symbol Test Condition min typ max Unit RES.STBY Vee-0.5 - Vee Input "High" Voltage EXTAL V IH Vee xO•7 - +0.3 V Other Inputs 2.0 - Port 22 Pin 22 V IH 2.2 - V Input "Low" Voltage All Inputs V IL -0.3 - 0.8 V Input "Low" Voltage All Inputs V IL -0.3 - 0.8 V NMI, RES, STBY, Input Leakage Current MPo , MP.,Port 5 IIlnl Vln = 0.5-V ee -0.5V - - 1.0 /l.A Three State loff-state) Ao-A". 0 0 -0,. RD. Leakage Current WR. R/W.Port 2.Port 6 IITs" Vin = 0.5-V ee -0.5V - - 1.0 /l.A Output "High" Voltage All Outputs V OH IOH=-200/l.A 2.4 - - V IOH =-10/l.A Vee-O.7 - - V Output "Low" Voltage All Outputs VOL IOL ":1.6mA - - 0.4 V Darlington Drive Current Ports 2. 6 -loH Vout= 1.5V 1.0 - 10.0 mA I nput Capacitance All Inputs Cln Vln = OV. f = lMHz. Ta = 25°C - - 12.5 pF Standby Current Non Operation ISTB - 3.0 15.0 /l.A Sleeping If = lMHz**) - 1.5 3.0 iliA IsLP Sleeping If = ·1.5MHz**) - 2.3 4.5 mA Current Dissipation* Sleeping If = 2MHz**) - 3.0 6.0 mA Operating If - lMHz**) - 7.0 10.0 mA lee Operating If = 1.5MHz**) - 10.5 15.0 mA Operating If = 2MHz**) - 14.0 20.0 mA RAM Standby Voltage V RAM 2.0 - - V ·VIH min· VCC-1.OV. VIL max a C.BV • All output terminals are at no load . •• Current Dislipation of tha operating or sleaping condition is proportional to the operating frequency. So the typo or max. values about Current DiSSipations at x MHz operation are decided according to the following formula: typo value (f - " MHz) - typo value If - 1MHz) • " max. value (f = x MHz) • max. value (f == 1MHz) x x (both the sleeping and operating) ~HITACHI 1307 I WIDE TEMPERATURE HD6303X, HD63A03X, HD63B03X SPECIFICATIONS -40°C TO +85°C (J VERSION) .• AC CHARACTERISTICS (Vcc·S.OV:l:10%.Vss.OV. Ta = -40 to +85°C,unlessotherwlsenoted.) BUS TIMING Test HD6303X HD63A03X HD63B03X Item Symbol Unit Condition min typ max min typ max min typ max Cycle Time tcye 1 - 10 0.666 - 10 0.5 .. - 10 liS Enable Rise Time tE, - - 25 - -. 25 - - 25 ns linable Fall Time tEl - - 25 - - 25 - - 25 ns Enable Pulse Width "High" Level' PW EH 450 - - 300 - - 220 - - ns Enable Pulse Width "Low" Level' PWEL 450 - - 300 - - 220 - - ns Address, R/WDelay Time' tAD - - 250 - - 190 - - 160 ns Data Delay Time Write I tDDW - - 200 - - 160 - - 120 ns Data Set-up Time Read I tDSR Fig. 1-13" 80 - - 70 - - 70 - - ns Address, R/WHold Time' tAH 80 - - 50 - - 35 - - ns Data Hold Time I Write' tHW 80 - - 50 - - 40 - - ns I Read tHR 0 - - 0 - - 0 - - ns RD, WR Pulse Width' PWRW 450 - - 300 - - 220 - - ns RD, WR Delay Time tRwD - - 40 - - 40 - - 40 ns RD, WR Hold Time tHRW - - 30 - - 30 - - 25 ns LIR Delay Time tDLR - - 200 - - 160 - - 120 ns LIR Hold Time tHLR 10 - - 10 - - 10 - - ns MR Set-up Time' tSMR 400 - - 280 - - 230 - - ns MR Hold Time' tHMR Fig. 1-14* * - - 90 - - 40 - - 0 ns E Clock Pulse Width at MR PWEMR - - 9 - - 9 - - 9 liS Fig. 1-15* * Processor Control Set·up Time tpcs 1-20,1-24 200 - - 200 - - 200 - - ns Processor Control Rise Time tpc, Fig. 1-14, - - 100 - - 100 - - 100 ns Processor Control Fall Time tpCI 1-15* * - - 100 - - 100 - - 100 ns BA Delay Time tBA Fig. 1-15* * - - 250 - - 190 - - 160 ns Oscillator Stabilization Time tRC Fig. 1-24** 20 - - 20 - - 20 - - ms Reset Pulse Width PWRST 3 - - 3 - - 3 - - tCYC • The .. timings change in approximate proportion to teye. The figure. In thl. characteristics represent those when teye is minimum I-In the hlghllt.peed operetionl. * *Refer to Pages 472-476 PERIPHERAL PORT TIMING Test HD6303X HD63A03X HD63B03X Item Symbol Unit Condition min typ max min typ max min typ max Peripheral Data Set·upTime Ports 2, 5, 6 tpDSU Fig. 1-17* * 200 - - 200 - - 200 - - ns Peripheral Data Hold Time Ports 2, 5, 6 tpDH Fig. 1-17* * 200 - - 200 - - 200 - - ns Delay Time (Enable .1 Negative Transition to Ports 2, 6 tPWD Perlpherel Data Valid) Fig. 1-18* * - - 300 - - 300 - - 300 ns * *Refer to Pages 472-476 ~HITACHI 1308 HD6303X,HD63A03X,HD63B03X WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) TIMER SCI TIMING Test HD6303X HD63A03X HD63B03X Item Symbol Unit Condition min typ max min max min typ max ~ Timer 1 Input Pulse Width tPWT Fig. 1-21"" 2.0 - - 2.0 - - 2.0 - - t cvc Delay Time (Enable Positive Fig. 1-19"" Transition to Timer Output) tTOO 1-20 - - 400 - - 400 - - 400 ns 1l Clock Sync. SCI Input Async. Mode t 5cyc Fig. 1-21"" 1.0 - - 1.0 - - 1.0 - - t"yc Clock Cycle Fig. 1-16. 1-21"* 2.0 - - 2.0 - - 2.0 - - tcyc SCI Transmit Data Delay Time (Clock Sync. Mode) tTXO - - 200 - - 200 - - 200 ns SCI Receive Data Set·up Time (Clock Sync. Mode) tSRX Fig. 1-16"" 290 - - 290 - - 290 - - ns SCI Receive Data Hold Time (Clock Sync. Mode) tHRX 100 - - 100 - - 100 - - ns SCI Input Clock Pulse Width tpWSCK 0.4 - 0.6 0.4 - 0.6 0.4 - 0.6 tsCYC Timer 2 Input Clock Cycle ttcvc 2.0 - - 2.0 - - 2.0- - - tCyc Timer 2 Input Clock Pulse Width tPWTCK Fig. 1-21"" 200 - - 200 - - 200 - - ns Timer 1-2. SCI Input Clock Rise Time tCKr - - 100 - - 100 - - 100 ns Timer 1-2, SCI Input Clock Fall Time tCKf - - 100 - - 100 - - 100 ns ""Refer to Pages 472-476 ~HITACHI 1309 I WIDE TEMPERATURE SPECIFICATIONS HD6303Y, HD63A03Y, -40°C TO + 85°C (J VERSION) HD63B03Y, HD63C03Y The HD6303Y is a CMOS 8-bit single-chip microprocessing unit which conlains a CPU compatible with the CMOS 8-bit microcom- HD6303YPJ, HD63A03YPJ, puter HD630\V, 256 bytes of RAM, 24 parallel 110 pins, Serial HD63B03YPJ,HD63C03YPJ Communication Interface 0 XM X WR P22(SCLK) ---t-H~ N OW 0 P23(R. )---rH-ioi l- N !!: R/W tt: P2. CT. ) --"14-H-Ioi 0 I- tt: OR a.. 0 BA P2sCTou!2) --.,.++H-Ioi a.. P2s(Toul3) --t4++H-Ioi P27CTCLK) ittttlrtt'L-.J_.J 00 D. .. ::J III 02 03 O. !Ia d. 0 D. 0, Ao .. .... A• A2 ~:s "CIII A3 "c .. A. «::J III As Pso(iJm. ) As PS,(iJm 2 ) A, P.2(MR ) PS3(RAi:T) '"tt: l- As p •• (IS ) 0 A. a.. PSS(OS ) A.o PS. A" PS' Au A'3 p.o A•• P•• A,. P02 ID POl l- tt: PO. 0 a.. RAM Pos ps. 256Bvtes Ps, ~HITACHI 1312 HD6303~HD63A03~HD63B03~HD63C03Y WIDE TEMPERATURE SPECIFICATIONS -40°C TO + 85°C (J VERSION) 1.2 HD6303Y, HD63A03Y, HD63B03Y, Electrical Characteristics Absolute Maximum Ratings Item Symbol Value Unit Supply voltage Vee -0.3 to +7.0 V Input voltage Von -0.3 to Vee+0.3 V Operating temperature Top' -40 to +85 ·C Storage temperature Tst. -55 to +150 ·C NQte: This product has protection circuits in input terminal from high statLc electricity voltage and high electric field. But be careful not to apply overvoltage more than maximum ratings to these high input impedance protection circuits. To assure the normal operation. we recommend Vln. V,,~,: V.,~s. (V"' or VOy ,) ;aVec_ Electrical Characteristics DC Characteristics (Vee = 5.0V ± 10%, f= 0.1 to 3.0 MHz, Vss = 0 V, Ta = -40 to + 85°C, unless otherwise noted) Item Symbol Min Typ Max Unit Test Condition Input high voltage RES, STBY V,H Vee-0.5 Vee+0.3 V EXTAL Vee x O.7 Vee+0.3 V Other inputs 2.1 Vee+0.3 V Input low voltage All other inputs V,l -0.3 08/0.6 3 V Input leakage current RES, NMI, STBY, lion 1 1.0 "A V;n=0.5 to Vee-O.5 V MPO, MPl Three state Ao-A15,Do-D7,RD IITsd 1.0 "A V;n=0.5 to Vee-O.5 V leakage current WR,R/W,Ports 2,5,6 Output high voltage VOH 2.4 V IOH- -200 "A All outputs Vee-0.7 V IOH=-lO "A Output low voltage All outputs VOL 0.4 V IOl-1.6 mA Darlington drive Ports 2, 6 -IOH 1.0 10.0 rnA Vout=1.5V current Input capacitance All other Inputs Cin 12.5 pF V;n=OV, 1=1 MHz Ta=25'C Standby current Not operating ISTB 3.0 15.0 "A Current dissipation l ISlP 1.5 3.0 mA Sleeping (1=1 MHz2) 2.3 4.5 rnA Sleeping (1=1.5 MHzZ) 3.0 6.0 mA Sleeping (1=2 MHzZ) 4.5 9.0 mA Sleeping (f=3MH z2) lee 7.0 10.0 rnA Operating (1= 1 MHzZ) 10.5 15.0 mA Operating (1=1.5MHzZ) 14.0 20.0 mA Operating (1=2 MHz2) 21.0 30.0 mA Operating (f=3MH z2) RAM standby vollage V.AM 2.0 V Notes; 1 V'H min=V« -l.OV, VII max;;;.O.8V (All output terminals are at no load.) 2. Current dISsipation of the operating or sleeping condition IS proportIonal to the operatmg frequency. So the tyPo or mal(. values about current diSsipations at )( MHz operation are decided accordmg to the followmg formula: I typ. value ('= x MHz) =typ. value (f = 1 MHz) X)( max. value (f=xMHz) =max. value (f=1 MHz)xx (both the sleeping and operatIng) 3. In case of SCLK Input. V.l = O.6V (- 20°C .-. DOC) ~HITACHI 1313 WIDE TEMPERATURE HD6303Y, HD63A03Y, HD63B03Y, HD63C03Y SPECIFICATIONS -40°C TO +85°C (J VERSION) AC Characteristics (Vee = 5.0V ±10%, 1=0.1 to 3.0 MHz, Vss=O V, Ta=-40 to +85°C, unless otherwise noted) Bus Timing Item Cycle time Enable rise time S,mbol tcyc IE. Min H06303Y Typ Max 10 25 Min 0.666 H063A03Y TJ'P Max 10 25 Min 0.5 H063B03Y Typ Max 10 25 - - 0.333 H063C03Y Typ 10 20 Unit .s ns Test Condition Fig. 1-15* EnabJe fall time IE! 25 25 25 20 ns Enable pulse width high le.... el l PWEH 450 300 220 140 ns Enable pulse width low level I PWEL 450 300 220 140 ns Address, R/W delay time l tAD 250 190 160 120 ns Data delay time (Write) toow 200 160 120 100 ns Data set·up time (Read) tOSR 80 70 60 50 ns Address. R/W hold tlme l tAH 80 50 40 20 ns Data hold time (Write) 1 tHW 70 50 40 20 ns IRead) tHR 0 ns RD, WR pulse widthl PWRW 450 300 220 140 ns ffD, WR delay time tRWO 40 40 40 40 ns , RD. WR hold time tHRW 20 20 20 20 nS DR delay time IOLR 200 160 120 80 ns DR hold tln'le tHLR 5 5 ns .Peripheral read access time I tAce laO ns MR set·up time! tSMR 400 280 230 170 ns Fig. 1-16' MR hold time l tHMR 100 70 50 25 ns E clock pulse width at MR PWEMR 9 .s FigS. 1-17, Processor control set-up time tpcs 200 200 200 100 ns 1-27. 1-28' Processor control rise time 100 100 100 50 ns Figs.I-16. tPCr 1-17' Processor cl)ntrol fall time tpCI 100 100 100 50 ns SA delay time tSA 250 190 160 120 ns Fig. 1-17' Oscillator stabilization time tRe 20 20 .20 20 ms Fig. 1-28' Reset pulse width PWRST tcyc Note: 1. These timings change in approximate proportion to leye. Tne figures in this characteristics represent those when teye IS minimum (=in the highest speed operation). 'Refer to Pages 618-621 ~HITACHI 1314 HD6303~HD63A03~HD63B03~HD63C03Y WIDE TEMPERATURE SPECIFICATIONS -40°C TO +85°C (J VERSION) Peripheral Port Timing H06303Y HD63A03Y HD63B03Y Test Item Symbol Min Typ Max Min Typ Max Min Typ Max Unit Condition Peripheral data (Ports 2, 5, tpOSU 200 200 200 ns Fig, 1-19' set-up time 6) Peripheral data (Ports 2, 5, tpOH 200 200 200 ns hold time 6) Delay time (From (Ports 2, 5, enable fall edge to 6 7) tpwo 300 300 300 ns Fig, 1-20' peripheral output) , Input strobe pulse tpWIS 200 200 200 ns Fig, 1-35' width Input data hold (Port 6) tlH 150 150 150 ns time I~put data set-up (Port 6) tiS 100 100 100 ns time Output strobe tOSOl 200 200 200 ns Fig.I-25' time toS02 'Refer to Pages 618-621 Timer, SCI Timing HD6303Y HD63A03Y HD63B03Y ------- Test Item S""bol Min Typ Max Min Typ Mal Min Typ Mal Unit Condition Timer 1 input pulse width tPWT 2.0 2.0 2.0 !eye Fig.I-23' Delay time (enable positive Figs. 1~21. tTOO 400 400 400 ns tranSition to timer output) '1-?_2_'_ _ ~A5ync:. mode) 1.0 1.0 1.0 Fig. 1-23' SClmput lStye !eye clock cycle (Clock sync.) 2.0 2.0 2.0 teye Fig. I-IS' SCI transmit data delay tTXO 240 240 240 ns Fig.I-1S' time (Clock sync. mode) SCI receive data set-up time (Clock sync. mode) tSRX 260 260 260 ns SCI receive data hold time (Clock sync. mOde) IHRX 100 100 100 ns SCI input clock pulse Width tPWSCK 0.4 0.6 0.4 0.6 0.4 0.6 tSeye Fig. 1-23' Timer 2 mput clock cycle ttcvc 2.0 2.0 2.0 !eye Timer 2 mput clock pulse Width IPWTCX 200 200 200 ns Timer 1 • 2, SCI Input clock nse time leK, 100 100 100 ns Timer 1 • 2, SCI input clock fall time leKI 100 100 100 ns I 'Refer to Pages 618-621 ~HITACHI 1315 NOTES: ~HITACHI 1316 NOTES: ~HITACHI 1317 Hitachi America, Ltd. SEMICONDUCTOR and IC DIVISION Hitachi America, Ltd. Semiconductor & IC Division Hitachi Plaza 2000 Sierra Point Parkway Brisbane, CA 94005-1819 Telephone: 415-589-8300 Telex: 17-1581 Twx: 910-338-2103 FAX: 415-583-4207 REGIONAL OFFICES MID·ATLANTIC REGION NORTHWEST REGION SOUTHEAST REGION Hitachi America, Ltd. Hitachi America, Ltd. Hitachi America, Ltd. 1700 Galloping Hill Rd. 2000 Sierra Point Parkway 4901 N.W. 17th Way, Suite 302 Kenilworth, NJ 07033 Brisbane, CA 94005-1819 Fort Lauderdale, FL 33309 201/245-6400 415/589-8300 305/491-6154 NORTHEAST REGION SOUTH CENTRAL REGION AUTOMOTIVE Hitachi America, Ltd. Hitachi America, Ltd. Hitachi America, Ltd. 5 Burlington Woods Drive Two Lincoln Centre, Suite 865 6 Parklane Blvd., #558 Burlington, MA 01803 5420 LBJ Freeway Dearborn, MI 48126 617/229-2150 Dallas, TX 75240 313/271-4410 214/991-4510 NORTH CENTRAL REGION Hitachi America, Ltd. SOUTHWEST REGION 500 Park Blvd., Suite 415 Hitachi America, Ltd. Itasca, IL 60143 18300 Von Karman Avenue, 312/773-4864 Suite 730 Irvine, CA 92715 714/553-8500 DISTRICT OFFICES Hitachi America, Ltd. Hitachi America, Ltd. Hitachi America, Ltd. 3800 W. 80th Street 6161 Savoy Dr., Suite 850 401 Harrison Oaks Blvd. Suite 1050 Houston, TX 77036 Suite #317 Bloomington, MN 55431 713/974-0534 Cary, NC 27513 612/896-3444 919/481-3908 Hitachi (Canadian) Ltd. Hitachi America, Ltd. 2625 Queensview Dr. 21 Old Main Street, Suite 104 Ottawa, Ontario, Canada K2A 3Y4 Fishkill, NY 12524 613/596-2777 914/897-3000 ~HITACHI® 1318