MITSUBISHI SEMICONDUCTORS c en rn ::0 en $'. )> z c )> r M37450M2-XXXSP/FP ~ ~ • MITSUBISHI ~ELECTRIC INTRODUCTION We hereby introduce the manual for CMOS 8-bit microcomputer M37450M2-XXXSP/FP hardware. This manual is prepared for the users who should understand fully the functions and features of M37450M2-XXXSP/FP so that they can utilze this product to its fullest capacity. A detailed explana- tions of the specifications and applications regard- ing the hardware is hereby provided; for the soft- ware, consult MELPS 740 programming manual. The contents of this user's manual are subject to change for the reasons of later improvement of the features. The information, charts, and other data in this us- er's manual are correct and reliable; however, Mit- subishi Electric Corporation is in no way responsi- ble for any violations of patents or other rights of the third party generated by the use of this manual. MELPS and MELCS are the trademarks of Mit- subishi Electric Corporation. CONTENTS CONTENTS 1. DESCRIPTION ·············· ······· ············· ·························· ······························· ···· ···· ········ ··········· 1 1. 1 Summary········· .... · .... · .... ····· .. ···· .... ······ ........ · ...... · .......... ···· .... ·· ........ · ................ ·· .... ·· .... · 1 1. 2 M37450 family .............................................................................................................. 2 1. 3 Pin configuration ........................................................................................................... 3 1. 4 Pin description···· ...... · ........... · ........ · ...... · .. ·· .. ·· .... ····· ..... ·· ....... · ..... ·· .................... · ..... · ..... 5 1. 5 Block diagram .. · · · · .. · .... · .. · .. · · · .... · · · .. · · .. · · ............ · · .. · · · · .. · · · · .... · · · ...... · · .. · ................ · · .. · .... · .. · 6 2. FUNCTIONS·························································································································· 8 2. 1 Central processing unit ........................ · .................... · .................. · ................................ · 8 2. 2 Access area ................................................................................................................ 12 2. 3 Memory map ............................................................................................................... 14 2 . 4 Input/Output pin .. ·· .. ·.... · .. · .. · .. ·· ...... · .. · .. · .. ·· .... ·· .. ··· .... ·.. · .... · .... ··· .... · .. · .. ·············· .. ···· .. · .... Jg 2 5 Interrupt'''"''""'"'"'""'"''""''""''''''""'''''"''""'"'"'''"'"'""''"""""''''""''''"'"'"'"'"' 26 0 2 . 6 Timer .. · · · · · · · ........ · .. · .. · .... · · .... · · ...... · · .. · .. · · · · · · .. · · .... · .... · · · · .. · ...... · · ...... · .... · .. · · .. · · · ............ · · · · · 33 2. 7 Serial 1/0 ...... · .... · · .. · .. · .... · · .... · · · .... · · · · · · .. · · · · · · · · .. · ........ · · · · .. · .... · .. · .... · · · · ........ · .... · .......... · · · · · · 43 2. 8 Bus interface ...... ·· .. ··· .... ·· .. · .. · .. · .... ··· .. ·.. ····· ........ · .... ·· .... · .... ···· .. · .. ··· .... · .. · ........ · .. · .... ·· .. ·· 58 2 . 9 A-D converter· .... ·· .. ··· .. · .. · .. · .. · .. · .... · .... · .. ······· ...... · .... ··· .. ·· ...... ·· .... ···· .... · .............. · .... ······ 65 2 . 10 D-A converter· ........ · .... · .. · .. · ...... ··· .... ···· ........................ ·· .... · .. ·· .... ···· ...................... · .. ···· 72 2. 11 PWM .......................................................................................................................... 73 2. 12 Multiplier/Divider unit .... · ............ ·· ...... ·· ........... ·· .. ·· ...... · ............ ···· .. · ....... ··· ...... · ... ··· .... ·· 77 3. RESET CIRCUIT ··.. ·...... · .. ·.... ·.... ··.... ·...... ·.. ·.......... ·.. ·.. ··...... ·...... ·.. ·.. ·.... · ·.. ·.. ·.. ·.. ·.. ···.. · ···.. · ··· 80 3. 1 Reset operation ...... · .. · .. · .... · .. · .. · .... · .............. · · · .... · · ........ · .... · .. · .. · .... · · .. · · · · · · · · · · .. · .... · · .... · · .. 80 3. 2 Internal condition of microcomputer after reset ................................................................. 81 3. 3 Reset circuit ................................................................................................................ 82 4. OSCILLATION CIRCUIT .................................................................................................... ··· 83 4. 1 Oscillation circuit .. · ...... · · .... · · .. · .. · ...... · .. · ...... · ...... · · · · · .. · .. · .... · .. · .. · .. · .... · ................ · · · · · .... · .. · 83 4. 2 Clock generating circuit .............. · .. · .. · ................................ · .... · .................... · .. · ............ · 84 5. ELECTRICAL CHARACTERISTICS ···· ······ ·· ·················· ·········· ····································· ······ ··· 85 6. TYPICAL CHARACTERISTICS ················· ······· ········ ·················· ·················· ··· ···· ···· ··········· ··· 94 6. 1 Port typical characteristics .................................................... · .... · .. · .... · .. · .. · .......... · .. · ...... · 94 6. 2 A-D conversion typical characteristics .................... · .. · ................................................ · ... · 95 6. 3 D-A conversion typical characteristics ............................................................................. 96 7. APPLICATION· ..................................................................................................................... 97 7. 1 Memory expansion ..... ·· ..... ·· ........... ·· .. · .......... ····· .. ··· ..... · .................. · ................ · ... · ....... 97 7. 2 Application circuit .. · · · .... · · · · .... · ........ · · .. · .... · · · · .... · .... · .... · · .... · · · .... · · · .......... · .... · · ........ · · .... · · 102 7. 3 Application software · · · · · .... · · · .... · .. · .... · · · · .... · · .... · · · · · .. · · · .. · · · .... · · .. · .. · .. · ......... · · .. · · · · · ...... · · .... · 106 APPENDIX 1 . Programming notes .......................................................................................... 142 APPENDIX 2. Handling of unused pins ................................................................................... 144 APPENDIX 3. Package outlines ............................................................................................. 145 APPENDIX 4. SFR memory map ............................................................................................ 146 APPENDIX 5. Control registers ...... , ....................................................................................... 149 APPENDIX 6. Instruction cycles in each addressing mode ........................................................ 154 APPENDIX 7. Machine instructions ........................................................................................ : 214 APPENDIX 8. List of instruction codes .................................................................................... 224 APPENDIX 9. Mask ROM ordering method ............................................................................. 225 APPENDIX 10. M60014-0120FP· ...... · ................ · · ......................................... · ........................... 231 DESCRIPTION 1. DESCRIPTION 1.1 Summary M37450M2-XXXSP/FP is a single-chip microcomputer designed with CMOS silicon gate technology. M37450M2-XXXSP is housed in a 64-pin shrink plastic molded DIP and M37450M2-XXXFP is housed in an 80-pin plastic molded QFP. In this single-chip microcomputer, ROM, RAM and 1/0 are placed on the same memory map in addition to simple instruction set. It is applicable to the office equipment and indus- trial controller. The use of CMOS process enables extremely low power consumption and is most suitable for battery drive. M37450M2-XXXSP/FP is equipped with 4K bytes of ROM and 128 bytes of RAM. In addition, the following are the built-in functions: • Master CPU bus interface function • 16-bit multi-functional timer • Serial 1/0 (Clock synchronous/UART is selectable by program) • A-D converter (Successive approximation) • D-A converter ( R-2R type) • PWM output • High-speed multiplier/divider In accordance with the built-in multiplier/divider, M37450M2-XXXSP/FP has multiply and divide instruc- tions in addition to MELPS 740 basic instruction sets. port 3 DAC (2-ch) "'t 0 Q. UART (+BRG) ADC ~"' .0 timer (16-bit, 3-ch) "'t0 "' ~ Q. .0 ,,1ti"' ~ 0 RAM ( 128-byte) t 0 a. ::;;; :;;: "- ROM (4K-byte) 1--- 1---1 "' t ~ ~ 0 Q. 0 150 t a." 0. 0 a. 2 6 ~ processor " clock port 2 Fig. 1.1.1 M37450M2-XXXSP/FP chip floor plan DESCRIPTION The difference between M37450M2-XXXSP and M37450M2-XXXFP lies only in the package (pin numbers) and port 4 (common with analog input port); and in whether RD, WR, RESETouT. AVcc. ADVREF• DAVREF· and VREF pins exist or not. Therefore, in this user's manual, explanation applies only to M37450M2-XXXSP (abbreviated as M37450), unless noted otherwise. Also, when referring to the differ- ence between M37450M2-XXXSP and M37450M2-XXXFP, 64-pin model (SP) and 80-pin model (FP) will be used to distinguish them. Table 1.1.1 Functions of M37450M2-XXXSP/FP Parameter Functions Number of basic instructions 71 (69 MELPS 740 basic instructions+2) Instruction execution time 0.8µs (minimum instructions, at 10MHz of frequency) Clock frequency 10MHz (max.) ROM 4096 bytes Memory size RAM 128 bytes -- l PO-P3, P5, P6 1/0 8-bitX6 Input/Output port [P4 Input 3-bitX 1 ( 8-bitX 1 for 80-pin model) l D-A Output 2-bitX1 Serial 1/0 UART or clock synchronous 16-bit timerX3, Timers 8-bit timer (serial 1/0 baud rate generator) X 1 A-D converter 8-bitX3 channels (8 channels for 80-pin model) D-A converter 8-bitX 2 channels Pulse width modulator 8-bit or 16-bitX 1 Data bus buffer 1-byte input and output each 64-levels (max. for M37450M2) Subroutine nesting 96-levels (max. for M37450M4, M37450M8) 6 external interrupts, 8 interna! interrupts Interrupts 1 software interrupt Clock generating circuit Built-in (ceramic or quarts crystal oscillator) Supply voltage 5V±10% Power dissipation 30mW (at 10MHz frequency) -- Input/Output characteristics 1J lnput!Output voltage 5V Output current ±5mA (max.) Memory expansion Possible Operating temperature range -10-7o·c Device structure CMOS silicon gate -~ M37450M2-XXXSP 64-pin shrink plastic molded DIP Package M37 450M2-XXXFP 80-pin plastic molded QFP 1.2 M37450 family M37450M2-XXXSP/FP as the base chip, the M37450 family will be developed as follows: Table 1.2.1 M37450 family Type ROM RAM Additional M37450M2-XXXSP/FP 4K bytes 128 bytes .__M~3_74_5_0_M_4_-_x_x_x_s_P_l_F_P~~~~~~1--~8_K~b~yt__e_s~--1-----2__ 56~b~y_te_s~__,__M_3_74_5_0_M_2_R_O_M_e_x~p_an_s_io_n~~~~--~~~~~----1 M37450MB-XXXSP/FP 16K bytes 3B4 bytes M37450M2 ROM expansion M37450S1SP/FP - ~~~~~-~~--j~~~~~~--+-~~~~~~+-~~~~~~~~~~~~~~~~~~~--1 12B bytes M37450M2 external ROM M37450S2SP/FP 1--~~~~~~~~~~~~~~t-~~--~~--+~~~--~~1--~~--~~~~~~~~~~~~~~~----~ - 256 bytes M37450M4 external ROM M37450S4SP/FP - 44B bytes M37450M8 external ROM BK bytes 256 bytes 16K bytes 384 bytes M37450E4SS/FS BK bytes 256 bytes M37450M4 EPROM version M37450E8SS/FS** 16K bytes 3B4 bytes M37450M8 EPROM version - 44B bytes **Under development These are all pin compatible and developed in terms of memory size and characteristics so that the user can select the most suitable device according to the system. This manual expains M37450M2-XXXSP/FP, but it is applicable to other microcomputers in the M37450 family as long as the user remembers the difference in memory. 2 DESCRIPTION 1.3 Pin configuration P37/SRDY ....... Vee P3e/ScLK ++ AVss P3 5 /TxD ++ - VREF Reference voltage input 1/0 port P3 P34 /RxD ++ P33/PWMour ++ f D-A output P3 2 /EV3 ++ P3 1 /EV 2 ++ 7 Input port P4 P30/EV1 ++ P57/087 ++ P5e/DBe ++ P5 5 /DBs ++ 1/0 port PS P5 4/084 ++ 1/0 port PO P5 3/083 ++ P5 2/DB2 ++ P51/DB1 ++ P5 0 /DBo ++ P6 7 /W++ P6 6 /R ++ P6 5 /CS ++ 1/0 port P6 P64/AO ++ 1/0 port P1 P63/PRDY ++ P6 2 /INT 3 ++ 22 P6 1 /INT 2 ++ 23 P6 0/INT 1 ++ 24 Read/Write status output Synchronous signal output CNV 55 -+ Reset input RESET-+ 28 1/0 port P2 Clock input Clock output Timing output Vss Outline 64P4B Fig 1.3.1 M37450M2-XXXSP, M37450M4-XXXSP, M37450M8-XXXSP pin configuration 3 DESCRIPTION tttttt i i t t i NC 64 +-P4 1 /AN 1 P3 1 /EV 2 ++ 2 63 +-P4 2 /AN 2 P3 0 /EV 1 ++ 3 62 +- P4 3 / AN 3 P5 7 /DB 7 ++ 4 61 +-· P4 4 / AN 4 60 +- P4 5 / AN 5 59 +- P4 6 / AN 6 58 +- P4 7 / AN 7 :s:: :s:: :s:: 57 ++ P0 0 /A 0 c.v VJ VJ 56 ++ P0 1 /A 1 -...J -...J -...J .i::. .i::. .i::. C.11 C.11 (11 55 ++ P0 2 /A 2 0 0 0 54 ++ P0 3 /A 3 :s:: 0 :s:: 0 :s:: 00 ..., .i::. ..., I\:> 53 ++ P04/A4 I I I 52 ++ P0 5 /A 5 x x x x x x 51 ++ P0 6 /A 6 .,,x .,,x .,,x 50 ++ P0 7 /A 7 49 ++ P1 0 /A 8 ""CJ ""CJ ""CJ 48 ++ P1 1 /A 9 47 ++ P12/A10 46 ++ P1 3 /A 11 45 ++ P14/A12 RD+- 21 44 ++ P1s/A13 R/W +- 22 43 ++ P15/A14 SYNC+- 23 42 ++ P11/A1s RESET OUT+- 24 NC '\-c--rr-'."rro,-,-,-,,..,.,-,-,-.,,r'.Tl-:-:TT-crr--,,--,.,--,r.,..,.,-,"'."Tr~ Outline 80P6 NC : No connection Fig 1.3.2 M37450M2-XXXFP, M37450M4-XXXFP, M37450M8-XXXFP pin configuration 4 DESCRIPTION 1.4 Pin description Table 1.4.1 Pin description Input/ Pin Name Functions Output t - - - - - - + - - - - - - - - - l - · - - - - - 1 - - - - - - - -. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - j Vee. Vss Supply voltage Power supply inputs 5V±10% to Vee. and OV to V 58 . 1------+---------t----+--------~-----------------·--------------·-·- -- ------ ------- ---------- CNVss CNVss Controls the processor mode of the chip. Normally connected to Vss or Vee. 1-------+---------t-----+---------------------------------------------------~ To enter the reset state, the reset input pin must be kept at a "L" for more than 2tis (under normal Vee --- RESET Reset input Input conditions). If more time is needed for the crystal oscillator to stabilize, this "L" condition should be main- tained for the required time. r---- - - - - - - j - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - ________________________ _____, X1N Clock input Input This chip has an internal clock generating circuit. To control generating frequency, an external ceramic or a 1 - - - - - - - + - - - - - - - - - - - - l - - - - - - l quartz crystal oscillator is connected between the X1N and Xour pins. If an external clock is used, the clock XouT Clock output Output source should be connected to the X1N pin and the Xour pin should be left open. t-------+---------·1----+-------·---··-·---·----------------------·---·---------·------ 1> Timing output Output Outputs signal consisting of oscillating frequency divided by four. 1--------+--·----------l------t----·------------·-------·--·------------·------·-------------·----- SYNC Synchronous signal output Output This signal is output "H" during operation code fetch and is used to control single stepping of programs. f--- ---+--------+------+---------------·-- - - - - - - -------1 - R/W Read/Write status output Output This signal determines the direction of the data bus. It is "H" during read and "L" during write. 1--------j---------j-----1--------------------·~---·-·-----------------------1 P00-P07 1/0 port PO 1/0 Port PO is an 8-bit 1/0 port with directional registers allowing each 1/0 bit to be individually programmed as input or output. The output structure is CMOS output. The low-order bits of the address are output except in single-chip mode. 1-------+---------__,-----t---------------------------------------------1 P1 0 -P17 1/0 port P1 1/0 Port P1 is an 8-bit 1/0 port and has basically the same functions as port PO. The high-order bits of the address are output except in single-chip mode. P2o-P2 7 1/0 port P2 1/0 Port P2 is an 8-bit 1/0 port and has basically the same functions as port PO. Used as data bus except in single-chip mode. I-----+-----------<----+------------------------------~- .- - - - - - - - P30 -P37 1/0 port P3 Port P3 is an 8-bit 1/0 port and has basically the same functions as port PO. Serial 110, PWM output, or 1/0 event 1/0 function can be selected with a program. t------+---------j-----1-------------------------------------·-- P40-P42 Input port P4 Input Analog input pin for the A-D converter. The 64-pin model has three pins and the 80-pin model has eight (P40-P4 7 ) pins. They may also be used as digital input pins. P5 0 -P5 7 1/0 port PS 1/0 Port P5 is an 8-bit 1/0 port and has basically the same functions as port PO. This port functions as an 8-bit data bus for the master CPU when slave mode is selected with a program. --------+-------+------------------------------------------~ Port P6 is an 8Rbit 1/0 port and has basically the same functlon as port PO. Pins P63 .-.....P6 7 change to a con- P6 0 -P67 1/0 port P6 1/0 trol bus for the master CPU when slave mode is selected with a program. Pins P60.-.....P62 may be program- med as external interrupt input pins. D-A,, D-A 2 0-A output Output Analog signal from 0-A converter is output. +-----+------------!-----+-----------------------------------------------! VREF Reference voltage input Input Reference voltage input pin for A-0 and D-A converter. This pin is for 64-pin model only. 1-------1---------+---+-------------------------------·----- ADV REF A-D reference voltage input Input Reference voltage input pin for A-D converter. This pin is for 80-pin modei only. 1------+---------j-----1---------------------------------------------~ DAV REF D~A reference voltage input input Reference voltage input pin for 0-A converter. This pin is for 80-pin model only. AVss Analog power supply Ground level input pin for A-0 and D-A converter. Same voltage as Vss is applied. 1-------+---------j----+-----·------------------------------------------- A Vee Analog power supply Power supply input pin for A-D converter. This pin is for 80-pin model only. Same voltage as Vee is applied. In the case of the 64-pin model, AVcc is connected to Vee internally. 1-------+------------!f------+------------------------------------------ - RD Read signal Output Control signal output as active "L" when valid data ls read from data bus. This pin is for 80Rpin model only. output - WR Write signal Output Control signal output as active "L" when writing data from data bus to external component. This pin is for output 80-pin model only. RESETouT Reset output Output Control signal output as active "H" during reset. It is used as a reset output signal for peripheral compo- nents. This pin is for 80-pin model only. 5 en I "T1 ..... fi M37450M2-XXXSP Ui (n m :... Clock Clock Timing Reset 0 Input Output Output Input n s:: RESET R/W SYNC Vee Vss ~ (,.) ...... .... (11 0 X1N XouT '.30'. "' '3i -r----11--@----@-------- ---1 c. iE' s:: I\) iii x>< Data Bus 3 >< en ""CJ C' 0 Clock Generating 0 circuit ~ a. iii" cc ii'! 3 I 51~-J I L_ ..________,___. ~ '---y-----' CNVss 1/0 port P6 1/0 port P5 1/0 port PO Note 1 : 256 bytes for M37450M2-XXXSP and 384 bytes for M37450M8-XXXSP. "',,," (') 2 : 8192 bytes for M37450M4-XXXSP and 16384 bytes for M37450M8-XXXSP. ,, ::Ill -I 0 z ~I M37450M2-XXXFP c.n ;.., Clock Clock Timing Reset Reset ~ Input Output Output Input Output (;) --i """ 01 0 X1N XouT ¢ -1-r-- RESET RESET ouT ~ WR RD R/W SYNC ---®--- Vee Vss -®-@----- - - - - - - - - - - - - - - - - - - - - I ~ "'x x ,,x \) Data Bus O" 0 Clock Generating 0 "'iii"" 0. circuit co Qi 3 I L_ __J '------,,------ CNVss 1/0 port P1 c l""I Cll Note : 256 bytes for M37450M4-XXXFP and 384 bytes for M37450M8-XXXFP. (") : 8192 bytes for M37450M4-XXXFP and 16284 bytes for M37450M8-XXXFP. ! ... 'V 0 '-J z FUNCTIONS 2. FUNCTIONS 2.1 Central processing unit (CPU) 6 registers are built-in the CPU of M37450. Accumulator (A), Index register X(X), Index register Y(Y), Stack pointer (S), Processor Status register (PS), all consisting 8-bit. Program Counter (PC) includes PCH and PCL, each of which consists of 8-bit registers. Other than the I flag to be set "1" immediately, the content of these registers are undefined after reset. Figure 2.1.1 shows the structure of the registers for M37450. A I Accumulator N v T B D Processor status register x I Index register X Carry flag Zero flag 7 I y I Index register Y Interrupt disable flag Decimal mode flag s I Stack pointer Break flag Index X mode flag 15 PCH PCL I Program counter Overflow flag Negative flag Fig. 2.1.1 Register structure 8 FUNCTIONS 2.1.1 Accumulator (A) The accumulator (A) is the 8-bit general-purpose register. This is a highly used register for data opera- tion, data transfer, temporary saves and conditional judgement. 2.1.2 Index register X(X), Index register V(Y) Index register X and Index register Y are both 8-bit registers. In the addressing mode using these index registers, memory access is made by adding the contents of the registers to the contents of the desig- nated address. This addressing mode is used for subroutine table reference and memory table reference, etc. Also, the index register has the increment, decrement, comparision, and data transfer functions which can be used as if it were an accumulator. In index register X, its content shows the OPERAND address when the T flag in the processor status reg- ister is "1 ". jl On-going routine JI L --------- J Interrupt requ est 1 (note) L M(S) - (PCH) J store return address [ --------- J L (S) - (S)-1 J 0 n stack : [ M(S) I - (PCL) J I _::]teJSR I [ (S) - (S)-1 J st ore contents of processor store return address [ M(S) - (PS) J atuS register on stack st on stack M(S) [ ---------- J [ (S) I - (S)-1 J (S) (S)-1 TI rL Interrupt routine } I flag "O"' to ''1'" fetch the jump M(S) I vector (PCL) I execute RTI (S) (S)-1 I I l subroutine I I I L (S) - (sJ+1 J restore contents of I I I I L (PS) - M(S) J p rocessor status register I J_ - I execute RTS restore return I [ (S) (S)+1 J I I address (S) (SJ+1 I [ (PCL) I - M(S) J restore return a ddress (PCL) M(S) I I I [ (S) I - (S)+1 J (S) (sJ+1 I I L (PCH) - M(S) J (PC") M(S) I J Note : The condition to enable the interrupt-+ interrupt enable bit fs "1" interrupt disable bit is "O"' Fig. 2.1.2 Stack store and restore sequence when executing interrupt and subroutine calls 9 FUNCTIONS 2.1.3 Stack pointer (S) Stack pointer is an 8-bit register used during subroutine calling and interrupts. When branching out from an on-going routine to subroutine and interrupt routine, it is necessary to remember the return address. Normally, internal RAM is used for storing the return address and this area is called stack area. Stack pointer is the pointer to show where the stack data are stored within the stack area. Figure 2.1.2 shows the data store and restore sequence to the stack area. Registers other than program counter and processor status register will not be stored automatically (during subroutine calling, the program counter only will be stored). Therefore, it is necessary, to store necessary registers by programming. (For the accumulator store and return, PHA and PLA instructions are used; for the store/return of processor status register, PHP and PLP instructions are used.) Normally, a zero page RAM ( 0000 16 ~ OOFF 16 ) is. used for the stack area. By setting the bit 7 ( SPS) of MISRG2 (address OODF 16 mentioned in the latter part) to "1 '', the 1-page RAM ( 0100 16 ~01 FF 16 ) can be used as the stack area. (However, this function cannot be used in the single-chip mode of M37450M2- XXXSP/FP, therefoe, do not set SPS to "1"). 2.1.4 Program counter (PC) Program counter is a 16-bit counter which consists of 8-bit register, PCH and PCL. This counter indicates the address of the next instruction to be executed. 2.1.5 Processor status register (PS) Processor status register is an 8-bit register which is composed of flags to maintain the condition of the processor immediately after an operation. After reset, I flag is set to "1", but other flags are unknown. T, D flags will directly affect operation so they must be always initialized. Each bit of the processor status register is explained below : (1) Carry flag C The carry flag maintains the carry or borrow generated by the Arithmetic Logic Unit (ALU) im- mediately after an operation, it is also changed by the shift and rotate instructions. SEC, CLC instruc- tions allow direct access for setting and resetting. (2) Zero flag Z This flag is set when the result of an operation and data transfer is "O" and reset when the result is other than "O". (3) Interrupt disable flag I This flag is used to disable all interrupts (except the ones caused by BRK instructions). When this flag is "1", it means interrupt disable condition. When an interrupt is accept, this flag is automatically set to "1" thereby preventing other interrupts. The SEI and CU insturctions are used by way of prog- ramming to set and reset this flag, respectively. (4) Decimal mode flag D This flag is used to define whether addition and subtraction are executed in binary or decimal. If the flag is "O'', the operation is executed in binary. When the content of the flag is "1", the operation is ex- ecuted in decimal. Decimal correction is automatically executed. (ADC and SBC is the only instruc- tion which can be performed in decimal mode). SED and GLD instructions are used to set and reset this flag, respectively. This can directly effects CPU operation ; always initialize after reset. (5) Break flag B The operation of a BRK instruction is similar to an interrupt. The BRK instruction is a non-maskable software interrupt that is used during program debugging. The break flag can be checked only by checking the content of the processor status register (PS) saved during an interrupt. The content of the processor status register (PS) is saved after setting flag B to "1" when the BRK instruction is used as an interrupt. It is cleared to "O" for other interrupts. 10 FUNCTIONS (6) Index X mode flag T When this flag is "O", the operation between accumulator and memory is executed. When this flag is "1", the operation between memories, memory and 1/0, 1/0 and 1/0 is executed directly and direct transfer of data is possible also without passing the accumulator. That is, the operation resulting be- tween memories 1 and 2 are stored in memory 1. The address of memory 1 is specified by the con- tents of index register X and that of the memory 2 is specified by the normal addressing mode. Flag T is set and reset by the SET and CL T instructions. This can directly effects CPU; always initialize after reset. (7) Overflow flag V The overflow flag functions when one word is added or subtracted in binary with the sign. When the result exceeds + 127 or - 128, the overflow flag is set. Besides the above conditions, when BIT in- struction is executed, the bit 6 of the memory, is input into the overflow flag. The overflow flag is reset by CLV insturction and no set instruction exists. This flag is non-function during the decimal operation mode. (8) Negative flag N The negative flag is set when the result of the data transfer or operation is negative (bit 7 is "1 "). Af- ter execution of BIT instructions, bit 7 of the memory where the BIT instruction is executed, is stored into the negative flag. The negative flag can be neither set nor reset directly. This flag is non- functional during the decimal operation mode. 11 FUNCTIONS 2.2 Access area In M37450, all ROM, RAM, 1/0, control registers are placed in the same memory area. Therefore, same instructions enable both data transfer and operation without the need to distinguish memory and 1/0 . M37 450 program counter consists of 16-bit and the accessible memory space is 64K byte from 0000 16 to FFFF15. Within the 64K-byte memory area, the lowest 256-byte and the highest 256-byte are called zero-page and special page area, respectively. Both are accessible with 2-byte by using the individual special addres- sing mode. 000015 RAM (128 bytes) 008015 1 - - - - - - - - - - - - Not used 1------------ SFR 010016 Not used t----------- FF00 16 ----r Internal ROM (4K bytes) Special page FFE0 16 1-- - - - - FFFF16 ------1 Vector table _ J_ _ Fig. 2.2.1 Block diagram of memory access area (M37450M2-XXXSP/FP) 12 FUNCTIONS 2.2.1 Zero page (0000 16...... 00FF 16) The 256-byte addresses from 0000 16 to OOFF16 are called zero page area where built-in RAM and Special Function Register ( SFR) are assigned. To specify the memory or register in the zero page area, use the zero page addressing mode shown in the Figure 2.2.2. Especially in this area, if using the instruction in the zero page specific addressing mode, we can access the zero page area with shorter instruction cycles. 2.2.2 Special page (FF00 16...... FFFF16) The 256-byte addresses from FF00 16 to FFFF16 are called special page area. To specify the memory in the special page area, use the special page addressing mode shown in the Figure 2.2.2. Especially in this area, if using the instruction in the special page specific addressing mode, we can access the special page area with shorter instruction cycles. Normally the highly used subroutines enter in this area. addressing mode ----,--- zero page specific zero page (2) zero page indirect (2) zero page X (2) addressing mode zero page y (2) l-----~-:: :g~:t~e:ti~e~3~ zero page bit (2) __ - - - absolute (3) absolute X (3) absolute Y (3) ----------, zero page addressing mode relative (2) 1 indirect (3) special page addressing mode indirect X (2) --------->--:'~·: '.'._(~ --- - ------ --- - -1 special page (2) special page specific ----------------~,~~·I~': __ ( ) indicates number of bytes Fig. 2.2.2 Zero page and special page addressing modes 13 FUNCTIONS 2.3 Memory map A memory map for the M37 450 (in single-chip mode) is shown in Figure 2.3.1. The following explains the memory and 1/0 assigned to the memory area in the single-chip mode. (1) RAM ( 0000 16 -00?F15) In M37450, the static RAM with the 128 X 8-bit capacity is assigned in the addresses 0000 16 to 007F16 . The internal RAM is used for data storage, subroutine calling or the stack area when interrupts occur. When RAM is used as the stack area, the depth of the subroutine 'nesting' and the interrupt levels should be kept in mind in order to avoid destruction of the RAM contents. (2) ROM (F000 1s-FFFF15) In M37450, the mask ROM with the 4K X 8-bit is assigned to the addresses F000 16 to FFFF16 . In the inter- nal ROM, addresses FFE0 16 to FFFF16 are assigned as the vector area of reset and for interrupts. (3) Special function register; SFR (OOD0 16 -00FF 16 ) Addresses OOD0 16 -00FF 16 are assigned for SFR (special function register) which includes input/output ports, timer, serial 1/0, bus interface, A-D converter, D-A converter, PWM, miscellaneous registers related to interrupts and CPU modes. OOD010 PO data register OOE810 Serial 110 control register OOD110 PO directional register OOE910 UART control register OOD210 P1 data register OOEA10 Baud rate generator OOD310 P1 directional register OOEB10 PWM register (L) OOD410 P2 data register OOEC1a PWM register ( H) OOD510 P2 directional register OOED10 Timer 1 control register 1 OOD610 P3 data register OOEE16 Timer 2 control register 2 OOD715 P3 directional register OOEF10 Timer 3 control register 3 OOD810 P4 OOF01s Timer 1 register ( L) OOD910 Reserved OOF11s Timer 1 register (H) OODA1s P5 data register OOF21s Timer 1 latch ( L) OODB10 P5 directional register OOF31s Timer 1 latch (H) OODC1s P6 data register OOF410 Timer 2 register ( L) OODD10 P6 directional register OOF51s Timer 2 register (H) OODE16 Miscellaneous register 1 OOF610 Timer 2 latch ( L) OODF10 Miscellaneous register 2 OOF71s Timer 2 latch ( H) OOE010 D-A1 register OOF81s Timer 3 register ( L) OOE11a D-A 2 register OOF910 Timer 3 register ( H) OOE210 A-D successive approximation register OOFA1a Timer 3 latch ( L) OOE310 A-D control register OOFB10 Timer 3 latch ( H) OOE410 Data bus buffer (DBBIN/DBBOUT) OOFC16 Interrupt request register 1 OOE510 Data bus buffer status register OOFD1s Interrupt request register 2 OOE610 Transmit/Receive buffer register OOFE1s Interrupt control register 1 OOE71s Serial 110 status register OOFF16 Interrupt control register 2 Fig. 2.3.1 SFR map 14 FUNCTIONS M37 450M2-XXXSP/FP --------ct-ec-im_a_I----. M37450M4-XXXSP/Fp----------ct-ec_i_m-al---. RAM I 000015 0 000016 0 ( 128 bytes) L RAM !--------- stack Zero page RAM ( 192 bytes) [ ooco,6 RAM 192 Zero 007F16 127 not used page 000016 208 not used SFR 010016 256 000015 208 RAM RAM SFR (64 bytes) t---------1 OOFF" 255 stack 013F 16 319 not used not used F000 16 E000 16 ROM ROM ROM (4K I FF0015 ROM (BK FFOO" bytes bytes) Special page Special page FFE0 16 vector table vector table FFFF16 FFFF16 M37450M8-XXXSP/FP - - - - - - - - - - - - - - . M37450S4SP/FP - - - - - - - - - - - - - - - . decimal decimal 000015 0 0 000016 RAM [ RAM RAM (192bytes) RAM Zero ( 192 bytes) Zero page 192 page OOC0 16 not used ooco,6 192 not used 000016 208 000016 208 SFR SFR 0100 16 256 010015 256 RAM RAM RAM RAM (192 bytes) r--------- (256 bytes) r---------1 stack stack OiBF, 6 447 01 FF16 511 not used COOO" ROM ROM FF0016 not used (16K bytes) Special page FFE0 16 vector table FFFF 16 FFFF" 15 FUNCTIONS 2.3.1 Processor mode M37 450 can select three processor modes by changing the contents of the processor mode bit (bit 0 and 1 of address OODF 16 ) while CNVss pin is connected to Vss. The relationship between the processor mode bit and each processor mode is shown in Table 2.3.1. Also, these modes can be controlled by the input level of the CNVss pin. Microprocessor mode starts when CNVss pin is connected to Vee, and the processor mode bits (b1, bO) are automatically set to ( 1, 0). In this case, only microprocessor mode can be selected, and do not change the processor mode bits. CNVss pin must be connected to Vee in case of external ROM version. The Table 2.3.2 shows the relationship between the CNVss pin input level and the processor mode. (1) Single-chip mode The all input/output ports of M37 450 have the original function. (2) Memory expanding mode This mode is used when the internal memory, 1/0, and the peripheral functions are not enough. In this mode, the register area for port PO~P2 cannot be used, but all other memory and the peripheral functions can be used. When memory expanding mode is selected, the functions of Port PO~P2 change as shown in Table 2.3.3. External memory can be placed in any area of the 64K bytes address. In the area where the external memory and the internal memory overlap, the internal memory has the priority to be read out. When the CPU reads out this area, therefore, the data from the external memory is not read into the CPU. The write- in in this area, however, will be made in the respective internal and external areas. (3) Microprocessor mode Same as the memory expanding mode except the access to the internal ROM area being prohibited. In this mode, ROM can easily be attached externally. Therefore this mode is used for small production or as the proto-type model before mass production. Figure.2.3.3 shows the memory map for each mode except the single-chip mode. Table 2.3.1 Relationship between the processor mode and the processor mode bit b1 bO I I I I DBBM DBBE CM1 CMO J MISRG2; address OODF 16 1 l Processor mode bit b1 bO 0 0 Single-chip mode 0 1 Memory expanding mode 1 0 M iCroprocessor mode 1 1 Inhibit use 16 FUNCTIONS Table 2.3.2 Relationship between CNVss pin input Table 2.3.3 The function of each port during memory level and the processor mode expanding mode CNVss pin Processor mode Port name Function Start as the single-chip mode after reset. Three Port PO Output the lower 8 bits of address. Connect to Vss modes can be realized by the processor mode bit. Port P1 Output the higher 8 bits of address. .. Microprocessor mode starts after reset. Only micro- Works as input/output pin for data D1 ........ Do (including i~=- Connect to Vee struction code). processor mode can be selected. Port P2 (The direction of the data bus will be determined by R/W status.) 0000,. 0000,. Internal RAM Internal RAM 008016 008016 External memory area External memory area 0000,. 000015 SFR SFR 0100,. 0100,. External memory area F000 16 External memory area Internal ROM FFFF 16 FFFF 16 Memory expanding mode Microprocessor mode Fig. 2.3.3 Memory map for each processor mode (except single-chip mode) I\ CM1 CMO 0 0 0 1 1 0 1 Par Internal Single-chip mode Internal Memory expanding mode Microprocessor mode ~ I I J I I Port PO Port P07 -P0o Port P01-P00 Same as left ~ 1/0 port ]( Address A1-Ao )C Internal Internal :J I I ~ I I Port P1 Port P1 7 -P1o Port P1 7 -P1 o Same as left ~ 1/0 port -:x Address A, 5 -A8 x:_ Internal j\J Internal Port P2 I Port P2 7 -P2o I J Port P21-P2 0 I I Same as left Y. 1/0 port J---~ Fig. 2.3.4 The function of ports PO~P2 in each processor mode 17 FUNCTIONS 2.3.2 Bus control during memory expansion M37450 is equipped with the software wait insertion flag, ROYE (bit 6 of address OOOF 16 ) which enables easy access in case of memory expanding and microprocessor mode with expansion of external memory and 1/0. When the ROYE flag is set, the bus operation is two times as slow as the original bus cycle ¢. The bus cy- cle changes at the next cycle after access is made to the ROYE flag. (see Figure 2.3.5) •Normal operation (ROYE=O) : ¢=2.5MHz (f(X 1N)=10MHz) •Slow operation (ROYE=1) : ¢=1.25MHz (f(X 1N)=10MHz) The flag setting affects the bus cycle even in the single-chip mode such as memory accessing and the peripheral function units except the timers, PWM, UART, etc. The ROYE flag is set to "O" at reset and the operation starts in no-software wait mode. SEB 6.DF1s CLB 6,DF1s LDA SYNCJl___I .______IL R/W LJ I RD WR Fig. 2.3.5 Bus-cycle changing by RDYE flag LJ 18 FUNCTIONS 2.4 Input/Output pin M37450 contains 53 input/output ports (58 in the 80-pin model). Figure 2.4.1 shows the input/output ports of the 80-pin model. B = P5 PO ¢:::::> -- P6 7 /W P1 B <==> -- ...,_____.,. P66 /R P65 /CS P6 4 /AO P6,IPRDY P2 P3o/EV 1 B <==> ~ P6 2 /INT 3 P3 1 /EV 2 ..,_.____,. - P6 1/INT 2 P3 2 /EV 3 P6 0 /INT 1 P3,IPWMouT B P34 1RxD ==> P4 P3 5 /TxD -- ______,,. D-A 1 D-A 2 P3,ISeLK P3,ISRDY -- ADVREf R/W -- DAV REF AVss SYNC -- CNVss A Vee RESET ¢ -- _____,,. Vss RESETouT Vee RD X1N WR Yor- lOMHz XouT Note : In the 64-pin model, P4 has 3 pins and no -RD, WR. AVee. RESET ouT pins. The reference voltage input pins for A-D and 0-A converters are common in 64-pin model. Fig. 2.4.1 Input/Output ports (80-pin model) 19 FUNCTIONS 2.4.1 Input/Output ports M37 450 has the input/output ports shown in Table 2.4.1. Table 2.4.1 Input/Output ports Port I Number of pins Programmable 1/0 port I Port PO-P3, P5. P6 48 3(64-pin model) Input port I Port 4 8(80-pin model) ---··- ·- Output port Jo-A 2 Port P3, P4, and P6 are double-functional ports and the function can be selected by program. The following shows how to determine the port direction of the programmable 1/0 port. Data that is written on the programmed output pin is stored in the port latch and is transferred to the out- put pin. When data is input to the programmed pin, data is read not from output pin but from output latch. Therefore, previously output data can be read correctly regardless of the logical level of the pin due to output loading. Because the programmed input pin is floating, the value of the pin can be read correctly. When data is written to the programmed input pin, it is written only to the port latch and the pin remains floating. The directional register can be utilized as same as the memory in the zero page; therefore using the zero page addressing mode achieves a short access cycle. The directional register corresponding to each port is located in the SFR area assigned to address 0000 16 ~ OOFF 16 . Each bit of this directional register determines the corresponding port direction. Bit and pin correspond in the follwing manner: On the corresponding bit of the pin: When "O" is written in, the corresponding port is an input pin. When "1" is written in, the corresponding port is an output pin. M37450 At reset, each directional register is initialized to "00 16", the 1/0 port is input. __ ,. r-----1 P0 7 Example: When "68 16" is written in the PO directinal register ( 0001 16 ). .,.__ P0 6 .,. __ P0 5 __ ,. P0 4 b7 b6 b5 b4 b3 b2 b1 bO .,.__ P0 3 000110 0 0 0 __,. P0 2 .,. __ P0 1 .,. __ POo ~ 20 FUNCTIONS Table 2.4.2 Port description Port PO 8-bit programmable input/output port Except in the single-chip mode, outputs the lower address byte. Output format : CMOS form Input format : TTL compatible Port P1 8-bit programmable input/output port Except in the single-chip mode, outputs the upper address byte. Output format : CMOS form 1-------+--ln~p_u_t_fo_r_m_a_t__:_T_T_L_c_o_m~p~a_t_ib_l_e _________,__ ______________________·-----~-~-~ Port P2 8-bit programmable input/output port Except in the single-chip mode, the data bus information is input and Output format : CMOS form output. Input format : TTL compatible 8-bit programmable input/output port This port is not affected by the processor mode. All ports are double- Output format : CMOS form functional ports in which functions can be selected by program. Input format : TTL compatible (However, when EV1 - EV3, RxD and ScLK pins are selected, they have schmitt input and not 1-------+--T_!L compatible) ---------+-_::------------------------------------ Port P4 3-bit input port· .. 64-pin model This port can be used as analog input pin and also as digital input port. 8-bit input port .. ·80-pin model When this port is read in 64-pin model, the upper 5 bits are unknown. Input format : TTL compatible Port P5 8-bit programmable input/output port ShT~ portis not affected by the p;;:;~essor mode. Port P5 can become auto- Output format : CMOS form matically the data bus for the host CPU when the slave mode is selected. Input format : TTL compatible (bit 2 of address OODF 16 as "1"). Port P6 8-bit programmable input/output port This port is not affected by the processor mode. Within this port, P6 3 -P67 Output format : CMOS form 5-bit can become automatically the control bus for the host CPU by select- Input format : TTL compatible ing the slave mode. (However, when INT1 -INT 3 are selected, they Port P6 0 - P6 2 3-bit port are double functions and functions can be have schmitt input and not TTL compatible) selected by program. -~ D-A 1 2-bit analog output port The value written-in the D-A converter register (OOE0 16 -00E1 16 address) D-A2 generates the corresponding analog voltage. 21 FUNCTIONS Port PO, P1, P2 Serial 1/0 enable bit Receive enable bit Directional register Directiooal register Data register Serial 1/0 enable bit Transmit enable bit Directional register Data bus Data register Event counter input Seruial 1/0 outnut Timer output Event interrupt input P3a Serial 110 clock selection bit Serial 1/0 enable bit ~ r-D-ire-ot-ion-,1-,,-,,-,,,-,!-_._____ Serial 1/0 mode selection bit (Synchronous) Data bus Serial 1/0 enable bit Data register Data bus Data register Serial 1/0 clock output External clock input Fig. 2.4.2 Block diagram of ports PO-P6 (single-chip mode) and output only pin output format(1) 22 FUNCTIONS Port P4 Serial 1/0 enable bit Serial 1/0 mode selection bit (Synchronous) Serial 1/0 mode selection bit ¢, R/W, SYNC, Rb, v'V-R, RESET OUT D;ita register Serial ready output P6 5 /CS P6 6 /R Data register Outp1Jt buffer Input buffer Bus interface enable bit 1 Directional register Data register Data register Interrupt input Parallel ready output Bus interface enable bit Direr.tiona! register Data bus Data register DBB control input P64 ······A0 input P6s ...... e:;§ input p55 ...... R/E input DBB control input P6,- .... ·W/R/W input Fig. 2.4.3 Block diagram of ports PO~P6 (single-chip mode) and output only pin output format (2) 23 FUNCTIONS 2.4.2 Pin descriptions (1) R/W pin R/W pin is the signal which determines the direction of the data .bus. When the pin level is "H", the data bus is in read state and wh~the level is "L", it is write state. Ordinarily, this signal is combined with signal and used to control RD and WR signals in both memory expanding and microprocessor modes. Also this pin can be used as an alternate switching signal to change the direction of the external bus buf- fer. Figure 2.4.4 shows an example for such a use. (2) RD, WR pin (Only in 80-pin model) The WR signal output from WR pin is functionally the same signal as the one that results by combining the R/W and signals as shown in Figure 2.4.4. A "L" signal is output when the bus is in a write cycle. The RD signal output from RD pin is approximately the same as the RD signal shown in Figure 2.4.4. A "L" signal is output only when CPU is actually reading data from the data bus. Using_!!:lis model design with peripheral devices is easily accommodated due to the separation of the RD and WR signals. Also the RD signal is not generated in a read cycle in which a dummy address is output, again allowing for easy connection to peripheral devices in the memory expanding and microprocessor mode. (3) X1N. XouT pin X1N and XouT are clock input/output pins. M37450 has a built-in clock generating circuit. The oscilation frequency is determined by a ceramic or crystal oscilator. When using an .external clock, the clock source should be connected to X1N pin and the XouT pin should be left open. (4) pin This pin outputs the internal system clock (the oscillation frequency between X1N and XouT divided by 4). During a STP and WIT instructions, operation ceases and is kept in a "H" state. (5) SYNC pin This pin outputs a "H" signal for one cycle at op-code fetch. It is used to control single-step operation of the program. Since this signal is also output when the CPU accesses internal memory and 1/0, it can be used to monitor the internal operation. (6) RESET pin To enter the reset state, the reset input pin must be kept at a "L" for more than 2µs (under normal Vee conditions). If more time needed for the crystal oscillator to stabilize, this "L" condition should be main- tained for the required time. (7) RESET ouT pin This pin becomes active "H" during reset and can be used as a reset signal for the peripheral devices. This is only in the 80-pin model. (8) VREF pin This pin inputs the reference voltage for the built-in A-D and D-A converters. This is only in the 64-pin model. (9) ADVREF pin This pin is used to input the reference voltage for the built-in A-D converter. It is only in the 80-pin model. 00) DAVREF pin This pin is used to input the reference voltage for the built-in D-A converter. It is only in the 80-pin model. (11) CNV88 pin Depending on the level input to this pin, the CPU will operate in a specific mode at reset (please refer to 2.3.1 for details). But by changing the level of this pin after reset, this mode remains unchanged. 24 FUNCTIONS (12) Vss. Vee. AVss. AVcc pin Power supply pins for this device and for the built-in A-D, D-A converters. AVcc pin is only in the 80-pin model and is connected to the built-in A-D converter. In the 64-pin model, it is internally connected to Vee- M37450 LS139 A,s --"' 1DA ~ CSO (0000 16- ) ; RAM Y, ~ CS1 (4000 16 - ) ; peripheral A,. - ~ 1D8 Y, cs2 (sooo 10- ) ; - Y3 CS3 (C000 16- ) ; ROM - - R/W ~ 2DA Y, ~ RD - if> 2Ds Yo WR Fig. 2.4.4 Example use of R/W signal 1 period SYNC Data Op code Op code Fig. 2.4.5 SYNC output 25 FUNCTIONS 2.5 Interrupt Interrupts are usually used in the following cases: • When the processing routine has higher priority than the on-going program. • When a routine must be executed at specific interval. The M37450 has 15 interrupt sources. Table 2.5.1 shows the priority and vector address of these inter- rupts. Each interrupt has its own jump vector address and a fixed priority. These 15 interrupts are prioritized as shown in Table 2.5.1 (Reset input has the highest priority among the interrupts). When two or more interrupt requests are generated at the same sampling point, the interrupt having the higher priority is accepted. The priority order is determined by hardware. However, multiple priority processing through software is possible by using interrupt control flags (interrupt enable bit, inter- rupt disable flag) . Table 2.5.1 Interrupt vector table and priority h Priority Interrupt source L Vector address Remarks Upper I Lower ----t--------T---------------------------·-~ 1 RESET (see note) FF 16 FFFE 16 Non-maskable 2 Input buffer full interrupt FFFD 16 FFFC 16 Valid only when data bus interface function is selected 3 Output buffer empty interrupt FFFB 16 FFFA 16 +--------·--------------1 f-- 4 INT1 interrupt FFF9 16 FFF816 Polarity programmable ------------~ ~I INT2 interrupt FFF7 16 FFF616 Polarity programmable t---_fi---+INT3 interrupt FFF5 16 FFF416 Polarity programmable 7 Timer 1 interrupt -··- -----~F3 16 FFF2 16 8 Timer 2 interrupt FFF1 16 FFF0 16 ~-· Timer 3 interrupt FFEF 16 II FFEE1s~---t-------------------l 10-· EV 1 (external event) interrupt I FFED 16 ..___ L_F_F_E_C_1~6_ _--+_P_o_la_rit~y~p_ro~g_ra_m_m_a_b_le_ _ _ _ _ _ _ _ _ ___, 11 EV 2 (external event) interrupt FFEB 16 I FFEA 16 Polarity program_m_a_b_le_ _ _ _ _ _ _ _ _ _ >--_1_2_+--E_V_3_(e_x_te_rn_a_Ie_v_e_nt_)_in__ F_E_91~6______+-_FF_E_8_1_6 _ _ _ _ _ te_r_ru_pt_ _ _ _ _ ---+---F__ Polarity programm_a__b_le_ _ _ _ _ _ _ _ ____, ~·-· Serial l/O receive interrupt --------~------------+----F__F_E_?_,_s___--J---F._F_E_B__,s_ ____, Valid only when serial 1/0 function is selected ~ Serial 1/0 transmit interrupt -----r--F_F_E_5_1_6 _ ___,_F_F_E_4_ 16_ _ _.,.___ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ____, 15 A-D conversion completion interrupt FFE3 16 FFE2 16 16 BRK instruction interrupt FFE115 Non-maskab!e software interrupt Note Reset is included in the table since it operates the same as other interrupts with the exception that it ls non-maskab!e 26 FUNCTIONS 2.5.1 Interrupt sources The following explains each interrupt source: (1) INT 1, INT2, INT3 interrupts An interrupt request is generated when a level-change from "H" to "L" or from "L" to "H" of the INT1, INT2, or INT 3 pin is detected (However, a pulse width of 160ns or more for "H" or "L" is necessary at the effec- tive polarity). These polarities are selected by bits 0-2 of MISRG1 (address OODE16) . INT1-INT 3 are common with P6 0 -:--P6 2 pins. They always detect the levels of port P6 0 -P62. At reset, MISRG1 is cleared to "00 16 ". So, INT1-INT3 interrupt request is generated at the falling edge. (2) Timer 1 -Timer 3 interrupts An interrupt request is generated at the next clock pulse after the timer 1, timer 2 or timer 3 reaches "000015". (3) EV 1, EV 2, EV3 interrupts An interrupt request is generated at the valid edge of the event wave form. (However, a pulse width of 160ns or more for the "H" or "L" is necessary at the effective polarity.) Selection of polarities is decided by bit 5 of the timer 1-3 control register. (4) Input buffer full (IBF) interrupt (Valid only when the data bus interface function is selected) The stat~_of data bus is latched into the input data bus buffer (DBBIN) at the rising edge of Wafter both CS and W are simultaneously "O" . At this point the IBF interrupt request is generated. (5) Qutpu_t_J:iuf!_er empty (QBE) interrupt (Valid only when the data bus interface function is selected.) When all CS, R and A0 are simultan~ously "O" , the data from the output data bus buffer is output to the data bus. Then at the rising edge of R signal, QBE interrupt request is generated. (6) Receive interrupt (valid only when serial l/Q is selected.) An interrupt request is generated when all data is received in the receive shift register and its contents are moved into the receive buffer. (7) Transmission interrupt (valid only when serial l/Q is selected.) In the case of the transmission interrupt, the interrupt timing can be selected by the transmission interrupt control bit (TIC) , bit 3 of the serial l/Q control register (See Table 2.5.2). (8) A-D conversion completion interrupt Interrupt request is generated at the completion of the A-D conversion. (9) BRK interrupt This interrupt is the lowest priority order software interrupt. It does not have a corresponding interrupt en- able flag nor it is effected by the interrupt disable flag ( non-maskable). If some interrupt requests are pending by interrupt enable bits or interrupt inhibit flag at BRK instruction execution, the service routine of the highest priority among the pending one is executed. For detailed explanation of each interrupt, please refer to the section on each function. Table 2.5.2 Selection of interrupt source by TIC TIC Interrupt sources ! - - - - + - - - - - - - - - - - - - - - - - - - - - _ _ _ _ : __ _ _ _ _ _ _ - - - - - - - - - - - - - - - - - - - - - - "O" The data written into the transmission buffer is transferred to the transmit shift register and when the transmission buffer becomes empty, the interrupt request is generated. "1" When the shift operation of the transmission shift register i~· completed: the i~terrupt request -is--ge_n_e_ra-te_d_.___ _ 27 FUNCTIONS Table 2.5.3 Structure of registers related to interrupt ( 1) bl bO Interrupt request register 1 (address OOFC 16 ) I I I I L ____ _ I Input buffer full interrupt request bit I I I I 0 : Request did not occur I I 1 : Request occurred I I I I L ________ Output buffer empty interrupt request bit I I 0 : Request did not occur I I I 1 : Request occurred I I I L _________ - INT 1 interrupt request bit I I 0 : Request did not occur I 1 : Request occurred I I L ____________ INT 2 interrupt request bit I I 0 : Request did not occur I 1 : Request occurred I L - - - - - - - - - - - - - INT3 interrupt request bit 0 : Request did not occur 1 : Request occurred I L _ -- - - - - - - - - - - - - -- Timer 1 interrupt request bit' I I 0 : Request did not occur I IL ________________ _ 1 : Request occurred Timer 2 interrupt request bit 0 : Request did not occur 1 : Request occurred ----- - - - - - - - - - - - - - - Timer 3 interrupt request bit 0 : Request did not occur 1 : Request occurred b7 bO 1-1-1 I I I I I Interrupt request register 2 (address OOFD 16 ) I I I I I L _____ EV 1 interrupt request bit I I I I I I I 0 : Request did not occur I I I I I 1 : Request occurred I I I I I ' - - - - - - - - EV 2 interrupt request bit I I I I I 0 : Request did not occur I I I I 1 : Request occurred I I I I L _________ EV 3 interrupt request bit I I I I I I 0 : Request did not occur I I I 1 : Request occurred I I I I I L _ - - - - - - - - - - - Serial 1/0 receive interrupt request bit I I 0 : Request did not occur I I I I 1 : Request occurred I I I L _________ ------Serial 1/0 transmit interrupt request bit I 0 : Request did not occur I 1 : Request occurred IL _______________ A-D conversion completion interrupt request bit 0 : Request did not occur 1 : Request occurred 28 FUNCTIONS Table. 2.5.4 Structure of registers related to interrupt (2) b? bO Interrupt control register 1 (address OOFE 16 ) I I I I I I I L ____ _ Input buffer full interrupt enable bit I I I I I O : Interrupt disable I I I I 1 : Interrupt enable I I I I I I L _ - - - - - - - Output buffer empty interrupt enable bit I I I O : Interrupt disable I I I I I I 1 : Interrupt enable IL _________ _ I I INT, interrupt enable bit I I I I 0 : Interrupt disable I I 1 : Interrupt enable I I I L ___________ _ INT 2 interrupt enable bit I I I 0 : Interrupt disable I I I I 1 : Interrupt enable I I I I INT 3 interrupt enable bit I I 0 : Interrupt disable I I I I 1 : Interrupt enable I L ______________ _ Timer 1 interrupt enable bit I I 0 : Interrupt disable I 1 : Interrupt enable I L ________________ _ Timer 2 interrupt enable bit 0 : Interrupt disable 1 : Interrupt enable - - - - - - - - - - - - - - - - - - - T i m e r 3 interrupt enable bit 0 : Interrupt disable 1 : Interrupt enable b? bO Interrupt control register 2 (address OOFF 16 ) I L _____ EV, interrupt enable bit O : Interrupt disable 1 : Interrupt enable - - - - - - - EV 2 interrupt enable bit O : Interrupt disable 1 : Interrupt enable L ___ - - - - - - EV 3 interrupt enable bit O : Interrupt disable 1 : Interrupt enable L ___ - - - - - - - - - Serial 1/0 receive interrupt enable bit 0 : Interrupt disable 1 : Interrupt enable L _______ - - - - - - S e r i a l 1/0 transmit interrupt enable bit 0 : Interrupt disable 1 : Interrupt enable L_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ A-D conversion completion interrupt enable bit 0 : Interrupt disable 1 : Interrupt enable 29 FUNCTIONS 2.5.2 Interrupt control The interrupt control model for M37 450 is shown in Figure 2.5.1. Interrupt request bit Interrupt enable bit Interrupt inhibit flag (I) Interrupt process starts Fig. 2.5.1 Interrupt control The interrupts for M37 450, as shown in Figure 2.5.1, are controlled by the interrupt request bit, interrupt enable bit, and interrupt inhibit flag ( I ) except the software interrupt by BRK instruction. These control bits and control flags are explained below: (1) Interrupt request bit Whenever interrupt request is generated, the request bit corresponding to the respective interrupt is set to "1". The request bit remains "1" until the interrupt is accepted, at which point it is automatically cleared. This bit can be cleared in program, but can not be set. The interrupt request bits are in the interrupt request registers 1 and 2 (addresses OOFC 16 and OOFD 16 ). (2) Interrupt enable bit This bit determines whether an interrupt will be accepted or not. When the enable bit is "O" an interrupt by the corresponding interrupt source is prohibited. When this bit is "1" an interrupt by the corresponding source is allowed. (3) Interrupt inhibit flag ( I ) Interrupt inhibit flag ( I ) is in the bit 2 of the processor status register. This flag inhibits all interrupts ex- cept the BRK instruction interrupt. By setting the interrupt inhibit flag to "1" , all interrupts are inhibited. By clearing it to "O" , the interrupt is allowed. To set and reset interrupt inhibit flag, SEI, CLI instructions are used respectively. When an interrupt is accepted, and program flow goes to the interrupt service routine, the interrupt inhibit flag is automatically set and multiple interrupts are inhibited. In order to allow multiple interrupts, this flag must be cleared by the CLI instruction within the interrupt routine. Each of these control flags and control bits is independent and have no effect on the other two flags. When the interrupt request and the interrupt enable bits are "1" , and the interrupt inhibit flag is "O" , the corresponding interrupt is generated. 30 FUNCTIONS 2.5.3 Interrupt sequence When an interrupt is accepted, the on-going process is stopped and the interrupt service routine is ex- ecuted. After the interrupt service routine is completed it is necessary to restore everything to the state before the interrupt occurred. In M37450, as soon as an interrupt is accepted, the contents of the program counter and the processor status register are saved in the stack area. At the same time, the content of the vector address corres- ponding to the accepted interrupt, which is in the inte~rupt vector table, enters into the program counter and interrupt service routine is executed. In the interrupt service routine, the corresponding interrupt request bit is cleared to "O" and interrupt in- hibit flag becomes "1" , thereby inhibiting multiple interrupts. (In order to allow multiple interrupts, the in- terrupt inhibit flag needs to be cleared by the CLI instruction. ) In order to execute the interrupt service routine, it is necessary to write the jump addresses (the first address of the interrupt service routine) in the vector table corresponding to each interrupt. The VElctor addresses of each interrupt are shown in the Table 2.5.1. Figure 2.5.2 shows the change in the stack pointer and the program counter at the time when an interrupt is accepted. Program counter Stack (in zero page) (S ) Program counter( L) Program counter( H) Stack pointer .. I____ c_s_)- - - - - ' ..... Interrupt accept Program counter Stack (in zero page) PCL Loaded contents of the vector (S )-3 address corresponding to the PCH accepted interrupt Processor status word Stack pointer I (S)-3 S) Program counter ( L) Program counter ( H) v Fig. 2.5.2 Program counter and stack pointer change in interrupt sequence 31 FUNCTIONS 2.5.4 Timing after interrupt Figure 2.5.3 shows the timing sequence when an interrupt is accepted. Figure 2.5.4 shows the processing time involved in the execution of interrupt service routine. SYNC R/W Address PC S,SPS S-1,SPS S-2,SPS Vector L Vector H Data Do not use PS Note : Vector L and vector H are the vector address of each interrupt, and AD", ADL are the contents of these vector address (jump addresses). See Table 2:5.1 for the vector address of each interrupt. Fig. 2.5.3 Timing chart after interrupt The interrupt service routine will start after the completion of the instruction being executed when the re- quest occurs. The two conditions that allow for the interrupt to be accepted is the interrupt inhibit flag must be "O" and the interrupt enable bit must be "1" (excluding the BRK instruction interrupt) . Interrupt request 23-7 cycles (9.2-2.Bµs when 10MHz is in operation) Main routine Maximum 16 cycles* Q ,_ __ The dummy cycle to 5_c_y_c-le_s......, stack save vector fetch Minimum O cycles process alter pipeline * At the DIV instruction Fig. 2.5.4 Execution time prior to interrupt process routine 32 FUNCTIONS 2.6 Timer M37450 has three multi-functional 16-bit timers and one 8-bit timer for generating serial 1/0 bit rate ( BRG). BRG will be explained under serial 1/0 section. Each of the three 16-bit timers is independent. The following seven modes are program selectable. • 16-bit timer mode (with timer latch) •Event counter mode (event polarity programmable) •Pulse output mode •Pulse period measurement mode •Pulse width measurement mode •Programmable waveform generation mode •Programmable one-shot generation mode Figure 2.6.1 shows the block diagram of the timers. Data bus 8 TL, TLH f(X,N)/4 16 INT T, TH Timer interrupt request bit RTL Timer control register 8 8 8 Data bus Fig. 2.6.1 Timer block diagram 33 FUNCTIONS 2.6.1 Block explanations (1) 16-bit timer (T) The 16-bit timer T consists of two 8-bit timers, TH and TL· The timer operates as a down counter, and the timer interrupt request is generated at the next clock pulse after the timer reaches "O". At the same time the timer interrupt request flag is set to "1" , and since the contents of the timer latch is transferred into the timer except in pulse period measurement mode and in pulse width measurement mode. In M37450, since the timer and the timer latch are independent, if the timer is set to a specific value the timer latch does not change. Data can be written into the timer at any time. In order to write a value directly into the timer, the count enable bit must be set to disabled ( "O") . First, the lower 8 bits (TL) must be written into the timer, and then the upper 8 bits (TH) must be written im- mediately following. The timer counts down from its value until it underflows at the next count of which the interrupt request flag is set to "1". When reading the value of the timer, since it is 16 bits, the upper 8 bits of the timer must be read (TH) . At the same time the contents of the lower timer byte (TL) are latched into the read-out timer latch (RTL) which can be read. Then if the lower timer byte (TL) is read, the read-out timer latch (RTL) output the data. Therefore, we are reading both TH and TL at the same time. (2) 16-bit timer latch (TL) The 16-bit timer latch TL consists of two 8-bit timer latches TLH or TLL. The data in this latch is read into the timer every time the timer overflows except in pulse period measurement mode and in pulse width measurement mode. At any time data can be sent to the timer latch. There is no specific required order when writing a value into the timer latch. The division ratio is 1I ( N+1) , where N is the value loaded into the timer latch. (3) Read-out timer latch (RTL) The read-out timer latch RTL latches the contents of the TL when the TH is read out. (4) Count enable bit (C) The count enable bits, C1 -C3, are bit 4- bit 6 of MISRG1. Each count bit C1 -C3 corresponds to the specific timer as shown in the Figure 2.6.2. "O" : Inhibit to input the count source to timer. "1" : Cornect the count source to timer. Immediately after reset these bits are set to "O" disable to count. If these bits, C1-C3 are set to "1" at the same time, timer 1-timer 3 will start counting simultaneously. C1 f(X,N) Timer 1 Timer 1 interrupt INT 1 Timer 2 Timer 2 interrupt INT 2 Timer3 Timer 3 interrupt INT3 Fig. 2.6.2 Correspondence between count enable bit and count source selection bit 34 FUNCTIONS (5) Count source selection bit (S) The count source selection bits, S1 ~ S3 are bit 3 of the timer 1 ~timer 3 control registers respectively. The count source of the timer can be selected by this bit. "O": oscillation frequency f (X 1N) divided by 4 "1" : external input INT pin. At 16-bit timer mode, event counter mode and programmable one-shot generation mode, this bit may be ignored. (6) Timer mode selection bit (TMS) The timer mode selection bits are bit 0~2 of timer 1 ~timer 3 control registers respectively. The corres- pondence between the timer mode selection bit and the timer mode is shown in Table 2.6.1. However, the timer 1 will be forced to be 16-bit timer mode after the execution of STP instruction and re- turns to the original timer mode after re-start (return from the STP state). Table 2.6.1 Relationship between TMS and the timer mode TMS Selection mode b2 b1 bO ---j 0 0 0 16-bit timer mode 0 0 1 Event counter mode ------1 0 1 0 Pulse output mode 0 1 1 Pulse period measurement mode 1 0 0 Pulse width measurement mode 1 0 1 Programmable wave form generation mode 1 1 0 Programmable one-shot generation mode 1 1 1 Selection disable Table 2.6.2 Timer related bit structure b7 bO 1-1-1 I Timer 1 control register (address OOE0 16 ) I I I I L _ _L __ L - - - -- Timer 1 mode selection bit (000) : 16-bit timer mode ( 001 ) : Event counter mode (010): Pulse output mode (011) : Pulse period measurement mode (100) : Pulse width measurement mode (101) : Programmable waveform generation mode I (110): Programmable one-shot generation mode I IL_ _ _ _ _ _ _ _ _ _ _ I Timer 1 count source selection bit I 0 : f(XIN)/4 I I 1 : INT1 pin input I L----------- Output level latch L - - - - - - - - - - - - Event polarity selection bit 0 : Falling edge 1 : Rising eage Note : Timer 2 and timer 3 control registers consist of the same bit structure as timer 1 control 1 register. 35 FUNCTIONS 2.6.2 16-bit timer mode (TMS"OOO") (1) Summary Interrupt request is generated each time when the timer overflows. Resolution~-16-bit Division ratio--1 /( N+1) When the value N ( N=0~65535) is written into the timer latch. Count source-Oscillation frequency f (X 1N) divided by 4. Figure 2.6.3 shows the structure of the timer mode. (2) Explanation of the timer mode operation The timer starts counting by setting the count enable bit to "1" . The timer counts down from its value until it underflows at which point the interrupt request flag is set to "1" . At the same time the content of the timer latch is loaded into the timer. The count source for the timer is connected to the oscillation clock f(X 1N) divided by 4 independent of the count source selection bit ( S) . If the timer register is set to a value N, the timer counts N times and on the next clock cycle loads the value of the timer latch into the timer. (3) Note The timer and the timer latch are each independent therefore, necessary to initially set a value in the tim- er register and the timer latch. Data bus 8 8 Count enable bit 16 TL Timer interrupt request bit RTL Timer control register 8 8 8 Data bus Fig. 2.6.3 16-bit timer mode structure 36 FUNCTIONS 2.6.3 Event counter mode (TMS "001 ") (1) Summary In this mode, the timer counts an extenal event input from EV port as the count source. Resolution--16-bit Division ratio--1/(N+1) when the value N (N=0~65535) is written into the timer latch. Count source-External event input from EV port. (Event polarity can be selected by program.) Maximum event input frequency- 1MHz at f(X 1N) =10MHz Figure 2.6.4 shows the structure of event counter mode. (2) Explanation of the event counter mode Event counter mode operates in the same way as the 16-bit timer mode except it counts the external event input from EV port. The count source selection bit ( S) does not effect this mode. Event polarity is selected by bit 5 of each timer control register. (3) Note The pulse widths of the event input signal period (either "H" or "L" ) must be (4/f(X 1N)+100ns) or more (where f(X 1N) is the oscillation frequency) . The event input from EV port is input into the timer synchronously with the internal clock, except the tim- ers 2 and 3 count asynchronously while the STP instruction is executed. Do not change the input status immediately before stop condition. Also, depending on the condition of EV port immediately before the change into stop condition and the value of the event polarity, the following lags in the count value occur as shown in Table 2.6.3. Table 2.6.3 Change in count value depending on the event polarity and the EV port Event polarity EV port Change in count value f - - - - - - - - - - - + - - - - - - - - - - - -- - - j - - - - - · - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 0 1 count down immediately after execution of STP instruction >---------+--------+-------------------·---------------~--·-~ 0 1 No change in the count value after execution of STP instruction 1 0 No change in the count value after execution of STP instruction f----------+------------j---------·------------------------j 1 1 1 count down immediately after execution of STP instruction Data bus 16 Event EV polarity Timer interrupt request bit selection Timer control RTL register 8 8 8 Data bus Fig. 2.6.4 Event counter mode structure 37 FUNCTIONS 2.6.4 Pulse output mode (TMS "01 O") (1) Summary This mode outputs a variable period pulse on the EV port. Resolution--16-bit Count source-Selected by the count source selection bit. Figure 2.6.5 shows the structure of pulse output mode. (2) Explanation of pulse output mode operation In this mode, a pulse width 50% cycle duty is output to the EV port and reverse the output each time the timer underflows. This creates a pulse period which is two times that of the timer underflow cycle. (3) Note EV port is initialized to "O" when "01 O" is written in TMS. The pulse widths, (either "H" or "L") must be (6/f(X 1N)+10ons) or more (where f(X,N) is the oscillation frequency). Data bus 8 8 TLL TLH f(X,N)/4 16 INT TL TH Timer interrupt request bit EV Timer control RTL register 8 8 8 Data bus Fig. 2.6.5 Pulse output Mode block diagram 38 FUNCTIONS 2.6.5 Pulse period measurement mode (TMS "011 ") (1) Summary This mode measures the period of the event wave form input from EV port. Resolution--16-bit Count source-Selected by the count source selection bit. Figure 2.6.6 shows the structure of pulse period measurement mode. Data bus 8 8 TLL TLH f(X,N)/4 Count enable bit 16 INT TL TH Timer interrupt request bit EV Timer control RTL register EV interrupt request bit 8 8 8 8 Data bus Fig. 2.6.6 Pulse period measurement mode structure (2) Explanation of the pulse period measurement mode operation The measured pulse period can be selected either from rising edge to rising edge of the event waveform or from falling edge to falling edge by the EV polarity selection bit (EP) . In this mode, event interrupt re- quest is generated at the valid edge of the event waveform. At this time the value which is 1's comple- ment of the timer is loaded into the timer latch, the contents of the timer is set to "FFFF 16" and the count- ing continues. Also when timer underflows the counting starts from "FFFF 16" instead of the value read from timer latch. r--- with EP="1" ---O>j "H" Event input wave _J I "L" fE-- with EP="O" ----?>/ Fig. 2.6.7 Measurement area selection by event polarity (3) Note EV interrupt cannot be accepted during the STP mode. Also during pulse period measurement mode, data should not be written into the timer latch. The pulse widths of input pulse from EV pin (either "H" or "L") must be (4/f(X 1N)+100ns) or more. Also the pulse widths of count source input signal from INT pin must be (6/f(X 1N)+100ns) or more (where f(X 1N) is the oscillation frequency). 39 FUNCTIONS 2.6.6 Pulse width measurement mode (TMS "100") (1) Summary This mode measures the pulse width of the event waveform input to the EV port. Resolution--16-bit Count source-Selected by the count source selection bit. Figure 2.6.8 shows the structure of the pulse width measurement mode. Data bus 8 8 TLL 16 INT Timer interrupt request bit EV RTL Timer control register EV interrupt 8 request bit Data bus Fig. 2.6.8 Pulse width measurement mode structure (2) Explanation of pulse width measurement mode operation The measured pulse width can be selected as either the width during the "H" period or the "L" period by the EV polarity selection bit. If EV polarity is selected as falling edge ( EP = "O") , the width of the "H" period is measured; if it is selected as rising edge (EP="1") , the width of the "L" period, is measured. The function of the timer in this mode is the same as the pulse period measurement mode, but timer is set to "FFFF 16 " at both edges of event waveform. with EP="O" "H" Event input wave_J ~--"L" with EP="1" Fig. 2.6.9 Measurement area selection by event polarity (3) Note EV interrupt cannot be accepted during the STP mode. Also during pulse width measurement mode, data should not be written into the timer latch. The pulse widths of input pulse from EV pin (either "H" or "L") must be (4/f(X 1N)+lOOns) or more. Also the pulse width of count source input signal from INT pin must be (6/f(X 1N)+ 100ns) or more (where f(X 1N) is the oscillation frequency). 40 FUNCTIONS 2.6.7 Programmable waveform generating mode (TMS "101") (1) Summary This mode output to the EV port the contents of the output level latch ( OLL), bit 4 of the timer control reg- ister, whenever the timer underflows. Resolution--16-bit Count source-Selected by the count source selection bit. Figure 2.6.10 shows the structure of the programmable waveform generating mode. (2) Explanation of programmable waveform generating mode operation The operation is the same as the pulse output mode except it outputs the content of the output level latch ( OLL) to the EV port whenever the timer underflows. A programmable waveform can be generated after the timer underflows by changing the value of the output level latch and the timer latch. (3) Note EV port is initialized to "1" when "101" is written in TMS. The pulse width of count source input signal from INT pin must be (6/f(X 1N)+100ns) or more (where f(X 1N) is the oscillation frequency). Data bus 8 8 Tlc TLH f(X,N)/4 16 INT Tc TH Timer interrupt request bit EV Q Timer control RTL register 8 Data bus Fig. 2.6.10 Programmable wave form generating mode structure 41 FUNCTIONS 2.6.8 Programmable one-shot generation mode (TMS "110") (1) Summary Resolution-~16-bit Count source-Oscillation frequency f(X 1N) divided by 4 Figure 2.6.11 shows the block diagram to the programmable one-shot generation mode. (2) Explanation of the programmable one-shot generation mode operation In this mode, a trigger signal from the INT pin leads the contents of the timer latch into the timer and starts the timer counting. At the same time as the trigger, the EV port becomes "H". When the timer underflows, this port becomes "L". The count source is the oscillation frequency divided by 4, regardless of the value of S. The maximum one-shot width is 26ms. (f(X 1N)=10MHz). The polarity of the trigger is programmable. (3) Note When "11 O" is written in TMS, EV pin is initialized to "O". The rising output from EV pin is synchronized with the trigger input signal of INT pin. The pulse width of count source input signal from INT pin must be (6/f(X 1N)+100ns) or more (where f(X 1N) is the oscillation frequency). Data bus 8 8 TLL 16 INT Timer interrupt request bit EV Timer control RTL register 8 8 8 Data bus Fig. 2.6.11 Programmable one-shot generation mode structure 42 FUNCTIONS 2. 7 Serial 110 M37450 has a built-in serial interface which can operate in either clock synchronous or asynchronous (UART). mode. There is also a built-in timer ( BRG) for generating the baud rate specifically for the serial 1/0 function. 2.7.1 Baud rate generator (BRG) BRG is an 8-bit timer with a timer latch used for generating baud rate of the serial 1/0. Bit 0 of the serial 1/0 control register selects whether f(X 1N)/2 or f(X 1N)/8 is used as the clock source for the BRG gener- ator. BRG division ratio---1 /( n+1) ( n : the value programmed in address OOEA16) Figure 2.7.1 shows the structure of BRG. Data bus BRG latch BRG BRG count source ' - - - - - - - - - ' -t Clock synchronous serial 1/0 shift clock - - UART transmit! shift clock selection bit ~l~~~I ~~~ction bit (UART) UART receive shift clock ScLK 0-------- Serial 1/0 clock selection bit (Clock synchronous serial 1/0) Fig. 2.7.1 Baud rate generator block diagram 43 FUNCTIONS 2.7.2 Clock synchronous serial 1/0 In M37 450, the clock synchronous serial 1/0 mode can be selected by setting the serial 1/0 mode selec- tion bit (bit 6 ofthe serial 1/0 control register )to "1 ". (1) Summary M37 450 has a built-in clock synchronous serial 1/0 with the following features: Protocol data communication-LSB first half duplex or full duplex Synchronous clock-BRG/4 or external clock input from ScLK pin (Max external input clock should be 1.25MHz) Data bus address OOE6, 6 Serial 110 control register address OOE8 16 P3s P34 r-;;;;;=-;::;;;;;-;;;;;;;;-1---~Rece1ve buffer full flag (RBF) ~---- Receive interrupt request (RI) RxD RE ScLK Frequency dividing ratio 11( n+1) f(X,N) Baud rate generator address OOEA 16 SRDY .---~---~ Shift clock TxD , >--~--w...---+--f-=:=.::::::=:::-1__~~-Transmit shift completion flag (TSC) TIC Transmit interrupt request (Tl) '----..----_J---_._- Transmit buffer empty flag (TSE) P3s P3 7 - - - - - - - , , address OOE616 Serial 110 status register address OOE7 16 Fig. 2.7.2 Clock synchronous serial 1/0 block diagram 44 FUNCTIONS (2) Block explanations [Serial 1/0 control register] Serial 1/0 control register consists of 8-bit and Table 2.7.1 shows the bit structure of the serial 1/0 control register. All bits of the serial 1/0 control register can be read or written to the program. At reset this register is cleared to "00 16 " disabiling the serial 1/0 function. Table 2.7.1 Bit structure of serial 1/0 control register b7 bO ._._.__,........_,...............,._._..,......._,.........~ .......~1-' I Serial 1/0 control register (address OOE8 16 ) I L __ - - - - BAG count source selection bit 0: f(X,N) divided by 2 1 : f(X,") divided by 8 L - -- - - --- Serial 1/0 synchronous clock selection bit 0 : BRG output 1 : External input clock L - - - - - - - - - SRov output enable bit 0 : P3 7 functions as normal 1/0 pin 1 : P3 7 function changes to SRov output pin L _ - - - - - - - - - - Transmit interrupt source selection bit 0 : Transmit buffer is empty 1 : Transmit shift operation is complete I I L_ - - - - -- - - - - - -- Transmit enable bit I 0 : Transmit disable I I 1 : Transmit enable L - - - - - - - - - - - - - - - Receive enable bit 0 : Receive disable 1 : Receive enable L __ - - - - - - - -- - - - - - Serial 1/0 mode selection bit 0: UART 1 : Clocked serial 1/0 L - - - - - - - - - - ·- - - - - - - Serial 1/0 enable bit 0 : Serial 1/0 disable (Pins P34 -P3 7 are normal 1/0 ports) 1 : Serial 1/0 enable (Pins P34 -P3 7 function as serial 1/0 pins) •Bit 0 : BRG count source selection bit This bit selects the input clock for the baud rate generator between f (X 1N) divided by 2 and f(X 1N) divided by 8. •Bit 1 : Serial 1/0 synchronous clock selection bit This bit selects whether BRG output or the external input clock issued as the clock. When an external input clock is selected, a clock of 1.25MHz or below must be used. When this bit is set to "O" in the synchronous serial 1/0 mode, the BRG output divided by 4 is selected as the syn- chronous clock. When this bit is set to "O" in UART mode, the BRG output divided by 16 is selected as the syn- chronous clock. 45 FUNCTIONS • Bit 2 : SRov output enable bit This bit controls s;~~ output. When SRDY output is selected at serialJLQ enable and in olock synchronous serial 1/0 mode, port P3 7 becomes output pin and output SRov signal. When UART function is selected, port P3 7 works as a normal input/output port regardless of the value of this bit. •Bit 3 : Transmit interrupt source selection bit (TIC) This bit selects the interrupt trigger point in the transmission process. If the bit is set to "O" , the transmit interrupt occurs when the transmit buffer becomes empty. If the bit is set to "1" the in- terrupt occurs when the transmit shift register has completed shifting. •Bit 4 : Transmit enable bit (TE) This bit enables the transmission operation of the serial 1/0. •Bit 5 : Receive enable bit (RE) This bit enables the receive operation of the serial 1/0. •Bit 6 : Serial 1/0 mode selection bit This bit selects the clock asynchronous or clock synchronous serial 1/0 mode. • Bit 7 : Serial 1/0 enable bit This bit controls the serial 1/0 function. When serial 1/0 is enabled, the port P3 4 ~ P3 7 can be selected as serial 1/0 function pins. The changes in the pin functions when the serial 1/0 is en- abled are shown below. P3 4 ~P3 7 pins change in functions • P3 4 pin: Serial data input pin ( RxD) I This is used as the normal 1/0 port when receive enable bit is disable( "O"). • P3 5 pin: Serial data output pin ( TxD) I I This is used as the normal 1/0 port when transmit enable bit is disable("O"). • P3 6 pin: This is used as the normal 1/0 port when internal clock is selected at UART. • P3 7 pin: Receive-enable signal output pin ( SRov) I This is used as the normal 1/0 port when UART is selected or SRov output function is not selected. _j 46 FUNCTIONS [Serial 1/0 status register] Serial 1/0 status register is the read-only register consisting of 7 flags which show the state of transmit and receive of the serial 1/0. At reset, this register is initialized to "00 16 ", but when the transmit enable bit of the serial 1/0 control reg- ister is "1" (enable), this register will be set to "05 16 " Table 2.7.2 Serial 1/0 status register b7 bO -I '---'-~.L..,,.......l.~-'---'~-'-~1_._~1r-' I Serial 1/0 status register (address OOE7 16 ) I L _____ Transmit buffer empty flag (TBE) I O: Full I 1 : Empty I I L _______ Receive buffer full flag (RBF) 0: Empty 1 : Full L ___ - - - - - - - Transmit shift register shift completion flag 0 : Busy shifting I I 1 : Shifting complete I L ___ - - - - - - - - O v e r r u n error (OE) flag 0 : No overrun error 1 : Overrun error - - - - - - - - - - - - - P a r i t y error (PE) flag 0 : No parity error 1 : Parity error I ' - - - - - - - - - - - - - - - - F r a m i n g error (FE) flag 0 : No framing error 1 : Framing error L - - - - - - - - - - - - - - - - - - S u m m i n g error (SE) flag 0 : OE+PE+FE=O 1 : OE+PE+FE=1 •Bit 0 : Transmit buffer empty flag (TBE) This flag indicates the state of the transmit buffer. It is set to "1" when the data written in the transmit buffer is shifted to the transmit shift register. This flag is cleared automatically when the data is written into the transmit buffer. Also this flag is cleared when transmit enable bit is set to "O". •Bit 1 : Receive buffer full flag ( RBF) This flag shows the state of the receive buffer. It is set to "1" when all bits are completely shifted from the receive shift register to the receive buffer. This flag is cleared automatically when the receive buffer is read out. Also this flag is cleared when receive enable bit is set to "O". •Bit 2 : Transmit shift register shift completion flag (TSC) This bit is cleared to "O" when the data in the transmission buffer register is transferred to the transmit shift register and set to "1" when data shift completes. It is also set to "1" when TE=O. •Bit 3 : Overrun error flag (OE) When continuously receiving serial data, this bit is set when the next data fill the receive shift register before the data in the receive buffer register has been read. 47 FUNCTIONS •Bit 4 : Parity error flag (PE) When receiving serial data with parity, this bit is set to "1" if the parity of the received data dif- fers from the specified parity •Bit 5 : Framing error flag (FE) This bit is set to "1" when the stop bit of the receive data is not detected at the setting timing. This detects the only first bit, and does not check the second one. •Bit 6 : Summing error flag (SE) This bit is set when either overrun, a parity, or a framing error occurs. Tests for these errors are performed as soon as the data is transferred from the receive shift register to the receive buffer register and at the same time the receive buffer full flag is set. The error flags (OE, PE, FE and SE) are cleared when any data is written in the serial 1/0 status register. Also, all status flags including error flags are cleared when SIOE=O. [Receive shift register (RSR) and receive buffer (RB)] The receive shift register is the serial-parallel conversion register for data receive only. It consists of 8-bit and cannot be accessed directly. When all bits are received in the receive shift register, they are shifted to the receive buffer register( RB). Since there are a receive shift register and a receive buffer register, the M37450 can receive con- tinuously. (Receive-ready signal ( SRDY) generating circuit] M37450 has the capability to show outside that the serial 1/0 is receive-ready state by using the SRDY sig- nal. SRDY signal is enabled by setting bit 2 of the serial 1/0 control register ( SRDY output enable bit) to "1 ". If the SRDY output enable bit is "1" and a signal is written to the transmit/receive buffer register, the SRDY signal goes "L". At this point the CPU is in the" ready" condition. On the falling edge of_~~ first shift clock, the SRDY signal returns to "H" state. The transmit enable bit must be set to "1" when SRDY signal is used. This signal is not used in UART mode. [Transmit shift regester (TSR) and transmit buffer register(TB)] The transmit buffer register(TB) consists of 8-bit. When the data are written in this buffer register, they are transferred to the transmit shift register (TSR) and output at the TxD pin from the least significant bit of the data. Once the data in the transmit buffer is transferred to the transmit shift register, the transmit buffer can hold the next data to be transmitted during data transmission. 48 FUNCTIONS (3) Serial data receive operation (When the external clock is selected) In order to set-up the serial 1/0 receive mode, the serial 1/0 control register must be initialized a~J.()llow : the serial 1/0 enable bit must be set, the external clock must be selected, receive enable bit, SRov and transmit enable bit must be set. If the SRov signal is not used or the internal clock is selected for the syn- chronous clock, it is not necessary to be set the transmission enable bit. After clearing the receive interrupt request bit, the receive interrupt enable bit should be set. The SRov pin level changes from "H" to "L" by writing dummy data in the receive buffer register (OOE6 16 address). This signal tells to the transmission side that the M37450 is ready to receive serial data. The transmission side detects the "L" signal and starts transmission. · The M37450 statrts to receive the serial data with the shift clock from the transmission side. The SRov pin return to "H" at the falling edge of the first shift clock. The receive data input to the RxD pin is read into the receive shift register bit by bit at the rising edge of the shift clock. The receive data is shifted from the most significant bit of the receive shift register and shifted one bit at a time. After repeating this operation 8 times and receiving of 1 byte data in the receive shift register, the con- tents are shifted to the receive buffer. At this time, the receive buffer full flag is set and the receive inter- rupt request is generated. The receive buffer flag is cleared when the receive buffer register is read out. The receive interrupt request flag is automatically cleared when the receive interrupt is accepted. This flag can be also cleared by software. When the new receive data is shifted into the receive shift register before reading the last data in the receive buffer register, the over-run flag of the serial 1/0 status regis- ter is set. In this case, the data is retained in the receive shift register and not sent to receive buffer reg- ister. And also the data in the receive shift register is not sent to receive buffer register when the data in the receive buffer register is read out. The above is an example of serial 1/0 transfer using the external clock as, but the internal clock can also be used. When the external clock is selected since, the receive shift register continues to shift the data until the shift clock stops. Clock must stop after 8 shifts (the same thing applies in the case of the transmission). The clock starts by writing data into the transmit/receive buffer register when the internal clock is selected. RECEIVING MSB LSB 1f lilf I l l I I I I I I I I I 07 06 05 04 03 D2 D1 DO Shift clock Receive shift register Fig. 2.7.3 Serial 1/0 receiving operation 49 FUNCTIONS (4) Serial data transmit operation (when the internal clock is selected) In order to set-up the serial 1/0 transmit mode, the serial 1/0 control register must be initialized as fol- lows: serial 1/0 enable bit must be set, internal clock must be selected, transmit enable bit must be en- abled, and SRov output and receive enable bit must be disabled. After clearing the transmit interrupt request bit, the transmit interrupt enable bit must be set and data writ- ten into the transmit buffer. When the data written in the transmit buffer is transferred to the transmit shift register, the transmit buffer empty flag (TBE) is set that the transmit buffer is empty. If the transmit inter- rupt source selection bit is "O" , the transmit interrupt is generated simultaneously. At the point when the transmission buffer empty flag is set, it is possible to write new transmit data into the transmit buffer. The transmit buffer empty flag is automatically cleared when the data is written in the transmit buffer. When the internal clock is selected, the transmission clock, BRG output divided by 4, is input into the transmit shift register through ScLK pin. Data transmission starts at writing data into the transmit buffer. At this time, eight-shift clock generates. As soon as the transmission starts, the transmit shift register shift completion flag in the serial 1/0 status register is cleared to "O". When the transmit interrupt source selec- tion bit is "1", the transmit interrupt is generated at the completion of the transmission operation. TRANSMITTING MSB LSB I I I I I I I I D7 D6 05 D4 D3 D2 D1 DO 1f I I I I I I I I~DO 07 D6 D5 D4 D3 02 D1 I I I I I I D7 D6 D5 D4 D3 D2 l-7D1 I I I I I I~ 07 D6 05 04 03 02 l l Shift clock Transmit shift register Fig. 2.7.4 Serial 110 transmission operation 50 FUNCTIONS Internal clock ¢> Transmit/Receive clock Data Receive enable signal SRov IJ Write-signal for receive/transmit buffer register (address OOE6 16 ) Jl i TBE=O t TBE=1 t RBF=1 TSC=;O TSC=1 Check overrun error Note 1 : The transmit interrupt (Tl) selects TBE=1 when the transmit buffer is emptied (or TSC=1 when the transmit shift operation is complete) by the transmit interrupt source selection bit of the serial 1/0 control register. Note 2 : When the data is written in the transmit buffer register and TSC=O, the transmission clock is continuously generated and the serial data is continuously output from the TxD port. Note 3 : The receive interrupt (RI) is set when the receive buffer full flag (RBF) is "1". Note 4 : ScLK generates after 0.5-1.5 shift clock cycle from writing transmit data to transmit buffer register. Fig. 2.7.5 Clock synchronous serial 1/0 timing diagram (5) Examples of clock synchronous serial 1/0 connection TxD RxD TxD Rxo ScLK -- ScLK ScLK ScLK RxD TxD INT SAOY INT SRDY Fig. 2.7.6 Example of full duplex swap connection Fig. 2.7.7 Example of half duplex data communica- tion connection 51 FUNCTIONS 2.7.3 Clock asynchronous serial 1/0 (UART) (1) Summary M37450 has a built-in UART with the following features: Baud rate selection 312.5 kbps(max.) Data format selection Start bit 1 Data bit 7 or 8 Parity bit 0 or 1 Stop bit 1 or 2 Shift clock selection External clock input from ScLK or BRG/16 Error detection 4 types (overrun, parity, framing, summing) Error or no-error can recognized by the summing error bit only. Figure 2.7.8 shows the structure of the UART-form serial 1/0. Data bus Serial 110 control register address OOE8 16 address OOE61s RxD OE Receive buffer register t----.----- Receive buffer full flag (RBF) Receive interrupt request (RI) Receive shift register UART control register I SP detection I address OOE91 6 FE Clock control circuit ~--t------r-----r---- Serial 110 clock selection bit ScLK f(X,N) Baud rate generator address OOEA1s ST /SP/PA deletion I ~---~ Transmit shift completion flag (TSC) TE Character '--~--------' length .----..r---- TIC Transmit interrupt (Tl) selection bit >----------<~--- Transmit buffer empty flag (TBE) P3e P3s address OOE61e Serial 1/0 status register address OOE71 6 Data bus Fig. 2.7.8 UART block diagram 52 FUNCTIONS (2) Block explanations [Serial 110 control register] Serial 1/0 control register consists of 8-bit and Table 2.7.3 shows the bit structure of the serial 1/0 control register. All bits of the serial 1/0 control register can be read or written to the program. At reset this register is cleared to "00 16 " disabiling the serial 1/0 function. When the serial 1/0 enable bit is set to "1" , the functions of the ports P34 -P3 6 are shown as follows: P3 4 pin - Serial data input pin ( RxD) (When the receive function is not used, this pin can be used as a normal input/output port. ) P3 5 pin--+ Serial data output pin (TxD) (When the transmit function is not used, this pin can be used as a normal input/output port. ) P3 6 pin--+ Clock input/output pin (ScLK) (When the internal clock is used as the sampling clock, this pin can be used as a nomal input/output port.) Table 2.7.3 Bit structure of serial 1/0 control register b7 bO . ...,......_,__._,_ I . . . .,...-..._,_.__ _.__._____.I Serial 110 control register (address OOE8, 6) I I I I I L - - - - - BRG count source selection bit I I 0: f(X,N) divided by 2 I I 1 : f(X,N) divided by 8 I I I L ______ _ I Serial 1/0 synchronous clock selection bit I I I I 0 : BRG output I I I I 1 : External input clock I IL ________ _ I I SRov output enable bit I I 0 : P3 7 functions as normal 1/0 pin I I I 1 : P37 function changes to SRoY output pin IL _ _ _ _ _ _ _ _ _ _ I I Transmit interrupt sorce selection bit I I I 0 : Transmit buffer is empty I I 1 : Transmission shift operation is complete I I I L ___ -- - - - - - - - - Transmit enable bit I I 0 : Transmit disable I I I I 1 : Transmit enable I L - - - - - - - - - - - - -- Receive enable bit I 0 : Receive disable I I 1 : Receive enable I Serial 1/0 mode selection bit I 0: UART I I 1 : Clocked serial 1/0 L _____ - - - - - - - - - - - - - Serial 1/0 enable bit 0 : Serial 1/0 disable (Pins P34 -P3 7 are normal 1/0 ports) 1 : Serial 1/0 enable (Pins P34 -P37 function as serial 1/0 pins) 53 FUNCTIONS [Serial 1/0 status register] The serial 1/0 status register is a read-only register consisting of 7 flags showing which show the state of the transmit/recive of the serial 1/0. At reset, this register is initialized to "00 16" , but is set to "05 16" when the transmit enable bit of the serial 1/0 control register is set to "1" (enable) . The flags designated by bits 4-6 are only valid in the UART mode. Table 2.7.4 Bit structure of serial 1/0 status register b? bO I- I ~~...,....~,.........---,.~~1~-,-~~1~-1 I ......... Serial 1/0 status register (address OOE7 16 ) I I L __ - - - Transmit buffer empty flag (TBE) I I 0: Full I I I I 1: Empty I I I L _______ Receive buffer full flag (RBF) I o:empty I 1 : Full I I I L ____ - - - - - Transmit shift register shift completion flag I 0 : Busy shifting I 1 : Shifting complete I I L - - - - - - - -----Overrun error (OE) flag 0 : No overrun error 1 : Overrun error - - - - - - - - - - - - - - - P a r i t y error (PE) flag I 0 : No parity error I 1 : Parity error I I I L - - - - - - - - - - - - - - - - - F r a m i n g error (FE) flag I 0 : No framing error I I 1 : Framing error I L - - - - - - - - - - - - - - - - - - - Summing error (SE) flag 0: OE+PE+FE=O 1 : OE+PE+FE=1 54 FUNCTIONS [UART control register] UART control register defines the UART's formats. This register can be read or written by software (see Table 2.7.5) . By setting the UART control register, 8 types of the serial data transfer formats can be selected (see. Table 2.7.6) . Table 2.7.5 Bit structure of UART control register Table 2.7.6 Correspondence between UARTCON and data format bl bO I - I -1- J - I ~~~~~~,l~,_.....~1~,.I I UART control register (address OOE9 16 ) b3 b2 b1 bO Serial data transfer format I I L _ - - - Character length selection bit 0 x 0 0 1ST-8DATA-1SP : I o, a bits 0 x 0 1 I I 1 : 7 bits I I 0 x 0 1ST-8DATA-1 PAR-1 SP I L _ _ _ _ _ _ _ Parityenablebit 0 x 1ST-7DATA-1 PAR-1 SP I 0: No parity 1 ·--- x 0 0 1ST-8DA T A-2SP I 1 : Parity enable -- I 1 x 0 1 1ST-7DATA-2SP I L __ - - - - - - -· - Parity selection bit x-- 0 1ST-8DATA-1PAR-2SP I I 0 : Even parity x 1ST-?DATA-1 PAR-2SP 1 : Odd parity I ST : Start bit I ' - - - - - - - - - - - - - S t o p bit length selection bit DATA : Serial data 0 · 1 stop bit SP: Stop bit 1 . 2 stop bits PAR : Parity bit (1)(1,8,0, 1) : 1 start bit+ 8 data bit+ 1 stop bit (2)( 1,7,0,1) : 1 start bit+ 7 data bit+ 1 stop bit (3)( 1,8, 1, 1) : 1 start bit+ 8 data bit+ 1 parity bit+ 1 stop bit (4)(1,7,1,1): 1 start bit+ 7 data bit+ 1 parity bit+ 1 stop bit (5)( 1,8,0,2) : 1 start bit+ 8 data bit+ 2 stop bit SP SP (6)( 1,7,0,2) : 1 start bit+ 7 data bit+ 2 stop bit SP SP ( 7)( 1,8, 1,2) : 1 start bit + 8 data bit + 1 parity bit+ 2 stop bit SP SP (8)(1,7,1,2): 1 startbit+7databit+1 paritybit+2stop bit SP SP Fig. 2.7.9 The communication data format for UART 55 FUNCTIONS [Receive shift register ( RSR) and receive buffer (RB)] The basic operation of the receive shift register and the receive buffer is the same as in the clock syn- chronous serial 1/0. However, the shift clock supplied to the receive shift register is either the external clock (input from ScLK pin) or the BRG clock divided by 16. The examination of the start bit consists of testing the center level of the start bit after the first falling edge of RxD input. If this level is high, the bit is ignored as noise, but if the bit level is low, the bit is recognized as a normal start bit and the CPU starts receiving data. The character bit length can be selected as either 8-bit or 7-bit by bit 0 of the UART control register. When 7-bit mode is selected, the most significant bit in the receive buffer register is set to "O" . The over-run error flag OE operates in the same manner as in clock synchronous mode but there are other flags such as: parity error bit (PE) , framing error bit (FE) and the summing error bit (SE) which is the result of the logical sum of OE,PE, and FE bits. These four error flags are bit 3~6 of the serial 1/0 sta- tus register and are cleared when the receive enable bit is cleared or dummy data is written into the se- rial 1/0 status register. [Transmit shift register (TSR) and transmit buffer (TB)] The basic operation of the transmit shift register and the transmit buffer is also the same as in the clock synchronous mode. The data is transmitted from TxD pin. Bit 3 of the UART control register selects the stop bit length as either 1 or 2 bits. Parity is created by hardware and set by bits 1 and 2 of the UART control register. When bit 1 of the UART control register is "O" meaning non-parity mode, the parity bit is not generated. Data transmission begins by writing data into the transmit buffer after setting the transmit enable bit. [Clock generating circuit] Table 2.7.7. shows the baud rate selection list when UART is selected. Table 2.7.7 Baud rate selection chart I Baud rate at Baud rate (bps) BRG count source I BRG value f(X,N)~lOMHz - l 300 l(X,N)/8 255( FF15) 305. 17578 f--· 600 f(X,N)/8 i 127( ?F15) 610. 35156 1200 f(X,N)/8 63(3F 16 ) 1220. 7031 r--------2400 f(X,N)/8 31 (1 F 16 ) 2441. 4063 4800 l(X,N)/8 15(0F16J 4882. 8125 -- 9600 f(X,N)/8 j 7(0716) 9765. 625 --- ~N)/8 19200 I 3(0315) 19531. 25 38400 !(X,N)/8 1 (0115) 39062. 5 76800 f(X,N)/2 3(0316) 78125 153600 f(X,N)/2 l(011sl 156250 !-· 307200 f(X,N)/2 0(0015) 312500 56 FUNCTIONS (3) UART receive operation In order the UART to receive data an initialization sequence must be followed. After selecting the clock source and serial 1/0 mode, bit 1 and 6 of serial 1/0 control register respectively, serial 1/0 enable bit must be set to "1" . By writing dummy data into the serial 1/0 status register, it will be initialized to "00 16 " . Lastly the data format must be set in the UART control register. After the receive enable bit of the serial 1/0 control register is set, the M37 450 is ready to receive the data. Once the start bit is recognized, receiving action will begin. When the first stop bit is recognized, the re- ceive buffer full flag is set and the receive interrupt request is generated. If there is an error in the re- ceiving operation, the error flag will be set at this time. (4) UART transmission operation In order the UART to transmit data an initialization sequence must be followed. After selecting the clock source and the serial 1/0 mode, bit 1 and 6 of serial 1/0 control register respectively, serial 1/0 enable bit must be set to "1" . By writing data into the serial 1/0 status register, it will be initialized to "00 16 " . Lastly the data format must be set in the UART control register. The shift clock is generated by writing the transmission data into the transmit buffer register after the transmit enable bit of the serial 1/0 control register is set to enable. At this time the transmission shift reg- ister shift completion flag is cleared to "O" and the transmit buffer empty flag is set to "1" . The next trans- mission data can be written into the transmission buffer. The transmit interrupt selection bit of the serial I/ 0 control register can select the transmit interrupt timing. If the selection bit is "O", the transmit interrupt occurs when the transmit buffer empty flag becomes "1". If the selection bit is "1", the transmit interrupt occurs when the transmit shift register shift completion flag becomes "1" . (The shift completion flag is set by the second stop bit when the stop bit length is chosen to be 2 at 2 stop bits. UART timing diagram is shown in Figure 2.7.10. Transmit buffer register write signal _J1___J1_ ________ "- TBE=O "'-rnE=O TSC=1 )t"TSC=O, TBE=1 /TBE=1 ~~~~~~~~--~ ~-----1 start bit _ _ _ ___,_, If the 2 stop-bit mode 7 or 8 data bit is selected, TSC is set 1 or 0 parit'. ~it n at the 2nd stop bit. Receive buffer 1or2sto~L__ I register read signal ---------.------- /RBF=1 "-RBF=O____ :,sF=1 Serial input ( RxD) ~~~:~~~~~~~ Note 1 : The error flag are detected at the same time RBF flag setting (RBF=1, at the first stop bit in data receiving mode.). Note 2 : The transmit interrupt is programmed to interrupt at either transmit buffer being empty (TBE=1) or the transmit being completed (TSC=1 ). Note 3 : The receive interrupt is generated by RBF=1. Fig. 2.7.10 UART data transmit/receive timing 57 FUNCTIONS 2.8 Bus interface The slave microcomputer is defined as the processor which operates by the master processor's instruc- tion. The M37450 has a built-in bus interface which the master processor can directly access through its data bus. This bus interface allows the master CPU to access the M37450 without any special hardware or pro- tocol. The master CPU can handle the slave M37450 the same as a standard peripheral LSI. r--- - - --- ---- - ---- ---- ---, I I I I I I I I I I 15 I Master CPU Data bus ~ Data bus Slave CPU I E I ~ I I I I I I L------------------------~ M37 450M 2-XXXSP/FP Fig. 2.8.1 Bus interface summary chart 58 FUNCTIONS 2.8.1 Bus interface function M37450 has the following built-in bus interface features: • 8-bit data bus •Data bus buffer ( 1-le~I common with input and output) •Direct connection to "R and W separation" or "R/W" type bus architecture •Output the input/output buffer condition on the data bus buffer Figure 2.8.2 shows the block diagram of the bus interface circuit. Internal data bus RD WR DBB DBBSTS P5 0 /DBo Input data bus buffer P5 1/DB 1 P5 2 /DB 2 "' P53/0B3 " .0 "' (;j "O P54 /DB 4 ~ P5s/DBs :c Output data bus buffer P5s/DBs P5 7 /DB 7 P6 7/W PS.JR P65 /CS P64 /AO P63/PRDY v - - - - - - - - - - - - - - - - - - - - - - - - - - ( l ( Fig. 2.8.2 Bus interface circuit block diagram 59 FUNCTIONS 2.8.2 Block explanation (1) Bus interface enable bit ( DBBE) If the bus interface enable bit, bit 2 of MISRG2 (address OODF 16 ) , is set to "1" , port PS and the part of port P6 change their functions as shown in Table 2.8.1. (2) Bus interface mode selection bit ( DBBM) Bus interface mod~ selection bit, bit 3 of MISRG2, defines t~bus interface function type. If the bit is set to "O" , the bus is~ and W separation type with separated RD or WR signals. If the bit is set to "1 ", the bus interface is R/W type with multiplexed R/W signals. (3) Input data bus buffer (DBBIN) This buffer is a single level buffer used to store the input from the master CPU data bus (port PS) . When the logical sum of CS and W is "O" , the data bus condition (at the rising edge of the W) is latched into the input data bus buffer (DBBIN). At the same time, the input buffer full flag (IBF) which is in bit 1 of the data bus buffer status register ( DBBSTS) , is set to "1" . Then, the input buffer full interrupt request is generated and bit O of the interrupt request register 1 (address OOFC 16 ) is set to "1" . Also in this timing, the AO status is copied to bit 3 of the data bus status register. The status of this bit shows whether the content of the data bus buffer is data or a command. The input buffer full flag is cleared to "O" automati- cally by reading the input data bus buffer. Table 2.8.1 Functions of bus interface enable bit DBBE "O", disable "1 ", enable ~~ I Port --·--- I --- -- ! - RD and WR !--·-------·- DBBM "O" separation type l1" I R/W type -------- Ports P5 0 - P57 1/0 port ~ystem data bus DBO~DB? t---------- ·!------------ --· 1---· Ports P6 3 1/0 port PRoY output pin r----- 1 - Ports P64 110 port Ao input pin - - - - - - + - = - - - - - - - - - - - - - - -.. Ports P6 5 Ports P6 6 1/0 port 1/0 port --- CS input pin - RD input pin I E signal input pin ---~---~ I . 1---- Ports P6 7 1/0 port WR input pin TR/W input pin Master CPU M37450 Master CPU M37450 0 0 ....._,0 7 P5 0 -P5 7 Do-D, P5 0 ........ P51 - RD P6 6 E P6 6 - ·- WR P6 7 R/W -"'" P6 7 R and W separation type system bus R/W type system bus Fig. 2.8.3 Bus connection block diagram 60 FUNCTIONS (4) Output data bus buffer (DBBOUT) This buffer is a single level buffer, used to store the output to the master CPU data bus (port P5) . When data is written to the output data buffer (address OOE4 16 ) , the output buffer full flag (OBF) , bit 0 of the data bus status register, is set to "1 ". When the logical sum of CS, R, and AO is "O" (see Table 2.8.2 CD condition) , !_Ile contents of the output data bus buffer is output to the master CPU data bus. At the rising edge of the R signal, the output buffer full flag is cleared to "O", the output buffer empty interrupt request is generated and the output buffer empty interrupt request flag (bit 1 of address OOFC 16 ) is set to "1 ". The input data bus buffer and the out- put data bus buffer are in the same address, and data can be read from the DBB 1N and write to DBBOUT. (5) Data bus buffer status and user definable flag ( DBBSTS) The data bus buffer status register, address OOE5 16 , houses data bus status flags and user definable flags. Bits 0, 1, and 3 are flags output buffer full flag, input buffer full flag, ( IBF) , and address input (AO) flags respectively. These bits can not be set or clear by program. The other bits are user definable flags that can be set or clear by program. The AO flag indicates where the data is actual data or a command; "O" meaning data and "1" meaning command. The content of the data bus status register is output to the data bus when the logical sum of CS and R is "O" and AO is "1" (see the condition CZ) in the Table 2.8.2). The logical sum of OBF and IBF is defined as the PRov signal (parallel ready) if bus interface used, this signal is output from P6 3 . This signal acts as a request to the master CPU for data receiving or transmis- sion. The master CPU cannot write to the data bus status register but it can read from it. On the other hand, the slave processor can read out from this register and write to bit U7, U6, U5, U4, and U2 in this register. The data bus status register is initialized to "01 16" at reset. In order to complete the initialization process of the data bus status register, bus interface enable bit ( DBBE) must be set to "1" , which causes the out- put buffer full flag to be cleared to "O" . At the same time that the output buffer full flag is cleared to "O" , the output buffer empty interrupt request is generated. Data to be sent should be written to the DBBOUT after IBF is set to "1", because PRov does not change to "H" when IBF="O". Table 2.8.2 Bus control signal and data bus status Table 2.8.3 Bus control signal and data bus status (RD, WR separation type) (R/W type) cs R w AO Data bus status Data on data bus cs R/W E AO Data bus status Data on data bus 0 0 1 0 Read DBBOUT 0 1 1 0 Read DBBOUT 0 0 1 1 Read DBBSTS 0 1 1 1 Read DBBSTS 0 1 0 0 Write DBBIN (data) 0 0 1 0 Write DBBIN (data) 0 1 0 1 Write DBBIN (command) 0 0 1 1 Write DBBIN (command) 0 x x x High impedance - 1 x x x High impedance - 61 FUNCTIONS Table 2.8.4 Structure of registers related to bus interface b7 bO ......._._.,.........._,._._~....,._._~....,._._..,......JI MISRG2 (address OODF 16 ) I 1 i i I L - --'- - - - - - Processor mode I I b1 bO I I 0 0 : Single-chip mode I I 0 : Memory expanding mode I I 0 : Microprocessor mode I I : Inhibit I I I L _______ _ Bus interlace enable bit (DBBE) I 0: Disable I 1 : Enable I I L _________ _ I Bus interlace mode selection bit (DBBM) I 0: RD, WR bus I I 1 : R/W bus I I L ___________ _ I PWM enable bit I 0: Disable I 1 : Enable L - - - - - - - -· - - - - - PWM mode selection bit 0 : 8-bit high speed PWM 1 : 16-bit high precision PWM L - - - - - - - - - - - - - - Bus cycle control bit 0 : Normal bus cycle 1 : Normal bus cycle X 2 L ____________ _ Stack page selection bit 0 : 0 page area 1 : 1 page area b7 bO ................................................... I -.-.................. ..... Data bus buffer status register (address OOE5 16 ) ~ I L - - - - - Output buffer full flag ( OBF) 0: Empty I I 1 : Full I I I I I L - - - - ---Input buffer full flag (IBF) I 0: Empty I I I 1 : Full I I I I L - - - - - ----User difinable flag (U2) I I User may define this flag I I I L_ - - - - - - - - - - A O flag (AO) I Indicates AO status flag when IBF flag is set I I I L _ _l _ _j_ _ _l - - - - - - - - - ----User dilnable flag (U4-U7) User may define this flag 62 FUNCTIONS 2.8.3 The use of bus interface Figure 2.8.3 shows an example of the bus interface connection. Master CPU Slave CPU Address bus 8 e r - - - - - - - - - - P65 /CS Decoder RD t--------------~ P66 /R WR t - - - - - - - - - - - - - - - - o ; . i P67 /W AO t - - - - - - - - - - - - - - - - 1 P6 4 /AO 8 D,-D, ~---D-a-ta_b_u_s- - - + - - - - - - . : : , . . 1 P5,-P5, M37450 Fig. 2.8.3 Example of connection with the master CPU (1) Initialization The bus interface function is accessed by setting the bus interface enable bit in the M37450. However, the master processor needs to know that the slave processor is ready to be accessed. The PRov which is common with P6 3 pin is output as "O'' for telling the master processor that the slave processor is ready. After reset sequence, PRov pin will be in input mode (high impedance), this pin must be pulled-up. START NO YES Fig. 2.8.4 Slave initialization routine (master side) 63 FUNCTIONS / OBE interrupt / IBF interrupt Receiving Transmission IBF interrupt request flag OBE interrupt request flag is cleared automatically is cleared automatically DBBSTS read-out DBBOUT write-in NO OBF flag is set DBBIN (command) read-out DBBIN (data) read-out Clear IBF Fig. 2.8.5 Example of the slave side transmit/receive software / PRov interrupt Transmit/Receive Read out odd address YES Receiving process Transmission process NO YES Write command into Write data into even address Read even address odd address Note : In the connection example in Figure 2.8.3, the slave-side AO status input is connected to the master-side address signal (AO) . The data or command can be distinguished by selecting even or odd address. Fig. 2.8.6 Example of the host-side tra it/receive software 64 FUNCTIONS 2.9 A-D converter M37450 has a built-in A-D converter with the features shown below. Analog input pin --8channels(80-pin model) (common with P4) 3channels(64-pin model) Architecture --Successive approximation A-D conversion circuit with a multiplexer Resolution --8-bit Absolute precision -±3LSB Conversion speed --19.Bµs (when f(X 1N)=10MHz) The block diagram of A-D converter is shown in Figure 2.9.1. Data bus A-D control register (address OOE3, 6 ) A-D control circuit A-D interrupt request P4 1/AN 1 A-D register (address OOE2 16 ) P43/AN3 P44/AN4 P45 /ANs P4,,/ANo P47 /AN 7 A Vee Fig. 2.9.1 A-D converter block diagram 65 FUNCTIONS 2.9.1 Block explanations The function of each block of the A-D converter is explained below. (1) A-D register This is a read-only register where the result of A-D conversion is stored. The content of this register should not be read out during the A-D conversion. (2) A-0 control register This register is to select the analog input pin. The value of the three least significant bits choses among AN 0 -AN 7 . The other analog input pins which are not used for A-D conversion can be used as normal port. Once the data is written to this register, A-D conversion will begin. In the 64-pin model there is only three analog input ports AN 0 -AN 2 , therefore the value of this register must be from 0-2. At reset, this register is undefined. (3) Comparator and control circuit The analog input voltage and the reference voltage are compared and the result is stored in the A-D reg- ister. The A-D interrupt request bit ( bit5 of address OOFD 16 ) is set to "1" at the completion of A-D conversion. The comparator consists of capacitance coupling so that f(X 1N) should be 1MHz or more during the A-D conversion. Table 2.9.1 A-D control register bit structure b7 bO __l._-__.l._-__.l._-__.l~_._.,.__.....,._,I A-D control register (address OOE3 l._-__l._- 16 ) ~~-~-- Analog input pin selection bit b2 b1 bO 0 0 : ANo 0 1 : AN 1 1 0 : AN2 0 1 1 : AN3 1 0 0 : AN4 1 0 1 : AN 5 1 0 : ANs 1 : AN 7 Note : In the 64-pin model, only bits AN 0 -AN 2 are selected. 66 FUNCTIONS 2.9.2 Internal operation during A-D conversion The A-D conversion starts by writing data into the A-D control register. When A-D conversion starts, the A- D register is cleared to "00 16 ". Next, the most significant bit of the A-D register is set to "1" and the com- parative voltage Vref is input in the comparator. Here the analog input voltage V1N is compared with Vref. If Vref< V1N, the bit is not cleared. If Vref>V1N. the bit is cleared to "O". By repeating this operation until the lowest bit of the A-D register, the analog value is converted to the digital value. At 198 clock cycles (when f(X 1N)=10MHz, 19.8µs) after the start of the A-D conversion, the conversion is completed and the result of conversion is stored in the A-D register. At the same time the A-D interrupt request is generated and the A-D interrupt request bit (bit 5 of address OOFD 16 ) is set to "1". ADVREF is VREF in the 64 pin model. Relational formula between Vref and ADVREF (80-pin model) ADV REF* Vref 256 X(n-0.5) at n=1~255 at n=O *VREF in the 64-pin model Table 2.9.2 Register contents in the A-D conversion process Change in A-0 register Comparative voltage At start of conversion I 0 I 0 I 0 I 0 I 0 I 0 I 0 I 0 I 0 1st ADV REF ADV REF comparison I 1 I 0 I 0 I 0 I 0 I 0 I 0 I 0 I --2- - ---s12 2nd I 1st I 1 I 0 I 0 I 0 I 0 I 0 I o. I ADVREF + ADVREF - - ADVREF comparison 2 4 512 "-..__The result of the 1st conversion 3rd ADVREF + ADVR_g_ + ADVREF - ADVREF comparison I 1st j 2nd j 1 I 0 I 0 I 0 I 0 I 0 I 2 - 4 - 8 512 A-D conversion result After 8th completion I 1st I 2nd I 3rd I 4th I sth I 6th I 7th I 8th I Note : ADVREF is VREF in the 64-pin model 67 FUNCTIONS 2.9.3 A-D conversion method The method for A-D conversion is explained below. (1) Clear the A-D interrupt request bit (bit 5) of the interrupt request register 2. (2) When the A-D interrupt is used, set the A-D interrupt enable bit to "1" and clear the interrupt disable flag to "O". (3) Select the analog input by the analog input selection bit of the A-D control register. A-D conversion begins by this write operation, (do not read the content of the A-D register during A-D conversion). (4) Confirm completion of conversion by checking the A-D interrupt request bit or the A-D interrupt. (5) The result of the conversion is obtained by reading out the A-D register. In case of not using the interrupt process the A-D interrupt request bit is not cleared to "O" automatically. It must be cleared to "O" before A-D conversion. At reset, this bit is reset to "O". 68 FUNCTIONS 2.9.4 A-D converter circuit Figure 2.9.2 shows the A-D converter circuit and Figure 2.9.3 shows the A-D conversion timing chart. Vee Vss AVcc AVss A No Sample clock r ___ l __ L_ ___ , AN 1 AN2 V1N AN3 IL __________ JI AN4 ANs Chopper Amp. ANs AN 7 A-D control register Reference clock ADV REF ---t~ \I Built-in DAG AVss A-D coversion complete interrupt A-D register Fig. 2.9.2 A-D converter equivalent circuit Write signal to the A-D control register l-E-----------------49 cycle--------------- A-D conversion completion flag _ _ ____.I Sampling clock ___.n___ Fig. 2.9.3 A-D conversion timing chart 69 FUNCTIONS 2.9.5 Measuring method of each standard of the A-D converter (1) Absolute precision The difference between the result code through a real A-D converter and one of a ideal featured A-D converter is indicated by LSB (least significant bit) unit. The measured input voltage is determined at center point of the output voltage output by the ideal A-D converter. For example, when ADV REF= 5.12V, 1 LSB width is 20mV and OmV, 20mV, 40mV, and 60 mV ... are selected as the input voltages. The range of actual input voltage is form AVss to ADVREF· When using the ADVREF lower than AVcc, the output code of input voltage becomes "FF 16 " from ADVREF to AVcc, but the precision becomes worse. The absolute precision of ±3 LSB means that, the input voltage at 100mV, the output code obtained by the ideal A-D converter is 05 16 indicating the range of 02 16 -08 16 . The range of the input voltage is AVss - ADV REF· If the lower ADV REF is used, the absolute precision shown by LSB becomes poor. The absolute precision includes zero error and the full-scale error. HEX BIN 0816 00001011 OA16 00001010 0915 00001001 0816 00001000 -------------- +3LSB 0716 00000111 Cll 'O 0615 00000110 0 '-' Ideal 8-bit A-D converter's :; characteristic Q. :; 0516 00000101 0 0415 00000100 0316 00000011 0216 0000001 0 -3LSB 0116 00000001 0016 00000000 0 20 40 60 80 100 1 20 140 160 180 200 220 Input voltage (mV) Fig. 2.9.4 A-D converter absolute precision 70 FUNCTIONS (2) Differential non-linearity Differential non-linearity shows the difference between the step width of 1 LSB of the ideal A-D converter and the measured step width. For example, when ADVReF=5.12V, 1LSB is 20mV. Here the maximum dif- ferential non-linearity deviation is ± 1LSB, that means the step width of the input voltage which gets the same output c.ode is in the range 0-40mV. HEX BIN 0816 00001011 OA 16 00001010 0916 00001001 1LSB 0815 00001000 ~ I I I I 07 16 00000111 I r+----' I I 0616 00000110 13) 'C 1LSB 0 " 05 16 00000101 '5 Differencial non-linearity Ee :::J 1LSB 0 0416 00000100 0315 00000011 0216 00000010 01 16 00000001 0016 00000000 0 20 40 60 80 100 120 140 160 180 200 220 Input voltage (mV) Fig. 2.9.5 A-D converter absolute precision Note : Each port of M37450 has a built-in protective circuit for the static electricity, but each analog-type port (AVcc. AVss. ADVR••· DAVR••· VREF• D-A,, D-A 2 ) are not on the same protective level; caution regarding the static electricity is necessary when handling. 71 FUNCTIONS 2.10 D-A converter M37450 has a built-in 0-A converter with features shown below. Analog output pin --2-channel Architecture --R-2R type Resolution --8-bit The block diagram of 0-A converter is shown in Figure 2.10.1. By writing the data to the 0-A register, the voltage between DAVREF and AVss corresponding to the con- tents of the 0-A register is output from the 0-A pin. ( D-A1 register corresponds with D-A1 pin; D-A 2 regis- ter corresponds with D-A 2 pin.) The relationship between the output voltage and the D-A register's value is as follows (80-pin model). V=DAVREF x n/256 (n=0~255) V; Output voltage DAVREF; Reference voltage (DAVREF is VREF in 64-pin model) n; 0-A conversion register value( Decimal representation) Since both D-A 1 and D-A 2 registers are cleared to "00 16 " at reset, the output voltage from D-A 1 and D-A 2 is OV after reset. The equivalent circuit of 0-A converter is shown in Figure 2.10.2. Both D-A 1 and D-A 2 have the same structure and output an un-buffered voltage. The resistor ladder is directly connected to D-Ai pin. so buf- fer amplifer is need to output current. Data bus D-A register D-A pin Fig. 2.10.1 D-A converter block diagram R R R R R R R R D-Ai 2R D-Ai register AVss DAV* REF This combination outputs a voltage corresponding to "C0 16" in the D-Ai register. *DAVREF pin corresponds to VREF pin in the 64-pin model Fig. 2.10.2 D-A converter equivalent circuit 72 FUNCTIONS 2.11 PWM M37450 has a built-in PWM generator with two modes which are software selectable. (1) High speed mode (Resolution 8-bit) Period ~z~:~ (fixed period) (at f(X1N)=10MHz) (2) High resolution mode (Resolution 16-bit) Period 6~z~~N~ 2 (fixed period) (at f(X1N)=10MHz) The structure of PWM generator is shown in Figure 2.11.1 Data bus PWM enable bit 8/16 selection Fig. 2.11.1 PWM block diagram 73 FUNCTIONS 2.11.1 Block explanations (1) PWM enable bit, PWM mode selection bit PWM enable bit and PWM mode selection bit are bit 4 and bit 5 of MISRG2 respectively. PWM enable bit controls the connection of count clock to the PWM generator. The PWM generator oper- ates when this bit is "1 ". PWM mode selection bit selects the PWM operation mode. When PWM mode selection bit is "O", the 8- bit high speed mode is selected. When it is "1 ", the 16-bit high resolution mode is selected. Since MISRG2 is initialized to "00 16 " at reset, the PWM generator is disabled at reset. (2) PWM register PWM register is made up of two 8-bit registers of PWMH and PWML. By setting a value to this register, the pulse width corresponding with the contents of this register is generated. (3) PWMouT pin To use P3 3 /PWMouT pin as PWMouT pin, the directional register for P3 3 pin must be set in the output condition (bit3 of address 0007 16 ). Then by setting the PWM enable bit to "1", the enable condition, P3 3 pin becomes PWMouT automatically. Table 2.11.1 PWM related register b7 bO MISRG2 (address OODF1sl i I I I L--1------ Processor mode bit I b1 bO I O O : Single-chip mode I 0 1 : Memory expanding mode I 1 O : Microprocessor mode I IL 1 1 : Inhibit Bus interface enable bit 0: Disable 1 : Enable L_ _ _ _ _ _ _ _ _ _ _ Bus interface mode bit 0: RD, WR bus I 1 : R/W bus I I L ___________ _ PWM enable bit I I I 0: Disable I IL _ _ _ _ _ _ _ _ _ _ _ _ _ 1 : Enable I I PWM mode selection bit I I 0 : 8-bit high speed PWM I I L- - - - - - - - - - - - - - 1 : 16-bit high resolution PWM Bus cycle control bit I 0 : Normal bus cycle I 1 : Normal bus cycle X2 L _ - - - - - - - - - - - - --- Stack page selection bit 0 : o page area 1 : 1 page area 74 FUNCTIONS 2.11.2 Explanation of the PWM operation PWM output starts by writing data into the PWM register and the PWM enable bit is set to "1". PWM out- put in each mode is explained below. L---!I 51µs (fixed cycle) I (1) High speed PWM mode This mode is selected by writing "O" in the PWM mode selection bit. In this mode, the "H" output period on the PWM pin is determined by the value m (m=0-255) written in the PWML register. m=O "L" m=1 m=2 m=3 L "H" I T=51µs (f(X,N)=10MHz) Note: m=PWM register contents. Fig. 2.11.2 Relationship between the PWM register value and the PWM output 75 FUNCTIONS (2) High resolution PWM mode This mode is selected by writing "1" in the PWM mode selection bit. In this mode, the "H" output period on the PWM pin is determined by the value m (m=0-65535) in the PWMH and PWML registers. To change all 16 bits during the PWM output period, the value of the PWMH must be changed first, then the value of PWML· In order to change the lower 8 bits only, the new value can be written into the PWML without rewriting the value to PWMH. In order to change only the upper 8 bits, the new value must be writ- ten to the PWMH, the value of PWML must be read out and the same value must be rewritten into PWML register. This must be done since the write action to PWML signifies the completion of the write cycle to the PWM register. When the value of the PWM register is changed during both high speed and high resolution PWM modes, the output changes(B) after PWM cycle (A) is completed. 13.107Xm I 65565 ms I '"" "' PWM output 13.107ms (fixed cycle) A B I I ""'~-"'J I I II I T T T Fig. 2.11.3 PWM output renewal 76 FUNCTIONS 2.12 Multiplier/Divider unit M37450 has a built-in hardware multiplier/divider unit with the featrues shown below. Multiplier 8-bitX8-bit 6µs (at the clock frequency 10MHz) Divider 16-bit+8-bit 6.4µs (at the clock frequency 10MHz) In M37450 with the built-in multiplier/divider unit, the multiplication/division instructions have been estab- lished in addition to the 69 basic instructions in the conventional series MELPS 740. These instructions are explained below. 2.12.1 Multiplication instruction (MUL) Table 2.12.1 shows the functions of the MUL instruction. Table 2.12.1 Multiplication·instruction MUL (MULtiply accumulator and memory) Function: M(S) •(A) - (A)XM(ZZ+X) (S)-(S)-1 Explanation : Multiplies accumulator with the memory specified by zero page X addressing mode and stores the high byte of the result on the stack and the low byte in the accumulator. Status flag : No change Register: Accumulator changes (S)-(S)-1 No change in the state of the other registers I Zero page I ""'"'"~'" ~ x (A) Multiplier I I j +~ -r--- ~~;-- -r-----,:----11 I : L - - - : - - - - H i g h - - - - f - - - - Low _____ _J I I Addressing mode Mnemonic Machine code Byte number Cycle number Zero page, X MUL $ZZ,X 62, •• zz,. 2 15 Note : When this instruction is executed, the contents of the accumulator and the stack pointer will change. 77 FUNCTIONS 2.12.2 Division instruction Table 2.12.2 shows the functions of the division instruction. In the division instruction of the M37 450, for there is no check for a divide by "O" or for a quotient exceed- ing 8 bits. Caution must also be paid to the remainder since it is 1's complement. Precautions can be taken as shown in Figure 2.12.1. Table 2.12.2 Division instruction DIV (DIVide memory by accumulator) Function: (A) - (M(zz+x+1), M(zz+x) )/(A) M(S) -1·s complement of remainder. (S)-(S)-1 Explanation : Divides by acumulator the 16-bit data that is the cotents of M(ZZ+x+1) for high byte and contents of the next address memory for low byte, and stores the quotient in the accumulator and the remainder on the stack as 1's complement. Status flag : No change Register: Accumulator changes (S)-(S)-1 No change in the state of the other registers Zero page Dividend (lower) M(ZZ+X) (A) Divisor Dividend (higher) M(zz+x+1) j 1's complement M(S) (A) Quotient of remainder ~ Addressing mode Mnemonic Machine code Byte number Cycle number Zero page, X DIV $ZZ,X E21s. ZZ10 2 16 I Note : The instruction does not check for an overflow of the quotient or zero division. A software check ls necessary before the DIV in- struction. The contents of the accumulator and the stack pointer will change. 78 FUNCTIONS Division YES YES _;~----3> Overflow procedure Execute DIV instruction Quotient get The complement of the remainder will be returned to the accumulator from PLA instruction the stack. (see note below) (A)~ (A)EOR $FF Real remainder calculated Note : When the division instruction is executed, the stack pointer changes. Therefore if a stack pointer manipulation Is used such as a PLA instruction, it must be executed after the question is obtained even if the remainder is not used. Fig. 2.12.1 Data processing before DIV instruction 79 RESET CIRCUIT 3. RESET CIRCUIT 3.1 Reset operation When the M37450 is supplied 5V±10% and RESET pin is in "L" level more than 8 ¢clocks, the M37450 is reset. If more time is needed for the crystal oscillator to stabilize, this "L" condition should be maintained for the reguired time. When the RESET pin becomes high, the sequence shown in Figure 3.1.1 starts. The program will start at the address indicated by the RESET vector, address, FFFE16 and FFFF 16 . SYNC Address RESET address Data from vector table B-12 clock cycle Note 1 : Clock output signal, ¢>, is f(X1") divided by 4. 2 : The mark "?" indicates an undefined address. Fig. 3.1.1 Timing diagram at reset 80 RESET CIRCUIT 3.2 Internal condition of microcomputer after reset Figures 3.2.1 and 3.2.2 shows the internal state following reset. Address Register contents Port PO directional register 000116 0015 Port P1 directional register 000316 oo,. Port P2 directional register 000515 Port P3 directional register 000715 oo;. Port P5 directional register OODB 16 oo,. Port P6 directional register OODD15 oo,. MISRG 1 OODE 16 MISRG 2 OODF15 0015 D-A 1 register OOE015 D-A 2 register OOE1 16 0015 Data bus buffer status register OOE5 16 Serial 1/0 status register OOE7 16 jojojoioiojojoj Serial 1/0 control register OOE815 oo" 1 UART control register OOE9 16 I I I oI oI o I oI Timer 1 control register OOED16 Timer 2 control register OOEE 16 Io Io Io I o Io lo I Timer 3 control register OOEF15 Fig. 3.2.1 Internal state of microcomputer at reset (1) Address Register contents Timer 1 register (lower) OOF0 16 FF16 Timer 1 register (upper) OOF1 16 0315 Interrupt request register 1 OOFC15 0016 Interrupt request register 2 OOFD 16 I o I oI o I o I o I o I Interrupt control register 1 OOFE 16 0015 I Interrupt control register 2 OOFF15 I a JoJoJoJoJoj Processor status register (PS) I I I J I I I 1 Contents of address Program counter (PCH) FFFF15 Contents of address (PCL) FFFE15 Note : The other registers and the RAM are undefined at reset, it is necessary to set initial values. Fig. 3.2.2 Internal state of microcomputer at reset (2) 81 RESET CIRCUIT 3.3 Reset circuit The reset input voltage must be kept below 0.6V until the supply voltage surpass 4.5V. Power on Supply voltage av ~ ~ Supply voltage Reset input voltage av : : ~.6V Reset input ~voltage av---+----- r------- Vee 1 I I Fig. 3.3.1 Power on reset condition I I I I I I .___ _ _ __.__,__. Vss I I L _____ _:_ __ _J M3745aM2-XXXSP Fig. 3.3.2 Power on reset circuit 82 OSCILLATION CIRCUIT 4. OSCILLATION CIRCUIT 4.1 Oscillation circuit M37450 has an internal oscillation circuit. The internal clock ¢is the frequency input into the clock input pin X1N divided by 4. A ceramic or crystal resonator can be used for the element to be attached to this cir- cuit. (1) The oscillation circuit using ceramic resonator or crystal resonator Figures 4.1.1-4.1.3 show the case where a ceramic or crystal resonator is used. As shown in the figure, the oscillation circuit can be formed by connecting the resonator between X 1N and XouT· In this case, the values Rf, C 1N, CouT• should be set to the values recommended by the manufacturer of the oscillator. (2) External clock input circuit. M37450 also can accept an external clock. A example of the external clock input is shown in Figure 4.1.4. In this case the XouT is left open. M37450M2-XXXSP/FP M37450M2-XXXSP/FP X1N XouT Rf X1N XouT RI 0 C1N J J. CauT Fig. 4.1.1 Oscillation circuit example with a ceramic Fig. 4.1.2 Oscillation circuit example with a ceramic resonator resonator (Built-In capacitor type) M37450M2-XXXSP/FP M37450M2-XXXSP/FP Xour X1N Xour Rf Open External oscillation soruce Vee lfUlJU1ru Vss Fig. 4.1.3 Oscillation circuit example with a crystal Fig. 4.1.4 Oscillation circuit example with a external resonator oscillation source 83 OSCILLATION CIRCUIT 4.2 Clock generating circuit . The oscillation circuit consists of an oscillating gate which works as an amplifier to obtain necessary gain for oscillation and the oscillation control flip-flop, which is used to stop or restart oscillation when neces- sary. M37 450 has a built-in clock generating circuit as shown in Figure 4.2.1. In M37450, the oscillation can be stopped by executing STP instruction while retaining the contents of all registers except for timer 1 register (stop mode). When operation resumes after the STP, it can start-up in the same state as when the oscillation stopped. When the STP instruction is executed, the oscillation stops with the internal clock and loH(avgl are the average current in lOOms. Note 4 : The total of loL of port PO, P1 and P2 should be 40mA (max)_ The total of 10 , of port P3, P5, P6, R/W SYNC, RESET our. RD, WR and¢ should be 40mA (max.). The total of 10 " of port PO, P1, and P2 should be 40mA (max.). The total of Iott of port P3, PS, P6, R/W, SYNC, RESET our. RD, WR, and ¢should be 40mA (max.). 85 ELECTRICAL CHARACTERISTICS ELECTRICAL CHARACTERISTICS (Vcc=5V±l0%, Vss= OV, Ta=-10-70'C, l(X,N)=lOMHz) Limits Symbol Parameter Test conditions Unit Min. Typ. Max. "H" output voltage RD, WR, R/W, SYNC, RESET our, ¢ loH=-2mA v_ "H" output voltage P00-P07, P1 0-P1,, P20 -P2r loH =-5 mA v P3o-P31, P5o-P5,, P6o-P6r "L" output voltage P00 ....... P07, P1o"".'P17, P2o ....... P21 P3o ....... P31, P5o.-...P51, P60 ....... P61 loL =2 mA o. 45 v RD, WR, R/W, SYNC, RESETour, ¢ "L" output voltage PQ0 .-.....P01, P1 0 .-....Ph, P2 0 ....... P21 P3o-P3,, P5o-P5,, P60-P61 loL =5 mA 1 v Hysteresis INT,-INT3 (P6 0-P3 2), EV,-EV3 (P3o-P32) Vr+ - Vr- RxD(P3,), Sc,K(P:Je) Function input level 0. 3 1 v Vr+ - Vr- Hysteresis RESET ---·--------·-----i-----------------j-----t-----i----t-----i 0. 7 v 0. 1 0. 5 f-V_r_+_-_V_r_-_,_H_y_s_te_re_s_is_X_1N_ _ _ _ _ _ _ _ _ _ _ _ _ _ _-c-·----------------'-j----+-----+---+-----l v ----+-"-L_"_in-p-ut_c_u_r-re_n_t_P_0_ l- 11L 0 7 P4o0....... P47, P3o..-..P37, --P-0__,_P_1_ P60.-..P67, -- _-_P_1_,_·_P._2_ RESET, 0 P5o---..P57 X1N --P-2,______ V1 =Vss t---·--------·------l'____+----+---·+----~ -5 5 µA litt "H" input current PQ0 .-....P01, P1 0 --Ph, P2 0---P2 7 P30 ....... P37 , P4o~41, P5o ....... P51 P60-P61, RESET, X1N V1 =Vee l! -5 5 11A VRAM RAM retention voltage At stop mode I 2 v ---·---------+-- f(X1N)= 10MHz At system operation 6 10 mA Ice Supply current At stop mode (Note 5) 1 10 µA Note 5 : The terminals RD, WR, SYNC, R/W, RESETour. ¢, Xour. D-A 1 and D-A, are all open.The other ports, which are in the input mode, are connected to V55. A-0 converter is in the A-0 completion state. The current through ADV REF and DAV REF is not included. (Fig. 5.4) A-0 CONVERTER CHARACTERISTICS (Vcc=AVcc= 5 V, Vss=AVss= 0 V, Ta =25°C, f(X,N)=l OM Hz unless otherwise noted) Symbol - Resolution Parameter I ' Test conditions ·----· I- Min. Limits Typ. Max. 8 ' Unit -- Bits ·--- - Absolute accuracy i Vcc=AVcc=AOVREF=5.12V ±1. 5 ±3 LSB 1 tcoNv Conversion time 49 tc() ~- Analog input voltage AVss A Vee v Reference input voltage l 2 v t VADVREF Vee ' RLADDER Ladder resistance value i ADV REF= 5 v 2 7. 5 10 kO ·----·· - . t-· llADVREF Reference input current ADVREF= 5V 0. 5 0. 7 2. 5 mA ---- VAvcc Analog power supply input voltage Vee v VAvss Analog power supply input voltage I oj v 0-A CONVERTER CHARACTERISTICS (Vee= 5 V, Vss=AVss= 0 V, Ta =25'C unless otherwise noted) Limits Symbol Parameter Test condition -- Unit Min. Typ. Max. --1 - Resolution 8 Bits - Full scale deviation .. Vcc=DAVREF=5V 1. 0 % tsu Set time 3 µS Ro Output resistance 1 2 4 kO VAVSS Analog power supply input voltage 0 v VoAVREF Reference input voltage 4 Vee v loAVREF Reference power input current 0 2. 5 5 mA 86 ELECTRICAL CHARACTERISTICS TIMING REQUIREMENTS Port/single-chip mode (Vcc=5V±10%, Vss=OV, Ta=-10-70t, unless otherwise noted) Limits Symbol Parameter Test condition Unit Min. Typ. Max. tsu(POO-¢) Port PO input setup time 200 ns tsu CS hold time 0 ns •su Data input setup time 130 ns lh(~-D) Data input hold time 0 ns Fig. 5.3 tsu) Cycle tir:ne ______________ 400 4000 ns tw(¢Hl ¢clock pulse w_id_th._('_'H_"_le_v_e_l)_____· - - · - - · - · · - - - j 190 ns l--tw<~---1 ¢clock pulse width ("L" level) 170 ns i------+----+---+----1 trc l ----! ¢clock rising edge time 20 ns ¢clock falling edge time ----+-- 20- -·-;;;--1 Master CPU bus interface (R and W separation type mode) (Vcc=5V±l0%, Vss=OV, T 3 =-10~70°C, unless otherwise noted) Limits Symbol Parameter Test condition Unit Min. Typ. Max. ta(R-D) Data output enable time after read 120 ns I-· tv(R-D) Data output disable time after read 10 85 ns ------ -- Fig. 5. 2 tPLH(R-PR) PRoY output transmission time after read 150 ns tPLH(W-PR) PRoY output transmission time after write 150 ns Master CPU bus interface (R/W type mode) (Vcc=5V±l0%, Vss=OV, Ta=-10~70'C, unless otherwise noted) Limits Symbol Parameter Test condition Unit Min. Typ. Max. ta(E-D) Data output enable time after read 120 ns - --- tv{E-D) Data output disable time after read Fig. 5. 2 10 85 ns tPLH(E-PR) PRoY output transmission time after E clock 150 ns Local bus/memory expansion mode, microprocessor mode (Vcc=5V±l0%, Vss=OV, T3 =-10-70°C, unless otherwise noted) Symbol Parameter Test condition r-----,. Limits Unit Min. Typ. Max. --~----- td(¢-A) ~ress delay time after ¢ 150 ns ~"'~ ----1 lv(¢-A) Address effective time after ¢ 10 ns t-----~V(RO-A) Address effective time after RD 10 ns lv(WR-A) Address effective time after WR 10 ns td(¢-D) Data output delay time after ¢ 160 ns ·-·-------- t--'cj(WR-D) Data output delay time after WR 160 ns Fig. 5. 3 r-"6-•-o) 20 ns tv(wR-o) Data output effective time after WR 20 ns td(¢-RW) R/W delay time after ¢ 150 ns ld(¢-SYNC) SYNC delay time after ¢ ----- ··150 ns tW(RD) RD pulse width 170 ns lw{WR) WR pulse width 170 ns 89 ELECTRICAL CHARACTERISTICS Test Condition Input voltage level : v,H 2.4V V1L 0.45V Output test level : VoH 2.0V Vol a.av PO P1 PO} P2 P1 50pF J; P3 P4 P5 I 100pF l 100pF P2 1--~--< 1 l 100pF P6 RI~) SYNC .....--.----< 1 I 5QPF RD WR 50pF Fig. 5.1 Test circuit in Fig. 5.2 Master CPU bus interface Fig. 5.3 Local bus test circuit single-chip mode test circuit Vee Vee RESET Vee AVee other power supply PO ADV REF P1 DAV REF P2 P3 D-A1 P4 D-A2 PS RD- P6 WR open CNVss R/W AVss SYNC Vss RESETour ¢ X1N XouT l l Fig. 5.4 Ice (at stop mode) test condition 90 ELECTRICAL CHARACTERISTICS TIMING DIAGRAM Port/Single-chip mode timing diagram ~ tw(¢,) 2. 0 2. 0 _J ~ 0. 8 O.SJ tw(¢H) __,.. r-11(¢) Ir(¢) tsu(PiD-¢) ~ _) 2. 4 Port Pi input I\.0. 45 5 th(¢-PiD) ld(¢-Pi0) Port Pi outpu t ) ¥2.0 1\0.8 Note: v,,,=O. BVcc. VIL =O. 16Vcc of x,N Master CPU bus interface/A and W separation type timing diagram read tSU(A-R) Ao , ~ tsulcs-Rl thlR-csl H /' cs o. 45 L 11'-+-~~~~~-t--''11 l__Jo. 45 2. 4 11.1 I~ 2. 4 1~ ,o_._45_ _ _ _ _ 1 o._45_,.i< 1 1 ----------+----o.-s----- 1 ta(R-D) '1---3- lv(R-DI ,,...---.. /2.0 ~-----------------r----' 91 ELECTRICAL CHARACTERISTICS write 1suCA-w Ao ~lsu-----------ll _/ 0. 45 _j ------------------------------------1-----'_J~o tPLH(E-PR) 92 ELECTRICAL CHARACTERISTICS Local bus timing diagram tW(¢H) tw(-A) x K= lh1¢-D) tsU(D-¢i) Do . . . . . 07 CPU read J I" ld(¢-D) ~ ly(¢-D) v CPU write t-..._ _,-1 -- tw(AD) K ~ ty(RD-A) RD 1 ~ tSU(D-RD) f... lh(RD-D) Do-D1 CPU read tw(wR) ~ ty(WR-·A) ~ WR \ ld(WR-O) ~ ty(WR-D) Do-D1 CPU write 93 TYPICAL CHARACTERISTICS 6. TYPICAL CHARACTERISTICS 6.1 Port typical characteristics Figure 6.1.1 and 6.1.2 shows the typical characteristics of the ports. [Port P0 0 10 H-VoH characteristics ( P-ch drive)] -50. 00 -40. 00 > 10 10 5 5 (]) (J) __, -1LSB -20f-- - - - - - - - - - +- - +- - - - - - - - - t-- +- - +- - - - (]) (J) __, -1LSB -201-- - - - - -- - -+-- - - - - - - --+-- +--+--f----- -30~-'-'-';~"""-'~W..U.~.J..U."';';':;';-1.J..J-'";1;~.U..C:~LU..L~.wJ.l;':!:':.L.u.u+:J:,~~±'-'-.i..U,li+LJ.llL~J.J.J..1+!,\,LU..Ll.!-.4UJ..w.lJ.J..Wl.JJJ 128 136 144 152 160 168 176 184 192 200 208 216 224 232 240 248 256 conversion result Measured when power supply is stable in single chip mode. Fig.6.2.1 A-D conversion typical characteristics 95 TYPICAL CHARACTERISTICS 6.3 D-A conversion typical characteristics Figure 6.3.1 shows the typical characteristics of the D-A converter. The bottom line of the graph shows the absolute precision error, this error being the difference between the ideal analog output corresponding to the input code and the measured value. The top line ·in the graph shows the width of the output analog value corresponding to the 1-bit change in the input code. * * * M37450M2-XXXSP D-A CONV. ERROR & STEP WIDTH * * * Vcc=5. 12 [VJ VREF=5. 12 (VJ 1LSB width (differential nonlinear) x,"=10 [MHz) Temp.=25 deg. error (absolute precision) 30~................~................~................~~~.,,..,.,~~.,,..,.,.........~.,,..,.,.........~~~~""'"'.........~~.......~................~.........,..,.,..,30 0.4% m 1m 1--~+-~-+-~-+-~-+~--1~~+-~-+-~-+-~-t-~--t~~r-~;-~-;-~-T~--t~--;'.'.> > 10 10 8 E £ ~~~~:r:~~~':t~:'.:t:::'.~:=:~J::'.::::E~~~~~~~~~:;::~~~~:i;::::t~~J'.lJo m_,o j ~ -0. 4% -20 t- - - - - -1 - -1 - - t- - I- - - - - --1- -1 - +-I- - 1-- - - - 30 0~~........ 16...................2~4......~3~2.................40~........4~8...........,..56,.............,6~4......~7~2..............,..80,................8~8.........~96......~10~4........~1~12.........~1~2~0.........1.... 8............. 28 digital input 301'TTT,.,..,.,rTTTl'TTT'l'T'l"'ITTT"l'TTTTT'T'T"TTT'l'TTTTmrTTTTT'l'TTmrrT'TTTT'TTTT"r"TT!'l'TTTT"l'TiTTT"l'TTTTmrTTTl'TTTTT'l'!TM'TT'nTTT"l'TTTTT'l"ITl"T"l"l'TTl'TTTTT'T'l30 0. 4% 20 l--+--+---t---"lo...---ll--_.,..........+--+.1- ..... +--+--'""'"'-......---1....................,................"'l--_-t20 1--~+-~-+-~-+-~-+~--if-~+-~-+-~-+-~-+~--t~~t-~+-~-+-~-+~--t~---1'-> > 10 10 8 5 e?' l*""'*"~~~-+++1~~~~~~~~~~......~:1:1:1:1.i:l:lij:liO!:l:!±tld:!±!±±!:l:iiOW:i:l:lij;jilcl:j~~i±l:ltl±jot±±:I o ~·~ 0 Q) -10 l1 -0. 4% -20 t- - - - - - - - - - - -+- - t- - - -I - - - - - -1---t---- -30 12~8........~1w36,........~1~4~4.........~15~2.........~1~60±-"-'""""16~8......~1~76......~1~8~4......~19~2......~m~o,........~2~0~8......~2~16,......~2~24~""""23~2.......................~2~4~3"'"""~2~ digital input Measured when power supply is stable in single-chip mode. Fig.6.3.1 0-A conversion typical characteristics 96 APPLICATION 7. APPLICATION 7 .1 Memory expansion The following figures explain the memory and port expansion methods when the M37450 is in memory ex- panding and microprocessor mode. 7 .1.1 ROM expansion Figure 7.1.1 and 7.1.2 shows the example of ROM expansion for 80-pin model and 64-pin model respec- tively. Avalable EPROMs are determined by these caluculations: CE access time (include decode time) 4000 ta(cE)~ f(XiN) -(tn,;)+td(¢-A)+tsu(o-q,)) OE access time 2000 ta(oE)~ f(XiN) -30)-tsu(o-¢) In 1OM Hz no-wait condition, the EPROM needs these timings: ta(cE)~100ns, ta(oE)~40ns A,s 74HC04 P3 Ao,..._,,A14 P4 CE Ao,._,A14 M5M27C256K-15 PS Do-D, OE Do-D, Decode Address A15 and connect 32K-byte P6 EPROM. RD Use an EPROM which has less than 150ns D-A 1 access time for CPU in no-wait condition D-A 2 (ROYE= "O") when the CPU is working in 1 (X,")=8MHz operation 8MHz Fig.7.1.1 M37450M2-XXXFP ROM expansion example t----~ 74HC04 The signal which is almost same as RD can be M5M27C256K-15 generated by¢ and R/W through 74ALS139. 8MHz Fig.7.1.2 M37450M2-XXXSP ROM expansion example 97 APPLICATION 7.1.2 ROM and RAM expansion Figure 7.1.3 shows the example of 32KB ROM expansion and 32KB RAM expansion. M37450M2-XXXFP 74HC04 1--~~"""" ~+---~~~~ Ao - A,. CE M5M27C256K-15 M5M5256P-15 Oo-01 OE 00,-00. OE w 8MHz M37450M2-XXXSP 74HC04 Ao - A14 CE Ao-A14 M5M27C256K-15 M5M5256P-15 OE oo, -oo. OE w 8MHz Note. The 32K-byte RAM overlapped by the internal RAM and SFR, is write-only. Available EPROMS are determined by these caluclations : Read model S1 access time (include decode time) 4000 tacs1l :> f(XiNl - (trc•1+tdc.-•1+tsuco-•J) OE access time 2000 ) taco•J :> ( f(XiNl - 30 -tsuco-•l Write model 2000 ) tsuCol :> ( f(X,N) - 30 -tdc;--01 Flg.7.1.3 Example for ROM and RAM expansion of M37450M2-XXXSP 98 APPLICATION 7.1.3 Memory and port expansion (1) Interface to M5M82C55AP-5 Figure 7.1.4 shows the port expansion circuit with the M5M82C55AP-5 and memories. The M5M82C55AP-5 must be used in mode 0. When using the M37450M2-XXXSP in 8MHz operation, use the ROM and RAM which satisfy the M37450M2-XXXSP's AC characteristics. However, in this case, the M5M82C55AP-5 can not satisfy the AC chatacteristics. To access the M5M82C55AP-5, set the RDYE flag (bit 6 of address OODF 16 ) of the M37450M2-XXXSP to "1 ". By setting RDYE, the timing period of the M37450M2-XXXSP is expaned by two. This causes the M37450 to satisfy the M5M82C55AP-5's timing characteristics. When using the M37450M2-XXXFP (80-pin type), the CPU outputs the RD and WR signals, so there is no need to separate the R/W signal. M37450M2-XXXSP 74ALS139 2E 2Y2 R/W 2B 2YOI'-' P1 7 (A15) P1 6 (A14) P1 5 (A13) I ..:::!=__ ...rl 2A 1E 18 1A 1Y1 h- 1YOh. lcs 1WR RD ~ POo(AO) 74HC04 8 ~ .'\ PA = _j_ ~ \ A, ... Ao A 14 - A0 CE OE M27C256-15 8 PB D7 -D 0 ... ... At2--Ao CS WARD P5o M5M5256-15 P2 7 (D 7 ) ~ D, I D 7 -D0 A,4 R At3 I 8 P2o(Dol L. L ••J ~~ Do PC -"" RESET YCJ~ I BM Hz M5M82C55AP-5 Fig.7.1.4 Example for interface to M5M82C55AP-5 99 APPLICATION (2) Timer function upgrade Figure 7.1.5 explains how the timer LSI upgraded, M5M82C54, and EPROM interface to the M37450FP. The addresses of the M5M82C54P are addresses 4000; 6 to 4003 16. The RDYE flag must be set to "1" for the M37450 to synchronize with the M5M82C54P. 74HC32 A,s P3 A,. A1a 74HC04 12 P4 A2 cs CLKo A, A, Ao Ao GATEo P5 15 OUTo CLK Ao-A14 M5M82C54P GATE1 P6 OUT1 M5M27C256-15 CLK2 DA1 GATE, DA, OUT2 Do-D1 OE Do-D1 RD WR 8 8 Do-D1 RD WR 8MHz Fig.7.1.5 Example for timer function upgrade 100 APPLICATION (3) Port expansion using gate arrays The M60014-0120FP is a gate array in the M37450 family, which is designed for port expansion. In micro- processor mode or memory-expanding mode of the M37450 family, it provides the system with three 8-bit (24 bits) or five 8-bit (40 bits) bi-directional ports. For details, see the M60014-0120FP specifications in Appendix 12. Figure 7.1.6 is a system wiring diagram for the small-eva-board (PCA7450PGB), which uses the micro- processor mode M37450M2-XXXFP and M60014-0120FP, for evaluating the 7450 system. P371Sii'Dv P381SCLK g:~ I~ P~/TXD P341RXO P33JPW!llOUT P321E\13 P31/EV2 F'3(11EV1 ABl5 P5ll/DB6 AB14 P551DB5 AB13 P54/084 A812 ..."' 1'531083 AB11 P521DB2 AB10 .• P51/DB1 . "''" "50/DBO P411AN7 ,,., P071A7 ·~ " ..,, P461AN6 ~~~l ~ '" '" "' "' 1047 ~ •o~ 1045 i~fTOUT 1044 ·~· 1042 RESET 1041 1040 0-.. Rei5 ~ 0-112 DA-VREF "' AD-VREF "" "' "' "' "~ "' "' AVee AVss CNVss Note : The oscillation is SM Hz. Fig.7.1.6 PCA7450PGB system wiring diagram 101 APPLICATION 7.2 Applicaiton circuit 7.2.1 Electric typewriter application This application uses three M37450s. As the master processor, the M37450 uses the 7.37MHz clock fre- quency. Others uses are mechanical controllers and FLT display drivers. M37450M2-XXXFP A,, A2 Y1 P5 A,. A1 A,3 AO Y? P64 A12.......,Ao AO K/B ;:: P4 P6 7 -P6 5 ..."'__, "'0;:: ~ xx URAT RD Fi x TxD RxD WR w (/) 'U D,-Do P5 PADY INT, cs AD ;:: ..."'__, "';:: 0 ~ xx Fi x (/) w 'U P5 7. 37MHz lOMHz Fig.7.2.1 Application for electric typewriter 102 APPLICATION 7.2.2 Hard disk drive application The M37450 has a high-speed A-D converter, a 2-channel D-A converter, high-speed PWM and 3 timers. Therefore, the M37450 can be used as hard disk controller which operates VCM servo (voice coil motor) or STM servo (stepping motor). STEP D-A1 D-A2 DF/F P0 1 STM DIR driver P0 2 SEEK P4o OFF SET COMP POs RED CLR TRACK < E - - - - - - - - - - - - - 1 P04 PWMour SPM PRoY < E - - - - - - - - - - - - 1 P0 5 driver IN Tl EV1 INDEX P 0 1 > - - - - - - - - - - - _ , , . . SOLLOCK D 10MHz Fig.7.2.2 Application for hard disk drive 103 APPLICATION 7.2.3 Intelligent modem application The M37450 has advanced 16-bit timers which can be applied to the intelligent modem controller shown in Figure 7.2.3. .--- DTMF mode telephone \= generator ¢= P2 PO \== selection switch 0 0 3 tone output ;:: 3 c: " -... EV1 ......,"' 0"' =) w w i5' line ~ ;:: P1 LED 0 " modem P5 "'x ~ 0 0 display a INT1 en Q. circuit INT2 ~ 'T1 0 a· "ti S: r--- ) 0 w P6 P3 RS-232-C < UART INT3 interface L-..---J a~ .,"':I."'"'' EV2 ..0 0"' toDTE L-..---J Fig.7.2.3 Application for intelligent modem 104 APPLICATION 7.2.4 Voice digital recording/playback system application By using the high speed A-D and D-A converters of the M37450, voice digital recording/playback system can be realized. ANO OA1 voice input voice output PO J) P1 address ~ P5 ;:: "'""' ~ gi ;:: j P6 "' xxx (/) ~ 'TI 'O P2 data )[j P3 key input EV1 control signal EV2 Fig.7.2.4 Application for voice digital recording/playback system 105 a m I ~ W • M50745 ASSEl'IBLER V.2.0lC • P. 002 J> I•: ~:Eu. LOC. OBJ. . .. .. • •••• 1. ... • .... 2 •.•. • ..•. SOURCE STATE:M!:NT .... 5 .... •. ~ ;••••••••••••••••••••••••••••••••••••••••• VER 0.8(5/26) (=;- ·~ ;, 0000 ......................................'... PoRTO ••• S F R E:QUATION ••• • SDO •• ;• ... 11> (5" :> 0001 PORTOD • tDl ;• :I 0002 PORTl • SD2 ;• = 1; (II 'f 0003 PORTlD • SD3 ;• 0 11 0004 .PORT2 • SD4 ;• ll 0005 PORT2D • SD5 ;• ::E lo OODS PORT3 • SOS ;• ~ ll 0007 PORT3D • SD7 ;• Cl> t ., 0008 PORT4 • SOS ;• 13 OODA PORTS • SDA ;• M OODB PORT5D • •DB ;• ll> OODC PORTS • SOC ;• Ill OODD PORTSD • SOD ;• l1 ;••······································· Ill OODE MISRGl • SOE ·• Ill 0,DE llP • 0,MISRGl ·• :!o l,DE I2P • l,MISRGl ·• 21 2.DE I3P • 2,MISRGl ·• 22 4,DE Cl • 4,MISRGl ·• 23 5,DE C2 • 5,MISRGl ·• 24 S,DE C3 • S,MISRGl ·• 25 OODF MISRG2 • SDF ·• 2S 0. DF CMO • 0 ,MISRG2 ·• 27 l , DF CMl • 1 , MI SRG2 ·• 28 2,DF DBBE • 2,MISRG2 ·• 29 3, DF DBBM • 3 ,MISRG2 ·• 30 4.DF PWME • 4,MISRG2 ·• 31 5, DF PWMM • 5 ,MISRG2 ·• 32 6,DF ROYE • 6,MISRG2 ·• 33 7,DF SPS • 7,MISRG2 ·• 34 OOEO D Al • SEO ·• 35 OOEl D-A2 • SEl ·• 36 OOE2 ADSR • SE2 ;• 37 OOE3 ADCON • SE3 ·• 38 OOE4 DBB • SE4 ;• 39 OOE5 DBBSTS • SES •• 40 0,E5 OBF • 0,DBBSTS ·• 41 1, E5 !BF • l, DBBSTS ·• 42 3,E5 AO • 3,DBBSTS ·• 43 OOES RB_TB • SES ·• 44 OOE7 SIOSTS • SE7 ;• 45 O,E7 TBE • 0,SfOSTS ·• 46 l,E7 RBF • l,SIOSTS ·• 47 2,E7 TSC • 2,SIOSTS ·• 48 3,E7 OE • 3,SIOSTS ·• - 49 4,E7 PE • 4,SIOSTS ·• - 50 5,E7 FE • 5,SIOSTS ·• "CJ 51 6.E7 SE • 6,SIOSTS ·• "CJ 52 OOE8 SIOCON • SES ·• I"" 53 O,E8 FOSC2_8 • 0,SIOCON ·• () 54 1.E8 BRG_EXC • l,SIOCON ·• Jao ::! 0 z • M50745 ASSEMBLER V.2.0lC • P. 003 E SEQ. LOC. OBJ .. . ... • .... l .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. 55 2,E8 SREADYE • 2,SIOCON 56 3,E8 TIC • 3,SIOCON 57 4,E8 TE • 4,SIOCON 58 5,E8 RE • 5,SIOCON 59 8,E8 UAR_CIO • 6,SIOCON 60 7,E8 SIOEN • 7,S!OCON 61 OOE9 UACON • SE9 62 0,E9 CH7_8 • O,UACON 63 1.E9 PARE D • l,UACON 64 2.E9 EVEN=OD • 2,UACON 65 3,E9 SP1_2 • 3,UACON 66 OOEA BRG • SEA 67 OOEB PWML • SEB 68 OOEC PWMH • SEC 69 OOED TMRl • SEO 70 O.ED TMSlO • O,TMRl 71 1.ED TMSll • 1, TMRl 72 2,ED TMS12 • 2,TMRl 73 3,ED Sl • 3,TMRl '14 4,ED OLLl • 4,TMRl ·15 5,ED EPl • 5,TMRl 7U OOEE TMR2 • SEE 77 O,EE TMS20 • 0,TMR2 78 1.EE TMS21 • l,TMR2 79 2,EE TMS22 • 2,TMR2 80 3,EE S2 • 3,TMR2 81 4,EE OLL2 • 4,TMR2 82 5,EE EP2 • 5,TMR2 83 OOEF TMR3 • sEF 84 O,EF TMS30 • 0,TMR3 85 1.EF TMS31 • l,TMR3 86 2,EF TMS32 • 2,TMR3 87 3,EF S3 • 3,TMR3 88 4,EF OLL3 • 4,TMR3 69 5,EF EP3 • 5,TMR3 90 91 OOFO ;•········································ TlL SFO 92 OOFl TlH SFl 93 OOF2 RLlL SF2 94 OOF3 RLlH SF3 95 OOF4 T2L IF4 \J6 OOF5 T2H sF5 97 OOF6 RL2L SFS 98 OOF7 RL2H SF7 gg OOF8 T3L SFS 100 OOF9 T3H SF9 101 OOFA RL3L IFA 102 103 104 OOFB OOFC O,FC RL3H IRQl IBFR SFB SFC 0, !RQl ,,,, )lo 105 1,FC OBER 1. IRQl 106 2,FC llR 2, IRQl r 107 3,FC !2R 3, IRQl n 108 4,FC !3R 4, IRQl )lo ::! 0 0 -..J z C) 00 I • M50745 ASSEMBLER V.2.0lC • P. 004 E SEQ. LOC. OBJ. . . ..• • .•.. 1. ... • .... 2 .... • .... SOURCE STATEMENT ..•. 5 .... •. 109 5,FC TlR • 5,IRQl :• 110 6,FC T2R • 6,IRQl :• 11 l 7, F.C T3R • 7, I RQl ;• 112 OOFD IRQ2 • SFD :• 113 0,FD ElR • 0, IRQ2 ;• 114 l ,FD E2R • l, !RQ2 ;• 115 2,FD E3R • 2, !RQ2 :• 116 3,FD RIR • 3,IRQ2 ;• 117 4,FD TIR • 4,IRQ2 :• 118 5,FD ADCOMPR • 5, IRQ2 :• 119 OOFE ICONl • SFE ;• 120 O,FE IBFE • 0, lCONl ;• 121 l,FE OBEE • l,!CONl ;• 122 2,FE llE • 2, !CONl ;• 123 3, FE l2E • 3, !CONl ;• 124 4,FE !3E • 4,!CONl ;• 125 5,FE TlE • 5,!CONl ;• 126 6,FE T2E • 6,ICONl ;• 127 7,FE T3E • 7,ICONl ;• 128 OOFF ICON2 • SFF ;• 129 0,FF ElE • O,!CON2 ;• 130 l,FF E2E • l,!CON2 ;• 131 2,FF E3E • 2,ICON2 ;• 132 3,FF R!E • 3,ICON2 ;• 133 4,FF TIE • 4, ICON2 ;• 134 5, FF ADCOMPE • 5, !CON2 ;• 135 :·······································'· 136 0000 Wl • SOO ;• 137 .••••••••••••••••••••••••••••••••••••••••• 138 .NL I ST ·• 158 .LIST ,,,,> r n > -I c; z • M50745 ASSEMBLER V.2.0lC • P. 005 E SEQ. LOC. OBJ .. . ... • .... 1 .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. 159 .PAGE 160 161 162 ... TIMER ... . ········•········•·············••·••······ ...................•.•....•....••........• ; 163 164 ;* * * MODE 0 (TMS=000 8 ; Timer mode) 165 ; This is the normal timer mode. When count value N is set in the timer latch, the actual counting number becomes (N+1), due to 166 ; the reload action needing 1 count-cycle. However, the timer does not need to be reloaded action until the first overflow. Therefore IG7 ; the initial timer value must be (N+1J so the same counting time will be used when the value N was loaded. HHI ; The timer must be loaded from the low-byte address first. lli9 l'IO TMSOOO: 171 F018 lFED CLB TMSlO ;SET MODE 172 FOlA 3FED CLB TMSll 173 FOlC 5FED CLB TMS12 174 ; ••• TIMER REGISTER SETTING ••• 175 FOlE 3CAAF2 LDM tsAA,RLlL RLlH I RLlL 176 F021 3CBBF3 LDM ISBB,RLlH ( BBH AAH 177 F024 3CABFO LDM ISAB,TlL TlH I TlL 178 F027 3CBBF1 LDM UBB, TlH ( BBH ABH 179 ; 180 F02A BFFC CLB TlR CLEAR REQUEST FLAG 181 F02C 8FDE SEB Cl TIMER START 182 F02E B7FCFD BBC TlR, • WAIT FOR TIMER_OVERFLOW 183 ; (400ns x BBABH WHEN fosc • lOMHz) 184 F031 BFFC CLB TlR CLEAR REQUEST FLAG 105 F033 EA NOP 106 F034 B7FCFD BBC TlR,• WAIT FOR TIMER_OVERFLOW 187 F037 9FDE CLB Cl (400ns x (BBAA+l )H WHEN fosc • 10 MHz) 188 F039 60 RTS 189 TMS0002: TMSOOO OF TYPE_2 190 F03A lFED CLB TMSlO SET MODE 191 F03C 3FED CLB TMSll 192 F03E 5FED CLB TMS12 193 ; ••• TIMER REGISTER SETTING ••• 194 F040 3CAAF2 LDM #SAA, RLlL SET RLlH I RLlL 195 F043 3CBBF3 LDM ISBB,RLlH ( BBH AAH 196 F046 3CABFO LDM ISAB, TlL SET TlH I TlL 197 F049 3CBBF1 LDM ISBB, TlH ( BBH ABH 198 ; J99 F04C BFFC CLB TlR CLEAR REQUEST FLAG 200 F04E 8FDE SEB Cl TIMER START 201 F050 B7FCFD BBC TIR, • WAIT FOR TIMER OVER_FLOW 202 ; (400ns x BBABH WHEN fosc • lOMHz) 203 F053 BFFC CLB TlR CLEAR REQUEST FLAG 204 F055 3C22F2 LDM IS22.RL1L SET RLlH I RLlL 205 F058 3C33F3 LDM IS33, RLlH ( 33H 22H ) 206 207 208 F05B B7FCFD I'05E BFFC ~"060 EA BBC CLB NOP TlR,• TlR WAIT FOR TIMER_OVERFLOW (400ns x (BBAA•l)H WHEN fosc • 10 MHz) ,,,,> 209 1'061 B7FCFD BBC TlR, • WAIT FOR TIMER OVERFLOW 210 ; (400ns x (332Z•l)H WHEN fosc • 10 MHz) r- 211 212 F064 9FDE CLB Cl n F066 60 RTS > ... 0 <.D I I~ 0 • M50745 ASSEMBLER v.2.01c • P. 008 E SEQ. LOC. OBJ .. . ... • ...• 1 ..•. • .••. 2 ...• • .... SOURCE STATEJllENT .... 5 •.•• • . 213 .PAGE 214 *** MODE 1 (TMS=001 6 : Event counter mode) 215 This mode has the same function as the timer mode except for using the EV port as count source. It is necessary to set port P30 to 216 input mode and set the polarity of the EV port. The EV input signal synchronizes with the internal clock, and the timer contents can 217 be read anytime. In this case. the timers high byte (T1 H) must be read first, and T1 L second. 218 219 220 TMSOOl: 221 F067 OFED SEB TMSlO SET MODE 222 F069 3FED CLB TMSll 223 F06B 5FED CLB TMS12 224 F06D 1FD7 CLB 0,PORT30 225 FOSF BFED CLB EPl PORARITY IS FALLING EDGE 226 ; ••• TIMER REGISTER SETTING 227 F071 3CFFF2 LOM #SFF.RLlL RLlH I RLlL 228 F074 3CFFF3 LOM #SFF,RLlH FFH FFH 229 F077 3CFFFO LOM #SFF. TlL TlH I TlL 230 F07A 3CFFF1 LDM #SFF,TlH FFH FFH 231 ; 232 F070 BFFC CLB TlR CLEAR REQUEST FLAG 233 F07F 8FOE SEB Cl TIMER START 234 ; : 235 ; 236 F081 A5Fl LOA TlH I I :Read timer_High 237 F083 49FF EOR ISFF 1---------1 :~et l's complement of timer_High 238 F085 8501 STA Wl+l Wl I timer_L I 239 F087 A5FO LOA TlL 1---------1 :Read timer_Low 240 F089 49FF EOR ISFF Wl+ll timer_H I :Get l's ~omplement of timer_Low 241 F08B 8500 STA Wl 1---------1 242 ; I I 243 F08D 18 CLC 244 FOBE B7FC01 BBC TlR, TMS00101 CHECK OVER FLOW 245 F091 38 SEC 246 TMS00101: 247 F092 60 RTS ,. 'V 'V r- ,.n -I 0 z • M50745 ASSEMBLER v.2.01c • P. 007 r,; SF.Q. LOC. OBJ .. . ... • .... l .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. :!411 .PAGE :~ •1 ! I :~:>o * * * MODE 2 (TMS=010 8 : Pulse output mode)- ln this mode,, the timer must be started alter setting port P30 to output mode, setting value to the timer latch, and selecting the ~!"">l 2~);~ count source. When this mode is selected, the EV port is initialized to "O" automatically. 253 TMSOlO: 254 F093 lFED CLB TMSlO ;SET MODE 255 F095 2FED SEB TMSll 256 F097 5FED CLB TMS12 257 F099 OFQ.7 SEB 0,PORT3D 258 F09B 7FED EVENT PORT OUTPUT_SET CLB Sl COUNT SOURCE • fosc/4 259 ; 260 F09D 3CAAF2 ••• TIMER REGISTER SETTING LDM ISAA,RLlL RLlH I RLlL 261 FOAO 3CBBF3 LDM UBB,RLlH 262 FOA3 3CABFO ( BBH AAH LDM UAB,TlL TlH I TlL 263 FOA6 3CBBF1 LDM UBB, TlH 264 ( BBH ABH ; 265 FOA9 BFFC CLB TlR 266 FOAB SFDE CLEAR REQUEST FLAG SEB Cl TIMER START 267 ; BBC TlR, • 268 FOAD BFFC OUTPUT Low Pulse (BBABH • 400ns) CLB TlR CLEAR REQUEST FLAG 269 NOP 270 BBC TlR, • 271 FOAF 60 OUTPUT High Pulse ((BBAA•l)H • 400ns) RTS REPEAT ,,,,> r- n > ::! 0 z N • M50745 ASSEMBLER V.2.0lC • P. 008 I•: SEQ. t.oc. OBJ •• .... • .... 1 .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. 272 PAGE 273 ;* * * MODE 3 (TMS=011 6 Pulse period measurement mode) 274 275 The timer must be started after setting port P3 0 to input mode, setting the polarity of input pulse and selecting the count source. :!'16 The end of the measurement is recognized by E1R to become "1". The period of the pulse can be determined by reading the con- 277 tents of the timer latch. (The timer latch can be read in any order.) 278 279 TMSOll: 280 FOBO OFED SEB TMSlO ;SET MODE 281 FOB2 2FED SEB TMSll 282 FOB4 5FED CLB TMS12 283 FOBS 1FD7 CLB O,PORT30 ;EVENT PORT tNPUT_SET 284 FOBS 7FED CLB Sl ;COUNT SOURCE • fosc/4 285 FOBA AFED SEB EPl ;PORARITY IS RISING EDGE 286 287 FOBC lFFD CLB ElR ;CLEAR EVENT_INTERRUPT_REQUEST_FLAG 288 FOBE SFDE SEB Cl ;TIMER START 289 FOCO 17FDFD BBC ElR,• ;Pulse Phase COUNT END AND DUST FIRST TIME 290 FOC3 lFFD CLB ElR ;CLEAR EVENT_INTERRUPT_REQUEST_FLAG 291 FOC5 EA NOP 2!J2 FOC6 17FDFD BBC ElR, • 293 FOC9 A5F3 LOA RLlH ;READ TIMER_LATCH High 294 FOCB A6F2 LOX RLlL ;READ TIMER_LATCH Low 295 FOCD 9FDE CLB Cl ;TIMER STOP ;~95 FOCF 60 RTS )lo "V "V r- (') )lo :! 0 z • M50745 ASSEMBLER V.2.0lC • P. 009 l' SEQ. LOC. OBJ .. . · ·. • .... 1 .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. 297 .PAGE 298 299 *** MODE 4 (TMS=100 8 Pulse width measurement mode) 300 The timer must be started after setting the port P3 0 to input, setting the polarity of input pulse and selecting the count source. The 301 end of measurement is recognized by E1 R to become "1". The width of the pulse can be determined by reading the contents of 302 the timer latch. (The timer latch can be read in any order.) 303 304 TMSlOO: 305 FODO lFED CLB TMSlO ;SET MODE 306 FOD2 3F£D CLB TMSll 307 FOD4 4FED SEB TMS12 308 FOD6 1FD7 CLB 0,PORT3D ; SET EVENT_PORT INPUT 309 FOOS 7FED CLB Sl ;COUNT SOURCE • fosc/4 310 FODA BFED CLB EPl ;PORARITY IS FALLING EDGE 311 ; ;MEASURES PULSE High 312 FODC lFFD CLB ElR ;CLEAR EVENT_INTERRUPT_REQUEST_FLAG 313 FODE SFDE SEB Cl ;TIMER START 314 FOEO 17FDFD BBC ElR,• ;COUNT Pulse Width END AND DUST FIRST TIME :1i5 FOE3 lFFD CLB ElR ;CLEAR EVENT_INTERRUPT_REQUEST_FLAG 316 FOES EA NOP :11·r FOES 17FDFD BBC ElR, • 316 FOE9 A5F3 LOA RLlH ;READ TIMER_LATCH High 319 FOEB A6F2 LOX RLlL ;READ TIMER_LATCH Low 320 FOED 9FDE CLB Cl ;TIMER STOP 321 FOEF 60 RTS )lo 'V 'V r (') )lo :::! 0 w z -1:>. • M50745 ASSEMBI..ER V.2.0lC • P. 010 E SEQ. ·LOC. OBJ •. . ... • .... l. ... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... • . 322 323 324 325 326 327 328 FOFO OFED SEB TMSlO 329 FOF2 3FED CLB TMSll 330 FOF4 4FED SEB TMS12 331 FOF6 OF07 SEB O.PORT3D :SET EVENT PORT OUTPUT 332 FOF8 7FED CLB Sl ;COUNT SOURCE • fosc/4 333 FOFA 3C22F2 LDM 022.RLlL RLlH I RLlL 334 FOFO 3C33F3 LDM IS33.RL1H 33H 22H 335 FlOO 3CAAFO LDM ISAA,TlL TlH I TlL :1:15 Fl03 3CBBF1 LDM #SBB, TlH BBH AAH :1:1·r <-BBAAH-> :1:~0 Fl06 9FED CLB OLLl CLEAR OUTPUT_LEVEL_LATCH :\:)~) Fl08 BFFC CLB TlR CLEAR OVERFLOW FLAG '.140 FlOA SFDE SEB Cl TIMER START :141 FlOC B7FCFD BBC TlR,• EVENT OUTPUT HIGH PULSE ( ·--> :14;! (3322+l)H :1,u FlOF BFFC CLB TlR CLEAR OVER FLOW FLAG M4 Flll SFED SEB OLLl J-1!) Fl13 B7FCFD BBC TlR, 0 EVENT OUTPUT LOW PULSE :\4H :14 ., Fl16 9FDE CLB Cl TIMER STOP Jl\U Fll8 60 RTS '.14\J :150 TMS1012: ;TMS101 OF TYPE_2CLIKE ONE-SHOT-PULSE) ]!jl Fll9 OFED SEB TMSlO ;SET MODE :1~,:~ FllB 3FED CLB TMS11 :~~:\ FllD 4FED SEB TMS12 :\!i4 FllF OFD7 SEB O,PORT3D SET EVENT PORT OUTPUT <-BBAAH-> ]:-,!) Fl21 3CAAFO LDM #SAA. TlL TlH I TlL --------- :\~,i; Fl24 3CBBF1 LDM #SBB, TlH ( BBH AAH ) :1!·,7 COUNT SOURCE CHANGE 3~i0 Fl27 6FED SEB Sl COUNT SOURCE • INT_PORT CLOCK :\!"t!I :\fill Fl29 9FED CLB OLLl :1nt Fl2B SFDE SEB Cl ; TIMER START :Hi:~ 3G:\ F12D 60 RTS > 'Tl 'Tl r t') > -4 0 z • M50745 ASSEMBLER v.2.01c • P. Ol! I•: ~;1•:(i. LOC. OBJ .. . ... • .... 1 .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. :164 .PAGE :'165 3nn *** MODE 6 (TMS=110s Programmable one-shot generation mode) The timer must be started after setting the port P30 to output and P60 to input, and setting value to timer and timer latch. When this :~tr/ mode is selected, the EV output port is initialized to "O". :~n" :~GU TMSl!O: :1·10 F12E lFED CLB TMS!O :111 Fl30 2FED ;SET MODE SEB TMSll :w~ Fl32 4Fli:D SEB TMS12 :n:1 Fl34 OFD7 SEB 0,PORT3D EVENT PORT OUTPUT_SET Ti4 Fl36 lFDD CLB 0,PORT6D :\"{!l Fl38 3C22F2 LDM ts22,RL1L :1·1r. F13B 3C33F3 RLlH I RLlL LDM #S33,RL!H ( 33H 22H :1"0 ; :nH Fl3E !FOE CLB IlP 379 Fl40 5FFC INTERRUPT PORARITY IS FALLING EDGE CLB llR CLEAR INTERRUPT REQUEST FLAG 380 Fl42 BFFC CLB TlR 381 Fl44 8FDE CLEAR OVER FLOW FLAG SEB Cl TIMER START 382 BBC llR, • 383 CATCH FALLING EDGE.ONE_SHOT_PULSE START BBC TlR, • CATCH TIMER OVERFLOW.ONE_SHOT_PULSE END. 384 Fl46 60 RTS ,. 'V 'V r- ,.-t t') 0 Ul z 0) • M50745 ASSEMBLER V.2.0lC • P. 012 E SEQ. LOC. OBJ .. . ... • .... l .... • .... 2 •••. • •••• SOURCE STATEMENT .... 5 •.•• •. 385 .PAGE 386 387 INITIAL SET FOR PULSE WIDTH MODULATER FUNCTION ••• 388 ......•........•.................•............•....•............... 389 In order to start the PWM function. set port P3 3 to output mode, select the mode (resolution), set the PWM register, and set the 390 PWME bit to "1". By setting the PWME to ''O'' or writing "O" to the PWM register, the PWM output will stop. 391 392 PWMOOO: ;SET FOR PWM 393 Fl47 6FD7 SEB 3,PORT3D ;SET PPORT3_3 OUTPUT 394 Fl49 3CAAEB LDM #SAA,PWML 395 Fl4C 3C55EC LDM IS55,PWMH 396 397 398 Fl4F 60 .................•••......••............•. RTS . PLUSE WIDTH MODULATER ••• 399 ........•................................. 400 PWM8 401 402 Fl50 BFDF CLB PWMM PWM MODE IS 8_BIT_MODE 403 Fl52 8FDF SEB PWME PWM START 1--- (CYCLE IS 51.2us) ---1 404 OUTPUT H-----------HL--------------L 405 PULSE I - 34 us - I - 17 . 2 us - I 406 CLB PWME PWM STOP 407 Fl54 60 RTS 408 409 PWM16: 410 Fl55 AFDF SEB PWMM PWM MODE IS 16_BIT_MODE 411 Fl57 8FDF SEB PWME PWM START 1--- (CYCLE IS 13.lms) ---1 412 OUTPUT H-----------HL--------------L 413 PULSE 1- 4.386 ms -1- 8.714 ms -I 414 Fl59 3CllEC LDM #Sll,PWMH CHANGE PWM's VALUE 415 Fl5C 3C22EB LDM 1$22,PWML PWM PULSE CHANGE FROM NEXT CYCLE 416 CLB PWME PWM STOP 417 Fl5F 60 RTS )lo "V "V r n )lo -I 0 z • M50745 ASSEMBLER V.2.0lC • P. 013 E :JEQ. LOC. OBJ .. . ... • .... l .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. 418 .PAGE 419 ......................................... 420 ••• A-D CONVERTER 421 ..•.•••.•..•.•...••.•........••.•........ 422 After writing the port number to ADCON, the A"D conversion will start through this port. The conversion completes in 19.Sµsec 423 when using 10MHz clock frequency. The ADCOMPR flag becoming ''1"' signals the A-D conversion completion. 424 425 ADOOO: 426 F160 A20'7 LOX IS07 427 ADOlO: 428 Fl62 BFFD CLB ADCOMPR CLEAR REQUEST FLAG 429 F164 8A TXA 430 Fl65 85E3 STA ADC ON SELECT A-D PIN AND START A-0 CONVERT 431 Fl67 B7FDFD BBC ADCOMPR,• CHECK CONVERT_END 432 Fl6A A5E2 LOA ADSR READ AD VALUE 433 Fl6C 9500 STA Wl,X 4:"l4 Fl6E CA DEX 435 Fl6F lOFl BPL ADOlO 436 Fl7l 60 RTS ,. '11 '11 r- ,.e:; -t ~ 0 ~ -....J z 00 • M50745 ASSEMBLER V.2.0lC • P. 014 E SEQ. LOC. 08.J •. . .•• • •••• 1 .••• • ••.• 2 •••• • •••• SOURCE STATEMENT .... 5 •.•• •. 437 .PAGE 438 439 ;•••······································ D-A CONVERTER 440 ;•••••···································· 441 442 ;••······································· ; By setting the D-A 1, 2 register, the D·A 1, 2 port outputs the corresponding voltage. The output voltage can be calculated as 443 ; (DAVref)-(D-A/256) [VJ 444 445 DAOOO: 446 F172 A900 LDA HOO 447 DA010: 448 F174 85EO STA D_Al (O_Al/256) • Vref [VJ OUTPUT 449 F176 85El STA D_A2 (0_A2/258) • Vref [VJ OUTPUT 450 .Fl78 3A INC A 451 Fl79 OOF9 BNE OAOlO 0 • 255 452 Fl7B 60 RTS 453 .NLIST 470 .LIST > 'V -... 'V n > -4 0 z • M~0745 ASSEMBLER V.2.0lC • P. 015 r' :;p;Q, LOC. OBJ .. . ... • .... 1 .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. 471 .PAGE •\72 4"1:1 ·174 FFEO 7CF1 ;••······································· .WORD SFFEO BRK .• BRK •1 ~,!j FFE2 7CF1 .WORD ADCOl'!P • ADCOMP ·l'fll FFE4 7CF1 .WORD Tl • TI 477 FFES 7CF1 .WORD' RI • RI 47U FFE8 7CF1 .WORD EV3 • EV3 4"f\l FFEA 7CF1 .WORD EV2 • EV2 ·1110 FFEC 7~1 .WORD EVl • EVl 411 l FFEE 7CF1 .WORD T3 • T3 4B!~ FFFO 7CF1 .WORD T2 • T2 40:~ FFF2 7CF1 .WORD Tl • Tl 4114 FFF4 7CF1 .WORD INT3 • INT3 4tl5 FFF6 7CF1 .WORD INT2 • INT2 486 FFFS 7CF1 .WORD lNTl • INTl 487 FFFA 7CF1 .WORD OSEI • OBE 488 FFFC 7CF1 .WORD !BF! • !BF 489 FFFE OOFO .WORD RESET • RESET 490 491 END 492 493 .END ERROR COUNT 0000 TOTAL LINE 0493 LINES COMMENT LINE 0147 LINES OBJECT SIZE 0413 BYTES ,,,,> r- (") > ::! 0 (0 z N 0 • M50745 ASSEMBLER V.2.0lC • P. 002 E SEQ. LOC. OBJ .. . ... • .... 1 .... • •... 2 ••.. • .... SOURCE STATEMENT .... 5 •..• •. 138 139 ;•••······································ ; ••• CLOCKED SERIAL 1/0 140 .......•.................................. 141 ; This program sets the work area for the clocked serial 1/0 of the sample program. 142 0000 FLAGS • SOO ;• 143 0,00 ERRFO • 0, FLAGS ;• 144 l,00 ERRFl • l, FLAGS ;• 145 2,00 ERRF2 • 2, FLAGS ;• 146 0001 BRGFLG3 • SOl ;"FLAGS SELECT BIT RATE(bps) 147 0,01 FB1250 • O,BRGFLG3 ; 0 1.25MHz 146 1. 01 FB250 • l,BRGFLG3 ;'250KHz when tosc • 10.0MHz 149 2,01 FB50 • 2,BRCFLG3 ;"50KHz 150 3,01 FBlO • 3,BRGFLG3 ;'lOKHz 151 4,01 FB25 • 4,BRGFLG3 ;'12.SKHz 152 5,01 FB12H • 5,BRGFLG3 ;"6.25KHz 153 6,01 FBS • 6,BRGFLG3 ;"2.5KHz 154 7,01 FB2H • 7,BRGFLG3 ;"1.25KHz 155 0003 WORK! • S03 ;• RECEIVER REGISTER 156 0009 WORKO • SOS : • TRANSMITTER REGISTER ,,,, )II r- e:; )II ~ 0 z • M50745 ASSEMBLER V.2.0lC • P. 003 E SEQ. LOC. OBJ .. . ... • .... 1. ... • •... 2 .... • .... SOURCE STATEMENT .... 5 .... • . 191 .PAGE 192 193 ;••······································· SERIAL l/0 194 .•..•••.......•............•.••.•.....•.•. 195 ; This program shows the CPU receives 1 byte data via the clocked serial 1/0. The received data is stored in memory WORK I. 196 197 198 F041 3C80D7 RCVOB: LDM IS80, PORT3D • %10000000 • PORT3D ------1 Srdy I··--·-> 199 • SET S!OCON %11100110 Selk 1<------ 200 F044 EFES SEB SIOEN • ENABLE SERIAL I/O Si 1<------ 201 F046 CFE8 SEB UAR_CIO • ENABLE CLOLKED SERIAL (hardware) 202 F046 AFE6 SEB RE ' ENABLE RECEIVER 203 F04A 4FE6 SEB SREADYE • ENABLE SREADY OUTPUT 204 F04C 2FE8 SEB BRG_EXC • SELECT EXC_CLOCK 205 F04E 3COOE6 LDM ISOO,RB TB • WRITE DUMl'lY DATA AND Srdy IS CLEARED LOW 206 FOSl 77FDFD BBC R!R, • - • RIR • 1 ? •• (RBE • l ?J 207 F054 ASE6 LDA RB TB • READ RB_TB 206 F056 6503 STA WORK! 209 FOSS 7FFD CLB RIR 210 FOSA FFEB CLB SIOEN 211 FOSC 60 RTS 212 )lo "a "a r n )lo ::! Q !::::l z N N • M50745 ASSEMBLER v.2.01c • P. 004 E SEQ. LOC. OBJ .. . . . • • .... 1 ••.• • •••. 2 .•.. • .••. SOURCE STATEMENT .... 5 .... •. 213 .PAGE 214 ····················~···················· 215 ••• SERIAL 1/0 216 ..•..•.........•......................... 217 ; This program shows the CPU transmits 1 byte data via the clocked serial 110. The transmitted data must be set in memory 218 : WORKO before the transmission. 2l!l TRN08: -----, 220 221 222 FOSD 3C80D7 F060 1FE8 ; LDM CLB U60,PORT3D FOSC2_8 . • %01100000 • PORT3D • fosc I (2°4} Selk 1------> So 1------> INT I<------ Srdy 223 ; • when foec • 10 MHz 224 F062 3COOEA LDM UOO,BRG • SET 1 . 25MHz 225 ; • SET SIOCON %11010000 226 FOBS lFDD CLB O,PORT6D • P6_0 IS INPUT PORT 227 F067 EFES SEB SIOEN • ENABLE SERIAL 1/0 228 F069 CFE8 SEB UAR_CIO 0 ENABLE CLOLKED SERIAL 229 F06B 3FE8 CLB BRG_EXC • SELECT BRG_CLOCK 230 FOGO 8FE8 231 F06F 9FFO SEB CLB TE TIR . CHECK INT PORT ' ENABLE TRANSMITTER 232 F071 07DCFD 233 F074 8509 234 F078 85E6 BBS LOA STA O.PORTB,• WORKO,X RB_TB .° • SET RB_TB 235 F078 97FDFD BBC TIR. • • TIR • 1 ? •• (TBE - 1 ?) 236 F07B 9FFD CLB TIR 237 F070 FFE8 CLB SIOEN 238 F07F 60 RTS ,,,,> r- n > ~ 0 z • M50745 ASSEl'!BLER V.2.0lC • P. 005 E SEQ. LOC. OBJ •. · · •. • ...• 1. .•• • ..•• 2 •••. • ••.• SOURCE STATEMENT ••.• 5 .••. •. ~:19 .PAGE 240 241 ;•········································ : ••• SERIAL 1/0 242 243 ;•········································ ; This 2 pages program transmits and receives 2-byte data in the full-duplex method. Send the transmitted data to WORK and 244 ; WORK+1 memories and select the baud rate flags (FB1250~FB2H), then execute the SERIALOO program. This page shows the 245 ; initial value and baud rate setting. ... ~4l1 I 24'! SERIALOO: So 1--->--1 248 F080 lFOO Ct.B ERRFO 249 250 F082 3FOO F084 SFOO CLB Ct.B ERRFl ERRF2 . Sin I I 1---<--' I 251 252 253 F086 3CE007 F089 3COOFO FOSC OFE8 LOM LOM SEB ISEO, PORT30 ISOO, IRQ2 FOSC2_8 .• %11100000 • PORT30 • rose / (2"4"4Y (hardware) 254 255 256 F08E F70105 F09l 3CF9EA SERIALOl: BBC LOM FB2H,SERIAt.02 ISF9,BRG .• when fosc • 10 MHz • SET 1 . 25KHz 257 F094 8030 BRA SERI ALEN 258 SER!At.02: 259 F096 070105 BBC FBS,SER!Al.03 260 F099 3C7CEA LOM 117C,BRG ; • SET 2. 5KHz 261 F09C 8035 BRA SERI ALEN 262 SERIAl.03: 263 F09E B70105 BBC FB12H,SERIAL04 264 FOAl 3C31EA LOM IS31.BRG :• SET 6.25KHz 265 FOA4 8020 BRA SERI ALEN 266 SERIAl.04: 267 FOA6 970105 BBC FB25,SERIALOS 268 FOA9 3C18EA t.OM IS18,BRG ;• SET 12.5KHz 269 FOAC 8025 BRA SERI ALEN 270 SERIAt.05: 271 272 273 FOAE 1FE8 FOBO 770105 FOB3 3C7CEA CLB BBC LOM FOSC2_8 FBlO,SERIAl.06 IS7C, BRG .. ; • fosc I ( 2 • 4) ; • SET lOKHz 274 FOBS 801B BRA SERI ALEN 275 SER!At.06: 276 FOBS 570105 BBC FB50,SERIAL07 277 FOBB 3Cl8EA LOM IS18,BRG ; • SET 50KHz 278 FOBE 8013 BRA SERI ALEN 279 SER!At.07: 200 FOCO 370105 BBC FB250,SERIAL08 201 FOC3 3C04EA LOM IS04,BRG ; • SET 250KHz 282 FOC6 8008 BRA SERI ALEN 283 SER!Al.08: 264 FOCB 170105 BBC FB1250,SERIAL09 205 race 3COOEA t.OM 1100,BRG : • SET 1. 25MHz 286 FOCE 8003 BRA SERI ALEN 287 SER!Al.09: .... I~ ,, 288 FODO OFOO SEB ERRFO 209 F002 60 RTS r- (') > ~ l'0 0 w z N ~ • M50745 ASSEMBLER V.2.0lC • P. 006 E SEQ. LOC. OBJ .. . ... • .... 1 .... • •... 2 .... • .... SOURCE STATEMENT ..•. 5 .... •. 290 .PAGE 291 ; This program transmits 2-byte data and at the same time receiving the 2-byte data in full-duplex. 292 293 SERIALEN: ;• SET SIOCON x1111x1.xx. (X IS SELECT_BIT) 294 F003 EFES SEB SI OEN 295 FOOS CFEB SEB UAR_CIO 296 FOD7 AFE8 SEB RE 297 FOD9 8FE8 SEB TE 298 FODB 4FE8 SEB SREADYE 299 ; 300 FOOD 9FFD CLB TIR 301 FODF A509 LOA WORKO 302 303 304 FOEl 85E6 FOE3 97FDFD ; STA BBC RB_TB TIR, • .. ;• SET RB_TB ;• TIR • 1 7 •• (TBE • 1 7) 305 FOES 9FFD CLB TIR 306 FOES ASOA LOA WORKO•l 307 308 FOEA 85E6 ; STA RB_TB .. ;•SET RB_TB AND TBE IS CLEARED AUTOMATICALLY 309 310 FOEC 71FDFD FOEF 7FFD FOFl A5E6 BBC CLB LOA RIR, • RIR RB_TB ..;•;• RBF RIR • l 7 •• (RBF • 1 IS CLEARED ?) 311 AUTOMATICALLY 312 FOF3 8503 STA WORK I 313 ; 314 FOFS C509 CMP WORKO 315 FOF7 F002 BEQ SERIAL20 316 FOF9 2FOO SEB ERRFl 317 SERIAL20: 318 FOFB 77FDFD BBC RIR, • ;• RIR • 1 7 319 FOFE A5E6 LOA RB_TB ;• RBF IS CLEARED AUTOMATICALLY 320 F100 8504 STA WORKI+l ::521 Fl02 C50A CMP WORKO•l 322 Fl04 F002 BEQ SERJAL30 323 Fl06 4FOO SEB ERRF2 324 SERIAL30: 325 Fl08 FFE8 CLB SJOEN 326 FlOA 60 RTS ,,,,> ,... (') > ::! 0 z • M50745 ASSEMBLER V.2.0lC • P. 004 E SEQ. LOC. OBJ .. . ... • .... 1 .... • .... 2 .... • .... SOURCE STATEMENT .... 5 .... •. 235 .PAGE 23fj 23'f ;••••····································· SERIAL I/O 238 ..•.•...................................•. 239 : This program transmits 1-byte data. Before execution, the transmitted data must be set in WORKO. 240 ~41 SI008: (hardware) 242 F09A 3CEOD7 LDM ISEO, PORT30 • %11100000 • PORT30 I 243 : So 1------> 244 F090 1FE8 CLB FOSC2_8 • fosc I ( 2 • 4) Selk !·-----> 245 : • when fosc • 10 MHz !~46 F09F 3COOEA LDM ISOO,BRG • SET l. 25MHz 247 : • SET SIOCON %11XlXXXX (X IS SELECT_BIT) 248 FOA2 EFES SEB SIOEN • ENABLE SERIAL l/0 249 FOA4 CFE8 SEB UAR_CIO • ENABLE CLOL.KED SERIAL 250 FOA6 8FE8 SEB TE • ENABLE TRANSMITTER 251 FOA8 SFEB SEB TIC • SET INTERRUPT REQUEST FROM TSC 252 FOM 9FFD CLB TIR 253 FOAC A515 LOA WORKO 254 FOAE 85E6 STA RB TB • SET RB_TB 255 FOBO 97FDFO BBC TIR,. • TIR • 1 7 •• (TSC • 1 7) 256 FOB3 9FFD CLB TIR 257 FOB5 FFE8 CLB SI OEN 258 FOB7 60 RTS 259 .NLIST ,,r,,> (') > :::! ~ 0 01 z N 0) • MS0745 ASSEMBLER V.2.0lC • P. 008 E SEQ. LOC. OB.J .. . . . . • .••. 1. .•. • •... 2 .... • .... SOURCE STATEMENT .... 5 .... . 350 .PACE 351 .......................................... 352 ; ••• SERIAL 1/0 353 .......................................... 354 '. This program transmits 32-bit data continuously. Before the execution, the transmitted data must be set in WORKO to WORK0+3. 355 356 SI032: ;. (hardware) 357 358 359 F127 3CEOD7 F12A 1FE8 ; LDM CLB llEO,PORT3D FOSC2_8 .. ; • %11100000 • PORT3D ;• rose/ (2"4) So I 1------> Selk 1------> 360 ; ;•when rose - 10 MHz 361 F12C 3COOEA LDM #SOO,BRC ; • SET 1 . 25MHz 362 ; ;• SET SIOCON .UlXlXXXX (XIS SELECT_BIT) 363 F12F EFES SEB SIOEN ;• ENABLE SERIAL 1/0 364 F131 CFE8 SEB UAR_CIO ; • ENABLE CLOLKED SERIAL 365 F133 8FE8 SEB TE ; • ENABLE TRANSMITTER 366 F135 A203 LOX #S03 367 SI033: 368 F137 8509 LDA WORKO,X 389 F139 85E6 STA RB_TB ;• SET RB_TB(when 8 bits) 370 F13B CA DEX 371 F13C B509 LOA WORKO,X 372 F13E 85E6 STA RB_TB ;• SET RB_TB(when 16 bits) 373 F140 CA DEX 374 Sl034: 375 F141 8509 LDA WORKO,X 376 F143 17E7FD BBC TBE, 0 377 F146 85E6 STA RB_TB ;• SET RB_TB(when 24,32 bits) 378 Fl48 CA DEX 379 F149 10F6 BPL SI034 380 Fl4B 57E7FD BBC TSC,• 381 F14E FFE8 CLB SIOEN 382 F150 60 RTS ,,,,,.. r- ,.. n -I 0 z • M50745 ASSEMBLER V.2.0lC • P. 002 E SEQ. LOC. OBJ .. . ... • •.•. l •... • .... 2 •..• • .... SOURCE STATEMENT .•.. 5 ...• • . 138 139 ... ;••······································· UART TYPE SERIAL 1/0 140 ;•········································ 141 142 ... This program sets the work area for UART of sample program. . soo ... 0000 WORK! 143 0002 WORKO S02 .. ; ..... 144 0004 FLAGS S04 145 146 l47 0,04 1.04 2,04 ERRFO ERRFl ERRF2 .. O,FLAGS 1,FLAGS 2,FLAGS ; 14A 140 U>O 0005 3,05 4,05 UES UESOE UESPE ... sos 3,UES 4,UES ..... ;"UART ERROR STATUS ; . .. ... 1 !"1 l 5,05 UESFE 5,UES l!i?. 6,05 UESSE 6,UES 153 0006 BRGFLG sos ;"FLAGS SELECT BIT RATE(bps) 154 0,06 FB3 O,BRGFLG 300 ... ; 0 155 1,06 FBS 1, BRGFLG ; 600 0 when fosc • 9.83041'1Hz tr.o 2,06 FB12 2,BRGFLG ;•1200 157 3,06 FB24 3,BRGFLG 2400 ... ; 0 158 4.06 FB48 4,BRGFLG ; 0 4800 150 5,06 FB96 5,BRGFLG ; 9600 0 160 6,06 F8192 6,8RGFLG 19200 llll 7,06 F8384 . 7 ,8RGFLG .. ; ; 0 38400 0 1(12 1113 104 0007 0,07 1.07 8RGFLG2 • 1"8768 1"81536 .. 107 0,8RGFLG2 l ,8RGFLG2 ; 76600 0 153600 CONTINUE 105 2,07 F83072 . 2,BRGFLG2 ; ; 0 307200 0 166 1Cl7 100 7,07 0008 0,08 FPEV_OD • UARTDF FUF701 .. 7,8RGFLG2 •08 O,UARTDF ;"THIS FLAG SELECTS ODD PARITY OR OR EVEN ONE. ;"FLAGS SELECT UART DATA FORMAT 1.7.0.l 169 1.08 FUF711 .. 1,UARTDF ; 0 ; 1.7.1.1 0 170 2,08 FUF702 2,UARTDF 1.7.0.2 ... ; 0 171 3,08 FUF712 3,UARTDF ; 1.7.1.2 0 172 4,08 FUF801 4,UARTDF ; 0 1.8.0. l 173 5,08 FUF811 5,UARTDF 1.8.l.1 174 6,08 FUF802 .. 6,UARTDF ; 0 : ·1.a.0.2 175 7,08 FUF812 7,UARTDF ; 0 1.8.l.2 176 ; Changing the address of the flags to port address causes the port input signal to define the UART's baud rate 177 : and transmission format. ,,,, )lo r- (") )lo ::! N 0 '-I z • M50145 ASSl!l'IBLER ~.2.0lC • N 00 I F. SEQ. LOC. OBJ •• . P. 003 .... .• •.• 1 .•.. .•••• 2 •••• . ••• SOURCE STATE:MENT .... S•... •. 240 .PAGE 247 248 249 ... ;••······································· UART TYPE SERIAL l/0 ;•••······································ 250 251 ; This 3 pages program shows the 2-byte data transmission and receiving program in the fuH-duplex method. Before executing the 252 ; program UARTSOO, set the transmitted data to WORK, WORK+ 1, the baud rate flags ( FB3- FB3072) and UART format flags 253 ; (FUF701-FUF812). This program page sets the UART's bit rate with the flags. 254 255 UARTTSOO: .... 256 257 258 1"074 11"04 F076 OFE8 F078 170605 CLB SEB BBC ERRl"O FOSC2 8 FB3,UARTTS01 .... 259 1"07B 3CFFEA LDM ISFl",BRG ;: 300bps SET ... 260 F07E 8052 BRA UARTTSEN 261 UARTTSOl: ; 262 F080 370605 BBC l"B6,UARTTS02 263 1"083 3C7FEA 264 F086 804A LDM BRA IS7F,BRG UARTTSEN .... ;• 600bps SET 265 266 F088 570605 UARTTS02: BBC l"Bl2,UARTTS03 .. 267 1"08B 3C31"EA 268 1"08E 8042 LDM BRA U3F,BRG UARTTSEN .... ;• l,200bps SET 269 270 1"090 770605 UARTTS03: BBC LDM l"B24,UARTTS04 ISlF ,BRG .. 271 F093 3ClFEA ;: 2,400bps SET .... 272 1"096 803A BRA UARTTSEN 273 UARTTS04: 274 F09.8 970605 BBC FB48,UARTTS05 275 1"09B 3COl"EA 276 F09E 0032 LDM BRA ISOl",BRG UARTTSEN .... ;• 4,800bps SET 277 270 l"OAO B70605 UARTTS05: BBC FB96,UARTTS06 .. 279 FOA3 3C07EA LDM IS07 ,BRG .. ;• 9,600bps SET .... 280 FOA6 802A BRA UARTTSEN 281 UARTTS06: 2B2 FOA8 070605 BBC FB192,UARTTS07 ...... 2B3 FOAB 3C03EA LDM IS03,BRG ;• 19,200bps SET 284 FOAE B022 BRA UARTTSEN 285 UARTTS07: 2B6 FOBO F70605 BBC FB384,UARTTSOB 287 FOB3 3C01EA 200 l"OB6 801A LDM BRA ISOl.BRG UARTTSEN .... ;• 3B,400bps SET ....• 209 UARTTSOB: 290 FOBS 1FE8 CLB FOSC2_8 291 FOBA 170705 BBC l"B768,UARTTS09 292 FOBD 3C03EA LDM U03,BRG ;: 76,BOObps SET 293 FOCO 8010 294 UARTTS09: BRA BBC UARTTSEN FB1536,UARTTS10 .... 295 FOC2 370705 296 FOCS 3C01EA 297 FOCB BOOB LOM BRA ISOl ,BRG UARTTSEN .... ;• 153,600bps SET .,,.,,> 298 299 FOCA 57070B UARTTSlO: BBC FB3072, UARTTSll .. ,... 300 FOCD 3COOEA LDM ISOO,BRG • 307,200bps SET -> ... 301 FOOO 8000 BRA UARTTSEN n 302 UARTTSEN: 303 FOD2 20DBFO JSR UART ::! 304 305 FOOS OF04 306 F007 60 \JARTTSll: SEB RTS ERRFO . 0 z • MS0745 ASSEMBLER V.2.0lC • P. 005 E SEQ. LOC. OBJ. . . ... • ... , 1. ... • .... 2 .... • .... SOURCE STATEMENT .... S .... • . 307 .PAGE 308 : This program sets the UART's transmission format with the flags. 309 ;••······································· 310 UART SUBROUTINE 311 :••••••••••••••••••••••••••••••••••••••••• (START-BIT . CHAR[7,8] . PARITY[0,1] 312 UART: ; • . STOP-BIT[l,2]) [ ,ODD,EVEN] 313 UART701: 314 FODB 170805 BBC FUF701,UART711 315 FODB 3C01E9 LDM #SOl,UACON ;• UACON SET %0001 316 FODE 8038 BRA UARTEN ·• (1.7.0.l) 317 UART711: 318 FOEO 370805 BBC FUF711,UART702 319 FOE3 3C03E9 LDM #103,UACON ;• UACON SET %0011 320 FOES S02E BRA UARTPA ·• (1.7.1.1) EVEN 321 UART702: 322 FOES 570805 BBC FUF702,UART712 323 FOES 3C09E9 LDM #109,UACON ;• UACON SET %1001 324 FOEE S02B BRA UARTEN ·• (1.7.0.2) 325 UART712: 32S FOFO 770805 BBC FUIP'712,UART801 327 FOF3 3COBE9 LDM 1108,UACON ;• UACON SET %1011 328 FOF6 801E BRA UARTPA ·• (1.7.1.2) EVEN 329 UART801: 330 FOF8 970805 BBC FUF801,UART811 331 FOFB 3COOE9 LDM #SOO,UACON ;• UACON SET %0000 332 FOFE 8018 BRA UARTEN :• (1.8.0.l) 333 UART811: 334 FlOO B70805 BBC FUF811,UART802 335 F103 3C02E9 LDM 1102,UACON ;• UACON SET %0010 338 F108 BOOE BRA UARTPA ;• ( 1. 8. 1.1) EVEN 337 UART802: 338 F108 D70805 BBC FUF802,UART812 339 FlOB 3C08E9 LDM 1108,UACON ;• UACON SET %1000 340 FlOE 800B BRA UARTEN :• (1.8.0.2) 341 UART812: 342 FllO F7080B BBC FUF812,UART822 343 F113 3COAE9 LDM HOA,UACON ; • UACON SET %1010 344 UARTPA: 345 F118 F70702 BBC FPEV_OD,UARTEN 346 F119 4FE9 SEB EVEN OD ; •PARITY IS ODD 34 7 UARTEN: - 348 FllB 2021Fl JSR UARTlO 349 UART822: 350 FUE OF04 SEB ERRFO 351 F120 80 RTS ,,r->.,, (') > :::! N 0 (0 z w C) • M50745 ASSEMBLER V.2.0lC • P. 006 E SEQ. LOC. OBJ .. . . . . . . . . . . 1. ... . ... 2 •... . .... SOURCE STATEMENT .... 5 .... • . 352 .PAGE 353 ; This ·program shows the 2-byte data tiansmission and receiving program in the full-duplex method. 354 UARTlO: ;•UART SET XlOllOOOX • SIOCON TxD 1-->--I 355 Fl21 3CAOD7 LDM UAO,PORT3D %10100000 • PORT30 0 I I 356 Fl24 EFES SEB SI OEN ;• ENABLE SERIAL I/0 RxD l--<--1 357 Fl26 OFE8 CLB UAR_CIO ;• ENABLE CLOLKEO SERIAL I 358 Fl28 AFES SEB RE ;•ENABLE RECEIVER (hardware) 359 Fl2A 8FE8 SEB TE ; • ENABLE TRANSMITTER ...... 360 Fl2C 3C0005 LDM ISOO,UES 361 Fl2F 3F04 CLB ERRFl 362 Fl31 5F04 CLB ERRF2 363 364 Fl33 A502 365 Fl35 65E6 ; LDA STA WORKO RB_TB .. ; • SET RB_TB 366 367 Fl37 17E7FD 368 F13A.A503 ; BBC LOA TSE,• WORKO+l .. 369 F13C 85E6 STA RB_TB ; • SET RB_TB ...... 370 UART12: 371 Fl3E 37E7FO BBC RBF, • 372 Fl41 D7E704 BBC SE.UART120 373 Fl44 A5E7 374 F146 8505 LDA STA SIOSTS UES .... .... 375 UART120: 376 Fl48 A5E6 LDA RB_TB 377 F14A 6500 STA WORK I 378 Fl4C C502 CMP WORKO 379 F14E F002 SEQ UART13 360 Fl50 2F04 SEB ERRFl 381 382 Fl52 A903 383 Fl54 25E7 UART13: LOA ANO #$03 SIOSTS .. 384 Fl56 85E7 STA SIOSTS ;•WRITE DUMMY DATA AND CLEAR ERROR_FLAGS 385 F158 37E7FD 386 l'15B A5E6 BBC LOA RBF,• RB TB .. 387 F150 8501 388 Fl5F C503 STA CMP WORKI+l WORKO+l .. 389 F161 F002 390 Fl63 4F04 391 UART14: BEQ SES UART14 ERRF2 .. 392 Fl65 206BF1 JSR UART_E_C :• CHECK UART ERROR 393 Fl68 FFE8 394 Fl6A 60 CLB RTS SIOEN .. )> '11 '11 r- (") )> :::! 0 z • M50745 ASSEMBLER V.2.0lC • P. 007 I!: SEQ. LOC. OBJ •. . ... • .•.• 1. ••. • ..•. 2 •••. • •••• SOURCE STATEMENT .••• 5 • , •. • . 395 •PACI!: 396 ; This program examines the errors of the received data. 397 UART_E_C: ; ' CHECK UART ERROR 398 1'169 270410 BBS ERRFl,ERROR ;• 399 F16C 47041A BBS ERRF2,ERROR ;• 400 FlBF C7E717 BBS SE.ERROR ;' SE • 401 1'172 A7E714 BBS FE, ERROR ;• FE • 402 Fl 75 87EJ11 BBS PE, ERROR ;• PE • 403 F178 87E70E BBS OE, ERROR ;• OE • 1 7 404 F17B C7050B BBS UESSE,ERROR ;• FIRST SE • 405 Fl7E A70508 BBS UESFE,ERROR ;• FIRST FE • 406 Fl81 870505 BBS UESPE,ERROR ;• FIRST PE • 407 Fl84 670502 BBS UESOE,ERROR ;' FIRST OE • 408 F187 8010 BRA NOERROR ;• 409 ;••·······································.. .... 410 ERROR: 411 Fl89 17DCFD BBC O.PORTS,ERROR ; INT ON 7 412 F18C 2200 JSR ¥Tl00m WAIT 100 DIS 413 F18E 17DCF8 BBC O,PORT6,ERROR .. ; INT ON 7 ...... 414 ERRORl: 415 F191 07DCFD BBS O,PORT6.ERROR1 INT ON 7 416 F194 2200 JSR ¥T100m WAIT 100 DI& 417 F196 07DCF8 .. BBS O.PORT6,ERROR1 INT ON 1 418 NOERROR: 419 Fl99 60 RTS ,.. .,,.,, r- ,.. (") :::! 0 ~ z w N • N50745 ASSE1'181..E1'1 V.2.0lC • P. 002 g SEQ. LOC. OBJ •. • ••0 . . .••• 1 •.•. • . . • 2 .••• • ..•• SOURCE STATEl'IENT .••. 5 •.•• • • I .NLIST 140 .LIST 141 142 0003 .. ; This program sets the work area for the multiply/divide calculation. n 103 143 144 145 0008 0000 OOOF Wl W2 DIVISOR • . 108 SOD IOF 146 0010 SP .. •10 147 0015 XO 115 148 . NLIST 171 .LIST 172 ; This program divides n-byte data with 1-byte data (DIVISOR). The dividend is stored in then-byte memories which. start from 1·r3 ; address W1. The quotient is stored in the n-byte area which starts from address W2. Also, the surplus data 1s stored m address W1. 174 ; "n" must be: 175 ; :fl:n=1 when 8 bits/8 bits 176 ; 16 bits/8 bits :fl:n=2 when 177 178 DIVM: :fl:n=3 when 24 bits/8 bits I : I 179 F021 A900 LOA 10 ;(2) Wl 1---------------1 100 •11---------------1 1111 F023 A202 ; * l.DX ln-1 ; (2) •21---------------1 1---------------1 l n:~ DIVl: lllJ F025 9509 STA Wl•l ,X ;(5) 1---------------1 llM F027 A50F l.DA DIVISOR ;(3) I : I 111:1 1'029 E208 DIV Wl,X ; (16) W2 1---------------1 llltl F020 9500 STA W2,X ;(5) •11---------------1 IW/ F02D 68 Pl.A ; (4) •21---------------1 lflH V02E 49FF EOR llFF ; (2) 1---------------1 11111 F030 9508 STA Wl.X ; (5) 1---------------1 \Ill) 1"032 CA DEX ;(2) I I 1111 F033 lOFO BPl. DIVl ;(2/4) DIVISORl---~-----------1 I tt:~ !'035 60 RTS ; (6) 1---------------1 JIU ; : I : I llM ; The execution time as the calculation of n-byte division: 46 (n-1 )+54 me (n~1) > 'V 'V r- t') > ::! 0 z • Mf•0745 l\SSEltlll.ER V.2.0lC • P. 003 E 5EQ. LOC. OBJ •. . ..• • .•.• 1 .•.• • •..• 2 ..•. • .•.• SOURCE STATEMENT .... 5 ...• •. l!l5 .PAGE l!l6 o-1 197 196 This program shows ~ aiXi (1 ::;;n::;;64). i=O 199 200 "X" is a variable which specifies RAM area (Xo-Xn- 1 ), "a" is a constant which specifies ROM area (ao-an-1). All are 8-bit data. 201 The result is stored in the 3-byte data specified by address SP. 202 : When setting "n", #n of the* part must be in the specified condition. 203 SOFP: 204 F036 3C0010 LDM ISOO,SP (4) RAM 205 F039 3C0011 LDM ISOO,SP+l (4) 1---------------1 XO 206 F03C 3C0012 LDM ISOO,SP•2 (4) 1---------------1 Xl 207 200 F03F A202 * LDX Jn-1 (2) 1---------------1 I : I 209 SOFPl: Xri-1 1---------------1 210 F041 BD5AFO LDA ao.x (4) 1---------------1 211 F044 6215 MUL xo.x (15) I I 212 F046 16 CLC (2) I I 213 F047 6510 ADC SP (3) SP 1---------------1 214 1'049 6510 STA SP (4) •l 1---------------1 215 F04B 68 PLA (4) +2 1---------------1 ~lG :~ l 7 F04C 6511 1'04E 8511 ADC STA SP•l SP+l (3) (4) 1---------------1 I I ;!10 F050 A512 LOA SP+2 (3) ••• ROM •• :!10 ~·os2 6900 ADC uoo (2) 1---------------1 AO 2:!0 F054 8512 STA SP•2 (4) 1---------------1 Al 221 222 F056 CA F057 10E8 DEX BPL SOFPl (2) (2/4) 1---------------1 I : I 22:1 F059 60 RTS (6) An-1 !---------------! :?:!4 :!2!) aO: 1---------------1I I 226 FOSA 01020304 .BYTE 1.2,3,4,5,6,7,8 ; any F05E 05060706 227 F062 OBOCODOE .BYTE 11,12,13,14,15,18,17,18 F066 OF101112 228 ~·o6A 151111718 .BYTE 21,22,23,24,25,26,27,28 F06E 191A1BlC 229 F072 1F202122 .BYTE 31,32,33.34,35,36,37,36 F076 23242526 230 F07A 292A282C .BYTE 41,42,43,44,45,46,47,48 F07E 2D2E2F30 Z31 FOB2 33343538 .BYTE 51,52,53,54,55,56,57,58 FOBS 3738393A 232 F08A 3D3E3F40 .BYTE 61,62,63,64,65,66,67,68 1'08E 41424344 233 F092 4748494A .BYTE 71, 72, 73;14, 75, 76, 77, 78 1'096 4B4C4D4E 234 ; The execution time is shown as: 52 (n-1 )+?Orne (n~O) here n is the calculation time. ,. '11 '11 r- ,. n :::! w 0 w z ~ • M50745 ASSEMBLER v.2.01c • p; 003 E SEQ. LOC. OBJ •• . ... • .... 1. .•. • ..•. 2 •••• • •••• SOURCE STATEMENT •••• S • ••• • • 199 200 MASTER SLAVE 201 ------, r------- I~---------->II P67/W 202 2UJ WR _ _ 204 ~m5 ,..----, 166/R 207 :mo M37450S-P'P A15-AlJ I -> I... DECODER ____ .,1---> I 65/CS I M374501'12-XXXSP ;:no M 1-----------> P~MO I 210 ?.11 212 D7-DO --------' I<----~----> II... ______ p s _ 21J 214 (hardware) 215 ,,,,> r (') > -I 0 z ' M50745 ASSEMBLER V.2.0lC ' P. 002 E SEQ . LOC. OBJ .. . ... ' .... 1 .... ' .... 2 .... ' .... SOURCE STATEMENT .... 5 .... '. 141 : This program sets the work area for the master microcomputer data 110 buffer. 142 0000 WCOM • SOO ' 143 o.oo FAO • O,WCOM ' USER SELECT FLAG l • CO!'!MAND , 0 • DATA 144 0010 WCMD • SlO ' CO!'!MAND DATA WORK AREA 145 0020 WDAT • S20 • DATA WORK AREA 146 2000 MOAT • S2000 • SLAVE's DATA ADDRESS 147 2001 MCMD • S2001 • SLAVE's COMMAND ADDRESS 148 SFOOO ' 159 ; This is the data bus buffer l/O sample program of the master microcomputer. 160 ; This part is the main routine. It also shows the 1-byte read/write. 101 1"006 CFDF SEB ROYE ; ' MASTER HARD WAI·T (WHEN lOMHz) 102 FOOO 3COODD LDM ISOO,PORTSD ;' !fl3 FOOB 3COOFE LDM noo. ICONl ;• 164 FOOE 3COOFF LDM #S00,ICON2 ;' ... 165 FOll 3COOOO LDM ISOO,WCOM ·' 166 MAS: 167 F014 07DCFD BBS O,PORT6,' lCiO ltHI 1"10 F017 201DFO FOlA 80F8 FOlC 42 JSR BRA STP RDWR MAS .. > -a -a r n > ~ w 0 Ul z w en • M50745 ASSEMBLER v.2.01c • P. 003 E SEQ. LOC. OBJ •. . . • . • .... 1 .... • .... 2 .... ' ...• SOURCE STATEMENT .... 5 .... •. 172 ; This part is the routine which the slave microcomputer reads and writes. 173 RDWR: . ;• ... 174 FOlO A00120 LDA MCMD ·' READ 12001 1'75 F020 8500 STA WCOM ; 176 177 170 F022 0304 F024 330A BBS BBC O,A,RO l,A,WR .. ; • SLAVE JS REQUESTING OUTPUT 179 160 101 F026 8017 F028 A00020 RD: BRA LDA RDWREND MOAT . •' READ 12000 105 io11 F02C 8520 F02E 800F STA BRA WDAT RDWREND .. · ' STORE WORK AREA ... 107 WR: ·•MASTER WRITE SLAVE 188 F030 070007 BBS FAO,WRCMO ; 189 F033 A520 LOA WDAT 190 191 192 F035 800020 F038 8005 WRCMD: STA BRA MOAT RDWRENO .. ;' WRITE $2000 ·'SLAVE REQUEST COMMAND 193 F03A A510 LDA WCMO 194 195 F03C 800120 RDWRENO: STA RTS MCMO .... ·' WRITE S2001 196 F03F 60 ,. 'V 'V r ,. (") ~ i5 z • M50745 ASSEMBLER V.2.0lC • P. 002 E SEQ. LOC. OBJ .. . ... • .... 1. ... • .... 2 ...• • .... SOURCE STATEMENT .... 5 .... • . 141 ~ This program sets the work area of the slave microcomputer's 1/0 data bus buffer. 142 143 0000 WCMD 100 COl'll'IANO DATA WORK AREA 144 0010 WDAT 110 DATA WORK AREA 145 SFOOO lf>5 ; This is the data bus buffer 1/0 sample program of the slave processor. This part is the main routine. It also shows lGG ; the 1-byte read/ write. 1G7 FOlE 3C08DC LDM IS08,PORT6 1Gl1 F021 3C08DD LDM ISOB,PORTSD SET ?63/Prdy OUTP\IT ll\!l 1'024 7FDF CLB DBBM 60 MODE no 1'026 4FDF SEB DBBE SET DATA BUS BUFFER(OBB) 171 SLV: 172 FOZB 37E506 BBC !BF ,SLVl 173 F02B 203FFO JSR IN INPUT 1 BYTES l"f7 SLVl: !"Ill F031 07E5F4 BBS OBF,SLV 1"10 F034 203AFO JSR O\IT O\ITPUT 1 BYTES 100 F037 BOEF BRA SLV 181 F039 42 ST? 102 ; This routine outputs data to the data bus buffer 103 OUT: 104 F03A A510 LOA WOAT 105 F03C 05E4 STA DBS OBF ON 106 F03E 60 RTS IR·r ; This routine inputs data from the data bus buffer. 100 IN: 109 F03F 67E506 BBS AO, INOlO !!JO F042 A5E4 LOA OBB Hll F044 8510 STA WOAT !!~~ F046 8004 BRA INOZO l\13 INOlO: STORE COl'll'IANO l!l4 F048 A5E4 LOA 088 195 F04A 6500 STA WCMD lflfi IN020: l ll'T F04C 60 RTS .,,.,,> r- C') > .... w 0 '-l z APPLICATION Sine-wave output by D-A conversion function. The next program samples the value from the ROM table's data every 1/32 period, and outputs the data to ports D-A 1 and D-A2 through D-A conversion. The figure shown below shows the expected sine-wave. 1. 0 one period 320µs (3. 125kHz) 138 APPLICATION ROM data N : counter value y sin(90°XN/B)+1 LIY=Y-Y' 2 N Y (calculated value) data (HEX) . Y' (set value) JY .. -- --~-··--·--- 0 0. 5 80 0. 5 0 1 0. 598 99 0. 598 0 2 0. 692 81 0. 691 0. 001 3 0. 778 C7 0. 777 0. 001 4 0. 854 DA 0. 851 0. 003 5 0. 916 EA 0. 914 0. 002 6 0. 962 F6 0. 961 0. 001 7 0. 990 FD 0. 988 0. 002 8 1 FF 1 1 9 0. 990 FD 0. 988 0. 002 10 0. 962 F6 0. 961 0. 001 11 0. 916 EA 0. 914 0. 002 12 0. 854 DA 0. 851 0. 003 13 0. 778 C7 0. 777 0. 001 14 0. 962 81 0. 691 0. 001 15 0. 598 99 0. 598 0 16 0. 5 80 0. 5 0 17 0. 402 66 0. 398 0. 004 18 0. 309 4F 0. 309 0 19 0. 222 38 0. 218 0. 004 20 0. 146 25 0. 145 0. 001 21 0. 084 15 0. 082 0. 002 22 0. 038 09 0. 035 0. 003 23 0. 010 02 0. 008 0. 002 24 0 00 0 0 25 0. 010 02 0. 008 0. 002 26 0. 038 09 0. 035 0. 003 27 0. 084 15 0. 082 0. 002 28 0. 146 25 0. 145 0. 001 29 0. 222 38 0. 218 0. 004 30 0. 309 4F 0. 309 0 31 0. 402 60 0. 398 0. 004 32 0. 5 80 0. 5 0 139 -"" Cl * M50745 ASSEMBLER V.2.0IC * P . 005 E SEQ. LOC. OBJ .. . . . ·*· ... 1 ... ·*· ... 2 ... ·*· ... SOURCE STATEMENT .... 5 ... ·*· 143 .PAGE ;* 144 145 *= $FOOO ;* 146 ;***************************************** 147 ; *** INITIAL *** ** 148 =***************************************** RESET: ;* 149 FOOO 78 SEI ;* 150 FOOi A27F 151 F003 9A LDX TXS #$7F ;* 152 F004 12 CLT =* 153 FOOS DB CLD =* 154 F006 3CJCFE LDM #$1 C, I CONJ =* ;* 155 F009 A900 LpA #$00 ;* 156 157 FOOB 85FF STA ICON2 ;* =***************************************** 158 159 ; *** D-A CONVERTER *** * 160 ;***************************************** SUBS IN: 161 FOOD A220 LDX #32 162 L2: 163 FOOF BDlFFO LDA SINDAT,X 164 F012 85EO STA D_Al 165 F014 49FF EOR #$FF 166 F016 85E1 STA D_A2 167 F018 CA DEX 168 F019 D002 BNE L1 169 FOJB 80FO BRA SUBS IN 170 L 1: 171 FOlD 80FO BRA L2 172 SINDAT: 173 ; 0 , 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 174 FOlF 8099B1C7 .BYTE $80,$99,$Bl,$C7,$0A,$EA,$F6,$FD,$FF,$FD F023 DAEAF6FD 175 F027 FFFD F029 F6EADAC7 .BYTE $F6,$EA,$DA,$C7,$BJ,$99,$80,$66,$4F,$38 ,. 'ti F02D B1998066 'ti F031 4F38 r- 176 F033 25150902 F037 00020915 .BYTE $25,$15,$09,$02,$00,$02,$09,$15,$25,$38 ,. (') F03B 2538 ::! 0 177 F030 4F6680 .BYTE $4f,$66,$80 z APPLICATION Output waveform D-A, 141 APPENDIX 1 APPENDIX 1. Programming notes (1) Processor status register RESET • Initialization Except for the interrupt inhibit flag (I) being set to "1", the contents of the processor status reg- intialize flags ister (PS) is unpredictable after reset. There- fore, flags affecting program execution must be main program intialized. The T flag and D flag which affect arithmetic op- erations, must be initialized. Initialize flags • Reference and save To reference the PS, the contents of the PS must first be saved to the stack using the PHP instruction, then read the contents of the s+1. The PLP instruction can be used to return the saved PS value to the PS if required. However, Contens of the stack memory just after a NOP instruction must be used after the execu- the execution of the PHP instruction tion of the PLP instruction. (2) Interrupts PLP instruction execution Even though the BBC and BBS instructions are executed just after the interrupt request bits are modified (by the program) , those instructions NOP are only valid for the contents before the mod- ification. Notes on PLP instruction At least one instruction cycle must be used (such as a NOP) between the modification of the interrupt request bits and the execution of BBC and BBS instructions. modify interrupt request bit (3) Decimal operations •Execution NOP Decimal operations are performed by setting the decimal mode flag ( D) and executing the ADC BBC or BBS instruction or SBC instruction. In this case, there must be at least one instruction following the ADC or SBC Notes on modification of interrupt instruction before executing the SEC, CLC, or request bit CLO instruction. • Notes on flags in decimal mode The N (Negative), V (Overflow), and Z (Zero) Dflag set flags are ignored during decimal mode. Also note that the C (Carry) flag is set to "1" if a ADC or SBC instruction digit is carried as the result of the operation, but is reset to "O" if the digit is borrowed. Therefore it can be used as a flag for judging of carried or NOP borrowed. It should be initialized before the calculations. SEC. CLC. CLO instruction Notes on operation in decimal mode 142 APPENDIX 1 (4) Timer • The frequency division ratio count enable bit clear The frequency division ratio when n (0~65535) is written in the timer latch is 1/(n+1 ). • Write to timer set the value in TL When directly writing a value in the timer, clear the count enable bit to count disable ( "O") and set the value in TH write in the low-order byte first and then in the high-order byte. • Read from timer Notes on setting the value to timer The timer value must be read from the high- order byte first. (5) Serial 1/0 • SRov output In clock synchronous se~@JlfO mode, if the re- interrupt enable bit clear ceiver is to output an SRov using an external clock, the receive enable bit, SRov output en- able bit, and transmission enable bit must be set select serial J/O mode to "1 ". • Initial setting of serial 1/0 interrupt When using the serial 1/0 interrupt, it should be interrupt request bit clear set using the following procedure: CDclear the interrupt enable bit to "O" by CLB in- struction interrupt enable bit set C2>select serial 1/0 @after waiting for one or more instructions use Serial 1/0 interrupt initialize the CLB instruction to set the interrupt request bit to "O". ®set the interrupt enable bit to "1". (6) A-D conversion The comparator consists of coupling that lose their charge when the clock frequency is low. Therefore, f (X 1N) must be no less than 1 MHz during A-D conversion. (If the bus cycle control bit is "1", the bus cycle is doubled and the A-D conversion time is also doubled, therefore, f (X,N) must not be less than 2MHz.) Also, the STP and WIT instructions must not be executed during A-D conversion. (7) STP instruction The STP instruction must be executed after set- ting the timer 1 count enable bit (bit 4 of address OODE 16 ) to enable ("1"). (8) Multiply/Divide instructions 1 . The MUL and DIV instructions are not affected by the T and D flags. 2. The contents of the processor status regis- ter are unaffected by multiply or divide in- structions. 143 APPENDIX 2 APPENDIX 2. Handling of unused pins Table 8.3.1 Example of unused pins handling of M37450M2-XXXSP/FP Pin or port Handling ---I Ports PO~P3, P5, P6 set input mode and pull-down through resistor Port P4 pull-down through resistor. ¢,SYNC, D-A 1 , D-A,, R/W, RD - open WR, RESET OUT A Vee l Vee or Vss level -· AVss, ADVREF· DAVREF, VREF Yss level Ports PO~P3, P5, P6 (Set input mode) PortP4 1---~ ¢ SYNC D-A 1 0-A 2 R/W open RD WR RESETouT AVcc t-------~ AVss t - - - - - - - - e ADV REF ,____ _ _ ___ DAVREF t - - - - - - - - - VREF t--------- M37450M2-XXXSP/FP 144 APPENDIX 3 APPENDIX 3. Package outlines M37450M2-XXXSP package outline TYPE 64P4B 64-PIN MOLDED PLASTIC DIP(LEAD PITCH 1.778mm) Dimension in mm 56 .4 +0.5 . -0.2 CD 19.05±0.3 17.0±0.15 ~I M37 450M2-XXX FP package outline TYPE 80P6 80PIN MOLDED PLASTIC FLAT Dimension in mm ir~li ... -. ·.14±0. 2.. 19. 2±0. 3 1-zt- c-1 ~ 145 APPENDIX 4 APPENDIX 4. SFR memory map 0000,. PO register PO 0001,. PO directional register POD 0002,. P1 register P1 0003,. P1 directional register P1D 000410 P2 register P2 0005,. P2 directional register P2D 0006,. P3 register P3 0001,. P3 directional register P3D _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _L_ _ _ _ _ ~~'.-64---~,n-~-~-ell ___________ _ P4 P4(80-pin model) . 0009,. Reserved OODA 1o P5 register P5 ooos,. P5 directional register P5D oooc,. PB register PB PB directional register PBD OODE1s MISRG1 MISRG1 OODF16 MISRG2 MISRG2 ---~~~-1--~-~~~1-~~~~-1-~~~-~1-~~~~-1--~-~~~1--~~-~-1--~~-~-- OOE010 D-A 1 register D-A1 OOE1 16 D-A2 register D-A2 146 APPENDIX 4 OOE216 A-0 register ADSR OOE3 16 A-0 control register AD CON OOE4 16 Data bus buffer register DBS OOE516 Data bus buffer status register DBBSTS U7 U6 U5 U4 AO U2 IBF OBF OOE616 Receive/transmit buffer register RB/TB OOE7 16 Serial 1/0 status register SIOSTS OOE8 16 Serial 1/0 control register SI OCON SIOE SIOM RE TE TIC SRDY scs css OOE9 16 UART control register UACON -------------- STPS PARS PARE CHAS OOEA1a Baud rate generator BRG OOE815 PWM register( low byte) PWML OOEC1a PWM register( high byte) PWMH OOED1a Timer 1 control register TMR1 EP1 OLL1 S1 10~ 12-I -T~~-11--1 TMS10 OOEE16 Timer 2 control register TMR2 OOEF1a r EP2 1·--1~- OLL2 S2 Timer 3 control register TMS22 TMS21 TMS20 TMR3 -------------- EP3 OLL3 S3 TMS32 TMS31 TMS30 147 APPENDIX 4 OOF0 16 Timer 1 register (low-order) T1L OOF1 16 Timer 1 register (high-order) T1H OOF2 16 Timer 1 latch (low-order) TL1L OOF3 16 Timer 1 latch (high-order) TL1H ------· OOF4 16 Timer 2 register (low-order) T2L OOF5 16 Timer 2 register (high-order) T2H ----- OOF615 Timer 2 latch (low-order) TL2L -------- OOF7 16 Timer 2 latch (high-order) TL2H OOF8 16 Timer 3 register (low-order) T3L ------------------------- OOF9 16 Timer 3 register (high-order) T3H OOFA 16 Timer 3 latch (low-order) TL3L OOFB 16 Timer 3 latch (high-order) TL3H OOFC 16 Interrupt request register 1 IRQ1 OOFD 16 Interrupt request register 2 IRQ2 ADR TIR RIR E3R E2R E1R OOFE 16 Interrupt control register 1 ICON1 Interrupt control register 2 ICON2 ml______ mr ~~~mtu TIE RIE E3E E2E E1E 148 APPENDIX 5 APPENDIX 5. Control registers b7 bO MISRG 1 (address OODErn) --- ------ _____ T ______ _ name function status at reset 0 : falling edge lNT 1 input polarity selection bit 1 : rising edge ------------- 0 : falling edge INT 2 input polarity selection bit 1 : rising edge : falling edge 1NT3 input polarity selection bit 1 : rising edge -----r----------- O : count disable Timer 1 count enable bit 6 -- - 1 >-----+---T~i~-:-~_.2_--·-_c_o_-~-~-;~en~a--b--le~-~-··-·--~------· - -;-~~~~~ Timer 3 count enable bit 1 count enable --- l--_-00_-jl ---------~-- - ------ b7 bO MISRG 2 (address OODF 16 ) -------------~---- bit name function status at reset - - - - - - - - - + - - - - - - - -· --------·-------- b1 bO 0 0 : single-chip mode Processor mode bit 1 : memory expanding mode 0 : microprocessor mode 1 : disable f------+---------------- --+---------------- 0: disable Bus interface enable bit 1 : enable --·---------------+------------------------- 0: RD, WR bus 3 Bus interface mode bit 1 : R/W bus r------r---------------------+---------- 0: disable 4 PWM enable bit 1 : enable -----------i----------- PWM mode selection bit 0 : 8-b1t high speed PWM I I . :O~ • -------~-b~~h prec1s1on PWM __ Bus cycle control bit I 0 : normal bus cycle 0 -----------------+1_1_n_o_rm_a_l_b_u_s_c_yc_l_e_X2 --+--- 1n 0 page area __L ar~------ Stack page selection bit m 1 page 0 _ __ _ _j b7 bO A-D control register (address OOE3 16 ) bit -----~ame -- _ - --- . bZ bl bO _ f_1mct1on ----1tat~-;-at reset 0 0 0 : input from P40 pm :O O 1 : input from P4 1 pm 0 · mput from P42 pm LL 2,1,0 I Analog input pin selection bit i ~--- 0 1 . input from P43 pm 0: input from P44 pin 1 : input from P4 5 pin 0 : input from P46 pin 1 : input fro.r:n P4 7 f?~____ [' I _____J___ U 149 APPENDIX 5 b7 bO lJllJIJlJ Data bus buffer status register (address OOE5 16 ) function status at reset 0 : buffer empty 1 : buffer full 0 : buffer empty l ~---------___, ---r----------------+------------------+------- f-----+------~~--------f-U_s_e_r_m_a~y-freely define this flag U 1 : buffer full User may freely define this flag -------+------ 1ndi cates the AO status when the IBF flag is set. User may freely define this fla~g _____--+-_ _ _u____ U O f-----+--------------·---~sermayfreelydefin_e_t_h_is_f_la~g_ _ _ _--+-_ _ _u___ ----------~_U_s_e_r_may freely define this fla_~g______~ _ _ _U_ _~ b7 bO [I].--,--cl~~'- LJ Serial 1/0 status register (address OOE7 16 ) I :==b=it=================n=a=m=e===========------~'--------=====--====f_u-__n-c=t_io L____________.. 0 Transmit buffer empty flag 1--------+------------------~uffer empty 1 Receive buffer full flag 0 : buffer full --t=i ___n__________________________________:=.--st--a--tu_s_a_tr~~ O : buffer empty 1 : buffer full ------+--- 0 -1 ___ -. ~----+------------------1---- 0 : busy shifting Transmit shift register shift completion flag 0 1 : shift complete f-----+----------------1-----------------------t---------j O: no Overrun error (OE) flag 1 : yes 0: no i Parity error (PE) flag ---~--------+--~ L Framing error (FE) flag 1 : yes f-----+------------------1--------- Summing error (SE) flag 0 : PE U OE U FE=O 0: no 1 : yes 0 _ · 6 1 : PE U OE U FE= 1 --~-----------------~------------------~-- Note : When the transmit enable bit of the serial 1/0 control register becomes "1" (enable), this register will be set to "05 16". Bits 4........ 5 flags are valid only in the UART mode. b7 bO function status at reset 0 : transmit disable 4 Transmit enable bit 0 1 : transmit enable 5 Receive enable bit 0 : transmit disable 0 1 : transmit enable 0: UART I 6 Serial 1/0 mode selection bit 11 : clock synchronous serial 1/0 l ~------------~ ~1 7 1 Serial 1/0 enable bit 0 : serial 1/0 disable 0 L 1 : serial 1/0 enable 150 APPENDIX 5 UART control register (address OOE9 16 ) b7 bO Timer 1 control register (address OOED 16 ) _ _ _ _·--·~~~~~n-a_;,,_·-e~~----~~--------.. -____ -_-b_2_b_O_ _ _ _ ;"";;;;;;- -_-__ 0 0 0 : 16-bit timer mode - -1 ~""'"'m""'_l a 0 0 1 event counter mode - ------ 0 1 0 : pulse output mode Timer 1 mode selection bit 0 1 1 : pulse period measurement mode 1 0 0 : pulse width measurement mode 1 0 1 : programmable waveform generation mode 1 1 0 : programmable one-shot generation mode --------- - - - - - ----- '. f(X,N)/4 Timer 1 count source selection bit f - - - - + - - - - - - - - - - - - - - - - _ , __ : _IN_T 1 pin input Output level latch o : falling edge 1 Event polarity selection bit 1 : rising edge b7 bO !-=-~-·~-~--~-~~-~ l-~~~-~.•~~~,.-··~-~--- Timer 2 control register (address OOEE 16 ) f--b_it_-+----------n;;;;-e--------~Ib--b~--- 2 function status at reset 0 0 a: 16-bit timer mode 0 0 0 1 : event counter mode ~-0 O 1 O : pulse output mode Timer 2 mode selection bit 0 1 1 : pulse period measurement mode 1 0 0 : pulse width measurement mode - 1 0 1 : programmable waveform generation mode 0 1 1 0 : programmable one-shot generation mode -f------------· 0 '. f(X,N)/4 Timer 2 count source selection bit 1 : INT2 pin input ·---+-·---·--------------·+--~-~-----------+--------4 Output level latch ----·----------+------------------+-- 0 : falling edge Event polarity selection bit : rising edge_ _ _ _ _ _ _ _ _ _ _~____ ___J 151 APPENDIX 5 b? bO Timer 3 control register (address OOEF 16 ) name function status at reset : b2 b1 bO I Q 0 0 : 16-bit timer mode 0 0 0 1 : event counter mode 0 1 0 : pulse output mode Timer 3 mode selection bit 0 1 1 : pulse period measurement mode 0 1 0 0 : pulse width measurement mode 1 0 1 : programmable waveform generation mode 0 1~ 1 0 : programmable one-shot generation mode '. f(X,N)/4 Timer 3 count source selection bit 0 1 : INT3 pin input Output level latch 0 ------~-----·--------+- : falling edge Event polarity selection bit 0 : rising edge ~--~-----~---·-·-------------~- b? bO [ I 11l 1 l( 11 Interrupt request register 1 (address OOFC, 6 ) bit ---,-- name 0 : no request function status at reset ---1 L~ 0 Input buffer full interrupt request bit 0 1 : request occured -------- --'----1 0 : no request 1 Output buffer empty interrupt request bit 0 1 : request occured ------- 0 : no request 2 INT 1 interrupt request bit 0 1 : request occured 0 : no request 3 INT 2 interrupt request bit 0 1 : request occured 0 : no request 4 INT 3 interrupt request bit 0 1 : request occured "- 0 : no request 5 Timer 1 interrupt request bit ---=±_ 0 1 : request occured I 0 : no request 6 Timer 2 interrupt request bit 1 : request occured 0 ----------1 0 : no request --, 7 Timer 3 interrupt request bit L 1 : request occured -----------------1.....--- ___o___ b? bO l_-=1-1 l l l l f] LG Interrupt request register 2 (address OOFD, 6 ) ----- name EV1 interrupt request b1_t_ _ _ 0 : no request function status at reset 0 1 : request occured 0 : no request J 1 EV 2 interrupt request bit 0 1 : request occured 0 : no request 2 1 EV3 interrupt request bit 0 1 : request occured 0 : no request 3 Serial 1/0 receive interrupt request bit 0 1 : request occured 0 : no request 4 Serial 1/0 transmit interrupt request bit 0 i 1 : request occured i O : no request 5 A-0 interrupt request bit 0 I 1 : request occured 152 APPENDIX 5 b? ~I I l l status at reset 0 : interrupt disable Output buffer empty interrupt enable bit : interrupt enable ------c---------------------- 0 : interrupt disable INT 1 interrupt enable bit 1 : interrupt enable -------·--- I 0 : interrupt disable INT2 interrupt enable bit 1 : interrupt enable - - - --------- --------- ------·-··-·---- - - + - - - - O : interrupt disable , ~ ~ :~~~~~: :~~~~----- ------- f INT 3 interrupt enable bit ---- -- -- 5 Timer 1 interrupt enable bit ------- ---- - - - - - - - - - - - 1 : interrupt enable I ---- ----- - ·o:i~-;~~~1 ctisab1~------- -:--- 6 Timer 2 interrupt enable bit r------- ~--------------------1 Timer 3 interrupt enable bit b? bO Interrupt control register 2 (address OOFF 16 ) bit ~v, i:t~~2b~;--- --~t~r;u~di;;bl~;,;;tio-;;-----==i-~t;;t;;; :t re;.;t 1 EV 2 interrupt enable bit_ _ _ _ _ _ _ _ ~ :~~:~~~:: :~s::I: ----------~ __O ___ -- 1 interrupt enable ------------------ ------ --------- - -- - - - - EV3 interrupt enable bit 0 interrupt disable 0 "l""'o ,.,::,,,.,~: .:., , ,; -:: : : : :::,~ -------l-- ~ 4 Senal 1/0 transmit interrupt enable bit 0 1 interrupt disable interrupt enable 0 ~-- -~------- - -~---- ----- - --- ------~ - --- 0 interrupt disable ---5 A~~ covers1on c_omplet1on interrup~=a~!~~-J !_~terrupt ~nab le _ ____ ____ L_ O j 153 APPENDIX 6 APPENDIX 6. Instruction cycles in each addressing mode Series MELPS 740 microcomputers use the internal clock ¢which is f(X,N) divided by four as the system clock. The SYNC signal is output when the contents of the PC indicates the location of the next op code. During the next half-cycle of ¢, the op code is fetched and stored in the op code register. The instruction decod- er of the CPU decodes this op code and determines the following sequence. This instruction timings of all addressing modes are described on the following pages. In these figures, ADDR and DATA are internal signals of the single-chip microcomputer. Therefore, these signals can be investigated only in the microprocessor mode. 154 APPENDIX 6 IMPLIED Instructions : CLC.6 CLD.6 CL/.6 CLT.6 CLV.6 DEX.6 DEY.6 INX.6 INY.6 NOP.6 SEC.6 SED.6 SEl.6 SET.6 TAX.6 TAY.6 TSX.6 TXA.6 TXS.6 TYA.6 Byte length :1 Cycle number :2 Timing ¢ SYNC H R/W ADDR DATA PC x PC+1 x Op code Invalid RD WR H 155 APPENDIX 6 IMPLIED Instructions : BRKL Byte length :1 Cycle number :7 Timing SYNC H R/W ADDR S,SPS S-1,SPS S-2,SPS FFEO DATA PS RD WR H ------------...., 156 APPENDIX 6 IMPLIED Instructions : STPn WITL>. Byte length :1 Cycle number Timing ---- -----i_____r SYNC R/W H L ADDR ( x'----------------------------~ PC PC+1 -----~ DATA =>< x'-------------------~~~ ~ ~ ~ _____.JX\._____ Op code Invalid Return from stop mode is excuted by external interrupt. Return from wait mode is executed by internal or external interrupt. RD ------------i____r--- WR H ---------------- 157 APPENDIX 6 IMPLIED Instructions : RTl.G Byte length :1 Cycle number :6 Timing "' SYNC H R/W ADDR S,SPS DATA Invalid RD WR H Instructions : RTS.G Byte length :1 Cycle number :6 Timing "' SYNC H R/W PCL ADDR S,SPS PCH Invalid stack DATA RD WR H 158 APPENDIX 6 IMPLIED Instructions : PHAL'-. PHPL'-. Byte length : 1 Cycle number : 3 Timing 159 APPENDIX 6 IMMEDIATE Instructions : ADCL::.#$nn (T=O) ANDL::.#$nn (T=O) CMPL::.#$nn (T=O) CPXL::.#$nn CPY6#$nn EORL::.#$nn (T=O) LDAL::.#$nn (T=O) LDX6#$nn LDYL::.#$nn ORAL::o.#$nn (T=O) SBCL::.#$nn (T=O) Byte length : 2 Cycle number : 2 Timing SYNC H L R/W ADDR DATA RD WR H 160 APPENDIX 6 ACCUMULATOR Instructi ans : ASLL:>.A DECLO.A INCL:>.A LSRL'.:>.A ROLLO.A RORL:>.A Byte length :1 Cycle number :2 Timing ¢ SYNC H R/W ADDR PC x PC+1 >C DATA RD WR H 161 APPENDIX 6 ACCUMULATOR BIT RELATIVE Instructions : BBC-6.i, A, $hhll BBS-6.i, A, $hhll Byte length : 2 ©With no branch Cycle number : 4 Timing ¢ SYNC H L R/W ADDR ( PC x_____x ><== PC+1 DATA ==>< Op code x.____ _____,X._____lnvaild RD WR H 162 APPENDIX 6 ACCUMULATOR BIT RELATIVE Instructions : BBCL>.i, A, $hhll BBSL>.i, A, $hhll Byte length : 2 ~With branch Cycle number : 6 Timing "' SYNC H R/W ADDR DATA PC x_______________x x. .__ __.x Op code PC+1 Invalid ±RR i:~!~i: Invalid *_ Invalid (PC+2)±RR * (PC+2),±RR (PC+2)H ±RR : value of offset RD WR H 163 APPENDIX 6 ACCUMULATOR BIT Instructions : CLBL>-i, A SEBL.i, A Byte length : 1 Cycle number : 2 Timing ¢> SYNC H R/W ADDR < PC x x PC+1 DATA Op code Invalid RD WR H 164 APPENDIX 6 BIT RELATIVE Instructions : BBCL:l.i, $zz, $hhll BBSL:l.i, $zz, $hhll Byte length : 3 CDWith no branch Cycle number : 5 Timing ¢ SYNC H R/W ADDR DATA PC x x x PC+1 AD,,00 RD WR H ~With branch Cycle number :7 Timing ¢ SYNC H R/W ADDR (PC+3), (PC+3),±RR (PC+2), (PC+3)H DATA Invalid Invalid RD WR H 165 APPENDIX 6 ZERO PAGE BIT Instructions : CLB.6.i, $zz SEB.6.i, $zz Byte length : 2 Cycle number : 5 Timing ¢> SYNC H R/W ADDR DATA PC x x PC+1 Op code AOL RD WR H LJ 166 APPENDIX 6 ZERO PAGE Instructions : ADCL::.$zz (T=O) ANDL::.$zz (T=O) BITL::.$zz CMPL::.$zz (T=O) CPXL::.$zz CPYL::.$zz EORL::.$zz (T=O) LDAL::.$zz (T=O) LDXL::.$zz LDYL::.$zz ORAL::.$zz SBCL::.$zz (T=O) TSTL::.$zz (T=O) Byte length : 2 Cycle number : 3 Timing ¢ SYNC H R/W ADDA < x x x PC PC+1 ADL,00 DATA RD =>< x x xOp code AOL Data WR H 167 APPENDIX 6 ZERO PAGE Instructions : ASLL>.$zz COML>.$zz DECL>.$zz INCL>.$zz LSRL>.$zz ROLL>.$zz RORL>.$zz Byte length : 2 Cycle number : 5 Timing SYNC H L R/W ADDA < PC x x x x== PC+1 ADL,00 DATA =x x x x x x > Op code AOL Data Invalid New data RD WR H 168 APPENDIX 6 ZERO PAGE Instructions : RRFL'>.$zz Byte length :2 Cycle number :a Timing ¢ SYNC H R/W ADDR DATA PC x x~---------'> PC+1 ADL,00 Op code ADL Data Invalid New data RD WR H 169 APPENDIX 6 ZERO PAGE Instructions : LDML'.\. # $nn, $zz Byte length :3 Cycle number :4 Timing ¢ SYNC H R/W ADDR __Pc _ __,X PC+1 X PC+2 X ADc,OO X'"_____,X_____ DATA Op code Data A De Data RD WR H LJ Instructions : STA6$zz STX6$zz STY6$zz Byte length : 2 Cycle number : 4 Timing SYNC H R/W ADDR PC x x PC+1 ADc,00 x >C DATA RD Op code ADc x x x Invalid Data Data ) WR H LJ 170 APPENDIX 6 ZERO PAGE X Instructions : ASL.6.$zz, X DEC.6.$zz, X I NC.6.$zz, X LSR.6.$zz, X RO L.6.$zz, X ROR.6.$zz, X Byte length : 2 Cycle number : 6 Timing ¢ SYNC ....___ _ _ ______.! __ H R/W ADDR PC x PC+1 X(Pc+1i,.00X . . _ _ AD,+X,00 v-- /\_ DATA Op code AD, Invalid Data Invalid New data RD WR H 171 APPENDIX 6 ZERO PAGE X Instructions : MUL6$zz, X Byte length :2 Cycle number : 15 Timing 1' SYNC H n R/W ADDR 0 PC+1 x AD,+x.oo DATA Invalid RD lJlJ LJ WR H 172 APPENDIX 6 ZERO PAGE X Instructions : DIV2'$zz, X Byte length Cycle number Timing ¢ SYNC R/W H n I ADDR @\ PC+1 'ru AD,+x+1.oo x S,SPSX ""'"\.r--"\ DATA Op code Invalid __, "----' RD lJlJ LJlJ WR H 173 APPENDIX 6 ZERO PAGE X ZERO PAGE Y Instructions : ADCL>$zz,X (T=O) AND6$zz, X (T=O) CMPL>$zz, X (T=O) EORL>$zz, X (T=O) LDAL>$zz, X (T=O) LDXL>$zz, Y LDYL>$zz, X ORA6$zz, X (T=O) SBC6$zz, X (T=O) Byte length : 2 Cycle number : 4 Timing SYNC R/W ADDR < PC x PC+1 X (Pc+1lL.oo X ADL+x(YJ,ooX DATA =>< Op code x ADL x Invalid x Data > 174 APPENDIX 6 ZERO PAGE X ZERO PAGE Y Instructions : STA6$zz, X STX6$zz, Y STY6$zz, X Byte length : 2 Cycle number : 5 Timing SYNC H R/W ADDR X ~-P_c_..... PC+1 x(PC+1),,oo X'-___ A_D_,+_x_(v_)_.o_o__ _.X'----- DATA Op code AD, Invalid Invalid Data RD WR H 175 APPENDIX 6 ABSOLUTE Instructions : ADCLi$hhll (T=O) ANDLi$hhll (T=O) BITLi$hhll CMPLi$hhll (T=O) CPXLi$hhll CPYLi$hhll EORLi$hhll (T=O) LDALi$hhll (T=O) LDXLi$hhll LDYLi$hhll ORALi$hhll (T=O) SBCLi$hhll (T=O) Byte length : 3 Cycle number : 4 Timing 1> SYNC H R/W ADDA DATA PC x x x x x PC+1 PC+2 AD, ADH RD WR H 176 APPENDIX 6 ABSOLUTE Instructions : ASL.6.$hhll DEC.6.$hhll INC.6.$hhll LSR.6.$hhll ROL.6.$hhll ROR.6.$hhll Byte length : 3 Cycle number : 6 Timing "' SYNC L - - - , ._ _ _ _ _ ___.I H R/W ADDR ( PC x x x PC+1 PC+2 ADL, ADH >C DATA RD =>< Op code x x x x x ADL ADH Data Invalid New data> WR H 177 APPENDIX 6 ABSOLUTE Instructions : JMPL>.$hhll Byte length :3 Cycle number :3 Timing SYNC H R/W ADDR DATA RD WR Instructions : JSRL'.O.$hhll Byte length :3 Cycle number :6 Timing q, SYNC H R/W ADDR PC x x PC+1 .___ _ _s_,_s_Ps ____ x x x__ S-1,SPS PC+2 ~_g_~-J DATA Op code ADL Invalid RD WR H 178 APPENDIX 6 ABSOLUTE Instructions : STAL'.':>.$hhll STXL'.':>.$hhll STY L>.$hhll Byte length : 3 Cycle number : 5 Timing SYNC H R/W ADDR ( PC xX x x PC+1 PC+2 AD,, ADH x DATA RD =>< Op code AD, x ADH x x x ) Invalid Data WR H 179 APPENDIX 6 ABSOLUTE X ABSOLUTE Y Instructions : ADC""$hhll, X or Y (T=O) AND""$hhll, X or Y (T=O) CMP""$hhll, X or Y (T=O) EOR""$hhll, X or Y (T=O) LDA""$hhll, X or Y (T=O) LDX""$hhll, Y LDY""$hhll, Y ORA""$hhll, X or Y (T=O) SBC""$hhll, X or Y (T=O) Byte length : 3 Cycle number : 5 Timing ¢ SYNC H R/W *C: Carry of ADL+Y ADDR ADL+X(Y) ADL+X(Y) ADH Ao"+c* DATA Invalid RD WR H 180 APPENDIX 6 ABSOLUTE X Instructions : ASLL'.$hhll, X DECL'.$hhll, X INCL'.$hhll, X LSRL'.$hhll, X ROLL'.$hhll, X RORL'.$hhll, X Byte length : 3 Cycle number : 7 Timing if> SYNC H R/W x x x x- - -)C *C: Carry of ADL+x ADDR PC PC+1 PC+2 A~~~X ADL+x ADH+C DATA Invalid Data Invalid New data RD WR H 181 APPENDIX 6 ABSOLUTE X ABSOLUTE Y Instructions : STAL'>.$hhll, X or Y Byte length Cycle number :6 Timing SYNC H R/W * C : Carry of AD,+Y AD,+X(Y) AD,+X(Y) ADDA PC PC+1 PC+2 ADH ADH+C DATA =x Opcode X AD, x x x xADH Invalid Invalid RD WR H 182 APPENDIX 6 INDIRECT Instructions : JMPL'>. ($hhll) Byte length Cycle number Timing SYNC R/W *BA : Basic address ADDA X. . __P_c__ _P_c_+_1__,X. . _p_c_+_2_ _,X....__:_~_~_ _,X...._B_~-~-~-1_X. . __~-~-~-_, DATA Op code BAL RD WR H --------------------------------- 183 APPENDIX 6 ZERO PAGE INDIRECT Instructions : JMP.6. ($zz) Byte length Cycle number Timing SYNC R/W *BA : Basic address ADDR ,___P_c_....X PC+1 x x x~-~-~-~--> BAL,00 BAL +1,00 DATA Op code BAL ADL RD Instructions : JSR.6. ($zz) Byte length Cycle number Timing SYNC H----------------. R/W * BA : Basic address ADDR DATA RD WR 184 APPENDIX 6 INDIRECT X Instructions : ADCL>. ($zz, X) (T=O) ANDLI. ($zz, X) (T=O) CMPLI. ($zz, X) (T=O) EORL>. ($zz, X) (T=O) LDAL>. ($zz, X) (T=O) ORAL>. ($zz, X) (T=O) SBCL>. ($zz, X) (T=O) Byte length : 2 Cycle number : 6 Timing SYNC R/W *BA : Basic address ADDR PC BAc+X,00 BAc+x+1.oo DATA =x Op code X..___B_A_c_ _,X Invalid X..___A_D_c_ _,X~_A_o_"_ _X Data RD 185 APPENDIX 6 INDIRECT X Instructions : STA.6. ($zz, X) Byte length :2 Cycle number :7 Timing ¢ SYNC R/W *BA : Basic address Data 186 APPENDIX 6 INDIRECT Y Instructions : ADCL~ ($zz), Y(T=O) AND6 ($zz), Y(T=O) CMP6 ($zz), Y(T=O) EOR6 ($zz), Y(T=O) LDA6 ($zz), Y(T=O) ORA6 ($zz), Y(T=O) SBC6 ($zz), Y(T=O) Byte length : 2 Cycle number : 6 Timing· SYNC R/W * BA : Basic address *C: Carry OF AD, ! Y ADDR DATA Invalid RD WR H 187 APPENDIX 6 INDIRECT Y Instructions : STAL. ($zz), Y Byte length :z Cycle number :7 Timing ¢ SYNC H R/W *BA : Basic address *C: Carry of AD,+Y ADDR DATA Invalid Invalid Data 11[) WR H 188 APPENDIX 6 RELATIVE Instructions : BCC.6$hhll BCS.6$hhll BEQ.6$hhll BMl.6$hhll BNE.6$hhll BPL.6$hhll BVC.6$hhll BVS.6$hhll Byte length :2 CDWith no branch ~With branch Cycle number : 2 Cycle number :4 Timing Timing ¢ n_n_n_ ¢ SYNC I SYNC H R/W R/W ADDR~ ADDR DATA~ DATA Invalid RD WR H ------------- WR H 189 APPENDIX 6 RELATIVE Instructions : BRA6$hhll Byte length Cycle number Timing ¢ SYNC H R/W (PC+2)L (PC+2)L±RR ADDR (PC+1)H (PC+2)H DATA Invalid Invalid RD WR H 190 APPENDIX 6 SPECIAL PAGE Instructions : JSR2'¥$hhll Byte length :2 Cycle number :5 Timing SYNC R/W H '----------...J' x x *BA: Basic address ADDA DATA PC Op code PC+1 BAL S,SPS Invalid x . _______,X (PC+1)H S-1,SPS BA,,FF H 191 [T=lJ APPENDIX 6 IMMEDIATE Instructions : ADCC.#$nn (T=1) ANDC.#$nn (T=1) EORC.#$nn (T=1) ORA6#$nn (T=1) SBCC.#$nn (T=1) Byte length :2 Cycle number :5 Timing ¢ SYNC H R/W ADDR DATA PC x x Op code PC+1 Data1 Data2 X,00 Invalid x New data RD WR H 192 (T=lJ APPENDIX 6 IMMEDIATE Instructions : CMPD. # $nn (T=1) Byte length :2 Cycle number :3 Timing L SYNC H R/W ADDR DATA RD WR H 193 (T=lJ APPENDIX 6 IMMEDIATE Instructions : LDAL'>.#$nn (T=1) Byte length :2 Cycle number :4 Timing ¢ SYNC H L R/W ADDR ( x x PC x >C) PC+1 X,00 DATA RD ==>< x x x x Op code Data Invalid Data WR H 194 (T=lJ APPENDIX 6 ZERO PAGE Instructions : ADCL'.$zz ( T= 1 ) ANDL'.$zz (T=1) EORL'.$zz (T=1) 0RAL'.$zz (T=1) SBCL'.$zz ( T= 1 ) Byte length : 2 Cycle number : 6 Timing SYNC ...._____ _ _ _ ____.! R/W ADDA PC X Pc+1 X ADL,oo X~ ______ x_.o_o_ _ _ _ _ _ _,)C DATA Invalid New data RD H WR 195 [T=lJ APPENDIX 6 ZERO PAGE Instructions : CMPL'.:.$zz (T=1) Byte length :2 Cycle number :4 Timing ¢ SYNC H R/W ADDR PC PC+1 AD,,00 X,00 DATA ==>< Op code x x x AOL Data1 Data2 RD WR H 196 [T=lJ APPENDIX 6 ZERO PAGE Instructions : LDAL:o.$zz (T=1) Byte length :2 Cycle number :5 Timing ¢ SYNC H R/W ADDR PC x x x Op code PC+1 AD, AD,,00 Data X,00 Invalid x Data DATA RD WR H 197 [T=l) APPENDIX 6 ZERO PAGE X Instructions : ADC2'$zz, X (T=1) AND2'$zz, X (T=1) EOR2'$zz, X (T=1) ORA2'$zz, X (T=1) SBC2'$zz, X (T=1) Byte length : 2 Cycle number : 7 Timing ¢ SYNC H R/W ADDR PC x PC+1 x(PC+1),,00X AD,+x,ooX_ _ _ _ _ _ _x_,o_o_ _ _ _ _ __,X____ DATA Invalid Data1 Data2 Invalid New data RD WR H 198 [T=lJ APPENDIX 6 ZERO PAGE X Instructions : CMP6$zz, X (T=1) Byte length :2 Cycle number :5 Timing SYNC H R/W ADDR DATA RD WR H 199 [T=l) APPENDIX 6 ZERO PAGE X Instructions : LDAL'>.$zz, x (T=1) Byte length :z Cycle number :5 Timing ¢ SYNC H R/W ADDR PC X Pc+1 X (Pc+1),,oo X AD,+x,oo X. ._____ x._oo_ _ _ __,X. ._____ DATA Op code AD, Invalid Data Invalid Data RD H WR 200 (T=1) APPENDIX 6 ABSOLUTE Instructions : ADC.6$hhll (T=1) AND.6$hhll (T=1) EOR.6$hhll (T=1) ORA.6$hhll (T=1) SBC.6$hhll (T=1) Byte length : 3 Cycle number : 7 Timing 1> SYNC H R/W ADDR PC x x x x Op code PC+1 AOL PC+2 ADH AOL ADH Data1 DATA RD WR H 201 (T=lJ APPENDIX 6 ABSOLUTE Instructions : CMP6$hhll (T=1) Byte length :3 Cycle number Timing ¢ SYNC H L R/W ADDR < x x x x x >C PC PC+1 PC+2 AD, ADH X,00 DATA RD =>< x x x x x ) Op code AD, ADH Data1 Data2 WR H 202 [T=lJ APPENDIX 6 ABSOLUTE Instructions : LDAL'o.$hhll (T=1) Byte length :3 Cycle number :6 Timing SYNC H R/W ADDR DATA PC x x x x Op code PC+1 AD, PC+2 ADH AD, ADH Data X,00 Invalid x Data RD H WR 203 (T=lJ APPENDIX 6 ABSOLUTE X ABSOLUTE Y Instructions : ADC""-$hhll, X or Y (T=1) AND""-$hhll, X or Y (T=1) EOR""-$hhll, X or Y (T=1) ORA""-$hhll, X or Y (T=1) SBC""-$hhll, X or Y (T=1) Byte length : 3 Cycle number : 8 Timing SYNC H R/W * C : Carry of ADL+Y ADDR ADL+X(Y) ADL+X(Y) PC+2 X,00 ADH ADH+c DATA Invalid Data1 Data2 Invalid New data AD WR H 204 (T=lJ APPENDIX 6 ABSOLUTE X ABSOLUTE Y Instructions : CMP-"'$hhll, X or Y (T=1) Byte length :3 Cycle number :6 Timing ¢ SYNC H R/W *C : Carry of ADL+v ADDR ADL+X(Y) ADL+X(Y) ADH ADH+c* DATA Invalid RD WR H 205 (T=lJ APPENDIX 6 ABSOLUTE X ABSOLUTE Y Instructions : LDA6$hhll, X or Y (T=1) Byte length :3 Cycle number :7 Timing ¢ SYNC H R/W *C: Carry of AD,+Y AD,+X(Y) ADDR X,00 ADH DATA Invalid Invalid Data RD WR H 206 (T=l) APPENDIX 6 INDIRECT X Instructions : ADC~ ($zz, X) (T=1) AND~ ($zz, X) (T=1) EOR~ ($zz, X) (T=1) ORA~ ($zz, X) (T=1) SBC~ ($zz, X) (T=1) Byte length : 2 Cycle number : 9 Timing SYNC H R/W *BA : Basic address ADDR X,00 DATA New data RD H WR 207 (T=1J APPENDIX 6 INDIRECT X Instructl ons : CMP.6. ($zz, X) (T=1) Byte length :2 Cycle number Timing SYNC H R/W * BA : Basic address ADDR PC (Pc+OL.oo BAL +x.oo BAL+x+1.oo X,00 DATA 'J: Op codex BAL x x x x x Invalid AOL ADH Data1 Data2 WR H 208 (T=lJ APPENDIX 6 INDIRECT X Instructions : LDA.6. ($zz, X) (T=1) Byte length :2 Cycle number :8 Timing ¢ SYNC H R/W *BA : Basic address ADDR (PC+1 )c,00 BA,+X,00 X,00 DATA Invalid Invalid RD WR H 209 (T=lJ APPENDIX 6 INDIRECT Y Instructions : CMPL. ($zz), Y (T=1) Byte length :2 Cycle number Timing SYNC H R/W * BA:Basic address *C: Carry of AD,+x AD,+Y ADDR ADH+C DATA Invalid RD WR H 210 (T=lJ APPENDIX 6 INDIRECT Y Instructions : ADCL'. ($zz), Y (T=1) ANDL'. ($zz), Y (T=1) EORL'. ($zz), Y (T=1) ·ORAL'. ($zz), Y (T=1) SBCL'. ($zz), Y (T=1) Byte length : 2 Cycle number : 9 Timing ¢ SYNC H R/W *BA : Basic address ADDR X,00 DATA New data RD WR H 211 APPENDIX 6 INDIRECT Y Instructions : LDAL'. ($zz), Y (T=1) Byte length Cycle number :s Timing ¢ SYNC H R/W *BA : Basic address *C: Carry of ADL+Y ADL+Y ADDR ADH+C X,00 DATA Invalid Invalid Data RD H WR 212 APPENDIX 7 APPENDIX 7. Machine instructions Addressing mode Symbol Function T Details IMP IMM A BIT,A ZP BIT,ZP OP n :j:I: OP n :j:I: OP n :j:I: OP n :j:I: OP n :j:I: OP n :J:1: ADC When T=O Adds the carry, accumulator and memory con- 69 2 2 (Note 1) A-A+M+C tents. The results are entered into the accumu- (Note 5) lator. When T=l Adds the contents of the memory in the address in- M (X)-M (X) +M+C dicated by index register X, the contents of the memory specified by the addressing modes in the I columns on the righ~ and the cootents c:i the carry. I The results are entered into the memory at the address indicated by index register X. AND When T=O "AND-s" the accumulator and memory con- 29 2 2 25 3 2 (Note 1) A-Al\M tents. The results are entered into the accumu- i lator. When T=l \ "ANO-s" the cootents of the memory of the address M (X)-M (X) I\ M I indicated by index register X and the contents of the 1 memory specified by the addressing modes in the columns on the right. The results are entered into the memory at the address indicated by index register X. ASL 7 0 1-bit shifts the contents of accumulator or con- OA 2 1 06 5 2 c-c:=::i-o tents of memory to the left. "O" enters 0th bit of memory or accumulator and the contents of the ! 7th bit enter carry flag. BBC Ab or Mb=O?---+ Branches when the contents of the bit specified 13 17 + 4 2 + 5 3 (Note 4) in the accumulator or memory are "O". 2i 2i l BBS (Note 4) I Ab or Mb=l? Branches when the contents of the bit specified in the accumulator or memory are "1 ". I 03 + 4 2i 2 1 °-1 2i 5 3 BCC C=O? Branches when the contents of carry flag are (Note 4) "O". BCS C=l? Branches when the contents of carry flag are (Note 4) "I". BEQ Z=l? Branches when the contents of zero flag are (Note 4) "I". t------+-----------+--------------------l-+----+---l--+----+-----jf-+----+--f-+----+--f-+----+--t--+-----+- BIT Al\M "AND-s" the contents of accumulator and mem- 24 3 2 ory. The results are not entered anywhere. BMI N=l? Branches when the contents of negative flag (Note4) are"I". 1-----+--------+----------------+--+---+-~-r-+--+---+--+-1--+---+---+--+-1--+---+-----+--1 BNE Z=O? Branches when the contents of zero flag are (Note 4) "O". BPL N=O? ----t Branches when the contents of negative flag ~t-jote 4) are "O". BRA PC-PC±offset Jumps to address where offset has been added to the program counter. BRK B-1 Executes software interrupt. 00 7 1 M(S)-PCH s-s--1 M(S)-PCL s-s--1 M(S)-PS s-s--1 PCL-ADL PCH-ADH J 214 APPENDIX 7 r---~----,---- ZP,X OP n 75 4 ZP,Y ABS # OP n # OP n # OP n # 2 6D 4 ABS,X 3 70; 5 ABS,Y 3 7915 3 - Addressing mode IND ZP,IND . ---- ---,--~---.-------··- IND,X IND,Y oPI-;;- # loP n # OP n # oPI,; #1 0PT~ ~-I"" 61 6 2 REL 711· 6 2 SP r- ()f,r-;;- # :: 'V Processor status register ~: q~,: • • zc ! I I 1 ! i i I +---~-+--+--+--+-+--+--+-+-- 35 4 2 N • • • • Z • I I l I +-+-j-1--'°'i ' " " ' I l-1-+6-6-+-2 -r-·-t-t--1C---t--+--+-+--t--t--t--c---•--t--t---t--t--t---C---t---t-+N-+-\-.+-.-+--+-.--t--+---+--ic l I 1--+--+-+--+-+-+--+--+--+--t---+-- +---1--+--+--+--+--+---+--+--+--1--+--+--+--- t--1 - -+---+--+--+-+---f---1-+--+-+--+--··+---+--+ 90 2 2 • • 1 1 • • I I I I I I -1 215 APPENDIX 7 Addressing mode Symbol Function Details IMP IMM A BIT,A ZP BIT,ZP OP n :j:!: OP n :j:!: OP n :j:!: OP n :j:I: OP n :j:!: OP n :j:!: BVC V=O? Branches when the contents of overflow flag (Note4) are "O." I lI BVS V=l? Branches when the contents of overflow flag (Note4) are "1." CLB Ab or Mb-a Clears the contents of the bit specified in the 16 2 1 1F 5 2 accumulator or memory to "O." I !1 !1 CLC c-o Clears the contents of the carry flag to "O." 18 2 1 CLO o-o Clears the contents of decimal mode flag to 08 2 1 ' "O." l CLI 1-0 Clears the contents of interrupt disable flag to 58. 2 1 CLT T-0 "O." Clears the contents of X-modified arithmetic l 1 ----j 12! 2 I t mode flag to "O." CLV v-o Clears the contents overflow flag to "O." 68 2 1 I CMP When T=O Compares the contents of accumulator and C9 2 2 C5 3 2 (Note 3) A-M memory. When T=l Compares the contents of the memory speci- I M(X)-M fied by addressing modes in the columns on the right with the contents of the address indi- cated by index register X. COM M-M Formes one's complement of contents of mem- 44 5 2 cry, and store it into memory. l CPX X-M Compares the contents of index register X and EO 2 2 E4 3 2 memory. CPY Y-M Compares the contents of index register Y and I co 2 2 C4 3 2 DEC A-A-1 or memory. Decrements the contents of ·accumulator or 1A 2 1 l C6 5 2 M-M-1 memory by 1. I DEX x-x-1 Decrements the contents of index register X by CA 2 1 1. DEY Y-Y-1 Decrements the contents of index register Y by 88 2 1 1. DIV A-(M(zz+x+l ), Divides by accumulator the 16-bit data that is M(zz+X))/A the contents of M (zz+ x+ I) for high byte and M (S) - 1's comple- the contents of the next address memory for ment of Remainder low byte, and stores the quotient in the accu- s-s-1 mulator and the remainder on the stack as 1's complement. EOR When T=O "Exclusive-ORs" the contents of accumulator 49 2 2 45 3 2 (Note 1) A-A¥M and memory. The results are stored into the accumulator. When T=l "Exclusive-ORs" the contents of the memory I M (X)-M (X)¥M specified by the addressing modes in the col- umns on the right and the contents of the mem- ory at the address indicated by index register X. The results are stored into the memory at the address indicated by index register X. INC A-A+l or Increments the contents of accumulator or 3A 2 1 E6 5 2 M-M+l memory by 1. INX x-x+1 Increments the contents of index register X by E8 2 1 1. INY Y-Y+l Increments the contents of index register Y by C8 2 1 1. 216 APPENDIX 7 Addressing mode Processor status reglster f - - · - - · , - - - · - - ,-------,---· ---·- ---,------,--· .. ---·-;··· ·----··· - ., . ------ ----,----------,- ZP,X ZP,Y ABS ABS,X ABS,Y 1-~-~l~~N~D,rx__ ;[)·"__ t-_R_l'fL SP 76543210 OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n ! OP n ~-1 0_f" _.". # OP n # N V T B D I Z C 1 50 2 2 1--+---t---+----t-+--+---+----+--+-f-··-+~ ---+---+--+--+--+-+--I--+-+--_,- -+----t-1--+---+--+--+----j-+--+--+---+--t---- -+-+- I 70 2 2 • • t--+---+-·--+----t-·t-+---t---+----t-- - - - L ----' - --+--! ---+-+-- t ·i - - -- + --+ -- I . -1-- +-+·-+-+-+--+---+---+--t-- 1 ··-t--+--+--+--t-+-+--+--+-+-.-+--.+-.--+-.-+-.-+-0--t 1--+--+--+--+-+--+---+--+---+---t--+-· t-- -- -- !---+---+---+--··· ---f--+---+-··+--+-t--+---j -r-·-t·-+--t·--t-+---+---t-· I I • • • 0 • • • t--t-- --+-+---" --+- t--t-- ---+--+-+---I --+--+--+-I--+--+--+--- - Lt--i - ---- - --1--+--+--+--+-1 -:-· t-;-+--.+--.-+-o-+--. -r-:- +--+--+---+--+-· -~ - ------ - t--i --+--+- - --1-t----·1•----+---+--+--_,· - +---+--+- --·- ·t +- -- . -+-- -t--t-·+--t--+----+--+- 0 • • • 0..... I +-- r-D-5+-4-+-2--+----t-+-+C-D-+-4-+--3;D-D-+-5-+-3-+-D-9t-5-+-3-+--+--+----1--+--t-+--+---+--+-+-- C1 6 2 D1 6 - - -- 2 N .....zc I • z • ! I -t--+-+--+-+-+--N 1 _: • EC 4 3 + NT .-t-.-+-.+-.-+-.+--z-+-c-+ I cc 4 3 t --~N1-; •• . z c D6 6 2 CE 6 3 DE 7 3 T N • z • l N • • • • z • f--+---+--+--+-t--·+--+--+--+-t--+-+--+--+-+-+-+---+--+-+-~-t-+--+---t--+---+-t--t-·--1---+-+--+---+---t--t-+--+--+-t--! N • • • • z • E2 16 2 [ I +--+--+--+--+--+---+--+--+--+-l--+--+--+--+-+-+-+---+---+--·~-+-+----t---~-+---t-+-+--+--+---+--+--1--+--+--+--+-I--+-_, 55 4 2 40 4 3 SD 5 3 59 5 3 41 6 2 51 6 2 N • • • • • Z • ! I F6 6 2 EE 6 3 FE 7 3 N • • • . z . l--+---+-·-+--+-+--+---+--+--+-f--·+-+--+--+-+-+-+---+--+---+-t--+-+--+---+-t--+--+--+-+-1-1-+--+--+--+-+-+------j--- N • • • • Z N • • • • z • l 217 APPENDIX 7 Addressing mode Symbol Function Details IMP IMM A BIT.A ZP BIT,ZP DP n :II DP n :II OP n :II OP n :II OP n :II OP n :II JMP II addressing mode is ABS JUmps to new address. PCc-AOc PCH-AOH II addressing mode is IND PCc- (AOH, AOL) PCH-(AOH, AOc+1) II addressing mode Is ZP, IND PCc-(00, AOc) PCH-(00, AOc+1l JSR M(S)-PCH After storing contents of program counter in s-s-1 stack, and jumps to new address. M(S)-PCc s-s-1 After executing the above, ii addressing mode Is ABS, PCc-AOc PCH-AOH II addressing mode is SP, PCc-AOc PCH-FF II addressing mode Is ZP, IND, PCc-(00, AOc) PCH-(00, AOc+l) LOA When T=O Load accumulator with contents of memory. A9 2 2 A5 3 2 (Note2) A-M When T=l Load memory indicated by Index register X with M(X)-M contents of memory specified by addressing mode shown in right column. LOM M-IMM Load memory with immediate value. 3C 4 3 LOX X-M Load index register X with contents of memory. A2 2 2 A6 3 2 LOY Y-M Load index register Y with contents of memory. AO 2 2 A4 3 2 LSR 7 0 Shift the contents of accumulator or memory to 4A 2 1 46 5 2 o-c::::i- c the right by one bit. 0th bit of accumulator or memory is stored in carry, 7th bit is cleared. MUL M(S) ·A-AXM(zz+X) Multiplies accumulator with the memory speci- s-s-1 fied by the zero page X addrressing mode and stores the high byte of the result on the stack and the low byte In the accumulator. NOP PC-PC+l No operation. EA 2 1 ORA When T=O Produce the logical OR of the contents of mem- 09 2 2 05 3 2 (Note 1) A-AVM ory and accumulator. The result is stored in accumulator. When T=l produce the logical OR of contents of memory M(X)-M(X)VM Indicated by index register X and contents of memory specified by addressing mode shown in right column. The result is stored in memory of address specified by index register X. 218 APPENDIX 7 Addressing mode Processor status register iE 1 ZP,X ZP,Y .AsS~-2sS.x- ABS,Y IND rZP,IN_02~x- -lND,Y- -;EL - -~ -f~±+~ OP n l # OP n # OP nJ# ~ # OP n # OP n # 0 4C 3 3 6CT 5 3 B !_ ()l>~~-~-+~p n # OP n # N V T B D I Z C 2 I 1 . . . . I I ! I +--t--t--f---f--l--j----t-+- - . ~- +-·-+--+--!---+--+ -+---+---·-+--+··-+--! 20 6 3 02 7 2 T 22 5 2 • • ! I 1 Dn_,~,__,-r---r-+--+--+--+--i--i--::-,.-+ r-t-t-+-+-+-+--+--+-+--+--t-i- 6 ·-r-c-r--i--1---r--i--i--i---i---r--t-r-·t--t-·t--1 85 4 2 AD 4 3 BDI 5 3 1uv 5 3 A1 6 2 IB1 2 N • • • • • Z • I i I T .I• f---1--4---+-B6-+--4+-2+-A-E+-4-+-l3-+--t1---+-+B-E+-5+-3 l T 1. . . N --f-~ • z • +--+--t--t--+--+--+-+-+--+-+-+--+--+--+----t--f--l---l--~-+--+--+,--1--i---+---+--;f--+--l--t-1-+-+--t--+--+-·-t--+--·+--t---1 84 4 2 AC 4 3 BC 5 3 l i I N • I • • z • 56 6 2 4E 6 3 SE 7 3 i o-+-:-+-1•--.+-.-+-.+-.+-z-+-c--1 II I 62 15 2 • • • •!• • l ~-+-+-l-+--+--+--~-~+-f-t-J~--+-~-+--,-+-1,__,· -+--+-+-+-~+--+---+I r ~1-+-+-~J-+--1+~; I I 15 4 2 OD~i-4-+-3-+-1 t-5-+-3-i---t-··-+--+-·-t-·~1·- IO~ s D-+-5-+-3-r-1·-9 C. I . . C, I ; : I : : 1 • : ; : 1 I l l 219 APPENDIX 7 Addressing mode Symbol Function Details IMP IMM A BIT,A ZP BIT,ZP OP n j:I: OP n j:I: OP n # OP n # OP n # OP n # PHA M(S)-A Saves the contents of the accumulator in the memory 48 3 1 s-s-1 at the address indicated by the stack pointe;r and decrements the contents of stack pointer by 1. PHP M(S)-PS Saves the contents of processor status register 08 3 1 s-s-1 in the memory at the address indicated by the stack pointer and decrements the contents of stack pointer by 1. PLA s-s+1 Increments the 'Contents of stack pointer by 1 and 68 4 1 A-M(S) pulls frcm the memay at the address indicated by the stack pointer, and store it in accumulator. PLP s-s+1 Increments the contents of stack pointer by 1 28 4 1 PS-M(S) and pulls from the memory at the address indi- cated by the stack pointer, and store it in pro- cessor status register. ROL Connects the carry flag and the accumulator or 2A 2 1 26 5 2 memory and rotates the contents to the left by 1 bit. 1-------1----------+- ROR Connects the carry flag and the accumulator or 6A 2 1 66 5 2 memory and rotates the contents to the right by I bit. RRF 7 0 Rotates the contents of memory to the right by 4 82 8 2 ~ bits. RTI s-s+1 --------+-R~~rns from th~ interrupt routine to the main 40 6 1 PS-M(S) routine. s-s+1 PCL-M(S) s-s+1 PCH-M(S) RTS s-s+1 Returns from the subroutine to the main routine. 60 6 1 PCL-M(S) s-s+1 PCH-M(S) t-ssc When T=O Subtracts the contents of memory and carry flag E9 2 2 ES 3 2 (Note 1) A-A-M-C from the contents of accumulator. The results (Note 5) are stored into the accumulator. When T=l Subtracts contents of carry flag and contents of M(X)-M(X)-M-C 1 the memory indicated by the addressing modes shown in the columns on the right from the I memory at the address indicated by index reg- ister X. The results are stored into the memory ---t--~·-------+--of_t_he_a_dd_r_e_ss_in_dicated by index register X. SEB Of 5 2 Ab or Mb-1 Sets the specified bit contents of accumulator o~ 2 1 or memory to "1." 2i 2i SEC Sets the contents of carry flag to j'l." 38 2 1 SED Sets the contents of decimal mode flag to ul." F8 2 1 SEI Sets the contents of interrupt disable flag to 78 2 1 "1." SET Sets the contents of X-modified arithmetic 32 2 1 mode flag to "1." 220 APPENDIX 7 Addressing mode Processor status register !----~---~--~----~---~---~---~··- . ·------,--·-·· ZP,X ZP,Y ABS ABS,X ABS,Y IND ZP,IND IND,X IND,Y REL SP 7 615 4 3 2 1 - ----0 j--,--·-t--;--~+--t---+-·--+--1--·+--t-- OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # OP n # N v T B D I z c ... .... ... ·---·--1 -- I ---j--j---t-·1·--j- ·-j--i --·--j--+-t--+-·+- +--- (Value saved in stack) ·[--· I I I t-3-6+-6-t-2-+---+-t--+2-E+-6-+--3+3·-E-t-7-t--3-t--t--t---t-+--+--t--+--+---'t--t--+--t---+--t-·- t-+· +---+-·-+·-·t---t-N-+--.·+-.·--t--.-t--r--.+-£ +-c t--+--t--+---+-t--+--+---+---+-t--t--+--t--+--t-t--+--t--+--+~t--+--+--t--+--1-+--+--t--t---t-t--I -+-- 76 6 2 6E 6 3 7E 7 3 N • • • z c t--i---t--+--+-+---+--+--+--+--+1--+--+--+--+--+--+--+-+--+--+--+-----t--+--+--+--+--+--+ -t--+--+-+-+---1--- -· +--- --1··-:+:- (Value saved "j stack) I l ...... -·- .r, I I F5 4 2 ED 4 3 FD 5 3 F9 5 3 E1 6 2 F1 6 2 N V c I t--+--t--t--t--+--+--+---t--+--+-+--+--+--+-+---+--+--.+--+--+--+---+--+--+--+--+--+---+--+--t---+--+- • ~ +Hil . ·1 . . . . I I 1 • • • • 1 • • -t--+--+-+--+--t--+--+-+--+--t--t---t-+--+-+--+--+--+-+--+--t--t---t-+--+-+--+--+-+--+--t--+--+-t--+-..·+--+--t--+--t 1 • 221 APPENDIX 7 Addressing mode Symbol Function Details IMP IMM A BIT,A ZP BIT,ZP OP n # OP n # OP! n # OP n # OP n # OP n # STA M-A Stores the contents of accumulator in the 85 4 2 memory. --- STP Stops the oscillation of the oscillator. 42 2 1 STX M-X Stores the contents of index register X in the 86 4 2 I memory. STY M-Y Stores the contents of index register Y in the 84 4 2 memory. TAX X-A Transfers the contents of accumulator to index 1 A12 register X. TAY Y-A Transfers the contents of accumulator to index 1 TST M=O? register Y. Tests whether the contents of memory are "O" A12 I l 64 3 2 TSX x-s or not. J_ J I Transfers the contents of stack pointer to index BAI 2 1 I register X. I TXA A-X Transfers the contents of index register X to the SA 2 1 accumulator. TXS s-x Transfers the contents of index register X to the ~ck pointer. 9A 2 1 + I TYA A-Y Transfers the contents of index register Y to the 98 2 1 accumulator. WIT Stops the internal clock. C2 2 1 Note 1 The number of cycles "n" is added by 3 when T is 1. 2 The number of cycles "n" is added by 2 when T is 1. 3 The number of cycles "n" is added by 1 when T is 1. 4 The number of cycles "nn is added by 2 when branching has occurred. 5 N, V and Z flags are invalid at decimal operation mode. 222 APPENDIX 7 Addressing mode Processor status register +--------------------------- ---------- - - - - - , - - --,-------- ---- - ------------+--------,---,--,- ---- ---1 ZP,X ZP,Y ABS ABS,X ABS,Y IND ZP,IND IND,X IND,Y REL SP 7 6 5 4 3 2 1 0 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 O_Pf_"~P-n--+---+---+--+---+-__,--+---+--- :II N v T B D I z c 95 5 2 SD 5 3 90 6 3 99 6 3 81 7 2 91 7 2 I .. ... +-+--+---+-+--+---+--+---+---+--+---+---+--+--f-+--- --+---+---+---+--+---+-----+---+--+---t-- -- ----+--+- -t---+--+---t----+-+--+--- - . .. . _ __(___ - - I--+--+--+--+---+--+--+---+--+---+---+--+--+-- -+---+--+----+---+--+--+--+--t---+---+--+---+--+---t---,-- t---+--1-+---t--- -r-+-- ---+ 96 5 2 BE 5 3 i • • ~---+- • •I• l--+--+---t--+---+---t--+--+---t--+--+---t--t-----t----+---t--+--+--t-l---+--+---+---+--+-l---+--+---1---+--+---t---j--+ ~--- ~1 ·- ~ +-+--+---+---+--+--+-+---+--+--~ --1--f-+-t--L 1 + 1-9-41-5-1-2-1--f--f--+8-C+-5+-3-+--+-+-+--+--+-++-+---+--+--+--+-- -- ____ ,__,_+-+-+-+-+--+--+--1--l--+-·- +-· 1 ---+---1---+---+--t---+--t--t--- - -----1-- -~ - - - N ! • • • I • r· z • 1--1--+--+--- __ µ - -+--- l-·- 1 N • • • Z • +--+---+---+--+--+---+-+-+- --+--+--+--+- -1-----t- +-+--- ---l----t---~--+----+---+--- • z I N••l•••Z• N • • • I Z • .l" . . . +--+---+---+--+---+---+--+---+---+--+----+---+--+----+---+--+----+---+--+---+--+--+----+---l-+--+--t--+--+---l---+---+---t+-+--+---+-+--4------+-- Symbol Contents Symbol Contents +-------~----------+----------------------------------------------------+---------------t------------------------------------------------------ IMP lmplied addressing mode + Addition IMM Immediate addressing mode - Subtraction A Accumulator or Accumulator addressing mode A Logical OR V Logical AND BIT, A Accumulator bit relative addressing mode ¥ Logical exclusive OR Negation ZP Zero page addressing mode Shows direction of data flow BIT, ZP Zero page bit relative addressing mode x Index register X y Index register Y ZP, X Zero page X addressing mod~ s Stack pointer ZP, Y Zero page Y addressing mode PC Program counter ABS Absolute addressing mode PS Processor status register ABS, X Absolute:_ X addressing mode PCH 8 high-order bits of program counter ABS, Y Absolute Y addressing mode PCL 8 low-order bits of program counter IND Indirect absolute addressing mode ADH 8 high-order bits of address ADL 8 low-order bits of address ZP, IND Zero page indirect absolute addressing mode (ADH, ADL) Contents of memory at address indicated by ADH and ADL, in ADH is 8 high-order bits and ADL is 8 low- IND, X Indirect X addressing mode order bits. IND, Y Indirect Y addressing mode (00, AOL) Contents of address indicated by zero page ADL REL Relative addressing mode FF FF in Hexadecimal notation SP Special page addressing mode M Memory specified by address designation of any c Carry flag addressing mode z Zero flag M (X) Memory of address indicated by contents of index I Interrupt disable flag register X D Decimal mode flag M (S) Memory of address indicated by contents of stack B Break flag pointer T X-modified arithmetic mode flag 1 bit of accumulator v Overflow flag 1 bit of memory N Negative flag Opcode n Number of cycles :II Number of bytes 223 APPENDIX 8 APPENDIX 8. List of instruction codes ~o,-~ 0.decimal 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 notation 0 1 2 3 4 5 6 7 8 9 A B c D E F 0000 "" 0 BRK ·ORA JSR IND, X ZP, IND BBS 0, A - ORA ZP ASL ZP BBS 0,ZP PHP ORA IMM ASL A SEB O,A - ORA ASL ABS SEB 0, ZP ABS ORA BBC ORA ASL BBC ORA DEC CLB ORA ASL CLB 0001 1 BPL CLT - CLC - IND, Y 0, A ZP,X ZP,X O,ZP ABS, Y A 0,A ABS,X ABS, X 0, ZP JSR AND JSR BBS BIT AND AOL BBS AND ROL SEB BIT AND AOL SEB 0010 2 PLP ABS IND, X SP 1, A ZP ZP ZP 1, ZP IMM A 1, A ABS ABS ABS 1, ZP AND BBC AND ROL BBC AND INC CLB LDM AND ROL CLB 0011 3 BMI SET - SEC IND, Y 1, A ZP, X ZP,X 1, ZP ABS, Y A 1, A ZP ABS,X ABS,X 1, ZP EOR BBS COM EOR LSR BBS EOR LSR SEB JMP EOR LSR SEB 0100 4 RTI STP PHA IND, X 2, A ZP ZP ZP 2, ZP IMM A 2, A ABS ABS ABS 2,ZP EOR BBC EOR LSR BBC EOR CLB EOR LSR CLB 0101 5 BVC - - CLI - - IND, Y 2, A ZP, X ZP,X 2, ZP ABS, Y 2, A ABS,X ABS,X 2,ZP ADC BBS TST ADC ROA BBS ADC ROA SEB JMP ADC ROA SEB 0110 6 ATS MUL PLA IND, X 3, A ZP ZP ZP 3, ZP IMM A 3, A IND ABS ABS 3, ZP ADC BBC ADC ROR BBC ADC CLB ADC ROR CLB 0111 7 BVS - - SEI - - IND, Y 3, A ZP, X ZP, X 3, ZP ABS, Y 3, A ABS,X ABS, X 3, ZP STA RAF BBS STY STA STX BBS SEB STY STA STX SEB 1000 8 BRA DEY - TXA IND, X ZP 4,A ZP ZP ZP 4, ZP 4, A ABS ABS ABS 4,ZP STA BBC STY STA STX BBC STA CLB STA CLB 1001 9 BCC - TYA TXS - - IND, Y 4,A ZP, X ZP,X ZP, Y 4, ZP ABS, Y 4,A ABS,X 4, ZP LDY LDA LDX BBS LDY LDA LDX BBS LDA SEB LDY LDA LDX SEB 1010 A TAY TAX IMM IND, X IMM 5, A ZP ZP ZP 5, ZP IMM 5,A ABS ABS ABS 5, ZP LDA JMP BBC LOY LOA LOX BBC LOA CLB LDY LDA LDX CLB 1011 B BCS CLV TSX IND, Y ZP, IND 5, A ZP,X ZP, X ZP, Y 5, ZP ABS,Y 5, A ABS,X ABS,X ABS,Y 5, ZP CPY CMP BBS CPY CMP DEC BBS CMP SEB CPY CMP DEC SEB 1100 c WIT INY DEX IMM IND,X 6,A ZP ZP ZP 6,ZP IMM 6,A ABS ABS ABS 6, ZP CMP BBC CMP DEC BBC CMP CLB CMP DEC CLB 1101 D BNE - - GLD - - IND, Y 6, A ZP, X ZP, X 6,ZP ABS,Y 6,A ABS,X ABS,X 6, ZP CPX SBC BBS CPX SBC FST BBS SBC SEB CPX SBC INC SEB 1110 E DIV (Note2) INX NOP IMM IND, X 7,A ZP ZP DIV 7, ZP IMM 7,A ABS ABS ABS 7, ZP SBC BBC SBC INC BBC SBC CLB SBC INC CLB 1111 F BEQ - - SED - - IND, Y 7,A ZP, X ZP, X 7, ZP ABS,Y 7, A ABS, X ABS,X 7, ZP 224 APPENDIX 9 APPENDIX 9. Mask ROM ordering method Please send the following data for mask orders. • mask ROM order confirmation form • mark specification form • ROM data······ EPROM 3 sets 225 APPENDIX 9 GZZ-SH00-95A <7580 > SERIES MELPS 740 MASK ROM ORDER CONFIRMATION FORM I Mask ROM number I SINGLE-CHIP MICROCOMPUTER M37450M2-XXXSP/FP Date: MITSUBISHI ELECTRIC Section head Supervisor ii s!_g_nature slg_nature 'Cii 0 Cll er: Note : Please fill in all items marked*. Responsible TEL officer Supervisor Company Cll Cll 0 ~ name ( ) c ::l t1S 10 Customer ::l c Date Date: -"'·-"' "' 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 masks based in this data. We shall assume the responsibility for errors only if the mask ROM data on the products we pro- duce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. Microcomputer name : D M37450M2-XXXSP D M37450M2-XXXFP Checksum code for entire EPROM areas I~-~-~-~-~ (hexadecimal notation) EPROM type D 2764 D 27128 D 27256 ~0000 10001 4K ~- 3000--, 4K -0~ 7000 - 1FFF_j 3FFF _J 7FFF __1K Set "FF16" in the shaded area. * 2 . Mark specification Mark specification must be submitted using the correct form for the type package being ordered fill out the appropriate mark specification form (64P4B for M37450M2-XXXSP; 80P6 for M37450M2-XXXFP) and attach to the mask ROM confirmation form. * 3 . Comments 226 APPENDIX 9 GZZ-SH00-99A <7580 > I Mask ROM number I SERIES MELPS 740 MASK ROM ORDER CONFIRMATION FORM SINGLE-CHIP MICROCOMPUTER M37450M4-XXXSP/FP Date: MITSUBISHI ELECTRIC Section head ··,-- Supervisor a. ·a; s_i_g_nature signatur~_ " a: Cl> I 1 Note : Please fill in all items marked*. Responsible TEL officer Supervisor Company Cl> Cl> name ( ) "c:;:!~ Customer "'"'c: :::i Cl) Cl Cl).- Date - Cl) Date: 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 in this data. We shall assume the responsibility for errors only if the mask ROM data on the products we pro- duce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. Microcomputer name : D M37450M4-XXXSP D M37450M4-XXXFP Checksum code for entire EPROM areas '~-~----'--~-~ (hexadecimal notation) EPROM type D 2764 D 27128 D 27256 [:]00001 ~- 1FFF_j BK 2000--, BK ~0000 6000 ~ 3FFF_J ?FFF__l!,K Set "FF 16 " in the sh_aded area. * 2 . Mark specification Mark specification must be submitted using the correct form for the type package being ordered fill out the appropriate mark specification form (64P4B for M37450M4-XXXSP; 80P6 for M37450M4-XXXFP) and attach to the mask ROM confirmation form. * 3. Comments 227 APPENDIX 9 GZZ-SH01-00A <7680 > J Mask ROM number J SERIES MELPS 740 MASK ROM ORDER CONFIRMATION FORM SINGLE-CHIP MICROCOMPUTER M37450M8-XXXSP/FP Date: MITSUBISHI ELECTRIC Section head Supervisor 15. s_!_g__nature s_!si_nature 'iii (.) Q) er Note: Please fill in all items marked*. Responsible TEL officer Supervisor Company Q) Q) name ( ) g~ Customer "'"' "' c: "' Ol ~·u; Date Date: 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 in this data. We shall assume the responsibility for errors only if the mask ROM data on the products we pro- duce differ from this data. Thus, the customer must be especially careful in verifying the data contained in the EPROMs submitted. Microcomputer name : D M37450M8-XXXSP D M37450M8-XXXFP Checksum code for entire EPROM areas .... I___.__~--'---' (hexadecimal notation) EPROM type t--- D 27128 D 27256 8""1 ~0000 3FFFJ 16K 4000 I 7FFF _J 16K Set "FF 16" in the shaded area. * 2 . Mark specification Mark specification must be submitted using the correct form for the type package being ordered fill out the appropriate mark specification form (64P4B for M37450M8-XXXSP; 80P6 for M37450M8-XXXFP) and attach to the mask ROM confirmation form. * 3 . Comments 228 APPENDIX 9 64P48 (64-PIN SHRINK DIP) MARK SPECIFICATION FORM 1 . Standard Mitsubishi mark 2. Standard mark+Customer's parts number 3. Special mark required For 2 I I I I I I I I I 1-1-rr1-1 I I I I I -upto 19 characters 1 _....--, Mitsubishi IC catalog name J 2 -a. Mitsubishi logo required 2 -b. Mitsubishi logo not required Note 1 The mark field should be written to the right. 2 The identification mark can be up to 19 alphanumeric characters (except J, I and O) and hyphens. For 3 Note 3 If the special character fonts (ex. customer's trademark logo) must be used in special mark, a clean font original (ideally a logo drawing) must be submitted. 4 If special mark is to be printed, indicate the desired layout on the package drawing below. The layout will be duplicated as closely as technically possible. 229 APPENDIX 9 80P6 (80-PIN QFP) MARK SPECIFICATION FORM 1 . Standard Mitsubishi mark 2 . Standard mark+Customer's parts number 3 . Special mark required For 2 - Up to 12 characters Mitsubishi IC catalog name 2 -a. Mitsubishi logo required 2 -b. Mitsubishi logo not required Note 1 The mark field should be written to the right. 2 The identification mark can be up to 12 alphanumeric characters (except J, I and 0) and hyphens. For 3 Note 3 If the special character fonts (ex. customer's trademark logo) must be used in special mark, a clean font original (ideally a logo drawing) must be submitted. 4 If special mark is to be printed, indicate the desired layout on the package drawing below. The layout will be duplicated as closely as technically possible. 230 APPENDIX 10 APPENDIX 10. M60014-0120FP Outline The M60014-012FP is a 2-micron CMOS gate array. As LSI Pin cofiguration for CPU 1/0 interfaces, it emulates ports PO, P1 and P2 of the M37450 in microprocessor mode. This gate array operates on a 5V power supply and can .connect directly to the M37450 data bus and address bus. It has 40 1/0 ports, these ports being assigned in groups of IQQ?- I 3 to 5 addresses. As with the MELPS 740 series 1/0 ports, RD- 2 they can be defined in 1-bit units as input and output ports. WR- 3 AST- 4 10 10- 5 Features 10 11- 6 10 12-++ 7 10 13++ B • 5V power supply 10 14- 9 • Four address decode ouptuts (for EPROM, RAMX2, and 10 15- 10 10 16- 11 54 ~ABOS EEPROM) lo17- 12 M60014-0120FP 53 -WMCS • Port addresses selectable from a choice of four Voo Vss • Direct connection to M37450 QFP type (can not for DIP 10 20- 14 51 ~ABO? 10 21- is SD ~AB06 type) 10 22- 16 49 ~AB05 • No-wait connection to M37450 in 8MHz operation 10 23- 17 10 24- is • Forty built-in ports with almost similar electrical charac- 10 25- 19 teristics to M37 450 1/0 ports 10 26++ 20 10 27- 21 GND 43 - RACB Application N.U 42 - EECB 41 -ROCB 1/0 port expansion when the M37450 and the MELPS 740 series with built-in CMOS output and TTL input 1/0 ports are in microporocessor mode. 231 APPENDIX 10 Block diagram RD ROCS WR RAGS RST EECS ASL1 WMCS ASLO 104 1047 AB14 1046 1045 Data register 1044 AB11 directional 1043 1042 register control 1041 1040 8 1037 103 1036 1035 1034 Data register 1033 directional 1032 register control 1031 1030 8 1027 102 1026 1025 Data register 1024 Data bus 1/0 1023 control buffer directional 1022 register control 1021 1020 8 8 1017 101 1016 I 1015 GV~~~ 1014 Data register 1013 directional 1012 register control 1011 I 1010 8 I 100 1007 1006 1005 1004 Data register 1003 I I directional register control 1002 __ 1001 L ---- a_ _ _ _ _ _ _ __J 1000 232 APPENDIX 10 Function outline The 40 bits of the 1/0 pins are divided into five groups of 8 bits. These function as CMOS output and TTL input ports. As shown in Table 7.1, port 100 is treated as input address OOD0 16 when ASL1 =O and ASLO= 1. Port 100 has a directional reg- ister (OOD1 16 ) allowing each 1/0 bit to be individually programmed as input or ouptut as with the MELPS 740. Similarly, when ASL 1=O and ASLO= 1: • Port 101 is treated as input address OOD2 16 and has a directional register at address OOD3 16 . • port 102 is treated as input address OOD4 16 and has a directional retister at address OOD5 16 . • Port 103 is treated as input address OOD6 16 and has a directional register at address OOD7 16 . • Port 104 is treated as input addres OOD8 16 and has a directional register at address OOD9 16 . With ASL 1 and ASLO, addresses A7 to A4 can be selected from C 16 , D16 , E16 , or F16 . If the RST pin is input "H", all 1/0 pins are initialized as input ports. Four output pins are for chip-select of external memory. ROCS is the ROM chip select and selects a 32K8 area (decodes 8000wFFFF16 ). RAGS is the RAM chip select and selectes a 5128 area (decodes 0000w01 FF16 ). EECS is the EEPROM chip select and selects a 5128 area (decodes 0200w03FF 16 ). WMCS is the RAM chip select and selects a 32K8 area (decodes 0000w7FFF16 ). Functions [Input pins] • RD (read) input When this pin is "L" and the addresses of the port are decoded, the content of this port is output to data bus. •WR (write) When this pin is "L" and the addresses of the port are decoded, input the data from the data bus and latches the data in the port latch. • ABOO~AB15 (address) input These are used to select from 100, 102, 103 and 104 and to generate the chip-select output. • RST (reset) input Clear the data latch of the port and set the directional register when this port is "H". • ALS1, ALSO (address selector) input Select the 12 most significant bits of the addresses of ports 100~ 104 as shown in Table 7.1. (1/0 pins] • D807-D800 (data bus) 1/0 Input and latch data using WR. Output data of the port address has been decoded using RD. • 1007-1000 (ports) 1/0 These 1/0 ports are decoded using the 12 most significant bits of the address and ASL 1 and ASLO. The 4 least significant bits of the address are decoded as follows: 0000 8 as data register and 0001 8 as directional register. • 1017-1010 (ports) 1/0 These 110 ports are decoded using the 12 most significant bits of the address and ASL 1 and ASLO. The 4 least significant bits of the address are decoded as follows: 0010 8 as data register and 0011 8 as directional register. • 1027-1020 (ports) 1/0 These 1/0 ports are decoded using the 12 most significant bits of the address and ASL 1 and ASLO. the 4 least significant bits of the address are decoded as follows: 0100 8 as data register and 0101 8 as directional register. • 1037-1030 (ports) 1/0 These 1/0 ports are decoded using the 12 most significant bits of the address and ASL 1 and ASLO. The 4 least significant bits of the address are decoded as follows: 0110 8 as data register and 0111 8 as directional register. 233 APPENDIX 10 • 1047-1040 (ports) 1/0 These 1/0 ports are decoded using the 12 most significant bits of the address and ASL 1 and ASLO. The 4 least significant bits of the address are decoded as follows: 1000 8 as data register and 1001 8 as directional register. [Output pins] • ROCS (chip select) output This chip select is set for ROM and selects a 32KB area (decodes 8000 16 -FFFF 16 ). • RAGS (chip select) output This chip select is set for RAM and selects a 512B area (decodes 000016-01 FF 16 ). • EECS (chip select) output This chip select is set for the EEPROM and selects a 5126 area (decodes 0200 16 -03FF 16 ). • WMCS (chip select) output Thsi chip select is set for the ROM and' selects a 32KB area (decodes 000016-7FFF 16 ). Add.ress select table ASL1 ALSO AB15-AB08 A7 A6 A5 A4 A3-AO 0 0 o-o 1 1 0 0 x-x (OOCX 16 ) 0 1 o~o 1 1 0 1 x~x (OODX 16 ) - 1 0 o-o 1 1 I 1 0 x~x (OOEX 16 ) 1 1 o~o 1 1 1 1 x~x (OOFX 16 ) 234 APPENDIX 10 Address map ASL1=0, ASLO=O ASL1=0 ASL0=1 OOC010 100 data register 000010 100 data register ooc110 100 directional register OOD110 100 directional register ooc2 16 101 data register 000210 I01 data register OOC310 101 directional register 0003,. !01 directional register OOC4 16 1_02 da11l...'_':2ister _ _ 000410 I02 data register OOC510 I02 directional register 000510 102 directional register 01FF16 OOC610 103 data register 0006,. 103 data register 020010 ooc1, 0 103 directional register 000710 I03 directional register ooca10 104 data register oooa10 104 data register OOC910 I04 directional register 000910 104 directional register 03FF10 ASL1=0 ASLO=O ASL1=0 ASL0=1 ooeo,. 100 data register OOF010 100 data register OOE110 100 directional register OOF110 100 directional register 7FFF 16 800010 OOE210 101 data register OOF2,. 101 data register OOE316 101 directional register OOF3,. 101 directional register OOE4 1o 102 data register OOF415 102 data register ooes,o 102 directional register OOF515 102 directional register OOE6,. 103 data register OOF610 103 data register OOE710 103 directional register OOF715 103 directional register OOE8,. 104 data register OOFB10 104 data register OOE910 104 directional register OOF910 104 directional register FFFF16 RAGS decode area EEGS decode area WMGS decode area ROGS decode area is dynamically changed by ASL 1 and ASLO. When this area is decoded, overlapping RAGS and WMGS output "H". Note 1. If M37450M2-XXXFP and M60014-0120FP are set to address selectors ASL1 =O and ASL0=1 then connected, ports PO, P1 and P2 of M37450 emulate ports 100, 101 and 102 of M60014-0120FP. Ports 103 and 104, which cor- respond to M37450 ports P3 and P4 are also assigned to the M60014-0102FP, but 103 and 104 do not emulate P3 and P4. (Ports 103 and 104 of the M60014-0120FP output the same data as P3 and P4 when they are set as out- put ports, but they cannot be used as input ports because, when P3 and P4 are set as input ports, the data input to ports 103 and 104 is not read by the M37450.) Note 2. User cannot use the OOXA 16 -00XF 16 (X=G, 0, E, F) which are in the decoded area by ASL 1 and ASLO. 235 APPENDIX 10 Timing chart address Teehl max 28ns EECB Teelh max 18ns Twmhl max 21ns WMCS Twmlh max 25.5ns RAGS RST 236 APPENDIX 10 • at read operation address RD Trdd ..,,__ _ _ _ _ _ _-"" max 42ns DB • at write operation Twahd min 1Ons address Twr min 20ns f.E-------4----;;.i WR DB *PORTda max 45ns *PORTdi Tacdi K--------~..i max 52ns *PORTda at the time write to data register when the contents of the register is "1". *PORTdi at the time write to directional register when the contents of the register is "1". Electric characteristics Um its Symbol Parameter Condition Unit max. min. VIL Voo=SV f---=- ..~ 0. 8 input voltage (TTL interface) v V1H Voo=5V 2. 0 VaL Voo=5V 0. 1 output voltage v VaH lo=OmA 4. 9 ioL Vol =0.4V 6 output current mA ioH VoH=2.4V -4 237 CONTACT ADDRESSES FOR FURTHER INFORMATION JAPAN~===~· SOUTHWEST WEST GERMANY----·---- Semiconductor Marketing Division Mitsubishi Electronics America, Inc. Mitsubishi Electric Europe GmbH Mitsubishi Electric Corporation 991 Knox Street Headquarters: 2-3, Marunouchi 2-chome Torrance, CA 90502 Gothear Str. 8 Chiyoda-ku, Tokyo 100, Japan Telephone: (213) 515-3993 4030 Ratingen 1, West Germany Telex: 24532 MELCO J Facsimile: (213) 217-5781 Telex: 8585070 MED D Telephone: (03) 218-3473 Telephone: (02102) 4860 (03) 218-3499 SOUTH CENTRAL Facsimile: (02102) 486-115 Facsimile: (03) 214-5570 Mitsubishi Electronics America, Inc. 1501 Luna Road, Suite 124 Munich Office: Overseas Marketing Manager Carrollton, TX 75006 Arabellastra~e 31 Kita-ltami Works Telephone: (214) 484-1919 8000 MUnchen 81, West Germany 4-1, Mizuhara, ltami-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 Mitsubishi Electronics America, Inc. Facsimile: (0727) 72-2329 15612 Highway 7 #243 FRANCE- Minnetonka, MN 55345 Mitsubishi Electric Europe GmbH HONG KONG===~~===~ Telephone: (612) 938-7779 55, Avenue de Colmar MITSUBISHI ELECTRIC (H.K.) LTD. Facsimile: (612) 938-5125 92563 Rueil Malmaison Cedex 25 Floor, Leighton Centre, Telex: 632326 77, Leighton Road. Causeway Bay. NORTH CENTRAL Telephone: 47087871 Hong Kong Mitsubishi Electronics America, Inc. Facsimile: 47513622 Telex: 60800 MELCO HX 800 N. Bierman Circle Telephone: (5) 773901-3 Mt. Prospect, IL 60056 ITALY========== Facsimile: (5) 895-3104 Telephone: (312) 298-9223 Mitsubishi Electric Europe GmbH Facsimile: (312) 298-0567 Centro Direziona!e Colleoni SINGAPORE========= Palazzo Cassiopea 1 MELCO SALES SINGAPORE PTE. NORTHEAST 20041 Agrate Brianza I-Milano LTD. Mitsubishi Electronics America, Inc. Telephone: (039) 636011 230 Upper Bukit Timah Road # 03- 200 Unicorn Park Drive Facsimile: (039) 6360120 01/15 Woburn, MA 01801 Hock Soon Industrial Complex Telephone: (617) 932-5700 SWEDEN Singapore 2158 Facsimile: (617) 938-1075 Mitsubishi Electric Europe GmbH Telex: RS 20845 MELCO Lastbilsvagen 68 Telephone: 4695255 MID-ATLANTIC 5-19149 Sollentuna, Sweden Facsimile: 4695347 Mitsubishi 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 fl., Chung-Ling Bldg., Facsimile: (201) 469-1909 U.K. =========== 363, Sec. 2, Fu-Hsing S Road, Mitsubishi Electric (U.K.) Ltd. Taipei R.O.C. SOUTH ATLANTIC Travellers Lane Telephone: (02) 735-3030 Mitsubishi Electronics America, Inc. Hatfield Facsimile: (02) 735-6771 2500 Gateway Center Blvd., Suite 300 Herts AL10 8XB, England, U.K. 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 Mitsubishi Electric Australia Pty. Ltd. Mitsubishi Electronics America, Inc. Mitsubishi Electronics America, Inc. 73-75, Epping Road, North Ryde, 1050 East Arques Avenue Town Executive Center P.O. Box 1567, Macquarie Centre, Sunnyvale, CA 94086 6100 Glades Road #210 N.S.W., 2113, Australia Telephone: (408) 730-5900 Boca Raton, FL 33433 Telex: MESYD AA 26614 Facsimile: (408) 730-4972 Telephone: (407) 487-7747 Telephone: (02) (888) 5777 Facsimile: (407) 487-2046 Facsimile: (02) (887) 3635 SAN DIEGO Mitsubishi Electronics America, Inc. CANADA 11545 West Bernardo Court Mitsubishi Electronics America, Inc. Suite 100 6185 Ordan Drive, Unit # 110 San Diego, CA 92128 Mississauga, Ontario, Canada L5T 2E1 Telephone: (619) 592-1445 Telephone: (416) 670-8711 Facsimile: (619) 592-0242 Facsimile: (416) 670-8715 DENVER Mitsubishi Electronics America, Inc. Mitsubishi Electronics America, Inc. 300 March Road, Suite 302 4600 South Ulster Street Kanata, Ontario, Canada K2K 2E2 Metropoint Building, 7th Floor Telephone: (416) 670-8711 Denver, CO 80237 Facsimile: (416) 670-8715 Telephone: (303) 740-6775 Facsimile: (303) 694-0613 MITSUBISHI SEMICONDUCTORS USER'S MANUAL M37450M2-XXXSP/FP Oct. First Edition 1989 Editioned by Committee of editing of Mitsubishi Semiconductor USER'S MANUAL Published by Mitsubishi Electric Corp., Semiconductor Marketing Division This book, or parts thereof, may not be reproduced in any form without permission of Mitsubishi Electric Corporation. ©1989 MITSUBISHI ELECTRIC CORPORATION MITSUBISHI SEMICONDUCTORS M374SOM2-XXXSP/FP ~MITSUBISHI ELECTRIC CORPORATION HEAD OFFICE MITSUBISHI DENKI BLDG . MARUNOUCHI , TOKYO 100 TELEX J24532 CABLE MELCO TOKYO These products at technologies are subject to Japanese and/at COCOM strategic restrictions, and diversion contrary thereto is prohibited. H-E0040-A Kl-8910 Printed in Japan ( ROD ) New publication , effective Oct. 1989. © 1989 MITSUBISHI ELECTRIC CORPORATION Specifications subject to change without notice.