MITSUBISHI SEMICONDUCTORS M37702 Group M37703 Group ~ Preface Preface This manual describes the hardware of the Mitsubishi eNOS 16-bit microcomputer M37702 group. After reading this manual, the user should be able to fully utilize the functions of the microcomputers of M37702 group and M37703 group. For details concerning the softwares for the M37702 group and M37703 group, refer to the MELPS 7700 SOFTWARE MANUAL. For details concerning the development support tools (assembler, option boards), refer to the respective operation manuals. Table of contents Table of contents CHAPTER 1. DESCRIPTION 1.1 M37702 group ..............................................................................................................................................3 1.2 Performance overview .................................................................................................................................4 1.3 Pin configuration ..........................................................................................................................................5 1.4 Pin description .............................................................................................................................................6 1.5 Block diagram ..............................................................................................................................................8 CHAPTER 2. FUNCTIONAL DESCRIPTION 2.1 Central processing unit (CPU) ................................................................................................................... 10 2.1.1 Accumulator (Acc) ............................................................................................................................ 10 2.1.2 Index register X (X) .......................................................................................................................... 10 2.1.3 Index register Y ................................................................................................................................ 10 2.1.4 Stack pointer (S) .............................................................................................................................. 12 2.1.5 Program co.unter (PC) ...................................................................................................................... 13 2.1.6 Program bank register (PG) ............................................................................................................. 13 2.1.7 Data bank register (DT) .................................................................................................................... 14 2.1.8 Direct page register (DPR) ............................................................................................................... 14 2.1.9 Processor status register (PS) ......................................................................................................... 15 2.2 Internal bus interface ................................................................................................................................. 17 2.2.1 Internal bus interface overview ........................................................................................................ 17 2.2.2 Bus interface unit functions .............................................................................................................. 17 2.2.3 Bus ihterface unit operations ............................................................................................................ 19 2.2.4 Data read/write operations ..........................................................................................................:.... 21 2.3 Addressable memory space ...................................................................................................................... 22 2.3.1 Banks .................................................................. :............................................................................ 22 2.3.2 Direct page ....................................................................................................................................... 22 2.4 Memory allocation ..................................................................................................................................... 23 2.4.1 Internal memory and peripheral device memory allocation .............................................................. 23 2.4.2 Processor modes ............................................................................................................................. 25 2.4.3 External memory area bus control ................................................................................................... 29 2.5 Input/Output pins .......................................................................................................................................31 2.5.1 Programmable I/O ports .................................................................~ ................................................. 31 2.5.2 Pin functions .....................................................................................................................................34 2.5.3 Single-chip mode pin functions ........................................................................................................ 38 2.5.4 Memory expansion and microprocessor mode pin functions .......................................................... .40 2.6 Interrupts ...................................................................................................................................................45 2.6.1 Interrupt functions ............................................................................................................................45 2.6.2 Sources of interrupts ........................................................................................................................47 2.6.3 Interrupt control ................................................................................................................................ 49 2.6.4 Interrupt priority level ........................................................................................................................ 53 2.6.5 Interrupt priority level detection circuit ............................................................................................. 53 2.6.6 Interrupt priority level detection time ................................................................................................ 56 2.6.7 Interrupt processing sequence ......................................................................................................... 57 2.6.8 Returning from an interrupt service routine ...................................................................................... 60 2.6.9 Multiple interrupts ............................................................................................................................. 60 2.6.10 Interrupt response time and interrupt delay time ............................................................................ 61 Table of contents 2.7 Timer A ...................................................................................................................................................... 64 2.7.1 Timer A description .......................................................................................................................... 64 2.7.2 Block description ..............................................................................................................................65 2.7.3 Timer mode ......................................................................................................................................72 2.7.4 Event counter mode ......................................................................................................................... 78 2.7.5 One-shot pulse mode ....................................................................................................................... 85 2.7.6 Pulse width modulation (PWM) mode .............................................................................................. 90 2.8 Timer B ......................................................................................................................................................94 2.8.1 Timer B description ..........................................................................................................................94 2.8.2 Block diagram ..................................................................................................................................94 2.8.3 Timer mode .................................................................................................................................... 100 2.8.4 Event counter mode ....................................................................................................................... 103 2.8.5 Pulse period/pulse width measurement mode ............................................................................... 105 2.9 Serial I/O ..................................................................................................................................................109 2.9.1 Serial I/O description ...................................................................................................................... 109 2.9.2 Block description ............................................"'............................................................................... 11 0 2.9.3 Clock synchronous serial I/O ......................................................................................................... 121 2.9.4 Clock asynchronous serial I/O (UART) .......................................................................................... 131 2.9.5 Sleep mode .................................................................................................................................... 143 2.10 A-O converter ......................................................................................................................................... 144 2.10.1 A-O converter overview ................................................................................................................ 144 2.10.2 Block description .......................................................................................................................... 145 2.10.3 Successive approximation conversion ......................................................................................... 152 2.10.4 A-O conversion mode ................................................................................................................... 154 2.11 Watchdog timer ...................................................................................................................................... 158 2.11.1 Operation description ................................................................................................................... 159 2.12 Hold function .......................................................................................................................................... 160 2.13 Ready function ....................................................................................................................................... 162 CHAPTER 3. RESET 3.1 Reset .......................................................................................................................................................164 3.1.1 Reset operation .............................................................................................................................. 164 3.1.2 Internal status at reset .................................................................................................................... 165 3.1.3 Bus state during reset in microprocessor mode ............................................................................. 168 3.2 Reset circuit ................................................ :............................................................................................ 169 3.3 Software reset .......................................................................................................................................... 170 CHAPTER 4. OSCILLATING CIRCUIT 4.1 Oscillating circuit ............................................................................................................. :........................ 172 4.1.1 Circuit using a ceramic resonator or a crystal resonator ................................................................ 172 4.1.2 External clock input circuit .......................................................................................................:...... 172 4.2 Clock generator ....................................................................................................................................... 173 CHAPTER 5. ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics .......................................................................................................................... 176 5.1.1 Absolute maximum ratings ............................................................................................................. 176 5.1.2 Recommended operating conditions .............................................................................................. 177 5.1.3 Electrical characteristics and A-O converter characteristics .......................................................... 178 5.1.4 Timing requirements ................................................... :................................................................... 181 5.1.5 Switching characteristics .... : ........................................................................................................... 184 5.1.6 Equations for calculating the parameters .......... ,............................................................................ 186 5.1.7 Timing diagrams ............................................................................................................................. 187 ii Table of contents CHAPTER 6. STANDARD CHARACTERISTICS 6.1 Standard characteristics .......................................................................................................................... 194 6.1.1 Standard port characteristics ......................................................................................................... 194 6.1.2 Icc-f(XIN} standard characteristics .................................................................................................. 195 6.1.3 A-D converter standard characteristics .......................................................................................... 196 CHAPTER 7. APPLICATION 7.1 Memory expansion .................................................................................................................................. 198 7.1.1 Memory expansion model .............................................................................., ............................... 198 7.1.2 Memory access time calculation .................................................................................................... 200 7.1.3 Memory expansion precautions ..................................................................................................... 206 7.1.4 Connection to devices that request long access time .................................................................... 208 7.1.5 Memory expansion example .......................................................................................................... 209 7.2110 expansion ..........................................................................................................................................215 7.2.1 1/0 expansion model ...................................................................................................................... 215 7.2.2110 expansion examples ................................................................................................................. 215 7.3 Program examples ...................................................................................................................................219 7.3.1 Hardware definition ........................................................................................................................ 220 7.3.2 Initialization examples .................................................................................................................... 224 7.3.3 Timer modes setting examples ...................................................................................................... 225 7.3.4 Serial 110 modes setting examples ................................................................................................ 232 7.3.5 A-D conversion modes setting examples ....................................................................................... 239 7.3.6 Interrupt processing examples ....................................................................................................... 243 7.3.7 Watchdog timer setting examples .................................................................................................. 246 7.3.8 Software timer setting examples .................................................................................................... 247 7.3.9 Interrupt vector table setting example ............................................................................................ 248 7.4 M37702 group execution performance .................................................................................................... 249 7.4.1 Comparing the execution speed of M37702 and M37700 ............................................................. 249 7.4.2 Software one-wait (20M Hz} and software+hardware wait (25MHz) execution speed comparison .......... 252 CHAPTER 8. PROM VERSION 8.1 Product expansion ................................................................................................................................... 256 8.2 M37702E2-XXXFP .................................................................................................................................. 257 8.2.1 Description ..................................................................................................................................... 257 8.2.2 Functional description .................................................................................................................... 258 8.2.3 Fast programming algorithm ....................................................................................................: ..... 261 8.3 Usage precaution ..................................................................................................................................... 263 CHAPTER 9. M37703 GROUP 9.1 Product expansion ................................................................................................................................... 266 9.1.1 M37703M2-XXXSP characterictics ................................................................................................ 266 9.2 M37703M2-XXXSP .................................................................................................................................. 267 9.2.1 Description ..................................................................................................................................... 267 9.2.2 Performance overview ................................................................................................................... 268 9.2.3 Differences between M37703M2-XXXSP and M37702M2-XXXFP ............................................... 269 9.2.4 Functional description .................................................................................................................... 270 iii Table of contents APPENDIX Appendix 1. M37702 group memory map ...................................................................................................... 272 Appendix 2. SFR area memory map ....................... \..................................................................................... 275 Appendix 3. Control registers ........................................................................................................................279 Appendix 4. Stop, wait, one-wait, Ready, Hold state ..................................................................................... 292 Appendix 5. Package outlines ...............•.......................................................................................................294 Appendix 6. Setting of unused pins ............................................................................................................... 295 Appendix 7. ROM ordering method ...............................................................................................................296 Appendix 8. IC sockets ..................................................................................................................................310 Appendix 9. M66800SP/FP ...........................................................................................................................313 Appendix 10. Instruction code table ...............................................................................................................315 Appendix 11. Machine instructions ................................................................................................................318 iv For using this manual This manual defines following items. ·f(XIN) f(XIN) means oscillating clock frequency. ·Internal clock ¢ Internal clock ¢ means operating clock of this microcomputer. It is obtained by dividing the input clock to XIN pin by 2 ( = f(XIN)/2). ·Clock cjJ1 Clock cjJ1 means the internal clock cjJ output from P42 pin. ·Bit attribute Bit attributes are described in the figure of register structure. The following abbreviations are used to indicate the attributes. b7 b6 b5 b4 b3 b2 b1 bO R/W : Possible to read and write L . . -_ _ _ _ _ W : Possible only to write R : Possible only to read ' - - - - - - - - - - - - - - - - Nothing allocated, undefined at reading 'Overflow and Underflow of timers Overflow of the timer means that the counter content reaches FFFF16 ~ reload value Un". Underflow of the timer means that the counter content reaches 000016 ~ reload value Un". Un" : Value set in reload register ©[f!]£[?)u~~ II DESCRIPTION 1.1 M37702 group 1.2 Performance overview 1.3 Pin configuration 1.4 Pin description 1.5 Block diagram DESCRIPTION The M37702M2-XXXFP is a 16-bit single-chip microcomputer designed with high-performance CMOS silicon gate technology. It is housed in an 80-pin plastic molded flat package. This single-chip microcomputer has a large 16M bytes address space, three instruction queue buffers, and two data buffers for high-speed instruction execution. The CPU is a 16-bit parallel processor that can also be switched to perform 8-bit parallel processing. This microcomputer is suitable for office, business, and industrial equipment controllers that require high-speed processing of large amounts of data. Photo of M37702M2-XXXFP Chip 2 'DESCRIPTION 1.1 M37702 group 1.1 M37702 group The M37702 group consists of chips shown in Table 1.1.1 with the M37702M2-XXXFP as the base chip. These chips are all pin compatible and provide a variety of memory characteristics, memory size, and operating clock frequencies to enable the user to select the chip best suited for his system. Hereafter, the M37702 group microcomputers will be referred to simply as the M37702 unless there is a specific difference by version. Table 1.1.1 M37702 group ROM RAM Clock Type name size size frequency Remarks (bytes) (bytes) (MHz) M37702M2-XXXFP 8 M37702M2AXXXFP 16K (Mask ROM) 16 High-speed version of M37702M2-XXXFP M37702M2BXXXFP 25 Super high-speed version of M37702M2-XXXFP M37702S1FP 8 External ROM version of M37702M2·XXXFP M37702S1AFP - 16 External ROM version of M37702M2AXXXFP M37702S1 BFP 25 External ROM version of M37702M2BXXXFP 512 M37702E2-XXXFP 8 One time PROM version of M37702M2-XXXFP M37702E2AXXXFP 16K (One time PROM) 16 One time PROM version of M37702M2AXXXFP M37702E2BXXXFP 25 One time PROM version of M37702M2BXXXFP M37702E2FS 8 EPROM version of M37702M2·XXXFP M37702E2AFS 16K (EPROM) 16 EPROM version of M37702M2AXXXFP M37702E2BFS 25 EPROM version of M37702M2BXXXFP M37702M4-XXXFP 8 Memory expansion version of M37702M2·XXXFP M37702M4AXXXFP 32K (Mask ROM) 16 Memory expansion version of M37702M2AXXXFP M37702M4BXXXFP 25 Memory expansion version of M37702M2BXXXFP M37702S4FP 8 External ROM version of M37702M4·XXXFP M37702S4AFP - 16 External ROM version of M37702M4AXXXFP M37702S4BFP 25 External ROM version of M37702M4BXXXFP 2048 M37702E4-XXXFP 8 One time PROM version of M37702M4·XXXFP M37702E4AXXXFP 32K (One time PROM) 16 One time PROM version of M37702M4AXXXFP M37702E4BXXXFP 25 One time PROM version of M37702M4BXXXFP M37702E4FS 8 EPROM version of M37702M4·XXXFP M37702E4AFS 32K (EPROM) 16 EPROM version of M37702M4AXXXFP M37702E4BFS 25 EPROM version of M37702M4BXXXFP 3 DESCRIPTION 1.2 Performance overview 1.2 Performance overview Table 1.2.1 shows the performance overview of the M37702M2-XXXFP/ M37702M2AXXXFP/ M37702M2BXXXFP. .. Table 1 2 1 M37702M2-XXXFP / M37702M2AXXXFP / M37702M2BXXXFP performance overview Parameters Functions Number of basic instructions 103 Instruction execution time M37702M2-XXXFP SOOns (the fastest instruction at 8MHz frequency) M37702M2AXXXFP 2S0ns (the fastest instruction at 16MHz frequency) M37702M2BXXXFP 160ns (the fastest instruction at 25M Hz frequency) Clock frequency M37702M2-XXXFP 8MHz (maximum) M37702M2AXXXFP 16MHz (maximum) M37702M2BXXXFP 2SMHz (maximum) Memory size ROM 16384 bytes RAM S12 bytes Input/Output ports Ports PO-P2, P4-P8 8 bits X 8 Port P3 4 bits X 1 Multi-function timers TAO, TA1, TA2, TA3, TA4 16 bits X S TBO, TB1, TB2 16 bits X 3 Serial 110 (UART or clock synchronous serial 110) X 2 A-D converter 8 bits X 1 (8 channels) Watchdog timer 12 bits X 1 Interrupts 3 external, 16 internal (priority levels 0 to 7 can be set for each interrupt with software) Clock generating circuit Built-in (externally connected to a ceramic resonator or quartz crystal oscillator) Supply voltage SV±10% Power dissipation 30mW (at external 8MHz frequency) Input/Output characteristics Input/Output voltage SV Output current SmA Memory expansion Maximum 16M bytes Operating temperature range -20 to 8SoC Device structure CMOS high-performance silicon gate process Package BO-pin plastic molded QFP 4 DESCRIPTION 1.3 Pin configuration 1.3 Pin configuration Figure 1.3.1 shows the M37702M2-XXXFP pin configuration. zzzzzzz T""" N C") '¢ III I~ r.o t::: 10I~ 00 0 Ul:'::OO I--.....Jxx 0.. 0.. 0.. 0.. ~~~~~~~ t ~ ~; ~ P7o/ANo _ 1 0 0 P84/CTS1/RTS1 P67ITB21N _ P66ITB11N _ P65ITBOIN _ 2 3 4 -- P851CLK1 P861RxD1 P87ITxD1 P641INT2 _ P631INT1 _ P621INTo _ 5 6 7 s: ~ --- POo/Ao P01/A1 P02lA2 P61ITA41N _ P60IT A40uT _ P57ITA31N _ B -.J -.J 0 --- P03lA3 P04/A4 P05lAs P56ITA30UT _ P5s!TA2IN _ P54ITA2oUT _ 11 12 13 I\J s: --- P06lA6 P07/A7 P10/AslDs P53!TA1IN _ P521TA1oUT _ P51ITAOIN _ P50ITAOoUT _ 14 15 16 17 I\) I >< - P11/A9ID9 P121A10/D1O P131A11/D11 >< P14/A121D12 P151A131D13 >< -n P16IA14/D14 P17/A1S/D1S 0 "tlI -- P2o/A161Do P21/A17/D1 P221A1B/D2 P23/A19/D3 Outline 80P6N Fig. 1.3.1 M37702M2-XXXFP pin configuration 5 DESCRIPTION 1.4 Pin description 1.4 Pin description Table 1 .4.1 shows the pin description. Table 1.4.1 Pin description (1) Pin Name Input/Output Functions Vee Vss Power supply Supply 5V±1 0% to Vee and OV to Vss. CNVss CNVss input Input This pin controls the processor mode. Connect to Vss for single-chip mode. It must be connected to Vee for exter- nal ROM types. RESET Reset input Input The microcomputer is reset when this pin is set to "L" level. XIN Clock input Input These .are the I/O pins of the internal clock generating circuit. Connect a ceramic or quartz crystal resonator XOUT Clock output Output between XIN and XOUT. When an external clock is used, the clock source should be connected to the XIN pin and the XOUT pin should be left open. E Enable output Output Oata or instruction read and data write are performed when output from this pin is "L" level. BYTE Bus width selection input Input When in memory expansion mode or microprocessor mode, this pin determines whether the external data bus is 8-bit width.or 16-bit width. The width is 16 bits when the signal level is "L" and 8 bits when the signal level is "H". AVee, AVss Analog supply input Power supply for the A-O converter. Externally connect AVee to Vee and AVss to Vss. VREF Reference voltage input Input This is a reference voltage input pin for the A-O con- verter. POO-P07 I/O port PO I/O This port is a CMOS I/O port. An I/O direction register is available so that each pin can be programmed for input or output. Address (Ao-A7) is output in memory expan- sion mode or microprocessor mode. P1o-P17 I/O port P1 I/O This port is an 8-bit 1/0 port with the same function as PO. When the BYTE pin is set to "H" level in memory expan- sion mode or microprocessor mode, address (AB-A1S) is output. In case the BYTE pin is set to "L"level, an address (A8-A15) is output when E pin level is "H", and high-order data (08-015) is input or output when E pin level is "L". P2o-P27 I/O port P2 I/O This port is an 8-bit I/O port with the same function as PO. In memory expansion mode or microprocessor mode, an address (A16-A23) is output when E pin level is "H", and low-order data (00-07) is input or output when E pin level is "L". P30-P33 1/0 port P3 I/O This port is a 4-bit 1/0 port with the same function as PO. In memory expansion mode or microprocessor mode, P30-P33 output R/W, BHE, ALE, and HLDA signals re- spectively. P4o-P47 1/0 port P4 I/O This port is an 8-bit I/O port with the same function as PO. In memory expansion mode or microprocessor mode, P40 and P41 become HOLD and ROY input pin respec- tively. P42 can be programmed for a CPl output pin. In microprocessor mode, P42 always outputs the clock CPl' 6 DESCRIPTION 1.4 Pin description Table 1.4.1 Pin description (2) Pin Name Input/Output Functions P5o-P57 I/O port P5 I/O This port is an 8-bit I/O port with the same function as PO. These pins can be programmed as I/O pins for timers AO-A3. P6o-P67 110 port P6 I/O This port is an 8-bit 110 port with the same function as PO. These pins can be programmed as I/O pins for timer A4, external interrupt input pins for INTa-INT2, and input pins for timers 80-82. P7o-P77 I/O port P7 I/O This port is an 8-bit I/O port with the same function as PO. These pins can be programmed as analog input pins ANa-AN7. P77 also functions as the ADTRG pin for an A-D conversion trigger. P8o-P87 1/0 port P8 1/0 This port is an 8-bit I/O port with the same function as PO. These pins can be programmed as CTS/RTS, ClK, RxD, TxD pins for UARTO and UART1. 7 DESCRIPTION 1.5 Block diagram 1.5 Block diagram Figure 1.5.1 shows the M37702M2-XXXFP block diagram "B. ~Jiw ~g~ .. ~g" V> Data Buffer DB H (8) W. :l!~ Data Buffer DB L (8) 5:: ~ ..H a: 6§: ~ lnstrucbon QU009 Buffer 00 (8) t: i Instructlon Queue Buffgr 01 (S) Stl Inslrucbon Queue Baffer e~ 02(8) Address Bus Incremenler e '~~ (24) Program Addrass Register .. ~ PA(24) 6 Data Addmss RegrstQl' DA(24) .. u c;> ~ ~~ -U §: 0 IncramanterlDacrsmentar I;' (24) ~ Program Counter PC (16) ~~ Program Bank Register f~~~ PG(B) Data Bank Reglst9l' DT(B) ~ ::. ::. ~ ~ ~J ]i " E 1= ~~~~. ~ ~~ ~ as ~ ~ j~ a: j j ! j II E 1= 1 ~IW ,,~ j ,,;0" a:~ ] !, g> ~>'I il 1 ,,~ " S ~~ ... B. 1S x il N Fig. 1.5.1 M37702M2·XXXFP block diagram 8 ©[}={]£~u~~ ~ fUNCT~ONAl [D)lESCRHPT~ON 2.1 Central processing unit (CPU) 2.2 Internal bus interface 2.3 Addressable memory space 2.4 Memory allocation 2.5 Input/Output pins 2.6 Interrupts 2.7 Timer A 2.8 Timer B 2.9 Serial I/O 2.10 A-D converter 2.11 Watchdog timer 2.12 Hold function 2.13 Ready function FUNCTIONAL DESCRIPTION 2.1 Central processing unit 2.1 Central processing unit (CPU) The MELPS 7700 CPU has ten registers as shown in Figure 2.1.1. Each of these registers is described below. 2.1.1 Accumulator (Ace) Accumulators A and B are available and each can be used as 8-bit or 16-bit register as necessary. (1) Accumulator A (A) Accumulator A is the main register of the microcomputer. Data operations such as calculations, data transfer, and input/output are executed mainly through accumulator A. It consists of 16 bits and the low-order 8 bits can be used separately. The data length flag (m) determines whether the register is used as a 16-bit register or as an 8-bit register. It is used as a 16-bit register when flag m is "0" and as an 8-bit register when flag m is "1 n. Flag m is a part of the processor status register (PS) which is described later. When an 8-bit register is selected, the low-order 8 bits of the accumulator A are used and the contents of the high-order 8 bits are unchanged. (2) Accumulator 8 (8) Accumulator B has the same functions as accumulator A. The MELPS 7700 instructions can use accumulator B instead of accumulator A, but the use of accumulator B requires more instruction bytes and execution cycles than accumulator A. Accumulator B is also controlled by the data length flag m. 2.1.2 Index register X (X) Index register X consists of 16 bits and the lower 8 bits can be used separately. The index register length flag (x) determines whether the register is used as a 16-bit register or as an 8-bit register. It is used as a 16-bit register when flag x is "0" and as an 8-bit register when flag x is "1 n. Flag x is a part of the .processor status register (PS) which is described later. When an 8-bit register is selected, the low-order 8 bits of the index register X are used ant!! the contents of the high-order 8 bits are unchanged. In index addressing mode, register X is used as the index registe.r and the contents of this address is added to obtain the real address. Also, when executing a block transfer instruction MVP or MVN, the contents of the index register X indicate the low-order 16 bits of the source data address. The third byte of the MVP or MVN is the high-order 8 bits of the source data address. 2.1.3 Index register Y Index register Y is a 16-bit register with the same function as index register X. As with index register X, the index register length flag (x) determines whether this register is used as a 16-bit register or as an 8- bit register. Also, when executing a block transfer instruction MVP or MVN, the content of index register Y indicates the low-order 16 bits of the destination data address. The second byte of the MVP or MVN is the high-order 8 bits of the destination data address. 10 FUNCTIONAL DESCRIPTION 2.1 Central processing unit b15 b8 b7 bO I AH I AL I Accumulator A b15 b8 b7 bO I BH I BL I Accumulator B b15 b8 b7 bO I XH I XL I Index register X b15 b8 b7 bO I YH I YL I Index register Y b15 b8 b7 bO I SH I SL I Stack pointer S b7 bO I OT I Data bank register DT b23 b16 b15 b8 b7 bO Ib7 PG ; bO I PCH I PCL I Program counter PC :""",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. Program bank register PG b15 b8 b7 bO I OPRH I OPRL I Direct page register DPR b15 b8 b7 bO I PSH I PSL I ,, Processor status register PS ,,, ------ :,, b15 -------- , b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 bO : 10101010101 IPL INIV Imlx 101 I IllCI I Carry flag Zero flag Interrupt disable flag Decimal mode flag Index register length flag Data length flag Overflow flag Negative flag Processor interrupt priority level Fig. 2.1.1 CPU registers structure 11 FUNCTIONAL DESCRIPTION 2.1 Central processing unit 2.1.4 Stack pointer (S) $tack pointer S is a 16-bit register. It is used during a subroutine call or interrupt. It is also used during addressing modes using the stack. The contents of the stack pointer S indicates the address (stack area) for storing registers during subroutine calls and interrupts. The bank 0 must be designated for the stack area (reffer to section" 2.3 Addressable memory space"). Normally, the stack area is reserved in internal RAM. When an interrupt is accepted, the contents of the program bank register PG is stored at the address indicated by the content of the stack pointer S, and the content of the stack pOinter S is decremented by 1. Then the contents of the program counter PC and the processor status register PS are stored with the high-order bytes followed by the low-order bytes (PCH, PCl, PSH, PSl). The contents of the stack pointer S after accepting an interrupt is equal to the content before the interrupt decremented by 5. Figure 2.1.2 shows the stored registers when an interrupt is accepted. When returning to the original routine after processing the interrupt, the registers stored in the stack area are restored to the original registers in the reverse sequence and the content of the stack pointer is returned to the status before the interrupt. The same operation is performed during a subroutine call, but the content of the processor status register PS is not stored (the content of the program bank register PG may not be stored either depending on the addressing mode). The user is responsible for storing registers other than those described above during interrupts or subroutine calls. In addition, the stack pointer S must be initialized at the beginning of the program because its content is undefined at reset. Normally, the stack pointer is initialized with the highest address of the internal RAM. The contents of the stack area changes when subroutines are nested or when multiple interrupts are accepted. Therefore, make sure necessary data in the internal RAM are not destroyed when nesting subroutines. Memory Address 8-4 ~ -------- Processor status register low-order byte(PSL) 8-3 Processor status register high-order byte(PSH) 8-2 Program counter low-order byte(PCL) 8-1 Program counter high-order byte(PCH) 8 Program bank register(PG) V ~ ,* Saccepting is the first address that the stack pOinter indicates at an interrupt. Fig. 2.1.2 Stored registers when an interrupt is accepted 12 FUNCTIONAL DESCRIPTION 2.1 Central processing unit 2.1.5 Program counter (PC) Program counter PC is a 16-bit counter that indicates the low-order 16 bits of the next program memory address to be executed. The content of the high-order program counter(PCH) becomes "FF16", and the low- order program counter(PCL) becomes "FE16" at reset. The content of the program counter PC becomes the content of the reset vector address(address FFFE16, FFFF16) after removing reset state. Figure 2.1.3 shows the program counter PC and the program bank register. b23 b16b15 b8 b7 bO PG PCH PCl b7 bO Fig. 2.1.3 Program counter and program bank register 2.1.6 Program bank register (PG) Program bank register PG is an 8-bit register that indicates the high-order 8 bits (bank) of the next program memory address to be executed. When a carry occurs after incrementing the content of the program counter PC, the content of the program bank register PG is incremented by 1. Also, when a carry or borrow occurs after adding or subtracting the content of the program counter PC, the content of the program bank register PG is incremented or decremented by 1 so that programs can be written without considering bank boundaries, usually. In single-chip mode, set the value "0016" because only address between 000016 and FFFF16 can be accessed. This register is cleared to "0016" at reset. 13 FUNCTIONAL DESCRIPTION 2.1 Central processing unit 2.1.7 Data bank register (DT) Data bank register DT is an 8-bit register. With some addressing modes using the data bank registerDT, the content of this register is used as the high-order 8 bits of a 24-bit address. In single-chip mode, set the value "0016" because only address between 000016 and FFFF16 can be accessed. Use the LDT instruction to set the value in this register. This register is cleared to "0016" at reset. ,lmefer to "MEPS 7700 SOFTWARE MANUAL" for the addressing modes. 2.1.8 Direct page register (DPR) Direct page register DPR is a 16-bit register. The content of this register indicates whether the direct page area is allocated in bank 0 or spans across bank 0 and 1. This area can be accessed with two bytes by using the direct page addressing mode. The content of the DPR is the base address (lowermost address) of the direct page area which extends 256 bytes above this address. The DPR can contain a value from 000016 to FFFF16. If it contains a value equal to or greater than "FF0116", the direct page area spans across banks 0 and 1. If the low-order 8 bits of the DPR is "0016", the number of cycles required to generate an address is minimized. Therefore, the low-order 8 bits of the DPR should normally be set to "0016". This register is cleared to "000016" at reset. Figure 2.1.4 shows the setting example of the direct page with the direct page register(DPR). 016 FF16 J DPR area when DPR=000016 ..,..,..,..,.,.... ..,.., ...... ...,..,. ............... .., ....... ...,.., ........... "'-- .......................................... . . 12316J DPR area when DPR=012316 Bank 0 22216 (Note 1) DPR area when DPR=FF1016 (Note 2) Note1: The number of execution cycles is incremented by 1 when the low-order 8 bits of the DPR are not "0016". Note 2 : The direct page spans across banks 0 and 1 when the DPR is "FF0116" or greater. Fig. 2.1.4 Setting example of direct page with direct page register (DPR) 14 FUNCTIONAL lD>ESCR][IPT][ON 2.1 Central processing unit 2.1.9 Processor status register (PS) Processor status register is an 11-bit register. It consists of flags to indicate the result of operation and CPU interrupt levels. The flags C, Z, V, and N are tested by branch instructions. Figure 2.1.5 shows the register structure of the processor status register. The details of the processor status register bits are described below. b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 bO I 0 I 0 I 0 I 0 I 0 I IPL I N IV Im I x I D I I I z I c I Note: Bits 11 to 15 always are "0" when the contents of the processor status register are read. Fig. 2.1.5 Processor status register structure (1) Carry flag (C) The carry flag is assigned to bit 0 of the processor status register. It contains the carry or borrow bit from the arithmetic and logic unit (ALU) after an arithmetic operation. This flag is also affected by shift and rotate instructions. This flag can be set with the SEC or SEP instruction and cleared with the CLC or CLP instruction. (2) Zero flag (Z) The zero flag is assigned to bit 1 of the processor status register. It is set to "1" if the result of an arithmetic operation or data transfer is zero, and cleared to "0" if otherwise. This flag can be set with the SEP instruction and cleared with the CLP instruction directly. Note: The content of this flag has no meaning during decimal mode addition (ADC instruction). (3) Interrupt disable flag (I) The interrupt disable flag is assigned to bit 2 of the processor status register. It disables all maskable interrupts (interrupts other than watchdog timer, BRK instruction, and zero divide). Interrupts are disabled when this flag is "1". When an interrupt is accepted, it is set to "1" automatically to prevent multiple interrupts. This flag can be set with the SEI or SEP instruction and cleared with the CLI or CLP instruction. This flag is set to "1" at reset., (4) Decimal mode flag (D) The decimal mode flag is assigned to bit 3 of the processor status register. It determines whether addition and subtraction are performed in binary or decimal. Binary arithmetic is performed when this flag is "0". If it is "1", decimal arithmetic is performed with each word treated as two or four digit decimal (determined by the data length flag m). Decimal adjust is performed automatically. Decimal operation is possible only with the ADC and SBC instructions. This flag can be set with the SEP instruction and cleared with the CLP instruction. This flag is cleared to "0" at reset. (5) Index register length flag (x) The index register length flag is assigned to bit 4 of the processor status register. It determines whether the index register X or index register Y is used as a 16-bit register or an 8-bit register. The register is used as a 16-bit register when flag x is "0" and as an 8-bit register when it is "1". This flag can be set with the SEP instruction and cleared with the CLP instruction. This flag is cleared to "0" at reset. (6) Data length flag (m) The data length flag is assigned to bit 5 of the program status register. It determines whether to treat data as 16-bit or as 8-bit. A data is treated as 16-bit when flag m is "0" and as 8-bit when it is "1". This flag can be set with the SEM or SEP instruction and cleared with the CLM or CLP instruction. This flag is cleared to "0" at reset. 15 FUNCTIONAL DESCRIPTION 2.1 Central processing unit (7) Overflow flag (V) The overflow flag is assigned to bit 6 of the processor status register. It is used when adding or subtracting a word as signed binary. In case the data length flag m is "0", the overflow flag is set to "1" when the result of addition or subtraction is outside the range between -32768 and +32767, and cleared to "0" in all other cases. In case the data length flag m is "1 ", the overflow flag is set to "1" when the result of addition or subtraction is outside the range between -128 and +127, and cleared to "0" in all other cases. The overflow flag can also be set and cleared directly with the SEP, ClV, and ClP instructions. Note: This flag has no meaning in decimal mode. (8) Negative flag (N) The negative flag is assigned to bit 7 of the processor status register. It is set when the result of arithmetic operation or data transfer is negative (Data bit 15 is 1 when data length flag m is "0", or data bit 7 is 1 when data length flag m is "1".). It is cleared in all other cases. It can also be set with the SEP instruction and cleared with the ClP instruction. Note : This flag has no meaning in decimal mode. (9) Processor interrupt priority level (IPl) The processor interrupt priority level (IPL) is assigned to bits 8, 9, and 10 of the processor status register. These three bits determine the priority level of processor interrupts from level 0 to level 7. Interrupt is enabled when the interrupt priority level of the requested interrupt (set with the interrupt control register) is higher than the processor interrupt priority. When an interrupt is accepted, the IPL is stored in the stack and the processor interrupt priority is replaced by the interrupt priority of the accepted interrupt. This simplifies control of multiple interrupts. There are no instructions to directly set or clear the IPL. It can be changed by placing the new IPL on the stack and updating the processor status register with the PUl or PlP instruction. The content of the IPL is cleared to "000" at reset. 16 FUNCTIONAL DESCRIPTION 2.2 Internal bus interface 2.2 Internal bus interface 2.2.1 Internal bus interface overview A bus interface unit (BIU) is provided between the CPU and the internal bus. Transfer of data between the CPU and memory or 1/0 device is always performed through the BIU. When the CPU reads data from memory or 1/0 device, it sends the address to be read to the BIU. The BIU reads the data from the specified address and the CPU receives the data from the BIU. Similarly, the CPU sends the address to be written to the BIU when writing data. Thus the BIU controls the transfer of data between the CPU and bus. Figure 2.2.1 shows the block diagram of the bus interface unit. CPU CPU Bus internal interface .. bus unit ' L . .' -- Memory Peripheral devices External ,, memory ......... .... .......... Even address data bus (8 bits) Odd address data bus (8 bits) Address bus (24 bits) Fig. 2.2.1 Internal bus interface block 2.2.2 Bus interface unit functions The M37702 group uses the clock cp (=f(XIN)/2) as the clock. The CPU also uses clock cp as the clock. However, since the CPU clock may be extended due to CPU wait under certain conditions, it is referred to as ¢Cpu to distinguish it from clock cpo The M37702 group internal bus (address bus and data bus) operates at timing E which is slower than clock cpo The operating clock of the CPU is different from the bus cycle because timing E is normally f(XIN)/4. Therefore, the BIU is provided between the CPU and bus to synchronize the transfer of data to and from memory and 1/0 device. The BIU enables the CPU to transfer data to and from memory through the bus without decreasing the instruction execution speed. The BIU consists of four registers as shown in Figure 2.2.2. Table 2.2.1 shows the functions of each register and buffer. Table 2.2.1 Functions of BIU registers and buffers Name Function Program address register Indicates the address of the program. Instruction queue buffer A three-byte buffer for temporarily holding instruction prefetched from memory. Data address register Indicates the address to be read from or to be written to memory or 1/0. Data buffer A two-byte buffer for temporarily holding data read from memory or 1/0 device by the BIU or data written to memory or 1/0 device by the CPU. 17 FUNCTIONAL DESCRIPTION 2.2 Internal bus interface b23 bO PA Program address register b7 bO 00 01 Instruction queue buffer 02 b23 bO DA Data address register b15 bO DBH DBL Data buffer Fig. 2.2.2 Bus interface unit registers The BIU performs the following operations. 1.Prefetches an instruction code from the program memory (area where the program is stored) and stores it in the instruction queue buffer. Normally, a program is executed sequentially in ascending order of address. Therefore, if the next instruction code is prefetched in the instruction queue buffer, the CPU can execute instructions simply by obtaining the instruction code from the instruction queue buffer. This will eliminate the time needed by the CPU to access the memory. When the CPU is not using the bus (for example when performing register to register operation), the BI U reads an instruction code from the program memory (area where the program is stored) and stores it in the instruction queue buffer. Data up to three bytes can be prefetched because the instruction queue buffer is three bytes long. Refer to Section "2.2.4 Data read/write operations" for more information concerning instruction code prefetch. 2.Reads data at the specified address into the BIU when the CPU requests data in memory and transfers it to the CPU. When executing instructions that processes data in memory or I/O device, the CPU must access the address assigned to the memory or I/O device and read the data. Because the operating clock of the CPU and bus are different, the CPU reads the data through the data buffer of the BIU. 3.Writes the data obtained from the CPU to the specified address in memory. When writing data to a specific address, the CPU sends the address and data to the BIU. And after that, the CPU continues to execute the next instruction extracting from the instruction queue buffer, because actual writing to memory or I/O device is performed by the BIU. 4.Controls read of word data from odd number address and outputs the control signals required to access external memory in byte unit. The transfer of data between the CPU and BIU is always performed through a 24-bit address bus and 16-bit data bus. This is also true between the BIU and internal memory or I/O device. The wait bit and BYTE pin (external bus width selection input pin) determine the data width only when an external memory is accessed. 18 FUNCTIONAL DESCRIPTION 2.2 Internal bus interface 2.2.3 Bus interface unit operations Figure 2.2.3 shows the operating waveforms of the bus interface unit in memory expansion mode or microprocessor mode. The M37702 group BIU always operates at one of the waveforms shown in Figure 2.2.3. The meaning of signals ALE and E in Figure 2.2.3 are as follows: • ALE (Address Latch Enable) Signal used to latch only address signals from Table 2.2.2 Bus status according to E and R/W multiplexed signals containing data and address. E R/W Bus Status H H Not used .E' H L Not used Signal set to "L" level when the bus interface unit L H Read reads instruction code or data from memory or L L Write when it writes data to memory. Table 2.2.2 shows the bus status according to E and R/W signals. (1) Basic operation Waveform (a) is the bus interface operating waveform under the following conditions: • When a one byte internal/external memory is accessed. • When two bytes in internal memory are accessed together (starting on an even address). • When two bytes in external memory are accessed together (starting on an even address when the BYTE pin is at "L" level). • When the instruction code is obtained from memory into the instruction queue buffer. Waveform (b) is the bus interface operating waveform when accessing in byte unit under the following conditions: • When two bytes in internal/external memory are accessed together (starting on an odd address). • When two bytes in external memory are accessed together with the BYTE pin at "H" level. Waveforms (a) and (b) are the basic operating waveforms of the BIU. Waveform (a) or (b) is always used when accessing the internal memory. However, signals other than E cannot be observed in single-chip mode because the port P3 is used as a programmable I/O port. (2) Effect of the wait bit When accessing the external memory area, the BIU operating waveform changes according to the wait bit. . With the M37702 group, the external memory access time can be 1.5 times as long ( the "L" level width of E signal becomes twice) by clearing the wait bit (bit 2) to "0" in the processor mode register (address 005E16). This enables external expansion of slow memories and peripheral LSls. Note : Internal memory access is not affected by the wait bit. Figure 2.2.3 (c) to (f) show the effect of the wait bit on waveforms (a) and (b). Waveform (c) is the waveform when an external memory area is accessed under the conditions for waveform (a) with the wait bit cleared to "0". Waveforms (d) to (f) are the waveforms when an external memory area is accessed under the conditions for waveform (b) with the wait bit cleared to "0". The entire waveform is affected by the wait bit for waveform (d) and the first half or the last half is affected respectively for waveforms (e) and (f). 19 FUNCTIONAL DESCRIPTION 2.2 Internal bus interface Internal clock if' Port P2 ~ (a) E ~ ALE ---1L- 1< >1 Port P2 ~ E ~ (b) ~ \ ALE 1< >1 Port P2 ==>1 Port P2 ~ (d) E n r ALE ---Il n 1< >1 PortP2~ (e) E~ ALE~ 1< >1 PortP2~ (I) E~ ALE~ \ 1< >1 • A: Address • D: Data • The waveform is for memory expansion mode or microprocessor mode. Fig. 2.2.3 Bus interface device operating waveform 20 FUNCTJrONAJL DESCRIPTION 2.2 Internal bus interface 2.2.4 Data read/write operations (1) Instruction code read The CPU reads instructions codes from the instruction queue buffer of the BIU and executes them. The CPU notifies the BIU that an instruction code is needed during the instruction code"fetch cycle. At this point, the operation depends on whether the instruction queue buffer contains an instruction code or not. If there is an instruction code in the instruction queue buffer, it is passed to the CPU. If there is no instruction code in the instruction queue buffer, or if the amount of data in the instruction queue buffer is less than the necessary instruction code, the BIU halts the CPU until a sufficient amount of instruction codes is stored in the instruction queue buffer. Even when there is no request for instruction code from the CPU, if the instruction queue buffer is empty or if there is only one instruction code and the bus is available at the next cycle (the CPU does not use the bus at the next cycle), the BIU reads instruction codes from memory and stores them in the instruction queue buffer (instruction prefetch). During instruction prefetch, if the first address accessed when reading an instruction code from memory is even, then the data at the next odd number address is also read and stored in the instruction queue buffer. If the first accessed address is odd, only one byte is read and stored in the instruction queue buffer. However, if the instruction code is read from external memory with the BYTE pin at "H" level (external bus width 8-bit) in memory expansion or microprocessor mode, only one byte is read regardless of the accessed address. Instruction code read is performed with operation (a) or (c) shown in Figure 2.2.3. When a branch or a jump or subroutine call instruction or an interrupt is executed, the content of the instruction queue buffer is cleared and a new instruction code is read from the new address. (2) Data read/write The CPU reads and writes data from/to the BIU data buffer. The CPU issues a request to BIU when it attempts to read or write data. At this point, if the BIU is using the bus or if there is a higher priority request, the CPU is made to wait until the BIU becomes ready. When the bus is available for data read or write, the BIU operates at one of the waveforms (a) to (f) shown in Figure 2.2.3. o Data read When the CPU requests data from the BIU, it waits until the data becomes complete data in the data buffer. The BI U sends the address received from the CPU on the address bus, reads the content of memory when E signal is "L" level, and stores it in the data buffer. o Data write The CPU sends address (address at which the data is written) and data to BIU. The address is written in the BIU data address register and the data is written in the data buffer. The actual writing in memory is performed by BIU and the CPU can proceed to the next step without waiting for the BIU to complete writing data in memory. The BIU sends the address received from the CPU to the addr~ss bus, sends the contents of the data buffer to the data bus, and writes it in memory when E signal is "L" level. 21 FUNCTIONAL DESCRIPTION 2.3 Addressable memory space 2.3 Addressable memory space The M37702 group allocates all ROM, RAM, I/O, and various control registers in the same memory space. Therefore, data transfer and operation can be performed with the same instruction without distinguishing memory and I/O area. The M37702 group program counter (PC) consists of 16 bits. It is used together with an 8-bit program bank register (PG) to directly access a 16M-byte address space from 016 to FFFFFF16. 2.3.1 Banks The M37702 group address space is divided into 64K-byte blocks called banks. The M37702 group can access 256 banks from bank 0 to bank 255 (FF16) in memory expansion or microprocessor mode. The high-order 8 bits of the 24-bit address indicate the bank and the content of the program bank register (PG) or the data bank register (DT) indicates the bank to be used. If the program counter overflows at a bank boundary, the content of the program bank register is incremented by 1. If a borrow occurs in the program counter register, the content of the program bank register is decremented by 1. Therefore, programs can be written without considering the bank boundaries, usually. The banks can be accessed efficiently by using an addressing mode that uses the data bank register. Bank 0 (address 016 to FFFF16) contains the internal ROM, internal RAM, and internal I/O control registers. Note: In single-chip mode, only bank 0 can be accessed. 2.3.2 Direct page By using the direct page register (DPR), bank 0 or a 256-byte space spanning across bank 0 and bank 1 can be accessed with fewer instruction cycles by using direct page addressing mode. This area is referred to as the direct page and is normally used for frequently accessed information. The direct page ar,ea can be specified by setting the lowermost address of the required area in the direct page register (see section "2.1.8 Direct page register"). 016 SpeCial function registers Internal RAM 27F16 t - - - - - - - - I Not used Bank 0 (Note) C00016 Internal ROM , FFFF16 1000016 "'":------~ ----+--- ,, ,, Bank 1 : : 1FFFF16 !......................-.:. ___--L___ : ! FE000016 !........................: : -----rt--- : : Bank 254 : : (Bank FE16) ~ FF000016 ••••••••••••••••••••••• ,, : ~' ' : -----I-i-'-- Bank 255 : : (Bank FF16 ) FFFFFF16 L .....................l ___--L+___ Note: The memory allocation of bank 0 depends on the microprocessor type. This diagram shows the allocation for M37702M2-XXXFP. Refer to the M37702 group memory map in Appendix 1 for other types. Also note that only bank 0 can be accessed in single-chip mode. Fig. 2.3.1 Addressable memory space 22 FUNCTIONAL DESCRIPTION 2.4 Memory allocation 2.4 Memory allocation Figure 2.4.1 shows the memory map in single-chip mode. The allocated memory and I/O are described below. 2.4.1 Internal memory and peripheral device memory allocation (1) SFR (Special Function Register) area Address 000016 to 007F16 of bank 0 are the SFR (Special Function Register) area. This area contains the control registers of internal peripheral devices, I/O ports, timers, and so on. Internal peripheral devices can be accessed through these registers. Figure 2.4.2 shows the memory map of the SFR area. 00000016 Special function registers 00007F16 t - - - - - - - - - - - - - - j 00008016 Interrupt vector table Internal RAM fFFD616 A-D conversion I 00027F16 t - - - - - - - - - - - - j / FFD816 UART 1 transmission 00028016 , I FFDA16 ~----U--A-R-T--1-r-ec-e-i-v-e--~~ Not used ,f FFDC16~------------------~~ I UART 0 transmission 00 B FFF16 f--:---,.,,......,.....,......,-:-:---.,....-----I ! OOC00016 I FFDE16 UART 0 receive I i I FFE016 Timer B2 ! FFE216 Timer B1 ,f i FFE416 Timer BO FFE616 : Timer A4 I ! I FFE816 Timer A3 ! FFEA16 Timer A2 1 FFEC16 Timer A 1 i / FFEE16 Timer AO " FFF016 I INT2 ! I FFF216 INT 1 . FFF416 / INTo , I FFF616 Watchdog timer : ! FFF816 DBC (Note) FFFA16 BRK instruction FFFC16 Zero Divide FFFE16 t-------::=R==E==S==E=T:=----r~ OOFFFF16 "'--"--"'-"'-"-"'-"=--"--'-"--.:....:.....-'---'...::.....:.:.--'---------------------------'----------------------'-'-'''''"'-' M37702M2-XXXFP Note: DBC is an interrupt for the exclusive use of the debugger and is not used, usually. Fig. 2.4.1 Memory map (in single-chip mode) 23 FUNCTIONAL DESCRIPTION 2.4 Memory allocation Address (Hexadecimal notation) Address (Hexadecimal notation)' 000000 000040 Count start flag 000001 000041 000002 Port PO register 000042 One-shot start flag 000003 Port P1 reQister 000043 000004 Port PO direction register 000044 Up-down flag 000005 Port P 1 direction reQister 000045 000006 Port P2 register 000046 Timer AO register 000007 Port P3 reqister 000047 000008 Port P2 direction register 000048 Timer A 1 register 000009 Port P3 direction register 000049 OOOOOA Port P4 reQister 00004A Timer A2 register 000008 Port P5 register 000048 OOOOOC Port P4 direction reQister 00004C Timer A3 register OOOOOD Port P5 direction register 00004D OOOOOE Port P6 reqister 00004E Timer A4 register OOOOOF Port P7 register 00004F 000010 Port P6 direction reqister 000050 Timer 80 register 000011 Port P7 direction register 000051 000012 Port P8 register 000052 Timer 81 register 000013 000053 000014 Port P8 direction rEJgister 000054 Timer 82 register 000015 000055 000016 000056 Timer AO mode register 000017 000057 Timer A 1 mode register 000018 000018 Timer A2 mode reqister 000019 000059 Timer A3 mode reqister 00001A 00005A Timer A4 mode register 000018 000058 Timer 80 mode reqister 00001C 00005C Timer 81 mode register 000010 00005D Timer 82 mode reqister 00001E A-O control register 00005E Processor mode register 00001F A-D swe~pin selection register 00005F 000020 A-D reQister 0 000060 Watchdog timer 000021 000061 Watchdog timer frequen9' selection fla~ 000022 A-D register 1 000062 000023 000063 000024 A-D register 2 000064 000025 000065 000026 A-D register 3 000066 000027 000067 000028 A-D reqister 4 000068 000029 000069 00002A A-D register 5 00006A 000028 000068 00002C A-D register 6 00006C 00002D 00006D 00002E A- Dreg ister 7 00006E 00002F 00006F 000030 UART 0 transmitlreceive mode register 000070 A-D conversion interrupt control re!:lister 000031 UART 0 baud rate generator 000071 UART 0 transmission interrupt control register 000032 000072 UART 0 receive interrupt control register UART 0 transmission buffer register 000033 000073 UART 1 transmission interrupt control register 000034 UART 0 transmit/receive control register 0 000074 UART 1 receive interrupt control reqister 000035 UART 0 transmit/receive control register 1 000075 Timer AO interrupt control reqister 000036 000076 Timer A 1 interrupt control register UART 0 receive buffer register 000037 000077 Timer A2 interruQt control register 000038 UART 1 transmit/receive mode reQister 000078 Timer A3 interrupt control register 000039 UART 1 baud rate generator 000079 Timer A4 interrupt control reqister 00003A 00007A Timer 80 interrupt control register UART 1 transmission buffer register 000038 000078 Timer 81 interrupt control reqister 00003C UART 1 transmit/receive control register 0 00007C Timer 82 interrupt control register 000030 UART 1 transmit/receive control register 1 000070 INTo interrupt control register 00003E UART 1 receive buffer register 00007E rNT1 interrupt control reqister 00003F 00007F INT2 interrupt control register Fig. 2.4.2 SFR area memory map 24 FUNCTIONAL DESCRIPTION 2.4 Memory allocation Each bit in the register can be either read only, write only, or read/write bit. Refer to each block description for the register function in the SFR area, and to section "3.1.2 Internal status at reset" for the status of the SFR at reset. (2) RAM The M37702M2-XXXFP, M37702M2AXXXFP and M37702M2BXXXFP have a 512-byte static RAM at address 008016 to 027F16 in bank 0 (Note). In addition to storing data, the internal RAM area is used as stack area during subroutine calls and interrupts. Therefore, be careful of subroutine nesting levels and multiple interrupt levels so that important data is not destroyed. Note1: Refer to "Appendix 1. M37702 group memory map" for other types. (3) ROM The M37702M2-XXXFP, M37702M2AXXXFP and M37702M2BXXXFP have a 16K-byte mask ROM at address C00016 to FFFF16 in bank 0 (Note). Address FFD616 to FFFF16 are allocated to the interrupt vector table containing branch destinations (address of interrupt handling routines) when reset or interrupt occurs. This area must be allocated to ROM in microprocessor mode and external ROM version which prohibit internal ROM. Note 2 : Refer to "Appendix 1. M37702 group memory map" for other types. 2.4.2 Processor modes The M37702 group can operate in single-chip mode, memory expansion mode, and microprocessor mode. The functions of some pins, memory allocation, and address space depend on the processor mode. The processor mode can be selected internally or externally as described below . • Externally changing the processor mode The processor mode after reset start can be selected with the input level to the CNVss pin during reset start. Table 2.4.1 shows the relationship between the processor mode and the input level to the CNVss pin. Table 2.4.1 Relationship between the processor mode and CNVss pin input level CNVss Pin Processor mode Vss level (OV) Starts in single-chip mode after reset. One of the three modes can be selected by changing_ the ~rocessor mode bits. Vee level (5V) Starts in microprocessor mode after reset. The other mode must not be selected by changing the processor mode bits . • Internally changing the processor mode After reset start with the CNVss pin set to Vss level, the processor mode can be changed internally from program by changing the processor mode bits in the processor mode register (bits 1 and 0 at address 5E16). Figure 2.4.4 shows the structure of the processor mode register. In case of changing the processor mode internally, the actual function of each pin changes when the bus cycle E used to write to the processor mode register returns to "H" level. Bus cycle E Port function change§. at the rising edge of E · ~ signal .·..,. .. .• ~ ~ ~ Cycle of writing data in processor mode register Fig. 2.4.3 Port function change timing due to change in processor mode 25 FUNCTIONAL DESCRIPTION 2.4 Memory allocation (1) Single·chip mode This mode is selected when starting after reset with the CNVss pin set to Vss level. In this mode, the address bus and data bus are not output externally and all ports function as programmable I/O pins (internal peripheral device I/O pins when internal peripheral devices are used). Also note that in single- chip mode, a zero value must be stored in the data bank register and program bank register because only bank 0 can be accessed. Furthermore, in this mode, the wait bit, which is described later, is ignored and internal memory and I/O are always accessed at no wait. b7 b6 b5 b4 b3 b2 b1 bO IR/W I 0 IR/W IR/W I W I R/W I R/W I R/W I Processor mode register (address 5E16) '--r--'-,..--'--r---'-----r-l---,-----'---r--'--~lJ Processor mode bits 00 : Single-chip mode 01 : Memory expansion mode 10 : Microprocessor mode 11 : This can not available. ' - - - - - - - Wait bit o : Wait during external access 1 : No wait ' - - - - - - - - - - Software reset bit 1 : Software reset activated by writing "1" ' - - - " - - - - - - - - - - - Interrupt priority detection time selection bits 00 : 7 cycles at internal clock rp 01 : 4 cycles at internal clock rp 10 : 2 cycles at internal clock rp 11 This can not available. L - - - - - - - - - - - - - - - - l I F i X this bit to "0". I ' - - - - - - - - - - - - - - - - - - Clock rp1 output selection bit o : rp1 output disabled (Port P42 functions as normal I/O port.) : rp1 output enabled (Port P42 functions as only rp1 output pin.) Note: Bit 3 is a write-only bit. This register is cleared to "0016" at reset. Fig. 2.4.4 Processor mode register structure 26 FUNCTIONAL DESCRIPTION 2.4 Memory allocation (2) Memory expansion mode This mode is selected when the processor mode bits are set to "01" after reset start with the CNVss pin set to Vss level. This mode is used when just using internal memory and 110 is not sufficient. In this mode, the memory and peripherals can be expanded to any area within a 16M-byte addressable memory space. When the memory expansion mode is selected, ports PO to P2 become the address bus and data bus and port P3 and part of P4 become the control signal I/O pins. In this case, the port register area associated with ports PO to P3 and part of P4 become unusable and lose their normal I/O pin functions, but other memory and peripherals can be used. Refer to section "2.5 Input/Output pins" for more details concerning the functions of ports PO to P4 when the memory expansion mode is selected. If an area overlapping the internal memory area is read when the external memory is extended, 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, if data is written in this area, it is written both in the internal memory and external memory. Furthermore, the accessing of external memory in this mode is affected by the level of the BYTE pin and wait bit described in the next section. (3) Microprocessor mode This mode is selected when the processor mode bits are set to "10" after reset start with the CNVss pin set to Vss level. Also, this mode is selected vJhen starting from reset with the CNVss pin set to Vee level. The function of this mode is the same as the memory expansion mode except that access to internal ROM is disabled and port P42 always outputs the clock rjJ1 regardless of the content of the clock rjJ1 output selection bit. This mode is suitable for small volume production or prototype models before full scale production because external ROM can be installed easily. Figure 2.4.5 shows the memory map in each processor mode. Refer to section "2.5 Input/Output pins" for the change in port functions. 27 FUNCTIONAL DESCRIPTION 2.4 Memory allocation 00000016 ----------. r----::S':':FR;:-"ar-ea----. ----------. r----::SF=:R==-a-r-ea----. SFRarea ........... t-___{:;.N;.;,ot;.;,el..._ _- I ........... t-_ _...;{:;.;N;.;.ot;.;.el~_ _-i 00008016 Internal Internal Internal RAM RAM RAM 00027F16 ---------_. ~~~~~ Not used 00C00016 Internal Internal ROM ROM 00FFFF16 Single·chip mode FFFFFF16 Memory expansion Microprocessor mode mode P··\·;\'l::::\,.ll:?:;,1 : External memory area Note: Address 216 to 916 can also be used as external memory area in memory expansion mode and microprocessor mode. Fig. 2.4.5 Memory map In each processor mode (for M37702M2-XXXFP) 28 FUNCTIONAL DESCRIPTION 2.4 Memory allocation 2.4.3 External memory area bus control The BYTE pin and the wait bit are provided to simplify access to external memory area in memory expansion mode and microprocessor mode. The BYTE pin and the wait bit are valid only when accessing external memory area and have no effect when accessing internal memory or internal peripherals. Therefore, the BYTE pin and the wait bit are ignored in single-chip mode. (1) BYTE pin (external bus width selection pin) When accessing the external memory in memory expansion mode or microprocessor mode, the input level to the BYTE pin is used to select whether 8-bit data bus or 16-bit data bus (refer to section "2.5.4.(2) Data bus"). The external bus width becomes 8-bit when the BYTE pin is at "H" level. In this case, data read/write to the external area is always performed in 8-bit (i-byte) unit and the port P2 pins become the data (Do to D7) I/O pins. The use of 8-bit peripheral les is simplified by setting the bus width for external area to 8-bit. The external bus width becomes 16-bit when the BYTE pin is at "L" level. In this case, data read/write to the external area is always performed in 16-bit (1 word) unit and the port P2 pins become the data I/O pins for the low-order byte (even address data: Do to D7) of a 16-bit data and the port Pi pins become the data I/O pins for the high-order byte (odd address data: DB to D15) of a 16-bit data. The data width is always 16-bit when accessing the internal memory area regardless of the BYTE pin level. (2) Wait bit . ~ . The wait bit (bit 2 araddress 5E16) is used to attach slower memory when expanding external memory or I/O in memory expansion mode or microprocessor mode. When the wait bit is "0", a wait for external area access is enabled (one-wait mode) and bus operation is performed at the speed of 2/3 of the bus cycle (bus cycle=f(XiN)/4) during no wait. When the wait bit is "1 ", bus operation becomes no wait mode and bus cycle is f(XIN)/4. The wait bit is cleared to "0" at reset and the system starts in one-wait mode. Internal memory access is always performed at no wait because this bit is ignored. Figure 2.4.6 shows the effect of the wait bit for external access. 29 FUNCTIONAL DESCRIPTION 2.4 Memory allocation (a) Waveform when the external memory area is accessed with the wait bit set to "1 ". Internal clock ¢ Port P2 E ALE __~h:~__~nL_____ * This waveform is always used when accessing the internal memory. (b) Waveform when the external memory area is accessed with the wait bit cleared to "0". Internal clock ¢ ,, ,, , Port P2 :=JS , , ,, Data S , Data ~ E iI n I ALE ri n * Waveform (a) is used for internal memory area access even when the wait bit is "0". Fig. 2.4.6 Effect of wait bit for external access 30 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins 2.5 Input/Output pins The M37702 group has 68 programmable I/O pins (ports PO to P8). These ports also function as 1/0 ports for internal peripheral devices. There are pins that function depend on the processor mode or not. 2.5.1 Programmable I/O ports Each of the programmable 1/0 ports (ports PO to P8) has a direction register and a port register. The direction register is used to select the input/output mode by one bit. The direction registers and the data registers are allocated in the SFR area of bank O. Input level is read from the pin selecting input mode by reading the port register. The data written to the port register is output from the pin selecting output mode. Figure 2.5.1 shows the memory allocation of the direction registers and the port registers. Address 216 Port PO 316 Port P1 416 Port PO direction register 516 Port P1 direction register 616 Port P2 716 Port P3 816 Port P2 direction register 916 Port P3 direction register A16 Port P4 816 Port P5 C16 Port P4 direction register D16 Port P5 direction register E16 Port P6 F16 Port P7 1016 Port P6 direction register 1116 Port P7 direction register 1216 Port P8 1316 1416 Port P8 direction register Fig. 2.5.1 Memory allocation of direction registers and port registers 31 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins (1) Direction register Each bit of the direction register corresponds to a pin. Figure 2.5.2 shows the structure of the direction register. The port is set to input mode (input pin) when the corresponding bit is "0", and to output mode (output pin) when the corresponding bit is "1". The direction registers are cleared to "0016" at reset. Therefore, 1/0 ports are set to input mode. If 1/0 port are not used as output pins, set the corresponding direction register bit to "0" for input mode. Port Pi direction register (i=O to 8) ' - - _ - ' - - _ - ' - - _ - ' - - - - _ - ' - - - - _ . . . L - _ - ' - _ - ' - _ Port direction selection bits o : Input mode (the corresponding pin is an input pin) 1 : Output mode (the corresponding pin is an output pin) Bit Corresponding pin Note: Nothing is allocated in the high-order 4 bits of port P3 direction register. The high-order 4 bits of port P3 direction register is fixed to "0" at reading. These registers are cleared to "0016" at reset. Fig. 2.5.2 Relationship between the port direction register and pins 32 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins (2) Port register The port register is used to transfer data with external devices through the 1/0 ports. Figure 2.5.3 shows the relationship between the port register and the pins. To output data from a port set to output mode, the data must be written to the corresponding bits of the port register. This data is written in the port latch and is output from the port set to output mode. If a port programmed for output is read, the status of the output pin is not read but the content of the port latch is read. Therefore, the previously output value can be read correctly even if the output "H" voltage drops or "L" voltage rises due to external load. A pin programmed for input is floated and the value input to the pin can be read by reading the corresponding bit of the port register. If a value is written to a pin programmed for input, it is written in the port latch and the pin remains floating. b7 b6 b5 b4 b3 b2 b1 bO I R/W I R/W I R/W I R/W I R/W I R/W I R/W I R/W I P ort Pi register (i=O to 8) L Port Pio Port Pi1 Port Pi2 Port Pi3 Port Pi4 Port Pi5 Port Pi6 Port Pi? Data 1/0 is performed by reading the corresponding bit to the pin or writing to the bit. Note: Nothing is allocated in the high-order 4 bits of port P3 direction register. The high-order 4 bits of port P3 direction register is fixed to "0" at reading. Fig. 2.5.3 Relationship between the port register and pins 33 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins 2.5.2 Pin functions Figure 2.5.4 shows the port peripheral circuits. The functions of some pins depend on the processor mode while others are not affected. This section describes those pins that are not affected by the processor mode. The next section describes the pin functions according to the processor mode. (1) Effect of processor mode on pin functions The function of some pins depends on the processor mode. Table 2.5.1 shows the pin functions according to processor mode. Table 2.5.2 shows the pin functions of ports PO to P4 according to processor mode. The function of port P1 also depends on the input level of the BYTE pin (external bus width selection pin). The details of the following pins are described in the next section. Table 2.5.1 Pin functions according to processor mode ~e Pin Single·chip mode Memory expansion mode and microprocessor mode External 16-bit bus (BYTE="L") I External 8-bit bus (BYTE="H") Port PO Programmable I/O port Address bus (Ao to A7) Port P1 Programmable I/O port Address bus (AB to Ats) IAddress bus (AB to Ats) IData bus (DB to Dts) Port P2 Programmable I/O port Address bus (Ats to A23)/Data bus (Do to D7) Port P3 Programmable 1/0 port P30 .... R/W output pin P31. ... BHE output pin P32 .... ALE output pin P33 .... HLDA output pin Port P4 Programmable 1/0 port P40 .... HOLD input pin Note: P42 pin can be P41. ... RDY input pin programmed for P43 to P47 .... Same as single-chip mode ¢t output pin. P42 .... Programmable 1/0 port/clock ¢t output pin (in memory expansion mode) Clock ¢t output pin (in microprocessor mode) BYTE Ignored External bus width selection pin Ports P07 to POo, Ph to P10, P27 to P20, P33 to P3o, P4s to P42 (dotted area not included) Ports P40, P4t, P47, P5t, P53, P5s, Data bus ---H=:!§~:J-+rl-t P57, P67 to P6t, P82, P8s (dotted area included, however no hysteresis for P82 and P8s) ,..-------- , "';'--<1jj---' , .-.-.--.-.-, , Ports Ph to P70 (dotted area not included) Port P77 (dotted area included) Data bus --+c~~~efTt--f r-------- ~ Analog input ,.-.--------",, Fig. 2.5.4 Port peripheral circuits (1) 34 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins Ports P83, P87 (dotted area not included) Ports P5e, P52, P54, P5G, P6e Data bus (dotted area included) r--------- : , ,, 1 . - __ - _ _ _ _ _ _1 Ports P8e, P8l, P84, P85 Data bus E output pin Fig. 2.5.4 Port peripheral circuit (2) 35 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins Table 2.5.2 Functions of ports PO to P4 according to processor mode ____________________________ ~_r_~~~_~~~!_ ~~_~~ _~~9J~!~!________________________________ I~ mode 5 b1 bO 10101 5 b1 bO 10111 sr:irifJ 10 Port Single-chip mode Memory expansion mode Microprocessor mode Port PO E I r E ~ P07 to POo =:x I/O port x= P07 to POo =:x A7 to Ao x= E I I .- BYTE="L" Ph to P10 :=:x A.s to Ae XOATA(Odd) >C a... E I I t::: 0 a... P17to P10 =:x 110 eart x= E I I BYTE="H" Ph to P10 =:x A.s to Ae )C E I I C\J BYTE="L" E I I P27 to P20 :=:x A23 to A.s XOATA(eVen)>C a... t::: 0 a... P27 to P20 =:x I/O eort x= E I I BYTE="H" , P27 to P20 =:x A23 to A.s XDATA{Odd,eVOO) >C E I I E I I P33 =:x HLDA )C Port P3 P33 to P30 =:x I/O eart x= P32 ~ P3. =:x SHE )C P30 =:x RfW )C E I I E I I Processor mode register P47 to P40 =:x I/O port )C P47 to P42 =:x I/O port )C bit 7 = "0" P4. =:x ROY )C ": Bus cycle E cjJl output from P42 ,First waveform of cjJl may be slightly short. Fig. 2.5.6 Clock cjJl output start timing 39 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins 2.5.4 Memory expansion and microprocessor mode pin functions The only difference between the memory expansion mode and microprocessor mode is the port P42 function . • In memory expansion mode ......... P42 function is selected by the clock t{l1 output selection bit. • In microprocessor mode ............... P42 always functions as the clock t{l1 output pin (the clock t{l1 output pin selection bit is ignored). The function of each pin except for port P42 is identical in memory expansion mode and microprocessor mode. In memory expansion mode, there are 38 110 ports (ports P42 to P47 and P5 to P8). In microprocessor mode, there are 37 110 ports (ports P43 to P47, and P5 to P8). The internal address bus and data bus can be used externally in microprocessor mode. Figure 2.5.7 shows the pin connection diagram in memory expansion and microprocessor mode. Table 2.5.5 shows the pin functions depending on processor mode (ports PO to P4 and BYTE pin) in memory expansion mode and microprocessor mode. Refer to Table 2.5.3 for the functions of other pins. Table 2.5.5 Pin functions in memory expansion and microprocessor mode Pin Functions Pin Functions Port PO Address bus P40 HOLD sianal input pin (Note 2) Port P1 Address bus/data bus (Note1) P41 RDY signal input pin (Note 2) Port P2 Address bus/data bus P42 Clock t{l1 output pin (Note 3) Port P3 External memory control signal output BYTE External bus width selection signal input Note1: This may be address bus only depending on the input level of the BYTE pin. Note 2 : In memory expansion mode and microprocessor mode, the direction register bits of ports P40 and P41 must be set to input mode. Note 3 : In memory expansion mode, port P42 functions as the clock t{l1 output pin by program. 40 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins o M37702M2.. XXXFP o o Fig. 2.5.7 Memory expansion and microprocessor mode pin connection diagram 41 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins The functions of each pin in memory expansion mode and microprocessor mode are described below. (1) Address bus (ports PO, P1, and P2) Ports PO, P1, and P2 become address signal output pins and lose their programmable 110 port functions. The M37702 group allows direct access 10 16M-byte memory space from address 00000016 to FFFFFF16. Therefore, 24 address signals are output externally in memory expansion mode and microprocessor mode which allow memory and 110 to be expanded externally. Port P1 and P2 also function as data 110 pins as the same time. High-order address Middle address ...mR- "V. low·order address Output port Fig. 2.5.8 Address bus (2) Data bus In addition to address signal (high-order and middle address bus) output function, ports P1 and P2 also function as data 110 pins. The level of the BYTE pin can be used to select between 8-bit or 16- bit data bus width . • When the BYTE pin is at "L" level (16-bit external bus width) When the BYTE pin is at "L" level, the external bus width is 16 bits and even address data and odd address data are output simultaneously. Ports P1 and P2 are used as address bus and data bus, and multiplexed (address signal and data signal) signals are output from these ports. Port P1 performs time division multiplexing of address (A15 to As) output and data input/output in odd address (high-order byte of 16-bit data). Middle address is output while E signal is at "H" level, and data input/output in odd address is performed while E signal is at "L" level. Similarly, port P2 performs time division multiplexing of address (A23 to A16) output and data input/ output in even address (low-order byte of 16-bit data). High-order address is output while E signal is at "H" level, and data input/output in even address is performed while E signal is at "L" level. Do Data Data in odd address Data in even address Port P1 Port P2 Fig. 2.5.9 Data bus (when BYTE pin="L" level) 42 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins E Port PO =x_______________ C L_O_w_-o_r_de_r_a_dd_r_es_s_______________ Port P1 --V_ _ _ ---.f\ Middle_ address Data in _ _- - - I ' -_ _ _ Xodd __ _ _V address A-- Port P2 High-order address Data in even address Fig. 2.5.10 Bus timing when external bus width is 16 bits • When the BYTE pin is at "H" level (a·bit external bus width) When the BYTE pin is at "H" level, the external bus width becomes a bits, and port P2 performs time division multiplexing of address (A23 to A16) output and data I/O. Address is output while E signal is at "H" level, and a-bit data is input/output when E signal is at "L" level. IP271 P261 P2s1 P241 P231 P221 P21 IP20 I Port P2 Fig. 2.5.11 Data bus (when BYTE pin= "H" level) E Port PO =x_______________________c Low-order address Port P1 =x_______________________C Middle address Port P2 =x X'---_________C High-order address Data Fig. 2.5.12 Bus timing when external bus width is a bits 43 FUNCTIONAL DESCRIPTION 2.5 Input/Output pins (3) Port P42 Port P42 has a different function between memory expansion and microprocessor mode. In memory expantion mode, port P42 functions as the clock r/ll output pin by setting the clock r/ll output selection bit in the processor mode register to "1 ", and as programmable 110 port by setting the clock r/ll output selection bit to "0". In microprocessor mode, port P42 always functions as the clock r/ll output pin regardless of the clock r/ll output selection bit. (4) R/W output pin A read/write signal indicating the data bus direction is output. The data bus is read when the level of this pin is at "H", and data is written to data bus when it is at "L". This signal is used for external memory input/output requests. (5) BHE output pin A byte high enable signal is output. This pin is at "L" level when an odd number address is accessed. This signal is used to expand the 8-bit memory and 110 when the external bus is used at 16-bit width. Refer to section "Chapter 7. Application" for memory and 110 expantion method. (6) ALE signal output pin This signal is used to obtain only address signal from the multiplexed signals of ports P1 and P2. A latch is opened externally when the ALE signal is at "H" level to obtain the address data and the latched content is held while the ALE signal is at "L" level. (7) HOLD input pin This pin is used to input the hold request signal. The microcomputer becomes Hold state while this pin is at "L" level. Refer to section "2.12 Hold function" for details. (8) HLDA signal output pin This pin is used to externally output the hold acknowledge signal. The hold acknowledge signal indicates that "L" level is input to the HOLD pin and the microcomputer is in Hold state. An "L" level is output from this pin while the mi~rocomputer is in Hold state. (9) ROY signal input pin This pin is used to input the ready signal. The bus cycle E can be stopped (Ready state) when "L" level is input to this pin. The port and bus status at inputing "L" level to the ROY pin is maintained while in Ready state. The ROY signal is used when slow memory is externally connected. Refer to section "2.13 Ready function" for details. (10) E output pin This pin is used to output the enable signal. Data input/output is performed when the output of this pin is at "L" level. This signal controls the time division multiplexing of address information and data. (11) BYTE pin This pin is used to input the byte enable signal. The input level to this pin determines whether the external memory is used with 16-bit data width or 8-bit. When the BYTE pin input level is at "L", the data width is 16 bits, and ports P1 and P2 become the data 110 pins (data bus). When the BYTE pin input level is at "H", the data width is 8 bits and port P2 becomes the data 110 pin (data bus). However, the data width is always, 16 bits regardless of the BYTE pin level when accessing an internal memory. (12) CNVss pin This pin controls the microprocessor operating mode. Memory expansion or microprocessor mode is selected by changing the processor mode bit in the processor mode register after reset start with setting this pin to the same level as the Vss pin. The microprocessor mode can also be selected by reset start with setting this pin to the same level as the Vee pin. This pin must be set to Vee level for external ROM version models such as the M37702S1 FP (refer to section "2.4.2 Processor modes"). 44 FUNCTIONAL DESCRIPTION 2.6 Interrupts 2.6 Interrupts The suspension of the current operation in order to perform another operation due to a certain event is referred to as an "interrupt". Interrupt is used when there is a request to execute a higher priority routine or when an operation must be performed at a certain timing. 2.6.1 Interrupt functions The M37702 group has 19 different sources of interrupts. When an interrupt is generated, a branch is made to the address (branch address) corresponding to the source. The branch address must be stored in the interrupt vector table. The interrupt vector table is allocated at address FFD616 to FFFF16 in bank O. When writing programs, branch must be made to the address in the interrupt vector table corresponding to each interrupt (interrupt vector address). The branch address is the start address of the interrupt handling routines (interrupt service routine). Figure 2.6.1 shows the interrupt mechanism. Executing routine Interrupt service routine ~ Inte""pl processing Interrupt~ Suspend operation Res"me processing ~ Return to . Oflgina.! End interrupt processing rOUtine RTI instruction Fig. 2.6.1 Interrupt mechanism 45 FUNCTIONAL DESCRIPTION 2.6 Interrupts When an interrupt is accepted, the contents of the following registers before the interrupt are stored to the stack area in the order (j)-.®-.®. (j) Program bank register (PG) ® Program counter (PCl, PC H) ® Processor status register (PSl, PSH) The procedure for storing these registers depends on whether the content of the stack pointer S is even or odd. When the content of the stack painter S is even, the content of the program counter PC and processor status register PS are stored in 16-bit unit. When the content of the stack painter S is odd, they are stored in 8-bit unit. Figure 2.6.2 shows the status of the stack area when an interrupt is accepted. When interrupt processing completes, the control must be returned to the original routine to resume processing. Therefore, the RTI instruction is used to return to the original routine and the above registers stored to the stack area are restored in the order of ®-.®-.(j) to resume operation. Only ·the above registers (j) to ® are stored automatically when an interrupt is accepted. The user is responsible for storing other necessary registers. Memory Address S-4 S-3 ~ ------ Low-order byte of processor status register (PSL) High-order byte of processor status register (PSH) S-2 Low-order byte of program counter (PCl) S-1 High-order byte of program counter (PCH) S Program bank register (PG) V-- ~ Note: S indicates the initial value at accepting the interrupt. Fig. 2.6.2 Content of the stack area when an interrupt is accepted 46 FUNCTIONAL DESCRIPTION 2.6 Interrupts 2.6.2 Sources of interrupts Table 2.6.1 shows the sources of interrupts and the corresponding vector address. Store the start address of the interrupt service routine at the vector address shown in this table. Table 2.6.1 Interrupt sources and vector address Vector address Interrupt source High·order Low-order Remarks address address Reset (Note 1) 00FFFF16 00FFFE16 Non-maskable Zero divide 00FFFD16 00FFFC16 Non-maskable software interrupt BRK instruction 00FFFB16 00FFFA16 Non-maskable software interrupt DBC (Note 2) 00FFF916 OOFFF816 Not used normally Watchdog timer OOFFF716 OOFFF616 Non-maskable interrupt INTo OOFFF516 OOFFF416 External interrupt due to INTo pin input signal INT1 OOFFF316 OOFFF216 External interr[Jpt due to INT1 pin input signal INT2 OOFFF116 OOFFF016 External interrupt due to INT2 pin input signal Timer AO OOFFEF16 OOFFEE16 Timer AO internal interrupt Timer A1 OOFFED16 OOFFEC16 Timer A1 internal interrupt Timer A2 00FFEB16 OOFFEA16 Timer A2 internal interrupt Timer A3 OOFFE916 OOFFE816 Timer A3 internal interrupt Timer A4 00FFE716 OOFFE616 Timer A4 internal interrupt Timer BO 00FFE516 OOFFE416 Timer BO internal interrupt Timer B1 OOFFE316 OOFFE216 Timer B1 internal interrupt Timer B2 OOFFE116 OOFFE016 Timer B2 internal interrupt UARTO receive OOFFDF16 OOFFDE16 Valid only when the UARTO function is selected. UARTO transmission OOFFDD16 OOFFDC16 UART1 receive OOFFDB16 OOFFDA16 Valid only when the UART1 function is selected. UART1 transmission 00FFD916 OOFFD816 A-D conversion OOFFD716 OOFFD616 Internal interrupt that occurs when A-D conversion completes. Note1: Reset is included in this table. Note 2 : The DBC interrupt is a debug control interrupt and is not normally used. 47 FUNCTIONAL DESCRIPTION 2.6 Interrupts Each interrupt source is described below. (1) Internal interrupt Table 2.6.2 shows the sources of internal interrupt. Table 2.6.2 Internal interrupt sources Interrupt Interrupt source Zero divide Occurs when 0 is specified as the divisor for a DIV instruction. (See "MELPS 7700 Software Manual") BRK instruction Occurs when a BRK instruction is executed. (See "MELPS 7700 Software Manual") Watchdog timer Occurs when the topmost bit of the 12-bit watchdog timer becomes "0". (See section "2.12 Watchdog timer") Timer Ai Occurs when timer Ai (i=O to 4) underflows or overflows. (See section "2.7 Timer A") Timer Bi Occurs when timer Bi (i=0 to 2) underflows or overflows. (See section "2.8 Timer S") UARTi receive Occurs durinq UARTi (j=0,1) receive. (See section "2.9 Serial 1/0'1 UARTi transmission Occurs during UARTi (i=0,1) transmit. (See section "2.9 Serial 1/0") A-O conversion Occurs when A-O conversion completes. (See section "2.11 A-O Converter") (2) External interrupt (INTo to INT2 interrupts) There are three external interrupts (INTo to INT2). These interrupts are generated by input level or input edge to pins INTo to INT2. The interrupt sources can be selected by using bits 4 and 5 of the INTi (i=O to 2) interrupt control register shown in Figure 2.6.4. Table 2.6.3 shows the sources of INTi interrupts. Pins INTo to INT2 are shared with ports P62 to P64. Therefore, the corresponding bit in the port P6 direction register must be cleared to "0" in order to use these pins as external interrupt input pins. If the INTi interrupts are not used, the INTi interrupt priority (see next section) should be set to 0 because the INTI interrupts always monitor the status of ports P62 to P64 to raise interrupt requests. The input signal to the INTi pins must have pulse width greater than 250ns at "H" level or "L" level regardless of the source oscillating frequency f(XIN). Table 2.6.3 INTI Interrupt sources b5 b4 Interrupt source 0 0 Falling edge of the signal input to the INTi pin 0 1 Rising edge of the signal input to the INTi pin 1 0 When the INTI pin level becomes "H" 1 1 When the INTi pin level becomes "L" 48 FUNCTIONAL DESCRIPTION 2.6 Interrupts 2.6.3 Interrupt control The enabling and disabling of interrupts are controlled by the interrupt request bit, interrupt priority level, processor interrupt priority (IPL), and interrupt disable flag (I) (excluding some software interrupts). The interrupt disable flag and the processor interrupt priority level are assigned to the processor status register (PS). The interrupt request bit and the interrupt priority level are assigned to the interrupt control register of the respective interrupt. Figure 2.6.3 shows the memory map of the interrupt control register and Figure 2.6.4 shows the structure. However, there is no interrupt control register for non-maskable interrupts such as zero divide interrupt, BRK instruction interrupt, and watchdog timer interrupt. • Non-maskable interrupt: An interrupt that causes branch to the interrupt service routine regardless of the interrupt control flags. - • Maskable interrupt: An interrupt that can be disabled with the interrupt control flags. Address 7016 A-D conversion interrupt control register 7116 UARTO transmission interrupt control register 7216 UARTO receive interrupt control register 7316 UART1 transmission interrupt control register 7416 UART1 receive interrupt control register 7516 Timer AO interrupt control register 7616 Timer A1 interrupt control register 7716 Timer A2 interrupt control register 7816 Timer A3 interrupt control register 7916 Timer A4 interrupt control register 7A16 Timer 80 interrupt control register 7816 Timer 81 interrupt control register 7e16 Timer 82 interrupt control register 7D16 INTo interrupt control register 7E16 , INT1 interrupt control register 7F16 INT2 interrupt control register Fig. 2.6.3 Interrupt control register memory map 49 FUNCTIONAL DESCRIPTION 2.6 Interrupts .A-D conversion, UARTO and 1 transmission, UARTO and 1 receive, timers AO to A4, timers BO to B2 interrupt control registers b7 b6 b5 b4 b3 b2 b1 bO ( address 7016 to 7C16) '----'------'----- Interrupt priority level selection bits ' - - - - - - - - - Interrupt request bit o : No interrupt request 1 : Interrupt request' Note: Bits 4 to 7 are undefined at reading. Bits 0 to 3 are cleared to "0" at reset. .INTo to INT2 interrupt control registers b7 b6 b5 b4 b3 b2 b1 bO ( address 7016 to 7F16) '----'---'--- Interrupt priority level selection bits ' - - - - - - - - - Interrupt request bit o : No interrupt request - 1 : Interrupt request ' - - - - - - - - - - - - - Level/edge selection bit o : Set interrupt request bit at "H" level for level sense and the falling edge for edge sense. : Set interrupt request bit at "L" level for level sense and the rising edge for edge sense. ' - - - - - - - - - - - - - - - - Level sense/edge sense selection bit o : Edge sense 1 : Level sense Note: Bits 6 and 7 are undefined at reading. Bits 0 to 5 are cleared to "0" at reset. Fig. 2.6.4 Interrupt control register structure 50 FUNCTIONAL DESCRIPTION 2.6 Interrupts The interrupt control bits are described below. (1) Interrupt disable flag (I flag) The interrupt disable flag (I flag) is assigned to the processor status register bit 2. This flag can be used to disable all maskable interrupts. All maskable interrupts are disabled when the I flag is set to "1" and enabled when it is cleared to "0". This flag is set to "1" at reset and must be cleared to "0" if interrupts are to be enabled. (2) Interrupt request bit When an interrupt request occurs, the interrupt request bit which is bit 3 of the corresponding interrupt control register is set to "1 ". The interrupt request bit remains set until the interrupt is accepted, and is cleared to "0" when the interrupt is accepted. This flag is used to indicate that an interrupt request has occurred. This bit can also be set or cleared by program. The INTI interrupt request bit has a function different from the above description when used in level sense mode. ClINTi interrupt request bit When the INTi interrupt is used in level sense mode (level sense/edge sense selection bit set to "1 "), the INTi interrupt request bit becomes a status bit indicating the status of the INTi input pin (ports P62 to P64). ;Therefore, the INTi interrupt request bit is set to "1" when the minput pin level is "H", and to "0" when it is "L" regardless of whether an interrupt request occurs or is accepted. 51 FUNCTIONAL DESCRIPTION 2.6 Interrupts (3) Interrupt priority level and processor interrupt priority level (IPL) An interrupt priority level between 0 and 7 can be assigned to each interrupt by using the interrupt priority level selection bits which are assigned to bits 0 to 2 of each interrupt control register. When an interrupt request occurs, this priority level is compared with the processor interrupt priority level in the processor status register. Interrupt priority level> Processor interrupt priority level (IPL) An interrupt is enabled when the above condition is satisfied. Therefore, an interrupt can be disabled by setting its priority level to O. The interrupt disable flag, interrupt request bit, interrupt priority level, and IPL are independent of each other and do not affect each other. An interrupt is generated only when all of these bits are properly set. These bits can be used to control interrupt priorities in a variety of ways by program. Table 2.6.4 shows the setting of interrupt priority levels and Table 2.6.5 shows the interrupt enable levels corresponding to IPL setting. Table 2.6.4 Setting of interrupt priority level Interrupt control register Interrupt priority level Priority b2 b1 bO 0 0 0 Level 0 (Interrupt disabled) - 0 0 1 Level 1 Low 0 1 0 Level 2 0 1 1 1 1 1 0 0 1 1 1 0 1 0 1 Level 3 Level 4 Level 5 Level 6 Level 7 Table 2.6.5 Interrupt enable levels corresponding to IPL setting l High IPL2 IPLl IPLo Enabled interrupt priority level 0 0 0 Enable level 1 and above interrupts. 0 0 1 Enable level 2 and above interrupts. 0 1 0 Enable level 3 and above interrupts. 0 1 1 Enable level 4 and above interrupts. 1 0 0 Enable level 5 and above interrupts. 1 0 1 Enable level 6 and above interrupts. 1 1 0 Enable level 7 interrupts. 1 1 1 Disable all maskable interrupts. IPLo: Processor status register bit 8 IPL 1: Processor status register bit 9 IPL2: Processor status register bit 10 52 FUNCTIONAL DESCRIPTION 2.6 Interrupts 2.6.4 Interrupt priority level All interrupts have an assigned priority level. When more than one interrupt request occurs during the same sampling interval (interval in which interrupt requests are checked) while all interrupts are enabled, the one with the highest priority is accepted. The priority level of all of the 19 sources except for software interrupts (zero divide and BRK instruction interrupt) and watchdog timer interrupt can be set by program using the interrupt priority level selection bits in the interrupt control register. Reset (highest priority) and watchdog timer interrupt priorities are set by the hardware. Figure 2.6.5 shows the hardware controlled interrupt priorities. ---------------, :0<0000<0: < Watchdog timer < t::l L.:J I A-O convert, UART interrupt, and so on I Priority detern:'ined by hardware L____________ I Interrupt priorities inside the dotted line are user settable Fig. 2.6.5 Hardware controlled interrupt priorities 2.6.5 Interrupt priority level detection circuit The M37702 group is equipped with an interrupt priority level detection circuit to select the highest priority when more than one interrupt request occurs during the same sampling interval. Figure 2.6.6 shows the interrupt priority level detection circuit. 53 FUNCTIONAL DESCRIPTION 2.6 Interrupts 1 Level zero Interrupt priority level , (initial value) r--------. Interrupt priority level 1.--------. A-O conversion TimerA4 UART1 transmission Timer A3 UART1 receive Timer A2 UARTO transmission Timer Al UARTO receive Timer AO Timer B2 Timer B1 Timer BO :'- _______ JI IPL Interrupt disable flag;:;--~~-..I Watchdog timer-----I } - - - The occurrence of interrupt Reset----' Fig. 2.6.6 Interrupt priority level detection circuit 54 FUNCTIONAL DESCRIPTION 2.6 Interrupts Time r - - - - - - -...... y I Interrupt source Y ~ Comparator X:The highest priority level at this point \/ (Priority Y:Priority level of interrupt source Y detection) Z:The highest priority level at this point iz • If X?Y then Z=X elf X processor status register changes to the priority of the accepted interrupt. Therefore, if the interrupt ~ disable flag I is cleared to "0" in the interrupt handling Multiple interrupt routine for the accepted interrupt, interrupts with priority higher than the current interrupt can be accepted as long as IPL is unchanged. This is referred I to as multiple interrupts. Figure 2.6.12 shows the multiple interrupt mechanism. ATI instruction ,,- .--- --- ---- -- -- - ----,, 1 (Interrupt 3) i : IPL=1 : 1 ______ - - - - - - - - ______ • .1 Interrupt 3 cannot be accepted because the ATI instruction priority of interrupt 3 is lower than interrupt 1'so I I :Set automatically C=:J :Set by program Fig. 2.6.12 Multiple interrupt 60 FUNCTIONAL DESCRIPTION 2.6 Interrupts 2.6.10 Interrupt response time and interrupt delay time When an interrupt request occurs, the priority must be checked and the INT ACK sequence must be executed before interrupt service routine can start. The interval between the interrupt request and the start of the interrupt service routine is referred to as the interrupt response time. This is shown in Figure 2.6.13. Interrupt priority detection is performed at the beginning of each instruction and during the INTACK sequence. This is performed in parallel with the instruction execution. Therefore, the interrupt response time is the sum of CD through ® as follows (in Figure 2.6.13): CD The interval from the time of the interrupt request until the instruction being executed completes. ® The interval from the start of the next instruction (start of interrupt priority detection) until the end of the instruction being executed at the end of priority detection. ® Time required to execute the INTACK sequence (13 cycles minimum, 15 cycles maximum). If registers are stored at the beginning of the interrupt service routine, the time required for this operation (context switching time) must also be added. The sum of the interrupt response time and the context switching time is the interrupt delay time (see Figure 2.6.13). This is the time required for the interrupt processing program to start after an interrupt request occurs. The interrupt delay time is expressed by the following equation. Interrupt delay time=(time required to execute instruction 1) + (time required to execute instruction 2) - 0.5<{l + (INTACK sequence interval) + (context switching time) Interrupt request is accepted. Interrupt request occurs. ~ ~ ® ----Time Instructions in interrupt Instruction 1 Instruction 2 INT ACK sequence Context service routine switching time ® ® Interrupt response time Interrupt delay time ® : Interrupt priority level detection Fig. 2.6.13 Interrupt response time and interrupt delay time 61 FUNCTIONAL DESCRIPTION 2.6 Interrupts [Precautions when using interrupts] 1. When the INTi interrupt is used in level sense mode, the INTI interrupt request bit functions as a status bit which indicates whether the INTI pin level is valid or invalid. It is set to "1" while valid and to "0" while invalid. After an interrupt is accepted, the interrupt request bit remains set to "1" while valid level is supplied to the INTi pin. The interrupt request is not retained when changing from valid level to invalid level if no interrupt is generated during valid level. Figure 2.6.14 shows the INTi interrupt during level sense mode. If the level of the INTi pin is valid (did not change from valid level to invalid level) when returning to the original routine after processing an interrupt, another interrupt is generated as shown in Figure 2.6.15. "1 "(disable) Interrupt disable flag I "O"(enable) ,. Valid ,,. INTi pin level t :. Invalid , .' Interrupt "1" ~: :" request bit L-: .. ~: "0" Interrupt enable inteNal This interrupt request is not retained because INTI pin returns to invalid level before accepting the interrupt request. Fig. 2.6.14 INTi Interrupt during level sense mode Detect interrupt Return to original routine Valid INTi pin level Invalid Interrupt seNice routine RTI RTI RTI instruction instruction instruction Fig. 2.6.15 Repeating INTi interrupt (level sense) 62 FUNCTIONAL DESCRIPTION 2.6 Interrupts 2. To change the INTI interrupt from level sense to edge sense, set the INTi interrupt control register in the sequence shown in Figure 2.6.16. Set the interrupt priorily level 10 level 0 ( Disable INTi interrupt) Sellhe level sense/edge sense selection billo "0" ( Select edge sense) Clear the interrupt request bit to "0" Sellhe inlerrupt priority level 10 level 1 to 7 ( Enable INTi interru'pt ) ,,, Fig. 2.6.16 Level/Edge sense switching flow 3. To change the INTi interrupt phase, set the INTi interrupt control register in the sequence shown in Fig. 2.6.17. Set the interrupt priority level to level 0 ( Disable INTi interrupt) ( Set the level/edge selection bit) Clear the interrupt request bit to "0" Set the interrupt priority level to level 1 to 7 ( Enable INTi interrupt) , ,, , ,, Fig. 2.6.17 Phase switching flow 63 FUNCTIONAL DESCRIPTION 2.7 Timer A 2.7 Timer A Timer A consists of five 16-bit timers (timers AD to A4). External output is the main function of these timers. Timers AD to A4 operate independently and each can operate in one of four different modes. 2.7.1 Timer A description Timer Ai (i=O to 4) has four operating modes as described below. These timers have identical functions except the two-phase pulse signal processing function in event counter mode. The timer 1/0 pins are shared with ports P50 to P57, P6o, and P61. .Timer mode This mode counts the selected internal clock. The counter is decremented by 1 each time a count source (selected clock) is input and a timer Ai interrupt request occurs when the content of the counter reaches 0000,6 ~ reload value "n" (hereafter referred to as underflow). Gate function (control count operation with the input level to the TAilN pin) and pulse output function (output from the TAiouT pin, a signal that changes phase each time the counter underflows) are available and can be selected by program . • Event counter mode This mode counts the external clock input to the TAilN pin. The counter can be incremented (add 1 to the content of the counter with each clock input) or decremented (subtract 1 from the content of the counter with each clock input) by program or with an external signal. In case used as an increment counter, a timer Ai interrupt request occurs when the counter reaches FFFF,s ~ reload value "n" (hereafter referred to as overflOW). In case used as a decrement counter, a timer Ai interrupt request occurs when the counter underflows. In addition, the pulse output function (output from the TAiouT pin, a signal that changes phase each time the counter underflows or overflows) can be selected by pro- gram. Timers A2, A3, and A4 also have two-phase pulse signal processing function which controls the counter increment/decrement by a two-phase signal with the phases shifted by 90 degrees . • One-shot pulse mode In this mode, the timer is driven by an internal or external trigger and "H" level is output from the TAiouT pin for an arbitrary' interval. .Pulse width modulation (PWM) mode In this mode, an arbitrary pulse width signal is output repeatedly from the TAiouT pin. PWM output is started by an internal or external trigger. 64 FUNCTIONAL DESCRIPTION 2.7 Timer A 2.7.2 Block description Figure 2.7.1 shows the block diagram of timer Ai. It is followed by the description of timer Ai related registers. Count source Data blJs(odd) 12~ionbit 116--0 164--0 (High-order 8bits) Timer mode Interrupt request bit Up/down selection(always TAilN decrement except for event counter mode) External trigger Downcount~ IUp-down flag~ r:: Pc'" ,"!pc, ~ TAi OUTOf----------- Event counter mode Read timer counting value Write to reload register One-shot pulse mode Pulse width modulation mode Read undefined value Write to reload register and counter 66 FUNCTIONAL DESCRIPTION 2.7 Timer A (2) Count start flag The count start flag (address 4016) separately controls starting/stopping of each timer. Each bit cor- responds to one of the timers. A count source is input to the counter when this flag is set to "1" and disabled when it is set to "0". Figure 2.7.2 shows the structure of the count start flag. b7 b6 b5 b4 b3 b2 b1 bO I R/W I R/W I R/W I R/W I R/W I R/W I R/W I R/W I Count start flag (address 4016) ~ Timer AO count start flag I Timer Ai count start flag Timer A2 count start flag Timer A3 count start flag Timer A4 count start flag Timer BO count start flag Timer B1 count start flag Timer B2 count start flag Note: This register is cleared to "0016" at reset. Fig. 2.7.2 Count start flag register structure (3) One-shot start flag The one-shot start flag (address 4216) generates a software trigger used in one-shot pulse mode. When a corresponding one-shot start flag to each timer is set to "1" in case software trigger is selected, a software trigger starting one-shot pulse output is generated. Refer to section "2.7.5 One- shot pulse mode" for more information. Figure 2.7.3 shows the structure of the one-shot start flag. b7 b6 b5 b4 b3 b2 b1 bO One-shot start flag (address 4216) Timer AO one-shot start flag Timer Ai one-shot start flag L-....._ _ _ L -_ _ _ _ _ _ Timer A2 one-shot start flag L -_ _ _ _ _ _ _ _ Timer A3 one-shot start flag L-....._ _ _ _ _ _ _ _ _ _Timer A4 one-shot start flag Note: Bits 5 to 7 are undefined at reading. Bits 0 to 4 are cleared to "0" at reset. Fig. 2.7.3 One-shot start flag register structure 67 FUNCTIONAL DESCRIPTION 2.7 Timer A (4) Up-down flag The up-down flag (address 4416) is a register consisting of up-down flags and two-phase pulse signal processing selection bits used in event counter mode. Figure 2.7.4 shows the structure of the up-down flag register followed by a description of each bit. b7 b6 b5 b4 b3 b2 b1 bO I W I W I W I R/W I R/W I R/W I R/W I R/W Up-down flag (address 4416) ~ Timer AD up-down flag I Timer Ai up-down flag Timer A2 up-down flag Timer A3 up-down flag Timer A4 up-down flag Timer A2 two-phase signal processing selection bit Timer A3 two-phase signal processing selection bit Timer A4 two-phase signal processing selection bit Note: This register is cleared to "0016" at reset. Fig. 2.7.4 Up-down flag register structure .Timer Ai up-down flags (bits 0 to 4) These flags are valid in event counter mode when the count up-down flag is selected as the increment! decrement trigger. The counter of the corresponding timer is decremented when this flag is "0" and incremented when it is "1" . • Two-phase signal processing selection bits (bits 5 to 7) In event counter mode, these bits select the two-phase pulse signal processing function which controls the counter using two-phase pulse with their phases shifted by 90 degrees. This bit can be an only written to. The corresponding timer operates with the two-phase pulse signal processing when this bit is set to "1". This bit must be set to "0" when the two-phase pulse signal processing function is not used and in modes other than event counter mode. It is cleared to "0" at reset. Use LDM and STA instructions to write to this bit. Do not use SEB and CLB instructions. (5) Timer Ai mode register The timer Ai mode register (address 5616 to 5A16) consists of operating mode selection bits, count source selection bits, and timer function selection bits. Figure 2.7.5 shows the structure of the timer Ai mode register. The operating mode selection bits and count source selection bits are described below. The functions of bits 2 to 5 depend on the operating mode and are described under the description of each operating mode. 68 FUNCTIONAL DESCRIPTION 2.7 Timer A b7 b6 b5 b4 b3 b2 b1 bO Timer AO mode register (address 5616) IR/W IR/W IR/W IR/W IR/WJI I I Timer Ai mode register (address 5716) R/W R/W R/W Timer A2 mode register (address 5816) II Timer A3 mode register (address 5916) Timer A4 mode register (address 5A16) Operating mode selection bits 00 : Timer mode 01 : Event counter mode 10 : One-shot pulse mode 11 : Pulse width modulation (PWM) mode : These bits' functions depend on operating mOde.l Count source selection bits 00 : Clock oscillating frequency divided by 2 (f2) 01 : Clock oscillating frequency divided by 16 (f16) 10 : Clock oscillating frequency divided by 64 (f64) 11 : Clock oscillating frequency divided by 512 (f512) Note:This register is cleared to "0016" at reset. Fig. 2.7.5 Timer Ai mode register structure .Operating mode selection bits (bits 0 and i) The operating mode selection bits are used to select the timer operating mode. Table 2.7.3 shows the relationship between the operating mode selection bits and the timer operating modes. Table 2.7.3 Relationship between operating mode selec· tion bits and operating mode bi bO Operating mode 0 0 Timer mode 0 1 Event counter mode 1 0 One-shot pulse mode 1 1 Pulse width modulation (PWM) mode .Count source selection bits (bits 6 and 7) " The count source selection bits are used to select the count source. Table 2.7.4 shows the relationship between the count source selection bits and the timer count sources. These bits are ignored in event counter mode. Table 2.7.4 Relationship between count source selection bits and count sources Input clock to the counter b7 b6 Timer count source f(XIN}=8MHz f(XIN}=i6MHz f(XIN)=25MHz 0 0 Clock OSCillating frequency divided by 2 (f2) 4MHz 8MHz 12.5MHz 0 1 Clock oscillating frequency divided by 16 (f16) 500kHz iMHz 1.5625MHz 1 0 Clock oscillating frequency divided by 64 (f64) 125kHz 250kHz 390.625kHz 1 1 Clock OSCillating frequency divided by 512 (f512) 15625Hz 31250Hz 48.8281 kHz 69 FUNCTIONAL DESCRIPTION 2.7 Timer A (6) Timer Ai interrupt control reg ister The timer Ai interrupt control register (address 7516 to 7916) consists of interrupt priority level selection bits and interrupt request bit. Figure 2.7.6 shows the structure of the timer Ai interrupt control register. The function of each bit is described below. Refer to section "2.6 Interrupts" for more information. b7 b6 b5 b4 b3 b2 b1 bO Timer AD interrupt control register (address 7516) Timer A 1 interrupt control register (address 7616) Timer A2 interrupt control register (address 7716) Timer A3 interrupt control register (address 7816) Timer A4 interrupt control register (address 7916) L-_L-_L-_ Interrupt priority selection bits 000 : Level 0 (disable interrupt) 001 : Level 1 Low 010 : Level 2 011 : Level 3 100 : Level 4 Priority 101 : Level 5 110 : Level 6 111 : Level 7 High Interrupt request bit o : No interrupt request 1 : Interrupt request Note: Bits 4 to 7 are undefined at reading. Bits 0 to 3 are cleared to "0" at reset. Fig. 2.7.6 Timer Ai interrupt control register structure .Interrupt priority level selection bits (bits D to 2) These bits are used to select the interrupt priority level. They should be set to a level between 1 and 7 when using a timer Ai interrupt. When there is an interrupt request, this level is compared with the processor interrupt priority level (IPL) in the processor status register (PS) and an interrupt is allowed only when this level is greater than IPL(interrupt disable flag I must be "0"). Set these bits to "000" to disable only timer Ai interrupt. .Interrupt request bit (bit 3) This bit is set to "1" when a timer Ai interrupt request occurs. The interrupt request bit set to "1" is cleared to "0" when the interrupt request is accepted. This bit can be set or cleared by. program. 70 FUNCTIONAL DESCRIPTION 2.7 Timer A (7) Ports P5 and P6 direction registers The input/output pins of timers AO to A3 are shared with port P5 and the input/output pins of timer A4 are shared with port P6. When using these ports as timer input pins, the corresponding bit in the direction register must be set to "0" (input mode). When using these ports as timer output pins, these ports function as timer output pins regardless of the content of the direction register. Figure 2.7.7 shows the relationship between port P5 direction register (address ODI6) and port P6 direction register (address 1016) with timer pins. b7 b6 b5 b4 b3 b2 b1 bO I R/W I R/W I R/W I R/W I R/W I R/W I R/W I R/W I Port P5 direction register (address 0016) ~ TAOoUT pin l TAOIN pin TA10UT pin TA11N pin TA20UT pin TA21N pin TA30UT pin TA31N pin b6 b5 b4 b3 b2 b1 bO Port P6 direction register (address 1016) TA40UT pin '-----TA4IN pin '----L--L--..L-..-..L-..-...L------INT pins, Timer B pins Note:These registers are cleared to "0016" at reset Fig. 2.7.7 Relationship between port P5 and P6 direction registers with timer pins 71 FUNCTIONAL DESCRIPTION' 2.7 Timer A 2.7.3 Timer mode [timer Ai mode register bits 1, 0 = "00"] The timer mode is selected by setting the timer Ai mode register bits 1 and 0 to "00". When this mode is selected, bit 5 of the timer Ai mode register must be set to "0", Figure 2.7.8 shows the structure of the timer Ai mode register in timer mode. In timer mode, the selected internal clock is decremented and an interrupt request occurs each time the counter underflows (the content of the counter reaches 000016 --7 reload value "n"). The timer dividing ratio is expressed as follows: Timer dividing ratio=1/{n+1) n: Value set in counter (value between 000016 and FFFF16) The following functions can be selected with the timer Ai mode register. .Gate function Controls count with the input signal to the TAilN pin . • Pulse output function Outputs from the T AiouT pin, a signal that changes phase each time the counter underflows. (1) Timer mode operation First, select the operating mode, pulse output function, gate funqtion, and count source with the timer Ai mode register, Next, write a value "n" ("n" = 000016 to FFFF16) in the timer Ai Set timer Ai mode register ' • Set the operating mode selection bits(bit1 ,0) to "00· register to specify the timer dividing ratio. At • Select pulse output function the same time, the value "n" is stored in the • Select gate function • Set bit 5 to "0· counter and the reload register. • Select count source When the count start flag is set to "1" (count enabled), the selected count source is input to the counter and starts the count operation. Specify timer dividing ratio • Set value to the timer Ai register Figure 2.7.9 shows the setting example of the , timer mode related registers. ,- - Selecting gate function· i. ---- ------ ----- -----; The content of the counter is decremented by , , ,, 1 each time the count source is input. When : Set the port direction registers : the counter underflows, the content of the re- : • Set the corresponding bit to TAi .. pin to "0· , ,, , load register is loaded into the counter and the ......................... _ ................ r"" __ ................. _ ......... _I __ .. interrupt request bit is set to "1", Count operation continues in this manner. The interrupt request occurs and the interrupt re- quest bit is set to "1" each time the counter underflows. Therefore, an interrupt request Count starts. occurs at every "n+ 1" count of the count source. lI! " the gate function is selected, count starts when the effective Interrupts must be enabled before they can be level is input to the TAiiN pin after the above setting. used. Refer to section "2.6 Interrupts" for more information. The interrupt request bit remains Fig. 2.7.9 Setting example of the timer mode re- "1" set until the interrupt is accepted or it is lated registers cleared by program. The content of the counter can be read at any time by reading the content of the timer Ai register, but the content of the reload register can not be read. In order to change the timer dividing ratio while the timer is operating, a 16-bit update value must be written simultaneously in the timer Ai register. This value is stored in the reload register, and loaded into the counter next time the counter under- flows after writing to timer Ai register. Figure 2.7.10 shows the timer mode operation diagram (without pulse output or gate function). 72 FUNCTIONAL DESCRIPTION 2.7 Timer A b7 b6 b5 b4 b3 b2 b1 bO I I I0 I I I I0 J J 0 Timer Ai mode regist er (In timer mode) I I Operating mode sele ction bits 00 : Timer mode Pulse output functio n selection bit o : No pulse output (TAiOUT pin functions as normal 1/0 port.) 1 : Pulse output Gate function selecti on bits OX : No gate functio n (TAiiN pin functions as normal 1/0 port. ) 10 : Count while TAi IN input level is "L" 11 : Count while T Ai IN input level is "H" (X="O" or "1 ") IFix this bit to "0". I Count source selection bits 00 : Clock oscillating frequency divided by 2 (f2) 01 : Clock oscillating frequency divided by 16 (f16) 10 : Clock oscillating frequency divided by 64 (f64) 11 : Clock oscillating frequency divided by 512 (f512) Note: This register is cleared to "0016" at reset. Fig. 2.7.8 Timer Ai mode register structure in timer mode 73 FUNCTIONAL DESCRIPTION 12.7 Timer A n = reload value FFFF16 / ' Count start Count stop 1: n Ol 1: .. ,, Underflow 0 0 ,, .~ .. ,, Underflow ~ , ~:::I .. ,, .. ,, , , 0 , t) , ' 000016 , ,, Time Set the count Clear the coLnt Set the count : start flag to "1" start flag to "0" i start flag to "1" Count start flag "1~/ "0" "'.tLJ/ ~ ,,, , TAi interrupt request bit "1" "O"'--_ _ _ _ _ _ _ r--: -I! I....._ _ _ _--' 1 . - 1_ _ _ --Ir t t Cleared by the interrupt accepted or program Fig. 2.7.10 Timer mode operation diagram (without pulse output or gate function) [Selection Function] Program selectable gate function and pulse output function are described below. These functions can be used together. OGate function The gate function is selected by setting the gat~ function selection bits of the timer Ai mode register to "10" or "11 ". The gate function controls the starting and stopping of the timer count by the level of the signal input to the TAiiN pin. Table 2.7.5 shows the relationship between the gate function selection bits and the count effective level. When using the gate function, the corresponding port direction register to the TAilN pin must be set to "0" for input mode. Table 2.7.5 Relationship between gate function selection bit and effective level Gate function selection bits Effective level b4 b3 1 0 Count while the input level to the TAilN pin is "L" 1 1 Count while the input level to the TAiiN pin is "H" 74 FUNCTIONAL DESCRlIJPTJION 2.7 Timer A When the gate function is selected, counting is performed when count source is input to the counter while the TAiiN pin is at effective level and the count start flag is "1 n. No count source is input and the count stops while the inpu(level is not effective. The content of the counter is preserved when the TAilN pin input level changes from effective to non-effective. Therefore, counting can resume when the input level returns to an effective level. The pulse width of the TAilN pin input signal during count interval and count halt interval must be at least 2 cycles of the selected count source. Figure 2.7.11 shows the timer operation example when the gate function is selected. n =reload value FFFF16 /count start : - - -~~:----- --- --------------- --- ------ --------- ---~--, n t---;--r C 2 c . . 8 • --: ~ Count stop ~: Underflow • . 2c '1--_----;----, L ~--,. :::l o C,) --. 000016L-_ _i - :_ _ _ _- : - -_ _ _ _ _. . - : -_ _ _ _ _ ,·--L-4_____.;.....-£>- Time Set the count start flag to "1" "1" /: Count start flag "O'~ ,, Input level to Effective level T AilN pin Non·effective levell--~ L T~~~n~:~u~: : ~:':"': - - - - - - - - - - - - - - - - - - - -.... 1!----- Cleared by the interrupt accepted or program Fig. 2.7.11 Timer operation example when the gate function is selected 75 FUNCTIONAL DESCRIPTION 2.7 Timer A .Pulse output function The pulse output function is selected by setting the pulse output function selection bit to "1". When the pulse output function is selected, a signal that changes phase each time the counter underflows is output from the TAiouT pin. The TAiouT pin is shared with ports P5 and P6. When the pulse output function is selected, the corresponding port is forced to output mode and functions as the TAiouT pin regardless of the content of the port direction register. It can be used as a programmable 1/0 port once the pulse output function selection bit is set to "0". "L" level is output from the TAioUT pin while the count start flag is "0" and count disabled. Therefore, the initial level of the output pulse is always "L". Figure 2.7.12 shows the timer operation example when the pulse output function is selected. n = reload value FFFF.6 Count start E / 2 _, Underflow 8 .'ic ::> o U 0000.6 ' - - - ; - - - - - - ' - - ! - - - - - - - - ' L . . . - . ! - - - - - - - ' - - I - - - - - - - ' - - ! - - -...... Time Set the count , start flag to "1 " "1" Count start flag ..o.~ Ir:--i/_~--~-__,!__-~_ Output pulse from "H" TAiouT pin "L"'--------~ L- ,,, ,, ,, TAi interrupt "1" request bit '"0.:.....--------11r-------,1..._ _ _--'1r-------,1..._ _ _--'1r-------,1..._ _ _--'1I - - \ t I Cleared by the interrupt accepted or program Fig. 2.7.12 Timer operation example when the pulse output function is selected 76 FUNCTIONAL DESCRIPTION 2.7 Timer A [Precautions when using the timer mode] 1. The value of the counter while operating can be read at any timing by reading the timer Ai register. However, if it is read at the reload timing shown in Figure 2.7.13, "FFFF,6" is returned instead of the reload value. The reload value is returned if it is read after the timer Ai register is set and before the count source is input and count started. Reload Counter content i (hexadecimal notation) 2 0 I n In - 1I : : : Read value (hexadecimal notation) 2 n = reload value 0 iFFFFi n - 1i Time .. Fig. 2.7.13 Reading the timer Ai register 77 FUNCTIONAL DESCRIPTION 2.7 Timer A 2.7.4 Event counter mode [timer Ai mode register bits 1,0 = "01"] The event counter mode is selected by setting the timer Ai mode register bit 1 to "0" and bit 0 to "1 ". When this mode is selected, bit 5 of the timer Ai mode register must be set to "0". Figure 2.7.14 shows the structure of the timer Ai mode register in event counter mode. In event counter mode, the external clock input to the TAilN pin is counted. The counter can be either an increment counter or a decrement counter according to the up-down flag or the input level to the TAiouT pin. Figure 2.7.15 shows the structure of the up-down flag register. In increment counter, an interrupt request occurs when the counter overflows (the content of the counter reaches FFFF1S --7 reload value "n"). In decrement counter, an interrupt request occurs when the counter underflows (the content of the counter reaches 00001S --7 reload value "n"). The timer dividing ratio is ex- pressed as follows: .Increment counter Timer dividing ratio=1/(n+1) .Decrement counter Timer dividing ratio=1/(FFFFls-n+1) n: Value set in counter (value between 000016 and FFFF16) In addition, in this mode, the pulse output function and two-phase pulse signal processing function can be selected by program. Two-phase pulse signal output processing function is available only with timers A2, A3, and A4 . • Pulse output function A pulse that changes phase is output from the TAioUT pin each time the counter underflows (decrement counter) or overflows (increment counter) . • Two-phase pulse signal processing function (timers A2 to A4) Whether to increment or decrement the counter is selected by using two signals with phase shifted 90 degrees. 78 FUNCTIONAL DESCRIPTION 2.7 Timer A b7 b6 b5 b4 b3 b2 b1 bO IX IX I o I I Timer Ai mode register (in event counter mo de) I o I 1 I I I I Operating mode selection bits 01 : Event counter mode Pulse output function selection bit o : No pulse output 1 : Pulse output Count polarity selection bit o : Count at the falling edge of the input sig nal 1 : Count at the rising edge of the input sig nal Up-down switching factor selection bit o : Content of the up-down flag 1 : Input signal to the TAioUT pin l Fix this bit to "0". J IThese bits are ignored (may be "0" or "1 ")·1 Note: This register is cleared to "0016" at reset. Fig. 2.7.14 Timer Ai mode register structure in event counter mode b7 b6 b5 b4 b3 b2 b1 bO I W I W I W I R/W I R/W I R/W I R/W I R/W I Up-down flag (address 4416) l ~ Timer AO up-down flag Timer A1 up-down flag Timer A2 up-down flag Timer A3 up-down flag Timer A4 up-down flag o : Decrement count 1 : Increment count Timer A2 two-phase signal processing selection bit Timer A3 two-phase signal processing selection bit Timer A4 two-phase signal processing selection bit o : Two-phase pulse signal processing disable 1 : Two-phase pulse signal processing enable Note:This register is cleared to "0016" at reset. Fig. 2.7.15 Up-down flag register structure 79 FUNCTIONAL DESCRIPTION 2.7 Timer A (1) Event counter mode operation First, select the operating mode, count polarity, pulse output function, and up-down switching factor with the timer Ai mode register. Next, write a value "n" ("n" = 000016 to FFFFI6) in the timer Ai register to specify the timer dividing ratio. At the same time, the value "n" is stored in the counter and the reload register. Also set the port direction register bit corresponding to the TAilN pin to "0" (input mode). When the count start flag is set to "1" (count enabled), the external clock input to the TAirN pin is input to the counter. The counter operates at the falling edge (when the count polarity selection bit is "0") or rising edge (when the count polarity selection bit is "1 ") of the input clock. Whether to increment or decrement the counter can be selected with the up-down flag or the level of the input signal to the TAiouT pin. The content of the up-down flag is used if the up-down switching factor selection bit is "0", and the level of the input signal to the TAiouT pin is used if it is "1". Figure 2.7.16 shows the setting example of the event counter mode related registers . • When using the content of the up-down flag The counter is decremented when the corre- sponding bit to the up-down flag is set to "0", and incremented when it is set to "1 ". Set timer Ai mode register • Set the operating mode selection bits(bit1 ,0) to "01" • Select pulse output function .When using the input signal to TAiouT pin • Select count polarity The counter is decremented when the input level • Select up-down switching factor • Set bit 5 to "0" to the TAiouT pin is "L", and incremented when it is "H". The TAiouT pin is shared with port pins. Therefore, the direction register of the corre- Set the up-down flag sponding port pin must be set to "0" (input • Select up/down count(when the up-down switching factor selection bit is "0") mode) when the input level of the TAiouT pin is • Select two-phase pulse signal processing function used to control increment/decrement. The pulse output function described later can- Specify timer dividing ratio not be used when the input level to the TAiouT • Set value to the timer Ai register pin is used to control increment/decrement. Set the port direction registers • Set the corresponding bit to TAilN pin to "0" • Set the corresponding bit to TAiouT pin to "0" (when the up-down switching factor selection bit or the two-phase signal processing selection bit is "1") Set the count start flag to "1" Count starts. Fig. 2.7.16 Setting example of the event counter mode related registers 80 FUNCTIONAL DESCRIPTION 2.7 Timer A The count direction can be changed while counting. The count direction changes when the next effective edge of the count source is input after the content of the up-down flag changes if the up- down flag is used for up-down switching factor, and after the input level to the TAioUT pin changes if the input signal to the TAioUT pin is used for up-down switching factor. Count operation continues and the counter underflows (decrement count) or overflows (increment count) at which time an interrupt request occurs and an interrupt request bit is set to "1". Interrupts must be enabled before they can be used. Refer to section "2.6 Interrupts" for more information. The interrupt request bit remains "1" set until the interrupt is accepted or it is cleared by program. The content of the counter can be read at any time by reading the content of timer Ai register, but the content of the reload register cannot be read. In order to change the timer dividing ratio while the timer is operating, a 16-bit update value must be written simultaneously in the timer Ai register. This value is stored in the reload register, and loaded into the counter next time the counter underflows after writing to timer Ai register. Figure 2.7.17 shows the event counter mode operation diagram (without pulse output or two-phase pulse signal processing function). n = reload value FFFF16 - - --- ----- - - - -- - --- - - - - -- - - - -- - -- - --- -- - -- - - -- - -- - -- -- - --- - - - -- Count start / OOOO'6L-_;..-_ _ _ _-L..4-_ _ _ _.-...J'--l-_ _ _ _ _ _ _---;_ _ _----'_ _ _....... Time Set the count , start flag to "1" Count start flag "1'~ i/ "0" Up-down flag "1" "O"'--_ _ _ _ _ _ _~-----~---' TAi interrupt "1" request bit "0" h h r---LJ \ t Cleared by the interrupt accepted or program I ;1! This opreation diagram selects the up-down flag for up-down switching factor. Fig. 2.7.17 Event counter mode operation diagram (when up·down switching factor selection bit is "0") 81 FUNCTIONAL DESCRIPTION 2.7 Timer A [Selection Function] Pulse output function and two-phase pulse signal processing function can be selected by program. How- ever, only timers A2, A3, and A4 can use the two-phase pulse signal processing function. The pulse output function and the two-phase pulse signal processing function both use the TAiouT pin. Therefore, only one of these functions can be used at anyone time . • Pulse output function Pulse output function is selected when the pulse output function selection bit is set to "1 ". When this function is selected, a signal that changes phase each time the content of the counter underflows (decrement count) or overflows (increment count) is output from the TAiouT pin. The TAiouT pin is shared with ports P5 and P6. When the pulse output function is selected, the corresponding port is forced to output mode and functions as the TAiouT pin regardless of the content of the port direction register. It can be used as a programmable I/O port once the pulse output function selection bit is set to "0". "L" level is output from the TAiouT pin while the count start flag is "0" and count disabled. Therefore, the initial level of the output pulse is always "L" . • Two-phase pulse signal processing function Two-phase pulse signal processing function is selected for timers A2 to A4 when the two-phase signal processing function selection bit is set to "1 ". When this function is selected, set the pulse output function selection bit to "0", the count polarity selection bit to "0", and the up-down selection bit to "1". Figure 2.7.18 shows the timer Aj mode register (j=2 to 4) when two-phase pulse signal processing function is selected. The TAjouT pin is used in input mode and the corresponding port direction register bit must be set to "0". b7 b6 b5 b4 b3 b2 b1 bO x x o o o o Timer Aj mode register (j=2 to 4) ' - - - - - ' - - - - - - - - - - - - - - - - May be "0" or "1" Fig. 2.7.18 Timer Aj mode register (j=2 to 4) when two-phase pulse signal processing function is selected 82 FUNCTIONAL DESCRIPTION 2.7 Timer A A timer with two-phase pulse signal processing function selected controls the counter by a two-phase pulse with phase shifted by 90 degrees. There are two types of two-phase pulse signal processing operation; one for timers A2 and A3 and another for timer A4 (quadruple processing). The counter is incremented when the rising edge is input to the T AkiN (k=2, 3) pin and decremented when the falling edge is input to the T AkiN pin after the level of the TAkoUT pin changes from "L" to "H". (See Figure 2.7.19) The counter is incremented at every rising and falling edge of the TA40UT and the TA41N pins when a phase related pulse with the rising edge input to the TA41N pin is input after the level of the TA40UT pin changes from "L" to "H". The counter is decremented at every rising and falling edge of the TA40UT and the TA41N pins when a phase related pulse with the falling edge input to the T A40UT pin is input after the level of the TA41N pin changes from "H" to "L". (See Fig. 2.7.20) "H" TAkoUT "L" "H" TAklN (k=2,3)"L" Up- Up- Up- Down- Down- Down- count count count count count count , , , , , +1 +1 +1 -1 -1 -1 Fig. 2.7.19 Timers A2 and A3 ~wo-phase pulse signal processing operation TA40UT "H'Dfl) "L" I L I I Ul-O- I~t Up-count at each edg~ Down-couni at each edge nru kDD- I I I t I +1 +1 +1 +1 +1 "':1 ":1 ":1 ":1 ..i1 TA4IN"H" "L" , , I I I , I ~p-co~nt aj eac~ edg~ ~own-count at each edge I I I , I +1 +1 +1 +1 +1 ':'1 ':'1 ':'1 ':'1 ':'1 Fig. 2.7.20 Timer A4 two-phase pulse signal processing operation (quadruple processing) 83 FUNCTIONAL DESCRIPTION 2.7 Timer A [Precautions when using event counter mode] 1. The value of the counter while operating can be read at any timing by reading the timer Ai register. However, if it is read at the reload timing shown in Figure 2.7.21, "FFFF16" is returned at underflow and "OOOOlS" is returned at overflow instead of the reload value. The reload value is returned if it is read after the timer Ai register is set and before the count source is input and count started. ( 1 ) Decrement ( 2) Increment Reload Reload ~ ....• Counter content - r - - r - - r - - r - - r - - , - - _ . 1 . . -2 (hexadecimal notation) 0 (hexadecimal notation) _+-2_+-_+-_+-_+-_+-- 1 n 1n - 1 1 ,, Read value - i - - - i - - - i - - - i - - - i - - - + - - 0 iFFFFj n - 1 j ,, _.1..-_.1..-_.1..-_.1..-_.1..-- , Counter content (hexadecimal notation) Read value (hexadecimal notation) IFFFDIFFFEIFFFFI I I I I I I jFFFojFFFEjFFFFj 0 I I '" n In+ 11 ,, ,, In + 1 j Ti~ Ti~ n = reload value n = reload value Fig. 2.7.21 Reading the timer Ai register 2. All of the following functions uses the TAiouT pin. Only one of these functions can be selected for each timer at anyone time . • Count control using input signal to TAiouT pin .Pulse output function .Two-phase pulse signal processing function (timers A2 to A4) 3. The phase difference of the two-phase pulse used for two-phase pulse processing function (input clocks to TAiouT and TAilN pins) must be the characteristics shown in Figure 2.7.22. T1 I--- TAilN CI~ T1 (Min.) T2,T3 (Min.) - frequency 8MHz 21ls 500ns 16MHz 1~s 250ns TAioUT T2 T3 I 25MHz 800ns 200ns Fig. 2.7.22 The characteristics of the two-phase pulse signal 84 FUNCTIONAL DESCRIPTION 2.7 Timer A 2.7.5 One·shot pulse mode [timer Ai mode register bits 1, 0 = "10"] The one-shot pulse mode is selected by setting the timer Ai mode register bit 1 to "1" and bit 0 to "0". When this mode is selected, the timer Ai mode register bit 5 must be set to "0" and bit 2 must be set to "1 ". Figure 2.7.23 shows the structure of the timer Ai mode register in one-shot pulse mode. In one-shot pulse mode, "H" level is output for an arbitrary interval from the TAiouT pin after a trigger. The trigger can be either an internal trigger generated by writing "1" into the one-shot start flag shown in Figure 2.7.24 or an external trigger generated by the effective edge of the input signal to the TAilN pin. Counting starts with a trigger and at the same time, "H" level is output from the TAiouT pin. The content of the counter is decremented by 1 each time a count source is input. When the content of the counter reaches "000116" ~ reload value "n", the output level from the T AiouT pin changes to "L" and counting stops. At this point, an interrupt request is occurs. The width of the output pulse ("H" level width) can be expressed as follows: Output pulse width =n/fi [5] fi: Selected count source frequency n: Value set in counter (000016 to FFFF16 during count halted) (000116 to FFFF16 during count operating) 85 FUNCTIONAL DESCRIPTION 2.7 Timer A b7 b6 b5 b4 b3 b2 b1 bO I a I 1 1 a I Timer Ai mode register (in one-shot pulse mode) I I I I I I I I Operating mode sele ction bits 10 : One-shot pulse mode : : Fix this bit to "1 ". I Trigger selection bits ox : Writing ope ratio n to the one-shot start flag (TAiIN pin functi ons as normal 110 port.) 10 : Falling edge of the input signal to TAilN pin 11 : Rising edge of the input signal to TAilN pin (X="O" or "1 ") : Fix this bit to "0". I Count source selecti on bits 00 : Clock oscillating frequency divided by 2 (f2) 01 : Clock oscillating frequency divided by 16 (f16) 10 : Clock oscillating frequency divided by 64 (f64) 11 : Clock oscillating frequency divided by 512 (f512) Note: This register is cleared to "0016" at reset. Fig. 2.7.23 Timer Ai mode register structure in one-shot pulse mode b7 b6 b5 b4 b3 b2 b1 bO One-shot start flag (address 4216) Timer AO one-shot start flag ' - - - - - 1 Timer A 1 one-shot start flag '------'------1 Timer A2 one-shot start flag ' - - - - - - - - - - - 1 Timer A3 one-shot start flag ' - - - - - - - - - - - - 1 Timer A4 one-shot start flag Internal trigger is generated when "1" is written to this flag. Note: Bits 5 to 7 are undefined at read. Bits 0 to 4 are cleared to "0" at reset. Fig. 2.7.24 One-shot start flag register structure 86 FUNCTIONAL DESCRIPTION 2.7 Timer A (1) One-shot pulse mode operation First select the operating mode, trigger occurrence factor, and count source with the timer Ai mode register. The TAioUT pin starts to output "L" level when one-shot pulse mode is selected with the operating mode selection bits. Next, write a value "n" ("n"= 000016 to FFFF16) in the timer Ai register to set the output pulse width. At this point, "n" is stored in the counter and the reload register. Count is enabled when the count start flag is set to "1", and then count starts when a trigger occurs. If bit 4 of the timer Ai mode register is "0", an internal trigger is generated by setting the corresponding bit to each timer in the one-shot start flag to "1". If bit 4 is "1" and bit 3 is "0", a trigger is generated at the falling edge of the T Ai IN pin input signal and if bit 4 is "1" and bit 3 is "1", a trigger is generated at the rising edge of the TAilN pin input signal. When using an external trigger, the corresponding port direction register bit to the TAilN pin must be set to "0" (input mode). Figure 2.7.25 shows the setting example of the one-shot pulse mode related registers. Set timer Ai mode register o Set the operating mode selection bits(bit 1,0) to "10" o Set bit2 to "1" " Select trigger occurrence factor o Set bit 5 to "0" o Select count source Set output pulse width a Set value to the timer Ai register .-- --- --- --_ ........ -- --- -_ --- Selecting external trigger .. ................. --- Selecting internal trigger -_ .. _.......... -_ .... --- -- --_ .., Set the port direction register ( Set the count s:tart flag to '1" ) o Set the corresponding bit to TAilN pin to "0" Writing '1" to the one-shot start flag ( Set the count start flag to "1" ) Trigger is generated. ~ Count starts. Trigger is generated. + Count starts. Fig. 2.7.25 Setting example of the one-shot pulse mode related registers 87 FUNCTIONAL DESCRIPTION 2.7 Timer A When triggered, counting starts and "H" level is output from the TAioUT pin. (However, if the timer Ai register contains "000016", the TAiouT pin level remains at "L" and counting does not start.) The counter is decremented by 1 each time a count source is input. When the content of the counter reaches 000116 --7 "n" , the TAiouT pin level changes to "L" and counting stops. The "H" level width of the output pulse from the TAiouT pin is (count source cycle) x n. An interrupt request occurs and the interrupt request bit is set to "1" when the TAiouT pin level changes from "H" to "L". Interrupts must be enabled before they can be used. Refer to section "2.6 Interrupts" for more information. The interrupt request bit remains "1" set until the interrupt is accepted or it is cleared by program. If a value is written in the timer Ai register while the counter is operating ("H" level is output from the TAiouT pin), this value is only set in the reload register. It is loaded into the counter at the next reload timing. Values other than 000016 can be written while the counter is operating. If the value of timer Ai register is read, the result is undefined. Figure 2.7.26 shows the one-shot pulse mode operation diagram (when external trigger is selected). FFFF16 n ~ reload value Count start Count stop "E / , :.. ' Count restart ~l • :---+ Count stop .l!l c: 8... --,, , Reload - , _., Reload -~ .l!l --,, c: ::I o : () 000116 L..._...:...._4-_ _ _ _ _-'-4-_ _4-_ _ _ +-_____....L.-!-___--1... Time Set the count start flag to "1" ~~~"O~ "1" ~Ii----.:'-------!.-----:--__+_---_:___- : Another trigger : / while counting : II' : Input level to "H",~_ _ TAilN pin " L " - · --!n,,______-+-__~n,- , ;t '----In' Output pulse from "H".... _ _ _....J'I:I4.. r !:::=l=/f='x=(=n)=[=s]=~·li__ ....J j.. 1/fiXCn+1) [s] .1:,',-_ _ __ TAioUT pin "L" , ,, ,, TAi interrupt "1'.' _ _ _ _ _ _ _ _ _ _...... request bit "O~ . r--lL..___________. . . . t Cleared by the interrupt accepted or program * This operation diagram selects the external trigger(rising edge) for trigger occurrence factor. Fig. 2.7.26 One·shot pulse mode operation (when external trigger Is selected) 88 FUNCTIONAL DESCRIPTION 2.7 Timer A The counter stops after completing one cycle of output, and repeats the same operation when the next trigger occurs. When the count start flag is "0" (count disabled), "L" level is output from the TAiouT pin. Therefore, an arbitrary pulse width can be generated by setting a value in the timer Ai register before setting the count start flag to "1 ". If another trigger is generated while counting, the content of the reload register is transferred to the counter and decrement continues from that value. In this case, the TAiouT pin level becomes "L" at n+1 count after the trigger. The content of the reload register is transferred to the counter only when a trigger occurs while counting. At least one cycle of the timer count source should elapse before retriggeri ng. [Precautions when using one-shot pulse mode] 1. If the count start flag is set to "0" while counting, counting stops and the output level of the TAiouT pin becomes "L". At the same time an interrupt request occurs and the interrupt request bit is set to "1 ". 2. Values between 000116 and FFFF16 can be written in the timer Ai register while the counter is operating ("H" level is output from the T AiouT pin). 3. When external trigger is selected, there may be a time lag between the time the effective edge is input to TAiiN pin and the time the trigger is generated. This is because the input signal to the TAilN pin is not synchronized with the internal operating clock. 4. When the operating mode is switched from timer mode or event counter mode to one-shot pulse mode, the interrupt request bit in timer Ai interrupt control register is set to "1 ". Clear the interrupt request bit to "0" after switching modes when using timer Ai interrupt or the interrupt request bit in one-shot pulse mode. 89 FUNCTIONAL DESCRIPTION 2.7 Timer A 2.7.6 Pulse width modulation (PWM) mode [timer Ai mode register bits 1, 0 = "11"] Pulse width modulation mode (hereafter referred to as PWM) is selected and timer Ai functions as a pulse width modulator when timer Ai mode register bits 1, 0 are set to "11". When this mode is selected, bit 2 of the timer Ai mode register must be set to "1 ". Figure 2.7.27 shows the structure of the timer Ai mode register in PWM mode. In PWM mode, an arbitrary pulse width signal is output continuously from the TAiouT pin. A is-bit PWM mode or an 8-bit PWM mode can be selected by program. 1.D16·bit PWM mode The counter functions as a is-bit pulse width modulator . • S-bit PWM mode The reload register and the counter are both divided into 8-bit halves. The high-order 8 bits of the counter function as a pulse width modulator and the low-order 8 bits function as a prescaler. The trigger is either an internal trigger generated when the count start flag shown in Figure 2.7.28 is set to "1" or an external trigger generated when the effective edge signal is input to the TAilN pin with the count start flag set to "1 n. When a trigger occurs, the pulse width modulator starts and pulses are output from the TAiouT pin. An interrupt request occurs and the interrupt request bit is set to "1 n each time the level of the output pulse changes from "H" to "Ln,. When the pulse width modulator starts operation with a trigger, the next trigger is not accepted (pulses are output continuously). b7 bS b5 b4 b3 b2 b1 bO I R/W IR/W I R/W I R/W I R/W I R/W I R/W I R/W I Count start flag (address 4016) L Timer AO count start flag I Timer A 1 count start flag Timer A2 count start flag Timer A3 count start flag Timer A4 count start flag In case of selecting an internal trigger, the internal trigger is generated when this flag is set to "1 ". Timer BO count start flag Timer B1 count start flag Timer B2 count start flag Note: This register is cleared to "0016" at reset. Fig. 2.7.28 Count start flag register structure 90 FUNCTIONAL DESCRIPTION 2.7 Timer A b7 bS b5 b4 b3 b2 b1 bO 1 1 1 I Timer Ai mode regis ter (in PWM mode) I I I I I I I I l 1 Operating mode sele ction bits 11 : PWM mode IFix this bit to "1 ". I Trigger selection bits ox : Writing ope ratio n to the one-shot start flag (T AilN pin functi ons as normal 1/0 port) 10 : Falling edge of the input signal to TAilN pin 11 : Rising edge of the input signal to TAilN pin (X="O" or "1 ") 1S/8-bit PWM mode selection bit o : 1S-bit PWM mod e 1 : 8-bit PWM mode Cou nt source select ion bits 00 : Clock oscillating frequency divided by 2 (f2) 01 : Clock oscillating frequency divided by 16 (f16) 10 : Clock oscillating frequency divided by 64 (f64) 11 : Clock oscillating frequency divided by 512 (f512) Note: This register is cleared to "0016" at reset. Fig. 2.7.27 Timer Ai mode register structure in PWM mode (1) PWM mode operation First, select the operating mode, trigger occurrence factor, 16/8-bit PWM mode, and count source with the timer Ai mode register. The TAiouT pin outputs "L" level when PWM mode is selected with the operating mode selection bits. Next, write an arbitrary value "n" in the timer Ai register to set the output pulse width. At this point, "n" is set in the counter and the reload register. Then when a trigger is generated, the pulse width modulator starts and pulses are output from the TAiouT pin. When the timer Ai mode register bit 4 is "0", an internal trigger occurs each time the corresponding bit to each timer in the count start flag is set to "1 ". If bit 4 is "1" and bit 3 is "0", the trigger occurs at the falling edge of the input signal to the TAilN pin. If bit 4 is "1" and bit 3 is "1", the trigger occurs at the rising edge of the input signal. When using an external trigger, set the corresponding port direction register to the TAilN pin to "0" (input mode). ( A pulse width modulator continuously outputs pulses when it starts operation. An interrupt request occurs and the interrupt request bit is set to "1" each time the level of the output signal changes from "H" to "L". Interrupts must be enabled before they can be use. See "2.6 Interrupts" for more informa- tion. The interrupt request bit remains "1" set until an interrupt request is accepted or it is cleared by program. If a value is written in the timer Ai register while the counter is operating, the value is set only in the reload register. It is loaded in the counter next time the level of the output pulse changes from "L" to "HII, If the value of the timer Ai register is read, the result is undefined. The 16-bit PWM mode and 8-bit PWM mode operations are described below. 91 FUNCTIONAL DESCRIPTION 2.7 Timer A [16-bit PWM mode] 16-bit PWM mode is selected when the 16/S-bit PWM mode selection bit is set to "0". In this mode, the cycle and width of the output pulse from the TAiouT pin can be expressed as follows: Output pulse cycle = (1/ti) X (2 16_1) [5] Output pulse "H" width = (1/ti) X n [5] fi: Frequency of selected count source [Hz] n: Value set in counter (value between 000016 and FFFE16) Figure 2.7.29 shows an example of an output waveform in 16-bit PWM mode. An interrupt request occurs and the interrupt request bit is set to "1" each time the level of the output pulse signal changes from "H" to "L". The "H" width of the output pulse can be changed while the pulse width modulator is operating (outputting the pulse signal) by writing a value in the timer Ai register. This value is written in the reload register and loaded into the counter next time the level of the output pulse changes from "L" to "H". Therefore, the pulse width changes from the pulse following the pulse being output when the value was written. : .. Iff, X (21Ll) [s] ,, Selected count source fi n n n n n n n n f": I U U /.J U U /.J U L . f"l ri n n n n n n . L.I /.J U U /.J U U I : : : I I I I I Input level to 'HI! I I . ~' - - - - - - - - - - - - - : : I I TA 'liN pm . "L" ,""-! : ~ " : : ! : This signal does not generate a t~igger. 1 ... : ,4 1 / fi X (n) [5] Output pulse from "H"_ _ _ TAiouTpin"L" . :I----l '--_____________ _ .J' ,I, This is an output example in case the content of the reload register is 000316 and the external trigger(rising edge) is selected for trigger occurrence factor. Fig. 2.7.29 16-bit PWM mode output wavetorm example [S-bit PWM mode] S-bit PWM mode is selected when the 16/S"bit PWM mode selection bit is set to "1 ". In this mode, the reload register and the counter are divided into a-bit halves. The high-order a bits of the counter function as an a-bit pulse width modulator and the low-order a bits function as a prescaler. The prescalar counts the clock selected with the count source selection bit. The prescalar is decremented and an underflow signal is generated when its content reaches 0016 -> "m" ("m" = value set in low-order a bits of the reload register). The content of the reload register is loaded into the prescalar and counting continues. The pulse width modulator (high-order a bits of the counter) counts the underflow signal generated by the prescalar. The cycle and width of the pulse output from the TAiouT pin can be expressed as follows: Output pulse cycle = (1/ti) X (m+ 1) X (2 8-1) [5] Output pulse "H" width = (1/ti) X (m+1) X n [5] fi : Frequency of selected count source [Hz] n: Value in the high-order a bits of the counter (Value between 0016 and FE16) m: Value in the low"order a bits of the counter (Value between 0016 and FF16) 92 FUNCTIONAL DESCRIPTION 2.7 Timer A Figure 2.7.30 shows an output waveform example in 8-bit PWM mode. In 8-bit PWM mode, pulse output starts at the set pulse cycle after "L" level with the width equal to the "H" level of the set pulse is output. The "H" width of the output pulse can be changed while the pulse width modulator is operating (outputting the pulse signal) by writing a value in the timer Ai register. This value is written in the reload register and loaded into the counter next time the level of the output pulse changes from "L" to "H". Therefore, the pulse width changes from the pulse following the pulse being output when the value was written. -- , llfi X (n+l) X (2 8 -1) [s] :"4 , Selected count source fi " , " , , I :: I : I , " "H" : I' : Input level to TAiiN pin "L"t ----;--~l:--'-:------ ---- ----.;-1----- L --.: I 11 1 , . .:. -----:c----~i _1 (fl X (m+ 1) [s] , Underflow signal "H"~-+--...., from prescaler "L" , , 1 Ifl X (m+ 1) X (n) [s] ----; !'II Output pulse from "H" TAiouT pin "L.. - - - ' - - - -...... '------- - - - - --_...... L ll. The setting conditions of this output example are as follows: • High-order 8 bits of counter = 0216 • Low-order 8 bits of counter = 0216 • Trigger occurrence factor: External trigger(falling edge) Fig. 2.7.30 a·bit PWM mode output waveform example [Precautions when using PWM mode] 1. When the operating mode is switched from timer mode or event counter mode to PWM mode, the interrupt request bit in timer Ai interrupt control register is set to "1 ". Clear the interrupt request bit to "0" after switching modes when using timer Ai interrupt or the interrupt request bit in PWM mode. 93 FUNCTIONAL DESCRIPTION 2.8 Timer B 2.8 Timer B Timer B consists of three 16-bit timers (timers BO to B2). Timers BO to B2 operate independently and each can operate in one of three different modes. 2.8.1 Timer B description Timer Bi (i= a to 2) has three operating modes as described below. These timers have identical functions. The input pins (TBbN) of these timers are shared with ports P65 to 67 . • Timer mode This mode counts the selected internal clock. The counter is decremented by 1 each time a count source (selected clock) is input and a timer Bi interrupt request occurs when the content of the counter reaches 000016 --7 reload value Un" (hereafter referred to as underflow) . • Event counter mode This mode counts the external clock input to the TBilN pin. The counter is decremented by 1 each time a clock is input and a Timer Bi interrupt request occurs when the counter underflows . • Pulse period/pulse width measurement mode In this mode, the period or the pulse width of the input signal to the TBilN pin is measured. 2.8.2 Block description Figure 2.8.1 shows the block diagram of timer Bi. It is followed by the description of the timer Bi related registers. Count source selection bits Data 5U5 (odd) 12-------0 1,6---0 11'fr 16. - - - - - - 0 1512 - - - - - - - 0 Timer mode Pulse period/pulse width measurement mode Polarity switching Interrupt TBilN and edge pulse '--_ _ _--r-'--'-_ _S-,..----,u request bit generating circuit Event counter mode Overflow flag Counter reset circuit Fig. 2.8.1 Timer Bi block diagram 94 FUNCTIONAL DESCRIPTION 2.8 Timer B (1) Counter and reload register (timer Bi register) Timer Bi counter and reload register consist of 16 bits. The counter counts the selected count source. In timer mode and event counter mode, the content of the counter is decremented by 1 each time a count source is input. The reload register is used to store the initial value of the counter. Th~. content of the counter changes each time a count source is input to the counter, but the content of the reload register remains unchanged. The content of the reload register is reloaded into the counter when the counter underflows. A value is set in the counter and the reload register by writing a value in the timer Bi register. In pLilse period/pulse width measurement mode, the content of the counter is incremented by 1 each time a count source is input to the counter. The result of measuring the pulse signal is transferred to the reload register. Table 2.8.1 shows the memory allocation of the timer Bi register. Table 2.8.1 Timer Bi register memory allocation Timer Bi register High-order byte Low-order byte Timer BO register Address 5116 Address 5016 Timer B1 register Address 5316 Address 5216 Timer B2 register Address 5516 Address 5416 In timer mode and event counter mode, the value written in the timer Bi register while the timer is not operating is stored in the counter and the reload register. The value written in the timer Bi register while the timer is operating is stored only in the reload register. In this case, the updated value is transferred to the counter during the next reload. When the timer Bi register is read, the counting value is read. When the timer Bi register is read in pulse period/pulse width measurement mode, the pulse width or the pulse period measurement result is read. The value of the timer Bi register is undefined at reset. Therefore, the counter and the reload register must first be initialized when using timer Bi in timer or event counter mode. (2) Count start flag The count start flag (address 4016) separately controls starting/stopping of each timer. Each bit 'cor- responds to one of the timers. A count source is input to the counter when this flag is "1 ", and disabled when it is set to "0". Figure 2.8.2 shows the structure of the count start flag. b7 b6 b5 b4 b3 b2 b1 bO I R/W I R/W I R/W I R/W I R/W I R/W I R/W I R/W I Count start flag (address 4016) ~ Timer AD count start flag I Timer A1 count start flag Timer A2 count start flag Timer A3 count start flag Timer A4 count start flag Timer BO count start flag Timer B1 count start flag Timer 82 count start flag Note:This register is cleared to "0016" at reset. Fig. 2.8.2 Count start flag register structure 95 FUNCTIONAL DESCRIPTION 2.8 Timer B (3) Timer 8i mode register The timer Bi mode register (address 5B16 to 5D16) consists of operating mode selection bits, overflow flag, and count source selection bits. Figure 2.8.3 shows the structure of the timer Bi mode register. The operating mode selection bits, overflow flag, and count source selection bits are described below. The function of bits 2 and 3 depend on the operating mode and are described under the description of each operating mode. b3 bO --,-------,--.,.--, Timer 80 mode register (address 5816) Timer 81 mode register (address 5C16) _,----'--,---'---,--'----,--' Timer 82 mode register (address 5016) '---"--- Operating mode selection bits 00 : Timer mode 01 : Event counter mode 10 : Pulse period/pulse width measurement mode ' - - - - ' - - - - - - - - 1 These bits' functions depend on operating mode. , - - - - - - - - - - - - - Timer Bi overflow flag o : No overflow or underflow 1 : Overflow or underflow ' - - - - - ' - - - - - - - - - - - - - - - - Count source selection bits 00 : Clock oscillating frequency divided by 2 (f2) 01 : Clock oscillating frequency divided by 16 (f16) 10 : Clock oscillating frequency divided by 64 (f64) 11 : Clock oscillating frequency divided by 512 (f512) Note: Bit 4 is undefined at reading. Bit 5 is set to "1" at reset and cleared to "0" by writing to this register. Bits 0 to 3 and bits 6 and 7 are cleared to "0" at reset. Fig. 2.8.3 Timer 8i mode register structure 96 FUNCTIONAL DESCRIPTION 2.8 Timer 8 .Operating mode selection bits (bits a and 1) The operating mode selection bits are used to select the timer operating mode. Table 2.8.2 shows the relationship between the operating mode selection bits and the timer operating modes. Table 2.8.2 Relationship between operating mode selection bits and operating modes b1 bO Operating mode a a Timer mode 0 1 Event counter mode 1 0 Pulse period/pulse width measurement mode .Timer Bi overflow flag (bit 5) The timer Bi overflow flag is set to "1" when the counter underflows in timer mode or event counter mode. In pulse period/pulse width measurement mode, it is set to "1" when the content of the counter reaches FFFF16 ~ 000016. This bit is set to "1" at reset and cleared to "0" when a value is written in the timer Bi mode register . • Count source selection bits (bits 6 and 7) The count source selection bits are used to select the count source. Table 2.8.3 shows the relationship between the count source selection bits and the timer count source. These bits are ignored in event counter mode. Table 2.8.3 Relationship between count source selection bits and count sources Input clock to the counter b7 b6 Timer count source f(XIN)=8MHz f(XIN)=16MHz f(XIN)=25MHz a a Clock oscillating frequency divided by 2 (f2) 4MHz 8MHz 12.5MHz a 1 Clock oscillating frequency divided by 16 (116) 500kHz 1MHz 1.5625MHz 1 a Clock oscillating frequency divided by 64 (164) 125kHz 250kHz 390.625kHz 1 1 Clock oscillating frequency divided by 512 (f512) 15625Hz 31250Hz 48.8281kHz 97 FUNCTIONAL DESCRIPTION 2.8 Timer B (4) Timer Bi interrupt control register The timer Bi interrupt control register (address 7A16 to 7C16) consists of interrupt priority level selection bits and interrupt request bit. Figure 2.8.4 shows the structure of the timer Bi interrupt control register. The function of each bit is described below. Refer to section "2.6 Interrupts" for more information. b7 b6 b5 b4 b3 b2 b1 bO Timer BO interrupt control register (address 7 A16) Timer B1 interrupt control register (address 7B16) Timer B2 interrupt control register (address 7C16) '---"---"--- Interrupt priority selection bits 000 : Level 0 (disable interrupt) 001 : Level 1 Low 010 : Level 2 011: Level 3 100 : Level 4 Priority 101 : Level 5 110 : Level 6 111 : Level 7 High Interrupt request bit a : No interrupt request 1 : Interrupt request Note: Bits 4 to 7 are undefined at reading. Bits a to 3 are cleared to "0" at reset. Fig. 2.8.4 Timer Bi interrupt control register structure .Interrupt priority level selection bits (bits 0 to 2) These bits are used to select the interrupt priority level. They should be set to a level between 1 and 7 when using timer Bi interrupt. When there is an interrupt request, this level is compared with the processor interrupt priority level (IPL) in the processor status register (PS) and an interrupt is allowed only when this level is greater than IPL (interrupt disable flag I must be "a"). Set these bits to "000" (level 0) to disable only timer Bi interrupt. .Interrupt request bit (bit 3) This bit is set to "1" when a timer Bi interrupt request occurs. The interrupt request bit set to "1" is cleared to "0" when the interrupt request is accepted. This bit can be set or cleared by program. 98 FUNCTIONAL DESCRIPTION 2.8 Timer B (5) Port P6 direction register Timers BO to B2 input pins are shared with port P6. When using these ports as timer input pins, the corresponding bit in the direction register must be set to "0" (input mode). Figure 2.8.5 shows the relationship between the port P6 direction register (address 1016) and the timer pins. b7 b6 b5 b4 b3 b2 b1 bO I R/W I R/W I R/W I R/W I R/W I R/W I R/W I R/W I Port P6 direction register (address 1016) ~ TA40UT pin I TA4IN pin INTo pin INTi pin INT2 pin TBOIN pin TB11N pin TB21N pin Note:This register is cleared to "0016" at reset. Fig. 2.8.5 Relationship between port P6 direction register and timer pins 99 FUNCTIONAL DESCRIPTION 2.8 Timer B 2.8.3 Timer mode [timer Bi mode register bits 1, 0 = "00"] Timer mode is selected by setting the timer Bi mode register bits 1 and 0 to "00". Figure 2.8.6 shows the structure of the timer Bi mode register in timer mode. In timer mode, the selected internal clock is decremented and an interrupt request occurs each time the counter underflows (the content of the counter reaches 000016 -7 reload value "n"). The timer dividing ratio is expressed as follows: Timer dividing ratio = 1/(n+1) n: Value set in counter (value between 000016 and FFFF16) b3 Timer Bi mode register (in timer mode) '----'--- Operating mode selection bits 00 : Timer mode ' - - - - ' - - - - - - - - - 1 These bits are ignored (may be "0" or "1 "). ' - - - - - - - - - - - - - - Timer Bi overflow flag o : No underflow 1 : Underflow ' - - - - ' - - - - - - - - - - - - - - - - Count source selection bits 00 : Clock oscillating frequency divided by 2 (f2) 01 : Clock oscillating frequency divided by 16 (f16) 10 : Clock oscillating frequency divided by 64 (f64) 11 : Clock oscillating frequency divided by 512 (f512) Note: Bit 4 is undefined at reading. Bit 5 is set to "1" at reset and cleared to "0" by writing to this register. Bits 0 to 3 and bits 6 and 7 are cleared to "0" at reset. Fig. 2.8.6 Timer Bi mode register structure in timer mode 100 FUNCTIONAL DESCRIPTION 2.8 Timer B '(1) Timer mode operation First, select the operating mode and count source with the timer Bi mode register. Next, write an value "n" ("n"=000016 to FFFF16) in the timer Bi register to specify the timer dividing ratio. At the same time, the value "n" is stored in the counter and the reload register. When the count start flag is set to "1" (count enabled), the selected count source is input to the counter and starts the count operation. Figure 2.8.7 shows the setting example of the timer mode related registers. The content of the counter is decremented by 1 each time the count source is input. When the counter underflows, the content of the reload Set timer Bi mode register I register is loaded in the counter and the interrupt .Set the operating mode selection bits (bit I, 0) to "00" I, .Select count source request bit is set to "1". At the same time, the timer Bi overflow flag is set to "1 ". Count op- eration continue~ in this manner. The interrupt request occurs and the interrupt request bit is Specify timer dividing ratio set to "1" each time the counter underflows. .Set value to the timer Bi register Therefore, an interrupt request occurs at every "n+ 1" count of the count source. Interrupts must be enabled before they can be used. Refer to Set the count start flag to "I" section "2.6 Interrupts" for more information. The interrupt request bit remains "1" set until the interrupt is accepted or it is cleared by program. Cou nt starts. The content of the counter can be read at any time by reading the content of the timer Bi reg- ister, but the content of the reload register can Fig. 2.8.7 Setting example of the timer mode reo not be read. In order to change the timer divid- lated reg isters ing ratio while the timer is operating, a 16-bit update value must be written simultaneously in the timer Bi register. This value is stored in the reload register and loaded in the counter next time the counter underflows after writing to timer Bi register. Figure 2.8.8 shows the timer mode operation diagram. 101 FUNCTIONAL DESCRIPTION 2.8 Timer B n = reload value FFFF16 / Count start Count stop ,~, n --: -----:- c~~~t ;~~t~~t-- --,, ,~ -, Underflow I ~-, 000016L-~ ____________L-+-____________L-+-__-r__~________~~____~~ Time Set the count start : Set the count start flag to "1" Clear the count start " flag to "1" / flag to "0" '\.. i/ Count start flag "1" 1t-!=-----;-----~~LJr-,-~­ "O,,--.J TBi overflow "1" flag "0" TBi interrupt "1" request bit "0" _----', ,...... t t Cleared by the interrupt accepted or program Fig. 2.8.8 Timer mode operation diagram 102 FUNCTIONAL DESCRIPTION 2.8 Timer B 2.8.4 Event counter mode [timer Bi mode register bits 1, 0 = "01 "] The event counter mode is selected by setting the timer Bi mode register bit 1 to "0" and bit 0 to "1". When this mode is selected, the timer Bi mode register bits 6 and 7 are ignored. Figure 2.8.9 shows the structure of the timer Bi mode register in event counter mode. In event counter mode, the input external clock to the TBiiN pin is counted. The counter is decremented each time a effective edge is input and an interrupt request occurs when the counter underflows (the content of the counter reaches 000016 ~ reload value "n"). The timer dividing ratio is expressed as follows: Timer dividing ratio =1/(n+1) n: Value set in counter (value between 000016 and FFFF16) b7 b6 b5 b4 b3 b2 b1 bO Timer Bi mode register (in event counter mode) '----'--- Operating mode selection bits 01 : Event counter mode ' - - _ . l . -_ _ _ _ _ Count polarity selection bits 00 : Count at the falling edge of the input signal 01 : Count at the rising edge of the input signal 10 : Count at both edges of the input signal L -_ _ _ _ _ _ _ _ _ _ _ _ Timer Bi overflow flag o : No underflow 1 : Underflow ' - - - - ' - - - - - - - - - - - - - - - - 1 These bits are ignored (may be "0" or "1"). Note: Bit 4 is undefined at reading. Bit 5 is set to "1" at reset and cleared to "0" by writing to this register. Bits 0 to 3 and bits 6 and 7 are cleared to "0" at reset. Fig. 2.8.9 Timer Bi mode register structure in event counter mode 103 FUNCTIONAL DESCRIPTION 2.8 Timer B (1) Event counter mode operation First, select the operating mode and the effective edge of the count source with the timer Bi mode register. Next, write a value "n" ("n"=000016 to FFFF16) in the timer Bi register specity the timer dividing ratio. At the same time, the value "n" is stored in the counter and the reload register. Also, set the corresponding port P6 direction register bit to TBilN pin to "0" (input mode). When the count start flag is set to "1" (count enabled), the effective edge of the input signal to TBilN pin is detected and count operation starts. Table 2.8.4 shows the relationship between the count polarity selection bits and the effective edge of the count. Figure 2.8.10 shows the setting example of the event counter mode related registers. Table 2.8.4 Relationship between count polarity selection bits and effective edge b3 b2 Count effective edge 0 0 Falling edge of input signal 0 1 Rising edge of input signal 1 0 Both edges of input signal The content of the counter is decremented by 1 each time an effective edge is detected. When the counter underflows, the content of the reload register is loaded in the counter and the interrupt request bit is set to "1". At the same time, the timer Bi overflow flag is set to "1". The count operation continues in this manner and an interrupt request occurs and the interrupt request bit is set to "1" each time the counter underflows. Therefore, a timer Bi inter- rupt request occurs at every "n+ 1" count of the count source. Interrupts must be enabled be- fore they can be used. Refer to section "2.6 Interrupts" for more information. The interrupt Set timer Bi mode register ) request bit remains "1" set until the interrupt is .Set the oerating mode selection bits (bit 1,0) to "01" accepted or it is cleared by program. .Select count source The content of the counter can be read at any time by reading the content of timer Bi regis- ter, but the content of the reload register can Specify timer dividing ratio not be read. .Set value to the timer Bi register In order to change the timer dividing ratio while the timer is operating, a 16-bit update value must be written simultaneously in the timer Bi Set the port direction registers .Set the corresponding bit to TBilN pin to "0" register. This value is stored in the reload reg- ister and loaded in the counter next time the counter underflows after writing to timer Bi register. Set the count start flag to "1" The operation in event counter mode is iden- tical to that of the timer mode except that an external clock input to the TBilN pin is counted. Count starts. Refer to "Fig. 2.8.8 Timer mode operation diagram" about an operation diagram. Fig. 2.8.10 Setting example of the event counter mode related registers 104 FUNCTIONAL DESCRIPTION 2.8 Timer 8 2.8.5 Pulse period/pulse width measurement mode [timer Bi mode register bits 1, 0="10"] The pulse period/pulse width measurement mode is selected by setting the timer Bi mode register bit 1 to "1" and bit 0 to "0". The difference between pulse period measurement and pulse width measurement is the effective edge of the input signal determining the count term . • Pulse period measurement Pulse period is measured by counting during the period between the falling edge and the next falling edge or between the rising edge and the next rising edge of the input signal to the TBilN pin . • Pulse width measurement Pulse width is measured by counting during the period between the falling edge and the next rising edge or between the rising edge and the next falling edge of the input signal to the TBilN pin. Figure 2.8.11 shows the structure of the timer Bi mode register in pulse period/pulse width measurement mode. (1) Pulse period /pulse width measurement mode description First, select the operating mode, whether to measure the pulse period or width, and count source with the timer Bi mode register. Set the corresponding port P6 direction register bit to TBIIN pin to "0" (input mode). When the count start flag is set to "1" (count enabled), the selected count source is input to the counter and count operation starts. The counter is incremented by 1 each time a count source is inpu·t. The content of the counter is transferred to the reload register when an effective edge is input to the TBilN pin. Then the counter is cleared to 000016. The count operation continues and the content of the counter is transferred to the reload register again when the next effective edge is input to the TBilN pin. Then the counter is cleared to 000016. At the same time, an interrupt request occurs and the interrupt request bit is set to "1 ". The measured result can be obtained by reading the timer Bi register because the content of the reload register is read. An interrupt request does not occur at the first effective edge after setting the cou nt start flag to "1". The interval between the falling edge and the rising edge or between the rising edge and the falling edge of the input Signal to the TBilN pin must be at least 2 cycles of the count source. When measuring the pulse width of a signal other than 50% duty, whether the result is "H" level width or "L" level width must be determined with program. Table 2.8.5 shows the relationship between measurement mode selection bits and measured intervals. Table 2.8.5 Relationship between measurement mode selection bits and measured intervals b3 b2 Measurement mode Measured intervals 0 0 Between the falling edge and the falling edge of the input signal 0 1 Pulse period Between the rising edge and the rising edge of the input signal Between the falling edge and the rising edge, and between the 1 0 Pulse width rising edge and the falling edge 105 FUNCTIONAL DESCRIPTION 2.8 Timer B In this mode, an interrupt request also occurs when the content of the counter reaches FFFF16 ~ 000016 in addition to the effective edge. When an overflow occurs, the timer Bi overflow flag is set to "1 ". Therefore, the cause of interrupt must be determined in the interrupt service routine by checking the timer Bi overflow flag. Interrupts must be enabled before they can be used. Refer to section "2.6 Interrupts" for more infor- mation. The interrupt request bit remains "1" set until the interrupt is accepted or it is cleared by program. Figure 2.8.12 shows the pulse period/pulse width measurement mode operation diagram in pulse period measurement mode. Figure 2.8.13 shows the pulse period/pulse width measurement mode operation diagram in pulse width measurement mode. b6 b5 b4 b3 b2 b1 bO Timer Bi mode register (in pulse period/pulse width measurement mode) --,-~.-~.-~.-~ ~--"--- Operating mode selection bits 10 : Pulse period/pulse width measurement mode ~--"----------- Measurement mode selection bits 00 : Pulse period mesurement (between the falling edge and the falling edge of the input signal) 01 : Pulse period mesurement (between the rising edge and the rising edge of the input signal) 10 : Pulse width measurement (between the falling edge and the rising edge, and between the rising edge and the falling edge L - -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Timer Bi overflow flag o : No overflow 1 : Overflow '----~-------------- Count source selection bits 00 : Clock oscillating frequency divided by 2 (f2) 01 : Clock oscillating frequency divided by 16 (f16) 10 : Clock oscillating frequency divided by 64 (f64) 11 : Clock oscillating frequency divided by 512 (f512) Note: Bit 4 is undefined at reading. Bit 5 is set to "1" at reset and cleared to "0" by writing to this register. Bits 0 to 3 and bits 6 and 7 are cleared to "0" at reset. Fig. 2.8.11 Timer Bi mode register structure in pulse period/pulse width measurement mode 106 FUNCTIONAL DESCRIPTION 2.8 Timer B Selected count source fi , ,, ,: ,: ,: Input signal to "H" ~ .: ...----.:li,, ...---.,:l:," :" " TBiiN pin "L" '1.._- ; . - - - - ' ''T-. . ; - - - - - ' ! Transfer! : Transfer: : Transferred timing of Reload register+- Counter __~____~ri ,i Clear , '\." Clear,! h-- Cleared timing of Counter+- "000016" __~____----,n ~ "1 " Count start flag "0"----' TBi interrupt "1" r---- request bit " 0 " - - - - - - - - - - - - - - - - - - - - - ' 1 This operation diagram measures between the falling edge and the falling edge, Fig. 2.8.12 Pulse period/pulse width measurement mode operation diagram in pulse period measurement mode Selected count source Ii :: I I :: I I :: I I I I I I I I ! I I 11 I I Input signal to " H " : ~r+:,-+---.....11 • ,i ,i ~ TBIIN pin "L" '-....---'-:T-ra-n-sf-'! TransfeIT-G..;.:--T-ra-n....l~fer :Transfet:L;.~";':-- Transferred timimg of Reload register+- Counter __~:~n , ' i i " ,h i Clear: Clear' '"~ '" Clear: Clear : ,1 ,1 '\J ,1 Cleared timing of Counter +-"000016" __~----,n n , ~, "1 " Count start flag "0"----' TBi interrupt "1" request bit " 0 " - - - - - - - - - - - ' t t Cleared by ,the interrupt accepted or program Fig. 2.8.13 Pulse period/pulse width measurement mode operation diagram in pulse width measurement mode 107 FUNCTIONAL DESCRIPTION 2.8 Timer B [Precaution when using the timer B] 1. The value of the counter while operating in timer mode or event counter mode can be read at any time by reading the timer Bi register. However, if it is read at the reload timing shown in Figure 2.8.14, "FFFF,s" is returned instead of the reload value. The reload value is returned if it is read after the timer , Bi register is set and before the count source is input and count started. Reload (hexadecimal --r---'---'--o---r,-n-',n-- ""1",- Counter content 2 ... -1 notation) -+--+---+---+:--+-: ----+:- , , , -r---r---r----,I--r'---"1",- Read value (hexadecimal 2 0 FFFF n - 1 notation) _-'--_.....1--_-'-_--'_ _-'--_-'--_ . ~ n=reload value Time Fig. 2.8.14 Reading the timer Bi register 2. Interrupt request occurs by two factors in pulse period/pulse width measurement mode. These interrupts use the same interrupt vector address of timer Bi. Two factors are follows . • Completing the measurement of the pulse period/pulse width .Overflow of the counter 108 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 2.9 Serial 110 Serial I/O consists of UARTO and UART1 that have same functions. These serial 1/0 can operate either as clock synchronous serial 1/0 port or asynchronous serial 1/0 (UART) port. 2.9.1 Serial 110 description UARTO and UART1 can operate either as. clock synchronous serial 1/0 port or asynchronous serial I/O (UART) port. These two serial I/O ports are independent, but have identical functions. Each serial 1/0 port has a transfer clock generation timer (baud rate generator referred to BRG) and can be set a variety of data transfer rate. Figure 2.9.1 shows the serial I/O operating modes. Each serial 1/0 has four operating modes. The following modes are available: .Clock synchronous serial 110 In this mode, both the transmission side and receiving side use the same clock to transfer data. The data (character) length is 8 bits . • 7-bit UART In this mode, the data is transferred at an arbitrary rate and data format. The data (character) length is 7 bits . • S-bit UART This mode is identical to 7-bit UART except that the data length is 8 bits . • 9-bit UART This mode is identical to 7-bit UART except that the data length is 9 bits. Clock synchronous serial I/O Serial 1/0 Clock asynchronous serial 1/0 (UART) 7-bit UART 8-bit UART 9-bit UART Fig. 2.9.1 Serial 110 operating modes 109 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 2.9.2 Block description Figure 2.9.2 shows the block diagram of serial 1/0. The function of each related registers are described below. RxDi(r--------------------------------------------------~ ~------,---~~ BRG count source selection bits f2 ---0 f'6 ---o~ [. . --0 f512 --0 Clod< synchronolls (Internal clock) cLKicr-----+---<~----------------------_+----~ CT~RTSLr----------------------------------~ Fig. 2.9.2 Serial 110 block diagram 110 FUNCTIONAL DESCRIPTION 2.9 Serial I/O (1) UARTi transmit/receive mode reg ister(i=O, 1) The UARTO transmit/receive mode register(address 3016) and the UART1 transmit/receive mode register(address 3816) consist of bits to set serial I/O modes, transfer format. Figure 2.9.3 shows the structure of the UARTi transmit/receive mode register. b7 b6 b5 b4 b3 b2 b1 bO UARTO transmit/receive mode register(address 3016) IR/W IR/W IR/W I R/W I R/W I R/W I R/W I R/W I UART1 transmit/receive mode register(address 3816) I I I Serial I/O mode selection bits 000 : Programmable 1/0 pin (Serial 1/0 prohibited) 001 : Clock synchronous serial I/O 100 : 7-bit UART 101 : 8-bit UART 110 : 9-bit UART Internal/External clock selection bit o : Internal clock 1 : External clock Stop bit length selection bit (in UART mode) o : One stop bit 1 : Two stop bits Odd/Even parity selection bit (in UART mode) o : Odd parity 1 : Even parity Parity enable bit (in UART mode) o : Parity disabled 1 : Parity enabled Sleep function selection bit (in UART mode) o : Sleep function disabled 1 : Sleep function enabled Note: Bits 4 to 6 are ignored in clock synchronous mode. Bit 7 must be set to "0" when using clock synchronous mode. This register is cleared to "0016" at reset. Fig. 2.9.3 UARTi transmit/receive mode register structure 111 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 .Serial 110 mode selection bits (bits 0 to 2) These bits are used to select serial I/O modes. Table 2.9.1 shows the relationship between the serial 110 mode selection bits and serial I/O modes. a When bits 2 to are set to "000", serial I/O is disabled and ports P8c to P83, and P84 to P87 function as programmable I/O ports. When one of the serial I/O modes is selected, port P8 has the function shown in Table 2.9.2 and loses its programmable I/O port function (except for some pins in UART mode). Table 2.9.1 Relationship between serial I/O mode selection bits and serial 110 modes b2 b1 bO Serial I/O mode selection bits 0 0 0 Programmable I/O pin (Serial I/O prohibited) 0 0 1 Clock synchronous serial I/O 0 1 0 Not available 0 1 1 Not available 1 0 0 7-bit UART 1 0 1 8-bit UART 1 1 0 9-bit UART 1 1 1 Not available , Table 2.9.2 Function of port P8 when serial I/O is selected Using UARTO Using UART1 Function P8c P84 CTS/RTS (transmission control Signal I/O pin) P8l P8s ClK (transfer clock I/O pin) (Note 1) P82 P86 RxD (serial data input pin) P83 P87 TxD (serial data output pin) (Note 2) Note1: ThiS depends on the Internal/external clock selection bit as follows: When external clock is selected : Clock input pin When internal clock is selected : ·Clock output pin in clock synchronous mode ·Normal I/O port in UART mode Note 2 :TxD pin starts to output "H" level when one of serial I/O modes is selected. 112 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 .Internal/external clock selection bit (bit 3) [Clock synchronous mode] This bit is used to select either an internal clock or an external clock as the synchronous clock (shift clock) for data transfer. When this bit is set to "0" to select an internal clock, the divided clock by 2 which the later described baud rate generator (BRG) generates is used as the shift clock. In addition, the CLKi pin becomes the output pin and the shift clock is output from this pin. When this bit is set to "1" to select an external clock, the CLKi pin becomes the input pin and data transfer is synchronized with the clock input to this pin. [UART mode] This bit is used to select either an internal clock or an external clock as the input to the BRG which is described later. When this bit is set to "0" to select an internal clock, the clock selected with the BRG count source selection bit in the UARTi transmit/receive control register 0 becomes the BRG input clock. In this case, the CLKi pin( ports P81, P8s) can be used as a programmable I/O pin. When this bit is set to "1" to select an external clock, the CLKi pin becomes the clock input pin and the clock input to this pin becomes the BRG input clock . • Stop bit length selection bit (bit 4) [Clock synchronous mode] This bit is ignored. It can be either "0" or "1 ". [UART mode] This bit is used to select between 1 and 2 bits as the stop bit to indicate the end of data. 1 stop bit is selected when this bit is "0". 2 stop bits are selected when this bit is "1 ". • Odd/even parity selection bit (bit 5) [Clock synchronous mode] This bit is ignored. It can be either "0" or "1 ". [UART mode] This bit is used to select between even parity and odd parity. Odd parity is selected when this bit is "0", and even parity is selected when this bit is "1 ". This bit is valid if the parity enable bit is set to "1" (enabled) . • Parity enable bit (bit 6) [Clock synchronous mode] This bit is ignored. It can be either "0" or "1 ". [UART mode] This bit is used to specify whether to add a parity bit at the end of transmitted data or to perform parity check of received data. Whether to use odd parity or even parity is specified with bit 5. When this bit is "1", a parity is added at transmitting, or parity check is performed at receiving . • Sleep function selection bit (bit 7) [Clock synchronous mode] This bit must be set to "0". [UART mode] This bit is used to enable or disable the sleep function. If this bit is set to "1" to enable the sleep function, the data is ignored when the most significant bit (MSB) of the received data is "0". This function is used when multiple microcomputers are connected through the serial I/O port. Refer to section "2.9.5 Sleep mode". 113 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 (2) UARTi transmit/receive control register 0 The UARTO transmit/receive control register O(address 341S) and the UART1 transmit/receive control register O(address 3C1S) consist of bits to select the BRG count source and CTS/RTS lunction, and a flag that indicates the UARTi transmission register status. Figure 2.9.4 shows the structure of the UARTi transmit/receive control register O. • BRG count source selection bits (bits 0 and 1) This bit is used to select the count source of the baud rate generator (BRG) when an internal clock is selected. Table 2.9.3 shows the relationship between the BRG count source selection bits and the count source. Table 2.9.3 Relationship between BRG count source selection bits and count source b1 bO. BRG count source a 0 12 selected which is the oscillating clock f(XIN) divided by 2 0 1 11s selected which is the oscillating clock f(XIN) divided by 16 1 0 fS4 selected which is the oscillating clock f(XIN) divided by 64 1 1 1512 selected which is the oscillating clock f(XIN) divided by 512 .CTS/RTS function selection bit (bit 2) This bit is used to select CTS and RTS function. Port P8c functions as CTS/RTS pin for UARTO, P84 as CTS/RTS pin for UART1. When this bit is "0", CTS function is selected. Port P8D or P84 becomes the CTS input pin. This pin must be at "L" level in order for transmission to start. When this bit is "1", RTS function is selected. port P8D or P84 becomes the RTS output pin. "H" level is output when receive is disabled (the receive enable bit in UARTi transmit/receive control register 1 is "0"). "L" level is output when receive is enabled (the receive enable bit is "1"). It returns to "H" level when receive starts . • Ttransmission register empty flag (bit 3) This flag is set to "0" when the content of UARTi transmission buffer register is transferred to the UARTi transmission register. It is set to "1" when transmission completes and the UARTi transmission register becomes empty. b3 UARTO transmiUreceive control register 0 (address 341S) UART1 transmiUreceive control register 0 (address 3C1S) '-------'-- BRG count source selection bits 00 : f2 selected 01 : f1s selected 10 : fS4 selected 11 : 1512 selected CTS/RTS function selection bit o : CTS function selected 1 : RTS function selected Transmission register empty flag o : Data in transmission register (transmitting) 1 : No data in transmission register (transmit complete) Note : Bit 3 is a read-only bit and set to "1" at reset. Bits 0 to 2 are cleared to "0" at reset. Bits 4 to 7 are undefined at reading. Fig. 2.9.4 UARTi transmit/receive control register 0 structure 114 FUNCTIONAL DESCRIPTION 2.9 Serial I/O (3) UARTI transmit/receive control register 1 The UARTO transmit/receive control register 1(address 3516) and the UART1 transmit/receive control register 1 (address 3D16) consist of serial I/O enable bits, serial I/O status flags, and serial I/O error flags. Figure 2.9.5 shows the structure of the UARTi transmit/receive control register 1. b7 b6 b5 b4 b3 b2 b1 bO I I l R 1R J I R R I I I I I UARTO transmit/receive control register 1 (address 3516) l R l R/W R R/W UART1 transmit/receive control register 1 (address 3016) L Transmit enable bit o : Transmission disable 1 : Transmission enable Transmission buffer empty flag o : Data in transmission buffer register 1 : No data in transmission buffer register Receive enable bit o : Receive disable 1 : Receive enable Receive completion flag o : No data in receive buffer register 1 : Data in receive buffer register Overrun error flag o : No overrun error 1 : Overrun error Framing error flag (in UART mode) o : No framing error 1 : Framing error Parity error flag (in UART mode) o : No parity error 1 : Parity error Error sum flag (in UART mode) o : No error 1 : Error occurred Note: Bits 5 to 7 are ignored in clock synchronous mode. Bit 0 and bits 2 to 7 are Gleared to "0" at reset. Bit 1 is set to "1" at reset. The receive enable bit and each error flag are cleared to "0" when the receive buffer register is read. Fig. 2.9.5 UARTi transmit/receive control register 1 structure 115 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 .Ttransmit enable bit (bit 0) Serial I/O transmission is enabled when this bit is set to "1 ". If this bit is set to "0" during transmitting, serial 1/0 transmission is disabled after the current transmission completes . • Transmission buffer empty flag (bit 1) This flag indicates the status of the transmission buffer register. This bit is set to "1" when the content of the transmission buffer register is transferred to the transmission register. This flag is automatically cleared to "0" when data is written in the transmission buffer register . • Receive enable bit (bit 2) Serial I/O reception is enabled when this bit is set to "1". If the RTS function is selected, the RTS pin becomes "L" level when this bit is set to "1 ". • Receive completion flag (bit 3) This flag is set to "1" when the data in the receive register is transferred to the receive buffer register (receive completion). This flag is cleared to "0" when the low-order byte of the receive buffer register is read or when the receive enable bit is set to "0" (receive disabled) . • Overrun error flag (bit 4) This flag is set to "1" when receiving of the next data completes and the content of the receive buffer register is updated while there is data remaining in the receive buffer register (before the content of the receive buffer register is read). This flag is cleared to "0" when the low-order byte of the receive buffer register is read or when the receive enable bit is set to "0" (receive disabled) . • Framing error flag (bit 5) [Clock synchronous mode] This flag is ignored. [UART mode] This flag is set to "1" when the number of stop bits is not the number specified with bit 4 of the UARTi transmitlreceive mode register. This flag is cleared to "0" when the low-order byte of the receive buffer register is read or when the receive enable bit is set to "0" (receive disabled). ' .Parity error flag (bit 6) [Clock synchronous mode] This flag is ignored. [UART mode] This flag is set to "1" when the parity odd/even is not the one specified. This flag is cleared to "0" when the low-order byte of the receive buffer register is read or when the receive enable bit is set to "0" (receive disabled) . • Error sum flag (bit 7) [Clock synchronous mode] This flag is ignored. [UART mode] This flag is set to "1" when either an overrun error, a framing error, or a parity error occurs. This flag is cleared to "0" when the low-order byte of the receive buffer register is read or when the receive enable bit is set to "0" (receive disabled). 116 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 (4) UARTi transmission register and UARTi transmission buffer register The UARTO transmission buffer register(address 3216, 3316) and the UART1 transmission buffer register(address 3A16, 3B16) are registers to set data output from TXOi pin. When transmit conditions are satisfied, the transmit data written in the UARTi transmission buffer register is transferred to the UARTi transmission register, and is synchronously transmitted from the TxOi pin with the specified clock. In clock synchronous mode and 7 or 8-bit UART mode, only the low-order byte of the UARTi trans- mission buffer register is used. In 9-bit UART mode, bit 8 of the transmit data is written in bit 0 of the high-order byte, and the remaining 0 to 7 bits are written in the low-order byte. The UARTi transmission buffer register becomes empty after the data is transferred to the UARTi transmission register. Therefore, the next transmit data can be written during transmission. The content of UARTi transmission buffer register can not be read because it is a write-only register. Figure 2.9.6 shows the block diagram of serial 1/0 transmission. : :: . •• , .... Data bus (even) , .. ' .. " ". ::-.: ... r'---'-------' TxOi Fig. 2.9.6 Serial 1/0 transmission block diagram (5) UARTi receive register and UARTi receive buffer register The UARTi receive register converts serial data input to the RxOi pin to parallel data. The RxOi pin level is moved bit by bit to the UARTi receive register synchronized with the rising edge of the synchronous clock. The UARTO receive buffer register(address 3616; 3716) and the UART1 receive buffer register(address 3E16, 3F16) are registers to read the received data. The content of UARTi receive register is automati- cally transferred to the UARTi receive buffer register when data receive completes. The contents of the high-order 7 bits of the UARTi receive buffer register are always "0" at reading. The same data as the MSB (most significant bit) of effective receive data can be read from the unused bits of the low-order 9 bits as follows: .07 and Os in 7-bit UART mode . • Os in 8-bit UART mode and clock synchronous mode. Note that the content of UARTi receive buffer register will be updated if the next receive data becomes available before the UARTi receive buffer register is read( overrun error occurs). Figure 2.9.7 shows the block diagram of serial 1/0 receive. 117 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 RxDi Fig. 2.9.7 Serial 110 receive block diagram (6) UARTi baud rate generator (BRG) The UARTO baud rate generator (address 3116) and the UART1 baud rate generator (address 3916) are timers used exclusively for serial I/O. It is equipped with a reload register and has a 8-bit structure. The BRG divides the input clock by (n+1), where "n" is the value set in the BRG register. This register can contain a value between 0016 and FF16. In clock synchronous serial I/O mode, the BRG becomes effective when an internal clock is selected and the BRG output divided by 2 becomes the transmit/receive clock. In UART mode, the BRG is effective regardless of the clock type and the BRG output divided by 16 becomes the transmit/receive clock. The content of the BRG register can not be read because it is a write-only register. Figure 2.9.8 shows the block diagram of shift clock generation . • Clock synchronous mode ~ f, -1'--_B_R_G_..... Transmission conlrol circuit I-"---~Transmission clock ~============~ ~~ ----~----------------~ Receive control circuit I-----~ Receive clock • UART mode Transmission control circuil t--~ Transmission clock BRG Receive control circuit Receive clock fi: Internal clock selected with the BRG count source selection bit fEXT: External clock input to the CLKi pin Fig. 2.9.8 Shift clock generation block diagram 118 FUNCTIONAL DESCRIPTION 2.9 Serial I/O (7) UARTi transmission interrupt control register and UARTi receive interrupt control register Transmit interrupt and receive interrupt can be used when the serial 1/0 function is selected. Each interrupt has an interrupt control register. Interrupt control register consists of interrupt priority level selection bits and interrupt request bit. Figure 2.9.9 shows the structure of UARTi transmission inter- rupt control register and UARTi receive interrupt control register. Refer to section "2.6 Interrupts" for more information . • Interrupt priority level selection bits (bits 0 to 2) These bits are used to select the interrupt priority level. They should be set to a level between 1 and 7 when using serial 1/0 interrupts. When there is an interrupt request, this level is compared with the processor interrupt priority level (IPL) in the processor status register (PS). The interrupt is allowed only when this level is greater than IPL (interrupt disable flag I must be "0"). Set the corresponding bits to "000" (level 0) to disable an interrupt. .Interrupt request bit (bit 3) The transmit interrupt request bit is set to "1" when data is transferred from the UARTi transmission buffer register to the UARTi transmission register for data transmission. The receive interrupt request bit is set to "1" when data receive completes and data is transferred from the UARTi receive register to the UARTi receive buffer register. The interrupt request bit set to "1" is cleared to "0" when the interrupt request is accepted. This bit can be set or cleared by program. b6 b5 _b_3-,-_b_2---r_b_1---._bO-, UARTO transmission interrupt control register (address 7116) UARTO receive interrupt control register (address 7216) ----,_.1...-,--'--..,.--'----,--' UART1 transmission interrupt control register (address 7316) UART1 receive Interrupt control register (address 7416) '----'------'--- Interrupt priority level selection bits 000 : Level 0 (disable interrupt) 001 : Level 1 Low 010 : Level 2 011 : Level 3 100 : Level 4 Priority 101 : Level 5 110 : Level 6 111 : Level 7 High Interrupt request bit o : No interrupt request 1 : I nterrupt request Note: Bits 4 to 7 are undefined at reading. Bits 0 to 3 are cleared to "0" at reset. Fig. 2.9.9 UARTi transmission interrupt control register and UARTi receive Interrupt control register structure 119 FUNCTIONAL DESCRIPTION 2.9 Serial I/O (8) Port P8 direction register Serial I/O input/output pins are shared with port P8. Port P8 function is selected by the serial I/O mode selection bits of the UARTi transmit/receive mode register. When using port P8 as serial 110 input pins, the corresponding bit in the direction register must be set to "O"(input mode). When using port P8 as serial I/O output pins, it functions as serial I/O output pins regardless of the direction register. Figure 2.9.10 shows the relationship between the port P8 direction register(address 1416) and the serial I/O pins. b7 b6 b5 b4 b3 b2 b1 bO IR/W IR/W IR/W IR/W I R/W IR/W IR/W IR/W Port P8 direction register (address 1416) l L- CTSo inputlRTSO output pin CLKo I/O pin RxDo input pin TxDo output pin CTSl inputlRTSl output pin CLKl I/O pin RxDl input pin TxDl output pin Note:This register is cleared to "0016" at reset. Fig. 2.9.10 Relationship between port P8 direction register and serial I/O pins 120 FUNCTIONAL DESCRIPTION 2.9 Serial I/O 2.9.3 Clock synchronous serial I/O Table 2.9.4 shows the performance of clock synchronous serial I/O mode. Table 2.9.4 Clock synchronous serial I/O description Parameter Function Data format B bit fixed, LSB first Transmission speed Internal clock BRG output divided by 2 External clock 2Mbps maximum (at f(XIN)=BMHz) 4Mbps maximum (at f(XIN)=16MHz) 5Mbps maximum (at f(XIN)=25MHz) Transmit/receive control CTS input or RTS output can be selected by program. (1) Synchronous clock (shift clock) The serial I/O data transfer rate is determined by the synchronous clock (shift clock). The M37702 group can select whether to generate this clock internally or to use an external clock. The synchronous clock is generated internally when the UARTi transmit/receive mode register bit 3 is set to "0", and externally when it is set to "1 ". In clock synchronous mode, the synchronous clock used for data transfer is generated by activating the transmitter. Therefore, the transmitter must be activated even when performing receive only . • Uslng Internal generation clock as synchronous clock When the internal/external clock selection bit is set to "0", the BRG output divided by 2 is used as the synchronc;lUs clock. In this case, the CLKi pin becomes output mode and the transmit/receive syn- chronous clock is output from the CLKi pin. The BRG is a serial I/O timer which has a B-bit structure and is used as a frequency divider to generate the desired frequency. The BRG divides the clock selected with bits 0 and 1 in the UARTi transmit/receive control register 0 by (n+1). The synchronous clock is the divided clock by 2 which has been divided by (n+1) with the BRG. "n" is the value set in the BRG register. It can be SE}t a value between 0016 and FF16. Synchronous clock frequency ............. fl / (2(n+1)) fl : BRG input frequency (i=2, 16, 64, 512) B synchronous clocks are generated by activating the trans- mitter. .Using external input clock as synchronous clock When the internal/external clock selection bit is set to "1 ", the external clock is used as the synchro- nous clock. When an external clock is selected, the clock input to the CLKi pin becomes the synchronous clock. Set the port PB direction register bit 1(CLKo) and bit 5(CLK1) to "0" to select input mode. 121 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 (2) Serial data transmission The data transmission method in clock synchronous serial I/O mode is described below. [Setting the control registers] Set each serial I/O control register for transmission . • UARTi transmit~receive mode register -Serial I/O mode selection bits Set the bits 2 to 0 to "001". -Internal/external clock selection bit Select either an internal clock ("0") or an external clock ("1 "). -Setting the bit 7 to "0" (disable sleep mode) .UARTi transmit/receive control register 0 -BRG count source selection bits Select the BRG count source with bits 0 and 1 when an internal clock is selected for synchronous clock. -CTS/RTS function selection bit Set the bit 2 to "0" when using CTS function, and to "1" when not use . • UARTi baud rate generator(BRG) -Dividing ratio Set the BRG value between 0016 and FF16 when an internal clock is selected for synchronous clock . • Port P8 direction register -Port direction selection bits Set the corresponding bit to "0" when the CTS function is selected and an external clock is selected . • UARTi transmission interrupt control register -Interrupt priority level selection bits When using UARTi transmission interrupt, set the priority level to the level 1 to 7. When not use, set to the level O. eUARTi transmission buffer register -Transfer data Set a transfer data to the low-order byte of UARTi tranSniission buffer register. The transmission buffer empty flag of UARTi transmit/receive control register 1 is cleared to "0" at the same time . • UARTi transmit/receive control register 1 -Transmit enable bit Set the bit 0 to "1" to enable transmitting. Figure 2.9.11 shows the setting example of clock synchronous serial I/O related registers at transmit- ting. 122 FUNCTIONAL DESCRIPTION 2.9 Serial 1/0 , UARTO transmitfreceive mode register (address 3016) UARTI transmitfreceive mode register (address 3816) b7 bO 'a- ....................... .. 01 1 1 10 o 11 1 I • I Internal/External clock selection bit • o: Internal clock UARTO transmisSion Interrupt control register (address 71 16) 1 : External clock UARTI transmission interrupt control register (address 7316) b7 bO Fix to "0". · I I I I I I I II D D 1 1 I Interrupt priority level selection bits D · UARTO transmitfreceive control register 0 (address 3416) I Set to level 1 to 7 when using interrupts. UARTI transmiVreceive control register 0 (address 3C16) D b7 bO D I I I I I I D - LL BRG count source selection bits UARTO transmission buller register (address 3216) UARTI transmission buller register (address 3A16) 00 : 12 selected 01 :"6 selected b7 bO 10 : 164 selected 11 : 512 selected I I I I I I I I ..JI CTS'RTS function selection bit "- Y o: CTS function selected Set a transmit data. 1 : RTS function selected (CTS function disabled) • D D D_ D D D D - - UARTO transmitfreceive control register 1 (address 3516) UARTO BRG register (address 3116) UARTI transmit/receive control register 1 (address 3016) UARTI BRG register (address 3916) b7 bO b7 bO I I I I I I I I~ I\. I I I I I I I I ) Transmit enable bit y o : Transmission disable 1 : Transmission enable Set a value between 0016 and FFI6. Necessary only to select Internal clock. • ~ D D - Port P8 direction register (address 1416) b7 bO I I 10 101 10 101 , ~ Corresponding to CTSo pin Transmitting operations start. Corresponding to ClKo pin Transmitting operations start when the following conditions are satisfied: Corresponding to CTSI pin .Transmission is enabled (the transmit enable bit is "1'1, Corresponding to ClKI pin .Transmit data is available in the UARTi transmission buffer register ~transmission buffer empty flag is "O"). D eeTS, pin input level is "l" (in case of selecting CTS function), I I • ~ • • • • III.III.aa.III • • • ~ Fig. 2.9.11 Setting example of clock synchronous serial I/O related registers at transmlttmg 123 FUNCTIONAL DESCRIPTION 2.9 Serial I/O [Transmit operation] The transmission of serial data starts when the following conditions are satisfied : A-D register 3 (address 261S) '-- A-D register 4 (address 281S) Decoder A-D register 5 (address 2A1S) .-- A-D register 6 (address 2C1S) Comparator A-D register 7 (address 2E1S) V ~. :Daia bus (even) \ ANoO AN10 -- ~ v- AN2 , __ -v- AN3'" ,-..-v- ,_ -v- AN4C? AN59 -u- ANs '" TRG ;::::: ..; - -u------< Selector Fig. 2.10.1 A-O converter block diagram 145 FUNCTIONAL DESCRIPTION 2.10 A-D converter (1) A-D control register The A-D control register (1 E1S) consists of bits that control the A-D converter. Figure 2.10.2 shows the structure of the A-D control register followed by description of each bit. b7 b6 b5 b4 b3 b2 b1 bO I R/W I R/W I R/W I R/W I R/W I R/W I R/W I R/W I A·D control register (address 1E16) I I I Analog input pin selection bits 000 : ANa pin selected 001 : AN1 pin selected 010 : AN2 pin selected 011 : AN3 pin selected 100 : AN4 pin selected 101 : ANs pin selected 110 : AN6 pin selected 111 : AN? pin selected (Note) '----"------------A-D mode selection bits 00 : One-shot mode 01 : Repeat mode 10 : Single sweep mode 11 : Repeat sweep mode ' - - - - - - - - - - - - - - T r i g g e r selection bit o : Software trigger (internal trigger) 1 : ADTRG input trigger (external trigger) ' - - - - - - - - - - - - - - - - A - D conversion start flag o : Stop A-D conversion 1 : Start A-D conversion ' - - - - - - - - - - - - - - - - - - A - D conversion frequency (I/JAD) selection flag o : Clock oscillating frequency divided by 8 (f8) 1 : Clock oscillating frequency divided by 4 (14) Note: ANa pin(port P7?) functions as ADTRG input pin when an external trigger is selected. Bits 0 to 2 are undefined at reset. Bits 3 to 7 are cleared to "0" at reset. Fig. 2.10.2 A-D control register structure 146 FUNCTIONAL DESCRJI1PTJrON 2.10 A-O converter _Analog input selection bits (bits 0 to 2) Table 2.10.2 Relationship between analog input pin se· The analog input selection bits are used to select lection bits and analog input pins the analog input pin in one-shot mode and repeat b2 b1 bO Analog input pin mode. The selected analog input pin remains 0 0 0 ANa pin selected unchanged when the mode is switched between 0 0 1 ANl pin selected one-shot mode and repeat mode. These bits 0 1 0 AN2 pin selected are ignored in single sweep mode and repeat 0 1 1 AN3 pin selected sweep mode. If an external trigger is selected 1 0 0 AN4 pin selected with the trigger selection bit (described later), 1 0 1 AN5 pin selected port P77 functions as ADTRG pin and cannot be 1 1 0 ANs pin selected used as AN7 pin. 1 1 1 AN7 pin selected Table 2.10.2 shows the relationship between the analog input selection bits and analog input pins. eA-D mode selection bits (bits 3, 4) The A-D mode selection bits are used to select one of the four available conversion modes. Table 2.10.3 shows the relationship between the A-D mode selection bits and the conversion modes. Table 2.10.3 Relationship between A·D mode selec· tion bits and conversion modes b4 b3 A-D conversion mode 0 0 One-shot mode 0 1 Repeat mode 1 0 Single sweep mode 1 1 Repeat sweep mode OTrigger selection bit (bit 5) The trigger selection bit is used to select the trigger occurrence factor which start an A-D conversion operation. An internal trigger or an external trigger is available for the trigger. An internal trigger (software trigger) is selected when this bit is "0" and an external trigger (input signal to ADTRG pin) is selected when this bit is "1". A trigger is generated and A-D conversion starts when the A-D conversion start flag (described later) is set to "1 ". A trigger is generated when the level of the signal input to the ADTRG pin changes from "H" to "L" (falling edge) while the A-D conversion start flag is "1 ". When an external trigger is selected, a retrigger is available during A-D conversion. In this case, the conversion is repeated from the beginning. The ADTRG pin is shared with the AN7 (port P77) pin. Therefore, the AN7 pin cannot be used as analog input pin when an external trigger is selected. When an external trigger is selected in each A-D conversion mode, the port P7 direction register bit 7 must be set to "0" (input mode). 147 FUNCTIONAL DESCRIPTION 2.10 A-O converter eA·D conversion start flag (bit 6) The A-D conversion start flag is used to start or stop A-D conversion. An internal trigger is generated and A-D conversion starts when the A-D conversion start flag is set to "1 ". A-D conversion stops when it is cleared to "0". This bit is automatically cleared after A-D conversion in one-shot mode and single sweep mode. It is not cleared in other modes and conversion continues until it is cleared to "0". The A-D conversion start flag must be set to "1" before the falling edge is input to the ADTRG pin. If external trigger is selected, this flag is not cleared to "0" after conversion. eA·D conversion frequency selection flag (bit 7) This flag is used to select the A-D converter operating frequency (¢AD). When this flag is "0", the clock frequency f(XIN) divided by 8 is selected. When this flag is "1 ", the clock frequency f(XIN) divided by 4 is selected. In one-shot mode and repeat mode, A-D conversion completes after 57 x ¢AD cycles from the beginning of A-D conversion. In single sweep and repeat sweep mode, A-D conversion completes after 57 x number of selected pins x ¢AD cycles from the beginning of A-D conversion. The A-D converter operating clock ¢AD during A-D conversion must be no less than 250kHz because the comparator in the A-D conversion circuit consists of capacity coupling amplifiers. Table 2.10.4 shows the relationship between the A-D conversion frequency selection flag and the A- D converter operating clock and conversion time. Table 2.10.4 Relationship between A·D conversion frequency selection flag and the A·D converter operating clock and conversion time A-D frequency selection flag "0" "1 " A-D converter operating clock ¢AD= f(XIN) ¢AD= f(XIN) 8 4 Conversion time f(XIN)=8MHz 57.0 IlS 28.5 IlS (Note) f(XIN)=16MHz 28.5 )ls 14.25 )ls f(XIN)=25MHz 18.24 )ls 9.12 )ls Note. Conversion time per one analog input pin 148 FUNCTIONAL DESCRIPTION 2.10 A-O converter (2) A-D register i (i=O to 7) The A-D registers (address 2016 to 2E16) are 8-bit read only registers. The conversion results (content of successive approximation register) are stored in these registers. Each A-D register corresponds to an analog input pin. The content of the A-D register can be read during A-D conversion. However, if the A-D register corresponding to the analog input being converted is read, the previous conversion result is obtained. Table 2.10.5 shows the relationship between the analog input pin and A-D register and Figure 2.10.3 shows the structure of A-D register. Table 2.10.5 Relationship between analog input pin and A-O register Analog input pin Register containing the result Address ANa pin A-D register 0 2016 ANI (:lin A-D register 1 2216 AN2 pin A-D register 2 2416 AN3 pin A-D register 3 2616 AN4 pin A-D register 4 2816 ANs pin A-D register 5 2A16 AN6 pin A-D register 6 2C16 AN7 pin A-D register 7 2E16 b7 b6 b5 b4 b3 b2 b1 bO R R R R R R R R I A-D register i (i = 0 to 7) IConversion result I Note: This register is undefined at reset. Fig. 2.10.3 A-D register i structure (3) Comparator and successive approximation register The compare reference voltage Vrel and analog input voltage VIN are compared for bits 7 to 0 of successive approximation register and the result is set in each bit. Comparison starts from bit 7 and the contents of this register (conversion result) is transferred to A-D register after comparing bit O. The content of the successive approximation register changes according to the comparison result of each bit. Therefore, the compare reference voltage Vrel also changes according to the content of the successive ap- proximation register. The analog input voltage VIN is selected by the decoder (refer to section "2.10.3 Successive approximation conversion"). 149 FUNCTIONAL DESCRIPTION 2.10 A-O converter (4) A·D conversion interrupt control register The A-O conversion interrupt control register (address 7016) consists of interrupt priority selection bits and interrupt request bit. Figure 2.10.4 shows the structure of the A-O conversion interrupt control register. Refer to section "2.6 Interrupts" for more information concerning interrupts. b7 b6 b5 b4 b3 b2 b1 bO A·D conversion interrupt control register (address 7016) '----'----'--- Interrupt priority selection bits 000 : Level a (disable interrupt) 001 : Level 1 Low 010 : Level 2 011 : Level 3 100 : Level 4 Priority 101 : Level 5 110 : Level 6 111 : Level 7 High Interrupt request bit a : No interrupt request 1 : Interrupt request Note: Bits 4 to 7 are undefined at reading. Bits a to 3 are cleared to "0" at reset. Fig. 2.10.4 A-D conversion interrupt control register structure .Interrupt priority selection bits (bits 0 to 2) These bits are used to select the interrupt priority level. They should be set to a level between 1and 7 when using an A-O conversion interrupt. When there is' an interrupt request, this level is compared with the processor interrupt priority level (IPL) in the processor status register (PS) and an interrupt is allowed only when this level is greater than IPL (interrupt disable flag I must be "0"). Set these bits to "000" to disable only A-O conversion interrupt. .Interrupt request bit (bit 3) This bit is set to "1" when an A-O conversion interrupt request occurs. The interrupt request bit set to "1" is cleared to "0" when the interrupt request is accepted. This bit can be set or cleared by program. 150 FUNCTIONAL DESCRIPTION 2.10 A-O converter (5) Port P7 direction register The analog input pin is shared with port P7. When using these ports as analog input pins or using port P77 as external trigger input pin, the corresponding bit in the port P7 direction register must be set to "0" (input mode). Figure 2.10.5 shows the relationship between the port P7 direction register (1116) and analog input pins. b7 b6 b5 b4 b3 b2 b1 bO IR/W IR/W IR/W I R/W I R/W I R/W I R/W I R/W I Port P7 direction register (address 1116) ~ ANa pin l AN1 pin AN2 pin AN3 pin AN4 pin AN5 pin AN6 pin AN? pin I ADTRG pin Note: This register is cleared to "0016" at reset. Fig. 2.10.5 Relationship between port P7 direction register and analog input pin 151 FUNCTIONAL DESCRIPTION 2.10 A-D converter 2.10.3 Successive approximation conversion A-O conversion starts when an internal or external trigger is generated. A-O conversion is performed by successive approximation. When A-O conversion starts, the following operations are performed to convert analog values to digital values. CDlnitialization of successive approximation register The successive approximation register is cleared to "OOlS". ®Setting the most significant bit (bit 7) The successive approximation register bit 7 is set to "1 ". Then the reference voltage V,of is compared with the input voltage VIN and bit 7 changes as follows: Unchanged if V,ef < VIN Cleared to "0" if V,ef > VIN The reference voltage input to VREF pin must be set between AVss and AVcc. The compare reference voltage V,ef depends on the value in the successive approximation register. Table 2.10.6 shows the relationship between V,ef and the value in the successive approximation register. Table 2.10.6 Relationship between successive approximation register and V,ef Content of successive approximation register 0 1 to 255 VREF/256 X (n-0.5) Comparison reference voltage V,ef (V) o n : The content of the successive approximation register Step ® above is repeated for all bits from bit 7 to bit 0 and the value in the successive approximation register (digital equivalent of the analog input voltage) is stored in the A-O register when comparison of bit 0 completes. Table 2.10.7 shows the change in the successive approximation register and compare voltage during A·D conversion. 152 FUNCTIONAL DESCRIPTION 2.10 A-O converter Table 2.10.7 Change In successive approximation register and compare voltage during A-O con- version Successive approximation register Compare voltage Vref b7 bO Conversion start 10101010101010101 o[V] +:.;~. First comparison 11 I 0 I 0 I 0 I 0 I 0 I 0 1 0 1 VREF VREF ""2 - 512 [V] + Second comparison I n711 I 0 I 0 I 0 I 0 I 0 I 0 I VREF ± VREF _ VREF 2 4 512 [V] ~ \ 1st comparison result VREF + VREF + VREF _ VREF Third comparison 1 n7 1 n6 I 1 I 0 I 0 I 0 I 0 I 0 I 2 - 4 - 8 512 [V] n .m \2nd comparison result ..... .·.·.1 I:-'''t = = yr :-:. ::'.:' = = Eighth comparison I n71 n61 n51 n41 n31 n21 n, 11 I + Conversion completed Iml~lrul~I~I~lrul~1 153 FUNCTIONAL DESCRIPTION 2.10 A-D converter 2.10.4 A-D conversion mode Four different A-D conversion modes can be selected with the A-D mode selection bits. In each mode, the trigger selection bit is used to determine whether to use a software trigger (internal trigger) or an external input signal (external trigger). Error is magnified if the input voltage to the analog input pin changes during A-D conversion. Make sure the input voltage to the analog input pin does not change during the A-D conversion interval which is rpAD x 57 cycles (rpAD is f(XIN)/8 or f(XIN)/4) per pin. Each conversion mode is described below for case selecting an internal trigger and an external trigger. (1) One-shot mode [A-D control register bits 4, 3="00"] In one-shot mode, the input voltage to the one analog input pin selected with the analog input selection bits is converted and an A-D interrupt request occurs when conversion completes. The analog input pin must be selected before generating the trigger. Pins not selected as analog input pin can be used as normal I/O ports . • When an internal trigger is selected to start A-D conversion When the A-D conversion start flag is set to "1 ", an internal trigger is generated and A-D conversion starts. After 57 cycles of rpAD, A-D conversion completes, the content of the successive approximation register (converted result) is transferred to the A-D register. At the same time, the A-D interrupt request occurs and the A-D interrupt request bit is set to "1 ". Then the A-D conversion start flag is cleared to "0" and A-D converter operation stops . • When an external trigger is selected to start A-D conversion A-D conversion starts when the input level of the ADTRG pin changes from "H" to "L" (falling edge) while the A-D conversion start flag is set to "1" . When A-D conversion completes after 57 cycles of rpAD, the content of the successive approximation register (converted result) is transferred to the A-D register. At the same time, the A-D interrupt request occurs and the A-D interrupt request bit is set to "1". At this point, the A-D conversion start flag remains "1". Therefore A-D conversion can be repeated by generating another trigger. A trigger can also be generated during A-D conversion. 154 FUNCTIONAL DESCRIPTION 2.10 A-O converter (2) Repeat mode [A·O control register bits 4, 3="01"] In repeat mode, the input voltage to the one analog input pin selected with the analog input selection bits is repeatedly converted. No interrupt request occur and the A-O conversion start flag is not cleared to "0" automatically. The conversion of the selected pin is repeated while the A-O conversion start flag is "1". The analog input pin must be selected before generating the trigger. Pins not selected as analog input pin can be used as normal 1/0 ports . • When an internal trigger is selected to start A-O conversion When the A-D conversion start flag is set to "1", an internal trigger is generated and A-O conversion starts. Each time an A-D conversion completes, the content of the successive approximation register (converted result) is transferred to the A-D register. The A-O converter does not stop at this point and conversion is repeated . • When an external trigger is selected to start A-O conversion A-O conversion starts when the input level of the ADTRG pin changes from "H" to "L" (falling edge) while the A-O conversion start flag is set to "1". Each time an A-O conversion completes, the content of the successive approximation register (conversion result) is transferred to the A-O register. The A-D con- verter does not stop at this point and conversion is repeated. 155 FUNCTIONAL DESCRIPTION 2.10 A-O converter (3) Single sweep mode [A-D control register bits 4, 3="10"] In single sweep mode, multiple analog input pins can be converted. The analog input pins are selected by bits 0 and 1 of the A-O sweep pin selection register (address 1F16) shown in Figure 2.10.6. The number of analog input pins can be selected among either 2, 4, 6, or 8 pins. The analog input pins must be selected before generating the trigger. A-O conversion is performed only for the input voltage of the selected input pins. An A-O interrupt request occurs and the A-O interrupt request bit is set to "1" when all selected pins are converted. The analog input selection bits in the A-O control register are ignored in this mode. b6 b5 b4 b3 b2 b1 bO A·D sweep pin selection register (address 1 F16) '----'--- A-O sweep pin selection bits 00 : ANa, AN1 (2 pins) 01 : ANa to AN3 (4 pins) 10 : ANa to AN5 (6 pins) 11 : ANa to AN? (8 pins) Note: Bits 0 and 1 are set to "1" at reset and ANa to AN? pins are selected for analog input 'pins. Bits 2 to 7 are undefined at reading, , Fig. 2.10.6 A·D sweep pin selection register structure .When an internal trigger is selected to start A·D conversion When the A-O conversion start flag is set to "1 ", an internal trigger is generated and A-O conversion of the ANa pin starts. After the ANa pin is converted, the selected analog input pins are converted in sequence. The converted result is transferred from the successive approximation register to the cor- responding A-O register each time a pin is converted. When all of the selected pins are converted, an A-O interrupt request is generated and the interrupt request bit is set to "1 ". At this point, the A-O conversion start flag is cleared and the A-D converter stops . • When an external trigger is selected to start A-D conversion The selected pins are converted in order starting from the ANa pin similar to selecting an internal trigger when the input level of the AOTRG pin changes from "H" to "L" (falling edge) while the A-O conversion start flag is set to "1" . The converted result is transferred from the successive approximation register to the corresponding A-O register each time a pin is converted. When all of the selected pins are converted, an A-O interrupt request occurs and the interrupt request bit is set to "1 ". At this point, the, A-O conversion start flag maintains "1 ". Therefore, A-O conversion can be repeated from the ANa pin by generating another trigger. A trigger can also be generated during A-O conversion. 156 FUNCTIONAL DESCRIPTION 2.10 A-O converter (4) Repeat sweep mode [A·D control register bits 4, 3="11"] I' In repeat sweep mode, the A-D sweep pin selection register can be used to select multiple analog input pins to be converted as with single sweep mode. Conversion is performed in order from the ANa .I pin. After converting ali selected pins, A-D converter does not stop, but repeats conversion from the I ANa pin. No A-D interrupt request occur when all selected pins are converted. The analog input selection bits in the A-D control register are ignored in this mode . • When an internal trigger is selected to start A·D conversion When the A-D conversion start flag is set to "1 ", an internal trigger is generated and A-D conversion starts from the ANa pin. After the ANa pin is converted, the selected analog input pins are converted in sequence. The converted result is transferred from the successive approximation register to the corresponding A-O register each time a pin is converted. When all of the selected pins are converted, conversion is repeated from the ANa pin. Conversion is repeated until the A-O conversion start flag is cleared to "0" . • When an external trigger is selected to start A-D conversion The selected pins are converted in order starting from the ANa pin similar to selecting an internal trigger when the input level of the AOTRG pin changes from "H" to "L" (falling edge) while the A-O conversion start flag is set to "1" . The converted result is transferred from the successive approximation register to the corresponding A-O register each time a pin is converted. Conversion is repeated until the A-O conversion start flag is cleared to "0". [Precautions when using an A-D converter] 1. Analog input pins must be selected (with analog input selection bits of A-O control register and A-O sweep pin selection register) before internal or external trigger is generated. 2. The port P7 direction register bit corresponding to the pin selected as analog input pin and external trigger input pin (port P77) must be set to "0" (input mode). 3. When an external trigger is selected, port P77 functions as ADTRG pin. If at the same time, AN7 pin is selected as the analog input, the external trigger input signal is converted and the converted result is transferred to A-O register 7. 157 FUNCTIONAL DESCRIPTION 2.11 Watchdog timer 2.11 Watchdog timer The watchdog timer is a 12-bit timer that is used to detect unexpected execution sequence caused by software run-away. It is also used to stabilize the oscillator when returning from the STP instruction. Figure 2.11.1 shows the block diagram of the watchdog timer. Frequency selection (forced to b during STP instruction execution) Watchdog timer (Address 6016) Set FFF16 Write to watchdog timer - - - - - - - , 2Vcc RESET o--.e..,detection circuit STP instruction S Q R Fig. 2.11.1 Watchdog timer block diagram 158 FUNCTIONAL DESCRIPTION 2.11 Watchdog timer 2.11.1 Operation description The watchdog timer (address 6016) consists of 12 bits and its content is decremented by 1 each time the clock selected with the watchdog timer frequency selection flag (bit 0 at address 6116) is input to the watchdog timer. The watchdog timer frequency selection flag is set to 0 at reset, and f512 (source oscillating frequency f(XIN) divided by 512) is selected as the watchdog timer count source after reset. Thereafter, it can also be set to 132 (source oscillating frequency f(xlN) divided by 32) by changing the watchdog timer frequency selection flag by program. Figure 2.11.2 shows the structure of the watchdog timer frequency selection flag. When there is a reset, "FFF16" is set in the watchdog timer. Then the count source f512 is counted after reset. The content of the watchdog timer is decremented by 1 each time a clock is input. An interrupt request occurs when the most significant bit of the watchdog timer becomes "0" after 2048 counts. The watchdog timer interrupt is a non-maskable interrupt with the highest priority. Processor interrupt priority level (IPL) is set to level 7 when accepting the interrupt. An arbitrary value cannot be set in the watchdog timer. A value "FFF16" is automatically set in the watchdog timer when there is a reset, when the STP instruction is executed, or when a writing operation is performed in the watchdog timer. The watchdog timer is a write-only register and its content is undefined at reading. The watchdog timer is in Hold state and the clock input of the watchdog timer is disabled while "L" level is applied to the HOLD pin (in Hold state). When using the watchdog timer to detect program run-away, the program must write to the watchdog timer before its most significant bit becomes "0". Then if this code is not executed due to program run-away, the most significant bit of the watchdog timer becomes "0" and an interrupt is generated. Thereafter, the control should be passed to the interrupt service routine. To restart from reset after detecting a program run-away, bit 3 of the processor mode register (software reset bit) must be set to "1" in the watchdog timer interrupt service routine. In this way, a run-away program can be automatically reset and returned to normal routine. In addition to detecting program run-away, the watchdog timer is also used as a return timer from a stop mode (halting of oscillating circuit with the STP instruction). When the STP instruction is executed, the watchdog timer count source is forced to band "FFF16" is set in the watchdog timer. Then when the watchdog timer is started with an external interrupt and a watchdog timer interrupt request occurs, a supply of internal clock I/J starts. This is because some time is required for the oscillator to stabilize. See section "4.2 Clock generator" for more detail concerning the stop mode. In order to stop the watchdog timer (disable its function), twice of the Vee voltage must be applied to the RESET pin. During this time, the watchdog timer stops with "FFF16" set. b7 b6 b5 b4 b3 b2 b1 bO Watchdog timer frequency selection flag (address 6116) Watchdog timer frequency selection flag o : f512 selected 1 : 132 selected Note: Bits 1 to 7 are undefined at reading. Bit 0 is cleared to "0" at reset. Fig. 2.11.2 Watchdog timer frequency selection flag structure 159 FUNCTIONAL DESCRIPTION 2.12 Hold function 2.12 Hold function The microcomputer is in Hold state while "L" level is input to the HOLD pin (P4o) in memory expansion mode and microprocessor mode. Table 2.12.1 shows the status of the microcomputer during Hold. Input mode must be selected by setting the port P4 direction register bit 0 to "0". The HOLD input ("L" level input) to the HOLD pin is accepted at the falling edge of the internal clock I/> from "H" to "L" while the bus is unused. When the HOLD input is accepted, I/> CPU (CPU operating clock: f(XIN)/2) stops at "L" level, and E output stops at "H" level at the completion of the executing bus cycle. In addition, "L" level is output from the HLDA pin (P33) to indicate that the microcomputer is in Hold state. Ports PO to P2, P3o, and P31 are floated during Hold. These ports are floated atter one cycle of the internal clock I/> later than the HLDA pin changes from "H" level to "L" level. Only ¢ CPU is stopped during Hold. The oscillator is operating and other internal peripherals can be operating. However, the watchdog timer is stopped. Hold state can be removed by returning the HOLD pin to "H" level. In this case, HOLD input ("H" level input) is also accepted at the falling edge of the internal clock I/> from "H" to "L" while the bus is unused. At the removing of Hold state, these ports are removed from Hold state after one cycle of the internal clock I/> later than the HLDA pin changes from "L" level to "H" level. Figure 2.12.1 shows the timing example when the Hold. Table 2.12.1 Microcomputer status during Hold (in memory expansion and microprocessor mode) Parameter Status during Hold Oscillation Operating Internal clock I/> Operating Clock 1/>1 In memory expansion mode······Output when the processor mode register bit 7 is "1" In microprocessor mode······Always output I/> CPU Stopped at "L" level E output Stopped at "H" level Ports PO-P2, Floating P3o, P31 Port P32, Stopped at "L" level HLDA pin (P33) Ports P43-P47, -- Retain the status at inputting "L" level to the HOLD pin P5, P6, P7, P8 Watchdog timer Stopped 160 FUNCTIONAL DESCRIPTION 2.12 Hold function (a) HOLD input is performed when the bus is unused clock C AHAL =x 0000'6 X FFFE'6 X ADH,ADL >C DATA Not used ADH,ADL IPL, Vector address E LJ II I RIW"H" ¢ CPU: CPU clock AHAL: Low-order 16 bits of the CPU internal address Ap: High·order 8 bits of the CPU internal address OATA : CPU inte rnal data bus Fig. 3.1.1 Internal processing sequence after removing reset state 164 RESET 3.1 Reset 3.1.2 Internal status at reset Figure 3.1.2 shows the contents of internal registers immediately at reset. Register contents Address 416 0016 516 0016 816 0016 916 . :::j: .: ·;.1 .. . ·1· .. LI 0 0 o 0 Port P3 direction register 1 C16 0016 016 0016 1016 0016 1116 0016 Port P7 direction register ~----------------------------~ 1416 Port P8 direction register ~----------------------------~ 1 E16 0 1 0 1 0 1 0 1 0 1 ? 1 ? ? A-O control register 1 F16 H: ::L .:J::;.: I: ··1:1· I:: 1 1 1 A-O sweep pin selection register o_o_1_6____________---' UARTO transmit/receive mode register 3016 1-1______________ 3416 1:::1·: ::;; I:: oj: .. ;·1 1 0 0 o UARTO transmit/receive control register 0 35161 0 1 0 0 0 0 0 1 o UARTO transmit/receive control register 1 1 1 1 0016 3C16 .. :~ I: :I:::··r:; I 1 .. 0 0 3016 0 1 0 1 0 1 0 1 0 0 1 o UART1 transmit/receive control register 1 0016 4016 '--____________________________------'1 Count start flag o o lone-shot start flag 4416 ~_____________0_0_1_6_______________.J1 Up-down flag Fig. 3.1.2 Internal status at reset (1) 165 RESET 3.1 Reset Register contents Address 5616 0016 ITimer AO mode register 5716 0016 Timer Ai mode register 5816 0016 Timer A2 mode register 5916 0016 Timer A3 mode register 5A16 0016 Timer A4 mode register 5B16 0 0 1 I I0 0 0 0 Timer BO mode register 5C16 0 0 1 I I0 0 0 0 Timer B1 mode register 1 I~ 5D16 0 0 I0 0 0 0 Timer B2 mode register 5E16 0016 Processor mode register 60161 FFF 16 Watchdog timer (Note 1) 6116 I: I ·"1' :' ,I I I· :1 0 I Watchdog timer frequency selection flag ·1 ; ':.1" ,: I I 0 70161 7116 I' .. , "1;, . I· I 0 0 0 0 0 0 0 A-D conversion interrupt control register UARTO transmit interrupt control register 72161' I I 1 0 1 0 0 0 UARTO receive interrupt control register 73161 ' .I 74161· 'I ". .,' I I 0 I I0 0 0 0 0 0 0 UART1 transmit interrupt control register UART1 receive interrupt control register 7516 i "1 I:... 1 ·1 0 0 0 0 Timer AO interrupt control register 76161 I:' ;I: 1 I 0 0 0 0 Timer Ai interrupt control register 77161 "'1 I I 0 0 0 0 Timer A2 interrupt control register 78161 I· , I' I· 0 0 0 0 Timer A3 interrupt control register 79161· J I,: .' I 0 0 0 0 Timer A4 interrupt control register 7A16 I· :I l I I 0 .. a a 0 ITimer BO interrupt control register 78161 :I:. .: I·' : :l I 0 :- 0 0 0 I Timer 81 interrupt control register 7C161· ·1" I: ·.',1 'I 0 0 0 0 1 Timer 82 interrupt control register Fig. 3.1.2 Internal status at reset (2) 166 RESET 3.1 Reset Register contents Address 7D16 I· : .~;. ··1; ,~. ;!, I 0 0 0 0 0 0 IINTo interrupt control register I·· ',. '·1 7E16 I~· i::·:: .: ".: ;:. 0 0 0 0 0 0 IINT1 interrupt control register 7F16 1::-::; , I' ., :L :1 0 0 0 0 0 0 IINT2 interrupt control register Register contents 0016 Program bank register PG Contents of address FFFF16 Program counter (high-order) PCH Contents of address FFFE16 Program counter (low-order) PCl 0016 Data bank register DT ~----------------------------~ 0016 Direct page register (high-order) DPRH 0016 Direct page register (low-order) DPRl b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 bO Processor status register PS 1[l°~I?I?IOIOIOI11?1? I (High-order 4 bits are 0 at reading) IPL N V m x D I Z C ~ Undefined at reset D Not allocated and undefined at reset (Note:Port P3 direction register bits 4 to 7 are "0" at reading.) Note 1. Watchdog timer is set to FFF 16 at reset. Note 2.The contents of registers and RAM other than those described in Figure 3.1.2 are undefined at reset. Fig. 3.1.2 Internal status at reset (3) 167 RESET 3.1 Reset 3.1.3 Bus state during reset in microprocessor mode Table 3.1.1 shows the state of the address bus, data bus, and control bus during reset ("L" level is applied to RESET pin) for Mask ROM version and PROM version models in microprocessor mode, and for external ROM version models. Table 3.1.1 Bus state during reset for Mask ROM version and PROM version In microprocessor mode and for external ROM version Model Address bus, data bus, control bus state Mask ROM version Ports PO, P1, P2 Address output ("H" or "L" level) External ROM version E, Port P30 (R/W) "H" level output Port P31(SHE) "H" or "L" level output (depends on address output) Port P32 (ALE) "L" level output Port P42(iJl1 Clock ¢1 output PROM version Ports PO, P1, P2 When "H" level is applied to either or both pins P51 and P52; .Ports PO, P1, P2 ........... floating When "L" level is applied to pins P51 and P52; .Ports PO, P1 .................. floating .Port P2 ........................... data output E, Port P30 (RIW) "H" level output Port P31 (SHE) "H" level or "L" level output Port P32 (ALE) "L" level output Port P42 (¢1) Clock ¢1 output 168 RESET 3.2 Reset circuit 3.2 Reset circuit The reset circuit must be designed so that the reset input voltage drops below O.9V when the source voltage reaches 4.5V as shown in Figure 3.2.1. Figure 3.2.2 shows the example of power-on reset circuit using a system reset Ie M51957AL. 4.5V Vcc Ov---:r RESET ov-----r--- Fig. 3.2.1 Power·on reset condition 5V M37702 1 M51957AL Vee Vt;<; 27kQ ~-_2=-1IN OUT·f-05=----------t RESET 4 47Q 10kQ Delay capacity 1--_-" VS$ 3 SW ~I~ In case of Cd=O.033flF, the dalay time td is about 11 ms. GND td=O.34XCd [flSJ, Cd: [pF 1 Fig. 3.2.2 Power·on reset circuit example 169 RESET 3.3 Software reset 3.3 Software reset The M37702 group can be reset internally by program. Software reset is generated by writing "1" to the processor mode register bit 3. Figure 3.3.1 shows the structure of the processor mode register. Software reset is the same as hardware reset (when the RESET pin level is returned to "H" after applying ilL" level) except that the contents of the internal RAM are preserved. Therefore, the contents of each register after software reset is initialized to values shown in Figure 3.1.2. b7 b6 b5 b4 b3 b2 b1 bO I 101 R/W R/wl R/wl W I I I I R/W R/W R/W Processpr mode register (address 5E16) I I Processor mode bits 00 : Single-chip mode 01 : Memory expansion mode 10 : Microprocessor mode 11 : This can not available. ' - - - - - - - Wait bit o : Wait during external access 1 : No wait ' - - - - - - - - - Software reset bit 1 : Software reset activated by writing "1" ' - - - - ' - - - - - - - - - - - - Interrupt priority detection time selection bits 00 : 7 cycles at internal clock IP 01 : 4 cycles at internal clock IP 10 : 2 cycles at internal clock IP 11 This can not available. '-----------------11 Fix this bit to "0". I ' - - - - - - - - - - - - - - - - - - Clock 1/11 output selection bit o : 1/11 output disabled (Port P42 functions as normal I/O port.) : 1/11 output enabled (Port P42 functions as only 1/11 output pin.) Note: Bit 3 is a write-only bit. This register is cleared to "0016" at reset. Fig. 3.3.1 Processor mode register structure 170 © [)={]~ [F)u~ [R1 ~ OSC~llATING C~RCUIT 4.1 Oscillating circuit 4.2 Clock generator v OSCILLATING CIRCUIT 4.1 Oscillating circuit 4.1 Oscillating circuit , The M37702 group is equipped with an oscillating circuit to generate the necessary clock. The frequency input to the clock input pin XIN is divided in half to obtain the internal clock cpo This cp is further divided in half to obtain the bus cycle. Either a ceramic resonator or a crystal resonator can be connected externally to the internal oscillating circuit. 4.1.1 Circuit using a ceramic resonator or a crystal resonator Figure 4.1.1 shows the circuit example using a ce- M37702M2-XXXFP ramic resonator and Figure 4.1.2 shows the circuit example using a crystal resonator. An oscillating circuit is formed by connecting the resonator be- tween XIN pin and XOUT pin as shown in the figures. The circuit constants such as RI......8..d.....IN. and COUT must be set to the resonator manufacturer's recom- mended values. 4.1.2 External clock input circuit JrCOUT An external clock signal can be supplied to the internal oscillating circuit. Figure 4.1.3 shows the circuit example of external clock input. Note that the ex- Fig. 4.1.1 Oscillating circuit using a ceramic resonator ternal clock must be input from XIN pin, and XOUT pin must be left open. M37702M2-XXXFP XIN XOUT A RI v IDI I I CIN - - -'-COUT J,- Jr Fig. 4.1.2 Oscillating circuit using a crystal resonator M37702M2-XXXFP XOUT Open External oscillating circuit Vee --, n n r- Vss L.J L.J L.J Fig. 4.1.3 External clock input circuit 172 OSCILLATING CIRCUIT 4.2 Clock generator 4.2 Clock generator The oscillating circuit consists of oscillating gate which functions as an amplifier to obtain the necessary gain and oscillation control flip-flop to control this amplifier. Therefore, oscillation can be stopped and restarted as necessary. The clock generation circuit shown in Figure 4.2.1 is built in the M37702 group. When the STP instruction is executed, the internal clock if! stops oscillation at the "L" state. At the same time, FFF16 is set in the watchdog timer and the input to the watchdog timer is connected to h2. This connection is cancelled and connected to the input determined by the content of the watchdog timer frequency selection flag when the most significant bit of the watchdog timer becomes "0" or when there is a reset. Oscillation is resumed when an interrupt is accepted, but the internal clock if! remains at "L" level until the most sig- nificant bit of the watchdog timer becomes "0". This is done to avoid the initial unstable interval when using a ceramic resonator. When the WIT instruction is executed, the internal clock if! stops at the "L" state, but the oscillator does not stop. Therefore, the timer, serial 1/0, and A-O converter can be used. The stopping of internal clock if! is cancelled when an interrupt is accepted. An instruction can be executed immediately because the oscillator does not stop. Refer to "Appendix 4. Stop, wait, one-wait, Ready, and Hold state" and "MELPS 7700 SOFTWARE MANUAL" for information concerning the STP and WIT instructions. Interrupt s o s o o Reset request STP R WIT R R STP instruction instruction '--_--' instruction f512 XIN XOUT Fig. 4.2.1 Clock generation circuit block diagram 173 OSCILLATING CIRCUIT 4.2 Clock generator MEMO 174 ©[}={] ffi\ ~ y ~ [R1 ~ ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics 5.1 Electrical characteristics 5.1.1 Absolute maximum ratings Absolute maximum ratings Symbol Parameter Conditions Ratings Unit Vee Supply voltage -0.3 to 7 V AVec Analog supply voltage -0.3 to 7 V VI Input voltage RESET, CNVss, BYTE -0.3 to 12 V VI Input voltage POo-P07, P1o-P17, P2o-P27, P3o-P33, -0.3 to Vee+0.3 V P4o-P47, P5o-P57, P6o-P67, P7o-P77, P8o-P87, VREF, XIN Vo Output voltage POo-P07, P1o-P17, P2o-P27, P3o-P33, -0.3 to Vee+0.3 V P4o-P47, P5o-P57, P6o-P67, P7o-P77, P8o-P87, XOUT, E Pd Power dissipation Ta=25°C 300 mW Topr Operating temperature -20 to 85 °C Tstg Storage temperature -40 to 150 °C 176 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics 5.1.2 Recommended operating conditions Recommended operating conditions (Vee=5V±1 0%, Ta=-20 to S5°C, unless otherwise noted) Limits Symbol Parameter Min. Typ. Max. Unit Vee Supply voltage 4.5 5.0 5.5 V AVec Analog supply voltage Vee V Vss Supply voltage 0 V AVss Analog supply voltage 0 V VIH High-level input voltage POo-P07, P3o-P33, P4o-P47, O.SVee Vee V P5o-P57, P6o-P67, P7o-P77, PSO-PS7, XIN, RESET, CNVss, BYTE VIH High-level input voltage P1o-P17, P2o-P27 O.SVee Vee V (in single-chip mode) VIH High-level input voltage P1o-P17, P2o-P27 0.5Vee Vee V (in memory expansion mode and microprocessor mode) VIL Low-level input voltage POo-P07, P3o-P33, P4o-P47, 0 0.2Vee V P5o-P57, P6o-P67, P7o-P77, P8o-PS7, XIN, RESET, CNVss, BYTE VIL Low-level input voltage P1o-P17, P2o-P27 0 0.2Vee V (in single-chip mode) VIL Low-level input voltage P1o-P17, P2o-P27 0 0.16Vee V (in memory expansion mode and microprocessor mode) IOH (peak) High-level peak output current POO-P07, P1o-P17, P2o-P27, -10 rnA P3o-P33, P4o-P47, P5o-P57, P6o-P67, P7o-P77, PSo-P87 IOH (av9) High-level average output current POo-P07, P1o-P17, P2o-P27, -5 mA P30-P33, P4o-P47, P5o-P57, P6o-P67, P7o-P77, PSo-PS7 IOL (peak) Low-level peak output current POO-P07, P1o-P17, P2o-P27, 10 mA P3o-P33, P4o-P47, ,P5o-P57, P6o-P67, P7o-P77, PSo-PS7 IOL (avg) Low-level average output current POo-P07, P1o-P17, P2o-P27, 5 mA P3o-P33, P4o-P47, P5o-P57, P6o-P67, P7o-P77, PSo-PS7 f(XIN) External clock frequency input M37702M2-XXXFP, M37702S1 FP S MHz M37702M2AXXXFP,M37702S1AFP 16 M37702M2BXXXFP,M37702S1BFP 25 Note 1. Average output current is the average value of a 100ms interval. 2. The sum of IOL(peak) for ports PO, P1, P2, P3, and PS must be SOmA or less, the sum of IOH(peak) for ports PO, P1, P2, P3, and PS must be SOmA or less, the sum of IOL(peak) for ports P4, P5, P6, and P7 must be 80mA or less, and the sum of IOH(peak) for ports P4, P5, P6, and P7 must be SOmA or less. 177 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics 5.1.3 Electrical characteristics and A·D converter characteristics M37702M2·XXXFP Electrical characteristics (Vcc=5V, Vss=OV, Ta=25°C, f(XIN)=8MHz , unless otherwise noted) Limits Symbol Parameter Test conditions Unit Min. Typ. Max. VOH High-level output voltage POo-POl, Pl o-P17, P2o-P2l, IOH=-10mA 3 V P3o, P31, P33, P4o-P4l, P5o-P5l, P6o-P6l, P7o-P7l, P8o-P8l VOH High-level output voltage POo-POl, Plo-P17, P2o-P2l, IOH=-400j.iA 4.7 V P3o, P31, P33 VOH High-level output voltage P32 IOH=-10mA 3.1 V IOH=-400IlA 4.8 VOH High-level output voltage E IOH=-10mA 3.4 V IOH=-400IlA 4.8 VOL Low-level output voltage POo-POl, Pl o-P17, P2o-P27, IOL=10mA 2 V P3o, P31, P33, P4o-P47, P5o-P5l, P6o-P67, P7o-P77, P8o-P87 VOL Low·level output voltage POo-POl, Pl o-P17, P2o-P2l, IOL=2mA 0.45 V P3o, P31, P33 VOL Low-level output voltage P32 IOL=10mA 1.9 V IOL=2mA 0.43 VOL Low-level output voltage E IOL=10mA 1.6 V IOL=2mA 0.4 VT+-VT- Hysteresis HOLD, ROY, TAOIN-TA4IN, TBOIN-TB2IN, 0.4 1 V INTo-INT2, ADTRG, CTSo, CTS1, CLKo, ClKl VT+-VT- Hysteresis RESET 0.2 0.5 V VT+-VT- Hysteresis XIN 0.1 0.3 V IiH High-level input current POo-P07, P1o-P 17, P2o-P2l, VI=5V 5 j.iA P3o-P33, P4o-P4l, P5o-P5l, P6o-P6l, P7o-P7l, P8o-P8l, XIN, RESET, CNVss, BYTE IiL Low-level input current POo-POl, Plo-P17, P2o-P2l, VI=OV -5 j.iA P3o-P33, P4o-P4l, P5o-P57, P6o-P6l, P7o-P7l, P8o-P87, XIN, RESET, CNVss, BYTE VRAM RAM hold voltage When clock is stopped. 2 V Icc Power supply current In single-chip f(XIN)~8MHz, 6 12 mA mode output square waveform only pin is Ta~25°C when 1 j.iA open and other clock is stopped. pins are Vss Ta~85°C when 20 during reset. clock is stopped. A·D converter characteristics (Vcc=5V, Vss=OV, Ta=25°C, f(XIN)=8MHz, unless otherwise noted) Limits Symbol Parameter Test conditions Unit Min. Typ. Max. - Resolution VREF=Vec 8 Bits - Absolute accuracy VREF=Vee ±3 LSB RLADDER Ladder resistance VREF=Vce 2 10 kQ teoNV Conversion time 28.5 IlS VREF Reference voltage 2 Vee V VIA Analog input voltage 0 VREF V 178 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics M37702M2AXXXFP Electrical characteristics (Vcc=5V, Vss=OV, Ta=25°C, f(XIN)=16MHz, unless otherwise noted) Limits Symbol Parameter Test conditions Unit Min. Typ. Max. VOH High-level output voltage POo-POl, P1 o-P17, P2o-P2l, IOH=-10mA 3 V P3o, P31, P33, P4o-P4l, P5o-P5l, P6o-P6l, P7o-P7l, P8o-P8l VOH High-level output voltage POo-POl, P1 o-P17, P2o-P2l, IOH=-400IlA 4.7 V P3o, P31, P33 VOH High-level output voltage P32 IOH=-10mA 3.1 V IOH=-4OOIlA 4.8 VOH High-level output voltage E IOH=-10mA 3.4 V IOH=-400IlA 4.8 VOL Low-level output voltage POo-POl, P1o-P17, P2o-P2l, IOL=10mA 2 V P3o, P31, P33, P4o-P4l, P5o-P5l, P6o-P6l, P7o-P7l, P8o-P8l VOL Low-level output voltage POo-POl, P1 o-P17, P2o-P2l, IOL=2mA 0.45 V P3o, P31, P33 VOL Low-level output voltage P32 IOL=10mA 1.9 V IOL=2mA 0.43 VOL Low-level output voltage E IOL=10mA 1.6 V IOL=2mA 0.4 VT+-VT- Hysteresis HOLD, ROY, TAOIN-TMiN, TBOIN-TB21N, 0.4 1 V INTo-INT2, ADTRG, CTSo, CTS1, CLKo, CLK1 VT+-VT- Hysteresis RESET 0.2 0.5 V VT+-VT- Hysteresis XIN 0.1 0.3 V IIH High-level input current POo-POl, P1 o-P17, P2o-P2l, VI=5V 5 j.tA P3o-P33, P4o-P4l, P5o-P5l, P6o-P6l, P7o-P7l, P8o-P8l, XIN, RESET, CNVss, BYTE ilL Low-level input current POo-POl, P1 o-P17, P2o-P2l, VI=OV -5 j.tA P3o-P33, P4o-P4l, P5o-P5l, P6o-P6l, P7o-P7l, P8o-P8l, XIN, RESET, CNVss, BYTE VRAM RAM hold voltage When clock is stopped. 2 V Icc Power supply current In single-chip f(XIN)=16MHz, 12 24 mA mode output square waveform only pin is Ta=25°C when 1 j.tA open and other clock is stopped. pins are Vss Ta=85°C when 20 during reset. clock is stopped. A·D converter characteristics (Vce=5V , Vss=OV , Ta=25°C , f(XIN)=16MHz , unless otherwise noted) Limits Symbol Parameter Test conditions Unit Min. Typ. Max. - Resolution VREF=Vee 8 Bits - Absolute accuracy VREF=Vee +3 LSB RLADDER Ladder resistance VREF=Vec 2 10 kQ teoNV Conversion time 14.25 Ils VREF Reference voltage 2 Vee V VIA Analog input voltage ,\ 0 VREF V 179 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics M37702M2BXXXFP Electrical characteristics (Vcc=5V, Vss=OV, Ta=25°C, f(XIN)=25MHz, unless otherwise noted) Limits Symbol Parameter Test conditions Unit Min. Typ. Max. VOH High-level output voltage POo-P07, P1 o-P17, P2o-P27, IOH=-10mA 3 V P3o, P31, P33, P4o-P47, P5o-P57, P6o-P67, P7o-P77, P8o-P87 VOH High-level output voltage POo-P07, P1 o-P17, P2o-P27, IOH=-400IlA 4.7 V P3o, P31, P33 VOH High-level output voltage P32 IOH=-10mA 3.1 V IOH=-400IlA 4.8 VOH High-level output voltage E IOH=-10mA 3.4 V IOH=-400IlA 4.8 VOL low-level output voltage POo-P07, P1 o-P17, P2o-P27, IOL=10mA 2 V P3o, P31, P33, P4o-P47, PSo-PS7, P6o-P67, P7o-P77, P8o-P87 VOL low-level output voltage POo-P07, P1 o-P17, P2o-P27, IOL=2mA 0.45 V P3o, P31, P33 VOL low-level output voltage P32 IOL=10mA 1.9 V IOL=2mA 0.43 VOL low-level output voltage E IOL=10mA 1.6 V IOL=2mA 0.4 VT+-VT- Hysteresis HOLD, RDY, TAOIN-TMiN, TBOIN-TB2IN, 0.4 1 V INTo-INT2, ADTRG, CTSo, CTS1, ClKo, ClK, VT+-VT- Hysteresis RESET 0.2 0.5 V VT+-VT- Hysteresis XIN 0.1 0.3 V IIH High-level input current POo-P07, P1 o-P17, P2o-P27, VI=5V 5 IlA P3o-P33, P4o-P47, P5o-P57, P6o-P67, P7o-P77, P8o-P87, XIN, RESET, CNVss, BYTE ilL low-level input current POo-P07, P1o-P17, P2o-P27, VI=OV -5 IlA P3o-P33, P4o-P47, P5o-P57, P6o-P67, P7o-P77, P8o-P87, XIN, RESET, CNVss, BYTE VRAM RAM hold voltage When clock is stopped. 2 V Icc Power supply current In single-chip f(XIN)=2SMHz, 19 38 rnA mode output square waveform only pin is Ta=2SoC when 1 IlA open and other clock is stopped. pins are Vss Ta=85°C when 20 during reset. clock is stopped. A-D converter characteristics (Vcc=5V, Vss=OV, Ta=25°C, f(XIN)=25MHz, unless otherwise noted) Limits Symbol Parameter Test conditions Unit Min. Typ. Max. - Resolution VREF=VCC 8 Bits - Absolute accuracy VREF=VCC ±3 LSB RLADDER Ladder resistance VREF=VCC 2 10 kQ tcoNV Conversion time 9.12 ).ls VREF Reference voltage 2 Vce V VIA Analog input voltage 0 VREF V 180 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics 5.1.4 Timing requirements Timing requiements (Vee=5V±10%, Vss=OV, Ta=25°C, unless otherwise noted) External clock input Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. te External clock input cycle time 125 62 40 ns tW(H) External cloCk input high-level pulse width 50 25 15 ns tW(L) External clock input lOW-level pulse width 50 25 15 ns t, External clock rise time 20 10 8 ns tf External clock fall time 20 10 8 ns S ingle-c h"IP mo d e Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tSU(POD-E) Port PO input setup time 200 100 60 ns tSU(P1D-E) Port Pi input setup time 200 100 60 ns tSU(P2D-E) Port P2 input setup time 200 100 60 ns tSU(P3D-E) Port P3 input setup time 200 100 60 ns tSU(P4D-E) Port P4 input setup time 200 100 60 ns tSU(P5D-E) Port P5 input setup time 200 100 60 ns tSU(P6D-E) Port P6 input setup time 200 100 60 ns tSU(P7D-E) Port P7 input setup time 200 100 60 ns tSU(P8D-E) Port P8 input setup time 200 100 60 ns th(E-POD) Port PO input hold time 0 0 0 ns th(E-P1D) Port Pi input hold time 0 0 0 ns th(E-P2D) Port P2 input hold time 0 0 0 ns th(E-P3D) Port P3 input hold time 0 0 0 ns th(E-P4D) Port P4 input hold time 0 0 0 ns th(E-P5D) Port P5 input hold time 0 0 0 ns th(E-P6D) Port P6 input hold time 0 0 0 ns h(E-P7D) Port P7 input hold time 0 0 0 ns th(E-P8D) Port P8 input hold time 0 0 0 ns Memory expansion mode and microprocessor mode Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tSU(P1D-E) Port Pi input setup time 60 45 30 ns tSU(P2D-E) Port P2 input setup time 60 45 30 ns tSU(RDY~) ROY input setup time 70 60 55 ns tSU(HOL~) HOLD input setup time 70 60 55 ns th(E-P1D) Port Pi input hold time 0 0 0 ns .th(E-P2D) Port P2 input hold time 0 0 0 ns th(~-RDY) ROY input hold time 0 0 0 ns th(~-HOLD) HOLD input hold time 0 0 0 ns 181 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics Timer A input (count input in event counter mode) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. te(TA) TAilN input cycle time 250 125 80 ns tW(TAH) TAilN input high-level pulse width 125 62 40 ns tW(TAL) TAilN input low-level pulse width 125 62 40 ns Timer A input (gating input in timer mode) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tC(TA) T AilN input cycle time 1000 500 320 ns tW(TAH) TAilN input high-level pulse width 500 250 160 ns tW(TAL) TAilN input low-level pulse width 500 250 160 ns Timer A input (external trigger input in one-shot pulse mode) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tC(TA) T Ai IN input cycle time 500 250 160 ns tW(TAH) TAilN input high-level pulse width 250 125 80 ns tW(TAL) TAilN input low-level pulse width 250 125 80 ns Timer A input (external trigger input in pulse width modulation mode) Limits Syinbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tW(TAH) TAilN input high-level pulse width 250 125 80 ns tW(TAL) TAilN input low-level pulse width 250 125 80 ns Timer A input (up-down input in event counter mode) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tc(uP) TAiouT input cycle time 5000 2500 2000 ns tW(UPH) TAiouT input high-level pulse width 2500 1250 1000 ns tW(UPL) TAiouT input low-level pulse width 2500 1250 1000 ns tsU(UP-TIN) T AioUT input setup time 1000 500 400 ns th(T",-UP) TAioUT input hold time 1000 500 400 ns Timer B input (count input in event counter mode) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tC(TB) TBilN input cycle time (one edge count) 250 125 80 ns tW(TBH) TBilN input high-level pulse width (one edge count) 125 62 40 ns tW(TBL) TBilN input low-level pulse width (one edge count) 125 62 40 ns tC(TB) TBilN input cycle time (both edges count) 500 250 160 ns tW(TBH) TBilN input high-level pulse width (both edges count) 250 125 80 ns tW(TBL) TBilN input low-level pulse width (both edges count) 250 125 80 ns 182 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics Timer B input (pulse period measurement mode) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tC(TB) TBiiN input cycle time 1000 500 320 ns tW(TBH) TBilN input high-level pulse width 500 250 160 ns tW(TBL) TBiiN input low-level pulse width 500 250 160 ns Timer B input (pulse width measurement mode) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tC(TB) TBiiN input cycle time 1000 500 320 ns tW(TBH) TBilN input high-level pulse width 500 250 160 ns tW(TBL) TBilN input low-level pulse width 500 250 160 ns A·D trigger input Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tC(AD) ADTRG input cycle time (minimum allowable trigger) 2000 1000 1000 ns tW(ADL) ADTRG input low-level pulse width 250 125 125 ns Serial 110 Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tC(CK) elKI input cycle time 500 250 200 ns tW(CKH) elK; input high-level pulse width 250 125 100 ns tW(CKL) elKI input low-level pulse width 250 125 100 ns td(C-O) TxDI output delay time 150 90 80 ns th(C-O) TxDI hold time 30 30 30 ns tsU(D-C) RxDI hold time 60 30 20 ns th(C-D) RxDI input hold time 90 90 90 ns External Interrupt INTI input Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. tW(INH) INTi input high-level pulse width 250 250 250 ns tW(INL) INTi input low-level pulse width 250 250 250 ns 183 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics 5.1.5 Switching characteristics Switching characteristics (Vcc=5V±10%, Vss=OV, Ta=25°C, unless otherwise noted) Single·chip mode Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. td(E-POO) Port PO data output delay time 200 100 80 ns td(E-Pl0) Port P1 data output delay time 200 100 80 ns td(E-P20) Port P2 data output delay time' 200 100 80 ns td(E-P30) Port P3 data output delay time 200 100 80 ns td(E-P40) Port P4 data output delay time 200 100 80 ns td(E-PSO) Port P5 data output delay time 200 100 80 ns td(E-paO) Port P6 data output delay time 200 100 80 ns td(E-P70) Port P7 data output delay time 200 100 80 ns td(E-paO) Port P8 data output delay time 200 100 80 ns .. Note: Test conditions are shown In Figure 5.1.1 . Memory expansion mode and microprocessor mode (when wait bit is "1 ") Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. td(POA-E) Port PO address output delay time 100 30 12 ns td(E-Pl0) Port P1 data output delay time (BYTE="L") 110 70 45 ns tPXZ(E-P1Zj Port P1 floating start delay time (BYTE="L") 5 5 5 ns td(P1A-E) Port P1 address output delay time 100 30 12 ns td(P1A-ALE) Port P1 address output delay time 80 24 5 ns td(E-P20) Port P2 data output delay time 110 70 45 ns tPXZ(E-P2Z) Port P2 floating start delay time 5 5 5 ns td(P2A-E) Port P2 address output delay time 100 30 12 ns td(p2A-ALE) Port P2 address output delay time, 80 24 5 ns td(,,-HLDA) HLDA output delay time 100 50 50 ns td(ALE-E) ALE output delay time 4 4 4 ns tW(ALE) ALE pulse width 90 35 22 ns td(BHE-E) SHE output delCl,y time 100 30 20 ns td(RIW-E) R/W output delav time 100 30 20 ns td(E...,) I cPl output delay time 0 30 0 20 0 18 ns th(E-POA) Port PO address hold time 50 25 18 ns th(ALE-P1A) Port P1 address hold time (BYTE="L") 9 9 9 ns th(E-Pl0) Port P1 data hold time (BYTE="L") 50 25 18 ns tPZX(E-P1Zj Port P1 floating release delay time (BYTE="L") 50 25 18 ns th(E-P1A) Port P1 address hold time (BYTE="H") 50 25 18 ns th(ALE-P2A) Port P2 address hold time 9 9 9 ns th(E-P20) Port P2 data hold time 50 25 18 ns tPZX(E-P2Zj Port P2 floating release delay time 50 25 18 ns th(E-BHE) SHE hold time 18 18 18 ns th(E-RlW) R/W hold time 18 18 18 ns tW(EL) E pulse width 220 95 50 ns .. Note : Test conditions are shown In Figure 5.1.1 . 184 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics Memory expansion mode and microprocessor mode (when wait bit = "0", and external memory area accessed) Limits Symbol Parameter 8MHz 16MHz 25MHz Unit Min. Max. Min. Max. Min. Max. td(POA-E) Port PO address output delay time 100 30 12 ns td(E-PlO) Port P1 data output delay time (BYTE="L") 110 70 45 ns tPXZ(E-P1Z) Port P1 floating start delay time (BYTE="L") 5 5 5 ns td(P1A-E) Port P1 address output delay time 100 30 12 ns td(P1A-ALE) Port P1 address output delay time 80 24 5 ns td(E-P2Q) Port P2 data output delay time 110 70 45 ns tPXZ(E-P2Z) Port P2 floating start delay time 5 5 5 ns td(P2A-E) Port P2 address output delay time 100 30 12 ns td(P2A-ALE) Port P2 address output delay time 80 24 5 ns td(¢1-HLDA) HLDA output delay time 100 50 50 ns td(ALE-E) ALE output delay time 4 4 4 ns tW(ALE) ALE pulse width 90 35 22 ns td(BHE-E) BHE output delay time 100 30 20 ns td(RIW-E) R/W output delay time 100 30 20 ns td(E-¢1) 1/11 output delay time 0 30 0 20 0 18 ns th(E-POA) Port PO address hold time 50 25 18 ns th(ALE-P1A) Port P1 address hold time (BYTE="L") 9 9 9 ns th(E-P1Q) Port P1 data hold time (BYTE="L") 50 25 18 ns tPZX(E-P1Z) Port P1 floating release delay time (BYTE="L") 50 25 18 ns th(E-P1A) Port P1 address hold time (BYTE="H") 50 25 18 ns th(ALE-P2A) Port P2 address hold time 9 9 9 ns th(E-P2Q) Port P2 data hold time 50 25 18 ns tPZX(E-P2Z) Port P2 floating release delay time 50 25 18 ns th(E-BHE) BHE hold time 18 18 18 ns th(E-R/W) R/W hold time 18 18 18 ns tW(EL) E pulse width 470 220 130 ns .. Note: Test conditions are shown In Figure 5.1.1. PO P1 P2 P3 1 100pF P4 P5 P6 I P7 P8 ¢1 E Fig.5.1.1 Testing circuit for ports PO to P8, ¢1 185 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics 5.1.6 Equations for calculating the parameters Table 5.1.1 shows the equations for calculating the following parameters : tw(ALE) ....................... ALE pulse width td(R/W-E) ................... R/W output delay time tw(EL) .......................... E pulse width tpzx(E-PiZ) ................. Port Pi floating release delay time td(PiA-E) .................... Port Pi address output delay time th(E-PiQ) ..................... Port Pi data hold time (i=O to 2) td(BHE-E) ................... SHE output delay time td(PiA-ALE) ................ Port Pi address output delay time Table 5.1.1 Equations for calculating parameters ~Y Parameter 8MHz version 16MHz version 25MHz version tw(ALE) 1 X 109 1 X 109 1 X 109 - 35 -.27.5 - 18 f(XIN) f(XIN) f(XIN) tw(EL) 2 X 10 9 Wait bit = "1" f(XIN)< - 30 < tw(EL)--- 1----------- - - - - - - - - - - 1----------- 4 X 10 9 Wait bit = "0" f(XIN) - 30 ,. < < td(PiA-E) 2 X 109 12 + - 80 f(XIN) 2 X 109 2 X 10 9 td(BHE-E) 100 + - 250 30 + - 125 f(XIN) f(XIN) 2 X 109 td(R/W-E) 20 + - 80 f(XIN) tpzx(E-PiZ) 1 X 109 1 X 109 1 X 109 th(E-PiQ) 2 X f(XIN) - 12.5 2 X f(XIN) - 6.25 2 X f(XIN) - 2 td(PiA-ALE) 1 X 109 1 X 10 9 1 X 10 9 - 35 - 45 - 38.5 f(XIN) f(XIN) f(XIN) (Dimension In ns) 186 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics 5.1.7 Timing diagram Single-chip mode f(XIN) E Port PO output Port PO input Port P1 output Port P1 input Port P2 output Port P2 input Port P3 output Port P3 input Port P4 output Port P4 input Port P5 output Port P5 input Port P6 output Port P6 input Port P7 output Port P7 input Port P8 output Port P8 input 187 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics TAiiN input ~ ----~f I~m, \~----:-tW""(T-AL-) I tc(TA) _ _ _ _• , . - - - . \....._ _ _ _ __ TAioUT input -----f I~"W ~ I,,,"" \ I ~~ • - - - . \....._ _ _ _ __ TAioUT input (Up-down input) ) In event counter mode TAiiN input (When count by falling) th(TIN-UP) Isu(uP~TIN) TAiiN input \ (When count by rising) 1\ J I~'", l te(TB) TBiiN input { < tw(TBL) ~ \ ~ I,.oc, { te(AD) ADTRG input le(CK) t / tw(CKH) elKi / ~ tw(CKL) \ th(C-O) TxDi X K td(C-O) tsu(D--C) th(C-D) RxDi { 1 INTi input t I.,,", ll+--:_ _t-,-w(INH-,--) _~j,------,I ~ 188 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics Memory expansion mode and microprocessor mode (When wait bit="1 ") ,, r------------------------------------ RDY input su(RDY-¢11 th(¢1-RDYl (When wait bit="O") r------------------------------------ ,, RDY input tsu(RDY-¢11 th(¢1-RDYl (When wait bit="1" or "0" in common) tsu(HOLD-¢11 th(¢1-HOLDl HOLD input td(¢1-HLDA) _+--+~t::..::d(¢1-HLDA) HLDA output Test conditions -Vcc=5V±10% -Input timing voltage : VIL=1.0V, VIH=4.0V -Output timing voltage : VOL=0.8V, VOH=2.0V 189 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics Memory expansion mode and microprocessor mode (When wait bit="1") f(XIN) Port PO output (Ao-A7) Port P1 output (As-A,slDs-Dls) (BYTE="L'1 Port P1 output (As-A,s) (BYTE="H") Port P1 input Port P2 output (A, s-A23IDo-D7) Port P2 input Port P32 output (ALE) td(BHE-EI Port P3, output (BHE) td(RIW-EI Port P30 output (RIW) Test conditions ·Vcc=5V±10% ·Output timing voltage: VOL=0,8V, VOH=2.0V ·Ports P1, P2 input : VIL=0.8V, VIH=2.5V ·Port P4, input : VIL=1.0V, VIH=4.0V 190 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics Memory expansion mode and microprocessor mode (When wait bit="O", and external memory area is accessed) !p, E Port PO output (A<>-A7) Port P1 output (As-A,5IOs-O,s) (SYTE="L") Port P 1 output (As-A,.) (SYTE='H") Port P1 input Port P2 output (AIIl-A23iO<>-07) Port P2 input Port P32 output (ALE) td(BHE-EI th(E- BHE) Port P3, output (SHE) th(E- R/W) Port P30 output (R/W) Test conditions ·Vcc=5V±10% ·Output timing voltage: VOL=0.8V, VOH=2.0V ·Ports P1, P2 input : VIL=O.8V, VIH=2.5V ·Port P4, input : VIL=1.0V, VIH=4.0V 191 ELECTRICAL CHARACTERISTICS 5.1 Electrical characteristics MEMO 192 ©[}={]t%~u~[R1 ® STANDARD CHARACTERISTICS 6.1 Standard characteristics STANDARD CHARACTERISTICS 6.1 Standard characteristics 6.1 Standard characteristics The data described in this chapter are characteristic examples for M37702M2BXXXFP. The data is not guaranteed value. Refer to "Chapter 5. Electrical characteristics" for rated values. 6.1.1 Standard port characteristics (1) Programmable 110 port (CMOS output) P channel IOH-VoH characteristics Supply voltage Vcc=5V P channel 50.0 40.0 Ta-25°C « 30.0 .s :---... :c .2 Ta=85°C r-- r-.,' r--.... 20.0 1'-.,' i". ~ 10.0 ~ o '" ~ ~ 1.0 2.0 3.0 4.0 5.0 VOH[VI (2) Programmable 110 port (CMOS output) N channel IOL-VoL characteristics Supply voltage Vcc=5V N channel 50.0 Ta 25°C 40.0 ~ V I 30.0 V ./ l---" Ta=85°C ...J .2 / /' 20.0 // ~/ f/ 10. 0 o , # 1.0 2.0 3.0 4.0 5.0 VOL [VI 194 STANDARD CHARACTERISTICS 6.1 Standard characteristics 6.1.2 Icc-f(XIN) standard characteristics (1) Icc-f(XIN) characteristics on operating and at reset Measurement condition (Vcc=5V, Ta=25°C, f(XIN): square wave, single-chip mode) 20.---~-----.----.-----,----.----~ 10 ;--./'- ~ / \\1 ./" 'IV /' Io en '" oS ./\ .,r- rJV r--' 1'/ IV ~ '\ ~ / o CJ -< a: :t o a: a: w -10 "3 :s - 20 --- --- --- --- --- --- --- --- --- --- ---- ---- - - - - ---- - - - --- -ILSB -30 128 136 144 152 160 168 IT6 184 192 200 208 216 224 232 240 248 256 STEP NO 196 ©[}={]£~u~~ [j APPLICATION 7.1 Memory expansion 7.2 I/O expansion 7.3 Program examples 7.4 M37702 group execution performance APPLICATION 7.1 Memory expansion 7.1 Memory expansion This section describes the external memory expansion of the M37702 group. 7.1.1 Memory expansion model The memory can be expanded in memory expansion mode and microprocessor mode by using the external bus width selection pin (BYTE pin). Four memory expansion models shown in Table 7.1.1 are available. (1) Minimum model External memory area within the 64K bytes memory space is accessed using an 8-bit data bus. No external address latch is necessary. This is the most cost effective expansion model for externally adding an 8-bit element. (2) Medium model A Memory space beyond 64K bytes is accessed using an 8-bit data bus as same as the minimum model. An n bit (n::;8) address latch is required to latch the address data from the high-order 8 bits (A23 to A1S) of the address bus multiplexed with the data bus, but the accessible memory space is expanded up to 16M bytes. (3) Medium model B This expansion model limits memory space to within 64K bytes, but provides optimum speed. The external data bus width is 16 bits and expanded memory area can be accessed as fast as internal area if no wait (software wait nor hardware wait due to the ROY input) is used. This expansion model requires an 8 bit address latch because the middle 8 bits (A15 to As) of the address bus are multiplexed with the data bus. (4) Maximum model This expansion model uses 16-bit width external data bus to access up to 16M bytes. An 8-bit latch to latch the middle 8 bits (A15 to AB) of the address bus and an n bit (n::;8) latch to latch n bits of the high-order 8 bits (A23 to A1S) are required. 198 APPLICATION 7.1 Memory expansion Table 7.1.1 Memory expansion model Access space Less than 64K-byte 64K-byte or more External bus width M37702 16+n IiiS~YT~Et"'~h""--';:;::"~Ao-A15+n a-bit B. . . _ . 00-07 P21+_ _, BYTE = "H" Memory expansion model Minimum model Memory expansion model Medium model A M37702 16 M37702 r;;S~Y~TE~~P;O1----.,..~+Ao-A15 ~~~~~~~~~1;6+~n Ao-A15+n lSYTE 16-bit P1 P1 P2 BYTE = "L" ALE 00-015 SHEr-~--------+ Memory expansion model Medium model B Memory expansion model Maximum model r------------------------------------------------------------, I The M37702 group must operate in memory expansion mode or microprocessor mode in order to perform I : memory expansion. When either of these modes is selected, ports PO, P1, P2, P3, and part of P4 function: I as address/data bus pins or memory expansion related control pins and lose their I/O port functions. I I Therefore, port expansion must be performed together with memory expansion for applications that use: : many ports because the number of 110 ports is reduced by 30 compared with single chip mode. Port I I expansion is described in section "7.2 I/O expansion". I : The Vss line of the M37702 group should be reenforced during memory expansion and 110 expansion because the: I address L bus is used at 24 bits. ____________________________________________________________ JI 199 APPLICATION 7.1 Memory expansion 7.1.2 Memory access time calculation This section describes how to calculate the memory access time necessary to satisfy the memory expansion timing requirements. The memory access time calculation methods are described for minimum model which does not use the ALE signal and other three models which use the ALE signal. (1) Minimum model memory access time Figure 7.1.1 shows the bus timing diagram for the minimum model. The memory access time ta(AD) for the minimum model is obtained by the following equation. ta(AD)=td(POAlP1 A-E)+tw(EL)-tsu(P2D-E)-{ address decode time} .... · - .... -'......205 ....,. .. ". ?05 ~ 0 E Q) 200 150 ""-. 193 i'---,163 137 I J I ···r- J 172 ·····T····_·.1~7 144 l·:::~··lr·2- ·•·.... :f-....,1~2 "'~;t.: 96 ~~07 94 - 8 2 - 122- 100 N° ~ ~~I 53 415 J8 50 d2 0 I I I I rI 1I 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [MHz] External input clock frequency f(XIN) * Excepl for address decode lime Fig. 7.1.2 Relationship between memory access time and operatmg clock frequency for mmlmum model [ns] BMHz vers~n .. 16MHz version .. .. 25MHz version 450 431 460 400 -~, '360. 1 --344 ( - - . - No wait ....•... Software one-wait 350 f-- .... -. 0- •.300 :J 300 .. .:!J ···.. _263 Q) 250 ~233 ~ ..... ' .. 207 0.. 200 .",)85-1- 175 :::l ,- .. _1 66 •... .. 160 Q) 150 . .150 147 Ul 150 145 . <'::-:-135- 125 ~~ r--.... 100 122 C1:! r····l···.·.~15 106 .~ ......-....... ···tJ~J Cii 100 --....!!1 .... 0 ~3 42-33 ~O 42_36-L-j5 50 I I "t< I 0 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [MHz] External input clock frequency f(XIN) Fig. 7.1.3 Relationship between data setup time for write and operating clock fre.quency 202 APPLICATION 7.1 Memory expansion (2) Medium/maximum model memory access time Figure 7.1.4 shows the bus timing diagram for medium and maximum models. ALE signal must be considered in addition to address output delay time when calculating the memory access time for this model. The memory access time for the medium and maximum model depends on the following two conditions: .When address is determined before ALE is enabled. (when tw(ALE)+td(ALE-E) ~ td(P1A1P2A-E)) ta(AD)=tw(ALE)+td(ALE-E)+tw(EL)-tsu(P2DIP1D-E) -{address latch delay+address decode time} ..... ® .When address is determined after ALE is enabled. (when tw(ALE)+td(ALE-E) > td(P1A1P2A-E)) Ia(AD)=td(P1 AlP2A-E)+t w(EL)-tsu(P2DIP 1D-E) -{address latch delay+address decode time} ..... ® Note: td(P1A1P2A-E) in equations ® and ® represents either td(P1A-E) or td(P2A-E) and tsu(P2DIP1D-E) represents either tsu(P1D-E) or tsu(P2D-E) . . td(P1A1P2A-E), tw(ALE), and tw(EL) in equations ® and ® are parameters that depend on the operating clock frequency and are calculated by the equations shown in Table 7.1.3. tsu(P2DIP1D-E) is a constant that depends on the operating clock frequency (8, 16, or 25MHz). The address latch delay is the delay caused when latching the address data. Note that its value is different under the conditions for equation ® and equation ®. The address decode time is the time required to decode the address and make the chip select signal valid. The data setup time for write can be obtained by equation ® similar to the minimum model. tsu(D)=tw(EL)-td(E-P20IP1O) ..... ® Note: td(E-P20IP10) in equation ® represents either td(E-P10) or td(E-P20). If the setup time requested by the device does not satisfy these values, waits must be inserted in the bus cycle using wait bits or the ROY input. Figure 7.1.5 shows the relationship between memory access time t.(AD) and operating clock frequency f(XIN) for medium and maximum models. The graph in Figure 7.1.5 does not take into consideration the address decode time in equations ® and ® and shows the memory access time when M74F573 is used for address latch. The address decode time must be subtracted and the actual address latch delay must be considered in order to obtain the actual memory access time. The relationship between the data setup time tsu(D) for write and the operating clock frequency is similar to the minimum model as shown in Figure 7.1.3. 203 APPLICATION 7.1 Memory expansion BYTE= "H" (When external bus width is 8-bit) E twIALE) twlEL) ALE Port PO (Ao-A?) Port P1 (AS-A 15) Port P2 (A 16-A23/DO-D?) Data -'~i=====i;j td(E-P2Q) • tsulD) Riw At data reading \I--_______ A_t_da_ta_w_r_iti_ng_--,I BYTE= ilL" (when external bus width is 16-bit) ALE Port PO (AO-A?) Port P1 (Aa-A15/DS-D15) _/~::::;::=:::;=;;j Port P2 (A16-A231DO-D?) _'~====;;j R/W At data reading \\-_ _ _ _ _ _ _ _A_td_a_ta_W_ri_tin_g_--,1 Fig. 7.1.4 Bus timing diagram for medium/maximum model 204 APPLICATION 7.1 Memory expansion Table 7.1.3 Parameter equations and constant depending on the operating clock frequency ~ 8MHz version 16MHz versionn 25MHz version Parameters M37702M2 M37702M2A M37702M2B td(P1A-E) 2X10 9 2X10 9 2X10 9 100 + - 250 30 + - 125 12 + - 80 td(P2A-E) f(XIN) f(XIN) f(XIN) 1X109 1X109 1X109 - 18 tW(ALE) - 35 - 27.5 f(XIN) f(XIN) f(XIN) 2X10 9 - 30 +- +- tW(EL) ______ ~~~L __________ ------------------- r------------- I Under software one-wait I I (wait bit ="0") tSU(P2D-E) 4X10 9 f(XIN) 60 - 30 -45 -------------------- +- 30 tSU(P1D-E) - td(E-P2Q) 110 70 45 td(E-PIO) - -- td(ALE-E) 4 +- (Unit: ns) [ns] BMHz version 600 580 ~ .. 16MHz version .... 25MHz version .. 550 ',513 [ - - Nowan _ _ 49\ ...•. ,- Software one·walt I-- 500 '. 5' '- 444 < 450 ]§ '0) • 400 -. -__388 (1)+-_ _ _ (2)_1 _ _ (1) '.: .. ..: ..... . ' r .... . _)).w,=, V ..N ....•.... .... ..... ~~.: E -. 3~~_~~---~r -- -- - - ---- ,, .·r-",---r-- 350 "'CIl" CIl 300 0) U I ~'M-H-1-4J~"'-m 1'-263 - 250 ~ 250 _1-- 241 - 6 1 ' - - . 61 -226 >- .... 200 ~61~ 138_ ~_._163 0 E 0) _ _ -:':"- 149 136- ,_~ 150 ~ 119 ~r-!,07 101 0 l . '-.- .,.,,124 113 ·:f'·······.:,.. ,.~O 3 100 --~N -9N~ 15 -'-II 50 -- --- _. 3730 23 0 I , I I I I I TI I T """f I I 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 External input clock frequency f(XIN) [MHz] ·Except for address decode time The data in the graph represents values when M74F573 is used for address lalch. and the delay is as follows. (1) tW(ALE)+td(ALE-E) ~ td(P1A1P2A-E) at 13ns (max) (2) tW(ALEI+td(ALE-E) > td(P1A1P2A-E) at 8.5ns (max) Fig. 7.1.5 Relationship between memory access time and operating clock frequency for midium/maximum model 205 APPLICATION 7.1 Memory expansion 7.1.3 Memory expansion precautions When setting E signal to "L" level and reading the data on the bus, the M37702 group has an address hold )ime (tpxz(E-P1ZIP2Z)) of up to 5ns. When the E signal becomes "H" level and data on the bus is read, at minimum the floating time (tpzx(E-P1ZIP2Z)) shown in Table 7.1.4 is reserved before the next address data is output. Therefore, when using devices that output data on the data bus within 5ns from the fall of the E signal (ton(oE):::;5ns) or output data on the data bus for more than tpzx(E-P1ZIP2Z) at the rise of the E signal, considerations must be made to prevent bus contention between the address data output by the M37702 group and the data output by the device. When using devices with ton(OE) that does not satisfy tpxz(E-P1ZIP2Z), generate the device read signal OE with only the leading edge of the fall of the E signal delayed for few nanoseconds. When using devices with tOF and tdis(OE) that do not satisfy tpzx(E-P1ZIP2Z), delete the data output by the device using a bus buffer for example. Figures 7.1.7 and 7.1.8 show examples of using a bus buffer. Table 7.1.5 shows Mitsubishi memories that can be connected to the M37702 group without bus buffer. When requesting memory with specifications shown in Table 7.1.5, specify "tOF 15ns microcomputer and kit." Table 7.1.4 Address hold time and data floating time ~ 8MHz version 16MHz versionn 25MHz version Parameter M37702M2 M37702M2A M37702M2B tpxz(E-P1Z) 1pxz(E-P2Z) 5 5 5 tpxz(E-P 1Z) 1X10 9 1X10 9 1X10 9 - 2.0 tpxz(E-P2Z) 2Xf(XIN) - 12.5 2Xf(XIN) - 6.25 2Xf(XIN) (DimenSion In ns) E Peripheral device OE (Read signal) tpzx(E-P1Z) /+---1 tpzx(E-P2Z) Adress output .•• Address Peripheral device data output •••••• - ••••• - •• _•• _••••• - _•• Fig. 7.1.6 Memory data read timing 206 APPLICATION 7.1 Memory expansion Table 7.1.5 Memory usable without bus buffer Memory type Type name tOF/tdlS (DE) Conditions EPROM M5M27C256AK-85/-10/-12/-15 15ns f(XIN)::::20MHz (Note) or equivalent OTP component M5M27C512AK-10/-12/-15 or equivalent OTP component M5M27C100K-12/-15 M5M27C1 01 K-12/-15 M5M27C102K-12/-15 M5L27512K-17/-2 30ns f(XIN)::::8MHz SRAM M5M52568P-70/-85/-10/-12/-15 15ns f(XIN)::::20MHz (Note) or equivalent L,LL types M5M5178P-35/-45/-55 Note: M74F32 or equivalent component is required for read signal generation when using at 16MHz fre- quency or greater. M37702 A1-A71----------~---+ Address bus ALS573AP BYTE 7r ALS245A* As-A151+_.....~I__.~'B IOs-015 A'-1-----+ ..... Data bus (odd) OIR DC ALS245A* A16-A23 '+_ _....._+l~, IOo-07'~ B A'+--il---+ Data bus (even) , - - - - - 0 - OIR DC * Available gate examples EI---t----, ~) ate 8MHz 16MHz ALS32* ,- - - - - - - - --, OR ALS32 ALS32 3-STATE ALS245A F245 BUFFER ALS1245A R/W 1 - -____--1 ~o__+.;.-a 0 - - ; . - - - -.. RD p - , - - - - -.. WO p-;._--015) '+-"T"-------+ Data bus As-A23 I ' I----+CSI 1-.---+ CS2 RDY signal input timing A<>-A7 1-_..1._____-1-_+ Address bus ROY ~-----jt----+-------, ALE Insert wait due to ROY ROY F04 only in area accessed byCS, InteNal extended by ROY input Circuit condition: f(XIN) ,;; 14.9MHz, Software no wait Fig. 7.1.9 ROY generation circuit example 7.1.5 Memory expansion example Memory expansion examples are described below. (1) Minimum model memory expansion example Figure 7.1.10 shows a minimum model memory expansion example. In a minimum model, the R/W signal and E signal are used to generate the memory read signal RO and write signal WR. The BHE signal is unused and must be kept open. M37702S1FP BYTE A1SI--.,-------------, Ao-A141----~-~Ao-At4 00-071+--~+__I~1 00-07 Memory map OE OE W 0000,6 SFR area 0080,6 Internal RAM area BHE 0280,6 External RAM area R/W (M5M5256BP) , 8000,6 E :WR External ROM area XtN XOUT HC32 (M5M27C256AK) 8MHz FFFF'6 7fT 7fT Fig. 7.1.10 Minimum model memory expansion example 209 APPLICATION 7.1 Memory expansion (2) Maximum model memory expansion example Figure 7.1.11 shows a maximum model memory expansion example. In maximum mode, the memory write signal must be separated into even address write signal WE and odd address write signal WO because the external data bus is used as a 16-bit bus. The even address write signal and odd address write signal are separated by using Ao of the address and the BHE signal. The read signal need not be separated because the microcomputer selectively inputs the data. M37702M2AXXXFP Memory expansion mode A1-A71--------T;.;;.;;.~~-----"' BYTE A8-A15 108-0151 ...............~ ALE 1--1---1---' M5M5256BP A16I0o Memory map ,"+_ _-"O",ata""b",us"","",od",,d--:0",8--"0,,,,15,"+1001_008 000016 SFR area 008016 OE Iii Inlernal RAM area Data bus (even) 027F16 01-07 Not used area C00016 RtW E Inlernal ROM area Ao FFFFl 6 1000016 Extended RAM area BHE (M5M5256BPX2) XIN XOUT ALS32 1FFFF16 0 16MHz iir iir Circuit condition' Software one-wait Fig. 7.1.11 Maximum model memory expansion example (3) Memory expansion example at 20MHz using software one·wait Figure 7.1.12 shows a memory expansion example at 20MHz using software one-wait (maximum model). No bus buffer is required in this example because M5M27C102K-15 is used as an external ROM (see Table 7.1.5). (4) Memory expansion example at 25MHz using software one·wait Figure 7.1.13 shows a memory expansion example at 25MHz using software one-wait (medium model 8). This example requires a bus buffer to prevent bus contention. 210 APPLICATION 7.1 Memory expansion M37702S1 BFP M5M27C102K-15 CE AI-A7 t-____...;..;=""':i;.;;;.._-..;A.;,;I.,.;-A.;.;I.:.-6~ Ao-AIS BYTE As-AIS 108-015 Memory map A16/00 000016 SFR area ALE 008016 f--""'--'-'-"'-'-"""--J 01-D7 ~--l~_ _-..;o~a;::(a~b;::u=-s_ _-..;0:::o-:::0~1=-5.1 00-015 Internal RAM area 027F16 DE f------J 028016 Extended ROM area R,;{i (M5M27Cl02K) E Bus buffer is unnecessary. 1 FFFF16 '--_ _ _ _ _-' XIN XOUT 0 20MHz Circuit condition: Software one-wait -ifr -ifr Fig. 7.1.12 Memory expansion example at 20MHz using software one-wait M37702S 1 BFP BYTE ALEf---j----' 00-07 E Memory map ¢1 000016 SFR area RN-I 008016 Internal RAM area BHE 027F16 WE Ao Extended RAM area F32 (M5M52568PX2) 7FFF16 800016 XIN XOUT Extended ROM area (M5M27C256AKX2) D 25MHz Circuit condition: Software one-wait FFFF16 Fig. 7.1.13 Memory expansion example at 25MHz using software one-wait 211 APPLICATION 7.1 Memory expansion (5) Memory expansion example at 25MHz using software one·wait+RDY Figure 7.1.14 shows a memory expansion example at 25MHz using software one-wait and RDY (medium model A). In this example, a software wait and a hardware wait by RDY are inserted during ROM access. M37702S1 BFP L BYTE Ao-A14I-""?""---.;.;,;;;;==---_ M5M27C512AK-15 AI51---------j A1G/Do Ao-A15 AD-AI5 ALE 1----+----' F245 E~~--1------~---' ¢1 RDYI--------------~-~ XIN XOUT o 25MHz Circuit condition: Software one-wait ifr ifr ROY signal input timing Fig. 7.1.14 Memory expansion example at 25 MHz using software one-wait+RDY 212 APPLICATION 7.1 Memory expansion (6) Memory expansion example using M66800SP/FP Figures 7.1.15 to 7.1.17 show memory expansion examples using the M66800SP/FP (hereafter referred to as M66S00). The M66800 is a memory control IC that can be connected to either word bus or byte bus of the M37702 group. It is equipped with an internal address decoder, read/write signal generator, and an ROY signal generator. {Precautions when expanding memory using the M66S00} Reenforce the GND lines of the M37702 group and M66S00 in order to prevent errors due to noise. Also add an SOpF capacitor between the ALE line and GND line for safety. Figure 7.1.15 shows an example of adding a 64KB EPROM (M5M27C512AK·10) and a 32KB SRAM (M5M5256BP-10) with no wait to the M37702 group that has an S-bit external bus and operates at 12.28SMHz. The ROY output pin of the M66800 is open because it operates at no wait. Figure 7.1.16 shows an example of adding a 64KB EPROM (M5M27C512AK-15) and a SKB high- speed SRAM (M5M517SP-45) to the M37702 group that has an S-bit external bus and operates at 15MHz. The SKB high-speed SRAM is no wait and one-wait is inserted with ROY for the EPROM. CS5 (EPROM chip select signal) is input as the wait request input (WRQ) to the M66800 in order to limit the area in which the ROY is valid. Figure 7.1.17 shows an example of adding a 12SKB EPROM (M5M27C102K-15) and two 32KB SRAMs (M5M5256BP-10) to the M37702 group that has a 16-bit external bus and operates at 12.2S8MHz. The SRAM is no wait and one-wait is inserted with ROY for the EPROM. Similar to Figure 7.1.16, an EPROM chip select signal is used to limit the area in which the ROY is valid. M37702S1AFP CNVss H M66800SP/FP BYTE BYTE AS A15 AD AD Ao-A? A16-A23 P5 As-A15 ADS-AD15 28000-2FFFF CS9 A16-A23 AD16-AD23 I M5M27C512AK·10 LM5M5256BP.,D P6 100-07 BOOO-17FFF CE S CS5 ALE _~ Ao-A15 ~ Ao-A14 ALE Ao-A15 EPROM Ao-Al. RAM .. P7 - BHE i - BHE (64K) r-- 00-07 OE • (32K) D01-DOa OE W II P8 E E - RD RiW RIW - WR I P4 tfJ <1>' )-- ROY WRO 3 WAIT~ XIN XOUT YD~ 12288MHz Fig. 7.1.15 Memory expansion example using M66800 (1) 213 APPLICATION 7.1 Memory expansion M37702S1AFP ~ CNVss M66800SP/FP BYTE - - - - - - BYTE AB-A15 AO-A? AO AO A16-A23 P5 .. .. AB-A15 ADS-AD15 _ 2000-3FFF CS1 A16-A23 I M~K-15 AD16-AD23_ BOOO-17FFF LM~M517SP-45 CE .. P6 /00-07 CS5 ALE ALE Ao-A,s Ao-A,s EPROM _t.,. A~ Ao-A.2 ..L- RAM P7 .. .. P8 BHE I - - - ---~ ~ BHE (64K) - 00-07 OE (SK) DO.-DOs OE W E E -RD P4 Rm Riw WR I - f--- I [w;T WRQ I-- ROY ROY WAIT I TTT XIN XOUT YD~ 15MHz Fig. 7.1.16 Memory expansion example using M66800 (2) M37702S1 AFP J M66800SP/FP CNVss BYTE BYTE AS-A15 7ir AD --- Ao-A? AD A16-A23 ----. P5 As-A15 ADS-AD15 IDs-D15 2BOOO-37FFF CS9 A16-A23 I M5M27C.02K ~5~5256BP-'O ~5:5256BP-' ~ AD16-AD23- 8000-27FFF .. P6 100-07 CS6 CE A~ .... Ao-A,. ~ Ao-A,. ~ Ao-A •• ALE ALE Al-A15 Al .. A15 ~ EPROM RAM RAM ~ P7 P8 BHE -- ---~ SHE - (12BK) 00-0,. OE ~ (32K) DO ,-DOs OE Vi (32K) DO.-DOs OE W E - - ----~E AD - P4 R/W ifJ'-- - ----~~ Riw <;i - - WRE - WRO -- ---_. I I -- l~ WRO - ROY RO"v WAIT~_ XIN XOUT f YD~ 12.288MHz Fig. 7.1.17 Memory expansion example using M66800 (3) ! 214 APPLICATION 7.2 I/O expansion 7.2 I/O expansion 1/0 expansion is described below. 7.2.1 110 expansion model Similar to memory expansion, 1/0 expansion for the M37702 group in memory expansion mode and microprocessor mode can be performed for the four models shown in Table 7.1.1. Memory mapped 1/0 is used for 1/0 expansion. The expansion methods and precautions are the same as for memory expansion. 7.2.2 110 expansion examples (1) Port expansion example using M5M82C55AP-2/FP-2 Figure 7.2.1 shows a port expansion example using M5M82C55AP-2/FP-2. This is an expansion example for a medium model B,and M5M82C55AP-2/FP-2 is connected to the even number port side and odd number port side of the M37702 group data bus to expand the 1/0 port to 48. The device reset signal is supplied from port P43. 215 APPLICATION 7.2 I/O expansion M37702S 1AFP , - - - - - - -.. eso r---------~ eS2 Ao--A7 I---------..,---~I_+..,. __--..... r----~es3 Address bus F139 A14 A YO M5M82C55AP-2/FP-2 ALS573AP A15 B Y1 I--+--HH----j es PortC~ Y2 A2 A1 ALE 1 - - - - 1 - - - 1 t--.---lE Y3 Al Ao Port 8 4'0';"'·"·' ,>- ALS245A Port A «m;:;1.';Z;;!J>- A8-A1S ID8-D1S H---~D~8~t8~b"'u-s~(O-d~d~l" A B ~----+-++I Do--D7 DIR OC RESET ALS245A M5M82C55AP-2/FP-2 A16-A23'+__D_8_t8_bu_s_(:..,e_ve_n.... lHI-' IDo-D7 ... A B 1• ..,...-. Port e <'~;'r'i·q·t>- DIR OC Al ~~ Pori 8 ~»~.+>­ P431--~~-- ---I----------+---~--. Port A .?-.k.,L..,$;'~ EI--~~~~-+_~---~ '--\-.1 Do-D7 RESET R/WI----. Ao I----:.-Q....J F32 ALS32 Circui1 condition: Software one-wait 16MHz Fig. 7.2 ..1 Port expansion example using M5M82C55AP-2/FP-2 216 APPLICATION 7.2 1/0 expansion (2) Port expansion example using M66500SP/FP Figure 7.2.2 shows a port expansion example using M66500SP/FP. This is an expansion example for a minimum model which adds 24 1/0 ports, 16 high-breakdown-voltage output ports, and 4 bits 1/0 ports. M37702S1 AFP , - - - - - - - - - . - CSo ,--------l~ CS2 , - - - - - -.... CS3 Ao-A7i-----......--,..---++-O!-~-- .. Address bus CNVss HC139·1 BYTE M6650DSP/FP A14 A YO A1S B YTI--j--1--J----l CS As-A15i-------..r Y2 A2 Port A "k,~~ A2 E Y3 A1 Al AD Ao PortB <~~> ALS245A PortC '.::(b?mtl~ A16-A23 ~___O_a_ta_b_u_s_-tll-I 00-07 1D0-07 Port E .."",,:,:t>- Port F ~~a::~::-~> Er--~~~--+-~· PortG '4G···~~~ RESET RO WR R/W 1 - - - _ 4 > - - - - - - - - l - ,a , L _________ I P43r------------------------~ Circuit condition: Software one-wait 16MHz Fig. 7.2.2 Port expansion example using M66500SP/FP 217 APPLICATION 7.2 I/O expansion (3) Port expansion example using M37451 M4-XXXFP Figure 7.2.3 shows an expansion example using an 8-bit single-chip microcomputer M37451 M4-XXXFP. This is an expansion example for a minimum model and the host bus interface function of the M37451 M4- XXXFP is used. M37702S1 AFP CSa ,------------I~ ,---------·CS2 r-----~CS3 ,... Aa-A?I----"""'l_---H-+~-----_t~ Address bus >-- CNVss " LS139 - BYTE ~AYo A8-A151----tr~, _B E ~~I-I--+-+--+-l'f.."" ,_M3745~M4-XXXFP Y31-.. " 7IT cs Port PO <~ _~ Aa AO! -- Port P1 0&~<;;j> A1 6-A 23 Data bus , ""W fDa-D?I.------------~i~1>j DBa-DB? T -IN-T-o~-----4----------~~,-----~PRDY 1 E 1---------0'" > ______+-l- - l E ____________--l\c___I~1 RlN -1-______---'-'FOc.:.4_"V I. Port P4 ,,,<1k*WJ RfW ·.....>O~.w,~~~/ Bus interface -- P431----------~~------------c---I~RESET .,Jr XIN XOUT XIN XOUT yor-l yor-l 12.5MHz 10MHz Fig. 7.2.3 Port expansion example using M37451 M4-XXXFP 218 APPLICATION 7.3 Program examples 7.3 Program examples 7.3.1 Hardware definition 7.3.2 Initialization examples 7.3.3 Timer modes setting examples (1) Timer A ......................... Timer mode (2) Timer A ......................... Event counter mode (3) Timer A ......................... Two phase pulse processing function (4) Timer A ......................... One·shot pulse mode (5) Timer A ......................... PWM mode (6) Timer B ......................... Pulse period measurement mode (7) Timer B ......................... Pulse width measurement mode 7.3.4 Serial I/O modes setting examples (1) 8-bit UART ................... 1 byte receive (2) 8-bit UART ................... 1 byte transmit (3) 8-bit UART ................... n-byte transmit (4) Clock synchronous .... 1 byte receive (5) Clock synchronous .... 1 byte transmit (6) Clock synchronous .... n-byte transmit (7) Error processing 7.3.5 A-O conversion modes setting examples (1) One-shot mode (2) Repeat mode (3) Single sweep mode (4) Repeat sweep mode 7.3.6 Interrupt processing examples (1) Interrupt setting example (2) Interrupt routine processing example ............ When memory space is 64K bytes or less. (3) Interrupt routine processing example ............ When memory space exceeds 64K bytes. 7.3.7 Watchdog timer setting examples 7.3.8 Software timer setting examples 7.3.9 Interrupt vector table setting example 219 . APPLICATION 7.3 Program examples 7.3.1 Hardware definition SEQ. LaC. OBJ. ....*.... 1. ••• *.... 2•••• *.... SOURCE STATEMENT ..•• 5•••. *.... 6 .••• *.... 7.••• *.... S•••• *.... 9•••• *... 4 I •PAGE 'M37702 HARDWARE DEFINE' 5 I 6 I ; ============================ ============================ 7 I M37702 Hardware define 8 I ; ==================================================== 9 1 10 I •SECTI ON SFR_AREA 11 I 12 I ; ================================================ 13 I Port registers 14 I ;============================================= . 15 I 16 I •ORG 000002H 17 000002 I POI: ; Port PO, PI registers 18 (000002) IH BYTE I PO: .BLKB ; Port PO register 19 (000003) IH BYTE I PI: .BLKB ; Port PI register 20 I ; ---------------------------- ------------ 21 000004 I paID: ; Port PO, PI direction registers 22 (000004) I H BYTE I POD: .BLKB ; Port PO direction register 23 (000005) I H BYTE I PID: .BLKB ; Port PI direction register 24 I ; ------- -------------- --- --- - - - ----- ----- 25 000006 I P23: ; Port P2, P3 registers 26 (000006) IH BYTE I P2: •BLKB ; Port P2 reg i ster 27 (000007) IH BYTE I P3: .BLKB ; Port P3 register 2S I ; ------- --------------------- ------------ 29 OOOOOS I P23D: ; Port P2, pa direction registers 30 (OOOOOS) IH BYTE I P2D: .BLKS ; Port P2 direction register 31 (000009) IH BYTE I P3D: .BLKB ; Port P3 direction register 32 I ; ---------------------------- ------------ 33 OOOOOA I P45: ; Port P4, P5 registers 34 (OOOOOA) I H BYTE I P4: .BLKB ; Port P4 register 35 (OOOOOB) IH BYTE I P5: .BLKB ; Port P5 register 36 1 : ------- --------------------- ------------ 37 OOOOOC I P45D: ; Port P4, P5 direction regi sters 3S (OOOOOC) IH BYTE I P4D: .BLKB ; Port P4 direction register 39 (OOOOOD) IH BYTE I P5D: .BLKB ; Port P5 direction register 40 I ; ------- --------------------- ------------ 41 OOOOOE I P67: ; Port PS, P7 registers 42 (OOOOOE) IH BYTE I P6: .BLKB ; Port PS register 43 (OOOOOF) IH BYTE I P7: .BLKB ; Port P7 register 44 I ; ------- ------- ------------- - -----.~------ 45 000010 I P67D: ; Port PS, P7 direction registers 46 (000010) IH BYTE I P6D: .BLKB ; Port P6 direction register 47 (000011) IH BYTE I P7D: .BLKB ; Port P7 direction register 4S I ; ------- - ----------------- --- -- ---------- 49 (000012) 2H BYTE IPS: .BLKB 2 ; Port PS register 50 I ;---------------------------------------- 51 (0000!4) 2H BYTE I PSD: •BLKB 2 ; Port PS di recti on reg i ster 52 I; 220 APPLICATION 7.3 Program examples SEQ. LOC. OBJ. .... *.... 1. ••• *.... 2•••• *.... SOURCE STATEMENT •••• 5•••• *.... 6 •••• *....7 •••• *.... 8•••• *....9 •••• *... 53 .PAGE 54 55 ;========================================= 56 I ; A-D conversion registers 57 I ;================================= 58 I; 59 I .ORG OOOOIEH 60 (OOOOIE) IH BYTE I ADCON: .BLKB I ; A-D control register 61 (OOOOIF) IH BYTE I ADSPS: .BLKB I ; A-D sweep Pin selection register 62 I ;---------------------------------------- 63 (000020) 2H BYTE I ADO: .BLKB 2 ; A-D register 0 64 I ;---------------------------------------- 65 (000022) 2H BYTE I ADI: .BLKB 2 ; A-D register I 66 I ; -- -------------------------- ------------ 67 (000024) 2H BYTE I AD2: .BLKB 2 ; A-D register 2 68 I ; ---------------------------- ------------ 69 (000026) 2H BYTE I AD3: .BLKB 2 ; A-D register 3 70 I ; ---------------------------- ------------ 71 (000028) 2H BYTE I AD4: •BLKB 2 ; A-D register 4 72 I ; ---------------------------- ------------ 73 (00002A) 2H BYTE I ADS: .BLKB 2 ; A-D register 5 74 I ;---------------------------------------- 75 (00002C) 2H BYTE I AD6: .BLKB 2 ; A-D register 6 76 I ; ---------------------------- ------------ 77 (00002E) 2H BYTE I AD7: .BLKB 2 ; A-D register 7 78 I ; 79 I ;=======--========--========================== 80 I Serial I/O a registers 81 I ;========================================= 82 I 83 000030 I SOMxB: 84 (000030) IH BYTE I SOMR: .BLKB ; UARTO transmit/receive mode register 85 (000031) IH BYTE I SOBRG: •BLKB ; UARTO baud rate generator (BRG) 86 I ; ------- --------------------- --- --------- 87 000032 I SOTB: ; UARTO transmission buffer registers 88 (000032) IH BYTE I SOTBL: .BLKB ; UARTO transmission buffer register (Jow-order) 89 (000033) IH BYTE I SOTBH: .BLKB ; UARTO transmission buffer register (high-order) 90 I ; ------- ---------------- ----- ------------ 91 000034 I SOC: ; UARTO transmit/receive control registers 92 (000034) IH BYTE I SOCL: .BLKB ; UARTO transmit/receive control register 0 93 (000035) I H BYTE I SOCH: .BLKB ; UARTO transmit/receive control register I 94 I ;---------------------------------------- 95 000036 I SORB: ; UARTO receive buffer registers 96 (000036) IH BYTE I SORBL: .BLKB ; UARTO receive buffer register (Jow-order) 97 (000037) IH BYTE I SORBH: .BLKB ; UARTO receive buffer register (high-order) 98 I 99 I ; ======================================== 100 I Serial I/O I registers 101 ; ============================================ 102 I ; 103 000038 I SIMxB: 104 (000038) IH BYTE I SIMR: .BLKB ; UARTI transmit/receive mode register 105 (000039) IH BYTE I SIBRG: .BLKB ; UARTI baud rate generator (BRG) 106 I ;---------------------------------------- 107 00003A I SITB: ; UARTI transmission buffer registers 108 (00003A) IH BYTE I SITBL: .BLKB ; UARTI transmission buffer register (Jow-order) 109 (00003B) IH BYTE I SITBH: .BLKB ; UARTI transmission buffer register (high-order) 110 I ; ---------------------------- ------------ III 00003C I SIC: ; UARTI transmit/receive control registers 112 (00003C) IH BYTE I SICL: .BLKB ; UARTI transmit/receive control register a 113 (00003D) IH BYTE I SICH: .BLKB ; UARTI transmi t/recei ve control register I 114 I ; ---------------------------- ------------ 115 00003E I SIRB: UARTI receive buffer registers 116 (00003E) IH BYTE I SIRBL: .BLKB UARTI receive buffer register (Jow-order) 117 (00003F) I H BYTE I SIRBH: .BLKB UARTI receive buffer register (high-order) 118 I; 221 APPLICATION 7.3 Program examples SEQ. LOC. OBJ. ....*.... 1. •.• *.... 2•••• *.... SOURCE STATEMENT. ••. 5.••• *.... 6•.•• *.... 7 •••• *.... 8 •••• *....9 •••• *... 119 1 .PAGE 120 1 121 1 ;============================================== 122 1 Timer registers 123 1 ; ============================================== 124 1 125 (000040) 2H BYTE 1 TABSR: .BLKB 2 ; Count start flag 126 1 ; ---------------------------- ------------ 127 (000042) 2H BYTE 1 ONSF: .BLKB 2 ; One-shot start flag 128 1 ; ------- --------------------- ------------ 129 (000044) 2H BYTE I UDF: .BLKB 2 ; Up/down flag 130 1 ; ---------------------------- ------------ 131 000046 1 TAO: ; Timer AO register 132 (000046) 1H BYTE 1 TAOL: .BLKB ; Timer AO register (Jow-order) 133 (000047) 1H BYTE 1 TAOH: .BLKB ; Timer AD register (high-order) 134 1 ; ---------------------------- ------------ 135 000048 1 TAl: ; Timer Al register 136 (000048) 1H BYTE 1 TAIL: .BLKB ; Timer Al register (low-order) 137 (000049) 1H BYTE 1 TA1H: .BLKE ; Timer Al register (high-order) 138 1 ; ---------------------------- ------------ 139 00004A 1 TA2: ; Timer A2 register 140 (00004A) 1H BYTE 1 TA2L: .BLKB ; Timer A2 register (Jow-order) 141 (00004B) 1H BYTE 1 TA2H: .BLKB ; Timer A2 register (high-order) 142 1 ; ---------------------------- ------------ 143 00004C 1 TA3: ; Timer A3 register 144 (00004C) 1H BYTE 1 TA3L: .BLKB ; Timer A3 register (low-order) 145 (00004D) 1H BYTE 1 TA3H: .BLKE ; Timer A3 register (high-order) 146 1 ; ---------------------------- ------------ 147 00004E 1 TM: ; Timer M register 148 (00004E) 1H BYTE 1 TML: .BLKE ; Timer M register (low-order) 149 (00004F) 1H BYTE 1 TMH: .ELKE ; Timer M register (high-order) 150 1 ; ---------------------------- ------------ 151 000050 1 TEO: ; Timer EO register 152 (000050) 1H BYTE 1 TEOL: .ELKB ; Timer BO register (Jow-order) 153 (000051) 1H BYTE 1 TEOH: .ELKB ; Timer BO register (high-order) 154 1 ; ---------------------------- ------------ 155 000052 1 TB1: ; Timer B1 register 156 (000052) 1H BYTE 1 TB1L: .ELKE ; Timer B1 register (low-order) 157 (000053) 1H BYTE 1 TE1H: .BLKB ; Timer B1 register (high-order) 158 1 ; ---------------------------- ------------ 159 000054 1 TE2: ; Timer B2 register 160 (000054) 1H BYTE 1 TB2L: .BLKB ; Timer B2 register (low-order) 161 (000055) 1H BYTE 1 TE2H: .BLKB ; Timer B2 register (high-order) 162 1 ; ---------------------------- ------------ 163 000056 1 TA01MR: ; Timer AD, Al mode registers 164 (000056) 1H BYTE 1 TAOMR: .BLKB ; Timer AO mode register 165 (000057) 1H BYTE 1 TA1MR: .BLKB ; Timer Al mode register 166 1 ; ---------------------------- ------------ 167 000058 1 TA23MR: ; Timer A2, A3 mode registers 168 (000058) 1H BYTE 1 TA2MR: .BLKB ; Timer A2 mode register 169 (000059) 1H BYTE I TA3MR: .BLKB ; Timer A3 mode register 170 I ; ---------------------------- ------------ 171 00005A 1 TMBOMR: ; Timer M, BO mode registers 172 (00005A) 1H BYTE 1 TMMR: .BLKB ; Timer A4 mode register 173 (00005B) 1H BYTE 1 TBOMR: .BLKB ; Timer EO mode register 174 I ; ---------------------------- ------------ 175 00005C 1 TEI2MR: ; Timer BI, B2 mode registers 176 (00005C) 1H EYTE 1 TE1MR: .BLKB ; Timer B1 mode register 177 (00005D) 1H EYTE 1 TE2MR: .BLKB ; Timer B2 mode register 178 1 179 1 ; ============================ ==================== 180 I Processor mode register 181 I ; ==============,================================= 182 1 183 (00005E) 2H EYTE 1 PMR: .BLKE 2 ; Processor mode register 184 I; 222 APPLICATION 7.3 Program examples SEQ. LOC. OBJ. .... *.... 1. ••. *.... 2•••. *.... SOURCE STATEMENT •••• 5•••• *.... 6•••• *.... 7..•• *.... 8••.• *.... 9••.• *... 185 1 .PAGE 186 1 187 1 ; ================================================ 188 1 Watchdog timer registers 189 1 ; ========================================== 190 1 191 (000060) II! BYTE 1 WDT: .BLKB ; Watchdog timer 192 (00006\) II! BYTE 1 WDC: .BLKB ; Watchdog timer frequency selection flag 193 1 194 1 ; ===--======================================== 195 1 Interrupt control registers 196 1 ; ============================================= 197 1 198 1 .ORG 0000701! 199 000070 1 ADxSOTIC: 200 (000070) II! BYTE 1 ADIC: .BLKB ; A-D conversion interrupt control register 201 (000071) II! BYTE 1 SOTIC: .BLKB ; UARTO transmission interrupt control register 202 1 ; ---------------------------- ------------ 203 000072 1 SORxSlTIC: 204 (000072) II! BYTE 1 SORIC: .BLKB ; UARTO receive interrUPt control register 205 (000073) II! BYTE 1 SlTIC: .BLKB ; UARTI transmission interrUPt control register 206 I ; ---------------------------- ------------ 207 000074 I SIRxTAOIC: 208 (000074) II! BYTE I SIRIC: .BLKB ; UARTI receive interrupt control register 209 (000075) II! BYTE I TAOIC: .BLKB ; Timer AO interrupt control register 210 I ; ---------------------------- ------------ 211 000076 I TAlxTA2IC: 212 (000076) II! BYTE ITAlIC: .BLKB ; Timer Al interrupt control register 213 (000077) II! BYTE I TA2IC: •BLKB ; Timer A2 interrupt control register 214 I ; ---------------------------- ------------ 215 000078 I TA3xTMIC: 216 (000078) II! BYTE I TA3IC: .BLKB ; Timer A3 interrupt control register 217 (000079) II! BYTE I TMIC: .BLKB ; Timer M interrupt control register 218 I ; ---------------------------- ------------ 219 00007A I TBOxTBlIC: 220 (00007 A) II! BYTE I TBOIC: .BLKB ; Timer BO interrupt control register 221 (00007B) II! BYTE I TBlIC: .BLKB ; Timer B1 interrupt control register 222 I ; ---------------------------- ------------ 223 00007C I TB2xINTOIC: 224 (00007C) II! BYTE I TB2IC: .BLKB ; Timer B2 interrupt control register 225 (00007D) II! BYTE I INTOIC: .BLKB ; INTO interrupt control register 226 I ; ---------------------------- ------------ 227 00007E 1 INTlxINT2IC: 228 (00007E) II! BYTE I INTlIC: .BLKB ; INTI interrupt control register 229 (00007F) II! BYTE I INT2IC: .BLKB ; INT2 interrupt control register 230 I ; ---------------------------- ------------ 231 I; 223 APPLICATION 7.3 Program examples 7.3.2 Initialization examples SEQ. LOC. OBJ. .... *.... 1. ••. *.... 2•••• *.... SOURCE STATEMENT •••• 5•••• *.... 8•••• *.... 7•••• *•••• 8•••• *.... 9•••• *... 242 .PAGE 'MAIN ROUTINE' 243 244 ;===================================================== 245 Main routine 248 ;===================================================== 247 248 ;================================================ 249 Ini tialization routine 250 ; ========================= ==================== 251 252 :------ - ------------------ -- - ------------ 253 Assembler declarations 254 255 258 These are assembler declarations. 257 Flags and registers used 258 in the program must match 259 these declarations. 280 281 .SECTION PROGRAM ; Sect i on name 282 .ORG OCOOOH ; Start address 283 •DATA 18 ; Data length 284 • INDEX 18 ; Index register length 285 .DP OOOOR ; Direct page 288 .DT DOH ; Data bank 287 288 289 Initialize registers and flags = 270 271 272 OOCOOO INITIAL: 273 OOCOOO 78 SEI ; Disable interrupt 274 OOCOO! C238 CLP m,x,D ; Set data and index register length 18 bits 275 ; Binary operation mode 278 OOCOO3 A27F02 LDX 1027FH 277 00C008 9A TXS ; Stack pointer=Highest address of RAM 278 00C007 A90000 LDA A,tO 279 OOCOOA 5B TAD ; Direct page=OH to FFH 280 OOCOOB 89C200 LDT 10 ; Data bank=Bank 0 281 OOCOOE *845E2000 L LDM 10020H,PMR ; InterruPt priority detection time=2 ¢> cycles 282 ; Single-chip mode 283 284 285 Clear RAM 288 ; --- ---- ---- --- ----- ----- --- - -- -- -------- 287 288 OOCOl2 A27E02 LDX .027EH 289 00COl5 A90000 LDA A,tO ; Set initial value (OH) in accumulator A 290 00COl8 RAM_CLR: 291 00COl8 *9500 STA A,O,X ; Write content of accumulator A to specified 292 OOCOIA CA DEX ; RAM in 18-bit unit 293 OOCOIB CA DEX 294 OOCOIC E07EOO CPX t07EH 295 OOCOIF DOF7 L BNE RAM_CLR 298 297 298 Change register model 299 (if necessary) 300 301 302 •DATA 8 ; Data length 303 00C021 F8 SEM ; Data length 8 bits 304 305 308 307 00C022 2000DO L JSR SUUL! 308 00C025 80FE L E_LOOP: BRA HOOP 309 224 APPLICATION 7.3 Program examples 7.3.3 Timer modes setting examples (1) Timer A ......................... Timer mode SEQ. LaC. OBJ. ••••••..• 1. ••• * •••• 2 ••••••••• SOURCE STATEMENT •••• 5•••• * •••• 6•••• *.... 7 •••• *.... 8•••• *....S•••• *... 327 1 •PAGE 328 1 329 1 ;======================================= 330 1 Timer setting eKample I 331 1 [Timer A: Timer mode] 332 1 ; ===================--== ==================== 333 1 33~ 1 ; ------- ---------- ----------- ------------ 335 1 When there is no pulse output 336 1 ---------------------------------------- 337 1 Timer :Timer AO 338 1 Mode :Timer mode 339 1 Pulse output :Disabled 340 I Gate function :Disabled 341 I Count source :f(XIN)/2 342 I 343 OODOOO 1 SUB_TU: 344 1 •DATA 8 345 OODOOO E224 1 SEP m. I ; Data length 8 bits. disable interrUPt 346 00D002 *144001 LI CLB 100000001B. TABSR ; Stop TAO count 347 00D005 *6~5600 LI LDM 100000000B. TAOMR ; Timer mode. disable pulse output and gate function 3~8 I ; Count source=f(XIN)/2 3~9 I .DATA 16 350 00D008 D8 I CLM : Data length IS bits 351 00D009 *6~~6CF07 LI LDM 12000-1. TAO : Set counter val ue 352 1 •DATA 8 353 OODOOD F8 I SEM ; Data length 8 bits 35~ OODOOE *6~ 7507 LI LDM #00000111B. TAOIC ; Clear TAO interrupt request bit 355 1 ; Enable TAO interrUPt (leve I 7) 35S OODOll *0~~001 LI SEB 100000001B. TABSR : Start TAO count 357 00D01~ 58 I CLI : Enable interrUPt 358 359 360 1 I I * Hereafter. interrupt request occurs after each timer AO overflows. 3S1 00D015 so • I RTS 362 I 363 I ------- --------------------- ------------ 364 I When there is pulse output 365 I ---------------------------------------- 36S I Timer :Timer AO 367 I Mode :Timer mode 368 I Pulse output :Enabled 369 I Gate function :Disabled 370 1 Count source :f(XIN)/2 371 1 372 00D01S 1 SUB_TU: 373 I .DATA 8 37~ 00D016 F8 I SEM ; Data length 8 bits 375 00D017 *144001 LI CLB 100000001B. TABSR ; Stop TAO count 376 00D01A *S4560~ LI LDM 100000100B. TAOMR ; Timer mode. enable pulse output. disable gate function 377 I ; Count source=f(XIN)/2 378 1 .DATA 16 379 00D01D D8 1 CLM ; Data length 16 bits 380 OODO 1E *6~46CF07 LI LDM #2000-1. TAO ; Set counter value 381 1 •DATA 8 382 00D022 F8 I SEM ; Data length 8 bits 383 00D023 *6~7500 Ll LDM 100000000B. TAOIC ; Disable TAO interrupt 38~ 00D026 *04~001 LI SEB 100000001B. TABSR ; Start TAO count 385 I 386 387 1 1 * Hereafter. the phase of output pulse inverts every time timer AO overflows. 388 00D029 60 I RTS 389 I 390 1 225 APPLICATION 7.3 Program examples (2) Timer A ......................... Event counter mode SEQ. LOC. OBJ. .... *.... 1......... 2 .... *.... SOURCE STATEMENT .••• 5.... *.... 6.... *.... 7 .... *.... 8 .••• *.... 9.... *... ' 3S1 I •PAGE 3S2 I 3S3 I ; =========================================== 3S4 I Timer setting example 2 3S5 I [Timer A: Event counter mode] 3S8 I ;============================================== 3S7 I 3S8 I Timer :Timer Al 3SS I Mode : Event counter mode 400 I Pulse output :Disabled 401 I Count phase :Fa11 402 I Up/down SWitch :Content of up/down fiag 403 I 404 00D02A I SUB_T2: 405 I •DATA 8 408 00D02A E224 I SEP m,l ; Data length 8 bits, disabl e interrupt 407 00D02C *140D08 LI CLB #00001000B,P5D ; Set P53/TAIIN Pin to input mode 408 00D02F *144002 L1 CLB #OOOOOOIOB, TABSR ; Stop TAl count 40S 00D032 *845701 L1 LDM #OOOOOOOIB, TAIMR ; Event counter mode, disable pulse output 410 I ; Select falling edge count and up/down flag 411 00D035 *144402 LI eLB #OOOOOOIOB,UDF ; Set to decrement count 412 I •DATA 16 413 00D038 D8 I CLM ; Data length 16 bits 414 000039 *84486300 L1 LDM #100-1, TAl ; Set counter val ue 415 I •DATA 8 416 000030 F8 I SEM ; Data length 8 bits 417 00003E *647803 LI LDM #OOOOOOl1B, TA lIC ; Clear TAl interrupt request bit 418 I ; Enable TAl interrUPt (level 3) 419 00D041 *044002 L1 SEB #000000 lOB , TABSR ; Start TAl count 420 00D044 58 I CLI ; Enable inte'rrupt 421 422 423 I I I * Hereafter, an interrUPt request occurs at every 100 count. 424 00D045 60 I RTS 425 I 428 I 226 APPLICATION 7.3 Program examples (3) Timer A ......................... Two phase pulse processing function SEQ. LOC. OBJ. .... *.... 1. ..• *....2•••. *.... SOURCE STATEMENT .••. 5.... *..•. B...• *•.•. 7 ..•• *.... 8••.• *.... 9•••• *••• 427 1 .PAGE 428 1 429 1 ;===================================================== 430 1 Timer setting example 3 431 1 [Timer A: Two phase pulse processing function] = 432 1 ; ================================================= 433 1 434 1 Timer :Timer A2 435 1 Mode : Event counter mode 436 1 (two phase pulse signal processing function) 437 1 438 00D046 1 SUB_T3: 439 I .DATA 8 440 000046 F8 1 SEM ; Data length 8 bits 441 00D047 *140D30 LI CLB 100110000B,P5D ; Set P54/TA20UT, P55/TA2IN pin to input mode 442 00004A *144004 LI CLB #00000100B, TABSR ; Stop TA2 count 443 00004D *645811 LI LDM 100010001B, TA2MR ; Event counter mode 444 00D050 *644420 L1 LDM #00100000B, UDF ; Select two phase pulse signal processing function 445 1 •DATA 18 446 00D053 D8 1 CLM ; Oata length 16 bits 447 000054 *644A0080 LI LDM #8000H,TA2 ; Set counter va I ue 448 1 •DATA 8 449 000058 F8 1 SEM Data length 8 bits 450 00D059 *B47700 LI LDM #OOOOOOOOB, TA21C Disable TA2 interrupt 451 00D05C *044004 LI SEB #00000100B, TABSR Start TA2 count 452 453 454 1 I I * Hereafter, count is performed with input signals to TA20UT and TA21N pins. 455 00D05F 60 I RTS 456 I 227 APPLICATION 7.3 Program examples (4) Timer A ......................... One·shot pulse mode SEQ. LOC. OBJ. .... *.... 1. .•• *.... 2•••• *.... SOURCE STATEMENT •••• 5•••• *.... 8•••• *.... 7•••• *•••• 8•••• *.... 9 •••• *••• 457 I •PAGE 458 I 459 I ;============================================= 480 I Timer setting example 4 481 I [Timer A: One-shot pulse mode] 462 I ; =============================================== 463 I 464 I -- ----- ------------------- -- ---- ---------- 465 I When internal trigger is selected = 468 I ;------------------------------------------ 467 I Timer :Timer A3 468 I Mode :One-shot pulse mode 469 I Start tr igger :One-shot start flag 470 I (Software trigger) 471 I Count source :f{XIN)/2 472 I 473 000060 I SUB_TU: 474 I •DATA 8 475 000080 F8 I SEM ; Data length 8 bits 476 000061 *144008 LI CLB 100001000B, TABSR ; Stop TA3 count 477 000084 *645906 LI LDM 100000110B, TA3MR ; One-shot pulse mode, software trigger 478 I ; Count source=f{XIN) /2 479 I •DATA 16 480 000067 08 I eLM ; Data lengt,h 16 bits 481 000068 *644CD007 LI LDM 12000, TA3 ; Set counter val ue 482 I •DATA 8 483 00D06C F8 I SEM ; Data length 8 bits 484 000060 *847800 LI LDM #00OOOOOOB,TA3IC ; Disable TA3 interrupt 485 000070 *044008 LI SEB #OOOOIOOOB,TABSR ; Enable TA3 count 486 000073 *844208 LI LDM 100001000B,ONSF ; Generate TA3 one-shot trigger I , 487 488 489 I ; I * Generate one-shot pulse 490 000076 60 I RTS 491 I 492 I 493 I ------------------------------------------ 494 I When external trigger is selected = 495 I ------------------------------------------ 496 I Timer :Timer A3 497 I Mode :One-shot pulse mode 498 I Start tr igger :Fa11 i ng edge of TA3lN 499 I (Hard ware trigger) 500 I Count source :f{XIN)/2 501 I 502 000077 I SUB_T4_2: 503 I •DATA 8 504 000077 F8 I SEM ; Data length 8 bi ts 505 000078 *140080 LI CLB '10000000B,P5D ; Set P57/TA31N Pin to input mode 506 00D07B *144008 LI CLB #OOOOIOOOB, TABSR ; Stop TA3 count 507 00D07E *645916 LI LDM #000101 lOB, TA3MR ; One-shot pulse mode, external trigger 508 I ; Count source=f{XIN/2) 509 I •DATA 18 510 000081 08 I CLM ; Data iength 18 bits 511 000082 *B44CD007 LI LDM #2000,TA3 ; Set counter val ue 512 I .DATA 8 513 00D086 F8 I SEM ; Data length 8 bits 514 00D087 *647800 LI LDM 100000000B, TA3IC ; Disable TA3 interrupt 515 00D08A *044008 LI SEB #OOOOIOOOB, TABSR ; Enable TA3 count 516 I 517 518 * Generate one-shot pulse at falling edge input to TA3lN pin 519 000080 60 RTS 520 I; 521 I; 228 APPLICATION 7.3 Program examples (5) Timer A ......................... PWM mode SEQ. LOC. OBJ. • ........ 1•••• *.... 2•••• *•••• SOURCE STATEMENT •••• 5 ......... 6.... *•••• 7 •••• * .... 8 •••• * •••• 9•••• * ••• 622 .PAGE 523 524 ;=--- ,====--=--- -- - -=========== 525 I; Timer setting example 5 526 I [Tiller A: PWM mode] 627 1;==--=========--============ 628 I ;---------------------------------------- 529 I IS-bit Plr.! = 530 I ---------------------------- ------------ 631 I Timer :Timer M 532 I Mode :PWM mode 533 I Start trigger :Count start flag 534 I (Software trigger) 535 I PIM lIode :IG-bit PWM mode 536 I Count source :f(XIN)/2 537 I 538 00008E I UB_TU: 539 I •DATA 8 540 00008E F8 I SEM ; Data length 8 bits 541 00008P *144010 LI CLB 100010000B. TABSR ; Stop TM count 542 000092 *645A07 LI LDM 'OOOOOlllB. TA4MR ; IS-bit PWM mode. software trigger 643 I ; Count source=f(XIN)/2 544 I .DATA 18 645 000095 os I CLM ; Data length IS bits 646 000096 1644E0007 LI LDr.! l20oo.TM ; Set counter value (output "0" pulse width) 547 I .DATA 8 648 OOOOBA F8 I SEM ; Data length 8 bits 649 00009B *647900 LI LDr.! 100000000B. TA4IC ; Disable TM interrupt 550 00009E *044010 LI SEB lOOOIOOOOB. TABSR ; Start PWM output 551 I 552 553 I I * Generate pulse 554 OOOOAl 60 I RTS 555 I; 55S I 557 I ; ---------------------------- ------------ 558 I S-bit PWM 559 I ; ---------------------------- ------------ 560 I Timer :Timer M 661 I Mode :PWM mode 5S2 I Start trigger :Count start flag 663 I (Software trigger) 564 I PIM mode :S-bi t PWM mode 565 I Count source :f(XIN)/2 5SS I 567 0000A2 I SUB_T5_2: 568 I •DATA S 66B OOOOA2 F8 I SEM ; Data length 8 bits 570 0000A3 *144010 LI CLB 100010000B. TABSR ; Stop TM count 571 OOOOAS *645A27 LI LDM .001001llB. TA4MR ; 8-bit PWM mode. software trigger 572 I ; Count source=f(XIN)/2 573 OOOOAS *644EC7 LI LDr.! 1200-I.TA4L ; Set prescaler value 574 OOOOAC *644FOA LI LDr.! 1I0.TMH ; Set counter value (output "0" pulse width) 575 OOOOAF *647900 LI LDr.I 100000000B. TA4IC ; Disable TM interrupt 57S 0000B2 *044010 LI SEB 100010000B. TABSR ; Start PWM output 677 I; 678 579 I ; I; * Generate pulse 580 0000B5 60 I RTS 681 I 582 I 229 APPLICATION 7.3 Program examples (6) Timer B ......................... Pulse period measurement mode SEQ. LOC. OBJ. •• , .* •••• 1. ... * •••• 2•••• * •••• SOURCE STATEMENT •••• 5 •••• * •••• 6•••• *.... 7•••• * •••• 8 •••• *.... 9•••• * • .'. ' 583 I .PAGE 584 I 585 I ; ========================== ===================== 586 I Timer setting example 6 587 I [Timer B: Pulse period measurement mode] = 588 I ; ============================================= 589 I Timer :Timer BI 590 I Mode :Pulse period measurement mode 591 I (between falling edge and falling edge) 592 I Count source :f(KIN)/64 593 1 594 00DOB6 I SUB_T6: 595 I .DATA 8 596 00DOB6 F8 I SEM ; Data length 8 bits 597 00DOB7 *141040 L1 CLB 101000000B.P6D ; Set P66/TBIIN pin to input mode 598 OODOBA *144040 til CLB 101000000B. TABSR ; Stop TBI count 599 OODOBD *645C82 L1 LDM #IOOOOOIOB. TBIMR ; Pulse period measurement mode 600 I ; Count source=f(XIN)/64 601 OODOCO *647BOO LI LDM 100000000B. TB IIC ; Clear TBI interruPt request bi t 602 I ; Disable TBI interrupt 603 00DOC3 *044040 LI SED 101000000B. TABSR ; Start TBI count 604 00DOC6 I LU6: 605 00DOC6 *347B08FC LI BBC 10000I000B.TBIIC.LI_T6 ; TBI interrupt request bit= "In? 606 I •DATA 16 607 OODOCA D8 I CLM ; Data length 16 bits 608 OODOCB *A552 L1 LDA A.TBI ; Read out measurement resul t in accumulator A 609 I •DATA 8 610 OODOCD F8 I SEM ; Data length 8 bits 611 I 612 I Note: TBI overflow period is assumed to be sufficiently longer 613 I than measured pulse period. 614 1 615 OODOCE 60 I RTS 616 I; 230 APPLICATION 7.3 Program examples (7) Timer B ......................... Pulse width measurement mode SEQ. LOC. OBJ. ......... 1. ........ 2••••••••• SOURCE STATEMENT .... 5•••• *•••• 8•••• * •••• 7......... S••••••••• S•••• *••• 817 •PAGE 81S I; 81S I ;==--======================= 820 I Timer setting eHample 7 821 I [Timer B: Pulse width measurement mode] = 822 I ;===-- ================= 623 I Timer :Timer B2 824 I , Mode :Pulse with measurement mode 825 I ; Count source :f(XIN)/84 626 I; 627 I; * This program is a TB21N input signal '11" level measurement eHample. 828 I; The TB2 overflow period is assumed to be sufficiently longer than 82S I; measured pulse Width. 830 I; 831 OODOCF I SUU7: 632 I •DATA 8 833 OODOCF F8 I SB>! ; Data length 8 bi ts 634 OODODO *141080 LI CLB 110000000B,P6D ; Set P67/TB21N pin to input mode 835 00DOD3 .144080 LI CLB IIOOOOOOOB, TABSR ; Stop TB2 count 636 OODOD6 1645DSA LI LDM 11000IOIOB, TB2MR ; Pulse width measurement mode 837 I ; Count source=f(XIN)/64 838 OODODS .647COO LI LDM 100000000B, TB21C ; Clear TB2 interrupt request bit 83S I ; Disable TB2 interrupt 840 OODODC *044080 LI SEB IIOOOOOOOB, TABSR ; Enable TB2 count 841 OODODF I LLT7: 842 OODODF *240E80FC LI BBS 110000000B,P8,LLT7 ; TB2IN= 't" ? 643 00DOE3 I L2_T7: 844 OODOES *340E80FC LI BBC IIOOOOOOOB, P6,L2_T7 ; TB2IN= '11"? 645 OODOE? *147C08 LI CLB 100001000B, TB2lC ; Clear interrUPt request bi t 846 OODOEA I L3_T7: 647 OODOEA *347C08FC LI BBC 100001000B, TB2IC,L3_T7 ; Interrupt request bi t= "I· ? 648 OODOEE *147C08 LI CLB 'OOOOIOOOB, TB2lC ; Clear interrupt request bi t 84S I •DATA 16 850 OODOFI D8 I CLM ; Data length 16 bits 851 OODOF2 *A554 LI LDA A,TB2 ; Read measurement result 652 I .DATA 8 653 ooDOF4 F8 I SEM ; Data length 8 bits 654 I 855 00DOF5 80 I RTS 856 I 231 APPLICATION 7.3 Program examples 7.3.4 Serial 1/0 modes setting examples (1) 8-bit UART ................... 1 byte receive SEQ. LOC. OBJ. •••• *•••• 1•••• *.... 2•••• *.... SOURCE STATEMENT •••• 5•••• *.... 6•••• *.... 7•••• *.... 8•••• *....9•••••••• 673 •PAGE 674 I; 675 I ;=--==--====--=============== 676 I ; Serial I/O setting example I 677 I ; [8-bit UART (I byte receive)] 678 I ;========================== 679 I ; Channel : UART I 680 I ; Mode :8-bi t UART 681 I ; Stop bit length :1 bit 682 I ; Parity : None 683 I ; Clock : Internal (9600bps) 684 I ; Sleep function :Oisabled 685 I; 686 I; a-bit UART (I byte receive) programming model 687 I; M37702 688 I; +-------+ 689 I; 1 690 I; OATA ---------->1 RxOI 691 I; 1 692 I; <----------1 RTSI 1 693 I; 694 I; +...... ---.. + 695 I; 9600bps 696 I; 697 000800 I SUB_SI: 698 I .OATA 8 699 000800 F8 I SEM ; Data length 8 bits 700 000801 *141440 LI CLB '01000000B.P8D ; Set P86/RXOI Pin to Input mode 701 000804 *643805 LI LOM 100000101B.SIMR ; 8-bit UART. internal clock. I stop bit 702 I ; No parity. disable sleep mode 703 000807 *643C04 LI LDM 'OOOOOIOOB.SI CL ; BRG count source=f(XIN)/2 704 I ; Select RTS function 705 00080A *643919 LI LOM .25.SIBRG ; Set value in BRG (at 9615bps: 8MHz) 706 000800 *643004 LI LOM lOOOOOIOOB.SICH ; Enable receive 707 708 709 I; I; I; * Receive starts when RTS output becomes 't" level to enabl e receive and a start bit is detected. 710 I; 711 000810 I LUI: 712 000810 *343D08FC LI BBC .OOOOIOOOB.SICH.LI_SI ; Receive complete (receive completion flag= "I" )1 713 000814 *34308003 LI BBC IIOOOOOOOB.SICH.L2_S1 ; Check error (error sum flag) 714 000818 2OBA08 LI JSR SUB_ERRO ; Jump to UART receive error processing routine 715 00081B I L2_SI: 716 00081B *A53E LI LDA A.SIRB ; Read receive buffer 717 00D8ID *143004 LI CLB IOOOOOIOOB.SICH ; Disable receive 718 000820 60 I RTS 719 I; 232 APPLICATION 7.3 Program examples (2) a·blt UART ................... 1 byte transmit SEQ. LOC. OBJ. ••••••••• 1••••••••• 2......... SOURCE STATEMENT .... 5•••• *•••• G.... *•••• 7•••• 1 •••• S•••• *.... 9•••• *... 720 .PAGE 721 I; 722 I ;====--==--======================= 723 I ; Serial I/O setting example 2 724 I ; [S-bit UART (1 bfte transmit)] 725 I '================= 726 I Channel :UARTO 727 1 Mode :S-bi t UART 728 1 Stop bit length :1 bit 729 I Paritf :None 730 1 Clock : Internal (B600bps) 731 1 Sleep function :Disabled 732 I 733 1 S-bit UART (1 bfte transmit) programming model 734 1 M37702 735 1 +-------+ 736 1 I 737 I. I TxOO 1----------> OATA 738 1 ; I 739 1 ; CTSO 1<------+ 740 1 ; I 741 I ; -+- GNO 742 I ; +-------+ 743 1 ; 9600bps 744 I; 745 000821 I SUB_S2: 746 1 .DATA S 747 000821 F8 I SEM ; Data length S bits 748 000822 1141401 LI CLB 10000000 lB. PSD ; Set P80/CTSO pin to input mode 749 000825 *643005 LI LDM 100000101B.SOMR ; S-bi t UART. internal clock, 1 stop bit 750 1 ; No pari tf, disable sle~p mode 751 000828 *643400 LI LDM 'OOOOOOOOB,SOCL ; BRG count source=f(XIN)/2 752 I ; Select CTS function 753 000828 *643119 LI LDM 125.S0BRG ; Set value in BRG (at 9Gl5bps; BMHz) 754 00082E 1643501 L1 LDM IOOOOOOOIB. socn ; Enable transmit 755 000831 *A582 1 LDA A.T_DATA ; Read transmit data (T_DATA) 756 000833 18532 LI STA A,SOTB ; Transmit data -+ transmission buffer 757 000835 .143501 LI CLB 10000000lB,SOCH ; Disable transmit 758 000838 60 1 RTS 759 1 ; 233 APPLICATION 7.3 Program examples (3) a·bit UART ................... n·byte transmit SEQ. LOC. OBJ. ••••••••• 1. ••• *....2•••• *.... SOURCE STATEMENT •••• 5•••• *•••• 6•••• *.... 7•••• *.... 8•••• *•••• 9•••• *... 760 .PAGE 761 762 ;======== - .. --============== 763 Serial I/O setting example 3 764 [8-bit UART (n-byte transmit)] 765 ;======================= 766 Channel :UARTO 767 Mode : 8-bi t UART 768 Stop bit length : I bi t 769 I ; Parity : None 770 I ; Clock : Internal (9600bps) 771 I ; Sleep function :Disabled 772 I; 773 I ; 8-bit UART (n-byte transmit) programming model 774 1; M37702 775 1 ; +-------+ 776 I; I 777 1 ; TxDO 1-------> DATA 778 1 ; 779 I; I 780 1; CTSO 1<------- RTS 781 I 782 1; +-------+ 783 1; 9600bps 784 1; 785 I ; ---------------------------- ------------ 786 1; Prepare transmi t 787 1 ; ---------------------------- ------------ 788 1 ; 789 000839 I SUB_S3: 790 I .DATA 8 791 1 .INDEX 8 792 000839 E230 1 SEP m,x ; Data length, index register length 8 bits 793 00D83B *141401 LI CLB 100000001B, P8D ; Set P80/CTSO pin to input mode 794 00D83E *643005 L1 LDt>! lOOOOOIOIB,SOMR ; 8-bit UART, internal clock, 1 stop bit 795 1 ; No parity, disable sleep mode 796 000841 *643400 LI LDM 100000000B,SOCL ; BRG count source=f(XIN}/2 797 1 ; Select RTS function 798 00D844 *643119 L1 LDM 125,SOBRG ; Set value in BRG (at 9615bps; 8MHz) 799 000847 *643501 L1 LDt>! 100000001B,SOCH ; Enable transmit 800 I 801 I ;---------------------------------------- 802 1 Operate transmi t 803 I ;---------------------------------------- 804 1 805 00084A A200 1 LOX #0 80B 00084C I LLSa: 807 00D84C *B582 I LOA ; Read transmit data 808 00D84E *8532 LI STA ; Transmit data ... transmiss ion buffer 809 00D850 1 L2_S3: 810 000850 .343502FC L1 BBC 1I00000010B,SOCH,L2_S3 ; Transmission buffer empty flag= "I n ? 811 00D854 E8 I INX 812 000855 *E480 I CPX ; Compare with transfer data count (DALCNT) 813 000857 00F3 LI BNE ; Continue data transmit? 814 I , 815 I ; ------- --------------------- -------- ---- 816 I Comp lete transmi t 817 1 ; ------- --------------------- -------- ---- 818 I 819 000859 *143501 LI CLB 100000001B, SOCH ; Disable transmit 820 1 821 00085C 60 I RTS 822 1 823 1 ; 234 APPLICATION 7.3 Program exampl.es (4) Clock synchronous .... 1 byte receive SEC. LOC. OBJ. .... *.... 1.... *.... 2.... *.••. SOURCE STATEMENT .... 5•••• *•••• 8.... *.... 7......... 8 •.••••••• 9 .... *.. . 824 I .PAGE 825 I 828 I ; ============================================== 827 I Serial I/O setting example 4 828 I [Clock synchronous (! byte receive)] 829 I ; ========================== ==================== 830 I Channel :UARTI 831 I Mode :Clock synchronous 832 I Clock :External 833 I 834 I Clock synchronous (! byte receive) programming model 835 I M37702 838 I +-------+ 837 I 1 RxOI 1<------- 838 I 1 839 I CLKI 1<------- CLOCK 840 I 1 841 I 1 RTSI 1-------> CTS 842 I 843 I +-------+ 844 I 845 000850 I SUB_S4: 846 I .OATA 8 847 000850 F8 I SEM ; Oata length 8 bits 848 00085E *141480 L1 CLB 101100000B, P80 ; Set P88/RXOI, P85/CLKI input to input mode 849 000881 *643809 LI LDM 10000100lB,SIMR ; Select clock synchronous, external clock 850 000864 *643C04 L1 LOM #OOOOOIOOB,SICL , Select RTS function 851 000887 *643A55 LI LOM #55H,SITB ; Set transmit dummy set 852 853 854 I I I * With clock synchronous serial I/O, the transmitter must be operating even if only recei ve is performed. 855 I 856 00086A *643005 LI LOM 100000101B,SICH ; Enable receive and transmi t 857 I 858 859 I I * Hereafter, receive operation starts when synchronous clock is input to CLKI Pin. 860 I 861 000860 I LLS4: 862 000860 *343008FC LI BBC 100001000B,SICH,LLS4 ; Receive completion fIag= "I"? 863 000871 *3430 I 003 L1 BBC 1000 IOOOOB, SI CH, L2_S4 ; Overrun error? 864 000875 20CID8 L1 JSR SUB_ERR I ; Jump to clock synchronous error processing routine 865 00D878 I L2_S4: 866 000878 *A53E LI LoA A,SIRB ; Read received result 887 00D87A *143005 LI CLB #OOOOOIOIB,SICH ; Disable receive and transmit 888 I 869 000870 60 I RTS 870 I 871 I 235 APPLICATION 7.3 Program examples (5) Clock synchronous .... 1 byte transmit SEQ. LOC. OBJ. ....*.... 1. ... *.... 2•••• *.... SOURCE STATEMENT .... 5•••• *.... 6.... *.... 7.... *.... 8•••• *.... 9.... *... 872 I •PAGE 873 I 874 I ; =============================================== 875 I Serial I/O setting example 5 876 I [Clock synchronous (! byte transmit)] 877 I ; ================================================ 878 I Channel :UARTO 879 I Mode :Clock synchronous 880 I Clock : Internal (2Mbps) 881 I 882 I Clock synchronous (! byte transmit) programming model 883 I M37702 884 I +-------+ 885 I 1 886 I 1 TxDO 1-------> DATA 887 I 1 888 I 1 CLKO 1-------> CLOCK(2Mbps) 889 I 1 890 I CTSO 1<------+ 891 I I 892 I -+- GND 893 I +-------+ 894 I 895 00D87E I SUB_S5: 896 I •DATA 8 897 00087E F8 I SEM ; Data length 8 bits 898 00087F *141401 LI CLB 10000000lB,P8D ; Set P80/CTSO Pin to input port 899 000882 *64300 I LI LDM 10000000lB,SOMR j Clock synchronous, internal clock 900 000885 *643400 LI LDM 100000000B,SOCL ; BRG count source=f(XIN)/2 901 I j Select CTS function 902 000888 *643100 LI LDM 10,SOBRG j Set value in BRG (at 2Mbpsj 8MHz) 903 00088B *64350 I LI LDM 'OOOOOOOIB,SOCH j Enable transmit 904 00D88E *A582 I LDA A,LDATA ; Read transmit data (LDATA) 905 00D890 *8532 LI STA A,SOTB ; Transmit data -+ transmiss ion buffer 906 00D892 *143501 LI CLB 10000000 I B, SO CH j Disable transmit 907 I 908 000895 60 I RTS 909 I 236 APPLICATION 7.3 Program examples (6) Clock synchronous .... n·byte transmit SEQ. LOC. OBJ. • ••• *.... 1.... *.... 2.... *.... SOURCE STATEMENT .... 5.... * .... 6.... *....7 .... *.... 8.... *.... 9.... *... 910 .PAGE 911 912 ;============================================= 913 Serial I/O setting example 8 914 [Clock synchronous (n-byte transmit)] 915 ;========================================== 916 Channel :UARTO 917 Mode :Clock synchronous 918 Clock : Internal (2Mbps) 919 920 Clock synchronous (n-byte transmit) programming model 921 M37702 922 +-------+ 923 1 TxDO 1-------> DATA 924 1 925 1 1 CLKO 1-------> CLOCK(2Mbps) 92S I 1 927 1 CTSO 1<------- RTS 928 I 929 I +-------+ 930 I 931 I ---------------------------------------- 932 1 Prepare transmi t 933 I ------- -- --- ---------------- --- --------- 934 1 935 000896 1 SUB_SS: 936 1 .DATA 8 937 I .INDEX 8 938 000896 E230 I SEP x,m ; Data length, index register length 8 bits 939 000898 *141401 L1 CLB 100000001B,P8D ; Set P80/CTSO pin to input mode 940 00089B *643001 Ll LDM 100000001B, SOMR ; Clock sYnchronous, internal clock 941 00D89E *643400 LI LOM 100000000B,SOCL ; BRG count source=f(XIN)/2 942 I ; Select CTS function 943 0008AI *643100 LI LOM 10 , SOBRG ; Set value in BRG (at 2Mbps; 8MHz) 944 0008M *643501 LI LOM 100000001B,SOCH ; Enable transmit 945 I 946 I ---------------------------------------- 947 1 Transm i t data 948 I ------- ------------------- -- ------- ----- 949 I 950 0008A7 A200 1 LOX 10 951 00D8A9 1 LLSS: 952 0008A9 *B582 I LDA A,LDATA,X ; Read transmit data 953 0008AB *8532 LI STA A,SOTB ; Transmit data ..... transmiss ion buffer 954 0008AO I L2_SS: 955 00D8AD *343502FC Ll BBC 100000010B ,SOCH, L2_S6 ; Transmission buffer empty? 95S 0008Bl E8 1 INX 957 0008B2 *E480 I CPX DALCNT ; Compare with trasfer data count (OAT_CN!) 958 0008B4 DOF3 LI BNE LLS6 ; Continue data transmit? 959 I 960 1 ------- --------------------- --------- --- 9S1 I Complete transmit 9S2 I ------- ------ --------------- -- ---------- 963 1 964 0008BS *143501 LI CLB 100000001B,SOCH ; Disable transmit 965 I 96S 0008B9 60 1 RTS 967 I 237 APPLICATION 7.3 Program examples (7) Error processing SEQ. LOC. OBJ. • ••• * •••• 1. ••. lI< •••• 2•••• lI< •••• SOURCE STATEMENT •••• 5 •••• lI< •••• S•••• lI< •••• 7•••• lI< •••• 8 •••• lI< •••• 9•••• lI< ••• 968 I •PAGE 969 I 970 I ; ============================================ 971 I Serial 1/0 setting example 7 972 I [Error proCeSSing] 973 I ; ============================================== 974 I 975 I ------- --- ------------- ----- ------------ 976 I UART ,receive error processing 977 I ---------------------------- ------------ 978 I 979 00D8BA I SUB_ERRO: 980 I 981 I Check error type (overrun, framing, parity) 982 I 983 1 Each error processing 984 1 985 1 986 00D8BA *143D04 LI CLB #00000 100B, SI CH ; Disable receive 987 I ; (Clear error flag) 988 00D8BD *043D04 LI SEB #OOOOOIOOB,SICH ; Enable receive 989 00D8CO SO I RTS 990 I 991 1 ------- --------- - --- ----- --- ---------- ---- -- -- - ---- 992 1 Clock synchronous receive error processing = 993 1 ------- ------------- -------- --- -------- - ---- -- - ---- 994 1 995 00D8CI I SUB_ERR 1: 996 I 997 I Overrun error processing 998 I 999 1 1000 1 1001 00D8CI *143D04 LI CLB #OOOOOIOOB,SI CH ; Disable receive 1002 I ; (Clear error flag) 1003 00D8C4 *043D04 L1 SEB #OOOOOIOOB,SI CH ; Enable receive 1004 I 1005 00D8C7 60 I RTS 1006 I 238 APPLICATION 7.3 Program examples 7.3.5 A-O conversion modes setting examples (1) One-shot mode SEQ. LOC. OBJ. .... *.... 1. ... *•••• 2 •••• *•••• SOURCE STATEMENT •••• 5•••• *•••• 6•••• *.... 7 .••• * •••. 8•••• *•••• 9 •••• *••• 1018 I •PAGE 1019 I 1020 I ;============--=================================== 1021 I A-D conversion setiing example I 1022 I [A-D conversion (one-shot mode)] 1023 I ; ========================== ==================== 102~ I A-D conversion mode :One-shot mode 1025 I Analog input Pin :ANO 1026 I Start trigger :Software trigger 1027 I A-D conversion frequency: f(XIN) /4 1028 I 1029 OOEOOO I SUB_ADI: 1030 I •DATA 8 1031 OOEOOO F8 I SEM ; Data length 8 bi ts 1032 OOEOOI *1~1l01 LI CLB 10000000lB,P7D ; Set P70/ANO pin to input mode 1033 OOEOO~ *6~ IE80 LI LDM #IOOOOOOOB,ADCON ; One-shot mode, software tr igger, 103~ A-D conversion frequency =f(XIN)/4 1035 00E007 *6~7000 LI LDM 100000000B, AD IC ; Clear A-D interrupt request bit, disable A-D interrupt 1036 OOEOOA *041E40 LI SEB 101000000B , AD CON ; Start A-D conversion 1037 OOEOOD I L_ADl: 1038 OOEOOD *347008FC LI BBC 100001000B,AD IC, L_ADI A-D conversion complete (interrupt request bit= "I n )? 1039 OOEOll *147008 LI CLB 100001000B,ADIC Clear A-D interrupt request bit 1040 00EOl4 *A520 LI LDA A,ADO Read conversion result (A-D register 0) 1041 00EOl6 60 I RTS 1042 I 239 APPLICATION 7.3 Program examples (2) Repeat mode SEQ. LOC. OBJ. .... *.... 1. ••• *.... 2•••• * •••• SOURCE STATEMENT. ••• 5•••• *.... 8•••• *.... 7•••• *.... 8•••• *.... 9•••• * ••• 1043 I •PAGE 1044 I 1045 I ;============================================== 1048 I A-D conversion setting example 2 1047 I [A-D conversion (repeat mode)] 1048 I ; ============================================== 1049 I A-D conversion mode :Repeat mode 1050 I Analog input pin :ANI 1051 I Start trigger :Software trigger 1052 I A-D conversion frequency :f{XIN)/4 1053 I 1054 00EOl7 I SUB_AD2: lOSS I • DATA 8 1058 00EOl7 F8 I SEM ; Data length 8 bits 1057 00EOl8 *141102 Ll CLB '000000IOB.P7D ; Set P71/ ANI pin to input mode 1058 OOEOIB *841E89 LI LDM '1000100IB.ADCON ; Repeat mode. software tr igger. 1059 A-D conversion frequency =f{XIN)/4 1080 OOEO I E *041 E40 LI SEB #OIOOOOOOB.ADCON ; Start A-D conversion 1081 I 1082 1083 I I * After time equal to A-D conversion interval (28.5/lS; at the latest 8MHz). conversion result can be obtained by reading A-D register I at any timing. 1084 I 1085 00E021 80 I RTS 1088 I 240 APPLICATION 7.3 Program examples (3) Single sweep mode SEQ. LOC. OBJ. .... * .... 1.... *.... 2.... *.... SOURCE STATEMENT •••• 5.... *.... 6.... * .... 7.... * .... 8 .... *.... 9 .... *... 1067 I .PAGE 1068 I 1069 I ;============================================ 1070 I A-D conversion setting example 3 1071 I [A-D conversion (single sweep mode)] 1072 I ;========--=========================== 1073 I A-D conversion mode :Single sweep mode 1074 I Analog input pin :ANO-AN5 1075 I Start trigger :External trigger 1076 I A-D conversion frequency :f(XIN)/4 1077 I 1078 00E022 I SUB_AD3: 1079 I •DATA 8 1080 00E022 F8 I SEM ; Data length 8 bits 1081 00E023 *1411BF LI CLB 110111111B.P7D ; Set ANO-AN5. ADTRG pins to input mode 1082 00E026 *641 F02 LI LDM 100000010B.ADSPS ; Select ANO-AN5 pin for sweep 1083 00E029 *641 EBO LI LDM 110110000B.ADCON ; Single sweep mode. external trigger. 1084 A-D conversion frequency =f(XIN)/4 1085 00E02C *647000 LI LDM 100000000B. AD IC Clear A-D conversion request bit. disable A-D interrUPt 1086 00E02F *041E40 LI SEB 101000000B.ADCON Enable A-D conversion 1087 I 1088 1088 I I * A-D conversion starts at fall ing edge input to ADTRG Pin. 1090 00E032 I L_AD3: 1091 00E032 *347008FC L1 BBC 100001000B.AD IC. L_AD3 ; Sweep complete (interrupt request bi t= "I" )? 1092 00E036 *147008 L1 CLB 'OOOOIOOOB.ADIC ; Clear A-D interrupt request bit 1093 1094 1095 I I I * Conversion result can be obtained by reading A-D registers 0-5. Then. A-D conversion is resumed when falling edge is input to 1096 I ADTRG pin. 1097 I Clear A-D conversi on start flag to "I" if reconversion is no necessary. 1098 I 1099 00E039 60 I RTS 1100 I 241 APPLICATION 7.3 Program examples (4) Repeat sweep mode SEC. LOC. OBJ. .. .. *.... 1.... *....2.... *.... SOURCE STATEMENT •••. 5 •••• lI< .... 8.... *.... 7.... *.... 8.... *.... 9.... *... 1101 I •PAGE 1102 I 1103 I ;============================================= 1104 I A-D conversion setting example 4 1105 I [A-D conversion (repeat sweep mode)] 1108 I ;=========================================== 1107 I A-D conversion mode :Repeat sweep mode 1108 I Analog input Pin :ANO-AN7 1109 1 Start trigger :Software trigger 1110 1 A-D conversion frequency :f(XlN)/4 1111 1 1112 00E03A 1 SUB_AD4: 1113 1 •DATA 8 1114 00E03A F8 1 SEM ; Data length 8 bits 1115 00E03B *841100 L1 LDM 100H,P7D ; Set ANO-AN7 Pins to input mode 1118 00E03E *841 FOS L1 LDM 100000011B,ADSPS ; Select ANO-AN7 pins for sweep 1117 00E041 *841 E98 Ll LDM lI0011000B,ADCON ; Repeat sweep mode, internal trigger, A-D conversion frequency =f(XIN)/4 1118 OOE044 *041 E40 LI SEB 101 OOOOOOB, ADCON ; Start A-D conversion 1119 1 1120 1121 1 1 * After the first A-D sweep at 8MHz), the (228Ils; latest conversion result can be obtained by reading 1122 I A-D registers 0-7 at any timing. 1123 1 1124 00E047 80 I RTS 1125 242 APPLICATION 7.3 Program examples 7.3.6 Interrupt processing examples (1) Interrupt setting example SEQ. LaC. OBJ. .... *.... 1.... *.... 2•••• *.... SOURCE STATEMENT .... 5.... *.... 6 .... *.... 7•••. *.... S.... *.... s.... *... 1133 1 •PAGE 1134 1 ;================================================ 1135 1 Interrupt setting example 1136 1 ; =====================::;======================= 1137 1 113S 1 In order to execute an interrUPt, the I flag 1139 1 must be cleared within the main routine and 1140 1 interrupt priority level must be set to level 1141 1 or greater in each interrUPt control register. 1142 1 1143 OOESOO 7S 1 SEI ; The I flag is initialized to "1 n after reset. 1144 1 1145 1 1146 1 •DATA 1147 OOESOI FS 1 SEM 114S 00ES02 *14100S Ll CLB #OOOOIOOOB,PBD ; Set PB3/INTI pin to input mode 1149 OOES05 *647E02 L1 LDM #000000108, INTI IC ; Set INTI interrupt priority level to level 2 1150 OOESOS 5S 1 eLI ; Enable interrUPt 1151 1152 1153 I 1 I * Hereafter, INTI interrUPt request occurs with input signa I to INTI pin. 243 APPLICATION 7.3 Program examples (2) Interrupt routine processing example ............ When memory space is 64K bytes or less. SEQ. LOC. OBJ. .., .* .... 1. ... *.... 2.... *.... SOURCE STATEMENT ••.• 5.... *.... 6 .... *.... 7•••• *.... 8.... *.... 9.... *... 1154 I •PAGE 1155 I 1156 I ; ================================================ 1157 I Interrupt routine processing example I 1158 I When memory space is 64K bytes or less = 1159 I (When data bank need not be changed) 1160 I ; =============================================== 1161 I 1162 00E809 I INTERRUPT_I: 1163 I ---- --- ---------------- --- -- - --- -- - ----- 1164 I Store registers 1165 I ---------------------------- ------------ 1166 I 1167 I .DATA 16 ; Register model declaration 1168 I • INDEX 16 1169 00E809 C230 I CLP m,x ; Data length, index register length 16 bits 1170 00E80B EBOD I PSH X,Y,A ; Store registers 1171 I 1172 I •DATA ; Change register model 1173 I • INDEX 1174 00E80D E230 I SEP m,x ; Data length, index register length 8 bits 1175 I 1176 I 1177 I Interrupt processing 1178 I 1179 I 1180 I ---------------------------- ------------ 1181 I Restore registers 1182 1183 1184 •DATA 16 ; Change register mode 1185 • INDEX 16 1186 00E80F C230 CLP m,x Data length, index register length 16 bits 1187 00E811 FBOD PUL X,Y,A Restore registers X, Y, A 1188 1189 1190 Return from interruPt processing routine = 1191 1192 1193 OOESI3 40 RTI ; Return to processing before interrupt 1194 1195 1196 * The PS, PG, and PC are restored automatically to their values before the interrupt with the RTI instruction. 1197 244 APPLICATION 7.3 Program examples (3) Interrupt routine processing example ............ When memory space exceeds 64K bytes. SEQ. LOC. 08J. .... *.... 1••••••••• 2•••• *.... SOURCE STATEMENT •••• 5•••• *.... 6•••• *....7•••• *.... 8 ••••••••• 9•••• *... 1198 •PAGE 1199 1200 ;=======----====================== 1201 Interrupt routine processing example 2 1202 When memory space exceeds 64K bytes 1203 (When data bank is changed) 1204 ;=--==--=====--================ 1205 1 ; 1206 00E814 1 lNTERRUPT_2: 1207 1 ;---------------------------------------- 1208 1; Store registers 1209 1 ;---------------------------------------- 1210 1; 1211 1 •DATA 16 ; Register model declaration 1212 1 • INDEX 16 1213 00E814 C230 1 CLP m,x ; Data length, index register length 16 bits 1214 00E818 EBOD 1 PSH X,Y,A ; Store registers 1215 00E818 88 1 PHT ; Store data bank register 1216 1 •DATA 8 ; Change register model 1217 1 • INDEX 8 1218 00E819 E230 1 SEP m,x ; Data length, index register length 8 bits 1219 1 .DT 0128 ; Declare data banks used for interrupt processing 1220 00E818 89C212 1 LOT 10128 ; Set data bank registers used for interrupt processing 1221 1 1222 1 1223 1 Interrupt processing 1224 1 , 1225 1; 1226 1 ;---------------------------------------- 1227 1; Restore registers 1228 1 ;---------------------------------------- 1229 1 ; 1230 00E81E AB 1 PLT ; Restore data bank registers 1231 1 .DATA 16 ; Change register model 1232 1 • INDEX 16 1233 00ES11' C230 1 CLP m,x ; Data length, index register length 16 bits 1234 00ES21 1'800 1 PUL X,Y,A ; Restore registers X, y, A 1235 1; 1236 1 ; ---------------------------- ------------------ --- 1237 I ; Return from interrupt processing routine = 1238 1 ;------------------------------------------------- 1239 1 1240 00E823 40 1 RTI ; Return to processing before interrupt 1241 1 1242 1243 1 * The PS, PG. and PC are restored automatically to their va lues before the interrUPt with the RTi instruction 1244 245 APPLICATION 7.3 Program examples 7.3.7 Watchdog timer setting examples SEQ. LOC. OBJ. .. .. *.... 1.... *.... 2.... *.... SOURCE STATEMENT .... 5.... *.... 8.... *.... 7.... *.... 8 •••• *....9 .... *... 1254 1 •PAGE 1255 1 1258 1 ; ============================================= 1257 1 Watchdog timer setting example 1 1258 1 [Watchdog timer write routine] 1259 1 ;================================================ 1280 1 '1'FFH" is set in watchdog timer by writing 1281 1 to watchdog timer (80H) 1262 1 1283 OOFOOO 1 WDT_SET: 1284 OOFOOO 08 1 PHP ; Store PS 1265 00F001 F8 1 SEM ; Data length 8 bits (note) 1286 00F002 *8580 L1 STA A,WDT ; Write to watchdog timer 1267 00F004 28 1 PLP ; Restore PS 1268 00F005 60 1 RTS 1268 1 1270 1 ; Note: The address following the watchdog timer 1271 1 contains the watchdog timer frequency 1272 1 selection flag. Therefore, be careful not 1273 1 to change this value when acceSSing the 1274 1 watchdog timer in 16-bit unit. 1275 1 1276 1 1277 1 ; ===================================================== 1278 1 Watchdog timer setting example 2 1278 1 [Watchdog timer interrupt processing example] = 1280 1 ; ===================================================== 1281 1 In this example, a software reset is performed 1282 1; when a watchdog timer interruPt is generated. 1283 1 1284 00F008 1 WATCH_DOG: 1285 1 .DATA 8 1288 OOF006 F8 1 SEM 1287 OOF007 *045E08 L1 SEB aOOOOIOOOB,PMR ; Software reset 1288 OOFOOA 40 1 RTI 1288 1 246 APPLICATION 7.3 Program examples 7.3.8 Software timer setting examples SEQ. LOC. OBJ. .... *.... 1•••• *....2•••• *.... SOURCE STATEMENT •••• 5•••• *.... 6•••• *.... 7•••• *.... 8•••• *.... 9•••• *... 1296 •PAGE 1297 129S ;==--=====================--================ 1299 Software timer examples 1300 ;=========================== 1301 ; Note: The wait time in the following subroutine depends 1302 on the operating frequency and external bus 1303 width of the microcomputer. 1304 The following routine assumes single-chip mode 1305 1306 1307 . with external input clock frequency at SMHz. 1 ;================================ 130S I ; 10 /lS wai t routine 1309 I ;=============================== 1310 1; 1 ,pcyc=250ns at f(XIN)=SMHz 1311 1; 1312 00F800 1 WITlO: 1313 1 •DATA 8 1314 OOFSOO FS 1 SEM 2 ,pcYC 1315 OOFSOI S94920 1 RLA 132 6+32 ,pcyc 1316 1 1317 1 ; Total 40 ,pCYC 131S 1; 1319 1 ;=========================== 1320 1; 50/ls wait routine 1321 1 ;============================== 1322 1; 1 ,pcYc=250ns at f(XI N)=SMHz 1323 1; 1324 00FS04 1 WIT50: 1325 1 •DATA 8 1326 00FS04 FS 1 SEM 2 ,pcYC 1327 00F805 8949CO 1 RLA 1192 6+192 ,pCYC 1328 1 1329 1 Total 200 ,pcYC 1330 1 1331 1 1332 247 APPLICATION 7.3 Program examples 7.3.9 Interrupt vector table setting example SEQ. LOC. OBJ. .. ,.*.... 1. ... *.... 2.... *.... SOURCE STATEMENT .... 5.... *.... 6.... *.... 7.... *.... 8•••• *.... S.... *... 1358 .PAGE 'INTERRUPT VECTOR TABLE' 1359 13S0 ;======================================================== 13S1 Interrupt vector tabl e 13S2 ;=========================== ============================ 13S3 13S4 •SECTION VECTOR_AREA 13S5 .ORG OFFDSH 136S OOFFDS 0000 L .WORD INLAD ; A-D conversion interrUPt vector 1367 00FFD8 0000 L .WORD INLSlT ; UARTI transmission interrupt vector 1368 OOFFDA 0000 L •WORD INLSlR ; UARTI recei ve interrUPt vector 1369 OOFFDC 0000 L •WORD INLSOT ; UARTO transmission interrupt vector 1370 OOFFDE 0000 L •WORD INLSOR ; UARTO recei ve interrupt vector 1371 DOFFED 0000 L •WORD INT_ TB2 ; Ti mer B2 interrupt vector 1372 00FFE2 0000 L •WORD INLTBI ; Timer BI interrupt vector 1373 00FFE4 0000 L •WORD I NLTBO ; Timer BO interrupt vector \ 1374 OOFFES 0000 L •WORD INT _TM ; Timer A4 interrupt vector 1375 00FFE8 0000 L .WORD 'INT3A3 ; Timer A3 interrupt vector 1376 OOFFEA 0000 L •WORD INLTA2 ; Timer A2 interrupt vector 1377 OOFFEC 0000 L .WORD INUAI ; Timer Al interrupt vector 1378 OOFFEE 0000 L •WORD INLTAO ; Timer AO interrupt vector 1379 OOFFFO 0000 L .WORD INT2 ; INT2 interrupt vector 1380 00FFF2 0000 L .WORD INTI ; INTI interrupt vector 1381 00FFF4 0000 L .WORD INTO ; INTO interrUPt vector 1382 OOFFFS 0000 L •WORD INUDT ; Watchdog timer interrupt vector 1383 00FFF8 0000 L •WORD RESERVED ; (Reserved area) 1384 OOFFFA 0000 L •WORD INURK ; BRK instruction interrupt vector 1385 OOFFFC 0000 L •WORD INUIVO ; Zero divide interrupt vector 1386 OOFFFE COOO L •WORD INITIAL ; Res,et vector 1387 248 APPLICATION 7.4 M37702 group execution performance 7.4 M37702 group execution performance The execution performance of the M37702 group is described below. 7.4.1 Comparing the execution speed of M37702 and M37700 One of the differences between the M37702 group and the M37700 group is the difference in the external area access operation while a software one-wait caused by the wait bit is valid (see Figure 7.4.1). The difference in program execution speed due to this difference in access operation is described below. Figure 7.4.3 compares the execution time of the M37702 group and M37700 group when executing two sample programs shown in Figure 7.4.2 under the conditions shown in Table 7.4.1 and the same clock frequency. Figure 7.4.3 shows that the M37702 group is much faster when accessing an external area while software one-wait is valid. This result depends on the frequency of the access and the difference increases as the access frequency increases. The effect for microprocessor mode using an 8-bit external bus appears in Figure 7.4.3. Table 7.4.1 M37702 group and M37700 group execution speed comparison conditions Parameter Conditions Operating mode Microprocessor mode External bus width 16 bits or 8 bits Software one-wait Valid Program area External EPROM Work area External or internal SRAM No software one-wait - rI r- (wait bit = "1 ") E -I : I---J. : E~ Software one-wait valid - (wait bit = "0") E -l H .... '" L--..J ....r - E j ····1 ········r Fig. 7.4.1 Effect of wait bit on external area access 249 APPLICATION 7.4 M37702 group execution performance Sample program A Sample program B SEP M, X SEP X LDA. B A, #0 CLM STA A, DEST+64 · DATA 16 STA A, DEST+65 INDEX 8 STA A, DEST+66 LDY #69 LDX. B #63 LOOPO: LDX #69 IT.(I.LIC: LDA A, SOUR, X LOOP1: ASL SOUR, X TAY SEM AND. B A, #OOOOOO11B · DATA 8 STA A, DEST, X ROL SOUR+2, X TYA ROL B AND. B A, #00001100B CLM ORA A, DEST+1, X · DATA 16 STA A, DEST+1, x ROR A TYA DEX AND. B A, #00110000~ DEX ORA A, DEST+2, x DEX STA A, DEST+2, x BNE LOOP1 TYA STA A, DEST, Y AND. B A, #11000000B SEM ORA A, DEST+3, x · DATA 8 STA A, DEST+3, X STA B, DEST+2, Y DEX CLM BPL ITALIC · DATA 16 DEY DEY DEY BNE LOOPO *SOUR, DEST: Work area Fig. 7.4.2 Sample program list 250 APPLICATION 7.4 M37702 group execution performance Execution speed for sample program A 1.00 1.00 .' 0.60 f-:~·:i(\- 1--f--l~"~"}1- I-- ~~~1t~' :=~t 0.40 ' ...:.... 0.20 ::':.::: ~:~)~.' ~.' '. ,:~".',.': .'~'.'.:..•.,~ ': O.OO+-..J..li,",,-,--l_...l--+--L..O:..O.L.-1-_.L...--t :t~~~:'!~ Work area Internal RAM Work area External RAM = = External 16-bit bus width External 8-bit bus width Execution speed for sample program B .------------------------------.~----------------------------~ 1.00 1.00 1.00-.--,.;;1.;;;00;..-------,--...;1;,:.0:;;,0,----. :::',:':':. 091 ;.:<:':~ 0.80 ,.;:.~:;':.~.2;.:' ~:,':.I--I-r=.;.i~-t---1il:;lii::;r--~~ ~,r ~,:: : ; . ' . : :!.::'·.:;·.:::,:' ... .... ...•' .'.. ....• : .. .. 0.60 Onu 0040 0.20 :=.,~:.,·.'.....~.:.:,~.~::~ =.,r. .,'.•..,.'. .' :.: .,' ,.;j. .,:•.,:.:'.:.;:.:• o.00+--'-''''''''--'-...1.--t----'w.;..WL.-.L..-'-----l Work area = Internal RAM Work area = External RAM .~l.'i;:' I - 1--+---1,::-:;,:: :.: - .JU II I--- Work area = Internal RAM Work area = External RAM External 16-bit bus width External 8-bit bus width Iff>] M37700 o M37702 Fig. 7.4.3 Execution speed comparison of M37702 group and M37700 group 251 APPLICATION 7.4 M37702 group execution performance 7.4.2 Software one·wait (20MHz) and software+hardware walt (25MHz) execution speed comparison The program execution time is for M37702 group operating at 20MHz with software one-wait and M37702 group operating at 25MHz with software one-wait and RDY (hardware wait). Figure 7.4.4 shows the execution time when two sample programs (see Figure 7.4.2) are executed under the conditions shown in table 7.4.2. Table 7.4.2 Software one·walt (20MHz) and software+hardware wait (25M Hz) execution speed comparison Parameter Conditions of software one-wait side Conditions of software + hardware side Operating mode Microprocessor mode (- Clock frequency 20MHz 25MHz External bus width 16 bits (- Software one-wait Valid (- RDY (hardware wait) Invalid Valid only in external EPROM area Program area External EPROM (- Work area External or internal SRAM (- In both cases, the M37702 group is used in microprocessor mode with 16-bit external bus and program stored in external EPROM. One wait is inserted for external memory access because software one-wait is used. In addition, RDY is used for external EPROM access during 25MHz operation for a total of two waits (RDY is invalidated for access of external RAM used for work area). Figure 7.4.5 shows the memory map during execution speed comparison. M37702 memory map SFR area Internal SRAM I-----------------i"'/ Specify which of two for work area. External SRAM Software one-wait is valid in this area. Program area RDY is valid in this area at 25M Hz. ] (Two waits are inserted at accessing.) External EPROM ~--------------~ Fig. 7.4.5 Memory map during execution speed comparison 252 APPLICATION 7.4 M37702 group execution performance Figure 7.4.4 shows that the difference in execution speed is small between 20MHz operation with software one-wait and 25MHz operation with software one-wait and RDY. 20MHz operation with software one-wait provides better cost performance because the use of specified memory eliminates the need for a bus buffer. Execution speed for sample program A Execution speed for sample program B 1.10-:r----- 1 0 4 - - . - - - - - - - , 1.10-:r-----~ 1.00 -:..... 1 .00 1.01 1.00+-_,.,,1;;;:.0;;;,0-1 1.00 ~ 1.00+--"""m",;;;',.-I 1--1-......,.,,;,;;,;;,-,,-,,--1 ~?\t~~ (';:>J r---- : : =~jt1~ = ~~):. ;":",;:;t 0.90 r---- :.:;<:- 1--1--1:;/.- 0.90 r---- .. :'.:- 1--l---f;;li: r- r---- ::=~= I--I---£,~~! I--l---f:~'-> ..:'::.,' .- ~ij~r- t-- 1--I---t:tJ\?: f- I-- 0.60 r---- :.i;61- {,:~~:.- r---- 0.60 r---- ·,;"8'- ~. : ":"-:" r- r---- 0.50 r---- ~;~\:- 1---1--1 "'~r'- r---- 0.50 r---- :1iiij,- .:'::~"':- 1--I--rYY« r- t~:;t r---- 040 r---- ,'j;'-}.- I--I----I!~.:::.} - r---- 0040 - i)f:~~::- I---l---{t\~· f - t-- :~:=i= . :.':::., .....:;:.~:;" 1--+---i~:~iW - r---- 0.30 - ':f.?1f._ I--I--f:@§r-r---- 1--1----1,':;::.. : , - r---- 0.20 -:;~jl- 1--+--I:1:;j;r- - r---- 1-~--ttj;2~r- - I--+--i.::;;:::::;::~ 0.10 -~~t[iE- ~~~~: 0.00 0.00 Work area = Internal RAM Work area = External RAM Work area = Internal RAM Work area = External RAM !Z3l 25MHz with hardware and software one-wait o 20MHz with software one-wait Fig. 7.4.4 Software one·wait (20MHz) and software+hardware wait (2SMHz) execution speed comparison 253 APPLICATION 7.4 M37702 group execution performance MEMO 254 ©O=O~~u~~ ® PROM VERSION 8.1 Product expansion 8.2 M37702E2-XXXFP 8.3 Usage precaution PROM VERSION 8.1 Product expansion 8.1 Product expansion Internal PROM (programmable ROM) version has the following 2 types: .One time PROM version ....................... Possible to write program in ROM once . • EPROM version ...................................... Possible to rewrite program in ROM because a written program is erased by exposing the erase window on top of the package to an ultraviolet light source. Table S.1.1 shows the product expansion of internal PROM version Table 8.1.1 Product expansion of internal PROM version Type name I ROM i RAM I Clock frequency Writing adapter M37702E2-XXXFP SMHz M37702E2AXXXFP One time PROM 16K bytes 16MHz PCA4774 M37702E2BXXXFP 25MHz 512 bytes M37702E2FS SMHz , M37702E2AFS EPROM 16K bytes 16MHz PCA4708 M37702E2BFS --------- ----_. --- - - ----- --- ---- "-"- 25MHz M37702E4-XXXFP 8MHz M37702E4AXXXFP One time PROM 32K bytes 16MHz PCA4774 M37702E4BXXXFP 25MHz M37702E4FS 2048 bytes 8MHz M37702E4AFS EPROM 32K bytes 16MHz PCA4708 M37702E4BFS 25MHz 256 PROM VERSION B.2 M37702E2-XXXFP 8.2 M37702E2-XXXFP The following descriptions will be for M37702E2-XXXFP. Internal PROM version has the same functions as M37702E2-XXXFP unless otherwise noted. 8.2.1 Description The M37702E2-XXXFP is a single-chip microcomputer designed with high-performance CMOS silicon gate technology, and has the same functions as M37702M2-XXXFP except that PROM is built in. Since general purpose PROM writers can be used for the built-in PROM, this microcomputer is suitable for small quantity production runs. Figure 8.2.1 shows the M37702E2-XXXFP pin configuration. P7a/ANa _ 1 P67iTB21N _ P66iTB11N _ 2 3 0 0 +~ PS4/CTSl/RTSI PSs/ClKI PS6/RxOI P65iTBOIN _ 4 P6411NT2 _ P6311NTI _ P62iINTa _ 5 7 :s: (,.) PS7iTXOI POa/Aa POl/AI P02iA2 P61iT A41N _ s ....... P03/A3 P6aiT A40UT _ P57iTA31N _ P56iTA30UT _ 9 11 "'-I 0 I\) -- P04/A4 P05/A5 +~ POS/A6 P55iTA21N - P54iT A20UT _ P53iTA11N_ 14 P52iTA1oUT _ 12 13 15 m I\.) D - P07/A7 P1 a/As/Os P11/Ag/Og -<+ P12/A1O/01O P51iTAOIN +~ 16 >< P13/Al1/011 P5aiT AOOUT _ 17 >< P14/AI2i012 P15/A13/013 >< 'TI P16/A14/014 P17/A15iD15 P2o/A16/0o "'C P21/A17/01 P22iA1S/02 0 P23/A19iD3 ~ t tt tt ~~~~~~~~ 10a w\:= >~Ir,~ ~ 0~IW >~I~g ~>~>~~~~ ~ IV) ~ 0 0 0 0 !--.JXx 0 0 ltttttt ~ ttll foI Rfilfil fcifsl[i'4]P;] p'lr 'I yollooll"II"II"Ii"1 P7o/ANo....--.. g ~+-+ P841CTS,/RTS' P67n"S21N ..-. g ~+-+ P8';CLK, P6efT81IN ++ P6sfT~~ _ P64llNT2 ++ § g +-+ 1+-+ G1 P8G/RxD, P87fTxDI PQntAo '7W P63/iNil .-.... ~:: PO,/A. ~ P621iNTo ... -~ ~ s: ~..-. P02iA, ~ P61ffA41N ... -~ ~ P6ofTA4oUT ...... P57ffA31N .-.. i '" -..J ~.--.. PO>'A3 ~ ... - ... P04lA4 tTs . .-.. PO,;As ~ ~ P5,fTA30UT +-+ ~ PSsffA21N ++ ~ -..J 0 I\) ~ ...... POG/A, P07/A7 ~ ~ P54fT A20UT ++ ~ m ~:: PWAoID, ~ I\) ~ P5J1TA11N ~ ~ X ~ - P11/A9ID9 A, ~ P5:iffA1our .......... F15 ~ ...... P12iAIOID" , P5.fTAOIN ...... ~ X 1# ++ P13"Al1JDll , P50fTAOOUT -.... f# X ~..- P141A12/D12 , "T1 ~++ P1,;AtJlD,3 , ~:::: ~ "tI F.¥:-P1GIA141D14 , P4s- ~ ~++ P17/A1S/015 P44 ++ ~ P43-~ bm- bill- P201AIG/D'~ P21/A17/Dl 01 p~++~ ~ ... - ... P22iAIO/D, D P41/RDY-' ~ ~++ P2>'AJ9/D, D, ~ ~ p711"1~9Ip~I' I11J2IiJJlp4j ~ p'IP7Ip'lp91~ol li tt~~ tttttttt rw·r~~~·rwr~B8~a ..Jt;:>WXO >O..JI-fji!J __ !·~·11 %~~~~~~~ 0.. 0.... D.... n. a.. a. 0.. ~ (' Jm DO 0 0 Outline 80P6N *: Connect to ceramic oscillating circuit. 0: Same function as EPROM (M5M27C256K). Fig. 8.2.2 Pin connections in EPROM mode 260 PROM VERSION 8.2 M37702E2-XXXFP 8.2.3 Fast programming algorithm To program the M37702E2-XXXFP using a fast programming algorithm, first set Vcc=6V, Vpp=12.5V, and address to 016. Then apply a 1ms write pulse, check that the data can be read. If it cannot be read, repeat the procedure until the data can be read. Record the number of pulses applied (N) before the data was read and then write the data again, further applying three times the number of pulses (3 x N ms). When this series of write operation is complete, increment the address and repeat the above procedure until the last address is reached. Finally, after writing to all addresses, read with Vcc=Vpp=5V (or Vcc=Vpp=5.25V). Figure 8.2.3 shows the fast programming algorithm flow chart. START ADDR=First location Program one pulse of 1ms FAIL Device failed Increment ADDR Device >----1 failed * : 4.5V5,Vcc=Vpp5,5.5V Fig. 8.2.3 Fast programming algorithm flow chart 261 PROM VERSION 8.2 M37702E2-XXXFP (1) Electrical characteristics of the fast programming algorithm Table 8.2.4 AC electrical characteristics (Ta=25+5°C, - Vcc=6V+O.25V, - Vpp=12.5±O.3V, unless otherwise noted) Limits Symbol Parameter Unit Min. Typ. Max. lAS Address setup time 2 Ils tOES DE setup time 2 J.lS tos Data setup time 2 J.lS tAH Address hold time 0 J.lS tOH Data hold time ------------ 2 J.lS tOFP Output enable to output float. delay 0 130 ns tves Vee setup time 2 J.lS tvps Vpp setup time 2 J.lS ----- tFPW CE initial program pulse width ... 0.95 1 1.05 ms topw CE over program pulse width 2.85 78.75 ms -~------- tOE Data valid from DE 150 ns t----p~Ill-.--.--.-+--- Verily ~[ f'---- VIH =>1r- Address VIL tA"1 i I tAH 0(- Data VIHIVoH VILIVOL ..I Data set 'K J' I -I~ Data output valid I tOH I tos 1-<-> i<-~ I ~~> VPP Vpp Vee I~p~ Vee+1 I ~ ~~; Vee Vee VIH ! I CE VIL - I .. ' I I I tOES, K'-~I [0(-> l tOE I1<------ !Fpw I' VIH .,-- -.--~ I:I y OE VIL k· 1OPIY .. ~ .. j' Fig. 8.2.4 Fast programming timing diagram 262 PROM VERSION 8.3 Usage precaution 8.3 Usage precaution [ Precaution on all internal PROM versions 1 High voltage is required to write to the built-in PROM. Be careful not to apply excessive voltage. Be especially careful during power-on. [ Precaution on one time PROM version 1 User programmable one time PROM versions (M37702E2FP, M37702E2AFP, M37702E2BFP, M37702E4FP, M37702E4AFP, M37702E4BFP) that are shipped in blank are also provided. A write test and screening after assembly process are not performed for these models. To improve their reliability after writing, we recommend that they are written and tested as flow shown in Figure 8.3.1. Writing with PROM writer Screening (Note) (Leave at 150°C for 40 hours) Verify test with PROM writer ~ ------------, I L __FunctionJ _ _ check _ _in_ target _device ___ Note: Never expose to 150°C exceeding 100 hours. Fig. 8.3.1 Writing and test flow for one time PROM version [ Precaution on EPROM version 1 .Cover the transparent glass window during read mode because exposing to sun light or fluorescent lamp can cause the information to be erased. eA shield to cover the transparent window is available from Mitsubishi Electric corp .. Be careful that the shield does not touch the microcomputer lead pins . • Clean the transparent glass before erasing. Fingers' flat and paste disturb the passage of ultraviolet rays and may affect badly the erasure capability . • Use a fit IC socket to mount the EPROM version models except for evaluation. Settle the ceramic package in an IC socket with silicon resin and the like, surely. 263 PROM VERSION 8.3 Usage precaution MEMO 264 ©[H]£~lr~~ ® M37703 GROUP 9.1 Product expansion 9.2 M37703M2-XXXSP M37703 GROUP 9.1 Product expansion 9.1 Product expansion The M37703M2-XXXSP is equal to the M37702M2-XXXFP enclosed in a 64-pin shrink plastic molded DIP. The M37703 group consists of chips shown in Table 9.1.1 with the M37703M2-XXXSP as the base chip. These chips are all pin compatible with each other. Only the memory type and size, and operating clock are different. Table 9.1.1 Product expansion of M37703 group Type name ROM RAM Clock frequency M37703M2-XXXSP 8MHz M37703 M2AXXXSP Mask ROM 16K bytes 16MHz M37703M2BXXXSP 25MHz M37703S1SP 8MHz M37703S1 ASP - 512 bytes 16MHz M37703S1 BSP 25MHz M37703E2-XXXSP 8MHz M37703E2AXXXSP One time PROM 16K bytes 16MHz M37703 E2 BXXXS P 25MHz M37703M4-XXXSP 8MHz M37703M4AXXXSP Mask ROM 32K bytes 16MHz M37703M4BXXXSP 25MHz M37703S4SP 8MHz M37703S4ASP - 2048 bytes 16MHz I M37703S4BSP 25MHz M37703E4-XXXSP 8MHz M37703E4AXXXSP One time PROM 32K bytes 16MHz M37703E4BXXXSP 25MHz 9.1.1 M37703M2·XXXSP characteristics .Number of basic instructions ................................................................................................................ 103 .Memory size ROM ............................................................................................................... 16K bytes RAM ...............................................................................................................512 bytes .Instruction execution time (the fastest instruction at 8MHz) ....................................................... 500ns .Single power supply ......................................................................................................................5V±10 0/o .Low power dissipation (at 8MHz) ........................................................................................ 30mW (Typ.) .Interrupts .................................................................................................................... 19 sources, 7 levels .Multi-function 16-bit timers ...................................................................................................................5+3 eUART ...........................................................................................................................................................2 .S-bit A-D converter ............................................................................................................4-channel input .Watchdog timer .Programmable 1/0 (ports PO, P1, P2, P3, P4, P5, P6, P7, and P8) ............................................... 53 266 M37703 GROUP 9.2 M37703M2-XXXSP 9.2 M37703M2-XXXSP The following descriptions will be for M37703M2-XXXSP. The products of M37703 group have the same functions as the M37703M2-XXXSP unless otherwise noted. 9.2.1 Description The M37703M2-XXXSP is a 16-bit single-chip microcomputer designed with high-performance CMOS sili- con gate technology. It is housed in a 64-pin shrink plastic molded 01 P. This single-chip microcomputer has a large 16M bytes address space, three instruction queue buffers, and two data buffers for high-speed instruction execution. The CPU is a 16-bit parallel processor that can also be switched to perform 8-bit parallel processing. This microcomputer is suitable for office, business, and industrial equipment controllers that require high-speed processing of large amounts data. Figure 9.2.1 shows the M37703M2-XXXSP pin configuration. AVee Vee VREF-+ 63 .... P8o/CTSo/RTSo AVss P77/AN7/ADTRG"" 4 P72/AN2"" 5 P71/AN1"" 6 P7o/ANo ..- P6s/TBOIN .... P62/1NTo"" 11 P56/TA30UT"" 13 Outline 64P4B Fig. 9.2.1 M37703M2-XXXSP pin configuration 267 M37703 GROUP 9.2 M37703M2-XXXSP 9.2.2 Performance overview Table 9.2.1 shows the performance overview of the M37703M2-XXXSP. Table 9.2.1 M37703M2-XXXSP performance overview Parameters Functions Number of basic instructions 103 Instruction execution time M37703M2-XXXSP 500ns (the fastest instruction at 8MHz frequency) M37703M2AXXXSP 250ns (the fastest instruction at 16MHz frequency) M37703M2BXXXSP 160ns (the fastest instruction at 25MHz frequency) Clock frequency M37703M2-XXXSP 8M Hz (maximum) M37703M2AXXXSP 16MHz (maximum) M37703M2BXXXSP 25MHz (maximum) Memory size ROM 16384 bytes RAM 512 bytes Input/Output ports Ports PO, P1, P2, P5 8 bits X 4 Port P8 6 bits X 1 Ports P4, P6, P7 4 bits X 3 Port P3 3 bits X 1 Multi-function timers TAO, TA1, TA2, TA3, TA4 16 bits X 5 (4 with I/O functions) TBO, TB1, TB2 16 bits X 3 (1 with I/O functions) Serial I/O Clock asynchronous serial I/O X 2 (UARTO can also be used as clock synchronous) A-D converter 8 bits X 1 (4 channels) Watchdog timer 12 bits X 1 Interrupts 3 external, 16 internal (priority levels 0 to 7 can be set for each interrupt with software) Clock generating circuit Built-in (externally connected to a ceramic resonator or quartz crystal resonator) Supply voltage 5V±10% Power dissipation 30mW (at external 8MHz frequency) Input/Output characteristics Input/Output voltage 5V Output current 5mA Memory expansion Maximum 16M bytes Operating temperature range -20 to 85°C Device structure CMOS high-performance silicon gate process Package 64-pin shrink plastic molded DIP 268 M37703 GROUP 9.2 M37703M2-XXXSP 9.2.3 Differences between M37703M2-XXXSP and M37702M2-XXXFP Table 9.2.2 shows the differences between M37703M2-XXXSP and M37702M2-XXXFP. Table 9.2.2 Differences between M37703M2-XXXSP and M37702M2-XXXFP Functions M37703M2-XXXSP M37702M2-XXXFP I/O ports 53 (in single-chip mode) 66 (in single-chip mod~ Port PO 6 bits 6 bits Port Pi 6 bits 6 bits Port P2 8 bits 8 bits Port P3 3 bits (P3:J/HLDA unavailable) 4 bits Port P4 4 bits (P43-P46 unavailable) 8 bits Port P5 8 bits 6 bits Port P6 4 bits (P6o, P61, P6s, and P67 unavailable) 6 bits Port P7 4 bits (P73-P76 unavailable) 6 bits Port P6 6 bits (P64 and P85 unavailable) 8 bits Timers 16bitsX8 16 bits X 8 Timer A TAO Timer I/O pins available Timer I/O pins available TA1 I nput= T AjIN, output= T AjOUT (j=O to 3) Input= TAilN, output= TAiouT (i=0 to 4) TA2 TA3 TA4 Internal timer (TA4IN and TA40UT unavailable) Timer 8 T80 Timer input pin (T80IN) available Timer input pin (T8kIN) available T81 Internal timer (T811N and T821N (k=O to 2) TB2 unavailable) Serial I/O 2 2 UARTO Clock asynchronous/synchronous Clock asynchronous/synchronous serial I/O serial I/O UART1 Clock asynchronous serial I/O Clock asynchronous/synchronous serial I/O A-D converter One 6-bit resolution One 8-bit resolution 4-channel analog input pin 8-channel analog input pin ANa, ANI, AN2, AN7 ANa, ANI, AN2, AN3, (AN3-AN6 unavailable) AN4, AN5, AN6, AN7 Note: AN7 pin is in common with Note : AN7 pin is in common with external trigger pin. external trigger pin. Package 64-pin shrink plastic molded DIP (64P48) 80-pin plastic molded QFP (80P6N) 269 M37703 GROUP 9.2 M37703M2-XXXSP 9.2.4 Functional description The internal circuit of the M37703M2-XXXSP is identical to that of the M37702M2-XXXFP including the control registers and memory allocation in SFR area. However, since the M37703M2-XXXSP has only 64 pins, some functions are different from the M37702M2-XXXFP. The functional differences are described below. (1) A-O converter Analog input pins are 4 channels of ANo-AN2, and AN7 pins. [ One·shot mode and repeat mode] The analog input pin selection bits in the A-O control register must be set to "000", "001 ", "010", or "111" . Bits 3 to 6 in the port P7 direction register must be set to "1" to select output mode because AN3- ANe pins are not available. [ Single sweep mode and repeat sweep mode] Bits 0 to 2 and bit 7 in the port P7 direction register must be set to "0" to select input mode. Bits 3 to 6 in the port P7 direction register must be set to "1" to select output mode because AN3-ANe pins are not available. The contents of the corresponding A-O registers to analog input AN3-ANs which have no input pins are undefined. (2) Timers I/O functions of timer A4, and input functions of timers B1 and B2 are not available. Therefore, these timers operate only in timer mode. Only count source can be selected for timers A4, B1 and B2, and bits 0 to 5 in each timer mode register must be fixed to "0". Other timers (timers AO to A3, and timer BO) have the same functions as the M37702M2-XXXFP. (3) Serial 1/0 UART1 can be used only in UART mode. It cannot be used in clock synchronous serial I/O mode. Therefore, the serial I/O mode selection bits in the UART1 transmit/receive mode register must be set to the value except for "001 ". The CTS/RTS function selection bit in the UART1 transmit/receive control register 0 must be fixed to "1" because CTS/RTS function is not available (this bit is set to "0" at reset). UARTO has the same functions as the M37702M2-XXXFP. (4) Ports The port direction registers for ports P4, P6, P7, and P8 contain 8 bits. However, the bits in the each direction register with no corresponding pins must be set to "1" to select output mode. The port P3 direction register bit 3 which is corresponding to port P33 must be set to "1" to select output mode. 270 Appendix 1. M37702 group memory map Appendix 2. SFR area memory map Appendix 3. Control registers Appendix 4. Stop, wait, one-wait, Ready, Hold state Appendix 5. Package outlines Appendix 6. Setting of unused pins Appendix 7. ROM ordering method Appendix 8. Ie socket Appendix 9. M66800SP/FP Appendix 10. Instruction code table Appendix 11. Machine instructions APPENDIX Appendix 1. M37702 group memory map Appendix 1. M37702 g roup memory map 1. Memory map in single·chip mode Figure 1 shows the memory map in single-chip mode. (A) (B) SFR area SFR area Internal RAM 512 bytes 27F16 Internal RAM 2048 bytes Not used Not used 800016 C00016 Internal ROM 32K bytes Internal ROM 16K bytes FFFF16 FFFF16 No. Type name Internal ROM M37702M2-XXXFP M37702M2AXXXFP M37702M2BXXXFP Mask ROM (A) M37702E2-XXXFP, M37702E2AXXXFP, M37702E2BXXXFP One time PROM M37702E2FS,M37702E2AFS,M37702E2BFS EPROM M37702M4-XXXFP M37702M4AXXXFP M37702M4BXXXFP Mask ROM (B) M37702E4·XXXFP, M37702E4AXXXFP, M37702E4BXXXFP One time PROM M37702E4FS,M37702E4AFS,M37702E4BFS EPROM Fig. 1 Memory map in single·chip mode 272 APPENDIX Appendix 1. M37702 group memory map 2. Memory map in memory expansion mode Figure 2 shows the memory map in memory expansion mode. (A) (B) SFR area .- - - - - - - ------- ----- 0,6 0,6 0,6 SFR area SFR area 7F'6 _____ 2!:'6 2'6 80,6 80,6 1\ External memory area Internal RAM 9'6 512 bytes \ A'6 27F'6 Internal RAM 2048 bytes \ .\ 87F,s \7F'6 I 0 I 0 I 0 I 0 IRWIRWIRWIRWI 000008 Port P2 direction register RW b7 b6 b5 b4 b3 b2 b1 bO 000009 Port P3 direction register -. I 0 I 0 I 0 I OIRWIRWIRWIRWI OOOOOA Port P4 register RW 000008 Port P5 register RW OOOOOc Port P4 direction register RW 000000 Port P5 direction register RW OOOOOE Port P6 register RW OOOOOF Port P7 register RW 000010 Port P6 direction register RW 000011 Port P7 direction register RW 000012 Port P8 r.egister RW 000013 000014 Port P8 direction register RW 000015 00001 0 00001 E A-D control register RW b7 b6 b5 b4 b3 b2 b1 bO 00001 F A-O sweep pin selection register RW I ? I ? I ? I ? I ? I ? IRWIR~ 00002 0 A-O register 0 RO 00002 1 00002 2 A-O register 1 RO 00002 3 00002 4 A-O register 2 RO 00002 5 L,..--- V 275 APPENDIX Appendix 2. SFR area memory map -- Address Registers Access (Hexadecimal notation) .,.... 00002 6. A-D register 3 RO 00002 7 00002 8 A-D register 4 RO 00002 9 00002 A A-D register 5 RO 00002 B 00002 C A-D register 6 RO 00002 D 00002 E A-D register 7 RO 00002 F 00003 0 UARTO transmiVreceive mode register RW 00003 1 BRGO register WO 00003 2 L UARTO transmission .- ........ WO 00003 3 buffer register H 00003 4 UARTO transmiVreceive control register 0 -> 00003 5 UARTO transmiVreceive control register 1 -> 00003 6 L RO 'UARTO receive buffer register •• i-i --_ .. _.- b7 b6 b5 b4 b3 b2 bl bO 00003 7 -> o 0 0 0 0 0 0 IRO I 00003 8 UARTI transmiVreceive mode register RW 00003 9 BRG1 register WO 00003 A UART1 transmission ..... _...L- WO 00003 B buffer register H 00003 C UARTI transmiVreceive control register 0 -> 00003 D UARTI transmiVreceive control register 1 -> 00003 E L RO 'UART1 receive buffer register •• i-i _...... - b7 b6 b5 b4 b3 b2 bl bO 00003 F -> o 0 0 0 0 0 0 IRO I 00004 0 Count start flag RW 00004 1 00004 2 One-shot start flag WO 00004 3 b7 b6 b5 b4 b3 b2 bl bO 00004 4 Up-down flag -> Iwol wolwolRWI RW IRW IRW IRW I 00004 5 00004 6 L 'Timer AO register _• •••••••••••• RW 00004 7 H 000048 L 'Timer A 1 register •••••••••••••• RW 00004 9 H L-- V 276 APPENDlIX Appendix 2. SFR area memory map -- Address Registers Access (Hexadecimal notation) ....... 00004 A • Timer A2 register •••••••••• ~•• RW 00004 B H 00004C • Timer A3 register •••••••••• ~•• RW 00004 D H 00004 E L • Timer A4 register ••••••••••••• RW 00004 F H 00005 0 • Timer BO register •••••••••• ~•• RW 00005 1 H 00005 2 L • Timer B1 register ••••••••••••• RW 00005 3 H 00005 4 • Timer B2 register •••••••••• ~•• RW 00005 5 H 00005 6 Timer AO mode register RW 000057 Timer A1 mode register RW 00005 8 Timer A2 mode register RW 000059 Timer A3 mode register RW 00005 A Timer A4 mode register RW 00005 B Timer BO mode register RW 00005 C Timer B1 mode register RW 00005 D Timer B2 mode register RW b7 b6 b5 b4 b3 b2 b1 bO 00005 E Processor mode register -> IRWIRWIRWIRWlwolRWIRWIRWI 00005 F 00006 0 Watchdog timer WO b7 b6 b5 b4 b3 b2 b1 bO 00006 1 Watchdog timer frequency selection flag RW ? ? ? ? ? ? 00006 2 00006 3 00006 4 00006 5 b7 b6 b5 b4 b3 b2 b1 bO 000070 A-O conversion interrupt control regiser -> ? ? ? ? RW RW RW RW 000071 UARTO transmission interrupt control reg Iter -> ? ? ? ? RW RW RW RW 000072 UARTO receive interrupt control register -> ? ? ? ? RW RW RW RW 000073 UART1transmission interrupt control reg iter -> ? ? ? ? RW RW RW RW 000074 UART1 receive interrupt control register -> ? ? ? ? RW RW RW RW 000075 Timer AD interrupt control register -> ? ? ? ? RW RW RW RW 000076 Timer A1 interrupt control register -> ? ? ? ? RW RW RW RW 277 APPENDIX Appendix 2. SFR area memory map -- Address Registers Access (Hexadecimal notation) ~ b7 b6 b5 b4 b3 b2 b1 bO 00007 7 Timer A2 interrupt control register -. ? ? ? ?RW RW RW RW 000078 Timer A3 interrupt control register -. ? ? ? ?RW RW RW RW 000079 Timer A4 interrupt control register -. ? ? ? ?RW RW RW RW 00007 A Timer BO interrupt control register -. ? ? ? ?RW RW RW RW 00007 B Timer B1 interrupt control register -. ? ? ? ?RW RW RW RW 00007C Timer B2 interrupt control register -. ? ? ? ?RW RW RW RW 00007 D INTo interrupt control register -. ? ? RW RW RW RW RW RW 00007 E INT1 interrupt control register -. ? ? RW RW RW RW RW RW 00007 F INT2 interrupt control register -. ? ? RW RW RW RW RW RW 00008 0 Internal RAM 278 APPENDIX Appendix 3. Control registers Appendix 3. Control registers The register structure of each control register allocated in the SFR area are shown on the following pages. Each table shows the bit names, functions, content when reset is removed, and bit attributes . • Bit attributes: Each bit in the control register is either read only, write only, or read/write. The following abbreviations are used to indicate the attribute. R : Read W : Write o : Possible to read or write X : Impossible to read or write 279 APPENDIX Appendix 3. Control registers 1.Port Pi direction registers (bO-B) b7 b6 b5 b4 b3 b2 b1 bO I Port Pi direction register I I I I I I I I (Address 0416,0516,OS16,0916,OC16,0016, 1016,1116,14,6) Bit Bit name Functions At reset R W ~ 0 Port Pia direction selection bit 0: Input mode 0 0 0 1 : Output mode ~ 1 Port Ph direction selection bit 0 0 0 2 Port Pi2 direction selection bit 0 0 0 3 Port Pi3 direction selection bit 0 0 0 4 Port Pi4 direction selection bit 0 0 0 5 Port Pi5 direction selection bit 0 0 0 6 Port Pi6 direction selection bit 0 0 0 7 Port Pi? direction selection bit 0 0 0 Note: The high-order 4 bits of port P3 dierction register are write prohibited and these bits are fixed to "0" at reading. 2.A-D control register b7 b6 b5 b4 b3 b2 b1 bO I I I I I I I I I A-O control register (Address 1E16) Bit Bit name Functions At reset R W Analog input selection bits b2b1bO I ~ 0 o 0 0: Select ANa Undefined 0 0 O 0 1 : Select AN, C- o 1 o : Select AN2 -1 o 1 1 : Select AN3 Under.ned 0 0 '--- 1 0 0: Select AN4 1 0 1 : Select AN5 2 1 1 0: Select AN6 Undefined 0 0 1 1 1 : Select AN? (Note) A-O mode selection bits b4b3 3 o 0: One-shot mode 0 0 0 O 1 : Repeat mode C- 1 0: Single sweep mode 4 1 1 : Repeat sweet mode 0 0 0 Trigger selection bit a :Software trigger (internal trigger) 5 1 : ADTRG input trigger (external trigger) 0 0 0 A-O conversion start flag o : Stop A-O conversion 6 1 : Start A-O conversion 0 0 0 A-O conversion frequency (¢lAD) o : Select f(XIN)/S 7 selection flag 1 : Select f(XIN)/4 0 0 0 Note. Pin AN? cannot be used as analog voltage input pin when an external trigger is selected. 280 APPENDIX Appendix 3. Control registers 3.A·O sweep pin selection register b7 b6 b5 b4 b3 b2 b1 bO I '::-I.: ,I<:! ···1·· I . I I I A-D sweep pin selection register (Address 1F,s) Bit Bit name Functions At reset R W A-D sweep pin selection bits b1bO ~ 0 o 0: ANa, AN, !2 Pinsl 1 0 0 I-- o 1 : ANo-AN3 4 pins 1 0: ANo-ANs !6 Pinsl '--- 1 1 1 : ANo-AN7 8 pins 1 0 0 2 These bits cannot be written and are undefined at reading. Undefined XX ~ Undefined XX I- 4 Undefined X X rs l- Undefined XX 6 Undefined X X t-- 7 Undefined X X 4.UARTi transmit/receive mode registers (i=O, 1) b7 b6 b5 b4 b3 b2 b1 bO I UARTO transmit/receive mode register !AddreSs 3O,sl I I I I I I I I UART1 transmit/receive mode register Address 38,s Bit Bit name Functions At reset R W Serial I/O mode selection bits b2b1bO ~ 0 o 0 0: Serial I/O prohibited 0 0 0 t-- o 0 1 : Clock synchronous serial I/O o 1 0: This cannot be available. '--- 1 o 1 1: This cannot be available. 0 0 0 I-- 1 0 0: 7-bit UART 1 0 1 : 8-bit UART 2 1 1 0: 9-bit UART 1 1 1: This cannot be available. 0 0 0 Internal/external clock selection bits o : Internal clock 3 1 : External clock 0 0 0 Stop bit length selection bit o : One stop bit 4 (in UART mode) 1 : Two stop bits 0 0 0 Odd/even parity selection bit o : Odd parity 5 (in UART mode) 1 : Even panty 0 0 0 Parity enable bit o : Parity disabled 6 (in UART mode) 1 : Parity enabled 0 0 0 Sleep function selection bit o : Sleep function disabled 7 (in UART mode) 1 : Sleep function enabled 0 0 0 Note: Bits 4 to 6 are ignored in clock synchronous mode. Bit 7 must be "0" when using clock synchronous mode. 281 APPENDIX Appendix 3. Control registers S.UARTi transmit/receive control register ° (i=O, 1) b7 b6 b5 b4 b3 b2 b1 ba I I·' I' I,; I I I J J UARTa transmit/receive control register a (Address 3416) UART1 transmit/receive control register a (Address 3C16) Bit Bit name Functions At reset R W BRG count source selection bits b1ba L....- a a a: Select f(XIN)/2 (12) a 0 0 I- a 1 : Select f(X1Nr 6 ~f16) f~XIN 1 a: Selectf XIN /64 fs4) '--- 1 1 1: Select /512 (f512) a 0 0 CTS/RTS function selection bit a : Select CTS function 2 1 : Select RTS function a 0 0 Transmission register empty flag a : Data in transmission register (transmitting) 1 : No data in transmission register 3 (transmit complete) 1 0 X 4 These bits cannot be written and are undefined at reading. Undefined XX I- 5 I- Undefined XX 6 I- Undefined XX 7 Undefined XX 6.UARTi transmit/receive control register 1 (i=O, 1) b7 b6 b5 b4 b3 b2 b1 ba I I I I I I I I I UARTa transmit/receive control register 1 (Address 3516) UART1 transmit/receive control register 1 (Address 3D16) Bit Bit name Functions At reset R W Transmit enable bit a : Transmission disable L....- a 1 : Transmission enable a 0 0 '--- 1 Transmission buffer empty flag a : Data in transmission buffer register 1 0 X 1 : No data in transmission buffer register Receive enable bit o : Receive disable 2 1 : Receive enable a 0 0 Receive completion flag o : No data in receive buffer register 3 1 : Data in receive buffer register 0 0 X Overrun error flag o : No overrun error 4 1 : Overrun error 0 0 X Framing error flag o : No framing error 5 (in UART mode) 1 : Framing error 0 0 X Parity error flag a : No parity error 6 (in UART mode) 1 : Panty error a 0 X Error sum flag 0: No error 7 (in UART mode) 1 : Error 0 0 X Note: Bits 5 to 7 are ignored in clock synchronous mode. Each error flag is cleared to "0" when the receive buffer register is read. 282 APPENDIX Appendix 3. Control registers 7.Count start flag b7 b6 b5 b4-b3 b2 b1 bO I I I I I I I I I Count start flag (Address 4016) Bit Bit name Functions At reset RW ~ 0 Timer AO count start flag o : Count stop 0 0 0 1 : Count start - 1 Timer Ai count start flag 0 0 0 2 Timer A2 count start flag 0 0 0 3 Timer A3 count start flag 0 0 0 4 Timer A4 count start flag 0 0 0 5 Timer BO count start flag 0 0 0 6 Timer B1 count start flag 0 0 0 7 Timer B2 count start flag 0 0 0 a.One·shot start flag b7 b6 b5 b4 b3 b2 b1 bO t::J:J.::J I I I I lOne-shot start flag (Address 4216) Bit Bit name Functions At reset R W '-- 0 Timer AO one-shot start flag 1 : One-shot start 0 X0 ~ 1 Timer Ai one-shot start flag 0 X0 2 Timer A2 one-shot start flag 0 X 0 3 Timer A3 one-shot start flag 0 X 0 4 Timer A4 one-shot start flag 0 X 0 5 These bits cannot be written and are undefined at reading_ Undefined X X - 6 Undefined X X - 7 Undefined XX 283 APPENDIX Appendix 3. Control registers 9.Up-down flag b7 b6 b5 b4 b3 b2 b1 bO I I I I I I I I I Up-down flag (Address 4416) Bit Bit name Functions At reset R W '-- 0 Timer AO up-down flag o : Down count 0 0 0 1 : Up count '--- 1 Timer A1 up-down flag 0 0 0 2 Timer A2 up-down flag 0 0 0 3 Timer A3 up-down flag 0 0 0 4 Timer A4 up-down flag 0 0 0 Timer A2 two-~hase signal o : Two-phase pulse signal 5 processing se ection bit processing disable 0 X0 1 : Two-phase pulse signal Timer A3 two-phase signal processing enable 6 processing selection bit 0 X0 Timer A4 two-phase signal 7 processing selection bit 0 X0 Note: Data must be written uSing LDM or STA instruction for bits 5-7. APPENDIX Appendix 3. Control registers 10.Timer Ai mode registers (i=O-4) b7 b6 b5 b4 b3 b2 b1 ba I I I I I I I I Timer Ai mode register (Addresses 5616-5AI6) Bit Bit name Functions At reset R W Operating mode selection bits b1ba L...- a a a: Timer mode a 0 0 a 1 : Event counter mode - 1 a: One-shot pulse mode '--- 1 1 1: PWM mode a 0 0 2 These bits' functions depend on operating mode. a 0 0 -3 a 0 0 ""4 a 0 0 -5 a 0 0 Count source selection bits b7b6 6 a a: Select f(XIN)/2 (f2) a 0 0 - a 1 : Select f(XIN)/16 (flS) 1 a: Select f(XIN)/64 (f64) 7 1 1 : Select f(XIN)/512 (f512) a 0 0 Note: In event counter mode, bits 6 and 7 are ignored. (1 )Timer mode b7 b6 b5 b4 b3 b2 b1 bO I I 10 1 I I I 0 I 0 I Timer Ai mode register Bit Bit name Functions ~ 0 Operating mode selection bits b1bO ~1 r-- o 0: Timer mode 2 Pulse output function selection bit o : No pulse output 1 : Pulse output Gate function selection bits b4b3 3 o X No gate function f- 1 0 Count while TAitN input level is "L" 4 1 1 Count while TAitN input level is "H" This bit must be fixed to "0". 5 Count source selection bits b7b6 6 o a Select f(XIN)/2 (f2) r-- o 1 Select f(XIN)/16 (fI6) 7 1 0 Select f(XIN)/64 (f64) 1 1 Select f(XINi/512· (f512) 285 APPENDIX Appendix 3. Control registers (2)Event counter mode b7 b6 b5 b4 b3 b2 b1 bO Ix I X I 0 I I I I 0 11 I Timer Ai mode register Bit Bit name Functions c- O Operating mode selection bits b1bO - o 1 : Event counter mode - 1 2 Pulse output function selection bit o : No pulse output 1 : Pulse output 3 Count polarity selection bit o : Count at the falling edge of the input signal 1 : Count at the rising edge of the input signal 4 Up-down switching factor selection bit o : Content of the up-down flag 1 : Input signal of the TAiouT pin This bit must be fixed to "0", 5 6 These bits are ignored (may be "0" or "1 "), - 7 (3)One-shot pulse mode b7 b6 b5 b4 b3 b2 b1 bO II 10 1 I I I 11 11 a Timer Ai mode register Bit Bit name Functions L- a Operating mode selection bits b1ba 1 a: One-shot pulse mode - ~ This bit must be fixed to "1 ", 2 Trigger selection bits b4b3 3 OX: Internal trigger (Writing operation to the one-shot start flag) I- 1 a: Falling edge of the input signal toTAilN input 4 1 1 : Rising edge of the input signal to TAilN input This bit must be fixed to "0", 5 Count source selection bits b7b6 6 a a Select f(XIN)/2 (f2) I- a 1 Select f(XIN)/16 (f16) 7 1 a Select I(X1Nl'64 (164) 1 1 Select I(XIN /512 (1512) 286 APPENDIX Appendix 3. Control registers (4)PWM mode b7 b6 b5 b4 b3 b2 b1 bO 1 1 1 1 1 11 11 11 1 Timer Ai mode register Bit Bit name Functions - 0 Operating mode selection bits b1bO 1 1: PWM mode ~ '1 This bit must be lixed to "1". 2 Trigger selection bits b4b3 3 OX: Internal trigger (Writing operation to the one-shot start flag) I-- 1 0: Failing edge of the input signal TAhN input 4 1 1 : Rising edge of the input signal TAilN input 5 16/8-bit PWM mode selection bit o : 16-bit PWM mode 1 : 8-bit PWM mode 6 Count source selection bits b7b6 o 0 Select I(XIN)/2 (12) r-- o 1 Select I(XIN)/16 (116) 7 1 0 Select I(XIN)/64 (164) 1 1 Select I(XIN)/512 (1512) 287 APPENDIX Appendix 3. Control registers 11.Timer Bi mode registers (i=O-2) b7 b6 b5 b4 b3 b2 b1 ba I I I II I I I I Timer Bi mode register (Address 5B16-5D16) Bit Bit name Functions At reset R W Operating mode selection bits b1ba ~ a a a Timer mode a 0 0 - a 1 Event counter mode 1 a Pulse period/pulse width '--- 1 measurement mode a 0 0 1 1 : This cannot be available. 2 These bits' functions depend on operating mode. a 0 0 ""3 a 0 0 4 This bit cannot be written and is undefined at reading. Urdefinad XX , Timer Bi overflow flag a: No overflow or underflow 5 1 : Overflow or underflow 1 0 X (Not.) Count source selection bits b7b6 6 a a: Select f(XIN)/2 (f2) a 0 0 - a 1 : Select f(XIN)/16 (f16) ~ a: Select f(XIN)/64 (f64) 7 1 1 : Select f(XIN)/512 (1512) a 0 0 Note: The timer Bi overflow flag which is set to "1" is cleared to "0" by writing to this register. (1}Timer mode b7 b6 b5 b4 b3 b2 b1 ba I I I I JX Ix I 0 I 0 I Timer Bi mode register Bit Bit name Functions ~ a Operating mode selection bits b1bO - ~ o 0: Timer mode 2 These bits are ignored (may be "0" or "1 "). ~ 4 This bit cannot be written and is undefined at reading. Timer Bi overflow flag o : No underflow 5 1 : Underflow Count source selection bits b7b6 6 o 0 Select f~XINr2 (f2) t-- o 1 Select f XIN /16 (f16) 7 1 0 Select f~X'Nl/64 (f64) 1 1 Select f XIN /512 (f512) 288 APPENDIX Appendix 3. Control registers (2)Event counter mode b7 b6 bS b4 b3 b2 b1 bO I XI XI I I J I I 0 11 Timer Bi mode register Bit Bit name Functions - 0 Operating mode selection bits b1bO I-- o 1 : Event counter mode "---- 1 Count polarity selection bits b3b2 2 o 0 : Count at the falling edge of the input signal I-- o 1 : Count at the rising edge of the input signal 3 1 0: Count at both edges of the input signal 1 1 : This cannot be available. 4 This bit cannot be written and is undefined at reading. Timer Bi overflow flag o : No underflow S 1 : Underflow 6 These bits are ignored (may be "0" or "1 "). '7 (3)Pulse period/pulse width measurement mode b7 b6 bS b4 b3 b2 b1 bO I I I I,. I I 11 I 0 I Timer Bi mode register Bit Bit name Functions - 0 Operating mode selection bits b1bO 1 0: Pulse period/pulse width measurement mode "---- '1 Measurement mode selection bits b3b2 2 o 0 : Pulse period measurement mode (between falling edge and the next falling edge) I-- o 1 : Pulse period measurement mode (between rising edge and the next rising edge) 3 1 0: Pulse width measurement mode 1 1 : This cannot be available. 4 This bit cannot be written and is undefined at reading. Timer Bi overflow flag o : No overfolw S 1 : Overflow Count source selection bits b7b6 6 o 0: Select f(XIN)/2 (12) I-- o 1 : Select f(XIN)/16 (f16) 7 1 0: Select f(XIN)/64 (164) 1 1 : Select I(XIN)/S12 (1512) 289 APPENDIX Appendix 3. Control registers 12.Processor mode register b7 b6 bS b4 b3 b2 b1 bO I 10 1 I I I I I I Processor mode register (Address SE16) Bit Bit name Functions AI resel R W Processor mode bits b1bO '-- 0 o 0: Single·chip mode 0 0 0 r-- o 1 : Memory expansion mode 1 0: Microprocessor mode - 1 1 1 : This cannot be available. 0 0 0 Wait bit o : Wait during external access 2 1 : No wait 0 0 0 Software reset bit Software reset activated by writing "1 ". 3 0 X 0 Interrupt priority detection bSb4 4 time selection bits o 0: Select 7 cycles at internal clock I/J 0 0 0 r-- o 1 : Select 4 cycles at internal clock I/J 1 0: Select 2 cycles at internal clock I/J S 1 1 : This cannot be available. 0 0 0 This bit must be fixed to "0". 6 0 0 0 Clock ¢1 output selection bit o : ¢1 output disabled (P42 is normal I/O port.) 7 1 : ¢1 output enable 0 0 0 (P42 is ¢1 output pin.) 13.Watchdog timer frequency selection flag b7 b6 bS b4 b3 b2 b1 bO p:::. h:/F:i: h~::r;; i[ifT:: ;~I I Watchdog timer frequency selection flag (Address 6116) Bit Bit name Functions AI resel R W Watchdog timer frequency o : Select f(XIN)/S12 (f512) - 0 selection flag 1 : Select f(XIN)/32 (132) 0 0 0 ' - - - 1 These bits cannot be written and are undefined at reading. Undefined XX -2 Undefined XX -3 Undefined X X 4" -S Undefined X X Undefined X X -6 Undefined X X -7 Undefined X X 290 APPENDIX Appendix 3. Control registers 14.A-O conversion, UART 0 and 1 transmission, UART 0 and 1 receive, timers AO-A4, timers BO-B2, interrupt control registers b7 b6 b5 b4 b3 b2 b1 bO 1::: ,.:. '·'·J::I 1 1 1 1timers A-O conversion, UARTO and 1 transmission, UARTO and 1 receive, timers Ao-A4, 80-82 interrupt control registers (Address 7016-7C16) Bit Bit name Functions At reset R W Interrupt priority level b2b1bO ~ 0 selection bits o 0 0 : Level 0 (Interrupt disabled) 0 0 0 c- O 0 1 : Level 1 o 1 0: Level 2 '---- 1 o 1 1 : Level 3 0 0 0 1 0 0: Level 4 r-- 1 0 1 : Level 5 2 1 1 0: Level 6 0 0 0 1 1 1 : Level 7 Interrupt request bit o : No interrupt request 3 1 : Interrupt request 0 0 0 4 These bits cannot be written and are undefined at reading. Undefined X X rs r-- Undefined X X ~ 6 Undefined X X 7 Undefined X X 15.1NTo-INT2 interrupt control registers b7 b6 b5 b4 b3 b2 b1 bO 1':+0'1 I I 1 1 1 IINT()-INT2 interrupt control registers (Address 7D16-7F16) Bit Bit name Functions At reset R W Interrupt priority level b2b1bO ' - - 0 selection bits o 0 0 : Level 0 (Interrupt disabled) 0 0 0 r-- o 0 1 : Level 1 o 1 0: Level 2 - 1 o 1 1 : Level 3 0 0 0 ~ 1 0 0: Level 4 1 0 1 : LevelS 2 1 1 0: Level 6 0 0 0 1 1 1 : Level 7 Interrupt request bit o : No interrupt request 3 1 : Interrupt request 0 0 0 Level/edge selection bit o:Set request bit at "H" level for level sense and the falling edge for edge sense. 4 1 : Set request bit at "L" level for level 0 0 0 sense and the rising edge for edge ~An~A. Level/edge sense selection bit o : Edge sense 5 1 : Level sense 0 0 0 6 These bits cannot be written and are undefined at reading. -7 Undefined X X Undefined X X 291 APPENDIX Appendix 4_ Stop, wait, one~wait, Ready, Hold state Appendix 4. Stop, wait, one-wait, Ready, Hold state 1. Stop, wait, one-wait, Ready, Hold state Table 1 shows the stop, wait, one-wait, Ready, and Hold state. The following are some notes for items in Table 1. (1) Oscillation Timer A, timer B, serial 1/0, and A-O converter can be used when the oscillator is operating. (2) STP instruction For mask ROM version, whether to enable or disable the STP instruction is selected with the STP instruction option on the mask ROM order confirmation form. The STP instruction is always valid for PROM version and external ROM version. Table 2 shows the external interrupts used to remove the state after executing the STP instruction (stop mode). Table 2 External interrupts used to remove stop mode External interrupt Interrupt source External input signal INTo, INT1, INT2 Serial 110 using external clock UARTO receive, UARTO transmission (clock synchronous/asynchronous) UART1 receive, UART1 transmission Timer interrupts in event counter mode Timer AO, Timer A1, Timer A2, Timer A3, Timer A4, Timer BO, Timer B1, Timer B2 (3) STP, WIT instructions The reset used to remove the state after executing the STP instruction (stop mode) or the state after executing the WIT instruction (wait mode) is a hardware reset. If a hardware reset is used to remove a stop mode or wait mode, the contents of the internal RAM are the contents before executing these instructions. The status of the other internal registers are the same as described in section "3.1.2 Internal status at reset". The contents of the internal RAM is not retained if a hardware reset is performed in cases other than stop mode or wait mode. If STP or WIT instruction is to be executed after writing to internal RAM, SFR, external memory, or peripheral IC, insert NOP instructions in front of these instructions. Table 3 shows the number of NOP instructions to insert. Table 3 Number of NOP instruction to insert Condition NOP instructions After writing to internal RAM and SFR After writing to external memory and peripheral IIC when the wait bit (bit 2 at address 5E1s) is "1" After writing to external memory and peripheral 1/0 when the wait bit is 3 "0" (one-wait mode) 292 APPENDIX Appendix 4. Stop, wait, one-wait, Ready, Hold state Table 1 Stop, wait, one-wait, Ready, Hold state ~ (stop mode) STP instruction WIT instruction Wait bit RDY input HOLD input Parameter (wait mode) (one-wait mode) (Ready state) (Hold state) Enabling condition Enabled in all operating Enabled in all operating Access external area with In memory expansion In memory expansion modes modes processor mode register mode or microprocessor mode or microprocessor bit 2 set to "0", mode mode Oscillator Stopped Operating Operating Operating Operating ~1 output Stop at 'L" level. Operating Operating Operating Operating E output Stop at 'H" or 'L" level. Stop at 'War 'L" level. "L" pulse width becomes Stop at 'H" or "L" level. Stop at "H" level. twice at external access, Port status Retain bus and port Retain bus and port Retain bus and port Ports PO, P1, P2, P30, status when STP status when WIT status when 'L" level is P31 are floating, Ports instruction is executed, instruction is executed, applied, P32, P33 stop at "L" level. --- Ports P43-P47, P5, P6, P7, P8 retain status when 'L" level is applied, Watchdog timer state Stopped (set 'FFF 16" in Operating Operating Operating Stopped watchdog timer and select count source f32) Removing of state Hardware reset or Hardware reset or Set processor mode Return ROY input to "H" Return HOLD input to "H" accepting external accepting interrupt register bit 2 to '1", level. level. interrupt 293 APPENDIX I Appendix 5. Package outlines Appendix 5. Package outlines @ @ Dimension in mm x ~N~ 00 CD @ ~I ~1_~ M ~ I I 20+0.2 0.6±0.2Tj= • 22.8+0.3 Fig. 4 80-pin plastic molded QFP (80P6N) 21.0±0.2 Dimension in mm (200) ~68.8 00.4 Notch 1840± 0 15 Fig. 5 80-pin ceramic LCC (8000) 294 APPENDIX Appendix 6. Setting of unused pins Appendix 6. Setting of unused pins Table 4 Setting example of unused pins in single-chip mode Pin Setting Ports PO-P8 Set to input mode and connect to Vss through a resistor (pull-down). E, XOUT (Note 1) Open. AVee Connect to Vee. AVss, VREF, BYTE Connect to Vss. Note1: When external clock is input to XIN. Table 5 Setting example of unused pins in memory expansion and microprocessor mode Pin Setting Ports P42-P47, P5-P8 Set to input mode and connect to Vss through a resistor (pull-down). BHE (Note 1), ALE (Note 2), Open. HLDA, XOUT (Note 3) HOLD, ROY Connect to Vee through a resistor (pull-up). AVee Connect to Vee. AVss, VREF Connect to Vss. Note1: When BYTE="H". Note 2 : When BYTE="H" and address space is 64K bytes. Note 3 : When external clock is input to XIN pin. (1) Single-chip mode (2) Memory expansion and microprocessor mode Ports PO-P8 Ports P42-P47, (input mode) P5-P8 (input mode) SHE ~ E ~ ALE Open VJ Open VJ HLOA --.....J XOUT --.....J XOUT --.....J --.....J 0 o I\J I\J HOLD ROY BYTE AVe<; AVec 1 - - - - - ' AVss AVss 1-------. VREF VAEF 1-------. Vss Vss Fig. 6 Setting example of unused pins 295 APPENDIX Appendix. 7 ROM ordering method Appendix. 7 ROM ordering method Please submit the information described below when ordering Mask ROM and One time PROM. [Mask ROM] CD Mask ROM Order Confirmation Form ...................................................................................... 1 set (There is a specific form to be used for each model.) @ Data to be written into mask ROM ..................................................................................... EPROM (Please provide three sets containing the identical data.) ® Mark SpeCification Form (described on page 309) ............................................................... 1 set [One time PROM] CD Writing to PROM Order Confirmation Form ............................................................................ 1 set (There is a specific form to be used for each model.) @ Data to be written into PROM built in ................................................................................ EPROM (Please provide three sets containing the identical data.) ® Mark Specification Form (described on page 309) ............................................................... 1 set 296 APPENDIX Appendix. 7 ROM ordering method GZZ-SH02-4SA <99AO ) MELPS 7700 MASK ROM ORDER CONFIRMATION FORM I Mask ROM number I SINGLE-CHIP 16-BIT MICROCOMPUTER M37702M2-XXXFP Date: MITSUBISHI ELECTRIC Section head Supervisor signature signature C. I Mask ROM number I MELPS 7700 MASK ROM ORDER CONFIRMATION FORM SINGLE-CHIP 16-BIT MICROCOMPUTER M37702M2AXXXFP Date: MITSUBISHI ELECTRIC Section head Supervisor sil'lnature siqnature 1i 'Qj u Q) a: Note: Please fill in all items marked>* Responsible TEL officer Supervisor Company name ( ) u Q) '"~ c :0 Customer Date ~ ''"" iii :0 C Cl Date: 'iii issued '* 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the 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 differ from this data. Thus, the customer must be especially careful in verifying the data con- tained in the EPROMs submitted. Checksum code for entire EPROM areas 1'--_'----' --_'----' (hexadecimal notation) EPROM Type: (1) Set "FF16" in the shaded area. 0 27256 0 27512 (2) Address 0 16 to 1016 are the area for storing the data on model designation and options. This area 0000 must be written with the data shown below. Details for option data are given next in the sec- W~.- 0010 tion describing the STP instruction option. Address and data are written in hexadecimal 4000l notation. Address Address Address DATA 16K 4D o 41 8 IOption datal 10 DATA 16K 33 1 FF 9 ~ 37 2 FF A 7FFFJ FFFF_I 37 3 FF B 30 4 FF C 32 5 FF D 4D 6 FF E 32 7 FF F STP instruction option One of the following sets of data should be written to the option data address (10 16 ) of the EPROM you have ordered. Check @ in the appropriate box. o STP instruction enable I 01 '6 Address 1016 o STP instruction disable I 00 '6 Address 1016 Mark specification Mark speCification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702M2AXXXFP) and attach to the Mask ROM Order Con- firmation Form. >* 4. Comments 298 APPENDIX Appendix. 7 ROM ordering method GZZ-SH02-47A< 99AO) MELPS 7700 MASK ROM ORDER CONFIRMATION FORM I Mask ROM number I SINGLE-CHIP 16-BIT MICROCOMPUTER M37702M2BXXXFP Dale: MITSUBISHI ELECTRIC Section head Supervisor signature signature C. ·iii (J OJ a: Note: Please fill in all items marked* Responsible TEL officer Supervisor Company name ( ) OJ (J '"OJ :; c Customer '" 0; :::l C Date Date: '" Cl !E ·iii issued '* 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the 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 differ from this data. Thus, the customer must be especially careful in verifying the data con- tained in the EPROMs submitted. Checksum code for entire EPROM areas 1.-1_-,-_-,-_-,-_-, (hexadecimal notation) EPROM Type: (1) Set "FF'6" in the shaded area. 0 27256 0 27512 (2) Address 0'6 to 10'6 are the area for storing the data on model designation and options. This area -"" must be written with the data shown below. Details for option data are given next in the sec- V~·OO1O tion describing the STP instruction option. ................ 4000l Address and data are written in hexadecimal notation. Address Address Address DATA 16K 4D o 42 8 IOption data I 10 33 1 FF 9 J ~. DATA 16K 37 2 FF A 7FFF FFFF_I 37 3 FF B 30 4 FF C 32 5 FF D 4D 6 FF E 32 7 FF F STP instruction option One of the following sets of data should be written to the option data address (10,6 ) of the EPROM you have ordered. Check @ in the appropriate box. o STP instruction enable I 01'6 Address 10'6 o STP instruction disable I 00'6 Address 10,6 '* 3. Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702M2BXXXFP) and attach to the Mask ROM Order Con- firmation Form. '* 4. Comments 299 APPENDIX Appendix. 7 ROM ordering method GZZ-SH02-36A <98AO) MELPS 7700 MASK ROM ORDER CONFIRMATION FORM IMask ROM number I SINGLE-CHIP 16-BIT MICROCOMPUTER M37702M4-XXXFP Date: MITSUBISHI ELECTRIC Section head Supervisor siQnature signature C. 'iii (J Q) a: Note: Please fill in all items marked*< TEL Responsible Supervisor Company offIcer Q) en name ( ) (J ~ c ::J Customer Date 'en" n;c ::J OJ Date: !!2 '0; issued *' ,. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the identical data, we will produce masks based on this data. We shall a·ssume the responsibility for errors only if the mask ROM data on the products we produce differ from this data. Thus, the customer must be especially careful in verifying the data con- tained in the EPROMs submitted. Checksum code for entire EPROM areas 1'--_'--_'--_'----' (hexadecimal notation) EPROM Type: (1) Set "FF,6" in the shaded area. o 27512 (2) Address 0'6 to 10'6 are the area for storing the data on model designation and options. This area ~-------, 0000 must be written with the data shown below. Details for option data are given next in the sec- ~!:~:I tion describing the STP instruction option. Address and data are written in hexadecimal notation. Address Address Address DATA 3dK 40 33 o , 20 FF 8 9 1Option data 110 L -_ _ _- - ' FFFF J 37 37 2 3 FF FF A B 30 4 FF C 32 5 FF o 40 6 FF E 34 7 FF F STP instruction option One of the following sets of data should be written to the option data address (10,6) of the EPROM you have ordered. Check @ in the appropriate box. o STP instruction enable 1 01 '6 Address 10'6 o STP instruction disable 1 00 '6 Address 10,6 Mark speCification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702M4-XXXFP) and attach to the Mask ROM Order Con- firmation Form. *' 4. Comments 300 APPENDIX Appendix. 7 ROM ordering method GZZ-SH02-37 A <98AO ) MELPS 7700 MASK ROM ORDER CONFIRMATION FORM I Mask ROM number I SINGLE-CHIP 16-BIT MICROCOMPUTER M37702M4AXXXFP Date: MITSUBISHI ELECTRIC Section head Supervisor signature a. .0; sig"nature " Q) a: Note: Please fill in all items marked* TEL Responsible Supervisor officer Company name Q) u '"~ ( ) c: ::l Customer ::l -co co '" c: Date Date: -'" "Cii Cl issued 7.{ 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the 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 differ from this data. Thus, the customer must be especially careful in verifying the data con- tained in the EPROMs submitted. Checksum code for entire EPROM areas 1'------'_----' ----' -----' (hexadecimal notation) EPROM Type: (1) Set "FF'6" in the shaded area. o 27512 (2) Address 0'6 to 1 0'6 are the area for storing the data on model designation and options. This area 0000 must be written with the data shown below. Details for option data are given next in the sec- ~::l tion describing the STP instruction option. Address and data are written in hexadecimal notation. Address Address Address 4D o 41 B IOptlon data I 10 DATA 32K 33 1 FF 9 37 2 FF A L -_ _ _ _ IFFFFJ 37 3 FF B 30 4 FF C 32 5 FF D 4D 6 FF E 34 7 FF F STP instruction option One of the following sets of data should be written to the option data address (10,6 ) of the EPROM you have ordered. Check @ in the appropriate box. o STP instruction enable I 01'6 Address 10 '6 o STP instruction disable I 00'6 Address 10'6 Mark specification Mark speCification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702M4AXXXFP) and attach to the Mask ROM Order Con- firmation Form. 7.{ 4. Comments 301 APPENDIX Appendix. 7 ROM ordering method GZZ-SH02-38A <98AO > MELPS 7700 MASK ROM ORDER CONFIRMATION FORM I Mask ROM number I SINGLE-CHIP 16-BIT MICROCOMPUTER M37702M4BXXXFP Dale: MITSUBISHI ELECTRIC Section head Supervisor signature sig"nature 1i "Qi 0 Q) CC Note: Please fill in all items marked* TEL Responsible Supervisor officer Company name Q) '"~ ( ) - 0 C ::::I Customer ''"" c ::::I '" Date Date: -'" "00 01 issued * 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the 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 differ from this data. Thus, the customer must be especially careful in verifying the data con- tained in the EPROMs submitted. Checksum code for entire EPROM areas L.I_~_~_~_...J (hexadecimal notation) EPROM Type: (1) Set "FF16" in the shaded area. 0 27512 (2) Address 0'6 to 10,6 are the area for storing the data on model designation and options. This area 0000 must be written with the data shown below. Details for option data are given next in the sec- ~"'" tion describing the STP instruction option. Address and data are written in hexadecimal notation . .. ...... .. .... .J BOOOl Address Address Address 4D a 42 8 IOption data I 10 DATA 32K 33 1 FF 9 37 2 FF A I FFFFJ 37 3 FF B 30 4 FF C 32 5 FF D 4D 6 FF E 34 7 FF F STP instruction option One of the following sets of data should be written to the option data address (10,6) of the EPROM you have ordered. Check @ in the appropriate box. o STP instruction enable I 01 '6 Address 10'6 o STP instruction disable I 00 '6 Address 10,6 Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate aOP6N Mark Specification Form (for M37702M4BXXXFP) and attach to the Mask ROM Order Con- firmation Form. * 4. Comments 302 APPENDIX Appendix. 7 ROM ordering method GZZ-SH02-54A ( 99AO > ROM number MELPS 7700 WRITING TO PROM ORDER CONFIRMATION FORM SINGLE-CHIP 16-BIT MICROCOMPUTER Date: M37702E2-XXXFP Section head Supervisor slqnature SIQnature MITSUBISHI ELECTRIC C. ·iii () Q) c:: Note: Please fill in all items marked* TEL Responsible Supervisor officer Company Vl Q) name ( ) () ~ Customer c: => Date '=>" roc: Vl Cl Date: !!J. ·iii issued * 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the identical data, we will produce writing to PROM based on this data. We shall assume the responsibility for errors only if the written PROM data on the products we produce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. Checksum code for entire EPROM areas l....1_~_~_~_....J (hexadecimal notation) EPROM Type: (1) Set "FF16" in the shaded area. 0 27256 0 27512 (2) Address 016 to OF16 are the area for storing the data on model designation. This area must be 0000 0000 written with the data shown below. Address and data are written in hexadecimal W~ OOOF • OOOF notation. Address Address 4000l 4D o 20 8 33 1 FF 9 COOOl 37 2 FF A DATA 16K DATA 37 3 FF B J 16K 7FFF FFFF J 30 32 4 5 FF FF C D 45 6 FF E 32 7 FF F Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702E2-XXXFP) and attach to the Writing to PROM Order Confirmation Form. * 3. Comments 303 APPENDIX Appendix. 7 ROM ordering method GZZ-SHD2-55A <99AD) ROM number MELPS 7700 WRITING TO PROM ORDER CONFIRMATION FORM SINGLE-CHIP 16-BIT MICROCOMPUTER Date: M37702E2AXXXFP Section head Supervisor signature signature MITSUBISHI ELECTRIC ii 'iii 0 Q) a: Note: Please fill in all items marked* Responsible TEL officer Supervisor Company name ( ) Q) 0 <: '" ~ :::l Customer '" <: iil :::l Date Date: '" -'" "00 Cl issued * 1. Confirmation Specify the name of the product being ordered and the type. of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the identical data, we will produce writing to PROM based on this data. We shall assume the responsibility for errors only if the written PROM data on the products we produce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. Checksum code for entire EPROM areas I ~--~--~--~~ (hexadecimal notation) EPROM Type: (1) Set "FF16" in the shaded area. o 27256 o 27512 (2) Address 016 to OF 16 are the area for storing the data on model designation. This area must be 0000 0000 written with the data shown below. OOOF OOOF Address and data are written in hexadecimal notation. Address Address 4D o 41 8 33 1 FF 9 4000l -- COOOl 37 2 FF A DATA 16K DATA 37 3 FF B 16K '--_ _ _--' 7FFF J '--_ _ _---' FFFF J 30 32 45 4 5 6 FF FF FF C D E 32 7 FF F Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702E2AXXXFP) and attach to the Writing to PROM Order Confirmation Form. * 3. Comments 304 APPENDIX Appendix. 7 ROM ordering method GZZ-SH04-07 A (OZAO > ROM number MELPS 7700 WRITING TO PROM ORDER CONFIRMATION FORM SINGLE-CHIP 16-BIT MICROCOMPUTER Date: M37702E2BXXXFP Section head Supervisor signature signature MITSUBISHI ELECTRIC C. ·iii 0 Q) a: Note: Please fill in all items marked?! TEL Responsible Supervisor officer Company name ( ) Q) 0 '"~ c: :::J Customer co iii :::J c: Date issued Date: '" ~ Cl ·iii * 1. Confirmation Specify the name of the product being ordered and the type. of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the identical data, we will produce writing to PROM based on this data. We shall assume the responsibility for errors only if the written PROM data on the products we produce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. Checksum code for entire EPROM areas .... 1__1,--_·-,-1_-,-_-, (hexadecimal notation) EPROM Type: (1) Set "FF16" in the shaded area. D 27256 0 27512 (2) Address 016 to OF 16 are the area for storing the data on model designation. This area must be 0000 0000 written with the data shown below. OOOF OOOF Address and data are written in hexadecimal • • notation. Address Address 4D o 42 8 33 1 FF 9 4000l COOOl 37 2 FF A DATA 16K DATA 37 3 FF B 16K 7FFFJ FFFF J 30 32 4 5 FF FF C D 45 6 FF E 32 7 FF F Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702E2BXXXFP) and attach to the Writing to PROM Order Confirmation Form. * 3. Comments 305 APPENDIX Appendix. 7 ROM ordering method GZZ-SH03-67A< 07AO > ROM number MELPS 7700 WRITING TO PROM ORDER CONFIRMATION FORM SINGLE-CHIP 16-BIT MICROCOMPUTER Date: M37702E4-XXXFP Section head Supervisor signature signature MITSUBISHI ELECTRIC E. ., 'iii Q) II: Note: Please fill in all items marked* Responsible TEL officer Supervisor Company III name ( ) .,c:Q) Q) ~ ::l Customer §10 Date Date: ~ .~ - III issued * 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the identical data, we will produce writing to PROM based on this data. We shall assume the responsibility for errors only if the written PROM data on the products we produce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. Checksum code for entire EPROM areas ... 1_-,-_-,-_-,-_-, (hexadecimal notation) EPROM Type: (1) Set "FF16" in the shaded area. o 27512 (2) Address 016 to OF16 are the area for storing the data on model designation. This area must be 0000 written with the data shown below. Address and data are written in hexadecimal ~~' notation. Address Address 4D o 2D 8 . . . . . . . . . . . . BOOOl 33 1 FF 9 37 2 FF A DATA 32K 37 3 FF B ' - - -_ _ _- - . ! FFFF J 30 32 45 4 5 6 FF FF FF C D E 34 7 FF F Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702E4-XXXFP) and attach to the Writing to PROM Order Confirmation Form. Comments 306 APPENDIX Appendix. 7 ROM ordering method GZZ-SH03-70A <07 AO) ROM number MELPS 7700 WRITING TO PROM ORDER CONFIRMATION FORM SINGLE-CHIP 16-BIT MICROCOMPUTER Date: M37702E4AXXXFP Section head Supervisor signature sig·nature MITSUBISHI ELECTRIC C. .Qj u Q) a: Note: Please fill in all items marked* Responsible TEL officer Supervisor Company name ( ) Q) u "' c: :; Q) Customer ro 1ii ::l c: Date Date: "' "00Ol -"' issued * 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the identical data, we will produce writing to PROM based on this data. We shall assume the responsibility for errors only if the written PROM data on the products we produce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. . Checksum code for entire EPROM areas L..I_.J..._.J..._.J..._-' (hexadecimal notation) EPROM Type: (1) Set "FF16" in the shaded area. o 27512 (2) Address 016 to OF 16 are the area for storing the data on model designation. This area must be 0000 written with the data shown below. Address and data are written in hexadecimal %W1' ' .~. BOOOl notation. 4D 33 Address a 1 41 FF Address 8 9 37 2 FF A DATA 32K 37 3 FF B ~_ _ _ _ FFFFJ 30 32 4 5 FF FF C D 45 6 FF E 34 7 FF F Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702E4AXXXFP) and attach to the Writing to PROM Order Confirmation Form. * 3. Comments 307 APPENDIX Appendix. 7 ROM ordering method GZZ-SH03-38A (01 AD) ROM number MELPS 7700 WRITING TO PROM ORDER CONFIRMATION FORM SINGLE-CHIP 16-BIT MICROCOMPUTER Date: M37702E4BXXXFP Section head Supervisor siQnature siQnature MITSUBISHI ELECTRIC C. 'iii 0 Q) a: Note: Please fill in all items marked* Responsible TEL officer Supervisor Company Q) VJ Q) name ( ) 0 :; c: Customer ':>" 7ac: VJ Date VJ 0> Date: - '(ij issued '* 1. Confirmation Specify the name of the product being ordered and the type of EPROMs submitted. Three sets of EPROMs are required for each pattern (Check @ in the appropriate box). If at least two of the three sets of EPROMs submitted contain the identical data, we will produce writing to PROM based on this data. We shall assume the responsibility for errors only if the written PROM data on the products we produce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. I Checksum code for entire EPROM areas L..._ - ' - _ - ' - _ - ' - _ - ' (hexadecimal notation) EPROM Type: (1) Set "FF16 " in the shaded area. o 27512 (2) Address 016 to OF16 are the area for storing the data on model designation. This area must be r - - - - - - - , 0000 written with the data shown below. Address and data are written in hexadecimal ~OO" .....~.'OO'l notation. Address Address 4D o 42 8 33 1 FF 9 37 2 FF A DATA 32K 37 3 FF B '---_ _ _----" FFFF J 30 32 45 4 5 6 FF FF FF C D E 34 7 FF F Mark specification Mark specification must be submitted using the correct form for the type of package being ordered fill out the appropriate 80P6N Mark Specification Form (for M37702E4BXXXFP) and attach to the Writing to PROM Order Confirmation Form. '* 3. Comments 308 APPENDIX Appendix. 7 ROM ordering method 80P6N (80-PIN QFP) MARK SPECIFICATION FORM Mitsubishi IC catalog name I ~----------------------------~ Please choose one of the marking types below (A, B, C), and enter the Mitsubishi IC catalog name and the special mark (if needed). A. Standard Mitsubishi Mark - - - - - - Mitsubishi IC catalog name Mltsublshi product number (6-diglt) B. Customer's Parts Number + Mitsubishi IC Catalog Name , - -Customer's Parts Number ___ J Note: The fonts and size of characters are standard Mitsu- bishi type. - - - - - Mitsubishi IC catalog name Note1: The mark field should be written right aligned. 2: The fonts and size of characters are standard Mitsu- bishi type. 3: Customer's parts number can be up to 14 alpha- numeric characters for capital letters, hyphens, commas, periods and so on. 4: If the Mitsubishi logo)... is not required, check the box below. )... Mitsubishi logo is not required D C. Special Mark Required Note1: If special mark is to be printed, indicate the desired layout of the mark in the left figure. The layout will be duplicated technically as close as possible. Mit- subishi product number (6-digit) and Mask ROM number (3-digit) are always marked for sorting the products. 2: If special character fonts (e.g., customer's trade mark logo) must be used in Special Mark, check the box below. For the new special character fonts a clean font ori- ginal (ideally logo drawing) must be submitted. Special character fonts required D 309 APPENDIX Appendix 8. Ie socket Appendix 8. IC socket 1. IC socket EPROM version of M37702 group (with BO-pin ceramic LCC package) can use IC sockets described below . • IC sockets for LCC package(BODO) provided by YAMAICHI ELECTRONICS Co., Ltd. Type name IC61-0B04-046 Type name IC61-0B04-034 (low profile model for mounting on printed circuit board) 20.0±03 15.8+0·1 INDEX-1 <3300 hole ~ c 'i1 ro 'i1 .g ci ro 'iii ci 0 ~ '"'i1 ,;!o '" ~ ..E; 0 N a-..: "' ~ ro .... 0 N. 'cC" N N " cD ;'! Ii ,..: N M N 0 N " M X ro ci N a '" 11.0 (Be non-prominence in this circle N ~ o N 0.8±<) 15 cD 0.8 X 15=12 .Oi025 22.00±05 SEC. X-X (S=10/1 ) Fig. 7 IC socket (type name IC61-0804-046) by YAMAICHI ELECTRONICS Co., Ltd. outline 310 APPENDIX Appendix 8. Ie socket 20.0±o.3 15.0 (connective position) 0.8X15=120±015 tNDEX-1 0.8 ±01 c . a'" .~ c 11 0 8e non- rorrinence in this clrde) Ie extraction notch (two poSition) (depth 38) 8.0±04 a N '"" O~~rT--~~~~~~HHHH~-.~ . a O.8±01S ~~~~~~~i1~r--r---L~ 0.8 X 15= 120±025 17.4±o.5 196±05 SEC. X-X (5=1011 ) Fig. 8 IC socket (type name IC61-0804-034) by YAMAICHI ELECTRONICS Co., Ltd. outline [Precaution when using IC socket] 1. The profile of IC61-0804-046 is higher than IC61-0804-034. IC61-0804-046 is an exclusive use of mounting on printed circuit board and easy to solder. 2. Use IC61-0804-046 and IC61-0804-034 sockets for evaluation. Do not use these Ie sockets mounting EPROM models for mass production. 311 APPENDIX Appendix 8. Ie socket 2. Example of printed circuit board mount pad Figure 9 shows the example of printed circuit board mount pad. This mount pad can mount 80P6N package, and IC61-0804-046 and IC61-0804-034 sockets provided by YAMAICHI ELECTRONICS Co., Ltd. which is described in "1. IC socket" . The mount pad shown in Figure 9 is one of examples. The user should consider the mounting condition and the standard when specifying the dimension for mass production board. o 8X23 =18 . - 4±o 1 a.8±OO5 , INDEX-l position I I '~~~~~~~~~~~~~,~~~~ / I - -$ I I - I I I I ffi '-V I' I I I I I I i I :g I I I ~ ~ CD ~ I I I a ~ ~ ..-~ I I I I -----j-------- ! I -, '" " III C') '" " ~ I I I ·8 I~ I i :I I I I x CD a I I I I ffi I I I I 't:.: (1200) - i 19.8±o1 ~"- 4- I/11.6(Stand-off position) 28.4±o 1 Fig. 9 Example of mount pad on printed circuit board 312 APPENDIX Appendix 9. M66800SP/FP Appendix 9. M66800SP/FP 1. Overview The M66800SP/FP is a 16M-byte external memory control Ie for the M37702 group. It uses a MAST (Mitsubishi Advanced Schottky TTL) process to enable fast operation. 2. Features • Supports no wait operation of the M37702 group under the following conditions: (1) Using 120ns (Max.) access time memory at source oscillating frequency of 12MHz (2) Using 100ns (Max.) access time memory at source oscillating frequency of 13MHz • Internal read/write control circuit with independent read/write output • Two internal octal latch circuits for address • Internal chip selectable circuit that can fully decode 16M bytes • Internal Ready signal generation circuit • Pin assignment that facilitates connection to M37702 group 313 APPENDIX Appendix 9. M66800SP/FP -+WAO Outline 64P4B l:tl0t:: 1~I~c I>-~ ~w ~ ~ ~I~'~ ~ ~ ~ ~ rw ~ ~ t ~ ~ t t t ~t~~~~ eS13 - - 1 SHE Am - - AD23 eSl0 - - 4 +- AD22 eS9 - - ess - - ~ AD20 eS7 - - 7 s:: 0') - - AD19 - - AD1S CS5 ..-.- 9 0') - - AD17 GND ex> - - AD16 0 __ AD15 eS4 - - 0 "'T1 __ AD14 eS3 - - eS2 - - "U __ AD13 eSl __ AD12 eso ~ - - ADll __ AD10 A23 - - A22 - - AD9 A21 - - ADS A20 - - ADO ~ ~ ~ ~ i ~ !!!i!! ,,><..... CDIt'l.q.UMN .... o Ol '" < ;;: :; ( «<~«« « « Outline 64P6W Fig. 10 M66800SP/FP pin configuration 314 APPENDIX Appendix 10. Instruction code table Appendix 10. Instruction code table INSTRUCTION CODE TABLE-1 ~'~'O Hexadecimal 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0 7- 0 4 netalien 0 1 2 3 4 5 6 7 8 9 A B C D E F ORA ORA SEB ORA ASL ORA ORA ASL SEB ORA ASL ORA 0000 0 BRK PHP PHD A,(DIR,X) A,SR DIR,b A,DIR DIR A,L(DIR) A,IMM A ABS,b A,ABS ABS A,ABL ORA ORA ORA CLB ORA ASL ORA ORA DEC CLB ORA ASL ORA 0001 1 BPL CLC TAS A,(DIRl.Y A,(DIR) A,(SR),Y DIR,b A,DIR,X DIR,X A,L(DIR),Y A,ABS,Y A ABS,b A,ABS,X ABS,X A,ABL,X JSR AND JSR AND BBS AND ROL AND AND ROL BBS AND ROL AND 0010 2 PLP PLD ABS A,(DIR,X) A8L A,SR DIR,b,R A,DIR DIR A,L(DIR) A,IMM A A8S,b,R A,A8S A8S A,A8L AND AND AND 88C AND ROL AND AND INC 88C AND ROL AND 0011 3 8MI SEC TSA A,(DIR),Y A,(DIR) A,(SR),Y DIR,b,R A,DIR,X DIR,X A,L(DIR),Y A,ABS,Y A ABS,b,R A,ABS,X A8S,X A,ABL,X EOR EOR EOR LSR EOR EOR LSR JMP EOR LSR EOR 0100 4 RTI Nole 1 MVP PHA PHG A,(DIR,X) A,SR A,DIR DIR A,L(DIR) A,IMM A A8S A,A8S A8S A,A8L EOR EOR EOR EOR LSR EOR EOR JMP EOR LSR EOR 0101 5 8VC MVN CLI PHY TAD A,(DIRl.Y A,(DIR) A,(SR),Y A,DIR,X DIR,X A,L(DIR),Y A,AB5,Y A8L A,A8S,X A8S,X A,ABL,X ADC ADC LDM ADC ROR ADC ADC ROR JMP ADC ROR ADC 0110 6 RTS PER PLA RTL A,(DIR,X) A,SR DIR A,DIR DIR A,L(DIR) A,IMM A (A8S) A,ABS ABS A,A8L ADC ADC ADC LDM ADC ROR ADC ADC JMP ADC ROR ADC 0111 7 BVS SEI PLY TDA A,(DIRl.Y A,(DIR) A,(SR),Y DIR,X A,DIR,X DIR,X A,L(DIR),Y A,ABS,Y (ABS,X) A,ABS,X ABS,X A,ABL,X BRA STA BRA STA STY STA STX STA STY STA STX STA 1000 8 DEY Nole 2 TXA PHT REL A,(DlR,X) REL A,SR DIR A,DIR DIR A,L(DIR) ABS A,ABS ABS A,ABL STA STA STA STY STA STX STA STA LDM STA LDM STA 1001 9 BCC TYA TXS TXY A,(DIR),Y A,(DIR) A,(SR),Y DIR,X A,DIR,X DIR,Y A,L(DIRl.Y A,ABS,Y ABS A,ABS,X ABS,X A,ABL,X LOY LOA LOX LOA LOY LOA LOX LOA LOA LOY LOA LOX LOA 1010 A TAY TAX PLT ,IMM A,(DIR,X) IMM A,SR DIR A,DIR DIR A,L(DIR) A,IMM ABS A,ABS ABS A,ABL LOA LOA LOA LOY LOA LDX LDA LDA LOY LOA LDX LDA 1011 B 8CS CLV TSX TYX A,(DIRl.Y A,(DIR) A,(SR),Y DIR,X A,DIR,X DIR,Y A,L(DIR),Y A,ABS,Y ABS,X A,ABS,X ABS,Y A,ABL,X CPY CMP CLP CMP CPY CMP DEC CMP CMP CPY CMP DEC CMP 1100 C INY DEX WIT IMM A,(DIR,X) IMM A,SR DIR A,DIR DIR A,L(DIR) A,IMM ABS A,ABS ABS A,ABL CMP CMP CMP CMP DEC CMP CMP JMP CMP DEC CMP 1101 0 BNE PEl CLM PHX STP A,(DIRl.Y A,(DIR) A,(SR),Y A,DIR,X DIR,X A,L(DIR),Y A,ABS,Y L(ABS) A,ABS,X ABS,X A,ABL,X CPX SBC SEP SBC CPX SBC INC SBC SBC CPX SBC INC SBC 1110 E INX NOP PSH IMM A,(DIR,X) IMM A,SR DIR A,DIR DIR A,L(DIR) A,IMM ABS A,ABS ABS A,ABL SBC SBC SBC SBC INC SBC SBC JSR SBC INC SBC 1111 F BEQ PEA SEM PLX PUL A,(DIR),Y A,(DIR) A,(SR),Y A,DIR,X DIR,X A,L(DlR),Y A,ABS,Y (ABS,X) A,ABS,X A8S,X A,ABL,X Nole 1 : 42'6 specifies Ihe conlenls of Ihe INSTRUCTION CODE TABLE-2 Aboullhe second word's codes, refer 10 Ihe INSTRUCTION CODE TABLE-2 2 : 89'6 specifies Ihe conlenls of Ihe INSTRUCTION CODE TABLE-3 Aboullhe Ihlrd word's codes, refer 10 Ihe INSTRUCTION CODE TABLE-2, 315 APPENDIX Appendix 10. Instruction code table INSTRUCTION CODE TABLE-2 (The first word's code of each instruction is 42 16) ~o,-~ 0000 0001 0010 0011 01 00 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 D ~D Hexadecimal 1 2 4 5 8 A 7 4 notatIon 0 3 6 7 9 B C D E F ORA ORA ORA ORA ORA ASL ORA ORA 0000 0 B,(OIR,X) B,SR B,DIR B,L( OIR) B,IMM B B,ABS B,ABL ORA ORA ORA ORA ORA ORA DEC ORA ORA 0001 1 TBS B,(OIR),Y B,(DIR) B,(SR),Y B,DIR,X B,L(DIR), B,ABS,Y B B,ABS,X B,ABL,X AND AND AND AND AND ROL AND AND 0010 2 B,(OIR,X) B,SR B,DIR B,L(OIR) B,IMM B B,ABS B,ABL AND AND AND AND AND AND INC AND AND 0011 3 TSB B,(OIR),Y B,(DIR) B,(SR),Y B,DIR,X 8,L(DIR), B,ABS,Y B B,ABS,X B,ABL,X EaR EOR EOR EOR EOA LSA EOA EaR 0100 4 PHB B,(OIR,X) B,SA B,DIR B,L(OIR) B,IMM B B,ABS B,ABL EOA EOA EaR EaR EaR EOA EOA EOA 0101 5 TBD B,(OIR),Y B,(DIA) B,(SR),Y B,DIA,X B,L(DIR), B,ABS,Y B,ABS,X B,ABL,X ADC ADC ADC ADC ADC ROA ADC ,ADC 0110 6 PLB B,(DIR,X) B,SA B,DIA B,L(OIR) B,IMM B B,ABS B,ABL ADC ADC ADC ADC ADC ADC ADC ADC 0111 7 TDB B,(DIR),Y B,(DIA) B,(SR),Y B,DIR,X B,L(DIR),Y B,ABS,Y B,ABS,X B,ABL,X STA STA STA STA STA STA 1000 8 TXB B,(OIR,X) B,SR B,DIA B,L(OIR) B,ABS B,ABL STA STA STA STA STA STA STA STA 1001 9 TYB B,(OIR),Y B,(DIA) B,(SR),Y B,DIA,X B,L(DIR), B,ABS,Y B,ABS,X B,ABL,X LDA LDA LDA LDA LDA LDA LDA 1010 A TBY TBX B,(OIR,X) B,SA B,DIR B,L(OIR) B,IMM B,ABS B,ABL LDA LDA LDA LDA LDA LDA LDA LDA 1011 B B,(OIR),Y B,(DIR) B,(SR),Y B,DIR,X B,L(DIR), B,ABS,Y B,ABS,X B,ABL,X CMP CMP CMP CMP CMP CMP CMP 1100 C B,(OIR,X) B,SA B,DIA B,L(OIR) B,IMM B,ABS B,ABL CMP CMP CMP CMP CMP CMP CMP CMP 1101 D B,(OIR),Y B,(DIR) B,(SR),Y B,DIA,X B,L(DIR), B,ABS,Y B,ABS,X B,ABL,X SBC SBC SBC SBC SBC SBC SBC 1110 E B,(OIR,X) B,SA B,DIR B,L( OIR) B,IMM B,ABS B,ABL SBC SBC SBC SBC SBC SBC SBC SBC 1111 F B,(OIR),Y B,(DIA) B,(SR),Y B,DIA,X B,L(DIR), B,ABS,Y B,ABS,X B,ABL,X 316 APPENDIX Appendix 10. Instruction code table INSTRUCTION CODE TABLE-3 (The first word's code of each instruction is 89 16) ~~oo Hexadecimal 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 D 7- D. nolalion 0 1 2 3 4 5 6 7 8 9 A B C D E F MPY MPY MPY MPY MPY MPY MPY 0000 0 (DIR,X) SR DIR L(DIR) IMM ABS ABL MPY MPY MPY MPY MPY MPY MPY MPY 0001 1 (DIR),Y (DIR) (SR),Y DIR,X L(DIR},Y ABS,Y ABS,X ABL,X DIV DIV DIV DIV DIV DIV DIV 0010 2 XAB (DIR,X) SR DIR L(DIR) IMM ABS ABL DIV DIV DIV DIV DIV DIV DIV DIV 0011 3 (DIRl,Y (DIR) (SR),Y DIR,X L(DIR),Y ABS,Y ABS,X ABL,X RLA 0100 4 IMM 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B LDT 1100 C IMM 1101 D 1110 E '- 1111 F 317 APPENDIX Appendix 11. Machine instructions Appendix 11. Machine instructions MACHINE INSTRUCTIONS Addressmg mode Symbol Function Details IMP IMM A DIR DIR,b DIR,X DIR,Y (DIR) (OIR,X) (OIR),Y op n # op n II op n #: op n lIop nil op n II op nil op n 11 op n II op n 11 ADC Acc,C - Acc+ M+ C Adds the carry, the accumulator and the memory contents 69 2 2 65 4 2 75 5 2 726 2 61 7 2 71 8 2 (Note 1,2) The result IS entered IOta the accumulator When the D flag IS "0", bmary additions IS done", and when the D flag IS 42 4 3 42 6 3 42 7 3 42 8 3 42 9 3 42 10 3 "1", deCimal addition IS done 69 65 75 72 61 71 AND Ace - AccA M Obtains the logical product of the contents of the accumu- 29 2 2 25 4 2 35 5 2 32 6 2 21 7 2 31 8 2 (Note 1 ,2) lator and the contents of the memory The result IS en- tered Into the accumulator 42 4 3 42 6 3 42 7 3 42 8 3 42 9 3 42 10 3 29 25 35 32 21 31 ASL m=O Shifts the accumulator or the memory contents one bit to OA 2 1 06 7 2 16 7 2 (Note 11 [9~-0 the left "0" IS entered mto bit 0 of the accumulator or the memory The contents of bit 15 (bit 7 when the m flag IS 42 4 2 m=l "1") of the accumulator or memory before shift IS entered OA [9-~-0 IOta the C flag BBC Mb=O') Tests the specified bit of the memory Branches when all (Note 3,5) the contents of the specIfied bit IS "0" BBS Mb=I" Tests the specified bit of the memory Branches when all (Note 3,5) the contents of the speCIfied bit IS "1" BCC C=O" Branches when the contents of the C flag IS "0" (Note3) BCS C=1 ? Branches when the contents of the C flag IS "1" (Nole 3) BEQ 2=1 ? Branches when the contents of the 2 flag IS "1" (Note3) BMI N=l ? Branches when the contents of the N flag IS "1" (Note3) BNE Z=O? Branches when the contents of the Z flag IS "a" (Note3) BPL N=O? Branches when the contents of the N flag IS "0" (Note3) BRA PC-PC±offset Jumps to the address indicated by the program counter (Note4) PG-PG+l plus the offset valu~ (carry occured) PG-PG-l (borrow occured) BRK PC-PC+2 Executes software interruption 0015 2 M(S)-PG S-S-1 M(S)-PCH S-S-1 M(S)-PCL S-S-1 M(S)-PSH , S-S-1 M(S)-PSL S-S-1 1-1 PCL-AD l PCH-AD H PG-0016 BVC V=O? Branches when the contents of the V flag IS "a" (Note3) BVS V=l ? Branches when the contents of the V flag IS "1" (Note 3) CLB Mb-O Makes the contents of the specified bit 10 the memory "0" 14 8 3 (Note5) CLC C-O Makes the contents of the C flag "0" 18 2 1 CLI 1-0 Makes the contents of the I flag "0" 58 2 1 CLM m-O Makes the contents of the m flag "0" 08 2 1 CLP PSb-O Specifies the brt posrtron In the processor status regrster by the brt C2 4 2 pattern of the second byte rn the Instructron, and sets "0" rn that bit -- CLV V-O Makes the contents of the V, flag "0" B8 2 1 CMP Acc- M Compares the contents of the accumulator with the contents of C9 2 2 C5 4 2 05 5 2 02 6 2 CI 7 2 01 8 2 (Note 1,2) the memory 42 4 3 42 6 3 42 7 3 42 8 3 42 9 3 42 10 3 C9 C5 05 02 CI DI 318 APPENDIX Appendix 11. Machine instructions Addressing mode Processor status register L(DIA) L(OIR),Y ABS ABS,b ABS,X ABS,Y ABL ABL,X (ABS) L(ABS) (ABS,X) STK AEL OIR,b,R ABS,b,R SA (SA),Y BLK 10 9 8 7 6 5 4 3 2 I 0 op n lIop nil op n lIop n II op n II op nil op n II op n II OIl n II op n II op n II op n II op n II op n II op n II op n II op n II op n II IPL N V m x D I Z C 6710 277 II 2 60 4 3 70 6 3 79 6 3 6F 6 4 7F 7 4 63 5 2 73 8 2 N V Z C 4212 3 42 13 3 426 4 42 8 4 42 8 4 42 8 5 42 9 5 42 7 3 42 10 3 67 77 60 7D 79 6F 7F 63 73 710 2 37 II 2 20 4 3 3D 6 3 39 6 3 2F 6 4 3F 7 4 23 5 2 33 8 2 N Z 212 3 42 13 3 ~2 6 4 42 8 4 42 8 4 42 8 5 42 9 5 42 7 3 42 10 3 27 37 20 3D 39 2F 3F 23 33 OE 7 3 IE 8 3 N Z C 34 7 4 3C 8 5 24 7 4 2C 8 5 90 4 2 BO 4 2 FO 4 2 30 4 2 004 2 10 4 2 80 4 2 82 4 3 50 4 2 70 4 2 IC 9 4 0 0 0 Specified flag be- comes "0" 0 CliO 2 07 II 2 CO 4 3 4212 3 42 13 3 42 6 4 C7 07 DO 6 3 D9 6 3 CF 6 4 OF 7 4 42 8 4 42 8 4 42 8 5 42 9 5 C3 5 2 03 8 2 42 7 3 42 10 3 N l TC pO DO 09 CF OF C3 03 I 319 APPENDIX Appendix 11. Machine instructions Addressing mode Symbol Function Details IMP IMM A DIR DIR,b DIR,X DIR,Y (DIRI (DIR,X) (DIR),Y op n # op n # 0p n # op n # op n # op n # opn# op n # op n # op n # CPX X-M Compares the contents of the Index register X with the EO 2 2 E4 4 2 (Note 21 contents of the memory CPY Y-M Compares the contents of the Index register Y with the CO 2 2 C4 4 2 (Note 21 contents of the memory DEC Ace-Ace-lor Decrements the contents of the accumlator or memory by IA 2 I C6 7 2 D6 7 2 (Note 11 M-M-I 1 42 4 2 IA DEX X-X-I Decrements the contents of the Index register X by 1 CA 2 I DEY Y-Y-I Decrements the contents of the Index register Y by 1 88 2 I DIV A(quotlentl-B,A/M The numeral that places the coolents ct accumulala B to the higher ader and the 8927 3 8929 3 893 o 3 8931 3 8932 3 893 3 3 (Nole 2,101 B( remainder) cootentsdacclJrrKJlatcrAtoihe looer ocder IS dlVlded'r.JtthecmtentsdthemelTlO')' 29 25 35 32 21 31 Th'J quctlent IS entered Into accumulatcr Aand the remarnder mto accumuiata 8 EaR Acc-AccVM Logical exclusive sum IS obtained of the contents 01 the 492 2 45 4 2 55 5 2 52 6 2 41 7 2 51 8 2 (Note 1,21 accumulator and the contents of the memory The result IS placed mto the accumulator 42 4 3 42 6 3 42 7 3 42 8 3 42 9 3 421 o 3 49 45 55 52 41 51 INC Acc-Acc+1 or Increments the contents of the accumulator or memory by 3A 2 I E6 7 2 F6 7 2 (Note 11 M -M+I 1 42 4 2 3A INX X-X+I Increments the contents of the mdex ieglster X by 1 EB 2 I INY Y-Y+I Increments the contents of the mdex register Y by 1 C8 2 I JMP ABS Places a new address Into the program counter and Jumps PCl -ADl to that new address PCH -ADH ABL PCl -AD l PCH -ADH PG-AD G (ABsl PC L -(AD H, ADLI PC H -(ADH,ADL+l I LlABSI , PC L -(ADH, ADL) PCH -(ADH,ADL+1I PG -(ADH, ADL +21 (ABS, xl PCL -(ADH, ADL +xl PCH -(ADH, ADL +X +11 JSR ABS Saves the contents of the program counter (also the con- M(sl- PCH tents of the program bank register for ABU Into the stack, S-S-I and Jumps to the new address M(SI- PC L S-S-I PCl -AD l PC H -AD H ABL M(sl- PG S-S-I M(sl- PC H S-S-I M(sl-pc L S-S-I PCl - ADl PCH -- ADH I PG -- ADG I I (ABS, xl I M(S)- PC H S-S-I M(S)-PC L I I S-S-I PC L -(ADH,ADL+xl I I PCH -(AD H, ADL +X ' i +1) J 320 APPENDIX Appendix 11. Machine instructions Addressing mode Processor status register LIDIR) LlOIR),Y ABS ABS,b ABS,X ABS,Y ABL ABL,X lABs) LIABS) (ABS,X) STK REL OIR,b,R ABS,b,R SR ISR),Y BLK 10 9 8 7 6 5 4 3 2 1 0 op n # op n II op n II op n II op n llop n II op n 11 op n li op n li op n # op n 11 op n ;; op n ;I op n li op n II op n li op n 11 op n li IPL N V m x D I Z C EC 4 3 N Z C C4 3 N Z C CE 7 .3 DE 8 3 N Z I N Z N Z 8935 3 89 36 .3 8929 4 8931 4 89 31 4 8931 5 89 32 5 8930 3 89 33 3 N V Z C 27 37 10 30 39 1F 3F 23 33 4710 2 57 11 2 40 4 3 50 6 3 59 6 3 4F 6 4 5F 7 4 43 5 2 53 8 2 N Z 4212 3 42 13 3 42 6 4 42 B 4 42 8 4 42 8 5 42 9 5 42 7 3 42 10 3 47 57 40 50 59 4F 5F 43 53 EE 7 3 FE 8 3 N Z N Z N Z 4C 2 3 5C 4 4 6C 4 3 OC 8 3 7C 6 3 20 6 3 22 8 4 FC 8 3 321 APPENDIX Appendix 11: Machine instructions Addressing mode Symbol Function Details IMP IMM A DIR DIR,b DlR,X DIR,Y (DIR) (OIR,X) (OIR),Y op n lIOP n # op n # op n # op n # op n # opn # op n # op n #: op n # LOA Acc- M Enters the contents 01 the memory into the accumulator A9 2 2 AS 4 2 B5 5 2 B2 6 2 AI 7 2 BI 8 2 (Note 1,2) 42 4 3 42 6 3 42 7 3 42 B 3 42 9 3 42 10 3 A9 A5 B5 B2 AI BI LOM M-IMM Enters the Immediate value Into the memory 64 4 3 74 5 3 (Note 5) LOT OT-IMM Enters the immediate value into the data bank register 89 5 3 I C2 LOX X-M Enters the contents of the memory into index register X Ai. 2 2 A6 4 2 B6 5 2 (Note 2) LOY Y-M Enters the contents of the memory into index register Y AD 2 2 A44 2 B4 5 2 (Note 2) LSR m=O Shifts the contents of the accumulator or the contents of 4A 2 1 46 7 2 56 7 2 (Note 1) O-~C the memory one bit to the right The bit 0 of the accumula- tor or the memory Is entered Into the C flag "0" is entered 42 4 2 m=l Into bit 15 (bit 7 when the m flag Is "1" ) 4A O-~C MPY B,A-A*M Multiplies the contents of accumulator A and the coolents of the mern- 8916 3 8918 3 8919 3 8920 3 89 21 3 8922 3 (Note 2,11) cry The higher order of the result of operatIOn are entered Into accu- 09 05 15 12 01 11 mulator B, and the lower order Into accumulator A MVN Mn+I-Mm+1 Transmits the data block The transmiSSion IS done from (NoteS) the lower order address of the block MVP Mn-I-Mm-I Transmits the data block TransmissIOn IS done form the (Note9) higher order address of the data block NOP PC-PC+I Advances the program counter, but performs nothmg else EA 2 1 ORA Acc-AccVM Logical sum per bit of the contents of the accumulator and 092 2 05 4 2 15 5 2 12 6 2 01 7 2 II 8 2 (Note 1,2) the contents of the memory IS obtained The result IS en- tered mto the accumulator 424 3 42 6 3 42 7 3 42 8 3 42 9 3 42 10 3 09 05 15 12 01 11 PEA M(S)-IMM, The 3rd and the 2nd bytes of the instruction are saved mto , S-S-I the stack, In thiS order M(S)-IMM, S-S-1 PEl M(S)-M((OPR)+IMM Specifies 2 sequential bytes in the direct page 10 the 2nd +11 byte of the rnstructlOn, and saves the contents rnto the S-S-I stack M(S)-M((OPR)+IMM) S-S-1 PER EAR-PC+IMM"IMM, Regards the 2nd and 3rd bytes of the instruction as 16-blt M(S)-EAR H numerals, adds them to the program counter, and saves S-S-I the result Into the stack M(S)-EARL S-S-I PHA m=O Saves the contents of accumulator A mto the stack M(S)-AH S-S-I M(S)-AL S-S-I m=l M(S)-AL S-S-I PHB m=O Saves the contents of accumulator B Into the stack M(S)-B H S-S-I M(S)-BL S-S-1 m=l M(S)-BL S-S-I 322 APPENDIX Appendix 11. Machine instructions Addressing mode Processor status register L(DIR) L(OIR),Y ABS ABS,b ABS,X ABS,Y ABL ABL,X (ABS) L(ABS) (ABS,X) STK REL OIR,b,R ABS,b,R SR (SR)'Y BLK 10 9 8 7 6 5 4 3 2 1 0 op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n # op n #op n # IPL N V m x D I Z C A710 2 87 11 2 AD 4 3 806 3 89 6 3 AF 6 4 8F 7 4 A3 5 2 B3 8 2 N Z 4212 3 42 13 3 42 6 4 42 8 4 42 8 4 42 8 5 42 9 5 42 7 3 42 10 3 A7 87 AD 80 89 AF 8F A3 83 9C 5 4 9E 6 4 AE 4 3 8E 6 3 N Z AC 4 3 Be 6 3 N Z 4E 7 3 5E 8 3 0 Z C 8924 3 89 25 3 8918 4 8920 4 89 20 4 8920 5 89 21 5 8919 3 89 22 3 N Z 0 07 17 00 10 19 OF 1F 03 13 54 7 3 + "i- X7 441+13 +X7 0710 2 17 11 2 00 4 3 10 6 3 19 6 3 OF 6 4 IF 7 4 03 5 2 13 8 2 N Z 4212 3 42 13 3 42 6 4 42 8 4 42 8 4 42 8 5 42 9 5 42 7 3 42 10 3 07 17 00 10 19 OF 1F 03 13 F4 5 3 04 5 2 62 5 3 48 4 1 42 6 2 48 323 APPENDIX Appendix 11. Machine instructions Addressing mode Symbol Function Details IMP IMM A DIA DIA,b DIA,X DIA,Y (DIA) (DIR, X) (DIR),Y op n # op n #cp n # cpn # op n # op n #cp n # cp n # op n # op n # PHD M(S)-DPRH Saves the contents of the direct page register mto the S-S-1 stack M(S)-DPAL S-S-1 PHG M(S)-PG Saves the contents of the program bank register Into the S-S-1 stack PHP M(S)-PSH Saves the contents of the program status register mto the S-S-1 stack M(S)-PS L S-S-1 PHT M(S)-DT Saves the contents of the data bank register IOta the S-S-1 stack PHX x=O Saves the contents of the Index register X Into the stack M(S)-XH S-S-1 M(S)-XL S-S-1 x=l M(S)-XL S-S-1 - PHY x=O Saves the contents of the Index register Y rnto the stack M(S)-YH S-S-1 M(S)-YL S-S-1 x=1 , M(S)-YL S-S-1 PLA m=O Restores the contents of the stack on the accumulator A S-S+1 AL-M(S) S-S+1 AH-M(S) m=l S-S+1 AL-M(S) PLB m=O Restores the contents of the stack on the accumulator B S-S+1 BL-M(S) S-S+1 BH-M(S) m=1 S-S+1 BL-M(S) PLD S-S+1 Restores the contents of the stack on the direct page re9- DPAL-M(S) Isler S-S+1 DPAH-M(S) PLP S-S+1 Restores the contents of the stack on the processor status PSL-M(S) register S-S+1 PSH-M(S) PLT S-S+1 I Restores the contents of the stack on the data bank reg- DT-M(S) Ister PLX x=O Restores the contents of the stack on the Index register X S-S+1 XL-M(S) S-S+1 XH-M(S) ! x=l I S-S+1 , ! I XL-MrS) I I 324 APPENDIX Appendix 11. Machine instructions Addressmg mode Processor status regIster L(DIR) LlOIR),Y ABS ABS,b ABS,X ABS,Y ABL ABL,X (ABS) L(ABS) (ABS,X) STK REL OIR,b,R A8S,b,R SR (SRl.Y BLK 10 9 8 7 6 5 4 3 2 I 0 OIl n jlop n jl OIl n jlop n jl OIl n II op n jl op n jlop n jl op n II op n jl OIl n jlop n jl op n II op n II op n lIop n II op n II op n II IPL N V m x D I Z C 08 4 1 48 3 1 08 4 1 88 3 1 OA 4 I 5A 4 I 68 5 1 N Z 42 7 2 N Z 68 28 5 1 28 6 1 Value saved In stack A8 6 1 N Z FA 5 1 N Z 325 APPENDIX Appendix 11. Machine instructions Addressing mode Symbol Function Detarls IMP IMM A DIA DIR,b DIR,X DIR,Y (DIA) (OIR, X) (OIR),Y cpn# op n # op n # op n # cp n #cp n # cpn #cpn #cpn # op n # PLY x=O Restores the contents of the stack on the Index register Y S-S+I YL-M(S) S-S+1 YH-M(S) x=1 S-S+1 YL-M(S) PSH M(S)-A, B, X'" Saves the registers among accumulator, Index register, (Note6) direct page regrster, data bank register, program bank register, or processor status register, speCified by the bit pattern of the second byte of the instruction into the stack PUL A, B, X"'-M(S) Restores the contents of the stack to the registers among (Nole7) accumulator, Index register, direct page register, data bank register, or processor status register, specified by the bit pattern of the second byte of the Instruction RLA m=O Rotates the contents of the accumulator A, n bits to the 89 6 3 (Note 13) n bit rotate left left 49+ I ~J m=1 n bit rotate left y b,l Ibol] RDL m=O Links the accumulator or the memory to C flag, and rotates 2A 2 1267 2 36 7 2 (Note 1) result to the left by 1 bit ~_lQJJ 42 4 2 2A m=1 Y b,l . lbe l-lQJ] ROR m=O Links the accumulator or the memory to C flag, and rotates 6A 2 1 66 7 2 767 2 (Note 1) result to the right by 1 bit LlQJ-lliiiNJ 424 2 6A m=1 [lQJ-1 b,l· Ibo~ RTI S-S+1 Returns from the interruption routine 4011 1 PSL-M(S) S-S+1 PSH-M(S) S-S+1 PCL-M(S) S-S+1 PCH-M(S) S-S+1 PG-M(S) RTL S-S+1 Returns from the subroutine The contents of the program 68 8 1 PCL-M(S) bank register are also restored. S-S+1 PCH-M(S) S-S+1 PG-M(S) RTS S-S+1 Returns from the subroutine The contents of the program 60 5 1 PCL-M(S) bank register are not restored S-S+1 PCH-M(S) SBC Ace, C-Acc-M-C Subtracts the contents of the memory and the borrow from E92 2 E54 2 F5 5 2 F26 2 EI 7 2 Fl 8 2 (Note 1,2) the contents of the accumulator 42 4 3 426 3 42 7 3 42 8 3 42 9 342103 E9 E5 F5 F2 EI FI 326 APPENDIX Appendix 11. Machine instructions Addressing mode Processor status register L(DIR) l(DIRI.V ABS ABS,b ABS,X ABS,Y ABL ABL,X (ABS) LiABS) (ABS,X) STK REL DIR,b,R ABS,b,R SR (SR),Y BLK 10 9 8 7 6 5 4 3 2 1 0 op n # op n llop n II op n II op n II op n II op n :;;: op n II op n II op n #: op n II op n # op n :it: op n :1* op n #op n # opnll op n #: IPL N V m x D I Z C 7A 5 1 N Z EB 12 2 + 211+12 FB 14 2 If restored the contents of PS, + 311+412 It becomes Its value And the other case IS no change 2E 7 3 3E 8 3 N Z C 6E 7 3 7E 8 3 N Z C Value saved In stack E7 10 2 F7 11 2 ED 4 3 FO 6 3 F9 6 3 EF 6 4 FF 7 4 E3 5 2 F3 8 2 N V Z C 4212 3 4213 3 42 6 4 42 8 4 42 8 4 42 8 5 42 9 5 42 7 3 4210 3 E7 F7 ED FO F9 EF ff E3 F3 327 APPENDIX Appendix 11. Machine instructions Addressing mode Symbol Function Details IMP IMM A DIR DIR,b DIR,X DIR,Y (DIR) (DIR,X) (DlR),Y IJIl n #: op n II op n II op n II op n II op n II op n II op n II op n II op n II SEB Mb~1 Makes the contents of the specified bit In the memory "1" 04 8 3 (NoteS) SEC C~1 Makes the contents of the C flag "1" 38 2 I SEI 1~1 Makes the contents of the I flag "1" 78 2 1 SEM m~1 Makes the contents of the m flag "1" F8 2 1 SEP PSb~1 Set the specified bit of the processor status register's low- E2 3 2 er byte (PSL) to "t" STA M-A cc Stores the contents of the accumulator Into the memory 85 4 2 95 S 2 92 7 2 81 7 2 91 7 2 (Note t) 42 6 3 42 7 3 42 9 3 42 9 3 42 9 3 85 95 92 81 91 STP Stops the oscillation of the oscillator DB 3 1 STX M~X Stores the contents of the mdex register X mto the memory 86 4 2 96 5 2 STY M~Y Stores the contents of the index register Y into the memory 84 4 2 94 5 2 TAD DPR~A Transmits the contents of the accumulator A to the direct 56 2 1 page register. TAS S~A Transmits the contents of the accumulator A to the stack pointer. 16 2 1 TAX X~A Transmits the contents of the accumulator A to the Index AA2 1 register X. TAY Y~A Transmits the contents of the accumulator A to the Index 1£ 2 1 register Y TBD DPR~B Transmits the contents of the accumulator B to the direct 42 4 2 page register 56 TBS S~B Transmits the contents of the accumulator B to the stack 42 4 2 pOinter 16 TBX X~B Transmits the contents of the accumulator B to the index 42 4 2 register X AA TBY Y~B Transmits the contents of the accumulator B to the index 42 4 2 register Y A8 TDA A~DPR Transmits the contents 01 the direct page register to the 76 2 1 accumulator A TDB B~DPR Transmits the contents of the direct page register to the 42 4 2 accumulator B 76 TSA A~S Transmits the contents of the stack pomter to the accumulator A 36 2 1 TSB B~S Transmits the contents of the stack pointer to the accumu- 42 4 2 lator B 36 TSX X~S Transmits the contents of the stack pointer to the mdex 6A 2 1 register X TXA A~X Transmits the contents of the index register X to the accu- 8A 2 1 mulator A TXB B~X Transmits the contents of the Index register X to the accu- 42 4 2 mulator B 8A TXS S~X Transmits the contents of the Index register X to the stack 9A 2 1 pointer. TXY Y~X Transmits the contents of the index register X to the mdex 96 2 1 register Y TYA A~Y Transmits the contents of the Index register Y to the accu- 98 2 1 mutator A TYB B~Y Transmits the contents of the index register Y to the accu- 42 4 2 mulator B 98 TYX X~Y Transmits the contents of the Index register 'V to the Index 86 2 1 register X WIT Stops the internal clock C63 1 XAB A:;B Exchanges the contents of the accumulator A and the con- 89 6 2 tents of the accumulator B 28 328 APPENDIX Appendix 11. Machine instructions Addressing mode Processor status register L(DIR) L(DIR),Y ABS ABS,b ABS,X ABS,Y ABL ABL,X (ABS) L(ABS) (ABS,X) STK REL DIR,b,R ABS,b,R SR (SR),Y BLK 10 9 8 6 5 op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n :II op n:ll IPL N V m x D I Z C OC 9 4 SpeCified ftag be- comes "1" 8710297112805 9053995 38F6 49F7 835293B2 4212342133427 427442744285429 427342103 87 97 80 90 99 8F 9F 83 93 8E 5 8C 5 N • Z • N Z • N Z N Z N Z N Z N Z N Z N Z N Z N Z N Z N Z N Z N Z N Z 329 APPENDIX Appendix 11. Machine instructions Symbols in machine instructions table Symbol Description Symbol Description IMP Implied addressing mode Exclusive OR IMM Immediate addressing mode Negation A Accumulator addressIng mode Movement to the arrow direction DIR Direct addressing mode Acc Accumulator DIR, b Direct bit addressing mode AccH Accumulator's upper a bits DIR,X Direct indexed X addressing mode Acce Accumulator's lower a bits DIR, Y Direct Indexed Y addressing mode A Accumulator A (DIR) Direct Indirect addressing mode AH Accumulator Ns upper a bits (DIR, X) Direct Indexed X Indirect addressing mode Ae Accumulator A's lower a bIts (DIRl. Y Direct Indirect Indexed Y addressing mode B Accumulator B L(DIR) Direct indirect long addressing mode BH Accumulator B's upper a bits L(DIR), Y Direct indirect long' indexed Y addressing mode Be Accumulator B's lower a bits ABS Absolute addressing mode X Index register X ABS, b Absolute bit addressing mode XH Index register X's upper a bits ABS, X Absolute Indexed X addressing mode Xc Index register X's lower a bits ABS, Y Absolute Indexed Y addressing mode Y Index register Y ABL Absolute long addressing mode YH Index register Y's upper a bits ABL, X Absolute long indexed X addressing mode Ye Index register Y's lower a bits (ABS) Absolute Indirect addressing mode S Stack pOinter L(ABS) Absolute Indirect long addressing mode PC Program counter (ABS,X) Absolute Indexed X Indirect addressing mode PC H Program counter's upper a bits STK Stack addressing mode PC e Program counter's lower a bits REL Relative addressing mode PG Program bank register DIR, b, REL Direct bit relative addressing mode DT Data bank register ABS,b,REL Absolute bit relative addressing mode DPR Direct page register SR Stack pointer relative addressing mode DPR H Direct page registe~s upp~r a bits (SR), Y Stack pointer relatIve indirect Indexed Y addressing DPR e Direct page registe~s lower a bits mode PS Processor status register BLK Block transler addressing mode PS H Processor status reglste~s upper a bits C Carry Ilag Processor status reglste(s lower a bits PS e Z Zero flag Processor status reglste(s both bit PSb I Interrupt disable flag M(S) Contents 01 memory at address Indicated by stack D Decimal operation mode Ilag pointer x Index register length selection Ilag both memory location m Data length selection Ilag Value 01 24-blt address's upp~r a-bit (A23-A,.) V Overflow Ilag Value 01 24-bot address's mIddle a-bot (A15-A.) N Negative Ilag Value 01 24-bit address's lower a-bit (A,-AD) IPL Processor Interrupt priority level Operation code + Addition Number 01 cycle - Subtraction Number 01 byte Multiplication Number 01 transler byte or rotation * / Division ( Number 01 registers pushed or pulled /\ Logical AND V Logical OR 330 APPENDIX Appendix 11. Machine instructions The number 01 cycles shown in the table is descnbed In case 01 the lastest mode lor each Instruction. The number 01 cycles shown in the table Is calculated lor OPRL =0. The number 01 cycles in the addressing mode concerning the OPR when OPRL *0 must be incremented by 1. The number 01 cycles shown in the table dillers according to the bytes letched into the instruction queue buller, or according to whether the memory read/write address is odd or even It also dillers when the external region memory is accessed by SYTE="H". Note 1. The operation code at the upper row is used lor accumulator A, and the operation at the lower row is used lor accumulator S. Note 2. When setting flag m=O to handle the data as 16-blt data In the Immediate addressing mode, the number 01 bytes increments by 1. Note 3. The number of cycles Increments by 2 when branching. Note 4. The operallon code on the upper row is used lor branching in the range 01 -128-+127, and the operation code on the lower row is used lor branching in the range 01 -32768-+32767. Note 5. When handling 16-bit data With flag m=O, the byte In the table IS Incremented by 1. Note 6. The number of cycles corresponding to the register to be pushed are ·added. The number 01 cycles when no pushing is done is 12. I, indicates the number 01 registers among A, S, X, Y, OPR, and PS to be saved, while i2 Indicates the number 01 registers among OT and PG to be saved Note 7. The number of cycles corresponding to the register to be pulled are added. The number 01 cycles when no pulling is done is 14. i, indicates the number of registers among A, S, X, Y, OT, and PS to be restored, while 12= 1 when OPR is to be restored Note 8. The number 01 cycles is the case when the number 01 bytes to be translered is even. When the number 01 bytes to be transfered is odd, the number IS calculated as; Note that, (i/2) shows the Integer part when i is diVided by 2 Note 9. The number 01 cycles IS the case when the number 01 bytes to be translered IS even When the number 01 bytes to be transfered IS odd, the number is calculated as; Note that, (,/2) shows the Integer part when i is diVided by 2 Note 10. The number 01 cycles IS the case in the 16-biH-8-blt operation The number 01 cycles IS incremented by 1610r-32-bit+16-blt operation Note 11. The number 01 cycles is the case In the 8-bltX8-blt operation The number 01 cycles IS incremented by B lor 16-bIt X16-bit operation. Note 12. When setting Ilag x=O to handle the data as 16-bIt data in the Immediate addreSSing mode, the number 01 bytes Increments by 1 Note 13. When flag m IS 0, the byte In the table IS Incremented by 1 331 CONTACT ADDRESSES FOR FURTHER INFORMATION JAPAN================== SOUTHWEST WEST GERMANY = = = = = = = Semiconductor Marketing Division Mitsublshi Electronics America, Inc. Mltsublshl Electric Europe GmbH Mltsublshl Electric Corporation 991 Knox Street Headquarters: 2-3, Marunouchl 2-chome Torrance, CA 90502 Gothear Str 8 Chlyoda-ku, Tokyo 100, Japan Telephone' (213) 515-3993 4030 Ratingen 1, West Germany Telex: 24532 MELCO J Facsimile: (213) 217-5781 Telex 8585070 M ED D Telephone' (03) 3218-3473 Telephone: (02102) 4860 (03) 3218-3499 SOUTH CENTRAL Facsimile (02102) 486-115 Facsimile' (03) 3214-5570 Mltsublshi Electronics America, Inc. 1501 Luna Road, SUite 124 Munich Office' Overseas Marketing Manager Carrollton, TX 75006 ArabellastraP.,e 31 Klta-Itaml Works Telephone' (214) 484-1919 8000 Munchen 81, West Germany 4-1, Mizuhara, Itami-shi, Facsimile: (214) 243-0207 Telex 5214820 Hyogo-ken 664, Japan Telephone. (089) 919006-09 Telex' 526408 KMELCO J NORTHERN Facsimile (089) 9101399 Telephone (0727) 82-5131 MltsublShl ElectroniCs America, Inc Facsimile: (0727) 72-2329 15612 Highway 7 #243 FRANCE========== Mmnetonka, M N 55345 Mltsubishi Electric Europe GmbH HONG KONG =============== Telephone' (612) 938-7779 55, Avenue de Colmar Mltsublshi Electric (H K ) Ltd. Facsimile (612) 938-5125 92563 Ruell Malmalson Cedex 41st II, Manuille Tower, 169, Telex 632326 Electric Road, North Pomt~ Hong Kong NORTH CENTRAL Telephone 47087871 Telex 60800 MELCO HX Mltsubishl Electronics America, Inc Facsimile. 47513622 Telephone 510-0555 800 N Bierman Circle Facsimile' 510-9830,510-9822, Mt Prospect, IL 60056 ITALY ================== 510-9803 Telephone (312) 298-9223 Mltsubishi ElectriC Europe GmbH Facsimile' (312) 298-0567 Centro Direzlonale Colleoni SINGAPORE =============== Palazzo Cassiopea 1 MELCO SALES SINGAPORE PTE NORTHEAST 20041 Agrate Brlanza I-Milano LTD Mltsubishi Electronics Amenca, Inc Telephone' (039) 636011 230 Upper Buklt Tlmah Road # 03- 200 Unicorn Park Drive Facsimile: (039) 6360120 01/15 Woburn, MA 01801 Hock Soon Industrial Complex Telephone (617) 932-5700 SWEDEN================ Smgapore 2158 Facsimile. (617) 938-1075 MltsublShl ElectriC Europe GmbH Telex RS 20845 MELCO Lastbllsvagen 6B Telephone 4695255 MID-ATLANTIC 5-19149 Sollentuna, Sweden Facsimile: 4695347 MltsublShl ElectroniCs America, Inc Telex 10877 (meab S) 800 Cottontail Lane Telephone: (08) 960468 TAIWAN ================== Somerset, NJ 08873 Facsimile (08) 966877 MELCO-TAIWAN CO., Ltd. Telephone (201) 469-8833 1st II , Chung-Lmg Bldg., Facsimile. (201) 469-1909 U.K. = = = = = = = = = = = 363, Sec. 2, Fu-Hsmg S Road, Mltsublshi ElectriC (U.K.) Ltd. Taipei R O.C SOUTH ATLANTIC Travellers Lane Telephone. (02) 735-3030 Mltsubishl ElectroniCs America, Inc Hatfield Facsimile (02) 735-6771 2500 Gateway Center Blvd., SUite 300 Herts AL10 8XB, England, UK. Telex. 25433 CHURYO "MELCO- MOrriSVille NC 27560 Telephone: (0044) 7072 76100 TAIWAN" Telephone (404) 368-4850 Facsimile (0044) 7072 78692 Facsimile: (404) 662-5208 U.S.A. =============== AUSTRALIA = = = = = = = = = NORTHWEST SOUTHEAST Mitsublshi Electric Australia Pty Ltd. Mltsubishl Electronics America, Inc Mltsubishl ElectrOniCS America, Inc. 348 VictOria Road 1050 East Arques Avenue Town Executive Center Rydalmere Nsw 2116, Australia Sunnyvale, CA 94086 6100 Glades Road #210 Private Bag No 2 Rydalmere Nsw 2116 Telephone (408) 730-5900 Boca Raton, FL 33433 Telex: MESYDAA 126614 Facsimile (408) 730-4972 Telephone: (407) 487-7747 Telephone' (02) 684-7200 Facsimile' (407) 487-2046 Facsimile (02) 638-7072 SAN DIEGO MitsublShl Electronics America, Inc CANADA 16980 Via Tazon, SUite 220 Mltsubishl ElectrOnics America, Inc San Diego, CA 92128 6185 Ordan Drive, Unit #110 Telephone (619) 451-9618 Mlsslssauga, OntariO, Canada L5T 2El Facsimile (619) 592-0242 Telephone: (416) 670-8711 Facsimile (416) 670-8715 DENVER MitsublShl Electronics America, Inc Mltsublshl ElectroniCs America, Inc 4600 South Ulster Street 300 March Road, SUite 302 Metropoint Buildmg, 7th Floor Kanata, Ontario, Canada K2K 2E2 Denver, CO 80237 Telephone (416) 670-8711 Telephone (303) 740-6775 FacSimile: (416) 670-8715 Facsimile: (303) 694-0613 MITSUBISHI SEMICONDUCTORS USER'S MANUAL M37702/M37703 Group Dec. First Edition 1991 Editloned 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. ©1991 MITSUBISHI ELECTRIC CORPORATION MITSUBISHI SEMICONDUCTORS M37702 Group M37703 Group J... MITSUBISHI ELECTRIC CORPORATION HEAD OFFICE MITSUBISHI DENKI BLDG MAAUNDUCHI . TOKYO 100 TELEX J24532 CABLE MELCO TOKYO If these products Of technologIes fall under Japanese and/Of COCOM strategIc restrIctIons, d,vers,on contrary thereto IS prohIbIted. H- EAOO4-A Printed in Japan ( ROD ) New publication, effective Dec . 1991 . c , 1991 MITSUBISHI ELECTRIC CORPORATION Specifications subject to change without notice.