M38002M4 MITSUBISHI | Alldatasheet

Document overview

  • Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
  • PDF pages: 173

Technical content

ADVANCED AND EVER ADVANCING MITSUBISHI ELECTRIC MITSUBISHI 8-BIT SINGLE-CHIP MICROCOMPUTER

740 FAMILY / 38000 SERIES

User’s Manual

Notes regarding these materials These materials are intended as a reference to assist our customers in the selection of the Mitsubishi semiconductor product best suited to the customer’s application; they do not convey any license under any intellectual property rights, or any other rights, belonging to Mitsubishi Electric Corporation or a third party. Mitsubishi Electric Corporation assumes no responsibility for any damage, or infringement of any third-party’s rights, originating in the use of any product data, diagrams, charts or circuit application examples contained in these materials. All information contained in these materials, including product data, diagrams and charts, represent information on products at the time of publication of these materials, and are subject to change by Mitsubishi Electric Corporation without notice due to product improvements or other reasons. It is therefore recommended that customers contact Mitsubishi Electric Corporation or an authorized Mitsubishi Semiconductor product distributor for the latest product information before purchasing a product listed herein. Mitsubishi Electric Corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake. Please contact Mitsubishi Electric Corporation or an authorized Mitsubishi Semiconductor product distributor when considering the use of a product contained herein for any specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use. The prior written approval of Mitsubishi Electric Corporation is necessary to reprint or reproduce in whole or in part these materials. If these products or technologies are subject to the Japanese export control restrictions, they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination. Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the country of destination is prohibited. Please contact Mitsubishi Electric Corporation or an authorized Mitsubishi Semiconductor product distributor for further details on these materials or the products contained therein. Keep safety first in your circuit designs! Mitsubishi Electric Corporation puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur with them. Trouble with semiconductors may lead to personal injury, fire or property damage. Remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of non-flammable material or (iii) prevention against any malfunction or mishap.

This user’s manual describes Mitsubishi’s CMOS 8- bit microcomputers 3800 Group. After reading this manual, the user should have a through knowledge of the functions and features of the 3800 Group, and should be able to fully utilize the product. The manual starts with specifications and ends with application examples. For details of software, refer to the “SERIES MELPS 740 <SOFTWARE> USER’S MANUAL.” For details of development support tools, refer to the “DEVELOPMENT SUPPORT TOOLS FOR MICRO- COMPUTERS” data book.

BEFORE USING THIS USER’S MANUAL This user’s manual consists of the following three chapters. Refer to the chapter appropriate to your conditions, such as hardware design or software development. Chapter 3 also includes necessary information for systems development. Be sure to refer to this chapter. 1. Organization l CHAPTER 1 HARDWARE This chapter describes features of the microcomputer and operation of each peripheral function. l CHAPTER 2 APPLICATION This chapter describes usage and application examples of peripheral functions, based mainly on setting examples of related registers. l CHAPTER 3 APPENDIX This chapter includes necessary information for systems development using the microcomputer, electric characteristics, a list of registers, the masking confirmation (mask ROM version), and mark specifications which are to be submitted when ordering. 2. Structure of register The figure of each register structure describes its functions, contents at reset, and attributes as follows : Note 2. Bit attributes••••••The attributes of control register bits are classified into 3 bytes : read-only, write-only and read and write. In the figure, these attributes are represented as follows : : Bit in which nothing is arranged 0 1 : Name Function At resetRWB 0 5 b0b1b2b3b4b5b6b7 Contents immediately after reset release Bit attributes (Note 1) Processor mode bits Stack page selection bit Nothing arranged for these bits. These are write disabled bits. When these bits are read out, the contents are “0.” Fix this bit to “0.” Main clock (XIN-XOUT ) stop bit Internal system clock selection bit 0 0 : Single-chip mode 1 0 :1 1 : Not available b1 b0 0 : 0 page1 : 1 page 0 : Operating 1 : Stopped 0 : XIN-XOUT selected 1 : XCIN-XCOUT selected : Bit that is not used for control of the corresponding function Note 1. Contents immediately after reset release Undefined••••••Undefined or reset release

  • •••••Contents determined by option at reset release[ (Note 2) CPU mode register (CPUM) [Address : 3B16] Bits

LIST OF GROUPS HA VING THE SIMILAR FUNCTIONS 3800 group, one of the CMOS 8-bit microcomputer 38000 series presented in this user’s manual is provided with standard functions. The basic functions of the 3800, 3802, 3806 and 3807 groups having the same functions are shown below. For the detailed functions of each group, refer to the related data book and user’s manual. List of groups having the same functions Notes 1: Extended operating temperature version available 2: High-speed version available 3: Extended operating temperature version and High-speed version available ] . ROM expansion Prescaler : 3 Timer : 4 <8-bit> Function Group Pin (Package type) Timer A-D converter D-A converter Clock generating circuit Serial I/O Remarks One Time PROM EPROM RAM Mask ROM Memory type ]24K 512 384 32K8K 16K 32K 16K (Note 1) (Note 1) 16K (Note 1) 32K (Note 1) 384 384 640 (Note 1) 24K 384 384 640 16K (Note 1) 32K (Note 1) 32K (Note 1) 32K 1024 PWM output 512 16K 16K 16K 3800 group 64 pin

  • 64P4B
  • 64P6N-A
  • 64P6D-A 1 circuit Prescaler : 3 Timer : 4 <8-bit> UART or Clock synchronous 5 1 3802 group 64 pin
  • 64P4B
  • 64P6N-A 8-bit 5 8-channel 8-bit 5 2-channel UART or Clock synchronous 5 1 Clock synchronous 5 1 1 circuit 1 circuit Prescaler : 3 Timer : 4 <8-bit> UART or Clock synchronous 5 1 Clock synchronous 5 1 3806 group 3807 group 80 pin
  • 80P6N-A 2 circuit 8-bit 5 13-channel 8-bit 5 4-channel UART or Clock synchronous 5 1 Clock synchronous 5 1 Timer : 3 <8-bit> Timer X/Y : 2 Timer A/B : 2 <16-bit> 80 pin
  • 80P6N-A
  • 80P6S-A
  • 80P6D-A 12K (Note 1) 16K (Note 1) 24K (Note 3) 24K 32K (Note 3) 48K (Note 3) 1024512384 384 1024 24K (Note 2) 48K (Note 3) 8-bit 5 8-channel 8-bit 5 2-channel As of September 1995 Real time port output Analog comparator Watchdog timer 48K (Note 2) — —

i Table of contents

3800 GROUP USER'S MANUAL

CHAPTER 1. HARDWARE

ii 3800 GROUP USER'S MANUAL Table of contents CHAPTER 2. APPLICATION CHAPTER 3. APPENDIX

3.1.8 Timing requirements and Switching characteristics

3800 GROUP USER’S MANUAL i

ii 3800 GROUP USER’S MANUAL List of figures Fig. 2.3.13 Connection diagram [Communication using a clock synchronous serial I/O] 2-31 Fig. 2.3.15 Setting of related registers at a transmitting side Fig. 2.3.16 Setting of related registers at a receiving side Fig. 2.3.17 Control procedure at a transmitting side Fig. 2.3.18 Control procedure at a receiving side[Communication using a clock synchronous serial I/O]. 2-35 Fig. 2.3.24 Connection diagram [Cyclic transmission or reception of block data between microcomputers]2-39 Fig. 2.3.25 Fig. 2.3.26 Setting of related registers [Cyclic transmission or reception of block data between microcomputers] .2-40

3800 GROUP USER’S MANUAL iii

iv 3800 GROUP USER’S MANUAL List of figures CHAPTER 3 APPENDIX Fig. 3.1.3 Timing diagram (in memory expansion mode and microprocessor mode) (1) 3-13 Fig. 3.1.4 Timing diagram (in memory expansion mode and microprocessor mode) (2) 3-14 Fig. 3.2.3 Standard characteristic example of CMOS output port at P-channel drive(1). 3-16 Fig. 3.2.4 Standard characteristic example of CMOS output port at P-channel drive(2). 3-16 Fig. 3.2.5 Standard characteristic example of CMOS output port at N-channel drive(1) 3-17 Fig. 3.2.6 Standard characteristic example of CMOS output port at N-channel drive(2) 3-17 Fig. 3.4.3 Wiring for the V

Table 3.1.17 Timing requirements in memory expansion mode and microprocessor mode Table 3.1.18 Switching characteristics in memory expansion mode and microprocessor mode

ii 3800 GROUP USER’S MANUAL List of tables

DESCRIPTION

FEATURES

APPLICATIONS

3800 GROUP USER’S MANUAL

DESCRIPTION/FEATURES/APPLICATIONS/PIN CONFIGURATION PIN CONFIGURATION (TOP VIEW) Fig. 1 Pin configuration of M38002M4-XXXFP/M38003M6-XXXHP Package type : 64P6N-A/64P6D-A 64-pin plastic-molded QFP The 3800 group is the 8-bit microcomputer based on the 740 fam- ily core technology. The 3800 group is designed for office automation equipment, household appliances and include four timers, serial I/O function. The various microcomputers in the 3800 group include variations of internal memory size and packaging. For details, refer to the section on part numbering. For details on availability of microcomputers in the 3800 group, re- fer to the section on group expansion. (at 8 MHz oscillation frequency)

  • Memory size (connect to external ceramic resonator or quartz-crystal oscillator) (Extended operating temperature version : 4.0 to 5.5 V)
  • Memory expansion possible (Extended operating temperature version : –40 to 85°C)

Office automation, factory automation, household appliances, and other consumer applications, etc. M38002M4-XXXFP M38003M6-XXXHP P33/RESET OUT P34/f P35/SYNC P37/RD P36/WR P32/ONW P64 P66 P67 P70 P71 VCC P30 P31 P63 P65 P62 P61 P60 P57 P56 P55/CNTR 1 P54/CNTR 0 P53/INT5 P52/INT4 P51/INT3 P50/INT2 P47/SRDY P46/SCLK P43/INT1 P44/RXD P45/TXD P24/DB4 P23/DB3 P22/DB2 P20/DB0 P21/DB1 P25/DB5 CNV SS P41 P40 XIN XOUT VSS P27/DB7 P26/DB6 P42/INT0 RESET P00/AD0 P01/AD1 P02/AD2 P03/AD3 P04/AD4 P05/AD5 P06/AD6 P07/AD7 P10/AD8 P11/AD9 P12/AD10 P13/AD11 P14/AD12 P17/AD15 P16/AD14 P15/AD13

1-33800 GROUP USER’S MANUAL PIN CONFIGURATION PIN CONFIGURA TION (TOP VIEW) Fig. 2 Pin configuration of M38002M4-XXXSP Package type : 64P4B 64-pin shrink plastic-molded DIP P64 P66 P67 P70 P71 VCC P63 P65 P62 P61 P60 P57 P56 P55/CNTR 1 P54/CNTR 0 P53/INT5 P52/INT4 P51/INT3 P50/INT2 P47/SRDY P46/SCLK P43/INT1 P44/RXD P45/TXD CNV SS P41 P40 XIN XOUT VSS P42/INT0 RESET P24/DB4 P23/DB3 P22/DB2 P20/DB0 P21/DB1 P25/DB5 P27/DB7 P26/DB6 P33/RESET OUT P34/f P35/SYNC P37/RD P36/WR P32/ONW P30 P31 P00/AD0 P01/AD1 P02/AD2 P03/AD3 P04/AD4 P05/AD5 P06/AD6 P07/AD7 P10/AD8 P11/AD9 P12/AD10 P13/AD11 P14/AD12 P17/AD15 P16/AD14 P15/AD13 M38002M4-XXXSP

Fig. 3 Functional block diagram FUNCTIONAL BLOCK DIAGRAM (Package : 64P4B) FUNCTIONAL BLOCK CNTR 1CNTR 0 INT2 to INT5 RAM ROM CPU A X Y S PC H PC L PS VSS RESET VCC 1 26 CNV SS P0(8) 49 50 51 52 53 54 55 56 P1(8) 41 43 45 4742 44 46 48 P2(8) 33 35 37 3934 36 38 40 P3(8) 57 59 61 6358 60 62 64 P4(8) 20 22 24 2821 23 25 29 P5(8) 12 14 16 1813 15 17 19 P7(2) P6(8) 4 6 1059 1 1 XIN XOUT Reset input Clock generating circuit Clock input Clock output Prescaler 12 (8) Timer 1 (8) Timer 2 (8) I/O port P4 I/O port P0 I/O port P1I/O port P2I/O port P3I/O port P5I/O port P7 I/O port P6 7 8 Serial I/O(8) INT0, INT1 Prescaler X (8) Timer X (8) Prescaler Y (8) Timer Y (8) CPU Data bus

  • 8-bit CMOS I/O port with the same function as port P0
  • CMOS compatible input level
  • CMOS 3-state output structure Pin V CC VSS CNV SS RESET XIN XOUT P00 – P07 P10 – P17 P20 – P27 P30 – P37 P40, P41 P42/INT0, P43/INT1 P44/RX D, P45/TX D, P46/SCLK , P47/SRDY P50/INT2 – P53/INT5 P54/CNTR 0, P55/CNTR 1 P56, P57 P60 – P67 P70, P71 Function
  • Apply voltage of 3.0 V to 5.5 V to VCC , and 0 V to VSS . (Extended operating temperature version : 4.0 V to 5.5 V)
  • This pin controls the operation mode of the chip.
  • Normally connected to VSS .
  • If this pin is connected to VCC , the internal ROM is inhibited and external memory is accessed.
  • Reset input pin for active “L ”
  • Input and output signals for the internal clock generating circuit.
  • Connect a ceramic resonator or quartz-crystal oscillator between the X IN and XOUT pins to set the oscillation frequency.
  • If an external clock is used, connect the clock source to the XIN pin and leave the XOUT pin open.
  • The clock is used as the oscillating source of system clock.
  • 8 bit CMOS I/O port
  • I/O direction register allows each pin to be individually programmed as either input or output.
  • At reset this port is set to input mode.
  • In modes other than single-chip, these pins are used as address, data, and control bus I/O pins.
  • CMOS compatible input level
  • CMOS 3-state output structure
  • 8-bit CMOS I/O port with the same function as port P0
  • CMOS compatible input level
  • CMOS 3-state output structure PIN DESCRIPTION

Table 1. Pin description

  • External interrupt input pins
  • Serial I/O I/O pins
  • External interrupt input pins
  • Timer X and Timer Y I/O pins
  • 8-bit CMOS I/O port with the same function as port P0
  • CMOS compatible input level
  • CMOS 3-state output structure
  • 2-bit CMOS I/O port with the same function as port P0
  • CMOS compatible input level
  • CMOS 3-state output structure

Fig. 4 Part numbering PAR T NUMBERING M3800 2 M 4 - XXX SPProduct Package type SP : 64P4B package FP : 64P6N-A package HP : 64P6D-A package SS : 64S1B package FS : 64D0 package ROM number Omitted in some types. ROM/PROM size : 4096 bytes : 8192 bytes : 12288 bytes : 16384 bytes : 20480 bytes : 24576 bytes : 28672 bytes : 32768 bytes The first 128 bytes and the last 2 bytes of ROM are reserved areas ; they cannot be used. Memory type M E S : Mask ROM version : EPROM or One Time PROM version : External ROM RAM size : 192 bytes : 256 bytes : 384 bytes : 512 bytes : 640 bytes : 768 bytes : 896 bytes : 1024 bytes Normally, using hyphen When electrical characteristic, or division of quality identification code using alphanumeric character – : standard D : Extended operating temperature version

1-73800 GROUP USER’S MANUAL GROUP EXPANSION GROUP EXPANSION Mitsubishi plans to expand the 3800 group as follows: (1) Support for mask ROM, One Time PROM, EPROM, and external ROM versions (2) Packages Memory Expansion Plan Fig. 5 Memory expansion plan M38002M2/E2 M38002M4/E4 M38003M6 M38002S M38007M8/E8 Mass product Being planned Mass product Mass product Mass product External ROM ROM size (bytes) 32K 28K 24K 20K 16K 12K 192 256 384 512 640 768 896 1024 RAM size (bytes) M38004M8/E8 Mass product Note : Products under development or planning: the development schedule and specifications may be revised without notice.

Currently supported products are listed below. Table 2. List of supported products As of September 1995

Currently supported products are listed below. Table 3. List of supported products (Extended operating temperature version)

Central Processing Unit (CPU) The 3800 group uses the standard 740 family instruction set. Re- fer to the table of 740 family addressing modes and machine in- structions or the SERIES 740 <Software> User’s Manual for de- tails on the instruction set. Machine-resident 740 family instructions are as follows: The FST and SLW instruction cannot be used. The STP , WIT, MUL, and DIV instruction can be used. The central processing unit (CPU) has the six registers. Accumulator (A) The accumulator is an 8-bit register. Data operations such as data transfer, etc., are executed mainly through the accumulator. Index register X (X), Index register Y (Y) Both index register X and index register Y are 8-bit registers. In the index addressing modes, the value of the OPERAND is added to the contents of register X or register Y and specifies the real ad- dress. When the T flag in the processor status register is set to “1”, the value contained in index register X becomes the address for the second OPERAND. Stack pointer (S) The stack pointer is an 8-bit register used during subroutine calls and interrupts. The stack is used to store the current address data and processor status when branching to subroutines or interrupt routines. The lower eight bits of the stack address are determined by the contents of the stack pointer. The upper eight bits of the stack ad- dress are determined by the Stack Page Selection Bit. If the Stack Page Selection Bit is “0”, then the RAM in the zero page is used as the stack area. If the Stack Page Selection Bit is “1”, then RAM in page 1 is used as the stack area. The Stack Page Selection Bit is located in the SFR area in the zero page. Note that the initial value of the Stack Page Selection Bit varies with each microcomputer type. Also some microcom- puter types have no Stack Page Selection Bit and the upper eight bits of the stack address are fixed. The operations of pushing register contents onto the stack and popping them from the stack are shown in Fig. 8. Program counter (PC) The program counter is a 16-bit counter consisting of two 8-bit registers PC H and PCL. It is used to indicate the address of the next instruction to be executed. Fig. 7 740 Family CPU register structure FUNCTIONAL DESCRIPTION X Y S PC L CNVTBD I Z A b15 b0b7 b0b7 b0b7 b0b7 Accumulator Index Register X Index Register Y Stack Pointer Program Counter Processor Status Register (PS) Carry Flag Zero Flag Interrupt Disable Flag Decimal Mode Flag Break Flag Index X Mode Flag Overflow Flag Negative Flag PC H

Table 4. Push and pop instructions of accumulator or processor status register to be executed is stored in the stack area.

(C) flag, Zero (Z) flag, Overflow (V) flag, or the Negative (N) flag. In decimal mode, the Z, V, N flags are not valid. initialized in the beginning of a program. tion. It can also be changed by a shift or rotate instruction. ated by the BRK instruction. Interrupts are disabled when the I flag is “1”. register is pushed onto the stack with the break flag set to “1”. stored in the negative flag. Table 5. Set and clear instructions of each bit of processor status register

1-133800 GROUP USER’S MANUAL CPU mode register The CPU mode register is allocated at address 003B16. The CPU mode register contains the stack page selection bit. Fig. 9 Structure of CPU mode register FUNCTIONAL DESCRIPTION CPU mode register (CPUM : address 003B16) b7 b0 Stack page selection bit 0 : 0 page 1 : 1 page Not used (return “0” when read) Processor mode bits b1 b0 0 0 : Single-chip mode 0 1 : Memory expansion mode 1 0 : Microprocessor mode 1 1 : Not available

Special function register (SFR) area The Special Function Register area in the zero page contains con- trol registers such as I/O ports and timers. RAM RAM is used for data storage and for stack area of subroutine calls and interrupts. ROM The first 128 bytes and the last 2 bytes of ROM are reserved for device testing and the rest is user area for storing programs. Interrupt vector area The interrupt vector area contains reset and interrupt vectors. Zero page The 256 bytes from addresses 000016 to 00FF16 are called the zero page area. The internal RAM and the special function regis- ters (SFR) are allocated to this area. The zero page addressing mode can be used to specify memory and register addresses in the zero page area. Access to this area with only 2 bytes is possible in the zero page addressing mode. Special page The 256 bytes from addresses FF0016 to FFFF16 are called the special page area. The special page addressing mode can be used to specify memory addresses in the special page area. Ac- cess to this area with only 2 bytes is possible in the special page addressing mode. Fig. 10 Memory map diagram FUNCTIONAL DESCRIPTION 010016 000016 004016 044016 FF0016 FFDC 16 FFFE 16 FFFF 16 192 256 384 512 640 768 896 1024 XXXX 00FF16 013F16 01BF 16 023F16 02BF 16 033F16 03BF 16 043F16 4096 8192 12288 16384 20480 24576 28672 32768 F000 E00016 D000 16 C000 16 B00016 A00016 900016 800016 F08016 E08016 D080 16 C080 16 B08016 A08016 908016 808016 YYYY 16 ZZZZ 16 RAM ROM Reserved area SFR area Not used Interrupt vector area ROM area Reserved ROM area (128 bytes) Zero page Special page RAM area RAM capacity (bytes) Address XXXX 16 ROM capacity (bytes) Address YYYY 16 Reserved ROM area Address ZZZZ 16

1-153800 GROUP USER’S MANUAL Fig. 11 Memory map of special function register (SFR) FUNCTIONAL DESCRIPTION 002016 002116 002216 002316 002416 002516 002616 002716 002816 002916 002A16 002B16 002C 16 002D 16 002E16 002F16 003016 003116 003216 003316 003416 003516 003616 003716 003816 003916 003A16 003B16 003C 16 003D 16 003E16 003F16 000016 000116 000216 000316 000416 000516 000616 000716 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 001016 001116 001216 001316 001416 001516 001616 001716 001816 001916 001A16 001B16 001C 16 001D 16 001E16 001F16 Port P0 (P0) Port P0 direction register (P0D) Port P1 (P1) Port P1 direction register (P1D) Port P2 (P2) Port P2 direction register (P2D) Port P3 (P3) Port P3 direction register (P3D) Port P4 (P4) Port P4 direction register (P4D) Port P5 (P5) Port P5 direction register (P5D) Port P6 (P6) Port P6 direction register (P6D) Port P7 (P7) Port P7 direction register (P7D) Transmit/Receive buffer register (TB/RB) Serial I/O status register (SIOSTS) Serial I/O control register (SIOCON) UART control register (UARTCON) Baud rate generator (BRG) Interrupt control register 2(ICON2) Prescaler Y (PREY) Timer Y (TY) Interrupt edge selection register (INTEDGE) CPU mode register (CPUM) Interrupt request register 1(IREQ1) Interrupt request register 2(IREQ2) Interrupt control register 1(ICON1) Prescaler 12 (PRE12) Timer 2 (T2) Prescaler X (PREX) Timer X (TX) Timer 1 (T1) Timer XY mode register (TM)

Table 6. List of I/O port functions tion I/O ports, refer to the applicable sections. 2: Make sure that the input level at each pin is either 0 V or VCC during execution of the STP instruction. When an input level is at an intermediate potential, a current will flow from VCC to VSS through the input-stage gate. which determine the input/output direction of each individual pin. can be set to be input port or output port. output latch is written to and the pin remains floating.

1-173800 GROUP USER’S MANUAL Fig. 12 Port block diagram (single-chip mode) FUNCTIONAL DESCRIPTION (1) Ports P0, P1, P2, P3, P40, P41, P56, P57, P6, P7 Direction register Data bus Port latch (2) Ports P42, P43, P50 – P53 Direction register Data bus Port latch Interrupt input (3) Port P44 Direction register Data bus Port latch Serial I/O input Serial I/O enable bit Receive enable bit (4) Port P45 Direction register Data bus Port latch Serial I/O output Serial I/O enable bit Transmit enable bit P45/TXD P-channel output disable bit (5) Port P46 Direction register Data bus Port latch Serial I/O clock output Serial I/O mode selection bit Serial I/O enable bit Serial I/O enable bit Serial I/O synchronous clock selection bit Serial I/O external clock input (6) Port P47 Direction register Data bus Port latch Serial I/O ready output Serial I/O enable bit SRDY output enable bit Serial I/O mode selection bit (7) Ports P54, P55 Direction register Data bus Port latch Pulse output mode Timer output Counter input Interrupt input

Interrupt enable bits can be set or cleared by software. table into the program counter. (1) Disable the external interrupt which is selected. (2) Change the active edge selection. (3) Clear the interrupt request bit which is selected to “0”. (4) Enable the external interrupt which is selected. Table 7. Interrupt vector addresses and priority Note 1: Vector addresses contain interrupt jump destination addresses. 2: Reset function in the same way as an interrupt with the highest priority.

1-193800 GROUP USER’S MANUAL Fig. 13 Interrupt control Fig. 14 Structure of interrupt-related registers FUNCTIONAL DESCRIPTION b7 b0 b7 b0 b7 b0 b7 b0 b7 b0 Interrupt edge selection register INT0 active edge selection bit INT1 active edge selection bit INT2 active edge selection bit INT3 active edge selection bit INT4 active edge selection bit INT5 active edge selection bit Not used (return “0” when read) (INTEDGE : address 003A16) Interrupt request register 1 INT0 interrupt request bit INT1 interrupt request bit Serial I/O receive interrupt request bit Serial I/O transmit interrupt request bit Timer X interrupt request bit Timer Y interrupt request bit Timer 1 interrupt request bit Timer 2 interrupt request bit Interrupt control register 1 INT0 interrupt enable bit INT1 interrupt enable bit Serial I/O receive interrupt enable bit Serial I/O transmit interrupt enable bit Timer X interrupt enable bit Timer Y interrupt enable bit Timer 1 interrupt enable bit Timer 2 interrupt enable bit (IREQ1 : address 003C 16) (ICON1 : address 003E16) Interrupt request register 2 CNTR 0 interrupt request bit CNTR 1 interrupt request bit INT2 interrupt request bit INT3 interrupt request bit INT4 interrupt request bit INT5 interrupt request bit Not used (return “0” when read) (IREQ2 : address 003D16) Interrupt control register 2 CNTR 0 interrupt enable bit CNTR 1 interrupt enable bit INT2 interrupt enable bit INT3 interrupt enable bit INT4 interrupt enable bit INT5 interrupt enable bit Not used (return “0” when read) (Do not write “1” to this bit) 0 : No interrupt request issued 1 : Interrupt request issued 0 : Interrupts disabled 1 : Interrupts enabled (ICON2 : address 003F16) 0 : Falling edge active 1 : Rising edge active Interrupt disable flag (I) Interrupt request Interrupt request bit Interrupt enable bit BRK instruction Reset

The 3800 group has four timers: timer X, timer Y, timer 1, and timer All timers are count down. When the timer reaches “0016”, an un- derflow occurs at the next count pulse and the corresponding timer latch is reloaded into the timer and the count is continued. When a timer underflows, the interrupt request bit corresponding to that timer is set to “1”. The division ratio of each timer or prescaler is given by 1/(n + 1), where n is the value in the corresponding timer or prescaler latch. Timer 1 and Timer 2 The count source of prescaler 12 is the oscillation frequency di- vided by 16. The output of prescaler 12 is counted by timer 1 and timer 2, and a timer underflow sets the interrupt request bit. Timer X and Timer Y Timer X and Timer Y can each be selected in one of four operating modes by setting the timer XY mode register. Timer Mode The timer counts f(XIN)/16 in timer mode. Pulse Output Mode Timer X (or timer Y) counts f(XIN)/16. Whene ver the contents of the timer reach “0016”, the signal output from the CNTR0 (or CNTR 1) pin is inverted. If the CNTR0 (or CNTR1) active edge switch bit is “0”, output begins at “ H”. If it is “1”, output starts at “L”. When using a timer in this mode, set the corresponding port P54 ( or port P55) direction register to out- put mode. Event Counter Mode Operation in event counter mode is the same as in timer mode, except the timer counts signals input through the CNTR0 or CNTR 1 pin. Pulse Width Measurement Mode If the CNTR0 (or CNTR1) active edge selection bit is “0”, the timer counts at the oscillation frequency divided by 16 while the CNTR 0 (or CNTR1) pin is at “H”. If the CNTR0 (or CNTR1) active edge switch bit is “1”, the count continues during the time that the CNTR 0 (or CNTR1) pin is at “L”. In all of these modes, the count can be stopped by setting the timer X (timer Y) count stop bit to “1”. Every time a timer underflows, the corresponding interrupt request bit is set. Fig. 15 Structure of timer XY register FUNCTIONAL DESCRIPTION Timer X count stop bit 0: Count start 1: Count stop Timer XY mode register (TM : address 002316) Timer Y operating mode bit 0 0: Timer mode 0 1: Pulse output mode 1 0: Event counter mode 1 1: Pulse width measurement mode CNTR 1 active edge switch bit 0: Interrupt at falling edge Count at rising edge in event counter mode 1: Interrupt at rising edge Count at falling edge in event counter mode CNTR 0 active edge switch bit 0: Interrupt at falling edge Count at rising edge in event counter mode 1: Interrupt at rising edge Count at falling edge in event counter mode Timer X operating mode bit 0 0: Timer mode 0 1: Pulse output mode 1 0: Event counter mode 1 1: Pulse width measurement mode b1b0 b5b4 Timer Y count stop bit 0: Count start 1: Count stop

1-213800 GROUP USER’S MANUAL Fig. 16 Block diagram of timer X, timer Y, timer 1, and timer 2 FUNCTIONAL DESCRIPTION Timer X latch (8) Timer X (8) Prescaler X latch (8) Prescaler X (8) Oscillator Divider f(XIN) 1/16 CNTR 0 active edge switch bit P54/CNTR 0 pin Port P54 direction register “0” “1” Eventcounter mode Timer X count stop bit CNTR 0 active edge switch bit Port P54 latch Pulse output mode Pulse width measurement mode Timer mode Pulse output mode “1” “0” Timer X latch write pulse Pulse output mode To timer X interrupt request bit To CNTR 0 interrupt request bit Data bus Timer Y latch (8) Timer Y (8) Prescaler Y latch (8) Prescaler Y (8) CNTR 1 active edge switch bit P55/CNTR 1 pin Port P55 direction register “0” “1” Eventcounter mode Timer Y count stop bit CNTR 1 active edge switch bit Port P5 latch Pulse output mode Pulse width measurement mode Timer mode Pulse output mode “1” “0” Timer Y latch write pulse Pulse output mode To timer Y interrupt request bit To CNTR 1 interrupt request bit Data bus Q Q R Toggle flip- flop T Q Q R Toggle flip- flop T Timer 2 latch (8) Timer 1 latch (8)Prescaler 12 latch (8) Prescaler 12 (8) Timer 2 (8)Timer 1 (8) Data bus To timer 2 interrupt request bit To timer 1 interrupt request bit

Serial I/O can be used as either clock synchronous or asynchro- nous (UAR T) serial I/O. A dedicated timer is also provided for baud rate generation. Clock synchronous serial I/O mode Clock synchronous serial I/O mode can be selected by setting the mode selection bit of the serial I/O control register to “1”. For clock synchronous serial I/O, the transmitter and the receiver must use the same clock. If an internal clock is used, transfer is started by a write signal to the TB/RB (address 0018 Fig. 17 Block diagram of clock synchronous serial I/O Fig. 18 Operation of clock synchronous serial I/O function FUNCTIONAL DESCRIPTION X IN F/F CLK1 Serial I/O status register Serial I/O control register RDY X D X D f(X IN Receive buffer Address 0018 Receive shift register Receive buffer full flag (RBF) Receive interrupt request (RI) Clock control circuit Shift clock Serial I/O synchronous clock selection bit Frequency division ratio 1/(n+1) Baud rate generator Address 001C BRG count source selection bit Clock control circuit Falling-edge detector Transmit buffer Data bus Address 0018 Shift clock Transmit shift completion flag (TSC) Transmit buffer empty flag (TBE) Transmit interrupt request (TI) Transmit interrupt source selection bit Address 0019 Data bus Address 001A Transmit shift register D D D D D D D D D D D D D D D D RBF = 1 TSC = 1 TBE = 0 TBE = 1 TSC = 0 Transfer shift clock (1/2 to 1/2048 of the internal clock, or an external clock) Serial output TxD Serial input RxD Write pulse to receive/transmit buffer (address 0018 Overrun error (OE) detection Notes 1 : The transmit interrupt (TI) can be selected to occur either when the transmit buffer has emptied (TBE=1) or after the transmit shift operation has ended (TSC=1), by setting the transmit interrupt source selection bit (TIC) of the serial I/O control register. 2 : If data is written to the transmit buffer when TSC=0, the transmit clock is generated continuously and serial data is output continuously from the TxD pin. 3 : The receive interrupt (RI) is set when the receive buffer full flag (RBF) becomes “1” . Receive enable signal S RDY HARDWARE

1-233800 GROUP USER’S MANUAL Asynchronous serial I/O (UART) mode Clock asynchronous serial I/O mode (UART) can be selected by clearing the serial I/O mode selection bit of the serial I/O control register to “0”. Eight serial data transfer formats can be selected, and the transfer formats used by a transmitter and receiver must be identical. The transmit and receive shift registers each have a buffer, but the two buffers have the same address in memory. Since the shift reg- ister cannot be written to or read from directly, transmit data is written to the transmit buffer, and receive data is read from the re- ceive buffer. The transmit buffer can also hold the next data to be transmitted, and the receive buffer can hold a character while the next charac- ter is being received. Fig. 19 Block diagram of UART serial I/O FUNCTIONAL DESCRIPTION f(XIN) OE PE FE Data bus Receive buffer Address 001816 Receive shift register Receive buffer full flag (RBF) Receive interrupt request (RI) Baud rate generator Frequency division ratio 1/(n+1) Address 001C16 ST/SP/PA generator Transmit buffer Data bus Transmit shift register Address 001816 Transmit shift completion flag (TSC) Transmit buffer empty flag (TBE) Transmit interrupt request (TI) Address 001916 STdetector SP detector UART control register Address 001B16 Character length selection bit Address 001A16 BRG count source selection bit Transmit interrupt source selection bit Serial I/O synchronous clock selection bit Clock control circuit Character length selection bit 7 bits 8 bits Serial I/O control register P46/SCLK Serial I/O status register P44/RXD P45/TXD

Fig. 20 Operation of UART serial I/O function Serial I/O control register (SIOCON) 001A16 The serial I/O control register consists of eight control bits for the serial I/O function. UART control register (UARTCON) 001B16 The UART control register consists of four control bits (bits 0 to 3) which are valid when asynchronous serial I/O is selected and set the data format of an data transfer. One bit in this register (bit 4) is always valid and sets the output structure of the P4 5/TX D pin. Serial I/O status register (SIOSTS) 001916 The read-only serial I/O status register consists of seven flags (bits 0 to 6) which indicate the operating status of the serial I/O function and various errors. Three of the flags (bits 4 to 6) are valid only in UART mode. The receive buffer full flag (bit 1) is cleared to “0” when the receive buffer is read. If there is an error, it is detected at the same time that data is transferred from the receive shift register to the receive buffer, and the receive buffer full flag is set. A write to the serial I/O status reg- ister clears all the error flags OE, PE, FE, and SE (bit 3 to bit 6, re- spectively). Writing “0” to the serial I/O enable bit SIOE (bit 7 of the Serial I/O Control Register) also clears all the status flags, in- cluding the error flags. All bits of the serial I/O status register are initialized to “0” at reset, but if the transmit enable bit (bit 4) of the serial I/O control register has been set to “1”, the transmit shift completion flag (bit 2) and the transmit buffer empty flag (bit 0) become “1”. Transmit buffer/Receive buffer register (TB/ RB) 001816 The transmit buffer and the receive buffer are located at the same address. The transmit buffer is write-only and the receive buffer is read-only. If a character bit length is 7 bits, the MSB of data stored in the receive buffer is “0”. Baud rate generator (BRG) 001C16 The baud rate generator determines the baud rate for serial trans- fer. The baud rate generator divides the frequency of the count source by 1/(n + 1), where n is the value written to the baud rate genera- tor. FUNCTIONAL DESCRIPTION TSC=0 TBE=1 RBF=0 TBE=0 TBE=0 RBF=1 RBF=1 STD 0 D 1 SP D 0 D 1ST SP TBE=1 TSC=1 STD 0 D 1 SP D 0 D 1ST SP Transmit or receive clock Transmit buffer write signal Generated at 2nd bit in 2-stop-bit mode 1 start bit 7 or 8 data bits 1 or 0 parity bit 1 or 2 stop bit (s) 1: Error flag detection occurs at the same time that the RBF flag becomes "1" (at 1st stop bit, during reception). 2: The transmit interrupt (TI) can be selected to occur when either the TBE or TSC flag becomes "1", depending on the setting of the transmit interrupt source selection bit (TIC) of the serial I/O control register. 3: The receive interrupt (RI) is set when the RBF flag becomes "1". 4: After data is written to the transmit buffer when TSC=1, 0.5 to 1.5 cycles of the data shift cycle is necessary until changing to TSC=0. Notes Serial output TXD Serial input RXD Receive buffer read signal

1-253800 GROUP USER’S MANUAL b7b7 Transmit buffer empty flag (TBE) 0: Buffer full 1: Buffer empty Receive buffer full flag (RBF) 0: Buffer empty 1: Buffer full Transmit shift completion flag (TSC) 0: Transmit shift in progress 1: Transmit shift completed Overrun error flag (OE) 0: No error 1: Overrun error Parity error flag (PE) 0: No error 1: Parity error Framing error flag (FE) 0: No error 1: Framing error Summing error flag (SE) 0: (OE) U (PE) U (FE)=0 1: (OE) U (PE) U (FE)=1 Not used (returns "1" when read) Serial I/O status register (SIOSTS : address 001916) Serial I/O control register (SIOCON : address 001A16) b0 b0 BRG count source selection bit (CSS) 0: f(XIN) 1: f(XIN)/4 Serial I/O synchronous clock selection bit (SCS) 0: BRG output divided by 4 when clock synchronous serial I/O is selected, BRG output divided by 16 when UART is selected. 1: External clock input when clock synchronous serial I/O is selected, external clock input divided by 16 when UART is selected. SRDY output enable bit (SRDY) 0: P47 pin operates as ordinaly I/O pin 1: P47 pin operates as SRDY output pin Transmit interrupt source selection bit (TIC) 0: Interrupt when transmit buffer has emptied 1: Interrupt when transmit shift operation is completed Transmit enable bit (TE) 0: Transmit disabled 1: Transmit enabled Receive enable bit (RE) 0: Receive disabled 1: Receive enabled Serial I/O mode selection bit (SIOM) 0: Clock asynchronous (UART) serial I/O 1: Clock synchronous serial I/O Serial I/O enable bit (SIOE) 0: Serial I/O disabled (pins P44 to P47 operate as ordinary I/O pins) 1: Serial I/O enabled (pins P44 to P47 operate as serial I/O pins) b7 UART control register (UARTCON : address 001B16) Character length selection bit (CHAS) 0: 8 bits 1: 7 bits Parity enable bit (PARE) 0: Parity checking disabled 1: Parity checking enabled Parity selection bit (PARS) 0: Even parity 1: Odd parity Stop bit length selection bit (STPS) 0: 1 stop bit 1: 2 stop bits P45/TXD P-channel output disable bit (POFF) 0: CMOS output (in output mode) 1: N-channel open drain output (in output mode) Not used (return "1" when read) Fig. 21 Structure of serial I/O control registers FUNCTIONAL DESCRIPTION

3.0V (Note 1) 0.6V (Note 2) Power source voltage Reset input voltage VCC RESET VSS M51953AL 3 0.1 m F 3800 group Note 1 : Extended operating temperature version : 4.0V Note 2 : Extended operating temperature version : 0.8V Reset Circuit To reset the microcomputer, the RESET pin should be held at an “L ” level for 2 µs or more. Then the RESET pin is returned to an “H” level (the power source voltage should be between 3.0 V and 5.5 V, and between 4.0 V and 5.5 V for extended operating tempera- ture version), reset is released. Internal operation does not begin until after 8 to 13 X IN clock cycles are completed. After the reset is completed, the program starts from the address contained in ad- dress FFFD 16 (high-order byte) and address FFFC16 (low-order byte). Make sure that the reset input voltage is less than 0.6 V for V CC of

3.0 V (Extended operating temperature version: the reset input

voltage is less than 0.8 V for V CC of 4.0 V). Fig. 23 Internal status of microcomputer after reset Fig. 22 Example of reset circuit FUNCTIONAL DESCRIPTION Note. 5 : Undefined ] : The initial values of CM1 are determined by the level at the CNV SS pin. The contents of all other registers and RAM are undefined after a reset, so they must be initialized by software. Register contents (000116) • • • Timer 2 Port P0 direction register Port P1 direction register Port P2 direction register Port P3 direction register Port P4 direction register Port P5 direction register Port P6 direction register Port P7 direction register Serial I/O status register Timer XY mode register Serial I/O control register UART control register Timer 1 (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) (25) (26) (27) (0003 16) • • • (000516) • • • (000716) • • • (000916) • • • (000B16) • • • (000D16) • • • (000F16) • • • (001916) • • • (001A16) • • • (001B16) • • • (002016) • • • (002116) • • • (002216) • • • (002316) • • • (002416) • • • (002516) • • • (002616) • • • (002716) • • • (003A16) • • • (003B16) • • • (003C16) • • • (003D16) • • • (003E16) • • • Address Prescaler 12 Prescaler X Timer X Prescaler Y Timer Y Interrupt edge selection register CPU mode register Interrupt request register 1 Interrupt request register 2 Interrupt control register 1 Interrupt control register 2 Processor status register Program counter 0016 0016 0016 0016 000000 0 ] 0016 FF16 FF16 FF16 FF16 0016 FF16 0116 FF16 0016 0016 0016 111000 0 0 0100 0 0 0 0016 0016 0016 Contents of address FFFC16 55555 1 55(PS) (PCH ) (PCL) Contents of address FFFD16 0016 0016 0016 (003F16) • • •

1-273800 GROUP USER’S MANUAL Fig. 24 Timing of reset FUNCTIONAL DESCRIPTION RESET Data f Address SYNC XIN: 8 to 13 clock cycles XIN ? ? ?? ? FFFC FFFD ADH, ADL 1: f(XIN) and f(f) are in the relationship: f(XIN)=2 • f(f). 2: A question mark (?) indicates an undefined status that depends on the previous status. Reset address from the vector table Notes RESET OUT (internal reset)

An oscillation circuit can be formed by connecting a resonator be- tween XIN and XOUT . To supply a clock signal externally, input it to the XIN pin and make the XOUT pin open. Oscillation control Stop Mode If the STP instruction is executed, the internal clock φ stops at “H”. Timer 1 is set to “01 16” and prescaler 12 is set to “FF16”. Oscillator restarts when an external interrupt is received, but the internal clock φ remains at “H” until timer 1 underflows. This allows time for the clock circuit oscillation to stabilize. If oscillator is restarted by a reset, no wait time is generated, so keep the RESET pin at “L ” level until oscillation has stabilized. Wait Mode If the WIT instruction is executed, the internal clock φ stops at an “H” level, but the oscillator itself does not stop. The internal clock restarts if a reset occurs or when an interrupt is received. Since the oscillator does not stop, normal operation can be started immediately after the clock is restarted. T o ensure that interrupts will be received to release the STP or WIT state, interrupt enable bits must be set to “1” before the STP or WIT instruction is executed. When the STP status is released, prescaler 12 and timer 1 will start counting and reset will not be released until timer 1 underflows, so set the timer 1 interrupt enable bit to “0” before the STP instruction is executed. Fig. 27 Block diagram of clock generating circuit Fig. 26 External clock input circuit Fig. 25 Ceramic resonator circuit FUNCTIONAL DESCRIPTION C OUT XIN X OUT C IN X IN XOUT Open External oscillation circuit Vss Vcc X OUTXIN R SQ STP instruction WIT instruction R S Q R SQ Reset STP instruction Timer 1 ONW control Prescaler 121/2 f output Internal clock f Rd Rf ONW pin Single-chip mode Reset Interrupt request Interrupt disable flag (I) FF16 0116 Reset or STP instruction

ports P0 to P3 lose their I/O port functions and become bus pins. Outputs low-order byte of address. Outputs high-order byte of address. (including instruction codes). (except that the port latch cannot be read). Table 8. Functions of ports in memory expansion mode and The shaded areas are external memory areas. is the start address of internal ROM.

Bus control with memory expansion The 3800 group has a built-in ONW function to facilitate access to external memory and I/O devices in memory expansion mode or microprocessor mode. If an “L ” level signal is input to the ONW pin when the CPU is in a read or write state, the corresponding read or write cycle is ex- tended by one cycle of φ. During this extended period, the RD or WR signal remains at “L ”. This extension period is valid only for writing to and reading from addresses 0000 16 to 000716 and 044016 to FFFF16 in microprocessor mode, 004016 to YYYY16 in memory expansion mode, and only read and write cycles are ex- tended. Fig. 30 ONW function timing FUNCTIONAL DESCRIPTION f Read cycle Write cycleDummy cycle Write cycle Read cycle Dummy cycle AD 15 to AD0 Period during which ONW input signal is received During this period, the ONW signal must be fixed at either “H” or “L”. At all other times, the input level of the ONW signal has no affect on operations. The bus cycles is not extended for an address in the area 0008 16 to 043F16, regardless of whether the ONW signal is received. ] : ]] ] ONW WR RD

1-313800 GROUP USER’S MANUAL NOTES ON PROGRAMMING NOTES ON PROGRAMMING Processor Status Register The contents of the processor status register (PS) after a reset are undefined, except for the interrupt disable flag (I) which is “1”. Af- ter a reset, initialize flags which affect program execution. In particular, it is essential to initialize the index X mode (T) and the decimal mode (D) flags because of their effect on calculations. Interrupts The contents of the interrupt request bits do not change immedi- ately after they have been written. After writing to an interrupt re- quest register, execute at least one instruction before executing a BBC or BBS instruction. Decimal Calculations To calculate in decimal notation, set the decimal mode flag (D) to “1”, then execute an ADC or SBC instruction. Only the ADC and SBC instructions yield proper decimal results. After executing an ADC or SBC instruction, execute at least one instruction before executing a SEC, CLC, or CLD instruction. In decimal mode, the values of the negative (N), overflow (V), and zero (Z) flags are invalid. The carry flag can be used to indicate whether a carry or borrow has occurred. Initialize the carry flag before each calculation. Clear the carry flag before an ADC and set the flag before an SBC. Timers If a value n (between 0 and 255) is written to a timer latch, the fre- quency division ratio is 1/(n + 1). Multiplication and Division Instructions The index X mode (T) and the decimal mode (D) flags do not af- fect the MUL and DIV instruction. The execution of these instructions does not change the contents of the processor status register. Ports The contents of the port direction registers cannot be read. The following cannot be used:

  • The data transfer instruction (LDA, etc.)
  • The operation instruction when the index X mode flag (T) is “1”
  • The addressing mode which uses the value of a direction regis- ter as an index
  • The bit-test instruction (BBC or BBS, etc.) to a direction register
  • The read-modify-write instruction (ROR, CLB, or SEB, etc.) to a direction register Use instructions such as LDM and STA, etc., to set the port direc- tion registers. Serial I/O In clock synchronous serial I/O, if the receive side is using an ex- ternal clock and it is to output the S RDY signal, set the transmit en- able bit, the receive enable bit, and the SRD Y output enable bit to “1”. Serial I/O continues to output the final bit from the T X D pin after transmission is completed. Instruction Execution Time The instruction execution time is obtained by multiplying the fre- quency of the internal clock φ by the number of cycles needed to execute an instruction. The number of cycles required to execute an instruction is shown in the list of machine instructions. The frequency of the internal clock φ is half of the X IN frequency. When the ONW function is used in modes other than single-chip mode, the frequency of the internal clock φ may be one fourth the X IN frequency. Memory Expansion Mode and Microproces- sor Mode Execute the LDM or STA instruction for writing to port P3 (address 000616) in memory expansion mode and microprocessor mode. Set areas which can be read out and write to port P3 (address 0006 16) in a memory, using the read-modify-write instruction (SEB, CLB).
  1. Mask ROM Order Confirmation Form
  2. Data to be written to ROM, in EPROM form (three identical

Figure 31 is recommended to verify programming. Table 9. Programming adapter expose to 150 °C exceeding 100 hours.

Table 10. Interrupt sources, vector addresses and interrupt priority Note: Reset functions in the same way as an interrupt with the highest priority.

FUNCTIONAL DESCRIPTION SUPPLEMENT Timing After Interrupt The interrupt processing routine begins with the machine cycle fol- lowing the completion of the instruction that is currently in execu- tion. Figure 32 shows a timing chart after an interrupt occurs, and Fig- ure 33 shows the time up to execution of the interrupt processing routine. Fig. 32 Timing chart after an interrupt occurs Fig. 33 Time up to execution of the interrupt processing routine : CPU operation code fetch cycle : Vector address of each interrupt : Jump destination address of each interrupt : “00 16” or “0116” SYNC BL, BH AL, AH SPS f Data bus Not used PC H PC L PS A L AH Address bus S, SPS S-2 , SPSS-1, SPSPC B L BH AL, AH SYNC RD WR Interrupt processing routine Generation of interrupt request Main routine 7 to 23 cycles (At performing 8.0 MHz, 1.75 ms to 5.75 ms) 2 cycles 5 cycles Start of interrupt processing 0 to 16 cycles Waiting time for post-processing of pipeline Stack push and Vector fetch [ : at execution of DIV instruction (16 cycles)

2.1 I/O port

2.2 Timer

2.3 Serial I/O

2.4 Processor mode

2.5 Reset

2-2 3800 GROUP USER’S MANUAL APPLICATION

2.1.1 Memory map of I/O port

Fig. 2.1.1 Memory map of I/O port related registers 000916 000016 000116 000216 000316 000416 000516 000616 000716 000816 000A16 000B16 000C 16 000D 16 000E16 000F16 Port P0 (P0) Port P0 direction register (P0D) Port P1 (P1) Port P1 direction register (P1D) Port P2 (P2) Port P2 direction register (P2D) Port P3 (P3) Port P3 direction register (P3D) Port P4 (P4) Port P4 direction register (P4D) Port P5 (P5) Port P5 direction register (P5D) Port P6 (P6) Port P6 direction register (P6D) Port P7 (P7) Port P7 direction register (P7D)

2-33800 GROUP USER’S MANUAL

2.1.2 Related registers

Fig. 2.1.2 Structure of Port Pi (i = 0, 1, 2, 3, 4, 5, 6, 7) Port Pi b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Name Port Pi0 Port Pi1 Port Pi2 Port Pi3 Port Pi4 Port Pi5 Port Pi6 Port Pi7 In output mode Write Read l Port latch In input mode Write : Port latch Read : Value of pins l [Address : 0016, 0216, 0416, 0616, 0816, 0A16, 0C16, 0E16] Note : (Note) Port P7 register [Address : 0E16] Port P7 is a 2-bit port (P70, P71). Accordingly, when bits 2 to 7 are read out, the contents are “0.” Fig. 2.1.3 Structure of Port Pi direction register (i = 0, 1, 2, 3, 4, 5, 6, 7) Port Pi direction register b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Name Port Pi direction register 0 Port Pi direction register (PiD) (i =0, 1, 2, 3, 4, 5, 6, 7) [Address : 0116, 0316, 0516, 0716, 0916, 0B16, 0D16, 0F16] 0 : Port Pi0 input mode 1 : Port Pi0 output mode 0 : Port Pi1 input mode 1 : Port Pi1 output mode 0 : Port Pi2 input mode 1 : Port Pi2 output mode 0 : Port Pi3 input mode 1 : Port Pi3 output mode 0 : Port Pi4 input mode 1 : Port Pi4 output mode 0 : Port Pi5 input mode 1 : Port Pi5 output mode 0 : Port Pi6 input mode 1 : Port Pi6 output mode 0 : Port Pi7 input mode 1 : Port Pi7 output mode Note : (Note) Port P7 direction register [Address : 0F 16] Port P7 is a 2-bit port (P70, P71). Accordingly, these bits do not have a direction register function. (Note) (Note) (Note) (Note) (Note)

, P3 P4, P5, P6, P7 ONW RESET OUT φ SYNC X OUT Set to the input mode and connect to V CC or V SS through a resistor of 1 k to 10 k

  • Set to the output mode and open at “L” or “H.” Open (only when using external clock). Handling

2.1.3 Handling of unused pins

Table 2.1.1 Handling of unused pins (in single-chip mode) Name of Pins/Ports P0, P1, P2, P3, P4, P5, P6, P7 X OUT Name of Pins/Ports Handling Table 2.1.2 Handling of unused pins (in memory expansion mode and microprocessor mode) Open Set to the input mode and connect to V CC or V SS through a resistor of 1 k to 10 k

  • Set to the output mode and open at “L” or “H.” Connect to V CC through a resistor of 1 k to 10 k Open Open Open Open (only when using external clock).

2.2.1 Memory map of timer

Fig. 2.2.1 Memory map of timer related registers C 003D 003E 003F Prescaler 12 (PRE12) Timer 1 (T1) Timer 2 (T2) Timer XY mode register (TM) Prescaler X (PREX) Timer X (TX) Prescaler Y (PREY) Timer Y (TY) Interrupt request register 1 (IREQ1) Interrupt request register 2 (IREQ2) Interrupt control register 1 (ICON1) Interrupt control register 2 (ICON2)

2-6 3800 GROUP USER’S MANUAL

2.2.2 Related registers

Fig. 2.2.2 Structure of Prescaler 12, Prescaler X, Prescaler Y Fig. 2.2.3 Structure of Timer 1 Prescaler 12, Prescaler X, Prescaler Y b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Prescaler 12 (PRE12), Prescaler X (PREX), Prescaler Y (PREY) [Address : 2016, 2416, 2616] The count value of each prescaler is set. The value set in this register is written to both the prescaler and the prescaler latch at the same time. When the prescaler is read out, the value (count value) of the prescaler is read out. l l l b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Timer 1 (T1) [Address : 2116] The count value of the Timer 1 is set. The value set in this register is written to both the Timer 1 and the Timer 1 latch at the same time. When the Timer 1 is read out, the value (count value) of the Timer 1 is read out. l l l Timer 1

2-73800 GROUP USER’S MANUAL APPLICATION Fig. 2.2.4 Structure of Timer 2, Timer X, Timer Y Timer 2, Timer X, Timer Y b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Timer 2 (T2), Timer X (TX), Timer Y (TY) [Address : 2216, 2516, 2716] The count value of each timer is set. The value set in this register is written to both the Timer and the Timer latch at the same time. When the Timer is read out, the value (count value) of the Timer is read out. l l l

2-8 3800 GROUP USER’S MANUAL Operating mode of Timer X/Timer Y Timer mode Pulse output mode Event counter mode Pulse width measurement mode Table. 2.2.1 Function of CNTR0/CNTR 1 edge switch bit Fig. 2.2.5 Structure of Timer XY mode register Function of CNTR0/CNTR 1 edge switch bit (bits 2 and 6) “0” “1” “0” “1” “0” “1” “0” “1”

  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge (No effect on timer count)
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge (No effect on timer count)
  • Start of pulse output : From “H” level
  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge
  • Start of pulse output : From “L” level
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge
  • Timer X/Timer Y : Count of rising edge
  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge
  • Timer X/Timer Y : Count of falling edge
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge
  • Timer X/Timer Y : Measurement of “H” level width
  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge
  • Timer X/Timer Y : Measurement of “L” level width
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge /LiteDiagLines /LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines Function Timer XY mode register b7 b6 b5 b4 b3 b2 b1 b0 B At resetR W Timer XY mode register (TM) Name Timer X operating mode bit CNTR 0 active edge switch bit Timer Y operating mode bit CNTR 1 active edge switch bit 0 0 : Timer mode 0 1 : Pulse output mode 1 0 : Event counter mode 1 1 : Pulse width measurement mode 0 0 : Timer mode 0 1 : Pulse output mode 1 0 : Event counter mode 1 1 : Pulse width measurement mode It depends on the operating mode of the Timer X (refer to Table 2.2.1). It depends on the operating mode of the Timer Y (refer to Table 2.2.1). b5 b4 Timer X count stop bit [Address : 2316] b1 b0 Timer Y count stop bit 0 : Count start 1 : Count stop 0 : Count start 1 : Count stop

2-93800 GROUP USER’S MANUAL APPLICATION Fig. 2.2.7 Structure of Interrupt request register 2 Fig. 2.2.6 Structure of Interrupt request register 1 Interrupt request register 2 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt request reigster 2 (IREQ2) [Address : 3D16] Name CNTR 0 interrupt request bit CNTR 1 interrupt request bit INT2 interrupt request bit 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request INT3 interrupt request bit 00 : No interrupt request 1 : Interrupt request Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “0.” INT5 interrupt request bit [ [ “0” is set by software, but not “1.” 4 00 : No interrupt request 1 : Interrupt request INT4 interrupt request bit [ 7 0 5 Interrupt request register 1 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt request reigster 1 (IREQ1) [Address : 3C16] Name [ “0” is set by software, but not “1.” /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines Timer Y interrupt request bit /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines Timer X interrupt request bit Timer 1 interrupt request bit0 : No interrupt request 1 : Interrupt request /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines Timer 2 interrupt request bit 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request INT0 interrupt request bit INT1 interrupt request bit Serial I/O receive interrupt request bit Serial I/O transmit interrupt request bit

2-10 3800 GROUP USER’S MANUAL Fig. 2.2.8 Structure of Interrupt control register 1 Fig. 2.2.9 Structure of Interrupt control register 2 Interrupt control register 2 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt control reigster 2 (ICON2) [Address : 3F16] Name CNTR 0 interrupt enable bit CNTR 1 interrupt enable bit INT2 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabledINT3 interrupt enable bit 00 : Interrupt disabled 1 : Interrupt enabled Fix these bits to “0.” INT5 interrupt enable bit 4 00 : Interrupt disabled 1 : Interrupt enabled INT4 interrupt enable bit 0 0 7 0 /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines Timer Y interrupt enable bit/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines Interrupt control register 1 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt control register 1 (ICON1) [Address : 3E16] Name INT0 interrupt enable bit INT1 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines Timer X interrupt enable bit Timer 1 interrupt enable bit0 : Interrupt disabled 1 : Interrupt enabled /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines/LiteDiagLines Timer 2 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled Serial I/O transmit interrupt enable bit Serial I/O receive interrupt enable bit

2-113800 GROUP USER’S MANUAL APPLICATION

2.2.3 Timer application examples

(1) Basic functions and uses [Function 1] Control of Event interval (Tim er X, Tim er Y , Tim er 1, Tim er 2) The Time r count stop bit is set to “0” after setting a count value to a time r. Then a time r interrupt request occurs after a certain period. [U se] • Generation of an output signal tim ing

  • Generation of a waiting tim e [Function 2] C ontrol of Cyclic operation (Tim er X, Time r Y, Time r 1, Tim er 2) The value of a tim er latch is autom atically w ritten to a corresponding tim er every tim e a tim er underflow s, and each cyclic tim er interrupt request occurs. [U se] • Generation of cyclic interrupts
  • C lock function (m easurem ent of 250m second) A pplication exam ple 1
  • Control of a main routine cycle [Function 3] O utput of Rectangular w aveform (Tim er X, Tim er Y) The output level of the CN TR pin is inverted every tim e a tim er underflow s (P ulse output m ode). [U se] • A piezoelectric buzzer output A pplication exam ple 2
  • Generation of the rem ote-control carrier waveform s [Function 4] C ount of External pulse (Tim er X , Tim er Y) E xternal pulses input to the C N T R pin are selected as a tim er count source (E vent counter m ode). [U se] • Measurem ent of frequency A pplication exam ple 3
  • D ivision of external pulses.
  • G eneration of interrupts in a cycle based on an external pulse. (count of a reel pulse) [Function 5] M easurem ent of External pulse w idth (Tim er X, Tim er Y) The “H ” or “L” level width of external pulses input to CN TR pin is measured (P ulse width m easurem ent mode). [U se] • Measurem ent of external pulse frequency (M easurem ent of pulse width of FG pulse] gener- ated by motor) Application example 4
  • Measurement of external pulse duty (when the frequency is fixed) ] FG pulse : Pulse used for detecting the motor speed to control the motor speed.

2-12 3800 GROUP USER’S MANUAL (2) Timer application example 1 : Clock function (measurement of 250 ms) Outline : The input clock is divided by a timer so that the clock counts up every 250 ms. Specifications :• The clock f(XIN) = 4.19 MHz (222 Hz) is divided by a timer.

  • The clock is counted at intervals of 250 ms by the Timer X interrupt. Figure 2.2.10 shows a connection of timers and a setting of division ratios, Figures 2.2.11 show a setting of related registers, and Figure 2.2.12 shows a control procedure. Fig. 2.2.10 Connection of timers and setting of division ratios [Clock function] Timer X interrupt request bit 1/16 0 or 11/2561/256f(XIN) =

4.19 MHz

0 : No interrupt request 1 : Interrupt request The clock is divided by 4 by software. 1 second

2-133800 GROUP USER’S MANUAL Fig. 2.2.11 Setting of related registers [Clock function] 255PREX Prescaler X (Address : 2416) 255TX Timer X (Address:2516) Set “division ratio – 1” Timer X interrupt enable bit : Interrupt enabled ICON1 Interrupt control register 1 (Address : 3E16) Timer X interrupt request bit (becomes “1” every 250 ms) IREQ1 Interrupt request register 1 (Address : 3C16) Timer X operating mode bits : Timer mode TM Timer XY mode register (Address : 2316) 001 Timer X count stop bit : Count stop Set to “0” at starting to count. b7 b0 b7 b0 b7 b0 b7 b0 b7 b0

Control procedure : Figure 2.2.12 shows a control procedure. Fig. 2.2.12 Control procedure [Clock function] RESET Initialization SEI TM ICON1 PREX TX TM CLI .... .... .... .... (Address : 23 (Address : 3E ), bit4 (Address : 24 (Address : 25 (Address : 23 ), bit3 XXXX X 256 – 1 256 – 1 l l l l l l l X : This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. Timer X interrupt processing routine CLT ( Note 2 CLD ( Note 3 Push register to stack RTI Y N Clock stop? Clock count up (1/4 second-year) Pop registers Check if the clock has already been set. Count up the clock. Pop registers which is pushed to stack Main processing PREX TX IREQ1 .... (Address : 24 (Address : 25 (Address : 3C ), bit4 256 – 1 256 – 1 [Processing for completion of setting clock] Note 1 Note 1: This processing is performed only at completing to set the clock. When restarting the clock from zero second after completing to set the clock, re-set timers. l l l l l Note 2: When using the Index X mode flag (T). Note 3: When using the Decimal mode flag (D). Push the register used in the interrupt processing routine into the stack. Timer X : Timer mode Timer X interrupt : Enabled Set “division ratio – 1” to the Prescaler X and Timer X. Timer X count : Operating Interrupts : Enabled All interrupts : Disabled

2-153800 GROUP USER’S MANUAL (3) Timer application example 2 : Piezoelectric buzzer output Outline : The rectangular waveform output function of a timer is applied for a piezoelectric buzzer output. Specifications :• The rectangular waveform resulting from dividing clock f(XIN) = 4.19 MHz into about 2 kHz (2048 Hz) is output from the P54/CNTR 0 pin.

  • The level of the P54/CNTR 0 pin fixes to “H” while a piezoelectric buzzer output is stopped. Figure 2.2.13 shows an example of a peripheral circuit, and Figure 2.2.14 shows a connection of the timer and setting of the division ratio. Fig. 2.2.13 Example of a peripheral circuit Fig. 2.2.14 Connection of the timer and setting of the division ratio [Piezoelectric buzzer output] 244 ms 244 ms 3800 group PiPiPi.... P54/CNTR 0 Set a division ratio so that the underflow output cycle of the Timer X becomes this value. The “H” level is output while a piezoelectric buzzer output is stopped. CNTR 0 output 1/16 1/2f(XIN) = 4.19 MHz Fixed Timer X Fixed 1/64 CNTR 01 Prescaler X

Fig. 2.2.15 Setting of related registers [Piezoelectric buzzer output] Control procedure : Figure 2.2.16 shows a control procedure. Fig. 2.2.16 Control procedure [Piezoelectric buzzer output] TX Timer X (Address : 25 16 ) Set “division ratio – 1” CNTR active edge switch bit : Output from the “H” level Timer X count stop bit : Count stop Set to “0” at starting to count. Timer X operating mode bits : Pulse output mode TM Timer XY mode register (Address : 23 16 ) b7 b0 b7 b0 PREX Prescaler X (Address : 24 16 ) b7 b0 Initialization P5D ICON1 TM TX PREX .... XXXX 1001 64 – 1 1 – 1 (Address : 0A ), bit4 (Address : 0B (Address : 3E ), bit4 (Address : 23 (Address : 25 (Address : 24 A piezoelectric buzzer is requested? RESET Y N Main processing TM (Address : 23 ), bit3 0 During stopping outputting a piezoelectric buzzer During outputting a piezoelectric buzzer Output unit l TM (Address : 23 16 ), TX (Address : 25 64 –1 X : This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. l Timer X interrupts : Disabled The CNTR output is stopped at this point (stop outputting a piezoelectric buzzer). Set “division ratio – 1” to the Prescaler X and Timer X. l l l The piezoelectric buzzer request occured in the main processing is processed in the output unit. XXX XXXX bit3 1

2-173800 GROUP USER’S MANUAL (4) Timer application example 3 : Measurement of frequency Outline : The following two values are compared for judging if the frequency is within a certain range.

  • A value counted a pulse which is input to P55/CNTR 1 pin by a timer.
  • A referance value Specifications :• The pulse is input to the P55/CNTR 1 pin and counted by the Timer Y.
  • A count value is read out at the interval of about 2 ms (Timer 1 interrupt interval : 244 µs 5 8). When the count value is 28 to 40, it is regarded the input pulse as a valid.
  • Because the timer is a down-counter, the count value is compared with 227 to 215]–. ] 227 to 215 = 255 (initialized value of counter) – 28 to 40 (the number of valid value). Figure 2.2.17 shows a method for judging if input pulse exists, and Figure 2.2.18 shows a setting of related registers. Input pulse 71.4 µs or more (14 kHz or less) 71.4 µs (14 kHz) 50 µs(20 kHz) 50 µs or less (20 kHz or more) Invalid Valid Invalid 2 ms 71.4 µs = 28 counts 2 ms 50 µs = 40 counts Fig 2.2.17 A method for judging if input pulse exists

2-18 3800 GROUP USER’S MANUAL APPLICATION Fig. 2.2.18 Setting of related registers [Measurement of frequency] 0PREY Prescaler Y (Address : 2616) Set “division ratio – 1” 255TY Timer Y (Address : 2716) Set “255” to this register immediately before counting pulse. (After a certain time, this value is decreased by the number of input pulses) Timer Y interrupt enable bit : Interrupt disabled ICON1 Interrupt control register 1 (Address : 3E16) Judgment of Timer Y interrupt request bit (When this bit is set to “1” at reading out the count value of the Timer Y (address : 27 16), 256 pulses or more are input (at setting 255 to the Timer Y).) IREQ1 Interrupt request register 1 (Address : 3C16) CNTR 1 active edge switch bits : Count at falling edge Timer Y count stop bit : Count stop Set to “0” at starting to count. Timer Y operating mode bit : Event counter mode TM Timer XY mode register (Address : 2316) b7 b0 Prescaler 12 (Address : 2016) b7 b0 63PRE12 7T1 Timer 1 (Address : 2116) b7 b0 b7 b0 b7 b0 b7 b0 Timer 1 interrupt enable bit : Interrupt enabled b7 b0

Control procedure : Figure 2.2.19 shows a control procedure. Fig. 2.2.19 Control procedure [Measurement of frequency] RTI (A) TY (Address : 27 TY IREQ1 (Address : 27 (Address : 3C ), bit5 256 – 1 Fpulse 0 Fpulse 1 Processing for a result of judgment 214 (A) 228? < < Compare the count value read with the reference value. Store the comparison result in flag Fpulse. Out of range In range l l l l l l Pop registers Pop registers which is pushed to stack. l Read the count value. Store the count value in the accumulator (A). Initialize the count value. Set the Timer Y interrupt request bit to “0.” RESET Initialization SEI TM PRE12 PREY TY ICON1 TM CLI .... (Address : 23 16 ) (Address : 20 (Address : 21 (Address : 26 (Address : 27 (Address : 3E ), bit6 (Address : 23 ), bit7 1110 XXXX 64–1 8–1 1–1 256–1 Timer 1 interrupt processing routine IREQ1 (Address : 3C 16 ), bit5? l l l l l l l Set the division ratio so that the Timer 1 interrupt occurs every 2 ms. Timer 1 interrupt : Enabled l Note 1: When using the Index X mode flag (T). Note 2: When using the Decimal mode flag (D). Push the register used in the interrupt processing routine into the stack. l X This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. When the count value is 256 or more, the processing is performed as out of range. Timer Y : Event counter mode (Count at falling edge of pulse input from CNTR pin) All interrupts : Disabled Timer Y count : Start Interrupts : Enabled CLT ( Note 1 CLD ( Note 2 Push register to stack

2-20 3800 GROUP USER’S MANUAL APPLICATION (5) Timer application example 4 : Measurement of pulse width of FG pulse generated by motor Outline : The “H” level width of a pulse input to the P54/CNTR 0 pin is counted by Timer X. An underflow is detected by Timer X interrupt and an end of the input pulse “H” level is detected by CNTR 0 interrupt. Specifications :• The “H” level width of a FG pulse input to the P54/CNTR 0 pin is counted by Timer (Example : When the clock frequency is 4.19 MHz, the count source would be 3.8 µs that is obtained by dividing the clock frequency by 16. Measurement can be made up to 250 ms in the range of FFFF 16 to 000016.) Figure 2.2.20 shows a connection of the timer and a setting of the division ratio, and Figure 2.2.21 shows a setting of related registers. Fig. 2.2.20 Connection of the timer and setting of the division ratio [Measurement of pulse width] f(XIN) = 4.19 MHz Fixed Prescaler X Timer X Timer X interrupt request bit 250 ms 0 : No interrupt request 1 : Interrupt request 1/16 0 or 11/2561/256

2-213800 GROUP USER’S MANUAL Fig. 2.2.21 Setting of related registers [Measurement of pulse width] CNTR 0 active edge switch bit : Count “H” level width Timer X operating mode bits : Pulse width measurement mode Timer X count stop bit : Count stop Set to “0” at starting to count. TM Timer XY mode register (Address : 2316) b7 b0 255PREX Prescaler X (Address : 2416) Set “division ratio – 1” 255TX Timer X (Address : 2516) Timer X interrupt enable bit : Interrupt enabled ICON1 Interrupt control register 1 (Address : 3E16) b7 b0 b7 b0 b7 b0 CNTR 0 interrupt enable bit : Interrupt enabled ICON2 Interrupt control register 2 (Address : 3F16) CNTR 0 interrupt request bit (This bit is set to “1” at completion of inputting “H” level signal.) IREQ2 Interrupt request register 2 (Address : 3D16) b7 b0 b7 b0 Timer X interrupt request bit (This bit is set to “1” at underflow of Timer X.) IREQ1 Interrupt request register (Address : 3C16) b7 b0

Fig. 2.2.22 Control procedure [Measurement of pulse width] Figure 2.2.22 shows a control procedure. Initialization All interrupts : Disabled l l l l l l SEI TM PREX TX ICON1 IREQ1 ICON2 IREQ2 TM CLI .... (Address : 23 16 ) (Address : 24 (Address : 25 (Address : 3E ), bit4 (Address : 3C ), bit4 (Address : 3F ), bit0 (Address : 3D ), bit0 (Address : 23 ), bit3 256–1 256–1 l X This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. Timer X interrupt processing routine Processing for error RTI Error occurs l CNTR interrupt processing routine CLT ( Note 1 CLD ( Note 2 Push register to stack RTI Pop registers l l A count value is read out and stored to RAM. Set the division ratio so that the Timer X interrupt occurs every 250 ms. l l (A) Result of pulse width measurement low–order 8-bit (A) Result of pulse width measurement high–order 8-bit PREX (Address : 24 TX (Address : 25 PREX Inversion of (A) TX 256 – 1 Inversion of (A) 256 – 1 Push the register used in the interrupt processing routine into the stack. Pop registers which is pushed to stack Timer X : Pulse width measurement mode Interrupts : Enabled (Count “H” level width of pulse input from CNTR 0 pin.) Set the division ratio so that the Timer X interrupt occurs every 250 ms. Timer X interrupt : Enabled CNTR interrupt : Enabled Timer X count : Start l Note 1: When using the Index X mode flag (T). Note 2: When using the Decimal mode flag (D). XXXX 1011 RESET

2-233800 GROUP USER’S MANUAL APPLICATION

2.3.1 Memory map of serial I/O

Fig. 2.3.1 Memory map of serial I/O related registers 001816 001916 001A16 001B16 001C 16 Transmit/Receive buffer register (TB/RB) Serial I/O status register (SIOSTS) Serial I/O control register (SIOCON) UART control register (UARTCON) Baud rate generator (BRG) 003F16 003A16 003C 16 003D 16 003E16 Interrupt edge selection register (INTEDGE) Interrupt request register 1 (IREQ1) Interrupt request register 2 (IREQ2) Interrupt control register 2 (ICON2) Interrupt control register 1 (ICON1)

2-24 3800 GROUP USER’S MANUAL APPLICATION

2.3.2 Related registers

Fig. 2.3.2 Structure of Transmit/Receive buffer register Fig. 2.3.3 Structure of Serial I/O status register Transmit/Receive buffer register b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Transmit/Receive buffer register (TB/RB) [Address : 1816] A transmission data is written to or a receive data is read out from this buffer register.

  • At writing : a data is written to the Transmit buffer register.
  • At reading : a content of the Receive buffer register is read out. 5 ? Note :A content of the Transmit buffer register cannot be read out. A data cannot be written to the Receive buffer register. b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Serial I/O status reigster (SIOSTS) [Address : 1916] Name Transmit buffer empty flag (TBE) 0 : (OE) (PE) (FE) = 0 1 : (OE) (PE) (FE) = 1 Overrun error flag (OE) 0 : Buffer full 1 : Buffer empty Nothing is allocated for this bit. It is a write disabled bit. When this bit is read out, the value is “0.” Receive buffer full flag (RBF) Transmit shift register shift completion flag (TSC) Parity error flag (PE) Framing error flag (FE) Summing error flag (SE) 0 : Buffer empty 1 : Buffer full 0 : Transmit shift in progress 1 : Transmit shift completed 0 : No error 1 : Overrun error 0 : No error 1 : Parity error 0 : No error 1 : Framing error Serial I/O status register

Fig. 2.3.4 Structure of Serial I/O control register Fig. 2.3.5 Structure of UART control register b7 b6 b5 b4 b3 b2 b1 b0 UART control register (UARTCON) [Address : 1B UART control register Character length selection bit (CHAS) 8 bits bits Parity enable bit (PARE) Parity checking disabled Parity checking enabled Stop bit length selection bit (STPS) 1 stop bit 2 stop bits /TxD P-channel output disable bit (POFF) Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “1.” Parity selection bit (PARS) Even parity Odd parity At resetB Name Function RW In output mode 1 : N-channel open-drain output CMOS output b7 b6 b5 b4 b3 b2 b1 b0 Serial I/O control register 0 : Transmit buffer empty 1 : Transmit shift operating completion f X I N f X I N Serial I/O synchronous clock selection bit (SCS) At selecting clock synchronous serial I/O 0 : BRG output divided by 4 1 : External clock input At selecting UART 0 : BRG output divided by 16 1 : External clock input divided by 16 Transmit interrupt source selection bit (TIC) S RDY output enable bit (SRDY) I/O port (P47) S RDY output pin At reset B Name Function RW Transmit disabled Transmit enabled Transmit enable bit (TE) Receive enable bit (RE) Receive disabled Receive enabled Serial I/O enable bit (SIOE) Serial I/O mode selection bit (SIOM) UART Clock synchronous serial I/O Serial I/O disabled (P4 –P4 I/O port) Serial I/O enabled (P4 –P4 Serial I/O function pin) BRG count source selection bit (CSS) Serial I/O control register (SIOCON) [Address : 1A

2-26 3800 GROUP USER’S MANUAL APPLICATION B Baud rate generator (BRG) [Address : 1C16] b7 b6 b5 b4 b3 b2 b1 b0 Baud rate generator ?A count value of Baud rate generator is set. Function At reset W R Fig. 2.3.6 Structure of Baud rate generator Fig. 2.3.7 Structure of Interrupt edge selection register Interrupt edge selection register (INTEDGE) [Address : 3A16] Interrupt edge selection register INT0 interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT1 interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT3 interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “0.” INT4 interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT5 interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT2 interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active At resetB Name Function RW 7 5 b7 b6 b5 b4 b3 b2 b1 b0

2-273800 GROUP USER’S MANUAL APPLICATION Serial I/O receive interrupt request bit Interrupt request register 1 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt request reigster 1 (IREQ1) [Address : 3C16] Name INT0 interrupt request bit INT1 interrupt request bit 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request Serial I/O transmit interrupt request bit Timer Y interrupt request bit Timer 1 interrupt request bit0 : No interrupt request 1 : Interrupt request Timer 2 interrupt request bit 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request [ “0” is set by software, but not “1.” Timer X interrupt request bit Fig. 2.3.8 Structure of Interrupt request register 1 Fig. 2.3.9 Structure of Interrupt control register 1 Timer Y interrupt enable bit Interrupt control register 1 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt control register 1 (ICON1) [Address : 3E16] Name INT0 interrupt enable bit INT1 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled Timer X interrupt enable bit Timer 1 interrupt enable bit0 : Interrupt disabled 1 : Interrupt enabled Timer 2 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled Serial I/O transmit interrupt enable bit Serial I/O receive interrupt enable bit

2-28 3800 GROUP USER’S MANUAL APPLICATION

2.3.3 Serial I/O connection examples

(1) Control of peripheral IC equipped with CS pin There are connection examples using a clock synchronous serial I/O mode. Figure 2.3.10 shows connection examples of a peripheral IC equipped with the CS pin. Fig. 2.3.10 Serial I/O connection examples (1) Port CS CLK IN OUT (4) Connecting ICs 3800 group Peripheral IC 1 Peripheral IC 2 Port SCLK TXD R XD CS CLK IN OUT (2) Transmission and reception 3800 group Peripheral IC (E PROM etc.) (3) Transmission and reception (Pins R XD and TXD are connected) (Pins IN and OUT in peripheral IC are connected) CS CLK IN OUT 3800 group Peripheral IC (E PROM etc.) [ 2 “Port” is an output port controlled by software.Note: Port SCLK TXD CS CLK DATA (1) Only transmission (using the R XD pin as an I/O port) 3800 group Peripheral IC (OSD controller etc.) [ 1 [ 1: Select an N-channel open-drain output control of TXD pin. 2: Use such OUT pin of peripheral IC as an N-channel open- drain output in high impedance during receiving data. Port SCLK TXD R XD SCLK TXD R XD Port CS CLK IN OUT

2-293800 GROUP USER’S MANUAL APPLICATION (2) Connection with microcomputer Figure 2.3.11 shows connection examples of the other microcomputers. Fig. 2.3.11 Serial I/O connection examples (2) (4) Using UART SCLK TXD R XD CLK IN OUT (2) Selecting an external clock 3800 group Microcomputer (3) Using the SRDY siganl output function (Selecting an external clock) SRDY SCLK TXD R XD RDY CLK IN OUT 3800 group Microcomputer CLK IN OUT (1) Selecting an internal clock 3800 group Microcomputer R XD TXD SCLK TXD R XD R XD TXD 3800 group Microcomputer

2-30 3800 GROUP USER’S MANUAL APPLICATION

2.3.4 Setting of serial I/O transfer data format

A clock synchronous or clock asynchronous (UART) is selected as a data format of the serial I/O. Figure 2.3.12 shows a setting of serial I/O transfer data format. Fig. 2.3.12 Setting of Serial I/O transfer data format 1ST-8DATA-1SP ST LSB Serial I/O UART Clock synchronous Serial I/O 1ST-7DATA-1SP ST LSB 1ST-8DATA-1PAR-1SP ST LSB 1ST-7DATA-1PAR-1SP ST LSB 1ST-8DATA-2SP ST LSB 1ST-7DATA-2SP ST LSB 1ST-8DATA-1PAR-2SP ST LSB 1ST-7DATA-1PAR-2SP ST LSB MSB SP MSB SP MSB PAR SP MSB PAR SP MSB 2SP MSB 2SP MSB PAR 2SP MSB PAR 2SP LSB first ST : Start bit SP : Stop bit PAR : Parity bit

2-313800 GROUP USER’S MANUAL APPLICATION

2.3.5 Serial I/O application examples

(1) Communication using a clock synchronous serial I/O (transmit/receive) Outline : 2-byte data is transmitted and received through the clock synchronous serial I/O. The S RDY signal is used for communication control. Fig. 2.3.13 Connection diagram [Communication using a clock synchronous serial I/O] Specifications : • The Serial I/O is used (clock synchronous serial I/O is selected)

  • Synchronous clock frequency : 125 kHz (f(XIN) = 4 MHz is divided by 32)
  • The SRDY (receivable signal) is used.
  • The receiving side outputs the S RDY signal at intervals of 2 ms (generated by timer), and 2-byte data is transferred from the transmitting side to the receiving side. P42/INT0 SCLK1 TXD 3800 group SRDY SCLK R XD 3800 group Transmitting side Receiving side Fig. 2.3.14 Timing chart [Communication using a clock synchronous serial I/O]
  • • • •D 0 D 4D 2D 1 D 6D 5 D 7D 3 D 0 D 4D 2D 1 D 6D 5 D 7D 3 D 0 D 1
  • • • •
  • • • • TXD SCLK SRDY 2 ms

2-32 3800 GROUP USER’S MANUAL APPLICATION Serial I/O status register (Address : 1916) SIOSTS Baud rate generator (Address : 1C16) BRG Set “division ratio – 1” Transmit buffer empty flag

  • Check to be transferred data from the Transmit buffer register to Transmit shift register.
  • Writable the next transmission data to the Transmit buffer register at being set to “1.” Transmitting side Transmit shift register shift completion flag Check a completion of transmitting 1-byte data with this flag “1” : Transmit shift completed Serial I/O control register (Address : 1A16) SIOCON BRG counter source selection bit : f(XIN) Serial I/O synchronous clock selection bit : BRG/4 Transmit enable bit : Transmit enabled Receive enable bit : Receive disabled Serial I/O mode selection bit : Clock synchronous serial I/O Serial I/O enable bit : Serial I/O enabled Interrupt edge selection register (Address : 3A16) INTEDGE INT0 active edge selection bit : Select INT0 falling edge b7 b0 b7 b0 11 0 1 00 b7 b0 b7 b0 Fig. 2.3.15 Setting of related registers at a transmitting side [Communication using a clock synchronous serial I/O]

Fig. 2.3.16 Setting of related registers at a receiving side [Communication using a clock synchronous serial I/O] b7 b0 Receiving side Serial I/O control register (Address : 1A SIOCON Serial I/O synchronous clock selection bit : External clock S RDY output enable bit : Use the S RDY output Transmit enable bit : Transmit enabled Set this bit to “1,” using S RDY output. Receive enable bit : Receive enabled Serial I/O mode selection bit : Clock synchronous serial I/O Serial I/O enable bit : Serial I/O enabled Serial I/O status register (Address : 19 SIOSTS Receive buffer full flag Check a completion of receiving 1-byte data with this flag. “1” : At completing to receive “0” : At reading out a receive buffer b7 b0 1 111 11

2-34 3800 GROUP USER’S MANUAL APPLICATION Control procedure : Figure 2.3.17 shows a control procedure at a transmitting side, and Figure 2.3.18 shows a control procedure at a receiving side. Fig. 2.3.17 Control procedure at a transmitting side [Communication using a clock synchronous serial I/O] RESET Initialization SIOCON BRG INTEDGE TB/RB (Address : 1816) The first byte of a transmission data Write a transmission data The Transmit buffer empty flag is set to “0” by this writing. Detect INT0 falling edgeIREQ1 (Address : 3C16), bit0? Check to be transfered data from the Transmit buffer register to the Transmit shift register. (Transmit buffer empty flag) SIOSTS (Address : 1916), bit0? TB/RB (Address : 1816) Write a transmission data The Transmit buffer empty flag is set to “0” by this writing. The second byte of a transmission data Check to be transfered data from the Transmit buffer register to the Transmit shift register. (Transmit buffer empty flag) SIOSTS (Address : 1916), bit0? Check a shift completion of the Transmit shift register (Transmit shift register shift completion flag) SIOSTS (Address : 1916), bit2? IREQ1 (Address : 3C16), bit0 0 l X : This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. l l l l l l (Address : 1A16) (Address : 1C16) (Address : 3A16), bit0 8–1 1101XX 002

Fig. 2.3.18 Control procedure at a receiving side [Communication using a clock synchronous serial I/O] RESET Initialization SIOCON (Address : 1A 1111 X X TB/RB (Address : 18 Dummy data S RDY output S RDY signal is output by writing data to the TB/RB. Using the S RDY the transmit enabled bit (bit4) of the SIOCON is set to “1.” An interval of 2 ms is generated by a timer. Pass 2 ms? Y N Check a completion of receiving (Receive buffer full flag) SIOSTS (Address : 19 16 ), bit1? Read out reception data from TB/RB (Address : 18 Receive the first byte data. A Receive buffer full flag is set to “0” by reading data. Check a completion of receiving (Receive buffer full flag) SIOSTS (Address : 19 16 ), bit1? Read out reception data from TB/RB (Address : 18 Receive the second byte data. A Receive buffer full flag is set to “0” by reading data. X : This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. l l l l l l l

2-36 3800 GROUP USER’S MANUAL APPLICATION (2) Output of serial data (control of a peripheral IC) Outline : 4-byte data is transmitted and received through the clock synchronous serial I/O. The CS signal is output to a peripheral IC through the port P53. Fig. 2.3.19 Connection diagram [Output of serial data] Specifications : • The Serial I/O is used. (clock synchronous serial I/O is selected)

  • Synchronous clock frequency : 125 kHz (f(XIN) = 4 MHz is divided by 32)
  • Transfer direction : LSB first
  • The Serial I/O1 interrupt is not used.
  • The Port P53 is connected to the CS pin (“L” active) of the peripheral IC for a transmission control (the output level of the port P53 is controlled by software). Figre 2.3.20 shows an output timing chart of serial data. Fig. 2.3.20 Timing chart [Output of serial data] P53 SCLK TXD CS Peripheral IC3800 group DATA CS CLK CLK DATA CS DO 0 DO 1 DO 2 DO 3 CLK DATA

2-373800 GROUP USER’S MANUAL APPLICATION Figure 2.3.21 shows a setting of serial I/O related registers, and Figure 2.3.22 shows a setting of serial I/O transmission data. Fig. 2.3.22 Setting of serial I/O transmission data [Output of serial data] Fig. 2.3.21 Setting of serial I/O related registers [Output of serial data] Set a transmission data. Check that transmission of the previous data is completed before writing data (bit 3 of the Interrupt request register 1 is set to “1”). TB/RB Transmit/Receive buffer register (Address : 1816) b7 b0 Serial I/O synchronous clock selection bit : BRG/4 SRDY output enable bit : Not use the SRDY signal output function Serial I/O transmit interrupt enable bit : Interrupt disabled ICON1 Interrupt control register 1 (Address : 3E16) Serial I/O transmit interrupt request bit Using this bit, check the completion of transmitting 1-byte base data. “1” : Transmit shift completion IREQ1 Interrupt request register 1 (Address : 3C16) 001SIOCON Serial I/O control register (Address : 1A16) 0011 BRG count source selection bit : f(XIN) Transmit interrupt source selection bit : Transmit shift operating completion Transmit enable bit : Transmit enabled Receive enable bit : Receive disabled b7 b0 b7 b0 b7 b0 Serial I/O mode selection bit : Clock synchronous serial I/O Serial I/O enable bit : Serial I/O enabled P45/TXD P-channel output disable bit : CMOS output UARTCON UART control register (Address : 1B16) b7 b0

7 Set “division ratio – 1”BRG

Baud rate generator (Address : 1C16) b7 b0

Control procedure : When the registers are set as shown in Figure 2.3.21, the Serial I/O can transmit 1-byte data simply by writing data to the Transmit buffer register. Thus, after setting the CS signal to “L,” write the transmission data to the Receive buffer register on a 1-byte base, and return the CS signal to “H” when the desired number of bytes have been transmitted. Figure 2.3.23 shows a control procedure of serial I/O. Fig. 2.3.23 Control procedure of serial I/O [Output of serial data] Set the Serial I/O. Set the CS signal output level to “L.” Set the Serial I/O transmit interrupt request bit to “0.” Write a transmission data. (start to transmit 1-byte data) Check the completion of transmitting 1- byte data. Use any of RAM area as a counter for counting the number of transmitted bytes. Check that transmission of the target number of bytes has been completed. Return the CS signal output level to “H” when transmission of the target number of bytes is completed. RESET P5 (Address : 0A ), bit3 0 N Y IREQ1 (Address : 3C 16 ), bit3? Complete to transmit data? Initialization SIOCON UARTCON BRG ICON1 P5D .... .... (Address : 1A 16 ) (Address : 1B ), bit4 (Address : 1C (Address : 3E ), bit3 (Address : 0A ), bit3 (Address : 0B P5 (Address : 0A ), bit3 1 l l l l l l l l l X : This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. l Serial I/O transmit interrupt : Disabled Set the CS signal output port. (“H” level output) IREQ1 (Address : 3C ), bit3 0 TB/RB (Address : 18 a transmissiondata l 11011000 8–1 XXXX XXX

2-393800 GROUP USER’S MANUAL (3) Cyclic transmission or reception of block data (data of a specified number of bytes) between microcomputers [without using an automatic transfer] Outline : When a clock synchronous serial I/O is used for communication, synchronization of the clock and the data between the transmitting and receiving sides may be lost because of noise included in the synchronizing clock. Thus, it is necessary to be corrected constantly. This “heading adjustment” is carried out by using the interval between blocks in this example. Fig. 2.3.24 Connection diagram [Cyclic transmission or reception of block data between microcomputers] Specifications :• The serial I/O is used (clock synchronous serial I/O is selected).

  • Synchronous clock frequency : 131 kHz (f(XIN) = 4.19 MHz is divided by 32)
  • Byte cycle: 488 µs
  • Number of bytes for transmission or reception : 8 byte/block
  • Block transfer cycle : 16 ms
  • Block transfer period : 3.5 ms
  • Interval between blocks : 12.5 ms
  • Heading adjustive time : 8 ms Limitations of the specifications 1. Reading of the reception data and setting of the next transmission data must be completed within the time obtained from “byte cycle – time for transferring 1-byte data” (in this example, the time taken from generating of the Serial I/O receive interrupt request to generating of the next synchronizing clock is 431 µs). 2. “Heading adjustive time < interval between blocks” must be satisfied. SCLK Master unit SCLK Slave unit TXD R XD TXD R XD

The communication is performed according to the timing shown below. In the slave unit, when a synchronizing clock is not input within a certain time (heading adjustive time), the next clock input is processed as the beginning (heading) of a block. When a clock is input again after one block (8 byte) is received, the clock is ignored. Figure 2.3.26 shows a setting of related registers. Fig. 2.3.25 Timing chart [Cyclic transmission or reception of block data between microcomputers] D 0 Byte cycle Block transfer period Block transfer cycle D 1 D 2 D 7 D 0 Interval between blocks Processing for heading adjustment Heading adjustive time Fig. 2.3.26 Setting of related registers [Cyclic transmission or reception of block data between microcomputers] Transmit enabled SIOCON Serial I/O control register (Address : 1A6) Synchronous clock : BRG/4 Transmit interrupt source : Transmit shift operating completion Receive enabled Clock synchronous serial I/O 011110 0 Master unit Serial I/O enabled BRG count source : f(XIN) Not use the SRDY output Not be effected by external clock Transmit enabled SIOCON Serial I/O control register (Address : 1A16) Not use the serial I/O transmit interrupt Receive enabled Clock synchronous serial I/O 111 1 Slave unit Serial I/O enabled Synchronous clock : External clock Not use the SRDY output UARTCON UART control register (Address : 1B16) P45/TXD pin : CMOS output Both of units b7 b0 7BRG b7 b0 Baud rate generator (Address : 1C16) Set “division ratio – 1” b7 b0 b7 b0

2-413800 GROUP USER’S MANUAL Control procedure : Control in the master unit After a setting of the related registers is completed as shown in Figure 2.3.33, in the master unit transmission or reception of 1-byte data is started simply by writing transmission data to the Transmit buffer register. To perform the communication in the timing shown in Figure 2.3.25, therefore, take the timing into account and write transmission data. Read out the reception data when the Serial I/O transmit interrupt request bit is set to “1,” or before the next transmission data is written to the Transmit buffer register. A processing example in the master unit using timer interrupts is shown below. Fig. 2.3.27 Control in the master unit Write a transmission data Read a reception data NWithin a block transfer period? Y YComplete to transfer a block? N RTI Write the first transmission data (first byte) in a block Count a block interval counter NStart a block transfer? Y Generate a certain block interval by using a timer or other functions. l Check the block interval counter and determine to start of a block transfer. l CLT (Note 1) CLD (Note 2) Push register to stack Note 1: When using the Index X mode flag (T). Note 2: When using the Decimal mode flag (D). Push the register used in the interrupt processing routine into the stack. l Pop registers Pop registers which is pushed to stack.l Interrupt processing routine executed every 488 ms

After a setting of the related registers is completed as shown in Figure 2.3.26, the slave unit becomes the state which is received a synchronizing clock at all times, and the Serial I/O receive interrupt request bit is set to “1” every time an 8-bit synchronous clock is received. By the serial I/O receive interrupt processing routine, the data to be transmitted next is written to the Transmit buffer register after received data is read out. However, if no serial I/O receive interrupt occurs for more than a certain time (head adjustive time), the following processing will be performed. 1. The first 1 byte data of the transmission data in the block is written into the Transmit buffer register. 2. The data to be received next is processed as the first 1 byte of the received data in the block. Figure 2.3.28 shows the control in the slave unit using a serial I/O receive interrupt and any timer interrupt (for head adjustive). Fig. 2.3.28 Control in the slave unit Write a transmission data Read a reception data NWithin a block transfer period? Y Y A received byte counter ≥ 8? N RTI Write any data (FF16) A received byte counter +1 Heading adjustive counter Initialized value (Note 3) Serial I/O receive interrupt processing routine Timer interrupt processing routine Heading adjustive counter – 1 NHeading adjustive counter = 0? Y RTI Write the first transmission data (first byte) in a block A received byte counter0 Check the received byte counter to judge if a block has been transfered. In this example, set the value which is equal to the heading adjustive time divided by the timer interrupt cycle as the initialized value of the heading adjustive counter. For example: When the heading adjustive time is 8 ms and the timer interrupt cycle is 1 ms, set 8 as the initialized value. l CLT (Note 1) CLD (Note 2) Push register to stack Push the register used in the interrupt processing routine into the stack. l CLT (Note 1) CLD (Note 2) Push register to stack Push the register used in the interrupt processing routine into the stack. l Pop registers Pop registers which is pushed to stack. l Pop registers Pop registers which is pushed to stack. l Notes 1: When using the Index X mode flag (T). 2: When using the Decimal mode flag (D).

2-433800 GROUP USER’S MANUAL (4) Communication (transmit/receive) using an asynchronous serial I/O (UART) Point : 2-byte data is transmitted and received through an asynchronous serial I/O. The port P40 is used for communication control. Fig. 2.3.29 Connection diagram [Communication using UART] Specifications : • The Serial I/O is used (UART is selected).

  • Transfer bit rate : 9600 bps (f(XIN) = 4.9152 MHz is divided by 512)
  • Communication control using port P40 (The output level of the port P40 is controlled by softoware.)
  • 2-byte data is transferred from the transmitting side to the receiving side at inter- vals of 10 ms (generated by timer). Fig. 2.3.30 Timing chart [Communication using UART] Transmitting side P40 3800 group P40 3800 group Receiving side TXD XD P40 TXD 10 ms D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7ST SP(2) D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7ST SP(2) D 0ST R

Table 2.3.1 shows setting examples of Baud rate generator (BRG) values and transfer bit rate values, Figure 2.3.31 shows a setting of related registers at a transmitting side, and Figure 2.3.32 shows a setting of related registers at a receiving side. Table 2.3.1 Setting examples of Baud rate generator values and transfer bit rate values BRG setting valueActual time (bps)BRG setting value at f(XIN) = 4.9152 MHZ 600 1200 2400 4800 9600 19200 38400 76800 31250 62500 600.96 1201.92 2403.85 4807.69 9615.38 20833.33 41666.67 83333.33 31250.00 62500.00 207(CF 16) 103(6716) 51(3316) 25(1916) 12(0C16) 5(0516) 2(0216) 5(0516) 15(0F16) 7(0716) 600.00 1200.00 2400.00 4800.00 9600.00 19200.00 38400.00 76800.00 191(BF 16) 95(5F16) 47(2F16) 23(1716) 11(0B16) 5(0516) 2(0216) 5(0516) 600.00 1200.00 2400.00 4800.00 9600.00 19200.00 38400.00 76800.00 127(7F 16) 63(3F16) 31(1F16) 15(0F16) 7(0716) 3(0316) 1(0116) 3(0316) at f(XIN) = 8 MHZat f(XIN) = 7.3728 MHZTransfer bit rate (bps) (Note 1) BRG count source (Note 2) Actual time (bps) Actual time (bps)BRG setting value f(XIN)/4 f(XIN)/4 f(XIN)/4 f(XIN)/4 f(XIN)/4 f(XIN)/4 f(XIN)/4 f(XIN) f(XIN) f(XIN) Transfer bit rate (bps) = (BRG setting value + 1) 5 16 5 m f(XIN) Notes 1: Equation of transfer bit rate m: when bit 0 of the Serial I/O control register (Address : 1A16) is set to “0,” a value of m is 1. when bit 0 of the Serial I/O control register (Address : 1A16) is set to “1,” a value of m is 4. 2: A BRG count source is selected by bit 0 of the Serial I/O control register (Address : 1A16).

2-453800 GROUP USER’S MANUAL Fig. 2.3.31 Setting of related registers at a transmitting side [Communication using UART] b7 b0 00 0 b7 b0 b7 b0 Serial I/O status register (Address : 1916) SIOSTS Transmitting side Baud rate generator (Address : 1C16) BRG SIOCON BRG count source selection bit : f(XIN)/4 Serial I/O synchronous clock selection bit : BRG/16 Transmit enable bit : Transmit enabled Receive enable bit : Receive disabled Serial I/O mode selection bit : Asynchronous serial I/O(UART) Serial I/O enable bit : Serial I/O enabled SRDY output enable bit : Not use SRDY out UART control register (Address : 1B16) UARTCON Character length selection bit : 8 bits Parity enable bit : Parity checking disabled P45/TXD P-channel output disable bit : CMOS output Stop bit length selection bit : 2 stop bits f(XIN) Transfer bit rate 5 16 5 m – 1 Transmit buffer empty flag

  • Check to be transferred data from the Transmit buffer register to the Transmit shift register.
  • Writable the next transmission data to the Transmit buffer register at being set to “1.” Transmit shift register shift completion flag Check a completion of transmitting 1-byte data with this flag. “1” : Transmit shift completed Serial I/O control register (Address : 1A16) Set when bit 0 of the Serial I/O control register (Address : 1A16) is set to “0,” a value of m is 1. when bit 0 of the Serial I/O control register (Address : 1A16) is set to “1,” a value of m is 4. 10 0 1 0 0 1 b7 b0

Fig. 2.3.32 Setting of related registers at a receiving side [Communication using UART] b7 b0 b7 b0 b7 b0 SIOSTS b7 b0 Receive buffer full flag Receiving side Serial I/O status register (Address : 1916) BRG 7 Serial I/O control register (Address : 1A16) SIOCON UARTCON Check a completion of receiving 1-byte data with this flag. “1” : at completing to receive “0” : at reading out a content of the Receive buffer register Overrun error flag “1” : when data are ready to be transferred to the Receive shift register in the state of storing data into the Receive buffer register. Parity error flag “1” : when parity error occurs at enabled parity. Framing error flag “1” : when data can not be received at the timing of setting a stop bit. Summing error flag “1” : when even one of the following errors occurs.

  • Overrun error
  • Parity error
  • Framing error BRG count source selection bit : f(XIN)/4 Serial I/O synchronous clock selection bit : BRG/16 Transmit enable bit : Transmit disabled Receive enable bit : Receive enabled Serial I/O mode selection bit : Asynchronous serial I/O(UART) Serial I/O enable bit : Serial I/O enabled SRDY output enable bit : Not use SRDY out UART control register (Address : 1B16) Character length selection bit : 8 bits Parity enable bit : Parity checking disabled Stop bit length selection bit : 2 stop bits Baud rate generator (Address : 1C16) f(XIN) Transfer bit rate 5 16 5 m – 1Set when bit 0 of the Serial I/O control register (Address : 1A16) is set to “0,” a value of m is 1. when bit 0 of the Serial I/O control register (Address : 1A16) is set to “1,” a value of m is 4. 10 10 0 0 1 001

2-473800 GROUP USER’S MANUAL Control procedure : Figure 2.3.33 shows a control procedure at a transmitting side, and Figure 2.3.34 shows a control procedure at a receiving side. RESET End of communication (Address : 1A16) (Address : 1B16) (Address : 1C16) (Address : 0816), bit0 (Address : 0916) P4 (Address : 0816), bit0 1 Y N TB/RB ((Address : 1816) The second byte of a transmission data SIOSTS (Address : 1916), bit0? SIOSTS (Address : 1916), bit2? Initialization SIOCON UARTCON BRG P4D 8–1 .... TB/RB (Address : 1816) The first byte of a transmission data P4 (Address : 0816), bit0 0 X : This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. Set port P40 for a communication control. An interval of 10 ms is generated by a timer. Start of communication. Write a transmission data The Transmit buffer empty flag is set to “0” by this writing. Write a transmission data The Transmit buffer empty flag is set to “0” by this writing. Check to be transferred data from the Transmit buffer register to the Transmit shift register. (Transmit buffer empty flag) Check to be transferred data from the Transmit buffer register to the Transmit shift register. (Transmit buffer empty flag) Check a shift completion of the Transmit shift register. (Transmit shift register shift completion flag) SIOSTS (Address : 1916), bit0? XXXXXXX 12 l l l l l l l l l l Pass 10 ms? 1001X 0012 000010002 Fig. 2.3.33 Control procedure at a transmitting side [Communication using UART]

Fig. 2.3.34 Control procedure at a receiving side [Communication using UART] RESET (Address : 1A (Address : 1B (Address : 1C (Address : 09 Check a completion of receiving. (Receive buffer full flag) SIOSTS (Address : 19 16 ), bit1? Read out a reception data from RB (Address : SIOSTS (Address : 19 ), bit6? Initialization SIOCON UARTCON BRG P4D 1010 X 001 00001000 XXXXXXX .... SIOSTS (Address : 19 ), bit1? Check an error falag. SIOSTS (Address : 19 ), bit6? P4 (Address : 08 ), bit0? SIOCON (Address : 1A SIOCON (Address : 1A 0000 X 001 1010 X 001 Read out a reception data from RB (Address : 18 Receive the first 1 byte data A Receive buffer full flag is set to “0” by reading data. Check a completion of receiving. (Receive buffer full flag) Receive the second byte data A Receive buffer full flag is set to “0” by reading data. Check an error flag. Countermeasure for a bit slippage X This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded. l l l l l l l Processing for error

2-493800 GROUP USER’S MANUAL

2.4.1 Memory map of processor mode

Fig. 2.4.1 Memory map of processor mode related register

2.4.2 Related register

Fig. 2.4.2 Structure of CPU mode register 003B16 CPU mode register (CPUM) CPU mode register (CPUM) [Adress : 3B16 ] Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “0.” CPU mode register Processor mode bits 00 : Single-chip mode 01 : Memory expansion mode 10 : Microprocessor mode 11 : Not available Stack page selection bit 0 : 0 page 1 : 1 page [ An initial value of bit 1 is determined by a level of the CNV SS pin. At resetB Name Function RW b7 b6 b5 b4 b3 b2 b1 b0

2.4.3 Processor mode application examples

(1) Application example of memory expansion in the case where the ONW (One-Wait) function is not used Outline The external memory is accessed in the microprocessor mode. At f(X IN ) = 8 MHz, an available RAM is given by the following : OE access time : ta (OE) 50 ns

  • Setup time for writing data : tsu (D) ns For example, the M5M5256BP-10 whose address access is 100 ns is available. Figure 2.4.3 shows an expansion example of a 32K byte ROM and a 32K byte RAM. Fig. 2.4.3 Expansion example of ROM and RAM 3800 group CNV SS ONW AD AD AD DB DB RD WR M5M27C256AK-10 M5M5256BP-10 CE A D OE A DQ –DQ OE W 8MHz V CC = 5.0V ± 10 % 0000 8000 0440 0040 0008 FFFF External RAM area (M5M5256BP) SFR area Internal RAM area External RAM area (M5M5256BP) External ROM area (M5M27C256AK) Memory map 74F04 S , P3 EPROM SRAM P30

Fig. 2.4.4 Read-cycle (OE access, SRAM) Fig. 2.4.5 Read-cycle (OE access, EPROM) Output enabled access time of M5M5256BP Data bus setup time before RD of 3800 td(AH—RD) RD pulse width of 3800 RD delay time after outputting address of 3800 50 ns (max) 65 ns (min) Address (low-order) A (Port P0) Address (high-order) A 8 –A 14(Port P1) DQ 1 –DQ 8 (Port P2) S(A15) WR “H” level 125 ns - 10 ns (min) 125 ns - 35 ns (min) OE (RD of 3800) td(AH—RD) t WL (RD) ta(OE) tsu(DB—RD) WL (RD) :ta(OE) tsu(DB—RD) RD delay time after outputting address of 3800 Output enabled access time of M5M27C256AK Data bus setup time before RD of 3800 50 ns (max) 65 ns (min) Address (low-order) A 0– A 7(Port P0) Address (high-order) A 8– A 14(Port P1) D 0– D 7 (Port P2) WR “H” level CE 5.8 ns (max) t PHL 125 ns - 10ns (min)125 ns - 35 ns (min) OE (RD of 3800) td(AH—RD) t WL (RD) ta(OE) tsu(DB — RD) RD pulse width of 3800 ta(OE) td(AH — RD) t WL (RD) tsu(DB — RD) t PHL Output delay time of 74F04 Data Data

2-52 3800 GROUP USER’S MANUAL Fig. 2.4.6 Write-cycle (W control, SRAM) td(AH— WR) W (WR of 3800) 65 ns (max) 35 ns (min) Address (low-order) Address (high-order) DataDQ 1–DQ 8 (Port P2) S (A15) OE (RD of 3800) “ H ” level 125 ns - 10 ns (min)125 ns - 35 ns (min) td(AH— WR) tWL (WR) td(WR — DB) tsu(D) :WR delay time after outputting address of 3800 :WR pulse width of 3800tWL (WR) :Data bus delay time after WR of 3800td(WR — DB) :Data setup time of M5M5256BPtsu(D) A0–A7 (Port P0) A8–A14 (Port P1)

(2) Application example of memory expansion in the case where the ONW (One-Wait) function is used Outline ONW function is used when the external memory access is slow. If “L” level signal is input to the P3 ONW pin while the CPU is in the read or write status, the read or write cycle corresponding to 1 cycle of φ is extended. In the extended period, the RD or WR signal is kept at the “L” level. The ONW function operates only when data is read from or written into addresses 0000 to 0007 and addresses 0440 to FFFF Figure 2.4.7 shows an application example of the ONW function. ____ Fig. 2.4.7 Application example of the ONW function 3800 group CNV SS AD 8 P6 ONW AD 14 AD 0 DB 0 DB 7 RD WR M5M27C256AK-10 M5M5256BP-10 CE A A D D OE A A DQ DQ OE W 8MHz VCC = 5.0V ± 10 % External RAM area (M5M5256BP) SFR area Internal RAM area External RAM area (M5M5256BP) External ROM area (M5M27C256AK) 0000 8000 0440 0040 0008 FFFF Memory map 74F04 S

2 P3 0 , P3 1

2.5.1 Connection example of reset IC

Figure 2.5.2 shows the system example which switch to the RAM backup mode by detecting a drop of the system power source voltage with the INT interrupt. Fig. 2.5.1 Example of Poweron reset circuit Fig. 2.5.2 RAM back-up system System power source voltage M62009L, M62009P, M62009FP VCC 1 RESET INT GND CdV1 VCC 2 3800 group VCC INT RESET

40 VSS

400.1 mF Power source GND Delay capacity Output VSS VCC

3.1 Electrical characteristics

3.2 Standard characteristics

3.3 Notes on use

3.4 Countermeasures against noise

3.5 List of registers

3.6 Mask ROM ordering method

3.7 Mark specification form

3.8 Package outline

3.9 List of instruction codes

3.10 Machine instructions

3.11 SFR memory map

3.12 Pin configuration

3.1.1 Absolute maximum ratings

Input voltage P00–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 Input voltage RESET , XIN Input voltage CNV SS Output voltageP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71, XOUT Pow er dissipation Operating temperature Storage temperature VCC VI VI VI VO Pd Topr Tstg Symbol Parameter Conditions Ratings –0.3 to 7.0 –0.3 to VCC +0.3 –0.3 to VCC +0.3 –0.3 to 13 –0.3 to VCC +0.3 1000(Note) –20 to 85 –40 to 125 V V V V V mW Unit Ta = 25 °C All voltages are based on VSS . Output transistors are cut off. Table 3.1.1 Absolute maximum ratings Note : 300 mW in case of the flat package. Table 3.1.2 Recommended operating conditions (VCC = 3.0 to 5.5 V, Ta = –20 to 85 °C, unless otherwise noted)

3.1.2 Recommended operating conditions

Note 1:The minimum power source voltage is [V] (f(XIN) = XMHz) on the condition of 2 MHz < f(XIN) < 8 MHz. 2:The total output current is the sum of all the currents flowing through all the applicable ports. The total average current is an aver- age value measured over 100 ms. The total peak current is the peak value of all the currents. 3:The peak output current is the peak current flowing in each port. 4:The average output current IOL(avg), IOH(avg) in an average value measured over 100 ms. 5.5 5.5 VCC VCC

0.2 VCC

0.16 VCC

–80 –80 –40 –40 –10

6 VCC –16

Power source voltage (Note 1)(f(XIN) ≤ 2 MHz) (f(XIN) = 8 MHz) Power source voltage “H” input voltage P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 “H” input voltage RESET , XIN, CNVSS “L” input voltage P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 “L” input voltage RESET , CNVSS “L” input voltage XIN “H” total peak output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7(Note 2) “H” total peak output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71(Note 2) “L” total peak output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7(Note 2) “L” total peak output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71(Note 2) “H” total average output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7(Note 2) “H” total average output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71(Note 2) “L” total average output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7(Note 2) “L” total average output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71(Note 2) “H” peak output current P00–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71(Note 3) “L” peak output current P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71(Note 3) “H” average output current P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71(Note 4) “L” average output current P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71(Note 4) Internal clock oscillation frequency (4.0 V ≤Vcc≤5.5 V) Internal clock oscillation frequency (3.0 V ≤Vcc≤4.0 V) VCC VSS VIH VIH VIL VIL VIL Σ IOH(peak) Σ IOH(peak) Σ IOL(peak) Σ IOL(peak) Σ IOH(a vg) Σ IOH(avg) Σ IOL(avg) Σ IOL(avg) IOH(peak) IOL(peak) IOH(avg) IOL(avg) f(XIN) Symbol Parameter Limits Min. V V V V V V V mA mA mA mA mA mA mA mA mA mA mA mA MHz Unit 3.0 4.0

0.8 VCC

5.0 5.0 Typ. Max. X+ 16

3-33800 GROUP USER’S MANUAL APPENDIX 2.0 1.0 5.0 5.0 –5.0 5.5 2.0 “H” output voltage P00–P0 7, P10–P1 7, P20–P27, P30–P3 7, P40–P4 7, P50–P57, P60–P6 7, P70, P71 (Note) “L” output voltage P00–P0 7, P10–P1 7, P20–P27, P30–P3 7, P40–P4 7,P50–P5 7, P60–P6 7, P70, P71 Hysteresis CNTR 0, CNTR1, INT0–INT5 Hysteresis R XD, SCLK Hysteresis RESET “H” input current P00–P0 7, P10–P1 7, P20–P27, P30–P3 7, P40–P4 7, P50–P57, P60–P6 7, P70, P71 “H” input current RESET , CNVSS “H” input current XIN “L ” input current P00–P0 7, P10–P1 7, P20–P27, P30–P3 7, P40–P4 7, P50–P57, P60–P6 7, P70, P71 RESET , CNVSS “L ” input current XIN RAM hold voltage Symbol Parameter Limits Min. V Unit Table 3.1.3 Electrical characteristics (VCC = 3.0 to 5.5 V , VSS = 0 V, Ta = –20 to 85 °C, unless otherwise noted)

3.1.3 Electrical characteristics

VCC –2.0 VCC –1.0 0.4 0.5 0.5 6.4 0.8 1.5 0.2 0.1 Typ. Max. IOH = –10 mA VCC = 4.0 to 5.5 V IOH = –1.0 mA VCC = 3.0 to 5.5 V IOL = 10 mA VCC = 4.0 to 5.5 V IOL = 1.0 mA VCC = 3.0 to 5.5 V VI = VCC VI = VCC VI = VCC VI = VSS VI = VSS When clock stopped f(XIN) = 8 MHz, VCC = 5 V f(XIN) = 5 MHz, VCC = 5 V f(XIN) = 2 MHz, VCC = 3 V When WIT instruction is executed with f(XIN) = 8 MHz, VCC = 5 V When WIT instruction is executed with f(XIN) = 5 MHz, VCC = 5 V When WIT instruction is executed with f(XIN) = 2 MHz, VCC = 3 V Test conditions VT+ – VT– VT+ – VT– VT+ – VT– IIH IIH IIH IIL IIL VRAM ICC VOH VOL V V V V µA µA µA µA µA V When STP instruction is executed with clock stopped, output transistors isolated. Note : P4 5 is measured when the P45/TX D P-channel output disable bit of the UART control register (bit 4 of address 001B16) is “0”. Ta = 25 °C Ta = 85 °C 2.0 Power source current mA µ A

Note: When bit 6 of address 001A16 is “1”. Divide this value by four when bit 6 of address 001A16 is “0”. Reset input “L” pulse width External clock input cycle time External clock input “H” pulse width External clock input “L ” pulse width CNTR 0, CNTR1 input cycle time CNTR 0, CNTR1 input “H” pulse width CNTR 0, CNTR1 input “L ” pulse width INT0 to INT5 input “H” pulse width INT0 to INT5 input “L ” pulse width Serial I/O clock input cycle time (Note) Serial I/O clock input “H” pulse width (Note) Serial I/O clock input “L ” pulse width (Note) Serial I/O input set up time Serial I/O input hold time tW(RESET) tc(XIN) tWH(X IN) tWL(X IN) tc(CNTR) tWH(CNTR) tWL(CNTR) tWH(INT) tWL(INT) tc(SCLK ) tWH(S CLK ) tWL(S CLK ) tsu(RX D–S CLK ) th(SCLK –R X D) Symbol Parameter Limits Min. µs ns ns ns ns ns ns ns ns ns ns ns ns ns Unit Table 3.1.4 Timing requirements (1) (VCC = 4.0 to 5.5 V, VSS = 0 V , Ta = –20 to 85 °C, unless otherwise noted)

3.1.4 Timing requirements and Switching characteristics

Typ. Max. Reset input “L” pulse width External clock input cycle time External clock input “H” pulse width External clock input “L” pulse width CNTR 0, CNTR1 input cycle time CNTR 0, CNTR1 input “H” pulse width CNTR 0, CNTR1 input “L ” pulse width INT0 to INT5 input “H” pulse width INT0 to INT5 input “L ” pulse width Serial I/O clock input cycle time (Note) Serial I/O clock input “H” pulse width (Note) Serial I/O clock input “L ” pulse width (Note) Serial I/O input set up time Serial I/O input hold time Symbol Parameter Limits Min. µs ns ns ns ns ns ns ns ns ns ns ns ns ns Unit Table 3.1.5 Timing requirements (2) (VCC = 3.0 to 4.0 V, VSS = 0 V , Ta = –20 to 85 °C, unless otherwise noted) 500/ (3 VCC –8) 200/ (3 VCC –8) 200/ (3 VCC –8) 500 230 230 230 230 2000 950 950 400 200 Typ. Max. Note:When bit 6 of address 001A16 is “1” (clock synchronous mode). Divide this value by four when bit 6 of address 001A16 is “0” (UART mode). tW(RESET) tc(XIN) tWH(X IN) tWL(X IN) tc(CNTR) tWH(CNTR) tWL(CNTR) tWH(INT) tWL(INT) tc(SCLK ) tWH(S CLK ) tWL(S CLK ) tsu(RXD–S CLK ) th(SCLK –R X D)

3-53800 GROUP USER’S MANUAL APPENDIX Serial I/O clock output “H” pulse width Serial I/O clock output “L ” pulse width Serial I/O output delay time (Note 1) Serial I/O output valid time (Note 1) Serial I/O clock output rising time Serial I/O clock output falling time CMOS output rising time (Note 2) CMOS output falling time (Note 2) 140 Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns Unit Table 3.1.6 Switching characteristics (1) (VCC = 4.0 to 5.5 V, VSS = 0 V , Ta = –20 to 85 °C, unless otherwise noted) tc(SCLK )/2–30 tc(SCLK )/2–30 –30 Typ. Max. tWH(S CLK ) tWL(S CLK ) td(SCLK –TX D) tv(SCLK –TXD) tr(SCLK ) tf(SCLK ) tr(CMOS) tf(CMOS) Test conditions Fig. 3.1.1 Note1: When the P45/TX D P-channel output disable bit of the UART control register (bit 4 of address 001B16) is “0”. 2: XOUT pin is excluded. Serial I/O clock output “H” pulse width Serial I/O clock output “L” pulse width Serial I/O output delay time (Note 1) Serial I/O output valid time (Note 1) Serial I/O clock output rising time Serial I/O clock output falling time CMOS output rising time (Note 2) CMOS output falling time (Note 2) 350 Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns Unit Table 3.1.7 Switching characteristics (2) (VCC = 3.0 to 4.0 V, VSS = 0 V, Ta = –20 to 85 °C, unless otherwise noted) tc(SCLK )/2–50 tc(SCLK )/2–50 –30 Typ. Max. tWH(S CLK ) tWL(S CLK ) td(SCLK –TX D) tv(SCLK –TXD) tr(SCLK ) tf(SCLK ) tr(CMOS) tf(CMOS) Test conditions Fig. 3.1.1 Note1: When the P45/TX D P-channel output disable bit of the UART control register (bit 4 of address 001B16) is “0”. 2: XOUT pin is excluded.

Before φ ONW input set up time After φ ONW input hold time Before φ data bus set up time After φ data bus hold time Before RD ONW input set up time Before WR ONW input set up time After RD ONW input hold time After WR ONW input hold time Before RD data bus set up time After RD data bus hold time tsu(ONW– φ) th(φ–ONW) tsu(DB–φ) th(φ–DB) tsu(ONW–RD) tsu(ONW–WR) th(RD–ONW) th(WR–ONW) tsu(DB–RD) th(RD–DB) Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns Unit –20 –20 –20 –20 Typ. Max. 200 200 Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns Unit tc(XIN)–10 tc(XIN)–10 tc(XIN)–10 3tc(XIN)–10 tc(XIN)–35 tc(XIN)–40 2tc(XIN) tc(XIN)–15 tc(XIN)–20 Typ. Max. tc(φ) twH( φ) twL(φ) td(φ–AH) tv(φ–AH) td(φ–AL) tv(φ–AL) td(φ–SYNC) tv(φ–SYNC) td(φ–WR) tv(φ–WR) td(φ–DB) tv(φ–DB) twL(RD) twL(WR) td(AH–RD) td(AH–WR) td(AL–RD) td(AL–WR) tv(RD–AH) tv(WR–AH) tv(RD–AL) tv(WR–AL) td(WR–DB) tv(WR–DB) td(RESET–RESET OUT ) tv(φ–RESET) Test conditions Note :The RESET OUT goes “H” in sync with the fall of the φ clock that is anywhere between about 8 cycle and 13 cycles after the RESET input goes “H”. Fig. 3.1.1 Table 3.1.8Timing requirements in memory expansion mode and microprocessor mode (1) (VCC = 4.0 to 5.5 V, VSS = 0 V, Ta = –20 to 85 °C, unless otherwise noted) Table 3.1.9Switching characteristics in memory expansion mode and microprocessor mode (1) (VCC = 4.0 to 5.5 V, VSS = 0 V, Ta = –20 to 85 °C, unless otherwise noted) φ clock cycle time φ clock “H” pulse width φ clock “L” pulse width After φ AD15–AD 8 delay time After φ AD15–AD 8 valid time After φ AD 7–AD 0 delay time After φ AD7–AD 0 valid time SYNC delay time SYNC v alid time RD and WR delay time RD and WR v alid time After φ data bus delay time After φ data bus valid time RD pulse width, WR pulse width RD pulse width, WR pulse width (When one-wait is valid) After AD15–AD 8 RD delay time After AD15–AD 8 WR delay time After AD7–AD 0 RD delay time After AD7–AD 0 WR delay time After RD AD15–AD 8 valid time After WR AD 15–AD 8 valid time After RD AD7–AD 0 valid time After WR AD 7–AD 0 valid time After WR data bus delay time After WR data bus valid time RESET OUT output delay time RESET OUT output valid time (Note)

3-73800 GROUP USER’S MANUAL APPENDIX Note: The RESET OUT goes “H” in sync with the fall of the φ clock that is anywhere between about 8 cycle and 13 cycles after the RESET input goes “H”. Before φ ONW input set up time After φ ONW input hold time Before φ data bus set up time After φ data bus hold time Before RD ONW input set up time Before WR ONW input set up time After RD ONW input hold time After WR ONW input hold time Before RD data bus set up time After RD data bus hold time tsu(ONW– φ) th(φ–ONW) tsu(DB–φ) th(φ–DB) tsu(ONW –RD) tsu(ONW –WR) th(RD –ONW) th(WR –ONW) tsu(DB–RD ) th(RD –DB) Symbol Parameter Limits Min. ns ns ns ns Unit –20 –20 180 –20 –20 185 Typ. Max. φ clock cycle time φ clock “H” pulse width φ clock “L” pulse width After φ AD15–AD 8 delay time After φ AD15–AD 8 valid time After φ AD 7–AD 0 delay time After φ AD7–AD 0 valid time SYNC delay time SYNC v alid time RD and WR delay time RD and WR v alid time After φ data bus delay time After φ data bus valid time RD pulse width, WR pulse width RD pulse width, WR pulse width (When one-wait is valid) After AD15–AD 8 RD delay time After AD15–AD 8 WR delay time After AD7–AD 0 RD delay time After AD7–AD 0 WR delay time After RD AD15–AD 8 valid time After WR AD 15–AD 8 valid time After RD AD7–AD 0 valid time After WR AD 7–AD 0 valid time After WR data bus delay time After WR data bus valid time RESET OUT output delay time RESET OUT output valid time (Note) 150 150 200 195 300 300 Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns Unit tc(XIN)–20 tc(XIN)–20 tc(XIN)–20 3tc(XIN)–20 tc(XIN)–145 tc(XIN)–145 2tc(XIN) Typ. Max. tc(φ) twH(φ) twL(φ) td(φ–AH) tv(φ–AH) td(φ–AL) tv(φ–AL) td(φ–SYNC) tv(φ–SYNC) td(φ–WR) tv(φ–WR) td(φ–DB) tv(φ–DB) twL(RD) twL(WR) td(AH–RD) td(AH–WR) td(AL–RD) td(AL–WR) tv(RD–AH) tv(WR–AH) tv(RD–AL) tv(WR–AL) td(WR–DB) tv(WR–DB) td(RESET–RESET OUT ) tv(φ–RESET) Test conditions Fig. 3.1.1 Table 3.1.10Timing requirements in memory expansion mode and microprocessor mode (2) (VCC = 3.0 V, VSS = 0 V, Ta = –20 to 85 °C, unless otherwise noted) Table 3.1.11Switching characteristics in memory expansion mode and microprocessor mode (2) (VCC = 3.0 V, VSS = 0 V, Ta = –20 to 85 °C, unless otherwise noted) ns ns ns ns ns

3.1.5 Absolute maximum ratings (Extended operating temperature version)

Table 3.1.12 Absolute maximum ratings (Extended operating temperature version) Power source voltage Input voltage P00–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 Input voltage RESET , XIN Input voltage CNV SS Output voltageP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71, XOUT Power dissipation Operating temperature Storage temperature Symbol Parameter Conditions Ratings –0.3 to 7.0 V Unit Ta = 25 °C All voltages are based on VSS . Output transistors are cut off. Note 1:The total output current is the sum of all the currents flowing through all the applicable ports. The total average current is an aver- age value measured over 100 ms. The total peak current is the peak value of all the currents. 2:The peak output current is the peak current flowing in each port. 3:The average output current IOL(avg), IOH(avg) in an average value measured over 100 ms. 5.5Power source voltage Power source voltage “H” input voltage P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 “H” input voltage RESET , XIN, CNVSS “L” input voltage P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 “L” input voltage RESET , CNVSS “L” input voltage XIN “H” total peak output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7 (Note 1) “H” total peak output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71 (Note 1) “L” total peak output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7 (Note 1) “L” total peak output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71 (Note 1) “H” total average output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7 (Note 1) “H” total average output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71 (Note 1) “L” total average output currentP0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7 (Note 1) “L” total average output currentP4 0–P4 7,P50–P5 7, P60–P6 7, P70, P71 (Note 1) “H” peak output current P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 (Note 2) “L” peak output current P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 (Note 2) “H” average output current P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 (Note 3) “L” average output current P0 0–P0 7, P10–P1 7, P20–P2 7, P30–P3 7, P40–P4 7, P50–P5 7, P60–P6 7, P70, P71 (Note 3) Internal clock oscillation frequency VCC VSS VIH VIH VIL VIL VIL Σ IOH(peak) Σ IOH(peak) Σ IOL(peak) Σ IOL(peak) Σ IOH(a vg) Σ IOH(a vg) Σ IOL(avg) Σ IOL(avg) IOH(peak) IOL(peak) IOH(avg) IOL(avg) f(XIN) Symbol Parameter Limits Min. V V Unit Table 3.1.13Recommended operating conditions (Extended operating temperature version) (VCC = 4.0 to 5.5 V, Ta = –40 to 85 °C, unless otherwise noted)

3.1.6 Recommended operating conditions (Extended operating temperature version)

4.0 5.0 Typ. Max. VCC VI VI VI VO Pd Topr Tstg –0.3 to VCC +0.3 –0.3 to VCC +0.3 –0.3 to 13 –0.3 to VCC +0.3 1000(Note) –40 to 85 –65 to 150 V V V V mW –80 –80 –40 –40 –10 V V V V V mA mA mA mA mA mA mA mA mA mA mA mA MHz Note : 300 mW in case of the flat package.

3-93800 GROUP USER’S MANUAL APPENDIX stopped, output transistors isolated. Note : P4 5 is measured when the P45/TX D P-channel output disable bit of the UART control register (bit 4 of address 001B16) is “0”. 2.0 5.0 5.0 –5.0 5.5 “H” output voltage P00–P0 7, P10–P1 7, P20–P27, P30–P3 7, P40–P4 7, P50–P57, P60–P6 7, P70, P71 (Note) “L” output voltage P00–P0 7, P10–P1 7, P20–P27, P30–P3 7, P40–P4 7,P50–P5 7, P60–P6 7, P70, P71 Hysteresis CNTR 0, CNTR1, INT0–INT5 Hysteresis R XD, SCLK Hysteresis RESET “H” input current P00–P0 7, P10–P1 7, P20–P27, P30–P3 7, P40–P4 7, P50–P57, P60–P6 7, P70, P71 “H” input current RESET , CNVSS “H” input current XIN “L ” input currentP00–P07, P10–P17, P20–P27, P30–P37, P40–P47, P50–P57, P60–P67, P70, P71, RESET, CNV SS “L ” input current XIN RAM hold voltage Symbol Parameter Limits Min. Unit Table 3.1.14 Electrical characteristics (Extended operating temperature version) (VCC = 4.0 to 5.5 V, VSS = 0 V , Ta = –40 to 85 °C, unless otherwise noted)

3.1.7 Electrical characteristics (Extended operating temperature version)

VCC –2.0 0.4 0.5 0.5 6.4 1.5 0.1 Typ. Max. IOH = –10 mA IOL = 10 mA VI = VCC VI = VCC VI = VCC VI = VSS VI = VSS When clock stopped f(XIN) = 8 MHz f(XIN) = 5 MHz When WIT instruction is executed with f(XIN) = 8 MHz When WIT instruction is executed with f(XIN) = 5 MHz Ta = 25 °C Ta = 85 °C 2.0 Test conditions VT+ – VT– VT+ – VT– VT+ – VT– IIH IIH IIH IIL IIL VRAM ICC VOH VOL V V V V V µA µA µA µA µA V Power source current mA µA

3.1.8 Timing requirements and Switching characteristics (Extended operating temperature version)

Note: Bit 6 of address 001A16 is “1”. Divide this value by four bit 6 of address 001A16 is “0”. Reset input “L” pulse width External clock input cycle time External clock input “H” pulse width External clock input “L ” pulse width CNTR 0, CNTR1 input cycle time CNTR 0, CNTR1 input “H” pulse width CNTR 0, CNTR1 input “L ” pulse width INT0 to INT5 input “H” pulse width INT0 to INT5 input “L ” pulse width Serial I/O clock input cycle time (Note) Serial I/O clock input “H” pulse width (Note) Serial I/O clock input “L ” pulse width (Note) Serial I/O input set up time Serial I/O input hold time tW(RESET) tc(XIN) tWH(X IN) tWL(X IN) tc(CNTR) tWH(CNTR) tWL(CNTR) tWH(INT) tWL(INT) tc(SCLK ) tWH(S CLK ) tWL(S CLK ) tsu(RX D–S CLK ) th(SCLK –R X D) Symbol Parameter Limits Min. µs ns ns ns ns ns ns ns ns ns ns ns ns ns Unit 125 200 800 370 370 220 100 Typ. Max. Table 3.1.15Timing requirements (Extended operating temperature version) (VCC = 4.0 to 5.5 V, VSS = 0 V, Ta = –40 to 85 °C, unless otherwise noted) Serial I/O clock output “H” pulse width Serial I/O clock output “L ” pulse width Serial I/O output delay time (Note 1) Serial I/O output valid time (Note 1) Serial I/O clock output rise time Serial I/O clock output fall time CMOS output rise time (Note 2) CMOS output fall time (Note 2) 140 Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns Unit tc(SCLK )/2–30 tc(SCLK )/2–30 –30 Typ. Max. tWH(S CLK ) tWL(S CLK ) td(SCLK –TX D) tv(SCLK –TXD) tr(SCLK ) tf(SCLK ) tr(CMOS) tf(CMOS) Test conditions Fig. 3.1.1 Note1: When the P45/TX D P-channel output disable bit of the UART control register (bit 4 of address 001B16) is “0”. 2: XOUT pin is excluded. Table 3.1.16Switching characteristics (Extended operating temperature version) (VCC = 4.0 to 5.5 V, VSS = 0 V, Ta = –40 to 85 °C, unless otherwise noted)

3-113800 GROUP USER’S MANUAL APPENDIX Table 3.1.17 Timing requirements in memory expansion mode and microprocessor mode (Extended operating temperature version) (VCC = 4.0 to 5.5 V, VSS = 0 V, Ta = –40 to 85 °C, unless otherwise noted) Table 3.1.18 Switching characteristics in memory expansion mode and microprocessor mode (Extended operating temperature version) (VCC = 4.0 to 5.5 V, VSS = 0 V, Ta = –40 to 85 °C, unless otherwise noted) Before φ ONW input set up time After φ ONW input hold time Before φ data bus set up time After φ data bus hold time Before RD ONW input set up time Before WR ONW input set up time After RD ONW input hold time After WR ONW input hold time Before RD data bus set up time After RD data bus hold time tsu(ONW– φ) th(φ–ONW) tsu(DB–φ) th(φ–DB) tsu(ONW –RD) tsu(ONW –WR) th(RD –ONW) th(WR –ONW) tsu(DB–RD ) th(RD –DB) Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns Unit –20 –20 –20 –20 Typ. Max. φ clock cycle time φ clock “H” pulse width φ clock “L ” pulse width After φ AD15–AD 8 delay time After φ AD15–AD 8 valid time After φ AD 7–AD 0 delay time After φ AD7–AD 0 valid time SYNC delay time SYNC valid time RD and WR delay time RD and WR valid time After φ data bus delay time After φ data bus valid time RD pulse width, WR pulse width RD pulse width, WR pulse width (When one-wait is valid) After AD 15–AD 8 RD delay time After AD15–AD 8 WR delay time After AD7–AD 0 RD delay time After AD7–AD 0 WR delay time After RD AD15–AD 8 valid time After WR AD15–AD 8 valid time After RD AD7–AD 0 valid time After WR AD7–AD 0 valid time After WR data bus delay time After WR data bus valid time RESET OUT output delay time RESET OUT output valid time (Note) 200 200 Symbol Parameter Limits Min. ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns Unit tc(XIN)–10 tc(XIN)–10 t c(XIN)–10 3tc(XIN)–10 tc(XIN)–35 tc(XIN)–40 c(XIN) tc(XIN)–15 tc(XIN)–20 Typ. Max. Test conditions Note : The RESET OUT output goes “H” in sync with the fall of the φ clock that is anywhere between about 8 cycle and 13 cycles after the RESET input goes “H”. Fig. 3.1.1 tc(φ) twH(φ) twL(φ) td(φ–AH) tv(φ–AH) td(φ–AL) tv(φ–AL) td(φ–SYNC) tv(φ–SYNC) td(φ–WR) tv(φ–WR) td(φ–DB) tv(φ–DB) twL(RD) twL(WR) td(AH–RD) td(AH–WR) td(AL–RD) td(AL–WR) tv(RD–AH) tv(WR–AH) tv(RD–AL) tv(WR–AL) td(WR–DB) tv(WR–DB) td(RESET–RESET OUT ) tv(φ–RESET) Fig. 3.1.1 Circuit for measuring output switching characteristics Measurement output pin 100pF CMOS output

3.1.9 Timing diagram

Fig. 3.1.2 Timing diagram (in single-chip mode) tWL(INT) tWH(INT) tWL(X IN) tWH(X IN) tC(XIN) XIN tW(RESET) RESET tf tr tWL(CNTR) tWH(CNTR) tC(CNTR) td(SCLK -TXD) tv(SCLK -TXD) tC(SCLK ) tWL(S CLK ) tWH(S CLK ) th(SCLK-R XD)tsu(SCLK-R XD) TXD R XD SCLK INT0–INT5 CNTR 0, CNTR1

3-133800 GROUP USER’S MANUAL APPENDIX Timing Diagram in Memory Expansion Mode and Microprocessor Mode (1) Fig. 3.1.3 Timing diagram (in memory expansion mode and microprocessor mode) (1) Timing Diagram in Microprocessor Mode tWL( f)tWH( f) tC(f) f td(f-AH) td(f-AL) td(f-SYNC) tv(f-AH) tv(f-AL) tv(f-SYNC) td(f-WR) tv(f-WR) tSU(ONW- f) th(f-ONW) tSU(DB- f) th(f-DB) td(f-DB) tv(f-DB) td(RESET- RESET OUT ) AD 15–AD 8 AD 7–AD 0 SYNC RD,WR ONW DB 0–DB 7 DB 0–DB 7 RESET f RESET OUT tv(f- RESETOUT )

0.5 VCC

(At CPU reading) (At CPU writing)

Timing Diagram in Memory Expansion Mode and Microprocessor Mode (2) Fig. 3.1.4 Timing diagram (in memory expansion mode and microprocessor mode) (2)

0.5 VCCRD,WR

0.5 VCCAD 15–AD 8

td(AH-WR) tv(WR-AH)

0.5 VCCAD 7–AD 0

td(AL-WR) tv(WR-AL)

0.2 VCCDB 0–DB 7

0.5 VCCRD

tSU(DB-RD) th(RD-DB)

0.5 VCCDB 0–DB 7

0.5 VCCWR

td(WR-DB) tv(WR-DB) th(WR-ONW) ONW tsu(ONW-WR) tv(RD-AH)td(AH-RD) td(AL-RD) tv(RD-AL) th(RD-ONW)tsu(ONW-RD) tWL(RD) tWL(WR) (At CPU reading) (At CPU writing) tWL(RD) tWL(WR)

3-153800 GROUP USER’S MANUAL

3.2.1 Power source current characteristic examples

Fig. 3.2.1 Power source current characteristic example [Measuring condition : 25 °C] Fig. 3.2.2 Power source current characteristic example (in wait mode) [Measuring condition : 25 °C] Rectangular waveform 84321 567 Vcc = 5.5 V, Ta = 25 Vcc = 4.0 V, Ta = 25 Power source current (mA) Vcc = 3.0 V, Ta = 25 Frequency f(XIN) (MHz) 84321 56 7 Rectangular waveform Power source current (mA) Frequency f(XIN) (MHz) Vcc = 4.0 V, Ta = 25 Vcc = 3.0 V, Ta = 25 Vcc = 5.5 V, Ta = 25

3-16 3800 GROUP USER’S MANUAL APPENDIX

3.2.2 Port standard characteristic examples

Fig. 3.2.3 Standard characteristic example of CMOS output port at P-channel drive (1) [Port P00 IOH –V OH characteristic (P-channel drive)] Fig. 3.2.4 Standard characteristic example of CMOS output port at P-channel drive (2) [Port P00 IOH –V OH characteristic (P-channel drive)] (Pins with same characteristic : P0, P1, P2, P3, P4, P5, P6, P7) (Pins with same characteristic : P0, P1, P2, P3, P4, P5, P6, P7) VOH (V) IOH (mA) 0.5 – 5 – 10 – 15 – 20 – 25 – 30 – 35 – 40 – 45 – 50 5.5 Vcc = 5.0 V, Ta = 25 Vcc = 4.0 V, Ta = 25 Vcc = 3.0 V, Ta = 25 VOH (V) IOH (mA) 0.5 – 5 – 10 – 15 – 20 – 25 – 30 – 35 – 40 – 45 – 50 5.5 Vcc = 4.0 V, Ta = 90 Vcc = 5.0 V, Ta = 90 Vcc = 3.0 V, Ta = 90

3-173800 GROUP USER’S MANUAL Fig. 3.2.5 Standard characteristic example of CMOS output port at N-channel drive (1) [Port P00 IOL –VOL characteristic (N-channel drive)] Fig. 3.2.6 Standard characteristic example of CMOS output port at N-channel drive (2) [Port P00 IOL –VOL characteristic (N-channel drive)] (Pins with same characteristic : P0, P1, P2, P3, P4, P5, P6, P7) (Pins with same characteristic : P0, P1, P2, P3, P4, P5, P6, P7) VOL (V) IOL (mA) 0.5 50 Vcc = 5.0 V, Ta = 90 Vcc = 4.0 V, Ta = 90 Vcc = 3.0 V, Ta = 90 VOL (V) IOL (mA) 0.5 Vcc = 5.0 V, Ta = 25 Vcc = 4.0 V, Ta = 25 Vcc = 3.0 V, Ta = 25

3800 GROUP USER’S MANUAL3-18

(1) Sequence for switching an external interrupt detection edge Clear an interrupt enable bit to “0” (interrupt disabled) Switch the detection edge Clear an interrupt request bit to “0” (no interrupt requ- est issued) Set the interrupt enable bit to “1” ( interrupt enabled )

3.3.1 Notes on interrupts

When the external interrupt detection edge must be switched, make sure the following sequence. Reason The interrupt circuit recognizes the switching of the detection edge as the change of external input signals. This may cause an unnecessary interrupt. (2) Bits 7 and 6 of the interrupt control register 2 Fix the bits 7 and 6 of the interrupt control register 2 (Address:003F 16) to “0”. Figure 3.3.1 shows the structure of the interrupt control register 2. Fig. 3.3.1 Structure of interrupt control register 2

3.3.2 Notes on the serial I/O

(1) Stop of data transmission As for the serial I/O that can be used as either a clock synchronous or an asynchronous (UART) serial I/O, clear the transmit enable bit to “0” (transmit disabled), and clear the serial I/O enable bit to “0” (serial I/O disabled)in the following cases : l when stopping data transmission during transmitting data in the clock synchronous serial I/O mode l when stopping data transmission during transmitting data in the UART mode l when stopping only data transmission during transmitting and receiving data in the UART mode Reason Since transmission is not stopped and the transmission circuit is not initialized even if the serial I/O enable bit is cleared to “0” (serial I/O disabled), the internal transmission is running (in this case, since pins TxD, RxD, S CLK , and SRDY function as I/O ports, the transmission data is not output). When data is written to the transmit buffer register in this state, the data is transferred to the transmit shift register and start tp be sjifted. When the serial I/O enable bit is set to “1” at this time, the data during internally shifting is output to the TxD pin and ti may cause an operation failure to a microcomputer. (2) Stop of data reception As for the serial I/O that can be used as either a clock synchronous or an asynchronous (UART) serial I/O, clear the receive enable bit to “0” (receive disabled), or clear the serial I/O enable bit to “0” (serial I/O disabled) in the following case : l when stopping data reception during receiving data in the clock synchronous serial I/O mode Clear the receive enable bit to “0” (receive disabled) in the following cases : l when stopping data reception during receiving data in the UART mode l when stopping only data reception during transmitting and receiving data in the UART mode b7 b0 Interrupt control register 2 Address 003F16 Interrupt enable bits Not used Fix these bits to “0”. 0 0

3800 GROUP USER’S MANUAL 3-19

(3) Stop of data transmission and reception in a clock synchronous serial I/O mode As for the serial I/O that can be used as either a clock synchronous or an asynchronous (UART) serial I/O, clear both the transmit enable bit and receive enable bit to “0” (transmit and receive disabled) at the same time in the following case: l when stopping data transmission and reception during transmitting and receiving data in the clock synchronous mode (when data is transmitted and received in the clock synchronous serial I/O mode, any one of data transmission and reception cannot be stopped.) Reason In the clock synchronous serial I/O mode, the same clock is used for transmission and reception. If any one of transmission and reception is disabled, a bit error occurs because transmission and reception cannot be synchronized. In this mode, the clock circuit of the transmission circuit also operates for data reception. Accordingly, the transmission circuit does not stop by clearing only the transmit enable bit to “0” (transmit disabled). Also, the transmission circuit is not initialized by clearing the serial I/O enable bit to “0” (serial I/O disabled) (refer to (1)). (4) The S RDY pin on a receiving side When signals are output from the SRDY pin on the reception side by using an external clock in the clock synchronous serial I/O mode, set all of the receive enable bit, the SRDY output enable bit, and the transmit enable bit to “1” (transmit enabled). (5) Stop of data reception in a clock synchronous serial I/O mode Set the serial I/O control register again after the transmission and the reception circuits are reset by clearing both the transmit enable bit and the receive enable bit to “0.” Clear both the transmit enable bit (TE) and the receive enable bit (RE) to “0” Set the bits 0 to 3 and bit 6 of the serial I/O control register Set both the transmit enable bit (TE) and the receive enable bit (RE) to “1” Can be set with the LDM instruction at the same time (6) Control of data transmission using the transmit shift completion flag The transmit shift completion flag changes from “1” to “0” with a delay of 0.5 to 1.5 shift clocks. When checking the transmit shift completion flag after writing a data to the transmit buffer register for controlling a data transmission, note this delay. (7) Control of data transmission using an external clock When an external clock is used as the synchronous clock for data transmission, set the transmit enable bit to “1” at “H” level of the S CLK input signal. Also, write data to the transmit buffer register at “H” level of the SCLK input signal.

3.3.3 Notes on the RESET pin

When a rising time of the reset signal is long, connect a ceramic capacitor or others across the RESET pin and the VSS pin. And use a 1000 pF or more capacitor for high frequency use. When connecting the capacitor, make sure the following : l Make the length of the wiring which is connected to a capacitor the shortest possible. l Make sure to check the operation of application products on the user side. Reason If the several nanosecond or several ten nanosecond impulse noise enters the RESET pin, a microcomputer may malfunction.

3800 GROUP USER’S MANUAL3-20

3.3.4 Notes on input and output pins

(1) Fix of a port input level in stand-by state Fix input levels of an input and an I/O port for getting effect of low-power dissipation in stand-by state*, especially for the I/O ports of the N-channel open-drain. Pull-up (connect the port to V CC ) or pull-down (connect the port to VSS ) these ports through a resistor. When determining a resistance value, make sure the following: l External circuit l Variation of output levels during the ordinary operation * stand-by state : the stop mode by executing the STP instruction the wait mode by executing the WIT instruction Reason Even when setting as an output port with its direction register, in the following state : the transistor becomes the OFF state, which causes the ports to be the high-impedance state. Make sure that the level becomes “undefined” depending on external circuits. Accordingly, the potential which is input to the input buffer in a microcomputer is unstable in the state that input levels of an input and an I/O port are “undefined.” This may cause power source current. (2) Modify of the content of I/O port latch When the content of the port latch of an I/O port is modified with the bit managing instruction*, the value of the unspecified bit may be changed. Reason The bit managing instruction is read-modify-write instruction for reading and writing data by a byte unit. Accordingly, when this instruction is executed on one bit of the port latch of an I/O port, the following is executed to all bits of the port latch. l As for a bit which is set as an input port : The pin state is read in the CPU, and is written to this bit after bit managing. l As for a bit which is set as an output port : The bit value is read in the CPU, and is written to this bit after bit managing. Make sure the following : l Even when a port which is set as an output port is changed for an input port, its port latch holds the output data. l Even when a bit of a port latch which is set as an input port is not speccified with a bit managing instruction, its value may be changed in case where content of the pin differs from a content of the port latch. * bit managing instructions : SEB and CLB instruction

3800 GROUP USER’S MANUAL 3-21

3.3.5 Notes on memory expansion mode and microprocessor mode

(1) Writing data to the port latch of port P3 In the memory expansion or the microprocessor mode, ports P30 and P31 can be used as the output port. Use the LDM or STA instruction for writing data to the port latch (address 000616) of port P3. When using a read-modify-write instruction (the SEB or the CLB instruction), allocate the read and the write enabled memory at address 000616. Reason In the memory expansion or microprocessor mode, address 000616 is allocated in the external area. Accordingly, l Data is read from the external memory. l Data is written to both the port latch of the port P3 and the external memory. Accordingly, when executing a read-modify-write instruction for address 000616, external memory data is read and modified, and the result is written in both the port latch of the port P3 and the external memory. If the read enabled memory is not allocated at address 000616, the read data is undefined. The undefined data is modified and written to the port latch of the port P3. The port latch data of port P3 becomes “undefined.” (2) Overlap of an internal memory and an external memory When the internal and the external memory are overlapped in the memory expansion mode, the internal memory is valid in this overlapped area. When the CPU writes or reads to this area, the following is performed : l When reading data Only the data in the internal memory is read into the CPU and the data in the external memory is not read into the CPU. However, as the read signal and address are still valid, the external memory data of the corresponding address is output to the external data bus. l When writing data Data is written in both the internal and the external memory.

3800 GROUP USER’S MANUAL3-22

(2) Write and read In PROM mode, operation is the same as that of the M5M27C256AK, but programming conditions of PROM programmer are not set automatically because there are no internal device ID codes. Accurately set the following conditions for data write/read. Take care not to apply 21 V to Vpp pin (is also used as the CNV SS pin), or the product may be permanently damaged. l Programming voltage : 12.5 V l Setting of programming adapter switch : refer to table 3.3.2 l Setting of PROM programmer address : refer to table 3.3.3 Table 3.3.2 Setting of programming adapter switch SW 1 CMOS SW 2 CMOS SW 3 OFF Programming adapter PCA4738S-64A PCA4738L-64A PCA4738F-64A Microcomputer M38002E4SS M38004E8SS M38002E2SP M38002E4SP M38004E8SP (one-time blank) M38002E4DSP (one-time blank) M38002E4FS M38004E8FS M38002E2FP M38002E4FP M38004E8FP (one-time blank) M38002E4DFP (one-time blank)

3.3.6 Notes on built-in PROM

(1) Programming adapter To write or read data into/from the internal PROM, use the dedicated programming adapter and general-purpose PROM programmer as shown in Table 3.3.1. Table 3.3.1 Programming adapter Programming adapter PCA4738S-64A PCA4738L-64A PCA4738F-64A

3800 GROUP USER’S MANUAL 3-23

Table 3.3.3 Setting of PROM programmer address PROM programmer start address Address : 608016 (Note 1) Address : 408016 (Note 2) Address : 008016 (Note 3) Microcomputer M38002E2SP M38002E2FP M38002E4SS M38002E4SP M38002E4FS M38002E4FP M38002E4DSP M38002E4DFP M38004E8SS M38004E8SP M38004E8FS M38004E8FP PROM programmer completion address Address : 7FFD16 (Note 1) Address : 7FFD16 (Note 2) Address : 7FFD16 (Note 3) Note1 : Addresses E08016 to FFFD16 in the internal PROM correspond to addresses 608016 to 7FFD16 in the ROM programmer. 2 : Addresses C08016 to FFFD16 in the internal PROM correspond to addresses 408016 to 7FFD16 in the ROM programmer. 3 : Addresses 808016 to FFFD16 in the internal PROM correspond to addresses 008016 to 7FFD16 in the ROM programmer. (3) Erasing Contents of the windowed EPROM are erased through an ultraviolet light source of the wavelength 2537- Angstrom . At least 15 W-sec/cm are required to erase EPROM contents.

3.4 Countermeasures against noise

Countermeasures against noise are described below. The following countermeasures are effective against noise in theory, however, it is necessary not only to take measures as follows but to evaluate before actual use.

3.4.1 Shortest wiring length

The wiring on a printed circuit board can be as an antenna which feeds noise into the microcomputer. The shorter the total wiring length (by mm unit), the less the possibility of noise insertion into a microcomputer. (1) Wiring for the RESET pin Make the length of wiring which is connected to the RESET pin as short as possible. Especially, connect a capacitor across the RESET pin and the V SS pin with the shortest possible wiring (within 20mm). Reason The reset works to initialize a microcomputer. The width of a pulse input into the RESET pin is determined by the timing necessary conditions. If noise having a shorter pulse width than the standard is input to the RESET pin, the reset is released before the internal state of the microcomputer is completely initialized. This may cause a program runaway. Fig. 3.4.1 Wiring for the RESET pin (2) Wiring for clock input/output pins l Make the length of wiring which is connected to clock I/O pins as short as possible. l Make the length of wiring (within 20mm) across the grounding lead of a capacitor which is connected to an oscillatorand the V SS pin of a microcomputer as short as possible. l Separate the V SS pattern only for oscillation from other V SS patterns. Reason A microcomputer's operation synchronizes with a clock generated by the oscillator (circuit). If noise enters clock I/O pins, clock waveforms may be deformed. This may cause a malfunction or program runaway. Also, if a potential difference is caused by the noise between the V SS level of a microcomputer and the V SS level of an oscillator, the correct clock will not be input in the microcomputer. RESET Reset circuit Noise V SS V SS Reset circuit V SS RESET V SS 3800 group 3800 group N.G. O.K.

3800 GROUP USER’S MANUAL 3-25

Fig. 3.4.2 Wiring for clock I/O pins (3) Wiring for the VPP pin of the One Time PROM version and the EPROM version (In this microcomputer the VPP pin is also used as the CNVSS pin) Connect an approximately 5 kΩ resistor to the VPP pin the shortest possible in series and also to the VSS pin. When not connecting the resistor, make the length of wiring between the VPP pin and the VSS pin the shortest possible. Note:Even when a circuit which inclued an approximately 5 kΩ resistor is used in the Mask ROM version, the maicrocomputer operates correctly. Reason The VPP pin of the One Time PROM and the EPROM version is the power source input pin for the built-in PROM. When programming in the built-in PROM, the impedance of the V PP pin is low to allow the electric current for wiring flow into the PROM. Be- cause of this, noise can enter easily. If noise enters the V PP pin, abnormal in struction codes or data are read from the built-in PROM, which may cause a program runaway.

3.4.2 Connection of a bypass capacitor across the

Connect an approximately 0.1 µF bypass capacitor across the VSS line and the VCC line as follows: l Connect a bypass capacitor across the VSS pin and the VCC pin at equal length . l Connect a bypass capacitor across the VSS pin and the VCC pin with the shortest possible wiring. l Use lines with a larger diameter than other signal lines for VSS line and VCC line. Fig. 3.4.3 Wiring for the VPP pin of the One Time PROM and the EPROM version Fig. 3.4.4 Bypass capacitor across the VSS line and the VCC line /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines VSS VCC /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines VSSVCC Chip /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines /LiteDiagLines XIN XOUT VSS An example of VSS patterns on the underside of a printed circuit board Oscillator wiring pattern example Separate the V SS line for oscillation from other VSS lines Noise XIN XOUT VSS XIN XOUT VSS N.G. O.K. CNV SS /VPP Approximately 5kΩ 3800 group VSS Make it the shortest possible

3800 GROUP USER’S MANUAL3-26

3.4.3. Consideration for oscillator Take care to prevent an oscillator that generates clocks for a microcomputer operation from being affected by other signals. (1) Keeping an oscillator away from large current signal lines Install a microcomputer (and especially an oscillator) as far as possible from signal lines where a current larger than the tolerance of current value flows. Reason In the system using a microcomputer, there are signal lines for controlling motors, LEDs, and thermal heads or others. When a large current flows through those signal lines, strong noise occurs because of mutual inductance. (2) Keeping an oscillator away from signal lines where potential levels change frequently Install an oscillator and a connecting pattern of an osillator away from signal lines where potential levels change frequently. Also, do not cross such signal lines over the clock lines or the signal lines which are sensitive to noise. Reason Signal lines where potential levels change frequently (such as the CNTR pin line) may affect other lines at signal rising or falling edge. If such lines cross over a clock line, clock waveforms may be deformed, which causes a microcomputer failure or a program runaway.

3.4.4 Setup for I/O ports

Setup I/O ports using hardware and software as follows: <Hardware> l Connect a resistor of 100 Ω or more to an I/O port inseries. <Software> l As for an input port, read data several times by a program for checking whether input levels are equal or not. l As for an output port, since the output data may reverse because of noise, rewrite data to its port latch at fixed periods. l Rewirte data to direction registers and pull-up control registers (only the product having it) at fixed periods. Fig.3.4.5 Wiring for a large current signal line Fig.3.4.6 Wiring to a signal line where potential levels change frequently XIN XOUT VSS M Microcomputer Mutual inductance Large current GND XIN XOUT VSS CNTRDo not cross Fig. 3.4.7 Setup for I/O ports Direction register Port latch Data bus I/O port pins Noise Noise N.G. O.K. When a direction register is set for input port again at fixed periods, a several-nanosecond short pulse may be output from this port. If this is undesirable, connect a capacitor to this port to remove the noise pulse.

3800 GROUP USER’S MANUAL 3-27

3.4.5 Providing of watchdog timer function by

If a microcomputer runs away because of noise or others, it can be detected by a software watchdog timer and the microcomputer can be reset to normal operation. This is equal to or more effective than program runaway detection by a hardware watchdog timer. The following shows an example of a watchdog timer provided by software. In the following example, to reset a microcomputer to normal operation, the main routine detects errors of the interrupt processing routine and the interrupt processing routine detects errors of the main routine. This example assumes that interrupt processing is repeated multiple times in a single main routine processing. <The main routine> l Assigns a single byte of RAM to a software watchdog timer (SWDT) and writes the initial value N in the SWDT once at each execution of the main routine. The initial value N should satisfy the following condition: Fig. 3.4.8 Watchdog timer by software N+1 ≥ (Counts of interrupt processing executed in each main routine) As the main routine execution cycle may change because of an interrupt processing or others, the initial value N should have a margin. l Watches the operation of the interrupt processing routine by comparing the SWDT contents with counts of interrupt processing count after the initial value N has been set. l Detects that the interrupt processing routine has failed and determines to branch to the program initialization routine for recovery processing in the following cases: If the SWDT contents do not change after interrupt processing <The interrupt processing routine> l Decrements the SWDT contents by 1 at each interrupt processing. l Determins that the main routine operates normally when the SWDT contents are reset to the initial value N at almost fixed cycles (at the fixed interrupt processing count). l Detects that the main routine has failed and determines to branch to the program initialization routine for recovery processing in the following case: When the contents of the SWDT reach 0 or less by continuative decrement without initializing to the initial value N . Main routine (SWDT) ← N CLI Main processing (SWDT) Interrupt processing routine errors Interrupt processing routine (SWDT) ← (SWDT)—1 Interrupt processing (SWDT) Main routine errors ≤0 RTI Return =N? ≤0?

3800 GROUP USER’S MANUAL3-28

Fig. 3.5.2 Structure of Port Pi direction register (i = 0, 1, 2, 3, 4, 5, 6, 7) Fig. 3.5.1 Structure of Port Pi (i = 0, 1, 2, 3, 4, 5, 6, 7) Port Pi b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Name Port Pi0 Port Pi1 Port Pi2 Port Pi3 Port Pi4 Port Pi5 Port Pi6 Port Pi7 In output mode Write Read l Port latch In input mode Write : Port latch Read : Value of pins l [Address : 0016, 0216, 0416, 0616, 0816, 0A16, 0C16, 0E16] Note : (Note) Port P7 register [Address : 0E16] Port P7 is a 2-bit port (P70, P71). Accordingly, when bits 2 to 7 are read out, the contents are “0.” Port Pi direction register b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Name Port Pi direction register 0 Port Pi direction register (PiD) (i =0, 1, 2, 3, 4, 5, 6, 7) [Address : 0116, 0316, 0516, 0716, 0916, 0B16, 0D16, 0F16] 0 : Port Pi0 input mode 1 : Port Pi0 output mode 0 : Port Pi1 input mode 1 : Port Pi1 output mode 0 : Port Pi2 input mode 1 : Port Pi2 output mode 0 : Port Pi3 input mode 1 : Port Pi3 output mode 0 : Port Pi4 input mode 1 : Port Pi4 output mode 0 : Port Pi5 input mode 1 : Port Pi5 output mode 0 : Port Pi6 input mode 1 : Port Pi6 output mode 0 : Port Pi7 input mode 1 : Port Pi7 output mode Note : (Note) Port P7 direction register [Address : 0F 16] Port P7 is a 2-bit port (P70, P71). Accordingly, these bits do not have a direction register function. (Note) (Note) (Note) (Note) (Note)

3800 GROUP USER’S MANUAL 3-29

Fig. 3.5.3 Structure of Transmit/Receive buffer register Fig. 3.5.4 Structure of Serial I/O status register Transmit/Receive buffer register b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Transmit/Receive buffer register (TB/RB) [Address : 1816] A transmission data is written to or a receive data is read out from this buffer register.

  • At writing : a data is written to the Transmit buffer register.
  • At reading : a content of the Receive buffer register is read out. 5 ? Note :A content of the Transmit buffer register cannot be read out. A data cannot be written to the Receive buffer register. b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Serial I/O status reigster (SIOSTS) [Address : 1916] Name Transmit buffer empty flag (TBE) 0 : (OE) (PE) (FE) = 0 1 : (OE) (PE) (FE) = 1 Overrun error flag (OE) 0 : Buffer full 1 : Buffer empty Nothing is allocated for this bit. It is a write disabled bit. When this bit is read out, the value is “0.” Receive buffer full flag (RBF) Transmit shift register shift completion flag (TSC) Parity error flag (PE) Framing error flag (FE) Summing error flag (SE) 0 : Buffer empty 1 : Buffer full 0 : Transmit shift in progress 1 : Transmit shift completed 0 : No error 1 : Overrun error 0 : No error 1 : Parity error 0 : No error 1 : Framing error Serial I/O status register

Serial I/O control register 0 : Transmit buffer empty 1 : Transmit shift operating completion f X I N f X I N Serial I/O synchronous clock selection bit (SCS) At selecting clock synchronous serial I/O 0 : BRG output divided by 4 1 : External clock input At selecting UART 0 : BRG output divided by 16 1 : External clock input divided by 16 Transmit interrupt source selection bit (TIC) S RDY output enable bit (SRDY) I/O port (P47) S RDY output pin At reset B Name Function RW Transmit disabled Transmit enabled Transmit enable bit (TE) Receive enable bit (RE) Receive disabled Receive enabled Serial I/O enable bit (SIOE) Serial I/O mode selection bit (SIOM) UART Clock synchronous serial I/O Serial I/O disabled (P4 –P4 I/O port) Serial I/O enabled (P4 –P4 Serial I/O function pin) BRG count source selection bit (CSS) Serial I/O control register (SIOCON) [Address : 1A Fig. 3.5.5 Structure of Serial I/O control register Fig. 3.5.6 Structure of UART control register b7 b6 b5 b4 b3 b2 b1 b0 UART control register (UARTCON) [Address : 1B UART control register Character length selection bit (CHAS) 8 bits bits Parity enable bit (PARE) Parity checking disabled Parity checking enabled Stop bit length selection bit (STPS) 1 stop bit 2 stop bits /TxD P-channel output disable bit (POFF) Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “1.” Parity selection bit (PARS) Even parity Odd parity At resetB Name Function RW In output mode 1 : N-channel open-drain output CMOS output

3800 GROUP USER’S MANUAL 3-31

Fig. 3.5.7 Structure of Baud rate generator Fig. 3.5.8 Structure of Prescaler 12, Prescaler X, Prescaler Y Prescaler 12, Prescaler X, Prescaler Y b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Prescaler 12 (PRE12), Prescaler X (PREX), Prescaler Y (PREY) [Address : 2016, 2416, 2616] The count value of each prescaler is set. The value set in this register is written to both the prescaler and the prescaler latch at the same time. When the prescaler is read out, the value (count value) of the prescaler is read out. l l l B Baud rate generator (BRG) [Address : 1C16] b7 b6 b5 b4 b3 b2 b1 b0 Baud rate generator ?A count value of Baud rate generator is set. Function At reset W R

3800 GROUP USER’S MANUAL3-32

Fig. 3.5.9 Structure of Timer 1 Fig. 3.5.10 Structure of Timer 2, Timer X, Timer Y b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Timer 1 (T1) [Address : 2116] The count value of the Timer 1 is set. The value set in this register is written to both the Timer 1 and the Timer 1 latch at the same time. When the Timer 1 is read out, the value (count value) of the Timer 1 is read out. l l l Timer 1 Timer 2, Timer X, Timer Y b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Timer 2 (T2), Timer X (TX), Timer Y (TY) [Address : 2216, 2516, 2716] The count value of each timer is set. The value set in this register is written to both the Timer and the Timer latch at the same time. When the Timer is read out, the value (count value) of the Timer is read out. l l l

3800 GROUP USER’S MANUAL 3-33

Pulse width measurement mode Table. 3.5.1 Function of CNTR0/CNTR 1 edge switch bit Fig. 3.5.11 Structure of Timer XY mode register Function of CNTR0/CNTR 1 edge switch bit (bits 2 and 6) “0” “1” “0” “1” “0” “1” “0” “1”

  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge (No effect on timer count)
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge (No effect on timer count)
  • Start of pulse output : From “H” level
  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge
  • Start of pulse output : From “L” level
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge
  • Timer X/Timer Y : Count of rising edge
  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge
  • Timer X/Timer Y : Count of falling edge
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge
  • Timer X/Timer Y : Measurement of “H” level width
  • Generation of CNTR 0/CNTR 1 interrupt request : Falling edge
  • Timer X/Timer Y : Measurement of “L” level width
  • Generation of CNTR 0/CNTR 1 interrupt request : Rising edge /LiteDiagLines /LiteDiagLines /LiteDiagLines/LiteDiagLines /LiteDiagLines/LiteDiagLines Function Timer XY mode register b7 b6 b5 b4 b3 b2 b1 b0 B At resetR W Timer XY mode register (TM) Name Timer X operating mode bit CNTR 0 active edge switch bit Timer Y operating mode bit CNTR 1 active edge switch bit 0 0 : Timer mode 0 1 : Pulse output mode 1 0 : Event counter mode 1 1 : Pulse width measurement mode 0 0 : Timer mode 0 1 : Pulse output mode 1 0 : Event counter mode 1 1 : Pulse width measurement mode It depends on the operating mode of the Timer X (refer to Table 3.5.1). It depends on the operating mode of the Timer Y (refer to Table 3.5.1). b5 b4 Timer X count stop bit [Address : 2316] b1 b0 Timer Y count stop bit 0 : Count start 1 : Count stop 0 : Count start 1 : Count stop

Fig. 3.5.12 Structure of Interrupt edge selection register Fig. 3.5.13 Structure of CPU mode register CPU mode register (CPUM) Adress : 3B Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “0.” CPU mode register Processor mode bits 00 : Single-chip mode Memory expansion mode Microprocessor mode Not available Stack page selection bit 0 page 1 page An initial value of bit 1 is determined by a level of the CNV SS pin. At reset B Name Function RW b7 b6 b5 b4 b3 b2 b1 b0 Interrupt edge selection register (INTEDGE) [Address : 3A Interrupt edge selection register INT interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “0.” INT interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active INT interrupt edge selection bit 0 : Falling edge active 1 : Rising edge active At reset B Name Function RW b7 b6 b5 b4 b3 b2 b1 b0

3800 GROUP USER’S MANUAL 3-35

Fig. 3.5.14 Structure of Interrupt request register 1 Fig. 3.5.15 Structure of Interrupt request register 2 [0 : No interrupt request 1 : Interrupt request Serial I/O receive interrupt request bit Serial I/O transmit interrupt request bit Interrupt request register 1 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt request reigster 1 (IREQ1) [Address : 3C16] Name [ “0” is set by software, but not “1.” Timer Y interrupt request bit Timer X interrupt request bit Timer 1 interrupt request bit0 : No interrupt request 1 : Interrupt request Timer 2 interrupt request bit 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request INT0 interrupt request bit INT1 interrupt request bit Interrupt request register 2 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt request reigster 2 (IREQ2) [Address : 3D16] Name CNTR 0 interrupt request bit CNTR 1 interrupt request bit INT2 interrupt request bit 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request 0 : No interrupt request 1 : Interrupt request INT3 interrupt request bit 00 : No interrupt request 1 : Interrupt request Nothing is allocated for these bits. These are write disabled bits. When these bits are read out, the values are “0.” INT5 interrupt request bit [ [ “0” is set by software, but not “1.” 4 00 : No interrupt request 1 : Interrupt request INT4 interrupt request bit [ 7 0 5

3800 GROUP USER’S MANUAL3-36

Fig. 3.5.16 Structure of Interrupt control register 1 Fig. 3.5.17 Structure of Interrupt control register 2 Timer Y interrupt enable bit Interrupt control register 1 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt control register 1 (ICON1) [Address : 3E16] Name INT0 interrupt enable bit INT1 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled Timer X interrupt enable bit Timer 1 interrupt enable bit0 : Interrupt disabled 1 : Interrupt enabled Timer 2 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled Serial I/O transmit interrupt enable bit Serial I/O receive interrupt enable bit Interrupt control register 2 b7 b6 b5 b4 b3 b2 b1 b0 B Function At resetRW Interrupt control reigster 2 (ICON2) [Address : 3F16] Name CNTR 0 interrupt enable bit CNTR 1 interrupt enable bit INT2 interrupt enable bit 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabled 0 : Interrupt disabled 1 : Interrupt enabledINT3 interrupt enable bit 00 : Interrupt disabled 1 : Interrupt enabled Fix these bits to “0.” INT5 interrupt enable bit 4 00 : Interrupt disabled 1 : Interrupt enabled INT4 interrupt enable bit 0 0 7 0

3-373800 GROUP USER’S MANUAL GZZ-SH04-34B<13B0> Receipt

740 FAMILY MASK ROM CONFIRMATION FORM

SINGLE-CHIP MICROCOMPUTER M38002M2-XXXSP/FP MITSUBISHI ELECTRIC Mask ROM number Date: Section head signature Supervisor signature Company name Note : Please fill in all items marked h . Customerh Issuance signatureDate issued Submitted byTEL Date: Supervisor h 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three EPROMs are required for each pattern. If at least two of the three sets of EPROMs submitted contain identical data, we will produce masks based on this data. We shall assume the responsibility for errors only if the mask ROM data on the products we produce differs from this data. Thus, extreme care must be taken to verify the data in the submitted EPROMs. Microcomputer name : 27256 27512 000016 000F16 001016 607F16 608016 7FFD16 7FFE16 7FFF16 M38002M2-XXXSP M38002M2-XXXFP Checksum code for entire EPROM (hexadecimal notation) In the address space of the microcomputer, the internal ROM area is from address E08016 to FFFD16. The reset vector is stored in addresses FFFC16 and FFFD16. (1) Set the data in the unused area (the shaded area of the diagram) to “FF16”. (2) The ASCII codes of the product name “M38002M2–” must be entered in addresses 000016 to 000816. And set the data “FF16” in addresses 000916 to 000F16. The ASCII codes and addresses are listed to the right in hexadecimal notation. Address 0000 000116 000216 000316 000416 000516 000616 000716 ‘M’ = 4D16 ‘3’ = 3316 ‘8’ = 3816 ‘0’ = 3016 ‘0’ = 3016 ‘2’ = 3216 ‘M’ = 4D16 ‘2’ = 3216 Address 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 ‘ – ’ = 2D16 FF16 FF16 FF16 FF16 FF16 FF16 FF16 (1/2) EPROM address EPROM address EPROM type (indicate the type used) 000016 000F16 001016 E07F16 E08016 FFFD16 FFFE16 FFFF16 Product name ASCII code : ‘M38002M2–’ data ROM 8062 bytes Product name ASCII code : ‘M38002M2–’ data ROM 8062 bytes

3-38 3800 GROUP USER’S MANUAL SINGLE-CHIP MICROCOMPUTER M38002M2-XXXSP/FP MITSUBISHI ELECTRIC GZZ-SH04-34B<13B0> Mask ROM number We recommend the use of the following pseudo-command to set the start address of the assembler source program. 27256 27512EPROM type The pseudo-command *=a$8000 .BYTEa ‘M38002M2–’ *=a$0000 .BYTEa ‘M38002M2–’ Note :If the name of the product written to the EPROMs does not match the name of the mask confirmation form, the ROM will not be processed. (2/2) h 2. Mark specification Mark specification must be submitted using the correct form for the package being ordered. Fill out the appropriate mark specification form (64P4B for M38002M2-XXXSP, 64P6N for M38002M2-XXXFP) and attach it to the mask ROM confirmation form. h 3. Usage conditions Please answer the following questions about usage for use in our product inspection : (1) How will you use the X IN-XOUT oscillator? At what frequency? f(X IN) = (2) In which operation mode will you use your microcomputer? h 4. Comments Ceramic resonator External clock input Single-chip mode Microprocessor mode Quartz crystal Other ( ) Memory expansion mode MHz

3-393800 GROUP USER’S MANUAL GZZ-SH04-79B<16A0> Receipt SINGLE-CHIP MICROCOMPUTER M38002M2DXXXSP/FP MITSUBISHI ELECTRIC Mask ROM number Date: Section head signature Supervisor signature Company name Note : Please fill in all items marked h . Customerh Issuance signatureDate issued Submitted byTEL Date: Supervisor h 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three EPROMs are required for each pattern. If at least two of the three sets of EPROMs submitted contain identical data, we will produce masks based on this data. We shall assume the responsibility for errors only if the mask ROM data on the products we produce differs from this data. Thus, extreme care must be taken to verify the data in the submitted EPROMs. Microcomputer name : 27256 27512 000016 000F16 001016 607F16 608016 7FFD16 7FFE16 7FFF16 M38002M2DXXXSP M38002M2DXXXFP Checksum code for entire EPROM (hexadecimal notation) In the address space of the microcomputer, the internal ROM area is from address E08016 to FFFD16. The reset vector is stored in addresses FFFC16 and FFFD16. (1) Set the data in the unused area (the shaded area of the diagram) to “FF16”. (2) The ASCII codes of the product name “M38002M2D” must be entered in addresses 000016 to 000816. And set the data “FF16” in addresses 000916 to 000F16. The ASCII codes and addresses are listed to the right in hexadecimal notation. Address 0000 000116 000216 000316 000416 000516 000616 000716 ‘M’ = 4D16 ‘3’ = 3316 ‘8’ = 3816 ‘0’ = 3016 ‘0’ = 3016 ‘2’ = 3216 ‘M’ = 4D16 ‘2’ = 3216 Address 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 ‘D’ = 4416 FF16 FF16 FF16 FF16 FF16 FF16 FF16 (1/2) EPROM address EPROM address EPROM type (indicate the type used) 000016 000F16 001016 E07F16 E08016 FFFD16 FFFE16 FFFF16 Product name ASCII code : ‘M38002M2D’ data ROM 8062 bytes Product name ASCII code : ‘M38002M2D’ data ROM 8062 bytes

3-40 3800 GROUP USER’S MANUAL SINGLE-CHIP MICROCOMPUTER M38002M2DXXXSP/FP MITSUBISHI ELECTRIC GZZ-SH04-79B<16A0> Mask ROM number We recommend the use of the following pseudo-command to set the start address of the assembler source program. 27256 27512EPROM type The pseudo-command *=a$8000 .BYTEa ‘M38002M2D’ *=a$0000 .BYTEa ‘M38002M2D’ Note :If the name of the product written to the EPROMs does not match the name of the mask confirmation form, the ROM will not be processed. (2/2) h 2. Mark specification Mark specification must be submitted using the correct form for the package being ordered. Fill out the appropriate mark specification form (64P4B for M38002M2DXXXSP, 64P6N for M38002M2DXXXFP) and attach it to the mask ROM confirmation form. h 3. Usage conditions Please answer the following questions about usage for use in our product inspection : (1) How will you use the X IN-XOUT oscillator? At what frequency? f(X IN) = (2) In which operation mode will you use your microcomputer? h 4. Comments Ceramic resonator External clock input Single-chip mode Microprocessor mode Quartz crystal Other ( ) Memory expansion mode MHz

3-413800 GROUP USER’S MANUAL GZZ-SH03-22B<9YB0> Receipt SINGLE-CHIP MICROCOMPUTER M38002M4-XXXSP/FP MITSUBISHI ELECTRIC Mask ROM number Date: Section head signature Supervisor signature Company name Note : Please fill in all items marked h . Customerh Issuance signatureDate issued Submitted byTEL Date: Supervisor h 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three EPROMs are required for each pattern. If at least two of the three sets of EPROMs submitted contain identical data, we will produce masks based on this data. We shall assume the responsibility for errors only if the mask ROM data on the products we produce differs from this data. Thus, extreme care must be taken to verify the data in the submitted EPROMs. Microcomputer name : 27256 27512 000016 000F16 001016 407F16 408016 7FFD16 7FFE16 7FFF16 M38002M4-XXXSP M38002M4-XXXFP Checksum code for entire EPROM (hexadecimal notation) In the address space of the microcomputer, the internal ROM area is from address C08016 to FFFD16. The reset vector is stored in addresses FFFC16 and FFFD16. (1) Set the data in the unused area (the shaded area of the diagram) to “FF16”. (2) The ASCII codes of the product name “M38002M4–” must be entered in addresses 000016 to 000816. And set the data “FF16” in addresses 000916 to 000F16. The ASCII codes and addresses are listed to the right in hexadecimal notation. Address 0000 000116 000216 000316 000416 000516 000616 000716 ‘M’ = 4D16 ‘3’ = 3316 ‘8’ = 3816 ‘0’ = 3016 ‘0’ = 3016 ‘2’ = 3216 ‘M’ = 4D16 ‘4’ = 3416 Address 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 ‘ – ’ = 2D16 FF16 FF16 FF16 FF16 FF16 FF16 FF16 (1/2) EPROM address EPROM address EPROM type (indicate the type used) 000016 000F16 001016 C07F16 C08016 FFFD16 FFFE16 FFFF16 Product name ASCII code : ‘M38002M4–’ data ROM 16254 bytes Product name ASCII code : ‘M38002M4–’ data ROM 16254 bytes

3-42 3800 GROUP USER’S MANUAL SINGLE-CHIP MICROCOMPUTER M38002M4-XXXSP/FP MITSUBISHI ELECTRIC GZZ-SH03-22B<9YB0> Mask ROM number We recommend the use of the following pseudo-command to set the start address of the assembler source program. 27256 27512EPROM type The pseudo-command *=a$8000 .BYTEa ‘M38002M4–’ *=a$0000 .BYTEa ‘M38002M4–’ Note :If the name of the product written to the EPROMs does not match the name of the mask confirmation form, the ROM will not be processed. (2/2) h 2. Mark specification Mark specification must be submitted using the correct form for the package being ordered. Fill out the appropriate mark specification form (64P4B for M38002M4-XXXSP, 64P6N for M38002M4-XXXFP) and attach it to the mask ROM confirmation form. h 3. Usage conditions Please answer the following questions about usage for use in our product inspection : (1) How will you use the X IN-XOUT oscillator? At what frequency? f(X IN) = (2) In which operation mode will you use your microcomputer? h 4. Comments Ceramic resonator External clock input Single-chip mode Microprocessor mode Quartz crystal Other ( ) Memory expansion mode MHz

3-433800 GROUP USER’S MANUAL GZZ-SH05-12B<21A0> Receipt SINGLE-CHIP MICROCOMPUTER M38002M4DXXXSP/FP MITSUBISHI ELECTRIC Mask ROM number Date: Section head signature Supervisor signature Company name Note : Please fill in all items marked h . Customerh Issuance signatureDate issued Submitted byTEL Date: Supervisor h 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three EPROMs are required for each pattern. If at least two of the three sets of EPROMs submitted contain identical data, we will produce masks based on this data. We shall assume the responsibility for errors only if the mask ROM data on the products we produce differs from this data. Thus, extreme care must be taken to verify the data in the submitted EPROMs. Microcomputer name : 27256 27512 000016 000F16 001016 407F16 408016 7FFD16 7FFE16 7FFF16 M38002M4DXXXSP M38002M4DXXXFP Checksum code for entire EPROM (hexadecimal notation) In the address space of the microcomputer, the internal ROM area is from address C08016 to FFFD16. The reset vector is stored in addresses FFFC16 and FFFD16. (1) Set the data in the unused area (the shaded area of the diagram) to “FF16”. (2) The ASCII codes of the product name “M38002M4D” must be entered in addresses 000016 to 000816. And set the data “FF16” in addresses 000916 to 000F16. The ASCII codes and addresses are listed to the right in hexadecimal notation. Address 0000 000116 000216 000316 000416 000516 000616 000716 ‘M’ = 4D16 ‘3’ = 3316 ‘8’ = 3816 ‘0’ = 3016 ‘0’ = 3016 ‘2’ = 3216 ‘M’ = 4D16 ‘4’ = 3416 Address 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 ‘D’ = 4416 FF16 FF16 FF16 FF16 FF16 FF16 FF16 (1/2) EPROM address EPROM address EPROM type (indicate the type used) 000016 000F16 001016 C07F16 C08016 FFFD16 FFFE16 FFFF16 Product name ASCII code : ‘M38002M4D’ data ROM 16254 bytes Product name ASCII code : ‘M38002M4D’ data ROM 16254 bytes

3-44 3800 GROUP USER’S MANUAL SINGLE-CHIP MICROCOMPUTER M38002M4DXXXSP/FP MITSUBISHI ELECTRIC GZZ-SH05-12B<21A0> Mask ROM number We recommend the use of the following pseudo-command to set the start address of the assembler source program. 27256 27512EPROM type The pseudo-command *=a$8000 .BYTEa ‘M38002M4D’ *=a$0000 .BYTEa ‘M38002M4D’ Note :If the name of the product written to the EPROMs does not match the name of the mask confirmation form, the ROM will not be processed. (2/2) h 2. Mark specification Mark specification must be submitted using the correct form for the package being ordered. Fill out the appropriate mark specification form (64P4B for M38002M4DXXXSP, 64P6N for M38002M4DXXXFP) and attach it to the mask ROM confirmation form. h 3. Usage conditions Please answer the following questions about usage for use in our product inspection : (1) How will you use the X IN-XOUT oscillator? At what frequency? f(X IN) = (2) In which operation mode will you use your microcomputer? h 4. Comments Ceramic resonator External clock input Single-chip mode Microprocessor mode Quartz crystal Other ( ) Memory expansion mode MHz

3-453800 GROUP USER’S MANUAL GZZ-SH04-62B<14B0> Receipt SINGLE-CHIP MICROCOMPUTER M38003M6-XXXSP/FP/HP MITSUBISHI ELECTRIC Mask ROM number Date: Section head signature Supervisor signature Company name Note : Please fill in all items marked h . Customerh Issuance signatureDate issued Submitted byTEL Date: Supervisor h 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three EPROMs are required for each pattern. If at least two of the three sets of EPROMs submitted contain identical data, we will produce masks based on this data. We shall assume the responsibility for errors only if the mask ROM data on the products we produce differs from this data. Thus, extreme care must be taken to verify the data in the submitted EPROMs. Microcomputer name : 27256 27512 000016 000F16 001016 207F16 208016 7FFD16 7FFE16 7FFF16 M38003M6-XXXSP Checksum code for entire EPROM (hexadecimal notation) In the address space of the microcomputer, the internal ROM area is from address A08016 to FFFD16. The reset vector is stored in addresses FFFC16 and FFFD16. (1) Set the data in the unused area (the shaded area of the diagram) to “FF16”. (2) The ASCII codes of the product name “M38003M6–” must be entered in addresses 000016 to 000816. And set the data “FF16” in addresses 000916 to 000F16. The ASCII codes and addresses are listed to the right in hexadecimal notation. Address 0000 000116 000216 000316 000416 000516 000616 000716 ‘M’ = 4D16 ‘3’ = 3316 ‘8’ = 3816 ‘0’ = 3016 ‘0’ = 3016 ‘3’ = 3316 ‘M’ = 4D16 ‘6’ = 3616 Address 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 ‘ – ’ = 2D16 FF16 FF16 FF16 FF16 FF16 FF16 FF16 (1/2) EPROM address EPROM address EPROM type (indicate the type used) 000016 000F16 001016 A07F16 A08016 FFFD16 FFFE16 FFFF16 Product name ASCII code : ‘M38003M6–’ data ROM 24446 bytes Product name ASCII code : ‘M38003M6–’ data ROM 24446 bytes M38003M6-XXXHPM38003M6-XXXFP

3-46 3800 GROUP USER’S MANUAL SINGLE-CHIP MICROCOMPUTER M38003M6-XXXSP/FP/HP MITSUBISHI ELECTRIC GZZ-SH04-62B<14B0> Mask ROM number We recommend the use of the following pseudo-command to set the start address of the assembler source program. 27256 27512EPROM type The pseudo-command *=a$8000 .BYTEa ‘M38003M6–’ *=a$0000 .BYTEa ‘M38003M6–’ Note :If the name of the product written to the EPROMs does not match the name of the mask confirmation form, the ROM will not be processed. (2/2) h 2. Mark specification Mark specification must be submitted using the correct form for the package being ordered. Fill out the appropriate mark specification form (64P4B for M38003M6-XXXSP, 64P6N for M38003M6-XXXFP) and attach it to the mask ROM confirmation form. M38003M6-XXXHP is specified to the standard mark. h 3. Usage conditions Please answer the following questions about usage for use in our product inspection : (1) How will you use the X IN-XOUT oscillator? At what frequency? f(X IN) = (2) In which operation mode will you use your microcomputer? h 4. Comments Ceramic resonator External clock input Single-chip mode Microprocessor mode Quartz crystal Other ( ) Memory expansion mode MHz

3-473800 GROUP USER’S MANUAL GZZ-SH04-30B<13B0> Receipt SINGLE-CHIP MICROCOMPUTER M38004M8-XXXSP/FP MITSUBISHI ELECTRIC Mask ROM number Date: Section head signature Supervisor signature Company name Note : Please fill in all items marked h . Customerh Issuance signatureDate issued Submitted byTEL Date: Supervisor h 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three EPROMs are required for each pattern. If at least two of the three sets of EPROMs submitted contain identical data, we will produce masks based on this data. We shall assume the responsibility for errors only if the mask ROM data on the products we produce differs from this data. Thus, extreme care must be taken to verify the data in the submitted EPROMs. Microcomputer name : M38004M8-XXXSP M38004M8-XXXFP Checksum code for entire EPROM (hexadecimal notation) In the address space of the microcomputer, the internal ROM area is from address 808016 to FFFD16. The reset vector is stored in addresses FFFC16 and FFFD16. (1) Set the data in the unused area (the shaded area of the diagram) to “FF16”. (2) The ASCII codes of the product name “M38004M8–” must be entered in addresses 000016 to 000816. And set the data “FF16” in addresses 000916 to 000F16. The ASCII codes and addresses are listed to the right in hexadecimal notation. Address 0000 000116 000216 000316 000416 000516 000616 000716 ‘M’ = 4D16 ‘3’ = 3316 ‘8’ = 3816 ‘0’ = 3016 ‘0’ = 3016 ‘4’ = 3416 ‘M’ = 4D16 ‘8’ = 3816 Address 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 ‘ – ’ = 2D16 FF16 FF16 FF16 FF16 FF16 FF16 FF16 (1/2) EPROM type (indicate the type used) 27512 EPROM address 000016 000F16 001016 807F16 808016 FFFD16 FFFE16 FFFF16 Product name ASCII code : ‘M38004M8–’ data ROM 32638 bytes

3-48 3800 GROUP USER’S MANUAL 27512 *=a$0000 .BYTEa ‘M38004M8–’ SINGLE-CHIP MICROCOMPUTER M38004M8-XXXSP/FP MITSUBISHI ELECTRIC GZZ-SH04-30B<13B0> Mask ROM number We recommend the use of the following pseudo-command to set the start address of the assembier source program. EPROM type The pseudo-command Note :If the name of the product written to the EPROMs does not match the name of the mask confirmation form, the ROM will not be processed. We recommend the use of the following pseudo-command to set the start address of the assembler source program. (2/2) h 2. Mark specification Mark specification must be submitted using the correct form for the package being ordered. Fill out the appropriate mark specification form (64P4B for M38004M8-XXXSP, 64P6N for M38004M8-XXXFP) and attach it to the mask ROM confirmation form. h 3. Usage conditions Please answer the following questions about usage for use in our product inspection : (1) How will you use the X IN-XOUT oscillator? At what frequency? f(X IN) = (2) In which operation mode will you use your microcomputer? h 4. Comments Ceramic resonator External clock input Single-chip mode Microprocessor mode Quartz crystal Other ( ) Memory expansion mode MHz

3-493800 GROUP USER’S MANUAL GZZ-SH07-23B<33A0> Receipt SINGLE-CHIP MICROCOMPUTER M38004M8DXXXSP/FP MITSUBISHI ELECTRIC Mask ROM number Date: Section head signature Supervisor signature Company name Note : Please fill in all items marked h . Customerh Issuance signatureDate issued Submitted byTEL Date: Supervisor h 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three EPROMs are required for each pattern. If at least two of the three sets of EPROMs submitted contain identical data, we will produce masks based on this data. We shall assume the responsibility for errors only if the mask ROM data on the products we produce differs from this data. Thus, extreme care must be taken to verify the data in the submitted EPROMs. Microcomputer name : M38004M8DXXXSP M38004M8DXXXFP Checksum code for entire EPROM (hexadecimal notation) In the address space of the microcomputer, the internal ROM area is from address 808016 to FFFD16. The reset vector is stored in addresses FFFC16 and FFFD16. (1) Set the data in the unused area (the shaded area of the diagram) to “FF16”. (2) The ASCII codes of the product name “M38004M8D” must be entered in addresses 000016 to 000816. And set the data “FF16” in addresses 000916 to 000F16. The ASCII codes and addresses are listed to the right in hexadecimal notation. Address 0000 000116 000216 000316 000416 000516 000616 000716 ‘M’ = 4D16 ‘3’ = 3316 ‘8’ = 3816 ‘0’ = 3016 ‘0’ = 3016 ‘4’ = 3416 ‘M’ = 4D16 ‘8’ = 3816 Address 000816 000916 000A16 000B16 000C 16 000D 16 000E16 000F16 ‘D’ = 4416 FF16 FF16 FF16 FF16 FF16 FF16 FF16 (1/2) EPROM type (indicate the type used) 27512 EPROM address 000016 000F16 001016 807F16 808016 FFFD16 FFFE16 FFFF16 Product name ASCII code : ‘M38004M8D’ data ROM 32638 bytes

3-50 3800 GROUP USER’S MANUAL 27512 *=a$0000 .BYTEa ‘M38004M8D’ SINGLE-CHIP MICROCOMPUTER M38004M8DXXXSP/FP MITSUBISHI ELECTRIC GZZ-SH07-23B<33A0> Mask ROM number We recommend the use of the following pseudo-command to set the start address of the assembier source program. EPROM type The pseudo-command Note :If the name of the product written to the EPROMs does not match the name of the mask confirmation form, the ROM will not be processed. We recommend the use of the following pseudo-command to set the start address of the assembler source program. (2/2) h 2. Mark specification Mark specification must be submitted using the correct form for the package being ordered. Fill out the appropriate mark specification form (64P4B for M38004M8DXXXSP, 64P6N for M38004M8DXXXFP) and attach it to the mask ROM confirmation form. h 3. Usage conditions Please answer the following questions about usage for use in our product inspection : (1) How will you use the X IN-XOUT oscillator? At what frequency? f(X IN) = (2) In which operation mode will you use your microcomputer? h 4. Comments Ceramic resonator External clock input Single-chip mode Microprocessor mode Quartz crystal Other ( ) Memory expansion mode MHz

3-513800 GROUP USER’S MANUAL

3-52 3800 GROUP USER’S MANUAL

3-533800 GROUP USER’S MANUAL 2.5/1 2.5/1

3-54 3800 GROUP USER’S MANUAL 2.5/1 1.5/1

3-553800 GROUP USER’S MANUAL 1.5/1

3.9 Machine instructions

3-56 3800 GROUP USER’S MANUAL Addressing mode Symbol Function Details IMP IMM A BIT, A ZP BIT, ZP OP n # OP n # OP n # OP n # OP n #OP n # Adds the carry, accumulator and memory con- tents. The results are entered into the accumulator. Adds the contents of the memory in the ad- dress indicated by index register X, the contents of the memory specified by the ad- dressing mode and the carry. The results are entered into the memory at the address indi- cated by index register X. “AND’s” the accumulator and memory con- tents. The results are entered into the accumulator. “AND’s” the contents of the memory of the ad- dress indicated by index register X and the contents of the memory specified by the ad- dressing mode. The results are entered into the memory at the address indicated by index register X. Shifts the contents of accumulator or contents of memory one bit to the left. The low order bit of the accumulator or memory is cleared and the high order bit is shifted into the carry flag. Branches when the contents of the bit speci- fied in the accumulator or memory is “0”. Branches when the contents of the bit speci- fied in the accumulator or memory is “1”. Branches when the contents of carry flag is “0”. Branches when the contents of carry flag is “1”. Branches when the contents of zero flag is “1”. “AND’s” the contents of accumulator and memory. The results are not entered any- where. Branches when the contents of negative flag is “1”. Branches when the contents of zero flag is “0”. Branches when the contents of negative flag is “0”. Jumps to address specified by adding offset to the program counter. Executes a software interrupt. ADC (Note 1) (Note 5) AND (Note 1) ASL BBC (Note 4) BBS (Note 4) BCC (Note 4) BCS (Note 4) BEQ (Note 4) BIT BMI (Note 4) BNE (Note 4) BPL (Note 4) BRA BRK 7 0 C ← ← 0 29 2 2 0A 2 1 03+2i 17+2i 07+2i 06 5 2 25 3 2 65 3 269 2 2 13+2i When T = 0 A ← A + M + C When T = 1 M(X) ← M(X) + M + C When T = 0 A ← A M When T = 1 M(X) ← M(X) M Ab or Mb = 0? Ab or Mb = 1? C = 0? C = 1? Z = 1? A M N = 1? Z = 0? N = 0? PC ← PC ± offset B ← 1 M(S) ← PC H S ← S – 1 M(S) ← PCL S ← S – 1 M(S) ← PS S ← S – 1 PC L ← ADL PC H ← ADH V V V 2

ZP, X ZP, Y ABS ABS, X ABS, Y IND ZP, IND IND, X IND, Y REL SP 7 6 5 4 3 2 1 0 Processor status register NVTBD I ZCOP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # 3-57 N N N M V M Z Z Z Z C C

3-58 3800 GROUP USER’S MANUAL Addressing mode Symbol Function Details IMP IMM A BIT, A ZP BIT, ZP OP n # OP n # OP n # OP n # OP n #OP n # Branches when the contents of overflow flag is “0”. Branches when the contents of overflow flag is “1”. Clears the contents of the bit specified in the accumulator or memory to “0”. Clears the contents of the carry flag to “0”. Clears the contents of decimal mode flag to “0”. Clears the contents of interrupt disable flag to “0”. Clears the contents of index X mode flag to “0”. Clears the contents of overflow flag to “0”. Compares the contents of accumulator and memory. Compares the contents of the memory speci- fied by the addressing mode with the contents of the address indicated by index register X. Forms a one’s complement of the contents of memory, and stores it into memory. Compares the contents of index register X and memory. Compares the contents of index register Y and memory. Decrements the contents of the accumulator or memory by 1. Decrements the contents of index register X by 1. Decrements the contents of index register Y by 1. Divides the 16-bit data that is the contents of M (zz + x + 1) for high byte and the contents of M (zz + x) for low byte by the accumulator. Stores the quotient in the accumulator and the 1’s complement of the remainder on the stack. “Exclusive-ORs” the contents of accumulator and memory. The results are stored in the ac- cumulator. “Exclusive-ORs” the contents of the memory specified by the addressing mode and the contents of the memory at the address indi- cated by index register X. The results are stored into the memory at the address indi- cated by index register X. Increments the contents of accumulator or memory by 1. Increments the contents of index register X by Increments the contents of index register Y by BVC (Note 4) BVS (Note 4) CLB CLC CLD CLI CLT CLV CMP (Note 3) COM CPX CPY DEC DEX DEY DIV EOR (Note 1) INC INX INY V = 0? V = 1? Ab or Mb ← 0 C ← 0 D ← 0 I ← 0 T ← 0 V ← 0 When T = 0 A – M When T = 1 M(X) – M M ← M X – M Y – M A ← A – 1 or M ← M – 1 X ← X – 1 Y ← Y – 1 A ← (M(zz + X + 1), M(zz + X)) / A M(S) ← 1’s complememt of Remainder S ← S – 1 When T = 0 A ← A V– M When T = 1 M(X) ← M(X) V– M A ← A + 1 or M ← M + 1 X ← X + 1 Y ← Y + 1 CA 1B+2i 1F+2i 21 52

ZP, X ZP, Y ABS ABS, X ABS, Y IND ZP, IND IND, X IND, Y REL SP 7 6 5 4 3 2 1 0 Processor status register NVTBD I ZCOP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # 3-59 CD EC CC CE EE N N N N N N N N N N N DD DE FE Z Z Z Z Z Z Z Z Z Z Z C C C

3-60 3800 GROUP USER’S MANUAL Addressing mode Symbol Function Details IMP IMM A BIT, A ZP BIT, ZP OP n # OP n # OP n # OP n # OP n #OP n # Jumps to the specified address. After storing contents of program counter in stack, and jumps to the specified address. Load accumulator with contents of memory. Load memory indicated by index register X with contents of memory specified by the ad- dressing mode. Load memory with immediate value. Load index register X with contents of memory. Load index register Y with contents of memory. Shift the contents of accumulator or memory to the right by one bit. The low order bit of accumulator or memory is stored in carry, 7th bit is cleared. Multiplies the accumulator with the contents of memory specified by the zero page X address- ing mode and stores the high byte of the result on the stack and the low byte in the accumula- tor. No operation. “Logical OR’s” the contents of memory and ac- cumulator. The result is stored in the accumulator. “Logical OR’s” the contents of memory indi- cated by index register X and contents of memory specified by the addressing mode. The result is stored in the memory specified by index register X. JMP JSR LDA (Note 2) LDM LDX LDY LSR MUL NOP ORA (Note 1) If addressing mode is ABS PC L ← ADL PC H ← ADH If addressing mode is IND PC L ← M (ADH , ADL) PC H ← M (ADH, ADL + 1) If addressing mode is ZP, IND PC L ← M(00, ADL) PC H ← M(00, ADL + 1) M(S) ← PCH S ← S – 1 M(S) ← PCL S ← S – 1 After executing the above, if addressing mode is ABS, PC L ← ADL PC H ← ADH if addressing mode is SP, PC L ← ADL PC H ← FF If addressing mode is ZP, IND, PC L ← M(00, ADL) PC H ← M(00, ADL + 1) When T = 0 A ← M When T = 1 M(X) ← M M ← nn X ← M Y ← M M(S) · A ← A 5 M(zz + X) S ← S – 1 PC ← PC + 1 When T = 0 A ← A V M When T = 1 M(X) ← M(X) V M 4A 2 1 EA 2 1 7 0 0→ → C

ZP, X ZP, Y ABS ABS, X ABS, Y IND ZP, IND IND, X IND, Y REL SP 7 6 5 4 3 2 1 0 Processor status register NVTBD I ZCOP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # 3-61 AD AE AC N N N N Z Z Z Z Z C B6 4 2 BD BC BE

53 B 2

3-62 3800 GROUP USER’S MANUAL Addressing mode Symbol Function Details IMP IMM A BIT, A ZP BIT, ZP OP n # OP n # OP n # OP n # OP n #OP n # Saves the contents of the accumulator in memory at the address indicated by the stack pointer and decrements the contents of stack pointer by 1. Saves the contents of the processor status register in memory at the address indicated by the stack pointer and decrements the contents of the stack pointer by 1. Increments the contents of the stack pointer by 1 and restores the accumulator from the memory at the address indicated by the stack pointer. Increments the contents of stack pointer by 1 and restores the processor status register from the memory at the address indicated by the stack pointer. Shifts the contents of the memory or accumu- lator to the left by one bit. The high order bit is shifted into the carry flag and the carry flag is shifted into the low order bit. Shifts the contents of the memory or accumu- lator to the right by one bit. The low order bit is shifted into the carry flag and the carry flag is shifted into the high order bit. Rotates the contents of memory to the right by 4 bits. Returns from an interrupt routine to the main routine. Returns from a subroutine to the main routine. Subtracts the contents of memory and complement of carry flag from the contents of accumulator. The results are stored into the accumulator. Subtracts contents of complement of carry flag and contents of the memory indicated by the addressing mode from the memory at the ad- dress indicated by index register X. The results are stored into the memory of the ad- dress indicated by index register X. Sets the specified bit in the accumulator or memory to “1”. Sets the contents of the carry flag to “1”. Sets the contents of the decimal mode flag to “1”. Sets the contents of the interrupt disable flag to “1”. Sets the contents of the index X mode flag to “1”. PHA PHP PLA PLP ROL ROR RRF RTI RTS SBC (Note 1) (Note 5) SEB SEC SED SEI SET M(S) ← A S ← S – 1 M(S) ← PS S ← S – 1 S ← S + 1 A ← M(S) S ← S + 1 PS ← M(S) S ← S + 1 PS ← M(S) S ← S + 1 PC L ← M(S) S ← S + 1 PC H ← M(S) S ← S + 1 PC L ← M(S) S ← S + 1 PC H ← M(S) When T = 0 A ← A – M – C When T = 1 M(X) ← M(X) – M – C Ab or Mb ← 1 C ← 1 D ← 1 I ← 1 T ← 1 7 0 ← ← C ← 7 0 → → 0B+2i 0F+2i 21 52 7 0 C → →

ZP, X ZP, Y ABS ABS, X ABS, Y IND ZP, IND IND, X IND, Y REL SP 7 6 5 4 3 2 1 0 Processor status register NVTBD I ZCOP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # 3-63 ED N N N N V Z Z Z Z C C C FD 3F 95 3 E 16 2F 16 2 (Value saved in stack) (Value saved in stack)

3-64 3800 GROUP USER’S MANUAL Addressing mode Symbol Function Details IMP IMM A BIT, A ZP BIT, ZP OP n # OP n # OP n # OP n # OP n #OP n # Stores the contents of accumulator in memory. Stops the oscillator. Stores the contents of index register X in memory. Stores the contents of index register Y in memory. Transfers the contents of the accumulator to index register X. Transfers the contents of the accumulator to index register Y. Tests whether the contents of memory are “0” or not. Transfers the contents of the stack pointer to index register X. Transfers the contents of index register X to the accumulator. Transfers the contents of index register X to the stack pointer. Transfers the contents of index register Y to the accumulator. Stops the internal clock. STA STP STX STY TAX TAY TST TSX TXA TXS TYA WIT M ← A M ← X M ← Y X ← A Y ← A M = 0? X ← S A ← X S ← X A ← Y AA BA Notes 1 : The number of cycles “n” is increased by 3 when T is 1. 2 : The number of cycles “n” is increased by 2 when T is 1. 3 : The number of cycles “n” is increased by 1 when T is 1. 4 : The number of cycles “n” is increased by 2 when branching has occurred. 5 : N, V, and Z flags are invalid in decimal operation mode.

ZP, X ZP, Y ABS ABS, X ABS, Y IND ZP, IND IND, X IND, Y REL SP 7 6 5 4 3 2 1 0 Processor status register NVTBD I ZCOP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # 3-65 N N N N N N Z Z Z Z Z Z Addition Subtraction Logical OR Logical AND Logical exclusive OR Negation Shows direction of data flow Index register X Index register Y Stack pointer Program counter Processor status register 8 high-order bits of program counter 8 low-order bits of program counter 8 high-order bits of address 8 low-order bits of address FF in Hexadecimal notation Immediate value Memory specified by address designation of any ad- dressing mode Memory of address indicated by contents of index register X Memory of address indicated by contents of stack pointer Contents of memory at address indicated by AD H and AD L, in ADH is 8 high-order bits and ADL is 8 low-or- der bits. Contents of address indicated by zero page AD L 1 bit of accumulator 1 bit of memory Opcode Number of cycles Number of bytes 96 5 2

9 D 63 9 9 63 8 1 72 9 1 72

Accumulator or Accumulator addressing mode Accumulator bit relative addressing mode Zero page addressing mode Zero page bit relative addressing mode Zero page X addressing mode Zero page Y addressing mode Absolute addressing mode Absolute X addressing mode Absolute Y addressing mode Indirect absolute addressing mode Zero page indirect absolute addressing mode Indirect X addressing mode Indirect Y addressing mode Relative addressing mode Special page addressing mode Carry flag Zero flag Interrupt disable flag Decimal mode flag Break flag X-modified arithmetic mode flag Overflow flag Negative flag IMP IMM A BIT, A ZP BIT, ZP ZP, X ZP, Y ABS ABS, X ABS, Y IND ZP, IND IND, X IND, Y REL SP C Z I D B T V N Symbol Contents Symbol Contents V X Y S PC PS PC H PC L AD H AD L FF nn M M(X) M(S) M(AD H , ADL) M(00, ADL) Ab Mb OP n V

3.10 List of instruction codes

D 7 – D4 D 3 – D0 Hexadecimal notation 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 A B C D E F 0001 ORA IND, X ORA IND, Y AND IND, X AND IND, Y EOR IND, X EOR IND, Y ADC IND, X ADC IND, Y STA IND, X STA IND, Y LDA IND, X LDA IND, Y CMP IND, X CMP IND, Y SBC IND, X SBC IND, Y 0010 JSR ZP, IND CLT JSR SP SET STP MUL ZP, X RRF ZP LDX IMM JMP ZP, IND WIT DIV ZP, X 0011 BBS 0, A BBC 0, A BBS 1, A BBC 1, A BBS 2, A BBC 2, A BBS 3, A BBC 3, A BBS 4, A BBC 4, A BBS 5, A BBC 5, A BBS 6, A BBC 6, A BBS 7, A BBC 7, A 0100 BIT ZP COM ZP TST ZP STY ZP STY ZP, X LDY ZP LDY ZP, X CPY ZP CPX ZP 0101 ORA ZP ORA ZP, X AND ZP AND ZP, X EOR ZP EOR ZP, X ADC ZP ADC ZP, X STA ZP STA ZP, X LDA ZP LDA ZP, X CMP ZP CMP ZP, X SBC ZP SBC ZP, X 0110 ASL ZP ASL ZP, X ROL ZP ROL ZP, X LSR ZP LSR ZP, X ROR ZP ROR ZP, X STX ZP STX ZP, Y LDX ZP LDX ZP, Y DEC ZP DEC ZP, X INC ZP INC ZP, X 0111 BBS 0, ZP BBC 0, ZP BBS 1, ZP BBC 1, ZP BBS 2, ZP BBC 2, ZP BBS 3, ZP BBC 3, ZP BBS 4, ZP BBC 4, ZP BBS 5, ZP BBC 5, ZP BBS 6, ZP BBC 6, ZP BBS 7, ZP BBC 7, ZP 1000 PHP CLC PLP SEC PHA CLI PLA SEI DEY TYA TAY CLV INY CLD INX SED 1001 ORA IMM ORA ABS, Y AND IMM AND ABS, Y EOR IMM EOR ABS, Y ADC IMM ADC ABS, Y STA ABS, Y LDA IMM LDA ABS, Y CMP IMM CMP ABS, Y SBC IMM SBC ABS, Y 1010 A ASL A DEC A ROL A INC A LSR A ROR A TXA TXS TAX TSX DEX NOP 1011 B SEB 0, A CLB 0, A SEB 1, A CLB 1, A SEB 2, A CLB 2, A SEB 3, A CLB 3, A SEB 4, A CLB 4, A SEB 5, A CLB 5, A SEB 6, A CLB 6, A SEB 7, A CLB 7, A 1100 C BIT ABS LDM ZP JMP ABS JMP IND STY ABS LDY ABS LDY ABS, X CPY ABS CPX ABS 1101 D ORA ABS ORA ABS, X AND ABS AND ABS, X EOR ABS EOR ABS, X ADC ABS ADC ABS, X STA ABS STA ABS, X LDA ABS LDA ABS, X CMP ABS CMP ABS, X SBC ABS SBC ABS, X 1110 E ASL ABS ASL ABS, X ROL ABS ROL ABS, X LSR ABS LSR ABS, X ROR ABS ROR ABS, X STX ABS LDX ABS LDX ABS, Y DEC ABS DEC ABS, X INC ABS INC ABS, X 1111 F SEB 0, ZP CLB 0, ZP SEB 1, ZP CLB 1, ZP SEB 2, ZP CLB 2, ZP SEB 3, ZP CLB 3, ZP SEB 4, ZP CLB 4, ZP SEB 5, ZP CLB 5, ZP SEB 6, ZP CLB 6, ZP SEB 7, ZP CLB 7, ZP 0000 BRK BPL JSR ABS BMI RTI BVC RTS BVS BRA BCC LDY IMM BCS CPY IMM BNE CPX IMM BEQ

3-673800 GROUP USER’S MANUAL Port P0 (P0) Port P0 direction register (P0D) Port P1 (P1) Port P1 direction register (P1D) Port P2 (P2) Port P2 direction register (P2D) Port P3 (P3) Port P3 direction register (P3D) Port P4 (P4) Port P4 direction register (P4D) Port P5 (P5) Port P5 direction register (P5D) Port P6 (P6) Port P6 direction register (P6D) Port P7 (P7) Port P7 direction register (P7D) Transmit/Receive buffer register (TB/RB) Serial I/O status register (SIOSTS) Serial I/O control register (SIOCON) UART control register (UARTCON) Baud rate generator (BRG) 0020 002116 002216 002316 002416 002516 002616 002716 002816 002916 002A 16 002B 16 002C 16 002D 16 002E 16 002F16 003016 003116 003216 003316 003416 003516 003616 003716 003816 003916 003A 16 003B 16 003C 16 003D 16 003E 16 003F16 Prescaler 12 (PRE12) Timer 1 (T1) Timer 2 (T2) Timer XY mode register (TM) Prescaler X (PREX) Timer X (TX) Prescaler Y (PREY) Timer Y (TY) Interrupt edge selection register (INTEDGE) CPU mode register (CPUM) Interrupt request register 1 (IREQ1) Interrupt request register 2 (IREQ2) Interrupt control register 1 (ICON1) Interrupt control register 2 (ICON2)

3-68 3800 GROUP USER’S MANUAL M38002M4-XXXFP M38003M6-XXXHP P33/RESET OUT P34/f P35/SYNC P37/RD P36/WR P32/ONW P64 P66 P67 P70 P71 VCC P30 P31 P63 P65 P62 P61 P60 P57 P56 P55/CNTR 1 P54/CNTR 0 P53/INT5 P52/INT4 P51/INT3 P50/INT2 P47/SRDY P46/SCLK P43/INT1 P44/RXD P45/TXD P24/DB4 P23/DB3 P22/DB2 P20/DB0 P21/DB1 P25/DB5 CNV SS P41 P40 XIN XOUT VSS P27/DB7 P26/DB6 P42/INT0 RESET P00/AD0 P01/AD1 P02/AD2 P03/AD3 P04/AD4 P05/AD5 P06/AD6 P07/AD7 P10/AD8 P11/AD9 P12/AD10 P13/AD11 P14/AD12 P17/AD15 P16/AD14 P15/AD13 PIN CONFIGURATION (TOP VIEW) Package type : 64P6N-A/64P6D-A 64-pin plastic-molded QFP

3-693800 GROUP USER’S MANUAL PIN CONFIGURATION (TOP VIEW) Package type : 64P4B 64-pin shrink plastic-molded DIP P64 P66 P67 P70 P71 VCC P63 P65 P62 P61 P60 P57 P56 P55/CNTR 1 P54/CNTR 0 P53/INT5 P52/INT4 P51/INT3 P50/INT2 P47/SRDY P46/SCLK P43/INT1 P44/RXD P45/TXD CNV SS P41 P40 XIN XOUT VSS P42/INT0 RESET P24/DB4 P23/DB3 P22/DB2 P20/DB0 P21/DB1 P25/DB5 P27/DB7 P26/DB6 P33/RESET OUT P34/f P35/SYNC P37/RD P36/WR P32/ONW P30 P31 P00/AD0 P01/AD1 P02/AD2 P03/AD3 P04/AD4 P05/AD5 P06/AD6 P07/AD7 P10/AD8 P11/AD9 P12/AD10 P13/AD11 P14/AD12 P17/AD15 P16/AD14 P15/AD13 M38002M4-XXXSP

USER’S MANUAL 3800Group Mar. First Edition 1996 Editioned by Committee of editing of Mitsubishi Semiconductor USER’S MANUAL Published by Mitsubishi Electric Corp., Semiconductor Marketing Division This book, or parts thereof, may not be reproduced in any form without permission of Mitsubishi Electric Corporation. ©1996 MITSUBISHI ELECTRIC CORPORATION

MITSUBISHI ELECTRIC CORPORATION HEAD OFFICE: MITSUBISHI DENKI BLDG., MARUNOUCHI, TOKYO 100. TELEX: J24532 CABLE: MELCO TOKYO User’s Manual

3800 Group

H-EE418-A KI-9603 Printed in Japan (ROD) © 1996 MITSUBISHI ELECTRIC CORPORATION New publication, effective Mar. 1996. Specifications subject to change without notice.