HD630S/HD63LOS SERIES HANDBOOK • USERS MANUALS • HD630S UO • HD630S VO • HD6370S VO • HD630SX • HD630SY • HD63POSY • HD63LOS • SOFTWARE APPLICATION NOTES: • HARDWARE APPLICATION NOTES: • APPENDIX: TECHNICAL Q & A • SYSTEM APPLICATION NOTES #U08 ~HITACHI® MEDICAL APPLICATIONS Hitachi's products are not authorized for use in MEDICAL APPLICATIONS, including, but not limited to, use in life support devices without the written consent of the appropriate officer of Hitachi's sales company. Buyers of Hitachi's products are requested to notify Hitachi's sales offices when planning to use the products in MEDICAL APPLICATIONS. When using this manual, the reader should keep the following in mind: 1. This manual may, wholly or partially, be subject to change without notice. 2. All rights reserved: No one is permitted to reproduce or duplicate, in any form, the whole or part of this manual without Hitachi's permission. 3. Hitachi will not be responsible for any damage to the user that may result from accidents or any other reasons during operation of his unit according to this manual. 4. This manual neither ensures the enforcement of any industrial properties or other rights, nor sanctions the enforcement right thereof. 5. Circuitry and other examples described herein are meant merely to indi- cate characteristics and performance of Hitachi semiconductor-applied products. Hitachi assumes no responsibility for any patent infringements or other problems resulting from applications based on the examples described herein. 6. No license is granted by implication or otherwise under any patents or other rights of any third party or Hitachi, Ltd. September 1988 ©Copyright 1988, Hitachi America Ltd. Printed in U.S.A. ii HD630S/HD63LOS SERIES HANDBOOK Quick Reference Guide Addressing Modes, CPU Architecture, and Instruction Set HD630SUO, HD630SVO, HD6370SVO User's Manual HD630SX, HD630SY, HD63POSY User's Manual HD63LOS User's Manual Software Application Notes Hardware Application Notes APPENDIX: 1echnica1 Q and A System Application Notes Hitachi Sales Offices Section 9, Page 1200 ~HITACHI iv TABLE OF CONTENTS Section 1 Page HD6305/HD63L05 Series Quick Reference Guide ............................... . Section 2 Addressing Modes, CPU Architecture, & Instruction Set Page 1.1 Addressing Modes ................................................. . 13 1.2 CPU Registers .................................................... . 18 1.3 Instruction Set .................................................... . 20 1.4 Bit Manipulation ................................................... . 27 1.5 Symbols and Abbreviations .......................................... . 28 1.6 Executable Instructions ............................................. . 30 1.7 BIUBIH Instruction Precaution ....................................... . 95 Section 3 HD6305UO, HD6305VO, HD63705VO User's Manual Page 1. OVERViEW .......................................................... . 101 1.1 Features of HD6305UO, HD6305VO, HD63705VO ........................ . 101 1.2 Block Diagram. ... ............ ....... ... ..... ......... ...... ....... 102 1.3 Terminal Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 2. INTERNAL HARDWARE AND OPERATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.1 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.2 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 2.3 Timer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 2.4 Serial Communication Interface (SCI). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.5 Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 2.6 Internal Oscillator Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 2.7 Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 2.8 Input/Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 2.9 Low Power Consumption Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 2.10 EPROM Mode (HD63705VO). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 ~HITACHI v 3. APPLICATION AND PRECAUTIONS ...................................... . 137 3.1 Watch-Dog Timer .................................................. . 137 3.2 Auto Reset Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 3.3 Manual Reset Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 3.4 AID Converter Circuit(1) ... High Speed. . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 141 3.5 AID Converter Circuit (2) ... Low Speed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 3.6 Precaution; - Board Design of Oscillation Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . 144 3.7 Precaution; - Sending/Receiving Program of Serial Data. . . . . . . . . . . . . . . . .. . . 145 3.8 Precaution; - WAIT/STOP Instructions Program. . . . . . . . . . . . . . . . . . . . . . . . . . . 145 4. PIN ARRANGEMENT AND DIMENSIONAL OUTLINE. . . . . . . . . . . . . . . . . . . . . . . . . 146 5. ELECTRICAL CHARACTERISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 5.1 Electrical Characteristics for HD6305UO, HD6305VO. . . . . . . . . . . . . . . . . . . . . . . 149 5.2 Electrical Characteristics for HD63705VO .. , . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 6. PROGRAMMABLE ROM................................................ 158 6.1 ProgrammingNerification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 6.2 Erasure (MCU with a window) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 , 6.3 Application Notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 7. ROM CODE ORDER METHOD........................................... 164 APPENDIX. . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 I. Design Prodcedures and Support Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 SINGLE CHIP MICROCOMPUTER ROM ORDERING PROCEDURE. . . . . . . . . . . . . . . . . 166 HD6305UO, HD6305VO ORDERING SPECIFICATIONS... . . ... . ... . . .... .... . . .. .. 168 Section 4 HD6305X, HD6305Y, HD63P05Y User's Manual Page 1. OVERViEW........................................................... 173 1.1 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 1.2 Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 2. INTERNAL HARDWARE AND OPERATIONS ............................... . 185 2.1 Memory ......................................................... . 185 2.2 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 2.3 Timer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 2.4 Serial Communication Interface (SCI). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 ~HITACHI vi 2.5 Reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 2.6 Internal Oscillator Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 2.7 Interrupts...... ..... ....... ........................... ............ 199 2.8 Input/Output Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 2.9 Low Power Dissipation Mode .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 3. APPLICATION AND PRECAUTIONS. . . . . . .... . .. . . .. . . . .. . . .. . . . ... . . .. . .. 210 3.1 Memory Space Expansion of HD6305X11Y1, HD6305X2IY2, HD63P05Y1 . . . . . . . . 210 3.2 WatCh-Dog Timer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 3.3 Auto Reset Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 3.4 Manual Reset Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 3.5 A/D Converter Circuit (1) ... High Speed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 3.6 A/D Converter Circuit (2) ... Low Speed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 3.7 Precaution; - Board Design of Oscillation Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . 218 3.8 Precaution; - Program of Write Only Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 3.9 Precaution; - Sending/Receiving Program of Serial Data. . . . . . . . . . . . . . . . . . . . 219 3.10 Precaution; - WAIT/STOP Instructions Program. . . . . . . . . . . . . . . . . . . . . . . . . . . 220 3.11 Precaution; - To use the EPROM ON-PACKAGE 8-bit Single-chip Microcomputer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 4. PIN ARRANGEMENT AND DIMENSIONAL OUTLINE .. 222 5. ELECTRICAL CHARACTERISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 5.1 Electrical Characteristics of HD6305XO, HD6305YO, HD63P05YO . . . . . . . . . . . . 225 5.2 Electrical Characteristics of HD6305X11X2, HD6305Y11Y2, HD63P05Y1 ......... 230 6. ROM CODE ORDER METHOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 APPENDIX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 I. Design Procedure and Support Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 II. Ordering Specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 SINGLE CHIP MICROCOMPUTER ROM ORDERING PROCEDURE. . . . . . . . . . . . . . . . . 240 HD6305XO/X1, HD6305YOIY1 ORDERING SPECIFICATIONS. . . . . . . . .. . . .... . . .. . . 242 Section 5 HD63L05 User's Manual Page 1. OVERViEW ........................................................... 251 1.1 Features of the HD63L05 MCU. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 1.2 Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 ~HITACHI vii 2. ARCHITECTURE...................................................... 256 2.1 Memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 2.2 Registers. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 2.3 System Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 2.4 Timer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 2.5 Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 2.6 Self Check. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 2.7 Internal Oscillator Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 2.8 Interruptions ........................._. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 2.9 Input/Output (Port A, B, C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 2.10 AID Converter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 2.11 LCD Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 2.12 Liquid Crystal Driver Waveforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 2.13 Bit Manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 2.14 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 2.15 Instruction Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 3. EXECUTABLE INSTRUCTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 3.1 Symbol and Abbreviation ....... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 3.2 Executable Instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 3.3 Limitation of SWI Instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 4. PIN ARRANGEMENT AND PACKAGE INFORMATION ........................ . 357 5. ELECTRICAL CHARACTERISTICS ....................................... . 359 6. APPLICATION ........................................................ . 366 6.1 How to Confirm Operation Frequency .................................. . 366 6.2 Method of the OM (Decimal Adjust Accumulator) ........................ . 366 6.3 Cautions on the Programming of the Write Only Register and Control Register .. 370 6.4 Cautions on Executing BSR (Branch SubRoutine) Instruction. . . . . . . . . . . . . . . . 370 6.5 Cautions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 7. EVALUATION CHIP (HD63L05EO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 7.1 Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 7.2 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 7.3 Pin Functions and Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 7.4 The Comparison between the HD63L05 MCU and the HD63L05EO . . . . . . . . . . . 386 7.5 LCD Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 7.6 Setting the mask-option data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 7.7 Electrical Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 ~HITACHI viii 8. ROM Code Order Method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 APPENDIX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 I. Design Procedure and Supporting Tool. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 SINGLE CHIP MICROCOMPUTER ROM ORDERING PROCEDURE. . . . . . . . . . . . . . . . . 399 HD63L05F1 ORDERING SPECIFICATIONS ..... " . . . . . . . . . . . . . . .. . . .. .. . . . . . . . . 401 HD63L05F MASK OPTION LIST. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 LCD PIN LOCATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 Section 6 Software Application Notes Page 1. HOW TO USE APPLICATION NOTES ..................................... . 413 1.1 Formats............................................................ 413 1.1.1 Specification Format (Format 1) .................................... . 415 1.1.2 Description Format (Format 2) ..................................... . 421 1.1.3 Flowchart Format (Format 3) ...................................... . 424 1.1.4 Program Listing Format (Format 4) .................................. . 426 1.2 How to Execute Programs ............................................. . 428 1.3 Symbols ........................................................... . 430 PROGRAM APPLICATION EXAMPLES ....................................... . 431 Program Application Table .................................................. . 433 MOVING DATA ........................................................... . 434 1. Filling Constant Values (Fill) ............................................. . 434 2. Moving Memory Blocks (Move) ........................................... . 439 3. Moving Strings (Moves) ................................................. . 446 BRANCHING FROM TABLE (CCASE) ........................................ . 452 4. Branching from Table (CCASE) ........................................... . 452 HANDLING ASCII ........................................................ . 459 5. Converting ASCII Lowercase into Uppercase (TPR) .......................... . 459 6. Converting ASCII into 1-Byte Hexadecimal (Nibble) ........................... . 464 7. Converting 8-Bit Binary Data into ASCII (Cobyte) ............................. . 469 BIT MANIPULATION ...................................................... . 474 8. Counting Number of Logical "1" Bits in 8-Bit Data (HCNT) ..................... . 474 9. Shifting 16-Bit Data (SHR) ............................................... . 479 ~HITACHI ix COUNTER. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 10. 4-Digit BCD Counter (DECNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 COMPARISON. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 489 11. Comparing 16-Bit Binary Data (CMP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 ARITHMETIC OPERATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495 12. Adding 16-Bit Binary Data (ADD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495 13. Subtracting 16-Bit Binary Data (SUB). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 14. Multiplying 16-Bit Binary Data (MUL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 15. Dividing 16-Bit Binary Data (DIV) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 16. Adding 8-Digit BCD (ADDD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 17. Subtracting 8-Bit BCD (SUBD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 18. 16-Bit Square Root (SQRT). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531 CONVERTING BCD INTO HEXADECIMALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537 19. Converting 2-Byte Hexadecimals into 5-Digit BCD (HEX) . . . . . . . . . . . . . . . . . . . . . . 537 20. Converting 5-Digit BCD into 2-Byte Hexadecimals (BCD) . . . . . . . . . . . . . . . . . . . . . . 542 SORTING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 21. Sorting (SORT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 Section 7 Hardware Application Notes Page APPLICATION NOTES GUIDE.. . .. . .... .. .. . ... . .. . . . . . . ... .. . . .. .. . .. . . . . . . 563 1. HOW TO USE APPLICATION NOTES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565 1.1 Application Example Configuration ............ . . . . . . . . . . . . . . . . . . . . . . . . . . 565 1.2 1st Section (Hardware) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567 1.3 2nd Section (Software) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571 1.4 3rd Section (Program Module) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573 1.4.1 Specification Format (Format 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574 1.4.2 Description Format (Format 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 1.4.3 Flowchart Format (Format 3) .......... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 1.5 4th Section (Subroutine) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 1.6 5th Section (Program Listing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587 1.7 Program Module Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 1.8 Symbols............................................................ 594 ~HITACHI x APPLICATION EXAMPLES. . . . . . . . . . . . . . . . . . . .. . .. . . . . . . . .. .. .. . . . . . .. . . .. .. 597 I/O PORT APPLICATIONS 1. HD61830 (LM200) Graphic Mode. . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 2. Liquid Crystal Module (H2570) Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623 TIMER APPLICATIONS 3. Duty Control of Pulse Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641 4. Pulse Width Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 5. Input Pulse Count. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664 6. Zero Cross. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672 7. Key Matrix (8 x 4). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 8. Fluorescent Display Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697 9. Stepping Motor Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709 INTERRUPT APPLICATION 10. With a Commercially Available Keyboard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734 SCI APPLICATIONS 11. SCI Clock Synchronous (External Clock) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748 12. SCI Clock Synchronous (Internal Clock). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 760 13. Liquid Crystal Driver (HD61100A) Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 772 EXTERNAL EXPANSION APPLICATION 14. External Expansion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784 LOW POWER DISSIPATION/FAIL SAFE APPLICATION 15. Low Power Dissipation Mode and HA1835P Control. . . . . . . . . . . . . . . . . . . . . . . . . . 816 Section a-Appendix Technical Q and A (Part I) a-Bit Single-Chip Microcomputer HD6305XO, HD6305X1, HD6305X2 HD6305YO, HD6305Y1, HD6305Y2 Q & A No. Page Parallel Port I (1) Outputting Data from Ports after a Reset QA63S-001B 841 (2) Serial I/O Pin Status QA63S-002B 842 (3) Using Port C when Serial I/O is Used QA63S-003B 843 Serial Port I (1) Designating Input or Output Operation of Serial QA63S-004B 844 I/O Clock Pin (2) SCI Prescaler Initialize Timing and Clock Output QA63S-00SB 845 Timing ~HITACHI xi Q&ANo. Page (3) SSR7 (SCI Interrupt Request Bit) Set Timing QA635-021B 846 (4) Using SDR (SCI Data Register) when Serial I/O ~s QA635-024B 847 not Used (5) Accessing SDR (SCI Data Register) QA635-025B 848 (6) Clearing SSR (SCI Interrupt Request Bit) QA635-026B 849 (7) Transmitting and Receiving Data Simultaneously QA635-030A 850 through Serial I/O (8) Notes on Receiving Data through SCI in External QA635-03lA 851 Clock Mode (9) SCI Operation in External Clock Mode QA635-032A 852 (10) Initializing the Transfer Clock Generator QA635-033A 853 Prescaler Timer/Counter ~ (1) Timer Count-down Timing when External Clock is QA635-006B 854 Input (2) Timer 2 Interrupt Cycles QA635-022B 855 (3) Reading/Writing Data from/into the TDR during QA635-034A 856 Timer Operation (4) Timer Clock Input Source QA635-035A 857 BUS Interface Interrupt I (1) Schmitt Trigger Circuit of Interrupt Pin QA635-007B 858 (2) Servicing Timer Interrupt while Masked QA635-008B 859 (3) Servicing INT External Interrupt while Masked QA635-009B 860 (4) Servicing INT2 External Interrupt while Masked QA635-0l0B 861 (5) Servicing an Interrupt after a Reset (CCR I bit QA635-0llB 862 initializing) (6) Servicing External Interrupt after Returning QA635-012B 863 from Standby Mode (7) Servicing Multiple Interrupts QA635-013B 864 (8) Time from Interrupt Occurrence to Interrupt QA635-036A 865 Servicing Routine Execution (9) Servicing SCI (Serial I/O) Interrupt while QA635-037A 866 Masked A/D Converter Oscillator I (1) Timing of External Clock Input to the Oscillator QA635-0l4B 867 and E Clock Timing Reset I (1) Port Status at a Reset QA635-015B 868 (2) Bus Status at a Reset QA635-0l6B 869 Low Power Consumption I (1) Bus Status in Low-Power-Consumption Modes QA635-0l7B 870 (2) Executing an Instruction when Entering Standby QA635-0l8B 871 Mode (3) Standby Mode Timing QA63S-0l9B 872 (4) Returning from Standby Mode QA63S-020B 873 (5 ) Entering Low-Power-Consumption Modes QA635-027B 874 (6) Entering Wait Mode QA635-028B 875 (7) Entering Stop Mode QA63S-029B 876 (8) Returning Time from Stop Mode QA635-038A 877 (9) Current Consumption in Low-Power-Consumption QA63S-039A 878 Mode ~HITACHI xii Q & A No. Page EPROM-on-chip Software (1) Accessing Not Used Areas on Memory Map QA635-040A 879 (2) Using Bit Manipulating Instruction for Output QA635-023B 880 Ports Eva1uation__K~i~t__~ Emulator SD Data Buffer (1) Statuses of Address Bus, Data Bus and Control QA635-041B 881 Line when the Internal Address Space is Accessed Others Section 8-Appendix Technical Q and A (Part II) 8-Bit Single-Chip Microcomputer HD6305UO,HD6305VO Q & A No. Page Parallel Port 1) Outputting Data from Ports after a Reset QA635-301A 889 (2) Serial I/O Pin Status QA635-302A 890 (3) Using Port D when Serial I/O is Used QA63S-303A 891 c==(1)Serial Por~ Designating Input or Output Operation of Serial 892 QA635-304A I/o Clock Pin (2) Using SDR (SCI Data Register) when Serial I/O is QA635-30SA 893 not Used (3) SSR7 (SCI Interrupt Request Bit) Set Timing QA635-306A 894 (4) Clearing SSR (SCI Interrupt Request Bit) QA635-307A 895 (5) Accessing SDR (SCI Data Register) QA635-308A 896 (6) Transmitting and Receiving Data Simultaneously QA635-309A 897 through Serial I/O (7) Notes on Receiving Data through SCI in External QA635-310A 898 Clock Mode (8) SCI Operation in External Clock Mode QA635-311A 899 (9) Initializing the Transfer Clock Generator QA635-312A 900 Prescaler CiO) SCI Prescaler Initialize Timing and Clock Output QA635-313A 901 Timing LTimer/Counter (1) Reading/Writing Data from/into the TDR during QA635-314A 902 Timer Operation (2) Timer Count-down Timing when External Clock is QA635-315A 903 Inpu t (3} Timer Clock Input Source QA635-316A 904 (4) Timer 2 Interrupt Cycles QA63S-317A 905 ~HITACHI xiii - - ..- ----------~--.-----.-~-~--.-- Q & A. No. Page BUS Interface Interrupt (1) Time from Interrupt Occurrence to Interrupt QA635-318A 906 Servicing Routine Execution (2) Schmitt Trigger Circuit of Interrupt Pin QA635-319A 907 (3) Servicing an Interrupt after a Reset (CCR I bit QA635-320A 908 initia1izi~ (4) Servicing INT External Interrupt while Masked QA635-32lA 909 (5) Servicing INT2 External Interrupt while Masked QA635-322A 910 (6) Servicing SCI (Serial I/O) Interrupt while QA635-323A 911 Masked (7) Servicing Timer Interrupt while Masked QA635-324A 912 (8) Servicing External Interrupt after Returning QA635-325A 913 from Standby Mode (9) Servicing Multiple Interrupts QA635-326A 914 A/D Converter Osc i lla tor (1) Timing of External Clock Input to the Oscillator QA635-327A 915 and E Clock Timing Reset (1) Port Status at a Reset QA635-328A 916 Low Power Consumption (1) Entering Low-Power-Consumption Modes QA635-329A 917 (2) Entering Wait Mode QA635-330A 918 (3) Entering Stop Mode QA635-331A 919 (4) Returning Time from Stop Mode QA635-332A 920 (5) Standby Mode Timing QA635-333A 921 (6) Returning from Standby Mode QA635-334A 922 (7) Executing an Instruction when Entering Standby QA635-335A 923 Mode (8) Current Consumption in Low-Power-Consumption QA635-336A 924 Mode EPROM-on-chip Software I (1) Using Bit Manipulating Instruction for Output QA635-337A 925 Ports (2) Accessing Not Used Areas on Memory Map QA635-338A 926 Evaluation K i t ] I Emulator , SD C Data Buffer Others ~HITACHI xiv Section 9 HD6305UO, HD6305VO, HD63705VO User's Manual Page 1. SYSTEM CONFIGURATION ............................................. . 937 1.1 System Configuration ............................................ . 937 1.1.1 External View .................................................. . 937 1.1.2 System Specification Outline ...................................... . 938 1.2 Operation ..................................................... . 942 1.2.1 Dialing Procedure ............................................... . 943 1.2.2 Storing Telephone Numbers ....................................... . 947 1.2.3 Displaying Information on LCD ..................................... . 952 1.2.4 Defining Information to be Displayed on LCD ......................... . 954 2. HARDWARE DESCRIPTION ............................................ . 956 2.1 Transmitting and Receiving Control Circuit ........................... . 957 2.2 Control Circuit for Storing and Retrieving Telephone Number in External RAM ......................................................... . 969 2.3 Driving the Liquid Crystal Display Module (H2572) ..................... . 973 2.4 8 x 8 Key Matrix ................................................ . 977 3. SOFTWARE DESCRIPTION ............................................. . 982 3.1 Transition Diagram .............................................. . 982 3.2 Program Module Configuration .................................... . 984 3.3 "SOFTWARE DESCRIPTION" Format .............................. . 986 3.4 Program Module Description ...................................... . 988 3.5 RAM Table ..................................................... . 1068 3.6 Flag Table ..................................................... . 1070 3.7 Subroutine Table ................................................ . 1073 3.8 RAM Memory Map for Storing Telephone Numbers .................... . 1077 3.9 Ports Labels Table ............................................... . 1078 4. PROGRAM LISTINGS .................................................. . 1079 4.1 Program Listing ................................................. . 1079 4.2 Symbol Table Listing ............................................. . 1149 4.3 Cross Reference Table Listing ..................................... . 1151 5. CIRCUIT DIAGRAMS .................................................. . 1164 5.1 Circuit Diagrams ................................................ . 1164 5.2 Pin Location of the HD6305YO ..................................... . 1166 5.3 Pin Functions .................................................. . 1167 APPENDIX I. HD61826 Data Sheet ........................................... . 1170 APPENDIX II. HA16808NT Data Sheet ........................................ . 1178 APPENDIX III. Instruction Set of the HD6305 Family ............................. . 1191 ~HITACHI xv HD630S/HD63LOS SERIES HANDBOOK Section One Ouick Reference .......... Guide ~HITACHI ~HITACHI 2 Ouick ......... Reference Guide ~HITACHI 3 QUICK REFERENCE GUIDE-------------------------------- • CMOS 8·BIT SINGLE·CHIP MICROCOMPUTER HD6305 SERIES HD6305UO HD6305VO HD6305XO HD6305Xl Type No. HD63A05UO HD63A05VO HD63A05XO HD63A05Xl HD63B05UO HD63B05VO HD63B05XO HD63B05Xl 1.0 (HD6305UO) 1.0 (HD6305VO) 1.0 (HD6305XOI 1.0 (HD6305Xl) Clock Frequency (MHz) 1.5 (HD63A05UO) 1.5 (HD63A05VO) 1.5 (HD63A05XO) 1.5 (HD63A05X 1) 2.0 (HD63B05UOI 2.0 (HD63B05VO) 2.0 (HD63B05XO) 2.0 (HD63B05Xl) LSI Characteristics Supply Voltage (V) 5.0 5.0 5.0 5.0 Operating Temperature (oC) 0-+70 0-+70. 1 0-+70'· 0- +70. 1 Package t DP40,FP·54, CP44 DP40 FP·54 CP44 DP·64S, Fp·64 DP·64S, FP·64 ROM (k byte) 2 4 4 4 Memory RAM (byte) 12B 192 128 12B ~ I/O Port 31 31 32 I/O Port Input Port 31 - 31 - 55 7 31 Output Port - - 16 External 2 2 2 2 Soft 1 1 1 1 Interrupt Timer 2 2 2 2 Serial 1 1 1 1 Functions Timer SCI External Memory Expansion - I - - 12k bytes Other Features HD63705VOC HD63705VOC EPROM on Chip Type HD637 A05VOC HD637A05VOC - - HD637BOsYOC HD637B05VOC HD63P05YO HD63P05Yl EPROM on the Package Type - - HD63PA05YO HD63PA05Yl HD63PB05YO HD63PB05Yl Evaluation Chip - - - - ~~~~ !_e!!1~_,:,~re Range (-40 - +85° Cl version is Ivallable, tOP; Plastic DIP. FP; Plastic Flat Package. CP; Plastic Leaded Chip Carrier (J·bend leads) ~HITACHI 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Q U I C K REFERENCE GUIDE HD6305X2 HD6305YO HD6305Yl HD6305Y2 HD63A05X2 HD63A05YO HD63A05Yl HD63A05Y2 HD63L05Fl HD63B05X2 HD63B05YO HD63B05Yl HD63B05Y2 1.0 (HD6305X2) 1.0 (HD6305YO) 1.0 (HD6305Yl) 1.0 (HD6305Y2) 1.5 (HD63A05X2) 1.5 (HD63A05YO) 1.5 (HD63A05Y1 ) 1.5 (HD63A05Y2) 0.125 2.0 (HD63B05X2) 2.0 (HD63B05YO) 2.0 (HD63B05Yll 2.0 (HD63B05Y2) 5.0 5.0 5.0 5.0 3.0 0-+70" 0-+70. 1 0-+70" 0-+70. 1 -20 - +75 DP·64S, FP·64 DP·64S, Fp·64 DP·64S, FP·64 DP·64S, FP·64 DP·64S, FP·80 - 8 a - 4 128 256 256 256 96 24 ~ ~ 24 I 20 31 7 55 ~ 31 ~ 31 7 20 I - - 16 - - I (19) 2 2 2 2 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 - • a·bit )( 1 (with 7·bit prescaler) oa·bit x 1 (with o 15·bit x 1 (combined with SCI) 7·bit prescaler) Synchronous - J 16k bytes I - a k bytes I 16k bytes - • Low power dissipation modes -S·bit AID converte (Wait, stop and standby) -LCD driver (6 x 7 segment) • Low power dis- sipation modes (Standby and halt) - - - - - HD63P05YO HD63P05Yl - HD63PA05YO HD63PA05Yl - - HD63PB05YO HD63PB05Yl - - - - HD63L05E ~HITACHI 5 ~HITACHI 6 HD630S/HD63LOS SERIES HANDBOOK Section 1\vo • Addressing Modes • CPU Architecture • Instruction Set ~HITACHI 7 ~HITACHI 8 • Addressing Modes • CPU Architecture • Instruction Set • HITACHI 9 ~HITACHI . 10 Section 2 Addressing Modes, CPU Architecture, and Instruction Set Table of Contents Page 1.1 Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.2 CPU Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.3 Instruction Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.4 Bit Manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1.5 Symbols and Abbreviations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 1.6 Executable Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 1.7 BILlBIH Instruction Precaution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 NOTE This section 2 applies only to HD6305, HD63P05, and HD63705 devices. The addressing modes, CPU architecture and instruction set for HD63L05 can be found in section 5. ~HITACHI 11 ~HITACHI 12 1.1 Addressing Modes Ten different addressing modes are available. (1) Immediate Refer to Fig. 1-2. The immediate addressing mode provides access to a constant which does not vary during execution of the program. This access requires an instruction length of 2 bytes. The effective address (EA) is PC and the operand is fetched from the byte that follows the operation code. (2) Direct Refer to Fig. 1-3. In the direct addressing mode, the address of the operand is contained in the 2nd byte of the instruction. The user can gain direct access to memory up to the lower 255th address. All RAM and I/O registers are on page 0 of address space so that the direct addressing mode may be utilized. (3) Extended Refer to Fig. 1-4. The extended addressing is used for referencing to all addresses of memory. The EA is the contents of the 2 bytes that follow the operation code. An extended address- ing instruction requires a length of 3 bytes. (4) Relative Refer to Fig. 1-5. The relative addressing mode is used with branch instructions only. When a branch occurs, the program counter is loaded with the contents of the byte following the operation code. EA = (PC) + 2 + Rel., where Rel. indicates a signed 8-bit data following the operation code. If no branch occurs, Rel. = O. When a branch occurs, the program jumps to any byte in the range +129 to -127. A branch instruction requires a length of 2 bytes. (5) Indexed (No Offset) Refer to Fig. 1-6. The indexed addressing mode allows access up to the lower 255th address of memory. In this mode, an instruction requires a length of one byte. The EA is the concents of the index register. ~HITACHI 13 (6) Indexed (8-bit Offset) Refer to Fig. 1-7. The EA is the contents of the byte following the operation code, plus the contents of the index register. This mode allows access up to the lower 51lth address of memory. Each instruction when used in the index addressing mode (8-bit offset) requires a length of 2 bytes. (7) Indexed (16-bit Offset) Refer to Fig. 1-8. The contents of the 2 bytes following the operation code are added to content of the index register to compute the value of EA. In this mode, the complete memory can be accessed. When used in the indexed addressing mode (16-bit offset), an instruction must be 3 bytes long. (8) Bit Set/Clear Refer to Fig. 1-9. This addressing mode is applied to the BSET and BCLR instructions that can set or clear any bit on page O. The lower 3 bits of the operation code specify the bit to be set or cleared. The byte that follows the operation code indicates an address within page O. (9) Bit Test and Branch Refer to Fig. 1-10. This addressing mode is applied to the BRSET and BRCLR instructions that can test any bit within page 0 and can be branched in the relative addressing mode. The byte to be tested is addressed depending on the contents of the byte following the operation code. Individual bits within the byte to be tested are specified by the lower 3 bits of the operation code. The 3rd byte represents a relative value which will be added to the program counter when a branch condition is established. Each of these instructions should be 3 byte.s long. The value of the test bit is written in the carry bit of the condition code register. (10) Implied Refer to Fig. 1-11. This mode involves no EA. All informa- tion needed for execution of an instruction is contained in the operation code. Direct manipulation on the accumulator and index register is included in the implied addressing mode. Other instructions such as SWI and RTI are also used in this mode. All instructions used in the implied addressing mode should have a length of one byte. ~HITACHI 14 I Memory i l= i I A I~_---cA~ F8 Index Reg I Stack Pomt PROG LOA: $F8 05BEt:=4A~6=:t------~ Prog Counl 05BFI- F8 05CO CCR Fig. 1-2 Example of Immediate Addressing EA 004B ./ Add., ~ CAT FCB 32 004B ~ c:~[:::~_==---~r---~==_~~:;oo~o~o--~_____eA~~;';J 20 20 Index Heg I Stack POint PROG LOA CAT 0520':j}B6t:=~_ _ J Prog Count 052E.. 4B 052F CCR §. . : ; : I Fig. 1-3 Example of Direct AddresSing EA 06E5 ~ ./ Adde, "" --r- '--I-~ oeioo A : : 40 PROG LOA CAT ~:g!l--~g:-:---hL~ Index Reg 040BI---:;E:;.5__-I~~ I Stack Point ~"" ~ ~"If-'__40_~ Prog Count 040C CCR Fig. 1-4 Example of Extended Addressing ~HITACHI 15 EA Memory ~. A Index Reg I . Stack Point PROG BEQ PROG2 04A7 27 04AB 1B ~ ; I Fig. 1-5 Example Qf Relative Addressing EA Memory OOBB . .~ ".",,, ... ~.~~~-------1========~~A~n~:;:~B~e~ ~~ • Stack Pomt PROG LOA X OSF4 ~6 I Prog Count 05FS CCR Fig. 1-6 ~ . Example of Indexed (No Offset) Addressing EA MeJory OOBe _I : : TABL FeB lIBF FCB $B6 00B9 OOBA BF 86 L -r-- Add., -r "'" A FCB IIDB OOBB DB CF I FCB lieF OOBe : Cf : I Index Reg Stack POint 03 PROG LOA TABl. X 0758 E6 07se B9 I I Pr2;i Count I I I .. 0750 . CCR § . , Fig. 1-7 Example of Indexed (8-bit Offset) Addressing ~HITACHI 16 EA 07BO ~. ./ Adder """ ~l[~A~DB . Stack Index Reg Int 02 PROG LOA TABl.X 0692 I g:;!~~~~:--~~----~ Prog Count 0695 CCR TABl ~~: ::~ g~~~I-~::1:~F;;6[-:-:-1}_______________.--1 FCB P DB 0780 DB FCB .CF 07Bll-....::;CF~.....j Fig. 1-8 Example of Indexed (16-bit Offset) Addressing EA Memory 0001 PORT B EOU 1 00011-......;B;;.F__-f"'l A 0000 Index Reg I PROG BClR 6 PORT B OSBF ,:=[10t~________~ Stack POInt 0590 I- 01 I Prog Counl 0591 CCR ~ . I ,• Fig. 1-9 Example of Bit Set/Clear Addressing EA Memory 0002 PORT C EQU 2. 00021--""FO'--I L.._ _ _' I Index Reg I PROG BRClR 2.PORT C. PROG 2 g~~:t::~~,f~;------I-rr--- 0594 0576.,-....:..10::.......-04 <-r----;"'----. CCR C In this example bit C of the CC becomes "0". Fig. 1-10 Example of Bit Test and Branch Addressing ~HITACHI 17 EA Memory i ·~. A E . In x E5 '~'~.-~ Stac In1 Prog Count 0588 OC" ~... ·· Fig. 1-11 Example of Implied Addressing 1.2 CPU Registers This CPU contains five registers available to the programmer. They are shown in Fig. 1-12. 7 0 I A I Accumulator 7 0IIndex I X RegIster 13 0IProgram I PC Counter 13 6 5 0 1010101010101, 111 SP IS~ck Pointer Condition IHIIINlzICICod!t ~~glster ig~~~ Zero Negative Interrupt Mask Half Carry Fig. 1-12 Programming Model (1) Accumulator (A) The accumulator is an 8-bit general purpose register which holds operands and results of the arithmetic operations or data manipulations. $ HITACHI 18 (2) Index Register (X) The index register is an 8-bit register used for the indexed addressing mode. It contains an 8-bit value which is added to an offset to create an effective address. The index register can also be used for data manipulations with read-modify-write instructions. When not performing addressing operations, the register can be used as a temporary storage area. (3) Program Counter (PC) The program counter is a l4-bit register which contains the address of the next instruction to be executed. (4) Stack Pointer (SP) The stack pointer is a l4-bit register containing the address of the next free location of the stack. Initially, the stack pointer is set to location $OOFF. It is decremented as a data is pushed on to the stack and incremented as data is then pulled out of the stack. The B high-order bits of the stack pointer are fixed to 00000011. During an MCU reset or a reset stack pointer (RSP) instruction, the pointer is set to location $OOFF. Subroutines and interrupts may be nested down to $00C1, which allows programmers to use up to 31 levels of subroutine calls and 12 levels of interrupt responses. (5) Condition Code Register (CCR) The condition code register is a 5-bit register indicating the results of the instruction just executed. These bits can be individually tested by conditional branch instructions. Each bit is described in the following paragraphs. (a) Half Carry (H) When set, this bit indicates that a carry occurred between bit 3 and 4 during an arithmetic operation (ADD, ADC). (b) Interrupt (I) Setting this bit masks all interrupts except for software ones. If an interrupt occurs while this bit is set, the interrupt is latched and is processed as soon as the interrupt bit (I) is cleared. (More precisely the interrupt enters the servicing routine after the instruction next to the CLI is executed.) ~HITACHI 19 - - - - - - - - - - - - ------------------------ ---- (c) Negative (N) When set, this bit indicates that the result of the last arithmetic, logical, or data manipulation is negative. (Bit 7 in the result is a logical "1".) (d) Zero (Z) When set, this bit indicates that the result of the last arithmetic, logical, or data manipulation is zero. (e) Carry/Borrow (C) When set, this bit indicates that a carry or borrow occurred during the last arithmetic operation. This bit is also affected by bit test and branch instructions, shifts and rotates. 1.3 Instruction Set The HD630SUO, HD630SVO, and HD6370SVO MCU provide object codes upward compatible with the HD680S family. They are designed to save execution time of key instructions in order to improve through put. 3 additional instructions; DAA, WAIT, STOP; are available. The HD630SUO, and HD630SVO, HD6370SVO MCU have 62 basic instruc- tions. They can be classified into five categories: register/memory, read-modify-write, branch, bit manipulation, and control. The details of each instruction are shown in the following tables. All the instructions in a given type are presented in individual tables. (1) Register/Memory Instruction Most of these instructions use two operands. One operand is either the accumulator or the index register. The other is obtain- ed from memory by using one of the addressing modes. The un- conditional jump,JMP) and the jump to subroutine (JSR) instruc- tions have no register operand. Refer to Table 1-1. (2) Read-Modify-Write Instructions These instructions read a memory location or a register, modify or test its contents, and write the modified value back to memory or to the register. The test for zero (TST) instruction is an exception to the read-modify-write instructions since it does not write data. Refer to Table 1-2. ~HITACHI 20 (3) Branch Instructions The branch instruction cause a branch from the program when a certain condition is met. Refer to Table 1-3. (4) Bit Manipulation Instructions These instructions are used on any bit in the lower 255 bytes of the memory. Two groups are available, one either sets or clears and the other performs the bit and test branch operations. Refer to Table 1-4. (5) Control Instructions These instructions control the MCU operation during program execution. Refer to Table 1-5. (6) Alphabetical Listing Table 1-6 lists the complete instruction set in alphabetical order. (7) Operation Code Map Table 1-7 is an operation code map for the instructions used on the MCU. ~HITACHI 21 Table 1-1 Register/Memory Instructions Addreaing Modo. Indexed Indexed Indexed Booleanl Condition OporMion. Mnemonic Arithmetic Codo Immediate Direct Extended (No Offse.) (8-Bl. 0tIsetI (16-8it0lls0tJ Operation OP # - OP # - OP # - OP • - OP # - OP # - H I N Z C Load A from Memory LOA A6 2 2 B6 2 3 C6 3 4 F6 1 3 E6 2 - 4 06 3 5 M··A • • " • 1\ Load X from Memory LOX AE 2 2 BE 2 3 CE 3 4 FE 1 3 EE 2 4 OE 3 5 M-X • • " • 1\ Store A in Memory STA - B7 2 3 C7 3 4 F7 1 4 E7 2 4 07 3 5 A-·M • • "• 1\ Store X in Memory STX --- 8F 2 3 CF 3 4 FF 1 4 EF 2 4 OF 3 5 X-·M • • " • 1\ " • 1\ 1\ Add Memory to A AOO AB 2 2 BB 2 3 CB 3 4 FB 1 3 EB 2 4 OB 3 5 A+M ·A 1\ Add Memory and Carry --I"- --I- e- r-- r- I- e-- " • "1\ 'oA AOC A9 2 2 B9 2 3 C9 3 4 F9 1 3 E9 2 4 09 3 5 A+M+C·.A 1\ 1\ Subtract Memory Subtract Memory from SUB AO 2 2 eo 2 3 CO 3 4 FO 1 3 EO 2 -,.....- -- --- r-- e- -,- -r- - - - _ . 4 00 3 5 A-M .A -- • • - e-- - _. 1\ " A with Borrow SBC A2 2 2 B2 2 3 C2 3 4 F2 1 3 E2 2 4 02 3 5 A-M-C .A • • --,.....1\" ---1\ -•" 1\ --.-• • AND Memory to A ANO A4 2 2 B4 2 3 C4 3 4 F4 1 3 E4 2 4 04 3 5 A- M·.A OR Memory with A ORA t;.A 2-~- faA 23 rcA 3'"4 r-FA'l- l rEA '"2 r-4" OA 3 ---r-------. 5 A+M'A ... • • I\, • 1\ Exclusive OR Memory ~ with A EOR A8 2 2 B8 2 3 C8 3 4 F8 1 3 E8 2 4 08 3 5 A+M .A • •" • Arithmetic Compare A " with Memory Arithmetic Compare X CMP Al- 2 2 BI 2 3 CI 3 4 FI 1 3 EI 2 4 01 3 5 A-M • • " 1\ 1\ with Memory CPX A3 2 2 B3 2 3 C3 3 4 F3 1 3 E3 2 4 03 3 5 X-M • • 1\ 1\ 1\ Bit res. Memory with A (logical Comp.r.~ BIT A5 2 2 B5 2 3 C5 3 4 F5 1 3 E5 2 4 05 3 5 A,M • •" • Jump Unconditional JMP - - - BC 2 2 CC 3 3 FC 1 2 EC 2 3 OC 3 4 • • • " • • Jump to Subroutine JSR - - - BO 2 5 CO 3 6 FO 1 5 ED 2 5 DO 3 6 • • • • • Symbols: op· Cpsrilion It • Number of by'.' - • Number of cvcl•• Table 1-2 Read/Modify/Wri te Instructions Addrelling Modes Condition Indexed Indexed Operations Mnemonic Boolean/Arithmetic Operation Code ImpliedlAI Implied(XI Direct (No Offsetl 18-Bl' Offsetl OP a - OP a - OP # - OP # - OP a - H I N Z C Increment INC 4C 1 2 5C 1 2 3C 2 5 7C 1 5 6C 2 • • " 1\ • 6 A+l ".. A or X+l .X or M+l ·.M -- Decrement DEC 4A 1 2 5A 1 2 3A 2 5 7A I 5 6A 2 ,6 A-l-..A or X-l-..X or M-t -·M • • • Clear CLR 4F 1 2 5F 1 2 3F 2 5 7F 1 5 6F 2 6 00 .... A or 00 ....X or 00 .. M • • "0 "1 • Complemenl COM 43 1 2 53 1 2 33 2 5 73 1 5 63 2 6 A ·.A or'l( -.X or M-M • • 1\ " I Negate DO-A .A or DO-X ··X (2', Complemenll NEG 40 1 2 50 1 2 30 2 5 70 1 5 60 2 6 or DO-M .M """ • • Rotate Left Thru Carry ROL 49 1 2 59 1 2 39 2 5 79 1 5 69 2 6 I II Ibp • • Lb-t I Ilori-II 1\ " 1\ ROR 46 1 2 56 1 2 36 2 5 76 1 5 66 2 6 LEHb. 1 H3 ..: I [\] • • 1\ ROllI. RighI Thru Carry C c b. M .. " 1\ Logicll Shift Left LSL 48 1 2 5B 1 2 38 2 5 78 1 5 68 2 6 D-i 1~,,:xH 1 1 1--" • • 1\ " 1\ Logical Shift RighI LSR 44 1 2 54 1 2 34 2 5 74 1 5 64 2 6 b. .. c 0-; 1 H'~~MI I KJ • • 0 1\ Arilhmlttic Shift RighI ASR 47 1 2 57 1 2 37 2 5 77 1 5 67 2 8 cr:1b.H+·:MI 1..KJ • • " " " C 1\ Arilh_ Shift Left ASl 48 1 2 58 1 2 3B 2 5 78 1 5 68 2 6 Equlilo LSL • • "" " Tilt for Negative or Zero TST 40 1 2 50 1 2 30 2 4 70 1 4 60 2 5 A-DO or X-DO or M-DO • • 1\ " • SVmbols: Op. Cpsralion It - • Numbor of byt.. - • Numbor of cycles ~HITACHI 22 Table 1-3 Branch Instruction Addressing Modes 1----.---- Condition Code Operations Mnemonic Relative Branch Test OP :1* - H I N Z C Branch Always BRA 20 2 • • • • • 3 None Branch Never BRN 21 2 • • • • •3 None Branch IF Higher BHI 22 2 3 C+Z=O • • • • • Branch IF Lower or Same BLS 23 . _ - t--- 2 3 C+Z=1 • • • • • Branch IF Carry Clear BCC 24 2 3 C=O t---..- - - - I - - - . • • • • • (Branch IF Higher or Same) (BHS) 24 2 3 C=O -25 -2- 3 C=1 • • • f--::-• • • • • -------~--~ Branch IF Carry Set ---- BCS . - f - - - - - - - - f---- 1 - - - . • • -- (Branch IF Lower) (BLO) 25 2 3 '26. 2 3 Z=O f------- C=1 • • • • • Branch IF Not Equal BNE • • • • • . Branch IF Equal --- BEQ BHCC-·· 27 2 3 Z=1 --_ 2 -3 H=O _ • • • • • .. . Branch IF Half Carry Clear --t---- ._- 28 • • • • • -- Branch IF Half Carry Set BHCS -----_. 29 2 3 H=1 3- N=O • • • • • f-:-:--------. _._Branch IF Plus _--_._-_._,._-- .. BPL 2A 2 3- N=1 • • • • • c------- -- 1----------_._----- - • 1--- • • •._- •---- Branch IF Minus BMI 2B 2 _--- ----,.. . f---------- ----" f-- Branch IF Interrupt Mask Bit is Clear -------------- Branch IF Interrupt Mask BMC 2C 2 3 1=0 • • • • •-- Bit is Set ._--------- Branch IF Interrupt Line BMS 20 2 3 1=1 • • • • r·····• ---- is Low Branch IF Interrupt Line BIL 2E 2 - - f---- ' - - - - f - - - - - . 3 INT=O •---- -• 1---• • • 1--- - - is High BIH 2F 2 3 INT=1 5-- 1------_._----_. • -• 1---- • 1----• -• Branch to Subroutine BSR AD 2 • • • • • Symbols: op = Operation # =: Number of bytes - = Number of cycles Table 1-4 Bit Manipulation Instructions Addressing Modes Booleanl Branch Condition Code Operations Mnemonic Bit Set/Clear Bit Test and Branch Arithmetic Operation Test OP :. - OP ~ - H I N Z C Branch IF Bit n is set BRSET n(n -0··· 7) - - 2·n- 3 5 - Mn=l • • • • 1\ Branch IF Bit n is clear BRCLR n(n-0····7) - - - 01 +2·n 3 5 - Mn=O • • • • /\ Set Bit n BSET n(n-0···7) 10+2·n 2 5 - - - 1-Mn - - • • • • • Clear Bit n Symbols: Op = Operation BCLR n(n =0··· 7) 11 +2·n 2 5 - O-Mn - - • • • • • # = Number of bytes - = Number of cycles ~HITACHI 23 Table 1-5 Control Instructions Addressing Modes Operations Mnemonic Implied Condition Code Boolean Operation OP # - H I N Z C Transfer A to X TAX 97 1 2 A----X • • • • • Transfer X to A TXA 9F 1 2 X----A • • • • •1 Set Carry Bit SEC 99 1 1 1----C • • • • 0 Clear Carry Bit ClC 9B 1 1 O---+C • •1 • • Set Interrupt Mask Bit SEI 9B 1 2 1----1 • 0 • • • Clear Interrupt Mask Bit CLI 9A 1 2 0----1 • • • • Software Interrupt SWI 83 1 10 • 1 • • • Return from Subroutine Return from Interrupt RTS RTI 81 80 1 1 5 8 • • • • • ? ? ? ? ? Reset Stack Pointer RSP 9C 1 2 $FF----SP • • • • • No-Operation Decimal Adjust A Stop NOP OAA STOP 90 80 8E 1 1 1 1 2 4 Advance Prog. Cntr. Only Converts binary add of BCD charcters into BeD format 0-.1 • • • • • • • • 00 • • • A '/' " . Wait WAIT 8F 1 4 0-'1 • • • • Symbol.: Op ~ OperatIon • Are BCD characters of upper byte 10 or more? IThey are not clearad if set in advance.! # a Number of bytes - • Number of cycl•• Table 1-6 Instruction Set (in Alphabetical Order) Addressing Mode. Condition Code Bit Bit Mnemonic Indexed Indexed Indexed Set! Test. Implied Immediate Direct Extended Relative INo Offset) 18-Bit) (lB-Bit) Clear Branch H I N Z C ADC X X X X X X 1\ • 1\ A 1\ ADD X X X X X- X A • 1\ 1\ 1\ AND X X X X X X • • • A 1\ ASl X X X X • • f, 1\ 1\ ASR X X X X • • A A 1\ BCC X • • • • • BClR X •• • • • BCS X • • • • • BEQ X • • • • • !lHCC X ••• • • BHCS X • • • • • BHI X •••• • IBHS) X • • • • • BlH X • • • • • Bil X •• •• • BIT X X X X X X •• • A A IBLO) X •• • • • BlS X • • • • • BMC X ••••• BMI- , X • • • • • BMS X • • • • • BNE X ••• •• BPl X • • • • • BRA X • • • •• Condition Code Symbols: (to be continued) H Half Carry IFrom Bit 3) C CarrylBorrow I Interrupt M.k A Test and Set if True, Cleaned Otherwise N Negative (Sign Bil) • Not Affllcllld Z Zero ? load CC Register From Stack ~HITACHI 24 Addressing Mode. Condition Code Bit Bit Mnemonic Indexed Indexed Indexed Set Test & Implied Immediate Direct Extended Relative (No Offset) (8-Bit) (16-Bit) Clear Branch H I N Z C BRN x • • • • • BRCLR x • • • • " BRSET x • • • • 1\ BSET x • • • • • BSR x • • • • •0 CLC x • •0 • • CLI x • • • • CLR x x x x • • 1\0 1 • CMP x x x x x x • • " "1 COM x x x x • • A CPX x x x x x x • • A " A" ~ DAA x • • " A DEC x x x x • • A " • EOR x x x x x x • • A A •- INC x x x x • • " A • JMP ; x x x x x • • • • • JSR x x x x x • • • • • LOA x x x x x x • • 1\ A • LOX x x x x x x • • 1\ 1\ • LSL x x x x • • LSR x x x x • • "0 "" "" NEG x x x x • • 1\ " " NOP x • • • • •- ORA x x x x x x • • 1\ " • - ROL x x x x • • 1\ " " ROR x I x x x • • 1\ A 1\ RSP RTI x x • • • • • ? ? ? ? ? RTS x • • • • • SBC x x x x x x • • 1\ A 1\1 SEC x • • • • SEI x • 1 • 1\• • STA x x x x x • • 1\ • STOP x • 0 • 1\• • STX x x x x x • • 1\ • SUB x x x x x x • • 1\ SWI x • 1 • "• "• TAX x • • • • • TST x x x x • • 1\ • 1\ TXA x • • • • • WAIT x • 0 • • • Condition Code Symbols: H Half Carry (From Bit 3) C Carry /Borrow Interrupt Mask /\ Test and Set if True, Cleared Otherwise N Z Negative (Sign Bit) Zero •? Not Affected Load CC Register From Stack ~HITACHI 25 Table 1-7 Operation Code Map Bit Manipulation Branch Read/Modify/Write Control Register/Memory Test & Set! Branch Clear Rei OIR A X .Xl .XO IMP IMP IMM OIR EXT .X2 .Xl .XO 0 BRSETO 0 1 BSETO 2 BRA 3 4 5 NEG 6 7 RW 8 9 - A 8 C SUB 0 E F -0 HIGH 1 BRCLRO BCLRO BRN - RTS· - CMP 1 2 BRSETl BSETl BHI - - - SBC 2 3 BRCLRl BCLRi BLS COM SWI· - CPX 3 L o 4 BRSET2 BSET2 BCC LSR - - AND 4 W 5 BRCLR2 BCLR2 BCS - - - BIT 5 6 BRSET3 BSET3 BNE ROR " - - LOA 6 7 BRCLR3 BCLR3 BEQ ASR - TAX· - STA STA(+ II 7 8 BRSET4 BSET4 BHCC LSL/ASL - CLC EOR 8 9 BRCLR4 BCLR4 BHCS ROL - SEC AOC 9 A BRSET5 BSET5 BPL DEC - CLI' ORA A B BRCLR5 BCLR5 BMI - - 5EI' ADD B C BRSET6 BSET6 BMC INC - RSp· - JMP(-l) C 0 BRCLR6 BCLR6 BMS TSTI-I) TST TST(-l) OAA· NOP B5R· J5R(+2) JSR(+l) JSRH2) 0 E BRSET7 BSET7 BIL - STOp· - LOX E F BRCLR7 BCLR7 BIH CLR WAIT' TXA· - STX STX(+II F 3/5 2/5 2/3 2/5 1/2 1/2 2/6 1/5 1/" 1/1 2/2 2/3 3/4 3/5 2/4 1/3 (NOTESI 1. "-" is an undefined operation code. 2. The lowermost numbers in each column represent a byte count and the number of cycles required (byte count/number of cyclesl. The number of cycles for the mnemonics asterisked (01 is as follows: ATI 8 TAX 2 ATS 5 ASP 2 SWI 10 TXA 2 DAA 2 BSA 5 STOP 4 ell 2 WAIT 4 SEI 2 3. The parenthesized numbers must be edded to the cycle count of the particular instruction. (11) Additional Instructions The following new instructions are used on the HD6305, and HD63705. DAA Converts the contents of the accumulator into BCD code. WAIT Causes the MCU to enter the wait mode. Refer to "2.9 Low Power Consumption Mode". STOP Causes the MCU to enter the stop mode. Refer to "2.9'Low Power Consumption Mode". ~HITACHI 26 1.4 Bit Manipulation The HD6305, HD63705 MCU can use a single instruction (BSET or BCLR) to set or clear one bit of the RAM or an I/O port. Every bit of memory or I/O within page 0 ($00 ~ $FF) can be tested by the BRSET or BRCLR instruction depending on the result of the test, the program can branch to required destinations. Since bits in the RAM, or I/O can be manipulated, the user may use a bit within the RAM as a flag or handle a single I/O bit as an independent I/O terminal. Fig. 1-13 shows an example of bit manipulation and the validity of test instructions. In the example, the program is con- figured assuming that bit 0 of port A is connected to a zero cross detector circuit and bit 1 of the same port to the trigger of a triac. The p.rogram shown can activate the triac within 10]1s from zero- crossing through the use of only 7 bytes on the ROM. The internal timer provides a required time of delay and pulse width modulation of power is also possible. SELF 1. BRCLR 0, PORT A, SELF 1 BSET l, PORT A BCLR 1, PORT A Fig. 1-13 Example of Bit Manipulation ~HITACHI 27 1. 5 Symbols and Abbreviations Shown below are the meanings of symbols and abbreviations. (1) Operation 0= contents -+- movement direction .+ = addition subtraction /\ AND v = OR $= Exclusive OR x = NOT (2) Register symbols in CPU ACCA = accumulator A CCR = condition codes register IX index register, 8 bits PC program counter, 14 bits PCH the six most significant bits of program counter PCL the eight least significant bits of program counter SP = stack pointer, 6 bits (3) Memory and addressing codes M= stored address MH the eight most significant bits of stored address ML the eight least significant bits of stored address M+l stored address M plus 1 Msp stored address indicated by stack pointer Imm immediate value Disp displacement value = M - (IX) D = displacement value = M - (IX) DR = displacement value the eight most significant bits DL = displacement value the eight least significant bits ReI = relative value IMPLIED = implied addressing RELATIVE = relative addressing ACCUMULATOR accumulator addressing ~HITACH. 28 INDEX REG. = index register addressing IMMEDIATE immediate addressing DIRECT = direct addressing EXTENDED extended addressing INDEXED 0 BYTE OFFSET indexed addressing 0 byte offset INDEXED 1 BYTE OFFSET indexed addressing 1 byte offset INDEXED 2 BYTE OFFSET indexed addressing 2 byte offset EA = ' effective address (4) Contents of bits 0 through 4 of condition codes register C .. carry - borrow bit 0 Z .. zero bit 1 N negative bit 2 I interrupt mask bit 3 H = half carry from bit 3 to bit 4 bit 4 (5) Status of each bit before execution of instruction An .. bit n of ACCA (n = 7, 6, 5, .... , 0) Mn bit n of M (n = 7, 6, 5, .... , 0) Xn bit n of IX (n = 7, 6, 5, .... , 0) (6) Status of each bit on result after execution of instruction Rn" bit n of result (n .. 7,6,5, .... , 0) (7) Symbols on instruction's format p.. each addressing mode on Immediate, Direct, Extended and index of 0, land 2 byte offset Q.. each addressing mode on Direct and index of 0 and 1 byte offset A.. accumulator addressing mode X index register addressing mode DR direct addressing mode dd.. relative operand (8 bits) n= bitnofmemory (n=7, 6, 5, .•.• , 0) (8) Status of H06305's interrupt pin INT = status of interrupt pin (high, low) ~HITACHI 29 1.6 Executable Instructions Arithmetic Operation ADC ADC (ADd with Carry) I Format II I Condition Codes II R: Set if a carry occurs from bit 3; ADC P otherwise reset. I: Not affected. N: Set if the most significant bit of the result is set; reset otherwise. I Operation II Z: Set if the result is 0; otherwise reset. C: Set i f a carry occurs from the ACCA + (ACCA) + (M) + (C) most significant bit of the result; otherwise reset. I Description IJ Adds the contents of the carry bit C to the sum of the contents of ACCA and M and stores the result into ACCA. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing I Operand Mnemonic I of of CPU Mode I type Byte 1 Byte 2 I Byte 3 I I bytes cycles I I IMMEDIATE ADC I t/Imm A9 Imm 2 2 DIRECT ADC I I M B9 M 2 3 EXTENDED ADC I 0 M C9 MH ML 3 4 INDEXED U BYTE I iOFFSET ADC I I O,X F9 I 1 3 INDEXED 1 BYTE I I OFFSET ADC :Disp ,X E9 I D 2 4 INDEXED 2 BYTE I I OFFSET ADC :Disp ,X D9 I DR DL 3 5 I I I I I I I I I Example II 0100 B6 02 LDA VAL2 (EXVAL5,EXVAL6)+(VAL1,VAL2) 0102 CB 0006 ADD EXVAL6 * =(EXVAL5, EXVAL6) 0105 C7 0006 STA EXVAL6 * 0108 B6 01 LDA VALl * 010A C9 0005 ADC EXVAL5 *** 010D C7 0005 STA EXVAL5 * ~HITACHI 30 Arithmetic Operation ADD ADD (ADD without carry) I Format IJ I Condition Codes II H: Set i f a carry occurs from bit 3 ADD P otherwise reset. I: Not affected. N: Set i f the significant bit of the result is 1; otherwise reset. I Operation II Z: Set i:f the result is 0; otherwise reset. C: Set i f a carry occurs from the ACCA ~ (ACCA) + (M) most significant bit of the result; otherwise reset. I Description I Adds the Mcontents to ACCA contents, and stores the result into ACCA. Addressing Mode and Number of CPU Cycles 0 Instruction code Number Number Addressing Mnemonic I Operand 0 of of CPU Mode I type Byte 1 iI Byte 2 Byte 3 I bytes cycles I I IMMEDIATE ADD I IIImm AB 0 Imm 2 2 0 DIRECT ADD 0 I M BB 0 0 M 2 3 0 EXTENDED ADD oM 0 CB : MH ML 3 4 INDEXED u BYTE I OFFSET ADD I O,X FB , I 1 3 ,, Disp,X 0 INDEXED 1 BYTE OFFSET ADD 0 EB , D 0 2 4 INDEXED Z BYTE I I OFFSET ADD , Disp,X I DB I DH DL 3 5 0 I I I ,I ,, I Example II 0110 B6 10 LOA VAll (VAL1)+(WORK)=(RESULT) 0112 BB FF ADD WORK * 0114 B7 50 STA RESULT * ~HITACHI 31 Logical Operation AND AND (logical AND) I Format IJ I Condition Codes II H: Not affected. AND P I: Not affected. N: Set i f the most significant bit of the result is "1"; otherwise reset. I Operation II Z: Set i f the result is "0"; otherwise reset. C: Not affected. ACCA +- (ACCA) 1\ (M) I Description II Performs logical AND between the ACCA contents and the M contents, and stores the result into ACCA. Addressing Mode and Number of CPU Cycles Addressing I Instruction code Number Number Mnemonic I Operand I Mode of of CPU I type Byte 1 iI Byte 2 Byte 3 I bytes cycles I I IMMEDIATE AND I flImm A4 I Imm 2 2 I I DIRECT AND I M B4 , M I 2 3 I EXTENDED AND 'M , C4 : MH ML 3 4 INDEXED 0 BYTE I OFFSET AND I I O,X F4 ,I 1 3 INDEXED .l BYTE I OFFSET AND I I Disp,X E4 , D I 2 4 INDEXED 2 BYTE I I OFFSET AND , Disp,X I D4 I DH DL 3 5 , , I I , I I I I Example II 0107 F6 LDA O,X ERASE UPPER 4 BITS 0108 A4 OF AND #$OF * OlOA F7 STA O,X (RESTORE) OlOB 5C INC X * OlOC 20 F2 BRA LOOP * ~HITACHI 32 Shift and Rotation ASL ASL (Arithmetic Shift Left) I Format II I Condition Codes II ASL Q H: Not affected. ASL A ASL X I: Not affected. N: Set if the most significant bit of the result is "I"; otherwise reset. I Operation II Z: Set if the result is "a"; otherwise reset. C: Set if the most significant bit is , "I" before shifting; otherwise El~1 I I I I I I I I~ reset. 0 b7 bo I Description I Shifts the contents of ACCA, IX or M 1 bit to the left. The bit a is loaded with "a". The carry bit C is loaded with the bit 7 of ACCA, IX or M. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing I Operand Mnemonic I I of of CPU Mode type Byte 1 : Byte 2 Byte 3 I I bytes cycles I I ACCUMULATOR ASL I A 48 I 1 2 I I INDEX REG. ASL I X 58 I I 1 2 I DIRECT ASL I I M 38 ,I M 2 5 INDEXED 0 BYTE I I I OFFSET ASL I O,X 78 I 1 5 INDEXED 1 BYTE I I I OFFSET ASL I Diso X 68 I D 2 6 I I I I I I I I I I I I I I Example II 010E B6 FF LDA WORK 0110 48 CHECK ASL A BRANCH FOLLOWING BIT 0111 25 2E BCS BITON * 7-6-5-4-3-2-1-0 0113 BITOFF EQU * 0113 AE 64 LDX #100 ~HITACHI 33 Shift and Rotation ASR ASR (Arithmetic Shift Right) I Format II I Condition Codes II ASR Q H: Not affected. ASR A I: Not affected. ASR X N: Set if the most significant bit of the result is "1"; otherwise reset. I Operation II Z: Set if the result is "0"; other- wise reset. C: Set if the most significant bit is • "1" before shifting; otherwise C?I I I I I I I I-.@] b7 bo reset. I Description I Shifts the contents of ACCA, IX or M l-bit to the right. The bit 7 is not affected. The bit o is loaded into the carry bit C. Addressing Mode and Number of CPU Cycles I Addressing I Instruction code Number Number Mnemonic I Operand I Mode of of CPU ,I type Byte 1 :I Byte 2 Byte 3 bytes cycles I , ACCUMULATOR ASR I A 47 I 1 2 INDEX REG. ASR I X 57 I I 1 2 DIRECT ASR I ., M I 37 ·: I M 2 5 INDEXED U BYTE I ASR O,X 77 I D 1 5 OFFSET INDEXED 1 BYTE OFFSET ASR I , Disp,X I 67 ·· I 2 6 I I , , I I I I I I . I I I I Example II 0143 37 FF ASR WORK BRANCH OPTION (KEEPING BIT 7) 0145 25 17 BCS OPTO 0147 37 FF ASR WORK 0149 25 1B BCS OPTl 014B 37 FF ASR WORK 0140 25 46 BCS OPT2 ~HITACHI 34 Conditional Branch BCC BCC (Branch if Carry Clear) I Format II I Condition Codes II BCC dd Not affected. I Operation II PC + (pC)+OO02+Rel i f (C)=O I Description I Tests the state of the C bit and causes a branch if C is "0". Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand of of CPU Mode type Byte 1 II Byte 2 I Byte 3 I bytes cycles I RELATIVE BCC Rel 24 , Rel 1 1 I 2 3 I I , I 1 I I 1 ,I 1 I ,1 1 I , I I 1 I I I , I , ,, I , I I I I I Example II 014F B6 20 LOA VAL2 0151 CB 0600 ADD EXVAL6 0154 24 11 BCC NORMAL KETA AGARI NASHI * 0156 5C INC X KETA AGARI ~HITACHI 35 Bit Control BCLR BCLR (Bit CLeaR bit n) I Format Ij I Condition Codes Ir BCLR n, DR Not affected. I Operation II Mn + 0 I Description I Clears the bit n (n = ° through 7) of M. The other bits are unaffected. Addressing Mode and Number of CPU Cycles , " N\'lmber Number Addressing Instruction code Mnemonic:, Operand of of CPU Mode type Byte 1 ,: Byte 2 Byte 3 I bytes cycles DIRECT BCLR I I O,M 11 , I M 2 5 , ,, DIRECT BCLR I 1,M 13 , M 2 5 ,, , DIRECT BCLR 2.M 15 : M 2 5 DIRECT BCLR ,,, 3,M 17 ,, M 2 5 DIRECT BCLR ,, , 4,M 19 ,I M 2 5 DIRECT , 5,M I lB , M 2 5 BCLR I , I ,, DIRECT BCLR I 6,M lD , M I 2 5 DIRECT BCLR ,, 7,M lF ,, M ,,, 2 5 I Example II 0157 B6 03 LOA CNTRL ** MAKE CONTROL CODE ** 0159 A4 FO AND #$FO * 015B BA FF ORA WORK * 0150 B7 03 STA CONTRL * 015F 11 03 BCLR O,CNTRL CLEAR BIT 0,6,7 ABSOLUTELY 0161 10 03 BCLR 6,CNTRL 0163 1F 03 BCLR 7,CNTRL ~HITACHI 36 Conditional Branch BCS BCS (Branch if Carry Set) I Format II I Condition Codes II BCS dd Not affected. I Operation II PC + (PC)+OOO2+Rel if (C)=l I Description I Tests the C-bit state and causes a branch if C is "1". Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I RELATIVE BCS ReI 25 I ReI 2 3 I , I I : I I I I I I I I I I I Example II 0165 B6 10 LDA VAll 0167 CB 0600 ADD EXVAL6 , 016A 25 13 BCS ABNML KETA AGAR! * 016C C7 0600 STA EXVAL6 KETA AGAR! NASH! $ HITACHI 37 Conditional Branch BEQ BEQ (Branch of Equal) I Format II I Condition Codes II BEQ dd Not affected. I Operation II PC'--(PC)+OOO2+Rel i f (Z)=l I Description ] Tests the Z-bit state and causes a branch if Z is "1", Addressing Mode and Number of CPU Cycles Addressing I Instruction code Number Number Mnemonic I Operand Mode I I type of of CPU I Byte 1 : Byte 2 I Byte 3 bytes cycles I I RELATIVE BEQ I ReI 27 I ReI 2 3 I I I I I I , I , I I , I I I I I I I I I I I I , , I I ,, I I I I I I I I I I I Example 016F B6 FF 0171 27 18 0173 B1 50 " LOA BEQ CMP WORK AAAA RESULT WORK = 0 0175 27 28 BEQ BBBB WORK = RESULT ~HITACHI 38 Conditional Branch BHCC BHCC (Branch if Half Carry Clear) I Format II I Condition Codes II BHCC dd Not affected. I Operation II PC ~ (PC)+OOO2+Rel i f (H)=O I Description II Tests the H-bit state and causes a branch if H is "0". Addressing Mode and Number of CPU Cycles , Number Number Addressing Instruction code Mnemonic I Operand I of of CPU Mode I type Byte I :I Byte 2 Byte 3 I bytes cycles RELATIVE BHCC I I ReI 28 1 , ReI 2 3 I I I ,, , ,I .,, I I I , I I I I , I 1 I I I ,I I I I , I I I I Example II 01E7 Al 09 CMP #$9 01E9 23 02 BLS DAALOW $99 ---> INPUT 01 EB AE 60 DAAH6 LOX #$60 HIGH NYBLE NEEDS CORRECTION * 01 ED 28 15 DAALOW BHCC DAAL9 01EF 9F TXA ~HITACHI 39 Conditional Branch BHCS BHCS (Branch if Half Carry Set) I Format II I Condition Codes II BHCS dd Not affected. I Operation II PC + (PC) + 0002 + .Rel i f (H) = 1 I Description II Tests the H-bit state and causes a branch if H is "1". Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I RELATIVE BHCS ReI 29 I ReI 2 3 I I I I : I I I I I I I I I I I Example 01FO A1 09 01F2 23 02 01F4 AE 60 " DAAH7 * CMP BLS LDX #$9 DAALW1 #$60 $99 --- INPUT HIGH NYBLE NEEDS CORRECTION 01F6 29 16 DAALW1 BHCS DAAL6 01F8 A4 OF AND #$F ~HITACHI 40 Conditional Branch BHI BHI (Branch if HIgher) I Format \I I Condition Codes II BHI dd Not affected. I Operation Ir PC + (PC)+0002+Rel if (C V Z)=O i.e. i f (ACCA) > (M) (unsigned binary numbers) I Description I Causes a branch i f both C-bit and Z-bit are "0". When the BHI instruction is executed immediately after either CMP or SUB instruction has been executed, a branch occurs if the minuend represented by the unsigned binary number (i.e. ACCA) is greater than the subtrahend represented by unsigned binary number (i.e. M). Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic I Operand I of of CPU Mode I type Byte I :I Byte 2 Byte 3 I bytes cycles I I RELATIVE BHI I ReI 22 I ReI 2 3 I I I I I I I I I 0 I I I I I I I I I I I I I I I I I I I I I I I I Example II 0177 B6 10 LDA VAll 0179 Bl 20 CMP VAL2 017B 22 16 BHI ZIP25 VALl > VAL2 (IGNORE SIGN BIT) * 017D B7 FF STA WORK VAL 1 --> WORK (LOWER OR SAME) ~HITACHI 4'1 Conditional Branch BHS BHS (Branch if Higher or Same) I Format II I Condition Codes II BHS dd Not affected. I Operation II PC + (PC)+OOO2+Rel i f (C)=O I Description I When the BHS instruction is executed after comparing or subtracting unsigned binary, if causes a branch i f the register contents are greater than or equal to the M contents. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic II Operand I Mode of of CPU type Byte 1 :I Byte 2 Byte 3 I bytes cycles I I RELATIVE BHS I Rei 24 I Rei 2 3 I I I I I I I I : I I I I I I I I I I I I I I I I I I I I I I I I Example II 0100 B6 10 LDA VAll 0102 Bl 20 CMP VAL2 0104 24 16 BHS ZlP26 VAll >= VAL2 IGNORE SIGN BIT * 0106 B7 FF STA WORK VAL 1 ---> WORK (LOWER) ~HITACHI 42 Conditional Branch BIH BIH (Branch if Interrupt line is High) I Format II I Condition Codes II BIH dd Not affected. I Operation Ij PC + (PC)+OOO2+Rel i f INT=l (high) I Description I Tests the external interrupt pin (INT) state and causes a branch if it is high. Addressing Mode and Number of CPU Cycles Addressing ,, Operand Instruction code Number Number Mnemonic , of of CPU Mode I type Byte 1 :I Byte 2 I Byte 3 I I I bytes cycles I RELATIVE BIH I I Rel 2F , I Rel I I 2 3 I I ,, I , I I , I I . , I I I ,I I I , I , I I I I I , I I I , I , I I I I I I Example II OlC6 2F 04 BIH INTHO INT LINE CHECK 01C8 A6 28 INTLl LDA #$28 OUTPUT DATA = $28 OlCA 20 02 BRA NEXT2 OlCC A6 FF INTHO LDA #$FF OUTPUT DATA = $FF OlCE C7 06EO NEXT2 STA PIA OUTPUT ~HITACHI 43 Conditional Branch BIL BIL (Branch if Interrupt line is Low) I Format II I Condition Codes II BIL dd Not affected. I Operation IJ PC ~ (pC)+OOO2+Rel i f INT=O (low) I Description I -- Tests the external interrupt pin (INT) state and causes a branch if it is low. Addressing Mode and Number of CPU Cycles Addressing I Instruction code Number Number Mnemonic: Operand of of CPU Mode I type Byte I i Byte 2 I Byte 3 I I bytes cycles I I RELATIVE BIL ReI 2E I ReI I I 2 3 I I I I I I . I I I I I I I I I I I I I I I . I I : I I I I I I I I I Example 'I 0101 2E 04 BIL INTL2 INT LINE CHECK 0103 A6 45 INTH3 LOA #$45 OUTPUT DATA = $45 0105 20 02 BRA NEXT4 0107 A6 00 INTL2 LOA #$0 OUTPUT DATA = $00 0109 C7 06EO NEXT4 STA PIA OUTPUT ~HITACHI 44 Logical Operation BIT BIT (BIt Test) I Format II I Condition Codes Ir R: Not affected. BIT P I: Not affected. N: Set if the most significant bit of the result of the AND operand is I Operation II 1; otherwise cleared. Z: Set if all the bits of the result of the AND operand are 0; other- (ACCA)!\(M) wise cleared. C: Not affected. I Description I Performs the logical AND operation between the ACCA contents and M contents and modifies the condition codes respectively. The ACCA contents and M contents are not affected. Addressing Mode and Number of CPU Cycles Addressing I Instruction code Number Number Mnemonic: Operand of of CPU Mode I type Byte 1 :I Byte 2 Byte 3 I bytes cycles , I I IMMEDIATE BIT I IIImm A5 I Imm 2 2 I I DIRECT BIT M B5 I I M 2 3 I EXTENDED BIT M C5 : MH ML 3 4 lNUI;./iliU U IHTI; I OFFSET BIT O,X F5 I 1 3 I~~~~~ED 1 BYTE I FF ET BIT Disp X E5 I D 2 4 ~;~~~~lJ l BYTJ; BIT Disp,X D5 I I DR DL 3 5 I I I I I Example II 0400 B6 10 EVBIT LOA VALl 0402 A5 FB BIT #$FB 0404 27 19 BEQ OK o <= BIT ASSIGN (VALl) <= 7 * 0406 A6 E3 NG LOA #227 SET ERROR NUMBER 040B CC 0432 JMP ERROR ~HITACHI 45 Conditional Branch BLO BLO (Branch if LOwer) I Format II I Condition Codes II BLO dd Not affected. Operation II PC + (PC)+OOO2+Rel i f (C)=l I Description I , Causes a branch when executing BLO after compare if register contents are less than M contents. BLO is equivalent to BCS. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I RELATIVE BLO ReI 25 I ReI 2 3 I I I I : I I I I I I I I I I I Example II 040B B6 10 lDA VAll 040D B1 20 CMP VAl2 040F 25 16 BlO ZIP27 VAll < VAl2 (IGNORE SIGN BIT) * 0411 B7 FF STA WORK VAll --> WORK HIGHER OR SAME $HITACHI 46 Conditional Branch BLS BLS (Branch if Lower or Same) I Format II I Condition Codes II BLS dd Not affected. I Operation II PC + (PC)+0002+Rel if (C V Z)=l Le. i f (ACCA) ~ (M) I Description ] Causes a branch if either C-bit or Z-bit is "1". When the BHI instruction is executed immediately after either CMP or SUB instruction has been executed, a branch occurs if the minuend represented by the unsigned binary number (Le. ACCA) is less than or equal to the subtrahend represented by unsigned binary number (i.e. M). Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 Byte 2 Byte 3 bytes cycles RELATIVE BLS Rel 23 Rel 2 3 I I I I I I I I I I I Example 0413 B6 10 0415 B1 20 0417 23 16 " * LDA CMP BLS VALl VAL2 ZIP28 VALl <= VAL2 IGNORE SIGN BIT 0419 B7 FF STA WORK VAll ---> WORK (HIGHER) ~HITACHI 47 Conditional Branch BMC BMC (Branch i f interrupt Mask is Clear) I Format II I Condition Codes II BMC dd Not affected. I Operation IJ PC + (PC)+0002+Rel i f (1)=0 I Description ] Tests the I-bit state and causes a branch if I is "0". Addressing Mode and Number of CPU Cycles Addressing Mode · type , Operand Mnemonic ,, Instruction code , Number of Number of CPU I Byte 1 : Byte 2 I Byte 3 bytes cycles , · ReI , I I ,· RELATIVE BMC I ReI 2C I 2 3 , • I ·, I I I I · I I · I I I I , I I I I · I I I , · I I I I I I ,I · · I I I I I I ,I I · I I I Example 0217 2C 07 II BMC MSKOFF INTMSK OFF? 0219 2E 05 BIL MSKOFF INT LINE LOW ? 021B C6 06EO LOA PIA READ DATA 021E B7 FF STA WORK 0220 81 MSKOFF RTS ~HITACHI 48 Conditional Branch BMI BMI (Branch if MInus) I Format II I Condition Codes II BMI dd Not affected. I Operation II PC + (PC)+OOO2+Rel i f (N)=l I Description ] Tests the N-bit state and causes a branch if N is "1". Addressing Mode and Number of CPU Cycles , Number Number Addressing I Operand Instruction code Mnemonic of of CPU Mode type Byte 1 Byte 2 Byte 3 bytes cycles RELATIVE BMI ReI 2B ReI 2 3 , I , I ,I I , I [ Example II 0425 B6 10 LDA VALl 0427 2B 16 BMI ZIP29 VALl < 0 0429 B7 FF * STA WORK VALl ---> WORK (PLUS) ~HITACHI 49 Conditional Branch BMS BMS (Branch if interrupt Mask is Set) I Format IJ I Condition Codes II BMS dd Not affected. I Operation II PC + (pC)+OOO2+Re1 i f (1)=1 I Description II Tests the I-bit state and causes a branch if I is "1". Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand of of CPU Mode type Byte 1 iI Byte 2 : Byte 3 bytes cycles I RELATIVE BMS Re1 2D I Re1 2 3 I , I I : , I I I I I , I , I I I I Example II 0221 20 01 BMS MSKON1 INTMSK ON ? 0223 81 MSKOF1 RTS NO 0224 20 FD MSKON1 BIL MSKOF1 INT LINE LOW ? 0226 C6 06EO LOA PIA DATA 0229 B7 FF STA WORK 022B 81 RTS ~HITACHI 50 Conditional Branch BNE BNE (Branch if Not Equal) I Format IJ I Condition Codes II BNE dd Not affected. I Operation II PC + (pC)+0002+Rel if (Z)=O I Description I Tests the Z-bit state and causes a branch if Z is "0". Following a compare or subtract instruction, BNE will cause a branch if the arguments were different. Addressing Mode and Number of CPU Cycles Addressing ,, Operand Instruction code Number Number Mnemonic I of of CPU Mode I type Byte 1 :I Byte 2 Byte 3 I bytes cycles RELATIVE BNE I I Rel 26 , I Rel 2 3 , ,, I , , ,I : I I , , I , ,, , I ,, I I I , , I I ,I , I I Example II 0200 B6 FF LOA WORK 020F 26 18 BNE ecce WORK NOT = 0 0211 B1 50 eMP RESULT 0213 26 10 BNE DODD WORK NOT = RESULT ~HITACHI 51 Conditional Branch BPL BPL (Branch if PLus) I Format II I Condition Codes II BPL dd Not affected. I Operation II PC +(PC)+0002+Rel if (N)=O I Description II Tests the N-bit state and causes a branch if N is "0". Addressing Mode and Number of CPU Cycles , Number Number Addressing Instruction code Mnemonic:, Operand of of CPU Mode type I Byte I : Byte 2 , Byte 3 I I bytes cycles I RELATIVE BPL I I ReI 2A ,I ReI , I 2 3 , ,, I I , , I ,, ,, I , ,,, ,, ,,, ,, ,,I , I , I ,, ,, ,, , I , I Example II 0215 B6 10 LOA VALl 0217 2A 16 BPL ZIP31 VAL >= 0 * 0219 B7 FF STA WORK VALl ---> WORK (MINUS) ~HITACHI 52 Unconditional Branch BRA BRA (BRanch Always) I Format II I Condition Codes II BRA dd Not affected. I Operation II PC + (PC)+OO02+Rel I Description J Causes an unconditional branch to the address gain from the operation shown above. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte I : Byte 2 Byte 3 I bytes cycles I RELATIVE BRA ReI 20 I ReI 2 3 I I I I : I I I I I I I I I I I Example II 0100 C6 0500 LOA EXVAL5 0103 B7 50 STA RESULT 0105 20 lE BRA ENOOl BRANCH TO ENOOl ALWAYS * 0107 CHECK8 EQU * • HITACHI 53 Conditional Branch BRCLR BRCLR (BRanch if bit n is CLeaR) I Format IJ I Condition Codes II H: Not affected. BRCLR n, DR, dd I: Not affected. N: Not affected. Z: Not affected. I Operation II C: Set i f (Mn)=l; otherwise reset. PC + (PC)+0003+Rel i f (Mn)=O I Description ] / Tests the bit n (n = 0 through 7) of M and causes a branch if the contents of Mn are "0". Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand of of CPU Mode type Byte 1 : Byte 2 Byte 3 I bytes cycles I RELATIVE BRCLR O,M ReI 01 I M ReI 3 5 I RELATIVE BRCLR I,M,Rel 03 I I M ReI 3 5 I RELATIVE BRCLR 2,M,Rel 05 : M ReI 3 5 RELATIVE BRCLR 3,M,Rel 07 I I M ReI 3 5 I RELATIVE BRCLR 4,M,Rel 09 I M ReI 3 5 I RELATIVE BRCLR 5,M,Rel OB I M ReI 3 5 I RELATIVE BRCLR 6,M,Rel OD I M ReI 3 5 I RELATIVE BRCLR 7,M,Rel OF I M ReI 3 5 I Example II 0107 B6 03 LOA CNTRL ** SET CONTROL CODE ** 0109 A4 OF AND #$OF OlOB BA FF ORA WORK 0100 B7 03 STA CNTRL * ** ACTION ** OlaF 09 03 17 BRCLR 4,CNTRL,ENGINE 0112 OF 03 28 BRCLR 7,CNTRL,GASCHK .HITACHI 54 Unconditional Branch BRN BRN (BRanch Never) I Format II I Condition Codes II BRN dd Not affected. I Operation II PC -+- (PC)+OOO2 I Description I It does not cause a branch. BRN, which requires 2-byte and 3 cycle long, is the inverse of BRA. This instruction is sometimes available for debugging program. Addressing Mode and Number of CPU Cycles Addressing ,, Operand Instruction code Number Number Mnemonic I of of CPU Mode I type Byte 1 :I Byte 2 Byte 3 I bytes cycles RELATIVE BRN I I Rel 21 , I Rel 2 3 I I I , I I ,I : I I I ,I I I I I I , I I I I I , I : , ,, I I I I , I , I I I I Example II 0115 EF 04 STX 4.X * 0117 21 FE BRN * ** DELAY ** 0119 21 FE BRN * 011 B 21 FE BRN * 0110 21 FE BRN * ~HITACHI 55 Conditional Branch BRSET BRSET (BRanch if bit n is SET) I Format 11 I Condition Codes II H: Not affected. BRSET n, DR, dd I: Not affected. N: Not affected. Z: Not affected. I Operation II C: Set i f (Mn)=l; otherwise reset. PC + (PC)+OO03+Rel i f (Mn)=l I Description II Tests the bit n (n = o through 7) of M, and causes a branch if the Mn contents are "1". Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand Mode type of of CPU Byte 1 : Byte 2 I Byte 3 bytes cycles I RELATIVE BRSET O,M,Rel 00 I M ReI 3 5 I RELATIVE BRSET 1,M,Rel 02 , I M ReI 3 5 I RELATIVE BRSET 2,M,Rel 04 : M ReI 3 5 I RELATIVE BRSET 3,M ReI 06 I M ReI 3 5 RELATIVE BRSET 4,M,Rel 08 I I M ReI 3 5 I RELATIVE BRSET 5,M,Rel OA I M ReI 3 5 , I RELATIVE BRSET '6,M,Rel OC I M ReI 3 5 I RELATIVE BRSET : 7,M,Rel OE I M ReI 3 5 I Example II OllF B6 03 LDA CNTRL ** SET CONTROL CODE ** 0121 A4 8E AND #$8E 0123 BA FF ORA WORK 0125 B7 03 STA CNTRL * ** ACTION ** 0127 00 03 17 PROC1 BRSET O,CNTRL,OIL 012A OE 03 28 PROC2 BRSET 7,CNTRL,GAS ~HITACHI 56 Bit Control BSET BSET (Bit SET bit n) I Format II Condition Codes II BSET n,DR Not affected. I Operation 1/ Mn -+- 1 I Description I Sets the bit n (n = 0 through 7) of M. All other bits are unaffected. Addressing Mode and Number of CPU Cycles , Instruction code Number Number Addressing Mnemonic : Operand of CPU of Mode , type I Byte 1 ! Byte 2 : Byte 3 bytes cycles DIRECT BSET : O,M 10 M 2 5 DIRECT BSET : I,M 12 M 2 5 DIRECT BSET : 2,M 14 M 2 5 I DIRECT BSET : 3,M 16 M 2 5 , DIRECT BSET : 4,M 18 M 2 5 DIRECT BSET 5,M lA : M 2 5 , DIRECT BSET '6M lC M 2 5 I DIRECT BSET I 7,M lE M 2 5 I Example II 01 00 B6 50 LOA RESULT 0102 2A 04 BPL PLUS * (MINUS) 0104 14 03 BSET 2.CNTRL 0106 16 FF BSET 3,WORK 0108 PLUS EQU * 0108 B6 20 LOA VAL2 ~HITACHI 57 Subroutine Control BSR BSR (Branch to SubRoutine) II II II Format Condition Codes BSR dd Not affected. Operation II PC -+- (PC)+OOO2 Msp -+- (PCL) , SP -+- (SP)-OOOl Msp -+- (PCR) , SP -+- (SP)-OOOl PC -+- (PC)+Re1 I Description I The program counter is increased by "2". The less significant bites (8-bits) of the program counter contents are pushed onto the stack. Then, stackpointer is decreased by "1". The more significant bits (6-bits) of the program counter contents are pushed onto the stack, then stackpointer is decreased by "1". Then a branch occurs to the address specified by the program counter. Addressing Mode and Number of CPU Cycles , Number Number Addressing Instruction code Mnemonic I Operand I of of CPU Mode I type Byte 1 :I Byte 2 I Byte 3 I I bytes cycles I I I RELATIVE BSR I Re1 AD I Re1 I I 2 5 I I I I I I I I I I I 0 I I I I I I I I I I I I I I I I I I I I I I I I Example II 010A A6 38 LOA #$38 ACCA = INTERFACE (0011 1011 ) 010C AD 18 BSR HAND * alOE A6 1E LOA #$lE ACCA = INTERFACE (0001 111 0) 0110 AD 28 BSR FING ~HITACHI 58 Bit Control CLC CLC (CLear Carry) I Format II I Condition Codes II H: Not affected. CLC I: Not affected. N: Not affected. Z: Not affected. I Operation II C: Reset. C -<- 0 I Description I Resets the carry bit C in the condition code register. Addressing Mode and Number of CPU Cycles , Number Number Addressing I Operand Instruction code Mnemonic I of of CPU Mode , type I Byte 1 II Byte 2 Byte 3 bytes cycles ,, , , IMPLIED CLC 98 1 1 ,, I , , , ,I : I , ,, I I ,, , I ,, I , , I I , I :, ,, , I ,, , I ,, , I I I Example II 0100 26 F8 BNE CHK83 0102 B7 50 STA RESULT 0104 98 CLC RETURN COOE SET 'OK' 0105 81 RTS * * ~HITACHI 59 Bit Control CLI CLI (CLear Interrupt mask) I Format 1/ I Condition Codes II CLI H: Not affected. I: Reset. N: Not affected. Z: Not affected. I Operation II C: Not affected. I+-O I Description H Resets the interrupt mask bit in the processor condition code register. This enables the microprocessor to service interrupts that occurred through an interrupt request from peripheral equipment. Addressing Mode and Number of CPU Cycles , Number Number Addressing Instruction code Mnemonic , Operand I Mode I type of of I Byte 1 :, Byte 2 Byte 3 bytes cycles IMPLIED CLI , I 9A I I 1 2 I I I , I I ,I : I I I I I I I I I I I I I I ,I I I I I I I I I Example II OlFA 9B SEI INTERRUPT DISABLE OlFB 9C RSP RESET STACK POINTER OlFC CD 06FO JSR SYSINZ SYSTEM INITIALIZE OlFF 9A CLI INTERRUPT ENABLE ~HITACHI 60 Arithmetic Operation CLR CLR (CLeaR) I Format IJ I Condition Codes II CLR Q H: Not affected. CLR A I: Not affected. CLR X N: Reset. Z: Set. I Operation II C: Not affected. IX +0 or ACCA + 0 or M + 0 I Description I The contents of IX, ACCA or M are replaced with "0". Addressing Mode and Number of CPU Cycles ! , Number Number Addressing I Operand Instruction code Mnemonic I of of CPU Mode I type Byte 1 ,: Byte 2 Byte 3 I bytes cycles ACCUMULATOR CLR I I A 4F , I 1 2 INDEX REG. CLR I I X SF ,, I 1 2 I DIRECT CLR , I M 3F : M 2 S INDEXED u BYTt: I OFFSET CLR I I oX 7F ,I 1 5 INDEXED .L BYTE I ,, OFFSET CLR , Disp,X I 6F D 2 6 ,, I I I , , I I ,I ,, I Example II * ** INITIALIZE ** 0106 3F 07 CLR PNTR 0108 3F 08 CLR PNTR+l OlOA 7F CLR O,X OlOB 4F CLR A ~HITACHI 61 Comparison and Test CMP CMP (CoMPare) I Format IJ I Condition Codes II R: Not affected. CMP P I: Not affected. N: Set if the most significant bit of the result of the subtraction is I Operation II "1"; otherwise reset. Z: Set if the result of the subtractio~ is 0; otherwise reset. C: Set if the absolute value of memory (ACCA)-(M) is greater than that of the accumulator; otherwise reset. I Description II Compares the ACCA contents with M contents, and affects the condition codes that can be referred to by conditional branch instructions. Both operands are unaffected. Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand Mode , of of CPU type Byte 1 : Byte 2 , Byte 3 bytes cycles , ,, I IMMEDIATE CMP IIImm Al Imm 2 2 ,, I I I DIRECT CMP M Bl I M 2 3 ,, I I I EXTENDED CMP M Cl : MH ML 3 4 INDEXED U BYTE , , I 1 OFFSET CMP 0 X Fl I I 3 lNlJllXllD 1 BYTE CMP DisD X El I , I 2 OFFSET , DRD 4 I INDEXED 2 BYTE I OFFSET CMP Disp,X Dl I : DL 3 5 , I I I I 0 , ,,, 0 0 ,, I Example II 0110 E6 07 LOA PNTR,X * 0112 A1 41 CMP #'A 0114 27 1A BEQ SECTA ACCA = 'A' 0116 A1 42 CMP #'B 0118 27 2A BEQ SECTB ACCA = 'B' OllA 20 FO BRA INPUT ~HITACHI 62 Logical Operation COM COM (COMplement) I Format IJ I Condition Codes Ir COM Q H: Not affected. COM A I: Not affected. COM X N: Set if the most significant bit of the result is "1"; otherwise I Operation II cleared. Z: Set if the result is "0"; otherwise reset. IX +- (IX) =$FF-(IX) I C: Set. or ACCA +- (ACCA) = $FF-(ACCA) or M +- (M) = $FF-(M) I Description II Replaces the contents of ACCA, IX or M with its l's complement. Addressing Mode and Number of CPU Cycles Addressing 0 Instruction code Number Number I Operand Mnemonic I of of CPU Mode I type Byte 1 :0 Byte 2 I Byte 3 I I bytes cycles I I I ACCUMULATOR COM I A 43 0 I I 1 2 I I 0 I INDEX REG. COM I X 53 0 0 I 1 2 0 I DIRECT COM I 0 M 33 : M I 2 5 INDEXED 0 BYTE I I I OFFSET COM I 0 O,X 73 0 1 5 INDEXED 1 BYTE 0 0 COM 0 Disp X D I OFFSET 63 0 2 6 I I I 0 I 0 0 I I I I 0 0 I Example II * onc SUBIN EQU * onc 5C INC X OnD E6 07 LOA PNTR,X 011F 43 COM A MODIFY DATA (REVERSE) 0120 81 RTS * ~HITACHI 63 Comparison and Test CPX CPX (ComPare indeX register) I Format II I Condition Codes Ir CPX P R: Not affected. I: Not affected. N: Set i f the most significant bit of the result is "1"; otherwise reset. I Operation II Z: Set i f the result is "0"; otherwise reset. C: Set i f the absolute value of the (IX)-(M) contents of the memory is greater than that of the contents of IX; otherwise reset. I Description II Compares the IX contents with M contents. The condition code can be collated by means of the next conditional branch instruction. Both operands are unaffected. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic: Operand of of CPU Mode I type Byte 1 Byte 2 Byte 3 I bytes cycles I IMMEDIATE CPX I tFImm A3 Imm 2 2 I DIRECT CPX I M B3 M 2 3 I EXTENDED CPX I M C3 MH ML 3 4 INDEXED a BYTE I OFFSRT CPX I I oX F3 1 3 IN~~:D 1 BYTE I OFF T CPX : Disp ,X E3 D 2 4 INDEXED 2 BYTE I OFFSET CPX : Disp X D3 DR DL 3 5 I I I I I Example II 0121 A6 CC LOA #$CC ACCA = INTERFACE TO CR OR LF 0123 BE 07 LOX PNTR 0125 A3 00 CPX #$00 0127 27 18 BEQ CR CARRIAGE RETURN 0129 A3 OA CPX #$OA 0128 27 28 SEQ LF LINE FEED ~HITACHI 64 Arithmetic Operation DAA DAA (Decimal Adjust Accumulator) I Format II I Condition Codes I H: Not affected. DAA I: Not affected. N: Set i f the most significant bit of result is "1"; otherwise reset. I Operation II Z: Set i f the result is "0", other- wise reset. C: Set or reset with the rule under Convert binary Add result which DAA and its previous ABA, into Binary Coded Decimal (BCD). ADD and ADC is converted into BCD. I Description I Bi t Condi tion Lower Early Lower Value added of bit C 4 bits H bit 4 bits to ACCA by Bit condition of bit C Add 00, 06, 60 66 (heradecimal) before DAA (bit (Half (bit DAA execution before DAA to ACCA according execution 4" 7) Carry) 0"3) (hexadecimal) execution to the table shown left. 0 0-9 0 0-9 00 0 0 0-8 0 A-F 06 0 If the BCD Add 0 0-9 1 0-3 06 0 result by ADD and 0 A-F 0 0-9 60 1 ADC instruction 0 9-F 0 A-F 66 1 A-F is in ACCA, bit 0 1 0-3 66 1 C or bit H, DAA 0 0-2 0 0-9 60 1 executes above 0 0-2 0 A-F 66 1 function. 0 0-3 1 0-3 66 1 Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I IMPLIED DAA 8D I 1 2 I , I ·· I I · I I I I I I I I I Example II , , ~HITACHI 65 Arithmetic Operation DEC DEC (DECrement) I Format 1/ I Condition Codes 1/ DEC Q H: Not affected. DEC A I: Not affected. DEC X N: Set if the most significant bit of the result is "1"; otherwise reset. Z: Set if the result is "0"; otherwise I Operation 1/ reset. C: Not affected. IX -+- (IX)-Ol or ACCA -+- (ACCA)-Ol or M +- (M)-Ol I Description 1 Subtracts "1" from the contents of ACCA, IX or M. Nand Z bits are set and reset according to the result of this operation. The C-bit is not affected. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand Mode type of of CPU Byte 1 Byte 2 Byte 3 bytes cycles ACCUMULATOR DEC A 4A 1 2 INDEX REG. DEC X SA 1 2 DIRECT DEC M 3A M 2 5 lN~:~J) U lira; OFF E DEC O,X 7A 1 5 ~~~!:D 1BUI! DEC Disp,X 6A D 2 6 I Example 1/01204A *LOOP23 DEC ** MOVE ** A 012E 2B 07 BMI NEXT 0130 FE LOX O,X * 0131 OF 0100 STX $100,X * 0134 5C INC X * 0135 20 F6 BRA LOOP23 0137 *NEXT EQU * • HITACHI 66 Logical Operation EOR EOR (Exclusive OR) I Format II I Condition Codes II EOR P R: Not affected. I: Not affected. N: Set if the most significant bit of the result is "1"; otherwise reset. I Operation II Z: Set if the result is "0"; otherwise reset. C: Not affected. ACCA -<- (ACCA) ® (M) I Description II Performs the logical EXCLUSIVE OR between the ACCA contents and M contents and stores the result into ACCA. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I IMMEDIATE EOR flImm A8 I Imm 2 2 I DIRECT EOR M B8 I I M 2 3 I EXTENDED EOR M C8 : MH ML 3 4 INDEXED 0 BYTE I OFFSET EOR O,X F8 I 1 3 INDEXEu .l HlT!> I OFFSET EOR Disp,X E8 I D 2 4 INDEXED 2 BYTE I OFFSET EOR Disp,X D8 I DR DL 3 5 I I I I I Example * ** ARRANGE CONTROL CODE ** 0137 B6 03 0139 A8 99 013B B7 03 " LOA EOR STA CNTRL #$99 CNTRL XXXX XXXX 1001 1001 0130 20 14 BRA ACTOl , ~HITACHI 67 Arithmetic Operation INC INC (INCrement) I Format 1/ I Condition Codes 1/ INC Q H: Not affected. INC A I: Not affected. INC X N: Set if the most significant bit of the result is "1"; otherwise reset. I Operation 1/ Z: Set if the result is "0"; otherwise reset. IX +- (IX)+Ol C: Not affected. or ACCA +- (ACCA)+Ol or M+- (M)+Ol I Description ] Adds "1" to the contents of ACCA, IX or M. Nand Z bits are set or reset according to the result of this operation. The C bit is not affected. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 Byte 2 Byte 3 bytes cycles ACCUMULATOR INC A 4C 1 2 INDEX REG. INC X 5C 1 2 DIRECT INC M 3C M 2 5 ~;~::D UBYTE INC oX 7C 1 5 ~~~~~~11 J. JSrr~ INC Disp X 6C D 2 6 I Example II 0100 4C LOOP3 INC A * 0101 Al 64 CMP #100 0103 22 1B BHI EXIT CHECK COUNTER (100 TIMES) 0105 FE LDX O,X 0106 DF 0300 STX $300,X MOVE 0109 5C INC X * 010A 20 F4 BRA LOOP3 $ HITACHI 68 Conditional Branch JMP JMP (JuMP) I Format II I Condition Codes II JMP P Not affected. I Operation II PC +- EA I Description I A jump occurs to the instruction stored at the effective address. The effective address is obtained according to the rules for EXTended, DIRect or INDexed addressing. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I DIRECT JMP M BC I M 2 2 EXTENDED INDEXED 0 BYTE JMP M CC . I I I MH ML 3 3 _OFFSET JMP a,x FC : 1 2 INDEXED 1 BYTE I OFFSET JMP DisD X EC I D 2 3 INDEXED l IIYTJ> I OFFSET JMP Disp,X DC I DR DL 3 4 I I I I I I I Example II OlOC B6 10 LDA VAll OlOE C7 0500 STA EXVAL5 0111 B6 20 LDA VAL2 0113 C7 0600 STA EXVAL6 0116 CC 0333 JMP END90 GO TO END-ROUTINE ~HITACHI 69 Subroutine Control JSR JSR (Jump to SubRoutine) Format II Condition Codes II i JSR P II Not affected. I Operation 1/ Note) PC + (PC)+n Msp + (PCL) , SP + (SP)-OOOl Msp + (PCR) , SP + (SP)-OOOl PC + EA .- I Description II Note) The program counter is increased by "n"in the addressing m0tie, then pushed onto the 2-byte stack. And the stack point is updated. A jump occurs to the specified address. The effective address is obtained according to the rules for EXTended, DIRect or INDexed addressing. Note) n is equal to 1, 2 or 3, according to the number of bytes in the instruction code. Refer to the addressing code and the number of MPU cycles shown below. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mode Mnemonic type Byte 1 :, Byte 2 ,, of of CPU Byte 3 bytes cycles DIRECT JSR M BD ,, M ,,, 2 5 ,,, , EXTENDED JSR M CD MH ML 3 6 INDEXED 0 BYTE , OFFSET JSR O,X FD : 1 5 INDEXED 1 BYTE JSR ,, 2 OFFSET Disp,X ED D 5 INDEXED 'L. BYTE ,, OFFSET JSR Disp X DD DR DL 3 6 ,, I Example II * ** MAIN ROUTINE ** 0119 START EQU * 0119 CD 0407 JSR INTRTN INITIALIZE 011C CD 04E5 JSR KBRTN INPUT FROM KEY-BOARD OllF CD 03AD JSR ANARTN ANALYSE 0122 CD 053C JSR PRCRTN PROCESS 0125 CC 06CB JMP ENDRTN END ~HITACHI 70 Load & Store LDA LDA (LoaD Accumulator) I Format II I Co~dition Codes II R: Not affected. LDAP I: Not affected. N: Set i f the most significant bit of the result is "1"; otherwise reset. I Operation 1/ Z: Set if the result is "0"; other- wise reset. C: Not affected. ACCA -<- (M) I Description I Loads the contents of memory into the accumulator. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing I Operand Mode Mnemonic ,I type Byte 1 : Byte 2 , Byte of of CPU I I I 3 bytes cycles I I I I IMMEDIATE LDA f1Imm A6 I Imm I 2 2 I I , I DIRECT LDA I I M B6 I I M I I 2 3 EXTENDED LDA , M C6 I , I MH I I ML 3 4 I INDEXED 0 BYTE I I OFFSET LDA O,X F6 I I 1 3 INDEXED 1 BYTE I , I OFFSET LDA Disp,X E6 I D I 2 4 INDEXED 1. BYTE I I OFFSET LDA Disp,X D6 I DR : DL 3 5 I I I I I I I I I I I Example II 0128 B6 10 LOA VAll 012A B7 FF STA WORK 012C F6 LOA O,X 0120 B7 50 STA RESULT 012F A6 FF LOA #$FF ~HITACHI 71 Load & Store LDX LDX (LoaD indeX register) I Format 1/ I Condition Codes Ij LDX P H: Not affected. I: Not affected. N: Set i f the most significant bit of IX is "1"; otherwise reset. I Operation II Z: Set i f all the bits of IX of the result are "0"; otherwise reset. C: Not affected. IX +- (M) I Description I Loads the M contents into IX. The condition code is set according to data. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 : Byte 2 Byte 3 I bytes cycles I IMMEDIATE LDX IIImm AE I Imm 2 2 I DIRECT LDX M BE I I M 2 3 I EXTENDED LDX M CE : MH ML 3 4 INDEXED 0 BYTE OFFSET LDX O,X FE I I 1 3 INDEXED 1 BYTE I OFFSET LDX Disp X EE I D 2 4 INDEXED 2 BYTE I OFFSET LDX Disp,X DE I DH DL 3 5 I I I I I Example 1/ 0131 BE 10 LOX VAll 0133 BF FF STX WORK 0135 FE LOX O,X 0136 BF 50 STX RESULT 0138 AE FF LOX #$FF ~HITACHI 72 Shift & Rotation LSL LSL (Logical Shift Left) I Format II I Condition Codes II LSL Q H: Not affected. LSL A I: Not affected. LSL X N: Set if the most significant bit of the result is "1"; otherwise reset. Z: Set if the result is "0"; otherwise I Operation IJ reset. C: Set if the least significant bit of ACCA, IX or memory is "1" before • execution of an instruction; @]~-I b. I I I I I I I 1+- bo 0 otherwise reset. I Description II Shifts the contents of ACCA, IX or M 1-bit to the left. The bit 0 is loaded with "0". The carry bit C is loaded with the most significant bit of ACCA, IX or M. Addressing Mode and Number of Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 : Byte 2 Byte 3 I bytes cycles I ACCUMULATOR LSL A 48 I 1 2 I INDEX REG. LSL X 58 I I 1 2 I DIRECT LSL M 38 : M 2 5 INDEXED U BYTE I OFFSET LSL O,X 78 I 1 5 INDEXED 1 BYTE I OFFSET LSL Disp X 68 I D 2 6 I I I I I I I Example II 013A 38 FF LSL WORK ** t4UL TI PL Y X 8 ** 013C 38 FF LSL WORK 013E 38 FF LSL WORK ~HITACHI 73 Shift & Rotation LSR LSR (Logical Shift Right) I Format II I Condition Codes II LSR Q H: Not affected. LSR A I: Not affected. LSR X N: Reset. Z: Set if the result is "0"; otherwise I Operation II reset. C: Set if the least significant bit of . ACCA, IX, or memory is "1" before execution of an instruction; I I I I I I I 1->0 otherwise reset. 0 ~I b7 bo I Description I Shifts the contents of ACCA, IX or M I-bit to the right. The bit 7 is loaded with "0". The carry bit C is loaded with the least significant bit of ACCA, IX or M. Addressing Mode and Number of CPU Cycles , Number Number Addressing , Operand Instruction code Mnemonic , of of CPU Mode I type Byte 1 :I Byte 2 Byte 3 bytes cycles ACCUMULATOR LSR A 44 I , 1 2 INDEX REG. LSR X 54 ,, I 1 2 ,, I DIRECT LSR M 34 M 2 5 INDEXED a BYTE OFFSET LSR O,X 74 ,I 1 5 INDEXED 1 BYTE ,, OFFSET LSR Disp,X 64 D 2 6 , , I :, , , , ,,, I I ,I ,, I I Example II 0140 34 FF LSR WORK ** DIVIDE / 16 ** 0142 34 FF LSR WORK 0144 34 FF LSR WORK 0146 34 FF LSR WORK $ HITACHI 74 Arithmetic Operation NEG NEG (NEGate) I Format 1/ I Condition Codes 1/ NEG Q H: Not affected. NEG A I: Not affected. NEG X N: Set i f the most significant bit of the result is "1"; otherwise reset. I Operation II Z: Set i f the result is "0"; otherwise reset. IX + (IX)=OO-(IX) C: Set i f a borrow occurs; otherwise reset. Set if the contents of or ACCA + (ACCA)=OO-(ACCA) ACCA, IX or Memory are other than "0 11 • or M+ (M)=OO-(M) I Description II Replaces the contents of ACCA, IX or M with its two's complement, and stores ACCA or IX contents into M contents. Note that $80 (-128) is unaffected. Addressing Mode and Number of CPU Cycles , Number Number Addressing I Operand Instruction code Mnemonic I of of CPU Mode I type Byte 1 :I Byte 2 Byte 3 I I bytes cycles ACCUMULATOR NEG I I A 40 , I 1 2 INDEX REG. NEG I I X 50 I ,, 1 2 , DIRECT NEG ,I M 30 : M 2 5 INDEXED 0 BYTE NEG ,, I I , 5 OFFSET 0 X 70 1 INDEXED 1 BYTE I ,, OFFSET NEG : Disp ,X 60 D 2 6 ,,I I I , , I I , I I I I Example II * CHECK RANGE (RELATIVE ADDRESSING) 0148 A1 81 CMP #129 CHECK RANGE 014A 24 44 BCC BERROR *OFFSET BRANCH ERROR 014C 40 NEG A 0140 20 14 BRA SET * ~HITACHI 75 Unconditional Branch NOP NOP (No OPeration) I Format II I Condition Codes II NOP Not affected. I Operation II I Description IJ This is a single-byte instruction which only causes the program counter to be increased. Other registers are unaffected. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing " I Operand Mnemonic I of of CPU Mode I type Byte 1 :, Byte 2 I Byte 3 I I I bytes cycles I IMPLIED NOP I I 9D , I I I 1 1 I ,, I I , , I ,, I ,I , I I , I ,I I I I I , I , I I , I I I I I I , I : , ,, I I I , , I I I I I I Example II 014F 9D NOP ** DELAY ** 0150 9D NOP 0151 9D NOP 0152 9D NOP 0153 9D NOP 0154 90 NOP ~HITACHI 76 Logical Operation ORA ORA (inclusive OR) I Format II I Condition Codes IJ R: Not affected. ORA I: Not affected. N: Set i f the most significant bit of the result is "I"; otherwise reset. Z: Set if all the bits of the result I Operation IJ are "0"; otherwise reset. C: Not affected. ACCA + (ACCA)v(M) I Description II Performs logical OR between ACCA contents and M contents, and stores the result into ACCA. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic :I Operand of of CPU Mode I type Byte 1 :I Byte 2 Byte 3 I bytes cycles IMMEDIATE ORA I I ffImm AA , I Imm 2 2 ,, I I DIRECT ORA I M BA M 2 3 ,, EXTENDED ORA ,I M CA , MH ML 3 4 iNDEXED U BYTE OFFSET ORA O,X FA , I 1 3 INDEXED 1. llYTll OFFSET ORA Disp X EA , I D 2 4 INDEXED 2 BYTE I OFFSET ORA Disp,X DA I DR DL 3 5 , I ,, I Example 0155 25 06 II BCS SKIP * 0157 ADCN EQU * ** ADDITION CONTROL BIT ** 0157 A6 14 LOA #$14 0001 0100 0159 BA 03 ORA CNTRL 015B B7 03 STA CNTRL 0150 SKIP EQU * ~HITACHI 77 Shift & Rotation ROL ROL (ROtate Left) I Format II I Condition Codes Ir ROL Q H: Not affected. ROL A I: Not affected. ROL X N: Set if the most significant bit of the result is "1"; otherwise reset. Z: Set of all the bits of the result I Operation II are "0"; otherwise reset. C: Set if the ACCA, IX, or the most significant bit of the memory is • "1", before execution of an G~I b. I I I I I I I I~@] bo instruction; otherwise reset. I Description II Shifts the contents of ACCA, IX or M 1-bit to the left. The bit 0 is loaded with the carry bit C, while the carry bit C is loaded with the most significant bit of ACCA, IX or M. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 I: Byte 2 Byte 3 bytes ,_ cycles I ACCUMULATOR ROL A 49 I 1 2 I INDEX REG. ROL X 59 , I 1 2 I DIRECT ROL M 39 : M 2 5 INDEXED U BYTE OFFSET ROL a,x 79 I I 1 5 INDEXED 1 BYTE I OFFSET ROL Disp X 69 I D 2 6 I I I I I I I Example 110150 98 * CLC REPEAT EQU ** REPEAT ACTION FOLLOWING CNTRL ** 015E * 015E 39 03 ROL CN1RL 0160 25 05 BCS ACTION ACTION & REPEAT OR ESCAPE 0162 90 NOP * 0163 90 NOP ** OELAY ** 0164 90 NOP * 0165 20 F7 BRA REPEAT ~HITACHI 78 Shift & Rotation ROR ROR (ROtate Right) I Format II I Condition Codes II ROR Q H: Not affected. ROR A I: Not affected. ROR X N: Set if the most significant bit of the result is "1"; otherwise reset. I Operation Ij Z: Set if all the bits of the result are "0"; otherwise reset. C: Set if the ACCA, IX, or the least • significant bit of Memory is "1"; ~1 I I I I I I I I-@] otherwise reset. b1 bo I Description I Shifts the contents of ACCA, IX or M one bit to the right. The bit 7 is loaded with the carry bit C, while the bit a is loaded with the carry bit C. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I ACCUMULATOR ROR A 46 I 1 2 I INDEX REG. ROR X 56 I I 1 2 I DIRECT ROR M 36 : M 2 5 INDEXED u BYTE OFESET ROR O,X 76 I I 1 5 INDEXED 1 BYTE I OFFSET ROR Disp.X 66 I D 2 6 I I I I I I I Example II * ** REPEAT ACTION FOLLOWING CNTRL ** 0167 98 CLC 0168 REPTl EQU * 0168 36 03 ROR CNTRL 016A 25 05 BCS ACTN1 ACTION & REPEAT OR ESCAPE 0l6C 90 NOP * 0160 90 NOP ** Oi:LAY ** 016E 90 NOP * ( 016F 20 F7 BRA REPTl $ HITACHI 79 Stack Pointer Operation RSP RSP (Reset Stack Pointer) I Format IJ I Condition Codes Ir RSP Not affected. I Operation II SP +- $FF I Description II Resets the stack pointer to the top ($FF) of the stack. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic: Operand of of CPU Mode Itype Byte 1 :I Byte 2 I Byte 3 I I bytes cycles I I I IMPLIED RSP I 9C I I I 1 2 I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I : I I I I I I I I I I I I I I I Example 1\ 0200 9B SEI INTERRUPT DISABLE 0201 9C RSP RESET STACK POINTER 0202 CD 06FO JSR SYSINZ SYSTEM INITIALIZE 0205 9A CLI INTERRUPT ENABLE ~HITACHI 80 Interrupt Control RTI RTI (ReTurn from Interrupt) I Format II I Condition Codes II RTI Recovers the state saved onto the stack. I Operation II SP -+- (SP)+OOOl, CCR -+- (SP) SP -+- (SP)+OOOl, ACCA -+- (SP) SP -+- (SP)+OOOl, IX -+- (SP) SP -+- (SP)+OOOl, PCR -+- (SP) SP -+- (SP)+OOOl, PCL -+- (SP) I Description I Sets the stack contents indicated by SP to CCR, ACCA, IX, PCR, or PCL increasing SP by "1". Note that I = o when the interrupt mask bit of CCR saved onto the stack is "0". Addressing Mode and Number of CPU Cycles Addressing Operand Instruction code Number Number Mnemonic of of CPU Mode type Byte 1 I: Byte 2 Byte 3 bytes cycles I IMPLIED RTI 80 I 1 8 I I I I : I I I I I I I I I I I Example II 020C CD 0345 JSR KEYSCN KEY INPUT 020F B7 10 STA INKEY STORE KEY CODE 0211 CO 0400 JSR EXSWIN INPUT EXTERNAL SW 0214 B7 11 STA INSW STORE SW CONDITION 0216 80 RTI RETURN TO INTERRUPT $ HITACHI 81 Subroutine Control RTS RTS (ReTurn from Subroutine) I Format II I Condition Codes II RTS Not affected. I Operation II SP +- (SP)+OOOl, PCR +- (SP) SP +- {SP)+OOOl, PCL +- (SP) I Description II Increases SP by "1" and sets the address contents indicated by SP to more significant bits (6-bits) of PC. Increases SP with "1" again, and sets the address contents specified by SP to less significant bits (8-bits) of PC. Addressing Mode and Number of CPU Cycles Addressing ,, Instruction code Number Number Mnemonic , Operand of of CPU Mode I type Byte 1 ,: Byte 2 I Byte 3 I I bytes cycles I IMPLIED RTS I I 81 , I I 1 5 , ,, I I I , ,, ,, 0 I , I , I , , I , I I I , I I , , I I , I ,, I Example II 0171 B7 FF STA WORK 0173 C6 0500 LOA EXVALS 0176 B7 50 STA RESULT 0178 98 CLC RETURN CODE SET : OK 0179 81 RTS * * ~HITACHI 82 Arithmetic Operation SBC SBC (SuBtract with Carry) I Format II I Condition Codes II H: Not affected. SBC P I: Not affected. N: Set if the most significant bit of the result is "1"; otherwise reset. I Operation II Z: Set i f the result is "0"; otherwise reset. C: Set if the absolute value of the contents of memory plus the carry ACCA + (ACCA)-(M)-(C) bit C is greater than the absolute value of the contents of ACCA; otherwise reset. I Description IJ Subtracts the contents of M and the carry bit C from that of ACCA, and stores the result into ACCA. Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand of of CPU Mode type Byte 1 :I Byte 2 I Byte 3 I bytes cycles I I IMMEDIATE SBC IIImm A2 I Imm I 2 2 I DIRECT SBC M B2 I I M 2 3 I EXTENDED SBC M C2 : MH ML 3 4 INDEXED U BYTE OFFSET SBC O,X F2 I I 1 3 INDEXED .L BYTE I OFFSET SBC Disp.X E2 I D 2 4 INDEXED L BYTE OFFSET SBC Disp,X D2 I I DH DL 3 5 I I I I I Example II * * (VAll, VALl+l)-(EXVAL5, EXVAL5+1) =(EXVAL5, EXVAL5+1) * 017A B6 11 LDA 'VALl+l * 017C CO 0501 SUB EXVAL5+1 * 017F C7 0501 STA EXVAL5+1 * 0182 B6 10 LDA VAll * 0184 C2 0500 SBC EXVAL5 * 0187 C7 0500 STA EXVAL5 * ~HITACHI 83 ---~--- ------------- Bit Control SEC SEC (SEt Carry) I Format 1/ I Condition Codes 1/ H: Not affected. SEC I: Not affected. N: Not affected. Z: Not affected. C: Set. I Operation 1/ C bit +- 1 I Description II Sets the carry bit C in the condition code register. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic: Operand of of CPU Mode ,I type Byte 1 Byte 2 Byte 3 bytes cycles , IMPLIED SEC " 99 1 1 , I ,,, I , I ,, I I I I I I I I Example II 018A 27 F8 BEQ CHK84 018C B7 50 STA RESULT 018E 99 SEC RETURN CODE SET : NG 018F 81 RTS * * $HITACHI 84 Bit Control SEI SEI (SEt Interrupt mask) I Format II I Condition Codes II SEI H: Not affected. I: Set. N: Not affected. Z: Not affected. I Operation II C: Not affected. I bit + 1 I Description I Sets the interrupt mask bit I in the condition code register. If this bit is set, interrupt from peripheral equipment is disabled until the interrupt mask bit is cleared. Addressing Mode and Number of CPU Cycles Addressing Mode ·· Mnemonic • Operand I type Instruction code I Number of Number of CPU I Byte 1 : Byte 2 I Byte 3 bytes cycles IMPLIED SEI I I 9B · I I I 1 2 I ·I I I ·,, I I · · I I I I · ·, I ···· I , I I · I I · ·· I Example II 0206 9B SEI INTERRUPT DISABLE 0207 9C RSP RESET STACK POINTER 0208 CD 06FO JSR SYSINZ SYSTEM INITIALIZE 020B 9A CLI INTERRUPT ENABLE ~HITACHI 85 Load & Store STA STA (STore Accumulator) I Format II I Condition Codes II R: Not affected. STA P I: Not affected. N: Set if the most significant bit of ACCA is "1"; otherwise reset. I Operation II Z: Set if the contents of ACCA are "0"; otherwise reset. C: Not affected. M +- (ACCA) I Description IJ Stores the ACCA contents into M. The ACCA contents are unaffected. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing I Operand Mnemonic II of of CPU Mode type Byte 1 :I Byte 2 I Byte 3 I I bytes cycles I 1 I DIRECT STA 1 M B7 I M I I 2 3 I I EXTENDED STA M C7 I I MH 1 I ML 3 4 INDEXED U BYTE I I OFFSET STA oX F7 , I 1 1 4 INDEXED .l BYTE I I 1 OFFSET STA DisD X E7 I D I 2 4 iNDEXED L JUTI' I I OFFSET STA Disp X D7 I DR 1 DL 3 5 I I I I I I I I I I I I I I I I I I I I Example II 0190 B6 10 LDA VAll 0192 B7 FF STA WORK 0194 B6 50 LDA RESULT 0196 F7 STA O,X 0197 A6 FF LDA #$FF 0199 D7 0500 STA EXVAL5,X ~HITACHI 86 Power Control STOP STOP (STOP) I Format U I Condition Codes II STOP Not affected. I Operation II I Description I Enters into the STOP mode by STOP instruction (For details, refer to STOP MODE in "2.9. Low Power Consumption Mode".) Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 I Byte 3 I bytes cycles I I IMPLIED STOP 8E I I 1 4 I I 0 I ! I 0 I I I I I I I I I I I Example " ~HITACHI 87 Load & Store STX STX (STore indeX register) I Format Ij I Condition Codes II R: Not affected. STX P I: Not affected. N: Set if the most significant bit of IX is "1"; otherwise reset. I Operation II Z: Set if the contents of IX are "0"; otherwise reset. C: Not affected. M To (IX) I Description II Stores the IX contents into memory. IX contents are unaffected. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 I Byte 3 I bytes cycles I I DIRECT STX M BF I M I I 2 3 I I EXTENDED STX M CF , I MH I I ML 3 4 INDEXED u ByTE I I OFFSET STX O,X FF : I 1 4 INDEXED 1 BYTE I OFF~F.T STX Disp,X EF I D 2 4 INDEXED 'L. llYl'1l I OFFSET STX Disp X DF I DR DL 3 5 I I I I I I I Example II 019C BE 10 LOX VAll 019E BF FF STX WORK 01AO BE 50 LOX RESULT OlA2 FF STX O,X 01A3 AE FF LOX #$FF 01A5 OF 0500 STX EXVAL5,X ~HITACHI 88 Arithmetic Operation SUB SUB (SUBtract) I Format II I Condition Codes II R: Not affected: SUB P I: Not affected. N: Set if the most significant bit of the result is "1"; otherwise reset. I Operation II Z: Set if the contents of the result are "0"; otherwise reset. C: Set if the absolute value of the ACCA + (ACCA)-(M) contents of memory is greater than the absolute value of the contents of ACCA; otherwise reset. I Description I Subtracts M contents from ACCA contents, and stores the result into ACCA. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I IMMEDIATE SUB IIImm AO I Imm 2 2 I DIRECT SUB M BO · MI I 2 3 EXTENDED INDEXED U BYTE OFFSET SUB SUB M O,X CO FO · I I MH ML 3 1 4 3 INDEXED .L BYTE I OFFSET SUB Disp,X EO I D 2 4 INDEXED 2 BYTE I OFFSET SUB Disp,X DO I DR DL 3 5 I I I I I Example II OlAS B6 10 LOA VAll (VAL1)-(WORK)=(RESULT) OlAA BO FF SUB WORK OlAe B7 50 STA RESULT $ HITACHI 89 Interrupt Control SWI SWI (SoftWare Interrupt) I Format II I Condition Codes II H: Not affected. SWI I: Set. N: Not affected. Z: Not affected. I Operation II PC +- (PC)+OOOI C: Not affected. Map+- (PCL) , SP +- (SP)-OOOI Msp +- (PCH) , SP +- (SP)-OOOI Msp +- (IX), SP +- (SP)-OOOI Map+- (ACCA), SP +- (SP)-OOOI Msp +- (CCR) , SP +- (SP)-OOOI I bit +- 1 PC +- (SWI interrUPt vector address) I Description II All the registers other than the stack pointer (SP) are pushed onto the stack. The interrupt mask bit is then set. Performs vectoring to the address indicated by the contents of the SWI interrupt vector address. Addressing Mode and Number of Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 t Byte 2 Byte 3 bytes cycles IMPLIED SWI 83 1 10 t I I I I I [ Example II OlOC A6 FF LDA #$FF * 01DE 87 36 STA TIMER+l * TIMER COUNTER SET OlEO A6 3F LDA #$3F * 01E2 87 35 STA TIMER * 01E4 A6 03 LDA #3 TIr4ER CODE SET 01E6 83 SWI MONITOR SERVICE CALL $ HITACHI 90 Transfer TAX TAX (Transfer Accumulator to indeX register) I Format II I Condition Codes II TAX Not affected. I Operation II IX +- (ACCA) I Description I Transfers the ACCA contents to IX. The ACCA contents are unaffected. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing I Operand Mnemonic I of of CPU Mode I type Byte 1 i Byte 2 Byte 3 I I bytes cycles I I IMPLIED TAX I 97 I 1 2 I I I I I I I I : I I I I I I I I I I I I I I I I I I I , I I I I I I I I Example OlAE 97 II TAX SAVE ACCUMULATOR OlAF A6 04 LDA #4 * OlBl BB 50 ADD RESULT ** ADD (RESULT+4) 01B3 B7 50 STA RESULT * 01B5 9F TXA REVIVE ACCUMULATOR ~HITACHI 91 Comparison & Test TST TST (TeST) I Format IJ I Condition Codes If TST Q H: Not affected. TST A I: Not affected. TST X N: Set if the most significant bit of ACCA, IX or M is "1"; otherwise I Operation II reset. Z: Set if the contents of ACCA, IX or M are "0"; otherwise reset. (IX) - 00 C: Not affected. or (ACCA) - 00 or (M) - 00 I Description I Sets Nand Z bits of the condition code register according to the contents of ACCA, IX or M. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing I Operand Mnemonic I I of of CPU Mode type Byte 1 : Byte 2 Byte 3 I I bytes cycles I I ACCUMULATOR TST I A 4D I 1 2 I INDEX REG. TST I I X 5D I I 1 2 I DIRECT TST I I M 3D , I M 2 4 INDEXED U BYTE I I OFFSET TST I I O,X 7D I 1 4 INDEXED .L BYTE I I OFFSET TST : Disp.X 6D I D 2 5 I I I I I I I I I I I I I I Example II OlBE 3D 03 TST CNTRL OlCO 27 18 BEQ INITOO CNTRL=$OO * 01C2 3D FF TST WORK 01C4 2B 28 BMI MINSOO WORK=(lXXX XXXX) * ~HITACHI 92 Transfer TXA TXA (Transfer indeX register to Accumulator) I Format II I Condition Codes II TXA Not affected. I Operation II ACCA +- (IX) I Description ] Transfers the IX contents to ACCA. IX contents are unaffected. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 I Byte 3 I bytes cycles I I IMPLIED TXA 9F I I I 1 2 I I , I I I I : I I I I I I I I I I I Example " 01B6 97 01B7 A6 04 01B9 BB 50 01BB B7 50 TAX LOA ADD STA #4 RESULT RESULT SAVE ACCUMULATOR * ** ADD (RESULT+4) *REVIVE ACCUMULATOR 01BO 9F TXA ~HITACHI 93 Power Control WAIT WAIT (WAIT) I Format II I Condition Codes Ij WAIT Not affected. I Operation II I Description I Enters into WAIT mode by WAIT instruction (Refer to WAIT MODE in "2.9 Low Power Consumption Mode" for details). Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand Mode type I of of CPU Byte 1 :I Byte 2 I Byte 3 bytes cycles I IMPLIED WAIT 8F , I I I 1 4 ,,I I I ,, I I , I , I , ,, I ,, I ,, , I , ,, ,, ,, ,,, I I Example II ~HITACHI 94 1.7 BIL/BIH Instruction Precaution (1) Execute Instruction after the INT voltage level has stabilized above V,H of below V,L • (2) INT voltage level need to be stabilized while BIL/BIH Instruction Execution. There may be a malfunction by glitch on control signal if BIL/BIH Instruction Execution has exercised in unstabilized INT signal level. INT VIH A T __________ __v_~ -:-~~t.~:~------------~~~\:--- --< BIL/BIH >--0--< BIL/BIH) 0 Avoid BIL/BIH Insruction Excution. ~HITACHI 95 ~HITACHI 96 HD630S/HD63LOS SERIES HANDBOOK Section Three • HD630S UO • HD630S VO • HD6370S VO User's Manual ~HITACHI 97 ~HITACHI 98 Section 3 HD6305UO, HD6305VO, HD63705VO User's Manual Table of Contents Page 1. OVERViEW ................................................... . 101 1.1 Features of HD6305UO, HD6305VO, HD63705VO .................. . 101 1.2 Block Diagram .............................................. . 102 1.3 Terminal Functions .........................•................. 103 2. INTERNAL HARDWARE AND OPERATIONS ........................ . 107 2.1 Memory ................................................... . 107 2.2 Registers .................................................. . 108 2.3 Timer ..................................................... . 110 2.4 Serial Communication Interface (SCI) ........................... . 113 2.5 Reset ..................................................... . 118 2.6 Internal Oscillator Options ..................................... . 119 2.7 Interrupts .................................................. . 120 2.8 Input/Output. ............................................... . 124 2.9 Low Power Consumption Mode ................................. . 126 2.10 EPROM Mode (HD63705VO) ................................... . 132 3. APPLICATION AND PRECAUTIONS ............................... . 137 3.1 Watch-Dog Timer ............................................ . 137 3.2 Auto Reset Circuit ........................................... . 139 3.3 Manual Reset Circuit ......................................... . 140 3.4 AID Converter Circuit (1) ... High Speed ......................... . 141 3.5 AID Converter Circuit (2) ... Low Speed .......................... . 143 3.6 Precaution; - Board Design of Oscillation Circuit ................... . 144 3.7 Precaution; - Sending/Receiving Program of Serial Data ............ . 145 3.8 Precaution; - WAIT/STOP Instructions Program .................... . 145 4. PIN ARRANGEMENT AND DIMENSIONAL OUTLINE ................. . 146 5. ELECTRICAL CHARACTERISTICS ................................ . 149 5.1 Electrical Characteristics for HD6305UO, HD6305VO ............... . 149 5.2 Electrical Characteristics for HD63705VO ........................ . 152 ~HITACHI 99 ----- ~-,--------- 6. PROGRAMMABLE ROM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 6.1 ProgrammingNerification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 6.2 Erasure (MCU with a window). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 6.3 Application Notes ............................................ 160 7. ROM CODE ORDER METHOD..................................... 164 APPENDIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 I. Design Prodcedures and Support Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 SINGLE CHIP MICROCOMPUTER ROM ORDERING PROCEDURE ......... 166 HD6305UO, HD6305VO ORDERING SPECIFICATIONS. . . . . . . . . . . . . . . . . . . . . 168 ~HITACHI 100 1. OVERVIEW 1.1 Features of HD6305UO, HD6305VO, HD63705VO Hitachi's HD6305UO, HD6305VO are CMOS 8-bit single-chip micro- computers containing CPU, RAM, I/O on a single chip. Features of this series are as follows; (1) Powerful Bit Manipulation Instructions Dew to upward compatibility with HD6805 family instruction set, powerful bit manipulation instructions are provided so that bit set, I bit reset, bit test, and branch would be executed with a single instruction. These bit manipulation instructions are available to I/O and internal RAM as well. (2) Low Power Consumption To exploit the CMOS process technology fully, three low power consumption modes; STOP, WAIT and STANDBY; are incorporated. Table 1-1 Features of HD6305UO, HD6305VO and HD63705VO Type No. HD6305UO HD6305VO HD63705VO Package DP-40,FP-54,CP-44 DP-40,FP-54,CP-44 DC-40 ROM (k byte) 2 4 4 Memory RAM (byte) 128 192 192 I/O Port 31 31 31 external 2 2 2 soft 1 1 1 Interrupt timer 2 2 2 serial 1 1 1 8-bit Timer 1 1 1 Timer 15-bit Timer 1 1 1 SCI 1 (clock synchronous) 1 (clock synchronous) 1 lMHz HD6305UO HD6305VO HD63705VO Speed Version 1.5MHz HD63A05UO HD63A05VO HD637AOSVO (SV ± 10%) 2MHz HD63B05UO HD63B05VO HD637BOSVO Operating Voltage 0.1 '" 0.5 MHz 3 '" 6.0V 3 '" 6.0V 4.5 '" S.SV ~HITACHI 101 Table 1-2 Feature of EPROM ON CHIP TYPE FAMILY Type HD63705VOC DC-40, Package (with window) Equivalent Device HD6305UO, HD6305VO r Process CMOS Erasure possible HD63705VO is fully compatible with HD6305VO. It is possible to program with EPROM programmers that are commercially available (e.g 27256 type) since HD63705VO contains 4k bytes of EPROM. And this makes it possible to use them for debugging as well as evaluating the program. 1.2 Block Diagram A block diagram of HD6305UO, HD6305VO is given in Fig. 1-1, HD63705V in Fig. 1-2, respectively. XTAL EXTAL RES NUM iiiiT SfBv" • TIMER CPU D./INT, Index Port A Control Ds/CK Port 0 B Register X D./Rx I/O I/O Terminals Condition Code D,/Tx Terminals 0, RegisterCCR 0, CPU D. Stack Pointer SP . Program Counter ALU Serial Port B "High"PCH Control K~~~_R;eg:ist:e~ri Serial I/O Program Terminals Counter Data "Low" PCL ~~~~ Registar Register Port C I/O Terminals "HD8306UO ROM 2048xB, RAM 128xB "HD8301iVO ROM 4OII8xB, RAM 192x8 Fig, 1-1 HD6305UO, HD6305VO Block Diagram • HITACHI 102 r-=EPROMM_ ~ rMCUrMo_de_.L-'-,--:;::-=-, Vpp/TIMER 7 Pre..810, 8 6::;':;~, I/L ..... I Time, Control IV-V Port A EO./A EO,/A , EO,/A, . 8 Accumulator Index A CPU . .2 0 .liNT1 EA, EO,/A) ,8 Regi ..., X Control ~r-D. ICK PortO 1/0Pini H 0; .- ~8./Rx EO .. /A. EO,/A, Condition Code ~ ei'r I:.i 011' ,IT. eE t/OPins EO. lA, EO.,/A7 5 Reg;"·'CCA CPU ~C[ f::F' 1-8' I I 0.0: 1m Stack Port B B. B, B, . 6 6 Pointer Sp ~':~.:= "High"PCH ALU Serial B, Control I/0Pini Program EAutB.. Counter ",A.~__""""l-_R_eg_i"_._'-I ~;:I EA1O/B, B. 8 "Low"PCL \r--v ~:~~~ Register EA,/S, Register IL porte 1/0Pini EA./C, EA,/C, EA,/C, EA,/C J EA./C. EA./C. EA./C. EA,/C, I 11 4096 • 8 L-_E_P_R_O_M__~ I I II I 192 • 8 ~___R_A_M__~ I Fig. 1-2 HD6370SVO Block Diagram Precaution for using the MCU in the ceramic package with a window (1) The data stored in EPROM may be lost or the MCU may be malfunc- tioned by photocurrent if the MCU is exposed to strong light like a fluorescent lamp or the sunlight. Therefore, it is recommended to cover the window with an opaque label. (2) Users should be particularly careful of static charge on the window, as it affects the MCU function to malfunction the LSI. The charge will be caused by rubbing the window with plastics or dry cloths, or touching a charged body on it. The opaque label that we recommended in (1) will be effective to distribute the charge evenly, if it is conductive. 1.3 Terminal Functions (1) Terminal functions of HD630SUO and HD630SVO are described below. • VCC' Vss Terminals for applying voltage. VCC provides S.OV±lO% power supply, while VSS is grounded. • INT, lNT2; INPUT, INPUT/OUTPUT Terminals for external interrupt input to HD630SUO and HD630SVO. Refer to "2.7 Interrupt" for details. INT2 is multiplexed with the D6' ~HITACHI 103 • XTAL, EXTAL Input terminals to the internal clock circuit. Connect a crystal oscillator (AT cut, 2.0 "'S.OMHz) or ceramic filter to these terminals. Refer to "2.6 Internal Oscillator Options" for details. • TIMER; INPUT An external input terminal for contro1ing event counter. Refer to "2.3 Timer" for details. • Irn'S; INPUT Resets the MCU. Refer t6 "2. S Reset" for details. • NUM NUM is not for user application. It can be used by connect- ing to VSS' • PORT A, B, C, D; INPUT/OUTPUT 31 terminals consist of three S-bit I/O ports (A, B, C) and one 7-bit I/O port (D). Each bit of these terminals function as input or output terminals by programming the Data Direction Register. Refer to "2.S Input/Output" for details. D6 of port D is multiplexed with INT2. \fuen D6 functions as a port, set MR6 in Miscellaneous Register to "I" in order to mask INT2 interrupt. • STBY; INPUT A terminal for permitting the MCU to enter into the Standby Mode. When STBY goes to "Low" level, the oscillation stops and the MCU enters into the Reset Mode. Refer to "Standby Mode" in "2.9 Low Power Consumption Mode" for details. • CK (DS); INPUT/OUTPUT Terminal to transmit or receive SCI clock for serial data transfer. Refer to "2.4 Serial Communication Interface" for details. • Tx (D3); INPUT/OUTPUT This terminal used to transmit serial data. Refer to "2.4 Serial Communication Interface" for details. ~HITACHI 104 • Rx (D4); INPUT/OUTPUT This terminal is used to receive serial data. Refer to "2.4 Serial Communication Interface" for details. (2) The followings describs HD63705VO MCU input and output terminals. • VCC' Vss These are the power supply inputs. VCC 5.0V ± 10%, VSS OV (ground) • • l1f.F/EA9 , INT2; INPUT, INPUT/OUTPUT The MCU receives an external interrupt through these terminals. For details, refer to "2.7 Interrupts". INT2 is mUltiplexed with Port D6' In the EPROM mode, INT is used as input of EA9. • XTAL, EXTAL These pins are inputs of the internal oscillator circuit. Connect crystal (AT cut, 2.0 ",S.O UHz) or ceramic resonator to them. Refer to "2.6 Internal Oscillator Options" for using these inputs. • TIMER/Vpp; INPUT This is an external input to control the internal timer circuit. Refer to "2.3 Timer" for details. In the EPROM mode, this terminal is used when programming EPROM. The programming voltage Vpp is applied to this terminal. When the voltage of l2.5V ± 0.3V is applied to this terminal and CE and OE are set "Low" and "High" respectively, datas are written into EPROM through Port A (EOO '" E07)' EPROM addresses are input through the Port C (EAo '" EA7)' Port B (EAs, EAro '" EAll) and INT (EA9)' • m; INPUT This is used to reset the MCU. Refer to "2.5 Reset" for details. • NUM This is not for user application. Connect this pin to the VSS in the MCU mode and to the Vce in the EPROM mode. ~HITACHI 105 • PORT A, B, C, D; INPUT/OUTPUT These 31 terminals consist of three 8-bit I/O ports (A, B, C) and a 7-bit I/O port (D). Each bit of these pins can be programmed as an input or output by programming the Data Direction Register. D6 is multiplexed with the INT2' When using the D6 as a port, set the INT2 interrupt mask bit in the miscellaneous register to "1" to prevent the INT2 interrupt. Refer to "2.8 Input/Output" for details. • STBY; INPUT This is used to put the MCU into the standby mode. Setting this pin to "low" level stops the internal oscillator and resets the MCU internal state. Refer to "Standby Mode" in "2.9 Low Power Consumption Mode" for details. The followings are input/output pins for serial communication interface (SCI). These are multiplexed with 03, 04, or 0S, Refer to "2.4 Serial Communication Interface" for details. • CK (05); INPUT/OUTPUT This is used to input or output clocks when receiving or transmitting serial data. • Rx (04); INPUT/OUTPUT This is used to receive serial data. • Tx (03); INPUT/OUTPUT This is used to transmit serial data • • HITACHI 106 2. INTERNAL HARDWARE AND OPERATIONS 2.1 Memory Fig. 2-1 shows the memory map of HD630SUO, HD630SVO and HD6370SVO. During the processing of the interrupt, the register contents are pushed onto the stack in the order shown in Fig. 2-2. The stack pointer decrements. The low order byte (PCL) of the program counter is stacked first and the high order byte (PCR) of the program, the index register (X), the accumulator (A) and the condition code register (CCR) are stacked in that order. For subroutine calls, program counter (PCR, PCL) contents are pushed onto the stack. a soooo 0 POR A 500 0 1'li0000 P SOO 0 $0000 PORl A SOO I/O Ports 1 I '0 Ports 1 10 Ports 1 PORT B $01 PORT B SOl PORT B 501 Timer 2 Timer 2 PORT C Timer 2 PORTC 502 PORT C 502 502 SCI SCI SCI 3 12 7 S007F 3 PORT 0 503 63 S003F 3 PORT 0 S03 63 S003F PORT 0 S03 128 4 PORT A ODR 504 64 ~0040 4 PORT A DDR 504 64 ~0040 4 PORT A DDR S04 RAM ~0080 RAM RAM I~OFF 5 PORT BOOR 505 5 PORT BOOR $06 '~OFF 5 PORT BOOR 505 ~FF (1288ytes) (192Bytes) (192Byt••) 6 PORT C ODR 506 6 PORT C ODR S06 6 PORT C DDR S06 Stack 7 PORT DOOR S07 Stack 7 PORT DOOR 507 Stack 7 PORT DOOR S07 25 5 25 5 25 5 25 8 S 100 8 Timer Data Reg SOB 25 6 $ ,00 8 Imer Date • S06 25 6 8 TUMr .t. "-II $08 S ,00 6143 Not Usad \ S17FF 9 T.mer CTRL Reg 509 10 MIse Hag SOA 409 6 Not Used SOFFF 9 TilMr CTRL Reg $09 10 MIse Heg lOA Not Used 50FFF 9 Timer CTRL. .... S09 10 MIse .g SOA 409 6 614 4 $1800 409 8 $1000 409 6 51000 Intern.1 Intern.1 ROM Not Used EPROM Not Used EPROM Not Used (2.048Byte.) (4.098Bytes) (4.096Byt.s) 818 o •••••• _•• 51FF4 Interrupt 18 SCI CTFIL Reg 510 818 0 --------- 51FF4 18 SCI CTRL Reg $10 818 o •••• _-_ •• 51FF4 16 SCI CTRL AI, $10 m 1 Vectors $1FFF $2000 17 SCI STS "eg $11 18 SCI Oltl Reg $12 m I 2 ~terruPI Ictor. SIFFF 52000 I SCI STs "10 $11 lB SCI Dill Re9 $12 m 1 '2 ~t.rruPt actors SIFFF 52000 17 SCI STS SII 18 SCI O.t. Reg $12 Not Usad Not Us.d Not Used Not Usod Not Usod Not Usod 127 $7F 63 53F 83 53F 1638 S3FFF 1838 S3FFF 1838 S3FFF HD6305UO MCU HD6305VO MCU HD63705VO MCU Fig. 2-1 Memory Map 7 e 543 2 1 0 C~ndition n-4 1 1 1 Code I Register n+1 Pull n-3 Accumulator n+2 n-2 Index Register n+3 n-1 1 1 I PCW n+4 n PCl" n+5 PUlh • In a subroutine cell, only PCL and PCH .reltacked. Fig. 2-2 Sequence of Interrupt Stacking ~HITACHI 107 2.2 Registers This CPU contains five registers available to the programmer. They are shown in Fig. 2-3. 7 0 I A I Accumulator 7 0Ilndl!x I X Register 13 0IProgram I PC Counter 13 6 5 0ISteck I 0101010101011 111 SP Pointer Condition LS9 I H I I I N I z I C ICod~ 1sur ~~:x" Zero Negative Interrupt Mask Half Carry Fig. 2-3 Programming Model (1) Accumulator (A) The accumulator is an a-bit general purpose register which holds operands and results of the arithmetic operations or data manipulations. (2) Index Register (X) The index register is an a-bit register used for the indexed addressing mode. It contains an a-bit value which is added to an offset to create an effective address. The index register can also be used for data manipulations with read-modify-write instructions. When not performing addressing operations. the register can be used as a temporary storage area. (3) Program Counter (PC) The program counter is a 14-bit register which contains the address of the next instruction to be executed. (4) Stack Pointer (SP) The stack pointer is a 14-bit register containing the address of the next free location of the stack. Initially, the stack ~HITACHI 108 pointer is set to location $OOFF. It is decremented as a data is pushed on to the stack and incremented as data is then pulled out of the stack. The 8 high-order bits of the stack pointer are fixed to 00000011. During an MCU reset or a reset stack pointer (RSP) instruction, the pointer is set to location $OOFF. Subroutines and interrupts may be nested down to $OOCl, which allows programmers to use up to 31 levels of subroutine calls and 12 levels of interrupt responses. (5) Condition Code Register (CCR) The condition code register is a 5-bit register indicating the results of the instruction just executed. These bits can be individually tested by conditional branch instructions. Each bit is described in the following paragraphs. (a) Half Carry (H) When set, this bit indicates that a carry occurred between bit 3 and 4 during an arithmetic operation (ADD, ADC). (b) Interrupt (I) Setting this bit masks all interrupts except for software ones. If an interrupt occurs while this bit is set, the interrupt is latched and is processed as soon as the interrupt bit (I) is cleared. (More precisely the interrupt enters the servicing routine after the instruction next to the CLI is executed.) (c) Negative (N) When set, this bit indicates that the result of the last arithmetic, logical, or data manipulation is negative. (Bit 7 in the result is a logical "1".) (d) Zero (Z) When set, this bit indicates that the result of the last arithmetic, logical, or data manipulation is zero. (e) Carry/Borrow (C) When set, this bit indicates that a carry or borrow occurred during the last arithmetic operation. This bit is also affected by bit test and branch instructions, shifts and rotates. ~HITACHI 109 2.3 Timer Fig. 2-4 contains a block diagram of the timer. The 8-bit counter may be loaded under program control and is decremented towards zero by the clock input. When the ~ounter, that is, the timer data register (TDR) reaches zero, the timer interrupt request bit (bit 7) of the timer control register is set. When recognizing the interrupt request, the MCU proceeds to store the current CPU state on the stack, and then fetches the timer vector address from locations $lFF8 and $lFF9 (or $lFF6 and $lFF7 if in the wait mode) in order to execute the interrupt service routine. The timer interrupt can be masked by setting the interrupt mask bit (bit 6) of the timer control register. The mask bit (I) of the condition code register can also disable the timer interrupt. The clock input to the timer can be from an external source applied to the TIMER input pin, or it can be the internal E signal (which is a clock obtained by dividing the oscillator clock by four). When the E signal is used as the source, it can be gated by an input applied to the TIMER pin. The counter start counting down from "$FF" after it reaches zero. The counter may be monitored at any time by reading the contents of the timer data register. This allows a program to determine the length of the time since the occurrence of a timer interrupt without distarbing the counter contents. At reset, the prescaler and counter are initialized to "$7F" and "$FO", respectively. The timer interrupt request bit (bit 7) is cleared and the timer interrupt request mask (bit 6) is set. The timer interrupt request bit must be cleared by software. ~HITACHI 110 Initialize IInternal Clock) E--+-i 3 ....--,----"'T""--..J Timer Interrupt Write Read Fig. 2-4 Timer Block Diagram Table 2-1 TCR7 Timer interrupt request 0 Absent 1 Present TCR6 Timer interrupt mask o Enabled 1 Disabled (1) Timer Control Register (TCR; $0009) Selection of a clock source, selection of a prescaler fre- quency division ratio, and a timer interrupt can be controlled by the timer control register (TCR; $0009). (Refer to Fig. 2-5). For the selection of a clock source, anyone of the four modes (Refer to Table 2-2) can be selected by bits 5 and 4 of the timer control register (TCR). ' - - - - - - - - - - - - Timer interrupt mask ' - - - - - - - - - - - - - - T i m e r interrupt requllt Fig. 2-5 Timer Control Register (TCR; $0009) ~HITACHI 111 After reset, the TCR is initialized to E under timer terminal control (bit 5 = 0, bit 4 = 1). If the timer terminal is "1", the counter starts counting down with "$FO" inunediate1y after reset. When "1" is written in bit 3, the prescaler is initialized. This bit always shows "0" when read. A prescaler division ratio is selected by the combination of three bits (bits 0, 1 and 2) of the timer control register (Refer to Table 2-3). There are eight different division ratios: +1, +2, +4, +8, +16, +32, +64 and +128. After reset, the TCR is set to the +1 mode. A timer interrupt is enabled when the timer interrupt mask bit is "0", and disabled when the bit is "1". When a timer interrupt occurs, "1" is set in the timer interrupt request bit. This bit can be cleared by writing "0" in that bit. Table 2-2 Clock Source Selection TCR Bit 5 Bit 4 Clock input source 0 0 Internal clock E 0 1 E under timer terminal control 1 0 No clock input (counting stopped) 1 1 Event input from timer terminal Table 2-3 Prescaler Division Ratio Selection TCR Bit 2 Bit 1 Bit 0 Prescaler division ratio 0 0 0 H 0 0 1 +2 0 1 0 +4 0 1 1 +8 1 0 0 +16 1 0 1 +32 1 1 0 +64 1 1 1 +128 ~HITACHI 112 2.4 Serial Communication Interface (SCI) The SCI is used for transferring 8-bit data in serial. The transfer clock width ranges from 1 ~s to about 32 ms (with a 4 MHz oscillator), and sixteen types of transfer clock widths are available. The SCI consists of three registers, an octal counter and a prescaler as shown in Fig. 2-6. It communicates with CPU through the data bus lines and with peripherals through bits 3, 4 and 5 of Port D. The followings describe the registers and the data transfer operations. SCI Control Registers (SCR; 0010) E Transfer Clock Generator I Initialize SCI Status Registers (SSR :$0011) Not Used SCI/TIMER2 Fig. 2-6 SCI Block Diagram (1) SCI Control Register (SCR: $0010) Fig. 2-7 shows SCI Control Register configulation. Bit 7 (SCR7) When this bit is set to "1 If, the DDR corresponding to D3 is set to 1t1 tt and D3 functions as output of SCI data. After reset, the bit is in it ial ized to "0". ~HITACHI 113 Bit 6 (SCR6) When this bit is set to "1", the DDR corresponding to D4 is set to "0" and D4 functions as input of SCI data. After reset, the bit is initialized to "0". Bits 5 and 4 (SCR5, SCR4) These bits select a clock source. After reset, the bits are initialized to "0". Bits 3 ~ 0 (SCR3 ~ SCRO) These bits select a transfer clock rate. After reset, the bits are initialized to "0". Fig. 2-7 SCI Control Register Transfer clock rate SCR3 SCR2 SCRl SCRO 4.00 MHz 4.194 MHz 0 0 0 0 1 us 0.95 us 0 0 0 1 2 us 1. 91 us 0 0 1 0 4 ).1s 3.82 us 0 0 1 1 8 us 7.64 us I I I I I I 1 1 1 1 32768 us 1/32s SCR7 03 terminal 0 Used as I/O terminal (by DOR). 1 Serial data output (DDR output) SCR6 D4 terminal 0 Used as I/O terminal (by DDR). 1 Serial data input (DOR input) ~HITACHI 114 SCRS SCR4 Clock source DS terminal 0 0 - Used as I/O terminal (by DDR). 0 1 - 1 0 Internal Clock output (DDR output) 1 1 External Clock input (DDR input) (2) SCI Data Register (SDR: $0012) A serial-parallel conversion register used for data transfer. (3) SCI Status Register (SSR: $0011) Bit 7 (SSR7) This is the SCI interrupt request bit which is set on the completion of transmitting or receiving 8-bit data. It is cleared when the MCU is reset or data is written to or read from the SCI data register with the SCRS "1". This bit can also be cleared by writing "0" into it. Bit 6(SSR6) This is the TIMER2 interrupt request bit. The TIMER2 is also used as the serial clock generator, and this bit is set on the every negative edge of the internal transfer clock. When the MCU is reset, the bit is cleared. It can also be cleared by writing "0" into it. (Refer to "2.3 Timer" for details). Bit 5 (SSRS) This is the SCI interrupt mask bit which can be set or cleared by software. When this bit is "1", the SCI interrupt (SSR7) is masked. Resetting the MCU sets this bit to "1". Bit 4 (SSR4) This is the TIMER2 interrupt mask bit which can be set or cleared by software. When this bit is "1", the TIMER2 interrupt (SSR6) is masked. Resetting the MCU sets this bit to "1". Bit 3 (SSR3) Writing "1" into this bit initializes the prescaler of the transfer clock generator. A read of this bit always indicates "0". ~HITACHI 115 Bit 2 tV Bit 0 Not used. SSR7 SCI Interrupt Request 0 Not Requested 1 Requested SSR6 TlMER2 Interrupt Request 0 Not Requested 1 Requested SSR5 SCI Interrupt Mask 0 Interrupt Allowed 1 Interrupt Inhibited SSR4 TIMER2 Interrupt Mask 0 Interrupt Allowed I Interrupt Inhibited (4) Transmit Operations The transfer clock width and the clock source are determined by setting the corresponding SCI control register bits, and then D3 and D5 are set to serial data output pin and serial clock pin respectively. The transmit data should be moved from the accumulator or the index register into the SCI data register. Then, the data moved into the SCI data register is output through the D3/Tx pin, starting with the LSB, synchronously with the negative edge of the serial clock. Refer to Fig. 2-8. When 8 bits of data have been transmitted, the bit 7 of the SCI status register (interrupt request bit) is set on the positive edge of the last serial clock. This interrupt request can be masked by setting bit 5 of the SCI status register. After completion of the data transmission, the 8th bit of data (MSB) stays at the D3/Tx pin. If the external clock source is selected, the transfer clock width determined by bit 0 to bit 3 of the SCI control register is ignored and the D5 / C! pin is set as input. If the internal clock source is selected, the D5/CK is set as output and clocks are generated with the transfer clock width selected by bit 0 to 3 of the SCI control register. ~HITACHI 116 Fig. 2-8 SCI Timing (S) Receive Operations The transfer clock width and the clock source are determined by setting the corresponding SCI control register bits, and the D4 pin and the DS pin are set to serial data input pin and serial clock pin respectively. Then the receive operation is enabled by dummy- reading or -writing the SCI data register. (This procedure is not needed after a data is received. It is needed after reset or when no data is received yet.) The received data through the D4/Rx pin is input to the SCI data register synchronously with the positive edge of the serial clock. (Refer to Fig. 2-8.) At completion of 8-bit data reception, the bit 7 in the SCI status register (interrupt request bit) is set. This interrupt request can be masked by set- ting bit S of the SCI status register. If the external clock source is selected, the transfer clock width determined by bit 0 to bit 3 of the SCI control register is ignored and data is received synchronously with the clock input through the DS/CK pin. If the internal clock source is selected, the DS/CK acts as an output and clocks are output with the transfer clock selected by bit 0 to bit 3 of the SCI control register. (6) TIMER2 The SCI transfer clock generator functions as a timer. The SCI clock selected by bits 3 to 0 of the SCI Control Register (4 VS to approx -32 ms in 4 MHz operation) is transmitted to bit 6 of the SCI Status Register, and the timer 2 interrupt request bit is set at each falling edge of the SCI clock. Since this interrupt occurs periodically, Timer2 is available for a reload counter or a timer. Timer2 is multiplexed with the SCI transfer clock generator. When using Timer2 independently of the SCI, external clock should be selected as SCI clock source by setting both SCS and SC4 to "1". If Internal clock is selected as a SCI clock source, reading from or writing to the SD! initializes the prescalor of the SCI tranBf~t clock generator. ~HITACHI 117 VZI + VFI { Vout = GND when Vee < VZI + VFl (b) Since the voltage VZ2' applied to ZD2, and the ON level VF2 of Tr2 are constant, even if the Vee changes. The followings describe the RES signals. ~HITACHI 139 v vee (Threshold voltage) VLM~ ~ 'Vet x Rt Vout Vee when Vee > VZZ + VFZ { Vout GND when Vee < VZZ + VFZ When the Vee changes, threshold level, VLM is affected by replacing the Zener diodes ZD 1 and ZD Z• (iii) The Auto-reset function will be more stabilized by feeding back the output signal to the RES pin, tuning finely the reference voltage, and providing hysteresis with the VLM1 and the VLMZ. (VLM1 is a voltage during the shifting from operation to resetting, and VLMZ is the voltage in recover- ing:) 3.3 Manual Reset Circuit (1) Purpose When the Meu is reset by an external switch, it is necessary to prevent chattering. The following describes a reset circuit in which chattering prevention and power-on reset functions are provided. (Z) Basic circuit Fig. 3-3 shows the basic circuit of manual reset. Vee Fig. 3-3 Basic Circuit of Manual Reset (3) Operation principle (i) Power-on reset During power-up, the capacitor e will be charged and the Vin rising time will be delayed by the eR charge time, so that power-on would reset normally. ~HITACHI 140 v vee 'w ~-r-'t=ut-- I---+l t - ex R (ii) Manual reset When SW is on, the Vout goes "a" and the MCU is reset. When SW is off, the capacitor C is charged, so that the rising time of Vin is delayed by the CR charge time. Chattering is prevented by the capacitor C and the Schmidt trigger HD74LS14. OFF-,-- ON - - - - i_ _- ,---- SW 1.6V 3.4 A/D Converter Circuit (1) .•• High Speed (1) Purpose The following describes how to implement a simple AID conversion (analog-digital conversion) using the resistance radder (R-2R) system. (2) Basic circuit Microcomputer An.log Vin + V out VREF- ( On + Q!!:.! + •.. + ~ +.Q!)x V V: Voltage of the output Input VREF 21 22 2n·l 2n "1" of the port R Vout = 0 : Vin ~ VREF V Port Nec....ry numb.r of Vout· 1 : Vin > VREF port-Accuracy bit+l 03 R 2R I--~=----Vin R 2R 2R eMOS H014060 Vout ~ ':2:..J Fig. 3-4 A/D Converter Basic Circuit Fig. 3-5 Timing Chart ~HITACHI 141 (3) Operation outline The follnwings describe the operation outline of 3-bits A/D converter circuit. (i) The digital outputs (D 3 • D2 • D1 ) are changed from (1. 1. 1) to (0. o. 0) at the port. VREF is reduced from 7/8 V to 0 by every 1/8 V according to Table 3-1. (ii) The output Vout ' which is the result of comparison between the analog input Yin and VREF. is reversed from "0" to "1" when Yin is greater than VREF as shown in Fig 3-5. (iii) The value of (D 3 • D2 • D1 ). when Vout is reversed from "0" to "1". is a digital value to the analog input Yin' Table 3-1 Value of VREF D3 D2 D1 VREF 0 0 0 0 0 0 1 1/8 x V Dl to D3 are denoted by "1" or "(I" 0 1 0 2/8 x V V: Voltage of the port output "1" 0 1 1 3/8 x V 1 0 0 4/8 x V 1 0 1 5/8 x V 1 1 0 6/8 x V 1 1 1 7/8 x V ~HITACHI 142 3.5 AID Converter Circuit (2) .•• Low Speed (1) Purpose The following describes the A/D conversion system utilizing time for charge/discharge to/from the CR circuit. This conversion system is available even if the A/D conversion tUne is slow. (2) Basic circuit Operation amplifier Microcomputer HA17902 Vln Analog Input R n : Count value A Number of T - T. x n Port port required C ' - - - - - ' -2 T. : Timer Interval Fig. 3-6 AID Converter Basic Circuit Fig. 3-7 Timing Chart (3) Operation outline (i) Set the output terminal A of the port to "1", discharge the external condenser C for a sufficiently long period, decline A from "1" to "0" synchronously with the timer interrupt and charge C. (ii) Check Vout for each timer interrupt and observe the time T in which Vout declines from "1" to "0" • Vout becomes "0" when Vin is less than VREF • T is obtained as T=TO x n, where "n" represents the number of timer interrupts and TO represents the timer interval. (iii) The obtained time T, which is voltage converted, is a digital value of the analog input Vin' ~HITACHI 143 AID conversion lubroutlne ":==:r---' __ .. :!'.!'!'!!'!.t.rrupt 3.6 Precautionj- Board Design of Oscillation Circuit When connecting crystal and ceramic resonator with the XTAL and EXTAL pins to oscillate, observe the followings in designing the board. (1) Locate crystal, ceramic resonator, and load capacity Cl and C2 as near the LSI as possible. (Induction of noise from outside to the XTAL and EXTAL pins may cause trouble in oscillation.) (2) Wire the signal lines to the neighbouring XTAL and EXTAL pins as far apart as possible. (3) Board design of situating signal lines or power supply lines near the oscillator circuit as shown in Fig. 3-9, should not be used because of trouble in oscillation by induction. The resistor between the XTAL and EXTAL, and pins close to them should be lOMn or more. ~HITACHI 144 -< IQ ~ ';;I ! or! gb or! ~ f{l 1 1 1-_ _-'-1- 4 - _ - ; : :_ _ Signal C XTAL r=J--~-IIt----'=-. XTAL EXTAL Lt--""--t--"i EXTAL Fig. 3-8 Design of Oscillation Fig. 3-9 Example of Circuit Causing Circuit Board Trouble in Oscillation 3.7 Precautionj- Sending/Receiving Program of Serial Data Reading from or Writing into the SCI data register (SDR: $0012) during sending/receiving of serial data may make sending/receiving operation of SCI out of order. 3.8 Precautionj- WAIT/STOP Instructions Program When I bit of condition code register is "1" and an interrupt (INT, TIMER/INT 2 , SCI/TIMER2 ) is held, the MCU does not enter into WAIT mode by executing the WAIT instruction. In that case, the MCU executes the corresponding interrupt proces- sing routine after the 4 dummy cycles. When external interrupts (INT, INT2) are held at the I bit mask, the MCU does not enter into the STOP mode by the STOP instruction execu- tion. The MCU executes the corresponding interrupt processing routine after the 4 dummy cycles, in this case, either. ~HITACHI 145 4. PIN ARRANGEMENT AND DIMENSIONAL OUTLINE (1) HD6305UO, HD6305VO • HD6305UO~ HD6305VOP (DP-40) • HD6305UOF, HD6305VOF (FP-54) ~ 0 Vee N~ A, ElCTAL XTAL nMER At Jl'iiY At o.;lRT; '" Do/CR" '"'""- D./Rx DolT. A, D. D, So Do 8, Ib e. C, ...a. S. C• c. c. a. c. 8, C. V.. C, • HD6305UOC~ HD6305VOCP (CP-44) • HD63705VOC (DC-40) o - RES iiif At 3 40 Vc:c EXTAL XTAL 7 TIMER/Vpp ii'fiiY D,IINT. D.tCK DoIAx Ds/T. NC D./CE A. D, DI/OE B. D. B. 1 C. B. C. C, B. C. C. B. B. B. B, C. V.. Fig. 4-1 Pin Arrangement (1bp View) ~HITACHI 146 Unit: _(inch) • DP-40 52.8(2.079) 40 54.0max.(2.126ma•.) 21 _lC; -~ a .. ~i~an • 1.2 20 -9 (0.047) • DC-40 50.28 (1.919) ~. 2' rV, [QJ 211 N- ;~ O.25!X}J (o.o'O_n,;) • FP-S4 2.9max. (0.1 14m•• .) 0.IS±0.05 (0.006 ± 0.002) (NOTE) Inch value indicated for your reference Fig. 4-2 Dimensional Outline ~HITACHI 147 Unit: _(inch) • CP-44 17.53±0 12(O.19O±o.oo5) 6 I~ 40 7 0 '17 I5.50 ± 0.50(0.61 0 ± 0.020) Fig. 4-2 Dimensional Outline • HITACHI 148 5. ELECTRICAL CHARACTERISTICS 5.1 Electrical Characteristics for HD6305UO, HD6305VO • 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 Voltage Topr o '" +70 °c Storage Voltage Tstg -55 '" +150 °c (Note) These devices contain circuits to protect the inputs against high static voltages or high electric fields. Be careful not to apply any voltage higher than the absolute maximum rating to these high input impedance circuits. For normal operation, we recommend the Vin and Vout be constrained to the range VSS ~ (Vin or Vout ) ~ VCC' • MCU MODE ELECTRICAL CHARACTERISTICS • DC Characteristics (VCC = 5.0V ± 10%, VSS = GND, Ta 0 '" +70°C unless otherwise specified) Item Symbol Test min Condition typ max Unit Input "High" ~, STFl VCC-0.5 - VCC +0.3 EXTAL VIH VCC xO.7 - VCC+0.3 V Voltage All Others 2.0 - VCC+0.3 Input "Low" Voltage All Inputs VIL -0.3 - O.S V Active - 5 10 mA Current ** Wait f=lMHz* - 2 5 mA ICC Dissipation Stop - 2 10 \.IA Standby - 2 10 \.IA Input Leakage TIMER~ IIILI - - 1 Current INT' TB Vin=0.5 '" Three State \.IA Ao"'A7 ,BO"'B7, Leakage CO"'C7,DO"'D6 IITSII VCC-°. 5V - - 1 Current Input f=lMHz, Capacitance All Inputs Cin Vin=OV - - 12 pF * The value at f=x MHz is gain by ICC=(f=XMHz) = ICC (f=lMHz) x X. ** VIR min = VCC -1. OV, VIL max = O. SV Penetrate current is not included. ~HITACHI 149 • AC Characteristics (VCC = 5.0V ± 10%, VSS GND, Ta unless otherwise specified) Item Symbol Test 1ID6305UO va 1ID63A05UO IVO HD63B05UO VO Condition min typ max min typ max Unit min typ max Clock Frequency fcl 0.4 - 4 0.4 - 6 0.4 - 8 MHz Cycle Time tcyc 1.0 - 10 0.666 - 10 0.5 - 10 }.IS INT Pulse Width tIW!. tcyc +250 - - tcyc +200 - - tcyc +200 - - ns INT2 tcyc tcyc tcyc Pulse Width tIW!.2 +250 - - +200 - - +200 - - ns RES Pulse Width tRW!. 5 - - 5 - - 5 - - tcyc TIMER Pulse Width tTWL tcyc +250 - - tcyc +200 - - tcyc +200 - - ns CL • 22pF± Oscillation \. 20% Start Time tosc Rs - 60n - - 20 - - 20 - - 20 ms (Crystal) max Reset Delay external Time tRHL capacitance 80 - - 80 - - 80 - - ms 2.2 }.IF • Port Characteristics (VCC = 5.0V ± 10%, VSS = GND, Ta = 0 ~ +70·C unless otherwise specified) Item Symbol Test Condition min typ max Unit Output "Righ" lOR = -200].lA 2.4 - - V VOR Voltage Por\:: A, lOR = -lO].lA VCC-0.7 - - V B, C, D Output "Low" Voltage VOL IOL = l.6mA - - 0.55 V Input "High" Voltage VIH 2.0 - VCC +0.3 V Input "Low" Port A, Voltage B, C. D VIL -0.3 - 0.8 V Input Vin = - Leakage IIILI 0.5WCC -0.5V - 1 ].lA Current ~HITACHI 150 • seI TimIng (Vee = S.OV ± 10%, VSS GND, Ta = 0 ~ +70·e) unless otherwise specified) HD6305UO/VO HD63A05UO/VO HD63BO suo IVO Item Symbol Unit m1n typ max min typ max min typ max Clock Cycle Time tScyc 1 - 32768 0.67 - 21845 0.5 - 16381 liS Data Output Delay Time tTXD - - 250 - - 250 - - 250 ns Data Set-up Time tSRX 200 - - 200 - - 200 - - ns Data Hold Time tHRX 100 - - 100 - - 100 - - ns tScvc Clock Output I Ds/CK \ IrO.6V O.6V ,j 2.4V \ O.6V Data Output - tn <. , <> HN482764 HD630SUO $1FF3 $1FF4 "' $1FF3 HN27C64 L ~ $1FF4 <> <- ,) <> or their equivalent $1FFF "' $1FFF $1000 $1000 <> { j <> HN482764 HD630SVO $1FF3 $1FF3 HN27C64 $1FF4 $1FF4 <> <. ,) <> or their equivalent $1FFF $1FFF ~HITACHI 163 I APPENDIX I I. DESIGN PROCEDURES AND SUPPORT TOOLS Cross assembler and hardware emulator, containing various kinds of computers, are available as supporting systems to develop users' programs. Users' programs are mask programmed into ROM and shipped by Hitachi. Fig. I-I shows a typical program design procedure and Table I-I summarizes a set of system development support tool for HD6305UO and HD6305VO. Text Editor Host Computer (61 Cross Assembler Host Computer Emulator EPROM On-Chip LSI, HD63705VOC No Fig. I-I Program Design Procedure ~HITACHI 164 The following explains the system development procedure. 1. Specify functional assignment of I/O pins and allocation of RAM area before starting programming. 2. Design a flowchart to implement the functions and encode this flowchart with mnemonic codes. 3. Punch the coded format onto cards or write it on a floppy disk. This set of coded form is a source program. 4. Assemble the source program to gene rage an obj ect with a cross system. And check errors out here. 5. 6. 7. Verify the program through hardware simulation with emulator or EPROM on-chip microcomputer. Send the completed program in EPROM to Hitachi. After Hitachi received user's specified ROM pattern, Hitachi I fabricate sample LSI for users' evaluation for the functions. If a user does not find any problem in the sample LSI, Hitachi will start mass production of the LSI. Table I-I System Development Support Tbols EPROM IBM PC Type No. Emulator On-Chip LSI Cross Assembler HD6305UO H35MIX3 HD63705VOC S35IBMPC HD6305VO (HS35VEML03H) ~HITACHI 165 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 (> (> (> (> (> 1 1 1 1 32768 IlS 1/32s SCR7 C7 terminal o Used as I/O terminal (by DDR). 1 Serial data output (DDR output) SCR6 C6 terminal o Used as I/O terminal (by DDR). 1 Serial data input (DDR input) SCRS SCR4 Clock source Cs terminal 0 0 - Used as I/O terminal (bYI DDR). 0 1 - 1 0 Internal Clock output (DDR output) I 1 External Clock input (DDR input) ~HITACHI 193 (2) SCI Data Register (SDR; $0012) A serial-parallel conversion register that is used for transferring data. (3) SCI Status Register (SSR; $0011) Bit 7 (SSR7) Bit 7 is the SCI interrupt request bit which is set upon completion of transmitting or receiving 8-bit data. It is cleared when reset or data is written to or read from the SCI data register with the SCR5="1". The bit can also be cleared by writing "0" into it. Bit 6 (SSR6) Bit 6 is the TIMER2 interrupt request bit. TIMER2 is multi- plexed with the serial clock generator, and SSR6 is set each time the internal transfer clock falls. When reset, the bit is cleared. It also be cleared by writing "0" in it. (For details, see TIMER2.) Bit 5 (SSR5) Bit 5 is the SCI interrupt mask bit which can be set or cleared by software. When this bit is set to "1", the SCI interrupt (SSR7) is masked. When reset, it is set to "1". Bit 4 (SSR4) Bit 4 is the TlMER2 interrupt mask bit which can be set or cleared by software. When the bit is set to "1", the TlMER2 inter- rupt (SSR6) is masked. When reset, it is set to "1". Bit 3 (SSR3) When "1" is written into this bit, the presca1er of the transfer clock generator is initialized. When read, the bit is always "0". Bits 2 IV 0 Not used. Fig. 2-8 SCI Status Register (SSR; $0011) $ HITACHI 194 SSR7 SCI interrupt request 0 Absent 1 Present SSR6 TlMER Z interrupt request 0 Absent 1 Present SSRS SCI interrupt mask 0 Enabled 1 Disabled SSR4 TlMERZ interrupt mask 0 Enabled 1 Disabled (4) Data Transmission By writing the desired control bits into the SCI control registers, a transfer rate and a source of transfer clock are determined and bits 7 and S of port C are set at the serial data output terminal and the serial clock terminal, respectively. The transmit data should be stored from the accumulator or index register into the SCI data register. The data written in the SCI data register is transmitted from the C7/Tx terminal, starting with the LSB, synchronously with the falling edge of the serial clock. (Refer to Fig. Z-9.) When 8 bits of data have been transmitted, the interrupt request bit is set in bit 7 of the SCI status register with the rising edge of the last serial clock. This request can be masked by setting bit S of the SCI status register. Once the data has been transmitted, the 8th bit data (MSB) stays at the C7/ Tx terminal. If an external clock source has been selected, the transfer rate determined by bits 0 ~ 3 of the SCI control register is ignored, and the CS/CK terminal is set as input. If the internal clock has been selected, the Cs/CK terminal is set as output and clocks are transmitted at the transfer rate selected by bits 0 ~ 3 of the SCI control register. ~HITACHI 195 Illput Oa'l Latch Timillf IC,/R_' 'Fig. 2-9 SCI Timing Chart (5) Data Reception By writing the desired control bits into the SCI control register, a transfer rate and a source of transfer clock are determined and bit 6 and 5 of port C are set at the serial data input terminal and the serial clock terminal, respectively. Then dummy-writing or reading the SCI data register, the system is ready for receiving data. (This procedure is not needed after reading a subsequent received data. It must be taken after reset and after not reading a subsequent received data.) The data from the C6/Rx terminal is input to the SCI data register synchronously with the leading edge of the serial clock (Refer to Fig. 2-9). When 8 bits of data have been received, the interrupt request bit is set in bit 7 of the SCI status register. This request can be masked by setting bit 5 of the SCI status register. If an external clock source has been selected, the transfer rate determined by bits 0 ~ 3 of the SCI control register is ignored and the data is received synchronously with the clock from the C5 /'CK terminal. If the internal clock has been selected, the C5 /CK terminal is set as output and 'clocks are output at the transfer rate selected by bits 0 ~ 3 of the SCI control register. (6) TlMER2 The SCI transfer clock generator can be used as a timer. The SCI clock selected by bits 3 ~ 0 of the SCI Control Register (4 ~s ~ approx. 32ms in 4MHz operation) is received by bit 6 of the SCI Status Register, and the timer 2 interrupt request bit is set at each falling edge of the SCI clock. Since this interrupt occurs periodically, Timer2 is available for a reload counter or a timer. Timer2 is multiplexed with the SCI transfer clock generator. When using Timer2 independently of the SCI, external clock should be selected as SCI clock source by setting both SCR5 and SCR4 to "1". If Internal clock is selected as a SCI clock source, reading from or writing to the SDR initializes the prescalor of the SCI transfer clock generator. ~HITACHI 196 CD --"--1 ®® ®@ i t L CD : Transfer clock generator is reset and mask bit (bit 4 of SCI status regis tor) is cleared ®.® : TlMER2 interrupt request ®.@ : TlMER2 interrupt request bit cleared 2.5 Reset The MCU can be reset either by external reset input (RES) or power-on reset. (Refer to Fig. 2-10.) On power up, the reset input must be held "Low" for at least tosc to assure that the internal oscillator is stabilized. A sufficient time of delay can be obtained by connecting a capacitance to the RES inputs as shown in Fig. 2-11. 5V 4.5/V Vee OV-------------J RES ...... ~VIL -RES Terminal -----------f""/ ' Internal Re~t ----------------~ Fig. 2-10 Power On and Reset Timing Vee .--J\Jw-t=:--'I 100kn :Vp RES$ 2.2"F HD6305X/Y MCU Fig. 2-11 Input Reset Delay Circuit 2.6 Internal Oscillator Options The internal oscillator circuit is designed to meet the require- ment for minimum external configurations. It can be driven by connect- ing a crystal (AT cut 2.0 ~ 8.0MHz) or ceramic oscillator between pins 5 and 6 depending on the required oscillation frequency stability. Three different terminal connections are shown in Fig. 2-12. Figs. 2-13 and 2-14 illustrate the specifications and typical arrange- ment of the crystal, respectively. ~HITACHI 197 EXTAL l·o-8:.oMHz~ XTAL HD6305X/Y MCU 10-22pF±20% Crystal Oscillator EXTAL XTAL HD6305X/Y MCU External Ceramic Oscillator Clock Input EXTAL NC XTAL HD6305X/Y MCU External Clock Drive Fig. 2-12 Internal Oscillator Circuit At Cut c, ~~ Paralle Resonance XTALL---f~EXTAL Co; 7pF max. f;2.0 -8.0MHz Rs;60n max. Fig. 2-13 Parameters of Crystal r--------------- (a) (b) [NOTE 1 Us. as short wirings as possible for connection of the crystal with the EXTAl and XTAl terminals. 00 not allow these wirings to cross others. Fig. 2-14 Typical Crystal Arrangement ~HITACHI 198 2.7 Interrupts There are six interrupts: external interrupts (INT, INT2) , internal timer interrupts (TIMER, TIMER2), serial interrupt (SCI) and interrupt by an instruction (SWI). Of these six interrupts, the INT2 and TIMER interrupt or the SCI and TIMER2 interrupt generate the same vector address, respectively. When an interrupt occurs, the program in progress stops and the then CPU status is saved onto the stack. Then, the interrupt mask bit (I) of the condition code register is set and the start address of the interrupt processing routine is obtained from a particular interrupt vector address. Then the interrupt ~outine starts from the start address. System can exit from the interrupt routine by an RTI instruction. When this instruction is executed, the CPU status before the interrupt (saved onto the stack) is pulled and the CPU restarts the sequence with the instruction next to the one at which the inter- rupt occurred. Table' 2-4 lists the priority of interrupts and their vector addresses. A flowchart of the interrupt sequence is shown in Fig. 2-15. A block diagram of the interrupt request source is shown in Fig. 2-16. (1) External Interrupt In the block diagram, both the external interrupts INT and INT2 are edge trigger inputs. At the falling edge of each input, an interrupt request is generated and latched. The INT interrupt request is auto- matically cleared if jumping is made to the INT processing routine. The INT2 interrupt request is masked when "0" is written to bit 7 of the Miscellaneous Register. If the I bit of the Condition Code Register is set to "1", interrupt requests of the external interrupt (INT, INT2) are retained, but not processed. Immediately after the I bit is cleared, the CPU jumps to the corresponding interrupt routine. The INT2 interrupt can be masked by setting bit 6 of the Miscellaneous Register. The INT terminal status can be tested by a BIL or BIH instruc- tion. The INT falling edge detector circuit and its latching ~HITACHI 199 circuit, and INT2 terminal are unaffected by executing BIL and BIH instructions. (2) Internal Interrupt and SCI Interrupt When I bit of the Condition Code Register is set to "1", internal timer interrupts (TIMER, TIMER2) and SCI interrupt requests are retained without being processed. Immediately after I bit is cleared, the CPU initiates the corresponding interrupt service routine. Timer interrupt, SCI interrupt, Timer2 interrupt can be masked by setting bit 6 of Timer Control Register, bit 5 of SCI Status Register, and bit 4 of SCI Status Register, respectively. Table 2-4 Priority of Interrupts Interrupt Priority Vector Address RES 1 $lFFE, $lFFF SWI 2 $lFFC, $lFFD INT 3 $lFFA, $lFFB TIMER/INT2 4 $lFF8, $lFF9 SCI/TIMER2 5 $lFF6, $lFF7 1.....1 $FF.....SP O..... OOR·S CLR iiii'l'Logic SFF.....TOR $7F .....Timer Prescaler $50.....TCR S3F .....SSR $OO.....SCR $7F .....MR Fig. 2-15 Interrupt Flowchart eHITACHI 200 Vectoring generated $1 FFA. $1 FFB BIH/BIL Test Condition Code Register (CCR) iNT Inter· rupt Latch INT Falling Edge Detector } - - - < t - t - - - - Vectoring generated $1FF8.$1FF9 TIMER SCI/TIMER. } - - - _ - - - Vectoring generated $1FF6.$1FF7 SCI Fig. Z-16 Interrupt Request Generation Circuitry (3) Miscellaneous Register (MR: $OOOA) Miscellaneous Register (MR: $OOOA) specifies INT request sense (edge sense or level sense) and controls INTZ interrupt. Bit 7 of Miscellaneous Register (MR7) is an INTZ interrupt request flag. When the falling edge is detected in INTZ, MR7 is set to "I". MR7 can be checked by software if it is INT Z interrupt or not in the interrupt service routine (vector address: $lFF8, $lFF9). This bit can be reset by software. Bit 6 (MR6) is the INTZ interrupt mask bit. If this bit is set to "1", the INTZ interrupt is masked. Both read and write are possible with bit 7, but "I" cannot be written in this bit by software. Thus an interrupt cannot be requested by software. During reset, bit 7 is initialized to "0", while bit 6 is initialized to "I". 76543210 IMR7IMR61Z1Z1Z1Z1Z1Z1 I tL__________ L._ _ _ _ _ _ _ _ _ _ _ _ INTl Interrupt Mask INTl Interrupt Request Flag Fig. Z-17 Miscellaneous Register (MR:$OOOA) ~HITACHI 201 2.8 Input/Output Ports (1) I/O Ports HD630SXO/YO and HD63P05YO have 32 I/O ports (Port A, B, C, G), HD630SXl/Yl, HD630SX2/Y2 provide 24 r/o ports (Port A, B, C). Each terminal can individually function either as input or output by programming the Data Direction Register. If a corresponding bit of Data Direction Register is set to "0", the I/O port functions as an input. While corresponding bit of Data Direction Register is pro- grammed to "1", the I/O port functions as an output. Port A, B or C, when functioning as output and reading I/O port data, reads latched data, even if the output level is flunched by the output load (Refer to Fig. 2-l8(a». In this case, Port G always reads the pin level (Refer to Fig. 2-l8(b». Thus even when "1" is transmitted, Port G sometimes reads "0" if the load condition causes the output voltage to decrease less than 2.0V. During reset, all Data Direction Registers are initialized to "0" and all I/O ports function as inputs. I/O ports are compatible with TTL and CMOS in respect to both input and output. If I/O ports are not used, they should be connected to Vss through resistors. If these terminals are left open, they may consume extra power. (2) Output Ports (for HD630SXO/YO, HD63POSYO only) There are 16 output-only terminals (ports E and F). Each of them can also read. In this case, latched data is read even with the output terminal level being fluctuated by the output load (as with ports A, B and C). When reset, "Low" level is transmitted from each output terminal. (3) Input Ports Seven input-only terminals are available (port D). Writing to an input terminal is invalid. All input/output terminals, output terminals and input terminals are TLL compatible and CMOS compatible in respect of both input and output. If I/O ports or input ports are not used, they should be connected to Vss through resistors. If these terminals are left open, they may consume extra power. ~HITACHI 202 Bit of data Bit of direction output Status of Input to register data output MCU 1 0 0 0 1 1 1 1 0 x 3-state Pin a. Ports A, Band C b. Port G Fig. 2-18 Input/Output Port Diagram ~HITACHI 203 2.9 Low Power Dissipation Mode HD6305X family and HD6305Y family have three types of low power dissipation modes: Wait mode, Stop mode, and Stop mode. (1) Wait Mode When Wait instruction is executed, the MCU enters into the WAIT mode; the oscillator does not stop, but the internal clock stops. The CPU stops but the internal peripherals (e.g. Timer and SCI) continue their current operations. (Note: Once the system entered into the Wait mode, SCI can no longer be retriggered.) During the Wait mode, RAM and I/O terminals hold their conditions just before entering into the Wait mode, while I bit of the Condi- tion Code Regi ster is cleared to "0". The MCU can be recovered from the Wait Mode by an interrupt (INT, TlMER/INT2, or SCI/TIMER2), RES or STBY. The RES resets the MCU, and the STBY brings it into the standby mode (Refer to Standby mode for details). When the CPU accepts interrupt request, the wait mode escapes, then the CPU is brought to the operation mode and vectors to the interrupt routine. If the interrupt is masked by the I bit of the condition code register, after releasing from the wait mode,the MCU executes the instruction next to the WAIT. If an interrupt other than the INT (e.g., TIMER/INT2 or SCI/TlMER2) is masked by the timer control register, miscellaneous register or serial status register, the CPU does not receive any interrupt request, Thus the wait mode cannot be released. Fig. 2-19 shows a flowchart for the wait function. (2) Stop Mode When STOP instruction is being executed, the MCU enters into the stop mode. In this mode, the oscillator stops and the CPU and peripheral stops functioning but the RAM, registers and I/O terminals hold their condition just before entering into the stop mode. The escape from this mode can be done by an external interrupt (INT or INT2), RES or STBY. The RES resets the MCU and the STBY brings it into the standby mode. ~HITACHI 204 When the CPU accepts interrupt request, the stop mode escapes, then the CPU is brought to the operation mode and vectors to the interrupt routine. If the interrupt is masked by the I bit of the condition code register, after releasing from the stop mode, the MCU executes the instruction next to the STOP. The MCU cannot be released from the STOP mode if the INTZ interrupt is masked by the miscellaneous register. Fig. 2-20 shows a flowchart for the stop function. Fig. 2-21 shows a timing chart when the MCU is released from the stop mode. For releasing from the stop mode by an interrupt, oscillation starts upon input of the interrupt and, after the internal delay time for stabilized oscillation, the CPU becomes active. When restarting by RES, oscillation starts when the RES goes "0" and the CPU restarts when the RES goes "1". The duration of RES="O" must exceed tosc=20ms to assure stabilized oscillation. (3) Standby Mode The MCU enters into the standby mode when the STBY goes "Low". In this mode, all operations stop and the internal condition is reset holding the RAM contents. The I/O terminals go into High- impedance state. The standby mode should escape by bringing STBY "High". The CPU must be restarted by reset. The timing of input signals at the RES and STBY is shown in Fig. 2-22. Table 2-5 lists the status of each parts of the MCV in each low po~er dissipation modes. Transitions between each mode are shown in Fig. 2-23. ~HITACHI 205 Oscillator Active Timer and Serial Clock Active All Other Clocks Stop Initialize CPU, TIMER. SCI. I/O and All Other Functions No No Load PC from Interrupt Vector Addresses Fetch Instruct ion Fig. 2-19 Wait Mode Flowchart ~HITACHI 206 Stop Oscillator and All Clocks No No to Standby Mode Turn on Oscillator Wait for Time Delay to Stabilize Turn on Oscillator Wait for Time Delay to Stabilize 1=0 Load PC from I nterrupt Vector Addresses Fetch Instruct ion Fig. 2-20 Stop Mode Flowchart ~HITACHI 207 Oscillator E STOP instruction I Interrupt Time required for oscillation to become executed stabilized (built-in delay time) restart (a) Restart by Interrupt Oscillator E STOP instruction Time required for oscillation to become Reset executed stabilized (tos e ) start (b) Restart by Reset Fig. 2-21 Timing Chart of Releasing from Stop Mode STBY \ H I RES I I I I I I \ I I I I I I I I I ,-_.& _ ..... _ ..I' if I .I tose I Restart Fig. 2-22 Timing Chart of Releasing from Standby Mode Table 2-5 Status of Each Part of MCU in Low Power Dissipation Modes Condition Mode Start Oscil- Timer, I/O Escape CPU Register RAM lator Serial terminal WAIT in- STBY, RES, INT, INT2, WAIT Active , Stop Active Keep Keep' Keep each interrupt request of struction Soft- TIMER, TIMER2, SCI ware STOP STOP in Stop Stop Stop Keep Keep Keep STBY, RES, INT, INT Z struction Stand- Hard- High im- by ware STBy="Low " Stop Stop Stop Reset Keep STBY="High" pedance ~HITACHI 208 Fig. 2-23 Transitions among Active Mode, Wait Mode, Stop Mode, Standby Mode and Reset ~HITACHI 209 3. APPLICATIONS AND PRECAUTIONS 3.1 Memory Space Expansion of HD6305X1/Y1, HD6305X2/Y2, HD63P05Y1 (1) ROM ROM space can be expanded by e~ternally connecting EPROM or I Mask ROM to the MCU. Fig. 3-1 show~ an example of using the I HN482732A. / HD6305Xl, HD6305X2 HD6305Yl, HD6305Y2 HN482732A HD63P05Yl 12 ADRO'VADR11 AO'VA11 8 DATAo'VDATA7 00 'V 07 Fig. 3-1 Memory Space Expansion for ROM (2) RAM Fig. 3-2 shows a system configuration by using the HM6116. HD6305Xl, HD6305X2 HM6 11 6 HD6305Yl, HD6305Y2 HD63P05Yl ADRO 'V ADR10 AO'VAlO DATAO'VDATA7 1/01 'V I/OS E WE R/W ..... v- ~ OE A ..... .... CS Fig. 3-2 Memory Space Expansion for RAM ~HITACHI 210 3.2 Watch-Dog Timer (1) Purpose A simple method of implementing the watch dog timer, which is generally known as a means of recovery from a system upset, will be described below. (2) Basic circuit Fig. 3-3 shows the basic circuit for recovery from a system upset. Vee Vee R --'l.- Microcomputer Alive Pulse Port Monostable Mu It i-vibrator Fig. 3-3 Basic Circuit for Recovery from a System Upset (3) Operation outline (i) In structuring system software, design the whole system so that a pulse is generated through the port within a predetermined period (r: Sms+2ms = 7ms ®: Sms+Sms =lOms «): 7ms * Preset as the pass ® lOms VZl + VFl Vout - GND when Vee < VZl + VFl (b) The voltage VZZ' applying to ZDZ, and the ON level VFZ of Trl are constant, even if the Vee changes. The followings describe the RES signals. v Vee ( ThreShoi~)D~--~- voltage Ivout-L ---------t:] L -_ _ ~ ______ ~ -+____ __ { Vout= Vee when Vee > VZZ + VFZ Vout = GND when Vee < VZZ + VFZ When the Vee changes, threshold level VLM is affected by replacing the Zener diodes ZD l and ZD Z• (iii) The Auto-reset function will be more stable by feeding back the output signal to the RES terminal, fine tuning the reference voltage, and providing hysteresis with the VLMI and the VLMZ. (VLMI is a voltage during the shifting ~HITACHI 213 from operation to resetting, and VLM2 is the voltage in recovering.) 3.4 Manual Reset Circuit (1) Purpose When the MCU is reset by an external switch, it is necessary to prevent the MCU from chattering. The following describes a reset circuit in which chattering prevention and power-on reset functions are provided. (2) Basic Circuit Fig. 3-5 shows the basic circuit of manual reset. Vee Vin Vou! ~-- To the RES pin r HDaLSu Fig. 3-5 Basic Circuit of Manual Reset (3) Operation Principle (i) Power-on reset During power-up, the capacitor C will be charged and the Yin rising time will be delayed by the CR charge time, so that power-on would be reset normally. Vee V L-~----- Vin t=CxR (ii) Manual reset When SW is on, the Vout goes "0" and the MCU is reset When SW is off, the capacitor C is charged, so that the rising time of Yin is delayed by the CR charge time. ~HITACHI 214 Chattering is prevented by the capacitor C and the schmidt trigger HD74LS14. OFF --1f-----ON - - - - t - - OFF 00 When SW OFF -- ON, sw Vout = GND when Yin < O.BV ® When SW ON -- OFF, Vout = VCC when Yin > 1.6V Vi n Vout 3.5 AID Converter Circuit (1) •.• High Speed (1) Purpose The following describes how to implement a simple AID conversion (analog-digital conversion) using the resistance radder (R-2R system). (2) Basic Circuit Microcomputer Vin Analog "':":':':-'---II~ v: Voltage of the output Input "1" of the port V =(~+Dn-I + ... +!!L+~ ) x V REF 2 2' zn-r 2n R Vout = 0 : Vin ;;;;;VRI!F 2R V Vout = 1 : Yin >VREF Port Necessary number of r----t~----------Vin port=Accuracy bit+l VREF 2R Fig. 3-6 AjD Converter Basic Circuit Vo"ut" r--t-- 1 M " ~ Fig. 3-7 Timing Chart ~HITACHI 215 (3) Operation Outline The following describes the operation outline of 3-bits A/D converter circuit. (i) The digital outputs (D3, D2, Dl) are changed from (1, 1, 1) to (0, 0, 0) at the port. VREF is reduced from 7/8 V to 0 by every 1/8 V according to Table 3-1. (ii) The output Vout • which is the result of comparison between the analog input Vin and VREF, is reversed from "0" to "1" when Vin is greater than VREF as shown in Fig. 3-7. (iii) The value of (D3, D2, D1), when Vout is reversed from "0" to "1", is a digital value to the analog input Vin. Table 3-1 Value of VREF D3 D2 D1 VREF 0 0 0 0 0 0 1 1/8 x V Dl '" D3 are denoted by "1" or "0" 0 1 0 2/8 x V V: Voltage of the port output "I" 0 1 1 3/8 x V 1 0 0 4/8 x V 1 0 1 5/8 x V 1 1 0 6/8 x V 1 1 1 7/8 x V ~HITACHI 216 3.6 AID Converter Circuit (2) ... Low Speed (1) Purpose The following describes the A/D conversion system utilizing time for charge/discharge to/from the CR circuit. This conversion system is available even if the A/D conversion time is slow. (2) Basic Circuit Operation Microcomputer amplifier HAl7902 Yin Analogo---------~ Input A Number of port Yin R VaEl' required = 2 I A Port ;;;0 Vout Fig. 3-8 AID Converter Basic Circuit n : Count Timer value T =To x n To: Timer Interval Fig. 3-9 Timing Chart (3) Operation Outline (i) Set the output terminal A of the port to "1", discharge the external condenser C for a sufficiently long period, decline A from "1" to "0" synchronously with the timer interrupt and charge C. (ii) Check Vout for each timer interrupt and observe the time T in which Vout declines from "1" to "0". Vout becomes "0" when Yin is less than VREFo Obtained as T=TO x n. (iii) The obtained time T which is voltage converted is a digital value of the analog input Yin. ~HITACHI 217 AID conversion subroutine 3.7 Precautionj- Board Design of Oscillation Circuit When connecting crystal and ceramic resonator with the XTAL and EXTAL pins to oscillate, observe the followings in designing the board. (1) Locate crystal, ceramic resonator, and load capacity Cl and C2 as near the LSI as possible. (Induction of noise from outside to the XTAL and EXTAL pins may cause trouble in oscillation.) (2) Wire the signal lines to the neighbouring XTAL and EXTAL pins as far apart as possible. (3) Board design of situating signal lines or power supply lines near the oscillator circuit as shown in Fig. 3-11, should not be used because of trouble in oscillation by induction. The resistor between the XTAL and EXTAL, and pins close to them should be 10Mn or more. ..; Oil ....III .... <= 00 ~ 00 ..... ..... '{J '"II I ---- Signal C I I Cl XTAL --, I I cf:;~ XTAL Cl--~~f-, ~ I I I EXTAL CI--+-~f-'l I T .. EXTAL f--I I I I I ;2 -.J,. I I I I HD6305X HD6305X HD6305Y HD6305Y HD63P05Y HD63P05Y Fig. 3-10 Design of Oscillation Fig. 3-11 Example of Circuit Causing Circuit Board Trouble in Oscillation ~HITACHI 218 3.8 Precaution; - Program of Write Only Register Read/Modify/Write instructions are unavailable for changing the contents of Write Only Register (e.g. DDR; Data Direction Register of I/O port) of HD630SX, HD630SY and HD63POSY. (1) Data cannot be read from Write Only Register. (e.g. DDR of I/O port) While Read/Modify/Write instructions are executed in the following sequence. (i) Reads the contents from appointed address. (ii) Changes the data which has been read. (iii) Turn the data back to the original address. Thus, Read/Modify/Write instructions cannot be applied to Write Only Register such as DDR. (2) For the same reason, do not set DDR of I/O port using BSET and BCLR instructions. (3) Stored instructions (e.g. STA and STX, etc.)are available for writting into the Write Only Register. 3.9 Precaution. - Sending/Receiving Program of Serial Data Reading from or Writing into the SCI data register (SDR:$0012) during sending/receiving of serial data may make sending/receiving operation of SCI out of order. ~HITACHI 219 3.10 Precaution; - WAIT/STOP Instructions Program When I bit of condition code register is "1" and interrupt (INT, TIMER/INTZ, SCI/TIMERZ) is held, the MCU does not enter into WAIT mode by executing WAIT instruction. In that case, after the 4 dummy cycles, the MCU executes the next instruction. In the same way, when external interrupts (INT, 1NT2) are held at the bit I set, the MCU does not enter into the STOP mode by executing STOP instruction. In that case the MCU executes the next instruction after the 4 dummy cycles. 3.11 Precaution; - 1b use the ERPOM ON-PACKAGE 8-hit Single-chip Microcomputer Please be careful of the following, since this MCU has a special structure with pin socket on the package. (1) Do not apply high static volcage or surge voltage over MAXIMUM RATINGS to the socket pins as well as the LSI pins. Otherwise permanent damage to the device would be caused. (Z) When using 3Zk EPROM (Z4-pin) , insert it leaving the four pins above open. (3) When inserting this into system products like mask ROM type single chip microcomputer, be careful of the following to give effective contact between the EPROM pins and socket pins. ~HITACHI 220 (a) When soldering the LSI onto a printed circuit board, the recommended condition is: Temperature: lower than 250°C Time: within 10 sec. (b) Be careful that detergent or coating does not get into the socket during flux washing or board coating after soldering, because that may adversely affect the socket contact. (c) Avoid permanent application of this during continuous vibration. (d) The socket, when repeatedly inserted and removed, loses its contactability. It is recommended to use a new one when used in production. 4 Pins (On index side) open. 24 Pin EPROM should be inserted on the mark side with 4 above open. o o o o o o o o o o o 0 a.4G2 JAPAN 1IiVHD63P05VO/Vl • HITACHI 221 4. PIN ARRANGEMENT AND DIMENSIONAL OUTLINE • HD630SXO, HD630SYO Vss G. RES G, 00 G, STBY G, XTAL G. EXTAL G. NUM G. TIMER G, A, F, A. F. A. F. A. F. A, F, A, F, A, F, A. B, F. E, (FP-64) B. E. B, E. B. E. B, E, B, E, B, E, C./Tx III B. E. CdT. e./Rx 0, D.IiN"T, CVRX~"~.~"~=~=~:~~~~w."~~~.w.~.~.~ c,/CK D. l~uuuuuJlOQQQQ~ C. D. u ~ C, 0, C, 0, C, 0, C. Vee • HD630SX1, HD630SX2, HD630SY1, HD630SY2 Vss OATAo RES DATA, DATA, "'< "'< I>• ~ f. < ~i "" ~ ~ I~ I~ :: ~ ~ "~ ~ ~ ~ DATAl XTAL DATA4 ~ " z EXTAL NUM DATA. DATA, ~ • •• i ~ ~ •• •• •• TIMER DATA 7 A, E A. A/W A, ADRll A. AOR'2 A, ADR" A, ADR,o A, A. ADA. ADA, (FP-64) B, ADR7 B, ADA, B, ADA, B. ADR4 B, ADA, B, ADA, B, ADA, at ADR~ B. ADA. 311 D. c,rr. 0, i1I;:;~=:;:I3=~fi~i;;:g CI/R. DI/mT; ~ u ;;,; U r5 ~ Q 0 Q 0 Q!~ C,/CK D. C, d D. C, 0, C, OJ C, 0, C. Vee ~HITACHI 222 • HD63POSYO • HD63POSYl v,, a Go v•• a DATAo lIES G, lIES DATA, 11iIT 3 G, 11iIT 3 DATA2 mv IG, mIV 1 DATA3 XTAL G. XTAL DATA. EXTAL G, EXTAL DATA, NUM G. NUM DATA, TIMER OVec VecO G, TIMER OVec VecO DATA? A, • F, A, E OAn VecO A. OAu VccO A. F. RtW A, " OA, VecO F, Aa 11 OA, VecO AOR13 A.I 10,0 F. Aol OA. ADRI2 OAo AoC A, F, A, ADRI1 A, OA, A.O A, OA, A,O ADR,o A,I F, A,I ADRo OA. A11 0 OAo AuO Ao Fo Ao ADRo OA, VssO E, OA, VssO B" ADR? B., OA, A,oO E. OA, A,oO ADR, E, ADA, B" OA, ao E. B. OA, ao ADR. OAo 0,0 E, OAo 0, 0 ADR:. B, E, B, AOR2 000 0.0 000 0.0 B, E, B, Bo 00, 0,0 1 Eo Bo 00, 0,0 C7/Tx 00, 0, C,/T. 00, 0, O. 0 O. 0 e./Rx D./ll'lTi e.!Rx Oe/iNT2 aVss 0, 0 0, OVss 0, 0 C./l:R C,/l:R 7 0, C. D. C. D. C, D, C, 0, C, D, C, 0, C, 1 D, C, 1 0, Co Vee Co Vee ~HITACHI 223 • DP-64S (Unit: mm(inch) 57.6(2.268) 58.6max.(2.307max.) 33 o 1.0 32 (0.039) 19.05 .£ 1 ;~ 1 (0.750) ~:1r-----\ "'~")' (0.070±0.010) (0.019 ± 0.004) ~ ~ O'~ IS' ~~.0IO:~.8g. 8 eFP-64 2.9max. (0.114max.) ---l-. OISt O.OS (0006' 0.002) ~0'.15' (O~ - 1.110 0 .3 . L--.--=D:-:::C:-_-=6:-:::4-=S~P:-----------·--~~-- _._- 57.3 (2.256) o o 32 Note) Inch value indicated for your reference. Fig. 4-2 Dimensional Outline ~HITACHI 224 5. ELECTRICAL CHARACTERISTICS 5.1 Electrical Characteristics of HD6305XO, HD6305YO, HD63P05YO • ABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply voltage Vee -0.3 'V +7.0 V Input voltage Vin -0.3 'V Vee + 0.3 V Operating temperature Topr 0 'V +70 °e Storage temperature Tstg -55 'V +150 °e [NOTE] These products have a protection circuit in their input terminals against high electrostatic voltage or high electric fields. Neverthless, be careful not to apply any voltage higher than the absolute maximum rating to these high input impedance circuits. To assure normal operation, we recommende Vin' Vout ; VSS ~ (V in or Vout ) ~ Vee ~HITACHI 225 .. ELECTRICAL CHARACTERISTICS • DC Characteristics (Vee = 5.0V ± 10%, Vss GND and Ta unless otherwise specified) Item Symbol Test min max Unit condition typ RES , STBY Vee-0 •5 - Vee +0 • 3 V Input voltage EXTAL VIR Vee xO . 7 - Vec+0.3 V "High" Others 2.0 - Vee+0 .3 V Input volt- age "Low" All Inputs VIL -0.3 - 0.8 V Operating - 5 10 rnA Current * Wait - 2 5 rnA lee f=lMHz** dissipation Stop - 2 10 ]JA Standby - 2 10 ].lA Input TIMER, leakage INT, IIILI - - 1 ]JA current STBY,D 1"'D 7 Vin=0.5'" Vec-°. 5V Ao '" A7, Three- BO '" B7 , state eO '" e 7 , Go '" G7 , IITSII - - 1 ]JA current EO '" E ** 7 '** FO '" F7' Input *** All f=lMHz, capacity terminals e in Vin=OV - - 12 pF * The value at f=XMHz is given by lee (f=XMHz) = Iee(f=lMHz)xX. VIH min = Vee - 1.OV, VIL max 0.8V. For HD63P05YO, lee of EPROM is not included. ** In Standby Mode *** HD63P05YO is MAX l5pF ~HITACHI 226 • AC Characteristics (V CC ~ 5.0V ± 10%, Vss = GND, Ta = 0 ~ +70·C, unless otherwise noted) HD6305XO/YO HD63A05XO/YO HD63B05XO/YO Test HD63P05YO HD63PA05YO 1ID63PB05YO Item Symbol Condition Unit min typ max min typ max min typ max Clock Frequency fcl 0.4 - 4 0.4 - 6 0.4 - 8 MHz Cycle Time tcyc 1.0 - 10 0.666 - 10 0.5 - 10 ~s INT tcyc tcyc tcyc Pulse Width tIWL +250 - - +200 - - +200 - - ns INT2 tcyc tcyc tcyc Pulse Width tIWL2 +250 - - +200 - - +200 - - ns RES Pulse Width tRWL 5 - - 5 - - 5 - - tcyc TIMER tcyc tcyc tcyc tTWL Pulse Width +250 - - +200 - - +200 - - ns Oscillation CL=22pF±20% Start Time (Crystal) tosc Rs=60fl max - - 20 - - 20 - - 20 ms Reset external Delay Time tRRL capacitance 80 - - 80 - - 80 - - ms 2.2~F • Port Characteristics (V CC 5.0V ± 10%, Vss GND, Ta 0 ~ + 70·C, unless otherwise noted) Item Symbol Test Condition min typ max Unit IOH = -200~A 2.4 - - V Output "High" Voltage VOH Port A, B, C, G, IOH = -lO~A Vcc -0.7 - - V E, F Output ''Low'' Voltage VOL IOL = 1.6mA - - 0.55 V Input "High" Voltage VIH 2.0 - Vcc +0.3 V Input "Low" Voltage Port A, B, C, D, VIL -0.3 - 0.8 V G V.l.n = 0.5 ~ Input Leakage Current IIILI -1 - 1 ~A VCC-O .5V ~HITACHI 227 • SCI Timing (VCC = S.OV ± 10%, Vss = GND, Ta = 0 ~ +70'C, unless otherwise noted.) HD630SXO/YO HD63AOSXO/YO HD63BOSXO/YO Test HD63POSYO HD63PAOSYO HD63PBOSYO Item Symbol Unit Condition min min max m:i.n typ max typ max typ Clock Cylce Time tScyc 1 - 32768 0.67 - 2184S O.S - 16384 jJs Data Output Delay Time tTxn Fig. 6-1 - - 2S0 - - 2S0 - - 2S0 ns Fig. 6-2 Data Set-up Time tSRX 200 - - 200 - - 200 - - ns Data Hold Time tHRX 100 - - 100 - - 100 - - ns tscyc Clock Output 2.4V C5/~ O.6V O.6V O.6V trxD Data Output 2.4V C7/Tx O.6V _____ ~ ~::..~=-------t-HR-X----------~~-:;.;;~-..;..~}'- __ ~::(.,.-----_ Fig. 5-1 SCI Timing (Internal Clock) tscyc -- ..._--- Clock Input 2.0V Cs/CK O.8V O.8V O.8V Data output C.]/Tx CSRX tHRX Data Input C6/Rx X 2 OV . O.8V ~.~~~ :~ ,I Fig. 5-2 SCI Timing (External Clock) ~HITACHI 228 Vee TTL Load (Port) 2.4kQ Test point oo--__....___...:lo:L:=:':::;.• 6:m:A.... terminal 40pF '2kQ [NOTES) 1. The load capacitance includes stary capacitance caused by the probe, etc. 2. All diodes are 152074 ® Fig. 5-J 'lest Load ~HITACHI 229 5.2 Electrical Characteristics of HD6J05Xl/X2, HD6J05Yl/Y2, HD6JP05Yl • ABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply voltage Vee -0.3 tV +7.0 V Input voltage Vin -0.3 tV Vee + 0.3 V Operating temperature Topr 0 tV +70 °e Storage temperature Tstg -55 tV +150 °e [NOTE] These products have a protection circuit in their input terminals against high electrostatic voltage or high electric fields. Notwithstanding, be careful not to apply any voltage higher than the absolute maximum rating to these high input impedance circuits. To assure normal operation, we recom- mended Vin' Vout ; VSS ~ (Vin or Vout ) ~ Vee ~HITACHI 230 • ELECTRICAL CHARACTERISTICS • DC Characteristics (V CC = S.OV ± 10%, VSS GND, Ta 0 ~ +70°C, unless otherwise specified.) Item Symbol Test Condition min typ max Unit RES, STBY VCC-O.S - VCC +0.3 V Input voltage EXTAL VIH VCC XO.7 - VCC+0.3 V "High" Others 2.0 - VCC +0.3 V Input volt- age "Low" All Input VIL -0.3 - 0.8 V Output I OH = -20 0lJA 2.4 - - voltage All Output VOH V "High" lOW -lOlJA VCC- 0 . 7 - - Output volt- age "Low" All Output VOL IOL =1.6mA - - O.SS V Input TIMER, INT, leakage Dl ~ D7, IIILI - - 1.0 lJA current STBY Vin=O.S ~ AO ~ A7' BO ~ B7, VCC - O.SV Three- Co ~ C7 , state ADRo IITSII - - 1.0 lJA ~ ADR13, * current DATAO ~DATA7' E*, R/W* Operating - S 10 mA Current** Wait - 2 5 mA dissipation ICC f = lMHz*** Stop - 2 10 lJA Standby - 2 10 lJA Input**** All f = lMHz, capacity terminals Cin Vin = OV - - 12 pF * At standby mode ** VIH min = VCC - 1.OV. VIL max 0.8 V. For HD63POSYl, ICC of EPROM is not included. *** The value at f xMHz can be calculated by the following equation: ICC (f = xMHz) ICC (f = lMHz) multiplied by X. **** HD63POSYI is MAX. lSpF ~HITACHI 231 • AC Characteristics (VCC = 5.0V ± 10%, Vss =GND, Ta = 0 ~ +70°C, unless otherwise specified.) HD6305Xl/X2/Yl/Y2 HD63A05X1!X2/Yl/Y2 HD63B05Xl/X2/Yl/Y2 Item Symbol Test HD63P05Yl HD63PA05Yl HD63PB05Y1 Unit Condition min typ max min typ max min typ max Cycle Time tcyc 1 - 10 0.666 - 10 0.5 - 10 IlS Enable Rise Time tEr - - 20 - - 20 - - 20 ns Enable Fall Time tEf - - 20 - - 20 - - 20 ns Enable Pulse Width ("High" PWEH 450 - - 300 - - 220 - - ns Level) Enable Pulse Width PWEL 450 - - 300 - - 220 - - ns ("Low" Level) Address Delay Time tAD Fig. 6-4 - - 250 - - 190 - - 180 ns Address Hold Time tAH 40 - - 30 - - 20 - - ns Data Delay Time tDW - - 200 - - 160 - - 120 ns Data Hold Time tRW 40 - - 30 - - 20 - - ns (Write) Data Set-up Time (Read) tDSR 80 - - 60 - - 50 - - ns Data Hold Time (Read) tHR 0 - - 0 - - 0 - - ns ~HITACHI 232 • Port Timing (VCC - 5.0V ± 10%, Vss - GND, Ta = 0 ~ +70·C, unless otherwise noted.) HD6305Xl/X2/Yl/Y2 HD63A05Xl/X2/Yl/Y2 HD63B05Xl/X2/Yl/Y2 Item Symbol Test HD63P05Y1 HD63PA05Y1 HD63PB05Y1 Condition Unit min typ max min typ max min typ max Port Data Set-up Time (Port A, B, tpDS 200 - - 200 - - 200 - - ns c, D) Fig. 6-5 Port Data Hold Time (Port A, B, tPOH 200 - - 200 - - 200 - - ns C, D) Port Data Delay Time (Port A, B, tpDW Fig. 6-6 - - 300 - - 300 - - 300 ns C) • Control Signal Timing (VCC = 5.0V ± 10%, Vss = GND, Ta 0 ~ +70·C, unless otherwise noted.) HD6305Xl/X2/Yl/Y2 HD63A05Xl/X2/Yl/Y2 HD63B05XI/X2/YI/Y2 Item Symbol Test HD63P05Y1 HD63PA05Y1 HD63PB05Y1 Condition Unit min typ max min typ max min typ max INT Pulse tcyc tcyc tcyc Width tIWL +250 - - +200 - - +200 - - ns IRT2 Pulse tcyc - tcyc - tcyc Width tIWL2 +250 - +200 - +200 - - ns RES Pulse Width tRWL 5 - - 5 - - 5 - - tcyc Control Set- up Time tcs Fig. 6-8 250 - - 250 - - 250 - - ns Timer Pulse tcyc tcyc tcyc Width tTWL +250 - - +200 - - +200 - - ns Oscillation Start Time tosc Fig. 6-8* - - 20 - - 20 - - 20 ms (Crystal) Reset Delay Time tRHL ** 80 - - 80 - - 80 - - ms * ~ = 22pF±20%, RS 60n max. ** 2.2 IlF • HITACHI 233 • SCI Timing (VCC = 5.0V ± 10%, Vss = GND, Ta = 0 ~ +70°C, unless otherwise noted) HD6305Xl!X2!Yl!Y2 HD63A05Xl!X2!Yl!Y2 HD63B05Xl!X2!Yl!Y2 Test HD63P05Y1 HD63PA05Yl HD63PB05Yl Item Symbol Unit Condition max min typ max min typ min typ min Clock Cycle Time tScyc 1 - 32768 0.67 - 21845 0.5 - 16384 ]1s Data Output Delay Time t Txn Fig. 6-9 - - 250 - - 250 - - 250 ns Data Set-up Fig. 6-10 Time tSRX 200 - - 200 - - 200 - - ns Data Hold Time tHRX 100 - - 100 - - 100 - - ns 1---------tCYC---------~ E PWfl PWfH t" Ao--A13 2.4V Address Valid R/W O.6V tow MCU Write DATAo-DATA7 MCU Read 2.0V DATAo-DATA7 O.SV Fig. 5-4 Bus Timing MCU Read \MV~·/ E 2.4V E etpow Port Port 2.4V Data A,B,C,D A,B,C _ _ _ _ _ _ _--' O.6V Valid Fi,g. 5-5 Port Data Set-up and Hold Times Fig. 5-6 Port Data Delay Time (MCU Read) (MCU Write) $ HITACHI 234 Interrupt Test E Address Bus Address Address Address PCo- PC7 Data Bus Op Code Operand Irrelevant Qp Code Data PCe- IX CCR ~e~~o, ~;~to, First Inst. of ,-------'/ PC'3 Add'essAdd,ess Interrupt Routine ...... Fig. 5-7 Interrupt Sequence E ==:=u-L ~r~\\\\\\\\\\\\\ ~ Vee ~, : _Io_sc-_-_-_-".-1---+--------< Vec-O.5V ~JVee-05V t-Iosc-J ~~, ________ ~~-JI Vee- O.5V L>__,____ Address Bus .--I///II////!I/~ 1FFF R/W 7lI!llllj}1lllIJljJ r,:J-.~I!WJ Dala Bus wa~,_,---------;s,~-{1Nff!l§,}-- Fig. 5-8 Reset Timing tscyC .-.------i Clock Output 2.4V Cs/CK O.6V Data Output C7/Tx Data Input C6/ Rx ________ ~t ~~~~ ___________t_H_RX__ -~~_-_-~_~~~----~:~:----------_ __ Fig. 5-9 SCI Timing (Internal Clock) ~HITACHI 235 tscvc - Clock Input 2.0V Cs/C'i< 0.8V Data Output C7/Tx ) r ~2.0V SRX tHRX 20V~ :( 0.8V 0.8V .1 Fig. 5-10 SCI Timing (External Clock) Vee TTL Load (Port) IOl = 1 .6mA 2.4kQ Test point oo---_--_:::.=~=_J terminel c 12kQ C =90pF for E, R/W, APRo'VADR13, DATAO'VDATA7 C = 40pF for A, Band C PORT [NOTES] 1. The load capacitance includes stary capacitance caused by the probe. etc. 2. All diodes are 1S2074 <8>. Fig. 5-11 Test Load • HITACHI 236 6. ROM CODE ORDER METHOD User's programs are mask programmed into ROM by Hitachi to be shipped as LSI. The users are requested to hand in three EPROMs in which the same contents are written, ordering specifications and list of the ROM contents. Relationship between the address of the mask ROM and that of the EPROM is shown in Table 6-1. Write $FF for the unused address data of EPROM. Table 6-1 Relationship between the Address of Mask ROM and that of EPROM Type Name Address of Mask ROM Address of EPROM Remarks HD630SXO $1000 $000 2 2 HN482732A or HD630SXl their equivalent $lFFF $FFF $0140 $140 2 HN482732A or 2 $OFFF $FFF their equivalent HD630SYO HD630SYl $1000 $000 2 HN482732A or 2 $lFFF $FFF their equivalent HD6305YO $0140 $0140 2 2 HN482764 or HD6305Yl their equivalent $lFFF $lFFF ~HITACHI 237 IAPPENDIX I I. DESIGN PROCEDURE AND SUPPORT TOOL Cross assembler and Hardware emulator, containing various kinds of computers, are available as supporting systems to develop user's programs. Hitachi will mask program user's programs into ROM to ship them as LSI. Fig. 1-1 shows a typical program design procedure and Table 1-1 summarizes a set of system development supporting tool for the HD6305 MCU. Text Editor Host Computer Cross Assembler Host Computer Emuletor EPROM On-Chlp LSI, HD63P05Y Fig. I-I Program Design Procedure ~HITACHI 238 The following explains the system development procedure. 1. Specify functional assignment of I/O pins and allocation of RAM area before starting programming. 2. Design flowchart to implement the functions and encode this flow·' chart with mnenic codes. 3. Punch the coded format onto cards or paper tape, or write it on a floppy disk. This set of coded form is a source program. 4. Assemble the source program to form an object program with cross system. Then check errors out. 5. Verify the program through hardware simulation with an emulator or EPROM on-package microcomputer. 6. Send the completed program in EPROM to Hitachi. 7. After Hitachi received user's specified ROM pattern and options, Hitachi will fabricate sample LSI for user's evaluation for the functions. If a user finds no problem in the sample LSI, Hitachi will start mass production of the LSI. Table I-1 System Development Support ~ol EPROM IBM PC Type No. Emulator On-Package LSI Cross Assembler HD6305XO/X1/X2 H35MIX5 HD63P05YO/Yl S35IBMPC HD630 5YO/Yl/Y2 (HS35YEML05H) ~HITACHI 239 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 -«) x Current AID 0 0 x x o--x x~ x Stand-by 0 0 0 x o--x 1"-01<»-'" x x :OFF O:ON ~ : Change the state Figure 2-9 Self Check Connections • HITACHI 264 2.7 Internal Oscillator Options The MCU contains two oscillators: oscillator 1 for system clock supply, and oscillator 2 for time base interruption and LCD drivers. (1) Oscillator 1 (OSCl) The internal oscillator circuit can be driven by connecting a crystal or a resistor between X~L and EX~L. A manufacturing mask option is available for selecting better matching between the external components and the internal oscillator at start up. Figure 2-10 shows the connection of oscillator circuit. A resistor selection graph to determine oscillation frequency of RC oscillator is given in Figure 2-11. When RC oscillation, the oscillation can be stopped by mask option in halt status. This saves consuming power when halting. (2) Oscillator 2 (OSC2) Clocks are supplied to Timer, Time Base, A/D Converter, and LCD Drive Circuit from OSC2 by connecting 32.768 kHz of crystal to XIN and XOUT. OSC2 operates even in the halt status, which permits the MCU to implement intermittent action indicating LCD status. In standby status, this frequency divider stops, while OSC2 keeps I on operating to maintain restart time after it has been relieazed from the instruction. Figure 2-12 shows the connection between OSCI and 2, while Figure 2-13 and 2-14 shows the relations between them. Mask options are available for deciding if OSC2 is used or not. When OSC2 is not used, OSC1/12 will be provided to the peripheral circui t as 4>32k. In this case, fix Xin pin to Vce. Figure 2-14 shows the combinations of selectable mask-options and the corresponding system operation statuses. Refer to this figure in selecting mask-options on oscillation circuit. ~HITACHI 265 EXTAL EXTAL Crystal Rs-l kSl = XTAL HD63L05 MCU 100 kll Typ. HD63L05 MCU 10pF XTAL vcc6 Crvstal Oscillator RC Oscillator EXTAL EXTA.L HD63L05 Ext. Clock Ext. Clock XTAL MCU Input XTAL MCU Input Ext. Clock Ext. Clock Crystal Option Resistor Option Figure 2-10 Mask Option for Oscillator1 ,...... 500 \ I VCC =3.0V - \ N Ta=25°C ;';2 '-' 400 300 \" >- ~ -- tJ I:l Q) ::l 200 ........... 0" Q) 'r..."' r--- f--. 100 0 100 200 300 400 500 600 700 Re sistance ( krl ) Figure 2-11 .Typical Resistor Selection Graph ~HITACHI 266 Crystal XOUT Rs=20kO= HD63L05 fCl; frequency of OSC1 XIN MCU 1/>32K; C clock for peripheral 10pF veeT Crystal Oscillator Time base Interrupt LCD XOUT Clock HD63L05 XIN MCU Vee No. U.... Figure Z-13 Relation between Oscillator1 and Oscillator2 Figure 2-12 Connection of Oscillator2 Combinations of Mask Option System Operation ~ Halt Stand-by Delay Time(s) At At OSCI Type OSC2 Other Options 0 1/16 1/2 1 System OSCI 0 x Used x x 0 0 CPU x x *2 Peripheral 0 x *1 Absent Not OSCI 0 x Crystal Stand-by 0 0 0 0 CPU x x Used Oscillation Peripheral 0 x OSCI 0 x Used x x 0 0 CPU x x Peripheral 0 x Present Stand-by aSCI 0 x Not CPU x x 0 0 0 0 Used Peripheral 0 x aSCI x x aSCI x x x CPU x x aSCI 0 Stops x ascilla- Peripheral 0 *2 tion at aSCI 0 x *3 Absent aSCI x x Stand-by 0 0 0 0 CPU runs x CR Peripheral 0 ascnlation aSCI x aSCI Stops x x x - - - ascilla- Present tion at aSCI 0 x aSCI x x Stand-by CPU 0 0 0 0 runs Peripheral x 0 0 . Selectable .. 0 ... run x . Unselectable .. x stop ... Note *1 In selecting crystal oscillat1on, aSCI cannot be stopped 1n halt status. *2 Delay time cannot be accurate without aSC2. *3 In selecting CR oscillation, stand-by operation is available for any options. Figure 2-14 Oscillator2 Mask~option and System Operation $HITAGHI 267 (3) Stand-by The MCU goes into stand-by mode when STAND-BY is pulled "High". In this status, all circuits, except OSC2, stop functioning holding current status. (Time Base, Timer, AID Converting Data are not held). OSC1 restarts oscillating by pulling STAND-BY "Low". Then the CPU restarts its operating sequence after delay time for oscillation stability has passed. CPU operation must be masked after the CPU has been released from stand-by mode until OSC1 oscillation is stabilized. This is because OSC1 stops functioning in the stand-by mode. For this reason, the HD63L05 MCU contains a frequency divider as a delay circuit, which permits the CPU to gain the accurate delay time if OSC2 is provided. Users should be careful when OSC2 is not provided, because the CPU starts functioning after ~J2k has been divided by the inter- nal divider corresponding to the selected delay time. This frequency circuit also operates just after reset. Don't input S~D-BY again during the delay time, because it will cause the system to malfunction. As a result, delay time is calculated as: [(J2768 Hz)/(OSC1)] x delay time. 12 2.8 Interruptions There are six different interruptions to the MCU: external inter- ruption through external interruption pin (INT), internal timer interruption, interruption by termination of AID conversion, time base interruption (2 types), and software interruption by an instruction (SWI). When any interruption occurs, processing is suspended and the present MCU status is pushed onto the stack. The interruption mask bit (I) in the Condition Code Register is set, the address of the interruption routine is obtained from the appropriate interruption vector address, then the interruption routine is executed. When RTI instruction has been completed, the MCU continues processing recovering the MCU status by RTI instruction. Table 2-1 provides a listing of the interruptions, their priority, and the vector addresses. In case a number of interruptions occurred simultaneously the MCU processes them according to the priority. Figure 2-15 shows the system operation flow, in which the portion surrounded with dot-dash line shows an interruption execution sequence. Note: A clear interruption bit instruction (CLI) allows to suspend the processing of the program by an interruption after execution of the next instruction while a set interruption bit instruction (SEI) inhibits any interruptions before execution of the next instruction. ~HITACHI 268 When a mask bit of a control register is cleared by an instruction, interruption is allowed before execution of the next instruction. (1) Acknowledging interruptions in HALT Status In HALT status, the CPU stops functioning, while the peripheral circuit are operating. When an interruption is acknowledged, the CPU reads the head address of the interruption routine from the vector address corresponding to the interruption condition. Then the CPU executes interruption service to meet the interruption condition. (2) Acknowledging interruptions in Stand-by Status In Stand-by status, the system stops with power is supplied to it. Any interruption request (including RES) is therefore, ignored. Table 2-1 Interruption Priority Interruption Priority Vector Address RES 1 $FFE, $FFF SWI 2 $FFC, $FFD INT 3 $FFA, $FFB TIMER 4 $FF8, $FF9 AID 5 $FF6, $FF7 TIME BASE 6 $FF4, $FFS ~HITACHI 269 - Opo'otlon Soq- sa,_ Figure 2-15 System Operation Flowchart ~HITACHI 270 2.9 Input/Output (Port A,B,C) There are 20 input/output pins. All pins can be programmed either as inputs or outputs under software control of the Data Direction Register. When programmed as outputs, all I/O pins read output data of the programmed logic level even if the actual output level is affected by output load (Refer to Figure 2-16). (1) Port Configuration Figure 2-17 shows the port configuration. Each pin can individually select four types of configurations by mask option. The following explains these. A: This port configuration is of general type. B: This configuration contains pull-up resistance to prevent input from floating when using the port as an input. Select this con- figuration in stich cases as connecting the switch to port directly. C: This port configu1ation is for driving key matrix. If key matrix is driven under this port configuration, the CPU can read the necessary data precisely, even if more than two keys are pushed simultaneously. D: This port configuration is NMOS open drain output, which is convenient for removing wired OR or driving transistor circuit. Users should be careful of the maximum output voltage of open drain output. Output voltage of open drain output covers from "OV" to "VCC"· 2.10 A/D Converter The MCU contains an 8-bit A/D converter based on the resistor ladder system. Figure 2-18 shows its block diagram. The "High" side of reference voltage is applied to VRH ' while the "Low" side of reference voltage is applied to VRL' The reference voltage, which is divided by resistors into voltages matching each bit, is compared with the analog input voltage in order to implement A/D conversion. As the analog input voltage is applied to the MOS gate of the comparator through the analog multiplexer, this voltage comparison system achieves high input impedance. ~HITACHI 271 AID converter provides two modes; AID conversion mode. and program comparison mode. (1) AID Conversion Mode This mode allows the MCU to perform AID conversion automatically. AID conversion starts when AID operating mode selection bit is initialized to "0". and "1" is programmed to AID conversion flag. When AID conversion has been completed. AID conversion flag is automatically reset while AID conversion interruption request flag is set. In response to this interruption request. the MCU loads the head address of AID conversion interruption routine. then executes the interruption routine. AID interruption can be masked by setting AID interruption mask bit to "1". The MCU requires about 2 ms to perform AID conversion itself. However. the MCU requires 4 ms at most to complete the whole AID conversion process. because clock generator is multiplexed with Time Base and LCD drive circuit. (2) Program Comparison Mode This mode allows the MCU to compare the predetermined standard level pro- grammed into the AID data register with the analog input level. When "1" is programmed in A/D operating mode selection bit, the MCU enters into pro- gram comparison mode. Result of the comparison is transmitted to comparison result output bit by programming the digital value co~sponding to standard level and by reading A/D control register. "1" is transmitted when analog input level is higher than standard level, while "0" is transmitted when analog input level is lower. Note that the NCU wastes more consuming power in this mode, because supply voltage is supplied with the comparator con- stantly. AID converter continues functioning even when halting. So halt power does not decrease when AID converter is functioning. In stand-by mode, conversion is suspended and comparat'or source power is off. AID converter sometimes reperforms AID conversion after being recovered from stand-by mode. However, its result cannot be assured. $ HITACHI 272 (3) AID Interruption Request Flag (AID INT) The AID INT bit is set to logical "1" after AID conversion has been completed, and is cleared by system reset. AID INT bit should be reset by program under interruption subroutine. Only logical "0" can be programmed into this bit. (4) AID Interruption Mask (AID MASK) If this bit is set, interruption request from the AID converter is masked. (5) AID Converter Flag (CNV) Set this bit to logical "1" in order to implement AID conversion. During conversion, data of this bit holds "1". The bit is automatically reset to "0" when the AID conversion has been completed. In AID conversion, supply voltage is applied to the comparator only when CNV="l". The digital data, which is obtained by AID conversion, is held in the AID data register. This data is reset when the CNV is set to "1" again. (6) AID Operation Mode Selection Bit (Auto/Program) This bit selects either auto-run 8-bit AID conversion or 8-bit programmed comparator operation (Auto 8 bits AID conversion at "0"). When this bit is reset to "0", the MCU selects the 8-bit AID conversion mode, then performs AID conversion according to the value represented by the AID conversion flag. When this bit is set to "1", the MCU selects Program Compare Mode, which allows the program to compare the value between AID data register and analog input level. (7) CaMP OUT This bit transmits the result of comparator operation between the standard level at AID register and analog input value (Logical "1" means that input voltage is higher than programmed reference voltage). (8) MPX This bit selects 8-channel analog inputs. The multiplexer is an analog switch based on CMOS. ~HITACHI 273 8its of Data 8it Of Out- OutPUt Input to Direction put Dlda Stete MCU Regilter 0 0 0 1 0 3-8ta.. Pin Figure 2-16 Port I/O Circuit Output Output Control Output Circuit Input ,..- .., +---~~~~o-.Input ~- (A) Standard port : Pull-up _J PMOS Vss VCC (B) Port with Input pull-up MOS PMOS with NMOS little lOB Output Output ~---L>O-i~o-.Input L-Doo--!.::>o--_ Input (C) Port for Key matrix (D) Open drain output Fig. 2-17 I/O Port Configuration ~HITACHI 274 ( )-Ma8k Option r---"'"'L~-CH, (CH.l (CH,1 Multi- plexer (CHd Analog Input (CH.l Reference I L...._ _..J'---(CH.l Voltage Input MPX Channel 000 CH, 001 (CH.l 010 (CH,1 011 (CH.l A/D 100 (CH,1 AID CTRL Regl..., Interruption 101 (CH.l ::::::~::::::::::::::::~:::::::::D.QB~ 110 (CH,1 111 (CH.l Figure 2-18 8 Bits AID Converter Block Diagram AID CTRL ';--::-.....L--::-.L-"7"-L.:.:.:~.L--:--L-:-_..,..._,....,JRegilter Figure 2-19 AID Control Register Configuration ~HITACHI 275 2.11 LCD CIRCUIT The system configuration of the LCD circuits is shown in Figure 2-20. 1/3 bias-l/3 duty drive, static drive, or output port con- figuration can be selected in LCD circuit. This selection can be specified by both mask option and duty select bit of system control register. Segment data for display are stored in data registers (LCDI to LCDS). Since the circuits are connected to the output pins through pin location block, users can specify a combination of datas to be multiplexed with the segment output pins. NOTE: In selecting LCD other than 1/3 bias-1/3 duty LCD, specify the Duty bit within 1 rns since reset has been vectored. The bit data of the LCD register (LCDl to LCDS) are combined with the timing clocks ($1, $2 or $3),and three combined bit data are gathered to make a segment output data in 1/3 bias - 1/3 duty drive. In case of static LCD drive or output port, timing is always fixed to $1 (always "High") and one bit data of the LCD register is assigned to segment pin. Note that the output pins (SEGl3 to SEG17) are analog inputs and mask options. When the form of output port is selected by Duty bit ("00"), $WRITE clock and fCL/4 (system clock) can be transmitted every time data is written into LCDI register by setting EXT bit to "1". This signal is also available for connecting the MCU to external circuit easily. All bits of LCDl, LCDZ, LCD3 register are cleared by reset. ~HITACHI 276 2.12 Liquid Crystal Driver Waveforms The LCD circuit is based on 1/3 bias - 1/3 duty driving. Figure 2-21 shows the common electrode output signal waveforms (COMI' COM2. COM3). segment signal waveforms (SEGI to SEG17) and LCD bias waveforms (between COM and SEGMENT). Assignment of segment pins to the bits of the LCD data register. including the case in which segment pins are used as output pins. is to be specified by the user when he orders masks. (Note) •. The pin function (Vl/CR7 or V2/CRS) can be selected by mask options. In case of 1/3 bias - 1/3 duty drive. select VI and V2 in order to reduce supply impedanc.e. For your application. connect 0.1 ~F condensors between VI pin and VCC as well as between V2 pin and VCC. respectively. SEO, SEG. SEO. SEO. SEG. SEG. lEG. SEG. SEG. SEG .. SEGu SEG .. SEG.I SEG.I Sy.tem Congnuof SEQ .. Cont. seG. -SEG., SEO,I Duty SEG n 00 OUTPUTPQRT 01 STATIC LCD 10 11381.. COM, COM, COM, " 113 Dutv LCD _........... 10u,,1 Figure 2-20 LCD Circuit System Configuration ~HITACHI 277 COMMON 1 COMMON 2 COMMON 3 SEGMENT 11,2,31 COM. -SE';MENT COM. -SEGMENT COM.-SEGMENT OUTPUT PORT STATIC LCD Vee Vee ...Jr::::'1 .._.. Output levels .. , .. L:!: fN1ching D•• in Vss Regilter Vss Figure 2-21 LCD Driving Waveforms 2.13 Bit Manipulation The MCU has the ability to set or clear any single random access memory or input/output bit (except the data direction registers) with a single instruction (BSET,BCLR). Any bit in the page zero read only memory can be tested, using the BRSET and BRCLR instructions,and the program branches as a result of its state. This capability to work with any bit in RAM,ROM or I/O allows the user to have individual flags in RAM or to handle single I/O bits as control lines. NOTE It is necessary to pay attention to the system control register, the timer control register,and A/D control register when BSET,BCLR,or Read/Modify/Write instructions are applied to them. If own interruption request occured onto the interruption request bit (bit 7)of the control register between read cycle and write cycle of these instructions,the bit7 might be cleared in the write cycle and not acknowledged by CPU • • HITACHI 278 2.14 Addressing Modes The MCU has ten addressing modes available for use by the programmer. They are explained and illustrated briefly in the fillowing paragraphs. (1) Immediate Refer to Figure 2-22. The immediate addressing mode accesses constants which do not change during program execution. Such instructions are two bytes long. The effective address (EA) is the PC and the operand is fetched from the byte following the opcode. (2) Direct Refer to Figure 2-23. In direct addressing, the address of the operand is contained in the second byte of the instruct~on. Direct addressing allows the user to directly address the lowest 256 bytes in memory. All RAM space, I/O registers and 128 bytes of ROM are located in page zero to take advantage of this efficient memory addressing. (3) Extended Refer to Figure 2-24. Extended addressing is used to reference any location in memory space. The EA is the contents of the two byte following the opcode.Extended addressing instructions are three bytes long. (4) Relative Refer to Figure 2-25. The relative addressing mode applies only to the branch instructions. In this mode the contents of the byte following the opcode are added to the program counter when the branch is taken. EA=(PC)+2+Rel. ReI is the contents of the location following the instruction opcode with bit 7 being the sign bit. If the branch is not taken, Rel=O. When a branch takes place, the program goes to somewhere within the range of +129 bytes to -127 of the present instruction. These instructions are two bytes long. (5) Indexed (No Offset) Refer to Figure 2-26. This mode of addressing accesses the lowest 256 bytes of memory. These instructions are one byte long and their EA is the contents of the index register. (6) Index (8-bit Offset) Refer to Figure 2-27. The EA is calculated by adding the contents of the byte following the opcode to the contents of the index register. In this mode,511 lowest memory locations are accessibl:. These instructions occupy two bytes. (7) Indexed (16-bit Offset) Refe.r to Figure 2-28. This addressing mode calculates the EA by adding the contents of two bytes following the opcode to the index register. Thus.the entire memory space may be accessed. Instructions which use this addressing mode are three bytes long. (8) Bit Set/Bit Clear Refer to Figure 2-29. This mode of addressing applies to instructions which can set or clear any bit on page zero. The lower three bits in the opcode specify the bit to be set or cleared while the byte following the opcode specifies the addresss in page zero • • HITACHI 279 (9) Bit Test and Branch Refer to Figure 2-30. This mode of add~essing applies to instructions which can test any bit in first 256 locations ($OO-$FF) and branch to any location relative to the PC. The byte to be tested is addressed by the byte following the opcode • The individual bit within that byte to be tested is addressed by the lower three bits of the opcode. The third byte is the relative address to be added to the program counter if the branch condition is met. These instructions are three bytes long. The value of the bit tested is written to the carry bit in the condition code register. (10) Implied Refer to Figure 2-31. The implied mode of addressing has no EA. A11 the information necessary to execute an instruction is contained in the opcode. Direct operations on accumulator and ,the index register are included in this mode of addressing. In addition,control instructions such as SWI,RTI belong to this group. All implied addressing instructions are one byte long. .HITACHI 280 l-k I ilir===I__ AF8: : J t: A I Index Rea PRQG LOA .1F8 : 05BE.~~A6E3 05BF~ Fa : _____ J Stack Point I Prot! Count 05C0 CCR Figure .2-22 Immediate Addressing Example lEA ,, Me.torY ,, I OO4B ,, t ,,, , / Adder CAT FCB 32 OO4B PROG LOA CAT ffi20 20 B6 , '" 00'00 I I A Stac~ ElliDt 20 Index Reg I I I ffi2E 4B Pro!! Count I ffi2F CCR I , , ~ Figure 2-23 Direct Addressing Example Memory , ~ 0000 =rn]I__ A 40 PROG LOA CAT Index Reg ...J O4OB~ Stack Point , : Prog Count CAT FCB 64 06E5t:J4Q:O=J----------.J 040C CCR Figure 2-24 Extended Addressing Example ~HITACHI 281 Memory :, § A Index ReI , : PROG BEQ PROG2 04A7 r:=J2~7==t-t_.J 04A8 I- 17 Figure 2-25 Relative Addressing Example EA , Me!ory I 0068 :, t ,, ,, / ~ Adder , TABL FCC/LV OOB8 4C Jx) f A 4C I 49 I iirlex-~ea B8 . , Stack POlOt ffiF<~ PROG LOA X Proll Count ffiF5 CCR § ,, Figure 2-26 Indexed (No Offset) Addressing Example r\'lcn~Ory , lEA I (lOBC I i , i f : / ~ Adder TABL FCB s: BF OO~9 BF FCB s: 86 (XJ8A ~6 A FCB s: OB OOl!B DB CF 1 FCB IICF 008( CF r Index Reg ,, ,, 03 1 PROG LOA T ABL,X 075B Stack POint EO 075C 8\1 I I Prog Count I I 075E I I , CCR § ,, ,, Figure 2-27 Indexed (8-Bit Offset) Addressing Example ~HITACHI 282 ,, Me!or~' , LI::A I 0780 I I T I I Adder /' PROG LOA TABL. X 0692 0093 ~ I D6 07 I h ""I DB Index Reg Stack t'oint I A 02 I I I 0694 7E IJ Prog Count I 0695 I I I CCR T ABL FCB II BF 077E HF I I FCB 1186 077F H6 FCB IIDB 0780 DB FCB IICF 0781 CF Figure 2-28 Indexed (16-Bit Offset) Addressing Example lEA I Me,f,OT" 0001 I I I I T PORT B EQU I 0001 PROG BCLR 6. PORT B 1581-" §i I ID , BiI 6 / ~ ~ "" A I I Index ReI! I I 0590 ()\ Sl!!£k~n! I Prog nl I , I m91 I ~ CCR ,, '' e : Figure 2-29 Bit Set/Bit Clear Addressing Example • HITACHI 283 lEA ,, i MeirY I 0002 I , I t PORT C EQU 2 0002 FO '/ Adder "'- A I I ~t ok Index Reg fROO BRCLR 2. PORT C, PROO 2 (1;74 I (I; ,, I :~~n! rog unt : (1;75 02 r----- (XX)() -i (1)94 I (1;76 10 ~l CCR r-f OR C , I 1 ~'" , Adder I / Figure 2-30 Bit Test and Branch Addressing Example ,, Memory ~ , , PROG TAX ffiBA~ ,, ,, § ,,, Figure 2-31 Implied Addressing Example • HITACHI 284 2.15 Instruction Set The MCU has a set of 59 basic instructions. They can be divided into five different types: register/memory, read/modify/write, branch, bit manipulation, and control. The following paragraphs briefly explain each type. All the instructions within a given type are presented in individual tables. (1) Register/Memory Instructions Most of these instructions use two operands. One operand is either the accumulator or the index register. The other operand is obtained from memory using one of the addressing modes. The jump unconditional (JMP) and jump to subroutine (JSR) instructions have no register operand. Refer to Table 2-2. (2) Read/Modify/Write Instructions These instructions read a memory location or a register, modify or test its contents, and write the modified value back to memory or to the register. The test for negative or zero (TST) instruction is an exception to the read/modify/ write instructions as it does not perform the write. Refer to Table 2-3. (3) Branch Instructions The branch instructions cause a branch from the program when a certain condition is met. Refer to Table 2-4. (4) Bit Manipulation Instructions These instructions are used on any bit in the first 256 bytes of the memory. One group either sets or clears. The other group performs the bit test and branch operations. Refer to Table 2-5. (5) Control Instructions The control instructions control the MCU operations during program execution. Refer to Table 2-6. (6) Alphabetical Listing The complete instruction set is given in alphabetical order in Table 2-7. (7) Op-code Map Table 2-8 is an op-code map for the instructions used on the MCU. ~HITACHI 285 Table 2-2 Register!Memory Instructions Addressing Mode Indexed Indexed Indexed Immediate Direct Extended (NoOffse" (8-B it Offset) (16-8it Offset) Operation Mnemonic Op # # Op # # Op # # Op # # Op # # Op # # Code Bytes Cycles Code Bvtes Cycles Code Bytes Cycles Code Bytes Cycles Code Byte. Cycles Code Byte. Cycles Load A from Memory LOA A6 2 2 B6 2 3 C6 3 4 F6 1 2 E6 2 4 06 3 5 Load X from Memory LOX AE 2 2 BE 2 3 CE 3 4 FE 1 2 EE 2 4 DE 3 5 Store A in Memory STA - - - B7 2 4 C7 3 5 F7 1 3 E7 2 5 07 3 6 Store X in Memory STX - - - BF 2 4 CF 3 5 FF 1 3 EF 2 5 OF 3 6 Add Memory to A ADD AB 2 2 BB 2 3 CB 3 4 FB 1 2 EB 2 4 DB 3 5 Add Memory and Carry to A AOC A9 2 2 B9 2 3 C9 3 4 F9 1 2 E9 2 4 09 3 5 Subtract Memory SUB AO 2 2 BO 2 3 CO 3 4 FO 1 2 EO 2 4 DO 3 5 Subtract Memory from SBC A2 2 2 B2 2 3 C2 3 4 F2 1 2 E2 2 4 02 3 5 A with Borrow AND Memory to A AND A4 2 2 B4 2 3 C4 3 4 F4 1 2 E4 2 4 04 3 5 OR Memory with A ORA AA 2 2 BA 2 3 CA 3 4 FA 1 2 EA 2 4 OA 3 5 Exclusive OR Memory with A EOR A8 2 2 BB 2 3 CB 3 4 FB I 2 E8 2 4 08 3 5 Arithmetic Compare A 4 01 CMP Al 2 2 Bl 2 3 Cl 3 4 Fl 1 2 El 2 3 5 with Memory Arithmetic Compare X CPX A3 2 2 B3 2 3 C3 3 4 F3 1 2 E3 2 4 03 3 5 with Memory Bit Test Memory with A (Logical Compere) BIT A5 2 2 B5 2 3 C5 3 4 F5 1 2 E5 2 4 05 3 5 Jump Unconditional JMP - - - BC 2 2 CC 3 3 FC 1 2 EC 2 3 DC 3 4 Jump to Subroutine JSR - - - BO 2 4 CD 3 5 FO 1 3 ED 2 4 DO 3 5 Symbol.: Op· Operation ft • Instruction Table 2-3 Read/Modify/Write Instructions Addressing Mode ,..._----.- Implied (A) Indexed Indexed Implied (X) Direct (No Offset) (8-Bit Offse" Operation Mnemonic Op # # Op # # Op # # Op # # Op # # Code Bytes Cvcles Code Bytes Cycles Code Bytes Cycles Code Bytes Cycles Code Bytes Cycle. Increment INC 4C 1 1 5C I 1 3C 2 4 7C 1 3 6C 2 5 Decrement DEC 4A 1 1 5A 1 1 3A 2 4 7A I 3 6A 2 5 Clear CLR 4F 1 1 5F 1 1 3F 2 4 7F I 3 6F 2 5 Complement COM 43 1 I 53 1 I 33 2 4 73 I 3 63 2 5 Negate NEG 40 I 1 50 1 I 30 2 4 70 I 3 60 2 5 (2'. Complement) Rotate Left Thru Carry ROL 49 I 1 59 1 I 39 2 4 79 I 3 69 2 5 Rotate Right Thru Carry ROR 46 1 1 56 1 I 36 2 4 76 1 3 66 2 5 Logical Shift Left LSL 48 I 1 58 1 I 36 2 4 78 1 3 6B 2 5 Logicel Shift Right LSR 44 I 1 54 1 1 34 2 4 74 1 3 64 2 5 47 I 77 67 ASR 1 57 r 1I- I 37 2 4 I 3 2 5 Arithmetic 5hift Right -SB- -_.- - . - Arithmetic Shift Left ASL 48 I I I 36 2 4 7B I 3 6B 2 5 Test for Negative or TST 40 1 I 50 I 1 3D 2 4 70 I 3 60 2 5 Zero Symbols: Op" ~.tion # .. Instruction ~HITACHI 286 Tab Ie 2-4 Branch Instructions Relative Addressing Mode Operation Mnemonic Op # # Code Bytes Cycles Branch Always BRA 20 2 3 Branch Never BRN 21 2 2 or 3· Branch IF Higher BHI 22 2 2 or 3· Branch IF lower or Same BlS 23 2 2 or 3· Branch IF Carry Clear BCC 24 2 2 or 3· (Branch IF Higher or Same) (BHS) 24 2 2 or 3· Branch IF Carry Set BCS 25 2 2 or 3· (Branch IF lower) (BlO) 25 2 2 or 3· Branch IF Not Equal BNE 26 2 2 or 3· Branch IF Equal BEQ 27 2 2 or 3· Branch IF Half Carry Clear BHCC 2B 2 2 or 3· Branch IF Half Carry Set BHCS 29 2 2 or 3· Branch IF Plus BPl 2A 2 2 or 3· Branch IF Minus BMI 2B 2 2 or 3· Branch IF Interrupt Mask Bit is Clear BMC 2C 2 2 or 3· Branch IF Interrupt Mask Bit is Set BMS 20 2 2 or 3· Branch IF Interrupt line is low Bil 2E 2 2 or 3· Branch IF Interrupt Line is High BIH 2F 2 2 or 3· Branch to Subroutine BSR AD 2 4 Symbol: Op = Oper.tion # .. Instruction • If branched, each instruction will be a 3-cvcle instruction. Tab Ie 2-5 Bit Processing Instructions Addressing Mode Bit Set/Clear Bit Test and Branch Operations Mnemonic Op # # Op # # Code Bytes Cycles Code Bytes Cycles Branch IF Bit n is Set BRSET n (n = 0 ..... 7) - - - 2· n 3 4 or 5· Branch IF Bit n is Clear BRClR n (n = 0 .•... 7) - - - 01 + 2' n 3 4 or5· Set Bit n BSET n In = 0 ..... 7) 10+2'n 2 4 - - - Clear Bit n BClRn(n=0 ..... 7) 11+2'n 2 4 - - - Symbol: Op· Oper.tion # - Instruction • If Br....ched. each instruction will be • 5-cvcle instruction. ~HITACHI 287 Tab Ie 2-6 Control Instructions Implied Operation Mnemonic Op # # Code Bytes Cycles Transfer A to X TAX 97 1 1 Transfer X to A TXA 9F 1 1 Set Carry Bit SEC 99 1 1 Clear Carry Bit ClC 98 1 1 Set Interrupt Mask Bit SEI 9B 1 1 Clear Interrupt Mask Bit CLI 9A 1 1 Software Interrupt SWI 83 1 9 Return from Subroutine RTS 81 1 4 Return from Interrupt RTI 80 1 7 Reset Stack Pointer RSP 9C 1 1 No-Qperation NOP 90 1 1 Symbol: Op - Operation # .. Instruction Table 2-7 Instruction Set Addressing Modes Condition Code Mnemonic Re- Indexed Indexed Indexed Bit Bit Implied Imme- Ex- Direct tended (No (8 Bits) (16 Bits) Setl Test & H I N Z C diate lative Offset) Clear Branch ADC x x x x x x 1\• 1\ 1\ 1\ ADD x x x x x x 1\• 1\ 1\ 1\ AND x x x x x x • • 1\1\ 1\ • ASl x x x x • • 1\ 1\1\ 1\1\ ASR x x x x • • BCC x • • • • • BClR x • • • • • BCS x • • • • • BEQ x • • • • • BHCC x • • • • • BHCS x • • • • • BHI x • • • • • BHS x • • • • • BIH x • • • • • Bil x • • • • • BIT x x x x x x • • 1\ 1\ • BlO x • • • • • BlS x • • • • • BMC x • • • • • BMI x • • • • • BMS x • • • • • BNE x • • • • • BPl x • • • • • BRA x • • • • • Symbols for condition code: (Continued) H Half Carrv (From Bit 3) C Carry/Borrow I Interrupt Mask 1\ Test and Set if True, Cleared Otherwise N Negal;"" (Sign Bill • Not Affected Z Zero ~HITACHI 288 Tab Ie 2-7 Instruction Set (Continued) Addressing Modes Condition Code Mnemonic Indexed Bit Bit Implied Imme- Ex- Re- (No Indexed Indexed Test & H Direct tended (8 Bits) (16 Bits) SIlt! I N Z C diate lative Offset) Clear Branch BRN x • • • • •A BRCLR x • • • • BRSET x • • • • A BSET x • • • • • BSR x • • • • • CLC x • • • • 0 CLI x • 0 • • • CLR x x x x • • 0 1 • CMP x x x x x x • • A A A COM x x x x • • A A 1 CPX x I< x x x x • • A A A DEC x x x x • • AA A • EOR x x x x x x • • A • INC x x x x • • A A • JMP x x x x x • • • • • JSR x x x x x • • • • • LOA x x x x x x • • A A • LOX x x x x x x • • A A • LSL x x x x • • A A A LSR x x x x • • 0 A A NEG x x x x • • A A A NOP x • • • • • ORA x x x x x x • • A A • ROL x x x x • • A A A ROR x x x x • • A A A RSP x • • • • • RTI x ? ? ? ? ? RTS x • • • • • SBC x x x x x x • • A A A SEC x • • • • 1 SEI x • 1 • • • STA x x x x x • • A A • STX x x x x x • • A A • SUB x x x x x x • • A A A SWI x • 1 • • • TAX x • • • • • TST x x x x • • A A • TXA x • • • • • Symbols for condition code: H Half Carry IFrom Bit 3) C Carry IBorrow I Interrupt MesIC A Test and Set if True, Cleared Otherwise N Negative ISign Bid • Not Affected Z Zero ? Load CC Register From Stack * HITACHI 289 Tab 1 e 2-8 OP Code Map Bit Manipulation Branch Read/Modify /Write Control Register/Memory Test & Branch Set/ Clear Rei olR IA I X I XI I .XO IMP IMP IMM I olR I EXT IX2 1 l·xo .Xl 0 1 2 3 I 4 I 5 I 6 I 7 8 9 A I B I C I 0 I E I F ~ HIGH 0 BRSETO BSETO BRA NEG RTI" - SUB 0 1 BRClRO BClRO BRN - RTS" - CMP 1 2 BRSETI BSETI BHI - - - SBC 2 3 BRClRl BClRl BlS COM SWI" - CPX 3 l 4 BRSET2 BSET2 BCC lSR - - AND 4 o 5 BRClR2 BClR2 BCS - - - BIT 5 W 6 BRSET3 BSET3 BNE ROR - - lOA 6 7 BRClR3 BClR3 BEQ ASR - TAX - [ STA (+11 7 8 BRSET4 BSET4 BHCC lSl/ASl - ClC EOR B 9 BRClR4 BClR4 BHCS ROl - SEC AoC 9 A BRSET5 BSET5 BPl DEC - Cli ORA A B BRClR5 BClR5 BMI - - SEI ADD B C BRSET6 BSET6 BMC INC - RSP - [ JMP(-11 C 0 BRClR6 BClR6 BMS TST - NOP BSR"I JSR(+11 I JSR ~SR(+1 0 E BRSET7 BSET7 Bil - - - lOX E F BRClR7 BClR7 BIH ClR - TXA - I STX(+11 F 3/4 or 5 2/4 2/20r3 2/4 [ 111 [ 1/1 [ 2/5 [ 1/3 1/" 1/1 2/2 [ 2/3 [ 3/4 [ 3/5 [ 2/4 [ 1/2 (NOTESI 1."-" is an undefined operation code. 2. The figure in the lowest row of each column gives the number of bytes and the cycles needed for the instruction. The number of cycles for the asterisked ("I mnemonics is a follows: RT! 7 RTS 4 SWI 9 BSR 4 3. The parenthesized figure must be edded to the cycle count of the associated Instruction. 4. If the instruction il branched. the cycle count is the larger figure. ~HITACHI 290 3. Executable Instruction 3.1 Symbol and Abbreviation Shown below are the meaninqs of symbols and abbreviations. (1) Operation ( ): contents movement direction +: addition subtraction /\: AND V: OR (±): Exclusive OR x: NOT (2) Register symbols in MPU ACCA: accumulator A CCR: condition codes register IX: index register, 8 bits pc: program counter, 12 bits PCH: upper three bits of program counter PCL: lower eight bits of program counter SP: stack pointer, 5 bits (3) Memory and addressing codes M: stored address MH: upper eight bits of stored address ML: lower ej.ght bits of stored address M+l: stored address M plus 1 Msp: stored address indicated by stack pointer Imm: immediate value Disp: displacement value = M - (IX) 0: displacement value =M- (IX) DH: displacement value upper eight bits DL: displacement value lower eight bits Rel: relative value IMPLIED: implied addressing RELATIVE: relative addressing ACCUMULATOR: accumulator addressing INDEX REG.: index register addressing IMMEDIATE: immediate addressing DIRECT: direct addressing EXTENDED: extended addressing INDEXED 0 BYTE OFFSET: indexed addressing 0 byte offset INDEXED 1 BYTE OFFSET: indexed addressing 1 byte offset ~HITACHI 291 INDEXED 2 BYTE OFFSET: indexed addressing 2 byte offset EA: effective address (4) Contents of bits 0 through 4 of condition codes register C: carry - borrow bit 0 Z: zero bit 1 N: negative bit 2 I: interruption mask bit 3 H: half carry from bit 3 to bit 4 bit 4 (5) Status of each bit before execution of instruction An: bit n of ACCA (n = 7, 6, 5, .... , 0) Mn: bit n of M (n .... , 0) 7, 6, 5, Xn: bit n of IX (n= 7, 6, 5, .... , 0) (6) Status of each bit on result after execution of instruction Rn: bit n of result (n = 7, 6, 5, .... , 0) ( 7) Symbols on instruction's format P: each addressing mode on Immediate, Direct, Extended and index of 0, land 2 bvte offset Q: each addressing mode on Direct and index of 0 and 1 byte offset A: accumulator addressing mode X: index register addressing mode DR: direct addressing mode dd: relative operand (8 bits) n: bi t n of memory (n = 7, 6, 5, .... , 0) (8) Status of HD63L05'S interruption pin INT: status of interruption pin (high, low) ~HITACHI 292 3.2 Executable Instruction Arithmetic Operation ADC ADC (ADd with Carry) Format II I Conditi~ R." C...os II ADCP I Set if there is a carry from bit 3, otherwise cleared. I: Unaffected. ~===========1I;:I====================~ N: Set if the most significant bit Operation . of the result is set; otherwise cleared. Z: Set if the result is 0; otherwise ACCA ... (ACCA) + (M) + (C) cleared. C: Set if there was a carry from the most significant bit of the result; otherwise cleared. I Description II Adds the contents of the carry bit C to the sum of the contents of ACCA and M, and stores the result into ACCA. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte 1 ,I Byte 2 I I I Byte 3 Number of bytes Number of CPU cycles I IMMEDIATE ADC Il1mm A9 Imm I 2 2 DIRECT ADC M B9 M 2 3 EXTENDED ADC M C9 MH ML 3 4 ~;~:~D v Inn ADC 0, X F9 1 2 INDEXED 1 BYTE ~E'SET ADC Disp,X E9 D 2 4 ~~!~D 2 BYTE ADC Disp X D9 I DR DL 3 5 , I ,, I Example II LOA VAL2 (EXVAL5, EXVAL6)+(VAL1, VAL2) ADD EXVAL6 * =(EXVAL5, EXVAL6) STA EXVAL6 * LOA VAll * ADC EXVAL5 *** STA EXVAL5 * ~HITACHI 293 Arithmetic Operation ADD ADD (ADD without carry) Format 1/ ' R: Condition Codes II ADDP I Set if there is a carry from bit 3; otherwise cleared. I: Unaffected. N: Set if the significant bit of the :======:::;-1-;::: I==========~ result is "1"; otherwise cleared. Operation Z: Set if the result is "0"; other- wise cleared. C: Set if there is a carry from the ACCA + (ACCA) + (M) most significant bit a the result; otherwise cleared. I Description I Adds the ACCA contents to the M contents and stores the result into ACCA. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand type of of CPU Mode Byte 1 : Byte 2 I Byte 3 I I bytes cycles I I IMMEDIATE ADD IIImm AB I Imm I I 2 2 I I DIRECT ADD M BB I I M I 2 3 I I EXTENDED ADD M CB : MH I ML 3 4 IN~~~D U BYTE I I OFF ADD O,X FB I I I 1 2 INDEXED 1 BYTE I I OFF!':F.T ADD DisD X EB I D I 2 4 ~NDEXED 2 BYTE I I OFFSET ADD Disp,X DB I DR : I DL 3 5 I I I I I I I I I I I I I Example II LDA VAll (VAL1)+(WORK)=(RESULT) ADD WORK * STA RESULT * ~HITACHI 294 Logical Operation AND AND (logical AND) II I~: Unaffected Format 1/ Condition Codes AND P I. N: Unaffected Set if the most significant bit of the result is "1"; otherwise ~====~========~ Operation II Z: cleared. Set if the result is "0" otherwise cleared. C: Unaffected ACCA + (ACCA) A (M) I Description I Performs logical AND between the ACCA contents and M contents, and stores the result into ACCA. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte 1 :I Byte 2 I I I Byte 3 Number of bytes Number of CPU cycles I I IMMEDIATE AND ffImm A4 I Imm I I 2 2 I I DIRECT AND M B4 I 0 M I 0 2 3 0 I EXTENDED AND M C4 0 0 MH I ML 3 4 ~;~;:u u "IU AND O,X F4 I I I I I 1 2 INDEXED 1 BYTE I I I OFFSET AND : Disp,X E4 I D I 2 4 I~~D Z BYTE I I I OFF ET AND : Disp,X D4 I DR : DL 3 5 I I . I I I I I . 0 0 I I I Example II LDA O,X ERASE UPPER 4 BITS AND #$OF * STA O,X (RESTORE) INC X * BRA LOOP * ~HITACHI 295 -~~----. -_._-.-.-- Shift and Rotation ASL ASL (Arithmetic Shift Left) I Format II ASL Q I Condition Codes II H: Unaffected ASL A I: Unaffected ASL X N: Set if the most significant bit of the result is "1"; otherwise cleared. I Operation II Z: Set i f the resul t is "0"; otherwise cleared. C: Set if the most significant bit • is "1", otherwise cleared. El~1 b. I I I I I I I I~ bo 0 I Description I Shifts the contents of ACCA, IX or M one bit to the left. The bit 0 is loaded with "0". The carry bit C is loaded with the bit 7 of ACCA, IX or M. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic I Operand I of of CPU Mode I type Byte 1 :I Byte 2 Byte 3 I bytes cycles I I ACCUMULATOR ASL A 48 I 1 1 I INDEX REG. ASL X 58 I I 1 1 I I DIRECT ASL M 38 M 2 4 INDEXED U BYTE OFFSET ASL a,x 78 I I 1 3 INDEXED I HYTE I OFFSET ASL Disp X 68 I D 2 5 I I I : I I I I I I I I I I I Example II LDA WORK CHECK ASL A BRANCH FOLLOWING BIT BCS BITON * 7-6-5-4-3-2-1-0 BITOFF EQU * LDX #100 ~HITACHI 296 Shift and Rotation ASR ASR (Arithmetic Shift Right) I Format IJ I Condition Codes II ASR Q H: Unaffected ASR A I: Unaffected ASR X N: Set if the most significant bit of the result is "1"; otherwise I Operation II Z: cleared. Set if the result is "0"; otherwisE cleared. ,. C: Set if the least significant bit is "1" before a shift; otherwise [[I I I I I I ] I-+@] bo cleared. b, I Description I Shifts the contents of ACCA, IX or M one bit to the right. The bit 7 is unaffected. The bit o is loaded into the carry bit C. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte 1 Byte 2 Number of Byte 3 bytes Number of CPU cycles I ACCUMULATOR ASR A 47 1 1 INDEX REG. ASR X 57 1 1 DIRECT ASR M 37 M 2 4 IND~D U JUT" OFFSET ASR O,X 77 1 3 ~;~~u J. DlJ:" ASR Disp,X 67 D 2 5 I I I I I I Example II ASR WORK BCS OPTO BRANCH OPTION (KEEPING BIT7) ASR WORK BCS OPTl ASR WORK BCS OPT2 * $ HITACHI 297 Conditional Branch BCC BCC (Branch if Carry Clear) Format 'I Condition Codes II BCC dd II Unaffected. Operation II PC + (PC)+0002+Rel i f (C)=O I Description I Tests the state of the C bit and causes a branch if it is "0". If branched, this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Addressing Operand Instruction code Number Number Mnemonic of of CPU Mode type Byte I Byte 2 Byte 3 bytes cycles RELATIVE BCC ReI 24 ReI 2 2 or 3 I I I I I I I I I I I I I Exa:mple II LDA VAL2 ADD EXVAL6 BCC NORMAL KETA AGARI NASHI * INC X KETA AGARI ~HITACHI 298 Bit Control BCLR BCLR (Bit CLeaR bit n) I Format II I Condition Codes II BCLR n, DR Unaffected. I Operation II Mn .. ° I Description I Clears the bit n (n = 0 through 7) of M. The other bits are unaffected. Addressing Mode Addressing Mode and Number of CPU Cycles . Mnemonic: Operand •, type Instruction code Byte 1 : Byte 2 • Byte 3 Number of bytes Number of CPU cycles I · I DIRECT BCLR O,M 11 M 2 4 DIRECT DIRECT BCLR BCLR 1,M 2,M 13 , 15 , ···M M 2 2 4 4 I DIRECT BCLR 3 M 17 · M 2 4 DIRECT DIRECT BCLR BCLR 4,M S,M 19 lB ·· I M M 2 2 4 4 DIRECT BCLR 6,M lD ·•· M 2 4 DIRECT BCLR 7,M iF ·· M 2 4 I Example II LOA AND CNTRL #$FO ** MAKE CONTROL CODE ** * ORA WORK * STA CNTRL * BCLR O,CNTRL CLEAR BIT 0,6,7 ABSOLUTELY BCLR 6,CNTRL BCLR 7,CNTRL ~HITACHI 299 Conditional Branch· BCS BCS (Branch if Carry Set) Format II Condition Codes U BCS dd II Unaffected Operation II PC + (PC)+OOO2+Rel i f (C)=l I Description II Tests the state of the C bit and causes a branch if it is "1". If branched. this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Addressing Operand Instruction code Number Number Mnemonic of of CPU Mode type Byte 1 Byte 2 Byte 3 bytes cycles RELATIVE BCS ReI 25 ReI 2 2 or 3 ,, , I I I Example II LOA VAll ADD EXVAL6 BCS ABNML KETA AGAR! * STA EXVAL6 KETA AGAR! NASH! ~HITACHI 300 Conditional Branch BEQ BEQ (Branch of EQual) Format II Condition Codes Ij BEQ dd II Unaffected. Operation II PC + (pC)+0002+Rel if (Z)=l I Description I Tests the state of the Z bit and causes a branch if it is "1". If branched, this instruction requires 3 cycles. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte 1 I: Byte 2 I I I Number of Byte 3 bytes Number of CPU cycles I I RELATIVE BEQ Rel 27 I Rel I I 2 2 or 3 I I 0 I 0 0 I I 0 I 0 I I 0 I 0 0 0 I I I I :, 0 0 I 0 ,, , I I Example II LDA BEQ WORK AAAA WORK = 0 CMP RESULT BEQ BBBB WORK = RESULT ~HITACHI 301 Conditional Branch BHCC BHCC (Branch if Half Carry Clear) Format II Condition Codes II i BHCC dd I' Unaffected I Operation " PC + (PC)+OOO2+Rel i f (H)=O I Description I Tests the state of the H bit and causes a branch if it is "0". If branched, this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand of of CPU Mode type Byte I Byte 2 Byte 3 bytes cycles RELATIVE BHCC ReI 28 ReI 2 2 or 3 I Example II CMP #$9 BLS DAALOW $99 ---> INPUT DAAH6 LDX #$60 HIGH NYBLE NEEDS CORRECTION * DAALOW BHCC DAAL9 TXA ~HITACHI 302 Conditional Branch BHCS BHCS (Branch if Half Carry Set) Format II Condition Codes 1/ BHCS dd II Unaffected. Operation 1/ PC + (pC)+OOO2+Rel i f (H)=l I Description I Tests the state of the H bit and causes a branch i f it is l. If branched, this instruction requires 3 cycles. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte 1 :I Byte 2 I Byte 3 Number of bytes Number of CPU cycles I RELATIVE BHCS Rel 29 I Rel 2 2 or 3 I I I I · I I · I I I I · I I · I Example 1/ CMP BLS #$9 DAALWl $99 ---> INPUT DAAH7 LDX #$60 HIGH NYBLE NEEDS CORRECTION * DAALWl BHCS DAAL6 NAD #$F ~HITACHI 303 Conditional Branch BHI BHI (Branch if HIgher) Format II Condition Codes II BHI dd II Unaffected. Operation II PC +- (PC)+O002+Rel if (C V Z)=O i.e. i f (ACCA) > (M) (unsigned binary numbers) I Description II Causes a branch if both bit C and bit z are "0". If the BHI instruction is executed immediately after execution of either of the instructions CMP or SUB, the branch will occur only if the unsigned binary number represented by the minuend (i.e. ACCA) was greater than the unsigned binary number represented by the subtrahend (1. e. M). This instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Addressing Mode · Mnemonic •• Operand type Instruction" code Byte I ,: Byte 2 I Byte 3 Number of Number of CPU I bytes cycles , I RELATIVE BHI ReI 22 · ReI I I 2 2 or 3 ·· I I ··, ,·I I ·· ··I · :·· I ·· I I , ··, · I I I Example II LDA VAll CMP VAL2 BHI ZIP25 VAll > VAL2 (IGNORE SIGN BIT) * VALl --> WORK (LOWER OR SAME) STA WORK ~HITACHI 304 Conditional Branch BHS BHS (Branch if Higher or Same) Format II Condition Codes II BHS dd II Unaffected. Operation U PC + (PC)+OOO2+Rel i f (C)=O I Description I Following to an unsigned compare or subtract, BHS will cause a branch i f the register is higher than or the same as the location in M. If branched, this instruction requires 3 cycles. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte I :I Byte 2 I Byte 3 Number of bytes Number of CPU cycles I RELATIVE BHS ReI 24 I ReI 2 2 or 3 . I I I I I I I I I I I I I I I Example II LDA VAll CMP VAL2 BHS ZIP26 VALl >= VAL2 IGNORE SIGN BIT * STA WORK VAll ---> WORK (LOWER) ~HITACHI 305 Conditional Branch BIB BIB (Branch if Interrupt line is Bigh) Format 1/ Condition Codes II BIB dd II Unaffected. ~====~========~ Operation II PC + (PC)+O002+Rel if INT-l (high) I Description )1 Tests the state of the external interrupt pin (00) and causes a branch if it is high. If branched. this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Addressing Operand Instruction code Number Number Mnemonic of of CPU Mode type Byte 1 Byte 2 Byte 3 bytes cycles RELATIVE BIB Rel 2F Rel 2 2 or 3 , :, ,, ,, I Example II BIH INTHO INT LINE CHECK INTLl LDA #$28 OUTPUT DATA = $28 BRA NEXT2 INTHO LDA #$FF OUTPUT DATA = $FF NEXT2 STA PIA OUTPUT ~HITACHI 306 Conditional Branch BIL BIL (Branch if Interrupt line is Low) Format II Condition Codes II BIL dd II Unaffected. ~====~========~ Operation II PC + (PC)+O002+Rel if INT=O (low) I Description II Tests the state of the external interrupt pin and causes a branch if it is low. If branched, this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand Mode type of of CPU Byte 1 :, Byt.e 2 Byte 3 bytes cycles RELATIVE BIL Rel 2E , I Rel 2 2 or 3 . ,, , : ,, ,, , I ,, ,, I Example II BIL INTL2 INT LINE CHECK INTH3 LDA #$45 OUTPUT DATA = $45 BRA NEXT4 INTL2 LDA #$0 OUTPUT DATA = $00 NEXT4 STA PIA OUTPUT ~HITACHI 307 Logical Operation BIT BIT (BIt Test) Format II Condition Codes 1/ BIT P II ~: Unaffected. Unaffected Set if the most significant bit of the result of the AND is "1"; Operation II Z: otherwise cleared. Set if all the bits of the result of the AND are "0"; otherwise (ACCA) I\. (M) cleared. C: Unaffected. I Description I Performs the logical AND operation of the ACCA contents and the M contents and modifies the respective condition codes. The contents of ACCA and M are unaffected. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I IMMEDIATE BIT IIImm A5 I Imm 2 2 I DIRECT EXTENDED BIT BIT M M B5 C5 ·· I I M MH ML 2 3 3 4 ~;~~u u Iml< · I BIT X F5 1 2 UWI<"",D .I. ISITI< I OFFSET BIT DisD.X E5 I D 2 4 lND=D L BYTE I OFFSET BIT Disp,X D5 I DR DL 3 5 I I I I I Example II EVBIT LDA BIT VAll #$FS BEQ OK 0 = BIT ASSIGN (VALl) <=7 * NG LDA #227 SET ERROR NUMBER JMP ERROR ~HITACHI 308 Conditional Branch BLO BLO (Branch if LOwer) Format Condition Codes 1/ 1/ BLO dd II Unaffected. Operation II PC + (PC)+O002+Rel if (C)=l I Description I Following to a compare, BLO will cause a branch if the register is lower than the memory location. Equivalent to the BCS executable instruction. If branched, this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Addressing I I Operand Instruction code Number Number Mnemonic of of CPU Mode type Byte I Byte 2 Byte 3 bytes cycles RELATIVE BLO ReI 25 ReI 2 2 or 3 I Example 1/ LOA VAll CMP VAL2 BLO ZIP27 VAll < VAL2 (IGNORE SIGN BIT) * STA WORK VAll --> WORK HIGHER OR SAME ~HITACHI 309 Conditional Branch BLS BLS (Branch if Lower or Same) Format II Condition Cod'es II BLS dd II Unaffected. Operation "-- IJ PC .... (PC)+O002+Rel if (C V Z)=l i.e. if (ACCA) ~ (M) I Description I Causes a branch if either C or Z is "1". If the BLS instruction is executed immediately after execution of either of the instructions CMP or SUB, the branch will occur only if the unsigned binary number represented by the minuend (i.e. ACCA) is less than or equal to the unsigned binary number represented by the subtrahend (i.e. M). If branched, this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand of of CPU Mode type Byte 1 Byte 2 Byte 3 bytes cycles RELATIVE BLS ReI 23 ReI 2 2 or 3 I Example II LOA CMP VAll VAL2 BLS ZIP28 VAll <= VAL2 IGNORE SIGN BIT * STA WORK VALl ---> WORK (HIGHER) ~HITACHI 310 Conditional Branch BMC BMC (Branch if interrupt Mask is Clear) Format II Condition Codes IJ BMC dd II Unaffected. Operation II PC ~ (pC)+0002+Rel if (1)=0 I Description I Tests the state of the I bit and causes a branch if I is "0". If branched, this instruction requires 3 cycles. Addressing Mode Addressing Mode and Number of CPU Cycles I Mnemonic II Operand I I type Instruction code Byte 1 :I Byte 2 I Byte 3 Number of bytes Number of CPU cycles I RELATIVE BMC Rei 2C I Rei 2 2 or 3 I I I I , I ,I I I I I I I I I I Example II BMe MSKOFF INTMSK OFF? BIL MSKOFF INT LINE LOW? LDA PIA READ DATA STA WORK MSKOFF RTS ~HITACHI 311 Conditional Branch BMI BMI (Branch i f MInus) Format II Condition Codes 1/ BMI dd II Unaffected. i I Operation II PC + (PC)+OOO2+Rel i f (N)=l I Description II Tests the state of the N bit, and causes a branch if N is "1". If branched, this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand type of of CPU Mode Byte 1 : Byte 2 Byte 3 I bytes cycles I RELATIVE BMI Rel 2B I Rel 2 2 or 3 I I I : I I I I I I I I I I I Example II LDA VAll BMI ZIP29 VAll < 0 * STA WORK VAL ---> WORK (PLUS) ~HITACHI 312 Conditional Branch BMS BMS (Branch if interrupt Mask is Set) Format II Condition Codes II BMS dd II Unaffected. ~====~==========~ Operation II PC + (PC+0002+Re1 if (1)=1 I Description II Tests the state of the I bit and causes a branch if I is "1". If branched, this instruction requires 3 cycles. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte 1 II Byte 2 Byte 3 Number of bytes Number of CPU cycles I I RELATIVE BMS Re1 2D I Re1 2 2 or 3 . I . I I Example II BMS MSKONl INTMSK ON? MSKOFl RTS NO MSKONl BIL MSKOFl INT LINE LOW? LDA PIA DATA STA WORK RTS ~HITACHI 313 Conditional Branch BNE BNE (Branch if Not Equal) Format II Condition Codes II BNE dd II Unaffected. i I Operation II PC + (PC)+0002+Rel if (Z)=O I Description I Tests the state of the Z bit and causes a branch if Z is "0". Following to a compare or subtract instruction, BNE will cause a branch if the contents are different. If branched, this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Addressing I Instruction code Number Number Mnemonic II Operand I Mode type of of CPU I Byte I I: Byte 2 Byte 3 bytes cycles , I RELATIVE BNE I ReI 26 I ReI 2 2 or 3 I I I I . I I I I I I I I I I I I I I I I I I I I I I I I I I I I I Example II LDA WORK BNE CCCC WORK NOT ~ 0 CMP RESULT BNE DDDD WORK NOT ~ RESULT ~HITACHI 314 Conditional Branch BPL BPL (Branch if PLus) Format II Condition Codes IJ BPL dd Unaffected. ~====~========~ Operation II PC + (PC)+O002+Rel if (N)=O I Description IJ Tests the state of the N bit, and causes a branch if N is "0". If branched; this instruction requires 3 cycles. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte I Byte 2 Byte 3 bytes cycles RELATIVE BPL ReI 2A ReI 2 2 or 3 -. I Example II LOA VALl BPL ZIP3l VAL >= 0 * STA WORK VALl ---> WORK (MINUS) ~HITACHI 315 --------"-------"-"--~ Unconditional Branch BRA BRA (BRanch always) Format Condition Codes II BRA dd " II Unaffected. Operation II PC + (PC)+OO02+Rel I Description I Causes an unconditional branch to the address given by the above expression. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand of of CPU Mode type Byte I :I Byte 2 Byte 3 bytes cycles I RELATIVE BRA ReI 20 I ReI 2 3 . I I . I I I I I I I I I I I I I Example II LOA EXVAL5 STA RESULT BRA ENOOl BRANCH TO ENOOl ALWAYS * CHECKS EQU * ~HITACHI 316 Conditional Branch BRCLR BRCLR (BRanch if bit n is CLeaR) I Format II I Condition Codes 1/ H: Unaffected. BRCLR n, DR, dd I: Unaffected. N: Unaffected. Z: Unaffected. C: Set i f (Mn)=l; otherwise cleared. / Operation II PC + (PC)+O003+Rel if (Mn)=O / Description ] \ Tests the bit n (n = 0 through 7) of M and causes a branch if the Mn contents are O. If branched, each instruction requires 5 cycles. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Number of Number of CPU I Byte 1 ,: Byte 2 Byte 3 bytes cycles RELATIVE BRCLR O,M,Rel 01 ,I M ReI 3 4 or 5 , RELATIVE BRCLR 1,M,Rel 03 ,, M ReI 3 4 or 5 , RELATIVE BRCLR 2,M,Rel as : M ReI 3 4 or 5 RELATIVE BRCLR 3,M,Rel 07 , I M ReI 3 4 or 5 RELATIVE BRCLR 4,M,Rel 09 ,, M ReI 3 4 or 5 RELATIVE BRCLR 5,M,Rel OB ,I M ReI 3 4 or 5 RELATIVE BRCLR 6,M,Rel aD ,, M ReI 3 4 or 5 ,, RELATIVE BRCLR 7,M,Rel OF M ReI 3 4 or 5 / Example II LDA AND CNTRL #$OF ** SET CONTROL CODE ** ORA WORK STA CNTRL * ** ACTION ** BRCLR 4,CNTRL,ENGINE BRCLR 7,CNTRL,GASCHK ~HITACHI 317 Unconditional Branch BRN BRN (BRanch Never) Format II Condition Codes II BRN dd II Unaffected. Operation II PC + (PC)+OOO2 I Description II BRN is included here to demonstrate the nature of branches on the HD63L05 MCU. Each branch is matched with an inverse that varies only in the least significant bit of the opcode. BRN is the inverse of BRA. This instruction may have some use during program debugging. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand of of CPU Mode type Byte 1 :I Byte 2 Byte 3 bytes cycles I RELATIVE BRN ReI 21 I ReI 2 2 I I , ,, I I I I I I I , I , I I Example II STX 4.X * BRN * ** DELAY ** BRN * BRN * BRN * ~HITACHI 318 Conditional Branch BRSET BRSET (BRanch if bit n is SET) I Format II I Condition Codes II H: Unaffected. BRSET n, DR, dd I: Unaffected. N: Unaffected. Z: Unaffected. I Operation II C: Set i f (Mn)=l; otherwise cleared. PC + (pC)+0003+Rel i f (Mn)=l I Description I Tests the bit n (n = o through 7) of M, and causes a branch if the Mn contents are "I". If branched, each instruction requires 5 cycles. Addressing Mode and Number of CPU Cycles instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 I: Byte 2 I Byte 3 I bytes cycles I RELATIVE BRSET o M ReI 00 , I M I , ReI 3 4 or 5 ,, I I RELATIVE BRSET I,M, ReI 02 M ,I ReI 3 4 or 5 RELATIVE BRSET 2,M,Rel 04 ,,, M I I ReI 3 4 or 5 I RELATIVE BRSET 3,M,Rel 06 , I M I Rel 3 4 or 5 ,, , I RELATIVE BRSET 4,M,Rel 08 M ReI 3 4 or 5 ,,, I I RELATIVE BRSET 5,M,Rel OA I M , ReI 3 4 or 5 , ,, RELATIVE BRSET 6 M ReI OC I M , ReI 3 4 or 5 , , RELATIVE BRSET 7,M,Rel OE I M I Rel 3 4 or 5 I I Example II LOA CNTRL ** SET CONTROL CODE ** AND #$8E ORA WORK STA CNTRL * ** ACTION ** PROCl BRSET O,CNTRL, OIL PROC2 BRSET 7,CNTRL, GAS ~HITACHI 319 Bit Control BSET BSET (Bit SET bit n) I Format II I Condition Codes II BSET n, DR Unaffected. I Operation IJ Mn +- 1 I Description II ( Sets the bit n (n .. 0 through 7) of M. All other bits are unaffected. Addressing Mode and Number of CPU Cycles Addressing Operand Instruction code Number Number Mode Mnemonic of of CPU type Byte 1 Byte 2 I Byte 3 bytes I cycles I DIRECT BSET O,M 10 M I I 2 4 DIRECT BSET I,M 12 M I 2 4 I DIRECT BSET 2,M 14 M I 2 4 I DIRECT BSET 3,M 16 M I 2 4 I DIRECT BSET 4,M 18 M I 2 4 I DIRECT BSET S,M lA M , I 2 4 DIRECT ,, BSET 6 M lC M 2 4 DIRECT - BSET 7,M IE M , 2 4 I I Example II LOA BPL RESULT PLUS * (MINUS) BSET 2,CNTRL BSET 3 ,WORK PLUS EQU * LOA VAL2 ~HITACHI 320 Subroutine Control BSR BSR (Branch to SubRoutine) Format II Condition Codes Ir BSR dd II Unaffected. Operation II PC + (PC)+OOO2 Msp + (PCL), SP + (SP)-OOOl Msp + (PCR), SP + (SP)-OOOl PC + (PC)+Rel I Description I The program counter is increased by "2". The less significant byte of the contents of the program counter is pushed onto the stack. The stack pointer is then decreased by "1". The more significant byte of the contents of the program counter is then pushed onto the stack. Unused bits in the Program Counter high byte are stored as l's on the stack. The stack pointer is again decreased by "1". A branch then occurs to the address specified by the program counter. Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand Mode type of of CPU Byte 1 : Byte 2 I Byte 3 bytes cycles I RELATIVE BSR Rel AD I Rel 2 4 I I , ,, I I I I I I I I I I I I Example II LOA #$3B ACCA = INTERFACE(OOll 1011) BSR HAND * ACCA = INTERFACE(OOOl 1110) LOA #$lE BSR FING ~HITACHI 321 Bit Control CLC CLC (CLear Carry) iF:' II 1\ Condition Codes Unaffected. Unaffected. Unaffected. I~======~============~ Unaffected. Operation II Z: c: Cleared. C + 0 I Description I Clears the carry bit C in the condition code register. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand Mode type of of CPU Byte 1 :I Byte 2 Byte 3 bytes cycles IMPLIED CLC 98 , I 1 1 I ,I I : , I , I , I , I I I I I I I I I I I Example II BNE CHK83 STA RESULT CLC RETURN CODE SET 'OK ' RTS * * eH1TACHI 322 Bit Control CLl CLI (CLear Interrupt mask) Format II II., Condition Code. II II CLI Operation I+-O I Description II Clears the interruption mask bit in the processor condition code register. This enables the MCU to service interruptions. Interruptions that were pending while the I bit was set will now begin to have effect. Addressing Mode and Number of CPU Cycles Addre88ing I Operand Instruction code Number Number Mnemonic of of CPU Mode type Byte 1 Byte 2 Byte 3 bytes cycles IMPLIED CLI 9A 1 1 I Example II SEI INTERRUPT DISABLE RSP RESET STACK POINTER JSR SYSINZ SYSTEM INITIALIZE CLI INTERRUPT ENABLE ~HITACHI 323 Arithmetic Operation CLR CLR (CLeaR) , I Format II I Condition Codes II CLR Q H: Unaffected CLR A I: Unaffected. CLR X N: Cleared. Z: Set. I Operation II C: Unaffected. IX -+- 0 or ACCA -+- 0 or M-+-O I Description II The contents of IX, ACCA or M are replaced with "0". Addressing Mode and Number of CPU Cycles Addressing Operand Instruction code Number Number Mnemonic of of CPU Mode type Byte 1 ,: Byte 2 Byte 3 bytes cycles ACCUMULATOR CLR A 4F ,I 1 1 I INDEX REG. CLR X SF :, 1 1 DIRECT CLR M 3F : M 2 4 ~;~~1J U ISUIS CLR ,x 7F , I 1 3 ~:~D 1 BYTE ,, CLR DiEiP.X 6F D 2 S I I , I I I I Example " * CLR CLR PNTR PNTR+l ** INITIALIZE ** CLR D,X CLR A .HITACH.I. 324 Comparison and Test CMP CMP (CoMPare) Format II IR: Condition Codes II CMP P I I: Unaffected. Unaffected. N: Set if the most significant bit ~============~======================~ Operation II Z: of the result of the subtraction is "1"; otherwise cleared. Set if the result of the subtrac- tion is "0"; otherwise cleared. C: Set if the absolute value of (ACCA)-(M) memory is greater than the absolute value of the accumulator; otherwise cleared. I Description I Compares the ACCA contents and the M contents, then sets the condition codes which may then be used for controlling the conditional branches. Both uperands are unaffected. Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand type of of CPU Mode Byte 1 Byte 2 Byte 3 bytes cycles IMMEDIATE CMP IIImm A1 Imm 2 2 DIRECT CMP M Bl M 2 3 EXTENDED CMP M C1 MH ML 3 4 i~~~D U BYTE OF S CMP X F1 1 2 iNDEXED 1. BYTE OFFSET CMP Di"'l> X E1 D 2 4 ~;~::D ~ BYTE CMP Disp,X D1 DR DL 3 5 I Example II LOA PNTR,X * CMP #'A BEQ SECTA ACCA = 'A' CMP #'B BEQ SECTB ACCA = 'B' BRA INPUT ~HITACHI 325 Logical Operation COM COM (COMplement) I Format II I Condition Codes II COM Q H: Unaffected. COM A I: Unaffected. COM X N: Set if the most significant bit of the result is "1"; otherwise cleared. I Operation II Z: Set if the result is "0"; other- wise cleared. IX +- (IX) = $FF-(IX) C: Set. or ACCA +- (ACCA) = $FF-(ACCA) or M +-(M) = $FF-(M) I Description I Replaces the contents of ACCA, IX or M with its l's complement. Addressing Mode and Number of CPU Cycles , Number Number Addressing Instruction code Mnemonic:, Operand of of CPU Mode type Byte 1 :, Byte 2 Byte 3 I bytes cycles ACCUMULATOR COM I I A 43 , I 1 1 INDEX REG. COM I I X 53 ,, I 1 1 , DIRECT COM I M 33 : M 2 4 1l'ouEXED u BYTE OFFSET COM X 73 ,I 1 3 ~~~~D 1 BYTE COM I Disp,X 63 I D 2 5 I I , I , I I Example II * SUBIN EQU * INC X LDA PNTR, X COM A MODIFY DATA (REVERSE) RTS * ~HITACHI 326 Comparison and Test CPX CPX (ComPare indeX register) Format II IR •. Condition Codes IJ CPX P I I: Unaffected. Unaffected. N: Set if the most significant bit :=======;-;::===========~ Operation II Z: of the result is "1"; otherwise cleared. Set if the result is "0"; other- wise cleared. (IX)-(M) C: Set if the absolute value of the contents of the memory is greater than the absolute value of the contents of IX; otherwise cleared. I Description I Compares the IX contents with M contents. The condition code can be collated by means of the next conditional branch instruction. Both operands are unaffected. Addressing Mode and Number of CPU Cycles Addressing Instruction code Number Number Mnemonic Operand Mode type I of of CPU Byte 1 I: Byte 2 I Byte 3 bytes cycles I I IMMEDIATE CPX IIImm A3 I Imm I I 2 2 I DIRECT CPX M B3 I I I M 2 3 I EXTENDED CPX M C3 : MH ML 3 4 u,DEXED 0 BYTE OFFSET CPX ,X F3 I I 1 2 INDEXED 1 BYTE I OFFSET CPX Disp,X E3 I D 2 4 INDEXED Z BYTE I OFFSET CPX Disp,X D3 I DR DL 3 5 I I I I I Example 'I LOA LOX #$CC PNTR ACCA = INTERFACE TO CR OR LF CPX #$00 BEQ CR CARRIAGE RETURN CPX #$OA BEQ LF LINE FEED ~HITACHI 327 Arithmetic Operation DEC DEC (DECrement) I Format 1/ I Condition Codes II DEC Q H: Unaffected. DEC A I: Unaffected. DEC X N: Set i f the most significant bit of the result is "1"; otherwise I Operation II Z: cleared. Set i f the result is "0"; other- wise cleared. IX -<- (IX)-Ol C: Unaffected or ACCA -<- (ACCA)-Ol or M -<- (M)-Ol I Description I Subtracts "1" from the contents of ACCA, IX or M. Nand Z bits are set and reset according to the result of this operation. C bit is unaffected by this operation. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand of of CPU Mode type Byte 1 :, Byte 2 Byte 3 bytes cycles ACCUMULATOR DEC A 4A I , 1 1 ,, INDEX REG. DEC X 5A , 1 1 , DIRECT DEC M 3A : M 2 4 INDEXED 0 BYTE :, OFFSET DEC ,X 7A 1 3 INDEXED 1. BYTE OFFSET DEC Disp_,X 6A ,, D 2 5 ,I ,, ,, I Example II *LOOP23 DECBMI **ANEXTMOVE ** LDX O,X * STX $100,X * INC X * BRA LOOP23 * NEXT EQU * ~HITACHI 328 Logical Operation EOR EOR (Exclusive OR) Format 1/ '~.:. Condition Codes II EOR P I N: Unaffected. Unaffected. Set if the most significant bit :======~-;::==========~ Operation II Z: of the result is "1"; otherwise cleared. Set if the result is "0"; other- wise cleared. C: Unaffected. ACCA + (ACCA) ED (M) , Description I Performs the logical EXCLUSIVE OR between the ACCA contents and M contents and stores the result into ACCA. Addressing Mode and Number of CPU Cycles , Number Number Addressing Instruction code Mnemonic , Operand I of of CPU Mode I type Byte 1 ,: Byte 2 Byte 3 I bytes cycles IMMEDIATE EOR I I flImm AS , I Imm 2 2 , ,, DIRECT EOR I M BS , M 2 3 ,, M ,, EXTENDED EOR CS MH ML 3 4 ,, ~~~~~D 0 BYTE EOR ,, ,X FS ,I 1 2 INDEXED 1 BYTE ,, OFF~F'1' EOR : Disp,X ES D 2 4 INUt;llliU Z llYn,; I I OFFSET EOR : Disp, X DS I DR DL 3 5 , , I I ,, ,, I Example II * LDA CNTRL ** ARRANGE CONTROL CODE ** xxx x XXXX EOR #$99 1001 1001 STA CNTRL BRA ACTOl ~HITACHI 329 Arithmetic Operation INC INC (INCrement) I Format II I Condition Codes II H: Unaffected. INC Q I: Unaffected. INC A N: Set if the most significant bit INC X of the result is "1"; otherwise cleared. I Operation II Z: Set if the result is "0"; other- wise cleared. IX +- (IX)+Ol C: Unaffected. or ACCA +- (ACCA)+Ol or M +- (M)+Ol I Description I Adds "1" to the contents of ACCA, IX or M. Nand Z bits are set or reset according to the result of this operation. The C bit is not affected by this operation. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Operand Mnemonic of of CPU Mode type Byte 1 : Byte 2 Byte 3 I bytes cycles I ACCUMULATOR INC A 4C I 1 1 I INDEX REG. INC X 5C I I 1 1 I DIRECT INC M 3C I 0 M 2 4 6;~~" v DXi" INC ,X 7C I I 1 3 HW"'A.W .1 BYTE I OFFSET INC Disp,X 6C I D 2 5 I I I I I I I Example II LOOP3 INC CMP A #100 * BHI EXIT CHECK COUNTER (100 TIMES) LDX O,X STX $300.X MOVE INC X * BRA LOOP3 ~HITACHI 330 Conditional Branch JMP JMP (JuMP) Format II Condition Codes IJ JMP P II Unaffected. Operation II PC + EA I Description I A jump occurs to the instruction stored at the effective address. The effective address is obtained according to the rules for EXTended, DIRect or INDexed addressing. Addressing Mode and Number of CPU Cycles Instruction code Number Number Addressing Mnemonic Operand Mode type I of of CPU Byte 1 : Byte 2 Byte 3 bytes cycles DIRECT JMP M BC , I M 2 2 ,, EXTENDED JMP M CC , MIl ML 3 3 INDEXED u BYTE JMP ,X FC ,, , 1 1 OFFSET INDEXED 1 BYTE OFFSET JMP Disp X EC , I D 2 3 INDEXED 2 BYTE ,, . OFFSET JMP Disp,X DC DR DL 3 4 I I :, ,, , , ,, I I I Example II LOA VALl STA EXVAL5 LOA VAL2 STA EXVAL6 JMP EN090 DO TO END-ROUTINE ~HITACHI 331 Subroutine Control JSR JSR (Jump to SubRoutine) Format II Condition Codes II JSR P II Unaffected. Operation II PC -<- (PC)+n Note ) Msp -<- (PCL), SP-<- (SP)-OOOl Msp -<- (PCR) , SP -<- (SP)-OOQl PC -<- EA I Description 11 Note) The program counter is increased by n depending on the addressing mode, then pushed onto the 2-byte stack. And the stack point is updated. A jump occurs to the instruction stored at the effective address. The effective address is obtained according to the rules for EXTended, DIRect or INDexed addressing. Note) n is equal to 1, 2 or 3, depending on the number of bytes in the instruction code. Refer to the addressing code and the number of MPU cycles shown below. Addressing Mode and Number of CPU Cy.:les Instruction code Number Number Addressing Mnemonic Operand Mode type I of of CPU Byte 1 : Byte 2 I Byte 3 bytes cycles ,· I DIRECT JSR M BD · M I I • I 2 4 ,·, , EXTENDED JSR M CD , MH I ML 3 5 INDEXED u BYTE OFFSET JSR ,X FD , 1 3 ,ND""",,,u 1 BYTE OFFSET JSR Disp,X ED , I D 2 4 INDEXED 2 BYTE ,, OFFSET JSR Disp,X DD DR DL 3 5 I , ·, ,, , I I I Example II *START ** MAIN ROUTINE ** EQU * JSR INTRTN INITIALIZE JSR KBRTN INPUT FROM KEY-BOARD JSR ANARTN ANALYSE JSR PRCRTN PROCESS JMP ENDRTN END ~HITACHI 332 Load & Store LDA LDA (LoaD Accumulator) Format 1/ '~:: Condition Codes II LDA P I Unaffected. Unaffected. N: Set if the most significant bit :======:::;--;::==========~ Operation II Z: of the result is "1"; otherwise cleared. Set if the result is "0"; other- wise cleared. ACCA .... (M) C: Unaffected. I Description I Loads the M contents into the accumulator. ~HITACHI 333 Load & Store LDX LDX (LoaD indeX register) Format LDX P II II !, Condition Codes Unaffected. II Unaffected. Set if the most significant bit of IX is "1"; otherwise cleared. Set if all bits of IX of the Operation II Z: C: result are "0"; otherwise cleared. Unaffected. IX ... (M) I Description I Loads the M contents into IX. The condition code is set according to data. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic II Operand I of of CPU Mode type Byte 1 I: Byte 2 Byte 3 I bytes cycles IMMEDIATE LDX I I IIImm AE , Imm I 2 2 I I DIRECT LDX M BE , I M 2 3 I EXTENDED LDX M CE , I MH ML 3 4 ~NDEAED u BYTE I OFFSET LDX ,X FE I 1 2 INDEXED 1 BYTE I . OFFSET LDX Disp X EE I D 2 4 INDEXED 2 BYTE I OFFSET LDX Disp X DE I DR DL 3 5 I I I I I Example II LOX VAll STX WORK LOX O,X STX RESULT LOX #$FF ~HITACHI 334 Shift & Rotation LSL LSL (Logical Shift Left) I Format II I Condition Codes U LSL Q H: Unaffected. LSL A I: Unaffected. LSL X N: Set if the most significant bit of the result is Ill"; otherwise I Operation II Z: cleared. Set if the result is "0"; other- wise cleared. • C: Set if the most significant bit EJ+-I I I I I I I I I+- 0 of ACCA, IX or M is "1" before the execution of an instruction; b, bo otherwise cleared. I Description I Shifts the contents of ACCA, IX or M 1-bit to the left. The bit 0 is loaded with "0". The carry bit C is loaded with the most significant bit of ACCA, IX or M. Addressing Mode Addressing Mode and Number of CPU Cycles Mnemonic Operand type Instruction code Byte 1 Byte 2 Number of Byte 3 bytes Number of CPU cycles I ACCUMULATOR LSL A 48 1 1 INDEX REG. LSL X 58 1 1 DIRECT LSL M 38 M 2 4 UlIUEXIIU U BYT!! OFFSET LSL ,X 78 1 3 UIU!!XED ~ DYT!! OFFSET LSL I DisD X 68 D 2 5 I I I I I I I I I I I I Example II LSL WORK ** MULTIPLY X 8 ** LSL WORK LSL WORK ~HITACHI 335 Shift & Rotation LSR LSR (Logical Shift Right) I Format 1/ I Condition Codes II LSR Q H: Unaffected. LSR A I: Unaffected. LSR X N: Cleared. Z: Set if the result is "0"; other- I Operation II e: wise cleared. Set if, before execution of an instruction, the least significant ------+ bit of ACCA, IX or M is "1"; 0 1 I I I I I I I I-{~] b7 b. otherwise cleared. I Description I Shifts the contents of ACCA, IX or M I-bit to the right. The bit 7 is loaded with "0". The carry bit C is loaded with the least significant bit of ACCA, IX or M. Addressing Mode and Number of CPU Cycles I Instruction code Number Number Addressing Mnemonic ,I Operand I Mode of of CPU , type Byte 1 :, Byte 2 Byte 3 bytes cycles ACCUMULATOR LSR ,, A 44 ,, 1 1 INDEX REG. LSR I , X 54 , I I 1 1 I I DIRECT LSR ,, 0 M 34 I M 2 4 lNlJ"lIl l±O.OIZ) \.1±0 ..n . • DP-64S 57.6(2.268) 58.6max.(2.307mlx.) 33 o 1.0 32 (0.039) . ., d. ., I' .&.~ 19.05 (0.750) ~_~i!l:EO ~l;t U'========\ I; 1.77B±0.25 ~±0.010) 0.4B±0.10 (0.019±0.0~ II .e'~ JL ~~ rf-IS" N""; 0.25!t~llII) \0.010'·. e Figure 4-2 Package Information $ HITACHI 358 5. Electrical Characteristics IIABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply Voltage VCC -O.3~ +5.5 V Input Voltage Vin -0. 3·~ VCC+O. 3 V Output Voltage Vout -0 • 3 "" VCC+O • 3 V Operating Temparature Topr -20-+75 °c Storage Temparature Tstg -55~+125 ! °c (NOTE) Permanent LSI damage may occur if maximum ratings are exceeded. I ~HITACHI 359 .DC CI{ARACTERISTICS (VCC=3.0±0.8V, VSS=OV, Ta=-20'V+75°C, typ means typical value at VCC=3.0V unless otherwise noted.) Item ~ymbol Test Condition min typ max Unit Connect CL-0.5].lF XTAL, XIN to VCH VC e-°. 3 - VCC V Input "High" Level Voltage RES, INT, SB VIH O.5VCC+0.9 - Vr.r. V TIMER 0.8VCC - VCC V NUM (Normal Mode) VCC-0.2 - VCC V Connect CL=0.5].lF XTAL, XIN to VCH VCC- 2 • l - VCC-l.a V Input "Low" RES, INT, SB VIL VSS - 0.2VCC V Level Voltage TIMER VSS - O.2VCC V NUM (Test Mode) VSS - 0.2 V NUM (Self Check Self Check Input Voltage Mode) VIM 0.5VCC -0.2 - O.5VCC +0.2 V RES (INT:Mask Input Pull- Option) VCC=3.0V, Vin=OV 3 15 30 -I R1 ].lA Up Current NUM Input Leackage TIMER, SB Current IIINI Vin = OV'VVCC - - 1.0 j.JA Dur~ng System f =400kHz - 100 200 ].lA * OperatioI1 No load. r.rystal Oscil- At Halt ICCl Tested after - 40 80 ].lA lation At setting up the Stand-By internal status - 2 5 ].lA by self check. Current At AID· Dissipation OperatioI1 - 200 600 ].lA During System R =100kHz - 120 200 ].lA * OperatioI1 No load. RC Oscil- At Halt ICC2 Tested after - 60** 100** ].lA setting up the lation At Stand-By internal status - 2 5 ].lA by self check. At AID Operatior: - 220 600 ].lA Output "Low Level Voltage E VOL IOL = 30].lA - - 0.3 V * By Mask option ** In the case that OSCI is stopped by Halt; 60].lA-30j.JA, 100].lA-60].lA ~HITACHI 360 .AC CHARACTERISTICS (VCC=3.0±0.8V, VSS=OV, Ta=-20'V+7S"C, typ means typical value at VCC=3.0V unless otherwise noted.) Item Syabol Test Condition min typ lUX unit Operating Clock Frequency fc1 100 400 500 kHz Cycle 'Ilime fcyc 8 10 40 lis Oscillation Frequency foSCR a -100kSl ±1% 300 400 500 kHz (Resistor Option) External Clock Duty Duty 45 50 55 % Oscillation Start Time tOSCf CD -10pF±20%, as -lk!'l max - - 150 ma (Crystal Option) Oscillation Start Time toSCR B.-lOOk!'l±l%, - - 2 l1li (Resistor Option) Connect CL-0.5I1F to VCH Oscillation Start Time (l2kHz) tOSC2 CG-10pF±20%. as-20k!'l max - - 1 s Internal Capacitance of Oscillator EXTAL CD - 10 - pF XOUT - 10 - pF Delay Time of OBcillation Delay Time tDLY Selected by maBk option 0 - 1 S aeset Delay Time taLH External Capacitance -2.2I1F 200 - - IDS RES Pulse Width tRW!. When OSC2 is used 48+1 - - liB When OSC2 is not used 1.5 tcyc+l - - 118 When OSC2 is used 32 - - liS TIff Pulse Width tIW!. When OSC2 is not used tcyc+l - - liS TIMER Pulse Width tTWL In the case of counter tcyc+l - - liS .PORT CHARACTERISTICS (VCC=3.0±0.8V t VSS=OV, Ta=-20'V+7SoC, typ means typical value at VCC=3 OV unless otherwise noted.) Item Svmbo Test Condition min tVD max Unit Output "High" Level Voltage Port A B,C VOH CMOS Output Inu--l 00 \lA V,.,.-o.l - - V Port A,B,C Key Load CMOS Output Inll--l0uA VCC-O.l - - V Output ''Low'' Level VoltaRe PortABC Vm 1m -10ClJA - - O.l V Input "High" Level Voltage Port A,B,C VIH 0.8VCC - VCC V Input ''Low'' Level Voltage Port A,BtC VIL VSS - 0.2VC£: V Input Leackage Current Port AtBtC IIINI Vin-OV - VCC - - 1.0 I1A Input Pull-Up Current Port AtB,C -1&2 Vrr-l.OV, Vin-OV 4 20 40 uA ~HITACHI 361 "LCD DRIVER OUTPUT CHARACTERISTICS(VCC-3.0V,VSs=OV,Ta.-2~ +75°C, unless otherwise noted.) Item Symbol Test Condition min typ max Unit ~OHI VI· I.OOV, V2- 2.00V 2.8 - -V Output "High" Level Voltage Segment VOH2 IOH- -llJA 1.8 - - V VOH3 0.8 - - V VOL 1 VI- I.OOV, V2- 2.00S - - 2.2 V Output "Low" Level Voltage Segment VOL2 IOL- IlJA - - 1.2 V VOL3 - - 0.2 V VOHI VI - I.OOV, V2- 2.00V 2.8 - - V Output "High" Level Voltage Counnon VOH 2 IOH- -5lJA 1.8 - - V VOH3 0.8 - - V VOL I VI - I.OOV, V2- 2.00V - - 2.2 V Output "Low" Level Voltage Common VOL 2 - - 1.2 V IOL= 5lJA VOL3 - - 0.2 V Dividing Resistor RLCD Tested between VI and V2 45 90 180 !ill In the case of Output Output "High" Level Voltage Segment VOH Port, IOH=-30lJA kTCC -0.3 - - V In the case of Output Output "Low" Level Voltage Segment VOL Port, IOL=30lJA - - 0.3 V $ HITACHI 362 __~~______________~_VOHl ~ ______-+______-+____~VOH2 ____________-+__-r____~VOH3 Figure 5-1 Output Level of SEG and COM Common Output V2 COM Segment Output SEG VSS~-------r----~ Figure 5-2 Power Supply Circuit for LCD Display ~HITACHI 363 • AID CONVERTER CHARACTERISTICS*(VCC=3.0V,VSs.OV,Ta=-20·C~ +75°C,C=300pF, unless otherwise noted.) Item Symbol Test Condition min typ max Unit Conversion Accuracy Resolution - - 8 bit Absolute Accuracy VHT.=0.2V< Vin-----Analog Input Voltage - - -......~ (Ladder resistor indicates the compared voltage. ) Figure 5-4 Example of 3 bit Resolution I ~HITACHI 365 6. Application 6.1 How to Confirm Operation Frequency When pin E of the HD63L05 MCU is connected to VCC through the resistor. the system clock ( E ) divided by OSCI is transmitted. The clock output from the OSC2 is available as outputs of the COMI. COM2. or COM3. 6.2 Method of the DAA (Decimal Adjust Accumulator) (1) Function This subroutine is a simulation of the DAA instruction performed by the HD63L05 MCU. This is used immediately after the addition of two bytes (ADD and ADC) which consist of two-digit BCD (Binary Coded Decimal). respectively. This subroutine converts the result of the BCD addition into two-digit BCD to transmit it from the accumulator. (2) Linkage The digit to be converted is input to the accumulator and opera- tion jumps to the routine. (Example) LDA ARGI ADD ARG2 JSR DAA---Jumps to the DAA subroutine STA ARG3 Two-digit BCDs are stored in the ARGI and ARG2 respectively and the operation jumps to the DAA after addition. The result of the addition is converted into BCD and is stored in the ARG3. (3) Result The binary coded decimal digit is output to the accumulator. (4) Register to be influenced (i) IX guarantees the contents before jumping to the routine. (ii) Of the CCR (Condition Code Register). the C bit is set when the result of the BCD addition or decimal conversion is rounded up. The previous contents in each bit of H. N and Z cannot be guaranteed. ~HITACHI 366 (5) Program specification Program specification is shown in Table 6-1. Table 6-1 Program Specification Number of words(B) Work area(B) Execution time(usec) Reentra.nt Relocation 31 Not 2* 410 Possible possib1e** Intermediate interrupt Indicator Possible -- *: It is necessary to provide this work area within the stored RAM ($020 $07F). **: Depending on the situation, it may be necessary to mask the inter- rupt during the execution of this subroutine. I ~HITACHI 367 Figure 6-1 DAA Subroutine Flowchart ~HITACHI 368 Table 6-2 DAA Subroutine Program List ADDRESS OP CODE COMMENT 0044 ATEMP RMB 1 0045 XTEMP Work area RMB 1 0099 B7 44* DAA STA ATEMP* Saves the input value 009B BF 45* STX XTEMP* 009D 5F CLR X Vacates the IX to store the 009E 25 04 BCS DAAH6 converted value. OOAO Al 99 CMP 11$99 Branches if the value is equal 00A2 23 02 BLS DAALOW to or less than $99, otherwise 00A4 AE 60 DAAH6 LDX 11$60 the higher 4 bits are also con- verted. 00A6 29 06 DAALOW BHCS DAAL6 00A8 A4 OF AND II$OF OOAA Al 09 CMP 11$09 It is not necessary to convert OOAC 23 04 BLS DAADNE if the lower 4 bits are less than OOAE 9F DAAL6 TXA $09.Therefore,branching is performed. OOAF AB 06 ADD 11$06 The converted value of the lower OOBl 97 TAX 4 bits. 00B2 9F DAADNE TXA Stores the converted value to A, 00B3 BB 44* ADD ATEMP* adds it to the original(ATEMP) 00B5 BE 45* LDX XTEMP* and prduces an output. 00B7 81 RTS * It is necessary to provide ATEMP and XTEMP within the stored RAM (Address $020 N $07F) in the work area. ~HITACHI 369 6.3 Cautions on the Programming the Write Only Register and Control Register It is impossible to change the Write Only Register Contents (for example, the Data Direction Register (DDR)of the I/O port) of the HD63L05 MCU by applying the Read/Modify/Write instructions. (1) The Write Only Register (for example the DDR of the I/O port) cannot read, the Read/Modify/Write instructions are executed in the following sequence. (i) Reading the contents of the specified address (ii) Changing the read-out data (iii) Returning the changed data to the original address Note that the Read/Modify/Write instructions cannot be applied to the Write Only Register such as the DDR. (2) For the same reason, do not set the DDR of the I/O port or LCD register by using the BSET and BCLR instructions of the HD63L05 MCU. (3) It is necessary to pay attention to the System Control Register, the Timer Control Register, and the A/D Control Register when BSET, BCLR, or Read/Modify/Write instructions are applied to them. If one's own interruption request occured onto the interruption request bit (bit 7) of the Control Register between read cycle and write cycle of these instructions, the bit 7 may be cleared in the write cycle and not acknowledged by cpu. (4) Store instructions, such as STA or STX, are used to write correctly in the Write Only Register or to avoid missing an interruption of the Control Register. 6.4 Cautions on Executing BSR (Branch SubRoutine) Instruction Sometimes the HD63L05 MCU does not execute the address munipu1a- tion normally with the second BSR instruction, if there exists the BSR instruction in the address where branch has occurred. For this reason, do not execute the BSR instruction in the branched address. ~HITACHI 370 The following methods are available for substituting for the second BSR instruction. (1) Insert the No OPeration (NOP) instruction before the second BSR instruction in order to cause a branch in the address in which the NOP instruction has been inserted. (2) Convert the BCR instruction in the branched address into Jump SubRoutine (JSR) instruction. B~R BSR LBL1J LBL1 B~R LBU-->1 LBL1 NOP LBL1 JSR B~R LBU LBL3 --J ______ J LBU ----- LBL2 ----- An example of a An example of a An example of a program which will program in which NOP program using JSR not execute branch instruction is instruction. normally. inserted. 6.5 Cautions (1) To prevent the induced noise, the crystal oscillators should be located as close to the LSI as physically possible. Signal lines should not run pararell with, or across the clock oscillator inputs, such as XTAL, EXTAL, XIN, XOUT. In particular, these clock oscillator inputs should be separated as much as possible. (2) Functions and Cautions A. When STAND-BY goes "High", OSCl, system operation, and peripheral circuits stop. (OSC2 operates). On power up, or when reset, pull STAND-BY "Low". B. OSCl, system operation, and peripheral circuit restart functioning by releasing them from. stand-by mode after the delay time caused by the frequency divider. If OSC2 is provided, clock is provided from OSCI with the system after the delay time selected by $FFI. If OSC2 is not provided, delay time means the period in which ~HITACHI 371 OSCI restarts functioning, after released from stand-by and the period in which judging output of frequency divider, changes by clock pulse transmitted to the delay circuit after restarting the functions. Note that the restart time of the system operation cannot be prescribed precisely when using crystal oscillation, as crystal oscillation affects both the restart time of the oscillation and harmonic oscillation when restarting the oscillation. C. In stand-by status, peripheral circuits (e.g. Time Base, Timer, AID converter, and LCD driver) stop functioning. When Time Base, Timer, AID converter go into stand-by mode during functioning, Timer and Time Base stop functioning and the result of AID conversion cannot be assurred. Transmit the signal specifying if stand-by input is available in order to control the stand-by signal. Then input the stand-by signal to the port. SB Input SP Port Output HD63L05 MCU Figure 6-2 Example of SB Input Masking ~HITACHI 372 7. Evaluation Chip (HD63LOSEO) The HD63LOSEO is a CMOS evaluation chip for the HD63LOS MCU. Connecting an external EPROM (HN48Z73Z) to the chip, it can be operated as a single chip microcomputer HD63LOS MCU. This chip is moulded in a 100 pins flat package. (Refer to Figure 7-1) 7.1 Block Diagram The following describes input signals and output signals of the HD63LOSEO MCU. Basically, the same pin name means the same function as the HD63LOS MCU. • VCC' VSS Power is supplied to the LSI by using these pins. Vce has a voltage of 3.0V±0.8V and Vss is grounded . • 00 This pin is used to interrupt the LSI processing externally. • XTAL, EXTAL Input/Output Pins for the internal oscillator. A crystal (400 kHz typ.) is connected to these pins. • TIMER An external input pin to count down the internal timer circuit. • RES This pin resets the LSI. • STANDBY (SB) This external input pin stops the LSI and holds data. • A/D Input Pins (CHl'VCH8) This is an input pins for analog voltages needed for A/D conversion. These may also be used as level check input under program control. • VRH, VRL Reference voltages for A/D conversion are applied to these two pins. • CCl, CCZ These pins are not user application. They should be left open. ~HITACHI 373 • XIN, XOUT A crystal (32.768kHz) is connected to these pins, for OSC2 oscillation. When OSC2 is not used, connect XIN to VCC. • VCH Decoupling pin from internal voltage regulato~ Connect a capacitor (O.5~F) between VCH and VCC to stabilize the voltage. • MSET This pin is not for user application. Connect it to VCC. • ADCLK This pin transmits a signal with 1/4 frequency of OSCI (100kHz typo synchonized with system clock E). NMOS open-drain output. • U/M The HD63L05EO MCU can take two operation modes based on the state of this pin. When the pin is connected to VCC, the LSI operates as a single chip microcomputer with external EPROM. When the pin is grounded, however, the HD63L05EO MCU operates in external extension mode. • Input/Output Pins (AO'VA7' BO'VB7' CO'VC3) These 20 pins consist of two 8-bit ports and one 4-bit port. Each pin functions as an input or output under program control of the Data Direction Register. These are NMOS open-drain output. • DO'VD7 These pins are input pins for instruction or data from external data bus. For example, output from an external EPROM are applied to these pins. • EO'VE7 These pins are NMOS open-drain outputs. When the U/M is logical "1", the internal address bus (AO'VA7) is transmitted. When the U/M is logical "0", the port E functions either as address bus or as data bus. When system clock E is "Low", port E functions as address bus. When system clock E is "High", port E functions as the peripheral data bus. • FO'VF3 These pins are NMOS open-drain outputs. When the U/M is logical "1", the internal address bus (A8 'VAll) is transmitted. When ~HITACHI 374 the U/M is logical "0", the port F transmits internal address bus while system clock E is "Low". • CE/WR This pin is a NMOS open-drain output. When the U/M is "High", CE signal (means address bus is in from $080 to $FFF) is trans- mitted. When the U/M is "Low", Read/Write clock is transmitted. • LIR NMOS open-drain output. Fetch signal is available from this pin. • HALT NMOS open drain output. When stand-by signal is acknowledged, the output from this pin goes "Low" to control external clock source. • Vl, V2 These are pins for LCD driver. When 1/3 bias - 1/3 duty drive, connect Vl and V2 to VCC through condensor (O.l~F each). I • Liquid Crystal Driver Pins (COM1~COM3' SEG1~SEG17) COM1~COM3 are for driving common electrodes, while SEG1~SEG17 are output pins for driving segments. SEGll~SEG17 functions as either SEGll~SEG17 or as A/D inputs (CH2~CH8) by specifying the function through selecting master-slice data. SEGll~SEG17 are multiplexed with A/D inputs (CH2~H8)' ~HITACHI 375 e HD63L05EO ~ I~ ~ ~!~««««m~.m====~ I;. :; .... ; NO • NO "'AL " y. NC 'INC BXTAt " F, NO ,. F. .... "NO '.. NO ..... "NO SB " .. "'" NO "I:.E, XIN "NO 'I E, X~ I~ TINBR D. ~ "~ iifiT •• D. .... ~ uNO -- m ~ "~ ... -~ ~ ..."~ "~ NO u. NO 810.. /Oil II tl C, NO ~ ~H~ NC: No Connection ~; ~~~~i,-~~~~~~~~~~~ Figure 7-1 (a) Pin Assignment (Top View) Unit: mm(inch) eFP-100 2.9malC. (0.1 14m.. .) ~±O.I 0.006) (0.012±0.004) . (0 00& ± 0.002) ~IHii'.H._"""'••yrt_15: 1.7±0.3 (0.061 ±0.oI2l Figure 7-1 (b) Package Information ~HITACHI 376 _f~5EO COlllllOn Driver COM, COMI Out ut He.~I---lI- COM. Data SEG, Latcb m~ SEGz S LCDl ':l SEG. I>- SEG4 LCD 2 ':l ADCLlt s 0 ~ LCD 3 ....: "'~ XIN XOUT 7 ~ fi •• !:I ... imT l " i.. LCD? 7 U/M LCD 8 '" 40 TIMER nIT ... III .. ..... , III ~!:I ~ > " ~ Accumulator s A "0·0... u to : CH, , ..... ~ In ex ....0 " 0 u (CHI) (CHa) Ao AI AI ...... U .. ~ 00 SRegister Condition X ....... !:I ~ -< g ~ -< (CH') (CH,) (CHe) t: Ae A. ;::~ .. " ...... ... 0 sCode Reg'CCR Stac SPointer L._ u ........-r--'-- (CH.) (CHa) !:I'" SP Bo rogram B, Counter Bz B. I 4 "Higb" PCH ALU B. Program B. Counter 8 IlLow" PCL '--. . . .-r---B. Be Co C, Cz Cs Fo '" Fa Eo '" E. Do ( ) Program Selection Figure 7-"2 HD63L05EO Block Diagram $ HITACHI 377 ,...-----1 ADCLK (E: 100kHz) ADB PDB CPU PERIPHERAL WR PERIPHERAL RD EN CPU Read CLK PORT D DATA TO CPU ~~~X!§~~~~==x==:j MULTIPLEXED ADD & DATA (MONITOR MODE) PORT E{ _ _ _ _ _ _ _--1 ADB (USER MODE) L_r-iiLo;rrl ADB (MONITOR MODE) PORT F{ ~ _____ ~ ADB (USER MODE) MV,C, R/W (MONITOR MODE) CHIP ENABLE (USER MODE) Figure 7-3 HD63L05EO Timing Chart ~HITACHI 378 7.2 Memory Map Figure 7-4 shows a memory map of the HD63L05EO Meu. $OOav$07F is contained in the LSI. $OSav$FFF is not contained, thus it is necessary to connect external EPROM (HN4S2732) to $OSav$FFF. $F3av$FF3 is not for user application, for Hitachi will replace these addresses by the self check program. PORT A $000 PORT B SOOI I I I I I PORT C S002 NOT USED Soos PORT A DDR· SOH PORT BOOR· S005 NOT USED 1 PORT C DDR· S006 NOT USED S 001 TIMER DATA REGISTER S 008 TIMER CTRL REGISTER S009 SOOA NOT USED SOOD A/D DATA REGISTER SOOE A/D CTRL REGISTER SOOF $080 SOlO US ER PROGRAM NOT USED SOlS LCDI DATA REGISTER· 8 So l4. LCD2 DATA REGI STER· 8 SOl5 SF2F LCDS DATA REGI STER· 1 $016 SFSO LCD+ DATA REGISTER· 1 SOl1 LCD5 DATA REGISTER· 1 SOl8 Reserved LCD6 DATA REGISTER· 1 SOl9 LCD1 DATA REGI STER· 1 SOIA NOT USED I LCOS DATA· + SOIB SFEF SYS CTRL REGISTER So IC MASTER SLICE (I) SFFO SOlD MASTER SLICE (2) SFFI NOT USED / $ 0 IF SFF2 SFFs RAM (96BYTE) ?20 TIME BASE VECTOR H SFr. TIME BASE VECTOR L SFF5 -------------------- STACK A/D VECTOR H SFF6 /060 A/D VECTOR L SFF1 SOH TIMER VECTOR H SFFS EXTERNAL EP ROM $ 080 TIMER VECTOR L SFFy INT VECTOR H SFFA INT VECTOR L SFFB $FFF SWI VECTOR H $FFC ~ • Write only register SWI VECTOR L SFFD RES VECTOR H SFFE RES VECTOR L SFFF Figure 7-4 Memory Map ~HITACHI 379 7.3 Pin Functions and Applications (I) Power 3V is supplied to VCC' then VDD is grounded. VCC is connected to VCH through a condensor. (VCH :::+lV is transmitted) VI and V2, which are connected to VCC through a condensor, are voltage pins for LCD drive. (VI :::+lV, V2 :::+2V are transmitted.) (2) Control Signals Connect U/M and MSET to VCC' (3) Interfacing to the user system. (a) I/O port (AO'VA7' BO'VB7' CO'VC7) Each pin has NMOS open-drain output. Therefore, "High" level of the output is obtained by connecting a resistor to VCC' When using as an input port, connect pull-up resistor to VCC' if necessary. (b) Control pins (RES, INT, SB, TIMER) Only RESET is connected to VCC through internal pull-up PMOS in the LSI. To avoid the floating input to 1Jf.f, S.B, or TIMER, connect pull-up resistors between these terminals and VCC, if necessary. (c) Others (SEGl'VSEG17, COMl'VCOM3, CHl'VCHa, CCl. CC2, VRH, VRL) Bit correspondence between SEGI 'V SEG17 and LCD register is fixed, which fixes the pin allocation and does not support the port function as an output only port. Note that the pin allocation of the HD63L05EO MCU is not equivalent to that of the HD63L05 MCU. The selection between SEG13 'V SEG17 (and master slice analog input CH2 'VCH a ) can be specified by the external EPROM data. VRH and VRL of the HD63L05EO MCU is equivalent to those of the HD63L05 MCU. $HITACHI 380 (4) Interfacing to External EPROM (a) Data inputs (DO "'D7) Connect the output pins from the EPROM to these pins. Provide pull-down resistor to reduce input high level. (b) Address Outputs (EO "'E7, FO "'F3) The address signals (AO "'All) is transmitted from these pins to EPROM. Connect them to VCC of the EPROM with pull-up resistors. (c) Chip Select Output (CE) Connect it to VCC of the EPROM with pull-up resistor. When ROM address is selected (from $080 to $FFF), "Low" level is available. (5) Others (HALT, LIR, ADCLK) Normally, these pins are not user application. Keep them open. ~HITACHI 381 +3V Vcc 1 1 1 o.1 )JF O.1)JF O.5)JFT VCR VI V2 OV VSS RD63L05EO Figure 7-5 Connections for Power Supplying ~HITACHI 382 VCC ---]1J-- XTAL VCH --- 32. 768kHz CJ XIN I Crystal xour HD63L05EO (b) Figure 7-6 Connections for the Oscillators ~HITACHI 383 Vee OUTPUT; R=20kfl INPUT; R=150kfl R Vss Figure 7-7 eonfigurati~~J NMOS open-drain Output ~HITACHI 384 +3V +5V I _ ov -I VCC ~Rh VCC DO 00 Dl 01 D2 02 D3 03 D4 04 DS 05 D6 06 D7 07 EO AO El Al E2 A2 E3 A3 E4 A4 ES AS E6 A6 E7 A7 FO AS Fl A9 F2 AlO F3 All R2 ~ HN482732 HD63LOSEO +SV ..... (EPROM) (Evaluation Chip) ~ R2 CE CE r- OE VSS GND OV OV Figure 7-8 Interfacing between HD63LOSEO and EPROM Rl, R2 = 20kO ~HITACHI 385 7.4 The Comparison between the HD63L05 MCU and the HD63L05EO The HD63L05EO MCU is an evaluation chip for the HD63L05 MCU, which supports the HD63L05 MCU function by connecting EPROM externally. However, these two devices have some differences in the architectures. Table 7-1 summarizes these. Table 7-1 The Comparison between the HD63L05 MCU and the HD63L05EO MCU HD63L05EO NO. ITEM HD63L05 HD63L05EO NOTE 1 Operating Voltage 2.2V"'3.SV XTAL/CR Mask option · XTAL Current cannot be supported. CR oscillation is 2 OSCI not supported. 3 OSC2 with OSCZ/without mask option · Selectable 4 REs ----.r-- · Master slice data is set while reset-ilL" 5 INT ~ · 6 TIMER VCC Timer input pin Normal mode · User Mode Equivarent to U/M 7 NUM VSS Test mode Monitor Mode Not supported 1/2VCC Self check mode -- Not supported S 9 STANDBY MSET Standby input -- · Present Standby delay time is se1ec table Not used 10 VRH/VRL A/D Standard voltage · 11 CCl/CC2 Not used · 12 13 CHI "'CHS Port input A/D input pins Pull-up R mask · Without pull-up R pin allocation of CH7/CHR is different type option !'ort output CMOS 14 NMOS Open drain type NMOS open drain LCD 1/3 bias 1/3 duty, Only 1/3 bias 1/3 Fixed pin location 15 static,output pin, duty is supported pin master slice 16 Pin location Specified by mask Fixed pattern option Liquid power sourcel Pin allocation of 17 Vb V2 Crystal source. CH7,CHS' CH7/CHS is different IS 19 VCH E LSI Goes to "Low" when Reset/Halt/S.B. · Goes to "Low" li1hen S.B. Equivalent to ADCLK 20 Port D -- Data input port Address,data output 21 Port E -- port 22 Port F -- Address output port Goes to "Low" 23 HALT -- when S.B. Goes to "Low" 24 LIR -- when Fetch cycle -eE'="Low" in the 25 CE/WR -- address $OSO"'$FFF 26 PACKAGE FP-SO/DP-64s FP-lOO ~HITACHI 386 7.5 LCD Output Note that LCD output of the HD63L05EO MCU is for 1/3 bias-1/3 duty drive and its pin location block is fixed. Table 7-2 Connections of the Pin location Block LCD regi~ter Timing SEGMENT Pin LCDI-O COM. SEG. I COM. SEG. z COM I SEG. S COMI SEG. 4 COM I SEGI 5 COM. SEGI 6 COM. SEGI ? Not used Not used LCD2-0 COM. SEG. I COM' SEG. 2 COM. SEG. S COMI SEG. 4 COM. SEG. 5 COM. SEG. 6 COM. SEG. ? Not used Not used LCDS-O COM. SEGe I COM. SEG. 2 COMI SEG. S COMI SEGe 4- COMI SEGs 5 COM. SEGo 6 COM. SEG. LCD4--0 COM. SEG. I COM. SEG. z COMI SEGlo S COMI SEG. 4 COMI SEGa 5 COM2 SEGa 6 COM. SEGa LCD5-0 COM2 SEGII I COM. SEGI2 z COM2 SEGI2 S COMI SEGn 4 COM2 SEGlo 5 COM. SEGlo 6 COM. SEGn LCD 6-0 COM. SEGI. I COM. SEGI. z COM I SEGI4 3 COMI SEGI3 4- COMI SEGI2 5 COM. SEGu 6 COM. SEGI4 LCD? -0 COM. SEGlo I COM. SEGlo 2 COMI SEGI. 8 COMI SEGle 4 COMI SEGI. 5 COM. SEGt5 6 COM. SEGls LCD8-0 COM. SEGI. I COM. SEGI. 2 Not used Not used 3 Not used Not used ~HITACHI 387 7.6 Setting the mask-option data The HD63LOSEO MCU contains two additional registers to specify the master-slice data for SEGll~SEG17 (CH2~CHa) and internal oscillator mask options. During the RES input is "Low", address bus (AO~All: from Port E, Port F) become alternately $FFO and $FFI. Therefore, the output data from the external EPROM (Address are $FFO and $FFl) can be written into these registers through Port D. 3 cycles are necessary for writing the master-slice data into the registers. Table 7-3 Master-slice select register in EPROM Bit iAddress Data 7 6 S 4 3 2 1 0 Master Slice $FFO 0 * CH2 CH3 CH4 CHS CH6 CH7 CHa Register 1 * SEG17 SEG16 SEGlS SEG14 SEG13 SEG12 SEGll (1) Master OSC2 0 * * * o sec 1/16 1/2 1 sec Slice $FFI Not Register used sec sec (2) OSC2 Set I-bit within 4 bit to 1 * * * Used "1". Set others to "0". * : These bits are not used, write "0". Note that only one bit of OSCI Delay Time select bits can be set to logical "0". System clock (ADCLK) ~In selecting delay time, it will delay the start. Fig. 7-9 Start from Reset ~HITACHI 388 7.7 Electrical Characteristics • ABSOLUTE MAXIMUM RATINGS Item Symbol Value Unit Supply Voltage VCC -0.3 'V +5.5 V Input Voltage Vin -0.3 'V VCC+O. 3 V Output Voltage Vout -0.3 'V VCC+0.3 V Operating Temperature Topr -20 'V +75 °c Storage Temperature Tstg -55 'V +125 °c (NOTE) Permanent LSI damage may occur if maximum ratings are exceeded. Normal operation should be under recommended operating conditions. If these conditions are exceeded, it could affect reliability of LSI. I ~HITACHI 389 • DC CHARACTERISTICS (VCC=3.0±0.8V, VSs=OV,Ta=-20 "-+75°C, typ means typical value at VCC=3.0V unless otherwise noted.) Item Symbol Test min typ max Unit Condition Connect Input XTAL, XIN CL=0.511F VC C-0.3 - VCC V "High" to VCH Level Voltage RES, INT, SB O.5VCC+0.9 - VCC V TIMER VIH 0.8VCC - VCC V U/M (User Mode) VCC-O .2 - VCC V Connect Input XTAL, XIN CL=0.511F VCC-2.l - VCC-1.8 V "Low" to VCH Level RES, INT, SB Vss - 0.2VCC V Voltage TIMER VIL Vss - 0.2VCC V U/M (Monitor Mode) Vss - 0.2 V Input Pull- VCC=3V, RES -I RI 3 15 30 llA Up Current Vin=OV Input Vin=OV "- Leakage Current TIMER, SB IIINI VCC - - 1.0 llA During System f=400kHz, - 100 200 llA Operation No load. Tested Current Crystal At Halt ICC after set- - 40 80 llA Diss ipat ion (400kHz) At ting up Standby the inter- - 2 5 llA nal status At AID Operation - 200 600 llA ~HITACHI 390 • AC CHARACTERISTICS (VCC=3.0±0.SV, VSS=OV, Ta=-2OV+75°C, typ means typical value at VCC=3.0V unless otherwise noted.) Item Symbol Test Condition min typ max Unit Operating Clock Frequency fcl 100 400 500 kHz Cycle Time tcyc 8 10 40 llS External Clock Duty Duty 45 50 55 % CD=10pF+20%, Oscillation Start Time (OSCI) tOSCf RS=lkn - - 150 ms CD=10pF+20%, Oscillation Start Time (OSC2) tOSC2 RS=20kn - - 1 s Internal Capacitance I OSCI EXTAL - 10 - pF of the Oscillator I OSC2 CD XOUT - 10 - pF Delay Time of Oscillation (Program) t DLy 0 - 1 s Reset Delay Time tRLH 200 - - ms m Pulse Width tRWL 48 - - lls !NT Pulse Width tIWL 32 - - lls TIMER Pulse Width tTWL tcyc+l - - llS I ~HITACHI 391 • PORT CHARACTERISTICS (VCC=3.0±O.8V, VSS=OV, Ta=-2OV+75°C, typ means typical value at VCC=3.0V unless otherwise noted.) Item Symbol Test Condition min tva max Unit Output "Low" Level Voltage Port A,B,C Vnt . IOL=lOOIlA - - 0.3 V Input "High" Level Voltage Port A,B,C VIH o.BVee - Vee V Input "Low" Level Voltage Port A,B,C V1L V•• - O. 2Vee V Input Leackage Current Port A,B,C IIINI Vin=O "-VCC - - 1 IlA Output "Low" Level Voltage ADCLK.«.L!I( 'iiAL'T",Port E,F VOL IOL=200IlA - - 0.3 V Input "High" Level Voltage Port D .- V,H O.BVee - Vec V Input ltLowlf Level Voltage Port D V,L Vas - O. 2Vee V • LCD DRIVER OUTPUT CHARACTERISTICS (VCC=3.0V, VSS=OV, Ta=2OV+75°C, unless otherwise noted.) Item Svmbol Test Condition min tvo max Unit vOHl 2.8 - - V Vl- 1.00V, v 2 - 2.00V Output "High" Level Voltage Segment ~-- 1.8 - - V IOH- -lilA VOH3 0.8 - - V VOL 1 vl- 1.00V, vz- 2.00V - - 2.2 V Output "Low" Level Voltage Segment VOL2 IOL- lilA - - 1.2 V VOL3 - - 0.2 V VOHI I.OOV', v 2 - 2.00V 2.8 - - V vl - Output "High" Level Voltage Common VOH2 10H- -51lA 1.'3 - - V VOH3 0.8 - - V VOLI vl- 1.00V, v 2 - 2.00V - - 2.2 V Output "Lew" Level Voltage Connnon VOL2 IOL= 51lA - - 1.2 V VOL3 - - 0.2 V Dividin~ Resistor RLCD Tested between VI and V2 45 90 180 kS"l In the case of Output Output "High" Level Voltage Segment VOH Port, IOH-- 3OIlA CC-0.3 - - V In the case of Output Output "Low" Level Voltage Segment VOL Port, IOL= 30llA - - 0.3 V ~HITACHI 392 "';;';=~ ______-L.._ VOHI VOH2 --------~------~--~-- VOR3 ------------~--~--~-- Figure 7-10 Output Level of SEG and COM VCC COlllllon Output I V2 COM VI SEG Segment Output VSS Figure 7-11 Power Supply Circuit for ~CD Display ~HITACHI 393 ---------- • AID CONVERTER CHARACTERISTICS *(VCC-3.0V, VSS-OV, Ta--20·C '\.+7S·C unless otherwise noted.) Item Symbol Test Condition min typ max Unit Conversion Accuracy Resolution - - 8 bit Absolute Accuracy VRT.=O. 2V < Vin.::I 3 o 2 1 o o 1/8 2/8 3/8 4/8 5/8 6/8 7/8 8/8 Analog Input Voltage (Ladder resistor indicates the compared I voltage.) Figure 7-13 Example of 3 bit Resolution ~HITACHI 395 8. ROM Code Order Method User's programs are mask programmed into ROM by Hitachi to be shipped as LSI. Users are requested to hand in three EPROMs in which the same contents are written,order specifications,mask option list, • and list of the ROM contents. Relationship between the address of the mask ROM and that of the EPROM is shown in Table 8-~ Write $FF for the unused address data of the EPROM. Table 8-1 Relationship between the Address of Mask ROM and that of EPROM Type name Address of Address of Remarks Mask ROM EPROM $080 A User programs are C' ) $080 C' written in 'this area. $F2F $F2F $F30 A $F30 This area is used for HD63L05Fl C' ) C' the Self Check program $FF3 " $FF3 by Hitachi. $FF4 " $FF4 User supplied vectors are C' C' written into this area. $FFF " $FFF EPROM is a HN482732 or equivalent product. ~HITACHI 396 I APPENDIX I. Design Procedure and Supporting Tool Cross assembler and Hardware emulator, containing various kinds of computers, are available as supporting systems to develop users' programs. Hitachi will mask program users' programs into ROM to ship them as LSI. Figure 1-1 shows a typical program design procedure. Table 1-1 summarizes a set of system development supporting tool for the HD63L05 MCU. ~ (i) Text Editor Host Computer ® @ @ @ Cross Assembler Evaluation Kit Host Computer ® Emulator Evaluation Kit I The following explains the system development procedure. 1. Specify functional assignment of I/O pins, and allocation of RAM area before starting programming. 2. Design flowchart to implement the functions -and encode this flow- chart with mnenic codes. 3. Write the coded format on cards or a floppy disk. This set of coded form is a source program. 4. Assemble the source· program to form an object program with an assembler on either a resident system(evaluation kit) or cross system. Then check errors out. 5. Verify the program through hardware simulation by an aid of evaluation kit 6. Send the completed program in EPROM to Hitachi. 7. After Hitachi received users' specified ROM pattern and options, Hitachi will pilot product sample LSI for users I evaluation for the functions. If a user finds no problem in the sample LSI, Hitachi will start mass production of the LSI. Figure 1-1 Program Design Procedure ~HITACHI 397 Table I-l System Development Support lbol IBM PC Type No. Evaluation Kit Cross Assembler HD63105Fl H315EVTl S35IBMPC ~HITACHI 398 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 (!) ROM code * 1 *1 2 sets of EPROM @ Mask Option List *2 *2 Part specific @Ordering Specifica- *3 Generic for Hitachi tions *3 microcomputers Comput.ar processing I y *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 I *5 t *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) *6 I I • ® Confirmation of func- tion, characteristics *7, *8 I OK + Engineering Sample (ES) I *9 I Confirmation of func- tion, characteristics, quality Commercial Sample (CS) I (E!n) (Note) Please send in(!), ~, and (j)at ROM ordering, and send back ~, ® after approving. Device Development Flowchart ~HITACHI 399 (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 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 guaranteed 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. (Commercial 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. ~HITACHI 400 HD63L05F1 ORDERING SPECIFICATIONS (1) GENERAL CHARACTERISTICS (Fill in blank space or appropriate boxD ). Device Package Outline Type (See Section) D DP-40 D CP-44 3,4.1 D FP-54 Application Options!Remarks: (be specific) Customer ROMCodeID ROM Code D EPROM M S 'f Customer Programmed Start Address Media ust pecl y: D ZTAT™ Customer Programmed Stop Address Operating Temperature D Standard D J Specification (-40"c to +8S"C), if offered Remask DYes DNo Previous Hitachi PIN (2) OPERATING CHARACTERISTICS LSI Average ·C D 500 Fit D( ) Ambient Target Level Temperature Range Of Reliability D 1000 Fit 'C- 'c LSI Average I % Acceptable D 1.0% D 0.4% Ambient Humidity Range %- % Quality Level D 0.65% D( ) Power On Average Hours!Day Remarks: Duration Maximum Applied Power Max V Voltage To LSI Supply I/O Max V (3) ELECTRICAL CHARACTERISTICS D Purchasing Specifications D Hitachi's Standard Specifications Refer To Data Sheet: ( For Hitachi Use Only) (4) CUSTOMER APPRO VAL (5) ROM CODE VERIFICATION Customer Name LSI Type No. PO# Accepted By (print) Shipping Date of ROM To Customer Accepted By (signature) Approved Date of Date ROM From Customer ~HITACHI 401 HD63L05F Date of Order MASK OPTION LIST Customer Dept. Accepted by * Select one type for each item ROM Code ID. and check. LSI Type No. HD63L05F (1) OSC Option Select one type of OSCI option. Type of Use of OSCI OSC2 Condition *1 XTAL OSC. CR OSC. *1 Crystal option of OSCI is not allowed to stop at halt. *2 If OSC2 is not used, the delay time is not accurate. *3 All CR option of OSCI allowed to use of stand-by mode. (2) I/O Option Specify an I/O option for each terminal. Port Mask Option A B C D AO Al A2 A3 A4 AS A6 A7 BO *4 Specify K-type if L-type is selected at LCD driver. B1 B2 A: Output without input pull-up PMOS. B3 B: Output with input pull-up PMOS. B4 C: Output for key scanning.- BS D: Open drain output. (Max. VCC) B6 E: Input without pull-up PMOS. 137 F: Input with pull-up PMOS. ' Co G: A/D input. C1 H: Segment output. C2 K: Terminals for LCD display. C3 (3) LCD Driver Specify a type of LCD driver. Mask Option L: 1/3 bias-I/3 duty LCD. SIP S: Static LCD. Segment I I P: Output Port. ••• Mask options indicated as _ are not available •••. ~HITACHI 402 LCD Pin Location LCD B Timing Segment Output Terminal Regis- I COM COM COM SEG SEG SEG SEt; SEG SEG SEG SEG SEG SEG SEG SEG SEG SEG SEG SEG SEG U 0 ter T 1 2 3 1 • 2 3 4 5 6 7 S 9 10 11 12 13 14 15 16 17 18 19 LCDl 0 1 2 3 4 5 6 7 LCD2 0 1 2 3 4 5 6 7 LCD3 0 1 2 3 4 5 6 LCD4 0 1 2 3 4 5 6 LCD5 0 1 I 2 3 4 5 6 LCD6 0 1 2 3 4 5 6 LCD 7 0 1 2 3 4 5 6 LCDS 0 1 2 3 4>WRITE 0 1/4-oSCl 0 * Specify the combination of timing and segment output terminal for each bit of LCD1 to LCD8. * When static or output port is selected. The timing is fixed at COM1. So specify COM1. * Don't specify the timing or segment output terminal for the terminal A/D input is selected at (2) I/O option. * Specify the LCD pin-location even in such a case as unused segments are provided, and program to put out those segments. The indication of segments cannot ,be defined as Hitachi will connect unspecified segment to any registers to prevent circuit from malfunctioning. ~HITACHI 403 ~HITACHI 404 HD630S/HD63LOS SERIES HANDBOOK Section Six Software Application Notes ~HITACHI 405 ~HITACHI 406 FOREWORD The HD6305 is a family of 8-bit single chip CMOS microcomputers controlled by microprogramming. This family provides an easy to use instruction set by adding instructions for decimal adjustment and a low power consumption mode to those of the NMOS HD6805 FAMILY. APPLICATION NOTES summarize typical programs for the HD6305 FAMILY to help users better understand the 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. ~HITACHI 407 ~HITACHI 408 Section 6 Software Application Notes Table of Contents Page 1. HOW TO USE APPLICATION NOTES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 413 1.1 Formats..................................................... 413 1.1.1 Specification Format (Format 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 415 1.1.2 Description Format (Format 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 421 1.1 .3 Flowchart Format (Format 3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 424 1.1.4 Program Listing Format (Format 4). . . . . . . . . . . . . . . . . . . . . . . . ... . .. 426 1.2 How to Execute Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 428 1.3 Symbols..................................................... 430 PROGRAM APPLICATION EXAMPLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 431 Program Application Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 MOVING DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 434 1. Filling Constant Values (Fill) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 2. Moving Memory Blocks (Move) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439 3. Moving Strings (Moves) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 446 BRANCHING FROM TABLE (CCASE). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 452 4. Branching from Table (CCASE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 452 HANDLING ASCII. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 459 5. Converting ASCII Lowercase into Uppercase (TPR). . . . . . . . . . . . . . . . . . . .. 459 6. Converting ASCII into 1-Byte Hexadecimal (Nibble). . . . . . . . . . . . . . . . . . . .. 464 7. Converting 8-Bit Binary Data into ASCII (Co byte) . . . . . . . . . . . . . . . . . . . . . .. 469 BIT MANIPULATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 474 8. Counting Number of Logical "1" Bits in 8-Bit Data (HCNT). . . . . . . . . . . . . .. 474 9. Shifting 16-Bit Data (SHR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 479 COUNTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 10. 4-Digit BCD Counter (DECNT) ............... . . . . . . . . . . . . . . . . . . . .. 484 ~HITACHI 409 COMPARISON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 489 11. Comparing 16-Bit Binary Data (CMP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 489 ARITHMETIC OPERATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 495 12. Adding 16-Bit Binary Data (ADD). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 495 13. Subtracting 16-Bit Binary Data (SUB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 501 14. Multiplying 16-Bit Binary Data (MUL) . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 507 15. Dividing 16-Bit Binary Data (DIV). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 513 16. Adding 8-Digit BCD (ADDD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 519 17. Subtracting 8-Bit BCD (SUBD) . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 18. 16-Bit Square Root (SQRT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 531 CONVERTING BCD INTO HEXADECIMALS ............................. 537 19. Converting 2-Byte Hexadecimals into 5-Digit BCD (HEX) . . . . . . . . . . . . . .. 537 20. Converting 5-Digit BCD into 2-Byte Hexadecimals (BCD) . . . . . . . . . . . . . .. 542 SORTING......................................................... 549 21 . Sorting (SORT). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 549 ~HITACHI 410 APPLICATION NOTES GUIDE ~HITACHI 411 ~HITACHI 412 < HD6305 FAMILY APPLICATION NOTES GUIDE> 1. How to Use APPLICATION 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 2 -DESCRIPTION 1 RAM Description Sample Application Basic Operation SPECIFICATIONS Format 1 DESCRIPTION 1Function Format 3 -FLOWCHART Details' User Notes Format 4 - PROGRAM LISTING SPECIFICATIONS NOTES Forma t 4 - 1 1"'-1 ...31» "/IlLY 1........ 1 PlIOClWlLlSTDIC Format 3-1 1"'-1 1""'1 ......... 1D6:J01'MlU.Y Format 2 -~L 100,-r 1III6:J05 'MIlLY 1..... 1 DUCunlOil Format 1 - "'_I IID6lO5FAIIILT 1........ 1 .lIKtllII ~ ClWICISlACftl Imlll'l'lUMlDruu IPICIFlCATICIIS --eTIiIi • (..,tood ~ CoIIhIIU Itorale .,u Location Lith. . ; I1114eHMIII r ......lt ~ . ," ~ ~ ~ . l.. ~ ::; 1;;;;;- , - ... , lee.Cion Itfttarl'\lft ~ ~ f- - SPlClnCAnllllll lObI - Fig. 1.1 APPLICATION NOTES Formats ~HITACHI 413 Programs in APPLICATION NOTES can be implemented in two ways, i.e. (1) without change or (2) partially changed. Read the information that applies to the type of implementation to be carried out. (1) Without change (a) All of Format 1 (b) RAM Description and Sample Application in Format 2 (c) PROGRAM LISTING in Format 4 (2) Partially changed (user originals) All of Formats 1 to 4 after reading these formats, change the FLOWCHART and PROGRAM LISTING according to user specification. ~HITACHI 414 1.1.1 SPECIFICATION Format (Format 1) SPECIFICATION Format is represented in Fig. 1.2. It gives program functions and specifications. Each item in the format is described using Fig. 1. 2. {\ ) . ITEM NUMBER AND PROGRAM NAME I MCU/MPU I HD6305 FAMILY I LABEL I (4 ) . FUNCTION I )6) I) (5 ) ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPEC IFICATIONS • : No t offec ted ROM (Bytes) x : Undefined Storage Byte Contents Location Lgth. 1 : Result RAM (Bytes) I ACCA IX Stack (Bytes) Entry I I No. of eye les ~ Argu- ments Reentrant N I Relocation Re- turns H Interrupt (8) . DESCRIPTION I (1) Function Details (2) User Notes (9 ) • SPECIFICATIONS NOTES I Fig. 1.2 SPECIFICATION Format ~HITACHI 415 (l) ITEM NUMBER AND PROGRAM NAME: Indicates item number and program name in APPLICATION NOTES. Program name {2} K:u/MPU: Indicates names of microcomputer and microprocessor family applicable to a program. HD6305 FAMILY IQ) L Microcomputer FAMILY HD6305 and microprocessor family name {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 l6-bit binary data in RAM to right. (b) Permits number of shifts to be freely determined. (0) Permits easy ..,1tiplioation of l6-bit binary data by 2-n (n : number of shifts). ~HITACHI 416 (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 label followed by "(RAM)". (c) Byte Length: Indicates byte length of the arguments. ARGUMENTS I Contents Storage Byte Location Lgth. 16-bit b-inary data to SFT 2 be (RAM) Entry shifted Argu- to right menta Number of IX 1 shifts Re- Shift SFT 2 turns results (RAM) (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 IX: Index register (b) Flags of condition code register C: Carry/borrow flag (carry and borrow) 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) ~HITACHI 417 (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 (Notes) REGISTERS AND FLAGS • : Not affected In the example, after executing a program, x : Undefined contents of index register (IX), condition I : Result code register (CCR), bit C, bit N and bit Z ACCA IX will be destroyed. Thus, register contents • which will be destroyed should be saved C z before executing a program. N • (7) SPECIFICATIONS: Explains a program specification. (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, 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» ~HITACHI 418 (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) 8 RAM (Bytes) 2 Stack (Bytes) 0 No. of cycles 110 Reentrant No Relocation No Interrupt Yes (8) DESCRIPTION: Explains detailed functions of a program and user notes. (a) Function Details : Gives an execution example and detailed functions of a program. (b) User Notes Explains notes and limitations when execut- ing a program. * Be sure to read these items when using the programs without change. ~HITACHI 419 DESCRIPTIOII (1) Function Details _ (a) Arg...nt d.etails SPT Holda l6-bit binary data to (!WI) be sbifted to rigbt. After SHR execution, containa sbift result. IX Holds nuaber of l6-bit binary data to be shifted to right. Fig. 1 EXIIIP1e of SHR execution (b) Fig. 1 shows example of SHR execution. If entry arg.....nts are held as shown ift p,art@ of Fig. 1, l6-bit binary data is shifted to right as shown in part @of Fig. 1. (2) User Rotes Be sure to hold data into IX within range of $01 S IX S ,OF. When data outside this range is held, SFT (RAIl) becomes "0". (9) SPECIFICATIONS NOTES: Explains notes on data process written in SPECIFICATIONS (7). SPECIFICATIONS IlOTESJ ''Mo. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to shift 16-bit binary data to right by 7 bits. $ HITACHI 420 1.1.2 DESCRIPTION Format (Format 2) 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. ,-(2) r (3) (1)- ITEM NUMBER AND PROGRAM NAME I I£U/MPU I 1ID6305 FAMILY (4) - DESCRIPTION I (3) RAM Description (4) Sample Application (5) Basic Operation Fig. 1.3 DESCRIPTION Format (1) ITEM NUMBER AND PROGRAM NAME } Same as SPECIFICATION (2) MCU/MPU Format (3) LABEL ~HITACHI 421 (4) DESCRIPTION: Gives RAM Description, Sample Application. and Basic Operation (a) RAM Description: Explains label and meaning of the RAM used in a program. 1106305 FNlILY SHR (3) RAIl Description Label RAil Description SFT Upper byte l6-bi t binary data to be shifted to right is stored before execution. Lower byte Shift result is stored after execution. (b) Sample Application: Gives a sample application in actual use. (4) Saq>le Application SHR subroutine is called after number of shifts and' l6-bit binary data to be shifted to right are held. WORKl RMB ------Reserves memory byte for 16-bit binary data. WORK2 RMB ---- Reserves memory byte for number of shifts. WORK3 RMB ----- Reserves memory byte for l6-bit binary shif t resul ts • WORK 4 RMB ---- Reserves II8IIOry byte for register contents saving. STX WORK4 - - Saves register contents that will be destroyed by executing SHR. LDA STA LDA WORKl SFT WORKl+l 1 Stores l6-bit binary data to be shifted into right in entry argument (SFT). STA SFT+l LDX WORK2 ----- Loads number of shifts into entry argument (Ix). II JSR &L.:.=_~s;:;;HR:;..aH ----- Calls SHR subroutine. LDA STA SFT WORK3 ) Stores shift results regarding l6-bit LDA SFT+l ----- binary (return argwaent (SFT» in RAIl. STA WORK3+l LDX WORK4. ----- Restores register. ~HITACHI 422 (c) Basic Operation: Indicates operating principles of a program. (5) Basic Operation (a) Upper 8 bits in l6-bit binary are shifted to right. Here LSB is rotated to bit C. Lower 8 bits are then rotated to right. At this time, LSD in bit C is rotated to MSB of lower 8 bits. (b) IX is used to keep track of number of shifts. IX is decremented each time 9. SHIPTDlG 1IDf>30S PMILY SRR FLOWCHART Shifts upper 8 bits in l6-bit binary to L...---,--''---' ----{ right. and shifts LSB to bit c. Rotate. lower 8 bits in l6-bit binary to ~----J right. Rotates LSB of upper 8 bits to ItSB ----{ of lower 8 bi ts. L - - - . - - - - - - l ----{ Decrements shift counter. ( IX) ----{ Tests if shift is completed. ~HITACHI 425 1.1.4 PROGRAM LISTING Format (Format 4) PROGRAM LISTING Format is represented in Fig. 1.5. Each item in the format is described using Fig. 1.5 (1) (2) (3) I I I ITEM NUMBER AND PROGRAM NAME I II:U/MPU t IID6305 FAMILY ILABEL I (4)------~p~~~G~~~L~IS~T~m~G===y-I------~------L-------------~---L---I Fig. 1.5 PROGRAM LISTING Format (1) ITEM NUMBER AND PROGRAM NAME } (2) MCU/MPU Same as SPECIFICATION Format (3) LABEL ~HITACHI 426 (4) PROGRAM LISTING: 9. HD6305 FAMILY SHR PIlOGRAK LISTING 00001 (a 00002 00003 00004 00005 00006 00007 (c)~' ENTRY: SFT <16-BIT aINARY DATA) OOOOB 00009 00010 00011 . II< IX 6305 FAMILY MOVE DESCRIPTION (b) Fig. 1 shows example of MOVE execu- b15 SOA SOA+l bO tion. ~Nffi') I 1 I 0 : 0 I 1 : 0 If entry arguments are as shown in b7 DEA. bO CD Entry DEA( RAM) I 9 : 0 I part CD of Fig. 1, data in source argument ($90) MCNl' ($1000 - $1009) is moved to destina- ~~HfM) I 0 : A I tion ($90 - $99) as shown in part @ l of Fig. 1. (2) User Notes Address space (a) As MeNT (RAM) is only one byte in Destinatl.U1l(000 length, its data must be between $01 Destination and $FF ($Ol~MCNT~$FF). ] data block (b) Do not hold MCNT (RAM) to "0", or I--~~ MOVE will not execute. @Resu1t (c) MOVE is located in internal RAM. Source Do not move data block to RAM s tart->SlOOO 1--..,......___-1 address where MOVE is stored, or execution SOA (UM) can not be stopped. (d) Hold entry arguments so that source te length to be moved area (Fig. 2 ®) and destination MCNT (RAM) area (Fig. 2@) do not overlap. If they do, the source data in Fig. 1 Example of MOVE execution overlapping area (Fig. 2 ®) will be destroyed. Source Address space start address -.f<:.""",=",.."j--- -}(i\ Destination_~~ \Ill start } address __-____ C Fig. 2 Example of overlapping source area with destination area $ HITACHI 440 2. MOVING MEMORY BLOCKS I MCU/MPU I lID630S FAMILY I LABEL I MOVE DESCRIPTION I (3) RAM Description Label RAM b7 bO Description SOA DEA f-- Upper byte Lower byte -} Source start address is stored in 2-byte hexadecimals. Destination start address is stored in l-byte hexadecimal. I---------! } MeNT ~-----i} Length of byte to be moved is stored in l-byte hexadecimal. MSUB LOA f-- - Instruction codes shown here are stored DIS P H by MOVE. - - Source data is loaded into ACCA by DISP L calling this area as subroutine. - HTS - Work area is reserved to save contents SPNT } of register IX. I ~HITACHI 441 2. MOVING MEMORY BLOCKS I MCU/MPU I HD6305 FAMILY I LABEL I MOVE DESCRIPTION I (4) Sample Application MOVE subroutine is called after source start address, destination start address and length of byte to be moved are held. WORK 1 RMB 2 Reserves memory byte for source start address. WORK2 RMB 1 Reserves memory byte for destination start address. WORK 3 RMB 1 Reserves memory byte for loading byte length to be moved. WORK 4 RMB 2 Reserves memory byte for register contents saving. STA STX WORK 4 WORK4+1 }----- Saves register contents that will be destroyed by executing MOVE. LDA WORKI STA LDA STA SOA WORK1+1 SOA+I }---- Stores source start address into entry argument (SOA) . LDA STA WORK 2 DEA } ----- Stores destination start address into entry argument (DEA). LDA STA WORK 3 MCNT } ----- Stores length of byte to be moved into entry argument (MCNT). II JSR MOVE II Calls MOVE subroutine. LDA LDX WORK4 WORK4+1 }----- Restores register. ~HITACHI 442 2. MOVING MEMORY BLOCKS MCU/MPU HD6305 FAMILY MOVE DESCRIPTION (5) Basic Operation (a) In the HD6305 family, IX is one byte in length. However, index addressing can be performed with source start address of 2 bytes by calling the subroutine shown in Fig. 3. MSllB LDA [) IS P . .\} Stores instruction codes for the RTS program into RAM as follows. lJ Label RAM Description MS L' U I--------,,---l} In,''ock 00004 '" 00005 '************************************************ " '" 00006 '" '" 00007 ENTRY SOA (SOURCE AOOR) '" 00008 '" DEA (DESTINATION ADDR) 00009 '" MCNT (TRANSFER COUNTER) '" 00010 '" RETURNS NOTHING '" 00011 '" '" 00012 " '" '************************************************ 00013 00014 0080 '" ORG $80 00015 'SOA " 00016 0080 0002 RM8 2 SOIJrce ADDR 00017 0082 0001 OEA RMB 1 DestInatIon ADDR 00018 0083 0001 MCNT RM8 1 Transfer counter 00019 0084 0004 MSUB RMB 4 Work aree for subroutIne 00020 0088 0001 RM8 RelatIve date of source ADDR 00021 ,.S~NT 1 0002'2 1000 ORG $1000 00023 'MOVE " 00024 1000 EOU Entry poInt 00025 1000 A6 06 LDA '11$06 " Store Instructlo~ cod~ (LOA Dlsp.X) 00026 1002 87 84 STA MSU8 00027 1004 86 80 LOA SOA Store source ADOR (H) 00028 1006 87 85 STA "1SU8+1 00029 1008 86 81 LOA SOA+1 Store source ADOR (ll 00030 1DOA 87 86 STA MSU8+2 00031 100C A6 81 LOA II$B1 Store InstructIon code (RTS) 00032 100E 87 87 STA MSU8+3 00033 10lO 31= 88 CLR SPNT CLear relatIve d~te of source ADDR 00034 101'2 8E 88 MOVEI LOX SPNT Loa(l reletlve (tllte of sOI/ree ADDR 00035 1014 80 84 JSR MSU8 Load transfer dllte 00036 1016 8E 82 LOX DEA LOlld rlestlnatlo~ ADDR 00037 1018 F7 STA O.X Store transfer data 00038 1019 3C 82 INC DEA Increment destInatIon ADDR 00039 1018 3C 88 INC SPNT Increme~t relatIve date of source ADDR 00040 10lD 3A 83 DEC MCNT Decrement transfer counter 00041 1011= 26 Fl BNE MOVEI Looo untIL transfer counter. 0 00042 1021 81 RTS ~HITACHI 445 3. MOVING STRINGS I MCU/MPU I HD6305 FAMILY I LABEL IMOVES FUNCTION I (a) Moves data block in memory to RAM using direct page addressing. (b) Terminates moving process when terminator $00 is found in data table. (c) Permits source and destination addresses to be freely selected in the memory. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS •x : Not affected : Undefined ROM (Bytes) 34 Storage Byte Contents Location Lgth. ! : Result RAM (Bytes) 8 Source Stack (Bytes) SOAS ACCA IX start 2 (RAM) x 2 address x I I I No. of cycles Entry Destina- tion DEAS C Z 668 1 Argu- ments start address (RAM) •N x I Reentrant No Re- turns - - - x H • Relocation No • Interrupt Yes DESCRIPTION 1 (1) Function Details (a) Argument details SOAS (RAM) : Holds source start address in 2-byte hexadecimals. DEAS (RAM) : Holds destination start address in I-byte hexadecimal. SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to put terminator at the 16th byte. ~HITACHI 446 3. MOVING STRINGS MCU/MPU HD6305 FAMILY DESCRIPTION (b) Fig. 1 shows example of MOVES execu- b15 SOAS SIlAS I bO tion. If\Entry !S~)~~Hl~~1)1 I : 1/ I " : 1/ I \Y b7 Ilf:AS bO If entry arguments are as shown in arguments IH:AS(ltA~t)1 : I (Suo) "" _ II . part CD of Fig. I, data in source l ($1000) is moved to destination ($90) Address space as shown in part ® of Fig. 1. When Destination~~~~ start ~ $\'" it loads terminator $00, MCU addres s r-~":'--i DEAS (RAM) JDestination terminates moving process. data block (2) User Notes ®Result (a) Source data must not contain any $00 function other than terminator. Source start-·$IUUU add r es s SOAS (RAM) 1 1--"'""-'--'----1 Source data (b) MOVES is located in internal RAM. 1--"""':'-.---1 J b 10 c k Do not move data block to RAM Terminator: where MOVES is held, or execution indicating can not be stopped. end of data block (c) Hold entry arguments so that source area (Fig. 2@) and destination area Fig. 1 Example of MOVES execution (Fig. 2 ©) do not overlap. 1£ they do, the source data in overlapping Source Address space start area (Fig. 2 ®) will be destroyed. address--~~~~----} (d) Amount of data block that can be Destination ® moved is MCU address space using ~____ }""..., I direct page addressing minus a-byte start address RAM used by MOVES. Fig. 2 Example of overlapping source area with destination area ~HITACHI 447 3. MOVING STRINGS ! MCU/MPU! HD6305 FAMILY I LABEL TMOVES DESCRIPTION I (3) RAM Description Label b7 RAM bO Description r---------------------~ S 0 A S f-- Upper byte __} Source start address is stored in 2-byte Lower byte hexadecimals. DRAS ~----I} Destination start address is stored in I-byte hexadecimal. MSSUB LDA I-- - Instruction codes shown here are stored DISP H by MOVES. Source data is loaded into r-- - ACCA by calling this area as subroutine. DISP L I-- - RTS Work area is reserved to save contents SOPNT ~ __________~ } of register IX. (4) Sample Application MOVES subroutine is called after source start address and destination start address are held. WORKl RMB 2 Reserves memory byte for source start address. WORK 2 RMB 1 Reserves memory byte for destination start address. WORK3 RMB 2 Reserves memory byte for register contents saving. STA STX WORK3 WORK3+1 }----- Saves register contents that will be destroyed by executing MOVES. LDA WORKl STA LDA STA SOAS WORK1+l SOAS+I }---- Stores source start address in entry argument (SOAS). LDA STA WORK 2 DEAS }----- Stores destination start address in entry argument (SOAS). JSR K>VES II Calls MOVES subroutine. LDA LDX WORK3 WORK3+1 }----- Restores register. • HITACHI 448 3. MOVING STRINGS MCU/MPU HD6305 FAMILY MOVES DESCRIPTION (5) Basic Operation (a) In the HD6305 family. IX is one byte in length. However. index addressing can be performed with source start address of 2 bytes by calling the subroutine shown in Fig •. 3. MSSUB LDA DISP,X Store instruction codes for } RTS the program in RAM as follows. JJ. Label RAM Description MSSUB I-";;"~____ --I} In"T~"= ood . . fOT LDA DISP. X b.,.,..,'""~'"'""","""" +- Instruction code for RTS (Notes) *1: Store the upper byte of the start· address in DISP H. *2: Store the lower byte of the start address in DISP L. Fig. 3 Details of instruction in RAM (b) IX is used to indicate source and destination addresses. which are alternately loaded into IX. (c) Source data is loaded into ACCA by calling the subroutine shown in Fig. 3. ACCA data is tested if it is terminator. If so. MOVES is terminated. If not. moving process continues until the terminator is found. I ~HITACHI 449 3. MOVING STRINGS H0630S FAMILY MOVES FLOWCHART Stores LOA operation code, destination start address, RTS operation code so that LOA OISP,X and RTS can be executed in RAM. $81-+MSSUD+3 ----[ Clears source address pointer. ---{ Loads destination address pointer into IX. ---{ Loads source data block into ACCA. if source data is terminator or not. If so, terminates MOVES. ---{ Loads destination address into IX. ---{ Stores source data in destination area. ---{ Increments destination address. ---{ Increments source address pointer. ___ { Executes LDA OISP ,X in RAM and loads source data into ACCA. (Note) * MSSUB does not appear in the PROGRAM LISTING because it is stored in RAM. ~HITACHI 450 3. MOVING STRINGS I MCU/MPU I HD6305 FAMILY I LABEL I MOVES PROGRAM LISTING I 00001 ********************************-*************** 00002 * * 00003 * NAME: MOVING STRINGS (MOVES) * 00004 * * 00005 ************************************************ ,. 00006 * 00007 * ENTRY SOAS (SOURCE ADDR) * 00008 * DEAS (DESTINATION ADDR) * 00009 * RETURNS NOTHING * 00010 * * 00011 ************************************************ 00012 * 00013 0080 ORG S80 00014 *SOAS RMB 00015 0080 0002 2 Source ADDR. 00016 00B2 0001 DEAS RMB 1 Destination ADDR. 00017 00B3 0004 MSSUB RMB 4 WorK area tor subroutine 00018 0087 0001 SOPNT RMB 1 ReLative data ot source ADDR 00019 * 00020 1000 ORG S1000 00021 *MOVES 00022 1000 EQU *IISD6 Entry point 00023 1000 A6 06 LOA Store instruction code (LOA Disp.X) 00024 1002 B7 83 STA MSSUB 00025 1004 B6 80 LOA SOAS Store source ADDR (H) 00026 1006 B7 84 STA MSSUB+l 00027 1008 B6 81 LOA SOAS+1 Store source ADDR (Ll 00028 100A B7 85 STA MSSUB+2 00029 100e A6 81 LOA IIS81 Store instruction code (RTS) 00030 100E B7 86 STA MSSUB+3 00031 i010 3F 87 CLR SOPNT CLear reLative data ot source ADDR 00032 1012 BE 87 MOVESI LOX SOPNT Load reLative data of source ADDR 00033 1014 BD 83 JSR MSSUB Load transter data 00034 1016 27 09 BEQ MOVES2 Brench it transter data = 0 00035 1018 BE 82 LOX DEAS Load destination ADDR 00036 lOlA F7 STA O.X Store transter data 00037 101B 3C 82 INC DEAS Increment destination ADDR 00038 10lD 3C 87 INC SOPNT Increment reLative data of source ADDR 00039 101F 20 F1 BRA MOVESI Branch MOVES 00040 1021 81 MOVES2 RTS ~HITACHI 451 4. BRANCHING FROM TABLE I MCU/MPU I HD630S FAMILY I LABEL I CCASE FUNCTION I (a) Stores service routine start address in RAM corresponding to the I-byte command in RAM. (b) Permits easy decoding and processing of keyboard and other data inputs. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS • : Not affected x : Undefined ROM (Bytes) 43 Storage Byte Contents Location Lgth. 1 : Result RAM (Bytes) 7 CMMD 1 ACCA IX Stack (Bytes) Command (RAM) Entry Data I • I x I 2 No. of cycles table TBTOP 2 169 start (RAM) C Z address Argu- t x Reentrant ments Program N I No TBTOP Re- turns start address (RAM) 2 x H • Relocation No Command existance Bit C (CCR) 1 • Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details CMMD (RAM) : Holds command such as ASCII. TBTOP(RAM): Holds data table address in which the command corresponding to that in CMMD (RAM) and command service routine start address have been stored in 3-byte units. After CCASE execution, it contains the service routine start address in 2-byte hexadecimals corresponding to the command in CMMD(RAM). Bit C : Indicates CCASE termination. Bit C=l : Data in data table is the same as that in CMMD(RAM). Bit c=o : Data in data table differs from that in CMMD(RAM). SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to find data at the end of 3 data units. ~HITACHI 452 4. BRANCHING FROM TABLE 1 MCU/MPU I HD630S FAMILY LABEL I CCASE DESCRIPTION I (b) Fig. I shows example of CCASE execu- b7 CIIMD bO I.:. I ! C~r.~\RAM) , tion. If entry arguments are as CDEntry blS TBTOP TBTOP+1 bO arguments T'/I?&.(N M) I I : D I • : • I shown in part CD of Fig. I, CCASE locates start address of command Return f bitCblSTBTOP TBTOP+lbO service routine in data table (Fig. ®argumentsl T~m~W')[Q I I : • I • : • I 2) and stores it in TBTOP (RAM) as shown in part ® of Fig. 1. Fig. 1 Example of CCASE execution (c) Data table shown in Fig. 2 must be Address Memory spaCQ Description set up before executing CCASE. It Start address _ _ $1 no 0 { r-- $4- 1 Command 'A' contains 3-byte data units beginning of data table TBTOP (RAM) Data block 1 $ 10 } Service routine start address ~:...$~:....t1--1 for comnand I AI at $IDOO and terminator indicating S ... 2 Coumand 'B' Data block 2 { $ 10 } Service routine the end of the table. The first $ +5 ~~:!ndd1~~SS for byte of the 3-byte data units is I I [t}_." command. The second and third bytes contain upper and lower bytes of command service routine start '_'0- ing the end of block data address respectively. Fig. 2 Example of data table (2) User Notes Do not use $00 as argument (CMMD) or as command in data table. It functions as terminator only. (3) RAM Description Label RAM Description b7 bO CMMD } l-byte command is stored. TBTOP Upper byte Data table start address is stored in } 2-byte hexadecimals before execution. - - Command service routine start address Lower byte is stored in 2-byte hexadecimals after execution. CSUS LDA - DISP H Instruction codes shown here are stored I-- - by CCASE. Data in data table are loaded into ACCA by calling this area as DISP L subroutine. - RTS ~HITACHI 453 4. BRANCHING FROM TABLE I K:U/MPU I HD6305 FAMILY I LABEL I CCASE DESCRIPTION I (4) Sample Application CCASE subroutine is called after command and start address of data table are held. WORK 1 RMB 1 ----- Reserves memory byte for command. WORK2 RMB 1 Reserves momory byte for register contents saving. STX WORK2 Saves register contents that will be destroyed by executing CCASE. LDA 1I$1D STA nrop } Stores data table start address into LDA 11$00 entry argument (TBTOP). STA TBTOP+l LDA STA WORKl CMMD } ----- Stores command into entry argument (CMMD). II JSR CCASE II ----- Calls CCASE subroutine. LDX WORK2 Restores register. BCC ERROR Tests if there is data corresponding to inputted command in data table. Program branching to * command service routine ERROR IERROR program I Executes error program because there is no data corresponding to inputted command in data table. ORG $IDOO Start address of data table. FCC 'A' Command 'A' FDB $1020 Start address of command service routine in case of command 'A'. FCC 'B' Command 'B' FDB $1045 Start address of command ser"ice routine in case of command 'B'. FCB $00 ----- Indicates the end of data block. $ HITACHI 454 4. BRANCHING FROM TABLE MCU/MPU HD6305 FAMILY CCASE DESCRIPTION (Note) * Example of branching to command service routine after CCASE execution: CCASE functions only to store start address of command service routine in TBTOP (RAM). Program as in the example below to branch to command service routine. Method used in this example is to store operation codes for JMP in TBTOP-l (RAM) and jump to command service routine. Iul_ _ J_S_R____C_C_A_S_E_--IJ11 ..... Calls CCASE subroutine. BCC ERROR ·· .. ·······Branches to ERROR i f bit C is cleared. ---.----- LDA #$CC } ..... Stores JMP operat~on . code in RAM. STA TBTOP-l Jump to command service J M P TBTOP-l ······Jumps to command service routine. routine I ---~~~===-------------~ ERROR LI_ _ _ E_RR_O_R_p_r_O_g_r_a_m_ _-, (5) Basic Operation (a) In the HD6305 family, IX is one byte in length. However, index addressing can be performed with data table start address of 2 bytes, by calling the subroutine shown in Fig. 3. eSUB LDA DIS P, X Stores instruction codes for } RTS the program in RAM as follows. Jj. Label RAM Description I-":;":"';;"~;':"'-:--I} 10"="00 00<1. for LOA DISP. X CSUB ~~...............,..,..,..,..,..,....,..,., +- Instruction code for RTS (Notes) *1: Stores the upper byte of the start address in DISP H. *2: Stores the lower byte of the start address in DISP L. Fig. 3 Details of instruction in RAM ~HITACHI 455 4. BRANCHING FROM TABLE r MCU/MPU 1 HD6305 FAMILY I I LABEL CCASE DESCRIfrION I (b) IX is used to indicate data table start address. (c) By calling the subroutine shown in Fig. 3, data table commands are read in order from start address and compared with entry argument contents. (d) If the data table commands match the entry argument contents (CMMD) , bit C is stored and CCASE is terminated. (e) If terminator $00 is found in data table, bit C is cleared and CCASE is terminated. ~HITACHI 456 4. BRANCHING FROM TABLE HD6305 FAMILY FLOWCHART Stores LDA operation code, destination start address, RTS instruction code to execute LDA DISP, X and RTS in RAM area. ___ ~Clears data table address pointer. ___ [LoadS I-byte from data table into ACCA. ---[ Clears bit C. (ACCA)=$~~_{Tests i f data table command is terminator or not. r -____~~~~$;OO ___ {In:rements the data table address po~nter. ---1 Compares entry argument (CMMD) and data table command. If different, adds "2" to the pointer to compare it with next data table command. ---IIf matched, stores command service routine start address in RAM. ---I Sets bit C to "1". n T s * c sun _-_{Executes LDA DISP,X in RAM and loads source data into ACCA. (Note) * CSUB does not appear in the PROGRAM LISTING because it is stored in RAM. ~HITACHI 457 4, BRANCHING FROM TABLE I MCU/MPU I HD6305 FAMILY I LABEL I ceASE PROGRAM LISTING I 00001 ************************************************* 00002 '" '" 00003 NAME : BRANCHING FROM TABLE (CCASE) 00004 '" '" 00005 '" ************************************************* '" 00006 '" '" 00007 ENTRY CMMO (COMMAND *) 00008 '" T8TOP (' 1 A t; • o 7 1 1 II II 1 1 1 Al'h: II f; L SY.\ ETB == U II I II (I (J liS (' A.\ \I X , 1u 1 (I liT f:M , A 1 0 1 tJ I.F S l: II F: H 1 0 1 1 \,T J.; S (' K rr }' s i< (' /) i 1 (I 0 1 1 0 1 (' R liS i= M " E 1 I 1 0 SO HS :-; F 1111 S I \' S / 11 0 !lEI. ~HITACHI 466 6. CONVERTING ASCII INTO I-BYTE HEXADECIMAL MCU/MPU HD630S FAMILY FLOWCHART NIBBLE NIBBLE:'---~----/ Tests if entry argument's ASCII is '0' or less. (bit C)=l Tests if entry argument's ASCII is 'G' or more. (bit C)=l Tests if entry argument's ASCII is 'A' or more. bit: N = 0 'A' to 'F' bit N = I : '0' to '@'. (bit N)=O • Tests if entry argument's ASCII is within range of ':' to '@'. bit C 0 '0' to '9' bit C = I : , :' to '@'. (bit C)=l NIBI -----~ Converts ASCII into I-byte hexadecimal. -----[ Clears bit C. ~HITACHI 467 6. CONVERTING ASCII INTO I-BYTE HEXADECIMAL I K:U/MPU I HD6305 FAMILY I LABEL I NIBBLE PROGRAM LISTING I 00001 ************************************************* 00002 * * 00003 NAME : CONVERTING ASCII 00004 * INTO 1-BYTE HEXADECIMAL (NIBBLE) * * 00005 * 00006 *************************************************** 00007 * * 00008 ENTRY ACCA (ASCII) * 00009 * RETURNS : ACCA (BINARY DATA) 00010 * CARRY (C=0:TRUE.C-1:FALSE) ** 00011 * 00012 * ************************************************* * 00013 * 00014 1000 ORG S1000 00015 *NIBBLE EQU 00016 1000 Entry poInt 00017 1000 AO 30 SUB * 11'0 ACCA (ASCII code) - '0' 7 00018 1002 25 OF BCS NIB2 Branch If ACCA('O' 00019 1004 AB E9 ADD IISE9 ACCA - 'G' -) ACCA 00020 1006 25 OB BCS NIB2 Brllnch If ACCA)='G' 00021 1008 AB 06 ADD 116 Test 'O'-'~' or 'A'-'F' 00022 100A 2A 04 BPL NIB1 Brllnch It ACCA = 'A'-'F' '00023 lOOC AB 07 ADD 117 Test '0'-'9' or ': I_'G)' 00024 100E 25 03 BCS NIB2 Brllnch It ACCA = ':'-'~' 00025 1010 AB OA NIBl ADD liSA Convert ASCII Into bInary dllt 00026 1012 98 CLC CLellr Cllrry 00027 1013 B1 NIB2 RTS ~HITACHI 468 7. CONVERTING 8-BIT BINARY DATA INTO ASCII MCU/MPU I HD630S FAMILY I LABEL ICOBYTE FUNCTION I (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 I CHANGES IN CPU SPECIFICATIONS .: REGISTERS AND FLAGS )( : Not affected Undefined ROM (Bytes) 26 Storage Byte Contents Location Lgth. 1 : Result RAM (Bytes) 2 ACCA IX Stack (Bytes) 8-bit Entry binary ACCA 1 I )( I )( I 2 No. of cycles data C Z Argu- )( )( 63 ments N I Reentrant Re- 2-digit turns ASCII COB (RAM) 2 )( H • No Relocation )( No Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details ACCA : Holds 8-bit binary data to be ACCA b7 AfrA bO CD Entry { (8-bi t binary I .. : I a converted into ASCII. argument $F3) ~ COB : Holds data converted, from (RAM) upper and lower 4 bits of \ COlII-I bO I • : I a :" I rOB (RAM)blScOIl 8-bit binary data into 2-digit ®Return (2-digit 6 argument ASCII ASCII, is set. 'F'=$46,'3'=$33) (b) Fig. 1 shows example of COBYTE ex- ecution. If entry argument is as Fig. 1 Example of COBYTE execution shown in part CD of Fig. I, data converted from 8-bit binary data into ASCII is contained to COB (RAM) as shown in part ® of Fig. 1. SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to convert 8-bit binary data into ASCII. ~HITACHI 469 7. CONVERTING 8-BIT BINARY DATA INTO ASCII I MCU/MPU I HD6305 FAMILY I I LABEL COBYTE DESCRIPTION I (2) User. Notes If 8-bit binary data in ACCA needs to be retained after COBYTE execution, it should be saved in memory before execution. (3) RAM Description Description Label RAM Data is stored which have been converted b7 bO from upper 4 bits of 8-Hit binary data COB Upper byte into one-digit ASCII. - Lower byte - Data is stored which have been converted from lower 4 bits of 8-bit binary data into one-digit ASCII. (4) Sample Application COBYTE subroutine is called after 8-bit binary data is held. WORKl RMB 1 Reserves memory byte for 8-bit binary data. WORK2 RMB 2 Reserves memory byte for 2-digit ASCII. WORK3 RMB 1 Reserves memory byte for register contents I I I saving. I STX WORK3 Saves register contents that will be destroyed by COBYTE execution. LDA WORKl ----- Loads 8-bit binary data into entry argument. JSR COBYTE II ----- Calls CO BYTE subroutine. LDA COB STA LDA STA WORK2 COB+l WORK2+l }---- Stores 2-digi t ASCII (return argument (COB) ) in RAM. LDX WORK 3 Restores register. ~HITACHI 470 7. CONVERTING 8-BIT BINARY DATA INTO ASCII I MCU/MPU HD6305 FAMILY I LABEL ICOBYTE DESCRIPTION I (5) Basic Operation (a) 8-bi t binary data in ACCA is divided into 4 upper and 4 lower bits. (b) Divided data is then checked by a comparison (instruction CMP). If data is between $00 and $09 (~: blocked area in ASCII table shown as Table 1) , $30 is added. If data is between $OA and $OF in Table 1), $37 is (c=J added. Result is converted into ASCII. Table 1 ASCII Table ~ LSD 000 00 1 o10 oI I r--;) I 00 . 101 p 1 10 III " o0 0 u XUL IlLE SP .-- I o0 0 1 SOH Del A Q , o u fl 1 STX l>C2 R , 00 1 1 ETX Df" + C • o u 1 0 EOT 1>(' 4 D T , o 10 1 .;;o.;u :\AK • U o110 SYS t' v 6 , Af'i\ '" "-- It 111 UEL ETB G W • 1 0 (I U us <'A!\ II X • 10 0 1 liT f; ~l ~ Y A 10 1 0 LF St:H Z B 1 fIll VT ESC K rs (' II 1 1 (I II 1 1 u 1 f' F (' R tiS 'd " E 111 II SO Hs ~ F 1111 S I \' S / '! u DEL ~HITACHI 471 7. CONVERTING 8-BIT BINARY DATA ~u/MPu HD630S FAMILY INTO ASCII FLOWCHART ___ { Saves 8-bit binary data of entry argument. ---{ Shifts upper 4 bits of 8-bit binary data into lower 4 bits. ---{ Converts upper 4 bits into ASCII. ___ { Stores result of ASCII conversion in RAM. ___ { Restores 8-bit binary data of entry argument. ---{ Clears upper 4 bits of 8-bit binary data. ---{ Converts lower 4 bits into ASCII. ___ { Stores results of ASCII conversion in RAM. R T S ___ [ Converts entry data between $00 and $09 into ASCII. ___ { Tests if data is $09 or less, or $OA or more. Converts data between $OA and $OF into ASCII. ~HITACHI 472 7. CONVERTING 8-BIT BINARY DATA INTO ASCII I K:U/MPU I HD6305 FAMILY I LABEL I COBYTE PROGRAM LISTING I 00001 ************************************************ 00002 00003 '" NAME : CONVERTING 8-BIT BINARY DATA '" '" 00004 '" INTO ASCII (COBYTE) 00005 '" ''"" 00006 '" ************************************************ 00007 00008 '" ENTRY : ACCA (8-BIT BINARY DATA) '" 00009 '" RETURNS : COB (2-BYTE ASCII) '" 00010 ''"" '" 00011 ************************************************'" 00012 00013 0080 '" ORG S80 00014 00015 0080 0002 '"COB RMB 2 2-byte ASCII 00016 00017 1000 '" ORG S1000 00018 00019 1000 '"COBYTE Eau Entry point 00020 1000 97 TAX '" Trensfer 8-blt blnery dete 00021 1001 44 LSR A Shift upper 4 bits to Lower 4 bits 00022 1002 44 LSR A 00023 1003 44 LSR A 00024 1004 44 LSR A 00025 1005 AD OA BSR CONIB Convert upper 4 bits Into ASCII 00026 1007 B7 80 STA COB Store ASCII 00027 1009 9F TXA Trensfer 8 bit binery dete 00028 100A A4 OF AND IlS0F Mesk upper 4 bits 00029 100C AD 03 BSR CONIB Convert Lower 4 bits into ASCII 00030 100E B7 81 STA COB+l Store ASCII 00031 1010 81 RTS 00032 1011 AB 30 CONIB ADD 11'0 Convert Into ASCII ('0'-'9') 00033 1013 Al 39 CMP 11'9 ASCII = '0'-'9' or 'A'-'F' ? 00034 1015 23 02 BLS CONIBl Brench If ACCA = '0'-'9' 00035 1017 AB 07 ADD 1l$07 Convert Into ASCII ('A'-'F') 00036 1019 81 CONIBl RTS ~HITACHI 473 8. COUNTING NUMBER OF LOGICAL "1" BITS IN 8-BIT DATA MCU/MPU I HD6305 FAMILY I LABEL I RCNT FUNCTION I (a) Counts number of logical "1" bits in 8-bit data string in ACCA, and stores result in RAM. (b) Permits easy parity checking. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS • : Not affected x : Undefined ROM (Bytes) 14 Contents Storage Byte Location Lgth. 1 : Result RAM (Bytes) 1 ACCA IX Stack (Bytes) 8-bit Entry data ACCA 1 I •I x I 0 No. of cycles Argu- C Z 134 ments Re- Number of logical HBIT 1 • N x I Reentrant No turns "1" bits (RAM) x R • Relocation No • Interrupt Yes DESCRIPTION J (1) Function Details (a) Argument details ACCA : Holds 8-bit data in which ACCA b7 A('C'A bO number of logical "1" bits CD Entry {(8-bit loll 1111 01 111 I I. I is counted. argument data $76) \ I There are five RBIT : Holds numb.er of logical "I" l' s. (RAM) bit in 8-bit data. RBIT (RAM)b7 ! IIBIT bO (b) Fig. 1 shows example of RCNT execu- ® Return {(The bit argument number .. I : • I tion. If entry argument is as of logical shown in part CD of Fig. 1, number of 1t1" $05) logical "1" bits in 8-bit data string is contained in RBIT (RAM) as Fig. 1 Example of HCNT execution shown in part ® of Fig. 1. SPECIFICATIONS NOTES I "No. of cycles" in "SPEC IFICATIONS" represents the number of cycles needed to count number of logical "1" bits in 8-bit data string. ~HITACHI 474 COUNTING NUMBER OF LOGICAL 8. BITS IN 8-BIT DATA "1"1 MCU/MPU 1 HD630S FAMILY 1 LABEL 1 HCNT DESCRIPTION I (c) Contents of ACCA are saved after HCNT execution. (2) User Notes When counting number of logical "0" bits. take 1 's complement of ACCA before HCNT execution. (3) RAM Description Label RAM Description b7 bO Number of logical "1" bits is stored HBI TIL-_ _ _ _ _---.JI in I-byte hexadecimal. (4) Sample Application Subroutine HCNT is called after 8-bit data is held. WORK 1 RMB 1 ----- Reserves memory byte for 8-bit data. WORK2 RMB 1 Reserves memory byte for number of logical "1" bits in 8-bit data string. WORK 3 RMB 1 Reserves memory byte for register contents saving. six WORK 3 Saves register contents that will be destroyea by HCNT execution. LDA WORK 1 Loads 8-bit data into entry argument (ACCA). JSR HCNT II Calls HCNT subroutine. LDA STA HBIT WORK 2 } Stores number of logical "1" bits (return argument (HBIT» in RAM. LDX WORK3 ----- Restores register. ~HITACHI 475 8. COUNTING NUMBER OF LOGICAL BITS IN 8-BIT DATA "1"1 MCU/MPU I HD6305 FAMILY I LABEL I RCNT DESCRIPTION J (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", RBIT (RAM) is incremented; if "0", no operation applied. (d) IX is decremented each time (b) and (c) are executed. (b) and (c) are looped until IX is "0". Number of logical "1" bits in 8-bit data is then determined. ~HITACHI 476 8. COUNTING NUMBER OF LOGICAL "I" MCU/MPU HD630S FAMILY HeNT BITS IN 8-BIT DATA FLOWCHART HCNT ----[ Loads "8" in counter for execution of 8-bit processing. ----I Clears counter (HI bit counter) that keeps track of number of logical "I" bits. ----{ Rotates MSB of 8-bit data in bit C. ----{ Tests if 8-bit data is "I" or "0". When 8-bit data is logical "1", increments HI bit counter. Decrements counter every time one bit is counted. ( IXl#O Tests if 8-bit processing is executed. ----~ Returns 8-bit data to entry state. ~HITACHI 477 8. COUNTING NUMBER OF LOGICAL "1" BITS IN 8-BIT DATA I I K:u/MPU I HD6305 FAMILY J LABEL I HCNT PROGRAM LISTING I ..... .. 00001 ************************************************ 00002 00003 NAME : COUNTING NUMBER OF LOGICAL "1" .. . 00004 00005 ..************************************************ BITS IN B-BIT DATA (HCNT> .. ..... .... 00006 00007 OOOOB 00009 00010 ENTRY : ACCA (B-BIT DATA) .... ..************************************************ RETURNS : HBIT (HIGH BIT COUNTER) 00011 00012 . 00013 OOBO 00014 .. ORG $BO 00015 ooao 0001 00016 . HBIT RMB High b It counter 00017 1000 0001a 00019 1000 .HCNT ORG ECU $1000 ..liB Entry point 00020 1000 AE oa LOX Set rotete counter 00021 1002 3F aO CLR HaIT Cleer high bit counter 00022 1004 49 HCNTl ROL A Rotete a-bit dete lett 00023 1005 24 02 BCC HCNT2 Branch If cerry=O 00024 1007 3C aD INC HBlT Increment high bit counter 00025 1009 SA HCNT2 DEC X Decrement rotate counter 00026 100A 26 Fa BNE HCNTl Loop until rotete countereD 00027 100C 49 ROL A Replace a-bit dete 00028 1000 81 RTS ~HITACHI 478 9. SHIFTING l6-BIT DATA MCU/MPU I HD630S FAMILY I LABEL I SHR FUNCTION I (a) Shifts l6-bit binary data in RAM to right. (b) Permits number of shifts to be freely determined. (c) Permits easy mUltiplication of l6-bit binary data by 2-n (n : number of shifts) • ARGUMENTS I CHANGES IN CPU SPECIFICATIONS .: REGISTERS AND FLAGS x : Not affected Undefined ROM (Bytes) 8 Storage Byte Contents Location Lgth. t : Result RAM (Bytes) 2 l6-bit ACCA IX Stack (Bytes) I • I binary data to be SFT (RAM) 2 x I 0 No. of cycles Entry shifted to right C z 110 Argu- ments x x Reentrant Number of IX 1 N I No shifts Re- Shift turns results SFT (RAM) 2 x H • Relocation No • Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details b7 IX bO 1 " : , I SFT : Holds l6-bit binary data to (RAM) be shifted to right. After Entry {"""" CD argumen ts Sf1, '''~, b 15 (:!q'IH II) SrI Sf'IH bO I'I'I"H'>'I"I'I'I'I+'I'I"I'I'I SHR execution, contains shift result. b~'\\ Return {~nm~1) "+1+1'1°1"1'1"1°1'1'1'10101'101 ® argument \\\0 S)'I HI+' IX : Holds number of l6-bit binary data to be shifted to right. Fig. 1 Example of SHR execution SPECIFICATIONS NOTES J "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to shift l6-bit binary data to right by 7 bits. ~HITACHI 479 9. SHIFTING 16-BIT DATA I MCU/MPU l HD6305 FAMILY 1LABELl SHR DESCRIPTION I (b) Fig. 1 shows example of SHR execution. If entry arguments are held as shown in partG) of Fig. 1, 16-bit binary data is shifted to right as shown in part ®of Fig. 1. (2) User Notes Be sure to hold data into IX within range of $01 :;; IX :;; $OF. When data outside this range is held, SFT (RAM) becomes "0". (3) RAM Description Label RAM Description b7 bO -} SFT Upper byte l6-bit binary data to be shifted to right is stored before execution. - Lower byte Shift result is stored after execution. (4) Sample Application SHR subroutine is called after number of shifts and l6-bit binary data to be shifted to right are held. WORK 1 RMB 2 ------Reserves memory byte for 16-bit binary data. WORK 2 RMB 1 Reserves memory b),te for number of shifts. WORK 3 RMB 2 Reserves memory byte for 16-bit binary shift results. WORK 4 RMB 1 Reserves memory byte for register contents saving. STX WORK 4 Saves register contents that will be destroyed by executing SHR. LDA WORK 1 } STA SFT Stores 16-bit binary data to be shifted LDA WORK 1+1 into right in entry argument (SFT). STA SFT+l LDX WORK 2 Loads number of shifts into entry argument (IX). II JSR SHR Calls SHR subroutine. LDA SFT } Stores shift results regarding l6-bit STA WORK 3 LDA SFT+1 binary (return argument (SFT» in RAM. STA WORK3+1 LDX WORK 4 ----- Restores register. ~HITACHI 480 9. SHIFTING 16-BIT DATA I K:u/MPU I HD6305 FAMILY I LABEL I SHR DESCRIPTION I (5) Basic Operation (a) Upper 8 bits in 16-bit binary are shifted to right. Here LSB is rotated to bit C. Lower 8 bits are then rotated to right. At this time, LSB in bit C is rotated to MSB of lower 8 bits. (b) IX is used, to keep track of number of shifts. IX is decremented each time (a) is executed. (a) is looped until IX is "0". ~HITACHI 481 9. SHIFTING l6-BIT DATA MCU/MPU HD6305 FAMILY SHR FLOWCHART S H R ----{ Shifts upper 8 bits in l6-bit binary to right, and shifts LSB to bit C. Rotates lower 8 bits in l6-bit binary to ----{ right. Rotates LSB of upper 8 bits to MSB of lower 8 bits. ----{ Decrements shift counter. ---{ Tests if shift is completed. ~HITACHI 482 9. SHIFTING 16-BIT DATA I MCU/MPU I HD6305 FAMILY I LABEL I SHR PROGRAM LISTING I 00001 ***********.w*********************************** 00002 '" 00003 NAME : SHIFTING 16-BIT DATA (SHR) " 00004 '" '" 00005 '" ************************************************'" 00006 00007 '" ENTRY SFT (16-BIT BINARY DATA) ,.'" 00008 ',." IX (SHIFT COUNTER) 00009 RETURNS SFT (16-BIT BINARY DATA) '" 00010 '" '" 00011 " '" '************************************************ 00012 '" 00013 0080 ORG $80 00014 00015 0080 0002 'SFT " RMB 2 16-bit binery data 00016 ,. 00017 1000 ORG $1000 00018 ,. 00019 1000 SHR EOU '" Entry point 00020 1000 34 80 LSR SFT Shift upper byte to right 00021 1002 36 81 ROR SFH1 Rotate lower byte to right 00022 1004 SA DEC X Decrement shift counter 00023 1005 26 F9 BNE SHR Loop until shift counter = 0 00024 1007 81 RTS ~HITACHI 483 10. 4-DIGIT BCD COUNTER MCU/MPU I HD6305 FAMILY I LABEL IDECNT FUNCTION I (a) Increments 4-digit BCD in RAM. (b) Permits easy counting of interrupts (external, timer, etc). ARGUMENTS I CHANGES IN CPU SPECIFICATIONS .: REGISTERS AND FLAGS Not affected x : Undefined ROM (Bytes) 13 Storage Byte Contents Location Lgth. 1: Result RAM (Bytes) 2 ACCA IX Stack (Bytes) Entry - - - I x I x I 0 No. of cycles 4-digit DCNTR C Z 42 Argu- BCD 2 ments counter (RAM) ! x Reentrant Re- N I No turns Counter over- flow or Bit C (CCR) 1 x H • Relocation No not? • Interrupt Yes DESCRIPTION J (1) Function Details (a) Argument details DCNT : Used as counter of 4-digit b 15 IX'NTR IX'NTItH bO (RAM) CD Be fo re { IJ('N1'R( RAM) BCD. Counts at every DECNT execution (..... ) I• : 0 I •:•I J"",~. I execution. Bit C : Indicates counter status R bi< C b15 b+o ____{: Te.t. if count.-op i . completed. I ~HITACHI 487 10. 4-DIGIT BCD COUNTER I K:U/MPU I HD6305 FAMILY I I LABEL DECNT PROGRAM LISTING I 00001 ************************************************** 00002 00003 ** NAME : 4-DIGIT SCD COUNTER (DECNT) ** 00004 * * 00005 ************************************************** 00006 * * 00007 * ENTRY NOTHING OOOOS * RETURNS : DCNTR (BCD COUNTER) * 00009 CARRY (C-0:TRUE,C-1:0VeR FLOW) * 00010 * 00011 * * ************************************************** 00012 * 00013 OOSO ORG $SO 00014 * 00015 OOSO 0002 DCNTR RMB 2 BCD counter 00016 * 00017 1000 ORG $1000 0001S *DeCNT 00019 1000 eou Entry point 00020 1000 AE 02 LOX * 112 Load ADDR polnte~ ( addition counter) 00021 1002 99 SEC Set carry 00022 1003 4F DECNTl CLR A Clear ACCA 00023 1004 E9 7F ADC DCNTR-l,X Increment BCD counter 00024 1006 SO DAA Convert Into BCD 00025 1007 E7 7F STA DCNTR-1, X Store BCD counter 00026 1009 SA DEC X Decrement ADDR pOinter 00027 100A 26 F7 BNE DECNTl Loop until ADDR polnter=O 0002S 100C Sl RTS ~HITACHI 488 11. COMPARING l6-BIT BINARY DATA MCU/MPU I HD630S FAMILY I LABEL I CMP FUNCTION I (a) Determines larger than / smaller than relationship (>,=, <) of l6-bit binary data of 2 groups, and loads result into bit C and bit Z of ceR. (b) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU SPECIFICATIONS .: REGISTERS AND FLAGS Not affected x : Undefined ROM (Bytes) 11 Storage Byte Contents Location Lgth. 1 : Result RAM (Bytes) 4 ACCA IX Stack (Bytes) I • I First CMD Entry value (RAM) 2 I x 0 No. of cycles C Z 20 Second CMT Argu- ments value (RAM) 2 t t Reentrant N I No Re- turns Com- parison bit C bit Z 1 x H • Relocation No results (CCR) • Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details CMD (RAM) : Holds the first l6-bit binary value. CMT (RAM) : Holds the second 16-bit binary value. Bit C, Bit Z (CCR) : Bit C and bit Z of CCR are held according to comparison results. I SPECIFICATIONS NOTES! ''No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to make equal comparand and comparative number. ~HITACHI 489 11. COMPARING 16-BIT BINARY DATAl K:u/MPu I HD6305 FAMILY I LABEL I CMP DESCRIPTION I (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. Table 1. Example of CMP execution Entry arguments Return arguments First value Second value CCR Large/small CMD (2 bytes relationship CMT (2 bytes bit C bit Z RAM) RAM) $F67D > $2001 0 0 $2200 $2200 0 1 $4001 < $FOOO 1 0 (c) After CMP execution. entry arguments are contained. (2) User Notes When not using upper byte. set "0" in the upper byte. If "0" is not set. comparison is performed with undefined data set in the upper byte. and correct data cannot be obtained. (3) RAM Description Label RAM Description b7 bO C M D Upper byte r- Lower byte - } The fi,at 16-bit bina'Y value is stored. C M T Upper byte I- Lower byte - } ... aecond 16-bit binary value 1s stored. ( • HITACHI 490 11. COMPARING l6-BIT BINARY DATA I MCU/MPU I HD630S FAMILY I LABEL I CMP DESCRIPTION I (4) Sample Application CMP subroutine is called after the first value and the second value are held. WORKl RMB 2 Reserves memory byte for the first l6-bit binary value. WORK 2 RMB 2 Reserves memory byte for the second l6-bit binary value. Saves register contents that will be TAX destroyed by CMP execution. LDA STA 'O~l CMD } Stores the first l6-bit binary value LDA WORK1+l into entry argument (CMD). STA CMD+l LDA STA WO~2 CMT } Stores the second l6-bit binary value LDA WORK2+1 into entry argument (CMT). STA CMT+l JSR CMP II Calls CMP subroutine. TXA Restores register. BEQ SKIP2 Branches to service routine when CMD=CMT. BCC SKIPl Branches to service routine when I CMD>CMT . l Service routine in easel of CMDCMT SKIP3 User program ~HITACHI 491 11. COMPARING l6-BIT BINARY DATA I K:U/MPU I HD6305 FAMILY I LABEL I CMP DESCRIPTION J (5) Basic Operation (a) When more than 2 bytes are compared, perform comparison for each byte. (b) Bit C and bit Z of CCR are determined as return argument, after comparison (instruction CMP) are executed. (c) Upper bytes are compared using one-byte (comparison instruction CMP). When equal, lower bytes are compared. When not equal, CMP is terminated. ~HITACHI 492 11. COMPARING 16-BIT BINARY DATA MCU/MPU HD630S FAMILY CMF FLOWCHART (CMD)+(CMT) ---{ (CMD)=(CMT) Compares upper 8 bits. Compares lower 8 bits. (O."H)-(O..,+» ----{ ~HITACHI 493 11. COMPARING 16-BIT BINARY DATA 1 MCU/MPU I HD6305 FAMILY I LABEL I CMP PROGRAM LISTING I 00001 *******************~**************w.************* 00002 ** 00003 NAME: COMPARING 16-BIT BINARY DATA performed with undefined data held in bit CIII [,..-0--,-:....:A:.....JL.......:;A~:.......:-~...J1 .... Addi tion the upper byte, and correct result '\J result Carry cannot be obtained. (b) After ADD execution, augend is Fig. 2 Example of addition when carry is generated destroyed because addition result is contained in ADED (RAM). If augend needs to be retained after 0 : 0 A : F I .... Augend ADD execution, it should be saved +) 0 : 0 F : 1 I .... Addend in memory before execution. bit c01 0 : 1 A : 0 I .... Addition result (3) RAM Description Fig. 3 Example of addition when upper byte is not used Label RAM Description b7 bO ADED Upper byte } "-bit.binary augend i •• tor,d before r- Lower byte - execut10n. 16-bit binary addition result is stored after execution. ADER Upper byte - - } "-bit binary addend is stored. Lower byte ~HITACHI 496 12. ADDING 16-BIT BINARY DATA I K:U/MPU I lID6305 FAMILY ILABEL I ADD DESCRIPTION I (4) Sample Application ADD subroutine is called after augend and addend are held. WORK 1 RMB 2 Reserves memory byte for 16-bit binary augend. WORK 2 RMB 2 Reserves memory byte for 16-bit binary addend. WORK3 RMB 2 Reserves memory byte for 16-bit binary addition results. WORK4 RMB 1 Reserves memory byte for register contents. STA WORK 4 ----- Saves register contents that will be destroyed by ADD execution. LDA STA LDA ::1 }____ WORK 1+1 Loads l6-bit binary augend into entry argument (ADED). STA ADED+l LDA STA ::2} Loads 16-bit binary.addend into entry LDA WORK 2+1 argument (ADER). STA ADER+l ADD II Calls ADD subroutine. BCS OVER If carry is generated in addition result, LDA STA LDA STA branches to service carry routine. Stores addition result (return argument (ADED» in RAM. ----- Restores register. I LDA WORK4 OVER I Service routine in case lof carry I ~HITACHI 497 12. ADDING l6-BIT BINARY DATA DESCRIPTION I I K:U/MPU 1 HD6305 FAMILY I LABEL I ADD (5) Basic Operation (a) When more than 2 bytes are added, perform addition for each byte. (b) Lower bytes (ADED+l, ADER+l) shown in (Formula 1) are added using l-byte addition (instruction ADD) ignoring bit c. When carry is generated after performing (Formula 1), bit C is set. (ADED + 1) + (ADER + 1) - ADED + 1 ------- (Formula 1) (c) Upper bytes (ADED, ADER) shown in (Formula 2) are added using l-byte addition (instruction ADC) based on consideration of bit C. (AD ED) + (ADER) + (bit C) - ADED -------------(Formula 2) Bit C is taken into consideration because there is carry involved with the addition result regarding lower bytes executed in (b). ~HITACHI 498 12. ADDING l6-BIT BINARY DATA I MCU/MPU I HD630S FAMILY I LABEL I ADD FLOWCHART I ADD ADD I SBED+ ---{ Subtracts lower 8 bits, and stores result in minuend RAM (SBED). I Subtracts upper 8 bits considering borrow (SBED)-(SBER)-(bit C) -SBED ---{ (bit C) which occurred in lower 8 bits, and stores result in minuend RAM (SBED). I RTS $ HITACHI 505 13. SUBTRACTING 16-BIT BINARY DATA I MCU/MPU I HD6305 FAMILY J LABEL I SUB PROGRAM LISTING I 00001 *************************************************** ,. ,. 00002 00003 NAME : SUBTRACTING 16-BIT BINARY DATA (SUB) " 00004 '" 00005 '" ***************************************************'" 00006 '" '" 00007 ENTRY SBED (MINUEND) 00008 ',." SBER (SUBTRAHEND) '*" 00009 RETURNS SBED (RESIDUAl) 00010 '" '" CARRY (C=O:TRUE.C=l:BORRDW) *'" 00011 '*************************************************** " '" 00012 00013 * 00014 0080 DRG $80 00015 00016 0080 0002 'SBED " RMB 2 Minuend -)ResiduaL 00017 0082 0002 SBER RMB 2 Subtrahend 00018 '" 00019 1000 DRG $1000 00020 'SUB " 00021 1000 EQU ,. Entry point 00022 1000 B6 81 LOA SBED+1 Load Lower minuend 00023 1002 BO 83 SUB SBER+1 Subtract,.Lower subtrahend 00024 1004 B7 81 STA SBED+1 Store Lower minuend area 00025 1006 B6 80 LOA SBED Load upper minuend 00026 1008 B2 82 SBC SBER Subtract upper subtrahend 00027 100A B7 80 STA SBED Store upper minuend area 00028 100e 81 RTS ~HITACHI 506 14. MULTIPLYING 16-BIT BINARY DATA MCU/MPU I HD6305 FAMTI..Y I LABEL I MUL FUNCTION I (a) Performs multiplication of l6-bit binary data in RAM and stores result in 32-bit binary in RAM. (b) Utilizes l6-bi t unsigned integers in arguments. ARGUMENTS J CHANGES IN CPU SPEC IFICATIONS .: REGISTERS AND FLAGS Not affec ted x: Undefined ROM (Bytes) 33 Storage Byte Contents Location Lgth. 1: Result RAM (Bytes) 6 Multipli- MCAND cand (RAM) 2 ACCA IX Stack (Bytes) Entry Multi- plier MER (RAM) 2 I x I x I 0 No. of cycles C Z 785 Product PRDCT Argu- 2 x x Reentrant (RAM) ments (Upper 2 N I No Re- bytes) turns Product MER x H • Relocation No 2 x Interrupt (RAM) (Lower 2 bytes) ! Yes DESCRIPTIONS I (1) Function Details (a) Argument details MCAND (RAM): Holds l6-bit binary multiplicand. MER (RAM) : Holds l6-bit binary multiplier. After MUL execution, the lower 16 bits of multiplication result is contained. PRDCT (RAM): Contains upper 16 bits of product. SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to hold $FFFF as entry argument. ~HITACHI 507 14. MULTIPLYING 16-BIT BINARY DATA I MCU/MPU I HD6305 FAMILY I LABEL I MUL DESCRIPTION I (b) Fig. 1 shows example of MUL execution. If entry arguments are as shown in part CD of Fig. 1, multiplication result is stored in PRDCT (RAM) and MER (RAM) as shown in part ® of Fig. 1. (c) Table 1 shows result when "0" is held Fig. 1 Example of MUL execution as entry argument. (2) User Notes (a) As shown in Fig. 2, when not using 10: 0IF: A I<-MUltiplicand upper byte, hold "0" in the upper xl 10 : 0 Is :B I<-Multiplier byte. If "0" is not held, multipli- 10 : 0 I 0 : 0 Is : 81 D : E I <-Product cation is performed with undefined data, and correct product cannot be Fi g. 2 Multiplication example when obtained. upper byte is not used Table 1 Product when not holding "0" as entry arguments Entry argument Return argument Multiplicand Multiplier Product (MCAND :MCAND+l) (MER:MER+l) (PRDCT:PRDCT+1: MER:MER+1) $**** * $0000 $00000000 $0000 $**** * $00000000 $0000 $0000 $00000000 (Note) * $**** indicates hexadecimals. (b) After MUL execution, multiplier is destroyed because lower 2 bytes of Product is held in MER (RAM). If minuend needs to be retained after MUL execution, it should be saved in memory before execution. Description bO ~HITACHI 508 14. MULTIPLYING l6-BIT BINARY DATA I K:U/MPU I HD6305 FAMILY I LABEL I MUL DESCRIPTION 1 (4) Sample Application MUL subroutine is called after multiplicand and multiplier are held. WORKl RMB 2 ----- Reserves memory byte for l6-bit binary multiplicand. WORK2 RMB 2 ----- Reserves memory byte for 16-bit binary multiplier. WORK 3 RMB 4 ----- Reserves memory byte for product. WORK4 RMB 2 -----, Reserves memory byte for register contents STA WORK 4 } ____ Saves register contents that will be STX WORK4+l destroyed by MUL execution. LDA WORKl } STA KCAND Stores 16-bit binary multiplicand into LDA WORK 1+1 entry argument (MER). STA MCAND+l LDA WOBK2 } STA MER Stores 16-bit binary multiplier into entry LDA WORK2+1 argument (KCAND). STA MER+l JSR MUL ----- Calls MUL subroutine. LDA PRDCT STA WORK 3 LDA PRDCT+l STA WORK3+1 >-___ _ Stores 32-bit binary product (return argument (PRDCT. MER» in RAM. LDA MER STA WORK 3+2 LDA MER+l STA WOBK3+3 LDA WORK4 ]-____ Restores register. LDX WOBK4+1 $ HITACHI 509 14. MULTIPLYING l6-BIT BINARY DATA I MCU/MPU I HD6305 FAMILY I LABEL I MUL DESCRIPTION I (5) Basic Operation (a) Fig. 3 shows example of 4-bit binary multiplication. bit 3 2 1 0 l l l 1 1 0 1 Multiplicand x) 1 0 0 1 Multiplier Multip licand x 1 1 0 1 ---- CD bit 0 of multiplier (1) Multiplicand x bit 1 of multiplier (0) 000 0 ----@ Partial products Multiplicand x bit 2 of multiplier (0) o0 0 0 ----® Multiplicand x ----@ +) 1 1 0 1 bit 3 of multiplier (1) Product 1 1 1 0 1 0 1 ---- ® 5 ( CD + @ + ® + @) Fig. 3 A multiplication example ($00 x $09 = $75) Multiplication of 4-bit binary data requires obtaining partial products, as shown in CD , @ , ® and @, and adding them. (® in Fig. 3 ) Each bit of binary data is either "0" or "1". If multiplier bit is 1, its partial product is multiplicand (CD and @ in Fig. 3), while'if multiplier bit is "0", its partial product is "0". (@and ® in Fig. 3) (b) Using Fig. 3, the program is explained as follows: (i) Clears RAM (PRDCT). (ii) IX is used to indicate number of partial product. (iii) To determine partial product for each 1 bit, tests whether LSB of multiplier (MER), is "1" or "0". (iv) If "1", Adds multiplicand to RAM for product, and stores sum in RAM for product, because if LSB of RAM for multiplier is "1", partial product is multiplicand. If LSB of RAM for multiplier is "0", partial product is "0", and there is no execution. (v) To acquire the partial product for the next bit in RAM for multiplier, rotates RAM for product and RAM for multiplier 1 bit right. (vi) Decrements IX. (vii) Loops (iii) to (vi) until IX is "0". ~HITACHI 510 14. MULTIPLYING l6-BIT BINARY MCU/MPU HD630S FAMILY DATA MUL FLOWCHART ----[ Clears RAM where product is to be stored. ____ { Stores counter indicating number of partial products. Tests i f LSB of multiplier is ---- [ "1" or "0". Adds multiplicand to product because ____ { partial product is multiplicand when LSB of multiplier is "1". Shifts LSB of product to upper bit of multiplier, and shifts LSB of ---- { multiplier to bit C by rotating RAM for the product and multiplier 1 bit right. Decrements counter indicating number of ---- { partial products. Tests i f all the partial products ---- [ have been obtained or not. ~HITACHI 511 14. MULTIPLYING 16-BIT BINARY DATA I MCU/MPU I HD630S FAMILY I LABEL I MUL PROGRAM LISTING I 00001 00002 .... **************************~*#******************* ... 00003 00004 .. NAME : 16-BIT MULTIPLATION (MUL) . 00005 00006 .... ************************************************ ... 00007 00008 .... ENTRY MACAND (MULTIPLICAND) MER (MUL TIPLIER) .. 00009 00010 00011 .. RETURNS PRDCT (UPPER PRODUCT> MER (LOWER PRODUCT> .. 00012 00013 .. ************************************************ 00014 0080 00015 00016 0080 0002 .. ORG MCAND RM8 S80 2 MuLtipLicend 00017 0082 0002 PRDCT RMB 2 Product (upper bytes) 00018 0084 0002 00019 .. MER RMB 2 MuLtipLier-)Product (Lower bytes) 00020 1000 00021 00022 1000 3F 82 .. MUL ORG CLR S1000 PRDCT CLeer product eree 00023 1002 3F 83 CLR PRDCT+l 00024 1004 AE 10 LOX 1U6 Set b it counter 00025 1006 01 85 OC MUll BRCLR 0.MER+1.MUL2 Brench if MER(O)=O 00026 1009 B6 81 LOA MCAND+l MCAND+PRDCT-)PRDCT 00027 100B 88 83 ADD PRDCT+l 00028 1000 B7 83 STA PRDCT+l 00029 100F 86 80 LOA MCAND 00030 1011 89 82 ADC PRDCT 00031 1013 87 82 STA PRDCT 00032 1015 36 82 MUL2 ROR PRDCT Rotete product eree 00033 1017 36 83 ROR PRDCT+l 00034 1019 36 84 ROR MER Rotete muLtiplier eree- 00035 1019 36 85 ROR MER+l -and set LS9 ot MER to carry 00036 10lD SA DEC X Decrement bit counter 00037 101E 26 E6 9NE MUll Loop until bit counter=O 00039 1020 81 RTS ~HITACHI 512 15. DIVIDING 16-BIT BINARY DATA MCU/MPU I HD6305 FAMILY I LABEL I DIV FUNCTION I (a) Performs divis ions of 16-bit binary data in RAM and stores result (quotient and residual) in 16-bit binary in RAM. (b) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGlSTERS AND FLAGS SPEC IFICATIONS Storage Byte • : Not affected x : Undefined ROM (Bytes) 47 Contents Location Lgth. t : Result RAM (Bytes) 6 DVD Stack (Bytes) Dividend (RAM) 2 ACCA IX Entry DVS I x I x I 0 No. of cycles Divisor (RAM) 2 C Z 1137 Argu- ments x x Reentrant DVD 2 Quotient (RAM) N I No Re- turns Residual RSD 2 x H • Relocation No (RAM) x Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details DVD (RAM) : Holds l6-bit binary dividend. Contains quotient after DIV execution. DVS (RAM) : Holds l6-bit binary divisor. RSD (RAM) : Holds 16-bit binary residual. SPECIFICATIONS NOTES I $ HITACHI 513 15. DIVIDING 16-BIT BINARY DATA I MCU/MPU I HD630s FAMILY I LABEL 1 DIV DESCRIPTION (b) Fig. 1 shows example of DIV execution. ® Return arguments If entry arguments are as shown in bls bO bI5bO ~ .... ~ part CD of Fig. I, division result Quotient I,VII 111."1101 !."'UIIO+) II.SII H.SJH (.~uF:\U) is stored in DVD (RAM) and RSD (RAM) Residual as shown part ® of Fig. 1. (c) Table 1 S!"IOWS result of holding "0" CD Entry arguments as argument. Fig. 1 Example of DIV execution (2) User Notes (a) When not using upper byte as shown in Fig. 2, hold "0" in the upper byte. ~ ... ~ If "0" is not held, division is ~)~ performed with undefined data in the Fig. 2 DIV example when upper upper byte, and correct result cannot bytes are not used be obtained. (b) After executing DIV, dividend is destroyed because quotient is contained in DVD (RAM). If dividend needs to be retained after DIV execution, it should be saved in memory before execution. TABLE 1 Results when holding "a" as entry arguments Entry Arguments Return Arguments Dividend (DVD) Divisor (DVS) Quotient (DVD) Residual (RSD) $**** * $ 0 0 0 0 $ F F F F $ F F F F $ 0 0 0 0 $***** $ 0 0 0 0 $ 0 0 0 0 $ 0 0 0 0 $ 0 0 0 0 $ F F F F $ 0 0 0 0 (Note) * $**** indicates hexadecimals. (3) RAM Description Label RAM Description b7 bO Upper byte } l6-bit binary dividend is stored DVD I- Lower byte - before execution. 16-bit binary quotient is stored after execution. OVS Upper byte f- Lower byte - } l6-bit binary divisor is stored. Upper byte } Work area is reserved to store RSO I- Lower byte - subtraction result of (OVO-DVS). 16-bit binary residual is stored after execution. ~HITACHI 514 15. DIVIDING 16-BIT BINARY DATA I MCU/MPU I HD6305 FAMILY r LABELl DIV DESCRIPTION I (4) Sample Application DIV subroutine is called after dividend and divisor are held. WORKl RMB 2 Reserves memory byte for l6-bit binary divisor. WORK 2 RMB 2 Reserves memory byte for l6-bit binary dividend. WORK 3 RMB 2 Reserves memory byte for l6-bit binary quotient. WORK 4 RMB 2 Reserves memory byte for l6-bit binary residual. WORK 5 RMB 2 Reserves memory byte in stack register. STA WORK5 } _____ Saves register contents that will be STX WORK5+l destroyed by executing DIV. LDA WORKl } STA DVS Stores l6-bit binary dividend into entry LDA WORK+l argument (DVS). STA DVS+l LDA WORK 2 } Stores l6-bit binary dividend into entry STA DVD LDA WORK2+l ----- argument (DVD). STA DVD+l II JSR DIV ----- Calls DIV subroutine. LDA DVD STA WORK 3 LDA DVD+l STA WORK3+l ~ ____ Stores division result (return arguments LDA RSD (DVD. RSD» in RAM. STA WORK 4 LDA RSD+l STA WORK4+l LDA WORK 5 } Restores register. LDX WORK5+l ~HITACHI 515 15. DIVIDING 16-BIT BINARY DATA I MCU /MPU I HD6305 FAMILY TLABEL I DIV DESCRIPTION I (5) Basic Operation (a) In binary code division, quotient and residual are obtained by repeated subtraction. Fig. 3 shows example of division ($OD + $03). ®® 1 0 0 Quotient Divisor 1 1 ) 1 1 0 1 Dividend -) 1 1 CD 0 0 ® -) 1 1 ---- @ 0 1 ---- ® +) 1 1 0 0 1 -) 1 1 -1 0 +) 1 1 0 0 1 <- Residual Fig. 3 Division example ($00+ $03) (b) Using Fig. 3, the flowchart is explained as follows; (i) IX is used to indicate number of shifts. (ii) Clears work area (RSD: RSD+1) where residual will be stored. (iii) Sets bit C in advance to store "1" in quotient RAM. (iv) Rotates DVD:DVD+1 (dividend ~ quotient and RSD:RSD+1 left 1 bit, sets "1" in quotient RAM and simultaneously shifts MSB of DVD: DVD+1 to LSB of RSD:RSD+1. This is because when performing subtrac- tion, the upper bits are fetched one by one from dividend. (v) Subtracts divisor, DVS:DVS+1 from RSD:RSD+1. If subtraction result is positive, sets LSB of DVD:DVD+l to "1". (Fig. 3 CD~®-®) If subtraction result is negative, adds divisor to subtraction result and clears "1" set in quotient RAM. (Fig. 3 @ ~® -+@) (vi) Decrements shift counter. (vii) Loops (iii) to (vi) until shift counter is "0". ~HITACHI 516 15. DIVIDING l6-BIT BINARY DATA K:U/MPU HD6305 FAMILY DIV FLOWCHART ____ { Loads number of shifts into shift counter. Clears work area where division result ----{ will be stored. ____ { Sets bit C to store "i" in quotient RAM. Shifts MSB of dividend to LSB of work ---- { area. ----~ Subtracts divisor from work area. ____ { Tes~s. if subtract~on result is posItIve or negatIve. (RSD: RSDtl) * 00010 * RSD (RESIDUAL> * 00011 * * 00012 * ************************************************ * 00013 * 00014 0080 ORG $80 00015 *DVD 00016 0080 0002 RMB 2 Dividend -) Quotient 00017 0082 0002 DVS RMB 2 Divisor 00018 0084 0002 RSD RMB 2 Residual 00019 * 00020 1000 ORG $1000 00021 * 00022 1000 DIV EQU Entr:- point 00023 1000 AE 10 LOX *IU6 Set shift counter 00024 1002 3F 84 CLR RSD CLellr worK (set Quotient afterwlI'd) 00025 1004 3F 85 CLR RSD+l 00026 1006 99 DIVl SEC Set LSB of residuaL aree to high 00027 1007 39 81 ROL DVD+l Shift dividend lind set MSB - 00028 1009 39 80 ROL- DVD -of dividend to LSB of worK 00029 100B 39 85 ROL RSD+l 00030 1000 39 84 ROL RSD 00031 100F B6 85 LOA RSD+l Work - divisor -> WorK 00032 1011 BO 83 SUB DVS+l 00033 1013 B7 85 STA RSD+1 00034 1015 86 84 LOA RSD 00035 1017 82 82 SBC DVS 00036 1019 87 84 STA RSD 00037 101B 24 OE BCC DIV2 Brench If worK ) divisor 00038 1010 86 83 LOA DVS+1 WorK + Divisor -) Work 00039 101F BB 85 ADD RSD+l 00040 1021 87 85 STA RSD+1 00041 1023 86 82 LOA DVS 00042 1025 69 84 AOC RSD 00043 1027 B7 84 STA RSD 00044 1029 3A 81 DEC DVD+1 CLeer LSB of residual area 00045 1028 SA DIV2 DEC X Decrement shift counter 00046 102C 26 08 BNE OIV1 Loop until shift counter = 0 00047 102E 81 RTS ~HITACHI 518 16. ADDING 8-DIGIT BCD MCU/MPU I HD630S FAMILY I LABEL I ADDD FUNCTION 1 (a) Performs addition of 8-digit BCD in RAM, and stores result in 8-digit BCD in RAM. (b) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPEC IF ICATIONS • x : : Not affected Undefined ROM (Bytes) 14 Storage Byte Contents Location Lgth. 1 : Result RAM (Bytes) 8 ABD IX Stack (Bytes) Augend 4 ACCA Entry (RAM) I x I x I 0 C Z No. of cycles Addend ACD (RAM) 4 ! x 84 Argu- ments N I Reentrant Re- Addition results ABD (RAM) 4 x H • No Relocation turns Carry or bit C x No 1 no carry (CCR) Interrupt Yes DESCRIPTIONS I (1) Function Details (a) Argument details ABD (RAM): Holds 8-digit BCD augend. After ADDD execution, Contains addition result. ACD (RAM) : Holds 8-digit BCD added. Bit C (CCR) : Indicates whether a carry is generated or not after ADDD execution. Bit C=l: Carry is generated in addition result. Bit C=O: No carry is generated in addition result. (See Fig. 2) SPECIFICATIONS NOTESf ~HITACHI 519 16. ADDING 8-DIGIT BCD I !£U/MPU I HD630S FAMILY I LABEL I ADDD DESCRIPTION I (b) Fig. 1 shows example of ADDD execution. If entry arguments are as shown in part I&ACDI& (2) User Notes b•• C b31 bO (a) As shown in Fig. 3, when not using ®Re.ur. {AI1D(RAN) arauaenta (8M88983) EJ 1-: .1-: .1.: ADD .1.: al ....Melitio• ABDttABDt3 result AJlDt.I upper digits, hold "0" in the upper Fig. 1 Example of ADDD digits. If "0" is not held, addition execution is performed with undefined data in the upper digits, and correct result Iv: 01.: .1.: 0II: 0I-Augend cannot be obtained. +) 11:·lo:aIO:olo:ol-Addend (b) After ADDD execution, augend is bit clll Ii: 01< 01.: 011: oI-Addition destroyed because addition result C~ arry . result are contained in ABD (RAM). If augend needs to be ratained after ADDD Fig. 2 Addition example when carryi s generated execution, it should be saved in memory before execution. 10: 0 10: 0 II : Z \8 : • I-Augend (c) Hold BCD data as augend and addend. +) 10: 0 10: 0 I. : 810 : 6 I-Addend If data other than in BCD from is bit c010: 0 \0: 0\3: 6\ g: v I-Addition held, correct addition result result ·cannot be obtained. Fig. 3 Addition example when upper digit is not used (3) RAM Description Label RAM Description b7 bO ABD Upper byte 8-digit BCD augend is stored before - - execution. r-- - 8-digit BCD addition result is - Lower ~yte - stored after execution. ACD Upper byte r-- - ...,- - 8-digit BCD addend is stored. - Lower byte - • HITACHI 520 16. ADDING 8-DIGIT BCD MCU/MPU I HD6305 FAMILY I LABEL I ADDD DESCRIPTION J (4) Sample Application ADDD subroutine is called after augend and addend are held. WORKl RMB 4 Reserves memory byte for 8-digit BCD augend. WORK 2 RMB 4 Reserves memory byte for 8-digit BCD addend. WORK 3 RMB 4 Reserves memory byte for addition result. WORK 4 RMB 2 Reserves memory byte for register contents saving. STA WORK 4 } Saves register contents that will be STX WORK4+l destroyed by executing ADDD. LDA WORKl STA ABD LDA WORK+l STA ABD+l Stores 8-digit BCD added into entry LDA WORK1+2 argument (ABD). STA ABD+2 LDA WORK1+3 STA ABD+3 LDA WORK2 STA ACD LDA WORK2+1 stores 8-digit BCD addend into entry STA ACD+I argument (ACD). LDA WORK2+2 STA ACD+2 LDA WORK2+3 STA ACD+3 JSR ADDD II Calls ADDD subroutine. BCS OVER If there is carry in addition result, branches to service carry routine. LDA ABD STA WORK3 LDA ABD+I STA WORK3+1 Stores addition result (return argument LDA ABD+2 (ABD» in RAM. STA WORK3+2 LDA ABD+3 STA WORK3+3 LDA WORK4 } Restores register. LDX WORK4+1 OVER IService routine in case of carry I ~HITACHI 521 16. ADDING 8-DIGIT BCD ! MCU/MPU! HD6305 FAMILY ! LABEL! ADDD DESCRIPTION I (5) Basic Operation (a) When more than 2 bytes are added, perform addition for each byte. (b) IX is used to indicate augend and addend addresses and is also used to count number of addition. (c) Clears bit C at first. (d) Performs (Formula 1) on each byte of augend and addend using index address- ing rode. 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 (instruction DAA), and stores it in augend RAM (ABD). (f) Decrements IX each time (d) and (e) are executed. (g) Loops (c) to (f) until IX is "0". ~HITACHI 522 16. ADDING 8-DIGIT BCD MCU/MPU HD630S FAMILY ADDD FLOWCHART 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. L---...r------' - - - { ---{ Adjusts addition result to decimal. Stores decimal-adjusted result in augend L----r-------' ---{ RAM. ---{ Decrements pointer indicating augend address and counter indicating number of addition. ---{ Tests if addition in all the digits is completed or not. ~HITACHI 523 16. ADDING 8-DIGIT BCD I ~ICU/NPU I HD630S FAHILY I LABEL I ADDD PROGRAH LISTING I OCl:..""'0l 0000':- 0:..1 003 ..."I0\."'lJ ... (\.""1\":05 0000", ,. ,. 0000, ENTRY ABD (AUGEND) "' (ADDEND) "' 00008 0000 0 ..'" RETURNS ACD ABD CARRY (SUM) (C=O;TRUE.C=l;OVER FLOW) "' ,."' 00010 00011 "' ,. 00012 "'**~***********************~********************* 00013 ,. 00014 0080 ORG $80 00015 ,. 00016 0080 0004 ABD RMB Augend - ) Sum 00017 0084 0004 00018 ACD ,. RMB '4" Addend 00019 1000 ORG $1000 00020 ,. 00021 1000 ADDD EQU '" EnTry point 00022 1000 AE 04 LDX 1i4 Set ADDR pointer (addition counter) 00023 1002 98 CLC CLear car~y 00024 1003 E6 7F ACDDl LDA ABD-l.X Augend .. addend 000:5 1005 E9 83 ADC ACD-l. X 00026 1007 8D DAA Convert i'11:0 BCD 00027 1008 E7 7F STA ABD-l.X Store In augend are/! 00028 100A SA DEC Decrement ADDR pointer 00029 100B 26 F6 00030 1000 8.1 9NE RTS "ADDDl Loop until AD DR pOinter 0 ~HITACHI 524 17. SUBTRACTING 8-DIGIT BCD MCU/MPU I HD6305 FAMILY I LABEL I SUBD FUNCTION I (a) Performs subtraction of 8-digit BCD in RAM and stores result in 8-digit BCD in RAM. (b) Utilizes unsigned integers in arguments. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS e:Not affected ROM (Bytes) x : Undefined 25 Storage Byte Contents Location Lgth. 1 : Result RAM (Bytes) 8 SUBEDS ACCA IX Stack (Bytes) Minuend 4 Entry (RAM) SUBERS I x I I x 0 No. of cycles Subtra- 4 hend (RAM) C Z 146 Argu- ments 1 x Reentrant Subtrac- SUBEDS 4 N I No tion (RAM) Re- result x e Relocation turns H No Borrow bit C or no 1 x Interrupt (CCR) borrow Yes DESCRIPTION I (1) Function Details (a) Argument details SUBEDS (RAM) : Holds 8-digit BCD minuend. After SUBD execution. Contains subtraction result. SUBERS (RAM): Holds 8-digit BCD Subtrahend. Bit C (CCR) : Indicates whether borrow is generated or not after SUBD execution. Bit C--o: Borrow is generated in subtraction result. Bit C=l: No borrow is generated in subtraction result. (See Fig. 2) SPECIFICATIONS NOTEsl 525 17. SUBTRACTING 8-DIGIT BCD I MCU/MPU I HD6305 FAMILY 1 1 LABEL SUBD DESCRIPTION I (b) Fig. 1 shows example of executing Sl'REnS( RAM) SUBD. If entry arguments are as CD!~~~ents1 (P012:H56) shown in part CD of Fig. 1, subtrac- tion result is stored in SUBEDS SI lIl'RS ( RA.\I) ( 12:H·56j~) I ~,:"21. ~,:".I',,:.I,:,:,,.I-subtrahend -) (RAM) as shown in part ® of Fig. 1. (2) User Notes (a) As shown in Fig. 3, when not using Fig. 1 Example of SUBD upper digits, hold "0" in the upper execution digits. If "0" is not held, sub- traction is performed with undefined II : 2 Is : + 15 : 61 7 : 8 I. . .Minuend data held in the upper digits, and ) correct result cannot be obtained. bit cIT] 1<21 <212: 21 <21<-Subtractiol1 (b) After SUBD execution, minuend is result destroyed because subtraction Fi g. 2 Subtraction example when result is contained in SUBEDS (RAM). borrow is generated If minuend needs to be retained after SUBD execution, it should be saved in memory before execution. ) (c) Hold BCD data as minuend and subtra- bit CQ] 1 0 : 0 10: 01 5 : 51 2: q"'Subtraction hend. If data other than BCD is held, result correct subtraction result cannot be Fig. 3 Subtraction example when obtained. upper digit is not used (3) RAM Descri.Ption Label RAM Description b7 bO SUBEOS Upper byte 8-digit BCD minuend is stored t- - before execution. t- - t- - 8-digit BCD subtraction result Lower byte is stored after execution. SUBERS Upper byte f-- - - - 8-digit BCD subtrahend is stored. - Lower byte - ~HITACHI 526 17. SUBTRACTING 8-DIGIT BCD MCU/MPU I HD6305 FAMILY I LABEL I SUBD DESCRIPTION I (4) Sample Application SUBD subroutine is called after minuend and subtrahend are held. WORKl RMB 4 ----- Reserves memory byte for 8-digit BCD minuend. WORK 2 RMB 4 Reserves memory byte for 8-digit BCD subtrahend. WORK 3 RMB 4 Reserves memory byte for 8-digit BCD subtraction result. WORK 4 RMB 2 Reserves memory byte for register contents saving. STA WORK 4 } _____ Saves register contents that will be STX WORK4+l destroyed by executing SHR. LDA WORKl STA SUBEDS LDA WORKl+l STA SUBEDS+l Stores 8-digit BCD minuend into entry LDA WORK 1+2 argument (SUBEDS). STA SUBEDS+2 LDA WORK 1+3 STA SUBEDS+3 LDA WORK 2 STA SUBERS LDA WORK2+l STA SUBERS+l Stores 8-digit BCD subtrahend into entry LDA WORK 2+2 argument (SUBERS). STA SUBERS+2 LDA WORK2+3 STA SUBERS+3 II JSR SUBD II Calls SUBD subroutine. BCC OVER If borrow is generated in subtraction result. branches to service borrow routine. LDA SUBEDS STA WORK3 LDA SUBEDS+l STA WORK3+l Stores subtraction result (return argument LDA SUBEDS+2 (SUBEDS» in RAM. STA WORK 3+2 LDA SUBEDS+3 STA WORK 3+3 LDA WORK 4 } LDX WORK4+1 ----- Restores register. OVER I Service routine in case of borrow I ~HITACHI 527 17. SUBTRACTING 8-DIGIT BCD I MCU/MPU I HD6305 FAMILY I LABEL I SUBD DESCRIPTION I (5) Basic Operation (a) Subtraction of BCD can be performed by (Formula 1) and (Formula 2). Minuend-Subtrahend=Minuend+lO's complement of subtrahend .•.•. (Formula,}l) 10's complement of minuend=$99-Subtrahend+l •••••••••••••••• (Formu1a 2) (b) (Formula 1) and (Formula 2) are described as follows: (i) Takes 10's complements of 8-digit subtrahend by (Formula 2) and stores them in SUBERS (RAM). (ii) IX is used to indicate minuend and subtrahend, and is also used to count number of subtraction. (iii) Performs (Formula 3) on every byte from LSB of 10's complement of minuend and subtrahend using index addressing mode. Minuend+lO's complement of subtrahend+(bit C) - ACCA ••• (Formula 3) (iv) Adjusts subtraction result of (iii) to decilllel value using decimal adjust(instructionDAA) and stores it in minuend RAM, (SUBERS). (v) Decrements IX. (vi) Loops (iii) to (iv) until IX is "0". ~HITACHI 528 17. SUBTRACTING 8-DIGIT BCD MCU/MPU HD6305 FAMILY SUBD FLOWCHART Takes 10's complement of subtrahend, and stores it in subtrahend RAM. However, only ($99-subtrahend) is calculated in this part. Adds "1" in the next step by setting bit C. (See Formula 2 in "(5) Basic Operation") Loads "4" in pointer indicating minuend --- { address and counter indicating number of subtraction. Adds 10's complement of subtrahend and --- { bit C to minuend. ---1L Adjusts addition result to decimal. ___ { Stores decimal adjusted result in minuend RAM. Decremen~s pointer indicating minuend --- { address and counter indicating number of subtraction. ___ ~ :ests if subtraction in all the digits l ~s completed or not. ~HITACHI 529 17. SUBTRACTING 8-DIGIT BCD I MCU/MPU I HD6305 FAMILY 1 J LABEL SUBD PROGRAM LISTING I 00001 ***~******************************************** ,. 00002 '" 00003 NAME : SUBTRACTING 8-DIGIT BCD (SUBD) 00004 '" '" >t 00005 '" ************************************************ 00006 '" 00007 ',." ENTRY SUBEDS (MINUEND) 00008 SUBERS (SUBTRAHEND) '" 00009 '" RETURNS SU8EDS (RESIDUAl) '" 00010 ',." '" CARRY (C=l;TRUE.C=O;BORROW) 00011 '" 00012 '" '" ************************************************ 00013 00014 0080 '" ORG $80 00015 00016 0080 0004 '" SUBEDS RM8 4 Minuend -) ResiduaL 00017 0084 0004 SUBERS RM8 4 Subtr~hend 00018 ,. 00019 1000 ORG $1000 00020 ,. 00021 1000 SU8D EOU 'jj4 " Entry point 00022 1000 AE 04 LOX Set subtr~ction counter 00023 1002 A6 99 SUBD: LOA ~$99 9999999 0 -Subtraend 00024 1004 EO 83 SUB SUBERS-1.X -) SUBERS 00025 1006 E7 83 STA SU8ERS-l.X 00026 1008 SA DEC X 00027 1009 26 F7 BNE SUBD1 00028 1008 99 SEC Set carry bit 00029 100C AE 04 LOX 114 Set AD DR pointer(subtraction counter) 00030 100E E6 7F SU8D2 LOA SUBEDS-1.X Minuend + negative of subtr~henc! 00031 1010 E9 83 ADe SUBERS-1.X 00032 1012 80 DAA Convert into 8CD 00033 1013 E7 7F STA SUBEDS-l.X Store in minuend area 00034 1015 SA DEC X Decrement ADDR pointer 00035 1016 26 F6 BNE SUBD2 Loop untiL AD DR pointer = 0 00036 1018 81 RTS ~HITACHI 530 18. l6-BIT SQUARE ROOT MCU/MPU 1 HD630S FAMILY I LABELl SQRT FUNCTION I (a) Obtains square root of l6-bit binary data in RAM and stores result in RAM. (b) Utilizes unsigned integers in argument. ARGUMENTS I CHANGES IN CPU SPEC IFICATIONS .: REGISTERS AND FLAGS Not affected x : Undefined ROM (Bytes) 71 Contents Storage Byte Location Lgth. 1 : Result RAM (Bytes) 6 ACCA IX Stack (Bytes) Entry Data to be SQRD 2 I x I x I 0 No. of cycles (RAM) squared 861 C Z Argu- ments x x Reentrant N I No Re- Square turns root SANS+l (RAM) 1 x H • Relocation No x Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details I SQRD : Holds l6-bit binary data to blS bO (RAM) CD Entry { S~RD~RAM) I E : 3 I E : 0 I be squared. argument ( E3 0) SQRD SQRD+l SANS-+l: Contains l6-bit binary square (RAM) b7 1 bO root. ® Return {SANS+l(RAM) I (b) Fig. 1 shows example of SQRT ex- argument (SFl) IF : 1 SANS+! ecution. If entry argument is as shown in part CD of Fig. 1, square Fi g. 1 Example of SQRT execution contained in SANS+l (RAM) as shown in part ® of Fig. 1- SPECIFICATIONS NOTES I "No. of cycles" represents the number of cycles needed to get square root of $FFFF. ~HITACHI 531 18. l6-BIT SQUARE ROOT I MCU/MPU I HD6305 FAMILY TLABEL I SQRT DESCRIPTION I (2) User Notes (a) When not using upper byte as shown 0 : 0 I I : 0 in Fig. 2, holds "0" in the upper byte. If "0" is not held, square root is 1 obtained with undefined data Held in 0 : 4 the upper byte, and correct result Fig. 2 Example when not upper cannot be obtained. bytes are not used (b) Values to the right of the binary point are truncated. (3) RAM Description Label RAM Description b7 bO } SQRD Upper byte - Lower byte - l6-bit binary data is stored. Work area is reserved to store square SANS (SANS+! ) - Upper byte Lower byte - } root before execution. 8-bit binary square root is stored in SANS+l, and "0" is stored in SANS after execution. Upper byte SWORK ~ Lower byte - } Work area is reserved to operate on upper 2 bits of data to be squared. ~HITACHI 532 18. 16-BIT SQUARE ROOT 1 M::U/MPU I HD6305 FAMILY I I LABEL SQRT DESCRIPTION I (4) Sample Application SQRT subroutine is called after data to be squared is held. WORKl RMB 2 Reserves memory byte for binary data to be squared. WORK 2 RMB 1 Reserves memory byte for 16-bit binary square root. WORK 3 RMB 2 Reserves memory byte for register contents saving. STA WORK 3 } Saves register contents that will be STX WORK3+l destroyed by SQRT execution. :~::+l LDA STA Stores data to be squared into entry LDA } argument (SQRD). STA SQRD+1 SQRT ~ Calls SQRT subroutine. Stores 16-bit binary square root (return LDA STA SANS+1 WORK2 }----- argument (SANS+l» in RAM. LDA WORK3 } Restores register. LDX WORK3+1 ~HITACHI 533 18. l6-BIT SQUARE ROOT I r«:U/MPU I HD6305 FAMILY I LABEL I SQRT DESCRIPTION I (5) Basic Operation (a) Fig. 3 shows calculation to obtain square root of l6-bit binary data. $05 of hexadecimal $22 data to be squared. @®© 1 1 I 1 1 1 1 0 1 1 (i) .••.•.••. Square root 1 1 I 1 1 __ ~lJ___________ ::Y'_~_O_J_~_o_l_~~ __ ~ ......... Data to be 11 I 1 I 1 @ squared 1 1 _________ 1 I 1 010: 1 1 0 0 : @ ---r~----------------~---~------- :0: _______ I 0i ® 10 1 0 1 1 ® 1 100 I 10 ---I~----------------4----T------ 1 :1 1 1 0 1 01 ® 1 1 -------- I 1 01110 : 101 01 @ I 1 • I Fig. 3 Calculating a square root (b) The calculation in Fig. 3, is explained as follows: (i) Clears square root area. SANS:SANS+l and work area SWORK:SWORK+l. (ii) Rotates SQRD:SQRD+l and SWORK:SWORK+l 2 bits left to fetch upper 2 bits of :data to be squared, and sets upper 2 bits of data to be squared in SWORK:SWORK+1. (Fig. 3 @- ®) (iii) Sets "1" in 2-byte area. SANS:'SANS+l from RAM address shown in SANS. (Fig. 3@-®) (iv) Subtracts SANS:SANS+l from SWORK:SWORK+l, and stores result in SWORK: SWORK+1. (Fig. 3@-®. ®. @) (v) When result is positive, increments SANS+l. (Fig. 3@- @) When result is negative, decrements SANS+l, and adds SANS: SANS+l to SWORK:SWORK+l. (Fig. 3 @ • ® - ®) (c) In SQRT, loops (ii) to (v) 8 times and then shifts SANS:SANS+l 1 bit. right to halve SANS: SANS+1. (Fig. 3@. @- @is square root). ~HITACHI 534 18. l6-BIT SQUARE ROOT K:U/MPU HD6305 FAMILY SQRT FLOWCHART ----( Loads number of shifts into shift counter. O---SWORK:SWORK+l Clears RAM used to obtain square ---{ root (solution). Stores upper 2 bits of data to be squared in lower 2 bits of work area. 1 --- bit C Sets "1" in solution. ~otate (SANS:SANS+l) , bit left Subtracts solution from work area. Tests if subtraction result is positive or negative. Adds solution to subtraction result to return to the state before subtrac- tion. ---{ Clears "1" set in solution. ---{ Increments solution. ---{ Decrements shift counter. Tests if shift is completed or ---{ not. ---{ Shifts solution to right to halve SANS:SANS+l. ~HITACHI 535 18. 16-BIT SQUARE ROOT PROGRAM LISTING I I MCU/MPU 1 HD6305 FAMILY I·LABEL 1 SQRT 00001 ************************************************ 00002 * * 00003 * NAME : 16-6IT S~UARE ROOT (SORT) * 00004 * * 00005 ************************************************ 00006 ,. 00007 * ENTRY : SORD (16-6IT BINARY DATA) * * 00008 00009 ,.* RETURNS : SANS (SOUARE ROOT) ,.* 00010 ************************************************ 00011 * 00012 0080 ORG S80 00013 * 00014 0080 0002 SORD RM6 2 Input 16-bit binery dete 00015 0082 0002 SANS RM6 2 SQuere rpot 00016 0084 0002 SWORK RM6 Work erea 00017 ,. 2 00018 1000 ORG S100.0 00019 * 00020 1000 SORT EOU * Entry point 00021 1000 AE 08 LOX 118 Set shift counter 00022 1002 3F 84 CLR SWORI< Cleer Work aree 00023 1004 3F 85 CLR SWORi<+l 00024 1006 3F 82 CLR SANS Cleer SQuere root aree 00025 1008 3F 83 CLR SANS+1 00026 100A 39 81 SORTI ROL SORD+I Shift upper 2 bits of SORO eree 00027 100C 39 80 ROL SORD -and set lower 2 bits of swork 00028 100E 39 85 ROL SWORK+I 00029 1010 39 84 ROL SWORK 00030 1012 39 81 ROL SORO+I 00031 1014 39 80 ROL SQRD 00032 1016 39 85 ROL SWORK+l 00033 1018 39 84 ROL SWORK 00034 lOlA 99 SEC Set LSB of SANS aree 00035 1016 39 83 ROL SANS+l ,00036 1010 39 82 ROL SANS 00037 101F 66 85 LOA SWORK+1 Swork - SANS -) Swork 00038 1021 60 83 SU6 SANS+l 00039 1023 67 85 STA SWORK+I 00040 1025 66 84 LOA SWORK 00041 1027 62 82 SBC SANS 00042 1029 67 84 STA SWORK 00043 1026 25 OA BCS SORT3 6rench if minus 00044 1020 3C 83 INC SANS+I SANS + 1 -) SANS 00045 102F SA SORT2 DEC X Decrement shift counter 00046 1030' 26 08 EiNE SORTl Loop until shift counter = 0 00047 1032 37 82 ASR SANS Helve SANS:SANS+1 00048 1034 36 83 ROR SANS+l 00049 1036 81 RTS 00050 1037 66 85 SORT3 LOA SWORK+1 Add !lsein 00051 1039 66 83 ADD SANS+I 00052 1036 67 85 STA SWORK+l 00053 1030 66 64 LOA SWORK 00054 103F 69 62 ADC SANS 00055 1041 B7 64 STA SWORK 00056 1043 3A 83 DEC SANS+1 SANS -1 -) SANS 00057 1045 20 E8 BRA SORT2 Branch SO'H2 ~HITACHI 536 19. CONVERTING 2-BYTE HEXA- DECIMALS INTO s-DIGIT BCD MCU/MPU I HD630s FAMILY I LABELl HEX FUNCTION I (a) Converts 2-byte hexadecimals data in RAM into s-digit BCD data and stores result in RAM. (b) Utilizes unsigned integers in argument. ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS • : Not affected x : Undefined ROM (Bytes) 31 Storage Byte Contents Location Lgth. 1 : Result RAM (Bytes) 6 2-byte ACCA IX Stack (Bytes) Entry hexa- decimal HEXD (RAM) 2 I x I x I 0 No. of cycles C Z x x 1257 Argu- N I Reentrant ments Re- S-figure turns BCD DECD (RAM) 3 x H • No Relocation x No Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details HEXD : Holds 2-byte hexadecimals to (RAM) be converted into BCD. DECD : Contains s-gidit BCD. (RAM) (b) Fig. 1 shows example of HEX execution. CD argument Entry bls {IIEXIJ( RA.'d) I (SCIJFE) C HEXD b19 : D IF :E I 1 IIEXD+l bO bO I If argument is as shown in part CD of @ Return {1J ~ ~A~\J 5 2 : 7 I 0.: I 3 : + I I Fig. I, s-digit BCD, in this case argument (527H) DECD IJECD+I DECD+2 "52734" is held in DECD (RAM) (see part @of Fig. 1). Fig. 1 Example of HEX EXECUTION (2) User Notes "0" is held as MSD (105) of return argument. SPECIFICATIONS NOTES I ~HITACHI 537 19. CONVERTING 2-BYTE HEXA- DECIMALS INTO 5-DIGIT BCD I MCU/MPU 1 HD6305 FAMILY 1 J LABEL HEX DESCRIPTION I (3) RAM Description Label RAM Description b7 bO HEXD Upper byte ~ Lower byte DECD Upper byte ~ f-- Lower byte HCNTR (4) Sample Application HEX subroutine is called after 2-byte hexadecima1s is held. WORlU RMB 2 Reserves memory byte for 2-byte hexadecima1s. WORK 2 RMB 3 Reserves memory byte for 5-digit BCD. WORK 3 RMB 2 Reserves memory byte for register contents saving. STA STX WORK 3 WORK3+l 1 Saves register contents that will be destroyed by HEX execution. LOA WORK 1 } STA HEXD Stores 2-byte hexadecima1s into entry LOA WORK 1+1 argument (HEX). STA HEXD+I JSR HEX II Calls HEX subroutine. LOA DECO STA WORK 2 LOA DECD+I Stores 5-digit BCD (return argument (DECO» STA WORK2+l in RAM. LOA DECD+2 STA WORK2+2 LOA WORK 3 } ___ ...;_ Restores register. LOX WORK3+l ~HITACHI 538 19. CONVERTING 2-BYTE HEXA- DECIMALS INTO 5-DIGIT BCD I MCU/MPU I HD6305 FAMILY I LABEL I HEX DESCRIPTION I (5) Basic Operation (a) 4-bit binary (ABCD) construction is shown in Fig. 2 (Formula I, Formula 2). ABC D = A x II· + B x II • + C x 2 1 + D x 2' ............ (Fo rmu la 1) =rHAXll)+B'X2+C~X2+D ......... (Formula 2) 1 I I I I I I I' , I I I I I I I ct I I I I I , I T Fig. 2 4-bit binary (ABCD) (b) 2-byte hexadecimals can be converted into 5-digit BCD by calculating (Formula 2). First, calculate a = (A x 2) + B, and adjust result into decimal. Next, the same calculation is done for fJ '" (a x 2) + C, and T (fJx 2) + D, both of which are adjusted into decimals. (c) HEX uses HEXD and DECD (RAM) for a = (A x 2) + B (i) Shifts 2-byte hexadecimals (HEXD) 1 bit left and rotates MSB to bit C. (ii) Loads 5-digit BCD (DECD) into ACCA and calculates (ACCA) + (DECD) + (bit C) ..... (ACCA), where a = (A ~: 2) + B is executed. (iii) Adjusts result into decimal and stores them in DECD. (iv) Loops (i) to (iii) sixteen times to convert 2-byte hexadecimals into 5-digit BCD. I • HITACHI 539 --------------------------- 19. CONVERTING 2-BYTE HEXA- MCU/MPU FAMILY DECIMALS INTO 5-DIGIT BCD HD6305 HEX FLOWCHART ~,....-------' ---{ Clears RAM where BCD is stored • .----======:;t-~ ---{ Stores number of shifts in loop counter. ~---{ Shifts and rotates 2-byte hexadecimals and sets MSB of 2-byte hexadecimals to bit C. ~----'---{ Loads "3" into IX. IX is inner loop counter. ~-~ Doubles RAM where BCD is stored and adds MSB of hexadecimal to result. ~---{ Adjusts result into decimal and stores them in RAM where BCD is stored. Decrements inner loop counter. ' - - - - r - - - - ' ---{ ---{ stored, Tests if all RAM where BCD is are converted or not. Decrements loop counter. '----.---------I - - - { Tests if shifts are completed or ----C not. ~HITACHI 540 19. CONVERTING 2-BYTE HEXA- DECIMALS INTO S-DIGIT BCD 1 MCU/MPU J HD630S FAMILY ILABEL I HEX PROGRAM LISTINGT 00001 00002 ************************************************ ,. ,. .. 00003 NAME : CONVERTING 2-BYTE HEXADECIMALS ,. ,. 00004 00005 ,. INTO S-DIGIT BCD (HEX) . 00006 00007 ..************************************************,. 00008 .. ENTRY : HEXD (2-BYTE HEXADECIMALS) ,. ,. RETURNS : DECO (S-DIGIT BCD) ,. 00009 00010 ,. ,. ***********************~************************ 00011 00012 ,. ORG S80 00013 0080 00014 .. 2-byte hexedeclmeLs 00015 0080 0002 HEXD RMB 2 00016 0082 0003 DECO RMB 3 S-dlglt BCD 00017 0085 0001 HCNTR RMB 1 Subtrectlon counter 00018 . ORG S1000 00019 1000 00020 . EQU ,. Entry point 00021 1000 HEX 00022 1000 3F 82 CLR DECO CLeer S-dlglt BCD eree 00023 1002 3F 83 CLR DECD+1 00024 1004 3F 84 CLR DECD+2 00025 1006 A6 10 LOA IH6 Set shift counter 00026 1008 B7 85 STA HCNTR 00027 100A 3B B1 HEXl ASL HEXD+1 Shift MSB of HEXD to cerry 00028 100C 39 80 ROL HEXD 00029 100E AE 03 LDX 113 Set ADDR pointer (eddltlon counter) 00030 1010 E6 Bl HEX2 LOA DECD-l. X DECO .. 2 + C -> ACCA 00031 1012 E9 B1 ADC DECD-1. X 00032 1014 8D DAA Convert Into BCD 00033 1015 E7 B1 STA DECD-l.X Store S-dlglt BCD ereB 00034 1017 SA DEC X Decrement ADDR pointer 00035 101B 26 F6 BNE HEX2 Loop untiL ADDR pointer = 0 00036 lOlA 3A BS DEC HCNTR Decrement shift counter 00037 101C 26 EC BNE HEX1 Loop untiL shift counter = 0 00038 101E 81 RTS ~HITACHI 541 20. CONVERTING 5-DIGIT BCD INTO 2-BYTE HEXADECIMALS MCU/MPU I HD6305 FAMILY I LABEL I .BCD FUNCTION I (a) Converts 5-digit BCD data in RAM into 2-byte hexadecimals and stores result in RAM. (b) Utilizes unsigned integers in argument. ----..---..- .- ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS SPEC IFICATIONS e: Not affected ROM (Bytes) x: Undefined 70 Storage Byte Contents Location Lgth. ! : Result RAM (Bytes) 8 ACCA IX Stack (Bytes) Entry 5-digit decimals DEC (RAM) 3 I x I x I 0 No. of cycles Argu- C Z 440 ments x x Reentrant N I No 2-byte HDATA Re- turns hexa- (RAM) 2 x e Relocation decimals H No x Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details DEC : Holds 5-digit BCD to be RAM (RAM) converted into hexadecimal. b7 bO f""~ HDATA: Contains 2-byte hexadecimals. 1 Entry DEC t 1 2 7 (RAM) I< Entry point 00023 1000 AE 80 LOX !lDEC Load BCD DATA ADDR 00024 1002 A6 OS LOA 115 Set figure counter 00025 1004 B7 85 STA BCNTR 00026 1006 3F 83 CLR HDATA CLear Hex area 00027 1008 3F 84 CLR HDATA+l 00028 100A 01 85 11 BCDI BRCLR 0.BCNTR.BCD4 Branch if bitO = 0 00029 1000 F6 LOA O.X 00030 100E A4 OF AND !I$F Set Lower 4 bits of BCD data 00031 1010 B8 84 BCD2 ADD HDATA+l ACCA + HDATA+l -> HDATA+l 00032 1012 B7 84 STA HDATA+l 00033 1014 AF CLR A CLear ACCA 00034 1015 B9 83 ADC HDATA ACCA(O> + HDATA + C-)HDATA 00035 1017 B7 83 STA HDATA 00036 1019 3A 85 DEC BCNTR Decrement digit counter 00037 1018 26 08 BNE BCD5 Loop unTiL figure counter = 0 00038 1010 81 RTS 00039 101E F6 BCD4 LOA O.X Set upper 4 bits of BCD data 00040 101F 44 LSR A 00041 1020 44 LSR A 00042 1021 44 LSR A 00043 1022 44 LSR A 00044 1023 20 EB BRA BCD2 Branch BCD2 00045 1025 00 85 01 BCDS BRSET 0.BCNTR.BCD3 Branch if bitO = 1 00046 1028 SC INC X Increment BCD data ADDR 00047 1029 38 84 BCD3 ASL HDATA+l HDATA:HDATA+l*2->BWDRK:BWORK+l 00048 1026 39 83 ROL HDATA 00049 102D 86 83 LOA HDATA 0005e 102F B7 86 STA BWORK 00051 1031 B6 84 LOA HDATA+l 00052 1033 B7 87 STA BWDRK+l 00053 1035 48 ASL A HDATA:HDATA+1>1<4-)HDATA:HDATA+l 00054 1036 39 83 RDL HDATA 00055 1038 48 ASL A 00056 1039 39 83 ROL HDATA 00057 103B B6 B7 ADD BWORK+l HDATA+l + BWORK+1->HDATA+1 00058 1030 B7 B4 STA HDATA+1 00059 103F B6 86 LOA BWORK 00060 1041 B9 83 ADC HDATA HDATA + BWORK + C - l HDATA 00061 1043 B7 83 STA HDATA 00062 1045 20 C3 BRA BCDI Branch BCDI ~HITACHI 548 21. SORTING MCU/MPU I HD6305 FAMILY I LABELl SORT FUNCTIONS 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 Storage Byte •x : : Not affected Undefined ROM (Bytes) 36 Contents Location Lgth. 1 : Result RAM (Bytes) 10 No. of ACCA IX Stack (Bytes) bytes to ACCA 1 be sorted I x I x I 0 No. of cycles Entry C Z 474 Starting Argu- address x x Reentrant ments of data IX 1 to be N I No sorted x H • Relocation No Re- turns - - - x Interrupt Yes DESCRIPTION I (1) Function Details (a) Argument details ACCA: Holds number of bytes to be sorted; (No. of bytes to be stored - 1) I-byte hexadecimal. IX : Holds starting address of data in RAM to be sorted in 1-byte hexadecimal. SPECIFICATIONS NOTES I ''No. of cycles" in "SPECIFICATIONS" represents the number of cycles needed to sort 5-byte ascending data to descending. ~HITACHI 549 21. SORTING HD6305 FAMILY SORT DESCRIPTION (b) Fig. 1 shows example of SORT execution. b7 ACCA bO If entry arguments are as shown in part Q) of ACCA($H) 10:. I Fig. 1, sorted data is stored from b7 IX bO I X ($90) I 9 : 0 I address $90 in descending order (see Memory space part ® of Fig. 1). Q)Entry Start argument address·-+$9o As data to be sorted is 5-byte, $04 of data t----I (Number of bytes to be sorted; ($05)-1) to be is held in ACCA. sorted(IX) (2) User Notes (a) When loading number of bytes to be ~ Memory space sorted, holds (No. of bytes to be sorted r Sorted - 1) to ACCA for effective loop processing. data (b) Stores data to be sorted in RAM ® Result using direct addressing. Fig. 1 Example of SORT execution (3) RAM Description Label RAM Description b7 bO SWORKI IX (address pointer) is saved. 1--------1 } ~--------Il SWORK2 Work area is reserved to exchange data SWORK3 during sorting operation. Counter is stored which shows how many SCNT 1 bytes remain to be sorted. SCNT 2 Counter is stored which shows how many L---_----I } bytes remain to be compared. ~HITACHI 550 21. SORTING I K:U/MPU I HD6305 FAMILY I LABELl SORT DESCRIPTION} (4) Sample Application SORT subroutine is called after start address and number of bytes to be sorted are held. WORKl RMB 1 Reserves memory byte for number of bytes to be sorted. WORK 2 RMB 1 Reserves memory byte for start address to be sorted. LDA WORKl ----- Loads number of bytes to be sorted into entry argument (ACCA) • LDX WORK 2 ----- Loads start address of data to be sorted into entry argument (IX) • ~ JSR SORT Calls SORT subroutine. " I ~HITACHI 551 21. SORTING I K:U/MPU 1 HD6305 FAMILY I LABEL I SORT DESCRIPTION I (5) Basic Operation (a) Fig. 2 shows how three byte values are sorted in descending order. Number of bytes 1__&_ _1_0_ _ _8_...1 Input data .. n=3 S---io 8 ......•......•. CD First [ lO~~ __ comparison times (n-1=2) Second - 10 & ... 8 8 ............... ............... ® @ (Note) 11'''-..... shows comparison. comparison [ 10 ............... ® >< shows data exchange • times 10 ............... ® (n-2=1) Fig. 2 Example of Sorting (i) Finds t~e lareest value among three and puts it into left position. (See Fig. 2 CD , ® and @ ) (ii) Compares middle and right values and puts larger one in middle. (See Fig. 2 CD , @ and ® ) (b) Program processing (0 Uses IX as two pointers. (ii) First, use IX as pointer showing memory address where data is stored. (iii) Loads this data into ACCA to be compared. (iv) Increments address where data is stored and compares new value with value (indicated with using index addressing mode) in ACCA. (v) If value is larger than compared value in ACCA (memory> ACCA), exchange them. (vi) Loop (iv) to (v) until counter SCNT2, showing number of remaining bytes,_ reaches "0". (vii) When SCNT2 reaches "0", the largest data is stored in ACCA. (viii) Then use IX as pointer when storing the largest data. (ix) Stores contents of ACCA in address IX points, and loads next address, at which the next largest data is to be stored, into IX. (x) Decrements counter SCNT1 showing how many bytes remain to be sorted. (xi) Loops (iv) to (x) until SCNT1 is "0" • • HITACHI 552 21. SORTING MCU/MPU HD6305 FAMILY SORT FLOWCHART Stores number of bytes to be sorted in ---{ SCNTl. ___ { Stores number of bytes to be compared in SCNT2. ___ { Saves start address of data to be sorted in RAM. ---{ Loads first data to be sorted into ACCA. ---{ Increments address pointer. ACCA with value of Exchanges data in ACCA with that pointed by IX. ---{ Decrements number of bytes to be compared. I Tests if all the comparisons are { (SeNTz),..- 0 completed or not. Continued on next page ~HITACHI 553 21. SORTING MCU/MPU HD6305 FAMILY SORT FLOWCHART ----I Stores order. maximum data in RAM in descending ____ [Increments address whose data is loaded to ACCA. ____ {necrements number of bytes remaining to be sorted. ____ { Loads the number of bytes remaining to be compared. ____{Tests if all the data is completed or not. Continued previous page _ _-'-_ _ (RTS) ~HITACHI 554 21. SORTING I MCU/MPU I HD6305 FAMILY I I LABEL SORT PROGRAM LISTING I 00001 00002 ,.************************************************,. 00003 ,. NAME : SORTING (SORT) ,. 00004 ,. ,. 00005 ,. ************************************************ ,. 00006 00007 ,. ENTRY :-ACCA (VOLUME OF SORTING DATA) ,. 00008 ,. IX (TOP ADDR OF SORTING DATAS)" 00009 ,. RETURNS: NOTING ,. 00010 ,. ,. 00011 00012 ,. ************************************************ 00013 0080 ORG S80 00014 ,. 00015 0080 0001 SWORK1 RMB Work tor ADDR oolnter 00016 0081 0001 SWORK2 RMB Work for data exchange 00017 0082 0001 SWORK3 RMB Work. for data exchange 00018 0083 0001 SCNTl RMB Counter for sortln9 data 00019 0084 0001 SCNT2 RMB Counter tor comoarlng date 00020 ,. 00021 1000 ORG $1000 00022 ,. 00023 1000 SORT EQU ,. Entry poInt 00024 1000 87 83 STA SCNTl Store counter tor sortIng data 00025 1002 87 84 SORTl STA SCNT2 Store counter tor comparIng data 00026 1004 BF 80 STX SWORI<1 Store sortln9 date ADDR 00027 1006 F6 LDA O.X Load sortln9 data 00028 1007 5C SORT2 INC X Set next sortln9 DATA ADDR 00029 1008 F1 CMP O.X Compere comparing DATA wIth sortin9 date 00030 1009 24 OA Bce SORB Branch it comparIng DATA> sortin9 data 00031 100B 87 81 STA SWORI<2 Exchange each data 00032 100D F6 LDA O.X 00033 100E 87 82 STA SWORI<3 00034 1010 B6 81 LDA SWORK2 00035 1012 F7 STA O.X 00036 1013 B6 82 LDA SWORI<3 Load exchanged data 00037 1015 3A 84 SORB DEC SCNT2 Decrement compare data counter 00038 1017 2<5 EE BNE SORT2 Loop untiL compare data counter=O 00039 1019 8E 80 LDX SWORKl Load sorting data ADDR 00040 1018 F7 ST .. O.X Store ml!x data 00041 101C se INC X Increment sortin9 data ADDR 00042 1010 3A 83 DEC SCNTl Decrement sortin9 data counter 00043 101" 86 83 LDA SCNTl Load sortins data counter 00044 10:?1 26 DF 8NE SORT) Loop unt;l sorting data counter=O 00045 1023 8: RTS ~HITACHI 555 ~HITACHI 556 HD63051HD63L05 SERIES HANDBOOK Section Seven Hardware Application Notes I ~HITACHI 557 ~HITACHI 558 FOREWORD The HD6305 is a series of CMOS 8-bit single chip microcomputers controlled by microprogramming. The CPU, clock generator, ROM, RAM, I/O, timer and serial communication interface are all resident on the chip. This series can be applied to a wide variety of systems, both small and large. APPLICATION NOTES are written to help users design hardware systems using examples of typical application functions with specific circuit diagrams, timing charts and program examples. Application examples in APPLICATION NOTES used in actual systems should be tested for proper operation. NOTE The following hardware application notes were prepared for HD6305X and HD6305Y devices. The applications, however, are generic in nature and also apply to HD6305U, HD6305V, and HD63L05 devices. ~HITACHI 559 Section 7 Hardware Application Notes Table of Contents Page APPLICATION NOTES GUiDE........................................ 563 1. HOW TO USE APPLICATION NOTES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 565 1.1 Application Example Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 565 1.2 1st Section (Hardware) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567 1.3 2nd Section (Software) ......................................... 571 1.4 3rd Section (Program Module) ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 573 1.4.1 Specification Format (Format 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 574 1.4.2 Description Format (Format 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 580 1.4.3 Flowchart Format (Format 3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 582 1.5 4th Section (Subroutine) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 584 1.6 5th Section (Program Listing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 587 1.7 Program Module Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 591 1.8 Symbols..................................................... 594 APPLICATION EXAMPLES... ..... . .. ...... . . ............ ..... . .. . ... 597 110 PORT APPLICATIONS 1. HD61830 (LM200) Graphic Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 2. Liquid Crystal Module (H2570) Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623 TIMER APPLICATIONS 3. Duty Control of Pulse Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641 4. Pulse Width Measurement ...... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 655 5. Input Pulse Count. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664 6. Zero Cross. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 672 7. Key Matrix (8 x 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 683 8. Fluorescent Display Control ................................ . . . . . . . 697 9. Stepping Motor Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709 INTERRUPT APPLICATION 10. With a Commercially Available Keyboard. . . . . . . . . . . . . . . . . . . . . . . . . . .. 734 ~HITACHI 560 SCI APPLICATIONS 11. SCI Clock Synchronous (External Clock) . . . . . . . . . . . . . . . . . . . . . . . . . . .. 748 12. SCI Clock Synchronous (Internal Clock). . . . . . . . . . . . . . . . . . . . . . . . . . . .. 760 13. Liquid Crystal Driver (HD61100A) Control. . . . . . . . . . . . . . . . . . . . . . . . . . .. 772 EXTERNAL EXPANSION APPLICATION 14. External Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784 LOW POWER DISSIPATION/FAIL SAFE APPLICATION 15. Low Power Dissipation Mode and HA1835P Control . . . . . . . . . . . . . . . . . .. 816 $ HITACHI 561 • HITACHI 562 APPLICATION NOTES GUIDE • HITACHI 563 ~HITACHI 564 1. HOW TO USE APPLICATION NOTES This chapter describes the configuration for each system application example following this chapter. 1.1 APPLICATION EXAMPLE CONFIGURATION 1 Each application example in APPLICATION NOTES is divided into 5 sections, as shown in Fig. 1.1. r - - - - - - - - - - - - - - - - - - - - - - - - - - -1 1st Section - - - -.....•..1 HARDWARE DESCRIPTION Function I (Hardware) 1 Microcomputer 1 1 Applications 1 1 Circuit Diagram I 1 Pin Functions 1 1 1 Hardware Operation ~---------------------------~ r-----------------------~ 2nd Section ------4·~1 SOFTWARE DESCRIPTION progra.m Module 1 (Software) Configuration 1 Program Module Functions I Program Module Sample 1 •L _ _ _ _ _ _ _ _ _ _ _ _ _ _ ____ Application ____ (Main _ _ _ .1 Program) r-----------------------, 3rd Section - - - - - - 4...1 PROGRAM MODULE (Program Module) DESCRIPTION FUNCTION ,ARGUMENTS CHARGES IN CPU REGISTERS AND FLAGS SPECIFICATIONS DESCRIPTION Function Details SPECIFICATIONS User Notes NOTES RAM Description FLOWCHART Sample Application B~sic Operation - - - - - - - - - - - - - - - - - - - - _I r-----------------------. 4th Section - - - -..........1 SUBROUTINE (Subroutine) 1 • DESCRIPTION 1 FUNCTION BASIC OPERATION : I n~~ 1 ~---------------------~ r------ 1 - - - - - - - - - - - - - - --I 5th Section - - - - - - 4.... PROGRAM LISTING Main Program Listing I (Program Listing) I Program Module I Listing 1 L __ Subroutine'Listing ------------------ J Fig. 1.1 Application Example Configuration ~HITACHI 565 (1) 1st Section (Hardware) Describes the function, circuit diagram or hardware operation of the HD6305 hardware example. (2) 2nd Section (Software) Describes the program module to control the hardware example in the 1st section and shows the main program when using all program modules. (3) 3rd Section (Program Module) Describes the program modules presented in the 2nd section in detail, using a modular format for more efficient system use. (4) 4th Section (Subroutine) Describes the subroutines used in the above program modules. Refer to it necessary when you use program module. (5) 5th Section (Program Listing) Presents sample application program listing for the above modules. A detailed explanation of all five sections follows. ~HITACHI 566 1.2 1ST SECTION (HARDWARE) (1) Function Describes system specifications for the hardware used in the particular application. Example: (1) Fune: t ion (a) Controls dot matrix liquid crystal controller driver H044780 (hereinafter, LCD-II) using the 1ID6305XO and displays in character mode on liquid crystal lIOdule H2570. (b) H2570 displays 5x7 dot characters in l-colUD\ x l6-row. (c) Transfers ASCII from the HD6305XO as display data to LCD-II. LCD-II automatically controls liquid ~rystal driver HD44100 and LCD by controlling LCD-II with the 1ID6305XO. (2) Microcomputer Applications Describes the typical functions of the microcomputer utilized for the particular application. Example: (2) Microcomputer Applications Displays characters on H2570 by controlling LCD-II data bus (DBo '" DB,) and control signals (E, as and R!W) through port G and port F. ~IiITACHI 567 (3) Circuit Diagram Shows the circuit diagram for the hardware specified above. Note) All the microcomputers described in APPLICATION NOTES are used Plastic DIP. Example: (3) Circuit Diagram MCU Liquid crystal module H2S70 +5V HD6305XO (HD6305YO) r----------------------- DB HI go I DB~'" G2 DBiLCD- gl 81, DBS gi DB6 ~ G7 v.. VDD o Fig. 1 H2570 Control Circuit • HITACHI 568 (4) Pin Functions Describes pin functions for interfacing external circuits using a table. Example: (4) Pin Functions Pin function. at the interface between the HD630SXO and LCD-II are shown in Table 1. Table 1 Pin Functions Active Pin Pin Name Input/ Name Program (HD630SXO) Level:..) Output ~High Function (LCD- Label r Low II) FO Output High Enable signal E Low Selects instruction register F1 Output RS High Selects data register PFDTR Writes data Low (Microcomputer + LCD-II) F2 Output R/W Re~ds data High (MicrocomDuter + LCD-II) Go Input! Ou~put - DBo f--- Input! G1 Ou~ut - DBl f--- Input! G2 Output - DB. t--- G3 Input! Ou~put - DB, Data lines f--- PGDTR G4 Input! Output - DB. f--- GS Input! Output - DB. t--- G6 Input { Ou~l'ut Input! - DB. t--- G7 Output - DB? (a) "Active Level" in Table I indicates as follow; High Logical I Low Logical 0 Logical I or Logical 0 (b) l:2:j in "Program Label" in Table I means there is no program label. ~HITACHI 569 (5) Hardware Operation Describes hardware operation required to control external circuits showing tUning charts. Example: (S) Hardware Operation LCD-II control signals (as, a/W, E) are controlled by the program. Each LCD-II control signal timing chart i. shown in Fig. 2. The HD630S family utilizes I/O port rather than buses to control LCD-II to eliminate any timing restriction. on LCD-II. Pin name (LCD-II) as, a/w E DBo"'DB 7 (HD630SXO+LCD-II)_ _ _ _ _ _ _ _ _ _ _ _J JIo.----''lf-J " '_ _ __ DBo"'DB7 (HD630SXO+-LCD-II) _ _ _ _ _ _ _ _ _ _ _ _J 1'0----.1 '1._ _ __ *1 Data is written to LCTC at the falling edge of E. *2 Data from LCD-II can be read during period Tl. Fig. 2 HD6305XO ++ LCD-II Interface _HITACHI 570 1.3 2ND SECTION (SOFTWARE) (1) Program Module Configuration Describes the necessary program modules to control the hardware specified in the 1ST SECTION. Each module in the Program Module Configuration figure has module No. (number of modules: 1 ~ N) at the upper right. The module No. of the main program is '0'. Example: (1) Program Module Configuration The program module configuration for character display on the liquid crystal module is shown in Fig. 3. Fig. 3 Program Module Configuration (2) Program Module Functions Explains functions of each program module presented in Program Module Configuration. "No." in the table matches module No. in Program Module Configuration. Example: (2) Program Module Functions Program module functions are summarized in Table 2. Table 2 Program Module Functions No. Program Module Name Label Function 0 MAIN PROGRAM LCDMN Demonstrates 'character display on H2570. 1 RESET LCD-II LCDRES Resets LCD-II using instruction. 2 In1.t1.all.zes LCD-II to display characters INITIALIZE LCD-II LCDINT on LCD. 3 LCDDSP Transfers ASCII code to LCD-II and DISPLAY ON LCD disJ1,J/!YJI on H2570. ~HITACHI 571 (3) Program Module Sample Application (Main Program) Explains a sample program (Main Program) in flowchart format using program modules described in Program Module Configuration. Example: (3) Program Module Sample Application (Main Program) The flowchart in Fig. 4 is an example of character display on H2570 performed by program module in Fig. 3. The program in Fig. 4 demonstrates the display on liquid crystal shown in Fig. 5. Main Program -----{ Clears pointer indicating display data. ~::::: ---of Selects port G as output. ;:=::::c=~ ----- { Ca1ls program module LCDRES and resets LCD-II. ::=::::c=~ _____{ Ca1ls program module LCDINT and r----1L~iiii~r:::=~ initializes LCD-II. a ~;;:;:;;;:;r;::;;;~ ----{ Loads display data into IX using index addressing modes. Tests i f data in data table is terminator r-''-'- of Fig. 7, ASCII is stored Fig. 7 Example of LCDDSP in current address of DDRAM, and Execution characters are displayed on LCD. I SPECIFICATIONS NOTES I (1) "SPECIFICATIONS" includes subroutine LCDBSY. (2) "No. of cycles" in "SPECIFICATIONS" represents the number of cycles required when subroutine LCDBSY is executed by the minimum cycles. ~HITACHI 634 PROGRAM MODULE NAME II DISPLAY ON LCD II MCU/MPU I HD6305XO/YO ILABEL IfCDDS1 DESCRIPTION I~============~====~~==~ (c) Program module LCDDSP calls subroutines shown in Table 5. Table 5 Subroutine Called in LCDDSP SubNout ine Label Function ame CHECK BUSY Checks busy flag. FLAG LCDBSY (2) User Notes (a) Selects DDR of port G as output. (b) Calls program modules LCDRES and LCDINT and initializes LCD-II to make H2570 display characters using LCD-II. (3) RAM Description RAM is not used in program module LCDDSP. (4) Sample Application Program module LCDDSP is called after selecting I/O port, resetting LCD-II, initializing LCD-II and storing display data. I LDA tl$FF } --Selects port G as output. STA PGDDR JSR LCDRES ----calls program module LCDRES and resets LCD-II. JSR LCDINT----Calls program module LCDINT and initializes LCD-II. LDX 11$41 ----Stores display data in entry argument. IMI--J-S-R------L-C-D-D-SP--~II--·Calls program module LCDDSP. I I I (5) Basic Operation (a) Microcomputer cannot write data into LCD-II when LCD-II is in operation. Whether LCD-II is in operation or not can be checked by busy flag. Therefore, program module LCDDSP calls subroutine LCDBSY and checks I LCD-II busy flag to test if LCD-II is in operation. Busy flag - 1 LCD-II is in operation. Data cannot be written. Busy flag - 0 : Data can be written into LCD-II. (b) Controls LCD-II control signal and writes data into LCD-II with timing iHus trated in "2.1 HARDWARE DESCRIPTION, (5) Hardware Operation". ~HITACHI 635 PROGRAM MODULE NAME II DISPLAY ON LCD II MCU/MPU I HD6305XO/YO ILABEL IfCDDS~ ~==========~==~====~==~~ FLOWCHART ____{Cal1s subroutine LCDBSY for LCD-II busy check. ----1[sets signals RS to High. R/Wand E to Low. -----[ Sets signal E to High. -----[ Outputs ASCII for display to LCD-II. -----[sets signal E to Low. ~HITACHI 636 2.4 SUBROUTINE DESCRIPTION I SUBROUTINE NAME I ~I===CH=E=C=K=BU=S=Y=F=LA=G==I~I=M=C=U=/=MP=U=Il-=HD=6=3=0=5=XO=/=Y=OJ:..=1L=A=B=E=L::.I~IL=C=D=B~S~ I FUNCTION I (1) Tests LCD-II status. (2) Loops subroutine LCDBSY until LCD-II becomes READY. I BASIC OPERATION I The MSB of data bus becomes busy flag if LCD-II data bus is read during RS=O, R/W=l and E=l. MODULE USING Il FLOWCHART II PROGRAM THIS SUBROUTINE J LCDINT, LCDDSP LCDBSY ) LCDBSYj $00 -+ PGDDR ------[Se1ects port G as input. $04 -+ PFDTR ------[sets signals R/W to High, RS and E to Low. LCDBYII 05 -+ PFDTR -------[sets signal E to High. (PGDTR) ------[Loads busy flag into ACCA. -+ACCA Shifts(ACCA) ------[ Loads busy flag into bit C. 1 bit left $04 -+ PFDTR ------[sets signal E to Low. L.(B_i_t_C<)~ _____{ Loops until busy flag beco~s "0". ~C)=O $FF -+ PGDDR ------[ Selects port G as output. ( RTS ) ~HITACHI 637 2.5 PROGRAM LISTING 00001 ***** 00002 RA.M ALLOCATION ************************* 00003 * 00004 0080 ORG $SO 00005 *POINTR RMB 00006 0080 0001 1 Pointer of display data table 00007 0081 0001 LCDCNT RMB 1 Loop counter 00008 * 00009 **** SYMBOL DEFINITIONS ************* 00010 * 00011 OOOC PFDTR EQU $OC Port F data register 00012 0000 PGDTR EQU $00 Port G data register 00013 0007 PGDDR EQU $07 Port G data direction register 00014 ************************************************ 00015 * * 00016 * MAIN PROGRAM : LCDMN * 00017 * * 00018 ************************************************ 00019 * 00020 1000 ORG $1000 00021 * 00022 1000 4F LCDMN CLR A Clear' pointer' 00023 1001 87 SO STA POINTR 00024 1003 87 00 STA PGDTR Initialize port G 00025 1005 A6 FF LOA t:I$FF 00026 1007 87 07 STA PGDDR Select port G as output 00027 1009 CD 1021 JSR LCDRES Reset LCD-II 00028 100C CD 1041 JSR LCDINT Initialize LCD-II 00029 100F 8E SO LCDM1 LOX POINTR Load data table pointer 00030 1011 DE 10BA LOX DDATA.X Ascii data -> IX 00031 1014 A3 FF CPX t:I$FF Test if IX=$FF 00032 1016 27 07 BEQ PEND Branch if IX=t:I$FF 00033 lOIS CD 1059 JSR LCDDSP Display data 00034 1018 3C 80 INC POINTR Increment pointer 00035 1010 20 FO 8RA LCDMI 8ranch always LCDM1 00036 101F 20 FE PEND BRA PEND End of main program 00037 ************************************************ 00038 * * 00039 NAME: LCDRES (RESET LCD-II) * 00040 * 00041 ************************************************** 00042 * * 00043 ENTRY NOTHING * 00044 * RETURNS NOTHING 00045 * * 00046 * * ************************************************ 00047 1021 A6 03 LCDRES LOA t:l3 Initialize loop counter 00048 1023 87 81 STA LCDCNT 00049 1025 A6 OC LCDRSI LOA t:I$OC Initialize ISms counter 00050 1027 AE FF LCDRS2 LOX t:I$FF Initialize inner counter 00051 1029 SA LCDRS3 DEC X Decrement inner counter 00052 102A 26 FD BNE LCDRS3 Loop until inner counter=O 00053 102C 4A DEC A Decrement ISms counter 00054 1020 26 FS 8NE LCDRS2 Loop until 15ms counter=O 00055 102F B7 OC STA PFDTR Set RS=O.R/W=O.E=O ~HITACHI 638 00056 1031 A6 01 LDA "$01 00057 1033 87 OC STA PFDTR Set RS=O.R/W=O.E=l 00058 1035 A6 30 LDA "$30 00059 1037 87 OD STA PGDTR Write instruction d~ta 00060 1039 4F CLR A Set E=O 00061 103A 87 OC STA PFDTR 00062 103C 3A 81 DEC LCDCNT Decrement Loop counter 00063 103E 26 E5 BNE LCDRS1 Loop untiL Loop counter=O 00064 1040 81 RTS 00065 ************************************************ 00066 * * 00067 NAME: LCDINT (INITIALIZE LCD-II) * 00068 * 00069 * * ************************************************ 00070 * * 00071 * ENTRY : NOTHING * 00072 RETURNS : NOTHING 00073 * * 00074 ************************************************** 00075 1041 AE 06 LCDINT LDX"6 Load Loop counter 00076 1043 CD 1068 LCDIT1 JSR LCDBSY ChecK busy fLag 00077 1046 4F CLR A Set RS=O.R/W=O.E=O 00078 1047 B7 OC STA PFDTR 00079 1049 A6 01 LDA "$01 Set E=l 00080 104B B7 OC STA PFDTR 00081 104D D6 1083 LDA INS-1.X Instruction data-)LCD-II 00082 1050 B7 OD STA PGDTR 00083 1052 4F CLR A Set E=O 00084 1053 B7 OC STA PFDTR 00085 1055 SA DEC X Decrement Loop counter 00086 1056 26 EB BNE LCDIT1 Loop untiL Loop counter=O 00087 1058 81 RTS 00088 ************************************************ 00089 * * 00090 NAME : LCDDSP (DISPLAY ON LCD-II) 00091 * * 00092 ************************************************** 00093 * * 00094 * ENTRY : IX (DISPLAY DATA) * 00095 RETURNS : NOTHING * 00096 * 00097 * ************************************************ * 00098 1059 CD 106B LCDDSP JSR LCDBSY ChecK busy fLag 00099 105C A6 02 LDA "$02 Set RS=l.R/W=O.E=O I 00100 lOSE B7 OC STA PFDTR 00101 1060 A6 03 LDA "$03 00102 1062 B7 OC STA PFDTR Set E=l 00103 1064 BF OD STX PGDTR Display data-)LCD-II 00104 1066 A6 02 LDA "$02 Set E=O 00105 1068 B7 OC STA PFDTR 00106 106A 81 RTS 00107 ************************************************ 00108 * * 00109 * NAME : LCDBSY (CHECK BUSY FLAG) 00110 * * * $ HITACHI 639 00111 *******************************************~*** 00112 106B 4F LCDBSY CLR A Select port G as lnp6t 00113 106C B7 07 STA PGDDR 00114 106E A6 04 LDA 1:*$04 Set RS=O.R/W=l.E=O 00115 1070 B7 OC STA PFDTR 00116 1072 A6 05 LCDBYl LDA 1:*$05 Set E=l 00117 1074 B7 OC STA PFDTR 00118 1076 B6 OD LDA PGDTR Read busy flag 00119 1078 48 LSL A Set busy flag to bit C 00120 1079 A6 04 LDA 1=1$04 Set E=O 00121 107B B7 OC STA PFDTR 00122 107D 25 F3 BCS LCDBY1 Loop untiL busy fLag=O 00123 107F A6 FF LDA I=I$FF SeLect port G as output 00124 1081 B7 07 STA PGDDR 00125 1083 81 RTS 00126 ************************************************ 00127 * * 00128 * DATA TABLE * 00129 * * 00130 ************************************************ 00131 1084 OC INS FCB $OC.$18.$90.$07.$01.$08 *instr'uction 00132 108A 43 DDATA FCC ICMOS MCU HD6305XI *DispLay 00133 109A FF FCB $FF 00134 ************************************************ 00135 * * 00136 * VECTOR ADDRESSES * 00137 * * 00138 ************************************************ 00139 * 00140 1FF6 ORG $1FF6 00141 * 00142 1FF6 1000 FDB LCDMN SCIITIMER2 00143 1FF8 1000 FDB LCDMN TIMER/INT2 00144 1FFA 1000 FDB LCDMN INT 00145 1FFC 1000 FDB LCDMN SWI 00146 1FFE 1000 FDB LCDMN RES 00147 * 00148 END @HITACHI 640 I3. DUTY CONTROL OF PULSE OUTPUT 3.1 HARDWARE DESCRIPTION (1) Func t ion (a) Outputs pulse with OV100% duty rate from the HD630SXO. (b) Performs DA conversion of output pulse with external integration circuit. (2) Microcomputer Applications (a) Executes the interrupt routine with the built-in 8-bit timer with 7-bit prescaler in the HD630SXO (hereinafter timer) . (b) Switches port C and outputs p_ulse with the interrupt routine. (c) Changes High and Low period of pulse with TDR. (3) Circuit Diagram MCU HD630SXO +SV (HD630SYO) 33 VCC IN'r f, 22pF 4 mY 5 XTAL 4MHzO 6 EXTAL 1---4--'<1 +12V 22pF 2.2f-JF ~~Vr~~--~.~>-~--~ DA output I Fig. 1 Duty Pulse Output Circuit (4) Pin Functions Pin function for pulse output is shown in Table 1. Table 1 Pin Function Pin Name Input I Active Level Program (HD630SXO) Output (High or Low) Function Label C3 Output - Outputs pulse PCDTR ~HITACHI 641 (5) Hardware Operation Outputs pulse with av100% duty rate at each 0.3s, increasing the duty rate 4% each time from port on the HD6305XO. The pulse output and DA conversion are shown in Fig. 2. 100 40 : 60 Output from Port C3 (duty 40%) 8ms 8ms Output after 5V DA conversion r---' I r-' 4.6V n .----I : O• 3S ",,,,,,,~ (,.,.,.",,,, 0.4V ~ r-- I :---' I OV~~------------~~~----------~--~I----­ ~ t Fig. 2 Pulse Output and Waveform after DA Conversion (Note) The output voltage after DA conversion is proportional to the duty. The operational amplifier is used to prevent the flactuation of analog output voltage caused by the load in user system. ~HITACHI 642 3.2 SOFTWARE DESCRIPTION (1) Program Module Configuration The program module configuration for pulse output is shown in Fig. 3. DUMN lQ. MAIN PROGRAM DUSET I 1 DUOUT I L.!.. OUTPUT 12 SET DUTY PULSE Fig. 3 Program Module Configuration (2) Program Module Functions Program module functions are summarized in Table 2. Table 2 Program Module Functions No. Program Module Name Label Function 0 MAIN PROGRAM DUMN Outputs pulse with ()'\,lOO% duty rate. 1 SET DUTY DUSET Sets duty. 2 OUTPUT PULSE DUOUT Outputs pulse from I/O port. ~HITACHI 643 (3) Program Module Sample Application (Main Program) The flowchart in Fig. 4 is an example of DA conversion by controlling pulse, performed by the program module in Fig. 3. Main program in Fig. 4 changes pulse output with ~lOO% duty rate lat each 0.3 second, increasing the duty rate 4% each time. Main Program -----{ Initializes RAM for work. ;:::=::r:::::::::::; '-::=::r==~ _____ { port r Initializes port C and selects bit 3 of C as output. -----{ Initializes timer control register. ;:::=::r::::::~ -----{ Enables interrupt. r--I,Jnm:i~C:=~ _____ { Stores entry argument in program module DUSET. { Calls program module DUSET to store ----- entry argument in program module DUOUT. :==::r::::::~ Increments data for next pulse output. Executes software timer of about 0.3s. (IX);O Timer Interrupt Routine _____ [ Executes program module DUOUT to output '::=::E::::::-' puIs e . Fig. 4 Program Module Flowchart ~HITACHI 644 3.3 PROGRAM MODULE DESCRIPTION I PROGRAM MODULE NAME II SET DUTY II MCU/MPU IlHD6305XO/ YO II LABEL IIDUSET I I FUNCTION IJ (1) Stores High and Low output period corresponding to I-byte hexadecimal duty stored in entry argument. (2) Specifies duty each 4%. I ARGUMENTS 1/ CHANGES IN CPU REGISTERS AND FLAGS JI SPECIFICATIONS I Contents Storage Location Byte Lgth. • Not x : affected : Undefined ROM (Bytes) t : Result 40 RAM (Bytes) ACCA IX Entry Duty IX 1 I x I • I 3 Stack (Bytes) 0 C Z No. of cycles Argu- x x 33 ments Hi~h HTIME ou put N I Reentrant pen.od (RAM) 1 Re- Low output LTIME (RAM) 1 x • No Relocation period H turns Output status HLOUT (RAM) 1 • No Interrupt flag Yes I DESCRIPTION I IX b7 IX bO (1) Function Details En«y argument { ($OA) I 0 : I A (a) Argument details IX: Holds duty as I-byte t r b7 HTIMEbO hexadecimal number. HTIME(RAM) : Contains High output period. LTIME(RAM) : Contains Low output period. ~Return HTIME(RAM) I 6 ($64) LTIME 4 : I HLOUT(RAM): Contains Flag indicating what output is performed; arguments LTIME (RAM) I 9 ($96) 6 : I HLOUT Low consecutive output, High consecutive output, or pulse output. HLOUT(RAM)I 0 ($02) 2 : I Table 3 shows flag functions. Fig. 5 Example of DUSET Execution I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles required in case of duty 40%. ~HITACHI 645 PROGRAM MODULE NAME II SET DUTY DESCRIPTION ~========~==~==========~ Table 3 Flag Functions Bit/Label Label Function Bit 1 Bit 0 uutputs Low consectively from bit 3 0 0 of Port C. HLOUT 1 0 Outputs pulse from bit 3 of port C. 1 1 Outputs High consect1vely trom b1t j of port C. (b) Fig. 5 shows an examples of program module DUSET execution. When entry argument is as shown in part of Fig. 6. (c) Program module DUOUT calls neither program modules nor subroutines. (2) User Notes (a) Selects DDR of port C as output. (b) Initializes timer. (c) Clear bit I to enable timer interrupt. (3) RAM Description Label RAM Description b7 bO HTIME } Stores High output period. LTIME } Stores Low Stores output period. flag indicating High, Low or pulse HLOUT } output from bit 3 of port C. (4) Sample Application Program module DUOUT is called to output pulse from bit 3 of port C after initializing port C, timer and duty, and enabling interrupt. I LDA 11$08 STA PCDDR }---selects bit 3 of port C as output. LDA 11$00 STA TCR }---sets timer dividing rate at + 32. LDX 1110 --- Loads duty into entry argument of program module DUSET. JSR DUSET ---Calls program module DUSET to store High and Low output periods in entry arguments of program module DUOUT. CLI ---Enables interrupt. I I ~HITACHI 649 - - - - - - - - - - - - --------------- PROGRAM MODULE NAME II OUTPUT PULSE II MCU/MPU I HD6305XO/YO ILABEL I~UOUT I ~==========~==~====~==~~ DESCRIPTION (5) Basic Operation (a) Determines the previous output at every timer interrupt, and changes output port. High to Low, Low to High. The period of High or Low is stored in TDR. (b) When duty is 0% or 100%. TDR is set to 50% output and the output port remains in High or Low state. ~HITACHI 650 PROGRAM MODULE NAME II OUTPUT PULSE II MCU/MPU I HD6305XO/YO ILABEL IIDUOUT I FLOWCHART I~==========~==~====~==~~ -----[Clears timer interrupt request flag. (3,PCDTR)=O ----~Tests whether Low or High. (3,PCDTR)"O -----[stores High period in TDR. (l,HLOUT)=O _____[ Tests output status flag in High period. -----[ Outputs High from bit 3 of port C. -----[stores Low period in TDR. _____[Tests output status flag in Low period. (O,HLOUT)"l ..---.....I..~;....., _____[ Outputs Low from bit 3 of port C. DUOUT2 ~HITACHI 651 3.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 3.5 PROGRAM LISTING 00001 00002 * *>1<>1<>1< RAM 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<>1< 00003 >I< 00004 0080 ORG $80 00005 >I< 00006 0080 0001 HTIME RMB High puLse data 00007 0081 0001 L TIME RMB Low puLse data 00008 0082 0001 HLOUT RMB Output data ststus 00009 0083 0001 WORK RMB Work for entry argument 00010 >I< 00011 >1<>1<>1<>1< SYMBOL DEFINITIONS *>1<>1<>1<>1<>1<>1<>1<>1<>1<>1<>1< 00012 >I< 00013 0002 PCDTR EQU $02 Port C data register 00014 0006 PCODR EQU $06 Port C data direction 00015 0008 TDR EQU $08 Timer data register 00016 0009 TCR EQU $09 Timer control register 00017 >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< 00018 >I< >I< 00019 >I< MAIN PROGRAM : DUMN >I< 00020 >I< >I< 00021 >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< 00022 >I< 00023 1000 ORG $1000 00024 00025 1000 4F * DUMN CLR A rlear entry argument 00026 1001 B7 83 STA WORK 00027 1003 B7 02 STA PCDTR Initialize port C 00028 1005 A6 08 LDA 11$08 SeLect port C bit 3 as output 00029 1007 B7 06 STA PCDDR 00030 1009 A6 OD LDA 11$00 Set prescaler 1/32 00031 100B B7 09 STA TCR 00032 100D 9A CLI Enab lei nturrupts 00033 100E BE 83 DUMN1 LDX WORK Load entry argument of DUSET 00034 1010 AD 14 BSR DUSET Store entry argument of DUOUT 00035 1012 5C INC X DUTY+4%-)entry argument 00036 1013 A3 1A CPX 1126 DUTY=104% ? 00037 1015 26 01 BNE DUMN2 00038 10 1 7 SF CLR X Store 0% duty 00039 1018 BF 83 DUMN2 STX WORK Store duty In entry argument 00040 lOlA AE FF LDX fj$FF Execute 0.3s software timer 00041 101C A6 FF DUMN3 LDA Il$FF 00042 10lE 4A DUMN4 DEC A 00043 101F 26 FD BNE DUMN4 00044 1021 SA DEC X 00045 1022 26 F8 BNE DUMN3 00046 1024 20 E8 BRA OUMNI 00047 >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< 00048 >I< >I< 00049 >I< NAME : DUSET (SET DUTY) >I< 00050 >I< 00051 * *>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< 00052 >I< >I< 00053 >I< ENTRY IX (DUTY DATA) >I< 00054 >I< RETURNS HTIME (HIGH PULSE PERIOD) >I< 00055 >I< LTIME (LOW PULSE PERIOD) >I< ~HITACHI 652 00056 * HLOUT (OUTPUT STATUS FLAG) * 00057 * * 00058 ************************************************ 00059 1026 5D DUSET TST X Test tf duty=O% ? 00060 1027 26 06 8NE DUSET1 00061 1029 11 82 8CLR O.HLOUT Set for Low 00062 1028 13 82 8CLR 1.HLOUT Set for Low puLse 00063 102D 20 08 BRA DUSET2 00064 102F A3 19 DUSETl CPX t:l25 Test if duty=100%? 00065 1031 26 OC BNE DUSET3 Branch for puLse output 00066 1033 10 82 BSET O.HLOUT Set for high 00067 1035 12 82 BSET 1.HLOUT Set for htgh puLse 00068 1037 A6 7D DUSET2 LDA t:l125 Set 50% duty timming 00069 1039 B7 80 STA HTIME 00070 103B B7 81 STA LTIME 00071 103D 20 OE BRA DUSET4 00072 103F D6 1067 DUSET3 LDA HTDATA-1.X Set period of high puLse 00073 1042 B7 80 STA HTIME 00074 1044 D6 107F LDA LTDATA-l. X Set period of Low puLse 00075 1047 B7 81 STA LTIME 00076 1049 11 82 BCLR O.HLOUT Set for Low puLse 00077 1048 12 82 BSET 1.HLOUT Set for high puLse 00078 104D 81 DUSET4 RTS 00079 ************************************************ 00080 * * 00081 * NAME : DUOUT (OUTPUT PULSE) * 00082 * * 00083 ************************************************ 00084 * * 00085 * ENTRY HTIME (HIGH PULSE PERIOD) * 00086 * LTIME (LOW PULSE PERIOD) * 00087 * HLOUT (OUTPUT STATUS FLAG) * 00088 * RETURNS : NOTHING * 00089 * * 00090 ************************************************ 00091 104E 1F 09 DUOUT BCLR 7.TCR CLea (' interrupt request btt 00092 1050 07 02 OB BRCLR 3.PCDTR.DUOUTl High or Low output? 00093 1053 B6 81 LDA LTIME Store for Low puLse period 00094 1055 87 08 STA TDR 00095 1057 00 82 OD BRSET 0.HLOUT.DUOUT2 Duty=O%? 00096 105A 17 02 BCLR 3.PCDTR Output Low puLse 00097 lOSC 20 09 BRA DUOUT2 00098 lOSE B6 80 DUOUT1 LDA HTIME Store for high puLse period 00099 1060 B7 08 STA TOR I 00100 1062 03 82 0'2 BRCLR 1.HLOUT.DUOUT2 Duty=100% ? 00101 1065 16 02 BSET 3.PCDTR Output high puLse 00102 1067 80 DUOUT2 RTI 00103 ************************************************ 00104 *' * 00105 * DATA TABLE * 00106 * * 00107 ************************************************ 00108 1068 OA HTDATA FCB 10 4 *High puLse period 00109 1069 14 FCB 20 8 00110 106A IE FCB 30 12 ~HITACHI 653 00111 106B 28 FCB 40 16 00112 106C 32 FCB 50 20 00113 1060 3C FCB 60 24 00114 106E 46 FCB 70 28 00115 106F 50 FCB 80 32 00116 1070 SA FCB 90 36 00117 1071 64 FCB 100 40 00118 1072 6E FCB 110 44 00119 1073 78 FCB 120 48 00120 1074 82 FCB 130 52 00121 1075 8C FCB 140 56 00122 1076 96 FCB 150 60 00123 1077 AO FCB 160 64 00124 1078 AA FCB 170 68 00125 1079 B4 FCB 180 72 00126 107A BE FCB 190 76 00127 107B CB FCB 200 80 00128 107C 02 FCB 210 84 00129 1070 DC FCB 220 88 00130 107E E6 FCB 230 92 00131 107F FO FCB 240 96 00132 1080 FO LTDATA FCB 240 4 *Low puLse period 00133 1081 E6 FCB 230 8 00134 1082 DC FCB 220 12 00135 1083 02 FCB 210 16 00136 1084 CB FCB 200 20 00137 1085 BE FCB 190 24 00138 1086 B4 FCB 180 28 00139 1087 AA FCB 170 32 00140 1088 AO FCB 160 36 00141 1089 96 FCB 150 40 00142 108A 8C FCB 140 44 00143 108B 82 FCB 130 48 00144 108C 78 FCB 120 52 00145 lOBO 6E FCB 110 56 00146 lOBE 64 FCB 100 60 00147 l08F SA FCB 90 64 00148 1090 50 FCB 80 6B 00149 1091 46 FCB 70 72 00150 1092 3C FCB 60 76 00151 1093 32 FCB 50 80 00152 1094 28 FCB 40 84 00153 1095 IE FCB 30 88 00154 1096 14 FCB 20 92 00155 1097 OA FCB 10 96 00156 ************************************************ 00157 .* * 00158 * VECTOR ADDRESSES * 00159 * * 00160 ************************************************ 00161 * 00162 1FF6 ORG $lFF6 00163 * 00164 1FF6 1000 FDB DUMN SCI/TIMER2 00165 1FF8 104E FOB DUOUT TIMER/INT2 00166 IFFA 1000 FOB DUMN INT 00167 1FFC 1000 FOB DUMN SWI 00168 1FFE 1000 FOB OUMN RES 00169 lI< 00170 END ~HITACHI 654 14. PULSE WIDTH MEASUREMENT 4.1 HARDWARE DESCRIPTION (1) Function (a) Measures the High period of the pulse using the HD6305XO. (b) Measures pulse width from 100~s to 255~s. (c) Converts measurement result into binary coded decimal (BCD) m.unber. (2) Microcomputer Applications (a) Measures pulse width using TIMER pin and INT pin of the HD6305XO. (b) The HD6305XO counts down TDR while the TIMER pin is High. (c) Executes interrupt routine on the INT falling edge, reads TDR value, and measures pulse width. (3) Circuit Diagram MCU HD6305XO +5V (HD6305YO) 33 VCC ~.:o :::AL .,tJ2PF 2 RES 2.2~F 7 NUM Pulse input 1 Vss ILJL Fig. 1 Pulse Width Measurement Circuit ~HITACHI 655 (4) Pin Functions Pin functions for pulse width measurement are shown in Table 1. Table 1 Pin Functions Pin Name Input/ Active level Program (llD6305XO) Output (High or Low) Function Label INT Input Low Detects falling edge of input pulse and executes the external interrupt routine. / TIMER Input High Counts down the TDR during "1" active period. / (5) Hardware Operation The HD6305XO measures the pulse width by counting down the TDR using the E clock while TIMER pin is High, which is given in Fig. 2. TDR pulse count value N N 4 E Clock TIMER input pin --------~I: Clock width W 1 4 - - - - ' - - "~ (Note) When E clock cycle is l~s, the clock width W is 4~s. Measurement error is within l~s. Fig. 2 Pulse Width Measurement ~HITACHI 656 4.2 SOFTWARE DESCRIPTION (1) Program Module Configuration The program module configuration for measuring pulse width and converting result into BCD number is shown in Fig. 3. PWMN LQ.. MAIN PROGRAM I PWCNT I HEX I LL CONVERT L1.. MEASURE PULSE WIDTH HEXADECIMAL INTO BCD Fig. 3 Program Module Configuration (2) Program Module Functions Program module functions are summarized in Table 2. Table 2 Program Module Functions No. Program Module Name Lavel Function 0 MAIN PROGRAM PWMN Obtains the pulse width in BCD number. MEASURE PULSE WIDTH Calculates the pulse width from TDR in 1 PWCNT I-byte hexadecimal number. Converts I-byte hexadecimal number into BCD. CONVERT HEXADECIMAL 2 HEX See subroutine HEX in HD630S FAMILY INTO BCD APPLICATION NOTES (SOFTWARE) for details. ~HITACHI 657 (3) Program Module Sample Application (Main Program) The flowchart in Fig. 4 is an example of pulse width measurement performed by the program module in Fig. 3. The main program in Fig. 4 obtains the pulse width as BCD number. Main Program Loads $50 into TCR, disables timer ---- { interrupt and sets presca1er rate to "+1". (iN!) =1 pulse is Low. ----{ Initializes TDR. is Low. _____[C1ears RAM for storing pulse width. -----[Enab1es interrupt. Stores 1-byte hexadecimal pulse. -----[ width in entry argument (HEXD(RAM» of subroutine HEX. l ____ ca11S subroutine HEX and converts 1-byte hexadecimal pulse width into BCD. See subroutine HEX in HD6305 FAMILY APPLICATION NOTES (SOFTWARE) for details. ( PWCNT ) lNT Interrupt Routine PWCNT MEASURE _____[Obtains the pulse width in 1-byte PULSE WIDTH hexadecimal number. Fig. 4 Program Module Flowchart ~HITACHI 658 4.3 PROGRAM MODULE DESCRIPTION I PROGRAM MODULE NAME II MEASURE PULSE WIDTH II MCU/MPU I IHD6305XO/ YO I ILABEL IlpWCNT I I FUNCTION I (1) Calculates the pulse width in I-byte hexadecimal number and stores result in TDRRAM(RAM). (2) Sets oscillator frequency to 4MHz in P!"og!;am module PWCNT execution. I ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS II SPECIFICATIONS I Contents Storage Location Byte Lgth. • Not affected : x : Undefined ROM (Bytes) t : Result 10 RAM (Bytes) ACCA IX I Entry - - - I x I • I Stack (Bytes) 0 C Z No. of cycles Argu- x x 18 ments N I Reentrant Re- Pulse TDRRAM H x • No Relocation 1 turns Width (RAM) • No Interrupt No I DESCRIPTION I Input (a) Arguments details b7 bO b7 bO STRTF 0lID STRTF IJIIIIJ STRTF(RAM): Holds flag indicating start/stop of pulse ($01) ~ ($00) count. Table 3 shows ACCA flag functions. ACCA: Contains result of b7 bO Return [ ACCA pulse count as I-byte hexadecimal number. <2> argument ($AO) A: 0 I I Fig. 5 Example of PLSCNT Execution I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles required to start pulse count. ~HITACHI 667 PROGRAM MODULE NAME II COUNT PULSES II MCU/MPU I HD6305XO/YO ILABEL IrLSCN~ DESCRIPTION I~========~====~====~~~ Table 3 Flag Functions Label Bit/Label Function h,t 0 Stops pulse count STRTF I Starts pulse count (b) Fig. 5 shows an example of program module PLSCNT execution. If 160 pulses are input from TIMER pin as shown in part CD of Fig. 5, the count result is contained in ACCA as shown in part Return {FREQ Table 3 shows flag functions. argument (RAM) b7 I 0 :0 I ($00) Fig. 5 EXrmple of FRQCNT Execution I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles requi red to measure frequency of 60 Hz. ~HITACHI 675 ! PROGRAM MODULE NAME II MEASURE POWER FREQUENCY II MCU/MPU IIHD6305XO/YO I! LABEL I fRQCN~ I DESCRIPTION II Table 3 Flag Functions Bit/Label Label Function bit I bit 0 0 0 Frequency is 50Hz. FREQ 0 I Frequency is 60Hz. I I Frequency is other than 50Hz or 60Hz. (b) Fig. 5 shows an example of program module FRQCNT execution. If power supply of 50Hz is measured as shown in part Return KEYONF ar uments module K84SCN g KEYONF(RAM) I 0: 1 I completion status. ($01) KEYONF(RAM)=1 : Indicates that key scan data Fig. 5 Example of K84SCN is stored in Execution KEYDAT(RAM). I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles required until key data is valid. ~HITACHI 688 I PROGRAM MODULE NAME II KEY SCAN II MCU/MPU I HD6305XO/YO ILABEL IIK84SC1 DESCRIPTION I~========~====~======~~ KEYONF(RAM)=O : Indicates that key scan data is not stored in KEYDAT(RAM). (b) Fig. 5 shows an example of program module K84SCN execution. If key in part aD of Fig. 5 is depressed, key scan data is contained in KEYDAT (RAM) as shown in par t 0 of Fig. 5. (c) Program module K84SCN calls neither program modules nor subroutines. (2) User Notes (a) Initializes timer 2. (b) Clears bit I and enables interrupt. (3) RAM Description Label RAM Description b7 bO OLDKEY } Stores previous key input data. NEW KEY } Stores present key input data. STBDAT } Stores data for strobe signal output. KEYNUM } Stores key number. Stores total number of depressed key during present TOTLKY } key scan. KEYONF } Stores flag indicating key being defined during key scan. KEYDAT } Stores defined key number by key scan. Stores counter for retrieving depressed key among SCOUNT } key input data. CHATFL } Bit 3-0; Stores counter for counting number of key scan data comparison. Bit 7 Stores flag for indicating whether chatter elimination has been completed. (4) Sample Application Program module K84SCN is called every 8ms after initializing timer 2 and enabling interrupt. I CLR OLDKEY I CLR }- - - Clears RAM to be used. KEYONF CLR PCDTR - - - Initializes port C. LDA II$OD STA LDA STA SCR 11$20 SSR 1--- Sets timer 2 interrupt cycle to 8ms, and enables timer 2 interrupt. CLI - - -Enables interrupt. LOOP BRCLR O,KEYONF,LOOP---Tests key press. I LDA KEYDAT STA KEY SET }---stores key scan data in RAM. BCLR O,KEYONF - - --Clears key press flag. I I I ~HITACHI 689 PROGRAM MODULE NAME II KEY SCAN II MCU/MPU I HD6305XO/YO I I LABEL fS4SC, DESCRIPTION ~========~==~====~====~ (5) Basic Operation. (a) Executes key scan with every Sms timer interrupt. Checks key scan execution flag (KEYONF(RAM» at the beginning of key scan, and decides whether present key scan data will be executed or not. (b) Outputs strobe signal from bit 3 to 0 of port C one by one, and fetches key press data from port G. (c) Tests if key scan data loaded into (b) is $FF. (i) $FF key scan data means that key of the column supplying current strobe signal was not depressed. Key scan for next column is started. (ii) Key scan data other than $FF means key of the column supplying current strobe signal is depressed. Test which row is pressed. CD Tests if bit C is 1 or 0 by shifting ACCA content where key scan data is stored, by 1 bit to right S times. In case of bit C is 0, the key was depressed. ~ To test double keys depressed, if key scan data includes 0, TOTLKY(RAM) is incremented. In case of TOTLKY=l, KEYNUM(RAM) content is stored in NEWKEY(RAM). In case of TOTLKY>I, double keys were depressed and return from program-module is performed. (d) Compares key data (NEWKEY(RAM» detected in (c) with previous key data (OLDKEY(RAM». If they are the same, counts-up lower 4 bits of chatter counter CHATFL(RAM). When the counter indicates "3", the key is defined. This is indicated by setting MSB of chatter cancel flag CHATFL(RAM) to " 1 ". The CHATFL(RAM) indicates both counter and flag. The chatter cancel flag is cleared when NEWKEY(RAM) and OLDKEY(RAM) data are different, and when no key is depressed. ~HITACHI 690 I PROGRAM MODULE NAME II KEY SCAN II MCU/MPU I HD6305XO/YO I I~84SC' LABEL FLOWCHART I~==========~==~====~==~~ ____ { Clears interrupt request bit of ~ __~____~ timer 2. is processed data for strobe signal. ----{ Initializes RAM indicating key number. ____ { Initializes RAM indicating the number of depressed key. ____{Initializes RAM storing newly-depressed key number. -----[ Outputs strobe signal. -----[ Loads key input data. ~HITACHI 691 PROGRAM MODULE NAME II KEY SCAN II MCU/MPU I HD6305XO/YO ILABEL If84SC, FLOWCHART I~==========~==~====~==~~ ___ {stores shift counter to check what key is depressed among 8 bits. ---{ Shifts key input data I bit right. ---{ Tests if key is depressed. ___ J 1 Tests if 2 keys are depressed at the same time. ____[ Stores depressed key number in NEWKEY(RAM) . ----[ Increments RAM indicating key number. ---{ Decrements shift counter. if one row key scan is completed. 4 ___ { Shift strobe Signal data I bit right to execute key scan for next column. ___ {Tests if all column key scan is I completed. ~HITACHI 692 I PROGRAM MODULE NAME II KEY SCAN II MCU/MPU I HD6305XO/YO ILABEL IE84SC, FLOWCHART I~==========~==~======~====~ present key input data is O. (NEWKEY) =(OLDKEY) __{compares present key input data with previous key input data. ~,.....,,=o.=....---' previous NEWKEY(RAM) and clears of key scan press. --~Tests if key is continuously pressed. Compares the number of chatter (CHATFL(RAM» with constant number. If they are the same, determines as key press and fetches key data. --1[Increments the number of chatter. { Sets flag indicating the termination -- of chatter prevention. __{stores depressed key data in RAM for processing with main program. __{sets flag indicating depressed key data being defined • • HITACHI 693 7.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 7.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ************************ 00003 * 00004 0080 ORG $80 00005 * 00006 0080 0001 II< *>I< 00055 >I< NTRY : NOTHING ~HITACHI 694 00056 * RETURNS : KEYOAT (KEY DATA) * 00057 * KEYONF (ESTAFLISHMENT OF KEY ON) * 00058 * * 00059 ************************************************ 00060 101E 10 11 1<84SCN BCLR 6.SSR CLear interrupt request fLag 00061 1020 00 84 60 BRSET o.I Result I '1Ihl'-, ~HI(lll: II , 1,1 , , II I I Fig. 6 Example of FLDSP Execution I SPECIFICATIONS NOTES I "No. of cycles" 'in "SPECIFICATIONS" represents the number of cycles required to display 1 digit. ~HITACHI 702 I PROGRAM MODULE NAME II Ir.:::=ll DRIVE FLUORESCENT DISPLAY TUBE .If::::l r;:;:l ~ HD6305XO/YOI~~ I DESCRIPTION II~==========~==~====~==~== (c) Table 3 shows relation between display data and actual display. Table 3 Display Data and Corresponding Display Display Display Display Display Data Data n $CO I.J $92 -. I I $E9 I $82 5 $A4 r $F8 1 $BO -: $80 U $99 .., I I $90 IJ_ I' :J (d) Program module FLDSP calls neither program modules nor subroutines. (2) User Notes (a) Reserves data shown in Table 3 as data table. (b) Selects DDRs of port A and port C as output. (c) Initializes timer 2. (d) Clears bit I to enable timer 2 interrupt. (3) RAM Description Label RAM Description b7 bO SEGD 10 7 digit ,.-- 10 6 digit - - ---- 105 digit 10 4 digit - Stores 8-digit display data shown in - -- ~ 10 3 digit Table 3. 10 2 digit - 10 1 digit - - 100 dhit - Stores counter indicating digit to be DSCNTR DECD l displayed. Stores data indicating digit turned on. ~HITACHI 703 PROGRAM MODULE NAME DRIVE FLUORESCENT DISPLAY TUBE I MCU/MPU I HP6305XO/YO ILABEL II FLDSP I DESCRIPTION (4) Sample Application Program module FLDSP is executed every lms after clearing bit I, initializ- ing digit output data, counter, port and timer 2. Fluorescent displays when display data is stored in display RAM. I I I LDA STA II$FE DECD }------ Initializes digit output data. LDA 11$07 } Initializes digit output counter. STA DSCNTR LDA II$FF } STA PADDR - - - -- Selects ports A and C as output. STA PCDDR LDA II$OA STA SCR }----- Sets interval of timer 2 interrupt to lms. LDA STA 11$2F SSR }----- Enables timer 2 interrupt. CLI - - - - - - Enab les in terrupt • LDA 11$11 STA SOA LDA 11$00 STA SOA+l Calls subroutine MOVE and transfers display LDA IISEGD data from data table to SEGD(RAM) where display STA DEA data is stored. LDA II$OB STA MCNT JSR MOVE I I I ORG $1100 FCB $FB, $B2, $92, $99, $BO, $A4, $E9, $CO - - - - - - - Display data (5) Basic Operation (a) Previous digit display is turned off and next digit is displayed every timer interrupt. (b) DSCNTR(RAM) is used as counter for display digits and pointer for display data and digit data. (c) Outputs display data and digit data to port using index addressing mode. (d) Decrements counter for display digits and pointer for digit data. ~HITACHI 704 I PROGRAM MODULE NAME DRIVE FLUORESCENT DISPLAY TUBE I MCU/MPU I HD6305XO/YO I LABEL IIFLDSP I FLOWCHART ------[Clears interrupt request bit of timer 2. _____{Turns off display for constant period each time one digit is displayed. -----l[Loads pointer indicating display data. ------{Outputs display data into port A. ------[outputs digit signal to port C. ______[Decrements counter indicating display digit. 8 digits are displayed. _____{InitializeS data for next display otate(DECD output. 1 bit left ------[ Initializes data for display output. ______[Initializes counter indicating display digit. ~HITACHI 705 8.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 8.5 PROGRAM LISTING 00001 00002 * **** RAM ALLOCATION ************************* 00003 00004 0080 * ORG $80 00005 * 00006 0080 0008 SEGD RMB 8 DispLay data 00007 0088 0001 DSCNTR RMB 1 Digit counter' 00008 0089 0001 DECO RMB 1 Digit data 00009 008A 0002 SOA RMB 2 Source address 00010 008C 0001 DEA RMB 1 Destination address 00011 0080 0001 MCNT RMB 1 Transfer counter 00012 008E 0004 MSUB RMB 4 Work area for subroutine 00013 0092 0001 SPNT RMB 1 ReLative data of source address 00014 * 00015 **** SYMBOL DEFINITIONS ************ 00016 00017 0000 * PADTR EOU $00 Port A data register 00018 0002 PCDTR EOU $02 Port C data register 00019 0004 PADDR EOU $04 Port A data direction register 00020 0006 PCDDR EOU $06 Port C data direction register 00021 0010 SCR EQU $10 SCI controL register 00022 0011 SSR EQU $11 SCI status register 00023 ************************************************ 00024 00025 ** MAIN PROGRAM : FLMN ** 00026 * * 00027 ************************************************ 00028 * 00029 1000 ORG $1000 00030 00031 1000 A6 FE * FLMN LOA t:I$FE InitiaLize digit data 00032 1002 B7 89 STA DECO 00033 1004 A6 07 LOA 1=17 InitiaLize digit counter 00034 1006 B7 88 STA DSCNTR 00035 1008 A6 FF LOA I=I$FF 00036 100A B7 04 STA PADDR SeLect port A as output 00037 100C B7 06 STA PCDDR SeLect port C as output 00038 100E A6 OA LOA t:I$OA InitiaL Ize SCR 00039 1010 B7 10 STA SCR 00040 1012 A6 2F LOA 1=I$2F InitiaLize SSR 00041 1014 B7 11 STA SSR 00042 1016 9A CLI EnabLe interrupts 00043 1017 A6 11 LOA t:I$l1 Stores source start address 00044 1019 B7 8A STA SOA into entry argument 00045 101B A6 00 LOA 1=1$00 00046 1010 B7 8B STA SOA+1 00047 101F A6 80 LOA I=ISEGD Stores destinatlo start address 00048 1021 B7 8C STA DEA into entry argument 00049 1023 A6 08 LOA t:l8 Stores Length of byte to be 00050 1025 B7 80 STA MCNT moved into entry argument 00051 1027 AD 25 BSR MOVE Move Segment data 00052 1029 20 FE PEND BRA PEND End of main program • HITACHI 706 00054 ******************************************* 00055 00056 * NAME : FLDSP (DRIVE FLOURSCENT DISPLAY ** * 00057 * TUBE) * 00058 * 00059 ******************************************* * 00060 * * 00061 * ENTRY DEGD (DISPLAY DATA) 00062 RETURNS NOTHING * 00063 * * 00064 ********************************************* 00065 102B 10 11 FLDSP BCLR 6.SSR CLear interrupt request flag 00066 102D A6 FF LDA "$FF Turn off dispLay 00067 102F B7 02 STA PCDTR 00068 1031 BE 88 LDX DSCNTR Load di9it counter 00069 1033 E6 80 LDA SEGD.X Output dispLay data 00070 1035 B7 00 STA PADTR 00071 1037 B6 89 LDA DE CD Output digit data 00072 1039 B7 02 STA PCDTR 00073 103B 3A 88 DEC DSCNTR Decrement digit counter 00074 103D OF 89 05 BRCLR 7.DECD.FLDSP1 DispLay 8-di9it ? 00075 1040 99 SEC Store next dl9it data 00076 1041 39 89 ROL DECO 00077 1043 20 08 BRA FLDSP2 00078 1045 A6 FE FLDSP1 LDA "$FE InitiaLize digit data 00079 1047 B7 89 STA DECO 00080 1049 A6 07 LDA In InitiaLize digit counter 00081 104B B7 88 STA DSCNTR 00082 104D 80 FLDSP2 RTI 00083 ************************************************ 00084 00085 ** NAME : MOVE (MOVING MEMORY BLOCKS) ** 00086 * 00087 ************************************************ * 00088 00089 * ENTRY SOA (SOURCE ADDR) * 00090 * DEA (DESTINATION ADDR) * 00091 * MCNT (TRNSFER COUNTER) * 00092 * RETURNS : NOTHING * 00093 * * 00094 * * ************************************************ 00095 104E A6 D6 MOVE LOA "$06 00096 1050 B7 8E STA MSUB Store instruction code (LDA 00097 1052 B6 8A LOA SOA Disp.X) 00098 1054 B7 8F STA MSUB+1 Store source ADDR (H) 00099 1056 B6 8B LDA SOA+1 00100 1058 B7 90 STA MSUB+2 SLore source ADOR (L) 00101 105A A6 81 LDA "$81 00102 105C B7 91 STA MSUB+3 Store instruction code (RTS) 00103 lOSE 3F 92 CLR SPNT CLear reLative data of source ADDR 00104 1060 BE 92 MOVE1 LOX SPNT Load reLative data of source ADDR 00105 1062 BD 8E JSR MSUB Load transfer data 00106 1064 BE 8C LOX DEA Destination ADDR 00107 1066 F7 STA O.X Store transfer data 00108 1067 3C 8C INC OEA Increment destination ADDR ~HITACHI 707 00109 1069 3C 92 INC SPNT Increment reLetive dete of source ADDR 00110 106B 3A BD DEC MCNT Decremerrt transfer counter 00111 1060 26 F1 BNE MOVE1 Brench until transfer counter=O 00112 106F 81 RTS 00113 ************************************************ 00114 * * 00115 * DATA TABLE * 00116 * * 00117 ************************************************ 00118 * 00119 1100 ORG $1100 00120 * 00121 1100 F8 FCB $F8.$82.$92.$99.$BO.$A4.$E9.$CO 00122 ************************************************ 00123 * * 00124 * VECTOR ADDRESSES * 00125 * * 00126 ************************************************ 00127 * 00128 IFF6 ORG $lFF6 00129 * 00130 IFF6 102B FOB FLDSP SCIITIMER2 00131 1FF8 1000 FOB FLMN TIMER/INT2 00132 1FFA 1000 FOB FLMN INT 00133 1FFC 1000 FOB FLMN SWI 00134 1FFE 1000 FOB FLMN RES 00135 * 00136 END ~HITACHI 708 19. STEPPING MOTOR CONTROL 9.1 HARDWARE DESCRIPTION (1) Func t ion (a) Drives stepping motor using the HD6305XO. (b) Uses 4-phase 2 exciting stepping motor. (c) 1 to 255 steps can be selected. (d) Controls slue pulse rate (slow-up, operating and slow-down) when 12 steps or more are selected. (e) Selects clockwise (normal) slue and counterclockwise (reverse) slue with stepping motor. Operates backlash when reverse slue is selected. (2) Microcomputer Applications (a) Executes interrupt routine using 8-bit timer with 7-bit presca1er contained in the HD6305XO (hereinafter, timer). (b) Drives stepping motor by outputting pulses from port B by interrupt routine. (c) Generates slow-up and slow-down pulse rate by changing TDR value. (3) Circuit Diagram MCU HD6305XO (HD6305YO) +12V +5V 33 VCC + 3 INT" 4 ST 5 XTAL ISSl72x4 6 EXTAL 2lmS" 7 NUM 1 VSS Fig. 1 Stepping Motor Control ~HITACHI 709 (4) Pin Functions Pin functions at the interface between the HD6305XO and stepping motor are shown in Table 1. Table 1 Pin Functions Active Pin Name Input/ level Pin Name Program (HD6305XO) Output (High Function (Motor) Label or Low) B2 Output - i B3 Output - Connects stepping motor. A PBDTR B4 Output - B B5 Output - A (5) Hardware Operation The stepping motor supplies pulses at the HD6305XO I/O port as shown in Fig. 2. At initialization Reverse slue • C Normtl slue Step Count --I1_4:.....L.1..:3;...L..=,2...L..:l=-+-=O+=-l...L.I...;;2;;....&...1.; ;,.3......1_4~1 A(BS) .J I B(B4) ----.I r A(B3) -, L- "lr(B2) - - , L B4 B2 (2 exciting type) Fig. 2 Outline of Stepping Motor Operation ~HITACHI 710 Slow-up and slow-down pulse rate are supplied to the stepping motor every four steps as shown in Fig. 3. Operating pulse Slow-down pulse Slow-up pulse rate area rate area rate area 21 20 1 4 steps .... ........................ 5 6 o 7 I Starts sl~ Stops slue Fig. 3 Outputs to the Stepping Motor (a) The pulse rate changes every 4 steps for slow-up and slow-down. (b) In case of slow-up area to the operating pulse area, the pulse rate changes in 21 steps to gradually increase the slue speed. (c) In case of slow-down area to stop, the pulse rate changes in 7 steps to gradually reduce the slue speed. (d) When reverse slue is selected, an additional one-step rotation, followed by a normal ~ne-step rotation, is executed. ~HITACHI 711 9.2 SOFTWARE DESCRIPTION (1) Program Module Configuration The program module configuration for stepping motor control is shown in Fig. 4. o MAIN PROGRAM SMCLC SMREV PROCESS GENERATE DATA STEPPING MOTOR OUTPUT Fig. 4 Program Module Configuration (2) Program Module Functions Program module functions are summarized in Table 2. Table 2 Program Module Functions No. Program Module Name Label Function 0 MAIN PROGRAM SMMN Rotates stepping motor. Calculates output data for slow-up, 1 PROCESS DATA SMCLC operating, slow-down and backlash by supplying total step count. 2 GENERATE STEPPING Supplies pulses to the stepping motor. SMREV MOTOR OUTPUT ~HITACHI 712 (3) Program Module Sample Application (Main program) The flowchart in Fig. 5 is an example of the stepping motor rotation performed by the program module in Fig. 4. When the program module of Fig. 5 is executed, the stepping motor makes 201 reverse slue, then one normal slue. Main Program Initializes each pin of the stepping motor. PBSM is the RAM for loading data which is supplied to the stepping motor at port B at the beginning of each timer interrupt routine. -----{ Selects port B as output. ____ -[ Initializes stepping motor start flag. Specifies timing for output to the stepping motor in TDR. TDRD(RAM) is the RAM for loading the timer value to TDR at the beginning of the timer interrupt routine. -----{ Specifies presca1er dividing rate 16. -----{ Enables interrupt. _____ { Stores reverse slue data in entry argument. _____ { Stores 200-step data in entry argument. ----- l Determines values for processing of slow-up, operating, and slow-down, respectively, from the supplied step count. Timer Interrupt Routine ------[outputs to stepping motor. Fig. 5 Program Module Flowchart $ HITACHI 713 -. .-.. ----,,--.·-_-·-·.,--___ ~_-_-.,_---....."....,...-c-.--_-. _. _~_. _ .. ~_~ __ . . ..._.- - - - - - - - -_. __ . ._ - - - - - - - 9.3 PROGRAM MODULE DESCRIPTION I PROGRAM MODULE NAME II PROCESS DATA II MCU/MPU IIHD6305XO/ YO IILABEL IISMCLC I I FUNCTION II Generates data for outputting to the stepping motor by the timer routine. Sets data for slow-up, operating and slow-down after determining the backlash requirement. I ARGUMENTS II CHANGES IN CPU REGISTERS AND FLAGS II SPECIFICATIONS I Contents Storage Location Byte Lgth. • Undefined Not affected : x : ROM (Bytes) t : Result 140 Norma1/ Reverse FRFLG. RAM (Bytes) 1 ACCA IX slue FLGI Entry flag Total I x I x I 9 Stack (Bytes) Step STEP 1 2 Count C Z No. of cycles Argu- x x 333 ments Slow-up SUP 1 data N I Reentrant Operating data SHOLD 1 l~i~:-dOwn Re- Il{ema~nder SOON 1 x H • No Relocation STEPE 1 turns of step Norma~~ x No Reverse FRFLG. slue 1 FLGI Interrupt flag Slue start flag SMSF. FLG1 1 Yes I DESCRIPTION I (1) Function Details (a) Argument details FLGl(RAM) : Holds flag indicating slue direction and start of stepping motor rotation. Flag functions are shown in Table 3. STEP (RAM) : Holds total step count. SUP (RAM) : Contains slow-up data. SHOLD(RAM) : Contains operating data. SDWN(RAM) : Contains slow-down data. STEPE(RAM) : Contains remainder of total step count divided by 4. I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles required to execute data in the sample application. ~HITACHI 714 I PROGRAM MODULE NAME II II I I PROCESS DATA MCU/MPU IIHD6305XO/YO II LABEL EMCLC I DESCRIPTION II~========~==~====~==~~ Table 3 Flag Functions Bit/Label Labe 1 ~S:=:MS':-:F=-=r=::F=RF=-LG7"""i Function 1 Rotates stepping motor clockwise (normal). o Rotates stepping motor counterclockwise (reverse). t FLGI o Stops slue. 1 Starts slue. (b) Fig. 6 shows an example of b7 FLGI bO program module SMCLC (j) Entry FLGl(RAM) 1- 1-1-1-1-1-1-1 0 I execution. If entry arguments are held arguments (Reverse=O) b7 SI'EPbO as shown in part (STEP) -----[Stores data not to output operating data. _____ [ Stores SDWNW(RAM) value as slow-down data. Stores STEP(RAM)-(SDWNW(RAM)+I+SHOLD (RAM» as slow-up data. _____[Stores normal or reverse slue data for the stepping motor. -----[ Clears the slow-up data table pointer. _____[sets the flag for the/stepping motor output. ~HITACHI 720 I PROGRAM MODULE NAME I GENERATE STEPPING MOTOR OUTPUT J I I MCU/MPU I IHD630SXO/ YO I LABEL IISMREV I I FUNCTION I Outputs pulse to the stepping motor. I ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS II SPECIFICATIONS I Contents Storage Location Byte Lgth. • Undefined Not affected x : : ROM (Bytes) ~1(t'~-up SUP 1 t : Result 105 Operat1ng SHOLD 1 RAM (Bytes) data ACCA IX I~~~~-down SDWN 1 6 Remainder Entry of the STEPE 1 I x I x I Stack (Bytes) step Normal{ 2 Reverse FRFLG. 1 slue flag FLGI C Z No. of cycles Argu- S.~ue start SMSF. flag FLGI 1 x x 76 ments N I Reentrant Re- Slue SMSF, x • No Relocation H turns start FLGI 1 flag • No Interrupt No I DESCRIPTION I ( 1) Function Details (a) Argument details FLGI (RAM) : Holds flag indicating rotation direction and rotation start of the stepping motor. Flag functions are shown in Table 5. STEP (RAM) ; Holds total slue step count. SUP (RAM) : Holds slow-up data. SHOLD (RAM): Holds operating data. SDWN (RAM) : Holds slow-down data. STEPE (RAM): Holds remainder of the total step count divided by 4. I SPECIFICATIONS NOTES I of"No.cy ofclescycles" in "SPECIFICATIONS" represents the number req ui red to execute with data in the sample application. ~HITACHI 721 I PROGRAM MODULE NAME II GENERATE STEPPING MOTOR OUTPUT II MCU/MPU IIHD6305XO/ YO II LABEL IISMREV I I DESCRIPTION II Table 5 Flag Functions Bit/Label Label Function SMSF FRFLG - 1 Rotates stepping motor clockwise (normal). FLGI - 0 Rotates stepping motor counterclockwise (reverse). 0 Stops slue. 1 - Starts slue. (b) Fig. 7 shows an example of b7 SUP bO program module SMREV SUP (RAM) ($15) rr::I1 execution. SHOLD If the entry argument is SHOLD (RAM) [[:::::IJ held as shown in part of Fig. 7. FLCI l- J - I - I - I - I - I 1 I 0 (c) Program module SMREV calls (RAM) ~ SMSF (Bit 1) other program modules and slue start (=1) subroutines shown in Table 6. FRFLG (Bit 0) Reverse slue (=0) i (2) Return {b7 FLCI argument (RAM) FLG 1 1- 1-I -I -I - 1-I t -I 1 bO SMSF (Bit 1) Slue stop (=0) Fig. 7 Example of SMREV Execution Table 6 Program Modules and Subroutines Called in SMREV Program module/ Subroutine Name Label Function LOAD NORMAL/ REVERSE SMFR Tests whether slue is normal or reverse and SLUE DATA stores next data in stepping motor. (2) User Notes (a) Selects bits 2-5 of port B as output., (b) Initializes timer. (c) Clears bit I to enable timer interrupt. ~HITACHI 722 I PROGRAM MODULE NAME GENERATE STEPPING MOTOR OUTPUT IMCU/MPU I HD6305XO/YO ILABEL IISMREV I DESCRIPTION (3) RAM Description Label RAM Description b7 STEP SUP ~bO! Stores total step counts. Stores one-fourth the step count for slow-up. SHOLD Stores one-fourth the step count for operating. SDWN Stores one-fourth the step count for slow-down. Stores the remainder of the total step count STEPE I---~} divided by 4. ~I FLGI Stores flag indicating normal/reverse slue and start/stop for the stepping motor. PBSM Holds data output to each pin of stepping motor. TDRD '-------'} Holds data to be stored in TDR. (4) Sample Application Program module SMREV is called after selecting I/O port. initializing timer and enabling interrupt. WORKl RMB I - - - - Reserves memory byte for the total step I I count. I I LDA 11$66 STA PBSM }- - - Initializes the stepping motor output pin. STA PBDTR LDA 1I$3C STA PBDDR } --- Selects bit 2-5 of port B as outputs. BCLR SMSF. FLGI - ---Sets rotation stop. LDA 11250 fl____ STA TDRD STA TDR Initializes output timing to the stepping LDA 114 motor. STA TCR CLI - - - - Enables interrupt. BCLR FRFLG. FLGI} LDA WORKI - - - Loads entry argument. STA STEP JSR SMCLC - - - - Calculates entry argument. I I ~HITACHI 723 PROGRAM MODULE NAME GENERATE STEPPING MOTOR OUTPUT IMCU/MPU I I HD6305XO/YO LABEL IISMREV I DESCRIPTION (5) Basic Operation (a) Program module SMREV is called by the timer routine. (b) Outputs pulses one step to stepping motor every timer interrupt. (c) At the beginning of timer interrupt, timer timing (slow-up, operating and slow-down slue) which is held in advance and output to the stepping motor. (d) Following (c). data to be output at the next timer interrupt is loaded. (e) Only the timer timing is held and no output is provided to the stepping motor, when the rotation start flag SMSF(RAM) is cl~ared. (f) Slow-up or slow-down output data is supplied to the stepping motor every 4-step. (g) To implement (f), a test is performed to determine if the 4-step output is supplied within the same timing. Then, outputs are supplied in the sequence of slow-up, operating and slow-down. Normal/reverse slue is tested and if it is reverse, output for backlash is provided. (h) Timing data for slow-up and slow-down should be set in the data table in advance. ~HITACHI 724 PROGRAM MODULE NAME GENERATE STEPPING MOTOR OUTPUT I MCU/MPU I HD6305XO/YO I LABEL IISMREV I FLOWCHART ------~UPdates the timer interrupt period. ______{Clears the timer interrupt request flag. output is supplied to motor. 2 to the stepping motor. ______ {Decrements counter indicating output to the stepping motor in 4 steps. ______{Tests if 4-step outputs are given to the stepping motor. (SCNTR)=O 3 ______ ,Initializes counter indicating output lL to the stepping motor in 4 steps. ------{Tests if slow-up output is complete. (SUP)=O ______ {Decrements counter indicating output slow-up data. ------ Sets timing for next slow-up output. 3 1 ~HITACHI 725 PROGRAM MODULE NAME GENERATE STEPPING MOTOR OUTPUT IMCU/MPU I HD6305XO/YO ILABEL II SMREV I FLOWCHART Tests if steady state output is terminated (Output of the remaining step count from the total step count to be processed divided by 4). (ACCA)=O ____ -[ StGre, st . .dy state Gutput. _____ [Tests if operating pulse rate output is completed. (SHOLD)=O _____ [ Decrements counter indicating operating pulse rate output. - - - - - [Te"s i f sIGw-dG~ Gutput is <_leted. (SDWN)=O __ ~ __[ Decrements counter indicating slow-down output. _____ [Initializes timing for the next slow-down output. 4 ~HITACHI 726 PROGRAM MODULE NAME GENERATE STEPPING MOTOR OUTPUT IMCU/MPU I I HD6305XO/YO LABEL II SMREV I FLOWCHART (FRFLG,FLGl)=l ____{Tests if backlash processing is needed. (FRFLG,FLGl)=O SMREV7 O+SMSF,FLGI ____ {Terminates output to the stepping motor. ----~Load, output for backlash processing. ____{ Stores normal or reverse slue data for the stepping motor. I ~HITACHI 727 9.4 SUBROUTINE DESCRIPTION SUBROUTINE NAME r==l • CALCULATE NORMAL/REVERS ROTATION DATA ~ .~ HD6305XO/YO ~ r:=l EJ FUNCTION Tests whether slue flag (FRFLG(RAM) is normal or reverse, stores data for the next stepping motor output in PBSM(RAM). BASIC OPERATION Tests whether slue is normal or reverse, and then performs shift. As a result, output data for one-step normal/reverse slue is obtained. FLOWCHART PROGRAM MODULE USING SMCLC, SMREV THIS SUBROUTINE -----[Tests if slue is normal or reverse. 1 bit right If normal, stores data for the next stepping motor output. Shift (PBSM) 1 bit left If reverse, stores data for the next stepping output. C)=l ~HITACHI 728 9.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ******************* 00003 * 00004 0080 ORG $80 00005 * 00006 0080 0001 PBSM RMB 1 Work to keep PBDTR data 00007 0081 0001 TORD RMB 1 Work to keep TOR data 00008 0082 0001 STEP RMB 1 TotaL step count 00009 0083 0001 SUP RMB 1 SLow-up data 00010 0084 0001 SHOLD RMB 1 Operating data 00011 0085 0001 SDWN RMB 1 SLow-down data 00012 0086 0001 STEPE RMB 1 Remainder of step 00013 0087 0001 SCNTR RMB 1 4 steps counter 00014 0088 0001 UPPTR RMB 1 TDR up-tabLe pointer 00015 0089 0001 STEPW RMB 1 Work for sLow-up data 00016 008A 0001 SDWNW RMB 1 Work for sLow-doun data 00017 008B 0001 FLGl RMB 1 FLag area 00018 * 00019 **** SYMBOL DEFINITIONS *************** 00020 * 00021 0001 PBDTR EQU $01 Port B data register 00022 0005 PBDDR EQU $05 Port B data direction register 00023 0008 TOR EQU $08 Timer data register 00024 0009 TCR EQU $09 Timer controL register 00025 0000 FRFLG EQU 0 Fore and reverse fLag 00026 0001 SMSF EQU 1 SLue star't flag 00027 *************************************************** 00028 ** ** 00029 MAIN PROGRAM : SMMN 00030 * * 00031 *************************************************** 00032 * 00033 1000 ORG $1000 00034 *SMMN 00035 1000 A6 66 LDA "$66 InitiaLize work for PBDTR 00036 1002 B7 80 STA PBSM 00037 1004 B7 01 STA PBDTR InitiaLize PBDTR 00038 1006 A6 3C LDA "$3C SeLect port B b2-b5 as output 00039 1008 B7 05 STA PBDDR 00040 100A 13 8B BCLR SMSF.FLG1 InitiaLize SMSF 00041 100C A6 FA LDA "250 00042 100E B7 81 STA TORD InitiaLize work for TOR 00043 1010 B7 08 STA TOR InitiaLize TOR 00044 1012 A6 04 00045 1014 B7 09 00046 1016 9A 00047 1017 11 8B 00048 1019 A6 C8 00049 101B B7 82 00050 1010 AD 02 00051 101F 20 FE PEND LDA STA CLI BCLR LOA STA BSR BRA "4 TCR FRFLG.FLG1 Load argument ~200 STEP SMCLC PEND InitiaLize TCR EnabLe interrupts Store argument of 200 steps CaLcuLate argument for SMREV End of program I 00052 ************************************************ 00053 ** ** 00054 NAME : SMCLC (PROCESS DATA) 00055 * * ~HITACHI 729 00056 ************************************************ 00057 * * 00058 * ENTRY :FRFLG(l:FORE SLUE.O:REVERSE SLUE>* 00059 * :STEP(TOTAL STEP COUNT) * 00060 * RETURNS :SUP(SLOW-UP DATA) * 00061 * SHOLD(OPERATING DATA) * 00062 * SDWN(SLOW-DOWN DATA) * 00063 * STEPE(REMAINDER OF STEP) * 00064 * FRFLG(FORE/REVERSE SLUE FLAG) * 00065 * SMSF(SLUE START FLAG ) * 00066 * * 00067 ************************************************ 00068 1021 00 88 02 SMCLC 8RSET FRFLG.FLG1.SMCL1 Fore or reverse sLue 00069 1024 3C 82 INC STEP If reverse increment STEP 00070 1026 86 82 SMCLl LOA STEP Load Lower 2 bit 00071 1028 A4 03 AND tI$03 00072 102A 87 86 STA STEPE 00073 102C 34 82 LSR STEP Store 1/4 times of STEP 00074 102E 34 82 LSR STEP 00075 1030 86 82 LOA STEP Te5t if STEP=O ? 00076 1032 27 3C BEQ SMCL5 8ranch if STEP=O 00077 1034 AE 04 LOX 1'*4 Initialize 4 steps counter 00078 1036 8F 87 STX SCNTR 00079 1038 Al 01 CMP til Test If STEP=l? 00080 103A 27 3A BEQ SMCL6 Branch If STEP=l 00081 103C Al 02 CMP 1=12 Test if STEP=2? 00082 103E 27 3A BEQ SMCL7 Branch If STEP=2 00083 1040 3F 8A CLR SDWNW Initialize work area 00084 1042 A6 02 LOA 1=12 00085 1044 87 89 STA STEPW 00086 1046 3C 8A SMCL2 INC SO WNW Increment sLow-down work 00087 1048 A6 04 LOA tl4 Add slow-up work 00088 104A 88 89 ADD STEPW 00089 104C 87 89 STA STEPW 00090 104E Al IE CMP 1=130 Test if STEPW=)30? 00091 1050 24 33 8HS SMCL9 Branch STEPW=)30 00092 1052 81 82 CMP STEP Test if STEPW=STEP? 00093 1054 27 3F 8EQ SMCL10 8ranch STEPW=STEP 00094 1056 25 EE BLO SMCL2 Test if STEPW of ** I I Fig. 5. key data is stored in key buffer as shown in part (2) of Fig. 5. \,. ** (c) Program.module KEYIN calls neither program modules nor subroutines. • SPECIFICATIONS NOTES 1/ ~HITACHI 738 I PROGRAM MODULE NAME II RECEIVE KEY DATA II MCU/MPU I HD630SXO/YO I LABEL IIKEYIN I DESCRIPTION I~==========~==~====~==~~ b7 PS bO I E I PS($OO) 0; 0 (2) User Notes (2) Result PE($OI) I 0 : I I (a) Clears RAM since 2-byte RAM is used as pointer indicating key KEYBUF ~l buffer. * .,. I I (b) Selects DDR of port B as input. ** (c) Clears INT2 interrupt mask bit. **: hexadecimal (d) Clears bit I to enable INT2 inter- rupt. Fig. 5 Example of KEYIN Execution (3) RAM Description Label RAM Description b7 bO Stores pointer indicating unprocessed key ~t PS data in key buffer. PE dl Stores pointer indicating key data in key l KEYBUF buffer. Used as key buffer storing IS-byte key data. j (4) Sample Application Program module KEYIN is called if ASCII key is pressed after RAM to be used is cleard, INT2 interrupt is enabled, and after I/O port is selected and interrupt is enabled. I I I CLR STA STA STA A PS PE }----- Clears RAM to be used. MR Clears INT2 interrupt mask. STA PBDDR I Selects port B as input. CLI Enables interrupt. ~HITACHI 739 --------~. I PROGRAM MODULE NAME II RECEIVE KEY DATA II MCU/MPU I HD6305XO/YO I LABEL IIKEYIN I DESCRIPTION I~==========~========~==~~ (5) Basic Operation (a) Input/output to/from key buffer. (i) Calls program module KEYIN at every INT2 interrupt and fetches key data from key buffer. Then, calls program module KEYIN in main program and fetches key data from key buffer. (ii) Clears starting point PS(RAM) and ending point PE(RAM) and stores key data in key buffer starting address. (iii) Program module KEYIN stores 1 byte of key data in 16-byte buffer area pointed by PE(RAM) , and increments PE(RAM). (iv) Program module KEYOUT fetches 1 byte from l6-byte buffer area pointed by PS(RAM) and increments PS(RAM). (v) PS(RAM) and PE(RAM) become "0" i f they are incremented till 15 bytes because the buffer area is l6-byte long. (b) Input to key buffer (i) Program module KEY IN loads PE(RAM) into ACCA and increments ACCA. Then, compares ACCA content with PS(RAM). If (ACCA)=PS(RAM), key data is not stored in key buffer. If (ACCA) ~ (PS), key data is stored in key buffer and PE(RAM) is incremented. (ii) Key buffer can be used up to 15 bytes. ~HITACHI 740 PROGRAM MODULE NAME II II I RECEIVE KEY DATA I II I MCU/MPU HD6305XO/YO LABEL KEYIN FLOWCHART I~==========~==~====~==~~ '--_-.._---' ----{ Clears INT2 interrupt request flag. ----{ Loads key buffer pointer into IX. '----..----' ---- Increments key buffer pointer. (ACCA)=(PS) =-_...,..._....;.;.0 ----{ Stores key data in key buffer. ---- Increments key buffer pointer. I ~HITACHI 741 I PROGRAM MODULE NAME II READ KEY DATA II MCU/MPU I~HD6305XO/Y~ ILABEL IrYOUTI I FUNCTION II Reads data from key buffer. I ARGUMENTS II CHANGES IN CPU REGISTERS AND FLAGS JI SPECIFICATIONS I Contents Storage Location Byte Lgth. • x : : Not affected Undefined ROM (Bytes) t : Result 20 RAM (Bytes) ACCA IX 18 Entry - - - I x I x I Stack (Bytes) 0 C Z No. of cycles Argu- ments t x 27 Un- N I Reentrant Re- processed key data IX 1 x H • No Relocation turns Un- processed Bit C (CCR) 1 • No Interrupt key data existence Yes I DESCRIPTION I r b7 PS hO PS(RAM)I 0 : 1 J ($01) PE (1) Function Details PE(RAM)I ($03) o: 3 I (a) Argument details K~YBUE 47 Return 1 arguments IX BitC b7 IX bO ($40) loll 4 : 0 I BitC = 1: No unprocessed data is Fig. 6 Example of KEYOUT in key buffer. Execution (b) Fig. 6 shows an example of program module KEYOUT execution. Unprocessed data is contained into IX after program module KEYOUT execution. (c) Program module KEYOUT calls neither program modules nor subroutine. (2) User Notes Program module KEYOUT should be used with program module KEYIN. (3) RAM Description Label RAM Description b7 bO PS } Stores pointer indicating unprocessed data in PE } key buffer. Stores pointer indicating key data in key buffer. ~: tU,ed ., key buffer "oring 15 byte key data. KEYBUF f- I- .-- t j (4) Sample Application First, clears RAM to be used, enables INT2 interrupt, and initializes I/O port. Second, enables interrupt and executes program module KEYIN. Then, execute program module KEYOUT. WORK1 . RMB 1 Reserves memory byte for key buffer unprocessed data . I I 0 CLR A STA PS }-Clears RAM to be used. STA PE STA MR ---Enables INT2 interrupt. STA PBDDR ---Selects port B as input. CLI ---Enables interrupt. LOOP n----------K-E-Y-0-U-T--"II--Ca1ls JSR program module KEYOUT. II BCS LOOP ---Tests if unprocessed data is in key buffer. STX WORK1 ---Stores unprocessed data in return argument in RAM. ~HITACHI 743 PROGRAM MODULE NAME II READ KEY DATA II MCU/MPU I HD6305XO/YO ILABEL IB DESCRIPTION I~==========~==~====~==~~ (5) Basic Operation (a) Input/output to/from key buffer. See (a) of (5) Basic operation in program module KEYIN for details. (b) Output from key buffer. (i) Program module KEYOUT tests if values in starting pointer PS(RAM) and values in ending pointer PE(RAM) are equal. (ii) In case of PS(RAM)=PE(RAM), no key data is in key buffer and bit C is set. (iii) In case of PS(RAM)~PE(RAM), key data is fetched from key buffer PS(RAM) indicates, and PS(RAM) is incremented. ~HITACHI 744 PROGRAM MODULE NAME II READ KEY DATA II MCU/MPU I HD6305XO/YO I LABEL IIKEYOUl FLOWCHART I~==========~========~==~~ ~__~____~ ----[Loads starting pointer into IX. is in key ____[stores key buffer content in return ~ __ __-=... ~ argument. ~__~~~~ ---- Increments starting pointer. ____ [Clears bit C, because unprocessed data is in key buffer. Sets bit C, because no unprocessed ---- [ data is in key buffer. KEYOT2 I ~HITACHI 745 10.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 10.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ************************ 00003 * 00004 OOSO ORG $SO 00005 * 00006 0080 0001 PS RMB 1 RoLL buffer start poInter 00007 OOSl 0001 PE RMB 1 RoLL buffer end poInter 00008 00S2 0010 I Return argument [SCIRDA I-byte data I 4 : 3 I of received data. ('C'=$43) SCISOK(RAM)=l: Data is received SCISOK(RAM) SCISOK from master system. ($01) 0 : 1 I I Fig. 5 Example of SCISRD Execution I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles are needed when having no wait time for receiving data. ~HITACHI 752 PROGRAM MODULE NAME II SCI SLAVE RECEIVE II MCU/MPU I HD6305XO/YO I LABEL I~ DESCRIPTION I~========~==~~====~~~ SCISOK(RAM)=O: No data is received from master system. (b) Program module SCISRD execution stores contents of SCI data register in SCIRDA (RAM). (c) SCISRD calls neither program modules nor subroutines. (2) User Notes (a) Initializes SCR. (b) When program module SCISRD is used, resetting system (in case of power on reset, supplying power) should be performed from master system. (c) Program module SCISRD should be called before master system begins to send data. (d) Program module SCISRD loops until sending data from master system is completed. (3) RAM Description Label RAM Description bO } SClRDA Stores received data. SCISOK I} Stores existence of received data. (4) Sample Application Program module SCISRD is called if SDR is dummy-read, bit I is cleared, data is received after I/O port is designated and SCR and SSR are initialized. LDA 11$10 STA STA PCDTR PCDDR }- - - - - Sets port C bit 4 to High. LDA STA II$FO SCR } - - - - - Sets transfer rate and selects internal clock source. LDA STA 11$18 SSR }- - --- Enables SCI interrupt. LDA SDR - - - - - Dummy-reads and clears SDR. CLl - - - - - Enables interrupt. LO<1P BRCLR O,SCISOK,LOOP - -- Waits for receive completion. LDA SCIRDA - - - - - - Loads received data into ACCA. BCLR O,SCISOK- - ,- - - - Clears flag indicating receive completion (5) Basic Operation (a) Receives serial data using SCI interrupt routine. (b) SCI interrupt routine is generated at serial data transfer/receive. (c) If SCI interrupt is generated after serial data is transferred, either transfer or receive is decided by considering CK request signal being out ut. ~HITACHI 753 PROGRAM MODULE NAME II SCI SLAVE RECEIVE II MCU/MPU I HD6305XO/YO I LABEL IISCISRDI FLOWCHART I~==========~==~====~==~~ ____{ Tests whether transfer or receive completion. 4,PCDTR)=1 ----{ Releases CK request signal. L..-'-';'-=T=':':"'...J - - - - { Stores received data in SCIRDA(RAM). L..-_--.._ _...J - - - - { Sets flag indicating data receive. L..-_-r-_...J - - - - { Clears SCI interrupt request flag. ~HITACHI 754 I PROGRAM MODULE NAME II SCI SLAVE TRANSFER II MCU/MPU I IHD6305XO/YO I I LABEL IISCISTDI I FUNCTION I Sends data of ACCA to master system. I ARGUMENTS I CHANGES IN CPU REGISTERS AND FLAGS II SPECIFICATIONS I Contents Storage Location Byte Lgth. • : x : Not affected Undefined ROM (Bytes) t : Result 5 RAM (Bytes) ACCA IX 0 Entry Data to be sent ACCA 1 I x I • I Stack (Bytes) 0 C Z No . of cycles Argu- ments • x 13 N I Reentrant x • No Re- turns - - - H Relocation • No Interrupt Yes I DESCRIPTION I Q) Entry {ACCA b7 ACCA bO argument 1-byte datal 4 ('C'=$43) 3 I : (1) Function Details SCI data b7 ~ bO (a) Argument details register SDR I 4 3 I : ACCA: Holds data to be sent to CKP~ master system. (2) Result (b) Program module SCISTD execution transfers contents of ACCA to Tx ~~ I I I I I rLt o + SDR and sends them to master. Bit 0 Bit 7 (c) SCISTD calls neither program Fig. 6 Example of SCISTD modules nor subroutines. Execution I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents number of cycles needed when having no wait time for transfer completion. ~HITACHI 755 PROGRAM MODULE NAME II. SCI SLAVE TRANSFER II MCU/MPU I HD6305XO/YO I LABEL IISCIST4 DESCRIPTION I (2) User Notes (a) Selects bit 4 of port C as output. (b) Initialize SCI. (3) RAM Description RAM is not used by program module SCISTD. (4) Sample Application Call SCISTD after selecting I/O port, initializing SCR and SSR and storing data to be sent. WORKI RMB I 1 - - - -- data Reserves memory byte for loading to be sent in user program. I I LDA STA STA 11$10 PCDTR PCDDR } -- - - Sets port C bit 4 to High. LDA II$FO STA SCR }---- Selects external clock source. LDA STA 11$18 SSR }- - -- Clears SCI interrupt request flag. LDA WORKI } ---- Loads data to be sent into entry argument. II JSR I (5) Basic Operation SCISTD II Calls program module SCISTD. Loads data to be sent into SDR and outputs CK request Signal. ~HITACHI 756 PROGRAM MODULE NAME II SCI SLAVE TRANSFER II MCU/MPU I HD6305XO/YO I LABEL IISCIST1 FLOWCHART I~==========~========~==~~ L..-_-.-_---' ----{ Loads data to be sent into SDR. L..-_-.-_---' ----{ Outputs CK request signal to master system. I ~HITACHI 757 11.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 11.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ************************ 00003 * 00004 0080 ORG $80 00005 * 00006 0080 0001 SCIRDA RMB Received data 00007 0081 0001 SCISOI< RMB Existence of received data 00008 * 00009 **** SYMBOL DEFINITIONS ******************** 00010 * 00011 0002 PCDTR EQU $02 Port C data register 00012 0006 PCDDR EQU $06 Port C data direction register 00013 0010 SCR EQU $10 SCI contoroL register 00014 0011 SSR EQU $11 SCI status register 00015 0012 SDR EQU $12 SCI data register 00016 ************************************************ 00017 * * 00018 * MAIN PROGRAM : SCISMN * 00019 * * 00020 ************************************************ 00021 * 00022 1000 ORG $1000 00023 * 00024 1000 A6 10 SCISMN LDA !tUO 00025 1002 B7 02 STA PCDTR InitiaLize port C 00026 1004 B7 06 STA PCDDR SeLect port C bit 4 as output 00027 1006 4F CLR A InitiaLize SCISOI< 00028 1007 B7 81 STA SCISOI< 00029 1009 A6 FO LDA !t$FO InitiaLize SCR 00030 100B B7 10 STA SCR 00031 100D A6 18 LDA !t$18 InitiaLize SSR 00032 100F B7 11 STA SSR 00033 1011 B6 12 LDA SDR Dummy read of SDR 00034 1013 9A CLI EnabLe interrupt 00035 1014 01 81 FD SCISM1 BRCLR O.SCISOI<.SCISMl Test if received data 00036 1017 B6 80 LDA SCIRDA Load received data 00037 1019 11 81 BCLR O.SCISOK Crear received data fLag 00038 101B CD 103A JSR TPR Convert into Lowercase 00039 101E CD 1035 JSR SCISTD Output data to master 00040 1021 20 Fl BRA SCISM1 00041 ************************************************ 00042 * * 00d43 * NAME : SCISRD (SCI SLAVE RECEIVE) * 00044 * * 00045 ************************************************ 00046 ** ** 00047 ENTRY NOTHING 00048 * RETURNS SCIRDA (RECEIVED DATA) * 00049 * SCISOI< (SCISOK=l;TRUE. * 00050 * SCISOI<=O;FALSE) * 00051 * * 00052 ************************************************ 00053 1023 09 02 08 SCISRD BRCLR 4.PCDTR.SCSRD1 Test if Tx or Rx 00054 1026 B6 12 LDA SDR Store received data 00055 1028 B7 80 STA SCIRDA ~HITACHI 758 00056 102A 10 81 BSET O.SCISOI< Set received data fLag 00057 102C 20 02 BRA SCSRD2 Branch SCSRD2 00058 102E 18 02 SCSRD1 BSET 4.PCDTR Set CI<=l 00059 1030 A6 38 SCSRD2 LDA 1t$38 CLear interrupt request flag 00060 1032 B7 11 STA SSR 00061 1034 80 RTI 00062 ************************************************ 00063 * * 00064 * NAME : SCISTD (SCI SLAVE TRNSFER) * 00065 ************************************************** 00066 00067 * * 00068 * ENTRY ACCA (DATA TO BE SENT) * 00069 * RETURNS NOTHING * 00070 * * 00071 ************************************************ 00072 1035 B7 12 SCISTD STA SDR Store transfer data 00073 1037 19 02 BCLR 4.PCDTR Set CI(-pin=O 00074 1039 81 RTS 00075 ************************************************ 00076 * * 00077 * NAME : TPR (CONVERTING ASCII LOWERCASE * 00078 * INTO ASCII) * 00079 * * 00080 ************************************************ 00081 103A Al 61 TPR CMP It'a ACCA - 'a' ? 00082 103C 25 06 BCS TPR1 Branch if ACCA ( , a' 00083 103E Al 7A CMP It'z ACCA - , z' ? 00084 1040 22 02 BHI TPR1 Branch if ACCA > ' z' 00085 1042 A4 DF AND It$DF Convert Lowercase to Upper'case 00086 1044 81 TPR1 RTS 00087 ************************************************ 00088 * * 00089 * VECTOR ADDRESSES * 00090 * 00091 * ************************************************ 00092 * 00093 1FF6 ORG $lFF6 00094 * 00095 1FF6 1023 FDB SCISRD SCIITIMER2 00096 IFF8 1000 FOB SCISMN TIMERIINT2 00097 1FFA 1000 FDB SCISMN INT 00098 IFFC 1000 FDB SCISMN SWI 00099 IFFE 1000 FDB SCISMN RES 00100 END ~HITACHI 759 12. SCI CLOCK SYNCHRONOUS (INTERNAL CLOCK) 12.1 HARDWARE DESCRIPTION (1) Function (a) Transfers clock synchronous serial data to slave system, and receives data from slave. (b) Handshakes using transfer/receive control signal to transfer or receive data. (2) Microcomputer Applications (a) Transfers data to/from slave system using clock synchro- nous SCI. (b) Inputs CK request signal to bit 3 of port C from slave system. Outputs transfer rate clock to slave system considering input state and receives data. (c) Outputs transfer request signal from bit 4 of port C to inform data transfer to slave system. (3) Circuit Diagram MCU HD6305XO (HD6305YO) 2 RES 7NUM 1 VSS I I I IL _____ JI Fig. 1 Clock Synchronous SCI Circuit ~HITACHI 760 (4) Pin Functions Pin functions at the interface between the HD6305XO SCI pins and slave system are shown in Table 1. Table I Pin Functions Active Pin Name Input/ Level Pin Name Function (Slave Program (HD6305XO) Output (High Lavel or Low) system) CK Output Low Outputs transfer clock. Serial clock / ~ Serial Rx Input - Receives data. data output Tx C3 Output Input - Low Transfers data. Inputs transfer clock request from slave. Serial data input CK request L Outputs clock if low. signal PCDTR Informs transfer start Transfer C4 Output Low request to slave. signal (5) Hardware Operation SCI timing chart is shown in Fig. 2. Transfer , - - Loads data to be sent into SDR Transfer(C4) signal request~ L_______ ________________________________ ~ ~ r-- Tx I slave sends data Receive CK request (C3) CK Rx Receive data latch timing Fig. 2 SCI Timing Chart ~HITACHI 761 12.2 SOFTWARE DESCRIPTION (1) Program Module Configuration The program module configuration for serial communication with slave system is shown in Fig. 3. SCIMMN MAIN o PROGRAM SCIMTD ,.:;S~C:.:;I:.:MRD:="'-'-_-r-~ Fig. 3 Program Module Configuration (2) Program Module Functions Program module functions are summarized in Table ·2. Table 2 Program Module Functions No. Program Module Name Label Function Sends data to slave syStem and receive it 0 MAIN PROGRAM SCIMMN from slave system without change by using the HD630SXO SCI. SCI MASTER TRANSFER Sends serial data to slave system using 1 SCIMTD internal clock. 2 SCI MASTER RECEIVE Receives data from slave system using SCIMRD internal clock. ~HITACHI 762 (3) Program Module Sample Application (Main Program) The flowchart in Fig. 4 is an example of sending serial data to slave system and receiving it from slave system, performed by the program module in Fig. 3. Main Program ~==~====~ ----I Seta tran,'er reque,t aignal to High. -----[lnitializes SClMOK(RAM) l.-_......-_--J ____{lnitializes serial clock transfer rate and selects internal clock source . .---~;:;:;:;:r-....J Stores data in entry argument of ----{ program module SClMTD. =:::c:::::~ ____ {Calls program module SClMTD and ~~~;;~____~ transfer data to slave system. Calis program module SClMRD and { receives data from slave system. Bit Tests i f data is received from { slave system. (Bit C)=O if received data equals sent data. Fig. 4 Program Module Flowchart ~HITACHI 763 12.3 PROGRAM MODULE DESCRIPTION ::1 =MA=S=TE=R=T=RAN=S=F=E=R==I~I=M=C=U=/=MP=U=H~H=D=6=3=0=5X=0=/=Y=0~11L=A=B=E=L~I~IS=C=IMT==:1 =P=RO=G=RAM==M=O=D=U=L=E=NAME=:::::II;:=S=C=I I FUNCTION I Sends data in SCITDA(RAM) into slave system using internal clock. II SPECIFICATION I ARGUMENTS CHANGES IN CPU REGISTERS AND FLAGS Contents Storage Location Byte Lgth. • : Not affected x : Undefined ROM (Bytes) t : Result 48 RAM (Bytes) ACCA IX 2 Entry Data to be sent SCITDA (RAM) 1 I x I x I Stack (Bytes) 0 C Z No. of cycles Argu- mentsr----+--------r--------+-----; •N x I 50 Reentrant Re- x H • No Relocation turns • No Interrupt Yes DESCRIPTION (1) Function Details CD Entry argument { SCITDA (RAM) ('C'=$43) SCI data I , b7 ScrTDA bO b7 4 : SDR 3 I bO (a) Argument details I 4 : 3 I SCITDA(RAM): Holds data to be sent to slave system. (b) Program module SCIMTD execution loads entry argument content CZ> Output into SDR and sends it to slave system. (c) Program module SCIMTD calls Bit 0 Bit 7 neither program modules nor subroutines. Fig. 5 Example of SCIMTD Execution SPECIFICATIONS NOTES II ~HITACHI 764 PROGRAM MODULE NAME II SCI MASTER TRANSFER IB HD6305XO/YO 88 DESCRIPTION I (2) User Notes (a) Initializes SCR. (b) When using program module SCIMTD, resetting system (in case of power on reset, activating power) is performed master reset firstly, then reset slave system secondly. (c) Sets slave to receiving state before program module SCIMTD execution. (d) Program module SCIMTD loops until sending data is completed. (3) RAM Description Label RAM Description SCITDA Stores data to be sent. SCIMOK Indicates data. (4) Sample Application Calls program module SCIMTD after selecting I/O port, loading data to be sent and initializing SCR. I I LDA STA STA 11$10 PCDTR PCDDR }---- Sets bit 4 of port C to High. LDA STA II$E3 SCR }- --- Selects internal clock source. LDA STA 11$41 SClTDA }-- -- Loads data to be sent into entry argument. II JSR SCIMTD II Calls program module SCIMTD. (5) Basic Operation (a) When transfer request signal is output, CK request signal may output I from slave system with the same timing. Then, l2~s software timer is executed and CK request signal is tested after CK request signal is output. (b) Transfers received serial data if CK request signal is output. (c) Goes to the next step after SCI interrupt request flag is set and transfer/receive completes. (d) When serial data is received, retains transfer request in output state until main program processes received data so that next data can not be received. ~HITACHI 765 PROGRAM MODULE NAME .11 SCI MASTER TRANSFER II MCU/MPU 1 HD6305XO/YO I LABEL 1FCIMTDI ~==~==~==~====~~~ FLOWCHART __ {sendS transfer request signal to slave system. Executes l2lJs software timer. data to be sent. flag. __ {DUmmy-readS SDR and places SCI in receive possible state. --{ Tests SCI interrupt request flag. --{ Selects external SCI clock source. --{ Stores serial data in return argument. --{ Selects internal SCI clock source. --{ Sets flag indicating data receive. is received during --{ Releases transfer rE!que~t signal. --{ Clears flag indicating data receive. $HITACHI 766 I PROGRAM MODULE NAME II II MCU/MPU IIHD6305xo/yoJ LABEL IISCIMRDI SCI MASTER RECEIVE I ~========~====~==~==~~ I FUNCTION I (1) Outputs serial clock and receives data from slave system. (2) Permits outputting when slave system cannot output serial clock. I ARGUMENTS I I CHANGES IN CPU REGISTERS AND FLAGS I SPECIFICATIONS I Contents Storage Location Byte Lgth. • : Not affected x : Undefined ROM (Bytes) t : Result 36 RAM (Bytes) ACCA IX 0 Entry - - - I x I x I Stack (Bytes) 0 C Z No • of cycles Argu- ments • N x I 43 Reentrant Received ACCA 1 Re- data x H • No Relocation turns ExistenCE of received Bit C (CCR) 1 • No Interrupt data Yes DESCRIPTION (J) Input CK p~ In nnnnnnnr UUUUUUUU (1) Function Details (a) Argument details Rx :0] I I I I I rL ACCA: Contains data received o ~ • 1 Bit 7 I from slave. Bit 0 Bit C(CCR): Indicates existence of received data. Bit C b7 ACCA bO (]) Return { ACCA @] I 4 : 3 I Bit C = 1 : No data is received argument ('C'-$43) from slave system. Bit C = 0 : Data is received Fig. 6 Example of SCIMRD from slave system. Execution SPECIFICATIONS NOTES II ~HITACHI 767 PROGRAM MODULE NAME II SCI MASTER RECEIVE II MCU/MPU I HD6305XO/YO ILABEL I B DESCRIPTION I~==========~========~==~~ (b) Program module SCIMRD execution contains SDR contents in return argument ACCA. (c) Program module SCIMRD calls neither program modules nor subroutines. (2) User Notes (a) Initializes SCR. (b) When program module SCIMRD is executed, set bit 3 and bit 4 of data register port C to "1". (c) Goes to transfer possible state in slave system before program module SCIMRD execution. (d) Program module SCIMRD loops until receiving data from slave system is completed. (3) RAM Description RAM is not used by program module SCIMRD (4) Sample Application Calls progra~ module SCIMRD after selecting I/O port and initializing SCR. I I LDA 11$30 STA PCDTR }--- Sets bit 3 and bit 4 of port C to High. STA PCDDR LDA II$E3 } ---Selects internal clock source. STA SCR LOOP II JSR SCIMRD II ---Calls program module SCIMRD. BCS LOOP ---Tests receive completion. I I I (5) Basic Operation (a) Checks transfer request signal to test if data is received after outputting the signal. (b) Tests if CK request signal has been output from slave system. (c) If output, sets SCI interrupt request flag, and stores serial data in return argument after checking that serial data is received. ~HITACHI 768 PROGRAM MODULE NAME II SCI MASTER RECEIVE II MCU/MPU I HD6305XO/YO I LABEL IISCIM, FLOWCHART I~==========~==~====~==~~ _____{Tests if data has been received during program module SCIMTD execution. -----{ Releases transfer request signal. -----{ Stores serial data in return argument. -----[Tests CK request signal from slave system. Disables SCI interrupt and clears SCI { ----- interrupt request flag. Dummy-reads SDR and mades SCI receive ----- { possible state. -----{ Tests SCI interrupt request flag. -----{ Selects external SCI clock source. -----{Stores serial data in return argument. -----{ Selects internal SCI clock source. SCMRD3 O+Bit C ~~~----, '----r----J __ { Stor~s f~ag indicating serial data rece1ve 1n return argument. I ~HITACHI 769 12.4 SUBROUTINE DESCRIPTION This application example calls no subroutines. 12.5 PROGRAM LISTING 00001 ***** RAM ALLOCATION ************************ 00002 00003 * 00004 0080 ORG $80 00005 *SCIMO/( RMB 00006 0080 0001 1 Indicate of receiving data 00007 0081 0001 SCIRDA RMB 1 Received data 00008 0082 0001 SCITDA RMB 1 SCI output data 00009 * 00010 **** SYMBOL DEFINITIONS ******************** 00011 >I< 00012 0001 PCDTR EQU $01 Port C data register 00013 0006 PCDDR EQU $06 Port C data direction register 00014 0010 sen EQU $10 SCI controL register 00015 0011 SSR EQU $11 SCI status register 00016 0012 SDR EQU $12 SCI data register 00017 ********>1<*>1<*>1<>1<>1<***>1<**>1<>1<***************>1<***>1<***** 00018 00019 *>I< MAIN PROGRAM : SCIMMN * 00020 * 00021 * >1<*****************>1<*******>1<>1<*>1<******>1<*>1<********* * 00022 * 00023 1000 ORG $1000 00024 * 00025 1000 A6 10 SCIMMN LDA 1:1$10 InitiaLize port C 00026 1002 B7 01 STA PCDTR 00027 1004 B7 06 STA PCDDR SeLect port C bit 4 as output 00028 1006 4F CLR A InitiaLize SCIMOK 00029 1007 B7 80 STA SCIMOI< 00030 1009 A6 E3 LDA I:1$E3 InltlaL Ize SCR 00031 100B B7 10 STA SCR 00032 100D A6 41 SCMMN1 LDA 1:1$41 Store output data 00033 100F B7 82 STA SCITDA 00034 1011 CD 1043 JSR SCIMTD Output SCI data 00035 1014 CD 101F SCMMN2 JSR SCIMRD Receive SCI data 00036 1017 25 FB BCS SCMMN2 Loop untiL receive data 00037 1019 A3 41 CPX 1:1$41 Test if Tx data=Rx data? 00038 101B 26 Fa BNE SCMMN1 Branch if not equaL 00039 10lD 20 FE PEND BRA PEND End of program 00040 **>1<***********>1<******>1<***>1<*****>1<**************** 00041 00042 ** NAME: SCIMRD (SCI MASTER RECEIVE) ** 00043 0(')044 * ********>1<*******>1<******************************* * 00045 ** 00046 ** ENTRY NOTHING 00047 * RETURNS ACCA (RECEIVED DATA) * 00048 * CARRY (C=O;TRUE.C=l;FALSE) * 00049 * * 00050 ************************************************ 00051 101F 09 01 18 SCIMRD BRCLR 4.PCDTR.SCMRD1 Branch if Rx=O 00052 1022 06 01 1C BRSET 3.PCDTR.SCMRD4 Branch If CK=O 00053 1025 A6 38 LDA 1:1$38 InitiaLize SSR 00054 1027 B7 11 STA SSR 00055 1029 B6 12 LDA SDR Execute dummy read ~HITACHI 770 00056 102B OF 11 FD SCMRD2 BRCLR 7,SSR,SCMR02 Loop untiL received data 00057 102E A6 F3 LOA H$F3 SeLect SCI as event Input 00058 1030 B7 10 STA SCR 00059 1032 B6 12 LOA SOR Load received data 00060 1034 AE E3 LOX H$E3 SeLect SCI as no cLock Input 00061 1036 BF 10 STX SCR 00062 1038 20 04 BRA SCMRD3 00063 103A 18 01 SCMRD1 BSET 4, PCOTR Set Rx=1 00064 103C B6 81 LOA SCIROA Load SCI data 00065 103E 98 SCMRD3 CLC CLear bit C 00066 103F 20 01 BRA SCMRD5 00067 1041 99 SCMRD4 SEC Set bit C 00068 1042 81 SCMRD5 RTS 00069 ************************************************ 00070 00071 ** NAME: SCIMTO (SCI MASTER TRANSFER) ** 00072 * * 00073 ************************************************ 00074 ** 00075 ENTRY : SCITOA (TRANSFER DATA) ** 00076 * RETURNS: NOTHING * 00077 * * 00078 ************************************************ 00079 1043 19 01 SCIMTD BCLR 4,PCOTR Set request Low 00080 1045 AE 02 LOX "2 Execute software timer 00081 1047 SA SCMT01 DEC X 00082 1048 26 FD BNE SCMTD1 00083 104A A6 38 LOA "$38 Mask SCI Interrupt 00084 104C B7 11 STA SSR 00085 104E 07 01 OF BRCLR 3,PCOTR,SCMTD2 Branch If CK=O 00086 1051 B6 82 LOA SCITOA Store transfer data 00087 1053 B7 12 STA SOR 00088 1055 OF 11 FD SCMTD4 BRCLR 7,SSR,SCMTD4 Loop untiL received data 00089 1058 00 80 02 BRSET O,SCIMOK,SCMTDS Set Tx=O 00090 1058 18 01 BSET 4,PCOTR Set request hl9h 00091 1050 11 80 SCMTD5 BCLR O,SCIMOK CLear SCI recelvln9 fLa9 00092 105F 81 RTS 00093 1060 BE 12 SCMTD2 LOX SDR Execute dummy read 00094 1062 OF 11 FD SCMTD3 BRCLR 7,SSR,SCMTD3 Loop untiL received data 00095 1065 A6 F3 LOA "$F3 SeLect SCI as event Input 00096 1067 B7 10 STA SCR 00097 1069 B6 12 LOA SOR Load transfer data 00098 106B B7 81 STA SCIROA 00099 1060 A6 E3 LOA "$E3 SeLect SCI as no cLock Input 00100 106F B7 10 STA SCR 00101 1071 10 80 BSET O,SCIMOK Set SCI recelvln9 fLa9 00102 1073 20 02 BRA SCMTD1 00103 00104 01)105 00106 00107 00108 00109 IFF6 ************************************************ * * * VECTOR ADDRESSES ************************************************ * ORG $lFF6 * * * I 00110 00111 1FF6 1000 * FOB SCIMMN SCIITIMER2 00112 1FF8 1000 FOB SCIMMN TIMER/INT2 00113 IFFA 1000 FOB SCIMMN INT 00114 IFFC 1000 FOB SCIMMN SWI 00115 IFFE 1000 FOB SCIMMN RES 00116 END ~HITACHI 771 13. LIQUID CRYSTAL DRIVER (HD6ll00A) CONTROL 13.1 HARDWARE DESCRIPTION (1) Func t ion (a) Controls LCD driver HD6ll00Ausing the HD630SXO to display numerals (from 0 to 9) on LCD. (b) Liquid crystal displays with 8 segment x 10 digits using dynamic drive. (c) Transfers 10 digits segment data from the HD630SXO to HD61100A. (2) Microcomputer Applications (a) Port C controls HD6ll00Acontrol signals (M and CLl) and common signal of liquid crystal, and displays numerals on liquid crystal. (b) Controls HD6ll00A control signals (CL2 and DL) by using clocked synchronizing SCI within the HD630SXO and transfers display data to HD6ll00A. (3) Circuit Diagram MCU HD630SXO +5V (HD630SYO) ~ VCC ~4 INT +SV STBY ErF~ 4f1Hz$ 6 XTAL 3215$.s[4~ 33~9b44Bl VlL VlR V4L V4R V2L V2R V3L V3R 22pF 2 ---=- RES EXTAL § VEE GND 46 VCC - COMMON Liquid crystal ~~ ESHL 2. 211F= = 7 80 -\ I-I rl nnll II n I-I 111-1 HD61100A Yl NUM 1" I ...-=. VSS 7i~ 25 C7/ Tx 7;"- FCS Y80 -I I II II-lUI 1111 'I II II I 8-segment x 10-digit 27 CS/CK M CLI CL2 DL 28 C4 44 37 40 41 29 r~i jHD74 IHCO L Fig. 1 HD6ll00A Control ~HITACHI 772 (4) Pin Functions Pin functions at the interface between the HD630SXO and HD6ll00A are shown in Table 1. Table 1 Pin Functions Active Pin Name Input/ Level Pin Name Program (HD630SXO) Output (High Function (HD61100A) Label or Low) Alternate signal of LCD C3 Output - driving output. M PCDTR Outputs LCD driving signal C4 Output - at the falling edge. CLl ~ Triggers display data at CK Output - the falling edge. CL2 TX Output - Inputs display data. DL ~ (S) Hardware Operation Control signals (M, CL1, CL2, DL) of HD6ll00A and LCD common signal are controlled by the HD630SXO clocked synchronizing SCI and port. The timing chart of each signal is shown in Fig. 2. Pin name on HD6ll00A COMM:-lL_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ........I1 I/O port M~ ------------'L control CL1.-n'--_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ~ Clock synchronous SCI control __________ JUULM I DL 80 bits output (10 digits) Fig. 2 HD6305XO ~ HD6ll00A and LCD Interface ~HITACHI 773 13.2 SOFTWARE DESCRIPTION (1) Program Module Configuration The program module configuration for character display on the liquid crystal module is shown in Fig. 3. Fig. 3 Program Module Configuration (2) Program Module Functions Program module functions are summarized in Table 2. Table 2 Program Module Functions No. Program Module Name Label Function 0 MAIN PROGRAM H61MN Displays 8 segment x 10 digits LCD. Transfers display data to HD6ll00A and 1 DISPLAY CHARACTER H61DSP displays on LCD. Stores display data in display RAM. TRANSFER CHARACTER See subroutine MOVE in HD630S FAMILY APPLI- 2 MOVE DATA CATION NOTES (SOFTWARE) for details. ~HITACHI 774 (3) Program Module Sample Application (Main Program) The Flow chart in Fig. 4 is an example of character display on liquid crystal performed by the program module in Fig. 3. The main program in Fig. 4 demonstrates the display on liquid crystal as shown in Fig. 5. Main Program _____{Sets signals CLI' M and COMMON to Low, Low and High respectiuely. :==::r==~ _____{Selects bits 2, 3 and 4 of port C as output ports. _____{Selects SCI to transfer clock output and defines transfer clock width. :::=::::r=::~ -----{Enables SCI interrupt. :==:::c:==; :==::r==::: ----- Initializes pointer for display data { RAM and counter (CNTR(RAM» indicating number of interrupts. -----{ Sets signal CLI to High. ~:::r=::=: -----{~~~~ and Low, respectively. signals CLI, M and Common to Low, :==:::r=::::::: _____{Stores display data in SDR and starts ~=::r====~ transfer. -----{ Enables interrupt. ~:::r=::=: ~=::r==~ -----{ D.fin." "o"m add, ••• of di.play da1<************************** 00082 ** ** 00083 NAME : MOVE (MOVING MEMORY BLOCKS) 00084 * * 00085 ***************************>1<********************** 00086 *>I< *>I< 00087 ENTRY : SOA (SOURCE ADDR) 00088 * DEA (DESTINATION ADDR) 00089 MCNT (TRANSFER COUNTER) *>I< 00090 * RETURNS : NOTHING 00091 *>I< * 00092 ************************************************** * 00093 1052 A6 D6 MOVE LDA H$D6 Load InstructIon code (LOA Dlsp.X) 00094 1054 B7 8F STA MSUB 00095 1056 B6 8B LDA SOA Load source ADDR (H) 00096 1058 B7 90 STA MSUB+l 00097 10SA B6 BC LDA SOA+l Load source ADDR CL) 00098 105C B7 91 STA MSUB+2 00099 lOSE A6 81 LDA H$8l Load instruction code CRTS) 00100 1060 B7 92 STA MSUB+3 00101 1062 3F 93 CLR SPNT CLear reLative data of source ADDR 00102 1064 BE 93 MOVE1 LDX SPNT Load reLatIve data of source ADDR 00103 1066 BD 8F JSR MSUB Load transfer data 00104 1068 BE 8D LOX DEA Load destination ADDR 00105 106A F7 STA O.X Store transfer data 00106 106B 3C 8D INC DEA Increment destihatlon ADDR 00107 106D 3C 93 INC SPNT Increment reLative data of source ADDR 00108 106F 3A 8E DEC MCNT Decrement transfer counter 00109 1071 26 Fl BNE MOVEl Branch untiL transfer counter =0 "0110 1073 81 RTS ~HITACHI 782 00111 ************************************************* 00112 * * 00113 * DATA TABLE * 00114 * * 00115 ************************************************* 00116 * 00117 1100 ORG $1100 00118 * 00119 1100 14 FCB $14.$B3.$B6.$D4.$E6 *Se9ment data 00120 1105 E7 FCB $E7.$74.$F7.$F6.$77 00121 ************************************************** 00122 * * 00123 * VECTOR ADDRESSES * 00124 * * 00125 ************************************************** 00126 * 00127 1FF6 ORG $lFF6 00128 * 00129 1FF6 1034 FOB H61DSP SCI/TIMER2 00130 1FF8 1000 FOB H61MN TIMER/INT2 00131 1FFA 1000 FOB H61MN INT 00132 1FFC 1000 FOB H61MN SWI 00133 1FFE 1000 FOB H61MN RES 00134 * 00135 END I ~HITACHI 783 ~4.:;-.;-::-E_X-::T:-:-E-::RN=A:-:-L-:----E_X-:P-:A-:N_S_I-:-ON=_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ....~ 14.1 HARDWARE DESCRIPTION (1) Function (a) Controls externally expanded memory and peripheral LSls using HD6305YZ. (b) Performs asynchronous serial interface with a console typewriter using the HD6350 (hereinafter, ACIA). (c) Controls liquid crystal module (hereinafter, HZ57l) through the HD63Zl (hereinafter, PIA) and displays inputs from a console typewriter in character mode. (2) Microcomputer Applications Interfaces with externally expanded LSls through address buses, data buses and control signals (R/W, E) using the HD6305YZ externally expanded functions. (3) Circuit Diagram +5V +5V 18 • 20 21 r/os i~ r/01 15 HD74HC04 1/05 14 1/05 13 l/o~ 11 152076 ~~~~ 10 r/ol 9 H2571 ~ Von 1 ~~s 7 ORo 8 OBI 9 DB2 10 DB3 11 DB .. 12 DBs i4 DB s OB, 6, 5 R/W 4" Console typewriter r-----' H075188 r - - - - - ( ] Jo-----i-:.RxDATA! ~~~--~I.mrs 1 I I I I ----=.,=5=18-:JglHoO CTs IL _____ TxDATA .J !I Fig. 1 External Expansion Circuit ~HITACHI 784 (4) Memory Map (a) Memories or peripheral LSIs are allocated in external memory space using address decoder (HD74HC138). ADR12 and ADR13 are connected to the HD74HC138 A and B pins. 16k byte memory space (from $0140 to $3FFF) are divided into 4 (4k bytes) and allocated. Table 1 shows system address decode. Table 1 System Address Decode HD74HC138 Input Out ut C B A Address Allocation Gl G2A G2B ADR .. ADR,. Yo Yl Yz - Y3 H L L L L L L H H H $0000 - $OFFF RAM H L L L L H H L H H $1000 - $lFFF ROM H L L L H L H H L H $2000 - $2FFF PIA H L L L H H H H H L $3000 - $3FFF ACIA (b) Fig. 2 shows system memory map $0000 I/O PORTS I $003F TIMER SCI $0040 HD630SY2 internal regist er and RAM memory space \ $OOFF (192 Byte) $0100 RAM S (64 Byte) $013F $0140 RAM ~ (HM6117) $07CF Not Used $1000 ) ROM (HM27C64) DDRA/PIRA $2000 I $lFFF CRA $2001 $2000 DDRII PlRlI $2002 CRB $2003 } PIA (HD6321) Not Used $2FFF $2FFF $3000 ACIA CTRL/STS $3000 } $3FFF (HD63S0) TDR/RDR $3001 ~ Not Used $3FFF Fig. 2 System Memory Map ~HITACHI 785 (5) Hardware Operation Fig. 3 shows timing charts of the HD6305Y2 and memories (HN27C64, HM6ll7). E ---'1 I 1 HD6305Y2 ADDRESS J J. R/W ~decoder delay time tAD CE - tCE HN27C64 OE 1 lt~ tACC ~tOE- I--t osR- t-tHR" DATA (OUT) ~decoder delay time I-'-' E2 Data{CEl,C read t t COl ,2 ~tHR_ tOSR M DATA t-- HM6117 (OUT) tAS twp WE II :~~e { tDW tOH DATA (IN) I-- tAD: Address delay time HD6305YZ tDSR: Data set-up time tHR: Data hold time tDW: Data delay time tCE: CE Output delay time HN27C64 tOE: OE Output delay time tACC: Access time tOH: Data output hold time tAA: Address access time tCOl,2: CElt CEZ Output delay time HM6117 tAS: Address set-up time twp: Write pulse width tDW: Input data set time tDH: Input data hold time Fig. 3 HD6305YZ/Memories Interface ~HITACHI 786 14.2 SOFTWARE DESCRIPTION (1) Program Module Configuration The program module configuration to display data input from a console typewriter on liquid crystal display system in Fig. 1 is shown in Fig. 4. TPR CONVERT CHARACTERS DATA DATA INTO ASCII Fig. 4 Program Module Configuration (2) Program Module Functions Program module functions are summarized in Table 2. Table 2 Program Module Functions Program Module No. Label Function Name Displays data input from console 0 MAIN PROGRAM EXPMN typewriter on console typewriter and liquid crystal display. INITIALIZE 1 EXPINT Initializes LCD-II. LCD-II DISPLAY Displays characters on liquid 2 EXPDSP CHARACTERS crysta1. 3 4 SEND DATA RECEIVE DATA EXPOUT EXPINP Sends data to console typewriter. Receives data from the console typewriter. Converts ASCII lowercase into ASCII I 5 CONVERT TPR uppercase. See subroutine TPR in INTO ASCII HD6305 SERIES APPLICATION NOTES (SOFTWARE) for details. ~HITACHI 787 (3) Program Module Sample Application (Main Program) The flowchart in Fig. 5 is an example of displaying data input from console typewriter on liquid crystal display and console typewriter, performed by the program module in Fig. 4. Main Program -----{ Enables INT2 interrupt. Specifies data direction register A -----{ (hereinaf ter, DDRA). ______[ Selects peripheral interface register A (hereinafter, PIRA) as output. -----{ Specifies PIRA. -----{ Outputs signals RS~O, R/W~l and E=O. _____ { Specifies data direction register B (hereinafter, DDRB). Selects peripheral interface register B { ----- (hereinafter, PIRB) as output. -----{ Specifies PIRB. -----{ Initializes FUNC(RAM). -----{ Initializes ENTRY(RAM). _____ { Calls program module EXPINT to initialize LCD-II. -----{ Initializes instruction ($OE). Calls subroutine EXPBSY to check busy ----- { flag. _____ { Calls subroutine EXPINS to set instruction in H257l. -----{ Master-reset ACIA. Initializes ACIA (1 start bit + 8-bit -----{ data + 1 stop bit, 1/16, RTS=O, TIE=O, RIE=l) . -----{ Enables interrupt. Fig. 5 Program Module Flowchart ~HITACHI 788 Tests if key data receive flag is set. Stores KEYDAT(RAM) in entry argument ACCA. Calls subroutine TPR to convert ASCII lowercase in ACCA into ASCII uppercase. See subroutine TPR in HD630S SERIES APPLICATION NOTES (SOFTWARE) for details. '--_....,.._ _..J -----r Clears key data receive flag. L---,------J ----{ RTS = O. ~----{ Stores ASCII uppercase in entry arguments OUTDAT(RAM) and DSPDAT(RAM). ~-----{ display data to console typewriter. Calls program module EXPOUT to send ~-----{ characters on liquid crystal display. Calls program module EXPDSP to exhibit INT2 Interrupt Routine Calls program module EXPINP to receive ~-----{ data from console typewriter and stores it in key data buffer. Fig. 5 (Cont.) Program Module Flowchart I ~HITACHI 789 14.3 PROGRAM MODULE DESCRIPTION I PROGRAM MODULE NAME II INITIALIZE LCD-II II MCU/MPU II HD6305Y2 II LABEL I ExpINTI I FUNCTION I Initializes LCD-II contained in H2571. I ARGUMENTS I I CHANGES IN CPU REGISTERS AND FLAGS II SJ'ECIFICATIONS I Contents Storage Location Byte Lgth. •x : Undefined : Not affected ROM (Bytes) Function t : Result 138 initiali FUNC RAM (Bytes) zation (RAM) 1 ACCA IX data($30) 5 Entry Entry mode ENTRY 1 I x I x I Stack (Bytes) initiali- (RAM) 2 zation C Z data($06) No. of cycles Argu- x x 54435 ments N I Reentrant Re- - - - x H • No Relocation turns • No Interrupt Yes I DESCRIPTION I (1) Function Details (a) Argument details FUNC(RAM) : Holds function initialization data ($30). ENTRY (RAM) : Holds entry mode initialization data ($06). (b) Program module EXPINT initializes LCD-II with instructions as follows; Display: Clear, Interface data length: 8 bits, Display line: I, Character font: 5 x 7 dots, Duty ratio: 1/8, DDRAM address: Increment, Display shift: No. I SPECIFICATIONS NOTES I "No. of cycles" in "SPECIFICATIONS" represents the number of cycles required when subroutine EXPBSY is executed at the minimum cycles. ~HITACHI 790 PROGRAM MODULE NAME II INITIALIZE LCD-II II MCU/MPU II HD6305Y2 II LABEL IEXPIN~ DESCRIPTION I~==========~============~~ (c) Program module EXPINT calls other program modules or subroutines shown in Table 3. Table 3 Program Modules and Subroutines called in EXPINT Program module/subroutine Label Functions CHECK BUSY FLAG EXPBSY Checks LCD-II busy flag. INSTRUCTION SET EXPINS Sets instructions in LCD-II. (2) User Notes Program module EXPINT cannot be called without initializing PIA. (3) RAM Description Label RAM Description b7 bO TNCNT } Stores counter for initializing LCD-II. CUNTl } Stores counter for initializing LCD-II. INSDAT } Stores instruction data. FUNC } Stores function initialization data ($30). ENTRY } Stores entry mode initialization data ($06). ~HITACHI 791 PROGRAM MODULE NAME II INITIALIZE LCD-II II MCU/MPU II HD6305Y2 II LABEL IrXPINTI DESCRIPTION I~==========~==~====~==~~ (4) Sample Application After initializing PIA and holding entry arguments, call program module EXPINT. I I I I LDA 11$00 STA CRA LDA II$FF STA DDRA LDA 11$04 STA CRA LDA #$02 ---- Initializes PIA. STA PIRA LDA #$00 STA CRB LDA II$FF STA DDRB LDA 11$04 STA CRB LDA 11$30 STA FUNC }---- Stores data in entry arguments FUNC(RAM) and ENTRY(RAM). LDA #$06 STA ENTRY ..I I_J_S_R____E_X_P_IN_T-LJII---- Calls program module EXPINT. ~HITACHI 792 PROGRAM MODULE NAME II INITIALIZE LCD-II II MCU/MPU II HD6305Y2 II LABEL I ExpINTI DESCRIPTION I~==========~==~====~==~~ (5) Basic Operation (a) Control of PIA is shown in Fig. 6 and Fig. 7. In Fig. 6, data ($80) is output from port A; in Fig. 7, data ($80) is input to port A. Note that this controlling method is applied to the system in Fig. 1, and memory map in Fig. 2. Stores "0" in bit 2 of control register '----T------I------{ (hereinafter, CRA) to select DDRA. CRA is allocated at $2001, so RS1=0, RSO=l. '----T------I ------{ output. Stores $FF in DDRA to select port A as ~~------{ Sets bit 2 of CRA to "1" to select PIRA. '----T------I ------{ Outputs $80 from port A by writing $80 into PIRA. Fig. 6 Control of PIA (Port A: Output Port) '----T------I------{ CRA Sets bit 2 of CRA to "0" to select DDRA. is allocated at $2001, so RS1=0, RSO=l. '----T------I ------{ Stores input. $00 in DDRA to select port A as '----T------I------{ Sets bit 2 of CRA to "1" to select PIRA. Moves input data from PIRA to ACCA. Fig. 7 Control of PIA (Port A: Input Port) ~HITACHI 793 PROGRAM MODULE NAME II INITIALIZE LCD-II II MCU/MPU II HD6305Y2 II LABEL IrXPINTI DESCRIPTION I~==========~==~====~==~~ (b) Function initialization data ($30) must be written 3 times into LCD-II as shown below to ensure LCD-II internal RESET. Afterwards, LCD-II busy flag can be checked to select functions. Reset LCD-II I Wait 15ms or more after reset. I Transfer $30 I Wait 4.1ms or more I Transfer $30 I Wait 100)1SI or more I L Transfer $30 I • (c) Data in Table 4 is transferred to LCD-II. Table 4 LCD-II Initialization Data Data Function $30 Sets interface length to 8 bits. $08 Turns off all display. $01 Clears all display. Sets DDRAM address to $00 $06 Specifies cursor direction right. Does no"£" shift display. ~HITACHI 794 PROGRAM MODULE NAME INITIALIZE LCD-II II MCU/MPU II HD6305Y2 II LABEL I~XPIN~ FLOWCHART -----{ Initializes loop counter. -----~ Initializes counter for software timer. Executes 30ms software timer. (CUNTl) -1-+ CUNTl Stores function initialization data in entry argument. Calls subroutine EXPINS to write instructions in LCD-II. (TNCNT) -1-+ ______ { Decrements loop counter. TNCNT (TNCNT) ,,0 ------{ Tests if LCD-II reset is completed. ~HITACHI 795 PROGRAM MODULE NAME II INITIALIZE LCD-II II MCU/MPU II HD630SY2 II I LABEL ExpINTI FLOWCHART I~==========~========~==~~ Stores function initialization data. (FUNC) .... INSDAT ---------{ (Interface length: 8 bits, Display line: 1, Character font: SX7 dots, Duty ratio: 1/8) ---------{ Calls subroutine EXPBSY to check busy flag. ----------{ Calls subroutine EXPINS to write instruction in LCD-II. Stores instruction data (display ON/OFF ---------{ control) in entry argument INSDAT(RAM). (display OFF, no cursor display, no blink) ----------{ Calls subroutine EXPBSY to check busy flag. ---------- { Calls subroutine EXPINS to write instruction in LCD-II. Stores instruction data (display clear) ----------{ in entry argument INSDAT(RAM). ----------{ Calls subroutine EXPBSY to check busy flag. ----------{ Calls subroutine EXPINS to send instruction to LCD-II. Stores instruction data (entry mode) in { entry argument INSDAT(RAM). --------- (DDRAM address increments, moves cursor right and display does not shift) ----------[ Calls subroutine EXPBSY to check busy flag. _________ { Calls subroutine EXPINS to send instruction to LCD-II. ~HITACHI 796 PROGRAM MODULE NAME II DISPLAY CHARACTERS II MCU/MPU II HD6305Y2 II LABEL IEXPDSpl I FUNCTION I Outputs display data to LCD-II and displays it on liquid crystal display. I ARGUMENTS I I CHANGES IN CPU REGISTERS AND FLAGS II SPECIFICATIONS I Contents Storage Location Byte Lgth. • x : : Not affected Undefined ROM (Bytes) t : Result 80 RAM (Bytes) ACCA IX 1 Entry Display data DSPDAT (RAM) 1 I x I • I Stack (Bytes) 2 C Z No. of cycles Argu- x x 113 ments N I Reentrant Re- - - - x H • No Relocation turns • No Interrupt Yes I DESCRIPTION I 'z' 00216 1114 A4 DF AND ~$DF Convert lowercase into 00217 1116 B7 84 STA KEYDAT Uppercese 00218 1118 81 TPR1 RTS 00219 ************************************************ 00220 * * ~HITACHI 814 00221 * NAME : EXPINP (RECEIVE DATA) * 00222 * * 00223 ************************************************ 00224 * * 00225 * ENTRY NOTHING * 00226 * RETURNS : KEYDAT (RECEIVE DATA) * 00227 * KEYORF (RECEIVE FLAG) * 00228 * * 00229 ************************************************ 00230 1119 A6 01 EXPINP LDA 1=1$01 Test if RDRF of ACIA=1 00231 1118 C4 3000 AND SR 00232 111E 27 13 8EQ EXPIP1 Loop if RDRF=O 00233 1120 A6 05 LOA *'1$05 Set RTS of ACIA=1 00234 1122 C7 3000 STA SR 00235 1125 C6 3001 LOA RDR Read received data 00236 1128 B7 84 STA I Execute STOP t Oscillation stabilization Restart instruction '""" i time instruction ~~ nterrupt Stop mode J '.! execution ------""'I:toP m O d e · ! - I - - - - - - - - - - - - - - SW input (INT) Restart by INT interrupt Fig. 3 Timing Chart in Stop Mode ~HITACHI 818 iii) Wait Mode Timing chart in Wait Mode is shown in Fig. 4. 55 Wait mode - - - - - - - l SW input T1 T2 Tl T2 T1 T2 T2 Tl Tl: Wait mode Wait mode----------~~~~~--~~.-~~~ T2: Program execution Program execution----~ High: Execution Low : Wait mode Wait instruction-----L--4---L----~-L---4_~~»fl--~-L-~~----------­ execution timing Timer interrupt j~ timing Fig. 4 Timing Chart in Wait Mode (b) HA1835P Control Timing chart of pulse output and reset pin for watchdog timer is shown in Fig. 5. System burst I- CLK -_rulJUll... --.H--+-J Watchdog Error _________--,...._ _ _---'r---s, Output Switch Automatic reset signal L ) I Fig. 5 Timing Chart of Pulse Output ~HITACHI 819 15.2 SOFTWARE DESCRIPTION (1) Program Module Configuration Program module configuration for switch board controlling HA1835P and low power dissipation mode is shown in Fig. 6. LWPMN o MAIN PROGRAM LWPMOD LWPWCH LOW POWER CONTROL DISSIPATION HA1835P Fig. 6 Program Module Configuration (2) Program Module Functions Program module functions are summarized in Table 2. Table 2 Program Module Functions No. Program Module Name Label Function Demonstrates low power dissipation and 0 MAIN PROGRAM LWPMN HA1835P control. LOW POWER Tests operation of low power dissipation 1 LWPMOD DISSIPATION mode. 2 CONTROL HA1835P Tests operation of watchdog timer LWPWCH using HA1835P. ~HITACHI 820 (3) Program Module Sample Application (Main Program) The flowchart in Fig. 7 is an example of low power dissipation and HA1835P control performed by the program module in Fig. 6. Main Program ___ [Turns off all LEDs indicating low power dissipation mode. ---{ Initializes LED counter. ---{ Initialize TDR. - - { Turns off LED. ---{ Initializes work area for LED. ---{ Initializes 32ms counter. Turns off LEDs indicating watchdog timer ~est and reset modes. ---{ Tests operation of low power dissipation mode. III ___{ Tests operation of watchdog timer using HA1835P. Fig. 7 Program Module Flowchart ~HITACHI 821 15.3 PROGRAM MODULE DESCRIPTION I PROGRAM MODULE NAME II LOW POWER DISSIPATION II MCU/MPU IlHD6305xo/yoJ ILABEL I ~WPMO~ I FUNCTION 1/ Tests operation of low power dissipation mode. I ARGUMENTS IJ CHANGES IN CPU REGISTERS AND FLAGS II SPECIFICATIONS I Contents Storage Location Byte Lgth. • Not : x : affected Undefined ROM (Bytes) t : Result 67 RAM (Bytes) ACCA IX 4 Entry - - - I x I • I Stack (Bytes) 0 C Z No. of cycles Argu- x x 92 ments N I Reentrant x x No Re- H Relocation turns - - - • No Interrupt Yes I DESCRIPTION I (1) Function De tails (a) Program module LWPMOD has no arguments. (b) Executes standby mode, stop mode, and wait mode with switch. Lights corresponding LED for each mode; LED turns off after reset. (2) User Notes (a) Executes only one mode at a time. (b) Selects only one mode switch. I SPECIFICATIONS NOTES II "No. of cycles"in "SPECIFICATION" represents the number of cycles required when data is not stored in SBRAM(RAM) and each mode is executed once. ~HITACHI 822 PROGRAM MODULE NAME II LOW POWER DISSIPATION I~ HD6305XO/YO B B DESCRIPTION I (c) Initializes timer. (d) Selects DDRs of bit 0-2 of port C as output. (3) RAM Description Label RAM Des cription b7 bO CNTRD Stores 32ms counter. CNTRI Stores Is counter. Upper Stores decision data to check reset data from SBRAM r- Lower - STANDBY mode. (4) Sample Application Calls program module LWPMOD after selecting I/O port and clearing RAM. I LDA 11$07 STA PCDTR } - - - Turns of f all LEDs indi ca ting modes. STA PCDDR CLR CNTRD ---Clears 32ms counter. CLR CNTRI - -- Clears Is counter. II JSR I I LWPMOD II ---Call program module LWPMOD. I (5) Basic Operation (a) Enters STANDBY mode by setting signal STBY to Low, returns with STBY to High. Software checks whether operation starts after activating on power or returns from STANDBY mode. When operation returns from STANDBY mode, turns.on LED. if not, stores comparison data in SBRAM(RAM). (b) Enters STOP mode by setting signal INT to High, returns with INT to Low. I When setting signal INT to High, LED indicates STOP mode and executes stop instruction. When Low, returns from STOP and turns LED off. (c) Enters WAIT mode by setting WAIT mode switch to High, returns with Low. Returns at every timer interrupt and executes interrupt routine. When WAIT mode switch is Low, enters WAIT mode after interrupt. Whether or not operation is returned at every timer interruption can be confirmed by LED counter incremented after return. When setting WAIT mode switch to High, turns on LED indicating WAIT mode and executes WAIT instruction. When Low, returns from WAIT mode and turns off LED indicat- ing WAIT mode. ~HITACHI 823 PROGRAM MODULE NAME POWER DISSIPATION II MCU/MPU I HD6305XO/YO ILABEL IILWPM09 FLOWCHART Tests whether operation starts after activating power or returns from STANDBY mode according to contents of RAM. on LED indicating STANDBY mode. Stores comparison data to test if --- { returns is caused by STANDBY mode. - LWPMDI o + Bit I ---{ Enables interrupt. ___{Tests whether operation enters STOP mode with signal INT. (INT)=O ----[ Turns ON LED indicating STOP mode. ___{Disables interrupt considering release of STOP mode. ---{ Enters STOP mode. ---{ Enables interrupt. ---{ Turns off LED indicating STOP mode. 1 ~HITACHI 824 PROGRAM MODULE NAME II LOW POWER DISSIPATION I~ HD6305XO/YO B B FLOWCHART ___ {Tests whether operation enters WAIT mode. (0 ,PADTR) =0 ---1[ Turns on LED indicating WAIT mode. ----[ Enters WAIT mode. ---~Turns off LED indicating WAIT mode. ___{stores counter data indicating r----'----, LED in port B and lights LED. '--_-.-_---.J I $ HITACHI 825 I PROGRAM MODULE NAME II CONTROL HA1835P II MCU/MPU II I IfWPWC~ HD6305XO/YOJ LABEL I FUNCTION II Tes ts watchdog timer operation using HA1835P. I ARGUMENTS 1/ CHANGES IN CPU REGISTERS AND FLAGS 11 SPECIFICATIONS I Contents Storage Location Byte Lgth. • Undefined Not affected : x : ROM (Bytes) t : Result 44 RAM (Bytes~ ACCA IX Entry - - - I x I • I 2 Stack (Bytes) 0 C Z No. of cycles Argu- x x 58 ments N I Reentrant - x • No Re- turns - - H Relocation • No Interrupt No I DESCRIPTION I (1) Function Details (a) Program module LWPWCH has no arguments. (b) Controls HA1835P using switch. (2) User Notes (a) Selects DDRs of bits 2, 3 and 4 of port A and ports Band C as output. (b) Selects DDRs of bits o and 1 of port A as input. I SPECIFICATIONS NOTES II "No. of cycles" in "SPECIFICATIONS" represents the number of cycles required when data is not stored in ERRAM(RAM) and an pulse generation is selected by switch. ~HITACHI 826 PROGRAM MODULE NAME II CONTROL HA1835P II MCU/MPU I HD6305XO/YO I LABEL IILwpWC~ DESCRIPTION I~==========~==~====~==~~ (3) RAM description Label RAM Description b7 bO ERRAM Stores check data .which tests whether operation starts after activating power or returns from watchdog timer error. (4) Sample Application Calls program module LWPWCH after selecting I/O port and clearing RAM. I BSET 4, PADTR Turns off LED indicating watchdog timer test mode. BSET 3, PADTR Turns off LED indicating watchdog timer reset. II JSR I LWPWCH II Calls program module LWPWCH I I (5) Basic Operation (a) Lights LED indicating watchdog timer mode, after main switch is activated. (b) When watchdog error switch is turned off, outputs pulse by 1ms software timer. When turned on, stops pulse output and enter eternity loop. (c) When turning off watchdog timer error switch. re-calls program after reset. If data in ERRAM(RAM) and decision data are the same. turns on LED indicating reset by watchdog timer error. (d) Stores check data if it is not stored in ERRAM(RAM). I ~HITACHI 827 PROGRAM MODULE NAME II CONTROL HAl835P II MCU/MPU I HD6305XO/YO I LABEL IILwpWC~ ~========~==~====~====~ FLOWCHART _____{Lights LED indicating watchdog timer mode after activating main power. (ERRAM);'$55 Tests reset is performed by main switch activation or by watchdog timer according to contents of RAM. reset after _____{Turns off LED indicating watchdog timer mode. LWPWHl _____{stores comparison data in RAM to test, resetting from watchdog timer error. Tests whether watchdog timer error -----{ switch is on. If ON, output pulse cannot be performed. ~HITACHI 828 I PROGRAM MODULE NAME II CONTROL HA183SP II MCU/MPU I HD630SXO/YO ILABEL IfWPWC~ FLOWCHART I~========~~========~==~~ --- Executes lms software timer. Outputs High and Low into HA183SP by lms intervals. LWPWHS I ~HITACHI 829 15.4 SUBROUTINE DESCRIPTION :==S=U=BR=O=UT=I=NE=N=AME==~I ==I=NC=REME==NT==C=OUN=T=E=R=~"=MC=U=I=MP=U=-I!:H=D=6=30=5=x=o=/y=o~1=LAB=E=L=I~f=WP=CN=!TI ::1 FUNCTION I Decrements LED counter CNTRI(RAM). BASIC OPERATION (1) This subroutine is called for e~ch 32ms timer interrupt. (2) Uses two counters to count up each second. (3) When incrementing one counter every timer interrupt, one second interval is obtained after 30 times incrementing. FLOWCHART PROGRAM MODULE USING THIS SUBROUTINE ~---r----~ ----~Clears interrupt request bit. ~---r~~~ ----~Increments 32ms counter. (CNTRI)"30 Displays on LED by decrementing in binary once each second during WAIT mode execution. ~~~~~~ ----~Increments ls counter • • HITACHI 830 15.5 PROGRAM LISTING 00001 * 00002 **** RAM ALLOCATION ************************* 00003 * 00004 0080 ORG $80 00005 * 00006 0080 0001 CNTRD RMB 1 15 counter 00007 0081 0001 CNTRI RMB 1 32ms counter 00008 0082 0002 ERRAM RMB 2 Watch dog data RAM area 00009 0084 0002 SBRAM RMB 2 Standby RAM area 00010 * 00011 **** SYMBOL DEFINITIONS ********************* 00012 * 00013 0000 PADTR EaU $00 Port A data register 00014 0001 PBDTR EaU $01 Port B data register 00015 0002 PCDTR EQU $02 Port C data register 00016 0004 PADDR EaU $04 Port A data direction register 00017 0005 PBDDR EaU $05 Port B data direction register 00018 0006 PCDDR Eau $06 Port 0 data direction register 00019 0009 TCR EQU $09 Timer controL register 00020 0008 TOR EQU $08 Timer data register 00021 ************************************************ 00022 * * 00023 * MAIN PROGRAM : LWPMN 00024 * 00025 * * ************************************************ 00026 * 00027 1000 ORG $1000 00028 * 00029 1000 A6 07 LWPMN LDA 11$07 00030 1002 B7 02 STA PCDTR Turn off LED 00031 1004 B7 06 STA PCDDR SeLect port C bltO-2 as output 00032 1006 A6 OF LOA I:l$F InitiaLize TCR 00033 1008 B7 09 STA TCR 00034 100A A6 FF LOA I:l$FF InitiaLize TOR 00035 100C B7 08 STA TOR 00036 lOOE B7 01 STA PBDTR Turn off LED 00037 1010 B7 05 STA PBDDR SeLect portB as output 00038 1012 3F 80 CLR CNTRD CLear 15 counter 00039 1014 3F 81 CLR CNTRI CLear 32ms counter 00040 1016 18 00 BSET 4.PAOTR Turn off LED 00041 1018 16 00 BSET 3.PADTR Tur-n off LED 00042 lOlA A6 IC LOA 1:l$1C SeLect port A bit2-4 as output 00043 10lC B7 04 STA PADDR 00044 10lE 02 00 as LWPMN1 BRSET I.PADTR.LWPMN2 Branch if HA1835P I test mode 00045 1021 CD 102B JSR LWPMOO Execute Low power mode 00046 1024 20 F8 BRA LWPMN1 00047 1026 CD 106E LWPMN2 JSR LWPWCH Execute HA1835P mode 00048 1029 20 F3 BRA LWPMNI 00049 ************************************************ 00050 * * 00051 * NAME : LWPMOD CLOW POWER DISSIPATION) * 00052 * * 00053 ************************************************ 00054 * * 00055 * INPUT : NOTHING * ~HITACHI 831 00056 * OUTPUT : NOTHING * 00057 * * 00058 *********************************************~** 00059 102B A6 AA LWPMOO LOA I:I$AA Test If SBRAM=$AA? 00060 1020 B1 84 CMP SBRAM 00061 102F 26 00 BNE LWPM02 Br'anch if not equaL 00062 1031 A6 55 LOA t1$55 Test if SBRAM+l=$55? 00063 1033 B1 85 CMP SBRAM+1 00064 1035 26 07 BNE LWPM02 Branch If not equaL 00065 1037 A6 06 LOA 1:1$06 Stand by LEO on 00066 1039 B7 02 STA PCOTR 00067 103B 9A LWPMOI CLI EnabLe interTupt 00068 103C 20 OA BRA LWPM03 00069 103E A6 AA LWPM02 LOA f:lMA Store $AA In SBRAM 00070 1040 B7 84 STA SBRAM 00071 1042 A6 55 LOA 1:1$55 Stor'e $55 in SBRAM+1 00072 1044 B7 85 STA SBRAM+1 00073 1046 20 F3 BRA LWPMOI 00074 1048 2F OC LWPM03 BIH LWPM05 Test if STOP mode? 00075 104A 00 00 16 LWPM04 BRSET 0.PAOTR.LWPM06 Branch if WAIT mode? 00076 1040 B6 80 LOA CNTRO Couote r' LEO on 00077 104F B7 01 STA PBOTR 00078 1051 A6 FF LOA I:I$FF SeLect por't B as output 00079 1053 B7 05 STA PBOOR 00080 1055 81 RTS 00081 1056 A6 05 LWPM05 LOA f:I$05 Stop mode LED on 00082 1058 B7 02 STA PCOTR 00083 105A 9B SEI Disable intrTupt 00084 105B 8E STOP STOP mode 00085 105C 9A CLI Enable i nterTupt 00086 1050 A6 07 LOA tlD7 00087 105F B7 02 STA PCDTR ALL LEO off 00088 1061 20 E5 BRA LWPMD3 ( INn = 1 -) WAIT mode LOaD 00089 1063 A6 03 LWPM06 LOA 1:103 Wait mode LEO on 00090 1065 B7 02 STA PCDTR 00091 1067 8F WAIT WAIT mode 00092 1068 A6 07 LOA 1:107 ALL LEO off 00093 106A B7 02 STA PCDTR 00094 106C 20 OC BRA LWPMD4 00095 ************************************************ 00096 * * 00097 * NAME : LWPWCH (CONTROL HA1835P) * 00098 * * 00099 ************************************************ 00100 * * 00101 * INPUT NOTHING * 00102 * OUTPUT NOTHING * 00103 * * 00104 ************************************************ 00105 106E 19 00 LWPWCH BCLR 4.PADTR Watch d09 LEO on 00106 1070 A6 55 LOA 1:1$55 Test if ERRAM+1=$55 00107 1072 B1 82 CMP ERRAM 00108 1074 26 OC BNE LWPWH1 Branch not equaL 00109 1076 A6 AA LOA I:I$AA Test if ~RRAM=$AA? 00110 1078 B1 83 CMP ERRAM+l ~HITACHI 832 00111 107A 26 06 BNE LWPWH1 Branch if not equaL 00112 107C 17 00 BCLR 3.PADTR Watch dog errar LED on 00113 107E 18 00 BSET 4.PADTR Watch dog LED off 00114 1080 20 08 BRA LWPWH2 00115 1082 A6 55 LWPWH1 LDA lass Stor'e $55 in ERRAM 00116 1084 B7 82 STA ERRAM 00117 1086 A6 AA LDA t:I$AA Store $AA in ERRAM+1 00118 1088 B7 83 STA ERRAM+1 00119 108A 00 00 FD LWPWH2 BRSET 0.PADTR.LWPWH2 Loop if W.D sw on 00120 108D A6 FA LDA t:l250 Execute lms software timer 00121 108F 4A LWPWH3 DEC A 00122 1090 26 FD BNE LWPWH3 00123 1092 04 00 04 BRSET 2.PADTR.LWPWH4 Branch if CLI<=l 00124 1095 14 00 BSET 2.PADTR Set CLI<= 1 00125 1097 20 02 BRA LWPWH5 00126 1099 15 00 LWPWH4 BCLR 2.PADTR Set CLI<=O 00127 109B 81 LWPWH5 RTS 00129 ************************************************ 00130 * * 00131 * NAME : LWPCNT (INCREMENT COUNTER) * 00.132 * * 00133 ************************************************ 00134 109C IF 09 LWPCNT BCLR 7.TCR CLear interrupt request bit 00135 109E 3C 81 INC CNTRI Increment 32ms counter 00136 10AO A6 30 LDA t:I$30 Test if CNTRI=30 00137 10A2 B1 81 CMP CNTRI 00138 10A4 26 04 BNE LWPCT1 Brabch not equaL 00139 10A6 3F 81 CLR CNTRI CLear 32ms counter 00140 10A8 3C 80 INC CNTRD Increment Is counter 00141 10AA 80 LWPCT1 RTI 00142 ************************************************ 00143 * * 00144 * VECTOR ADDRESSES * 00145 * * 00146 ************************************************ 00147 * 00148 1FF6 ORG $IFF6 00149 * 00150 1FF6 1000 FDB LWPMN SCI/TIMER2 00151 IFF8 109C FDB LWPCNT TIMERIINT2 00152 1FFA 1000 FDB LWPMN INT 00153 1FFC 1000 FDB LWPMN SWI 00154 IFFE 1000 FDB LWPMN RES 00155 * I 00156 END ~HITACHI 833 • HITACHI 834 HD6305/HD63L05 SERIES HANDBOOK Section Eight APPENDIX: Thchnical Q and A (Part I) 8-Bit Single-Chip Microcomputer HD630SXO, HD630SX1, HD630SX2 HD630SYO, HD630SY1, HD630SY2 I ~HITACHI 835 ~HITACHI 836 PREFACE The HD6305X and HD6305Y are microprogram-controlled 8-bit single-chip microcomputers that use CMOS 2.5 vm technology. They have a very high compatibility with the HD6805 in terms of instruction set. The CPU, ROM, RAM, I/O, timer, and serial communications interface (SCI) are all integrated into one chip. Each HD6305X-series microcomputer consists of: A HD630SXO with a 128-byte RAM and a 4-kbyte ROM on a single chip; a HD6305X1 connectable to external memory; and a HD6305X2 without ROM. Each HD6305Y-series microcomputer consists of: A HD6305YO with a 256-byte RAM and a 8-kbyte ROM on a single chip; a HD6305Y1 with optional external memory; and a HD6305Y2 without ROM. The CMOS technology enables these models to operate over a wide range of supply voltages (Vcc operates in the 3 V - 6 V range at operating frequencies of 0.1 MHz - 0.5 ftlHz) with less power consumption. The low-power-consumption modes (STOP, WAIT, and STANDBY) available with these models permit further power savings. The instruction set includes DAA (decimal adjust instruc- tion), and STOP and WAIT (used to enter the corresponding low-power-consumption modes), in addition to the HD6805 I instruction set. The minimum instruction execution time is 0.5 vsec/cycle (f=2 MHz), permitting high-speed operation. ~HITACHI 837 HOW TO USE THIS MANUAL This TECHNICAL QUESTIONS AND ANSWERS is a user ref- erence manual that has been compiled in question-and- answer form. It is based on technical inquiries from HITACHI microcomputer users. This manual should be used in conjunction with the appropriate data book (which you should already have) • You can make best use of this manual either by: reading all of it before you start to design any microcomputer- applied products, in order to strengthen your technical background; or referring to it during the actual design process, using it to help you solve specific problems that may arise. Although some of the items supplement the data book, most of them are inquiries from the users. In order to meet future needs, we are prepared to increase the number of Q & A items and to update the data book . • HITACHI 838 Contents Q & A No. Page Parallel Port (1 Outputting Data from Ports after a Reset QA635-001B 841 (2) Serial 1/0 Pin Status QA635-002B 842 (3) Using Port C when Serial I/O is Used QA635-003B 843 Serial Port (1) Designating Input or Output Operation of Serial QA635-004B 844 I/O Clock Pin (2) SCI Prescaler Initialize Timing and Clock Output QA63S-00SB 845 Timing (3) SSR7 (SCI Interrupt Request Bit) Set Timing QA63S-021B 846 (4) Using SDR (SCI Data Register) when Serial I/O 1S QA635-024B 847 not Used (5) Accessing SDR (SCI Data Register) QA63S-02SB 848 (6) Clearing SSR (SCI Interrupt Request Bit) QA63S-026B 849 (7) Transmitting and Receiving Data Simultaneously QA63S-030A 850 through Serial I/O (8) Notes on Receiving Data through SCI in External QA63S-031A 851 Clock Mode (9) SCI Operation in External Clock Mode QA635-032A 852 (10) Initializing the Transfer Clock Generator QA63S-033A 853 Prescaler Timer /Co'un ter ::::J (1) Timer Count-down Timing when External Clock is QA635-006B 854 Input (2) Timer 2 Interrupt Cycles QA63S-022B 855 (3) Reading/Writing Data from/into the TOR during QA63S-034A 856 Timer Operation (4) Timer Clock Input Source QA635-035A 857 BUS Interface Interrupt I (1) Schmitt Trigger Circuit of Interrupt Pin QA63S-007B 858 (2) Servicing Timer Interrupt while Masked QA63S-008B 859 (3) Servicing INT External Interrupt while Masked QA63S-009B 860 (4) Servicing INT2 External Interrupt while Masked QA63S-010B 861 (5) Servicing an Interrupt after a Reset (CCR I bit QA635-011B 862 initializing) (6) Servicing External Interrupt after Returning QA635-012B 863 from Standby Mode (7) Servicing Multiple Interrupts QA635-013B 864 (8) Time from Interrupt Occurrence to Interrupt Ql\635-036A 865 Servicing Routine Execution (9) Servicing SCI (Serial I/O) Interrupt while QA635-037A 866 Masked A/D Converter I Oscillator I (1) Timing of External Clock Input to the Oscillator QA635-014B 867 and E Clock Timing ~HITACHI 839 Q & A No. Page Reset (1) Port Status at a Reset QA63S-0lSB 868 (2) Bus Status at a Reset QA63S-0l6B 869 Low Power Consum tion 1 Bus Status in Low-Power-Consumption Modes QA63S-0l7B 870 (2) Executing an Instruction when Entering Standby QA635-018B 871 Mode (3) Standby Mode Timing QA635-019B 872 (4) Returning from Standby Mode QA63S-020B 873 (S) Entering Low-Power-Consumption Modes QA635-027B 874 (6) Entering Wait Mode QA635-028B 875 (7) Entering Stop Mode QA63S-029B 876 (8) Returning Time from Stop Mode QA63S-038A 877 (9) Current Consumption in Low-Power-Consumption QA635-039A 878 Mode EPROM-'-on-chip Software (1) Accessing Not Used Areas on Memory Map QA63S-040A 879 (2) Using Bit Manipulating Instruction for Output QA635-023B 880 Ports I Evaluation Kit Emulator SD Data Buffer (1) Statuses of Address Bus, Data Bus and Control QA63S-041B 881 Line when the Internal Address Space is Accessed Others ~HITACHI 840 No. QA635-001B Type HD6305XO/Xl/X2 HD6305YO/Yl/Y2 I Device Io4S .8S o 8M Dl6M DEvaluation kit Emulator o Software o SD o SBC Theme Outputting Data from Ports after a Reset Question I Classification Parallel Port * Serial Port Which operation should be performed first to output data through input ports A, B, C, D and G after a reset?; Timer/Counter storing data in the Data Register of the ports or BUS Interface designating the corresponding DDR (Data Direction Interrupt Register)? A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Titlel Store the data to be output in the Data Register first, and then designate the corresponding DDR to data ou tpu t 8-bit Single-chip (DDR=l) • Microcomputer Data Book Since a reset causes the Data Register to become 0, if the DDR is designated to data output before data 1.S stored in the Data register, 0 is ou tpu t to the ports. Other Data Document Ti tl e I Reference Q & A Sheet ~ QA635-0l5B Supplement I The HD6305Xl/X2 and HD6305Yl/Y2 do not have port G. ~HITACHI 841 No. QA63S-002B Type HD630SXO/Xl/X2 HD630SYO/Yl/Y2 I Device Io4S .8S o 8M D16M DEvaluation kit Emulator o Software o SD o SBC Theme Serial I/O Pin Status Question I Classification Parallel Port - * After ports Cs to C7 are respectively used as CK, Rx Serial Port and Tx pins of the SCI (serial I/O) , these ports are spe- Timer/Counter cified as I/O pins using the SCR (SCI Control BUS Interface Register)(SCR7=SCR6=SCR5=0). What is the value of the DDR Interrupt (Data Direction Register) when the ports are used as I/O A/D Converter pins? Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer Applicable Manual Title I The DDR retains the value for the SCI, as shown below. 8-bit Single-chip Pin DDR value for SCI Notes Microcomputer Data Book C7/Tx 1 (output port) When Tx is used, SCR7=l. C6/Rx 0 (input port) When Rx is used, SCR6=1. 0 (input port) In the case of external clock Other Data Document CS/CK - source mode. Title I 1 (output port) In the case of internal clock source mode. Even when the SCR value is changed after the SCI is used, the DDR value shown in the above table is maintained. When using Cs to C7 as I/O ports, rewrite the DDR value using Reference Q & A Sheet software. ~ Supplement I SCR (SCI Control Register: $0010) 7 6 5 4 3 2 1 0 I I I I I SCR7 SCR6 SCR5 SCR4 SCR3 SCR2 SCRI SCRO I I I + Clock source selection bit r SCI data input enable bit r SCI data output enable bit ~HITACHI 842 No. QA63S-003B Type HD630SXO/Xl/X2 HD630SYO/Yl/Y2 I Device I oo 4S .8S o 8M O16M Eva lua tion kit Emulator o Software o SD o SBC Theme Using Port C when Serial I/O is Used Question r Classification Parallel Port * Serial Port When ports Cs to C7 are used as the SCI (serial I/O) , is it possible to use ports Co to C4 as usual I/O pins? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-ch i p Software Evaluation Kit Emulator SD Data Buffer Others Answer I Apl'licable Manual Ti t lei Yes. These ports can be used as usual I/O pins because they are independent of the SCI. The ports affected by the 8-bit Single-chip Microcomputer SCR (SCI Control Register) when the SCI is used are ports Data Book Cs to C7 only. Input and output functions of ports Co to C4 are selected using bits 0 to 4 of port C's DDR (Data Direction Register). Other Data Document Title J Reference _Q & A Sheet ~ Supplement I I ~HITACHI 843 No. QA63S-004B Type HD630SXO/Xl/X2 HD630SYO/Yl/Y2 IDevice IoCl 4S .SS o SM OI6M Evaluation kit Emulator o Software o SD o SBC Theme Designating Input or Output Operation of Serial I/O Clock Pin Question I Classification Parallel Port Serial Port Does setting 0 or I in the corresponding DDR (Data * Timer /Counter Direction Register) enable the clock pin CK to be designated as an input or output pin when the SCI BUS Interface (serial I/O) is used? Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title J No. Bits 4 and 5 (SCR4,.2.) of the SCR (SCI Control Register) designate the CK pin as input or output when the S-bit Single-chip Microcomputer SCI is used, not the DDR. Data Book As shown below, the combination of bits 4 and 5 enables the SCI clock source selection, determining whether the CK pin is specified as an input or output pin. Other Data Document SCRS SCR4 Clock source CK pin (port C5) Title I 0 0 Used as I/O pin (according tc - 0 1 the DDR) 1 0 Internal Clock output (DDR output) I 1 External Clock input (DDR input) Note: The selection of input or output is made by the DDR Reference Q & A Sheet when SCRS is 0 and SCR4 is 0 or 1. ~ Supplement I SCR (SCI Control Register: $0010) 7 6 5 4 3 2 1 0 I SCR7 I SCR6 I SCRS I SCR4 I SCR3 I SCR2 I SCRI I SCRO I ~ f Clock source selection bit ~HITACHI 844 No. QA63S-00SB Type HD630SXO/Xl/X2 HD6305YO/Yl/Y2 I Device Io 4S .8S o 8M o 16M DEvaluation kit Emulator o Software o SD o SBC Theme SCI Prescaler Initialize Timing and Clock Output Timing Ques tion I Classification Parallel Port Serial Port At what timing is the SCI (serial I/O) prescaler initiali- * Timer/Counter zed? In addition, when the internal clock is used (SCR4=O, BUS Interface SCR5=1), at what timing lS the CK (seria I clock) output? Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I The prescaler is initialized when data is read from or wt"i t ten into the SDR (SCI Data Regist~). 8-bit Single-chip When the internal clock is used, the CK is output at the Microcomputer Data Book baud rate specified by bits 0 to 3 of the SCR (SCI Control Register) , immediately after the data reading/writing. The SCI timing chart is shown below. Other Data Document Titlel ,~P<'ViOU' d." S«'"' do,k (C,/Ci(J ~ .\ I 2 3 .. !) 6 7 8 Output data , LSB MSB (C,/Tx)----J _____ Input data Reference Q & A Sheet latch timing I 1 1 J I I I ( C./Rx) ~ SCI Timing Chart Supplement I ~HITACHI 845 No. QA63S-021B Type HD630SXO/Xl/X2 HD630SYO/Yl/Y2 I Device I CI 4S .8S D 8M D 16M DEvaluation kit, Emulator o Software o SD D SBC Theme SSR7 (SCI Interrupt Request Bit) Set Timing Ques tion I Classification Parallel Port After 8-bit data transmitting or rece1v1ng through the SCI * Serial Port (serial I/O) is completed, SSR7 (SCI interrupt request bit) Timer/Counter of the SSR (SCI Status Register) is set. At what timing is BUS Interface this setting performed? Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Titlel SSR7 is set at the rising edge of the 8th CK (serial clock) as shown below. Serial ClOCk_~ <;J~~ SCI interrupt request bit ~HITACHI 846 No. QA635-024B Type HD630SXO/Xl/X2 HD630SYO/Y 1/Y2 I Device Io4S .8S o 8M Dl6M DEvaluation kit, Emulator o Software o SD o SBC Theme Using SDR (SCI Data Register) when Serial I/O is not Used Ques tion I Classification Parallel Port Serial Port Is it possible to use the SDR (SCR Data Register: $0012) as * Timer/Counter a general-purpose register when the SCI (serial I/O) is not used? BUS Interface Interrupt A/D Converter Osc i lla tor Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I Yes. The SDR can be used as a general-purpose register when the SCI is not used i. e. , when the SCI clock is stopped with SCR4 to SCR7 being O. Other Data Document Ti t Ie I Reference Q & A Sheet ~ Supplement! SCR (SCI Control Register: $0010) 7 6 5 4 3 2 1 0 ! SCR7 ! SCR6 I SCRS I SCR4 I SCR3 I SCR2 I SCRI I SCRO I f t I Clock source selection bit SCI data input pin enable bit SCI data output pin enable bit ~HITACHI 847 No. QA63S-02SB Type HD630SXO/XI/X2 HD630SYO/YI/Y2 I Device I [J 4S .8S o 8M Dl6M DEvaluation kit Emulator o Software o SD DSBC Theme Accessing SDR (SCI Data Register) Question I Classification Parallel Port What will happen if data is read from or written into the Serial Port SDR (SCI Data Register) while another data is being * Timer/Counter transmitted or received through the SCI (serial I/O)? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual TitleJ Normal operation can not be guaranteed for either transmission or reception. Do not access the SDR during data transmitting or receiving since the SCI becomes disabled after the access (the MCU must be reset to use the SCI again). Other Data Document Ti tIe I Reference Q & A Sheet ~ QA63S-033A Sup~lement I SDR (SCI Data Register: $0012) 7 6 5 4 3 2 1 0 Receive -I MSB I I I I I I I LSB I ____ Transmit ~HITACHI 848 No. QA635-026B Type HD6305XO/Xl/X2 HD6305YO/Y1/Y2 IDevice Io 4S .8S o 8M Dl6M DEvaluation kit Emulator o Software o SD o SBC Theme Clearing SSR (SCI Interrupt Request Bit) Question I Classification Parallel Port Serial Port After data is transmitted or received through the SCI * Timer/Counter (serial I/O), SSR7 (SCI interrupt request bit) is set to 1. At this time, if 0 is set in SSR7 by software BUS Interface to cl~ar the bit, is it possible to transmit or receive Interrl!.E.t the next data? A/D Converter Oscillator Reset Low Power Consumption EPROM-on-ch~ Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Ti t Ie I No. When 0 is set in SSR7 by software, this bit is cleared, and the next data transmitting and receiving can- not be performed. SSR7 is cleared under the following con- ditions. ~When data is read from or written into the SDR (SCI Data Register) • Other Data Document (After SSR7 is cleared and the octal counter is reset, Ti t Ie I the next data transmitting/receiving is executed.) KDWhen 0 is set in SSR7 by software. (The SCI's octal counter is not reset, enabling no data transmitting/receiving.) Therefore, repeat data reading or writing from/into the SDR to transmit/receive data repeatedly. Reference Q & A Sheet Dummy-read the SDR before receiving the first data. ~ Supplement I SSR (SCI Status Register: $0011) 7 6 5 4 3 2 1 0 I SSe SSR6 1SSR5 1SSR4 I SSR3 1><1><1><1 SCI interrupt request bit ~HITACHI 849 No. QA635-030A Type HD6305XO/XI/X2 HD6305YO/Y l/Y2 IDevice I D4S .8S o 8M Dl6M DEvaluation kit, Emulator o Software o SD o SBC Theme Transmitting and Receiving Data Simultaneously through Serial I/O Ques tion I Classification Parallel Port Serial Port Is is possible to transmit and receive data simultaneously * Timer /Counter through the SCI (serial I/O) by using the internal clock for transmitting and the external clock for receiving, or BUS Interface vice versa? Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Titiej No. Only one clock sburce can be selected as the SCI transfer clock. Simultaneous data transmission and recep- tion using two transfer clocks are impossible. When a single clock source is used, data can be transmitted and received at the same time. Other Data Document Ti tIe I Reference Q & A Sheet ~ Supplement I ~HITACHI 850 No. QA635-031A Type HD6305XO/Xl/X2 HD6305YO/Yl/Y2 IDevice I D 4S .8S o 8M D16M DEvaluation kit Emulator o Software o SD o SBC Theme Notes on Receiving Data through SCI in External Clock Mode Question I Classification Parallel Port Serial Port What should we pay attention to when using the external * Timer/Counter clock to receive data through the .SCI (serial I/O)? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consum~tion EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Ti tIe I The external transf;er clock source does not enable the receiving side to check when data is transmitted. Therefore, it is necessary to read out data in the SDR (SCI Data Register) as soon as the data is received, to prepare for receiving the next data. Whether or not receiving has been completed can be checked Other Da ta Doc umen t by an SCI interrupt or by testing bit 7 of the SSR (SCI Title I Status Register) by software. Reference Q & A Sheet ~ Supplement I SSR (SCI Status Register: $0011) 7 6 5 4 3 2 1 0 I SSe SSR6 1SSR5 1SSR4 1SSR3 1><1><1><1 SCI i,,"=p' '"q."" bi, (" No ,"que... ) 1: Yes ~HITACHI 851 No. QA63S-032A Type HD630SXO/Xl/X2 HD630SYO /Y 1/Y2 Device I Cl 4S .8S o 8M D16M DEvaluation kit Emulator o Software o SD o SBC Theme SCI Operation in External Clock Mode Ques tion , Classification Parallel Port Serial Port The SCI ( serial I/O) is in external c1oc~mode; * Timer/Counter If the external clock is applied to the CK pin before the CPU writes/reads data into/from the SDR (Serial Data BUS Interface Register) after the one-byte data transmitting/receiving is Interrupt completed, will the SCI start the next data A/D Converter transmitting/receiving? Oscillator Reset Low Power Consumption EPROM-on-chi]:> Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual TitleJ No. The SCI does qot start transmitting or receiving the next data until the CPU writes/reads data into/from the SDR. That is, any clock signal applied to the CK pin before the CPU accesses the SDR wi 11 be ignored. Other Data Document Ti tIe' Reference Q & A Sheet ~ Supplement I - The CK pin can also used SCRS SCR4 Clock Cs pin as Cs pin. I t is con- source trolled by bits 4 and 5 0 0 - Used as I/O pin (accordin~ of the SCR (SCI Control 0 1 - to the DDR) Register). 1 0 Interna Clock output (DDR output) 1 1 External Clock input (DDR input) ~HITACHI 852 No. QA635-033A Type HD6305XO/Xl/X2 HD6305YO/Y l/Y2 I Device Io 4S .8S o 8M Dl6M DEvaluation kit Emulator o Software o SD o SBC Theme Initializing the Transfer Clock Generator Pres caler Question I Classification Parallel Port Serial Port ~he prescaler of the SCI transfer clock generator is ini- * Timer/Counter tialized by reading/writing data from/into the SDR (SCI Status Register) or by setting 1 in SSR3 (SCI Status BUS Interface Register bit 3). What is the difference of the initializa- Interrupt tion performed by these two methods? A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chi£ Software Evaluation Kit Emulator SD Data Buffer Others Answer I ~licable Manual TitleJ h'here are differences in the following points. (1) When data is read/written from/into the SDR, the SCI octal counter is initialized at the same time the pres caler is initialized. This causes the SCI to start transmitting or receiving the next data. Other Da ta Doc umen t (2) When I is set in SSR3, only the prescaler is ini- Ti tIe I tialized. The SCI does not start data trasmitting/receiving. IsSR3 is the bit to be used to initialize the presca ler when the transfer clock generator is utilized as Timer 2. Reference J! & A Sheet ~ QA635-025B Supplement I ~SR (SCI Status Register: $0011) 7 6 5 4 3 2 I 0 I SSR7 I SSR6 I SSR5 I SSR4 I SS~>in) (high impedance) Other Data Document D - - High impedance Ti tIe I (Input pin) E, F - 0 o output (Output pin) G 0 0 Designated as an input port (I/O pin) (high impedance) Reference Q & A Sheet ~ QA63S-001B QA63S-016B Supplement I The HD6305XI/X2 and HD6305Yl/Y2 do not have ports E, F and G. ~HITACHI 868 No. QA63S-0l6B Type HD630SXO/xl/x2 HD630SYO/YI/Y2 I Device Io4S .8S o 8M D16M DEvaluation kit Emulator o Software o SD OSBC Theme Bus Status at a Reset Ques tion I Classi fica tion Parallel Port - Serial Port What are the statuses of the address bus, data bus and R/w signal at a reset? Timer/Counter BUS Interface Interrupt AID Converter Osc i 11a tor Reset * Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Ti tIe I Their statuses are as shown below. ~ Status at a reset Address bus Outputs $lFFF Other Data Document Data bus High impedance Ti tIe I - R/w signal High level (read) Reference Q & A Sheet ~ QA63S-0lSB QA63S-017B Supplement I The above answer does not apply to the HD630SXO and HD630SYO since these I units cannot be expanded externally. ~HITACHI 869 No. QA635-0l7B Type HD6305XO/xl/x2 HD6305YO/Y l!Y2 I Device Io4S .8S o 8M D16M DEvaluation kit Emulator o Software o SD o SBC Theme Bus Status in Low-Power-Consumption Modes Question Classification Parallel Port What are the statuses of the address bus, data bus and R/w - Serial Port signa I in low-power-consumption modes (wait, stop and Timer/Counter standby)? BUS Interface Interrupt AID Converter asci lla tor Reset Low Power Consumption * EPROM-on-chi~ Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Ti tIe I Their statuses are as shown below. Mode Address Data bus R/w E pin bus signal Wait $IFFF High High E clock ilIlI>edance level output Other Data Document Stop $IFFF High High Low Ti tIe I impedance level level Standby High High High High impedance impedance impedance impedance Reference Q & A Sheet ~ Supplement I The above answer does not apply to the HD6305XO and HD6305YO since these units cannot be expanded externally. ~HITACHI 870 No. QA635-0l8B Type HD630SXO/Xl/X2 HD630SYO/Y l/Y2 I Device Io 4S .8S o 8M Dl6M DEvaluation kit Emulator o Software o SD o SBC Theme Executing an Instruction when Entering Standby Mode Question I Classification Parallel Port The MCU enters standby mode by setting the STBY pin in Low. Seria 1 Port What will happen to the instruction that was being executed Timer/Counter at that time? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption * EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I The instruction execution is stopped since the MCU enters standby mode whether or not an instruction execution 8-bit Single-chip sequence is executed. The MCU enters standby mode imme- Microcomputer Data Book diately after the STBY pin becomes Low. In standby mode, the internal oscillator is stopped and the contents of the MCU internal registers are destroyed. So, Other Data Document be sure to perform a reset-start to return from standby Ti tIe I mode (the built-in RAM values are retained) • E clock -.JI Reference Q & A Sheet STU Y I I L..........-... Standby mode ~ QA635-0l9B Supplement I ~HITACHI 871 No. QA635-0l9B Type HD6305XO/Xl/X2 HD6305YO!Yl/Y2 I Device I Cl 4S .8S o 8M Dl6M DEvaluation kit Emulator o Software o SD o SBC Theme Standby Mode Timing Question I Classification Parallel Port In the following chart showing the timing at which the MCU Serial Port enters standby mode, is there any limit to the value of t? Timer/Counter In addition, at what timing should Vcc be dropped? BUS Interface Interrupt STBY A/D Converter \ IJ I Oscillator Reset , ,, , , Low Power Consumption IfES I, , , '1 L_ _1_ * EPROM-on-chip . I --! t I I l Software Evaluation Kit Oscillation Restart Stabilizing Emulator Timing Chart of Returm.ng Time SD from Standby Mode Data Buffer (t oSC =20 ms) Others Answer I Applicable Manual There is no limit to the value of to Ti tIe I -- -- Eith~the STBY pin or RES pin can be Low first. However, the RES must~raised 20 msec or more behind the rising 8-bit Single-chip edge of the STBY to restart operation. Microcomputer Data Book The Vcc must be dropped after the STBY becomes Low. I t should be returned to the specified level before the STBY returns to High. Other Data Document Title I Reference .Q& A Sheet ~ QA635-0l8B QA6)5-020B Supplement I ~HITACHI 872 No. QA635-020B Type HD6305XO/Xl/X2 HD6305YO/Yl/Y2 I Device I oo 4S .8S o 8M 016M Evalua tion ki t Emulator o Software o SD 0 SBC Theme Returning from Standby Mode Questionl Classification Parallel Port Is there any method of returning from standby mode other Serial Port than reset-start? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset * Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I No. In standby mode, the internal oscillator is stopped and the MCU internal register values are destroyed. (The 8-bit Single-chip contents of the Program Coun~are also destroyed.) Microcomputer Data Book Therefore, only setting the STBY pin in High caused the MCU to burst. Be sure to perform a reset-start to return from standby Other Data Document mode. Tit Ie I S'i'lIT - - - - - - , \ I L-. ----jIJf--~ \~_l\ \ \ \ l_L-__ __ L_ ... I -jI!:I--_ _ _+:----j~ ( Reference Q & A Sheet ~ Oscillation Restart Timing Chart of Returning Stabilizing QA635-0l9B from Standby Mode Time (t osc =20 ms) Supplement I I ~HITACHI 873 No. QA63S-0Z7B Type HD630SXO/XI/X2 HD630SYO/YI/YZ IDevice Io4S .8S o 8M Ol6M DEvaluation kit Emulator o Software o SD o SBC Theme Entering Low-Power-Consumption Modes Question' Classification Parallel Port Does executing the WAIT or STOP instruction always cause Serial Port the MCU to enter wait or stop mode? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption * EPROM-on-ch ip Software Evaluation Kit Emulator SD Data Buffer Others AnswerJ Applicable Manual Titlel No. The MCU en ters wait or stop mode only in the following conditions. CD When there is no interrupt requests. -- -- (The RES, STBY and INT pins are all High and the INT interrup~tch and all interrupt bits are cleared. ) G) When the INTZ and internal interrupts are disabled by Other Data Document the mask bits, and there is no other interrupts. Ti tIe I -- (The RES, STBY and INT pins are all High, the INT interrupt latch is cleared, and each interrupt mask bit is set.) If the above conditions are not met, the MCU executes the next instruction after the execution of the WAIT Reference Q & A Sheet and STOP instructions which requires 4 cycles. ~ Supplement I -- In case G) above, the absence or presence of the INTZ and internal interrupt requests has no effec t. ~HITACHI 874 No. QA63S-0Z8B Type HD630SXO/Xl/XZ HD630SYO/Yl/YZ I Device Io4S .8S o 8M Ol6M DEvaluation kit Emulator o Software o SO o SBC Theme Entering Wait Mode Question I Classification Parallel Port Are there any precautions about entering wait mode by the Serial Port WAIT instruction execution? Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption * EPROM-on-chip Software Evaluation Kit Emulator SO Data Buffer Others Answer I Al'plicable Manual Note that the method of entering wait mode differs Title I Jepending on the returning method from wait mode. ~ Optl frnm w.. it. --- INT interrupt --- rnl..ion mmle INTZ, TIMER, TIMERZ, SCI an.nr II rot~lrll Executing Clear the CCR I Clear the CCR I bit. interrupt bit. Set all in- Set all mask bits except Other Data Document routine terrupt mask bits. the one for the interrupt Ti tIe I to be used. --- Do not cause any INT in- terrupts in wait mode. Executing Set the CCR I bit. Set the CCR I bit. an ope- Set all interrupt Set all mask bits except ration mask bits. the one for the interrupt Reference Q & A Sheet after the to be used. -- ~ WAIT inst- Do not cause any INT in- ruction* terrupts in wait mode. *., The INT interrupt requested (by detecting a falling edge in the INT pin) before the WAIT instruction execution has already been serviced. Supplement I CCR (Condition Code Register) I bit: Interrupt mask bit (except software I interrupts) -- Interrupt mask bits: INTZ - - - - Miscellaneous Register (MR: $OA) bit 6 TIMER - - - - Timer control Register (TCR: '$09) bit 6 TIMER2 - - SCI Status Register (SSR: $11 ) bit 4 SCI SCI Status Register (SSR: $11) bit 5 ~HITACHI 875 No. QA635-029B Type HD6305XO/Xl/X2 HD6305YO/Yl/Y2 I Device I CI 45 .85 o 8M Dl6M DEvaluation kit Emulator o Software o SD o SBC Theme Entering Stop Mode Question I Classification Parallel Port Are there any precautions about entering stop mode by the Serial Port STOP instruction execution? Timer /Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption * EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Ti tIe I Note that the method of entering stop mode differs depending on the returning method from stop mode. ~ Ope- from stop -- INT interrupt - - interrupt ration mnd& INT2 after a return Executing Clear the CCR I Other Data Document interrupt -- Clear the CCR I bit. Set all mask bits except bit. Set the INT2 Title I routine interrupt mask bit the one for the interrupt (MR6). to be used. -- Do not cause any INT in- terrupts in stop mode. Executing Set the CCR I bit. Set the CCR I bit. an ope- Set the INT2 inter Set all mask bi ts except Reference Q & A Sheet ration rupt mask bit the one for the interrupt ~ after the (MR6). to be used. STOP inst- -- Do not cause any INT in- ruction* terrupts in stop mode. *., The -- INT~terrupt requested (by detecting a falling edge in the INT pin) before the STOP instruction execution has already been serviced. Supplement I CCR (Condition Code Register) I bit: Interrupt mask bit (except software interrupts) -- INT2 interrupt mask bit ----- Miscellaneous Register (MR: $OA) bit 6 ~H'ITACHI 876 No. QA63S-038A Type HD630SXO/Xl/X2 HD630SYO/YI/Y2 I Device Io4S .8S o 8M Dl6M DEvaluation kit, Emulator o Software o SD OSBC Theme Returning Time from Stop Mode Ques tion I Classification Parallel Port How long is the internal delay when the MCU returns from Serial Port -- stop mode to operating mode by the interrupt INT or 1NT2· Timer/Counter BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption * EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I It is approximately 14 ms when a 4-MHz crystal oscillator is used. The internal delay time indicates the period whi Ie the CPU execution is stopped and until the oscillating circuit which was stopped in stop mode performs stabilized oscilla- tion. This delay is automatically generated in the MCU. Other Data Document Title I Reference 06- A Sheet ~ Supplement I I ~HITACHI 877 No. QA635-039A Type HD6305XO/XI/X2 HD6305YO/YI/Y2 IDevice I CJ 4S .8S o 8M Dl6M DEvaluation kit Emulator o Software DSD o SBC Theme Current Consumption in Low-Power-Consumption Mode Question I Classification Parallel Port Is the Icc (current consumption) in low-power-consumption Serial Port modes which is specified in the data sheets the value when Timer/Counter no load is applied to the I/O ports? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption * EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others AnswerJ Applicable Manual Title I Yes. Since the I/O ports maintain their output levels even in stop and wait modes, the Icc will be increased by IOH or IOL when a load is applied to the ports. In standby mode, however, the I/O ports are in the high impedance state, and the Icc is the same with or without Other Data Document load. Ti tIe J Reference Q & A Sheet ~ Supplement I • HITACHI 878 No. QA63S-040A Type HD630SXO/XI/X2 HD630SYO/YI/Y2 1Device I oD4SEvaluation .8S o 8M Ol6M kit...L Emulator o Software o SD OSBC Theme Accessing Not Used Areas on Memory Map Ouestion I Classification Parallel Port What will happen if data is read from or written into the Serial Port area designated as Not Used on the memory map? Timer/Counter BUS Interface Interru--"t A/D Converter Oscillator Reset Low Power Consum~tion EPROM-on-ch~ Software * Evaluation Kit Emulator SO Data Buffer Others Answer I Ap~licable Manual TitleJ Nothing will happen as long as the areas are not addresses $13 to $lF. Never access the $13 to $lF areas since they are used for IC testing. Accessing (reading/writing) these areas causes the MCU to burst. Other Data Document Title] Reference.Q & A Sheet ~ Supplement I ~HITACHI I 879 No. QA635-023B Type HD6305XO/Xl/X2 HD6305YO/Yl/Y2 IDevice I D 4S .8S o 8M D16M DEvaluation ki tL Emu la tor o Software o SD DSBC Theme Using Bit Manipulating Instruction for Output Ports Question I Classification Parallel Port Is it possible to use the bit manipulating instruction for Serial Port the Data Registers of the output ports (ports A, B, C and G Timer/Counter used for output and output ports E and F)? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-ch~ Software * Evaluation Kit Emulator SD Data Buffer Others Answer I Ap~licable Manual TitleJ Yes. The bit manipulating instruction automatically reads out an 8-bit Single-chip Microcomputer address, manipulates data in it and re-enters a result in Data Book the address. This instruction can be used for any read/write registers. However, when data is read from the Port Data Register, Other Data Document data output to port G is determined by a pin voltage. That Title I is, a voltage of less than 2.0 V due to the external cir- cuit causes incorrect data to be output to port G. Design the external circuit appropriately to prevent incorrect data output. To ports A, B, C, E and F, the logical levels stored in the Port Data Register are output. Reference Q & A Sheet ~ Supplement I The HD6305Xl/X2 and HD6305YI/Y2 do not have port E, F and G. ~HITACHI 880 No. QA635-041B Type HD6305XO/Xl/X2 HD6305YO/YI/Y2 JDevice I oDEvaluation 4S .8S o 8M D16M kit Emulator o Software o SO DSBC Statuses of Address Bus, Data Bus and Control Line when the Internal Theme Address Space is Accessed Question I Classification Parallel Port What values are output to the address bus, data buses and Serial Port control line when the CPU access the internal address Timer/Counter space? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SO Data Buffer * Others Answer I Applicable Manual Title I The same value as the accessed data is output to the address bus and control line, whether the CPU accesses the internal address space or external address space and whether the CPU reads or writes data. However, the data buses are in the high impedance state when the CPU read data from the internal address space, Other Data Document though the same value as the data written into the Title I internal space by the CPU is output to the data buses. Reference Q & A Sheet ~ Supplement I ~HITACHI 881 .HITACHI 882 HD630S/HD63LOS SERIES HANDBOOK Section Eight APPENDIX: Thchnical Q and A (Part II) 8-Bit Single-Chip Microcomputer HD630SUO,HD630SVO ~HITACHI 883 • HITACHI 884 PREFACE The HD6305UO and HD6305VO are microprogram-controlled8-bit single-chip microcomputers that use CMOS 2.5-pm technology. These models are 40-pin versions of the HD6305XO. The CPU, memory, timer, serial communications interface (SCI), and I/O are all integrated into one chip. The only difference between the HD6305UO and the HD6305VO lies in their memory capacities. The former has a 2-kbyte ROM and a l28-byte RAM; the latter has a 4-kbyte ROM and a 192-byte RAM. The CMOS technology enables these models to operate over a wide range of supply voltages (Vcc operates in the 3 V - 6 V range at operating frequencies of 0.1 MHz - 0.5 MHz) with less power consumption. The 10w-power-consumption modes (STOP, WAIT, and STANDBY) available with these models permit further power savings. The instruction set includes DAA (decimal adjust instruc- tion), and STOP and WAIT (used to enter the corresponding 10w-power-consumption modes), in addition to the HD6805 instruction set. The minimum instruction execution time is 0.5 psec/cyc1e (f=2 MHz), permitting high-speed operation • • HITACHI 885 HOW TO USE THIS MANUAL This TECHNICAL QUESTIONS AND ANSWERS is a user ref- erence manual that has been compiled in question-and- answer form. It is based on technical inquiries from HITACHI microcomputer users. This manual should be used in conjunction with the appropriate data book (which you should already have) . You can make best use of this manual either by: reading all of it before you start to design any microcomputer- applied products, in order to strengthen your technical background; or referring to it during the actual design process, using it to help you solve specific problems that may arise. Although some of the items supplement the data book, most of them are inquiries from the users. In order to meet future needs, we are prepared to increase the number of Q & A items and to update the data book. ~HITACHI 886 Contents Q & A No. Pa2e Parallel Port 1 Outputting Data from Ports after a Reset QA635-301A 889 (2) Serial I/O Pin Status QA635-302A 890 (3) Using Port D when Serial I/O is Used QA635-303A 891 c==(1)Serial Por~ Designating Input or Output Operation of Serial QA635-304A 892 I/O Clock Pin (2) Using SDR (SCI Data Register) when Serial I/O is QA635-305A 893 not Used (3) SSR7 (SCI Interrupt Request Bit) Set Timing QA635-306A 894 (4) Clearing SSR (SCI Interrupt Request Bit) QA635-307A 895 (5) Accessing SDR (SCI Data Register) QA635-308A 896 (6) Transmitting and Receiving Data Simultaneously QA635-309A 897 through Serial I/O (7) Notes on Receiving Data through SCI in External QA635-310A 898 Clock Mode (8) SCI Operation in External Clock Mode QA635-311A 899 (9) Initializing the Transfer Clock Generator QA635- 312A 900 Prescaler (10) SCI Prescaler Initialize Timing and Clock Output QA635-313A 901 Timing LTimer/Counter (1) Reading/Writing Data from/into the TOR during QA635-314A 902 Timer Operation (2) Timer Count-down Timing when External Clock is QA635-315A 903 Input (3) Timer Clock Input Source QA635-316A 904 (4) Timer 2 Interrupt Cycles QA635-317A 905 BUS Interface Interrupt (1) lime from Interrupt Occurrence to Interrupt QA635-318A 906 Servicing Routine Execution (2) Schmitt Trigger Circuit of Interrupt Pin QA635-319A 907 (3) Servicing an Interrupt after a Reset (CCR I bit QA635-320A 908 initializi!!£2. (4) Servicing INT External Interrupt while Masked QA635-321A 909 (5) Servicing INT2 External Interrupt while Masked QA635-322A 910 (6) Servicing SCI (Serial I/O) Interrupt while QA635-323A 911 Masked (7) Servicing Timer Interrupt while Masked QA635-324A 912 (8) Servicing External Interrupt after Returning QA635-325A 913 from Standby Mode (9) Servicing Multiple Interrupts QA635-326A 914 A/D Converter Oscillator I (1) Timing of External Clock Input to the Oscillator QA635-327A 915 and E Clock Timing ~HITACHI 887 Q & A No. Page Reset I (1) Port Status at a Reset QA635-328A 916 Low Power Consumption I (1) Entering Low-Power-Consumption Modes QA635-329A 917 (2) Entering Wait Mode QA635-330A 918 (3) Entering Stop Mode QA635-331A 919 (4) Returning Time from Stop Mode QA635-332A 920 (5) Standby Mode Timing QA635-333A 921 (6) Returning from Standby Mode QA635-334A 922 (7) Executing an Instruction when Entering Standby QA635-335A 923 Mode (8) Current Consumption in Low-Power-Consumption QA635-336A 924 Mode EPROM-on-chip Software I (1) Using Bit Manipulating Instruction for Output QA635-337A 925 Ports (2) Accessing Not Used Areas on Memory Map QA635-338A 926 Evaluation K i t ] Emulator I SO. r Data Buffer Others ~HITACHI 888 No. QA63S-301A Type HD630SUO HD630SVO 1 1 Device a 4S • 8S a8M a16M a Evaluation kit Emulator a Software aSD a SBC Theme Outputting Data from Ports after a Reset Ouestion I Classi fica tion Parallel Port * Serial Port Which operation should be performed first to output data through input ports A, B, C and D after a reset?; storing Timer/Counter data in the Data Register of the ports or designating the BUS Interface corresponding DDR (Data Direction Register)? Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I Store the data to be output in the Data Register first, HD630SUO, HD630SVO and then designate the corresponding DDR to data output Data Sheets (DDR=l). 8-bit Single-Chip Micro- Since a reset causes the Data Register to become 0, if the computer Data Book DDR is designated to data output before data is stored in the Data register, 0 is output to the ports. Other Data Document Title I Reference ~ & A Sheet ~ QA63S-328A Supplement I ~HITACHI 889 No. QA63S-302A Type HD630SUO HD630SVO IDevice Io4S • 8S o 8M O16M DEvaluation kit Emulator o Software OSD o SBC Theme Serial I/O Pin Status Question 1 Classification Parallel Port * Serial Port After ports D3 to Ds are respectively used as CK, Rx and Tx pins of the SCI (serial I/O), these ports are Timer /Counter specified as I/O pins using the SCR (SCI Control Register) BUS Interface (SCR7=SCR6=SCRS=0). What is the value of the DDR (Data Interrupt Direction Register) when the ports are used as I/O pins? A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Ti tIe I The DOR retains the value for the SCI, as shown below. HD630SUO, HD630SVO Data Sheets Pin OOR value for SCI Notes 8-bit Single-Chip Micro- D3/Tx 1 (output port) When Tx is used SCR7=1. computer Data Book D4/Rx 0 (input port) When Rx is used SCR6=1. Other Data Document 0 (input port) In the case of external clock - Os/CK source mode. Title I 1 (ou tpu t port) In the case of internal clock source mode. Even when the SCR value is changed after the SCI is used, the DDR value shown in the above table is maintained. When using D3 to DS as I/O ports, rewrite the DDR value using Reference Q & A Sheet software. ~ Supplement I SCR (SCI Control Register: $0010) 7 6 5 4 3 2 1 0 LSCR7 SCR6 I SCRsl SCR4 I SCR3 I SCR2 I SCRI I. SCRO f t Clock source selection bit SCI data input enable bit SCI data output enable bit ~HITACHI 890 No. QA63S-303A Type HD630SUO HD630SVO IDevice I oo 4S .8S 08M 016M Evaluation kit Emulator o Software OSD o SBC Theme Using Port D when Serial I/O is Used Question I Classification Parallel Port * Serial Port When ports D3 to DS are used as the SCI (serial I/O), is it Timer/Counter possible to use ports DO to D2 and D6 as usual I/O pins? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I A~plicable Manual Title I Yes. These ports can be used as usual I/O pins because HD630SUO, HD630SVO they are independent of the SCI. The ports affected by the Data Sheets SCR (SCI Control Register) when the SCI is used are ports 8-bit Single-Chip Micro- D3 to DS only. Input and output functions of ports DO computer Data Book to D2 and D6 are selected using bits 0 to 2 and 6 of port D's DDR (Data Direction Register). Other Data Document Title I Reference 0 & A·Sheet ~ Supplement I ~HITACHI 891 No. QA635-304A Type HD6305UO HD6305VO J Device Io 4S • 8S D8M D 16M DEvaluation kit Emulator o Software DSD o SBC Theme Designating Input or Output Operation of Serial I/O Clock Pin Question I Classification Parallel Port Does setting 0 or 1 in the corresponding DDR (Data * Serial Port Direction Register) enable the clock pin CK to be Timer/Counter designated as an input or output pin when the SCI BUS Interface (serial I/O) is used? Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buff~r Others Answer I Applicable Manual TitleJ No. Bits 4 and 5 (SCR4. 5) of the SCR (SCI Control HD630SUO, HD6305VO Register) designate the CK pin as input or output when Data Sheets the SCI is used, not the DDR. 8-bit Single-Chip Micro- As shown below, the combination of bits 4 and 5 enables the computer Data Book SCI clock source selection, determining whether the CK pin is specified as an input or output pin. Other Data Document SCR5 SCR4 Clock source CK pin (port Ds ) Title I 0 0 ~ Used as I/O pin (according t( 0 1 the DDR) 1 0 Internal Clock output (DDR out~ut) 1 1 External Clock input (DDR input) Note: The selection of input or output is made by the DDR Reference Q & A Sheet when SCR5 is 0 and SCR4 is 0 or 1. ~ Supplement I SCR (SCI Control Register: $0010) 7 6 5 4 3 2 1 0 I SCR7 I SCR6 I SCRsl SCR4 I SCR3 I SCR2 I SCRI I SCRO I r Clock source selection bit ~HITACHI 892 No. QA635-305A Type HD6305UO HD6305VO IDevice I C14S .8S C18M C1l6M CI Evaluation kit Emulator CI Software CI SD CI SBC Theme Using SDR (SCI. Data Register) when Serial I/O is not Used Question I Classification Parallel Port Serial Port Is it possible to use the SDR (SCR Data Register: $0012) as * Timer/Counter a general-purpose register when the SCI (serial I/O) is not BUS Interface used? Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I Yes. The SDR can be used as a general-purpose register when the SCI is not used i.e., when the SCI clock is stopped with SCR4 to SCR7 being O. Other Data Document Title I Reference Q & A Sheet ~ Supplement I SCR (SCI Control Register: $0010) 7 6 5 4 3 2 1 0 I SCR7 I SCR6 I SCR5 I SCR4 I SCR3 I SCR2 I SCRI I SCRO I I r Clock source selection bit SCI data input pin enable bit SCI data output pin enable bit $ HITACHI 893 .--~------------ -~~- No. QA635-306A Type HD630SUO HD630SVO I Device Io 4S • 8S o 8M O16M DEvaluation kit, Emulator o Software OSD o SBC Theme SSR7 (SCI Interrupt Request Bit) Set Timing QuestionJ Classification Parallel Port Serial Port After 8-bit data transmitting or receiving through the SCI * Timer/Counter (serial I/O) is completed, SSR7 (SCI interrupt request bit) BUS Interface of the SSR (SCI Status Register) is set. At what timing is Interrupt this setting performed? A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I - SSR7 is set at the rising edge of the 8th CK (serial clock) as shown below. ~P<'ViOU" d.,. Serial clock (DS/CK) ~ Other Data Document Ou'pu' da<. Title I (D /Tx) ' ' I LSB MSB 3 ----./ Input data latch timing I I I 1 I I I (D/RX) SSR7 Reference Q & A Sheet ~ Supplement I SSR (SCI Status Register: $OOll ) 7 6 5 4 3 2 1 0 I· SsE SSR6 I SSRS I SSR4 I SSR3 1><1><1><1 SCI interrupt request bit ~HITACHI 894 No. QA635-307A Type HD6305UO HD630SVO I Device I oo 4S • 8S o 8M o 16M Evalua tion kit Emulator o Software DSD o SBC Theme Clearing SSR (SCI Interrupt Request Bit) Question I Classification Parallel Port '" Serial Port After data is transmitted or received through the SCI (serial I/O), SSR7 (SCI interrupt request bit) is set Timer/Counter to 1. At this time, i f 0 is set in SSR7 by software BUS Interface to clear the bit, is it possible to transmit or receive Interru~t the next data? A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I No. When 0 is set in SSR7 by software, this bit is cleared, and the next data transmitting and receiving can- not be performed. SSR7 is cleared under the following con- ditions. CDWhen data is read from or written into the SDR (SCI Data Regis ted. Other Data Document (After SSR7 is cleared and the octal counter is reset, Title I the next data transmitting/receiving is executed.) <1><1><1 LSCI interrupt request bit ~HITACHI 895 No. QA635-30SA Type HD6305UO HD630SVO I Device Io 4S .8S o SM O16M DEvaluation kit Emulator OSD o Software o SBC Theme Accessing SDR (SCI Data Register) Question I Classification Parallel Port Serial Port What will happen if data is read from or written into the * Timer/Counter SDR (SCI Data Register) while another data is being transmitted or received through the SCI (serial I/O)? BUS Interface Interrupt A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others AnswerJ Applicable Manual Tit1eJ Normal operation can not be guaranteed for either transmission or reception. Do not access the SDR during data transmitting or receiving since the SCI becomes disabled after the access (the MCU must be reset to use the SCI again). Other Data Document Title I Reference Q & A Sheet ~ QA635-312A Supplement I SDR (SCI Data Register: $0012) 7 6 5 4 3 2 1 0 Receive _I MSB I I I 1 I I I LSB I --Transmit ~HITACHI 896 No. QA635-309A Type HD6305UO HD6305VO IDevice Io4S • 8S o 8M o 16M DEvaluation kit Emulator o Software OSD o SBC Theme Transmitting and Receiving Data Simultaneously through Serial I/O Ques tion I Classification Para lIel Port Serial Port Is is possible to transmit and receive data simultaneously * Timer/Counter through the SCI (serial I/O) by using the internal clock for transmitting and the external clock for receiving, or BUS Interface vice versa? Interr~t A/D Converter Oscillator Reset Low Power Consu~tion EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I No. Only one clock source can be selected as the SCI transfer clock. Simultaneous data transmission and recep- tion using two transfer clocks are impossible. When a single clock source is used, data can be transmitted and received at the same time. Other Data Document Title I Reference J( & A Sheet ~ Supplement I ~HITACHI 897 Ne. QA635-310A Type HD6305UO HD6305VO IDevice Io4S • 8S o 8M D16M DEvaluation kit, Emulator o Software OSD o SBC Theme Notes on Receiving Data through SCI in External Clock Mode Question I Classification Parallel Port Serial Port What should we pay attention to when using the external * Timer/Counter clock to receive data through the SCI (serial I/O)? BUS Interface InterruJ>t A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I The external transfer clock source does not enable the receiving side to check when data is transmitted. Therefore, it is necessary to read out data in the SDR (SCI Data Register) as soon as the data is received, to prepare for receiving the next data. Whether 'or not receiving has been completed can be checked Other Data Document by an SCI interrupt or by testing bit 7 of the SSR (SCI Title I Status Register) by software. Reference Q & A Sheet ~ Supplement I SSR (SCI Status Register: $0011) 7 6 5 4 3 2 1 0 ISCSSR61 SSR51 SSR41 SSR31><1><1><1 SCI i",mup' «qU"" hi, (0' '0 '"q",," ) 1: Yes ~HITACHI 898 No. QA63S-3llA Type HD630SUO HD630SVO IDevice o 4S • 8S o 8M o 16M DEvaluation kit Emulator OSD o Software o SBC Theme SCI Operation in External Clock Mode Question I Classification Parallel Port Serial Port The SCI (serial I/O) is in external cLoc~mode; * Timer/Counter If the external clock is applied to the CK pin before the CPU writes/reads data into/from the SDR (Serial Data BUS Interface Register) after the one-byte data transmitting/receiving is Interrupt completed, will the SCI start the next data A/D Converter transmitting/receiving? Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer I Applicable Manual Title I No. The SCI does not start transmitting or receiving the next data until the CPU writes/reads data into/gom the SDR. That is, any clock signal applied to the CK pin before the CPU accesses the SDR will be ignored. Other Data Document Title I Reference Q & A Sheet ~ Supplement I The CK pin can also used SCRS SCR4 Clock DS pin as DS pin. I t is con- source trolled by bits 4 and S 0 0 - Used as I/O p.in (accordin~ of the SCR (SCI Control 0 1 - to the DDR) Register). 1 0 Internal Clock output (DDR output) 1 1 External Clock input (DDR input) ~HITACHI 899 No. QA63S-312A Type HD63CSUO HD630SVO I Device Io 4S • BS o BM o 16M DEvaluation kit Emulator o Software OSD o SBC Theme Initializing the Transfer Clock Generator Prescaler . QuestionJ Classification Parallel Port Serial Port The pres caler of the SCI transfer clock generator is ini- * Timer/Counter tialized by reading/writing data from/into the SDR (SCI Status Register) or by setting 1 in SSR3 (SCI Status BUS Interface Register bit 3). What is the difference of the initializa- Interrupt tion performed by these two methods? A/D Converter Oscillator Reset Low Power Consumption EPROM-on-chip Software Evaluation Kit Emulator SD Data Buffer Others Answer j Applicable Manual Ti tIe I There are differences in the following points. (1) When data is read/written from/into the SDR, the SCI octal counter is initialized at the same time the prescaler is initialized. This causes the SCI to start transmitting or receiving the next data. Other Data Document (2) When 1 is set in SSR3, only the prescaler is ini- Ti tIe I tialized. The SCI does not start data trasmitting/receiving. SSR3 is the bit to be used to initialize the prescaler when the transfer clock generator is utilized as Timer 2. Reference Q & A Sheet ~ QA63S-30BA Supplement I SSR (SCI Status Register: $0011 ) 7 6 5 4 3 2 1 0 I SSR7 I SSR6 I SSRS I SSR4 I SSR3C>Plementj SSR (SCI Status Register: $0011) I 7 6 5 4 3 2 1 0 I SSR7 I SSR6 I SSRS I SSR4 I SSR3 l>i'r'f-t--:.. D," ~ II rD. ~ ____-:..-==-.:..-:.= ==dJ+,v IE." IE. ".",' lAI IE. IA. I E. IS lA. I E. lAo. IE,~~~----~ i~:pL~~----~ HD •• OIYO I I I I I L - - -- ----- -----, ----------, I r I I +'V I EE-eFt I I I I PKM I I I U-tAO B I I I I I I I 10kO : I I IL .. _________ JI F, I I Cd) Others I I I I I I I I I I I I I I L _________ .__ _ Ca) Tone Transmitting Fig. 2.3 Interface Circuit Between the HD6305YO and ~HITACHI 958 (a) Tone transmitting (b) Receiving (c) Detecting circuit conditions (d) Others (d) Others i----------~~---------: I ! I _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _...I:_-'l."'kalr--H~ 0 ___ ~ 0 I !SetS8 80 0 i I ===~======L-E=}=DhJ.----- -- ----- J ---------l J~ .'7ko .7ko 1:* ~::J ,----"-,,,i Subscriber Line (e) Detecting Ci7cuit 'ko i : Conditionsr---~-~--~~;~--~--~ +,v~ -gsv-i ? I ~ ~ ~------~I rt-I--~-'" ~ I H~I r- CAC) : EE-CFtl l EE-CF' (AC) I P¥ 1_~vi2-", ~ Ii I H -+I- (AC) H1t- I--.;-=.·,,".:t!---...:L==-=:.r - - -- t===-='--=c:r t---=!=t.,""'f'--------t I!f +5 V 2'7kn 1o."I18V 11.X I:~ 1- -,-.'--k'n'======,- - (b) Receiving r-- DynaUilc-- - - - -l-rl--~If---------SW-'-(K-S-)--' I I ]il'~ M~~ MIC, ~~ MIe l I I I I KS ~0 - - - VS s,l'to"-__- I I - _ - j I f---:-tl-!!:,,~ OOTPUT I I ..... "" I 'I F ' v I I vs "I''ti~ JlIR\f'k"a,...,.___; L. , G~ I I T.Lt~·J~J< I ~Fli YI--T-"""",p:iF;---"i., I I ~~ : PKM ~ ~1O.a -.9 ~: I I I~:;~''''_'Ni'a=-____-; I I U-tAO? " -__________- ' m I~;n Rt 0.4071' i Ct : I ISRIDGE , ~,...~~,~.a""" IBRIDGE r 35 ..10~ __ f--H L'========= l~Jp 10 !!o,--~=-d.._.J AGC ::~ ...~ .. l..-~~___________________-=.:~ lIET+________-"....'l DTMF HA16808NI' 8 I PS 31 '----------=="T""---r-------~_"'I p IS_C.ri8 v.... ,."' ' _,..---+ GND)J-"'+--.."'""-=--- VSP 2(1 "Ska) lOOkn 3.3-1:' COMP~·~'~~~~::·:::J ~l----l-----------=F:.Jl"11 MUTE VIP ALT 27 100:. " SPOUT~fU=-t=~--fl '.a ~~t-7a ~LD BUF!~~~ ::~ lkn 2SCUS lOko.L 16 GRCT L,30 180 l~kn 21 LI ALC~M~~~~·~I~F--ff ~58 BUFF I N u ~ lookn ~ BRIDGE. IJ 2."kOO.o}SI'FJ REC, I" i" .:~ 16 BRIDGEt REel 22 c..lQn ~l'~.aY_-----------------r ~ . "Transmitting and Receiving Control Circuit" ~HITACHI 959 I (4) Pin Functions Pin functions at the interface between the HD630SYO and "Transmitting and Receiving Control Circuit" are shown in Table 2.2. Table 2.2 Pin Functions at the Interface Between the HD630SYO and "Transmitting and Receiving Control Circuit" Active Level Pin Name Input/ (High Device and Pin Program Section Name (HD630SYO) Output or Low) Function Name Label (a) Tone EO Output - Data for tone output HD61826 COLl PEDTR transmitting El Output COL~ E2 Output COL3 EJ Output Rowi E!\ output ROW~ ES Output ROW~ E§ Output ROW~ E7 Output Low ON/OFF switch for HS pin HS (b) Receiving Dl Input High Detect receiving Photo- Collecter PDDTR coupler (c) Detecting D2 ,Input Detect circuit conditions Photo- Emitter circuit coupler conditions D3 Input Photo- Emitter cout21er (d) Others D4 Input High Control hook switch Switch FS Output High Control relay Relay PFDTR F6 Output - Buzz Buzzer Note: "Active Level" in Table 2.2 indicates the following; High: logical 1 Low logical 0 logical 1 or logical 0 ~HITACHI 960 (S) Hardware Operation (a) Tone transmitting In this application system, port E of the HD630SYO outputs data corresponding to a telephone number to the HD6l826, which in turn outputs the corresponding tones. The HD6l826 outputs tone (O~9, *, #) corresponding to 7-bit input signal (ROWI~ROW4 and COLl~COL3). The relation between tone output and row/column input is shown in Fig. 2.4. For example, to output "2", set both ROWl and COL2 to High. Fig. 2.4 Relation Between Tone Output and Row/Column Input In this system, the HD6l826 is connected to the HD630SYO through photo-couplers. Thus, to output "2", set bits 1 and 3 of port E to High. Bit 7 of port E is also used to control the HS pin of the HD6l826. The interface circuit between port E of the HD630SYO and Row/Column/HS of the HD6l826 is shown in Fig. 2.S. ~HITACHI 961 I +5V 200S"l1 voo~ 16 2 .~h. Jd... 48 HS 17 200S"l3 14 E7 2A4 47 E6 46 ROW4 2 1Al 2 Y4 3 HS ~ 4 *~r.::.. .ll.. ..-- Row3 4 1Yl 18 ROW 200S"l5 12 ~ HS ES 45 lA2 HD6305YO ROW2 6 lA3 0 'd' lY2 16 ROW3 6 .~r.::.. .!..L I~ ROW4 E4 ROWI N 200S"l7 16 44 8 1A4 Ul l Y3 14 ROW2 10 ROW3 E3 ..... E2 43 COL3 11 2Al ,...'d' l Y4 12 ROWI 8 t~h. L I 15 ROW2" 42 COW 13 Ci 14 2A2 :II 2Y19 COL3 ROWI El EE-CF4 HD61826 41 CaLl 15 2Y2,7 COL2 13 COL3 EO 2A3 ,....l: IG 2Y315 coLi ~ COL2 200S"l1 16 --1l COLI ...!Q GND 2G~ 2 ~~[ 15 10 vss 200S"l3 14 '--- TIT 4 .~(.. .ll.. 200S"l5 12 6 ~~h. rli-- 200S"l7 10 8 ~~c.. r-- 9 EE-CF4 Fig. 2.S Interface Circuit Between Port E of the HD630SYO and Row/Column/ HS pin of the HD6l826 Interface timing between the HD630SYO (port E) and the HD6l826 (Row, Column, HS, OSC, MUTE, TONE) is shown in Fig. 2.6. I I , Pin name i 112" II 113" I I I (HD630SYO/HD6l826)I I I I I I EO / COLl ,I I I I I El/ COL2 II ,I I I E2/ COL3 I I I I I:I E3/ ROWl E4/ ROW2 I I I I I I I I I I I I I ES / ROW3 I I I I I I I I E6 / ROW4 I I I I I II E7/ HS I: II II I I I I OSC I : III I I I:I I I :111 I I I MUTE 11I \iI I I I I I I I I I I I I TONE Fig. 2.6 Tone Transmitting Interface Timing ~HITACHI 962 (b) Receiving When this telephone is called from another telephone, a ring signal is input to the HA16808NT from the subscriber line. Ring signal output from the HA16808NT is input to bit 1 of port D through a photo-coupler. When bit 1 of port D is "1", the HD6305YO determines a receiving" condition. Interface timing for the ring signal, photo-coupler, and port is shown in Fig. 2.7. Pin name HA16808NT { OUTPUT _ _--J Photo-coupler ---~ L Fig. 2.7 Receiving Interface Timing ~HITACHI 963 (c) Detect circuit conditions In this application system, circuit conditions are detected using features of the subscriber line. Two subscriber lines are connected to this system as shown in Fig. 2.8. I sy,t~11- Thi' ------0: Subscriber line Fig. 2.8 This System and Subscriber Line When the handset is down, both subscriber lines are Low. When -the handset is up to call, either subscriber line is High. After the tones are output and the call answered, the subscriber line which was previously High goes Low, and that which was Low goes High. When the conversation is over and the handset is put down, both sub- scriber lines go Low again. In this system, the changing High and Low states of the subscriber lines are input to bits 2 and 3 of port D of the HD6305YO through photo- couplers. As mentioned above, using these data, various circuit conditior can be detected. ~HITACHI 964 (i) When handset is up to call 35 High 02 47M2 03 36 Low 47kQ +5V +5V H06305YO ljJF ljJF 4 4 Photo- coupler Q) 1 Fig. 2.9 Circuit Condition When Handset is Up to Call I I Pin name Handset { Hook switch I I I I Photo-coupler OJ I I I I Photo-coupler G) I I I I I I I HD6305YO 1"' 03 I I I I I I Handset is up. Fig. 2.10 Interface Timing When Handset is Up to Call ~HITACHI 965 I (ii) When call is answered (conversation in progress) 35 Low 02 47H2 High 03 36 47kSi +5V +5V H06305YO l\-lF lpF 4 4 Photo- coupler 1 Q) Fig. 2.11 Circuit Condition When Call is Answered Pin name I Handset { Hook switch ------------~i--------------­ Photo-coupler CD i I L.I_ _ _ _ _ _ _ _ _ _ _ __ I I I I Photo-coupler (6) --------------11--' I H06305YO 1°' 03-------------r:--~ ! Answered Fig. 2.12 Interface Timing When Call is Answered ~HITACHI 966 (d) Others (i) Control relay When tone is output using on-hook dialing, bit 5 of port F is set to High and relay ON. +5V F 54 Low 2kSl 5r-----~vvv-~ 2SC458 1 HD630SYO I I Subscriber I Line I I I I »--+---~----o To Diode. Bridge To Diode Bridge Fig. 2.13 Relay OFF +5V 54 High 2kSl o o F5r-------~Ar--ri HD6305YO Subscriber Line To Diode Bridge To Diode Bridge Fig. 2.14 Relay ON ~HITACHI 967 (ii) Control hook-switch When tone is output using on-hook dialing (handset is down), this switch is ON. If High is input to bit 4 of port D, software forces bit 5 of port F to Low to turn relay OFF. Fig. 2.15 Control Hook Switch (iii) Buzz If a call is answered during automatic retrying, software outputs a pulse from bit 6 of port F to generate buzzing. PKM 24-4AO HD6305YO 55 F6~--------------~ Fig. 2.16 ~uzz ~HITACHI 968 2.2 Control Circuit for Storing and Retrieving Telephone Numbers in External RAM 8 x 8 v A Circuit Conditions l;t----- r - - - 1 -() Key Matrix A ~ Detector I\r- 'Ij Speech ->() Network, \ Tone k - -V Generator r-v '--- HD6305YO ~ '---K RAM for ~ Storing Tele- ~ phone Numbers Ill' 0- LA N-v' LCD Module Fig. 2.17 "Control Circuit for Storing and Retrieving Telephone Numbers in External RAM" Part (1) Hardware and Operation Description (a) The HD6305YO controls the HM6264AP external RAM for storing and retrieving telephone numbers. (b) The HM6264AP is an 8l92-word x 8-bit static RAM. (2) Microcomputer Applications (a) I/O ports of the HD6305YO control the HM6264AP. (b) The data bus is controlled by port A, lower 8 bits of the address bus by port B, and upper 5 bits of the address bus by port E, bits 0'1.04. (c) Control pins of the HM6264AP are controlled by port E, bits 5'1.07. ~HITACHI 969 ._--- ---------- -.---~.-,-~~- -- (3) Circuit Diagram The interface circuit between the HD6305YO and HM6264AP is shown in Fig. 2.1S. kJ B7 17 3 A7 +5v B6 IS 4 A6 B5 19 5 AS VCC 20 6 A4 B4 7 CSI ~ 21 B3 S A3 22 B2 23 9 A2 GND ~ Bl 24 10 Al BO AO TiT E7 48 26 CS2 E6 47 27 WE E5 46 22 OE E4 45 2 HD6305YO 23 Al2 HM6264AP E3 44 43 21 All E2 24 AI0 42 El 25 A9 41 EO AS A7 9 19 I/OS A6 10 18 1/07 AS I I 17 1/06 12 16 A4 1/05 13 15 A3 1/04 14 13 A2 15 12 1/03 Al 16 11 1/02 AO 1/01 Fig. 2.1S Interface Circuit Between the HD6305YO and HM6264AP ~HITACHI 970 (4) Pin Functions Pin functions at the interface between the HD630SYO and HM6264AP are shown in Table 2.3. Table 2.3 Pin Functions at the Interface Between the HD630SYO and HM6264AP Active Level Pin Name Input/ (High Program (HD630SYO) Output or Low) Function HM6264AP Label Input/ PADTR Ao Data lines I/Ol Output Input/ Al I/0 2 Output Input/ A2 Output I/03 Input/ A3 Output I/04 Input/ A4 Output I/OS Input/ AS Output I/06 Input/ ~ Output I/07 Input/ A7 Output I/OS BO Output Lower S bits of address lines AO PBDTR Bl output Al B2 Output A2 B3 Output A3 B4 Output A4 BS Output AS B6 Output ~ B7 Output A7 EO Output Upper S bits of address lines As PEDTR El Output Ag E2 Output A10 E3 Output All E4 Output A12 ES Output Low Output enable signal OE E6 Output Low write enable signal WE E7 Output High Chip select CS2 Note: " Active Level" in Table 2.3 indicates the following; High: logical 1 Low logical 0 logical 1 or logical 0 ~HITACHI ~--~- - ~~------ 971 I (5) Hardware Operation Upper 3 bits of port E control CS2, 00, and WE of HM6264AP. The interface timing is shown in Fig. 2.19. (a) Write Address ~ __________________ --------------------J:><:~--------- Pin name (HM6264AP) I I I I I I WE ----~I~------------------~ I I I I Din ------T:------------------------~<:~____~_________________ I I I Set address Write data (b) Read Address ~ ----------------------------------J:><:~-------- I ____ Pin name (HM6264AP) Dout --T-----------------~<~~ ________>_ Set address Read data Fig. 2.19 HD6305yO~HM6264AP Interface Timing • HITACHI 972 2.3 Driving the L:...c;.uid Crystal Display Module (H2572') 8 x 8 " I;t-- roo--- ~ Key Matrix A y A Circuit Conditions Detector ~ rt the, same i I I I ,-- ----!----.-{ Sampled data not the same I I I I 1 .---------~ Sampled data is the same Key input OFF determined Determined "ON" Fig. 2.25 Chatter Prevention Timing ~HITACHI 980 In chatter prevention program, key input signals are sampled every 16 ms. If the same key input signal is sampled three times consecutively, key input data is established. In Fig. 2.25, since data sampled at CD C1! @ @) are not the same three 'V 'V times consecutively, the program regards them as chatter and ignores them. Data sampled at G)'V ®, however, a:r:e the same and is thus determined as valid key input. ~HITACHI 981 I Section 3. Software Description This chapter describes the software configuration of the Intelligent Telephone, the system model for this APPLICATION NOTE. 3.1 Transition Diagram The transition diagram is shown in Fig. 3.1. The symbol 0 indicates pushing a key. For example, !EXECUTE! simply indicates pushinglEXECUTij key. Note: In case of "Clear Accumulated Charge", if !CLEAR A.C.! key is pushed, accumuiated charge display remains unchanged during this process. Fig. 3.1 ~HITACHI' 982 ________ } The __ se three " _"_ have the same ll.nes meaning_ Transiti on Diagram ~HITACHI 983 3.2 Program Module Configuration The programs for the Intelligent Telephone consists of the following three functional groups. (1) Processing programs controlled by the main program. (Initialize System Mode Process· Check Input Data· Error Process). (2) Interrupt Programs Controlled by Timer 1. (Count Buzzing Time • Count Time for Displaying Information on LCD). (3) Interrupt Programs Controlled by Timer 2. (Key Scan· Buzzing· Control Dialing Circuit). ** *" *" *" * ~HITACHI 984 These three functional groups make up a triple hierarohy of program modules. Fig. 3.2 shows program module configuration and program module names (e.g.:Main Program), labels (e.g.:MAINPR), and module numbers (e.g.:O), which are used in Program Module Description. * called from modules marked * modules marked *~ ~HITACHI 985 3.3 ;; SOFl'WARE DESCRIPTION" Format (1) Program module configuration and program module description. The program .nodules are explained in "3.2 Program Module Configuration" and " 3.4 Program Module Description". This part explains how these two parts are described and how the program modules are referred to. (a) Program module configuration Each program module is described as shown. ("Enter a Telephone Number" module is used as an example to explain the format. (3) Program details (a) The internal RAM used in the program is listed in "3.5 RAM Table". Some special RAM used as flags are listed in "3.6 Flag Table". (b) The subroutines used in the program are listed in "3.7 Subroutine Table". (c) Information on the RAM for storing telephone numbers is described in "3.8 RAM Memory Map for Storing Telephone Numbers". (d) Port labels used in program routines are listed in "3.9 Ports Label Table". ~HITACHI 986 (2) RAM description format (a) RAM used by the programs is described in the following format. Example : KEYDAT (RAM) Indicates "KEYDAT" is a label in RAM. (b) RAM used as flags is described in the following format. Example: (0, FLAG) -------- Indicates bit position 0 of "FLAG". (b) Program module description lts~'~H -~J .. (j)program modules location Depending on program In the case of the module configuration, third module, the MOOULE NO, ~.4 L1\8EL in the case of the upper two modules IS highest hierarchy name is described module, the module I s here. On ~ key (firrt proc .... l and IEXECUTEI key (second proceell) input, enter n. . . and telephone numbau,. name is described Hierarch of program here; in the case of modules are indicated tal In thoo firet process (TRMFLG .. O), delo!U calendar • tilne ond diepl"y the second highest to show from where cur~r to pApare for data inp1.l.t. Searching for elllPty -space in RJ\M module, the upper the program module is for ltorin; telephone number. b also perfot1Ded. module I s name and its called. (h) In the . .cond p~ces. (TRMFLG-ll • enter nlUll. and telephone n\llllbf!r in RNt module I s name is for stori,,'i telephone n\$lber. Afta" .ntarin<;. mode fla<;l and othe:r described here. RAII\'\.""~.cle.red. (2) Argument. StorageLO"ation of Bytes ®Arguments Tone outputting nag Proc ••• fbi (4, WAIT3) TRHn.G (RAM) , (1 bit) Entry=Arguments that must li:nM (RAM) be loaded before ~·~l.phan. nlllllber LCIl dillpl ..y I\AM LCPM (1\AM1 " program module CURAIlP (RAM) 1 CUuor poSition Seuch direction flag (2,Ft.AG) (lbitl execution. Name.telephone number (RAM for etoring 29 Returns=Arguments that are telephonll ,ul!llber) stored after program module execution. ® Subroutine When process is executed by using subroutines, the flowchart is described as below. Function executed by sub- routine (Even if more than two subroutines are used, (In some cases, more only one function is than two subroutines executed. ) are used.) @ Label in the program Indicate the label in the program. ~HITACHI 987 I 3.4 Program Module Description Each program module in "3.2 Program Module Configuration" is explained in this section. All the module's functions are shown in Table 3.1. Table 3.1 Program Module Function Module Program Module Label No. Function Main Program MAINPR o Controls the Intelligent Telephone Initialize System SYSINT 1.0 Initializes the system Mode Process MODE 2.0 Executes the mode process Set Charge Display Request MOD 10 2.1 Sets charge display request flag Flag Set Accumulated Charge MOD20 2.2 Sets accumulated charge display Display Request Flag request flag Set Elapsed Time Display MOD30 2.3 Sets elapsed time display request Request Flag flag Enter a Telephone Number MOD40 2.4 Enters names and telephone numbers Review/Modify/Delete a MOD50 2.5 Reviews/Modifies/Deletes names and Telephone Number telephone numbers Prepare for Speed Dialing MODSO 2.6 Prepares for speed dialing Enter a Speed Dial Number MOD 90 2.7 Enter speed dialing numbers Prepare for Redialing MODIOO 2.S Prepares for redialing Prepare for Retrying MOD110 2.9 Prepares for retrying Prepare for Normal Dialing MOD120 2.10 Prepares for normal dialing Set Calendar & Time MOD 130 2.11 Sets correct calendar & time Set Rate for Charge MOD140 2.12 Sets charge per time Clear Accumulated Charge MOD150 2.13 Clears current accumulated charge End MOD160 2.14 Clears mode flag and RAM used Check Input Data CHECK 3.0 Checks input data and moves cursor Check for Normal Dialing CHEKl 3.1 Checks if correct data for normal dialing Check for Speed Dialing CHEK2 3.2 Checks if correct data for speed dialing Check for Entering Speed CHEK3 3.3 Checks if correct data for entering Dial Number speed dial Check for Storing Telephone CHEK4 3.4 Checks if correct data for storing Numbers telephone numbers Check for Setting Calendar CHEK5 3.5 Checks if correct data for setting & Time, Charge calendar & time, charge Move Cursor to Left or CURLR 3.6 Moves cursor to left or right Right Move Cursor to 21st Digit MVECUR 3.7 Moves cursor to 21st digit Error Process ERROR 4.0 Executes error process Control Timer 1 TIMERl TIO Controls timer 1 Count Buzzing Time BUZC Tl1.0 Counts buzzing time Count Time for Displaying FIGURE T12.0 Counts time or charge for LCD Information on LCD display Control Timer 2 TIMER2 T20 Controls timer 2 Key Scan KSSSCN T21.0 Executes SxS key scan Buzzing BUZZ T22.0 outputs buzzing Control Dialing Circuit TELMN T23.0 Controls dialing While Talking TELMIO T23.1 Tests if talking While Receiving TELM20 T23.2 Tests if receiving Generate Tone TELM30 T23.3 Performs tone output ~HITACHI 988 ---Table 3.1 Program Module Function (cont.l Module Program Module Label No. Function Relay ON TELM40 T23.4 Connects line using relay While Retrying TELMSO T23.S Executes retrying Connect Lines TELM60 T23.6 Prepares for dialing Display on LCD LCD EX1.O Displays figure on LCD Microcomputer ~ Telephone OUTDAT EX2.0 Moves data from microcomputer to RAM Numbers Storing RAM Microcomputer ~ Telephone INPDAT EX2.1 Moves data from RAM to microcomputer Numbers Storing RAM $ HITACHI 989 II II Main . program Main Program MODULE NO. o LABEL MAINPR (1) Function "Main program" controls the major processes of the Intelligent Telephone. It first initializes the system, and after enabling timer interrupts, waits for key input. If any key is depressed, data is input identifying the key. The main program divides this data into mode and character types. If any error occurs during mode and character processing, the error flag is set and the error process routine is executed. (Relation between the main program and key data is described in "Note".) $ HITACHI 990 Main Program Main Program MODULE NO. o LABEL MAINPR (2) Flowchart Program module SYSINT Initialize system No Character MAINI Program mode CHECK Input data Program module check MODE Mode process Yes MAIN3 Program module No ERROR Error process I4AIN4 Reinitialize flag for key input ~HITACHI 991 II Main Program Main Program MODULE NO. LABEL MAINPR ° Note: Main program and key data The keyboard configuration for this system is shown in Fig. 3.3. The data shown above each key identifies which key is depressed. (These are not ASCII.) This data, called "key data", is input to the main program which divides them into mode and character types for respective processing. Character keys r--------------------------------------J------l : i Data identifY in g-l---I@llsoB 2 1 1Sc0 3 1 1SOD 4 1 1$E051 1S0161 1S02 7 1 1S03 8 1 : which key is : A : depressed I : (Key data) I : Is091 F ISgAI IS~BI Is~cl IS~DI IS~EJ IS~FI Is~ol I I i I I S~ll I S~2J I S~31 I S~41 I S;51 IS~61 S~ 1 71 I S~81 i IS!91IS~AIIS~BIIS~cl fS;DIIS~EIIS~FIIS;OI ! 19~11 1$~21 19;31 1S~41 IS~51 I$;61 I S~71 I~:~ 1 I I r,------------------J i_____________________________ J I:~;.I f:·~ R~j9 I::~ 1 ~ @J S3A S3B EXE- SET coT SET CHARGE Ig:1 END CUTE These keys Mode keys are not used in this system. Fig. 3.3 Keys ~HITACHI 992 Main Program ~Initialize system] Initialize System MODULE NO. 1.0 LABEL SYSINT (1) Function "Initialize System" initializes timers, ports, and internal RAM. If necessary, it initializes RAM for storing telephone numbers. Before initializing RAM for storing telephone numbers, test its check data fields so as not to clear stored telephone numbers unnecessarily. After checking data, even if only one check data field is invalid, RAM is cleared and new check data is entered again 'for reinifialization. If all the check data are valid, data in RAM is determined to be valid and RAM is not cleared. (2) Arguments Contents Storage Location No. of Bytes Entry Returns • HITACHI 993 I , . . - - - - - - - " , •• e , Main Program r-1In1t1aL1ze systeml Initialize System MODULE NO. 1.0 LABEL SYSINT (3) Flowchart SYSINT SYSINT Initialize timers Initialize ports ARGINT END Initialize internal RAM ~ Valid Invalid RAMCL RAMCLR 1 Clear RAM for storing telephone No. I RAMCLE RTS ~HITACHI 994 Main Program H Mode Process I II Mode Process MODULE N O . 2 . ° LABEL MODE I I (1) Function "Mode Process" is a driver routine for executing the various mode processes corresponding to key data. Before branching to a mode, the mode flag (Note 1) is defined first. A particular mode is executed depending on this mode flag. (2) Arguments Common entry and return arguments for all the mode processes are shown below. Particular entry and return arguments for each mode are explained in each mode's description in detail. Contents Storage Location No. of Bytes Entry Key data KEYDAT (RAM) 1 Mode flag MODFLG (RAM) 1 Process flag TRMFLG (RAM) 1 Returns Mode flag MODFLG (RAM) 1 Process flag TRMFLG (RAM) 1 Error process request flag (0, ERFLG) (1 bit) ~HITACHI 995 I Main Program ~ Mode Process I Mode Process I MODULE NO. 2.0 LABEL MODE (3) Flowchart Yes No Define mode Increment Set error flag corre- process sponding to process request key data flag flag MODE 4 Jump to correspond- ing module MODEF ~HITACHI 996 Main Program H Mode Process Mode Process MODULE NO. 2. 0 LABEL I MODE Notes: 1. Key data input to "Mode Process" Key data (KEYDAT) is checked as to whether it is the IEXECUTE!key or another key. If another key is input, key data is changed to mode flag (MODFLG) (If the!EXECUTE! key, refer to the next page). Jump to the corresponding module is executed depending on this mode flag. The mode flag and corresponding modules are shown in Table 3.2. Table 3.2 Mode Flag and Corresponding Modules of "Mode Process" Key data Mode flag Module (KEYDAT) (MODFLG) Label Function $2E $1 MOD10 Set charge display request flag $2F $2 MOD20 Set accumulated charge display request flag $30 $3 MOD30 Set elapsed time display request flag $31 $4 MOD40 Enter a telephone number $32 $5 MOD50 Review/Modify/Delete a telephone number $33 $6 MOD 5 0 ___$_3_4___ lchangS>____$_7____ lcalt>_M_O_D_5_0________________________--------------- $35 $8 MOD80 Prepare for speed dialing $36 $9 MOD90 Enter a speed dial number $37 $A MOD100 Prepare for redialing $38 $B MODllO Prepare for retrying $39 $C MOD120 Prepare for normal dialing $3A $0 MOD130 Set calendar & time $3B $E MOD140 Set rate for charge $3C $F MOD150 Clear accumulated charge $30 $10 MOD160 End ~HITACHI 997 Main Program ~de Process Mode Process MODULE NO. 2.0 LABEL MODE 2. How to process IEXECUTE ! key input: For example, when entering a telephone number, the following procedure is performed as below. Push I ENTER 1 k e y _ Input name and - - -......... Push I EXECUTE I key telephone number This procedure corresponds to "First" and "Second" processes performed by the module corresponding to the defined mode flag. Push ~key _Input name and - P u s h IEXECUTElkey n telephone number First process I n Second process U Define mode (Processed by "Check input data" U Increment module) flag and process flag and jump to MOD40 jump to MOD40 for controlling for processing LCD input and input name and display. telephone number. The !EXECUTE! key may never be depressed at the beginning of a module. If it is depressed, the program processes it as an error.) o When a mode flag except for the !EXECUTElkey is depressed, the program regards it as "First process". o When the IEXECUTE I key is depressed, the program regards it as "Second process". ~HITACHI 998 Main Program ~ Mode Process I Set Charge Display Request Flag MODULE NO. 2.1 LABEL ""--;::=======: MOD 10 (1) Function On IDISPLAY CHARGEI key input, clear calendar & time display request flag and set charge display request flag to display charge as counted by timer 1. (2) Arguments Contents Storage Location No. of Bytes Entry Returns Calender & time display request (1, FLAG) (1 bit) flag Charge display request flag (7, FLAG) (1 bit) (3) Flowchart MOD10 MOD10 Clear calendar & time display request flag Set charge display request flag RTS ~HITACHI 999 --------- - I ---- Main Program ~ Mode Process Set Accumulated Charge Display Request Flag I MODULE NO. I. 2.2 I LABEL I MOD20 (1) Function On I DISPLAY ACCUMULATED CHARGE I key input, clear calendar & time display request flag and set accumulated charge display request flag to display accumulated charge as counted by timer 1. (2) Arguments Contents Storage Location No. of Bytes Entry Returns Calender & time display request (l, FLAG) (l bit) flag Accumulated charge display (6, FLAG) (l bit) reques!: flag (3) Flowchart MOD20 MOD20 Clear calendar & time display request flag Set accumulated charge display request flag RTS ~HITACHI 1000 Main Program H Mode Process Set Elapsed Time Display Request MODULE NO. 2.3 LABEL MOD30 Flag (1) Function On I DISPLAY ELAPSED TIMEI key input, clear calendar & time display request flag and set elapsed time display request flag to display elapsed time as counted by timer 1. (2) Arguments Contents Storage Location No. of Bytes Entry Returns Calender & time display request (1, FLAG) (l bit) flag Elapsed time display request (3, FLAG) (1 bit) flag (3) Flowchart MOD30 MOD30 Clear calendar & time display request flag Set elapsed time display request flag RTS ~HITACHI 1001 I Main Program H Mode Process I Enter a Telephone Number I MODULE NO. 2.4 LABEL MOD40 (l) Function On [ENTERJ key (first process) and IEXECUTEI key (second process) input, enter names and telephone numbers. (a) In the first process (TRMFLG=O), delete calendar & time and display cursor to prepare for data input. Searching for empty space in RAM for storing telephone numbers is also performed. (b) In the second process (TRMFLG=l), enter name and telephone number in RAM for storing telephone number. After entering, mode flag and other RAM used are cleared. (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (1 bit) Process flag TRMFLG (RAM) 1 Name·te1ephone number LCDM (RAM) 40 Returns LCD display RAM LCDM (RAM) 40 Cursor position CURADP :'(RAM) 1 Search direction flag (2, FLAG) (1 bit) Name·telephone number (RAM for storing 29 telephone number) ~HITACHI 1002 Main Program H Mode Process Enter a Telephone Number MODULE NO. 2.4 LABEL MOD401 (3) Flowchart Yes No No LCD Clear LCD display TOROKU Enter name Define and telephon number cursor position END Set search Clear mode direction flag and flag to find RAM used empty space KENSAK LCDMCR Find empty space MOD42 ~HITACHI 1003 Main Program ~ Mode Process Review/Modify/Delete a Telephone Number MODULE NO. 2.5 LABEL MODSO (l) Function On IENTERI/IMODIFyl/IDELETElkey input, review/modify/delete a telephone number previously entered and stored in RAM. To modify or delete a telephone number, the desired data must first be reviewed, after which the previously specified process is executed. (a) In the first process (TRMFLG=O), clear the display and define cursor position. (b) In the second process (TRMFLG=l), display the first telephone number to be reviewed. (c) In the third process (TRMFLG=2), corresponding to EJ key or 1 ('-I key input, locate the desired data. In this process, IEXECUTEI key is not depressed, however sub-processes for reviewing data are instead determined by the "Input Data Check" routine. Reviewing of data is continued unuil the desired data is found. (d) In the fourth process (TRMFLG=3), determine whether reviewing is completed, or modifying or deleting data. (i) Review ••.• In the fourth process (TRMFLG=3), complete reviewing and clear mode flag, process flag, and RAM used. (ii) Modify In the fourth process (TRMFLG=3), display data to be modified and enable cursor movement. In the fifth process (TRMFLG=4), store modified telephone number in RAM for storing telephone number and clear mode flag, process flag, and RAM used. (iii) Delete ••.• In the fourth process (TRMFLG=3), delete desired data and clear mode flag, process flag, and RAM used. $ HITACHI 1004 Main Program ~ Mode Process '---;::======;---' Review/Modify/Delete a Telephone MODULE NO. 2.5 LABEL MOD50 Number (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (1 bit) Process flag TRMFLG (RAM) 1 Reviewing data LCDM (RAM) 40 Key data KE"1DAT (RAM) 1 Modified data LCDM (RAM) 1 Returns LCD display RAM LCDM (RAM) 40 Cursor position CURADP (RAM) 1 LCD display pointer LCDMP (RAM) 1 Cursor movement (7, BZRFLG) (1 bit) disable/enable flag Search direction flag (2, FLAG) (1 bit) Modified/deleted data (RAM for storing 29 telephone number) (3) Flowchart No ~HITACHI 1005 .! Main Program H Mode Process Review/Modify/Delete a Telephone MODULE NO. 2.5 LABEL MODSO Number Yes No Yes No No LCD Display data to be modified TOROKU END Enter Clear mode modified flag and data Set cursor RAM used TOROKU movement Delete enable flag desired data END Clear mode flag and END RAM used Clear mode flag and RAM used 1 MOD7F ~HITACHI 1006 Main Program ~ Mode Process Prepare for Speed Dialing MODULE NO. 2.6 LABEL I MOD80 (1) Function (Note) On I SPEED DIALI key (first process) and ISPEED DIAL CODE I (second process) input, load telephone number corresponding to desired speed dial number from RAM for storing telephone number. Actual tone output, however, is executed hy timer 2. Note: I In this case, EXECUTE I key is not depressed, however sub-processes for reviewing data are instead determined by the "Input Data Check" routine. (a) In the first process (TRMFLG=O), clear display and display "NO.? ". (b) In the second process (TRMFLG=l), display telephone number corresponding to desired s~eed dial code and set tone output request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (l bit) Process flag TRMFLG (RAM) 1 Speed dial code LCDM (RAM) 40 Returns Telephone number corresponding LCDM (RAM) 40 to desired speed dial code Cursor position CURADP (RAM) 1 LCD display pointer LCDMP (RAM) 1 Tone output request flag (1, BZR) (1 bit) Tone outputting flag (4, WAIT3) (l bit) ~HITACHI 1007 I loiain Program H Mode Process I Prepare for Speed Dialing I MODULE NO. 2.6 I ( LABEL MOD80 (3) Flowchart Yes No LCDMCR LCD Clear LCD display Set ASCII to display "NO. " LCD Display TAN "NO. ? Review tele- phone number corresponding to desired speed dial code Define cursor Set tone position output request flag Set tone outputting flag MOD8S • HITACHI 1008 Main Program H Mode Process Enter a Speed Dial Number MODULE NO. 2.7 LABEL MOD90 (1) Function On IENTER SPEED DIAL I key (first process) and IEXECUTEI key (second and third process) input, enter speed dial to RAM for storing telephone number. (a) In the first process (TRMFLG=O), clear calendar & time and display cursor. (b) In the second process (TRMFLG=l), display speed dial code and display cursor for telephone number input. (c) In the third process (TRMFLG=2), enter speed dial code and corresponding telephone number. Then clear mode flag, process flag and RAM used. (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag l4, WA.L'l'Cl) (i bit) Process flag TRMFLG (RAM) 1 Speed dial code . telephone LCDM (RAM) 40 number Returns LCD display RAM LCDM (RAM) 40 Cursor position CURADP (RAM) 1 LCD display pOinter LCDMP (RAM) 1 Telephone number (RAM for storing 9 telephone number) ~HITACHI 1009 II Main program H Mode Process I Enter a Speed Dial Number I MODULE NO. 2.7 LABEL MOD90 (3) Flowchart No Yes No LCDMCR LCD Clear LCD LCD display Display "* * LCD Enter Display telephone cursor No. END Clear mode flag and RAM used MOD94 ~HITACHI 1010 Main Program ~ Mode Process Prepare for Redialing MODULE NO. 2.81 LABEL I MOD100 (1) Function On IREDIAL Ikey input, load the telephone number, previously output, from RAM for redialing. Actual tone output, however, is executed by timer 2. (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (1 bit) Telephone number previously MEMO (RAM) 21 output Returns Telephone number for redialing LCDM (RAM) 40 Tone output request flag (1, BZR) (1 bit) Tone outputting flag (4, WAIT3) (1 bit) 101~,_1 ~HITACHI Main Prog:r"am H Mode Process I Prepare for Redialing I MODULE NO. 2.8 LABEL MOD100 (3) Flowchart ( MOD100 M~~y_e_s~ ________ ~ No LCDMCR LCD Clear LCD display LCD Display tele- phone number for redialing Set tone output request flag Set tone outputting flag MOD103 RTS ~HITACHI 1012 Main Program H Mode Process Prepare for Retrying MODULE NO. 2.9 LABEL I MOOllO (1) Function On IRETRY I key input, load the telephone number, previously output, from RAM for retrying. Actual tone output, however, is executed by timer 2. (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (1 bit) Telephone number previously MEMO (RAM) 21 output Returns Telephone number for retrying LCOM (RAM) 40 Retry output request flag (0, BZRFLG) (1 bit) (3) Flowchart MOOllO MOO~ Yes ~~~~--------~ No LCOMCR Ud2 Clear LCD display LCD Display tele- phone number for retrying Set retry output request flag Mooll3 ( RTS ~HITACHI 1013 I Main Program H Mode Process I Prepare for Normal Dialing I MODULE NO. 2.10 LABEL MOD120 (1) Function On IDIALI key input, prepare for normal dialing. Actual tone output, however, is executed by timer 2. (2) Arguments Contents storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (1 bit) Returns LCD display RAM LCDM (RAM) 40 Cursor OFF CURADP (RAM) 1 RAM for redialing MEMO (RAM) 21 Tone output request flag (1, BZR) (1 bit) I (3) Flowchart MOD120 oo~ urin tone output? Yes No LCDMCR LCD -- Clear LCD display I Cursor OFF I MEMCLR Clear RAM for redialing I Set tone output request flag 1 MOD121 I RTS ~HITACHI 1014 Main Program H Mode Process Set Calendar & Time MODULE NO. 2.11 LABEL I MOD130 (1) Function I On I SET CALENDAR & TIMEI k8Y (first process) and IEXECUTE key (second process) input, set calendar & time. (a) In the first process (TRMFLG=O), clear calendar & time display request flag and display the current calendar & time. (b) In the second process (TRMFLG=l), determine whether or not the modified data is correct. If data is correct, set modified calendar & time and clear mode flag, process flag, and RAM used. If incorrect, wait for modified data input again. (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (1 bit) Process flag TRMFLG (RAM) 1 Modified calendar & time LCDM (RAM) 40 Returns Calendar & time display (1, FLAG) (1 bit) request flag Calendar & time to be LCDM (RAM) 40 modified Calendar & time modified CALNDR (RAM) 5 and determined to be correct ~HITACHI 1015 Main Program H Mode Process Set Calendar & Time I MODULE NO. 2.11 LABEL MOD130 (3) Flowchart No No Clear calendar & time display request flag (Note) CALSHU Determine whether or not SHUCAL data is right LCD Display calendar 8. time to be modified END Clear mode flag and RAM used Note: Determine whether or not modified data is correct format as calendar & time. For example, 30:65:01 is not correct format for time. If data is correct, set modified calendar & time. If incorrect, store "0" in TRMFLG (RAM). ~HITACHI 1016 Main Program H Mode Process Set Rate for Charge MODULE NO. 2.12 LABEL I MOD140 ( 1 ) Func tion I I I On ISET CHARGE key (first process) and EXECUTE key (second process) input, set charge per unit time. (a) In the first process (TRMFLG=O), clear calendar & time display request flag and display the current charge per unit time. (b) In the second process (TRMFLG=l), determine whether or not the modified data is correct. If data is correct, set modified charge per unit time and clear mode flag, process flag, and RAM used. If incorrect, wait for modified data input again. (2) Arguments Contents Storage Location No. of Bytes Entry Process flag TRMFLG (RAM) 1 Modified charge per time LCDM (RAM) 40 Returns Calendar & time display (1, FLAG) (1 bit) request flag Charge per time to be LCDM (RAM) 40 modified Charge per time modified ADDRAT (RAM) 4 and determined to be SEC (RAM) 2 correct ~HITACHI Main Program H Mode Process I Set Rate for Charge I MODULE NO. 2.12 LABEL MOD140 (3) Flowchart No No Clear calendar Note: & time display Determine whether or not request flag RATSET (Note) modified data is correct Determine format as charge per time. whether or not If data is correct, set data is right modified charge per time. Display charge per time to be If incorrect, store "0" modified in TRMFLG .(RAM). END Clear mode flag and RAM used MOD144 RTS ~HITACHI 1018 Main Program H Mode Process Clear Accumulated Charge MODULE NO. 2.13 LABEL MOD150 (1) Function I I On CLEAR ACCUMULATED CHARGE key input, clear the current accumulated charge. (2) Arguments Contents Storage Location No. of Bytes Entry Returns Accumulated charge TOTAL (RAM) 4 (3) Flowchart MOD150 MOD150 Store $00 in RAM for accumu- lated charge to clear RTS ) $ HITACHI 1019 Main Program H Mode Process I End I MODULE NO. 2.14 LABEL MOD160 (1) Function On I ENDI key input, clear mode flag and the internal RAM used in Mode Process. (2 ) Arguments Contents Storage Location No. of Bytes Entry , Returns RAM used in Mode Process The internal RAM (3) Flowchart MOD160 MOD160 END -- Clear RAM used in Mode process ( RTS ~HITACHI 1020 r Main Program H Check Input Data I Check Input Data MODULE NO. I 3.0 LABEL CHECK (1) Function "Check Input Data" determines whether key data is character or cursor movement at the beginning. In the case of characters, a check process is executed corresponding to the previously defined mode flag. In the case of cursor movement, a move process is executed corresponding to the key data (Refer to "Note"). (2) Arguments Common entry and return arguments for all the check input data processes are shown below. Particular entry and return arguments for each checking data are explained in each checking data's description in detail. Contents Storage Location No. of Bytes Entry Key data KEYDAT (RAM) 1 Mode flag MODFLG (RAM) 1 Calendar & time display (1, FLAG) (1 bit) request flag Returns ASCII code KEYSET (RAM) 1 ~HITACHI 1021 I Main Program H Check Input Data I Check Input Data MODULE NO. 3.0 LABEL CHECK (3) Flowchart Yes CHECKS Jwnp to corresponding Convert module key data to ASCII CHECK3 Jwnp to corresponding module CHECKF Note: Key data input to "Check Input Data" Key data is checked as to whether it represents characters or cursor movement. After checking, the corresponding process is executed. (i) Character Key data (KEYDAT) is converted to ASCII character codes, after which a particular module is called depending on the mode flag (MODFLG). Mode flag and corresponding modules are shown in Table 3.3. ~HITACHI 1022 Main Program H Check Input Data I Check Input Data MODULE NO. 3.0 LABEL CHECK Table 3.3 Mode Flag and Corresponding Modules of "Check Input Data" Mode flag Module (MODFLG) Label Function $0,$12 CHEKl For normal dialing; valid data (Q'\.9, *, #) $8 CHEK2 For speed dialing; valid data (0"'9) $9 CHEK3 For entering speed dial; valid data (Q) : 0"'9, ®: 0"'9, *, #) $4,$5,$6,$7 CHEK4 For storing telephone number; valid data (Q): all ® : 0"'9, *, #) $D,$E CHEKS For setting calendar & time, charge; valid data (0"'9) (ii) Cursor A particular module is called depending on key data stored in KEYDAT. Key data and corresponding modules is shown in Table 3.4. Table 3.4 Key Data and Corresponding Modules Key data Module (KEYDAT) Label Function $29 CURLR Move cursor to left or right $2A $2B ~ MVECUR Move cursor to 21st digit $ HITACHI 1023 Main Program H Check Input Data i Check for Normal Dialing MODULE NO. 3.1 LABEL CHEKI (1) Function For normal dialing, valid data is (0 ~ 9, *, #). (a) Valid data is stored in DIALNO (RAM) up until the 20th digit. From the 21st digit, it is stored in DIADAT (RAM). (b) Valid data is displayed on LCD up until the 38th digit. (c) If invalid data is input, set error process request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Key data KEKEYSET (RAM) 1 Tone output setting flag (5, WAIT3) (1 bit) Display on 38th digit flag (4, WAITS) (1 bit) Tone after 21st qigit flag (3, WAITS) (1 bit) Tone on 21st digit LCDMP (RAM) 1 Pointer for buffer DIAPI (RAM) 1 Returns Valid data (until 20th digit) DIALNO (RAM) 21 Valid data (after 21st digit) DIADAT (RAM) 5 RAM for redialing MEMO (RAM) 21 Tone output request flag (1, BZR) (1 bit) Tone outputting flag (4, WAIT3) (1 bit) Tone output setting flag (5, WAIT3) (1 bit) LCD display RAM 'I LCDM (RAM) 40 Pointer for buffer DIAPI (RAM) 1 LCD display pointer LCDMP (RAM) 1 Cursor OFF CURADP (RAM) 1 LCD display after 38th digit flag (4, WAITS) (1 bit) Error process request flag (0, ERFLG) (1 bit) ~HITACHI 1024 Main Program H Check Input Data I Check for Normal Dialing MODULE NO. 3.1 LABEL CHEKl (3) Flowchart CHKll Set error process Clear RAM for redial- request flag ing Set tone output request flag Set tone output Set tone setting output setting flag flag LCD LCD Store k.ey data Store key data in DIIILNO (RAM) in DIIILNO (RlIM) and display it and display it ~HITACHI 1025 Main Program H Check Input Data I Check for Normal Dialing MODULE NO. 3.1 LABEL CHEKl CHK14 Set output after 21st digit flag LCD Store key data in DIADAT (IWI) and display i t No Clear pointer for buffer CHK17 Increment LCD display pointer Yes CHKl5 Set tone No output after 38th digit flag Store key data in DIADAT (RAM) No Clear pointer for buffer 1 ~HITACHI 1026 Main Program H Check Input Data I Check for Speed Dialing MODULE NO. 3.2 LABEL CHEK2 (1) Function For speed dialing, valid data is (OV9). (a) Valid data is stored in LCDM (RAM) and displayed on the 10th digit. (b) If invalid data is input, set error process request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Key data KEYSET (RAM) 1 Process flag TRMFLG (RAM) 1 Returns Cursor position CURADP (RAM) 1 LCD display pointer LCDMP (RAM) 1 Valid data LCDM (RAM) 40 Tone output request flag (1, BZR) (l bit) Error process request flag (0, ERFLG) (l bit) ~HITACHI 1027 I Main Program HCheck Input Data I Check for Speed Dialing MODULE NO. 3.2 LABEL CHEK2 (3) Flowchart No Define cursor position No CHK22 Set error LCD process Store key data request in LCDM (RAM) and display it flag Set tone output request flag CHK23 RTS ~HITACHI 1028 Main Program H Check Input oat:';] I_Number Check for Entering Speed Dial MODULE NO. 3.3 LABEL CHEK3 (1) Function For entering speed dial number, valid data is (in the first process : O~9; in the second process : O~9, *, #). (a) Valid data is stored in LCDM (RAM) and displayed. (In the first process, valid data is displayed on the 10th digit. In the second process, valid data is displayed on 21~38th digit.) (b) If invalid data is input, set error process request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Key data KEYSET (RAM) 1 Process flag TRMFLG (RAM) 1 LCD display pointer LCDMP (RAM) 1 Cursor position CURADP (RAM) 1 Returns Valid data LCDM (RAM) 40 Cursor position CURADP (RAM) 1 LCD display pointer LCDMP (RAM) 1 Error process request flag (0, ERFLG) (1 bit) ~HITACHI 1029 I Main Program H Check Input Data I I Check for Entering Speed Dial . Number MODULE NO . 3.3 LABEL CHEK3 (3) Flowchart No Yes No Yes 1 Yes CHK35 2 Set error process No request 1 flag 2 Store key data in LCDM (RAM) Yes Increment Define LCD display cursor pointer position CHK34 LCD Display key data CHK36 ~HITACHI 1030 Main Program H Check Input Data I ICheCk for Storing Telephone Numbers I MODULE NO. 3.4 LABEL CHEK4 (1) Function For storing telephone numbers, valid data is (1~20th digit all key; 2l~38th digit : 0~9, *, #). (a) Valid data is stored in LCDM (RAM) and displayed. (b) If invalid data is input, set error process request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Key data KEYSET (RAM) 1 LCD display pointer LCDMP (RAM) 1 Mode flag MODFLG (RAM) 1 Returns Valid data LCDM (RAM) 40 LCD display pointer LCDMP (RAM) 1 Cursor position CURADP (RAM) 1 Error process request flag (0, ERFLG) (1 bit) ~HITACHI Main Program H Check Input Data I ICheck for Storing Telephone Numbersl MODULE NO. 3.4 LABEL CHEK4 (3) Flowchart No Yes Store key data in LCDM (RAM) Yes Increment LCD display 1 pointer No Yes CHK46 Increment LCD display pointer CHK45 LCD Display key data Set error process request flag CHK47 ~HITACHI 1032 Main Program H Check Input Data I Check for Setting Calendar & Time, MODULE NO. LABEL Charge 3.5 CHEK5 (1) Function For setting calendar & time or charge, valid data is (0~9). (a) Valid data is stored in LCDM (RAM) and displayed. (b) If invalid data is input, set error process request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Key data KEYSET (RAM) 1 Process flag TRMFLG (RAM) 1 Mode flag MODFLG (RAM) 1 Returns LCD display pointer LCDMP (RAM) 1 Cursor position CURADP (RAM) 1 Valid data LCDM (RAM) 40 Error process request flag (0, ERFLG) (1 bit) ~HITACHI 1033 ,I Main Program H Check Input Data I Check for Setting Calendar & Time, MODULE NO. 3.5 LABEL CHEK5 Charge (3) Flowchart No CHK53 Store valid data in Set error process LCDM (RAM) request flag No Increment LCD display pointer \ No CHK52 ~ LC.Q Display character with cursor for charge· $ HITACHI 1034 Main Program H Check Input Datal Move Cursor to Left or Right MQDULE NO. 3.6 LABELI CURLR I (1) Func tion Moves cursor to left or right. If cursor movement disable flag is set, review the next or previous data. While setting calendar & time or charge, cursor cannot be moved to unnecessary area. (2) Arguments Contents Storage Location No. of Bytes Entry Key data KEYDAT (RAM) 1 Calendar & time display (1, FLAG) (1 bit) request flag Cursor movement disable flag (7, BZRFLG) (1 bit) Mode flag MODFLG (RAM) 1 Process flag TRMFLG (RAM) 1 Tone outputting flag (4, WAIT3) (1 bit) LCD display pointer LCDMP (RAM) 1 Cursor position CURADP (RAM) 1 Returns Reviewing data LCDM (RAM) 40 LCD display pointer LCDMP (RAM) 1 Cursor positiop. CURADP (RAM) 1 ~HITACHI 1035 I H Check Input Data I Move Cursor to Left or Right MODULE NO. 3.6 LABEL CURLR (3) Flowchart Move cursor to right CURLR8 Move cursor Move cursor to right to left CURLR9 Move cursor to left and display it CURLR3 ~ Move cursor to right and CURLRA Increment display it process LCD flag Display cursor MODE2 Review previous data 1 ~HITACHI 1036 Main Program H Check Input Data I Move cursor to 21st Digit MODULE NO. 3.7 LABEL MVECUR (1) Function Moves cursor to 21st digit. (2) Arguments Contents Storage Location No. of Bytes Entry Tone outputting flag (4, WAIT3) (1 bit) Returns LCD display pointer LCDMP (RAM) 1 Cursor position CURADP (RAM) 1 (3) Flowchart Yes Move pointer to 21st digit LCD Display cursor on 21st digit MVECUF ~HITACHI 1037 ~--------------~i Main Program r-iI Error Process I i Error Process I MODULE NO. 4.0 LABEL ERROR (1) Function "Error Process" performs error processing corresponding to error process request flag. The actual generating of the buzzer, however, is executed by timer 2. Counting for "ERROR" or "FULL" display time is executed by timer 1. Details of the error process request flag are shown in Table 3.5. Table 3.5 Error Process Request Flag ERFLG (RAM) Bit 2 1 0 Function 0 0 0 No error 0 0 1 Generate buzzing 0 1 1 Generate buzzing and display "ERROR" 1 0 1 Generate buzzing and display "FULL u (2) Arguments Contents Storage Location No. of Bytes Entry Error process request flag ERFLG (RAM) 1 Buzzer output time BZRCNT (RAM) 2 Error message display time ERRl (RAM), 2 ERR2 (RAM) Returns Error process complete flag ERFLG (RAM) 1 ~HITACHI 1038 I Main Program H Error Process I Error Process MODULE NO. I 4.0 LABEL I ERROR I (3) Flowchart Yes Yes Define buzzing and display time ERROR2 Set flag for error process Yes No ERROR4 LCDMCR LCD Display LCD II FULL" Display "ERROR" ERROR6 Clear error process request flag ~HITACHI 1039 I Control Timer 1 Control Timer 1 MODULE NO. TID LABEL TIMERI (1) Function "Control Timer I" controls counting buzzing time and displaying information on LCD. (2) Arguments There are no common entry and return arguments for controlling timer 1. Particular entry and return arguments for each module are explained in each module's description in detail. Contents Storage Location No. of Bytes Entry Returns (3) Flowchart TIMER 1 ) T IMERI I Clear interrupt request flag I Program module BUZC - - Count buzzer time I Program module FIGURE CoWltt-Ime for displaying information on LCD I RTI ~HITACHI 1040 ~ Control Timer 1 H Count I_______________ ~ Time Buzzing Count Buzzing Time MODULE NO. TIl. 0 LABEL BUZC (1) Function Counts displaying error message time and buzzing time. (2) Arguments Contents Storage Location No. of Bytes Entry Buzzing output request flag (3, BZRFLG) (1 bit) Counter of buzzing time BZRCNT (RAM) 2 Counter of displaying error ERRI (RAM), 2 time ERR2 (RAM) Error display request flag (7, WAITS) (1 bit) Returns Buzzing output complete flag (3, BZRFLG) (1 bit) Counter of buzzing time BZRCNT (RAM) 2 Counter of displaying error ERRI (RAM), 2 time ERR2 (RAM) Calendar & time display (1, FLAG) (1 bit) request flag Error display complete flag (7, WAITS) (1 bit) $ HITACHI 1041 I I Control Timer 1 H ~~:t Buzzi",:! i Count Buzzing Time I MODULE NO. Tl1.0 LABEL BUZC (3) Flowchart No No Decrement counter of buzzing Yes time BUZC3 Clear No buzzing request flag No Decrement counter of displaying error time BUZC6 ~HITACHI 1042 Count Time for Displaying Control Timer 1 Information on LCD Count Time for Displaying MODULE NO. Tl2.0 LABEL FIGURE Information on LCD (1) Function Counts calendar & time, elapsed time, charge, and accumulated charge. Displaying information on LCD is selected by flags. (2) Arguments Contents Storage Location No. of Bytes Entry I-second counter TCNTR (RAM) 1 Handset up flag (0, TELFLG) (1 bit) While talking flag (1, TELFLG) (1 bit) Calendar & time display request (1, FLAG) (l bit) flag Charge display request flag (7, FLAG) (1 bit) Accumulated charge display (6, FLAG) (l bit) request flag Elapsed time display request (3, FLAG) (1 bit) flag Calendar & time counter CALNDR (RAM) 5 Elapsed time counter TEL (RAM) 3 Charge counter SINGL (RAM) 4 Accumulated charge counter TOTAL (RAM) 4 Returns I-second counter TCNTR (RAM) 1 Calendar & time counter CALNDR (RAM) 5 Elapsed time counter TEL (RAM) 3 Charge per time counter SECCNT (RAM) 2 Charge counter SINGL (RAM) 4 .Accumulated charge counter TOTAL (RAM) 4 LCD d"isplay RAM LCDM (RAM) 40 Cursor OFF CURADP (RAM) 1 • HITACHI 1043 II i Count Time for Displaying Control Timer 1 Information on LCD Count Time for Displaying MODULE NO. T12.0 LABEL FIGURE Information on LCD (3) Flowchart Decrement I-second counter Load calendar & time data FIG4 Reinitialize TELLCD No Load I-second elapsed counter time data TIMCNT Increment time counter Load accumu- lated charge data Yes TELCLR SNGCLR FIG6 Clear charge, SNGSTA time counter NO Load charge data FIG7 Cursor OFF No MONEY Count charge and time LCD Display LCD data 2 1 ~HITACHI 1044 Control Timer 2 Control Timer 2 MODULE NO. T20 LABEL TIMER2 (1) Function "Control Timer 2" controls key scan, buzzer output, and controlling dialing circuit. (2) Arguments There are no common entry and return arguments for controlling timer 2. Particular entry and return arguments for each module are explained in each module's description in detail. Contents Storage Location No. of Bytes Entry Returns (3) Flowchart ( TlMER2 TlMER21 Clear interrupt request flag I Program module K88SCN Execute 8 x 8 key scan I Program module BUZZ Output buzzer I Program module TELM!! control dialing ci reui t I ( RTI ) ~HITACHI 1045 II I Control Timer 2 H Key Scan Key Scan I MODULE NO. T21.0 LABEL K88SCN (1) Function Executes key scan of 8x8 key matrix. After processed chatter prevention routine, valid data is stored in KEYDAT (RAM) and flag is set indicating key data is contained. (2) Arguments Contents Storage Location No. of Bytes Entry Returns Key data (Note) KEYDAT (RAM) 1 Key data/no key data (0, FLAG) (1 bit) Note: (0, FLAG) o No key data is contained (0, FLAG) 1 Key data is contained ~HITACHI 1046 IControl Timer 2 ~~_____K_e_y__S_c_a_n____~ Key Scan MODULE NO. T21.0 LABEL K88SCN (3) Flowchart Yes Output strobe signal No K88SN6 No Store key data No Test key is depressed twice or not Store valid Increment key data in counter Store key KEYDAT (RAM) data Set flag K88SN2 indicating Define strobe valid data signal for next row 1 No K88SN9 ~HITACHI 1047 I I Control Timer' 2 H Buzzing Buzzing I MODULE NO. T22.0 LABEL BUZZ (1) Function Output High and Low to port F, bit 6 by the same cycle of timer 2, if buzzer output request flag is set. (2) Arguments Contents storage Location No_ of Bytes Entry Buzzer output request flag (3, BZRFLG) (1 bit) High-Low output request flag (0, BZR) (1 bit) Returns High-Low output request flag (0, BZR) (l bit) (3) Flowchart No No BUZZI Output Low Output High to port F, to port F, bit 6 bit 6 Set High Set Low output output request fla request flag BUZZ2 eHITACHI 1048 Control Dialing Control Timer 2 Circuit Control Dialing Circuit MODULE NO. T23.0 LABEL TELMN (1) Function "Control Dialing Circuit" controls six routine (While Talking, while Receiving, Generate Tone, Relay ON, while Retrying, and Connect Lines) as shown in (3) Flowchart. Each routine has its flag to indicate dialing circuit status. Flag is checked at the beginning of this routine and each module is executed depending on the flag. (2) Arguments Common entry and return arguments for controlling dialing circuit are shown below. Particular entry and return arguments for each module are explained in each modules description in detail. Contents Storage Location No. of Bytes Entry Talking flag (1, TELFLG) (1 bit) Receiving flag (1, PDDTR) (1 bit) Tone output flag (2, BZR) (1 bit) Tone output request flag (1, BZR) (1 bit) Retrying flag (0, BZRFLG) (1 bit) Handset up? (2, PDDTR) (3, PDDTR) (2 bits) Returns ~HITACHI 1049 I I_Control Timer 2 H Control Dialing I Circu~t_ Control Dialing Circuit I MODULE NO. T23.0 LABEL TELMN (3) Flowchart Program module TELMlO While talking TELMN2 Program module TELM20 WhH-e-- Program module TELM40 Rela~ Yes TELMNS Program module TELMN6 TELM50 While retrying Program module TELM60 Connect lines ~HITACHI 1050 I. Control Timer 2 H Control Dial;ng • . ;.:C:i:r:c:u:i:t::::::::~ While Talking MODULE NO. T23.1 LABEL TELM10 (1) Function Tests if conversation is continuing. If handset is down, clear talking flag and set calendar & time display request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Handset up? (2,PDDTR) (3,PDDTR) (2 bits) Port E status (0, WAIT3) (1 bit) Contents of port E before tone MEMOP (RAM) 1 output Returns Calendar & time display request (1, FLAG) (1 bit) flag Port E PEDTR 1 Port E status (0, WAIT3) (1 bit) ~HITACHI 1051 II Control Timer 2 Control Dialing Circuit While Talking MODULE NO. T23.l LABEL TELMIO (3) Flowchart No Yes Set calendar & time display reques·t flag TELMll No Load previous data into port E TELM12 CALRST If handset down, clear RAM used ~HITACHI 1052 Control Dialing Control Timer 2 Circuit While Receiving MODULE NO. T23.2 LABEL TELM20 (1) Function Tests whether or not handset is up. If handset is up, set talking flag. If called, whether handset is up or not, retrying is canceled. (2) Arguments Contents Storage Location No. of Bytes Entry Retrying flag (0, BZRFLG)' (1 bit) Handset up? (2,PDDTR) (3,PDDTR) (2 bits) Returns Talking flag (1, TELFLG) (1 bit) Retrying flag (0, BZRFLG) (1 bit) Cursor OFF CURADP (RAM) 1 (3) Flowchart C TELM20 TELM~~y_e_s __________________ ~ ~ TELM2l No CANCEL Cancel retrying Yes Handset up? TELM22 • No Set talking flag I Cursor OFF ~HITACHI 1053 I Control Timer 2 Control Dialing Circuit Generate Tone MODULE NO. T23.3 LABEL TELM30 (1) Function Generates tone for normal dialing, speed dialing, redialing, retrying. Dialing number for output is stored in DIALNO (RAM) until 20th digit. From 21st digit, number is stored in DIADAT (RAM). When tone output is finished, test when conversation begins. If conversation begins, set talking flag. (2) Arguments Contents Storage Location No. of Bytes Entry Process flag TELWAT (RAM) 1 Tone output until 20th digit flag (5, WAITS) (1 bit) Tone output after 21st digit flag (5, WAITS) (1 bit) Telephone number (until 20th DIALNO (RAM) 20 digit) Telephone number (from 21st DIADAT (RAM) 5 digit) Pointer of telephone Dumber TELNO (RAM) 1 (until 20th digit) Pointer of telephone number DIAP2 (RAM) 1 (from 21st digit) Retrying flag (0, BZRFLG) (1 bit) Handset up? (6,TELFLG) (7,TELFLG) (2 bits) Next data existance flag (3, WAIT3) (1 bit) Contents of port E before tone PEDTR 1 output Call is answered? (2,PDDTR) (3,PDDTR) (2 bits) Returns Process flag TELWAT (RAM) 1 Tone output data MFDAT (RAM) 1 Talking flag (I, TELFLG) (1 bit) Handset up flag (0, TELFLG) (1 bit) Contents of port E MEMOP (RAM) 1 Contents of port E reserved flag (0, WAIT3) (1 bit) ~HITACHI 1054 w "l ~ ~() :or ~ II m CD Ii Yes II ~ CD 1-3 0 ::l No r " I I CD ~ 3: I 0 :I tJ C ~ t" trI Z (') 0 :I No ......... / ' ,0 ~ tIl trI t" ---, r;; () ...·0 Ii::l g!t t;3 ...rt~ ·0 ~ w ....0 0 III ...... .... ~ 0 (11 (11 0 II ::l \Q Control Timer 2 Control Dialing Circuit Generate Tone MODULE NO. T23.3 LABEL TELM30 No TELM37 HS pin OFF HS pin ON MFOUT Yes Output 1 digit No Set flag for HS pin Increment ON pointer for buffer Yes Yes TELM3B No Set talking No Clear flag pointer for buffer TEL363 CALRST Set HS pin If handset down, clear OFF request RAM used flag 1 TELM3F ~HITACHI 1056 Control Dl.aling Control Timer 2 Circuit Relay ON MODULE NO. T23.4 LABEL TELM40 (1) Function Confirms whether or not handset is up for tone output. If handset is up, set tone output request flag. If handset is down, connect line using relay. After confirming line connected, set tone output request flag. (2) Arguments Contents Storage Location No. of Bytes Entry Relay ON flag (6, BZR) (1 bit) Handset up? (Line connected?) (2,PDDTR),(3,PDDTR) (2 bits) Wait for 0.5 sec flag TELWAT (RAM) 1 Returns Relay ON request flag (5, PFDTR) (1 bit) Relay ON fl<,.g (6, BZR) (1 bit) Tone output request flag (2, BZR) (1 bit) Error process request flag (O,ERFLG) (l,ERFLG) (2 bits) Handset up (0, TELFLG) (1 bit) Which photo-coupler ON (6,TELFLG) (7,TELFLG) (2 bits) Relay OFF request flag (5, BZR) (1 bit) Dialing flag (1, BZR) (1 bit) • HITACHI 1057 I Control Dialing Control Timer 2 Circuit Relay ON MODULE NO. T23.4 LABEL TELM40 ( 3 ) Flowchart Yes Yes TELM43 wait for 0.5 sec Set tone Relay ON output Set tone request output re- flag quest flag Set error process re- Set relay quest flag ON flag TELM49 ~HITACHI 1058 I. Control Timer 2 .H. Circul.t Contr';'l Dialing While Retrying MODULE NO. T23.5 LABEL TELM50 (1) Function Retries for 45 seconds every two minutes. (a) While waiting for two minutes; blink the telephone number on and off to indicate retrying. (b) If call is answered while ringing for 45 seconds, (i) Set buzzer request flag to notify caller. (ii) Set talking flag (iii) Complete retrying (c) If ringing is executed for 10 times with no answer, cancel retrying. (2) Arguments Contents Storage Location No. of Bytes Entry Process flag for tone output TELWAT (RAM) 1 Counter for retrying function REC (RAM) 1 Counting how many times retrying (7, BZR) (1 bit) is executed Which photo-coupler is high (6,TELFLG) (7,TELFLG) (2 bits) Call is answered (2,PDDTR) (3,PDDTR) (2 bits) Returns Process flag for tone output TELWAT (RAM) 1 Telephone number LCDM (RAM) 40 Tone output request flag (I, BZR) (1 bit) Tone outputting flag (4, WAIT3) (1 bit) Talking flag (I, TELFLG) (1 bit) Handset up? (0, TELFLG) (1 bit) Buzzer output request flag (3,BZRFLG) (1 bit) Buzzing time BZRCNT (RAM) 2 Error message display OFF ERRl (RAM), 2 request counter ERR2 (RAM) $ HITACHI 1059 Control Timer 2 Control Dialing Circuit While Retrying MODULE NO. T23.S LABEL TELMSO (3) Flowchart Yes No Initialize for retry ing No Initialize to blink onl off tele- phon~ number TELS12 DIAL2 LCDMCR Turn on LCD Turnoff Set flag to telephone telephone indicate number number initialize completed set flag to Set flag to turn off turn on telephone No telephone No No DIAL2 Turn on tele- phone number and set tone output request flag 1 ~HITACHI 1060 Control Dialing Control Timer 2 Circuit While Retrying MODULE NO. T23.S LABEL TELMSO No No Stop output tone Set flag indicating Set flag answered indicating output 45 sec. Set talking flag for next output CANCEL Cancel TELM5B retrying CANCEL Cancel retrying 1 TELM5F CALRST If handset down, clear RAM used ~HITACHI 1061 I Control Dialing Control Timer 2 Circuit Connect Lines MODULE NO. T23.6 LABEL TELM60 (1) Function Clears display and sets flag indicating handset is up and prepare for tone output. (2) Arguments Contents Storage Location No. of Bytes Entry Mode flag MODFLG (RAM) 1 Handset up (2,PDDTR) (3,PDDTR) (2 bits) Returns LCD display RAM LCDM (RAM) 40 RAM for redialing MEMO (RAM) 21 Handset up? (0, TELFLG) (1 bit) Tone outputting flag (4, WAIT3) (1 bit) Cursor OFF CURADP (RAM) 1 LCD display pointer LCDMP (RAM) 1 ~HITACt.... 1062 I. Control Timer 2 .H. ec;>ntrol Dialing C~rcuit Connect Lines MODULE NO. T23.6 LABEL TELM60 (3) Flowchart No Yes No TELM6l LCDMCR LCD Clear dis la Cursor OFF and define display position Set flag indicating handset up CALRST If handset down, clear RAM used TELM62 ~HITACHI 1063 Display on LCD MODULE NO. EX 1. 0 LABEL LCD (1) Function Displays ASCII, stored in LCDM (RAM), on LCD. (2) ArgUlllents Contents Storage Location No. of Bytes Entry Display data (ASCII) LCDM (RAM) 40 Cursor position (Note) CURADP (RAM) 1 Returns Note: CURADP indicates cursor position. Example: CURADP=O No cursor displayed. CURADP=l Cursor is displayed on 1st digit. CURADP=2 Cursor is displayed on 2nd digit. ~HITACHI 1064 Display on LCD MODULE NO. EX1.0 LABEL LCD (3) Flowchart LCD LCOINS ~instruc- tion in instruction register LCDl LCDDSP Display 1 digit No LCDINS ~instruction in instruction register No LCD4 Store Store instruction instruction for cursor for cursor ON OFF LCDS LCD INS ~instruction in instruction register ~HITACHI · · c - . - -_ _ _ _ _ _ _ _ _ _ _ _ __ 1065 I Microcomputer + Telephone MODULE NO. EX2.0 LABEL OUTDAT Numbers Storin RAM (1) Function Loads data from microcomputer to RAM for storing telephone numbers. (2) Arguments Contents Storage Location No. of Bytes Entry Data DATA (RAM) 1 Address DTDP (RAM) 2 Returns Data (RAM for storing 1 telephone numbers) (3) Flowchart ( OUTDAT OU TDAT I Disable interrupts I Load data into port A I Load upper address into port E, lower to port B. I Select port A as output Output data I Enable interrupts I RTS ~HITACHI 1066 Microcomputer + Telephone MODULE NO. EX2.1 LABEL INPDAT Numbers Storing RAM (1) Function Loads data from RAM for storing telephone numbers to microcomputer. (2) Arguments Contents Storage Location No. of Bytes Entry Address DTDP (RAM) 2 Returns Data DATA (RAM) 1 (3) Flowchart ( I NPDAT INPDAT I Disable interrupts I Load upper address into port E, lower to port B. I Select port A as input I Load data into DATA (RAM) I Enable interrupts 1 RTS ~HITACHI 1067 I 3.5 RAM Table RAM allocation for the Intelligent Telephone is Shown in table 3.6. Table 3.6 RAM Table Label No. of Bytes Description ADD RAT 4 Counter for rate of charge BZRCNT 2 Counter for buzz time CALCNT 1 Address pointer for modifying data CALNDR 5 Counter for calendar & time CNT 1 Address pointer for modifying data CNTBIT 1 Indicator determining what should be changed from BCD to ASCII CURADP 1 Current cursor position DATA 1 Temporary storage for telephone no. data DIADAT 5 Buffer of telephone no. for more than 21 digits tone output DIALNO 21 Currently dialed telephone no. DIAPl 1 Pointer to buffer of telephone no. for more than 21 digits tone output DIAP2 1 DTADS 2 Starting address of review data DTCNT 1 Pointer indicating what digit of review data is being reviewed DTDP 2 Address pointer for telephone no. data ERRl 1 Counter for error message display time --------------------- ERR2 1 HOLD 1 Pointer to display RAM converting blank spaces KEYDAT 1 Valid key data KEYNUM 1 Data for identifying depressed key KEYSET 1 ASCII code corresponding key data LCDM 40 LCD display RAM LCDMP 1 Pointer to LCD display RAM MEMO 21 Previously called telephone number MEMOP 1 Contents of port E before tone output MFDAT 1 Tone data to be output MODFLG 1 Mode flag NEWKEY 1 Current key data OLDKEY 1 Previous key data POINTR 1 Pointer for moving data to display RAM REC 1 Counter for retrying function REFDAT 20 Data being reviewed ~HITACHI 1068 Table 3.6 RAM Table (cont.) Label No. of Bytes Description SCOUNT 1 Counter used in determining depressed key SDP 2 Pointer to next review data SEC 2 Charge per unit time SECCNT 2 Counter for unit time of charge SHUCNT 1 Address pointer for modifying data SHUSEC 2 Charge per time to be modified SHUSTA 5 Calendar & time to be modified SINGL 4 Counter of charge STBDAT 1 Data for strobe signal output TCNTR 1 Counter for timer 1 interrupts TEL 3 Counter for elapsed time TELCNT 1 Pointer to what digit of telephone no. is output TELNO 1 Pointer to what digit of telephone no. is output TELWAT 1 Process flag for tone output TIMSTA 1 Time counter to be modified TOTAL 4 Counter for accumulated charge TOTLKY 1 Number of depressed key TRMFLG 1 Process flag TRNS 1 Counter of blank spaces WAITl 1 Counter for HS pin ON WAIT2 1 Counter for HS pin ON/OFF WAIT4 1 Counter for blinking telephone no. ON/OFF during retrying ~HITACHI 1069 I 3.6 Flag Table The flag used by the Intelligent Telephone are shown in Table 3.7. Note : Flag function of bits 1 ~ 3 of port D data register is described at the last of Flag Table. Table 3.7 Flag Table Flag Bit Description BZR 0 0 Output High for buzzing 1 Output Low for buzzing 1 0 Not requesting tone output 1 Requesting tone output 2 0 Not tone outputting 1 Tone outputting 3 0 Not requesting HS pin ON 1 Requesting HS pin ON 4 Not used 5 0 <= Not requesting relay OFF 1 Requesting relay OFF 6 0 Relay OFF 1 Relay ON 7 0 Not counting how many times retrying function is executed 1 Counting how many times retrying function is executed BZRFLG 0 0 Not retrying 1 Retrying 1 0 Not waiting for 2 minutes during retrying 1 Waiting for 2 minutes during retrying 2 0 Not ringing for 45 sec during retrying 1 Ringing for 45 sec during retrying 3 0 Not requesting buzzing 1 Requesting buzzing 4 0 Not buzzing 1 Buzzing 5 Not used 6 Not used 7 0 Cursor movement enable 1 Cursor movement disable CHATFL 0 Counter to indicate how many times current key data is compared with previous key data 1 2 3 4 Not used 5 Not used 6 Not used 7 o Chatter prevension incompletion 1 Chatter prevension completion ~HITACHI 1070 Table 3.7 Flag Table (cont.) Flag Bit Description ERFLG o bit 2 1 0 Description 000 No error 1 001 Buzzing only 011 Buzzing and displaying "ERROR" 2 1 0 1 Buzzing and displaying "FULL" 3 Not used 4 Not used 5 Not used 6 Not used 7 Not used FLAG o o No key data input 1 Key data input 1 o Not displaying calendar & time 1 Displaying calendar & time 2 o Reviewing in forward direction 1 Reviewing in reverse direction 3 o Not displaying elapsed time 1 Displaying elapsed time 4 o Not reviewing data 1 Reviewing data 5 o Not desired data 1 Desired data 6 o Not displaying accumulated charge 1 Displaying accumulated charge 7 o Not displaying charge 1 Displaying charge TELFLG o o Handset down 1 Handset up 1 o Not talking 1 Talking 2 o Not receiving 1 Receiving 3 o No ringing 1 Ringing 4 o Not waiting for 3 sec before tone output 1 Waiting for 3 sec before tone output 5 o Not dialing 1 Dialing 6 o Photo-coupler (1) OFF 1 Photo-coupler (1) ON 7 o Photo-coupler (2) OFF 1 Photo-coupler (2) ON ~HITACHI 1071 Table 3.7 Flag Table (cant.) Flag Bit Description WAIT3 o 0 Not contents of port E restored 1 Contents of port E restored 1 o Retrying not initialized 1 Retrying initialized 2 o Turn on telephone number during retrying 1 Turn off telephone number during retrying 3 Not used 4 o No tone output 1 Tone output S o Not initialized for tone output 1 Initialized for tone output 6 Not used 7 Not used WAITS o Not used 1 o Not receiving 1 Receiving 2 Not used 3 o Not preparing for tone output after 21st digit 1 Preparing for tone output after 21st digit 4 o LCD display not full 1 LCD display full S o Tone output until 20th digit 1 Tone output after 21st digit 6 Not used 7 o Not displaying "ERROR" 1 Displaying "ERROR" Note Bits 1 ~ 3 of port D data register indicate dialing circuit status as follows; Flag Bit Description PDDTR 1 o = Not receiving 1 = Receiving 2 Handset up Talking Handset up 'l'alking -3- bit 2 3 bit 2 3 or bit 2 3 bit 2 3 -------- 1 0 -------- o 1 --------- o 1 -------- 1 0 ~HITACHI 1072 3.7 Subroutine Table The subroutines used by the Intelligent Telephone are shown in Table 3.8 with input and output arguments. (Refer to "3.5 RAM Table" for argument details.) Table 3.8 Subroutine Table Subroutine Entry Returns Name Storage Location Bytes Storage Location Bytes Function ARGINT Clear internal RAM CALLCD CALNDR (RAM) 5 LCDM (RAM) 40 Load calendar data into display RAM CALRST If handset is down, clear RAM used CALSHU LCDM (RAM) 40 CALNDR (RAM) 5 Determine whether or TELFLG (RAM) 1 not modified data is ERFLG (RPM) 1 correct format as calendar & time. If data is correct, set modified calendar & time. If incorrect, store "0" in TRMFLG (RAM) • CANCEL Cancel retrying CLEAR LCDM (RAM) 40 Store $00 in display RAM CRGSET ADDRAT (RAM) 4 LCDM (RAM) 40 Load charge per unit SEC (RAM) 2 time into display RAM CURCAL LCDMP (RAM) 1 LCDMP (RAM) 1 Define cursor position KEYDAT (RAM) 1 CURADP (RAM) 1 for setting calendar & time CURRAT LCDMP (RAM) 1 LCDMP (RAM) 1 Define cursor position CURADP (RAM) 1 for setting charge DIACLR DIALNO (RAM) 21 Clear RAM for tone output DIAL2 MEMO (RAM) 21 LCDM (RAM) 40 Display telephone number for retrying DTADD DTDP (RAM) 2 DTDP (RAM) 2 Increment pointer to data table DTLCD DTDP (RAM) 2 LCDM (RAM) 40 Display name and telephone number DTSUB DTDP (RAM) 2 DTDP (RAM) 2 Decrement pointer to data table ~HITACHI 1073 Table 3.8 Subroutine Table (cont.) Subroutine Entry Returns Name Storage Location Bytes Storage Location Bytes Function END (4, WAIT3) (lbit) (1, FLAG) (lbit) Clear RAM used in Mode DIALNO (RAM) 21 LCDM (RAM) 40 Process and set calendar & time display request flag. In the case of tone outputting, display telephone no. KENSAK REFDAT (RAM) 20 LCDM (RAM) 40 Compare data string FLAG (RAM) 1 FLAG (RAM) 1 LCDBSY Check LCD busy flag LCDDSP IX 1 Store ASCII in DDRAM of LCD-II LCDINS IX 1 Store instruction in instruction register LCDINT Select display mode of LCD-II LCDMCR LCDM (RAM) 40 Clear display RAM LCDMST FLAG (RAM) 1 LCDM (RAM) 40 Clear display RAM and send display format LCDRES Reset LCD-II by instruction LCDSET CNT (RAM) 1 LCDM (RAM) 40 Send calendar & time or FLAG (RAM) 1 charge to display RAM LFCRSR CURADP (RAM) 1 CURADP (RAM) 1 Move cursor to the left LCDMP (RAM) 1 LCDMP (RAM) 1 MODFLG (RAM) 1 TRMFLG (RAM) 1 MEMCLR MEMO (RAM) 21 Clear telephone number for redialing MFOUT ACCA 1 MFDAT (RAM) 1 Output tone data corresponding to ASCII MNYASC TOTAL (RAM) 4 LCDM (RAM) 40 Convert data to ASCII SINGL (RAM) 4 and load in display ADDRAT (RAM) 4 RAM SEC (RAM) 2 MONEY ADDRA'l' (RAM) 4 TOTAL (RAM) 4 Count charge SEC (RAM) 2 SINGL (RAM) 4 MOVEl LCDM (RAM) 40 REFDAT (RAM) 20 Move -to review data area ~HITACHI 1074 Table 3.8 Subroutine Table (cont.) Subroutine Entry Returns Name Storage Location Bytes Storage Location Bytes Function MOVE2 REFDAT (RAM) 20 LCDM (RAM) 40 Move review data to display RAM RAMCLR Clear RAM for storing telephone numbers RATSET LCDM (RAM) 40 ADDRAT (RAM) 4 Determine whether or SEC (RAM) 2 not modified data is TRMFLG (RAM) 1 correct format as ERFLG (RAM) 1 charge per unit time. If data is correct, set modified charge per unit time. If incorrect, store "0" in TRMFLG (RAM). RTCRSR CURADP (AAM) 1 CURADP (RAM) 1 Move curser to the LCDMP (RAM) 1 LCDMP (RAM) 1 right MODFLG (RAM) 1 TRMFLG (RAM) 1 SHUCAL CALNDR (RAM) 5 LCDM (RAM) 40 Load calendar & time CURADP (RAM) 1 or cursor into display RAM SNGCLR SINGL (RAM) 4 Clear charge SNGSTA LCDM (RAM) 40 Load charge into display RAM TAN LCDM (RAM) 40 DIALNO (RAM) 21 Display speed dial MEMO (RAM) 21 and corresponding LCDMP (RAM) 1 telephone number CURADP (RAM) 1 TELCLR TEL (RAM) 3 Clear elapsed time TLCN'J' TEL (RAM) 3 TEL (RAM) 3 Count elapsed time TELLCD CNT (RAM) 1 LCDM (RAM) 40 Load elapsed time into FLAG (RAM) 1 display RAM TELNOl LCDM (RAM) 40 DATA (RAM) 1 Change 2 bytes of data into 1 byte TELN02 DATA (RAM) 1 LCDM (RAM) 40 Change 1 byte of data into 2 bytes TIMCNT CNTBIT (RAM) 1 CALNDR (RAM) 5 Count calendar & time TEL (RAM) 3 charge TOLCLR TOTAL (RAM) 4 Clear accumulated charge ~HITACHI 1075 I Table 3.8 Subroutine Table (cont.) Subroutine Entry Returns Name Storage Location Bytes Storage Location Bytes Function TOLSTA TOTAL (RAM) 4 LCDM (RAM) 40 Load accumulated charge into displ.ay RAM TOROKU DTDP (RAM) 2 (RAM for storing 29 Enter name and telephone LCDM (RAM) 40 telephone no.) number in RAM for storing telephone no. YERCNT CALNDR (RAM) 5 CALNDR (RAM) 5 Count calendar & time 3.8 RAM Memory Map for Storing Telephone Numbers $0000 - A name is input with a max. of 20 First person's name ) characters. (A space counts as one character.) $0014 A telephone number is input with a First person's } max. of 18 digits, initially re- 1 telephone number quiring 18 bytes. However, 2 $OOlD digits can be converted and stored in 1 byte (BCD), so that only 9 Second person's name bytes are necessary for storing a telephone number. (A space is $0031 changed to 4 bits, also.) Second person's telephone number No terminator required between two $003A groups of data. Names and telephone numbers for a max. of 200 I...~ \...h I....r"\ vi"' persons j $16A8- Not Used $1700_ Telephone number IA telephone number is input with a max. of 18 digits, initially 1 corresponding to requiring 18 bytes. However, 2 speed dial "0" digits can be converted and stored $1709 in 1 byte (BCD), so that only 9 Telephone number bytes are necessary for telephone corresponding to number. (A space is changed to 4 speed dial "1" bits, also.) $1712 Speed dial No terminator required between two codes for groups of data. a max. of 10 phone numbers ~ 8 ( ~ R ~ $175A- Not Used Note: Speed dial codes are entered in order from o to 9. Fig. 3.4 RAM Memory Map for Storing Telephone Numbers ~HITACHI 1077 3.9 Ports Labels Table The ports used by the Intelligent Telephone are shown in Table 3.9. Table 3.9 Ports Labels Table Ports Label Address Port A data register PADTR $00 Port A data direction register PADDR $04 Port B data register PBDTR $01 Port B data direction register PBDDR $05 Port C data register PCDTR $02 Port C data direction register PCDDR $06 Port D data register PDDTR $03 Port E data register PEDTR $OB Port F data register PFDTR $OC Port G data register PGDTR $OD Port G data direction register PGDDR $07 ~HITACHI 1078 Section 4 Program Listings 4.1 Program Listing 00001 00002 ***** RAM ALLOCATION ************************ 00003 00004 0040 * ORG $40 00005 00006 0040 0001 *LCDMP RMB 1 Pointer to dipLay RAM 00007 0041 0001 MODFLG RMB 1 Mode flag 00008 0042 0001 FLAG RMB 1 FLag for information to be dispLayed 00009 0043 0001 TRMFLG RMB 1 Process flag 00010 0044 0001 TELFLG RMB 1 FLag for output tone 00011 0045 0002 DTOP RMB 2 Address pointer to teLephone no. data 00012 0047 0002 SOP RMB 2 Pointer to next review data 00013 0049 0001 DTCNT RMB 1 Pointer to review data digit 00014 004A 0001 DATA RMB 1 Temporary storage for teLephone no. data 00015 004B 0001 CURADP RMB 1 Current cursor pointer 00016 004C 0002 BZRCNT RMB 2 Buzzeing time counter 00017 004E 0001 BZRFLG RMB 1 FLag for tone output 00018 004F 0001 BZR RMB 1 FLas for tone output 00019 0050 0002 DTADS RMB 2 Start address of relvlew data 00020 0052 0002 SEC RMB 2 Charge per unit time 00021 00022 0054 0001 *kEY SET RMB 1 ASCII code 00023 0055 0001 OLDI= $2E 00116 0509 B1 58 CMP KEYOAT 00117 050B 22 OS BHI MAIN1 It < $2E. execute input data check 00118 0500 CO OS7B JSR MODE It >= $2E. execute mode process 00119 0510 20 OS BRA MAIN2 00120 0512 CO OSE9 MAIN1 JSR CHECK 00121 0515 20 00 BRA MAIN2 00122 0517 00 BE 02 MAIN2 BRSET 0.ERFLG.MAIN3 Error? 00123 051A 20 03 BRA MAIN4 00124 051C CO 0695 MAIN3 JSR ERROR 00125 OSlF 11 42 MAIN4 BCLR O.FLAG ReintiaLize fLa9 00126 0521 20 E1 BRA MAINI ** 00838 ************************************************** 00839 00840 * * 00841 ENTRY : TRMFLG. LCDM * 00842 * RETURNS: FLAG. LCDM. ADDRAT. SEC 00843 * * 00844 * * ************************************************ 00845 0955 B6 43 MOD140 LDA TRMFLG Check process flag 00846 0957 26 11 BNE MOD142 00847 0959 B6 42 MOD141 LDA FLAG 00848 095B A4 35 AND 1I$3S 00849 095D B7 42 STA FLAG Clear display 00850 095F CD 16EA JSR CRGSET 00851 0962 CD 110E JSR LCD Diaplay current charge 00852 0965 3C 43 INC TRMFLG 00853 0967 CC 097F JMP MOD144 00854 096A A1 01 MOD142 CMP 11$1 00855 096C 26 03 BNE MOD143 00856 096E CC 097F JMP MOD144 00857 0971 A1 02 MOD143 CMP 11$2 00858 0973 26 07 BNE MOD145 00859 0975 CD 172C JSR RATSET Enter modified charge 00860 0978 B6 43 LDA TRMFLG 00861 097A 27 DD BEQ MOD141 00862 097C CD 18DA MOD145 JSR END 00863 097F 81 MOD144 RTS 00864 00865 * ************************************************ 00866 ** ** 00867 NAME : CLEAR ACCUMULATED CHARGE 00868 * (MOD150> * 00869 * 00870 * ************************************************ 00871 * * 00872 * ENTRY : NOTHING * 00873 RETURNS : TOTAL * 00874 * 00875 ************************************************** 00876 0980 AE 04 MOD150 LDX 114 . 00877 0982 4F MOD1S1 CLR A Clear TOTAL 00878 0983 D7 0130 STA TOTAL-l.X 00879 0986 5A DEC X 00880 0987 26 F9 BNE MOD1S1 ~HITACHI 1094 00881 0989 81 RTS 00882 00883 ************************************************* 00884 00885 * NAME END (MOD160) * 00886 * * 00887 * ************************************************ * 00888 00889 ** ENTRY: NOTHING ** 00890 * RETURNS : INTERNAL RAM * 00891 * * 00892 ************************************************ 00893 098A CD 18DA MOD160 JSR END CLear RAM 00894 098D 81 RTS 00895 * 00896 ***** PROGRAM MODULE FOR CHECK INPUT DATA ****** 00897 * 00898 ************************************************ 00899 * * 00900 * NAME : CHECK FOR NORMAL DIALING * 00901 * (CHEKl) 00902 * 00903 * ************************************************ * 00904 * * 00905 * ENTRY KEYSET. WAIn. WAITS. LCOMP * 00906 * DIAP1 * 00907 * RETURNS DIALNO. DIAOAT. MEMO. BZR * 00908 * WAIn. LCDM. OIAP1. LCDMP * 00909 * WAITS. CURADP; ERFLG * 00910 * * 00911 ************************************************ 00912 098E B6 54 CHEKl LOA KEY SET Key data " * ? 00913 0990 A1 2A CMP 1I$2A 00914 0992 27 11 BEQ CHK12 Key data " II " ? 00915 0994 A1 23 CMP 11$23 00916 0996 27 OD BEQ CHK12 Key data o- 9 ? 00917 0998 A1 39 CMP 11$39 00918 099A 22 04 BHI CHl 39 ? 01049 OA79 25 07 BCS CHK33 01050 OA7B B7 4B STA CURADP It so. stop cursor position 01051 OA7D 4A DEC A 01052 OA7E B7 40 STA LCDMP 01053 OA80 20 02 BRA CHK34 01054 OA82 3C 40 CHK33 INC LCDMP It not. increment cursor position, 01055 OA84 CD 1l0E CHK34 JSR LCD 01056 OA87 20 02 BRA CHK36 01057 OA89 10 BE CHK35 BSET O.ERFLG If invaLid data input. buzzing 01058 OA8B 81 CHK36 RTS 01059 01060 * ************************************************ 01061 01062 * NAME : CHECK FOR TELEPHONE NUMBERS ** 01063 * (CHEK4) * 01064 * 01065 * ************************************************ * 01066 01067 ** ENTRY: KEYSET. LCDMP. MODFLG ** 01068 * RETURNS : ERFLG. LCDM. LCDMP. CURADP * 01069 ************************************************** 01070 01071 OA8C B6 40 CHEK4 LDA LCDMP Cursor positon > Line 20? 01072 OA8E Al 13 CMP ~19 01073 OA90 22 OC BHI CHK42 01074 OA92 BE 40 LDX LCDMP Process for Line 1-20 01075 OA94 B6 54 LDA KEY SET 01076 OA96 E7 71 STA LCDM.X Store key d~ta in LCDM 01077 OA98 3C 40 INC LCDMP 01078 OA9A 3C 4B INC CURADP 01079 OA9C 20 37 BRA CHK45 01080 OA9E B6 54 CHK42 LDA KEY SET Process for Line 21-38 01081 OAAO Al 2A CMP ~$2A Key data "*"? 01082 OAA2 27 1A BEQ CHK43 01083 OAA4 Al 23 CMP ~$23 Key d~ta II ** II ? 01084 OAA6 27 16 BEQ CHK43 01085 OAA8 Al 39 CMP ~$39 Key data o- 9 ? 01086 OAAA 22 2E BHI CHK46 01087 OAAC Al 30 CMP ~$30 01088 OAAE 24 OE BCC CHK43 01089 OABO B6 41 LDA MODFLG 01090 OAB2 Al 06 CMP ~$6 Modify data? 01091 OAB4 26 24 BNE CHK46 01092 OAB6 B6 54 LDA KEY SET 01093 OAB8 Al 20 CMP ~$20 If so. SP is vaL id d~ta 01094 OABA 27 02 BEQ CHK43 01095 OABC 20 1C BRA CHI<46 01096 OABE BE 40 CHK43 LDX LCDMP 01097 OACO B6 54 LDA KEYSET 01098 OAC2 E7 71 STA LCDM.X 01099 OAC4 B6 4B LDA CURADP 01100 OAC6 Al 27 CMP ~39 Cursor position> Line 39? ~HITACHI 1098 01101 OAC8 25 07 BCS CHK44 01102 OACA B7 4B STA CURADP 01103 OACC 4A DEC A 01104 OACD B7 40 STA LCDMP 01105 OACF 20 04 BRA CHK45 01106 OAD1 3C 40 CHK44 INC LCDMP Increment cursror position 01107 OAD3 3C 48 INC CURADP 01108 OAD5 CD 110E CHK45 JSR LCD Displey figures 01109 OAD8 20 02 BRA CHK47 01110 OADA 10 BE CHK46 BSET O.ERFLG If invelid date input. buzzer 01111 OADC 81 CHK47 RTS 01112 * 01113 ************************************************ 01114 01115 * NAME : CHECK FOR CALENDAR & TIME. * 01116 * CHARGE (CHEK5) * 01117 * * 01118 * ************************************************* 01119 * * 01120 ENTRY : KEYSET. TRMFLG. MODFLG 01121 * RETURNS : ERFLG. LCDM. LCDMP. CURADP * 01122 * * 01123 ************************************************** 01124 OADD B6 54 CHEK5 LDA KEY SET Key data = 0 - 9? 01125 OADF Al 39 CMP 11$39 01126 OAEI 22 2C BHI CHK53 01127 OAE3 Al 30 CMP 11$30 01128 OAE5 24 02 BCC CHK51 01129 OAE7 20 26 BRA CHK53 01130 OAE9 BE 40 CHK51 LDX LCDMP Store key data in LCDM 01131 OAEB B6 54 LDA KEYSET 01132 OAED E7 71 STA LCDM.X 01133 OAEF B6 43 LDA TRMFLG 01134 OAFl Al 01 CMP III 01135 OAF3 26 lC BNE CHK5F 01136 OAFS 3C 40 INC LCDMP 01137 OAF7 3C 48 INC CURADP 01138 OAF9 B6 41 LDA MODFLG 01139 OAFB Al OD CMP II$D 01140 OAFD 26 08 BNE CHK52 01141 OAFF CD 17EC JSR CURCAL Define cursor position for 01142 OB02 CD 110E JSR LCD -setting calendar & time 01143 OB05 20 OA BRA CHK5F 01144 OB07 CD 17BB CHK52 JSR CUR RAT Define cursor position tor 01145 OBOA CD 110E JSR LCD -setting charge 01146 OBOD 20 02 BRA CHK5F 01147 OBOF 10 BE CHK53 BSET O.ERFLG Set error process request flag 01148 OB11 81 CHK5F RTS 01149 01150 * ************************************************ 01151 * 01152 * NAME : MOVE CURSOR TO RIGHT OR LEFT ** 01153 * (CURLR) * 01154 ************************************************** 01155 ~HITACHI 1099 I 01156 01157 ** ENTRY KEYDAT. FLAG. BZRFLG. MODFLG ** 01158 * TRMFLG. WAIT3. LCDMP. CURADP * 01159 * RETURNS LCDM. LCDMP. CURADP * 01160 * 01161 * ************************************************ 01162 OB12 08 BO 5C CURLR BRSET 4.WAIT3.CURLRF Output tone? 01163 OB15 B6 41 LDA MODFLG 01164 OB17 Al 00 CMP ~$D Set caLendar & time? 01165 OB19 27 2B BEQ CURLR4 01166 OB1B AlOE CMP ~$E Set charge ? 01167 OB1D 27 3C BEQ CURLR7 01168 OB1F B6 58 LDA KEYDAT If not. move cursor normaLLy 01169 OB21 Al 29 CMP 1*$29 01170 OB23 26 OB BNE CURLR2 01171 OB25 02 42 49 BRSET 1. FLAG. CURLRF 01172 OB28 OE 4E 14 BRSET 7.BZRFLG.CURLR3 01173 OB2B CD 1911 JSR LFCRSR Move cursor to Left? 01174 OB2E 20 41 BRA CURLRF 01175 OB30 Al 2A CURLR2 CMP ~$2A 01176 OB32 26 3D BNE CURLRF 01177 OB34 02 42 3A BRSET 1.FLAG.CURLRF 01178 OB37 OE 4E 05 BRSET 7.BZRFLG.CURLR3 01179 OB3A CD 1934 JSR RTCRSR 01180 OB3D 20 32 BRA CURLRF 01181 OB3F 3A 43 CURLR3 DEC TRMFLG 01182 OB41 CD 0587 JSR MODE2 Search data 01183 OB44 20 2B BRA CURLRF 01184 OB46 B6 58 CURLR4 LDA KEYDAT Move cursor for setting caLendar & time 01185 OB48 Al 29 CMP ~$29 01186 OB4A 26 06 BNE CURLR5 01187 OB4C 3A 40 DEC LCDMP Move cursor to Left 01188 OB4E 3A 48 DEC CURADP 01189 OB50 20 04 BRA CURLR6 01190 OB52 3C 40 CURLR5 INC LCDMP Move cursor to right 01191 OB54 3C 4B INC CURADP 01192 OB56 CD 17EC CURLR6 JSR CUR CAL 01193 OB59 20 13 BRA CURLRA 01194 OB5B B6 58 CURLR7 LDA KEYDAT Move cursor for setting charge 01195 OB5D Al 29 CMP ~$29 01196 OB5F 26 06 BNE CURLR8 01197 OB61 3A 40 DEC LCDMP Move cursor to Left 01198 OB63 3A 4B DEC CURADP 01199 OB65 20 04 BRA CURLR9 01200 OB67 3C 40 CURLR8 INC LCDMP Move cursor to right 01201 OB69 3C 4B INC CURADP 01202 OB6B CD 17BB CURLR9 JSR CURRAT 01203 OB6E CD 110E CURLRA JSR LCD 01204 OB71 81 CURLRF RTS 01205 01206 * ************************************************ 01207 * * 01208 * NAME : MOVE CURSOR TO 21ST DIGIT * 01209 * (MVECUR) 01210 * * * ~HITACHI 1100 01211 ************************************************ 01212 * * 01213 * ENTRY : WAIT3 * 01214 * RETURNS : LCDMP, CURADP 01215 * 01216 * ************************************************ * 01217 OB72 08 BO OA MVECUR BRSET 4,WAIT3,MVECUF Output tone? 01218 OB75 A6 14 LDA M20 Move cursor on 21st digit 01219 OB77 B7 40 STA LCDMP 01220 OB79 4C INC A 01221 OB7A B7 4B STA CURADP 01222 OB7C CD 1l0E JSR LCD 01223 OB7F 81 MVECUF RTS 01224 01225 * PROGRAM MODULE FOR TIMER1 ************** **** 01226 01227 * 01228 * ************************************************ 01229 * * 01230 NAME : CONTROL TIMER1 (TIMER1) 01231 * * 01232 ************************************************** 01233 * * 01234 * ENTRY : NOTHING * 01235 RETURNS : NOTHING * 01236 * 01237 * * ************************************************ 01238 OB80 IF 09 TIMER 1 BCLR 7,TCR 01239 OB82 A6 FA LDA M$FA 01240 OB84 B7 08 STA TDR 01241 OB86 CD OB8D JSR BUZC 01242 OB89 CD OBDB JSR FIGURE 01243 OB8C 80 RTI 01244 01245 * ************************************************ 01246 ** ** 01247 NAME : COUNT BUZZING TIME (BUZC) 01248 01249 ************************************************** 01250 ** ** 01251 ENTRY BZRFLG, BZRCNT, ERR1, ERR2 01252 * WAITS * 01253 * RETURNS BZRFLG, BZRCNT, ERR1, ERR2 * 01254 * FLAG, WAITS * 01255 * 01256 * ************************************************ 01257 OBBD 06 4E 06 BUZC BRSET 3,B2RFLG,BU2C1 Test it buzzer end 01258 OB90 OE B2 ID BRSET 7,WAIT5,BU2C2 01259 OB93 CC OBDA JMP BU2C6 01260 OB96 BE 4D BUZC1 LDX BZRCNT+1 Count buzzer time 01261 OB98 SA DEC X 01262 OB99 BF 4D STX BZRCNT+1 01263 OB9B A3 00 CPX 110 01264 OB9D 26 11 BNE BUZC2 01265 OB9F B6 4C LDA B2RCNT ~HITACHI 1101 01266 OBA1 27 09 BEQ BUZC3 01267 OBA3 4A DEC A 01268 OBA4 B7 4C STA BZRCNT 01269 OBA6 A6 FF LDA II$FF 01270 OBA8 B7 4D STA BZRCNT+l 01271 OBAA 20 04 BRA BUZC2 01272 OBAC 17 4E BUZC3 BCLR 3.BZRFLG Count dispLay time 01273 OBAE IE B2 BSET 7. WAIT5 01274 OBBO C6 013B BUZC2 LOA ERR1 01275 OBB3 27 07 BEQ BUZC5 01276 OBB5 4A DEC A 01277 OBB6 C7 013B STA ERRl 01278 OBB9 CC OBDA JMP BUZC6 01279 OBBC C6 013C BUZC5 LOA ERR2 01280 OBBF 27 19 BEQ BUZC6 01281 08C1 4A DEC A 01282 OBC2 C7 013C STA ERR2 01283 OBC5 Al 01 CMP III 01284 OBC7 26 OC BNE BUZC4 01285 OBC9 CD 1966 JSR LCDMCR 01286 OBCC CD 110E JSR LCD 01287 OBCF 12 42 BSET 1.FLAG Define fLag for caLendar & time 01288 OBD1 IF B2 BCLR 7. WAIT5 01289 OBD3 20 05 BRA BUZC6 01290 OBD5 A6 FF BUZC4 LOA II$FF 01291 OBD7 C7 013B STA ERR1 01292 OBDA 81 BUZC6 RTS 01293 01294 ************************************************* 01295 * ** 01296 NAME : COUNI TIME FOR DIALING 01297 * INFORMATION ON LCD (FIGURE) * 01298 * 01299 * ************************************************ * 01300 * 01301 * ENTRY TCNTR. TELFLG. FLAG. CALNDR ** 01302 * TEL. SINGL. TOTAL 01303 * RETURNS TCNTR. CALNDR. TEL. SINGL * 01304 * TOTAL. LCDM. CURADP. SECCNT * 01305 * * 01306 ************************************************ 01307 OBDB 3A 70 FIGURE DEC TCNTR Decrement I-second counter 01308 OBDD 26 45 BNE FIG8 I-second? 01309 OBDF A6 7D LOA 1I$7D ReinitiaLize I-second counter 01310 OBE1 B7 70 STA TCNTR 01311 OBE3 CD 11E4 JSR YERCNT Count caLender 01312 OBE6 01 44 OD BRCLR O.TELFLG.FIG1 Hand-set up? 01313 OBE9 CD 1489 JSR TELCLR CLear eLapsed time 01314 OBEC CD 17B1 JSR SNGCLR CLear charge 01315 OBEF 4F CLR A 01316 OBFO C7 0135 STA SECCNT Clear charge time counter 01317 OBF3 C7 0136 STA SECCNT+l 01318 OBF6 03 44 06 FIG1 BRCLR 1.TELFLG.FIG2 TaLking? 01319 OBF9 CO IlEA JSR TLCNT Count eLapsed time 01320 OBFC CD 15CE JSR MONEY Count charge ~HITACHI 1102 01321 OBFF 02 42 OB FIG2 8RSET 1.FLAG.FIG3 DispLay caLendar & time? 01322 OC02 06 42 OD 8RSET 3.FLAG.FIG4 ELapsed time? 01323 OC05 OC 42 OF 8RSET 6.FLAG.FIG5 AccumuLated charge? 01324 OC08 OE 42 11 8RSET 7.FLAG.FIG6 Charge? 01325 OCOB 20 17 BRA FIG8 01326 OCOD CD 1258 FIG3 JSR CALLCD Load caLendar & time deta 01327 OC10 20 OD BRA FIG7 01328 OC12 CD 1267 FIG4 JSR TELLCD Loed eLapsed time data 01329 OC15 20 08 BRA FIG7 01330 OC17 CD 16CD FIGS JSR TOLSTA Load accumuLated charge deta 01331 OC1A 20 03 BRA FIG7 01332 OC1C CD 167E FIG6 JSR SNGSTA Load charge data 01333 OC1F 3F 4B FIG7 CLR CURADP Cursor OFF 01334 OC21 CD 110E JSR LCD DispLay information 01335 OC24 81 FIG8 RTS 01336 01337 * **** PROGRAM MODULE FOR TIMER2 ************ 01338 * 01339 * 01340 ************************************************ 01341 01342 * NAME : CONTROL TIMER2 (TIMER2) * 01343 * * 01344 ************************************************** 01345 01346 * ENTRY : NOTHING * 01347 * RETURNS : NOTHING * 01348 * * 01349 * ************************************************ * 01350 OC25 10 11 TIMER2 BCLR 6.SSR 01351 OC27 CD OC31 JSR K88SCN 01352 OC2A CD OC95 JSR BUZZ 01353 OC2D CD OCAF JSR TELMN 01354 OC30 80 RTI 01355 01356 * ************************************************ 01357 * * 01358 NAME : KEY SCAN (K88SCN) 01359 * * 01360 ************************************************** 01361 * * 01362 ENTRY NOTHING 01363 * RETURNS: KEYDAT. FLAG * 01364 * * 01365 * ************************************************ * 01366 OC31 00 42 60 K88SCN BRSET 0.FLAG.K88SN9 Test if there is key data 01367 OC34 A6 80 LOA ~$80 InitiaLize strobe data 01368 OC36 B7 5B STA STBDAT 01369 OC38 A6 01 LOA ~$Ol InitiaLize key number 01370 OC3A B7 5A STA KEYNUM 01371 OC3C 3F 59 CLR TOTLI * 01756 * * 01757 ************************************************ 01758 * * 01759 * ENTRY TELWAT. TELFLG. REC. BZR * 01760 * PDDTR * ~HITACHI 1110 01761 * RETURNS: TELWAT. WAIT3. BZR. TELFLG * 01762 * REC. LCDM. BZRFLG. ERRI. ERR2 * 01763 01764 * ************************************************ * 01765 OEF2 B6 B6 TELMSO LOA TELWAT Initiellze retryin9 01766 OEF4 26 1A BNE TELMS1 01767 OEF6 A6 1E LDA 1:130 01768 OEF8 C7 0139 STA TELNO 01769 OEFB A6 FF LOA ~$FF 01770 OEFO C7 013A STA TELCNT 01771 OFOO A6 01 LOA ~1 01772 OF02 B7 B6 STA TELWAT 01773 OF04 OE 4F 06 BRSET 7.8ZR.TELS01 Initielize tone output counter? 01774 OF07 A6 OA LDA ~10 01775 OF09 B7 B4 STA REC 01776 OFOB IE 4F BSET 7.BZR 01777 OFOO CC OFD7 TEL501 JMP TELMSF 01778 OF10 Al 01 TELMS1 CMP U 01779 OF12 26 59 BNE TELM54 01780 OF14 02 BO 08 BRSET 1. WAIT3. TEL51l 01781 OFl7 A6 35 LOA ~$3S Initiellze for blinkin9 retry no. 01782 OF19 87 B1 STA WAIT4 01783 OF1B 12 BO BSET 1.WAIn 01784 OFlD 20 28 BRA TEL513 01785 OF1F 04 BO OF TELSll BRSET 2.WAIT3.TEL512 01786 OF22 3A B1 DEC WAIT4 Turn on retry no. 01787 OF24 B6 Bl LOA WAIT4 01788 OF26 26 1F BNE TEL513 01789 OF28 13 BO BCLR 1. WAIn 01790 OF2A 14 80 BSET 2.WAIT3 01791 OF2C CO 1526 JSR DIAL2 01792 OF2F 20 16 BRA TEL513 01793 OF31 3A 81 TEL512 DEC WAIT4 Turn off retry no. 01794'OF3386 B1 LOA WAIT4 01795 OF35 26 10 8NE TELS13 01796 OF37 13 BO BCLR 1.WAIn 01797 OF39 15 BO 8CLR 2.WAIT3 01798 OF3B B6 42 LOA FLAG 01799 OF30 A4 35 AND ~$3S 01800 OF3F B7 42 STA FLAG 01801 OF41 CD 1966 JSR LCOMCR 01802 OF44 CD 110E JSR LCD 01803 OF47 C6 013A TEL513 LOA TELCNT Wait 2 minutes 01804 OF4A 4A DEC A 01805 OF4B C7 013A STA TELCNT 01806 OF4E 26 12 BNE TELMS2 01807 OF 50 C6 0139 LOA TELNO 01808 OF53 4A DEC A 01809 OF 54 C7 0139 STA TELNO 01810 OF57 26 OC BNE TELM53 01811 OF 59 3F B6 CLR TELWAT 01812 OFSB 12 4F BSET 1.BZR If waiting finished. set flag 01813 OF50 18 .BO BSET 4.WAIT3 01814 OF SF CD 1526 JSR OIAL2 01815 OF62 CC OF07 TELM52 JMP TELMSF ~HITACHI 1111 --. -.----- - ---"----.--._ ··----0 .. - ___ ". _ _ -~---. 01816 OF65 A6 FF TELM53 LDA I:I$FF 01817 OF67 C7 013A STA TELCNT 01818 OF6A CC OFD7 JMP TELM5F 01819 OF6D Al 02 TELM54 CMP 1:12 01820 OF6F 26 4C BNE TELM5A 01821 OF71 OC 44 09 BRSET 6.TELFLG.TELM55 01822 OF74 OE 44 OC BRSET 7.TELFLG.TELM56 01823 OF77 CD 1001 JSR CANCEL 01824 OF7A CC OFD7 JMP TELM5F 01825 OF7D 06 03 09 TELM55 BRSET 3.PDDTR.TELM57 Test if answered 01826 OF80 CC OFA4 JMP TELM58 01827 OF83 04 03 03 TELM56 BRSET 2.PODTR.TELM57 0182B OFB6 CC OFA4 JMP TELM58 01829 OF89 12 44 TELM57 BSET 1.TELFLG Define flag for taLking 01830 OFBB 11 44 BCLR O.TELFLG 01831 OF8D 16 4E BSET 3.BZRFLG InitiaLize buzzering 01832 OF8F A6 07 LDA 1:1$7 01833 OF91 B7 4C STA BZRCNT 01834 OF93 A6 FF LDA I:I$FF 01835 OF95 B7 4D STA BZRCNT+1 01836 OF97 4F CLR A 01837 OF98 C7 013B STA ERR1 01838 OF9B C7 013C STA ERR2 01839 OF9E CD 1001 JSR CANCEL 01840 OFA1 CC OFD7 JMP TELM5F 01841 OFA4 C6 OBA TELM58 LDA TELCNT Output tone 45s 01842 OFA7 4A DEC A 01843 OFA8 C7 013A STA TELCNT 01844 OFAB 26 OD BNE TELM59 01845 OF AD C6 0139 LOA TELNO 01846 OFBO 4A DEC A 01847 OFB1 C7 0139 STA TELNO 01848 OFB4 26 04 BNE TELM59 01849 OFB6 A6 03 LOA 1:13 01850 OFB8 B7 86 STA TELWAT 01851 OFBA CC OFD7 TELM59 JMP TELM5F 01852 OFBD Al 03 TELM5A CMP 1:13 01853 OFBF 26 OC BNE TELM5B 01854 OFC1 B6 OC LDA PFOTR Stop tone output 01855 OFC3 A4 CF AND 1:1%11001111 01856 OFC5 B7 OC STA PFDTR 01857 OFC7 3A B4 DEC REC Decrement repeat counter 01858 OFC9 B6 B4 LDA REC 01859 OFCB 26 06 BNE TELM5C 01860 OFCD CD 1001 TELM5B JSR CANCEL I f 10 times. canceL retrying 01861 OFDO CC OFD7 JMP TELM5F 01862 OFD3 3F B6 TELM5C CLR TELWAT I f not. reinitiaLize for next output 01863 OFD5 19 BO BCLR 4. WAIT3 01864 OFD7 CD 1038 TELM5F JSR CALRST 01865 OFDA 81 RTS 01866 * 01867 ************************************************ 01868 * * 01869 * NAME : CONNECT LINES (TELM60) * 01870 * * ~HITACHI 1112 01871 ************************************************ 01872 01873 * ENTRY MODFLG. PDDTR * 01874 * RETURNS : LCDM. MEMO. TELFLG. WAIT3 * 01875 * CURADP. LCDMP * 01876 * * 01877 ************************************************** 01878 OFD8 86 41 TELM60 LDA MODFLG 01879 OFDD 26 1E 6NE TELM62 01880 OFDF 04 03 05 6RSET 2.PDDTR.TELM61 Handset up? 01881 OFE2 06 03 02 6RSET 3.PDDTR.TELM61 01882 OFE5 20 16 6RA TELM62 01883 OFE7 66 42 TELM61 LDA FLAG If so. cLear dispLay 01884 OFE9 A4 35 AND '*$35 01885 OFE6 67 42 STA FLAG 01886 OF ED CD 1966 JSR LCDMCR 01887 OFFO CD 110E JSR LCD 01888 OFF3 A6 02 LDA '*2 01889 OFF5 67 40 STA LCDMP 01890 OFF7 3F 46 CLR CURADP 01891 OFF9 10 60 6SET 0.WAIT3 Define fLag for tone output 01892 OFF6 10 44 6SET O.TELFLG 01893 OFFD CD 1038 TELM62 JSR CALRST 01894 1000 81 RTS 01895 ************************************************* 01896 01897 01898 * NAME : RESET RETRYING (CANCEL) * 01899 * * 01900 ************************************************** 01901 * 01902 * ENTRY : NOTHING 01903 * RETURNS : RAM(USED FOR RETRYING) * 01904 * * 01905 * * ************************************************ 01906 1001 66 4E CANCEL LDA BZRFLG Reset retrying 01907 1003 A4 FE AND '*"11111110 01908 1005 67 4E STA 6ZRFLG 01909 1007 02 44 06 6RSET 1. TELFLG. CANCL2 01910 100A 66 OC LDA PFDTR 01911 100C A4 DF AND '*"11011111 01912 100E 67 OC STA PFDTR 01913 1010 4F CANCL2 CLR A Clear RAM 01914 1011 67 66 STA TELWAT 01915 1013 C7 0139 STA TELNO 01916 1016 C7 013A STA TELCNT 01917 1019 67 64 STA REC 01918 1016 67 4C STA 6ZRCNT 01919 101D 67 60 STA WAIT3 01920 101F 67 61 STA WAIT4 01921 1021 67 62 STA WAITS 01922 1023 66 4F LDA 6ZR 01923 1025 A4 7F AND ,*"01111111 01924 1027 67 4F STA 6ZR 01925 1029 66 06 LDA PEDTR ~HITACHI 1113 I 01926 102B A4 7F AND 1:1%01111111 01927 102D B7 OB STA PEDTR 01928 102F B6 B3 LDA MEMOP 01929 1031 B7 OB STA PEDTR 01930 1033 10 BO BSET O.WAIT3 01931 1035 12 42 BSET I.FLAG 01932 1037 81 RTS 01933 * 01934 ************************************************ 01935 * * 01936 * NAME : RESET HANDSET (CALRST) * 01937 * * 01938 ************************************************ 01939 * * 01940 * ENTRY : NOTHING * 01941 * RETURNS : NOTHING * 01942 * * 01943 ************************************************ 01944 103B 01 4E 03 CALRST BRCLR O. BZRFLG. RTS11 Test if retryins 01945 103B CC 10CE JMP RTS18 01946 103E OB 4F OB RTS11 BRCLR 5.BZR.RTS12 01947 1041 09 03 08 BRCLR 4.PDDTR.RTS12 01948 1044 B6 OC LDA PFDTR ReLay OFF 01949 1046 A4 OF AND 11%11011111 01950 1048 B7 OC STA PFDTR 01951 104A 1B 4F BCLR 5.BZR 01952 104C 04 03 07 RTS12 BRSET 2. PDDTR. RTS13 Test if taLkins 01953 104F 06 03 04 BRSET 3.PDDTR.RTS13 01954 1052 19 BO BCLR 4. WAIT3 01955 1054 20 03 BRA RTS14 01956 1056 CC lODE RTS13 JMP RSTEND 01957 1059 01 BO 34 RTS14 BRCLR O. WAIn. RTS17 01958 105C 66 OB LOA PEDTR I f not. HS pin OFF 01959 105E A4 7F AND 1:1%01111111 01960 1060 B7 OB STA PEDTR 01961 1062 B6 B3 LOA ME MOP 01962 1064 B7 OB STA PEDTR 01963 1066 17 42 BCLR 3.FLAG 01964 106B 12 42 BSET I.FLAG 01965 106A 11 BO BCLR 0.WAIT3 01966 106C AE 05 LOX 115 01967 106E A6 20 RTS15 LDA 11$20 01968 1070 E7 B6 STA DIADAT-l, X 01969 1072 5A DEC X 01970 1073 26 F9 BNE RTS15 01971 1075 CD 18DA JSR END 01972 1078 B6 41 LDA MODFLG 01973 107A Al 01 CMP 11$1 01974 107C 27 OC BEQ RTS16 01975 107E Al 02 CMP 1:1$2 01976 1080 27 08 BEQ RTS16 01977 1082 Al 03 CMP 1:1$3 01978 1084 27 04 BEQ RTS16 01979 1086 Al OC CMP I:I$C 01980 1088 27 00 BEQ RTS16 ~HITACHI 1114 01981 108A 09 BO 03 RTS16 BRCLR 4.WAIT3.RTS17 01982 108D CD 18DA JSR END 01963 1090 4F RTS17 CLR A CLear RAM 01984 1091 B7 B6 STA TELWAT 01985 1093 C7 0139 STA TELNO 01986 1096 C7 013A STA TELCNT 01987 1099 B7 B4 STA REC 01988 109B 97 AE STA WAIT1 01989 109D B7 AF STA WAIT2 01990 109F 97 BO STA WAIT3 01991 10A1 B7 B2 STA WAITS 01992 10A3 B7 BC STA DIAP1 01993 lOA5 B7 BD STA DIAP2 01994 10A7 B6 44 LDA TELFLG 01995 10A9 A4 04 AND *I'WOOO0100 01996 10AB B7 44 STA TELFLG 01997 lOAD B6 4E LDA BZRFLG 01998 lOAF A4 F9 AND *lY,11l11001 01999 10B1 B7 4E STA BZRFLG 02000 10B3 B6 4F LDA 9ZR 02001 lOBS A4 01 AND *lY,00000001 02002 10B7 B7 4F STA BZR 02003 10B9 CD 146C JSR DIACLR 02004 10BC CD 1489 JSR TELCLR 02005 10BF CD 17B1 JSR SNGCLR 02006 10C2 4F CLR A 02007 10C3 C7 0135 STA SECCNT 02008 10C6 C7 0136 STA SECCNT+1 02009 10C9 OC BO OE BRSET 6.WAIT3.RTS19 02010 lOCC 20 10 BRA RSTEND 02011 10CE B6 41 RTS18 LDA MODFLG 02012 10DO A1 10 CMP 1*$10 02013 10D2 26 OA BNE RSTEND 02014 10D4 CD 1001 JSR CANCEL 02015 10D7 CC 104C JMP RTS12 02016 10DA 3F 43 RTS19 CLR TRMFLG 02017 lODC ID BO BCLR 6.WAIT3 02018 lODE 81 RSTEND RTS 02019 * 02020 ************************************************ 02021 * * 02022 * NAME : REFER TO DIAL NUMBER (MFOUT) * 02023 * * 02024 ************************************************ 02025 * * 02026 * ENTRY : ACCA * 02027 * RETURNS: MFDAT. Bit C * 02028 * * 02029 ************************************************ 02030 10DF SF MFOUT CLR X 02031 10EO Dl 10F6 MFOUTl CMP MFTBL.X 02032 10E3 27 09 BEQ MFOUT2 02033 10ES SC INC X 02034 10E6 SC INC X 02035 10E7 A3 18 CPX *lMFTBLE-MFTBL ~HITACHI 1115 02036 10E9 26 F5 BNE MFOUTl 02037 10E8 98 CLC 02038 10EC 20 07 BRA MFOUTE 02039 10EE 5C MFOUT2 INC X 02040 10EF 06 10F6 LOA MFT8L.X 02041 10F2 87 B5 STA MFOAT Define dieL no. 02042 10F4 99 SEC 02043 10F5 81 MFOUTE RTS 02044 * 02045 ************************************************ 02046 ** 02047 NAME / : DATA TABLE ** 02048 02049 ************************************************** 02050 10F6 31 MFTBL FCC "1" Output tone date 02051 10F7 09 FeB "00001001 02052 10F8 32 FCC "2" 02053 10F9 OA FCB "00001010 02054 10FA 33 FCC "3" 02055 10F8 OC FCB "00001100 02056 10FC 34 FCC "4" 02057 10FD 11 FCB "00010001 02058 10FE 35 FCC "5" 02059 10FF 12 FCB "00010010 02060 1100 36 FCC "6" 02061 1101 14 FCB "00010100 02062 1102 37 FCC "7" 02063 1103 21 FCB "00100001 02064 11 04 38 FCC "8" 02065 11 05 22 FCB "00100010 02066 11 06 39 FCC "9" 02067 11 07 24 FCB "00100100 02068 11 08 2A FCC "*" 02069 1109 41 FCB "01000001 02070 11 OA 30 FCC "0" 02071 1108 42 FCB "01000010 02072 llOC 23 FCC "!:t" 02073 11 00 44 FCB "01000100 02074 110E MFTBLE EQU * 02075 02076 ***** PROGRAM MODULE FOR LCD DISPLAY ******** 02077 02078 * 02079 * ************************************************ 02080 02081 ** NAME : LCD PROGRAM (LCD) ** 02082 02083 ************************************************** 02084 02085 * ENTRY : LCDM. CURADP * 02086 * RETURNS : NOTHING * 02087 * * 02088 * ************************************************* 02089 1l0E 98 LCD SEI. 02090 110F AE 02 LOX !:t2 $ HITACHI 1116 02091 1111 CD 1148 JSR LCDINS CLear address counter 02092 1114 3F 6C CLR POINTR CLear pointer 02093 1116 BE 6C LOX POINTR 02094 1118 EE 71 LCD1 LOX LCDM.X Load ASCII into IX 02095 111A CD 115C JSR LCDDSP DispLay figure 02096 1110 3C 6C INC POINTR Increment pointer 02097 111F BE 6C LOX POINTR 02098 1121 A3 28 CPX ~40 POinter=40? 02099 1123 26 F3 BI'JE LCD1 Branch if pointer =/ 40 02100 1125 86 4B LOA CURADP 02101 1127 B7 6C STA POINTR Load cursor position data 02102 1129 27 19 BEQ LCD4 DispLay cursor? 02103 112B AE 02 LOX ~02 02104 1120 CD 1148 JSR LCDINS Load instruction 02105 1130 3A 6C DEC POINTR 02106 1132 27 09 8EQ LCD3 DispLay on 1st digit? 02107 1134 AE 14 LCD2 LOX ~$14 02108 1136 CD 1148 JSR LCD INS Shift cursor to right 02109 1139 3A 6C DEC POINTR 02110 113B 26 F7 BNE LCD2 02111 1130 AE OE LCD3 LOX ~$OE Cursor ON 02112 113F CD 1148 LCD5 JSR LCD INS 02113 1142 9A CLI 02114 1143 81 RTS 02115 1144 AE OC LCD4 LOX ~$OC Cursor OFF 02116 1146 20 F7 BRA LCD5 02117 02118 * ****************************************-******** 02119 ** '"'" 02120 NAME : LOAD INSTRUCTION INTO 02121 * INSTRUCTION REGISTER(LCDINS)* 02122 * 02123 *******"'*******"'***"'*"'*****"'*****"'**************'" 02124 02125 ** ENTRY: IX *'" 02126 * RETURNS : NOTHING '" 02127 02128 * *************************"'*****************"'***'" * 02129 1148 CD 11C4 LCD INS JSR LCDBSY Check busy fLag 02130 1148 BF 00 STX PADTR 02131 1140 B6 OC LOA PFDTR 02132 114F A4 FO AND ~$FO 02133 1151 B7 OC STA PFDTR R¥W=O RS=O E=O 02134 1153 AA 01 ORA ~$01 R¥W=O RS=O E=1 02135 1155 B7 OC STA PFDTR 02136 1157 A4 FO AND ~$FO 02137 1159 B7 OC STA PFDTR R¥W=O RS=O E=O 02138 115B 81 RTS 02139 02140 '"**************"''''****'''''''''***************'''*****'''*** 02141 02142 '"* NAME : DISPLAY FIGURE ON LCD(LCDDSP) *'" 02143 '" 02144 '************************************************ " ()2145 '" '" ~HITACHI 1117 02146 * ENTRY : IX * 02147 RETURNS : NOTHING 02148 * * ************************************************* 02149 * 02150 115C CD llC4 LCDDSP JSR LCDBSY Check busy fLag 02151 115F BF 00 STX PADTR 02152 1161 B6 OC LOA PFDTR 02153 1163 A4 FO AND IISFO 02154 1165 AA 02 ORA IIS02 R¥W=O RS=l E=O 02155 1167 B7 OC STA PFDTR 02156 1169 AA 01 ORA IIS01 R¥W=O RS=1 E=l 02157 116B B7 OC STA PFDTR 02158 1160 A4 F2 AND IISF2 R/W=O RS=1 E=O 02159 116F B7 OC STA PFDTR 02160 1171 81 RTS 02161 02162 * ************************************************ 02163 * * 02164 * NAME : RESET LCD-II (LCDRES) * 02165 ************************************************** 02166 02167 * * 02168 * ENTRY : NOTHING * 02169 RETURNS : NOTHING 02170 * * 02171 * ************************************************ * 02172 1172 A6 03 LCD RES LOA 113 02173 1174 B7 60 STA CNT Inltl!!Llze CNT 02174 1176 A6 OC LCDRSI LOA IISOC Execute of software timer of 15ms 02175 1178 AE FF LCDRS2 LOX IISFF 02176 117A 5A LCDRS3 DEC X 02177 117B 26 FD 8NE LCDRS3 02178 1170 4A DEC, A 02179 117E 26 F8 8NE LCDRS2 02180 1180 A6 FF LOA IISFF 02181 1182 B7 04 STA PADDR SeLect port A as output 02182 1184 3F OC CLR PFDTR R¥W=O RS=O E=O 021B3 1186 A6 01 LOA IIS01 02184 11B8 B7 OC STA PFDTR R¥W=O RS=O E=1 021B5 l18A A6 30 LOA IIS30 02186 118C B7 00 STA PADTR Output Instruction 02187 l18E 3F OC CLR PFDTR R¥W=O RS=O E=O ,02188 1190 3A 60 DEC CNT 02189 1192 26 E2 8NE LCDRSI 8ranch if not CNT=O 02190 1194 81 RTS 02191 * 02192 ************************************************ 02193 ** 02194 NAME : INITIALIZE DISPLAY MODE OF LCD** 02195 * (LCDINT> * 02196 * * 02197 ************************************************ 02198 02199 ** ENTRY NOTHING ** 02200 * RETURNS : NOTHING * @-HITACHI 1118 02201 * * 02202 ************************************************ 02203 1195 AE 06 LCDINT LDX !:I 6 02204 1197 A3 02 LCDINl CPX !:I 2 02205 1199 27 14 BEQ LCDIN2 02206 119B CD 11C4 LCDIN5 JSR LCDBSY Check busy fLag 02207 119E 3F OC CLR PFDTR R¥W=O RS=O E=O 02208 11AO A6 01 LDA !:II 02209 11A2 B7 OC STA PFDTR R¥W=O RS=O E=l 02210 11A4 D6 1AOC LDA YOKO-l.X 02211 11A7 B7 00 STA PADTR Store instruction data 02212 11A9 3F OC CLR PFDTR R¥W=O RS=O E=O 02213 11AB 5A DEC X 02214 11AC 26 E9 BNE LCDINl Branch if not IX=O 02215 11AE 81 RTS 02216 11AF AE 40 LCDIN2 LDX !:I$40 02217 11B1 CD 1148 JSR LCDINS Output instruction 02218 11B4 AE OC LDX !:I12 02219 11B6 B7 6C STA POINTR 02220 11BB 5F LCDIN3 CLR X 02221 11B9 CD 115C JSR LCDDSP 02222 11BC 3A 6C DEC POINTR 02223 11BE 26 FB BNE LCDIN3 Test if data is written 12 t'~es 02224 11CO AE 02 LDX !:I 2 02225 11C2 20 D7 BRA LCDIN5 02226 ************************************************* 02227 02228 * * 02229 * NAME : CHECK BUSY (LCDBSY) * 02230 * * 02231 ************************************************ 02232 * * 02233 ENTRY : NOTHING 02234 * RETURNS : NOTHING * 02235 * * 02236 * * ************************************************ 02237 11C4 3F 04 LCDBSY CLR PADDR SeLect port A as input 02238 11C6 B6 OC LDA PFDTR 02239 11C8 A4 FO AND !:I$FO R¥W=l RS=O E=O 02240 11CA AA 04 ORA !:I$04 02241 11CC B7 OC STA PFDTR 02242 11CE B6 OC LCDBYl LDA PFDTR 02243 11DO AA 01 ORA !:I$Ol R¥W=l RS=O E=l 02244 1102 B7 OC STA PFDTR 02245 11D4 B6 00 LDA PADTR Load busy fLag into ACCA 02246 11D6 48 LSL A Load MSB into carry bit 02247 11D7 B6 OC LDA PFDTR 02248 11D9 A4 F4 AND !:I$F4 02249 11DB B7 OC STA PFDTR R¥W=l RS=O E=O 02250 11DD 25 EF BCS LCDBYl 02251 11DF A6 FF LDA !:I$FF SeLect port A as output 02252 llEl B7 04 STA PADDR 02253 llE::; 81 RTS 02254 * 1)2255 ************************************************ ~HITACHI 1119 02256 * * 02257 * NAME : COUNT CALENDAR & TIME (YERCNT>* 02258 * * 02259 ************************************************ 02260 * * 02261 * ENTRY : CALNDR * 02262 * RETURNS : CALNDR * 02263 * * 02264 ************************************************ 02265 llE4 AE 05 YERCNT LDX l:I$5 02266 llE6 CD I1F4 JSR TIMCNT Count caLendar & time 02267 llE9 81 RTS 02268 * 02269 ************************************************ 02270 * * 02271 * NAME : COUNT ELAPSED TIME (TLCNT) * 02272 * * 02273 ************************************************ 02274 * * 02275 * ENTRY : TEL * 02276 * RETURNS : TEL * 02277 * * 02278 ************************************************ 02279 llEA AE 03 TLCNT LDX l:I3 02280 llEC 10 6B BSET O. CNTBIT Set bit 02281 llEE CD llF4 JSR TIMCNT Count time 02282 I1F1 11 6B 8CLR O. CNTBIT CLear bit 02283 llF3 81 RTS 02284 * 02285 ************************************************ 02286 * * 02287 * NAME : COUNT TIME (TIMCNT) * 02288 * * 02289 ************************************************ 02290 * * 02291 * ENTRY : CNTBIT * 02292 * RETURNS : CALNDR. TEL * 02293 * * 02294 ************************************************ 02295 llF4 99 TIMCNT SEC Set carry bit 02296 llF5 A6 01 TIMCT! LDA l:Il 02297 llF7 85 68 BIT CNTBIT ELapsed time? 02298 llF9 26 4A 8NE TIMCT2 02299 llFB 4F CLR A CLear acca 02300 I1FC E9 5C ADC CALNDR-l.X Count UP 02301 lIFE 80 , TIMCT3 OAA 02302 llFF 01 6B 08 BRCLR 0.CNT8IT. TIMCT4 02303 1202 B7 6A STA TIMSTA Store TIMSTA 02304 1204 9F TXA IX-)ACCA 02305 1205 A8 02 ADD l:I2 IX+2 02306 1207 97 TAX ACCA-)IX 02307 1208 B6 6A LOA TIMSTA 02308 120A A3 02 TIMCT4 CPX l:I$2 IX=2? 02309 120C 26 3C BNE TIMCT5 02310 120E B7 6A STA TIMSTA ~HITACHI 1120 02311 1210 B6 50 LDA CALNDR 02312 1212 44 LSR A 02313 1213 44 LSR A 02314 1214 44 LSR A 02315 1215 44 LSR A 02316 1216 48 LSL A 02317 1217 B7 5A STA KEYNUM 02318 1219 48 LSL A 02319 121A 48 LSL A 02320 1218 BB 5A ADD KEYNUM 02321 1210 87 5A STA KEYNUM 02322 121F B6 50 LDA CALNDR 02323 1221 A4 OF AND l:i$OF 02324 1223 8B 5A ADD KEYNUM 02325 1225 97 TAX 02326 1226 B6 6A LOA TIMSTA 02327 1228 01 1AOO CMP MONTH-1.X 02328 122B AE 02 LOX l:i2 02329 1220 25 20 TIMCT6 8CS TIMCT? 02330 122F 99 SEC Bit set 02331 1230 06 1A17 LOA SHUNEW-1.X 02332 1233 B7 6A TIMCT8 STA TIMSTA Store count data 02333 1235 A6 01 LOA l:i1 02334 1237 85 6B BIT CNTBIT ELapsed time? 02335 1239 27 17 BEQ TIMCT9 02336 123B 5A DEC X 02337 123C 5A DEC X X-2->X 02338 1230 B6 6A LDA TIMSTA 02339 123F E7 61 STA TEL-l. X Store TEL 02340 1241 5A TIMC10 DEC X Decrement pointer 02341 1242 26 B1 BNE TIMCn Branch if not IX=O 02342 1244 81 RTS 02343 1245 4F TIMCT2 CLR A CLear ACCA 02344 1246 E9 61 ADC TEL-l. X Count UP 02345 1248 20 B4 BRA TIMCT3 02346 124A 01 1A12 TIMCT5 CMP SHUSE-1.X Compare tabLe 02347 1240 20 DE BRA TIMCT6 02348 124F 98 TIMCT7 CLC 02349 1250 20 E1 8RA TIMCTS O->C 02350 1252 B6 6A TIMCT9 LOA TIMSTA 02351 1254 E7 5C STA CALNDR-1.X Store CALNDR counter 02352 1256 20 E9 BRA TIMC10 02353 * 02354 ************************************************ 02355 * * 02356 * NAME : LOAD CALENDAR & TIME DATA * 02357 * INTO DISPLAY RAM (CALLCD)* 02358 * * 02359 ************************************************ 02360 * * 02361 * ENTRY : CALNDR * 02362 * RETURNS : LCDM * 02363 * * 02364 ************************************************ 02365 1258 CD 12AB CALLCD JSR LCDMST ~HITACHI 1121 02366 125B A6 05 LOA 1:15 02367 1250 B7 60 STA CNT 5->CNT 02368 125F A6 1B LOA 1:127 02369 1261 B7 6E STA CALCNT 27->CALCNT 02370 1263 CD 1276 JSR LCD SET Store CALN 02371 1266 81 RTS 02372 02373 * ************************************************ 02374 * **' 02375 * NAME : LOAD ELAPSED TIME DATA 02376 INTO DISPLAY RAM(TELLCD) * 02377 * 02378 * ************************************************ * 02379 * * 02380 ENTRY : CNT. FLAG .* 02381 * RETURNS : LCDM 02382 * * 02383 ************************************************** 02384 1267 CD 12AB TELLCD JSR LCDMST 02385 126A A6 03 LOA 1:13 02386 126C B7 60 STA CNT 3->CNT 023B7 126E A6 1B LOA 1:127 02388 1270 B7 6E STA CALCNT 8->CALCNT 02389 1272 CD 1276 JSR LCD SET 02390 1275 81 RTS 02391 02392 * ************************************************ 02393 * ** 02394 NAME : LOAD DATA INTO DISPLAY RAM 02395 * (LCDSET> * 02396 * 02397 * ************************************************* 02398 * * 02399 * ENTRY : CNT. FLAG * 02400 * RETURNS: LCDM * 02401 02402 ************************************************** 02403 1276 BE 60 LCD SET LOX CNT 02404 1278 06 42 28 LCDSE1 BRSET 3. FLAG. LCDSE2 02405 127B E6 5C LOA CALNDR-1.X Load ceLender dete 02406 1270 A4 OF LCDSE3 AND I:I$OF 02407 127F AB 30 ADD 1:1'0 Dete->ASCII 02408 1281 BE 6E LOX CALCNT 02409 1283 E7 71 STA LCDM.X 0.2410 1285 3A 6E DEC CALCNT 02411 1287 BE 60 LOX CNT 02412 1289 06 42 1B BRSET 3. FLAG. LCDSE6 02413 128C E6 5C LOA CALNDR-1.X 02414 128E 44 LCDSE7 LSR A Shift 4 bits to right 02415 128F 44 LSR A 02416 1290 44 LSR A 02417 1291 44 LSR A 02418 1292 AB 30 ADD 11'0 -)ASCII 02419 1294 BE 6E LOX CALCNT 02420 1296 E7 71 STA LCDM.X ~HITACHI 1122 02421 1298 3A 6D DEC CNT Decrement CNT 02422 129A 3A 6E DEC CALCNT Decrement 2 CALCNT 02423 129C 3A 6E DEC CALCNT 02424 129E BE 6D LDX CNT Load pointer 02425 12AO 26 D6 BNE LCDSE1 . 02426 12A2 81 RTS 02427 12A3 E6 61 LCDSE2 LDA TEL-1.X Load charge counter 02428 12A5 20 D6 BRA LCDSE3 02429 12A7 E6 61 LCDSE6 LDA TEL-1.X Load charge counter 02430 12A9 20 E3 BRA LCDSE7 02431 02432 * ************************************************ 02433 * 02434 NAME : LOAD DISPLAY FORMAT (LCDMST) ** 02435 * 02436 ************************************************** 02437 * * 02438 ENTRY : FLAG 02439 * RETURNS : LCDM * 02440 * * 02441 * ************************************************ * 02442 12AB CD 1966 LCDMST JSR LCDMCR Clear dlaplay RAM 02443 12AE AE OF LDX ~$F 15-)IX 02444 12BO 06 42 09 LCDMS1 BRSET 3.FLAG.LCDMS2 Calendar or charge? 02445 12B3 D6 19E2 LDA CALDAT-1.X For calendar & time display 02446 12B6 E7 7D LCDMS3 STA LCDM+12.X Store In display RAM 02447 12B8 5A DEC X 02448 12B9 26 F5 BNE LCDMS1 02449 12BB 81 RTS 02450 12BC D6 19F1 LCDMS2 LDA TELOAT-1.X For elapsed time display 02451 12BF 20 F5 BRA LCDMS3 02452 02453 * **** SUBROUTINES **************************** 02454 02455 * 02456 * ************************************************ 02457 * * 02458 NAME : REVIEW DATA (KENSAK) * 02459 * 02460 ************************************************** 02461 * * 02462 ENTRY : RFOAT. FLAG * 02463 * RETURNS : FLAG. LCOM 02464 * * 02465 * ************************************************ * 02466 12C1 A6 20 KENSAK LDA ~$20 Clear " * " 02467 12C3 B7 98 STA LCOM+39 02468 12C5 19 42 BCLR 4.FLAG 02469 12C7 B6 45 KENSK1 LDA DTOP Load start address of the data 02470 12C9 B7 47 STA SDP 02471 12CB B6 46 LDA DTOP+1 02472 12CD B7 48 STA SDP+1 02473 12CF 3F 49 CLR DTCNT 02474 12D1 CD 187C JSR INPOAT Load data from external RAM 02475 12D4 86 4A LOA DATA Search space area ~HITACHI 1123 II 02476 12D6 26 09 BNE KENSK2 02477 12D8 86 41 LDA MODFLG 02478 12DA Al 04 CMP 1:1$4 02479 12DC 26 55 BNE I(ENSI<9 02480 12DE CC 1399 JMP KNSRTS 02481 12El B6 43 KENSK2 LDA TRMFLG 02482 I2E3 27 4E BEQ KENSK9 02483 12E5 86 4A KENSK3 LDA DATA Data SP? 02484 12E7 Al 20 CMP 1:1$20 02485 12E9 26 OA BNE I(ENSK4 02486 12EB CD 18C4 JSR DTADD 02487 12EE 3C 49 INC DTCNT 02488 12FO CD 187C JSR INPDAT 02489 12F3 20 FO BRA I(ENSK3 02490 12F5 SF KENSK4 CLR X 02491 12F6 D6 0115 KENSI(5 LDA REFDAT.X 02492 12F9 Al 20 CMP 1:1$20 02493 12FB 26 13 BNE KENSK6 02494 12FD 5C INC X 02495 12FE A3 14 CPX 1*20 02496 1300 26 F4 BNE KENSK5 02497 1302 A6 10 LDA 1*$10 02498 1304 B7 4C STA BZRCNT 02499 1306 3F 4F CLR BZR 02500 1308 16 4E BSET 3.BZRFLG If aL L data is SP. buzzing 02501 130A CD 1966 JSR LCDMCR 02502 130D CC 1399 JMP KNSRTS 02503 1310 IB 42 I(ENSK6 8CLR 5.FLAG CLear equaL fLag 02504 1312 86 49 I(ENSI<7 LDA DTCNT Store next data address 02505 1314 8B 48 ADD SDP+1 02506 1316 B7 46 STA DTDP+l 02507 1318 B6 47 LDA SDP 02508 131A A9 00 ADC 1:10 02509 131C B7 45 STA DTOP 02510 131E CD 187C KENSI(8 JSR INPDAT 02511 1321 B6 4A LDA DATA 02512 1323 Dl- 0115 CMP REFDAT.X Compare data 02513 1326 27 3F BEQ I(NSKEQ 02514 1328 3C 49 INC DTCNT 02515 132A OA 42 C8 8RSET 5.FLAG.KENSK4 Check equal flag 02516 132D B6 49 LDA DTCNT 02517 132F Al 14 CMP 1:120 02518 1331 26 DF 8NE KENSK7 02519 1333 86 48 KENSI<9 LDA SDP+l Store pointer of next data 02520 1335 A8 10 ADD 1:129 02521 1337 87 46 STA DTDP+1 02522 1339 86 47 LDA SDP 02523 1338 A9 00 ADC 1:10 02524 133D 87 45 STA DTDP 02525 133F 05 42 07 BRCLR 2. FLAG .I(ENSI(A Check search direction fLag 02526 1342 CD 18CF JSR DTSU8 02527 1345 86 45 LDA DTDP 02528 1347 28 3E 8MI KENSKD 02529 1349 86 45 I(ENSKA LDA DTDP Test if pOinter shows Last address 02530 134B Al 16 CMP I*RAMEND/256 ¢!)HITACHI 1124 02531 134D 27 03 BEQ KENSKB 02532 134F CC 12C7 JMP KENSK1 02533 1352 B6 46 KENSKB LDA DTDP+1 02534 1354 Al A8 CMP I:IRAMEND*2561256 02535 1356 25 03 BCS I(ENSKC 02536 1358 CC 12C7 JMP KENSI(l 02537 135B B6 41 KENSKC LDA MODFLG 02538 135D Al 04 CMP 1:1$4 02539 135F 26 2A BNE KENSKE 02540 1361 10 BE BSET O.ERFLG If RAM is fuLL. dispLay "FULL" 02541 1363 14 BE BSET 2.ERFLG 02542 1365 20 32 BRA KNSRTS 02543 1367 5C KNSKEQ INC X 02544 1368 CD 18C4 JSR DTADD 02545 136B lA 42 BSET 5.FLAG 02546 136D D6 0115 LDA REFDAT.X 02547 1370 26 AC BNE KENSK8 0254B 1372 09 42 06 BRCLR 4. FLAG. I(NSEQ 1 02549 1375 A6 2A LDA 1:I$2A 02550 1377 B7 9B STA LCDM+39 02551 1379 20 10 BRA KENSKE 02552 137B 18 42 KNSEQI BSET 4.FLAG 02553 137D B6 47 LDA SDP 02554 137F B7 50 STA DTADS 02555 1381 B6 48 LDA SDP+l 02556 1383 B7 51 STA DTADS+l 02557 1385 20 AC BRA KENSK9 02558 1387 3F 45 KENSKD CLR DTDP CLear data tabLe pointer 02559 1389 3F 46 CLR DTDP+l 02560 138B 09 42 OB KENSKE BRCLR 4.FLAG.KNSRTS Check pL. 'flas 02561 138E B6 50 LDA DTADS DispLay data reviewed 02562 1390 B7 45 STA DTDP 02563 1392 B6 51 LDA DTADS+1 02564 1394 B7 46 STA DTDP+l 02565 1396 CD 1449 JSR DTLCD 02566 1399 81 I(NSRTS RTS 02567 * 02568 ************************************************ 02569 * * 02570 * NAME : ENTER DATA (TOROKU) * 02571 * * 02572 ************************************************ 02573 * * 02574 * ENTRY : DTDP. LCDM * 02575 * RETURNS : NOTHING * 02576 * * 02577 ************************************************ 02578 139A 5F TOROKU CLR X CLear pointer 02579 139B E6 71 TOROKI LDA LCDM.X 02580 139D A1 20 CMP 1:1$20 Data = SP? 02581 139F 26 OC BNE TOROI(3 02582 13Al A3 13 CPX 1:119 SP = 20 disit? 02583 13A3 27 03 BEQ TOROK2 02584 13A5 5C INC X Increment pointer 02585 13A6 20 F3 BRA TOROKI ~HITACHI 1125 02586 13A8 CO 1966 TDROK2 JSR LCDMCR CLear dispLay RAM 02587 13AB 20 5B BRA TRKRTS 02588 BAD 5F TOROK3 CLR X 02589 13AE E6 71 TOROK4 LDA LCDM,X 02590 13BO B7 4A STA DATA Store data in output RAM 02591 13B2 CO 189F JSR OUTDAT Outout data 02592 13B5 5C INC X 02593 13B6 CD 18C4 JSR DTADD 02594 13B9 A3 14 CPX ~20 Test if 20 digits are entered 02595 13BB 26 F1 BNE TOROI(4 02596 13BO 3F CO MOD95 CLR TRNS 02597 13BF A6 14 LDA ~20 InitiaLize pointer for externaL RAM 02598 13C1 B7 BF STA HOLD 02599 13C3 BE BF TRKC1 LOX HOLD 02600 13C5 E6 71 LOA LCDM,X 02601 13C7 Al 20 CMP ~$20 Data = SP? 02602 13C9 26 04 BNE TRKC2 02603 13CB 3C BF INC HOLD If SP, increment pointer 02604 13CO 20 OF BRA TRKC3 02605 13CF Al 23 TRKC2 CMP ~$23 02606 1301 26 02 BNE TRKC5 02607 13D3 A6 2E LDA ~$2E 0260B 1305 BE CO TRKC5 LOX TRNS Load data into saving RAM 02609 1307 D7 0115 STA REFDAT,X 02610 130A 3C BF INC HOLD Increment pointer 02611 130C 3C CO INC TRNS 02612 130E B6 BF TRKC3 LOA HOLD 02613 13EO Al 26 CMP ~38 CompLete entering? 02614 13E2 26 DF BNE TRKC1 02615 13E4 B6 CO TRKC4 LOA TRNS CompLete saving? 02616 13E6 Al 12 CMP ~18 02617 13E8 27 OB BEQ TOROKS 0261B 13EA BE CO LDX TRNS 02619 13EC A6 FF LDA ~$FF 02620 13EE 07 0115 STA REFDAT,X Load $FF into rest area 02621 13F1 3C CO INC TRNS 02622 13F3 20 EF BRA TRKC4 02623 13F5 CD 1907 TOROI<5 JSR MOVE2 Load data 02624 13F8 AE 14 LDX ~20 02625 13FA CD 1823 TOROK6 JSR TELN01 Change 2bytes into 1byte 02626 13FD CD 189F JSR OUTOAT 02627 1400 5C INC X 0262B 1401 CD 18C4 JSR OTADD Output data 02629 1404 A3 26 CPX ~38 02630 1406 26 F2 BNE TOROK6 Test if entering is compLete 02631 1408 B1 TRKRTS RTS 02632 * 02633 ************************************************ 02634 * * 02635 NAME : SEARCH SPEED DIAL NO.(TAN) 02636 * * 02637 ************************************************** 02638 * * 02639 ErJTRY LCDM 02640 '" RETURNS : DIALNO. MEMO. LCDM. CURADP * " * ~HITACHI 1126 02641 * * 02642 ************************************************ 02643 1409 B6 7A TAN LDA LCDM+9 Load speed diaL no. 02644 140B A4 OF AND Ii$OF 02645 140D B7 46 STA DTDP+l 02646 140F BE 46 LDX DTDP+l 02647 1411 A6 17 LDA 1i$17 02648 1413 B7 45 STA DTDP 02649 1415 A6 F7 LDA Ii$F7 02650 1417 B7 46 STA DTDP+l 02651 1419 AS 09 TANI ADD 1i9 Sellrch dllta In externllL RAM 02652 141B B7 46 STA DTDP+l 02653 141D 5A DEC X 02654 141E A3 FF CPX Ii$FF 02655 1420 26 F7 BNE TAN1 02656 1422 AE 14 LOX 1i20 02657 1424 CD 187C TAN2 JSR INPDAT LOlld speed dlllL no. 02658 1427 CD 1838 JSR TELN02 Chenge 1 byte to 2 bytes 02659 142A 5C INC X 02660 142B 5C INC X 02661 142C CD 18C4 JSR DTADD 02662 142F A3 26 CPX 1i38 02663 1431 26 Fl BNE TAN2 02664 1433 CD 1476 JSR MEMCLR CLear memo for redlllLlng 02665 1436 5F CLR X 02666 1437 E6 84 TAN3 LDA LCDM+19.X DlspLey speed dleL no. 02667 1439 E7 99 STA DIALNO.X 02668 1438 07 0100 STA MEMO.X 02669 143E 5C INC X 02670 143F A3 14 CPX 1i20 02671 1441 26 F4 BNE TAN3 02672 1443 3F 4B CLR CURADP 02673 1445 CD 110E JSR LCD 02674 1448 81 RTS 02675 * 02676 ************************************************ 02677 * * 02678 * NAME : DISPLAY DATA FOR ONE PERSON * 02679 * (DTLCD) * 02680 * * 02681 ************************************************ 02682 * * 02683 * ENTRY : DTDP * 02684 * RETURNS : LCDM * 02685 * * 02686 ************************************************ 02687 1449 5F DTLCD CLR X 02688 144A CD 187C DTLCDI JSR INPDAT LOlld nllme from externeL RAM 02689 144D B6 4A LDA DATA 02690 144F E7 71 STA LCDM.X DispLay name 02691 1451 CD 18C4 JSR DTADD 02692 1454 5C INC X 02693 1455 A3 14 CPX 1i20 02694 1457 26 Fl BNE DTLCD1 02695 1459 CD 187C DTLCD2 JSR INPDAT Load diaL no. from externeL RAM ~HITACHI 1127 02696 145C CD 183B JSR TELN02 Change 2 bytes to 1 byte 02697 145F CD 18C4 JSR DTADD 02698 1462 5C INC X 02699 1463 5C INC X 02700 1464 A3 26 CPX 1:138 02701 1466 26 F1 BNE DTLCD2 Test if input data is compLete 02702 1468 CD 110E JSR LCD DispLay name and teLephone no. 02703 146B B1 RTS 02704 * 02705 ************************************************ 02706 * * 02707 NAME : CLEAR DIAL NUMBER (DIACLR) 02708 * * 02709 ************************************************** 02710 02711 * ENTRY : NOTHING * 02712 * RETURNS : DIALNO * 02713 * * 02714 * * ************************************************ 02715 146C AE 15 DIACLR LDX 1:121 02716 146E A6 20 DIACL1 LDA 1:1$20 02717 1470 E7 98 STA DIALNO-l.X CLear diaL no. 02718 1472 5A DEC X 02719 1473 26 F9 BNE DIACll 02720 1475 81 RTS 02721 * 02722 ************************************************ 02723 * * 02724 * NAME : CLEAR MEMO FOR REDIALING * 02725 (MEMCLR) * 02726 * 02727 * * ************************************************ 02728 * * 02729 * ENTRY : NOTHING * 02730 * RETURNS : MEMO * 02731 02732 ************************************************** 02733 1476 AE 15 MEMCLR LOX 1:121 02734 1478 A6 20 MEMCL1 LDA 1:1$20 02735 147A E7 FF STA MEMO-1.X CLear memo for rediaLing 02736 147C 5A DEC X 02737 147D 26 F9 BNE MEMCll 02738 147F 81 RTS 02739 * 02740 ************************************************ 02741 * * 02742 NAME : CLEAR DISPLAY RAM (CLEAR) 02743 * * 02744 ************************************************** 02745 * * 02746 * ENTRY NOTHING * 02747 * RETURNS : LCDM * 02748 * * 02749 ************************************************ 02750 1480 AE 28 CLEAR LDX 1:140 ~HITACHI 1128 02751 1482 4F CLR1 CLR A 02752 1483 E7 70 STA LCDM-1.X CLear dispLay RAM 02753 1485 5A DEC X 02754 1486 26 FA BNE CLRl 02755 1488 81 RTS 02756 02757 ************************************************* 02758 * * 02759 NAME : CLEAR ELAPSED TIME (TELCLR) 02760 * * 02761 * * ************************************************ 02762 ** ** 02763 ENTRY: NOTHING 02764 * RETURNS : TEL * 02765 02766 * ************************************************ * 02767 1489 AE 03 TELCLR LOX "3 02768 1489 6~ 61 TELCLl CLR TEL-1.X CLear eLapsed time counter 02769 1480 5A DEC X 02770 148E 26 F9 9NE TELCL1 02771 1490 81 RTS 02772 02773 * ************************************************ 02774 ** 02775 ** NAME : LOAD CALENDAR & TIME DATA 02776 * INTO DIAPLAY RAM (SHUCAL) * 02777 **********************************************~*** 02778 02779 * * 02780 ENTRY : CALNDR. CURADP 02781 * RETURNS : LCDM * 02782 * * 02783 ************************************************** 02784 1491 17 42 SHUCAL 9CLR 3:FLAG CLear fLag 02785 1493 CD 1258 JSR CALL CD 02786 1496 A6 OF LDA "$F 02787 1498 97 49 STA CURADP Define cursor position 02788 149A A6 OE LOA "14 02789 149C 97 40 STA LCDMP 02790 149E 81 RTS 02791 02792 * ************************************************ 02793 02794 * NAME : CHECK CALNDAR & TIME (CALSHU) ** 02795 * 02796 ************************************************** 02797 * * 02798 ENTRY : LCDM * 02799 * RETURNS : CALNDR. TELFLG. ERFLG 02800 * * 02801 * ************************************************ * 02802 149F A6 02 CAL SHU LOA "2 02803 14A1 97 60 STA CNT Set digit counter 02804 14A3 3F 6F CLR SHUCNT CLear pointer 02805 14A5 3F 6E CLR CALCNT ~HITACHI 1129 02806 14A7 8E 6E LOX CALC NT 02807 14A9 4F CALSH1 CLR A CLear ACCA 02808 14AA 98 CLC CLear bit C 02809 14AB E6 7E LOA LCOM+13.X 02810 14AO A1 30 CMP 11'0 Key data = 0-97 02811 14AF 25 60 BCS CALS10 02812 14B1 AB C6 ADD II$C6 02813 14B3 25 69 BCS CALS10 02814 14B5 AB OA ADD II$OA Convert ASCII into BCD 02815 14B7 BE 60 LOX CNT Load digit counter 02816 14B9 27 22 BEQ CALSH2 Check digit 02817 14BB 48 LSL A Shift 4 bits Left 02818 14BC 48 LSL A 02819 14BO 4B LSL A 02820 14BE 48 LSL A 02821 14BF BE 6F LOX SHUCNT 02822 14C1 E7 65 STA SHUSTA.X Store modified data 02823 14C3 3A 60 CALSH3 DEC CNT Decrement digit pointer 02824 14C5 3C 6E CALSH4 INC CALCNT LCOM+13 increment 02825 14C7 BE 6E LOX CALCNT 02826 14C9 A3 OF CPX II$F CALCNT=157 02827 14CB 26 DC BNE CALSH1 02828 14CD AE 05 l-DX 115 02829 14CF E6 64 CALSH5 LOA SHUSTA-l.X Load SHUSE DATA 02830 1401 A3 03 CPX 113 MONTH and DAY 7 02831 1403 24 02 BCC CALSH7 02832 1405 27 3E BEQ CALSH8 Error 02833 1407 E7 5C CALSH7 STA CALNOR-1.X store CALNOR 02834 1409 5A DEC X 02835 140A 26 F3 BNE CALSH5 IX=O 7 02836 140C 81 CALSH9 RTS 02837 1400 BE 6F CAL5H2 LOX SHUCNT 02838 140FEB 65 ADD SHUSTA.X 1st digit? 02839 14E1 A3 01 CPX III 02840 14E3 27 OF BEQ DAY 02B41 14E5 01 1A13 CMP SHUSE.X 02842 14E8 24 2B CALSH6 BCC CALSH8 Error 02843 14EA E7 65 STA SHUSTA.X SHUSEdata->SHUSESTA 02844 14EC A6 02 LOA 112 02845 14EE B7 60 STA CNT 2->CNT 02846 14FO 3C 6F INC SHUCNT Increment SHUCNT 02847 14F2 20 01 BRA CALSH4 02848 14F4 B7 BF DAY STA HOLD 02849 14F6 B6 65 LOA SHUSTA 02850 14F8 44 LSR A 02851 14F9 44 LSR A 02852 14FA 44 LSR A 02853 14FB 44 LSR A 02854 14FC 48 LSL A 02855 14FO B7 CO STA TRNS 02856 14FF 48 LSL A 02857 1500 48 LSL A 02858 1501 BB CO ADD TRNS 02859 1503 87 CO STA TRNS 02860 1505 B6 65 LOA SHUSTA ~HITACHI 1130 02861 1507 A4 OF AND I:I$OF 02862 1509 BB CO ADD TRNS 02863 150B 97 TAX 02864 150C B6 BF LOA HOLD 02865 150E D1 1AOO CMP MONTH-1.X MONTH deta tabLe 02866 1511 AE 01 LOX 1:11 l->IX 02867 1513 20 D3 BRA CALSH6 02868 1515 4F CALSH8 CLR A Prepare for error process 02869 1516 B7 4F STA BZR 02870 1518 B7 43 STA TRMFLG 02871 151A 10 BE BSET O.ERFLG 02872 151C 20 BE BRA CALSH9 02873 151E B6 60 CALS10 LDA CNT 02874 1520 Al 02 CMP 1:12 02875 1522 26 F1 BNE CALSH8 02876 1524 20 9D BRA CALSH3 02877 * 02878 ************************************************ 02879 * * 02880 * NAME : DISPLAY RETRYING NUMBER * 02881 * (DIAL2) * 02882 * * 02883 ************************************************ 02884 * * 02885 * ENTRY : DIAN02. MEMO * 02886 * RETURNS : LCDM * 02887 * * 02888 ************************************************ 02889 1526 AE OE DIAL2 LDX 1:114 02890 1528 D6 1A55 DIAL21 LDA DIAN02-1.X DispLay "RETRY" 02891 152B E7 71 STA LCDM.X 02892 152D 5A DEC X 02893 152E 26 F8 BNE DIAL21 02894 1530 5F CLR X 02895 1531 D6 0100 DIAL22 LDA MEMO.X Load retry no. 02896 1534 E7 85 STA LCDM+20, X 02897 1536 E7 99 STA DIALNO.X 02898 1538 5C INC X 02899 1539 A3 14 CPX 1:120 02900 153B 26 F4 BNE DIAL22 02901 153D CD 1l0E JSR LCD DispLay retry no. 02902 1540 81 RTS 02903 * 02904 ************************************************ 02905 * * 02906 * NAME : INITIALIZE INTERNAL RAM * 02907 * (ARGINT) * 02908 * * 02909 ************************************************ 02910 * * 02911 * ENTRY : NOTHING * 02912 * RETURNS : NOTHING * 02913 * * 02914 ************************************************ 02915 1541 9B ARGINT SEI ~HITACHI 1131 I 02916 1542 CD 1172 JSR LCDRES 02917 1545 CD 1195 JSR LCDlNT Initialize LCD 029:e. 1548 9A CLI 029~9 1549 CD 1489 JSR TELCLR Clear TEL counter 02920 154C CD 146C JSR DlACLR 02921 154F CD 1476 JSR MEMCLR 02922 1552 4F CLR A 02923 1553 87 6C STA POINTR Clear RAM 02924 1555 87 6E STA CALCNT 02925 1557 B7 6D STA CNT 02926 1559 B7 48 STA CURADP 02927 1558 87 6F STA SHUCNT 02928 155D C7 0137 STA SHU SEC 02929 1560 87 68 STA CNTBIT 02930 1562 87 44 STA TELFLG 02931 1564 87 86 STA TELWAT 02932 1566 C7 0139 STA TELNO 02933 1569 C7 013A STA TELCNT 02934 156C 87 84 STA REC 02935 156E 87 85 STA MFDAT 02936 1570 87 42 STA FLAG 02937 1572 87 AE STA WAIT1 02938 1574 87 AF STA WAIT2 02939 1576 87 80 STA WAIT3 02940 1578 87 81 STA WAIT4 02941 157A B7 82 STA WAIT5 02942 157C B7 83 STA MEMOP 02943 lS7E B7 4E STA 8ZRFLG 02944 1580 87 4F STA 8ZR 02945 1582 87 8C STA DlAPl 02946 1584 87 8D STA DIAP2 02947 1586 C7 0138 STA ERRl 02948 1589 C7 013C STA ERR2 02949 158C 87 8E STA ERFLG 02950 158E AE 04 LDX 1:14 02951 1590 4F ARG16 CLR A 02952 1591 07 0128 STA ADDRAT-1.X Cleer ADDRAT 02953 1594 5A DEC X 02954 1595 26 F9 8NE ARG16 02955 1597 AE 02 LDX 1:12 02956 1599 4F ARG17 CLR A 02957 159A E7 51 STA SEC-l.X Cleer SEC 02958 159C 5A DEC X 02959 159D 26 FA 8NE ARG17 02960 159F AE 02 LDX 1:12 02961 15Al 4F ARG18 CLR A 02962 15A2 07, 0134 STA SECCNT-1.X Cleer SECCNT 02963 15A5 SA DEC X 02964 15A6 26 F9 8NE ARG18 02965 15A8 CD 17A7 JSR TOLCLR Cleer TOTAL 02966 1SA8 CD 1781 JSR SNGCLR Clear SINGL 02967 15AE AE 05 LDX 1:15 02968 15BO 6F SC ARG19 CLR CALNDR-1.X 02969 15B2 SA DEC X 02970 15B3 26 F8 BNE ARG19 ~HITACHI 1132 02971 15B5 AE 04 LDX tl4 02972 15B7 A6 01 ARG100 LDA III 02973 15B9 E7 5C STA CALNDR-1.X 02974 15BB SA DEC X 02975 15BC 26 F9 BNE ARG100 02976 15BE AE OS LDX tiS 02977 15CO A6 20 ARG110 LDA tI$20 02978 15C2 E7 B6 STA DIADAT-1.X 02979 15C4 SA DEC X 02980 15C5 26 F9 BNE ARGllO 02981 15C7 CD 1001 JSR CANCEL In1t1aL1ze for teLephone circu1t 02982 15CA CD 1038 JSR CALRST 02983 15CD 81 RTS 02984 * 02985 ************************************************ 02986 * * 02987 * NAME : COUNT CHARGE (MONEY) * 02988 * * 02989 ************************************************ 02990 * * 02991 * ENTRY : ADDRAT. SEC * 02992 * RETURNS : SINGL. TOTAL * 02993 * * 02994 ************************************************ 02995 15CE AE 02 MONEY LDX tl2 2-)IX 02996 15DO 99 SEC l-)C 02997 15D1 4F MONEY 1 CLR A 02998 15D2 D9 0134 ADC SECCNT-1.X 1 sec UP 02999 15D5 8D DAA 03000 15D6 D7 0134 STA SECCNT-1.X 03001 15D9 SA DEC X 03002 15DA 26 F.5 BNE MONEYl IX=O? 03003 15DC B6 53 LDA SEC+1 SEC=SECCNT? 03004 15DE C1 0136 CMP SECCNT+1 03005 15E1 26 2E BNE MONEY4 03006 15E3 B6 52 LDA SEC 03007 15E5 C1 0135 CMP SECCNT 03008 15E8 26 27 BNE MONEY4 03009 15EA 4F CLR A 03010 15EB C7 0136 STA SECCNT+1 CLeer SECCNT 03011 15EE C7 0135 STA SECCNT 03012 15F1 AE 04 LDX tl4 03013 15F3 98 CLC CLeer b1t C 03014 15F4 D6 0128 MONEY2 LDA ADDRAT-I. X Rete+eccumuLeted charge 03015 15F7 09 0130 AOC TOTAL-I. X 03016 15FA 8D DAA 03017 15FB 07 0130 STA TOTAL-I. X 03018 15FE SA DEC X 03019 15FF 26 F3 BNE MONEY2 IX=O? 03020 1601 AE 04 LDX 114 03021 1603 98 CLC O-)C 03022 1604 D6 0128 MONEY3 LDA ADDRAT-1.X 03023 1607 D9 012C ADC SINGl-1.X rate+SINGL CHARGE 03024 160A 8D DAA 03025 160B D7 012C STA SINGL-1.X ~HITACHI 1133 II 03026 l60E SA DEC X 03027 160F 26 F3 BNE MONEY3 03028 1611 81 MONEY4 RTS 03029 * 03030 ************************************************ 03031 * * 03032 NAME : CHANGE TO ASCII (MNYASC) 03033 * * 03034 ************************************************** 03035 03036 * ENTRY : TOTAL, SINGL, ADDRAT, SEC * 03037 * RETURNS : LCDM * 03038 * * 03039 * ************************************************ * 03040 1612 BE 6D MNYASC LDX CNT 03041 1614 04 6B 37 MNYAS1 BRSET 2,CNTBIT.MNYAS6 TOTAL-)AccA 03042 1617 06 6B 39 BRSET 3,CNTBIT,MNYAS7 SINGL-)ACCA 03043 161A 08 6B 3B BRSET 4,CNTBIT,MNYAS8 ADDRAT-)ACCA 03044 161D OA 6B 3D BRSET 5.CNTBIT,MNYAS9 SEC-)ACCA 03045 1620 A4 OF MNYAS2 AND I*$OF 03046 1622 AB 30 ADD 1*'0 03047 1624 BE 6E LDX CALCNT 03048 1626 E7 71 STA LCDM.X 03049 1628 3A 6E DEC CALCNT 03050 162A BE 6D LDX CNT 03051 162C 04 6B 32 BRSET 2,CNTBIT,MNYAI3 03052 162F 06 6B 34 BRSET 3,CNTBIT,MNYA14 03053 1632 08 6B 36 BRSET 4, CNTBIT, MNYA15 03054 1635 OA 6B 38 BRSET 5,CNTBIT,MNYA16 03055 1638 44 MNYAS4 LSR A 03056 1639 44 LSR A 03057 163A 44 LSR A 03058 163B 44 LSR A 03059 163C AB 30 ADD 1*'0 03060 163E BE 6E LDX CALC NT 03061 1640 OA 6B 35 BRSET 5,CNTBIT,MNYA17 03062 1643 E7 71 MNYA10 STA LCDM,X 03063 1645 3A 6E MNYAS5 DEC CALCNT 03064 1647 3A 6D DEC CNT 03065 1649 BE 6D LDX CNT 03066 164B 26 C7 BNE MNYAS1 03067 164D 81 RTS 03068 164E D6 0130 MNYAS6 LDA TOTAL-LX 03069 1651 20 CD BRA MNYAS2 03070 1653 D6 012C MNYAS7 LDA SINGL-LX 03071 1656 20 C8 BRA MNYAS2 03072 1658 D6 0128 MNYAS8 LDA ADDRAT-I. X 03073 165B 20 C3 BRA MNYAS2 03074 165D E6 51 MNYAS9 LDA SEC-I. X 03075 165F 20 BF BRA MNYAS2 03076 1661 D6 0130 MNYA13 LDA TOTAL-I. X 03077 1664 20 D2 BRA MNYAS4 03078 1666 06 012C MNYA14 LDA SmGL-l.X 03079 166 9 20 CD BRA MNW:S4 03080 1662 D6 0128 Mr~YA15 LDA ADe'RAT -1 . :< ¢!)HITACHI 1134 03081 166E 20 C8 BRA Mf\YAS4 03082 1670 A3 01 MNYA16 CPX til 03(183 1672 27 C4 BEQ MNYAS4 03084 1674 E6 51 LDA SEC-1.X 03095 1676 20 CO BRA MNYAS4 03086 1678 A3 1B MNYA17 CPX il27 03087 167A 27 C9 BEQ MNYAS5 03088 167C 20 C5 BRA MNYP10 03089 * 03090 ************************************************ 03091 * * 03092 * NAME : LOAD CHARGE DATA INTO * 03093 * DISPLAY RAM (SNGSTA) * 03094 * * 03095 ************************************************ 03096 * * 03097 * ENTRY : NOTHING * 03098 * RETURNS : LCDM * 03099 * * 03100 ************************************************ 03101 167E CD 1966 SNGSTA JSR LCDMCR 03102 1681 A6 02 LDA il2 03103 1683 87 6D STA CNT 03104 1685 A6 16 LDA 1:122 03105 1687 B7 6E STA CALCNT 03106 1689 1A 68 BSET 5, CNTBIT 03107 1688 CD 1612 JSR t~NYASC 031(18 168E 1B 6B 8CLR 5, CNTBIT 03109 1690 AE OD LDX il13 03110 1692 D6 lA28 SNGS1 LDA RATDAT-l,X 03111 1695 E7 72 STA LCDM+1,X 03112 1697 5A DEC X 03113 1698 26 F8 8NE SNGS1 03114 169A AE 04 LDX il4 03115 169C 06 lA38 SNGS2 LDA SECDAT-l,X 03116 169F E7 80 STA LCDM+15,X 03117 16A1 5A DEC X 03118 16A2 26 Fa 8NE SNGS2 03119 16A4 AE OF LDX 1:115 03120 16A6 06 :A1C SNGS3 LDA CRGDAT-1,X 03121 16A9 E7 88 STA LCDM+23,X 03122 16A8 SA DEC X 03123 16AC 26 F8 8NE SNGS3 03124 16AE A6 04 LDA 1:14 4-)CNT 03125 1680 87 6D STA CNT 03126 1682 A6 OE LDA il14 13-)CALCNT 03127 1684 87 6E STA CALCNT 03128 1686 18 68 8SET 4, CNT8IT RATE SET 03129 1688 CD 1612 JSR MNYASC date-)ASCII 03130 1688 19 68 8CLR 4. CNTBIT 03131 16BD A6 :::4 LDA 1:14 03132 168F 87 (lD STA c~n 03133 16C1 A6 '26 LDA 1::38 03134 16C3 ~~? (',i" STA CALeNT ,. 03135 16Cc, L .r," 2. ':,ET 3.CNTE:- -:riAP,::J:- ~HITACHI 1135 03136 16C7 CD l612 ~~~ MNYASC data-)ASCII 03137 16CA 17 6B BCLR 3.Cl\,T81T 03138 16CC 81 RTS 03139 03140 * ************************************************ 03141 * ** 03142 NAME : LOAD ACCUMULATED CHARGE 03143 * INTO DISPLAY RAM (TOLSTA) * 03144 * 03145 * * ************************************************ 03146 03147 * ENTRY : TOTAL * 03148 * RETURNS : LCDM * 03149 * * 03150 * * ************************************************ 03151 16CD CD 1966 TOLSTA JSR LCDMCR 03152 16DO AE OF LOX In5 03153 16D2 D6 lAIC TOLSTl LDA CRGOAT-l. X 03154 16D5 E7 7D STA LCOM+12.X 03155 1607 5A DEC X 03156 1608 26 F8 BNE TOLSTl 03157 160A A6 04 LDA 114 03158 160C B7 6D STA CNT 03159 16DE A6 IB LDA 1127 03160 16EO B7 6E STA CALCNT 03161 16E2 14 6B BSET 2.CNTBIT Set charge 03162 16E4 CD 1612 JSR MNYASC 03163 16E7 15 6B BCLR 2.CNTBIT 03164 16E9 81 RTS 03165 03166 ************************************************* 03167 03168 * NAME : SET CHARGE PER UNIT TIME * 03169 * (CRGSET) * 03170 * * 03171 * ************************************************* 03172 03173 * ENTRY : AOORAT. SEC * 03174 * RETURNS : LCDM * 03175 * * 03176 ************************************************** 03177 16EA CO 1966 CRGSET JSR LCOMCR 03178 16EO A6 AO LOA II$AO 03179 16EF B7 88 STA LCDM+23 03180 16F1 A6 04 LDA 114 03181 16F3 B7 60 STA CNT 03182 16F5 A6 16 LOA 1122 03183 16F7 B7 6E STA CALCNT 03184 16F9 18 6B BSET 4.CNTBIT Set rate 03185 16FB CD 1612 JSR MNYASC Oata-)ASCII 03186 16FE 19 6B BCLR 4.CNTBIT 03187 1700 A6 02 LDA 112 03188 1702 B7 6D STA CNT 03189 1704 A6 IE LOA 1130 03190 1706 B7 6E STA CALCNT ~HITACHI 1136 03191 1708 1A 6B BSET 5.CNTBIT Set rate 03192 170A CD 1612 JSR MNYASC Data-)ASCII 03193 170D 1B 6B BCLR 5.CNTBIT 03194 170F AE 05 LDX 115 03195 1711 D6 lA2B CRGSTl LDA RATDAT-I. X 03196 1714 E7 7A STA LCDM+9.X 03197 1716 5A DEC X 0319B 1717 26 FB BNE CRGSTl 03199 1719 AE 04 LDX 1:14 03200 171B D6 lA38 CRGST2 LDA SECDAT-l.X 03201 171E E7 88 STA LCDM+23.X 03202 1720 5A DEC X 03203 1721 26 F8 BNE CRGST2 03204 1723 A6 10 LDA 1116 03205 1725 B7 48 STA CURADP 03206 1727 A6 OF LDA 1115 03207 1729 B7 40 STA LCDMP 03208 172B 81 RTS 03209 * 03210 ************************************************ 03211 * * 03212 * NAME : STORE RATE COUNTER (RATSET) * 03213 * * 03214 ************************************************ 03215 * * 03216 * ENTRY : LCDM * 03217 * RETURNS: ADDRAT. SEC. TRMFLG. ERFLG * 03218 * * 03219 ************************************************ 03220 172C 3F 6F RAT SET CLR SHUCNT 03221 172E 3F 6D CLR CNT CLear counter 03222 1730 4F CLR A 03223 1731 8E 6F LDX SHUCNT 03224 1733 E6 80 RATSEI LDA LCDM+15.X Store ASCII 03225 1735 Al 30 CMP 11'0 ASCIDO ? 03226 1737 25 65 8CS RATSE5 03227 1739 A8 C6 ADD II$C6 ASCII(9 ? 03228 173B 25 61 BCS RATSE5 03229 173D A8 OA ADD II$OA 0-ASCII-9 03230 173F 48 LSL A 03231 1740 48 LSL A Second digit 03232 1741 48 LSL A 03233 1742 48 LSL A 03234 1743 8E 60 LDX CNT 03235 1745 E7 65 STA SHUSTA.X Store SHUSTA 03236 1747 3C 6F INC SHUCNT 03237 1749 BE 6F LDX SHUCNT 03238 174B E6 80 LOA LCDM+15.X Store ASCII 03239 174D Al 30 CMP 11'0 ASCII>O ? 03240 174F 25 4D BCS RATSE5 03241 1751 A8 C6 ADD I:I$C6 ASCII(9 ? 03242 1753 25 49 BCS RATSE5 03243 1755 AB OA ADD I:I$OA 03244 1757 BE 60 LDX CNT 03245 1759 EB 65 ADD SHUSTA.X ~HITACHI 1137 I 03246 1758 E7 65 STA ~L1t I~TI\ ,., ...JII ..... ..)I M,A 03247 175D 3C 6F INC SHUCNT 03248 175F 3C 60 INC CNT 03249 1761 BE 6F LOX SHUCNT 03250 1763 A3 08 CPX 1/8 Rate end ? 03251 1765 26 CC BNE RATSEI 03252 1767 B6 BO LOA LCOM+28 SEC ASCII-)deta 03253 1769 AO 30 SUB 1/'0 Thjrd digit 03254 176B 25 31 BCS RATSE5 03255 1760 C7 0137 STA SHUSEC 03256 1770 B6 8E LOA LCOM+29 03257 1772 AO 30 SUB 1/'0 03258 1774 25 28 BCS RATSE5 03259 1776 48 LSL A Second digit 03260 1777 48 LSL A 03261 1778 48 LSL A 03262 1779 48 LSL A 03263 177A C7 0138 STA SHUSEC+1 03264 1770 B6 8F LOA LCOM+30 03265 177F AO 30 SUB 1/'0 First djgit 03266 1781 25 1B BCS RATSE5 03267 1783 CB 0138 ADO SHUSEC+1 03268 1786 C7 0138 STA SHUSEC+l 03269 1789 AE 04 LOX 1/4 03270 178B E6 64 RATSE2 LOA SHUSTA-l,X 03271 17BD 07 0128 STA AOORAT-l, X Store ADDRAT 03272 1790 5A DEC X 03273 1791 26 F8 BNE RATSE2 03274 1793 AE 02 LDX 1/2 03275 1795 D6 0136 RATSE3 LDA SHUSEC-1.X 03276 1798 E7 51 STA SEC-1.X Store SEC 03277 179A 5A DEC X 03278 179B 26 F8 BNE RATSE3 03279 1790 81 RATSE4 RTS 03280 179E 4F RATSE5 CLR A 03281 179F B7 4F STA BZR CLear BZR 03282 17Al B7 43 STA TRMFLG CLear TRMFLG 03283 17A3 10 BE BSET O.ERFLG Set error process request flag 03284 17A5 20 F6 BRA RATSE4 03285 03286 '"'''''''''''''''''''**'''**'''''''''***''''''*'''***'''''''''********'''*******'''''''''* " 032B7 03288 '" NAME : CLEAR ACCUMULATED CHARGE * 03289 '" (TDLCLR) * 03290 ''"" '*" 03291 *"'*"''''*''''''''''''''''''''''''****''''''*****''''''****''''''***'''*'''*'''*****'''* 03292 '" * 03293 '" ENTRY : NOTHING * 03294 '" RETURNS : TOTAL * 03295 * '" 03296 ***"'**"'*"'*"'*"'**"'**"'**"''''*'''*****'''''''''***''''''****''''''**** 03297 17A7 AE 04 TOLCLR LOX l:I4 03298 17A9 4F ToLCLl CLR A 03299 17AA 07 0130 STA TOTAL-1.X CLear accumuLated charge 03300 17AO 5A DEC X OHITACHI 1138 03301 17AE 26 F9 BNE TOLCll 03302 17BO 81 RTS 03303 * 03304 ************************************************ 03305 * * 03306 * NAME : CLEAR CHARGE (SNGCLR) * 03307 * * 03308 ************************************************ 03309 * * 03310 * ENTRY : NOTHING * 03311 * RETURNS : SINGL * 03312 * * 03313 ************************************************ 03314 17B1 AE 04 SNGCLR LOX 114 03315 17B3 4F SNGCll CLR A 03316 17B4 07 012C STA SINGL-1.X CLear charge 03317 17B7 5A DEC X 03318 17B8 26 F9 BNE SNGCll 03319 17BA 81 RTS 03320 * 03321 ************************************************ 03322 * * 03323 * NAME : MOVE CURSOR FOR SETTING CHARGE* 03324 * (CURRAn * 03325 * * 03326 ******************************~***************** 03327 * * 03328 * ENTRY : LCOMP * 03329 * RETURNS : LCOMP. CURAOP * 03330 * * 03331 ************************************************ 03332 17BB B6 40 CURRAT LOA LCOMP Load LCOM poInter 03333 17BO A1 OE CMP 1114 LCOMP=14 ? 03334 17BF 27 11 BEQ CURRAI 03335 17C1 A1· 17 CMP 1123 LCOMP=23 ? 03336 17C3 27 13 BEQ CURRA2 03337 17C5 A1 1B CMP 1127 LCOMP=27 ? 03338 17C7 27 19 BEQ CURRA3 03339 17C9 A1 IF CMP 1131 LCOMP=31 ? 03340 17C8 26 04 BNE CURRA4 03341 17CO 3A 40 DEC LCOMP 30-)LCOMP 03342 17CF 3A 4B DEC CURAOP 31-)CURAOP 03343 1701 81 CURRA4 RTS 03344 1702 3C 40 CURRAI INC LCOMP 15-)LCOMP 03345 1704 3C 4B INC CURAOP 16-)CURAOP 03346 1706 20 F9 BRA CURRA4 03347 1708 A6 lC CURRA2 LOA 1128 28-)LCOMP 03348 170A B7 40 STA LCOMP 03349 170C A6 10 LOA 1129 29-)CURAOP 03350 170E B7 4B STA CURAOP 03351 17EO 20 EF BRA CURRA4 03352 17E2 A6 16 CURRA3 LOA 1122 22-)LCOMP 03353 17E4 B7 40 STA LCOMP 03354 17E6 A6 17 LOA 1123 23-)CURAOP 03355 17E8 B7 4B STA CURAOP ~HITACHI 1139 I n""''":?r-/ .. ...,,-A .1 (CH 20 E5 V...)...);;JO BRA CURRA4 03357 * 03358 ************************************************ 03359 * * 03360 * NANE : MOVE CURSOR FOR SETTING * 03361 * CALENDAR & CHARGE (CURCAL) * 03362 * * 03363 ************************************************ 03364 * * 03365 * ENTRY : LCDMP. KEYDAT * 03366 * RETURNS : LCDMP. CURADP * 03367 * * 03368 ************************************************ 03369 17EC B6 40 CURCAL LDA LCDMP Load LCDM pointer 03370 17EE Al OD CMP In3 LCDMP=13 ? 03371 17FO 27 19 BEQ CURCll 03372 17F2 Al 10 CMP 1116 LCDMP=16 ? 03373 17F4 27 1B BEQ CURCL2 03374 17F6 Al 13 CMP 1119 LCDMP=19 ? 03375 17F8 27 17 BEQ CURCL2 03376 17FA Al 16 CMP 1122 LCDMP=22 ? 03377 17FC 27 13 BEQ CURCL2 03378 17FE Al 19 CMP 1125 LCDMP=25 ? 03379 1800 27 OF BEQ CURCL2 03380 1802 Al 1C CMP 1128 LCDMP=28 ? 03381 1804 26 04 BNE CURCL5 03382 1806 3A 4B DEC CURADP 28-)CURADP 03383 1808 3A 40 DEC LCDMP 27-)LCDMP 03384 180A 81 CURCL5 RTS 03385 180B 3C 40 CURCll INC LCDMP 14-)LCDMP 03386 180D 3C 4B INC CURADP 15-)CURADP 03387 180F 20 F9 BRA CURCL5 03388 1811 B6 58 CURCL2 LDA KEYDAT RIGHT key or LEFT key ? 03389 1813 Al 29 CMP 11$29 03390 1815 27 06 BEQ CURCL3 03391 1817 3C 40 INC LCDMP LCDMP+1 03392 1819 3C 4B INC CURADP CURADP+1 03393 181B 20 ED BRA CURCL5 03394 181D 3A 40 CURCL3 DEC LCDMP LCDMP-1 03395 181F 3A 4B DEC CURADP CURADP-1 03396 1821 20 E7 BRA CURCL5 03397 * 03398 ***************************'********************* 03399 * * 03400 * NAME : CONVERT 2 BYTES INTO 1 BYTE * 03401 * -LG 03633 1920 27 11 6EQ LFCR3 036:,4 1922 3A 40 LFCR4 DEC L:::DMF' Move cursor to Left 03635 1924 3A 4B DEC CURADP 03636 1926 A6 01 LDA il$1 03637 1928 61 4B CMP CURADP 03638 192A 23 04 6LS LFCR1 03639 192C B7 4B STA CURADP 03640 192E 3F 40 CLR LCDMP 03641 1930 CD 1l0E LFCR1 JSR LCD DispLay cursor 03642 1933 81 LFCR3 RTS 03643 * 03644 ************************************************ 03645 * * 03646 * NAME : MOVE CURSOR TO RIGHT (RTCRSR) * 03647 * * 03648 ************************************************ 03649 * * 03650 * ENTRY : LCDMP. CURADP. MODFLG. TRMFLG * 03651 * RETURNS : LCDMP. CURADP * 03652 * * 03653 ************************************************ 03654 1934 66 41 RTCRSR LDA MODFLG 03655 1936 A1 08 CMP 11$8 03656 1938 27 07 BEQ RTCR3 03657 193A A1 09 CMP 11$9 03658 193C 27 03 BEQ RTCR3 03659 193E CC 1945 JMP RTCR5 03660 1941 B6 43 RTCR3 LDA TRMFLG 03661 1943 27 20 6EQ RTCR4 03662 1945 66 46 RTCR5 LDA CURADP 03663 1947 A1 14 CMP 1120 03664 1949 23 08 6LS RTCRI 03665 1946 6E 46 LDX CURADP 03666 194D E6 71 LDA LCDM.X 03667 194F Al 20 CMP 11$20 03668 1951 27 OF BEQ RTCR2 03669 1953 3C 40 RTCR1 INC LCDMP Move cursor to right 03670 1955 3C 4B INC CURADP 03671 1957 A6 26 LDA 1138 03672 1959 B1 4B CMP CURADP 03673 1956 24 05 BCC RTCR2 03674 195D B7 46 STA CURADP 03675 195F 4A DEC A 03676 1960 67 40 STA LCDMP 03677 1962 CD 1l0E RTCR2 JSR LCD DispLIlY cursor 03678 1965 81 RTCR4 RTS 03679 * 03680 ************************************************ 03681 * * 03682 * NAME : CLEAR DIAPLAY RAM (LCDMCR) * 03683 * * 03684 ************************************************ 03685 * * ~HITACHI 1145 03686 * ENTRY : NOTHING * 03687 * RETURNS : LCDM * 03688 * * 03689 ************************************************ 03690 1966 AE 28 LCDMCR LDX ~40 CLear diapLay RAM 03691 1968 A6 20 MCR1 LDA ~$20 03692 196A E7 70 STA LCDM-1, X 03693 196C 5A DEC X 03694 196D 26 F9 BNE MCR1 03695 196F 81 RTS 03696 * 03697 ************************************************ 03698 * * 03699 * NAME : CLEAR EXTERNAL RAM (RAMCLR) * 03700 * * 03701 ************************************************ 03702 * * 03703 * ENTRY : NOTHING * 03704 * RETURNS : NOTHING * 03705 * * 03706 ************************************************ 03707 1970 3F 4A RAMCLR CLR DATA 03708 1972 3F 45 CLR DTDP 03709 1974 3F 46 CLR DTDP+1 03710 1976 CD 189F RAMCLl JSR OUTDAT CLear externaL RAM 03711 1979 CD 18C4 JSR DTADD 03712 197C A6 16 LDA ~RAMENDI256 03713 197E B1 45 CMP DTDP 03714 1980 26 F4 BNE RAMeL1 03715 1982 A6 A8 LDA ~RAMEND*256/256 03716 1984 81 46 CMP DTDP+1 03717 1986 26 EE BNE RAMCL1 03718 1988 A6 17 LDA ~$17 03719 198A B7 45 STA DTDP 03720 198C 5F CLR X 03721 198D BF 46 STX DTDP+1 03722 198F A6 FF RAMCL2 LDA ~$FF 03723 1991 B7 4A STA DATA 03724 1993 CD 189F JSR OUTDAT 03725 1996 B6 46 LDA DTDP+1 03726 1998 A9 01 ADD ~$1 03727 199A B7 46 STA DTDP+l 03728 199C BE 46 LDX DTDP+l 03729 199E A3 64 CPX ~$64 03730 19AO 26 ED 9NE RAMCL2 03731 19A2 A6 IF LDA ~$lF Store RAM check data 03732 19A4 B7 45 STA DTDP 03733 19A6 3F 46 CLR DTDP+1 03734 19A8 A6 4C LOA ~$4C 03735 19AA B7 4A STA DATA 03736 19AC CD 189F JSR OUTDAT 03737 19AF 3C 46 INC DTDP+l 03738 1991 A6 4F LDA ~$4F 03739 19B3 B7 4A STA DATA 03740 1995 CD 189F JSR OUTDAT ~HITACHI 1146 03741 19B8 3C 46 INC OTDP+1 03742 19BA A6 56 LOA 11$56 03743 19BC B7 4A STA OAT A 03744 19BE CD 189F JSR OUTDAT 03745 19C1 3C 46 INC OTDP+1 03746 19C3 A6 45 LOA 11$45 03747 19C5 B7 4A STA OATA 03748 19C7 CD 189F JSR OUTDAT 03749 19CA 81 RTS 03750 * 03751 ************************************************ 03752 * * 03753 * NAME : MOVE TO REVIEW DATA AREA * 03754 * ( MOVED * 03755 * * 03756 ************************************************ 03757 * * 03758 * ENTER LCOM * 03759 * RETURNS REFOAT * 03760 * * 03761 ************************************************ 03762 19CB 5F MOVEl CLR X 03763 19CC E6 71 MOV11 LOA LCDM.X 03764 19CE D7 0115 STA REFOAT.X Store review data 03765 1901 5C INC X 03766 1902 A3 14 CPX 1120 03767 1904 26 F6 BNE MOV11 03768 1906 81 RTS 03769 * 03770 ************************************************ 03771 * * 03772 * NAME : MOVE REVIEW OATA TO DISPLAY * 03773 * RAM (MOVE2) * 03774 * * 03775 ************************************************ 03776 * * 03777 * ENTER REF OAT * 03778 * RETURNS LCDM * 03779 * * 03780 ************************************************ 03781 1907 SF MOVE2 CLR X 03782 1908 D6 0115 MOV21 LDA REFDAT.X 03783 190B E7 85 STA LCOM+20.X Store dispLay data 03784 19DD 5C INC X 03785 19DE A3 12 CPX 1118 03786 19EO 26 F6 BNE MOV21 03787 19E2 81 RTS 03788 * 03789 ************************************************ 03790 * * 03791 * DATA TABLE * 03792 * * 03793 ************************************************ 03794 19E3 2A CALDAT FCC "* ! 03795 19F2 2A TELDAT FCC "* TIME ~HITACHI 1147 03796 1A01 32 MONTH FCB $32.$29.$32.$31.$32.$31 03797 1A07 32 FCB $32.$32.$31.$32.$31.$32 03798 1AOD OC YOKO FCB $OC.$80.$06.$01.$08.$34 03799 1A13 13 SHUSE FCB $13.$00.$24.$60.$60 03800 1A18 01 SHUNEW FCB $01.$01.$00.$00.$00 03801 1AlD 43 CRGDAT FCC "CHARGE: " 03802 1A2C 52 RATDAT FCC "RATE: 03803 1A39 53 SECDAT FCC "SEC: 03804 1A40 4E N01 FCC liND.?" 03805 1A44 20 N02 FCC NO. " 03806 1A4C 20 DIAN01 FCC " REDIAL 03807 1A56 20 DIAN02 FCC " RETRY 03808 1A64 2A FULLD FCC "* FULL *" 03809 1A6C 2A ERRORD FCC "* ERROR *" 03810 * 03811 ************************************************ 03812 * * 03813 * VECTOR ADDRESSES * 03814 * * 03815 ************************************************ 03816 * 03817 1FF6 ORG $lFF6 03818 * 03819 1FF6 OC25 FDB TIMER2 K88SCN/BUZZER 03820 1FF8 OB80 FDB TIMER1 INT2/TIMER 03821 1FFA 0500 FDB MAINPR INT 03822 1FFC 0500 FDB MAINPR SWI 03823 1FFE 0500 FDB MAINPR RES 03824 * 03825 END ~HITACHI 1148 4.2 Symbol Table Listing ADDRAT 0129 ARGINT 1541 ARG100 15B7 ARG110 15CO ARG16 1590 ARG17 1599 ARG18 15A1 ARG19 15BO BUZC OB8D BUZC1 OB96 BUZC2 OBBO BUZC3 OBAC BUZC4 OBD5 BUZC5 OBBC BUZC6 OBDA BUZZ OC95 BUZZ1 OCA6 BUZZ2 OCAE BZR 004F BZRCNT 004C BZRFLG 004E CALC NT 006E CALDAT 19E3 CALLCD 1258 CALNDR 005D CALRST 1038 CAL SHU 149F CALSH1 14A9 CALSH2 14DD CALSH3 14C3 CALSH4 14C5 CALSH5 14CF CALSH6 14E8 CALSH7 14D7 CALSH8 1515 CALSH9 14DC CALS10 151E CANCEL 1001 CANCL2 1010 CATBL 067A CATBLE 068C CHATFL 0057 CHECK 05E9 CHECKF 0651 CHECK1 05EF CHECK2 05F7 CHECK3 0601 CHECK4 0612 CHECKS 062A CHECK6 062D CHECK7 063B CHEI1< CHI<53 080F 01126 01129 01147>1< CLEAR 1480 00527 00597 02750>k CLR1 1482 02751>1< 02754 CMPNUM 0003 00101* 01407 CNT 006D 00038* 02173 02188 02367 02386 02403 02411 02421 02424 02803 02815 02823 02845 02873 02925 03040 03050 03064 03065 03103 03125 03132 03158 03181 0:)188 C322l U..)L._)"f 0:::244 03248 li·'),(""""I-," / CNTBIT 0068 00036* :)2280 02282 02297 02302 02334 02929 03041 03042 03043 03044 03051 03052 03053 03054 03061 03106 03103 031 '?2. 03130 03135 03137 03161 03163 03184 03186 0319l 03193 CRGDAT lAlD 03120 03153 03601* CRGSET 16EA 00850 03177* CRGSTl 1711 03195* 03198 CRGST2 1718 03200* 03203 CSTBL 068C 00303 00308 00312 00315 00358>1< CST8LE 0695 00308 00364* CURADP 0048 00015~' 00489 005';:4 00535 00541 00634 00639 00641 00676 00682 00690 00799 OC19~6 00998 01043 01047 01050 01078 01099 01102 01107 01137 011 :3E', 01191 ~HITACHI 1152 01198 01201 01221 01333 01514 01890 021lXJ 0:::672 02787 02926 03205 03342 03345 03350 03355 03382 03386 03392 03395 03597 03635 03637 03639 03662 03665 03670 03672 03674 CURCAL 17EC 01141 01192 03369* CURCL1 1808 03371 03385* CURCL2 1811 03373 03375 03377 03379 03388* CURCL3 181D 03390 03394* CURCL5 180A 03381 03384* 03387 03393 03396 CURLR 0812 00359 00361 01162* CURLRA 086E 01193 01203* CURLRF 0871 01162 01171 01174 01176 01177 01180 01183 01204* CURLR2 0830 01170 01175* CURLR3 083F 01172 01178 01181* CURLR4 OB46 01165 01184* CURLR5 0852 01186 01190* CURLR6 OB56 01189 01192* CURLR7 OB58 01167 01194* CURLR8 OB67 01196 01200* CURLR9 OB6B 01199 01202* CURRAT 17BB 01144 01202 03332* CURRA1 17D2 03334 03344* CURRA2 17D8 03336 03347* CURRA3 17E2 03338 03352* CURRA4 17D1 03340 03343* 03346 03351 03356 DATA 004A 00014* 00158 00163 00168 00173 02475 02483 02511 02590 02689 03422 03436 03499 03518 03707 03723 03735 03739 03743 03747 DAY 14F4 02840 02848>1< DIACLR 146C 02003 02715>1< 02920 DIACLl 146E 02716>1< 02719 DIADAT 00B7 00054* 00955 00973 01610 01628 01636 01664 01968 02978 DIALNO 0099 00043* 00738 00771 00932 00947 01558 01591 02667 02717 02897 03608 DIAL2 1526 01791 01814 02889>1< DIAL21 1528 02890* 02893 DIAL22 1531 02895* 02900 DIAN01 1A4C 00731 03806* DIAN02 1A56 00764 02890 03807* DIAP1 OOBC 00055* 00954 00959 00960 00963 00972 00974 00975 00978 01992 02945 DIAP2 OOBD 00056* 01609 01627 01634 01644 01646 01649 01663 01993 02946 DTADD 18C4 02486 02544 02593 02628 02661 02691 02697 03552* 03711 DTADD1 laCE 03555 03557* DTADS 0050 00019* 00551 00554 00562 00565 00586 00588 00598 00600 02554 02556 02561 02563 DTCNT 0049 00013>1< 02473 02487 02504 02514 02516 03592 DTDP 0045 00011* 00155 00156 001fi1 00166 00171 00493 00494 00532 00533 00553 00556 00564 00567 00587 00589 00599 00601 00699 00700 00702 00704 00706 02469 02471 02506 02509 02521 02524 02527 02529 02533 02558 02559 02562 02564 02645 02646 02648 02650 02652 03487 03489 03500 03520- 03523 03532 03552 03554 03556 03570 03572 03574 03593 03594 03708 ~HITACHI -- ------~- --- --,---~------~~---- --~~ 1153 m 03709 03713 03716 03719 03721 03725 03727 03728 03732 03733 03737 03741 03745 DTLCD 1449 02565 02687* DTLCD1 144A 02688* 02694 DTLCD2 1459 02695* 02701 DTSU8 18CF 02526 03570* DTSU81 18D9 03573 03575* END 18DA 00153 00501 00575 00591 00603 00711 00832 00862 00893 01971 01982 03587* END1 18FA 03587 03603* END2 1904 03608* 03612 END3 1910 03602 03614* ERFLG 008E 00057* 00122 00198 00209 00387 00388 00412 00414 00921 01010 01057 01110 01147 01733 01734 02540 02541 02871 02949 03283 ERROR 0695 00124 00376* ERRORD 1A6C 00395 03809* ERROR2 06A8 00377 00379 00386* ERROR3 06C1 00395* 00398 ERROR4 06CE 00388 00401* ERRORS 06DC 00407* 00410 ERROR6 06E7 00387 00400 00412* ERR1 0138 00075* 00378 00382 01274 01277 01291 01837 02947 ERR2 013C 00076* 00385 01279 01282 01838 02948 FIGURE OSDS 01242 01307* FIG1 OSF6 01312 01318* FIG2 OSFF 01318 01321* FIG3 OCOO 01321 01326* FIG4 OC12 01322 01328* FIGS OC17 01323 01330* FIG6 OC1C 01324 01332* FIG7 OC1F 01327 01329 01331 01333* FIG8 OC24 01308 01325 01335* FLAG 0042 00008* 00114 00125 00271 00389 00391 00401 00403 00431 00433 00434 00448 00450 00451 00465 00467 00468 00485 00487 00492 00520 00522 00536 00550 00561 00621 00623 00668 00670 00725 00727 00758 00760 00792 00794 00817 00819 00847 00849 01171 01177 01287 01321 01322 01323 01324 01366 01414 01482 01483 01485 01487 01798 01800 01883 01885 01931 01963 01964 02404 02412 02444 02468 02503 02515 02525 02545 02548 02552 02560 02784 02936 03599 03603 03605 FULLD 1A64 00407 03808* HOLD OOBF 00059* 02598 02599 02603 02610 02612 02848 02864 INPDAT 187C 00157 00162 00167 00172 02474 02488 02510 02657 02688 02695 03486* JMPAOR 013E 00081* 00213 00216 00293 00296 00313 00316 JTSL 0130 00080* 00218 00219 00298 00299 00318 00319 KENSAI< 12C1 00495 00538 00568 02466* KENSKA 1349 02525 02529* KENSKB 1352 02531 02533* KENSJ1< 02489 KENSI<4 12F5 02485 02490* 02515 I1< 02496 KENSK6 1310 02493 02503* KENSI<7 1312 02504>1< 02518 KENSK8 13iE 02510* 02547 KENSK9 1333 02479 02482 02519* 02557 KEYCD 0652 00278 00328* KEYDAT 0058 00026* 00116 00190 00274 00277 00302 00547 01168 01184 01194 01413 03388 KEYNUM 005A 00028* 01370 01379 01380 01390 01392 02317 02320 02321 02324 KEYSET 0054 00022* 00279 00912 00930 00945 00953 00971 00999 01005 01026 01033 01045 01075 01080 01092 01097 01124 01131 KNSEQ1 1378 02548 02552>1< KNSKEQ 1367 02513 02543* KNSRTS 1399 02480 02502 02542 02560 02566* K88SCN OC31 01351 01366* K88SN1 OC40 01373>1< 01396 K88SN2 OC52 01377 01382* K88SN3 OC56 01384>1< 01394 K88SN4 OC65 01385 01392* 1<88SN5 OC68 01381 01395>1< K88SN6 OC77 01398 01401* 1<88SN7 OC7D 01400 01404* 1<88SN8 OC8C 01408 01411* 1<88SN9 OC94 01366 01389 01403 01404 01410 01415>1< LCD 110E 00393 00399 00405 00411 00491 00526 00580 00625 00635 00672 00677 00693 00729 00742 00762 00775 00796 00821 00851 00935 00950 00958 01007 01055 01108 01142 01145 01203 01222 01286 01334 01802 01887 02089* 02673 02702 02901 03613 03641 03677 LCD8SY 11C4 02129 02150 02206 02237* LCD8Y1 lICE 02242* 02250 LCDDSP 115C 02095 02150* 02221 LCD INS 1148 02091 02104 02108 02112 02129* 02217 LCDINT 1195 02203* 02917 LCDIN1 1197 02204* 02214 LCDIN2 11AF 02205 02216* LCDIN3 1188 02220* 02223 LCDIN5 1198 02206* 02225 LCDM 0071 00042* 00396 00408 00628 00647 00687 00688 00697 00732 00737 00765 00770 00931 00946 00957 01006 01027 01046 01076 01098 01132 02094 02409 02420 02446 02467 02550 02579 02589 02600 02643 02666 02690 02752 02809 02891 02896 03048 03062 03111 03116 03121 03154 03179 03196 03201 03224 03238 03252 03256 03264 03409 03411 03413 03421 03437 03451 03452 03469 03609 03666 03692 03763 03783 LCDMCR 1966 00392 00404 00490 00496 00525 00624 00671 00728 00761 00795 01285 01801 01886 02442 02501 02586 03101 03151 03177 03601 03606 03690* LCDMP 0040 00006* 00543 00632 00636 00638 00674 00678 00680 00692 00798 00925 00929 00934 00942 00949 00956 00964 00965 00996 01044 01052 01054 01071 01074 01077 01096 01104 01106 01130 01136 01187 01190 ~HITACHI --~ ------ --.~-.---~-~~ --------- 1155 m 01197 01200 01219 01889 02789 03207 03332 03341 03344 03348 03353 03369 03383 03385 03391 03394 03591 03634 03640 03669 03676 LCoMST 12AB 02365 02384 02442* LCoMS1 12BO 02444* 02448 LCoMS2 12BC 02444 02450* LCoMS3 12B6 02446* 02451 LCoRES 1172 02172* 02916 LCoRS1 1176 02174* 02189 LCoRS2 1178 02175* 02179 LCoRS3 117A 02176* 02177 LCoSET 1276 02370 02389 02403* LCoSE1 1278 02404* 02425 LCoSE2 12A3 02404 02427* LCoSE3 1270 02406* 02428 LCoSE6 12A7 02412 02429* LCoSE7 128E 02414* 02430 LC01 1118 02094* 02099 LC02 1134 02107* 02110 LC03 1130 02106 02111* LC04 1144 02102 02115* LC05 113F 02112* 02116 LFCRSR 1911 01173 03626* LFCR1 1930 03638 03641* LFCR2 191E 03628 03630 03632* LFCR3 1933 03633 03642* LFCR4 1922 03631 03634* MAINI341 03799* SHUSEC 0137 00071* 02928 03255 03263 03267 03268 03275 SHUSTA 0065 00034* 02822 02829 02838 02843 028 4 9 02860 03235 03245 03246 03270 SINGL 012D 00068* 03023 03025 03070 03078 03316 SNGCLR 1781 01314 02005 02966 03314* SNGCLI 1783 03315* 03318 SNGSTA 167E 01332 03101* SNGSl 1692 03110* 03113 SNGS2 169C 03115;< 03J.l8 SNGS3 16A6 03120* 03123 SSR 0011 00097* 00146 01350 ST8DAT 0058 00029* 01368 01373 01395 SYSINT 0523 00113 00138* TAN 1409 00650 02643* ~HITACHI -~~~-~- -------~ ~~---~-- --~-~ 1159 m TANI 1419 02651* 02655 TAN2 1424 02657* 02663 TAN3 1437 02666* 02671 TCNTR 0070 00041* 01307 01310 TCR 0009 00099* 001'"2 01238 TOR 0008 00098* 0014'J 01240 TEL 0062 00033* 02339 02344 02427 02429 02768 TELClR 1489 01313 02004 02767>'(. 02919 TElCll 1488 02768* 02770 TElCNT Ol3A 00074* 01679 01770 01803 01805 01817 01841 01843 01916 01986 02933 TElDAT 19F2 02450 03795* TELFlG 0044 00010* 01312 01318 01451 01513 01602 01603 01670 01671 01693 01694 01719 01721 01741 01743 01749 01821 01822 01829 01830 01892 01909 01994 01996 02930 TELLCD 1267 01328 02384* TELMN OCAF 01353 01451* TELMN1 OCCO 01451 014'::7'" TELMN2 OCC5 01452 01<-59* TELMN3 OCCA 01453 01461* TELMN4 OCCF 01454 01463* TELMN5 OCD4 014'3'::; 01465* TELMN6 OCD9 01456 01467* TELMN7 oeDe 01!.f5t'3 01460 01462 01464- 01466 01468* TELMIO OCDO 01457 0148C'* TELMll OCE7 01480 014,31 01484* TELM12 OCFC 01484 01494* TElM20 0000 014':,9 01507: 1, TELM21 0008 0150? o151lK TELM22 0010 015:;,S o 15,[J';l 01513* TELM23 0014 015:0 01512 01515* TELM3A OE84 01608 01671 01690>K TELM3S OE80 01687 01690 01693* TELM3F OE95 01541 01546 01568 01576 01579 01597 01600 01605 01617 01643 01653 01656 01669 01673 01676 01686 01689 01692 01697* TELM30 OD15 01461 01531* TELM31 OD2E 01532 01542* TELM32 OD3A 01543 01547* TELM33 OD87 01549 01580* TELM34 ODB7 01593 01601>1< TELM35 ODCF 01589 01609* TELM36 ODE3 01548 01618* TELM37 OE35 01618 01657* TELM38 OEM 01606 01677* TELM39 OE7B 01607 01670 01687* TELM40 OE96 01463 01709* TELM41 OEAD 01710 01719* TELM42 OEB1 01711 01721* TELM43 OEB3 01720 01722* TELM44 OEBS 01709 01726* TELM45 OEe5 01728 01731* TELM46 OEDD 01731 01741* TELM47 OEE1 01732 01743* TELM48 OEE3 01742 01744* TELM49 OEF1 01718 01725 01730 01740 01751>1< ~HITACHI 1160 TELM5A OFBO 01820 01852* TELM58 OF CO 01853 01860* TELM5C OF03 01859 01862* TELM5F OFD7 01777 01815 01818 01824 01840 01851 01861 01864* TELM50 OEF2 01465 01765* TELM51 OFI0 01766 01778* TELM52 OF62 01806 01815* TELM53 OF65 01810 01816* TELM54 OF60 01779 01819* TELM55 OF70 01821 01825* TELM56 OF83 01822 01827* TELM57 OF89 01825 01827 01829* TELM58 OFA4 01826 01828 01841* TELM59 OF8A 01844 01848 01851* TE!...M60 OF08 01467 01878* TELM61 OFE7 01880 01881 01883* TELM62 OFFO 01879 01882 01893* TELNO 0139 00073* 01538 01557 01569 01571 01586 01590 01683 01768 01807 01809 01845 01847 01915 01985 02932 TELNOI 1823 02625 03409* TELN02 1838 02658 02696 03436* TELWAT 0086 00053* 01531 01534 01544 01681 01716 01724 01726 01729 01750 01765 01772 01811 01850 01862 01914 01984 02931 TELll 1832 03415 03417* TEL21 1848 03441 03444* TEL22 1853 03445 03448* TEL222 1859 03443 03447 03449 03451* TEL23 1868 03459 03462* TEL24 1873 03463 03466* TEL25 1879 03461 03465 03467 03469* TEL321 0040 01547 01549* TEL322 0061 01556 01564* TEL323 006C 01567 01569* TEL324 007F 01554 01577* TEL331 009C 01588 01590* TEL332 OOAF 01585 01598* TEL341 00C6 01601 01606* TEL342 00C9 01602 01607* TEL343 OOCC 01603 01608* TEL351 0000 01612 01616* TEL361 OEOO 01626 01638* TEL362 OE19 01637 01642 01644* TEL363 OE24 01648 01650* TEL364 OE20 01624 01654* TEL371 OE50 01666 01670* TEL372 OE5C 01662 01674* TEL501 OFOO 01773 01777* TEL511 OFIF 01780 01785* TEL512 OF31 01785 01793* TEL513 OF47 01784 01788 01792 01795 01803* TIMCNT llF4 02266 02281 02295* TIMCTl IlF5 02296* 02341 TIMCT2 1245 02298 02343* - ------~--- -~ ------. ~HITACHI .-~~------- .~ ------- ~- -------~------.- 1161 I TIMCT3 IlFE 02301* 02345 TIMCT4 120A 02302 02308* TIMCT5 124A 02309 02346* TIMCT6 122D 02329* 02347 TIMCT? 124F 02329 02348* TIMCT8 1233 02332* 02349 TIMCT9 1252 02335 02350* TIMC10 1241 02340* 02352 TIMER1 0880 01238* 03820 TIMER2 OC25 01350* 03819 TIMSTA 006A 00035* 02303 02307 02310 02326 02332 02338 02350 TLCNT IlEA 01319 02279* ·TOLCLR 17A7 02965 03297* TOLCLl 17A9 03298* 03301 TOLSTA 16CD 01330 03151* TOLSTl 16D2 03153* 03156 TOROKU 139A 00500 00590 00602 02578* TOROK1 1398 02579* 02585 TOROK2 13A8 02583 02586* TOROI<3 13AD 02581 02588* TOROK4 13AE 02589* 02595 TOROI<5 13F5 02617 02623* TOROl<6 13FA 02625* 02630 TOTAL 0131 00069* 00878 03015 03017 03068 03076 03299 TOTLI CflCfl • ABSOLUTE MAXIMUM RATINGS (Vss = OV) Item Symbol Value Unit Power supply voltage VDD 6,0 V Terminal voltage V7' Vss --·0.3 to VDD +0.3 V --_. Operating temperature Topr -20 to +75 °c Storage temperature Tstg -55 to +125 °c ~HITACHI 1170 • ELECTRICAL CHARACTERISTICS • DC Characteristics (VSS = OV VD D = 2 0 to 5 5V T.0 = -20 to +75°C) - Item Symbol Test Condition min. typo *1 max. Unit -- -- Opera ting voltage (I) VDD Tone Out Mode 2.5 - 5.5 V Operating voltage (2) VDD Non Tone Out Mode J.7 - 5.5 V -- Reset volt:lge VDn - 1.5 - V Memory clear voltage I'DC - 1.15 - V Opemting current IDD Tone Out Mode, no load - 300 - "A - ---_ .._- - Memory retention (reset) current IDn - 0.5 -- "A except 115 pin 80% VDD ----- - - ._------- - Input High voltage Vm HS pin VDD =3.0 to 5.5V 90% VDD - - V US pin VDD = 2.0 to 3.0V VDD-O.I - - Input Low voltage I'lL - - 20% VDD V - - - - - - 1 - - -- - - Input leak current 1/1.11 Pull-up MaS off, VIN =0 to v-VV-- - - - "A ----- - - InpulPuU-up MaS VIN =O(RO, ST, SO, 59, ROW, current -II' COL, liS) - 10 - "A Output IIigh voltage VO ll -lOll =0.1 mA (MUTE) VD D -0.5 - - V - Output Low voltage VOL 101.=O.lmA (ROW, COL) - - 0.3 V Output MaS ofr, VIN = 0 to I'DD Output leak current IlLol (TONE MUTE) - - ___ L_________ I "A - - - - - - - - - - "-- ~ • AC Characteristics (Vss = OV, VlJD = 2.0 to 5 SV To = -20 to +7S 0 C) _____I_tc_m _ _ _ _ _-!-_S::..y_m_b_()~I~=_-.~~~~~~~~_T-'_e::.._s-t~C~o~n~d~i_t-,.i_o-_n-_-_~-_-'_-_-_-_-_-~----I-l-l-i-l-l-.---+~_-t-y-p-.*-:-1-.--m-'-lx-.--- -u;;U-- Oscillation frequency fos e - 400 - kHz Oscillation start ~I;ti-m-e--+-I-'s-"-Ir-=---f---------------+------- 5 - ms ROW TONE V S· 1 - - - - - - - - - - I--::---f------- Tone Out f------ on __In_g_'e_·_T_o_nc_·M_o'!.::_600n to Vss 200 245 290 mVrms COLUM TONE I'oc I'DlJ = 2.5 to 5.5V, To = 25°C 270 310 360 mVrms ----I------I--=--=----!----::c---": --:--::-- 1--:----/--- ROW TONE Von Single Tone Mode, 10kn to I'ss 245 270 300 mVrms Tone Out COLUM TONE. V OC VD D = 2.5 to 5.5V, To = 25°C 310 340 370 mVrms -R-O-W-'-C-'O-L.LU-M-T-o-n-e-O=-u:"'t:':"'I-~----- ----''--='-------'---=------1----1---- - - - - / - - - ratio dBcll I'DD = 2.5 to S.5V - 2 - dB -----------4------r----------------------+----~----- Output distortion Dis 10kn to Vss, VDD = 2.5 to 5.5V - 5 7 'in *-1-Typ~;~-lu-c-I~I;;;_d~-sl-g-n-v~I~~(tt;-st-and;~~i-v-al-u-e-a-t-V-D-D-;;--2.5V aniC-To-=-iso·c-)---- . ______ .L._ _ _ _ _ _ _ _ _ _ • Description The HD61826 is specifically designed Ie to implement a voltage is higher than the reset voltage, the oscillator is DTMF (Dual-Tone Multi Frequency) telephone dialing enabled by a key input and then this key input is imple' system. With fow voltage and low-power consumption mented with the key debounce circuit, In this case, if the CMOS process, it can be operated directly from the first key after the reset (note 1) is other than # and *, the telephone line. This Ie generates each DTMF signal by internal memory data is cleared, and then this input key is digitally synthesizing the sinusoidal waveform for the encoded and stored into the memory. The following keys individual frequencies, using a 400 kHz ceramic oscilla· are in turn stored into the memory and converted into tion as frequency reference. The last dial numbers can be DTMF signal outputs. (note 2) redialed by the simple key operation using an internal When the HD61826 is reset after dialing, it will be in the redial memory. The HD61826 can also be used as a redial mode with the first # key. However, if the 24 or normal DTMF dialer without the redial memory by mode more keys have been dialed previously or the memory has select input. already been cleared, it cannot be in the redial mode. In the HD61826, ON HOOK/OFF HOOK is detected by During the redial mode, any key input is not accepted, the HS pin. When the supply voltage is lower than reset blot after the completion of redial, the HD61826 can be voltage, the HD61826 does not accept any key inputs used as a usual dialer. The signal output will stop with the independent of the HS pin. When the power supply pause during the redial and the redial starts again with # voltage is lower than memory clear voltage, the internal key. # key is used to insert the pause data in the memo memory data is cleared. ory. In this case, # key does not influence the output of While the telephone is in the OF F HOOK and the supply signal but is stored in the memory as one digit. NOTES: I. In the 11061826, the reset means the clearing of all logic (counter, etc.) except RAM. 1-1061826 is reset when the tel~phone is in the ON HOOK or the supply voltage is lower than the reset voltage. 2. While the key is pushed, the DTMF signal is kept generating. ~HITACHI 1171 -------.-----------.-.--.--~--- • PIN FUNCTION • Voo (Pin 1) Th is is a positive voltage supply pin which applies voltage to the basis of the Vss pin. HD61826 provides the internal sense circuit for the supply voltage. To make this circuit operate stable, the following rising time is necessary. ---+-------'I,,--+-----+--~----Hpsel vollage - - - - J < - - - - - - - - - - - - - - - - - - \ . - / - - - - - - I \ I emory c1eaf I" =O.I-.1Oms voltage -------v" • TONE (Pin 2) This is a Tone output (DTMF signal output) pin. Output circuit is N-Channel MOS source-follower and the resistor to Vss is necessary. Further, to II Internal realize low power consumption in the standby logic lone mode, TONE output MOS and internal V,ef circuit ,----.j signal are turned off after tone output completed. And this is synchronous with MUTE signal. DTMF signal is digitally synthesized by using the 400 kHz oscillation as frequency reference. Tone output frequency of HD61826 and its deviation from Tone output standard DTM F are as follows: N -, channel sourcefollower output Standard Tone Output % Devia- TONE: ~nnr.llnr----l DTMF (Hz) Frequency Using 400 kHz OscilJa tion tion from Standard (~ UUV UV :L I [, 697 694,44 -0.37 I I ..0 - - - - - Tone '"': output on ------<~..., ROW [, 770 7{)9,23 -0.10 I f3 852 851,06 -0.11 I L f. 941 938,97 -0.22 .- f, 1209 1212,12 0.26 COL f 6 1336 1333,33 -0.20 f7 1477 1481,48 0.30 As the HD61826 contains an voltage reference (V,etl circuit, it always generates stable Tone output amplitude even if supply voltage and temperature change. ~HITACHI 1172 • MUTE (Pin 3) \'1'" This is a pin which mutes the receiver and the transmitter. Output circuit is P·Channel MaS open drain. L Tn MUTE ... High level I !Tlll'!'nal logic While reset, the output voltage is held to Low level. I' channel MOS open drClin output • RD (Pin 4) Redial Operation This is an input pin which selects H061826 opera- tions: a tone dialer with redial providing memory function, and a simple tone dialer in which only normal key input is converted into tone output. This pin is implemented with the pull-up MaS, and to realize the low power dissipation on reset, M - + - - To intel'nal logic the pull-up MaS is turned off at the reset. (note 1) (protection diode) RDpin Operation Mode Redial Operation High (to Vvv) Tone Dialer no Tone out with * Of # or open with Redial available . Redial/Pause with # Simple not Low (to Vs s ) • Tone out with * Of # Tone Dialer available NOTES: _ 1. The input pins, with pull-up MOS which is turned off at the reset, can be applied to RD, ST, SO, S9, HS. 2. The logic is positive. PMOS is ON with the low voltage and OFF with the high voltage. • ST (Pin 5) Single Tone Test This is an input pin to put H 061826 in the single tone mode for tone output test. This pin is im- plemented with the pull-up MaS which is turned off at the reset. Further, in the single tone mode, digital signal for test is output on MUTE. Usually ST pin should be fixed to High level or open. -----_._---- ._-- STpin SO pin S9 pin Operation Mode Tone Output High (to Vvv) - - Dual Tone DTMF Tone out or open Low High to ROW Single tone out Low (to VSS) Single Tone High Low to COL Single tone out NOTE: SO and S9 pins should not be Low level at the same time. ~HITACHI 1173 • SO,59 (Pin 6,7) Selection These are input pins to select functions and each system_ When the first key input after the reset is of them has pull-up MOS which is turned OFF at o or 9, all the key inputs including the 0 or 9 key the reset_ The function of this terminal is to become invalid after then_ In other words, the prevent the 0 dialing in and 9 dialing in, which is signals are not output to TONE and MUTE_ Then applied to the telephone subset under the PBX the telephone is initialized by the reset. ,----------- -----------------~--- ---------~---------------------- so Pin S91'in Function f----------------- ---------------- High (to V DD) or open High (to V DD) or opcn Normal dialing mode f - - - - - - - - - - - - - - - - - - - ------------~------t----------~---------------- High (to VDD) or opcn Low (to Vss) 9 dialing in inhibition Illode 1 - - - - - - - - - - - - - - - --------~----------___t__c c:--:c-:-------- --~--------- Low (to V SS) lIigh (to V DD) or open 0 dialing in inhibition mode f - - - - - = ' - - - - - - - - - - - - - - - - - - - - - - - - - - - ------------- ----- --~- Low (to Vss) ' - _ - ' - - - -_ _ _ _ _ _ _..L..._ _ _ _Vss) Low (to --'-_ _ _ _ _ _ _ _ _ _ _ _ Test Illode (for testing Ie. Not use_) • OSCin, OSCout (Pin 8, 9) Oscillation Input, Output These are the input pins for the oscillator and con- struct the inverter (with disable function to stop the oscillation). The frequency is stable in the circuit by using the ceramic resonator. Then the oscillator section needs two external capacitors. The ceramic resonator should be 400 kHz and High Q_ Recommended ceramic resonator: I'rutl.'rti"n d"\'j("(, KYOCERA CO. KBR-400H ex_ ceramic oscillation \ - --, ,, 1~1 C 1 =100pF ,I \ C2 = 470 pF Oscillation Circuit When OSCout is open, a 400 kHz external pulse can be applied to OSCin_ • Vss (Pin 10) This is a negative power supply pin. ~HITACHI 1174 • COLI to COl 3 (Pin 11 to 13) Colum Input ROW I to ROW 4 (Pin 14 to 17) Row Input These are input/output pins for a key board which consist of PMOS pull-up and NMOS driver_ (As a matter of form, these are CMOS_) :~ernal As the row and column are alternately scanned, the HD61826 can be connected both to the matrix- type keyboard and the 2-of-7 keyboard. While } logic waiting for the key input, Rows are High level and Columns are Low level. And in the reset mode, ~----~---------r~~ both Rowand Column are low level. The hold time of the key should be more than 10 ms. (While the oscillation stops, the period for starting oscillation should be added.) (note 1) The key debounce time is 20 ms. Tone is remaining while pushing the key (precisely speaking, after key operation, tone continues during the debounce time). But the key operation should meet the DTMF receiver specification. NOTES: I. The oscillation stops in IID61826; I. After the reset 2. After the completkon of Tone output I/O Circuit for Keyboard 3. On Pause 1---- HOW, (f,) COL---~ ~----HOW t-___ HOW:o Matrix Keyboard (h) t-___ ROW " (I:,) I~~COL t-_ _ ~HOW., ~----HOW (I.,) L ,-'- 2-of-7 Keyboard _ .0 o~ u- When two keys are pushed at the same time, the Keyboard Configuration key of the smaller number of ROWand COL is given priority and is entered. Ex. When 2 and 5 are pushed at the same time, 2 is accepted. ~HITACHI 1175 • HS (Pin 18) Hook Switch This is an input pin for detecting ON·HOOK/OFF· H061826 is reset by setting the HS terminal High HOOK switch. It has a pull·up MOS which is level. Even if the HS terminal is fixed to Low level, turned off at the reset. the H061826 is reset when supply voltage is lower ON HOOK .... High (to V oo ) or open than reset voltage. So without using the HS pin the OFF HOOK ... Low (to Vss ) H 061826 can control the operation mode by the monitor of supply voltage. Then, as the pull·up MOS is turned off with the reset signal, the current does not increase on reset. An external capacitor must be provided between the HS pin and Vss to • TIMING CHART prevent the switch from chattering. liS , ' - -_ _ _ _ _ _ _ _ ----.Jn L _ _ _ _ _ _ _ _ _ _ _ _ __ Key nFLSffil~________~IOOl~___________________ OSC IICJ nil CJ MUTE Il.--II~______~r_l~--------------------- (2): (3): (3) (21 TONE ~ ... --------~~~-------------------- L H . MUTE I 5~ L Mode Item Symbol min. typo max. Unit Normal Dial Pre·Digital Pause tPRP - 5 - ms Post-Digital Pause tpop - 44 - ms Pre·Digital Pause tpRP - 5 - ms Redial Tone Output time tTONE - 133 - ms Inter·Digital Pause tJDP - 87 - ms Post-Digital Pause tpop - 44 - ms • AN EXAMPLE OF KEY OPERATION (RO = High) 110011: . ---'Ki,:y------ ,·-------··--'"""(iNj?----·- .--------.---.. "ii, (ii;,ii"~ in-jl,i,il;ii"i"i',' iiii;'iil"' \\1.11 Su-;-i.;,,,\" -~"Id S9'; iii;iil ON ON Nnrmilll);al 011 nll.14Sfi 0,1.2..1.4,$.6,11,"1('1 01,1" I 2 J II nN .' , 5 fa ,""ld ON Rttlial Oil (I I 2 011 n,* S 61 :I IJial aUt'1 Redi'" 1H 7.8. ON ON 01:'1:' 5 6 7,·, R •. Rt'dial 01,1-' (I. I I J 4 NOTE: • shows that after tone output Mute is ON Ntlrmal ni;ll 01-' I I 9, I. 2 • Low level and - shows that Mute is High level. (rau~C! fntry) Rt'dial Ilndudln" rllu~d ON on .. I 2. ON Uialllr 24 dill-il~ til muu~ 01· I! I I .•. 1 1.1. .. . J. 24 Ii"'r~ 14 lilllt'~ ON r,euRlllln flf Oyer nll~' 01'1' ~HITACHI 1176 • APPLICATION CIRCUIT IlIl I{OW, HOW" 4 5 6 SO HOW" 8 9 S9 HOW, "* 0 :!± '--------+-4~~._+_+--_.__i v" COL, '---......-------t--+---t--+-t-..J\j\l\,..4~ liS ~ COL ,1-----' ~ COI~,I__-----' '" Q ::r: ~+_~~---_;TONE l-~----i MUTE Hil C Speech Cin'uit H GN ~HITACHI 1177 Appendix II. HA16808NT Data Sheet -Preliminary- • Abstract The HA16808NT IS a monolithic IC including speech network, tone ringer, and speaker amp. Therefore the telephone with speaker can be co.posed of HA16808NT and dialer IC • • Features DP-42S • Low voltage operation ------ (1.8V) • AGC according to the I ine current (Gains of sending, receIvIng, DTHF, and melody) • Adjustable receIvIng gain by external resistor (0- +10dB) • Interface for DTHF (VDO, MUTE, Sending amp. of DTHF signal) • Interface for melody IC (VDO, Sending amp. of melody signal) • Noise suppression (No output for the input below noise level. The nOIse level can be controlled by external components.) • Possible to dial under the on-hook condition (Included speaker amp.) • Possible to receIve by speaker (Also possible to send .ith handset in speaker mode.) • At the time to send DTMF or melody, backtone comes out from receIver or speaker. • Variable osci Ilation freq. of ringer by external R, C. • Variable supply initiation current. ~HITACHI 1178 • Block DiagraIR SW3 (liS) MIe...c -e:::~ l ¢~ Yl__-<~ ~ _~~L--+---4~11 _ _~ -~-------j~GIr DET. ~ LB-=_-j h:----jr:! -l.-I---jl_f---~ ~r--1 --- ... ~--l-----_j[I L.:. REG. ____ -j§ SW2(SP) ~ ~ OSC. - r! ---1 OSC. ~ " or L:.- I - L - ~ MUTE --------~MU~T-EI~[S§C>__VREF ,---~~_~~L-_~~ ID. ... r,:; ~ttY~--------+-~ SWl (HOLD) ,--<> ~ Ll r- ~~ ~~---~-t-r~ ~HITACHI 1179 I • Maximum Rating (Ta=25=C) NO Item Symbol Rating Unit Note 1 Supply Voltage (OFF HOOK) VL 20 V 1 2 Supply Current (OFF HOOK) IL 120 lOA 3 Supply Voltage(Tone Ringer) VTR 30 V 4 Operation Temperature Topr -20-+70 ·C 5 Storage Temperature Tstg -55- +125 ·C 6 Power Dissipation Pr 950 loW Note 1) 3 illS Pulse duration II Electrical Characteristics (handset mode) NO Itelll SYlllbol Test Condition Spec. Un it L lilA 1II1n. typo max. 1 Supply Speaking VL 20 2.3 2.6 2.8 V f-- 2 Voltage 80 5.0 6.5 8.0 V :-- 3 Di a ling 20 5.5 6.2 6.6 V '--- 4 80 7.0 10.0 V 5 Receiving Gain GR 30 f = 1kHz -6.5 -5 -3.5 dB ;--- ~ 6 80 -12.5 -11 -9.5 dB 7 Up Hode 30 REXBs = 560 Q 5 10 15 dB 8 Sending Gain GT 30 f = 1kHz 50 51. 5 53 dB :-- 9 80 44.5 46 47.5 dB 10 Side tone GSID 30 f = 1kHz 40 dB 11 DTMF Sending Gain GHF 30 22.5 24 25.5 dB - 12 80 19 20.5 22 dB 13 Sending Dynamic Range DRT 30 f = 1kHz 2.2 2.7 Vp-p - 14 80 4.5 6.0 Vp-p 15 Receiving Dynamic DRR 20 f = 1kHz 0.4 0.6 Vp-p - 16 Range 80 0.8 Vp-p 17 DTHF Dynuic Range DRHF 20 2.8 4.0 Vp-p -- 18 80 3.0 Vp-p 19 DTMF Supply Stand-by VDD 20 1.6 1.8 V Voltage ~HITACHI 1180 110 Item :)ymbol Test Conditions Spec. Un it I L lOA typo max. 10 111. 21 DTHF Supply Mute VOD 20 3.5 3.8 V Vo I-tage r-- 22 DTHF Supply Stand-by IOD 20 200 JlA - 23 Current Hute 20 2 lOA 24 DTHF Backtone BT~IF 80 VHl=170mVp-p 40 60 80 mVp-p 25 Line Hatching Jr,pedance ZIN 20,80 f=1kllz 500 600 700 Q (speaker lIIode) HO Itell :'>Ylllbol Test Conditions Spec. Un it [L IIJA IIIln. typo max. 1 Supply Speaking VLSP 20 3.7 4.1 4.5 V - 2 Voltage 80 6 9 V - 3 Di a ling 20 5.2 6.0 6.8 V - 4 80 7 10 V 5 Receiving Gain GRSP 30 f = 1kHz -12.5 -10 -7.5 dB - 6 80 -17.5 -15 -12.5 dB 7 Sending Gain Grsp 30 f = 1kHz 47.5 49.5 51.5 dB - 8 80 40 42 44 dB 9 Side ton~ i->SIOSP 30 f = 1kHz 45 dB 10 DTHF Sending Gain GHFSP 30 21. 5 23.5 25.5 dB r-- 11 80 17.5 19.5 21. 5 dB 12 Sending Dynamic Range DRTSP 50 f = 1kHz 2.3 Vp_p 13 Receiving (SP) Dynamic DRsp 50 Speaker Output 0.8 Vp-p Range 14 DTHF Dynamic Range DRHFSP 20 2.5 Vp_p 15 DTHF Backtone Receiver BTHFSP 25 Vi n = 120mVp-p 40 60 80 roVp-p - 16 Speaker 50 400 500 600 mVp-p 17 Line Hatching Impedance ZINSP 20,80 270 700 Q 18 Speaker AIliP. Gain Gsp 30 5 8.5 12 dB {!)HITACHI 1181 (melody mode) HO Item pymboJ Test Conditions Spec. Unit IL rnA min. typo max. 1 Supply Voltage VLlID 20 3.7 4.2 4.7 V t-- 2 80 6 9 V 3 Helody IC Vo J tage Vou 20 1.2 1.5 1.8 V t-- 4 Supply Current lou 20 200 JIA 5 Melody Sending Gain GilD 30 f = 1kllz 23 25 27 dB t-- 6 80 20 22 24 dB 7 Helody Sending Dynalllic DRuo 30 f=lkllz 2.2 Vp-p Range 8 Helody Back Receiver BTuo 30 f = 1kllz 30 60 90 IIIVp-p '-- 9 tone Speaker 30 Vin=70mVp_p 350 450 550 mVp-p (tone ringer) HO ltell Symbol Test Conditions Spec. Un i t min. typo max. 1 Supply Initiation Voltage VIII 17 19 21 V 2 Supply Ini tiation Current Iru 0.7 1.5 3.0 lOA 3 Sustaining Voltage Vsus 9 11 V 4 Sustaining Current Isus Vin=15V 0.5 1.0 2.0 lOA 5 Output "II" Voltage Val! Vin=24V, lou=-lOIllA 20.0 21. 5 22.5 V 6 Output "L" Voltage VOL Vin=24V, IOL=lOmA 0.7 1.0 2.0 V 7 Output Frequency fL RI =165kQ, CI =0.47J1F 9 10 11 liz t-- 8 fHI R2 =190kQ, C2 = 6800pF 460 510 565 liz t-- 9 fll2 Vin=24V 575 640 705 liz ~HITACHI 1182 II Test Ci rcu it (TOP VIEW) (S2)O~---~OX C3 1\0 1 42 n 0 C4 I CO* I----- 2 "4te- C 0 I-- 3 - 40 C26 o 0-- I-- 4 -39 i-- ~ C2 E 0- I-- I-- 5 I-- 30 f-- 1}J.6 :8 wv ~1 6 37 F U I ~-7 I-- 36 R15 f-- C24 G 8 3s SI2 1 :fn2 c-9 "- 34 I len \14 c2: R3 - 10 IIA16808NT -33 "'-" u - -32 ~~1 II "'-" 11 I -12 -31 R4 - 13 -30 -0 T J I-- I-- C20. K 6 14 29 ~(S11 l- 15 f-- 20 C19 , ... 1<1- fl7 I-- -27 ClB R13 i-- f16 L 0 17 -- -26 .() 5 M ca' - - fCl ~ ~ N ~~ , ~16 rR2 C10 ~ ~ RIO 1" R o ~t!--l 20 I-- ~ R9 CFf41 p15 '-" I 21 22 C12 ~ =:=C lJ ~ 0 o p '-" ''R8 Unit: ..... R W) C7 C (F) f-Ho. C Value ~Ho. C Value No. C Value ",No. C Value rNo. C Value ",No. C Value 0 1000P 1 0~4711 2 6800p 3 2211 4 2211 5 0.01511 6 0.03311 7 3.311 8 2.211 9 0.4711 10 2.211 11 0.4711 12 0.04711 13 0.04711 14 2.211 15 O.h 16 III 17 lp 18 10011 19 3.311 20 33011 21 2.211 22 hi 23 2200p 24 1011 25 0.4711 26 0.06811 ~Ho. R Value {No. R Value ~No. R Value "No. R Value I\No. R Value ~Ho. R Value" 1 165K 2 190K 3 13K 4 13K 5 13K 6 2.4K 7 12K 8 110 9 10 10 10 11 180 12 51K 13 8 14 510K 15 10 16 30 17 560K ~HITACHI 1183 I .. Pin Description Pin SYlllbol Fund i on Fund i on I SYlllbol Pin No. No. 1 HIC 1 Hic. Input 1I00k Sill itch liS 42 2 HIC 2 AGC AGC 41 3 GND Tone Ringer Voice SW Gain Adjustlllent VS3 40 4 OUTPUT (Noise Suppression) 5 Vee Decide the Suppression VS4 39- 6 LOH FREQ. Level (Speaker Receive) 7 TIHE On at Speaker Mode SP SH 38 CONSTANT Detect the Line Current ILDET 37 8 HIGH FREQ. Bridge part I BRGI 36 9 TIHE Bridge part 2 BRG2 35 CONSTANT Loss Pad on Speaker mode ALC 34 10 RSL Variable Vsp Voltage Vsp ALT 33 11 MUTE DTMF Hode (~1. 6V) Regulating Capacitor BIPS 32 12 HOLD On at Melody Hode Speaker AIlIP. GND GND 2 31 Line L1 30 13 RB Decide IC Bias Current Speaker Part Regulator Vsp 29 14 GRCT Adjust Receiving Gain Compensating Capacitor COMPI 28 15 BRG3 Receiving Signal Input Speaker AIlIP. Output SP OUT 27 16 BRG4 one part of the bridge) Speaker AIlIP. Input SP IN 26 17 MEL Melody Input Buffer AIlIP. Output BUFF OUT 25 18 VREF2 Melody IC Supply Buffer AIlIP. Input BUFF IN 24 Vol tage Receiver Output REC1 23 19 DTMF DTMF Input REC2 22 20 VREF1 DTMF IC Supply Voltage Line (GND) L2 21 ~HITACHI 1184 .. Connection Arrangement and Application Circuit liS IIGe Cex19 o .OG8u o-------~~I- - - - - - - j """17 5GOK 0.G8fl VS4 -~0.47,? SPSW SW2(SP) ILDET Rex16 30 DRIDGE1 Red5 10 BRIDGE2 IILC VSP liLT DIPS GND2 L1 L1 VSP COHP SP OUT L2 SP IN DUFF ou'r !lUFF IN RECl REC2 Ce.~5 Ilex8 Ce.~6-l • 3,3p 110 0.047p nop VIEW) Nole) @ Pin must be separaled with other GNDs and be connected to LZ directly, Unit (H (Q») C (F) External Components are only for reference, ~HITACHI 1185 I SENDING GAIN VS. LINE CURRENT 55 50 ~ ---- ~~ co -u I- <..:> .-c al 45 <..:> b:> r::: -u r::: <11 U') 40 o 20 40 60 80 100 Line Current Il (mA) RECEIVING GAIN VS. LINE CURRENT o ---- co -u -5 l- ~ ~, t..:> .-r::: al <..:> -10 b:> ~ r::: '-> Q) <> Q) 0::: -15 o 20 40 60 80 100 ~HITACHI 1186 DTMF SUPPLY VOLTAGE VS. LINE CURRENT 40 DTHF Oper tion ::> Q 30 Q ::> Q) b> .... cd 0 20 ::> Stand-by ->. 0. 0. '" V) 10 t.L. ::E: l- <=> 0 20 40 60 80 100 Line Current IL (mA) DTMF SUPPLY CURRENT VS. LINE CURRENT 4 .-.. <: s Q 0 3 +' c: Q) J.. DT ~F Opera t i on J.. w'" 2 -c. >. 0. '" V) t.L. ::z:: 1 l- <=> Stand-by 0 20 40 60 80 100 Line Current IL (rnA) ~HITACHI - - - - ---~------- - 1187 I MELODY IC SUPPLY VOLTAGE VS. LINE CURRENT 2.0 r - - - - - - r - - - - - , - - - - , - - - , - - - - - - - , ...--. :> ::r:: Q :> .... 1.5 d Q) J-, J-, ::< u -a.a. >. 1.0 ::< tI) u >. ""0 0 0.5 Q) x: o 20 40 60 80 100 IL (mA) Line Current MELODY Ie SUPPLY CURRENT VS. LINE CURRENT 1. 0 ,...--------.-----,-----,------r----, ....... -< e 0.75 1-----+----+-----+----1------1 .... d Q) '"' J-, ::< U >. 0.5 i - - - - - t - - - - t - - - - - t - - - - + - - - - - - ; a. a. ::< tI) u >. 0.25 I - - - - I - - - - - - l f - - - - - - - l - - - - - t - - - - - \ ""0 o Q) x: o 20 40 60 80 100 Line Current IL (mA) eHITACHI 1188 DTMF GAIN VS. LINE CURRENT 30 ---------- 25 ....... Q:I "U Is. ::c u 20 .-c 01 U u.. ::z:: fo- e 15 o 20 40 60 80 100 Line Current IL (.A) DTMF GAIN{ON-HOOK DIAL MODE) VS. LINE CURRENT 30 ....... Q) -0 ,......, 0"'" ::z::"U ......, 25 -;"'- ._ VI els. ~u 0 0 ..c:: ::c 20 ---r-----r-- I c 0 .-c 01 t.:I 15 u.. ::z:: f0- e o 20 40 60 80 100 Line Current IL (mA) ~HITACHI 1189 II MELODY GAIN VS. LINE CURRENT 30 ........ /Xl -0 ""::r; L:> 25 -- ~ ---- .-C 20 oj L:> >. -0 0 Q) ::t: 15 o 20 40 60 80 100 Line Current IL (mA) TONE RINGER SUPPLY VOLTAGE VS, SUPPLY CURRENT 2.0 <: VTII a 1.5 ~ Vl ...... ...., U - c Q) s... s... ::s >. 1.0 / Y'''/-- / Q, Q, ::s (I) 0,5 / o 10 20 30 Supply Voltage Vs (V) ~HITACHI 1190 Appendix III. Instruction Set of the HD6305 Family Meanings of Symbols and abbreviations in the instruction set are as follows. (1) Operation ( ) = Contents ~ = Data transfer direction + Addition Subtraction A AND V OR €) = Exclusive OR X = NOT (2) Register symbols in MCU/MPU A Accumulator A X Index register SP Stack pointer, 6 bits CCR Condition code register (3) Contents of bits 0 through 4 of condition code register C Carry - borrow bit 0 Z Zero bit 1 N Negative bit 2 I Interrupt mask bit 3 H Half carry from bit 3 to bit 4 bit 4 (4) Memory and addressing codes M Stored address M+l Stored address M plus 1 IMP Implied addressing Rel Relative addressing A Accumulator addressing X Index register addressing IMM Immediate addressing DIR Direct addressing EXT Extended addressing ,XO Indexed addressing 0 byte offset ,Xl Indexed addressing 1 byte offset ,X2 Indexed addressing 2 byte offset ~HITACHI 1191 I (5) Status of each bit before execution of instruction Mn Bit n of M (n=7, 6, 5, ... , 0) (6) Symbols in instruction format A Accumulator addressing mode X Index register addressing mode n Bit n of memory (n=7, 6, 5, ... , 0) (7) Status of interrupt pin Status of interrupt pin (high, low) Register/Memory Instructions Address>n, Modes I I Indexed Ii Indexed i: Immediate I Direct !Ii Extended !i' (NoIndexed Boolean/ Condition Qoerations 'tnemonic I Arithmetic Code , Offset) [ (8-Bit Offset) i(16·&t Offsetli Operation 1 iopi • i-loP' • 1 - lOP! • I - :OPI • I -IOPI • I - !OPI • I =l IHIIINlzic Load A from Memory , LOA IASL 2 I 2 B612131C613 i 4 ,F61 1 13 IE61 2 141061 3 5 I M--A ' • i·! (\ AI· Load X from Memory Store A In Memory LOX STA ,AE! 2 ! 2 ,6E I 2 I 3 ICE i 3 I 4 ,FE, 1 I 3 1EE! 2 I - 1 - 'B7[ 2 [ 3 !c71 3 I 4 I F71 1 I 4 I E71 2 I 4 IDE I 3 4 1071 3 5 5 M-X A-M ,• !• I , i.l·i A • A A · Store X In Memory Add Memory to A I , STX ADD 1 -li- BF I 2 I 3 iCF! 3 I 4 iFF' 1 I 4 1EF! 2 IABI 2 I 2 BB! 2 I 3 ICBI 3 I 4 I FB I ' ! 3 I EB! 2 4 ~DFL 3 4 !OBI 3 5 5 X-M A+M ..... A i .j • LA' A I AI • I , A -, · Add Memory and Carry to A 1 I I AOC 1 jA9 Il I I I ' I ' ! I ! I iii 2 ii 2 B9, 2 i 3 IC91 3 4 IF91 t L3 JE9 2 4J0913! 5 i A+M+C-A : AO I 2 ! 2 ,BO I 2 I 3 I CO 1 3 I 4 I FO! t I 3 IEO I 2 I 4 'DO 1 3 5 ! A-M_A ! I I, I I·, _, I , , A ! Subtract Memory ,I SUB l·i· 11I Subtract Memory from A wnh Borrow I SBC Ii I,A2 2:I 2 iIB21213 I I IC213, til i I I I ! 1 I : 4 IF21t 3 E21 2 1410213 51 A-M-C_A I.I.IA A A , I 4 104! 3 : • I _ ! ,~, -, , • AND Memory to A AND 1A41 2 1 2 I B41 2 1 3 I C41 3 i 4 1F41 t 1 3 ,E41 2 5: M M-A OR Memory with A Exclusive OR Memory with A ! ORA EOR 'AAI 2 I 2 IBAI 2 : 3 :cAI 3 I 4 IFA! t 13 lEAl 2 , 1 1 , I , 1 , I 1 I I I, I , , I ' , , 1 I , :A812121B81213 .CB13141F81t 13 iEBI2 4 i0813 4 10AI 3 15 I AVM-A , I .I 5 iA(-jjM_A i-!_IA , , · Arithmetic Compare A 1 , , ,I i f I with Memory CMP :Al i 2 ! 2 ~S1: 2 : 3 iCl13 i 4 IFII Arithmetic Compare X I with Memory CPX , A3 i 2 : 2 'B31 2 : Bit rest Memory with I i I I : : : i I : I 'i I I ! " I i ~ ! I A (Logical Compar., BIT i AS! 2 I 2 'B5 I 2 1 3 1c51 3 I 4 ; F5' 1 ; 3 E5 i 2 ' 4 1051 3 IS! A"M Jump Unconditional JMP 'SCI 2 I 2 icci 3 : 3 !Fe! 1 ! 2 lEe! 2 I 3 !DC! 3 j 4 I Jump 10 Subroutine JSR '8012 ! 5 !col 3 : 6 :r:O! 1 IS :eol 2 ! 5 roo! 3 16 i Syrnbo Is: Op = Operation # .. ~umber u f hytes - '" Number of eye les ~HITACHI 1192 Read/Modify/Write Instructions Addrt:!ssin~ ~odes Indexed i Indeked i C,mdition Boo l~an I Ari thmet ic Cude Operations ~lnemon ic Imph.dlAI Iml)hedIX}! DIrect INo OffsetlI IS·e.l Ottset:11 Oper.ltLon 1 Increment i INC OPi :s I - OPI .. - i - - OPi :% i - ,OPI .. I - IOPi :1 I - : i4Ci 1 I 2 .5Ci 112'3Ci21517C; 1 : 5 leC: 2 i 6 i A + 1 -A or X + 1 -X or M + 1 -M I - • i :\ I -. ! • , DEC 14AI 1 I 2 iSAI 1 2 13.0.1 2 : S i 7AI , is 16AI 2! 6: 04,-1-04, or X-l-X or M-l_M 1-1- ,... I, " 1 • Decrement , , CI • ., 1 ClR i 4F \ 1 I 2 i SF i 1 I 2 13F i 2 ! 5 i 7F I 1 I 5 16F I 2 I 6 I DO-A or DO-X or DO-M 1 0 ! 1 : • _Ie ( Complement I COM ,43 1 I 2 1531 1 i 2 \331 2 i 5 173, 1 , 5 63! 2] 6 1 A __ A or x-x or M-M i • I • j ! "'. \ ' A, Negete I i, I ' I I 1 I iii ! I I ! I DO-A-A 0< DO-X-X I I (2', Com~m.nt) I NEG I 1401 1 2 1501, 2 130 I 2is: i 70 I 1 5 601 2 I 6 lor DO-M-M ~ • "- "I A Rotate Left Thru Cerrv ROl 49 1 2 i 59! I 12 391 2 I 51791, i I I 5 69 2 6 lb-i I I I I I ('~ b• AOI'i orll (, - r, ,\ "- i 2 5 76 1 5 66 2 6 L-@_(I 1-1+':"1 1. ~ - - Rotate RIght Thru Carry ROR 46 1 2 2 36 " 56 " "- 1' 2!581' 2 381 2 5 78 1 5 68 6 I . 2 D-l I ~~:'H I 1 1- 0 I"- " I Loglca' Shift Left lSl 48 1 I ' . A C b. -- 0 , -- b. C Logical Shift Right I lSR 44 1 2H I i1 2134:! 2 51 74 1 ' I 64 21 6 0-1 I I·H~:"I I 1-0 5 ,A I . Arithmetic Shift Right Arithmetic Shift Left I ASR ASl 47 1 2 7 1 5 12H 2 1 I 5 671 2 6 46 1 2 ,581 1 I 2i 38' 2 I 5 I 78! 1 I 5 1661 2I 6 +T I H'~~:"I I ~ - • " " I-t-IA [(b. EQual to LSl C A " A I i I 1-!.I,IJ- Test for Negative I Iii l i : I or Zero I TST ;4011 2!501 1 2:3D i 2 I4 : 7D i 1 14 i601 2I 5 , i A-OO or X-OO or 1104-00 Symbo is: Op = Operation Ii "" Number of bytes ~, .. Number of eye les Branch Instructions Addressing Modes , I Condition Code Operat.ions Mnemonic RelatIve I Branch Tes t ~ '.• I OP i :: ! - ! H' I ' N 1 Z: C Branch Always t BRA 20 i 2 I 3 None , i·i·l~ Branch Never : BRN 21 I 2 :! 3 22 I 2 ! None I • 1·1·1.1. Branch IF Higher i1 BHI 3 :CVZ=O , I • j .1 • I • I·I.!.:. • !.I.:.,. .. Branch IF lower Dr Same i BlS 23 i 2 , 3 'CVZ=1 I • .,.;., I Branch IF Carry Clear BeC 24 i 2 3 iC=O (Branch IF Higher or Same) (BHS) 24 i 2 3 ,c=o Branch IF Carry Set i BCS 25 2 3 C=l • ~---:;-r;- I I , , (Branch IF lower) (BlO) 25 , 2 3 ·C=l • •,•I•I• I I • • •I• • '. Branch IF Not Equal BNE 26 2 I 3 'Z=O I Branch IF Equal BEQ 27 I 2 : , 3 'Z=l • • • • Branch IF Half Carry Clear BHCC 2B 2 3 H=O ---~~-"~~ , , • • • • • • .' .' • • Branch IF Half Carry Set BHCS 29 2 3 H=l Branch IF Plus BPl 2A 2 3 N=O 1-":-- Branch IF Minus BMI 2B 2 3 N=l • • • • • • • .,. • Branch IF Interrupt Mask i Bit IS Clear BMC 2C I 2 3 1=0 Branch IF Interrupt Mask BIt IS Set BMS 20 2 3 1=1 • • • •• Branch IF Interrupt Line IS Low Bil 2E 2 3 INT=O • • • • • Branch If Interrupt LIne is High BIH 2F 2 3 INT=l • • • •• Branch to Subroutine BSR AD , 2 5 • • • • • Symbols: , Op "" Operat ion = !'lumber of ~vt:es = Number ot eye l~s ~HITACHI 1193 Bit Manipulation Instructions Addressing ~odes , Boo lean I Operations I Mnemonic Bit Set!Clear : BIt Test and Branch Ad thmetic Branch Test i I Condition Code I OP 1= , - , OP 1=1- Operation H I I IN! Z , C • .: • , • I r, I -i-; 2:n , 31 5 - . .' ..,., . Branch IF Bit n is set BRSET n(r._0· .. 7) - Mn_l • ! • I Branch IF Bit n is clear BRClR n(n=0···7) - - - ; 01 +2·n I 31 5 - Mn=O I ·i Set Bit n BSET n(n=0···7) 10+2·n 2 5! - 1-1- l-Mn - -; ., , . \ • ,, Clear Bit n BClR n(n=0.. ·7) : 11+2·n 2 5l - 1-1- O-Mn I - ' -: Symbols: Op - Operation # '" Number oi bytes '\. • Number of cycles Control Instructions I Addressing }lodeli , Cond icion Code .i.•• •• .,.,. Operations Mnemonic Implied Boolean Operacion - L .,.,. OP # H I N ZlC Transfer A to X TAX 97 1 2 iA-X Transfer X to A TXA 9F 1 2 I X-A , Set Carry Bit SEC 99 1 1 11-C .1.,1 • • ., • • .,. Clear Carry Bit ClC 9B 1 1 ,O-C ."·0 • • .,. Set Interrupt Mask Bit SEI 9B 1 ! 1-1 2 1 -I· Clear Interrupt Mask Bit ! CLI 9A 1 , ! 0-1 2 0 Software Interrupt SWI I 83 1 10 I • • 1 5 ! .,. • • • ·1· Return from Subroutine RTS 81 1 -Return - from Interrupt RTI 80 1 ! 8 ! ? ? ? ?! ? Reset Stack Pointer I RSP 9C 1 2 , $FF-SP • • • No-Operation Decimal Adjust A NOP OAA , 90 80 1 ! 1 i Advance Prog. Cntr. Only 1 I 2 Ii Converts bmarv add of BCD eharete,. Into BCD format ., .,. • • • -1- • " " , ,,* ·i·'·: I I .1 .1 .' I Stop STOP. i 8E 1 I 4 Wait I WAIT 1 8F 1 4 : .1 • Symbols: 00 = Op~r.:lti.)n :I • Xumbl:!c or' bytes ~ '" .sumbl!r di L:yclcs * Are SCD L:h.tr:u.::t~rs ,)[ upper hycc to "r :':'lOre! (Tht!y ..lC~ not ,.;It:!ar~d if ~~t: in .ldvance.) ~HITACHI 1194 Operation Code Map Bit Manipulation Branch Control ! I Test & Set. I I Branch Clear Rei : DIR A ! X ! .Xl o 2 ,3 4 : S 6 7 0' BRSETO BSETO BRA NEG IRW: - ! BRCLRO BCLRO BRN i 'RTS'!, - I 2' BRSETl BSETl i BHI - I - 1 -J SBC I 2 ! 3, BRCLRl BCLRl BLS COM ,SWI'I - I CPX 31 L BRSET2 I - o 4; BSET2 i BCC i LSR - I I AND -~ W S' BRCLR2 ! BCLR2 ! BCS I - I - , - I BIT S I I I 61 BRSET3 i BSET3 I BNE I ROR ! - i -J LOA 61 l7 i BRCLR3 ! BCLR3 I BEQ ASR , ,- ITAX': - I STA I STA(+1J! 7 I I 8 ! BRSET4 BSET4 1 BHCC i LSLlASL i - l CLC I EOR 81 , 9 ; BRCLR4 I BCLR4 I BHCS I ROL , - I SEC I ADC 9 I A I BRSETS I BSETS ! BPL I DEC - I CU'I ORA A , ! B I BRCLRS ! BCLRS i BMI i - - I SEI'I ADD 8 I C I BRSET6 I BSET6 I BMC ! INC I I - !RSP'I -! JMP(-l) , C I 101 BRCLR6 I BCLR6 ! BMS ,TSTI-1I1 TST i TST(-l) IDAA'I NOPIBSR'I JSR(+2) I JSR(+l) !JSAI+21ID ~ E ' BRSET7 BSET7 i BIL - 'STOP', - I LOX I E F : BRCLR7 BCLR7 ! BIH CLR WAIT" I TXA'1 - ! STX ISTXI+1Ji F I 3/S 2.'S i 2/3 2/S i 1 2 I 112 I 2/6 IllS I 1,' : 1,1 1 2/2 ! 2/3 ! 3/4 ! 31S I 2/4 I 1/3 (NOTES) 1_ "_" is an undefined operation code, 2, Lowermost numbers in each column represent a byte count and the number of cycles required (byte count/number of cycles). Number of cycles for asterisked (,~) mnemonics is as follows: RTl 8 TAX 2 RTS 5 RSP 2 SWI 10 TXA 2 DAA 2 BSR 5 STOP 4 WAIT 4 3. Parenthesized numbers must be added to the cycle count of the particular instruction_ ~HITACHI 1195 NOTES 1196 NOTES 1197 NOTES 1198' NOTES 1199 HITACHI AMERICA, LTD. SEMICONDUCTOR AND IC DIVISION u.s. SALES OFFICE Hitachi America, Ltd. Semiconductor and IC Division 2210 O'Toole Avenue San Jose, CA 95131 Tel: 408-435-8300 Telex: 17-1581 Twx: 910-338-2103 Fax: 408-435-2748 Fax: 408-435-2749 Fax: 408-435-2782 REGIONAL OFFICES DISTRICT OFFICES MID-ATLANTIC REGION • Hitachi America, Ltd. 3800 W. 80th Street, Suite 1050 Hitachi America, Ltd. Bloomington, MN 55431 1700 Galloping Hill Rd. 612/896-3444 Kenilworth, NJ 07033 201/245-6400 • Hitachi America, Ltd. NORTHEAST REGION 80 Washington St., Suite 302 Hitachi America, Ltd. Poughkeepsie, NY 12601 5 Burlington Woods Drive 914/485-3400 Burlington, MA 01803 617/229-2150 • Hitachi America, Ltd. SOUTH CENTRAL REGION 6 Parklane Blvd., #558 Dearborn, MI48126 Hitachi America, Ltd. 313/271-4410 Two Lincoln Centre, Suite 865 5420 LBJ Freeway Dallas, TX 75240 • Hitachi America, Ltd. 214/991-4510 6161 Savoy Dr., Suite 850 Houston, TX 77036 NORTH CENTRAL REGION 713/974-0534 Hitachi America, Ltd. 500 Park Blvd., Suite 415 Itasca, IL 60143 • Hitachi (Canadian) Ltd. 312/773-4864 2625 Queensview Dr. Ottawa, Ontario, Canada K2A 3Y4 NORTHWEST REGION 613/596-2777 Hitachi America, Ltd. 2210 O'Toole Avenue • Hitachi America, Ltd. San Jose, CA 95131 401 Harrison Oaks Blvd., Suite #317 408/435-2200 Cary, NC 27513 919/481-3908 SOUTHWEST REGION Hitachi America, Ltd. 18300 Von Karman Avenue, Suite 730 Irvine, CA 92715 714/553-8500 SOUTHEAST REGION Hitachi America, Ltd. 4901 N.w. 17th Way, Suite 302 Fort Lauderdale, FL 33309 ~HITACHI 1200 305/491-6154